From 235550112e0ac8c0c2548220f3029324ffe98f81 Mon Sep 17 00:00:00 2001 From: Diana Derevyankina <54894989+DziyanaDzeraviankina@users.noreply.github.com> Date: Tue, 3 May 2022 15:00:18 +0300 Subject: [PATCH] Fix imports from restricted paths (#130102) * Fix imports from restricted paths * Re-export EmbeddableRegistryDefinition from embedabble server and fix some imports Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> --- src/plugins/embeddable/common/index.ts | 1 + src/plugins/embeddable/common/types.ts | 12 +++++++++++- src/plugins/embeddable/server/index.ts | 4 +++- src/plugins/embeddable/server/plugin.ts | 7 +++++-- src/plugins/embeddable/server/types.ts | 6 ------ src/plugins/visualizations/common/types.ts | 5 ++--- .../make_visualize_embeddable_factory.test.ts | 5 ++--- .../embeddable/make_visualize_embeddable_factory.ts | 5 ++--- .../plugins/lens/common/embeddable_factory/index.ts | 7 ++++--- .../expressions/counter_rate/counter_rate.test.ts | 3 +-- .../expressions/format_column/format_column.test.ts | 3 +-- .../expressions/merge_tables/merge_tables.test.ts | 3 +-- .../common/expressions/time_scale/time_scale.test.ts | 6 ++---- .../server/migrations/saved_object_migrations.ts | 4 +--- x-pack/plugins/lens/server/migrations/types.ts | 4 +--- x-pack/plugins/maps/common/embeddable/extract.ts | 3 +-- x-pack/plugins/maps/common/embeddable/inject.ts | 7 +++---- 17 files changed, 41 insertions(+), 44 deletions(-) diff --git a/src/plugins/embeddable/common/index.ts b/src/plugins/embeddable/common/index.ts index 4eed6531cf7d55..ad362a0d8dc7ca 100644 --- a/src/plugins/embeddable/common/index.ts +++ b/src/plugins/embeddable/common/index.ts @@ -12,6 +12,7 @@ export type { EmbeddableStateWithType, PanelState, EmbeddablePersistableStateService, + EmbeddableRegistryDefinition, } from './types'; export { ViewMode } from './types'; export type { SavedObjectEmbeddableInput } from './lib'; diff --git a/src/plugins/embeddable/common/types.ts b/src/plugins/embeddable/common/types.ts index 1984619c12074e..c37b3ee2b720cd 100644 --- a/src/plugins/embeddable/common/types.ts +++ b/src/plugins/embeddable/common/types.ts @@ -8,7 +8,11 @@ import type { SerializableRecord } from '@kbn/utility-types'; import type { KibanaExecutionContext } from '@kbn/core/public'; -import { PersistableStateService, PersistableState } from '@kbn/kibana-utils-plugin/common'; +import type { + PersistableStateService, + PersistableState, + PersistableStateDefinition, +} from '@kbn/kibana-utils-plugin/common'; export enum ViewMode { EDIT = 'edit', @@ -74,6 +78,12 @@ export interface PanelState extends PersistableStateDefinition

{ + id: string; +} + export type EmbeddablePersistableStateService = PersistableStateService; export interface CommonEmbeddableStartContract { diff --git a/src/plugins/embeddable/server/index.ts b/src/plugins/embeddable/server/index.ts index 8d88f35a4be224..4b93f0838c649c 100644 --- a/src/plugins/embeddable/server/index.ts +++ b/src/plugins/embeddable/server/index.ts @@ -10,6 +10,8 @@ import { EmbeddableServerPlugin, EmbeddableSetup, EmbeddableStart } from './plug export type { EmbeddableSetup, EmbeddableStart }; -export type { EnhancementRegistryDefinition, EmbeddableRegistryDefinition } from './types'; +export type { EnhancementRegistryDefinition } from './types'; + +export type { EmbeddableRegistryDefinition } from '../common'; export const plugin = () => new EmbeddableServerPlugin(); diff --git a/src/plugins/embeddable/server/plugin.ts b/src/plugins/embeddable/server/plugin.ts index 51fa1edb2c634a..2260d6b34c8e8e 100644 --- a/src/plugins/embeddable/server/plugin.ts +++ b/src/plugins/embeddable/server/plugin.ts @@ -19,7 +19,6 @@ import { EnhancementsRegistry, EnhancementRegistryDefinition, EnhancementRegistryItem, - EmbeddableRegistryDefinition, } from './types'; import { getExtractFunction, @@ -27,7 +26,11 @@ import { getMigrateFunction, getTelemetryFunction, } from '../common/lib'; -import { EmbeddableStateWithType, CommonEmbeddableStartContract } from '../common/types'; +import { + EmbeddableStateWithType, + CommonEmbeddableStartContract, + EmbeddableRegistryDefinition, +} from '../common/types'; import { getAllMigrations } from '../common/lib/get_all_migrations'; export interface EmbeddableSetup extends PersistableStateService { diff --git a/src/plugins/embeddable/server/types.ts b/src/plugins/embeddable/server/types.ts index 9b0479d6bc25d8..bd78265bea6b1e 100644 --- a/src/plugins/embeddable/server/types.ts +++ b/src/plugins/embeddable/server/types.ts @@ -23,12 +23,6 @@ export interface EnhancementRegistryItem

extends PersistableStateDefinition

{ - id: string; -} - export interface EmbeddableRegistryItem

extends PersistableState

{ id: string; diff --git a/src/plugins/visualizations/common/types.ts b/src/plugins/visualizations/common/types.ts index 978e424477be6c..8aa03470b2094e 100644 --- a/src/plugins/visualizations/common/types.ts +++ b/src/plugins/visualizations/common/types.ts @@ -6,10 +6,9 @@ * Side Public License, v 1. */ -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { SavedObjectAttributes } from '@kbn/core/server'; import type { SerializableRecord } from '@kbn/utility-types'; -import { AggConfigSerialized, SerializedSearchSourceFields } from '@kbn/data-plugin/common'; +import type { AggConfigSerialized, SerializedSearchSourceFields } from '@kbn/data-plugin/common'; +import type { SavedObjectAttributes } from '@kbn/core/types'; export interface VisParams { [key: string]: any; diff --git a/src/plugins/visualizations/server/embeddable/make_visualize_embeddable_factory.test.ts b/src/plugins/visualizations/server/embeddable/make_visualize_embeddable_factory.test.ts index 42fcc34984b4da..d8a1fc51cd6db9 100644 --- a/src/plugins/visualizations/server/embeddable/make_visualize_embeddable_factory.test.ts +++ b/src/plugins/visualizations/server/embeddable/make_visualize_embeddable_factory.test.ts @@ -9,9 +9,8 @@ import semverGte from 'semver/functions/gte'; import { makeVisualizeEmbeddableFactory } from './make_visualize_embeddable_factory'; import { getAllMigrations } from '../migrations/visualization_saved_object_migrations'; -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { SerializedSearchSourceFields } from '@kbn/data-plugin/public'; -import { GetMigrationFunctionObjectFn } from '@kbn/kibana-utils-plugin/common'; +import type { SerializedSearchSourceFields } from '@kbn/data-plugin/common'; +import type { GetMigrationFunctionObjectFn } from '@kbn/kibana-utils-plugin/common'; describe('embeddable migrations', () => { test('should have same versions registered as saved object migrations versions (>7.13.0)', () => { diff --git a/src/plugins/visualizations/server/embeddable/make_visualize_embeddable_factory.ts b/src/plugins/visualizations/server/embeddable/make_visualize_embeddable_factory.ts index e9dd45e1f84fc2..d92810743bed49 100644 --- a/src/plugins/visualizations/server/embeddable/make_visualize_embeddable_factory.ts +++ b/src/plugins/visualizations/server/embeddable/make_visualize_embeddable_factory.ts @@ -7,10 +7,9 @@ */ import { flow, mapValues } from 'lodash'; -import { EmbeddableRegistryDefinition } from '@kbn/embeddable-plugin/server'; +import type { EmbeddableRegistryDefinition } from '@kbn/embeddable-plugin/server'; import type { SerializableRecord } from '@kbn/utility-types'; -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { SerializedSearchSourceFields } from '@kbn/data-plugin/public'; +import type { SerializedSearchSourceFields } from '@kbn/data-plugin/common'; import { mergeMigrationFunctionMaps, MigrateFunctionsObject, diff --git a/x-pack/plugins/lens/common/embeddable_factory/index.ts b/x-pack/plugins/lens/common/embeddable_factory/index.ts index c4b03ae2807785..8ddddf654b017b 100644 --- a/x-pack/plugins/lens/common/embeddable_factory/index.ts +++ b/x-pack/plugins/lens/common/embeddable_factory/index.ts @@ -7,9 +7,10 @@ import { SerializableRecord, Serializable } from '@kbn/utility-types'; import { SavedObjectReference } from '@kbn/core/types'; -import { EmbeddableStateWithType } from '@kbn/embeddable-plugin/common'; -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { EmbeddableRegistryDefinition } from '@kbn/embeddable-plugin/server'; +import type { + EmbeddableStateWithType, + EmbeddableRegistryDefinition, +} from '@kbn/embeddable-plugin/common'; export type LensEmbeddablePersistableState = EmbeddableStateWithType & { attributes: SerializableRecord; diff --git a/x-pack/plugins/lens/common/expressions/counter_rate/counter_rate.test.ts b/x-pack/plugins/lens/common/expressions/counter_rate/counter_rate.test.ts index 32a37e0cf949ef..9f19b5d052c689 100644 --- a/x-pack/plugins/lens/common/expressions/counter_rate/counter_rate.test.ts +++ b/x-pack/plugins/lens/common/expressions/counter_rate/counter_rate.test.ts @@ -7,8 +7,7 @@ import { counterRate, CounterRateArgs } from '.'; -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { Datatable } from '@kbn/expressions-plugin/public'; +import { Datatable } from '@kbn/expressions-plugin/common'; import { functionWrapper } from '@kbn/expressions-plugin/common/expression_functions/specs/tests/utils'; describe('lens_counter_rate', () => { diff --git a/x-pack/plugins/lens/common/expressions/format_column/format_column.test.ts b/x-pack/plugins/lens/common/expressions/format_column/format_column.test.ts index 63e32ffbf1df66..d0db49f4afaae9 100644 --- a/x-pack/plugins/lens/common/expressions/format_column/format_column.test.ts +++ b/x-pack/plugins/lens/common/expressions/format_column/format_column.test.ts @@ -5,8 +5,7 @@ * 2.0. */ -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { Datatable, DatatableColumn } from '@kbn/expressions-plugin/public'; +import type { Datatable, DatatableColumn } from '@kbn/expressions-plugin/common'; import { functionWrapper } from '@kbn/expressions-plugin/common/expression_functions/specs/tests/utils'; import { formatColumn } from '.'; diff --git a/x-pack/plugins/lens/common/expressions/merge_tables/merge_tables.test.ts b/x-pack/plugins/lens/common/expressions/merge_tables/merge_tables.test.ts index 4c8a3bf9aa3107..4558bdfe68661a 100644 --- a/x-pack/plugins/lens/common/expressions/merge_tables/merge_tables.test.ts +++ b/x-pack/plugins/lens/common/expressions/merge_tables/merge_tables.test.ts @@ -7,8 +7,7 @@ import moment from 'moment'; import { mergeTables } from '.'; -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { ExpressionValueSearchContext } from '@kbn/data-plugin/public'; +import type { ExpressionValueSearchContext } from '@kbn/data-plugin/common'; import { Datatable, ExecutionContext, diff --git a/x-pack/plugins/lens/common/expressions/time_scale/time_scale.test.ts b/x-pack/plugins/lens/common/expressions/time_scale/time_scale.test.ts index dd3e18c720c0a4..e7fdd720d075c7 100644 --- a/x-pack/plugins/lens/common/expressions/time_scale/time_scale.test.ts +++ b/x-pack/plugins/lens/common/expressions/time_scale/time_scale.test.ts @@ -6,10 +6,8 @@ */ import moment from 'moment'; -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -import type { Datatable } from '@kbn/expressions-plugin/public'; -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -import type { TimeRange } from '@kbn/data-plugin/public'; +import type { Datatable } from '@kbn/expressions-plugin/common'; +import type { TimeRange } from '@kbn/data-plugin/common'; import { functionWrapper } from '@kbn/expressions-plugin/common/expression_functions/specs/tests/utils'; // mock the specific inner variable: diff --git a/x-pack/plugins/lens/server/migrations/saved_object_migrations.ts b/x-pack/plugins/lens/server/migrations/saved_object_migrations.ts index f5fa4b27447ac1..f76381406b1324 100644 --- a/x-pack/plugins/lens/server/migrations/saved_object_migrations.ts +++ b/x-pack/plugins/lens/server/migrations/saved_object_migrations.ts @@ -13,9 +13,7 @@ import { SavedObjectReference, SavedObjectUnsanitizedDoc, } from '@kbn/core/server'; -import { Filter } from '@kbn/es-query'; -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { Query } from '@kbn/data-plugin/public'; +import type { Query, Filter } from '@kbn/es-query'; import { mergeSavedObjectMigrationMaps } from '@kbn/core/server'; import { MigrateFunctionsObject } from '@kbn/kibana-utils-plugin/common'; import { PersistableFilter } from '../../common'; diff --git a/x-pack/plugins/lens/server/migrations/types.ts b/x-pack/plugins/lens/server/migrations/types.ts index 9b66f7023cdeba..5bdc332668621d 100644 --- a/x-pack/plugins/lens/server/migrations/types.ts +++ b/x-pack/plugins/lens/server/migrations/types.ts @@ -6,9 +6,7 @@ */ import type { PaletteOutput, CustomPaletteParams } from '@kbn/coloring'; -import { Filter } from '@kbn/es-query'; -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { Query } from '@kbn/data-plugin/public'; +import type { Query, Filter } from '@kbn/es-query'; import type { MigrateFunctionsObject } from '@kbn/kibana-utils-plugin/common'; import type { LayerType, PersistableFilter } from '../../common'; diff --git a/x-pack/plugins/maps/common/embeddable/extract.ts b/x-pack/plugins/maps/common/embeddable/extract.ts index e73b1566c02896..d329aefe7cff61 100644 --- a/x-pack/plugins/maps/common/embeddable/extract.ts +++ b/x-pack/plugins/maps/common/embeddable/extract.ts @@ -5,8 +5,7 @@ * 2.0. */ -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { EmbeddableRegistryDefinition } from '@kbn/embeddable-plugin/server'; +import { EmbeddableRegistryDefinition } from '@kbn/embeddable-plugin/common'; import { MapEmbeddablePersistableState } from './types'; import { MapSavedObjectAttributes } from '../map_saved_object_type'; import { extractReferences } from '../migrations/references'; diff --git a/x-pack/plugins/maps/common/embeddable/inject.ts b/x-pack/plugins/maps/common/embeddable/inject.ts index 2e1892b95a0f1b..4bb26dd00d28de 100644 --- a/x-pack/plugins/maps/common/embeddable/inject.ts +++ b/x-pack/plugins/maps/common/embeddable/inject.ts @@ -5,10 +5,9 @@ * 2.0. */ -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { EmbeddableRegistryDefinition } from '@kbn/embeddable-plugin/server'; -import { MapEmbeddablePersistableState } from './types'; -import { MapSavedObjectAttributes } from '../map_saved_object_type'; +import type { EmbeddableRegistryDefinition } from '@kbn/embeddable-plugin/common'; +import type { MapEmbeddablePersistableState } from './types'; +import type { MapSavedObjectAttributes } from '../map_saved_object_type'; import { extractReferences, injectReferences } from '../migrations/references'; export const inject: EmbeddableRegistryDefinition['inject'] = (state, references) => {