[Maps] Isolate maps-setting froms maps_legacy (#92918)

Creates a new plugins, maps_ems, with `map.*` configs and shared EMS-settings. `maps_legacy` now only supports the `region_map` and `coordinate_map` plugins.
This commit is contained in:
Thomas Neirynck 2021-03-15 11:15:39 -04:00 committed by GitHub
parent ae1f284118
commit e1363855bf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
80 changed files with 550 additions and 350 deletions

View file

@ -142,6 +142,10 @@ to link individual managment section into it. This plugin does not contain any i
management section itself.
|{kib-repo}blob/{branch}/src/plugins/maps_ems/README.md[mapsEms]
|Configuration of kibana-wide EMS settings and some higher level utilities.
|{kib-repo}blob/{branch}/src/plugins/maps_legacy/README.md[mapsLegacy]
|Internal objects used by the Coordinate, Region, and Vega visualizations.

View file

@ -50,7 +50,7 @@ pageLoadAssetSize:
logstash: 53548
management: 46112
maps: 183610
mapsLegacy: 116817
mapsLegacy: 87859
mapsLegacyLicensing: 20214
ml: 82187
monitoring: 80000
@ -107,3 +107,4 @@ pageLoadAssetSize:
osquery: 107090
fileUpload: 25664
banners: 17946
mapsEms: 26072

View file

@ -0,0 +1,3 @@
# Maps EMS
Configuration of kibana-wide EMS settings and some higher level utilities.

View file

@ -8,4 +8,5 @@
export const TMS_IN_YML_ID = 'TMS in config/kibana.yml';
export * from './ems_defaults';
export { ORIGIN } from './origin';

View file

@ -0,0 +1,87 @@
/*
* 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';
import {
DEFAULT_EMS_FONT_LIBRARY_URL,
DEFAULT_EMS_LANDING_PAGE_URL,
DEFAULT_EMS_TILE_API_URL,
DEFAULT_EMS_FILE_API_URL,
} from './common';
const tileMapConfigOptionsSchema = schema.object({
attribution: schema.string({ defaultValue: '' }),
minZoom: schema.number({ defaultValue: 0, min: 0 }),
maxZoom: schema.number({ defaultValue: 10 }),
tileSize: schema.maybe(schema.number()),
subdomains: schema.maybe(schema.arrayOf(schema.string())),
errorTileUrl: schema.maybe(schema.string()),
tms: schema.maybe(schema.boolean()),
reuseTiles: schema.maybe(schema.boolean()),
bounds: schema.maybe(schema.arrayOf(schema.number({ min: 2 }))),
default: schema.maybe(schema.boolean()),
});
export const tilemapConfigSchema = schema.object({
url: schema.maybe(schema.string()),
options: tileMapConfigOptionsSchema,
});
const layerConfigSchema = schema.object({
url: schema.string(),
format: schema.object({
type: schema.string({ defaultValue: 'geojson' }),
}),
meta: schema.object({
feature_collection_path: schema.string({ defaultValue: 'data' }),
}),
attribution: schema.string(),
name: schema.string(),
fields: schema.arrayOf(
schema.object({
name: schema.string(),
description: schema.string(),
})
),
});
export type LayerConfig = TypeOf<typeof layerConfigSchema>;
const regionmapConfigSchema = schema.object({
includeElasticMapsService: schema.boolean({ defaultValue: true }),
layers: schema.arrayOf(layerConfigSchema, { defaultValue: [] }),
});
export const emsConfigSchema = schema.object({
regionmap: regionmapConfigSchema,
tilemap: tilemapConfigSchema,
includeElasticMapsService: schema.boolean({ defaultValue: true }),
proxyElasticMapsServiceInMaps: schema.boolean({ defaultValue: false }),
manifestServiceUrl: schema.string({ defaultValue: '' }),
emsUrl: schema.conditional(
schema.siblingRef('proxyElasticMapsServiceInMaps'),
true,
schema.never(),
schema.string({ defaultValue: '' })
),
emsFileApiUrl: schema.string({ defaultValue: DEFAULT_EMS_FILE_API_URL }),
emsTileApiUrl: schema.string({ defaultValue: DEFAULT_EMS_TILE_API_URL }),
emsLandingPageUrl: schema.string({ defaultValue: DEFAULT_EMS_LANDING_PAGE_URL }),
emsFontLibraryUrl: schema.string({
defaultValue: DEFAULT_EMS_FONT_LIBRARY_URL,
}),
emsTileLayerId: schema.object({
bright: schema.string({ defaultValue: 'road_map' }),
desaturated: schema.string({ defaultValue: 'road_map_desaturated' }),
dark: schema.string({ defaultValue: 'dark_map' }),
}),
});
export type MapsEmsConfig = TypeOf<typeof emsConfigSchema>;
export type TileMapConfig = TypeOf<typeof tilemapConfigSchema>;

View file

@ -0,0 +1,13 @@
/*
* 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.
*/
module.exports = {
preset: '@kbn/test',
rootDir: '../../..',
roots: ['<rootDir>/src/plugins/maps_ems'],
};

View file

@ -0,0 +1,9 @@
{
"id": "mapsEms",
"version": "8.0.0",
"kibanaVersion": "kibana",
"configPath": ["map"],
"ui": true,
"server": true,
"extraPublicDirs": ["common"]
}

View file

@ -0,0 +1,35 @@
/*
* 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 { PluginInitializerContext } from 'kibana/public';
import { MapsEmsPlugin } from './plugin';
import { IServiceSettings } from './service_settings';
import type { MapsEmsConfig } from '../config';
/** @public */
export {
VectorLayer,
FileLayerField,
FileLayer,
TmsLayer,
IServiceSettings,
} from './service_settings';
export function plugin(initializerContext: PluginInitializerContext) {
return new MapsEmsPlugin(initializerContext);
}
export type { MapsEmsConfig, LayerConfig } from '../config';
export * from '../common';
export interface MapsEmsPluginSetup {
config: MapsEmsConfig;
getServiceSettings: () => Promise<IServiceSettings>;
}
export type MapsEmsPluginStart = ReturnType<MapsEmsPlugin['start']>;

View file

@ -0,0 +1,17 @@
/*
* 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 type { MapsEmsConfig } from '../config';
let kibanaVersion: string;
export const setKibanaVersion = (version: string) => (kibanaVersion = version);
export const getKibanaVersion = (): string => kibanaVersion;
let mapsEmsConfig: MapsEmsConfig;
export const setMapsEmsConfig = (config: MapsEmsConfig) => (mapsEmsConfig = config);
export const getMapsEmsConfig = () => mapsEmsConfig;

View file

@ -6,10 +6,8 @@
* Side Public License, v 1.
*/
import { lazyLoadMapsLegacyModules } from './lazy_load_bundle';
// @ts-expect-error
import { getMapsLegacyConfig } from './kibana_services';
import { IServiceSettings } from './map/service_settings_types';
import type { IServiceSettings } from '../service_settings/service_settings_types';
import { getMapsEmsConfig } from '../kibana_services';
let loadPromise: Promise<IServiceSettings>;
@ -19,10 +17,9 @@ export async function getServiceSettings(): Promise<IServiceSettings> {
}
loadPromise = new Promise(async (resolve) => {
const modules = await lazyLoadMapsLegacyModules();
const config = getMapsLegacyConfig();
// @ts-expect-error
resolve(new modules.ServiceSettings(config, config.tilemap));
const { ServiceSettings } = await import('./lazy');
const config = getMapsEmsConfig();
resolve(new ServiceSettings(config, config.tilemap));
});
return loadPromise;
}

View file

@ -0,0 +1,9 @@
/*
* 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.
*/
export { ServiceSettings } from '../../service_settings/service_settings';

View file

@ -0,0 +1,50 @@
/*
* 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.
*/
// @ts-ignore
import { CoreSetup, CoreStart, Plugin, PluginInitializerContext } from 'kibana/public';
// @ts-ignore
import { setKibanaVersion, setMapsEmsConfig } from './kibana_services';
// @ts-ignore
import { MapsEmsPluginSetup, MapsEmsPluginStart } from './index';
import type { MapsEmsConfig } from '../config';
import { getServiceSettings } from './lazy_load_bundle/get_service_settings';
/**
* These are the interfaces with your public contracts. You should export these
* for other plugins to use in _their_ `SetupDeps`/`StartDeps` interfaces.
* @public
*/
// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface MapsEmsStartDependencies {}
// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface MapsEmsSetupDependencies {}
export class MapsEmsPlugin implements Plugin<MapsEmsPluginSetup, MapsEmsPluginStart> {
readonly _initializerContext: PluginInitializerContext<MapsEmsConfig>;
constructor(initializerContext: PluginInitializerContext<MapsEmsConfig>) {
this._initializerContext = initializerContext;
}
public setup(core: CoreSetup, plugins: MapsEmsSetupDependencies) {
const config = this._initializerContext.config.get<MapsEmsConfig>();
const kibanaVersion = this._initializerContext.env.packageInfo.version;
setKibanaVersion(kibanaVersion);
setMapsEmsConfig(config);
return {
getServiceSettings,
config,
};
}
public start(core: CoreStart, plugins: MapsEmsStartDependencies) {}
}

