extends PersistableStateDefinition {
+ id: string;
+}
+
export type EmbeddablePersistableStateService = PersistableStateService;
export interface CommonEmbeddableStartContract {
diff --git a/src/plugins/embeddable/public/lib/embeddables/diff_embeddable_input.test.ts b/src/plugins/embeddable/public/lib/embeddables/diff_embeddable_input.test.ts
index 00c4de5ff426f..1dfd056bc75c0 100644
--- a/src/plugins/embeddable/public/lib/embeddables/diff_embeddable_input.test.ts
+++ b/src/plugins/embeddable/public/lib/embeddables/diff_embeddable_input.test.ts
@@ -20,6 +20,7 @@ const getGenericEmbeddableState = (state?: Partial): Embeddable
disableTriggers: false,
enhancements: undefined,
syncColors: false,
+ syncTooltips: false,
viewMode: ViewMode.VIEW,
title: 'So Very Generic',
id: 'soVeryGeneric',
@@ -44,6 +45,7 @@ test('Omitting generic embeddable input omits all generic input keys', () => {
'disableTriggers',
'enhancements',
'syncColors',
+ 'syncTooltips',
'viewMode',
'title',
'id',
diff --git a/src/plugins/embeddable/public/lib/embeddables/diff_embeddable_input.ts b/src/plugins/embeddable/public/lib/embeddables/diff_embeddable_input.ts
index a396ed324a949..a66294d08bdc4 100644
--- a/src/plugins/embeddable/public/lib/embeddables/diff_embeddable_input.ts
+++ b/src/plugins/embeddable/public/lib/embeddables/diff_embeddable_input.ts
@@ -20,6 +20,7 @@ const allGenericInputKeys: Readonly> = [
'disableTriggers',
'enhancements',
'syncColors',
+ 'syncTooltips',
'viewMode',
'title',
'id',
@@ -31,6 +32,7 @@ const genericInputKeysToCompare = [
'disableTriggers',
'enhancements',
'syncColors',
+ 'syncTooltips',
'title',
'id',
] as const;
diff --git a/src/plugins/embeddable/server/index.ts b/src/plugins/embeddable/server/index.ts
index 8d88f35a4be22..4b93f0838c649 100644
--- a/src/plugins/embeddable/server/index.ts
+++ b/src/plugins/embeddable/server/index.ts
@@ -10,6 +10,8 @@ import { EmbeddableServerPlugin, EmbeddableSetup, EmbeddableStart } from './plug
export type { EmbeddableSetup, EmbeddableStart };
-export type { EnhancementRegistryDefinition, EmbeddableRegistryDefinition } from './types';
+export type { EnhancementRegistryDefinition } from './types';
+
+export type { EmbeddableRegistryDefinition } from '../common';
export const plugin = () => new EmbeddableServerPlugin();
diff --git a/src/plugins/embeddable/server/plugin.ts b/src/plugins/embeddable/server/plugin.ts
index 51fa1edb2c634..2260d6b34c8e8 100644
--- a/src/plugins/embeddable/server/plugin.ts
+++ b/src/plugins/embeddable/server/plugin.ts
@@ -19,7 +19,6 @@ import {
EnhancementsRegistry,
EnhancementRegistryDefinition,
EnhancementRegistryItem,
- EmbeddableRegistryDefinition,
} from './types';
import {
getExtractFunction,
@@ -27,7 +26,11 @@ import {
getMigrateFunction,
getTelemetryFunction,
} from '../common/lib';
-import { EmbeddableStateWithType, CommonEmbeddableStartContract } from '../common/types';
+import {
+ EmbeddableStateWithType,
+ CommonEmbeddableStartContract,
+ EmbeddableRegistryDefinition,
+} from '../common/types';
import { getAllMigrations } from '../common/lib/get_all_migrations';
export interface EmbeddableSetup extends PersistableStateService {
diff --git a/src/plugins/embeddable/server/types.ts b/src/plugins/embeddable/server/types.ts
index 9b0479d6bc25d..bd78265bea6b1 100644
--- a/src/plugins/embeddable/server/types.ts
+++ b/src/plugins/embeddable/server/types.ts
@@ -23,12 +23,6 @@ export interface EnhancementRegistryItem extends PersistableStateDefinition
{
- id: string;
-}
-
export interface EmbeddableRegistryItem
extends PersistableState
{
id: string;
diff --git a/src/plugins/event_annotation/common/constants.ts b/src/plugins/event_annotation/common/constants.ts
new file mode 100644
index 0000000000000..3338450b64ce5
--- /dev/null
+++ b/src/plugins/event_annotation/common/constants.ts
@@ -0,0 +1,24 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
+ * Side Public License, v 1.
+ */
+
+export const AvailableAnnotationIcons = {
+ ASTERISK: 'asterisk',
+ ALERT: 'alert',
+ BELL: 'bell',
+ BOLT: 'bolt',
+ BUG: 'bug',
+ CIRCLE: 'circle',
+ EDITOR_COMMENT: 'editorComment',
+ FLAG: 'flag',
+ HEART: 'heart',
+ MAP_MARKER: 'mapMarker',
+ PIN_FILLED: 'pinFilled',
+ STAR_EMPTY: 'starEmpty',
+ TAG: 'tag',
+ TRIANGLE: 'triangle',
+} as const;
diff --git a/src/plugins/event_annotation/common/index.ts b/src/plugins/event_annotation/common/index.ts
index 3ed43b19a705c..50d7c8b851776 100644
--- a/src/plugins/event_annotation/common/index.ts
+++ b/src/plugins/event_annotation/common/index.ts
@@ -17,4 +17,8 @@ export type {
export { manualPointEventAnnotation, manualRangeEventAnnotation } from './manual_event_annotation';
export { eventAnnotationGroup } from './event_annotation_group';
export type { EventAnnotationGroupArgs } from './event_annotation_group';
-export type { EventAnnotationConfig, RangeEventAnnotationConfig } from './types';
+export type {
+ EventAnnotationConfig,
+ RangeEventAnnotationConfig,
+ AvailableAnnotationIcon,
+} from './types';
diff --git a/src/plugins/event_annotation/common/manual_event_annotation/index.ts b/src/plugins/event_annotation/common/manual_event_annotation/index.ts
index 2401af53df76c..bb02018f5a81a 100644
--- a/src/plugins/event_annotation/common/manual_event_annotation/index.ts
+++ b/src/plugins/event_annotation/common/manual_event_annotation/index.ts
@@ -8,6 +8,8 @@
import type { ExpressionFunctionDefinition } from '@kbn/expressions-plugin/common';
import { i18n } from '@kbn/i18n';
+import { AvailableAnnotationIcons } from '../constants';
+
import type {
ManualRangeEventAnnotationArgs,
ManualRangeEventAnnotationOutput,
@@ -65,6 +67,8 @@ export const manualPointEventAnnotation: ExpressionFunctionDefinition<
help: i18n.translate('eventAnnotation.manualAnnotation.args.icon', {
defaultMessage: 'An optional icon used for annotation lines',
}),
+ options: [...Object.values(AvailableAnnotationIcons)],
+ strict: true,
},
textVisibility: {
types: ['boolean'],
diff --git a/src/plugins/event_annotation/common/types.ts b/src/plugins/event_annotation/common/types.ts
index 664138c9eb9e6..e0b0de3c85c9e 100644
--- a/src/plugins/event_annotation/common/types.ts
+++ b/src/plugins/event_annotation/common/types.ts
@@ -6,15 +6,18 @@
* Side Public License, v 1.
*/
+import { $Values } from '@kbn/utility-types';
+import { AvailableAnnotationIcons } from './constants';
+
export type LineStyle = 'solid' | 'dashed' | 'dotted';
export type Fill = 'inside' | 'outside' | 'none';
export type AnnotationType = 'manual';
export type KeyType = 'point_in_time' | 'range';
-
+export type AvailableAnnotationIcon = $Values;
export interface PointStyleProps {
label: string;
color?: string;
- icon?: string;
+ icon?: AvailableAnnotationIcon;
lineWidth?: number;
lineStyle?: LineStyle;
textVisibility?: boolean;
diff --git a/src/plugins/expressions/common/execution/execution.test.ts b/src/plugins/expressions/common/execution/execution.test.ts
index 78d88adfa3dbd..75a95035bb89f 100644
--- a/src/plugins/expressions/common/execution/execution.test.ts
+++ b/src/plugins/expressions/common/execution/execution.test.ts
@@ -714,7 +714,7 @@ describe('Execution', () => {
expect(result).toMatchObject({
type: 'error',
error: {
- message: '[requiredArg] > requiredArg requires an argument',
+ message: '[requiredArg] > requiredArg requires the "arg" argument',
},
});
});
@@ -725,7 +725,7 @@ describe('Execution', () => {
expect(result).toMatchObject({
type: 'error',
error: {
- message: '[var_set] > var_set requires an "name" argument',
+ message: '[var_set] > var_set requires the "name" argument',
},
});
});
diff --git a/src/plugins/expressions/common/execution/execution.ts b/src/plugins/expressions/common/execution/execution.ts
index 17b6338a48f89..2fda462929ff4 100644
--- a/src/plugins/expressions/common/execution/execution.ts
+++ b/src/plugins/expressions/common/execution/execution.ts
@@ -224,6 +224,7 @@ export class Execution<
inspectorAdapters.tables[name] = datatable;
},
isSyncColorsEnabled: () => execution.params.syncColors!,
+ isSyncTooltipsEnabled: () => execution.params.syncTooltips!,
...execution.executor.context,
getExecutionContext: () => execution.params.executionContext,
};
@@ -480,7 +481,7 @@ export class Execution<
);
// Check for missing required arguments.
- for (const { aliases, default: argDefault, name, required } of Object.values(argDefs)) {
+ for (const { default: argDefault, name, required } of Object.values(argDefs)) {
if (!(name in dealiasedArgAsts) && typeof argDefault !== 'undefined') {
dealiasedArgAsts[name] = [parse(argDefault as string, 'argument')];
}
@@ -489,13 +490,7 @@ export class Execution<
continue;
}
- if (!aliases?.length) {
- throw new Error(`${fnDef.name} requires an argument`);
- }
-
- // use an alias if _ is the missing arg
- const errorArg = name === '_' ? aliases[0] : name;
- throw new Error(`${fnDef.name} requires an "${errorArg}" argument`);
+ throw new Error(`${fnDef.name} requires the "${name}" argument`);
}
// Create the functions to resolve the argument ASTs into values
diff --git a/src/plugins/expressions/common/execution/types.ts b/src/plugins/expressions/common/execution/types.ts
index 44d6fef6f79a6..686ade0869171 100644
--- a/src/plugins/expressions/common/execution/types.ts
+++ b/src/plugins/expressions/common/execution/types.ts
@@ -66,6 +66,11 @@ export interface ExecutionContext<
*/
isSyncColorsEnabled?: () => boolean;
+ /**
+ * Returns the state (true|false) of the sync tooltips across panels switch.
+ */
+ isSyncTooltipsEnabled?: () => boolean;
+
/**
* Contains the meta-data about the source of the expression.
*/
diff --git a/src/plugins/expressions/common/expression_renderers/types.ts b/src/plugins/expressions/common/expression_renderers/types.ts
index 1e40ba2a65fff..06d3617d74784 100644
--- a/src/plugins/expressions/common/expression_renderers/types.ts
+++ b/src/plugins/expressions/common/expression_renderers/types.ts
@@ -91,6 +91,8 @@ export interface IInterpreterRenderHandlers {
isInteractive(): boolean;
isSyncColorsEnabled(): boolean;
+
+ isSyncTooltipsEnabled(): boolean;
/**
* This uiState interface is actually `PersistedState` from the visualizations plugin,
* but expressions cannot know about vis or it creates a mess of circular dependencies.
diff --git a/src/plugins/expressions/common/service/expressions_services.ts b/src/plugins/expressions/common/service/expressions_services.ts
index d873a1957cd1f..d4bac702bd6e0 100644
--- a/src/plugins/expressions/common/service/expressions_services.ts
+++ b/src/plugins/expressions/common/service/expressions_services.ts
@@ -152,6 +152,8 @@ export interface ExpressionExecutionParams {
syncColors?: boolean;
+ syncTooltips?: boolean;
+
inspectorAdapters?: Adapters;
executionContext?: KibanaExecutionContext;
diff --git a/src/plugins/expressions/public/loader.ts b/src/plugins/expressions/public/loader.ts
index 6482da0af21ee..7f7a96fde6f1a 100644
--- a/src/plugins/expressions/public/loader.ts
+++ b/src/plugins/expressions/public/loader.ts
@@ -58,6 +58,7 @@ export class ExpressionLoader {
onRenderError: params && params.onRenderError,
renderMode: params?.renderMode,
syncColors: params?.syncColors,
+ syncTooltips: params?.syncTooltips,
hasCompatibleActions: params?.hasCompatibleActions,
});
this.render$ = this.renderHandler.render$;
@@ -142,6 +143,7 @@ export class ExpressionLoader {
searchSessionId: params.searchSessionId,
debug: params.debug,
syncColors: params.syncColors,
+ syncTooltips: params.syncTooltips,
executionContext: params.executionContext,
});
this.subscription = this.execution
@@ -182,6 +184,7 @@ export class ExpressionLoader {
this.params.searchSessionId = params.searchSessionId;
}
this.params.syncColors = params.syncColors;
+ this.params.syncTooltips = params.syncTooltips;
this.params.debug = Boolean(params.debug);
this.params.partial = Boolean(params.partial);
this.params.throttle = Number(params.throttle ?? 1000);
diff --git a/src/plugins/expressions/public/react_expression_renderer/use_expression_renderer.ts b/src/plugins/expressions/public/react_expression_renderer/use_expression_renderer.ts
index 033d50d7faf0d..7daa4b3626fa7 100644
--- a/src/plugins/expressions/public/react_expression_renderer/use_expression_renderer.ts
+++ b/src/plugins/expressions/public/react_expression_renderer/use_expression_renderer.ts
@@ -111,6 +111,7 @@ export function useExpressionRenderer(
debouncedLoaderParams.interactive,
debouncedLoaderParams.renderMode,
debouncedLoaderParams.syncColors,
+ debouncedLoaderParams.syncTooltips,
]);
useEffect(() => {
diff --git a/src/plugins/expressions/public/render.ts b/src/plugins/expressions/public/render.ts
index 25bffdca089ee..1d90a795a03a4 100644
--- a/src/plugins/expressions/public/render.ts
+++ b/src/plugins/expressions/public/render.ts
@@ -28,6 +28,7 @@ export interface ExpressionRenderHandlerParams {
onRenderError?: RenderErrorHandlerFnType;
renderMode?: RenderMode;
syncColors?: boolean;
+ syncTooltips?: boolean;
interactive?: boolean;
hasCompatibleActions?: (event: ExpressionRendererEvent) => Promise;
}
@@ -54,6 +55,7 @@ export class ExpressionRenderHandler {
onRenderError,
renderMode,
syncColors,
+ syncTooltips,
interactive,
hasCompatibleActions = async () => false,
}: ExpressionRenderHandlerParams = {}
@@ -94,6 +96,9 @@ export class ExpressionRenderHandler {
isSyncColorsEnabled: () => {
return syncColors || false;
},
+ isSyncTooltipsEnabled: () => {
+ return syncTooltips || false;
+ },
isInteractive: () => {
return interactive ?? true;
},
diff --git a/src/plugins/expressions/public/types/index.ts b/src/plugins/expressions/public/types/index.ts
index 322c2895f9bb5..b035daf4deefc 100644
--- a/src/plugins/expressions/public/types/index.ts
+++ b/src/plugins/expressions/public/types/index.ts
@@ -50,6 +50,7 @@ export interface IExpressionLoaderParams {
searchSessionId?: string;
renderMode?: RenderMode;
syncColors?: boolean;
+ syncTooltips?: boolean;
hasCompatibleActions?: ExpressionRenderHandlerParams['hasCompatibleActions'];
executionContext?: KibanaExecutionContext;
diff --git a/src/plugins/newsfeed/public/lib/convert_items.test.ts b/src/plugins/newsfeed/public/lib/convert_items.test.ts
index 8b599d841935c..cd2c8e4675396 100644
--- a/src/plugins/newsfeed/public/lib/convert_items.test.ts
+++ b/src/plugins/newsfeed/public/lib/convert_items.test.ts
@@ -34,31 +34,35 @@ const createNewsfeedItem = (parts: Partial = {}): NewsfeedItem =>
});
describe('localizeItem', () => {
- const item = createApiItem({
- languages: ['en', 'fr'],
- title: {
- en: 'en title',
- fr: 'fr title',
- },
- description: {
- en: 'en desc',
- fr: 'fr desc',
- },
- link_text: {
- en: 'en link text',
- fr: 'fr link text',
- },
- link_url: {
- en: 'en link url',
- fr: 'fr link url',
- },
- badge: {
- en: 'en badge',
- fr: 'fr badge',
- },
- publish_on: new Date('2014-10-31T04:23:47Z'),
- expire_on: new Date('2049-10-31T04:23:47Z'),
- hash: 'hash',
+ let item: ApiItem;
+
+ beforeEach(() => {
+ item = createApiItem({
+ languages: ['en', 'fr'],
+ title: {
+ en: 'en title',
+ fr: 'fr title',
+ },
+ description: {
+ en: 'en desc',
+ fr: 'fr desc',
+ },
+ link_text: {
+ en: 'en link text',
+ fr: 'fr link text',
+ },
+ link_url: {
+ en: 'en link url',
+ fr: 'fr link url',
+ },
+ badge: {
+ en: 'en badge',
+ fr: 'fr badge',
+ },
+ publish_on: new Date('2014-10-31T04:23:47Z'),
+ expire_on: new Date('2049-10-31T04:23:47Z'),
+ hash: 'hash',
+ });
});
it('converts api items to newsfeed items using the specified language', () => {
@@ -82,6 +86,39 @@ describe('localizeItem', () => {
hash: 'hash',
});
});
+
+ it('uses the fallback language when `languages` is `null`', () => {
+ item = createApiItem({
+ languages: null,
+ title: {
+ en: 'en title',
+ },
+ description: {
+ en: 'en desc',
+ },
+ link_text: {
+ en: 'en link text',
+ },
+ link_url: {
+ en: 'en link url',
+ },
+ badge: {
+ en: 'en badge',
+ },
+ publish_on: new Date('2014-10-31T04:23:47Z'),
+ expire_on: new Date('2049-10-31T04:23:47Z'),
+ hash: 'hash',
+ });
+
+ expect(localizeItem(item, 'fr')).toMatchObject({
+ title: 'en title',
+ description: 'en desc',
+ linkText: 'en link text',
+ linkUrl: 'en link url',
+ badge: 'en badge',
+ hash: 'hash',
+ });
+ });
});
describe('validatePublishedDate', () => {
diff --git a/src/plugins/newsfeed/public/lib/convert_items.ts b/src/plugins/newsfeed/public/lib/convert_items.ts
index 38ea2cc895f3e..9235906a15fb1 100644
--- a/src/plugins/newsfeed/public/lib/convert_items.ts
+++ b/src/plugins/newsfeed/public/lib/convert_items.ts
@@ -42,7 +42,7 @@ export const localizeItem = (rawItem: ApiItem, userLanguage: string): NewsfeedIt
} = rawItem;
let chosenLanguage = userLanguage;
- if (languages && !languages.includes(chosenLanguage)) {
+ if (!languages || !languages.includes(chosenLanguage)) {
chosenLanguage = NEWSFEED_FALLBACK_LANGUAGE; // don't remove the item: fallback on a language
}
diff --git a/src/plugins/presentation_util/public/__stories__/render.tsx b/src/plugins/presentation_util/public/__stories__/render.tsx
index bd6463ca254d6..7e24606ca5331 100644
--- a/src/plugins/presentation_util/public/__stories__/render.tsx
+++ b/src/plugins/presentation_util/public/__stories__/render.tsx
@@ -13,6 +13,7 @@ import { ExpressionRenderDefinition, IInterpreterRenderHandlers } from '@kbn/exp
export const defaultHandlers: IInterpreterRenderHandlers = {
getRenderMode: () => 'view',
isSyncColorsEnabled: () => false,
+ isSyncTooltipsEnabled: () => false,
isInteractive: () => true,
done: action('done'),
onDestroy: action('onDestroy'),
diff --git a/src/plugins/unified_search/public/apply_filters/apply_filter_popover_content.tsx b/src/plugins/unified_search/public/apply_filters/apply_filter_popover_content.tsx
index 25d6f27bc51f1..9017fbf40ee2f 100644
--- a/src/plugins/unified_search/public/apply_filters/apply_filter_popover_content.tsx
+++ b/src/plugins/unified_search/public/apply_filters/apply_filter_popover_content.tsx
@@ -19,7 +19,11 @@ import {
} from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n-react';
import React, { Component } from 'react';
-import { getDisplayValueFromFilter, mapAndFlattenFilters } from '@kbn/data-plugin/public';
+import {
+ getDisplayValueFromFilter,
+ mapAndFlattenFilters,
+ getFieldDisplayValueFromFilter,
+} from '@kbn/data-plugin/public';
import { Filter } from '@kbn/data-plugin/common';
import { DataView } from '@kbn/data-views-plugin/public';
import { FilterLabel } from '../filter_bar';
@@ -33,6 +37,7 @@ interface Props {
interface State {
isFilterSelected: boolean[];
+ fieldLabel?: string;
}
// Needed for React.lazy
@@ -46,12 +51,15 @@ export default class ApplyFiltersPopoverContent extends Component
super(props);
this.state = {
isFilterSelected: props.filters.map(() => true),
+ fieldLabel: undefined,
};
}
- private getLabel(filter: Filter) {
+
+ private getLabel = (filter: Filter) => {
const valueLabel = getDisplayValueFromFilter(filter, this.props.indexPatterns);
- return ;
- }
+ const fieldLabel = getFieldDisplayValueFromFilter(filter, this.props.indexPatterns);
+ return ;
+ };
public render() {
if (this.props.filters.length === 0) {
diff --git a/src/plugins/unified_search/public/autocomplete/providers/kql_query_suggestion/field.tsx b/src/plugins/unified_search/public/autocomplete/providers/kql_query_suggestion/field.tsx
index 139405f6af9f4..723b7e6896229 100644
--- a/src/plugins/unified_search/public/autocomplete/providers/kql_query_suggestion/field.tsx
+++ b/src/plugins/unified_search/public/autocomplete/providers/kql_query_suggestion/field.tsx
@@ -8,7 +8,6 @@
import { IFieldType, indexPatterns as indexPatternsUtils } from '@kbn/data-plugin/public';
import { flatten } from 'lodash';
-import { escapeKuery } from './lib/escape_kuery';
import { sortPrefixFirst } from './sort_prefix_first';
import { QuerySuggestionField, QuerySuggestionTypes } from '../query_suggestion_provider';
import { KqlQuerySuggestionProvider } from './types';
@@ -27,7 +26,7 @@ const keywordComparator = (first: IFieldType, second: IFieldType) => {
export const setupGetFieldSuggestions: KqlQuerySuggestionProvider = (
core
) => {
- return ({ indexPatterns }, { start, end, prefix, suffix, nestedPath = '' }) => {
+ return async ({ indexPatterns }, { start, end, prefix, suffix, nestedPath = '' }) => {
const allFields = flatten(
indexPatterns.map((indexPattern) => {
return indexPattern.fields.filter(indexPatternsUtils.isFilterable);
@@ -42,7 +41,7 @@ export const setupGetFieldSuggestions: KqlQuerySuggestionProvider {
const remainingPath =
field.subType && field.subType.nested
diff --git a/src/plugins/unified_search/public/autocomplete/providers/kql_query_suggestion/index.ts b/src/plugins/unified_search/public/autocomplete/providers/kql_query_suggestion/index.ts
index 1002863fec7f4..cd022ec371e65 100644
--- a/src/plugins/unified_search/public/autocomplete/providers/kql_query_suggestion/index.ts
+++ b/src/plugins/unified_search/public/autocomplete/providers/kql_query_suggestion/index.ts
@@ -9,7 +9,6 @@
import { CoreSetup } from '@kbn/core/public';
import { $Keys } from 'utility-types';
import { flatten, uniqBy } from 'lodash';
-import { fromKueryExpression } from '@kbn/es-query';
import { setupGetFieldSuggestions } from './field';
import { setupGetValueSuggestions } from './value';
import { setupGetOperatorSuggestions } from './operator';
@@ -38,11 +37,12 @@ export const setupKqlQuerySuggestionProvider = (
conjunction: setupGetConjunctionSuggestions(core),
};
- const getSuggestionsByType = (
+ const getSuggestionsByType = async (
cursoredQuery: string,
querySuggestionsArgs: QuerySuggestionGetFnArgs
- ): Array> | [] => {
+ ): Promise> | []> => {
try {
+ const { fromKueryExpression } = await import('@kbn/es-query');
const cursorNode = fromKueryExpression(cursoredQuery, {
cursorSymbol,
parseCursor: true,
@@ -56,13 +56,13 @@ export const setupKqlQuerySuggestionProvider = (
}
};
- return (querySuggestionsArgs) => {
+ return async (querySuggestionsArgs): Promise => {
const { query, selectionStart, selectionEnd } = querySuggestionsArgs;
const cursoredQuery = `${query.substr(0, selectionStart)}${cursorSymbol}${query.substr(
selectionEnd
)}`;
- return Promise.all(getSuggestionsByType(cursoredQuery, querySuggestionsArgs)).then(
+ return Promise.all(await getSuggestionsByType(cursoredQuery, querySuggestionsArgs)).then(
(suggestionsByType) => dedup(flatten(suggestionsByType))
);
};
diff --git a/src/plugins/unified_search/public/autocomplete/providers/kql_query_suggestion/lib/escape_kuery.ts b/src/plugins/unified_search/public/autocomplete/providers/kql_query_suggestion/lib/escape_kuery.ts
index 6636f9b602687..20a20797c15e2 100644
--- a/src/plugins/unified_search/public/autocomplete/providers/kql_query_suggestion/lib/escape_kuery.ts
+++ b/src/plugins/unified_search/public/autocomplete/providers/kql_query_suggestion/lib/escape_kuery.ts
@@ -6,8 +6,6 @@
* Side Public License, v 1.
*/
-import { escapeKuery } from '@kbn/es-query';
-
/**
* Escapes backslashes and double-quotes. (Useful when putting a string in quotes to use as a value
* in a KQL expression. See the QuotedCharacter rule in kuery.peg.)
@@ -15,6 +13,3 @@ import { escapeKuery } from '@kbn/es-query';
export function escapeQuotes(str: string) {
return str.replace(/[\\"]/g, '\\$&');
}
-
-// Re-export this function from the @kbn/es-query package to avoid refactoring
-export { escapeKuery };
diff --git a/src/plugins/unified_search/public/autocomplete/providers/kql_query_suggestion/types.ts b/src/plugins/unified_search/public/autocomplete/providers/kql_query_suggestion/types.ts
index e9ca34e546f0b..d7b8b3315fafd 100644
--- a/src/plugins/unified_search/public/autocomplete/providers/kql_query_suggestion/types.ts
+++ b/src/plugins/unified_search/public/autocomplete/providers/kql_query_suggestion/types.ts
@@ -6,10 +6,10 @@
* Side Public License, v 1.
*/
-import { CoreSetup } from '@kbn/core/public';
-import { KueryNode } from '@kbn/es-query';
+import type { KueryNode } from '@kbn/es-query';
+import type { CoreSetup } from '@kbn/core/public';
import type { UnifiedSearchPublicPluginStart } from '../../../types';
-import { QuerySuggestionBasic, QuerySuggestionGetFnArgs } from '../query_suggestion_provider';
+import type { QuerySuggestionBasic, QuerySuggestionGetFnArgs } from '../query_suggestion_provider';
export type KqlQuerySuggestionProvider = (
core: CoreSetup