From 74bb4d08e2d0dae853f2df682d7563ab7373663c Mon Sep 17 00:00:00 2001 From: Alexey Antonov Date: Fri, 31 Jan 2020 16:22:08 +0300 Subject: [PATCH 1/2] [Reporting] New Platform Migration Part of #53898 --- .../core => common}/create_getter_setter.ts | 0 src/plugins/kibana_utils/common/index.ts | 1 + .../public/core/create_kibana_utils_core.ts | 2 +- src/plugins/kibana_utils/public/core/index.ts | 1 - .../public/core/saved_objects_client.ts | 2 +- src/plugins/kibana_utils/public/core/state.ts | 2 +- src/plugins/kibana_utils/public/index.ts | 2 +- src/plugins/kibana_utils/server/index.ts | 20 +++ .../public/np_ready/services.ts | 2 +- .../csv/server/execute_job.test.js | 8 +- .../export_types/csv/server/execute_job.ts | 3 +- x-pack/legacy/plugins/reporting/index.ts | 44 +----- .../legacy/plugins/reporting/server/index.ts | 12 ++ .../legacy/plugins/reporting/server/legacy.ts | 41 ++++++ .../legacy/plugins/reporting/server/plugin.ts | 128 +++++++----------- .../plugins/reporting/server/services.ts | 12 ++ 16 files changed, 152 insertions(+), 128 deletions(-) rename src/plugins/kibana_utils/{public/core => common}/create_getter_setter.ts (100%) create mode 100644 src/plugins/kibana_utils/server/index.ts create mode 100644 x-pack/legacy/plugins/reporting/server/index.ts create mode 100644 x-pack/legacy/plugins/reporting/server/legacy.ts create mode 100644 x-pack/legacy/plugins/reporting/server/services.ts diff --git a/src/plugins/kibana_utils/public/core/create_getter_setter.ts b/src/plugins/kibana_utils/common/create_getter_setter.ts similarity index 100% rename from src/plugins/kibana_utils/public/core/create_getter_setter.ts rename to src/plugins/kibana_utils/common/create_getter_setter.ts diff --git a/src/plugins/kibana_utils/common/index.ts b/src/plugins/kibana_utils/common/index.ts index bfb45b88964d8..80d72edc18528 100644 --- a/src/plugins/kibana_utils/common/index.ts +++ b/src/plugins/kibana_utils/common/index.ts @@ -19,4 +19,5 @@ export * from './defer'; export * from './of'; +export { createGetterSetter, Get, Set } from './create_getter_setter'; export { distinctUntilChangedWithInitialValue } from './distinct_until_changed_with_initial_value'; diff --git a/src/plugins/kibana_utils/public/core/create_kibana_utils_core.ts b/src/plugins/kibana_utils/public/core/create_kibana_utils_core.ts index 84ecffa1da634..c528c68f29edb 100644 --- a/src/plugins/kibana_utils/public/core/create_kibana_utils_core.ts +++ b/src/plugins/kibana_utils/public/core/create_kibana_utils_core.ts @@ -17,7 +17,7 @@ * under the License. */ -import { createGetterSetter, Get, Set } from './create_getter_setter'; +import { createGetterSetter, Get, Set } from '../../common'; import { CoreStart } from '../../../../core/public'; import { KUSavedObjectClient, createSavedObjectsClient } from './saved_objects_client'; diff --git a/src/plugins/kibana_utils/public/core/index.ts b/src/plugins/kibana_utils/public/core/index.ts index 7e8dff7191fe8..3f08d591300a2 100644 --- a/src/plugins/kibana_utils/public/core/index.ts +++ b/src/plugins/kibana_utils/public/core/index.ts @@ -17,5 +17,4 @@ * under the License. */ -export * from './create_getter_setter'; export * from './create_kibana_utils_core'; diff --git a/src/plugins/kibana_utils/public/core/saved_objects_client.ts b/src/plugins/kibana_utils/public/core/saved_objects_client.ts index 40407fea5d189..5262755a6a3ab 100644 --- a/src/plugins/kibana_utils/public/core/saved_objects_client.ts +++ b/src/plugins/kibana_utils/public/core/saved_objects_client.ts @@ -18,7 +18,7 @@ */ import { CoreStart } from '../../../../core/public'; -import { Get } from './create_getter_setter'; +import { Get } from '../../common'; type CoreSavedObjectClient = CoreStart['savedObjects']['client']; diff --git a/src/plugins/kibana_utils/public/core/state.ts b/src/plugins/kibana_utils/public/core/state.ts index 8ac6e4e0e58e6..52c4d166d737e 100644 --- a/src/plugins/kibana_utils/public/core/state.ts +++ b/src/plugins/kibana_utils/public/core/state.ts @@ -17,7 +17,7 @@ * under the License. */ -import { createGetterSetter } from './create_getter_setter'; +import { createGetterSetter } from '../../common'; import { CoreStart } from '../../../../core/public'; export const [getCoreStart, setCoreStart] = createGetterSetter('CoreStart'); diff --git a/src/plugins/kibana_utils/public/index.ts b/src/plugins/kibana_utils/public/index.ts index 00c1c95028b4d..5bb5202c9e38a 100644 --- a/src/plugins/kibana_utils/public/index.ts +++ b/src/plugins/kibana_utils/public/index.ts @@ -17,7 +17,7 @@ * under the License. */ -export { defer, Defer, of } from '../common'; +export { defer, Defer, of, createGetterSetter, Get, Set } from '../common'; export * from './core'; export * from './errors'; export * from './field_mapping'; diff --git a/src/plugins/kibana_utils/server/index.ts b/src/plugins/kibana_utils/server/index.ts new file mode 100644 index 0000000000000..f8b79a1b8b339 --- /dev/null +++ b/src/plugins/kibana_utils/server/index.ts @@ -0,0 +1,20 @@ +/* + * 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. + */ + +export { Get, Set, createGetterSetter } from '../common'; diff --git a/test/interpreter_functional/plugins/kbn_tp_run_pipeline/public/np_ready/services.ts b/test/interpreter_functional/plugins/kbn_tp_run_pipeline/public/np_ready/services.ts index 657d8d5150c3a..a700727d87299 100644 --- a/test/interpreter_functional/plugins/kbn_tp_run_pipeline/public/np_ready/services.ts +++ b/test/interpreter_functional/plugins/kbn_tp_run_pipeline/public/np_ready/services.ts @@ -17,7 +17,7 @@ * under the License. */ -import { createGetterSetter } from '../../../../../../src/plugins/kibana_utils/public/core'; +import { createGetterSetter } from '../../../../../../src/plugins/kibana_utils/public'; import { ExpressionsStart } from './types'; export const [getExpressions, setExpressions] = createGetterSetter('Expressions'); diff --git a/x-pack/legacy/plugins/reporting/export_types/csv/server/execute_job.test.js b/x-pack/legacy/plugins/reporting/export_types/csv/server/execute_job.test.js index 1abc923d340e6..42246b3de4799 100644 --- a/x-pack/legacy/plugins/reporting/export_types/csv/server/execute_job.test.js +++ b/x-pack/legacy/plugins/reporting/export_types/csv/server/execute_job.test.js @@ -11,6 +11,7 @@ import { CancellationToken } from '../../../common/cancellation_token'; import { fieldFormats } from '../../../../../../../src/plugins/data/server'; import { LevelLogger } from '../../../server/lib/level_logger'; import { executeJobFactory } from './execute_job'; +import { setFieldFormats } from '../../../server/services'; const delay = ms => new Promise(resolve => setTimeout(() => resolve(), ms)); @@ -67,8 +68,7 @@ describe('CSV Execute Job', function() { uiSettingsGetStub.withArgs('csv:separator').returns(','); uiSettingsGetStub.withArgs('csv:quoteValues').returns(true); - mockServer = { - expose: function() {}, + setFieldFormats({ fieldFormatServiceFactory: function() { const uiConfigMock = {}; uiConfigMock['format:defaultTypeMap'] = { @@ -81,6 +81,10 @@ describe('CSV Execute Job', function() { return fieldFormatsRegistry; }, + }); + + mockServer = { + expose: function() {}, plugins: { elasticsearch: { getCluster: function() { diff --git a/x-pack/legacy/plugins/reporting/export_types/csv/server/execute_job.ts b/x-pack/legacy/plugins/reporting/export_types/csv/server/execute_job.ts index fe64fdc96d904..981a659804e2d 100644 --- a/x-pack/legacy/plugins/reporting/export_types/csv/server/execute_job.ts +++ b/x-pack/legacy/plugins/reporting/export_types/csv/server/execute_job.ts @@ -12,6 +12,7 @@ import { ESQueueWorkerExecuteFn, ExecuteJobFactory, Logger, ServerFacade } from import { JobDocPayloadDiscoverCsv } from '../types'; import { fieldFormatMapFactory } from './lib/field_format_map'; import { createGenerateCsv } from './lib/generate_csv'; +import { getFieldFormats } from '../../../server/services'; export const executeJobFactory: ExecuteJobFactory { - const fieldFormats = await server.fieldFormatServiceFactory(uiConfig); + const fieldFormats = await getFieldFormats().fieldFormatServiceFactory(uiConfig); return fieldFormatMapFactory(indexPatternSavedObject, fieldFormats); })(), (async () => { diff --git a/x-pack/legacy/plugins/reporting/index.ts b/x-pack/legacy/plugins/reporting/index.ts index d38e19dee2ef2..7e52378b6dcba 100644 --- a/x-pack/legacy/plugins/reporting/index.ts +++ b/x-pack/legacy/plugins/reporting/index.ts @@ -6,28 +6,16 @@ import { i18n } from '@kbn/i18n'; import { Legacy } from 'kibana'; -import { IUiSettingsClient } from 'kibana/server'; import { resolve } from 'path'; -import { PluginStart as DataPluginStart } from '../../../../src/plugins/data/server'; -import { PluginSetupContract as SecurityPluginSetup } from '../../../plugins/security/server'; import { PLUGIN_ID, UI_SETTINGS_CUSTOM_PDF_LOGO } from './common/constants'; import { config as reportingConfig } from './config'; -import { - LegacySetup, - ReportingPlugin, - reportingPluginFactory, - ReportingSetupDeps, -} from './server/plugin'; +import { legacyInit } from './server/legacy'; import { ReportingConfigOptions, ReportingPluginSpecOptions } from './types.d'; const kbToBase64Length = (kb: number) => { return Math.floor((kb * 1024 * 8) / 6); }; -interface ReportingDeps { - data: DataPluginStart; -} - export const reporting = (kibana: any) => { return new kibana.Plugin({ id: PLUGIN_ID, @@ -73,35 +61,7 @@ export const reporting = (kibana: any) => { }, async init(server: Legacy.Server) { - const coreSetup = server.newPlatform.setup.core; - const pluginsSetup: ReportingSetupDeps = { - security: server.newPlatform.setup.plugins.security as SecurityPluginSetup, - usageCollection: server.newPlatform.setup.plugins.usageCollection, - }; - - const fieldFormatServiceFactory = async (uiSettings: IUiSettingsClient) => { - const [, plugins] = await coreSetup.getStartServices(); - const { fieldFormats } = (plugins as ReportingDeps).data; - - return fieldFormats.fieldFormatServiceFactory(uiSettings); - }; - - const __LEGACY: LegacySetup = { - config: server.config, - info: server.info, - route: server.route.bind(server), - plugins: { - elasticsearch: server.plugins.elasticsearch, - xpack_main: server.plugins.xpack_main, - }, - savedObjects: server.savedObjects, - fieldFormatServiceFactory, - uiSettingsServiceFactory: server.uiSettingsServiceFactory, - }; - - const initializerContext = server.newPlatform.coreContext; - const plugin: ReportingPlugin = reportingPluginFactory(initializerContext, __LEGACY, this); - await plugin.setup(coreSetup, pluginsSetup); + return legacyInit(server); }, deprecations({ unused }: any) { diff --git a/x-pack/legacy/plugins/reporting/server/index.ts b/x-pack/legacy/plugins/reporting/server/index.ts new file mode 100644 index 0000000000000..438a3fd595a10 --- /dev/null +++ b/x-pack/legacy/plugins/reporting/server/index.ts @@ -0,0 +1,12 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { PluginInitializerContext } from 'src/core/server'; +import { ReportingPlugin as Plugin } from './plugin'; + +export const plugin = (context: PluginInitializerContext) => { + return new Plugin(context); +}; diff --git a/x-pack/legacy/plugins/reporting/server/legacy.ts b/x-pack/legacy/plugins/reporting/server/legacy.ts new file mode 100644 index 0000000000000..dd28a987d129a --- /dev/null +++ b/x-pack/legacy/plugins/reporting/server/legacy.ts @@ -0,0 +1,41 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ +import { Legacy } from 'kibana'; +import { PluginInitializerContext } from 'src/core/server'; +import { plugin } from './index'; +import { LegacySetup, ReportingSetupDeps, ReportingStartDeps } from './plugin'; +import { PluginSetupContract as SecurityPluginSetup } from '../../../../plugins/security/server'; +import { PluginStart as DataPluginStart } from '../../../../../src/plugins/data/server'; + +const buildLegacyDependencies = (server: Legacy.Server): LegacySetup => ({ + config: server.config, + info: server.info, + route: server.route.bind(server), + plugins: { + elasticsearch: server.plugins.elasticsearch, + xpack_main: server.plugins.xpack_main, + }, + savedObjects: server.savedObjects, + uiSettingsServiceFactory: server.uiSettingsServiceFactory, +}); + +export const legacyInit = async (server: Legacy.Server) => { + const coreSetup = server.newPlatform.setup.core; + const pluginInstance = plugin(server.newPlatform.coreContext as PluginInitializerContext); + + await pluginInstance.setup(coreSetup, { + security: server.newPlatform.setup.plugins.security as SecurityPluginSetup, + usageCollection: server.newPlatform.setup.plugins.usageCollection, + __LEGACY: buildLegacyDependencies(server), + } as ReportingSetupDeps); + + // Schedule to call the "start" hook only after start dependencies are ready + coreSetup.getStartServices().then(([core, plugins]) => + pluginInstance.start(core, { + data: (plugins as any).data as DataPluginStart, + } as ReportingStartDeps) + ); +}; diff --git a/x-pack/legacy/plugins/reporting/server/plugin.ts b/x-pack/legacy/plugins/reporting/server/plugin.ts index cf66ec74969ca..b5343f6fb11c5 100644 --- a/x-pack/legacy/plugins/reporting/server/plugin.ts +++ b/x-pack/legacy/plugins/reporting/server/plugin.ts @@ -5,14 +5,13 @@ */ import { Legacy } from 'kibana'; -import { CoreSetup, CoreStart, Plugin, LoggerFactory } from 'src/core/server'; +import { CoreSetup, CoreStart, Plugin, PluginInitializerContext } from 'src/core/server'; import { UsageCollectionSetup } from 'src/plugins/usage_collection/server'; import { PluginSetupContract as SecurityPluginSetup } from '../../../../plugins/security/server'; import { XPackMainPlugin } from '../../xpack_main/server/xpack_main'; // @ts-ignore import { mirrorPluginStatus } from '../../../server/lib/mirror_plugin_status'; import { PLUGIN_ID } from '../common/constants'; -import { ReportingPluginSpecOptions } from '../types.d'; import { registerRoutes } from './routes'; import { checkLicenseFactory, getExportTypesRegistry, runValidations, LevelLogger } from './lib'; import { createBrowserDriverFactory } from './browsers'; @@ -20,27 +19,23 @@ import { registerReportingUsageCollector } from './usage'; import { logConfiguration } from '../log_configuration'; import { PluginStart as DataPluginStart } from '../../../../../src/plugins/data/server'; -export interface ReportingInitializerContext { - logger: LoggerFactory; -} - -// For now there is no exposed functionality to other plugins -export type ReportingSetup = object; -export type ReportingStart = object; +import { setFieldFormats } from './services'; export interface ReportingSetupDeps { usageCollection: UsageCollectionSetup; security: SecurityPluginSetup; + __LEGACY: LegacySetup; } -export type ReportingStartDeps = object; -type LegacyPlugins = Legacy.Server['plugins']; +export interface ReportingStartDeps { + data: DataPluginStart; +} export interface LegacySetup { config: Legacy.Server['config']; info: Legacy.Server['info']; plugins: { - elasticsearch: LegacyPlugins['elasticsearch']; + elasticsearch: Legacy.Server['plugins']['elasticsearch']; xpack_main: XPackMainPlugin & { status?: any; }; @@ -48,71 +43,50 @@ export interface LegacySetup { route: Legacy.Server['route']; savedObjects: Legacy.Server['savedObjects']; uiSettingsServiceFactory: Legacy.Server['uiSettingsServiceFactory']; - fieldFormatServiceFactory: DataPluginStart['fieldFormats']['fieldFormatServiceFactory']; } -export type ReportingPlugin = Plugin< - ReportingSetup, - ReportingStart, - ReportingSetupDeps, - ReportingStartDeps ->; - -/* We need a factory that returns an instance of the class because the class - * implementation itself restricts against having Legacy dependencies passed - * into `setup`. The factory parameters take the legacy dependencies, and the - * `setup` method gets it from enclosure */ -export function reportingPluginFactory( - initializerContext: ReportingInitializerContext, - __LEGACY: LegacySetup, - legacyPlugin: ReportingPluginSpecOptions -) { - return new (class ReportingPlugin implements ReportingPlugin { - private initializerContext: ReportingInitializerContext; - - constructor(context: ReportingInitializerContext) { - this.initializerContext = context; - } - - public async setup(core: CoreSetup, plugins: ReportingSetupDeps): Promise { - const exportTypesRegistry = getExportTypesRegistry(); - - let isCollectorReady = false; - // Register a function with server to manage the collection of usage stats - const { usageCollection } = plugins; - registerReportingUsageCollector( - usageCollection, - __LEGACY, - () => isCollectorReady, - exportTypesRegistry - ); - - const logger = new LevelLogger(this.initializerContext.logger.get('reporting')); - const browserDriverFactory = await createBrowserDriverFactory(__LEGACY, logger); - - logConfiguration(__LEGACY, logger); - runValidations(__LEGACY, logger, browserDriverFactory); - - const { xpack_main: xpackMainPlugin } = __LEGACY.plugins; - mirrorPluginStatus(xpackMainPlugin, legacyPlugin); - const checkLicense = checkLicenseFactory(exportTypesRegistry); - (xpackMainPlugin as any).status.once('green', () => { - // Register a function that is called whenever the xpack info changes, - // to re-compute the license check results for this plugin - xpackMainPlugin.info.feature(PLUGIN_ID).registerLicenseCheckResultsGenerator(checkLicense); - }); - - // Post initialization of the above code, the collector is now ready to fetch its data - isCollectorReady = true; - - // Reporting routes - registerRoutes(__LEGACY, plugins, exportTypesRegistry, browserDriverFactory, logger); - - return {}; - } - - public start(core: CoreStart, plugins: ReportingStartDeps): ReportingStart { - return {}; - } - })(initializerContext); +export class ReportingPlugin implements Plugin { + constructor(private context: PluginInitializerContext) {} + + public async setup(core: CoreSetup, plugins: ReportingSetupDeps) { + const { usageCollection, __LEGACY } = plugins; + const exportTypesRegistry = getExportTypesRegistry(); + + let isCollectorReady = false; + + // Register a function with server to manage the collection of usage stats + registerReportingUsageCollector( + usageCollection, + __LEGACY, + () => isCollectorReady, + exportTypesRegistry + ); + + const logger = new LevelLogger(this.context.logger.get('reporting')); + const browserDriverFactory = await createBrowserDriverFactory(__LEGACY, logger); + + logConfiguration(__LEGACY, logger); + runValidations(__LEGACY, logger, browserDriverFactory); + + const { xpack_main: xpackMainPlugin } = __LEGACY.plugins; + mirrorPluginStatus(xpackMainPlugin, plugins); + + const checkLicense = checkLicenseFactory(exportTypesRegistry); + + (xpackMainPlugin as any).status.once('green', () => { + // Register a function that is called whenever the xpack info changes, + // to re-compute the license check results for this plugin + xpackMainPlugin.info.feature(PLUGIN_ID).registerLicenseCheckResultsGenerator(checkLicense); + }); + + // Post initialization of the above code, the collector is now ready to fetch its data + isCollectorReady = true; + + // Reporting routes + registerRoutes(__LEGACY, plugins, exportTypesRegistry, browserDriverFactory, logger); + } + + public start(core: CoreStart, plugins: ReportingStartDeps) { + setFieldFormats(plugins.data.fieldFormats); + } } diff --git a/x-pack/legacy/plugins/reporting/server/services.ts b/x-pack/legacy/plugins/reporting/server/services.ts new file mode 100644 index 0000000000000..7d15d2e1af1ae --- /dev/null +++ b/x-pack/legacy/plugins/reporting/server/services.ts @@ -0,0 +1,12 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { createGetterSetter } from '../../../../../src/plugins/kibana_utils/server'; +import { PluginStart as DataPluginStart } from '../../../../../src/plugins/data/server'; + +export const [getFieldFormats, setFieldFormats] = createGetterSetter< + DataPluginStart['fieldFormats'] +>('FieldFormats'); From 5aa5ab5b15f446ba1cb1e0e62154ef4ef5700907 Mon Sep 17 00:00:00 2001 From: Alexey Antonov Date: Fri, 31 Jan 2020 17:46:15 +0300 Subject: [PATCH 2/2] fix CI --- x-pack/legacy/plugins/reporting/index.ts | 2 +- x-pack/legacy/plugins/reporting/server/legacy.ts | 14 +++++++++++--- x-pack/legacy/plugins/reporting/server/plugin.ts | 6 ++++-- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/x-pack/legacy/plugins/reporting/index.ts b/x-pack/legacy/plugins/reporting/index.ts index 7e52378b6dcba..cbafc4b1ecc4b 100644 --- a/x-pack/legacy/plugins/reporting/index.ts +++ b/x-pack/legacy/plugins/reporting/index.ts @@ -61,7 +61,7 @@ export const reporting = (kibana: any) => { }, async init(server: Legacy.Server) { - return legacyInit(server); + return legacyInit(server, this); }, deprecations({ unused }: any) { diff --git a/x-pack/legacy/plugins/reporting/server/legacy.ts b/x-pack/legacy/plugins/reporting/server/legacy.ts index dd28a987d129a..fdc71c655e2fd 100644 --- a/x-pack/legacy/plugins/reporting/server/legacy.ts +++ b/x-pack/legacy/plugins/reporting/server/legacy.ts @@ -9,27 +9,35 @@ import { plugin } from './index'; import { LegacySetup, ReportingSetupDeps, ReportingStartDeps } from './plugin'; import { PluginSetupContract as SecurityPluginSetup } from '../../../../plugins/security/server'; import { PluginStart as DataPluginStart } from '../../../../../src/plugins/data/server'; +import { ReportingPluginSpecOptions } from '../types'; -const buildLegacyDependencies = (server: Legacy.Server): LegacySetup => ({ +const buildLegacyDependencies = ( + server: Legacy.Server, + reportingPlugin: ReportingPluginSpecOptions +): LegacySetup => ({ config: server.config, info: server.info, route: server.route.bind(server), plugins: { elasticsearch: server.plugins.elasticsearch, xpack_main: server.plugins.xpack_main, + reporting: reportingPlugin, }, savedObjects: server.savedObjects, uiSettingsServiceFactory: server.uiSettingsServiceFactory, }); -export const legacyInit = async (server: Legacy.Server) => { +export const legacyInit = async ( + server: Legacy.Server, + reportingPlugin: ReportingPluginSpecOptions +) => { const coreSetup = server.newPlatform.setup.core; const pluginInstance = plugin(server.newPlatform.coreContext as PluginInitializerContext); await pluginInstance.setup(coreSetup, { security: server.newPlatform.setup.plugins.security as SecurityPluginSetup, usageCollection: server.newPlatform.setup.plugins.usageCollection, - __LEGACY: buildLegacyDependencies(server), + __LEGACY: buildLegacyDependencies(server, reportingPlugin), } as ReportingSetupDeps); // Schedule to call the "start" hook only after start dependencies are ready diff --git a/x-pack/legacy/plugins/reporting/server/plugin.ts b/x-pack/legacy/plugins/reporting/server/plugin.ts index b5343f6fb11c5..cadbf07946417 100644 --- a/x-pack/legacy/plugins/reporting/server/plugin.ts +++ b/x-pack/legacy/plugins/reporting/server/plugin.ts @@ -20,6 +20,7 @@ import { logConfiguration } from '../log_configuration'; import { PluginStart as DataPluginStart } from '../../../../../src/plugins/data/server'; import { setFieldFormats } from './services'; +import { ReportingPluginSpecOptions } from '../types'; export interface ReportingSetupDeps { usageCollection: UsageCollectionSetup; @@ -39,6 +40,7 @@ export interface LegacySetup { xpack_main: XPackMainPlugin & { status?: any; }; + reporting: ReportingPluginSpecOptions; }; route: Legacy.Server['route']; savedObjects: Legacy.Server['savedObjects']; @@ -68,8 +70,8 @@ export class ReportingPlugin implements Plugin