diff --git a/x-pack/.i18nrc.json b/x-pack/.i18nrc.json index 32ff4908629ebe..e41c1c00f7d64c 100644 --- a/x-pack/.i18nrc.json +++ b/x-pack/.i18nrc.json @@ -18,7 +18,7 @@ "xpack.idxMgmt": "legacy/plugins/index_management", "xpack.indexLifecycleMgmt": "legacy/plugins/index_lifecycle_management", "xpack.infra": "legacy/plugins/infra", - "xpack.kueryAutocomplete": "legacy/plugins/kuery_autocomplete", + "xpack.data": "plugins/data", "xpack.lens": "legacy/plugins/lens", "xpack.licenseMgmt": "legacy/plugins/license_management", "xpack.licensing": "plugins/licensing", diff --git a/x-pack/index.js b/x-pack/index.js index 9ab6e2ee322d90..e2d25ce87b26b4 100644 --- a/x-pack/index.js +++ b/x-pack/index.js @@ -23,7 +23,6 @@ import { licenseManagement } from './legacy/plugins/license_management'; import { indexManagement } from './legacy/plugins/index_management'; import { indexLifecycleManagement } from './legacy/plugins/index_lifecycle_management'; import { spaces } from './legacy/plugins/spaces'; -import { kueryAutocompleteInitializer } from './legacy/plugins/kuery_autocomplete'; import { canvas } from './legacy/plugins/canvas'; import { infra } from './legacy/plugins/infra'; import { taskManager } from './legacy/plugins/task_manager'; @@ -65,7 +64,6 @@ module.exports = function(kibana) { licenseManagement(kibana), indexManagement(kibana), indexLifecycleManagement(kibana), - kueryAutocompleteInitializer(kibana), infra(kibana), taskManager(kibana), rollup(kibana), diff --git a/x-pack/legacy/plugins/kuery_autocomplete/index.ts b/x-pack/legacy/plugins/kuery_autocomplete/index.ts deleted file mode 100644 index 5f9d74ed799e6e..00000000000000 --- a/x-pack/legacy/plugins/kuery_autocomplete/index.ts +++ /dev/null @@ -1,22 +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 { resolve } from 'path'; -import { Legacy } from 'kibana'; - -import { LegacyPluginApi, LegacyPluginInitializer } from '../../../../src/legacy/types'; - -export const kueryAutocompleteInitializer: LegacyPluginInitializer = ({ - Plugin, -}: LegacyPluginApi) => - new Plugin({ - id: 'kuery_autocomplete', - publicDir: resolve(__dirname, 'public'), - uiExports: { - hacks: [resolve(__dirname, 'public/legacy')], - }, - init: (server: Legacy.Server) => ({}), - } as Legacy.PluginSpecOptions); diff --git a/x-pack/legacy/plugins/kuery_autocomplete/public/legacy.ts b/x-pack/legacy/plugins/kuery_autocomplete/public/legacy.ts deleted file mode 100644 index 303fe8c557fbd2..00000000000000 --- a/x-pack/legacy/plugins/kuery_autocomplete/public/legacy.ts +++ /dev/null @@ -1,27 +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/public'; -import { npSetup, npStart } from 'ui/new_platform'; - -import { plugin } from './index'; -import { - KueryAutocompletePluginSetupDependencies, - KueryAutocompletePluginStartDependencies, -} from './plugin'; - -const pluginsSetup: Readonly = { - data: npSetup.plugins.data, -}; - -const pluginsStart: Readonly = { - data: npStart.plugins.data, -}; - -const pluginInstance = plugin({} as PluginInitializerContext); - -export const setup = pluginInstance.setup(npSetup.core, pluginsSetup); -export const start = pluginInstance.start(npStart.core, pluginsStart); diff --git a/x-pack/legacy/plugins/kuery_autocomplete/public/plugin.ts b/x-pack/legacy/plugins/kuery_autocomplete/public/plugin.ts deleted file mode 100644 index 81737c46365327..00000000000000 --- a/x-pack/legacy/plugins/kuery_autocomplete/public/plugin.ts +++ /dev/null @@ -1,41 +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, CoreSetup, CoreStart, Plugin } from 'src/core/public'; -import { Plugin as DataPublicPlugin } from '../../../../../src/plugins/data/public'; -import { setAutocompleteService } from './services'; -import { setupKqlQuerySuggestionProvider } from './kql_query_suggestion'; - -/** @internal */ -export interface KueryAutocompletePluginSetupDependencies { - data: ReturnType; -} - -/** @internal */ -export interface KueryAutocompletePluginStartDependencies { - data: ReturnType; -} - -const KUERY_LANGUAGE_NAME = 'kuery'; - -/** @internal */ -export class KueryAutocompletePlugin implements Plugin, void> { - initializerContext: PluginInitializerContext; - - constructor(initializerContext: PluginInitializerContext) { - this.initializerContext = initializerContext; - } - - public async setup(core: CoreSetup, plugins: KueryAutocompletePluginSetupDependencies) { - const kueryProvider = setupKqlQuerySuggestionProvider(core); - - plugins.data.autocomplete.addQuerySuggestionProvider(KUERY_LANGUAGE_NAME, kueryProvider); - } - - public start(core: CoreStart, plugins: KueryAutocompletePluginStartDependencies) { - setAutocompleteService(plugins.data.autocomplete); - } -} diff --git a/x-pack/plugins/data/kibana.json b/x-pack/plugins/data/kibana.json new file mode 100644 index 00000000000000..21f44a3ae92590 --- /dev/null +++ b/x-pack/plugins/data/kibana.json @@ -0,0 +1,13 @@ +{ + "id": "data_xpack", + "version": "8.0.0", + "kibanaVersion": "kibana", + "configPath": [ + "xpack" + ], + "requiredPlugins": [ + "data" + ], + "server": false, + "ui": true +} diff --git a/x-pack/legacy/plugins/kuery_autocomplete/public/index.ts b/x-pack/plugins/data/public/autocomplete/index.ts similarity index 50% rename from x-pack/legacy/plugins/kuery_autocomplete/public/index.ts rename to x-pack/plugins/data/public/autocomplete/index.ts index c2241f424511ff..59670a89d2cafc 100644 --- a/x-pack/legacy/plugins/kuery_autocomplete/public/index.ts +++ b/x-pack/plugins/data/public/autocomplete/index.ts @@ -4,9 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { PluginInitializerContext } from 'src/core/public'; -import { KueryAutocompletePlugin as Plugin } from './plugin'; - -export function plugin(initializerContext: PluginInitializerContext) { - return new Plugin(initializerContext); -} +export { + setupKqlQuerySuggestionProvider, + KUERY_LANGUAGE_NAME, +} from './providers/kql_query_suggestion'; diff --git a/x-pack/legacy/plugins/kuery_autocomplete/public/kql_query_suggestion/__fixtures__/index_pattern_response.json b/x-pack/plugins/data/public/autocomplete/providers/kql_query_suggestion/__fixtures__/index_pattern_response.json similarity index 100% rename from x-pack/legacy/plugins/kuery_autocomplete/public/kql_query_suggestion/__fixtures__/index_pattern_response.json rename to x-pack/plugins/data/public/autocomplete/providers/kql_query_suggestion/__fixtures__/index_pattern_response.json diff --git a/x-pack/legacy/plugins/kuery_autocomplete/public/kql_query_suggestion/conjunction.test.ts b/x-pack/plugins/data/public/autocomplete/providers/kql_query_suggestion/conjunction.test.ts similarity index 93% rename from x-pack/legacy/plugins/kuery_autocomplete/public/kql_query_suggestion/conjunction.test.ts rename to x-pack/plugins/data/public/autocomplete/providers/kql_query_suggestion/conjunction.test.ts index e8aec0deec6d75..d993c3d8ad51d2 100644 --- a/x-pack/legacy/plugins/kuery_autocomplete/public/kql_query_suggestion/conjunction.test.ts +++ b/x-pack/plugins/data/public/autocomplete/providers/kql_query_suggestion/conjunction.test.ts @@ -5,8 +5,8 @@ */ import { setupGetConjunctionSuggestions } from './conjunction'; -import { autocomplete, esKuery } from '../../../../../../src/plugins/data/public'; -import { coreMock } from '../../../../../../src/core/public/mocks'; +import { autocomplete, esKuery } from '../../../../../../../src/plugins/data/public'; +import { coreMock } from '../../../../../../../src/core/public/mocks'; const mockKueryNode = (kueryNode: Partial) => (kueryNode as unknown) as esKuery.KueryNode; diff --git a/x-pack/legacy/plugins/kuery_autocomplete/public/kql_query_suggestion/conjunction.tsx b/x-pack/plugins/data/public/autocomplete/providers/kql_query_suggestion/conjunction.tsx similarity index 97% rename from x-pack/legacy/plugins/kuery_autocomplete/public/kql_query_suggestion/conjunction.tsx rename to x-pack/plugins/data/public/autocomplete/providers/kql_query_suggestion/conjunction.tsx index f570586274fdd8..020fe2525e76a0 100644 --- a/x-pack/legacy/plugins/kuery_autocomplete/public/kql_query_suggestion/conjunction.tsx +++ b/x-pack/plugins/data/public/autocomplete/providers/kql_query_suggestion/conjunction.tsx @@ -7,7 +7,7 @@ import React from 'react'; import { $Keys } from 'utility-types'; import { FormattedMessage } from '@kbn/i18n/react'; import { KqlQuerySuggestionProvider } from './types'; -import { autocomplete } from '../../../../../../src/plugins/data/public'; +import { autocomplete } from '../../../../../../../src/plugins/data/public'; const bothArgumentsText = ( ) => (kueryNode as unknown) as esKuery.KueryNode; diff --git a/x-pack/legacy/plugins/kuery_autocomplete/public/kql_query_suggestion/field.tsx b/x-pack/plugins/data/public/autocomplete/providers/kql_query_suggestion/field.tsx similarity index 96% rename from x-pack/legacy/plugins/kuery_autocomplete/public/kql_query_suggestion/field.tsx rename to x-pack/plugins/data/public/autocomplete/providers/kql_query_suggestion/field.tsx index a8af884c24fc32..442804409b3235 100644 --- a/x-pack/legacy/plugins/kuery_autocomplete/public/kql_query_suggestion/field.tsx +++ b/x-pack/plugins/data/public/autocomplete/providers/kql_query_suggestion/field.tsx @@ -8,7 +8,11 @@ import { flatten } from 'lodash'; import { FormattedMessage } from '@kbn/i18n/react'; import { escapeKuery } from './lib/escape_kuery'; import { sortPrefixFirst } from './sort_prefix_first'; -import { IFieldType, isFilterable, autocomplete } from '../../../../../../src/plugins/data/public'; +import { + IFieldType, + isFilterable, + autocomplete, +} from '../../../../../../../src/plugins/data/public'; import { KqlQuerySuggestionProvider } from './types'; const getDescription = (field: IFieldType) => { diff --git a/x-pack/legacy/plugins/kuery_autocomplete/public/kql_query_suggestion/index.ts b/x-pack/plugins/data/public/autocomplete/providers/kql_query_suggestion/index.ts similarity index 94% rename from x-pack/legacy/plugins/kuery_autocomplete/public/kql_query_suggestion/index.ts rename to x-pack/plugins/data/public/autocomplete/providers/kql_query_suggestion/index.ts index 2cc15fe4c92801..6168ab8fc34628 100644 --- a/x-pack/legacy/plugins/kuery_autocomplete/public/kql_query_suggestion/index.ts +++ b/x-pack/plugins/data/public/autocomplete/providers/kql_query_suggestion/index.ts @@ -11,13 +11,15 @@ import { setupGetFieldSuggestions } from './field'; import { setupGetValueSuggestions } from './value'; import { setupGetOperatorSuggestions } from './operator'; import { setupGetConjunctionSuggestions } from './conjunction'; -import { esKuery, autocomplete } from '../../../../../../src/plugins/data/public'; +import { esKuery, autocomplete } from '../../../../../../../src/plugins/data/public'; const cursorSymbol = '@kuery-cursor@'; const dedup = (suggestions: autocomplete.QuerySuggestion[]): autocomplete.QuerySuggestion[] => uniq(suggestions, ({ type, text, start, end }) => [type, text, start, end].join('|')); +export const KUERY_LANGUAGE_NAME = 'kuery'; + export const setupKqlQuerySuggestionProvider = ( core: CoreSetup ): autocomplete.QuerySuggestionsGetFn => { diff --git a/x-pack/legacy/plugins/kuery_autocomplete/public/kql_query_suggestion/lib/escape_kuery.test.ts b/x-pack/plugins/data/public/autocomplete/providers/kql_query_suggestion/lib/escape_kuery.test.ts similarity index 100% rename from x-pack/legacy/plugins/kuery_autocomplete/public/kql_query_suggestion/lib/escape_kuery.test.ts rename to x-pack/plugins/data/public/autocomplete/providers/kql_query_suggestion/lib/escape_kuery.test.ts diff --git a/x-pack/legacy/plugins/kuery_autocomplete/public/kql_query_suggestion/lib/escape_kuery.ts b/x-pack/plugins/data/public/autocomplete/providers/kql_query_suggestion/lib/escape_kuery.ts similarity index 100% rename from x-pack/legacy/plugins/kuery_autocomplete/public/kql_query_suggestion/lib/escape_kuery.ts rename to x-pack/plugins/data/public/autocomplete/providers/kql_query_suggestion/lib/escape_kuery.ts diff --git a/x-pack/legacy/plugins/kuery_autocomplete/public/kql_query_suggestion/operator.test.ts b/x-pack/plugins/data/public/autocomplete/providers/kql_query_suggestion/operator.test.ts similarity index 94% rename from x-pack/legacy/plugins/kuery_autocomplete/public/kql_query_suggestion/operator.test.ts rename to x-pack/plugins/data/public/autocomplete/providers/kql_query_suggestion/operator.test.ts index acafc4e169c8f2..7e564b96064ef5 100644 --- a/x-pack/legacy/plugins/kuery_autocomplete/public/kql_query_suggestion/operator.test.ts +++ b/x-pack/plugins/data/public/autocomplete/providers/kql_query_suggestion/operator.test.ts @@ -6,8 +6,8 @@ import indexPatternResponse from './__fixtures__/index_pattern_response.json'; import { setupGetOperatorSuggestions } from './operator'; -import { autocomplete, esKuery } from '../../../../../../src/plugins/data/public'; -import { coreMock } from '../../../../../../src/core/public/mocks'; +import { autocomplete, esKuery } from '../../../../../../../src/plugins/data/public'; +import { coreMock } from '../../../../../../../src/core/public/mocks'; const mockKueryNode = (kueryNode: Partial) => (kueryNode as unknown) as esKuery.KueryNode; diff --git a/x-pack/legacy/plugins/kuery_autocomplete/public/kql_query_suggestion/operator.tsx b/x-pack/plugins/data/public/autocomplete/providers/kql_query_suggestion/operator.tsx similarity index 98% rename from x-pack/legacy/plugins/kuery_autocomplete/public/kql_query_suggestion/operator.tsx rename to x-pack/plugins/data/public/autocomplete/providers/kql_query_suggestion/operator.tsx index 6e9010c4310fbe..fa215f33494088 100644 --- a/x-pack/legacy/plugins/kuery_autocomplete/public/kql_query_suggestion/operator.tsx +++ b/x-pack/plugins/data/public/autocomplete/providers/kql_query_suggestion/operator.tsx @@ -10,7 +10,7 @@ import { $Keys } from 'utility-types'; import { flatten } from 'lodash'; import { KqlQuerySuggestionProvider } from './types'; -import { autocomplete } from '../../../../../../src/plugins/data/public'; +import { autocomplete } from '../../../../../../../src/plugins/data/public'; const equalsText = ( = ( core: CoreSetup diff --git a/x-pack/legacy/plugins/kuery_autocomplete/public/kql_query_suggestion/value.test.ts b/x-pack/plugins/data/public/autocomplete/providers/kql_query_suggestion/value.test.ts similarity index 96% rename from x-pack/legacy/plugins/kuery_autocomplete/public/kql_query_suggestion/value.test.ts rename to x-pack/plugins/data/public/autocomplete/providers/kql_query_suggestion/value.test.ts index 5ffe30c877868f..14eeabda97d1a4 100644 --- a/x-pack/legacy/plugins/kuery_autocomplete/public/kql_query_suggestion/value.test.ts +++ b/x-pack/plugins/data/public/autocomplete/providers/kql_query_suggestion/value.test.ts @@ -5,9 +5,9 @@ */ import { setupGetValueSuggestions } from './value'; import indexPatternResponse from './__fixtures__/index_pattern_response.json'; -import { coreMock } from '../../../../../../src/core/public/mocks'; -import { autocomplete, esKuery } from '../../../../../../src/plugins/data/public'; -import { setAutocompleteService } from '../services'; +import { coreMock } from '../../../../../../../src/core/public/mocks'; +import { autocomplete, esKuery } from '../../../../../../../src/plugins/data/public'; +import { setAutocompleteService } from '../../../services'; const mockKueryNode = (kueryNode: Partial) => (kueryNode as unknown) as esKuery.KueryNode; diff --git a/x-pack/legacy/plugins/kuery_autocomplete/public/kql_query_suggestion/value.ts b/x-pack/plugins/data/public/autocomplete/providers/kql_query_suggestion/value.ts similarity index 93% rename from x-pack/legacy/plugins/kuery_autocomplete/public/kql_query_suggestion/value.ts rename to x-pack/plugins/data/public/autocomplete/providers/kql_query_suggestion/value.ts index 242b9ccba3508e..83b8024d8314de 100644 --- a/x-pack/legacy/plugins/kuery_autocomplete/public/kql_query_suggestion/value.ts +++ b/x-pack/plugins/data/public/autocomplete/providers/kql_query_suggestion/value.ts @@ -7,8 +7,8 @@ import { flatten } from 'lodash'; import { escapeQuotes } from './lib/escape_kuery'; import { KqlQuerySuggestionProvider } from './types'; -import { getAutocompleteService } from '../services'; -import { autocomplete } from '../../../../../../src/plugins/data/public'; +import { getAutocompleteService } from '../../../services'; +import { autocomplete } from '../../../../../../../src/plugins/data/public'; const wrapAsSuggestions = (start: number, end: number, query: string, values: string[]) => values diff --git a/x-pack/plugins/data/public/index.ts b/x-pack/plugins/data/public/index.ts new file mode 100644 index 00000000000000..0e614264385eff --- /dev/null +++ b/x-pack/plugins/data/public/index.ts @@ -0,0 +1,20 @@ +/* + * 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 { PluginInitializer } from 'kibana/public'; +import { + DataPublicPlugin as Plugin, + DataPublicSetup, + DataPublicStart, + DataPublicSetupDependencies, + DataPublicStartDependencies, +} from './plugin'; + +export const plugin: PluginInitializer< + DataPublicSetup, + DataPublicStart, + DataPublicSetupDependencies, + DataPublicStartDependencies +> = () => new Plugin(); diff --git a/x-pack/plugins/data/public/plugin.ts b/x-pack/plugins/data/public/plugin.ts new file mode 100644 index 00000000000000..4d74754e4a62ad --- /dev/null +++ b/x-pack/plugins/data/public/plugin.ts @@ -0,0 +1,33 @@ +/* + * 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 } from 'src/core/public'; +import { DataPublicPluginStart, DataPublicPluginSetup } from '../../../../src/plugins/data/public'; +import { setAutocompleteService } from './services'; +import { setupKqlQuerySuggestionProvider, KUERY_LANGUAGE_NAME } from './autocomplete'; + +export interface DataPublicSetupDependencies { + data: DataPublicPluginSetup; +} +export interface DataPublicStartDependencies { + data: DataPublicPluginStart; +} + +export type DataPublicSetup = ReturnType; +export type DataPublicStart = ReturnType; + +export class DataPublicPlugin implements Plugin { + public setup(core: CoreSetup, plugins: DataPublicSetupDependencies) { + plugins.data.autocomplete.addQuerySuggestionProvider( + KUERY_LANGUAGE_NAME, + setupKqlQuerySuggestionProvider(core) + ); + } + + public start(core: CoreStart, plugins: DataPublicStartDependencies) { + setAutocompleteService(plugins.data.autocomplete); + } +} diff --git a/x-pack/legacy/plugins/kuery_autocomplete/public/services.ts b/x-pack/plugins/data/public/services.ts similarity index 70% rename from x-pack/legacy/plugins/kuery_autocomplete/public/services.ts rename to x-pack/plugins/data/public/services.ts index 1ec48e597f6360..847b4c783fd7fd 100644 --- a/x-pack/legacy/plugins/kuery_autocomplete/public/services.ts +++ b/x-pack/plugins/data/public/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/public'; -import { DataPublicPluginStart } from '../../../../../src/plugins/data/public'; +import { createGetterSetter } from '../../../../src/plugins/kibana_utils/public'; +import { DataPublicPluginStart } from '../../../../src/plugins/data/public'; export const [getAutocompleteService, setAutocompleteService] = createGetterSetter< DataPublicPluginStart['autocomplete']