Skip to content

Commit

Permalink
Fix imports from restricted paths (#130102)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
DianaDerevyankina and kibanamachine authored May 3, 2022
1 parent 0558903 commit 2355501
Show file tree
Hide file tree
Showing 17 changed files with 41 additions and 44 deletions.
1 change: 1 addition & 0 deletions src/plugins/embeddable/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export type {
EmbeddableStateWithType,
PanelState,
EmbeddablePersistableStateService,
EmbeddableRegistryDefinition,
} from './types';
export { ViewMode } from './types';
export type { SavedObjectEmbeddableInput } from './lib';
Expand Down
12 changes: 11 additions & 1 deletion src/plugins/embeddable/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -74,6 +78,12 @@ export interface PanelState<E extends EmbeddableInput & { id: string } = { id: s

export type EmbeddableStateWithType = EmbeddableInput & { type: string };

export interface EmbeddableRegistryDefinition<
P extends EmbeddableStateWithType = EmbeddableStateWithType
> extends PersistableStateDefinition<P> {
id: string;
}

export type EmbeddablePersistableStateService = PersistableStateService<EmbeddableStateWithType>;

export interface CommonEmbeddableStartContract {
Expand Down
4 changes: 3 additions & 1 deletion src/plugins/embeddable/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
7 changes: 5 additions & 2 deletions src/plugins/embeddable/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,18 @@ import {
EnhancementsRegistry,
EnhancementRegistryDefinition,
EnhancementRegistryItem,
EmbeddableRegistryDefinition,
} from './types';
import {
getExtractFunction,
getInjectFunction,
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<EmbeddableStateWithType> {
Expand Down
6 changes: 0 additions & 6 deletions src/plugins/embeddable/server/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,6 @@ export interface EnhancementRegistryItem<P extends SerializableRecord = Serializ
id: string;
}

export interface EmbeddableRegistryDefinition<
P extends EmbeddableStateWithType = EmbeddableStateWithType
> extends PersistableStateDefinition<P> {
id: string;
}

export interface EmbeddableRegistryItem<P extends EmbeddableStateWithType = EmbeddableStateWithType>
extends PersistableState<P> {
id: string;
Expand Down
5 changes: 2 additions & 3 deletions src/plugins/visualizations/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
7 changes: 4 additions & 3 deletions x-pack/plugins/lens/common/embeddable_factory/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 '.';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
4 changes: 1 addition & 3 deletions x-pack/plugins/lens/server/migrations/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
3 changes: 1 addition & 2 deletions x-pack/plugins/maps/common/embeddable/extract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
7 changes: 3 additions & 4 deletions x-pack/plugins/maps/common/embeddable/inject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down

0 comments on commit 2355501

Please sign in to comment.