diff --git a/x-pack/plugins/maps/common/constants.ts b/x-pack/plugins/maps/common/constants.ts index 1e49c61d29d91..5cfed7d6a58b5 100644 --- a/x-pack/plugins/maps/common/constants.ts +++ b/x-pack/plugins/maps/common/constants.ts @@ -130,7 +130,7 @@ export enum ES_GEO_FIELD_TYPE { GEO_SHAPE = 'geo_shape', } -// Using strings instead of ES_GEO_FIELD_TYPE enum to avoid typeing errors where IFieldType.type is compared to value +// Using strings instead of ES_GEO_FIELD_TYPE enum to avoid typeing errors where IndexPatternField.type is compared to value export const ES_GEO_FIELD_TYPES = ['geo_point', 'geo_shape']; export enum ES_SPATIAL_RELATIONS { diff --git a/x-pack/plugins/maps/common/elasticsearch_util/es_agg_utils.ts b/x-pack/plugins/maps/common/elasticsearch_util/es_agg_utils.ts index cae5f6ee9f41a..55600ca307ff2 100644 --- a/x-pack/plugins/maps/common/elasticsearch_util/es_agg_utils.ts +++ b/x-pack/plugins/maps/common/elasticsearch_util/es_agg_utils.ts @@ -7,13 +7,13 @@ import { i18n } from '@kbn/i18n'; import _ from 'lodash'; -import { IndexPattern, IFieldType } from '../../../../../src/plugins/data/common'; +import type { IndexPattern, IndexPatternField } from 'src/plugins/data/common'; import { AGG_TYPE, JOIN_FIELD_NAME_PREFIX, TOP_TERM_PERCENTAGE_SUFFIX } from '../constants'; export type BucketProperties = Record; export type PropertiesMap = Map; -export function getField(indexPattern: IndexPattern, fieldName: string): IFieldType { +export function getField(indexPattern: IndexPattern, fieldName: string): IndexPatternField { const field = indexPattern.fields.getByName(fieldName); if (!field) { throw new Error( @@ -26,7 +26,7 @@ export function getField(indexPattern: IndexPattern, fieldName: string): IFieldT return field; } -export function addFieldToDSL(dsl: object, field: IFieldType) { +export function addFieldToDSL(dsl: object, field: IndexPatternField) { return !field.scripted ? { ...dsl, field: field.name } : { diff --git a/x-pack/plugins/maps/public/classes/fields/es_doc_field.ts b/x-pack/plugins/maps/public/classes/fields/es_doc_field.ts index abdcf65a4ab1d..afddb34d2d0ec 100644 --- a/x-pack/plugins/maps/public/classes/fields/es_doc_field.ts +++ b/x-pack/plugins/maps/public/classes/fields/es_doc_field.ts @@ -5,11 +5,11 @@ * 2.0. */ +import type { IndexPatternField } from 'src/plugins/data/public'; import { FIELD_ORIGIN } from '../../../common/constants'; import { ESTooltipProperty } from '../tooltips/es_tooltip_property'; import { ITooltipProperty, TooltipProperty } from '../tooltips/tooltip_property'; import { indexPatterns } from '../../../../../../src/plugins/data/public'; -import { IFieldType } from '../../../../../../src/plugins/data/public'; import { IField, AbstractField } from './field'; import { IESSource } from '../sources/es_source'; import { IVectorSource } from '../sources/vector_source'; @@ -42,7 +42,7 @@ export class ESDocField extends AbstractField implements IField { return this._source; } - async _getIndexPatternField(): Promise { + async _getIndexPatternField(): Promise { const indexPattern = await this._source.getIndexPattern(); const indexPatternField = indexPattern.fields.getByName(this.getName()); return indexPatternField && indexPatterns.isNestedField(indexPatternField) diff --git a/x-pack/plugins/maps/public/classes/layers/choropleth_layer_wizard/layer_template.tsx b/x-pack/plugins/maps/public/classes/layers/choropleth_layer_wizard/layer_template.tsx index 82a741e7ccdab..5bd2b68e61bc4 100644 --- a/x-pack/plugins/maps/public/classes/layers/choropleth_layer_wizard/layer_template.tsx +++ b/x-pack/plugins/maps/public/classes/layers/choropleth_layer_wizard/layer_template.tsx @@ -18,7 +18,7 @@ import { EuiSpacer, EuiTitle, } from '@elastic/eui'; -import { IFieldType, IndexPattern } from 'src/plugins/data/public'; +import { IndexPatternField, IndexPattern } from 'src/plugins/data/public'; import { RenderWizardArguments } from '../layer_wizard_registry'; import { EMSFileSelect } from '../../../components/ems_file_select'; import { GeoIndexPatternSelect } from '../../../components/geo_index_pattern_select'; @@ -56,14 +56,14 @@ interface State { leftEmsFileId: string | null; leftEmsFields: Array>; leftIndexPattern: IndexPattern | null; - leftGeoFields: IFieldType[]; - leftJoinFields: IFieldType[]; + leftGeoFields: IndexPatternField[]; + leftJoinFields: IndexPatternField[]; leftGeoField: string | null; leftEmsJoinField: string | null; leftElasticsearchJoinField: string | null; rightIndexPatternId: string; rightIndexPatternTitle: string | null; - rightTermsFields: IFieldType[]; + rightTermsFields: IndexPatternField[]; rightJoinField: string | null; } diff --git a/x-pack/plugins/maps/public/classes/sources/es_geo_line_source/update_source_editor.tsx b/x-pack/plugins/maps/public/classes/sources/es_geo_line_source/update_source_editor.tsx index 2688ef1d29686..66f3efe992f88 100644 --- a/x-pack/plugins/maps/public/classes/sources/es_geo_line_source/update_source_editor.tsx +++ b/x-pack/plugins/maps/public/classes/sources/es_geo_line_source/update_source_editor.tsx @@ -9,11 +9,8 @@ import React, { Fragment, Component } from 'react'; import { FormattedMessage } from '@kbn/i18n/react'; import { EuiPanel, EuiSpacer, EuiTitle } from '@elastic/eui'; -import { - IFieldType, - IndexPattern, - indexPatterns, -} from '../../../../../../../src/plugins/data/public'; +import type { IndexPatternField, IndexPattern } from 'src/plugins/data/public'; +import { indexPatterns } from '../../../../../../../src/plugins/data/public'; import { MetricsEditor } from '../../../components/metrics_editor'; import { getIndexPatternService } from '../../../kibana_services'; import { GeoLineForm } from './geo_line_form'; @@ -30,7 +27,7 @@ interface Props { interface State { indexPattern: IndexPattern | null; - fields: IFieldType[]; + fields: IndexPatternField[]; } export class UpdateSourceEditor extends Component { diff --git a/x-pack/plugins/maps/public/classes/sources/es_search_source/es_search_source.tsx b/x-pack/plugins/maps/public/classes/sources/es_search_source/es_search_source.tsx index 464ba024663ec..93362a1721ce5 100644 --- a/x-pack/plugins/maps/public/classes/sources/es_search_source/es_search_source.tsx +++ b/x-pack/plugins/maps/public/classes/sources/es_search_source/es_search_source.tsx @@ -9,7 +9,7 @@ import _ from 'lodash'; import React, { ReactElement } from 'react'; import rison from 'rison-node'; import { i18n } from '@kbn/i18n'; -import type { Filter, IFieldType, IndexPattern } from 'src/plugins/data/public'; +import type { Filter, IndexPatternField, IndexPattern } from 'src/plugins/data/public'; import { GeoJsonProperties, Geometry, Position } from 'geojson'; import { esFilters } from '../../../../../../../src/plugins/data/public'; import { AbstractESSource } from '../es_source'; @@ -183,7 +183,7 @@ export class ESSearchSource extends AbstractESSource implements ITiledSingleLaye async getFields(): Promise { try { const indexPattern = await this.getIndexPattern(); - const fields: IFieldType[] = indexPattern.fields.filter((field) => { + const fields: IndexPatternField[] = indexPattern.fields.filter((field) => { // Ensure fielddata is enabled for field. // Search does not request _source return field.aggregatable; @@ -300,7 +300,7 @@ export class ESSearchSource extends AbstractESSource implements ITiledSingleLaye }; } - const topHitsSplitField: IFieldType = getField(indexPattern, topHitsSplitFieldName); + const topHitsSplitField: IndexPatternField = getField(indexPattern, topHitsSplitFieldName); const cardinalityAgg = { precision_threshold: 1 }; const termsAgg = { size: DEFAULT_MAX_BUCKETS_LIMIT, diff --git a/x-pack/plugins/maps/public/classes/sources/es_search_source/top_hits/create_source_editor.tsx b/x-pack/plugins/maps/public/classes/sources/es_search_source/top_hits/create_source_editor.tsx index 41c9076c11436..e71ee803d77e6 100644 --- a/x-pack/plugins/maps/public/classes/sources/es_search_source/top_hits/create_source_editor.tsx +++ b/x-pack/plugins/maps/public/classes/sources/es_search_source/top_hits/create_source_editor.tsx @@ -8,16 +8,13 @@ import React, { Component } from 'react'; import { EuiPanel } from '@elastic/eui'; +import type { IndexPattern, IndexPatternField } from 'src/plugins/data/public'; import { SCALING_TYPES } from '../../../../../common/constants'; import { GeoFieldSelect } from '../../../../components/geo_field_select'; import { GeoIndexPatternSelect } from '../../../../components/geo_index_pattern_select'; import { getGeoFields, getTermsFields, getSortFields } from '../../../../index_pattern_util'; import { ESSearchSourceDescriptor } from '../../../../../common/descriptor_types'; -import { - IndexPattern, - IFieldType, - SortDirection, -} from '../../../../../../../../src/plugins/data/common'; +import { SortDirection } from '../../../../../../../../src/plugins/data/public'; import { TopHitsForm } from './top_hits_form'; import { OnSourceChangeArgs } from '../../source'; @@ -27,12 +24,12 @@ interface Props { interface State { indexPattern: IndexPattern | null; - geoFields: IFieldType[]; + geoFields: IndexPatternField[]; geoFieldName: string | null; sortField: string | null; - sortFields: IFieldType[]; + sortFields: IndexPatternField[]; sortOrder: SortDirection; - termFields: IFieldType[]; + termFields: IndexPatternField[]; topHitsSplitField: string | null; topHitsSize: number; } diff --git a/x-pack/plugins/maps/public/classes/sources/es_search_source/top_hits/top_hits_form.tsx b/x-pack/plugins/maps/public/classes/sources/es_search_source/top_hits/top_hits_form.tsx index 79d6039076f81..072c399544182 100644 --- a/x-pack/plugins/maps/public/classes/sources/es_search_source/top_hits/top_hits_form.tsx +++ b/x-pack/plugins/maps/public/classes/sources/es_search_source/top_hits/top_hits_form.tsx @@ -8,6 +8,7 @@ import React, { ChangeEvent, Component, Fragment } from 'react'; import { EuiFormRow, EuiSelect } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; +import type { IndexPatternField } from 'src/plugins/data/public'; import { SingleFieldSelect } from '../../../../components/single_field_select'; import { getIndexPatternService } from '../../../../kibana_services'; // @ts-expect-error @@ -15,16 +16,16 @@ import { ValidatedRange } from '../../../../components/validated_range'; import { DEFAULT_MAX_INNER_RESULT_WINDOW } from '../../../../../common/constants'; import { loadIndexSettings } from '../util/load_index_settings'; import { OnSourceChangeArgs } from '../../source'; -import { IFieldType, SortDirection } from '../../../../../../../../src/plugins/data/public'; +import { SortDirection } from '../../../../../../../../src/plugins/data/public'; interface Props { indexPatternId: string; isColumnCompressed?: boolean; onChange: (args: OnSourceChangeArgs) => void; sortField: string; - sortFields: IFieldType[]; + sortFields: IndexPatternField[]; sortOrder: SortDirection; - termFields: IFieldType[]; + termFields: IndexPatternField[]; topHitsSplitField: string | null; topHitsSize: number; } diff --git a/x-pack/plugins/maps/public/classes/sources/es_search_source/top_hits/update_source_editor.tsx b/x-pack/plugins/maps/public/classes/sources/es_search_source/top_hits/update_source_editor.tsx index 6ca38f3be22f4..33f0d3c1d9840 100644 --- a/x-pack/plugins/maps/public/classes/sources/es_search_source/top_hits/update_source_editor.tsx +++ b/x-pack/plugins/maps/public/classes/sources/es_search_source/top_hits/update_source_editor.tsx @@ -9,12 +9,13 @@ import React, { Component, Fragment } from 'react'; import { EuiFormRow, EuiTitle, EuiPanel, EuiSpacer, EuiSwitch, EuiSwitchEvent } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; +import type { IndexPatternField } from 'src/plugins/data/public'; import { FIELD_ORIGIN } from '../../../../../common/constants'; import { TooltipSelector } from '../../../../components/tooltip_selector'; import { getIndexPatternService } from '../../../../kibana_services'; import { getTermsFields, getSortFields, getSourceFields } from '../../../../index_pattern_util'; -import { SortDirection, IFieldType } from '../../../../../../../../src/plugins/data/public'; +import { SortDirection } from '../../../../../../../../src/plugins/data/public'; import { ESDocField } from '../../../fields/es_doc_field'; import { OnSourceChangeArgs } from '../../source'; import { TopHitsForm } from './top_hits_form'; @@ -36,8 +37,8 @@ interface Props { interface State { loadError?: string; sourceFields: IField[]; - termFields: IFieldType[]; - sortFields: IFieldType[]; + termFields: IndexPatternField[]; + sortFields: IndexPatternField[]; } export class TopHitsUpdateSourceEditor extends Component { diff --git a/x-pack/plugins/maps/public/classes/sources/es_search_source/util/get_docvalue_source_fields.test.ts b/x-pack/plugins/maps/public/classes/sources/es_search_source/util/get_docvalue_source_fields.test.ts index 0a24c140d735f..a4429c663da84 100644 --- a/x-pack/plugins/maps/public/classes/sources/es_search_source/util/get_docvalue_source_fields.test.ts +++ b/x-pack/plugins/maps/public/classes/sources/es_search_source/util/get_docvalue_source_fields.test.ts @@ -6,10 +6,9 @@ */ import { getDocValueAndSourceFields } from './get_docvalue_source_fields'; -import { IndexPattern } from '../../../../../../../../src/plugins/data/common/index_patterns/index_patterns'; -import { IFieldType } from '../../../../../../../../src/plugins/data/common/index_patterns/fields'; +import type { IndexPatternField, IndexPattern } from 'src/plugins/data/public'; -function createMockIndexPattern(fields: IFieldType[]): IndexPattern { +function createMockIndexPattern(fields: IndexPatternField[]): IndexPattern { const indexPattern = { get fields() { return { @@ -29,9 +28,8 @@ describe('getDocValueAndSourceFields', () => { createMockIndexPattern([ { name: 'foobar', - // @ts-expect-error runtimeField not added yet to IFieldType. API tbd - runtimeField: {}, - }, + runtimeField: { type: 'keyword' }, + } as IndexPatternField, ]), ['foobar'], 'epoch_millis' diff --git a/x-pack/plugins/maps/public/classes/sources/es_search_source/util/get_docvalue_source_fields.ts b/x-pack/plugins/maps/public/classes/sources/es_search_source/util/get_docvalue_source_fields.ts index 78823f4631cac..949dc990c44fe 100644 --- a/x-pack/plugins/maps/public/classes/sources/es_search_source/util/get_docvalue_source_fields.ts +++ b/x-pack/plugins/maps/public/classes/sources/es_search_source/util/get_docvalue_source_fields.ts @@ -34,9 +34,7 @@ export function getDocValueAndSourceFields( lang: field.lang || '', }, }; - } - // @ts-expect-error runtimeField has not been added to public API yet. exact shape of type TBD. - else if (field.readFromDocValues || field.runtimeField) { + } else if (field.readFromDocValues || field.runtimeField) { const docValueField = field.type === 'date' ? { diff --git a/x-pack/plugins/maps/public/classes/sources/es_source/es_source.ts b/x-pack/plugins/maps/public/classes/sources/es_source/es_source.ts index 23bcd9baed8c0..ce8991bb63ce6 100644 --- a/x-pack/plugins/maps/public/classes/sources/es_source/es_source.ts +++ b/x-pack/plugins/maps/public/classes/sources/es_source/es_source.ts @@ -7,7 +7,7 @@ import { i18n } from '@kbn/i18n'; import uuid from 'uuid/v4'; -import { Filter, IFieldType, IndexPattern, ISearchSource } from 'src/plugins/data/public'; +import { Filter, IndexPatternField, IndexPattern, ISearchSource } from 'src/plugins/data/public'; import { AbstractVectorSource, BoundsFilters } from '../vector_source'; import { getAutocompleteService, @@ -364,7 +364,7 @@ export class AbstractESSource extends AbstractVectorSource implements IESSource } } - async _getGeoField(): Promise { + async _getGeoField(): Promise { const indexPattern = await this.getIndexPattern(); const geoField = indexPattern.fields.getByName(this.getGeoFieldName()); if (!geoField) { diff --git a/x-pack/plugins/maps/public/classes/tooltips/es_tooltip_property.test.ts b/x-pack/plugins/maps/public/classes/tooltips/es_tooltip_property.test.ts index fbb416e7a7619..b9021f1896550 100644 --- a/x-pack/plugins/maps/public/classes/tooltips/es_tooltip_property.test.ts +++ b/x-pack/plugins/maps/public/classes/tooltips/es_tooltip_property.test.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { IFieldType, IndexPattern } from '../../../../../../src/plugins/data/public'; +import type { IndexPatternField, IndexPattern } from 'src/plugins/data/public'; import { ESTooltipProperty } from './es_tooltip_property'; import { TooltipProperty } from './tooltip_property'; import { AbstractField } from '../fields/field'; @@ -25,7 +25,7 @@ const indexPatternField = { searchable: true, aggregatable: true, readFromDocValues: false, -} as IFieldType; +} as IndexPatternField; const featurePropertyField = new MockField({ fieldName: 'machine.os', @@ -41,7 +41,7 @@ const nonFilterableIndexPatternField = { searchable: true, aggregatable: true, readFromDocValues: false, -} as IFieldType; +} as IndexPatternField; const nonFilterableFeaturePropertyField = new MockField({ fieldName: 'location', @@ -51,7 +51,7 @@ const nonFilterableFeaturePropertyField = new MockField({ const indexPattern = { id: 'indexPatternId', fields: { - getByName: (name: string): IFieldType | null => { + getByName: (name: string): IndexPatternField | null => { if (name === 'machine.os') { return indexPatternField; } diff --git a/x-pack/plugins/maps/public/components/geo_field_select.tsx b/x-pack/plugins/maps/public/components/geo_field_select.tsx index 0b04ec7146611..5ee81866784bc 100644 --- a/x-pack/plugins/maps/public/components/geo_field_select.tsx +++ b/x-pack/plugins/maps/public/components/geo_field_select.tsx @@ -8,12 +8,12 @@ import React from 'react'; import { i18n } from '@kbn/i18n'; import { EuiFormRow } from '@elastic/eui'; +import type { IndexPatternField } from 'src/plugins/data/public'; import { SingleFieldSelect } from './single_field_select'; -import { IFieldType } from '../../../../../src/plugins/data/common'; interface Props { value: string; - geoFields: IFieldType[]; + geoFields: IndexPatternField[]; onChange: (geoFieldName?: string) => void; } diff --git a/x-pack/plugins/maps/public/components/metrics_editor/metric_editor.tsx b/x-pack/plugins/maps/public/components/metrics_editor/metric_editor.tsx index b72a8d01d4a93..c3782d9be73d2 100644 --- a/x-pack/plugins/maps/public/components/metrics_editor/metric_editor.tsx +++ b/x-pack/plugins/maps/public/components/metrics_editor/metric_editor.tsx @@ -11,15 +11,15 @@ import { i18n } from '@kbn/i18n'; import { EuiButtonEmpty, EuiComboBoxOptionOption, EuiFieldText, EuiFormRow } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n/react'; +import type { IndexPatternField } from 'src/plugins/data/public'; import { MetricSelect } from './metric_select'; import { SingleFieldSelect } from '../single_field_select'; import { AggDescriptor } from '../../../common/descriptor_types'; import { AGG_TYPE, DEFAULT_PERCENTILE } from '../../../common/constants'; import { getTermsFields } from '../../index_pattern_util'; -import { IFieldType } from '../../../../../../src/plugins/data/public'; import { ValidatedNumberInput } from '../validated_number_input'; -function filterFieldsForAgg(fields: IFieldType[], aggType: AGG_TYPE) { +function filterFieldsForAgg(fields: IndexPatternField[], aggType: AGG_TYPE) { if (!fields) { return []; } @@ -40,7 +40,7 @@ function filterFieldsForAgg(fields: IFieldType[], aggType: AGG_TYPE) { interface Props { metric: AggDescriptor; - fields: IFieldType[]; + fields: IndexPatternField[]; onChange: (metric: AggDescriptor) => void; onRemove: () => void; metricsFilter?: (metricOption: EuiComboBoxOptionOption) => boolean; diff --git a/x-pack/plugins/maps/public/components/metrics_editor/metrics_editor.tsx b/x-pack/plugins/maps/public/components/metrics_editor/metrics_editor.tsx index 2124345e7e03c..17baa7eb355d6 100644 --- a/x-pack/plugins/maps/public/components/metrics_editor/metrics_editor.tsx +++ b/x-pack/plugins/maps/public/components/metrics_editor/metrics_editor.tsx @@ -8,9 +8,9 @@ import React, { Component, Fragment } from 'react'; import { FormattedMessage } from '@kbn/i18n/react'; import { EuiButtonEmpty, EuiComboBoxOptionOption, EuiSpacer, EuiTextAlign } from '@elastic/eui'; +import type { IndexPatternField } from 'src/plugins/data/public'; import { MetricEditor } from './metric_editor'; import { DEFAULT_METRIC } from '../../classes/sources/es_agg_source'; -import { IFieldType } from '../../../../../../src/plugins/data/public'; import { AggDescriptor, FieldedAggDescriptor } from '../../../common/descriptor_types'; import { AGG_TYPE } from '../../../common/constants'; @@ -23,7 +23,7 @@ export function isMetricValid(aggDescriptor: AggDescriptor) { interface Props { allowMultipleMetrics: boolean; metrics: AggDescriptor[]; - fields: IFieldType[]; + fields: IndexPatternField[]; onChange: (metrics: AggDescriptor[]) => void; metricsFilter?: (metricOption: EuiComboBoxOptionOption) => boolean; } diff --git a/x-pack/plugins/maps/public/components/single_field_select.tsx b/x-pack/plugins/maps/public/components/single_field_select.tsx index 6727de35b1be7..67594db11eb37 100644 --- a/x-pack/plugins/maps/public/components/single_field_select.tsx +++ b/x-pack/plugins/maps/public/components/single_field_select.tsx @@ -17,20 +17,20 @@ import { EuiFlexItem, EuiToolTip, } from '@elastic/eui'; -import { IFieldType } from 'src/plugins/data/public'; +import { IndexPatternField } from 'src/plugins/data/public'; import { FieldIcon } from '../../../../../src/plugins/kibana_react/public'; function fieldsToOptions( - fields?: IFieldType[], - isFieldDisabled?: (field: IFieldType) => boolean -): Array> { + fields?: IndexPatternField[], + isFieldDisabled?: (field: IndexPatternField) => boolean +): Array> { if (!fields) { return []; } return fields .map((field) => { - const option: EuiComboBoxOptionOption = { + const option: EuiComboBoxOptionOption = { value: field, label: field.displayName ? field.displayName : field.name, }; @@ -45,14 +45,14 @@ function fieldsToOptions( } type Props = Omit< - EuiComboBoxProps, + EuiComboBoxProps, 'isDisabled' | 'onChange' | 'options' | 'renderOption' | 'selectedOptions' | 'singleSelection' > & { - fields?: IFieldType[]; + fields?: IndexPatternField[]; onChange: (fieldName?: string) => void; value: string | null; // index pattern field name - isFieldDisabled?: (field: IFieldType) => boolean; - getFieldDisabledReason?: (field: IFieldType) => string | null; + isFieldDisabled?: (field: IndexPatternField) => boolean; + getFieldDisabledReason?: (field: IndexPatternField) => string | null; }; export function SingleFieldSelect({ @@ -64,7 +64,7 @@ export function SingleFieldSelect({ ...rest }: Props) { function renderOption( - option: EuiComboBoxOptionOption, + option: EuiComboBoxOptionOption, searchValue: string, contentClassName: string ) { @@ -91,13 +91,13 @@ export function SingleFieldSelect({ ); } - const onSelection = (selectedOptions: Array>) => { + const onSelection = (selectedOptions: Array>) => { onChange(_.get(selectedOptions, '0.value.name')); }; - const selectedOptions: Array> = []; + const selectedOptions: Array> = []; if (value && fields) { - const selectedField = fields.find((field: IFieldType) => { + const selectedField = fields.find((field: IndexPatternField) => { return field.name === value; }); if (selectedField) { diff --git a/x-pack/plugins/maps/public/connected_components/edit_layer_panel/join_editor/resources/join.tsx b/x-pack/plugins/maps/public/connected_components/edit_layer_panel/join_editor/resources/join.tsx index 6962977627b98..c636047e2be37 100644 --- a/x-pack/plugins/maps/public/connected_components/edit_layer_panel/join_editor/resources/join.tsx +++ b/x-pack/plugins/maps/public/connected_components/edit_layer_panel/join_editor/resources/join.tsx @@ -9,7 +9,7 @@ import _ from 'lodash'; import React, { Component } from 'react'; import { EuiFlexItem, EuiFlexGroup, EuiButtonIcon } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; -import type { IFieldType, IndexPattern, Query } from 'src/plugins/data/public'; +import type { IndexPatternField, IndexPattern, Query } from 'src/plugins/data/public'; import { JoinExpression } from './join_expression'; import { MetricsExpression } from './metrics_expression'; import { WhereExpression } from './where_expression'; @@ -38,7 +38,7 @@ interface Props { } interface State { - rightFields: IFieldType[]; + rightFields: IndexPatternField[]; indexPattern?: IndexPattern; loadError?: string; } diff --git a/x-pack/plugins/maps/public/connected_components/edit_layer_panel/join_editor/resources/join_expression.tsx b/x-pack/plugins/maps/public/connected_components/edit_layer_panel/join_editor/resources/join_expression.tsx index f2073a9f6e650..19a47736b1958 100644 --- a/x-pack/plugins/maps/public/connected_components/edit_layer_panel/join_editor/resources/join_expression.tsx +++ b/x-pack/plugins/maps/public/connected_components/edit_layer_panel/join_editor/resources/join_expression.tsx @@ -18,7 +18,7 @@ import { } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; -import { IFieldType } from 'src/plugins/data/public'; +import { IndexPatternField } from 'src/plugins/data/public'; import { FormattedMessage } from '@kbn/i18n/react'; import { DEFAULT_MAX_BUCKETS_LIMIT } from '../../../../../common/constants'; import { SingleFieldSelect } from '../../../../components/single_field_select'; @@ -54,7 +54,7 @@ interface Props { // Right field props rightValue: string; rightSize?: number; - rightFields: IFieldType[]; + rightFields: IndexPatternField[]; onRightFieldChange: (term?: string) => void; onRightSizeChange: (size: number) => void; } diff --git a/x-pack/plugins/maps/public/connected_components/edit_layer_panel/join_editor/resources/metrics_expression.tsx b/x-pack/plugins/maps/public/connected_components/edit_layer_panel/join_editor/resources/metrics_expression.tsx index 899430f3c2f2d..4c2e96498ee20 100644 --- a/x-pack/plugins/maps/public/connected_components/edit_layer_panel/join_editor/resources/metrics_expression.tsx +++ b/x-pack/plugins/maps/public/connected_components/edit_layer_panel/join_editor/resources/metrics_expression.tsx @@ -15,7 +15,7 @@ import { EuiFormHelpText, } from '@elastic/eui'; -import { IFieldType } from 'src/plugins/data/public'; +import { IndexPatternField } from 'src/plugins/data/public'; import { FormattedMessage } from '@kbn/i18n/react'; import { MetricsEditor } from '../../../../components/metrics_editor'; import { AGG_TYPE } from '../../../../../common/constants'; @@ -23,7 +23,7 @@ import { AggDescriptor, FieldedAggDescriptor } from '../../../../../common/descr interface Props { metrics: AggDescriptor[]; - rightFields: IFieldType[]; + rightFields: IndexPatternField[]; onChange: (metrics: AggDescriptor[]) => void; } diff --git a/x-pack/plugins/maps/public/index_pattern_util.test.ts b/x-pack/plugins/maps/public/index_pattern_util.test.ts index 49ae16415e159..d1affe6ce4d85 100644 --- a/x-pack/plugins/maps/public/index_pattern_util.test.ts +++ b/x-pack/plugins/maps/public/index_pattern_util.test.ts @@ -14,6 +14,7 @@ import { supportsGeoTileAgg, } from './index_pattern_util'; import { ES_GEO_FIELD_TYPE } from '../common/constants'; +import { IndexPatternField } from 'src/plugins/data/public'; describe('getSourceFields', () => { test('Should remove multi fields from field list', () => { @@ -21,7 +22,7 @@ describe('getSourceFields', () => { { name: 'agent', type: 'string', - }, + } as IndexPatternField, { name: 'agent.keyword', subType: { @@ -30,7 +31,7 @@ describe('getSourceFields', () => { }, }, type: 'string', - }, + } as IndexPatternField, ]; const sourceFields = getSourceFields(fields); expect(sourceFields).toEqual([{ name: 'agent', type: 'string' }]); @@ -44,7 +45,7 @@ describe('Gold+ licensing', () => { name: 'location', type: 'geo_point', aggregatable: true, - }, + } as IndexPatternField, supportedInBasic: true, supportedInGold: true, }, @@ -53,7 +54,7 @@ describe('Gold+ licensing', () => { name: 'location', type: 'geo_shape', aggregatable: false, - }, + } as IndexPatternField, supportedInBasic: false, supportedInGold: false, }, @@ -62,7 +63,7 @@ describe('Gold+ licensing', () => { name: 'location', type: 'geo_shape', aggregatable: true, - }, + } as IndexPatternField, supportedInBasic: false, supportedInGold: true, }, diff --git a/x-pack/plugins/maps/public/index_pattern_util.ts b/x-pack/plugins/maps/public/index_pattern_util.ts index 3b1cb461c8779..a2133f4f2521b 100644 --- a/x-pack/plugins/maps/public/index_pattern_util.ts +++ b/x-pack/plugins/maps/public/index_pattern_util.ts @@ -5,14 +5,14 @@ * 2.0. */ -import { IFieldType, IndexPattern } from 'src/plugins/data/public'; +import type { IndexPatternField, IndexPattern } from 'src/plugins/data/public'; import { i18n } from '@kbn/i18n'; import { getIndexPatternService } from './kibana_services'; import { indexPatterns } from '../../../../src/plugins/data/public'; import { ES_GEO_FIELD_TYPE, ES_GEO_FIELD_TYPES } from '../common/constants'; import { getIsGoldPlus } from './licensed_features'; -export function getGeoTileAggNotSupportedReason(field: IFieldType): string | null { +export function getGeoTileAggNotSupportedReason(field: IndexPatternField): string | null { if (!field.aggregatable) { return i18n.translate('xpack.maps.geoTileAgg.disabled.docValues', { defaultMessage: @@ -46,7 +46,7 @@ export async function getIndexPatternsFromIds( return await Promise.all(promises); } -export function getTermsFields(fields: IFieldType[]): IFieldType[] { +export function getTermsFields(fields: IndexPatternField[]): IndexPatternField[] { return fields.filter((field) => { return ( field.aggregatable && @@ -56,7 +56,7 @@ export function getTermsFields(fields: IFieldType[]): IFieldType[] { }); } -export function getSortFields(fields: IFieldType[]): IFieldType[] { +export function getSortFields(fields: IndexPatternField[]): IndexPatternField[] { return fields.filter((field) => { return field.sortable && !indexPatterns.isNestedField(field); }); @@ -70,23 +70,23 @@ export function getAggregatableGeoFieldTypes(): string[] { return aggregatableFieldTypes; } -export function getGeoFields(fields: IFieldType[]): IFieldType[] { +export function getGeoFields(fields: IndexPatternField[]): IndexPatternField[] { return fields.filter((field) => { return !indexPatterns.isNestedField(field) && ES_GEO_FIELD_TYPES.includes(field.type); }); } -export function getGeoPointFields(fields: IFieldType[]): IFieldType[] { +export function getGeoPointFields(fields: IndexPatternField[]): IndexPatternField[] { return fields.filter((field) => { return !indexPatterns.isNestedField(field) && ES_GEO_FIELD_TYPE.GEO_POINT === field.type; }); } -export function getFieldsWithGeoTileAgg(fields: IFieldType[]): IFieldType[] { +export function getFieldsWithGeoTileAgg(fields: IndexPatternField[]): IndexPatternField[] { return fields.filter(supportsGeoTileAgg); } -export function supportsGeoTileAgg(field?: IFieldType): boolean { +export function supportsGeoTileAgg(field?: IndexPatternField): boolean { return ( !!field && !!field.aggregatable && @@ -95,7 +95,7 @@ export function supportsGeoTileAgg(field?: IFieldType): boolean { ); } -export function getSourceFields(fields: IFieldType[]): IFieldType[] { +export function getSourceFields(fields: IndexPatternField[]): IndexPatternField[] { return fields.filter((field) => { // Multi fields are not stored in _source and only exist in index. const isMultiField = field.subType && field.subType.multi; diff --git a/x-pack/plugins/maps/server/maps_telemetry/maps_telemetry.ts b/x-pack/plugins/maps/server/maps_telemetry/maps_telemetry.ts index b345c427b50b9..5041cb997ff58 100644 --- a/x-pack/plugins/maps/server/maps_telemetry/maps_telemetry.ts +++ b/x-pack/plugins/maps/server/maps_telemetry/maps_telemetry.ts @@ -7,7 +7,7 @@ import _ from 'lodash'; import { SavedObject } from 'kibana/server'; -import { IFieldType } from 'src/plugins/data/public'; +import type { IndexPatternField } from 'src/plugins/data/public'; import { ES_GEO_FIELD_TYPE, LAYER_TYPE, @@ -136,7 +136,8 @@ async function isFieldGeoShape( return false; } return indexPattern.fields.some( - (fieldDescriptor: IFieldType) => fieldDescriptor.name && fieldDescriptor.name === geoField! + (fieldDescriptor: IndexPatternField) => + fieldDescriptor.name && fieldDescriptor.name === geoField! ); }