From c4458ca1b479f4aa789e0edfd733d25eec617884 Mon Sep 17 00:00:00 2001 From: Aaron Caldwell Date: Wed, 4 Mar 2020 06:44:44 -0700 Subject: [PATCH] [File upload] Move File Upload to New Platform (#58550) * Move file upload to np. Some additional mods & removals * Consume file upload from NP in maps and pass to kibana services * Register telemetry mappings * Init indexPatternService in start method * Fix type check issues. Add missing prop to telemetry * Update i18n path * Review feedback --- x-pack/.i18nrc.json | 2 +- x-pack/index.js | 2 -- x-pack/legacy/plugins/file_upload/index.js | 36 ------------------- .../plugins/maps/public/kibana_services.js | 6 ++++ .../create_client_file_source_editor.js | 5 +-- x-pack/legacy/plugins/maps/public/plugin.ts | 3 +- .../common/constants/file_import.ts | 0 x-pack/plugins/file_upload/kibana.json | 9 +++++ .../plugins/file_upload/mappings.ts | 0 .../public/components/index_settings.js | 0 .../public/components/json_import_progress.js | 0 .../components/json_index_file_picker.js | 0 .../components/json_upload_and_parse.js | 0 .../plugins/file_upload/public/index.ts | 0 .../file_upload/public/kibana_services.js | 16 ++++----- .../plugins/file_upload/public/plugin.ts | 22 ++++++++---- .../file_upload/public/util/file_parser.js | 0 .../public/util/file_parser.test.js | 0 .../util/geo_json_clean_and_validate.js | 0 .../util/geo_json_clean_and_validate.test.js | 0 .../file_upload/public/util/geo_processing.js | 0 .../public/util/geo_processing.test.js | 0 .../file_upload/public/util/http_service.js | 0 .../public/util/indexing_service.js | 0 .../public/util/indexing_service.test.js | 0 .../file_upload/public/util/pattern_reader.js | 0 .../public/util/size_limited_chunking.js | 0 .../public/util/size_limited_chunking.test.js | 0 .../client/call_with_request_factory.js | 0 .../file_upload/server/client/errors.js | 0 .../file_upload/server/index.js} | 8 ++--- .../server/kibana_server_services.js | 0 .../server/models/import_data/import_data.js | 0 .../server/models/import_data/index.js | 0 .../plugins/file_upload/server/plugin.js | 10 +++--- .../file_upload/server/routes/file_upload.js | 0 .../server/routes/file_upload.test.js | 0 .../telemetry/file_upload_usage_collector.ts | 0 .../file_upload/server/telemetry/index.ts | 1 + .../file_upload/server/telemetry/mappings.ts | 21 +++++++++++ .../server/telemetry/telemetry.test.ts | 0 .../file_upload/server/telemetry/telemetry.ts | 0 42 files changed, 74 insertions(+), 67 deletions(-) delete mode 100644 x-pack/legacy/plugins/file_upload/index.js rename x-pack/{legacy => }/plugins/file_upload/common/constants/file_import.ts (100%) create mode 100644 x-pack/plugins/file_upload/kibana.json rename x-pack/{legacy => }/plugins/file_upload/mappings.ts (100%) rename x-pack/{legacy => }/plugins/file_upload/public/components/index_settings.js (100%) rename x-pack/{legacy => }/plugins/file_upload/public/components/json_import_progress.js (100%) rename x-pack/{legacy => }/plugins/file_upload/public/components/json_index_file_picker.js (100%) rename x-pack/{legacy => }/plugins/file_upload/public/components/json_upload_and_parse.js (100%) rename x-pack/{legacy => }/plugins/file_upload/public/index.ts (100%) rename x-pack/{legacy => }/plugins/file_upload/public/kibana_services.js (53%) rename x-pack/{legacy => }/plugins/file_upload/public/plugin.ts (53%) rename x-pack/{legacy => }/plugins/file_upload/public/util/file_parser.js (100%) rename x-pack/{legacy => }/plugins/file_upload/public/util/file_parser.test.js (100%) rename x-pack/{legacy => }/plugins/file_upload/public/util/geo_json_clean_and_validate.js (100%) rename x-pack/{legacy => }/plugins/file_upload/public/util/geo_json_clean_and_validate.test.js (100%) rename x-pack/{legacy => }/plugins/file_upload/public/util/geo_processing.js (100%) rename x-pack/{legacy => }/plugins/file_upload/public/util/geo_processing.test.js (100%) rename x-pack/{legacy => }/plugins/file_upload/public/util/http_service.js (100%) rename x-pack/{legacy => }/plugins/file_upload/public/util/indexing_service.js (100%) rename x-pack/{legacy => }/plugins/file_upload/public/util/indexing_service.test.js (100%) rename x-pack/{legacy => }/plugins/file_upload/public/util/pattern_reader.js (100%) rename x-pack/{legacy => }/plugins/file_upload/public/util/size_limited_chunking.js (100%) rename x-pack/{legacy => }/plugins/file_upload/public/util/size_limited_chunking.test.js (100%) rename x-pack/{legacy => }/plugins/file_upload/server/client/call_with_request_factory.js (100%) rename x-pack/{legacy => }/plugins/file_upload/server/client/errors.js (100%) rename x-pack/{legacy/plugins/file_upload/public/legacy.ts => plugins/file_upload/server/index.js} (60%) rename x-pack/{legacy => }/plugins/file_upload/server/kibana_server_services.js (100%) rename x-pack/{legacy => }/plugins/file_upload/server/models/import_data/import_data.js (100%) rename x-pack/{legacy => }/plugins/file_upload/server/models/import_data/index.js (100%) rename x-pack/{legacy => }/plugins/file_upload/server/plugin.js (79%) rename x-pack/{legacy => }/plugins/file_upload/server/routes/file_upload.js (100%) rename x-pack/{legacy => }/plugins/file_upload/server/routes/file_upload.test.js (100%) rename x-pack/{legacy => }/plugins/file_upload/server/telemetry/file_upload_usage_collector.ts (100%) rename x-pack/{legacy => }/plugins/file_upload/server/telemetry/index.ts (83%) create mode 100644 x-pack/plugins/file_upload/server/telemetry/mappings.ts rename x-pack/{legacy => }/plugins/file_upload/server/telemetry/telemetry.test.ts (100%) rename x-pack/{legacy => }/plugins/file_upload/server/telemetry/telemetry.ts (100%) diff --git a/x-pack/.i18nrc.json b/x-pack/.i18nrc.json index 8f5a5ea4f10e4..824bb764345f3 100644 --- a/x-pack/.i18nrc.json +++ b/x-pack/.i18nrc.json @@ -14,7 +14,7 @@ "xpack.drilldowns": "plugins/drilldowns", "xpack.endpoint": "plugins/endpoint", "xpack.features": "plugins/features", - "xpack.fileUpload": "legacy/plugins/file_upload", + "xpack.fileUpload": "plugins/file_upload", "xpack.graph": ["legacy/plugins/graph", "plugins/graph"], "xpack.grokDebugger": "legacy/plugins/grokdebugger", "xpack.idxMgmt": "plugins/index_management", diff --git a/x-pack/index.js b/x-pack/index.js index f3f569e021070..6b84c74690615 100644 --- a/x-pack/index.js +++ b/x-pack/index.js @@ -30,7 +30,6 @@ import { remoteClusters } from './legacy/plugins/remote_clusters'; import { crossClusterReplication } from './legacy/plugins/cross_cluster_replication'; import { upgradeAssistant } from './legacy/plugins/upgrade_assistant'; import { uptime } from './legacy/plugins/uptime'; -import { fileUpload } from './legacy/plugins/file_upload'; import { encryptedSavedObjects } from './legacy/plugins/encrypted_saved_objects'; import { snapshotRestore } from './legacy/plugins/snapshot_restore'; import { transform } from './legacy/plugins/transform'; @@ -69,7 +68,6 @@ module.exports = function(kibana) { crossClusterReplication(kibana), upgradeAssistant(kibana), uptime(kibana), - fileUpload(kibana), encryptedSavedObjects(kibana), lens(kibana), snapshotRestore(kibana), diff --git a/x-pack/legacy/plugins/file_upload/index.js b/x-pack/legacy/plugins/file_upload/index.js deleted file mode 100644 index 23e1e1d98aa7f..0000000000000 --- a/x-pack/legacy/plugins/file_upload/index.js +++ /dev/null @@ -1,36 +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 { FileUploadPlugin } from './server/plugin'; -import { mappings } from './mappings'; - -export const fileUpload = kibana => { - return new kibana.Plugin({ - require: ['elasticsearch'], - name: 'file_upload', - id: 'file_upload', - // TODO: uiExports and savedObjectSchemas to be removed on migration - uiExports: { - mappings, - }, - savedObjectSchemas: { - 'file-upload-telemetry': { - isNamespaceAgnostic: true, - }, - }, - - init(server) { - const coreSetup = server.newPlatform.setup.core; - const coreStart = server.newPlatform.start.core; - const { usageCollection } = server.newPlatform.setup.plugins; - const pluginsStart = { - usageCollection, - }; - const fileUploadPlugin = new FileUploadPlugin(); - fileUploadPlugin.setup(coreSetup); - fileUploadPlugin.start(coreStart, pluginsStart); - }, - }); -}; diff --git a/x-pack/legacy/plugins/maps/public/kibana_services.js b/x-pack/legacy/plugins/maps/public/kibana_services.js index a1b1c9ec1518e..ef427aa31d01b 100644 --- a/x-pack/legacy/plugins/maps/public/kibana_services.js +++ b/x-pack/legacy/plugins/maps/public/kibana_services.js @@ -28,6 +28,12 @@ export const getInspector = () => { return inspector; }; +let fileUploadPlugin; +export const setFileUpload = fileUpload => (fileUploadPlugin = fileUpload); +export const getFileUploadComponent = () => { + return fileUploadPlugin.JsonUploadAndParse; +}; + export async function fetchSearchSourceAndRecordWithInspector({ searchSource, requestId, diff --git a/x-pack/legacy/plugins/maps/public/layers/sources/client_file_source/create_client_file_source_editor.js b/x-pack/legacy/plugins/maps/public/layers/sources/client_file_source/create_client_file_source_editor.js index 150c7c39fe117..f9bfc4ddde91b 100644 --- a/x-pack/legacy/plugins/maps/public/layers/sources/client_file_source/create_client_file_source_editor.js +++ b/x-pack/legacy/plugins/maps/public/layers/sources/client_file_source/create_client_file_source_editor.js @@ -5,7 +5,7 @@ */ import React from 'react'; -import { start as fileUpload } from '../../../../../file_upload/public/legacy'; +import { getFileUploadComponent } from '../../../kibana_services'; export function ClientFileCreateSourceEditor({ previewGeojsonFile, @@ -14,8 +14,9 @@ export function ClientFileCreateSourceEditor({ onRemove, onIndexReady, }) { + const FileUpload = getFileUploadComponent(); return ( - { public start(core: CoreStart, plugins: any) { setInspector(plugins.np.inspector); + setFileUpload(plugins.np.file_upload); } } diff --git a/x-pack/legacy/plugins/file_upload/common/constants/file_import.ts b/x-pack/plugins/file_upload/common/constants/file_import.ts similarity index 100% rename from x-pack/legacy/plugins/file_upload/common/constants/file_import.ts rename to x-pack/plugins/file_upload/common/constants/file_import.ts diff --git a/x-pack/plugins/file_upload/kibana.json b/x-pack/plugins/file_upload/kibana.json new file mode 100644 index 0000000000000..3fda32fb6ebe5 --- /dev/null +++ b/x-pack/plugins/file_upload/kibana.json @@ -0,0 +1,9 @@ +{ + "id": "file_upload", + "version": "8.0.0", + "kibanaVersion": "kibana", + "configPath": ["xpack", "file_upload"], + "server": true, + "ui": true, + "requiredPlugins": ["data", "usageCollection"] +} diff --git a/x-pack/legacy/plugins/file_upload/mappings.ts b/x-pack/plugins/file_upload/mappings.ts similarity index 100% rename from x-pack/legacy/plugins/file_upload/mappings.ts rename to x-pack/plugins/file_upload/mappings.ts diff --git a/x-pack/legacy/plugins/file_upload/public/components/index_settings.js b/x-pack/plugins/file_upload/public/components/index_settings.js similarity index 100% rename from x-pack/legacy/plugins/file_upload/public/components/index_settings.js rename to x-pack/plugins/file_upload/public/components/index_settings.js diff --git a/x-pack/legacy/plugins/file_upload/public/components/json_import_progress.js b/x-pack/plugins/file_upload/public/components/json_import_progress.js similarity index 100% rename from x-pack/legacy/plugins/file_upload/public/components/json_import_progress.js rename to x-pack/plugins/file_upload/public/components/json_import_progress.js diff --git a/x-pack/legacy/plugins/file_upload/public/components/json_index_file_picker.js b/x-pack/plugins/file_upload/public/components/json_index_file_picker.js similarity index 100% rename from x-pack/legacy/plugins/file_upload/public/components/json_index_file_picker.js rename to x-pack/plugins/file_upload/public/components/json_index_file_picker.js diff --git a/x-pack/legacy/plugins/file_upload/public/components/json_upload_and_parse.js b/x-pack/plugins/file_upload/public/components/json_upload_and_parse.js similarity index 100% rename from x-pack/legacy/plugins/file_upload/public/components/json_upload_and_parse.js rename to x-pack/plugins/file_upload/public/components/json_upload_and_parse.js diff --git a/x-pack/legacy/plugins/file_upload/public/index.ts b/x-pack/plugins/file_upload/public/index.ts similarity index 100% rename from x-pack/legacy/plugins/file_upload/public/index.ts rename to x-pack/plugins/file_upload/public/index.ts diff --git a/x-pack/legacy/plugins/file_upload/public/kibana_services.js b/x-pack/plugins/file_upload/public/kibana_services.js similarity index 53% rename from x-pack/legacy/plugins/file_upload/public/kibana_services.js rename to x-pack/plugins/file_upload/public/kibana_services.js index b48b7e49e7912..1269e16266eb5 100644 --- a/x-pack/legacy/plugins/file_upload/public/kibana_services.js +++ b/x-pack/plugins/file_upload/public/kibana_services.js @@ -4,19 +4,17 @@ * you may not use this file except in compliance with the Elastic License. */ -import { npStart } from 'ui/new_platform'; -import { DEFAULT_KBN_VERSION } from '../common/constants/file_import'; - -export const indexPatternService = npStart.plugins.data.indexPatterns; - +export let indexPatternService; export let savedObjectsClient; export let basePath; -export let kbnVersion; export let kbnFetch; -export const initServicesAndConstants = ({ savedObjects, http, injectedMetadata }) => { - savedObjectsClient = savedObjects.client; +export const setupInitServicesAndConstants = ({ http }) => { basePath = http.basePath.basePath; - kbnVersion = injectedMetadata.getKibanaVersion(DEFAULT_KBN_VERSION); kbnFetch = http.fetch; }; + +export const startInitServicesAndConstants = ({ savedObjects }, { data }) => { + indexPatternService = data.indexPatterns; + savedObjectsClient = savedObjects.client; +}; diff --git a/x-pack/legacy/plugins/file_upload/public/plugin.ts b/x-pack/plugins/file_upload/public/plugin.ts similarity index 53% rename from x-pack/legacy/plugins/file_upload/public/plugin.ts rename to x-pack/plugins/file_upload/public/plugin.ts index 53b292b02760f..338c61ad141c6 100644 --- a/x-pack/legacy/plugins/file_upload/public/plugin.ts +++ b/x-pack/plugins/file_upload/public/plugin.ts @@ -4,26 +4,36 @@ * you may not use this file except in compliance with the Elastic License. */ -import { Plugin, CoreStart } from 'src/core/public'; +// @ts-ignore +import { CoreSetup, CoreStart, Plugin } from 'kibana/server'; // @ts-ignore import { JsonUploadAndParse } from './components/json_upload_and_parse'; // @ts-ignore -import { initServicesAndConstants } from './kibana_services'; +import { setupInitServicesAndConstants, startInitServicesAndConstants } from './kibana_services'; +import { IDataPluginServices } from '../../../../src/plugins/data/public'; /** * These are the interfaces with your public contracts. You should export these * for other plugins to use in _their_ `SetupDeps`/`StartDeps` interfaces. * @public */ + +// eslint-disable-next-line @typescript-eslint/no-empty-interface +export interface FileUploadPluginSetupDependencies {} +export interface FileUploadPluginStartDependencies { + data: IDataPluginServices; +} + export type FileUploadPluginSetup = ReturnType; export type FileUploadPluginStart = ReturnType; -/** @internal */ export class FileUploadPlugin implements Plugin { - public setup() {} + public setup(core: CoreSetup, plugins: FileUploadPluginSetupDependencies) { + setupInitServicesAndConstants(core); + } - public start(core: CoreStart) { - initServicesAndConstants(core); + public start(core: CoreStart, plugins: FileUploadPluginStartDependencies) { + startInitServicesAndConstants(core, plugins); return { JsonUploadAndParse, }; diff --git a/x-pack/legacy/plugins/file_upload/public/util/file_parser.js b/x-pack/plugins/file_upload/public/util/file_parser.js similarity index 100% rename from x-pack/legacy/plugins/file_upload/public/util/file_parser.js rename to x-pack/plugins/file_upload/public/util/file_parser.js diff --git a/x-pack/legacy/plugins/file_upload/public/util/file_parser.test.js b/x-pack/plugins/file_upload/public/util/file_parser.test.js similarity index 100% rename from x-pack/legacy/plugins/file_upload/public/util/file_parser.test.js rename to x-pack/plugins/file_upload/public/util/file_parser.test.js diff --git a/x-pack/legacy/plugins/file_upload/public/util/geo_json_clean_and_validate.js b/x-pack/plugins/file_upload/public/util/geo_json_clean_and_validate.js similarity index 100% rename from x-pack/legacy/plugins/file_upload/public/util/geo_json_clean_and_validate.js rename to x-pack/plugins/file_upload/public/util/geo_json_clean_and_validate.js diff --git a/x-pack/legacy/plugins/file_upload/public/util/geo_json_clean_and_validate.test.js b/x-pack/plugins/file_upload/public/util/geo_json_clean_and_validate.test.js similarity index 100% rename from x-pack/legacy/plugins/file_upload/public/util/geo_json_clean_and_validate.test.js rename to x-pack/plugins/file_upload/public/util/geo_json_clean_and_validate.test.js diff --git a/x-pack/legacy/plugins/file_upload/public/util/geo_processing.js b/x-pack/plugins/file_upload/public/util/geo_processing.js similarity index 100% rename from x-pack/legacy/plugins/file_upload/public/util/geo_processing.js rename to x-pack/plugins/file_upload/public/util/geo_processing.js diff --git a/x-pack/legacy/plugins/file_upload/public/util/geo_processing.test.js b/x-pack/plugins/file_upload/public/util/geo_processing.test.js similarity index 100% rename from x-pack/legacy/plugins/file_upload/public/util/geo_processing.test.js rename to x-pack/plugins/file_upload/public/util/geo_processing.test.js diff --git a/x-pack/legacy/plugins/file_upload/public/util/http_service.js b/x-pack/plugins/file_upload/public/util/http_service.js similarity index 100% rename from x-pack/legacy/plugins/file_upload/public/util/http_service.js rename to x-pack/plugins/file_upload/public/util/http_service.js diff --git a/x-pack/legacy/plugins/file_upload/public/util/indexing_service.js b/x-pack/plugins/file_upload/public/util/indexing_service.js similarity index 100% rename from x-pack/legacy/plugins/file_upload/public/util/indexing_service.js rename to x-pack/plugins/file_upload/public/util/indexing_service.js diff --git a/x-pack/legacy/plugins/file_upload/public/util/indexing_service.test.js b/x-pack/plugins/file_upload/public/util/indexing_service.test.js similarity index 100% rename from x-pack/legacy/plugins/file_upload/public/util/indexing_service.test.js rename to x-pack/plugins/file_upload/public/util/indexing_service.test.js diff --git a/x-pack/legacy/plugins/file_upload/public/util/pattern_reader.js b/x-pack/plugins/file_upload/public/util/pattern_reader.js similarity index 100% rename from x-pack/legacy/plugins/file_upload/public/util/pattern_reader.js rename to x-pack/plugins/file_upload/public/util/pattern_reader.js diff --git a/x-pack/legacy/plugins/file_upload/public/util/size_limited_chunking.js b/x-pack/plugins/file_upload/public/util/size_limited_chunking.js similarity index 100% rename from x-pack/legacy/plugins/file_upload/public/util/size_limited_chunking.js rename to x-pack/plugins/file_upload/public/util/size_limited_chunking.js diff --git a/x-pack/legacy/plugins/file_upload/public/util/size_limited_chunking.test.js b/x-pack/plugins/file_upload/public/util/size_limited_chunking.test.js similarity index 100% rename from x-pack/legacy/plugins/file_upload/public/util/size_limited_chunking.test.js rename to x-pack/plugins/file_upload/public/util/size_limited_chunking.test.js diff --git a/x-pack/legacy/plugins/file_upload/server/client/call_with_request_factory.js b/x-pack/plugins/file_upload/server/client/call_with_request_factory.js similarity index 100% rename from x-pack/legacy/plugins/file_upload/server/client/call_with_request_factory.js rename to x-pack/plugins/file_upload/server/client/call_with_request_factory.js diff --git a/x-pack/legacy/plugins/file_upload/server/client/errors.js b/x-pack/plugins/file_upload/server/client/errors.js similarity index 100% rename from x-pack/legacy/plugins/file_upload/server/client/errors.js rename to x-pack/plugins/file_upload/server/client/errors.js diff --git a/x-pack/legacy/plugins/file_upload/public/legacy.ts b/x-pack/plugins/file_upload/server/index.js similarity index 60% rename from x-pack/legacy/plugins/file_upload/public/legacy.ts rename to x-pack/plugins/file_upload/server/index.js index 719599df3ccbe..f894bf788a893 100644 --- a/x-pack/legacy/plugins/file_upload/public/legacy.ts +++ b/x-pack/plugins/file_upload/server/index.js @@ -3,10 +3,8 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ +import { FileUploadPlugin } from './plugin'; -import { npStart } from 'ui/new_platform'; -import { plugin } from '.'; +export * from './plugin'; -const pluginInstance = plugin(); - -export const start = pluginInstance.start(npStart.core); +export const plugin = () => new FileUploadPlugin(); diff --git a/x-pack/legacy/plugins/file_upload/server/kibana_server_services.js b/x-pack/plugins/file_upload/server/kibana_server_services.js similarity index 100% rename from x-pack/legacy/plugins/file_upload/server/kibana_server_services.js rename to x-pack/plugins/file_upload/server/kibana_server_services.js diff --git a/x-pack/legacy/plugins/file_upload/server/models/import_data/import_data.js b/x-pack/plugins/file_upload/server/models/import_data/import_data.js similarity index 100% rename from x-pack/legacy/plugins/file_upload/server/models/import_data/import_data.js rename to x-pack/plugins/file_upload/server/models/import_data/import_data.js diff --git a/x-pack/legacy/plugins/file_upload/server/models/import_data/index.js b/x-pack/plugins/file_upload/server/models/import_data/index.js similarity index 100% rename from x-pack/legacy/plugins/file_upload/server/models/import_data/index.js rename to x-pack/plugins/file_upload/server/models/import_data/index.js diff --git a/x-pack/legacy/plugins/file_upload/server/plugin.js b/x-pack/plugins/file_upload/server/plugin.js similarity index 79% rename from x-pack/legacy/plugins/file_upload/server/plugin.js rename to x-pack/plugins/file_upload/server/plugin.js index c448676f813ea..a11516d03f068 100644 --- a/x-pack/legacy/plugins/file_upload/server/plugin.js +++ b/x-pack/plugins/file_upload/server/plugin.js @@ -6,22 +6,22 @@ import { initRoutes } from './routes/file_upload'; import { setElasticsearchClientServices, setInternalRepository } from './kibana_server_services'; -import { registerFileUploadUsageCollector } from './telemetry'; +import { registerFileUploadUsageCollector, fileUploadTelemetryMappingsType } from './telemetry'; export class FileUploadPlugin { constructor() { this.router = null; } - setup(core) { + setup(core, plugins) { + core.savedObjects.registerType(fileUploadTelemetryMappingsType); setElasticsearchClientServices(core.elasticsearch); this.router = core.http.createRouter(); + registerFileUploadUsageCollector(plugins.usageCollection); } - start(core, plugins) { + start(core) { initRoutes(this.router, core.savedObjects.getSavedObjectsRepository); setInternalRepository(core.savedObjects.createInternalRepository); - - registerFileUploadUsageCollector(plugins.usageCollection); } } diff --git a/x-pack/legacy/plugins/file_upload/server/routes/file_upload.js b/x-pack/plugins/file_upload/server/routes/file_upload.js similarity index 100% rename from x-pack/legacy/plugins/file_upload/server/routes/file_upload.js rename to x-pack/plugins/file_upload/server/routes/file_upload.js diff --git a/x-pack/legacy/plugins/file_upload/server/routes/file_upload.test.js b/x-pack/plugins/file_upload/server/routes/file_upload.test.js similarity index 100% rename from x-pack/legacy/plugins/file_upload/server/routes/file_upload.test.js rename to x-pack/plugins/file_upload/server/routes/file_upload.test.js diff --git a/x-pack/legacy/plugins/file_upload/server/telemetry/file_upload_usage_collector.ts b/x-pack/plugins/file_upload/server/telemetry/file_upload_usage_collector.ts similarity index 100% rename from x-pack/legacy/plugins/file_upload/server/telemetry/file_upload_usage_collector.ts rename to x-pack/plugins/file_upload/server/telemetry/file_upload_usage_collector.ts diff --git a/x-pack/legacy/plugins/file_upload/server/telemetry/index.ts b/x-pack/plugins/file_upload/server/telemetry/index.ts similarity index 83% rename from x-pack/legacy/plugins/file_upload/server/telemetry/index.ts rename to x-pack/plugins/file_upload/server/telemetry/index.ts index 7969dd04ce31f..8d4f4e72bd28a 100644 --- a/x-pack/legacy/plugins/file_upload/server/telemetry/index.ts +++ b/x-pack/plugins/file_upload/server/telemetry/index.ts @@ -5,3 +5,4 @@ */ export { registerFileUploadUsageCollector } from './file_upload_usage_collector'; +export { fileUploadTelemetryMappingsType } from './mappings'; diff --git a/x-pack/plugins/file_upload/server/telemetry/mappings.ts b/x-pack/plugins/file_upload/server/telemetry/mappings.ts new file mode 100644 index 0000000000000..ca935fea3449a --- /dev/null +++ b/x-pack/plugins/file_upload/server/telemetry/mappings.ts @@ -0,0 +1,21 @@ +/* + * 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 { SavedObjectsType } from 'src/core/server'; +import { TELEMETRY_DOC_ID } from './telemetry'; + +export const fileUploadTelemetryMappingsType: SavedObjectsType = { + name: TELEMETRY_DOC_ID, + hidden: false, + namespaceAgnostic: true, + mappings: { + properties: { + filesUploadedTotalCount: { + type: 'long', + }, + }, + }, +}; diff --git a/x-pack/legacy/plugins/file_upload/server/telemetry/telemetry.test.ts b/x-pack/plugins/file_upload/server/telemetry/telemetry.test.ts similarity index 100% rename from x-pack/legacy/plugins/file_upload/server/telemetry/telemetry.test.ts rename to x-pack/plugins/file_upload/server/telemetry/telemetry.test.ts diff --git a/x-pack/legacy/plugins/file_upload/server/telemetry/telemetry.ts b/x-pack/plugins/file_upload/server/telemetry/telemetry.ts similarity index 100% rename from x-pack/legacy/plugins/file_upload/server/telemetry/telemetry.ts rename to x-pack/plugins/file_upload/server/telemetry/telemetry.ts