From 008d3944c00b309a86f5bd2cf8e2b3c2fb461003 Mon Sep 17 00:00:00 2001 From: Alison Goryachev Date: Wed, 25 Mar 2020 14:33:33 -0400 Subject: [PATCH 01/35] [Remote clusters] Fix handling of remote clusters with deprecated proxy setting (#61126) --- .../common/lib/cluster_serialization.test.ts | 36 ++++++++++- .../common/lib/cluster_serialization.ts | 62 ++++++++++++------- .../remote_clusters/common/lib/index.ts | 7 ++- .../remote_cluster_form.js | 2 + .../server/routes/api/delete_route.test.ts | 40 +++++++++++- .../server/routes/api/delete_route.ts | 15 ++++- .../server/routes/api/update_route.ts | 7 ++- 7 files changed, 139 insertions(+), 30 deletions(-) diff --git a/x-pack/plugins/remote_clusters/common/lib/cluster_serialization.test.ts b/x-pack/plugins/remote_clusters/common/lib/cluster_serialization.test.ts index 10b3dbbd9b45..7fd8b4a89498 100644 --- a/x-pack/plugins/remote_clusters/common/lib/cluster_serialization.test.ts +++ b/x-pack/plugins/remote_clusters/common/lib/cluster_serialization.test.ts @@ -124,6 +124,7 @@ describe('cluster_serialization', () => { skipUnavailable: false, transportPingSchedule: '-1', transportCompress: false, + serverName: 'localhost', }); }); @@ -155,6 +156,38 @@ describe('cluster_serialization', () => { expect(() => serializeCluster('foo')).toThrowError(); }); + it('should serialize a cluster that has a deprecated proxy setting', () => { + expect( + serializeCluster({ + name: 'test_cluster', + proxyAddress: 'localhost:9300', + mode: 'proxy', + isConnected: true, + skipUnavailable: false, + proxySocketConnections: 18, + serverName: 'localhost', + hasDeprecatedProxySetting: true, + }) + ).toEqual({ + persistent: { + cluster: { + remote: { + test_cluster: { + mode: 'proxy', + proxy_socket_connections: 18, + proxy_address: 'localhost:9300', + skip_unavailable: false, + server_name: 'localhost', + proxy: null, + seeds: null, + node_connections: null, + }, + }, + }, + }, + }); + }); + it('should serialize a complete cluster object to only dynamic properties', () => { expect( serializeCluster({ @@ -167,13 +200,14 @@ describe('cluster_serialization', () => { skipUnavailable: false, transportPingSchedule: '-1', transportCompress: false, + mode: 'sniff', }) ).toEqual({ persistent: { cluster: { remote: { test_cluster: { - mode: null, + mode: 'sniff', node_connections: null, proxy_address: null, proxy_socket_connections: null, diff --git a/x-pack/plugins/remote_clusters/common/lib/cluster_serialization.ts b/x-pack/plugins/remote_clusters/common/lib/cluster_serialization.ts index d0898fda93a4..3d8ffa13b821 100644 --- a/x-pack/plugins/remote_clusters/common/lib/cluster_serialization.ts +++ b/x-pack/plugins/remote_clusters/common/lib/cluster_serialization.ts @@ -6,7 +6,8 @@ import { PROXY_MODE } from '../constants'; -export interface ClusterEs { +// Values returned from ES GET /_remote/info +export interface ClusterInfoEs { seeds?: string[]; mode?: 'proxy' | 'sniff'; connected?: boolean; @@ -42,19 +43,23 @@ export interface Cluster { connectedSocketsCount?: number; hasDeprecatedProxySetting?: boolean; } -export interface ClusterPayload { + +interface ClusterPayloadEs { + skip_unavailable?: boolean | null; + mode?: 'sniff' | 'proxy' | null; + proxy_address?: string | null; + proxy_socket_connections?: number | null; + server_name?: string | null; + seeds?: string[] | null; + node_connections?: number | null; + proxy?: null; +} +// Payload expected from ES PUT /_cluster/settings +export interface ClusterSettingsPayloadEs { persistent: { cluster: { remote: { - [key: string]: { - skip_unavailable?: boolean | null; - mode?: 'sniff' | 'proxy' | null; - proxy_address?: string | null; - proxy_socket_connections?: number | null; - server_name?: string | null; - seeds?: string[] | null; - node_connections?: number | null; - }; + [key: string]: ClusterPayloadEs; }; }; }; @@ -62,7 +67,7 @@ export interface ClusterPayload { export function deserializeCluster( name: string, - esClusterObject: ClusterEs, + esClusterObject: ClusterInfoEs, deprecatedProxyAddress?: string | undefined ): Cluster { if (!name || !esClusterObject || typeof esClusterObject !== 'object') { @@ -112,12 +117,16 @@ export function deserializeCluster( // If a user has a remote cluster with the deprecated proxy setting, // we transform the data to support the new implementation and also flag the deprecation if (deprecatedProxyAddress) { + // Create server name (address, without port), since field doesn't exist in deprecated implementation + const defaultServerName = deprecatedProxyAddress.split(':')[0]; + deserializedClusterObject = { ...deserializedClusterObject, proxyAddress: deprecatedProxyAddress, seeds: undefined, hasDeprecatedProxySetting: true, mode: PROXY_MODE, + serverName: defaultServerName, }; } @@ -131,7 +140,7 @@ export function deserializeCluster( return deserializedClusterObject; } -export function serializeCluster(deserializedClusterObject: Cluster): ClusterPayload { +export function serializeCluster(deserializedClusterObject: Cluster): ClusterSettingsPayloadEs { if (!deserializedClusterObject || typeof deserializedClusterObject !== 'object') { throw new Error('Unable to serialize cluster'); } @@ -145,22 +154,31 @@ export function serializeCluster(deserializedClusterObject: Cluster): ClusterPay proxyAddress, proxySocketConnections, serverName, + hasDeprecatedProxySetting, } = deserializedClusterObject; + const clusterData: ClusterPayloadEs = { + skip_unavailable: typeof skipUnavailable === 'boolean' ? skipUnavailable : null, + mode: mode || null, + proxy_address: proxyAddress || null, + proxy_socket_connections: proxySocketConnections || null, + server_name: serverName || null, + seeds: seeds || null, + node_connections: nodeConnections || null, + }; + + // This is only applicable in edit mode + // In order to "upgrade" an existing remote cluster to use the new proxy mode settings, we need to set the old proxy setting to null + if (hasDeprecatedProxySetting) { + clusterData.proxy = null; + } + return { // Background on why we only save as persistent settings detailed here: https://github.com/elastic/kibana/pull/26067#issuecomment-441848124 persistent: { cluster: { remote: { - [name]: { - skip_unavailable: typeof skipUnavailable === 'boolean' ? skipUnavailable : null, - mode: mode || null, - proxy_address: proxyAddress || null, - proxy_socket_connections: proxySocketConnections || null, - server_name: serverName || null, - seeds: seeds || null, - node_connections: nodeConnections || null, - }, + [name]: clusterData, }, }, }, diff --git a/x-pack/plugins/remote_clusters/common/lib/index.ts b/x-pack/plugins/remote_clusters/common/lib/index.ts index 52a0536bfd55..43cf004becff 100644 --- a/x-pack/plugins/remote_clusters/common/lib/index.ts +++ b/x-pack/plugins/remote_clusters/common/lib/index.ts @@ -4,4 +4,9 @@ * you may not use this file except in compliance with the Elastic License. */ -export { deserializeCluster, serializeCluster, Cluster, ClusterEs } from './cluster_serialization'; +export { + deserializeCluster, + serializeCluster, + Cluster, + ClusterInfoEs, +} from './cluster_serialization'; diff --git a/x-pack/plugins/remote_clusters/public/application/sections/components/remote_cluster_form/remote_cluster_form.js b/x-pack/plugins/remote_clusters/public/application/sections/components/remote_cluster_form/remote_cluster_form.js index 94d6ca4ebb64..7d3ed0708ae5 100644 --- a/x-pack/plugins/remote_clusters/public/application/sections/components/remote_cluster_form/remote_cluster_form.js +++ b/x-pack/plugins/remote_clusters/public/application/sections/components/remote_cluster_form/remote_cluster_form.js @@ -135,6 +135,7 @@ export class RemoteClusterForm extends Component { skipUnavailable, }, } = this.state; + const { fields } = this.props; let modeSettings; @@ -155,6 +156,7 @@ export class RemoteClusterForm extends Component { name, skipUnavailable, mode, + hasDeprecatedProxySetting: fields.hasDeprecatedProxySetting, ...modeSettings, }; } diff --git a/x-pack/plugins/remote_clusters/server/routes/api/delete_route.test.ts b/x-pack/plugins/remote_clusters/server/routes/api/delete_route.test.ts index cf14f8a67054..ec14336da08d 100644 --- a/x-pack/plugins/remote_clusters/server/routes/api/delete_route.test.ts +++ b/x-pack/plugins/remote_clusters/server/routes/api/delete_route.test.ts @@ -84,6 +84,20 @@ describe('DELETE remote clusters', () => { describe('success', () => { deleteRemoteClustersTest('deletes remote cluster', { apiResponses: [ + async () => ({ + persistent: { + cluster: { + remote: { + test: { + seeds: ['127.0.0.1:9300'], + skip_unavailable: false, + mode: 'sniff', + }, + }, + }, + }, + transient: {}, + }), async () => ({ test: { connected: true, @@ -143,7 +157,17 @@ describe('DELETE remote clusters', () => { deleteRemoteClustersTest( 'returns errors array with 404 error if remote cluster does not exist', { - apiResponses: [async () => ({})], + apiResponses: [ + async () => ({ + persistent: { + cluster: { + remote: {}, + }, + }, + transient: {}, + }), + async () => ({}), + ], params: { nameOrNames: 'test', }, @@ -178,6 +202,20 @@ describe('DELETE remote clusters', () => { 'returns errors array with 400 error if ES still returns cluster information', { apiResponses: [ + async () => ({ + persistent: { + cluster: { + remote: { + test: { + seeds: ['127.0.0.1:9300'], + skip_unavailable: false, + mode: 'sniff', + }, + }, + }, + }, + transient: {}, + }), async () => ({ test: { connected: true, diff --git a/x-pack/plugins/remote_clusters/server/routes/api/delete_route.ts b/x-pack/plugins/remote_clusters/server/routes/api/delete_route.ts index 742780ffed30..07b0fa3fd9cd 100644 --- a/x-pack/plugins/remote_clusters/server/routes/api/delete_route.ts +++ b/x-pack/plugins/remote_clusters/server/routes/api/delete_route.ts @@ -37,6 +37,8 @@ export const register = (deps: RouteDependencies): void => { const itemsDeleted: any[] = []; const errors: any[] = []; + const clusterSettings = await callAsCurrentUser('cluster.getSettings'); + // Validator that returns an error if the remote cluster does not exist. const validateClusterDoesExist = async (name: string) => { try { @@ -60,9 +62,12 @@ export const register = (deps: RouteDependencies): void => { }; // Send the request to delete the cluster and return an error if it could not be deleted. - const sendRequestToDeleteCluster = async (name: string) => { + const sendRequestToDeleteCluster = async ( + name: string, + hasDeprecatedProxySetting: boolean + ) => { try { - const body = serializeCluster({ name }); + const body = serializeCluster({ name, hasDeprecatedProxySetting }); const updateClusterResponse = await callAsCurrentUser('cluster.putSettings', { body }); const acknowledged = get(updateClusterResponse, 'acknowledged'); const cluster = get(updateClusterResponse, `persistent.cluster.remote.${name}`); @@ -98,8 +103,12 @@ export const register = (deps: RouteDependencies): void => { let error: any = await validateClusterDoesExist(clusterName); if (!error) { + // Check if cluster contains deprecated proxy setting + const hasDeprecatedProxySetting = Boolean( + get(clusterSettings, `persistent.cluster.remote[${clusterName}].proxy`, undefined) + ); // Delete the cluster. - error = await sendRequestToDeleteCluster(clusterName); + error = await sendRequestToDeleteCluster(clusterName, hasDeprecatedProxySetting); } if (error) { diff --git a/x-pack/plugins/remote_clusters/server/routes/api/update_route.ts b/x-pack/plugins/remote_clusters/server/routes/api/update_route.ts index 14b161b6f26b..47b0d4ad2def 100644 --- a/x-pack/plugins/remote_clusters/server/routes/api/update_route.ts +++ b/x-pack/plugins/remote_clusters/server/routes/api/update_route.ts @@ -10,7 +10,7 @@ import { i18n } from '@kbn/i18n'; import { RequestHandler } from 'src/core/server'; import { API_BASE_PATH, SNIFF_MODE, PROXY_MODE } from '../../../common/constants'; -import { serializeCluster, deserializeCluster, Cluster, ClusterEs } from '../../../common/lib'; +import { serializeCluster, deserializeCluster, Cluster, ClusterInfoEs } from '../../../common/lib'; import { doesClusterExist } from '../../lib/does_cluster_exist'; import { RouteDependencies } from '../../types'; import { licensePreRoutingFactory } from '../../lib/license_pre_routing_factory'; @@ -68,7 +68,10 @@ export const register = (deps: RouteDependencies): void => { }); const acknowledged = get(updateClusterResponse, 'acknowledged'); - const cluster = get(updateClusterResponse, `persistent.cluster.remote.${name}`) as ClusterEs; + const cluster = get( + updateClusterResponse, + `persistent.cluster.remote.${name}` + ) as ClusterInfoEs; if (acknowledged && cluster) { const body = { From 4c70ef54a7656361886568195946b9cd361d20f5 Mon Sep 17 00:00:00 2001 From: Nathan Reese Date: Wed, 25 Mar 2020 13:42:50 -0600 Subject: [PATCH 02/35] descriptors to descriptor_types (#61290) Co-authored-by: Elastic Machine --- x-pack/legacy/plugins/maps/common/descriptor_types.ts | 8 ++++++++ .../plugins/maps/public/actions/map_actions.d.ts | 2 +- .../plugins/maps/public/layers/blended_vector_layer.ts | 2 +- .../plugins/maps/public/layers/sources/es_source.d.ts | 2 +- .../maps/public/layers/sources/vector_source.d.ts | 2 +- .../field_meta/categorical_field_meta_popover.tsx | 2 +- .../field_meta/ordinal_field_meta_popover.tsx | 2 +- .../vector/properties/dynamic_style_property.d.ts | 7 ++++--- .../layers/styles/vector/properties/style_property.ts | 5 +---- .../maps/public/layers/styles/vector/vector_style.d.ts | 2 +- .../layers/styles/vector/vector_style_defaults.ts | 2 +- .../plugins/maps/public/layers/util/can_skip_fetch.ts | 2 +- .../plugins/maps/public/layers/util/data_request.ts | 2 +- .../maps/public/layers/util/is_refresh_only_query.ts | 2 +- .../plugins/maps/public/layers/vector_layer.d.ts | 7 +++++-- .../data_request_descriptor_types.d.ts | 0 .../common/descriptor_types}/descriptor_types.d.ts | 2 +- x-pack/plugins/maps/common/descriptor_types/index.ts | 10 ++++++++++ .../maps/common/descriptor_types}/map_descriptor.ts | 0 .../style_property_descriptor_types.d.ts | 2 +- 20 files changed, 41 insertions(+), 22 deletions(-) create mode 100644 x-pack/legacy/plugins/maps/common/descriptor_types.ts rename x-pack/{legacy/plugins/maps/common => plugins/maps/common/descriptor_types}/data_request_descriptor_types.d.ts (100%) rename x-pack/{legacy/plugins/maps/common => plugins/maps/common/descriptor_types}/descriptor_types.d.ts (99%) create mode 100644 x-pack/plugins/maps/common/descriptor_types/index.ts rename x-pack/{legacy/plugins/maps/common => plugins/maps/common/descriptor_types}/map_descriptor.ts (100%) rename x-pack/{legacy/plugins/maps/common => plugins/maps/common/descriptor_types}/style_property_descriptor_types.d.ts (99%) diff --git a/x-pack/legacy/plugins/maps/common/descriptor_types.ts b/x-pack/legacy/plugins/maps/common/descriptor_types.ts new file mode 100644 index 000000000000..1f0eda26e7f7 --- /dev/null +++ b/x-pack/legacy/plugins/maps/common/descriptor_types.ts @@ -0,0 +1,8 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +// eslint-disable-next-line @kbn/eslint/no-restricted-paths +export * from '../../../../plugins/maps/common/descriptor_types'; diff --git a/x-pack/legacy/plugins/maps/public/actions/map_actions.d.ts b/x-pack/legacy/plugins/maps/public/actions/map_actions.d.ts index 3a61d5affd86..48ab95708936 100644 --- a/x-pack/legacy/plugins/maps/public/actions/map_actions.d.ts +++ b/x-pack/legacy/plugins/maps/public/actions/map_actions.d.ts @@ -6,7 +6,7 @@ /* eslint-disable @typescript-eslint/consistent-type-definitions */ import { LAYER_TYPE } from '../../common/constants'; -import { DataMeta, MapFilters } from '../../common/data_request_descriptor_types'; +import { DataMeta, MapFilters } from '../../common/descriptor_types'; export type SyncContext = { startLoading(dataId: string, requestToken: symbol, meta: DataMeta): void; diff --git a/x-pack/legacy/plugins/maps/public/layers/blended_vector_layer.ts b/x-pack/legacy/plugins/maps/public/layers/blended_vector_layer.ts index 8c54720987e4..f5526ad703dd 100644 --- a/x-pack/legacy/plugins/maps/public/layers/blended_vector_layer.ts +++ b/x-pack/legacy/plugins/maps/public/layers/blended_vector_layer.ts @@ -34,7 +34,7 @@ import { VectorStyleDescriptor, SizeDynamicOptions, DynamicStylePropertyOptions, -} from '../../common/style_property_descriptor_types'; +} from '../../common/descriptor_types'; const ACTIVE_COUNT_DATA_ID = 'ACTIVE_COUNT_DATA_ID'; diff --git a/x-pack/legacy/plugins/maps/public/layers/sources/es_source.d.ts b/x-pack/legacy/plugins/maps/public/layers/sources/es_source.d.ts index b565cb9108ae..ffd1d343b59e 100644 --- a/x-pack/legacy/plugins/maps/public/layers/sources/es_source.d.ts +++ b/x-pack/legacy/plugins/maps/public/layers/sources/es_source.d.ts @@ -7,7 +7,7 @@ import { AbstractVectorSource } from './vector_source'; import { IVectorSource } from './vector_source'; import { IndexPattern, SearchSource } from '../../../../../../../src/plugins/data/public'; -import { VectorSourceRequestMeta } from '../../../common/data_request_descriptor_types'; +import { VectorSourceRequestMeta } from '../../../common/descriptor_types'; export interface IESSource extends IVectorSource { getId(): string; diff --git a/x-pack/legacy/plugins/maps/public/layers/sources/vector_source.d.ts b/x-pack/legacy/plugins/maps/public/layers/sources/vector_source.d.ts index fd585e100924..7a747da24423 100644 --- a/x-pack/legacy/plugins/maps/public/layers/sources/vector_source.d.ts +++ b/x-pack/legacy/plugins/maps/public/layers/sources/vector_source.d.ts @@ -8,7 +8,7 @@ import { FeatureCollection } from 'geojson'; import { AbstractSource, ISource } from './source'; import { IField } from '../fields/field'; -import { ESSearchSourceResponseMeta } from '../../../common/data_request_descriptor_types'; +import { ESSearchSourceResponseMeta } from '../../../common/descriptor_types'; export type GeoJsonFetchMeta = ESSearchSourceResponseMeta; diff --git a/x-pack/legacy/plugins/maps/public/layers/styles/vector/components/field_meta/categorical_field_meta_popover.tsx b/x-pack/legacy/plugins/maps/public/layers/styles/vector/components/field_meta/categorical_field_meta_popover.tsx index 9aec7ece45f3..550b3737963d 100644 --- a/x-pack/legacy/plugins/maps/public/layers/styles/vector/components/field_meta/categorical_field_meta_popover.tsx +++ b/x-pack/legacy/plugins/maps/public/layers/styles/vector/components/field_meta/categorical_field_meta_popover.tsx @@ -11,7 +11,7 @@ import { EuiFormRow, EuiSwitch, EuiSwitchEvent } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { FieldMetaPopover } from './field_meta_popover'; import { IDynamicStyleProperty } from '../../properties/dynamic_style_property'; -import { FieldMetaOptions } from '../../../../../../common/style_property_descriptor_types'; +import { FieldMetaOptions } from '../../../../../../common/descriptor_types'; type Props = { styleProperty: IDynamicStyleProperty; diff --git a/x-pack/legacy/plugins/maps/public/layers/styles/vector/components/field_meta/ordinal_field_meta_popover.tsx b/x-pack/legacy/plugins/maps/public/layers/styles/vector/components/field_meta/ordinal_field_meta_popover.tsx index 777f60b5075a..32a54a45ed4d 100644 --- a/x-pack/legacy/plugins/maps/public/layers/styles/vector/components/field_meta/ordinal_field_meta_popover.tsx +++ b/x-pack/legacy/plugins/maps/public/layers/styles/vector/components/field_meta/ordinal_field_meta_popover.tsx @@ -12,7 +12,7 @@ import { i18n } from '@kbn/i18n'; import { DEFAULT_SIGMA } from '../../vector_style_defaults'; import { FieldMetaPopover } from './field_meta_popover'; import { IDynamicStyleProperty } from '../../properties/dynamic_style_property'; -import { FieldMetaOptions } from '../../../../../../common/style_property_descriptor_types'; +import { FieldMetaOptions } from '../../../../../../common/descriptor_types'; import { VECTOR_STYLES } from '../../../../../../common/constants'; function getIsEnableToggleLabel(styleName: string) { diff --git a/x-pack/legacy/plugins/maps/public/layers/styles/vector/properties/dynamic_style_property.d.ts b/x-pack/legacy/plugins/maps/public/layers/styles/vector/properties/dynamic_style_property.d.ts index a83dd55c0c17..88eb489c4996 100644 --- a/x-pack/legacy/plugins/maps/public/layers/styles/vector/properties/dynamic_style_property.d.ts +++ b/x-pack/legacy/plugins/maps/public/layers/styles/vector/properties/dynamic_style_property.d.ts @@ -8,11 +8,12 @@ import { IStyleProperty } from './style_property'; import { FIELD_ORIGIN } from '../../../../../common/constants'; import { - FieldMetaOptions, + CategoryFieldMeta, DynamicStylePropertyOptions, -} from '../../../../../common/style_property_descriptor_types'; + FieldMetaOptions, + RangeFieldMeta, +} from '../../../../../common/descriptor_types'; import { IField } from '../../../fields/field'; -import { CategoryFieldMeta, RangeFieldMeta } from '../../../../../common/descriptor_types'; export interface IDynamicStyleProperty extends IStyleProperty { getOptions(): DynamicStylePropertyOptions; diff --git a/x-pack/legacy/plugins/maps/public/layers/styles/vector/properties/style_property.ts b/x-pack/legacy/plugins/maps/public/layers/styles/vector/properties/style_property.ts index fef7778c5f08..af04a95e3c3b 100644 --- a/x-pack/legacy/plugins/maps/public/layers/styles/vector/properties/style_property.ts +++ b/x-pack/legacy/plugins/maps/public/layers/styles/vector/properties/style_property.ts @@ -8,10 +8,7 @@ import { ReactElement } from 'react'; // @ts-ignore import { getVectorStyleLabel } from '../components/get_vector_style_label'; -import { - FieldMetaOptions, - StylePropertyOptions, -} from '../../../../../common/style_property_descriptor_types'; +import { FieldMetaOptions, StylePropertyOptions } from '../../../../../common/descriptor_types'; import { VECTOR_STYLES } from '../../../../../common/constants'; type LegendProps = { diff --git a/x-pack/legacy/plugins/maps/public/layers/styles/vector/vector_style.d.ts b/x-pack/legacy/plugins/maps/public/layers/styles/vector/vector_style.d.ts index 37aea501f519..77ea44ac26bf 100644 --- a/x-pack/legacy/plugins/maps/public/layers/styles/vector/vector_style.d.ts +++ b/x-pack/legacy/plugins/maps/public/layers/styles/vector/vector_style.d.ts @@ -7,7 +7,7 @@ import { IStyleProperty } from './properties/style_property'; import { IDynamicStyleProperty } from './properties/dynamic_style_property'; import { IVectorLayer } from '../../vector_layer'; import { IVectorSource } from '../../sources/vector_source'; -import { VectorStyleDescriptor } from '../../../../common/style_property_descriptor_types'; +import { VectorStyleDescriptor } from '../../../../common/descriptor_types'; export interface IVectorStyle { getAllStyleProperties(): IStyleProperty[]; diff --git a/x-pack/legacy/plugins/maps/public/layers/styles/vector/vector_style_defaults.ts b/x-pack/legacy/plugins/maps/public/layers/styles/vector/vector_style_defaults.ts index f104afd2a785..86602381cf61 100644 --- a/x-pack/legacy/plugins/maps/public/layers/styles/vector/vector_style_defaults.ts +++ b/x-pack/legacy/plugins/maps/public/layers/styles/vector/vector_style_defaults.ts @@ -18,7 +18,7 @@ import { DEFAULT_LINE_COLORS, // @ts-ignore } from '../color_utils'; -import { VectorStylePropertiesDescriptor } from '../../../../common/style_property_descriptor_types'; +import { VectorStylePropertiesDescriptor } from '../../../../common/descriptor_types'; // @ts-ignore import { getUiSettings } from '../../../kibana_services'; diff --git a/x-pack/legacy/plugins/maps/public/layers/util/can_skip_fetch.ts b/x-pack/legacy/plugins/maps/public/layers/util/can_skip_fetch.ts index 7b75bb0f21b7..758cc35f41fb 100644 --- a/x-pack/legacy/plugins/maps/public/layers/util/can_skip_fetch.ts +++ b/x-pack/legacy/plugins/maps/public/layers/util/can_skip_fetch.ts @@ -9,7 +9,7 @@ import turf from 'turf'; import turfBooleanContains from '@turf/boolean-contains'; import { isRefreshOnlyQuery } from './is_refresh_only_query'; import { ISource } from '../sources/source'; -import { DataMeta } from '../../../common/data_request_descriptor_types'; +import { DataMeta } from '../../../common/descriptor_types'; import { DataRequest } from './data_request'; const SOURCE_UPDATE_REQUIRED = true; diff --git a/x-pack/legacy/plugins/maps/public/layers/util/data_request.ts b/x-pack/legacy/plugins/maps/public/layers/util/data_request.ts index e36157419462..eeef5c49c6ef 100644 --- a/x-pack/legacy/plugins/maps/public/layers/util/data_request.ts +++ b/x-pack/legacy/plugins/maps/public/layers/util/data_request.ts @@ -6,7 +6,7 @@ /* eslint-disable max-classes-per-file */ import _ from 'lodash'; -import { DataRequestDescriptor, DataMeta } from '../../../common/data_request_descriptor_types'; +import { DataRequestDescriptor, DataMeta } from '../../../common/descriptor_types'; export class DataRequest { private readonly _descriptor: DataRequestDescriptor; diff --git a/x-pack/legacy/plugins/maps/public/layers/util/is_refresh_only_query.ts b/x-pack/legacy/plugins/maps/public/layers/util/is_refresh_only_query.ts index 48b1340207fd..a56da4b23aa1 100644 --- a/x-pack/legacy/plugins/maps/public/layers/util/is_refresh_only_query.ts +++ b/x-pack/legacy/plugins/maps/public/layers/util/is_refresh_only_query.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { Query } from '../../../common/map_descriptor'; +import { Query } from '../../../common/descriptor_types'; // Refresh only query is query where timestamps are different but query is the same. // Triggered by clicking "Refresh" button in QueryBar diff --git a/x-pack/legacy/plugins/maps/public/layers/vector_layer.d.ts b/x-pack/legacy/plugins/maps/public/layers/vector_layer.d.ts index 390374f761fc..70fd9927b773 100644 --- a/x-pack/legacy/plugins/maps/public/layers/vector_layer.d.ts +++ b/x-pack/legacy/plugins/maps/public/layers/vector_layer.d.ts @@ -7,8 +7,11 @@ import { AbstractLayer } from './layer'; import { IVectorSource } from './sources/vector_source'; -import { VectorLayerDescriptor } from '../../common/descriptor_types'; -import { MapFilters, VectorSourceRequestMeta } from '../../common/data_request_descriptor_types'; +import { + MapFilters, + VectorLayerDescriptor, + VectorSourceRequestMeta, +} from '../../common/descriptor_types'; import { ILayer } from './layer'; import { IJoin } from './joins/join'; import { IVectorStyle } from './styles/vector/vector_style'; diff --git a/x-pack/legacy/plugins/maps/common/data_request_descriptor_types.d.ts b/x-pack/plugins/maps/common/descriptor_types/data_request_descriptor_types.d.ts similarity index 100% rename from x-pack/legacy/plugins/maps/common/data_request_descriptor_types.d.ts rename to x-pack/plugins/maps/common/descriptor_types/data_request_descriptor_types.d.ts diff --git a/x-pack/legacy/plugins/maps/common/descriptor_types.d.ts b/x-pack/plugins/maps/common/descriptor_types/descriptor_types.d.ts similarity index 99% rename from x-pack/legacy/plugins/maps/common/descriptor_types.d.ts rename to x-pack/plugins/maps/common/descriptor_types/descriptor_types.d.ts index cfbcb65255ab..fb49e1aaebe1 100644 --- a/x-pack/legacy/plugins/maps/common/descriptor_types.d.ts +++ b/x-pack/plugins/maps/common/descriptor_types/descriptor_types.d.ts @@ -5,7 +5,7 @@ */ /* eslint-disable @typescript-eslint/consistent-type-definitions */ -import { AGG_TYPE, GRID_RESOLUTION, RENDER_AS, SORT_ORDER, SCALING_TYPES } from './constants'; +import { AGG_TYPE, GRID_RESOLUTION, RENDER_AS, SORT_ORDER, SCALING_TYPES } from '../constants'; import { VectorStyleDescriptor } from './style_property_descriptor_types'; import { DataRequestDescriptor } from './data_request_descriptor_types'; diff --git a/x-pack/plugins/maps/common/descriptor_types/index.ts b/x-pack/plugins/maps/common/descriptor_types/index.ts new file mode 100644 index 000000000000..af0f4487f471 --- /dev/null +++ b/x-pack/plugins/maps/common/descriptor_types/index.ts @@ -0,0 +1,10 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +export * from './data_request_descriptor_types'; +export * from './descriptor_types'; +export * from './map_descriptor'; +export * from './style_property_descriptor_types'; diff --git a/x-pack/legacy/plugins/maps/common/map_descriptor.ts b/x-pack/plugins/maps/common/descriptor_types/map_descriptor.ts similarity index 100% rename from x-pack/legacy/plugins/maps/common/map_descriptor.ts rename to x-pack/plugins/maps/common/descriptor_types/map_descriptor.ts diff --git a/x-pack/legacy/plugins/maps/common/style_property_descriptor_types.d.ts b/x-pack/plugins/maps/common/descriptor_types/style_property_descriptor_types.d.ts similarity index 99% rename from x-pack/legacy/plugins/maps/common/style_property_descriptor_types.d.ts rename to x-pack/plugins/maps/common/descriptor_types/style_property_descriptor_types.d.ts index 2fce56339e10..47e56ff96d62 100644 --- a/x-pack/legacy/plugins/maps/common/style_property_descriptor_types.d.ts +++ b/x-pack/plugins/maps/common/descriptor_types/style_property_descriptor_types.d.ts @@ -12,7 +12,7 @@ import { VECTOR_STYLES, STYLE_TYPE, LAYER_STYLE_TYPE, -} from './constants'; +} from '../constants'; // Non-static/dynamic options export type SymbolizeAsOptions = { From a16968dd3a92216f1da14eb992690181b29693e2 Mon Sep 17 00:00:00 2001 From: Poff Poffenberger Date: Wed, 25 Mar 2020 14:54:32 -0500 Subject: [PATCH 03/35] [Canvas] Fix map embeddables not showing up on PDF reports (#61149) * Allow embeddables to track their own render complete for report generation in canvas * Updating following consult with reporting team Co-authored-by: Elastic Machine --- .../canvas/public/apps/export/export/export_app.js | 3 ++- .../element_share_container/element_share_container.js | 8 ++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/x-pack/legacy/plugins/canvas/public/apps/export/export/export_app.js b/x-pack/legacy/plugins/canvas/public/apps/export/export/export_app.js index 9b198cee34aa..7537f8eaa903 100644 --- a/x-pack/legacy/plugins/canvas/public/apps/export/export/export_app.js +++ b/x-pack/legacy/plugins/canvas/public/apps/export/export/export_app.js @@ -28,6 +28,7 @@ export class ExportApp extends React.PureComponent { const { workpad, selectedPageId } = this.props; const { pages, height, width } = workpad; const activePage = pages.find(page => page.id === selectedPageId); + const pageElementCount = activePage.elements.length; return (
@@ -39,7 +40,7 @@ export class ExportApp extends React.PureComponent {
{Style.it( workpad.css, -
+
(this.sharedItemRef = ref)} > From d50fe0c985c711dfaa1c2b99fed4292eebe56398 Mon Sep 17 00:00:00 2001 From: Zacqary Adam Xeper Date: Wed, 25 Mar 2020 15:56:35 -0500 Subject: [PATCH 04/35] [Logs / Metrics UI] [NP followup] Cleanup link-to routes (#61162) * Split link-to into Metrics and Logs routers * Fix logs stream link-to * Import fix * Update snapshots Co-authored-by: Elastic Machine --- .../with_log_position_url_state.tsx | 2 ++ .../infra/public/pages/link_to/index.ts | 3 +- .../public/pages/link_to/link_to_logs.tsx | 34 +++++++++++++++++++ .../{link_to.tsx => link_to_metrics.tsx} | 11 ++---- .../pages/link_to/redirect_to_logs.test.tsx | 4 +-- .../link_to/redirect_to_node_logs.test.tsx | 4 +-- .../infra/public/routers/logs_router.tsx | 4 +-- .../infra/public/routers/metrics_router.tsx | 4 +-- x-pack/test/functional/apps/infra/link_to.ts | 2 +- 9 files changed, 49 insertions(+), 19 deletions(-) create mode 100644 x-pack/plugins/infra/public/pages/link_to/link_to_logs.tsx rename x-pack/plugins/infra/public/pages/link_to/{link_to.tsx => link_to_metrics.tsx} (68%) diff --git a/x-pack/plugins/infra/public/containers/logs/log_position/with_log_position_url_state.tsx b/x-pack/plugins/infra/public/containers/logs/log_position/with_log_position_url_state.tsx index 0d3586f9376f..ddd5b471a02c 100644 --- a/x-pack/plugins/infra/public/containers/logs/log_position/with_log_position_url_state.tsx +++ b/x-pack/plugins/infra/public/containers/logs/log_position/with_log_position_url_state.tsx @@ -144,5 +144,7 @@ export const replaceLogPositionInQueryString = (time: number) => time, tiebreaker: 0, }, + end: new Date(time + ONE_HOUR).toISOString(), + start: new Date(time - ONE_HOUR).toISOString(), streamLive: false, }); diff --git a/x-pack/plugins/infra/public/pages/link_to/index.ts b/x-pack/plugins/infra/public/pages/link_to/index.ts index 4c8051f8da73..27e2d483f8fa 100644 --- a/x-pack/plugins/infra/public/pages/link_to/index.ts +++ b/x-pack/plugins/infra/public/pages/link_to/index.ts @@ -4,6 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -export { LinkToPage } from './link_to'; +export { LinkToLogsPage } from './link_to_logs'; +export { LinkToMetricsPage } from './link_to_metrics'; export { getNodeLogsUrl, RedirectToNodeLogs } from './redirect_to_node_logs'; export { getNodeDetailUrl, RedirectToNodeDetail } from './redirect_to_node_detail'; diff --git a/x-pack/plugins/infra/public/pages/link_to/link_to_logs.tsx b/x-pack/plugins/infra/public/pages/link_to/link_to_logs.tsx new file mode 100644 index 000000000000..04d5c454a92c --- /dev/null +++ b/x-pack/plugins/infra/public/pages/link_to/link_to_logs.tsx @@ -0,0 +1,34 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import React from 'react'; +import { match as RouteMatch, Redirect, Route, Switch } from 'react-router-dom'; + +import { RedirectToLogs } from './redirect_to_logs'; +import { RedirectToNodeLogs } from './redirect_to_node_logs'; +import { inventoryModels } from '../../../common/inventory_models'; + +interface LinkToPageProps { + match: RouteMatch<{}>; + location: { + search: string; + }; +} + +const ITEM_TYPES = inventoryModels.map(m => m.id).join('|'); + +export const LinkToLogsPage: React.FC = props => { + return ( + + + + + + ); +}; diff --git a/x-pack/plugins/infra/public/pages/link_to/link_to.tsx b/x-pack/plugins/infra/public/pages/link_to/link_to_metrics.tsx similarity index 68% rename from x-pack/plugins/infra/public/pages/link_to/link_to.tsx rename to x-pack/plugins/infra/public/pages/link_to/link_to_metrics.tsx index ce62a0a3f4e3..3eb4a9f26fe2 100644 --- a/x-pack/plugins/infra/public/pages/link_to/link_to.tsx +++ b/x-pack/plugins/infra/public/pages/link_to/link_to_metrics.tsx @@ -7,9 +7,7 @@ import React from 'react'; import { match as RouteMatch, Redirect, Route, Switch } from 'react-router-dom'; -import { RedirectToLogs } from './redirect_to_logs'; import { RedirectToNodeDetail } from './redirect_to_node_detail'; -import { RedirectToNodeLogs } from './redirect_to_node_logs'; import { RedirectToHostDetailViaIP } from './redirect_to_host_detail_via_ip'; import { inventoryModels } from '../../../common/inventory_models'; @@ -19,13 +17,9 @@ interface LinkToPageProps { const ITEM_TYPES = inventoryModels.map(m => m.id).join('|'); -export const LinkToPage: React.FC = props => { +export const LinkToMetricsPage: React.FC = props => { return ( - = props => { path={`${props.match.url}/host-detail-via-ip/:hostIp`} component={RedirectToHostDetailViaIP} /> - - + ); }; diff --git a/x-pack/plugins/infra/public/pages/link_to/redirect_to_logs.test.tsx b/x-pack/plugins/infra/public/pages/link_to/redirect_to_logs.test.tsx index b4ed43f84e27..0556955e47f6 100644 --- a/x-pack/plugins/infra/public/pages/link_to/redirect_to_logs.test.tsx +++ b/x-pack/plugins/infra/public/pages/link_to/redirect_to_logs.test.tsx @@ -19,7 +19,7 @@ describe('RedirectToLogs component', () => { expect(component).toMatchInlineSnapshot(` `); }); @@ -33,7 +33,7 @@ describe('RedirectToLogs component', () => { expect(component).toMatchInlineSnapshot(` `); }); diff --git a/x-pack/plugins/infra/public/pages/link_to/redirect_to_node_logs.test.tsx b/x-pack/plugins/infra/public/pages/link_to/redirect_to_node_logs.test.tsx index 519ee6406093..1394fc48107e 100644 --- a/x-pack/plugins/infra/public/pages/link_to/redirect_to_node_logs.test.tsx +++ b/x-pack/plugins/infra/public/pages/link_to/redirect_to_node_logs.test.tsx @@ -73,7 +73,7 @@ describe('RedirectToNodeLogs component', () => { expect(component).toMatchInlineSnapshot(` `); }); @@ -89,7 +89,7 @@ describe('RedirectToNodeLogs component', () => { expect(component).toMatchInlineSnapshot(` `); }); diff --git a/x-pack/plugins/infra/public/routers/logs_router.tsx b/x-pack/plugins/infra/public/routers/logs_router.tsx index 6700ed1fc847..8258f087b587 100644 --- a/x-pack/plugins/infra/public/routers/logs_router.tsx +++ b/x-pack/plugins/infra/public/routers/logs_router.tsx @@ -8,7 +8,7 @@ import React from 'react'; import { Route, Router, Switch } from 'react-router-dom'; import { NotFoundPage } from '../pages/404'; -import { LinkToPage } from '../pages/link_to'; +import { LinkToLogsPage } from '../pages/link_to'; import { LogsPage } from '../pages/logs'; import { RedirectWithQueryParams } from '../utils/redirect_with_query_params'; import { useKibana } from '../../../../../src/plugins/kibana_react/public'; @@ -19,7 +19,7 @@ export const LogsRouter: AppRouter = ({ history }) => { return ( - + {uiCapabilities?.logs?.show && ( )} diff --git a/x-pack/plugins/infra/public/routers/metrics_router.tsx b/x-pack/plugins/infra/public/routers/metrics_router.tsx index 7c2ebed8463f..7cb9de65e729 100644 --- a/x-pack/plugins/infra/public/routers/metrics_router.tsx +++ b/x-pack/plugins/infra/public/routers/metrics_router.tsx @@ -9,7 +9,7 @@ import { Route, Router, Switch } from 'react-router-dom'; import { NotFoundPage } from '../pages/404'; import { InfrastructurePage } from '../pages/infrastructure'; -import { LinkToPage } from '../pages/link_to'; +import { LinkToMetricsPage } from '../pages/link_to'; import { MetricDetail } from '../pages/metrics'; import { RedirectWithQueryParams } from '../utils/redirect_with_query_params'; import { useKibana } from '../../../../../src/plugins/kibana_react/public'; @@ -20,7 +20,7 @@ export const MetricsRouter: AppRouter = ({ history }) => { return ( - + {uiCapabilities?.infrastructure?.show && ( )} diff --git a/x-pack/test/functional/apps/infra/link_to.ts b/x-pack/test/functional/apps/infra/link_to.ts index 7e79f42ac94c..a287d53d5df0 100644 --- a/x-pack/test/functional/apps/infra/link_to.ts +++ b/x-pack/test/functional/apps/infra/link_to.ts @@ -25,7 +25,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { it('redirects to the logs app and parses URL search params correctly', async () => { const location = { hash: '', - pathname: '/link-to/logs', + pathname: '/link-to', search: `time=${timestamp}&filter=trace.id:${traceId}`, state: undefined, }; From d87cb9489f966e7f0c9d242bee31ec4cda3ecfd0 Mon Sep 17 00:00:00 2001 From: Dario Gieselaar Date: Wed, 25 Mar 2020 22:07:45 +0100 Subject: [PATCH 05/35] [APM] Explicit telemetry mappings (#61266) Replaces generic object type mappings with explicitly defined properties. These were probably unmapped because the sample data for some agents does not have these fields. --- x-pack/legacy/plugins/apm/mappings.json | 113 ++++++++++++++++++++++-- 1 file changed, 106 insertions(+), 7 deletions(-) diff --git a/x-pack/legacy/plugins/apm/mappings.json b/x-pack/legacy/plugins/apm/mappings.json index ba4c7a89ceaa..5d14ae03f9a3 100644 --- a/x-pack/legacy/plugins/apm/mappings.json +++ b/x-pack/legacy/plugins/apm/mappings.json @@ -136,7 +136,20 @@ "service": { "properties": { "framework": { - "type": "object" + "properties": { + "composite": { + "type": "keyword", + "ignore_above": 256 + }, + "name": { + "type": "keyword", + "ignore_above": 256 + }, + "version": { + "type": "keyword", + "ignore_above": 256 + } + } }, "language": { "properties": { @@ -187,18 +200,52 @@ "service": { "properties": { "framework": { - "type": "object" + "properties": { + "composite": { + "type": "keyword", + "ignore_above": 256 + }, + "name": { + "type": "keyword", + "ignore_above": 256 + }, + "version": { + "type": "keyword", + "ignore_above": 256 + } + } }, "language": { "properties": { + "composite": { + "type": "keyword", + "ignore_above": 256 + }, "name": { "type": "keyword", "ignore_above": 256 + }, + "version": { + "type": "keyword", + "ignore_above": 256 } } }, "runtime": { - "type": "object" + "properties": { + "composite": { + "type": "keyword", + "ignore_above": 256 + }, + "name": { + "type": "keyword", + "ignore_above": 256 + }, + "version": { + "type": "keyword", + "ignore_above": 256 + } + } } } } @@ -234,9 +281,17 @@ }, "language": { "properties": { + "composite": { + "type": "keyword", + "ignore_above": 256 + }, "name": { "type": "keyword", "ignore_above": 256 + }, + "version": { + "type": "keyword", + "ignore_above": 256 } } }, @@ -391,18 +446,62 @@ "rum-js": { "properties": { "agent": { - "type": "object" + "properties": { + "version": { + "type": "keyword", + "ignore_above": 256 + } + } }, "service": { "properties": { "framework": { - "type": "object" + "properties": { + "composite": { + "type": "keyword", + "ignore_above": 256 + }, + "name": { + "type": "keyword", + "ignore_above": 256 + }, + "version": { + "type": "keyword", + "ignore_above": 256 + } + } }, "language": { - "type": "object" + "properties": { + "composite": { + "type": "keyword", + "ignore_above": 256 + }, + "name": { + "type": "keyword", + "ignore_above": 256 + }, + "version": { + "type": "keyword", + "ignore_above": 256 + } + } }, "runtime": { - "type": "object" + "properties": { + "composite": { + "type": "keyword", + "ignore_above": 256 + }, + "name": { + "type": "keyword", + "ignore_above": 256 + }, + "version": { + "type": "keyword", + "ignore_above": 256 + } + } } } } From 37c92ca4764cc096f7eeaf1f7d57d4c733fdb4e2 Mon Sep 17 00:00:00 2001 From: Josh Dover Date: Wed, 25 Mar 2020 15:09:04 -0600 Subject: [PATCH 06/35] Fix plugin enabled config options (#60998) --- src/plugins/apm_oss/server/index.ts | 1 + src/plugins/timelion/config.ts | 1 + x-pack/plugins/advanced_ui_actions/kibana.json | 1 + x-pack/plugins/alerting_builtins/kibana.json | 1 + x-pack/plugins/data_enhanced/kibana.json | 2 +- x-pack/plugins/drilldowns/kibana.json | 1 + x-pack/plugins/features/kibana.json | 1 + x-pack/plugins/lens/kibana.json | 3 ++- x-pack/plugins/observability/kibana.json | 1 + x-pack/plugins/oss_telemetry/kibana.json | 1 + x-pack/plugins/reporting/kibana.json | 1 + x-pack/plugins/searchprofiler/kibana.json | 1 + x-pack/plugins/triggers_actions_ui/kibana.json | 3 ++- x-pack/plugins/uptime/kibana.json | 2 +- x-pack/plugins/watcher/kibana.json | 1 + 15 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/plugins/apm_oss/server/index.ts b/src/plugins/apm_oss/server/index.ts index 95a4ae4519bc..bd0d23d62500 100644 --- a/src/plugins/apm_oss/server/index.ts +++ b/src/plugins/apm_oss/server/index.ts @@ -22,6 +22,7 @@ import { APMOSSPlugin } from './plugin'; export const config = { schema: schema.object({ + enabled: schema.boolean({ defaultValue: true }), transactionIndices: schema.string({ defaultValue: 'apm-*' }), spanIndices: schema.string({ defaultValue: 'apm-*' }), errorIndices: schema.string({ defaultValue: 'apm-*' }), diff --git a/src/plugins/timelion/config.ts b/src/plugins/timelion/config.ts index eaea1aaca1b7..97a423331b92 100644 --- a/src/plugins/timelion/config.ts +++ b/src/plugins/timelion/config.ts @@ -21,6 +21,7 @@ import { schema, TypeOf } from '@kbn/config-schema'; export const configSchema = schema.object( { + enabled: schema.boolean({ defaultValue: true }), ui: schema.object({ enabled: schema.boolean({ defaultValue: false }) }), graphiteUrls: schema.maybe(schema.arrayOf(schema.string())), }, diff --git a/x-pack/plugins/advanced_ui_actions/kibana.json b/x-pack/plugins/advanced_ui_actions/kibana.json index 515c4749de21..45907e2d8b60 100644 --- a/x-pack/plugins/advanced_ui_actions/kibana.json +++ b/x-pack/plugins/advanced_ui_actions/kibana.json @@ -1,6 +1,7 @@ { "id": "advancedUiActions", "version": "kibana", + "configPath": ["xpack", "advanced_ui_actions"], "requiredPlugins": [ "embeddable", "uiActions" diff --git a/x-pack/plugins/alerting_builtins/kibana.json b/x-pack/plugins/alerting_builtins/kibana.json index cd6bb7519c09..78de9a1ae016 100644 --- a/x-pack/plugins/alerting_builtins/kibana.json +++ b/x-pack/plugins/alerting_builtins/kibana.json @@ -4,5 +4,6 @@ "version": "8.0.0", "kibanaVersion": "kibana", "requiredPlugins": ["alerting"], + "configPath": ["xpack", "alerting_builtins"], "ui": false } diff --git a/x-pack/plugins/data_enhanced/kibana.json b/x-pack/plugins/data_enhanced/kibana.json index b2d5f42d9e46..443bb63a2779 100644 --- a/x-pack/plugins/data_enhanced/kibana.json +++ b/x-pack/plugins/data_enhanced/kibana.json @@ -3,7 +3,7 @@ "version": "8.0.0", "kibanaVersion": "kibana", "configPath": [ - "xpack" + "xpack", "data_enhanced" ], "requiredPlugins": [ "data" diff --git a/x-pack/plugins/drilldowns/kibana.json b/x-pack/plugins/drilldowns/kibana.json index b951c7dc1fc8..4dba07b5a7be 100644 --- a/x-pack/plugins/drilldowns/kibana.json +++ b/x-pack/plugins/drilldowns/kibana.json @@ -3,6 +3,7 @@ "version": "kibana", "server": false, "ui": true, + "configPath": ["xpack", "drilldowns"], "requiredPlugins": [ "uiActions", "embeddable" diff --git a/x-pack/plugins/features/kibana.json b/x-pack/plugins/features/kibana.json index e38d7be89290..325e5a040749 100644 --- a/x-pack/plugins/features/kibana.json +++ b/x-pack/plugins/features/kibana.json @@ -3,6 +3,7 @@ "version": "8.0.0", "kibanaVersion": "kibana", "optionalPlugins": ["timelion"], + "configPath": ["xpack", "features"], "server": true, "ui": true } diff --git a/x-pack/plugins/lens/kibana.json b/x-pack/plugins/lens/kibana.json index 867a7454f044..6abdaad7903b 100644 --- a/x-pack/plugins/lens/kibana.json +++ b/x-pack/plugins/lens/kibana.json @@ -4,5 +4,6 @@ "kibanaVersion": "kibana", "server": true, "ui": false, - "optionalPlugins": ["usageCollection", "taskManager"] + "optionalPlugins": ["usageCollection", "taskManager"], + "configPath": ["xpack", "lens"] } diff --git a/x-pack/plugins/observability/kibana.json b/x-pack/plugins/observability/kibana.json index 57063ea729ed..438b9ddea473 100644 --- a/x-pack/plugins/observability/kibana.json +++ b/x-pack/plugins/observability/kibana.json @@ -2,5 +2,6 @@ "id": "observability", "version": "8.0.0", "kibanaVersion": "kibana", + "configPath": ["xpack", "observability"], "ui": true } diff --git a/x-pack/plugins/oss_telemetry/kibana.json b/x-pack/plugins/oss_telemetry/kibana.json index d83894f7c44a..0defee0881e0 100644 --- a/x-pack/plugins/oss_telemetry/kibana.json +++ b/x-pack/plugins/oss_telemetry/kibana.json @@ -4,5 +4,6 @@ "version": "8.0.0", "kibanaVersion": "kibana", "requiredPlugins": ["usageCollection", "taskManager"], + "configPath": ["xpack", "oss_telemetry"], "ui": false } diff --git a/x-pack/plugins/reporting/kibana.json b/x-pack/plugins/reporting/kibana.json index a7e2bd288f0b..3da2d2a09470 100644 --- a/x-pack/plugins/reporting/kibana.json +++ b/x-pack/plugins/reporting/kibana.json @@ -2,6 +2,7 @@ "id": "reporting", "version": "8.0.0", "kibanaVersion": "kibana", + "configPath": ["xpack", "reporting"], "requiredPlugins": [ "home", "management", diff --git a/x-pack/plugins/searchprofiler/kibana.json b/x-pack/plugins/searchprofiler/kibana.json index 183130821240..f92083ee9d9f 100644 --- a/x-pack/plugins/searchprofiler/kibana.json +++ b/x-pack/plugins/searchprofiler/kibana.json @@ -3,6 +3,7 @@ "version": "8.0.0", "kibanaVersion": "kibana", "requiredPlugins": ["devTools", "home", "licensing"], + "configPath": ["xpack", "searchprofiler"], "server": true, "ui": true } diff --git a/x-pack/plugins/triggers_actions_ui/kibana.json b/x-pack/plugins/triggers_actions_ui/kibana.json index d11f2b3e51c9..11cbacee08af 100644 --- a/x-pack/plugins/triggers_actions_ui/kibana.json +++ b/x-pack/plugins/triggers_actions_ui/kibana.json @@ -4,5 +4,6 @@ "server": false, "ui": true, "optionalPlugins": ["alerting", "alertingBuiltins"], - "requiredPlugins": ["management", "charts", "data"] + "requiredPlugins": ["management", "charts", "data"], + "configPath": ["xpack", "trigger_actions_ui"] } diff --git a/x-pack/plugins/uptime/kibana.json b/x-pack/plugins/uptime/kibana.json index 603cfac316b2..6ec8a755ebea 100644 --- a/x-pack/plugins/uptime/kibana.json +++ b/x-pack/plugins/uptime/kibana.json @@ -1,5 +1,5 @@ { - "configPath": ["xpack"], + "configPath": ["xpack", "uptime"], "id": "uptime", "kibanaVersion": "kibana", "requiredPlugins": ["alerting", "features", "licensing", "usageCollection"], diff --git a/x-pack/plugins/watcher/kibana.json b/x-pack/plugins/watcher/kibana.json index 7c02118c58d7..a0482ad00797 100644 --- a/x-pack/plugins/watcher/kibana.json +++ b/x-pack/plugins/watcher/kibana.json @@ -1,5 +1,6 @@ { "id": "watcher", + "configPath": ["xpack", "watcher"], "version": "kibana", "requiredPlugins": [ "home", From 0d45d9b53f0bd329c642e6c60f18377f9b666842 Mon Sep 17 00:00:00 2001 From: Rudolf Meijering Date: Wed, 25 Mar 2020 22:22:21 +0100 Subject: [PATCH 07/35] Update core migration docs links (#61251) --- ...a-plugin-core-public.httpsetup.basepath.md | 2 +- .../kibana-plugin-core-public.httpsetup.md | 2 +- src/core/MIGRATION.md | 100 +++++++++--------- src/core/public/http/types.ts | 1 + 4 files changed, 53 insertions(+), 52 deletions(-) diff --git a/docs/development/core/public/kibana-plugin-core-public.httpsetup.basepath.md b/docs/development/core/public/kibana-plugin-core-public.httpsetup.basepath.md index 90af143af353..15206a7ae5e1 100644 --- a/docs/development/core/public/kibana-plugin-core-public.httpsetup.basepath.md +++ b/docs/development/core/public/kibana-plugin-core-public.httpsetup.basepath.md @@ -4,7 +4,7 @@ ## HttpSetup.basePath property -APIs for manipulating the basePath on URL segments. +APIs for manipulating the basePath on URL segments. See [IBasePath](./kibana-plugin-core-public.ibasepath.md) Signature: diff --git a/docs/development/core/public/kibana-plugin-core-public.httpsetup.md b/docs/development/core/public/kibana-plugin-core-public.httpsetup.md index b7375b724549..bb43e9f588a7 100644 --- a/docs/development/core/public/kibana-plugin-core-public.httpsetup.md +++ b/docs/development/core/public/kibana-plugin-core-public.httpsetup.md @@ -16,7 +16,7 @@ export interface HttpSetup | Property | Type | Description | | --- | --- | --- | | [anonymousPaths](./kibana-plugin-core-public.httpsetup.anonymouspaths.md) | IAnonymousPaths | APIs for denoting certain paths for not requiring authentication | -| [basePath](./kibana-plugin-core-public.httpsetup.basepath.md) | IBasePath | APIs for manipulating the basePath on URL segments. | +| [basePath](./kibana-plugin-core-public.httpsetup.basepath.md) | IBasePath | APIs for manipulating the basePath on URL segments. See [IBasePath](./kibana-plugin-core-public.ibasepath.md) | | [delete](./kibana-plugin-core-public.httpsetup.delete.md) | HttpHandler | Makes an HTTP request with the DELETE method. See [HttpHandler](./kibana-plugin-core-public.httphandler.md) for options. | | [fetch](./kibana-plugin-core-public.httpsetup.fetch.md) | HttpHandler | Makes an HTTP request. Defaults to a GET request unless overriden. See [HttpHandler](./kibana-plugin-core-public.httphandler.md) for options. | | [get](./kibana-plugin-core-public.httpsetup.get.md) | HttpHandler | Makes an HTTP request with the GET method. See [HttpHandler](./kibana-plugin-core-public.httphandler.md) for options. | diff --git a/src/core/MIGRATION.md b/src/core/MIGRATION.md index 0d5d300ec3b7..50fd1f716ba3 100644 --- a/src/core/MIGRATION.md +++ b/src/core/MIGRATION.md @@ -88,7 +88,7 @@ src/plugins plugin.ts [5] ``` -**[1] `kibana.json`** is a [static manifest](../../docs/development/core/server/kibana-plugin-server.pluginmanifest.md) file that is used to identify the plugin and to determine what kind of code the platform should execute from the plugin: +**[1] `kibana.json`** is a [static manifest](../../docs/development/core/server/kibana-plugin-core-server.pluginmanifest.md) file that is used to identify the plugin and to determine what kind of code the platform should execute from the plugin: ```json { @@ -98,7 +98,7 @@ src/plugins "ui": true } ``` -More details about[manifest file format](/docs/development/core/server/kibana-plugin-server.pluginmanifest.md) +More details about[manifest file format](/docs/development/core/server/kibana-plugin-core-server.pluginmanifest.md) Note that `package.json` files are irrelevant to and ignored by the new platform. @@ -210,9 +210,9 @@ These are the contracts exposed by the core services for each lifecycle event: | lifecycle event | contract | | --------------- | --------------------------------------------------------------------------------------------------------------- | -| *contructor* | [PluginInitializerContext](../../docs/development/core/server/kibana-plugin-server.plugininitializercontext.md) | -| *setup* | [CoreSetup](../../docs/development/core/server/kibana-plugin-server.coresetup.md) | -| *start* | [CoreStart](../../docs/development/core/server/kibana-plugin-server.corestart.md) | +| *contructor* | [PluginInitializerContext](../../docs/development/core/server/kibana-plugin-core-server.plugininitializercontext.md) | +| *setup* | [CoreSetup](../../docs/development/core/server/kibana-plugin-core-server.coresetup.md) | +| *start* | [CoreStart](../../docs/development/core/server/kibana-plugin-core-server.corestart.md) | | *stop* | | ### Integrating with other plugins @@ -1131,24 +1131,24 @@ import { npStart: { core } } from 'ui/new_platform'; | Legacy Platform | New Platform | Notes | | ----------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------- | -| `chrome.addBasePath` | [`core.http.basePath.prepend`](/docs/development/core/public/kibana-plugin-public.httpservicebase.basepath.md) | | -| `chrome.navLinks.update` | [`core.appbase.updater`](/docs/development/core/public/kibana-plugin-public.appbase.updater_.md) | Use the `updater$` property when registering your application via `core.application.register` | -| `chrome.breadcrumbs.set` | [`core.chrome.setBreadcrumbs`](/docs/development/core/public/kibana-plugin-public.chromestart.setbreadcrumbs.md) | | -| `chrome.getUiSettingsClient` | [`core.uiSettings`](/docs/development/core/public/kibana-plugin-public.uisettingsclient.md) | | -| `chrome.helpExtension.set` | [`core.chrome.setHelpExtension`](/docs/development/core/public/kibana-plugin-public.chromestart.sethelpextension.md) | | -| `chrome.setVisible` | [`core.chrome.setIsVisible`](/docs/development/core/public/kibana-plugin-public.chromestart.setisvisible.md) | | +| `chrome.addBasePath` | [`core.http.basePath.prepend`](/docs/development/core/public/kibana-plugin-core-public.httpsetup.basepath.md) | | +| `chrome.navLinks.update` | [`core.appbase.updater`](/docs/development/core/public/kibana-plugin-core-public.appbase.updater_.md) | Use the `updater$` property when registering your application via `core.application.register` | +| `chrome.breadcrumbs.set` | [`core.chrome.setBreadcrumbs`](/docs/development/core/public/kibana-plugin-core-public.chromestart.setbreadcrumbs.md) | | +| `chrome.getUiSettingsClient` | [`core.uiSettings`](/docs/development/core/public/kibana-plugin-core-public.uisettingsclient.md) | | +| `chrome.helpExtension.set` | [`core.chrome.setHelpExtension`](/docs/development/core/public/kibana-plugin-core-public.chromestart.sethelpextension.md) | | +| `chrome.setVisible` | [`core.chrome.setIsVisible`](/docs/development/core/public/kibana-plugin-core-public.chromestart.setisvisible.md) | | | `chrome.setRootTemplate` / `chrome.setRootController` | -- | Use application mounting via `core.application.register` (not available to legacy plugins at this time). | -| `import { recentlyAccessed } from 'ui/persisted_log'` | [`core.chrome.recentlyAccessed`](/docs/development/core/public/kibana-plugin-public.chromerecentlyaccessed.md) | | -| `ui/capabilities` | [`core.application.capabilities`](/docs/development/core/public/kibana-plugin-public.capabilities.md) | | -| `ui/documentation_links` | [`core.docLinks`](/docs/development/core/public/kibana-plugin-public.doclinksstart.md) | | -| `ui/kfetch` | [`core.http`](/docs/development/core/public/kibana-plugin-public.httpservicebase.md) | API is nearly identical | -| `ui/notify` | [`core.notifications`](/docs/development/core/public/kibana-plugin-public.notificationsstart.md) and [`core.overlays`](/docs/development/core/public/kibana-plugin-public.overlaystart.md) | Toast messages are in `notifications`, banners are in `overlays`. May be combined later. | +| `import { recentlyAccessed } from 'ui/persisted_log'` | [`core.chrome.recentlyAccessed`](/docs/development/core/public/kibana-plugin-core-public.chromerecentlyaccessed.md) | | +| `ui/capabilities` | [`core.application.capabilities`](/docs/development/core/public/kibana-plugin-core-public.capabilities.md) | | +| `ui/documentation_links` | [`core.docLinks`](/docs/development/core/public/kibana-plugin-core-public.doclinksstart.md) | | +| `ui/kfetch` | [`core.http`](/docs/development/core/public/kibana-plugin-core-public.httpservicebase.md) | API is nearly identical | +| `ui/notify` | [`core.notifications`](/docs/development/core/public/kibana-plugin-core-public.notificationsstart.md) and [`core.overlays`](/docs/development/core/public/kibana-plugin-core-public.overlaystart.md) | Toast messages are in `notifications`, banners are in `overlays`. May be combined later. | | `ui/routes` | -- | There is no global routing mechanism. Each app [configures its own routing](/rfcs/text/0004_application_service_mounting.md#complete-example). | -| `ui/saved_objects` | [`core.savedObjects`](/docs/development/core/public/kibana-plugin-public.savedobjectsstart.md) | Client API is the same | -| `ui/doc_title` | [`core.chrome.docTitle`](/docs/development/core/public/kibana-plugin-public.chromedoctitle.md) | | -| `uiExports/injectedVars` / `chrome.getInjected` | [Configure plugin](#configure-plugin) and [`PluginConfigDescriptor.exposeToBrowser`](/docs/development/core/server/kibana-plugin-server.pluginconfigdescriptor.exposetobrowser.md) | Can only be used to expose configuration properties | +| `ui/saved_objects` | [`core.savedObjects`](/docs/development/core/public/kibana-plugin-core-public.savedobjectsstart.md) | Client API is the same | +| `ui/doc_title` | [`core.chrome.docTitle`](/docs/development/core/public/kibana-plugin-core-public.chromedoctitle.md) | | +| `uiExports/injectedVars` / `chrome.getInjected` | [Configure plugin](#configure-plugin) and [`PluginConfigDescriptor.exposeToBrowser`](/docs/development/core/server/kibana-plugin-core-server.pluginconfigdescriptor.exposetobrowser.md) | Can only be used to expose configuration properties | -_See also: [Public's CoreStart API Docs](/docs/development/core/public/kibana-plugin-public.corestart.md)_ +_See also: [Public's CoreStart API Docs](/docs/development/core/public/kibana-plugin-core-public.corestart.md)_ ##### Plugins for shared application services @@ -1192,26 +1192,26 @@ In server code, `core` can be accessed from either `server.newPlatform` or `kbnS | Legacy Platform | New Platform | Notes | | ----------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------- | -| `server.config()` | [`initializerContext.config.create()`](/docs/development/core/server/kibana-plugin-server.plugininitializercontext.config.md) | Must also define schema. See _[how to configure plugin](#configure-plugin)_ | -| `server.route` | [`core.http.createRouter`](/docs/development/core/server/kibana-plugin-server.httpservicesetup.createrouter.md) | [Examples](./MIGRATION_EXAMPLES.md#route-registration) | -| `server.renderApp()` / `server.renderAppWithDefaultConfig()` | [`context.rendering.render()`](/docs/development/core/server/kibana-plugin-server.iscopedrenderingclient.render.md) | [Examples](./MIGRATION_EXAMPLES.md#render-html-content) | -| `request.getBasePath()` | [`core.http.basePath.get`](/docs/development/core/server/kibana-plugin-server.httpservicesetup.basepath.md) | | -| `server.plugins.elasticsearch.getCluster('data')` | [`context.core.elasticsearch.dataClient`](/docs/development/core/server/kibana-plugin-server.iscopedclusterclient.md) | | -| `server.plugins.elasticsearch.getCluster('admin')` | [`context.core.elasticsearch.adminClient`](/docs/development/core/server/kibana-plugin-server.iscopedclusterclient.md) | | -| `server.plugins.elasticsearch.createCluster(...)` | [`core.elasticsearch.legacy.createClient`](/docs/development/core/server/kibana-plugin-server.elasticsearchservicestart.legacy.md) | | -| `server.savedObjects.setScopedSavedObjectsClientFactory` | [`core.savedObjects.setClientFactoryProvider`](/docs/development/core/server/kibana-plugin-server.savedobjectsservicesetup.setclientfactoryprovider.md) | | -| `server.savedObjects.addScopedSavedObjectsClientWrapperFactory` | [`core.savedObjects.addClientWrapper`](/docs/development/core/server/kibana-plugin-server.savedobjectsservicesetup.addclientwrapper.md) | | -| `server.savedObjects.getSavedObjectsRepository` | [`core.savedObjects.createInternalRepository`](/docs/development/core/server/kibana-plugin-server.savedobjectsservicestart.createinternalrepository.md) [`core.savedObjects.createScopedRepository`](/docs/development/core/server/kibana-plugin-server.savedobjectsservicestart.createscopedrepository.md) | | -| `server.savedObjects.getScopedSavedObjectsClient` | [`core.savedObjects.getScopedClient`](/docs/development/core/server/kibana-plugin-server.savedobjectsservicestart.getscopedclient.md) | | -| `request.getSavedObjectsClient` | [`context.core.savedObjects.client`](/docs/development/core/server/kibana-plugin-server.requesthandlercontext.core.md) | | -| `request.getUiSettingsService` | [`context.core.uiSettings.client`](/docs/development/core/server/kibana-plugin-server.iuisettingsclient.md) | | -| `kibana.Plugin.deprecations` | [Handle plugin configuration deprecations](#handle-plugin-config-deprecations) and [`PluginConfigDescriptor.deprecations`](docs/development/core/server/kibana-plugin-server.pluginconfigdescriptor.md) | Deprecations from New Platform are not applied to legacy configuration | -| `kibana.Plugin.savedObjectSchemas` | [`core.savedObjects.registerType`](docs/development/core/server/kibana-plugin-server.savedobjectsservicesetup.registertype.md) | [Examples](./MIGRATION_EXAMPLES.md#saved-objects-types) | -| `kibana.Plugin.mappings` | [`core.savedObjects.registerType`](docs/development/core/server/kibana-plugin-server.savedobjectsservicesetup.registertype.md) | [Examples](./MIGRATION_EXAMPLES.md#saved-objects-types) | -| `kibana.Plugin.migrations` | [`core.savedObjects.registerType`](docs/development/core/server/kibana-plugin-server.savedobjectsservicesetup.registertype.md) | [Examples](./MIGRATION_EXAMPLES.md#saved-objects-types) | -| `kibana.Plugin.savedObjectsManagement` | [`core.savedObjects.registerType`](docs/development/core/server/kibana-plugin-server.savedobjectsservicesetup.registertype.md) | [Examples](./MIGRATION_EXAMPLES.md#saved-objects-types) | - -_See also: [Server's CoreSetup API Docs](/docs/development/core/server/kibana-plugin-server.coresetup.md)_ +| `server.config()` | [`initializerContext.config.create()`](/docs/development/core/server/kibana-plugin-core-server.plugininitializercontext.config.md) | Must also define schema. See _[how to configure plugin](#configure-plugin)_ | +| `server.route` | [`core.http.createRouter`](/docs/development/core/server/kibana-plugin-core-server.httpservicesetup.createrouter.md) | [Examples](./MIGRATION_EXAMPLES.md#route-registration) | +| `server.renderApp()` / `server.renderAppWithDefaultConfig()` | [`context.rendering.render()`](/docs/development/core/server/kibana-plugin-core-server.iscopedrenderingclient.render.md) | [Examples](./MIGRATION_EXAMPLES.md#render-html-content) | +| `request.getBasePath()` | [`core.http.basePath.get`](/docs/development/core/server/kibana-plugin-core-server.httpservicesetup.basepath.md) | | +| `server.plugins.elasticsearch.getCluster('data')` | [`context.core.elasticsearch.dataClient`](/docs/development/core/server/kibana-plugin-core-server.iscopedclusterclient.md) | | +| `server.plugins.elasticsearch.getCluster('admin')` | [`context.core.elasticsearch.adminClient`](/docs/development/core/server/kibana-plugin-core-server.iscopedclusterclient.md) | | +| `server.plugins.elasticsearch.createCluster(...)` | [`core.elasticsearch.legacy.createClient`](/docs/development/core/server/kibana-plugin-core-server.elasticsearchservicestart.legacy.md) | | +| `server.savedObjects.setScopedSavedObjectsClientFactory` | [`core.savedObjects.setClientFactoryProvider`](/docs/development/core/server/kibana-plugin-core-server.savedobjectsservicesetup.setclientfactoryprovider.md) | | +| `server.savedObjects.addScopedSavedObjectsClientWrapperFactory` | [`core.savedObjects.addClientWrapper`](/docs/development/core/server/kibana-plugin-core-server.savedobjectsservicesetup.addclientwrapper.md) | | +| `server.savedObjects.getSavedObjectsRepository` | [`core.savedObjects.createInternalRepository`](/docs/development/core/server/kibana-plugin-core-server.savedobjectsservicestart.createinternalrepository.md) [`core.savedObjects.createScopedRepository`](/docs/development/core/server/kibana-plugin-core-server.savedobjectsservicestart.createscopedrepository.md) | | +| `server.savedObjects.getScopedSavedObjectsClient` | [`core.savedObjects.getScopedClient`](/docs/development/core/server/kibana-plugin-core-server.savedobjectsservicestart.getscopedclient.md) | | +| `request.getSavedObjectsClient` | [`context.core.savedObjects.client`](/docs/development/core/server/kibana-plugin-core-server.requesthandlercontext.core.md) | | +| `request.getUiSettingsService` | [`context.core.uiSettings.client`](/docs/development/core/server/kibana-plugin-core-server.iuisettingsclient.md) | | +| `kibana.Plugin.deprecations` | [Handle plugin configuration deprecations](#handle-plugin-config-deprecations) and [`PluginConfigDescriptor.deprecations`](docs/development/core/server/kibana-plugin-core-server.pluginconfigdescriptor.md) | Deprecations from New Platform are not applied to legacy configuration | +| `kibana.Plugin.savedObjectSchemas` | [`core.savedObjects.registerType`](docs/development/core/server/kibana-plugin-core-server.savedobjectsservicesetup.registertype.md) | [Examples](./MIGRATION_EXAMPLES.md#saved-objects-types) | +| `kibana.Plugin.mappings` | [`core.savedObjects.registerType`](docs/development/core/server/kibana-plugin-core-server.savedobjectsservicesetup.registertype.md) | [Examples](./MIGRATION_EXAMPLES.md#saved-objects-types) | +| `kibana.Plugin.migrations` | [`core.savedObjects.registerType`](docs/development/core/server/kibana-plugin-core-server.savedobjectsservicesetup.registertype.md) | [Examples](./MIGRATION_EXAMPLES.md#saved-objects-types) | +| `kibana.Plugin.savedObjectsManagement` | [`core.savedObjects.registerType`](docs/development/core/server/kibana-plugin-core-server.savedobjectsservicesetup.registertype.md) | [Examples](./MIGRATION_EXAMPLES.md#saved-objects-types) | + +_See also: [Server's CoreSetup API Docs](/docs/development/core/server/kibana-plugin-core-server.coresetup.md)_ ##### Plugin services | Legacy Platform | New Platform | Notes | @@ -1228,9 +1228,9 @@ This table shows where these uiExports have moved to in the New Platform. In mos | Legacy Platform | New Platform | Notes | | ---------------------------- | ------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------- | | `aliases` | | | -| `app` | [`core.application.register`](/docs/development/core/public/kibana-plugin-public.applicationsetup.register.md) | | +| `app` | [`core.application.register`](/docs/development/core/public/kibana-plugin-core-public.applicationsetup.register.md) | | | `canvas` | | Should be an API on the canvas plugin. | -| `chromeNavControls` | [`core.chrome.navControls.register{Left,Right}`](/docs/development/core/public/kibana-plugin-public.chromenavcontrols.md) | | +| `chromeNavControls` | [`core.chrome.navControls.register{Left,Right}`](/docs/development/core/public/kibana-plugin-core-public.chromenavcontrols.md) | | | `contextMenuActions` | | Should be an API on the devTools plugin. | | `devTools` | | | | `docViews` | [`plugins.discover.docViews.addDocView`](./src/plugins/discover/public/doc_views) | Should be an API on the discover plugin. | @@ -1256,8 +1256,8 @@ This table shows where these uiExports have moved to in the New Platform. In mos | `shareContextMenuExtensions` | | | | `styleSheetPaths` | | | | `taskDefinitions` | | Should be an API on the taskManager plugin. | -| `uiCapabilities` | [`core.application.register`](/docs/development/core/public/kibana-plugin-public.applicationsetup.register.md) | | -| `uiSettingDefaults` | [`core.uiSettings.register`](/docs/development/core/server/kibana-plugin-server.uisettingsservicesetup.md) | | +| `uiCapabilities` | [`core.application.register`](/docs/development/core/public/kibana-plugin-core-public.applicationsetup.register.md) | | +| `uiSettingDefaults` | [`core.uiSettings.register`](/docs/development/core/server/kibana-plugin-core-server.uisettingsservicesetup.md) | | | `validations` | | Part of SavedObjects, see [#33587](https://github.com/elastic/kibana/issues/33587) | | `visEditorTypes` | | | | `visTypeEnhancers` | | | @@ -1444,7 +1444,7 @@ In the legacy platform, Kibana requires to bind elasticsearch related API with a ``` The new platform introduced [a handler interface](/rfcs/text/0003_handler_interface.md) on the server-side to perform that association internally. Core services, that require impersonation with an incoming request, are -exposed via `context` argument of [the request handler interface.](/docs/development/core/server/kibana-plugin-server.requesthandler.md) +exposed via `context` argument of [the request handler interface.](/docs/development/core/server/kibana-plugin-core-server.requesthandler.md) The above example looks in the new platform as ```js async function handler(context, req, res) { @@ -1452,13 +1452,13 @@ The above example looks in the new platform as } ``` -The [request handler context](/docs/development/core/server/kibana-plugin-server.requesthandlercontext.md) exposed the next scoped **core** services: +The [request handler context](/docs/development/core/server/kibana-plugin-core-server.requesthandlercontext.md) exposed the next scoped **core** services: | Legacy Platform | New Platform | | --------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------| -| `request.getSavedObjectsClient` | [`context.savedObjects.client`](/docs/development/core/server/kibana-plugin-server.savedobjectsclient.md) | -| `server.plugins.elasticsearch.getCluster('admin')` | [`context.elasticsearch.adminClient`](/docs/development/core/server/kibana-plugin-server.iscopedclusterclient.md) | -| `server.plugins.elasticsearch.getCluster('data')` | [`context.elasticsearch.dataClient`](/docs/development/core/server/kibana-plugin-server.iscopedclusterclient.md) | -| `request.getUiSettingsService` | [`context.uiSettings.client`](/docs/development/core/server/kibana-plugin-server.iuisettingsclient.md) | +| `request.getSavedObjectsClient` | [`context.savedObjects.client`](/docs/development/core/server/kibana-plugin-core-server.savedobjectsclient.md) | +| `server.plugins.elasticsearch.getCluster('admin')` | [`context.elasticsearch.adminClient`](/docs/development/core/server/kibana-plugin-core-server.iscopedclusterclient.md) | +| `server.plugins.elasticsearch.getCluster('data')` | [`context.elasticsearch.dataClient`](/docs/development/core/server/kibana-plugin-core-server.iscopedclusterclient.md) | +| `request.getUiSettingsService` | [`context.uiSettings.client`](/docs/development/core/server/kibana-plugin-core-server.iuisettingsclient.md) | #### Declare a custom scoped service Plugins can extend the handler context with custom API that will be available to the plugin itself and all dependent plugins. diff --git a/src/core/public/http/types.ts b/src/core/public/http/types.ts index c40ad74893ea..b12cd1fe09a9 100644 --- a/src/core/public/http/types.ts +++ b/src/core/public/http/types.ts @@ -24,6 +24,7 @@ import { MaybePromise } from '@kbn/utility-types'; export interface HttpSetup { /** * APIs for manipulating the basePath on URL segments. + * See {@link IBasePath} */ basePath: IBasePath; From 4b012fb21af603efcf07c285f1c713e8eae6b828 Mon Sep 17 00:00:00 2001 From: Josh Dover Date: Wed, 25 Mar 2020 15:27:26 -0600 Subject: [PATCH 08/35] Fix running Kibana Platform migrations in development (#61325) --- .../core/server/kibana-plugin-core-server.md | 2 - ...re-server.pluginsservicesetup.contracts.md | 11 ---- ...-plugin-core-server.pluginsservicesetup.md | 20 ------- ...re-server.pluginsservicesetup.uiplugins.md | 15 ----- ...re-server.pluginsservicestart.contracts.md | 11 ---- ...-plugin-core-server.pluginsservicestart.md | 19 ------- src/core/server/legacy/legacy_service.test.ts | 1 + .../server/plugins/plugins_service.mock.ts | 1 + .../server/plugins/plugins_service.test.ts | 57 ++++++++++++------- src/core/server/plugins/plugins_service.ts | 16 ++++-- .../saved_objects_service.test.ts | 8 +-- .../saved_objects/saved_objects_service.ts | 12 ++-- src/core/server/server.api.md | 9 ++- src/core/server/server.ts | 6 +- 14 files changed, 71 insertions(+), 117 deletions(-) delete mode 100644 docs/development/core/server/kibana-plugin-core-server.pluginsservicesetup.contracts.md delete mode 100644 docs/development/core/server/kibana-plugin-core-server.pluginsservicesetup.md delete mode 100644 docs/development/core/server/kibana-plugin-core-server.pluginsservicesetup.uiplugins.md delete mode 100644 docs/development/core/server/kibana-plugin-core-server.pluginsservicestart.contracts.md delete mode 100644 docs/development/core/server/kibana-plugin-core-server.pluginsservicestart.md diff --git a/docs/development/core/server/kibana-plugin-core-server.md b/docs/development/core/server/kibana-plugin-core-server.md index a1158dc85391..793684c1b379 100644 --- a/docs/development/core/server/kibana-plugin-core-server.md +++ b/docs/development/core/server/kibana-plugin-core-server.md @@ -115,8 +115,6 @@ The plugin integrates with the core system via lifecycle events: `setup` | [PluginConfigDescriptor](./kibana-plugin-core-server.pluginconfigdescriptor.md) | Describes a plugin configuration properties. | | [PluginInitializerContext](./kibana-plugin-core-server.plugininitializercontext.md) | Context that's available to plugins during initialization stage. | | [PluginManifest](./kibana-plugin-core-server.pluginmanifest.md) | Describes the set of required and optional properties plugin can define in its mandatory JSON manifest file. | -| [PluginsServiceSetup](./kibana-plugin-core-server.pluginsservicesetup.md) | | -| [PluginsServiceStart](./kibana-plugin-core-server.pluginsservicestart.md) | | | [RequestHandlerContext](./kibana-plugin-core-server.requesthandlercontext.md) | Plugin specific context passed to a route handler.Provides the following clients and services: - [rendering](./kibana-plugin-core-server.iscopedrenderingclient.md) - Rendering client which uses the data of the incoming request - [savedObjects.client](./kibana-plugin-core-server.savedobjectsclient.md) - Saved Objects client which uses the credentials of the incoming request - [savedObjects.typeRegistry](./kibana-plugin-core-server.isavedobjecttyperegistry.md) - Type registry containing all the registered types. - [elasticsearch.dataClient](./kibana-plugin-core-server.scopedclusterclient.md) - Elasticsearch data client which uses the credentials of the incoming request - [elasticsearch.adminClient](./kibana-plugin-core-server.scopedclusterclient.md) - Elasticsearch admin client which uses the credentials of the incoming request - [uiSettings.client](./kibana-plugin-core-server.iuisettingsclient.md) - uiSettings client which uses the credentials of the incoming request | | [RouteConfig](./kibana-plugin-core-server.routeconfig.md) | Route specific configuration. | | [RouteConfigOptions](./kibana-plugin-core-server.routeconfigoptions.md) | Additional route options. | diff --git a/docs/development/core/server/kibana-plugin-core-server.pluginsservicesetup.contracts.md b/docs/development/core/server/kibana-plugin-core-server.pluginsservicesetup.contracts.md deleted file mode 100644 index 5e0543dbaa2d..000000000000 --- a/docs/development/core/server/kibana-plugin-core-server.pluginsservicesetup.contracts.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-core-server](./kibana-plugin-core-server.md) > [PluginsServiceSetup](./kibana-plugin-core-server.pluginsservicesetup.md) > [contracts](./kibana-plugin-core-server.pluginsservicesetup.contracts.md) - -## PluginsServiceSetup.contracts property - -Signature: - -```typescript -contracts: Map; -``` diff --git a/docs/development/core/server/kibana-plugin-core-server.pluginsservicesetup.md b/docs/development/core/server/kibana-plugin-core-server.pluginsservicesetup.md deleted file mode 100644 index 5bfa65f36bda..000000000000 --- a/docs/development/core/server/kibana-plugin-core-server.pluginsservicesetup.md +++ /dev/null @@ -1,20 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-core-server](./kibana-plugin-core-server.md) > [PluginsServiceSetup](./kibana-plugin-core-server.pluginsservicesetup.md) - -## PluginsServiceSetup interface - - -Signature: - -```typescript -export interface PluginsServiceSetup -``` - -## Properties - -| Property | Type | Description | -| --- | --- | --- | -| [contracts](./kibana-plugin-core-server.pluginsservicesetup.contracts.md) | Map<PluginName, unknown> | | -| [uiPlugins](./kibana-plugin-core-server.pluginsservicesetup.uiplugins.md) | {
internal: Map<PluginName, InternalPluginInfo>;
public: Map<PluginName, DiscoveredPlugin>;
browserConfigs: Map<PluginName, Observable<unknown>>;
} | | - diff --git a/docs/development/core/server/kibana-plugin-core-server.pluginsservicesetup.uiplugins.md b/docs/development/core/server/kibana-plugin-core-server.pluginsservicesetup.uiplugins.md deleted file mode 100644 index 7168a360c244..000000000000 --- a/docs/development/core/server/kibana-plugin-core-server.pluginsservicesetup.uiplugins.md +++ /dev/null @@ -1,15 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-core-server](./kibana-plugin-core-server.md) > [PluginsServiceSetup](./kibana-plugin-core-server.pluginsservicesetup.md) > [uiPlugins](./kibana-plugin-core-server.pluginsservicesetup.uiplugins.md) - -## PluginsServiceSetup.uiPlugins property - -Signature: - -```typescript -uiPlugins: { - internal: Map; - public: Map; - browserConfigs: Map>; - }; -``` diff --git a/docs/development/core/server/kibana-plugin-core-server.pluginsservicestart.contracts.md b/docs/development/core/server/kibana-plugin-core-server.pluginsservicestart.contracts.md deleted file mode 100644 index 5c680d9d2d50..000000000000 --- a/docs/development/core/server/kibana-plugin-core-server.pluginsservicestart.contracts.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-core-server](./kibana-plugin-core-server.md) > [PluginsServiceStart](./kibana-plugin-core-server.pluginsservicestart.md) > [contracts](./kibana-plugin-core-server.pluginsservicestart.contracts.md) - -## PluginsServiceStart.contracts property - -Signature: - -```typescript -contracts: Map; -``` diff --git a/docs/development/core/server/kibana-plugin-core-server.pluginsservicestart.md b/docs/development/core/server/kibana-plugin-core-server.pluginsservicestart.md deleted file mode 100644 index cb450ded47c5..000000000000 --- a/docs/development/core/server/kibana-plugin-core-server.pluginsservicestart.md +++ /dev/null @@ -1,19 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-core-server](./kibana-plugin-core-server.md) > [PluginsServiceStart](./kibana-plugin-core-server.pluginsservicestart.md) - -## PluginsServiceStart interface - - -Signature: - -```typescript -export interface PluginsServiceStart -``` - -## Properties - -| Property | Type | Description | -| --- | --- | --- | -| [contracts](./kibana-plugin-core-server.pluginsservicestart.contracts.md) | Map<PluginName, unknown> | | - diff --git a/src/core/server/legacy/legacy_service.test.ts b/src/core/server/legacy/legacy_service.test.ts index 94e86c39289b..ef31be559b30 100644 --- a/src/core/server/legacy/legacy_service.test.ts +++ b/src/core/server/legacy/legacy_service.test.ts @@ -87,6 +87,7 @@ beforeEach(() => { }, savedObjects: savedObjectsServiceMock.createInternalSetupContract(), plugins: { + initialized: true, contracts: new Map([['plugin-id', 'plugin-value']]), uiPlugins: { public: new Map([['plugin-id', {} as DiscoveredPlugin]]), diff --git a/src/core/server/plugins/plugins_service.mock.ts b/src/core/server/plugins/plugins_service.mock.ts index 5a52ebccbd47..29e5b83b2e4c 100644 --- a/src/core/server/plugins/plugins_service.mock.ts +++ b/src/core/server/plugins/plugins_service.mock.ts @@ -28,6 +28,7 @@ const createSetupContractMock = (): PluginsServiceSetup => ({ internal: new Map(), public: new Map(), }, + initialized: true, }); const createStartContractMock = () => ({ contracts: new Map() }); const createServiceMock = (): PluginsServiceMock => ({ diff --git a/src/core/server/plugins/plugins_service.test.ts b/src/core/server/plugins/plugins_service.test.ts index df618b2c0a70..4f69a2b4156b 100644 --- a/src/core/server/plugins/plugins_service.test.ts +++ b/src/core/server/plugins/plugins_service.test.ts @@ -516,28 +516,29 @@ describe('PluginsService', () => { }); describe('#setup()', () => { - describe('uiPlugins.internal', () => { - it('includes disabled plugins', async () => { - mockDiscover.mockReturnValue({ - error$: from([]), - plugin$: from([ - createPlugin('plugin-1', { - path: 'path-1', - version: 'some-version', - configPath: 'plugin1', - }), - createPlugin('plugin-2', { - path: 'path-2', - version: 'some-version', - configPath: 'plugin2', - }), - ]), - }); + beforeEach(() => { + mockDiscover.mockReturnValue({ + error$: from([]), + plugin$: from([ + createPlugin('plugin-1', { + path: 'path-1', + version: 'some-version', + configPath: 'plugin1', + }), + createPlugin('plugin-2', { + path: 'path-2', + version: 'some-version', + configPath: 'plugin2', + }), + ]), + }); - mockPluginSystem.uiPlugins.mockReturnValue(new Map()); + mockPluginSystem.uiPlugins.mockReturnValue(new Map()); + }); + describe('uiPlugins.internal', () => { + it('includes disabled plugins', async () => { config$.next({ plugins: { initialize: true }, plugin1: { enabled: false } }); - await pluginsService.discover(); const { uiPlugins } = await pluginsService.setup({} as any); expect(uiPlugins.internal).toMatchInlineSnapshot(` @@ -552,6 +553,24 @@ describe('PluginsService', () => { `); }); }); + + describe('plugin initialization', () => { + it('does initialize if plugins.initialize is true', async () => { + config$.next({ plugins: { initialize: true } }); + await pluginsService.discover(); + const { initialized } = await pluginsService.setup({} as any); + expect(mockPluginSystem.setupPlugins).toHaveBeenCalled(); + expect(initialized).toBe(true); + }); + + it('does not initialize if plugins.initialize is false', async () => { + config$.next({ plugins: { initialize: false } }); + await pluginsService.discover(); + const { initialized } = await pluginsService.setup({} as any); + expect(mockPluginSystem.setupPlugins).not.toHaveBeenCalled(); + expect(initialized).toBe(false); + }); + }); }); describe('#stop()', () => { diff --git a/src/core/server/plugins/plugins_service.ts b/src/core/server/plugins/plugins_service.ts index 427cc19a8614..9987d1633c50 100644 --- a/src/core/server/plugins/plugins_service.ts +++ b/src/core/server/plugins/plugins_service.ts @@ -33,8 +33,11 @@ import { InternalCoreSetup, InternalCoreStart } from '../internal_types'; import { IConfigService } from '../config'; import { pick } from '../../utils'; -/** @public */ +/** @internal */ export interface PluginsServiceSetup { + /** Indicates whether or not plugins were initialized. */ + initialized: boolean; + /** Setup contracts returned by plugins. */ contracts: Map; uiPlugins: { /** @@ -55,8 +58,9 @@ export interface PluginsServiceSetup { }; } -/** @public */ +/** @internal */ export interface PluginsServiceStart { + /** Start contracts returned by plugins. */ contracts: Map; } @@ -103,14 +107,16 @@ export class PluginsService implements CoreService(); - if (!config.initialize || this.coreContext.env.isDevClusterMaster) { - this.log.info('Plugin initialization disabled.'); - } else { + const initialize = config.initialize && !this.coreContext.env.isDevClusterMaster; + if (initialize) { contracts = await this.pluginsSystem.setupPlugins(deps); + } else { + this.log.info('Plugin initialization disabled.'); } const uiPlugins = this.pluginsSystem.uiPlugins(); return { + initialized: initialize, contracts, uiPlugins: { internal: this.uiPluginInternalInfo, diff --git a/src/core/server/saved_objects/saved_objects_service.test.ts b/src/core/server/saved_objects/saved_objects_service.test.ts index 58b9abfbcdb3..018117776dcc 100644 --- a/src/core/server/saved_objects/saved_objects_service.test.ts +++ b/src/core/server/saved_objects/saved_objects_service.test.ts @@ -171,14 +171,12 @@ describe('SavedObjectsService', () => { return expect(KibanaMigratorMock.mock.calls[0][0].callCluster()).resolves.toMatch('success'); }); - it('skips KibanaMigrator migrations when --optimize=true', async () => { - const coreContext = createCoreContext({ - env: ({ cliArgs: { optimize: true }, packageInfo: { version: 'x.x.x' } } as unknown) as Env, - }); + it('skips KibanaMigrator migrations when pluginsInitialized=false', async () => { + const coreContext = createCoreContext({ skipMigration: false }); const soService = new SavedObjectsService(coreContext); await soService.setup(createSetupDeps()); - await soService.start({}); + await soService.start({ pluginsInitialized: false }); expect(migratorInstanceMock.runMigrations).not.toHaveBeenCalled(); }); diff --git a/src/core/server/saved_objects/saved_objects_service.ts b/src/core/server/saved_objects/saved_objects_service.ts index 175eac3c1bd9..aa440c645456 100644 --- a/src/core/server/saved_objects/saved_objects_service.ts +++ b/src/core/server/saved_objects/saved_objects_service.ts @@ -269,7 +269,9 @@ interface WrappedClientFactoryWrapper { /** @internal */ // eslint-disable-next-line @typescript-eslint/no-empty-interface -export interface SavedObjectsStartDeps {} +export interface SavedObjectsStartDeps { + pluginsInitialized?: boolean; +} export class SavedObjectsService implements CoreService { @@ -349,7 +351,7 @@ export class SavedObjectsService } public async start( - core: SavedObjectsStartDeps, + { pluginsInitialized = true }: SavedObjectsStartDeps, migrationsRetryDelay?: number ): Promise { if (!this.setupDeps || !this.config) { @@ -376,9 +378,11 @@ export class SavedObjectsService * However, our build system optimize step and some tests depend on the * HTTP server running without an Elasticsearch server being available. * So, when the `migrations.skip` is true, we skip migrations altogether. + * + * We also cannot safely run migrations if plugins are not initialized since + * not plugin migrations won't be registered. */ - const cliArgs = this.coreContext.env.cliArgs; - const skipMigrations = cliArgs.optimize || this.config.migration.skip; + const skipMigrations = this.config.migration.skip || !pluginsInitialized; if (skipMigrations) { this.logger.warn( diff --git a/src/core/server/server.api.md b/src/core/server/server.api.md index 6d4181e5e1ab..232d34e48438 100644 --- a/src/core/server/server.api.md +++ b/src/core/server/server.api.md @@ -1426,10 +1426,10 @@ export type PluginName = string; // @public (undocumented) export type PluginOpaqueId = symbol; -// @public (undocumented) +// @internal (undocumented) export interface PluginsServiceSetup { - // (undocumented) contracts: Map; + initialized: boolean; // (undocumented) uiPlugins: { internal: Map; @@ -1438,9 +1438,8 @@ export interface PluginsServiceSetup { }; } -// @public (undocumented) +// @internal (undocumented) export interface PluginsServiceStart { - // (undocumented) contracts: Map; } @@ -2348,7 +2347,7 @@ export const validBodyOutput: readonly ["data", "stream"]; // src/core/server/legacy/types.ts:164:3 - (ae-forgotten-export) The symbol "LegacyNavLinkSpec" needs to be exported by the entry point index.d.ts // src/core/server/legacy/types.ts:165:3 - (ae-forgotten-export) The symbol "LegacyAppSpec" needs to be exported by the entry point index.d.ts // src/core/server/legacy/types.ts:166:16 - (ae-forgotten-export) The symbol "LegacyPluginSpec" needs to be exported by the entry point index.d.ts -// src/core/server/plugins/plugins_service.ts:44:5 - (ae-forgotten-export) The symbol "InternalPluginInfo" needs to be exported by the entry point index.d.ts +// src/core/server/plugins/plugins_service.ts:47:5 - (ae-forgotten-export) The symbol "InternalPluginInfo" needs to be exported by the entry point index.d.ts // src/core/server/plugins/types.ts:226:3 - (ae-forgotten-export) The symbol "KibanaConfigType" needs to be exported by the entry point index.d.ts // src/core/server/plugins/types.ts:226:3 - (ae-forgotten-export) The symbol "SharedGlobalConfigKeys" needs to be exported by the entry point index.d.ts // src/core/server/plugins/types.ts:228:3 - (ae-forgotten-export) The symbol "PathConfigType" needs to be exported by the entry point index.d.ts diff --git a/src/core/server/server.ts b/src/core/server/server.ts index 09a1328f346d..222be572b75e 100644 --- a/src/core/server/server.ts +++ b/src/core/server/server.ts @@ -72,6 +72,7 @@ export class Server { private readonly metrics: MetricsService; private readonly coreApp: CoreApp; + private pluginsInitialized?: boolean; private coreStart?: InternalCoreStart; constructor( @@ -156,6 +157,7 @@ export class Server { }; const pluginsSetup = await this.plugins.setup(coreSetup); + this.pluginsInitialized = pluginsSetup.initialized; const renderingSetup = await this.rendering.setup({ http: httpSetup, @@ -176,7 +178,9 @@ export class Server { public async start() { this.log.debug('starting server'); - const savedObjectsStart = await this.savedObjects.start({}); + const savedObjectsStart = await this.savedObjects.start({ + pluginsInitialized: this.pluginsInitialized, + }); const capabilitiesStart = this.capabilities.start(); const uiSettingsStart = await this.uiSettings.start(); const elasticsearchStart = await this.elasticsearch.start(); From 8eaed26eb8366cdbfb9ba04eb04c8577f4c70bc4 Mon Sep 17 00:00:00 2001 From: CJ Cenizal Date: Wed, 25 Mar 2020 14:42:48 -0700 Subject: [PATCH 09/35] Set initial nav drawer isLocked state in Header constructor (#61338) --- src/core/public/chrome/ui/header/header.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/core/public/chrome/ui/header/header.tsx b/src/core/public/chrome/ui/header/header.tsx index 4dec084fd8a8..66b34c3db7ba 100644 --- a/src/core/public/chrome/ui/header/header.tsx +++ b/src/core/public/chrome/ui/header/header.tsx @@ -92,6 +92,9 @@ export class Header extends Component { constructor(props: HeaderProps) { super(props); + let isLocked = false; + props.isLocked$.subscribe(initialIsLocked => (isLocked = initialIsLocked)); + this.state = { appTitle: 'Kibana', isVisible: true, @@ -101,7 +104,7 @@ export class Header extends Component { navControlsLeft: [], navControlsRight: [], currentAppId: '', - isLocked: false, + isLocked, }; } From 22552564901ff9c9cb16c43b6f767d24cac97b3e Mon Sep 17 00:00:00 2001 From: Vadim Dalecky Date: Wed, 25 Mar 2020 23:14:11 +0100 Subject: [PATCH 10/35] =?UTF-8?q?test:=20=F0=9F=92=8D=20use=20fake=20timer?= =?UTF-8?q?s=20in=20TimedItemBuffer=20tests=20(#61225)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ✅ Closes: #58662 Co-authored-by: Elastic Machine --- .../buffer/tests/timed_item_buffer.test.ts | 31 +++++++++++-------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/src/plugins/bfetch/common/buffer/tests/timed_item_buffer.test.ts b/src/plugins/bfetch/common/buffer/tests/timed_item_buffer.test.ts index e1640927c4ea..7a0d32499589 100644 --- a/src/plugins/bfetch/common/buffer/tests/timed_item_buffer.test.ts +++ b/src/plugins/bfetch/common/buffer/tests/timed_item_buffer.test.ts @@ -20,11 +20,16 @@ import { TimedItemBuffer } from '../timed_item_buffer'; import { runItemBufferTests } from './run_item_buffer_tests'; -// FLAKY: https://github.com/elastic/kibana/issues/58662 -describe.skip('TimedItemBuffer', () => { +jest.useFakeTimers(); + +beforeEach(() => { + jest.clearAllTimers(); +}); + +describe('TimedItemBuffer', () => { runItemBufferTests(TimedItemBuffer); - test('does not do unnecessary flushes', async () => { + test('does not do unnecessary flushes', () => { const onFlush = jest.fn(); const buf = new TimedItemBuffer({ onFlush, @@ -38,7 +43,7 @@ describe.skip('TimedItemBuffer', () => { expect(onFlush).toHaveBeenCalledTimes(1); }); - test('does not do extra flush after timeout if buffer was flushed during timeout wait', async () => { + test('does not do extra flush after timeout if buffer was flushed during timeout wait', () => { const onFlush = jest.fn(); const buf = new TimedItemBuffer({ onFlush, @@ -46,14 +51,14 @@ describe.skip('TimedItemBuffer', () => { }); buf.write(0); - await new Promise(r => setTimeout(r, 3)); + jest.advanceTimersByTime(3); buf.flush(); - await new Promise(r => setTimeout(r, 11)); + jest.advanceTimersByTime(11); expect(onFlush).toHaveBeenCalledTimes(1); }); - test('flushes buffer automatically after timeout reached', async () => { + test('flushes buffer automatically after timeout reached', () => { const onFlush = jest.fn(); const buf = new TimedItemBuffer({ onFlush, @@ -64,12 +69,12 @@ describe.skip('TimedItemBuffer', () => { buf.write(2); expect(onFlush).toHaveBeenCalledTimes(0); - await new Promise(r => setTimeout(r, 3)); + jest.advanceTimersByTime(3); expect(onFlush).toHaveBeenCalledTimes(1); expect(onFlush).toHaveBeenCalledWith([1, 2]); }); - test('does not call flush after timeout if flush was triggered because buffer size reached', async () => { + test('does not call flush after timeout if flush was triggered because buffer size reached', () => { const onFlush = jest.fn(); const buf = new TimedItemBuffer({ onFlush, @@ -81,11 +86,11 @@ describe.skip('TimedItemBuffer', () => { buf.write(2); expect(onFlush).toHaveBeenCalledTimes(1); - await new Promise(r => setTimeout(r, 3)); + jest.advanceTimersByTime(3); expect(onFlush).toHaveBeenCalledTimes(1); }); - test('does not automatically flush if `.clear()` was called', async () => { + test('does not automatically flush if `.clear()` was called', () => { const onFlush = jest.fn(); const buf = new TimedItemBuffer({ onFlush, @@ -95,11 +100,11 @@ describe.skip('TimedItemBuffer', () => { buf.write(1); buf.write(2); - await new Promise(r => setImmediate(r)); + jest.advanceTimersByTime(1); buf.clear(); expect(onFlush).toHaveBeenCalledTimes(0); - await new Promise(r => setTimeout(r, 6)); + jest.advanceTimersByTime(6); expect(onFlush).toHaveBeenCalledTimes(0); }); }); From a825fc9e932bbb155d350a6ecace20bafd094db3 Mon Sep 17 00:00:00 2001 From: Rudolf Meijering Date: Wed, 25 Mar 2020 23:17:40 +0100 Subject: [PATCH 11/35] Fix incorrect config validation on SIGHUP (#61246) --- src/legacy/server/kbn_server.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/legacy/server/kbn_server.js b/src/legacy/server/kbn_server.js index 6991527a9503..e06212d87e3e 100644 --- a/src/legacy/server/kbn_server.js +++ b/src/legacy/server/kbn_server.js @@ -199,8 +199,7 @@ export default class KbnServer { } applyLoggingConfiguration(settings) { - const config = new Config(this.config.getSchema(), settings); - + const config = Config.withDefaultSchema(settings); const loggingOptions = loggingConfiguration(config); const subset = { ops: config.get('ops'), From 45132a1763014c7c1ec401f36ed0a652acc69ceb Mon Sep 17 00:00:00 2001 From: Candace Park <56409205+parkiino@users.noreply.github.com> Date: Wed, 25 Mar 2020 18:19:28 -0400 Subject: [PATCH 12/35] Task/windows eventing form (#60690) Policy Details: Windows Eventing UI card Co-authored-by: kevinlog --- .../endpoint/models/policy_details_config.ts | 45 +++++++ .../endpoint/store/policy_details/action.ts | 14 ++- .../store/policy_details/index.test.ts | 92 +++++++++++++++ .../store/policy_details/middleware.ts | 17 ++- .../endpoint/store/policy_details/reducer.ts | 8 ++ .../store/policy_details/selectors.ts | 37 +++++- .../public/applications/endpoint/types.ts | 64 +++++++++- .../endpoint/view/policy/policy_details.tsx | 58 ++++++++- .../view/policy/policy_forms/config_form.tsx | 110 ++++++++++++++++++ .../policy/policy_forms/eventing/checkbox.tsx | 49 ++++++++ .../policy/policy_forms/eventing/windows.tsx | 70 +++++++++++ x-pack/test/functional/apps/endpoint/index.ts | 1 - .../apps/endpoint/policy_details.ts | 25 ---- 13 files changed, 550 insertions(+), 40 deletions(-) create mode 100644 x-pack/plugins/endpoint/public/applications/endpoint/models/policy_details_config.ts create mode 100644 x-pack/plugins/endpoint/public/applications/endpoint/store/policy_details/index.test.ts create mode 100644 x-pack/plugins/endpoint/public/applications/endpoint/view/policy/policy_forms/config_form.tsx create mode 100644 x-pack/plugins/endpoint/public/applications/endpoint/view/policy/policy_forms/eventing/checkbox.tsx create mode 100644 x-pack/plugins/endpoint/public/applications/endpoint/view/policy/policy_forms/eventing/windows.tsx delete mode 100644 x-pack/test/functional/apps/endpoint/policy_details.ts diff --git a/x-pack/plugins/endpoint/public/applications/endpoint/models/policy_details_config.ts b/x-pack/plugins/endpoint/public/applications/endpoint/models/policy_details_config.ts new file mode 100644 index 000000000000..1900516cb539 --- /dev/null +++ b/x-pack/plugins/endpoint/public/applications/endpoint/models/policy_details_config.ts @@ -0,0 +1,45 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { PolicyConfig } from '../types'; + +/** + * A typed Object.entries() function where the keys and values are typed based on the given object + */ +const entries = (o: T): Array<[keyof T, T[keyof T]]> => + Object.entries(o) as Array<[keyof T, T[keyof T]]>; +type DeepPartial = { [K in keyof T]?: DeepPartial }; + +/** + * Returns a deep copy of PolicyDetailsConfig + */ +export function clone(policyDetailsConfig: PolicyConfig): PolicyConfig { + const clonedConfig: DeepPartial = {}; + for (const [key, val] of entries(policyDetailsConfig)) { + if (typeof val === 'object') { + const valClone: Partial = {}; + clonedConfig[key] = valClone; + for (const [key2, val2] of entries(val)) { + if (typeof val2 === 'object') { + valClone[key2] = { + ...val2, + }; + } else { + clonedConfig[key] = { + ...val, + }; + } + } + } else { + clonedConfig[key] = val; + } + } + + /** + * clonedConfig is typed as DeepPartial so we can construct the copy from an empty object + */ + return clonedConfig as PolicyConfig; +} diff --git a/x-pack/plugins/endpoint/public/applications/endpoint/store/policy_details/action.ts b/x-pack/plugins/endpoint/public/applications/endpoint/store/policy_details/action.ts index cf875e01a6fd..e7e523a9287b 100644 --- a/x-pack/plugins/endpoint/public/applications/endpoint/store/policy_details/action.ts +++ b/x-pack/plugins/endpoint/public/applications/endpoint/store/policy_details/action.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { PolicyData } from '../../types'; +import { PolicyData, PolicyConfig } from '../../types'; interface ServerReturnedPolicyDetailsData { type: 'serverReturnedPolicyDetailsData'; @@ -13,4 +13,14 @@ interface ServerReturnedPolicyDetailsData { }; } -export type PolicyDetailsAction = ServerReturnedPolicyDetailsData; +/** + * When users change a policy via forms, this action is dispatched with a payload that modifies the configuration of a cloned policy config. + */ +interface UserChangedPolicyConfig { + type: 'userChangedPolicyConfig'; + payload: { + policyConfig: PolicyConfig; + }; +} + +export type PolicyDetailsAction = ServerReturnedPolicyDetailsData | UserChangedPolicyConfig; diff --git a/x-pack/plugins/endpoint/public/applications/endpoint/store/policy_details/index.test.ts b/x-pack/plugins/endpoint/public/applications/endpoint/store/policy_details/index.test.ts new file mode 100644 index 000000000000..b20df84fdf57 --- /dev/null +++ b/x-pack/plugins/endpoint/public/applications/endpoint/store/policy_details/index.test.ts @@ -0,0 +1,92 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { PolicyDetailsState } from '../../types'; +import { createStore, Dispatch, Store } from 'redux'; +import { policyDetailsReducer, PolicyDetailsAction } from './index'; +import { policyConfig, windowsEventing } from './selectors'; +import { clone } from '../../models/policy_details_config'; + +describe('policy details: ', () => { + let store: Store; + let getState: typeof store['getState']; + let dispatch: Dispatch; + + beforeEach(() => { + store = createStore(policyDetailsReducer); + getState = store.getState; + dispatch = store.dispatch; + + dispatch({ + type: 'serverReturnedPolicyDetailsData', + payload: { + policyItem: { + id: '', + name: '', + description: '', + config_id: '', + enabled: true, + output_id: '', + inputs: [], + namespace: '', + package: { + name: '', + title: '', + version: '', + }, + revision: 1, + }, + policyConfig: { + windows: { + malware: { + mode: 'detect', + }, + eventing: { + process: false, + network: false, + }, + }, + mac: { + malware: { + mode: '', + }, + eventing: { + process: false, + network: false, + }, + }, + linux: { + eventing: { + process: false, + network: false, + }, + }, + }, + }, + }); + }); + + describe('when the user has enabled windows process eventing', () => { + beforeEach(() => { + const config = policyConfig(getState()); + if (!config) { + throw new Error(); + } + + const newPayload1 = clone(config); + newPayload1.windows.eventing.process = true; + + dispatch({ + type: 'userChangedPolicyConfig', + payload: { policyConfig: newPayload1 }, + }); + }); + + it('windows process eventing is enabled', async () => { + expect(windowsEventing(getState())!.process).toEqual(true); + }); + }); +}); diff --git a/x-pack/plugins/endpoint/public/applications/endpoint/store/policy_details/middleware.ts b/x-pack/plugins/endpoint/public/applications/endpoint/store/policy_details/middleware.ts index 39d7eb93569e..1942538aa9df 100644 --- a/x-pack/plugins/endpoint/public/applications/endpoint/store/policy_details/middleware.ts +++ b/x-pack/plugins/endpoint/public/applications/endpoint/store/policy_details/middleware.ts @@ -5,7 +5,7 @@ */ import { MiddlewareFactory, PolicyDetailsState } from '../../types'; -import { selectPolicyIdFromParams, isOnPolicyDetailsPage } from './selectors'; +import { policyIdFromParams, isOnPolicyDetailsPage } from './selectors'; import { sendGetDatasource } from '../../services/ingest'; export const policyDetailsMiddlewareFactory: MiddlewareFactory = coreStart => { @@ -16,7 +16,7 @@ export const policyDetailsMiddlewareFactory: MiddlewareFactory { return { policyItem: undefined, + policyConfig: undefined, isLoading: false, }; }; @@ -34,5 +35,12 @@ export const policyDetailsReducer: Reducer = ( }; } + if (action.type === 'userChangedPolicyConfig') { + return { + ...state, + policyConfig: action.payload.policyConfig, + }; + } + return state; }; diff --git a/x-pack/plugins/endpoint/public/applications/endpoint/store/policy_details/selectors.ts b/x-pack/plugins/endpoint/public/applications/endpoint/store/policy_details/selectors.ts index a08130d0f4b3..6a5d4077b3c3 100644 --- a/x-pack/plugins/endpoint/public/applications/endpoint/store/policy_details/selectors.ts +++ b/x-pack/plugins/endpoint/public/applications/endpoint/store/policy_details/selectors.ts @@ -6,9 +6,12 @@ import { createSelector } from 'reselect'; import { PolicyDetailsState } from '../../types'; +import { Immutable } from '../../../../../common/types'; -export const selectPolicyDetails = (state: PolicyDetailsState) => state.policyItem; +/** Returns the policy details */ +export const policyDetails = (state: PolicyDetailsState) => state.policyItem; +/** Returns a boolean of whether the user is on the policy details page or not */ export const isOnPolicyDetailsPage = (state: PolicyDetailsState) => { if (state.location) { const pathnameParts = state.location.pathname.split('/'); @@ -18,7 +21,8 @@ export const isOnPolicyDetailsPage = (state: PolicyDetailsState) => { } }; -export const selectPolicyIdFromParams: (state: PolicyDetailsState) => string = createSelector( +/** Returns the policyId from the url */ +export const policyIdFromParams: (state: PolicyDetailsState) => string = createSelector( (state: PolicyDetailsState) => state.location, (location: PolicyDetailsState['location']) => { if (location) { @@ -27,3 +31,32 @@ export const selectPolicyIdFromParams: (state: PolicyDetailsState) => string = c return ''; } ); + +/** Returns the policy configuration */ +export const policyConfig = (state: Immutable) => state.policyConfig; + +/** Returns an object of all the windows eventing configuration */ +export const windowsEventing = (state: PolicyDetailsState) => { + const config = policyConfig(state); + return config && config.windows.eventing; +}; + +/** Returns the total number of possible windows eventing configurations */ +export const totalWindowsEventing = (state: PolicyDetailsState): number => { + const config = policyConfig(state); + if (config) { + return Object.keys(config.windows.eventing).length; + } + return 0; +}; + +/** Returns the number of selected windows eventing configurations */ +export const selectedWindowsEventing = (state: PolicyDetailsState): number => { + const config = policyConfig(state); + if (config) { + return Object.values(config.windows.eventing).reduce((count, event) => { + return event === true ? count + 1 : count; + }, 0); + } + return 0; +}; diff --git a/x-pack/plugins/endpoint/public/applications/endpoint/types.ts b/x-pack/plugins/endpoint/public/applications/endpoint/types.ts index dae2c93c9dd0..6c5330bd78ba 100644 --- a/x-pack/plugins/endpoint/public/applications/endpoint/types.ts +++ b/x-pack/plugins/endpoint/public/applications/endpoint/types.ts @@ -75,17 +75,77 @@ export interface PolicyListState { } /** - * Policy list store state + * Policy details store state */ export interface PolicyDetailsState { /** A single policy item */ - policyItem: PolicyData | undefined; + policyItem?: PolicyData; /** data is being retrieved from server */ + policyConfig?: PolicyConfig; isLoading: boolean; /** current location of the application */ location?: Immutable; } +/** + * Policy Details configuration + */ +export interface PolicyConfig { + windows: WindowsPolicyConfig; + mac: MacPolicyConfig; + linux: LinuxPolicyConfig; +} + +/** + * Windows-specific policy configuration + */ +interface WindowsPolicyConfig { + /** malware mode can be detect, prevent or prevent and notify user */ + malware: { + mode: string; + }; + eventing: { + process: boolean; + network: boolean; + }; +} + +/** + * Mac-specific policy configuration + */ +interface MacPolicyConfig { + /** malware mode can be detect, prevent or prevent and notify user */ + malware: { + mode: string; + }; + eventing: { + process: boolean; + network: boolean; + }; +} +/** + * Linux-specific policy configuration + */ +interface LinuxPolicyConfig { + eventing: { + process: boolean; + network: boolean; + }; +} + +/** OS used in Policy */ +export enum OS { + windows = 'windows', + mac = 'mac', + linux = 'linux', +} + +/** Used in Policy */ +export enum EventingFields { + process = 'process', + network = 'network', +} + export interface GlobalState { readonly hostList: HostListState; readonly alertList: AlertListState; diff --git a/x-pack/plugins/endpoint/public/applications/endpoint/view/policy/policy_details.tsx b/x-pack/plugins/endpoint/public/applications/endpoint/view/policy/policy_details.tsx index bdbd323eaab7..7317bd5e03ed 100644 --- a/x-pack/plugins/endpoint/public/applications/endpoint/view/policy/policy_details.tsx +++ b/x-pack/plugins/endpoint/public/applications/endpoint/view/policy/policy_details.tsx @@ -5,13 +5,26 @@ */ import React from 'react'; -import { EuiTitle } from '@elastic/eui'; +import { + EuiTitle, + EuiPage, + EuiPageBody, + EuiPageHeader, + EuiPageHeaderSection, + EuiFlexGroup, + EuiFlexItem, + EuiButton, + EuiButtonEmpty, + EuiText, + EuiSpacer, +} from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n/react'; import { usePolicyDetailsSelector } from './policy_hooks'; -import { selectPolicyDetails } from '../../store/policy_details/selectors'; +import { policyDetails } from '../../store/policy_details/selectors'; +import { WindowsEventing } from './policy_forms/eventing/windows'; export const PolicyDetails = React.memo(() => { - const policyItem = usePolicyDetailsSelector(selectPolicyDetails); + const policyItem = usePolicyDetailsSelector(policyDetails); function policyName() { if (policyItem) { @@ -29,8 +42,41 @@ export const PolicyDetails = React.memo(() => { } return ( - -

{policyName()}

-
+ + + + + +

{policyName()}

+
+
+ + + + + + + + + + + + +
+ +

+ +

+
+ + +
+
); }); diff --git a/x-pack/plugins/endpoint/public/applications/endpoint/view/policy/policy_forms/config_form.tsx b/x-pack/plugins/endpoint/public/applications/endpoint/view/policy/policy_forms/config_form.tsx new file mode 100644 index 000000000000..66d5932b91c2 --- /dev/null +++ b/x-pack/plugins/endpoint/public/applications/endpoint/view/policy/policy_forms/config_form.tsx @@ -0,0 +1,110 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import React from 'react'; +import { + EuiCard, + EuiFlexGroup, + EuiFlexItem, + EuiTitle, + EuiHorizontalRule, + EuiSpacer, + EuiText, +} from '@elastic/eui'; +import { FormattedMessage } from '@kbn/i18n/react'; +import styled from 'styled-components'; + +const PolicyDetailCard = styled.div` + .policyDetailTitleOS { + flex-grow: 2; + } + .policyDetailTitleFlexItem { + margin: 0; + } +`; +export const ConfigForm: React.FC<{ + type: string; + supportedOss: string[]; + children: React.ReactNode; + id: string; + selectedEventing: number; + totalEventing: number; +}> = React.memo(({ type, supportedOss, children, id, selectedEventing, totalEventing }) => { + const typeTitle = () => { + return ( + + + + +
+ +
+
+
+ + {type} + +
+ + + +
+ +
+
+
+ + {supportedOss.join(', ')} + +
+ + + + + +
+ ); + }; + + const events = () => { + return ( + +
+ +
+
+ ); + }; + + return ( + + + + {events()} + + {children} + + } + /> + + ); +}); diff --git a/x-pack/plugins/endpoint/public/applications/endpoint/view/policy/policy_forms/eventing/checkbox.tsx b/x-pack/plugins/endpoint/public/applications/endpoint/view/policy/policy_forms/eventing/checkbox.tsx new file mode 100644 index 000000000000..add137ea57a5 --- /dev/null +++ b/x-pack/plugins/endpoint/public/applications/endpoint/view/policy/policy_forms/eventing/checkbox.tsx @@ -0,0 +1,49 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import React, { useCallback } from 'react'; +import { EuiCheckbox } from '@elastic/eui'; +import { useDispatch } from 'react-redux'; +import { usePolicyDetailsSelector } from '../../policy_hooks'; +import { policyConfig, windowsEventing } from '../../../../store/policy_details/selectors'; +import { PolicyDetailsAction } from '../../../../store/policy_details'; +import { OS, EventingFields } from '../../../../types'; +import { clone } from '../../../../models/policy_details_config'; + +export const EventingCheckbox: React.FC<{ + id: string; + name: string; + os: OS; + protectionField: EventingFields; +}> = React.memo(({ id, name, os, protectionField }) => { + const policyDetailsConfig = usePolicyDetailsSelector(policyConfig); + const eventing = usePolicyDetailsSelector(windowsEventing); + const dispatch = useDispatch<(action: PolicyDetailsAction) => void>(); + + const handleRadioChange = useCallback( + (event: React.ChangeEvent) => { + if (policyDetailsConfig) { + const newPayload = clone(policyDetailsConfig); + newPayload[os].eventing[protectionField] = event.target.checked; + + dispatch({ + type: 'userChangedPolicyConfig', + payload: { policyConfig: newPayload }, + }); + } + }, + [dispatch, os, policyDetailsConfig, protectionField] + ); + + return ( + + ); +}); diff --git a/x-pack/plugins/endpoint/public/applications/endpoint/view/policy/policy_forms/eventing/windows.tsx b/x-pack/plugins/endpoint/public/applications/endpoint/view/policy/policy_forms/eventing/windows.tsx new file mode 100644 index 000000000000..e92e22fc97fe --- /dev/null +++ b/x-pack/plugins/endpoint/public/applications/endpoint/view/policy/policy_forms/eventing/windows.tsx @@ -0,0 +1,70 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import React, { useMemo } from 'react'; +import { i18n } from '@kbn/i18n'; +import { EventingCheckbox } from './checkbox'; +import { OS, EventingFields } from '../../../../types'; +import { usePolicyDetailsSelector } from '../../policy_hooks'; +import { + selectedWindowsEventing, + totalWindowsEventing, +} from '../../../../store/policy_details/selectors'; +import { ConfigForm } from '../config_form'; + +export const WindowsEventing = React.memo(() => { + const checkboxes = useMemo( + () => [ + { + name: i18n.translate('xpack.endpoint.policyDetailsConfig.eventingProcess', { + defaultMessage: 'Process', + }), + os: OS.windows, + protectionField: EventingFields.process, + }, + { + name: i18n.translate('xpack.endpoint.policyDetailsConfig.eventingNetwork', { + defaultMessage: 'Network', + }), + os: OS.windows, + protectionField: EventingFields.network, + }, + ], + [] + ); + + const renderCheckboxes = () => { + return checkboxes.map((item, index) => { + return ( + + ); + }); + }; + + const selected = usePolicyDetailsSelector(selectedWindowsEventing); + const total = usePolicyDetailsSelector(totalWindowsEventing); + + return ( + + ); +}); diff --git a/x-pack/test/functional/apps/endpoint/index.ts b/x-pack/test/functional/apps/endpoint/index.ts index 4d55b3af4956..3e70a1cc6767 100644 --- a/x-pack/test/functional/apps/endpoint/index.ts +++ b/x-pack/test/functional/apps/endpoint/index.ts @@ -14,7 +14,6 @@ export default function({ loadTestFile }: FtrProviderContext) { loadTestFile(require.resolve('./header_nav')); loadTestFile(require.resolve('./host_list')); loadTestFile(require.resolve('./policy_list')); - loadTestFile(require.resolve('./policy_details')); loadTestFile(require.resolve('./alerts')); }); } diff --git a/x-pack/test/functional/apps/endpoint/policy_details.ts b/x-pack/test/functional/apps/endpoint/policy_details.ts deleted file mode 100644 index f251dcd93014..000000000000 --- a/x-pack/test/functional/apps/endpoint/policy_details.ts +++ /dev/null @@ -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; - * you may not use this file except in compliance with the Elastic License. - */ -import expect from '@kbn/expect'; -import { FtrProviderContext } from '../../ftr_provider_context'; - -export default function({ getPageObjects, getService }: FtrProviderContext) { - const pageObjects = getPageObjects(['common', 'endpoint']); - const testSubjects = getService('testSubjects'); - - // Skipped until we can figure out how to load data for Ingest - describe.skip('Endpoint Policy Details', function() { - this.tags(['ciGroup7']); - - it('loads the Policy Details Page', async () => { - await pageObjects.common.navigateToUrlWithBrowserHistory('endpoint', '/policy/123'); - await testSubjects.existOrFail('policyDetailsViewTitle'); - - const policyDetailsNotFoundTitle = await testSubjects.getVisibleText('policyDetailsName'); - expect(policyDetailsNotFoundTitle).to.equal('policy with some protections 123'); - }); - }); -} From 33511b38794a89b6e357d223ef4282ccf0a1a0c7 Mon Sep 17 00:00:00 2001 From: Frank Hassanabad Date: Wed, 25 Mar 2020 16:30:53 -0600 Subject: [PATCH 13/35] [SIEM] Add developer optimization scripts for their environments ## Summary This adds an optimization script very copied and slightly modified from: * https://github.com/elastic/kibana/pull/49868 Usage: Run this to do an dev tsconfig optimization: ```ts node x-pack/legacy/plugins/siem/scripts/optimize_tsconfig ``` Run this to undo the optimization: ```ts node x-pack/legacy/plugins/siem/scripts/unoptimize_tsconfig ``` Testing and what this does: Run this: ```ts node x-pack/legacy/plugins/siem/scripts/optimize_tsconfig ``` Then run your start-test-all or at least your linter, typescript check, and jest tests to make sure they all operate as expected. Restart your IDE and ensure everything works as expected. Run `git status` and ensure it looks like no new files want to be checked in. Open up your: ```ts kibana/x-pack/tsconfig.json ``` And notice it is now changed when optimization has run to use a smaller set of includes. Open up your: ```ts kibana/tsconfig.json ``` And notice it is now changed when optimization is run to use a smaller set of includes. --- .../plugins/siem/scripts/optimize_tsconfig.js | 13 ++++ .../siem/scripts/optimize_tsconfig/README.md | 16 ++++ .../scripts/optimize_tsconfig/optimize.js | 76 +++++++++++++++++++ .../siem/scripts/optimize_tsconfig/paths.js | 23 ++++++ .../scripts/optimize_tsconfig/tsconfig.json | 15 ++++ .../scripts/optimize_tsconfig/unoptimize.js | 25 ++++++ .../siem/scripts/unoptimize_tsconfig.js | 13 ++++ 7 files changed, 181 insertions(+) create mode 100644 x-pack/legacy/plugins/siem/scripts/optimize_tsconfig.js create mode 100644 x-pack/legacy/plugins/siem/scripts/optimize_tsconfig/README.md create mode 100644 x-pack/legacy/plugins/siem/scripts/optimize_tsconfig/optimize.js create mode 100644 x-pack/legacy/plugins/siem/scripts/optimize_tsconfig/paths.js create mode 100644 x-pack/legacy/plugins/siem/scripts/optimize_tsconfig/tsconfig.json create mode 100644 x-pack/legacy/plugins/siem/scripts/optimize_tsconfig/unoptimize.js create mode 100644 x-pack/legacy/plugins/siem/scripts/unoptimize_tsconfig.js diff --git a/x-pack/legacy/plugins/siem/scripts/optimize_tsconfig.js b/x-pack/legacy/plugins/siem/scripts/optimize_tsconfig.js new file mode 100644 index 000000000000..ff4002b076e5 --- /dev/null +++ b/x-pack/legacy/plugins/siem/scripts/optimize_tsconfig.js @@ -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; + * you may not use this file except in compliance with the Elastic License. + */ + +const { optimizeTsConfig } = require('./optimize_tsconfig/optimize'); + +optimizeTsConfig().catch(err => { + console.error(err); + // eslint-disable-next-line no-process-exit + process.exit(1); +}); diff --git a/x-pack/legacy/plugins/siem/scripts/optimize_tsconfig/README.md b/x-pack/legacy/plugins/siem/scripts/optimize_tsconfig/README.md new file mode 100644 index 000000000000..d3615d2870ef --- /dev/null +++ b/x-pack/legacy/plugins/siem/scripts/optimize_tsconfig/README.md @@ -0,0 +1,16 @@ +Hard forked from here: +x-pack/legacy/plugins/apm/scripts/optimize-tsconfig.js + + +#### Optimizing TypeScript + +Kibana and X-Pack are very large TypeScript projects, and it comes at a cost. Editor responsiveness is not great, and the CLI type check for X-Pack takes about a minute. To get faster feedback, we create a smaller SIEM TypeScript project that only type checks the SIEM project and the files it uses. This optimization consists of creating a `tsconfig.json` in SIEM that includes the Kibana/X-Pack typings, and editing the Kibana/X-Pack configurations to not include any files, or removing the configurations altogether. The script configures git to ignore any changes in these files, and has an undo script as well. + +To run the optimization: + +`$ node x-pack/legacy/plugins/siem/scripts/optimize_tsconfig` + +To undo the optimization: + +`$ node x-pack/legacy/plugins/siem/scripts/unoptimize_tsconfig` + diff --git a/x-pack/legacy/plugins/siem/scripts/optimize_tsconfig/optimize.js b/x-pack/legacy/plugins/siem/scripts/optimize_tsconfig/optimize.js new file mode 100644 index 000000000000..9c04e0b69b73 --- /dev/null +++ b/x-pack/legacy/plugins/siem/scripts/optimize_tsconfig/optimize.js @@ -0,0 +1,76 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +/* eslint-disable import/no-extraneous-dependencies */ + +const fs = require('fs'); +const { promisify } = require('util'); +const path = require('path'); +const json5 = require('json5'); +const execa = require('execa'); + +const readFile = promisify(fs.readFile); +const writeFile = promisify(fs.writeFile); + +const { xpackRoot, kibanaRoot, tsconfigTpl, filesToIgnore } = require('./paths'); +const { unoptimizeTsConfig } = require('./unoptimize'); + +function prepareParentTsConfigs() { + return Promise.all( + [path.resolve(xpackRoot, 'tsconfig.json'), path.resolve(kibanaRoot, 'tsconfig.json')].map( + async filename => { + const config = json5.parse(await readFile(filename, 'utf-8')); + + await writeFile( + filename, + JSON.stringify( + { + ...config, + include: [], + }, + null, + 2 + ), + { encoding: 'utf-8' } + ); + } + ) + ); +} + +async function addFilesToXpackTsConfig() { + const template = json5.parse(await readFile(tsconfigTpl, 'utf-8')); + const xpackTsConfig = path.join(xpackRoot, 'tsconfig.json'); + const config = json5.parse(await readFile(xpackTsConfig, 'utf-8')); + + await writeFile(xpackTsConfig, JSON.stringify({ ...config, ...template }, null, 2), { + encoding: 'utf-8', + }); +} + +async function setIgnoreChanges() { + for (const filename of filesToIgnore) { + await execa('git', ['update-index', '--skip-worktree', filename]); + } +} + +async function optimizeTsConfig() { + await unoptimizeTsConfig(); + + await prepareParentTsConfigs(); + + await addFilesToXpackTsConfig(); + + await setIgnoreChanges(); + // eslint-disable-next-line no-console + console.log( + 'Created an optimized tsconfig.json for SIEM. To undo these changes, run `./scripts/unoptimize_tsconfig.js`' + ); +} + +module.exports = { + optimizeTsConfig, +}; diff --git a/x-pack/legacy/plugins/siem/scripts/optimize_tsconfig/paths.js b/x-pack/legacy/plugins/siem/scripts/optimize_tsconfig/paths.js new file mode 100644 index 000000000000..ca26203e17d2 --- /dev/null +++ b/x-pack/legacy/plugins/siem/scripts/optimize_tsconfig/paths.js @@ -0,0 +1,23 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ +const path = require('path'); + +const xpackRoot = path.resolve(__dirname, '../../../../..'); +const kibanaRoot = path.resolve(xpackRoot, '..'); + +const tsconfigTpl = path.resolve(__dirname, './tsconfig.json'); + +const filesToIgnore = [ + path.resolve(xpackRoot, 'tsconfig.json'), + path.resolve(kibanaRoot, 'tsconfig.json'), +]; + +module.exports = { + xpackRoot, + kibanaRoot, + tsconfigTpl, + filesToIgnore, +}; diff --git a/x-pack/legacy/plugins/siem/scripts/optimize_tsconfig/tsconfig.json b/x-pack/legacy/plugins/siem/scripts/optimize_tsconfig/tsconfig.json new file mode 100644 index 000000000000..bec6988bdebd --- /dev/null +++ b/x-pack/legacy/plugins/siem/scripts/optimize_tsconfig/tsconfig.json @@ -0,0 +1,15 @@ +{ + "include": [ + "typings/**/*", + "plugins/siem/**/*", + "legacy/plugins/siem/**/*", + "plugins/apm/typings/numeral.d.ts", + "legacy/plugins/canvas/types/webpack.d.ts" + ], + "exclude": [ + "test/**/*", + "**/__fixtures__/**/*", + "legacy/plugins/siem/cypress/**/*", + "**/typespec_tests.ts" + ] +} diff --git a/x-pack/legacy/plugins/siem/scripts/optimize_tsconfig/unoptimize.js b/x-pack/legacy/plugins/siem/scripts/optimize_tsconfig/unoptimize.js new file mode 100644 index 000000000000..21fc1aa2a1a3 --- /dev/null +++ b/x-pack/legacy/plugins/siem/scripts/optimize_tsconfig/unoptimize.js @@ -0,0 +1,25 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ +/* eslint-disable import/no-extraneous-dependencies */ + +const execa = require('execa'); + +const { filesToIgnore } = require('./paths'); + +async function unoptimizeTsConfig() { + for (const filename of filesToIgnore) { + await execa('git', ['update-index', '--no-skip-worktree', filename]); + await execa('git', ['checkout', filename]); + } +} + +module.exports = { + unoptimizeTsConfig: async () => { + await unoptimizeTsConfig(); + // eslint-disable-next-line no-console + console.log('Removed SIEM TypeScript optimizations'); + }, +}; diff --git a/x-pack/legacy/plugins/siem/scripts/unoptimize_tsconfig.js b/x-pack/legacy/plugins/siem/scripts/unoptimize_tsconfig.js new file mode 100644 index 000000000000..d5392c76d9f8 --- /dev/null +++ b/x-pack/legacy/plugins/siem/scripts/unoptimize_tsconfig.js @@ -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; + * you may not use this file except in compliance with the Elastic License. + */ + +const { unoptimizeTsConfig } = require('./optimize_tsconfig/unoptimize'); + +unoptimizeTsConfig().catch(err => { + console.error(err); + // eslint-disable-next-line no-process-exit + process.exit(1); +}); From 30a512d83175cdfd907657865272131aea27a51e Mon Sep 17 00:00:00 2001 From: Tyler Smalley Date: Wed, 25 Mar 2020 15:35:33 -0700 Subject: [PATCH 14/35] Temporarily disable tests caused by possible ES regression https://github.com/elastic/kibana/issues/61366 Signed-off-by: Tyler Smalley --- test/functional/apps/discover/_errors.js | 3 ++- .../api_integration/apis/monitoring/elasticsearch/nodes.js | 3 ++- x-pack/test/functional/apps/monitoring/elasticsearch/nodes.js | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/test/functional/apps/discover/_errors.js b/test/functional/apps/discover/_errors.js index 7dbb93c884f4..9a7356d8e521 100644 --- a/test/functional/apps/discover/_errors.js +++ b/test/functional/apps/discover/_errors.js @@ -35,7 +35,8 @@ export default function({ getService, getPageObjects }) { await esArchiver.unload('invalid_scripted_field'); }); - describe('invalid scripted field error', () => { + // https://github.com/elastic/kibana/issues/61366 + describe.skip('invalid scripted field error', () => { it('is rendered', async () => { const isFetchErrorVisible = await testSubjects.exists('discoverFetchError'); expect(isFetchErrorVisible).to.be(true); diff --git a/x-pack/test/api_integration/apis/monitoring/elasticsearch/nodes.js b/x-pack/test/api_integration/apis/monitoring/elasticsearch/nodes.js index 4d86fc9d9a7f..f9a6dd31092a 100644 --- a/x-pack/test/api_integration/apis/monitoring/elasticsearch/nodes.js +++ b/x-pack/test/api_integration/apis/monitoring/elasticsearch/nodes.js @@ -34,7 +34,8 @@ export default function({ getService }) { return esArchiver.unload(archive); }); - it('should return data for 2 active nodes', async () => { + // https://github.com/elastic/kibana/issues/61366 + it.skip('should return data for 2 active nodes', async () => { const { body } = await supertest .post('/api/monitoring/v1/clusters/fHJwISmKTFO8bj57oFBLUQ/elasticsearch/nodes') .set('kbn-xsrf', 'xxx') diff --git a/x-pack/test/functional/apps/monitoring/elasticsearch/nodes.js b/x-pack/test/functional/apps/monitoring/elasticsearch/nodes.js index d407ba898f10..dcbd94de8a77 100644 --- a/x-pack/test/functional/apps/monitoring/elasticsearch/nodes.js +++ b/x-pack/test/functional/apps/monitoring/elasticsearch/nodes.js @@ -34,7 +34,8 @@ export default function({ getService, getPageObjects }) { await tearDown(); }); - it('should have an Elasticsearch Cluster Summary Status with correct info', async () => { + // https://github.com/elastic/kibana/issues/61366 + it.skip('should have an Elasticsearch Cluster Summary Status with correct info', async () => { expect(await esClusterSummaryStatus.getContent()).to.eql({ nodesCount: 'Nodes\n2', indicesCount: 'Indices\n20', From 420c213b582b5490c1b033e68138e19a931200cb Mon Sep 17 00:00:00 2001 From: Vadim Dalecky Date: Wed, 25 Mar 2020 23:57:03 +0100 Subject: [PATCH 15/35] =?UTF-8?q?ci:=20=F0=9F=8E=A1=20add=20more=20tags=20?= =?UTF-8?q?to=20ProBot=20PR=20path=20labeler=20(#59913)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * ci: 🎡 add more tags to ProBot PR path labeler * fix: 🐛 add missing colon Co-authored-by: Elastic Machine --- .github/paths-labeller.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/.github/paths-labeller.yml b/.github/paths-labeller.yml index 694d1a2f67e2..4a498af6b1c8 100644 --- a/.github/paths-labeller.yml +++ b/.github/paths-labeller.yml @@ -1,3 +1,19 @@ --- + - "Team:AppArch": + - "src/plugins/bfetch/**/*.*" + - "src/plugins/dashboard_embeddable_container/**/*.*" + - "src/plugins/data/**/*.*" + - "src/plugins/embeddable/**/*.*" + - "src/plugins/expressions/**/*.*" + - "src/plugins/inspector/**/*.*" + - "src/plugins/ui_actions/**/*.*" + - "src/plugins/visualizations/**/*.*" + - "Feature:Embedding": + - "src/plugins/embeddable/**/*.*" + - "src/plugins/dashboard_embeddable_container/**/*.*" - "Feature:Drilldowns": - "x-pack/plugins/drilldowns/**/*.*" + - "x-pack/plugins/dashboard_enhanced/public/services/drilldowns/**/*.*" + - "Feature:ExpressionLanguage": + - "src/plugins/expressions/**/*.*" + - "src/plugins/bfetch/**/*.*" From 5c5c98f0e76726bc974f3ae5bffdfadd0efcfbb1 Mon Sep 17 00:00:00 2001 From: Andrew Cholakian Date: Wed, 25 Mar 2020 17:58:07 -0500 Subject: [PATCH 16/35] [Uptime] Various Settings Fixes (#61007) Fixes behavior in chrome where using the enter key to submit the settings form would reload the page. Fixes #61006 Fixes test failures in uptime settings tests by waiting until form data is loaded: https://kibana-ci.elastic.co/job/elastic+kibana+master/3882/https:/ Sample failure: { Error: expected { heartbeatIndices: '' } to sort of equal { heartbeatIndices: 'heartbeat-8*' } at Assertion.assert (/dev/shm/workspace/kibana/packages/kbn-expect/expect.js:100:11) at Assertion.eql (/dev/shm/workspace/kibana/packages/kbn-expect/expect.js:244:8) at Context.it (test/functional/apps/uptime/settings.ts:31:25) at process._tickCallback (internal/process/next_tick.js:68:7) actual: '{\n "heartbeatIndices": ""\n}', expected: '{\n "heartbeatIndices": "heartbeat-8*"\n}', showDiff: true } Re-enables location tests failure, which should have been fixed by https://github.com/elastic/kibana/pull/60573/files#diff-7198f3de6fe631f903e590f63bc88e21R20 --- .../plugins/uptime/public/pages/settings.tsx | 7 +++++-- x-pack/test/functional/apps/uptime/index.ts | 14 ++++++++++---- x-pack/test/functional/apps/uptime/locations.ts | 2 +- x-pack/test/functional/apps/uptime/settings.ts | 4 ++-- x-pack/test/functional/services/uptime.ts | 10 +++++----- 5 files changed, 23 insertions(+), 14 deletions(-) diff --git a/x-pack/legacy/plugins/uptime/public/pages/settings.tsx b/x-pack/legacy/plugins/uptime/public/pages/settings.tsx index e78c3e0f7de0..d3e17a15ee0e 100644 --- a/x-pack/legacy/plugins/uptime/public/pages/settings.tsx +++ b/x-pack/legacy/plugins/uptime/public/pages/settings.tsx @@ -78,7 +78,8 @@ export const SettingsPageComponent = ({ } }; - const onApply = () => { + const onApply = (event: React.FormEvent) => { + event.preventDefault(); if (formFields) { dispatchSetDynamicSettings(formFields); } @@ -176,7 +177,9 @@ export const SettingsPageComponent = ({ } > { id: settingsObjectId, }); } catch (e) { - // If it's not found that's fine, we just want to ensure - // this is the default state - if (e.response?.status !== 404) { - throw e; + // a 404 just means the doc is already missing + if (e.response.status !== 404) { + const { status, statusText, data, headers, config } = e.response; + throw new Error( + `error attempting to delete settings:\n${JSON.stringify( + { status, statusText, data, headers, config }, + null, + 2 + )}` + ); } } }); diff --git a/x-pack/test/functional/apps/uptime/locations.ts b/x-pack/test/functional/apps/uptime/locations.ts index 96c7fad89a85..7f6932ab5031 100644 --- a/x-pack/test/functional/apps/uptime/locations.ts +++ b/x-pack/test/functional/apps/uptime/locations.ts @@ -10,7 +10,7 @@ import { FtrProviderContext } from '../../ftr_provider_context'; export default ({ getPageObjects, getService }: FtrProviderContext) => { const pageObjects = getPageObjects(['uptime']); - describe.skip('location', () => { + describe('location', () => { const start = new Date().toISOString(); const end = new Date().toISOString(); diff --git a/x-pack/test/functional/apps/uptime/settings.ts b/x-pack/test/functional/apps/uptime/settings.ts index aafb145a1b9b..477eeb84ae5c 100644 --- a/x-pack/test/functional/apps/uptime/settings.ts +++ b/x-pack/test/functional/apps/uptime/settings.ts @@ -17,7 +17,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { const es = getService('es'); // Flaky https://github.com/elastic/kibana/issues/60866 - describe.skip('uptime settings page', () => { + describe('uptime settings page', () => { const settingsPage = () => pageObjects.uptime.settings; beforeEach('navigate to clean app root', async () => { // make 10 checks @@ -48,7 +48,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { }); // Failing: https://github.com/elastic/kibana/issues/60863 - it.skip('changing index pattern setting is reflected elsewhere in UI', async () => { + it('changing index pattern setting is reflected elsewhere in UI', async () => { const originalCount = await pageObjects.uptime.getSnapshotCount(); // We should find 1 monitor up with the default index pattern expect(originalCount.up).to.eql(1); diff --git a/x-pack/test/functional/services/uptime.ts b/x-pack/test/functional/services/uptime.ts index f9902d0142b9..5a24a51f967f 100644 --- a/x-pack/test/functional/services/uptime.ts +++ b/x-pack/test/functional/services/uptime.ts @@ -16,14 +16,14 @@ export function UptimeProvider({ getService }: FtrProviderContext) { await testSubjects.click('settings-page-link', 5000); }, changeHeartbeatIndicesInput: async (text: string) => { - const input = await testSubjects.find('heartbeat-indices-input', 5000); + const input = await testSubjects.find('heartbeat-indices-input-loaded', 5000); await input.clearValueWithKeyboard(); await input.type(text); }, loadFields: async () => { - const heartbeatIndices = await ( - await testSubjects.find('heartbeat-indices-input', 5000) - ).getAttribute('value'); + const input = await testSubjects.find('heartbeat-indices-input-loaded', 5000); + const heartbeatIndices = await input.getAttribute('value'); + return { heartbeatIndices }; }, applyButtonIsDisabled: async () => { @@ -34,7 +34,7 @@ export function UptimeProvider({ getService }: FtrProviderContext) { await retry.waitFor('submit to succeed', async () => { // When the form submit is complete the form will no longer be disabled const disabled = await ( - await testSubjects.find('heartbeat-indices-input', 5000) + await testSubjects.find('heartbeat-indices-input-loaded', 5000) ).getAttribute('disabled'); return disabled === null; }); From 43d95da4644a222fc89fc18112627ff0bc664777 Mon Sep 17 00:00:00 2001 From: Nathan L Smith Date: Wed, 25 Mar 2020 18:24:15 -0500 Subject: [PATCH 17/35] Make global service map zoom toward center (#61340) * Make global service map zoom toward center Calculate the center of the graph when there's not a primary node. Also update to latest version of types. Fixes #61176. * Fix types --- .../apm/public/components/app/ServiceMap/Controls.tsx | 10 +++++++++- .../components/app/ServiceMap/cytoscapeOptions.ts | 8 ++++---- x-pack/package.json | 2 +- yarn.lock | 8 ++++---- 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/x-pack/legacy/plugins/apm/public/components/app/ServiceMap/Controls.tsx b/x-pack/legacy/plugins/apm/public/components/app/ServiceMap/Controls.tsx index a2e7b2c76031..eabd967e6efe 100644 --- a/x-pack/legacy/plugins/apm/public/components/app/ServiceMap/Controls.tsx +++ b/x-pack/legacy/plugins/apm/public/components/app/ServiceMap/Controls.tsx @@ -41,9 +41,17 @@ const steps = 5; function doZoom(cy: cytoscape.Core | undefined, increment: number) { if (cy) { const level = cy.zoom() + increment; + // @ts-ignore `.position()` _does_ work on a NodeCollection. It returns the position of the first element in the collection. + const primaryCenter = cy.nodes('.primary').position(); + const { x1, y1, w, h } = cy.nodes().boundingBox({}); + const graphCenter = { x: x1 + w / 2, y: y1 + h / 2 }; + cy.animate({ duration, - zoom: { level, position: cy.$('.primary').position() } + zoom: { + level, + position: primaryCenter || graphCenter + } }); } } diff --git a/x-pack/legacy/plugins/apm/public/components/app/ServiceMap/cytoscapeOptions.ts b/x-pack/legacy/plugins/apm/public/components/app/ServiceMap/cytoscapeOptions.ts index 413458f336e6..0438842f7af1 100644 --- a/x-pack/legacy/plugins/apm/public/components/app/ServiceMap/cytoscapeOptions.ts +++ b/x-pack/legacy/plugins/apm/public/components/app/ServiceMap/cytoscapeOptions.ts @@ -62,7 +62,7 @@ const style: cytoscape.Stylesheet[] = [ isService(el) ? el.data(SERVICE_NAME) : el.data(SPAN_DESTINATION_SERVICE_RESOURCE), - 'min-zoomed-font-size': theme.euiSizeL, + 'min-zoomed-font-size': parseInt(theme.euiSizeL, 10), 'overlay-opacity': 0, shape: (el: cytoscape.NodeSingular) => isService(el) ? 'ellipse' : 'diamond', @@ -70,7 +70,7 @@ const style: cytoscape.Stylesheet[] = [ 'text-background-opacity': 0, 'text-background-padding': theme.paddingSizes.xs, 'text-background-shape': 'roundrectangle', - 'text-margin-y': theme.paddingSizes.s, + 'text-margin-y': parseInt(theme.paddingSizes.s, 10), 'text-max-width': '200px', 'text-valign': 'bottom', 'text-wrap': 'ellipsis', @@ -105,8 +105,8 @@ const style: cytoscape.Stylesheet[] = [ 'source-arrow-color': lineColor, 'target-arrow-shape': 'triangle', // @ts-ignore - 'source-distance-from-node': theme.paddingSizes.xs, - 'target-distance-from-node': theme.paddingSizes.xs + 'source-distance-from-node': parseInt(theme.paddingSizes.xs, 10), + 'target-distance-from-node': parseInt(theme.paddingSizes.xs, 10) } }, // @ts-ignore DefinitelyTyped says visibility is "none" but it's diff --git a/x-pack/package.json b/x-pack/package.json index dacde606239b..2f94beaf1bf7 100644 --- a/x-pack/package.json +++ b/x-pack/package.json @@ -50,7 +50,7 @@ "@types/cheerio": "^0.22.10", "@types/chroma-js": "^1.4.2", "@types/color": "^3.0.0", - "@types/cytoscape": "^3.8.2", + "@types/cytoscape": "^3.14.0", "@types/d3-array": "^1.2.7", "@types/d3-scale": "^2.1.1", "@types/d3-shape": "^1.3.1", diff --git a/yarn.lock b/yarn.lock index 7608fedd705a..461f12cd2ea1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3726,10 +3726,10 @@ "@types/cp-file" "*" "@types/glob" "*" -"@types/cytoscape@^3.8.2": - version "3.8.2" - resolved "https://registry.yarnpkg.com/@types/cytoscape/-/cytoscape-3.8.2.tgz#428e85e12fb8dba94b05b1b1a8b04fd6f91b9c2d" - integrity sha512-b9n8dwMnU+64++Vky7bfab3Fod6JRbhZRrRJgnyKd03sh/vgNYHsq9N3W1MlU32d3AanxWUDH/1+jC+l5V9BeQ== +"@types/cytoscape@^3.14.0": + version "3.14.0" + resolved "https://registry.yarnpkg.com/@types/cytoscape/-/cytoscape-3.14.0.tgz#346b5430a7a1533784bcf44fcbe6c5255b948d36" + integrity sha512-qOhhZFGb35457vmCu9YHqwjqleraSAEikaIFmMUPWzTC7FrwkS7VR/6ymqRHW7Z8wivHuzsZDYCoePIepd69qg== "@types/d3-array@^1.2.7": version "1.2.7" From 9243b6de2897fa55f7f47b685fd344dbe9d4e497 Mon Sep 17 00:00:00 2001 From: Ryland Herrick Date: Wed, 25 Mar 2020 19:08:29 -0500 Subject: [PATCH 18/35] Check auth status via security plugin on our privileges endpoint (#61334) * Accounts for security being disabled, adds tests * Updates other auth-aware endpoints (import timeline, graphql) to account for security being disabled. --- .../routes/__mocks__/request_responses.ts | 4 +- .../privileges/read_privileges_route.test.ts | 56 +++++++++++++++++-- .../privileges/read_privileges_route.ts | 9 ++- .../lib/framework/kibana_framework_adapter.ts | 2 +- .../timeline/routes/import_timelines_route.ts | 6 +- x-pack/legacy/plugins/siem/server/plugin.ts | 2 +- .../plugins/siem/server/routes/index.ts | 6 +- 7 files changed, 66 insertions(+), 19 deletions(-) diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/__mocks__/request_responses.ts b/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/__mocks__/request_responses.ts index 24f50c5ce87a..3b24b722f735 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/__mocks__/request_responses.ts +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/__mocks__/request_responses.ts @@ -514,7 +514,7 @@ export const updateActionResult = (): ActionResult => ({ config: {}, }); -export const getMockPrivileges = () => ({ +export const getMockPrivilegesResult = () => ({ username: 'test-space', has_all_requested: false, cluster: { @@ -565,8 +565,6 @@ export const getMockPrivileges = () => ({ }, }, application: {}, - is_authenticated: false, - has_encryption_key: true, }); export const getFindResultStatusEmpty = (): SavedObjectsFindResponse => ({ diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/privileges/read_privileges_route.test.ts b/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/privileges/read_privileges_route.test.ts index 44050f21a125..aa4f6150889f 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/privileges/read_privileges_route.test.ts +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/privileges/read_privileges_route.test.ts @@ -4,20 +4,24 @@ * you may not use this file except in compliance with the Elastic License. */ +import { securityMock } from '../../../../../../../../plugins/security/server/mocks'; import { readPrivilegesRoute } from './read_privileges_route'; import { serverMock, requestContextMock } from '../__mocks__'; -import { getPrivilegeRequest, getMockPrivileges } from '../__mocks__/request_responses'; +import { getPrivilegeRequest, getMockPrivilegesResult } from '../__mocks__/request_responses'; -describe('read_privileges', () => { +describe('read_privileges route', () => { let server: ReturnType; let { clients, context } = requestContextMock.createTools(); + let mockSecurity: ReturnType; beforeEach(() => { server = serverMock.create(); ({ clients, context } = requestContextMock.createTools()); - clients.clusterClient.callAsCurrentUser.mockResolvedValue(getMockPrivileges()); - readPrivilegesRoute(server.router, false); + mockSecurity = securityMock.createSetup(); + mockSecurity.authc.isAuthenticated.mockReturnValue(false); + clients.clusterClient.callAsCurrentUser.mockResolvedValue(getMockPrivilegesResult()); + readPrivilegesRoute(server.router, mockSecurity, false); }); describe('normal status codes', () => { @@ -26,10 +30,28 @@ describe('read_privileges', () => { expect(response.status).toEqual(200); }); - test.skip('returns the payload when doing a normal request', async () => { + test('returns the payload when doing a normal request', async () => { const response = await server.inject(getPrivilegeRequest(), context); + const expectedBody = { + ...getMockPrivilegesResult(), + is_authenticated: false, + has_encryption_key: true, + }; expect(response.status).toEqual(200); - expect(response.body).toEqual(getMockPrivileges()); + expect(response.body).toEqual(expectedBody); + }); + + test('is authenticated when security says so', async () => { + mockSecurity.authc.isAuthenticated.mockReturnValue(true); + const expectedBody = { + ...getMockPrivilegesResult(), + is_authenticated: true, + has_encryption_key: true, + }; + + const response = await server.inject(getPrivilegeRequest(), context); + expect(response.status).toEqual(200); + expect(response.body).toEqual(expectedBody); }); test('returns 500 when bad response from cluster', async () => { @@ -41,4 +63,26 @@ describe('read_privileges', () => { expect(response.body).toEqual({ message: 'Test error', status_code: 500 }); }); }); + + describe('when security plugin is disabled', () => { + beforeEach(() => { + server = serverMock.create(); + ({ clients, context } = requestContextMock.createTools()); + + clients.clusterClient.callAsCurrentUser.mockResolvedValue(getMockPrivilegesResult()); + readPrivilegesRoute(server.router, undefined, false); + }); + + it('returns unauthenticated', async () => { + const expectedBody = { + ...getMockPrivilegesResult(), + is_authenticated: false, + has_encryption_key: true, + }; + + const response = await server.inject(getPrivilegeRequest(), context); + expect(response.status).toEqual(200); + expect(response.body).toEqual(expectedBody); + }); + }); }); diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/privileges/read_privileges_route.ts b/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/privileges/read_privileges_route.ts index 81ce4a9c3f2f..2f5ea4d1ec76 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/privileges/read_privileges_route.ts +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/privileges/read_privileges_route.ts @@ -8,10 +8,15 @@ import { merge } from 'lodash/fp'; import { IRouter } from '../../../../../../../../../src/core/server'; import { DETECTION_ENGINE_PRIVILEGES_URL } from '../../../../../common/constants'; +import { SetupPlugins } from '../../../../plugin'; import { buildSiemResponse, transformError } from '../utils'; import { readPrivileges } from '../../privileges/read_privileges'; -export const readPrivilegesRoute = (router: IRouter, usingEphemeralEncryptionKey: boolean) => { +export const readPrivilegesRoute = ( + router: IRouter, + security: SetupPlugins['security'], + usingEphemeralEncryptionKey: boolean +) => { router.get( { path: DETECTION_ENGINE_PRIVILEGES_URL, @@ -29,7 +34,7 @@ export const readPrivilegesRoute = (router: IRouter, usingEphemeralEncryptionKey const index = siemClient.signalsIndex; const clusterPrivileges = await readPrivileges(clusterClient.callAsCurrentUser, index); const privileges = merge(clusterPrivileges, { - is_authenticated: true, // until we support optional auth: https://github.com/elastic/kibana/pull/55327#issuecomment-577159911 + is_authenticated: security?.authc.isAuthenticated(request) ?? false, has_encryption_key: !usingEphemeralEncryptionKey, }); diff --git a/x-pack/legacy/plugins/siem/server/lib/framework/kibana_framework_adapter.ts b/x-pack/legacy/plugins/siem/server/lib/framework/kibana_framework_adapter.ts index 004ac36bad5b..6b41426e047c 100644 --- a/x-pack/legacy/plugins/siem/server/lib/framework/kibana_framework_adapter.ts +++ b/x-pack/legacy/plugins/siem/server/lib/framework/kibana_framework_adapter.ts @@ -122,7 +122,7 @@ export class KibanaBackendFrameworkAdapter implements FrameworkAdapter { private async getCurrentUserInfo(request: KibanaRequest): Promise { try { - const user = await this.security.authc.getCurrentUser(request); + const user = (await this.security?.authc.getCurrentUser(request)) ?? null; return user; } catch { return null; diff --git a/x-pack/legacy/plugins/siem/server/lib/timeline/routes/import_timelines_route.ts b/x-pack/legacy/plugins/siem/server/lib/timeline/routes/import_timelines_route.ts index fefe31b2f36d..2b41b4e7843a 100644 --- a/x-pack/legacy/plugins/siem/server/lib/timeline/routes/import_timelines_route.ts +++ b/x-pack/legacy/plugins/siem/server/lib/timeline/routes/import_timelines_route.ts @@ -30,6 +30,7 @@ import { import { IRouter } from '../../../../../../../../src/core/server'; import { TIMELINE_IMPORT_URL } from '../../../../common/constants'; +import { SetupPlugins } from '../../../plugin'; import { importTimelinesPayloadSchema } from './schemas/import_timelines_schema'; import { importRulesSchema } from '../../detection_engine/routes/schemas/response/import_rules_schema'; import { LegacyServices } from '../../../types'; @@ -37,7 +38,6 @@ import { LegacyServices } from '../../../types'; import { Timeline } from '../saved_object'; import { validate } from '../../detection_engine/routes/rules/validate'; import { FrameworkRequest } from '../../framework'; -import { SecurityPluginSetup } from '../../../../../../../plugins/security/server'; const CHUNK_PARSED_OBJECT_SIZE = 10; @@ -46,7 +46,7 @@ const timelineLib = new Timeline(); export const importTimelinesRoute = ( router: IRouter, config: LegacyServices['config'], - securityPluginSetup: SecurityPluginSetup + security: SetupPlugins['security'] ) => { router.post( { @@ -96,7 +96,7 @@ export const importTimelinesRoute = ( const chunkParseObjects = chunk(CHUNK_PARSED_OBJECT_SIZE, uniqueParsedObjects); let importTimelineResponse: ImportTimelineResponse[] = []; - const user = await securityPluginSetup.authc.getCurrentUser(request); + const user = await security?.authc.getCurrentUser(request); let frameworkRequest = set('context.core.savedObjects.client', savedObjectsClient, request); frameworkRequest = set('user', user, frameworkRequest); diff --git a/x-pack/legacy/plugins/siem/server/plugin.ts b/x-pack/legacy/plugins/siem/server/plugin.ts index 2bce9b6a7e1a..98631ea220a5 100644 --- a/x-pack/legacy/plugins/siem/server/plugin.ts +++ b/x-pack/legacy/plugins/siem/server/plugin.ts @@ -46,7 +46,7 @@ export interface SetupPlugins { encryptedSavedObjects: EncryptedSavedObjectsSetup; features: FeaturesSetup; licensing: LicensingPluginSetup; - security: SecuritySetup; + security?: SecuritySetup; spaces?: SpacesSetup; } diff --git a/x-pack/legacy/plugins/siem/server/routes/index.ts b/x-pack/legacy/plugins/siem/server/routes/index.ts index 29c21ad15723..8c9f92890c26 100644 --- a/x-pack/legacy/plugins/siem/server/routes/index.ts +++ b/x-pack/legacy/plugins/siem/server/routes/index.ts @@ -31,13 +31,13 @@ import { findRulesStatusesRoute } from '../lib/detection_engine/routes/rules/fin import { getPrepackagedRulesStatusRoute } from '../lib/detection_engine/routes/rules/get_prepackaged_rules_status_route'; import { importTimelinesRoute } from '../lib/timeline/routes/import_timelines_route'; import { exportTimelinesRoute } from '../lib/timeline/routes/export_timelines_route'; -import { SecurityPluginSetup } from '../../../../../plugins/security/server/'; +import { SetupPlugins } from '../plugin'; export const initRoutes = ( router: IRouter, config: LegacyServices['config'], usingEphemeralEncryptionKey: boolean, - security: SecurityPluginSetup + security: SetupPlugins['security'] ) => { // Detection Engine Rule routes that have the REST endpoints of /api/detection_engine/rules // All REST rule creation, deletion, updating, etc...... @@ -79,5 +79,5 @@ export const initRoutes = ( readTagsRoute(router); // Privileges API to get the generic user privileges - readPrivilegesRoute(router, usingEphemeralEncryptionKey); + readPrivilegesRoute(router, security, usingEphemeralEncryptionKey); }; From 1bcf848e468e58809ccb850784c42626bdd15eee Mon Sep 17 00:00:00 2001 From: Tyler Smalley Date: Wed, 25 Mar 2020 22:22:04 -0700 Subject: [PATCH 19/35] Sets min_doc_count=0 for parent histogram of derivative aggregation (#61390) From the docs: The specified metric must be numeric and the enclosing histogram must have min_doc_count set to 0 (default for histogram aggregations). https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-pipeline-derivative-aggregation.html#search-aggregations-pipeline-derivative-aggregation This is now enforced, and currently failing the promotion of the current Elasticsearch build Related to https://github.com/elastic/kibana/pull/61387 Signed-off-by: Tyler Smalley --- .../server/lib/elasticsearch/nodes/get_nodes/get_nodes.js | 2 +- .../api_integration/apis/monitoring/elasticsearch/nodes.js | 3 +-- x-pack/test/functional/apps/monitoring/elasticsearch/nodes.js | 3 +-- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/x-pack/plugins/monitoring/server/lib/elasticsearch/nodes/get_nodes/get_nodes.js b/x-pack/plugins/monitoring/server/lib/elasticsearch/nodes/get_nodes/get_nodes.js index c248ad743e0e..d431ec47adbc 100644 --- a/x-pack/plugins/monitoring/server/lib/elasticsearch/nodes/get_nodes/get_nodes.js +++ b/x-pack/plugins/monitoring/server/lib/elasticsearch/nodes/get_nodes/get_nodes.js @@ -84,7 +84,7 @@ export async function getNodes(req, esIndexPattern, pageOfNodes, clusterStats, n by_date: { date_histogram: { field: 'timestamp', - min_doc_count: 1, + min_doc_count: 0, fixed_interval: bucketSize + 's', }, aggs: getMetricAggs(LISTING_METRICS_NAMES, bucketSize), diff --git a/x-pack/test/api_integration/apis/monitoring/elasticsearch/nodes.js b/x-pack/test/api_integration/apis/monitoring/elasticsearch/nodes.js index f9a6dd31092a..4d86fc9d9a7f 100644 --- a/x-pack/test/api_integration/apis/monitoring/elasticsearch/nodes.js +++ b/x-pack/test/api_integration/apis/monitoring/elasticsearch/nodes.js @@ -34,8 +34,7 @@ export default function({ getService }) { return esArchiver.unload(archive); }); - // https://github.com/elastic/kibana/issues/61366 - it.skip('should return data for 2 active nodes', async () => { + it('should return data for 2 active nodes', async () => { const { body } = await supertest .post('/api/monitoring/v1/clusters/fHJwISmKTFO8bj57oFBLUQ/elasticsearch/nodes') .set('kbn-xsrf', 'xxx') diff --git a/x-pack/test/functional/apps/monitoring/elasticsearch/nodes.js b/x-pack/test/functional/apps/monitoring/elasticsearch/nodes.js index dcbd94de8a77..d407ba898f10 100644 --- a/x-pack/test/functional/apps/monitoring/elasticsearch/nodes.js +++ b/x-pack/test/functional/apps/monitoring/elasticsearch/nodes.js @@ -34,8 +34,7 @@ export default function({ getService, getPageObjects }) { await tearDown(); }); - // https://github.com/elastic/kibana/issues/61366 - it.skip('should have an Elasticsearch Cluster Summary Status with correct info', async () => { + it('should have an Elasticsearch Cluster Summary Status with correct info', async () => { expect(await esClusterSummaryStatus.getContent()).to.eql({ nodesCount: 'Nodes\n2', indicesCount: 'Indices\n20', From 9dd7ac2de9f7ef117601e09682361142f228cf80 Mon Sep 17 00:00:00 2001 From: Thomas Watson Date: Thu, 26 Mar 2020 06:59:13 +0100 Subject: [PATCH 20/35] Bump cypress dev-dependency from 4.0.2 to 4.2.0 (#61128) --- x-pack/package.json | 2 +- yarn.lock | 128 +++++++++++++++++++++++++++----------------- 2 files changed, 80 insertions(+), 50 deletions(-) diff --git a/x-pack/package.json b/x-pack/package.json index 2f94beaf1bf7..1b69ed353984 100644 --- a/x-pack/package.json +++ b/x-pack/package.json @@ -120,7 +120,7 @@ "cheerio": "0.22.0", "commander": "3.0.2", "copy-webpack-plugin": "^5.0.4", - "cypress": "^4.0.2", + "cypress": "^4.2.0", "cypress-multi-reporters": "^1.2.3", "enzyme": "^3.11.0", "enzyme-adapter-react-16": "^1.15.2", diff --git a/yarn.lock b/yarn.lock index 461f12cd2ea1..a925df3d1f46 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8283,14 +8283,6 @@ chalk@2.4.2, chalk@^2.3.2, chalk@^2.4.2, chalk@~2.4.1: escape-string-regexp "^1.0.5" supports-color "^5.3.0" -chalk@3.0.0, chalk@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/chalk/-/chalk-3.0.0.tgz#3f73c2bf526591f574cc492c51e2456349f844e4" - integrity sha512-4D3B6Wf41KOYRFdszmDqMCGq5VV/uMAB273JILmO+3jAlh8X4qDtdtgCR3fxtbLEMzSx22QdhnDcJvu2u1fVwg== - dependencies: - ansi-styles "^4.1.0" - supports-color "^7.1.0" - chalk@^1.0.0, chalk@^1.1.1, chalk@^1.1.3: version "1.1.3" resolved "https://registry.yarnpkg.com/chalk/-/chalk-1.1.3.tgz#a8115c55e4a702fe4d150abd3872822a7e09fc98" @@ -8320,6 +8312,14 @@ chalk@^2.3.0: escape-string-regexp "^1.0.5" supports-color "^5.2.0" +chalk@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/chalk/-/chalk-3.0.0.tgz#3f73c2bf526591f574cc492c51e2456349f844e4" + integrity sha512-4D3B6Wf41KOYRFdszmDqMCGq5VV/uMAB273JILmO+3jAlh8X4qDtdtgCR3fxtbLEMzSx22QdhnDcJvu2u1fVwg== + dependencies: + ansi-styles "^4.1.0" + supports-color "^7.1.0" + chalk@~0.4.0: version "0.4.0" resolved "https://registry.yarnpkg.com/chalk/-/chalk-0.4.0.tgz#5199a3ddcd0c1efe23bc08c1b027b06176e0c64f" @@ -10145,10 +10145,10 @@ cypress-multi-reporters@^1.2.3: debug "^4.1.1" lodash "^4.17.11" -cypress@^4.0.2: - version "4.0.2" - resolved "https://registry.yarnpkg.com/cypress/-/cypress-4.0.2.tgz#ede194d7bc73fb449f8de553c9e1db4ca15309ef" - integrity sha512-WRzxOoSd+TxyXKa7Zi9orz3ii5VW7yhhVYstCU+EpOKfPan9x5Ww2Clucmy4H/W0GHUYAo7GYFZRD33ZCSNBQA== +cypress@^4.2.0: + version "4.2.0" + resolved "https://registry.yarnpkg.com/cypress/-/cypress-4.2.0.tgz#45673fb648b1a77b9a78d73e58b89ed05212d243" + integrity sha512-8LdreL91S/QiTCLYLNbIjLL8Ht4fJmu/4HGLxUI20Tc7JSfqEfCmXELrRfuPT0kjosJwJJZacdSji9XSRkPKUw== dependencies: "@cypress/listr-verbose-renderer" "0.4.1" "@cypress/xvfb" "1.2.4" @@ -10156,13 +10156,14 @@ cypress@^4.0.2: arch "2.1.1" bluebird "3.7.2" cachedir "2.3.0" - chalk "3.0.0" + chalk "2.4.2" check-more-types "2.24.0" + cli-table3 "0.5.1" commander "4.1.0" common-tags "1.8.0" debug "4.1.1" eventemitter2 "4.1.2" - execa "3.3.0" + execa "1.0.0" executable "4.1.1" extract-zip "1.6.7" fs-extra "8.1.0" @@ -10173,10 +10174,12 @@ cypress@^4.0.2: listr "0.14.3" lodash "4.17.15" log-symbols "3.0.0" - minimist "1.2.0" + minimist "1.2.2" moment "2.24.0" + ospath "1.2.2" + pretty-bytes "5.3.0" ramda "0.26.1" - request "2.88.0" + request cypress-io/request#b5af0d1fa47eec97ba980cde90a13e69a2afcd16 request-progress "3.0.0" supports-color "7.1.0" tmp "0.1.0" @@ -12568,21 +12571,18 @@ exec-sh@^0.3.2: resolved "https://registry.yarnpkg.com/exec-sh/-/exec-sh-0.3.2.tgz#6738de2eb7c8e671d0366aea0b0db8c6f7d7391b" integrity sha512-9sLAvzhI5nc8TpuQUh4ahMdCrWT00wPWz7j47/emR5+2qEfoZP5zzUXvx+vdx+H6ohhnsYC31iX04QLYJK8zTg== -execa@3.3.0: - version "3.3.0" - resolved "https://registry.yarnpkg.com/execa/-/execa-3.3.0.tgz#7e348eef129a1937f21ecbbd53390942653522c1" - integrity sha512-j5Vit5WZR/cbHlqU97+qcnw9WHRCIL4V1SVe75VcHcD1JRBdt8fv0zw89b7CQHQdUHTt2VjuhcF5ibAgVOxqpg== +execa@1.0.0, execa@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/execa/-/execa-1.0.0.tgz#c6236a5bb4df6d6f15e88e7f017798216749ddd8" + integrity sha512-adbxcyWV46qiHyvSp50TKt05tB4tK3HcmF7/nxfAdhnox83seTDbwnaqKO4sXRy7roHAIFqJP/Rw/AuEbX61LA== dependencies: - cross-spawn "^7.0.0" - get-stream "^5.0.0" - human-signals "^1.1.1" - is-stream "^2.0.0" - merge-stream "^2.0.0" - npm-run-path "^4.0.0" - onetime "^5.1.0" - p-finally "^2.0.0" - signal-exit "^3.0.2" - strip-final-newline "^2.0.0" + cross-spawn "^6.0.0" + get-stream "^4.0.0" + is-stream "^1.1.0" + npm-run-path "^2.0.0" + p-finally "^1.0.0" + signal-exit "^3.0.0" + strip-eof "^1.0.0" execa@^0.1.1: version "0.1.1" @@ -12644,19 +12644,6 @@ execa@^0.7.0: signal-exit "^3.0.0" strip-eof "^1.0.0" -execa@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/execa/-/execa-1.0.0.tgz#c6236a5bb4df6d6f15e88e7f017798216749ddd8" - integrity sha512-adbxcyWV46qiHyvSp50TKt05tB4tK3HcmF7/nxfAdhnox83seTDbwnaqKO4sXRy7roHAIFqJP/Rw/AuEbX61LA== - dependencies: - cross-spawn "^6.0.0" - get-stream "^4.0.0" - is-stream "^1.1.0" - npm-run-path "^2.0.0" - p-finally "^1.0.0" - signal-exit "^3.0.0" - strip-eof "^1.0.0" - execa@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/execa/-/execa-4.0.0.tgz#7f37d6ec17f09e6b8fc53288611695b6d12b9daf" @@ -15314,7 +15301,7 @@ har-validator@~5.0.3: ajv "^5.1.0" har-schema "^2.0.0" -har-validator@~5.1.0: +har-validator@~5.1.0, har-validator@~5.1.3: version "5.1.3" resolved "https://registry.yarnpkg.com/har-validator/-/har-validator-5.1.3.tgz#1ef89ebd3e4996557675eed9893110dc350fa080" integrity sha512-sNvOCzEQNr/qrvJgc3UG/kD4QtlHycrzwS+6mfTrrSq97BvaYcPZZI1ZSqGSPR73Cxn4LKTD4PttRwfU7jWq5g== @@ -20148,6 +20135,11 @@ minimist@1.2.0, minimist@^1.1.0, minimist@^1.1.1, minimist@^1.1.3, minimist@^1.2 resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284" integrity sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ= +minimist@1.2.2: + version "1.2.2" + resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.2.tgz#b00a00230a1108c48c169e69a291aafda3aacd63" + integrity sha512-rIqbOrKb8GJmx/5bc2M0QchhUouMXSpd1RTclXsB41JdL+VtnojfaJR+h7F9k18/4kHUsBFgk80Uk+q569vjPA== + minimist@^0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.1.0.tgz#99df657a52574c21c9057497df742790b2b4c0de" @@ -21732,6 +21724,11 @@ osenv@0, osenv@^0.1.0: os-homedir "^1.0.0" os-tmpdir "^1.0.0" +ospath@1.2.2: + version "1.2.2" + resolved "https://registry.yarnpkg.com/ospath/-/ospath-1.2.2.tgz#1276639774a3f8ef2572f7fe4280e0ea4550c07b" + integrity sha1-EnZjl3Sj+O8lcvf+QoDg6kVQwHs= + p-all@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/p-all/-/p-all-2.1.0.tgz#91419be56b7dee8fe4c5db875d55e0da084244a0" @@ -21780,11 +21777,6 @@ p-finally@^1.0.0: resolved "https://registry.yarnpkg.com/p-finally/-/p-finally-1.0.0.tgz#3fbcfb15b899a44123b34b6dcc18b724336a2cae" integrity sha1-P7z7FbiZpEEjs0ttzBi3JDNqLK4= -p-finally@^2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/p-finally/-/p-finally-2.0.1.tgz#bd6fcaa9c559a096b680806f4d657b3f0f240561" - integrity sha512-vpm09aKwq6H9phqRQzecoDpD8TmVyGw70qmWlyq5onxY7tqyTTFVvxMykxQSQKILBSFlbXpypIw2T1Ml7+DDtw== - p-is-promise@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/p-is-promise/-/p-is-promise-1.1.0.tgz#9c9456989e9f6588017b0434d56097675c3da05e" @@ -22812,6 +22804,11 @@ prettier@^1.19.1: resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.19.1.tgz#f7d7f5ff8a9cd872a7be4ca142095956a60797cb" integrity sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew== +pretty-bytes@5.3.0: + version "5.3.0" + resolved "https://registry.yarnpkg.com/pretty-bytes/-/pretty-bytes-5.3.0.tgz#f2849e27db79fb4d6cfe24764fc4134f165989f2" + integrity sha512-hjGrh+P926p4R4WbaB6OckyRtO0F0/lQBiT+0gnxjV+5kjPBrfVBFCsCLbMqVQeydvIoouYTCmmEURiH3R1Bdg== + pretty-bytes@^4.0.2: version "4.0.2" resolved "https://registry.yarnpkg.com/pretty-bytes/-/pretty-bytes-4.0.2.tgz#b2bf82e7350d65c6c33aa95aaa5a4f6327f61cd9" @@ -25259,6 +25256,31 @@ request@^2.87.0: tunnel-agent "^0.6.0" uuid "^3.1.0" +request@cypress-io/request#b5af0d1fa47eec97ba980cde90a13e69a2afcd16: + version "2.88.1" + resolved "https://codeload.github.com/cypress-io/request/tar.gz/b5af0d1fa47eec97ba980cde90a13e69a2afcd16" + dependencies: + aws-sign2 "~0.7.0" + aws4 "^1.8.0" + caseless "~0.12.0" + combined-stream "~1.0.6" + extend "~3.0.2" + forever-agent "~0.6.1" + form-data "~2.3.2" + har-validator "~5.1.3" + http-signature "~1.2.0" + is-typedarray "~1.0.0" + isstream "~0.1.2" + json-stringify-safe "~5.0.1" + mime-types "~2.1.19" + oauth-sign "~0.9.0" + performance-now "^2.1.0" + qs "~6.5.2" + safe-buffer "^5.1.2" + tough-cookie "~2.5.0" + tunnel-agent "^0.6.0" + uuid "^3.3.2" + require-ancestors@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/require-ancestors/-/require-ancestors-1.0.0.tgz#807831f8f8081fb12863da81ddb15c8f2a73a004" @@ -28567,6 +28589,14 @@ tough-cookie@~2.3.0, tough-cookie@~2.3.3: dependencies: punycode "^1.4.1" +tough-cookie@~2.5.0: + version "2.5.0" + resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-2.5.0.tgz#cd9fb2a0aa1d5a12b473bd9fb96fa3dcff65ade2" + integrity sha512-nlLsUzgm1kfLXSXfRZMc1KLAugd4hqJHDTvc2hDIwS3mZAfMEuMbc03SujMF+GEcpaX/qboeycw6iO8JwVv2+g== + dependencies: + psl "^1.1.28" + punycode "^2.1.1" + tr46@^1.0.0, tr46@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/tr46/-/tr46-1.0.1.tgz#a8b13fd6bfd2489519674ccde55ba3693b706d09" From fe2ae7ea0d24d6105993920a3bdc19033483f0cb Mon Sep 17 00:00:00 2001 From: Thomas Watson Date: Thu, 26 Mar 2020 07:07:42 +0100 Subject: [PATCH 21/35] Bump extract-zip from v1.6.7 to v1.7.0 (#61209) This commit also consolidates our versions of the mkdirp sub-dependency to use the newest 0.5.x version (v0.5.4) wherever possible. --- packages/kbn-pm/dist/index.js | 1 + x-pack/package.json | 2 +- yarn.lock | 23 ++++++++++++++++++++--- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/packages/kbn-pm/dist/index.js b/packages/kbn-pm/dist/index.js index 4b6375b0cc09..ace8fc11c124 100644 --- a/packages/kbn-pm/dist/index.js +++ b/packages/kbn-pm/dist/index.js @@ -4013,6 +4013,7 @@ function mkdirP (p, opts, f, made) { } switch (er.code) { case 'ENOENT': + if (path.dirname(p) === p) return cb(er); mkdirP(path.dirname(p), opts, function (er, made) { if (er) cb(er, made); else mkdirP(p, opts, cb, made); diff --git a/x-pack/package.json b/x-pack/package.json index 1b69ed353984..1677748e4c9e 100644 --- a/x-pack/package.json +++ b/x-pack/package.json @@ -233,7 +233,7 @@ "del": "^5.1.0", "dragselect": "1.13.1", "elasticsearch": "^16.5.0", - "extract-zip": "1.6.7", + "extract-zip": "^1.7.0", "file-saver": "^1.3.8", "file-type": "^10.9.0", "font-awesome": "4.7.0", diff --git a/yarn.lock b/yarn.lock index a925df3d1f46..7717ea90f1ee 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9213,7 +9213,7 @@ concat-stream@1.6.0, concat-stream@^1.4.7, concat-stream@~1.6.0: readable-stream "^2.2.2" typedarray "^0.0.6" -concat-stream@1.6.2, concat-stream@^1.4.6, concat-stream@^1.5.0, concat-stream@^1.6.0, concat-stream@^1.6.1: +concat-stream@1.6.2, concat-stream@^1.4.6, concat-stream@^1.5.0, concat-stream@^1.6.0, concat-stream@^1.6.1, concat-stream@^1.6.2: version "1.6.2" resolved "https://registry.yarnpkg.com/concat-stream/-/concat-stream-1.6.2.tgz#904bdf194cd3122fc675c77fc4ac3d4ff0fd1a34" integrity sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw== @@ -12946,7 +12946,7 @@ extract-zip@1.6.6: mkdirp "0.5.0" yauzl "2.4.1" -extract-zip@1.6.7, extract-zip@^1.6.6, extract-zip@^1.6.7: +extract-zip@1.6.7: version "1.6.7" resolved "https://registry.yarnpkg.com/extract-zip/-/extract-zip-1.6.7.tgz#a840b4b8af6403264c8db57f4f1a74333ef81fe9" integrity sha1-qEC0uK9kAyZMjbV/Txp0Mz74H+k= @@ -12956,6 +12956,16 @@ extract-zip@1.6.7, extract-zip@^1.6.6, extract-zip@^1.6.7: mkdirp "0.5.1" yauzl "2.4.1" +extract-zip@^1.6.6, extract-zip@^1.6.7, extract-zip@^1.7.0: + version "1.7.0" + resolved "https://registry.yarnpkg.com/extract-zip/-/extract-zip-1.7.0.tgz#556cc3ae9df7f452c493a0cfb51cc30277940927" + integrity sha512-xoh5G1W/PB0/27lXgMQyIhP5DSY/LhoCsOyZgb+6iMmRtCwVBo55uKaMoEYrDCKQhWvqEip5ZPKAc6eFNyf/MA== + dependencies: + concat-stream "^1.6.2" + debug "^2.6.9" + mkdirp "^0.5.4" + yauzl "^2.10.0" + extsprintf@1.3.0: version "1.3.0" resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.3.0.tgz#96918440e3041a7a414f8c52e3c574eb3c3e1e05" @@ -20266,7 +20276,7 @@ mkdirp@0.5.0: dependencies: minimist "0.0.8" -mkdirp@0.5.1, mkdirp@0.5.x, "mkdirp@>=0.5 0", mkdirp@^0.5.0, mkdirp@^0.5.1, mkdirp@~0.5.0, mkdirp@~0.5.1: +mkdirp@0.5.1: version "0.5.1" resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.1.tgz#30057438eac6cf7f8c4767f38648d6697d75c903" integrity sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM= @@ -20280,6 +20290,13 @@ mkdirp@0.5.3: dependencies: minimist "^1.2.5" +mkdirp@0.5.x, "mkdirp@>=0.5 0", mkdirp@^0.5.0, mkdirp@^0.5.1, mkdirp@^0.5.4, mkdirp@~0.5.0, mkdirp@~0.5.1: + version "0.5.4" + resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.4.tgz#fd01504a6797ec5c9be81ff43d204961ed64a512" + integrity sha512-iG9AK/dJLtJ0XNgTuDbSyNS3zECqDlAhnQW4CsNxBG3LQJBbHmRX1egw39DmtOdCAqY+dKXV+sgPgilNWUKMVw== + dependencies: + minimist "^1.2.5" + mkdirp@^1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-1.0.3.tgz#4cf2e30ad45959dddea53ad97d518b6c8205e1ea" From cf5c8f60bbed35cfe47ec3f8e2aa3a30f4705547 Mon Sep 17 00:00:00 2001 From: Peter Pisljar Date: Thu, 26 Mar 2020 07:34:18 +0100 Subject: [PATCH 22/35] fixing tabifyAggResponse (#61214) --- .../search/tabify/response_writer.test.ts | 21 ++++++++++++++++--- .../public/search/tabify/response_writer.ts | 7 +++---- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src/plugins/data/public/search/tabify/response_writer.test.ts b/src/plugins/data/public/search/tabify/response_writer.test.ts index ca84f08de8c8..52338ae79ccb 100644 --- a/src/plugins/data/public/search/tabify/response_writer.test.ts +++ b/src/plugins/data/public/search/tabify/response_writer.test.ts @@ -106,13 +106,13 @@ describe('TabbedAggResponseWriter class', () => { }); test('adds the row to the array', () => { - responseWriter.bucketBuffer = [{ id: 'col-0', value: 'US' }]; - responseWriter.metricBuffer = [{ id: 'col-1', value: 5 }]; + responseWriter.bucketBuffer = [{ id: 'col-0-1', value: 'US' }]; + responseWriter.metricBuffer = [{ id: 'col-1-2', value: 5 }]; responseWriter.row(); expect(responseWriter.rows.length).toEqual(1); - expect(responseWriter.rows[0]).toEqual({ 'col-0': 'US', 'col-1': 5 }); + expect(responseWriter.rows[0]).toEqual({ 'col-0-1': 'US', 'col-1-2': 5 }); }); test("doesn't add an empty row", () => { @@ -120,6 +120,21 @@ describe('TabbedAggResponseWriter class', () => { expect(responseWriter.rows.length).toEqual(0); }); + + test('doesnt add a partial row', () => { + responseWriter.bucketBuffer = [{ id: 'col-0-1', value: 'US' }]; + responseWriter.row(); + + expect(responseWriter.rows.length).toEqual(0); + }); + + test('adds partial row if partialRows is set to true', () => { + responseWriter = createResponseWritter(splitAggConfig, { partialRows: true }); + responseWriter.bucketBuffer = [{ id: 'col-0-1', value: 'US' }]; + responseWriter.row(); + + expect(responseWriter.rows.length).toEqual(1); + }); }); describe('response()', () => { diff --git a/src/plugins/data/public/search/tabify/response_writer.ts b/src/plugins/data/public/search/tabify/response_writer.ts index cacecbec3be0..02e18d75ae6e 100644 --- a/src/plugins/data/public/search/tabify/response_writer.ts +++ b/src/plugins/data/public/search/tabify/response_writer.ts @@ -69,10 +69,9 @@ export class TabbedAggResponseWriter { rowBuffer[metric.id] = metric.value; }); - const isPartialRow = - this.partialRows && !this.columns.every(column => rowBuffer.hasOwnProperty(column.id)); - - if (!isEmpty(rowBuffer) && !isPartialRow) { + const isPartialRow = !this.columns.every(column => rowBuffer.hasOwnProperty(column.id)); + const removePartial = isPartialRow && !this.partialRows; + if (!isEmpty(rowBuffer) && !removePartial) { this.rows.push(rowBuffer); } } From 1d278d4494581b7473cf667717a290df913ddfbf Mon Sep 17 00:00:00 2001 From: Daniil Suleiman <31325372+sulemanof@users.noreply.github.com> Date: Thu, 26 Mar 2020 10:52:57 +0300 Subject: [PATCH 23/35] [Discover][Visualize] Fix visualizing a selected field in discover search (#61226) * Fix visualize a discover search * Move deep clone into vis.ts * Add functional tests * Fix passing filters to visualize * Revert fixing filters --- .../public/np_ready/public/vis.ts | 6 +- .../apps/discover/_field_visualize.ts | 80 +++++++++++++++++++ test/functional/apps/discover/index.js | 1 + 3 files changed, 85 insertions(+), 2 deletions(-) create mode 100644 test/functional/apps/discover/_field_visualize.ts diff --git a/src/legacy/core_plugins/visualizations/public/np_ready/public/vis.ts b/src/legacy/core_plugins/visualizations/public/np_ready/public/vis.ts index 0ba936c9f656..91b6a2368f5e 100644 --- a/src/legacy/core_plugins/visualizations/public/np_ready/public/vis.ts +++ b/src/legacy/core_plugins/visualizations/public/np_ready/public/vis.ts @@ -132,8 +132,10 @@ export class Vis { this.data.savedSearchId = state.data.savedSearchId; } if (state.data && state.data.aggs) { - let configStates = state.data.aggs; - configStates = this.initializeDefaultsFromSchemas(configStates, this.type.schemas.all || []); + const configStates = this.initializeDefaultsFromSchemas( + cloneDeep(state.data.aggs), + this.type.schemas.all || [] + ); if (!this.data.indexPattern) { if (state.data.aggs.length) { throw new Error('trying to initialize aggs without index pattern'); diff --git a/test/functional/apps/discover/_field_visualize.ts b/test/functional/apps/discover/_field_visualize.ts new file mode 100644 index 000000000000..4a72d5bb3471 --- /dev/null +++ b/test/functional/apps/discover/_field_visualize.ts @@ -0,0 +1,80 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import { FtrProviderContext } from '../../ftr_provider_context'; + +export default function({ getService, getPageObjects }: FtrProviderContext) { + const esArchiver = getService('esArchiver'); + const inspector = getService('inspector'); + const kibanaServer = getService('kibanaServer'); + const log = getService('log'); + const PageObjects = getPageObjects(['common', 'discover', 'header', 'timePicker']); + const defaultSettings = { + defaultIndex: 'logstash-*', + }; + + describe('discover field visualize button', () => { + before(async function() { + log.debug('load kibana index with default index pattern'); + await esArchiver.load('discover'); + + // and load a set of makelogs data + await esArchiver.loadIfNeeded('logstash_functional'); + await kibanaServer.uiSettings.replace(defaultSettings); + }); + + beforeEach(async () => { + log.debug('go to discover'); + await PageObjects.common.navigateToApp('discover'); + await PageObjects.timePicker.setDefaultAbsoluteRange(); + }); + + it('should visualize a field in area chart', async () => { + await PageObjects.discover.clickFieldListItem('phpmemory'); + log.debug('visualize a phpmemory field'); + await PageObjects.discover.clickFieldListItemVisualize('phpmemory'); + await PageObjects.header.waitUntilLoadingHasFinished(); + const expectedTableData = [ + ['0', '10'], + ['58,320', '2'], + ['171,080', '2'], + ['3,240', '1'], + ['3,520', '1'], + ['3,880', '1'], + ['4,120', '1'], + ['4,640', '1'], + ['4,760', '1'], + ['5,680', '1'], + ['7,160', '1'], + ['7,400', '1'], + ['8,400', '1'], + ['8,800', '1'], + ['8,960', '1'], + ['9,400', '1'], + ['10,280', '1'], + ['10,840', '1'], + ['13,080', '1'], + ['13,360', '1'], + ]; + await inspector.open(); + await inspector.expectTableData(expectedTableData); + await inspector.close(); + }); + }); +} diff --git a/test/functional/apps/discover/index.js b/test/functional/apps/discover/index.js index 64a5a6133536..582c979a194f 100644 --- a/test/functional/apps/discover/index.js +++ b/test/functional/apps/discover/index.js @@ -35,6 +35,7 @@ export default function({ getService, loadTestFile }) { loadTestFile(require.resolve('./_saved_queries')); loadTestFile(require.resolve('./_discover')); loadTestFile(require.resolve('./_discover_histogram')); + loadTestFile(require.resolve('./_field_visualize')); loadTestFile(require.resolve('./_filter_editor')); loadTestFile(require.resolve('./_errors')); loadTestFile(require.resolve('./_field_data')); From 1abd2c3e79a1e9d5750d129168a55faf1fae5fd5 Mon Sep 17 00:00:00 2001 From: spalger Date: Thu, 26 Mar 2020 00:56:26 -0700 Subject: [PATCH 24/35] fix kbn/pm dist --- packages/kbn-pm/dist/index.js | 1105 +++++---------------------------- 1 file changed, 139 insertions(+), 966 deletions(-) diff --git a/packages/kbn-pm/dist/index.js b/packages/kbn-pm/dist/index.js index ace8fc11c124..f7aee155c9b1 100644 --- a/packages/kbn-pm/dist/index.js +++ b/packages/kbn-pm/dist/index.js @@ -79087,7 +79087,7 @@ __webpack_require__.r(__webpack_exports__); /* harmony import */ var _build_production_projects__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(704); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "buildProductionProjects", function() { return _build_production_projects__WEBPACK_IMPORTED_MODULE_0__["buildProductionProjects"]; }); -/* harmony import */ var _prepare_project_dependencies__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(927); +/* harmony import */ var _prepare_project_dependencies__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(922); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "prepareExternalProjectDependencies", function() { return _prepare_project_dependencies__WEBPACK_IMPORTED_MODULE_1__["prepareExternalProjectDependencies"]; }); /* @@ -79272,9 +79272,9 @@ const pAll = __webpack_require__(706); const arrify = __webpack_require__(708); const globby = __webpack_require__(709); const isGlob = __webpack_require__(603); -const cpFile = __webpack_require__(912); -const junk = __webpack_require__(924); -const CpyError = __webpack_require__(925); +const cpFile = __webpack_require__(907); +const junk = __webpack_require__(919); +const CpyError = __webpack_require__(920); const defaultOptions = { ignoreJunk: true @@ -79524,8 +79524,8 @@ const fs = __webpack_require__(23); const arrayUnion = __webpack_require__(710); const glob = __webpack_require__(712); const fastGlob = __webpack_require__(717); -const dirGlob = __webpack_require__(905); -const gitignore = __webpack_require__(908); +const dirGlob = __webpack_require__(900); +const gitignore = __webpack_require__(903); const DEFAULT_FILTER = () => false; @@ -81358,11 +81358,11 @@ module.exports.generateTasks = pkg.generateTasks; Object.defineProperty(exports, "__esModule", { value: true }); var optionsManager = __webpack_require__(719); var taskManager = __webpack_require__(720); -var reader_async_1 = __webpack_require__(876); -var reader_stream_1 = __webpack_require__(900); -var reader_sync_1 = __webpack_require__(901); -var arrayUtils = __webpack_require__(903); -var streamUtils = __webpack_require__(904); +var reader_async_1 = __webpack_require__(871); +var reader_stream_1 = __webpack_require__(895); +var reader_sync_1 = __webpack_require__(896); +var arrayUtils = __webpack_require__(898); +var streamUtils = __webpack_require__(899); /** * Synchronous API. */ @@ -82002,9 +82002,9 @@ var extend = __webpack_require__(837); */ var compilers = __webpack_require__(840); -var parsers = __webpack_require__(872); -var cache = __webpack_require__(873); -var utils = __webpack_require__(874); +var parsers = __webpack_require__(867); +var cache = __webpack_require__(868); +var utils = __webpack_require__(869); var MAX_LENGTH = 1024 * 64; /** @@ -100537,9 +100537,9 @@ var toRegex = __webpack_require__(728); */ var compilers = __webpack_require__(857); -var parsers = __webpack_require__(868); -var Extglob = __webpack_require__(871); -var utils = __webpack_require__(870); +var parsers = __webpack_require__(863); +var Extglob = __webpack_require__(866); +var utils = __webpack_require__(865); var MAX_LENGTH = 1024 * 64; /** @@ -101049,7 +101049,7 @@ var parsers = __webpack_require__(861); * Module dependencies */ -var debug = __webpack_require__(863)('expand-brackets'); +var debug = __webpack_require__(800)('expand-brackets'); var extend = __webpack_require__(737); var Snapdragon = __webpack_require__(767); var toRegex = __webpack_require__(728); @@ -101643,839 +101643,12 @@ exports.createRegex = function(pattern, include) { /* 863 */ /***/ (function(module, exports, __webpack_require__) { -/** - * Detect Electron renderer process, which is node, but we should - * treat as a browser. - */ - -if (typeof process !== 'undefined' && process.type === 'renderer') { - module.exports = __webpack_require__(864); -} else { - module.exports = __webpack_require__(867); -} - - -/***/ }), -/* 864 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * This is the web browser implementation of `debug()`. - * - * Expose `debug()` as the module. - */ - -exports = module.exports = __webpack_require__(865); -exports.log = log; -exports.formatArgs = formatArgs; -exports.save = save; -exports.load = load; -exports.useColors = useColors; -exports.storage = 'undefined' != typeof chrome - && 'undefined' != typeof chrome.storage - ? chrome.storage.local - : localstorage(); - -/** - * Colors. - */ - -exports.colors = [ - 'lightseagreen', - 'forestgreen', - 'goldenrod', - 'dodgerblue', - 'darkorchid', - 'crimson' -]; - -/** - * Currently only WebKit-based Web Inspectors, Firefox >= v31, - * and the Firebug extension (any Firefox version) are known - * to support "%c" CSS customizations. - * - * TODO: add a `localStorage` variable to explicitly enable/disable colors - */ - -function useColors() { - // NB: In an Electron preload script, document will be defined but not fully - // initialized. Since we know we're in Chrome, we'll just detect this case - // explicitly - if (typeof window !== 'undefined' && window.process && window.process.type === 'renderer') { - return true; - } - - // is webkit? http://stackoverflow.com/a/16459606/376773 - // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632 - return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) || - // is firebug? http://stackoverflow.com/a/398120/376773 - (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) || - // is firefox >= v31? - // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages - (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) || - // double check webkit in userAgent just in case we are in a worker - (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)); -} - -/** - * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default. - */ - -exports.formatters.j = function(v) { - try { - return JSON.stringify(v); - } catch (err) { - return '[UnexpectedJSONParseError]: ' + err.message; - } -}; - - -/** - * Colorize log arguments if enabled. - * - * @api public - */ - -function formatArgs(args) { - var useColors = this.useColors; - - args[0] = (useColors ? '%c' : '') - + this.namespace - + (useColors ? ' %c' : ' ') - + args[0] - + (useColors ? '%c ' : ' ') - + '+' + exports.humanize(this.diff); - - if (!useColors) return; - - var c = 'color: ' + this.color; - args.splice(1, 0, c, 'color: inherit') - - // the final "%c" is somewhat tricky, because there could be other - // arguments passed either before or after the %c, so we need to - // figure out the correct index to insert the CSS into - var index = 0; - var lastC = 0; - args[0].replace(/%[a-zA-Z%]/g, function(match) { - if ('%%' === match) return; - index++; - if ('%c' === match) { - // we only are interested in the *last* %c - // (the user may have provided their own) - lastC = index; - } - }); - - args.splice(lastC, 0, c); -} - -/** - * Invokes `console.log()` when available. - * No-op when `console.log` is not a "function". - * - * @api public - */ - -function log() { - // this hackery is required for IE8/9, where - // the `console.log` function doesn't have 'apply' - return 'object' === typeof console - && console.log - && Function.prototype.apply.call(console.log, console, arguments); -} - -/** - * Save `namespaces`. - * - * @param {String} namespaces - * @api private - */ - -function save(namespaces) { - try { - if (null == namespaces) { - exports.storage.removeItem('debug'); - } else { - exports.storage.debug = namespaces; - } - } catch(e) {} -} - -/** - * Load `namespaces`. - * - * @return {String} returns the previously persisted debug modes - * @api private - */ - -function load() { - var r; - try { - r = exports.storage.debug; - } catch(e) {} - - // If debug isn't set in LS, and we're in Electron, try to load $DEBUG - if (!r && typeof process !== 'undefined' && 'env' in process) { - r = process.env.DEBUG; - } - - return r; -} - -/** - * Enable namespaces listed in `localStorage.debug` initially. - */ - -exports.enable(load()); - -/** - * Localstorage attempts to return the localstorage. - * - * This is necessary because safari throws - * when a user disables cookies/localstorage - * and you attempt to access it. - * - * @return {LocalStorage} - * @api private - */ - -function localstorage() { - try { - return window.localStorage; - } catch (e) {} -} - - -/***/ }), -/* 865 */ -/***/ (function(module, exports, __webpack_require__) { - - -/** - * This is the common logic for both the Node.js and web browser - * implementations of `debug()`. - * - * Expose `debug()` as the module. - */ - -exports = module.exports = createDebug.debug = createDebug['default'] = createDebug; -exports.coerce = coerce; -exports.disable = disable; -exports.enable = enable; -exports.enabled = enabled; -exports.humanize = __webpack_require__(866); - -/** - * The currently active debug mode names, and names to skip. - */ - -exports.names = []; -exports.skips = []; - -/** - * Map of special "%n" handling functions, for the debug "format" argument. - * - * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N". - */ - -exports.formatters = {}; - -/** - * Previous log timestamp. - */ - -var prevTime; - -/** - * Select a color. - * @param {String} namespace - * @return {Number} - * @api private - */ - -function selectColor(namespace) { - var hash = 0, i; - - for (i in namespace) { - hash = ((hash << 5) - hash) + namespace.charCodeAt(i); - hash |= 0; // Convert to 32bit integer - } - - return exports.colors[Math.abs(hash) % exports.colors.length]; -} - -/** - * Create a debugger with the given `namespace`. - * - * @param {String} namespace - * @return {Function} - * @api public - */ - -function createDebug(namespace) { - - function debug() { - // disabled? - if (!debug.enabled) return; - - var self = debug; - - // set `diff` timestamp - var curr = +new Date(); - var ms = curr - (prevTime || curr); - self.diff = ms; - self.prev = prevTime; - self.curr = curr; - prevTime = curr; - - // turn the `arguments` into a proper Array - var args = new Array(arguments.length); - for (var i = 0; i < args.length; i++) { - args[i] = arguments[i]; - } - - args[0] = exports.coerce(args[0]); - - if ('string' !== typeof args[0]) { - // anything else let's inspect with %O - args.unshift('%O'); - } - - // apply any `formatters` transformations - var index = 0; - args[0] = args[0].replace(/%([a-zA-Z%])/g, function(match, format) { - // if we encounter an escaped % then don't increase the array index - if (match === '%%') return match; - index++; - var formatter = exports.formatters[format]; - if ('function' === typeof formatter) { - var val = args[index]; - match = formatter.call(self, val); - - // now we need to remove `args[index]` since it's inlined in the `format` - args.splice(index, 1); - index--; - } - return match; - }); - - // apply env-specific formatting (colors, etc.) - exports.formatArgs.call(self, args); - - var logFn = debug.log || exports.log || console.log.bind(console); - logFn.apply(self, args); - } - - debug.namespace = namespace; - debug.enabled = exports.enabled(namespace); - debug.useColors = exports.useColors(); - debug.color = selectColor(namespace); - - // env-specific initialization logic for debug instances - if ('function' === typeof exports.init) { - exports.init(debug); - } - - return debug; -} - -/** - * Enables a debug mode by namespaces. This can include modes - * separated by a colon and wildcards. - * - * @param {String} namespaces - * @api public - */ - -function enable(namespaces) { - exports.save(namespaces); - - exports.names = []; - exports.skips = []; - - var split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/); - var len = split.length; - - for (var i = 0; i < len; i++) { - if (!split[i]) continue; // ignore empty strings - namespaces = split[i].replace(/\*/g, '.*?'); - if (namespaces[0] === '-') { - exports.skips.push(new RegExp('^' + namespaces.substr(1) + '$')); - } else { - exports.names.push(new RegExp('^' + namespaces + '$')); - } - } -} - -/** - * Disable debug output. - * - * @api public - */ - -function disable() { - exports.enable(''); -} - -/** - * Returns true if the given mode name is enabled, false otherwise. - * - * @param {String} name - * @return {Boolean} - * @api public - */ - -function enabled(name) { - var i, len; - for (i = 0, len = exports.skips.length; i < len; i++) { - if (exports.skips[i].test(name)) { - return false; - } - } - for (i = 0, len = exports.names.length; i < len; i++) { - if (exports.names[i].test(name)) { - return true; - } - } - return false; -} - -/** - * Coerce `val`. - * - * @param {Mixed} val - * @return {Mixed} - * @api private - */ - -function coerce(val) { - if (val instanceof Error) return val.stack || val.message; - return val; -} - - -/***/ }), -/* 866 */ -/***/ (function(module, exports) { - -/** - * Helpers. - */ - -var s = 1000; -var m = s * 60; -var h = m * 60; -var d = h * 24; -var y = d * 365.25; - -/** - * Parse or format the given `val`. - * - * Options: - * - * - `long` verbose formatting [false] - * - * @param {String|Number} val - * @param {Object} [options] - * @throws {Error} throw an error if val is not a non-empty string or a number - * @return {String|Number} - * @api public - */ - -module.exports = function(val, options) { - options = options || {}; - var type = typeof val; - if (type === 'string' && val.length > 0) { - return parse(val); - } else if (type === 'number' && isNaN(val) === false) { - return options.long ? fmtLong(val) : fmtShort(val); - } - throw new Error( - 'val is not a non-empty string or a valid number. val=' + - JSON.stringify(val) - ); -}; - -/** - * Parse the given `str` and return milliseconds. - * - * @param {String} str - * @return {Number} - * @api private - */ - -function parse(str) { - str = String(str); - if (str.length > 100) { - return; - } - var match = /^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec( - str - ); - if (!match) { - return; - } - var n = parseFloat(match[1]); - var type = (match[2] || 'ms').toLowerCase(); - switch (type) { - case 'years': - case 'year': - case 'yrs': - case 'yr': - case 'y': - return n * y; - case 'days': - case 'day': - case 'd': - return n * d; - case 'hours': - case 'hour': - case 'hrs': - case 'hr': - case 'h': - return n * h; - case 'minutes': - case 'minute': - case 'mins': - case 'min': - case 'm': - return n * m; - case 'seconds': - case 'second': - case 'secs': - case 'sec': - case 's': - return n * s; - case 'milliseconds': - case 'millisecond': - case 'msecs': - case 'msec': - case 'ms': - return n; - default: - return undefined; - } -} - -/** - * Short format for `ms`. - * - * @param {Number} ms - * @return {String} - * @api private - */ - -function fmtShort(ms) { - if (ms >= d) { - return Math.round(ms / d) + 'd'; - } - if (ms >= h) { - return Math.round(ms / h) + 'h'; - } - if (ms >= m) { - return Math.round(ms / m) + 'm'; - } - if (ms >= s) { - return Math.round(ms / s) + 's'; - } - return ms + 'ms'; -} - -/** - * Long format for `ms`. - * - * @param {Number} ms - * @return {String} - * @api private - */ - -function fmtLong(ms) { - return plural(ms, d, 'day') || - plural(ms, h, 'hour') || - plural(ms, m, 'minute') || - plural(ms, s, 'second') || - ms + ' ms'; -} - -/** - * Pluralization helper. - */ - -function plural(ms, n, name) { - if (ms < n) { - return; - } - if (ms < n * 1.5) { - return Math.floor(ms / n) + ' ' + name; - } - return Math.ceil(ms / n) + ' ' + name + 's'; -} - - -/***/ }), -/* 867 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * Module dependencies. - */ - -var tty = __webpack_require__(478); -var util = __webpack_require__(29); - -/** - * This is the Node.js implementation of `debug()`. - * - * Expose `debug()` as the module. - */ - -exports = module.exports = __webpack_require__(865); -exports.init = init; -exports.log = log; -exports.formatArgs = formatArgs; -exports.save = save; -exports.load = load; -exports.useColors = useColors; - -/** - * Colors. - */ - -exports.colors = [6, 2, 3, 4, 5, 1]; - -/** - * Build up the default `inspectOpts` object from the environment variables. - * - * $ DEBUG_COLORS=no DEBUG_DEPTH=10 DEBUG_SHOW_HIDDEN=enabled node script.js - */ - -exports.inspectOpts = Object.keys(process.env).filter(function (key) { - return /^debug_/i.test(key); -}).reduce(function (obj, key) { - // camel-case - var prop = key - .substring(6) - .toLowerCase() - .replace(/_([a-z])/g, function (_, k) { return k.toUpperCase() }); - - // coerce string value into JS value - var val = process.env[key]; - if (/^(yes|on|true|enabled)$/i.test(val)) val = true; - else if (/^(no|off|false|disabled)$/i.test(val)) val = false; - else if (val === 'null') val = null; - else val = Number(val); - - obj[prop] = val; - return obj; -}, {}); - -/** - * The file descriptor to write the `debug()` calls to. - * Set the `DEBUG_FD` env variable to override with another value. i.e.: - * - * $ DEBUG_FD=3 node script.js 3>debug.log - */ - -var fd = parseInt(process.env.DEBUG_FD, 10) || 2; - -if (1 !== fd && 2 !== fd) { - util.deprecate(function(){}, 'except for stderr(2) and stdout(1), any other usage of DEBUG_FD is deprecated. Override debug.log if you want to use a different log function (https://git.io/debug_fd)')() -} - -var stream = 1 === fd ? process.stdout : - 2 === fd ? process.stderr : - createWritableStdioStream(fd); - -/** - * Is stdout a TTY? Colored output is enabled when `true`. - */ - -function useColors() { - return 'colors' in exports.inspectOpts - ? Boolean(exports.inspectOpts.colors) - : tty.isatty(fd); -} - -/** - * Map %o to `util.inspect()`, all on a single line. - */ - -exports.formatters.o = function(v) { - this.inspectOpts.colors = this.useColors; - return util.inspect(v, this.inspectOpts) - .split('\n').map(function(str) { - return str.trim() - }).join(' '); -}; - -/** - * Map %o to `util.inspect()`, allowing multiple lines if needed. - */ - -exports.formatters.O = function(v) { - this.inspectOpts.colors = this.useColors; - return util.inspect(v, this.inspectOpts); -}; - -/** - * Adds ANSI color escape codes if enabled. - * - * @api public - */ - -function formatArgs(args) { - var name = this.namespace; - var useColors = this.useColors; - - if (useColors) { - var c = this.color; - var prefix = ' \u001b[3' + c + ';1m' + name + ' ' + '\u001b[0m'; - - args[0] = prefix + args[0].split('\n').join('\n' + prefix); - args.push('\u001b[3' + c + 'm+' + exports.humanize(this.diff) + '\u001b[0m'); - } else { - args[0] = new Date().toUTCString() - + ' ' + name + ' ' + args[0]; - } -} - -/** - * Invokes `util.format()` with the specified arguments and writes to `stream`. - */ - -function log() { - return stream.write(util.format.apply(util, arguments) + '\n'); -} - -/** - * Save `namespaces`. - * - * @param {String} namespaces - * @api private - */ - -function save(namespaces) { - if (null == namespaces) { - // If you set a process.env field to null or undefined, it gets cast to the - // string 'null' or 'undefined'. Just delete instead. - delete process.env.DEBUG; - } else { - process.env.DEBUG = namespaces; - } -} - -/** - * Load `namespaces`. - * - * @return {String} returns the previously persisted debug modes - * @api private - */ - -function load() { - return process.env.DEBUG; -} - -/** - * Copied from `node/src/node.js`. - * - * XXX: It's lame that node doesn't expose this API out-of-the-box. It also - * relies on the undocumented `tty_wrap.guessHandleType()` which is also lame. - */ - -function createWritableStdioStream (fd) { - var stream; - var tty_wrap = process.binding('tty_wrap'); - - // Note stream._type is used for test-module-load-list.js - - switch (tty_wrap.guessHandleType(fd)) { - case 'TTY': - stream = new tty.WriteStream(fd); - stream._type = 'tty'; - - // Hack to have stream not keep the event loop alive. - // See https://github.com/joyent/node/issues/1726 - if (stream._handle && stream._handle.unref) { - stream._handle.unref(); - } - break; - - case 'FILE': - var fs = __webpack_require__(23); - stream = new fs.SyncWriteStream(fd, { autoClose: false }); - stream._type = 'fs'; - break; - - case 'PIPE': - case 'TCP': - var net = __webpack_require__(805); - stream = new net.Socket({ - fd: fd, - readable: false, - writable: true - }); - - // FIXME Should probably have an option in net.Socket to create a - // stream from an existing fd which is writable only. But for now - // we'll just add this hack and set the `readable` member to false. - // Test: ./node test/fixtures/echo.js < /etc/passwd - stream.readable = false; - stream.read = null; - stream._type = 'pipe'; - - // FIXME Hack to have stream not keep the event loop alive. - // See https://github.com/joyent/node/issues/1726 - if (stream._handle && stream._handle.unref) { - stream._handle.unref(); - } - break; - - default: - // Probably an error on in uv_guess_handle() - throw new Error('Implement me. Unknown stream file type!'); - } - - // For supporting legacy API we put the FD here. - stream.fd = fd; - - stream._isStdio = true; - - return stream; -} - -/** - * Init logic for `debug` instances. - * - * Create a new `inspectOpts` object in case `useColors` is set - * differently for a particular `debug` instance. - */ - -function init (debug) { - debug.inspectOpts = {}; - - var keys = Object.keys(exports.inspectOpts); - for (var i = 0; i < keys.length; i++) { - debug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]]; - } -} - -/** - * Enable namespaces listed in `process.env.DEBUG` initially. - */ - -exports.enable(load()); - - -/***/ }), -/* 868 */ -/***/ (function(module, exports, __webpack_require__) { - "use strict"; var brackets = __webpack_require__(858); -var define = __webpack_require__(869); -var utils = __webpack_require__(870); +var define = __webpack_require__(864); +var utils = __webpack_require__(865); /** * Characters to use in text regex (we want to "not" match @@ -102630,7 +101803,7 @@ module.exports = parsers; /***/ }), -/* 869 */ +/* 864 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -102668,7 +101841,7 @@ module.exports = function defineProperty(obj, prop, val) { /***/ }), -/* 870 */ +/* 865 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -102744,7 +101917,7 @@ utils.createRegex = function(str) { /***/ }), -/* 871 */ +/* 866 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -102755,7 +101928,7 @@ utils.createRegex = function(str) { */ var Snapdragon = __webpack_require__(767); -var define = __webpack_require__(869); +var define = __webpack_require__(864); var extend = __webpack_require__(737); /** @@ -102763,7 +101936,7 @@ var extend = __webpack_require__(737); */ var compilers = __webpack_require__(857); -var parsers = __webpack_require__(868); +var parsers = __webpack_require__(863); /** * Customize Snapdragon parser and renderer @@ -102829,7 +102002,7 @@ module.exports = Extglob; /***/ }), -/* 872 */ +/* 867 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -102919,14 +102092,14 @@ function textRegex(pattern) { /***/ }), -/* 873 */ +/* 868 */ /***/ (function(module, exports, __webpack_require__) { module.exports = new (__webpack_require__(849))(); /***/ }), -/* 874 */ +/* 869 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -102944,7 +102117,7 @@ utils.define = __webpack_require__(836); utils.diff = __webpack_require__(853); utils.extend = __webpack_require__(837); utils.pick = __webpack_require__(854); -utils.typeOf = __webpack_require__(875); +utils.typeOf = __webpack_require__(870); utils.unique = __webpack_require__(740); /** @@ -103242,7 +102415,7 @@ utils.unixify = function(options) { /***/ }), -/* 875 */ +/* 870 */ /***/ (function(module, exports) { var toString = Object.prototype.toString; @@ -103377,7 +102550,7 @@ function isBuffer(val) { /***/ }), -/* 876 */ +/* 871 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -103396,9 +102569,9 @@ var __extends = (this && this.__extends) || (function () { }; })(); Object.defineProperty(exports, "__esModule", { value: true }); -var readdir = __webpack_require__(877); -var reader_1 = __webpack_require__(890); -var fs_stream_1 = __webpack_require__(894); +var readdir = __webpack_require__(872); +var reader_1 = __webpack_require__(885); +var fs_stream_1 = __webpack_require__(889); var ReaderAsync = /** @class */ (function (_super) { __extends(ReaderAsync, _super); function ReaderAsync() { @@ -103459,15 +102632,15 @@ exports.default = ReaderAsync; /***/ }), -/* 877 */ +/* 872 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -const readdirSync = __webpack_require__(878); -const readdirAsync = __webpack_require__(886); -const readdirStream = __webpack_require__(889); +const readdirSync = __webpack_require__(873); +const readdirAsync = __webpack_require__(881); +const readdirStream = __webpack_require__(884); module.exports = exports = readdirAsyncPath; exports.readdir = exports.readdirAsync = exports.async = readdirAsyncPath; @@ -103551,7 +102724,7 @@ function readdirStreamStat (dir, options) { /***/ }), -/* 878 */ +/* 873 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -103559,11 +102732,11 @@ function readdirStreamStat (dir, options) { module.exports = readdirSync; -const DirectoryReader = __webpack_require__(879); +const DirectoryReader = __webpack_require__(874); let syncFacade = { - fs: __webpack_require__(884), - forEach: __webpack_require__(885), + fs: __webpack_require__(879), + forEach: __webpack_require__(880), sync: true }; @@ -103592,7 +102765,7 @@ function readdirSync (dir, options, internalOptions) { /***/ }), -/* 879 */ +/* 874 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -103601,9 +102774,9 @@ function readdirSync (dir, options, internalOptions) { const Readable = __webpack_require__(27).Readable; const EventEmitter = __webpack_require__(379).EventEmitter; const path = __webpack_require__(16); -const normalizeOptions = __webpack_require__(880); -const stat = __webpack_require__(882); -const call = __webpack_require__(883); +const normalizeOptions = __webpack_require__(875); +const stat = __webpack_require__(877); +const call = __webpack_require__(878); /** * Asynchronously reads the contents of a directory and streams the results @@ -103979,14 +103152,14 @@ module.exports = DirectoryReader; /***/ }), -/* 880 */ +/* 875 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; const path = __webpack_require__(16); -const globToRegExp = __webpack_require__(881); +const globToRegExp = __webpack_require__(876); module.exports = normalizeOptions; @@ -104163,7 +103336,7 @@ function normalizeOptions (options, internalOptions) { /***/ }), -/* 881 */ +/* 876 */ /***/ (function(module, exports) { module.exports = function (glob, opts) { @@ -104300,13 +103473,13 @@ module.exports = function (glob, opts) { /***/ }), -/* 882 */ +/* 877 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -const call = __webpack_require__(883); +const call = __webpack_require__(878); module.exports = stat; @@ -104381,7 +103554,7 @@ function symlinkStat (fs, path, lstats, callback) { /***/ }), -/* 883 */ +/* 878 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -104442,14 +103615,14 @@ function callOnce (fn) { /***/ }), -/* 884 */ +/* 879 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; const fs = __webpack_require__(23); -const call = __webpack_require__(883); +const call = __webpack_require__(878); /** * A facade around {@link fs.readdirSync} that allows it to be called @@ -104513,7 +103686,7 @@ exports.lstat = function (path, callback) { /***/ }), -/* 885 */ +/* 880 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -104542,7 +103715,7 @@ function syncForEach (array, iterator, done) { /***/ }), -/* 886 */ +/* 881 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -104550,12 +103723,12 @@ function syncForEach (array, iterator, done) { module.exports = readdirAsync; -const maybe = __webpack_require__(887); -const DirectoryReader = __webpack_require__(879); +const maybe = __webpack_require__(882); +const DirectoryReader = __webpack_require__(874); let asyncFacade = { fs: __webpack_require__(23), - forEach: __webpack_require__(888), + forEach: __webpack_require__(883), async: true }; @@ -104597,7 +103770,7 @@ function readdirAsync (dir, options, callback, internalOptions) { /***/ }), -/* 887 */ +/* 882 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -104624,7 +103797,7 @@ module.exports = function maybe (cb, promise) { /***/ }), -/* 888 */ +/* 883 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -104660,7 +103833,7 @@ function asyncForEach (array, iterator, done) { /***/ }), -/* 889 */ +/* 884 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -104668,11 +103841,11 @@ function asyncForEach (array, iterator, done) { module.exports = readdirStream; -const DirectoryReader = __webpack_require__(879); +const DirectoryReader = __webpack_require__(874); let streamFacade = { fs: __webpack_require__(23), - forEach: __webpack_require__(888), + forEach: __webpack_require__(883), async: true }; @@ -104692,16 +103865,16 @@ function readdirStream (dir, options, internalOptions) { /***/ }), -/* 890 */ +/* 885 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var path = __webpack_require__(16); -var deep_1 = __webpack_require__(891); -var entry_1 = __webpack_require__(893); -var pathUtil = __webpack_require__(892); +var deep_1 = __webpack_require__(886); +var entry_1 = __webpack_require__(888); +var pathUtil = __webpack_require__(887); var Reader = /** @class */ (function () { function Reader(options) { this.options = options; @@ -104767,13 +103940,13 @@ exports.default = Reader; /***/ }), -/* 891 */ +/* 886 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -var pathUtils = __webpack_require__(892); +var pathUtils = __webpack_require__(887); var patternUtils = __webpack_require__(721); var DeepFilter = /** @class */ (function () { function DeepFilter(options, micromatchOptions) { @@ -104857,7 +104030,7 @@ exports.default = DeepFilter; /***/ }), -/* 892 */ +/* 887 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -104888,13 +104061,13 @@ exports.makeAbsolute = makeAbsolute; /***/ }), -/* 893 */ +/* 888 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -var pathUtils = __webpack_require__(892); +var pathUtils = __webpack_require__(887); var patternUtils = __webpack_require__(721); var EntryFilter = /** @class */ (function () { function EntryFilter(options, micromatchOptions) { @@ -104980,7 +104153,7 @@ exports.default = EntryFilter; /***/ }), -/* 894 */ +/* 889 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -105000,8 +104173,8 @@ var __extends = (this && this.__extends) || (function () { })(); Object.defineProperty(exports, "__esModule", { value: true }); var stream = __webpack_require__(27); -var fsStat = __webpack_require__(895); -var fs_1 = __webpack_require__(899); +var fsStat = __webpack_require__(890); +var fs_1 = __webpack_require__(894); var FileSystemStream = /** @class */ (function (_super) { __extends(FileSystemStream, _super); function FileSystemStream() { @@ -105051,14 +104224,14 @@ exports.default = FileSystemStream; /***/ }), -/* 895 */ +/* 890 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -const optionsManager = __webpack_require__(896); -const statProvider = __webpack_require__(898); +const optionsManager = __webpack_require__(891); +const statProvider = __webpack_require__(893); /** * Asynchronous API. */ @@ -105089,13 +104262,13 @@ exports.statSync = statSync; /***/ }), -/* 896 */ +/* 891 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -const fsAdapter = __webpack_require__(897); +const fsAdapter = __webpack_require__(892); function prepare(opts) { const options = Object.assign({ fs: fsAdapter.getFileSystemAdapter(opts ? opts.fs : undefined), @@ -105108,7 +104281,7 @@ exports.prepare = prepare; /***/ }), -/* 897 */ +/* 892 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -105131,7 +104304,7 @@ exports.getFileSystemAdapter = getFileSystemAdapter; /***/ }), -/* 898 */ +/* 893 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -105183,7 +104356,7 @@ exports.isFollowedSymlink = isFollowedSymlink; /***/ }), -/* 899 */ +/* 894 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -105214,7 +104387,7 @@ exports.default = FileSystem; /***/ }), -/* 900 */ +/* 895 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -105234,9 +104407,9 @@ var __extends = (this && this.__extends) || (function () { })(); Object.defineProperty(exports, "__esModule", { value: true }); var stream = __webpack_require__(27); -var readdir = __webpack_require__(877); -var reader_1 = __webpack_require__(890); -var fs_stream_1 = __webpack_require__(894); +var readdir = __webpack_require__(872); +var reader_1 = __webpack_require__(885); +var fs_stream_1 = __webpack_require__(889); var TransformStream = /** @class */ (function (_super) { __extends(TransformStream, _super); function TransformStream(reader) { @@ -105304,7 +104477,7 @@ exports.default = ReaderStream; /***/ }), -/* 901 */ +/* 896 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -105323,9 +104496,9 @@ var __extends = (this && this.__extends) || (function () { }; })(); Object.defineProperty(exports, "__esModule", { value: true }); -var readdir = __webpack_require__(877); -var reader_1 = __webpack_require__(890); -var fs_sync_1 = __webpack_require__(902); +var readdir = __webpack_require__(872); +var reader_1 = __webpack_require__(885); +var fs_sync_1 = __webpack_require__(897); var ReaderSync = /** @class */ (function (_super) { __extends(ReaderSync, _super); function ReaderSync() { @@ -105385,7 +104558,7 @@ exports.default = ReaderSync; /***/ }), -/* 902 */ +/* 897 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -105404,8 +104577,8 @@ var __extends = (this && this.__extends) || (function () { }; })(); Object.defineProperty(exports, "__esModule", { value: true }); -var fsStat = __webpack_require__(895); -var fs_1 = __webpack_require__(899); +var fsStat = __webpack_require__(890); +var fs_1 = __webpack_require__(894); var FileSystemSync = /** @class */ (function (_super) { __extends(FileSystemSync, _super); function FileSystemSync() { @@ -105451,7 +104624,7 @@ exports.default = FileSystemSync; /***/ }), -/* 903 */ +/* 898 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -105467,7 +104640,7 @@ exports.flatten = flatten; /***/ }), -/* 904 */ +/* 899 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -105488,13 +104661,13 @@ exports.merge = merge; /***/ }), -/* 905 */ +/* 900 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; const path = __webpack_require__(16); -const pathType = __webpack_require__(906); +const pathType = __webpack_require__(901); const getExtensions = extensions => extensions.length > 1 ? `{${extensions.join(',')}}` : extensions[0]; @@ -105560,13 +104733,13 @@ module.exports.sync = (input, opts) => { /***/ }), -/* 906 */ +/* 901 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; const fs = __webpack_require__(23); -const pify = __webpack_require__(907); +const pify = __webpack_require__(902); function type(fn, fn2, fp) { if (typeof fp !== 'string') { @@ -105609,7 +104782,7 @@ exports.symlinkSync = typeSync.bind(null, 'lstatSync', 'isSymbolicLink'); /***/ }), -/* 907 */ +/* 902 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -105700,7 +104873,7 @@ module.exports = (obj, opts) => { /***/ }), -/* 908 */ +/* 903 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -105708,9 +104881,9 @@ module.exports = (obj, opts) => { const fs = __webpack_require__(23); const path = __webpack_require__(16); const fastGlob = __webpack_require__(717); -const gitIgnore = __webpack_require__(909); -const pify = __webpack_require__(910); -const slash = __webpack_require__(911); +const gitIgnore = __webpack_require__(904); +const pify = __webpack_require__(905); +const slash = __webpack_require__(906); const DEFAULT_IGNORE = [ '**/node_modules/**', @@ -105808,7 +104981,7 @@ module.exports.sync = options => { /***/ }), -/* 909 */ +/* 904 */ /***/ (function(module, exports) { // A simple implementation of make-array @@ -106277,7 +105450,7 @@ module.exports = options => new IgnoreBase(options) /***/ }), -/* 910 */ +/* 905 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -106352,7 +105525,7 @@ module.exports = (input, options) => { /***/ }), -/* 911 */ +/* 906 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -106370,17 +105543,17 @@ module.exports = input => { /***/ }), -/* 912 */ +/* 907 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; const path = __webpack_require__(16); const {constants: fsConstants} = __webpack_require__(23); -const pEvent = __webpack_require__(913); -const CpFileError = __webpack_require__(916); -const fs = __webpack_require__(920); -const ProgressEmitter = __webpack_require__(923); +const pEvent = __webpack_require__(908); +const CpFileError = __webpack_require__(911); +const fs = __webpack_require__(915); +const ProgressEmitter = __webpack_require__(918); const cpFileAsync = async (source, destination, options, progressEmitter) => { let readError; @@ -106494,12 +105667,12 @@ module.exports.sync = (source, destination, options) => { /***/ }), -/* 913 */ +/* 908 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -const pTimeout = __webpack_require__(914); +const pTimeout = __webpack_require__(909); const symbolAsyncIterator = Symbol.asyncIterator || '@@asyncIterator'; @@ -106790,12 +105963,12 @@ module.exports.iterator = (emitter, event, options) => { /***/ }), -/* 914 */ +/* 909 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -const pFinally = __webpack_require__(915); +const pFinally = __webpack_require__(910); class TimeoutError extends Error { constructor(message) { @@ -106841,7 +106014,7 @@ module.exports.TimeoutError = TimeoutError; /***/ }), -/* 915 */ +/* 910 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -106863,12 +106036,12 @@ module.exports = (promise, onFinally) => { /***/ }), -/* 916 */ +/* 911 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -const NestedError = __webpack_require__(917); +const NestedError = __webpack_require__(912); class CpFileError extends NestedError { constructor(message, nested) { @@ -106882,10 +106055,10 @@ module.exports = CpFileError; /***/ }), -/* 917 */ +/* 912 */ /***/ (function(module, exports, __webpack_require__) { -var inherits = __webpack_require__(918); +var inherits = __webpack_require__(913); var NestedError = function (message, nested) { this.nested = nested; @@ -106936,7 +106109,7 @@ module.exports = NestedError; /***/ }), -/* 918 */ +/* 913 */ /***/ (function(module, exports, __webpack_require__) { try { @@ -106944,12 +106117,12 @@ try { if (typeof util.inherits !== 'function') throw ''; module.exports = util.inherits; } catch (e) { - module.exports = __webpack_require__(919); + module.exports = __webpack_require__(914); } /***/ }), -/* 919 */ +/* 914 */ /***/ (function(module, exports) { if (typeof Object.create === 'function') { @@ -106978,16 +106151,16 @@ if (typeof Object.create === 'function') { /***/ }), -/* 920 */ +/* 915 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; const {promisify} = __webpack_require__(29); const fs = __webpack_require__(22); -const makeDir = __webpack_require__(921); -const pEvent = __webpack_require__(913); -const CpFileError = __webpack_require__(916); +const makeDir = __webpack_require__(916); +const pEvent = __webpack_require__(908); +const CpFileError = __webpack_require__(911); const stat = promisify(fs.stat); const lstat = promisify(fs.lstat); @@ -107084,7 +106257,7 @@ exports.copyFileSync = (source, destination, flags) => { /***/ }), -/* 921 */ +/* 916 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -107092,7 +106265,7 @@ exports.copyFileSync = (source, destination, flags) => { const fs = __webpack_require__(23); const path = __webpack_require__(16); const {promisify} = __webpack_require__(29); -const semver = __webpack_require__(922); +const semver = __webpack_require__(917); const defaults = { mode: 0o777 & (~process.umask()), @@ -107241,7 +106414,7 @@ module.exports.sync = (input, options) => { /***/ }), -/* 922 */ +/* 917 */ /***/ (function(module, exports) { exports = module.exports = SemVer @@ -108843,7 +108016,7 @@ function coerce (version, options) { /***/ }), -/* 923 */ +/* 918 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -108884,7 +108057,7 @@ module.exports = ProgressEmitter; /***/ }), -/* 924 */ +/* 919 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -108930,12 +108103,12 @@ exports.default = module.exports; /***/ }), -/* 925 */ +/* 920 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -const NestedError = __webpack_require__(926); +const NestedError = __webpack_require__(921); class CpyError extends NestedError { constructor(message, nested) { @@ -108949,7 +108122,7 @@ module.exports = CpyError; /***/ }), -/* 926 */ +/* 921 */ /***/ (function(module, exports, __webpack_require__) { var inherits = __webpack_require__(29).inherits; @@ -109005,7 +108178,7 @@ module.exports = NestedError; /***/ }), -/* 927 */ +/* 922 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; From 4b4c5bca2de87c1392d24b9f40458710afecbd0d Mon Sep 17 00:00:00 2001 From: MadameSheema Date: Thu, 26 Mar 2020 09:19:10 +0100 Subject: [PATCH 25/35] increases timeouts (#61229) Co-authored-by: Elastic Machine --- x-pack/legacy/plugins/siem/cypress.json | 2 +- x-pack/legacy/plugins/siem/cypress/tasks/login.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/x-pack/legacy/plugins/siem/cypress.json b/x-pack/legacy/plugins/siem/cypress.json index d2397e1ec90d..cc41b72714ed 100644 --- a/x-pack/legacy/plugins/siem/cypress.json +++ b/x-pack/legacy/plugins/siem/cypress.json @@ -1,6 +1,6 @@ { "baseUrl": "http://localhost:5601", - "defaultCommandTimeout": 30000, + "defaultCommandTimeout": 60000, "screenshotsFolder": "../../../../target/kibana-siem/cypress/screenshots", "trashAssetsBeforeRuns": false, "video": false, diff --git a/x-pack/legacy/plugins/siem/cypress/tasks/login.ts b/x-pack/legacy/plugins/siem/cypress/tasks/login.ts index 3abf5a693048..c7788b080d06 100644 --- a/x-pack/legacy/plugins/siem/cypress/tasks/login.ts +++ b/x-pack/legacy/plugins/siem/cypress/tasks/login.ts @@ -131,5 +131,5 @@ export const loginAndWaitForPageWithoutDateRange = (url: string) => { login(); cy.viewport('macbook-15'); cy.visit(url); - cy.contains('a', 'SIEM', { timeout: 60000 }); + cy.contains('a', 'SIEM', { timeout: 120000 }); }; From 535b933b6687a71e7e6c94b8045c95fc5de313fb Mon Sep 17 00:00:00 2001 From: Jean-Louis Leysens Date: Thu, 26 Mar 2020 10:13:09 +0100 Subject: [PATCH 26/35] [Console] Clean up after initial 7.7.0 spec definitions update (#61227) * Move JSON files in console_extensions to mirror console struct. Also update the spec-to-console package README.md with the new instructions. * Re-add flat settings completion in indices.put_template * Re-add template completion suggestions for indices.get_template Co-authored-by: Elastic Machine --- packages/kbn-spec-to-console/README.md | 2 +- .../lib/spec_definitions/json/.eslintrc | 27 ------------------- .../json/generated/indices.put_template.json | 3 ++- .../json/overrides/indices.get_template.json | 8 ++++++ .../server/lib/spec_definitions/js/index.ts | 7 +++++ .../spec_definitions/js/ingest.ts} | 0 .../json}/generated/async_search.delete.json | 0 .../json}/generated/async_search.get.json | 0 .../json}/generated/async_search.submit.json | 0 .../autoscaling.get_autoscaling_decision.json | 0 .../cat.ml_data_frame_analytics.json | 0 .../json}/generated/cat.ml_datafeeds.json | 0 .../json}/generated/cat.ml_jobs.json | 0 .../generated/cat.ml_trained_models.json | 0 .../ccr.delete_auto_follow_pattern.json | 0 .../json}/generated/ccr.follow.json | 0 .../json}/generated/ccr.follow_info.json | 0 .../json}/generated/ccr.follow_stats.json | 0 .../json}/generated/ccr.forget_follower.json | 0 .../ccr.get_auto_follow_pattern.json | 0 .../ccr.pause_auto_follow_pattern.json | 0 .../json}/generated/ccr.pause_follow.json | 0 .../ccr.put_auto_follow_pattern.json | 0 .../ccr.resume_auto_follow_pattern.json | 0 .../json}/generated/ccr.resume_follow.json | 0 .../json}/generated/ccr.stats.json | 0 .../json}/generated/ccr.unfollow.json | 0 .../json}/generated/enrich.delete_policy.json | 0 .../generated/enrich.execute_policy.json | 0 .../json}/generated/enrich.get_policy.json | 0 .../json}/generated/enrich.put_policy.json | 0 .../json}/generated/enrich.stats.json | 0 .../json}/generated/graph.explore.json | 0 .../json}/generated/ilm.delete_lifecycle.json | 0 .../generated/ilm.explain_lifecycle.json | 0 .../json}/generated/ilm.get_lifecycle.json | 0 .../json}/generated/ilm.get_status.json | 0 .../json}/generated/ilm.move_to_step.json | 0 .../json}/generated/ilm.put_lifecycle.json | 0 .../json}/generated/ilm.remove_policy.json | 0 .../json}/generated/ilm.retry.json | 0 .../json}/generated/ilm.set_policy.json | 0 .../json}/generated/ilm.start.json | 0 .../json}/generated/ilm.stop.json | 0 .../json}/generated/indices.freeze.json | 0 .../indices.reload_search_analyzers.json | 0 .../json}/generated/indices.unfreeze.json | 0 .../json}/generated/license.delete.json | 0 .../json}/generated/license.get.json | 0 .../generated/license.get_basic_status.json | 0 .../generated/license.get_trial_status.json | 0 .../json}/generated/license.post.json | 0 .../generated/license.post_start_basic.json | 0 .../generated/license.post_start_trial.json | 0 .../generated/migration.deprecations.json | 0 .../generated/migration.get_assistance.json | 0 .../json}/generated/migration.upgrade.json | 0 .../json}/generated/ml.close_job.json | 0 .../json}/generated/ml.delete_calendar.json | 0 .../generated/ml.delete_calendar_event.json | 0 .../generated/ml.delete_calendar_job.json | 0 .../ml.delete_data_frame_analytics.json | 0 .../json}/generated/ml.delete_datafeed.json | 0 .../generated/ml.delete_expired_data.json | 0 .../json}/generated/ml.delete_filter.json | 0 .../json}/generated/ml.delete_forecast.json | 0 .../json}/generated/ml.delete_job.json | 0 .../generated/ml.delete_model_snapshot.json | 0 .../generated/ml.delete_trained_model.json | 0 .../generated/ml.evaluate_data_frame.json | 0 .../ml.explain_data_frame_analytics.json | 0 .../generated/ml.find_file_structure.json | 0 .../json}/generated/ml.flush_job.json | 0 .../json}/generated/ml.forecast.json | 0 .../json}/generated/ml.get_buckets.json | 0 .../generated/ml.get_calendar_events.json | 0 .../json}/generated/ml.get_calendars.json | 0 .../json}/generated/ml.get_categories.json | 0 .../ml.get_data_frame_analytics.json | 0 .../ml.get_data_frame_analytics_stats.json | 0 .../generated/ml.get_datafeed_stats.json | 0 .../json}/generated/ml.get_datafeeds.json | 0 .../json}/generated/ml.get_filters.json | 0 .../json}/generated/ml.get_influencers.json | 0 .../json}/generated/ml.get_job_stats.json | 0 .../json}/generated/ml.get_jobs.json | 0 .../generated/ml.get_model_snapshots.json | 0 .../generated/ml.get_overall_buckets.json | 0 .../json}/generated/ml.get_records.json | 0 .../generated/ml.get_trained_models.json | 0 .../ml.get_trained_models_stats.json | 0 .../json}/generated/ml.info.json | 0 .../json}/generated/ml.open_job.json | 0 .../generated/ml.post_calendar_events.json | 0 .../json}/generated/ml.post_data.json | 0 .../json}/generated/ml.preview_datafeed.json | 0 .../json}/generated/ml.put_calendar.json | 0 .../json}/generated/ml.put_calendar_job.json | 0 .../ml.put_data_frame_analytics.json | 0 .../json}/generated/ml.put_datafeed.json | 0 .../json}/generated/ml.put_filter.json | 0 .../json}/generated/ml.put_job.json | 0 .../json}/generated/ml.put_trained_model.json | 0 .../generated/ml.revert_model_snapshot.json | 0 .../json}/generated/ml.set_upgrade_mode.json | 0 .../ml.start_data_frame_analytics.json | 0 .../json}/generated/ml.start_datafeed.json | 0 .../ml.stop_data_frame_analytics.json | 0 .../json}/generated/ml.stop_datafeed.json | 0 .../json}/generated/ml.update_datafeed.json | 0 .../json}/generated/ml.update_filter.json | 0 .../json}/generated/ml.update_job.json | 0 .../generated/ml.update_model_snapshot.json | 0 .../json}/generated/ml.upgrade.json | 0 .../json}/generated/ml.validate.json | 0 .../json}/generated/ml.validate_detector.json | 0 .../json}/generated/monitoring.bulk.json | 0 .../json}/generated/rollup.delete_job.json | 0 .../json}/generated/rollup.get_jobs.json | 0 .../generated/rollup.get_rollup_caps.json | 0 .../rollup.get_rollup_index_caps.json | 0 .../json}/generated/rollup.put_job.json | 0 .../json}/generated/rollup.rollup_search.json | 0 .../json}/generated/rollup.start_job.json | 0 .../json}/generated/rollup.stop_job.json | 0 .../generated/security.authenticate.json | 0 .../generated/security.change_password.json | 0 .../security.clear_cached_realms.json | 0 .../security.clear_cached_roles.json | 0 .../generated/security.create_api_key.json | 0 .../generated/security.delete_privileges.json | 0 .../json}/generated/security.delete_role.json | 0 .../security.delete_role_mapping.json | 0 .../json}/generated/security.delete_user.json | 0 .../generated/security.disable_user.json | 0 .../json}/generated/security.enable_user.json | 0 .../json}/generated/security.get_api_key.json | 0 .../security.get_builtin_privileges.json | 0 .../generated/security.get_privileges.json | 0 .../json}/generated/security.get_role.json | 0 .../generated/security.get_role_mapping.json | 0 .../json}/generated/security.get_token.json | 0 .../json}/generated/security.get_user.json | 0 .../security.get_user_privileges.json | 0 .../generated/security.has_privileges.json | 0 .../security.invalidate_api_key.json | 0 .../generated/security.invalidate_token.json | 0 .../generated/security.put_privileges.json | 0 .../json}/generated/security.put_role.json | 0 .../generated/security.put_role_mapping.json | 0 .../json}/generated/security.put_user.json | 0 .../json}/generated/slm.delete_lifecycle.json | 0 .../generated/slm.execute_lifecycle.json | 0 .../generated/slm.execute_retention.json | 0 .../json}/generated/slm.get_lifecycle.json | 0 .../json}/generated/slm.get_stats.json | 0 .../json}/generated/slm.get_status.json | 0 .../json}/generated/slm.put_lifecycle.json | 0 .../json}/generated/slm.start.json | 0 .../json}/generated/slm.stop.json | 0 .../json}/generated/sql.clear_cursor.json | 0 .../json}/generated/sql.query.json | 0 .../json}/generated/sql.translate.json | 0 .../json}/generated/ssl.certificates.json | 0 .../generated/transform.cat_transform.json | 0 .../generated/transform.delete_transform.json | 0 .../generated/transform.get_transform.json | 0 .../transform.get_transform_stats.json | 0 .../transform.preview_transform.json | 0 .../generated/transform.put_transform.json | 0 .../generated/transform.start_transform.json | 0 .../generated/transform.stop_transform.json | 0 .../generated/transform.update_transform.json | 0 .../json}/generated/watcher.ack_watch.json | 0 .../generated/watcher.activate_watch.json | 0 .../generated/watcher.deactivate_watch.json | 0 .../json}/generated/watcher.delete_watch.json | 0 .../generated/watcher.execute_watch.json | 0 .../json}/generated/watcher.get_watch.json | 0 .../json}/generated/watcher.put_watch.json | 0 .../json}/generated/watcher.start.json | 0 .../json}/generated/watcher.stats.json | 0 .../json}/generated/watcher.stop.json | 0 .../json}/generated/xpack.info.json | 0 .../generated/xpack.ssl.certificates.json | 0 .../json}/generated/xpack.usage.json | 0 .../json}/overrides/async_search.submit.json | 0 .../json}/overrides/ccr.follow.json | 0 .../json}/overrides/ccr.forget_follower.json | 0 .../ccr.put_auto_follow_pattern.json | 0 .../json}/overrides/ccr.resume_follow.json | 0 .../json}/overrides/enrich.put_policy.json | 0 .../json}/overrides/ilm.move_to_step.json | 0 .../json}/overrides/ilm.put_lifecycle.json | 0 .../overrides/ml.evaluate_data_frame.json | 0 .../ml.explain_data_frame_analytics.json | 0 .../json}/overrides/ml.get_buckets.json | 0 .../overrides/ml.get_calendar_events.json | 0 .../json}/overrides/ml.get_calendars.json | 0 .../json}/overrides/ml.get_categories.json | 0 .../json}/overrides/ml.get_influencers.json | 0 .../overrides/ml.get_model_snapshots.json | 0 .../overrides/ml.get_overall_buckets.json | 0 .../json}/overrides/ml.get_records.json | 0 .../overrides/ml.post_calendar_events.json | 0 .../json}/overrides/ml.put_calendar.json | 0 .../ml.put_data_frame_analytics.json | 0 .../json}/overrides/ml.put_datafeed.json | 0 .../json}/overrides/ml.put_job.json | 0 .../json}/overrides/ml.put_trained_model.json | 0 .../overrides/ml.revert_model_snapshot.json | 0 .../json}/overrides/ml.update_datafeed.json | 0 .../json}/overrides/ml.update_job.json | 0 .../overrides/ml.update_model_snapshot.json | 0 .../overrides/security.authenticate.json | 0 .../overrides/security.change_password.json | 0 .../overrides/security.create_api_key.json | 0 .../json}/overrides/security.get_token.json | 0 .../overrides/security.has_privileges.json | 0 .../security.invalidate_api_key.json | 0 .../overrides/security.invalidate_token.json | 0 .../json}/overrides/security.put_role.json | 0 .../overrides/security.put_role_mapping.json | 0 .../json}/overrides/security.put_user.json | 0 .../json}/overrides/slm.put_lifecycle.json | 0 .../json}/overrides/slm.start.json | 0 .../json}/overrides/slm.stop.json | 0 .../json}/overrides/sql.query.json | 0 .../transform.get_transform_stats.json | 0 .../transform.preview_transform.json | 0 .../overrides/transform.put_transform.json | 0 .../overrides/transform.stop_transform.json | 0 .../overrides/transform.update_transform.json | 0 .../json}/overrides/xpack.graph.explore.json | 0 .../json}/overrides/xpack.info.json | 0 .../json}/overrides/xpack.license.post.json | 0 .../overrides/xpack.rollup.delete_job.json | 0 .../json}/overrides/xpack.rollup.put_job.json | 0 .../overrides/xpack.rollup.rollup_search.json | 0 .../xpack.security.authenticate.json | 0 .../xpack.security.change_password.json | 0 .../overrides/xpack.security.get_token.json | 0 .../xpack.security.invalidate_token.json | 0 .../overrides/xpack.security.put_role.json | 0 .../xpack.security.put_role_mapping.json | 0 .../overrides/xpack.security.put_user.json | 0 .../xpack.watcher.execute_watch.json | 0 .../overrides/xpack.watcher.put_watch.json | 0 .../console_extensions/server/plugin.ts | 4 +-- 249 files changed, 20 insertions(+), 31 deletions(-) delete mode 100644 src/plugins/console/server/lib/spec_definitions/json/.eslintrc create mode 100644 src/plugins/console/server/lib/spec_definitions/json/overrides/indices.get_template.json create mode 100644 x-pack/plugins/console_extensions/server/lib/spec_definitions/js/index.ts rename x-pack/plugins/console_extensions/server/{spec/ingest/index.ts => lib/spec_definitions/js/ingest.ts} (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/async_search.delete.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/async_search.get.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/async_search.submit.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/autoscaling.get_autoscaling_decision.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/cat.ml_data_frame_analytics.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/cat.ml_datafeeds.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/cat.ml_jobs.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/cat.ml_trained_models.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/ccr.delete_auto_follow_pattern.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/ccr.follow.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/ccr.follow_info.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/ccr.follow_stats.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/ccr.forget_follower.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/ccr.get_auto_follow_pattern.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/ccr.pause_auto_follow_pattern.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/ccr.pause_follow.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/ccr.put_auto_follow_pattern.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/ccr.resume_auto_follow_pattern.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/ccr.resume_follow.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/ccr.stats.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/ccr.unfollow.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/enrich.delete_policy.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/enrich.execute_policy.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/enrich.get_policy.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/enrich.put_policy.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/enrich.stats.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/graph.explore.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/ilm.delete_lifecycle.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/ilm.explain_lifecycle.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/ilm.get_lifecycle.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/ilm.get_status.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/ilm.move_to_step.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/ilm.put_lifecycle.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/ilm.remove_policy.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/ilm.retry.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/ilm.set_policy.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/ilm.start.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/ilm.stop.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/indices.freeze.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/indices.reload_search_analyzers.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/indices.unfreeze.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/license.delete.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/license.get.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/license.get_basic_status.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/license.get_trial_status.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/license.post.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/license.post_start_basic.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/license.post_start_trial.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/migration.deprecations.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/migration.get_assistance.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/migration.upgrade.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/ml.close_job.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/ml.delete_calendar.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/ml.delete_calendar_event.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/ml.delete_calendar_job.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/ml.delete_data_frame_analytics.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/ml.delete_datafeed.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/ml.delete_expired_data.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/ml.delete_filter.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/ml.delete_forecast.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/ml.delete_job.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/ml.delete_model_snapshot.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/ml.delete_trained_model.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/ml.evaluate_data_frame.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/ml.explain_data_frame_analytics.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/ml.find_file_structure.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/ml.flush_job.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/ml.forecast.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/ml.get_buckets.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/ml.get_calendar_events.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/ml.get_calendars.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/ml.get_categories.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/ml.get_data_frame_analytics.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/ml.get_data_frame_analytics_stats.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/ml.get_datafeed_stats.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/ml.get_datafeeds.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/ml.get_filters.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/ml.get_influencers.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/ml.get_job_stats.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/ml.get_jobs.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/ml.get_model_snapshots.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/ml.get_overall_buckets.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/ml.get_records.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/ml.get_trained_models.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/ml.get_trained_models_stats.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/ml.info.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/ml.open_job.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/ml.post_calendar_events.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/ml.post_data.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/ml.preview_datafeed.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/ml.put_calendar.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/ml.put_calendar_job.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/ml.put_data_frame_analytics.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/ml.put_datafeed.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/ml.put_filter.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/ml.put_job.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/ml.put_trained_model.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/ml.revert_model_snapshot.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/ml.set_upgrade_mode.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/ml.start_data_frame_analytics.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/ml.start_datafeed.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/ml.stop_data_frame_analytics.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/ml.stop_datafeed.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/ml.update_datafeed.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/ml.update_filter.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/ml.update_job.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/ml.update_model_snapshot.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/ml.upgrade.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/ml.validate.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/ml.validate_detector.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/monitoring.bulk.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/rollup.delete_job.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/rollup.get_jobs.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/rollup.get_rollup_caps.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/rollup.get_rollup_index_caps.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/rollup.put_job.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/rollup.rollup_search.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/rollup.start_job.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/rollup.stop_job.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/security.authenticate.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/security.change_password.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/security.clear_cached_realms.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/security.clear_cached_roles.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/security.create_api_key.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/security.delete_privileges.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/security.delete_role.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/security.delete_role_mapping.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/security.delete_user.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/security.disable_user.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/security.enable_user.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/security.get_api_key.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/security.get_builtin_privileges.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/security.get_privileges.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/security.get_role.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/security.get_role_mapping.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/security.get_token.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/security.get_user.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/security.get_user_privileges.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/security.has_privileges.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/security.invalidate_api_key.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/security.invalidate_token.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/security.put_privileges.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/security.put_role.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/security.put_role_mapping.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/security.put_user.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/slm.delete_lifecycle.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/slm.execute_lifecycle.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/slm.execute_retention.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/slm.get_lifecycle.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/slm.get_stats.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/slm.get_status.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/slm.put_lifecycle.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/slm.start.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/slm.stop.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/sql.clear_cursor.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/sql.query.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/sql.translate.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/ssl.certificates.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/transform.cat_transform.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/transform.delete_transform.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/transform.get_transform.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/transform.get_transform_stats.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/transform.preview_transform.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/transform.put_transform.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/transform.start_transform.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/transform.stop_transform.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/transform.update_transform.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/watcher.ack_watch.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/watcher.activate_watch.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/watcher.deactivate_watch.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/watcher.delete_watch.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/watcher.execute_watch.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/watcher.get_watch.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/watcher.put_watch.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/watcher.start.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/watcher.stats.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/watcher.stop.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/xpack.info.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/xpack.ssl.certificates.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/generated/xpack.usage.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/overrides/async_search.submit.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/overrides/ccr.follow.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/overrides/ccr.forget_follower.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/overrides/ccr.put_auto_follow_pattern.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/overrides/ccr.resume_follow.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/overrides/enrich.put_policy.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/overrides/ilm.move_to_step.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/overrides/ilm.put_lifecycle.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/overrides/ml.evaluate_data_frame.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/overrides/ml.explain_data_frame_analytics.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/overrides/ml.get_buckets.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/overrides/ml.get_calendar_events.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/overrides/ml.get_calendars.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/overrides/ml.get_categories.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/overrides/ml.get_influencers.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/overrides/ml.get_model_snapshots.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/overrides/ml.get_overall_buckets.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/overrides/ml.get_records.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/overrides/ml.post_calendar_events.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/overrides/ml.put_calendar.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/overrides/ml.put_data_frame_analytics.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/overrides/ml.put_datafeed.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/overrides/ml.put_job.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/overrides/ml.put_trained_model.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/overrides/ml.revert_model_snapshot.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/overrides/ml.update_datafeed.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/overrides/ml.update_job.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/overrides/ml.update_model_snapshot.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/overrides/security.authenticate.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/overrides/security.change_password.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/overrides/security.create_api_key.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/overrides/security.get_token.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/overrides/security.has_privileges.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/overrides/security.invalidate_api_key.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/overrides/security.invalidate_token.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/overrides/security.put_role.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/overrides/security.put_role_mapping.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/overrides/security.put_user.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/overrides/slm.put_lifecycle.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/overrides/slm.start.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/overrides/slm.stop.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/overrides/sql.query.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/overrides/transform.get_transform_stats.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/overrides/transform.preview_transform.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/overrides/transform.put_transform.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/overrides/transform.stop_transform.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/overrides/transform.update_transform.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/overrides/xpack.graph.explore.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/overrides/xpack.info.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/overrides/xpack.license.post.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/overrides/xpack.rollup.delete_job.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/overrides/xpack.rollup.put_job.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/overrides/xpack.rollup.rollup_search.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/overrides/xpack.security.authenticate.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/overrides/xpack.security.change_password.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/overrides/xpack.security.get_token.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/overrides/xpack.security.invalidate_token.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/overrides/xpack.security.put_role.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/overrides/xpack.security.put_role_mapping.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/overrides/xpack.security.put_user.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/overrides/xpack.watcher.execute_watch.json (100%) rename x-pack/plugins/console_extensions/server/{spec => lib/spec_definitions/json}/overrides/xpack.watcher.put_watch.json (100%) diff --git a/packages/kbn-spec-to-console/README.md b/packages/kbn-spec-to-console/README.md index bf60afd88f49..526ceef43e3c 100644 --- a/packages/kbn-spec-to-console/README.md +++ b/packages/kbn-spec-to-console/README.md @@ -26,7 +26,7 @@ At the root of the Kibana repository, run the following commands: yarn spec_to_console -g "/rest-api-spec/src/main/resources/rest-api-spec/api/*" -d "src/plugins/console/server/lib/spec_definitions/json" # X-pack -yarn spec_to_console -g "/x-pack/plugin/src/test/resources/rest-api-spec/api/*" -d "x-pack/plugins/console_extensions/server/spec/generated" +yarn spec_to_console -g "/x-pack/plugin/src/test/resources/rest-api-spec/api/*" -d "x-pack/plugins/console_extensions/server/lib/spec_definitions/json" ``` ### Information used in Console that is not available in the REST spec diff --git a/src/plugins/console/server/lib/spec_definitions/json/.eslintrc b/src/plugins/console/server/lib/spec_definitions/json/.eslintrc deleted file mode 100644 index 10f7444ecaf1..000000000000 --- a/src/plugins/console/server/lib/spec_definitions/json/.eslintrc +++ /dev/null @@ -1,27 +0,0 @@ ---- - -root: true -extends: '../../../../../../../.eslintrc.js' - -rules: - block-scoped-var: off - camelcase: off - dot-location: off - dot-notation: off - eqeqeq: off - guard-for-in: off - new-cap: off - no-caller: off - no-empty: off - no-extend-native: off - no-loop-func: off - no-multi-str: off - no-nested-ternary: off - no-proto: off - no-sequences: off - no-undef: off - no-use-before-define: off - one-var: off - strict: off - no-var: off - prefer-const: off diff --git a/src/plugins/console/server/lib/spec_definitions/json/generated/indices.put_template.json b/src/plugins/console/server/lib/spec_definitions/json/generated/indices.put_template.json index e6317bd6eb53..8fb31277da44 100644 --- a/src/plugins/console/server/lib/spec_definitions/json/generated/indices.put_template.json +++ b/src/plugins/console/server/lib/spec_definitions/json/generated/indices.put_template.json @@ -4,7 +4,8 @@ "include_type_name": "__flag__", "order": "", "create": "__flag__", - "master_timeout": "" + "master_timeout": "", + "flat_settings": "__flag__" }, "methods": [ "PUT", diff --git a/src/plugins/console/server/lib/spec_definitions/json/overrides/indices.get_template.json b/src/plugins/console/server/lib/spec_definitions/json/overrides/indices.get_template.json new file mode 100644 index 000000000000..e0cbcc9cee2e --- /dev/null +++ b/src/plugins/console/server/lib/spec_definitions/json/overrides/indices.get_template.json @@ -0,0 +1,8 @@ +{ + "indices.get_template": { + "patterns": [ + "_template", + "_template/{template}" + ] + } +} diff --git a/x-pack/plugins/console_extensions/server/lib/spec_definitions/js/index.ts b/x-pack/plugins/console_extensions/server/lib/spec_definitions/js/index.ts new file mode 100644 index 000000000000..bc9fbec194d0 --- /dev/null +++ b/x-pack/plugins/console_extensions/server/lib/spec_definitions/js/index.ts @@ -0,0 +1,7 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +export { processors } from './ingest'; diff --git a/x-pack/plugins/console_extensions/server/spec/ingest/index.ts b/x-pack/plugins/console_extensions/server/lib/spec_definitions/js/ingest.ts similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/ingest/index.ts rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/js/ingest.ts diff --git a/x-pack/plugins/console_extensions/server/spec/generated/async_search.delete.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/async_search.delete.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/async_search.delete.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/async_search.delete.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/async_search.get.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/async_search.get.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/async_search.get.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/async_search.get.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/async_search.submit.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/async_search.submit.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/async_search.submit.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/async_search.submit.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/autoscaling.get_autoscaling_decision.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/autoscaling.get_autoscaling_decision.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/autoscaling.get_autoscaling_decision.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/autoscaling.get_autoscaling_decision.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/cat.ml_data_frame_analytics.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/cat.ml_data_frame_analytics.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/cat.ml_data_frame_analytics.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/cat.ml_data_frame_analytics.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/cat.ml_datafeeds.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/cat.ml_datafeeds.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/cat.ml_datafeeds.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/cat.ml_datafeeds.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/cat.ml_jobs.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/cat.ml_jobs.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/cat.ml_jobs.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/cat.ml_jobs.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/cat.ml_trained_models.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/cat.ml_trained_models.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/cat.ml_trained_models.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/cat.ml_trained_models.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/ccr.delete_auto_follow_pattern.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ccr.delete_auto_follow_pattern.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/ccr.delete_auto_follow_pattern.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ccr.delete_auto_follow_pattern.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/ccr.follow.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ccr.follow.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/ccr.follow.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ccr.follow.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/ccr.follow_info.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ccr.follow_info.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/ccr.follow_info.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ccr.follow_info.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/ccr.follow_stats.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ccr.follow_stats.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/ccr.follow_stats.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ccr.follow_stats.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/ccr.forget_follower.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ccr.forget_follower.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/ccr.forget_follower.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ccr.forget_follower.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/ccr.get_auto_follow_pattern.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ccr.get_auto_follow_pattern.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/ccr.get_auto_follow_pattern.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ccr.get_auto_follow_pattern.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/ccr.pause_auto_follow_pattern.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ccr.pause_auto_follow_pattern.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/ccr.pause_auto_follow_pattern.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ccr.pause_auto_follow_pattern.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/ccr.pause_follow.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ccr.pause_follow.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/ccr.pause_follow.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ccr.pause_follow.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/ccr.put_auto_follow_pattern.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ccr.put_auto_follow_pattern.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/ccr.put_auto_follow_pattern.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ccr.put_auto_follow_pattern.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/ccr.resume_auto_follow_pattern.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ccr.resume_auto_follow_pattern.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/ccr.resume_auto_follow_pattern.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ccr.resume_auto_follow_pattern.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/ccr.resume_follow.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ccr.resume_follow.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/ccr.resume_follow.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ccr.resume_follow.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/ccr.stats.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ccr.stats.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/ccr.stats.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ccr.stats.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/ccr.unfollow.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ccr.unfollow.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/ccr.unfollow.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ccr.unfollow.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/enrich.delete_policy.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/enrich.delete_policy.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/enrich.delete_policy.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/enrich.delete_policy.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/enrich.execute_policy.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/enrich.execute_policy.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/enrich.execute_policy.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/enrich.execute_policy.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/enrich.get_policy.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/enrich.get_policy.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/enrich.get_policy.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/enrich.get_policy.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/enrich.put_policy.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/enrich.put_policy.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/enrich.put_policy.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/enrich.put_policy.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/enrich.stats.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/enrich.stats.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/enrich.stats.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/enrich.stats.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/graph.explore.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/graph.explore.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/graph.explore.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/graph.explore.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/ilm.delete_lifecycle.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ilm.delete_lifecycle.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/ilm.delete_lifecycle.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ilm.delete_lifecycle.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/ilm.explain_lifecycle.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ilm.explain_lifecycle.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/ilm.explain_lifecycle.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ilm.explain_lifecycle.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/ilm.get_lifecycle.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ilm.get_lifecycle.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/ilm.get_lifecycle.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ilm.get_lifecycle.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/ilm.get_status.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ilm.get_status.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/ilm.get_status.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ilm.get_status.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/ilm.move_to_step.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ilm.move_to_step.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/ilm.move_to_step.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ilm.move_to_step.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/ilm.put_lifecycle.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ilm.put_lifecycle.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/ilm.put_lifecycle.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ilm.put_lifecycle.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/ilm.remove_policy.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ilm.remove_policy.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/ilm.remove_policy.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ilm.remove_policy.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/ilm.retry.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ilm.retry.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/ilm.retry.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ilm.retry.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/ilm.set_policy.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ilm.set_policy.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/ilm.set_policy.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ilm.set_policy.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/ilm.start.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ilm.start.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/ilm.start.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ilm.start.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/ilm.stop.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ilm.stop.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/ilm.stop.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ilm.stop.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/indices.freeze.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/indices.freeze.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/indices.freeze.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/indices.freeze.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/indices.reload_search_analyzers.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/indices.reload_search_analyzers.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/indices.reload_search_analyzers.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/indices.reload_search_analyzers.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/indices.unfreeze.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/indices.unfreeze.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/indices.unfreeze.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/indices.unfreeze.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/license.delete.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/license.delete.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/license.delete.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/license.delete.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/license.get.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/license.get.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/license.get.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/license.get.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/license.get_basic_status.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/license.get_basic_status.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/license.get_basic_status.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/license.get_basic_status.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/license.get_trial_status.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/license.get_trial_status.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/license.get_trial_status.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/license.get_trial_status.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/license.post.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/license.post.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/license.post.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/license.post.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/license.post_start_basic.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/license.post_start_basic.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/license.post_start_basic.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/license.post_start_basic.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/license.post_start_trial.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/license.post_start_trial.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/license.post_start_trial.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/license.post_start_trial.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/migration.deprecations.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/migration.deprecations.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/migration.deprecations.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/migration.deprecations.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/migration.get_assistance.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/migration.get_assistance.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/migration.get_assistance.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/migration.get_assistance.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/migration.upgrade.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/migration.upgrade.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/migration.upgrade.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/migration.upgrade.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/ml.close_job.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.close_job.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/ml.close_job.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.close_job.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/ml.delete_calendar.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.delete_calendar.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/ml.delete_calendar.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.delete_calendar.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/ml.delete_calendar_event.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.delete_calendar_event.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/ml.delete_calendar_event.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.delete_calendar_event.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/ml.delete_calendar_job.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.delete_calendar_job.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/ml.delete_calendar_job.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.delete_calendar_job.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/ml.delete_data_frame_analytics.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.delete_data_frame_analytics.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/ml.delete_data_frame_analytics.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.delete_data_frame_analytics.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/ml.delete_datafeed.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.delete_datafeed.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/ml.delete_datafeed.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.delete_datafeed.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/ml.delete_expired_data.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.delete_expired_data.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/ml.delete_expired_data.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.delete_expired_data.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/ml.delete_filter.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.delete_filter.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/ml.delete_filter.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.delete_filter.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/ml.delete_forecast.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.delete_forecast.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/ml.delete_forecast.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.delete_forecast.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/ml.delete_job.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.delete_job.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/ml.delete_job.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.delete_job.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/ml.delete_model_snapshot.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.delete_model_snapshot.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/ml.delete_model_snapshot.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.delete_model_snapshot.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/ml.delete_trained_model.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.delete_trained_model.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/ml.delete_trained_model.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.delete_trained_model.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/ml.evaluate_data_frame.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.evaluate_data_frame.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/ml.evaluate_data_frame.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.evaluate_data_frame.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/ml.explain_data_frame_analytics.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.explain_data_frame_analytics.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/ml.explain_data_frame_analytics.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.explain_data_frame_analytics.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/ml.find_file_structure.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.find_file_structure.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/ml.find_file_structure.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.find_file_structure.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/ml.flush_job.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.flush_job.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/ml.flush_job.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.flush_job.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/ml.forecast.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.forecast.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/ml.forecast.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.forecast.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/ml.get_buckets.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.get_buckets.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/ml.get_buckets.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.get_buckets.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/ml.get_calendar_events.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.get_calendar_events.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/ml.get_calendar_events.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.get_calendar_events.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/ml.get_calendars.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.get_calendars.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/ml.get_calendars.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.get_calendars.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/ml.get_categories.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.get_categories.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/ml.get_categories.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.get_categories.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/ml.get_data_frame_analytics.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.get_data_frame_analytics.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/ml.get_data_frame_analytics.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.get_data_frame_analytics.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/ml.get_data_frame_analytics_stats.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.get_data_frame_analytics_stats.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/ml.get_data_frame_analytics_stats.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.get_data_frame_analytics_stats.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/ml.get_datafeed_stats.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.get_datafeed_stats.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/ml.get_datafeed_stats.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.get_datafeed_stats.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/ml.get_datafeeds.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.get_datafeeds.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/ml.get_datafeeds.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.get_datafeeds.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/ml.get_filters.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.get_filters.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/ml.get_filters.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.get_filters.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/ml.get_influencers.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.get_influencers.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/ml.get_influencers.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.get_influencers.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/ml.get_job_stats.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.get_job_stats.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/ml.get_job_stats.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.get_job_stats.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/ml.get_jobs.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.get_jobs.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/ml.get_jobs.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.get_jobs.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/ml.get_model_snapshots.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.get_model_snapshots.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/ml.get_model_snapshots.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.get_model_snapshots.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/ml.get_overall_buckets.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.get_overall_buckets.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/ml.get_overall_buckets.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.get_overall_buckets.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/ml.get_records.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.get_records.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/ml.get_records.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.get_records.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/ml.get_trained_models.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.get_trained_models.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/ml.get_trained_models.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.get_trained_models.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/ml.get_trained_models_stats.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.get_trained_models_stats.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/ml.get_trained_models_stats.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.get_trained_models_stats.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/ml.info.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.info.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/ml.info.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.info.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/ml.open_job.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.open_job.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/ml.open_job.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.open_job.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/ml.post_calendar_events.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.post_calendar_events.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/ml.post_calendar_events.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.post_calendar_events.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/ml.post_data.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.post_data.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/ml.post_data.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.post_data.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/ml.preview_datafeed.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.preview_datafeed.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/ml.preview_datafeed.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.preview_datafeed.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/ml.put_calendar.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.put_calendar.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/ml.put_calendar.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.put_calendar.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/ml.put_calendar_job.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.put_calendar_job.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/ml.put_calendar_job.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.put_calendar_job.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/ml.put_data_frame_analytics.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.put_data_frame_analytics.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/ml.put_data_frame_analytics.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.put_data_frame_analytics.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/ml.put_datafeed.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.put_datafeed.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/ml.put_datafeed.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.put_datafeed.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/ml.put_filter.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.put_filter.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/ml.put_filter.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.put_filter.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/ml.put_job.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.put_job.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/ml.put_job.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.put_job.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/ml.put_trained_model.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.put_trained_model.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/ml.put_trained_model.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.put_trained_model.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/ml.revert_model_snapshot.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.revert_model_snapshot.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/ml.revert_model_snapshot.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.revert_model_snapshot.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/ml.set_upgrade_mode.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.set_upgrade_mode.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/ml.set_upgrade_mode.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.set_upgrade_mode.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/ml.start_data_frame_analytics.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.start_data_frame_analytics.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/ml.start_data_frame_analytics.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.start_data_frame_analytics.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/ml.start_datafeed.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.start_datafeed.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/ml.start_datafeed.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.start_datafeed.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/ml.stop_data_frame_analytics.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.stop_data_frame_analytics.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/ml.stop_data_frame_analytics.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.stop_data_frame_analytics.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/ml.stop_datafeed.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.stop_datafeed.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/ml.stop_datafeed.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.stop_datafeed.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/ml.update_datafeed.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.update_datafeed.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/ml.update_datafeed.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.update_datafeed.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/ml.update_filter.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.update_filter.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/ml.update_filter.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.update_filter.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/ml.update_job.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.update_job.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/ml.update_job.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.update_job.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/ml.update_model_snapshot.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.update_model_snapshot.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/ml.update_model_snapshot.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.update_model_snapshot.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/ml.upgrade.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.upgrade.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/ml.upgrade.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.upgrade.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/ml.validate.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.validate.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/ml.validate.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.validate.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/ml.validate_detector.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.validate_detector.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/ml.validate_detector.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ml.validate_detector.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/monitoring.bulk.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/monitoring.bulk.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/monitoring.bulk.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/monitoring.bulk.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/rollup.delete_job.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/rollup.delete_job.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/rollup.delete_job.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/rollup.delete_job.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/rollup.get_jobs.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/rollup.get_jobs.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/rollup.get_jobs.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/rollup.get_jobs.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/rollup.get_rollup_caps.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/rollup.get_rollup_caps.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/rollup.get_rollup_caps.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/rollup.get_rollup_caps.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/rollup.get_rollup_index_caps.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/rollup.get_rollup_index_caps.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/rollup.get_rollup_index_caps.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/rollup.get_rollup_index_caps.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/rollup.put_job.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/rollup.put_job.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/rollup.put_job.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/rollup.put_job.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/rollup.rollup_search.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/rollup.rollup_search.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/rollup.rollup_search.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/rollup.rollup_search.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/rollup.start_job.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/rollup.start_job.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/rollup.start_job.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/rollup.start_job.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/rollup.stop_job.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/rollup.stop_job.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/rollup.stop_job.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/rollup.stop_job.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/security.authenticate.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/security.authenticate.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/security.authenticate.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/security.authenticate.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/security.change_password.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/security.change_password.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/security.change_password.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/security.change_password.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/security.clear_cached_realms.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/security.clear_cached_realms.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/security.clear_cached_realms.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/security.clear_cached_realms.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/security.clear_cached_roles.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/security.clear_cached_roles.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/security.clear_cached_roles.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/security.clear_cached_roles.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/security.create_api_key.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/security.create_api_key.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/security.create_api_key.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/security.create_api_key.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/security.delete_privileges.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/security.delete_privileges.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/security.delete_privileges.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/security.delete_privileges.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/security.delete_role.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/security.delete_role.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/security.delete_role.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/security.delete_role.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/security.delete_role_mapping.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/security.delete_role_mapping.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/security.delete_role_mapping.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/security.delete_role_mapping.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/security.delete_user.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/security.delete_user.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/security.delete_user.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/security.delete_user.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/security.disable_user.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/security.disable_user.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/security.disable_user.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/security.disable_user.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/security.enable_user.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/security.enable_user.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/security.enable_user.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/security.enable_user.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/security.get_api_key.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/security.get_api_key.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/security.get_api_key.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/security.get_api_key.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/security.get_builtin_privileges.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/security.get_builtin_privileges.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/security.get_builtin_privileges.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/security.get_builtin_privileges.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/security.get_privileges.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/security.get_privileges.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/security.get_privileges.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/security.get_privileges.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/security.get_role.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/security.get_role.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/security.get_role.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/security.get_role.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/security.get_role_mapping.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/security.get_role_mapping.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/security.get_role_mapping.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/security.get_role_mapping.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/security.get_token.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/security.get_token.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/security.get_token.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/security.get_token.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/security.get_user.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/security.get_user.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/security.get_user.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/security.get_user.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/security.get_user_privileges.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/security.get_user_privileges.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/security.get_user_privileges.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/security.get_user_privileges.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/security.has_privileges.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/security.has_privileges.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/security.has_privileges.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/security.has_privileges.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/security.invalidate_api_key.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/security.invalidate_api_key.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/security.invalidate_api_key.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/security.invalidate_api_key.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/security.invalidate_token.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/security.invalidate_token.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/security.invalidate_token.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/security.invalidate_token.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/security.put_privileges.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/security.put_privileges.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/security.put_privileges.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/security.put_privileges.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/security.put_role.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/security.put_role.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/security.put_role.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/security.put_role.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/security.put_role_mapping.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/security.put_role_mapping.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/security.put_role_mapping.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/security.put_role_mapping.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/security.put_user.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/security.put_user.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/security.put_user.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/security.put_user.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/slm.delete_lifecycle.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/slm.delete_lifecycle.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/slm.delete_lifecycle.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/slm.delete_lifecycle.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/slm.execute_lifecycle.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/slm.execute_lifecycle.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/slm.execute_lifecycle.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/slm.execute_lifecycle.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/slm.execute_retention.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/slm.execute_retention.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/slm.execute_retention.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/slm.execute_retention.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/slm.get_lifecycle.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/slm.get_lifecycle.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/slm.get_lifecycle.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/slm.get_lifecycle.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/slm.get_stats.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/slm.get_stats.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/slm.get_stats.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/slm.get_stats.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/slm.get_status.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/slm.get_status.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/slm.get_status.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/slm.get_status.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/slm.put_lifecycle.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/slm.put_lifecycle.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/slm.put_lifecycle.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/slm.put_lifecycle.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/slm.start.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/slm.start.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/slm.start.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/slm.start.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/slm.stop.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/slm.stop.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/slm.stop.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/slm.stop.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/sql.clear_cursor.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/sql.clear_cursor.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/sql.clear_cursor.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/sql.clear_cursor.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/sql.query.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/sql.query.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/sql.query.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/sql.query.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/sql.translate.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/sql.translate.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/sql.translate.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/sql.translate.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/ssl.certificates.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ssl.certificates.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/ssl.certificates.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/ssl.certificates.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/transform.cat_transform.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/transform.cat_transform.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/transform.cat_transform.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/transform.cat_transform.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/transform.delete_transform.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/transform.delete_transform.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/transform.delete_transform.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/transform.delete_transform.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/transform.get_transform.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/transform.get_transform.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/transform.get_transform.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/transform.get_transform.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/transform.get_transform_stats.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/transform.get_transform_stats.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/transform.get_transform_stats.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/transform.get_transform_stats.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/transform.preview_transform.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/transform.preview_transform.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/transform.preview_transform.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/transform.preview_transform.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/transform.put_transform.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/transform.put_transform.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/transform.put_transform.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/transform.put_transform.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/transform.start_transform.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/transform.start_transform.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/transform.start_transform.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/transform.start_transform.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/transform.stop_transform.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/transform.stop_transform.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/transform.stop_transform.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/transform.stop_transform.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/transform.update_transform.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/transform.update_transform.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/transform.update_transform.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/transform.update_transform.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/watcher.ack_watch.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/watcher.ack_watch.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/watcher.ack_watch.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/watcher.ack_watch.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/watcher.activate_watch.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/watcher.activate_watch.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/watcher.activate_watch.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/watcher.activate_watch.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/watcher.deactivate_watch.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/watcher.deactivate_watch.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/watcher.deactivate_watch.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/watcher.deactivate_watch.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/watcher.delete_watch.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/watcher.delete_watch.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/watcher.delete_watch.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/watcher.delete_watch.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/watcher.execute_watch.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/watcher.execute_watch.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/watcher.execute_watch.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/watcher.execute_watch.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/watcher.get_watch.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/watcher.get_watch.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/watcher.get_watch.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/watcher.get_watch.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/watcher.put_watch.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/watcher.put_watch.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/watcher.put_watch.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/watcher.put_watch.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/watcher.start.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/watcher.start.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/watcher.start.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/watcher.start.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/watcher.stats.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/watcher.stats.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/watcher.stats.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/watcher.stats.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/watcher.stop.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/watcher.stop.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/watcher.stop.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/watcher.stop.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/xpack.info.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/xpack.info.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/xpack.info.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/xpack.info.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/xpack.ssl.certificates.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/xpack.ssl.certificates.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/xpack.ssl.certificates.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/xpack.ssl.certificates.json diff --git a/x-pack/plugins/console_extensions/server/spec/generated/xpack.usage.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/xpack.usage.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/generated/xpack.usage.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/generated/xpack.usage.json diff --git a/x-pack/plugins/console_extensions/server/spec/overrides/async_search.submit.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/async_search.submit.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/overrides/async_search.submit.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/async_search.submit.json diff --git a/x-pack/plugins/console_extensions/server/spec/overrides/ccr.follow.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/ccr.follow.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/overrides/ccr.follow.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/ccr.follow.json diff --git a/x-pack/plugins/console_extensions/server/spec/overrides/ccr.forget_follower.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/ccr.forget_follower.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/overrides/ccr.forget_follower.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/ccr.forget_follower.json diff --git a/x-pack/plugins/console_extensions/server/spec/overrides/ccr.put_auto_follow_pattern.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/ccr.put_auto_follow_pattern.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/overrides/ccr.put_auto_follow_pattern.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/ccr.put_auto_follow_pattern.json diff --git a/x-pack/plugins/console_extensions/server/spec/overrides/ccr.resume_follow.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/ccr.resume_follow.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/overrides/ccr.resume_follow.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/ccr.resume_follow.json diff --git a/x-pack/plugins/console_extensions/server/spec/overrides/enrich.put_policy.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/enrich.put_policy.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/overrides/enrich.put_policy.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/enrich.put_policy.json diff --git a/x-pack/plugins/console_extensions/server/spec/overrides/ilm.move_to_step.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/ilm.move_to_step.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/overrides/ilm.move_to_step.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/ilm.move_to_step.json diff --git a/x-pack/plugins/console_extensions/server/spec/overrides/ilm.put_lifecycle.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/ilm.put_lifecycle.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/overrides/ilm.put_lifecycle.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/ilm.put_lifecycle.json diff --git a/x-pack/plugins/console_extensions/server/spec/overrides/ml.evaluate_data_frame.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/ml.evaluate_data_frame.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/overrides/ml.evaluate_data_frame.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/ml.evaluate_data_frame.json diff --git a/x-pack/plugins/console_extensions/server/spec/overrides/ml.explain_data_frame_analytics.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/ml.explain_data_frame_analytics.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/overrides/ml.explain_data_frame_analytics.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/ml.explain_data_frame_analytics.json diff --git a/x-pack/plugins/console_extensions/server/spec/overrides/ml.get_buckets.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/ml.get_buckets.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/overrides/ml.get_buckets.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/ml.get_buckets.json diff --git a/x-pack/plugins/console_extensions/server/spec/overrides/ml.get_calendar_events.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/ml.get_calendar_events.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/overrides/ml.get_calendar_events.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/ml.get_calendar_events.json diff --git a/x-pack/plugins/console_extensions/server/spec/overrides/ml.get_calendars.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/ml.get_calendars.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/overrides/ml.get_calendars.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/ml.get_calendars.json diff --git a/x-pack/plugins/console_extensions/server/spec/overrides/ml.get_categories.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/ml.get_categories.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/overrides/ml.get_categories.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/ml.get_categories.json diff --git a/x-pack/plugins/console_extensions/server/spec/overrides/ml.get_influencers.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/ml.get_influencers.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/overrides/ml.get_influencers.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/ml.get_influencers.json diff --git a/x-pack/plugins/console_extensions/server/spec/overrides/ml.get_model_snapshots.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/ml.get_model_snapshots.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/overrides/ml.get_model_snapshots.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/ml.get_model_snapshots.json diff --git a/x-pack/plugins/console_extensions/server/spec/overrides/ml.get_overall_buckets.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/ml.get_overall_buckets.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/overrides/ml.get_overall_buckets.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/ml.get_overall_buckets.json diff --git a/x-pack/plugins/console_extensions/server/spec/overrides/ml.get_records.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/ml.get_records.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/overrides/ml.get_records.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/ml.get_records.json diff --git a/x-pack/plugins/console_extensions/server/spec/overrides/ml.post_calendar_events.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/ml.post_calendar_events.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/overrides/ml.post_calendar_events.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/ml.post_calendar_events.json diff --git a/x-pack/plugins/console_extensions/server/spec/overrides/ml.put_calendar.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/ml.put_calendar.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/overrides/ml.put_calendar.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/ml.put_calendar.json diff --git a/x-pack/plugins/console_extensions/server/spec/overrides/ml.put_data_frame_analytics.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/ml.put_data_frame_analytics.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/overrides/ml.put_data_frame_analytics.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/ml.put_data_frame_analytics.json diff --git a/x-pack/plugins/console_extensions/server/spec/overrides/ml.put_datafeed.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/ml.put_datafeed.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/overrides/ml.put_datafeed.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/ml.put_datafeed.json diff --git a/x-pack/plugins/console_extensions/server/spec/overrides/ml.put_job.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/ml.put_job.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/overrides/ml.put_job.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/ml.put_job.json diff --git a/x-pack/plugins/console_extensions/server/spec/overrides/ml.put_trained_model.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/ml.put_trained_model.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/overrides/ml.put_trained_model.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/ml.put_trained_model.json diff --git a/x-pack/plugins/console_extensions/server/spec/overrides/ml.revert_model_snapshot.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/ml.revert_model_snapshot.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/overrides/ml.revert_model_snapshot.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/ml.revert_model_snapshot.json diff --git a/x-pack/plugins/console_extensions/server/spec/overrides/ml.update_datafeed.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/ml.update_datafeed.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/overrides/ml.update_datafeed.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/ml.update_datafeed.json diff --git a/x-pack/plugins/console_extensions/server/spec/overrides/ml.update_job.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/ml.update_job.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/overrides/ml.update_job.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/ml.update_job.json diff --git a/x-pack/plugins/console_extensions/server/spec/overrides/ml.update_model_snapshot.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/ml.update_model_snapshot.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/overrides/ml.update_model_snapshot.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/ml.update_model_snapshot.json diff --git a/x-pack/plugins/console_extensions/server/spec/overrides/security.authenticate.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/security.authenticate.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/overrides/security.authenticate.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/security.authenticate.json diff --git a/x-pack/plugins/console_extensions/server/spec/overrides/security.change_password.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/security.change_password.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/overrides/security.change_password.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/security.change_password.json diff --git a/x-pack/plugins/console_extensions/server/spec/overrides/security.create_api_key.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/security.create_api_key.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/overrides/security.create_api_key.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/security.create_api_key.json diff --git a/x-pack/plugins/console_extensions/server/spec/overrides/security.get_token.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/security.get_token.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/overrides/security.get_token.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/security.get_token.json diff --git a/x-pack/plugins/console_extensions/server/spec/overrides/security.has_privileges.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/security.has_privileges.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/overrides/security.has_privileges.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/security.has_privileges.json diff --git a/x-pack/plugins/console_extensions/server/spec/overrides/security.invalidate_api_key.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/security.invalidate_api_key.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/overrides/security.invalidate_api_key.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/security.invalidate_api_key.json diff --git a/x-pack/plugins/console_extensions/server/spec/overrides/security.invalidate_token.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/security.invalidate_token.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/overrides/security.invalidate_token.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/security.invalidate_token.json diff --git a/x-pack/plugins/console_extensions/server/spec/overrides/security.put_role.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/security.put_role.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/overrides/security.put_role.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/security.put_role.json diff --git a/x-pack/plugins/console_extensions/server/spec/overrides/security.put_role_mapping.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/security.put_role_mapping.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/overrides/security.put_role_mapping.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/security.put_role_mapping.json diff --git a/x-pack/plugins/console_extensions/server/spec/overrides/security.put_user.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/security.put_user.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/overrides/security.put_user.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/security.put_user.json diff --git a/x-pack/plugins/console_extensions/server/spec/overrides/slm.put_lifecycle.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/slm.put_lifecycle.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/overrides/slm.put_lifecycle.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/slm.put_lifecycle.json diff --git a/x-pack/plugins/console_extensions/server/spec/overrides/slm.start.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/slm.start.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/overrides/slm.start.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/slm.start.json diff --git a/x-pack/plugins/console_extensions/server/spec/overrides/slm.stop.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/slm.stop.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/overrides/slm.stop.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/slm.stop.json diff --git a/x-pack/plugins/console_extensions/server/spec/overrides/sql.query.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/sql.query.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/overrides/sql.query.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/sql.query.json diff --git a/x-pack/plugins/console_extensions/server/spec/overrides/transform.get_transform_stats.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/transform.get_transform_stats.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/overrides/transform.get_transform_stats.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/transform.get_transform_stats.json diff --git a/x-pack/plugins/console_extensions/server/spec/overrides/transform.preview_transform.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/transform.preview_transform.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/overrides/transform.preview_transform.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/transform.preview_transform.json diff --git a/x-pack/plugins/console_extensions/server/spec/overrides/transform.put_transform.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/transform.put_transform.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/overrides/transform.put_transform.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/transform.put_transform.json diff --git a/x-pack/plugins/console_extensions/server/spec/overrides/transform.stop_transform.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/transform.stop_transform.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/overrides/transform.stop_transform.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/transform.stop_transform.json diff --git a/x-pack/plugins/console_extensions/server/spec/overrides/transform.update_transform.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/transform.update_transform.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/overrides/transform.update_transform.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/transform.update_transform.json diff --git a/x-pack/plugins/console_extensions/server/spec/overrides/xpack.graph.explore.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/xpack.graph.explore.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/overrides/xpack.graph.explore.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/xpack.graph.explore.json diff --git a/x-pack/plugins/console_extensions/server/spec/overrides/xpack.info.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/xpack.info.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/overrides/xpack.info.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/xpack.info.json diff --git a/x-pack/plugins/console_extensions/server/spec/overrides/xpack.license.post.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/xpack.license.post.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/overrides/xpack.license.post.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/xpack.license.post.json diff --git a/x-pack/plugins/console_extensions/server/spec/overrides/xpack.rollup.delete_job.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/xpack.rollup.delete_job.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/overrides/xpack.rollup.delete_job.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/xpack.rollup.delete_job.json diff --git a/x-pack/plugins/console_extensions/server/spec/overrides/xpack.rollup.put_job.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/xpack.rollup.put_job.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/overrides/xpack.rollup.put_job.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/xpack.rollup.put_job.json diff --git a/x-pack/plugins/console_extensions/server/spec/overrides/xpack.rollup.rollup_search.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/xpack.rollup.rollup_search.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/overrides/xpack.rollup.rollup_search.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/xpack.rollup.rollup_search.json diff --git a/x-pack/plugins/console_extensions/server/spec/overrides/xpack.security.authenticate.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/xpack.security.authenticate.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/overrides/xpack.security.authenticate.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/xpack.security.authenticate.json diff --git a/x-pack/plugins/console_extensions/server/spec/overrides/xpack.security.change_password.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/xpack.security.change_password.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/overrides/xpack.security.change_password.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/xpack.security.change_password.json diff --git a/x-pack/plugins/console_extensions/server/spec/overrides/xpack.security.get_token.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/xpack.security.get_token.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/overrides/xpack.security.get_token.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/xpack.security.get_token.json diff --git a/x-pack/plugins/console_extensions/server/spec/overrides/xpack.security.invalidate_token.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/xpack.security.invalidate_token.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/overrides/xpack.security.invalidate_token.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/xpack.security.invalidate_token.json diff --git a/x-pack/plugins/console_extensions/server/spec/overrides/xpack.security.put_role.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/xpack.security.put_role.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/overrides/xpack.security.put_role.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/xpack.security.put_role.json diff --git a/x-pack/plugins/console_extensions/server/spec/overrides/xpack.security.put_role_mapping.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/xpack.security.put_role_mapping.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/overrides/xpack.security.put_role_mapping.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/xpack.security.put_role_mapping.json diff --git a/x-pack/plugins/console_extensions/server/spec/overrides/xpack.security.put_user.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/xpack.security.put_user.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/overrides/xpack.security.put_user.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/xpack.security.put_user.json diff --git a/x-pack/plugins/console_extensions/server/spec/overrides/xpack.watcher.execute_watch.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/xpack.watcher.execute_watch.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/overrides/xpack.watcher.execute_watch.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/xpack.watcher.execute_watch.json diff --git a/x-pack/plugins/console_extensions/server/spec/overrides/xpack.watcher.put_watch.json b/x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/xpack.watcher.put_watch.json similarity index 100% rename from x-pack/plugins/console_extensions/server/spec/overrides/xpack.watcher.put_watch.json rename to x-pack/plugins/console_extensions/server/lib/spec_definitions/json/overrides/xpack.watcher.put_watch.json diff --git a/x-pack/plugins/console_extensions/server/plugin.ts b/x-pack/plugins/console_extensions/server/plugin.ts index 8c2cb4d0db42..2a08c258f4bb 100644 --- a/x-pack/plugins/console_extensions/server/plugin.ts +++ b/x-pack/plugins/console_extensions/server/plugin.ts @@ -8,7 +8,7 @@ import { CoreSetup, CoreStart, Logger, Plugin, PluginInitializerContext } from ' import { ConsoleSetup, ConsoleStart } from '../../../../src/plugins/console/server'; -import { processors } from './spec/ingest/index'; +import { processors } from './lib/spec_definitions/js'; interface SetupDependencies { console: ConsoleSetup; @@ -18,7 +18,7 @@ interface StartDependencies { console: ConsoleStart; } -const CONSOLE_XPACK_JSON_SPEC_PATH = join(__dirname, 'spec/'); +const CONSOLE_XPACK_JSON_SPEC_PATH = join(__dirname, 'lib/spec_definitions/json'); export class ConsoleExtensionsServerPlugin implements Plugin { log: Logger; From 3f80d89eb5b3cf777c2a96213a828d53974c43b7 Mon Sep 17 00:00:00 2001 From: Gidi Meir Morris Date: Thu, 26 Mar 2020 09:29:23 +0000 Subject: [PATCH 27/35] [Alerting] Makes the tooltips in the ES Index Action a little clearer. (#61301) Made the tooltips in the ES Action flyout a little clearer. --- .../components/builtin_action_types/es_index.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/es_index.tsx b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/es_index.tsx index 706d746b9299..8a13c461fb31 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/es_index.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/es_index.tsx @@ -193,7 +193,8 @@ const IndexActionConnectorFields: React.FunctionComponent @@ -224,8 +225,7 @@ const IndexActionConnectorFields: React.FunctionComponent From 9d0d3f7a53a7cf93860ea3c8e67d03be700f595b Mon Sep 17 00:00:00 2001 From: Robert Oskamp Date: Thu, 26 Mar 2020 10:30:05 +0100 Subject: [PATCH 28/35] [ML] Disable mml api integration test --- .../api_integration/apis/ml/calculate_model_memory_limit.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/x-pack/test/api_integration/apis/ml/calculate_model_memory_limit.ts b/x-pack/test/api_integration/apis/ml/calculate_model_memory_limit.ts index 5d1a52e3c2c2..61e1763cc9f7 100644 --- a/x-pack/test/api_integration/apis/ml/calculate_model_memory_limit.ts +++ b/x-pack/test/api_integration/apis/ml/calculate_model_memory_limit.ts @@ -147,7 +147,8 @@ export default ({ getService }: FtrProviderContext) => { }, ]; - describe('calculate model memory limit', function() { + // failing test, see https://github.com/elastic/kibana/issues/61400 + describe.skip('calculate model memory limit', function() { before(async () => { await esArchiver.load('ml/ecommerce'); }); From 468de51153f3a75e822d09c642b4998f5830494d Mon Sep 17 00:00:00 2001 From: Pierre Gayvallet Date: Thu, 26 Mar 2020 10:49:05 +0100 Subject: [PATCH 29/35] Add plugin start contract to getStartServices return value (#61216) * add plugin own contract as third element of getStartServices result * adapt plugins code * update tests * revert unknown to use void again * update generated doc * fix UT * update mock to allow non-object `pluginStartContract` * add @typeParam documentation --- ...n-core-public.coresetup.getstartservices.md | 2 +- .../kibana-plugin-core-public.coresetup.md | 4 ++-- ...ibana-plugin-core-public.legacycoresetup.md | 2 +- .../kibana-plugin-core-public.plugin.setup.md | 4 ++-- ...plugin-core-public.startservicesaccessor.md | 2 +- ...n-core-server.coresetup.getstartservices.md | 2 +- .../kibana-plugin-core-server.coresetup.md | 4 ++-- ...plugin-core-server.startservicesaccessor.md | 2 +- examples/alerting_example/public/plugin.tsx | 9 +++------ examples/bfetch_explorer/public/plugin.tsx | 5 ++++- examples/embeddable_examples/public/index.ts | 13 +++++++++++-- examples/embeddable_examples/public/plugin.ts | 4 ++-- examples/search_explorer/public/plugin.tsx | 2 +- src/core/public/index.ts | 18 ++++++++++++------ src/core/public/legacy/legacy_service.ts | 4 ++-- src/core/public/mocks.ts | 15 ++++++++++++--- src/core/public/plugins/plugin.test.ts | 7 ++++++- src/core/public/plugins/plugin.ts | 8 ++++---- src/core/public/plugins/plugins_service.ts | 2 +- src/core/public/public.api.md | 10 +++++----- src/core/server/index.ts | 15 ++++++++++----- src/core/server/legacy/legacy_service.ts | 2 +- src/core/server/mocks.ts | 12 +++++++++--- .../integration_tests/plugins_service.test.ts | 14 ++++++++++---- src/core/server/plugins/plugin.test.ts | 6 +++++- src/core/server/plugins/plugin.ts | 4 ++-- src/core/server/server.api.md | 6 +++--- .../input_control_vis/public/plugin.ts | 4 ++-- .../kibana/public/discover/plugin.ts | 2 +- .../vis_type_timelion/public/plugin.ts | 2 +- .../vis_type_vislib/public/plugin.ts | 4 ++-- .../core_plugins/vis_type_xy/public/plugin.ts | 4 ++-- src/plugins/home/public/plugin.ts | 4 +++- x-pack/plugins/actions/server/plugin.ts | 2 +- x-pack/plugins/alerting/server/plugin.ts | 2 +- x-pack/plugins/ingest_manager/public/plugin.ts | 7 +++++-- x-pack/plugins/ml/public/index.ts | 15 +++++++++++++-- x-pack/plugins/ml/public/plugin.ts | 2 +- x-pack/plugins/monitoring/server/plugin.ts | 4 ++-- .../account_management_app.test.ts | 2 +- .../logged_out/logged_out_app.test.ts | 2 +- .../authentication/login/login_app.test.ts | 2 +- .../overwritten_session_app.test.ts | 2 +- x-pack/plugins/security/public/index.ts | 17 +++++++++++++---- .../management/spaces_management_app.test.tsx | 2 +- .../capabilities/capabilities_switcher.test.ts | 1 + .../plugins/resolver_test/public/index.ts | 13 +++++++++++-- 47 files changed, 178 insertions(+), 93 deletions(-) diff --git a/docs/development/core/public/kibana-plugin-core-public.coresetup.getstartservices.md b/docs/development/core/public/kibana-plugin-core-public.coresetup.getstartservices.md index e4fec4eae31b..8664ad0e2a0e 100644 --- a/docs/development/core/public/kibana-plugin-core-public.coresetup.getstartservices.md +++ b/docs/development/core/public/kibana-plugin-core-public.coresetup.getstartservices.md @@ -9,5 +9,5 @@ Signature: ```typescript -getStartServices: StartServicesAccessor; +getStartServices: StartServicesAccessor; ``` diff --git a/docs/development/core/public/kibana-plugin-core-public.coresetup.md b/docs/development/core/public/kibana-plugin-core-public.coresetup.md index c039bc19348c..870fa33dce90 100644 --- a/docs/development/core/public/kibana-plugin-core-public.coresetup.md +++ b/docs/development/core/public/kibana-plugin-core-public.coresetup.md @@ -9,7 +9,7 @@ Core services exposed to the `Plugin` setup lifecycle Signature: ```typescript -export interface CoreSetup +export interface CoreSetup ``` ## Properties @@ -19,7 +19,7 @@ export interface CoreSetup | [application](./kibana-plugin-core-public.coresetup.application.md) | ApplicationSetup | [ApplicationSetup](./kibana-plugin-core-public.applicationsetup.md) | | [context](./kibana-plugin-core-public.coresetup.context.md) | ContextSetup | [ContextSetup](./kibana-plugin-core-public.contextsetup.md) | | [fatalErrors](./kibana-plugin-core-public.coresetup.fatalerrors.md) | FatalErrorsSetup | [FatalErrorsSetup](./kibana-plugin-core-public.fatalerrorssetup.md) | -| [getStartServices](./kibana-plugin-core-public.coresetup.getstartservices.md) | StartServicesAccessor<TPluginsStart> | [StartServicesAccessor](./kibana-plugin-core-public.startservicesaccessor.md) | +| [getStartServices](./kibana-plugin-core-public.coresetup.getstartservices.md) | StartServicesAccessor<TPluginsStart, TStart> | [StartServicesAccessor](./kibana-plugin-core-public.startservicesaccessor.md) | | [http](./kibana-plugin-core-public.coresetup.http.md) | HttpSetup | [HttpSetup](./kibana-plugin-core-public.httpsetup.md) | | [injectedMetadata](./kibana-plugin-core-public.coresetup.injectedmetadata.md) | {
getInjectedVar: (name: string, defaultValue?: any) => unknown;
} | exposed temporarily until https://github.com/elastic/kibana/issues/41990 done use \*only\* to retrieve config values. There is no way to set injected values in the new platform. Use the legacy platform API instead. | | [notifications](./kibana-plugin-core-public.coresetup.notifications.md) | NotificationsSetup | [NotificationsSetup](./kibana-plugin-core-public.notificationssetup.md) | diff --git a/docs/development/core/public/kibana-plugin-core-public.legacycoresetup.md b/docs/development/core/public/kibana-plugin-core-public.legacycoresetup.md index 25387ff5ec8c..26220accbfaf 100644 --- a/docs/development/core/public/kibana-plugin-core-public.legacycoresetup.md +++ b/docs/development/core/public/kibana-plugin-core-public.legacycoresetup.md @@ -13,7 +13,7 @@ Setup interface exposed to the legacy platform via the `ui/new_platform` module. Signature: ```typescript -export interface LegacyCoreSetup extends CoreSetup +export interface LegacyCoreSetup extends CoreSetup ``` ## Remarks diff --git a/docs/development/core/public/kibana-plugin-core-public.plugin.setup.md b/docs/development/core/public/kibana-plugin-core-public.plugin.setup.md index 7ed0e056b390..7fa05588a330 100644 --- a/docs/development/core/public/kibana-plugin-core-public.plugin.setup.md +++ b/docs/development/core/public/kibana-plugin-core-public.plugin.setup.md @@ -7,14 +7,14 @@ Signature: ```typescript -setup(core: CoreSetup, plugins: TPluginsSetup): TSetup | Promise; +setup(core: CoreSetup, plugins: TPluginsSetup): TSetup | Promise; ``` ## Parameters | Parameter | Type | Description | | --- | --- | --- | -| core | CoreSetup<TPluginsStart> | | +| core | CoreSetup<TPluginsStart, TStart> | | | plugins | TPluginsSetup | | Returns: diff --git a/docs/development/core/public/kibana-plugin-core-public.startservicesaccessor.md b/docs/development/core/public/kibana-plugin-core-public.startservicesaccessor.md index 02e896a6b47e..ad53307d53d6 100644 --- a/docs/development/core/public/kibana-plugin-core-public.startservicesaccessor.md +++ b/docs/development/core/public/kibana-plugin-core-public.startservicesaccessor.md @@ -9,5 +9,5 @@ Allows plugins to get access to APIs available in start inside async handlers, s Signature: ```typescript -export declare type StartServicesAccessor = () => Promise<[CoreStart, TPluginsStart]>; +export declare type StartServicesAccessor = () => Promise<[CoreStart, TPluginsStart, TStart]>; ``` diff --git a/docs/development/core/server/kibana-plugin-core-server.coresetup.getstartservices.md b/docs/development/core/server/kibana-plugin-core-server.coresetup.getstartservices.md index ea8e610ee56d..1f326449156f 100644 --- a/docs/development/core/server/kibana-plugin-core-server.coresetup.getstartservices.md +++ b/docs/development/core/server/kibana-plugin-core-server.coresetup.getstartservices.md @@ -9,5 +9,5 @@ Signature: ```typescript -getStartServices: StartServicesAccessor; +getStartServices: StartServicesAccessor; ``` diff --git a/docs/development/core/server/kibana-plugin-core-server.coresetup.md b/docs/development/core/server/kibana-plugin-core-server.coresetup.md index b0eba8ac7806..29fdc37a8117 100644 --- a/docs/development/core/server/kibana-plugin-core-server.coresetup.md +++ b/docs/development/core/server/kibana-plugin-core-server.coresetup.md @@ -9,7 +9,7 @@ Context passed to the plugins `setup` method. Signature: ```typescript -export interface CoreSetup +export interface CoreSetup ``` ## Properties @@ -19,7 +19,7 @@ export interface CoreSetup | [capabilities](./kibana-plugin-core-server.coresetup.capabilities.md) | CapabilitiesSetup | [CapabilitiesSetup](./kibana-plugin-core-server.capabilitiessetup.md) | | [context](./kibana-plugin-core-server.coresetup.context.md) | ContextSetup | [ContextSetup](./kibana-plugin-core-server.contextsetup.md) | | [elasticsearch](./kibana-plugin-core-server.coresetup.elasticsearch.md) | ElasticsearchServiceSetup | [ElasticsearchServiceSetup](./kibana-plugin-core-server.elasticsearchservicesetup.md) | -| [getStartServices](./kibana-plugin-core-server.coresetup.getstartservices.md) | StartServicesAccessor<TPluginsStart> | [StartServicesAccessor](./kibana-plugin-core-server.startservicesaccessor.md) | +| [getStartServices](./kibana-plugin-core-server.coresetup.getstartservices.md) | StartServicesAccessor<TPluginsStart, TStart> | [StartServicesAccessor](./kibana-plugin-core-server.startservicesaccessor.md) | | [http](./kibana-plugin-core-server.coresetup.http.md) | HttpServiceSetup | [HttpServiceSetup](./kibana-plugin-core-server.httpservicesetup.md) | | [metrics](./kibana-plugin-core-server.coresetup.metrics.md) | MetricsServiceSetup | [MetricsServiceSetup](./kibana-plugin-core-server.metricsservicesetup.md) | | [savedObjects](./kibana-plugin-core-server.coresetup.savedobjects.md) | SavedObjectsServiceSetup | [SavedObjectsServiceSetup](./kibana-plugin-core-server.savedobjectsservicesetup.md) | diff --git a/docs/development/core/server/kibana-plugin-core-server.startservicesaccessor.md b/docs/development/core/server/kibana-plugin-core-server.startservicesaccessor.md index 4de781fc99cc..7f90060d3ffa 100644 --- a/docs/development/core/server/kibana-plugin-core-server.startservicesaccessor.md +++ b/docs/development/core/server/kibana-plugin-core-server.startservicesaccessor.md @@ -9,5 +9,5 @@ Allows plugins to get access to APIs available in start inside async handlers. P Signature: ```typescript -export declare type StartServicesAccessor = () => Promise<[CoreStart, TPluginsStart]>; +export declare type StartServicesAccessor = () => Promise<[CoreStart, TPluginsStart, TStart]>; ``` diff --git a/examples/alerting_example/public/plugin.tsx b/examples/alerting_example/public/plugin.tsx index 299806d39344..e3748e3235f4 100644 --- a/examples/alerting_example/public/plugin.tsx +++ b/examples/alerting_example/public/plugin.tsx @@ -17,7 +17,7 @@ * under the License. */ -import { Plugin, CoreSetup, AppMountParameters, CoreStart } from 'kibana/public'; +import { Plugin, CoreSetup, AppMountParameters } from 'kibana/public'; import { PluginSetupContract as AlertingSetup } from '../../../x-pack/plugins/alerting/public'; import { ChartsPluginStart } from '../../../src/plugins/charts/public'; import { TriggersAndActionsUIPublicPluginSetup } from '../../../x-pack/plugins/triggers_actions_ui/public'; @@ -43,17 +43,14 @@ export interface AlertingExamplePublicStartDeps { export class AlertingExamplePlugin implements Plugin { public setup( - core: CoreSetup, + core: CoreSetup, { alerting, triggers_actions_ui }: AlertingExamplePublicSetupDeps ) { core.application.register({ id: 'AlertingExample', title: 'Alerting Example', async mount(params: AppMountParameters) { - const [coreStart, depsStart]: [ - CoreStart, - AlertingExamplePublicStartDeps - ] = await core.getStartServices(); + const [coreStart, depsStart] = await core.getStartServices(); const { renderApp } = await import('./application'); return renderApp(coreStart, depsStart, params); }, diff --git a/examples/bfetch_explorer/public/plugin.tsx b/examples/bfetch_explorer/public/plugin.tsx index 3155354c91fd..fc3202f08bf7 100644 --- a/examples/bfetch_explorer/public/plugin.tsx +++ b/examples/bfetch_explorer/public/plugin.tsx @@ -34,7 +34,10 @@ export interface BfetchExplorerStartPlugins { } export class BfetchExplorerPlugin implements Plugin { - public setup(core: CoreSetup, plugins: BfetchExplorerSetupPlugins) { + public setup( + core: CoreSetup, + plugins: BfetchExplorerSetupPlugins + ) { const double = plugins.bfetch.batchedFunction<{ num: number }, { num: number }>({ url: '/bfetch_explorer/double', }); diff --git a/examples/embeddable_examples/public/index.ts b/examples/embeddable_examples/public/index.ts index 1c2c3911d100..5fcd454b17a5 100644 --- a/examples/embeddable_examples/public/index.ts +++ b/examples/embeddable_examples/public/index.ts @@ -26,9 +26,18 @@ export { export { ListContainer, LIST_CONTAINER } from './list_container'; export { TODO_EMBEDDABLE } from './todo'; -import { EmbeddableExamplesPlugin } from './plugin'; +import { + EmbeddableExamplesPlugin, + EmbeddableExamplesSetupDependencies, + EmbeddableExamplesStartDependencies, +} from './plugin'; export { SearchableListContainer, SEARCHABLE_LIST_CONTAINER } from './searchable_list_container'; export { MULTI_TASK_TODO_EMBEDDABLE } from './multi_task_todo'; -export const plugin: PluginInitializer = () => new EmbeddableExamplesPlugin(); +export const plugin: PluginInitializer< + void, + void, + EmbeddableExamplesSetupDependencies, + EmbeddableExamplesStartDependencies +> = () => new EmbeddableExamplesPlugin(); diff --git a/examples/embeddable_examples/public/plugin.ts b/examples/embeddable_examples/public/plugin.ts index 3663af68ae2c..5c202d96ceb1 100644 --- a/examples/embeddable_examples/public/plugin.ts +++ b/examples/embeddable_examples/public/plugin.ts @@ -28,11 +28,11 @@ import { } from './searchable_list_container'; import { LIST_CONTAINER, ListContainerFactory } from './list_container'; -interface EmbeddableExamplesSetupDependencies { +export interface EmbeddableExamplesSetupDependencies { embeddable: EmbeddableSetup; } -interface EmbeddableExamplesStartDependencies { +export interface EmbeddableExamplesStartDependencies { embeddable: EmbeddableStart; } diff --git a/examples/search_explorer/public/plugin.tsx b/examples/search_explorer/public/plugin.tsx index 29b236e82bf4..70b37aa9e626 100644 --- a/examples/search_explorer/public/plugin.tsx +++ b/examples/search_explorer/public/plugin.tsx @@ -21,7 +21,7 @@ import { Plugin, CoreSetup, AppMountParameters } from 'kibana/public'; import { AppPluginStartDependencies } from './types'; export class SearchExplorerPlugin implements Plugin { - public setup(core: CoreSetup) { + public setup(core: CoreSetup) { core.application.register({ id: 'searchExplorer', title: 'Search Explorer', diff --git a/src/core/public/index.ts b/src/core/public/index.ts index f72e115fd24f..254cac349559 100644 --- a/src/core/public/index.ts +++ b/src/core/public/index.ts @@ -177,13 +177,18 @@ export { MountPoint, UnmountCallback, PublicUiSettingsParams } from './types'; /** * Core services exposed to the `Plugin` setup lifecycle * + * @typeParam TPluginsStart - the type of the consuming plugin's start dependencies. Should be the same + * as the consuming {@link Plugin}'s `TPluginsStart` type. Used by `getStartServices`. + * @typeParam TStart - the type of the consuming plugin's start contract. Should be the same as the + * consuming {@link Plugin}'s `TStart` type. Used by `getStartServices`. + * * @public * * @internalRemarks We document the properties with \@link tags to improve * navigation in the generated docs until there's a fix for * https://github.com/Microsoft/web-build-tools/issues/1237 */ -export interface CoreSetup { +export interface CoreSetup { /** {@link ApplicationSetup} */ application: ApplicationSetup; /** @@ -209,7 +214,7 @@ export interface CoreSetup { getInjectedVar: (name: string, defaultValue?: any) => unknown; }; /** {@link StartServicesAccessor} */ - getStartServices: StartServicesAccessor; + getStartServices: StartServicesAccessor; } /** @@ -219,9 +224,10 @@ export interface CoreSetup { * * @public */ -export type StartServicesAccessor = () => Promise< - [CoreStart, TPluginsStart] ->; +export type StartServicesAccessor< + TPluginsStart extends object = object, + TStart = unknown +> = () => Promise<[CoreStart, TPluginsStart, TStart]>; /** * Core services exposed to the `Plugin` start lifecycle @@ -274,7 +280,7 @@ export interface CoreStart { * @public * @deprecated */ -export interface LegacyCoreSetup extends CoreSetup { +export interface LegacyCoreSetup extends CoreSetup { /** @deprecated */ injectedMetadata: InjectedMetadataSetup; } diff --git a/src/core/public/legacy/legacy_service.ts b/src/core/public/legacy/legacy_service.ts index 1b7e25f58556..39ca7bdf54b7 100644 --- a/src/core/public/legacy/legacy_service.ts +++ b/src/core/public/legacy/legacy_service.ts @@ -57,7 +57,7 @@ export class LegacyPlatformService { public readonly legacyId = Symbol(); private bootstrapModule?: BootstrapModule; private targetDomElement?: HTMLElement; - private readonly startDependencies$ = new Subject<[LegacyCoreStart, object]>(); + private readonly startDependencies$ = new Subject<[LegacyCoreStart, object, {}]>(); private readonly startDependencies = this.startDependencies$.pipe(first()).toPromise(); constructor(private readonly params: LegacyPlatformParams) {} @@ -129,7 +129,7 @@ export class LegacyPlatformService { }, }; - this.startDependencies$.next([legacyCore, plugins]); + this.startDependencies$.next([legacyCore, plugins, {}]); // Inject parts of the new platform into parts of the legacy platform // so that legacy APIs/modules can mimic their new platform counterparts diff --git a/src/core/public/mocks.ts b/src/core/public/mocks.ts index c860e9de8334..0c4930592b23 100644 --- a/src/core/public/mocks.ts +++ b/src/core/public/mocks.ts @@ -49,13 +49,22 @@ export { uiSettingsServiceMock } from './ui_settings/ui_settings_service.mock'; export { savedObjectsServiceMock } from './saved_objects/saved_objects_service.mock'; export { scopedHistoryMock } from './application/scoped_history.mock'; -function createCoreSetupMock({ basePath = '' } = {}) { +function createCoreSetupMock({ + basePath = '', + pluginStartDeps = {}, + pluginStartContract, +}: { + basePath?: string; + pluginStartDeps?: object; + pluginStartContract?: any; +} = {}) { const mock = { application: applicationServiceMock.createSetupContract(), context: contextServiceMock.createSetupContract(), fatalErrors: fatalErrorsServiceMock.createSetupContract(), - getStartServices: jest.fn, object]>, []>(() => - Promise.resolve([createCoreStartMock({ basePath }), {}]) + getStartServices: jest.fn, object, any]>, []>( + () => + Promise.resolve([createCoreStartMock({ basePath }), pluginStartDeps, pluginStartContract]) ), http: httpServiceMock.createSetupContract({ basePath }), notifications: notificationServiceMock.createSetupContract(), diff --git a/src/core/public/plugins/plugin.test.ts b/src/core/public/plugins/plugin.test.ts index 111ee93dd699..39330711f798 100644 --- a/src/core/public/plugins/plugin.test.ts +++ b/src/core/public/plugins/plugin.test.ts @@ -109,6 +109,10 @@ describe('PluginWrapper', () => { test("`start` resolves `startDependencies` Promise after plugin's start", async () => { expect.assertions(2); + const pluginStartContract = { + someApi: () => 'foo', + }; + let startDependenciesResolved = false; mockPluginLoader.mockResolvedValueOnce(() => ({ setup: jest.fn(), @@ -116,6 +120,7 @@ describe('PluginWrapper', () => { // Add small delay to ensure startDependencies is not resolved until after the plugin instance's start resolves. await new Promise(resolve => setTimeout(resolve, 10)); expect(startDependenciesResolved).toBe(false); + return pluginStartContract; }, })); await plugin.load(addBasePath); @@ -127,7 +132,7 @@ describe('PluginWrapper', () => { // called. const startDependenciesCheck = plugin.startDependencies.then(res => { startDependenciesResolved = true; - expect(res).toEqual([context, deps]); + expect(res).toEqual([context, deps, pluginStartContract]); }); await plugin.start(context, deps); await startDependenciesCheck; diff --git a/src/core/public/plugins/plugin.ts b/src/core/public/plugins/plugin.ts index e880627e352c..e51c45040c45 100644 --- a/src/core/public/plugins/plugin.ts +++ b/src/core/public/plugins/plugin.ts @@ -35,7 +35,7 @@ export interface Plugin< TPluginsSetup extends object = object, TPluginsStart extends object = object > { - setup(core: CoreSetup, plugins: TPluginsSetup): TSetup | Promise; + setup(core: CoreSetup, plugins: TPluginsSetup): TSetup | Promise; start(core: CoreStart, plugins: TPluginsStart): TStart | Promise; stop?(): void; } @@ -72,7 +72,7 @@ export class PluginWrapper< private initializer?: PluginInitializer; private instance?: Plugin; - private readonly startDependencies$ = new Subject<[CoreStart, TPluginsStart]>(); + private readonly startDependencies$ = new Subject<[CoreStart, TPluginsStart, TStart]>(); public readonly startDependencies = this.startDependencies$.pipe(first()).toPromise(); constructor( @@ -105,7 +105,7 @@ export class PluginWrapper< * @param plugins The dictionary where the key is the dependency name and the value * is the contract returned by the dependency's `setup` function. */ - public async setup(setupContext: CoreSetup, plugins: TPluginsSetup) { + public async setup(setupContext: CoreSetup, plugins: TPluginsSetup) { this.instance = await this.createPluginInstance(); return await this.instance.setup(setupContext, plugins); @@ -125,7 +125,7 @@ export class PluginWrapper< const startContract = await this.instance.start(startContext, plugins); - this.startDependencies$.next([startContext, plugins]); + this.startDependencies$.next([startContext, plugins, startContract]); return startContract; } diff --git a/src/core/public/plugins/plugins_service.ts b/src/core/public/plugins/plugins_service.ts index 8e1574d05baf..e698af689036 100644 --- a/src/core/public/plugins/plugins_service.ts +++ b/src/core/public/plugins/plugins_service.ts @@ -53,7 +53,7 @@ export interface PluginsServiceStart { */ export class PluginsService implements CoreService { /** Plugin wrappers in topological order. */ - private readonly plugins = new Map>>(); + private readonly plugins = new Map>(); private readonly pluginDependencies = new Map(); private readonly satupPlugins: PluginName[] = []; diff --git a/src/core/public/public.api.md b/src/core/public/public.api.md index eec12f234817..9f7f649f1e2a 100644 --- a/src/core/public/public.api.md +++ b/src/core/public/public.api.md @@ -371,7 +371,7 @@ export interface CoreContext { } // @public -export interface CoreSetup { +export interface CoreSetup { // (undocumented) application: ApplicationSetup; // @deprecated (undocumented) @@ -379,7 +379,7 @@ export interface CoreSetup { // (undocumented) fatalErrors: FatalErrorsSetup; // (undocumented) - getStartServices: StartServicesAccessor; + getStartServices: StartServicesAccessor; // (undocumented) http: HttpSetup; // @deprecated @@ -807,7 +807,7 @@ export interface IUiSettingsClient { } // @public @deprecated -export interface LegacyCoreSetup extends CoreSetup { +export interface LegacyCoreSetup extends CoreSetup { // Warning: (ae-forgotten-export) The symbol "InjectedMetadataSetup" needs to be exported by the entry point index.d.ts // // @deprecated (undocumented) @@ -907,7 +907,7 @@ export interface PackageInfo { // @public export interface Plugin { // (undocumented) - setup(core: CoreSetup, plugins: TPluginsSetup): TSetup | Promise; + setup(core: CoreSetup, plugins: TPluginsSetup): TSetup | Promise; // (undocumented) start(core: CoreStart, plugins: TPluginsStart): TStart | Promise; // (undocumented) @@ -1237,7 +1237,7 @@ export class SimpleSavedObject { } // @public -export type StartServicesAccessor = () => Promise<[CoreStart, TPluginsStart]>; +export type StartServicesAccessor = () => Promise<[CoreStart, TPluginsStart, TStart]>; // @public export type StringValidation = StringValidationRegex | StringValidationRegexString; diff --git a/src/core/server/index.ts b/src/core/server/index.ts index 1b436bfd7262..56ce16a951aa 100644 --- a/src/core/server/index.ts +++ b/src/core/server/index.ts @@ -333,9 +333,13 @@ export interface RequestHandlerContext { /** * Context passed to the plugins `setup` method. * + * @typeParam TPluginsStart - the type of the consuming plugin's start dependencies. Should be the same + * as the consuming {@link Plugin}'s `TPluginsStart` type. Used by `getStartServices`. + * @typeParam TStart - the type of the consuming plugin's start contract. Should be the same as the + * consuming {@link Plugin}'s `TStart` type. Used by `getStartServices`. * @public */ -export interface CoreSetup { +export interface CoreSetup { /** {@link CapabilitiesSetup} */ capabilities: CapabilitiesSetup; /** {@link ContextSetup} */ @@ -353,7 +357,7 @@ export interface CoreSetup { /** {@link MetricsServiceSetup} */ metrics: MetricsServiceSetup; /** {@link StartServicesAccessor} */ - getStartServices: StartServicesAccessor; + getStartServices: StartServicesAccessor; } /** @@ -364,9 +368,10 @@ export interface CoreSetup { * * @public */ -export type StartServicesAccessor = () => Promise< - [CoreStart, TPluginsStart] ->; +export type StartServicesAccessor< + TPluginsStart extends object = object, + TStart = unknown +> = () => Promise<[CoreStart, TPluginsStart, TStart]>; /** * Context passed to the plugins `start` method. diff --git a/src/core/server/legacy/legacy_service.ts b/src/core/server/legacy/legacy_service.ts index b19a991fdf0d..361fade6a4d0 100644 --- a/src/core/server/legacy/legacy_service.ts +++ b/src/core/server/legacy/legacy_service.ts @@ -312,7 +312,7 @@ export class LegacyService implements CoreService { uuid: { getInstanceUuid: setupDeps.core.uuid.getInstanceUuid, }, - getStartServices: () => Promise.resolve([coreStart, startDeps.plugins]), + getStartServices: () => Promise.resolve([coreStart, startDeps.plugins, {}]), }; // eslint-disable-next-line @typescript-eslint/no-var-requires diff --git a/src/core/server/mocks.ts b/src/core/server/mocks.ts index 2aa35dff563f..31bf17da041a 100644 --- a/src/core/server/mocks.ts +++ b/src/core/server/mocks.ts @@ -96,7 +96,13 @@ function pluginInitializerContextMock(config: T = {} as T) { type CoreSetupMockType = MockedKeys & jest.Mocked>; -function createCoreSetupMock() { +function createCoreSetupMock({ + pluginStartDeps = {}, + pluginStartContract, +}: { + pluginStartDeps?: object; + pluginStartContract?: any; +} = {}) { const httpService = httpServiceMock.createSetupContract(); const httpMock: jest.Mocked = { createCookieSessionStorageFactory: httpService.createCookieSessionStorageFactory, @@ -131,8 +137,8 @@ function createCoreSetupMock() { uuid: uuidServiceMock.createSetupContract(), metrics: metricsServiceMock.createSetupContract(), getStartServices: jest - .fn, object]>, []>() - .mockResolvedValue([createCoreStartMock(), {}]), + .fn, object, any]>, []>() + .mockResolvedValue([createCoreStartMock(), pluginStartDeps, pluginStartContract]), }; return mock; diff --git a/src/core/server/plugins/integration_tests/plugins_service.test.ts b/src/core/server/plugins/integration_tests/plugins_service.test.ts index d5531478f03c..1521fc332bcd 100644 --- a/src/core/server/plugins/integration_tests/plugins_service.test.ts +++ b/src/core/server/plugins/integration_tests/plugins_service.test.ts @@ -107,7 +107,7 @@ describe('PluginsService', () => { }); it("properly resolves `getStartServices` in plugin's lifecycle", async () => { - expect.assertions(5); + expect.assertions(6); const pluginPath = 'plugin-path'; @@ -125,20 +125,25 @@ describe('PluginsService', () => { let contextFromStart: any = null; let contextFromStartService: any = null; + const pluginStartContract = { + someApi: () => 'foo', + }; + const pluginInitializer = () => ({ setup: async (coreSetup, deps) => { - coreSetup.getStartServices().then(([core, plugins]) => { + coreSetup.getStartServices().then(([core, plugins, pluginStart]) => { startDependenciesResolved = true; - contextFromStartService = { core, plugins }; + contextFromStartService = { core, plugins, pluginStart }; }); }, start: async (core, plugins) => { contextFromStart = { core, plugins }; await new Promise(resolve => setTimeout(resolve, 10)); expect(startDependenciesResolved).toBe(false); + return pluginStartContract; }, - } as Plugin); + } as Plugin); jest.doMock( join(pluginPath, 'server'), @@ -163,5 +168,6 @@ describe('PluginsService', () => { expect(startDependenciesResolved).toBe(true); expect(contextFromStart!.core).toEqual(contextFromStartService!.core); expect(contextFromStart!.plugins).toEqual(contextFromStartService!.plugins); + expect(contextFromStartService!.pluginStart).toEqual(pluginStartContract); }); }); diff --git a/src/core/server/plugins/plugin.test.ts b/src/core/server/plugins/plugin.test.ts index 6875302f88a9..1e4d94dd00d0 100644 --- a/src/core/server/plugins/plugin.test.ts +++ b/src/core/server/plugins/plugin.test.ts @@ -250,6 +250,9 @@ test("`start` resolves `startDependencies` Promise after plugin's start", async }); const startContext = { any: 'thing' } as any; const pluginDeps = { someDep: 'value' }; + const pluginStartContract = { + someApi: () => 'foo', + }; let startDependenciesResolved = false; @@ -259,6 +262,7 @@ test("`start` resolves `startDependencies` Promise after plugin's start", async // delay to ensure startDependencies is not resolved until after the plugin instance's start resolves. await new Promise(resolve => setTimeout(resolve, 10)); expect(startDependenciesResolved).toBe(false); + return pluginStartContract; }, }; mockPluginInitializer.mockReturnValue(mockPluginInstance); @@ -267,7 +271,7 @@ test("`start` resolves `startDependencies` Promise after plugin's start", async const startDependenciesCheck = plugin.startDependencies.then(resolvedStartDeps => { startDependenciesResolved = true; - expect(resolvedStartDeps).toEqual([startContext, pluginDeps]); + expect(resolvedStartDeps).toEqual([startContext, pluginDeps, pluginStartContract]); }); await plugin.start(startContext, pluginDeps); diff --git a/src/core/server/plugins/plugin.ts b/src/core/server/plugins/plugin.ts index b372874264eb..7c67ab7a48df 100644 --- a/src/core/server/plugins/plugin.ts +++ b/src/core/server/plugins/plugin.ts @@ -61,7 +61,7 @@ export class PluginWrapper< private instance?: Plugin; - private readonly startDependencies$ = new Subject<[CoreStart, TPluginsStart]>(); + private readonly startDependencies$ = new Subject<[CoreStart, TPluginsStart, TStart]>(); public readonly startDependencies = this.startDependencies$.pipe(first()).toPromise(); constructor( @@ -115,7 +115,7 @@ export class PluginWrapper< this.log.debug('Starting plugin'); const startContract = await this.instance.start(startContext, plugins); - this.startDependencies$.next([startContext, plugins]); + this.startDependencies$.next([startContext, plugins, startContract]); return startContract; } diff --git a/src/core/server/server.api.md b/src/core/server/server.api.md index 232d34e48438..9317481ae2f8 100644 --- a/src/core/server/server.api.md +++ b/src/core/server/server.api.md @@ -622,7 +622,7 @@ export interface ContextSetup { export type CoreId = symbol; // @public -export interface CoreSetup { +export interface CoreSetup { // (undocumented) capabilities: CapabilitiesSetup; // (undocumented) @@ -630,7 +630,7 @@ export interface CoreSetup { // (undocumented) elasticsearch: ElasticsearchServiceSetup; // (undocumented) - getStartServices: StartServicesAccessor; + getStartServices: StartServicesAccessor; // (undocumented) http: HttpServiceSetup; // (undocumented) @@ -2270,7 +2270,7 @@ export type SharedGlobalConfig = RecursiveReadonly_2<{ }>; // @public -export type StartServicesAccessor = () => Promise<[CoreStart, TPluginsStart]>; +export type StartServicesAccessor = () => Promise<[CoreStart, TPluginsStart, TStart]>; // @public export type StringValidation = StringValidationRegex | StringValidationRegexString; diff --git a/src/legacy/core_plugins/input_control_vis/public/plugin.ts b/src/legacy/core_plugins/input_control_vis/public/plugin.ts index e85ccd94f9e6..c45e0d17872e 100644 --- a/src/legacy/core_plugins/input_control_vis/public/plugin.ts +++ b/src/legacy/core_plugins/input_control_vis/public/plugin.ts @@ -24,7 +24,7 @@ import { VisualizationsSetup, VisualizationsStart } from '../../visualizations/p import { createInputControlVisFn } from './input_control_fn'; import { createInputControlVisTypeDefinition } from './input_control_vis_type'; -type InputControlVisCoreSetup = CoreSetup; +type InputControlVisCoreSetup = CoreSetup; export interface InputControlVisDependencies { core: InputControlVisCoreSetup; @@ -46,7 +46,7 @@ export interface InputControlVisPluginStartDependencies { } /** @internal */ -export class InputControlVisPlugin implements Plugin, void> { +export class InputControlVisPlugin implements Plugin { constructor(public initializerContext: PluginInitializerContext) {} public async setup( diff --git a/src/legacy/core_plugins/kibana/public/discover/plugin.ts b/src/legacy/core_plugins/kibana/public/discover/plugin.ts index d3cdeb49fba7..42f3ec672609 100644 --- a/src/legacy/core_plugins/kibana/public/discover/plugin.ts +++ b/src/legacy/core_plugins/kibana/public/discover/plugin.ts @@ -91,7 +91,7 @@ export class DiscoverPlugin implements Plugin { public initializeInnerAngular?: () => void; public initializeServices?: () => Promise<{ core: CoreStart; plugins: DiscoverStartPlugins }>; - setup(core: CoreSetup, plugins: DiscoverSetupPlugins) { + setup(core: CoreSetup, plugins: DiscoverSetupPlugins) { const { appMounted, appUnMounted, stop: stopUrlTracker } = createKbnUrlTracker({ baseUrl: core.http.basePath.prepend('/app/kibana'), defaultSubUrl: '#/discover', diff --git a/src/legacy/core_plugins/vis_type_timelion/public/plugin.ts b/src/legacy/core_plugins/vis_type_timelion/public/plugin.ts index 9d69c312b48f..8d067369fef7 100644 --- a/src/legacy/core_plugins/vis_type_timelion/public/plugin.ts +++ b/src/legacy/core_plugins/vis_type_timelion/public/plugin.ts @@ -35,7 +35,7 @@ import { getTimelionVisualizationConfig } from './timelion_vis_fn'; import { getTimelionVisDefinition } from './timelion_vis_type'; import { setIndexPatterns, setSavedObjectsClient } from './helpers/plugin_services'; -type TimelionVisCoreSetup = CoreSetup; +type TimelionVisCoreSetup = CoreSetup; /** @internal */ export interface TimelionVisDependencies extends Partial { diff --git a/src/legacy/core_plugins/vis_type_vislib/public/plugin.ts b/src/legacy/core_plugins/vis_type_vislib/public/plugin.ts index 9539adbd2ec2..3022a03d65fe 100644 --- a/src/legacy/core_plugins/vis_type_vislib/public/plugin.ts +++ b/src/legacy/core_plugins/vis_type_vislib/public/plugin.ts @@ -62,10 +62,10 @@ export interface VisTypeVislibPluginStartDependencies { data: DataPublicPluginStart; } -type VisTypeVislibCoreSetup = CoreSetup; +type VisTypeVislibCoreSetup = CoreSetup; /** @internal */ -export class VisTypeVislibPlugin implements Plugin, void> { +export class VisTypeVislibPlugin implements Plugin { constructor(public initializerContext: PluginInitializerContext) {} public async setup( diff --git a/src/legacy/core_plugins/vis_type_xy/public/plugin.ts b/src/legacy/core_plugins/vis_type_xy/public/plugin.ts index 35abb04fd873..0884cdf6a5e1 100644 --- a/src/legacy/core_plugins/vis_type_xy/public/plugin.ts +++ b/src/legacy/core_plugins/vis_type_xy/public/plugin.ts @@ -47,10 +47,10 @@ export interface VisTypeXyPluginStartDependencies { visualizations: VisualizationsStart; } -type VisTypeXyCoreSetup = CoreSetup; +type VisTypeXyCoreSetup = CoreSetup; /** @internal */ -export class VisTypeXyPlugin implements Plugin, void> { +export class VisTypeXyPlugin implements Plugin { constructor(public initializerContext: PluginInitializerContext) {} public async setup( diff --git a/src/plugins/home/public/plugin.ts b/src/plugins/home/public/plugin.ts index 2353df600aa6..fab7808b5072 100644 --- a/src/plugins/home/public/plugin.ts +++ b/src/plugins/home/public/plugin.ts @@ -50,7 +50,9 @@ export interface HomePluginSetupDependencies { kibanaLegacy: KibanaLegacySetup; } -export class HomePublicPlugin implements Plugin { +export class HomePublicPlugin + implements + Plugin { private readonly featuresCatalogueRegistry = new FeatureCatalogueRegistry(); private readonly environmentService = new EnvironmentService(); private readonly tutorialService = new TutorialService(); diff --git a/x-pack/plugins/actions/server/plugin.ts b/x-pack/plugins/actions/server/plugin.ts index c6c4f377ab61..ce31e62bc9b8 100644 --- a/x-pack/plugins/actions/server/plugin.ts +++ b/x-pack/plugins/actions/server/plugin.ts @@ -175,7 +175,7 @@ export class ActionsPlugin implements Plugin, Plugi const usageCollection = plugins.usageCollection; if (usageCollection) { - core.getStartServices().then(async ([coreStart, startPlugins]: [CoreStart, any]) => { + core.getStartServices().then(async ([, startPlugins]: [CoreStart, any, any]) => { registerActionsUsageCollector(usageCollection, startPlugins.taskManager); initializeActionsTelemetry( diff --git a/x-pack/plugins/alerting/server/plugin.ts b/x-pack/plugins/alerting/server/plugin.ts index e88124322c1e..b0d06d4aeeb7 100644 --- a/x-pack/plugins/alerting/server/plugin.ts +++ b/x-pack/plugins/alerting/server/plugin.ts @@ -143,7 +143,7 @@ export class AlertingPlugin { const usageCollection = plugins.usageCollection; if (usageCollection) { - core.getStartServices().then(async ([coreStart, startPlugins]: [CoreStart, any]) => { + core.getStartServices().then(async ([, startPlugins]: [CoreStart, any, any]) => { registerAlertsUsageCollector(usageCollection, startPlugins.taskManager); initializeAlertingTelemetry( diff --git a/x-pack/plugins/ingest_manager/public/plugin.ts b/x-pack/plugins/ingest_manager/public/plugin.ts index 99dcebd9bfba..d7be1c1f1fe6 100644 --- a/x-pack/plugins/ingest_manager/public/plugin.ts +++ b/x-pack/plugins/ingest_manager/public/plugin.ts @@ -32,7 +32,9 @@ export interface IngestManagerStartDeps { data: DataPublicPluginStart; } -export class IngestManagerPlugin implements Plugin { +export class IngestManagerPlugin + implements + Plugin { private config: IngestManagerConfigType; constructor(private readonly initializerContext: PluginInitializerContext) { @@ -50,7 +52,8 @@ export class IngestManagerPlugin implements Plugin { async mount(params: AppMountParameters) { const [coreStart, startDeps] = (await core.getStartServices()) as [ CoreStart, - IngestManagerStartDeps + IngestManagerStartDeps, + IngestManagerStart ]; const { renderApp } = await import('./applications/ingest_manager'); return renderApp(coreStart, params, deps, startDeps, config); diff --git a/x-pack/plugins/ml/public/index.ts b/x-pack/plugins/ml/public/index.ts index f9f2be390e05..8070f94a1264 100755 --- a/x-pack/plugins/ml/public/index.ts +++ b/x-pack/plugins/ml/public/index.ts @@ -6,8 +6,19 @@ import { PluginInitializer } from 'kibana/public'; import './index.scss'; -import { MlPlugin, MlPluginSetup, MlPluginStart } from './plugin'; +import { + MlPlugin, + MlPluginSetup, + MlPluginStart, + MlSetupDependencies, + MlStartDependencies, +} from './plugin'; -export const plugin: PluginInitializer = () => new MlPlugin(); +export const plugin: PluginInitializer< + MlPluginSetup, + MlPluginStart, + MlSetupDependencies, + MlStartDependencies +> = () => new MlPlugin(); export { MlPluginSetup, MlPluginStart }; diff --git a/x-pack/plugins/ml/public/plugin.ts b/x-pack/plugins/ml/public/plugin.ts index d4bec3d617a0..62b60f81b672 100644 --- a/x-pack/plugins/ml/public/plugin.ts +++ b/x-pack/plugins/ml/public/plugin.ts @@ -31,7 +31,7 @@ export interface MlSetupDependencies { } export class MlPlugin implements Plugin { - setup(core: CoreSetup, pluginsSetup: MlSetupDependencies) { + setup(core: CoreSetup, pluginsSetup: MlSetupDependencies) { core.application.register({ id: PLUGIN_ID, title: i18n.translate('xpack.ml.plugin.title', { diff --git a/x-pack/plugins/monitoring/server/plugin.ts b/x-pack/plugins/monitoring/server/plugin.ts index d9500284b52d..24d8bcaa4397 100644 --- a/x-pack/plugins/monitoring/server/plugin.ts +++ b/x-pack/plugins/monitoring/server/plugin.ts @@ -224,7 +224,7 @@ export class Plugin { this.monitoringCore = this.getLegacyShim( config, legacyConfig, - core.getStartServices as () => Promise<[CoreStart, PluginsStart]>, + core.getStartServices as () => Promise<[CoreStart, PluginsStart, {}]>, this.licenseService, this.cluster ); @@ -293,7 +293,7 @@ export class Plugin { getLegacyShim( config: MonitoringConfig, legacyConfig: any, - getCoreServices: () => Promise<[CoreStart, PluginsStart]>, + getCoreServices: () => Promise<[CoreStart, PluginsStart, {}]>, licenseService: MonitoringLicenseService, cluster: ICustomClusterClient ): MonitoringCore { diff --git a/x-pack/plugins/security/public/account_management/account_management_app.test.ts b/x-pack/plugins/security/public/account_management/account_management_app.test.ts index ad40c61718c7..bac98d563975 100644 --- a/x-pack/plugins/security/public/account_management/account_management_app.test.ts +++ b/x-pack/plugins/security/public/account_management/account_management_app.test.ts @@ -38,7 +38,7 @@ describe('accountManagementApp', () => { it('properly sets breadcrumbs and renders application', async () => { const coreSetupMock = coreMock.createSetup(); const coreStartMock = coreMock.createStart(); - coreSetupMock.getStartServices.mockResolvedValue([coreStartMock, {}]); + coreSetupMock.getStartServices.mockResolvedValue([coreStartMock, {}, {}]); const authcMock = securityMock.createSetup().authc; const containerMock = document.createElement('div'); diff --git a/x-pack/plugins/security/public/authentication/logged_out/logged_out_app.test.ts b/x-pack/plugins/security/public/authentication/logged_out/logged_out_app.test.ts index c8303ecc940d..f0c18a3f1408 100644 --- a/x-pack/plugins/security/public/authentication/logged_out/logged_out_app.test.ts +++ b/x-pack/plugins/security/public/authentication/logged_out/logged_out_app.test.ts @@ -35,7 +35,7 @@ describe('loggedOutApp', () => { it('properly renders application', async () => { const coreSetupMock = coreMock.createSetup(); const coreStartMock = coreMock.createStart(); - coreSetupMock.getStartServices.mockResolvedValue([coreStartMock, {}]); + coreSetupMock.getStartServices.mockResolvedValue([coreStartMock, {}, {}]); const containerMock = document.createElement('div'); diff --git a/x-pack/plugins/security/public/authentication/login/login_app.test.ts b/x-pack/plugins/security/public/authentication/login/login_app.test.ts index 2597a935f45d..b7119d179b0b 100644 --- a/x-pack/plugins/security/public/authentication/login/login_app.test.ts +++ b/x-pack/plugins/security/public/authentication/login/login_app.test.ts @@ -38,7 +38,7 @@ describe('loginApp', () => { it('properly renders application', async () => { const coreSetupMock = coreMock.createSetup(); const coreStartMock = coreMock.createStart(); - coreSetupMock.getStartServices.mockResolvedValue([coreStartMock, {}]); + coreSetupMock.getStartServices.mockResolvedValue([coreStartMock, {}, {}]); const containerMock = document.createElement('div'); loginApp.create({ diff --git a/x-pack/plugins/security/public/authentication/overwritten_session/overwritten_session_app.test.ts b/x-pack/plugins/security/public/authentication/overwritten_session/overwritten_session_app.test.ts index 7b15d8c46f6e..96e72ead2299 100644 --- a/x-pack/plugins/security/public/authentication/overwritten_session/overwritten_session_app.test.ts +++ b/x-pack/plugins/security/public/authentication/overwritten_session/overwritten_session_app.test.ts @@ -37,7 +37,7 @@ describe('overwrittenSessionApp', () => { it('properly sets breadcrumbs and renders application', async () => { const coreSetupMock = coreMock.createSetup(); const coreStartMock = coreMock.createStart(); - coreSetupMock.getStartServices.mockResolvedValue([coreStartMock, {}]); + coreSetupMock.getStartServices.mockResolvedValue([coreStartMock, {}, {}]); const authcMock = securityMock.createSetup().authc; const containerMock = document.createElement('div'); diff --git a/x-pack/plugins/security/public/index.ts b/x-pack/plugins/security/public/index.ts index fdb8b544d61d..458f7ab801fd 100644 --- a/x-pack/plugins/security/public/index.ts +++ b/x-pack/plugins/security/public/index.ts @@ -6,13 +6,22 @@ import './index.scss'; import { PluginInitializer, PluginInitializerContext } from 'src/core/public'; -import { SecurityPlugin, SecurityPluginSetup, SecurityPluginStart } from './plugin'; +import { + SecurityPlugin, + SecurityPluginSetup, + SecurityPluginStart, + PluginSetupDependencies, + PluginStartDependencies, +} from './plugin'; export { SecurityPluginSetup, SecurityPluginStart }; export { SessionInfo } from './types'; export { AuthenticatedUser } from '../common/model'; export { SecurityLicense, SecurityLicenseFeatures } from '../common/licensing'; -export const plugin: PluginInitializer = ( - initializerContext: PluginInitializerContext -) => new SecurityPlugin(initializerContext); +export const plugin: PluginInitializer< + SecurityPluginSetup, + SecurityPluginStart, + PluginSetupDependencies, + PluginStartDependencies +> = (initializerContext: PluginInitializerContext) => new SecurityPlugin(initializerContext); diff --git a/x-pack/plugins/spaces/public/management/spaces_management_app.test.tsx b/x-pack/plugins/spaces/public/management/spaces_management_app.test.tsx index 7738a440cb5e..61c872ec9269 100644 --- a/x-pack/plugins/spaces/public/management/spaces_management_app.test.tsx +++ b/x-pack/plugins/spaces/public/management/spaces_management_app.test.tsx @@ -51,7 +51,7 @@ async function mountApp(basePath: string, spaceId?: string) { .create({ spacesManager, securityLicense, - getStartServices: async () => [coreStart, pluginsStart as PluginsStart], + getStartServices: async () => [coreStart, pluginsStart as PluginsStart, {}], }) .mount({ basePath, element: container, setBreadcrumbs }); diff --git a/x-pack/plugins/spaces/server/capabilities/capabilities_switcher.test.ts b/x-pack/plugins/spaces/server/capabilities/capabilities_switcher.test.ts index 2c1ab26dd3d8..b4489e570015 100644 --- a/x-pack/plugins/spaces/server/capabilities/capabilities_switcher.test.ts +++ b/x-pack/plugins/spaces/server/capabilities/capabilities_switcher.test.ts @@ -103,6 +103,7 @@ const setup = (space: Space) => { coreSetup.getStartServices.mockResolvedValue([ coreMock.createStart(), { features: featuresStart }, + {}, ]); const spacesService = spacesServiceMock.createSetupContract(); diff --git a/x-pack/test/plugin_functional/plugins/resolver_test/public/index.ts b/x-pack/test/plugin_functional/plugins/resolver_test/public/index.ts index c5f3c0e19138..51ec5a08b7a3 100644 --- a/x-pack/test/plugin_functional/plugins/resolver_test/public/index.ts +++ b/x-pack/test/plugin_functional/plugins/resolver_test/public/index.ts @@ -5,6 +5,15 @@ */ import { PluginInitializer } from 'kibana/public'; -import { ResolverTestPlugin } from './plugin'; +import { + ResolverTestPlugin, + ResolverTestPluginSetupDependencies, + ResolverTestPluginStartDependencies, +} from './plugin'; -export const plugin: PluginInitializer = () => new ResolverTestPlugin(); +export const plugin: PluginInitializer< + void, + void, + ResolverTestPluginSetupDependencies, + ResolverTestPluginStartDependencies +> = () => new ResolverTestPlugin(); From 2b113e1ec8e858542209976f25b743e1ef557004 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Fern=C3=A1ndez?= Date: Thu, 26 Mar 2020 10:51:51 +0100 Subject: [PATCH 30/35] =?UTF-8?q?[Logs=20UI]=20Cleanup=20`/log=5Fentries/e?= =?UTF-8?q?ntries`'s=20underlying=20implemen=E2=80=A6=20(#60764)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Rename temporary name * Rename `LogEntryDocument` fields to match `LogEntry` * Dedupe types Co-authored-by: Elastic Machine --- .../log_entries/kibana_log_entries_adapter.ts | 14 ++++---------- .../log_entries_domain/log_entries_domain.ts | 17 +++++++---------- .../infra/server/routes/log_entries/entries.ts | 2 +- .../server/routes/log_entries/highlights.ts | 2 +- 4 files changed, 13 insertions(+), 22 deletions(-) diff --git a/x-pack/plugins/infra/server/lib/adapters/log_entries/kibana_log_entries_adapter.ts b/x-pack/plugins/infra/server/lib/adapters/log_entries/kibana_log_entries_adapter.ts index 3a5dff75f004..b8513541be7a 100644 --- a/x-pack/plugins/infra/server/lib/adapters/log_entries/kibana_log_entries_adapter.ts +++ b/x-pack/plugins/infra/server/lib/adapters/log_entries/kibana_log_entries_adapter.ts @@ -112,7 +112,7 @@ export class InfraKibanaLogEntriesAdapter implements LogEntriesAdapter { ); const hits = sortDirection === 'asc' ? esResult.hits.hits : esResult.hits.hits.reverse(); - return mapHitsToLogEntryDocuments(hits, sourceConfiguration.fields.timestamp, fields); + return mapHitsToLogEntryDocuments(hits, fields); } public async getContainedLogSummaryBuckets( @@ -226,11 +226,7 @@ export class InfraKibanaLogEntriesAdapter implements LogEntriesAdapter { } } -function mapHitsToLogEntryDocuments( - hits: SortedSearchHit[], - timestampField: string, - fields: string[] -): LogEntryDocument[] { +function mapHitsToLogEntryDocuments(hits: SortedSearchHit[], fields: string[]): LogEntryDocument[] { return hits.map(hit => { const logFields = fields.reduce<{ [fieldName: string]: JsonValue }>( (flattenedFields, field) => { @@ -243,10 +239,8 @@ function mapHitsToLogEntryDocuments( ); return { - gid: hit._id, - // timestamp: hit._source[timestampField], - // FIXME s/key/cursor/g - key: { time: hit.sort[0], tiebreaker: hit.sort[1] }, + id: hit._id, + cursor: { time: hit.sort[0], tiebreaker: hit.sort[1] }, fields: logFields, highlights: hit.highlight || {}, }; diff --git a/x-pack/plugins/infra/server/lib/domains/log_entries_domain/log_entries_domain.ts b/x-pack/plugins/infra/server/lib/domains/log_entries_domain/log_entries_domain.ts index 9a2631e3c2f7..a88b1d9049c7 100644 --- a/x-pack/plugins/infra/server/lib/domains/log_entries_domain/log_entries_domain.ts +++ b/x-pack/plugins/infra/server/lib/domains/log_entries_domain/log_entries_domain.ts @@ -7,7 +7,6 @@ import { sortBy } from 'lodash'; import { RequestHandlerContext } from 'src/core/server'; -import { TimeKey } from '../../../../common/time'; import { JsonObject } from '../../../../common/typed_json'; import { LogEntriesSummaryBucket, @@ -56,9 +55,7 @@ export class InfraLogEntriesDomain { private readonly libs: { sources: InfraSources } ) {} - /* Name is temporary until we can clean up the GraphQL implementation */ - /* eslint-disable-next-line @typescript-eslint/camelcase */ - public async getLogEntriesAround__new( + public async getLogEntriesAround( requestContext: RequestHandlerContext, sourceId: string, params: LogEntriesAroundParams @@ -133,14 +130,14 @@ export class InfraLogEntriesDomain { const entries = documents.map(doc => { return { - id: doc.gid, - cursor: doc.key, + id: doc.id, + cursor: doc.cursor, columns: configuration.logColumns.map( (column): LogColumn => { if ('timestampColumn' in column) { return { columnId: column.timestampColumn.id, - timestamp: doc.key.time, + timestamp: doc.cursor.time, }; } else if ('messageColumn' in column) { return { @@ -292,17 +289,17 @@ export interface LogEntriesAdapter { export type LogEntryQuery = JsonObject; export interface LogEntryDocument { + id: string; fields: Fields; - gid: string; highlights: Highlights; - key: TimeKey; + cursor: LogEntriesCursor; } export interface LogSummaryBucket { entriesCount: number; start: number; end: number; - topEntryKeys: TimeKey[]; + topEntryKeys: LogEntriesCursor[]; } const logSummaryBucketHasEntries = (bucket: LogSummaryBucket) => diff --git a/x-pack/plugins/infra/server/routes/log_entries/entries.ts b/x-pack/plugins/infra/server/routes/log_entries/entries.ts index f33dfa71fedc..2cd889d9c556 100644 --- a/x-pack/plugins/infra/server/routes/log_entries/entries.ts +++ b/x-pack/plugins/infra/server/routes/log_entries/entries.ts @@ -48,7 +48,7 @@ export const initLogEntriesRoute = ({ framework, logEntries }: InfraBackendLibs) let entries; if ('center' in payload) { - entries = await logEntries.getLogEntriesAround__new(requestContext, sourceId, { + entries = await logEntries.getLogEntriesAround(requestContext, sourceId, { startTimestamp, endTimestamp, query: parseFilterQuery(query), diff --git a/x-pack/plugins/infra/server/routes/log_entries/highlights.ts b/x-pack/plugins/infra/server/routes/log_entries/highlights.ts index 2e581d96cab9..9a61c8fa5aa9 100644 --- a/x-pack/plugins/infra/server/routes/log_entries/highlights.ts +++ b/x-pack/plugins/infra/server/routes/log_entries/highlights.ts @@ -45,7 +45,7 @@ export const initLogEntriesHighlightsRoute = ({ framework, logEntries }: InfraBa if ('center' in payload) { entriesPerHighlightTerm = await Promise.all( highlightTerms.map(highlightTerm => - logEntries.getLogEntriesAround__new(requestContext, sourceId, { + logEntries.getLogEntriesAround(requestContext, sourceId, { startTimestamp, endTimestamp, query: parseFilterQuery(query), From d51b26d9b647d66ff2f019ce6c4abfdba542826f Mon Sep 17 00:00:00 2001 From: Maryia Lapata Date: Thu, 26 Mar 2020 13:17:31 +0300 Subject: [PATCH 31/35] [NP] Vislib: createFiltersFromEvent goes through plugin class (#61072) * Use createFiltersFromEvent vis plugin class * Update legend.test.tsx * Use createGetterSetter helper * Fix TS * Fix TS * Refactoring * Update services.ts Co-authored-by: Elastic Machine --- .../core_plugins/vis_type_vislib/public/legacy.ts | 7 +------ .../vis_type_vislib/public/legacy_imports.ts | 2 -- .../core_plugins/vis_type_vislib/public/plugin.ts | 11 +++++------ .../core_plugins/vis_type_vislib/public/services.ts | 4 ++++ .../public/vislib/components/legend/legend.test.tsx | 5 ++++- .../public/vislib/components/legend/legend.tsx | 4 ++-- 6 files changed, 16 insertions(+), 17 deletions(-) diff --git a/src/legacy/core_plugins/vis_type_vislib/public/legacy.ts b/src/legacy/core_plugins/vis_type_vislib/public/legacy.ts index de3a115fc3e4..ef7277222e5f 100644 --- a/src/legacy/core_plugins/vis_type_vislib/public/legacy.ts +++ b/src/legacy/core_plugins/vis_type_vislib/public/legacy.ts @@ -25,10 +25,7 @@ import { VisTypeVislibPluginSetupDependencies, VisTypeVislibPluginStartDependencies, } from './plugin'; -import { - setup as visualizationsSetup, - start as visualizationsStart, -} from '../../visualizations/public/np_ready/public/legacy'; +import { setup as visualizationsSetup } from '../../visualizations/public/np_ready/public/legacy'; const setupPlugins: Readonly = { expressions: npSetup.plugins.expressions, @@ -37,8 +34,6 @@ const setupPlugins: Readonly = { }; const startPlugins: Readonly = { - expressions: npStart.plugins.expressions, - visualizations: visualizationsStart, data: npStart.plugins.data, }; diff --git a/src/legacy/core_plugins/vis_type_vislib/public/legacy_imports.ts b/src/legacy/core_plugins/vis_type_vislib/public/legacy_imports.ts index 667396a14c3d..9f7b8cbeea11 100644 --- a/src/legacy/core_plugins/vis_type_vislib/public/legacy_imports.ts +++ b/src/legacy/core_plugins/vis_type_vislib/public/legacy_imports.ts @@ -17,8 +17,6 @@ * under the License. */ -import { npStart } from 'ui/new_platform'; -export const { createFiltersFromEvent } = npStart.plugins.data.actions; import { search } from '../../../../plugins/data/public'; export const { tabifyAggResponse, tabifyGetColumns } = search; // @ts-ignore diff --git a/src/legacy/core_plugins/vis_type_vislib/public/plugin.ts b/src/legacy/core_plugins/vis_type_vislib/public/plugin.ts index 3022a03d65fe..8b4510050802 100644 --- a/src/legacy/core_plugins/vis_type_vislib/public/plugin.ts +++ b/src/legacy/core_plugins/vis_type_vislib/public/plugin.ts @@ -25,7 +25,7 @@ import { } from 'kibana/public'; import { Plugin as ExpressionsPublicPlugin } from '../../../../plugins/expressions/public'; -import { VisualizationsSetup, VisualizationsStart } from '../../visualizations/public'; +import { VisualizationsSetup } from '../../visualizations/public'; import { createVisTypeVislibVisFn } from './vis_type_vislib_vis_fn'; import { createPieVisFn } from './pie_fn'; import { @@ -41,7 +41,7 @@ import { import { ChartsPluginSetup } from '../../../../plugins/charts/public'; import { ConfigSchema as VisTypeXyConfigSchema } from '../../vis_type_xy'; import { DataPublicPluginStart } from '../../../../plugins/data/public'; -import { setFormatService } from './services'; +import { setFormatService, setDataActions } from './services'; export interface VisTypeVislibDependencies { uiSettings: IUiSettingsClient; @@ -57,8 +57,6 @@ export interface VisTypeVislibPluginSetupDependencies { /** @internal */ export interface VisTypeVislibPluginStartDependencies { - expressions: ReturnType; - visualizations: VisualizationsStart; data: DataPublicPluginStart; } @@ -111,7 +109,8 @@ export class VisTypeVislibPlugin implements Plugin { ); } - public start(core: CoreStart, deps: VisTypeVislibPluginStartDependencies) { - setFormatService(deps.data.fieldFormats); + public start(core: CoreStart, { data }: VisTypeVislibPluginStartDependencies) { + setFormatService(data.fieldFormats); + setDataActions({ createFiltersFromEvent: data.actions.createFiltersFromEvent }); } } diff --git a/src/legacy/core_plugins/vis_type_vislib/public/services.ts b/src/legacy/core_plugins/vis_type_vislib/public/services.ts index 658db00b9a31..da50e227d84d 100644 --- a/src/legacy/core_plugins/vis_type_vislib/public/services.ts +++ b/src/legacy/core_plugins/vis_type_vislib/public/services.ts @@ -20,6 +20,10 @@ import { createGetterSetter } from '../../../../plugins/kibana_utils/common'; import { DataPublicPluginStart } from '../../../../plugins/data/public'; +export const [getDataActions, setDataActions] = createGetterSetter< + DataPublicPluginStart['actions'] +>('vislib data.actions'); + export const [getFormatService, setFormatService] = createGetterSetter< DataPublicPluginStart['fieldFormats'] >('vislib data.fieldFormats'); diff --git a/src/legacy/core_plugins/vis_type_vislib/public/vislib/components/legend/legend.test.tsx b/src/legacy/core_plugins/vis_type_vislib/public/vislib/components/legend/legend.test.tsx index 7f06bdddb480..c378ae7b05b3 100644 --- a/src/legacy/core_plugins/vis_type_vislib/public/vislib/components/legend/legend.test.tsx +++ b/src/legacy/core_plugins/vis_type_vislib/public/vislib/components/legend/legend.test.tsx @@ -32,10 +32,13 @@ jest.mock('@elastic/eui', () => ({ })); jest.mock('../../../legacy_imports', () => ({ - createFiltersFromEvent: jest.fn().mockResolvedValue(['yes']), getTableAggs: jest.fn(), })); +jest.mock('../../../services', () => ({ + getDataActions: () => ({ createFiltersFromEvent: jest.fn().mockResolvedValue(['yes']) }), +})); + const vis = { params: { addLegend: true, diff --git a/src/legacy/core_plugins/vis_type_vislib/public/vislib/components/legend/legend.tsx b/src/legacy/core_plugins/vis_type_vislib/public/vislib/components/legend/legend.tsx index afd974d6d9b4..2fe16bbfeb62 100644 --- a/src/legacy/core_plugins/vis_type_vislib/public/vislib/components/legend/legend.tsx +++ b/src/legacy/core_plugins/vis_type_vislib/public/vislib/components/legend/legend.tsx @@ -23,7 +23,7 @@ import { compact, uniq, map, every, isUndefined } from 'lodash'; import { i18n } from '@kbn/i18n'; import { EuiPopoverProps, EuiIcon, keyCodes, htmlIdGenerator } from '@elastic/eui'; -import { createFiltersFromEvent } from '../../../legacy_imports'; +import { getDataActions } from '../../../services'; import { CUSTOM_LEGEND_VIS_TYPES, LegendItem } from './models'; import { VisLegendItem } from './legend_item'; import { getPieNames } from './pie_utils'; @@ -101,7 +101,7 @@ export class VisLegend extends PureComponent { return false; } - const filters = await createFiltersFromEvent(item.values); + const filters = await getDataActions().createFiltersFromEvent(item.values); return Boolean(filters.length); }; From d55553711e3e8626a82a761dc504fb5efc6625ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Fern=C3=A1ndez=20Haro?= Date: Thu, 26 Mar 2020 10:28:13 +0000 Subject: [PATCH 32/35] [Telemetry] Re-enable telemetry.config (#61408) --- .../usage/telemetry_usage_collector.test.ts | 2 +- .../usage/telemetry_usage_collector.ts | 19 +++++++++++++------ src/plugins/telemetry/server/config.ts | 4 +++- src/plugins/telemetry/server/plugin.ts | 2 +- 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/plugins/telemetry/server/collectors/usage/telemetry_usage_collector.test.ts b/src/plugins/telemetry/server/collectors/usage/telemetry_usage_collector.test.ts index f44603f4f19f..9dc19f34f7eb 100644 --- a/src/plugins/telemetry/server/collectors/usage/telemetry_usage_collector.test.ts +++ b/src/plugins/telemetry/server/collectors/usage/telemetry_usage_collector.test.ts @@ -119,7 +119,7 @@ describe('telemetry_usage_collector', () => { const usageCollector = mockUsageCollector() as any; const collectorOptions = createTelemetryUsageCollector( usageCollector, - () => tempFiles.unreadable + async () => tempFiles.unreadable ); expect(collectorOptions.type).toBe('static_telemetry'); diff --git a/src/plugins/telemetry/server/collectors/usage/telemetry_usage_collector.ts b/src/plugins/telemetry/server/collectors/usage/telemetry_usage_collector.ts index 3daae90106e9..bde7cfa5c444 100644 --- a/src/plugins/telemetry/server/collectors/usage/telemetry_usage_collector.ts +++ b/src/plugins/telemetry/server/collectors/usage/telemetry_usage_collector.ts @@ -20,11 +20,12 @@ import { accessSync, constants, readFileSync, statSync } from 'fs'; import { safeLoad } from 'js-yaml'; import { dirname, join } from 'path'; +import { Observable } from 'rxjs'; import { UsageCollectionSetup } from 'src/plugins/usage_collection/server'; -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { getConfigPath } from '../../../../../core/server/path'; +import { take } from 'rxjs/operators'; +import { TelemetryConfigType } from '../../config'; // look for telemetry.yml in the same places we expect kibana.yml import { ensureDeepObject } from './ensure_deep_object'; @@ -80,20 +81,26 @@ export async function readTelemetryFile(path: string): Promise Promise ) { return usageCollection.makeUsageCollector({ type: 'static_telemetry', isReady: () => true, fetch: async () => { - const configPath = getConfigPathFn(); + const configPath = await getConfigPathFn(); const telemetryPath = join(dirname(configPath), 'telemetry.yml'); return await readTelemetryFile(telemetryPath); }, }); } -export function registerTelemetryUsageCollector(usageCollection: UsageCollectionSetup) { - const collector = createTelemetryUsageCollector(usageCollection); +export function registerTelemetryUsageCollector( + usageCollection: UsageCollectionSetup, + config$: Observable +) { + const collector = createTelemetryUsageCollector(usageCollection, async () => { + const config = await config$.pipe(take(1)).toPromise(); + return config.config; + }); usageCollection.registerCollector(collector); } diff --git a/src/plugins/telemetry/server/config.ts b/src/plugins/telemetry/server/config.ts index 7c62a37df717..9621a8b5619b 100644 --- a/src/plugins/telemetry/server/config.ts +++ b/src/plugins/telemetry/server/config.ts @@ -18,6 +18,8 @@ */ import { schema, TypeOf } from '@kbn/config-schema'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths +import { getConfigPath } from '../../../core/server/path'; import { ENDPOINT_VERSION } from '../common/constants'; export const configSchema = schema.object({ @@ -31,7 +33,7 @@ export const configSchema = schema.object({ { defaultValue: true } ), // `config` is used internally and not intended to be set - // config: Joi.string().default(getConfigPath()), TODO: Get it in some other way + config: schema.string({ defaultValue: getConfigPath() }), banner: schema.boolean({ defaultValue: true }), url: schema.conditional( schema.contextRef('dev'), diff --git a/src/plugins/telemetry/server/plugin.ts b/src/plugins/telemetry/server/plugin.ts index d7a4e15968a4..77036b4ea7dd 100644 --- a/src/plugins/telemetry/server/plugin.ts +++ b/src/plugins/telemetry/server/plugin.ts @@ -163,7 +163,7 @@ export class TelemetryPlugin implements Plugin { config$: this.config$, getSavedObjectsClient, }); - registerTelemetryUsageCollector(usageCollection); + registerTelemetryUsageCollector(usageCollection, this.config$); registerManagementUsageCollector(usageCollection, getUiSettingsClient); registerUiMetricUsageCollector(usageCollection, registerType, getSavedObjectsClient); registerApplicationUsageCollector(usageCollection, registerType, getSavedObjectsClient); From 01e3cc307e68a01f91818bd915028f3412b34604 Mon Sep 17 00:00:00 2001 From: MadameSheema Date: Thu, 26 Mar 2020 11:34:28 +0100 Subject: [PATCH 33/35] [SIEM] Adds 'Deleting prebuilt rules' tests (#61328) * implements 'Deleting prebuilt rules' tests * refactors code * extracts the number of prebuilt riles to a constant that can be used in any test --- .../signal_detection_rules_custom.spec.ts | 4 +- .../signal_detection_rules_ml.spec.ts | 4 +- .../signal_detection_rules_prebuilt.spec.ts | 123 +++++++++++++++++- .../plugins/siem/cypress/objects/rule.ts | 2 + .../cypress/screens/signal_detection_rules.ts | 12 ++ .../cypress/tasks/signal_detection_rules.ts | 42 +++++- .../rules/all/batch_actions.tsx | 1 + .../detection_engine/rules/all/columns.tsx | 1 + .../detection_engine/rules/all/index.tsx | 1 + .../pages/detection_engine/rules/index.tsx | 1 + 10 files changed, 177 insertions(+), 14 deletions(-) diff --git a/x-pack/legacy/plugins/siem/cypress/integration/signal_detection_rules_custom.spec.ts b/x-pack/legacy/plugins/siem/cypress/integration/signal_detection_rules_custom.spec.ts index 06ba4bed005c..3f509c35b64e 100644 --- a/x-pack/legacy/plugins/siem/cypress/integration/signal_detection_rules_custom.spec.ts +++ b/x-pack/legacy/plugins/siem/cypress/integration/signal_detection_rules_custom.spec.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { newRule } from '../objects/rule'; +import { newRule, totalNumberOfPrebuiltRules } from '../objects/rule'; import { ABOUT_FALSE_POSITIVES, @@ -83,7 +83,7 @@ describe('Signal detection rules, custom', () => { changeToThreeHundredRowsPerPage(); waitForRulesToBeLoaded(); - const expectedNumberOfRules = 93; + const expectedNumberOfRules = totalNumberOfPrebuiltRules + 1; cy.get(RULES_TABLE).then($table => { cy.wrap($table.find(RULES_ROW).length).should('eql', expectedNumberOfRules); }); diff --git a/x-pack/legacy/plugins/siem/cypress/integration/signal_detection_rules_ml.spec.ts b/x-pack/legacy/plugins/siem/cypress/integration/signal_detection_rules_ml.spec.ts index 99391fa73a75..db56193c6b51 100644 --- a/x-pack/legacy/plugins/siem/cypress/integration/signal_detection_rules_ml.spec.ts +++ b/x-pack/legacy/plugins/siem/cypress/integration/signal_detection_rules_ml.spec.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { machineLearningRule } from '../objects/rule'; +import { machineLearningRule, totalNumberOfPrebuiltRules } from '../objects/rule'; import { ABOUT_FALSE_POSITIVES, @@ -88,7 +88,7 @@ describe('Signal detection rules, machine learning', () => { changeToThreeHundredRowsPerPage(); waitForRulesToBeLoaded(); - const expectedNumberOfRules = 93; + const expectedNumberOfRules = totalNumberOfPrebuiltRules + 1; cy.get(RULES_TABLE).then($table => { cy.wrap($table.find(RULES_ROW).length).should('eql', expectedNumberOfRules); }); diff --git a/x-pack/legacy/plugins/siem/cypress/integration/signal_detection_rules_prebuilt.spec.ts b/x-pack/legacy/plugins/siem/cypress/integration/signal_detection_rules_prebuilt.spec.ts index 172f1dc91816..98af25cd7d20 100644 --- a/x-pack/legacy/plugins/siem/cypress/integration/signal_detection_rules_prebuilt.spec.ts +++ b/x-pack/legacy/plugins/siem/cypress/integration/signal_detection_rules_prebuilt.spec.ts @@ -4,11 +4,21 @@ * you may not use this file except in compliance with the Elastic License. */ -import { ELASTIC_RULES_BTN, RULES_ROW, RULES_TABLE } from '../screens/signal_detection_rules'; +import { + COLLAPSED_ACTION_BTN, + ELASTIC_RULES_BTN, + RELOAD_PREBUILT_RULES_BTN, + RULES_ROW, + RULES_TABLE, +} from '../screens/signal_detection_rules'; import { changeToThreeHundredRowsPerPage, + deleteFirstRule, + deleteSelectedRules, loadPrebuiltDetectionRules, + reloadDeletedRules, + selectNumberOfRules, waitForLoadElasticPrebuiltDetectionRulesTableToBeLoaded, waitForPrebuiltDetectionRulesToBeLoaded, waitForRulesToBeLoaded, @@ -18,11 +28,18 @@ import { waitForSignalsIndexToBeCreated, waitForSignalsPanelToBeLoaded, } from '../tasks/detections'; -import { esArchiverLoadEmptyKibana, esArchiverUnloadEmptyKibana } from '../tasks/es_archiver'; +import { + esArchiverLoad, + esArchiverLoadEmptyKibana, + esArchiverUnloadEmptyKibana, + esArchiverUnload, +} from '../tasks/es_archiver'; import { loginAndWaitForPageWithoutDateRange } from '../tasks/login'; import { DETECTIONS } from '../urls/navigation'; +import { totalNumberOfPrebuiltRules } from '../objects/rule'; + describe('Signal detection rules, prebuilt rules', () => { before(() => { esArchiverLoadEmptyKibana(); @@ -33,6 +50,9 @@ describe('Signal detection rules, prebuilt rules', () => { }); it('Loads prebuilt rules', () => { + const expectedNumberOfRules = totalNumberOfPrebuiltRules; + const expectedElasticRulesBtnText = `Elastic rules (${expectedNumberOfRules})`; + loginAndWaitForPageWithoutDateRange(DETECTIONS); waitForSignalsPanelToBeLoaded(); waitForSignalsIndexToBeCreated(); @@ -41,7 +61,6 @@ describe('Signal detection rules, prebuilt rules', () => { loadPrebuiltDetectionRules(); waitForPrebuiltDetectionRulesToBeLoaded(); - const expectedElasticRulesBtnText = 'Elastic rules (92)'; cy.get(ELASTIC_RULES_BTN) .invoke('text') .should('eql', expectedElasticRulesBtnText); @@ -49,9 +68,105 @@ describe('Signal detection rules, prebuilt rules', () => { changeToThreeHundredRowsPerPage(); waitForRulesToBeLoaded(); - const expectedNumberOfRules = 92; cy.get(RULES_TABLE).then($table => { cy.wrap($table.find(RULES_ROW).length).should('eql', expectedNumberOfRules); }); }); }); + +describe('Deleting prebuilt rules', () => { + beforeEach(() => { + esArchiverLoad('prebuilt_rules_loaded'); + loginAndWaitForPageWithoutDateRange(DETECTIONS); + waitForSignalsPanelToBeLoaded(); + waitForSignalsIndexToBeCreated(); + goToManageSignalDetectionRules(); + }); + + afterEach(() => { + esArchiverUnload('prebuilt_rules_loaded'); + }); + + it('Does not allow to delete one rule when more than one is selected', () => { + const numberOfRulesToBeSelected = 2; + selectNumberOfRules(numberOfRulesToBeSelected); + + cy.get(COLLAPSED_ACTION_BTN).each(collapsedItemActionBtn => { + cy.wrap(collapsedItemActionBtn).should('have.attr', 'disabled'); + }); + }); + + it('Deletes and recovers one rule', () => { + const expectedNumberOfRulesAfterDeletion = totalNumberOfPrebuiltRules - 1; + const expectedNumberOfRulesAfterRecovering = totalNumberOfPrebuiltRules; + + deleteFirstRule(); + cy.reload(); + changeToThreeHundredRowsPerPage(); + waitForRulesToBeLoaded(); + + cy.get(ELASTIC_RULES_BTN) + .invoke('text') + .should('eql', `Elastic rules (${expectedNumberOfRulesAfterDeletion})`); + cy.get(RULES_TABLE).then($table => { + cy.wrap($table.find(RULES_ROW).length).should('eql', expectedNumberOfRulesAfterDeletion); + }); + cy.get(RELOAD_PREBUILT_RULES_BTN).should('exist'); + cy.get(RELOAD_PREBUILT_RULES_BTN) + .invoke('text') + .should('eql', 'Reload 1 deleted Elastic prebuilt rule '); + + reloadDeletedRules(); + + cy.get(RELOAD_PREBUILT_RULES_BTN).should('not.exist'); + + cy.reload(); + changeToThreeHundredRowsPerPage(); + waitForRulesToBeLoaded(); + + cy.get(RULES_TABLE).then($table => { + cy.wrap($table.find(RULES_ROW).length).should('eql', expectedNumberOfRulesAfterRecovering); + }); + cy.get(ELASTIC_RULES_BTN) + .invoke('text') + .should('eql', `Elastic rules (${expectedNumberOfRulesAfterRecovering})`); + }); + + it('Deletes and recovers more than one rule', () => { + const numberOfRulesToBeSelected = 2; + const expectedNumberOfRulesAfterDeletion = totalNumberOfPrebuiltRules - 2; + const expectedNumberOfRulesAfterRecovering = totalNumberOfPrebuiltRules; + + selectNumberOfRules(numberOfRulesToBeSelected); + deleteSelectedRules(); + cy.reload(); + changeToThreeHundredRowsPerPage(); + waitForRulesToBeLoaded(); + + cy.get(RELOAD_PREBUILT_RULES_BTN).should('exist'); + cy.get(RELOAD_PREBUILT_RULES_BTN) + .invoke('text') + .should('eql', `Reload ${numberOfRulesToBeSelected} deleted Elastic prebuilt rules `); + cy.get(ELASTIC_RULES_BTN) + .invoke('text') + .should('eql', `Elastic rules (${expectedNumberOfRulesAfterDeletion})`); + cy.get(RULES_TABLE).then($table => { + cy.wrap($table.find(RULES_ROW).length).should('eql', expectedNumberOfRulesAfterDeletion); + }); + + reloadDeletedRules(); + + cy.get(RELOAD_PREBUILT_RULES_BTN).should('not.exist'); + + cy.reload(); + changeToThreeHundredRowsPerPage(); + waitForRulesToBeLoaded(); + + cy.get(RULES_TABLE).then($table => { + cy.wrap($table.find(RULES_ROW).length).should('eql', expectedNumberOfRulesAfterRecovering); + }); + cy.get(ELASTIC_RULES_BTN) + .invoke('text') + .should('eql', `Elastic rules (${expectedNumberOfRulesAfterRecovering})`); + }); +}); diff --git a/x-pack/legacy/plugins/siem/cypress/objects/rule.ts b/x-pack/legacy/plugins/siem/cypress/objects/rule.ts index a183da1de5d6..a3c648c9cc93 100644 --- a/x-pack/legacy/plugins/siem/cypress/objects/rule.ts +++ b/x-pack/legacy/plugins/siem/cypress/objects/rule.ts @@ -4,6 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ +export const totalNumberOfPrebuiltRules = 92; + interface Mitre { tactic: string; techniques: string[]; diff --git a/x-pack/legacy/plugins/siem/cypress/screens/signal_detection_rules.ts b/x-pack/legacy/plugins/siem/cypress/screens/signal_detection_rules.ts index 257671527934..65f24e3a765e 100644 --- a/x-pack/legacy/plugins/siem/cypress/screens/signal_detection_rules.ts +++ b/x-pack/legacy/plugins/siem/cypress/screens/signal_detection_rules.ts @@ -4,10 +4,18 @@ * you may not use this file except in compliance with the Elastic License. */ +export const BULK_ACTIONS_BTN = '[data-test-subj="bulkActions"] span'; + export const CREATE_NEW_RULE_BTN = '[data-test-subj="create-new-rule"]'; +export const COLLAPSED_ACTION_BTN = '[data-test-subj="euiCollapsedItemActionsButton"]'; + export const CUSTOM_RULES_BTN = '[data-test-subj="show-custom-rules-filter-button"]'; +export const DELETE_RULE_ACTION_BTN = '[data-test-subj="deleteRuleAction"]'; + +export const DELETE_RULE_BULK_BTN = '[data-test-subj="deleteRuleBulk"]'; + export const ELASTIC_RULES_BTN = '[data-test-subj="show-elastic-rules-filter-button"]'; export const LOAD_PREBUILT_RULES_BTN = '[data-test-subj="load-prebuilt-rules"]'; @@ -21,6 +29,10 @@ export const PAGINATION_POPOVER_BTN = '[data-test-subj="tablePaginationPopoverBu export const RISK_SCORE = '[data-test-subj="riskScore"]'; +export const RELOAD_PREBUILT_RULES_BTN = '[data-test-subj="reloadPrebuiltRulesBtn"]'; + +export const RULE_CHECKBOX = '.euiTableRow .euiCheckbox__input'; + export const RULE_NAME = '[data-test-subj="ruleName"]'; export const RULE_SWITCH = '[data-test-subj="rule-switch"]'; diff --git a/x-pack/legacy/plugins/siem/cypress/tasks/signal_detection_rules.ts b/x-pack/legacy/plugins/siem/cypress/tasks/signal_detection_rules.ts index 22e5f166b298..cfc490526d84 100644 --- a/x-pack/legacy/plugins/siem/cypress/tasks/signal_detection_rules.ts +++ b/x-pack/legacy/plugins/siem/cypress/tasks/signal_detection_rules.ts @@ -5,13 +5,21 @@ */ import { + BULK_ACTIONS_BTN, + COLLAPSED_ACTION_BTN, CREATE_NEW_RULE_BTN, + CUSTOM_RULES_BTN, + DELETE_RULE_ACTION_BTN, + DELETE_RULE_BULK_BTN, LOAD_PREBUILT_RULES_BTN, LOADING_INITIAL_PREBUILT_RULES_TABLE, LOADING_SPINNER, PAGINATION_POPOVER_BTN, + RULE_CHECKBOX, + RULE_NAME, RULES_TABLE, THREE_HUNDRED_ROWS, + RELOAD_PREBUILT_RULES_BTN, } from '../screens/signal_detection_rules'; export const changeToThreeHundredRowsPerPage = () => { @@ -19,10 +27,22 @@ export const changeToThreeHundredRowsPerPage = () => { cy.get(THREE_HUNDRED_ROWS).click(); }; +export const deleteFirstRule = () => { + cy.get(COLLAPSED_ACTION_BTN) + .first() + .click({ force: true }); + cy.get(DELETE_RULE_ACTION_BTN).click(); +}; + +export const deleteSelectedRules = () => { + cy.get(BULK_ACTIONS_BTN).click({ force: true }); + cy.get(DELETE_RULE_BULK_BTN).click(); +}; + export const filterByCustomRules = () => { - cy.get('[data-test-subj="show-custom-rules-filter-button"]').click({ force: true }); - cy.get('[data-test-subj="loading-spinner"]').should('exist'); - cy.get('[data-test-subj="loading-spinner"]').should('not.exist'); + cy.get(CUSTOM_RULES_BTN).click({ force: true }); + cy.get(LOADING_SPINNER).should('exist'); + cy.get(LOADING_SPINNER).should('not.exist'); }; export const goToCreateNewRule = () => { @@ -30,9 +50,7 @@ export const goToCreateNewRule = () => { }; export const goToRuleDetails = () => { - cy.get('[data-test-subj="ruleName"]').click({ force: true }); - cy.get('.euiLoadingSpinner').should('exist'); - cy.get('.euiLoadingSpinner').should('not.exist'); + cy.get(RULE_NAME).click({ force: true }); }; export const loadPrebuiltDetectionRules = () => { @@ -41,6 +59,18 @@ export const loadPrebuiltDetectionRules = () => { .click({ force: true }); }; +export const reloadDeletedRules = () => { + cy.get(RELOAD_PREBUILT_RULES_BTN).click({ force: true }); +}; + +export const selectNumberOfRules = (numberOfRules: number) => { + for (let i = 0; i < numberOfRules; i++) { + cy.get(RULE_CHECKBOX) + .eq(i) + .click({ force: true }); + } +}; + export const waitForLoadElasticPrebuiltDetectionRulesTableToBeLoaded = () => { cy.get(LOADING_INITIAL_PREBUILT_RULES_TABLE).should('exist'); cy.get(LOADING_INITIAL_PREBUILT_RULES_TABLE).should('not.exist'); diff --git a/x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/all/batch_actions.tsx b/x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/all/batch_actions.tsx index a0942d7f6534..60ad68b8c914 100644 --- a/x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/all/batch_actions.tsx +++ b/x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/all/batch_actions.tsx @@ -108,6 +108,7 @@ export const getBatchItems = ({ {i18n.BATCH_ACTION_DUPLICATE_SELECTED} , !rowItem.immutable, }, { + 'data-test-subj': 'deleteRuleAction', description: i18n.DELETE_RULE, icon: 'trash', name: i18n.DELETE_RULE, diff --git a/x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/all/index.tsx b/x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/all/index.tsx index 1a0de4672931..8458b3236852 100644 --- a/x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/all/index.tsx +++ b/x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/all/index.tsx @@ -307,6 +307,7 @@ export const AllRules = React.memo( {i18n.SELECTED_RULES(selectedRuleIds.length)} {!hasNoPermissions && ( { {prePackagedRuleStatus === 'someRuleUninstall' && ( Date: Thu, 26 Mar 2020 10:49:41 +0000 Subject: [PATCH 34/35] [APM] Link preview breaks when editing a custom link (#61053) * refactoring custom link server side * refactoring custom link server side * fixing pr comments * fixing unit test * fixing unit tests * renaming server directory Co-authored-by: Elastic Machine --- .../CustomLinkFlyout/FiltersSection.tsx | 31 ++-- .../CustomLinkFlyout/LinkPreview.test.tsx | 64 ++++---- .../CustomLinkFlyout/LinkPreview.tsx | 31 ++-- .../CustomLinkFlyout/LinkSection.tsx | 2 +- .../CustomLinkFlyout/helper.test.ts | 90 ++---------- .../CustomLink/CustomLinkFlyout/helper.ts | 94 +++--------- .../CustomLink/CustomLinkFlyout/index.tsx | 13 +- .../CustomLinkFlyout/saveCustomLink.ts | 11 +- .../CustomLink/CustomLinkTable.tsx | 2 +- .../CustomizeUI/CustomLink/index.test.tsx | 34 ++--- .../Settings/CustomizeUI/CustomLink/index.tsx | 2 +- .../CustomLink/CustomLinkPopover.test.tsx | 2 +- .../CustomLink/CustomLinkPopover.tsx | 2 +- .../CustomLink/CustomLinkSection.test.tsx | 2 +- .../CustomLink/CustomLinkSection.tsx | 2 +- .../CustomLink/index.test.tsx | 2 +- .../CustomLink/index.tsx | 2 +- .../TransactionActionMenu.tsx | 27 ++-- .../custom_link/custom_link_filter_options.ts | 18 +++ .../common/custom_link/custom_link_types.d.ts | 39 +++++ .../apm/common/custom_link_filter_options.ts | 28 ---- .../get_transaction.test.ts.snap | 44 +++--- .../list_custom_links.test.ts.snap | 0 .../create_or_update_custom_link.test.ts | 22 +-- .../create_or_update_custom_link.ts | 14 +- .../custom_link/custom_link_types.d.ts | 14 -- .../settings/custom_link/custom_link_types.ts | 46 ++++++ .../{__test__ => }/get_transaction.test.ts | 19 +-- .../settings/custom_link/get_transaction.ts | 38 +++-- .../lib/settings/custom_link/helper.test.ts | 137 ++++++++++++++++++ .../server/lib/settings/custom_link/helper.ts | 46 ++++++ .../{__test__ => }/list_custom_links.test.ts | 8 +- .../settings/custom_link/list_custom_links.ts | 28 ++-- .../apm/server/routes/settings/custom_link.ts | 39 ++--- 34 files changed, 556 insertions(+), 397 deletions(-) create mode 100644 x-pack/plugins/apm/common/custom_link/custom_link_filter_options.ts create mode 100644 x-pack/plugins/apm/common/custom_link/custom_link_types.d.ts delete mode 100644 x-pack/plugins/apm/common/custom_link_filter_options.ts rename x-pack/plugins/apm/server/lib/settings/custom_link/{__test__ => }/__snapshots__/get_transaction.test.ts.snap (59%) rename x-pack/plugins/apm/server/lib/settings/custom_link/{__test__ => }/__snapshots__/list_custom_links.test.ts.snap (100%) rename x-pack/plugins/apm/server/lib/settings/custom_link/{__test__ => }/create_or_update_custom_link.test.ts (72%) delete mode 100644 x-pack/plugins/apm/server/lib/settings/custom_link/custom_link_types.d.ts create mode 100644 x-pack/plugins/apm/server/lib/settings/custom_link/custom_link_types.ts rename x-pack/plugins/apm/server/lib/settings/custom_link/{__test__ => }/get_transaction.test.ts (64%) create mode 100644 x-pack/plugins/apm/server/lib/settings/custom_link/helper.test.ts create mode 100644 x-pack/plugins/apm/server/lib/settings/custom_link/helper.ts rename x-pack/plugins/apm/server/lib/settings/custom_link/{__test__ => }/list_custom_links.test.ts (79%) diff --git a/x-pack/legacy/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CustomLinkFlyout/FiltersSection.tsx b/x-pack/legacy/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CustomLinkFlyout/FiltersSection.tsx index 1c253b2fa8bf..fdef9e1f5b7e 100644 --- a/x-pack/legacy/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CustomLinkFlyout/FiltersSection.tsx +++ b/x-pack/legacy/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CustomLinkFlyout/FiltersSection.tsx @@ -16,10 +16,12 @@ import { import { i18n } from '@kbn/i18n'; import { isEmpty } from 'lodash'; import React from 'react'; -import { FilterOptions } from '../../../../../../../../../../plugins/apm/common/custom_link_filter_options'; +import { + Filter, + FilterKey +} from '../../../../../../../../../../plugins/apm/common/custom_link/custom_link_types'; import { DEFAULT_OPTION, - FilterKeyValue, FILTER_SELECT_OPTIONS, getSelectOptions } from './helper'; @@ -28,12 +30,16 @@ export const FiltersSection = ({ filters, onChangeFilters }: { - filters: FilterKeyValue[]; - onChangeFilters: (filters: FilterKeyValue[]) => void; + filters: Filter[]; + onChangeFilters: (filters: Filter[]) => void; }) => { - const onChangeFilter = (filter: FilterKeyValue, idx: number) => { + const onChangeFilter = ( + key: Filter['key'], + value: Filter['value'], + idx: number + ) => { const newFilters = [...filters]; - newFilters[idx] = filter; + newFilters[idx] = { key, value }; onChangeFilters(newFilters); }; @@ -45,14 +51,14 @@ export const FiltersSection = ({ // if there is only one item left it should not be removed // but reset to empty if (isEmpty(newFilters)) { - onChangeFilters([['', '']]); + onChangeFilters([{ key: '', value: '' }]); } else { onChangeFilters(newFilters); } }; const handleAddFilter = () => { - onChangeFilters([...filters, ['', '']]); + onChangeFilters([...filters, { key: '', value: '' }]); }; return ( @@ -81,7 +87,7 @@ export const FiltersSection = ({ {filters.map((filter, idx) => { - const [key, value] = filter; + const { key, value } = filter; const filterId = `filter-${idx}`; const selectOptions = getSelectOptions(filters, key); return ( @@ -100,10 +106,7 @@ export const FiltersSection = ({ } )} onChange={e => - onChangeFilter( - [e.target.value as keyof FilterOptions, value], - idx - ) + onChangeFilter(e.target.value as FilterKey, value, idx) } isInvalid={ !isEmpty(value) && @@ -119,7 +122,7 @@ export const FiltersSection = ({ 'xpack.apm.settings.customizeUI.customLink.flyOut.filters.defaultOption.value', { defaultMessage: 'Value' } )} - onChange={e => onChangeFilter([key, e.target.value], idx)} + onChange={e => onChangeFilter(key, e.target.value, idx)} value={value} isInvalid={!isEmpty(key) && isEmpty(value)} /> diff --git a/x-pack/legacy/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CustomLinkFlyout/LinkPreview.test.tsx b/x-pack/legacy/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CustomLinkFlyout/LinkPreview.test.tsx index 9b487cf91608..2f4d9a4c4016 100644 --- a/x-pack/legacy/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CustomLinkFlyout/LinkPreview.test.tsx +++ b/x-pack/legacy/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CustomLinkFlyout/LinkPreview.test.tsx @@ -5,7 +5,7 @@ */ import React from 'react'; import { LinkPreview } from '../CustomLinkFlyout/LinkPreview'; -import { render, getNodeText, getByTestId } from '@testing-library/react'; +import { render, getNodeText, getByTestId, act } from '@testing-library/react'; describe('LinkPreview', () => { const getElementValue = (container: HTMLElement, id: string) => @@ -15,37 +15,47 @@ describe('LinkPreview', () => { ); it('shows label and url default values', () => { - const { container } = render( - - ); - expect(getElementValue(container, 'preview-label')).toEqual('Elastic.co'); - expect(getElementValue(container, 'preview-url')).toEqual( - 'https://www.elastic.co' - ); + act(() => { + const { container } = render( + + ); + expect(getElementValue(container, 'preview-label')).toEqual('Elastic.co'); + expect(getElementValue(container, 'preview-url')).toEqual( + 'https://www.elastic.co' + ); + }); }); it('shows label and url values', () => { - const { container } = render( - - ); - expect(getElementValue(container, 'preview-label')).toEqual('foo'); - expect( - (getByTestId(container, 'preview-link') as HTMLAnchorElement).text - ).toEqual('https://baz.co'); + act(() => { + const { container } = render( + + ); + expect(getElementValue(container, 'preview-label')).toEqual('foo'); + expect( + (getByTestId(container, 'preview-link') as HTMLAnchorElement).text + ).toEqual('https://baz.co'); + }); }); it('shows warning when couldnt replace context variables', () => { - const { container } = render( - - ); - expect(getElementValue(container, 'preview-label')).toEqual('foo'); - expect( - (getByTestId(container, 'preview-link') as HTMLAnchorElement).text - ).toEqual('https://baz.co?service.name={{invalid}'); - expect(getByTestId(container, 'preview-warning')).toBeInTheDocument(); + act(() => { + const { container } = render( + + ); + expect(getElementValue(container, 'preview-label')).toEqual('foo'); + expect( + (getByTestId(container, 'preview-link') as HTMLAnchorElement).text + ).toEqual('https://baz.co?service.name={{invalid}'); + expect(getByTestId(container, 'preview-warning')).toBeInTheDocument(); + }); }); }); diff --git a/x-pack/legacy/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CustomLinkFlyout/LinkPreview.tsx b/x-pack/legacy/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CustomLinkFlyout/LinkPreview.tsx index 0ad3455ab271..8edfb176a1af 100644 --- a/x-pack/legacy/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CustomLinkFlyout/LinkPreview.tsx +++ b/x-pack/legacy/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CustomLinkFlyout/LinkPreview.tsx @@ -17,28 +17,22 @@ import { } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { debounce } from 'lodash'; +import { Filter } from '../../../../../../../../../../plugins/apm/common/custom_link/custom_link_types'; import { Transaction } from '../../../../../../../../../../plugins/apm/typings/es_schemas/ui/transaction'; import { callApmApi } from '../../../../../../services/rest/createCallApmApi'; -import { - FilterKeyValue, - convertFiltersToObject, - replaceTemplateVariables -} from './helper'; +import { replaceTemplateVariables, convertFiltersToQuery } from './helper'; interface Props { label: string; url: string; - filters: FilterKeyValue[]; + filters: Filter[]; } const fetchTransaction = debounce( - async ( - filters: FilterKeyValue[], - callback: (transaction: Transaction) => void - ) => { + async (filters: Filter[], callback: (transaction: Transaction) => void) => { const transaction = await callApmApi({ pathname: '/api/apm/settings/custom_links/transaction', - params: { query: convertFiltersToObject(filters) } + params: { query: convertFiltersToQuery(filters) } }); callback(transaction); }, @@ -51,7 +45,20 @@ export const LinkPreview = ({ label, url, filters }: Props) => { const [transaction, setTransaction] = useState(); useEffect(() => { - fetchTransaction(filters, setTransaction); + /* + React throwns "Can't perform a React state update on an unmounted component" + It happens when the Custom Link flyout is closed before the return of the api request. + To avoid such case, sets the isUnmounted to true when component unmount and check its value before update the transaction. + */ + let isUnmounted = false; + fetchTransaction(filters, (_transaction: Transaction) => { + if (!isUnmounted) { + setTransaction(_transaction); + } + }); + return () => { + isUnmounted = true; + }; }, [filters]); const { formattedUrl, error } = replaceTemplateVariables(url, transaction); diff --git a/x-pack/legacy/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CustomLinkFlyout/LinkSection.tsx b/x-pack/legacy/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CustomLinkFlyout/LinkSection.tsx index 8bcebc2aea09..630f7148ad40 100644 --- a/x-pack/legacy/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CustomLinkFlyout/LinkSection.tsx +++ b/x-pack/legacy/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CustomLinkFlyout/LinkSection.tsx @@ -12,7 +12,7 @@ import { } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import React from 'react'; -import { CustomLink } from '../../../../../../../../../../plugins/apm/server/lib/settings/custom_link/custom_link_types'; +import { CustomLink } from '../../../../../../../../../../plugins/apm/common/custom_link/custom_link_types'; import { Documentation } from './Documentation'; interface InputField { diff --git a/x-pack/legacy/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CustomLinkFlyout/helper.test.ts b/x-pack/legacy/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CustomLinkFlyout/helper.test.ts index ac01ee48f2fe..0a63cfcff9aa 100644 --- a/x-pack/legacy/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CustomLinkFlyout/helper.test.ts +++ b/x-pack/legacy/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CustomLinkFlyout/helper.test.ts @@ -4,79 +4,21 @@ * you may not use this file except in compliance with the Elastic License. */ import { - convertFiltersToArray, - convertFiltersToObject, getSelectOptions, replaceTemplateVariables } from '../CustomLinkFlyout/helper'; -import { CustomLink } from '../../../../../../../../../../plugins/apm/server/lib/settings/custom_link/custom_link_types'; import { Transaction } from '../../../../../../../../../../plugins/apm/typings/es_schemas/ui/transaction'; describe('Custom link helper', () => { - describe('convertFiltersToArray', () => { - it('returns array of tuple when custom link not defined', () => { - expect(convertFiltersToArray()).toEqual([['', '']]); - }); - it('returns filters as array', () => { - expect( - convertFiltersToArray({ - 'service.name': 'foo', - 'transaction.type': 'bar' - } as CustomLink) - ).toEqual([ - ['service.name', 'foo'], - ['transaction.type', 'bar'] - ]); - }); - it('returns empty when no filter is added', () => { - expect( - convertFiltersToArray({ - label: 'foo', - url: 'bar' - } as CustomLink) - ).toEqual([['', '']]); - }); - }); - - describe('convertFiltersToObject', () => { - it('returns undefined when any filter is added', () => { - expect(convertFiltersToObject([['', '']])).toBeUndefined(); - }); - it('removes uncompleted filters', () => { - expect( - convertFiltersToObject([ - ['service.name', ''], - ['', 'foo'], - ['transaction.type', 'bar'] - ]) - ).toEqual({ 'transaction.type': ['bar'] }); - }); - it('splits the value by comma', () => { - expect( - convertFiltersToObject([ - ['service.name', 'foo'], - ['service.environment', 'foo, bar'], - ['transaction.type', 'foo, '], - ['transaction.name', 'foo,'] - ]) - ).toEqual({ - 'service.name': ['foo'], - 'service.environment': ['foo', 'bar'], - 'transaction.type': ['foo'], - 'transaction.name': ['foo'] - }); - }); - }); - describe('getSelectOptions', () => { it('returns all available options when no filters were selected', () => { expect( getSelectOptions( [ - ['', ''], - ['', ''], - ['', ''], - ['', ''] + { key: '', value: '' }, + { key: '', value: '' }, + { key: '', value: '' }, + { key: '', value: '' } ], '' ) @@ -92,10 +34,10 @@ describe('Custom link helper', () => { expect( getSelectOptions( [ - ['service.name', 'foo'], - ['', ''], - ['', ''], - ['', ''] + { key: 'service.name', value: 'foo' }, + { key: '', value: '' }, + { key: '', value: '' }, + { key: '', value: '' } ], '' ) @@ -110,10 +52,10 @@ describe('Custom link helper', () => { expect( getSelectOptions( [ - ['service.name', 'foo'], - ['transaction.name', 'bar'], - ['', ''], - ['', ''] + { key: 'service.name', value: 'foo' }, + { key: 'transaction.name', value: 'bar' }, + { key: '', value: '' }, + { key: '', value: '' } ], 'transaction.name' ) @@ -128,10 +70,10 @@ describe('Custom link helper', () => { expect( getSelectOptions( [ - ['service.name', 'foo'], - ['transaction.name', 'bar'], - ['service.environment', 'baz'], - ['transaction.type', 'qux'] + { key: 'service.name', value: 'foo' }, + { key: 'transaction.name', value: 'bar' }, + { key: 'service.environment', value: 'baz' }, + { key: 'transaction.type', value: 'qux' } ], '' ) diff --git a/x-pack/legacy/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CustomLinkFlyout/helper.ts b/x-pack/legacy/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CustomLinkFlyout/helper.ts index df99c82c71b7..7bfdbf1655e0 100644 --- a/x-pack/legacy/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CustomLinkFlyout/helper.ts +++ b/x-pack/legacy/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CustomLinkFlyout/helper.ts @@ -5,80 +5,19 @@ */ import { i18n } from '@kbn/i18n'; import Mustache from 'mustache'; -import { isEmpty, pick, get } from 'lodash'; -import { Transaction } from '../../../../../../../../../../plugins/apm/typings/es_schemas/ui/transaction'; +import { isEmpty, get } from 'lodash'; +import { FILTER_OPTIONS } from '../../../../../../../../../../plugins/apm/common/custom_link/custom_link_filter_options'; import { - FilterOptions, - FILTER_OPTIONS -} from '../../../../../../../../../../plugins/apm/common/custom_link_filter_options'; -import { CustomLink } from '../../../../../../../../../../plugins/apm/server/lib/settings/custom_link/custom_link_types'; - -type FilterKey = keyof FilterOptions | ''; -type FilterValue = string; -export type FilterKeyValue = [FilterKey, FilterValue]; + Filter, + FilterKey +} from '../../../../../../../../../../plugins/apm/common/custom_link/custom_link_types'; +import { Transaction } from '../../../../../../../../../../plugins/apm/typings/es_schemas/ui/transaction'; interface FilterSelectOption { - value: 'DEFAULT' | keyof FilterOptions; + value: 'DEFAULT' | FilterKey; text: string; } -/** - * Converts available filters from the Custom Link to Array of filters. - * e.g. - * customLink = { - * id: '1', - * label: 'foo', - * url: 'http://www.elastic.co', - * service.name: 'opbeans-java', - * transaction.type: 'request' - * } - * - * results: [['service.name', 'opbeans-java'],['transaction.type', 'request']] - * @param customLink - */ -export const convertFiltersToArray = ( - customLink?: CustomLink -): FilterKeyValue[] => { - if (customLink) { - const filters = Object.entries( - pick(customLink, FILTER_OPTIONS) - ) as FilterKeyValue[]; - if (!isEmpty(filters)) { - return filters; - } - } - return [['', '']]; -}; - -/** - * Converts array of filters into object. - * e.g. - * filters: [['service.name', 'opbeans-java'],['transaction.type', 'request']] - * - * results: { - * 'service.name': 'opbeans-java', - * 'transaction.type': 'request' - * } - * @param filters - */ -export const convertFiltersToObject = (filters: FilterKeyValue[]) => { - const convertedFilters = Object.fromEntries( - filters - .filter(([key, value]) => !isEmpty(key) && !isEmpty(value)) - .map(([key, value]) => [ - key, - // Splits the value by comma, removes whitespace from both ends and filters out empty values - value - .split(',') - .map(v => v.trim()) - .filter(v => v) - ]) - ); - if (!isEmpty(convertedFilters)) { - return convertedFilters; - } -}; - export const DEFAULT_OPTION: FilterSelectOption = { value: 'DEFAULT', text: i18n.translate( @@ -90,7 +29,7 @@ export const DEFAULT_OPTION: FilterSelectOption = { export const FILTER_SELECT_OPTIONS: FilterSelectOption[] = [ DEFAULT_OPTION, ...FILTER_OPTIONS.map(filter => ({ - value: filter as keyof FilterOptions, + value: filter, text: filter })) ]; @@ -102,14 +41,12 @@ export const FILTER_SELECT_OPTIONS: FilterSelectOption[] = [ * @param selectedKey */ export const getSelectOptions = ( - filters: FilterKeyValue[], - selectedKey: FilterKey + filters: Filter[], + selectedKey: Filter['key'] ) => { return FILTER_SELECT_OPTIONS.filter( ({ value }) => - !filters.some( - ([filterKey]) => filterKey === value && filterKey !== selectedKey - ) + !filters.some(({ key }) => key === value && key !== selectedKey) ); }; @@ -172,3 +109,12 @@ export const replaceTemplateVariables = ( return { formattedUrl: url, error }; } }; + +export const convertFiltersToQuery = (filters: Filter[]) => { + return filters.reduce((acc: Record, { key, value }) => { + if (key && value) { + acc[key] = value; + } + return acc; + }, {}); +}; diff --git a/x-pack/legacy/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CustomLinkFlyout/index.tsx b/x-pack/legacy/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CustomLinkFlyout/index.tsx index 68755bad5f65..7412eb457786 100644 --- a/x-pack/legacy/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CustomLinkFlyout/index.tsx +++ b/x-pack/legacy/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CustomLinkFlyout/index.tsx @@ -14,13 +14,15 @@ import { } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import React, { useState } from 'react'; -import { CustomLink } from '../../../../../../../../../../plugins/apm/server/lib/settings/custom_link/custom_link_types'; +import { + CustomLink, + Filter +} from '../../../../../../../../../../plugins/apm/common/custom_link/custom_link_types'; import { useApmPluginContext } from '../../../../../../hooks/useApmPluginContext'; import { FiltersSection } from './FiltersSection'; import { FlyoutFooter } from './FlyoutFooter'; import { LinkSection } from './LinkSection'; import { saveCustomLink } from './saveCustomLink'; -import { convertFiltersToArray, convertFiltersToObject } from './helper'; import { LinkPreview } from './LinkPreview'; import { Documentation } from './Documentation'; @@ -42,8 +44,11 @@ export const CustomLinkFlyout = ({ const [label, setLabel] = useState(customLinkSelected?.label || ''); const [url, setUrl] = useState(customLinkSelected?.url || ''); + const selectedFilters = customLinkSelected?.filters; const [filters, setFilters] = useState( - convertFiltersToArray(customLinkSelected) + selectedFilters?.length + ? selectedFilters + : ([{ key: '', value: '' }] as Filter[]) ); const isFormValid = !!label && !!url; @@ -59,7 +64,7 @@ export const CustomLinkFlyout = ({ id: customLinkSelected?.id, label, url, - filters: convertFiltersToObject(filters), + filters, toasts }); setIsSaving(false); diff --git a/x-pack/legacy/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CustomLinkFlyout/saveCustomLink.ts b/x-pack/legacy/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CustomLinkFlyout/saveCustomLink.ts index 815ce1d95c38..9cbaf16320a6 100644 --- a/x-pack/legacy/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CustomLinkFlyout/saveCustomLink.ts +++ b/x-pack/legacy/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CustomLinkFlyout/saveCustomLink.ts @@ -6,6 +6,10 @@ import { i18n } from '@kbn/i18n'; import { NotificationsStart } from 'kibana/public'; +import { + Filter, + CustomLink +} from '../../../../../../../../../../plugins/apm/common/custom_link/custom_link_types'; import { callApmApi } from '../../../../../../services/rest/createCallApmApi'; export async function saveCustomLink({ @@ -18,15 +22,16 @@ export async function saveCustomLink({ id?: string; label: string; url: string; - filters?: { [key: string]: string[] }; + filters: Filter[]; toasts: NotificationsStart['toasts']; }) { try { - const customLink = { + const customLink: CustomLink = { label, url, - ...filters + filters: filters.filter(({ key, value }) => key && value) }; + if (id) { await callApmApi({ pathname: '/api/apm/settings/custom_links/{id}', diff --git a/x-pack/legacy/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CustomLinkTable.tsx b/x-pack/legacy/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CustomLinkTable.tsx index f7d8c4baa71e..68e6ee52af0b 100644 --- a/x-pack/legacy/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CustomLinkTable.tsx +++ b/x-pack/legacy/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CustomLinkTable.tsx @@ -13,8 +13,8 @@ import { EuiSpacer } from '@elastic/eui'; import { isEmpty } from 'lodash'; +import { CustomLink } from '../../../../../../../../../plugins/apm/common/custom_link/custom_link_types'; import { units, px } from '../../../../../style/variables'; -import { CustomLink } from '../../../../../../../../../plugins/apm/server/lib/settings/custom_link/custom_link_types'; import { ManagedTable } from '../../../../shared/ManagedTable'; import { TimestampTooltip } from '../../../../shared/TimestampTooltip'; import { LoadingStatePrompt } from '../../../../shared/LoadingStatePrompt'; diff --git a/x-pack/legacy/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/index.test.tsx b/x-pack/legacy/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/index.test.tsx index b5bee5a5a1eb..0c04b7cccbd2 100644 --- a/x-pack/legacy/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/index.test.tsx +++ b/x-pack/legacy/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/index.test.tsx @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { fireEvent, render, wait } from '@testing-library/react'; +import { fireEvent, render, wait, RenderResult } from '@testing-library/react'; import React from 'react'; import { act } from 'react-dom/test-utils'; import * as apmApi from '../../../../../services/rest/createCallApmApi'; @@ -71,20 +71,6 @@ describe('CustomLink', () => { ); expectTextsInDocument(component, ['No links found.']); }); - it('opens flyout when click to create new link', () => { - const { queryByText, getByText } = render( - - - - - - ); - expect(queryByText('Create link')).not.toBeInTheDocument(); - act(() => { - fireEvent.click(getByText('Create custom link')); - }); - expect(queryByText('Create link')).toBeInTheDocument(); - }); }); describe('overview', () => { @@ -146,7 +132,7 @@ describe('CustomLink', () => { jest.resetAllMocks(); }); - const openFlyout = () => { + const openFlyout = async () => { const component = render( @@ -158,12 +144,13 @@ describe('CustomLink', () => { act(() => { fireEvent.click(component.getByText('Create custom link')); }); + await wait(() => component.queryByText('Create link')); expect(component.queryByText('Create link')).toBeInTheDocument(); return component; }; it('creates a custom link', async () => { - const component = openFlyout(); + const component = await openFlyout(); const labelInput = component.getByTestId('label'); act(() => { fireEvent.change(labelInput, { @@ -205,16 +192,13 @@ describe('CustomLink', () => { }); describe('Filters', () => { - const addFilterField = ( - component: ReturnType, - amount: number - ) => { + const addFilterField = (component: RenderResult, amount: number) => { for (let i = 1; i <= amount; i++) { fireEvent.click(component.getByText('Add another filter')); } }; - it('checks if add filter button is disabled after all elements have been added', () => { - const component = openFlyout(); + it('checks if add filter button is disabled after all elements have been added', async () => { + const component = await openFlyout(); expect(component.getAllByText('service.name').length).toEqual(1); addFilterField(component, 1); expect(component.getAllByText('service.name').length).toEqual(2); @@ -224,8 +208,8 @@ describe('CustomLink', () => { addFilterField(component, 2); expect(component.getAllByText('service.name').length).toEqual(4); }); - it('removes items already selected', () => { - const component = openFlyout(); + it('removes items already selected', async () => { + const component = await openFlyout(); const addFieldAndCheck = ( fieldName: string, diff --git a/x-pack/legacy/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/index.tsx b/x-pack/legacy/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/index.tsx index a4985d441069..47990bf9233f 100644 --- a/x-pack/legacy/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/index.tsx +++ b/x-pack/legacy/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/index.tsx @@ -8,8 +8,8 @@ import { EuiPanel, EuiSpacer, EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; import { isEmpty } from 'lodash'; import React, { useEffect, useState } from 'react'; import { i18n } from '@kbn/i18n'; +import { CustomLink } from '../../../../../../../../../plugins/apm/common/custom_link/custom_link_types'; import { useLicense } from '../../../../../hooks/useLicense'; -import { CustomLink } from '../../../../../../../../../plugins/apm/server/lib/settings/custom_link/custom_link_types'; import { useFetcher, FETCH_STATUS } from '../../../../../hooks/useFetcher'; import { CustomLinkFlyout } from './CustomLinkFlyout'; import { CustomLinkTable } from './CustomLinkTable'; diff --git a/x-pack/legacy/plugins/apm/public/components/shared/TransactionActionMenu/CustomLink/CustomLinkPopover.test.tsx b/x-pack/legacy/plugins/apm/public/components/shared/TransactionActionMenu/CustomLink/CustomLinkPopover.test.tsx index 99789ca2ecdf..8df6d952cfac 100644 --- a/x-pack/legacy/plugins/apm/public/components/shared/TransactionActionMenu/CustomLink/CustomLinkPopover.test.tsx +++ b/x-pack/legacy/plugins/apm/public/components/shared/TransactionActionMenu/CustomLink/CustomLinkPopover.test.tsx @@ -5,10 +5,10 @@ */ import React from 'react'; import { render, act, fireEvent } from '@testing-library/react'; -import { CustomLink } from '../../../../../../../../plugins/apm/server/lib/settings/custom_link/custom_link_types'; import { Transaction } from '../../../../../../../../plugins/apm/typings/es_schemas/ui/transaction'; import { CustomLinkPopover } from './CustomLinkPopover'; import { expectTextsInDocument } from '../../../../utils/testHelpers'; +import { CustomLink } from '../../../../../../../../plugins/apm/common/custom_link/custom_link_types'; describe('CustomLinkPopover', () => { const customLinks = [ diff --git a/x-pack/legacy/plugins/apm/public/components/shared/TransactionActionMenu/CustomLink/CustomLinkPopover.tsx b/x-pack/legacy/plugins/apm/public/components/shared/TransactionActionMenu/CustomLink/CustomLinkPopover.tsx index ee4aa25606a0..a20bc7e21cfc 100644 --- a/x-pack/legacy/plugins/apm/public/components/shared/TransactionActionMenu/CustomLink/CustomLinkPopover.tsx +++ b/x-pack/legacy/plugins/apm/public/components/shared/TransactionActionMenu/CustomLink/CustomLinkPopover.tsx @@ -12,8 +12,8 @@ import { } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import styled from 'styled-components'; +import { CustomLink } from '../../../../../../../../plugins/apm/common/custom_link/custom_link_types'; import { Transaction } from '../../../../../../../../plugins/apm/typings/es_schemas/ui/transaction'; -import { CustomLink } from '../../../../../../../../plugins/apm/server/lib/settings/custom_link/custom_link_types'; import { CustomLinkSection } from './CustomLinkSection'; import { ManageCustomLink } from './ManageCustomLink'; import { px } from '../../../../style/variables'; diff --git a/x-pack/legacy/plugins/apm/public/components/shared/TransactionActionMenu/CustomLink/CustomLinkSection.test.tsx b/x-pack/legacy/plugins/apm/public/components/shared/TransactionActionMenu/CustomLink/CustomLinkSection.test.tsx index 4e52c302c602..d429fa56894e 100644 --- a/x-pack/legacy/plugins/apm/public/components/shared/TransactionActionMenu/CustomLink/CustomLinkSection.test.tsx +++ b/x-pack/legacy/plugins/apm/public/components/shared/TransactionActionMenu/CustomLink/CustomLinkSection.test.tsx @@ -5,13 +5,13 @@ */ import React from 'react'; import { render } from '@testing-library/react'; -import { CustomLink } from '../../../../../../../../plugins/apm/server/lib/settings/custom_link/custom_link_types'; import { CustomLinkSection } from './CustomLinkSection'; import { expectTextsInDocument, expectTextsNotInDocument } from '../../../../utils/testHelpers'; import { Transaction } from '../../../../../../../../plugins/apm/typings/es_schemas/ui/transaction'; +import { CustomLink } from '../../../../../../../../plugins/apm/common/custom_link/custom_link_types'; describe('CustomLinkSection', () => { const customLinks = [ diff --git a/x-pack/legacy/plugins/apm/public/components/shared/TransactionActionMenu/CustomLink/CustomLinkSection.tsx b/x-pack/legacy/plugins/apm/public/components/shared/TransactionActionMenu/CustomLink/CustomLinkSection.tsx index 601405dda6ec..52befe37ffda 100644 --- a/x-pack/legacy/plugins/apm/public/components/shared/TransactionActionMenu/CustomLink/CustomLinkSection.tsx +++ b/x-pack/legacy/plugins/apm/public/components/shared/TransactionActionMenu/CustomLink/CustomLinkSection.tsx @@ -5,8 +5,8 @@ */ import React from 'react'; import Mustache from 'mustache'; +import { CustomLink } from '../../../../../../../../plugins/apm/common/custom_link/custom_link_types'; import { Transaction } from '../../../../../../../../plugins/apm/typings/es_schemas/ui/transaction'; -import { CustomLink } from '../../../../../../../../plugins/apm/server/lib/settings/custom_link/custom_link_types'; import { SectionLinks, SectionLink diff --git a/x-pack/legacy/plugins/apm/public/components/shared/TransactionActionMenu/CustomLink/index.test.tsx b/x-pack/legacy/plugins/apm/public/components/shared/TransactionActionMenu/CustomLink/index.test.tsx index ba9c7eee8792..2dab8d63f99b 100644 --- a/x-pack/legacy/plugins/apm/public/components/shared/TransactionActionMenu/CustomLink/index.test.tsx +++ b/x-pack/legacy/plugins/apm/public/components/shared/TransactionActionMenu/CustomLink/index.test.tsx @@ -13,7 +13,7 @@ import { expectTextsInDocument, expectTextsNotInDocument } from '../../../../utils/testHelpers'; -import { CustomLink as CustomLinkType } from '../../../../../../../../plugins/apm/server/lib/settings/custom_link/custom_link_types'; +import { CustomLink as CustomLinkType } from '../../../../../../../../plugins/apm/common/custom_link/custom_link_types'; describe('Custom links', () => { it('shows empty message when no custom link is available', () => { diff --git a/x-pack/legacy/plugins/apm/public/components/shared/TransactionActionMenu/CustomLink/index.tsx b/x-pack/legacy/plugins/apm/public/components/shared/TransactionActionMenu/CustomLink/index.tsx index 9280f8e71bf9..b32d8f0d9582 100644 --- a/x-pack/legacy/plugins/apm/public/components/shared/TransactionActionMenu/CustomLink/index.tsx +++ b/x-pack/legacy/plugins/apm/public/components/shared/TransactionActionMenu/CustomLink/index.tsx @@ -15,8 +15,8 @@ import { import { i18n } from '@kbn/i18n'; import styled from 'styled-components'; import { isEmpty } from 'lodash'; +import { CustomLink as CustomLinkType } from '../../../../../../../../plugins/apm/common/custom_link/custom_link_types'; import { Transaction } from '../../../../../../../../plugins/apm/typings/es_schemas/ui/transaction'; -import { CustomLink as CustomLinkType } from '../../../../../../../../plugins/apm/server/lib/settings/custom_link/custom_link_types'; import { ActionMenuDivider, SectionSubtitle diff --git a/x-pack/legacy/plugins/apm/public/components/shared/TransactionActionMenu/TransactionActionMenu.tsx b/x-pack/legacy/plugins/apm/public/components/shared/TransactionActionMenu/TransactionActionMenu.tsx index e3c412f40ba3..0c5359e446ab 100644 --- a/x-pack/legacy/plugins/apm/public/components/shared/TransactionActionMenu/TransactionActionMenu.tsx +++ b/x-pack/legacy/plugins/apm/public/components/shared/TransactionActionMenu/TransactionActionMenu.tsx @@ -7,8 +7,10 @@ import { EuiButtonEmpty } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import React, { FunctionComponent, useMemo, useState } from 'react'; -import { FilterOptions } from '../../../../../../../plugins/apm/common/custom_link_filter_options'; -import { CustomLink as CustomLinkType } from '../../../../../../../plugins/apm/server/lib/settings/custom_link/custom_link_types'; +import { + CustomLink as CustomLinkType, + Filter +} from '../../../../../../../plugins/apm/common/custom_link/custom_link_types'; import { Transaction } from '../../../../../../../plugins/apm/typings/es_schemas/ui/transaction'; import { ActionMenu, @@ -29,6 +31,7 @@ import { CustomLinkPopover } from './CustomLink/CustomLinkPopover'; import { getSections } from './sections'; import { useLicense } from '../../../hooks/useLicense'; import { px } from '../../../style/variables'; +import { convertFiltersToQuery } from '../../app/Settings/CustomizeUI/CustomLink/CustomLinkFlyout/helper'; interface Props { readonly transaction: Transaction; @@ -58,20 +61,22 @@ export const TransactionActionMenu: FunctionComponent = ({ ); const [isCustomLinkFlyoutOpen, setIsCustomLinkFlyoutOpen] = useState(false); - const filters: FilterOptions = useMemo( - () => ({ - 'service.name': transaction?.service.name, - 'service.environment': transaction?.service.environment, - 'transaction.name': transaction?.transaction.name, - 'transaction.type': transaction?.transaction.type - }), + const filters = useMemo( + () => + [ + { key: 'service.name', value: transaction?.service.name }, + { key: 'service.environment', value: transaction?.service.environment }, + { key: 'transaction.name', value: transaction?.transaction.name }, + { key: 'transaction.type', value: transaction?.transaction.type } + ] as Filter[], [transaction] ); + const { data: customLinks = [], status, refetch } = useFetcher( callApmApi => callApmApi({ pathname: '/api/apm/settings/custom_links', - params: { query: filters } + params: { query: convertFiltersToQuery(filters) } }), [filters] ); @@ -95,7 +100,7 @@ export const TransactionActionMenu: FunctionComponent = ({ <> {isCustomLinkFlyoutOpen && ( { toggleCustomLinkFlyout(); diff --git a/x-pack/plugins/apm/common/custom_link/custom_link_filter_options.ts b/x-pack/plugins/apm/common/custom_link/custom_link_filter_options.ts new file mode 100644 index 000000000000..65d2877dabe9 --- /dev/null +++ b/x-pack/plugins/apm/common/custom_link/custom_link_filter_options.ts @@ -0,0 +1,18 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ +import { + SERVICE_NAME, + SERVICE_ENVIRONMENT, + TRANSACTION_NAME, + TRANSACTION_TYPE +} from '../elasticsearch_fieldnames'; + +export const FILTER_OPTIONS = [ + SERVICE_NAME, + SERVICE_ENVIRONMENT, + TRANSACTION_TYPE, + TRANSACTION_NAME +] as const; diff --git a/x-pack/plugins/apm/common/custom_link/custom_link_types.d.ts b/x-pack/plugins/apm/common/custom_link/custom_link_types.d.ts new file mode 100644 index 000000000000..ca5e47555495 --- /dev/null +++ b/x-pack/plugins/apm/common/custom_link/custom_link_types.d.ts @@ -0,0 +1,39 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { + SERVICE_NAME, + SERVICE_ENVIRONMENT, + TRANSACTION_NAME, + TRANSACTION_TYPE +} from '../elasticsearch_fieldnames'; +import { FILTER_OPTIONS } from './custom_link_filter_options'; + +export interface CustomLinkES { + id?: string; + '@timestamp'?: number; + label: string; + url: string; + [SERVICE_NAME]?: string[]; + [SERVICE_ENVIRONMENT]?: string[]; + [TRANSACTION_NAME]?: string[]; + [TRANSACTION_TYPE]?: string[]; +} + +export type FilterKey = typeof FILTER_OPTIONS[number]; + +export interface Filter { + key: FilterKey | ''; + value: string; +} + +export interface CustomLink { + id?: string; + '@timestamp'?: number; + label: string; + url: string; + filters?: Filter[]; +} diff --git a/x-pack/plugins/apm/common/custom_link_filter_options.ts b/x-pack/plugins/apm/common/custom_link_filter_options.ts deleted file mode 100644 index 32b19ad60a64..000000000000 --- a/x-pack/plugins/apm/common/custom_link_filter_options.ts +++ /dev/null @@ -1,28 +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; - * you may not use this file except in compliance with the Elastic License. - */ -import * as t from 'io-ts'; -import { - SERVICE_NAME, - SERVICE_ENVIRONMENT, - TRANSACTION_TYPE, - TRANSACTION_NAME -} from './elasticsearch_fieldnames'; - -export const FilterOptionsRt = t.partial({ - [SERVICE_NAME]: t.union([t.string, t.array(t.string)]), - [SERVICE_ENVIRONMENT]: t.union([t.string, t.array(t.string)]), - [TRANSACTION_NAME]: t.union([t.string, t.array(t.string)]), - [TRANSACTION_TYPE]: t.union([t.string, t.array(t.string)]) -}); - -export type FilterOptions = t.TypeOf; - -export const FILTER_OPTIONS: ReadonlyArray = [ - SERVICE_NAME, - SERVICE_ENVIRONMENT, - TRANSACTION_TYPE, - TRANSACTION_NAME -] as const; diff --git a/x-pack/plugins/apm/server/lib/settings/custom_link/__test__/__snapshots__/get_transaction.test.ts.snap b/x-pack/plugins/apm/server/lib/settings/custom_link/__snapshots__/get_transaction.test.ts.snap similarity index 59% rename from x-pack/plugins/apm/server/lib/settings/custom_link/__test__/__snapshots__/get_transaction.test.ts.snap rename to x-pack/plugins/apm/server/lib/settings/custom_link/__snapshots__/get_transaction.test.ts.snap index 16a270fd6d25..a91641b59252 100644 --- a/x-pack/plugins/apm/server/lib/settings/custom_link/__test__/__snapshots__/get_transaction.test.ts.snap +++ b/x-pack/plugins/apm/server/lib/settings/custom_link/__snapshots__/get_transaction.test.ts.snap @@ -8,22 +8,35 @@ Object { "filter": Array [ Object { "term": Object { - "service.name": "foo", + "processor.event": "transaction", }, }, Object { - "term": Object { - "service.environment": "bar", + "terms": Object { + "service.name": Array [ + "foo", + ], }, }, Object { - "term": Object { - "transaction.type": "qux", + "terms": Object { + "service.environment": Array [ + "bar", + ], }, }, Object { - "term": Object { - "transaction.name": "baz", + "terms": Object { + "transaction.name": Array [ + "baz", + ], + }, + }, + Object { + "terms": Object { + "transaction.type": Array [ + "qux", + ], }, }, ], @@ -37,21 +50,6 @@ Object { `; exports[`custom link get transaction fetches without filter 1`] = ` -Object { - "body": Object { - "query": Object { - "bool": Object { - "filter": Array [], - }, - }, - }, - "index": "myIndex", - "size": 1, - "terminateAfter": 1, -} -`; - -exports[`custom link get transaction removes not listed filters from query 1`] = ` Object { "body": Object { "query": Object { @@ -59,7 +57,7 @@ Object { "filter": Array [ Object { "term": Object { - "service.name": "foo", + "processor.event": "transaction", }, }, ], diff --git a/x-pack/plugins/apm/server/lib/settings/custom_link/__test__/__snapshots__/list_custom_links.test.ts.snap b/x-pack/plugins/apm/server/lib/settings/custom_link/__snapshots__/list_custom_links.test.ts.snap similarity index 100% rename from x-pack/plugins/apm/server/lib/settings/custom_link/__test__/__snapshots__/list_custom_links.test.ts.snap rename to x-pack/plugins/apm/server/lib/settings/custom_link/__snapshots__/list_custom_links.test.ts.snap diff --git a/x-pack/plugins/apm/server/lib/settings/custom_link/__test__/create_or_update_custom_link.test.ts b/x-pack/plugins/apm/server/lib/settings/custom_link/create_or_update_custom_link.test.ts similarity index 72% rename from x-pack/plugins/apm/server/lib/settings/custom_link/__test__/create_or_update_custom_link.test.ts rename to x-pack/plugins/apm/server/lib/settings/custom_link/create_or_update_custom_link.test.ts index 624f01c64932..9bd6c7879760 100644 --- a/x-pack/plugins/apm/server/lib/settings/custom_link/__test__/create_or_update_custom_link.test.ts +++ b/x-pack/plugins/apm/server/lib/settings/custom_link/create_or_update_custom_link.test.ts @@ -4,10 +4,10 @@ * you may not use this file except in compliance with the Elastic License. */ -import { createOrUpdateCustomLink } from '../create_or_update_custom_link'; -import { CustomLink } from '../custom_link_types'; -import { Setup } from '../../../helpers/setup_request'; -import { mockNow } from '../../../../../../../legacy/plugins/apm/public/utils/testHelpers'; +import { Setup } from '../../helpers/setup_request'; +import { mockNow } from '../../../../../../legacy/plugins/apm/public/utils/testHelpers'; +import { CustomLink } from '../../../../common/custom_link/custom_link_types'; +import { createOrUpdateCustomLink } from './create_or_update_custom_link'; describe('Create or Update Custom link', () => { const internalClientIndexMock = jest.fn(); @@ -23,8 +23,10 @@ describe('Create or Update Custom link', () => { const customLink = ({ label: 'foo', url: 'http://elastic.com/{{trace.id}}', - 'service.name': 'opbeans-java', - 'transaction.type': 'Request' + filters: [ + { key: 'service.name', value: 'opbeans-java' }, + { key: 'transaction.type', value: 'Request' } + ] } as unknown) as CustomLink; afterEach(() => { internalClientIndexMock.mockClear(); @@ -43,8 +45,8 @@ describe('Create or Update Custom link', () => { '@timestamp': 1570737000000, label: 'foo', url: 'http://elastic.com/{{trace.id}}', - 'service.name': 'opbeans-java', - 'transaction.type': 'Request' + 'service.name': ['opbeans-java'], + 'transaction.type': ['Request'] } }); }); @@ -62,8 +64,8 @@ describe('Create or Update Custom link', () => { '@timestamp': 1570737000000, label: 'foo', url: 'http://elastic.com/{{trace.id}}', - 'service.name': 'opbeans-java', - 'transaction.type': 'Request' + 'service.name': ['opbeans-java'], + 'transaction.type': ['Request'] } }); }); diff --git a/x-pack/plugins/apm/server/lib/settings/custom_link/create_or_update_custom_link.ts b/x-pack/plugins/apm/server/lib/settings/custom_link/create_or_update_custom_link.ts index 5dce371e4f30..d24fd9988997 100644 --- a/x-pack/plugins/apm/server/lib/settings/custom_link/create_or_update_custom_link.ts +++ b/x-pack/plugins/apm/server/lib/settings/custom_link/create_or_update_custom_link.ts @@ -4,11 +4,13 @@ * you may not use this file except in compliance with the Elastic License. */ -import { pick } from 'lodash'; -import { FILTER_OPTIONS } from '../../../../common/custom_link_filter_options'; +import { + CustomLink, + CustomLinkES +} from '../../../../common/custom_link/custom_link_types'; import { APMIndexDocumentParams } from '../../helpers/es_client'; import { Setup } from '../../helpers/setup_request'; -import { CustomLink } from './custom_link_types'; +import { toESFormat } from './helper'; export async function createOrUpdateCustomLink({ customLinkId, @@ -21,14 +23,12 @@ export async function createOrUpdateCustomLink({ }) { const { internalClient, indices } = setup; - const params: APMIndexDocumentParams = { + const params: APMIndexDocumentParams = { refresh: true, index: indices.apmCustomLinkIndex, body: { '@timestamp': Date.now(), - label: customLink.label, - url: customLink.url, - ...pick(customLink, FILTER_OPTIONS) + ...toESFormat(customLink) } }; diff --git a/x-pack/plugins/apm/server/lib/settings/custom_link/custom_link_types.d.ts b/x-pack/plugins/apm/server/lib/settings/custom_link/custom_link_types.d.ts deleted file mode 100644 index edb9eb35b902..000000000000 --- a/x-pack/plugins/apm/server/lib/settings/custom_link/custom_link_types.d.ts +++ /dev/null @@ -1,14 +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; - * you may not use this file except in compliance with the Elastic License. - */ -import * as t from 'io-ts'; -import { FilterOptions } from '../../../../common/custom_link_filter_options'; - -export type CustomLink = { - id?: string; - '@timestamp': number; - label: string; - url: string; -} & FilterOptions; diff --git a/x-pack/plugins/apm/server/lib/settings/custom_link/custom_link_types.ts b/x-pack/plugins/apm/server/lib/settings/custom_link/custom_link_types.ts new file mode 100644 index 000000000000..f35a72ff840f --- /dev/null +++ b/x-pack/plugins/apm/server/lib/settings/custom_link/custom_link_types.ts @@ -0,0 +1,46 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ +import * as t from 'io-ts'; +import { + SERVICE_NAME, + SERVICE_ENVIRONMENT, + TRANSACTION_NAME, + TRANSACTION_TYPE +} from '../../../../common/elasticsearch_fieldnames'; + +export interface CustomLinkES { + id?: string; + '@timestamp'?: number; + label: string; + url: string; + [SERVICE_NAME]?: string[]; + [SERVICE_ENVIRONMENT]?: string[]; + [TRANSACTION_NAME]?: string[]; + [TRANSACTION_TYPE]?: string[]; +} + +export const filterOptionsRt = t.partial({ + [SERVICE_NAME]: t.string, + [SERVICE_ENVIRONMENT]: t.string, + [TRANSACTION_NAME]: t.string, + [TRANSACTION_TYPE]: t.string +}); + +export const payloadRt = t.intersection([ + t.type({ + label: t.string, + url: t.string + }), + t.partial({ + id: t.string, + filters: t.array( + t.type({ + key: t.string, + value: t.string + }) + ) + }) +]); diff --git a/x-pack/plugins/apm/server/lib/settings/custom_link/__test__/get_transaction.test.ts b/x-pack/plugins/apm/server/lib/settings/custom_link/get_transaction.test.ts similarity index 64% rename from x-pack/plugins/apm/server/lib/settings/custom_link/__test__/get_transaction.test.ts rename to x-pack/plugins/apm/server/lib/settings/custom_link/get_transaction.test.ts index 4fc22298a476..514e473b8e78 100644 --- a/x-pack/plugins/apm/server/lib/settings/custom_link/__test__/get_transaction.test.ts +++ b/x-pack/plugins/apm/server/lib/settings/custom_link/get_transaction.test.ts @@ -6,29 +6,18 @@ import { inspectSearchParams, SearchParamsMock -} from '../../../../../../../legacy/plugins/apm/public/utils/testHelpers'; -import { getTransaction } from '../get_transaction'; -import { Setup } from '../../../helpers/setup_request'; +} from '../../../../../../legacy/plugins/apm/public/utils/testHelpers'; +import { getTransaction } from './get_transaction'; +import { Setup } from '../../helpers/setup_request'; import { SERVICE_NAME, TRANSACTION_TYPE, SERVICE_ENVIRONMENT, TRANSACTION_NAME -} from '../../../../../common/elasticsearch_fieldnames'; +} from '../../../../common/elasticsearch_fieldnames'; describe('custom link get transaction', () => { let mock: SearchParamsMock; - it('removes not listed filters from query', async () => { - mock = await inspectSearchParams(setup => - getTransaction({ - setup: (setup as unknown) as Setup, - // @ts-ignore ignoring the _debug is not part of filter options - filters: { _debug: true, [SERVICE_NAME]: 'foo' } - }) - ); - - expect(mock.params).toMatchSnapshot(); - }); it('fetches without filter', async () => { mock = await inspectSearchParams(setup => getTransaction({ diff --git a/x-pack/plugins/apm/server/lib/settings/custom_link/get_transaction.ts b/x-pack/plugins/apm/server/lib/settings/custom_link/get_transaction.ts index 396a7cb29f01..431034931878 100644 --- a/x-pack/plugins/apm/server/lib/settings/custom_link/get_transaction.ts +++ b/x-pack/plugins/apm/server/lib/settings/custom_link/get_transaction.ts @@ -3,35 +3,47 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ - -import { pick } from 'lodash'; -import { - FilterOptions, - FILTER_OPTIONS -} from '../../../../common/custom_link_filter_options'; +import * as t from 'io-ts'; +import { PROCESSOR_EVENT } from '../../../../common/elasticsearch_fieldnames'; import { Transaction } from '../../../../typings/es_schemas/ui/transaction'; import { Setup } from '../../helpers/setup_request'; +import { ProcessorEvent } from '../../../../common/processor_event'; +import { filterOptionsRt } from './custom_link_types'; +import { splitFilterValueByComma } from './helper'; export async function getTransaction({ setup, filters = {} }: { setup: Setup; - filters?: FilterOptions; + filters?: t.TypeOf; }) { const { client, indices } = setup; - const esFilters = Object.entries(pick(filters, FILTER_OPTIONS)).map( - ([key, value]) => { - return { term: { [key]: value } }; - } - ); + const esFilters = Object.entries(filters) + // loops through the filters splitting the value by comma and removing white spaces + .map(([key, value]) => { + if (value) { + return { terms: { [key]: splitFilterValueByComma(value) } }; + } + }) + // removes filters without value + .filter(value => value); const params = { terminateAfter: 1, index: indices['apm_oss.transactionIndices'], size: 1, - body: { query: { bool: { filter: esFilters } } } + body: { + query: { + bool: { + filter: [ + { term: { [PROCESSOR_EVENT]: ProcessorEvent.transaction } }, + ...esFilters + ] + } + } + } }; const resp = await client.search(params); return resp.hits.hits[0]?._source; diff --git a/x-pack/plugins/apm/server/lib/settings/custom_link/helper.test.ts b/x-pack/plugins/apm/server/lib/settings/custom_link/helper.test.ts new file mode 100644 index 000000000000..6ebf02fcc72d --- /dev/null +++ b/x-pack/plugins/apm/server/lib/settings/custom_link/helper.test.ts @@ -0,0 +1,137 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ +import { fromESFormat, splitFilterValueByComma, toESFormat } from './helper'; + +describe('Custom link API helper', () => { + describe('splitFilterValueByComma', () => { + it('returns empty string when any value is provided', () => { + expect(splitFilterValueByComma('')).toEqual([]); + }); + it('removes white spaces', () => { + expect(splitFilterValueByComma('foo, bar, ')).toEqual(['foo', 'bar']); + expect(splitFilterValueByComma('foo , bar , baz, ')).toEqual([ + 'foo', + 'bar', + 'baz' + ]); + }); + it('doesnt slipt when comma is not found', () => { + expect(splitFilterValueByComma('foo bar')).toEqual(['foo bar']); + }); + it('doesnt slipt with dot', () => { + expect(splitFilterValueByComma('foo.bar. baz')).toEqual(['foo.bar. baz']); + }); + }); + + describe('fromESFormat', () => { + it('converts without filters', () => { + expect( + fromESFormat({ + id: '123', + '@timestamp': 455, + label: 'foo', + url: 'bar' + }) + ).toEqual({ + id: '123', + '@timestamp': 455, + label: 'foo', + url: 'bar', + filters: [] + }); + }); + it('converts with filters', () => { + expect( + fromESFormat({ + id: '123', + '@timestamp': 455, + label: 'foo', + url: 'bar', + 'service.name': ['baz'], + 'transaction.name': ['quz', 'qux', 'quux'] + }) + ).toEqual({ + id: '123', + '@timestamp': 455, + label: 'foo', + url: 'bar', + filters: [ + { key: 'service.name', value: 'baz' }, + { key: 'transaction.name', value: 'quz,qux,quux' } + ] + }); + }); + it('returns empty string when any filter value is provided', () => { + expect( + fromESFormat({ + id: '123', + '@timestamp': 455, + label: 'foo', + url: 'bar', + 'service.name': [], + 'transaction.name': ['quz', 'qux', 'quux'] + }) + ).toEqual({ + id: '123', + '@timestamp': 455, + label: 'foo', + url: 'bar', + filters: [ + { key: 'service.name', value: '' }, + { key: 'transaction.name', value: 'quz,qux,quux' } + ] + }); + }); + }); + + describe('toESFormat', () => { + it('converts without filters', () => { + expect( + toESFormat({ + label: 'foo', + url: 'bar' + }) + ).toEqual({ + label: 'foo', + url: 'bar' + }); + }); + it('converts with filters', () => { + expect( + toESFormat({ + label: 'foo', + url: 'bar', + filters: [ + { key: 'service.name', value: 'baz' }, + { key: 'transaction.name', value: 'quz,qux,quux' } + ] + }) + ).toEqual({ + label: 'foo', + url: 'bar', + 'service.name': ['baz'], + 'transaction.name': ['quz', 'qux', 'quux'] + }); + }); + it('removes filters without key or value', () => { + expect( + toESFormat({ + label: 'foo', + url: 'bar', + filters: [ + { key: '', value: 'baz' }, + { key: 'service.name', value: '' }, + { key: 'transaction.name', value: 'quz,qux,quux' } + ] + }) + ).toEqual({ + label: 'foo', + url: 'bar', + 'transaction.name': ['quz', 'qux', 'quux'] + }); + }); + }); +}); diff --git a/x-pack/plugins/apm/server/lib/settings/custom_link/helper.ts b/x-pack/plugins/apm/server/lib/settings/custom_link/helper.ts new file mode 100644 index 000000000000..cfdbbdc21b43 --- /dev/null +++ b/x-pack/plugins/apm/server/lib/settings/custom_link/helper.ts @@ -0,0 +1,46 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ +import { isEmpty } from 'lodash'; +import { + CustomLinkES, + CustomLink, + Filter, + FilterKey +} from '../../../../common/custom_link/custom_link_types'; + +export function fromESFormat(customLinkES: CustomLinkES): CustomLink { + const { id, label, url, '@timestamp': timestamp, ...filters } = customLinkES; + return { + id, + '@timestamp': timestamp, + label, + url, + filters: Object.entries(filters).map( + ([key, value]: [string, string[]]) => ({ + key: key as FilterKey, + value: isEmpty(value) ? '' : value.join() + }) + ) + }; +} + +export function toESFormat(customLink: CustomLink): CustomLinkES { + const { label, url, filters = [] } = customLink; + const ESFilters = filters + .filter(({ key, value }) => key && value) + .reduce((acc: Record, { key, value }) => { + acc[key] = splitFilterValueByComma(value); + return acc; + }, {}); + return { label, url, ...ESFilters }; +} + +export function splitFilterValueByComma(filterValue: Filter['value']) { + return filterValue + .split(',') + .map(v => v.trim()) + .filter(v => v); +} diff --git a/x-pack/plugins/apm/server/lib/settings/custom_link/__test__/list_custom_links.test.ts b/x-pack/plugins/apm/server/lib/settings/custom_link/list_custom_links.test.ts similarity index 79% rename from x-pack/plugins/apm/server/lib/settings/custom_link/__test__/list_custom_links.test.ts rename to x-pack/plugins/apm/server/lib/settings/custom_link/list_custom_links.test.ts index 5466225dc321..45610e36786b 100644 --- a/x-pack/plugins/apm/server/lib/settings/custom_link/__test__/list_custom_links.test.ts +++ b/x-pack/plugins/apm/server/lib/settings/custom_link/list_custom_links.test.ts @@ -4,16 +4,16 @@ * you may not use this file except in compliance with the Elastic License. */ -import { listCustomLinks } from '../list_custom_links'; +import { listCustomLinks } from './list_custom_links'; import { inspectSearchParams, SearchParamsMock -} from '../../../../../../../legacy/plugins/apm/public/utils/testHelpers'; -import { Setup } from '../../../helpers/setup_request'; +} from '../../../../../../legacy/plugins/apm/public/utils/testHelpers'; +import { Setup } from '../../helpers/setup_request'; import { SERVICE_NAME, TRANSACTION_NAME -} from '../../../../../common/elasticsearch_fieldnames'; +} from '../../../../common/elasticsearch_fieldnames'; describe('List Custom Links', () => { let mock: SearchParamsMock; diff --git a/x-pack/plugins/apm/server/lib/settings/custom_link/list_custom_links.ts b/x-pack/plugins/apm/server/lib/settings/custom_link/list_custom_links.ts index 67956ef3a60c..bae313c8b6ee 100644 --- a/x-pack/plugins/apm/server/lib/settings/custom_link/list_custom_links.ts +++ b/x-pack/plugins/apm/server/lib/settings/custom_link/list_custom_links.ts @@ -3,20 +3,23 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ - -import { FilterOptions } from '../../../../common/custom_link_filter_options'; +import * as t from 'io-ts'; +import { + CustomLink, + CustomLinkES +} from '../../../../common/custom_link/custom_link_types'; import { Setup } from '../../helpers/setup_request'; -import { CustomLink } from './custom_link_types'; +import { fromESFormat } from './helper'; +import { filterOptionsRt } from './custom_link_types'; export async function listCustomLinks({ setup, filters = {} }: { setup: Setup; - filters?: FilterOptions; -}) { + filters?: t.TypeOf; +}): Promise { const { internalClient, indices } = setup; - const esFilters = Object.entries(filters).map(([key, value]) => { return { bool: { @@ -47,9 +50,12 @@ export async function listCustomLinks({ ] } }; - const resp = await internalClient.search(params); - return resp.hits.hits.map(item => ({ - id: item._id, - ...item._source - })); + const resp = await internalClient.search(params); + const customLinks = resp.hits.hits.map(item => + fromESFormat({ + id: item._id, + ...item._source + }) + ); + return customLinks; } diff --git a/x-pack/plugins/apm/server/routes/settings/custom_link.ts b/x-pack/plugins/apm/server/routes/settings/custom_link.ts index e11c1df9d4b1..428b96ad3982 100644 --- a/x-pack/plugins/apm/server/routes/settings/custom_link.ts +++ b/x-pack/plugins/apm/server/routes/settings/custom_link.ts @@ -4,51 +4,52 @@ * you may not use this file except in compliance with the Elastic License. */ import * as t from 'io-ts'; -import { FilterOptionsRt } from '../../../common/custom_link_filter_options'; -import { createRoute } from '../create_route'; +import { pick } from 'lodash'; +import { FILTER_OPTIONS } from '../../../common/custom_link/custom_link_filter_options'; import { setupRequest } from '../../lib/helpers/setup_request'; import { createOrUpdateCustomLink } from '../../lib/settings/custom_link/create_or_update_custom_link'; +import { + filterOptionsRt, + payloadRt +} from '../../lib/settings/custom_link/custom_link_types'; import { deleteCustomLink } from '../../lib/settings/custom_link/delete_custom_link'; -import { listCustomLinks } from '../../lib/settings/custom_link/list_custom_links'; import { getTransaction } from '../../lib/settings/custom_link/get_transaction'; +import { listCustomLinks } from '../../lib/settings/custom_link/list_custom_links'; +import { createRoute } from '../create_route'; export const customLinkTransactionRoute = createRoute(core => ({ path: '/api/apm/settings/custom_links/transaction', params: { - query: FilterOptionsRt + query: filterOptionsRt }, handler: async ({ context, request }) => { const setup = await setupRequest(context, request); - const { params } = context; - return await getTransaction({ setup, filters: params.query }); + const { query } = context.params; + // picks only the items listed in FILTER_OPTIONS + const filters = pick(query, FILTER_OPTIONS); + return await getTransaction({ setup, filters }); } })); export const listCustomLinksRoute = createRoute(core => ({ path: '/api/apm/settings/custom_links', params: { - query: FilterOptionsRt + query: filterOptionsRt }, handler: async ({ context, request }) => { const setup = await setupRequest(context, request); - const { params } = context; - return await listCustomLinks({ setup, filters: params.query }); + const { query } = context.params; + // picks only the items listed in FILTER_OPTIONS + const filters = pick(query, FILTER_OPTIONS); + return await listCustomLinks({ setup, filters }); } })); -const payload = t.intersection([ - t.type({ - label: t.string, - url: t.string - }), - FilterOptionsRt -]); - export const createCustomLinkRoute = createRoute(() => ({ method: 'POST', path: '/api/apm/settings/custom_links', params: { - body: payload + body: payloadRt }, options: { tags: ['access:apm', 'access:apm_write'] @@ -68,7 +69,7 @@ export const updateCustomLinkRoute = createRoute(() => ({ path: t.type({ id: t.string }), - body: payload + body: payloadRt }, options: { tags: ['access:apm', 'access:apm_write'] From 3fe48fe8b3eab98b60c5843af964fe33b7c51989 Mon Sep 17 00:00:00 2001 From: Dmitry Lemeshko Date: Thu, 26 Mar 2020 13:50:58 +0300 Subject: [PATCH 35/35] Fix empty coverage folder, collect coverage when some tests fail (#61349) * create coverage folder only if json file being saved * skip some tests * unskip test * do not fail coverage run if some tests fail * unskip fixed test --- test/functional/apps/visualize/_tile_map.js | 1 - test/functional/services/remote/remote.ts | 9 +++------ test/scripts/jenkins_ci_group.sh | 2 +- test/scripts/jenkins_xpack_ci_group.sh | 2 +- .../feature_controls/advanced_settings_security.ts | 3 ++- x-pack/test/functional/page_objects/gis_page.js | 2 +- 6 files changed, 8 insertions(+), 11 deletions(-) diff --git a/test/functional/apps/visualize/_tile_map.js b/test/functional/apps/visualize/_tile_map.js index 9e39e93926c9..0a7be3d68231 100644 --- a/test/functional/apps/visualize/_tile_map.js +++ b/test/functional/apps/visualize/_tile_map.js @@ -57,7 +57,6 @@ export default function({ getService, getPageObjects }) { }); describe('complete config', function describeIndexTests() { - this.tags(['skipCoverage']); before(async function() { await browser.setWindowSize(1280, 1000); diff --git a/test/functional/services/remote/remote.ts b/test/functional/services/remote/remote.ts index afe8499a1c2e..e571a1a7e555 100644 --- a/test/functional/services/remote/remote.ts +++ b/test/functional/services/remote/remote.ts @@ -48,6 +48,9 @@ export async function RemoteProvider({ getService }: FtrProviderContext) { }; const writeCoverage = (coverageJson: string) => { + if (!Fs.existsSync(coverageDir)) { + Fs.mkdirSync(coverageDir, { recursive: true }); + } const id = coverageCounter++; const timestamp = Date.now(); const path = resolve(coverageDir, `${id}.${timestamp}.coverage.json`); @@ -75,12 +78,6 @@ export async function RemoteProvider({ getService }: FtrProviderContext) { }, w3c=${isW3CEnabled}, codeCoverage=${collectCoverage}` ); } - // code coverage is supported only in Chrome browser - if (collectCoverage) { - // We are running xpack tests with different configs and cleanup will delete collected coverage - // del.sync(coverageDir); - Fs.mkdirSync(coverageDir, { recursive: true }); - } consoleLog$ .pipe( diff --git a/test/scripts/jenkins_ci_group.sh b/test/scripts/jenkins_ci_group.sh index f3ac951cdc7b..b233d99d2690 100755 --- a/test/scripts/jenkins_ci_group.sh +++ b/test/scripts/jenkins_ci_group.sh @@ -22,7 +22,7 @@ else echo " -> running tests from the clone folder" #yarn run grunt "run:functionalTests_ciGroup${CI_GROUP}"; - node scripts/functional_tests --debug --include-tag "ciGroup$CI_GROUP" --config test/functional/config.coverage.js; + node scripts/functional_tests --debug --include-tag "ciGroup$CI_GROUP" --config test/functional/config.coverage.js || true; if [[ -d target/kibana-coverage/functional ]]; then echo " -> replacing kibana${CI_GROUP} with kibana in json files" diff --git a/test/scripts/jenkins_xpack_ci_group.sh b/test/scripts/jenkins_xpack_ci_group.sh index 4c2b4194c52e..01b13293c10b 100755 --- a/test/scripts/jenkins_xpack_ci_group.sh +++ b/test/scripts/jenkins_xpack_ci_group.sh @@ -23,7 +23,7 @@ else cd "kibana${CI_GROUP}/x-pack" echo " -> running tests from the clone folder" - node scripts/functional_tests --debug --include-tag "ciGroup$CI_GROUP" --config test/functional/config.coverage.js; + node scripts/functional_tests --debug --include-tag "ciGroup$CI_GROUP" --config test/functional/config.coverage.js || true; if [[ -d ../target/kibana-coverage/functional ]]; then echo " -> replacing kibana${CI_GROUP} with kibana in json files" diff --git a/x-pack/test/functional/apps/advanced_settings/feature_controls/advanced_settings_security.ts b/x-pack/test/functional/apps/advanced_settings/feature_controls/advanced_settings_security.ts index 0d4c6b2c8766..1f22ca59ab2d 100644 --- a/x-pack/test/functional/apps/advanced_settings/feature_controls/advanced_settings_security.ts +++ b/x-pack/test/functional/apps/advanced_settings/feature_controls/advanced_settings_security.ts @@ -138,7 +138,8 @@ export default function({ getPageObjects, getService }: FtrProviderContext) { }); }); - describe('no advanced_settings privileges', () => { + describe('no advanced_settings privileges', function() { + this.tags(['skipCoverage']); before(async () => { await security.role.create('no_advanced_settings_privileges_role', { elasticsearch: { diff --git a/x-pack/test/functional/page_objects/gis_page.js b/x-pack/test/functional/page_objects/gis_page.js index 1d0e231d7dc5..ae037c3954a0 100644 --- a/x-pack/test/functional/page_objects/gis_page.js +++ b/x-pack/test/functional/page_objects/gis_page.js @@ -86,8 +86,8 @@ export function GisPageProvider({ getService, getPageObjects }) { async waitForLayersToLoad() { log.debug('Wait for layers to load'); - const tableOfContents = await testSubjects.find('mapLayerTOC'); await retry.try(async () => { + const tableOfContents = await testSubjects.find('mapLayerTOC'); await tableOfContents.waitForDeletedByCssSelector('.euiLoadingSpinner'); }); }