[Maps] replace IFieldType with IndexPatternField (#110245)
* [Maps] replace IFieldType with IndexPatternField * clean up imports * import from public Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
9e1a4dda42
commit
4cf722fb48
|
@ -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 {
|
||||
|
|
|
@ -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<string | number, unknown>;
|
||||
export type PropertiesMap = Map<string, BucketProperties>;
|
||||
|
||||
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 }
|
||||
: {
|
||||
|
|
|
@ -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<IFieldType | undefined> {
|
||||
async _getIndexPatternField(): Promise<IndexPatternField | undefined> {
|
||||
const indexPattern = await this._source.getIndexPattern();
|
||||
const indexPatternField = indexPattern.fields.getByName(this.getName());
|
||||
return indexPatternField && indexPatterns.isNestedField(indexPatternField)
|
||||
|
|
|
@ -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<EuiComboBoxOptionOption<string>>;
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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<Props, State> {
|
||||
|
|
|
@ -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<IField[]> {
|
||||
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,
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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<Props, State> {
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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'
|
||||
? {
|
||||
|
|
|
@ -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<IFieldType> {
|
||||
async _getGeoField(): Promise<IndexPatternField> {
|
||||
const indexPattern = await this.getIndexPattern();
|
||||
const geoField = indexPattern.fields.getByName(this.getGeoFieldName());
|
||||
if (!geoField) {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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<AGG_TYPE>) => boolean;
|
||||
|
|
|
@ -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<AGG_TYPE>) => boolean;
|
||||
}
|
||||
|
|
|
@ -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<EuiComboBoxOptionOption<IFieldType>> {
|
||||
fields?: IndexPatternField[],
|
||||
isFieldDisabled?: (field: IndexPatternField) => boolean
|
||||
): Array<EuiComboBoxOptionOption<IndexPatternField>> {
|
||||
if (!fields) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return fields
|
||||
.map((field) => {
|
||||
const option: EuiComboBoxOptionOption<IFieldType> = {
|
||||
const option: EuiComboBoxOptionOption<IndexPatternField> = {
|
||||
value: field,
|
||||
label: field.displayName ? field.displayName : field.name,
|
||||
};
|
||||
|
@ -45,14 +45,14 @@ function fieldsToOptions(
|
|||
}
|
||||
|
||||
type Props = Omit<
|
||||
EuiComboBoxProps<IFieldType>,
|
||||
EuiComboBoxProps<IndexPatternField>,
|
||||
'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<IFieldType>,
|
||||
option: EuiComboBoxOptionOption<IndexPatternField>,
|
||||
searchValue: string,
|
||||
contentClassName: string
|
||||
) {
|
||||
|
@ -91,13 +91,13 @@ export function SingleFieldSelect({
|
|||
);
|
||||
}
|
||||
|
||||
const onSelection = (selectedOptions: Array<EuiComboBoxOptionOption<IFieldType>>) => {
|
||||
const onSelection = (selectedOptions: Array<EuiComboBoxOptionOption<IndexPatternField>>) => {
|
||||
onChange(_.get(selectedOptions, '0.value.name'));
|
||||
};
|
||||
|
||||
const selectedOptions: Array<EuiComboBoxOptionOption<IFieldType>> = [];
|
||||
const selectedOptions: Array<EuiComboBoxOptionOption<IndexPatternField>> = [];
|
||||
if (value && fields) {
|
||||
const selectedField = fields.find((field: IFieldType) => {
|
||||
const selectedField = fields.find((field: IndexPatternField) => {
|
||||
return field.name === value;
|
||||
});
|
||||
if (selectedField) {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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,
|
||||
},
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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!
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue