From a66310a4e12739a7a89aca6deac43244fc041067 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Fern=C3=A1ndez=20Haro?= Date: Fri, 30 Aug 2024 00:20:01 +0200 Subject: [PATCH 1/2] [Move `@kbn/config-schema` to server] `discover` --- src/plugins/discover/common/config.ts | 22 ------------------- .../public/application/discover_router.tsx | 2 +- .../discover/public/application/index.tsx | 2 +- src/plugins/discover/public/plugin.tsx | 2 +- src/plugins/discover/server/config.ts | 15 ++++++++++++- 5 files changed, 17 insertions(+), 26 deletions(-) delete mode 100644 src/plugins/discover/common/config.ts diff --git a/src/plugins/discover/common/config.ts b/src/plugins/discover/common/config.ts deleted file mode 100644 index 272f81b77d5a..000000000000 --- a/src/plugins/discover/common/config.ts +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0 and the Server Side Public License, v 1; you may not use this file except - * in compliance with, at your election, the Elastic License 2.0 or the Server - * Side Public License, v 1. - */ - -import { schema, TypeOf } from '@kbn/config-schema'; - -export const configSchema = schema.object({ - enableUiSettingsValidations: schema.boolean({ defaultValue: false }), - experimental: schema.maybe( - schema.object({ - ruleFormV2Enabled: schema.maybe(schema.boolean({ defaultValue: false })), - enabledProfiles: schema.maybe(schema.arrayOf(schema.string(), { defaultValue: [] })), - }) - ), -}); - -export type ConfigSchema = TypeOf; -export type ExperimentalFeatures = NonNullable; diff --git a/src/plugins/discover/public/application/discover_router.tsx b/src/plugins/discover/public/application/discover_router.tsx index 7a158c05525a..a760118f1290 100644 --- a/src/plugins/discover/public/application/discover_router.tsx +++ b/src/plugins/discover/public/application/discover_router.tsx @@ -14,7 +14,7 @@ import { EuiErrorBoundary } from '@elastic/eui'; import { KibanaContextProvider } from '@kbn/kibana-react-plugin/public'; import useObservable from 'react-use/lib/useObservable'; import type { Observable } from 'rxjs'; -import { ExperimentalFeatures } from '../../common/config'; +import type { ExperimentalFeatures } from '../../server/config'; import { ContextAppRoute } from './context'; import { SingleDocRoute } from './doc'; import { DiscoverMainRoute } from './main'; diff --git a/src/plugins/discover/public/application/index.tsx b/src/plugins/discover/public/application/index.tsx index db7d9cb86ff7..0b8f767bf1de 100644 --- a/src/plugins/discover/public/application/index.tsx +++ b/src/plugins/discover/public/application/index.tsx @@ -10,7 +10,7 @@ import React from 'react'; import { i18n } from '@kbn/i18n'; import { toMountPoint } from '@kbn/react-kibana-mount'; import type { Observable } from 'rxjs'; -import { ExperimentalFeatures } from '../../common/config'; +import type { ExperimentalFeatures } from '../../server/config'; import { DiscoverRouter } from './discover_router'; import { DiscoverServices } from '../build_services'; import type { DiscoverCustomizationContext } from '../customizations'; diff --git a/src/plugins/discover/public/plugin.tsx b/src/plugins/discover/public/plugin.tsx index 61a205be2cff..ab10c04459b9 100644 --- a/src/plugins/discover/public/plugin.tsx +++ b/src/plugins/discover/public/plugin.tsx @@ -51,7 +51,7 @@ import { } from './components/discover_container'; import { getESQLSearchProvider } from './global_search/search_provider'; import { HistoryService } from './history_service'; -import { ConfigSchema, ExperimentalFeatures } from '../common/config'; +import type { ConfigSchema, ExperimentalFeatures } from '../server/config'; import { DataSourceProfileService, DocumentProfileService, diff --git a/src/plugins/discover/server/config.ts b/src/plugins/discover/server/config.ts index 1203502538a6..35e854b87be1 100644 --- a/src/plugins/discover/server/config.ts +++ b/src/plugins/discover/server/config.ts @@ -7,7 +7,20 @@ */ import { PluginConfigDescriptor } from '@kbn/core-plugins-server'; -import { configSchema, type ConfigSchema } from '../common/config'; +import { schema, TypeOf } from '@kbn/config-schema'; + +export const configSchema = schema.object({ + enableUiSettingsValidations: schema.boolean({ defaultValue: false }), + experimental: schema.maybe( + schema.object({ + ruleFormV2Enabled: schema.maybe(schema.boolean({ defaultValue: false })), + enabledProfiles: schema.maybe(schema.arrayOf(schema.string(), { defaultValue: [] })), + }) + ), +}); + +export type ConfigSchema = TypeOf; +export type ExperimentalFeatures = NonNullable; export const config: PluginConfigDescriptor = { schema: configSchema, From 4a672c811fbabbfa3372aa3467cbc9784bd9755b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Fern=C3=A1ndez=20Haro?= Date: Fri, 30 Aug 2024 01:05:37 +0200 Subject: [PATCH 2/2] Fix import --- src/plugins/discover/server/plugin.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/discover/server/plugin.ts b/src/plugins/discover/server/plugin.ts index 0ffb4bb303a9..dd5c7702f1fc 100644 --- a/src/plugins/discover/server/plugin.ts +++ b/src/plugins/discover/server/plugin.ts @@ -20,7 +20,7 @@ import { createSearchEmbeddableFactory } from './embeddable'; import { initializeLocatorServices } from './locator'; import { registerSampleData } from './sample_data'; import { getUiSettings } from './ui_settings'; -import { ConfigSchema } from '../common/config'; +import type { ConfigSchema } from './config'; export class DiscoverServerPlugin implements Plugin