From e894c411e4e699009888a0d17112733c79783843 Mon Sep 17 00:00:00 2001 From: Liza Katz Date: Wed, 28 Jul 2021 13:29:32 +0200 Subject: [PATCH] [Data][Filters] Move more filter utils to package and cleanup API (#106566) * Move more utils to package and cleanup API * docs and imports * better imports * change comment Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> --- ...na-plugin-plugins-data-public.esfilters.md | 23 ++- ...in-plugins-data-public.extracttimerange.md | 29 +++ ...a-plugin-plugins-data-public.filteritem.md | 11 ++ ...-plugin-plugins-data-public.filterlabel.md | 11 ++ ...gin-plugins-data-public.generatefilters.md | 30 +++ ...s-data-public.getdisplayvaluefromfilter.md | 23 +++ ...in-plugins-data-public.getesqueryconfig.md | 22 +++ .../kibana-plugin-plugins-data-public.md | 8 +- ...ugins-data-server.buildqueryfromfilters.md | 21 +++ ...na-plugin-plugins-data-server.esfilters.md | 2 +- ...in-plugins-data-server.getesqueryconfig.md | 22 +++ .../kibana-plugin-plugins-data-server.md | 2 + .../src/es_query/filter_matches_index.ts | 2 +- .../build_filters/build_empty_filter.ts | 23 +++ .../{ => build_filters}/build_filter.test.ts | 4 +- .../{ => build_filters}/build_filters.ts | 17 +- .../{ => build_filters}/custom_filter.ts | 2 +- .../{ => build_filters}/exists_filter.test.ts | 4 +- .../{ => build_filters}/exists_filter.ts | 4 +- .../geo_bounding_box_filter.test.ts | 0 .../geo_bounding_box_filter.ts | 2 +- .../geo_polygon_filter.test.ts | 0 .../{ => build_filters}/geo_polygon_filter.ts | 2 +- .../get_converted_value_for_field.ts | 35 ++++ .../get_filter_field.test.ts | 4 +- .../{ => build_filters}/get_filter_field.ts | 6 +- .../get_filter_params.test.ts | 2 +- .../{ => build_filters}/get_filter_params.ts | 5 +- .../src/filters/build_filters/index.ts | 24 +++ .../{ => build_filters}/match_all_filter.ts | 2 +- .../missing_filter.test.ts | 0 .../{ => build_filters}/missing_filter.ts | 2 +- .../{ => build_filters}/phrase_filter.test.ts | 4 +- .../{ => build_filters}/phrase_filter.ts | 31 +--- .../phrases_filter.test.ts | 4 +- .../{ => build_filters}/phrases_filter.ts | 5 +- .../query_string_filter.test.ts | 0 .../query_string_filter.ts | 2 +- .../{ => build_filters}/range_filter.test.ts | 4 +- .../{ => build_filters}/range_filter.ts | 4 +- .../src/filters/{ => build_filters}/types.ts | 0 .../filters/helpers}/compare_filters.test.ts | 2 +- .../src/filters/helpers}/compare_filters.ts | 2 +- .../filters/helpers}/dedup_filters.test.ts | 35 +++- .../src/filters/helpers}/dedup_filters.ts | 2 +- .../src/filters/helpers}/index.ts | 8 +- .../src/filters/{ => helpers}/meta_filter.ts | 26 ++- .../filters/helpers}/only_disabled.test.ts | 2 +- .../src/filters/helpers}/only_disabled.ts | 3 +- .../src/filters/helpers}/uniq_filters.test.ts | 2 +- .../src/filters/helpers}/uniq_filters.ts | 2 +- packages/kbn-es-query/src/filters/index.ts | 93 +++++++--- src/plugins/data/common/es_query/index.ts | 158 ++++++++++------ src/plugins/data/common/query/index.ts | 1 - .../data/common/query/timefilter/get_time.ts | 2 +- .../search/expressions/kibana_context.ts | 2 +- src/plugins/data/public/deprecated.ts | 173 ++++++++++++++++++ src/plugins/data/public/index.ts | 130 +------------ src/plugins/data/public/public.api.md | 132 ++++++++----- .../query/filter_manager/filter_manager.ts | 3 +- .../data/public/query/filter_manager/index.ts | 1 - src/plugins/data/public/ui/index.ts | 2 +- src/plugins/data/server/deprecated.ts | 67 +++++++ src/plugins/data/server/index.ts | 64 +------ src/plugins/data/server/server.api.md | 81 ++++---- 65 files changed, 925 insertions(+), 466 deletions(-) create mode 100644 docs/development/plugins/data/public/kibana-plugin-plugins-data-public.extracttimerange.md create mode 100644 docs/development/plugins/data/public/kibana-plugin-plugins-data-public.filteritem.md create mode 100644 docs/development/plugins/data/public/kibana-plugin-plugins-data-public.filterlabel.md create mode 100644 docs/development/plugins/data/public/kibana-plugin-plugins-data-public.generatefilters.md create mode 100644 docs/development/plugins/data/public/kibana-plugin-plugins-data-public.getdisplayvaluefromfilter.md create mode 100644 docs/development/plugins/data/public/kibana-plugin-plugins-data-public.getesqueryconfig.md create mode 100644 docs/development/plugins/data/server/kibana-plugin-plugins-data-server.buildqueryfromfilters.md create mode 100644 docs/development/plugins/data/server/kibana-plugin-plugins-data-server.getesqueryconfig.md create mode 100644 packages/kbn-es-query/src/filters/build_filters/build_empty_filter.ts rename packages/kbn-es-query/src/filters/{ => build_filters}/build_filter.test.ts (97%) rename packages/kbn-es-query/src/filters/{ => build_filters}/build_filters.ts (85%) rename packages/kbn-es-query/src/filters/{ => build_filters}/custom_filter.ts (91%) rename packages/kbn-es-query/src/filters/{ => build_filters}/exists_filter.test.ts (90%) rename packages/kbn-es-query/src/filters/{ => build_filters}/exists_filter.ts (88%) rename packages/kbn-es-query/src/filters/{ => build_filters}/geo_bounding_box_filter.test.ts (100%) rename packages/kbn-es-query/src/filters/{ => build_filters}/geo_bounding_box_filter.ts (94%) rename packages/kbn-es-query/src/filters/{ => build_filters}/geo_polygon_filter.test.ts (100%) rename packages/kbn-es-query/src/filters/{ => build_filters}/geo_polygon_filter.ts (93%) create mode 100644 packages/kbn-es-query/src/filters/build_filters/get_converted_value_for_field.ts rename packages/kbn-es-query/src/filters/{ => build_filters}/get_filter_field.test.ts (93%) rename packages/kbn-es-query/src/filters/{ => build_filters}/get_filter_field.ts (97%) rename packages/kbn-es-query/src/filters/{ => build_filters}/get_filter_params.test.ts (98%) rename packages/kbn-es-query/src/filters/{ => build_filters}/get_filter_params.ts (79%) create mode 100644 packages/kbn-es-query/src/filters/build_filters/index.ts rename packages/kbn-es-query/src/filters/{ => build_filters}/match_all_filter.ts (92%) rename packages/kbn-es-query/src/filters/{ => build_filters}/missing_filter.test.ts (100%) rename packages/kbn-es-query/src/filters/{ => build_filters}/missing_filter.ts (93%) rename packages/kbn-es-query/src/filters/{ => build_filters}/phrase_filter.test.ts (97%) rename packages/kbn-es-query/src/filters/{ => build_filters}/phrase_filter.ts (78%) rename packages/kbn-es-query/src/filters/{ => build_filters}/phrases_filter.test.ts (91%) rename packages/kbn-es-query/src/filters/{ => build_filters}/phrases_filter.ts (91%) rename packages/kbn-es-query/src/filters/{ => build_filters}/query_string_filter.test.ts (100%) rename packages/kbn-es-query/src/filters/{ => build_filters}/query_string_filter.ts (94%) rename packages/kbn-es-query/src/filters/{ => build_filters}/range_filter.test.ts (97%) rename packages/kbn-es-query/src/filters/{ => build_filters}/range_filter.ts (97%) rename packages/kbn-es-query/src/filters/{ => build_filters}/types.ts (100%) rename {src/plugins/data/common/query/filter_manager => packages/kbn-es-query/src/filters/helpers}/compare_filters.test.ts (99%) rename {src/plugins/data/common/query/filter_manager => packages/kbn-es-query/src/filters/helpers}/compare_filters.ts (97%) rename {src/plugins/data/common/query/filter_manager => packages/kbn-es-query/src/filters/helpers}/dedup_filters.test.ts (76%) rename {src/plugins/data/common/query/filter_manager => packages/kbn-es-query/src/filters/helpers}/dedup_filters.ts (96%) rename {src/plugins/data/common/query/filter_manager => packages/kbn-es-query/src/filters/helpers}/index.ts (65%) rename packages/kbn-es-query/src/filters/{ => helpers}/meta_filter.ts (81%) rename {src/plugins/data/public/query/filter_manager/lib => packages/kbn-es-query/src/filters/helpers}/only_disabled.test.ts (99%) rename {src/plugins/data/public/query/filter_manager/lib => packages/kbn-es-query/src/filters/helpers}/only_disabled.ts (89%) rename {src/plugins/data/common/query/filter_manager => packages/kbn-es-query/src/filters/helpers}/uniq_filters.test.ts (96%) rename {src/plugins/data/common/query/filter_manager => packages/kbn-es-query/src/filters/helpers}/uniq_filters.ts (95%) create mode 100644 src/plugins/data/public/deprecated.ts create mode 100644 src/plugins/data/server/deprecated.ts diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.esfilters.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.esfilters.md index eb06d99426197..2976c0884fc4c 100644 --- a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.esfilters.md +++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.esfilters.md @@ -4,6 +4,13 @@ ## esFilters variable +> Warning: This API is now obsolete. +> +> Please import helpers from the package kbn/es-query directly. This import will be deprecated in v8.0.0. +> + +Filter helpers namespace: + Signature: ```typescript @@ -16,7 +23,7 @@ esFilters: { buildPhrasesFilter: (field: import("@kbn/es-query").IndexPatternFieldBase, params: any[], indexPattern: import("@kbn/es-query").IndexPatternBase) => import("@kbn/es-query").PhrasesFilter; buildExistsFilter: (field: import("@kbn/es-query").IndexPatternFieldBase, indexPattern: import("@kbn/es-query").IndexPatternBase) => import("@kbn/es-query").ExistsFilter; buildPhraseFilter: (field: import("@kbn/es-query").IndexPatternFieldBase, value: any, indexPattern: import("@kbn/es-query").IndexPatternBase) => import("@kbn/es-query").PhraseFilter; - buildQueryFilter: (query: any, index: string, alias: string) => import("@kbn/es-query").QueryStringFilter; + buildQueryFilter: (query: any, index: string, alias: string) => import("@kbn/es-query/target_types/filters/build_filters").QueryStringFilter; buildRangeFilter: (field: import("@kbn/es-query").IndexPatternFieldBase, params: import("@kbn/es-query").RangeFilterParams, indexPattern: import("@kbn/es-query").IndexPatternBase, formattedValue?: string | undefined) => import("@kbn/es-query").RangeFilter; isPhraseFilter: (filter: any) => filter is import("@kbn/es-query").PhraseFilter; isExistsFilter: (filter: any) => filter is import("@kbn/es-query").ExistsFilter; @@ -24,7 +31,7 @@ esFilters: { isRangeFilter: (filter: any) => filter is import("@kbn/es-query").RangeFilter; isMatchAllFilter: (filter: any) => filter is import("@kbn/es-query").MatchAllFilter; isMissingFilter: (filter: any) => filter is import("@kbn/es-query").MissingFilter; - isQueryStringFilter: (filter: any) => filter is import("@kbn/es-query").QueryStringFilter; + isQueryStringFilter: (filter: any) => filter is import("@kbn/es-query/target_types/filters/build_filters").QueryStringFilter; isFilterPinned: (filter: import("@kbn/es-query").Filter) => boolean | undefined; toggleFilterNegated: (filter: import("@kbn/es-query").Filter) => { meta: { @@ -39,21 +46,21 @@ esFilters: { params?: any; value?: string | undefined; }; - $state?: import("@kbn/es-query/target_types/filters/types").FilterState | undefined; + $state?: import("@kbn/es-query").FilterState | undefined; query?: any; }; disableFilter: (filter: import("@kbn/es-query").Filter) => import("@kbn/es-query").Filter; getPhraseFilterField: (filter: import("@kbn/es-query").PhraseFilter) => string; getPhraseFilterValue: (filter: import("@kbn/es-query").PhraseFilter) => string | number | boolean; getDisplayValueFromFilter: typeof getDisplayValueFromFilter; - compareFilters: (first: import("@kbn/es-query").Filter | import("@kbn/es-query").Filter[], second: import("@kbn/es-query").Filter | import("@kbn/es-query").Filter[], comparatorOptions?: import("../common").FilterCompareOptions) => boolean; - COMPARE_ALL_OPTIONS: import("../common").FilterCompareOptions; + compareFilters: (first: import("@kbn/es-query").Filter | import("@kbn/es-query").Filter[], second: import("@kbn/es-query").Filter | import("@kbn/es-query").Filter[], comparatorOptions?: import("@kbn/es-query").FilterCompareOptions | undefined) => boolean; + COMPARE_ALL_OPTIONS: import("@kbn/es-query").FilterCompareOptions; generateFilters: typeof generateFilters; onlyDisabledFiltersChanged: (newFilters?: import("@kbn/es-query").Filter[] | undefined, oldFilters?: import("@kbn/es-query").Filter[] | undefined) => boolean; - changeTimeFilter: typeof changeTimeFilter; - convertRangeFilterToTimeRangeString: typeof convertRangeFilterToTimeRangeString; + changeTimeFilter: typeof oldChangeTimeFilter; + convertRangeFilterToTimeRangeString: typeof oldConvertRangeFilterToTimeRangeString; mapAndFlattenFilters: (filters: import("@kbn/es-query").Filter[]) => import("@kbn/es-query").Filter[]; - extractTimeFilter: typeof extractTimeFilter; + extractTimeFilter: typeof oldExtractTimeFilter; extractTimeRange: typeof extractTimeRange; } ``` diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.extracttimerange.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.extracttimerange.md new file mode 100644 index 0000000000000..e0d9fcef130b6 --- /dev/null +++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.extracttimerange.md @@ -0,0 +1,29 @@ + + +[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [extractTimeRange](./kibana-plugin-plugins-data-public.extracttimerange.md) + +## extractTimeRange() function + +Signature: + +```typescript +export declare function extractTimeRange(filters: Filter[], timeFieldName?: string): { + restOfFilters: Filter[]; + timeRange?: TimeRange; +}; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| filters | Filter[] | | +| timeFieldName | string | | + +Returns: + +`{ + restOfFilters: Filter[]; + timeRange?: TimeRange; +}` + diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.filteritem.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.filteritem.md new file mode 100644 index 0000000000000..1bb193521b429 --- /dev/null +++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.filteritem.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [FilterItem](./kibana-plugin-plugins-data-public.filteritem.md) + +## FilterItem variable + +Signature: + +```typescript +FilterItem: (props: FilterItemProps) => JSX.Element +``` diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.filterlabel.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.filterlabel.md new file mode 100644 index 0000000000000..59425a2e3605d --- /dev/null +++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.filterlabel.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [FilterLabel](./kibana-plugin-plugins-data-public.filterlabel.md) + +## FilterLabel variable + +Signature: + +```typescript +FilterLabel: (props: FilterLabelProps) => JSX.Element +``` diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.generatefilters.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.generatefilters.md new file mode 100644 index 0000000000000..31c8c3e98c639 --- /dev/null +++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.generatefilters.md @@ -0,0 +1,30 @@ + + +[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [generateFilters](./kibana-plugin-plugins-data-public.generatefilters.md) + +## generateFilters() function + +Generate filter objects, as a result of triggering a filter action on a specific index pattern field. + +Signature: + +```typescript +export declare function generateFilters(filterManager: FilterManager, field: IFieldType | string, values: any, operation: string, index: string): Filter[]; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| filterManager | FilterManager | | +| field | IFieldType | string | | +| values | any | | +| operation | string | | +| index | string | | + +Returns: + +`Filter[]` + +{object} An array of filters to be added back to filterManager + diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.getdisplayvaluefromfilter.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.getdisplayvaluefromfilter.md new file mode 100644 index 0000000000000..3666047e3cecb --- /dev/null +++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.getdisplayvaluefromfilter.md @@ -0,0 +1,23 @@ + + +[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [getDisplayValueFromFilter](./kibana-plugin-plugins-data-public.getdisplayvaluefromfilter.md) + +## getDisplayValueFromFilter() function + +Signature: + +```typescript +export declare function getDisplayValueFromFilter(filter: Filter, indexPatterns: IIndexPattern[]): string; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| filter | Filter | | +| indexPatterns | IIndexPattern[] | | + +Returns: + +`string` + diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.getesqueryconfig.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.getesqueryconfig.md new file mode 100644 index 0000000000000..9c00719badc5e --- /dev/null +++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.getesqueryconfig.md @@ -0,0 +1,22 @@ + + +[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [getEsQueryConfig](./kibana-plugin-plugins-data-public.getesqueryconfig.md) + +## getEsQueryConfig() function + +Signature: + +```typescript +export declare function getEsQueryConfig(config: KibanaConfig): EsQueryConfig; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| config | KibanaConfig | | + +Returns: + +`EsQueryConfig` + diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.md index e60e26bcb503e..37af5ea226086 100644 --- a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.md +++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.md @@ -43,8 +43,12 @@ | Function | Description | | --- | --- | +| [extractTimeRange(filters, timeFieldName)](./kibana-plugin-plugins-data-public.extracttimerange.md) | | +| [generateFilters(filterManager, field, values, operation, index)](./kibana-plugin-plugins-data-public.generatefilters.md) | Generate filter objects, as a result of triggering a filter action on a specific index pattern field. | | [getDefaultQuery(language)](./kibana-plugin-plugins-data-public.getdefaultquery.md) | | +| [getDisplayValueFromFilter(filter, indexPatterns)](./kibana-plugin-plugins-data-public.getdisplayvaluefromfilter.md) | | | [getEsPreference(uiSettings, sessionId)](./kibana-plugin-plugins-data-public.getespreference.md) | | +| [getEsQueryConfig(config)](./kibana-plugin-plugins-data-public.getesqueryconfig.md) | | | [getSearchParamsFromRequest(searchRequest, dependencies)](./kibana-plugin-plugins-data-public.getsearchparamsfromrequest.md) | | | [getTime(indexPattern, timeRange, options)](./kibana-plugin-plugins-data-public.gettime.md) | | | [isEsError(e)](./kibana-plugin-plugins-data-public.iseserror.md) | Checks if a given errors originated from Elasticsearch. Those params are assigned to the attributes property of an error. | @@ -107,13 +111,15 @@ | [connectToQueryState](./kibana-plugin-plugins-data-public.connecttoquerystate.md) | Helper to setup two-way syncing of global data and a state container | | [createSavedQueryService](./kibana-plugin-plugins-data-public.createsavedqueryservice.md) | | | [ES\_SEARCH\_STRATEGY](./kibana-plugin-plugins-data-public.es_search_strategy.md) | | -| [esFilters](./kibana-plugin-plugins-data-public.esfilters.md) | | +| [esFilters](./kibana-plugin-plugins-data-public.esfilters.md) | Filter helpers namespace: | | [esKuery](./kibana-plugin-plugins-data-public.eskuery.md) | | | [esQuery](./kibana-plugin-plugins-data-public.esquery.md) | | | [exporters](./kibana-plugin-plugins-data-public.exporters.md) | | | [extractSearchSourceReferences](./kibana-plugin-plugins-data-public.extractsearchsourcereferences.md) | | | [fieldFormats](./kibana-plugin-plugins-data-public.fieldformats.md) | | | [fieldList](./kibana-plugin-plugins-data-public.fieldlist.md) | | +| [FilterItem](./kibana-plugin-plugins-data-public.filteritem.md) | | +| [FilterLabel](./kibana-plugin-plugins-data-public.filterlabel.md) | | | [getKbnTypeNames](./kibana-plugin-plugins-data-public.getkbntypenames.md) | Get the esTypes known by all kbnFieldTypes {Array} | | [INDEX\_PATTERN\_SAVED\_OBJECT\_TYPE](./kibana-plugin-plugins-data-public.index_pattern_saved_object_type.md) | \* | | [indexPatterns](./kibana-plugin-plugins-data-public.indexpatterns.md) | | diff --git a/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.buildqueryfromfilters.md b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.buildqueryfromfilters.md new file mode 100644 index 0000000000000..90fdb471d6280 --- /dev/null +++ b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.buildqueryfromfilters.md @@ -0,0 +1,21 @@ + + +[Home](./index.md) > [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) > [buildQueryFromFilters](./kibana-plugin-plugins-data-server.buildqueryfromfilters.md) + +## buildQueryFromFilters variable + +> Warning: This API is now obsolete. +> +> Please import from the package kbn/es-query directly. This import will be deprecated in v8.0.0. +> + +Signature: + +```typescript +buildQueryFromFilters: (filters: oldFilter[] | undefined, indexPattern: import("@kbn/es-query").IndexPatternBase | undefined, ignoreFilterIfFieldNotInIndex?: boolean | undefined) => { + must: never[]; + filter: oldFilter[]; + should: never[]; + must_not: oldFilter[]; +} +``` diff --git a/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.esfilters.md b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.esfilters.md index 9006b088993a1..b807fe7d66369 100644 --- a/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.esfilters.md +++ b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.esfilters.md @@ -8,7 +8,7 @@ ```typescript esFilters: { - buildQueryFilter: (query: any, index: string, alias: string) => import("@kbn/es-query").QueryStringFilter; + buildQueryFilter: (query: any, index: string, alias: string) => import("@kbn/es-query/target_types/filters/build_filters").QueryStringFilter; buildCustomFilter: typeof import("@kbn/es-query").buildCustomFilter; buildEmptyFilter: (isPinned: boolean, index?: string | undefined) => import("@kbn/es-query").Filter; buildExistsFilter: (field: import("@kbn/es-query").IndexPatternFieldBase, indexPattern: import("@kbn/es-query").IndexPatternBase) => import("@kbn/es-query").ExistsFilter; diff --git a/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.getesqueryconfig.md b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.getesqueryconfig.md new file mode 100644 index 0000000000000..f8909a7e7715f --- /dev/null +++ b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.getesqueryconfig.md @@ -0,0 +1,22 @@ + + +[Home](./index.md) > [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) > [getEsQueryConfig](./kibana-plugin-plugins-data-server.getesqueryconfig.md) + +## getEsQueryConfig() function + +Signature: + +```typescript +export declare function getEsQueryConfig(config: KibanaConfig): EsQueryConfig; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| config | KibanaConfig | | + +Returns: + +`EsQueryConfig` + diff --git a/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.md b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.md index 8e23f47976bd9..ea0a6f8c64be0 100644 --- a/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.md +++ b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.md @@ -32,6 +32,7 @@ | --- | --- | | [getCapabilitiesForRollupIndices(indices)](./kibana-plugin-plugins-data-server.getcapabilitiesforrollupindices.md) | | | [getDefaultSearchParams(uiSettingsClient)](./kibana-plugin-plugins-data-server.getdefaultsearchparams.md) | | +| [getEsQueryConfig(config)](./kibana-plugin-plugins-data-server.getesqueryconfig.md) | | | [getShardTimeout(config)](./kibana-plugin-plugins-data-server.getshardtimeout.md) | | | [getTime(indexPattern, timeRange, options)](./kibana-plugin-plugins-data-server.gettime.md) | | | [parseInterval(interval)](./kibana-plugin-plugins-data-server.parseinterval.md) | | @@ -72,6 +73,7 @@ | --- | --- | | [AggGroupLabels](./kibana-plugin-plugins-data-server.agggrouplabels.md) | | | [AggGroupNames](./kibana-plugin-plugins-data-server.agggroupnames.md) | | +| [buildQueryFromFilters](./kibana-plugin-plugins-data-server.buildqueryfromfilters.md) | | | [castEsToKbnFieldTypeName](./kibana-plugin-plugins-data-server.castestokbnfieldtypename.md) | Get the KbnFieldType name for an esType string | | [config](./kibana-plugin-plugins-data-server.config.md) | | | [ES\_SEARCH\_STRATEGY](./kibana-plugin-plugins-data-server.es_search_strategy.md) | | diff --git a/packages/kbn-es-query/src/es_query/filter_matches_index.ts b/packages/kbn-es-query/src/es_query/filter_matches_index.ts index 714ae5f7b274b..7df719533486a 100644 --- a/packages/kbn-es-query/src/es_query/filter_matches_index.ts +++ b/packages/kbn-es-query/src/es_query/filter_matches_index.ts @@ -7,7 +7,7 @@ */ import { Filter } from '../filters'; -import { IndexPatternBase } from './types'; +import { IndexPatternBase } from '..'; /* * TODO: We should base this on something better than `filter.meta.key`. We should probably modify diff --git a/packages/kbn-es-query/src/filters/build_filters/build_empty_filter.ts b/packages/kbn-es-query/src/filters/build_filters/build_empty_filter.ts new file mode 100644 index 0000000000000..a7945da5829a9 --- /dev/null +++ b/packages/kbn-es-query/src/filters/build_filters/build_empty_filter.ts @@ -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 + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { Filter, FilterMeta, FilterState, FilterStateStore } from './types'; + +export const buildEmptyFilter = (isPinned: boolean, index?: string): Filter => { + const meta: FilterMeta = { + disabled: false, + negate: false, + alias: null, + index, + }; + const $state: FilterState = { + store: isPinned ? FilterStateStore.GLOBAL_STATE : FilterStateStore.APP_STATE, + }; + + return { meta, $state }; +}; diff --git a/packages/kbn-es-query/src/filters/build_filter.test.ts b/packages/kbn-es-query/src/filters/build_filters/build_filter.test.ts similarity index 97% rename from packages/kbn-es-query/src/filters/build_filter.test.ts rename to packages/kbn-es-query/src/filters/build_filters/build_filter.test.ts index d7cf7938b3737..762af90063070 100644 --- a/packages/kbn-es-query/src/filters/build_filter.test.ts +++ b/packages/kbn-es-query/src/filters/build_filters/build_filter.test.ts @@ -7,8 +7,8 @@ */ import { buildFilter, FilterStateStore, FILTERS } from '.'; -import { IndexPatternBase } from '..'; -import { fields as stubFields } from './stubs'; +import { IndexPatternBase } from '../..'; +import { fields as stubFields } from '../stubs'; describe('buildFilter', () => { const stubIndexPattern: IndexPatternBase = { diff --git a/packages/kbn-es-query/src/filters/build_filters.ts b/packages/kbn-es-query/src/filters/build_filters/build_filters.ts similarity index 85% rename from packages/kbn-es-query/src/filters/build_filters.ts rename to packages/kbn-es-query/src/filters/build_filters/build_filters.ts index ae27e64f3a41d..9beee96fd2ee2 100644 --- a/packages/kbn-es-query/src/filters/build_filters.ts +++ b/packages/kbn-es-query/src/filters/build_filters/build_filters.ts @@ -6,15 +6,14 @@ * Side Public License, v 1. */ -import { - Filter, - FILTERS, - buildPhraseFilter, - buildPhrasesFilter, - buildRangeFilter, - buildExistsFilter, -} from '.'; -import { IndexPatternFieldBase, IndexPatternBase } from '..'; +import { Filter, FILTERS } from './types'; + +import { buildPhraseFilter } from './phrase_filter'; +import { buildPhrasesFilter } from './phrases_filter'; +import { buildRangeFilter } from './range_filter'; +import { buildExistsFilter } from './exists_filter'; + +import type { IndexPatternFieldBase, IndexPatternBase } from '../../es_query'; import { FilterMeta, FilterStateStore } from './types'; export function buildFilter( diff --git a/packages/kbn-es-query/src/filters/custom_filter.ts b/packages/kbn-es-query/src/filters/build_filters/custom_filter.ts similarity index 91% rename from packages/kbn-es-query/src/filters/custom_filter.ts rename to packages/kbn-es-query/src/filters/build_filters/custom_filter.ts index aa9e798a5b1ac..0dc1fc86d25a1 100644 --- a/packages/kbn-es-query/src/filters/custom_filter.ts +++ b/packages/kbn-es-query/src/filters/build_filters/custom_filter.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import { Filter } from './types'; +import type { Filter } from './types'; export type CustomFilter = Filter & { query: any; diff --git a/packages/kbn-es-query/src/filters/exists_filter.test.ts b/packages/kbn-es-query/src/filters/build_filters/exists_filter.test.ts similarity index 90% rename from packages/kbn-es-query/src/filters/exists_filter.test.ts rename to packages/kbn-es-query/src/filters/build_filters/exists_filter.test.ts index 83976d45f8e04..35a2a5c3d6057 100644 --- a/packages/kbn-es-query/src/filters/exists_filter.test.ts +++ b/packages/kbn-es-query/src/filters/build_filters/exists_filter.test.ts @@ -6,9 +6,9 @@ * Side Public License, v 1. */ -import { IndexPatternBase } from '..'; +import { IndexPatternBase } from '../../es_query'; import { buildExistsFilter, getExistsFilterField } from './exists_filter'; -import { fields } from './stubs/fields.mocks'; +import { fields } from '../stubs/fields.mocks'; describe('exists filter', function () { const indexPattern: IndexPatternBase = { diff --git a/packages/kbn-es-query/src/filters/exists_filter.ts b/packages/kbn-es-query/src/filters/build_filters/exists_filter.ts similarity index 88% rename from packages/kbn-es-query/src/filters/exists_filter.ts rename to packages/kbn-es-query/src/filters/build_filters/exists_filter.ts index 7785a62261fde..fdb4ab548fdc5 100644 --- a/packages/kbn-es-query/src/filters/exists_filter.ts +++ b/packages/kbn-es-query/src/filters/build_filters/exists_filter.ts @@ -6,8 +6,8 @@ * Side Public License, v 1. */ -import { IndexPatternFieldBase, IndexPatternBase } from '..'; -import { Filter, FilterMeta } from './types'; +import type { IndexPatternFieldBase, IndexPatternBase } from '../../es_query'; +import type { Filter, FilterMeta } from './types'; export type ExistsFilterMeta = FilterMeta; diff --git a/packages/kbn-es-query/src/filters/geo_bounding_box_filter.test.ts b/packages/kbn-es-query/src/filters/build_filters/geo_bounding_box_filter.test.ts similarity index 100% rename from packages/kbn-es-query/src/filters/geo_bounding_box_filter.test.ts rename to packages/kbn-es-query/src/filters/build_filters/geo_bounding_box_filter.test.ts diff --git a/packages/kbn-es-query/src/filters/geo_bounding_box_filter.ts b/packages/kbn-es-query/src/filters/build_filters/geo_bounding_box_filter.ts similarity index 94% rename from packages/kbn-es-query/src/filters/geo_bounding_box_filter.ts rename to packages/kbn-es-query/src/filters/build_filters/geo_bounding_box_filter.ts index b309515109d48..323c7108ea3e5 100644 --- a/packages/kbn-es-query/src/filters/geo_bounding_box_filter.ts +++ b/packages/kbn-es-query/src/filters/build_filters/geo_bounding_box_filter.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import { Filter, FilterMeta, LatLon } from './types'; +import type { Filter, FilterMeta, LatLon } from './types'; export type GeoBoundingBoxFilterMeta = FilterMeta & { params: { diff --git a/packages/kbn-es-query/src/filters/geo_polygon_filter.test.ts b/packages/kbn-es-query/src/filters/build_filters/geo_polygon_filter.test.ts similarity index 100% rename from packages/kbn-es-query/src/filters/geo_polygon_filter.test.ts rename to packages/kbn-es-query/src/filters/build_filters/geo_polygon_filter.test.ts diff --git a/packages/kbn-es-query/src/filters/geo_polygon_filter.ts b/packages/kbn-es-query/src/filters/build_filters/geo_polygon_filter.ts similarity index 93% rename from packages/kbn-es-query/src/filters/geo_polygon_filter.ts rename to packages/kbn-es-query/src/filters/build_filters/geo_polygon_filter.ts index 42e417f2c88a4..d25f2a87dcd8c 100644 --- a/packages/kbn-es-query/src/filters/geo_polygon_filter.ts +++ b/packages/kbn-es-query/src/filters/build_filters/geo_polygon_filter.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import { Filter, FilterMeta, LatLon } from './types'; +import type { Filter, FilterMeta, LatLon } from './types'; export type GeoPolygonFilterMeta = FilterMeta & { params: { diff --git a/packages/kbn-es-query/src/filters/build_filters/get_converted_value_for_field.ts b/packages/kbn-es-query/src/filters/build_filters/get_converted_value_for_field.ts new file mode 100644 index 0000000000000..39b3abd7780ef --- /dev/null +++ b/packages/kbn-es-query/src/filters/build_filters/get_converted_value_for_field.ts @@ -0,0 +1,35 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { IndexPatternFieldBase } from '../../es_query'; + +/** + * @internal + * See issues bellow for the reason behind this change. + * Values need to be converted to correct types for boolean \ numeric fields. + * https://github.com/elastic/kibana/issues/74301 + * https://github.com/elastic/kibana/issues/8677 + * https://github.com/elastic/elasticsearch/issues/20941 + * https://github.com/elastic/elasticsearch/pull/22201 + **/ +export const getConvertedValueForField = (field: IndexPatternFieldBase, value: any) => { + if (typeof value !== 'boolean' && field.type === 'boolean') { + if ([1, 'true'].includes(value)) { + return true; + } else if ([0, 'false'].includes(value)) { + return false; + } else { + throw new Error(`${value} is not a valid boolean value for boolean field ${field.name}`); + } + } + + if (typeof value !== 'number' && field.type === 'number') { + return Number(value); + } + return value; +}; diff --git a/packages/kbn-es-query/src/filters/get_filter_field.test.ts b/packages/kbn-es-query/src/filters/build_filters/get_filter_field.test.ts similarity index 93% rename from packages/kbn-es-query/src/filters/get_filter_field.test.ts rename to packages/kbn-es-query/src/filters/build_filters/get_filter_field.test.ts index 0425aa6cc8c72..6f20c727c1481 100644 --- a/packages/kbn-es-query/src/filters/get_filter_field.test.ts +++ b/packages/kbn-es-query/src/filters/build_filters/get_filter_field.test.ts @@ -9,8 +9,8 @@ import { buildPhraseFilter } from './phrase_filter'; import { buildQueryFilter } from './query_string_filter'; import { getFilterField } from './get_filter_field'; -import { IndexPatternBase } from '..'; -import { fields } from './stubs/fields.mocks'; +import { IndexPatternBase } from '../../es_query'; +import { fields } from '../stubs/fields.mocks'; describe('getFilterField', function () { const indexPattern: IndexPatternBase = { diff --git a/packages/kbn-es-query/src/filters/get_filter_field.ts b/packages/kbn-es-query/src/filters/build_filters/get_filter_field.ts similarity index 97% rename from packages/kbn-es-query/src/filters/get_filter_field.ts rename to packages/kbn-es-query/src/filters/build_filters/get_filter_field.ts index 4b540beb03754..a949c0f7cd5b1 100644 --- a/packages/kbn-es-query/src/filters/get_filter_field.ts +++ b/packages/kbn-es-query/src/filters/build_filters/get_filter_field.ts @@ -6,14 +6,14 @@ * Side Public License, v 1. */ -import { Filter } from './types'; import { getExistsFilterField, isExistsFilter } from './exists_filter'; import { getGeoBoundingBoxFilterField, isGeoBoundingBoxFilter } from './geo_bounding_box_filter'; import { getGeoPolygonFilterField, isGeoPolygonFilter } from './geo_polygon_filter'; -import { getPhraseFilterField, isPhraseFilter } from './phrase_filter'; +import { getMissingFilterField, isMissingFilter } from './missing_filter'; import { getPhrasesFilterField, isPhrasesFilter } from './phrases_filter'; +import { getPhraseFilterField, isPhraseFilter } from './phrase_filter'; import { getRangeFilterField, isRangeFilter } from './range_filter'; -import { getMissingFilterField, isMissingFilter } from './missing_filter'; +import type { Filter } from './types'; export const getFilterField = (filter: Filter) => { if (isExistsFilter(filter)) { diff --git a/packages/kbn-es-query/src/filters/get_filter_params.test.ts b/packages/kbn-es-query/src/filters/build_filters/get_filter_params.test.ts similarity index 98% rename from packages/kbn-es-query/src/filters/get_filter_params.test.ts rename to packages/kbn-es-query/src/filters/build_filters/get_filter_params.test.ts index 8bb62279b6f74..6d5ad4c2e291b 100644 --- a/packages/kbn-es-query/src/filters/get_filter_params.test.ts +++ b/packages/kbn-es-query/src/filters/build_filters/get_filter_params.test.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import { phraseFilter, phrasesFilter, rangeFilter, existsFilter } from './stubs'; +import { phraseFilter, phrasesFilter, rangeFilter, existsFilter } from '../stubs'; import { getFilterParams } from './get_filter_params'; describe('getFilterParams', () => { diff --git a/packages/kbn-es-query/src/filters/get_filter_params.ts b/packages/kbn-es-query/src/filters/build_filters/get_filter_params.ts similarity index 79% rename from packages/kbn-es-query/src/filters/get_filter_params.ts rename to packages/kbn-es-query/src/filters/build_filters/get_filter_params.ts index 83cc1464f8b10..65a586db39789 100644 --- a/packages/kbn-es-query/src/filters/get_filter_params.ts +++ b/packages/kbn-es-query/src/filters/build_filters/get_filter_params.ts @@ -6,7 +6,10 @@ * Side Public License, v 1. */ -import { Filter, FILTERS, PhraseFilter, PhrasesFilter, RangeFilter } from '.'; +import type { PhrasesFilter } from './phrases_filter'; +import type { PhraseFilter } from './phrase_filter'; +import type { RangeFilter } from './range_filter'; +import { Filter, FILTERS } from './types'; export function getFilterParams(filter: Filter) { switch (filter.meta.type) { diff --git a/packages/kbn-es-query/src/filters/build_filters/index.ts b/packages/kbn-es-query/src/filters/build_filters/index.ts new file mode 100644 index 0000000000000..c8b96d8b8efc9 --- /dev/null +++ b/packages/kbn-es-query/src/filters/build_filters/index.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 * from './get_converted_value_for_field'; +export * from './build_filters'; +export * from './build_empty_filter'; +export * from './custom_filter'; +export * from './exists_filter'; +export * from './geo_bounding_box_filter'; +export * from './geo_polygon_filter'; +export * from './get_filter_field'; +export * from './get_filter_params'; +export * from './match_all_filter'; +export * from './missing_filter'; +export * from './phrase_filter'; +export * from './phrases_filter'; +export * from './query_string_filter'; +export * from './range_filter'; +export * from './types'; diff --git a/packages/kbn-es-query/src/filters/match_all_filter.ts b/packages/kbn-es-query/src/filters/build_filters/match_all_filter.ts similarity index 92% rename from packages/kbn-es-query/src/filters/match_all_filter.ts rename to packages/kbn-es-query/src/filters/build_filters/match_all_filter.ts index a3fdd740986d4..1a3fae4181379 100644 --- a/packages/kbn-es-query/src/filters/match_all_filter.ts +++ b/packages/kbn-es-query/src/filters/build_filters/match_all_filter.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import { Filter, FilterMeta } from './types'; +import type { Filter, FilterMeta } from './types'; export interface MatchAllFilterMeta extends FilterMeta { field: any; diff --git a/packages/kbn-es-query/src/filters/missing_filter.test.ts b/packages/kbn-es-query/src/filters/build_filters/missing_filter.test.ts similarity index 100% rename from packages/kbn-es-query/src/filters/missing_filter.test.ts rename to packages/kbn-es-query/src/filters/build_filters/missing_filter.test.ts diff --git a/packages/kbn-es-query/src/filters/missing_filter.ts b/packages/kbn-es-query/src/filters/build_filters/missing_filter.ts similarity index 93% rename from packages/kbn-es-query/src/filters/missing_filter.ts rename to packages/kbn-es-query/src/filters/build_filters/missing_filter.ts index 0e10cb18d3c21..e52b7753c13a4 100644 --- a/packages/kbn-es-query/src/filters/missing_filter.ts +++ b/packages/kbn-es-query/src/filters/build_filters/missing_filter.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import { Filter, FilterMeta } from './types'; +import type { Filter, FilterMeta } from './types'; export type MissingFilterMeta = FilterMeta; diff --git a/packages/kbn-es-query/src/filters/phrase_filter.test.ts b/packages/kbn-es-query/src/filters/build_filters/phrase_filter.test.ts similarity index 97% rename from packages/kbn-es-query/src/filters/phrase_filter.test.ts rename to packages/kbn-es-query/src/filters/build_filters/phrase_filter.test.ts index 7e6ccadc800d4..3a2c3ee5b8241 100644 --- a/packages/kbn-es-query/src/filters/phrase_filter.test.ts +++ b/packages/kbn-es-query/src/filters/build_filters/phrase_filter.test.ts @@ -11,8 +11,8 @@ import { buildPhraseFilter, getPhraseFilterField, } from './phrase_filter'; -import { fields, getField } from '../filters/stubs'; -import { IndexPatternBase } from '../es_query'; +import { fields, getField } from '../stubs'; +import { IndexPatternBase } from '../../es_query'; describe('Phrase filter builder', () => { let indexPattern: IndexPatternBase; diff --git a/packages/kbn-es-query/src/filters/phrase_filter.ts b/packages/kbn-es-query/src/filters/build_filters/phrase_filter.ts similarity index 78% rename from packages/kbn-es-query/src/filters/phrase_filter.ts rename to packages/kbn-es-query/src/filters/build_filters/phrase_filter.ts index fd5ded010bf07..bc60043d0887e 100644 --- a/packages/kbn-es-query/src/filters/phrase_filter.ts +++ b/packages/kbn-es-query/src/filters/build_filters/phrase_filter.ts @@ -7,8 +7,9 @@ */ import type { estypes } from '@elastic/elasticsearch'; import { get, isPlainObject } from 'lodash'; -import { Filter, FilterMeta } from './types'; -import { IndexPatternFieldBase, IndexPatternBase } from '..'; +import type { Filter, FilterMeta } from './types'; +import type { IndexPatternFieldBase, IndexPatternBase } from '../../es_query'; +import { getConvertedValueForField } from './get_converted_value_for_field'; export type PhraseFilterMeta = FilterMeta & { params?: { @@ -96,32 +97,6 @@ export const getPhraseScript = (field: IndexPatternFieldBase, value: string) => }; }; -/** - * @internal - * See issues bellow for the reason behind this change. - * Values need to be converted to correct types for boolean \ numeric fields. - * https://github.com/elastic/kibana/issues/74301 - * https://github.com/elastic/kibana/issues/8677 - * https://github.com/elastic/elasticsearch/issues/20941 - * https://github.com/elastic/elasticsearch/pull/22201 - **/ -export const getConvertedValueForField = (field: IndexPatternFieldBase, value: any) => { - if (typeof value !== 'boolean' && field.type === 'boolean') { - if ([1, 'true'].includes(value)) { - return true; - } else if ([0, 'false'].includes(value)) { - return false; - } else { - throw new Error(`${value} is not a valid boolean value for boolean field ${field.name}`); - } - } - - if (typeof value !== 'number' && field.type === 'number') { - return Number(value); - } - return value; -}; - /** * @internal * Takes a scripted field and returns an inline script appropriate for use in a script query. diff --git a/packages/kbn-es-query/src/filters/phrases_filter.test.ts b/packages/kbn-es-query/src/filters/build_filters/phrases_filter.test.ts similarity index 91% rename from packages/kbn-es-query/src/filters/phrases_filter.test.ts rename to packages/kbn-es-query/src/filters/build_filters/phrases_filter.test.ts index 5e742187cdf05..c3e7fd37e1ff6 100644 --- a/packages/kbn-es-query/src/filters/phrases_filter.test.ts +++ b/packages/kbn-es-query/src/filters/build_filters/phrases_filter.test.ts @@ -6,9 +6,9 @@ * Side Public License, v 1. */ +import { IndexPatternBase } from '../../es_query'; import { buildPhrasesFilter, getPhrasesFilterField } from './phrases_filter'; -import { IndexPatternBase } from '..'; -import { fields } from './stubs/fields.mocks'; +import { fields } from '../stubs'; describe('phrases filter', function () { const indexPattern: IndexPatternBase = { diff --git a/packages/kbn-es-query/src/filters/phrases_filter.ts b/packages/kbn-es-query/src/filters/build_filters/phrases_filter.ts similarity index 91% rename from packages/kbn-es-query/src/filters/phrases_filter.ts rename to packages/kbn-es-query/src/filters/build_filters/phrases_filter.ts index 451a0a46789fb..6f8c3815a5c63 100644 --- a/packages/kbn-es-query/src/filters/phrases_filter.ts +++ b/packages/kbn-es-query/src/filters/build_filters/phrases_filter.ts @@ -6,10 +6,9 @@ * Side Public License, v 1. */ -import { Filter, FilterMeta } from './types'; +import { Filter, FilterMeta, FILTERS } from './types'; import { getPhraseScript } from './phrase_filter'; -import { FILTERS } from './index'; -import { IndexPatternFieldBase, IndexPatternBase } from '../es_query'; +import type { IndexPatternFieldBase, IndexPatternBase } from '../../es_query'; export type PhrasesFilterMeta = FilterMeta & { params: string[]; // The unformatted values diff --git a/packages/kbn-es-query/src/filters/query_string_filter.test.ts b/packages/kbn-es-query/src/filters/build_filters/query_string_filter.test.ts similarity index 100% rename from packages/kbn-es-query/src/filters/query_string_filter.test.ts rename to packages/kbn-es-query/src/filters/build_filters/query_string_filter.test.ts diff --git a/packages/kbn-es-query/src/filters/query_string_filter.ts b/packages/kbn-es-query/src/filters/build_filters/query_string_filter.ts similarity index 94% rename from packages/kbn-es-query/src/filters/query_string_filter.ts rename to packages/kbn-es-query/src/filters/build_filters/query_string_filter.ts index b4774d5e65a67..4fa084f181827 100644 --- a/packages/kbn-es-query/src/filters/query_string_filter.ts +++ b/packages/kbn-es-query/src/filters/build_filters/query_string_filter.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import { Filter, FilterMeta } from './types'; +import type { Filter, FilterMeta } from './types'; export type QueryStringFilterMeta = FilterMeta; diff --git a/packages/kbn-es-query/src/filters/range_filter.test.ts b/packages/kbn-es-query/src/filters/build_filters/range_filter.test.ts similarity index 97% rename from packages/kbn-es-query/src/filters/range_filter.test.ts rename to packages/kbn-es-query/src/filters/build_filters/range_filter.test.ts index 634471b1d4d9e..0e6fadcf2be46 100644 --- a/packages/kbn-es-query/src/filters/range_filter.test.ts +++ b/packages/kbn-es-query/src/filters/build_filters/range_filter.test.ts @@ -7,9 +7,9 @@ */ import { each } from 'lodash'; +import { IndexPatternBase, IndexPatternFieldBase } from '../../es_query'; +import { fields, getField } from '../stubs'; import { buildRangeFilter, getRangeFilterField, RangeFilter } from './range_filter'; -import { fields, getField } from '../filters/stubs'; -import { IndexPatternBase, IndexPatternFieldBase } from '../es_query'; describe('Range filter builder', () => { let indexPattern: IndexPatternBase; diff --git a/packages/kbn-es-query/src/filters/range_filter.ts b/packages/kbn-es-query/src/filters/build_filters/range_filter.ts similarity index 97% rename from packages/kbn-es-query/src/filters/range_filter.ts rename to packages/kbn-es-query/src/filters/build_filters/range_filter.ts index 2df313eb7dd76..6ed560ccc831e 100644 --- a/packages/kbn-es-query/src/filters/range_filter.ts +++ b/packages/kbn-es-query/src/filters/build_filters/range_filter.ts @@ -7,8 +7,8 @@ */ import type { estypes } from '@elastic/elasticsearch'; import { map, reduce, mapValues, get, keys, pickBy } from 'lodash'; -import { Filter, FilterMeta } from './types'; -import { IndexPatternBase, IndexPatternFieldBase } from '..'; +import type { Filter, FilterMeta } from './types'; +import type { IndexPatternBase, IndexPatternFieldBase } from '../../es_query'; const OPERANDS_IN_RANGE = 2; diff --git a/packages/kbn-es-query/src/filters/types.ts b/packages/kbn-es-query/src/filters/build_filters/types.ts similarity index 100% rename from packages/kbn-es-query/src/filters/types.ts rename to packages/kbn-es-query/src/filters/build_filters/types.ts diff --git a/src/plugins/data/common/query/filter_manager/compare_filters.test.ts b/packages/kbn-es-query/src/filters/helpers/compare_filters.test.ts similarity index 99% rename from src/plugins/data/common/query/filter_manager/compare_filters.test.ts rename to packages/kbn-es-query/src/filters/helpers/compare_filters.test.ts index 506bec8143f34..1216180d76193 100644 --- a/src/plugins/data/common/query/filter_manager/compare_filters.test.ts +++ b/packages/kbn-es-query/src/filters/helpers/compare_filters.test.ts @@ -7,7 +7,7 @@ */ import { compareFilters, COMPARE_ALL_OPTIONS } from './compare_filters'; -import { buildEmptyFilter, buildQueryFilter, FilterStateStore } from '../../es_query'; +import { buildEmptyFilter, buildQueryFilter, FilterStateStore } from '..'; describe('filter manager utilities', () => { describe('compare filters', () => { diff --git a/src/plugins/data/common/query/filter_manager/compare_filters.ts b/packages/kbn-es-query/src/filters/helpers/compare_filters.ts similarity index 97% rename from src/plugins/data/common/query/filter_manager/compare_filters.ts rename to packages/kbn-es-query/src/filters/helpers/compare_filters.ts index fc820779b2461..1ca9143247eea 100644 --- a/src/plugins/data/common/query/filter_manager/compare_filters.ts +++ b/packages/kbn-es-query/src/filters/helpers/compare_filters.ts @@ -7,7 +7,7 @@ */ import { defaults, isEqual, omit, map } from 'lodash'; -import { FilterMeta, Filter } from '@kbn/es-query'; +import type { FilterMeta, Filter } from '../build_filters'; export interface FilterCompareOptions { index?: boolean; diff --git a/src/plugins/data/common/query/filter_manager/dedup_filters.test.ts b/packages/kbn-es-query/src/filters/helpers/dedup_filters.test.ts similarity index 76% rename from src/plugins/data/common/query/filter_manager/dedup_filters.test.ts rename to packages/kbn-es-query/src/filters/helpers/dedup_filters.test.ts index 6926bb53f05ac..0d86e95c67f24 100644 --- a/src/plugins/data/common/query/filter_manager/dedup_filters.test.ts +++ b/packages/kbn-es-query/src/filters/helpers/dedup_filters.test.ts @@ -6,28 +6,33 @@ * Side Public License, v 1. */ +import { IndexPatternBase, IndexPatternFieldBase } from '../../es_query'; +import { buildQueryFilter, buildRangeFilter, Filter, FilterStateStore } from '../build_filters'; import { dedupFilters } from './dedup_filters'; -import { Filter, buildRangeFilter, buildQueryFilter, FilterStateStore } from '../../es_query'; -import { IIndexPattern, IFieldType } from '../../index_patterns'; describe('filter manager utilities', () => { - let indexPattern: IIndexPattern; + let indexPattern: IndexPatternBase; beforeEach(() => { indexPattern = { id: 'index', - } as IIndexPattern; + } as IndexPatternBase; }); describe('dedupFilters(existing, filters)', () => { test('should return only filters which are not in the existing', () => { const existing: Filter[] = [ - buildRangeFilter({ name: 'bytes' } as IFieldType, { from: 0, to: 1024 }, indexPattern, ''), + buildRangeFilter( + { name: 'bytes' } as IndexPatternFieldBase, + { from: 0, to: 1024 }, + indexPattern, + '' + ), buildQueryFilter({ match: { _term: { query: 'apache', type: 'phrase' } } }, 'index', ''), ]; const filters: Filter[] = [ buildRangeFilter( - { name: 'bytes' } as IFieldType, + { name: 'bytes' } as IndexPatternFieldBase, { from: 1024, to: 2048 }, indexPattern, '' @@ -42,7 +47,12 @@ describe('filter manager utilities', () => { test('should ignore the disabled attribute when comparing ', () => { const existing: Filter[] = [ - buildRangeFilter({ name: 'bytes' } as IFieldType, { from: 0, to: 1024 }, indexPattern, ''), + buildRangeFilter( + { name: 'bytes' } as IndexPatternFieldBase, + { from: 0, to: 1024 }, + indexPattern, + '' + ), { ...buildQueryFilter( { match: { _term: { query: 'apache', type: 'phrase' } } }, @@ -54,7 +64,7 @@ describe('filter manager utilities', () => { ]; const filters: Filter[] = [ buildRangeFilter( - { name: 'bytes' } as IFieldType, + { name: 'bytes' } as IndexPatternFieldBase, { from: 1024, to: 2048 }, indexPattern, '' @@ -69,7 +79,12 @@ describe('filter manager utilities', () => { test('should ignore $state attribute', () => { const existing: Filter[] = [ - buildRangeFilter({ name: 'bytes' } as IFieldType, { from: 0, to: 1024 }, indexPattern, ''), + buildRangeFilter( + { name: 'bytes' } as IndexPatternFieldBase, + { from: 0, to: 1024 }, + indexPattern, + '' + ), { ...buildQueryFilter( { match: { _term: { query: 'apache', type: 'phrase' } } }, @@ -81,7 +96,7 @@ describe('filter manager utilities', () => { ]; const filters: Filter[] = [ buildRangeFilter( - { name: 'bytes' } as IFieldType, + { name: 'bytes' } as IndexPatternFieldBase, { from: 1024, to: 2048 }, indexPattern, '' diff --git a/src/plugins/data/common/query/filter_manager/dedup_filters.ts b/packages/kbn-es-query/src/filters/helpers/dedup_filters.ts similarity index 96% rename from src/plugins/data/common/query/filter_manager/dedup_filters.ts rename to packages/kbn-es-query/src/filters/helpers/dedup_filters.ts index f4e9535489f94..564354d012371 100644 --- a/src/plugins/data/common/query/filter_manager/dedup_filters.ts +++ b/packages/kbn-es-query/src/filters/helpers/dedup_filters.ts @@ -7,8 +7,8 @@ */ import { filter, find } from 'lodash'; +import type { Filter } from '..'; import { compareFilters, FilterCompareOptions } from './compare_filters'; -import { Filter } from '../../es_query'; /** * Combine 2 filter collections, removing duplicates diff --git a/src/plugins/data/common/query/filter_manager/index.ts b/packages/kbn-es-query/src/filters/helpers/index.ts similarity index 65% rename from src/plugins/data/common/query/filter_manager/index.ts rename to packages/kbn-es-query/src/filters/helpers/index.ts index 81909f2b0cae0..d94719ea46b27 100644 --- a/src/plugins/data/common/query/filter_manager/index.ts +++ b/packages/kbn-es-query/src/filters/helpers/index.ts @@ -6,6 +6,8 @@ * Side Public License, v 1. */ -export { dedupFilters } from './dedup_filters'; -export { uniqFilters } from './uniq_filters'; -export { compareFilters, COMPARE_ALL_OPTIONS, FilterCompareOptions } from './compare_filters'; +export * from './compare_filters'; +export * from './dedup_filters'; +export * from './uniq_filters'; +export * from './meta_filter'; +export * from './only_disabled'; diff --git a/packages/kbn-es-query/src/filters/meta_filter.ts b/packages/kbn-es-query/src/filters/helpers/meta_filter.ts similarity index 81% rename from packages/kbn-es-query/src/filters/meta_filter.ts rename to packages/kbn-es-query/src/filters/helpers/meta_filter.ts index 25fd26c410826..91f5186570195 100644 --- a/packages/kbn-es-query/src/filters/meta_filter.ts +++ b/packages/kbn-es-query/src/filters/helpers/meta_filter.ts @@ -6,21 +6,8 @@ * Side Public License, v 1. */ -import { Filter, FilterMeta, FilterState, FilterStateStore } from './types'; - -export const buildEmptyFilter = (isPinned: boolean, index?: string): Filter => { - const meta: FilterMeta = { - disabled: false, - negate: false, - alias: null, - index, - }; - const $state: FilterState = { - store: isPinned ? FilterStateStore.GLOBAL_STATE : FilterStateStore.APP_STATE, - }; - - return { meta, $state }; -}; +import { omit, get } from 'lodash'; +import { Filter, FilterStateStore } from '../build_filters'; export const isFilterPinned = (filter: Filter) => { return filter.$state && filter.$state.store === FilterStateStore.GLOBAL_STATE; @@ -68,3 +55,12 @@ export const isFilter = (x: unknown): x is Filter => export const isFilters = (x: unknown): x is Filter[] => Array.isArray(x) && !x.find((y) => !isFilter(y)); + +/** + * Clean out any invalid attributes from the filters + * @param {object} filter The filter to clean + * @returns {object} + */ +export const cleanFilter = (filter: Filter): Filter => omit(filter, ['meta', '$state']) as Filter; + +export const isFilterDisabled = (filter: Filter): boolean => get(filter, 'meta.disabled', false); diff --git a/src/plugins/data/public/query/filter_manager/lib/only_disabled.test.ts b/packages/kbn-es-query/src/filters/helpers/only_disabled.test.ts similarity index 99% rename from src/plugins/data/public/query/filter_manager/lib/only_disabled.test.ts rename to packages/kbn-es-query/src/filters/helpers/only_disabled.test.ts index 1abb535046227..8f631682c28b0 100644 --- a/src/plugins/data/public/query/filter_manager/lib/only_disabled.test.ts +++ b/packages/kbn-es-query/src/filters/helpers/only_disabled.test.ts @@ -6,8 +6,8 @@ * Side Public License, v 1. */ +import { Filter } from '../build_filters'; import { onlyDisabledFiltersChanged } from './only_disabled'; -import { Filter } from '../../../../common'; describe('filter manager utilities', () => { describe('onlyDisabledFiltersChanged()', () => { diff --git a/src/plugins/data/public/query/filter_manager/lib/only_disabled.ts b/packages/kbn-es-query/src/filters/helpers/only_disabled.ts similarity index 89% rename from src/plugins/data/public/query/filter_manager/lib/only_disabled.ts rename to packages/kbn-es-query/src/filters/helpers/only_disabled.ts index 106cd754ab42d..d090c411934f7 100644 --- a/src/plugins/data/public/query/filter_manager/lib/only_disabled.ts +++ b/packages/kbn-es-query/src/filters/helpers/only_disabled.ts @@ -7,7 +7,8 @@ */ import { filter } from 'lodash'; -import { Filter, compareFilters, COMPARE_ALL_OPTIONS } from '../../../../common'; +import type { Filter } from '..'; +import { compareFilters, COMPARE_ALL_OPTIONS } from './compare_filters'; const isEnabled = (f: Filter) => f && f.meta && !f.meta.disabled; diff --git a/src/plugins/data/common/query/filter_manager/uniq_filters.test.ts b/packages/kbn-es-query/src/filters/helpers/uniq_filters.test.ts similarity index 96% rename from src/plugins/data/common/query/filter_manager/uniq_filters.test.ts rename to packages/kbn-es-query/src/filters/helpers/uniq_filters.test.ts index 180a91bded9e2..bc72df6237831 100644 --- a/src/plugins/data/common/query/filter_manager/uniq_filters.test.ts +++ b/packages/kbn-es-query/src/filters/helpers/uniq_filters.test.ts @@ -6,8 +6,8 @@ * Side Public License, v 1. */ +import { buildQueryFilter, Filter, FilterStateStore } from '../build_filters'; import { uniqFilters } from './uniq_filters'; -import { buildQueryFilter, Filter, FilterStateStore } from '../../es_query'; describe('filter manager utilities', () => { describe('niqFilter', () => { diff --git a/src/plugins/data/common/query/filter_manager/uniq_filters.ts b/packages/kbn-es-query/src/filters/helpers/uniq_filters.ts similarity index 95% rename from src/plugins/data/common/query/filter_manager/uniq_filters.ts rename to packages/kbn-es-query/src/filters/helpers/uniq_filters.ts index b0749e13658ce..e502cd5dbba5d 100644 --- a/src/plugins/data/common/query/filter_manager/uniq_filters.ts +++ b/packages/kbn-es-query/src/filters/helpers/uniq_filters.ts @@ -7,7 +7,7 @@ */ import { each, union } from 'lodash'; -import { Filter } from '../../es_query'; +import type { Filter } from '..'; import { dedupFilters } from './dedup_filters'; /** diff --git a/packages/kbn-es-query/src/filters/index.ts b/packages/kbn-es-query/src/filters/index.ts index 90c1675e8a3cf..57139dc5110a4 100644 --- a/packages/kbn-es-query/src/filters/index.ts +++ b/packages/kbn-es-query/src/filters/index.ts @@ -6,31 +6,74 @@ * Side Public License, v 1. */ -import { omit, get } from 'lodash'; -import { Filter } from './types'; +export { + dedupFilters, + uniqFilters, + compareFilters, + COMPARE_ALL_OPTIONS, + FilterCompareOptions, + cleanFilter, + isFilter, + isFilters, + pinFilter, + isFilterPinned, + onlyDisabledFiltersChanged, + enableFilter, + disableFilter, + isFilterDisabled, + toggleFilterNegated, + toggleFilterDisabled, + toggleFilterPinned, + unpinFilter, +} from './helpers'; -export * from './build_filters'; -export * from './custom_filter'; -export * from './exists_filter'; -export * from './geo_bounding_box_filter'; -export * from './geo_polygon_filter'; -export * from './get_filter_field'; -export * from './get_filter_params'; -export * from './match_all_filter'; -export * from './meta_filter'; -export * from './missing_filter'; -export * from './phrase_filter'; -export * from './phrases_filter'; -export * from './query_string_filter'; -export * from './range_filter'; +export { + isExistsFilter, + isMatchAllFilter, + isGeoBoundingBoxFilter, + isGeoPolygonFilter, + isMissingFilter, + isPhraseFilter, + isPhrasesFilter, + isRangeFilter, + isQueryStringFilter, + getFilterField, + buildQueryFilter, + buildPhrasesFilter, + buildPhraseFilter, + buildRangeFilter, + buildCustomFilter, + buildFilter, + buildEmptyFilter, + buildExistsFilter, + getRangeScript, + getPhraseScript, + getConvertedValueForField, + getPhraseFilterValue, + getPhraseFilterField, + isScriptedPhraseFilter, + isScriptedRangeFilter, + getFilterParams, +} from './build_filters'; -export { Query, Filter, FILTERS, LatLon, FilterStateStore, FieldFilter, FilterMeta } from './types'; +export { + Query, + Filter, + FilterState, + LatLon, + FieldFilter, + FilterMeta, + ExistsFilter, + RangeFilter, + PhraseFilter, + PhrasesFilter, + RangeFilterMeta, + GeoPolygonFilter, + MatchAllFilter, + CustomFilter, + MissingFilter, + GeoBoundingBoxFilter, + RangeFilterParams, +} from './build_filters'; -/** - * Clean out any invalid attributes from the filters - * @param {object} filter The filter to clean - * @returns {object} - */ -export const cleanFilter = (filter: Filter): Filter => omit(filter, ['meta', '$state']) as Filter; - -export const isFilterDisabled = (filter: Filter): boolean => get(filter, 'meta.disabled', false); +export { FilterStateStore, FILTERS } from './build_filters/types'; diff --git a/src/plugins/data/common/es_query/index.ts b/src/plugins/data/common/es_query/index.ts index 6d5084900b11d..b24ddf7303694 100644 --- a/src/plugins/data/common/es_query/index.ts +++ b/src/plugins/data/common/es_query/index.ts @@ -10,6 +10,9 @@ export { getEsQueryConfig } from './get_es_query_config'; // NOTE: Trick to deprecate exports https://stackoverflow.com/a/49152018/372086 import { + enableFilter as oldEnableFilter, + pinFilter as oldPinFilter, + toggleFilterDisabled as oldToggleFilterDisabled, isFilterDisabled as oldIsFilterDisabled, disableFilter as oldDisableFilter, fromKueryExpression as oldFromKueryExpression, @@ -59,256 +62,306 @@ import { FILTERS as oldFILTERS, IFieldSubType as oldIFieldSubType, EsQueryConfig as oldEsQueryConfig, + compareFilters as oldCompareFilters, + COMPARE_ALL_OPTIONS as OLD_COMPARE_ALL_OPTIONS, + dedupFilters as oldDedupFilters, isFilter as oldIsFilter, + onlyDisabledFiltersChanged as oldOnlyDisabledFiltersChanged, + uniqFilters as oldUniqFilters, FilterStateStore, } from '@kbn/es-query'; /** - * @deprecated Please import from the package kbn/es-query directly. This import will be deprecated in v8.0.0. + * @deprecated Please import from the package kbn/es-query directly. This import will be removed in v8.0.0. */ const isFilter = oldIsFilter; /** - * @deprecated Please import from the package kbn/es-query directly. This import will be deprecated in v8.0.0. + * @deprecated Please import from the package kbn/es-query directly. This import will be removed in v8.0.0. */ const isFilterDisabled = oldIsFilterDisabled; /** - * @deprecated Please import from the package kbn/es-query directly. This import will be deprecated in v8.0.0. + * @deprecated Please import from the package kbn/es-query directly. This import will be removed in v8.0.0. */ const disableFilter = oldDisableFilter; /** - * @deprecated Please import from the package kbn/es-query directly. This import will be deprecated in v8.0.0. + * @deprecated Please import from the package kbn/es-query directly. This import will be removed in v8.0.0. */ const fromKueryExpression = oldFromKueryExpression; /** - * @deprecated Please import from the package kbn/es-query directly. This import will be deprecated in v8.0.0. + * @deprecated Please import from the package kbn/es-query directly. This import will be removed in v8.0.0. */ const toElasticsearchQuery = oldToElasticsearchQuery; /** - * @deprecated Please import from the package kbn/es-query directly. This import will be deprecated in v8.0.0. + * @deprecated Please import from the package kbn/es-query directly. This import will be removed in v8.0.0. */ const nodeTypes = oldNodeTypes; /** - * @deprecated Please import from the package kbn/es-query directly. This import will be deprecated in v8.0.0. + * @deprecated Please import from the package kbn/es-query directly. This import will be removed in v8.0.0. */ const buildEsQuery = oldBuildEsQuery; /** - * @deprecated Please import from the package kbn/es-query directly. This import will be deprecated in v8.0.0. + * @deprecated Please import from the package kbn/es-query directly. This import will be removed in v8.0.0. */ const buildQueryFromFilters = oldBuildQueryFromFilters; /** - * @deprecated Please import from the package kbn/es-query directly. This import will be deprecated in v8.0.0. + * @deprecated Please import from the package kbn/es-query directly. This import will be removed in v8.0.0. */ const luceneStringToDsl = oldLuceneStringToDsl; /** - * @deprecated Please import from the package kbn/es-query directly. This import will be deprecated in v8.0.0. + * @deprecated Please import from the package kbn/es-query directly. This import will be removed in v8.0.0. */ const decorateQuery = olddecorateQuery; /** - * @deprecated Please import from the package kbn/es-query directly. This import will be deprecated in v8.0.0. + * @deprecated Please import from the package kbn/es-query directly. This import will be removed in v8.0.0. */ const getPhraseFilterField = oldgetPhraseFilterField; /** - * @deprecated Please import from the package kbn/es-query directly. This import will be deprecated in v8.0.0. + * @deprecated Please import from the package kbn/es-query directly. This import will be removed in v8.0.0. */ const getPhraseFilterValue = oldgetPhraseFilterValue; /** - * @deprecated Please import from the package kbn/es-query directly. This import will be deprecated in v8.0.0. + * @deprecated Please import from the package kbn/es-query directly. This import will be removed in v8.0.0. */ const isFilterPinned = oldIsFilterPinned; /** - * @deprecated Please import from the package kbn/es-query directly. This import will be deprecated in v8.0.0. + * @deprecated Please import from the package kbn/es-query directly. This import will be removed in v8.0.0. */ const nodeBuilder = oldNodeBuilder; /** - * @deprecated Please import from the package kbn/es-query directly. This import will be deprecated in v8.0.0. + * @deprecated Please import from the package kbn/es-query directly. This import will be removed in v8.0.0. */ const isFilters = oldIsFilters; /** - * @deprecated Please import from the package kbn/es-query directly. This import will be deprecated in v8.0.0. + * @deprecated Please import from the package kbn/es-query directly. This import will be removed in v8.0.0. + */ +const uniqFilters = oldUniqFilters; + +/** + * @deprecated Please import from the package kbn/es-query directly. This import will be removed in v8.0.0. + */ +const onlyDisabledFiltersChanged = oldOnlyDisabledFiltersChanged; + +/** + * @deprecated Please import from the package kbn/es-query directly. This import will be removed in v8.0.0. */ const isExistsFilter = oldIsExistsFilter; /** - * @deprecated Please import from the package kbn/es-query directly. This import will be deprecated in v8.0.0. + * @deprecated Please import from the package kbn/es-query directly. This import will be removed in v8.0.0. */ const isMatchAllFilter = oldIsMatchAllFilter; /** - * @deprecated Please import from the package kbn/es-query directly. This import will be deprecated in v8.0.0. + * @deprecated Please import from the package kbn/es-query directly. This import will be removed in v8.0.0. */ const isGeoBoundingBoxFilter = oldIsGeoBoundingBoxFilter; /** - * @deprecated Please import from the package kbn/es-query directly. This import will be deprecated in v8.0.0. + * @deprecated Please import from the package kbn/es-query directly. This import will be removed in v8.0.0. */ const isGeoPolygonFilter = oldIsGeoPolygonFilter; /** - * @deprecated Please import from the package kbn/es-query directly. This import will be deprecated in v8.0.0. + * @deprecated Please import from the package kbn/es-query directly. This import will be removed in v8.0.0. */ const isMissingFilter = oldIsMissingFilter; /** - * @deprecated Please import from the package kbn/es-query directly. This import will be deprecated in v8.0.0. + * @deprecated Please import from the package kbn/es-query directly. This import will be removed in v8.0.0. */ const isPhraseFilter = oldIsPhraseFilter; /** - * @deprecated Please import from the package kbn/es-query directly. This import will be deprecated in v8.0.0. + * @deprecated Please import from the package kbn/es-query directly. This import will be removed in v8.0.0. */ const isPhrasesFilter = oldIsPhrasesFilter; /** - * @deprecated Please import from the package kbn/es-query directly. This import will be deprecated in v8.0.0. + * @deprecated Please import from the package kbn/es-query directly. This import will be removed in v8.0.0. */ const isRangeFilter = oldIsRangeFilter; /** - * @deprecated Please import from the package kbn/es-query directly. This import will be deprecated in v8.0.0. + * @deprecated Please import from the package kbn/es-query directly. This import will be removed in v8.0.0. */ const isQueryStringFilter = oldIsQueryStringFilter; /** - * @deprecated Please import from the package kbn/es-query directly. This import will be deprecated in v8.0.0. + * @deprecated Please import from the package kbn/es-query directly. This import will be removed in v8.0.0. */ const buildQueryFilter = oldBuildQueryFilter; /** - * @deprecated Please import from the package kbn/es-query directly. This import will be deprecated in v8.0.0. + * @deprecated Please import from the package kbn/es-query directly. This import will be removed in v8.0.0. */ const buildPhrasesFilter = oldBuildPhrasesFilter; /** - * @deprecated Please import from the package kbn/es-query directly. This import will be deprecated in v8.0.0. + * @deprecated Please import from the package kbn/es-query directly. This import will be removed in v8.0.0. */ const buildPhraseFilter = oldBuildPhraseFilter; /** - * @deprecated Please import from the package kbn/es-query directly. This import will be deprecated in v8.0.0. + * @deprecated Please import from the package kbn/es-query directly. This import will be removed in v8.0.0. */ const buildRangeFilter = oldBuildRangeFilter; /** - * @deprecated Please import from the package kbn/es-query directly. This import will be deprecated in v8.0.0. + * @deprecated Please import from the package kbn/es-query directly. This import will be removed in v8.0.0. */ const buildCustomFilter = oldBuildCustomFilter; /** - * @deprecated Please import from the package kbn/es-query directly. This import will be deprecated in v8.0.0. + * @deprecated Please import from the package kbn/es-query directly. This import will be removed in v8.0.0. */ const buildFilter = oldBuildFilter; /** - * @deprecated Please import from the package kbn/es-query directly. This import will be deprecated in v8.0.0. + * @deprecated Please import from the package kbn/es-query directly. This import will be removed in v8.0.0. */ const buildEmptyFilter = oldBuildEmptyFilter; /** - * @deprecated Please import from the package kbn/es-query directly. This import will be deprecated in v8.0.0. + * @deprecated Please import from the package kbn/es-query directly. This import will be removed in v8.0.0. */ const buildExistsFilter = oldBuildExistsFilter; /** - * @deprecated Please import from the package kbn/es-query directly. This import will be deprecated in v8.0.0. + * @deprecated Please import from the package kbn/es-query directly. This import will be removed in v8.0.0. */ const toggleFilterNegated = oldtoggleFilterNegated; /** - * @deprecated Please import from the package kbn/es-query directly. This import will be deprecated in v8.0.0. + * @deprecated Please import from the package kbn/es-query directly. This import will be removed in v8.0.0. + */ +const enableFilter = oldEnableFilter; + +/** + * @deprecated Please import from the package kbn/es-query directly. This import will be removed in v8.0.0. + */ +const pinFilter = oldPinFilter; + +/** + * @deprecated Please import from the package kbn/es-query directly. This import will be removed in v8.0.0. + */ +const toggleFilterDisabled = oldToggleFilterDisabled; + +/** + * @deprecated Please import from the package kbn/es-query directly. This import will be removed in v8.0.0. + */ +const compareFilters = oldCompareFilters; + +/** + * @deprecated Please import from the package kbn/es-query directly. This import will be removed in v8.0.0. + */ +const dedupFilters = oldDedupFilters; + +/** + * @deprecated Please import from the package kbn/es-query directly. This import will be removed in v8.0.0. + */ +const COMPARE_ALL_OPTIONS = OLD_COMPARE_ALL_OPTIONS; + +/** + * @deprecated Please import from the package kbn/es-query directly. This import will be removed in v8.0.0. */ const FILTERS = oldFILTERS; /** - * @deprecated Please import from the package kbn/es-query directly. This import will be deprecated in v8.0.0. + * @deprecated Please import from the package kbn/es-query directly. This import will be removed in v8.0.0. */ type Filter = oldFilter; /** - * @deprecated Please import from the package kbn/es-query directly. This import will be deprecated in v8.0.0. + * @deprecated Please import from the package kbn/es-query directly. This import will be removed in v8.0.0. */ type RangeFilterMeta = oldRangeFilterMeta; /** - * @deprecated Please import from the package kbn/es-query directly. This import will be deprecated in v8.0.0. + * @deprecated Please import from the package kbn/es-query directly. This import will be removed in v8.0.0. */ type RangeFilterParams = oldRangeFilterParams; /** - * @deprecated Please import from the package kbn/es-query directly. This import will be deprecated in v8.0.0. + * @deprecated Please import from the package kbn/es-query directly. This import will be removed in v8.0.0. */ type ExistsFilter = oldExistsFilter; /** - * @deprecated Please import from the package kbn/es-query directly. This import will be deprecated in v8.0.0. + * @deprecated Please import from the package kbn/es-query directly. This import will be removed in v8.0.0. */ type GeoPolygonFilter = oldGeoPolygonFilter; /** - * @deprecated Please import from the package kbn/es-query directly. This import will be deprecated in v8.0.0. + * @deprecated Please import from the package kbn/es-query directly. This import will be removed in v8.0.0. */ type PhrasesFilter = oldPhrasesFilter; /** - * @deprecated Please import from the package kbn/es-query directly. This import will be deprecated in v8.0.0. + * @deprecated Please import from the package kbn/es-query directly. This import will be removed in v8.0.0. */ type PhraseFilter = oldPhraseFilter; /** - * @deprecated Please import from the package kbn/es-query directly. This import will be deprecated in v8.0.0. + * @deprecated Please import from the package kbn/es-query directly. This import will be removed in v8.0.0. */ type MatchAllFilter = oldMatchAllFilter; /** - * @deprecated Please import from the package kbn/es-query directly. This import will be deprecated in v8.0.0. + * @deprecated Please import from the package kbn/es-query directly. This import will be removed in v8.0.0. */ type CustomFilter = oldCustomFilter; /** - * @deprecated Please import from the package kbn/es-query directly. This import will be deprecated in v8.0.0. + * @deprecated Please import from the package kbn/es-query directly. This import will be removed in v8.0.0. */ type MissingFilter = oldMissingFilter; /** - * @deprecated Please import from the package kbn/es-query directly. This import will be deprecated in v8.0.0. + * @deprecated Please import from the package kbn/es-query directly. This import will be removed in v8.0.0. */ type RangeFilter = oldRangeFilter; /** - * @deprecated Please import from the package kbn/es-query directly. This import will be deprecated in v8.0.0. + * @deprecated Please import from the package kbn/es-query directly. This import will be removed in v8.0.0. */ type GeoBoundingBoxFilter = oldGeoBoundingBoxFilter; /** - * @deprecated Please import from the package kbn/es-query directly. This import will be deprecated in v8.0.0. + * @deprecated Please import from the package kbn/es-query directly. This import will be removed in v8.0.0. */ type KueryNode = oldKueryNode; /** - * @deprecated Please import from the package kbn/es-query directly. This import will be deprecated in v8.0.0. + * @deprecated Please import from the package kbn/es-query directly. This import will be removed in v8.0.0. */ type FilterMeta = oldFilterMeta; /** - * @deprecated Please import from the package kbn/es-query directly. This import will be deprecated in v8.0.0. + * @deprecated Please import from the package kbn/es-query directly. This import will be removed in v8.0.0. */ type IFieldSubType = oldIFieldSubType; /** - * @deprecated Please import from the package kbn/es-query directly. This import will be deprecated in v8.0.0. + * @deprecated Please import from the package kbn/es-query directly. This import will be removed in v8.0.0. */ type EsQueryConfig = oldEsQueryConfig; /** - * @deprecated Please import from the package kbn/es-query directly. This import will be deprecated in v8.0.0. + * @deprecated Please import from the package kbn/es-query directly. This import will be removed in v8.0.0. */ export { + COMPARE_ALL_OPTIONS, + compareFilters, + enableFilter, + pinFilter, + toggleFilterDisabled, disableFilter, fromKueryExpression, toElasticsearchQuery, @@ -343,6 +396,9 @@ export { FILTERS, isFilter, isFilterDisabled, + dedupFilters, + onlyDisabledFiltersChanged, + uniqFilters, FilterStateStore, Filter, RangeFilterMeta, diff --git a/src/plugins/data/common/query/index.ts b/src/plugins/data/common/query/index.ts index 63de416e7b5bf..35b1617dfa7d6 100644 --- a/src/plugins/data/common/query/index.ts +++ b/src/plugins/data/common/query/index.ts @@ -6,7 +6,6 @@ * Side Public License, v 1. */ -export * from './filter_manager'; export * from './timefilter'; export * from './types'; export * from './is_query'; diff --git a/src/plugins/data/common/query/timefilter/get_time.ts b/src/plugins/data/common/query/timefilter/get_time.ts index 64842be20fbad..4c20e49f53315 100644 --- a/src/plugins/data/common/query/timefilter/get_time.ts +++ b/src/plugins/data/common/query/timefilter/get_time.ts @@ -8,7 +8,7 @@ import dateMath from '@elastic/datemath'; import { buildRangeFilter } from '@kbn/es-query'; -import { IIndexPattern, TimeRange, TimeRangeBounds } from '../..'; +import type { IIndexPattern, TimeRange, TimeRangeBounds } from '../..'; interface CalculateBoundsOptions { forceNow?: Date; diff --git a/src/plugins/data/common/search/expressions/kibana_context.ts b/src/plugins/data/common/search/expressions/kibana_context.ts index 8112777b9b0f3..fb766b497c39c 100644 --- a/src/plugins/data/common/search/expressions/kibana_context.ts +++ b/src/plugins/data/common/search/expressions/kibana_context.ts @@ -11,8 +11,8 @@ import { i18n } from '@kbn/i18n'; import { ExpressionFunctionDefinition, ExecutionContext } from 'src/plugins/expressions/common'; import { Adapters } from 'src/plugins/inspector/common'; import { Filter } from '@kbn/es-query'; +import { Query, uniqFilters } from '@kbn/es-query'; import { unboxExpressionValue } from '../../../../expressions/common'; -import { Query, uniqFilters } from '../../query'; import { ExecutionContextSearch, KibanaContext, KibanaFilter } from './kibana_context_type'; import { KibanaQueryOutput } from './kibana_context_type'; import { KibanaTimerangeOutput } from './timerange'; diff --git a/src/plugins/data/public/deprecated.ts b/src/plugins/data/public/deprecated.ts new file mode 100644 index 0000000000000..229b6b39d9ad8 --- /dev/null +++ b/src/plugins/data/public/deprecated.ts @@ -0,0 +1,173 @@ +/* + * 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. + */ + +/* + * Filters: + */ + +import { + getPhraseFilterField, + getPhraseFilterValue, + isExistsFilter, + isFilterPinned, + isMatchAllFilter, + isMissingFilter, + isPhraseFilter, + isPhrasesFilter, + isQueryStringFilter, + isRangeFilter, + toggleFilterNegated, + buildEmptyFilter, + buildExistsFilter, + buildPhraseFilter, + buildPhrasesFilter, + buildQueryFilter, + buildRangeFilter, + disableFilter, + fromKueryExpression, + toElasticsearchQuery, + nodeTypes, + buildEsQuery, + buildQueryFromFilters, + luceneStringToDsl, + decorateQuery, + FILTERS, + isFilter, + isFilters, + KueryNode, + RangeFilter, + RangeFilterMeta, + RangeFilterParams, + ExistsFilter, + PhrasesFilter, + PhraseFilter, + CustomFilter, + MatchAllFilter, + IFieldSubType, + EsQueryConfig, + FilterStateStore, + compareFilters, + COMPARE_ALL_OPTIONS, + onlyDisabledFiltersChanged, + getEsQueryConfig, +} from '../common'; + +import { FilterLabel, FilterItem } from './ui'; + +import { + getDisplayValueFromFilter, + generateFilters, + extractTimeRange, + changeTimeFilter as oldChangeTimeFilter, + mapAndFlattenFilters as oldMapAndFlattenFilters, + extractTimeFilter as oldExtractTimeFilter, + convertRangeFilterToTimeRangeString as oldConvertRangeFilterToTimeRangeString, +} from './query'; + +/** + * @deprecated This import will be removed in v8.0.0. + */ +const changeTimeFilter = oldChangeTimeFilter; +/** + * @deprecated This import will be removed in v8.0.0. + */ +const mapAndFlattenFilters = oldMapAndFlattenFilters; +/** + * @deprecated This import will be removed in v8.0.0. + */ +const extractTimeFilter = oldExtractTimeFilter; +/** + * @deprecated This import will be removed in v8.0.0. + */ +const convertRangeFilterToTimeRangeString = oldConvertRangeFilterToTimeRangeString; + +/** + * Filter helpers namespace: + * @deprecated Please import helpers from the package kbn/es-query directly. This import will be removed in v8.0.0. + */ +export const esFilters = { + FilterLabel, + FilterItem, + + FILTERS, + FilterStateStore, + + buildEmptyFilter, + buildPhrasesFilter, + buildExistsFilter, + buildPhraseFilter, + buildQueryFilter, + buildRangeFilter, + + isPhraseFilter, + isExistsFilter, + isPhrasesFilter, + isRangeFilter, + isMatchAllFilter, + isMissingFilter, + isQueryStringFilter, + isFilterPinned, + + toggleFilterNegated, + disableFilter, + getPhraseFilterField, + getPhraseFilterValue, + getDisplayValueFromFilter, + + compareFilters, + COMPARE_ALL_OPTIONS, + generateFilters, + onlyDisabledFiltersChanged, + + changeTimeFilter, + convertRangeFilterToTimeRangeString, + mapAndFlattenFilters, + extractTimeFilter, + extractTimeRange, +}; + +/** + * Deprecated type exports + */ +export { + KueryNode, + RangeFilter, + RangeFilterMeta, + RangeFilterParams, + ExistsFilter, + PhrasesFilter, + PhraseFilter, + CustomFilter, + MatchAllFilter, + IFieldSubType, + EsQueryConfig, + isFilter, + isFilters, +}; + +/** + * @deprecated Please import helpers from the package kbn/es-query directly. This import will be removed in v8.0.0. + */ +export const esKuery = { + nodeTypes, + fromKueryExpression, + toElasticsearchQuery, +}; + +/** + * @deprecated Please import helpers from the package kbn/es-query directly. This import will be removed in v8.0.0. + */ +export const esQuery = { + buildEsQuery, + getEsQueryConfig, + buildQueryFromFilters, + luceneStringToDsl, + decorateQuery, +}; + +export type { Filter, Query } from '../common'; diff --git a/src/plugins/data/public/index.ts b/src/plugins/data/public/index.ts index e6a5a02123c2b..e896fb9a5d4e2 100644 --- a/src/plugins/data/public/index.ts +++ b/src/plugins/data/public/index.ts @@ -17,131 +17,11 @@ import { ConfigSchema } from '../config'; * Filters: */ -import { - getPhraseFilterField, - getPhraseFilterValue, - isExistsFilter, - isFilterPinned, - isMatchAllFilter, - isMissingFilter, - isPhraseFilter, - isPhrasesFilter, - isQueryStringFilter, - isRangeFilter, - toggleFilterNegated, - buildEmptyFilter, - buildExistsFilter, - buildPhraseFilter, - buildPhrasesFilter, - buildQueryFilter, - buildRangeFilter, - disableFilter, - fromKueryExpression, - toElasticsearchQuery, - nodeTypes, - buildEsQuery, - buildQueryFromFilters, - luceneStringToDsl, - decorateQuery, - FILTERS, - FilterStateStore, - compareFilters, - COMPARE_ALL_OPTIONS, -} from '../common'; - -import { FilterLabel } from './ui'; -import { FilterItem } from './ui/filter_bar'; - -import { - getDisplayValueFromFilter, - generateFilters, - onlyDisabledFiltersChanged, - changeTimeFilter, - mapAndFlattenFilters, - extractTimeFilter, - extractTimeRange, - convertRangeFilterToTimeRangeString, -} from './query'; - -// Filter helpers namespace: -export const esFilters = { - FilterLabel, - FilterItem, - - FILTERS, - FilterStateStore, - - buildEmptyFilter, - buildPhrasesFilter, - buildExistsFilter, - buildPhraseFilter, - buildQueryFilter, - buildRangeFilter, - - isPhraseFilter, - isExistsFilter, - isPhrasesFilter, - isRangeFilter, - isMatchAllFilter, - isMissingFilter, - isQueryStringFilter, - isFilterPinned, - - toggleFilterNegated, - disableFilter, - getPhraseFilterField, - getPhraseFilterValue, - getDisplayValueFromFilter, - - compareFilters, - COMPARE_ALL_OPTIONS, - generateFilters, - onlyDisabledFiltersChanged, - - changeTimeFilter, - convertRangeFilterToTimeRangeString, - mapAndFlattenFilters, - extractTimeFilter, - extractTimeRange, -}; +export * from './deprecated'; -export { - KueryNode, - RangeFilter, - RangeFilterMeta, - RangeFilterParams, - ExistsFilter, - PhrasesFilter, - PhraseFilter, - CustomFilter, - MatchAllFilter, - IFieldSubType, - EsQueryConfig, - isFilter, - isFilters, -} from '../common'; - -import { getEsQueryConfig } from '../common'; - -/** - * @deprecated Please import helpers from the package kbn/es-query directly. This import will be deprecated in v8.0.0. - */ -export const esKuery = { - nodeTypes, - fromKueryExpression, - toElasticsearchQuery, -}; - -/** - * @deprecated Please import helpers from the package kbn/es-query directly. This import will be deprecated in v8.0.0. - */ -export const esQuery = { - buildEsQuery, - getEsQueryConfig, - buildQueryFromFilters, - luceneStringToDsl, - decorateQuery, -}; +export { getEsQueryConfig } from '../common'; +export { FilterLabel, FilterItem } from './ui'; +export { getDisplayValueFromFilter, generateFilters, extractTimeRange } from './query'; /* * Field Formatters: @@ -462,7 +342,7 @@ export { QueryStringInput, SearchBar } from './ui'; * Types to be shared externally * @public */ -export type { Filter, Query, RefreshInterval, TimeRange } from '../common'; +export type { RefreshInterval, TimeRange } from '../common'; export { createSavedQueryService, diff --git a/src/plugins/data/public/public.api.md b/src/plugins/data/public/public.api.md index 8ec5eeca70b06..61838c438d38d 100644 --- a/src/plugins/data/public/public.api.md +++ b/src/plugins/data/public/public.api.md @@ -62,7 +62,7 @@ import { IStorageWrapper } from 'src/plugins/kibana_utils/public'; import { IUiSettingsClient } from 'src/core/public'; import { KibanaClient } from '@elastic/elasticsearch/api/kibana'; import { KibanaExecutionContext } from 'src/core/public'; -import { KueryNode as KueryNode_2 } from '@kbn/es-query'; +import { KueryNode as KueryNode_3 } from '@kbn/es-query'; import { Location } from 'history'; import { LocationDescriptorObject } from 'history'; import { Logger } from '@kbn/logging'; @@ -814,7 +814,7 @@ export type EsdslExpressionFunctionDefinition = ExpressionFunctionDefinition JSX.Element; FilterItem: (props: import("./ui/filter_bar/filter_item").FilterItemProps) => JSX.Element; @@ -824,7 +824,7 @@ export const esFilters: { buildPhrasesFilter: (field: import("@kbn/es-query").IndexPatternFieldBase, params: any[], indexPattern: import("@kbn/es-query").IndexPatternBase) => import("@kbn/es-query").PhrasesFilter; buildExistsFilter: (field: import("@kbn/es-query").IndexPatternFieldBase, indexPattern: import("@kbn/es-query").IndexPatternBase) => import("@kbn/es-query").ExistsFilter; buildPhraseFilter: (field: import("@kbn/es-query").IndexPatternFieldBase, value: any, indexPattern: import("@kbn/es-query").IndexPatternBase) => import("@kbn/es-query").PhraseFilter; - buildQueryFilter: (query: any, index: string, alias: string) => import("@kbn/es-query").QueryStringFilter; + buildQueryFilter: (query: any, index: string, alias: string) => import("@kbn/es-query/target_types/filters/build_filters").QueryStringFilter; buildRangeFilter: (field: import("@kbn/es-query").IndexPatternFieldBase, params: import("@kbn/es-query").RangeFilterParams, indexPattern: import("@kbn/es-query").IndexPatternBase, formattedValue?: string | undefined) => import("@kbn/es-query").RangeFilter; isPhraseFilter: (filter: any) => filter is import("@kbn/es-query").PhraseFilter; isExistsFilter: (filter: any) => filter is import("@kbn/es-query").ExistsFilter; @@ -832,7 +832,7 @@ export const esFilters: { isRangeFilter: (filter: any) => filter is import("@kbn/es-query").RangeFilter; isMatchAllFilter: (filter: any) => filter is import("@kbn/es-query").MatchAllFilter; isMissingFilter: (filter: any) => filter is import("@kbn/es-query").MissingFilter; - isQueryStringFilter: (filter: any) => filter is import("@kbn/es-query").QueryStringFilter; + isQueryStringFilter: (filter: any) => filter is import("@kbn/es-query/target_types/filters/build_filters").QueryStringFilter; isFilterPinned: (filter: import("@kbn/es-query").Filter) => boolean | undefined; toggleFilterNegated: (filter: import("@kbn/es-query").Filter) => { meta: { @@ -847,15 +847,15 @@ export const esFilters: { params?: any; value?: string | undefined; }; - $state?: import("@kbn/es-query/target_types/filters/types").FilterState | undefined; + $state?: import("@kbn/es-query").FilterState | undefined; query?: any; }; disableFilter: (filter: import("@kbn/es-query").Filter) => import("@kbn/es-query").Filter; getPhraseFilterField: (filter: import("@kbn/es-query").PhraseFilter) => string; getPhraseFilterValue: (filter: import("@kbn/es-query").PhraseFilter) => string | number | boolean; getDisplayValueFromFilter: typeof getDisplayValueFromFilter; - compareFilters: (first: import("@kbn/es-query").Filter | import("@kbn/es-query").Filter[], second: import("@kbn/es-query").Filter | import("@kbn/es-query").Filter[], comparatorOptions?: import("../common").FilterCompareOptions) => boolean; - COMPARE_ALL_OPTIONS: import("../common").FilterCompareOptions; + compareFilters: (first: import("@kbn/es-query").Filter | import("@kbn/es-query").Filter[], second: import("@kbn/es-query").Filter | import("@kbn/es-query").Filter[], comparatorOptions?: import("@kbn/es-query").FilterCompareOptions | undefined) => boolean; + COMPARE_ALL_OPTIONS: import("@kbn/es-query").FilterCompareOptions; generateFilters: typeof generateFilters; onlyDisabledFiltersChanged: (newFilters?: import("@kbn/es-query").Filter[] | undefined, oldFilters?: import("@kbn/es-query").Filter[] | undefined) => boolean; changeTimeFilter: typeof changeTimeFilter; @@ -957,6 +957,14 @@ export const extractSearchSourceReferences: (state: SearchSourceFields) => [Sear indexRefName?: string; }, SavedObjectReference_2[]]; +// Warning: (ae-missing-release-tag) "extractTimeRange" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export function extractTimeRange(filters: Filter_2[], timeFieldName?: string): { + restOfFilters: Filter_2[]; + timeRange?: TimeRange; +}; + // Warning: (ae-missing-release-tag) "FieldFormat" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) @@ -1084,6 +1092,18 @@ export const fieldList: (specs?: FieldSpec[], shortDotsEnable?: boolean) => IInd // @public @deprecated (undocumented) export type Filter = Filter_2; +// Warning: (ae-forgotten-export) The symbol "FilterItemProps" needs to be exported by the entry point index.d.ts +// Warning: (ae-missing-release-tag) "FilterItem" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export const FilterItem: (props: FilterItemProps) => JSX.Element; + +// Warning: (ae-forgotten-export) The symbol "FilterLabelProps" needs to be exported by the entry point index.d.ts +// Warning: (ae-missing-release-tag) "FilterLabel" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export const FilterLabel: (props: FilterLabelProps) => JSX.Element; + // Warning: (ae-forgotten-export) The symbol "PersistableStateService" needs to be exported by the entry point index.d.ts // Warning: (ae-missing-release-tag) "FilterManager" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // @@ -1128,6 +1148,11 @@ export class FilterManager implements PersistableStateService { telemetry: (filters: import("../../../../kibana_utils/common/persistable_state").SerializableState, collector: unknown) => {}; } +// Warning: (ae-missing-release-tag) "generateFilters" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public +export function generateFilters(filterManager: FilterManager, field: IFieldType | string, values: any, operation: string, index: string): Filter_2[]; + // Warning: (ae-forgotten-export) The symbol "QueryLanguage" needs to be exported by the entry point index.d.ts // Warning: (ae-missing-release-tag) "getDefaultQuery" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // @@ -1137,12 +1162,23 @@ export function getDefaultQuery(language?: QueryLanguage): { language: QueryLanguage; }; +// Warning: (ae-missing-release-tag) "getDisplayValueFromFilter" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export function getDisplayValueFromFilter(filter: Filter, indexPatterns: IIndexPattern[]): string; + // Warning: (ae-forgotten-export) The symbol "IUiSettingsClient" needs to be exported by the entry point index.d.ts // Warning: (ae-missing-release-tag) "getEsPreference" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) export function getEsPreference(uiSettings: IUiSettingsClient_2, sessionId?: string): any; +// Warning: (ae-forgotten-export) The symbol "KibanaConfig" needs to be exported by the entry point index.d.ts +// Warning: (ae-missing-release-tag) "getEsQueryConfig" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export function getEsQueryConfig(config: KibanaConfig): EsQueryConfig_2; + // Warning: (ae-missing-release-tag) "getKbnTypeNames" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public @@ -1886,7 +1922,7 @@ export type KibanaContext = ExpressionValueSearchContext; // Warning: (ae-missing-release-tag) "KueryNode" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public @deprecated (undocumented) -export type KueryNode = KueryNode_2; +export type KueryNode = KueryNode_3; // Warning: (ae-missing-release-tag) "MatchAllFilter" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // @@ -2689,49 +2725,45 @@ export interface WaitUntilNextSessionCompletesOptions { // src/plugins/data/common/index_patterns/index_patterns/index_pattern.ts:138:7 - (ae-forgotten-export) The symbol "FieldAttrSet" needs to be exported by the entry point index.d.ts // src/plugins/data/common/index_patterns/index_patterns/index_pattern.ts:169:7 - (ae-forgotten-export) The symbol "RuntimeField" needs to be exported by the entry point index.d.ts // src/plugins/data/common/search/aggs/types.ts:129:51 - (ae-forgotten-export) The symbol "AggTypesRegistryStart" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/deprecated.ts:93:23 - (ae-forgotten-export) The symbol "changeTimeFilter" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/deprecated.ts:93:23 - (ae-forgotten-export) The symbol "convertRangeFilterToTimeRangeString" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/deprecated.ts:93:23 - (ae-forgotten-export) The symbol "extractTimeFilter" needs to be exported by the entry point index.d.ts // src/plugins/data/public/field_formats/field_formats_service.ts:56:3 - (ae-forgotten-export) The symbol "FormatFactory" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:67:23 - (ae-forgotten-export) The symbol "getDisplayValueFromFilter" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:67:23 - (ae-forgotten-export) The symbol "generateFilters" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:67:23 - (ae-forgotten-export) The symbol "changeTimeFilter" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:67:23 - (ae-forgotten-export) The symbol "convertRangeFilterToTimeRangeString" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:67:23 - (ae-forgotten-export) The symbol "extractTimeFilter" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:67:23 - (ae-forgotten-export) The symbol "extractTimeRange" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:138:21 - (ae-forgotten-export) The symbol "getEsQueryConfig" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:177:26 - (ae-forgotten-export) The symbol "FieldFormatsRegistry" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:177:26 - (ae-forgotten-export) The symbol "BoolFormat" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:177:26 - (ae-forgotten-export) The symbol "BytesFormat" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:177:26 - (ae-forgotten-export) The symbol "ColorFormat" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:177:26 - (ae-forgotten-export) The symbol "DurationFormat" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:177:26 - (ae-forgotten-export) The symbol "IpFormat" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:177:26 - (ae-forgotten-export) The symbol "NumberFormat" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:177:26 - (ae-forgotten-export) The symbol "PercentFormat" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:177:26 - (ae-forgotten-export) The symbol "RelativeDateFormat" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:177:26 - (ae-forgotten-export) The symbol "SourceFormat" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:177:26 - (ae-forgotten-export) The symbol "StaticLookupFormat" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:177:26 - (ae-forgotten-export) The symbol "UrlFormat" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:177:26 - (ae-forgotten-export) The symbol "StringFormat" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:177:26 - (ae-forgotten-export) The symbol "TruncateFormat" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:177:26 - (ae-forgotten-export) The symbol "HistogramFormat" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:220:23 - (ae-forgotten-export) The symbol "datatableToCSV" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:247:27 - (ae-forgotten-export) The symbol "isFilterable" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:247:27 - (ae-forgotten-export) The symbol "isNestedField" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:247:27 - (ae-forgotten-export) The symbol "validateIndexPattern" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:247:27 - (ae-forgotten-export) The symbol "flattenHitWrapper" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:247:27 - (ae-forgotten-export) The symbol "formatHitProvider" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:418:20 - (ae-forgotten-export) The symbol "getResponseInspectorStats" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:418:20 - (ae-forgotten-export) The symbol "tabifyAggResponse" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:418:20 - (ae-forgotten-export) The symbol "tabifyGetColumns" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:420:1 - (ae-forgotten-export) The symbol "CidrMask" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:421:1 - (ae-forgotten-export) The symbol "dateHistogramInterval" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:430:1 - (ae-forgotten-export) The symbol "InvalidEsCalendarIntervalError" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:431:1 - (ae-forgotten-export) The symbol "InvalidEsIntervalFormatError" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:432:1 - (ae-forgotten-export) The symbol "IpAddress" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:433:1 - (ae-forgotten-export) The symbol "isDateHistogramBucketAggConfig" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:437:1 - (ae-forgotten-export) The symbol "isValidEsInterval" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:438:1 - (ae-forgotten-export) The symbol "isValidInterval" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:441:1 - (ae-forgotten-export) The symbol "parseInterval" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:442:1 - (ae-forgotten-export) The symbol "propFilter" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:445:1 - (ae-forgotten-export) The symbol "toAbsoluteDates" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:57:26 - (ae-forgotten-export) The symbol "FieldFormatsRegistry" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:57:26 - (ae-forgotten-export) The symbol "BoolFormat" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:57:26 - (ae-forgotten-export) The symbol "BytesFormat" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:57:26 - (ae-forgotten-export) The symbol "ColorFormat" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:57:26 - (ae-forgotten-export) The symbol "DurationFormat" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:57:26 - (ae-forgotten-export) The symbol "IpFormat" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:57:26 - (ae-forgotten-export) The symbol "NumberFormat" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:57:26 - (ae-forgotten-export) The symbol "PercentFormat" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:57:26 - (ae-forgotten-export) The symbol "RelativeDateFormat" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:57:26 - (ae-forgotten-export) The symbol "SourceFormat" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:57:26 - (ae-forgotten-export) The symbol "StaticLookupFormat" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:57:26 - (ae-forgotten-export) The symbol "UrlFormat" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:57:26 - (ae-forgotten-export) The symbol "StringFormat" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:57:26 - (ae-forgotten-export) The symbol "TruncateFormat" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:57:26 - (ae-forgotten-export) The symbol "HistogramFormat" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:100:23 - (ae-forgotten-export) The symbol "datatableToCSV" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:127:27 - (ae-forgotten-export) The symbol "isFilterable" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:127:27 - (ae-forgotten-export) The symbol "isNestedField" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:127:27 - (ae-forgotten-export) The symbol "validateIndexPattern" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:127:27 - (ae-forgotten-export) The symbol "flattenHitWrapper" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:127:27 - (ae-forgotten-export) The symbol "formatHitProvider" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:298:20 - (ae-forgotten-export) The symbol "getResponseInspectorStats" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:298:20 - (ae-forgotten-export) The symbol "tabifyAggResponse" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:298:20 - (ae-forgotten-export) The symbol "tabifyGetColumns" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:300:1 - (ae-forgotten-export) The symbol "CidrMask" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:301:1 - (ae-forgotten-export) The symbol "dateHistogramInterval" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:310:1 - (ae-forgotten-export) The symbol "InvalidEsCalendarIntervalError" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:311:1 - (ae-forgotten-export) The symbol "InvalidEsIntervalFormatError" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:312:1 - (ae-forgotten-export) The symbol "IpAddress" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:313:1 - (ae-forgotten-export) The symbol "isDateHistogramBucketAggConfig" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:317:1 - (ae-forgotten-export) The symbol "isValidEsInterval" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:318:1 - (ae-forgotten-export) The symbol "isValidInterval" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:321:1 - (ae-forgotten-export) The symbol "parseInterval" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:322:1 - (ae-forgotten-export) The symbol "propFilter" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:325:1 - (ae-forgotten-export) The symbol "toAbsoluteDates" needs to be exported by the entry point index.d.ts // src/plugins/data/public/search/session/session_service.ts:62:5 - (ae-forgotten-export) The symbol "UrlGeneratorStateMapping" needs to be exported by the entry point index.d.ts // (No @packageDocumentation comment for this package) diff --git a/src/plugins/data/public/query/filter_manager/filter_manager.ts b/src/plugins/data/public/query/filter_manager/filter_manager.ts index d514e0eb18705..bcae190b50773 100644 --- a/src/plugins/data/public/query/filter_manager/filter_manager.ts +++ b/src/plugins/data/public/query/filter_manager/filter_manager.ts @@ -11,10 +11,9 @@ import { Subject } from 'rxjs'; import { IUiSettingsClient } from 'src/core/public'; -import { isFilterPinned, Filter } from '@kbn/es-query'; +import { isFilterPinned, onlyDisabledFiltersChanged, Filter } from '@kbn/es-query'; import { sortFilters } from './lib/sort_filters'; import { mapAndFlattenFilters } from './lib/map_and_flatten_filters'; -import { onlyDisabledFiltersChanged } from './lib/only_disabled'; import { PartitionedFilters } from './types'; import { diff --git a/src/plugins/data/public/query/filter_manager/index.ts b/src/plugins/data/public/query/filter_manager/index.ts index 55dba640b07b6..e63fda2f969b4 100644 --- a/src/plugins/data/public/query/filter_manager/index.ts +++ b/src/plugins/data/public/query/filter_manager/index.ts @@ -9,7 +9,6 @@ export { FilterManager } from './filter_manager'; export { mapAndFlattenFilters } from './lib/map_and_flatten_filters'; -export { onlyDisabledFiltersChanged } from './lib/only_disabled'; export { generateFilters } from './lib/generate_filters'; export { getDisplayValueFromFilter } from './lib/get_display_value'; export { getIndexPatternFromFilter } from './lib/get_index_pattern_from_filter'; diff --git a/src/plugins/data/public/ui/index.ts b/src/plugins/data/public/ui/index.ts index e28605cafe87a..1c8df359602b9 100644 --- a/src/plugins/data/public/ui/index.ts +++ b/src/plugins/data/public/ui/index.ts @@ -7,7 +7,7 @@ */ export { IndexPatternSelectProps } from './index_pattern_select'; -export { FilterLabel } from './filter_bar'; +export { FilterLabel, FilterItem } from './filter_bar'; export { QueryStringInput, QueryStringInputProps } from './query_string_input'; export { SearchBar, SearchBarProps, StatefulSearchBarProps } from './search_bar'; export { SuggestionsComponent } from './typeahead'; diff --git a/src/plugins/data/server/deprecated.ts b/src/plugins/data/server/deprecated.ts new file mode 100644 index 0000000000000..b414c4cc19c08 --- /dev/null +++ b/src/plugins/data/server/deprecated.ts @@ -0,0 +1,67 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { + buildQueryFilter, + buildCustomFilter, + buildEmptyFilter, + buildExistsFilter, + buildFilter, + buildPhraseFilter, + buildPhrasesFilter, + buildRangeFilter, + isFilterDisabled, + nodeTypes, + fromKueryExpression, + toElasticsearchQuery, + buildEsQuery, + buildQueryFromFilters, +} from '../common'; +/* + * @deprecated Please import from the package kbn/es-query directly. This will be deprecated in v8.0.0. + * Filter helper namespace: + */ +export const esFilters = { + buildQueryFilter, + buildCustomFilter, + buildEmptyFilter, + buildExistsFilter, + buildFilter, + buildPhraseFilter, + buildPhrasesFilter, + buildRangeFilter, + isFilterDisabled, +}; + +/* + * esQuery and esKuery: + */ + +import { getEsQueryConfig } from '../common'; + +/* + * Filter helper namespace + * @deprecated Please import from the package kbn/es-query directly. This will be deprecated in v8.0.0. + */ +export const esKuery = { + nodeTypes, + fromKueryExpression, + toElasticsearchQuery, +}; + +/* + * Filter helper namespace + * @deprecated Please import from the package kbn/es-query directly. This will be deprecated in v8.0.0. + */ +export const esQuery = { + buildQueryFromFilters, + getEsQueryConfig, + buildEsQuery, +}; + +export type { Filter, Query, EsQueryConfig, KueryNode, IFieldSubType } from '../common'; diff --git a/src/plugins/data/server/index.ts b/src/plugins/data/server/index.ts index a9e8cda082314..e0c4861ec5545 100644 --- a/src/plugins/data/server/index.ts +++ b/src/plugins/data/server/index.ts @@ -6,41 +6,12 @@ * Side Public License, v 1. */ -import { - buildQueryFilter, - buildCustomFilter, - buildEmptyFilter, - buildExistsFilter, - buildFilter, - buildPhraseFilter, - buildPhrasesFilter, - buildRangeFilter, - isFilterDisabled, - nodeTypes, - fromKueryExpression, - toElasticsearchQuery, - buildEsQuery, - buildQueryFromFilters, -} from '../common'; import { PluginConfigDescriptor, PluginInitializerContext } from '../../../core/server'; import { ConfigSchema, configSchema } from '../config'; import { DataServerPlugin, DataPluginSetup, DataPluginStart } from './plugin'; -/* - * @deprecated Please import from the package kbn/es-query directly. This will be deprecated in v8.0.0. - * Filter helper namespace: - */ -export const esFilters = { - buildQueryFilter, - buildCustomFilter, - buildEmptyFilter, - buildExistsFilter, - buildFilter, - buildPhraseFilter, - buildPhrasesFilter, - buildRangeFilter, - isFilterDisabled, -}; +export * from './deprecated'; +export { getEsQueryConfig, buildQueryFromFilters } from '../common'; /** * Exporters (CSV) @@ -52,34 +23,6 @@ export const exporters = { CSV_MIME_TYPE, }; -/* - * esQuery and esKuery: - */ - -import { getEsQueryConfig } from '../common'; - -/* - * Filter helper namespace - * @deprecated Please import from the package kbn/es-query directly. This will be deprecated in v8.0.0. - */ -export const esKuery = { - nodeTypes, - fromKueryExpression, - toElasticsearchQuery, -}; - -/* - * Filter helper namespace - * @deprecated Please import from the package kbn/es-query directly. This will be deprecated in v8.0.0. - */ -export const esQuery = { - buildQueryFromFilters, - getEsQueryConfig, - buildEsQuery, -}; - -export type { EsQueryConfig, KueryNode, IFieldSubType } from '../common'; - /* * Field Formats: */ @@ -285,10 +228,7 @@ export const search = { export { // kbn field types castEsToKbnFieldTypeName, - // query - Filter, getTime, - Query, // timefilter RefreshInterval, TimeRange, diff --git a/src/plugins/data/server/server.api.md b/src/plugins/data/server/server.api.md index 47a39c99d52ef..15632d1959493 100644 --- a/src/plugins/data/server/server.api.md +++ b/src/plugins/data/server/server.api.md @@ -343,6 +343,16 @@ export enum BUCKET_TYPES { TERMS = "terms" } +// Warning: (ae-missing-release-tag) "buildQueryFromFilters" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public @deprecated (undocumented) +export const buildQueryFromFilters: (filters: Filter_2[] | undefined, indexPattern: import("@kbn/es-query").IndexPatternBase | undefined, ignoreFilterIfFieldNotInIndex?: boolean | undefined) => { + must: never[]; + filter: Filter_2[]; + should: never[]; + must_not: Filter_2[]; +}; + // Warning: (ae-missing-release-tag) "castEsToKbnFieldTypeName" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public @@ -452,7 +462,7 @@ export type EsaggsExpressionFunctionDefinition = ExpressionFunctionDefinition<'e // // @public (undocumented) export const esFilters: { - buildQueryFilter: (query: any, index: string, alias: string) => import("@kbn/es-query").QueryStringFilter; + buildQueryFilter: (query: any, index: string, alias: string) => import("@kbn/es-query/target_types/filters/build_filters").QueryStringFilter; buildCustomFilter: typeof import("@kbn/es-query").buildCustomFilter; buildEmptyFilter: (isPinned: boolean, index?: string | undefined) => import("@kbn/es-query").Filter; buildExistsFilter: (field: import("@kbn/es-query").IndexPatternFieldBase, indexPattern: import("@kbn/es-query").IndexPatternBase) => import("@kbn/es-query").ExistsFilter; @@ -611,6 +621,12 @@ export function getCapabilitiesForRollupIndices(indices: Record>; +// Warning: (ae-forgotten-export) The symbol "KibanaConfig" needs to be exported by the entry point index.d.ts +// Warning: (ae-missing-release-tag) "getEsQueryConfig" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export function getEsQueryConfig(config: KibanaConfig): EsQueryConfig_2; + // Warning: (ae-missing-release-tag) "getShardTimeout" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) @@ -1486,38 +1502,37 @@ export function usageProvider(core: CoreSetup_2): SearchUsage; // src/plugins/data/common/index_patterns/index_patterns/index_pattern.ts:65:5 - (ae-forgotten-export) The symbol "FormatFieldFn" needs to be exported by the entry point index.d.ts // src/plugins/data/common/index_patterns/index_patterns/index_pattern.ts:138:7 - (ae-forgotten-export) The symbol "FieldAttrSet" needs to be exported by the entry point index.d.ts // src/plugins/data/common/index_patterns/index_patterns/index_pattern.ts:169:7 - (ae-forgotten-export) The symbol "RuntimeField" needs to be exported by the entry point index.d.ts -// src/plugins/data/server/index.ts:50:23 - (ae-forgotten-export) The symbol "datatableToCSV" needs to be exported by the entry point index.d.ts -// src/plugins/data/server/index.ts:75:21 - (ae-forgotten-export) The symbol "getEsQueryConfig" needs to be exported by the entry point index.d.ts -// src/plugins/data/server/index.ts:106:26 - (ae-forgotten-export) The symbol "FieldFormatsRegistry" needs to be exported by the entry point index.d.ts -// src/plugins/data/server/index.ts:106:26 - (ae-forgotten-export) The symbol "FieldFormat" needs to be exported by the entry point index.d.ts -// src/plugins/data/server/index.ts:106:26 - (ae-forgotten-export) The symbol "BoolFormat" needs to be exported by the entry point index.d.ts -// src/plugins/data/server/index.ts:106:26 - (ae-forgotten-export) The symbol "BytesFormat" needs to be exported by the entry point index.d.ts -// src/plugins/data/server/index.ts:106:26 - (ae-forgotten-export) The symbol "ColorFormat" needs to be exported by the entry point index.d.ts -// src/plugins/data/server/index.ts:106:26 - (ae-forgotten-export) The symbol "DurationFormat" needs to be exported by the entry point index.d.ts -// src/plugins/data/server/index.ts:106:26 - (ae-forgotten-export) The symbol "IpFormat" needs to be exported by the entry point index.d.ts -// src/plugins/data/server/index.ts:106:26 - (ae-forgotten-export) The symbol "NumberFormat" needs to be exported by the entry point index.d.ts -// src/plugins/data/server/index.ts:106:26 - (ae-forgotten-export) The symbol "PercentFormat" needs to be exported by the entry point index.d.ts -// src/plugins/data/server/index.ts:106:26 - (ae-forgotten-export) The symbol "RelativeDateFormat" needs to be exported by the entry point index.d.ts -// src/plugins/data/server/index.ts:106:26 - (ae-forgotten-export) The symbol "SourceFormat" needs to be exported by the entry point index.d.ts -// src/plugins/data/server/index.ts:106:26 - (ae-forgotten-export) The symbol "StaticLookupFormat" needs to be exported by the entry point index.d.ts -// src/plugins/data/server/index.ts:106:26 - (ae-forgotten-export) The symbol "UrlFormat" needs to be exported by the entry point index.d.ts -// src/plugins/data/server/index.ts:106:26 - (ae-forgotten-export) The symbol "StringFormat" needs to be exported by the entry point index.d.ts -// src/plugins/data/server/index.ts:106:26 - (ae-forgotten-export) The symbol "TruncateFormat" needs to be exported by the entry point index.d.ts -// src/plugins/data/server/index.ts:106:26 - (ae-forgotten-export) The symbol "HistogramFormat" needs to be exported by the entry point index.d.ts -// src/plugins/data/server/index.ts:138:27 - (ae-forgotten-export) The symbol "isFilterable" needs to be exported by the entry point index.d.ts -// src/plugins/data/server/index.ts:138:27 - (ae-forgotten-export) The symbol "isNestedField" needs to be exported by the entry point index.d.ts -// src/plugins/data/server/index.ts:254:20 - (ae-forgotten-export) The symbol "tabifyAggResponse" needs to be exported by the entry point index.d.ts -// src/plugins/data/server/index.ts:254:20 - (ae-forgotten-export) The symbol "tabifyGetColumns" needs to be exported by the entry point index.d.ts -// src/plugins/data/server/index.ts:256:1 - (ae-forgotten-export) The symbol "CidrMask" needs to be exported by the entry point index.d.ts -// src/plugins/data/server/index.ts:257:1 - (ae-forgotten-export) The symbol "dateHistogramInterval" needs to be exported by the entry point index.d.ts -// src/plugins/data/server/index.ts:266:1 - (ae-forgotten-export) The symbol "InvalidEsCalendarIntervalError" needs to be exported by the entry point index.d.ts -// src/plugins/data/server/index.ts:267:1 - (ae-forgotten-export) The symbol "InvalidEsIntervalFormatError" needs to be exported by the entry point index.d.ts -// src/plugins/data/server/index.ts:268:1 - (ae-forgotten-export) The symbol "IpAddress" needs to be exported by the entry point index.d.ts -// src/plugins/data/server/index.ts:272:1 - (ae-forgotten-export) The symbol "isValidEsInterval" needs to be exported by the entry point index.d.ts -// src/plugins/data/server/index.ts:273:1 - (ae-forgotten-export) The symbol "isValidInterval" needs to be exported by the entry point index.d.ts -// src/plugins/data/server/index.ts:277:1 - (ae-forgotten-export) The symbol "propFilter" needs to be exported by the entry point index.d.ts -// src/plugins/data/server/index.ts:280:1 - (ae-forgotten-export) The symbol "toAbsoluteDates" needs to be exported by the entry point index.d.ts -// src/plugins/data/server/index.ts:281:1 - (ae-forgotten-export) The symbol "calcAutoIntervalLessThan" needs to be exported by the entry point index.d.ts +// src/plugins/data/server/index.ts:21:23 - (ae-forgotten-export) The symbol "datatableToCSV" needs to be exported by the entry point index.d.ts +// src/plugins/data/server/index.ts:49:26 - (ae-forgotten-export) The symbol "FieldFormatsRegistry" needs to be exported by the entry point index.d.ts +// src/plugins/data/server/index.ts:49:26 - (ae-forgotten-export) The symbol "FieldFormat" needs to be exported by the entry point index.d.ts +// src/plugins/data/server/index.ts:49:26 - (ae-forgotten-export) The symbol "BoolFormat" needs to be exported by the entry point index.d.ts +// src/plugins/data/server/index.ts:49:26 - (ae-forgotten-export) The symbol "BytesFormat" needs to be exported by the entry point index.d.ts +// src/plugins/data/server/index.ts:49:26 - (ae-forgotten-export) The symbol "ColorFormat" needs to be exported by the entry point index.d.ts +// src/plugins/data/server/index.ts:49:26 - (ae-forgotten-export) The symbol "DurationFormat" needs to be exported by the entry point index.d.ts +// src/plugins/data/server/index.ts:49:26 - (ae-forgotten-export) The symbol "IpFormat" needs to be exported by the entry point index.d.ts +// src/plugins/data/server/index.ts:49:26 - (ae-forgotten-export) The symbol "NumberFormat" needs to be exported by the entry point index.d.ts +// src/plugins/data/server/index.ts:49:26 - (ae-forgotten-export) The symbol "PercentFormat" needs to be exported by the entry point index.d.ts +// src/plugins/data/server/index.ts:49:26 - (ae-forgotten-export) The symbol "RelativeDateFormat" needs to be exported by the entry point index.d.ts +// src/plugins/data/server/index.ts:49:26 - (ae-forgotten-export) The symbol "SourceFormat" needs to be exported by the entry point index.d.ts +// src/plugins/data/server/index.ts:49:26 - (ae-forgotten-export) The symbol "StaticLookupFormat" needs to be exported by the entry point index.d.ts +// src/plugins/data/server/index.ts:49:26 - (ae-forgotten-export) The symbol "UrlFormat" needs to be exported by the entry point index.d.ts +// src/plugins/data/server/index.ts:49:26 - (ae-forgotten-export) The symbol "StringFormat" needs to be exported by the entry point index.d.ts +// src/plugins/data/server/index.ts:49:26 - (ae-forgotten-export) The symbol "TruncateFormat" needs to be exported by the entry point index.d.ts +// src/plugins/data/server/index.ts:49:26 - (ae-forgotten-export) The symbol "HistogramFormat" needs to be exported by the entry point index.d.ts +// src/plugins/data/server/index.ts:81:27 - (ae-forgotten-export) The symbol "isFilterable" needs to be exported by the entry point index.d.ts +// src/plugins/data/server/index.ts:81:27 - (ae-forgotten-export) The symbol "isNestedField" needs to be exported by the entry point index.d.ts +// src/plugins/data/server/index.ts:197:20 - (ae-forgotten-export) The symbol "tabifyAggResponse" needs to be exported by the entry point index.d.ts +// src/plugins/data/server/index.ts:197:20 - (ae-forgotten-export) The symbol "tabifyGetColumns" needs to be exported by the entry point index.d.ts +// src/plugins/data/server/index.ts:199:1 - (ae-forgotten-export) The symbol "CidrMask" needs to be exported by the entry point index.d.ts +// src/plugins/data/server/index.ts:200:1 - (ae-forgotten-export) The symbol "dateHistogramInterval" needs to be exported by the entry point index.d.ts +// src/plugins/data/server/index.ts:209:1 - (ae-forgotten-export) The symbol "InvalidEsCalendarIntervalError" needs to be exported by the entry point index.d.ts +// src/plugins/data/server/index.ts:210:1 - (ae-forgotten-export) The symbol "InvalidEsIntervalFormatError" needs to be exported by the entry point index.d.ts +// src/plugins/data/server/index.ts:211:1 - (ae-forgotten-export) The symbol "IpAddress" needs to be exported by the entry point index.d.ts +// src/plugins/data/server/index.ts:215:1 - (ae-forgotten-export) The symbol "isValidEsInterval" needs to be exported by the entry point index.d.ts +// src/plugins/data/server/index.ts:216:1 - (ae-forgotten-export) The symbol "isValidInterval" needs to be exported by the entry point index.d.ts +// src/plugins/data/server/index.ts:220:1 - (ae-forgotten-export) The symbol "propFilter" needs to be exported by the entry point index.d.ts +// src/plugins/data/server/index.ts:223:1 - (ae-forgotten-export) The symbol "toAbsoluteDates" needs to be exported by the entry point index.d.ts +// src/plugins/data/server/index.ts:224:1 - (ae-forgotten-export) The symbol "calcAutoIntervalLessThan" needs to be exported by the entry point index.d.ts // src/plugins/data/server/plugin.ts:81:74 - (ae-forgotten-export) The symbol "DataEnhancements" needs to be exported by the entry point index.d.ts // src/plugins/data/server/search/types.ts:120:5 - (ae-forgotten-export) The symbol "ISearchStartSearchSource" needs to be exported by the entry point index.d.ts