From b09653ac74a8b34332bc23f95479b48ee30e709f Mon Sep 17 00:00:00 2001 From: Gidi Meir Morris Date: Fri, 3 Jan 2020 12:07:17 +0000 Subject: [PATCH 1/2] moved Task Manager server code under "server" directory (#53777) Changes Task Manager folder structure to include a "server" folder as required by our linting rules as part of the migration to the Kibana Platform --- .../server/action_type_registry.test.ts | 2 +- .../actions/server/action_type_registry.ts | 2 +- .../actions/server/actions_client.test.ts | 2 +- .../server/builtin_action_types/index.test.ts | 2 +- .../server/create_execute_function.test.ts | 2 +- .../server/lib/task_runner_factory.test.ts | 2 +- .../actions/server/lib/task_runner_factory.ts | 2 +- x-pack/legacy/plugins/actions/server/shim.ts | 2 +- .../server/alert_type_registry.test.ts | 2 +- .../alerting/server/alert_type_registry.ts | 2 +- .../alerting/server/alerts_client.test.ts | 4 +- .../server/lib/alerts_client_factory.test.ts | 2 +- .../server/lib/task_runner_factory.test.ts | 2 +- .../server/lib/task_runner_factory.ts | 2 +- x-pack/legacy/plugins/alerting/server/shim.ts | 2 +- .../legacy/plugins/lens/server/usage/task.ts | 2 +- .../visualizations/get_usage_collector.ts | 2 +- .../register_usage_collector.ts | 2 +- .../oss_telemetry/server/lib/tasks/index.ts | 4 +- .../tasks/visualizations/task_runner.test.ts | 2 +- .../lib/tasks/visualizations/task_runner.ts | 2 +- .../plugins/oss_telemetry/server/plugin.ts | 2 +- .../plugins/oss_telemetry/test_utils/index.ts | 4 +- x-pack/legacy/plugins/task_manager/index.ts | 95 +---------------- .../task_manager/{ => server}/README.md | 0 .../plugins/task_manager/server/index.ts | 100 ++++++++++++++++++ .../lib/correct_deprecated_fields.test.ts | 0 .../lib/correct_deprecated_fields.ts | 0 .../{ => server}/lib/fill_pool.test.ts | 0 .../{ => server}/lib/fill_pool.ts | 0 .../lib/get_template_version.test.ts | 0 .../{ => server}/lib/get_template_version.ts | 0 .../lib/identify_es_error.test.ts | 0 .../{ => server}/lib/identify_es_error.ts | 0 .../{ => server}/lib/intervals.test.ts | 0 .../{ => server}/lib/intervals.ts | 0 .../{ => server}/lib/middleware.test.ts | 0 .../{ => server}/lib/middleware.ts | 0 .../{ => server}/lib/pull_from_set.test.ts | 0 .../{ => server}/lib/pull_from_set.ts | 0 .../{ => server}/lib/result_type.ts | 0 .../lib/sanitize_task_definitions.test.ts | 0 .../lib/sanitize_task_definitions.ts | 0 .../task_manager/{ => server}/mappings.json | 0 .../task_manager/{ => server}/migrations.ts | 6 +- .../task_manager/{ => server}/plugin.test.ts | 0 .../task_manager/{ => server}/plugin.ts | 0 .../mark_available_tasks_as_claimed.test.ts | 0 .../mark_available_tasks_as_claimed.ts | 0 .../{ => server}/queries/query_clauses.ts | 0 .../plugins/task_manager/{ => server}/task.ts | 0 .../task_manager/{ => server}/task_events.ts | 0 .../{ => server}/task_manager.mock.ts | 0 .../{ => server}/task_manager.test.ts | 8 +- .../task_manager/{ => server}/task_manager.ts | 5 +- .../{ => server}/task_poller.test.ts | 0 .../task_manager/{ => server}/task_poller.ts | 0 .../{ => server}/task_pool.test.ts | 0 .../task_manager/{ => server}/task_pool.ts | 0 .../{ => server}/task_runner.test.ts | 5 +- .../task_manager/{ => server}/task_runner.ts | 0 .../{ => server}/task_store.test.ts | 15 ++- .../task_manager/{ => server}/task_store.ts | 5 +- .../{ => server}/test_utils/index.ts | 0 .../task_manager/{ => server}/types.ts | 0 .../task_manager/task_manager_integration.js | 2 +- x-pack/test/typings/hapi.d.ts | 2 +- x-pack/typings/hapi.d.ts | 2 +- 68 files changed, 143 insertions(+), 154 deletions(-) rename x-pack/legacy/plugins/task_manager/{ => server}/README.md (100%) create mode 100644 x-pack/legacy/plugins/task_manager/server/index.ts rename x-pack/legacy/plugins/task_manager/{ => server}/lib/correct_deprecated_fields.test.ts (100%) rename x-pack/legacy/plugins/task_manager/{ => server}/lib/correct_deprecated_fields.ts (100%) rename x-pack/legacy/plugins/task_manager/{ => server}/lib/fill_pool.test.ts (100%) rename x-pack/legacy/plugins/task_manager/{ => server}/lib/fill_pool.ts (100%) rename x-pack/legacy/plugins/task_manager/{ => server}/lib/get_template_version.test.ts (100%) rename x-pack/legacy/plugins/task_manager/{ => server}/lib/get_template_version.ts (100%) rename x-pack/legacy/plugins/task_manager/{ => server}/lib/identify_es_error.test.ts (100%) rename x-pack/legacy/plugins/task_manager/{ => server}/lib/identify_es_error.ts (100%) rename x-pack/legacy/plugins/task_manager/{ => server}/lib/intervals.test.ts (100%) rename x-pack/legacy/plugins/task_manager/{ => server}/lib/intervals.ts (100%) rename x-pack/legacy/plugins/task_manager/{ => server}/lib/middleware.test.ts (100%) rename x-pack/legacy/plugins/task_manager/{ => server}/lib/middleware.ts (100%) rename x-pack/legacy/plugins/task_manager/{ => server}/lib/pull_from_set.test.ts (100%) rename x-pack/legacy/plugins/task_manager/{ => server}/lib/pull_from_set.ts (100%) rename x-pack/legacy/plugins/task_manager/{ => server}/lib/result_type.ts (100%) rename x-pack/legacy/plugins/task_manager/{ => server}/lib/sanitize_task_definitions.test.ts (100%) rename x-pack/legacy/plugins/task_manager/{ => server}/lib/sanitize_task_definitions.ts (100%) rename x-pack/legacy/plugins/task_manager/{ => server}/mappings.json (100%) rename x-pack/legacy/plugins/task_manager/{ => server}/migrations.ts (73%) rename x-pack/legacy/plugins/task_manager/{ => server}/plugin.test.ts (100%) rename x-pack/legacy/plugins/task_manager/{ => server}/plugin.ts (100%) rename x-pack/legacy/plugins/task_manager/{ => server}/queries/mark_available_tasks_as_claimed.test.ts (100%) rename x-pack/legacy/plugins/task_manager/{ => server}/queries/mark_available_tasks_as_claimed.ts (100%) rename x-pack/legacy/plugins/task_manager/{ => server}/queries/query_clauses.ts (100%) rename x-pack/legacy/plugins/task_manager/{ => server}/task.ts (100%) rename x-pack/legacy/plugins/task_manager/{ => server}/task_events.ts (100%) rename x-pack/legacy/plugins/task_manager/{ => server}/task_manager.mock.ts (100%) rename x-pack/legacy/plugins/task_manager/{ => server}/task_manager.test.ts (97%) rename x-pack/legacy/plugins/task_manager/{ => server}/task_manager.ts (98%) rename x-pack/legacy/plugins/task_manager/{ => server}/task_poller.test.ts (100%) rename x-pack/legacy/plugins/task_manager/{ => server}/task_poller.ts (100%) rename x-pack/legacy/plugins/task_manager/{ => server}/task_pool.test.ts (100%) rename x-pack/legacy/plugins/task_manager/{ => server}/task_pool.ts (100%) rename x-pack/legacy/plugins/task_manager/{ => server}/task_runner.test.ts (98%) rename x-pack/legacy/plugins/task_manager/{ => server}/task_runner.ts (100%) rename x-pack/legacy/plugins/task_manager/{ => server}/task_store.test.ts (98%) rename x-pack/legacy/plugins/task_manager/{ => server}/task_store.ts (98%) rename x-pack/legacy/plugins/task_manager/{ => server}/test_utils/index.ts (100%) rename x-pack/legacy/plugins/task_manager/{ => server}/types.ts (100%) diff --git a/x-pack/legacy/plugins/actions/server/action_type_registry.test.ts b/x-pack/legacy/plugins/actions/server/action_type_registry.test.ts index 98721c5675824..2f15ae1c0a2b3 100644 --- a/x-pack/legacy/plugins/actions/server/action_type_registry.test.ts +++ b/x-pack/legacy/plugins/actions/server/action_type_registry.test.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { taskManagerMock } from '../../task_manager/task_manager.mock'; +import { taskManagerMock } from '../../task_manager/server/task_manager.mock'; import { ActionTypeRegistry } from './action_type_registry'; import { ExecutorType } from './types'; import { ActionExecutor, ExecutorError, TaskRunnerFactory } from './lib'; diff --git a/x-pack/legacy/plugins/actions/server/action_type_registry.ts b/x-pack/legacy/plugins/actions/server/action_type_registry.ts index a09788e45c394..f66d1947c2b8b 100644 --- a/x-pack/legacy/plugins/actions/server/action_type_registry.ts +++ b/x-pack/legacy/plugins/actions/server/action_type_registry.ts @@ -7,7 +7,7 @@ import Boom from 'boom'; import { i18n } from '@kbn/i18n'; import { TaskManagerSetupContract } from './shim'; -import { RunContext } from '../../task_manager'; +import { RunContext } from '../../task_manager/server'; import { ExecutorError, TaskRunnerFactory } from './lib'; import { ActionType } from './types'; import { ActionsConfigurationUtilities } from './actions_config'; diff --git a/x-pack/legacy/plugins/actions/server/actions_client.test.ts b/x-pack/legacy/plugins/actions/server/actions_client.test.ts index 73b1de224eb32..9e75248c56cae 100644 --- a/x-pack/legacy/plugins/actions/server/actions_client.test.ts +++ b/x-pack/legacy/plugins/actions/server/actions_client.test.ts @@ -10,7 +10,7 @@ import { ActionTypeRegistry } from './action_type_registry'; import { ActionsClient } from './actions_client'; import { ExecutorType } from './types'; import { ActionExecutor, TaskRunnerFactory } from './lib'; -import { taskManagerMock } from '../../task_manager/task_manager.mock'; +import { taskManagerMock } from '../../task_manager/server/task_manager.mock'; import { configUtilsMock } from './actions_config.mock'; import { getActionsConfigurationUtilities } from './actions_config'; diff --git a/x-pack/legacy/plugins/actions/server/builtin_action_types/index.test.ts b/x-pack/legacy/plugins/actions/server/builtin_action_types/index.test.ts index a39aaf3a3e2d1..3a0c9f415cc2b 100644 --- a/x-pack/legacy/plugins/actions/server/builtin_action_types/index.test.ts +++ b/x-pack/legacy/plugins/actions/server/builtin_action_types/index.test.ts @@ -6,7 +6,7 @@ import { ActionExecutor, TaskRunnerFactory } from '../lib'; import { ActionTypeRegistry } from '../action_type_registry'; -import { taskManagerMock } from '../../../task_manager/task_manager.mock'; +import { taskManagerMock } from '../../../task_manager/server/task_manager.mock'; import { registerBuiltInActionTypes } from './index'; import { Logger } from '../../../../../../src/core/server'; import { loggingServiceMock } from '../../../../../../src/core/server/mocks'; diff --git a/x-pack/legacy/plugins/actions/server/create_execute_function.test.ts b/x-pack/legacy/plugins/actions/server/create_execute_function.test.ts index c5496cd92cc9f..6de446ee2da76 100644 --- a/x-pack/legacy/plugins/actions/server/create_execute_function.test.ts +++ b/x-pack/legacy/plugins/actions/server/create_execute_function.test.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { taskManagerMock } from '../../task_manager/task_manager.mock'; +import { taskManagerMock } from '../../task_manager/server/task_manager.mock'; import { createExecuteFunction } from './create_execute_function'; import { savedObjectsClientMock } from '../../../../../src/core/server/mocks'; diff --git a/x-pack/legacy/plugins/actions/server/lib/task_runner_factory.test.ts b/x-pack/legacy/plugins/actions/server/lib/task_runner_factory.test.ts index eb183f1f1d06a..5b60696c42d52 100644 --- a/x-pack/legacy/plugins/actions/server/lib/task_runner_factory.test.ts +++ b/x-pack/legacy/plugins/actions/server/lib/task_runner_factory.test.ts @@ -7,7 +7,7 @@ import sinon from 'sinon'; import { ExecutorError } from './executor_error'; import { ActionExecutor } from './action_executor'; -import { ConcreteTaskInstance, TaskStatus } from '../../../task_manager'; +import { ConcreteTaskInstance, TaskStatus } from '../../../task_manager/server'; import { TaskRunnerFactory } from './task_runner_factory'; import { actionTypeRegistryMock } from '../action_type_registry.mock'; import { actionExecutorMock } from './action_executor.mock'; diff --git a/x-pack/legacy/plugins/actions/server/lib/task_runner_factory.ts b/x-pack/legacy/plugins/actions/server/lib/task_runner_factory.ts index c0cca22b2c3eb..ca6a726f40e14 100644 --- a/x-pack/legacy/plugins/actions/server/lib/task_runner_factory.ts +++ b/x-pack/legacy/plugins/actions/server/lib/task_runner_factory.ts @@ -6,7 +6,7 @@ import { ActionExecutorContract } from './action_executor'; import { ExecutorError } from './executor_error'; -import { RunContext } from '../../../task_manager'; +import { RunContext } from '../../../task_manager/server'; import { PluginStartContract as EncryptedSavedObjectsStartContract } from '../../../../../plugins/encrypted_saved_objects/server'; import { ActionTaskParams, GetBasePathFunction, SpaceIdToNamespaceFunction } from '../types'; diff --git a/x-pack/legacy/plugins/actions/server/shim.ts b/x-pack/legacy/plugins/actions/server/shim.ts index 3887e62c4c40a..f8aa9b8d7a25c 100644 --- a/x-pack/legacy/plugins/actions/server/shim.ts +++ b/x-pack/legacy/plugins/actions/server/shim.ts @@ -8,7 +8,7 @@ import Hapi from 'hapi'; import { Legacy } from 'kibana'; import * as Rx from 'rxjs'; import { ActionsConfigType } from './types'; -import { TaskManager } from '../../task_manager'; +import { TaskManager } from '../../task_manager/server'; import { XPackMainPlugin } from '../../xpack_main/server/xpack_main'; import KbnServer from '../../../../../src/legacy/server/kbn_server'; import { LegacySpacesPlugin as SpacesPluginStartContract } from '../../spaces'; diff --git a/x-pack/legacy/plugins/alerting/server/alert_type_registry.test.ts b/x-pack/legacy/plugins/alerting/server/alert_type_registry.test.ts index e03df364e78ce..57e1b965960e8 100644 --- a/x-pack/legacy/plugins/alerting/server/alert_type_registry.test.ts +++ b/x-pack/legacy/plugins/alerting/server/alert_type_registry.test.ts @@ -6,7 +6,7 @@ import { TaskRunnerFactory } from './lib'; import { AlertTypeRegistry } from './alert_type_registry'; -import { taskManagerMock } from '../../task_manager/task_manager.mock'; +import { taskManagerMock } from '../../task_manager/server/task_manager.mock'; const taskManager = taskManagerMock.create(); diff --git a/x-pack/legacy/plugins/alerting/server/alert_type_registry.ts b/x-pack/legacy/plugins/alerting/server/alert_type_registry.ts index ec875aa2181eb..b7512864c2a98 100644 --- a/x-pack/legacy/plugins/alerting/server/alert_type_registry.ts +++ b/x-pack/legacy/plugins/alerting/server/alert_type_registry.ts @@ -7,7 +7,7 @@ import Boom from 'boom'; import { i18n } from '@kbn/i18n'; import { TaskRunnerFactory } from './lib'; -import { RunContext } from '../../task_manager'; +import { RunContext } from '../../task_manager/server'; import { TaskManagerSetupContract } from './shim'; import { AlertType } from './types'; diff --git a/x-pack/legacy/plugins/alerting/server/alerts_client.test.ts b/x-pack/legacy/plugins/alerting/server/alerts_client.test.ts index d11541e9378bb..316f4cf802ab6 100644 --- a/x-pack/legacy/plugins/alerting/server/alerts_client.test.ts +++ b/x-pack/legacy/plugins/alerting/server/alerts_client.test.ts @@ -7,9 +7,9 @@ import uuid from 'uuid'; import { schema } from '@kbn/config-schema'; import { AlertsClient } from './alerts_client'; import { savedObjectsClientMock, loggingServiceMock } from '../../../../../src/core/server/mocks'; -import { taskManagerMock } from '../../task_manager/task_manager.mock'; +import { taskManagerMock } from '../../task_manager/server/task_manager.mock'; import { alertTypeRegistryMock } from './alert_type_registry.mock'; -import { TaskStatus } from '../../task_manager'; +import { TaskStatus } from '../../task_manager/server'; import { IntervalSchedule } from './types'; import { resolvable } from './test_utils'; diff --git a/x-pack/legacy/plugins/alerting/server/lib/alerts_client_factory.test.ts b/x-pack/legacy/plugins/alerting/server/lib/alerts_client_factory.test.ts index a465aebc8bd86..299e9270ba6bb 100644 --- a/x-pack/legacy/plugins/alerting/server/lib/alerts_client_factory.test.ts +++ b/x-pack/legacy/plugins/alerting/server/lib/alerts_client_factory.test.ts @@ -7,7 +7,7 @@ import { Request } from 'hapi'; import { AlertsClientFactory, ConstructorOpts } from './alerts_client_factory'; import { alertTypeRegistryMock } from '../alert_type_registry.mock'; -import { taskManagerMock } from '../../../task_manager/task_manager.mock'; +import { taskManagerMock } from '../../../task_manager/server/task_manager.mock'; import { KibanaRequest } from '../../../../../../src/core/server'; import { loggingServiceMock } from '../../../../../../src/core/server/mocks'; diff --git a/x-pack/legacy/plugins/alerting/server/lib/task_runner_factory.test.ts b/x-pack/legacy/plugins/alerting/server/lib/task_runner_factory.test.ts index 7966f98c749c8..fd13452e04535 100644 --- a/x-pack/legacy/plugins/alerting/server/lib/task_runner_factory.test.ts +++ b/x-pack/legacy/plugins/alerting/server/lib/task_runner_factory.test.ts @@ -7,7 +7,7 @@ import sinon from 'sinon'; import { schema } from '@kbn/config-schema'; import { AlertExecutorOptions } from '../types'; -import { ConcreteTaskInstance, TaskStatus } from '../../../task_manager'; +import { ConcreteTaskInstance, TaskStatus } from '../../../task_manager/server'; import { TaskRunnerContext, TaskRunnerFactory } from './task_runner_factory'; import { encryptedSavedObjectsMock } from '../../../../../plugins/encrypted_saved_objects/server/mocks'; import { diff --git a/x-pack/legacy/plugins/alerting/server/lib/task_runner_factory.ts b/x-pack/legacy/plugins/alerting/server/lib/task_runner_factory.ts index fe0979538d04e..5614188795ded 100644 --- a/x-pack/legacy/plugins/alerting/server/lib/task_runner_factory.ts +++ b/x-pack/legacy/plugins/alerting/server/lib/task_runner_factory.ts @@ -5,7 +5,7 @@ */ import { Logger } from '../../../../../../src/core/server'; -import { RunContext } from '../../../task_manager'; +import { RunContext } from '../../../task_manager/server'; import { createExecutionHandler } from './create_execution_handler'; import { createAlertInstanceFactory } from './create_alert_instance_factory'; import { AlertInstance } from './alert_instance'; diff --git a/x-pack/legacy/plugins/alerting/server/shim.ts b/x-pack/legacy/plugins/alerting/server/shim.ts index a3d6b778b3a1f..ae29048d83dd9 100644 --- a/x-pack/legacy/plugins/alerting/server/shim.ts +++ b/x-pack/legacy/plugins/alerting/server/shim.ts @@ -7,7 +7,7 @@ import Hapi from 'hapi'; import { Legacy } from 'kibana'; import { LegacySpacesPlugin as SpacesPluginStartContract } from '../../spaces'; -import { TaskManager } from '../../task_manager'; +import { TaskManager } from '../../task_manager/server'; import { XPackMainPlugin } from '../../xpack_main/server/xpack_main'; import KbnServer from '../../../../../src/legacy/server/kbn_server'; import { diff --git a/x-pack/legacy/plugins/lens/server/usage/task.ts b/x-pack/legacy/plugins/lens/server/usage/task.ts index 64bc37ce909a2..9d0ec725800cd 100644 --- a/x-pack/legacy/plugins/lens/server/usage/task.ts +++ b/x-pack/legacy/plugins/lens/server/usage/task.ts @@ -16,7 +16,7 @@ import { } from 'elasticsearch'; import { ESSearchResponse } from '../../../apm/typings/elasticsearch'; import { XPackMainPlugin } from '../../../xpack_main/server/xpack_main'; -import { RunContext } from '../../../task_manager'; +import { RunContext } from '../../../task_manager/server'; import { getVisualizationCounts } from './visualization_counts'; // This task is responsible for running daily and aggregating all the Lens click event objects diff --git a/x-pack/legacy/plugins/oss_telemetry/server/lib/collectors/visualizations/get_usage_collector.ts b/x-pack/legacy/plugins/oss_telemetry/server/lib/collectors/visualizations/get_usage_collector.ts index 680cb97e0fda3..11dbddc00f830 100644 --- a/x-pack/legacy/plugins/oss_telemetry/server/lib/collectors/visualizations/get_usage_collector.ts +++ b/x-pack/legacy/plugins/oss_telemetry/server/lib/collectors/visualizations/get_usage_collector.ts @@ -5,7 +5,7 @@ */ import { get } from 'lodash'; -import { PluginSetupContract as TaskManagerPluginSetupContract } from '../../../../../task_manager/plugin'; +import { PluginSetupContract as TaskManagerPluginSetupContract } from '../../../../../task_manager/server/plugin'; import { PLUGIN_ID, VIS_TELEMETRY_TASK, VIS_USAGE_TYPE } from '../../../../constants'; async function isTaskManagerReady(taskManager: TaskManagerPluginSetupContract | undefined) { diff --git a/x-pack/legacy/plugins/oss_telemetry/server/lib/collectors/visualizations/register_usage_collector.ts b/x-pack/legacy/plugins/oss_telemetry/server/lib/collectors/visualizations/register_usage_collector.ts index 1a47f68adcc58..46b86091c9db1 100644 --- a/x-pack/legacy/plugins/oss_telemetry/server/lib/collectors/visualizations/register_usage_collector.ts +++ b/x-pack/legacy/plugins/oss_telemetry/server/lib/collectors/visualizations/register_usage_collector.ts @@ -5,7 +5,7 @@ */ import { UsageCollectionSetup } from 'src/plugins/usage_collection/server'; -import { PluginSetupContract as TaskManagerPluginSetupContract } from '../../../../../task_manager/plugin'; +import { PluginSetupContract as TaskManagerPluginSetupContract } from '../../../../../task_manager/server/plugin'; import { getUsageCollector } from './get_usage_collector'; export function registerVisualizationsCollector( diff --git a/x-pack/legacy/plugins/oss_telemetry/server/lib/tasks/index.ts b/x-pack/legacy/plugins/oss_telemetry/server/lib/tasks/index.ts index cb6b4eab09741..c9714306d73c5 100644 --- a/x-pack/legacy/plugins/oss_telemetry/server/lib/tasks/index.ts +++ b/x-pack/legacy/plugins/oss_telemetry/server/lib/tasks/index.ts @@ -5,12 +5,12 @@ */ import { CoreSetup, Logger } from 'kibana/server'; -import { PluginSetupContract as TaskManagerPluginSetupContract } from '../../../../task_manager/plugin'; +import { PluginSetupContract as TaskManagerPluginSetupContract } from '../../../../task_manager/server/plugin'; import { PLUGIN_ID, VIS_TELEMETRY_TASK } from '../../../constants'; import { visualizationsTaskRunner } from './visualizations/task_runner'; import KbnServer from '../../../../../../../src/legacy/server/kbn_server'; import { LegacyConfig } from '../../plugin'; -import { TaskInstance } from '../../../../task_manager'; +import { TaskInstance } from '../../../../task_manager/server'; export function registerTasks({ taskManager, diff --git a/x-pack/legacy/plugins/oss_telemetry/server/lib/tasks/visualizations/task_runner.test.ts b/x-pack/legacy/plugins/oss_telemetry/server/lib/tasks/visualizations/task_runner.test.ts index 0663a5bd330ca..af3eed2496f5d 100644 --- a/x-pack/legacy/plugins/oss_telemetry/server/lib/tasks/visualizations/task_runner.test.ts +++ b/x-pack/legacy/plugins/oss_telemetry/server/lib/tasks/visualizations/task_runner.test.ts @@ -12,7 +12,7 @@ import { getMockTaskInstance, } from '../../../../test_utils'; import { visualizationsTaskRunner } from './task_runner'; -import { TaskInstance } from '../../../../../task_manager'; +import { TaskInstance } from '../../../../../task_manager/server'; describe('visualizationsTaskRunner', () => { let mockTaskInstance: TaskInstance; diff --git a/x-pack/legacy/plugins/oss_telemetry/server/lib/tasks/visualizations/task_runner.ts b/x-pack/legacy/plugins/oss_telemetry/server/lib/tasks/visualizations/task_runner.ts index 9d8f76f6a10dc..8fb2da5627ee8 100644 --- a/x-pack/legacy/plugins/oss_telemetry/server/lib/tasks/visualizations/task_runner.ts +++ b/x-pack/legacy/plugins/oss_telemetry/server/lib/tasks/visualizations/task_runner.ts @@ -8,7 +8,7 @@ import _, { countBy, groupBy, mapValues } from 'lodash'; import { APICaller, CoreSetup } from 'kibana/server'; import { getNextMidnight } from '../../get_next_midnight'; import { VisState } from '../../../../../../../../src/legacy/core_plugins/visualizations/public'; -import { TaskInstance } from '../../../../../task_manager'; +import { TaskInstance } from '../../../../../task_manager/server'; import { ESSearchHit } from '../../../../../apm/typings/elasticsearch'; import { LegacyConfig } from '../../../plugin'; diff --git a/x-pack/legacy/plugins/oss_telemetry/server/plugin.ts b/x-pack/legacy/plugins/oss_telemetry/server/plugin.ts index f661311fc24b8..209c73eb0eb62 100644 --- a/x-pack/legacy/plugins/oss_telemetry/server/plugin.ts +++ b/x-pack/legacy/plugins/oss_telemetry/server/plugin.ts @@ -5,7 +5,7 @@ */ import { CoreSetup, Logger, Plugin, PluginInitializerContext } from 'kibana/server'; -import { PluginSetupContract as TaskManagerPluginSetupContract } from '../../task_manager/plugin'; +import { PluginSetupContract as TaskManagerPluginSetupContract } from '../../task_manager/server/plugin'; import { registerCollectors } from './lib/collectors'; import { registerTasks, scheduleTasks } from './lib/tasks'; import KbnServer from '../../../../../src/legacy/server/kbn_server'; diff --git a/x-pack/legacy/plugins/oss_telemetry/test_utils/index.ts b/x-pack/legacy/plugins/oss_telemetry/test_utils/index.ts index 04e248d28b577..c6046eb648bf4 100644 --- a/x-pack/legacy/plugins/oss_telemetry/test_utils/index.ts +++ b/x-pack/legacy/plugins/oss_telemetry/test_utils/index.ts @@ -6,8 +6,8 @@ import { APICaller, CoreSetup } from 'kibana/server'; -import { TaskInstance } from '../../task_manager'; -import { PluginSetupContract as TaskManagerPluginSetupContract } from '../../task_manager/plugin'; +import { TaskInstance } from '../../task_manager/server'; +import { PluginSetupContract as TaskManagerPluginSetupContract } from '../../task_manager/server/plugin'; export const getMockTaskInstance = (): TaskInstance => ({ state: { runs: 0, stats: {} }, diff --git a/x-pack/legacy/plugins/task_manager/index.ts b/x-pack/legacy/plugins/task_manager/index.ts index 6f2bc3704bb67..276d1ea3accea 100644 --- a/x-pack/legacy/plugins/task_manager/index.ts +++ b/x-pack/legacy/plugins/task_manager/index.ts @@ -4,97 +4,4 @@ * you may not use this file except in compliance with the Elastic License. */ -import { Root } from 'joi'; -import { Legacy } from 'kibana'; -import { Plugin, PluginSetupContract } from './plugin'; -import { SavedObjectsSerializer, SavedObjectsSchema } from '../../../../src/core/server'; -import mappings from './mappings.json'; -import { migrations } from './migrations'; - -export { PluginSetupContract as TaskManager }; -export { - TaskInstance, - ConcreteTaskInstance, - TaskRunCreatorFunction, - TaskStatus, - RunContext, -} from './task'; - -export function taskManager(kibana: any) { - return new kibana.Plugin({ - id: 'task_manager', - require: ['kibana', 'elasticsearch', 'xpack_main'], - configPrefix: 'xpack.task_manager', - config(Joi: Root) { - return Joi.object({ - enabled: Joi.boolean().default(true), - max_attempts: Joi.number() - .description( - 'The maximum number of times a task will be attempted before being abandoned as failed' - ) - .min(1) - .default(3), - poll_interval: Joi.number() - .description('How often, in milliseconds, the task manager will look for more work.') - .min(100) - .default(3000), - request_capacity: Joi.number() - .description('How many requests can Task Manager buffer before it rejects new requests.') - .min(1) - // a nice round contrived number, feel free to change as we learn how it behaves - .default(1000), - index: Joi.string() - .description('The name of the index used to store task information.') - .default('.kibana_task_manager') - .invalid(['.tasks']), - max_workers: Joi.number() - .description( - 'The maximum number of tasks that this Kibana instance will run simultaneously.' - ) - .min(1) // disable the task manager rather than trying to specify it with 0 workers - .default(10), - }).default(); - }, - init(server: Legacy.Server) { - const plugin = new Plugin({ - logger: { - get: () => ({ - info: (message: string) => server.log(['info', 'task_manager'], message), - debug: (message: string) => server.log(['debug', 'task_manager'], message), - warn: (message: string) => server.log(['warn', 'task_manager'], message), - error: (message: string) => server.log(['error', 'task_manager'], message), - }), - }, - }); - const schema = new SavedObjectsSchema(this.kbnServer.uiExports.savedObjectSchemas); - const serializer = new SavedObjectsSerializer(schema); - const setupContract = plugin.setup( - {}, - { - serializer, - config: server.config(), - elasticsearch: server.plugins.elasticsearch, - savedObjects: server.savedObjects, - } - ); - this.kbnServer.afterPluginsInit(() => { - plugin.start(); - }); - server.expose(setupContract); - }, - uiExports: { - mappings, - migrations, - savedObjectSchemas: { - task: { - hidden: true, - isNamespaceAgnostic: true, - convertToAliasScript: `ctx._id = ctx._source.type + ':' + ctx._id`, - indexPattern(config: any) { - return config.get('xpack.task_manager.index'); - }, - }, - }, - }, - }); -} +export * from './server/'; diff --git a/x-pack/legacy/plugins/task_manager/README.md b/x-pack/legacy/plugins/task_manager/server/README.md similarity index 100% rename from x-pack/legacy/plugins/task_manager/README.md rename to x-pack/legacy/plugins/task_manager/server/README.md diff --git a/x-pack/legacy/plugins/task_manager/server/index.ts b/x-pack/legacy/plugins/task_manager/server/index.ts new file mode 100644 index 0000000000000..67b85af324f3d --- /dev/null +++ b/x-pack/legacy/plugins/task_manager/server/index.ts @@ -0,0 +1,100 @@ +/* + * 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 { Root } from 'joi'; +import { Legacy } from 'kibana'; +import { Plugin, PluginSetupContract } from './plugin'; +import { SavedObjectsSerializer, SavedObjectsSchema } from '../../../../../src/core/server'; +import mappings from './mappings.json'; +import { migrations } from './migrations'; + +export { PluginSetupContract as TaskManager }; +export { + TaskInstance, + ConcreteTaskInstance, + TaskRunCreatorFunction, + TaskStatus, + RunContext, +} from './task'; + +export function taskManager(kibana: any) { + return new kibana.Plugin({ + id: 'task_manager', + require: ['kibana', 'elasticsearch', 'xpack_main'], + configPrefix: 'xpack.task_manager', + config(Joi: Root) { + return Joi.object({ + enabled: Joi.boolean().default(true), + max_attempts: Joi.number() + .description( + 'The maximum number of times a task will be attempted before being abandoned as failed' + ) + .min(1) + .default(3), + poll_interval: Joi.number() + .description('How often, in milliseconds, the task manager will look for more work.') + .min(100) + .default(3000), + request_capacity: Joi.number() + .description('How many requests can Task Manager buffer before it rejects new requests.') + .min(1) + // a nice round contrived number, feel free to change as we learn how it behaves + .default(1000), + index: Joi.string() + .description('The name of the index used to store task information.') + .default('.kibana_task_manager') + .invalid(['.tasks']), + max_workers: Joi.number() + .description( + 'The maximum number of tasks that this Kibana instance will run simultaneously.' + ) + .min(1) // disable the task manager rather than trying to specify it with 0 workers + .default(10), + }).default(); + }, + init(server: Legacy.Server) { + const plugin = new Plugin({ + logger: { + get: () => ({ + info: (message: string) => server.log(['info', 'task_manager'], message), + debug: (message: string) => server.log(['debug', 'task_manager'], message), + warn: (message: string) => server.log(['warn', 'task_manager'], message), + error: (message: string) => server.log(['error', 'task_manager'], message), + }), + }, + }); + const schema = new SavedObjectsSchema(this.kbnServer.uiExports.savedObjectSchemas); + const serializer = new SavedObjectsSerializer(schema); + const setupContract = plugin.setup( + {}, + { + serializer, + config: server.config(), + elasticsearch: server.plugins.elasticsearch, + savedObjects: server.savedObjects, + } + ); + this.kbnServer.afterPluginsInit(() => { + plugin.start(); + }); + server.expose(setupContract); + }, + uiExports: { + mappings, + migrations, + savedObjectSchemas: { + task: { + hidden: true, + isNamespaceAgnostic: true, + convertToAliasScript: `ctx._id = ctx._source.type + ':' + ctx._id`, + indexPattern(config: any) { + return config.get('xpack.task_manager.index'); + }, + }, + }, + }, + }); +} diff --git a/x-pack/legacy/plugins/task_manager/lib/correct_deprecated_fields.test.ts b/x-pack/legacy/plugins/task_manager/server/lib/correct_deprecated_fields.test.ts similarity index 100% rename from x-pack/legacy/plugins/task_manager/lib/correct_deprecated_fields.test.ts rename to x-pack/legacy/plugins/task_manager/server/lib/correct_deprecated_fields.test.ts diff --git a/x-pack/legacy/plugins/task_manager/lib/correct_deprecated_fields.ts b/x-pack/legacy/plugins/task_manager/server/lib/correct_deprecated_fields.ts similarity index 100% rename from x-pack/legacy/plugins/task_manager/lib/correct_deprecated_fields.ts rename to x-pack/legacy/plugins/task_manager/server/lib/correct_deprecated_fields.ts diff --git a/x-pack/legacy/plugins/task_manager/lib/fill_pool.test.ts b/x-pack/legacy/plugins/task_manager/server/lib/fill_pool.test.ts similarity index 100% rename from x-pack/legacy/plugins/task_manager/lib/fill_pool.test.ts rename to x-pack/legacy/plugins/task_manager/server/lib/fill_pool.test.ts diff --git a/x-pack/legacy/plugins/task_manager/lib/fill_pool.ts b/x-pack/legacy/plugins/task_manager/server/lib/fill_pool.ts similarity index 100% rename from x-pack/legacy/plugins/task_manager/lib/fill_pool.ts rename to x-pack/legacy/plugins/task_manager/server/lib/fill_pool.ts diff --git a/x-pack/legacy/plugins/task_manager/lib/get_template_version.test.ts b/x-pack/legacy/plugins/task_manager/server/lib/get_template_version.test.ts similarity index 100% rename from x-pack/legacy/plugins/task_manager/lib/get_template_version.test.ts rename to x-pack/legacy/plugins/task_manager/server/lib/get_template_version.test.ts diff --git a/x-pack/legacy/plugins/task_manager/lib/get_template_version.ts b/x-pack/legacy/plugins/task_manager/server/lib/get_template_version.ts similarity index 100% rename from x-pack/legacy/plugins/task_manager/lib/get_template_version.ts rename to x-pack/legacy/plugins/task_manager/server/lib/get_template_version.ts diff --git a/x-pack/legacy/plugins/task_manager/lib/identify_es_error.test.ts b/x-pack/legacy/plugins/task_manager/server/lib/identify_es_error.test.ts similarity index 100% rename from x-pack/legacy/plugins/task_manager/lib/identify_es_error.test.ts rename to x-pack/legacy/plugins/task_manager/server/lib/identify_es_error.test.ts diff --git a/x-pack/legacy/plugins/task_manager/lib/identify_es_error.ts b/x-pack/legacy/plugins/task_manager/server/lib/identify_es_error.ts similarity index 100% rename from x-pack/legacy/plugins/task_manager/lib/identify_es_error.ts rename to x-pack/legacy/plugins/task_manager/server/lib/identify_es_error.ts diff --git a/x-pack/legacy/plugins/task_manager/lib/intervals.test.ts b/x-pack/legacy/plugins/task_manager/server/lib/intervals.test.ts similarity index 100% rename from x-pack/legacy/plugins/task_manager/lib/intervals.test.ts rename to x-pack/legacy/plugins/task_manager/server/lib/intervals.test.ts diff --git a/x-pack/legacy/plugins/task_manager/lib/intervals.ts b/x-pack/legacy/plugins/task_manager/server/lib/intervals.ts similarity index 100% rename from x-pack/legacy/plugins/task_manager/lib/intervals.ts rename to x-pack/legacy/plugins/task_manager/server/lib/intervals.ts diff --git a/x-pack/legacy/plugins/task_manager/lib/middleware.test.ts b/x-pack/legacy/plugins/task_manager/server/lib/middleware.test.ts similarity index 100% rename from x-pack/legacy/plugins/task_manager/lib/middleware.test.ts rename to x-pack/legacy/plugins/task_manager/server/lib/middleware.test.ts diff --git a/x-pack/legacy/plugins/task_manager/lib/middleware.ts b/x-pack/legacy/plugins/task_manager/server/lib/middleware.ts similarity index 100% rename from x-pack/legacy/plugins/task_manager/lib/middleware.ts rename to x-pack/legacy/plugins/task_manager/server/lib/middleware.ts diff --git a/x-pack/legacy/plugins/task_manager/lib/pull_from_set.test.ts b/x-pack/legacy/plugins/task_manager/server/lib/pull_from_set.test.ts similarity index 100% rename from x-pack/legacy/plugins/task_manager/lib/pull_from_set.test.ts rename to x-pack/legacy/plugins/task_manager/server/lib/pull_from_set.test.ts diff --git a/x-pack/legacy/plugins/task_manager/lib/pull_from_set.ts b/x-pack/legacy/plugins/task_manager/server/lib/pull_from_set.ts similarity index 100% rename from x-pack/legacy/plugins/task_manager/lib/pull_from_set.ts rename to x-pack/legacy/plugins/task_manager/server/lib/pull_from_set.ts diff --git a/x-pack/legacy/plugins/task_manager/lib/result_type.ts b/x-pack/legacy/plugins/task_manager/server/lib/result_type.ts similarity index 100% rename from x-pack/legacy/plugins/task_manager/lib/result_type.ts rename to x-pack/legacy/plugins/task_manager/server/lib/result_type.ts diff --git a/x-pack/legacy/plugins/task_manager/lib/sanitize_task_definitions.test.ts b/x-pack/legacy/plugins/task_manager/server/lib/sanitize_task_definitions.test.ts similarity index 100% rename from x-pack/legacy/plugins/task_manager/lib/sanitize_task_definitions.test.ts rename to x-pack/legacy/plugins/task_manager/server/lib/sanitize_task_definitions.test.ts diff --git a/x-pack/legacy/plugins/task_manager/lib/sanitize_task_definitions.ts b/x-pack/legacy/plugins/task_manager/server/lib/sanitize_task_definitions.ts similarity index 100% rename from x-pack/legacy/plugins/task_manager/lib/sanitize_task_definitions.ts rename to x-pack/legacy/plugins/task_manager/server/lib/sanitize_task_definitions.ts diff --git a/x-pack/legacy/plugins/task_manager/mappings.json b/x-pack/legacy/plugins/task_manager/server/mappings.json similarity index 100% rename from x-pack/legacy/plugins/task_manager/mappings.json rename to x-pack/legacy/plugins/task_manager/server/mappings.json diff --git a/x-pack/legacy/plugins/task_manager/migrations.ts b/x-pack/legacy/plugins/task_manager/server/migrations.ts similarity index 73% rename from x-pack/legacy/plugins/task_manager/migrations.ts rename to x-pack/legacy/plugins/task_manager/server/migrations.ts index 2853be0c4d5b2..7dce763ddf309 100644 --- a/x-pack/legacy/plugins/task_manager/migrations.ts +++ b/x-pack/legacy/plugins/task_manager/server/migrations.ts @@ -3,11 +3,7 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ - -// Task manager uses an unconventional directory structure so the linter marks this as a violation, server files should -// be moved under task_manager/server/ -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { SavedObject } from 'src/core/server'; +import { SavedObject } from '../../../../../src/core/server'; export const migrations = { task: { diff --git a/x-pack/legacy/plugins/task_manager/plugin.test.ts b/x-pack/legacy/plugins/task_manager/server/plugin.test.ts similarity index 100% rename from x-pack/legacy/plugins/task_manager/plugin.test.ts rename to x-pack/legacy/plugins/task_manager/server/plugin.test.ts diff --git a/x-pack/legacy/plugins/task_manager/plugin.ts b/x-pack/legacy/plugins/task_manager/server/plugin.ts similarity index 100% rename from x-pack/legacy/plugins/task_manager/plugin.ts rename to x-pack/legacy/plugins/task_manager/server/plugin.ts diff --git a/x-pack/legacy/plugins/task_manager/queries/mark_available_tasks_as_claimed.test.ts b/x-pack/legacy/plugins/task_manager/server/queries/mark_available_tasks_as_claimed.test.ts similarity index 100% rename from x-pack/legacy/plugins/task_manager/queries/mark_available_tasks_as_claimed.test.ts rename to x-pack/legacy/plugins/task_manager/server/queries/mark_available_tasks_as_claimed.test.ts diff --git a/x-pack/legacy/plugins/task_manager/queries/mark_available_tasks_as_claimed.ts b/x-pack/legacy/plugins/task_manager/server/queries/mark_available_tasks_as_claimed.ts similarity index 100% rename from x-pack/legacy/plugins/task_manager/queries/mark_available_tasks_as_claimed.ts rename to x-pack/legacy/plugins/task_manager/server/queries/mark_available_tasks_as_claimed.ts diff --git a/x-pack/legacy/plugins/task_manager/queries/query_clauses.ts b/x-pack/legacy/plugins/task_manager/server/queries/query_clauses.ts similarity index 100% rename from x-pack/legacy/plugins/task_manager/queries/query_clauses.ts rename to x-pack/legacy/plugins/task_manager/server/queries/query_clauses.ts diff --git a/x-pack/legacy/plugins/task_manager/task.ts b/x-pack/legacy/plugins/task_manager/server/task.ts similarity index 100% rename from x-pack/legacy/plugins/task_manager/task.ts rename to x-pack/legacy/plugins/task_manager/server/task.ts diff --git a/x-pack/legacy/plugins/task_manager/task_events.ts b/x-pack/legacy/plugins/task_manager/server/task_events.ts similarity index 100% rename from x-pack/legacy/plugins/task_manager/task_events.ts rename to x-pack/legacy/plugins/task_manager/server/task_events.ts diff --git a/x-pack/legacy/plugins/task_manager/task_manager.mock.ts b/x-pack/legacy/plugins/task_manager/server/task_manager.mock.ts similarity index 100% rename from x-pack/legacy/plugins/task_manager/task_manager.mock.ts rename to x-pack/legacy/plugins/task_manager/server/task_manager.mock.ts diff --git a/x-pack/legacy/plugins/task_manager/task_manager.test.ts b/x-pack/legacy/plugins/task_manager/server/task_manager.test.ts similarity index 97% rename from x-pack/legacy/plugins/task_manager/task_manager.test.ts rename to x-pack/legacy/plugins/task_manager/server/task_manager.test.ts index e70ee108f275c..51c3e5b81d764 100644 --- a/x-pack/legacy/plugins/task_manager/task_manager.test.ts +++ b/x-pack/legacy/plugins/task_manager/server/task_manager.test.ts @@ -20,12 +20,8 @@ import { awaitTaskRunResult, TaskLifecycleEvent, } from './task_manager'; -// Task manager uses an unconventional directory structure so the linter marks this as a violation, server files should -// be moved under task_manager/server/ -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { savedObjectsClientMock } from 'src/core/server/mocks'; -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { SavedObjectsSerializer, SavedObjectsSchema } from 'src/core/server'; +import { savedObjectsClientMock } from '../../../../../src/core/server/mocks'; +import { SavedObjectsSerializer, SavedObjectsSchema } from '../../../../../src/core/server'; import { mockLogger } from './test_utils'; import { asErr, asOk } from './lib/result_type'; import { ConcreteTaskInstance, TaskLifecycleResult, TaskStatus } from './task'; diff --git a/x-pack/legacy/plugins/task_manager/task_manager.ts b/x-pack/legacy/plugins/task_manager/server/task_manager.ts similarity index 98% rename from x-pack/legacy/plugins/task_manager/task_manager.ts rename to x-pack/legacy/plugins/task_manager/server/task_manager.ts index b7abeb248d143..6c9191ffe3d0e 100644 --- a/x-pack/legacy/plugins/task_manager/task_manager.ts +++ b/x-pack/legacy/plugins/task_manager/server/task_manager.ts @@ -7,13 +7,10 @@ import { Subject, Observable, Subscription } from 'rxjs'; import { filter } from 'rxjs/operators'; import { performance } from 'perf_hooks'; -// Task manager uses an unconventional directory structure so the linter marks this as a violation, server files should -// be moved under task_manager/server/ -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { SavedObjectsClientContract, SavedObjectsSerializer } from 'src/core/server'; import { pipe } from 'fp-ts/lib/pipeable'; import { Option, none, some, map as mapOptional } from 'fp-ts/lib/Option'; +import { SavedObjectsClientContract, SavedObjectsSerializer } from '../../../../../src/core/server'; import { Result, asErr, either, map, mapErr, promiseResult } from './lib/result_type'; import { Logger } from './types'; diff --git a/x-pack/legacy/plugins/task_manager/task_poller.test.ts b/x-pack/legacy/plugins/task_manager/server/task_poller.test.ts similarity index 100% rename from x-pack/legacy/plugins/task_manager/task_poller.test.ts rename to x-pack/legacy/plugins/task_manager/server/task_poller.test.ts diff --git a/x-pack/legacy/plugins/task_manager/task_poller.ts b/x-pack/legacy/plugins/task_manager/server/task_poller.ts similarity index 100% rename from x-pack/legacy/plugins/task_manager/task_poller.ts rename to x-pack/legacy/plugins/task_manager/server/task_poller.ts diff --git a/x-pack/legacy/plugins/task_manager/task_pool.test.ts b/x-pack/legacy/plugins/task_manager/server/task_pool.test.ts similarity index 100% rename from x-pack/legacy/plugins/task_manager/task_pool.test.ts rename to x-pack/legacy/plugins/task_manager/server/task_pool.test.ts diff --git a/x-pack/legacy/plugins/task_manager/task_pool.ts b/x-pack/legacy/plugins/task_manager/server/task_pool.ts similarity index 100% rename from x-pack/legacy/plugins/task_manager/task_pool.ts rename to x-pack/legacy/plugins/task_manager/server/task_pool.ts diff --git a/x-pack/legacy/plugins/task_manager/task_runner.test.ts b/x-pack/legacy/plugins/task_manager/server/task_runner.test.ts similarity index 98% rename from x-pack/legacy/plugins/task_manager/task_runner.test.ts rename to x-pack/legacy/plugins/task_manager/server/task_runner.test.ts index f3f9b9a88c68c..3f7877aa4c20f 100644 --- a/x-pack/legacy/plugins/task_manager/task_runner.test.ts +++ b/x-pack/legacy/plugins/task_manager/server/task_runner.test.ts @@ -12,10 +12,7 @@ import { TaskEvent, asTaskRunEvent, asTaskMarkRunningEvent } from './task_events import { ConcreteTaskInstance, TaskStatus } from './task'; import { TaskManagerRunner } from './task_runner'; import { mockLogger } from './test_utils'; -// Task manager uses an unconventional directory structure so the linter marks this as a violation, server files should -// be moved under task_manager/server/ -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { SavedObjectsErrorHelpers } from '../../../../src/core/server'; +import { SavedObjectsErrorHelpers } from '../../../../../src/core/server'; let fakeTimer: sinon.SinonFakeTimers; diff --git a/x-pack/legacy/plugins/task_manager/task_runner.ts b/x-pack/legacy/plugins/task_manager/server/task_runner.ts similarity index 100% rename from x-pack/legacy/plugins/task_manager/task_runner.ts rename to x-pack/legacy/plugins/task_manager/server/task_runner.ts diff --git a/x-pack/legacy/plugins/task_manager/task_store.test.ts b/x-pack/legacy/plugins/task_manager/server/task_store.test.ts similarity index 98% rename from x-pack/legacy/plugins/task_manager/task_store.test.ts rename to x-pack/legacy/plugins/task_manager/server/task_store.test.ts index bbce3143e8011..c7a0a1a020721 100644 --- a/x-pack/legacy/plugins/task_manager/task_store.test.ts +++ b/x-pack/legacy/plugins/task_manager/server/task_store.test.ts @@ -17,14 +17,13 @@ import { TaskLifecycleResult, } from './task'; import { FetchOpts, StoreOpts, OwnershipClaimingOpts, TaskStore } from './task_store'; -// Task manager uses an unconventional directory structure so the linter marks this as a violation, server files should -// be moved under task_manager/server/ -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { savedObjectsClientMock } from 'src/core/server/mocks'; -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { SavedObjectsSerializer, SavedObjectsSchema, SavedObjectAttributes } from 'src/core/server'; -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { SavedObjectsErrorHelpers } from '../../../../src/core/server/saved_objects/service/lib/errors'; +import { savedObjectsClientMock } from '../../../../../src/core/server/mocks'; +import { + SavedObjectsSerializer, + SavedObjectsSchema, + SavedObjectAttributes, +} from '../../../../../src/core/server'; +import { SavedObjectsErrorHelpers } from '../../../../../src/core/server/saved_objects/service/lib/errors'; import { asTaskClaimEvent, TaskEvent } from './task_events'; import { asOk, asErr } from './lib/result_type'; diff --git a/x-pack/legacy/plugins/task_manager/task_store.ts b/x-pack/legacy/plugins/task_manager/server/task_store.ts similarity index 98% rename from x-pack/legacy/plugins/task_manager/task_store.ts rename to x-pack/legacy/plugins/task_manager/server/task_store.ts index 096a8774c8488..e8fc0ccb90936 100644 --- a/x-pack/legacy/plugins/task_manager/task_store.ts +++ b/x-pack/legacy/plugins/task_manager/server/task_store.ts @@ -16,10 +16,7 @@ import { SavedObjectAttributes, SavedObjectsSerializer, SavedObjectsRawDoc, - // Task manager uses an unconventional directory structure so the linter marks this as a violation, server files should - // be moved under task_manager/server/ - // eslint-disable-next-line @kbn/eslint/no-restricted-paths -} from 'src/core/server'; +} from '../../../../../src/core/server'; import { asOk, asErr } from './lib/result_type'; diff --git a/x-pack/legacy/plugins/task_manager/test_utils/index.ts b/x-pack/legacy/plugins/task_manager/server/test_utils/index.ts similarity index 100% rename from x-pack/legacy/plugins/task_manager/test_utils/index.ts rename to x-pack/legacy/plugins/task_manager/server/test_utils/index.ts diff --git a/x-pack/legacy/plugins/task_manager/types.ts b/x-pack/legacy/plugins/task_manager/server/types.ts similarity index 100% rename from x-pack/legacy/plugins/task_manager/types.ts rename to x-pack/legacy/plugins/task_manager/server/types.ts diff --git a/x-pack/test/plugin_api_integration/test_suites/task_manager/task_manager_integration.js b/x-pack/test/plugin_api_integration/test_suites/task_manager/task_manager_integration.js index 486a93aba76df..ff06bee83d51d 100644 --- a/x-pack/test/plugin_api_integration/test_suites/task_manager/task_manager_integration.js +++ b/x-pack/test/plugin_api_integration/test_suites/task_manager/task_manager_integration.js @@ -11,7 +11,7 @@ import supertestAsPromised from 'supertest-as-promised'; const { task: { properties: taskManagerIndexMapping }, -} = require('../../../../legacy/plugins/task_manager/mappings.json'); +} = require('../../../../legacy/plugins/task_manager/server/mappings.json'); export default function({ getService }) { const es = getService('legacyEs'); diff --git a/x-pack/test/typings/hapi.d.ts b/x-pack/test/typings/hapi.d.ts index fa2712e69a5b0..0400c1b7d8f23 100644 --- a/x-pack/test/typings/hapi.d.ts +++ b/x-pack/test/typings/hapi.d.ts @@ -9,7 +9,7 @@ import 'hapi'; import { XPackMainPlugin } from '../../legacy/plugins/xpack_main/server/xpack_main'; import { SecurityPlugin } from '../../legacy/plugins/security'; import { ActionsPlugin, ActionsClient } from '../../legacy/plugins/actions'; -import { TaskManager } from '../../legacy/plugins/task_manager'; +import { TaskManager } from '../../legacy/plugins/task_manager/server'; import { AlertingPlugin, AlertsClient } from '../../legacy/plugins/alerting'; declare module 'hapi' { diff --git a/x-pack/typings/hapi.d.ts b/x-pack/typings/hapi.d.ts index 569508caf3f20..cfc1a641550fc 100644 --- a/x-pack/typings/hapi.d.ts +++ b/x-pack/typings/hapi.d.ts @@ -9,7 +9,7 @@ import 'hapi'; import { XPackMainPlugin } from '../legacy/plugins/xpack_main/server/xpack_main'; import { SecurityPlugin } from '../legacy/plugins/security'; import { ActionsPlugin, ActionsClient } from '../legacy/plugins/actions'; -import { TaskManager } from '../legacy/plugins/task_manager'; +import { TaskManager } from '../legacy/plugins/task_manager/server'; import { AlertingPlugin, AlertsClient } from '../legacy/plugins/alerting'; declare module 'hapi' { From 6942d0bbe6c451dd61dbbc5ecfff8aeabeb7b54c Mon Sep 17 00:00:00 2001 From: Alexey Antonov Date: Fri, 3 Jan 2020 15:57:46 +0300 Subject: [PATCH 2/2] =?UTF-8?q?Move=20index=20patterns:=20src/legacy/core?= =?UTF-8?q?=5Fplugins/data=20=F0=9F=91=89=20src/plugins/data=20(#53794)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Move index patterns: src/legacy/core_plugins/data 👉 src/plugins/data Closes: #43444 Make sure that all index pattern related imports use NP (and delete index_pattern folder from shim) * fix JEST tests * fix CI * fix PR comments Co-authored-by: Elastic Machine --- src/legacy/core_plugins/data/public/index.ts | 3 -- .../data/public/index_patterns/index.ts | 33 --------------- .../public/views/json_code_block.test.tsx | 2 +- .../public/views/table/table.test.tsx | 6 +-- .../np_ready/dashboard_app_controller.tsx | 9 ++++- .../__jest__/render.test.js | 6 --- .../__jest__/step_index_pattern.test.js | 5 --- .../step_index_pattern/step_index_pattern.js | 6 +-- src/legacy/ui/public/agg_types/agg_configs.ts | 2 +- .../agg_types/filter/agg_type_filters.test.ts | 2 +- .../agg_types/filter/agg_type_filters.ts | 2 +- .../ui/public/agg_types/param_types/field.ts | 2 +- .../param_types/filter/field_filters.test.ts | 2 +- .../param_types/filter/field_filters.ts | 2 +- .../public/index_patterns/__mocks__/index.ts | 25 ------------ src/legacy/ui/public/index_patterns/index.ts | 40 ------------------- .../ui/public/indices/constants/index.js | 6 +-- .../ui/public/registry/doc_views_types.ts | 2 +- .../saved_objects/helpers/apply_es_resp.ts | 2 +- .../editors/config/editor_config_providers.ts | 2 +- .../editors/default/components/agg.test.tsx | 2 +- .../default/components/agg_param_props.ts | 2 +- .../default/components/agg_params.test.tsx | 2 +- .../editors/default/components/agg_params.tsx | 2 +- .../components/agg_params_helper.test.ts | 2 +- .../default/components/agg_params_helper.ts | 2 +- .../editors/default/components/agg_select.tsx | 2 +- .../editors/default/controls/field.test.tsx | 2 +- .../vis/editors/default/controls/field.tsx | 2 +- .../editors/default/controls/top_field.tsx | 2 +- .../default/controls/top_sort_field.tsx | 2 +- .../editors/default/vis_type_agg_filter.ts | 2 +- .../public/query/timefilter/timefilter.ts | 2 +- .../field_validators/index_pattern_field.ts | 11 ++--- .../auto_follow_pattern_add.test.js | 4 +- .../follower_index_add.test.js | 6 +-- .../components/auto_follow_pattern_form.js | 4 +- .../auto_follow_pattern_validators.js | 20 +++++----- .../public/components/search_bar.test.tsx | 3 +- .../graph/public/components/search_bar.tsx | 2 +- .../public/services/index_pattern_cache.ts | 2 +- .../services/persistence/deserialize.test.ts | 2 +- .../services/persistence/deserialize.ts | 2 +- .../state_management/datasource.sagas.ts | 2 +- .../state_management/datasource.test.ts | 2 +- .../graph/public/state_management/mocks.ts | 2 +- .../plugins/graph/public/types/app_state.ts | 2 +- .../public/elasticsearch_geo_utils.test.js | 6 +-- .../data_recognizer/data_recognizer.d.ts | 3 +- .../full_time_range_selector.test.tsx | 2 +- .../full_time_range_selector.tsx | 2 +- .../full_time_range_selector_service.ts | 2 +- .../kibana/__mocks__/index_pattern.ts | 2 +- .../create_analytics_button.test.tsx | 5 --- .../create_analytics_flyout.test.tsx | 5 --- .../create_analytics_form.test.tsx | 5 --- .../create_analytics_form.tsx | 12 +++--- .../use_create_analytics_form/reducer.test.ts | 4 -- .../use_create_analytics_form/reducer.ts | 10 ++--- .../use_create_analytics_form.test.tsx | 4 -- .../analytics_service/get_analytics.test.ts | 4 -- .../actions_panel/actions_panel.tsx | 4 +- .../components/search_panel/search_panel.tsx | 2 +- .../index_based/data_loader/data_loader.ts | 2 +- .../datavisualizer/index_based/page.tsx | 10 +++-- .../common/chart_loader/chart_loader.ts | 2 +- .../job_creator/advanced_job_creator.ts | 2 +- .../new_job/common/job_creator/job_creator.ts | 2 +- .../common/job_creator/job_creator_factory.ts | 2 +- .../job_creator/multi_metric_job_creator.ts | 2 +- .../job_creator/population_job_creator.ts | 2 +- .../job_creator/single_metric_job_creator.ts | 2 +- .../jobs/new_job/utils/new_job_utils.ts | 8 +++- .../services/field_format_service.ts | 2 +- .../new_job_capabilities._service.test.ts | 2 +- .../util/field_types_utils.test.ts | 11 +++-- .../application/util/field_types_utils.ts | 5 +-- .../job_create_logistics.test.js | 4 +- .../job_create/steps/step_logistics.js | 5 ++- .../steps_config/validate_index_pattern.js | 5 +-- .../transform/public/app/common/request.ts | 4 +- .../transform/public/app/lib/kibana/common.ts | 9 +++-- .../components/step_define/common.test.ts | 2 +- .../components/step_define/common.ts | 8 ++-- .../use_pivot_preview_data.test.tsx | 2 +- .../step_define/use_pivot_preview_data.ts | 8 ++-- 86 files changed, 145 insertions(+), 277 deletions(-) delete mode 100644 src/legacy/core_plugins/data/public/index_patterns/index.ts delete mode 100644 src/legacy/ui/public/index_patterns/__mocks__/index.ts delete mode 100644 src/legacy/ui/public/index_patterns/index.ts diff --git a/src/legacy/core_plugins/data/public/index.ts b/src/legacy/core_plugins/data/public/index.ts index 09881c00c63b6..4514d67ea5fcd 100644 --- a/src/legacy/core_plugins/data/public/index.ts +++ b/src/legacy/core_plugins/data/public/index.ts @@ -28,8 +28,6 @@ export function plugin() { /** @public types */ export { DataStart }; - -export { Field, FieldType, IFieldList, IndexPattern } from './index_patterns'; export { EsQuerySortValue, FetchOptions, ISearchSource, SortDirection } from './search/types'; export { SearchSourceFields } from './search/types'; export { @@ -41,5 +39,4 @@ export { /** @public static code */ export * from '../common'; export { FilterStateManager } from './filter/filter_manager'; -export { getFromSavedObject, getRoutes, flattenHitWrapper } from './index_patterns'; export { getRequestInspectorStats, getResponseInspectorStats } from './search'; diff --git a/src/legacy/core_plugins/data/public/index_patterns/index.ts b/src/legacy/core_plugins/data/public/index_patterns/index.ts deleted file mode 100644 index 96995c10e5469..0000000000000 --- a/src/legacy/core_plugins/data/public/index_patterns/index.ts +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import { IFieldType, indexPatterns } from '../../../../../plugins/data/public'; - -const getFromSavedObject = indexPatterns.getFromSavedObject; -const getRoutes = indexPatterns.getRoutes; -const flattenHitWrapper = indexPatterns.flattenHitWrapper; - -export { getFromSavedObject, getRoutes, flattenHitWrapper }; -export { IFieldType as FieldType }; -export { - Field, - IFieldList, - IndexPattern, - IndexPatternsContract, -} from '../../../../../plugins/data/public'; diff --git a/src/legacy/core_plugins/kbn_doc_views/public/views/json_code_block.test.tsx b/src/legacy/core_plugins/kbn_doc_views/public/views/json_code_block.test.tsx index 776971e57091d..ea11ea7b7df10 100644 --- a/src/legacy/core_plugins/kbn_doc_views/public/views/json_code_block.test.tsx +++ b/src/legacy/core_plugins/kbn_doc_views/public/views/json_code_block.test.tsx @@ -19,7 +19,7 @@ import React from 'react'; import { shallow } from 'enzyme'; import { JsonCodeBlock } from './json_code_block'; -import { IndexPattern } from 'ui/index_patterns'; +import { IndexPattern } from '../../../../../plugins/data/public'; it('returns the `JsonCodeEditor` component', () => { const props = { diff --git a/src/legacy/core_plugins/kbn_doc_views/public/views/table/table.test.tsx b/src/legacy/core_plugins/kbn_doc_views/public/views/table/table.test.tsx index 24efbc2d41f4f..91b98865a0207 100644 --- a/src/legacy/core_plugins/kbn_doc_views/public/views/table/table.test.tsx +++ b/src/legacy/core_plugins/kbn_doc_views/public/views/table/table.test.tsx @@ -18,12 +18,12 @@ */ import React from 'react'; import { mount } from 'enzyme'; -import { IndexPattern } from 'ui/index_patterns'; // @ts-ignore import { findTestSubject } from '@elastic/eui/lib/test'; -import { flattenHitWrapper } from '../../../../data/public/'; import { DocViewTable } from './table'; +import { IndexPattern, indexPatterns } from '../../../../../../plugins/data/public'; + jest.mock('ui/new_platform'); // @ts-ignore @@ -70,7 +70,7 @@ const indexPattern = { formatHit: jest.fn(hit => hit._source), } as IndexPattern; -indexPattern.flattenHit = flattenHitWrapper(indexPattern, indexPattern.metaFields); +indexPattern.flattenHit = indexPatterns.flattenHitWrapper(indexPattern, indexPattern.metaFields); describe('DocViewTable at Discover', () => { // At Discover's main view, all buttons are rendered diff --git a/src/legacy/core_plugins/kibana/public/dashboard/np_ready/dashboard_app_controller.tsx b/src/legacy/core_plugins/kibana/public/dashboard/np_ready/dashboard_app_controller.tsx index 5ba457b6c3362..08637174c8cec 100644 --- a/src/legacy/core_plugins/kibana/public/dashboard/np_ready/dashboard_app_controller.tsx +++ b/src/legacy/core_plugins/kibana/public/dashboard/np_ready/dashboard_app_controller.tsx @@ -39,8 +39,13 @@ import { unhashUrl, VISUALIZE_EMBEDDABLE_TYPE, } from '../legacy_imports'; -import { FilterStateManager, IndexPattern } from '../../../../data/public'; -import { Query, SavedQuery, IndexPatternsContract } from '../../../../../../plugins/data/public'; +import { FilterStateManager } from '../../../../data/public'; +import { + IndexPattern, + Query, + SavedQuery, + IndexPatternsContract, +} from '../../../../../../plugins/data/public'; import { DashboardContainer, diff --git a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/__jest__/render.test.js b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/__jest__/render.test.js index be4866f9dfdd4..375e80028f317 100644 --- a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/__jest__/render.test.js +++ b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/__jest__/render.test.js @@ -22,12 +22,6 @@ const unmountComponentAtNode = jest.fn(); jest.doMock('react-dom', () => ({ render, unmountComponentAtNode })); -// If we don't mock this, Jest fails with the error `TypeError: Cannot redefine property: prototype -// at Function.defineProperties`. -jest.mock('ui/index_patterns', () => ({ - INDEX_PATTERN_ILLEGAL_CHARACTERS: ['\\', '/', '?', '"', '<', '>', '|', ' '], -})); - jest.mock('ui/chrome', () => ({ getUiSettingsClient: () => ({ get: () => '', diff --git a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/__jest__/step_index_pattern.test.js b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/__jest__/step_index_pattern.test.js index 1797fc203ccd8..85e610bbbf993 100644 --- a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/__jest__/step_index_pattern.test.js +++ b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/__jest__/step_index_pattern.test.js @@ -32,11 +32,6 @@ const mockIndexPatternCreationType = { checkIndicesForErrors: () => false, getShowSystemIndices: () => false, }; -// If we don't mock this, Jest fails with the error `TypeError: Cannot redefine property: prototype -// at Function.defineProperties`. -jest.mock('ui/index_patterns', () => ({ - INDEX_PATTERN_ILLEGAL_CHARACTERS: ['\\', '/', '?', '"', '<', '>', '|', ' '], -})); jest.mock('ui/chrome', () => ({ getUiSettingsClient: () => ({ diff --git a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/step_index_pattern.js b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/step_index_pattern.js index 4764b516dffec..c990efaf43547 100644 --- a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/step_index_pattern.js +++ b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/step_index_pattern.js @@ -19,7 +19,7 @@ import React, { Component } from 'react'; import PropTypes from 'prop-types'; -import { INDEX_PATTERN_ILLEGAL_CHARACTERS as ILLEGAL_CHARACTERS } from 'ui/index_patterns'; +import { indexPatterns } from '../../../../../../../../../../plugins/data/public'; import { MAX_SEARCH_SIZE } from '../../constants'; import { getIndices, @@ -71,7 +71,7 @@ export class StepIndexPattern extends Component { indexPatternName: indexPatternCreationType.getIndexPatternName(), }; - this.ILLEGAL_CHARACTERS = [...ILLEGAL_CHARACTERS]; + this.ILLEGAL_CHARACTERS = [...indexPatterns.ILLEGAL_CHARACTERS]; this.lastQuery = null; } @@ -243,7 +243,7 @@ export class StepIndexPattern extends Component { if (!query || !query.length || query === '.' || query === '..') { // This is an error scenario but do not report an error containsErrors = true; - } else if (containsIllegalCharacters(query, ILLEGAL_CHARACTERS)) { + } else if (containsIllegalCharacters(query, indexPatterns.ILLEGAL_CHARACTERS)) { const errorMessage = i18n.translate( 'kbn.management.createIndexPattern.step.invalidCharactersErrorMessage', { diff --git a/src/legacy/ui/public/agg_types/agg_configs.ts b/src/legacy/ui/public/agg_types/agg_configs.ts index ece9c90d09b68..6e811afb1849d 100644 --- a/src/legacy/ui/public/agg_types/agg_configs.ts +++ b/src/legacy/ui/public/agg_types/agg_configs.ts @@ -31,7 +31,7 @@ import { TimeRange } from 'src/plugins/data/public'; import { Schema } from '../vis/editors/default/schemas'; import { AggConfig, AggConfigOptions } from './agg_config'; import { AggGroupNames } from '../vis/editors/default/agg_groups'; -import { IndexPattern } from '../../../core_plugins/data/public'; +import { IndexPattern } from '../../../../plugins/data/public'; import { ISearchSource, FetchOptions } from '../courier/types'; type Schemas = Record; diff --git a/src/legacy/ui/public/agg_types/filter/agg_type_filters.test.ts b/src/legacy/ui/public/agg_types/filter/agg_type_filters.test.ts index f470ebbc90b48..517cee23e6be1 100644 --- a/src/legacy/ui/public/agg_types/filter/agg_type_filters.test.ts +++ b/src/legacy/ui/public/agg_types/filter/agg_type_filters.test.ts @@ -17,7 +17,7 @@ * under the License. */ -import { IndexPattern } from 'ui/index_patterns'; +import { IndexPattern } from '../../../../../plugins/data/public'; import { AggTypeFilters } from './agg_type_filters'; import { AggType } from '..'; import { AggConfig } from '../../vis'; diff --git a/src/legacy/ui/public/agg_types/filter/agg_type_filters.ts b/src/legacy/ui/public/agg_types/filter/agg_type_filters.ts index 4d99575e4ae38..2388d458d4abb 100644 --- a/src/legacy/ui/public/agg_types/filter/agg_type_filters.ts +++ b/src/legacy/ui/public/agg_types/filter/agg_type_filters.ts @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -import { IndexPattern } from '../../index_patterns'; +import { IndexPattern } from '../../../../../plugins/data/public'; import { AggConfig } from '../../vis'; import { AggType } from '..'; diff --git a/src/legacy/ui/public/agg_types/param_types/field.ts b/src/legacy/ui/public/agg_types/param_types/field.ts index 4fda86bd1379f..0ca60267becec 100644 --- a/src/legacy/ui/public/agg_types/param_types/field.ts +++ b/src/legacy/ui/public/agg_types/param_types/field.ts @@ -25,7 +25,7 @@ import { FieldParamEditor } from '../../vis/editors/default/controls/field'; import { BaseParamType } from './base'; import { toastNotifications } from '../../notify'; import { propFilter } from '../filter'; -import { Field, IFieldList } from '../../index_patterns'; +import { Field, IFieldList } from '../../../../../plugins/data/public'; const filterByType = propFilter('type'); diff --git a/src/legacy/ui/public/agg_types/param_types/filter/field_filters.test.ts b/src/legacy/ui/public/agg_types/param_types/filter/field_filters.test.ts index e8d53754f6682..978b7edaa83ff 100644 --- a/src/legacy/ui/public/agg_types/param_types/filter/field_filters.test.ts +++ b/src/legacy/ui/public/agg_types/param_types/filter/field_filters.test.ts @@ -17,10 +17,10 @@ * under the License. */ -import { Field } from 'ui/index_patterns'; import { IndexedArray } from 'ui/indexed_array'; import { AggTypeFieldFilters } from './field_filters'; import { AggConfig } from 'ui/vis'; +import { Field } from '../../../../../../plugins/data/public'; describe('AggTypeFieldFilters', () => { let registry: AggTypeFieldFilters; diff --git a/src/legacy/ui/public/agg_types/param_types/filter/field_filters.ts b/src/legacy/ui/public/agg_types/param_types/filter/field_filters.ts index b3dbcf05681db..e5cb5226435ff 100644 --- a/src/legacy/ui/public/agg_types/param_types/filter/field_filters.ts +++ b/src/legacy/ui/public/agg_types/param_types/filter/field_filters.ts @@ -16,8 +16,8 @@ * specific language governing permissions and limitations * under the License. */ -import { Field } from 'ui/index_patterns'; import { AggConfig } from '../../../vis'; +import { Field } from '../../../../../../plugins/data/public'; type AggTypeFieldFilter = (field: Field, aggConfig: AggConfig) => boolean; diff --git a/src/legacy/ui/public/index_patterns/__mocks__/index.ts b/src/legacy/ui/public/index_patterns/__mocks__/index.ts deleted file mode 100644 index 0cb1cf897b166..0000000000000 --- a/src/legacy/ui/public/index_patterns/__mocks__/index.ts +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import { indexPatterns as npIndexPatterns } from '../../../../../plugins/data/public'; - -export const flattenHitWrapper = npIndexPatterns.flattenHitWrapper; - -// static code -export { getFromSavedObject, getRoutes } from '../../../../core_plugins/data/public'; diff --git a/src/legacy/ui/public/index_patterns/index.ts b/src/legacy/ui/public/index_patterns/index.ts deleted file mode 100644 index 47f6e697c54e9..0000000000000 --- a/src/legacy/ui/public/index_patterns/index.ts +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/** - * Nothing to see here! - * - * Index Patterns have moved to the data plugin, and are being re-exported - * from ui/index_patterns for backwards compatibility. - */ - -import { indexPatterns } from '../../../../plugins/data/public'; - -// static code -export const INDEX_PATTERN_ILLEGAL_CHARACTERS = indexPatterns.ILLEGAL_CHARACTERS; -export const INDEX_PATTERN_ILLEGAL_CHARACTERS_VISIBLE = indexPatterns.ILLEGAL_CHARACTERS_VISIBLE; -export const ILLEGAL_CHARACTERS = indexPatterns.ILLEGAL_CHARACTERS_KEY; -export const CONTAINS_SPACES = indexPatterns.CONTAINS_SPACES_KEY; -export const validateIndexPattern = indexPatterns.validate; -export const flattenHitWrapper = indexPatterns.flattenHitWrapper; -export const getFromSavedObject = indexPatterns.getFromSavedObject; -export const getRoutes = indexPatterns.getRoutes; - -// types -export { Field, FieldType, IFieldList, IndexPattern } from '../../../core_plugins/data/public'; diff --git a/src/legacy/ui/public/indices/constants/index.js b/src/legacy/ui/public/indices/constants/index.js index 87d36d1c6d14a..72ecc2e4c87de 100644 --- a/src/legacy/ui/public/indices/constants/index.js +++ b/src/legacy/ui/public/indices/constants/index.js @@ -17,11 +17,11 @@ * under the License. */ -import { INDEX_PATTERN_ILLEGAL_CHARACTERS_VISIBLE } from '../../index_patterns'; +import { indexPatterns } from '../../../../../plugins/data/public'; -export const INDEX_ILLEGAL_CHARACTERS_VISIBLE = [...INDEX_PATTERN_ILLEGAL_CHARACTERS_VISIBLE, '*']; +export const INDEX_ILLEGAL_CHARACTERS_VISIBLE = [...indexPatterns.ILLEGAL_CHARACTERS_VISIBLE, '*']; // Insert the comma into the middle, so it doesn't look as if it has grammatical meaning when // these characters are rendered in the UI. -const insertionIndex = Math.floor(INDEX_PATTERN_ILLEGAL_CHARACTERS_VISIBLE.length / 2); +const insertionIndex = Math.floor(indexPatterns.ILLEGAL_CHARACTERS_VISIBLE.length / 2); INDEX_ILLEGAL_CHARACTERS_VISIBLE.splice(insertionIndex, 0, ','); diff --git a/src/legacy/ui/public/registry/doc_views_types.ts b/src/legacy/ui/public/registry/doc_views_types.ts index f078f374b4579..eb2a5bdc4b3b7 100644 --- a/src/legacy/ui/public/registry/doc_views_types.ts +++ b/src/legacy/ui/public/registry/doc_views_types.ts @@ -16,9 +16,9 @@ * specific language governing permissions and limitations * under the License. */ -import { IndexPattern } from 'src/legacy/core_plugins/data/public'; import { ComponentType } from 'react'; import { IScope } from 'angular'; +import { IndexPattern } from '../../../../plugins/data/public'; export interface AngularDirective { controller: (scope: AngularScope) => void; diff --git a/src/legacy/ui/public/saved_objects/helpers/apply_es_resp.ts b/src/legacy/ui/public/saved_objects/helpers/apply_es_resp.ts index bec0a1d96ba92..ee49b7495f2af 100644 --- a/src/legacy/ui/public/saved_objects/helpers/apply_es_resp.ts +++ b/src/legacy/ui/public/saved_objects/helpers/apply_es_resp.ts @@ -20,7 +20,7 @@ import _ from 'lodash'; import { EsResponse, SavedObject, SavedObjectConfig } from 'ui/saved_objects/types'; import { parseSearchSource } from 'ui/saved_objects/helpers/parse_search_source'; import { expandShorthand, SavedObjectNotFound } from '../../../../../plugins/kibana_utils/public'; -import { IndexPattern } from '../../../../core_plugins/data/public'; +import { IndexPattern } from '../../../../../plugins/data/public'; /** * A given response of and ElasticSearch containing a plain saved object is applied to the given diff --git a/src/legacy/ui/public/vis/editors/config/editor_config_providers.ts b/src/legacy/ui/public/vis/editors/config/editor_config_providers.ts index 3dd911efc324c..31fc0d90be101 100644 --- a/src/legacy/ui/public/vis/editors/config/editor_config_providers.ts +++ b/src/legacy/ui/public/vis/editors/config/editor_config_providers.ts @@ -20,7 +20,7 @@ import { TimeIntervalParam } from 'ui/vis/editors/config/types'; import { AggConfig } from '../..'; import { AggType } from '../../../agg_types'; -import { IndexPattern } from '../../../index_patterns'; +import { IndexPattern } from '../../../../../../plugins/data/public'; import { leastCommonMultiple } from '../../../utils/math'; import { parseEsInterval } from '../../../../../core_plugins/data/public'; import { leastCommonInterval } from '../../lib/least_common_interval'; diff --git a/src/legacy/ui/public/vis/editors/default/components/agg.test.tsx b/src/legacy/ui/public/vis/editors/default/components/agg.test.tsx index 661ece5944fa3..c19f101fa2c32 100644 --- a/src/legacy/ui/public/vis/editors/default/components/agg.test.tsx +++ b/src/legacy/ui/public/vis/editors/default/components/agg.test.tsx @@ -24,8 +24,8 @@ import { AggGroupNames } from '../agg_groups'; import { DefaultEditorAgg, DefaultEditorAggProps } from './agg'; import { act } from 'react-dom/test-utils'; import { DefaultEditorAggParams } from './agg_params'; -import { IndexPattern } from 'ui/index_patterns'; import { AggType } from 'ui/agg_types'; +import { IndexPattern } from '../../../../../../../plugins/data/public'; jest.mock('./agg_params', () => ({ DefaultEditorAggParams: () => null, diff --git a/src/legacy/ui/public/vis/editors/default/components/agg_param_props.ts b/src/legacy/ui/public/vis/editors/default/components/agg_param_props.ts index aafba008f97c5..df77ea9e43eab 100644 --- a/src/legacy/ui/public/vis/editors/default/components/agg_param_props.ts +++ b/src/legacy/ui/public/vis/editors/default/components/agg_param_props.ts @@ -17,13 +17,13 @@ * under the License. */ -import { Field } from 'ui/index_patterns'; import { AggParam } from 'ui/agg_types'; import { AggConfig } from '../../../../agg_types/agg_config'; import { ComboBoxGroupedOptions } from '../utils'; import { EditorConfig } from '../../config/types'; import { VisState } from '../../..'; import { SubAggParamsProp } from './agg_params'; +import { Field } from '../../../../../../../plugins/data/public'; // NOTE: we cannot export the interface with export { InterfaceName } // as there is currently a bug on babel typescript transform plugin for it diff --git a/src/legacy/ui/public/vis/editors/default/components/agg_params.test.tsx b/src/legacy/ui/public/vis/editors/default/components/agg_params.test.tsx index 25e2db8ef1836..9f3f5bff3f56e 100644 --- a/src/legacy/ui/public/vis/editors/default/components/agg_params.test.tsx +++ b/src/legacy/ui/public/vis/editors/default/components/agg_params.test.tsx @@ -19,9 +19,9 @@ import React from 'react'; import { mount, shallow } from 'enzyme'; -import { IndexPattern } from 'ui/index_patterns'; import { AggConfig, VisState } from '../../..'; import { DefaultEditorAggParams, DefaultEditorAggParamsProps } from './agg_params'; +import { IndexPattern } from '../../../../../../../plugins/data/public'; const mockEditorConfig = { useNormalizedEsInterval: { hidden: false, fixedValue: false }, diff --git a/src/legacy/ui/public/vis/editors/default/components/agg_params.tsx b/src/legacy/ui/public/vis/editors/default/components/agg_params.tsx index 1515ed86db070..c62e2837908c7 100644 --- a/src/legacy/ui/public/vis/editors/default/components/agg_params.tsx +++ b/src/legacy/ui/public/vis/editors/default/components/agg_params.tsx @@ -23,8 +23,8 @@ import { i18n } from '@kbn/i18n'; import useUnmount from 'react-use/lib/useUnmount'; import { VisState } from 'ui/vis'; -import { IndexPattern } from 'ui/index_patterns'; import { aggTypes, AggType, AggParam, AggConfig } from 'ui/agg_types/'; +import { IndexPattern } from '../../../../../../../plugins/data/public'; import { DefaultEditorAggSelect } from './agg_select'; import { DefaultEditorAggParam } from './agg_param'; diff --git a/src/legacy/ui/public/vis/editors/default/components/agg_params_helper.test.ts b/src/legacy/ui/public/vis/editors/default/components/agg_params_helper.test.ts index eb6bef4887642..fb37dd5d94618 100644 --- a/src/legacy/ui/public/vis/editors/default/components/agg_params_helper.test.ts +++ b/src/legacy/ui/public/vis/editors/default/components/agg_params_helper.test.ts @@ -19,7 +19,6 @@ import { AggConfig, VisState } from '../../..'; import { AggType } from 'ui/agg_types'; -import { IndexPattern, Field } from 'ui/index_patterns'; import { IndexedArray } from 'ui/indexed_array'; import { getAggParamsToRender, @@ -28,6 +27,7 @@ import { isInvalidParamsTouched, } from './agg_params_helper'; import { EditorConfig } from '../../config/types'; +import { IndexPattern, Field } from '../../../../../../../plugins/data/public'; jest.mock('ui/agg_types', () => ({ aggTypes: { diff --git a/src/legacy/ui/public/vis/editors/default/components/agg_params_helper.ts b/src/legacy/ui/public/vis/editors/default/components/agg_params_helper.ts index d233f561940da..e0e014f69ef3f 100644 --- a/src/legacy/ui/public/vis/editors/default/components/agg_params_helper.ts +++ b/src/legacy/ui/public/vis/editors/default/components/agg_params_helper.ts @@ -20,7 +20,6 @@ import { get, isEmpty } from 'lodash'; import { i18n } from '@kbn/i18n'; import { aggTypeFilters } from 'ui/agg_types/filter'; -import { IndexPattern, Field } from 'ui/index_patterns'; import { aggTypes, AggParam, FieldParamType, AggType } from 'ui/agg_types'; import { aggTypeFieldFilters } from 'ui/agg_types/param_types/filter'; import { AggConfig, VisState } from '../../..'; @@ -28,6 +27,7 @@ import { groupAndSortBy, ComboBoxGroupedOptions } from '../utils'; import { EditorConfig } from '../../config/types'; import { AggTypeState, AggParamsState } from './agg_params_state'; import { AggParamEditorProps } from './agg_param_props'; +import { IndexPattern, Field } from '../../../../../../../plugins/data/public'; interface ParamInstanceBase { agg: AggConfig; diff --git a/src/legacy/ui/public/vis/editors/default/components/agg_select.tsx b/src/legacy/ui/public/vis/editors/default/components/agg_select.tsx index 2934711b2357a..443c655912a55 100644 --- a/src/legacy/ui/public/vis/editors/default/components/agg_select.tsx +++ b/src/legacy/ui/public/vis/editors/default/components/agg_select.tsx @@ -23,9 +23,9 @@ import { EuiComboBox, EuiComboBoxOptionProps, EuiFormRow, EuiLink, EuiText } fro import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; import { AggType } from 'ui/agg_types'; -import { IndexPattern } from 'ui/index_patterns'; import { documentationLinks } from '../../../../documentation_links/documentation_links'; import { ComboBoxGroupedOptions } from '../utils'; +import { IndexPattern } from '../../../../../../../plugins/data/public'; interface DefaultEditorAggSelectProps { aggError?: string; diff --git a/src/legacy/ui/public/vis/editors/default/controls/field.test.tsx b/src/legacy/ui/public/vis/editors/default/controls/field.test.tsx index aac32e28c80a5..4d15ac8e80e63 100644 --- a/src/legacy/ui/public/vis/editors/default/controls/field.test.tsx +++ b/src/legacy/ui/public/vis/editors/default/controls/field.test.tsx @@ -21,7 +21,7 @@ import React from 'react'; import { act } from 'react-dom/test-utils'; import { mount, shallow, ReactWrapper } from 'enzyme'; import { EuiComboBoxProps, EuiComboBox } from '@elastic/eui'; -import { Field } from '../../../../index_patterns'; +import { Field } from '../../../../../../../plugins/data/public'; import { ComboBoxGroupedOptions, SubAggParamsProp } from '..'; import { FieldParamEditor, FieldParamEditorProps } from './field'; import { AggConfig, VisState } from '../../..'; diff --git a/src/legacy/ui/public/vis/editors/default/controls/field.tsx b/src/legacy/ui/public/vis/editors/default/controls/field.tsx index a96be3a14b7ef..75a9e24cd0dee 100644 --- a/src/legacy/ui/public/vis/editors/default/controls/field.tsx +++ b/src/legacy/ui/public/vis/editors/default/controls/field.tsx @@ -23,7 +23,7 @@ import React, { useEffect } from 'react'; import { EuiComboBox, EuiComboBoxOptionProps, EuiFormRow } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { AggConfig } from '../../..'; -import { Field } from '../../../../index_patterns'; +import { Field } from '../../../../../../../plugins/data/public'; import { formatListAsProse, parseCommaSeparatedList } from '../../../../../../utils'; import { AggParam, FieldParamType } from '../../../../agg_types'; import { AggParamEditorProps, ComboBoxGroupedOptions } from '..'; diff --git a/src/legacy/ui/public/vis/editors/default/controls/top_field.tsx b/src/legacy/ui/public/vis/editors/default/controls/top_field.tsx index 5a5f2ceee3a56..e15187621954f 100644 --- a/src/legacy/ui/public/vis/editors/default/controls/top_field.tsx +++ b/src/legacy/ui/public/vis/editors/default/controls/top_field.tsx @@ -19,7 +19,7 @@ import React from 'react'; import { i18n } from '@kbn/i18n'; -import { Field } from '../../../../index_patterns'; +import { Field } from '../../../../../../../plugins/data/public'; import { FieldParamEditor } from './field'; import { getCompatibleAggs } from './top_aggregate'; import { AggParamEditorProps } from '..'; diff --git a/src/legacy/ui/public/vis/editors/default/controls/top_sort_field.tsx b/src/legacy/ui/public/vis/editors/default/controls/top_sort_field.tsx index 4116ae878209e..905bd052ec695 100644 --- a/src/legacy/ui/public/vis/editors/default/controls/top_sort_field.tsx +++ b/src/legacy/ui/public/vis/editors/default/controls/top_sort_field.tsx @@ -19,7 +19,7 @@ import React from 'react'; import { i18n } from '@kbn/i18n'; -import { Field } from '../../../../index_patterns'; +import { Field } from '../../../../../../../plugins/data/public'; import { FieldParamEditor } from './field'; import { AggParamEditorProps } from '..'; diff --git a/src/legacy/ui/public/vis/editors/default/vis_type_agg_filter.ts b/src/legacy/ui/public/vis/editors/default/vis_type_agg_filter.ts index 5842d7579f60a..c64907fff58a1 100644 --- a/src/legacy/ui/public/vis/editors/default/vis_type_agg_filter.ts +++ b/src/legacy/ui/public/vis/editors/default/vis_type_agg_filter.ts @@ -18,7 +18,7 @@ */ import { AggType } from '../../../agg_types'; import { aggTypeFilters, propFilter } from '../../../agg_types/filter'; -import { IndexPattern } from '../../../index_patterns'; +import { IndexPattern } from '../../../../../../plugins/data/public'; import { AggConfig } from '../../../vis'; const filterByName = propFilter('name'); diff --git a/src/plugins/data/public/query/timefilter/timefilter.ts b/src/plugins/data/public/query/timefilter/timefilter.ts index 639f3f4a66f18..58806a9328b1c 100644 --- a/src/plugins/data/public/query/timefilter/timefilter.ts +++ b/src/plugins/data/public/query/timefilter/timefilter.ts @@ -20,13 +20,13 @@ import _ from 'lodash'; import { Subject, BehaviorSubject } from 'rxjs'; import moment from 'moment'; -import { IndexPattern } from 'src/legacy/core_plugins/data/public'; import { areRefreshIntervalsDifferent, areTimeRangesDifferent } from './lib/diff_time_picker_vals'; import { parseQueryString } from './lib/parse_querystring'; import { calculateBounds, getTime } from './get_time'; import { TimefilterConfig, InputTimeRange, TimeRangeBounds } from './types'; import { RefreshInterval, TimeRange } from '../../../common'; import { TimeHistoryContract } from './time_history'; +import { IndexPattern } from '../../index_patterns'; // TODO: remove! diff --git a/src/plugins/es_ui_shared/static/forms/helpers/field_validators/index_pattern_field.ts b/src/plugins/es_ui_shared/static/forms/helpers/field_validators/index_pattern_field.ts index 7f178eabdcd19..48702a32bfde8 100644 --- a/src/plugins/es_ui_shared/static/forms/helpers/field_validators/index_pattern_field.ts +++ b/src/plugins/es_ui_shared/static/forms/helpers/field_validators/index_pattern_field.ts @@ -16,12 +16,13 @@ * specific language governing permissions and limitations * under the License. */ -import { ILLEGAL_CHARACTERS, validateIndexPattern } from 'ui/index_patterns'; import { ValidationFunc } from '../../hook_form_lib'; import { containsChars } from '../../../validators/string'; import { ERROR_CODE } from './types'; +import { indexPatterns } from '../../../../../data/public'; + export const indexPatternField = (i18n: any) => ( ...args: Parameters ): ReturnType> => { @@ -45,9 +46,9 @@ export const indexPatternField = (i18n: any) => ( } // Validate illegal characters - const errors = validateIndexPattern(value); + const errors = indexPatterns.validate(value); - if (errors[ILLEGAL_CHARACTERS]) { + if (errors[indexPatterns.ILLEGAL_CHARACTERS_KEY]) { return { code: 'ERR_FIELD_FORMAT', formatType: 'INDEX_PATTERN', @@ -55,8 +56,8 @@ export const indexPatternField = (i18n: any) => ( defaultMessage: 'The index pattern contains the invalid {characterListLength, plural, one {character} other {characters}} { characterList }.', values: { - characterList: errors[ILLEGAL_CHARACTERS].join(' '), - characterListLength: errors[ILLEGAL_CHARACTERS].length, + characterList: errors[indexPatterns.ILLEGAL_CHARACTERS_KEY].join(' '), + characterListLength: errors[indexPatterns.ILLEGAL_CHARACTERS_KEY].length, }, }), }; diff --git a/x-pack/legacy/plugins/cross_cluster_replication/__jest__/client_integration/auto_follow_pattern_add.test.js b/x-pack/legacy/plugins/cross_cluster_replication/__jest__/client_integration/auto_follow_pattern_add.test.js index 2e0acca5ba4a8..06a7c2f1ec45e 100644 --- a/x-pack/legacy/plugins/cross_cluster_replication/__jest__/client_integration/auto_follow_pattern_add.test.js +++ b/x-pack/legacy/plugins/cross_cluster_replication/__jest__/client_integration/auto_follow_pattern_add.test.js @@ -5,7 +5,7 @@ */ import { setupEnvironment, pageHelpers, nextTick, getRandomString } from './helpers'; -import { INDEX_PATTERN_ILLEGAL_CHARACTERS_VISIBLE } from '../../../../../../src/legacy/ui/public/index_patterns'; +import { indexPatterns } from '../../../../../../src/plugins/data/public'; jest.mock('ui/new_platform'); @@ -203,7 +203,7 @@ describe('Create Auto-follow pattern', () => { ); }; - return INDEX_PATTERN_ILLEGAL_CHARACTERS_VISIBLE.reduce((promise, char) => { + return indexPatterns.ILLEGAL_CHARACTERS_VISIBLE.reduce((promise, char) => { return promise.then(() => expectInvalidChar(char)); }, Promise.resolve()); }); diff --git a/x-pack/legacy/plugins/cross_cluster_replication/__jest__/client_integration/follower_index_add.test.js b/x-pack/legacy/plugins/cross_cluster_replication/__jest__/client_integration/follower_index_add.test.js index a1535c4560fc3..8d4523ca26de2 100644 --- a/x-pack/legacy/plugins/cross_cluster_replication/__jest__/client_integration/follower_index_add.test.js +++ b/x-pack/legacy/plugins/cross_cluster_replication/__jest__/client_integration/follower_index_add.test.js @@ -7,7 +7,7 @@ import { setupEnvironment, pageHelpers, nextTick } from './helpers'; import { RemoteClustersFormField } from '../../public/app/components'; -import { INDEX_PATTERN_ILLEGAL_CHARACTERS_VISIBLE } from '../../../../../../src/legacy/ui/public/index_patterns'; +import { indexPatterns } from '../../../../../../src/plugins/data/public'; jest.mock('ui/new_platform'); @@ -129,7 +129,7 @@ describe('Create Follower index', () => { ); }; - return INDEX_PATTERN_ILLEGAL_CHARACTERS_VISIBLE.reduce((promise, char) => { + return indexPatterns.ILLEGAL_CHARACTERS_VISIBLE.reduce((promise, char) => { return promise.then(() => expectInvalidChar(char)); }, Promise.resolve()); }); @@ -158,7 +158,7 @@ describe('Create Follower index', () => { ); }; - return INDEX_PATTERN_ILLEGAL_CHARACTERS_VISIBLE.reduce((promise, char) => { + return indexPatterns.ILLEGAL_CHARACTERS_VISIBLE.reduce((promise, char) => { return promise.then(() => expectInvalidChar(char)); }, Promise.resolve()); }); diff --git a/x-pack/legacy/plugins/cross_cluster_replication/public/app/components/auto_follow_pattern_form.js b/x-pack/legacy/plugins/cross_cluster_replication/public/app/components/auto_follow_pattern_form.js index e676b831e0f2e..ebb731a1b1aca 100644 --- a/x-pack/legacy/plugins/cross_cluster_replication/public/app/components/auto_follow_pattern_form.js +++ b/x-pack/legacy/plugins/cross_cluster_replication/public/app/components/auto_follow_pattern_form.js @@ -29,7 +29,6 @@ import { EuiTitle, } from '@elastic/eui'; -import { INDEX_PATTERN_ILLEGAL_CHARACTERS_VISIBLE } from 'ui/index_patterns'; import { INDEX_ILLEGAL_CHARACTERS_VISIBLE } from 'ui/indices'; import routing from '../services/routing'; @@ -45,8 +44,9 @@ import { } from '../services/auto_follow_pattern_validators'; import { AutoFollowPatternRequestFlyout } from './auto_follow_pattern_request_flyout'; +import { indexPatterns } from '../../../../../../../src/plugins/data/public'; -const indexPatternIllegalCharacters = INDEX_PATTERN_ILLEGAL_CHARACTERS_VISIBLE.join(' '); +const indexPatternIllegalCharacters = indexPatterns.ILLEGAL_CHARACTERS_VISIBLE.join(' '); const indexNameIllegalCharacters = INDEX_ILLEGAL_CHARACTERS_VISIBLE.join(' '); const getEmptyAutoFollowPattern = (remoteClusterName = '') => ({ diff --git a/x-pack/legacy/plugins/cross_cluster_replication/public/app/services/auto_follow_pattern_validators.js b/x-pack/legacy/plugins/cross_cluster_replication/public/app/services/auto_follow_pattern_validators.js index bd51af824324b..18610c87c0a51 100644 --- a/x-pack/legacy/plugins/cross_cluster_replication/public/app/services/auto_follow_pattern_validators.js +++ b/x-pack/legacy/plugins/cross_cluster_replication/public/app/services/auto_follow_pattern_validators.js @@ -8,18 +8,14 @@ import React from 'react'; import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; -import { - ILLEGAL_CHARACTERS, - CONTAINS_SPACES, - validateIndexPattern as getIndexPatternErrors, -} from 'ui/index_patterns'; - import { indexNameBeginsWithPeriod, findIllegalCharactersInIndexName, indexNameContainsSpaces, } from 'ui/indices'; +import { indexPatterns } from '../../../../../../../src/plugins/data/public'; + export const validateName = (name = '') => { let errorMsg = null; @@ -57,9 +53,9 @@ export const validateName = (name = '') => { export const validateLeaderIndexPattern = indexPattern => { if (indexPattern) { - const errors = getIndexPatternErrors(indexPattern); + const errors = indexPatterns.validate(indexPattern); - if (errors[ILLEGAL_CHARACTERS]) { + if (errors[indexPatterns.ILLEGAL_CHARACTERS_KEY]) { return { message: ( { defaultMessage="Remove the {characterListLength, plural, one {character} other {characters}} {characterList} from the index pattern." values={{ - characterList: {errors[ILLEGAL_CHARACTERS].join(' ')}, - characterListLength: errors[ILLEGAL_CHARACTERS].length, + characterList: ( + {errors[indexPatterns.ILLEGAL_CHARACTERS_KEY].join(' ')} + ), + characterListLength: errors[indexPatterns.ILLEGAL_CHARACTERS_KEY].length, }} /> ), }; } - if (errors[CONTAINS_SPACES]) { + if (errors[indexPatterns.CONTAINS_SPACES_KEY]) { return { message: ( Promise diff --git a/x-pack/legacy/plugins/graph/public/services/persistence/deserialize.test.ts b/x-pack/legacy/plugins/graph/public/services/persistence/deserialize.test.ts index c7f8b72cc1abf..d38c950a5986f 100644 --- a/x-pack/legacy/plugins/graph/public/services/persistence/deserialize.test.ts +++ b/x-pack/legacy/plugins/graph/public/services/persistence/deserialize.test.ts @@ -6,9 +6,9 @@ import { GraphWorkspaceSavedObject, Workspace } from '../../types'; import { savedWorkspaceToAppState } from './deserialize'; -import { IndexPattern } from 'src/legacy/core_plugins/data/public'; import { createWorkspace } from '../../angular/graph_client_workspace'; import { outlinkEncoders } from '../../helpers/outlink_encoders'; +import { IndexPattern } from '../../../../../../../src/plugins/data/public'; describe('deserialize', () => { let savedWorkspace: GraphWorkspaceSavedObject; diff --git a/x-pack/legacy/plugins/graph/public/services/persistence/deserialize.ts b/x-pack/legacy/plugins/graph/public/services/persistence/deserialize.ts index 9a13da65e976a..af34b4f1a725b 100644 --- a/x-pack/legacy/plugins/graph/public/services/persistence/deserialize.ts +++ b/x-pack/legacy/plugins/graph/public/services/persistence/deserialize.ts @@ -4,7 +4,6 @@ * you may not use this file except in compliance with the Elastic License. */ -import { IndexPattern } from 'src/legacy/core_plugins/data/public/'; import { SerializedNode, UrlTemplate, @@ -25,6 +24,7 @@ import { colorChoices, iconChoicesByClass, } from '../../helpers/style_choices'; +import { IndexPattern } from '../../../../../../../src/plugins/data/public'; const defaultAdvancedSettings: AdvancedSettings = { useSignificance: true, diff --git a/x-pack/legacy/plugins/graph/public/state_management/datasource.sagas.ts b/x-pack/legacy/plugins/graph/public/state_management/datasource.sagas.ts index 7afea3d2a765a..34d39e71dec55 100644 --- a/x-pack/legacy/plugins/graph/public/state_management/datasource.sagas.ts +++ b/x-pack/legacy/plugins/graph/public/state_management/datasource.sagas.ts @@ -6,7 +6,6 @@ import { takeLatest, put, call, select } from 'redux-saga/effects'; import { i18n } from '@kbn/i18n'; -import { IndexPattern } from 'src/legacy/core_plugins/data/public'; import { Action } from 'typescript-fsa'; import { GraphStoreDependencies } from './store'; import { loadFields } from './fields'; @@ -18,6 +17,7 @@ import { setDatasource, requestDatasource, } from './datasource'; +import { IndexPattern } from '../../../../../../src/plugins/data/public'; /** * Saga loading field information when the datasource is switched. This will overwrite current settings diff --git a/x-pack/legacy/plugins/graph/public/state_management/datasource.test.ts b/x-pack/legacy/plugins/graph/public/state_management/datasource.test.ts index 7e51e463f9f61..041098a9aaae5 100644 --- a/x-pack/legacy/plugins/graph/public/state_management/datasource.test.ts +++ b/x-pack/legacy/plugins/graph/public/state_management/datasource.test.ts @@ -10,7 +10,7 @@ import { datasourceSelector, requestDatasource } from './datasource'; import { datasourceSaga } from './datasource.sagas'; import { fieldsSelector } from './fields'; import { updateSettings } from './advanced_settings'; -import { IndexPattern } from 'src/legacy/core_plugins/data/public'; +import { IndexPattern } from '../../../../../../src/plugins/data/public'; const waitForPromise = () => new Promise(r => setTimeout(r)); diff --git a/x-pack/legacy/plugins/graph/public/state_management/mocks.ts b/x-pack/legacy/plugins/graph/public/state_management/mocks.ts index 9672edef31d6f..5a4f0d033aa42 100644 --- a/x-pack/legacy/plugins/graph/public/state_management/mocks.ts +++ b/x-pack/legacy/plugins/graph/public/state_management/mocks.ts @@ -4,13 +4,13 @@ * you may not use this file except in compliance with the Elastic License. */ -import { IndexPattern } from 'src/legacy/core_plugins/data/public'; import { NotificationsStart, HttpStart } from 'kibana/public'; import createSagaMiddleware from 'redux-saga'; import { createStore, applyMiddleware, AnyAction } from 'redux'; import { ChromeStart } from 'kibana/public'; import { GraphStoreDependencies, createRootReducer, GraphStore, GraphState } from './store'; import { Workspace, GraphWorkspaceSavedObject, IndexPatternSavedObject } from '../types'; +import { IndexPattern } from '../../../../../../src/plugins/data/public'; jest.mock('ui/new_platform'); diff --git a/x-pack/legacy/plugins/graph/public/types/app_state.ts b/x-pack/legacy/plugins/graph/public/types/app_state.ts index 24b1876bb713f..eef8060f07f5c 100644 --- a/x-pack/legacy/plugins/graph/public/types/app_state.ts +++ b/x-pack/legacy/plugins/graph/public/types/app_state.ts @@ -5,9 +5,9 @@ */ import { SimpleSavedObject } from 'src/core/public'; -import { IndexPattern } from 'src/legacy/core_plugins/data/public'; import { FontawesomeIcon } from '../helpers/style_choices'; import { OutlinkEncoder } from '../helpers/outlink_encoders'; +import { IndexPattern } from '../../../../../../src/plugins/data/public'; export interface UrlTemplate { url: string; diff --git a/x-pack/legacy/plugins/maps/public/elasticsearch_geo_utils.test.js b/x-pack/legacy/plugins/maps/public/elasticsearch_geo_utils.test.js index 170ede9f2bb26..fb4b0a6e29e6c 100644 --- a/x-pack/legacy/plugins/maps/public/elasticsearch_geo_utils.test.js +++ b/x-pack/legacy/plugins/maps/public/elasticsearch_geo_utils.test.js @@ -5,7 +5,7 @@ */ jest.mock('ui/new_platform'); -jest.mock('ui/index_patterns'); + jest.mock('./kibana_services', () => { return { SPATIAL_FILTER_TYPE: 'spatial_filter', @@ -20,7 +20,7 @@ import { convertMapExtentToPolygon, roundCoordinates, } from './elasticsearch_geo_utils'; -import { flattenHitWrapper } from 'ui/index_patterns'; +import { indexPatterns } from '../../../../../src/plugins/data/public'; const geoFieldName = 'location'; const mapExtent = { @@ -172,7 +172,7 @@ describe('hitsToGeoJson', () => { }, }, }; - const indexPatternFlattenHit = flattenHitWrapper(indexPatternMock); + const indexPatternFlattenHit = indexPatterns.flattenHitWrapper(indexPatternMock); it('Should handle geoField being an object', () => { const hits = [ diff --git a/x-pack/legacy/plugins/ml/public/application/components/data_recognizer/data_recognizer.d.ts b/x-pack/legacy/plugins/ml/public/application/components/data_recognizer/data_recognizer.d.ts index 2a15c597fed81..4258b3761f72c 100644 --- a/x-pack/legacy/plugins/ml/public/application/components/data_recognizer/data_recognizer.d.ts +++ b/x-pack/legacy/plugins/ml/public/application/components/data_recognizer/data_recognizer.d.ts @@ -5,9 +5,8 @@ */ import { FC } from 'react'; - -import { IndexPattern } from 'ui/index_patterns'; import { SavedSearchSavedObject } from '../../../../common/types/kibana'; +import { IndexPattern } from '../../../../../../../../src/plugins/data/public'; declare const DataRecognizer: FC<{ indexPattern: IndexPattern; diff --git a/x-pack/legacy/plugins/ml/public/application/components/full_time_range_selector/full_time_range_selector.test.tsx b/x-pack/legacy/plugins/ml/public/application/components/full_time_range_selector/full_time_range_selector.test.tsx index 38e4a3fc24278..a4e2ebe6784d8 100644 --- a/x-pack/legacy/plugins/ml/public/application/components/full_time_range_selector/full_time_range_selector.test.tsx +++ b/x-pack/legacy/plugins/ml/public/application/components/full_time_range_selector/full_time_range_selector.test.tsx @@ -6,9 +6,9 @@ import React from 'react'; import { shallowWithIntl } from 'test_utils/enzyme_helpers'; -import { IndexPattern } from 'ui/index_patterns'; import { FullTimeRangeSelector } from './index'; import { Query } from 'src/plugins/data/public'; +import { IndexPattern } from '../../../../../../../../src/plugins/data/public'; // Create a mock for the setFullTimeRange function in the service. // The mock is hoisted to the top, so need to prefix the mock function diff --git a/x-pack/legacy/plugins/ml/public/application/components/full_time_range_selector/full_time_range_selector.tsx b/x-pack/legacy/plugins/ml/public/application/components/full_time_range_selector/full_time_range_selector.tsx index f637ffb9beea0..ef2a4c28a570d 100644 --- a/x-pack/legacy/plugins/ml/public/application/components/full_time_range_selector/full_time_range_selector.tsx +++ b/x-pack/legacy/plugins/ml/public/application/components/full_time_range_selector/full_time_range_selector.tsx @@ -8,9 +8,9 @@ import React, { FC } from 'react'; import { FormattedMessage } from '@kbn/i18n/react'; import { Query } from 'src/plugins/data/public'; -import { IndexPattern } from 'ui/index_patterns'; import { EuiButton } from '@elastic/eui'; import { setFullTimeRange } from './full_time_range_selector_service'; +import { IndexPattern } from '../../../../../../../../src/plugins/data/public'; interface Props { indexPattern: IndexPattern; diff --git a/x-pack/legacy/plugins/ml/public/application/components/full_time_range_selector/full_time_range_selector_service.ts b/x-pack/legacy/plugins/ml/public/application/components/full_time_range_selector/full_time_range_selector_service.ts index bd31ccf7eca3d..e69aaf2ede037 100644 --- a/x-pack/legacy/plugins/ml/public/application/components/full_time_range_selector/full_time_range_selector_service.ts +++ b/x-pack/legacy/plugins/ml/public/application/components/full_time_range_selector/full_time_range_selector_service.ts @@ -7,12 +7,12 @@ import moment from 'moment'; import { i18n } from '@kbn/i18n'; -import { IndexPattern } from 'ui/index_patterns'; import { toastNotifications } from 'ui/notify'; import { timefilter } from 'ui/timefilter'; import { Query } from 'src/plugins/data/public'; import dateMath from '@elastic/datemath'; import { ml, GetTimeFieldRangeResponse } from '../../services/ml_api_service'; +import { IndexPattern } from '../../../../../../../../src/plugins/data/public'; export interface TimeRange { from: number; diff --git a/x-pack/legacy/plugins/ml/public/application/contexts/kibana/__mocks__/index_pattern.ts b/x-pack/legacy/plugins/ml/public/application/contexts/kibana/__mocks__/index_pattern.ts index a9f30a904d54b..6a85c18de6d31 100644 --- a/x-pack/legacy/plugins/ml/public/application/contexts/kibana/__mocks__/index_pattern.ts +++ b/x-pack/legacy/plugins/ml/public/application/contexts/kibana/__mocks__/index_pattern.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { IndexPattern } from 'ui/index_patterns'; +import { IndexPattern } from '../../../../../../../../../src/plugins/data/public'; export const indexPatternMock = ({ id: 'the-index-pattern-id', diff --git a/x-pack/legacy/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/components/create_analytics_button/create_analytics_button.test.tsx b/x-pack/legacy/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/components/create_analytics_button/create_analytics_button.test.tsx index 15f30b6cca6c4..abb35e50ec2a2 100644 --- a/x-pack/legacy/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/components/create_analytics_button/create_analytics_button.test.tsx +++ b/x-pack/legacy/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/components/create_analytics_button/create_analytics_button.test.tsx @@ -15,11 +15,6 @@ import { kibanaContextValueMock } from '../../../../../contexts/kibana/__mocks__ import { useCreateAnalyticsForm } from '../../hooks/use_create_analytics_form'; -jest.mock('ui/index_patterns', () => ({ - validateIndexPattern: () => true, - INDEX_PATTERN_ILLEGAL_CHARACTERS: [], -})); - const getMountedHook = () => mountHook( () => useCreateAnalyticsForm(), diff --git a/x-pack/legacy/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/components/create_analytics_flyout/create_analytics_flyout.test.tsx b/x-pack/legacy/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/components/create_analytics_flyout/create_analytics_flyout.test.tsx index 880a1354e7a64..d5d509826667c 100644 --- a/x-pack/legacy/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/components/create_analytics_flyout/create_analytics_flyout.test.tsx +++ b/x-pack/legacy/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/components/create_analytics_flyout/create_analytics_flyout.test.tsx @@ -15,11 +15,6 @@ import { kibanaContextValueMock } from '../../../../../contexts/kibana/__mocks__ import { useCreateAnalyticsForm } from '../../hooks/use_create_analytics_form'; -jest.mock('ui/index_patterns', () => ({ - validateIndexPattern: () => true, - INDEX_PATTERN_ILLEGAL_CHARACTERS: [], -})); - const getMountedHook = () => mountHook( () => useCreateAnalyticsForm(), diff --git a/x-pack/legacy/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/components/create_analytics_form/create_analytics_form.test.tsx b/x-pack/legacy/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/components/create_analytics_form/create_analytics_form.test.tsx index 49381e3b1c031..0d4daee373b13 100644 --- a/x-pack/legacy/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/components/create_analytics_form/create_analytics_form.test.tsx +++ b/x-pack/legacy/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/components/create_analytics_form/create_analytics_form.test.tsx @@ -15,11 +15,6 @@ import { kibanaContextValueMock } from '../../../../../contexts/kibana/__mocks__ import { useCreateAnalyticsForm } from '../../hooks/use_create_analytics_form'; -jest.mock('ui/index_patterns', () => ({ - validateIndexPattern: () => true, - INDEX_PATTERN_ILLEGAL_CHARACTERS: [], -})); - const getMountedHook = () => mountHook( () => useCreateAnalyticsForm(), diff --git a/x-pack/legacy/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/components/create_analytics_form/create_analytics_form.tsx b/x-pack/legacy/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/components/create_analytics_form/create_analytics_form.tsx index e2106e56e0346..0815b8dbd8d3d 100644 --- a/x-pack/legacy/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/components/create_analytics_form/create_analytics_form.tsx +++ b/x-pack/legacy/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/components/create_analytics_form/create_analytics_form.tsx @@ -21,7 +21,6 @@ import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; import { metadata } from 'ui/metadata'; -import { IndexPattern, INDEX_PATTERN_ILLEGAL_CHARACTERS } from 'ui/index_patterns'; import { ml } from '../../../../../services/ml_api_service'; import { Field, EVENT_RATE_FIELD_ID } from '../../../../../../../common/types/fields'; @@ -38,11 +37,10 @@ import { Messages } from './messages'; import { JobType } from './job_type'; import { JobDescriptionInput } from './job_description'; import { mmlUnitInvalidErrorMessage } from '../../hooks/use_create_analytics_form/reducer'; - -// based on code used by `ui/index_patterns` internally -// remove the space character from the list of illegal characters -INDEX_PATTERN_ILLEGAL_CHARACTERS.pop(); -const characterList = INDEX_PATTERN_ILLEGAL_CHARACTERS.join(', '); +import { + IndexPattern, + indexPatterns, +} from '../../../../../../../../../../../src/plugins/data/public'; const NUMERICAL_FIELD_TYPES = new Set([ 'long', @@ -63,7 +61,6 @@ const OMIT_FIELDS: string[] = ['_source', '_type', '_index', '_id', '_version', export const CreateAnalyticsForm: FC = ({ actions, state }) => { const { setFormState } = actions; const kibanaContext = useKibanaContext(); - const { form, indexPatternsMap, isAdvancedEditorEnabled, isJobCreated, requestMessages } = state; const { @@ -93,6 +90,7 @@ export const CreateAnalyticsForm: FC = ({ actions, sta sourceIndexFieldsCheckFailed, trainingPercent, } = form; + const characterList = indexPatterns.ILLEGAL_CHARACTERS_VISIBLE.join(', '); // Find out if index pattern contain numeric fields. Provides a hint in the form // that an analytics jobs is not able to identify outliers if there are no numeric fields present. diff --git a/x-pack/legacy/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/hooks/use_create_analytics_form/reducer.test.ts b/x-pack/legacy/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/hooks/use_create_analytics_form/reducer.test.ts index 754f7a1136a97..fcb99ea83548d 100644 --- a/x-pack/legacy/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/hooks/use_create_analytics_form/reducer.test.ts +++ b/x-pack/legacy/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/hooks/use_create_analytics_form/reducer.test.ts @@ -12,10 +12,6 @@ import { ACTION } from './actions'; import { reducer, validateAdvancedEditor } from './reducer'; import { getInitialState, JOB_TYPES } from './state'; -jest.mock('ui/index_patterns', () => ({ - validateIndexPattern: () => true, -})); - type SourceIndex = DataFrameAnalyticsConfig['source']['index']; const getMockState = ({ diff --git a/x-pack/legacy/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/hooks/use_create_analytics_form/reducer.ts b/x-pack/legacy/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/hooks/use_create_analytics_form/reducer.ts index 06c8a6c6a8846..8498b0e5a9e9e 100644 --- a/x-pack/legacy/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/hooks/use_create_analytics_form/reducer.ts +++ b/x-pack/legacy/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/hooks/use_create_analytics_form/reducer.ts @@ -5,9 +5,6 @@ */ import { i18n } from '@kbn/i18n'; - -import { validateIndexPattern } from 'ui/index_patterns'; - import { isValidIndexName } from '../../../../../../../common/util/es_utils'; import { Action, ACTION } from './actions'; @@ -26,6 +23,7 @@ import { isRegressionAnalysis, isClassificationAnalysis, } from '../../../../common/analytics'; +import { indexPatterns } from '../../../../../../../../../../../src/plugins/data/public'; const mmlAllowedUnitsStr = `${ALLOWED_DATA_UNITS.slice(0, ALLOWED_DATA_UNITS.length - 1).join( ', ' @@ -66,9 +64,9 @@ export const validateAdvancedEditor = (state: State): State => { // general check against Kibana index pattern names, but since this is about the advanced editor // with support for arrays in the job config, we also need to check that each individual name // doesn't include a comma if index names are supplied as an array. - // `validateIndexPattern()` returns a map of messages, we're only interested here if it's valid or not. + // `indexPatterns.validate()` returns a map of messages, we're only interested here if it's valid or not. // If there are no messages, it means the index pattern is valid. - let sourceIndexNameValid = Object.keys(validateIndexPattern(sourceIndexName)).length === 0; + let sourceIndexNameValid = Object.keys(indexPatterns.validate(sourceIndexName)).length === 0; const sourceIndex = jobConfig?.source?.index; if (sourceIndexNameValid) { if (typeof sourceIndex === 'string') { @@ -293,7 +291,7 @@ export function reducer(state: State, action: Action): State { if (action.payload.sourceIndex !== undefined) { newFormState.sourceIndexNameEmpty = newFormState.sourceIndex === ''; - const validationMessages = validateIndexPattern(newFormState.sourceIndex); + const validationMessages = indexPatterns.validate(newFormState.sourceIndex); newFormState.sourceIndexNameValid = Object.keys(validationMessages).length === 0; } diff --git a/x-pack/legacy/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/hooks/use_create_analytics_form/use_create_analytics_form.test.tsx b/x-pack/legacy/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/hooks/use_create_analytics_form/use_create_analytics_form.test.tsx index 6854b439d7382..3298a7d00253f 100644 --- a/x-pack/legacy/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/hooks/use_create_analytics_form/use_create_analytics_form.test.tsx +++ b/x-pack/legacy/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/hooks/use_create_analytics_form/use_create_analytics_form.test.tsx @@ -12,10 +12,6 @@ import { kibanaContextValueMock } from '../../../../../contexts/kibana/__mocks__ import { getErrorMessage, useCreateAnalyticsForm } from './use_create_analytics_form'; -jest.mock('ui/index_patterns', () => ({ - validateIndexPattern: () => true, -})); - const getMountedHook = () => mountHook( () => useCreateAnalyticsForm(), diff --git a/x-pack/legacy/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/services/analytics_service/get_analytics.test.ts b/x-pack/legacy/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/services/analytics_service/get_analytics.test.ts index 33a073d7a686e..1aaddda358082 100644 --- a/x-pack/legacy/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/services/analytics_service/get_analytics.test.ts +++ b/x-pack/legacy/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/services/analytics_service/get_analytics.test.ts @@ -8,10 +8,6 @@ import { GetDataFrameAnalyticsStatsResponseOk } from '../../../../../services/ml import { getAnalyticsJobsStats } from './get_analytics'; import { DATA_FRAME_TASK_STATE } from '../../components/analytics_list/common'; -jest.mock('ui/index_patterns', () => ({ - validateIndexPattern: () => true, -})); - describe('get_analytics', () => { test('should get analytics jobs stats', () => { // arrange diff --git a/x-pack/legacy/plugins/ml/public/application/datavisualizer/index_based/components/actions_panel/actions_panel.tsx b/x-pack/legacy/plugins/ml/public/application/datavisualizer/index_based/components/actions_panel/actions_panel.tsx index 1b2f1553585cd..f291118140b9a 100644 --- a/x-pack/legacy/plugins/ml/public/application/datavisualizer/index_based/components/actions_panel/actions_panel.tsx +++ b/x-pack/legacy/plugins/ml/public/application/datavisualizer/index_based/components/actions_panel/actions_panel.tsx @@ -8,11 +8,9 @@ import React, { FC, useState } from 'react'; import { FormattedMessage } from '@kbn/i18n/react'; import { i18n } from '@kbn/i18n'; - -import { IndexPattern } from 'ui/index_patterns'; - import { EuiPanel, EuiSpacer, EuiText, EuiTitle, EuiFlexGroup } from '@elastic/eui'; +import { IndexPattern } from '../../../../../../../../../../src/plugins/data/public'; import { CreateJobLinkCard } from '../../../../components/create_job_link_card'; import { DataRecognizer } from '../../../../components/data_recognizer'; diff --git a/x-pack/legacy/plugins/ml/public/application/datavisualizer/index_based/components/search_panel/search_panel.tsx b/x-pack/legacy/plugins/ml/public/application/datavisualizer/index_based/components/search_panel/search_panel.tsx index 4dd1593a14da5..180fd2f103f2c 100644 --- a/x-pack/legacy/plugins/ml/public/application/datavisualizer/index_based/components/search_panel/search_panel.tsx +++ b/x-pack/legacy/plugins/ml/public/application/datavisualizer/index_based/components/search_panel/search_panel.tsx @@ -21,7 +21,7 @@ import { import { FormattedMessage } from '@kbn/i18n/react'; import { i18n } from '@kbn/i18n'; -import { IndexPattern } from 'ui/index_patterns'; +import { IndexPattern } from '../../../../../../../../../../src/plugins/data/public'; import { SEARCH_QUERY_LANGUAGE } from '../../../../../../common/constants/search'; import { SavedSearchQuery } from '../../../../contexts/kibana'; diff --git a/x-pack/legacy/plugins/ml/public/application/datavisualizer/index_based/data_loader/data_loader.ts b/x-pack/legacy/plugins/ml/public/application/datavisualizer/index_based/data_loader/data_loader.ts index fe0d69fdeec6b..983908e2eb7f7 100644 --- a/x-pack/legacy/plugins/ml/public/application/datavisualizer/index_based/data_loader/data_loader.ts +++ b/x-pack/legacy/plugins/ml/public/application/datavisualizer/index_based/data_loader/data_loader.ts @@ -7,7 +7,7 @@ import { i18n } from '@kbn/i18n'; import { toastNotifications } from 'ui/notify'; -import { IndexPattern } from 'ui/index_patterns'; +import { IndexPattern } from '../../../../../../../../../src/plugins/data/public'; import { SavedSearchQuery } from '../../../contexts/kibana'; import { IndexPatternTitle } from '../../../../../common/types/kibana'; diff --git a/x-pack/legacy/plugins/ml/public/application/datavisualizer/index_based/page.tsx b/x-pack/legacy/plugins/ml/public/application/datavisualizer/index_based/page.tsx index 898c852fe50a5..99df9fcdb60a2 100644 --- a/x-pack/legacy/plugins/ml/public/application/datavisualizer/index_based/page.tsx +++ b/x-pack/legacy/plugins/ml/public/application/datavisualizer/index_based/page.tsx @@ -8,7 +8,6 @@ import React, { FC, Fragment, useEffect, useState } from 'react'; import { merge } from 'rxjs'; import { i18n } from '@kbn/i18n'; -import { FieldType } from 'ui/index_patterns'; import { timefilter } from 'ui/timefilter'; import { @@ -22,7 +21,12 @@ import { EuiSpacer, EuiTitle, } from '@elastic/eui'; -import { KBN_FIELD_TYPES, esQuery, esKuery } from '../../../../../../../../src/plugins/data/public'; +import { + IFieldType, + KBN_FIELD_TYPES, + esQuery, + esKuery, +} from '../../../../../../../../src/plugins/data/public'; import { NavigationMenu } from '../../components/navigation_menu'; import { ML_JOB_FIELD_TYPES } from '../../../../common/constants/field_types'; import { SEARCH_QUERY_LANGUAGE } from '../../../../common/constants/search'; @@ -107,7 +111,7 @@ export const Page: FC = () => { // Obtain the list of non metric field types which appear in the index pattern. let indexedFieldTypes: ML_JOB_FIELD_TYPES[] = []; - const indexPatternFields: FieldType[] = currentIndexPattern.fields; + const indexPatternFields: IFieldType[] = currentIndexPattern.fields; indexPatternFields.forEach(field => { if (field.scripted !== true) { const dataVisualizerType: ML_JOB_FIELD_TYPES | undefined = kbnTypeToMLJobType(field); diff --git a/x-pack/legacy/plugins/ml/public/application/jobs/new_job/common/chart_loader/chart_loader.ts b/x-pack/legacy/plugins/ml/public/application/jobs/new_job/common/chart_loader/chart_loader.ts index 502a88ecf6004..5e92ab67fcc79 100644 --- a/x-pack/legacy/plugins/ml/public/application/jobs/new_job/common/chart_loader/chart_loader.ts +++ b/x-pack/legacy/plugins/ml/public/application/jobs/new_job/common/chart_loader/chart_loader.ts @@ -6,13 +6,13 @@ import memoizeOne from 'memoize-one'; import { isEqual } from 'lodash'; -import { IndexPattern } from 'ui/index_patterns'; import { IndexPatternTitle } from '../../../../../../common/types/kibana'; import { Field, SplitField, AggFieldPair } from '../../../../../../common/types/fields'; import { ml } from '../../../../services/ml_api_service'; import { mlResultsService } from '../../../../services/results_service'; import { getCategoryFields as getCategoryFieldsOrig } from './searches'; import { aggFieldPairsCanBeCharted } from '../job_creator/util/general'; +import { IndexPattern } from '../../../../../../../../../../src/plugins/data/public'; type DetectorIndex = number; export interface LineChartPoint { diff --git a/x-pack/legacy/plugins/ml/public/application/jobs/new_job/common/job_creator/advanced_job_creator.ts b/x-pack/legacy/plugins/ml/public/application/jobs/new_job/common/job_creator/advanced_job_creator.ts index d8917db7a33ff..b0eb1b98cd02b 100644 --- a/x-pack/legacy/plugins/ml/public/application/jobs/new_job/common/job_creator/advanced_job_creator.ts +++ b/x-pack/legacy/plugins/ml/public/application/jobs/new_job/common/job_creator/advanced_job_creator.ts @@ -4,7 +4,6 @@ * you may not use this file except in compliance with the Elastic License. */ -import { IndexPattern } from 'ui/index_patterns'; import { SavedSearchSavedObject } from '../../../../../../common/types/kibana'; import { JobCreator } from './job_creator'; @@ -15,6 +14,7 @@ import { JOB_TYPE } from '../../../../../../common/constants/new_job'; import { getRichDetectors } from './util/general'; import { isValidJson } from '../../../../../../common/util/validation_utils'; import { ml } from '../../../../services/ml_api_service'; +import { IndexPattern } from '../../../../../../../../../../src/plugins/data/public'; export interface RichDetector { agg: Aggregation | null; diff --git a/x-pack/legacy/plugins/ml/public/application/jobs/new_job/common/job_creator/job_creator.ts b/x-pack/legacy/plugins/ml/public/application/jobs/new_job/common/job_creator/job_creator.ts index 4707eff8d844e..513c8239db01e 100644 --- a/x-pack/legacy/plugins/ml/public/application/jobs/new_job/common/job_creator/job_creator.ts +++ b/x-pack/legacy/plugins/ml/public/application/jobs/new_job/common/job_creator/job_creator.ts @@ -4,7 +4,6 @@ * you may not use this file except in compliance with the Elastic License. */ -import { IndexPattern } from 'ui/index_patterns'; import { SavedSearchSavedObject } from '../../../../../../common/types/kibana'; import { UrlConfig } from '../../../../../../common/types/custom_urls'; import { IndexPatternTitle } from '../../../../../../common/types/kibana'; @@ -24,6 +23,7 @@ import { isSparseDataJob } from './util/general'; import { parseInterval } from '../../../../../../common/util/parse_interval'; import { Calendar } from '../../../../../../common/types/calendars'; import { mlCalendarService } from '../../../../services/calendar_service'; +import { IndexPattern } from '../../../../../../../../../../src/plugins/data/public'; export class JobCreator { protected _type: JOB_TYPE = JOB_TYPE.SINGLE_METRIC; diff --git a/x-pack/legacy/plugins/ml/public/application/jobs/new_job/common/job_creator/job_creator_factory.ts b/x-pack/legacy/plugins/ml/public/application/jobs/new_job/common/job_creator/job_creator_factory.ts index 4ffcd1b06ca47..868346d0188ea 100644 --- a/x-pack/legacy/plugins/ml/public/application/jobs/new_job/common/job_creator/job_creator_factory.ts +++ b/x-pack/legacy/plugins/ml/public/application/jobs/new_job/common/job_creator/job_creator_factory.ts @@ -4,12 +4,12 @@ * you may not use this file except in compliance with the Elastic License. */ -import { IndexPattern } from 'ui/index_patterns'; import { SavedSearchSavedObject } from '../../../../../../common/types/kibana'; import { SingleMetricJobCreator } from './single_metric_job_creator'; import { MultiMetricJobCreator } from './multi_metric_job_creator'; import { PopulationJobCreator } from './population_job_creator'; import { AdvancedJobCreator } from './advanced_job_creator'; +import { IndexPattern } from '../../../../../../../../../../src/plugins/data/public'; import { JOB_TYPE } from '../../../../../../common/constants/new_job'; diff --git a/x-pack/legacy/plugins/ml/public/application/jobs/new_job/common/job_creator/multi_metric_job_creator.ts b/x-pack/legacy/plugins/ml/public/application/jobs/new_job/common/job_creator/multi_metric_job_creator.ts index e86ee09d234f1..947c1bcf6c1a4 100644 --- a/x-pack/legacy/plugins/ml/public/application/jobs/new_job/common/job_creator/multi_metric_job_creator.ts +++ b/x-pack/legacy/plugins/ml/public/application/jobs/new_job/common/job_creator/multi_metric_job_creator.ts @@ -4,7 +4,6 @@ * you may not use this file except in compliance with the Elastic License. */ -import { IndexPattern } from 'ui/index_patterns'; import { SavedSearchSavedObject } from '../../../../../../common/types/kibana'; import { JobCreator } from './job_creator'; import { @@ -22,6 +21,7 @@ import { } from '../../../../../../common/constants/new_job'; import { ml } from '../../../../services/ml_api_service'; import { getRichDetectors } from './util/general'; +import { IndexPattern } from '../../../../../../../../../../src/plugins/data/public'; export class MultiMetricJobCreator extends JobCreator { // a multi metric job has one optional overall partition field diff --git a/x-pack/legacy/plugins/ml/public/application/jobs/new_job/common/job_creator/population_job_creator.ts b/x-pack/legacy/plugins/ml/public/application/jobs/new_job/common/job_creator/population_job_creator.ts index 8fcd03982424d..9300e53c578e1 100644 --- a/x-pack/legacy/plugins/ml/public/application/jobs/new_job/common/job_creator/population_job_creator.ts +++ b/x-pack/legacy/plugins/ml/public/application/jobs/new_job/common/job_creator/population_job_creator.ts @@ -4,7 +4,6 @@ * you may not use this file except in compliance with the Elastic License. */ -import { IndexPattern } from 'ui/index_patterns'; import { SavedSearchSavedObject } from '../../../../../../common/types/kibana'; import { JobCreator } from './job_creator'; import { @@ -17,6 +16,7 @@ import { Job, Datafeed, Detector } from './configs'; import { createBasicDetector } from './util/default_configs'; import { JOB_TYPE, CREATED_BY_LABEL } from '../../../../../../common/constants/new_job'; import { getRichDetectors } from './util/general'; +import { IndexPattern } from '../../../../../../../../../../src/plugins/data/public'; export class PopulationJobCreator extends JobCreator { // a population job has one overall over (split) field, which is the same for all detectors diff --git a/x-pack/legacy/plugins/ml/public/application/jobs/new_job/common/job_creator/single_metric_job_creator.ts b/x-pack/legacy/plugins/ml/public/application/jobs/new_job/common/job_creator/single_metric_job_creator.ts index cb8a46ade513c..f98fd4dbe970a 100644 --- a/x-pack/legacy/plugins/ml/public/application/jobs/new_job/common/job_creator/single_metric_job_creator.ts +++ b/x-pack/legacy/plugins/ml/public/application/jobs/new_job/common/job_creator/single_metric_job_creator.ts @@ -4,7 +4,6 @@ * you may not use this file except in compliance with the Elastic License. */ -import { IndexPattern } from 'ui/index_patterns'; import { SavedSearchSavedObject } from '../../../../../../common/types/kibana'; import { parseInterval } from '../../../../../../common/util/parse_interval'; import { JobCreator } from './job_creator'; @@ -17,6 +16,7 @@ import { } from '../../../../../../common/constants/aggregation_types'; import { JOB_TYPE, CREATED_BY_LABEL } from '../../../../../../common/constants/new_job'; import { getRichDetectors } from './util/general'; +import { IndexPattern } from '../../../../../../../../../../src/plugins/data/public'; export class SingleMetricJobCreator extends JobCreator { protected _type: JOB_TYPE = JOB_TYPE.SINGLE_METRIC; diff --git a/x-pack/legacy/plugins/ml/public/application/jobs/new_job/utils/new_job_utils.ts b/x-pack/legacy/plugins/ml/public/application/jobs/new_job/utils/new_job_utils.ts index 050387e6de263..d1e81c1c344de 100644 --- a/x-pack/legacy/plugins/ml/public/application/jobs/new_job/utils/new_job_utils.ts +++ b/x-pack/legacy/plugins/ml/public/application/jobs/new_job/utils/new_job_utils.ts @@ -4,8 +4,12 @@ * you may not use this file except in compliance with the Elastic License. */ -import { IndexPattern } from 'ui/index_patterns'; -import { esQuery, Query, esKuery } from '../../../../../../../../../src/plugins/data/public'; +import { + IndexPattern, + esQuery, + Query, + esKuery, +} from '../../../../../../../../../src/plugins/data/public'; import { KibanaConfigTypeFix } from '../../../contexts/kibana'; import { SEARCH_QUERY_LANGUAGE } from '../../../../../common/constants/search'; import { SavedSearchSavedObject } from '../../../../../common/types/kibana'; diff --git a/x-pack/legacy/plugins/ml/public/application/services/field_format_service.ts b/x-pack/legacy/plugins/ml/public/application/services/field_format_service.ts index a9ecf56c58ea7..11f0d59e04545 100644 --- a/x-pack/legacy/plugins/ml/public/application/services/field_format_service.ts +++ b/x-pack/legacy/plugins/ml/public/application/services/field_format_service.ts @@ -4,10 +4,10 @@ * you may not use this file except in compliance with the Elastic License. */ -import { IndexPattern } from 'ui/index_patterns'; import { mlFunctionToESAggregation } from '../../../common/util/job_utils'; import { getIndexPatternById, getIndexPatternIdFromName } from '../util/index_utils'; import { mlJobService } from './job_service'; +import { IndexPattern } from '../../../../../../../src/plugins/data/public'; type FormatsByJobId = Record; type IndexPatternIdsByJob = Record; diff --git a/x-pack/legacy/plugins/ml/public/application/services/new_job_capabilities._service.test.ts b/x-pack/legacy/plugins/ml/public/application/services/new_job_capabilities._service.test.ts index 91c945ea8ff29..5aeed3587b5a0 100644 --- a/x-pack/legacy/plugins/ml/public/application/services/new_job_capabilities._service.test.ts +++ b/x-pack/legacy/plugins/ml/public/application/services/new_job_capabilities._service.test.ts @@ -5,7 +5,7 @@ */ import { newJobCapsService } from './new_job_capabilities_service'; -import { IndexPattern } from 'ui/index_patterns'; +import { IndexPattern } from '../../../../../../../src/plugins/data/public'; // there is magic happening here. starting the include name with `mock..` // ensures it can be lazily loaded by the jest.mock function below. diff --git a/x-pack/legacy/plugins/ml/public/application/util/field_types_utils.test.ts b/x-pack/legacy/plugins/ml/public/application/util/field_types_utils.test.ts index 2abb8097598d2..14150edb977bd 100644 --- a/x-pack/legacy/plugins/ml/public/application/util/field_types_utils.test.ts +++ b/x-pack/legacy/plugins/ml/public/application/util/field_types_utils.test.ts @@ -4,8 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { FieldType } from 'ui/index_patterns'; -import { KBN_FIELD_TYPES } from '../../../../../../../src/plugins/data/public'; +import { IFieldType, KBN_FIELD_TYPES } from '../../../../../../../src/plugins/data/public'; import { ML_JOB_FIELD_TYPES } from '../../../common/constants/field_types'; import { kbnTypeToMLJobType, @@ -16,7 +15,7 @@ import { describe('ML - field type utils', () => { describe('kbnTypeToMLJobType', () => { test('returns correct ML_JOB_FIELD_TYPES for KBN_FIELD_TYPES', () => { - const field: FieldType = { + const field: IFieldType = { type: KBN_FIELD_TYPES.NUMBER, name: KBN_FIELD_TYPES.NUMBER, aggregatable: true, @@ -37,7 +36,7 @@ describe('ML - field type utils', () => { }); test('returns ML_JOB_FIELD_TYPES.KEYWORD for aggregatable KBN_FIELD_TYPES.STRING', () => { - const field: FieldType = { + const field: IFieldType = { type: KBN_FIELD_TYPES.STRING, name: KBN_FIELD_TYPES.STRING, aggregatable: true, @@ -46,7 +45,7 @@ describe('ML - field type utils', () => { }); test('returns ML_JOB_FIELD_TYPES.TEXT for non-aggregatable KBN_FIELD_TYPES.STRING', () => { - const field: FieldType = { + const field: IFieldType = { type: KBN_FIELD_TYPES.STRING, name: KBN_FIELD_TYPES.STRING, aggregatable: false, @@ -55,7 +54,7 @@ describe('ML - field type utils', () => { }); test('returns undefined for non-aggregatable "foo"', () => { - const field: FieldType = { + const field: IFieldType = { type: 'foo', name: 'foo', aggregatable: false, diff --git a/x-pack/legacy/plugins/ml/public/application/util/field_types_utils.ts b/x-pack/legacy/plugins/ml/public/application/util/field_types_utils.ts index e2b876aa8dbcd..e8fe2ffb1fed9 100644 --- a/x-pack/legacy/plugins/ml/public/application/util/field_types_utils.ts +++ b/x-pack/legacy/plugins/ml/public/application/util/field_types_utils.ts @@ -5,15 +5,14 @@ */ import { i18n } from '@kbn/i18n'; -import { FieldType } from 'ui/index_patterns'; import { ML_JOB_FIELD_TYPES } from '../../../common/constants/field_types'; -import { KBN_FIELD_TYPES } from '../../../../../../../src/plugins/data/public'; +import { IFieldType, KBN_FIELD_TYPES } from '../../../../../../../src/plugins/data/public'; // convert kibana types to ML Job types // this is needed because kibana types only have string and not text and keyword. // and we can't use ES_FIELD_TYPES because it has no NUMBER type -export function kbnTypeToMLJobType(field: FieldType) { +export function kbnTypeToMLJobType(field: IFieldType) { // Return undefined if not one of the supported data visualizer field types. let type; switch (field.type) { diff --git a/x-pack/legacy/plugins/rollup/__jest__/client_integration/job_create_logistics.test.js b/x-pack/legacy/plugins/rollup/__jest__/client_integration/job_create_logistics.test.js index 063f48dce337d..c960eabb37dcb 100644 --- a/x-pack/legacy/plugins/rollup/__jest__/client_integration/job_create_logistics.test.js +++ b/x-pack/legacy/plugins/rollup/__jest__/client_integration/job_create_logistics.test.js @@ -12,7 +12,7 @@ import { MONTH, YEAR, } from '../../../../../../src/plugins/es_ui_shared/public/components/cron_editor'; -import { INDEX_PATTERN_ILLEGAL_CHARACTERS_VISIBLE } from '../../../../../../src/legacy/ui/public/index_patterns'; +import { indexPatterns } from '../../../../../../src/plugins/data/public'; import { setupEnvironment, pageHelpers } from './helpers'; jest.mock('ui/new_platform'); @@ -154,7 +154,7 @@ describe('Create Rollup Job, step 1: Logistics', () => { ); }; - [...INDEX_PATTERN_ILLEGAL_CHARACTERS_VISIBLE, ','].reduce((promise, char) => { + [...indexPatterns.ILLEGAL_CHARACTERS_VISIBLE, ','].reduce((promise, char) => { return promise.then(() => expectInvalidChar(char)); }, Promise.resolve()); }); diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_create/steps/step_logistics.js b/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_create/steps/step_logistics.js index 75c70ab6ce20a..8cba18804b1c6 100644 --- a/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_create/steps/step_logistics.js +++ b/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_create/steps/step_logistics.js @@ -26,12 +26,13 @@ import { // eslint-disable-next-line @kbn/eslint/no-restricted-paths import { CronEditor } from '../../../../../../../../../src/plugins/es_ui_shared/public/components/cron_editor'; -import { INDEX_PATTERN_ILLEGAL_CHARACTERS_VISIBLE } from 'ui/index_patterns'; import { INDEX_ILLEGAL_CHARACTERS_VISIBLE } from 'ui/indices'; import { logisticalDetailsUrl, cronUrl } from '../../../services'; import { StepError } from './components'; -const indexPatternIllegalCharacters = INDEX_PATTERN_ILLEGAL_CHARACTERS_VISIBLE.join(' '); +import { indexPatterns } from '../../../../../../../../../src/plugins/data/public'; + +const indexPatternIllegalCharacters = indexPatterns.ILLEGAL_CHARACTERS_VISIBLE.join(' '); const indexIllegalCharacters = INDEX_ILLEGAL_CHARACTERS_VISIBLE.join(' '); export class StepLogisticsUi extends Component { diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_create/steps_config/validate_index_pattern.js b/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_create/steps_config/validate_index_pattern.js index 8082814abba51..206cc325813c0 100644 --- a/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_create/steps_config/validate_index_pattern.js +++ b/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_create/steps_config/validate_index_pattern.js @@ -7,8 +7,7 @@ import React from 'react'; import { FormattedMessage } from '@kbn/i18n/react'; -import { INDEX_PATTERN_ILLEGAL_CHARACTERS_VISIBLE } from 'ui/index_patterns'; - +import { indexPatterns } from '../../../../../../../../../src/plugins/data/public'; export function validateIndexPattern(indexPattern, rollupIndex) { if (!indexPattern || !indexPattern.trim()) { return [ @@ -28,7 +27,7 @@ export function validateIndexPattern(indexPattern, rollupIndex) { ]; } - const illegalCharacters = INDEX_PATTERN_ILLEGAL_CHARACTERS_VISIBLE.reduce((chars, char) => { + const illegalCharacters = indexPatterns.ILLEGAL_CHARACTERS_VISIBLE.reduce((chars, char) => { if (indexPattern.includes(char)) { chars.push(char); } diff --git a/x-pack/legacy/plugins/transform/public/app/common/request.ts b/x-pack/legacy/plugins/transform/public/app/common/request.ts index 5f0c778695523..5d508f3d245d3 100644 --- a/x-pack/legacy/plugins/transform/public/app/common/request.ts +++ b/x-pack/legacy/plugins/transform/public/app/common/request.ts @@ -6,14 +6,14 @@ import { DefaultOperator } from 'elasticsearch'; -import { IndexPattern } from 'ui/index_patterns'; - import { dictionaryToArray } from '../../../common/types/common'; import { SavedSearchQuery } from '../lib/kibana'; import { StepDefineExposedState } from '../sections/create_transform/components/step_define/step_define_form'; import { StepDetailsExposedState } from '../sections/create_transform/components/step_details/step_details_form'; +import { IndexPattern } from '../../../../../../../src/plugins/data/public'; + import { getEsAggFromAggConfig, getEsAggFromGroupByConfig, diff --git a/x-pack/legacy/plugins/transform/public/app/lib/kibana/common.ts b/x-pack/legacy/plugins/transform/public/app/lib/kibana/common.ts index 62c87413c9bce..3e55d509a94ab 100644 --- a/x-pack/legacy/plugins/transform/public/app/lib/kibana/common.ts +++ b/x-pack/legacy/plugins/transform/public/app/lib/kibana/common.ts @@ -5,8 +5,11 @@ */ import { SavedObjectsClientContract, IUiSettingsClient } from 'src/core/public'; -import { IndexPattern as IndexPatternType } from 'ui/index_patterns'; -import { esQuery, IndexPatternsContract } from '../../../../../../../../src/plugins/data/public'; +import { + IndexPattern, + esQuery, + IndexPatternsContract, +} from '../../../../../../../../src/plugins/data/public'; type IndexPatternId = string; type SavedSearchId = string; @@ -68,7 +71,7 @@ export function loadCurrentSavedSearch(savedSearches: any, savedSearchId: SavedS // Helper for creating the items used for searching and job creation. export function createSearchItems( - indexPattern: IndexPatternType | undefined, + indexPattern: IndexPattern | undefined, savedSearch: any, config: IUiSettingsClient ) { diff --git a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/step_define/common.test.ts b/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/step_define/common.test.ts index c1a7fb3424c3a..78ad217a69e3d 100644 --- a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/step_define/common.test.ts +++ b/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/step_define/common.test.ts @@ -14,7 +14,7 @@ import { } from '../../../../common'; import { getPivotPreviewDevConsoleStatement, getPivotDropdownOptions } from './common'; -import { IndexPattern } from 'ui/index_patterns'; +import { IndexPattern } from '../../../../../../../../../../src/plugins/data/public'; describe('Transform: Define Pivot Common', () => { test('getPivotDropdownOptions()', () => { diff --git a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/step_define/common.ts b/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/step_define/common.ts index 54b810b7b6686..b4b03c1f0d571 100644 --- a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/step_define/common.ts +++ b/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/step_define/common.ts @@ -5,10 +5,10 @@ */ import { get } from 'lodash'; import { EuiComboBoxOptionProps } from '@elastic/eui'; - -import { IndexPattern } from 'ui/index_patterns'; - -import { KBN_FIELD_TYPES } from '../../../../../../../../../../src/plugins/data/public'; +import { + IndexPattern, + KBN_FIELD_TYPES, +} from '../../../../../../../../../../src/plugins/data/public'; import { PreviewRequestBody, diff --git a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/step_define/use_pivot_preview_data.test.tsx b/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/step_define/use_pivot_preview_data.test.tsx index 824ff0462cbba..1ad8ed099b241 100644 --- a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/step_define/use_pivot_preview_data.test.tsx +++ b/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/step_define/use_pivot_preview_data.test.tsx @@ -14,7 +14,7 @@ import { UsePivotPreviewDataReturnType, } from './use_pivot_preview_data'; -import { IndexPattern } from 'ui/index_patterns'; +import { IndexPattern } from '../../../../../../../../../../src/plugins/data/public'; jest.mock('../../../../hooks/use_api'); diff --git a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/step_define/use_pivot_preview_data.ts b/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/step_define/use_pivot_preview_data.ts index e02f2473fc10b..84fafcad8151e 100644 --- a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/step_define/use_pivot_preview_data.ts +++ b/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/step_define/use_pivot_preview_data.ts @@ -6,13 +6,15 @@ import { useEffect, useState } from 'react'; -import { IndexPattern } from 'ui/index_patterns'; - import { dictionaryToArray } from '../../../../../../common/types/common'; import { useApi } from '../../../../hooks/use_api'; import { Dictionary } from '../../../../../../common/types/common'; -import { ES_FIELD_TYPES } from '../../../../../../../../../../src/plugins/data/public'; +import { + IndexPattern, + ES_FIELD_TYPES, +} from '../../../../../../../../../../src/plugins/data/public'; + import { getPreviewRequestBody, PreviewRequestBody,