View file

@ -6,4 +6,4 @@
* Side Public License, v 1.
*/
export * from './ems_defaults';
export * from './service_settings_types';

View file

@ -14,12 +14,12 @@ jest.mock('../kibana_services', () => ({
import url from 'url';
import EMS_FILES from '../__tests__/map/ems_mocks/sample_files.json';
import EMS_TILES from '../__tests__/map/ems_mocks/sample_tiles.json';
import EMS_STYLE_ROAD_MAP_BRIGHT from '../__tests__/map/ems_mocks/sample_style_bright';
import EMS_STYLE_ROAD_MAP_DESATURATED from '../__tests__/map/ems_mocks/sample_style_desaturated';
import EMS_STYLE_DARK_MAP from '../__tests__/map/ems_mocks/sample_style_dark';
import { ORIGIN } from '../common/constants/origin';
import EMS_FILES from '../../__tests__/map/ems_mocks/sample_files.json';
import EMS_TILES from '../../__tests__/map/ems_mocks/sample_tiles.json';
import EMS_STYLE_ROAD_MAP_BRIGHT from '../../__tests__/map/ems_mocks/sample_style_bright';
import EMS_STYLE_ROAD_MAP_DESATURATED from '../../__tests__/map/ems_mocks/sample_style_desaturated';
import EMS_STYLE_DARK_MAP from '../../__tests__/map/ems_mocks/sample_style_dark';
import { ORIGIN } from '../../common';
import { ServiceSettings } from './service_settings';
describe('service_settings (FKA tile_map test)', function () {

View file

@ -8,13 +8,25 @@
import _ from 'lodash';
import MarkdownIt from 'markdown-it';
import { EMSClient } from '@elastic/ems-client';
import { EMSClient, FileLayer as EMSFileLayer, TMSService } from '@elastic/ems-client';
import { i18n } from '@kbn/i18n';
import { getKibanaVersion } from '../kibana_services';
import { ORIGIN, TMS_IN_YML_ID } from '../common/constants';
import { FileLayer, IServiceSettings, TmsLayer } from './service_settings_types';
import { ORIGIN, TMS_IN_YML_ID } from '../../common';
import type { MapsEmsConfig, TileMapConfig } from '../../config';
export class ServiceSettings {
constructor(mapConfig, tilemapsConfig) {
/**
* This class provides access to the EMS-layers and the kibana.yml configured layers through a single interface.
*/
export class ServiceSettings implements IServiceSettings {
private readonly _mapConfig: MapsEmsConfig;
private readonly _tilemapsConfig: TileMapConfig;
private readonly _hasTmsConfigured: boolean;
private _showZoomMessage: boolean;
private readonly _emsClient: EMSClient;
private readonly tmsOptionsFromConfig: any;
constructor(mapConfig: MapsEmsConfig, tilemapsConfig: TileMapConfig) {
this._mapConfig = mapConfig;
this._tilemapsConfig = tilemapsConfig;
this._hasTmsConfigured = typeof tilemapsConfig.url === 'string' && tilemapsConfig.url !== '';
@ -28,14 +40,12 @@ export class ServiceSettings {
tileApiUrl: this._mapConfig.emsTileApiUrl,
landingPageUrl: this._mapConfig.emsLandingPageUrl,
// Wrap to avoid errors passing window fetch
fetchFunction: function (...args) {
fetchFunction(...args: any[]) {
// @ts-expect-error
return fetch(...args);
},
});
this.getTMSOptions();
}
getTMSOptions() {
const markdownIt = new MarkdownIt({
html: false,
linkify: true,
@ -48,25 +58,29 @@ export class ServiceSettings {
});
}
shouldShowZoomMessage({ origin }) {
shouldShowZoomMessage({ origin }: { origin: string }): boolean {
return origin === ORIGIN.EMS && this._showZoomMessage;
}
enableZoomMessage() {
enableZoomMessage(): void {
this._showZoomMessage = true;
}
disableZoomMessage() {
disableZoomMessage(): void {
this._showZoomMessage = false;
}
__debugStubManifestCalls(manifestRetrieval) {
__debugStubManifestCalls(manifestRetrieval: () => Promise<unknown>): { removeStub: () => void } {
const oldGetManifest = this._emsClient.getManifest;
// This legacy code used for debugging/testing only.
// @ts-expect-error
this._emsClient.getManifest = manifestRetrieval;
return {
removeStub: () => {
// @ts-expect-error
delete this._emsClient.getManifest;
//not strictly necessary since this is prototype method
// not strictly necessary since this is prototype method
if (this._emsClient.getManifest !== oldGetManifest) {
this._emsClient.getManifest = oldGetManifest;
}
@ -74,7 +88,7 @@ export class ServiceSettings {
};
}
_backfillSettings = (fileLayer) => {
_backfillSettings = (fileLayer: EMSFileLayer): FileLayer => {
// Older version of Kibana stored EMS state in the URL-params
// Creates object literal with required parameters as key-value pairs
const format = fileLayer.getDefaultFormatType();
@ -87,8 +101,8 @@ export class ServiceSettings {
created_at: fileLayer.getCreatedAt(),
attribution: getAttributionString(fileLayer),
fields: fileLayer.getFieldsInLanguage(),
format: format, //legacy: format and meta are split up
meta: meta, //legacy, format and meta are split up
format, // legacy: format and meta are split up
meta, // legacy, format and meta are split up
};
};
@ -108,25 +122,28 @@ export class ServiceSettings {
async getTMSServices() {
let allServices = [];
if (this._hasTmsConfigured) {
//use tilemap.* settings from yml
const tmsService = _.cloneDeep(this.tmsOptionsFromConfig);
tmsService.id = TMS_IN_YML_ID;
tmsService.origin = ORIGIN.KIBANA_YML;
// use tilemap.* settings from yml
const tmsService: TmsLayer = {
..._.cloneDeep(this.tmsOptionsFromConfig),
id: TMS_IN_YML_ID,
origin: ORIGIN.KIBANA_YML,
};
allServices.push(tmsService);
}
if (this._mapConfig.includeElasticMapsService && !this._mapConfig.emsUrl) {
const servicesFromManifest = await this._emsClient.getTMSServices();
const strippedServiceFromManifest = await Promise.all(
const strippedServiceFromManifest: TmsLayer[] = await Promise.all(
servicesFromManifest
.filter((tmsService) => tmsService.getId() === this._mapConfig.emsTileLayerId.bright)
.map(async (tmsService) => {
//shim for compatibility
.map(async (tmsService: TMSService) => {
// shim for compatibility
return {
origin: tmsService.getOrigin(),
id: tmsService.getId(),
minZoom: await tmsService.getMinZoom(),
maxZoom: await tmsService.getMaxZoom(),
minZoom: (await tmsService.getMinZoom()) as number,
maxZoom: (await tmsService.getMaxZoom()) as number,
attribution: getAttributionString(tmsService),
};
})
@ -142,34 +159,34 @@ export class ServiceSettings {
*
* @param additionalQueryParams
*/
setQueryParams(additionalQueryParams) {
setQueryParams(additionalQueryParams: { [p: string]: string }) {
// Functions more as a "set" than an "add" in ems-client
this._emsClient.addQueryParams(additionalQueryParams);
}
async getFileLayerFromConfig(fileLayerConfig) {
async getFileLayerFromConfig(fileLayerConfig: FileLayer): Promise<EMSFileLayer | undefined> {
const fileLayers = await this._emsClient.getFileLayers();
return fileLayers.find((fileLayer) => {
const hasIdByName = fileLayer.hasId(fileLayerConfig.name); //legacy
const hasIdByName = fileLayer.hasId(fileLayerConfig.name); // legacy
const hasIdById = fileLayer.hasId(fileLayerConfig.id);
return hasIdByName || hasIdById;
});
}
async getEMSHotLink(fileLayerConfig) {
async getEMSHotLink(fileLayerConfig: FileLayer): Promise<string | null> {
const layer = await this.getFileLayerFromConfig(fileLayerConfig);
return layer ? layer.getEMSHotLink() : null;
}
async loadFileLayerConfig(fileLayerConfig) {
async loadFileLayerConfig(fileLayerConfig: FileLayer): Promise<FileLayer | null> {
const fileLayer = await this.getFileLayerFromConfig(fileLayerConfig);
return fileLayer ? this._backfillSettings(fileLayer) : null;
}
async _getAttributesForEMSTMSLayer(isDesaturated, isDarkMode) {
async _getAttributesForEMSTMSLayer(isDesaturated: boolean, isDarkMode: boolean) {
const tmsServices = await this._emsClient.getTMSServices();
const emsTileLayerId = this._mapConfig.emsTileLayerId;
let serviceId;
let serviceId: string;
if (isDarkMode) {
serviceId = emsTileLayerId.dark;
} else {
@ -183,36 +200,40 @@ export class ServiceSettings {
return service.getId() === serviceId;
});
return {
url: await tmsService.getUrlTemplate(),
minZoom: await tmsService.getMinZoom(),
maxZoom: await tmsService.getMaxZoom(),
attribution: getAttributionString(tmsService),
url: await tmsService!.getUrlTemplate(),
minZoom: await tmsService!.getMinZoom(),
maxZoom: await tmsService!.getMaxZoom(),
attribution: getAttributionString(tmsService!),
origin: ORIGIN.EMS,
};
}
async getAttributesForTMSLayer(tmsServiceConfig, isDesaturated, isDarkMode) {
async getAttributesForTMSLayer(
tmsServiceConfig: TmsLayer,
isDesaturated: boolean,
isDarkMode: boolean
) {
if (tmsServiceConfig.origin === ORIGIN.EMS) {
return this._getAttributesForEMSTMSLayer(isDesaturated, isDarkMode);
} else if (tmsServiceConfig.origin === ORIGIN.KIBANA_YML) {
const attrs = _.pick(this._tilemapsConfig, ['url', 'minzoom', 'maxzoom', 'attribution']);
return { ...attrs, ...{ origin: ORIGIN.KIBANA_YML } };
} else {
//this is an older config. need to resolve this dynamically.
// this is an older config. need to resolve this dynamically.
if (tmsServiceConfig.id === TMS_IN_YML_ID) {
const attrs = _.pick(this._tilemapsConfig, ['url', 'minzoom', 'maxzoom', 'attribution']);
return { ...attrs, ...{ origin: ORIGIN.KIBANA_YML } };
} else {
//assume ems
// assume ems
return this._getAttributesForEMSTMSLayer(isDesaturated, isDarkMode);
}
}
}
async _getFileUrlFromEMS(fileLayerConfig) {
async _getFileUrlFromEMS(fileLayerConfig: FileLayer) {
const fileLayers = await this._emsClient.getFileLayers();
const layer = fileLayers.find((fileLayer) => {
const hasIdByName = fileLayer.hasId(fileLayerConfig.name); //legacy
const hasIdByName = fileLayer.hasId(fileLayerConfig.name); // legacy
const hasIdById = fileLayer.hasId(fileLayerConfig.id);
return hasIdByName || hasIdById;
});
@ -224,34 +245,34 @@ export class ServiceSettings {
}
}
async getUrlForRegionLayer(fileLayerConfig) {
async getUrlForRegionLayer(fileLayerConfig: FileLayer): Promise<string | undefined> {
let url;
if (fileLayerConfig.origin === ORIGIN.EMS) {
url = this._getFileUrlFromEMS(fileLayerConfig);
} else if (fileLayerConfig.layerId && fileLayerConfig.layerId.startsWith(`${ORIGIN.EMS}.`)) {
//fallback for older saved objects
// fallback for older saved objects
url = this._getFileUrlFromEMS(fileLayerConfig);
} else if (
fileLayerConfig.layerId &&
fileLayerConfig.layerId.startsWith(`${ORIGIN.KIBANA_YML}.`)
) {
//fallback for older saved objects
// fallback for older saved objects
url = fileLayerConfig.url;
} else {
//generic fallback
// generic fallback
url = fileLayerConfig.url;
}
return url;
}
async getJsonForRegionLayer(fileLayerConfig) {
async getJsonForRegionLayer(fileLayerConfig: FileLayer) {
const url = await this.getUrlForRegionLayer(fileLayerConfig);
const response = await fetch(url);
const response = await fetch(url!);
return await response.json();
}
}
function getAttributionString(emsService) {
function getAttributionString(emsService: EMSFileLayer | TMSService) {
const attributions = emsService.getAttributions();
const attributionSnippets = attributions.map((attribution) => {
const anchorTag = document.createElement('a');
@ -262,5 +283,5 @@ function getAttributionString(emsService) {
anchorTag.textContent = attribution.label;
return anchorTag.outerHTML;
});
return attributionSnippets.join(' | '); //!!!this is the current convention used in Kibana
return attributionSnippets.join(' | '); // !!!this is the current convention used in Kibana
}

View file

@ -9,7 +9,7 @@
export interface TmsLayer {
id: string;
origin: string;
minZoom: string;
minZoom: number;
maxZoom: number;
attribution: string;
}
@ -20,6 +20,13 @@ export interface FileLayer {
id: string;
format: string | { type: string };
fields: FileLayerField[];
url?: string;
layerId?: string;
created_at?: string;
attribution?: string;
meta?: {
[key: string]: string;
};
}
export interface FileLayerField {
@ -34,8 +41,16 @@ export interface VectorLayer extends FileLayer {
}
export interface IServiceSettings {
getEMSHotLink(layer: FileLayer): Promise<string>;
getEMSHotLink(layer: FileLayer): Promise<string | null>;
getTMSServices(): Promise<TmsLayer[]>;
getFileLayers(): Promise<FileLayer[]>;
getUrlForRegionLayer(layer: FileLayer): Promise<string>;
getUrlForRegionLayer(layer: FileLayer): Promise<string | undefined>;
setQueryParams(params: { [p: string]: string }): void;
enableZoomMessage(): void;
disableZoomMessage(): void;
getAttributesForTMSLayer(
tmsServiceConfig: TmsLayer,
isDesaturated: boolean,
isDarkMode: boolean
): any;
}

View file

@ -0,0 +1,56 @@
/*
* 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 {
CoreSetup,
PluginInitializerContext,
Plugin,
PluginConfigDescriptor,
} from 'src/core/server';
import { MapsEmsConfig, emsConfigSchema } from '../config';
export const config: PluginConfigDescriptor<MapsEmsConfig> = {
exposeToBrowser: {
regionmap: true,
tilemap: true,
includeElasticMapsService: true,
proxyElasticMapsServiceInMaps: true,
manifestServiceUrl: true,
emsUrl: true,
emsFileApiUrl: true,
emsTileApiUrl: true,
emsLandingPageUrl: true,
emsFontLibraryUrl: true,
emsTileLayerId: true,
},
schema: emsConfigSchema,
};
export interface MapsEmsPluginSetup {
config: MapsEmsConfig;
}
export class MapsEmsPlugin implements Plugin<MapsEmsPluginSetup> {
readonly _initializerContext: PluginInitializerContext<MapsEmsConfig>;
constructor(initializerContext: PluginInitializerContext<MapsEmsConfig>) {
this._initializerContext = initializerContext;
}
public setup(core: CoreSetup) {
const emsPluginConfig = this._initializerContext.config.get();
return {
config: emsPluginConfig,
};
}
public start() {}
}
export const plugin = (initializerContext: PluginInitializerContext) =>
new MapsEmsPlugin(initializerContext);

View file

@ -0,0 +1,12 @@
{
"extends": "../../../tsconfig.base.json",
"compilerOptions": {
"composite": true,
"outDir": "./target/types",
"emitDeclarationOnly": true,
"declaration": true,
"declarationMap": true
},
"include": ["common/**/*", "public/**/*", "server/**/*", "./config.ts"],
"references": [{ "path": "../../core/tsconfig.json" }]
}

View file

@ -8,80 +8,6 @@
import { schema, TypeOf } from '@kbn/config-schema';
import {
DEFAULT_EMS_FONT_LIBRARY_URL,
DEFAULT_EMS_LANDING_PAGE_URL,
DEFAULT_EMS_TILE_API_URL,
DEFAULT_EMS_FILE_API_URL,
} from './common/ems_defaults';
export const tilemapConfigSchema = schema.object({
url: schema.maybe(schema.string()),
options: schema.object({
attribution: schema.string({ defaultValue: '' }),
minZoom: schema.number({ defaultValue: 0, min: 0 }),
maxZoom: schema.number({ defaultValue: 10 }),
tileSize: schema.maybe(schema.number()),
subdomains: schema.maybe(schema.arrayOf(schema.string())),
errorTileUrl: schema.maybe(schema.string()),
tms: schema.maybe(schema.boolean()),
reuseTiles: schema.maybe(schema.boolean()),
bounds: schema.maybe(schema.arrayOf(schema.number({ min: 2 }))),
default: schema.maybe(schema.boolean()),
}),
});
const layerConfigSchema = schema.object({
url: schema.string(),
format: schema.object({
type: schema.string({ defaultValue: 'geojson' }),
}),
meta: schema.object({
feature_collection_path: schema.string({ defaultValue: 'data' }),
}),
attribution: schema.string(),
name: schema.string(),
fields: schema.arrayOf(
schema.object({
name: schema.string(),
description: schema.string(),
})
),
});
export type LayerConfig = TypeOf<typeof layerConfigSchema>;
export const regionmapConfigSchema = schema.object({
includeElasticMapsService: schema.boolean({ defaultValue: true }),
layers: schema.arrayOf(layerConfigSchema, { defaultValue: [] }),
});
export const configSchema = schema.object({
includeElasticMapsService: schema.boolean({ defaultValue: true }),
proxyElasticMapsServiceInMaps: schema.boolean({ defaultValue: false }),
tilemap: tilemapConfigSchema,
regionmap: regionmapConfigSchema,
manifestServiceUrl: schema.string({ defaultValue: '' }),
emsUrl: schema.conditional(
schema.siblingRef('proxyElasticMapsServiceInMaps'),
true,
schema.never(),
schema.string({ defaultValue: '' })
),
emsFileApiUrl: schema.string({ defaultValue: DEFAULT_EMS_FILE_API_URL }),
emsTileApiUrl: schema.string({ defaultValue: DEFAULT_EMS_TILE_API_URL }),
emsLandingPageUrl: schema.string({ defaultValue: DEFAULT_EMS_LANDING_PAGE_URL }),
emsFontLibraryUrl: schema.string({
defaultValue: DEFAULT_EMS_FONT_LIBRARY_URL,
}),
emsTileLayerId: schema.object({
bright: schema.string({ defaultValue: 'road_map' }),
desaturated: schema.string({ defaultValue: 'road_map_desaturated' }),
dark: schema.string({ defaultValue: 'dark_map' }),
}),
});
export const configSchema = schema.object({});
export type MapsLegacyConfig = TypeOf<typeof configSchema>;

View file

@ -2,9 +2,8 @@
"id": "mapsLegacy",
"version": "8.0.0",
"kibanaVersion": "kibana",
"configPath": ["map"],
"ui": true,
"server": true,
"extraPublicDirs": ["common"],
"requiredBundles": ["kibanaReact", "visDefaultEditor"]
"requiredPlugins": ["mapsEms"],
"requiredBundles": ["kibanaReact", "visDefaultEditor", "mapsEms"]
}

View file

@ -6,7 +6,7 @@
* Side Public License, v 1.
*/
import { TmsLayer } from '..';
import { TmsLayer } from '../../../maps_ems/public';
export interface WMSOptions {
selectedTmsLayer?: TmsLayer;

View file

@ -10,7 +10,7 @@ import React, { useMemo } from 'react';
import { EuiPanel, EuiSpacer, EuiTitle } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n/react';
import { TmsLayer } from '../index';
import { TmsLayer } from '../../../maps_ems/public';
import { SelectOption, SwitchOption } from '../../../vis_default_editor/public';
import { WmsInternalOptions } from './wms_internal_options';
import { WMSOptions } from '../common/types';

View file

@ -10,13 +10,6 @@ import { PluginInitializerContext } from 'kibana/public';
import { MapsLegacyPlugin } from './plugin';
import * as colorUtil from './map/color_util';
import { KibanaMapLayer } from './map/kibana_map_layer';
import {
VectorLayer,
FileLayerField,
FileLayer,
TmsLayer,
IServiceSettings,
} from './map/service_settings_types';
import { mapTooltipProvider } from './tooltip_provider';
import './map/index.scss';
@ -26,21 +19,9 @@ export function plugin(initializerContext: PluginInitializerContext) {
}
/** @public */
export {
colorUtil,
IServiceSettings,
KibanaMapLayer,
VectorLayer,
FileLayerField,
FileLayer,
TmsLayer,
mapTooltipProvider,
};
export * from '../common';
export * from './common/types';
export { ORIGIN, TMS_IN_YML_ID } from './common/constants';
export { colorUtil, KibanaMapLayer, mapTooltipProvider };
export { WMSOptions } from './common/types';
export { WmsOptions } from './components/wms_options';
export { LegacyMapDeprecationMessage } from './components/legacy_map_deprecation_message';

View file

@ -1,25 +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.
*/
let toast;
export const setToasts = (notificationToast) => (toast = notificationToast);
export const getToasts = () => toast;
let uiSettings;
export const setUiSettings = (coreUiSettings) => (uiSettings = coreUiSettings);
export const getUiSettings = () => uiSettings;
let kibanaVersion;
export const setKibanaVersion = (version) => (kibanaVersion = version);
export const getKibanaVersion = () => kibanaVersion;
let mapsLegacyConfig;
export const setMapsLegacyConfig = (config) => (mapsLegacyConfig = config);
export const getMapsLegacyConfig = () => mapsLegacyConfig;
export const getEmsTileLayerId = () => getMapsLegacyConfig().emsTileLayerId;

View file

@ -0,0 +1,29 @@
/*
* 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 { IUiSettingsClient, ToastsSetup } from 'kibana/public';
import type { MapsEmsConfig, IServiceSettings } from '../../maps_ems/public';
let toast: ToastsSetup;
export const setToasts = (notificationToast: ToastsSetup) => (toast = notificationToast);
export const getToasts = () => toast;
let uiSettings: IUiSettingsClient;
export const setUiSettings = (coreUiSettings: IUiSettingsClient) => (uiSettings = coreUiSettings);
export const getUiSettings = () => uiSettings;
let mapsEmsConfig: MapsEmsConfig;
export const setMapsEmsConfig = (config: MapsEmsConfig) => (mapsEmsConfig = config);
export const getEmsTileLayerId = () => mapsEmsConfig.emsTileLayerId;
let getServiceSettingsFunction: () => Promise<IServiceSettings>;
export const setGetServiceSettings = (getSS: () => Promise<IServiceSettings>) =>
(getServiceSettingsFunction = getSS);
export const getServiceSettings = async (): Promise<IServiceSettings> => {
return await getServiceSettingsFunction();
};

View file

@ -11,7 +11,6 @@ let loadModulesPromise: Promise<LazyLoadedMapsLegacyModules>;
interface LazyLoadedMapsLegacyModules {
KibanaMap: unknown;
L: unknown;
ServiceSettings: unknown;
}
export async function lazyLoadMapsLegacyModules(): Promise<LazyLoadedMapsLegacyModules> {
@ -20,12 +19,11 @@ export async function lazyLoadMapsLegacyModules(): Promise<LazyLoadedMapsLegacyM
}
loadModulesPromise = new Promise(async (resolve) => {
const { KibanaMap, L, ServiceSettings } = await import('./lazy');
const { KibanaMap, L } = await import('./lazy');
resolve({
KibanaMap,
L,
ServiceSettings,
});
});
return loadModulesPromise;

View file

@ -9,6 +9,4 @@
// @ts-expect-error
export { KibanaMap } from '../../map/kibana_map';
// @ts-expect-error
export { ServiceSettings } from '../../map/service_settings';
// @ts-expect-error
export { L } from '../../leaflet';

View file

@ -9,9 +9,13 @@
import { i18n } from '@kbn/i18n';
import * as Rx from 'rxjs';
import { filter, first } from 'rxjs/operators';
import { getEmsTileLayerId, getUiSettings, getToasts } from '../kibana_services';
import {
getEmsTileLayerId,
getUiSettings,
getToasts,
getServiceSettings,
} from '../kibana_services';
import { lazyLoadMapsLegacyModules } from '../lazy_load_bundle';
import { getServiceSettings } from '../get_service_settings';
const WMS_MINZOOM = 0;
const WMS_MAXZOOM = 22; //increase this to 22. Better for WMS

View file

@ -12,7 +12,7 @@ import $ from 'jquery';
import { get, isEqual, escape } from 'lodash';
import { zoomToPrecision } from './zoom_to_precision';
import { i18n } from '@kbn/i18n';
import { ORIGIN } from '../common/constants/origin';
import { ORIGIN } from '../../../maps_ems/common';
import { getToasts } from '../kibana_services';
import { L } from '../leaflet';

View file

@ -9,14 +9,19 @@
// @ts-ignore
import { CoreSetup, CoreStart, Plugin, PluginInitializerContext } from 'kibana/public';
// @ts-ignore
import { setToasts, setUiSettings, setKibanaVersion, setMapsLegacyConfig } from './kibana_services';
import {
setToasts,
setUiSettings,
setMapsEmsConfig,
setGetServiceSettings,
} from './kibana_services';
// @ts-ignore
import { getPrecision, getZoomPrecision } from './map/precision';
import { MapsLegacyPluginSetup, MapsLegacyPluginStart } from './index';
import { MapsLegacyConfig } from '../config';
// @ts-ignore
import { BaseMapsVisualizationProvider } from './map/base_maps_visualization';
import { getServiceSettings } from './get_service_settings';
import type { MapsEmsPluginSetup } from '../../maps_ems/public';
/**
* These are the interfaces with your public contracts. You should export these
@ -24,19 +29,9 @@ import { getServiceSettings } from './get_service_settings';
* @public
*/
export const bindSetupCoreAndPlugins = (
core: CoreSetup,
config: MapsLegacyConfig,
kibanaVersion: string
) => {
setToasts(core.notifications.toasts);
setUiSettings(core.uiSettings);
setKibanaVersion(kibanaVersion);
setMapsLegacyConfig(config);
};
// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface MapsLegacySetupDependencies {}
export interface MapsLegacySetupDependencies {
mapsEms: MapsEmsPluginSetup;
}
// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface MapsLegacyStartDependencies {}
@ -48,18 +43,16 @@ export class MapsLegacyPlugin implements Plugin<MapsLegacyPluginSetup, MapsLegac
}
public setup(core: CoreSetup, plugins: MapsLegacySetupDependencies) {
const config = this._initializerContext.config.get<MapsLegacyConfig>();
const kibanaVersion = this._initializerContext.env.packageInfo.version;
bindSetupCoreAndPlugins(core, config, kibanaVersion);
setToasts(core.notifications.toasts);
setUiSettings(core.uiSettings);
setMapsEmsConfig(plugins.mapsEms.config);
setGetServiceSettings(plugins.mapsEms.getServiceSettings);
const getBaseMapsVis = () => new BaseMapsVisualizationProvider();
return {
getServiceSettings,
getZoomPrecision,
getPrecision,
config,
getBaseMapsVis,
};
}

View file

@ -12,19 +12,7 @@ import { configSchema, MapsLegacyConfig } from '../config';
import { getUiSettings } from './ui_settings';
export const config: PluginConfigDescriptor<MapsLegacyConfig> = {
exposeToBrowser: {
includeElasticMapsService: true,
proxyElasticMapsServiceInMaps: true,
tilemap: true,
regionmap: true,
manifestServiceUrl: true,
emsUrl: true,
emsFileApiUrl: true,
emsTileApiUrl: true,
emsLandingPageUrl: true,
emsFontLibraryUrl: true,
emsTileLayerId: true,
},
exposeToBrowser: {},
schema: configSchema,
};

View file

@ -7,8 +7,9 @@
"declaration": true,
"declarationMap": true
},
"include": ["common/**/*", "public/**/*", "server/**/*", "config.ts"],
"include": ["public/**/*", "server/**/*", "config.ts"],
"references": [
{ "path": "../vis_default_editor/tsconfig.json" },
{ "path": "../maps_ems/tsconfig.json" }
]
}

View file

@ -2,13 +2,13 @@
"id": "regionMap",
"version": "8.0.0",
"kibanaVersion": "kibana",
"configPath": ["map", "regionmap"],
"ui": true,
"server": true,
"requiredPlugins": [
"visualizations",
"expressions",
"mapsLegacy",
"mapsEms",
"kibanaLegacy",
"data",
"share"

View file

@ -7,7 +7,7 @@
*/
import React, { lazy } from 'react';
import { IServiceSettings } from 'src/plugins/maps_legacy/public';
import { IServiceSettings } from 'src/plugins/maps_ems/public';
import { VisEditorOptionsProps } from 'src/plugins/visualizations/public';
import { RegionMapVisParams } from '../region_map_types';

View file

@ -12,7 +12,7 @@ import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n/react';
import { VisEditorOptionsProps } from 'src/plugins/visualizations/public';
import { truncatedColorSchemas } from '../../../charts/public';
import { FileLayerField, VectorLayer, IServiceSettings } from '../../../maps_legacy/public';
import { FileLayerField, VectorLayer, IServiceSettings } from '../../../maps_ems/public';
import { SelectOption, SwitchOption, NumberInputOption } from '../../../vis_default_editor/public';
import { WmsOptions } from '../../../maps_legacy/public';
import { RegionMapVisParams } from '../region_map_types';

View file

@ -12,7 +12,7 @@ import { createGetterSetter } from '../../kibana_utils/public';
import { DataPublicPluginStart } from '../../data/public';
import { KibanaLegacyStart } from '../../kibana_legacy/public';
import { SharePluginStart } from '../../share/public';
import { VectorLayer, TmsLayer } from '../../maps_legacy/public';
import { VectorLayer, TmsLayer } from '../../maps_ems/public';
export const [getCoreService, setCoreService] = createGetterSetter<CoreStart>('Core');

View file

@ -20,7 +20,8 @@ import { VisualizationsSetup } from '../../visualizations/public';
import { createRegionMapFn } from './region_map_fn';
// @ts-ignore
import { createRegionMapTypeDefinition } from './region_map_type';
import { IServiceSettings, MapsLegacyPluginSetup } from '../../maps_legacy/public';
import { MapsLegacyPluginSetup } from '../../maps_legacy/public';
import { IServiceSettings, MapsEmsPluginSetup } from '../../maps_ems/public';
import {
setCoreService,
setFormatService,
@ -49,6 +50,7 @@ export interface RegionMapPluginSetupDependencies {
expressions: ReturnType<ExpressionsPublicPlugin['setup']>;
visualizations: VisualizationsSetup;
mapsLegacy: MapsLegacyPluginSetup;
mapsEms: MapsEmsPluginSetup;
}
/** @internal */
@ -65,9 +67,8 @@ export interface RegionMapsConfig {
layers: any[];
}
export interface RegionMapPluginSetup {
config: any;
}
// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface RegionMapPluginSetup {}
// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface RegionMapPluginStart {}
@ -81,19 +82,19 @@ export class RegionMapPlugin implements Plugin<RegionMapPluginSetup, RegionMapPl
public setup(
core: CoreSetup,
{ expressions, visualizations, mapsLegacy }: RegionMapPluginSetupDependencies
{ expressions, visualizations, mapsLegacy, mapsEms }: RegionMapPluginSetupDependencies
) {
const config = {
...this._initializerContext.config.get<RegionMapsConfigType>(),
// The maps legacy plugin updates the regionmap config directly in service_settings,
// future work on how configurations across the different plugins are organized would
// ideally constrain regionmap config updates to occur only from this plugin
...mapsLegacy.config.regionmap,
...mapsEms.config.regionmap,
};
const visualizationDependencies: Readonly<RegionMapVisualizationDependencies> = {
uiSettings: core.uiSettings,
regionmapsConfig: config as RegionMapsConfig,
getServiceSettings: mapsLegacy.getServiceSettings,
getServiceSettings: mapsEms.getServiceSettings,
BaseMapsVisualization: mapsLegacy.getBaseMapsVis(),
};
@ -104,9 +105,7 @@ export class RegionMapPlugin implements Plugin<RegionMapPluginSetup, RegionMapPl
createRegionMapTypeDefinition(visualizationDependencies)
);
return {
config,
};
return {};
}
public start(core: CoreStart, plugins: RegionMapPluginStartDependencies) {

View file

@ -9,7 +9,7 @@
import { i18n } from '@kbn/i18n';
import { VisTypeDefinition } from '../../visualizations/public';
import { ORIGIN } from '../../maps_legacy/public';
import { ORIGIN, VectorLayer } from '../../maps_ems/public';
import { getDeprecationMessage } from './get_deprecation_message';
import { RegionMapVisualizationDependencies } from './plugin';
@ -107,11 +107,12 @@ provided base maps, or add your own. Darker colors represent higher values.',
const newLayers = layers
.map(mapToLayerWithId.bind(null, ORIGIN.EMS))
.filter(
(layer) => !vectorLayers.some((vectorLayer) => vectorLayer.layerId === layer.layerId)
(layer: VectorLayer) =>
!vectorLayers.some((vectorLayer) => vectorLayer.layerId === layer.layerId)
);
// backfill v1 manifest for now
newLayers.forEach((layer) => {
newLayers.forEach((layer: VectorLayer) => {
if (layer.format === 'geojson') {
layer.format = {
type: 'geojson',

View file

@ -7,7 +7,8 @@
*/
import { SchemaConfig } from 'src/plugins/visualizations/public';
import { VectorLayer, FileLayerField, WMSOptions } from '../../maps_legacy/public/index';
import { VectorLayer, FileLayerField } from '../../maps_ems/public';
import { WMSOptions } from '../../maps_legacy/public';
export interface RegionMapVisParams {
readonly addTooltip: true;

View file

@ -10,7 +10,8 @@ import { i18n } from '@kbn/i18n';
import { getFormatService, getNotifications, getKibanaLegacy } from './kibana_services';
import { truncatedColorMaps } from '../../charts/public';
import { tooltipFormatter } from './tooltip_formatter';
import { mapTooltipProvider, ORIGIN, lazyLoadMapsLegacyModules } from '../../maps_legacy/public';
import { mapTooltipProvider, lazyLoadMapsLegacyModules } from '../../maps_legacy/public';
import { ORIGIN } from '../../maps_ems/public';
export function createRegionMapVisualization({
regionmapsConfig,

View file

@ -6,8 +6,7 @@
* Side Public License, v 1.
*/
import { FileLayer, VectorLayer } from '../../maps_legacy/public';
import { ORIGIN } from '../../maps_legacy/public';
import { FileLayer, VectorLayer, ORIGIN } from '../../maps_ems/public';
export const mapToLayerWithId = (prefix: string, layer: FileLayer): VectorLayer => ({
...layer,

View file

@ -6,22 +6,9 @@
* Side Public License, v 1.
*/
import { TypeOf } from '@kbn/config-schema';
import { PluginConfigDescriptor } from 'kibana/server';
import { CoreSetup } from 'src/core/server';
import { regionmapConfigSchema } from '../../maps_legacy/config';
import { getUiSettings } from './ui_settings';
export type RegionmapConfig = TypeOf<typeof regionmapConfigSchema>;
export const config: PluginConfigDescriptor<RegionmapConfig> = {
exposeToBrowser: {
includeElasticMapsService: true,
layers: true,
},
schema: regionmapConfigSchema,
};
export const plugin = () => ({
setup(core: CoreSetup) {
core.uiSettings.register(getUiSettings());

View file

@ -10,6 +10,7 @@
"include": ["public/**/*", "server/**/*"],
"references": [
{ "path": "../maps_legacy/tsconfig.json" },
{ "path": "../maps_ems/tsconfig.json" },
{ "path": "../vis_default_editor/tsconfig.json" },
]
}

View file

@ -2,13 +2,13 @@
"id": "tileMap",
"version": "8.0.0",
"kibanaVersion": "kibana",
"configPath": ["map", "tilemap"],
"ui": true,
"server": true,
"requiredPlugins": [
"visualizations",
"expressions",
"mapsLegacy",
"mapsEms",
"kibanaLegacy",
"data",
"share"

View file

@ -15,7 +15,9 @@ import {
} from 'kibana/public';
import { Plugin as ExpressionsPublicPlugin } from '../../expressions/public';
import { VisualizationsSetup } from '../../visualizations/public';
import { IServiceSettings, MapsLegacyPluginSetup } from '../../maps_legacy/public';
import { MapsLegacyPluginSetup } from '../../maps_legacy/public';
import { MapsEmsPluginSetup } from '../../maps_ems/public';
import { IServiceSettings } from '../../maps_ems/public';
import { DataPublicPluginStart } from '../../data/public';
import {
setCoreService,
@ -31,10 +33,6 @@ import { createTileMapFn } from './tile_map_fn';
import { createTileMapTypeDefinition } from './tile_map_type';
import { getTileMapRenderer } from './tile_map_renderer';
export interface TileMapConfigType {
tilemap: any;
}
/** @private */
export interface TileMapVisualizationDependencies {
uiSettings: IUiSettingsClient;
@ -49,6 +47,7 @@ export interface TileMapPluginSetupDependencies {
expressions: ReturnType<ExpressionsPublicPlugin['setup']>;
visualizations: VisualizationsSetup;
mapsLegacy: MapsLegacyPluginSetup;
mapsEms: MapsEmsPluginSetup;
}
/** @internal */
@ -58,9 +57,8 @@ export interface TileMapPluginStartDependencies {
share: SharePluginStart;
}
export interface TileMapPluginSetup {
config: any;
}
// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface TileMapPluginSetup {}
// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface TileMapPluginStart {}
@ -74,15 +72,15 @@ export class TileMapPlugin implements Plugin<TileMapPluginSetup, TileMapPluginSt
public setup(
core: CoreSetup,
{ expressions, visualizations, mapsLegacy }: TileMapPluginSetupDependencies
{ expressions, visualizations, mapsLegacy, mapsEms }: TileMapPluginSetupDependencies
) {
const { getZoomPrecision, getPrecision, getServiceSettings } = mapsLegacy;
const { getZoomPrecision, getPrecision } = mapsLegacy;
const visualizationDependencies: Readonly<TileMapVisualizationDependencies> = {
getZoomPrecision,
getPrecision,
BaseMapsVisualization: mapsLegacy.getBaseMapsVis(),
uiSettings: core.uiSettings,
getServiceSettings,
getServiceSettings: mapsEms.getServiceSettings,
};
expressions.registerFunction(createTileMapFn);
@ -90,10 +88,7 @@ export class TileMapPlugin implements Plugin<TileMapPluginSetup, TileMapPluginSt
visualizations.createBaseVisualization(createTileMapTypeDefinition(visualizationDependencies));
const config = this.initializerContext.config.get<TileMapConfigType>();
return {
config,
};
return {};
}
public start(core: CoreStart, plugins: TileMapPluginStartDependencies) {

View file

@ -11,7 +11,7 @@ import { createGetterSetter } from '../../kibana_utils/public';
import { DataPublicPluginStart } from '../../data/public';
import { KibanaLegacyStart } from '../../kibana_legacy/public';
import { SharePluginStart } from '../../share/public';
import { TmsLayer } from '../../maps_legacy/public';
import { TmsLayer } from '../../maps_ems/public';
export const [getCoreService, setCoreService] = createGetterSetter<CoreStart>('Core');

View file

@ -6,20 +6,6 @@
* Side Public License, v 1.
*/
import { TypeOf } from '@kbn/config-schema';
import { PluginConfigDescriptor } from 'kibana/server';
import { tilemapConfigSchema } from '../../maps_legacy/config';
export type TilemapConfig = TypeOf<typeof tilemapConfigSchema>;
export const config: PluginConfigDescriptor<TilemapConfig> = {
exposeToBrowser: {
url: true,
options: true,
},
schema: tilemapConfigSchema,
};
export const plugin = () => ({
setup() {},
start() {},

View file

@ -10,6 +10,7 @@
"include": ["public/**/*", "server/**/*"],
"references": [
{ "path": "../maps_legacy/tsconfig.json" },
{ "path": "../maps_ems/tsconfig.json" },
{ "path": "../vis_default_editor/tsconfig.json" },
]
}

View file

@ -3,7 +3,7 @@
"version": "kibana",
"server": true,
"ui": true,
"requiredPlugins": ["data", "visualizations", "mapsLegacy", "expressions", "inspector"],
"requiredPlugins": ["data", "visualizations", "mapsEms", "expressions", "inspector"],
"optionalPlugins": ["home","usageCollection"],
"requiredBundles": ["kibanaUtils", "kibanaReact", "visDefaultEditor"]
}

View file

@ -9,7 +9,7 @@
import { i18n } from '@kbn/i18n';
// @ts-ignore
import { bypassExternalUrlCheck } from '../vega_view/vega_base_view';
import { IServiceSettings, FileLayer } from '../../../maps_legacy/public';
import { IServiceSettings, FileLayer } from '../../../maps_ems/public';
import { Data, UrlObject, EmsQueryRequest } from './types';
/**

View file

@ -22,7 +22,7 @@ import { EmsFileParser } from './ems_file_parser';
import { UrlParser } from './url_parser';
import { SearchAPI } from './search_api';
import { TimeCache } from './time_cache';
import { IServiceSettings } from '../../../maps_legacy/public';
import { IServiceSettings } from '../../../maps_ems/public';
import {
Bool,
Data,

View file

@ -23,7 +23,7 @@ import {
import { createVegaFn } from './vega_fn';
import { createVegaTypeDefinition } from './vega_type';
import { IServiceSettings, MapsLegacyPluginSetup } from '../../maps_legacy/public';
import { IServiceSettings, MapsEmsPluginSetup } from '../../maps_ems/public';
import { ConfigSchema } from '../config';
import { getVegaInspectorView } from './vega_inspector';
@ -45,7 +45,7 @@ export interface VegaPluginSetupDependencies {
visualizations: VisualizationsSetup;
inspector: InspectorSetup;
data: DataPublicPluginSetup;
mapsLegacy: MapsLegacyPluginSetup;
mapsEms: MapsEmsPluginSetup;
}
/** @internal */
@ -63,7 +63,7 @@ export class VegaPlugin implements Plugin<void, void> {
public setup(
core: CoreSetup,
{ inspector, data, expressions, visualizations, mapsLegacy }: VegaPluginSetupDependencies
{ inspector, data, expressions, visualizations, mapsEms }: VegaPluginSetupDependencies
) {
setInjectedVars({
enableExternalUrls: this.initializerContext.config.get().enableExternalUrls,
@ -73,7 +73,7 @@ export class VegaPlugin implements Plugin<void, void> {
setUISettings(core.uiSettings);
setMapServiceSettings(
new MapServiceSettings(mapsLegacy.config, this.initializerContext.env.packageInfo.version)
new MapServiceSettings(mapsEms.config, this.initializerContext.env.packageInfo.version)
);
const visualizationDependencies: Readonly<VegaVisualizationDependencies> = {
@ -81,7 +81,7 @@ export class VegaPlugin implements Plugin<void, void> {
plugins: {
data,
},
getServiceSettings: mapsLegacy.getServiceSettings,
getServiceSettings: mapsEms.getServiceSettings,
};
inspector.registerView(getVegaInspectorView({ uiSettings: core.uiSettings }));

View file

@ -8,7 +8,7 @@
import { DataPublicPluginStart } from 'src/plugins/data/public';
import { IInterpreterRenderHandlers } from 'src/plugins/expressions';
import { IServiceSettings } from 'src/plugins/maps_legacy/public';
import { IServiceSettings } from 'src/plugins/maps_ems/public';
import { VegaParser } from '../data_model/vega_parser';
import { createVegaStateRestorer } from '../lib/vega_state_restorer';

View file

@ -7,7 +7,7 @@
*/
import type { Style } from 'mapbox-gl';
import { TMS_IN_YML_ID } from '../../../../maps_legacy/public';
import { TMS_IN_YML_ID } from '../../../../maps_ems/public';
export const vegaLayerId = 'vega';
export const userConfiguredLayerId = TMS_IN_YML_ID;

View file

@ -10,7 +10,7 @@ import { get } from 'lodash';
import { uiSettingsServiceMock } from 'src/core/public/mocks';
import { MapServiceSettings, getAttributionsForTmsService } from './map_service_settings';
import { MapsLegacyConfig } from '../../../../maps_legacy/config';
import type { MapsEmsConfig } from '../../../../maps_ems/public';
import { EMSClient, TMSService } from '@elastic/ems-client';
import { setUISettings } from '../../services';
@ -20,7 +20,7 @@ const getPrivateField = <T>(mapServiceSettings: MapServiceSettings, privateField
describe('vega_map_view/map_service_settings', () => {
describe('MapServiceSettings', () => {
const appVersion = '99';
let config: MapsLegacyConfig;
let config: MapsEmsConfig;
let getUiSettingsMockedValue: any;
beforeEach(() => {
@ -29,7 +29,7 @@ describe('vega_map_view/map_service_settings', () => {
desaturated: 'road_map_desaturated',
dark: 'dark_map',
},
} as MapsLegacyConfig;
} as MapsEmsConfig;
setUISettings({
...uiSettingsServiceMock.createSetupContract(),
get: () => getUiSettingsMockedValue,

View file

@ -10,11 +10,11 @@ import { i18n } from '@kbn/i18n';
import type { EMSClient, TMSService } from '@elastic/ems-client';
import { getUISettings } from '../../services';
import { userConfiguredLayerId } from './constants';
import type { MapsLegacyConfig } from '../../../../maps_legacy/config';
import type { MapsEmsConfig } from '../../../../maps_ems/public';
type EmsClientConfig = ConstructorParameters<typeof EMSClient>[0];
const hasUserConfiguredTmsService = (config: MapsLegacyConfig) => Boolean(config.tilemap?.url);
const hasUserConfiguredTmsService = (config: MapsEmsConfig) => Boolean(config.tilemap?.url);
const initEmsClientAsync = async (config: Partial<EmsClientConfig>) => {
/**
@ -37,7 +37,7 @@ export class MapServiceSettings {
private emsClient?: EMSClient;
private isDarkMode: boolean = false;
constructor(public config: MapsLegacyConfig, private appVersion: string) {}
constructor(public config: MapsEmsConfig, private appVersion: string) {}
private isInitialized() {
return Boolean(this.emsClient);

View file

@ -17,8 +17,7 @@ import { SearchAPI } from '../../data_model/search_api';
import vegaMap from '../../test_utils/vega_map_test.json';
import { coreMock } from '../../../../../core/public/mocks';
import { dataPluginMock } from '../../../../data/public/mocks';
import { IServiceSettings } from '../../../../maps_legacy/public';
import type { MapsLegacyConfig } from '../../../../maps_legacy/config';
import type { IServiceSettings, MapsEmsConfig } from '../../../../maps_ems/public';
import { MapServiceSettings } from './map_service_settings';
import { userConfiguredLayerId } from './constants';
import {
@ -94,7 +93,7 @@ describe('vega_map_view/view', () => {
maxZoom: 20,
},
},
} as MapsLegacyConfig;
} as MapsEmsConfig;
function setMapService(defaultTmsLayer: string) {
setMapServiceSettings(({

View file

@ -19,7 +19,7 @@
{ "path": "../../core/tsconfig.json" },
{ "path": "../data/tsconfig.json" },
{ "path": "../visualizations/tsconfig.json" },
{ "path": "../maps_legacy/tsconfig.json" },
{ "path": "../maps_ems/tsconfig.json" },
{ "path": "../expressions/tsconfig.json" },
{ "path": "../inspector/tsconfig.json" },
{ "path": "../home/tsconfig.json" },

View file

@ -11,7 +11,7 @@ import {
DEFAULT_EMS_FONT_LIBRARY_URL,
DEFAULT_EMS_LANDING_PAGE_URL,
DEFAULT_EMS_TILE_API_URL,
} from '../../../../src/plugins/maps_legacy/common';
} from '../../../../src/plugins/maps_ems/common';
const IS_ENTERPRISE_PLUS = () => true;

View file

@ -10,7 +10,7 @@ import {
DEFAULT_EMS_FONT_LIBRARY_URL,
DEFAULT_EMS_LANDING_PAGE_URL,
DEFAULT_EMS_TILE_API_URL,
} from '../../../../src/plugins/maps_legacy/common';
} from '../../../../src/plugins/maps_ems/common';
export interface IEMSConfig {
emsUrl?: string;

View file

@ -17,7 +17,7 @@
"visualizations",
"dashboard",
"embeddable",
"mapsLegacy",
"mapsEms",
"usageCollection",
"savedObjects",
"share",

View file

@ -12,10 +12,10 @@ import { getDataSourceLabel } from '../../../../common/i18n_getters';
import { FIELD_ORIGIN, FORMAT_TYPE, SOURCE_TYPES } from '../../../../common/constants';
import { KibanaRegionField } from '../../fields/kibana_region_field';
import { registerSource } from '../source_registry';
import { KibanaRegionmapSourceDescriptor } from '../../../../common/descriptor_types/source_descriptor_types';
import { KibanaRegionmapSourceDescriptor } from '../../../../common/descriptor_types';
import { Adapters } from '../../../../../../../src/plugins/inspector/common/adapters';
import { IField } from '../../fields/field';
import { LayerConfig } from '../../../../../../../src/plugins/maps_legacy/config';
import type { LayerConfig } from '../../../../../../../src/plugins/maps_ems/public';
export const sourceTitle = i18n.translate('xpack.maps.source.kbnRegionMapTitle', {
defaultMessage: 'Configured GeoJSON',

View file

@ -7,7 +7,7 @@
import _ from 'lodash';
import { CoreStart } from 'kibana/public';
import { MapsLegacyConfig } from '../../../../src/plugins/maps_legacy/config';
import type { MapsEmsConfig } from '../../../../src/plugins/maps_ems/public';
import { MapsConfigType } from '../config';
import { MapsPluginStartDependencies } from './plugin';
import { EMSSettings } from '../common/ems_settings';
@ -62,9 +62,9 @@ export const getEnabled = () => getMapAppConfig().enabled;
export const getShowMapsInspectorAdapter = () => getMapAppConfig().showMapsInspectorAdapter;
export const getPreserveDrawingBuffer = () => getMapAppConfig().preserveDrawingBuffer;
// map.* kibana.yml settings from maps_legacy plugin that are shared between OSS map visualizations and maps app
let kibanaCommonConfig: MapsLegacyConfig;
export const setKibanaCommonConfig = (config: MapsLegacyConfig) => (kibanaCommonConfig = config);
// map.* kibana.yml settings from maps_ems plugin that are shared between OSS map visualizations and maps app
let kibanaCommonConfig: MapsEmsConfig;
export const setKibanaCommonConfig = (config: MapsEmsConfig) => (kibanaCommonConfig = config);
export const getKibanaCommonConfig = () => kibanaCommonConfig;
let emsSettings: EMSSettings;

View file

@ -25,7 +25,7 @@ import {
getEMSSettings,
} from './kibana_services';
import { getLicenseId } from './licensed_features';
import { LayerConfig } from '../../../../src/plugins/maps_legacy/config';
import { LayerConfig } from '../../../../src/plugins/maps_ems/public';
export function getKibanaRegionList(): LayerConfig[] {
return getRegionmapLayers();

View file

@ -51,7 +51,7 @@ import { MapsStartApi } from './api';
import { createLayerDescriptors, registerLayerWizard, registerSource } from './api';
import { SharePluginSetup, SharePluginStart } from '../../../../src/plugins/share/public';
import { EmbeddableStart } from '../../../../src/plugins/embeddable/public';
import { MapsLegacyConfig } from '../../../../src/plugins/maps_legacy/config';
import type { MapsEmsPluginSetup } from '../../../../src/plugins/maps_ems/public';
import { DataPublicPluginStart } from '../../../../src/plugins/data/public';
import { LicensingPluginSetup, LicensingPluginStart } from '../../licensing/public';
import { FileUploadPluginStart } from '../../file_upload/public';
@ -71,7 +71,7 @@ export interface MapsPluginSetupDependencies {
home?: HomePublicPluginSetup;
visualizations: VisualizationsSetup;
embeddable: EmbeddableSetup;
mapsLegacy: { config: MapsLegacyConfig };
mapsEms: MapsEmsPluginSetup;
share: SharePluginSetup;
licensing: LicensingPluginSetup;
}
@ -120,11 +120,11 @@ export class MapsPlugin
registerLicensedFeatures(plugins.licensing);
const config = this._initializerContext.config.get<MapsConfigType>();
setKibanaCommonConfig(plugins.mapsLegacy.config);
setKibanaCommonConfig(plugins.mapsEms.config);
setMapAppConfig(config);
setKibanaVersion(this._initializerContext.env.packageInfo.version);
const emsSettings = new EMSSettings(plugins.mapsLegacy.config, getIsEnterprisePlus);
const emsSettings = new EMSSettings(plugins.mapsEms.config, getIsEnterprisePlus);
setEMSSettings(emsSettings);
// register url generators

View file

@ -6,8 +6,14 @@
*/
import { i18n } from '@kbn/i18n';
import { CoreSetup, CoreStart, Logger, Plugin, PluginInitializerContext } from 'src/core/server';
import { DEFAULT_APP_CATEGORIES } from '../../../../src/core/server';
import {
CoreSetup,
CoreStart,
Logger,
Plugin,
PluginInitializerContext,
DEFAULT_APP_CATEGORIES,
} from '../../../../src/core/server';
import { PluginSetupContract as FeaturesPluginSetupContract } from '../../features/server';
// @ts-ignore
import { getEcommerceSavedObjects } from './sample_data/ecommerce_saved_objects';
@ -28,7 +34,7 @@ import { initRoutes } from './routes';
import { ILicense } from '../../licensing/common/types';
import { LicensingPluginSetup } from '../../licensing/server';
import { HomeServerPluginSetup } from '../../../../src/plugins/home/server';
import { MapsLegacyPluginSetup } from '../../../../src/plugins/maps_legacy/server';
import { MapsEmsPluginSetup } from '../../../../src/plugins/maps_ems/server';
import { EMSSettings } from '../common/ems_settings';
import { PluginStart as DataPluginStart } from '../../../../src/plugins/data/server';
@ -37,7 +43,7 @@ interface SetupDeps {
usageCollection: UsageCollectionSetup;
home: HomeServerPluginSetup;
licensing: LicensingPluginSetup;
mapsLegacy: MapsLegacyPluginSetup;
mapsEms: MapsEmsPluginSetup;
}
export interface StartDeps {
@ -139,8 +145,8 @@ export class MapsPlugin implements Plugin {
// @ts-ignore
setup(core: CoreSetup, plugins: SetupDeps) {
const { usageCollection, home, licensing, features, mapsLegacy } = plugins;
const mapsLegacyConfig = mapsLegacy.config;
const { usageCollection, home, licensing, features, mapsEms } = plugins;
const mapsEmsConfig = mapsEms.config;
const config$ = this._initializerContext.config.create();
const currentConfig = this._initializerContext.config.get();
@ -154,7 +160,7 @@ export class MapsPlugin implements Plugin {
let isEnterprisePlus = false;
let lastLicenseId: string | undefined;
const emsSettings = new EMSSettings(mapsLegacyConfig, () => isEnterprisePlus);
const emsSettings = new EMSSettings(mapsEmsConfig, () => isEnterprisePlus);
licensing.license$.subscribe((license: ILicense) => {
const enterprise = license.check(APP_ID, 'enterprise');
isEnterprisePlus = enterprise.state === 'valid';

View file

@ -16,7 +16,7 @@
],
"references": [
{ "path": "../../../src/core/tsconfig.json" },
{ "path": "../../../src/plugins/maps_legacy/tsconfig.json" },
{ "path": "../../../src/plugins/maps_ems/tsconfig.json" },
{ "path": "../features/tsconfig.json" },
{ "path": "../licensing/tsconfig.json" },
{ "path": "../file_upload/tsconfig.json" },

View file

@ -4,5 +4,5 @@
"kibanaVersion": "kibana",
"server": false,
"ui": true,
"requiredPlugins": ["licensing", "mapsLegacy"]
"requiredPlugins": ["licensing", "mapsEms"]
}

View file

@ -7,6 +7,7 @@
import { CoreSetup, CoreStart, Plugin } from 'kibana/public';
import { LicensingPluginSetup, ILicense } from '../../licensing/public';
import { IServiceSettings, MapsEmsPluginSetup } from '../../../../src/plugins/maps_ems/public';
/**
* These are the interfaces with your public contracts. You should export these
@ -16,7 +17,7 @@ import { LicensingPluginSetup, ILicense } from '../../licensing/public';
export interface MapsLegacyLicensingSetupDependencies {
licensing: LicensingPluginSetup;
mapsLegacy: any;
mapsEms: MapsEmsPluginSetup;
}
// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface MapsLegacyLicensingStartDependencies {}
@ -27,16 +28,16 @@ export type MapsLegacyLicensingStart = ReturnType<MapsLegacyLicensing['start']>;
export class MapsLegacyLicensing
implements Plugin<MapsLegacyLicensingSetup, MapsLegacyLicensingStart> {
public setup(core: CoreSetup, plugins: MapsLegacyLicensingSetupDependencies) {
const { licensing, mapsLegacy } = plugins;
const { licensing, mapsEms } = plugins;
if (licensing) {
licensing.license$.subscribe(async (license: ILicense) => {
const serviceSettings = await mapsLegacy.getServiceSettings();
const serviceSettings: IServiceSettings = await mapsEms.getServiceSettings();
const { uid, isActive } = license;
if (isActive && license.hasAtLeast('basic')) {
serviceSettings.setQueryParams({ license: uid });
serviceSettings.setQueryParams({ license: uid || '' });
serviceSettings.disableZoomMessage();
} else {
serviceSettings.setQueryParams({ license: undefined });
serviceSettings.setQueryParams({ license: '' });
serviceSettings.enableZoomMessage();
}
});

View file

@ -10,5 +10,6 @@
"include": ["public/**/*"],
"references": [
{ "path": "../licensing/tsconfig.json" },
{ "path": "../../../src/plugins/maps_ems/tsconfig.json" }
]
}