Skip to content

Commit

Permalink
[maps] move registerLayerWizard and registerSource to MapsSetupApi
Browse files Browse the repository at this point in the history
  • Loading branch information
nreese committed Sep 16, 2021
1 parent fc87fe0 commit f3598ca
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 9 deletions.
1 change: 1 addition & 0 deletions x-pack/plugins/maps/public/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

export { MapsStartApi } from './start_api';
export { MapsSetupApi } from './setup_api';
export { createLayerDescriptors } from './create_layer_descriptors';
export { registerLayerWizard, registerSource } from './register';
export { suggestEMSTermJoinConfig } from './ems';
14 changes: 14 additions & 0 deletions x-pack/plugins/maps/public/api/setup_api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* 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; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import type { SourceRegistryEntry } from '../classes/sources/source_registry';
import type { LayerWizard } from '../classes/layers/layer_wizard_registry';

export interface MapsSetupApi {
registerLayerWizard(layerWizard: LayerWizard): Promise<void>;
registerSource(entry: SourceRegistryEntry): Promise<void>;
}
4 changes: 0 additions & 4 deletions x-pack/plugins/maps/public/api/start_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
*/

import type { LayerDescriptor } from '../../common/descriptor_types';
import type { SourceRegistryEntry } from '../classes/sources/source_registry';
import type { LayerWizard } from '../classes/layers/layer_wizard_registry';
import type { CreateLayerDescriptorParams } from '../classes/sources/es_search_source';
import type { SampleValuesConfig, EMSTermJoinConfig } from '../ems_autosuggest';

Expand All @@ -22,7 +20,5 @@ export interface MapsStartApi {
params: CreateLayerDescriptorParams
) => Promise<LayerDescriptor>;
};
registerLayerWizard(layerWizard: LayerWizard): Promise<void>;
registerSource(entry: SourceRegistryEntry): Promise<void>;
suggestEMSTermJoinConfig(config: SampleValuesConfig): Promise<EMSTermJoinConfig | null>;
}
13 changes: 11 additions & 2 deletions x-pack/plugins/maps/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,20 @@ export const plugin: PluginInitializer<MapsPluginSetup, MapsPluginStart> = (
};

export { MAP_SAVED_OBJECT_TYPE } from '../common/constants';
export type { PreIndexedShape } from '../common/elasticsearch_util';

export type { RenderTooltipContentParams } from './classes/tooltips/tooltip_property';
export type { ITooltipProperty, RenderTooltipContentParams } from './classes/tooltips/tooltip_property';

export { MapsStartApi } from './api';
export type { MapsSetupApi, MapsStartApi } from './api';

export type { MapEmbeddable, MapEmbeddableInput, MapEmbeddableOutput } from './embeddable';

export type { EMSTermJoinConfig, SampleValuesConfig } from './ems_autosuggest';

export type { IVectorSource, GeoJsonWithMeta } from './classes/sources/vector_source/vector_source';
export type { ImmutableSourceProperty, SourceEditorArgs } from './classes/sources/source';
export type { Attribution } from '../common/descriptor_types';
export type { BoundsRequestMeta, SourceTooltipConfig } from './classes/sources/vector_source/vector_source';
export type { IField } from './classes/fields/field';
export type { LayerWizard, RenderWizardArguments } from './classes/layers/layer_wizard_registry';
export type { DataRequest } from './classes/util/data_request';
10 changes: 7 additions & 3 deletions x-pack/plugins/maps/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import {
createLayerDescriptors,
registerLayerWizard,
registerSource,
MapsSetupApi,
MapsStartApi,
suggestEMSTermJoinConfig,
} from './api';
Expand Down Expand Up @@ -137,7 +138,7 @@ export class MapsPlugin
this._initializerContext = initializerContext;
}

public setup(core: CoreSetup, plugins: MapsPluginSetupDependencies) {
public setup(core: CoreSetup, plugins: MapsPluginSetupDependencies): MapsSetupApi {
registerLicensedFeatures(plugins.licensing);

const config = this._initializerContext.config.get<MapsConfigType>();
Expand Down Expand Up @@ -193,6 +194,11 @@ export class MapsPlugin
plugins.expressions.registerFunction(createTileMapFn);
plugins.expressions.registerRenderer(tileMapRenderer);
plugins.visualizations.createBaseVisualization(tileMapVisType);

return {
registerLayerWizard,
registerSource,
};
}

public start(core: CoreStart, plugins: MapsPluginStartDependencies): MapsStartApi {
Expand All @@ -210,8 +216,6 @@ export class MapsPlugin

return {
createLayerDescriptors,
registerLayerWizard,
registerSource,
suggestEMSTermJoinConfig,
};
}
Expand Down

0 comments on commit f3598ca

Please sign in to comment.