Skip to content

Commit

Permalink
Remove internal platform types exports (elastic#50427)
Browse files Browse the repository at this point in the history
* remove exports of internal core types

* updates documentation

* rename internal types file
  • Loading branch information
pgayvallet authored Nov 13, 2019
1 parent 6c3ee58 commit e6ea2bf
Show file tree
Hide file tree
Showing 19 changed files with 126 additions and 136 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ returns `basePath` value, specific for an incoming request.
<b>Signature:</b>

```typescript
get: (request: LegacyRequest | KibanaRequest<unknown, unknown, unknown>) => string;
get: (request: KibanaRequest<unknown, unknown, unknown> | LegacyRequest) => string;
```
4 changes: 2 additions & 2 deletions docs/development/core/server/kibana-plugin-server.basepath.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ export declare class BasePath

| Property | Modifiers | Type | Description |
| --- | --- | --- | --- |
| [get](./kibana-plugin-server.basepath.get.md) | | <code>(request: LegacyRequest &#124; KibanaRequest&lt;unknown, unknown, unknown&gt;) =&gt; string</code> | returns <code>basePath</code> value, specific for an incoming request. |
| [get](./kibana-plugin-server.basepath.get.md) | | <code>(request: KibanaRequest&lt;unknown, unknown, unknown&gt; &#124; LegacyRequest) =&gt; string</code> | returns <code>basePath</code> value, specific for an incoming request. |
| [prepend](./kibana-plugin-server.basepath.prepend.md) | | <code>(path: string) =&gt; string</code> | Prepends <code>path</code> with the basePath. |
| [remove](./kibana-plugin-server.basepath.remove.md) | | <code>(path: string) =&gt; string</code> | Removes the prepended basePath from the <code>path</code>. |
| [serverBasePath](./kibana-plugin-server.basepath.serverbasepath.md) | | <code>string</code> | returns the server's basePath<!-- -->See [BasePath.get](./kibana-plugin-server.basepath.get.md) for getting the basePath value for a specific request |
| [set](./kibana-plugin-server.basepath.set.md) | | <code>(request: LegacyRequest &#124; KibanaRequest&lt;unknown, unknown, unknown&gt;, requestSpecificBasePath: string) =&gt; void</code> | sets <code>basePath</code> value, specific for an incoming request. |
| [set](./kibana-plugin-server.basepath.set.md) | | <code>(request: KibanaRequest&lt;unknown, unknown, unknown&gt; &#124; LegacyRequest, requestSpecificBasePath: string) =&gt; void</code> | sets <code>basePath</code> value, specific for an incoming request. |

## Remarks

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ sets `basePath` value, specific for an incoming request.
<b>Signature:</b>

```typescript
set: (request: LegacyRequest | KibanaRequest<unknown, unknown, unknown>, requestSpecificBasePath: string) => void;
set: (request: KibanaRequest<unknown, unknown, unknown> | LegacyRequest, requestSpecificBasePath: string) => void;
```
32 changes: 3 additions & 29 deletions src/core/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,11 @@
* @packageDocumentation
*/

import {
ElasticsearchServiceSetup,
InternalElasticsearchServiceSetup,
IScopedClusterClient,
} from './elasticsearch';
import { InternalHttpServiceSetup, HttpServiceSetup } from './http';
import { ElasticsearchServiceSetup, IScopedClusterClient } from './elasticsearch';
import { HttpServiceSetup } from './http';
import { PluginsServiceSetup, PluginsServiceStart, PluginOpaqueId } from './plugins';
import { ContextSetup } from './context';
import { SavedObjectsServiceStart } from './saved_objects';

import {
InternalUiSettingsServiceSetup,
IUiSettingsClient,
UiSettingsServiceSetup,
} from './ui_settings';
import { IUiSettingsClient, UiSettingsServiceSetup } from './ui_settings';
import { SavedObjectsClientContract } from './saved_objects/types';

export { bootstrap } from './bootstrap';
Expand Down Expand Up @@ -177,7 +167,6 @@ export {
export {
IUiSettingsClient,
UiSettingsParams,
InternalUiSettingsServiceSetup,
UiSettingsType,
UiSettingsServiceSetup,
UserProvidedValues,
Expand Down Expand Up @@ -251,19 +240,4 @@ export interface CoreSetup {
*/
export interface CoreStart {} // eslint-disable-line @typescript-eslint/no-empty-interface

/** @internal */
export interface InternalCoreSetup {
context: ContextSetup;
http: InternalHttpServiceSetup;
elasticsearch: InternalElasticsearchServiceSetup;
uiSettings: InternalUiSettingsServiceSetup;
}

/**
* @internal
*/
export interface InternalCoreStart {
savedObjects: SavedObjectsServiceStart;
}

export { ContextSetup, PluginsServiceSetup, PluginsServiceStart, PluginOpaqueId };
39 changes: 39 additions & 0 deletions src/core/server/internal_types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import { InternalElasticsearchServiceSetup } from './elasticsearch';
import { InternalHttpServiceSetup } from './http';
import { InternalUiSettingsServiceSetup } from './ui_settings';
import { ContextSetup } from './context';
import { SavedObjectsServiceStart } from './saved_objects';

/** @internal */
export interface InternalCoreSetup {
context: ContextSetup;
http: InternalHttpServiceSetup;
elasticsearch: InternalElasticsearchServiceSetup;
uiSettings: InternalUiSettingsServiceSetup;
}

/**
* @internal
*/
export interface InternalCoreStart {
savedObjects: SavedObjectsServiceStart;
}
3 changes: 2 additions & 1 deletion src/core/server/legacy/legacy_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
import { combineLatest, ConnectableObservable, EMPTY, Observable, Subscription } from 'rxjs';
import { first, map, publishReplay, tap } from 'rxjs/operators';
import { CoreService } from '../../types';
import { InternalCoreSetup, InternalCoreStart, CoreSetup, CoreStart } from '../';
import { CoreSetup, CoreStart } from '../';
import { InternalCoreSetup, InternalCoreStart } from '../internal_types';
import { SavedObjectsLegacyUiExports } from '../types';
import { Config } from '../config';
import { CoreContext } from '../core_context';
Expand Down
2 changes: 1 addition & 1 deletion src/core/server/plugins/plugins_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { PluginWrapper } from './plugin';
import { DiscoveredPlugin, DiscoveredPluginInternal, PluginName } from './types';
import { PluginsConfig, PluginsConfigType } from './plugins_config';
import { PluginsSystem } from './plugins_system';
import { InternalCoreSetup } from '..';
import { InternalCoreSetup } from '../internal_types';

/** @public */
export interface PluginsServiceSetup {
Expand Down
38 changes: 4 additions & 34 deletions src/core/server/server.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -449,11 +449,11 @@ export interface AuthToolkit {
export class BasePath {
// @internal
constructor(serverBasePath?: string);
get: (request: LegacyRequest | KibanaRequest<unknown, unknown, unknown>) => string;
get: (request: KibanaRequest<unknown, unknown, unknown> | LegacyRequest) => string;
prepend: (path: string) => string;
remove: (path: string) => string;
readonly serverBasePath: string;
set: (request: LegacyRequest | KibanaRequest<unknown, unknown, unknown>, requestSpecificBasePath: string) => void;
set: (request: KibanaRequest<unknown, unknown, unknown> | LegacyRequest, requestSpecificBasePath: string) => void;
}

// Warning: (ae-forgotten-export) The symbol "BootstrapArgs" needs to be exported by the entry point index.d.ts
Expand Down Expand Up @@ -712,36 +712,6 @@ export interface IndexSettingsDeprecationInfo {
[indexName: string]: DeprecationInfo[];
}

// @internal (undocumented)
export interface InternalCoreSetup {
// (undocumented)
context: ContextSetup;
// Warning: (ae-forgotten-export) The symbol "InternalElasticsearchServiceSetup" needs to be exported by the entry point index.d.ts
//
// (undocumented)
elasticsearch: InternalElasticsearchServiceSetup;
// Warning: (ae-forgotten-export) The symbol "InternalHttpServiceSetup" needs to be exported by the entry point index.d.ts
//
// (undocumented)
http: InternalHttpServiceSetup;
// (undocumented)
uiSettings: InternalUiSettingsServiceSetup;
}

// @internal (undocumented)
export interface InternalCoreStart {
// Warning: (ae-forgotten-export) The symbol "SavedObjectsServiceStart" needs to be exported by the entry point index.d.ts
//
// (undocumented)
savedObjects: SavedObjectsServiceStart;
}

// @internal (undocumented)
export interface InternalUiSettingsServiceSetup {
asScopedToClient(savedObjectsClient: SavedObjectsClientContract): IUiSettingsClient;
register(settings: Record<string, UiSettingsParams>): void;
}

// @public
export interface IRouter {
delete: <P extends ObjectType, Q extends ObjectType, B extends ObjectType>(route: RouteConfig<P, Q, B>, handler: RequestHandler<P, Q, B>) => void;
Expand Down Expand Up @@ -839,7 +809,7 @@ export interface LegacyRequest extends Request {

// @public @deprecated (undocumented)
export interface LegacyServiceSetupDeps {
// Warning: (ae-incompatible-release-tags) The symbol "core" is marked as @public, but its signature references "InternalCoreSetup" which is marked as @internal
// Warning: (ae-forgotten-export) The symbol "InternalCoreSetup" needs to be exported by the entry point index.d.ts
//
// (undocumented)
core: InternalCoreSetup & {
Expand All @@ -851,7 +821,7 @@ export interface LegacyServiceSetupDeps {

// @public @deprecated (undocumented)
export interface LegacyServiceStartDeps {
// Warning: (ae-incompatible-release-tags) The symbol "core" is marked as @public, but its signature references "InternalCoreStart" which is marked as @internal
// Warning: (ae-forgotten-export) The symbol "InternalCoreStart" needs to be exported by the entry point index.d.ts
//
// (undocumented)
core: InternalCoreStart & {
Expand Down
3 changes: 2 additions & 1 deletion src/core/server/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ import { config as uiSettingsConfig } from './ui_settings';
import { mapToObject } from '../utils/';
import { ContextService } from './context';
import { SavedObjectsServiceSetup } from './saved_objects/saved_objects_service';
import { RequestHandlerContext, InternalCoreSetup } from '.';
import { RequestHandlerContext } from '.';
import { InternalCoreSetup } from './internal_types';

const coreId = Symbol('core');

Expand Down
20 changes: 9 additions & 11 deletions x-pack/legacy/plugins/apm/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,10 @@
import { i18n } from '@kbn/i18n';
import { Server } from 'hapi';
import { resolve } from 'path';
import {
InternalCoreSetup,
PluginInitializerContext
} from '../../../../src/core/server';
import { PluginInitializerContext } from '../../../../src/core/server';
import { LegacyPluginInitializer } from '../../../../src/legacy/types';
import mappings from './mappings.json';
import { plugin } from './server/new-platform/index';
import { plugin } from './server/new-platform';

export const apm: LegacyPluginInitializer = kibana => {
return new kibana.Plugin({
Expand Down Expand Up @@ -111,12 +108,13 @@ export const apm: LegacyPluginInitializer = kibana => {
});

const initializerContext = {} as PluginInitializerContext;
const core = {
http: {
server
}
} as InternalCoreSetup;
plugin(initializerContext).setup(core);
const legacySetup = {
server
};
plugin(initializerContext).setup(
server.newPlatform.setup.core,
legacySetup
);
}
});
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,26 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { InternalCoreSetup } from 'src/core/server';
import { CoreSetup } from 'src/core/server';
import { getSavedObjectsClient } from '../helpers/saved_objects_client';
import { APM_TELEMETRY_DOC_ID, createApmTelementry } from './apm_telemetry';
import { LegacySetup } from '../../new-platform/plugin';

export interface CoreSetupWithUsageCollector extends InternalCoreSetup {
http: InternalCoreSetup['http'] & {
server: {
usage: {
collectorSet: {
makeUsageCollector: (options: unknown) => unknown;
register: (options: unknown) => unknown;
};
export interface LegacySetupWithUsageCollector extends LegacySetup {
server: LegacySetup['server'] & {
usage: {
collectorSet: {
makeUsageCollector: (options: unknown) => unknown;
register: (options: unknown) => unknown;
};
};
};
}

export function makeApmUsageCollector(core: CoreSetupWithUsageCollector) {
const { server } = core.http;

export function makeApmUsageCollector(
core: CoreSetup,
{ server }: LegacySetupWithUsageCollector
) {
const apmUsageCollector = server.usage.collectorSet.makeUsageCollector({
type: 'apm',
fetch: async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { InternalCoreSetup } from 'src/core/server';
import { CoreSetup } from 'src/core/server';
import { CallCluster } from '../../../../../../../../src/legacy/core_plugins/elasticsearch';
import { getApmIndices } from '../apm_indices/get_apm_indices';
import { LegacySetup } from '../../../new-platform/plugin';

export async function createApmAgentConfigurationIndex(
core: InternalCoreSetup
core: CoreSetup,
{ server }: LegacySetup
) {
try {
const { server } = core.http;
const indices = await getApmIndices(server);
const index = indices['apm_oss.apmAgentConfigurationIndex'];
const { callWithInternalUser } = server.plugins.elasticsearch.getCluster(
Expand Down
17 changes: 11 additions & 6 deletions x-pack/legacy/plugins/apm/server/new-platform/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,21 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { InternalCoreSetup } from 'src/core/server';
import { Server } from 'hapi';
import { CoreSetup } from 'src/core/server';
import { makeApmUsageCollector } from '../lib/apm_telemetry';
import { CoreSetupWithUsageCollector } from '../lib/apm_telemetry/make_apm_usage_collector';
import { LegacySetupWithUsageCollector } from '../lib/apm_telemetry/make_apm_usage_collector';
import { createApmAgentConfigurationIndex } from '../lib/settings/agent_configuration/create_agent_config_index';
import { createApmApi } from '../routes/create_apm_api';

export interface LegacySetup {
server: Server;
}

export class Plugin {
public setup(core: InternalCoreSetup) {
createApmApi().init(core);
createApmAgentConfigurationIndex(core);
makeApmUsageCollector(core as CoreSetupWithUsageCollector);
public setup(core: CoreSetup, __LEGACY: LegacySetup) {
createApmApi().init(core, __LEGACY);
createApmAgentConfigurationIndex(core, __LEGACY);
makeApmUsageCollector(core, __LEGACY as LegacySetupWithUsageCollector);
}
}
Loading

0 comments on commit e6ea2bf

Please sign in to comment.