diff --git a/.ci/packer_cache.sh b/.ci/packer_cache.sh index ab68a60dcfc279..5f091cc2e11a60 100755 --- a/.ci/packer_cache.sh +++ b/.ci/packer_cache.sh @@ -42,7 +42,7 @@ tar -cf "$HOME/.kibana/bootstrap_cache/$branch.tar" \ packages/*/node_modules \ x-pack/node_modules \ x-pack/legacy/plugins/*/node_modules \ - x-pack/legacy/plugins/reporting/.chromium \ + x-pack/plugins/reporting/.chromium \ test/plugin_functional/plugins/*/node_modules \ examples/*/node_modules \ .es \ diff --git a/src/cli/cluster/cluster_manager.ts b/src/cli/cluster/cluster_manager.ts index fc94f8d585a020..dec16b63d78f08 100644 --- a/src/cli/cluster/cluster_manager.ts +++ b/src/cli/cluster/cluster_manager.ts @@ -261,7 +261,7 @@ export class ClusterManager { /debug\.log$/, ...pluginInternalDirsIgnore, fromRoot('src/legacy/server/sass/__tmp__'), - fromRoot('x-pack/legacy/plugins/reporting/.chromium'), + fromRoot('x-pack/plugins/reporting/.chromium'), fromRoot('x-pack/plugins/siem/cypress'), fromRoot('x-pack/plugins/apm/e2e'), fromRoot('x-pack/plugins/apm/scripts'), diff --git a/src/dev/build/tasks/clean_tasks.js b/src/dev/build/tasks/clean_tasks.js index ec38dd8a1195c1..31731e392e5cb4 100644 --- a/src/dev/build/tasks/clean_tasks.js +++ b/src/dev/build/tasks/clean_tasks.js @@ -206,7 +206,7 @@ export const CleanExtraBrowsersTask = { async run(config, log, build) { const getBrowserPathsForPlatform = (platform) => { - const reportingDir = 'x-pack/legacy/plugins/reporting'; + const reportingDir = 'x-pack/plugins/reporting'; const chromiumDir = '.chromium'; const chromiumPath = (p) => build.resolvePathForPlatform(platform, reportingDir, chromiumDir, p); diff --git a/src/dev/precommit_hook/casing_check_config.js b/src/dev/precommit_hook/casing_check_config.js index 44e46e8017257d..69c35b5b943aa8 100644 --- a/src/dev/precommit_hook/casing_check_config.js +++ b/src/dev/precommit_hook/casing_check_config.js @@ -172,12 +172,12 @@ export const TEMPORARILY_IGNORED_PATHS = [ 'x-pack/plugins/monitoring/public/icons/health-green.svg', 'x-pack/plugins/monitoring/public/icons/health-red.svg', 'x-pack/plugins/monitoring/public/icons/health-yellow.svg', - 'x-pack/legacy/plugins/reporting/export_types/printable_pdf/server/lib/pdf/assets/fonts/noto/NotoSansCJKtc-Medium.ttf', - 'x-pack/legacy/plugins/reporting/export_types/printable_pdf/server/lib/pdf/assets/fonts/noto/NotoSansCJKtc-Regular.ttf', - 'x-pack/legacy/plugins/reporting/export_types/printable_pdf/server/lib/pdf/assets/fonts/roboto/Roboto-Italic.ttf', - 'x-pack/legacy/plugins/reporting/export_types/printable_pdf/server/lib/pdf/assets/fonts/roboto/Roboto-Medium.ttf', - 'x-pack/legacy/plugins/reporting/export_types/printable_pdf/server/lib/pdf/assets/fonts/roboto/Roboto-Regular.ttf', - 'x-pack/legacy/plugins/reporting/export_types/printable_pdf/server/lib/pdf/assets/img/logo-grey.png', + 'x-pack/plugins/reporting/server/export_types/printable_pdf/server/lib/pdf/assets/fonts/noto/NotoSansCJKtc-Medium.ttf', + 'x-pack/plugins/reporting/server/export_types/printable_pdf/server/lib/pdf/assets/fonts/noto/NotoSansCJKtc-Regular.ttf', + 'x-pack/plugins/reporting/server/export_types/printable_pdf/server/lib/pdf/assets/fonts/roboto/Roboto-Italic.ttf', + 'x-pack/plugins/reporting/server/export_types/printable_pdf/server/lib/pdf/assets/fonts/roboto/Roboto-Medium.ttf', + 'x-pack/plugins/reporting/server/export_types/printable_pdf/server/lib/pdf/assets/fonts/roboto/Roboto-Regular.ttf', + 'x-pack/plugins/reporting/server/export_types/printable_pdf/server/lib/pdf/assets/img/logo-grey.png', 'x-pack/test/functional/es_archives/monitoring/beats-with-restarted-instance/data.json.gz', 'x-pack/test/functional/es_archives/monitoring/beats-with-restarted-instance/mappings.json', 'x-pack/test/functional/es_archives/monitoring/logstash-pipelines/data.json.gz', diff --git a/x-pack/.gitignore b/x-pack/.gitignore index 6bac5e181861da..5245e8a2e95c4d 100644 --- a/x-pack/.gitignore +++ b/x-pack/.gitignore @@ -5,8 +5,8 @@ /test/functional/screenshots /test/functional/apps/reporting/reports/session /test/reporting/configs/failure_debug/ -/legacy/plugins/reporting/.chromium/ -/legacy/plugins/reporting/.phantom/ +/plugins/reporting/.chromium/ +/plugins/reporting/.phantom/ /.aws-config.json /.env /.kibana-plugin-helpers.dev.* diff --git a/x-pack/.i18nrc.json b/x-pack/.i18nrc.json index a479b08ef90697..48dfa341f63853 100644 --- a/x-pack/.i18nrc.json +++ b/x-pack/.i18nrc.json @@ -35,7 +35,7 @@ "xpack.monitoring": ["plugins/monitoring", "legacy/plugins/monitoring"], "xpack.remoteClusters": "plugins/remote_clusters", "xpack.painlessLab": "plugins/painless_lab", - "xpack.reporting": ["plugins/reporting", "legacy/plugins/reporting"], + "xpack.reporting": ["plugins/reporting"], "xpack.rollupJobs": ["legacy/plugins/rollup", "plugins/rollup"], "xpack.searchProfiler": "plugins/searchprofiler", "xpack.security": ["legacy/plugins/security", "plugins/security"], diff --git a/x-pack/.kibana-plugin-helpers.json b/x-pack/.kibana-plugin-helpers.json index ed0b38841c1a88..ca0cae6dd3ca39 100644 --- a/x-pack/.kibana-plugin-helpers.json +++ b/x-pack/.kibana-plugin-helpers.json @@ -13,8 +13,8 @@ "index.js", ".i18nrc.json", "plugins/**/*", - "legacy/plugins/reporting/.phantom/*", - "legacy/plugins/reporting/.chromium/*", + "plugins/reporting/.phantom/*", + "plugins/reporting/.chromium/*", "legacy/common/**/*", "legacy/plugins/**/*", "legacy/server/**/*", diff --git a/x-pack/build_chromium/README.md b/x-pack/build_chromium/README.md index 501136ab0a965f..72e41afc80c95e 100644 --- a/x-pack/build_chromium/README.md +++ b/x-pack/build_chromium/README.md @@ -110,7 +110,7 @@ To run the build, replace the sha in the following commands with the sha that yo After the build completes, there will be a .zip file and a .md5 file in `~/chromium/chromium/src/out/headless`. These are named like so: `chromium-{first_7_of_SHA}-{platform}`, for example: `chromium-4747cc2-linux`. -The zip files need to be deployed to s3. For testing, I drop them into `headless-shell-dev`, but for production, they need to be in `headless-shell`. And the `x-pack/legacy/plugins/reporting/server/browsers/chromium/paths.js` file needs to be upated to have the correct `archiveChecksum`, `archiveFilename`, `binaryChecksum` and `baseUrl`. Below is a list of what the archive's are: +The zip files need to be deployed to s3. For testing, I drop them into `headless-shell-dev`, but for production, they need to be in `headless-shell`. And the `x-pack/plugins/reporting/server/browsers/chromium/paths.ts` file needs to be upated to have the correct `archiveChecksum`, `archiveFilename`, `binaryChecksum` and `baseUrl`. Below is a list of what the archive's are: - `archiveChecksum`: The contents of the `.md5` file, which is the `md5` checksum of the zip file. - `binaryChecksum`: The `md5` checksum of the `headless_shell` binary itself. diff --git a/x-pack/index.js b/x-pack/index.js index 9cf63854d40939..8096774d7a4915 100644 --- a/x-pack/index.js +++ b/x-pack/index.js @@ -6,7 +6,6 @@ import { xpackMain } from './legacy/plugins/xpack_main'; import { monitoring } from './legacy/plugins/monitoring'; -import { reporting } from './legacy/plugins/reporting'; import { security } from './legacy/plugins/security'; import { dashboardMode } from './legacy/plugins/dashboard_mode'; import { beats } from './legacy/plugins/beats_management'; @@ -18,7 +17,6 @@ module.exports = function (kibana) { return [ xpackMain(kibana), monitoring(kibana), - reporting(kibana), spaces(kibana), security(kibana), dashboardMode(kibana), diff --git a/x-pack/legacy/plugins/reporting/index.ts b/x-pack/legacy/plugins/reporting/index.ts deleted file mode 100644 index 1ae971b6566b07..00000000000000 --- a/x-pack/legacy/plugins/reporting/index.ts +++ /dev/null @@ -1,49 +0,0 @@ -/* - * 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 { i18n } from '@kbn/i18n'; -import { Legacy } from 'kibana'; -import { resolve } from 'path'; -import { PLUGIN_ID, UI_SETTINGS_CUSTOM_PDF_LOGO } from './common/constants'; -import { legacyInit } from './server/legacy'; - -export type ReportingPluginSpecOptions = Legacy.PluginSpecOptions; - -const kbToBase64Length = (kb: number) => Math.floor((kb * 1024 * 8) / 6); - -export const reporting = (kibana: any) => { - return new kibana.Plugin({ - id: PLUGIN_ID, - publicDir: resolve(__dirname, 'public'), - require: ['kibana', 'elasticsearch', 'xpack_main'], - - uiExports: { - uiSettingDefaults: { - [UI_SETTINGS_CUSTOM_PDF_LOGO]: { - name: i18n.translate('xpack.reporting.pdfFooterImageLabel', { - defaultMessage: 'PDF footer image', - }), - value: null, - description: i18n.translate('xpack.reporting.pdfFooterImageDescription', { - defaultMessage: `Custom image to use in the PDF's footer`, - }), - type: 'image', - validation: { - maxSize: { - length: kbToBase64Length(200), - description: '200 kB', - }, - }, - category: [PLUGIN_ID], - }, - }, - }, - - async init(server: Legacy.Server) { - return legacyInit(server, this); - }, - } as ReportingPluginSpecOptions); -}; diff --git a/x-pack/legacy/plugins/reporting/server/index.ts b/x-pack/legacy/plugins/reporting/server/index.ts deleted file mode 100644 index 2388eac48f8ccb..00000000000000 --- a/x-pack/legacy/plugins/reporting/server/index.ts +++ /dev/null @@ -1,17 +0,0 @@ -/* - * 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 { ReportingConfig } from './config'; -import { ReportingCore } from './core'; -import { ReportingPlugin as Plugin } from './plugin'; - -export const plugin = (context: PluginInitializerContext, config: ReportingConfig) => { - return new Plugin(context, config); -}; - -export { ReportingPlugin } from './plugin'; -export { ReportingConfig, ReportingCore }; diff --git a/x-pack/legacy/plugins/reporting/server/legacy.ts b/x-pack/legacy/plugins/reporting/server/legacy.ts deleted file mode 100644 index 14abd53cc83d93..00000000000000 --- a/x-pack/legacy/plugins/reporting/server/legacy.ts +++ /dev/null @@ -1,61 +0,0 @@ -/* - * 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 { take } from 'rxjs/operators'; -import { PluginInitializerContext } from 'src/core/server'; -import { LicensingPluginSetup } from '../../../../plugins/licensing/server'; -import { ReportingPluginSpecOptions } from '../'; -import { PluginsSetup } from '../../../../plugins/reporting/server'; -import { SecurityPluginSetup } from '../../../../plugins/security/server'; -import { buildConfig } from './config'; -import { plugin } from './index'; -import { LegacySetup, ReportingStartDeps } from './types'; - -const buildLegacyDependencies = ( - server: Legacy.Server, - reportingPlugin: ReportingPluginSpecOptions -): LegacySetup => ({ - route: server.route.bind(server), - plugins: { - xpack_main: server.plugins.xpack_main, - reporting: reportingPlugin, - }, -}); - -/* - * Starts the New Platform instance of Reporting using legacy dependencies - */ -export const legacyInit = async ( - server: Legacy.Server, - reportingLegacyPlugin: ReportingPluginSpecOptions -) => { - const { core: coreSetup } = server.newPlatform.setup; - const { config$ } = (server.newPlatform.setup.plugins.reporting as PluginsSetup).__legacy; - const reportingConfig = await config$.pipe(take(1)).toPromise(); - const __LEGACY = buildLegacyDependencies(server, reportingLegacyPlugin); - - const pluginInstance = plugin( - server.newPlatform.coreContext as PluginInitializerContext, - buildConfig(coreSetup, server, reportingConfig) - ); - - await pluginInstance.setup(coreSetup, { - elasticsearch: coreSetup.elasticsearch, - licensing: server.newPlatform.setup.plugins.licensing as LicensingPluginSetup, - security: server.newPlatform.setup.plugins.security as SecurityPluginSetup, - usageCollection: server.newPlatform.setup.plugins.usageCollection, - __LEGACY, - }); - - // Schedule to call the "start" hook only after start dependencies are ready - coreSetup.getStartServices().then(([core, plugins]) => - pluginInstance.start(core, { - data: (plugins as ReportingStartDeps).data, - __LEGACY, - }) - ); -}; diff --git a/x-pack/legacy/plugins/reporting/server/lib/esqueue/__tests__/fixtures/queue.js b/x-pack/legacy/plugins/reporting/server/lib/esqueue/__tests__/fixtures/queue.js deleted file mode 100644 index 6bdd922555fa9f..00000000000000 --- a/x-pack/legacy/plugins/reporting/server/lib/esqueue/__tests__/fixtures/queue.js +++ /dev/null @@ -1,11 +0,0 @@ -import events from 'events'; - -export class QueueMock extends events.EventEmitter { - constructor() { - super(); - } - - setClient(client) { - this.client = client; - } -} diff --git a/x-pack/legacy/plugins/reporting/server/plugin.ts b/x-pack/legacy/plugins/reporting/server/plugin.ts deleted file mode 100644 index 5a407ad3e4c4af..00000000000000 --- a/x-pack/legacy/plugins/reporting/server/plugin.ts +++ /dev/null @@ -1,81 +0,0 @@ -/* - * 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 { CoreSetup, CoreStart, Plugin, PluginInitializerContext } from 'src/core/server'; -import { createBrowserDriverFactory } from './browsers'; -import { ReportingConfig } from './config'; -import { ReportingCore } from './core'; -import { registerRoutes } from './routes'; -import { createQueueFactory, enqueueJobFactory, LevelLogger, runValidations } from './lib'; -import { setFieldFormats } from './services'; -import { ReportingSetup, ReportingSetupDeps, ReportingStart, ReportingStartDeps } from './types'; -import { registerReportingUsageCollector } from './usage'; -// @ts-ignore no module definition -import { mirrorPluginStatus } from '../../../server/lib/mirror_plugin_status'; - -export class ReportingPlugin - implements Plugin { - private config: ReportingConfig; - private logger: LevelLogger; - private reportingCore: ReportingCore; - - constructor(context: PluginInitializerContext, config: ReportingConfig) { - this.config = config; - this.logger = new LevelLogger(context.logger.get('reporting')); - this.reportingCore = new ReportingCore(this.config); - } - - public async setup(core: CoreSetup, plugins: ReportingSetupDeps) { - const { config } = this; - const { elasticsearch, __LEGACY, licensing, security } = plugins; - const router = core.http.createRouter(); - const basePath = core.http.basePath.get; - const { xpack_main: xpackMainLegacy, reporting: reportingLegacy } = __LEGACY.plugins; - - // legacy plugin status - mirrorPluginStatus(xpackMainLegacy, reportingLegacy); - - const browserDriverFactory = await createBrowserDriverFactory(config, this.logger); - const deps = { - browserDriverFactory, - elasticsearch, - licensing, - basePath, - router, - security, - }; - - runValidations(config, elasticsearch, browserDriverFactory, this.logger); - - this.reportingCore.pluginSetup(deps); - registerReportingUsageCollector(this.reportingCore, plugins); - registerRoutes(this.reportingCore, this.logger); - - return {}; - } - - public async start(core: CoreStart, plugins: ReportingStartDeps) { - const { reportingCore, logger } = this; - - const esqueue = await createQueueFactory(reportingCore, logger); - const enqueueJob = enqueueJobFactory(reportingCore, logger); - - this.reportingCore.pluginStart({ - savedObjects: core.savedObjects, - uiSettings: core.uiSettings, - esqueue, - enqueueJob, - }); - - setFieldFormats(plugins.data.fieldFormats); - - return {}; - } - - public getReportingCore() { - return this.reportingCore; - } -} diff --git a/x-pack/plugins/maps/public/connected_components/gis_map/view.js b/x-pack/plugins/maps/public/connected_components/gis_map/view.js index f733d08cf0b718..122f5cdd45c1cb 100644 --- a/x-pack/plugins/maps/public/connected_components/gis_map/view.js +++ b/x-pack/plugins/maps/public/connected_components/gis_map/view.js @@ -64,7 +64,7 @@ export class GisMap extends Component { // - If it's not, then reporting injects a listener into the browser for a custom "renderComplete" event. // - When that event is fired, we snapshot the viz and move on. // Failure to not have the dom attribute, or custom event, will timeout the job. - // See x-pack/legacy/plugins/reporting/export_types/common/lib/screenshots/wait_for_render.ts for more. + // See x-pack/plugins/reporting/export_types/common/lib/screenshots/wait_for_render.ts for more. _onInitialLoadRenderComplete = () => { const el = document.querySelector(`[data-dom-id="${this.state.domId}"]`); diff --git a/x-pack/legacy/plugins/reporting/README.md b/x-pack/plugins/reporting/README.md similarity index 100% rename from x-pack/legacy/plugins/reporting/README.md rename to x-pack/plugins/reporting/README.md diff --git a/x-pack/legacy/plugins/reporting/common/constants.ts b/x-pack/plugins/reporting/common/constants.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/common/constants.ts rename to x-pack/plugins/reporting/common/constants.ts diff --git a/x-pack/legacy/plugins/reporting/common/get_absolute_url.test.ts b/x-pack/plugins/reporting/common/get_absolute_url.test.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/common/get_absolute_url.test.ts rename to x-pack/plugins/reporting/common/get_absolute_url.test.ts diff --git a/x-pack/legacy/plugins/reporting/common/get_absolute_url.ts b/x-pack/plugins/reporting/common/get_absolute_url.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/common/get_absolute_url.ts rename to x-pack/plugins/reporting/common/get_absolute_url.ts diff --git a/x-pack/plugins/reporting/common/index.ts b/x-pack/plugins/reporting/common/index.ts index 36c896fb4f7b8e..cda8934fc8bf62 100644 --- a/x-pack/plugins/reporting/common/index.ts +++ b/x-pack/plugins/reporting/common/index.ts @@ -5,3 +5,4 @@ */ export { CancellationToken } from './cancellation_token'; +export { Poller } from './poller'; diff --git a/x-pack/plugins/reporting/common/types.ts b/x-pack/plugins/reporting/common/types.ts index 5b9ddfb1bbdea7..2b9e9299852f54 100644 --- a/x-pack/plugins/reporting/common/types.ts +++ b/x-pack/plugins/reporting/common/types.ts @@ -5,7 +5,7 @@ */ // eslint-disable-next-line @kbn/eslint/no-restricted-paths -export { ConfigType } from '../server/config'; +export { ReportingConfigType } from '../server/config'; export type JobId = string; export type JobStatus = diff --git a/x-pack/legacy/plugins/reporting/common/validate_urls.test.ts b/x-pack/plugins/reporting/common/validate_urls.test.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/common/validate_urls.test.ts rename to x-pack/plugins/reporting/common/validate_urls.test.ts diff --git a/x-pack/legacy/plugins/reporting/common/validate_urls.ts b/x-pack/plugins/reporting/common/validate_urls.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/common/validate_urls.ts rename to x-pack/plugins/reporting/common/validate_urls.ts diff --git a/x-pack/plugins/reporting/kibana.json b/x-pack/plugins/reporting/kibana.json index e44bd92c42391f..bc1a808d500e09 100644 --- a/x-pack/plugins/reporting/kibana.json +++ b/x-pack/plugins/reporting/kibana.json @@ -3,18 +3,18 @@ "version": "8.0.0", "kibanaVersion": "kibana", "optionalPlugins": [ + "security", "usageCollection" ], "configPath": ["xpack", "reporting"], "requiredPlugins": [ + "data", "home", "management", "licensing", "uiActions", "embeddable", - "share", - "kibanaLegacy", - "licensing" + "share" ], "server": true, "ui": true diff --git a/x-pack/plugins/reporting/public/plugin.tsx b/x-pack/plugins/reporting/public/plugin.tsx index 8f59a898b8e35f..7dd709b956d12a 100644 --- a/x-pack/plugins/reporting/public/plugin.tsx +++ b/x-pack/plugins/reporting/public/plugin.tsx @@ -26,7 +26,7 @@ import { import { ManagementSectionId, ManagementSetup } from '../../../../src/plugins/management/public'; import { SharePluginSetup } from '../../../../src/plugins/share/public'; import { LicensingPluginSetup } from '../../licensing/public'; -import { ConfigType, JobId, JobStatusBuckets } from '../common/types'; +import { ReportingConfigType, JobId, JobStatusBuckets } from '../common/types'; import { JOB_COMPLETION_NOTIFICATIONS_SESSION_KEY } from '../constants'; import { getGeneralErrorToast } from './components'; import { ReportListing } from './components/report_listing'; @@ -37,7 +37,7 @@ import { csvReportingProvider } from './share_context_menu/register_csv_reportin import { reportingPDFPNGProvider } from './share_context_menu/register_pdf_png_reporting'; export interface ClientConfigType { - poll: ConfigType['poll']; + poll: ReportingConfigType['poll']; } function getStored(): JobId[] { diff --git a/x-pack/legacy/plugins/reporting/server/browsers/chromium/driver/chromium_driver.ts b/x-pack/plugins/reporting/server/browsers/chromium/driver/chromium_driver.ts similarity index 99% rename from x-pack/legacy/plugins/reporting/server/browsers/chromium/driver/chromium_driver.ts rename to x-pack/plugins/reporting/server/browsers/chromium/driver/chromium_driver.ts index 6480fb4413f047..898b123e976fd2 100644 --- a/x-pack/legacy/plugins/reporting/server/browsers/chromium/driver/chromium_driver.ts +++ b/x-pack/plugins/reporting/server/browsers/chromium/driver/chromium_driver.ts @@ -9,7 +9,7 @@ import { map, trunc } from 'lodash'; import open from 'opn'; import { ElementHandle, EvaluateFn, Page, Response, SerializableOrJSHandle } from 'puppeteer'; import { parse as parseUrl } from 'url'; -import { ViewZoomWidthHeight } from '../../../../export_types/common/layouts/layout'; +import { ViewZoomWidthHeight } from '../../../export_types/common/layouts/layout'; import { LevelLogger } from '../../../lib'; import { ConditionalHeaders, ElementPosition } from '../../../types'; import { allowRequest, NetworkPolicy } from '../../network_policy'; diff --git a/x-pack/legacy/plugins/reporting/server/browsers/chromium/driver/index.ts b/x-pack/plugins/reporting/server/browsers/chromium/driver/index.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/server/browsers/chromium/driver/index.ts rename to x-pack/plugins/reporting/server/browsers/chromium/driver/index.ts diff --git a/x-pack/legacy/plugins/reporting/server/browsers/chromium/driver_factory/args.ts b/x-pack/plugins/reporting/server/browsers/chromium/driver_factory/args.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/server/browsers/chromium/driver_factory/args.ts rename to x-pack/plugins/reporting/server/browsers/chromium/driver_factory/args.ts diff --git a/x-pack/legacy/plugins/reporting/server/browsers/chromium/driver_factory/index.ts b/x-pack/plugins/reporting/server/browsers/chromium/driver_factory/index.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/server/browsers/chromium/driver_factory/index.ts rename to x-pack/plugins/reporting/server/browsers/chromium/driver_factory/index.ts diff --git a/x-pack/legacy/plugins/reporting/server/browsers/chromium/index.ts b/x-pack/plugins/reporting/server/browsers/chromium/index.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/server/browsers/chromium/index.ts rename to x-pack/plugins/reporting/server/browsers/chromium/index.ts diff --git a/x-pack/legacy/plugins/reporting/server/browsers/chromium/paths.ts b/x-pack/plugins/reporting/server/browsers/chromium/paths.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/server/browsers/chromium/paths.ts rename to x-pack/plugins/reporting/server/browsers/chromium/paths.ts diff --git a/x-pack/legacy/plugins/reporting/server/browsers/chromium/puppeteer.ts b/x-pack/plugins/reporting/server/browsers/chromium/puppeteer.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/server/browsers/chromium/puppeteer.ts rename to x-pack/plugins/reporting/server/browsers/chromium/puppeteer.ts diff --git a/x-pack/legacy/plugins/reporting/server/browsers/create_browser_driver_factory.ts b/x-pack/plugins/reporting/server/browsers/create_browser_driver_factory.ts similarity index 89% rename from x-pack/legacy/plugins/reporting/server/browsers/create_browser_driver_factory.ts rename to x-pack/plugins/reporting/server/browsers/create_browser_driver_factory.ts index 7b4407890652c5..f3486a48ba7b1f 100644 --- a/x-pack/legacy/plugins/reporting/server/browsers/create_browser_driver_factory.ts +++ b/x-pack/plugins/reporting/server/browsers/create_browser_driver_factory.ts @@ -4,6 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ +import { first } from 'rxjs/operators'; import { ReportingConfig } from '../'; import { LevelLogger } from '../lib'; import { HeadlessChromiumDriverFactory } from './chromium/driver_factory'; @@ -19,13 +20,13 @@ export async function createBrowserDriverFactory( const browserConfig = captureConfig.browser.chromium; const browserAutoDownload = captureConfig.browser.autoDownload; const browserType = captureConfig.browser.type; - const dataDir = config.kbnConfig.get('path', 'data'); + const dataDir = await config.kbnConfig.get('path', 'data').pipe(first()).toPromise(); if (browserConfig.disableSandbox) { logger.warning(`Enabling the Chromium sandbox provides an additional layer of protection.`); } if (browserAutoDownload) { - await ensureBrowserDownloaded(browserType); + await ensureBrowserDownloaded(browserType, logger); } try { diff --git a/x-pack/legacy/plugins/reporting/server/browsers/download/checksum.ts b/x-pack/plugins/reporting/server/browsers/download/checksum.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/server/browsers/download/checksum.ts rename to x-pack/plugins/reporting/server/browsers/download/checksum.ts diff --git a/x-pack/legacy/plugins/reporting/server/browsers/download/clean.ts b/x-pack/plugins/reporting/server/browsers/download/clean.ts similarity index 85% rename from x-pack/legacy/plugins/reporting/server/browsers/download/clean.ts rename to x-pack/plugins/reporting/server/browsers/download/clean.ts index 8988cbd1c9ec22..8558b001e8174f 100644 --- a/x-pack/legacy/plugins/reporting/server/browsers/download/clean.ts +++ b/x-pack/plugins/reporting/server/browsers/download/clean.ts @@ -4,17 +4,16 @@ * you may not use this file except in compliance with the Elastic License. */ +import del from 'del'; import { readdirSync } from 'fs'; import { resolve as resolvePath } from 'path'; - -import del from 'del'; - -import { log, asyncMap } from './util'; +import { LevelLogger } from '../../lib'; +import { asyncMap } from './util'; /** * Delete any file in the `dir` that is not in the expectedPaths */ -export async function clean(dir: string, expectedPaths: string[]) { +export async function clean(dir: string, expectedPaths: string[], logger: LevelLogger) { let filenames: string[]; try { filenames = await readdirSync(dir); @@ -30,7 +29,7 @@ export async function clean(dir: string, expectedPaths: string[]) { await asyncMap(filenames, async (filename) => { const path = resolvePath(dir, filename); if (!expectedPaths.includes(path)) { - log(`Deleting unexpected file ${path}`); + logger.warn(`Deleting unexpected file ${path}`); await del(path, { force: true }); } }); diff --git a/x-pack/legacy/plugins/reporting/server/browsers/download/download.test.ts b/x-pack/plugins/reporting/server/browsers/download/download.test.ts similarity index 82% rename from x-pack/legacy/plugins/reporting/server/browsers/download/download.test.ts rename to x-pack/plugins/reporting/server/browsers/download/download.test.ts index 05ee2862f017b9..b33dfa721d0382 100644 --- a/x-pack/legacy/plugins/reporting/server/browsers/download/download.test.ts +++ b/x-pack/plugins/reporting/server/browsers/download/download.test.ts @@ -5,11 +5,11 @@ */ import { createHash } from 'crypto'; -import { resolve as resolvePath } from 'path'; +import del from 'del'; import { readFileSync } from 'fs'; +import { resolve as resolvePath } from 'path'; import { Readable } from 'stream'; - -import del from 'del'; +import { LevelLogger } from '../../lib'; import { download } from './download'; const TEMP_DIR = resolvePath(__dirname, '__tmp__'); @@ -29,6 +29,12 @@ class ReadableOf extends Readable { jest.mock('axios'); const request: jest.Mock = jest.requireMock('axios').request; +const mockLogger = ({ + error: jest.fn(), + warn: jest.fn(), + info: jest.fn(), +} as unknown) as LevelLogger; + test('downloads the url to the path', async () => { const BODY = 'abdcefg'; request.mockImplementationOnce(async () => { @@ -37,7 +43,7 @@ test('downloads the url to the path', async () => { }; }); - await download('url', TEMP_FILE); + await download('url', TEMP_FILE, mockLogger); expect(readFileSync(TEMP_FILE, 'utf8')).toEqual(BODY); }); @@ -50,7 +56,7 @@ test('returns the md5 hex hash of the http body', async () => { }; }); - const returned = await download('url', TEMP_FILE); + const returned = await download('url', TEMP_FILE, mockLogger); expect(returned).toEqual(HASH); }); @@ -59,7 +65,7 @@ test('throws if request emits an error', async () => { throw new Error('foo'); }); - return expect(download('url', TEMP_FILE)).rejects.toThrow('foo'); + return expect(download('url', TEMP_FILE, mockLogger)).rejects.toThrow('foo'); }); afterEach(async () => await del(TEMP_DIR)); diff --git a/x-pack/legacy/plugins/reporting/server/browsers/download/download.ts b/x-pack/plugins/reporting/server/browsers/download/download.ts similarity index 68% rename from x-pack/legacy/plugins/reporting/server/browsers/download/download.ts rename to x-pack/plugins/reporting/server/browsers/download/download.ts index a5ad69b46e46df..30b50c32a74026 100644 --- a/x-pack/legacy/plugins/reporting/server/browsers/download/download.ts +++ b/x-pack/plugins/reporting/server/browsers/download/download.ts @@ -4,13 +4,11 @@ * you may not use this file except in compliance with the Elastic License. */ -import { openSync, writeSync, closeSync, mkdirSync } from 'fs'; +import Axios from 'axios'; import { createHash } from 'crypto'; +import { closeSync, mkdirSync, openSync, writeSync } from 'fs'; import { dirname } from 'path'; - -import Axios from 'axios'; - -import { log } from './util'; +import { LevelLogger } from '../../lib'; /** * Download a url and calculate it's checksum @@ -18,8 +16,8 @@ import { log } from './util'; * @param {String} path * @return {Promise} checksum of the downloaded file */ -export async function download(url: string, path: string) { - log(`Downloading ${url}`); +export async function download(url: string, path: string, logger: LevelLogger) { + logger.info(`Downloading ${url} to ${path}`); const hash = createHash('md5'); @@ -39,7 +37,15 @@ export async function download(url: string, path: string) { }); await new Promise((resolve, reject) => { - resp.data.on('error', reject).on('end', resolve); + resp.data + .on('error', (err: Error) => { + logger.error(err); + reject(err); + }) + .on('end', () => { + logger.info(`Downloaded ${url}`); + resolve(); + }); }); } finally { closeSync(handle); diff --git a/x-pack/legacy/plugins/reporting/server/browsers/download/ensure_downloaded.ts b/x-pack/plugins/reporting/server/browsers/download/ensure_downloaded.ts similarity index 74% rename from x-pack/legacy/plugins/reporting/server/browsers/download/ensure_downloaded.ts rename to x-pack/plugins/reporting/server/browsers/download/ensure_downloaded.ts index f1f609ed5607b3..b334510d719473 100644 --- a/x-pack/legacy/plugins/reporting/server/browsers/download/ensure_downloaded.ts +++ b/x-pack/plugins/reporting/server/browsers/download/ensure_downloaded.ts @@ -8,6 +8,7 @@ import { existsSync } from 'fs'; import { resolve as resolvePath } from 'path'; import { BrowserDownload, chromium } from '../'; import { BROWSER_TYPE } from '../../../common/constants'; +import { LevelLogger } from '../../lib'; import { md5 } from './checksum'; import { clean } from './clean'; import { download } from './download'; @@ -19,16 +20,17 @@ import { asyncMap } from './util'; * @param {String} browserType * @return {Promise} */ -export async function ensureBrowserDownloaded(browserType = BROWSER_TYPE) { - await ensureDownloaded([chromium]); +export async function ensureBrowserDownloaded(browserType = BROWSER_TYPE, logger: LevelLogger) { + await ensureDownloaded([chromium], logger); } /** - * Like ensureBrowserDownloaded(), except it applies to all browsers + * Check for the downloaded archive of each requested browser type and + * download them if they are missing or their checksum is invalid* * @return {Promise} */ -export async function ensureAllBrowsersDownloaded() { - await ensureDownloaded([chromium]); +export async function ensureAllBrowsersDownloaded(logger: LevelLogger) { + await ensureDownloaded([chromium], logger); } /** @@ -38,13 +40,14 @@ export async function ensureAllBrowsersDownloaded() { * @param {BrowserSpec} browsers * @return {Promise} */ -async function ensureDownloaded(browsers: BrowserDownload[]) { +async function ensureDownloaded(browsers: BrowserDownload[], logger: LevelLogger) { await asyncMap(browsers, async (browser) => { const { archivesPath } = browser.paths; await clean( archivesPath, - browser.paths.packages.map((p) => resolvePath(archivesPath, p.archiveFilename)) + browser.paths.packages.map((p) => resolvePath(archivesPath, p.archiveFilename)), + logger ); const invalidChecksums: string[] = []; @@ -53,21 +56,24 @@ async function ensureDownloaded(browsers: BrowserDownload[]) { const path = resolvePath(archivesPath, archiveFilename); if (existsSync(path) && (await md5(path)) === archiveChecksum) { + logger.info(`Browser archive exists in ${path}`); return; } - const downloadedChecksum = await download(url, path); + const downloadedChecksum = await download(url, path, logger); if (downloadedChecksum !== archiveChecksum) { invalidChecksums.push(`${url} => ${path}`); } }); if (invalidChecksums.length) { - throw new Error( + const err = new Error( `Error downloading browsers, checksums incorrect for:\n - ${invalidChecksums.join( '\n - ' )}` ); + logger.error(err); + throw err; } }); } diff --git a/x-pack/legacy/plugins/reporting/server/browsers/download/index.ts b/x-pack/plugins/reporting/server/browsers/download/index.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/server/browsers/download/index.ts rename to x-pack/plugins/reporting/server/browsers/download/index.ts diff --git a/x-pack/legacy/plugins/reporting/server/browsers/download/util.ts b/x-pack/plugins/reporting/server/browsers/download/util.ts similarity index 70% rename from x-pack/legacy/plugins/reporting/server/browsers/download/util.ts rename to x-pack/plugins/reporting/server/browsers/download/util.ts index 679106742e3d0c..99267664be7660 100644 --- a/x-pack/legacy/plugins/reporting/server/browsers/download/util.ts +++ b/x-pack/plugins/reporting/server/browsers/download/util.ts @@ -6,17 +6,6 @@ import { Readable } from 'stream'; -/** - * Log a message if the DEBUG environment variable is set - */ -export function log(...args: any[]) { - if (process.env.DEBUG) { - // allow console log since this is off by default and only for debugging - // eslint-disable-next-line no-console - console.log(...args); - } -} - /** * Iterate an array asynchronously and in parallel */ diff --git a/x-pack/legacy/plugins/reporting/server/browsers/extract/__tests__/__fixtures__/file.md b/x-pack/plugins/reporting/server/browsers/extract/__tests__/__fixtures__/file.md similarity index 100% rename from x-pack/legacy/plugins/reporting/server/browsers/extract/__tests__/__fixtures__/file.md rename to x-pack/plugins/reporting/server/browsers/extract/__tests__/__fixtures__/file.md diff --git a/x-pack/legacy/plugins/reporting/server/browsers/extract/__tests__/__fixtures__/file.md.zip b/x-pack/plugins/reporting/server/browsers/extract/__tests__/__fixtures__/file.md.zip similarity index 100% rename from x-pack/legacy/plugins/reporting/server/browsers/extract/__tests__/__fixtures__/file.md.zip rename to x-pack/plugins/reporting/server/browsers/extract/__tests__/__fixtures__/file.md.zip diff --git a/x-pack/legacy/plugins/reporting/server/browsers/extract/__tests__/extract.js b/x-pack/plugins/reporting/server/browsers/extract/__tests__/extract.js similarity index 100% rename from x-pack/legacy/plugins/reporting/server/browsers/extract/__tests__/extract.js rename to x-pack/plugins/reporting/server/browsers/extract/__tests__/extract.js diff --git a/x-pack/legacy/plugins/reporting/server/browsers/extract/extract.js b/x-pack/plugins/reporting/server/browsers/extract/extract.js similarity index 100% rename from x-pack/legacy/plugins/reporting/server/browsers/extract/extract.js rename to x-pack/plugins/reporting/server/browsers/extract/extract.js diff --git a/x-pack/legacy/plugins/reporting/server/browsers/extract/extract_error.js b/x-pack/plugins/reporting/server/browsers/extract/extract_error.js similarity index 100% rename from x-pack/legacy/plugins/reporting/server/browsers/extract/extract_error.js rename to x-pack/plugins/reporting/server/browsers/extract/extract_error.js diff --git a/x-pack/legacy/plugins/reporting/server/browsers/extract/index.js b/x-pack/plugins/reporting/server/browsers/extract/index.js similarity index 100% rename from x-pack/legacy/plugins/reporting/server/browsers/extract/index.js rename to x-pack/plugins/reporting/server/browsers/extract/index.js diff --git a/x-pack/legacy/plugins/reporting/server/browsers/extract/unzip.js b/x-pack/plugins/reporting/server/browsers/extract/unzip.js similarity index 100% rename from x-pack/legacy/plugins/reporting/server/browsers/extract/unzip.js rename to x-pack/plugins/reporting/server/browsers/extract/unzip.js diff --git a/x-pack/legacy/plugins/reporting/server/browsers/index.ts b/x-pack/plugins/reporting/server/browsers/index.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/server/browsers/index.ts rename to x-pack/plugins/reporting/server/browsers/index.ts diff --git a/x-pack/legacy/plugins/reporting/server/browsers/install.ts b/x-pack/plugins/reporting/server/browsers/install.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/server/browsers/install.ts rename to x-pack/plugins/reporting/server/browsers/install.ts diff --git a/x-pack/legacy/plugins/reporting/server/browsers/network_policy.test.ts b/x-pack/plugins/reporting/server/browsers/network_policy.test.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/server/browsers/network_policy.test.ts rename to x-pack/plugins/reporting/server/browsers/network_policy.test.ts diff --git a/x-pack/legacy/plugins/reporting/server/browsers/network_policy.ts b/x-pack/plugins/reporting/server/browsers/network_policy.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/server/browsers/network_policy.ts rename to x-pack/plugins/reporting/server/browsers/network_policy.ts diff --git a/x-pack/legacy/plugins/reporting/server/browsers/safe_child_process.ts b/x-pack/plugins/reporting/server/browsers/safe_child_process.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/server/browsers/safe_child_process.ts rename to x-pack/plugins/reporting/server/browsers/safe_child_process.ts diff --git a/x-pack/legacy/plugins/reporting/server/config/index.ts b/x-pack/plugins/reporting/server/config/config.ts similarity index 84% rename from x-pack/legacy/plugins/reporting/server/config/index.ts rename to x-pack/plugins/reporting/server/config/config.ts index 3ec5aab4d451b8..4142ab6f0ae433 100644 --- a/x-pack/legacy/plugins/reporting/server/config/index.ts +++ b/x-pack/plugins/reporting/server/config/config.ts @@ -4,10 +4,11 @@ * you may not use this file except in compliance with the Elastic License. */ -import { Legacy } from 'kibana'; +import { Observable } from 'rxjs'; import { get } from 'lodash'; -import { CoreSetup } from 'src/core/server'; -import { ConfigType as ReportingConfigType } from '../../../../../plugins/reporting/server'; +import { map } from 'rxjs/operators'; +import { CoreSetup, PluginInitializerContext } from 'src/core/server'; +import { ReportingConfigType } from './schema'; // make config.get() aware of the value type it returns interface Config { @@ -39,7 +40,7 @@ interface Config { } interface KbnServerConfigType { - path: { data: string }; + path: { data: Observable }; server: { basePath: string; host: string; @@ -55,17 +56,16 @@ export interface ReportingConfig extends Config { } export const buildConfig = ( + initContext: PluginInitializerContext, core: CoreSetup, - server: Legacy.Server, reportingConfig: ReportingConfigType ): ReportingConfig => { - const config = server.config(); const { http } = core; const serverInfo = http.getServerInfo(); const kbnConfig = { path: { - data: config.get('path.data'), + data: initContext.config.legacy.globalConfig$.pipe(map((c) => c.path.data)), }, server: { basePath: core.http.basePath.serverBasePath, @@ -84,5 +84,3 @@ export const buildConfig = ( }, }; }; - -export { ReportingConfigType }; diff --git a/x-pack/plugins/reporting/server/config/create_config.test.ts b/x-pack/plugins/reporting/server/config/create_config.test.ts index 3107866be64967..1c4c840cfa3126 100644 --- a/x-pack/plugins/reporting/server/config/create_config.test.ts +++ b/x-pack/plugins/reporting/server/config/create_config.test.ts @@ -5,9 +5,10 @@ */ import * as Rx from 'rxjs'; -import { CoreSetup, Logger, PluginInitializerContext } from 'src/core/server'; -import { ConfigType as ReportingConfigType } from './schema'; +import { CoreSetup, PluginInitializerContext } from 'src/core/server'; +import { LevelLogger } from '../lib'; import { createConfig$ } from './create_config'; +import { ReportingConfigType } from './schema'; interface KibanaServer { host?: string; @@ -37,14 +38,14 @@ const makeMockCoreSetup = (serverInfo: KibanaServer): CoreSetup => describe('Reporting server createConfig$', () => { let mockCoreSetup: CoreSetup; let mockInitContext: PluginInitializerContext; - let mockLogger: Logger; + let mockLogger: LevelLogger; beforeEach(() => { mockCoreSetup = makeMockCoreSetup({ host: 'kibanaHost', port: 5601, protocol: 'http' }); mockInitContext = makeMockInitContext({ kibanaServer: {}, }); - mockLogger = ({ warn: jest.fn(), debug: jest.fn() } as unknown) as Logger; + mockLogger = ({ warn: jest.fn(), debug: jest.fn() } as unknown) as LevelLogger; }); afterEach(() => { @@ -52,7 +53,8 @@ describe('Reporting server createConfig$', () => { }); it('creates random encryption key and default config using host, protocol, and port from server info', async () => { - const result = await createConfig$(mockCoreSetup, mockInitContext, mockLogger).toPromise(); + const mockConfig$: any = mockInitContext.config.create(); + const result = await createConfig$(mockCoreSetup, mockConfig$, mockLogger).toPromise(); expect(result.encryptionKey).toMatch(/\S{32,}/); // random 32 characters expect(result.kibanaServer).toMatchInlineSnapshot(` @@ -73,8 +75,8 @@ describe('Reporting server createConfig$', () => { encryptionKey: 'iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii', kibanaServer: {}, }); - const result = await createConfig$(mockCoreSetup, mockInitContext, mockLogger).toPromise(); - + const mockConfig$: any = mockInitContext.config.create(); + const result = await createConfig$(mockCoreSetup, mockConfig$, mockLogger).toPromise(); expect(result.encryptionKey).toMatch('iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii'); expect((mockLogger.warn as any).mock.calls.length).toBe(0); }); @@ -88,7 +90,8 @@ describe('Reporting server createConfig$', () => { protocol: 'httpsa', }, }); - const result = await createConfig$(mockCoreSetup, mockInitContext, mockLogger).toPromise(); + const mockConfig$: any = mockInitContext.config.create(); + const result = await createConfig$(mockCoreSetup, mockConfig$, mockLogger).toPromise(); expect(result).toMatchInlineSnapshot(` Object { @@ -115,7 +118,8 @@ describe('Reporting server createConfig$', () => { encryptionKey: 'aaaaaaaaaaaaabbbbbbbbbbbbaaaaaaaaa', kibanaServer: { hostname: '0' }, }); - const result = await createConfig$(mockCoreSetup, mockInitContext, mockLogger).toPromise(); + const mockConfig$: any = mockInitContext.config.create(); + const result = await createConfig$(mockCoreSetup, mockConfig$, mockLogger).toPromise(); expect(result.kibanaServer).toMatchInlineSnapshot(` Object { @@ -136,7 +140,8 @@ describe('Reporting server createConfig$', () => { encryptionKey: '888888888888888888888888888888888', capture: { browser: { chromium: { disableSandbox: false } } }, } as ReportingConfigType); - const result = await createConfig$(mockCoreSetup, mockInitContext, mockLogger).toPromise(); + const mockConfig$: any = mockInitContext.config.create(); + const result = await createConfig$(mockCoreSetup, mockConfig$, mockLogger).toPromise(); expect(result.capture.browser.chromium).toMatchObject({ disableSandbox: false }); expect((mockLogger.warn as any).mock.calls.length).toBe(0); @@ -147,7 +152,8 @@ describe('Reporting server createConfig$', () => { encryptionKey: '888888888888888888888888888888888', capture: { browser: { chromium: { disableSandbox: true } } }, } as ReportingConfigType); - const result = await createConfig$(mockCoreSetup, mockInitContext, mockLogger).toPromise(); + const mockConfig$: any = mockInitContext.config.create(); + const result = await createConfig$(mockCoreSetup, mockConfig$, mockLogger).toPromise(); expect(result.capture.browser.chromium).toMatchObject({ disableSandbox: true }); expect((mockLogger.warn as any).mock.calls.length).toBe(0); @@ -157,7 +163,8 @@ describe('Reporting server createConfig$', () => { mockInitContext = makeMockInitContext({ encryptionKey: '888888888888888888888888888888888', } as ReportingConfigType); - const result = await createConfig$(mockCoreSetup, mockInitContext, mockLogger).toPromise(); + const mockConfig$: any = mockInitContext.config.create(); + const result = await createConfig$(mockCoreSetup, mockConfig$, mockLogger).toPromise(); expect(result.capture.browser.chromium).toMatchObject({ disableSandbox: expect.any(Boolean) }); expect((mockLogger.warn as any).mock.calls.length).toBe(0); diff --git a/x-pack/plugins/reporting/server/config/create_config.ts b/x-pack/plugins/reporting/server/config/create_config.ts index d363494ddb9a6e..67df7dacc77ab8 100644 --- a/x-pack/plugins/reporting/server/config/create_config.ts +++ b/x-pack/plugins/reporting/server/config/create_config.ts @@ -5,13 +5,14 @@ */ import { i18n } from '@kbn/i18n/'; -import { TypeOf } from '@kbn/config-schema'; import crypto from 'crypto'; import { capitalize } from 'lodash'; +import { Observable } from 'rxjs'; import { map, mergeMap } from 'rxjs/operators'; -import { CoreSetup, Logger, PluginInitializerContext } from 'src/core/server'; +import { CoreSetup } from 'src/core/server'; +import { LevelLogger } from '../lib'; import { getDefaultChromiumSandboxDisabled } from './default_chromium_sandbox_disabled'; -import { ConfigSchema } from './schema'; +import { ReportingConfigType } from './schema'; /* * Set up dynamic config defaults @@ -19,8 +20,12 @@ import { ConfigSchema } from './schema'; * - xpack.kibanaServer * - xpack.reporting.encryptionKey */ -export function createConfig$(core: CoreSetup, context: PluginInitializerContext, logger: Logger) { - return context.config.create>().pipe( +export function createConfig$( + core: CoreSetup, + config$: Observable, + logger: LevelLogger +) { + return config$.pipe( map((config) => { // encryption key let encryptionKey = config.encryptionKey; diff --git a/x-pack/plugins/reporting/server/config/index.ts b/x-pack/plugins/reporting/server/config/index.ts index a0d7618322c653..caa64a7414005e 100644 --- a/x-pack/plugins/reporting/server/config/index.ts +++ b/x-pack/plugins/reporting/server/config/index.ts @@ -5,11 +5,12 @@ */ import { PluginConfigDescriptor } from 'kibana/server'; -import { ConfigSchema, ConfigType } from './schema'; - +import { ConfigSchema, ReportingConfigType } from './schema'; +export { buildConfig } from './config'; export { createConfig$ } from './create_config'; +export { ConfigSchema, ReportingConfigType }; -export const config: PluginConfigDescriptor = { +export const config: PluginConfigDescriptor = { exposeToBrowser: { poll: true }, schema: ConfigSchema, deprecations: ({ unused }) => [ @@ -20,5 +21,3 @@ export const config: PluginConfigDescriptor = { unused('kibanaApp'), ], }; - -export { ConfigSchema, ConfigType }; diff --git a/x-pack/plugins/reporting/server/config/schema.ts b/x-pack/plugins/reporting/server/config/schema.ts index 402fddcb5e0146..dfabfa98f8cbf3 100644 --- a/x-pack/plugins/reporting/server/config/schema.ts +++ b/x-pack/plugins/reporting/server/config/schema.ts @@ -172,4 +172,4 @@ export const ConfigSchema = schema.object({ poll: PollSchema, }); -export type ConfigType = TypeOf; +export type ReportingConfigType = TypeOf; diff --git a/x-pack/legacy/plugins/reporting/server/core.ts b/x-pack/plugins/reporting/server/core.ts similarity index 92% rename from x-pack/legacy/plugins/reporting/server/core.ts rename to x-pack/plugins/reporting/server/core.ts index b89ef9e06b9610..e7786b3b753fbf 100644 --- a/x-pack/legacy/plugins/reporting/server/core.ts +++ b/x-pack/plugins/reporting/server/core.ts @@ -5,22 +5,22 @@ */ import * as Rx from 'rxjs'; -import { first, mapTo, map } from 'rxjs/operators'; +import { first, map, mapTo } from 'rxjs/operators'; import { + BasePath, ElasticsearchServiceSetup, + IRouter, KibanaRequest, + SavedObjectsClientContract, SavedObjectsServiceStart, UiSettingsServiceStart, - IRouter, - SavedObjectsClientContract, - BasePath, } from 'src/core/server'; -import { SecurityPluginSetup } from '../../../../plugins/security/server'; -import { LicensingPluginSetup } from '../../../../plugins/licensing/server'; -import { screenshotsObservableFactory } from '../export_types/common/lib/screenshots'; +import { LicensingPluginSetup } from '../../licensing/server'; +import { SecurityPluginSetup } from '../../security/server'; import { ScreenshotsObservableFn } from '../server/types'; import { ReportingConfig } from './'; import { HeadlessChromiumDriverFactory } from './browsers/chromium/driver_factory'; +import { screenshotsObservableFactory } from './export_types/common/lib/screenshots'; import { checkLicense, getExportTypesRegistry } from './lib'; import { ESQueueInstance } from './lib/create_queue'; import { EnqueueJobFn } from './lib/enqueue_job'; @@ -31,7 +31,7 @@ export interface ReportingInternalSetup { licensing: LicensingPluginSetup; basePath: BasePath['get']; router: IRouter; - security: SecurityPluginSetup; + security?: SecurityPluginSetup; } interface ReportingInternalStart { diff --git a/x-pack/legacy/plugins/reporting/export_types/common/constants.ts b/x-pack/plugins/reporting/server/export_types/common/constants.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/export_types/common/constants.ts rename to x-pack/plugins/reporting/server/export_types/common/constants.ts diff --git a/x-pack/legacy/plugins/reporting/export_types/common/execute_job/decrypt_job_headers.test.ts b/x-pack/plugins/reporting/server/export_types/common/execute_job/decrypt_job_headers.test.ts similarity index 96% rename from x-pack/legacy/plugins/reporting/export_types/common/execute_job/decrypt_job_headers.test.ts rename to x-pack/plugins/reporting/server/export_types/common/execute_job/decrypt_job_headers.test.ts index fe3ac16b79fe06..4998d936c9b166 100644 --- a/x-pack/legacy/plugins/reporting/export_types/common/execute_job/decrypt_job_headers.test.ts +++ b/x-pack/plugins/reporting/server/export_types/common/execute_job/decrypt_job_headers.test.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { cryptoFactory, LevelLogger } from '../../../server/lib'; +import { cryptoFactory, LevelLogger } from '../../../lib'; import { decryptJobHeaders } from './decrypt_job_headers'; const encryptHeaders = async (encryptionKey: string, headers: Record) => { diff --git a/x-pack/legacy/plugins/reporting/export_types/common/execute_job/decrypt_job_headers.ts b/x-pack/plugins/reporting/server/export_types/common/execute_job/decrypt_job_headers.ts similarity index 95% rename from x-pack/legacy/plugins/reporting/export_types/common/execute_job/decrypt_job_headers.ts rename to x-pack/plugins/reporting/server/export_types/common/execute_job/decrypt_job_headers.ts index a13c1fa2a9efb4..e5124c80601d7f 100644 --- a/x-pack/legacy/plugins/reporting/export_types/common/execute_job/decrypt_job_headers.ts +++ b/x-pack/plugins/reporting/server/export_types/common/execute_job/decrypt_job_headers.ts @@ -5,7 +5,7 @@ */ import { i18n } from '@kbn/i18n'; -import { cryptoFactory, LevelLogger } from '../../../server/lib'; +import { cryptoFactory, LevelLogger } from '../../../lib'; interface HasEncryptedHeaders { headers?: string; diff --git a/x-pack/legacy/plugins/reporting/export_types/common/execute_job/get_conditional_headers.test.ts b/x-pack/plugins/reporting/server/export_types/common/execute_job/get_conditional_headers.test.ts similarity index 97% rename from x-pack/legacy/plugins/reporting/export_types/common/execute_job/get_conditional_headers.test.ts rename to x-pack/plugins/reporting/server/export_types/common/execute_job/get_conditional_headers.test.ts index 5067d5f5e5dd82..5d651ad5f8aea1 100644 --- a/x-pack/legacy/plugins/reporting/export_types/common/execute_job/get_conditional_headers.test.ts +++ b/x-pack/plugins/reporting/server/export_types/common/execute_job/get_conditional_headers.test.ts @@ -5,9 +5,10 @@ */ import sinon from 'sinon'; -import { ReportingConfig, ReportingCore } from '../../../server'; -import { JobDocPayload } from '../../../server/types'; +import { ReportingConfig } from '../../../'; +import { ReportingCore } from '../../../core'; import { createMockReportingCore } from '../../../test_helpers'; +import { JobDocPayload } from '../../../types'; import { JobDocPayloadPDF } from '../../printable_pdf/types'; import { getConditionalHeaders, getCustomLogo } from './index'; diff --git a/x-pack/legacy/plugins/reporting/export_types/common/execute_job/get_conditional_headers.ts b/x-pack/plugins/reporting/server/export_types/common/execute_job/get_conditional_headers.ts similarity index 89% rename from x-pack/legacy/plugins/reporting/export_types/common/execute_job/get_conditional_headers.ts rename to x-pack/plugins/reporting/server/export_types/common/execute_job/get_conditional_headers.ts index 808d5db5c57d5a..6854f678aa9759 100644 --- a/x-pack/legacy/plugins/reporting/export_types/common/execute_job/get_conditional_headers.ts +++ b/x-pack/plugins/reporting/server/export_types/common/execute_job/get_conditional_headers.ts @@ -4,8 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ -import { ReportingConfig } from '../../../server'; -import { ConditionalHeaders } from '../../../server/types'; +import { ReportingConfig } from '../../../'; +import { ConditionalHeaders } from '../../../types'; export const getConditionalHeaders = ({ config, diff --git a/x-pack/legacy/plugins/reporting/export_types/common/execute_job/get_custom_logo.test.ts b/x-pack/plugins/reporting/server/export_types/common/execute_job/get_custom_logo.test.ts similarity index 97% rename from x-pack/legacy/plugins/reporting/export_types/common/execute_job/get_custom_logo.test.ts rename to x-pack/plugins/reporting/server/export_types/common/execute_job/get_custom_logo.test.ts index 2cbde69c81316f..bd6eb4644d87f9 100644 --- a/x-pack/legacy/plugins/reporting/export_types/common/execute_job/get_custom_logo.test.ts +++ b/x-pack/plugins/reporting/server/export_types/common/execute_job/get_custom_logo.test.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { ReportingCore } from '../../../server'; +import { ReportingCore } from '../../../core'; import { createMockReportingCore } from '../../../test_helpers'; import { JobDocPayloadPDF } from '../../printable_pdf/types'; import { getConditionalHeaders, getCustomLogo } from './index'; diff --git a/x-pack/legacy/plugins/reporting/export_types/common/execute_job/get_custom_logo.ts b/x-pack/plugins/reporting/server/export_types/common/execute_job/get_custom_logo.ts similarity index 87% rename from x-pack/legacy/plugins/reporting/export_types/common/execute_job/get_custom_logo.ts rename to x-pack/plugins/reporting/server/export_types/common/execute_job/get_custom_logo.ts index 777de317af41e1..85d1272fc22ced 100644 --- a/x-pack/legacy/plugins/reporting/export_types/common/execute_job/get_custom_logo.ts +++ b/x-pack/plugins/reporting/server/export_types/common/execute_job/get_custom_logo.ts @@ -4,9 +4,9 @@ * you may not use this file except in compliance with the Elastic License. */ -import { UI_SETTINGS_CUSTOM_PDF_LOGO } from '../../../common/constants'; -import { ReportingConfig, ReportingCore } from '../../../server'; -import { ConditionalHeaders } from '../../../server/types'; +import { ReportingConfig, ReportingCore } from '../../../'; +import { UI_SETTINGS_CUSTOM_PDF_LOGO } from '../../../../common/constants'; +import { ConditionalHeaders } from '../../../types'; import { JobDocPayloadPDF } from '../../printable_pdf/types'; // Logo is PDF only export const getCustomLogo = async ({ diff --git a/x-pack/legacy/plugins/reporting/export_types/common/execute_job/get_full_urls.test.ts b/x-pack/plugins/reporting/server/export_types/common/execute_job/get_full_urls.test.ts similarity index 99% rename from x-pack/legacy/plugins/reporting/export_types/common/execute_job/get_full_urls.test.ts rename to x-pack/plugins/reporting/server/export_types/common/execute_job/get_full_urls.test.ts index 6529dd91496cb5..5b5a6b06930fea 100644 --- a/x-pack/legacy/plugins/reporting/export_types/common/execute_job/get_full_urls.test.ts +++ b/x-pack/plugins/reporting/server/export_types/common/execute_job/get_full_urls.test.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { ReportingConfig } from '../../../server'; +import { ReportingConfig } from '../../../'; import { JobDocPayloadPNG } from '../../png/types'; import { JobDocPayloadPDF } from '../../printable_pdf/types'; import { getFullUrls } from './get_full_urls'; diff --git a/x-pack/legacy/plugins/reporting/export_types/common/execute_job/get_full_urls.ts b/x-pack/plugins/reporting/server/export_types/common/execute_job/get_full_urls.ts similarity index 93% rename from x-pack/legacy/plugins/reporting/export_types/common/execute_job/get_full_urls.ts rename to x-pack/plugins/reporting/server/export_types/common/execute_job/get_full_urls.ts index 6c7c77345bbcc0..642b1c02869283 100644 --- a/x-pack/legacy/plugins/reporting/export_types/common/execute_job/get_full_urls.ts +++ b/x-pack/plugins/reporting/server/export_types/common/execute_job/get_full_urls.ts @@ -7,12 +7,12 @@ import { format as urlFormat, parse as urlParse, - UrlWithStringQuery, UrlWithParsedQuery, + UrlWithStringQuery, } from 'url'; -import { getAbsoluteUrlFactory } from '../../../common/get_absolute_url'; -import { validateUrls } from '../../../common/validate_urls'; -import { ReportingConfig } from '../../../server'; +import { ReportingConfig } from '../../..'; +import { getAbsoluteUrlFactory } from '../../../../common/get_absolute_url'; +import { validateUrls } from '../../../../common/validate_urls'; import { JobDocPayloadPNG } from '../../png/types'; import { JobDocPayloadPDF } from '../../printable_pdf/types'; diff --git a/x-pack/legacy/plugins/reporting/export_types/common/execute_job/index.ts b/x-pack/plugins/reporting/server/export_types/common/execute_job/index.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/export_types/common/execute_job/index.ts rename to x-pack/plugins/reporting/server/export_types/common/execute_job/index.ts diff --git a/x-pack/legacy/plugins/reporting/export_types/common/execute_job/omit_blacklisted_headers.test.ts b/x-pack/plugins/reporting/server/export_types/common/execute_job/omit_blacklisted_headers.test.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/export_types/common/execute_job/omit_blacklisted_headers.test.ts rename to x-pack/plugins/reporting/server/export_types/common/execute_job/omit_blacklisted_headers.test.ts diff --git a/x-pack/legacy/plugins/reporting/export_types/common/execute_job/omit_blacklisted_headers.ts b/x-pack/plugins/reporting/server/export_types/common/execute_job/omit_blacklisted_headers.ts similarity index 95% rename from x-pack/legacy/plugins/reporting/export_types/common/execute_job/omit_blacklisted_headers.ts rename to x-pack/plugins/reporting/server/export_types/common/execute_job/omit_blacklisted_headers.ts index 0e5974225b932b..5147881a980eac 100644 --- a/x-pack/legacy/plugins/reporting/export_types/common/execute_job/omit_blacklisted_headers.ts +++ b/x-pack/plugins/reporting/server/export_types/common/execute_job/omit_blacklisted_headers.ts @@ -7,7 +7,7 @@ import { omit } from 'lodash'; import { KBN_SCREENSHOT_HEADER_BLACKLIST, KBN_SCREENSHOT_HEADER_BLACKLIST_STARTS_WITH_PATTERN, -} from '../../../common/constants'; +} from '../../../../common/constants'; export const omitBlacklistedHeaders = ({ job, diff --git a/x-pack/legacy/plugins/reporting/export_types/common/layouts/create_layout.ts b/x-pack/plugins/reporting/server/export_types/common/layouts/create_layout.ts similarity index 93% rename from x-pack/legacy/plugins/reporting/export_types/common/layouts/create_layout.ts rename to x-pack/plugins/reporting/server/export_types/common/layouts/create_layout.ts index d33760fcb4f89d..216a59d41cec01 100644 --- a/x-pack/legacy/plugins/reporting/export_types/common/layouts/create_layout.ts +++ b/x-pack/plugins/reporting/server/export_types/common/layouts/create_layout.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { CaptureConfig } from '../../../server/types'; +import { CaptureConfig } from '../../../types'; import { LayoutParams, LayoutTypes } from './'; import { Layout } from './layout'; import { PreserveLayout } from './preserve_layout'; diff --git a/x-pack/legacy/plugins/reporting/export_types/common/layouts/index.ts b/x-pack/plugins/reporting/server/export_types/common/layouts/index.ts similarity index 93% rename from x-pack/legacy/plugins/reporting/export_types/common/layouts/index.ts rename to x-pack/plugins/reporting/server/export_types/common/layouts/index.ts index 993b8f6cdc9ab6..23e4c095afe611 100644 --- a/x-pack/legacy/plugins/reporting/export_types/common/layouts/index.ts +++ b/x-pack/plugins/reporting/server/export_types/common/layouts/index.ts @@ -4,8 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ -import { HeadlessChromiumDriver } from '../../../server/browsers'; -import { LevelLogger } from '../../../server/lib'; +import { HeadlessChromiumDriver } from '../../../browsers'; +import { LevelLogger } from '../../../lib'; import { Layout } from './layout'; export { createLayout } from './create_layout'; diff --git a/x-pack/legacy/plugins/reporting/export_types/common/layouts/layout.ts b/x-pack/plugins/reporting/server/export_types/common/layouts/layout.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/export_types/common/layouts/layout.ts rename to x-pack/plugins/reporting/server/export_types/common/layouts/layout.ts diff --git a/x-pack/legacy/plugins/reporting/export_types/common/layouts/preserve_layout.css b/x-pack/plugins/reporting/server/export_types/common/layouts/preserve_layout.css similarity index 100% rename from x-pack/legacy/plugins/reporting/export_types/common/layouts/preserve_layout.css rename to x-pack/plugins/reporting/server/export_types/common/layouts/preserve_layout.css diff --git a/x-pack/legacy/plugins/reporting/export_types/common/layouts/preserve_layout.ts b/x-pack/plugins/reporting/server/export_types/common/layouts/preserve_layout.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/export_types/common/layouts/preserve_layout.ts rename to x-pack/plugins/reporting/server/export_types/common/layouts/preserve_layout.ts diff --git a/x-pack/legacy/plugins/reporting/export_types/common/layouts/print.css b/x-pack/plugins/reporting/server/export_types/common/layouts/print.css similarity index 100% rename from x-pack/legacy/plugins/reporting/export_types/common/layouts/print.css rename to x-pack/plugins/reporting/server/export_types/common/layouts/print.css diff --git a/x-pack/legacy/plugins/reporting/export_types/common/layouts/print_layout.ts b/x-pack/plugins/reporting/server/export_types/common/layouts/print_layout.ts similarity index 94% rename from x-pack/legacy/plugins/reporting/export_types/common/layouts/print_layout.ts rename to x-pack/plugins/reporting/server/export_types/common/layouts/print_layout.ts index 759f07a33e2b63..30c83771aa3c93 100644 --- a/x-pack/legacy/plugins/reporting/export_types/common/layouts/print_layout.ts +++ b/x-pack/plugins/reporting/server/export_types/common/layouts/print_layout.ts @@ -6,9 +6,9 @@ import path from 'path'; import { EvaluateFn, SerializableOrJSHandle } from 'puppeteer'; -import { LevelLogger } from '../../../server/lib'; -import { HeadlessChromiumDriver } from '../../../server/browsers'; -import { CaptureConfig } from '../../../server/types'; +import { CaptureConfig } from '../../../types'; +import { HeadlessChromiumDriver } from '../../../browsers'; +import { LevelLogger } from '../../../lib'; import { getDefaultLayoutSelectors, LayoutSelectorDictionary, Size, LayoutTypes } from './'; import { Layout } from './layout'; diff --git a/x-pack/legacy/plugins/reporting/export_types/common/lib/screenshots/constants.ts b/x-pack/plugins/reporting/server/export_types/common/lib/screenshots/constants.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/export_types/common/lib/screenshots/constants.ts rename to x-pack/plugins/reporting/server/export_types/common/lib/screenshots/constants.ts diff --git a/x-pack/legacy/plugins/reporting/export_types/common/lib/screenshots/get_element_position_data.ts b/x-pack/plugins/reporting/server/export_types/common/lib/screenshots/get_element_position_data.ts similarity index 94% rename from x-pack/legacy/plugins/reporting/export_types/common/lib/screenshots/get_element_position_data.ts rename to x-pack/plugins/reporting/server/export_types/common/lib/screenshots/get_element_position_data.ts index d02e852a3c1b65..140d76f8d1cd6c 100644 --- a/x-pack/legacy/plugins/reporting/export_types/common/lib/screenshots/get_element_position_data.ts +++ b/x-pack/plugins/reporting/server/export_types/common/lib/screenshots/get_element_position_data.ts @@ -5,9 +5,9 @@ */ import { i18n } from '@kbn/i18n'; -import { HeadlessChromiumDriver } from '../../../../server/browsers'; -import { LevelLogger, startTrace } from '../../../../server/lib'; -import { AttributesMap, ElementsPositionAndAttribute } from '../../../../server/types'; +import { HeadlessChromiumDriver } from '../../../../browsers'; +import { LevelLogger, startTrace } from '../../../../lib'; +import { AttributesMap, ElementsPositionAndAttribute } from '../../../../types'; import { LayoutInstance } from '../../layouts'; import { CONTEXT_ELEMENTATTRIBUTES } from './constants'; diff --git a/x-pack/legacy/plugins/reporting/export_types/common/lib/screenshots/get_number_of_items.ts b/x-pack/plugins/reporting/server/export_types/common/lib/screenshots/get_number_of_items.ts similarity index 93% rename from x-pack/legacy/plugins/reporting/export_types/common/lib/screenshots/get_number_of_items.ts rename to x-pack/plugins/reporting/server/export_types/common/lib/screenshots/get_number_of_items.ts index 9e446f499ab3a3..42eb91ecba830b 100644 --- a/x-pack/legacy/plugins/reporting/export_types/common/lib/screenshots/get_number_of_items.ts +++ b/x-pack/plugins/reporting/server/export_types/common/lib/screenshots/get_number_of_items.ts @@ -5,9 +5,9 @@ */ import { i18n } from '@kbn/i18n'; -import { LevelLogger, startTrace } from '../../../../server/lib'; -import { HeadlessChromiumDriver } from '../../../../server/browsers'; -import { CaptureConfig } from '../../../../server/types'; +import { HeadlessChromiumDriver } from '../../../../browsers'; +import { LevelLogger, startTrace } from '../../../../lib'; +import { CaptureConfig } from '../../../../types'; import { LayoutInstance } from '../../layouts'; import { CONTEXT_GETNUMBEROFITEMS, CONTEXT_READMETADATA } from './constants'; diff --git a/x-pack/legacy/plugins/reporting/export_types/common/lib/screenshots/get_screenshots.ts b/x-pack/plugins/reporting/server/export_types/common/lib/screenshots/get_screenshots.ts similarity index 89% rename from x-pack/legacy/plugins/reporting/export_types/common/lib/screenshots/get_screenshots.ts rename to x-pack/plugins/reporting/server/export_types/common/lib/screenshots/get_screenshots.ts index 578a4dd0b975c2..05c315b8341a33 100644 --- a/x-pack/legacy/plugins/reporting/export_types/common/lib/screenshots/get_screenshots.ts +++ b/x-pack/plugins/reporting/server/export_types/common/lib/screenshots/get_screenshots.ts @@ -5,9 +5,9 @@ */ import { i18n } from '@kbn/i18n'; -import { HeadlessChromiumDriver } from '../../../../server/browsers'; -import { LevelLogger, startTrace } from '../../../../server/lib'; -import { ElementsPositionAndAttribute, Screenshot } from '../../../../server/types'; +import { HeadlessChromiumDriver } from '../../../../browsers'; +import { LevelLogger, startTrace } from '../../../../lib'; +import { ElementsPositionAndAttribute, Screenshot } from '../../../../types'; export const getScreenshots = async ( browser: HeadlessChromiumDriver, diff --git a/x-pack/legacy/plugins/reporting/export_types/common/lib/screenshots/get_time_range.ts b/x-pack/plugins/reporting/server/export_types/common/lib/screenshots/get_time_range.ts similarity index 90% rename from x-pack/legacy/plugins/reporting/export_types/common/lib/screenshots/get_time_range.ts rename to x-pack/plugins/reporting/server/export_types/common/lib/screenshots/get_time_range.ts index 74926918584fe4..ba68a5fec4e4cc 100644 --- a/x-pack/legacy/plugins/reporting/export_types/common/lib/screenshots/get_time_range.ts +++ b/x-pack/plugins/reporting/server/export_types/common/lib/screenshots/get_time_range.ts @@ -4,8 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ -import { LevelLogger, startTrace } from '../../../../server/lib'; -import { HeadlessChromiumDriver } from '../../../../server/browsers'; +import { HeadlessChromiumDriver } from '../../../../browsers'; +import { LevelLogger, startTrace } from '../../../../lib'; import { LayoutInstance } from '../../layouts'; import { CONTEXT_GETTIMERANGE } from './constants'; diff --git a/x-pack/legacy/plugins/reporting/export_types/common/lib/screenshots/index.ts b/x-pack/plugins/reporting/server/export_types/common/lib/screenshots/index.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/export_types/common/lib/screenshots/index.ts rename to x-pack/plugins/reporting/server/export_types/common/lib/screenshots/index.ts diff --git a/x-pack/legacy/plugins/reporting/export_types/common/lib/screenshots/inject_css.ts b/x-pack/plugins/reporting/server/export_types/common/lib/screenshots/inject_css.ts similarity index 92% rename from x-pack/legacy/plugins/reporting/export_types/common/lib/screenshots/inject_css.ts rename to x-pack/plugins/reporting/server/export_types/common/lib/screenshots/inject_css.ts index 8a198880a77685..d72afacc1bef3c 100644 --- a/x-pack/legacy/plugins/reporting/export_types/common/lib/screenshots/inject_css.ts +++ b/x-pack/plugins/reporting/server/export_types/common/lib/screenshots/inject_css.ts @@ -7,8 +7,8 @@ import { i18n } from '@kbn/i18n'; import fs from 'fs'; import { promisify } from 'util'; -import { LevelLogger, startTrace } from '../../../../server/lib'; -import { HeadlessChromiumDriver } from '../../../../server/browsers'; +import { HeadlessChromiumDriver } from '../../../../browsers'; +import { LevelLogger, startTrace } from '../../../../lib'; import { Layout } from '../../layouts/layout'; import { CONTEXT_INJECTCSS } from './constants'; diff --git a/x-pack/legacy/plugins/reporting/export_types/common/lib/screenshots/observable.test.ts b/x-pack/plugins/reporting/server/export_types/common/lib/screenshots/observable.test.ts similarity index 97% rename from x-pack/legacy/plugins/reporting/export_types/common/lib/screenshots/observable.test.ts rename to x-pack/plugins/reporting/server/export_types/common/lib/screenshots/observable.test.ts index cc8b4383104304..2ddb4a5d5b9943 100644 --- a/x-pack/legacy/plugins/reporting/export_types/common/lib/screenshots/observable.test.ts +++ b/x-pack/plugins/reporting/server/export_types/common/lib/screenshots/observable.test.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -jest.mock('../../../../server/browsers/chromium/puppeteer', () => ({ +jest.mock('../../../../browsers/chromium/puppeteer', () => ({ puppeteerLaunch: () => ({ // Fixme needs event emitters newPage: () => ({ @@ -18,14 +18,10 @@ jest.mock('../../../../server/browsers/chromium/puppeteer', () => ({ import * as Rx from 'rxjs'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths import { loggingServiceMock } from '../../../../../../../../src/core/server/mocks'; -import { HeadlessChromiumDriver } from '../../../../server/browsers'; -import { LevelLogger } from '../../../../server/lib'; -import { - CaptureConfig, - ConditionalHeaders, - ElementsPositionAndAttribute, -} from '../../../../server/types'; +import { HeadlessChromiumDriver } from '../../../../browsers'; +import { LevelLogger } from '../../../../lib'; import { createMockBrowserDriverFactory, createMockLayoutInstance } from '../../../../test_helpers'; +import { CaptureConfig, ConditionalHeaders, ElementsPositionAndAttribute } from '../../../../types'; import * as contexts from './constants'; import { screenshotsObservableFactory } from './observable'; diff --git a/x-pack/legacy/plugins/reporting/export_types/common/lib/screenshots/observable.ts b/x-pack/plugins/reporting/server/export_types/common/lib/screenshots/observable.ts similarity index 98% rename from x-pack/legacy/plugins/reporting/export_types/common/lib/screenshots/observable.ts rename to x-pack/plugins/reporting/server/export_types/common/lib/screenshots/observable.ts index bb11d1d3b7b63b..028bff4aaa5eee 100644 --- a/x-pack/legacy/plugins/reporting/export_types/common/lib/screenshots/observable.ts +++ b/x-pack/plugins/reporting/server/export_types/common/lib/screenshots/observable.ts @@ -16,14 +16,14 @@ import { tap, toArray, } from 'rxjs/operators'; -import { HeadlessChromiumDriverFactory } from '../../../../server/browsers'; +import { HeadlessChromiumDriverFactory } from '../../../../browsers'; import { CaptureConfig, ElementsPositionAndAttribute, ScreenshotObservableOpts, ScreenshotResults, ScreenshotsObservableFn, -} from '../../../../server/types'; +} from '../../../../types'; import { DEFAULT_PAGELOAD_SELECTOR } from '../../constants'; import { getElementPositionAndAttributes } from './get_element_position_data'; import { getNumberOfItems } from './get_number_of_items'; diff --git a/x-pack/legacy/plugins/reporting/export_types/common/lib/screenshots/open_url.ts b/x-pack/plugins/reporting/server/export_types/common/lib/screenshots/open_url.ts similarity index 83% rename from x-pack/legacy/plugins/reporting/export_types/common/lib/screenshots/open_url.ts rename to x-pack/plugins/reporting/server/export_types/common/lib/screenshots/open_url.ts index 3cf962b8178fdc..bd7e8c508c118f 100644 --- a/x-pack/legacy/plugins/reporting/export_types/common/lib/screenshots/open_url.ts +++ b/x-pack/plugins/reporting/server/export_types/common/lib/screenshots/open_url.ts @@ -5,9 +5,9 @@ */ import { i18n } from '@kbn/i18n'; -import { HeadlessChromiumDriver } from '../../../../server/browsers'; -import { LevelLogger, startTrace } from '../../../../server/lib'; -import { CaptureConfig, ConditionalHeaders } from '../../../../server/types'; +import { HeadlessChromiumDriver } from '../../../../browsers'; +import { LevelLogger, startTrace } from '../../../../lib'; +import { CaptureConfig, ConditionalHeaders } from '../../../../types'; export const openUrl = async ( captureConfig: CaptureConfig, diff --git a/x-pack/legacy/plugins/reporting/export_types/common/lib/screenshots/wait_for_render.ts b/x-pack/plugins/reporting/server/export_types/common/lib/screenshots/wait_for_render.ts similarity index 93% rename from x-pack/legacy/plugins/reporting/export_types/common/lib/screenshots/wait_for_render.ts rename to x-pack/plugins/reporting/server/export_types/common/lib/screenshots/wait_for_render.ts index c31c55ea8dec66..b6519e914430a5 100644 --- a/x-pack/legacy/plugins/reporting/export_types/common/lib/screenshots/wait_for_render.ts +++ b/x-pack/plugins/reporting/server/export_types/common/lib/screenshots/wait_for_render.ts @@ -5,9 +5,9 @@ */ import { i18n } from '@kbn/i18n'; -import { LevelLogger, startTrace } from '../../../../server/lib'; -import { HeadlessChromiumDriver } from '../../../../server/browsers'; -import { CaptureConfig } from '../../../../server/types'; +import { HeadlessChromiumDriver } from '../../../../browsers'; +import { LevelLogger, startTrace } from '../../../../lib'; +import { CaptureConfig } from '../../../../types'; import { LayoutInstance } from '../../layouts'; import { CONTEXT_WAITFORRENDER } from './constants'; diff --git a/x-pack/legacy/plugins/reporting/export_types/common/lib/screenshots/wait_for_visualizations.ts b/x-pack/plugins/reporting/server/export_types/common/lib/screenshots/wait_for_visualizations.ts similarity index 91% rename from x-pack/legacy/plugins/reporting/export_types/common/lib/screenshots/wait_for_visualizations.ts rename to x-pack/plugins/reporting/server/export_types/common/lib/screenshots/wait_for_visualizations.ts index ff84d06956dbc1..75a7b6516473cb 100644 --- a/x-pack/legacy/plugins/reporting/export_types/common/lib/screenshots/wait_for_visualizations.ts +++ b/x-pack/plugins/reporting/server/export_types/common/lib/screenshots/wait_for_visualizations.ts @@ -5,9 +5,9 @@ */ import { i18n } from '@kbn/i18n'; -import { LevelLogger, startTrace } from '../../../../server/lib'; -import { HeadlessChromiumDriver } from '../../../../server/browsers'; -import { CaptureConfig } from '../../../../server/types'; +import { HeadlessChromiumDriver } from '../../../../browsers'; +import { LevelLogger, startTrace } from '../../../../lib'; +import { CaptureConfig } from '../../../../types'; import { LayoutInstance } from '../../layouts'; import { CONTEXT_WAITFORELEMENTSTOBEINDOM } from './constants'; diff --git a/x-pack/legacy/plugins/reporting/export_types/csv/index.ts b/x-pack/plugins/reporting/server/export_types/csv/index.ts similarity index 85% rename from x-pack/legacy/plugins/reporting/export_types/csv/index.ts rename to x-pack/plugins/reporting/server/export_types/csv/index.ts index cdb4c36dba3df5..8642a6d5758a80 100644 --- a/x-pack/legacy/plugins/reporting/export_types/csv/index.ts +++ b/x-pack/plugins/reporting/server/export_types/csv/index.ts @@ -5,19 +5,15 @@ */ import { - CSV_JOB_TYPE as jobType, LICENSE_TYPE_BASIC, LICENSE_TYPE_ENTERPRISE, LICENSE_TYPE_GOLD, LICENSE_TYPE_PLATINUM, LICENSE_TYPE_STANDARD, LICENSE_TYPE_TRIAL, -} from '../../common/constants'; -import { - ESQueueCreateJobFn, - ESQueueWorkerExecuteFn, - ExportTypeDefinition, -} from '../../server/types'; +} from '../../../common/constants'; +import { CSV_JOB_TYPE as jobType } from '../../../constants'; +import { ESQueueCreateJobFn, ESQueueWorkerExecuteFn, ExportTypeDefinition } from '../../types'; import { metadata } from './metadata'; import { createJobFactory } from './server/create_job'; import { executeJobFactory } from './server/execute_job'; diff --git a/x-pack/legacy/plugins/reporting/export_types/csv/metadata.ts b/x-pack/plugins/reporting/server/export_types/csv/metadata.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/export_types/csv/metadata.ts rename to x-pack/plugins/reporting/server/export_types/csv/metadata.ts diff --git a/x-pack/legacy/plugins/reporting/export_types/csv/server/create_job.ts b/x-pack/plugins/reporting/server/export_types/csv/server/create_job.ts similarity index 87% rename from x-pack/legacy/plugins/reporting/export_types/csv/server/create_job.ts rename to x-pack/plugins/reporting/server/export_types/csv/server/create_job.ts index c76b4afe727daa..acf7f0505a735e 100644 --- a/x-pack/legacy/plugins/reporting/export_types/csv/server/create_job.ts +++ b/x-pack/plugins/reporting/server/export_types/csv/server/create_job.ts @@ -5,9 +5,9 @@ */ import { KibanaRequest, RequestHandlerContext } from 'src/core/server'; -import { ReportingCore } from '../../../server'; -import { cryptoFactory } from '../../../server/lib'; -import { CreateJobFactory, ESQueueCreateJobFn } from '../../../server/types'; +import { ReportingCore } from '../../../'; +import { cryptoFactory } from '../../../lib'; +import { CreateJobFactory, ESQueueCreateJobFn } from '../../../types'; import { JobParamsDiscoverCsv } from '../types'; export const createJobFactory: CreateJobFactory Promise.resolve(mockUiSettingsClient); - mockReportingPlugin.getElasticsearchService = () => Promise.resolve(mockElasticsearch); + mockReportingCore = await createMockReportingCore(mockReportingConfig); + mockReportingCore.getUiSettingsServiceFactory = () => Promise.resolve(mockUiSettingsClient); + mockReportingCore.getElasticsearchService = () => Promise.resolve(mockElasticsearch); + mockReportingCore.config = mockReportingConfig; cancellationToken = new CancellationToken(); @@ -116,7 +117,7 @@ describe('CSV Execute Job', function () { describe('basic Elasticsearch call behavior', function () { it('should decrypt encrypted headers and pass to callAsCurrentUser', async function () { - const executeJob = await executeJobFactory(mockReportingPlugin, mockLogger); + const executeJob = await executeJobFactory(mockReportingCore, mockLogger); await executeJob( 'job456', getJobDocPayload({ @@ -136,7 +137,7 @@ describe('CSV Execute Job', function () { testBody: true, }; - const executeJob = await executeJobFactory(mockReportingPlugin, mockLogger); + const executeJob = await executeJobFactory(mockReportingCore, mockLogger); const job = getJobDocPayload({ headers: encryptedHeaders, fields: [], @@ -163,7 +164,7 @@ describe('CSV Execute Job', function () { _scroll_id: scrollId, }); callAsCurrentUserStub.onSecondCall().resolves(defaultElasticsearchResponse); - const executeJob = await executeJobFactory(mockReportingPlugin, mockLogger); + const executeJob = await executeJobFactory(mockReportingCore, mockLogger); await executeJob( 'job456', getJobDocPayload({ @@ -181,7 +182,7 @@ describe('CSV Execute Job', function () { }); it('should not execute scroll if there are no hits from the search', async function () { - const executeJob = await executeJobFactory(mockReportingPlugin, mockLogger); + const executeJob = await executeJobFactory(mockReportingCore, mockLogger); await executeJob( 'job456', getJobDocPayload({ @@ -215,7 +216,7 @@ describe('CSV Execute Job', function () { _scroll_id: 'scrollId', }); - const executeJob = await executeJobFactory(mockReportingPlugin, mockLogger); + const executeJob = await executeJobFactory(mockReportingCore, mockLogger); await executeJob( 'job456', getJobDocPayload({ @@ -254,7 +255,7 @@ describe('CSV Execute Job', function () { _scroll_id: lastScrollId, }); - const executeJob = await executeJobFactory(mockReportingPlugin, mockLogger); + const executeJob = await executeJobFactory(mockReportingCore, mockLogger); await executeJob( 'job456', getJobDocPayload({ @@ -286,7 +287,7 @@ describe('CSV Execute Job', function () { _scroll_id: lastScrollId, }); - const executeJob = await executeJobFactory(mockReportingPlugin, mockLogger); + const executeJob = await executeJobFactory(mockReportingCore, mockLogger); const jobParams = getJobDocPayload({ headers: encryptedHeaders, fields: ['one', 'two'], @@ -313,7 +314,7 @@ describe('CSV Execute Job', function () { _scroll_id: 'scrollId', }); - const executeJob = await executeJobFactory(mockReportingPlugin, mockLogger); + const executeJob = await executeJobFactory(mockReportingCore, mockLogger); const jobParams = getJobDocPayload({ headers: encryptedHeaders, fields: ['one', 'two'], @@ -338,7 +339,7 @@ describe('CSV Execute Job', function () { _scroll_id: 'scrollId', }); - const executeJob = await executeJobFactory(mockReportingPlugin, mockLogger); + const executeJob = await executeJobFactory(mockReportingCore, mockLogger); const jobParams = getJobDocPayload({ headers: encryptedHeaders, fields: ['=SUM(A1:A2)', 'two'], @@ -364,7 +365,7 @@ describe('CSV Execute Job', function () { _scroll_id: 'scrollId', }); - const executeJob = await executeJobFactory(mockReportingPlugin, mockLogger); + const executeJob = await executeJobFactory(mockReportingCore, mockLogger); const jobParams = getJobDocPayload({ headers: encryptedHeaders, fields: ['one', 'two'], @@ -390,7 +391,7 @@ describe('CSV Execute Job', function () { _scroll_id: 'scrollId', }); - const executeJob = await executeJobFactory(mockReportingPlugin, mockLogger); + const executeJob = await executeJobFactory(mockReportingCore, mockLogger); const jobParams = getJobDocPayload({ headers: encryptedHeaders, fields: ['=SUM(A1:A2)', 'two'], @@ -416,7 +417,7 @@ describe('CSV Execute Job', function () { _scroll_id: 'scrollId', }); - const executeJob = await executeJobFactory(mockReportingPlugin, mockLogger); + const executeJob = await executeJobFactory(mockReportingCore, mockLogger); const jobParams = getJobDocPayload({ headers: encryptedHeaders, fields: ['one', 'two'], @@ -443,7 +444,7 @@ describe('CSV Execute Job', function () { _scroll_id: 'scrollId', }); - const executeJob = await executeJobFactory(mockReportingPlugin, mockLogger); + const executeJob = await executeJobFactory(mockReportingCore, mockLogger); const jobParams = getJobDocPayload({ headers: encryptedHeaders, fields: ['one', 'two'], @@ -464,7 +465,7 @@ describe('CSV Execute Job', function () { _scroll_id: 'scrollId', }); - const executeJob = await executeJobFactory(mockReportingPlugin, mockLogger); + const executeJob = await executeJobFactory(mockReportingCore, mockLogger); const jobParams = getJobDocPayload({ headers: encryptedHeaders, fields: ['one', 'two'], @@ -487,7 +488,7 @@ describe('CSV Execute Job', function () { _scroll_id: 'scrollId', }); - const executeJob = await executeJobFactory(mockReportingPlugin, mockLogger); + const executeJob = await executeJobFactory(mockReportingCore, mockLogger); const jobParams = getJobDocPayload({ headers: encryptedHeaders, fields: ['one', 'two'], @@ -508,7 +509,7 @@ describe('CSV Execute Job', function () { _scroll_id: 'scrollId', }); - const executeJob = await executeJobFactory(mockReportingPlugin, mockLogger); + const executeJob = await executeJobFactory(mockReportingCore, mockLogger); const jobParams = getJobDocPayload({ headers: encryptedHeaders, fields: ['one', 'two'], @@ -524,7 +525,7 @@ describe('CSV Execute Job', function () { describe('Elasticsearch call errors', function () { it('should reject Promise if search call errors out', async function () { callAsCurrentUserStub.rejects(new Error()); - const executeJob = await executeJobFactory(mockReportingPlugin, mockLogger); + const executeJob = await executeJobFactory(mockReportingCore, mockLogger); const jobParams = getJobDocPayload({ headers: encryptedHeaders, fields: [], @@ -543,7 +544,7 @@ describe('CSV Execute Job', function () { _scroll_id: 'scrollId', }); callAsCurrentUserStub.onSecondCall().rejects(new Error()); - const executeJob = await executeJobFactory(mockReportingPlugin, mockLogger); + const executeJob = await executeJobFactory(mockReportingCore, mockLogger); const jobParams = getJobDocPayload({ headers: encryptedHeaders, fields: [], @@ -564,7 +565,7 @@ describe('CSV Execute Job', function () { _scroll_id: undefined, }); - const executeJob = await executeJobFactory(mockReportingPlugin, mockLogger); + const executeJob = await executeJobFactory(mockReportingCore, mockLogger); const jobParams = getJobDocPayload({ headers: encryptedHeaders, fields: [], @@ -585,7 +586,7 @@ describe('CSV Execute Job', function () { _scroll_id: undefined, }); - const executeJob = await executeJobFactory(mockReportingPlugin, mockLogger); + const executeJob = await executeJobFactory(mockReportingCore, mockLogger); const jobParams = getJobDocPayload({ headers: encryptedHeaders, fields: [], @@ -613,7 +614,7 @@ describe('CSV Execute Job', function () { _scroll_id: undefined, }); - const executeJob = await executeJobFactory(mockReportingPlugin, mockLogger); + const executeJob = await executeJobFactory(mockReportingCore, mockLogger); const jobParams = getJobDocPayload({ headers: encryptedHeaders, fields: [], @@ -641,7 +642,7 @@ describe('CSV Execute Job', function () { _scroll_id: undefined, }); - const executeJob = await executeJobFactory(mockReportingPlugin, mockLogger); + const executeJob = await executeJobFactory(mockReportingCore, mockLogger); const jobParams = getJobDocPayload({ headers: encryptedHeaders, fields: [], @@ -678,7 +679,7 @@ describe('CSV Execute Job', function () { }); it('should stop calling Elasticsearch when cancellationToken.cancel is called', async function () { - const executeJob = await executeJobFactory(mockReportingPlugin, mockLogger); + const executeJob = await executeJobFactory(mockReportingCore, mockLogger); executeJob( 'job345', getJobDocPayload({ @@ -697,7 +698,7 @@ describe('CSV Execute Job', function () { }); it(`shouldn't call clearScroll if it never got a scrollId`, async function () { - const executeJob = await executeJobFactory(mockReportingPlugin, mockLogger); + const executeJob = await executeJobFactory(mockReportingCore, mockLogger); executeJob( 'job345', getJobDocPayload({ @@ -715,7 +716,7 @@ describe('CSV Execute Job', function () { }); it('should call clearScroll if it got a scrollId', async function () { - const executeJob = await executeJobFactory(mockReportingPlugin, mockLogger); + const executeJob = await executeJobFactory(mockReportingCore, mockLogger); executeJob( 'job345', getJobDocPayload({ @@ -737,7 +738,7 @@ describe('CSV Execute Job', function () { describe('csv content', function () { it('should write column headers to output, even if there are no results', async function () { - const executeJob = await executeJobFactory(mockReportingPlugin, mockLogger); + const executeJob = await executeJobFactory(mockReportingCore, mockLogger); const jobParams = getJobDocPayload({ headers: encryptedHeaders, fields: ['one', 'two'], @@ -749,7 +750,7 @@ describe('CSV Execute Job', function () { it('should use custom uiSettings csv:separator for header', async function () { mockUiSettingsClient.get.withArgs('csv:separator').returns(';'); - const executeJob = await executeJobFactory(mockReportingPlugin, mockLogger); + const executeJob = await executeJobFactory(mockReportingCore, mockLogger); const jobParams = getJobDocPayload({ headers: encryptedHeaders, fields: ['one', 'two'], @@ -761,7 +762,7 @@ describe('CSV Execute Job', function () { it('should escape column headers if uiSettings csv:quoteValues is true', async function () { mockUiSettingsClient.get.withArgs('csv:quoteValues').returns(true); - const executeJob = await executeJobFactory(mockReportingPlugin, mockLogger); + const executeJob = await executeJobFactory(mockReportingCore, mockLogger); const jobParams = getJobDocPayload({ headers: encryptedHeaders, fields: ['one and a half', 'two', 'three-and-four', 'five & six'], @@ -773,7 +774,7 @@ describe('CSV Execute Job', function () { it(`shouldn't escape column headers if uiSettings csv:quoteValues is false`, async function () { mockUiSettingsClient.get.withArgs('csv:quoteValues').returns(false); - const executeJob = await executeJobFactory(mockReportingPlugin, mockLogger); + const executeJob = await executeJobFactory(mockReportingCore, mockLogger); const jobParams = getJobDocPayload({ headers: encryptedHeaders, fields: ['one and a half', 'two', 'three-and-four', 'five & six'], @@ -784,7 +785,7 @@ describe('CSV Execute Job', function () { }); it('should write column headers to output, when there are results', async function () { - const executeJob = await executeJobFactory(mockReportingPlugin, mockLogger); + const executeJob = await executeJobFactory(mockReportingCore, mockLogger); callAsCurrentUserStub.onFirstCall().resolves({ hits: { hits: [{ one: '1', two: '2' }], @@ -804,7 +805,7 @@ describe('CSV Execute Job', function () { }); it('should use comma separated values of non-nested fields from _source', async function () { - const executeJob = await executeJobFactory(mockReportingPlugin, mockLogger); + const executeJob = await executeJobFactory(mockReportingCore, mockLogger); callAsCurrentUserStub.onFirstCall().resolves({ hits: { hits: [{ _source: { one: 'foo', two: 'bar' } }], @@ -825,7 +826,7 @@ describe('CSV Execute Job', function () { }); it('should concatenate the hits from multiple responses', async function () { - const executeJob = await executeJobFactory(mockReportingPlugin, mockLogger); + const executeJob = await executeJobFactory(mockReportingCore, mockLogger); callAsCurrentUserStub.onFirstCall().resolves({ hits: { hits: [{ _source: { one: 'foo', two: 'bar' } }], @@ -853,7 +854,7 @@ describe('CSV Execute Job', function () { }); it('should use field formatters to format fields', async function () { - const executeJob = await executeJobFactory(mockReportingPlugin, mockLogger); + const executeJob = await executeJobFactory(mockReportingCore, mockLogger); callAsCurrentUserStub.onFirstCall().resolves({ hits: { hits: [{ _source: { one: 'foo', two: 'bar' } }], @@ -895,7 +896,7 @@ describe('CSV Execute Job', function () { beforeEach(async function () { configGetStub.withArgs('csv', 'maxSizeBytes').returns(1); - const executeJob = await executeJobFactory(mockReportingPlugin, mockLogger); + const executeJob = await executeJobFactory(mockReportingCore, mockLogger); const jobParams = getJobDocPayload({ headers: encryptedHeaders, fields: ['one', 'two'], @@ -925,7 +926,7 @@ describe('CSV Execute Job', function () { beforeEach(async function () { configGetStub.withArgs('csv', 'maxSizeBytes').returns(9); - const executeJob = await executeJobFactory(mockReportingPlugin, mockLogger); + const executeJob = await executeJobFactory(mockReportingCore, mockLogger); const jobParams = getJobDocPayload({ headers: encryptedHeaders, fields: ['one', 'two'], @@ -962,7 +963,7 @@ describe('CSV Execute Job', function () { _scroll_id: 'scrollId', }); - const executeJob = await executeJobFactory(mockReportingPlugin, mockLogger); + const executeJob = await executeJobFactory(mockReportingCore, mockLogger); const jobParams = getJobDocPayload({ headers: encryptedHeaders, fields: ['one', 'two'], @@ -991,7 +992,7 @@ describe('CSV Execute Job', function () { let maxSizeReached: boolean; beforeEach(async function () { - mockReportingPlugin.getUiSettingsServiceFactory = () => mockUiSettingsClient; + mockReportingCore.getUiSettingsServiceFactory = () => mockUiSettingsClient; configGetStub.withArgs('csv', 'maxSizeBytes').returns(18); callAsCurrentUserStub.onFirstCall().returns({ @@ -1001,7 +1002,7 @@ describe('CSV Execute Job', function () { _scroll_id: 'scrollId', }); - const executeJob = await executeJobFactory(mockReportingPlugin, mockLogger); + const executeJob = await executeJobFactory(mockReportingCore, mockLogger); const jobParams = getJobDocPayload({ headers: encryptedHeaders, fields: ['one', 'two'], @@ -1038,7 +1039,7 @@ describe('CSV Execute Job', function () { _scroll_id: 'scrollId', }); - const executeJob = await executeJobFactory(mockReportingPlugin, mockLogger); + const executeJob = await executeJobFactory(mockReportingCore, mockLogger); const jobParams = getJobDocPayload({ headers: encryptedHeaders, fields: ['one', 'two'], @@ -1064,7 +1065,7 @@ describe('CSV Execute Job', function () { _scroll_id: 'scrollId', }); - const executeJob = await executeJobFactory(mockReportingPlugin, mockLogger); + const executeJob = await executeJobFactory(mockReportingCore, mockLogger); const jobParams = getJobDocPayload({ headers: encryptedHeaders, fields: ['one', 'two'], @@ -1090,7 +1091,7 @@ describe('CSV Execute Job', function () { _scroll_id: 'scrollId', }); - const executeJob = await executeJobFactory(mockReportingPlugin, mockLogger); + const executeJob = await executeJobFactory(mockReportingCore, mockLogger); const jobParams = getJobDocPayload({ headers: encryptedHeaders, fields: ['one', 'two'], diff --git a/x-pack/legacy/plugins/reporting/export_types/csv/server/execute_job.ts b/x-pack/plugins/reporting/server/export_types/csv/server/execute_job.ts similarity index 95% rename from x-pack/legacy/plugins/reporting/export_types/csv/server/execute_job.ts rename to x-pack/plugins/reporting/server/export_types/csv/server/execute_job.ts index a6b2b0d0561d03..de5ddb2503b2f8 100644 --- a/x-pack/legacy/plugins/reporting/export_types/csv/server/execute_job.ts +++ b/x-pack/plugins/reporting/server/export_types/csv/server/execute_job.ts @@ -7,11 +7,11 @@ import { i18n } from '@kbn/i18n'; import Hapi from 'hapi'; import { IUiSettingsClient, KibanaRequest } from '../../../../../../../src/core/server'; -import { CSV_BOM_CHARS, CSV_JOB_TYPE } from '../../../common/constants'; -import { ReportingCore } from '../../../server'; -import { cryptoFactory, LevelLogger } from '../../../server/lib'; -import { getFieldFormats } from '../../../server/services'; -import { ESQueueWorkerExecuteFn, ExecuteJobFactory } from '../../../server/types'; +import { ReportingCore } from '../../..'; +import { CSV_BOM_CHARS, CSV_JOB_TYPE } from '../../../../common/constants'; +import { getFieldFormats } from '../../../../server/services'; +import { cryptoFactory, LevelLogger } from '../../../lib'; +import { ESQueueWorkerExecuteFn, ExecuteJobFactory } from '../../../types'; import { JobDocPayloadDiscoverCsv } from '../types'; import { fieldFormatMapFactory } from './lib/field_format_map'; import { createGenerateCsv } from './lib/generate_csv'; diff --git a/x-pack/legacy/plugins/reporting/export_types/csv/server/lib/cell_has_formula.ts b/x-pack/plugins/reporting/server/export_types/csv/server/lib/cell_has_formula.ts similarity index 85% rename from x-pack/legacy/plugins/reporting/export_types/csv/server/lib/cell_has_formula.ts rename to x-pack/plugins/reporting/server/export_types/csv/server/lib/cell_has_formula.ts index 1433d852ce6307..659aef85ed5938 100644 --- a/x-pack/legacy/plugins/reporting/export_types/csv/server/lib/cell_has_formula.ts +++ b/x-pack/plugins/reporting/server/export_types/csv/server/lib/cell_has_formula.ts @@ -5,7 +5,7 @@ */ import { startsWith } from 'lodash'; -import { CSV_FORMULA_CHARS } from '../../../../common/constants'; +import { CSV_FORMULA_CHARS } from '../../../../../common/constants'; export const cellHasFormulas = (val: string) => CSV_FORMULA_CHARS.some((formulaChar) => startsWith(val, formulaChar)); diff --git a/x-pack/legacy/plugins/reporting/export_types/csv/server/lib/check_cells_for_formulas.test.ts b/x-pack/plugins/reporting/server/export_types/csv/server/lib/check_cells_for_formulas.test.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/export_types/csv/server/lib/check_cells_for_formulas.test.ts rename to x-pack/plugins/reporting/server/export_types/csv/server/lib/check_cells_for_formulas.test.ts diff --git a/x-pack/legacy/plugins/reporting/export_types/csv/server/lib/check_cells_for_formulas.ts b/x-pack/plugins/reporting/server/export_types/csv/server/lib/check_cells_for_formulas.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/export_types/csv/server/lib/check_cells_for_formulas.ts rename to x-pack/plugins/reporting/server/export_types/csv/server/lib/check_cells_for_formulas.ts diff --git a/x-pack/legacy/plugins/reporting/export_types/csv/server/lib/escape_value.test.ts b/x-pack/plugins/reporting/server/export_types/csv/server/lib/escape_value.test.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/export_types/csv/server/lib/escape_value.test.ts rename to x-pack/plugins/reporting/server/export_types/csv/server/lib/escape_value.test.ts diff --git a/x-pack/legacy/plugins/reporting/export_types/csv/server/lib/escape_value.ts b/x-pack/plugins/reporting/server/export_types/csv/server/lib/escape_value.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/export_types/csv/server/lib/escape_value.ts rename to x-pack/plugins/reporting/server/export_types/csv/server/lib/escape_value.ts diff --git a/x-pack/legacy/plugins/reporting/export_types/csv/server/lib/field_format_map.test.ts b/x-pack/plugins/reporting/server/export_types/csv/server/lib/field_format_map.test.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/export_types/csv/server/lib/field_format_map.test.ts rename to x-pack/plugins/reporting/server/export_types/csv/server/lib/field_format_map.test.ts diff --git a/x-pack/legacy/plugins/reporting/export_types/csv/server/lib/field_format_map.ts b/x-pack/plugins/reporting/server/export_types/csv/server/lib/field_format_map.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/export_types/csv/server/lib/field_format_map.ts rename to x-pack/plugins/reporting/server/export_types/csv/server/lib/field_format_map.ts diff --git a/x-pack/legacy/plugins/reporting/export_types/csv/server/lib/flatten_hit.test.ts b/x-pack/plugins/reporting/server/export_types/csv/server/lib/flatten_hit.test.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/export_types/csv/server/lib/flatten_hit.test.ts rename to x-pack/plugins/reporting/server/export_types/csv/server/lib/flatten_hit.test.ts diff --git a/x-pack/legacy/plugins/reporting/export_types/csv/server/lib/flatten_hit.ts b/x-pack/plugins/reporting/server/export_types/csv/server/lib/flatten_hit.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/export_types/csv/server/lib/flatten_hit.ts rename to x-pack/plugins/reporting/server/export_types/csv/server/lib/flatten_hit.ts diff --git a/x-pack/legacy/plugins/reporting/export_types/csv/server/lib/format_csv_values.test.ts b/x-pack/plugins/reporting/server/export_types/csv/server/lib/format_csv_values.test.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/export_types/csv/server/lib/format_csv_values.test.ts rename to x-pack/plugins/reporting/server/export_types/csv/server/lib/format_csv_values.test.ts diff --git a/x-pack/legacy/plugins/reporting/export_types/csv/server/lib/format_csv_values.ts b/x-pack/plugins/reporting/server/export_types/csv/server/lib/format_csv_values.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/export_types/csv/server/lib/format_csv_values.ts rename to x-pack/plugins/reporting/server/export_types/csv/server/lib/format_csv_values.ts diff --git a/x-pack/legacy/plugins/reporting/export_types/csv/server/lib/generate_csv.ts b/x-pack/plugins/reporting/server/export_types/csv/server/lib/generate_csv.ts similarity index 98% rename from x-pack/legacy/plugins/reporting/export_types/csv/server/lib/generate_csv.ts rename to x-pack/plugins/reporting/server/export_types/csv/server/lib/generate_csv.ts index a8fdd8d1a5bbca..019fa3c9c8e9d2 100644 --- a/x-pack/legacy/plugins/reporting/export_types/csv/server/lib/generate_csv.ts +++ b/x-pack/plugins/reporting/server/export_types/csv/server/lib/generate_csv.ts @@ -5,7 +5,7 @@ */ import { i18n } from '@kbn/i18n'; -import { LevelLogger } from '../../../../server/lib'; +import { LevelLogger } from '../../../../lib'; import { GenerateCsvParams, SavedSearchGeneratorResult } from '../../types'; import { createFlattenHit } from './flatten_hit'; import { createFormatCsvValues } from './format_csv_values'; diff --git a/x-pack/legacy/plugins/reporting/export_types/csv/server/lib/hit_iterator.test.ts b/x-pack/plugins/reporting/server/export_types/csv/server/lib/hit_iterator.test.ts similarity index 95% rename from x-pack/legacy/plugins/reporting/export_types/csv/server/lib/hit_iterator.test.ts rename to x-pack/plugins/reporting/server/export_types/csv/server/lib/hit_iterator.test.ts index 7ef4f502b34a39..479879e3c8b019 100644 --- a/x-pack/legacy/plugins/reporting/export_types/csv/server/lib/hit_iterator.test.ts +++ b/x-pack/plugins/reporting/server/export_types/csv/server/lib/hit_iterator.test.ts @@ -6,9 +6,9 @@ import expect from '@kbn/expect'; import sinon from 'sinon'; -import { CancellationToken } from '../../../../../../../plugins/reporting/common'; -import { LevelLogger } from '../../../../server/lib'; -import { ScrollConfig } from '../../../../server/types'; +import { CancellationToken } from '../../../../../common'; +import { LevelLogger } from '../../../../lib'; +import { ScrollConfig } from '../../../../types'; import { createHitIterator } from './hit_iterator'; const mockLogger = { diff --git a/x-pack/legacy/plugins/reporting/export_types/csv/server/lib/hit_iterator.ts b/x-pack/plugins/reporting/server/export_types/csv/server/lib/hit_iterator.ts similarity index 93% rename from x-pack/legacy/plugins/reporting/export_types/csv/server/lib/hit_iterator.ts rename to x-pack/plugins/reporting/server/export_types/csv/server/lib/hit_iterator.ts index 803161910443e0..38b28573d602db 100644 --- a/x-pack/legacy/plugins/reporting/export_types/csv/server/lib/hit_iterator.ts +++ b/x-pack/plugins/reporting/server/export_types/csv/server/lib/hit_iterator.ts @@ -6,9 +6,9 @@ import { i18n } from '@kbn/i18n'; import { SearchParams, SearchResponse } from 'elasticsearch'; -import { CancellationToken } from '../../../../../../../plugins/reporting/common'; -import { LevelLogger } from '../../../../server/lib'; -import { ScrollConfig } from '../../../../server/types'; +import { CancellationToken } from '../../../../../common'; +import { LevelLogger } from '../../../../lib'; +import { ScrollConfig } from '../../../../types'; async function parseResponse(request: SearchResponse) { const response = await request; diff --git a/x-pack/legacy/plugins/reporting/export_types/csv/server/lib/max_size_string_builder.test.ts b/x-pack/plugins/reporting/server/export_types/csv/server/lib/max_size_string_builder.test.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/export_types/csv/server/lib/max_size_string_builder.test.ts rename to x-pack/plugins/reporting/server/export_types/csv/server/lib/max_size_string_builder.test.ts diff --git a/x-pack/legacy/plugins/reporting/export_types/csv/server/lib/max_size_string_builder.ts b/x-pack/plugins/reporting/server/export_types/csv/server/lib/max_size_string_builder.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/export_types/csv/server/lib/max_size_string_builder.ts rename to x-pack/plugins/reporting/server/export_types/csv/server/lib/max_size_string_builder.ts diff --git a/x-pack/legacy/plugins/reporting/export_types/csv/types.d.ts b/x-pack/plugins/reporting/server/export_types/csv/types.d.ts similarity index 93% rename from x-pack/legacy/plugins/reporting/export_types/csv/types.d.ts rename to x-pack/plugins/reporting/server/export_types/csv/types.d.ts index 0f6223d8553de6..c80cd5fd24fe5b 100644 --- a/x-pack/legacy/plugins/reporting/export_types/csv/types.d.ts +++ b/x-pack/plugins/reporting/server/export_types/csv/types.d.ts @@ -4,8 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ -import { CancellationToken } from '../../../../../plugins/reporting/common'; -import { JobDocPayload, JobParamPostPayload, ScrollConfig } from '../../server/types'; +import { CancellationToken } from '../../../common'; +import { JobParamPostPayload, JobDocPayload, ScrollConfig } from '../../types'; export type RawValue = string | object | null | undefined; diff --git a/x-pack/legacy/plugins/reporting/export_types/csv_from_savedobject/index.ts b/x-pack/plugins/reporting/server/export_types/csv_from_savedobject/index.ts similarity index 89% rename from x-pack/legacy/plugins/reporting/export_types/csv_from_savedobject/index.ts rename to x-pack/plugins/reporting/server/export_types/csv_from_savedobject/index.ts index 570b91600cbe0d..65802ee5bb7fbb 100644 --- a/x-pack/legacy/plugins/reporting/export_types/csv_from_savedobject/index.ts +++ b/x-pack/plugins/reporting/server/export_types/csv_from_savedobject/index.ts @@ -5,15 +5,15 @@ */ import { - CSV_FROM_SAVEDOBJECT_JOB_TYPE, LICENSE_TYPE_BASIC, LICENSE_TYPE_ENTERPRISE, LICENSE_TYPE_GOLD, LICENSE_TYPE_PLATINUM, LICENSE_TYPE_STANDARD, LICENSE_TYPE_TRIAL, -} from '../../common/constants'; -import { ExportTypeDefinition } from '../../server/types'; +} from '../../../common/constants'; +import { CSV_FROM_SAVEDOBJECT_JOB_TYPE } from '../../../constants'; +import { ExportTypeDefinition } from '../../types'; import { metadata } from './metadata'; import { createJobFactory, ImmediateCreateJobFn } from './server/create_job'; import { executeJobFactory, ImmediateExecuteFn } from './server/execute_job'; diff --git a/x-pack/legacy/plugins/reporting/export_types/csv_from_savedobject/metadata.ts b/x-pack/plugins/reporting/server/export_types/csv_from_savedobject/metadata.ts similarity index 82% rename from x-pack/legacy/plugins/reporting/export_types/csv_from_savedobject/metadata.ts rename to x-pack/plugins/reporting/server/export_types/csv_from_savedobject/metadata.ts index fcef889e52fe42..a0fd8a29fdcc45 100644 --- a/x-pack/legacy/plugins/reporting/export_types/csv_from_savedobject/metadata.ts +++ b/x-pack/plugins/reporting/server/export_types/csv_from_savedobject/metadata.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { CSV_FROM_SAVEDOBJECT_JOB_TYPE } from '../../common/constants'; +import { CSV_FROM_SAVEDOBJECT_JOB_TYPE } from '../../../constants'; export const metadata = { id: CSV_FROM_SAVEDOBJECT_JOB_TYPE, diff --git a/x-pack/legacy/plugins/reporting/export_types/csv_from_savedobject/server/create_job/create_job.ts b/x-pack/plugins/reporting/server/export_types/csv_from_savedobject/server/create_job/create_job.ts similarity index 92% rename from x-pack/legacy/plugins/reporting/export_types/csv_from_savedobject/server/create_job/create_job.ts rename to x-pack/plugins/reporting/server/export_types/csv_from_savedobject/server/create_job/create_job.ts index d23f60d9c24806..c187da5104d3f0 100644 --- a/x-pack/legacy/plugins/reporting/export_types/csv_from_savedobject/server/create_job/create_job.ts +++ b/x-pack/plugins/reporting/server/export_types/csv_from_savedobject/server/create_job/create_job.ts @@ -7,10 +7,10 @@ import { notFound, notImplemented } from 'boom'; import { get } from 'lodash'; import { KibanaRequest, RequestHandlerContext } from 'src/core/server'; -import { CSV_FROM_SAVEDOBJECT_JOB_TYPE } from '../../../../common/constants'; -import { ReportingCore } from '../../../../server'; -import { cryptoFactory, LevelLogger } from '../../../../server/lib'; -import { CreateJobFactory, TimeRangeParams } from '../../../../server/types'; +import { ReportingCore } from '../../../..'; +import { CSV_FROM_SAVEDOBJECT_JOB_TYPE } from '../../../../../common/constants'; +import { cryptoFactory, LevelLogger } from '../../../../lib'; +import { CreateJobFactory, TimeRangeParams } from '../../../../types'; import { JobDocPayloadPanelCsv, JobParamsPanelCsv, diff --git a/x-pack/legacy/plugins/reporting/export_types/csv_from_savedobject/server/create_job/create_job_search.ts b/x-pack/plugins/reporting/server/export_types/csv_from_savedobject/server/create_job/create_job_search.ts similarity index 95% rename from x-pack/legacy/plugins/reporting/export_types/csv_from_savedobject/server/create_job/create_job_search.ts rename to x-pack/plugins/reporting/server/export_types/csv_from_savedobject/server/create_job/create_job_search.ts index 19204ef81c5ebb..02abfb90091a1d 100644 --- a/x-pack/legacy/plugins/reporting/export_types/csv_from_savedobject/server/create_job/create_job_search.ts +++ b/x-pack/plugins/reporting/server/export_types/csv_from_savedobject/server/create_job/create_job_search.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { TimeRangeParams } from '../../../../server/types'; +import { TimeRangeParams } from '../../../../types'; import { SavedObjectMeta, SavedObjectReference, diff --git a/x-pack/legacy/plugins/reporting/export_types/csv_from_savedobject/server/create_job/index.ts b/x-pack/plugins/reporting/server/export_types/csv_from_savedobject/server/create_job/index.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/export_types/csv_from_savedobject/server/create_job/index.ts rename to x-pack/plugins/reporting/server/export_types/csv_from_savedobject/server/create_job/index.ts diff --git a/x-pack/legacy/plugins/reporting/export_types/csv_from_savedobject/server/execute_job.ts b/x-pack/plugins/reporting/server/export_types/csv_from_savedobject/server/execute_job.ts similarity index 96% rename from x-pack/legacy/plugins/reporting/export_types/csv_from_savedobject/server/execute_job.ts rename to x-pack/plugins/reporting/server/export_types/csv_from_savedobject/server/execute_job.ts index 4ef7b8514b3632..d555100b6320d3 100644 --- a/x-pack/legacy/plugins/reporting/export_types/csv_from_savedobject/server/execute_job.ts +++ b/x-pack/plugins/reporting/server/export_types/csv_from_savedobject/server/execute_job.ts @@ -6,10 +6,10 @@ import { i18n } from '@kbn/i18n'; import { KibanaRequest, RequestHandlerContext } from 'src/core/server'; -import { CONTENT_TYPE_CSV, CSV_FROM_SAVEDOBJECT_JOB_TYPE } from '../../../common/constants'; -import { ReportingCore } from '../../../server'; -import { cryptoFactory, LevelLogger } from '../../../server/lib'; -import { ExecuteJobFactory, JobDocOutput, JobDocPayload } from '../../../server/types'; +import { ReportingCore } from '../../..'; +import { CONTENT_TYPE_CSV, CSV_FROM_SAVEDOBJECT_JOB_TYPE } from '../../../../common/constants'; +import { cryptoFactory, LevelLogger } from '../../../lib'; +import { ExecuteJobFactory, JobDocOutput, JobDocPayload } from '../../../types'; import { CsvResultFromSearch } from '../../csv/types'; import { FakeRequest, JobDocPayloadPanelCsv, JobParamsPanelCsv, SearchPanel } from '../types'; import { createGenerateCsv } from './lib'; diff --git a/x-pack/legacy/plugins/reporting/export_types/csv_from_savedobject/server/lib/generate_csv.ts b/x-pack/plugins/reporting/server/export_types/csv_from_savedobject/server/lib/generate_csv.ts similarity index 92% rename from x-pack/legacy/plugins/reporting/export_types/csv_from_savedobject/server/lib/generate_csv.ts rename to x-pack/plugins/reporting/server/export_types/csv_from_savedobject/server/lib/generate_csv.ts index 2397da9337890f..dd0fb34668e9e6 100644 --- a/x-pack/legacy/plugins/reporting/export_types/csv_from_savedobject/server/lib/generate_csv.ts +++ b/x-pack/plugins/reporting/server/export_types/csv_from_savedobject/server/lib/generate_csv.ts @@ -6,8 +6,8 @@ import { badRequest } from 'boom'; import { KibanaRequest, RequestHandlerContext } from 'src/core/server'; -import { LevelLogger } from '../../../../server/lib'; -import { ReportingCore } from '../../../../server'; +import { ReportingCore } from '../../../..'; +import { LevelLogger } from '../../../../lib'; import { FakeRequest, JobParamsPanelCsv, SearchPanel, VisPanel } from '../../types'; import { generateCsvSearch } from './generate_csv_search'; diff --git a/x-pack/legacy/plugins/reporting/export_types/csv_from_savedobject/server/lib/generate_csv_search.ts b/x-pack/plugins/reporting/server/export_types/csv_from_savedobject/server/lib/generate_csv_search.ts similarity index 96% rename from x-pack/legacy/plugins/reporting/export_types/csv_from_savedobject/server/lib/generate_csv_search.ts rename to x-pack/plugins/reporting/server/export_types/csv_from_savedobject/server/lib/generate_csv_search.ts index 848623ede5b2fa..a9e4366f4eda6b 100644 --- a/x-pack/legacy/plugins/reporting/export_types/csv_from_savedobject/server/lib/generate_csv_search.ts +++ b/x-pack/plugins/reporting/server/export_types/csv_from_savedobject/server/lib/generate_csv_search.ts @@ -4,6 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ +import { ReportingCore } from '../../../../'; import { IUiSettingsClient, KibanaRequest, @@ -16,9 +17,8 @@ import { IIndexPattern, Query, } from '../../../../../../../../src/plugins/data/server'; -import { CancellationToken } from '../../../../../../../plugins/reporting/common'; -import { LevelLogger } from '../../../../server/lib'; -import { ReportingCore } from '../../../../server'; +import { CancellationToken } from '../../../../../common'; +import { LevelLogger } from '../../../../lib'; import { createGenerateCsv } from '../../../csv/server/lib/generate_csv'; import { CsvResultFromSearch, diff --git a/x-pack/legacy/plugins/reporting/export_types/csv_from_savedobject/server/lib/get_data_source.ts b/x-pack/plugins/reporting/server/export_types/csv_from_savedobject/server/lib/get_data_source.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/export_types/csv_from_savedobject/server/lib/get_data_source.ts rename to x-pack/plugins/reporting/server/export_types/csv_from_savedobject/server/lib/get_data_source.ts diff --git a/x-pack/legacy/plugins/reporting/export_types/csv_from_savedobject/server/lib/get_filters.test.ts b/x-pack/plugins/reporting/server/export_types/csv_from_savedobject/server/lib/get_filters.test.ts similarity index 98% rename from x-pack/legacy/plugins/reporting/export_types/csv_from_savedobject/server/lib/get_filters.test.ts rename to x-pack/plugins/reporting/server/export_types/csv_from_savedobject/server/lib/get_filters.test.ts index 110ce91ddfd79e..b5d564d93d0d6a 100644 --- a/x-pack/legacy/plugins/reporting/export_types/csv_from_savedobject/server/lib/get_filters.test.ts +++ b/x-pack/plugins/reporting/server/export_types/csv_from_savedobject/server/lib/get_filters.test.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { TimeRangeParams } from '../../../../server/types'; +import { TimeRangeParams } from '../../../../types'; import { QueryFilter, SavedSearchObjectAttributes, SearchSourceFilter } from '../../types'; import { getFilters } from './get_filters'; diff --git a/x-pack/legacy/plugins/reporting/export_types/csv_from_savedobject/server/lib/get_filters.ts b/x-pack/plugins/reporting/server/export_types/csv_from_savedobject/server/lib/get_filters.ts similarity index 96% rename from x-pack/legacy/plugins/reporting/export_types/csv_from_savedobject/server/lib/get_filters.ts rename to x-pack/plugins/reporting/server/export_types/csv_from_savedobject/server/lib/get_filters.ts index 4695bbd9225812..26631548cc7972 100644 --- a/x-pack/legacy/plugins/reporting/export_types/csv_from_savedobject/server/lib/get_filters.ts +++ b/x-pack/plugins/reporting/server/export_types/csv_from_savedobject/server/lib/get_filters.ts @@ -6,7 +6,7 @@ import { badRequest } from 'boom'; import moment from 'moment-timezone'; -import { TimeRangeParams } from '../../../../server/types'; +import { TimeRangeParams } from '../../../../types'; import { Filter, QueryFilter, SavedSearchObjectAttributes, SearchSourceFilter } from '../../types'; export function getFilters( diff --git a/x-pack/legacy/plugins/reporting/export_types/csv_from_savedobject/server/lib/get_job_params_from_request.ts b/x-pack/plugins/reporting/server/export_types/csv_from_savedobject/server/lib/get_job_params_from_request.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/export_types/csv_from_savedobject/server/lib/get_job_params_from_request.ts rename to x-pack/plugins/reporting/server/export_types/csv_from_savedobject/server/lib/get_job_params_from_request.ts diff --git a/x-pack/legacy/plugins/reporting/export_types/csv_from_savedobject/server/lib/index.ts b/x-pack/plugins/reporting/server/export_types/csv_from_savedobject/server/lib/index.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/export_types/csv_from_savedobject/server/lib/index.ts rename to x-pack/plugins/reporting/server/export_types/csv_from_savedobject/server/lib/index.ts diff --git a/x-pack/legacy/plugins/reporting/export_types/csv_from_savedobject/types.d.ts b/x-pack/plugins/reporting/server/export_types/csv_from_savedobject/types.d.ts similarity index 95% rename from x-pack/legacy/plugins/reporting/export_types/csv_from_savedobject/types.d.ts rename to x-pack/plugins/reporting/server/export_types/csv_from_savedobject/types.d.ts index f838268078503a..36ae5b1dac05eb 100644 --- a/x-pack/legacy/plugins/reporting/export_types/csv_from_savedobject/types.d.ts +++ b/x-pack/plugins/reporting/server/export_types/csv_from_savedobject/types.d.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { JobDocPayload, JobParamPostPayload, TimeRangeParams } from '../../server/types'; +import { JobParamPostPayload, JobDocPayload, TimeRangeParams } from '../../types'; export interface FakeRequest { headers: Record; @@ -101,7 +101,6 @@ export interface SavedObject { /* This object is passed to different helpers in different parts of the code - packages/kbn-es-query/src/es_query/build_es_query - - x-pack/legacy/plugins/reporting/export_types/csv/server/lib/field_format_map The structure has redundant parts and json-parsed / json-unparsed versions of the same data */ export interface IndexPatternSavedObject { diff --git a/x-pack/legacy/plugins/reporting/export_types/png/index.ts b/x-pack/plugins/reporting/server/export_types/png/index.ts similarity index 88% rename from x-pack/legacy/plugins/reporting/export_types/png/index.ts rename to x-pack/plugins/reporting/server/export_types/png/index.ts index 04f56185d49106..a3b51e365e7727 100644 --- a/x-pack/legacy/plugins/reporting/export_types/png/index.ts +++ b/x-pack/plugins/reporting/server/export_types/png/index.ts @@ -11,12 +11,8 @@ import { LICENSE_TYPE_STANDARD, LICENSE_TYPE_TRIAL, PNG_JOB_TYPE as jobType, -} from '../../common/constants'; -import { - ESQueueCreateJobFn, - ESQueueWorkerExecuteFn, - ExportTypeDefinition, -} from '../../server/types'; +} from '../../../common/constants'; +import { ESQueueCreateJobFn, ESQueueWorkerExecuteFn, ExportTypeDefinition } from '../..//types'; import { metadata } from './metadata'; import { createJobFactory } from './server/create_job'; import { executeJobFactory } from './server/execute_job'; diff --git a/x-pack/legacy/plugins/reporting/export_types/png/metadata.ts b/x-pack/plugins/reporting/server/export_types/png/metadata.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/export_types/png/metadata.ts rename to x-pack/plugins/reporting/server/export_types/png/metadata.ts diff --git a/x-pack/legacy/plugins/reporting/export_types/png/server/create_job/index.ts b/x-pack/plugins/reporting/server/export_types/png/server/create_job/index.ts similarity index 88% rename from x-pack/legacy/plugins/reporting/export_types/png/server/create_job/index.ts rename to x-pack/plugins/reporting/server/export_types/png/server/create_job/index.ts index ab492c21256eba..3f1556fb297827 100644 --- a/x-pack/legacy/plugins/reporting/export_types/png/server/create_job/index.ts +++ b/x-pack/plugins/reporting/server/export_types/png/server/create_job/index.ts @@ -4,9 +4,9 @@ * you may not use this file except in compliance with the Elastic License. */ -import { validateUrls } from '../../../../common/validate_urls'; -import { cryptoFactory } from '../../../../server/lib'; -import { CreateJobFactory, ESQueueCreateJobFn } from '../../../../server/types'; +import { validateUrls } from '../../../../../common/validate_urls'; +import { cryptoFactory } from '../../../../lib'; +import { CreateJobFactory, ESQueueCreateJobFn } from '../../../../types'; import { JobParamsPNG } from '../../types'; export const createJobFactory: CreateJobFactory ({ generatePngObservableFactory: jest.fn() })); @@ -68,6 +68,8 @@ beforeEach(async () => { const mockGetElasticsearch = jest.fn(); mockGetElasticsearch.mockImplementation(() => Promise.resolve(mockElasticsearch)); mockReporting.getElasticsearchService = mockGetElasticsearch; + // @ts-ignore over-riding config method + mockReporting.config = mockReportingConfig; (generatePngObservableFactory as jest.Mock).mockReturnValue(jest.fn()); }); diff --git a/x-pack/legacy/plugins/reporting/export_types/png/server/execute_job/index.ts b/x-pack/plugins/reporting/server/export_types/png/server/execute_job/index.ts similarity index 93% rename from x-pack/legacy/plugins/reporting/export_types/png/server/execute_job/index.ts rename to x-pack/plugins/reporting/server/export_types/png/server/execute_job/index.ts index 0d0a9e748682a1..ea4c4b1d106ae5 100644 --- a/x-pack/legacy/plugins/reporting/export_types/png/server/execute_job/index.ts +++ b/x-pack/plugins/reporting/server/export_types/png/server/execute_job/index.ts @@ -7,10 +7,10 @@ import apm from 'elastic-apm-node'; import * as Rx from 'rxjs'; import { catchError, map, mergeMap, takeUntil } from 'rxjs/operators'; -import { PNG_JOB_TYPE } from '../../../../common/constants'; -import { ReportingCore } from '../../../../server'; -import { LevelLogger } from '../../../../server/lib'; -import { ESQueueWorkerExecuteFn, ExecuteJobFactory, JobDocOutput } from '../../../../server/types'; +import { ReportingCore } from '../../../..'; +import { PNG_JOB_TYPE } from '../../../../../common/constants'; +import { ESQueueWorkerExecuteFn, ExecuteJobFactory, JobDocOutput } from '../../../..//types'; +import { LevelLogger } from '../../../../lib'; import { decryptJobHeaders, getConditionalHeaders, diff --git a/x-pack/legacy/plugins/reporting/export_types/png/server/lib/generate_png.ts b/x-pack/plugins/reporting/server/export_types/png/server/lib/generate_png.ts similarity index 94% rename from x-pack/legacy/plugins/reporting/export_types/png/server/lib/generate_png.ts rename to x-pack/plugins/reporting/server/export_types/png/server/lib/generate_png.ts index 0ad381885f4c41..d7e9d0f812b378 100644 --- a/x-pack/legacy/plugins/reporting/export_types/png/server/lib/generate_png.ts +++ b/x-pack/plugins/reporting/server/export_types/png/server/lib/generate_png.ts @@ -7,9 +7,9 @@ import apm from 'elastic-apm-node'; import * as Rx from 'rxjs'; import { map } from 'rxjs/operators'; -import { ReportingCore } from '../../../../server'; -import { LevelLogger } from '../../../../server/lib'; -import { ConditionalHeaders, ScreenshotResults } from '../../../../server/types'; +import { ReportingCore } from '../../../../'; +import { LevelLogger } from '../../../../lib'; +import { ConditionalHeaders, ScreenshotResults } from '../../../../types'; import { LayoutParams } from '../../../common/layouts'; import { PreserveLayout } from '../../../common/layouts/preserve_layout'; diff --git a/x-pack/legacy/plugins/reporting/export_types/png/types.d.ts b/x-pack/plugins/reporting/server/export_types/png/types.d.ts similarity index 93% rename from x-pack/legacy/plugins/reporting/export_types/png/types.d.ts rename to x-pack/plugins/reporting/server/export_types/png/types.d.ts index 80a2a1899a075b..486a8e91a722f7 100644 --- a/x-pack/legacy/plugins/reporting/export_types/png/types.d.ts +++ b/x-pack/plugins/reporting/server/export_types/png/types.d.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { JobDocPayload } from '../../server/types'; +import { JobDocPayload } from '../../../server/types'; import { LayoutInstance, LayoutParams } from '../common/layouts'; // Job params: structure of incoming user request data diff --git a/x-pack/legacy/plugins/reporting/export_types/printable_pdf/index.ts b/x-pack/plugins/reporting/server/export_types/printable_pdf/index.ts similarity index 88% rename from x-pack/legacy/plugins/reporting/export_types/printable_pdf/index.ts rename to x-pack/plugins/reporting/server/export_types/printable_pdf/index.ts index ec537b52244c2d..39a0cbd5270a18 100644 --- a/x-pack/legacy/plugins/reporting/export_types/printable_pdf/index.ts +++ b/x-pack/plugins/reporting/server/export_types/printable_pdf/index.ts @@ -11,12 +11,8 @@ import { LICENSE_TYPE_STANDARD, LICENSE_TYPE_TRIAL, PDF_JOB_TYPE as jobType, -} from '../../common/constants'; -import { - ESQueueCreateJobFn, - ESQueueWorkerExecuteFn, - ExportTypeDefinition, -} from '../../server/types'; +} from '../../../common/constants'; +import { ESQueueCreateJobFn, ESQueueWorkerExecuteFn, ExportTypeDefinition } from '../../types'; import { metadata } from './metadata'; import { createJobFactory } from './server/create_job'; import { executeJobFactory } from './server/execute_job'; diff --git a/x-pack/legacy/plugins/reporting/export_types/printable_pdf/metadata.ts b/x-pack/plugins/reporting/server/export_types/printable_pdf/metadata.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/export_types/printable_pdf/metadata.ts rename to x-pack/plugins/reporting/server/export_types/printable_pdf/metadata.ts diff --git a/x-pack/legacy/plugins/reporting/export_types/printable_pdf/server/create_job/compatibility_shim.js b/x-pack/plugins/reporting/server/export_types/printable_pdf/server/create_job/compatibility_shim.js similarity index 100% rename from x-pack/legacy/plugins/reporting/export_types/printable_pdf/server/create_job/compatibility_shim.js rename to x-pack/plugins/reporting/server/export_types/printable_pdf/server/create_job/compatibility_shim.js diff --git a/x-pack/legacy/plugins/reporting/export_types/printable_pdf/server/create_job/compatibility_shim.test.js b/x-pack/plugins/reporting/server/export_types/printable_pdf/server/create_job/compatibility_shim.test.js similarity index 100% rename from x-pack/legacy/plugins/reporting/export_types/printable_pdf/server/create_job/compatibility_shim.test.js rename to x-pack/plugins/reporting/server/export_types/printable_pdf/server/create_job/compatibility_shim.test.js diff --git a/x-pack/legacy/plugins/reporting/export_types/printable_pdf/server/create_job/index.ts b/x-pack/plugins/reporting/server/export_types/printable_pdf/server/create_job/index.ts similarity index 91% rename from x-pack/legacy/plugins/reporting/export_types/printable_pdf/server/create_job/index.ts rename to x-pack/plugins/reporting/server/export_types/printable_pdf/server/create_job/index.ts index 5a0074ebd566b8..44dc5dc662d5a2 100644 --- a/x-pack/legacy/plugins/reporting/export_types/printable_pdf/server/create_job/index.ts +++ b/x-pack/plugins/reporting/server/export_types/printable_pdf/server/create_job/index.ts @@ -5,9 +5,9 @@ */ import { KibanaRequest, RequestHandlerContext } from 'src/core/server'; -import { validateUrls } from '../../../../common/validate_urls'; -import { cryptoFactory } from '../../../../server/lib'; -import { CreateJobFactory, ESQueueCreateJobFn } from '../../../../server/types'; +import { validateUrls } from '../../../../../common/validate_urls'; +import { cryptoFactory } from '../../../../lib'; +import { CreateJobFactory, ESQueueCreateJobFn } from '../../../../types'; import { JobParamsPDF } from '../../types'; // @ts-ignore no module def (deprecated module) import { compatibilityShimFactory } from './compatibility_shim'; diff --git a/x-pack/legacy/plugins/reporting/export_types/printable_pdf/server/execute_job/index.test.ts b/x-pack/plugins/reporting/server/export_types/printable_pdf/server/execute_job/index.test.ts similarity index 94% rename from x-pack/legacy/plugins/reporting/export_types/printable_pdf/server/execute_job/index.test.ts rename to x-pack/plugins/reporting/server/export_types/printable_pdf/server/execute_job/index.test.ts index d7e2bed377f10e..10f3ea41812472 100644 --- a/x-pack/legacy/plugins/reporting/export_types/printable_pdf/server/execute_job/index.test.ts +++ b/x-pack/plugins/reporting/server/export_types/printable_pdf/server/execute_job/index.test.ts @@ -7,13 +7,13 @@ jest.mock('../lib/generate_pdf', () => ({ generatePdfObservableFactory: jest.fn() })); import * as Rx from 'rxjs'; -import { CancellationToken } from '../../../../../../../plugins/reporting/common'; -import { ReportingCore } from '../../../../server'; -import { cryptoFactory, LevelLogger } from '../../../../server/lib'; +import { ReportingCore } from '../../../../'; +import { CancellationToken } from '../../../../../common'; +import { cryptoFactory, LevelLogger } from '../../../../lib'; import { createMockReportingCore } from '../../../../test_helpers'; import { JobDocPayloadPDF } from '../../types'; import { generatePdfObservableFactory } from '../lib/generate_pdf'; -import { executeJobFactory } from './index'; +import { executeJobFactory } from './'; let mockReporting: ReportingCore; @@ -66,6 +66,8 @@ beforeEach(async () => { const mockGetElasticsearch = jest.fn(); mockGetElasticsearch.mockImplementation(() => Promise.resolve(mockElasticsearch)); mockReporting.getElasticsearchService = mockGetElasticsearch; + // @ts-ignore over-riding config + mockReporting.config = mockReportingConfig; (generatePdfObservableFactory as jest.Mock).mockReturnValue(jest.fn()); }); diff --git a/x-pack/legacy/plugins/reporting/export_types/printable_pdf/server/execute_job/index.ts b/x-pack/plugins/reporting/server/export_types/printable_pdf/server/execute_job/index.ts similarity index 92% rename from x-pack/legacy/plugins/reporting/export_types/printable_pdf/server/execute_job/index.ts rename to x-pack/plugins/reporting/server/export_types/printable_pdf/server/execute_job/index.ts index b0b2d02305b9b3..a4d84b2f9f1e04 100644 --- a/x-pack/legacy/plugins/reporting/export_types/printable_pdf/server/execute_job/index.ts +++ b/x-pack/plugins/reporting/server/export_types/printable_pdf/server/execute_job/index.ts @@ -7,17 +7,17 @@ import apm from 'elastic-apm-node'; import * as Rx from 'rxjs'; import { catchError, map, mergeMap, takeUntil } from 'rxjs/operators'; -import { PDF_JOB_TYPE } from '../../../../common/constants'; -import { ReportingCore } from '../../../../server'; -import { LevelLogger } from '../../../../server/lib'; -import { ESQueueWorkerExecuteFn, ExecuteJobFactory, JobDocOutput } from '../../../../server/types'; +import { ReportingCore } from '../../../..'; +import { PDF_JOB_TYPE } from '../../../../../common/constants'; +import { LevelLogger } from '../../../../lib'; +import { ESQueueWorkerExecuteFn, ExecuteJobFactory, JobDocOutput } from '../../../../types'; import { decryptJobHeaders, getConditionalHeaders, getCustomLogo, getFullUrls, omitBlacklistedHeaders, -} from '../../../common/execute_job/'; +} from '../../../common/execute_job'; import { JobDocPayloadPDF } from '../../types'; import { generatePdfObservableFactory } from '../lib/generate_pdf'; diff --git a/x-pack/legacy/plugins/reporting/export_types/printable_pdf/server/lib/generate_pdf.ts b/x-pack/plugins/reporting/server/export_types/printable_pdf/server/lib/generate_pdf.ts similarity index 96% rename from x-pack/legacy/plugins/reporting/export_types/printable_pdf/server/lib/generate_pdf.ts rename to x-pack/plugins/reporting/server/export_types/printable_pdf/server/lib/generate_pdf.ts index 3b626c8f0da442..366949a033757b 100644 --- a/x-pack/legacy/plugins/reporting/export_types/printable_pdf/server/lib/generate_pdf.ts +++ b/x-pack/plugins/reporting/server/export_types/printable_pdf/server/lib/generate_pdf.ts @@ -7,9 +7,9 @@ import { groupBy } from 'lodash'; import * as Rx from 'rxjs'; import { mergeMap } from 'rxjs/operators'; -import { ReportingCore } from '../../../../server'; -import { LevelLogger } from '../../../../server/lib'; -import { ConditionalHeaders, ScreenshotResults } from '../../../../server/types'; +import { ReportingCore } from '../../../../'; +import { LevelLogger } from '../../../../lib'; +import { ConditionalHeaders, ScreenshotResults } from '../../../../types'; import { createLayout, LayoutInstance, LayoutParams } from '../../../common/layouts'; // @ts-ignore untyped module import { pdf } from './pdf'; diff --git a/x-pack/legacy/plugins/reporting/export_types/printable_pdf/server/lib/pdf/assets/fonts/noto/LICENSE_OFL.txt b/x-pack/plugins/reporting/server/export_types/printable_pdf/server/lib/pdf/assets/fonts/noto/LICENSE_OFL.txt similarity index 100% rename from x-pack/legacy/plugins/reporting/export_types/printable_pdf/server/lib/pdf/assets/fonts/noto/LICENSE_OFL.txt rename to x-pack/plugins/reporting/server/export_types/printable_pdf/server/lib/pdf/assets/fonts/noto/LICENSE_OFL.txt diff --git a/x-pack/legacy/plugins/reporting/export_types/printable_pdf/server/lib/pdf/assets/fonts/noto/NotoSansCJKtc-Medium.ttf b/x-pack/plugins/reporting/server/export_types/printable_pdf/server/lib/pdf/assets/fonts/noto/NotoSansCJKtc-Medium.ttf similarity index 100% rename from x-pack/legacy/plugins/reporting/export_types/printable_pdf/server/lib/pdf/assets/fonts/noto/NotoSansCJKtc-Medium.ttf rename to x-pack/plugins/reporting/server/export_types/printable_pdf/server/lib/pdf/assets/fonts/noto/NotoSansCJKtc-Medium.ttf diff --git a/x-pack/legacy/plugins/reporting/export_types/printable_pdf/server/lib/pdf/assets/fonts/noto/NotoSansCJKtc-Regular.ttf b/x-pack/plugins/reporting/server/export_types/printable_pdf/server/lib/pdf/assets/fonts/noto/NotoSansCJKtc-Regular.ttf similarity index 100% rename from x-pack/legacy/plugins/reporting/export_types/printable_pdf/server/lib/pdf/assets/fonts/noto/NotoSansCJKtc-Regular.ttf rename to x-pack/plugins/reporting/server/export_types/printable_pdf/server/lib/pdf/assets/fonts/noto/NotoSansCJKtc-Regular.ttf diff --git a/x-pack/legacy/plugins/reporting/export_types/printable_pdf/server/lib/pdf/assets/fonts/noto/index.js b/x-pack/plugins/reporting/server/export_types/printable_pdf/server/lib/pdf/assets/fonts/noto/index.js similarity index 100% rename from x-pack/legacy/plugins/reporting/export_types/printable_pdf/server/lib/pdf/assets/fonts/noto/index.js rename to x-pack/plugins/reporting/server/export_types/printable_pdf/server/lib/pdf/assets/fonts/noto/index.js diff --git a/x-pack/legacy/plugins/reporting/export_types/printable_pdf/server/lib/pdf/assets/fonts/roboto/LICENSE.txt b/x-pack/plugins/reporting/server/export_types/printable_pdf/server/lib/pdf/assets/fonts/roboto/LICENSE.txt similarity index 100% rename from x-pack/legacy/plugins/reporting/export_types/printable_pdf/server/lib/pdf/assets/fonts/roboto/LICENSE.txt rename to x-pack/plugins/reporting/server/export_types/printable_pdf/server/lib/pdf/assets/fonts/roboto/LICENSE.txt diff --git a/x-pack/legacy/plugins/reporting/export_types/printable_pdf/server/lib/pdf/assets/fonts/roboto/Roboto-Italic.ttf b/x-pack/plugins/reporting/server/export_types/printable_pdf/server/lib/pdf/assets/fonts/roboto/Roboto-Italic.ttf similarity index 100% rename from x-pack/legacy/plugins/reporting/export_types/printable_pdf/server/lib/pdf/assets/fonts/roboto/Roboto-Italic.ttf rename to x-pack/plugins/reporting/server/export_types/printable_pdf/server/lib/pdf/assets/fonts/roboto/Roboto-Italic.ttf diff --git a/x-pack/legacy/plugins/reporting/export_types/printable_pdf/server/lib/pdf/assets/fonts/roboto/Roboto-Medium.ttf b/x-pack/plugins/reporting/server/export_types/printable_pdf/server/lib/pdf/assets/fonts/roboto/Roboto-Medium.ttf similarity index 100% rename from x-pack/legacy/plugins/reporting/export_types/printable_pdf/server/lib/pdf/assets/fonts/roboto/Roboto-Medium.ttf rename to x-pack/plugins/reporting/server/export_types/printable_pdf/server/lib/pdf/assets/fonts/roboto/Roboto-Medium.ttf diff --git a/x-pack/legacy/plugins/reporting/export_types/printable_pdf/server/lib/pdf/assets/fonts/roboto/Roboto-Regular.ttf b/x-pack/plugins/reporting/server/export_types/printable_pdf/server/lib/pdf/assets/fonts/roboto/Roboto-Regular.ttf similarity index 100% rename from x-pack/legacy/plugins/reporting/export_types/printable_pdf/server/lib/pdf/assets/fonts/roboto/Roboto-Regular.ttf rename to x-pack/plugins/reporting/server/export_types/printable_pdf/server/lib/pdf/assets/fonts/roboto/Roboto-Regular.ttf diff --git a/x-pack/legacy/plugins/reporting/export_types/printable_pdf/server/lib/pdf/assets/img/logo-grey.png b/x-pack/plugins/reporting/server/export_types/printable_pdf/server/lib/pdf/assets/img/logo-grey.png similarity index 100% rename from x-pack/legacy/plugins/reporting/export_types/printable_pdf/server/lib/pdf/assets/img/logo-grey.png rename to x-pack/plugins/reporting/server/export_types/printable_pdf/server/lib/pdf/assets/img/logo-grey.png diff --git a/x-pack/legacy/plugins/reporting/export_types/printable_pdf/server/lib/pdf/index.js b/x-pack/plugins/reporting/server/export_types/printable_pdf/server/lib/pdf/index.js similarity index 100% rename from x-pack/legacy/plugins/reporting/export_types/printable_pdf/server/lib/pdf/index.js rename to x-pack/plugins/reporting/server/export_types/printable_pdf/server/lib/pdf/index.js diff --git a/x-pack/legacy/plugins/reporting/export_types/printable_pdf/server/lib/tracker.ts b/x-pack/plugins/reporting/server/export_types/printable_pdf/server/lib/tracker.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/export_types/printable_pdf/server/lib/tracker.ts rename to x-pack/plugins/reporting/server/export_types/printable_pdf/server/lib/tracker.ts diff --git a/x-pack/legacy/plugins/reporting/export_types/printable_pdf/server/lib/uri_encode.js b/x-pack/plugins/reporting/server/export_types/printable_pdf/server/lib/uri_encode.js similarity index 100% rename from x-pack/legacy/plugins/reporting/export_types/printable_pdf/server/lib/uri_encode.js rename to x-pack/plugins/reporting/server/export_types/printable_pdf/server/lib/uri_encode.js diff --git a/x-pack/legacy/plugins/reporting/export_types/printable_pdf/types.d.ts b/x-pack/plugins/reporting/server/export_types/printable_pdf/types.d.ts similarity index 93% rename from x-pack/legacy/plugins/reporting/export_types/printable_pdf/types.d.ts rename to x-pack/plugins/reporting/server/export_types/printable_pdf/types.d.ts index cdd2ddd586c0d8..792b6734b9ec3b 100644 --- a/x-pack/legacy/plugins/reporting/export_types/printable_pdf/types.d.ts +++ b/x-pack/plugins/reporting/server/export_types/printable_pdf/types.d.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { JobDocPayload } from '../../server/types'; +import { JobDocPayload } from '../../../server/types'; import { LayoutInstance, LayoutParams } from '../common/layouts'; // Job params: structure of incoming user request data, after being parsed from RISON diff --git a/x-pack/plugins/reporting/server/index.ts b/x-pack/plugins/reporting/server/index.ts index 9d34eba70d0f4c..c78e042d019e8a 100644 --- a/x-pack/plugins/reporting/server/index.ts +++ b/x-pack/plugins/reporting/server/index.ts @@ -4,11 +4,18 @@ * you may not use this file except in compliance with the Elastic License. */ -import { PluginInitializerContext } from 'src/core/server'; +import { PluginInitializerContext } from 'kibana/server'; import { ReportingPlugin } from './plugin'; +import { ReportingConfigType } from './config'; -export { config, ConfigSchema, ConfigType } from './config'; -export { PluginsSetup } from './plugin'; +export const plugin = (initContext: PluginInitializerContext) => + new ReportingPlugin(initContext); -export const plugin = (initializerContext: PluginInitializerContext) => - new ReportingPlugin(initializerContext); +export { ReportingPlugin as Plugin }; +export { config } from './config'; +export { ReportingSetupDeps as PluginSetup } from './types'; +export { ReportingStartDeps as PluginStart } from './types'; + +// internal imports +export { ReportingCore } from './core'; +export { ReportingConfig } from './config/config'; diff --git a/x-pack/legacy/plugins/reporting/server/lib/__tests__/export_types_registry.js b/x-pack/plugins/reporting/server/lib/__tests__/export_types_registry.js similarity index 100% rename from x-pack/legacy/plugins/reporting/server/lib/__tests__/export_types_registry.js rename to x-pack/plugins/reporting/server/lib/__tests__/export_types_registry.js diff --git a/x-pack/legacy/plugins/reporting/server/lib/check_license.test.ts b/x-pack/plugins/reporting/server/lib/check_license.test.ts similarity index 99% rename from x-pack/legacy/plugins/reporting/server/lib/check_license.test.ts rename to x-pack/plugins/reporting/server/lib/check_license.test.ts index 366a8d94286f11..aa9f86533ef61e 100644 --- a/x-pack/legacy/plugins/reporting/server/lib/check_license.test.ts +++ b/x-pack/plugins/reporting/server/lib/check_license.test.ts @@ -5,7 +5,7 @@ */ import { checkLicense } from './check_license'; -import { ILicense } from '../../../../../plugins/licensing/server'; +import { ILicense } from '../../../licensing/server'; import { ExportTypesRegistry } from './export_types_registry'; describe('check_license', () => { diff --git a/x-pack/legacy/plugins/reporting/server/lib/check_license.ts b/x-pack/plugins/reporting/server/lib/check_license.ts similarity index 97% rename from x-pack/legacy/plugins/reporting/server/lib/check_license.ts rename to x-pack/plugins/reporting/server/lib/check_license.ts index 1b4eeaa0bae3ef..a764aa1f1eec63 100644 --- a/x-pack/legacy/plugins/reporting/server/lib/check_license.ts +++ b/x-pack/plugins/reporting/server/lib/check_license.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { ILicense } from '../../../../../plugins/licensing/server'; +import { ILicense } from '../../../licensing/server'; import { ExportTypeDefinition } from '../types'; import { ExportTypesRegistry } from './export_types_registry'; diff --git a/x-pack/legacy/plugins/reporting/server/lib/create_queue.ts b/x-pack/plugins/reporting/server/lib/create_queue.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/server/lib/create_queue.ts rename to x-pack/plugins/reporting/server/lib/create_queue.ts diff --git a/x-pack/legacy/plugins/reporting/server/lib/create_tagged_logger.ts b/x-pack/plugins/reporting/server/lib/create_tagged_logger.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/server/lib/create_tagged_logger.ts rename to x-pack/plugins/reporting/server/lib/create_tagged_logger.ts diff --git a/x-pack/legacy/plugins/reporting/server/lib/create_worker.test.ts b/x-pack/plugins/reporting/server/lib/create_worker.test.ts similarity index 96% rename from x-pack/legacy/plugins/reporting/server/lib/create_worker.test.ts rename to x-pack/plugins/reporting/server/lib/create_worker.test.ts index 1193091075e3ee..8e1174e01aa7fe 100644 --- a/x-pack/legacy/plugins/reporting/server/lib/create_worker.test.ts +++ b/x-pack/plugins/reporting/server/lib/create_worker.test.ts @@ -6,7 +6,7 @@ import * as sinon from 'sinon'; import { ReportingConfig, ReportingCore } from '../../server'; -import { createMockReportingCore } from '../../test_helpers'; +import { createMockReportingCore } from '../test_helpers'; import { createWorkerFactory } from './create_worker'; // @ts-ignore import { Esqueue } from './esqueue'; @@ -42,6 +42,8 @@ describe('Create Worker', () => { mockConfig = { get: configGetStub, kbnConfig: { get: configGetStub } }; mockReporting = await createMockReportingCore(mockConfig); mockReporting.getExportTypesRegistry = () => getMockExportTypesRegistry(); + // @ts-ignore over-riding config manually + mockReporting.config = mockConfig; client = new ClientMock(); queue = new Esqueue('reporting-queue', { client }); executeJobFactoryStub.reset(); diff --git a/x-pack/legacy/plugins/reporting/server/lib/create_worker.ts b/x-pack/plugins/reporting/server/lib/create_worker.ts similarity index 97% rename from x-pack/legacy/plugins/reporting/server/lib/create_worker.ts rename to x-pack/plugins/reporting/server/lib/create_worker.ts index 57bd61aee71956..c9e865668bb301 100644 --- a/x-pack/legacy/plugins/reporting/server/lib/create_worker.ts +++ b/x-pack/plugins/reporting/server/lib/create_worker.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { CancellationToken } from '../../../../../plugins/reporting/common'; +import { CancellationToken } from '../../common'; import { PLUGIN_ID } from '../../common/constants'; import { ReportingCore } from '../../server'; import { LevelLogger } from '../../server/lib'; diff --git a/x-pack/legacy/plugins/reporting/server/lib/crypto.ts b/x-pack/plugins/reporting/server/lib/crypto.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/server/lib/crypto.ts rename to x-pack/plugins/reporting/server/lib/crypto.ts diff --git a/x-pack/legacy/plugins/reporting/server/lib/enqueue_job.ts b/x-pack/plugins/reporting/server/lib/enqueue_job.ts similarity index 97% rename from x-pack/legacy/plugins/reporting/server/lib/enqueue_job.ts rename to x-pack/plugins/reporting/server/lib/enqueue_job.ts index 6367c8a1da98a4..3837f593df5b27 100644 --- a/x-pack/legacy/plugins/reporting/server/lib/enqueue_job.ts +++ b/x-pack/plugins/reporting/server/lib/enqueue_job.ts @@ -6,7 +6,7 @@ import { EventEmitter } from 'events'; import { KibanaRequest, RequestHandlerContext } from 'src/core/server'; -import { AuthenticatedUser } from '../../../../../plugins/security/server'; +import { AuthenticatedUser } from '../../../security/server'; import { ESQueueCreateJobFn } from '../../server/types'; import { ReportingCore } from '../core'; // @ts-ignore diff --git a/x-pack/legacy/plugins/reporting/server/lib/esqueue/__tests__/fixtures/job.js b/x-pack/plugins/reporting/server/lib/esqueue/__tests__/fixtures/job.js similarity index 57% rename from x-pack/legacy/plugins/reporting/server/lib/esqueue/__tests__/fixtures/job.js rename to x-pack/plugins/reporting/server/lib/esqueue/__tests__/fixtures/job.js index 2d0ac86fd96f1d..9cc62800d439f1 100644 --- a/x-pack/legacy/plugins/reporting/server/lib/esqueue/__tests__/fixtures/job.js +++ b/x-pack/plugins/reporting/server/lib/esqueue/__tests__/fixtures/job.js @@ -1,3 +1,9 @@ +/* + * 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 events from 'events'; export class JobMock extends events.EventEmitter { diff --git a/x-pack/legacy/plugins/reporting/server/lib/esqueue/__tests__/fixtures/legacy_elasticsearch.js b/x-pack/plugins/reporting/server/lib/esqueue/__tests__/fixtures/legacy_elasticsearch.js similarity index 100% rename from x-pack/legacy/plugins/reporting/server/lib/esqueue/__tests__/fixtures/legacy_elasticsearch.js rename to x-pack/plugins/reporting/server/lib/esqueue/__tests__/fixtures/legacy_elasticsearch.js diff --git a/x-pack/legacy/plugins/reporting/reporting.d.ts b/x-pack/plugins/reporting/server/lib/esqueue/__tests__/fixtures/queue.js similarity index 58% rename from x-pack/legacy/plugins/reporting/reporting.d.ts rename to x-pack/plugins/reporting/server/lib/esqueue/__tests__/fixtures/queue.js index ec65c15f53864d..974cb4a5e2a6e1 100644 --- a/x-pack/legacy/plugins/reporting/reporting.d.ts +++ b/x-pack/plugins/reporting/server/lib/esqueue/__tests__/fixtures/queue.js @@ -4,4 +4,14 @@ * you may not use this file except in compliance with the Elastic License. */ -export { ReportingPlugin } from './server/plugin'; +import events from 'events'; + +export class QueueMock extends events.EventEmitter { + constructor() { + super(); + } + + setClient(client) { + this.client = client; + } +} diff --git a/x-pack/legacy/plugins/reporting/server/lib/esqueue/__tests__/fixtures/worker.js b/x-pack/plugins/reporting/server/lib/esqueue/__tests__/fixtures/worker.js similarity index 55% rename from x-pack/legacy/plugins/reporting/server/lib/esqueue/__tests__/fixtures/worker.js rename to x-pack/plugins/reporting/server/lib/esqueue/__tests__/fixtures/worker.js index 09c94b44a81455..fe8a859ccb4455 100644 --- a/x-pack/legacy/plugins/reporting/server/lib/esqueue/__tests__/fixtures/worker.js +++ b/x-pack/plugins/reporting/server/lib/esqueue/__tests__/fixtures/worker.js @@ -1,3 +1,9 @@ +/* + * 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 events from 'events'; export class WorkerMock extends events.EventEmitter { diff --git a/x-pack/legacy/plugins/reporting/server/lib/esqueue/__tests__/helpers/create_index.js b/x-pack/plugins/reporting/server/lib/esqueue/__tests__/helpers/create_index.js similarity index 100% rename from x-pack/legacy/plugins/reporting/server/lib/esqueue/__tests__/helpers/create_index.js rename to x-pack/plugins/reporting/server/lib/esqueue/__tests__/helpers/create_index.js diff --git a/x-pack/legacy/plugins/reporting/server/lib/esqueue/__tests__/helpers/errors.js b/x-pack/plugins/reporting/server/lib/esqueue/__tests__/helpers/errors.js similarity index 100% rename from x-pack/legacy/plugins/reporting/server/lib/esqueue/__tests__/helpers/errors.js rename to x-pack/plugins/reporting/server/lib/esqueue/__tests__/helpers/errors.js diff --git a/x-pack/legacy/plugins/reporting/server/lib/esqueue/__tests__/helpers/index_timestamp.js b/x-pack/plugins/reporting/server/lib/esqueue/__tests__/helpers/index_timestamp.js similarity index 100% rename from x-pack/legacy/plugins/reporting/server/lib/esqueue/__tests__/helpers/index_timestamp.js rename to x-pack/plugins/reporting/server/lib/esqueue/__tests__/helpers/index_timestamp.js diff --git a/x-pack/legacy/plugins/reporting/server/lib/esqueue/__tests__/index.js b/x-pack/plugins/reporting/server/lib/esqueue/__tests__/index.js similarity index 100% rename from x-pack/legacy/plugins/reporting/server/lib/esqueue/__tests__/index.js rename to x-pack/plugins/reporting/server/lib/esqueue/__tests__/index.js diff --git a/x-pack/legacy/plugins/reporting/server/lib/esqueue/__tests__/job.js b/x-pack/plugins/reporting/server/lib/esqueue/__tests__/job.js similarity index 100% rename from x-pack/legacy/plugins/reporting/server/lib/esqueue/__tests__/job.js rename to x-pack/plugins/reporting/server/lib/esqueue/__tests__/job.js diff --git a/x-pack/legacy/plugins/reporting/server/lib/esqueue/__tests__/worker.js b/x-pack/plugins/reporting/server/lib/esqueue/__tests__/worker.js similarity index 100% rename from x-pack/legacy/plugins/reporting/server/lib/esqueue/__tests__/worker.js rename to x-pack/plugins/reporting/server/lib/esqueue/__tests__/worker.js diff --git a/x-pack/legacy/plugins/reporting/server/lib/esqueue/constants/default_settings.js b/x-pack/plugins/reporting/server/lib/esqueue/constants/default_settings.js similarity index 100% rename from x-pack/legacy/plugins/reporting/server/lib/esqueue/constants/default_settings.js rename to x-pack/plugins/reporting/server/lib/esqueue/constants/default_settings.js diff --git a/x-pack/legacy/plugins/reporting/server/lib/esqueue/constants/events.js b/x-pack/plugins/reporting/server/lib/esqueue/constants/events.js similarity index 100% rename from x-pack/legacy/plugins/reporting/server/lib/esqueue/constants/events.js rename to x-pack/plugins/reporting/server/lib/esqueue/constants/events.js diff --git a/x-pack/legacy/plugins/reporting/server/lib/esqueue/constants/index.js b/x-pack/plugins/reporting/server/lib/esqueue/constants/index.js similarity index 100% rename from x-pack/legacy/plugins/reporting/server/lib/esqueue/constants/index.js rename to x-pack/plugins/reporting/server/lib/esqueue/constants/index.js diff --git a/x-pack/legacy/plugins/reporting/server/lib/esqueue/constants/statuses.ts b/x-pack/plugins/reporting/server/lib/esqueue/constants/statuses.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/server/lib/esqueue/constants/statuses.ts rename to x-pack/plugins/reporting/server/lib/esqueue/constants/statuses.ts diff --git a/x-pack/legacy/plugins/reporting/server/lib/esqueue/helpers/create_index.js b/x-pack/plugins/reporting/server/lib/esqueue/helpers/create_index.js similarity index 100% rename from x-pack/legacy/plugins/reporting/server/lib/esqueue/helpers/create_index.js rename to x-pack/plugins/reporting/server/lib/esqueue/helpers/create_index.js diff --git a/x-pack/legacy/plugins/reporting/server/lib/esqueue/helpers/errors.js b/x-pack/plugins/reporting/server/lib/esqueue/helpers/errors.js similarity index 100% rename from x-pack/legacy/plugins/reporting/server/lib/esqueue/helpers/errors.js rename to x-pack/plugins/reporting/server/lib/esqueue/helpers/errors.js diff --git a/x-pack/legacy/plugins/reporting/server/lib/esqueue/helpers/index_timestamp.js b/x-pack/plugins/reporting/server/lib/esqueue/helpers/index_timestamp.js similarity index 100% rename from x-pack/legacy/plugins/reporting/server/lib/esqueue/helpers/index_timestamp.js rename to x-pack/plugins/reporting/server/lib/esqueue/helpers/index_timestamp.js diff --git a/x-pack/legacy/plugins/reporting/server/lib/esqueue/index.js b/x-pack/plugins/reporting/server/lib/esqueue/index.js similarity index 100% rename from x-pack/legacy/plugins/reporting/server/lib/esqueue/index.js rename to x-pack/plugins/reporting/server/lib/esqueue/index.js diff --git a/x-pack/legacy/plugins/reporting/server/lib/esqueue/job.js b/x-pack/plugins/reporting/server/lib/esqueue/job.js similarity index 100% rename from x-pack/legacy/plugins/reporting/server/lib/esqueue/job.js rename to x-pack/plugins/reporting/server/lib/esqueue/job.js diff --git a/x-pack/legacy/plugins/reporting/server/lib/esqueue/worker.js b/x-pack/plugins/reporting/server/lib/esqueue/worker.js similarity index 99% rename from x-pack/legacy/plugins/reporting/server/lib/esqueue/worker.js rename to x-pack/plugins/reporting/server/lib/esqueue/worker.js index d7c929dd94cde1..ab462d8c6e7c38 100644 --- a/x-pack/legacy/plugins/reporting/server/lib/esqueue/worker.js +++ b/x-pack/plugins/reporting/server/lib/esqueue/worker.js @@ -7,8 +7,7 @@ import events from 'events'; import moment from 'moment'; import Puid from 'puid'; -import { CancellationToken } from '../../../../../../plugins/reporting/common'; -import { Poller } from '../../../../../common/poller'; +import { CancellationToken, Poller } from '../../../common'; import { constants } from './constants'; import { UnspecifiedWorkerError, WorkerTimeoutError } from './helpers/errors'; diff --git a/x-pack/legacy/plugins/reporting/server/lib/export_types_registry.ts b/x-pack/plugins/reporting/server/lib/export_types_registry.ts similarity index 91% rename from x-pack/legacy/plugins/reporting/server/lib/export_types_registry.ts rename to x-pack/plugins/reporting/server/lib/export_types_registry.ts index 0d5459a7c106b0..893a2635561ff4 100644 --- a/x-pack/legacy/plugins/reporting/server/lib/export_types_registry.ts +++ b/x-pack/plugins/reporting/server/lib/export_types_registry.ts @@ -6,10 +6,10 @@ import { isString } from 'lodash'; import memoizeOne from 'memoize-one'; -import { getExportType as getTypeCsv } from '../../export_types/csv'; -import { getExportType as getTypeCsvFromSavedObject } from '../../export_types/csv_from_savedobject'; -import { getExportType as getTypePng } from '../../export_types/png'; -import { getExportType as getTypePrintablePdf } from '../../export_types/printable_pdf'; +import { getExportType as getTypeCsv } from '../export_types/csv'; +import { getExportType as getTypeCsvFromSavedObject } from '../export_types/csv_from_savedobject'; +import { getExportType as getTypePng } from '../export_types/png'; +import { getExportType as getTypePrintablePdf } from '../export_types/printable_pdf'; import { ExportTypeDefinition } from '../types'; type GetCallbackFn = ( diff --git a/x-pack/legacy/plugins/reporting/server/lib/get_user.ts b/x-pack/plugins/reporting/server/lib/get_user.ts similarity index 74% rename from x-pack/legacy/plugins/reporting/server/lib/get_user.ts rename to x-pack/plugins/reporting/server/lib/get_user.ts index 164ffc5742d049..49d15a7c551003 100644 --- a/x-pack/legacy/plugins/reporting/server/lib/get_user.ts +++ b/x-pack/plugins/reporting/server/lib/get_user.ts @@ -4,8 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ -import { SecurityPluginSetup } from '../../../../../plugins/security/server'; -import { KibanaRequest } from '../../../../../../src/core/server'; +import { KibanaRequest } from 'kibana/server'; +import { SecurityPluginSetup } from '../../../security/server'; export function getUserFactory(security?: SecurityPluginSetup) { return (request: KibanaRequest) => { diff --git a/x-pack/legacy/plugins/reporting/server/lib/index.ts b/x-pack/plugins/reporting/server/lib/index.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/server/lib/index.ts rename to x-pack/plugins/reporting/server/lib/index.ts diff --git a/x-pack/legacy/plugins/reporting/server/lib/jobs_query.ts b/x-pack/plugins/reporting/server/lib/jobs_query.ts similarity index 98% rename from x-pack/legacy/plugins/reporting/server/lib/jobs_query.ts rename to x-pack/plugins/reporting/server/lib/jobs_query.ts index 06c4a7714099ea..8784d8ff35d251 100644 --- a/x-pack/legacy/plugins/reporting/server/lib/jobs_query.ts +++ b/x-pack/plugins/reporting/server/lib/jobs_query.ts @@ -8,7 +8,7 @@ import { i18n } from '@kbn/i18n'; import { errors as elasticsearchErrors } from 'elasticsearch'; import { ElasticsearchServiceSetup } from 'kibana/server'; import { get } from 'lodash'; -import { AuthenticatedUser } from '../../../../../plugins/security/server'; +import { AuthenticatedUser } from '../../../security/server'; import { ReportingConfig } from '../'; import { JobSource } from '../types'; diff --git a/x-pack/legacy/plugins/reporting/server/lib/level_logger.ts b/x-pack/plugins/reporting/server/lib/level_logger.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/server/lib/level_logger.ts rename to x-pack/plugins/reporting/server/lib/level_logger.ts diff --git a/x-pack/legacy/plugins/reporting/server/lib/trace.ts b/x-pack/plugins/reporting/server/lib/trace.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/server/lib/trace.ts rename to x-pack/plugins/reporting/server/lib/trace.ts diff --git a/x-pack/legacy/plugins/reporting/server/lib/validate/index.ts b/x-pack/plugins/reporting/server/lib/validate/index.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/server/lib/validate/index.ts rename to x-pack/plugins/reporting/server/lib/validate/index.ts diff --git a/x-pack/legacy/plugins/reporting/server/lib/validate/validate_browser.ts b/x-pack/plugins/reporting/server/lib/validate/validate_browser.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/server/lib/validate/validate_browser.ts rename to x-pack/plugins/reporting/server/lib/validate/validate_browser.ts diff --git a/x-pack/legacy/plugins/reporting/server/lib/validate/validate_max_content_length.test.js b/x-pack/plugins/reporting/server/lib/validate/validate_max_content_length.test.js similarity index 100% rename from x-pack/legacy/plugins/reporting/server/lib/validate/validate_max_content_length.test.js rename to x-pack/plugins/reporting/server/lib/validate/validate_max_content_length.test.js diff --git a/x-pack/legacy/plugins/reporting/server/lib/validate/validate_max_content_length.ts b/x-pack/plugins/reporting/server/lib/validate/validate_max_content_length.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/server/lib/validate/validate_max_content_length.ts rename to x-pack/plugins/reporting/server/lib/validate/validate_max_content_length.ts diff --git a/x-pack/plugins/reporting/server/plugin.ts b/x-pack/plugins/reporting/server/plugin.ts index 905ed2b237c86b..d0d25f6d9e0ae7 100644 --- a/x-pack/plugins/reporting/server/plugin.ts +++ b/x-pack/plugins/reporting/server/plugin.ts @@ -6,33 +6,85 @@ import { Observable } from 'rxjs'; import { first } from 'rxjs/operators'; -import { CoreSetup, Logger, Plugin, PluginInitializerContext } from 'src/core/server'; -import { ConfigType, createConfig$ } from './config'; - -export interface PluginsSetup { - /** @deprecated */ - __legacy: { - config$: Observable; - }; -} +import { CoreSetup, CoreStart, Plugin, PluginInitializerContext } from 'src/core/server'; +import { ReportingCore } from './core'; +import { ReportingConfigType } from './config'; +import { createBrowserDriverFactory } from './browsers'; +import { buildConfig, createConfig$ } from './config'; +import { createQueueFactory, enqueueJobFactory, LevelLogger, runValidations } from './lib'; +import { registerRoutes } from './routes'; +import { setFieldFormats } from './services'; +import { ReportingSetup, ReportingSetupDeps, ReportingStart, ReportingStartDeps } from './types'; +import { registerReportingUsageCollector } from './usage'; -export class ReportingPlugin implements Plugin { - private readonly log: Logger; +export class ReportingPlugin + implements Plugin { + private readonly initializerContext: PluginInitializerContext; + private logger: LevelLogger; + private reportingCore?: ReportingCore; + private config$: Observable; - constructor(private readonly initializerContext: PluginInitializerContext) { - this.log = this.initializerContext.logger.get(); + constructor(context: PluginInitializerContext) { + this.logger = new LevelLogger(context.logger.get()); + this.initializerContext = context; + this.config$ = context.config.create(); } - public async setup(core: CoreSetup): Promise { - return { - __legacy: { - config$: createConfig$(core, this.initializerContext, this.log).pipe(first()), - }, - }; + public async setup(core: CoreSetup, plugins: ReportingSetupDeps) { + const { elasticsearch, http } = core; + const { licensing, security } = plugins; + const { initializerContext: initContext } = this; + const router = http.createRouter(); + const basePath = http.basePath.get; + + const coreConfig = await createConfig$(core, this.config$, this.logger) + .pipe(first()) + .toPromise(); // apply computed defaults to config + const reportingConfig = buildConfig(initContext, core, coreConfig); // combine kbnServer configs + this.reportingCore = new ReportingCore(reportingConfig); + + const browserDriverFactory = await createBrowserDriverFactory(reportingConfig, this.logger); + + this.reportingCore.pluginSetup({ + browserDriverFactory, + elasticsearch, + licensing, + basePath, + router, + security, + }); + + runValidations(reportingConfig, elasticsearch, browserDriverFactory, this.logger); + registerReportingUsageCollector(this.reportingCore, plugins); + registerRoutes(this.reportingCore, this.logger); + + return {}; } - public start() {} - public stop() {} -} + public async start(core: CoreStart, plugins: ReportingStartDeps) { + const { logger } = this; + const reportingCore = this.getReportingCore(); -export { ConfigType }; + const esqueue = await createQueueFactory(reportingCore, logger); + const enqueueJob = enqueueJobFactory(reportingCore, logger); + + reportingCore.pluginStart({ + savedObjects: core.savedObjects, + uiSettings: core.uiSettings, + esqueue, + enqueueJob, + }); + + setFieldFormats(plugins.data.fieldFormats); + logger.info('reporting plugin started'); + + return {}; + } + + public getReportingCore() { + if (!this.reportingCore) { + throw new Error('Setup is not ready'); + } + return this.reportingCore; + } +} diff --git a/x-pack/legacy/plugins/reporting/server/routes/generate_from_jobparams.ts b/x-pack/plugins/reporting/server/routes/generate_from_jobparams.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/server/routes/generate_from_jobparams.ts rename to x-pack/plugins/reporting/server/routes/generate_from_jobparams.ts diff --git a/x-pack/legacy/plugins/reporting/server/routes/generate_from_savedobject.ts b/x-pack/plugins/reporting/server/routes/generate_from_savedobject.ts similarity index 96% rename from x-pack/legacy/plugins/reporting/server/routes/generate_from_savedobject.ts rename to x-pack/plugins/reporting/server/routes/generate_from_savedobject.ts index 4bc143b9115729..b8326406743b78 100644 --- a/x-pack/legacy/plugins/reporting/server/routes/generate_from_savedobject.ts +++ b/x-pack/plugins/reporting/server/routes/generate_from_savedobject.ts @@ -9,7 +9,7 @@ import { get } from 'lodash'; import { HandlerErrorFunction, HandlerFunction, QueuedJobPayload } from './types'; import { ReportingCore } from '../'; import { API_BASE_GENERATE_V1, CSV_FROM_SAVEDOBJECT_JOB_TYPE } from '../../common/constants'; -import { getJobParamsFromRequest } from '../../export_types/csv_from_savedobject/server/lib/get_job_params_from_request'; +import { getJobParamsFromRequest } from '../export_types/csv_from_savedobject/server/lib/get_job_params_from_request'; import { authorizedUserPreRoutingFactory } from './lib/authorized_user_pre_routing'; /* diff --git a/x-pack/legacy/plugins/reporting/server/routes/generate_from_savedobject_immediate.ts b/x-pack/plugins/reporting/server/routes/generate_from_savedobject_immediate.ts similarity index 90% rename from x-pack/legacy/plugins/reporting/server/routes/generate_from_savedobject_immediate.ts rename to x-pack/plugins/reporting/server/routes/generate_from_savedobject_immediate.ts index 8a6d4553dfa9c0..1221f67855410e 100644 --- a/x-pack/legacy/plugins/reporting/server/routes/generate_from_savedobject_immediate.ts +++ b/x-pack/plugins/reporting/server/routes/generate_from_savedobject_immediate.ts @@ -6,14 +6,15 @@ import { schema } from '@kbn/config-schema'; import { ReportingCore } from '../'; -import { HandlerErrorFunction } from './types'; import { API_BASE_GENERATE_V1 } from '../../common/constants'; -import { createJobFactory, executeJobFactory } from '../../export_types/csv_from_savedobject'; -import { getJobParamsFromRequest } from '../../export_types/csv_from_savedobject/server/lib/get_job_params_from_request'; -import { JobDocPayloadPanelCsv } from '../../export_types/csv_from_savedobject/types'; +import { createJobFactory } from '../export_types/csv_from_savedobject/server/create_job'; +import { executeJobFactory } from '../export_types/csv_from_savedobject/server/execute_job'; +import { getJobParamsFromRequest } from '../export_types/csv_from_savedobject/server/lib/get_job_params_from_request'; +import { JobDocPayloadPanelCsv } from '../export_types/csv_from_savedobject/types'; import { LevelLogger as Logger } from '../lib'; import { JobDocOutput } from '../types'; import { authorizedUserPreRoutingFactory } from './lib/authorized_user_pre_routing'; +import { HandlerErrorFunction } from './types'; /* * This function registers API Endpoints for immediate Reporting jobs. The API inputs are: diff --git a/x-pack/legacy/plugins/reporting/server/routes/generation.test.ts b/x-pack/plugins/reporting/server/routes/generation.test.ts similarity index 98% rename from x-pack/legacy/plugins/reporting/server/routes/generation.test.ts rename to x-pack/plugins/reporting/server/routes/generation.test.ts index 87ac71e250d0c2..eb75109c704c7e 100644 --- a/x-pack/legacy/plugins/reporting/server/routes/generation.test.ts +++ b/x-pack/plugins/reporting/server/routes/generation.test.ts @@ -9,7 +9,7 @@ import { UnwrapPromise } from '@kbn/utility-types'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths import { setupServer } from 'src/core/server/saved_objects/routes/integration_tests/test_utils'; import { registerJobGenerationRoutes } from './generation'; -import { createMockReportingCore } from '../../test_helpers'; +import { createMockReportingCore } from '../test_helpers'; import { ReportingCore } from '..'; import { ExportTypesRegistry } from '../lib/export_types_registry'; import { ExportTypeDefinition } from '../types'; diff --git a/x-pack/legacy/plugins/reporting/server/routes/generation.ts b/x-pack/plugins/reporting/server/routes/generation.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/server/routes/generation.ts rename to x-pack/plugins/reporting/server/routes/generation.ts diff --git a/x-pack/legacy/plugins/reporting/server/routes/index.ts b/x-pack/plugins/reporting/server/routes/index.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/server/routes/index.ts rename to x-pack/plugins/reporting/server/routes/index.ts diff --git a/x-pack/legacy/plugins/reporting/server/routes/jobs.test.ts b/x-pack/plugins/reporting/server/routes/jobs.test.ts similarity index 99% rename from x-pack/legacy/plugins/reporting/server/routes/jobs.test.ts rename to x-pack/plugins/reporting/server/routes/jobs.test.ts index 0911f48f82ca4e..d13b3e72ca8e7e 100644 --- a/x-pack/legacy/plugins/reporting/server/routes/jobs.test.ts +++ b/x-pack/plugins/reporting/server/routes/jobs.test.ts @@ -4,18 +4,18 @@ * you may not use this file except in compliance with the Elastic License. */ -import supertest from 'supertest'; import { UnwrapPromise } from '@kbn/utility-types'; +import { of } from 'rxjs'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths import { setupServer } from 'src/core/server/saved_objects/routes/integration_tests/test_utils'; -import { registerJobInfoRoutes } from './jobs'; -import { createMockReportingCore } from '../../test_helpers'; +import supertest from 'supertest'; import { ReportingCore } from '..'; +import { ReportingInternalSetup } from '../core'; +import { LevelLogger } from '../lib'; import { ExportTypesRegistry } from '../lib/export_types_registry'; +import { createMockReportingCore } from '../test_helpers'; import { ExportTypeDefinition } from '../types'; -import { LevelLogger } from '../lib'; -import { ReportingInternalSetup } from '../core'; -import { of } from 'rxjs'; +import { registerJobInfoRoutes } from './jobs'; type setupServerReturn = UnwrapPromise>; diff --git a/x-pack/legacy/plugins/reporting/server/routes/jobs.ts b/x-pack/plugins/reporting/server/routes/jobs.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/server/routes/jobs.ts rename to x-pack/plugins/reporting/server/routes/jobs.ts diff --git a/x-pack/legacy/plugins/reporting/server/routes/legacy.ts b/x-pack/plugins/reporting/server/routes/legacy.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/server/routes/legacy.ts rename to x-pack/plugins/reporting/server/routes/legacy.ts diff --git a/x-pack/legacy/plugins/reporting/server/routes/lib/authorized_user_pre_routing.test.ts b/x-pack/plugins/reporting/server/routes/lib/authorized_user_pre_routing.test.ts similarity index 85% rename from x-pack/legacy/plugins/reporting/server/routes/lib/authorized_user_pre_routing.test.ts rename to x-pack/plugins/reporting/server/routes/lib/authorized_user_pre_routing.test.ts index 4cb7af3d0d4090..b218f9e4607dde 100644 --- a/x-pack/legacy/plugins/reporting/server/routes/lib/authorized_user_pre_routing.test.ts +++ b/x-pack/plugins/reporting/server/routes/lib/authorized_user_pre_routing.test.ts @@ -5,20 +5,23 @@ */ import { KibanaRequest, RequestHandlerContext, KibanaResponseFactory } from 'kibana/server'; -import sinon from 'sinon'; import { coreMock, httpServerMock } from 'src/core/server/mocks'; -import { ReportingConfig, ReportingCore } from '../../'; -import { createMockReportingCore } from '../../../test_helpers'; +import { ReportingCore } from '../../'; +import { createMockReportingCore } from '../../test_helpers'; import { authorizedUserPreRoutingFactory } from './authorized_user_pre_routing'; import { ReportingInternalSetup } from '../../core'; -let mockConfig: ReportingConfig; let mockCore: ReportingCore; - -const getMockConfig = (mockConfigGet: sinon.SinonStub) => ({ - get: mockConfigGet, - kbnConfig: { get: mockConfigGet }, -}); +const kbnConfig = { + 'server.basePath': '/sbp', +}; +const reportingConfig = { + 'roles.allow': ['reporting_user'], +}; +const mockReportingConfig = { + get: (...keys: string[]) => (reportingConfig as any)[keys.join('.')] || 'whoah!', + kbnConfig: { get: (...keys: string[]) => (kbnConfig as any)[keys.join('.')] }, +}; const getMockContext = () => (({ @@ -38,13 +41,11 @@ const getMockResponseFactory = () => unauthorized: (obj: unknown) => obj, } as unknown) as KibanaResponseFactory); -beforeEach(async () => { - const mockConfigGet = sinon.stub().withArgs('roles', 'allow').returns(['reporting_user']); - mockConfig = getMockConfig(mockConfigGet); - mockCore = await createMockReportingCore(mockConfig); -}); - describe('authorized_user_pre_routing', function () { + beforeEach(async () => { + mockCore = await createMockReportingCore(mockReportingConfig); + }); + it('should return from handler with null user when security is disabled', async function () { mockCore.getPluginSetupDeps = () => (({ @@ -106,7 +107,7 @@ describe('authorized_user_pre_routing', function () { ).toMatchObject({ body: `Sorry, you don't have access to Reporting` }); }); - it('should return from handler when security is enabled and user has explicitly allowed role', async function () { + it('should return from handler when security is enabled and user has explicitly allowed role', async function (done) { mockCore.getPluginSetupDeps = () => (({ // @ts-ignore @@ -117,17 +118,16 @@ describe('authorized_user_pre_routing', function () { }, }, } as unknown) as ReportingInternalSetup); + // @ts-ignore overloading config getter + mockCore.config = mockReportingConfig; const authorizedUserPreRouting = authorizedUserPreRoutingFactory(mockCore); const mockResponseFactory = getMockResponseFactory(); - let handlerCalled = false; - authorizedUserPreRouting((user: unknown) => { + authorizedUserPreRouting((user) => { expect(user).toMatchObject({ roles: ['reporting_user'], username: 'friendlyuser' }); - handlerCalled = true; + done(); return Promise.resolve({ status: 200, options: {} }); })(getMockContext(), getMockRequest(), mockResponseFactory); - - expect(handlerCalled).toBe(true); }); it('should return from handler when security is enabled and user has superuser role', async function () {}); diff --git a/x-pack/legacy/plugins/reporting/server/routes/lib/authorized_user_pre_routing.ts b/x-pack/plugins/reporting/server/routes/lib/authorized_user_pre_routing.ts similarity index 95% rename from x-pack/legacy/plugins/reporting/server/routes/lib/authorized_user_pre_routing.ts rename to x-pack/plugins/reporting/server/routes/lib/authorized_user_pre_routing.ts index 87582ca3ca239b..2ad974c9dd8e18 100644 --- a/x-pack/legacy/plugins/reporting/server/routes/lib/authorized_user_pre_routing.ts +++ b/x-pack/plugins/reporting/server/routes/lib/authorized_user_pre_routing.ts @@ -5,7 +5,7 @@ */ import { RequestHandler, RouteMethod } from 'src/core/server'; -import { AuthenticatedUser } from '../../../../../../plugins/security/server'; +import { AuthenticatedUser } from '../../../../security/server'; import { getUserFactory } from '../../lib/get_user'; import { ReportingCore } from '../../core'; diff --git a/x-pack/legacy/plugins/reporting/server/routes/lib/get_document_payload.ts b/x-pack/plugins/reporting/server/routes/lib/get_document_payload.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/server/routes/lib/get_document_payload.ts rename to x-pack/plugins/reporting/server/routes/lib/get_document_payload.ts diff --git a/x-pack/legacy/plugins/reporting/server/routes/lib/job_response_handler.ts b/x-pack/plugins/reporting/server/routes/lib/job_response_handler.ts similarity index 97% rename from x-pack/legacy/plugins/reporting/server/routes/lib/job_response_handler.ts rename to x-pack/plugins/reporting/server/routes/lib/job_response_handler.ts index 990af2d0aca80a..1a2e10cf355a2c 100644 --- a/x-pack/legacy/plugins/reporting/server/routes/lib/job_response_handler.ts +++ b/x-pack/plugins/reporting/server/routes/lib/job_response_handler.ts @@ -5,7 +5,7 @@ */ import { ElasticsearchServiceSetup, kibanaResponseFactory } from 'kibana/server'; -import { AuthenticatedUser } from '../../../../../../plugins/security/server'; +import { AuthenticatedUser } from '../../../../security/server'; import { ReportingConfig } from '../../'; import { WHITELISTED_JOB_CONTENT_TYPES } from '../../../common/constants'; import { ExportTypesRegistry } from '../../lib/export_types_registry'; diff --git a/x-pack/legacy/plugins/reporting/server/routes/types.d.ts b/x-pack/plugins/reporting/server/routes/types.d.ts similarity index 82% rename from x-pack/legacy/plugins/reporting/server/routes/types.d.ts rename to x-pack/plugins/reporting/server/routes/types.d.ts index afa3fd3358fc17..5eceed0a7f2ab4 100644 --- a/x-pack/legacy/plugins/reporting/server/routes/types.d.ts +++ b/x-pack/plugins/reporting/server/routes/types.d.ts @@ -4,8 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ -import { KibanaResponseFactory, KibanaRequest, RequestHandlerContext } from 'src/core/server'; -import { AuthenticatedUser } from '../../../../../plugins/security/common/model/authenticated_user'; +import { KibanaRequest, KibanaResponseFactory, RequestHandlerContext } from 'src/core/server'; +import { AuthenticatedUser } from '../../../security/server'; import { JobDocPayload } from '../types'; export type HandlerFunction = ( diff --git a/x-pack/legacy/plugins/reporting/server/services.ts b/x-pack/plugins/reporting/server/services.ts similarity index 67% rename from x-pack/legacy/plugins/reporting/server/services.ts rename to x-pack/plugins/reporting/server/services.ts index 7d15d2e1af1ae9..9f4897a69f4eda 100644 --- a/x-pack/legacy/plugins/reporting/server/services.ts +++ b/x-pack/plugins/reporting/server/services.ts @@ -4,8 +4,8 @@ * 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'; +import { createGetterSetter } from '../../../../src/plugins/kibana_utils/server'; +import { PluginStart as DataPluginStart } from '../../../../src/plugins/data/server'; export const [getFieldFormats, setFieldFormats] = createGetterSetter< DataPluginStart['fieldFormats'] diff --git a/x-pack/legacy/plugins/reporting/test_helpers/create_mock_browserdriverfactory.ts b/x-pack/plugins/reporting/server/test_helpers/create_mock_browserdriverfactory.ts similarity index 96% rename from x-pack/legacy/plugins/reporting/test_helpers/create_mock_browserdriverfactory.ts rename to x-pack/plugins/reporting/server/test_helpers/create_mock_browserdriverfactory.ts index 260c94c31df1ca..5b0d740e031ab3 100644 --- a/x-pack/legacy/plugins/reporting/test_helpers/create_mock_browserdriverfactory.ts +++ b/x-pack/plugins/reporting/server/test_helpers/create_mock_browserdriverfactory.ts @@ -6,11 +6,11 @@ import { Page } from 'puppeteer'; import * as Rx from 'rxjs'; +import { HeadlessChromiumDriver, HeadlessChromiumDriverFactory } from '../browsers'; +import { createDriverFactory } from '../browsers/chromium'; import * as contexts from '../export_types/common/lib/screenshots/constants'; -import { HeadlessChromiumDriver, HeadlessChromiumDriverFactory } from '../server/browsers'; -import { createDriverFactory } from '../server/browsers/chromium'; -import { LevelLogger } from '../server/lib'; -import { CaptureConfig, ElementsPositionAndAttribute } from '../server/types'; +import { LevelLogger } from '../lib'; +import { CaptureConfig, ElementsPositionAndAttribute } from '../types'; interface CreateMockBrowserDriverFactoryOpts { evaluate: jest.Mock, any[]>; diff --git a/x-pack/legacy/plugins/reporting/test_helpers/create_mock_layoutinstance.ts b/x-pack/plugins/reporting/server/test_helpers/create_mock_layoutinstance.ts similarity index 94% rename from x-pack/legacy/plugins/reporting/test_helpers/create_mock_layoutinstance.ts rename to x-pack/plugins/reporting/server/test_helpers/create_mock_layoutinstance.ts index 7f4330e7f6bc6b..22da9eb418e9ac 100644 --- a/x-pack/legacy/plugins/reporting/test_helpers/create_mock_layoutinstance.ts +++ b/x-pack/plugins/reporting/server/test_helpers/create_mock_layoutinstance.ts @@ -5,7 +5,7 @@ */ import { createLayout, LayoutInstance, LayoutTypes } from '../export_types/common/layouts'; -import { CaptureConfig } from '../server/types'; +import { CaptureConfig } from '../types'; export const createMockLayoutInstance = (captureConfig: CaptureConfig) => { const mockLayout = createLayout(captureConfig, { diff --git a/x-pack/legacy/plugins/reporting/test_helpers/create_mock_reportingplugin.ts b/x-pack/plugins/reporting/server/test_helpers/create_mock_reportingplugin.ts similarity index 67% rename from x-pack/legacy/plugins/reporting/test_helpers/create_mock_reportingplugin.ts rename to x-pack/plugins/reporting/server/test_helpers/create_mock_reportingplugin.ts index f6dbccdfe3980b..b04e697d0a118c 100644 --- a/x-pack/legacy/plugins/reporting/test_helpers/create_mock_reportingplugin.ts +++ b/x-pack/plugins/reporting/server/test_helpers/create_mock_reportingplugin.ts @@ -4,42 +4,52 @@ * you may not use this file except in compliance with the Elastic License. */ -jest.mock('../server/routes'); -jest.mock('../server/usage'); -jest.mock('../server/browsers'); -jest.mock('../server/browsers'); -jest.mock('../server/lib/create_queue'); -jest.mock('../server/lib/enqueue_job'); -jest.mock('../server/lib/validate'); +jest.mock('../routes'); +jest.mock('../usage'); +jest.mock('../browsers'); +jest.mock('../browsers'); +jest.mock('../lib/create_queue'); +jest.mock('../lib/enqueue_job'); +jest.mock('../lib/validate'); import { of } from 'rxjs'; -import { EventEmitter } from 'events'; -// eslint-disable-next-line @kbn/eslint/no-restricted-paths import { coreMock } from 'src/core/server/mocks'; -import { ReportingConfig, ReportingCore, ReportingPlugin } from '../server'; -import { ReportingSetupDeps, ReportingStartDeps } from '../server/types'; -import { ReportingInternalSetup } from '../server/core'; +import { ReportingConfig, ReportingCore } from '../'; +import { ReportingInternalSetup } from '../core'; +import { ReportingPlugin } from '../plugin'; +import { ReportingSetupDeps, ReportingStartDeps } from '../types'; const createMockSetupDeps = (setupMock?: any): ReportingSetupDeps => { return { - elasticsearch: setupMock.elasticsearch, security: setupMock.security, licensing: { license$: of({ isAvailable: true, isActive: true, type: 'basic' }), } as any, usageCollection: {} as any, - __LEGACY: { plugins: { xpack_main: { status: new EventEmitter() } } } as any, }; }; export const createMockStartDeps = (startMock?: any): ReportingStartDeps => ({ data: startMock.data, - __LEGACY: {} as any, }); const createMockReportingPlugin = async (config: ReportingConfig): Promise => { - config = config || {}; - const plugin = new ReportingPlugin(coreMock.createPluginInitializerContext(config), config); + const mockConfig = { + index: '.reporting', + kibanaServer: { + hostname: 'localhost', + port: '80', + }, + capture: { + browser: { + chromium: { + disableSandbox: true, + }, + }, + }, + ...config, + }; + const plugin = new ReportingPlugin(coreMock.createPluginInitializerContext(mockConfig)); const setupMock = coreMock.createSetup(); const coreStartMock = coreMock.createStart(); const startMock = { diff --git a/x-pack/legacy/plugins/reporting/test_helpers/create_mock_server.ts b/x-pack/plugins/reporting/server/test_helpers/create_mock_server.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/test_helpers/create_mock_server.ts rename to x-pack/plugins/reporting/server/test_helpers/create_mock_server.ts diff --git a/x-pack/legacy/plugins/reporting/test_helpers/index.ts b/x-pack/plugins/reporting/server/test_helpers/index.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/test_helpers/index.ts rename to x-pack/plugins/reporting/server/test_helpers/index.ts diff --git a/x-pack/legacy/plugins/reporting/server/types.ts b/x-pack/plugins/reporting/server/types.ts similarity index 83% rename from x-pack/legacy/plugins/reporting/server/types.ts rename to x-pack/plugins/reporting/server/types.ts index 2ccc209c3ce502..409a89899bee00 100644 --- a/x-pack/legacy/plugins/reporting/server/types.ts +++ b/x-pack/plugins/reporting/server/types.ts @@ -4,22 +4,18 @@ * you may not use this file except in compliance with the Elastic License. */ -import { Legacy } from 'kibana'; -import { KibanaRequest, RequestHandlerContext } from 'src/core/server'; -import { ElasticsearchServiceSetup } from 'kibana/server'; import * as Rx from 'rxjs'; +import { KibanaRequest, RequestHandlerContext } from 'src/core/server'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths import { DataPluginStart } from 'src/plugins/data/server/plugin'; import { UsageCollectionSetup } from 'src/plugins/usage_collection/server'; -import { LicensingPluginSetup } from '../../../../plugins/licensing/server'; -import { ReportingPluginSpecOptions } from '../'; -import { CancellationToken } from '../../../../plugins/reporting/common'; -import { JobStatus } from '../../../../plugins/reporting/common/types'; -import { SecurityPluginSetup } from '../../../../plugins/security/server'; -import { XPackMainPlugin } from '../../xpack_main/server/xpack_main'; -import { LayoutInstance } from '../export_types/common/layouts'; +import { CancellationToken } from '../../../plugins/reporting/common'; +import { LicensingPluginSetup } from '../../licensing/server'; +import { SecurityPluginSetup } from '../../security/server'; +import { JobStatus } from '../common/types'; import { ReportingConfigType } from './config'; import { ReportingCore } from './core'; +import { LayoutInstance } from './export_types/common/layouts'; import { LevelLogger } from './lib'; /* @@ -161,31 +157,18 @@ export type ScreenshotsObservableFn = ({ */ export interface ReportingSetupDeps { - elasticsearch: ElasticsearchServiceSetup; licensing: LicensingPluginSetup; - security: SecurityPluginSetup; + security?: SecurityPluginSetup; usageCollection?: UsageCollectionSetup; - __LEGACY: LegacySetup; } export interface ReportingStartDeps { data: DataPluginStart; - __LEGACY: LegacySetup; } export type ReportingStart = object; export type ReportingSetup = object; -export interface LegacySetup { - plugins: { - xpack_main: XPackMainPlugin & { - status?: any; - }; - reporting: ReportingPluginSpecOptions; - }; - route: Legacy.Server['route']; -} - /* * Internal Types */ @@ -202,8 +185,6 @@ export type ESQueueWorkerExecuteFn = ( cancellationToken?: CancellationToken ) => Promise; -export type ServerFacade = LegacySetup; - export type CaptureConfig = ReportingConfigType['capture']; export type ScrollConfig = ReportingConfigType['csv']['scroll']; diff --git a/x-pack/legacy/plugins/reporting/server/usage/__snapshots__/reporting_usage_collector.test.ts.snap b/x-pack/plugins/reporting/server/usage/__snapshots__/reporting_usage_collector.test.ts.snap similarity index 100% rename from x-pack/legacy/plugins/reporting/server/usage/__snapshots__/reporting_usage_collector.test.ts.snap rename to x-pack/plugins/reporting/server/usage/__snapshots__/reporting_usage_collector.test.ts.snap diff --git a/x-pack/legacy/plugins/reporting/server/usage/decorate_range_stats.ts b/x-pack/plugins/reporting/server/usage/decorate_range_stats.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/server/usage/decorate_range_stats.ts rename to x-pack/plugins/reporting/server/usage/decorate_range_stats.ts diff --git a/x-pack/legacy/plugins/reporting/server/usage/get_export_type_handler.ts b/x-pack/plugins/reporting/server/usage/get_export_type_handler.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/server/usage/get_export_type_handler.ts rename to x-pack/plugins/reporting/server/usage/get_export_type_handler.ts diff --git a/x-pack/legacy/plugins/reporting/server/usage/get_reporting_usage.ts b/x-pack/plugins/reporting/server/usage/get_reporting_usage.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/server/usage/get_reporting_usage.ts rename to x-pack/plugins/reporting/server/usage/get_reporting_usage.ts diff --git a/x-pack/legacy/plugins/reporting/server/usage/index.ts b/x-pack/plugins/reporting/server/usage/index.ts similarity index 87% rename from x-pack/legacy/plugins/reporting/server/usage/index.ts rename to x-pack/plugins/reporting/server/usage/index.ts index d00a8570a024f6..a426451db2282b 100644 --- a/x-pack/legacy/plugins/reporting/server/usage/index.ts +++ b/x-pack/plugins/reporting/server/usage/index.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { LicenseType } from '../../../../../plugins/licensing/server'; +import { LicenseType } from '../../../licensing/server'; export interface FeaturesAvailability { isAvailable: () => boolean; diff --git a/x-pack/legacy/plugins/reporting/server/usage/reporting_usage_collector.test.ts b/x-pack/plugins/reporting/server/usage/reporting_usage_collector.test.ts similarity index 99% rename from x-pack/legacy/plugins/reporting/server/usage/reporting_usage_collector.test.ts rename to x-pack/plugins/reporting/server/usage/reporting_usage_collector.test.ts index 830c6275cd96a0..d5dccaca3042a0 100644 --- a/x-pack/legacy/plugins/reporting/server/usage/reporting_usage_collector.test.ts +++ b/x-pack/plugins/reporting/server/usage/reporting_usage_collector.test.ts @@ -8,7 +8,7 @@ import * as Rx from 'rxjs'; import sinon from 'sinon'; import { UsageCollectionSetup } from 'src/plugins/usage_collection/server'; import { ReportingConfig } from '../'; -import { createMockReportingCore } from '../../test_helpers'; +import { createMockReportingCore } from '../test_helpers'; import { getExportTypesRegistry } from '../lib/export_types_registry'; import { ReportingSetupDeps } from '../types'; import { FeaturesAvailability } from './'; diff --git a/x-pack/legacy/plugins/reporting/server/usage/reporting_usage_collector.ts b/x-pack/plugins/reporting/server/usage/reporting_usage_collector.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/server/usage/reporting_usage_collector.ts rename to x-pack/plugins/reporting/server/usage/reporting_usage_collector.ts diff --git a/x-pack/legacy/plugins/reporting/server/usage/types.ts b/x-pack/plugins/reporting/server/usage/types.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/server/usage/types.ts rename to x-pack/plugins/reporting/server/usage/types.ts diff --git a/x-pack/plugins/translations/translations/ja-JP.json b/x-pack/plugins/translations/translations/ja-JP.json index 9f47c9558486e5..cf04fa4601c0de 100644 --- a/x-pack/plugins/translations/translations/ja-JP.json +++ b/x-pack/plugins/translations/translations/ja-JP.json @@ -12677,8 +12677,6 @@ "xpack.reporting.panelContent.successfullyQueuedReportNotificationTitle": "{objectType} のレポートキュー", "xpack.reporting.panelContent.whatCanBeExportedWarningDescription": "初めに変更内容を保存してください", "xpack.reporting.panelContent.whatCanBeExportedWarningTitle": "保存された {objectType} のみエクスポートできます", - "xpack.reporting.pdfFooterImageDescription": "PDF のフッターに使用するカスタム画像です", - "xpack.reporting.pdfFooterImageLabel": "PDF フッター画像", "xpack.reporting.publicNotifier.csvContainsFormulas.formulaReportMessage": "レポートには、スプレッドシートアプリケーションで式と解釈される可能性のある文字が含まれています。", "xpack.reporting.publicNotifier.csvContainsFormulas.formulaReportTitle": "レポートには式{reportObjectType} '{reportObjectTitle}'が含まれている場合があります", "xpack.reporting.publicNotifier.downloadReportButtonLabel": "レポートをダウンロード", diff --git a/x-pack/plugins/translations/translations/zh-CN.json b/x-pack/plugins/translations/translations/zh-CN.json index 8711fbc223960f..0713adf4d8c54b 100644 --- a/x-pack/plugins/translations/translations/zh-CN.json +++ b/x-pack/plugins/translations/translations/zh-CN.json @@ -12682,8 +12682,6 @@ "xpack.reporting.panelContent.successfullyQueuedReportNotificationTitle": "已为 {objectType} 排队报告", "xpack.reporting.panelContent.whatCanBeExportedWarningDescription": "请先保存您的工作", "xpack.reporting.panelContent.whatCanBeExportedWarningTitle": "只会导出保存的 {objectType}", - "xpack.reporting.pdfFooterImageDescription": "PDF 的页脚中要使用的定制图片", - "xpack.reporting.pdfFooterImageLabel": "PDF 页脚图片", "xpack.reporting.publicNotifier.csvContainsFormulas.formulaReportMessage": "报告包含电子表格应用程序可解释为公式的字符。", "xpack.reporting.publicNotifier.csvContainsFormulas.formulaReportTitle": "报告可能包含公式 {reportObjectType} '{reportObjectTitle}'", "xpack.reporting.publicNotifier.downloadReportButtonLabel": "下载报告", diff --git a/x-pack/tasks/prepare.ts b/x-pack/tasks/prepare.ts index 6d4eb5603ad3ad..5c71675d441898 100644 --- a/x-pack/tasks/prepare.ts +++ b/x-pack/tasks/prepare.ts @@ -4,8 +4,22 @@ * you may not use this file except in compliance with the Elastic License. */ -import { ensureAllBrowsersDownloaded } from '../legacy/plugins/reporting/server/browsers'; +import { ensureAllBrowsersDownloaded } from '../plugins/reporting/server/browsers'; +import { LevelLogger } from '../plugins/reporting/server/lib'; export const prepareTask = async () => { - await ensureAllBrowsersDownloaded(); + // eslint-disable-next-line no-console + const consoleLogger = (tag: string) => (message: unknown) => console.log(tag, message); + const innerLogger = { + get: () => innerLogger, + debug: consoleLogger('debug'), + info: consoleLogger('info'), + warn: consoleLogger('warn'), + trace: consoleLogger('trace'), + error: consoleLogger('error'), + fatal: consoleLogger('fatal'), + log: consoleLogger('log'), + }; + const levelLogger = new LevelLogger(innerLogger); + await ensureAllBrowsersDownloaded(levelLogger); }; diff --git a/x-pack/test/reporting_api_integration/services.ts b/x-pack/test/reporting_api_integration/services.ts index a0b572787ddfc5..dadb466d45982a 100644 --- a/x-pack/test/reporting_api_integration/services.ts +++ b/x-pack/test/reporting_api_integration/services.ts @@ -8,7 +8,7 @@ import expect from '@kbn/expect'; import * as Rx from 'rxjs'; import { filter, first, mapTo, switchMap, timeout } from 'rxjs/operators'; // @ts-ignore no module definition -import { indexTimestamp } from '../../legacy/plugins/reporting/server/lib/esqueue/helpers/index_timestamp'; +import { indexTimestamp } from '../../plugins/reporting/server/lib/esqueue/helpers/index_timestamp'; import { services as xpackServices } from '../functional/services'; import { FtrProviderContext } from './ftr_provider_context';