From 468de51153f3a75e822d09c642b4998f5830494d Mon Sep 17 00:00:00 2001 From: Pierre Gayvallet Date: Thu, 26 Mar 2020 10:49:05 +0100 Subject: [PATCH] Add plugin start contract to getStartServices return value (#61216) * add plugin own contract as third element of getStartServices result * adapt plugins code * update tests * revert unknown to use void again * update generated doc * fix UT * update mock to allow non-object `pluginStartContract` * add @typeParam documentation --- ...n-core-public.coresetup.getstartservices.md | 2 +- .../kibana-plugin-core-public.coresetup.md | 4 ++-- ...ibana-plugin-core-public.legacycoresetup.md | 2 +- .../kibana-plugin-core-public.plugin.setup.md | 4 ++-- ...plugin-core-public.startservicesaccessor.md | 2 +- ...n-core-server.coresetup.getstartservices.md | 2 +- .../kibana-plugin-core-server.coresetup.md | 4 ++-- ...plugin-core-server.startservicesaccessor.md | 2 +- examples/alerting_example/public/plugin.tsx | 9 +++------ examples/bfetch_explorer/public/plugin.tsx | 5 ++++- examples/embeddable_examples/public/index.ts | 13 +++++++++++-- examples/embeddable_examples/public/plugin.ts | 4 ++-- examples/search_explorer/public/plugin.tsx | 2 +- src/core/public/index.ts | 18 ++++++++++++------ src/core/public/legacy/legacy_service.ts | 4 ++-- src/core/public/mocks.ts | 15 ++++++++++++--- src/core/public/plugins/plugin.test.ts | 7 ++++++- src/core/public/plugins/plugin.ts | 8 ++++---- src/core/public/plugins/plugins_service.ts | 2 +- src/core/public/public.api.md | 10 +++++----- src/core/server/index.ts | 15 ++++++++++----- src/core/server/legacy/legacy_service.ts | 2 +- src/core/server/mocks.ts | 12 +++++++++--- .../integration_tests/plugins_service.test.ts | 14 ++++++++++---- src/core/server/plugins/plugin.test.ts | 6 +++++- src/core/server/plugins/plugin.ts | 4 ++-- src/core/server/server.api.md | 6 +++--- .../input_control_vis/public/plugin.ts | 4 ++-- .../kibana/public/discover/plugin.ts | 2 +- .../vis_type_timelion/public/plugin.ts | 2 +- .../vis_type_vislib/public/plugin.ts | 4 ++-- .../core_plugins/vis_type_xy/public/plugin.ts | 4 ++-- src/plugins/home/public/plugin.ts | 4 +++- x-pack/plugins/actions/server/plugin.ts | 2 +- x-pack/plugins/alerting/server/plugin.ts | 2 +- x-pack/plugins/ingest_manager/public/plugin.ts | 7 +++++-- x-pack/plugins/ml/public/index.ts | 15 +++++++++++++-- x-pack/plugins/ml/public/plugin.ts | 2 +- x-pack/plugins/monitoring/server/plugin.ts | 4 ++-- .../account_management_app.test.ts | 2 +- .../logged_out/logged_out_app.test.ts | 2 +- .../authentication/login/login_app.test.ts | 2 +- .../overwritten_session_app.test.ts | 2 +- x-pack/plugins/security/public/index.ts | 17 +++++++++++++---- .../management/spaces_management_app.test.tsx | 2 +- .../capabilities/capabilities_switcher.test.ts | 1 + .../plugins/resolver_test/public/index.ts | 13 +++++++++++-- 47 files changed, 178 insertions(+), 93 deletions(-) diff --git a/docs/development/core/public/kibana-plugin-core-public.coresetup.getstartservices.md b/docs/development/core/public/kibana-plugin-core-public.coresetup.getstartservices.md index e4fec4eae31b..8664ad0e2a0e 100644 --- a/docs/development/core/public/kibana-plugin-core-public.coresetup.getstartservices.md +++ b/docs/development/core/public/kibana-plugin-core-public.coresetup.getstartservices.md @@ -9,5 +9,5 @@ Signature: ```typescript -getStartServices: StartServicesAccessor; +getStartServices: StartServicesAccessor; ``` diff --git a/docs/development/core/public/kibana-plugin-core-public.coresetup.md b/docs/development/core/public/kibana-plugin-core-public.coresetup.md index c039bc19348c..870fa33dce90 100644 --- a/docs/development/core/public/kibana-plugin-core-public.coresetup.md +++ b/docs/development/core/public/kibana-plugin-core-public.coresetup.md @@ -9,7 +9,7 @@ Core services exposed to the `Plugin` setup lifecycle Signature: ```typescript -export interface CoreSetup +export interface CoreSetup ``` ## Properties @@ -19,7 +19,7 @@ export interface CoreSetup | [application](./kibana-plugin-core-public.coresetup.application.md) | ApplicationSetup | [ApplicationSetup](./kibana-plugin-core-public.applicationsetup.md) | | [context](./kibana-plugin-core-public.coresetup.context.md) | ContextSetup | [ContextSetup](./kibana-plugin-core-public.contextsetup.md) | | [fatalErrors](./kibana-plugin-core-public.coresetup.fatalerrors.md) | FatalErrorsSetup | [FatalErrorsSetup](./kibana-plugin-core-public.fatalerrorssetup.md) | -| [getStartServices](./kibana-plugin-core-public.coresetup.getstartservices.md) | StartServicesAccessor<TPluginsStart> | [StartServicesAccessor](./kibana-plugin-core-public.startservicesaccessor.md) | +| [getStartServices](./kibana-plugin-core-public.coresetup.getstartservices.md) | StartServicesAccessor<TPluginsStart, TStart> | [StartServicesAccessor](./kibana-plugin-core-public.startservicesaccessor.md) | | [http](./kibana-plugin-core-public.coresetup.http.md) | HttpSetup | [HttpSetup](./kibana-plugin-core-public.httpsetup.md) | | [injectedMetadata](./kibana-plugin-core-public.coresetup.injectedmetadata.md) | {
getInjectedVar: (name: string, defaultValue?: any) => unknown;
} | exposed temporarily until https://github.com/elastic/kibana/issues/41990 done use \*only\* to retrieve config values. There is no way to set injected values in the new platform. Use the legacy platform API instead. | | [notifications](./kibana-plugin-core-public.coresetup.notifications.md) | NotificationsSetup | [NotificationsSetup](./kibana-plugin-core-public.notificationssetup.md) | diff --git a/docs/development/core/public/kibana-plugin-core-public.legacycoresetup.md b/docs/development/core/public/kibana-plugin-core-public.legacycoresetup.md index 25387ff5ec8c..26220accbfaf 100644 --- a/docs/development/core/public/kibana-plugin-core-public.legacycoresetup.md +++ b/docs/development/core/public/kibana-plugin-core-public.legacycoresetup.md @@ -13,7 +13,7 @@ Setup interface exposed to the legacy platform via the `ui/new_platform` module. Signature: ```typescript -export interface LegacyCoreSetup extends CoreSetup +export interface LegacyCoreSetup extends CoreSetup ``` ## Remarks diff --git a/docs/development/core/public/kibana-plugin-core-public.plugin.setup.md b/docs/development/core/public/kibana-plugin-core-public.plugin.setup.md index 7ed0e056b390..7fa05588a330 100644 --- a/docs/development/core/public/kibana-plugin-core-public.plugin.setup.md +++ b/docs/development/core/public/kibana-plugin-core-public.plugin.setup.md @@ -7,14 +7,14 @@ Signature: ```typescript -setup(core: CoreSetup, plugins: TPluginsSetup): TSetup | Promise; +setup(core: CoreSetup, plugins: TPluginsSetup): TSetup | Promise; ``` ## Parameters | Parameter | Type | Description | | --- | --- | --- | -| core | CoreSetup<TPluginsStart> | | +| core | CoreSetup<TPluginsStart, TStart> | | | plugins | TPluginsSetup | | Returns: diff --git a/docs/development/core/public/kibana-plugin-core-public.startservicesaccessor.md b/docs/development/core/public/kibana-plugin-core-public.startservicesaccessor.md index 02e896a6b47e..ad53307d53d6 100644 --- a/docs/development/core/public/kibana-plugin-core-public.startservicesaccessor.md +++ b/docs/development/core/public/kibana-plugin-core-public.startservicesaccessor.md @@ -9,5 +9,5 @@ Allows plugins to get access to APIs available in start inside async handlers, s Signature: ```typescript -export declare type StartServicesAccessor = () => Promise<[CoreStart, TPluginsStart]>; +export declare type StartServicesAccessor = () => Promise<[CoreStart, TPluginsStart, TStart]>; ``` diff --git a/docs/development/core/server/kibana-plugin-core-server.coresetup.getstartservices.md b/docs/development/core/server/kibana-plugin-core-server.coresetup.getstartservices.md index ea8e610ee56d..1f326449156f 100644 --- a/docs/development/core/server/kibana-plugin-core-server.coresetup.getstartservices.md +++ b/docs/development/core/server/kibana-plugin-core-server.coresetup.getstartservices.md @@ -9,5 +9,5 @@ Signature: ```typescript -getStartServices: StartServicesAccessor; +getStartServices: StartServicesAccessor; ``` diff --git a/docs/development/core/server/kibana-plugin-core-server.coresetup.md b/docs/development/core/server/kibana-plugin-core-server.coresetup.md index b0eba8ac7806..29fdc37a8117 100644 --- a/docs/development/core/server/kibana-plugin-core-server.coresetup.md +++ b/docs/development/core/server/kibana-plugin-core-server.coresetup.md @@ -9,7 +9,7 @@ Context passed to the plugins `setup` method. Signature: ```typescript -export interface CoreSetup +export interface CoreSetup ``` ## Properties @@ -19,7 +19,7 @@ export interface CoreSetup | [capabilities](./kibana-plugin-core-server.coresetup.capabilities.md) | CapabilitiesSetup | [CapabilitiesSetup](./kibana-plugin-core-server.capabilitiessetup.md) | | [context](./kibana-plugin-core-server.coresetup.context.md) | ContextSetup | [ContextSetup](./kibana-plugin-core-server.contextsetup.md) | | [elasticsearch](./kibana-plugin-core-server.coresetup.elasticsearch.md) | ElasticsearchServiceSetup | [ElasticsearchServiceSetup](./kibana-plugin-core-server.elasticsearchservicesetup.md) | -| [getStartServices](./kibana-plugin-core-server.coresetup.getstartservices.md) | StartServicesAccessor<TPluginsStart> | [StartServicesAccessor](./kibana-plugin-core-server.startservicesaccessor.md) | +| [getStartServices](./kibana-plugin-core-server.coresetup.getstartservices.md) | StartServicesAccessor<TPluginsStart, TStart> | [StartServicesAccessor](./kibana-plugin-core-server.startservicesaccessor.md) | | [http](./kibana-plugin-core-server.coresetup.http.md) | HttpServiceSetup | [HttpServiceSetup](./kibana-plugin-core-server.httpservicesetup.md) | | [metrics](./kibana-plugin-core-server.coresetup.metrics.md) | MetricsServiceSetup | [MetricsServiceSetup](./kibana-plugin-core-server.metricsservicesetup.md) | | [savedObjects](./kibana-plugin-core-server.coresetup.savedobjects.md) | SavedObjectsServiceSetup | [SavedObjectsServiceSetup](./kibana-plugin-core-server.savedobjectsservicesetup.md) | diff --git a/docs/development/core/server/kibana-plugin-core-server.startservicesaccessor.md b/docs/development/core/server/kibana-plugin-core-server.startservicesaccessor.md index 4de781fc99cc..7f90060d3ffa 100644 --- a/docs/development/core/server/kibana-plugin-core-server.startservicesaccessor.md +++ b/docs/development/core/server/kibana-plugin-core-server.startservicesaccessor.md @@ -9,5 +9,5 @@ Allows plugins to get access to APIs available in start inside async handlers. P Signature: ```typescript -export declare type StartServicesAccessor = () => Promise<[CoreStart, TPluginsStart]>; +export declare type StartServicesAccessor = () => Promise<[CoreStart, TPluginsStart, TStart]>; ``` diff --git a/examples/alerting_example/public/plugin.tsx b/examples/alerting_example/public/plugin.tsx index 299806d39344..e3748e3235f4 100644 --- a/examples/alerting_example/public/plugin.tsx +++ b/examples/alerting_example/public/plugin.tsx @@ -17,7 +17,7 @@ * under the License. */ -import { Plugin, CoreSetup, AppMountParameters, CoreStart } from 'kibana/public'; +import { Plugin, CoreSetup, AppMountParameters } from 'kibana/public'; import { PluginSetupContract as AlertingSetup } from '../../../x-pack/plugins/alerting/public'; import { ChartsPluginStart } from '../../../src/plugins/charts/public'; import { TriggersAndActionsUIPublicPluginSetup } from '../../../x-pack/plugins/triggers_actions_ui/public'; @@ -43,17 +43,14 @@ export interface AlertingExamplePublicStartDeps { export class AlertingExamplePlugin implements Plugin { public setup( - core: CoreSetup, + core: CoreSetup, { alerting, triggers_actions_ui }: AlertingExamplePublicSetupDeps ) { core.application.register({ id: 'AlertingExample', title: 'Alerting Example', async mount(params: AppMountParameters) { - const [coreStart, depsStart]: [ - CoreStart, - AlertingExamplePublicStartDeps - ] = await core.getStartServices(); + const [coreStart, depsStart] = await core.getStartServices(); const { renderApp } = await import('./application'); return renderApp(coreStart, depsStart, params); }, diff --git a/examples/bfetch_explorer/public/plugin.tsx b/examples/bfetch_explorer/public/plugin.tsx index 3155354c91fd..fc3202f08bf7 100644 --- a/examples/bfetch_explorer/public/plugin.tsx +++ b/examples/bfetch_explorer/public/plugin.tsx @@ -34,7 +34,10 @@ export interface BfetchExplorerStartPlugins { } export class BfetchExplorerPlugin implements Plugin { - public setup(core: CoreSetup, plugins: BfetchExplorerSetupPlugins) { + public setup( + core: CoreSetup, + plugins: BfetchExplorerSetupPlugins + ) { const double = plugins.bfetch.batchedFunction<{ num: number }, { num: number }>({ url: '/bfetch_explorer/double', }); diff --git a/examples/embeddable_examples/public/index.ts b/examples/embeddable_examples/public/index.ts index 1c2c3911d100..5fcd454b17a5 100644 --- a/examples/embeddable_examples/public/index.ts +++ b/examples/embeddable_examples/public/index.ts @@ -26,9 +26,18 @@ export { export { ListContainer, LIST_CONTAINER } from './list_container'; export { TODO_EMBEDDABLE } from './todo'; -import { EmbeddableExamplesPlugin } from './plugin'; +import { + EmbeddableExamplesPlugin, + EmbeddableExamplesSetupDependencies, + EmbeddableExamplesStartDependencies, +} from './plugin'; export { SearchableListContainer, SEARCHABLE_LIST_CONTAINER } from './searchable_list_container'; export { MULTI_TASK_TODO_EMBEDDABLE } from './multi_task_todo'; -export const plugin: PluginInitializer = () => new EmbeddableExamplesPlugin(); +export const plugin: PluginInitializer< + void, + void, + EmbeddableExamplesSetupDependencies, + EmbeddableExamplesStartDependencies +> = () => new EmbeddableExamplesPlugin(); diff --git a/examples/embeddable_examples/public/plugin.ts b/examples/embeddable_examples/public/plugin.ts index 3663af68ae2c..5c202d96ceb1 100644 --- a/examples/embeddable_examples/public/plugin.ts +++ b/examples/embeddable_examples/public/plugin.ts @@ -28,11 +28,11 @@ import { } from './searchable_list_container'; import { LIST_CONTAINER, ListContainerFactory } from './list_container'; -interface EmbeddableExamplesSetupDependencies { +export interface EmbeddableExamplesSetupDependencies { embeddable: EmbeddableSetup; } -interface EmbeddableExamplesStartDependencies { +export interface EmbeddableExamplesStartDependencies { embeddable: EmbeddableStart; } diff --git a/examples/search_explorer/public/plugin.tsx b/examples/search_explorer/public/plugin.tsx index 29b236e82bf4..70b37aa9e626 100644 --- a/examples/search_explorer/public/plugin.tsx +++ b/examples/search_explorer/public/plugin.tsx @@ -21,7 +21,7 @@ import { Plugin, CoreSetup, AppMountParameters } from 'kibana/public'; import { AppPluginStartDependencies } from './types'; export class SearchExplorerPlugin implements Plugin { - public setup(core: CoreSetup) { + public setup(core: CoreSetup) { core.application.register({ id: 'searchExplorer', title: 'Search Explorer', diff --git a/src/core/public/index.ts b/src/core/public/index.ts index f72e115fd24f..254cac349559 100644 --- a/src/core/public/index.ts +++ b/src/core/public/index.ts @@ -177,13 +177,18 @@ export { MountPoint, UnmountCallback, PublicUiSettingsParams } from './types'; /** * Core services exposed to the `Plugin` setup lifecycle * + * @typeParam TPluginsStart - the type of the consuming plugin's start dependencies. Should be the same + * as the consuming {@link Plugin}'s `TPluginsStart` type. Used by `getStartServices`. + * @typeParam TStart - the type of the consuming plugin's start contract. Should be the same as the + * consuming {@link Plugin}'s `TStart` type. Used by `getStartServices`. + * * @public * * @internalRemarks We document the properties with \@link tags to improve * navigation in the generated docs until there's a fix for * https://github.com/Microsoft/web-build-tools/issues/1237 */ -export interface CoreSetup { +export interface CoreSetup { /** {@link ApplicationSetup} */ application: ApplicationSetup; /** @@ -209,7 +214,7 @@ export interface CoreSetup { getInjectedVar: (name: string, defaultValue?: any) => unknown; }; /** {@link StartServicesAccessor} */ - getStartServices: StartServicesAccessor; + getStartServices: StartServicesAccessor; } /** @@ -219,9 +224,10 @@ export interface CoreSetup { * * @public */ -export type StartServicesAccessor = () => Promise< - [CoreStart, TPluginsStart] ->; +export type StartServicesAccessor< + TPluginsStart extends object = object, + TStart = unknown +> = () => Promise<[CoreStart, TPluginsStart, TStart]>; /** * Core services exposed to the `Plugin` start lifecycle @@ -274,7 +280,7 @@ export interface CoreStart { * @public * @deprecated */ -export interface LegacyCoreSetup extends CoreSetup { +export interface LegacyCoreSetup extends CoreSetup { /** @deprecated */ injectedMetadata: InjectedMetadataSetup; } diff --git a/src/core/public/legacy/legacy_service.ts b/src/core/public/legacy/legacy_service.ts index 1b7e25f58556..39ca7bdf54b7 100644 --- a/src/core/public/legacy/legacy_service.ts +++ b/src/core/public/legacy/legacy_service.ts @@ -57,7 +57,7 @@ export class LegacyPlatformService { public readonly legacyId = Symbol(); private bootstrapModule?: BootstrapModule; private targetDomElement?: HTMLElement; - private readonly startDependencies$ = new Subject<[LegacyCoreStart, object]>(); + private readonly startDependencies$ = new Subject<[LegacyCoreStart, object, {}]>(); private readonly startDependencies = this.startDependencies$.pipe(first()).toPromise(); constructor(private readonly params: LegacyPlatformParams) {} @@ -129,7 +129,7 @@ export class LegacyPlatformService { }, }; - this.startDependencies$.next([legacyCore, plugins]); + this.startDependencies$.next([legacyCore, plugins, {}]); // Inject parts of the new platform into parts of the legacy platform // so that legacy APIs/modules can mimic their new platform counterparts diff --git a/src/core/public/mocks.ts b/src/core/public/mocks.ts index c860e9de8334..0c4930592b23 100644 --- a/src/core/public/mocks.ts +++ b/src/core/public/mocks.ts @@ -49,13 +49,22 @@ export { uiSettingsServiceMock } from './ui_settings/ui_settings_service.mock'; export { savedObjectsServiceMock } from './saved_objects/saved_objects_service.mock'; export { scopedHistoryMock } from './application/scoped_history.mock'; -function createCoreSetupMock({ basePath = '' } = {}) { +function createCoreSetupMock({ + basePath = '', + pluginStartDeps = {}, + pluginStartContract, +}: { + basePath?: string; + pluginStartDeps?: object; + pluginStartContract?: any; +} = {}) { const mock = { application: applicationServiceMock.createSetupContract(), context: contextServiceMock.createSetupContract(), fatalErrors: fatalErrorsServiceMock.createSetupContract(), - getStartServices: jest.fn, object]>, []>(() => - Promise.resolve([createCoreStartMock({ basePath }), {}]) + getStartServices: jest.fn, object, any]>, []>( + () => + Promise.resolve([createCoreStartMock({ basePath }), pluginStartDeps, pluginStartContract]) ), http: httpServiceMock.createSetupContract({ basePath }), notifications: notificationServiceMock.createSetupContract(), diff --git a/src/core/public/plugins/plugin.test.ts b/src/core/public/plugins/plugin.test.ts index 111ee93dd699..39330711f798 100644 --- a/src/core/public/plugins/plugin.test.ts +++ b/src/core/public/plugins/plugin.test.ts @@ -109,6 +109,10 @@ describe('PluginWrapper', () => { test("`start` resolves `startDependencies` Promise after plugin's start", async () => { expect.assertions(2); + const pluginStartContract = { + someApi: () => 'foo', + }; + let startDependenciesResolved = false; mockPluginLoader.mockResolvedValueOnce(() => ({ setup: jest.fn(), @@ -116,6 +120,7 @@ describe('PluginWrapper', () => { // Add small delay to ensure startDependencies is not resolved until after the plugin instance's start resolves. await new Promise(resolve => setTimeout(resolve, 10)); expect(startDependenciesResolved).toBe(false); + return pluginStartContract; }, })); await plugin.load(addBasePath); @@ -127,7 +132,7 @@ describe('PluginWrapper', () => { // called. const startDependenciesCheck = plugin.startDependencies.then(res => { startDependenciesResolved = true; - expect(res).toEqual([context, deps]); + expect(res).toEqual([context, deps, pluginStartContract]); }); await plugin.start(context, deps); await startDependenciesCheck; diff --git a/src/core/public/plugins/plugin.ts b/src/core/public/plugins/plugin.ts index e880627e352c..e51c45040c45 100644 --- a/src/core/public/plugins/plugin.ts +++ b/src/core/public/plugins/plugin.ts @@ -35,7 +35,7 @@ export interface Plugin< TPluginsSetup extends object = object, TPluginsStart extends object = object > { - setup(core: CoreSetup, plugins: TPluginsSetup): TSetup | Promise; + setup(core: CoreSetup, plugins: TPluginsSetup): TSetup | Promise; start(core: CoreStart, plugins: TPluginsStart): TStart | Promise; stop?(): void; } @@ -72,7 +72,7 @@ export class PluginWrapper< private initializer?: PluginInitializer; private instance?: Plugin; - private readonly startDependencies$ = new Subject<[CoreStart, TPluginsStart]>(); + private readonly startDependencies$ = new Subject<[CoreStart, TPluginsStart, TStart]>(); public readonly startDependencies = this.startDependencies$.pipe(first()).toPromise(); constructor( @@ -105,7 +105,7 @@ export class PluginWrapper< * @param plugins The dictionary where the key is the dependency name and the value * is the contract returned by the dependency's `setup` function. */ - public async setup(setupContext: CoreSetup, plugins: TPluginsSetup) { + public async setup(setupContext: CoreSetup, plugins: TPluginsSetup) { this.instance = await this.createPluginInstance(); return await this.instance.setup(setupContext, plugins); @@ -125,7 +125,7 @@ export class PluginWrapper< const startContract = await this.instance.start(startContext, plugins); - this.startDependencies$.next([startContext, plugins]); + this.startDependencies$.next([startContext, plugins, startContract]); return startContract; } diff --git a/src/core/public/plugins/plugins_service.ts b/src/core/public/plugins/plugins_service.ts index 8e1574d05baf..e698af689036 100644 --- a/src/core/public/plugins/plugins_service.ts +++ b/src/core/public/plugins/plugins_service.ts @@ -53,7 +53,7 @@ export interface PluginsServiceStart { */ export class PluginsService implements CoreService { /** Plugin wrappers in topological order. */ - private readonly plugins = new Map>>(); + private readonly plugins = new Map>(); private readonly pluginDependencies = new Map(); private readonly satupPlugins: PluginName[] = []; diff --git a/src/core/public/public.api.md b/src/core/public/public.api.md index eec12f234817..9f7f649f1e2a 100644 --- a/src/core/public/public.api.md +++ b/src/core/public/public.api.md @@ -371,7 +371,7 @@ export interface CoreContext { } // @public -export interface CoreSetup { +export interface CoreSetup { // (undocumented) application: ApplicationSetup; // @deprecated (undocumented) @@ -379,7 +379,7 @@ export interface CoreSetup { // (undocumented) fatalErrors: FatalErrorsSetup; // (undocumented) - getStartServices: StartServicesAccessor; + getStartServices: StartServicesAccessor; // (undocumented) http: HttpSetup; // @deprecated @@ -807,7 +807,7 @@ export interface IUiSettingsClient { } // @public @deprecated -export interface LegacyCoreSetup extends CoreSetup { +export interface LegacyCoreSetup extends CoreSetup { // Warning: (ae-forgotten-export) The symbol "InjectedMetadataSetup" needs to be exported by the entry point index.d.ts // // @deprecated (undocumented) @@ -907,7 +907,7 @@ export interface PackageInfo { // @public export interface Plugin { // (undocumented) - setup(core: CoreSetup, plugins: TPluginsSetup): TSetup | Promise; + setup(core: CoreSetup, plugins: TPluginsSetup): TSetup | Promise; // (undocumented) start(core: CoreStart, plugins: TPluginsStart): TStart | Promise; // (undocumented) @@ -1237,7 +1237,7 @@ export class SimpleSavedObject { } // @public -export type StartServicesAccessor = () => Promise<[CoreStart, TPluginsStart]>; +export type StartServicesAccessor = () => Promise<[CoreStart, TPluginsStart, TStart]>; // @public export type StringValidation = StringValidationRegex | StringValidationRegexString; diff --git a/src/core/server/index.ts b/src/core/server/index.ts index 1b436bfd7262..56ce16a951aa 100644 --- a/src/core/server/index.ts +++ b/src/core/server/index.ts @@ -333,9 +333,13 @@ export interface RequestHandlerContext { /** * Context passed to the plugins `setup` method. * + * @typeParam TPluginsStart - the type of the consuming plugin's start dependencies. Should be the same + * as the consuming {@link Plugin}'s `TPluginsStart` type. Used by `getStartServices`. + * @typeParam TStart - the type of the consuming plugin's start contract. Should be the same as the + * consuming {@link Plugin}'s `TStart` type. Used by `getStartServices`. * @public */ -export interface CoreSetup { +export interface CoreSetup { /** {@link CapabilitiesSetup} */ capabilities: CapabilitiesSetup; /** {@link ContextSetup} */ @@ -353,7 +357,7 @@ export interface CoreSetup { /** {@link MetricsServiceSetup} */ metrics: MetricsServiceSetup; /** {@link StartServicesAccessor} */ - getStartServices: StartServicesAccessor; + getStartServices: StartServicesAccessor; } /** @@ -364,9 +368,10 @@ export interface CoreSetup { * * @public */ -export type StartServicesAccessor = () => Promise< - [CoreStart, TPluginsStart] ->; +export type StartServicesAccessor< + TPluginsStart extends object = object, + TStart = unknown +> = () => Promise<[CoreStart, TPluginsStart, TStart]>; /** * Context passed to the plugins `start` method. diff --git a/src/core/server/legacy/legacy_service.ts b/src/core/server/legacy/legacy_service.ts index b19a991fdf0d..361fade6a4d0 100644 --- a/src/core/server/legacy/legacy_service.ts +++ b/src/core/server/legacy/legacy_service.ts @@ -312,7 +312,7 @@ export class LegacyService implements CoreService { uuid: { getInstanceUuid: setupDeps.core.uuid.getInstanceUuid, }, - getStartServices: () => Promise.resolve([coreStart, startDeps.plugins]), + getStartServices: () => Promise.resolve([coreStart, startDeps.plugins, {}]), }; // eslint-disable-next-line @typescript-eslint/no-var-requires diff --git a/src/core/server/mocks.ts b/src/core/server/mocks.ts index 2aa35dff563f..31bf17da041a 100644 --- a/src/core/server/mocks.ts +++ b/src/core/server/mocks.ts @@ -96,7 +96,13 @@ function pluginInitializerContextMock(config: T = {} as T) { type CoreSetupMockType = MockedKeys & jest.Mocked>; -function createCoreSetupMock() { +function createCoreSetupMock({ + pluginStartDeps = {}, + pluginStartContract, +}: { + pluginStartDeps?: object; + pluginStartContract?: any; +} = {}) { const httpService = httpServiceMock.createSetupContract(); const httpMock: jest.Mocked = { createCookieSessionStorageFactory: httpService.createCookieSessionStorageFactory, @@ -131,8 +137,8 @@ function createCoreSetupMock() { uuid: uuidServiceMock.createSetupContract(), metrics: metricsServiceMock.createSetupContract(), getStartServices: jest - .fn, object]>, []>() - .mockResolvedValue([createCoreStartMock(), {}]), + .fn, object, any]>, []>() + .mockResolvedValue([createCoreStartMock(), pluginStartDeps, pluginStartContract]), }; return mock; diff --git a/src/core/server/plugins/integration_tests/plugins_service.test.ts b/src/core/server/plugins/integration_tests/plugins_service.test.ts index d5531478f03c..1521fc332bcd 100644 --- a/src/core/server/plugins/integration_tests/plugins_service.test.ts +++ b/src/core/server/plugins/integration_tests/plugins_service.test.ts @@ -107,7 +107,7 @@ describe('PluginsService', () => { }); it("properly resolves `getStartServices` in plugin's lifecycle", async () => { - expect.assertions(5); + expect.assertions(6); const pluginPath = 'plugin-path'; @@ -125,20 +125,25 @@ describe('PluginsService', () => { let contextFromStart: any = null; let contextFromStartService: any = null; + const pluginStartContract = { + someApi: () => 'foo', + }; + const pluginInitializer = () => ({ setup: async (coreSetup, deps) => { - coreSetup.getStartServices().then(([core, plugins]) => { + coreSetup.getStartServices().then(([core, plugins, pluginStart]) => { startDependenciesResolved = true; - contextFromStartService = { core, plugins }; + contextFromStartService = { core, plugins, pluginStart }; }); }, start: async (core, plugins) => { contextFromStart = { core, plugins }; await new Promise(resolve => setTimeout(resolve, 10)); expect(startDependenciesResolved).toBe(false); + return pluginStartContract; }, - } as Plugin); + } as Plugin); jest.doMock( join(pluginPath, 'server'), @@ -163,5 +168,6 @@ describe('PluginsService', () => { expect(startDependenciesResolved).toBe(true); expect(contextFromStart!.core).toEqual(contextFromStartService!.core); expect(contextFromStart!.plugins).toEqual(contextFromStartService!.plugins); + expect(contextFromStartService!.pluginStart).toEqual(pluginStartContract); }); }); diff --git a/src/core/server/plugins/plugin.test.ts b/src/core/server/plugins/plugin.test.ts index 6875302f88a9..1e4d94dd00d0 100644 --- a/src/core/server/plugins/plugin.test.ts +++ b/src/core/server/plugins/plugin.test.ts @@ -250,6 +250,9 @@ test("`start` resolves `startDependencies` Promise after plugin's start", async }); const startContext = { any: 'thing' } as any; const pluginDeps = { someDep: 'value' }; + const pluginStartContract = { + someApi: () => 'foo', + }; let startDependenciesResolved = false; @@ -259,6 +262,7 @@ test("`start` resolves `startDependencies` Promise after plugin's start", async // delay to ensure startDependencies is not resolved until after the plugin instance's start resolves. await new Promise(resolve => setTimeout(resolve, 10)); expect(startDependenciesResolved).toBe(false); + return pluginStartContract; }, }; mockPluginInitializer.mockReturnValue(mockPluginInstance); @@ -267,7 +271,7 @@ test("`start` resolves `startDependencies` Promise after plugin's start", async const startDependenciesCheck = plugin.startDependencies.then(resolvedStartDeps => { startDependenciesResolved = true; - expect(resolvedStartDeps).toEqual([startContext, pluginDeps]); + expect(resolvedStartDeps).toEqual([startContext, pluginDeps, pluginStartContract]); }); await plugin.start(startContext, pluginDeps); diff --git a/src/core/server/plugins/plugin.ts b/src/core/server/plugins/plugin.ts index b372874264eb..7c67ab7a48df 100644 --- a/src/core/server/plugins/plugin.ts +++ b/src/core/server/plugins/plugin.ts @@ -61,7 +61,7 @@ export class PluginWrapper< private instance?: Plugin; - private readonly startDependencies$ = new Subject<[CoreStart, TPluginsStart]>(); + private readonly startDependencies$ = new Subject<[CoreStart, TPluginsStart, TStart]>(); public readonly startDependencies = this.startDependencies$.pipe(first()).toPromise(); constructor( @@ -115,7 +115,7 @@ export class PluginWrapper< this.log.debug('Starting plugin'); const startContract = await this.instance.start(startContext, plugins); - this.startDependencies$.next([startContext, plugins]); + this.startDependencies$.next([startContext, plugins, startContract]); return startContract; } diff --git a/src/core/server/server.api.md b/src/core/server/server.api.md index 232d34e48438..9317481ae2f8 100644 --- a/src/core/server/server.api.md +++ b/src/core/server/server.api.md @@ -622,7 +622,7 @@ export interface ContextSetup { export type CoreId = symbol; // @public -export interface CoreSetup { +export interface CoreSetup { // (undocumented) capabilities: CapabilitiesSetup; // (undocumented) @@ -630,7 +630,7 @@ export interface CoreSetup { // (undocumented) elasticsearch: ElasticsearchServiceSetup; // (undocumented) - getStartServices: StartServicesAccessor; + getStartServices: StartServicesAccessor; // (undocumented) http: HttpServiceSetup; // (undocumented) @@ -2270,7 +2270,7 @@ export type SharedGlobalConfig = RecursiveReadonly_2<{ }>; // @public -export type StartServicesAccessor = () => Promise<[CoreStart, TPluginsStart]>; +export type StartServicesAccessor = () => Promise<[CoreStart, TPluginsStart, TStart]>; // @public export type StringValidation = StringValidationRegex | StringValidationRegexString; diff --git a/src/legacy/core_plugins/input_control_vis/public/plugin.ts b/src/legacy/core_plugins/input_control_vis/public/plugin.ts index e85ccd94f9e6..c45e0d17872e 100644 --- a/src/legacy/core_plugins/input_control_vis/public/plugin.ts +++ b/src/legacy/core_plugins/input_control_vis/public/plugin.ts @@ -24,7 +24,7 @@ import { VisualizationsSetup, VisualizationsStart } from '../../visualizations/p import { createInputControlVisFn } from './input_control_fn'; import { createInputControlVisTypeDefinition } from './input_control_vis_type'; -type InputControlVisCoreSetup = CoreSetup; +type InputControlVisCoreSetup = CoreSetup; export interface InputControlVisDependencies { core: InputControlVisCoreSetup; @@ -46,7 +46,7 @@ export interface InputControlVisPluginStartDependencies { } /** @internal */ -export class InputControlVisPlugin implements Plugin, void> { +export class InputControlVisPlugin implements Plugin { constructor(public initializerContext: PluginInitializerContext) {} public async setup( diff --git a/src/legacy/core_plugins/kibana/public/discover/plugin.ts b/src/legacy/core_plugins/kibana/public/discover/plugin.ts index d3cdeb49fba7..42f3ec672609 100644 --- a/src/legacy/core_plugins/kibana/public/discover/plugin.ts +++ b/src/legacy/core_plugins/kibana/public/discover/plugin.ts @@ -91,7 +91,7 @@ export class DiscoverPlugin implements Plugin { public initializeInnerAngular?: () => void; public initializeServices?: () => Promise<{ core: CoreStart; plugins: DiscoverStartPlugins }>; - setup(core: CoreSetup, plugins: DiscoverSetupPlugins) { + setup(core: CoreSetup, plugins: DiscoverSetupPlugins) { const { appMounted, appUnMounted, stop: stopUrlTracker } = createKbnUrlTracker({ baseUrl: core.http.basePath.prepend('/app/kibana'), defaultSubUrl: '#/discover', diff --git a/src/legacy/core_plugins/vis_type_timelion/public/plugin.ts b/src/legacy/core_plugins/vis_type_timelion/public/plugin.ts index 9d69c312b48f..8d067369fef7 100644 --- a/src/legacy/core_plugins/vis_type_timelion/public/plugin.ts +++ b/src/legacy/core_plugins/vis_type_timelion/public/plugin.ts @@ -35,7 +35,7 @@ import { getTimelionVisualizationConfig } from './timelion_vis_fn'; import { getTimelionVisDefinition } from './timelion_vis_type'; import { setIndexPatterns, setSavedObjectsClient } from './helpers/plugin_services'; -type TimelionVisCoreSetup = CoreSetup; +type TimelionVisCoreSetup = CoreSetup; /** @internal */ export interface TimelionVisDependencies extends Partial { diff --git a/src/legacy/core_plugins/vis_type_vislib/public/plugin.ts b/src/legacy/core_plugins/vis_type_vislib/public/plugin.ts index 9539adbd2ec2..3022a03d65fe 100644 --- a/src/legacy/core_plugins/vis_type_vislib/public/plugin.ts +++ b/src/legacy/core_plugins/vis_type_vislib/public/plugin.ts @@ -62,10 +62,10 @@ export interface VisTypeVislibPluginStartDependencies { data: DataPublicPluginStart; } -type VisTypeVislibCoreSetup = CoreSetup; +type VisTypeVislibCoreSetup = CoreSetup; /** @internal */ -export class VisTypeVislibPlugin implements Plugin, void> { +export class VisTypeVislibPlugin implements Plugin { constructor(public initializerContext: PluginInitializerContext) {} public async setup( diff --git a/src/legacy/core_plugins/vis_type_xy/public/plugin.ts b/src/legacy/core_plugins/vis_type_xy/public/plugin.ts index 35abb04fd873..0884cdf6a5e1 100644 --- a/src/legacy/core_plugins/vis_type_xy/public/plugin.ts +++ b/src/legacy/core_plugins/vis_type_xy/public/plugin.ts @@ -47,10 +47,10 @@ export interface VisTypeXyPluginStartDependencies { visualizations: VisualizationsStart; } -type VisTypeXyCoreSetup = CoreSetup; +type VisTypeXyCoreSetup = CoreSetup; /** @internal */ -export class VisTypeXyPlugin implements Plugin, void> { +export class VisTypeXyPlugin implements Plugin { constructor(public initializerContext: PluginInitializerContext) {} public async setup( diff --git a/src/plugins/home/public/plugin.ts b/src/plugins/home/public/plugin.ts index 2353df600aa6..fab7808b5072 100644 --- a/src/plugins/home/public/plugin.ts +++ b/src/plugins/home/public/plugin.ts @@ -50,7 +50,9 @@ export interface HomePluginSetupDependencies { kibanaLegacy: KibanaLegacySetup; } -export class HomePublicPlugin implements Plugin { +export class HomePublicPlugin + implements + Plugin { private readonly featuresCatalogueRegistry = new FeatureCatalogueRegistry(); private readonly environmentService = new EnvironmentService(); private readonly tutorialService = new TutorialService(); diff --git a/x-pack/plugins/actions/server/plugin.ts b/x-pack/plugins/actions/server/plugin.ts index c6c4f377ab61..ce31e62bc9b8 100644 --- a/x-pack/plugins/actions/server/plugin.ts +++ b/x-pack/plugins/actions/server/plugin.ts @@ -175,7 +175,7 @@ export class ActionsPlugin implements Plugin, Plugi const usageCollection = plugins.usageCollection; if (usageCollection) { - core.getStartServices().then(async ([coreStart, startPlugins]: [CoreStart, any]) => { + core.getStartServices().then(async ([, startPlugins]: [CoreStart, any, any]) => { registerActionsUsageCollector(usageCollection, startPlugins.taskManager); initializeActionsTelemetry( diff --git a/x-pack/plugins/alerting/server/plugin.ts b/x-pack/plugins/alerting/server/plugin.ts index e88124322c1e..b0d06d4aeeb7 100644 --- a/x-pack/plugins/alerting/server/plugin.ts +++ b/x-pack/plugins/alerting/server/plugin.ts @@ -143,7 +143,7 @@ export class AlertingPlugin { const usageCollection = plugins.usageCollection; if (usageCollection) { - core.getStartServices().then(async ([coreStart, startPlugins]: [CoreStart, any]) => { + core.getStartServices().then(async ([, startPlugins]: [CoreStart, any, any]) => { registerAlertsUsageCollector(usageCollection, startPlugins.taskManager); initializeAlertingTelemetry( diff --git a/x-pack/plugins/ingest_manager/public/plugin.ts b/x-pack/plugins/ingest_manager/public/plugin.ts index 99dcebd9bfba..d7be1c1f1fe6 100644 --- a/x-pack/plugins/ingest_manager/public/plugin.ts +++ b/x-pack/plugins/ingest_manager/public/plugin.ts @@ -32,7 +32,9 @@ export interface IngestManagerStartDeps { data: DataPublicPluginStart; } -export class IngestManagerPlugin implements Plugin { +export class IngestManagerPlugin + implements + Plugin { private config: IngestManagerConfigType; constructor(private readonly initializerContext: PluginInitializerContext) { @@ -50,7 +52,8 @@ export class IngestManagerPlugin implements Plugin { async mount(params: AppMountParameters) { const [coreStart, startDeps] = (await core.getStartServices()) as [ CoreStart, - IngestManagerStartDeps + IngestManagerStartDeps, + IngestManagerStart ]; const { renderApp } = await import('./applications/ingest_manager'); return renderApp(coreStart, params, deps, startDeps, config); diff --git a/x-pack/plugins/ml/public/index.ts b/x-pack/plugins/ml/public/index.ts index f9f2be390e05..8070f94a1264 100755 --- a/x-pack/plugins/ml/public/index.ts +++ b/x-pack/plugins/ml/public/index.ts @@ -6,8 +6,19 @@ import { PluginInitializer } from 'kibana/public'; import './index.scss'; -import { MlPlugin, MlPluginSetup, MlPluginStart } from './plugin'; +import { + MlPlugin, + MlPluginSetup, + MlPluginStart, + MlSetupDependencies, + MlStartDependencies, +} from './plugin'; -export const plugin: PluginInitializer = () => new MlPlugin(); +export const plugin: PluginInitializer< + MlPluginSetup, + MlPluginStart, + MlSetupDependencies, + MlStartDependencies +> = () => new MlPlugin(); export { MlPluginSetup, MlPluginStart }; diff --git a/x-pack/plugins/ml/public/plugin.ts b/x-pack/plugins/ml/public/plugin.ts index d4bec3d617a0..62b60f81b672 100644 --- a/x-pack/plugins/ml/public/plugin.ts +++ b/x-pack/plugins/ml/public/plugin.ts @@ -31,7 +31,7 @@ export interface MlSetupDependencies { } export class MlPlugin implements Plugin { - setup(core: CoreSetup, pluginsSetup: MlSetupDependencies) { + setup(core: CoreSetup, pluginsSetup: MlSetupDependencies) { core.application.register({ id: PLUGIN_ID, title: i18n.translate('xpack.ml.plugin.title', { diff --git a/x-pack/plugins/monitoring/server/plugin.ts b/x-pack/plugins/monitoring/server/plugin.ts index d9500284b52d..24d8bcaa4397 100644 --- a/x-pack/plugins/monitoring/server/plugin.ts +++ b/x-pack/plugins/monitoring/server/plugin.ts @@ -224,7 +224,7 @@ export class Plugin { this.monitoringCore = this.getLegacyShim( config, legacyConfig, - core.getStartServices as () => Promise<[CoreStart, PluginsStart]>, + core.getStartServices as () => Promise<[CoreStart, PluginsStart, {}]>, this.licenseService, this.cluster ); @@ -293,7 +293,7 @@ export class Plugin { getLegacyShim( config: MonitoringConfig, legacyConfig: any, - getCoreServices: () => Promise<[CoreStart, PluginsStart]>, + getCoreServices: () => Promise<[CoreStart, PluginsStart, {}]>, licenseService: MonitoringLicenseService, cluster: ICustomClusterClient ): MonitoringCore { diff --git a/x-pack/plugins/security/public/account_management/account_management_app.test.ts b/x-pack/plugins/security/public/account_management/account_management_app.test.ts index ad40c61718c7..bac98d563975 100644 --- a/x-pack/plugins/security/public/account_management/account_management_app.test.ts +++ b/x-pack/plugins/security/public/account_management/account_management_app.test.ts @@ -38,7 +38,7 @@ describe('accountManagementApp', () => { it('properly sets breadcrumbs and renders application', async () => { const coreSetupMock = coreMock.createSetup(); const coreStartMock = coreMock.createStart(); - coreSetupMock.getStartServices.mockResolvedValue([coreStartMock, {}]); + coreSetupMock.getStartServices.mockResolvedValue([coreStartMock, {}, {}]); const authcMock = securityMock.createSetup().authc; const containerMock = document.createElement('div'); diff --git a/x-pack/plugins/security/public/authentication/logged_out/logged_out_app.test.ts b/x-pack/plugins/security/public/authentication/logged_out/logged_out_app.test.ts index c8303ecc940d..f0c18a3f1408 100644 --- a/x-pack/plugins/security/public/authentication/logged_out/logged_out_app.test.ts +++ b/x-pack/plugins/security/public/authentication/logged_out/logged_out_app.test.ts @@ -35,7 +35,7 @@ describe('loggedOutApp', () => { it('properly renders application', async () => { const coreSetupMock = coreMock.createSetup(); const coreStartMock = coreMock.createStart(); - coreSetupMock.getStartServices.mockResolvedValue([coreStartMock, {}]); + coreSetupMock.getStartServices.mockResolvedValue([coreStartMock, {}, {}]); const containerMock = document.createElement('div'); diff --git a/x-pack/plugins/security/public/authentication/login/login_app.test.ts b/x-pack/plugins/security/public/authentication/login/login_app.test.ts index 2597a935f45d..b7119d179b0b 100644 --- a/x-pack/plugins/security/public/authentication/login/login_app.test.ts +++ b/x-pack/plugins/security/public/authentication/login/login_app.test.ts @@ -38,7 +38,7 @@ describe('loginApp', () => { it('properly renders application', async () => { const coreSetupMock = coreMock.createSetup(); const coreStartMock = coreMock.createStart(); - coreSetupMock.getStartServices.mockResolvedValue([coreStartMock, {}]); + coreSetupMock.getStartServices.mockResolvedValue([coreStartMock, {}, {}]); const containerMock = document.createElement('div'); loginApp.create({ diff --git a/x-pack/plugins/security/public/authentication/overwritten_session/overwritten_session_app.test.ts b/x-pack/plugins/security/public/authentication/overwritten_session/overwritten_session_app.test.ts index 7b15d8c46f6e..96e72ead2299 100644 --- a/x-pack/plugins/security/public/authentication/overwritten_session/overwritten_session_app.test.ts +++ b/x-pack/plugins/security/public/authentication/overwritten_session/overwritten_session_app.test.ts @@ -37,7 +37,7 @@ describe('overwrittenSessionApp', () => { it('properly sets breadcrumbs and renders application', async () => { const coreSetupMock = coreMock.createSetup(); const coreStartMock = coreMock.createStart(); - coreSetupMock.getStartServices.mockResolvedValue([coreStartMock, {}]); + coreSetupMock.getStartServices.mockResolvedValue([coreStartMock, {}, {}]); const authcMock = securityMock.createSetup().authc; const containerMock = document.createElement('div'); diff --git a/x-pack/plugins/security/public/index.ts b/x-pack/plugins/security/public/index.ts index fdb8b544d61d..458f7ab801fd 100644 --- a/x-pack/plugins/security/public/index.ts +++ b/x-pack/plugins/security/public/index.ts @@ -6,13 +6,22 @@ import './index.scss'; import { PluginInitializer, PluginInitializerContext } from 'src/core/public'; -import { SecurityPlugin, SecurityPluginSetup, SecurityPluginStart } from './plugin'; +import { + SecurityPlugin, + SecurityPluginSetup, + SecurityPluginStart, + PluginSetupDependencies, + PluginStartDependencies, +} from './plugin'; export { SecurityPluginSetup, SecurityPluginStart }; export { SessionInfo } from './types'; export { AuthenticatedUser } from '../common/model'; export { SecurityLicense, SecurityLicenseFeatures } from '../common/licensing'; -export const plugin: PluginInitializer = ( - initializerContext: PluginInitializerContext -) => new SecurityPlugin(initializerContext); +export const plugin: PluginInitializer< + SecurityPluginSetup, + SecurityPluginStart, + PluginSetupDependencies, + PluginStartDependencies +> = (initializerContext: PluginInitializerContext) => new SecurityPlugin(initializerContext); diff --git a/x-pack/plugins/spaces/public/management/spaces_management_app.test.tsx b/x-pack/plugins/spaces/public/management/spaces_management_app.test.tsx index 7738a440cb5e..61c872ec9269 100644 --- a/x-pack/plugins/spaces/public/management/spaces_management_app.test.tsx +++ b/x-pack/plugins/spaces/public/management/spaces_management_app.test.tsx @@ -51,7 +51,7 @@ async function mountApp(basePath: string, spaceId?: string) { .create({ spacesManager, securityLicense, - getStartServices: async () => [coreStart, pluginsStart as PluginsStart], + getStartServices: async () => [coreStart, pluginsStart as PluginsStart, {}], }) .mount({ basePath, element: container, setBreadcrumbs }); diff --git a/x-pack/plugins/spaces/server/capabilities/capabilities_switcher.test.ts b/x-pack/plugins/spaces/server/capabilities/capabilities_switcher.test.ts index 2c1ab26dd3d8..b4489e570015 100644 --- a/x-pack/plugins/spaces/server/capabilities/capabilities_switcher.test.ts +++ b/x-pack/plugins/spaces/server/capabilities/capabilities_switcher.test.ts @@ -103,6 +103,7 @@ const setup = (space: Space) => { coreSetup.getStartServices.mockResolvedValue([ coreMock.createStart(), { features: featuresStart }, + {}, ]); const spacesService = spacesServiceMock.createSetupContract(); diff --git a/x-pack/test/plugin_functional/plugins/resolver_test/public/index.ts b/x-pack/test/plugin_functional/plugins/resolver_test/public/index.ts index c5f3c0e19138..51ec5a08b7a3 100644 --- a/x-pack/test/plugin_functional/plugins/resolver_test/public/index.ts +++ b/x-pack/test/plugin_functional/plugins/resolver_test/public/index.ts @@ -5,6 +5,15 @@ */ import { PluginInitializer } from 'kibana/public'; -import { ResolverTestPlugin } from './plugin'; +import { + ResolverTestPlugin, + ResolverTestPluginSetupDependencies, + ResolverTestPluginStartDependencies, +} from './plugin'; -export const plugin: PluginInitializer = () => new ResolverTestPlugin(); +export const plugin: PluginInitializer< + void, + void, + ResolverTestPluginSetupDependencies, + ResolverTestPluginStartDependencies +> = () => new ResolverTestPlugin();