From adc6234f3d8cac79b2d21f3fa8c436877fbd3ac1 Mon Sep 17 00:00:00 2001 From: Liza K Date: Wed, 23 Jun 2021 23:08:56 +0300 Subject: [PATCH 01/10] remove es query dependency on format.convert --- .../common/es_query/filters/meta_filter.ts | 4 +- .../common/es_query/filters/phrases_filter.ts | 7 +-- .../common/es_query/filters/range_filter.ts | 5 +-- .../data/common/es_query/filters/types.ts | 2 + .../lib/get_display_value.test.ts | 44 +++++++++++++++++++ .../filter_manager/lib/get_display_value.ts | 9 ++-- .../filter_manager/lib/mappers/map_phrases.ts | 21 +++++++-- 7 files changed, 74 insertions(+), 18 deletions(-) create mode 100644 src/plugins/data/public/query/filter_manager/lib/get_display_value.test.ts diff --git a/src/plugins/data/common/es_query/filters/meta_filter.ts b/src/plugins/data/common/es_query/filters/meta_filter.ts index 87455cf1cb763..b6714b5b8d02a 100644 --- a/src/plugins/data/common/es_query/filters/meta_filter.ts +++ b/src/plugins/data/common/es_query/filters/meta_filter.ts @@ -6,6 +6,8 @@ * Side Public License, v 1. */ +import { ConvertFn } from './types'; + export enum FilterStateStore { APP_STATE = 'appState', GLOBAL_STATE = 'globalState', @@ -35,7 +37,7 @@ export type FilterMeta = { type?: string; key?: string; params?: any; - value?: string; + value?: string | ConvertFn; }; // eslint-disable-next-line diff --git a/src/plugins/data/common/es_query/filters/phrases_filter.ts b/src/plugins/data/common/es_query/filters/phrases_filter.ts index 8a79472154493..2694461fc1930 100644 --- a/src/plugins/data/common/es_query/filters/phrases_filter.ts +++ b/src/plugins/data/common/es_query/filters/phrases_filter.ts @@ -41,11 +41,6 @@ export const buildPhrasesFilter = ( const type = FILTERS.PHRASES; const key = field.name; - const format = (f: IFieldType, value: any) => - f && f.format && f.format.convert ? f.format.convert(value) : value; - - const value = params.map((v: any) => format(field, v)).join(', '); - let should; if (field.scripted) { should = params.map((v: any) => ({ @@ -60,7 +55,7 @@ export const buildPhrasesFilter = ( } return { - meta: { index, type, key, value, params }, + meta: { index, type, key, params }, query: { bool: { should, diff --git a/src/plugins/data/common/es_query/filters/range_filter.ts b/src/plugins/data/common/es_query/filters/range_filter.ts index 7bc7a8cff7487..9f1d9a5d08926 100644 --- a/src/plugins/data/common/es_query/filters/range_filter.ts +++ b/src/plugins/data/common/es_query/filters/range_filter.ts @@ -84,10 +84,7 @@ export const getRangeFilterField = (filter: RangeFilter) => { }; const formatValue = (field: IFieldType, params: any[]) => - map(params, (val: any, key: string) => get(operators, key) + format(field, val)).join(' '); - -const format = (field: IFieldType, value: any) => - field && field.format && field.format.convert ? field.format.convert(value) : value; + map(params, (val: any, key: string) => get(operators, key) + val).join(' '); // Creates a filter where the value for the given field is in the given range // params should be an object containing `lt`, `lte`, `gt`, and/or `gte` diff --git a/src/plugins/data/common/es_query/filters/types.ts b/src/plugins/data/common/es_query/filters/types.ts index a007189d81a03..364400e6a2009 100644 --- a/src/plugins/data/common/es_query/filters/types.ts +++ b/src/plugins/data/common/es_query/filters/types.ts @@ -40,3 +40,5 @@ export enum FILTERS { GEO_POLYGON = 'geo_polygon', SPATIAL_FILTER = 'spatial_filter', } + +export type ConvertFn = (value: any) => string; diff --git a/src/plugins/data/public/query/filter_manager/lib/get_display_value.test.ts b/src/plugins/data/public/query/filter_manager/lib/get_display_value.test.ts new file mode 100644 index 0000000000000..d0211e1353257 --- /dev/null +++ b/src/plugins/data/public/query/filter_manager/lib/get_display_value.test.ts @@ -0,0 +1,44 @@ +/* + * 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 { stubIndexPattern, phraseFilter } from 'src/plugins/data/common/stubs'; +import { getDisplayValueFromFilter } from './get_display_value'; + +describe('getDisplayValueFromFilter', () => { + it('returns the value if string', () => { + phraseFilter.meta.value = 'abc'; + const displayValue = getDisplayValueFromFilter(phraseFilter, [stubIndexPattern]); + expect(displayValue).toBe('abc'); + }); + + it('returns the value if undefined', () => { + phraseFilter.meta.value = undefined; + const displayValue = getDisplayValueFromFilter(phraseFilter, [stubIndexPattern]); + expect(displayValue).toBe(''); + }); + + it('calls the value function if proivided', () => { + phraseFilter.meta.value = jest.fn((x) => { + return 'abc'; + }); + const displayValue = getDisplayValueFromFilter(phraseFilter, [stubIndexPattern]); + expect(displayValue).toBe('abc'); + expect(phraseFilter.meta.value).toHaveBeenCalledWith(undefined); + }); + + it('calls the value function if proivided, with formatter', () => { + stubIndexPattern.getFormatterForField = jest.fn().mockReturnValue('banana'); + phraseFilter.meta.value = jest.fn((x) => { + return x + 'abc'; + }); + const displayValue = getDisplayValueFromFilter(phraseFilter, [stubIndexPattern]); + expect(stubIndexPattern.getFormatterForField).toHaveBeenCalledTimes(1); + expect(phraseFilter.meta.value).toHaveBeenCalledWith('banana'); + expect(displayValue).toBe('bananaabc'); + }); +}); diff --git a/src/plugins/data/public/query/filter_manager/lib/get_display_value.ts b/src/plugins/data/public/query/filter_manager/lib/get_display_value.ts index 45c6167f600bc..17853d1e93cda 100644 --- a/src/plugins/data/public/query/filter_manager/lib/get_display_value.ts +++ b/src/plugins/data/public/query/filter_manager/lib/get_display_value.ts @@ -28,11 +28,12 @@ function getValueFormatter(indexPattern?: IIndexPattern, key?: string) { } export function getDisplayValueFromFilter(filter: Filter, indexPatterns: IIndexPattern[]): string { - if (typeof filter.meta.value === 'function') { + const { key, value } = filter.meta; + if (typeof value === 'function') { const indexPattern = getIndexPatternFromFilter(filter, indexPatterns); - const valueFormatter: any = getValueFormatter(indexPattern, filter.meta.key); - return (filter.meta.value as any)(valueFormatter); + const valueFormatter = getValueFormatter(indexPattern, key); + return value(valueFormatter); } else { - return filter.meta.value || ''; + return value || ''; } } diff --git a/src/plugins/data/public/query/filter_manager/lib/mappers/map_phrases.ts b/src/plugins/data/public/query/filter_manager/lib/mappers/map_phrases.ts index bfd528264b00f..5601dd66e5206 100644 --- a/src/plugins/data/public/query/filter_manager/lib/mappers/map_phrases.ts +++ b/src/plugins/data/public/query/filter_manager/lib/mappers/map_phrases.ts @@ -6,14 +6,29 @@ * Side Public License, v 1. */ -import { Filter, isPhrasesFilter } from '../../../../../common'; +import { Filter, FilterValueFormatter, isPhrasesFilter } from '../../../../../common'; + +const getFormattedValueFn = (params: any) => { + return (formatter?: FilterValueFormatter) => { + return params + .map((v: any) => { + return formatter ? formatter.convert(v) : v; + }) + .join(', '); + }; +}; export const mapPhrases = (filter: Filter) => { if (!isPhrasesFilter(filter)) { throw filter; } - const { type, key, value, params } = filter.meta; + const { type, key, params } = filter.meta; - return { type, key, value, params }; + return { + type, + key, + value: getFormattedValueFn(params), + params, + }; }; From f8e7e158be43c90d78ddc158236bc4ded7ad0bf5 Mon Sep 17 00:00:00 2001 From: Liza K Date: Wed, 23 Jun 2021 23:29:35 +0300 Subject: [PATCH 02/10] FieldBase --- .../es_query/es_query/filter_matches_index.ts | 5 ++-- .../es_query/handle_nested_filter.test.ts | 5 ++-- .../data/common/es_query/es_query/index.ts | 2 +- .../data/common/es_query/es_query/types.ts | 24 +++++++++++++++++-- .../common/es_query/filters/build_filters.ts | 7 +++--- .../common/es_query/filters/exists_filter.ts | 4 ++-- .../common/es_query/filters/phrase_filter.ts | 8 +++---- .../common/es_query/filters/phrases_filter.ts | 5 ++-- .../es_query/filters/range_filter.test.ts | 14 +++++------ .../common/es_query/filters/range_filter.ts | 9 ++++--- .../common/es_query/kuery/functions/exists.ts | 6 ++--- .../kuery/functions/geo_bounding_box.ts | 6 ++--- .../es_query/kuery/functions/geo_polygon.ts | 6 ++--- .../common/es_query/kuery/functions/is.ts | 4 ++-- .../common/es_query/kuery/functions/range.ts | 4 ++-- .../kuery/functions/utils/get_fields.test.ts | 14 +++++------ .../utils/get_full_field_name_node.ts | 4 ++-- .../common/index_patterns/fields/types.ts | 11 ++------- .../data/common/index_patterns/types.ts | 23 ++---------------- 19 files changed, 76 insertions(+), 85 deletions(-) diff --git a/src/plugins/data/common/es_query/es_query/filter_matches_index.ts b/src/plugins/data/common/es_query/es_query/filter_matches_index.ts index b376436756092..f77a029b6bdd5 100644 --- a/src/plugins/data/common/es_query/es_query/filter_matches_index.ts +++ b/src/plugins/data/common/es_query/es_query/filter_matches_index.ts @@ -6,9 +6,8 @@ * Side Public License, v 1. */ -import { IFieldType } from '../../index_patterns'; import { Filter } from '../filters'; -import { IndexPatternBase } from './types'; +import { FieldBase, IndexPatternBase } from './types'; /* * TODO: We should base this on something better than `filter.meta.key`. We should probably modify @@ -26,5 +25,5 @@ export function filterMatchesIndex(filter: Filter, indexPattern?: IndexPatternBa return filter.meta.index === indexPattern.id; } - return indexPattern.fields.some((field: IFieldType) => field.name === filter.meta.key); + return indexPattern.fields.some((field) => field.name === filter.meta.key); } diff --git a/src/plugins/data/common/es_query/es_query/handle_nested_filter.test.ts b/src/plugins/data/common/es_query/es_query/handle_nested_filter.test.ts index d312d034df564..bc0df315340fe 100644 --- a/src/plugins/data/common/es_query/es_query/handle_nested_filter.test.ts +++ b/src/plugins/data/common/es_query/es_query/handle_nested_filter.test.ts @@ -9,8 +9,7 @@ import { handleNestedFilter } from './handle_nested_filter'; import { fields } from '../../index_patterns/mocks'; import { buildPhraseFilter, buildQueryFilter } from '../filters'; -import { IndexPatternBase } from './types'; -import { IFieldType } from '../../index_patterns'; +import { IndexPatternBase, FieldBase } from './types'; describe('handleNestedFilter', function () { const indexPattern: IndexPatternBase = { @@ -46,7 +45,7 @@ describe('handleNestedFilter', function () { it('should return filter untouched if it does not target a field from the given index pattern', () => { const field = { ...getField('extension'), name: 'notarealfield' }; - const filter = buildPhraseFilter(field as IFieldType, 'jpg', indexPattern); + const filter = buildPhraseFilter(field, 'jpg', indexPattern); const result = handleNestedFilter(filter, indexPattern); expect(result).toBe(filter); }); diff --git a/src/plugins/data/common/es_query/es_query/index.ts b/src/plugins/data/common/es_query/es_query/index.ts index c10ea5846ae3f..efe645f111b6a 100644 --- a/src/plugins/data/common/es_query/es_query/index.ts +++ b/src/plugins/data/common/es_query/es_query/index.ts @@ -11,4 +11,4 @@ export { buildQueryFromFilters } from './from_filters'; export { luceneStringToDsl } from './lucene_string_to_dsl'; export { decorateQuery } from './decorate_query'; export { getEsQueryConfig } from './get_es_query_config'; -export { IndexPatternBase } from './types'; +export { IndexPatternBase, FieldBase, IFieldSubType } from './types'; diff --git a/src/plugins/data/common/es_query/es_query/types.ts b/src/plugins/data/common/es_query/es_query/types.ts index 2133736516049..29d5b4dad6a61 100644 --- a/src/plugins/data/common/es_query/es_query/types.ts +++ b/src/plugins/data/common/es_query/es_query/types.ts @@ -6,9 +6,29 @@ * Side Public License, v 1. */ -import { IFieldType } from '../../index_patterns'; +import type { estypes } from '@elastic/elasticsearch'; + +export interface IFieldSubType { + multi?: { parent: string }; + nested?: { path: string }; +} +export interface FieldBase { + name: string; + type: string; + subType?: IFieldSubType; + /** + * Scripted field painless script + */ + script?: string; + /** + * Scripted field langauge + * Painless is the only valid scripted field language + */ + lang?: estypes.ScriptLanguage; + scripted?: boolean; +} export interface IndexPatternBase { - fields: IFieldType[]; + fields: FieldBase[]; id?: string; } diff --git a/src/plugins/data/common/es_query/filters/build_filters.ts b/src/plugins/data/common/es_query/filters/build_filters.ts index 369f9530fb92b..333bca779af44 100644 --- a/src/plugins/data/common/es_query/filters/build_filters.ts +++ b/src/plugins/data/common/es_query/filters/build_filters.ts @@ -6,7 +6,8 @@ * Side Public License, v 1. */ -import { IFieldType, IndexPatternBase } from '../..'; +import { FieldBase, IndexPatternBase } from '../..'; + import { Filter, FILTERS, @@ -20,7 +21,7 @@ import { export function buildFilter( indexPattern: IndexPatternBase, - field: IFieldType, + field: FieldBase, type: FILTERS, negate: boolean, disabled: boolean, @@ -60,7 +61,7 @@ export function buildCustomFilter( function buildBaseFilter( indexPattern: IndexPatternBase, - field: IFieldType, + field: FieldBase, type: FILTERS, params: any ): Filter { diff --git a/src/plugins/data/common/es_query/filters/exists_filter.ts b/src/plugins/data/common/es_query/filters/exists_filter.ts index 4836950c3bb27..f5ffb85490bc2 100644 --- a/src/plugins/data/common/es_query/filters/exists_filter.ts +++ b/src/plugins/data/common/es_query/filters/exists_filter.ts @@ -7,7 +7,7 @@ */ import { Filter, FilterMeta } from './meta_filter'; -import { IFieldType } from '../../index_patterns'; +import { FieldBase } from '../../index_patterns'; import { IndexPatternBase } from '..'; export type ExistsFilterMeta = FilterMeta; @@ -27,7 +27,7 @@ export const getExistsFilterField = (filter: ExistsFilter) => { return filter.exists && filter.exists.field; }; -export const buildExistsFilter = (field: IFieldType, indexPattern: IndexPatternBase) => { +export const buildExistsFilter = (field: FieldBase, indexPattern: IndexPatternBase) => { return { meta: { index: indexPattern.id, diff --git a/src/plugins/data/common/es_query/filters/phrase_filter.ts b/src/plugins/data/common/es_query/filters/phrase_filter.ts index 27c1e85562097..7433d1eb7a2cf 100644 --- a/src/plugins/data/common/es_query/filters/phrase_filter.ts +++ b/src/plugins/data/common/es_query/filters/phrase_filter.ts @@ -8,7 +8,7 @@ import type { estypes } from '@elastic/elasticsearch'; import { get, isPlainObject } from 'lodash'; import { Filter, FilterMeta } from './meta_filter'; -import { IFieldType } from '../../index_patterns'; +import { FieldBase } from '../../index_patterns'; import { IndexPatternBase } from '..'; export type PhraseFilterMeta = FilterMeta & { @@ -59,7 +59,7 @@ export const getPhraseFilterValue = (filter: PhraseFilter): PhraseFilterValue => }; export const buildPhraseFilter = ( - field: IFieldType, + field: FieldBase, value: any, indexPattern: IndexPatternBase ): PhraseFilter => { @@ -82,7 +82,7 @@ export const buildPhraseFilter = ( } }; -export const getPhraseScript = (field: IFieldType, value: string) => { +export const getPhraseScript = (field: FieldBase, value: string) => { const convertedValue = getConvertedValueForField(field, value); const script = buildInlineScriptForPhraseFilter(field); @@ -106,7 +106,7 @@ export const getPhraseScript = (field: IFieldType, value: string) => { * https://github.com/elastic/elasticsearch/issues/20941 * https://github.com/elastic/elasticsearch/pull/22201 **/ -export const getConvertedValueForField = (field: IFieldType, value: any) => { +export const getConvertedValueForField = (field: FieldBase, value: any) => { if (typeof value !== 'boolean' && field.type === 'boolean') { if ([1, 'true'].includes(value)) { return true; diff --git a/src/plugins/data/common/es_query/filters/phrases_filter.ts b/src/plugins/data/common/es_query/filters/phrases_filter.ts index 2694461fc1930..e73f0f4e6a810 100644 --- a/src/plugins/data/common/es_query/filters/phrases_filter.ts +++ b/src/plugins/data/common/es_query/filters/phrases_filter.ts @@ -9,8 +9,7 @@ import { Filter, FilterMeta } from './meta_filter'; import { getPhraseScript } from './phrase_filter'; import { FILTERS } from './index'; -import { IFieldType } from '../../index_patterns'; -import { IndexPatternBase } from '../es_query'; +import { FieldBase, IndexPatternBase } from '../es_query'; export type PhrasesFilterMeta = FilterMeta & { params: string[]; // The unformatted values @@ -33,7 +32,7 @@ export const getPhrasesFilterField = (filter: PhrasesFilter) => { // Creates a filter where the given field matches one or more of the given values // params should be an array of values export const buildPhrasesFilter = ( - field: IFieldType, + field: FieldBase, params: any[], indexPattern: IndexPatternBase ) => { diff --git a/src/plugins/data/common/es_query/filters/range_filter.test.ts b/src/plugins/data/common/es_query/filters/range_filter.test.ts index bb7ecc09ebc34..613f987a76800 100644 --- a/src/plugins/data/common/es_query/filters/range_filter.test.ts +++ b/src/plugins/data/common/es_query/filters/range_filter.test.ts @@ -9,15 +9,15 @@ import { each } from 'lodash'; import { buildRangeFilter, getRangeFilterField, RangeFilter } from './range_filter'; import { fields, getField } from '../../index_patterns/mocks'; -import { IIndexPattern, IFieldType } from '../../index_patterns'; +import { IndexPatternBase, FieldBase } from '../es_query'; describe('Range filter builder', () => { - let indexPattern: IIndexPattern; + let indexPattern: IndexPatternBase; beforeEach(() => { indexPattern = { id: 'id', - } as IIndexPattern; + } as IndexPatternBase; }); it('should be a function', () => { @@ -130,7 +130,7 @@ describe('Range filter builder', () => { }); describe('when given params where one side is infinite', () => { - let field: IFieldType; + let field: FieldBase; let filter: RangeFilter; beforeEach(() => { @@ -160,7 +160,7 @@ describe('Range filter builder', () => { }); describe('when given params where both sides are infinite', () => { - let field: IFieldType; + let field: FieldBase; let filter: RangeFilter; beforeEach(() => { @@ -186,9 +186,9 @@ describe('Range filter builder', () => { }); describe('getRangeFilterField', function () { - const indexPattern: IIndexPattern = ({ + const indexPattern: IndexPatternBase = ({ fields, - } as unknown) as IIndexPattern; + } as unknown) as IndexPatternBase; test('should return the name of the field a range query is targeting', () => { const field = indexPattern.fields.find((patternField) => patternField.name === 'bytes'); diff --git a/src/plugins/data/common/es_query/filters/range_filter.ts b/src/plugins/data/common/es_query/filters/range_filter.ts index 9f1d9a5d08926..4b0fc10d90ff6 100644 --- a/src/plugins/data/common/es_query/filters/range_filter.ts +++ b/src/plugins/data/common/es_query/filters/range_filter.ts @@ -8,8 +8,7 @@ import type { estypes } from '@elastic/elasticsearch'; import { map, reduce, mapValues, get, keys, pickBy } from 'lodash'; import { Filter, FilterMeta } from './meta_filter'; -import { IFieldType } from '../../index_patterns'; -import { IndexPatternBase } from '..'; +import { IndexPatternBase, FieldBase } from '..'; const OPERANDS_IN_RANGE = 2; @@ -83,13 +82,13 @@ export const getRangeFilterField = (filter: RangeFilter) => { return filter.range && Object.keys(filter.range)[0]; }; -const formatValue = (field: IFieldType, params: any[]) => +const formatValue = (field: FieldBase, params: any[]) => map(params, (val: any, key: string) => get(operators, key) + val).join(' '); // Creates a filter where the value for the given field is in the given range // params should be an object containing `lt`, `lte`, `gt`, and/or `gte` export const buildRangeFilter = ( - field: IFieldType, + field: FieldBase, params: RangeFilterParams, indexPattern: IndexPatternBase, formattedValue?: string @@ -135,7 +134,7 @@ export const buildRangeFilter = ( return filter as RangeFilter; }; -export const getRangeScript = (field: IFieldType, params: RangeFilterParams) => { +export const getRangeScript = (field: FieldBase, params: RangeFilterParams) => { const knownParams = mapValues( pickBy(params, (val, key: any) => key in operators), (value) => (field.type === 'number' && typeof value === 'string' ? parseFloat(value) : value) diff --git a/src/plugins/data/common/es_query/kuery/functions/exists.ts b/src/plugins/data/common/es_query/kuery/functions/exists.ts index fa6c37e6ba18f..17db93ae68d26 100644 --- a/src/plugins/data/common/es_query/kuery/functions/exists.ts +++ b/src/plugins/data/common/es_query/kuery/functions/exists.ts @@ -8,7 +8,7 @@ import { get } from 'lodash'; import * as literal from '../node_types/literal'; -import { KueryNode, IFieldType, IndexPatternBase } from '../../..'; +import { KueryNode, FieldBase, IndexPatternBase } from '../../..'; export function buildNodeParams(fieldName: string) { return { @@ -30,9 +30,9 @@ export function toElasticsearchQuery( value: context?.nested ? `${context.nested.path}.${fieldNameArg.value}` : fieldNameArg.value, }; const fieldName = literal.toElasticsearchQuery(fullFieldNameArg); - const field = get(indexPattern, 'fields', []).find((fld: IFieldType) => fld.name === fieldName); + const field = indexPattern?.fields?.find((fld: FieldBase) => fld.name === fieldName); - if (field && (field as IFieldType).scripted) { + if (field?.scripted) { throw new Error(`Exists query does not support scripted fields`); } return { diff --git a/src/plugins/data/common/es_query/kuery/functions/geo_bounding_box.ts b/src/plugins/data/common/es_query/kuery/functions/geo_bounding_box.ts index 38a433b1b80ab..60211f3f67863 100644 --- a/src/plugins/data/common/es_query/kuery/functions/geo_bounding_box.ts +++ b/src/plugins/data/common/es_query/kuery/functions/geo_bounding_box.ts @@ -9,7 +9,7 @@ import _ from 'lodash'; import { nodeTypes } from '../node_types'; import * as ast from '../ast'; -import { IndexPatternBase, KueryNode, IFieldType, LatLon } from '../../..'; +import { IndexPatternBase, KueryNode, FieldBase, LatLon } from '../../..'; export function buildNodeParams(fieldName: string, params: any) { params = _.pick(params, 'topLeft', 'bottomRight'); @@ -36,8 +36,8 @@ export function toElasticsearchQuery( value: context?.nested ? `${context.nested.path}.${fieldNameArg.value}` : fieldNameArg.value, }; const fieldName = nodeTypes.literal.toElasticsearchQuery(fullFieldNameArg) as string; - const fieldList: IFieldType[] = indexPattern?.fields ?? []; - const field = fieldList.find((fld: IFieldType) => fld.name === fieldName); + const fieldList = indexPattern?.fields ?? []; + const field = fieldList.find((fld) => fld.name === fieldName); const queryParams = args.reduce((acc: any, arg: any) => { const snakeArgName = _.snakeCase(arg.name); diff --git a/src/plugins/data/common/es_query/kuery/functions/geo_polygon.ts b/src/plugins/data/common/es_query/kuery/functions/geo_polygon.ts index 69de7248a7b38..b437baf37988e 100644 --- a/src/plugins/data/common/es_query/kuery/functions/geo_polygon.ts +++ b/src/plugins/data/common/es_query/kuery/functions/geo_polygon.ts @@ -8,7 +8,7 @@ import { nodeTypes } from '../node_types'; import * as ast from '../ast'; -import { IndexPatternBase, KueryNode, IFieldType, LatLon } from '../../..'; +import { IndexPatternBase, KueryNode, FieldBase, LatLon } from '../../..'; import { LiteralTypeBuildNode } from '../node_types/types'; export function buildNodeParams(fieldName: string, points: LatLon[]) { @@ -35,8 +35,8 @@ export function toElasticsearchQuery( value: context?.nested ? `${context.nested.path}.${fieldNameArg.value}` : fieldNameArg.value, }; const fieldName = nodeTypes.literal.toElasticsearchQuery(fullFieldNameArg) as string; - const fieldList: IFieldType[] = indexPattern?.fields ?? []; - const field = fieldList.find((fld: IFieldType) => fld.name === fieldName); + const fieldList = indexPattern?.fields ?? []; + const field = fieldList.find((fld) => fld.name === fieldName); const queryParams = { points: points.map((point: LiteralTypeBuildNode) => { return ast.toElasticsearchQuery(point, indexPattern, config, context); diff --git a/src/plugins/data/common/es_query/kuery/functions/is.ts b/src/plugins/data/common/es_query/kuery/functions/is.ts index 55d036c2156f9..47ae5bb4af0d9 100644 --- a/src/plugins/data/common/es_query/kuery/functions/is.ts +++ b/src/plugins/data/common/es_query/kuery/functions/is.ts @@ -11,7 +11,7 @@ import { getPhraseScript } from '../../filters'; import { getFields } from './utils/get_fields'; import { getTimeZoneFromSettings } from '../../utils'; import { getFullFieldNameNode } from './utils/get_full_field_name_node'; -import { IndexPatternBase, KueryNode, IFieldType } from '../../..'; +import { IndexPatternBase, KueryNode, FieldBase } from '../../..'; import * as ast from '../ast'; @@ -100,7 +100,7 @@ export function toElasticsearchQuery( return { match_all: {} }; } - const queries = fields!.reduce((accumulator: any, field: IFieldType) => { + const queries = fields!.reduce((accumulator: any, field: FieldBase) => { const wrapWithNestedQuery = (query: any) => { // Wildcards can easily include nested and non-nested fields. There isn't a good way to let // users handle this themselves so we automatically add nested queries in this scenario. diff --git a/src/plugins/data/common/es_query/kuery/functions/range.ts b/src/plugins/data/common/es_query/kuery/functions/range.ts index caefa7e5373ca..13919759f4dbb 100644 --- a/src/plugins/data/common/es_query/kuery/functions/range.ts +++ b/src/plugins/data/common/es_query/kuery/functions/range.ts @@ -13,7 +13,7 @@ import { getRangeScript, RangeFilterParams } from '../../filters'; import { getFields } from './utils/get_fields'; import { getTimeZoneFromSettings } from '../../utils'; import { getFullFieldNameNode } from './utils/get_full_field_name_node'; -import { IndexPatternBase, KueryNode, IFieldType } from '../../..'; +import { IndexPatternBase, KueryNode, FieldBase } from '../../..'; export function buildNodeParams(fieldName: string, params: RangeFilterParams) { const paramsToMap = _.pick(params, 'gt', 'lt', 'gte', 'lte', 'format'); @@ -62,7 +62,7 @@ export function toElasticsearchQuery( }); } - const queries = fields!.map((field: IFieldType) => { + const queries = fields!.map((field) => { const wrapWithNestedQuery = (query: any) => { // Wildcards can easily include nested and non-nested fields. There isn't a good way to let // users handle this themselves so we automatically add nested queries in this scenario. diff --git a/src/plugins/data/common/es_query/kuery/functions/utils/get_fields.test.ts b/src/plugins/data/common/es_query/kuery/functions/utils/get_fields.test.ts index 47fe677454cbf..949f94d043553 100644 --- a/src/plugins/data/common/es_query/kuery/functions/utils/get_fields.test.ts +++ b/src/plugins/data/common/es_query/kuery/functions/utils/get_fields.test.ts @@ -6,21 +6,21 @@ * Side Public License, v 1. */ +import { IndexPatternBase } from '../../..'; import { fields } from '../../../../index_patterns/mocks'; import { nodeTypes } from '../../index'; -import { IIndexPattern, IFieldType } from '../../../../index_patterns'; // @ts-ignore import { getFields } from './get_fields'; describe('getFields', () => { - let indexPattern: IIndexPattern; + let indexPattern: IndexPatternBase; beforeEach(() => { indexPattern = ({ fields, - } as unknown) as IIndexPattern; + } as unknown) as IndexPatternBase; }); describe('field names without a wildcard', () => { @@ -41,14 +41,14 @@ describe('getFields', () => { }); test('should not match a wildcard in a literal node', () => { - const indexPatternWithWildField = { + const indexPatternWithWildField: IndexPatternBase = ({ title: 'wildIndex', fields: [ { name: 'foo*', }, ], - } as IIndexPattern; + } as unknown) as IndexPatternBase; const fieldNameNode = nodeTypes.literal.buildNode('foo*'); const results = getFields(fieldNameNode, indexPatternWithWildField); @@ -76,8 +76,8 @@ describe('getFields', () => { expect(Array.isArray(results)).toBeTruthy(); expect(results).toHaveLength(2); - expect(results!.find((field: IFieldType) => field.name === 'machine.os')).toBeDefined(); - expect(results!.find((field: IFieldType) => field.name === 'machine.os.raw')).toBeDefined(); + expect(results!.find((field) => field.name === 'machine.os')).toBeDefined(); + expect(results!.find((field) => field.name === 'machine.os.raw')).toBeDefined(); }); }); }); diff --git a/src/plugins/data/common/es_query/kuery/functions/utils/get_full_field_name_node.ts b/src/plugins/data/common/es_query/kuery/functions/utils/get_full_field_name_node.ts index 644791637aa70..cfea79696122c 100644 --- a/src/plugins/data/common/es_query/kuery/functions/utils/get_full_field_name_node.ts +++ b/src/plugins/data/common/es_query/kuery/functions/utils/get_full_field_name_node.ts @@ -7,7 +7,7 @@ */ import { getFields } from './get_fields'; -import { IndexPatternBase, IFieldType, KueryNode } from '../../../..'; +import { IndexPatternBase, FieldBase, KueryNode } from '../../../..'; export function getFullFieldNameNode( rootNameNode: any, @@ -27,7 +27,7 @@ export function getFullFieldNameNode( } const fields = getFields(fullFieldNameNode, indexPattern); - const errors = fields!.reduce((acc: any, field: IFieldType) => { + const errors = fields!.reduce((acc: any, field: FieldBase) => { const nestedPathFromField = field.subType && field.subType.nested ? field.subType.nested.path : undefined; diff --git a/src/plugins/data/common/index_patterns/fields/types.ts b/src/plugins/data/common/index_patterns/fields/types.ts index 0fb7a46c2cf73..608294b04dc91 100644 --- a/src/plugins/data/common/index_patterns/fields/types.ts +++ b/src/plugins/data/common/index_patterns/fields/types.ts @@ -5,18 +5,13 @@ * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ -import type { estypes } from '@elastic/elasticsearch'; -import { FieldSpec, IFieldSubType, IndexPattern } from '../..'; +import { FieldBase, FieldSpec, IndexPattern } from '../..'; /** * @deprecated * Use IndexPatternField or FieldSpec instead */ -export interface IFieldType { - name: string; - type: string; - script?: string; - lang?: estypes.ScriptLanguage; +export interface IFieldType extends FieldBase { count?: number; // esTypes might be undefined on old index patterns that have not been refreshed since we added // this prop. It is also undefined on scripted fields. @@ -27,8 +22,6 @@ export interface IFieldType { sortable?: boolean; visualizable?: boolean; readFromDocValues?: boolean; - scripted?: boolean; - subType?: IFieldSubType; displayName?: string; customLabel?: string; format?: any; diff --git a/src/plugins/data/common/index_patterns/types.ts b/src/plugins/data/common/index_patterns/types.ts index a88f029c0c7cd..4fa7531efcb74 100644 --- a/src/plugins/data/common/index_patterns/types.ts +++ b/src/plugins/data/common/index_patterns/types.ts @@ -9,7 +9,7 @@ import type { estypes } from '@elastic/elasticsearch'; import { ToastInputFields, ErrorToastOptions } from 'src/core/public/notifications'; // eslint-disable-next-line import type { SavedObject } from 'src/core/server'; -import type { IndexPatternBase } from '../es_query'; +import type { FieldBase, IFieldSubType, IndexPatternBase } from '../es_query'; import { IFieldType } from './fields'; import { RUNTIME_FIELD_TYPES } from './constants'; import { SerializedFieldFormat } from '../../../expressions/common'; @@ -149,12 +149,6 @@ export type AggregationRestrictions = Record< time_zone?: string; } >; - -export interface IFieldSubType { - multi?: { parent: string }; - nested?: { path: string }; -} - export interface TypeMeta { aggs?: Record; [key: string]: any; @@ -183,30 +177,17 @@ export interface FieldSpecExportFmt { /** * Serialized version of IndexPatternField */ -export interface FieldSpec { +export interface FieldSpec extends FieldBase { /** * Popularity count is used by discover */ count?: number; - /** - * Scripted field painless script - */ - script?: string; - /** - * Scripted field langauge - * Painless is the only valid scripted field language - */ - lang?: estypes.ScriptLanguage; conflictDescriptions?: Record; format?: SerializedFieldFormat; - name: string; - type: string; esTypes?: string[]; - scripted?: boolean; searchable: boolean; aggregatable: boolean; readFromDocValues?: boolean; - subType?: IFieldSubType; indexed?: boolean; customLabel?: string; runtimeField?: RuntimeField; From 1a2284fad68b69c8d9e703326e5e9ac9d454959b Mon Sep 17 00:00:00 2001 From: Liza K Date: Wed, 23 Jun 2021 23:47:39 +0300 Subject: [PATCH 03/10] fix types --- src/plugins/data/common/es_query/filters/meta_filter.ts | 4 +--- src/plugins/data/common/es_query/filters/types.ts | 2 -- .../data/public/query/filter_manager/lib/get_display_value.ts | 4 +++- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/plugins/data/common/es_query/filters/meta_filter.ts b/src/plugins/data/common/es_query/filters/meta_filter.ts index b6714b5b8d02a..87455cf1cb763 100644 --- a/src/plugins/data/common/es_query/filters/meta_filter.ts +++ b/src/plugins/data/common/es_query/filters/meta_filter.ts @@ -6,8 +6,6 @@ * Side Public License, v 1. */ -import { ConvertFn } from './types'; - export enum FilterStateStore { APP_STATE = 'appState', GLOBAL_STATE = 'globalState', @@ -37,7 +35,7 @@ export type FilterMeta = { type?: string; key?: string; params?: any; - value?: string | ConvertFn; + value?: string; }; // eslint-disable-next-line diff --git a/src/plugins/data/common/es_query/filters/types.ts b/src/plugins/data/common/es_query/filters/types.ts index 364400e6a2009..a007189d81a03 100644 --- a/src/plugins/data/common/es_query/filters/types.ts +++ b/src/plugins/data/common/es_query/filters/types.ts @@ -40,5 +40,3 @@ export enum FILTERS { GEO_POLYGON = 'geo_polygon', SPATIAL_FILTER = 'spatial_filter', } - -export type ConvertFn = (value: any) => string; diff --git a/src/plugins/data/public/query/filter_manager/lib/get_display_value.ts b/src/plugins/data/public/query/filter_manager/lib/get_display_value.ts index 17853d1e93cda..1ccfaacb24e4b 100644 --- a/src/plugins/data/public/query/filter_manager/lib/get_display_value.ts +++ b/src/plugins/data/public/query/filter_manager/lib/get_display_value.ts @@ -32,7 +32,9 @@ export function getDisplayValueFromFilter(filter: Filter, indexPatterns: IIndexP if (typeof value === 'function') { const indexPattern = getIndexPatternFromFilter(filter, indexPatterns); const valueFormatter = getValueFormatter(indexPattern, key); - return value(valueFormatter); + // TODO: distinguish between FilterMeta which is serializable to mapped FilterMeta + // Where value can be a function. + return (value as any)(valueFormatter); } else { return value || ''; } From 5b40ebced194077d3042dfa96f810e9cd50bd8c0 Mon Sep 17 00:00:00 2001 From: Liza K Date: Sun, 27 Jun 2021 15:00:11 +0300 Subject: [PATCH 04/10] types --- .../data/common/search/expressions/phrase_filter.test.ts | 1 - .../query/filter_manager/lib/get_display_value.test.ts | 5 +++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/plugins/data/common/search/expressions/phrase_filter.test.ts b/src/plugins/data/common/search/expressions/phrase_filter.test.ts index 39bd907513a0d..a61cc0bfd68ab 100644 --- a/src/plugins/data/common/search/expressions/phrase_filter.test.ts +++ b/src/plugins/data/common/search/expressions/phrase_filter.test.ts @@ -32,7 +32,6 @@ describe('interpreter/functions#phraseFilter', () => { "something", ], "type": "phrases", - "value": "test, something", }, "query": Object { "bool": Object { diff --git a/src/plugins/data/public/query/filter_manager/lib/get_display_value.test.ts b/src/plugins/data/public/query/filter_manager/lib/get_display_value.test.ts index d0211e1353257..48e1007534769 100644 --- a/src/plugins/data/public/query/filter_manager/lib/get_display_value.test.ts +++ b/src/plugins/data/public/query/filter_manager/lib/get_display_value.test.ts @@ -23,9 +23,10 @@ describe('getDisplayValueFromFilter', () => { }); it('calls the value function if proivided', () => { + // The type of value currently doesn't match how it's used. Refactor needed. phraseFilter.meta.value = jest.fn((x) => { return 'abc'; - }); + }) as any; const displayValue = getDisplayValueFromFilter(phraseFilter, [stubIndexPattern]); expect(displayValue).toBe('abc'); expect(phraseFilter.meta.value).toHaveBeenCalledWith(undefined); @@ -35,7 +36,7 @@ describe('getDisplayValueFromFilter', () => { stubIndexPattern.getFormatterForField = jest.fn().mockReturnValue('banana'); phraseFilter.meta.value = jest.fn((x) => { return x + 'abc'; - }); + }) as any; const displayValue = getDisplayValueFromFilter(phraseFilter, [stubIndexPattern]); expect(stubIndexPattern.getFormatterForField).toHaveBeenCalledTimes(1); expect(phraseFilter.meta.value).toHaveBeenCalledWith('banana'); From 08a5c854a43ed3187f4c34655b984931582c185b Mon Sep 17 00:00:00 2001 From: Liza K Date: Sun, 27 Jun 2021 16:25:39 +0300 Subject: [PATCH 05/10] Fix type imports --- ...na-plugin-plugins-data-public.esfilters.md | 8 ++-- ...bana-plugin-plugins-data-public.eskuery.md | 2 +- ...bana-plugin-plugins-data-public.esquery.md | 2 +- ...gin-plugins-data-public.ifieldtype.lang.md | 11 ------ ...a-plugin-plugins-data-public.ifieldtype.md | 8 +--- ...gin-plugins-data-public.ifieldtype.name.md | 11 ------ ...n-plugins-data-public.ifieldtype.script.md | 11 ------ ...plugins-data-public.ifieldtype.scripted.md | 11 ------ ...-plugins-data-public.ifieldtype.subtype.md | 11 ------ ...gin-plugins-data-public.ifieldtype.type.md | 11 ------ ...lugins-data-public.iindexpattern.fields.md | 11 ++++++ ...lugin-plugins-data-public.iindexpattern.md | 3 +- ...n-plugins-data-public.indexpatternfield.md | 2 +- ...s-data-public.indexpatternfield.subtype.md | 2 +- ...ns-data-public.indexpatternfield.tojson.md | 4 +- ...na-plugin-plugins-data-server.esfilters.md | 8 ++-- ...bana-plugin-plugins-data-server.eskuery.md | 2 +- ...bana-plugin-plugins-data-server.esquery.md | 2 +- ...gin-plugins-data-server.ifieldtype.lang.md | 11 ------ ...a-plugin-plugins-data-server.ifieldtype.md | 8 +--- ...gin-plugins-data-server.ifieldtype.name.md | 11 ------ ...n-plugins-data-server.ifieldtype.script.md | 11 ------ ...plugins-data-server.ifieldtype.scripted.md | 11 ------ ...-plugins-data-server.ifieldtype.subtype.md | 11 ------ ...gin-plugins-data-server.ifieldtype.type.md | 11 ------ .../es_query/es_query/filter_matches_index.ts | 2 +- .../es_query/handle_nested_filter.test.ts | 2 +- .../common/es_query/filters/exists_filter.ts | 3 +- .../common/es_query/filters/phrase_filter.ts | 3 +- .../common/es_query/kuery/functions/exists.ts | 1 - .../kuery/functions/geo_bounding_box.ts | 2 +- .../es_query/kuery/functions/geo_polygon.ts | 2 +- .../common/es_query/kuery/functions/range.ts | 2 +- .../data/common/index_patterns/types.ts | 1 + src/plugins/data/public/public.api.md | 37 +++++++------------ src/plugins/data/server/server.api.md | 23 +++--------- 36 files changed, 59 insertions(+), 213 deletions(-) delete mode 100644 docs/development/plugins/data/public/kibana-plugin-plugins-data-public.ifieldtype.lang.md delete mode 100644 docs/development/plugins/data/public/kibana-plugin-plugins-data-public.ifieldtype.name.md delete mode 100644 docs/development/plugins/data/public/kibana-plugin-plugins-data-public.ifieldtype.script.md delete mode 100644 docs/development/plugins/data/public/kibana-plugin-plugins-data-public.ifieldtype.scripted.md delete mode 100644 docs/development/plugins/data/public/kibana-plugin-plugins-data-public.ifieldtype.subtype.md delete mode 100644 docs/development/plugins/data/public/kibana-plugin-plugins-data-public.ifieldtype.type.md create mode 100644 docs/development/plugins/data/public/kibana-plugin-plugins-data-public.iindexpattern.fields.md delete mode 100644 docs/development/plugins/data/server/kibana-plugin-plugins-data-server.ifieldtype.lang.md delete mode 100644 docs/development/plugins/data/server/kibana-plugin-plugins-data-server.ifieldtype.name.md delete mode 100644 docs/development/plugins/data/server/kibana-plugin-plugins-data-server.ifieldtype.script.md delete mode 100644 docs/development/plugins/data/server/kibana-plugin-plugins-data-server.ifieldtype.scripted.md delete mode 100644 docs/development/plugins/data/server/kibana-plugin-plugins-data-server.ifieldtype.subtype.md delete mode 100644 docs/development/plugins/data/server/kibana-plugin-plugins-data-server.ifieldtype.type.md 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 2ca4847d6dc39..0cdc1e5c8bcbf 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 @@ -13,11 +13,11 @@ esFilters: { FILTERS: typeof FILTERS; FilterStateStore: typeof FilterStateStore; buildEmptyFilter: (isPinned: boolean, index?: string | undefined) => import("../common").Filter; - buildPhrasesFilter: (field: import("../common").IFieldType, params: any[], indexPattern: import("../common").MinimalIndexPattern) => import("../common").PhrasesFilter; - buildExistsFilter: (field: import("../common").IFieldType, indexPattern: import("../common").MinimalIndexPattern) => import("../common").ExistsFilter; - buildPhraseFilter: (field: import("../common").IFieldType, value: any, indexPattern: import("../common").MinimalIndexPattern) => import("../common").PhraseFilter; + buildPhrasesFilter: (field: import("../common").FieldBase, params: any[], indexPattern: import("../common").IndexPatternBase) => import("../common").PhrasesFilter; + buildExistsFilter: (field: import("../common").FieldBase, indexPattern: import("../common").IndexPatternBase) => import("../common").ExistsFilter; + buildPhraseFilter: (field: import("../common").FieldBase, value: any, indexPattern: import("../common").IndexPatternBase) => import("../common").PhraseFilter; buildQueryFilter: (query: any, index: string, alias: string) => import("../common").QueryStringFilter; - buildRangeFilter: (field: import("../common").IFieldType, params: import("../common").RangeFilterParams, indexPattern: import("../common").MinimalIndexPattern, formattedValue?: string | undefined) => import("../common").RangeFilter; + buildRangeFilter: (field: import("../common").FieldBase, params: import("../common").RangeFilterParams, indexPattern: import("../common").IndexPatternBase, formattedValue?: string | undefined) => import("../common").RangeFilter; isPhraseFilter: (filter: any) => filter is import("../common").PhraseFilter; isExistsFilter: (filter: any) => filter is import("../common").ExistsFilter; isPhrasesFilter: (filter: any) => filter is import("../common").PhrasesFilter; diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.eskuery.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.eskuery.md index 881a1fa803ca6..332114e637586 100644 --- a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.eskuery.md +++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.eskuery.md @@ -10,6 +10,6 @@ esKuery: { nodeTypes: import("../common/es_query/kuery/node_types").NodeTypes; fromKueryExpression: (expression: any, parseOptions?: Partial) => import("../common").KueryNode; - toElasticsearchQuery: (node: import("../common").KueryNode, indexPattern?: import("../common").MinimalIndexPattern | undefined, config?: Record | undefined, context?: Record | undefined) => import("@kbn/common-utils").JsonObject; + toElasticsearchQuery: (node: import("../common").KueryNode, indexPattern?: import("../common").IndexPatternBase | undefined, config?: Record | undefined, context?: Record | undefined) => import("@kbn/common-utils").JsonObject; } ``` diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.esquery.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.esquery.md index 70805aaaaee8c..0bc9c0c12fc3a 100644 --- a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.esquery.md +++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.esquery.md @@ -10,7 +10,7 @@ esQuery: { buildEsQuery: typeof buildEsQuery; getEsQueryConfig: typeof getEsQueryConfig; - buildQueryFromFilters: (filters: import("../common").Filter[] | undefined, indexPattern: import("../common").MinimalIndexPattern | undefined, ignoreFilterIfFieldNotInIndex?: boolean) => { + buildQueryFromFilters: (filters: import("../common").Filter[] | undefined, indexPattern: import("../common").IndexPatternBase | undefined, ignoreFilterIfFieldNotInIndex?: boolean) => { must: never[]; filter: import("../common").Filter[]; should: never[]; diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.ifieldtype.lang.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.ifieldtype.lang.md deleted file mode 100644 index f99e7ba8b967e..0000000000000 --- a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.ifieldtype.lang.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [IFieldType](./kibana-plugin-plugins-data-public.ifieldtype.md) > [lang](./kibana-plugin-plugins-data-public.ifieldtype.lang.md) - -## IFieldType.lang property - -Signature: - -```typescript -lang?: estypes.ScriptLanguage; -``` diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.ifieldtype.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.ifieldtype.md index 29377ff8fd392..55df5c3367748 100644 --- a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.ifieldtype.md +++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.ifieldtype.md @@ -12,7 +12,7 @@ Signature: ```typescript -export interface IFieldType +export interface IFieldType extends FieldBase ``` ## Properties @@ -26,15 +26,9 @@ export interface IFieldType | [esTypes](./kibana-plugin-plugins-data-public.ifieldtype.estypes.md) | string[] | | | [filterable](./kibana-plugin-plugins-data-public.ifieldtype.filterable.md) | boolean | | | [format](./kibana-plugin-plugins-data-public.ifieldtype.format.md) | any | | -| [lang](./kibana-plugin-plugins-data-public.ifieldtype.lang.md) | estypes.ScriptLanguage | | -| [name](./kibana-plugin-plugins-data-public.ifieldtype.name.md) | string | | | [readFromDocValues](./kibana-plugin-plugins-data-public.ifieldtype.readfromdocvalues.md) | boolean | | -| [script](./kibana-plugin-plugins-data-public.ifieldtype.script.md) | string | | -| [scripted](./kibana-plugin-plugins-data-public.ifieldtype.scripted.md) | boolean | | | [searchable](./kibana-plugin-plugins-data-public.ifieldtype.searchable.md) | boolean | | | [sortable](./kibana-plugin-plugins-data-public.ifieldtype.sortable.md) | boolean | | -| [subType](./kibana-plugin-plugins-data-public.ifieldtype.subtype.md) | IFieldSubType | | | [toSpec](./kibana-plugin-plugins-data-public.ifieldtype.tospec.md) | (options?: {
getFormatterForField?: IndexPattern['getFormatterForField'];
}) => FieldSpec | | -| [type](./kibana-plugin-plugins-data-public.ifieldtype.type.md) | string | | | [visualizable](./kibana-plugin-plugins-data-public.ifieldtype.visualizable.md) | boolean | | diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.ifieldtype.name.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.ifieldtype.name.md deleted file mode 100644 index 1c01484372fd3..0000000000000 --- a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.ifieldtype.name.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [IFieldType](./kibana-plugin-plugins-data-public.ifieldtype.md) > [name](./kibana-plugin-plugins-data-public.ifieldtype.name.md) - -## IFieldType.name property - -Signature: - -```typescript -name: string; -``` diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.ifieldtype.script.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.ifieldtype.script.md deleted file mode 100644 index 252c2c3822046..0000000000000 --- a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.ifieldtype.script.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [IFieldType](./kibana-plugin-plugins-data-public.ifieldtype.md) > [script](./kibana-plugin-plugins-data-public.ifieldtype.script.md) - -## IFieldType.script property - -Signature: - -```typescript -script?: string; -``` diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.ifieldtype.scripted.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.ifieldtype.scripted.md deleted file mode 100644 index 33bbd0c2c20cb..0000000000000 --- a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.ifieldtype.scripted.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [IFieldType](./kibana-plugin-plugins-data-public.ifieldtype.md) > [scripted](./kibana-plugin-plugins-data-public.ifieldtype.scripted.md) - -## IFieldType.scripted property - -Signature: - -```typescript -scripted?: boolean; -``` diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.ifieldtype.subtype.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.ifieldtype.subtype.md deleted file mode 100644 index d0c26186da085..0000000000000 --- a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.ifieldtype.subtype.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [IFieldType](./kibana-plugin-plugins-data-public.ifieldtype.md) > [subType](./kibana-plugin-plugins-data-public.ifieldtype.subtype.md) - -## IFieldType.subType property - -Signature: - -```typescript -subType?: IFieldSubType; -``` diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.ifieldtype.type.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.ifieldtype.type.md deleted file mode 100644 index 26228cbe4bfdb..0000000000000 --- a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.ifieldtype.type.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [IFieldType](./kibana-plugin-plugins-data-public.ifieldtype.md) > [type](./kibana-plugin-plugins-data-public.ifieldtype.type.md) - -## IFieldType.type property - -Signature: - -```typescript -type: string; -``` diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.iindexpattern.fields.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.iindexpattern.fields.md new file mode 100644 index 0000000000000..792bee44f96a8 --- /dev/null +++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.iindexpattern.fields.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [IIndexPattern](./kibana-plugin-plugins-data-public.iindexpattern.md) > [fields](./kibana-plugin-plugins-data-public.iindexpattern.fields.md) + +## IIndexPattern.fields property + +Signature: + +```typescript +fields: IFieldType[]; +``` diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.iindexpattern.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.iindexpattern.md index 88d8520a373c6..c441073781169 100644 --- a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.iindexpattern.md +++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.iindexpattern.md @@ -12,7 +12,7 @@ Signature: ```typescript -export interface IIndexPattern extends MinimalIndexPattern +export interface IIndexPattern extends IndexPatternBase ``` ## Properties @@ -20,6 +20,7 @@ export interface IIndexPattern extends MinimalIndexPattern | Property | Type | Description | | --- | --- | --- | | [fieldFormatMap](./kibana-plugin-plugins-data-public.iindexpattern.fieldformatmap.md) | Record<string, SerializedFieldFormat<unknown> | undefined> | | +| [fields](./kibana-plugin-plugins-data-public.iindexpattern.fields.md) | IFieldType[] | | | [getFormatterForField](./kibana-plugin-plugins-data-public.iindexpattern.getformatterforfield.md) | (field: IndexPatternField | IndexPatternField['spec'] | IFieldType) => FieldFormat | Look up a formatter for a given field | | [timeFieldName](./kibana-plugin-plugins-data-public.iindexpattern.timefieldname.md) | string | | | [title](./kibana-plugin-plugins-data-public.iindexpattern.title.md) | string | | diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternfield.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternfield.md index 8cd1a476cf32f..16546ceca958d 100644 --- a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternfield.md +++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternfield.md @@ -37,7 +37,7 @@ export declare class IndexPatternField implements IFieldType | [searchable](./kibana-plugin-plugins-data-public.indexpatternfield.searchable.md) | | boolean | | | [sortable](./kibana-plugin-plugins-data-public.indexpatternfield.sortable.md) | | boolean | | | [spec](./kibana-plugin-plugins-data-public.indexpatternfield.spec.md) | | FieldSpec | | -| [subType](./kibana-plugin-plugins-data-public.indexpatternfield.subtype.md) | | import("../types").IFieldSubType | undefined | | +| [subType](./kibana-plugin-plugins-data-public.indexpatternfield.subtype.md) | | import("../..").IFieldSubType | undefined | | | [type](./kibana-plugin-plugins-data-public.indexpatternfield.type.md) | | string | | | [visualizable](./kibana-plugin-plugins-data-public.indexpatternfield.visualizable.md) | | boolean | | diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternfield.subtype.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternfield.subtype.md index 5c3c4d54ad099..6cd5247291602 100644 --- a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternfield.subtype.md +++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternfield.subtype.md @@ -7,5 +7,5 @@ Signature: ```typescript -get subType(): import("../types").IFieldSubType | undefined; +get subType(): import("../..").IFieldSubType | undefined; ``` diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternfield.tojson.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternfield.tojson.md index 8882fa05ce0c2..b77f3d1f374fb 100644 --- a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternfield.tojson.md +++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternfield.tojson.md @@ -19,7 +19,7 @@ toJSON(): { searchable: boolean; aggregatable: boolean; readFromDocValues: boolean; - subType: import("../types").IFieldSubType | undefined; + subType: import("../..").IFieldSubType | undefined; customLabel: string | undefined; }; ``` @@ -37,7 +37,7 @@ toJSON(): { searchable: boolean; aggregatable: boolean; readFromDocValues: boolean; - subType: import("../types").IFieldSubType | undefined; + subType: import("../..").IFieldSubType | undefined; customLabel: string | undefined; }` 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 d951cb2426943..202c9e4588f8a 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 @@ -11,11 +11,11 @@ esFilters: { buildQueryFilter: (query: any, index: string, alias: string) => import("../common").QueryStringFilter; buildCustomFilter: typeof buildCustomFilter; buildEmptyFilter: (isPinned: boolean, index?: string | undefined) => import("../common").Filter; - buildExistsFilter: (field: import("../common").IFieldType, indexPattern: import("../common").MinimalIndexPattern) => import("../common").ExistsFilter; + buildExistsFilter: (field: import("../common").FieldBase, indexPattern: import("../common").IndexPatternBase) => import("../common").ExistsFilter; buildFilter: typeof buildFilter; - buildPhraseFilter: (field: import("../common").IFieldType, value: any, indexPattern: import("../common").MinimalIndexPattern) => import("../common").PhraseFilter; - buildPhrasesFilter: (field: import("../common").IFieldType, params: any[], indexPattern: import("../common").MinimalIndexPattern) => import("../common").PhrasesFilter; - buildRangeFilter: (field: import("../common").IFieldType, params: import("../common").RangeFilterParams, indexPattern: import("../common").MinimalIndexPattern, formattedValue?: string | undefined) => import("../common").RangeFilter; + buildPhraseFilter: (field: import("../common").FieldBase, value: any, indexPattern: import("../common").IndexPatternBase) => import("../common").PhraseFilter; + buildPhrasesFilter: (field: import("../common").FieldBase, params: any[], indexPattern: import("../common").IndexPatternBase) => import("../common").PhrasesFilter; + buildRangeFilter: (field: import("../common").FieldBase, params: import("../common").RangeFilterParams, indexPattern: import("../common").IndexPatternBase, formattedValue?: string | undefined) => import("../common").RangeFilter; isFilterDisabled: (filter: import("../common").Filter) => boolean; } ``` diff --git a/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.eskuery.md b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.eskuery.md index 6274eb5f4f4a5..fce25a899de8e 100644 --- a/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.eskuery.md +++ b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.eskuery.md @@ -10,6 +10,6 @@ esKuery: { nodeTypes: import("../common/es_query/kuery/node_types").NodeTypes; fromKueryExpression: (expression: any, parseOptions?: Partial) => import("../common").KueryNode; - toElasticsearchQuery: (node: import("../common").KueryNode, indexPattern?: import("../common").MinimalIndexPattern | undefined, config?: Record | undefined, context?: Record | undefined) => import("@kbn/common-utils").JsonObject; + toElasticsearchQuery: (node: import("../common").KueryNode, indexPattern?: import("../common").IndexPatternBase | undefined, config?: Record | undefined, context?: Record | undefined) => import("@kbn/common-utils").JsonObject; } ``` diff --git a/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.esquery.md b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.esquery.md index 0d1baecb014f5..68507f3fb9b81 100644 --- a/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.esquery.md +++ b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.esquery.md @@ -8,7 +8,7 @@ ```typescript esQuery: { - buildQueryFromFilters: (filters: import("../common").Filter[] | undefined, indexPattern: import("../common").MinimalIndexPattern | undefined, ignoreFilterIfFieldNotInIndex?: boolean) => { + buildQueryFromFilters: (filters: import("../common").Filter[] | undefined, indexPattern: import("../common").IndexPatternBase | undefined, ignoreFilterIfFieldNotInIndex?: boolean) => { must: never[]; filter: import("../common").Filter[]; should: never[]; diff --git a/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.ifieldtype.lang.md b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.ifieldtype.lang.md deleted file mode 100644 index 3d5a757cb8f18..0000000000000 --- a/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.ifieldtype.lang.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) > [IFieldType](./kibana-plugin-plugins-data-server.ifieldtype.md) > [lang](./kibana-plugin-plugins-data-server.ifieldtype.lang.md) - -## IFieldType.lang property - -Signature: - -```typescript -lang?: estypes.ScriptLanguage; -``` diff --git a/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.ifieldtype.md b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.ifieldtype.md index bbc4cc2135d40..98fde569b575d 100644 --- a/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.ifieldtype.md +++ b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.ifieldtype.md @@ -12,7 +12,7 @@ Signature: ```typescript -export interface IFieldType +export interface IFieldType extends FieldBase ``` ## Properties @@ -26,15 +26,9 @@ export interface IFieldType | [esTypes](./kibana-plugin-plugins-data-server.ifieldtype.estypes.md) | string[] | | | [filterable](./kibana-plugin-plugins-data-server.ifieldtype.filterable.md) | boolean | | | [format](./kibana-plugin-plugins-data-server.ifieldtype.format.md) | any | | -| [lang](./kibana-plugin-plugins-data-server.ifieldtype.lang.md) | estypes.ScriptLanguage | | -| [name](./kibana-plugin-plugins-data-server.ifieldtype.name.md) | string | | | [readFromDocValues](./kibana-plugin-plugins-data-server.ifieldtype.readfromdocvalues.md) | boolean | | -| [script](./kibana-plugin-plugins-data-server.ifieldtype.script.md) | string | | -| [scripted](./kibana-plugin-plugins-data-server.ifieldtype.scripted.md) | boolean | | | [searchable](./kibana-plugin-plugins-data-server.ifieldtype.searchable.md) | boolean | | | [sortable](./kibana-plugin-plugins-data-server.ifieldtype.sortable.md) | boolean | | -| [subType](./kibana-plugin-plugins-data-server.ifieldtype.subtype.md) | IFieldSubType | | | [toSpec](./kibana-plugin-plugins-data-server.ifieldtype.tospec.md) | (options?: {
getFormatterForField?: IndexPattern['getFormatterForField'];
}) => FieldSpec | | -| [type](./kibana-plugin-plugins-data-server.ifieldtype.type.md) | string | | | [visualizable](./kibana-plugin-plugins-data-server.ifieldtype.visualizable.md) | boolean | | diff --git a/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.ifieldtype.name.md b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.ifieldtype.name.md deleted file mode 100644 index 8be33a3f56d97..0000000000000 --- a/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.ifieldtype.name.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) > [IFieldType](./kibana-plugin-plugins-data-server.ifieldtype.md) > [name](./kibana-plugin-plugins-data-server.ifieldtype.name.md) - -## IFieldType.name property - -Signature: - -```typescript -name: string; -``` diff --git a/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.ifieldtype.script.md b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.ifieldtype.script.md deleted file mode 100644 index b54a952a11253..0000000000000 --- a/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.ifieldtype.script.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) > [IFieldType](./kibana-plugin-plugins-data-server.ifieldtype.md) > [script](./kibana-plugin-plugins-data-server.ifieldtype.script.md) - -## IFieldType.script property - -Signature: - -```typescript -script?: string; -``` diff --git a/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.ifieldtype.scripted.md b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.ifieldtype.scripted.md deleted file mode 100644 index f7a8ed9aee0df..0000000000000 --- a/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.ifieldtype.scripted.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) > [IFieldType](./kibana-plugin-plugins-data-server.ifieldtype.md) > [scripted](./kibana-plugin-plugins-data-server.ifieldtype.scripted.md) - -## IFieldType.scripted property - -Signature: - -```typescript -scripted?: boolean; -``` diff --git a/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.ifieldtype.subtype.md b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.ifieldtype.subtype.md deleted file mode 100644 index fa78b23a2b558..0000000000000 --- a/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.ifieldtype.subtype.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) > [IFieldType](./kibana-plugin-plugins-data-server.ifieldtype.md) > [subType](./kibana-plugin-plugins-data-server.ifieldtype.subtype.md) - -## IFieldType.subType property - -Signature: - -```typescript -subType?: IFieldSubType; -``` diff --git a/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.ifieldtype.type.md b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.ifieldtype.type.md deleted file mode 100644 index ef6a4dcc167c5..0000000000000 --- a/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.ifieldtype.type.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) > [IFieldType](./kibana-plugin-plugins-data-server.ifieldtype.md) > [type](./kibana-plugin-plugins-data-server.ifieldtype.type.md) - -## IFieldType.type property - -Signature: - -```typescript -type: string; -``` diff --git a/src/plugins/data/common/es_query/es_query/filter_matches_index.ts b/src/plugins/data/common/es_query/es_query/filter_matches_index.ts index f77a029b6bdd5..714ae5f7b274b 100644 --- a/src/plugins/data/common/es_query/es_query/filter_matches_index.ts +++ b/src/plugins/data/common/es_query/es_query/filter_matches_index.ts @@ -7,7 +7,7 @@ */ import { Filter } from '../filters'; -import { FieldBase, IndexPatternBase } from './types'; +import { IndexPatternBase } from './types'; /* * TODO: We should base this on something better than `filter.meta.key`. We should probably modify diff --git a/src/plugins/data/common/es_query/es_query/handle_nested_filter.test.ts b/src/plugins/data/common/es_query/es_query/handle_nested_filter.test.ts index bc0df315340fe..c33d0eb4e1a18 100644 --- a/src/plugins/data/common/es_query/es_query/handle_nested_filter.test.ts +++ b/src/plugins/data/common/es_query/es_query/handle_nested_filter.test.ts @@ -9,7 +9,7 @@ import { handleNestedFilter } from './handle_nested_filter'; import { fields } from '../../index_patterns/mocks'; import { buildPhraseFilter, buildQueryFilter } from '../filters'; -import { IndexPatternBase, FieldBase } from './types'; +import { IndexPatternBase } from './types'; describe('handleNestedFilter', function () { const indexPattern: IndexPatternBase = { diff --git a/src/plugins/data/common/es_query/filters/exists_filter.ts b/src/plugins/data/common/es_query/filters/exists_filter.ts index f5ffb85490bc2..ed499e8ead0db 100644 --- a/src/plugins/data/common/es_query/filters/exists_filter.ts +++ b/src/plugins/data/common/es_query/filters/exists_filter.ts @@ -7,8 +7,7 @@ */ import { Filter, FilterMeta } from './meta_filter'; -import { FieldBase } from '../../index_patterns'; -import { IndexPatternBase } from '..'; +import { FieldBase, IndexPatternBase } from '..'; export type ExistsFilterMeta = FilterMeta; diff --git a/src/plugins/data/common/es_query/filters/phrase_filter.ts b/src/plugins/data/common/es_query/filters/phrase_filter.ts index 7433d1eb7a2cf..628ae684ff2b9 100644 --- a/src/plugins/data/common/es_query/filters/phrase_filter.ts +++ b/src/plugins/data/common/es_query/filters/phrase_filter.ts @@ -8,8 +8,7 @@ import type { estypes } from '@elastic/elasticsearch'; import { get, isPlainObject } from 'lodash'; import { Filter, FilterMeta } from './meta_filter'; -import { FieldBase } from '../../index_patterns'; -import { IndexPatternBase } from '..'; +import { FieldBase, IndexPatternBase } from '..'; export type PhraseFilterMeta = FilterMeta & { params?: { diff --git a/src/plugins/data/common/es_query/kuery/functions/exists.ts b/src/plugins/data/common/es_query/kuery/functions/exists.ts index 17db93ae68d26..b6a9a55d8218d 100644 --- a/src/plugins/data/common/es_query/kuery/functions/exists.ts +++ b/src/plugins/data/common/es_query/kuery/functions/exists.ts @@ -6,7 +6,6 @@ * Side Public License, v 1. */ -import { get } from 'lodash'; import * as literal from '../node_types/literal'; import { KueryNode, FieldBase, IndexPatternBase } from '../../..'; diff --git a/src/plugins/data/common/es_query/kuery/functions/geo_bounding_box.ts b/src/plugins/data/common/es_query/kuery/functions/geo_bounding_box.ts index 60211f3f67863..79bef10b14f71 100644 --- a/src/plugins/data/common/es_query/kuery/functions/geo_bounding_box.ts +++ b/src/plugins/data/common/es_query/kuery/functions/geo_bounding_box.ts @@ -9,7 +9,7 @@ import _ from 'lodash'; import { nodeTypes } from '../node_types'; import * as ast from '../ast'; -import { IndexPatternBase, KueryNode, FieldBase, LatLon } from '../../..'; +import { IndexPatternBase, KueryNode, LatLon } from '../../..'; export function buildNodeParams(fieldName: string, params: any) { params = _.pick(params, 'topLeft', 'bottomRight'); diff --git a/src/plugins/data/common/es_query/kuery/functions/geo_polygon.ts b/src/plugins/data/common/es_query/kuery/functions/geo_polygon.ts index b437baf37988e..2e3280138502a 100644 --- a/src/plugins/data/common/es_query/kuery/functions/geo_polygon.ts +++ b/src/plugins/data/common/es_query/kuery/functions/geo_polygon.ts @@ -8,7 +8,7 @@ import { nodeTypes } from '../node_types'; import * as ast from '../ast'; -import { IndexPatternBase, KueryNode, FieldBase, LatLon } from '../../..'; +import { IndexPatternBase, KueryNode, LatLon } from '../../..'; import { LiteralTypeBuildNode } from '../node_types/types'; export function buildNodeParams(fieldName: string, points: LatLon[]) { diff --git a/src/plugins/data/common/es_query/kuery/functions/range.ts b/src/plugins/data/common/es_query/kuery/functions/range.ts index 13919759f4dbb..b134434dc182b 100644 --- a/src/plugins/data/common/es_query/kuery/functions/range.ts +++ b/src/plugins/data/common/es_query/kuery/functions/range.ts @@ -13,7 +13,7 @@ import { getRangeScript, RangeFilterParams } from '../../filters'; import { getFields } from './utils/get_fields'; import { getTimeZoneFromSettings } from '../../utils'; import { getFullFieldNameNode } from './utils/get_full_field_name_node'; -import { IndexPatternBase, KueryNode, FieldBase } from '../../..'; +import { IndexPatternBase, KueryNode } from '../../..'; export function buildNodeParams(fieldName: string, params: RangeFilterParams) { const paramsToMap = _.pick(params, 'gt', 'lt', 'gte', 'lte', 'format'); diff --git a/src/plugins/data/common/index_patterns/types.ts b/src/plugins/data/common/index_patterns/types.ts index 4fa7531efcb74..6a9decdaa9375 100644 --- a/src/plugins/data/common/index_patterns/types.ts +++ b/src/plugins/data/common/index_patterns/types.ts @@ -32,6 +32,7 @@ export interface RuntimeField { */ export interface IIndexPattern extends IndexPatternBase { title: string; + fields: IFieldType[]; /** * Type is used for identifying rollup indices, otherwise left undefined */ diff --git a/src/plugins/data/public/public.api.md b/src/plugins/data/public/public.api.md index 2849b93b14483..54009a76b1a65 100644 --- a/src/plugins/data/public/public.api.md +++ b/src/plugins/data/public/public.api.md @@ -808,11 +808,11 @@ export const esFilters: { FILTERS: typeof FILTERS; FilterStateStore: typeof FilterStateStore; buildEmptyFilter: (isPinned: boolean, index?: string | undefined) => import("../common").Filter; - buildPhrasesFilter: (field: import("../common").IFieldType, params: any[], indexPattern: import("../common").IndexPatternBase) => import("../common").PhrasesFilter; - buildExistsFilter: (field: import("../common").IFieldType, indexPattern: import("../common").IndexPatternBase) => import("../common").ExistsFilter; - buildPhraseFilter: (field: import("../common").IFieldType, value: any, indexPattern: import("../common").IndexPatternBase) => import("../common").PhraseFilter; + buildPhrasesFilter: (field: import("../common").FieldBase, params: any[], indexPattern: import("../common").IndexPatternBase) => import("../common").PhrasesFilter; + buildExistsFilter: (field: import("../common").FieldBase, indexPattern: import("../common").IndexPatternBase) => import("../common").ExistsFilter; + buildPhraseFilter: (field: import("../common").FieldBase, value: any, indexPattern: import("../common").IndexPatternBase) => import("../common").PhraseFilter; buildQueryFilter: (query: any, index: string, alias: string) => import("../common").QueryStringFilter; - buildRangeFilter: (field: import("../common").IFieldType, params: import("../common").RangeFilterParams, indexPattern: import("../common").IndexPatternBase, formattedValue?: string | undefined) => import("../common").RangeFilter; + buildRangeFilter: (field: import("../common").FieldBase, params: import("../common").RangeFilterParams, indexPattern: import("../common").IndexPatternBase, formattedValue?: string | undefined) => import("../common").RangeFilter; isPhraseFilter: (filter: any) => filter is import("../common").PhraseFilter; isExistsFilter: (filter: any) => filter is import("../common").ExistsFilter; isPhrasesFilter: (filter: any) => filter is import("../common").PhrasesFilter; @@ -1242,10 +1242,11 @@ export interface IFieldSubType { }; } +// Warning: (ae-forgotten-export) The symbol "FieldBase" needs to be exported by the entry point index.d.ts // Warning: (ae-missing-release-tag) "IFieldType" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public @deprecated (undocumented) -export interface IFieldType { +export interface IFieldType extends FieldBase { // (undocumented) aggregatable?: boolean; // (undocumented) @@ -1261,28 +1262,16 @@ export interface IFieldType { // (undocumented) format?: any; // (undocumented) - lang?: estypes.ScriptLanguage; - // (undocumented) - name: string; - // (undocumented) readFromDocValues?: boolean; // (undocumented) - script?: string; - // (undocumented) - scripted?: boolean; - // (undocumented) searchable?: boolean; // (undocumented) sortable?: boolean; // (undocumented) - subType?: IFieldSubType; - // (undocumented) toSpec?: (options?: { getFormatterForField?: IndexPattern['getFormatterForField']; }) => FieldSpec; // (undocumented) - type: string; - // (undocumented) visualizable?: boolean; } @@ -1295,6 +1284,8 @@ export interface IIndexPattern extends IndexPatternBase { // // (undocumented) fieldFormatMap?: Record | undefined>; + // (undocumented) + fields: IFieldType[]; getFormatterForField?: (field: IndexPatternField | IndexPatternField['spec'] | IFieldType) => FieldFormat; // (undocumented) getTimeField?(): IFieldType | undefined; @@ -1557,7 +1548,7 @@ export class IndexPatternField implements IFieldType { // (undocumented) readonly spec: FieldSpec; // (undocumented) - get subType(): import("../types").IFieldSubType | undefined; + get subType(): import("../..").IFieldSubType | undefined; // (undocumented) toJSON(): { count: number; @@ -1571,7 +1562,7 @@ export class IndexPatternField implements IFieldType { searchable: boolean; aggregatable: boolean; readFromDocValues: boolean; - subType: import("../types").IFieldSubType | undefined; + subType: import("../..").IFieldSubType | undefined; customLabel: string | undefined; }; // (undocumented) @@ -2728,13 +2719,13 @@ export interface WaitUntilNextSessionCompletesOptions { // Warnings were encountered during analysis: // -// src/plugins/data/common/es_query/filters/exists_filter.ts:20:3 - (ae-forgotten-export) The symbol "ExistsFilterMeta" needs to be exported by the entry point index.d.ts -// src/plugins/data/common/es_query/filters/exists_filter.ts:21:3 - (ae-forgotten-export) The symbol "FilterExistsProperty" needs to be exported by the entry point index.d.ts +// src/plugins/data/common/es_query/filters/exists_filter.ts:19:3 - (ae-forgotten-export) The symbol "ExistsFilterMeta" needs to be exported by the entry point index.d.ts +// src/plugins/data/common/es_query/filters/exists_filter.ts:20:3 - (ae-forgotten-export) The symbol "FilterExistsProperty" needs to be exported by the entry point index.d.ts // src/plugins/data/common/es_query/filters/match_all_filter.ts:17:3 - (ae-forgotten-export) The symbol "MatchAllFilterMeta" needs to be exported by the entry point index.d.ts // src/plugins/data/common/es_query/filters/meta_filter.ts:43:3 - (ae-forgotten-export) The symbol "FilterState" needs to be exported by the entry point index.d.ts // src/plugins/data/common/es_query/filters/meta_filter.ts:44:3 - (ae-forgotten-export) The symbol "FilterMeta" needs to be exported by the entry point index.d.ts -// src/plugins/data/common/es_query/filters/phrase_filter.ts:23:3 - (ae-forgotten-export) The symbol "PhraseFilterMeta" needs to be exported by the entry point index.d.ts -// src/plugins/data/common/es_query/filters/phrases_filter.ts:21:3 - (ae-forgotten-export) The symbol "PhrasesFilterMeta" needs to be exported by the entry point index.d.ts +// src/plugins/data/common/es_query/filters/phrase_filter.ts:22:3 - (ae-forgotten-export) The symbol "PhraseFilterMeta" needs to be exported by the entry point index.d.ts +// src/plugins/data/common/es_query/filters/phrases_filter.ts:20:3 - (ae-forgotten-export) The symbol "PhrasesFilterMeta" needs to be exported by the entry point index.d.ts // 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 diff --git a/src/plugins/data/server/server.api.md b/src/plugins/data/server/server.api.md index 5ca19f9e1e509..16988607b8ab4 100644 --- a/src/plugins/data/server/server.api.md +++ b/src/plugins/data/server/server.api.md @@ -447,11 +447,11 @@ export const esFilters: { buildQueryFilter: (query: any, index: string, alias: string) => import("../common").QueryStringFilter; buildCustomFilter: typeof buildCustomFilter; buildEmptyFilter: (isPinned: boolean, index?: string | undefined) => import("../common").Filter; - buildExistsFilter: (field: import("../common").IFieldType, indexPattern: import("../common").IndexPatternBase) => import("../common").ExistsFilter; + buildExistsFilter: (field: import("../common").FieldBase, indexPattern: import("../common").IndexPatternBase) => import("../common").ExistsFilter; buildFilter: typeof buildFilter; - buildPhraseFilter: (field: import("../common").IFieldType, value: any, indexPattern: import("../common").IndexPatternBase) => import("../common").PhraseFilter; - buildPhrasesFilter: (field: import("../common").IFieldType, params: any[], indexPattern: import("../common").IndexPatternBase) => import("../common").PhrasesFilter; - buildRangeFilter: (field: import("../common").IFieldType, params: import("../common").RangeFilterParams, indexPattern: import("../common").IndexPatternBase, formattedValue?: string | undefined) => import("../common").RangeFilter; + buildPhraseFilter: (field: import("../common").FieldBase, value: any, indexPattern: import("../common").IndexPatternBase) => import("../common").PhraseFilter; + buildPhrasesFilter: (field: import("../common").FieldBase, params: any[], indexPattern: import("../common").IndexPatternBase) => import("../common").PhrasesFilter; + buildRangeFilter: (field: import("../common").FieldBase, params: import("../common").RangeFilterParams, indexPattern: import("../common").IndexPatternBase, formattedValue?: string | undefined) => import("../common").RangeFilter; isFilterDisabled: (filter: import("../common").Filter) => boolean; }; @@ -693,10 +693,11 @@ export interface IFieldSubType { }; } +// Warning: (ae-forgotten-export) The symbol "FieldBase" needs to be exported by the entry point index.d.ts // Warning: (ae-missing-release-tag) "IFieldType" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public @deprecated (undocumented) -export interface IFieldType { +export interface IFieldType extends FieldBase { // (undocumented) aggregatable?: boolean; // (undocumented) @@ -712,21 +713,11 @@ export interface IFieldType { // (undocumented) format?: any; // (undocumented) - lang?: estypes.ScriptLanguage; - // (undocumented) - name: string; - // (undocumented) readFromDocValues?: boolean; // (undocumented) - script?: string; - // (undocumented) - scripted?: boolean; - // (undocumented) searchable?: boolean; // (undocumented) sortable?: boolean; - // (undocumented) - subType?: IFieldSubType; // Warning: (ae-forgotten-export) The symbol "FieldSpec" needs to be exported by the entry point index.d.ts // // (undocumented) @@ -734,8 +725,6 @@ export interface IFieldType { getFormatterForField?: IndexPattern['getFormatterForField']; }) => FieldSpec; // (undocumented) - type: string; - // (undocumented) visualizable?: boolean; } From a0696b5bf6cf891ff54ea084e4552e9b867ade82 Mon Sep 17 00:00:00 2001 From: Liza K Date: Sun, 27 Jun 2021 16:44:16 +0300 Subject: [PATCH 06/10] test types --- .../common/es_query/es_query/handle_nested_filter.test.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/plugins/data/common/es_query/es_query/handle_nested_filter.test.ts b/src/plugins/data/common/es_query/es_query/handle_nested_filter.test.ts index c33d0eb4e1a18..cf5d68eff65d1 100644 --- a/src/plugins/data/common/es_query/es_query/handle_nested_filter.test.ts +++ b/src/plugins/data/common/es_query/es_query/handle_nested_filter.test.ts @@ -44,8 +44,9 @@ describe('handleNestedFilter', function () { }); it('should return filter untouched if it does not target a field from the given index pattern', () => { - const field = { ...getField('extension'), name: 'notarealfield' }; - const filter = buildPhraseFilter(field, 'jpg', indexPattern); + const field = getField('extension'); + field!.name = 'notarealfield'; + const filter = buildPhraseFilter(field!, 'jpg', indexPattern); const result = handleNestedFilter(filter, indexPattern); expect(result).toBe(filter); }); From 7984b50875c94d65d28aa0f008260e460b969d59 Mon Sep 17 00:00:00 2001 From: Liza K Date: Mon, 28 Jun 2021 12:17:49 +0300 Subject: [PATCH 07/10] fix jest --- .../common/es_query/es_query/handle_nested_filter.test.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/plugins/data/common/es_query/es_query/handle_nested_filter.test.ts b/src/plugins/data/common/es_query/es_query/handle_nested_filter.test.ts index cf5d68eff65d1..24852ebf33bda 100644 --- a/src/plugins/data/common/es_query/es_query/handle_nested_filter.test.ts +++ b/src/plugins/data/common/es_query/es_query/handle_nested_filter.test.ts @@ -45,8 +45,11 @@ describe('handleNestedFilter', function () { it('should return filter untouched if it does not target a field from the given index pattern', () => { const field = getField('extension'); - field!.name = 'notarealfield'; - const filter = buildPhraseFilter(field!, 'jpg', indexPattern); + const unrealField = { + ...field!, + name: 'notarealfield', + }; + const filter = buildPhraseFilter(unrealField, 'jpg', indexPattern); const result = handleNestedFilter(filter, indexPattern); expect(result).toBe(filter); }); From 028d7da8d1bd894667616f5300f4a4db231616cc Mon Sep 17 00:00:00 2001 From: Liza K Date: Tue, 29 Jun 2021 10:02:03 +0100 Subject: [PATCH 08/10] rename --- .../kibana-plugin-plugins-data-public.esfilters.md | 8 ++++---- .../kibana-plugin-plugins-data-server.esfilters.md | 8 ++++---- src/plugins/data/common/es_query/es_query/index.ts | 2 +- src/plugins/data/common/es_query/es_query/types.ts | 4 ++-- .../data/common/es_query/filters/build_filters.ts | 6 +++--- .../data/common/es_query/filters/exists_filter.ts | 4 ++-- .../data/common/es_query/filters/phrase_filter.ts | 8 ++++---- .../data/common/es_query/filters/phrases_filter.ts | 4 ++-- .../common/es_query/filters/range_filter.test.ts | 6 +++--- .../data/common/es_query/filters/range_filter.ts | 6 +++--- .../data/common/es_query/kuery/functions/exists.ts | 4 ++-- .../data/common/es_query/kuery/functions/is.ts | 4 ++-- .../functions/utils/get_full_field_name_node.ts | 4 ++-- .../data/common/index_patterns/fields/types.ts | 4 ++-- src/plugins/data/common/index_patterns/types.ts | 4 ++-- src/plugins/data/public/public.api.md | 12 ++++++------ src/plugins/data/server/server.api.md | 12 ++++++------ 17 files changed, 50 insertions(+), 50 deletions(-) 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 0cdc1e5c8bcbf..d06ce1b2ef2bc 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 @@ -13,11 +13,11 @@ esFilters: { FILTERS: typeof FILTERS; FilterStateStore: typeof FilterStateStore; buildEmptyFilter: (isPinned: boolean, index?: string | undefined) => import("../common").Filter; - buildPhrasesFilter: (field: import("../common").FieldBase, params: any[], indexPattern: import("../common").IndexPatternBase) => import("../common").PhrasesFilter; - buildExistsFilter: (field: import("../common").FieldBase, indexPattern: import("../common").IndexPatternBase) => import("../common").ExistsFilter; - buildPhraseFilter: (field: import("../common").FieldBase, value: any, indexPattern: import("../common").IndexPatternBase) => import("../common").PhraseFilter; + buildPhrasesFilter: (field: import("../common").IndexPatternFieldBase, params: any[], indexPattern: import("../common").IndexPatternBase) => import("../common").PhrasesFilter; + buildExistsFilter: (field: import("../common").IndexPatternFieldBase, indexPattern: import("../common").IndexPatternBase) => import("../common").ExistsFilter; + buildPhraseFilter: (field: import("../common").IndexPatternFieldBase, value: any, indexPattern: import("../common").IndexPatternBase) => import("../common").PhraseFilter; buildQueryFilter: (query: any, index: string, alias: string) => import("../common").QueryStringFilter; - buildRangeFilter: (field: import("../common").FieldBase, params: import("../common").RangeFilterParams, indexPattern: import("../common").IndexPatternBase, formattedValue?: string | undefined) => import("../common").RangeFilter; + buildRangeFilter: (field: import("../common").IndexPatternFieldBase, params: import("../common").RangeFilterParams, indexPattern: import("../common").IndexPatternBase, formattedValue?: string | undefined) => import("../common").RangeFilter; isPhraseFilter: (filter: any) => filter is import("../common").PhraseFilter; isExistsFilter: (filter: any) => filter is import("../common").ExistsFilter; isPhrasesFilter: (filter: any) => filter is import("../common").PhrasesFilter; 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 202c9e4588f8a..594afcf9ee0dd 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 @@ -11,11 +11,11 @@ esFilters: { buildQueryFilter: (query: any, index: string, alias: string) => import("../common").QueryStringFilter; buildCustomFilter: typeof buildCustomFilter; buildEmptyFilter: (isPinned: boolean, index?: string | undefined) => import("../common").Filter; - buildExistsFilter: (field: import("../common").FieldBase, indexPattern: import("../common").IndexPatternBase) => import("../common").ExistsFilter; + buildExistsFilter: (field: import("../common").IndexPatternFieldBase, indexPattern: import("../common").IndexPatternBase) => import("../common").ExistsFilter; buildFilter: typeof buildFilter; - buildPhraseFilter: (field: import("../common").FieldBase, value: any, indexPattern: import("../common").IndexPatternBase) => import("../common").PhraseFilter; - buildPhrasesFilter: (field: import("../common").FieldBase, params: any[], indexPattern: import("../common").IndexPatternBase) => import("../common").PhrasesFilter; - buildRangeFilter: (field: import("../common").FieldBase, params: import("../common").RangeFilterParams, indexPattern: import("../common").IndexPatternBase, formattedValue?: string | undefined) => import("../common").RangeFilter; + buildPhraseFilter: (field: import("../common").IndexPatternFieldBase, value: any, indexPattern: import("../common").IndexPatternBase) => import("../common").PhraseFilter; + buildPhrasesFilter: (field: import("../common").IndexPatternFieldBase, params: any[], indexPattern: import("../common").IndexPatternBase) => import("../common").PhrasesFilter; + buildRangeFilter: (field: import("../common").IndexPatternFieldBase, params: import("../common").RangeFilterParams, indexPattern: import("../common").IndexPatternBase, formattedValue?: string | undefined) => import("../common").RangeFilter; isFilterDisabled: (filter: import("../common").Filter) => boolean; } ``` diff --git a/src/plugins/data/common/es_query/es_query/index.ts b/src/plugins/data/common/es_query/es_query/index.ts index efe645f111b6a..ecc7c8ba5a9f5 100644 --- a/src/plugins/data/common/es_query/es_query/index.ts +++ b/src/plugins/data/common/es_query/es_query/index.ts @@ -11,4 +11,4 @@ export { buildQueryFromFilters } from './from_filters'; export { luceneStringToDsl } from './lucene_string_to_dsl'; export { decorateQuery } from './decorate_query'; export { getEsQueryConfig } from './get_es_query_config'; -export { IndexPatternBase, FieldBase, IFieldSubType } from './types'; +export { IndexPatternBase, IndexPatternFieldBase, IFieldSubType } from './types'; diff --git a/src/plugins/data/common/es_query/es_query/types.ts b/src/plugins/data/common/es_query/es_query/types.ts index 29d5b4dad6a61..ef028e1aa9d4a 100644 --- a/src/plugins/data/common/es_query/es_query/types.ts +++ b/src/plugins/data/common/es_query/es_query/types.ts @@ -12,7 +12,7 @@ export interface IFieldSubType { multi?: { parent: string }; nested?: { path: string }; } -export interface FieldBase { +export interface IndexPatternFieldBase { name: string; type: string; subType?: IFieldSubType; @@ -29,6 +29,6 @@ export interface FieldBase { } export interface IndexPatternBase { - fields: FieldBase[]; + fields: IndexPatternFieldBase[]; id?: string; } diff --git a/src/plugins/data/common/es_query/filters/build_filters.ts b/src/plugins/data/common/es_query/filters/build_filters.ts index 333bca779af44..1d8d67b6e937f 100644 --- a/src/plugins/data/common/es_query/filters/build_filters.ts +++ b/src/plugins/data/common/es_query/filters/build_filters.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import { FieldBase, IndexPatternBase } from '../..'; +import { IndexPatternFieldBase, IndexPatternBase } from '../..'; import { Filter, @@ -21,7 +21,7 @@ import { export function buildFilter( indexPattern: IndexPatternBase, - field: FieldBase, + field: IndexPatternFieldBase, type: FILTERS, negate: boolean, disabled: boolean, @@ -61,7 +61,7 @@ export function buildCustomFilter( function buildBaseFilter( indexPattern: IndexPatternBase, - field: FieldBase, + field: IndexPatternFieldBase, type: FILTERS, params: any ): Filter { diff --git a/src/plugins/data/common/es_query/filters/exists_filter.ts b/src/plugins/data/common/es_query/filters/exists_filter.ts index ed499e8ead0db..7a09adb7d9ed6 100644 --- a/src/plugins/data/common/es_query/filters/exists_filter.ts +++ b/src/plugins/data/common/es_query/filters/exists_filter.ts @@ -7,7 +7,7 @@ */ import { Filter, FilterMeta } from './meta_filter'; -import { FieldBase, IndexPatternBase } from '..'; +import { IndexPatternFieldBase, IndexPatternBase } from '..'; export type ExistsFilterMeta = FilterMeta; @@ -26,7 +26,7 @@ export const getExistsFilterField = (filter: ExistsFilter) => { return filter.exists && filter.exists.field; }; -export const buildExistsFilter = (field: FieldBase, indexPattern: IndexPatternBase) => { +export const buildExistsFilter = (field: IndexPatternFieldBase, indexPattern: IndexPatternBase) => { return { meta: { index: indexPattern.id, diff --git a/src/plugins/data/common/es_query/filters/phrase_filter.ts b/src/plugins/data/common/es_query/filters/phrase_filter.ts index 628ae684ff2b9..68ad16cb31d42 100644 --- a/src/plugins/data/common/es_query/filters/phrase_filter.ts +++ b/src/plugins/data/common/es_query/filters/phrase_filter.ts @@ -8,7 +8,7 @@ import type { estypes } from '@elastic/elasticsearch'; import { get, isPlainObject } from 'lodash'; import { Filter, FilterMeta } from './meta_filter'; -import { FieldBase, IndexPatternBase } from '..'; +import { IndexPatternFieldBase, IndexPatternBase } from '..'; export type PhraseFilterMeta = FilterMeta & { params?: { @@ -58,7 +58,7 @@ export const getPhraseFilterValue = (filter: PhraseFilter): PhraseFilterValue => }; export const buildPhraseFilter = ( - field: FieldBase, + field: IndexPatternFieldBase, value: any, indexPattern: IndexPatternBase ): PhraseFilter => { @@ -81,7 +81,7 @@ export const buildPhraseFilter = ( } }; -export const getPhraseScript = (field: FieldBase, value: string) => { +export const getPhraseScript = (field: IndexPatternFieldBase, value: string) => { const convertedValue = getConvertedValueForField(field, value); const script = buildInlineScriptForPhraseFilter(field); @@ -105,7 +105,7 @@ export const getPhraseScript = (field: FieldBase, value: string) => { * https://github.com/elastic/elasticsearch/issues/20941 * https://github.com/elastic/elasticsearch/pull/22201 **/ -export const getConvertedValueForField = (field: FieldBase, value: any) => { +export const getConvertedValueForField = (field: IndexPatternFieldBase, value: any) => { if (typeof value !== 'boolean' && field.type === 'boolean') { if ([1, 'true'].includes(value)) { return true; diff --git a/src/plugins/data/common/es_query/filters/phrases_filter.ts b/src/plugins/data/common/es_query/filters/phrases_filter.ts index e73f0f4e6a810..7f7831e1c7978 100644 --- a/src/plugins/data/common/es_query/filters/phrases_filter.ts +++ b/src/plugins/data/common/es_query/filters/phrases_filter.ts @@ -9,7 +9,7 @@ import { Filter, FilterMeta } from './meta_filter'; import { getPhraseScript } from './phrase_filter'; import { FILTERS } from './index'; -import { FieldBase, IndexPatternBase } from '../es_query'; +import { IndexPatternFieldBase, IndexPatternBase } from '../es_query'; export type PhrasesFilterMeta = FilterMeta & { params: string[]; // The unformatted values @@ -32,7 +32,7 @@ export const getPhrasesFilterField = (filter: PhrasesFilter) => { // Creates a filter where the given field matches one or more of the given values // params should be an array of values export const buildPhrasesFilter = ( - field: FieldBase, + field: IndexPatternFieldBase, params: any[], indexPattern: IndexPatternBase ) => { diff --git a/src/plugins/data/common/es_query/filters/range_filter.test.ts b/src/plugins/data/common/es_query/filters/range_filter.test.ts index 613f987a76800..30e52b21d52b7 100644 --- a/src/plugins/data/common/es_query/filters/range_filter.test.ts +++ b/src/plugins/data/common/es_query/filters/range_filter.test.ts @@ -9,7 +9,7 @@ import { each } from 'lodash'; import { buildRangeFilter, getRangeFilterField, RangeFilter } from './range_filter'; import { fields, getField } from '../../index_patterns/mocks'; -import { IndexPatternBase, FieldBase } from '../es_query'; +import { IndexPatternBase, IndexPatternFieldBase } from '../es_query'; describe('Range filter builder', () => { let indexPattern: IndexPatternBase; @@ -130,7 +130,7 @@ describe('Range filter builder', () => { }); describe('when given params where one side is infinite', () => { - let field: FieldBase; + let field: IndexPatternFieldBase; let filter: RangeFilter; beforeEach(() => { @@ -160,7 +160,7 @@ describe('Range filter builder', () => { }); describe('when given params where both sides are infinite', () => { - let field: FieldBase; + let field: IndexPatternFieldBase; let filter: RangeFilter; beforeEach(() => { diff --git a/src/plugins/data/common/es_query/filters/range_filter.ts b/src/plugins/data/common/es_query/filters/range_filter.ts index f87f9d0f846f2..e44e23f64936e 100644 --- a/src/plugins/data/common/es_query/filters/range_filter.ts +++ b/src/plugins/data/common/es_query/filters/range_filter.ts @@ -8,7 +8,7 @@ import type { estypes } from '@elastic/elasticsearch'; import { map, reduce, mapValues, get, keys, pickBy } from 'lodash'; import { Filter, FilterMeta } from './meta_filter'; -import { IndexPatternBase, FieldBase } from '..'; +import { IndexPatternBase, IndexPatternFieldBase } from '..'; const OPERANDS_IN_RANGE = 2; @@ -88,7 +88,7 @@ const formatValue = (params: any[]) => // Creates a filter where the value for the given field is in the given range // params should be an object containing `lt`, `lte`, `gt`, and/or `gte` export const buildRangeFilter = ( - field: FieldBase, + field: IndexPatternFieldBase, params: RangeFilterParams, indexPattern: IndexPatternBase, formattedValue?: string @@ -134,7 +134,7 @@ export const buildRangeFilter = ( return filter as RangeFilter; }; -export const getRangeScript = (field: FieldBase, params: RangeFilterParams) => { +export const getRangeScript = (field: IndexPatternFieldBase, params: RangeFilterParams) => { const knownParams = mapValues( pickBy(params, (val, key: any) => key in operators), (value) => (field.type === 'number' && typeof value === 'string' ? parseFloat(value) : value) diff --git a/src/plugins/data/common/es_query/kuery/functions/exists.ts b/src/plugins/data/common/es_query/kuery/functions/exists.ts index b6a9a55d8218d..4df566d874d8b 100644 --- a/src/plugins/data/common/es_query/kuery/functions/exists.ts +++ b/src/plugins/data/common/es_query/kuery/functions/exists.ts @@ -7,7 +7,7 @@ */ import * as literal from '../node_types/literal'; -import { KueryNode, FieldBase, IndexPatternBase } from '../../..'; +import { KueryNode, IndexPatternFieldBase, IndexPatternBase } from '../../..'; export function buildNodeParams(fieldName: string) { return { @@ -29,7 +29,7 @@ export function toElasticsearchQuery( value: context?.nested ? `${context.nested.path}.${fieldNameArg.value}` : fieldNameArg.value, }; const fieldName = literal.toElasticsearchQuery(fullFieldNameArg); - const field = indexPattern?.fields?.find((fld: FieldBase) => fld.name === fieldName); + const field = indexPattern?.fields?.find((fld: IndexPatternFieldBase) => fld.name === fieldName); if (field?.scripted) { throw new Error(`Exists query does not support scripted fields`); diff --git a/src/plugins/data/common/es_query/kuery/functions/is.ts b/src/plugins/data/common/es_query/kuery/functions/is.ts index 47ae5bb4af0d9..381913670c26a 100644 --- a/src/plugins/data/common/es_query/kuery/functions/is.ts +++ b/src/plugins/data/common/es_query/kuery/functions/is.ts @@ -11,7 +11,7 @@ import { getPhraseScript } from '../../filters'; import { getFields } from './utils/get_fields'; import { getTimeZoneFromSettings } from '../../utils'; import { getFullFieldNameNode } from './utils/get_full_field_name_node'; -import { IndexPatternBase, KueryNode, FieldBase } from '../../..'; +import { IndexPatternBase, KueryNode, IndexPatternFieldBase } from '../../..'; import * as ast from '../ast'; @@ -100,7 +100,7 @@ export function toElasticsearchQuery( return { match_all: {} }; } - const queries = fields!.reduce((accumulator: any, field: FieldBase) => { + const queries = fields!.reduce((accumulator: any, field: IndexPatternFieldBase) => { const wrapWithNestedQuery = (query: any) => { // Wildcards can easily include nested and non-nested fields. There isn't a good way to let // users handle this themselves so we automatically add nested queries in this scenario. diff --git a/src/plugins/data/common/es_query/kuery/functions/utils/get_full_field_name_node.ts b/src/plugins/data/common/es_query/kuery/functions/utils/get_full_field_name_node.ts index cfea79696122c..2a31ebeee2fab 100644 --- a/src/plugins/data/common/es_query/kuery/functions/utils/get_full_field_name_node.ts +++ b/src/plugins/data/common/es_query/kuery/functions/utils/get_full_field_name_node.ts @@ -7,7 +7,7 @@ */ import { getFields } from './get_fields'; -import { IndexPatternBase, FieldBase, KueryNode } from '../../../..'; +import { IndexPatternBase, IndexPatternFieldBase, KueryNode } from '../../../..'; export function getFullFieldNameNode( rootNameNode: any, @@ -27,7 +27,7 @@ export function getFullFieldNameNode( } const fields = getFields(fullFieldNameNode, indexPattern); - const errors = fields!.reduce((acc: any, field: FieldBase) => { + const errors = fields!.reduce((acc: any, field: IndexPatternFieldBase) => { const nestedPathFromField = field.subType && field.subType.nested ? field.subType.nested.path : undefined; diff --git a/src/plugins/data/common/index_patterns/fields/types.ts b/src/plugins/data/common/index_patterns/fields/types.ts index 608294b04dc91..3b2e25d3d80a6 100644 --- a/src/plugins/data/common/index_patterns/fields/types.ts +++ b/src/plugins/data/common/index_patterns/fields/types.ts @@ -5,13 +5,13 @@ * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ -import { FieldBase, FieldSpec, IndexPattern } from '../..'; +import { IndexPatternFieldBase, FieldSpec, IndexPattern } from '../..'; /** * @deprecated * Use IndexPatternField or FieldSpec instead */ -export interface IFieldType extends FieldBase { +export interface IFieldType extends IndexPatternFieldBase { count?: number; // esTypes might be undefined on old index patterns that have not been refreshed since we added // this prop. It is also undefined on scripted fields. diff --git a/src/plugins/data/common/index_patterns/types.ts b/src/plugins/data/common/index_patterns/types.ts index 6a9decdaa9375..b03e745df74a6 100644 --- a/src/plugins/data/common/index_patterns/types.ts +++ b/src/plugins/data/common/index_patterns/types.ts @@ -9,7 +9,7 @@ import type { estypes } from '@elastic/elasticsearch'; import { ToastInputFields, ErrorToastOptions } from 'src/core/public/notifications'; // eslint-disable-next-line import type { SavedObject } from 'src/core/server'; -import type { FieldBase, IFieldSubType, IndexPatternBase } from '../es_query'; +import type { IndexPatternFieldBase, IFieldSubType, IndexPatternBase } from '../es_query'; import { IFieldType } from './fields'; import { RUNTIME_FIELD_TYPES } from './constants'; import { SerializedFieldFormat } from '../../../expressions/common'; @@ -178,7 +178,7 @@ export interface FieldSpecExportFmt { /** * Serialized version of IndexPatternField */ -export interface FieldSpec extends FieldBase { +export interface FieldSpec extends IndexPatternFieldBase { /** * Popularity count is used by discover */ diff --git a/src/plugins/data/public/public.api.md b/src/plugins/data/public/public.api.md index dc04854168bee..33561e68f335d 100644 --- a/src/plugins/data/public/public.api.md +++ b/src/plugins/data/public/public.api.md @@ -808,11 +808,11 @@ export const esFilters: { FILTERS: typeof FILTERS; FilterStateStore: typeof FilterStateStore; buildEmptyFilter: (isPinned: boolean, index?: string | undefined) => import("../common").Filter; - buildPhrasesFilter: (field: import("../common").FieldBase, params: any[], indexPattern: import("../common").IndexPatternBase) => import("../common").PhrasesFilter; - buildExistsFilter: (field: import("../common").FieldBase, indexPattern: import("../common").IndexPatternBase) => import("../common").ExistsFilter; - buildPhraseFilter: (field: import("../common").FieldBase, value: any, indexPattern: import("../common").IndexPatternBase) => import("../common").PhraseFilter; + buildPhrasesFilter: (field: import("../common").IndexPatternFieldBase, params: any[], indexPattern: import("../common").IndexPatternBase) => import("../common").PhrasesFilter; + buildExistsFilter: (field: import("../common").IndexPatternFieldBase, indexPattern: import("../common").IndexPatternBase) => import("../common").ExistsFilter; + buildPhraseFilter: (field: import("../common").IndexPatternFieldBase, value: any, indexPattern: import("../common").IndexPatternBase) => import("../common").PhraseFilter; buildQueryFilter: (query: any, index: string, alias: string) => import("../common").QueryStringFilter; - buildRangeFilter: (field: import("../common").FieldBase, params: import("../common").RangeFilterParams, indexPattern: import("../common").IndexPatternBase, formattedValue?: string | undefined) => import("../common").RangeFilter; + buildRangeFilter: (field: import("../common").IndexPatternFieldBase, params: import("../common").RangeFilterParams, indexPattern: import("../common").IndexPatternBase, formattedValue?: string | undefined) => import("../common").RangeFilter; isPhraseFilter: (filter: any) => filter is import("../common").PhraseFilter; isExistsFilter: (filter: any) => filter is import("../common").ExistsFilter; isPhrasesFilter: (filter: any) => filter is import("../common").PhrasesFilter; @@ -1242,11 +1242,11 @@ export interface IFieldSubType { }; } -// Warning: (ae-forgotten-export) The symbol "FieldBase" needs to be exported by the entry point index.d.ts +// Warning: (ae-forgotten-export) The symbol "IndexPatternFieldBase" needs to be exported by the entry point index.d.ts // Warning: (ae-missing-release-tag) "IFieldType" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public @deprecated (undocumented) -export interface IFieldType extends FieldBase { +export interface IFieldType extends IndexPatternFieldBase { // (undocumented) aggregatable?: boolean; // (undocumented) diff --git a/src/plugins/data/server/server.api.md b/src/plugins/data/server/server.api.md index c38dbdab17f90..52c127eb65003 100644 --- a/src/plugins/data/server/server.api.md +++ b/src/plugins/data/server/server.api.md @@ -447,11 +447,11 @@ export const esFilters: { buildQueryFilter: (query: any, index: string, alias: string) => import("../common").QueryStringFilter; buildCustomFilter: typeof buildCustomFilter; buildEmptyFilter: (isPinned: boolean, index?: string | undefined) => import("../common").Filter; - buildExistsFilter: (field: import("../common").FieldBase, indexPattern: import("../common").IndexPatternBase) => import("../common").ExistsFilter; + buildExistsFilter: (field: import("../common").IndexPatternFieldBase, indexPattern: import("../common").IndexPatternBase) => import("../common").ExistsFilter; buildFilter: typeof buildFilter; - buildPhraseFilter: (field: import("../common").FieldBase, value: any, indexPattern: import("../common").IndexPatternBase) => import("../common").PhraseFilter; - buildPhrasesFilter: (field: import("../common").FieldBase, params: any[], indexPattern: import("../common").IndexPatternBase) => import("../common").PhrasesFilter; - buildRangeFilter: (field: import("../common").FieldBase, params: import("../common").RangeFilterParams, indexPattern: import("../common").IndexPatternBase, formattedValue?: string | undefined) => import("../common").RangeFilter; + buildPhraseFilter: (field: import("../common").IndexPatternFieldBase, value: any, indexPattern: import("../common").IndexPatternBase) => import("../common").PhraseFilter; + buildPhrasesFilter: (field: import("../common").IndexPatternFieldBase, params: any[], indexPattern: import("../common").IndexPatternBase) => import("../common").PhrasesFilter; + buildRangeFilter: (field: import("../common").IndexPatternFieldBase, params: import("../common").RangeFilterParams, indexPattern: import("../common").IndexPatternBase, formattedValue?: string | undefined) => import("../common").RangeFilter; isFilterDisabled: (filter: import("../common").Filter) => boolean; }; @@ -693,11 +693,11 @@ export interface IFieldSubType { }; } -// Warning: (ae-forgotten-export) The symbol "FieldBase" needs to be exported by the entry point index.d.ts +// Warning: (ae-forgotten-export) The symbol "IndexPatternFieldBase" needs to be exported by the entry point index.d.ts // Warning: (ae-missing-release-tag) "IFieldType" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public @deprecated (undocumented) -export interface IFieldType extends FieldBase { +export interface IFieldType extends IndexPatternFieldBase { // (undocumented) aggregatable?: boolean; // (undocumented) From d210ddb7f5ecd407fe60837bd8994869da54d78b Mon Sep 17 00:00:00 2001 From: Liza K Date: Tue, 29 Jun 2021 14:10:43 +0100 Subject: [PATCH 09/10] docs --- .../kibana-plugin-plugins-data-public.ifieldtype.md | 2 +- ...data-public.indexpattern.getaggregationrestrictions.md | 8 ++++++-- .../kibana-plugin-plugins-data-server.ifieldtype.md | 2 +- ...data-server.indexpattern.getaggregationrestrictions.md | 8 ++++++-- src/plugins/data/public/public.api.md | 4 +++- src/plugins/data/server/server.api.md | 4 +++- 6 files changed, 20 insertions(+), 8 deletions(-) diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.ifieldtype.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.ifieldtype.md index 55df5c3367748..e1acea53ea5e0 100644 --- a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.ifieldtype.md +++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.ifieldtype.md @@ -12,7 +12,7 @@ Signature: ```typescript -export interface IFieldType extends FieldBase +export interface IFieldType extends IndexPatternFieldBase ``` ## Properties diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpattern.getaggregationrestrictions.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpattern.getaggregationrestrictions.md index e42980bb53af4..1bbe0b594ecf0 100644 --- a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpattern.getaggregationrestrictions.md +++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpattern.getaggregationrestrictions.md @@ -9,7 +9,9 @@ ```typescript getAggregationRestrictions(): RecordSignature: ```typescript -export interface IFieldType extends FieldBase +export interface IFieldType extends IndexPatternFieldBase ``` ## Properties diff --git a/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.indexpattern.getaggregationrestrictions.md b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.indexpattern.getaggregationrestrictions.md index b655e779e4fa4..70a3da86e9fbd 100644 --- a/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.indexpattern.getaggregationrestrictions.md +++ b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.indexpattern.getaggregationrestrictions.md @@ -9,7 +9,9 @@ ```typescript getAggregationRestrictions(): Record Date: Wed, 30 Jun 2021 10:10:09 +0100 Subject: [PATCH 10/10] comment --- src/plugins/data/common/es_query/es_query/types.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/plugins/data/common/es_query/es_query/types.ts b/src/plugins/data/common/es_query/es_query/types.ts index ef028e1aa9d4a..9282072cd444d 100644 --- a/src/plugins/data/common/es_query/es_query/types.ts +++ b/src/plugins/data/common/es_query/es_query/types.ts @@ -14,6 +14,9 @@ export interface IFieldSubType { } export interface IndexPatternFieldBase { name: string; + /** + * Kibana field type + */ type: string; subType?: IFieldSubType; /**