mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 09:19:04 -04:00
[dataViews] no more IndexPatternBase, IndexPatternFieldBase (#121836)
* remove IndexPatternFieldBase and IndexPatternBase references
This commit is contained in:
parent
f7dee0088f
commit
d4fdd35543
59 changed files with 209 additions and 228 deletions
|
@ -12,7 +12,7 @@ import { buildQueryFromKuery } from './from_kuery';
|
|||
import { buildQueryFromFilters } from './from_filters';
|
||||
import { buildQueryFromLucene } from './from_lucene';
|
||||
import { Filter, Query } from '../filters';
|
||||
import { BoolQuery, IndexPatternBase } from './types';
|
||||
import { BoolQuery, DataViewBase } from './types';
|
||||
import { KueryQueryOptions } from '../kuery';
|
||||
|
||||
/**
|
||||
|
@ -42,7 +42,7 @@ function removeMatchAll<T>(filters: T[]) {
|
|||
* @public
|
||||
*/
|
||||
export function buildEsQuery(
|
||||
indexPattern: IndexPatternBase | undefined,
|
||||
indexPattern: DataViewBase | undefined,
|
||||
queries: Query | Query[],
|
||||
filters: Filter | Filter[],
|
||||
config: EsQueryConfig = {
|
||||
|
|
|
@ -8,12 +8,12 @@
|
|||
|
||||
import { Filter } from '../filters';
|
||||
import { filterMatchesIndex } from './filter_matches_index';
|
||||
import { IndexPatternBase } from './types';
|
||||
import { DataViewBase } from './types';
|
||||
|
||||
describe('filterMatchesIndex', () => {
|
||||
it('should return true if the filter has no meta', () => {
|
||||
const filter = {} as Filter;
|
||||
const indexPattern = { id: 'foo', fields: [{ name: 'bar' }] } as IndexPatternBase;
|
||||
const indexPattern = { id: 'foo', fields: [{ name: 'bar' }] } as DataViewBase;
|
||||
|
||||
expect(filterMatchesIndex(filter, indexPattern)).toBe(true);
|
||||
});
|
||||
|
@ -26,35 +26,35 @@ describe('filterMatchesIndex', () => {
|
|||
|
||||
it('should return true if the filter key matches a field name', () => {
|
||||
const filter = { meta: { index: 'foo', key: 'bar' } } as Filter;
|
||||
const indexPattern = { id: 'foo', fields: [{ name: 'bar' }] } as IndexPatternBase;
|
||||
const indexPattern = { id: 'foo', fields: [{ name: 'bar' }] } as DataViewBase;
|
||||
|
||||
expect(filterMatchesIndex(filter, indexPattern)).toBe(true);
|
||||
});
|
||||
|
||||
it('should return true if custom filter for the same index is passed', () => {
|
||||
const filter = { meta: { index: 'foo', key: 'bar', type: 'custom' } } as Filter;
|
||||
const indexPattern = { id: 'foo', fields: [{ name: 'bara' }] } as IndexPatternBase;
|
||||
const indexPattern = { id: 'foo', fields: [{ name: 'bara' }] } as DataViewBase;
|
||||
|
||||
expect(filterMatchesIndex(filter, indexPattern)).toBe(true);
|
||||
});
|
||||
|
||||
it('should return false if custom filter for a different index is passed', () => {
|
||||
const filter = { meta: { index: 'foo', key: 'bar', type: 'custom' } } as Filter;
|
||||
const indexPattern = { id: 'food', fields: [{ name: 'bara' }] } as IndexPatternBase;
|
||||
const indexPattern = { id: 'food', fields: [{ name: 'bara' }] } as DataViewBase;
|
||||
|
||||
expect(filterMatchesIndex(filter, indexPattern)).toBe(false);
|
||||
});
|
||||
|
||||
it('should return false if the filter key does not match a field name', () => {
|
||||
const filter = { meta: { index: 'foo', key: 'baz' } } as Filter;
|
||||
const indexPattern = { id: 'foo', fields: [{ name: 'bar' }] } as IndexPatternBase;
|
||||
const indexPattern = { id: 'foo', fields: [{ name: 'bar' }] } as DataViewBase;
|
||||
|
||||
expect(filterMatchesIndex(filter, indexPattern)).toBe(false);
|
||||
});
|
||||
|
||||
it('should return true if the filter has meta without a key', () => {
|
||||
const filter = { meta: { index: 'foo' } } as Filter;
|
||||
const indexPattern = { id: 'foo', fields: [{ name: 'bar' }] } as IndexPatternBase;
|
||||
const indexPattern = { id: 'foo', fields: [{ name: 'bar' }] } as DataViewBase;
|
||||
|
||||
expect(filterMatchesIndex(filter, indexPattern)).toBe(true);
|
||||
});
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
*/
|
||||
|
||||
import { Filter } from '../filters';
|
||||
import { IndexPatternBase } from '..';
|
||||
import { DataViewBase } from '..';
|
||||
|
||||
/*
|
||||
* TODO: We should base this on something better than `filter.meta.key`. We should probably modify
|
||||
|
@ -16,7 +16,7 @@ import { IndexPatternBase } from '..';
|
|||
*
|
||||
* @internal
|
||||
*/
|
||||
export function filterMatchesIndex(filter: Filter, indexPattern?: IndexPatternBase | null) {
|
||||
export function filterMatchesIndex(filter: Filter, indexPattern?: DataViewBase | null) {
|
||||
if (!filter.meta?.key || !indexPattern) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
|||
import { migrateFilter } from './migrate_filter';
|
||||
import { filterMatchesIndex } from './filter_matches_index';
|
||||
import { Filter, cleanFilter, isFilterDisabled } from '../filters';
|
||||
import { BoolQuery, IndexPatternBase } from './types';
|
||||
import { BoolQuery, DataViewBase } from './types';
|
||||
import { handleNestedFilter } from './handle_nested_filter';
|
||||
|
||||
/**
|
||||
|
@ -48,7 +48,7 @@ const translateToQuery = (filter: Partial<Filter>): estypes.QueryDslQueryContain
|
|||
*/
|
||||
export const buildQueryFromFilters = (
|
||||
filters: Filter[] = [],
|
||||
indexPattern: IndexPatternBase | undefined,
|
||||
indexPattern: DataViewBase | undefined,
|
||||
ignoreFilterIfFieldNotInIndex: boolean = false
|
||||
): BoolQuery => {
|
||||
filters = filters.filter((filter) => filter && !isFilterDisabled(filter));
|
||||
|
|
|
@ -9,11 +9,11 @@
|
|||
import { SerializableRecord } from '@kbn/utility-types';
|
||||
import { Query } from '../filters';
|
||||
import { fromKueryExpression, toElasticsearchQuery, nodeTypes, KueryNode } from '../kuery';
|
||||
import { BoolQuery, IndexPatternBase } from './types';
|
||||
import { BoolQuery, DataViewBase } from './types';
|
||||
|
||||
/** @internal */
|
||||
export function buildQueryFromKuery(
|
||||
indexPattern: IndexPatternBase | undefined,
|
||||
indexPattern: DataViewBase | undefined,
|
||||
queries: Query[] = [],
|
||||
allowLeadingWildcards: boolean = false,
|
||||
dateFormatTZ?: string,
|
||||
|
@ -27,7 +27,7 @@ export function buildQueryFromKuery(
|
|||
}
|
||||
|
||||
function buildQuery(
|
||||
indexPattern: IndexPatternBase | undefined,
|
||||
indexPattern: DataViewBase | undefined,
|
||||
queryASTs: KueryNode[],
|
||||
config: SerializableRecord = {}
|
||||
): BoolQuery {
|
||||
|
|
|
@ -7,11 +7,11 @@
|
|||
*/
|
||||
|
||||
import { getFilterField, cleanFilter, Filter } from '../filters';
|
||||
import { IndexPatternBase } from './types';
|
||||
import { DataViewBase } from './types';
|
||||
import { getDataViewFieldSubtypeNested } from '../utils';
|
||||
|
||||
/** @internal */
|
||||
export const handleNestedFilter = (filter: Filter, indexPattern?: IndexPatternBase) => {
|
||||
export const handleNestedFilter = (filter: Filter, indexPattern?: DataViewBase) => {
|
||||
if (!indexPattern) return filter;
|
||||
|
||||
const fieldName = getFilterField(filter);
|
||||
|
|
|
@ -13,8 +13,6 @@ export { buildQueryFromFilters } from './from_filters';
|
|||
export { luceneStringToDsl } from './lucene_string_to_dsl';
|
||||
export { decorateQuery } from './decorate_query';
|
||||
export type {
|
||||
IndexPatternBase,
|
||||
IndexPatternFieldBase,
|
||||
IFieldSubType,
|
||||
BoolQuery,
|
||||
DataViewBase,
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
import { get, omit } from 'lodash';
|
||||
import { getConvertedValueForField } from '../filters';
|
||||
import { Filter } from '../filters';
|
||||
import { IndexPatternBase } from './types';
|
||||
import { DataViewBase } from './types';
|
||||
|
||||
/** @internal */
|
||||
export interface DeprecatedMatchPhraseFilter extends Filter {
|
||||
|
@ -32,7 +32,7 @@ function isDeprecatedMatchPhraseFilter(filter: Filter): filter is DeprecatedMatc
|
|||
}
|
||||
|
||||
/** @internal */
|
||||
export function migrateFilter(filter: Filter, indexPattern?: IndexPatternBase) {
|
||||
export function migrateFilter(filter: Filter, indexPattern?: DataViewBase) {
|
||||
if (isDeprecatedMatchPhraseFilter(filter)) {
|
||||
// @ts-ignore
|
||||
const match = filter.match || filter.query.match;
|
||||
|
|
|
@ -53,11 +53,6 @@ export interface DataViewFieldBase {
|
|||
scripted?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use DataViewField instead. All index pattern interfaces were renamed.
|
||||
*/
|
||||
export type IndexPatternFieldBase = DataViewFieldBase;
|
||||
|
||||
/**
|
||||
* A base interface for an index pattern
|
||||
* @public
|
||||
|
@ -68,11 +63,6 @@ export interface DataViewBase {
|
|||
title: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use DataViewBase instead. All index pattern interfaces were renamed.
|
||||
*/
|
||||
export type IndexPatternBase = DataViewBase;
|
||||
|
||||
export interface BoolQuery {
|
||||
must: estypes.QueryDslQueryContainer[];
|
||||
must_not: estypes.QueryDslQueryContainer[];
|
||||
|
|
|
@ -14,7 +14,7 @@ import { buildPhrasesFilter } from './phrases_filter';
|
|||
import { buildRangeFilter, RangeFilterParams } from './range_filter';
|
||||
import { buildExistsFilter } from './exists_filter';
|
||||
|
||||
import type { IndexPatternFieldBase, IndexPatternBase } from '../../es_query';
|
||||
import type { DataViewFieldBase, DataViewBase } from '../../es_query';
|
||||
import { FilterStateStore } from './types';
|
||||
|
||||
/**
|
||||
|
@ -32,8 +32,8 @@ import { FilterStateStore } from './types';
|
|||
* @public
|
||||
*/
|
||||
export function buildFilter(
|
||||
indexPattern: IndexPatternBase,
|
||||
field: IndexPatternFieldBase,
|
||||
indexPattern: DataViewBase,
|
||||
field: DataViewFieldBase,
|
||||
type: FILTERS,
|
||||
negate: boolean,
|
||||
disabled: boolean,
|
||||
|
@ -52,8 +52,8 @@ export function buildFilter(
|
|||
}
|
||||
|
||||
function buildBaseFilter(
|
||||
indexPattern: IndexPatternBase,
|
||||
field: IndexPatternFieldBase,
|
||||
indexPattern: DataViewBase,
|
||||
field: DataViewFieldBase,
|
||||
type: FILTERS,
|
||||
params: Serializable
|
||||
): Filter {
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
*/
|
||||
|
||||
import { has } from 'lodash';
|
||||
import type { IndexPatternFieldBase, IndexPatternBase } from '../../es_query';
|
||||
import type { DataViewFieldBase, DataViewBase } from '../../es_query';
|
||||
import type { Filter, FilterMeta } from './types';
|
||||
|
||||
/** @public */
|
||||
|
@ -44,7 +44,7 @@ export const getExistsFilterField = (filter: ExistsFilter) => {
|
|||
*
|
||||
* @public
|
||||
*/
|
||||
export const buildExistsFilter = (field: IndexPatternFieldBase, indexPattern: IndexPatternBase) => {
|
||||
export const buildExistsFilter = (field: DataViewFieldBase, indexPattern: DataViewBase) => {
|
||||
return {
|
||||
meta: {
|
||||
index: indexPattern.id,
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import { IndexPatternFieldBase } from '../../es_query';
|
||||
import { DataViewFieldBase } from '../../es_query';
|
||||
|
||||
/**
|
||||
* @internal
|
||||
|
@ -18,7 +18,7 @@ import { IndexPatternFieldBase } from '../../es_query';
|
|||
* https://github.com/elastic/elasticsearch/pull/22201
|
||||
**/
|
||||
export const getConvertedValueForField = (
|
||||
field: IndexPatternFieldBase,
|
||||
field: DataViewFieldBase,
|
||||
value: string | boolean | number
|
||||
) => {
|
||||
if (typeof value !== 'boolean' && field.type === 'boolean') {
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||
import { get, has, isPlainObject } from 'lodash';
|
||||
import type { Filter, FilterMeta } from './types';
|
||||
import type { IndexPatternFieldBase, IndexPatternBase } from '../../es_query';
|
||||
import type { DataViewFieldBase, DataViewBase } from '../../es_query';
|
||||
import { getConvertedValueForField } from './get_converted_value_for_field';
|
||||
|
||||
export type PhraseFilterValue = string | number | boolean;
|
||||
|
@ -93,9 +93,9 @@ export const getPhraseFilterValue = (
|
|||
* @public
|
||||
*/
|
||||
export const buildPhraseFilter = (
|
||||
field: IndexPatternFieldBase,
|
||||
field: DataViewFieldBase,
|
||||
value: PhraseFilterValue,
|
||||
indexPattern: IndexPatternBase
|
||||
indexPattern: DataViewBase
|
||||
): PhraseFilter | ScriptedPhraseFilter => {
|
||||
const convertedValue = getConvertedValueForField(field, value);
|
||||
|
||||
|
@ -117,7 +117,7 @@ export const buildPhraseFilter = (
|
|||
};
|
||||
|
||||
/** @internal */
|
||||
export const getPhraseScript = (field: IndexPatternFieldBase, value: PhraseFilterValue) => {
|
||||
export const getPhraseScript = (field: DataViewFieldBase, value: PhraseFilterValue) => {
|
||||
const convertedValue = getConvertedValueForField(field, value);
|
||||
const script = buildInlineScriptForPhraseFilter(field);
|
||||
|
||||
|
@ -141,7 +141,7 @@ export const getPhraseScript = (field: IndexPatternFieldBase, value: PhraseFilte
|
|||
* @param {object} scriptedField A Field object representing a scripted field
|
||||
* @returns {string} The inline script string
|
||||
*/
|
||||
export const buildInlineScriptForPhraseFilter = (scriptedField: IndexPatternFieldBase) => {
|
||||
export const buildInlineScriptForPhraseFilter = (scriptedField: DataViewFieldBase) => {
|
||||
// We must wrap painless scripts in a lambda in case they're more than a simple expression
|
||||
if (scriptedField.lang === 'painless') {
|
||||
return (
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||
import { Filter, FilterMeta, FILTERS } from './types';
|
||||
import { getPhraseScript, PhraseFilterValue } from './phrase_filter';
|
||||
import type { IndexPatternFieldBase, IndexPatternBase } from '../../es_query';
|
||||
import type { DataViewFieldBase, DataViewBase } from '../../es_query';
|
||||
|
||||
export type PhrasesFilterMeta = FilterMeta & {
|
||||
params: PhraseFilterValue[]; // The unformatted values
|
||||
|
@ -48,9 +48,9 @@ export const getPhrasesFilterField = (filter: PhrasesFilter) => {
|
|||
* @public
|
||||
*/
|
||||
export const buildPhrasesFilter = (
|
||||
field: IndexPatternFieldBase,
|
||||
field: DataViewFieldBase,
|
||||
params: PhraseFilterValue[],
|
||||
indexPattern: IndexPatternBase
|
||||
indexPattern: DataViewBase
|
||||
) => {
|
||||
const index = indexPattern.id;
|
||||
const type = FILTERS.PHRASES;
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
*/
|
||||
|
||||
import { each } from 'lodash';
|
||||
import { IndexPatternBase, IndexPatternFieldBase } from '../../es_query';
|
||||
import { DataViewBase, DataViewFieldBase } from '../../es_query';
|
||||
import { fields, getField } from '../stubs';
|
||||
import {
|
||||
buildRangeFilter,
|
||||
|
@ -17,12 +17,12 @@ import {
|
|||
} from './range_filter';
|
||||
|
||||
describe('Range filter builder', () => {
|
||||
let indexPattern: IndexPatternBase;
|
||||
let indexPattern: DataViewBase;
|
||||
|
||||
beforeEach(() => {
|
||||
indexPattern = {
|
||||
id: 'id',
|
||||
} as IndexPatternBase;
|
||||
} as DataViewBase;
|
||||
});
|
||||
|
||||
it('should be a function', () => {
|
||||
|
@ -145,7 +145,7 @@ describe('Range filter builder', () => {
|
|||
});
|
||||
|
||||
describe('when given params where one side is infinite', () => {
|
||||
let field: IndexPatternFieldBase;
|
||||
let field: DataViewFieldBase;
|
||||
let filter: ScriptedRangeFilter;
|
||||
|
||||
beforeEach(() => {
|
||||
|
@ -179,7 +179,7 @@ describe('Range filter builder', () => {
|
|||
});
|
||||
|
||||
describe('when given params where both sides are infinite', () => {
|
||||
let field: IndexPatternFieldBase;
|
||||
let field: DataViewFieldBase;
|
||||
let filter: ScriptedRangeFilter;
|
||||
|
||||
beforeEach(() => {
|
||||
|
@ -209,9 +209,9 @@ describe('Range filter builder', () => {
|
|||
});
|
||||
|
||||
describe('getRangeFilterField', function () {
|
||||
const indexPattern: IndexPatternBase = {
|
||||
const indexPattern: DataViewBase = {
|
||||
fields,
|
||||
} as unknown as IndexPatternBase;
|
||||
} as unknown as DataViewBase;
|
||||
|
||||
test('should return the name of the field a range query is targeting', () => {
|
||||
const field = indexPattern.fields.find((patternField) => patternField.name === 'bytes');
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||
import { map, reduce, mapValues, has, get, keys, pickBy } from 'lodash';
|
||||
import type { Filter, FilterMeta } from './types';
|
||||
import type { IndexPatternBase, IndexPatternFieldBase } from '../../es_query';
|
||||
import type { DataViewBase, DataViewFieldBase } from '../../es_query';
|
||||
|
||||
const OPERANDS_IN_RANGE = 2;
|
||||
|
||||
|
@ -128,9 +128,9 @@ const formatValue = (params: any[]) =>
|
|||
* @public
|
||||
*/
|
||||
export const buildRangeFilter = (
|
||||
field: IndexPatternFieldBase,
|
||||
field: DataViewFieldBase,
|
||||
params: RangeFilterParams,
|
||||
indexPattern: IndexPatternBase,
|
||||
indexPattern: DataViewBase,
|
||||
formattedValue?: string
|
||||
): RangeFilter | ScriptedRangeFilter | MatchAllRangeFilter => {
|
||||
params = mapValues(params, (value: any) => (field.type === 'number' ? parseFloat(value) : value));
|
||||
|
@ -174,7 +174,7 @@ export const buildRangeFilter = (
|
|||
/**
|
||||
* @internal
|
||||
*/
|
||||
export const getRangeScript = (field: IndexPatternFieldBase, params: RangeFilterParams) => {
|
||||
export const getRangeScript = (field: DataViewFieldBase, params: RangeFilterParams) => {
|
||||
const knownParams: estypes.InlineScript['params'] = mapValues(
|
||||
pickBy(params, (val, key) => key in operators),
|
||||
(value) => (field.type === 'number' && typeof value === 'string' ? parseFloat(value) : value)
|
||||
|
|
|
@ -6,24 +6,24 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import { IndexPatternBase, IndexPatternFieldBase } from '../../es_query';
|
||||
import { DataViewBase, DataViewFieldBase } from '../../es_query';
|
||||
import { buildQueryFilter, buildRangeFilter, Filter, FilterStateStore } from '../build_filters';
|
||||
import { dedupFilters } from './dedup_filters';
|
||||
|
||||
describe('filter manager utilities', () => {
|
||||
let indexPattern: IndexPatternBase;
|
||||
let indexPattern: DataViewBase;
|
||||
|
||||
beforeEach(() => {
|
||||
indexPattern = {
|
||||
id: 'index',
|
||||
} as IndexPatternBase;
|
||||
} as DataViewBase;
|
||||
});
|
||||
|
||||
describe('dedupFilters(existing, filters)', () => {
|
||||
test('should return only filters which are not in the existing', () => {
|
||||
const existing: Filter[] = [
|
||||
buildRangeFilter(
|
||||
{ name: 'bytes' } as IndexPatternFieldBase,
|
||||
{ name: 'bytes' } as DataViewFieldBase,
|
||||
{ from: 0, to: 1024 },
|
||||
indexPattern,
|
||||
''
|
||||
|
@ -32,7 +32,7 @@ describe('filter manager utilities', () => {
|
|||
];
|
||||
const filters: Filter[] = [
|
||||
buildRangeFilter(
|
||||
{ name: 'bytes' } as IndexPatternFieldBase,
|
||||
{ name: 'bytes' } as DataViewFieldBase,
|
||||
{ from: 1024, to: 2048 },
|
||||
indexPattern,
|
||||
''
|
||||
|
@ -48,7 +48,7 @@ describe('filter manager utilities', () => {
|
|||
test('should ignore the disabled attribute when comparing ', () => {
|
||||
const existing: Filter[] = [
|
||||
buildRangeFilter(
|
||||
{ name: 'bytes' } as IndexPatternFieldBase,
|
||||
{ name: 'bytes' } as DataViewFieldBase,
|
||||
{ from: 0, to: 1024 },
|
||||
indexPattern,
|
||||
''
|
||||
|
@ -60,7 +60,7 @@ describe('filter manager utilities', () => {
|
|||
];
|
||||
const filters: Filter[] = [
|
||||
buildRangeFilter(
|
||||
{ name: 'bytes' } as IndexPatternFieldBase,
|
||||
{ name: 'bytes' } as DataViewFieldBase,
|
||||
{ from: 1024, to: 2048 },
|
||||
indexPattern,
|
||||
''
|
||||
|
@ -76,7 +76,7 @@ describe('filter manager utilities', () => {
|
|||
test('should ignore $state attribute', () => {
|
||||
const existing: Filter[] = [
|
||||
buildRangeFilter(
|
||||
{ name: 'bytes' } as IndexPatternFieldBase,
|
||||
{ name: 'bytes' } as DataViewFieldBase,
|
||||
{ from: 0, to: 1024 },
|
||||
indexPattern,
|
||||
''
|
||||
|
@ -88,7 +88,7 @@ describe('filter manager utilities', () => {
|
|||
];
|
||||
const filters: Filter[] = [
|
||||
buildRangeFilter(
|
||||
{ name: 'bytes' } as IndexPatternFieldBase,
|
||||
{ name: 'bytes' } as DataViewFieldBase,
|
||||
{ from: 1024, to: 2048 },
|
||||
indexPattern,
|
||||
''
|
||||
|
|
|
@ -6,12 +6,12 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import { IndexPatternFieldBase } from '../..';
|
||||
import { DataViewFieldBase } from '../..';
|
||||
|
||||
/**
|
||||
* Base index pattern fields for testing
|
||||
*/
|
||||
export const fields: IndexPatternFieldBase[] = [
|
||||
export const fields: DataViewFieldBase[] = [
|
||||
{
|
||||
name: 'bytes',
|
||||
type: 'number',
|
||||
|
|
|
@ -13,7 +13,7 @@ import { KQLSyntaxError } from '../kuery_syntax_error';
|
|||
import { KueryNode, KueryParseOptions, KueryQueryOptions } from '../types';
|
||||
|
||||
import { parse as parseKuery } from '../grammar';
|
||||
import { IndexPatternBase } from '../..';
|
||||
import { DataViewBase } from '../..';
|
||||
|
||||
const fromExpression = (
|
||||
expression: string | estypes.QueryDslQueryContainer,
|
||||
|
@ -66,7 +66,7 @@ export const fromKueryExpression = (
|
|||
*/
|
||||
export const toElasticsearchQuery = (
|
||||
node: KueryNode,
|
||||
indexPattern?: IndexPatternBase,
|
||||
indexPattern?: DataViewBase,
|
||||
config: KueryQueryOptions = {},
|
||||
context?: Record<string, any>
|
||||
): JsonObject => {
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
*/
|
||||
|
||||
import * as ast from '../ast';
|
||||
import { IndexPatternBase, KueryNode, KueryQueryOptions } from '../..';
|
||||
import { DataViewBase, KueryNode, KueryQueryOptions } from '../..';
|
||||
|
||||
export function buildNodeParams(children: KueryNode[]) {
|
||||
return {
|
||||
|
@ -17,7 +17,7 @@ export function buildNodeParams(children: KueryNode[]) {
|
|||
|
||||
export function toElasticsearchQuery(
|
||||
node: KueryNode,
|
||||
indexPattern?: IndexPatternBase,
|
||||
indexPattern?: DataViewBase,
|
||||
config: KueryQueryOptions = {},
|
||||
context: Record<string, any> = {}
|
||||
) {
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
*/
|
||||
|
||||
import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||
import { IndexPatternFieldBase, IndexPatternBase, KueryNode, KueryQueryOptions } from '../..';
|
||||
import { DataViewFieldBase, DataViewBase, KueryNode, KueryQueryOptions } from '../..';
|
||||
import * as literal from '../node_types/literal';
|
||||
|
||||
export function buildNodeParams(fieldName: string) {
|
||||
|
@ -18,7 +18,7 @@ export function buildNodeParams(fieldName: string) {
|
|||
|
||||
export function toElasticsearchQuery(
|
||||
node: KueryNode,
|
||||
indexPattern?: IndexPatternBase,
|
||||
indexPattern?: DataViewBase,
|
||||
config: KueryQueryOptions = {},
|
||||
context: Record<string, any> = {}
|
||||
): estypes.QueryDslQueryContainer {
|
||||
|
@ -30,7 +30,7 @@ export function toElasticsearchQuery(
|
|||
value: context?.nested ? `${context.nested.path}.${fieldNameArg.value}` : fieldNameArg.value,
|
||||
};
|
||||
const fieldName = literal.toElasticsearchQuery(fullFieldNameArg) as string;
|
||||
const field = indexPattern?.fields?.find((fld: IndexPatternFieldBase) => fld.name === fieldName);
|
||||
const field = indexPattern?.fields?.find((fld: DataViewFieldBase) => fld.name === fieldName);
|
||||
|
||||
if (field?.scripted) {
|
||||
throw new Error(`Exists query does not support scripted fields`);
|
||||
|
|
|
@ -12,7 +12,7 @@ import { getPhraseScript } from '../../filters';
|
|||
import { getFields } from './utils/get_fields';
|
||||
import { getTimeZoneFromSettings, getDataViewFieldSubtypeNested } from '../../utils';
|
||||
import { getFullFieldNameNode } from './utils/get_full_field_name_node';
|
||||
import { IndexPatternBase, KueryNode, IndexPatternFieldBase, KueryQueryOptions } from '../..';
|
||||
import { DataViewBase, KueryNode, DataViewFieldBase, KueryQueryOptions } from '../..';
|
||||
|
||||
import * as ast from '../ast';
|
||||
|
||||
|
@ -40,7 +40,7 @@ export function buildNodeParams(fieldName: string, value: any, isPhrase: boolean
|
|||
|
||||
export function toElasticsearchQuery(
|
||||
node: KueryNode,
|
||||
indexPattern?: IndexPatternBase,
|
||||
indexPattern?: DataViewBase,
|
||||
config: KueryQueryOptions = {},
|
||||
context: Record<string, any> = {}
|
||||
): estypes.QueryDslQueryContainer {
|
||||
|
@ -101,7 +101,7 @@ export function toElasticsearchQuery(
|
|||
return { match_all: {} };
|
||||
}
|
||||
|
||||
const queries = fields!.reduce((accumulator: any, field: IndexPatternFieldBase) => {
|
||||
const queries = fields!.reduce((accumulator: any, field: DataViewFieldBase) => {
|
||||
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.
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||
import * as ast from '../ast';
|
||||
import * as literal from '../node_types/literal';
|
||||
import { IndexPatternBase, KueryNode, KueryQueryOptions } from '../..';
|
||||
import { DataViewBase, KueryNode, KueryQueryOptions } from '../..';
|
||||
|
||||
export function buildNodeParams(path: any, child: any) {
|
||||
const pathNode =
|
||||
|
@ -21,7 +21,7 @@ export function buildNodeParams(path: any, child: any) {
|
|||
|
||||
export function toElasticsearchQuery(
|
||||
node: KueryNode,
|
||||
indexPattern?: IndexPatternBase,
|
||||
indexPattern?: DataViewBase,
|
||||
config: KueryQueryOptions = {},
|
||||
context: Record<string, any> = {}
|
||||
): estypes.QueryDslQueryContainer {
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||
import * as ast from '../ast';
|
||||
import { IndexPatternBase, KueryNode, KueryQueryOptions } from '../..';
|
||||
import { DataViewBase, KueryNode, KueryQueryOptions } from '../..';
|
||||
|
||||
export function buildNodeParams(child: KueryNode) {
|
||||
return {
|
||||
|
@ -18,7 +18,7 @@ export function buildNodeParams(child: KueryNode) {
|
|||
|
||||
export function toElasticsearchQuery(
|
||||
node: KueryNode,
|
||||
indexPattern?: IndexPatternBase,
|
||||
indexPattern?: DataViewBase,
|
||||
config: KueryQueryOptions = {},
|
||||
context: Record<string, any> = {}
|
||||
): estypes.QueryDslQueryContainer {
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||
import * as ast from '../ast';
|
||||
import { IndexPatternBase, KueryNode, KueryQueryOptions } from '../..';
|
||||
import { DataViewBase, KueryNode, KueryQueryOptions } from '../..';
|
||||
|
||||
export function buildNodeParams(children: KueryNode[]) {
|
||||
return {
|
||||
|
@ -18,7 +18,7 @@ export function buildNodeParams(children: KueryNode[]) {
|
|||
|
||||
export function toElasticsearchQuery(
|
||||
node: KueryNode,
|
||||
indexPattern?: IndexPatternBase,
|
||||
indexPattern?: DataViewBase,
|
||||
config: KueryQueryOptions = {},
|
||||
context: Record<string, any> = {}
|
||||
): estypes.QueryDslQueryContainer {
|
||||
|
|
|
@ -13,7 +13,7 @@ import { getRangeScript, RangeFilterParams } from '../../filters';
|
|||
import { getFields } from './utils/get_fields';
|
||||
import { getDataViewFieldSubtypeNested, getTimeZoneFromSettings } from '../../utils';
|
||||
import { getFullFieldNameNode } from './utils/get_full_field_name_node';
|
||||
import type { IndexPatternBase, KueryNode, KueryQueryOptions } from '../..';
|
||||
import type { DataViewBase, KueryNode, KueryQueryOptions } from '../..';
|
||||
|
||||
export function buildNodeParams(
|
||||
fieldName: string,
|
||||
|
@ -28,7 +28,7 @@ export function buildNodeParams(
|
|||
|
||||
export function toElasticsearchQuery(
|
||||
node: KueryNode,
|
||||
indexPattern?: IndexPatternBase,
|
||||
indexPattern?: DataViewBase,
|
||||
config: KueryQueryOptions = {},
|
||||
context: Record<string, any> = {}
|
||||
): estypes.QueryDslQueryContainer {
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import { IndexPatternBase } from '../../..';
|
||||
import { DataViewBase } from '../../..';
|
||||
import { fields } from '../../../filters/stubs';
|
||||
|
||||
import { nodeTypes } from '../../index';
|
||||
|
@ -15,12 +15,12 @@ import { getFields } from './get_fields';
|
|||
jest.mock('../../grammar');
|
||||
|
||||
describe('getFields', () => {
|
||||
let indexPattern: IndexPatternBase;
|
||||
let indexPattern: DataViewBase;
|
||||
|
||||
beforeEach(() => {
|
||||
indexPattern = {
|
||||
fields,
|
||||
} as unknown as IndexPatternBase;
|
||||
} as unknown as DataViewBase;
|
||||
});
|
||||
|
||||
describe('field names without a wildcard', () => {
|
||||
|
@ -41,14 +41,14 @@ describe('getFields', () => {
|
|||
});
|
||||
|
||||
test('should not match a wildcard in a literal node', () => {
|
||||
const indexPatternWithWildField: IndexPatternBase = {
|
||||
const indexPatternWithWildField: DataViewBase = {
|
||||
title: 'wildIndex',
|
||||
fields: [
|
||||
{
|
||||
name: 'foo*',
|
||||
},
|
||||
],
|
||||
} as unknown as IndexPatternBase;
|
||||
} as unknown as DataViewBase;
|
||||
|
||||
const fieldNameNode = nodeTypes.literal.buildNode('foo*');
|
||||
const results = getFields(fieldNameNode, indexPatternWithWildField);
|
||||
|
|
|
@ -8,10 +8,10 @@
|
|||
|
||||
import * as literal from '../../node_types/literal';
|
||||
import * as wildcard from '../../node_types/wildcard';
|
||||
import { KueryNode, IndexPatternBase } from '../../..';
|
||||
import { KueryNode, DataViewBase } from '../../..';
|
||||
import { LiteralTypeBuildNode } from '../../node_types/types';
|
||||
|
||||
export function getFields(node: KueryNode, indexPattern?: IndexPatternBase) {
|
||||
export function getFields(node: KueryNode, indexPattern?: DataViewBase) {
|
||||
if (!indexPattern) return [];
|
||||
if (node.type === 'literal') {
|
||||
const fieldName = literal.toElasticsearchQuery(node as LiteralTypeBuildNode);
|
||||
|
|
|
@ -7,12 +7,12 @@
|
|||
*/
|
||||
|
||||
import { getFields } from './get_fields';
|
||||
import { IndexPatternBase, IndexPatternFieldBase, KueryNode } from '../../..';
|
||||
import { DataViewBase, DataViewFieldBase, KueryNode } from '../../..';
|
||||
import { getDataViewFieldSubtypeNested } from '../../../utils';
|
||||
|
||||
export function getFullFieldNameNode(
|
||||
rootNameNode: any,
|
||||
indexPattern?: IndexPatternBase,
|
||||
indexPattern?: DataViewBase,
|
||||
nestedPath?: string
|
||||
): KueryNode {
|
||||
const fullFieldNameNode = {
|
||||
|
@ -28,7 +28,7 @@ export function getFullFieldNameNode(
|
|||
}
|
||||
const fields = getFields(fullFieldNameNode, indexPattern);
|
||||
|
||||
const errors = fields!.reduce((acc: any, field: IndexPatternFieldBase) => {
|
||||
const errors = fields!.reduce((acc: any, field: DataViewFieldBase) => {
|
||||
const subTypeNested = getDataViewFieldSubtypeNested(field);
|
||||
const nestedPathFromField = subTypeNested?.nested.path;
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
import _ from 'lodash';
|
||||
|
||||
import { functions } from '../functions';
|
||||
import { IndexPatternBase, KueryNode, KueryQueryOptions } from '../..';
|
||||
import { DataViewBase, KueryNode, KueryQueryOptions } from '../..';
|
||||
import { FunctionName, FunctionTypeBuildNode } from './types';
|
||||
|
||||
export function buildNode(functionName: FunctionName, ...args: any[]) {
|
||||
|
@ -45,7 +45,7 @@ export function buildNodeWithArgumentNodes(
|
|||
|
||||
export function toElasticsearchQuery(
|
||||
node: KueryNode,
|
||||
indexPattern?: IndexPatternBase,
|
||||
indexPattern?: DataViewBase,
|
||||
config?: KueryQueryOptions,
|
||||
context?: Record<string, any>
|
||||
) {
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
import { JsonValue } from '@kbn/utility-types';
|
||||
import { KueryNode, KueryQueryOptions } from '..';
|
||||
import { IndexPatternBase } from '../..';
|
||||
import { DataViewBase } from '../..';
|
||||
|
||||
export type FunctionName = 'is' | 'and' | 'or' | 'not' | 'range' | 'exists' | 'nested';
|
||||
|
||||
|
@ -21,7 +21,7 @@ interface FunctionType {
|
|||
buildNodeWithArgumentNodes: (functionName: FunctionName, args: any[]) => FunctionTypeBuildNode;
|
||||
toElasticsearchQuery: (
|
||||
node: any,
|
||||
indexPattern?: IndexPatternBase,
|
||||
indexPattern?: DataViewBase,
|
||||
config?: KueryQueryOptions,
|
||||
context?: Record<string, any>
|
||||
) => JsonValue;
|
||||
|
|
|
@ -12,7 +12,7 @@ This hook uses the kibana `services.data.autocomplete.getValueSuggestions()` ser
|
|||
|
||||
This component can be used to display available indexPattern fields. It requires an indexPattern to be passed in and will show an error state if value is not one of the available indexPattern fields. Users will be able to select only one option.
|
||||
|
||||
The `onChange` handler is passed `IndexPatternFieldBase[]`.
|
||||
The `onChange` handler is passed `DataViewFieldBase[]`.
|
||||
|
||||
```js
|
||||
<FieldComponent
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import { IndexPatternFieldBase } from '@kbn/es-query';
|
||||
import { DataViewFieldBase } from '@kbn/es-query';
|
||||
import * as i18n from '../translations';
|
||||
|
||||
/**
|
||||
|
@ -14,7 +14,7 @@ import * as i18n from '../translations';
|
|||
*/
|
||||
export const checkEmptyValue = (
|
||||
param: string | undefined,
|
||||
field: IndexPatternFieldBase | undefined,
|
||||
field: DataViewFieldBase | undefined,
|
||||
isRequired: boolean,
|
||||
touched: boolean
|
||||
): string | undefined | null => {
|
||||
|
|
|
@ -10,7 +10,7 @@ import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
|||
import { EuiComboBox, EuiComboBoxOptionOption, EuiFormRow } from '@elastic/eui';
|
||||
import type { ListSchema } from '@kbn/securitysolution-io-ts-list-types';
|
||||
import { useFindLists } from '@kbn/securitysolution-list-hooks';
|
||||
import { IndexPatternFieldBase } from '@kbn/es-query';
|
||||
import { DataViewFieldBase } from '@kbn/es-query';
|
||||
|
||||
import { filterFieldToList } from '../filter_field_to_list';
|
||||
import { getGenericComboBoxProps } from '../get_generic_combo_box_props';
|
||||
|
@ -31,7 +31,7 @@ interface AutocompleteFieldListsProps {
|
|||
onChange: (arg: ListSchema) => void;
|
||||
placeholder: string;
|
||||
rowLabel?: string;
|
||||
selectedField: IndexPatternFieldBase | undefined;
|
||||
selectedField: DataViewFieldBase | undefined;
|
||||
selectedValue: string | undefined;
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ import {
|
|||
EuiComboBoxOptionOption,
|
||||
EuiComboBox,
|
||||
} from '@elastic/eui';
|
||||
import { IndexPatternBase, IndexPatternFieldBase } from '@kbn/es-query';
|
||||
import { DataViewBase, DataViewFieldBase } from '@kbn/es-query';
|
||||
|
||||
import { uniq } from 'lodash';
|
||||
|
||||
|
@ -41,9 +41,9 @@ const SINGLE_SELECTION = { asPlainText: true };
|
|||
|
||||
interface AutocompleteFieldMatchProps {
|
||||
placeholder: string;
|
||||
selectedField: IndexPatternFieldBase | undefined;
|
||||
selectedField: DataViewFieldBase | undefined;
|
||||
selectedValue: string | undefined;
|
||||
indexPattern: IndexPatternBase | undefined;
|
||||
indexPattern: DataViewBase | undefined;
|
||||
isLoading: boolean;
|
||||
isDisabled: boolean;
|
||||
isClearable: boolean;
|
||||
|
|
|
@ -10,7 +10,7 @@ import React, { useCallback, useMemo, useState } from 'react';
|
|||
import { EuiComboBox, EuiComboBoxOptionOption, EuiFormRow } from '@elastic/eui';
|
||||
import { uniq } from 'lodash';
|
||||
import { ListOperatorTypeEnum as OperatorTypeEnum } from '@kbn/securitysolution-io-ts-list-types';
|
||||
import { IndexPatternBase, IndexPatternFieldBase } from '@kbn/es-query';
|
||||
import { DataViewBase, DataViewFieldBase } from '@kbn/es-query';
|
||||
|
||||
// TODO: I have to use any here for now, but once this is available below, we should use the correct types, https://github.com/elastic/kibana/issues/100715
|
||||
// import { AutocompleteStart } from '../../../../../../../src/plugins/data/public';
|
||||
|
@ -26,9 +26,9 @@ import { paramIsValid } from '../param_is_valid';
|
|||
|
||||
interface AutocompleteFieldMatchAnyProps {
|
||||
placeholder: string;
|
||||
selectedField: IndexPatternFieldBase | undefined;
|
||||
selectedField: DataViewFieldBase | undefined;
|
||||
selectedValue: string[];
|
||||
indexPattern: IndexPatternBase | undefined;
|
||||
indexPattern: DataViewBase | undefined;
|
||||
isLoading: boolean;
|
||||
isDisabled: boolean;
|
||||
isClearable: boolean;
|
||||
|
|
|
@ -6,12 +6,12 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import { IndexPatternFieldBase } from '@kbn/es-query';
|
||||
import { DataViewFieldBase } from '@kbn/es-query';
|
||||
|
||||
// Copied from "src/plugins/data/common/index_patterns/fields/fields.mocks.ts" but with the types changed to "IndexPatternFieldBase" since that type is compatible.
|
||||
// Copied from "src/plugins/data/common/index_patterns/fields/fields.mocks.ts" but with the types changed to "DataViewFieldBase" since that type is compatible.
|
||||
// TODO: This should move out once those mocks are directly useable or in their own package, https://github.com/elastic/kibana/issues/100715
|
||||
|
||||
export const fields: IndexPatternFieldBase[] = [
|
||||
export const fields: DataViewFieldBase[] = [
|
||||
{
|
||||
name: 'bytes',
|
||||
type: 'number',
|
||||
|
@ -309,6 +309,6 @@ export const fields: IndexPatternFieldBase[] = [
|
|||
readFromDocValues: false,
|
||||
subType: { nested: { path: 'nestedField.nestedChild' } },
|
||||
},
|
||||
] as unknown as IndexPatternFieldBase[];
|
||||
] as unknown as DataViewFieldBase[];
|
||||
|
||||
export const getField = (name: string) => fields.find((field) => field.name === name);
|
||||
|
|
|
@ -10,7 +10,7 @@ import { filterFieldToList } from '.';
|
|||
|
||||
import type { ListSchema } from '@kbn/securitysolution-io-ts-list-types';
|
||||
import { getListResponseMock } from '../list_schema/index.mock';
|
||||
import { IndexPatternFieldBase } from '@kbn/es-query';
|
||||
import { DataViewFieldBase } from '@kbn/es-query';
|
||||
|
||||
describe('#filterFieldToList', () => {
|
||||
test('it returns empty array if given a undefined for field', () => {
|
||||
|
@ -19,7 +19,7 @@ describe('#filterFieldToList', () => {
|
|||
});
|
||||
|
||||
test('it returns empty array if filed does not contain esTypes', () => {
|
||||
const field: IndexPatternFieldBase = {
|
||||
const field: DataViewFieldBase = {
|
||||
name: 'some-name',
|
||||
type: 'some-type',
|
||||
};
|
||||
|
@ -28,7 +28,7 @@ describe('#filterFieldToList', () => {
|
|||
});
|
||||
|
||||
test('it returns single filtered list of ip_range -> ip', () => {
|
||||
const field: IndexPatternFieldBase & { esTypes: string[] } = {
|
||||
const field: DataViewFieldBase & { esTypes: string[] } = {
|
||||
esTypes: ['ip'],
|
||||
name: 'some-name',
|
||||
type: 'ip',
|
||||
|
@ -40,7 +40,7 @@ describe('#filterFieldToList', () => {
|
|||
});
|
||||
|
||||
test('it returns single filtered list of ip -> ip', () => {
|
||||
const field: IndexPatternFieldBase & { esTypes: string[] } = {
|
||||
const field: DataViewFieldBase & { esTypes: string[] } = {
|
||||
esTypes: ['ip'],
|
||||
name: 'some-name',
|
||||
type: 'ip',
|
||||
|
@ -52,7 +52,7 @@ describe('#filterFieldToList', () => {
|
|||
});
|
||||
|
||||
test('it returns single filtered list of keyword -> keyword', () => {
|
||||
const field: IndexPatternFieldBase & { esTypes: string[] } = {
|
||||
const field: DataViewFieldBase & { esTypes: string[] } = {
|
||||
esTypes: ['keyword'],
|
||||
name: 'some-name',
|
||||
type: 'keyword',
|
||||
|
@ -64,7 +64,7 @@ describe('#filterFieldToList', () => {
|
|||
});
|
||||
|
||||
test('it returns single filtered list of text -> text', () => {
|
||||
const field: IndexPatternFieldBase & { esTypes: string[] } = {
|
||||
const field: DataViewFieldBase & { esTypes: string[] } = {
|
||||
esTypes: ['text'],
|
||||
name: 'some-name',
|
||||
type: 'text',
|
||||
|
@ -76,7 +76,7 @@ describe('#filterFieldToList', () => {
|
|||
});
|
||||
|
||||
test('it returns 2 filtered lists of ip_range -> ip', () => {
|
||||
const field: IndexPatternFieldBase & { esTypes: string[] } = {
|
||||
const field: DataViewFieldBase & { esTypes: string[] } = {
|
||||
esTypes: ['ip'],
|
||||
name: 'some-name',
|
||||
type: 'ip',
|
||||
|
@ -89,7 +89,7 @@ describe('#filterFieldToList', () => {
|
|||
});
|
||||
|
||||
test('it returns 1 filtered lists of ip_range -> ip if the 2nd is not compatible type', () => {
|
||||
const field: IndexPatternFieldBase & { esTypes: string[] } = {
|
||||
const field: DataViewFieldBase & { esTypes: string[] } = {
|
||||
esTypes: ['ip'],
|
||||
name: 'some-name',
|
||||
type: 'ip',
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
*/
|
||||
|
||||
import { ListSchema } from '@kbn/securitysolution-io-ts-list-types';
|
||||
import { IndexPatternFieldBase } from '@kbn/es-query';
|
||||
import { DataViewFieldBase } from '@kbn/es-query';
|
||||
import { typeMatch } from '../type_match';
|
||||
|
||||
/**
|
||||
|
@ -22,7 +22,7 @@ import { typeMatch } from '../type_match';
|
|||
*/
|
||||
export const filterFieldToList = (
|
||||
lists: ListSchema[],
|
||||
field?: IndexPatternFieldBase & { esTypes?: string[] }
|
||||
field?: DataViewFieldBase & { esTypes?: string[] }
|
||||
): ListSchema[] => {
|
||||
if (field != null) {
|
||||
const { esTypes = [] } = field;
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import { IndexPatternFieldBase } from '@kbn/es-query';
|
||||
import { DataViewFieldBase } from '@kbn/es-query';
|
||||
|
||||
import {
|
||||
EXCEPTION_OPERATORS,
|
||||
|
@ -20,10 +20,10 @@ import {
|
|||
/**
|
||||
* Returns the appropriate operators given a field type
|
||||
*
|
||||
* @param field IndexPatternFieldBase selected field
|
||||
* @param field DataViewFieldBase selected field
|
||||
*
|
||||
*/
|
||||
export const getOperators = (field: IndexPatternFieldBase | undefined): OperatorOption[] => {
|
||||
export const getOperators = (field: DataViewFieldBase | undefined): OperatorOption[] => {
|
||||
if (field == null) {
|
||||
return [isOperator];
|
||||
} else if (field.type === 'boolean') {
|
||||
|
|
|
@ -16,7 +16,7 @@ import {
|
|||
} from '.';
|
||||
import { getField } from '../../fields/index.mock';
|
||||
import { autocompleteStartMock } from '../../autocomplete/index.mock';
|
||||
import { IndexPatternFieldBase } from '@kbn/es-query';
|
||||
import { DataViewFieldBase } from '@kbn/es-query';
|
||||
|
||||
// Copied from "src/plugins/data/common/index_patterns/index_pattern.stub.ts"
|
||||
// TODO: Remove this in favor of the above if/when it is ported, https://github.com/elastic/kibana/issues/100715
|
||||
|
@ -153,7 +153,7 @@ describe('use_field_value_autocomplete', () => {
|
|||
const suggestionsMock = jest.fn().mockResolvedValue([]);
|
||||
|
||||
await act(async () => {
|
||||
const selectedField: IndexPatternFieldBase | undefined = getField('nestedField.child');
|
||||
const selectedField: DataViewFieldBase | undefined = getField('nestedField.child');
|
||||
if (selectedField == null) {
|
||||
throw new TypeError('selectedField for this test should always be defined');
|
||||
}
|
||||
|
|
|
@ -9,19 +9,15 @@
|
|||
import { useEffect, useRef, useState } from 'react';
|
||||
import { debounce } from 'lodash';
|
||||
import { ListOperatorTypeEnum as OperatorTypeEnum } from '@kbn/securitysolution-io-ts-list-types';
|
||||
import {
|
||||
IndexPatternBase,
|
||||
IndexPatternFieldBase,
|
||||
getDataViewFieldSubtypeNested,
|
||||
} from '@kbn/es-query';
|
||||
import { DataViewBase, DataViewFieldBase, getDataViewFieldSubtypeNested } from '@kbn/es-query';
|
||||
|
||||
// TODO: I have to use any here for now, but once this is available below, we should use the correct types, https://github.com/elastic/kibana/issues/100715
|
||||
// import { AutocompleteStart } from '../../../../../../../../src/plugins/data/public';
|
||||
type AutocompleteStart = any;
|
||||
|
||||
interface FuncArgs {
|
||||
fieldSelected: IndexPatternFieldBase | undefined;
|
||||
patterns: IndexPatternBase | undefined;
|
||||
fieldSelected: DataViewFieldBase | undefined;
|
||||
patterns: DataViewBase | undefined;
|
||||
searchQuery: string;
|
||||
value: string | string[] | undefined;
|
||||
}
|
||||
|
@ -33,10 +29,10 @@ export type UseFieldValueAutocompleteReturn = [boolean, boolean, string[], Func
|
|||
export interface UseFieldValueAutocompleteProps {
|
||||
autocompleteService: AutocompleteStart;
|
||||
fieldValue: string | string[] | undefined;
|
||||
indexPattern: IndexPatternBase | undefined;
|
||||
indexPattern: DataViewBase | undefined;
|
||||
operatorType: OperatorTypeEnum;
|
||||
query: string;
|
||||
selectedField: IndexPatternFieldBase | undefined;
|
||||
selectedField: DataViewFieldBase | undefined;
|
||||
}
|
||||
/**
|
||||
* Hook for using the field value autocomplete service
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
import React, { useCallback, useMemo } from 'react';
|
||||
import { EuiComboBox, EuiComboBoxOptionOption } from '@elastic/eui';
|
||||
import { OperatorOption } from '@kbn/securitysolution-list-utils';
|
||||
import { IndexPatternFieldBase } from '@kbn/es-query';
|
||||
import { DataViewFieldBase } from '@kbn/es-query';
|
||||
|
||||
import { getOperators } from '../get_operators';
|
||||
import {
|
||||
|
@ -28,7 +28,7 @@ interface OperatorState {
|
|||
operatorInputWidth?: number;
|
||||
operatorOptions?: OperatorOption[];
|
||||
placeholder: string;
|
||||
selectedField: IndexPatternFieldBase | undefined;
|
||||
selectedField: DataViewFieldBase | undefined;
|
||||
}
|
||||
|
||||
export const OperatorComponent: React.FC<OperatorState> = ({
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
*/
|
||||
|
||||
import dateMath from '@elastic/datemath';
|
||||
import { IndexPatternFieldBase } from '@kbn/es-query';
|
||||
import { DataViewFieldBase } from '@kbn/es-query';
|
||||
import { checkEmptyValue } from '../check_empty_value';
|
||||
|
||||
import * as i18n from '../translations';
|
||||
|
@ -22,7 +22,7 @@ import * as i18n from '../translations';
|
|||
*/
|
||||
export const paramIsValid = (
|
||||
param: string | undefined,
|
||||
field: IndexPatternFieldBase | undefined,
|
||||
field: DataViewFieldBase | undefined,
|
||||
isRequired: boolean,
|
||||
touched: boolean
|
||||
): string | undefined => {
|
||||
|
|
|
@ -29,8 +29,8 @@ import {
|
|||
nestedEntryItem,
|
||||
} from '@kbn/securitysolution-io-ts-list-types';
|
||||
import {
|
||||
IndexPatternBase,
|
||||
IndexPatternFieldBase,
|
||||
DataViewBase,
|
||||
DataViewFieldBase,
|
||||
getDataViewFieldSubtypeNested,
|
||||
isDataViewFieldSubtypeNested,
|
||||
} from '@kbn/es-query';
|
||||
|
@ -283,17 +283,17 @@ export const getUpdatedEntriesOnDelete = (
|
|||
* add nested entry, should only show nested fields, if item is the parent
|
||||
* field of a nested entry, we only display the parent field
|
||||
*
|
||||
* @param patterns IndexPatternBase containing available fields on rule index
|
||||
* @param patterns DataViewBase containing available fields on rule index
|
||||
* @param item exception item entry
|
||||
* set to add a nested field
|
||||
*/
|
||||
export const getFilteredIndexPatterns = (
|
||||
patterns: IndexPatternBase,
|
||||
patterns: DataViewBase,
|
||||
item: FormattedBuilderEntry,
|
||||
type: ExceptionListType,
|
||||
preFilter?: (i: IndexPatternBase, t: ExceptionListType, o?: OsTypeArray) => IndexPatternBase,
|
||||
preFilter?: (i: DataViewBase, t: ExceptionListType, o?: OsTypeArray) => DataViewBase,
|
||||
osTypes?: OsTypeArray
|
||||
): IndexPatternBase => {
|
||||
): DataViewBase => {
|
||||
const indexPatterns = preFilter != null ? preFilter(patterns, type, osTypes) : patterns;
|
||||
|
||||
if (item.nested === 'child' && item.parent != null) {
|
||||
|
@ -338,7 +338,7 @@ export const getFilteredIndexPatterns = (
|
|||
*/
|
||||
export const getEntryOnFieldChange = (
|
||||
item: FormattedBuilderEntry,
|
||||
newField: IndexPatternFieldBase
|
||||
newField: DataViewFieldBase
|
||||
): { index: number; updatedEntry: BuilderEntry } => {
|
||||
const { parent, entryIndex, nested } = item;
|
||||
const newChildFieldValue = newField != null ? newField.name.split('.').slice(-1)[0] : '';
|
||||
|
@ -651,9 +651,9 @@ export const getCorrespondingKeywordField = ({
|
|||
fields,
|
||||
selectedField,
|
||||
}: {
|
||||
fields: IndexPatternFieldBase[];
|
||||
fields: DataViewFieldBase[];
|
||||
selectedField: string | undefined;
|
||||
}): IndexPatternFieldBase | undefined => {
|
||||
}): DataViewFieldBase | undefined => {
|
||||
const selectedFieldBits =
|
||||
selectedField != null && selectedField !== '' ? selectedField.split('.') : [];
|
||||
const selectedFieldIsTextType = selectedFieldBits.slice(-1)[0] === 'text';
|
||||
|
@ -673,7 +673,7 @@ export const getCorrespondingKeywordField = ({
|
|||
* Formats the entry into one that is easily usable for the UI, most of the
|
||||
* complexity was introduced with nested fields
|
||||
*
|
||||
* @param patterns IndexPatternBase containing available fields on rule index
|
||||
* @param patterns DataViewBase containing available fields on rule index
|
||||
* @param item exception item entry
|
||||
* @param itemIndex entry index
|
||||
* @param parent nested entries hold copy of their parent for use in various logic
|
||||
|
@ -681,7 +681,7 @@ export const getCorrespondingKeywordField = ({
|
|||
* was added to ensure that nested items could be identified with their parent entry
|
||||
*/
|
||||
export const getFormattedBuilderEntry = (
|
||||
indexPattern: IndexPatternBase,
|
||||
indexPattern: DataViewBase,
|
||||
item: BuilderEntry,
|
||||
itemIndex: number,
|
||||
parent: EntryNested | undefined,
|
||||
|
@ -727,7 +727,7 @@ export const getFormattedBuilderEntry = (
|
|||
* Formats the entries to be easily usable for the UI, most of the
|
||||
* complexity was introduced with nested fields
|
||||
*
|
||||
* @param patterns IndexPatternBase containing available fields on rule index
|
||||
* @param patterns DataViewBase containing available fields on rule index
|
||||
* @param entries exception item entries
|
||||
* @param addNested boolean noting whether or not UI is currently
|
||||
* set to add a nested field
|
||||
|
@ -736,7 +736,7 @@ export const getFormattedBuilderEntry = (
|
|||
* was added to ensure that nested items could be identified with their parent entry
|
||||
*/
|
||||
export const getFormattedBuilderEntries = (
|
||||
indexPattern: IndexPatternBase,
|
||||
indexPattern: DataViewBase,
|
||||
entries: BuilderEntry[],
|
||||
parent?: EntryNested,
|
||||
parentIndex?: number
|
||||
|
@ -758,14 +758,14 @@ export const getFormattedBuilderEntries = (
|
|||
entryIndex: index,
|
||||
field: isNewNestedEntry
|
||||
? undefined
|
||||
: // This type below is really a FieldSpec type from "src/plugins/data/common/index_patterns/fields/types.ts", we cast it here to keep using the IndexPatternFieldBase interface
|
||||
: // This type below is really a FieldSpec type from "src/plugins/data/common/index_patterns/fields/types.ts", we cast it here to keep using the DataViewFieldBase interface
|
||||
({
|
||||
aggregatable: false,
|
||||
esTypes: ['nested'],
|
||||
name: item.field != null ? item.field : '',
|
||||
searchable: false,
|
||||
type: 'string',
|
||||
} as IndexPatternFieldBase),
|
||||
} as DataViewFieldBase),
|
||||
id: item.id != null ? item.id : `${index}`,
|
||||
nested: 'parent',
|
||||
operator: isOperator,
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import { IndexPatternFieldBase } from '@kbn/es-query';
|
||||
import { DataViewFieldBase } from '@kbn/es-query';
|
||||
import type {
|
||||
CreateExceptionListItemSchema,
|
||||
Entry,
|
||||
|
@ -33,13 +33,13 @@ export interface OperatorOption {
|
|||
|
||||
export interface FormattedBuilderEntry {
|
||||
id: string;
|
||||
field: IndexPatternFieldBase | undefined;
|
||||
field: DataViewFieldBase | undefined;
|
||||
operator: OperatorOption;
|
||||
value: string | string[] | undefined;
|
||||
nested: 'parent' | 'child' | undefined;
|
||||
entryIndex: number;
|
||||
parent: { parent: BuilderEntryNested; parentIndex: number } | undefined;
|
||||
correspondingKeywordField: IndexPatternFieldBase | undefined;
|
||||
correspondingKeywordField: DataViewFieldBase | undefined;
|
||||
}
|
||||
|
||||
export interface EmptyEntry {
|
||||
|
|
|
@ -11,8 +11,8 @@ import { FilterManager } from '../filter_manager';
|
|||
|
||||
import {
|
||||
Filter,
|
||||
IndexPatternFieldBase,
|
||||
IndexPatternBase,
|
||||
DataViewFieldBase,
|
||||
DataViewBase,
|
||||
isExistsFilter,
|
||||
buildExistsFilter,
|
||||
isPhraseFilter,
|
||||
|
@ -25,7 +25,7 @@ const INDEX_NAME = 'my-index';
|
|||
const EXISTS_FIELD_NAME = '_exists_';
|
||||
const FIELD = {
|
||||
name: 'my-field',
|
||||
} as IndexPatternFieldBase;
|
||||
} as DataViewFieldBase;
|
||||
const PHRASE_VALUE = 'my-value';
|
||||
|
||||
describe('Generate filters', () => {
|
||||
|
@ -70,7 +70,7 @@ describe('Generate filters', () => {
|
|||
});
|
||||
|
||||
it('should update and re-enable EXISTING exists filter', () => {
|
||||
const filter = buildExistsFilter(FIELD, { id: INDEX_NAME } as IndexPatternBase);
|
||||
const filter = buildExistsFilter(FIELD, { id: INDEX_NAME } as DataViewBase);
|
||||
filter.meta.disabled = true;
|
||||
filtersArray.push(filter);
|
||||
|
||||
|
@ -113,7 +113,7 @@ describe('Generate filters', () => {
|
|||
{
|
||||
name: 'my-field',
|
||||
type: 'ip_range',
|
||||
} as IndexPatternFieldBase,
|
||||
} as DataViewFieldBase,
|
||||
{
|
||||
gt: '192.168.0.0',
|
||||
lte: '192.168.255.255',
|
||||
|
@ -140,7 +140,7 @@ describe('Generate filters', () => {
|
|||
{
|
||||
name: 'my-field',
|
||||
type: 'number_range',
|
||||
} as IndexPatternFieldBase,
|
||||
} as DataViewFieldBase,
|
||||
10000,
|
||||
'+',
|
||||
INDEX_NAME
|
||||
|
|
|
@ -6,10 +6,10 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import { IndexPatternFieldBase } from '@kbn/es-query';
|
||||
import { DataViewFieldBase } from '@kbn/es-query';
|
||||
import { IndexPatternField } from '../../../../../../plugins/data/public';
|
||||
|
||||
type IndexedFieldItemBase = Partial<IndexPatternField> & IndexPatternFieldBase;
|
||||
type IndexedFieldItemBase = Partial<IndexPatternField> & DataViewFieldBase;
|
||||
|
||||
export interface IndexedFieldItem extends IndexedFieldItemBase {
|
||||
info: string[];
|
||||
|
|
|
@ -154,12 +154,12 @@ const expectedIndexPatterns = {
|
|||
},
|
||||
};
|
||||
|
||||
type IndexPatternBaseState = Omit<
|
||||
type DataViewBaseState = Omit<
|
||||
IndexPatternPrivateState,
|
||||
'indexPatternRefs' | 'indexPatterns' | 'existingFields' | 'isFirstExistenceFetch'
|
||||
>;
|
||||
|
||||
function enrichBaseState(baseState: IndexPatternBaseState): IndexPatternPrivateState {
|
||||
function enrichBaseState(baseState: DataViewBaseState): IndexPatternPrivateState {
|
||||
return {
|
||||
currentIndexPatternId: baseState.currentIndexPatternId,
|
||||
layers: baseState.layers,
|
||||
|
@ -302,7 +302,7 @@ describe('IndexPattern Data Source', () => {
|
|||
});
|
||||
|
||||
it('should create a table when there is a formula without aggs', async () => {
|
||||
const queryBaseState: IndexPatternBaseState = {
|
||||
const queryBaseState: DataViewBaseState = {
|
||||
currentIndexPatternId: '1',
|
||||
layers: {
|
||||
first: {
|
||||
|
@ -340,7 +340,7 @@ describe('IndexPattern Data Source', () => {
|
|||
});
|
||||
|
||||
it('should generate an expression for an aggregated query', async () => {
|
||||
const queryBaseState: IndexPatternBaseState = {
|
||||
const queryBaseState: DataViewBaseState = {
|
||||
currentIndexPatternId: '1',
|
||||
layers: {
|
||||
first: {
|
||||
|
@ -490,7 +490,7 @@ describe('IndexPattern Data Source', () => {
|
|||
});
|
||||
|
||||
it('should put all time fields used in date_histograms to the esaggs timeFields parameter', async () => {
|
||||
const queryBaseState: IndexPatternBaseState = {
|
||||
const queryBaseState: DataViewBaseState = {
|
||||
currentIndexPatternId: '1',
|
||||
layers: {
|
||||
first: {
|
||||
|
@ -536,7 +536,7 @@ describe('IndexPattern Data Source', () => {
|
|||
});
|
||||
|
||||
it('should pass time shift parameter to metric agg functions', async () => {
|
||||
const queryBaseState: IndexPatternBaseState = {
|
||||
const queryBaseState: DataViewBaseState = {
|
||||
currentIndexPatternId: '1',
|
||||
layers: {
|
||||
first: {
|
||||
|
@ -573,7 +573,7 @@ describe('IndexPattern Data Source', () => {
|
|||
});
|
||||
|
||||
it('should wrap filtered metrics in filtered metric aggregation', async () => {
|
||||
const queryBaseState: IndexPatternBaseState = {
|
||||
const queryBaseState: DataViewBaseState = {
|
||||
currentIndexPatternId: '1',
|
||||
layers: {
|
||||
first: {
|
||||
|
@ -703,7 +703,7 @@ describe('IndexPattern Data Source', () => {
|
|||
});
|
||||
|
||||
it('should add time_scale and format function if time scale is set and supported', async () => {
|
||||
const queryBaseState: IndexPatternBaseState = {
|
||||
const queryBaseState: DataViewBaseState = {
|
||||
currentIndexPatternId: '1',
|
||||
layers: {
|
||||
first: {
|
||||
|
@ -786,7 +786,7 @@ describe('IndexPattern Data Source', () => {
|
|||
});
|
||||
|
||||
it('should put column formatters after calculated columns', async () => {
|
||||
const queryBaseState: IndexPatternBaseState = {
|
||||
const queryBaseState: DataViewBaseState = {
|
||||
currentIndexPatternId: '1',
|
||||
layers: {
|
||||
first: {
|
||||
|
@ -835,7 +835,7 @@ describe('IndexPattern Data Source', () => {
|
|||
});
|
||||
|
||||
it('should rename the output from esaggs when using flat query', () => {
|
||||
const queryBaseState: IndexPatternBaseState = {
|
||||
const queryBaseState: DataViewBaseState = {
|
||||
currentIndexPatternId: '1',
|
||||
layers: {
|
||||
first: {
|
||||
|
@ -887,7 +887,7 @@ describe('IndexPattern Data Source', () => {
|
|||
});
|
||||
|
||||
it('should not put date fields used outside date_histograms to the esaggs timeFields parameter', async () => {
|
||||
const queryBaseState: IndexPatternBaseState = {
|
||||
const queryBaseState: DataViewBaseState = {
|
||||
currentIndexPatternId: '1',
|
||||
layers: {
|
||||
first: {
|
||||
|
@ -937,7 +937,7 @@ describe('IndexPattern Data Source', () => {
|
|||
});
|
||||
|
||||
it('should collect expression references and append them', async () => {
|
||||
const queryBaseState: IndexPatternBaseState = {
|
||||
const queryBaseState: DataViewBaseState = {
|
||||
currentIndexPatternId: '1',
|
||||
layers: {
|
||||
first: {
|
||||
|
@ -972,7 +972,7 @@ describe('IndexPattern Data Source', () => {
|
|||
});
|
||||
|
||||
it('should keep correct column mapping keys with reference columns present', async () => {
|
||||
const queryBaseState: IndexPatternBaseState = {
|
||||
const queryBaseState: DataViewBaseState = {
|
||||
currentIndexPatternId: '1',
|
||||
layers: {
|
||||
first: {
|
||||
|
@ -1010,7 +1010,7 @@ describe('IndexPattern Data Source', () => {
|
|||
|
||||
it('should topologically sort references', () => {
|
||||
// This is a real example of count() + count()
|
||||
const queryBaseState: IndexPatternBaseState = {
|
||||
const queryBaseState: DataViewBaseState = {
|
||||
currentIndexPatternId: '1',
|
||||
layers: {
|
||||
first: {
|
||||
|
|
|
@ -110,7 +110,7 @@ export default {
|
|||
},
|
||||
indexPatterns: {
|
||||
description:
|
||||
'`IndexPatternBase` - index patterns used to populate field options and value autocomplete.',
|
||||
'`DataViewBase` - index patterns used to populate field options and value autocomplete.',
|
||||
type: {
|
||||
required: true,
|
||||
},
|
||||
|
@ -192,7 +192,7 @@ export default {
|
|||
},
|
||||
listTypeSpecificIndexPatternFilter: {
|
||||
description:
|
||||
'`(pattern: IndexPatternBase, type: ExceptionListType) => IndexPatternBase` - callback invoked when index patterns filtered. Optional to be used if you would only like certain fields displayed.',
|
||||
'`(pattern: DataViewBase, type: ExceptionListType) => DataViewBase` - callback invoked when index patterns filtered. Optional to be used if you would only like certain fields displayed.',
|
||||
type: {
|
||||
required: false,
|
||||
},
|
||||
|
|
|
@ -102,7 +102,7 @@ export default {
|
|||
},
|
||||
indexPattern: {
|
||||
description:
|
||||
'`IndexPatternBase` - index patterns used to populate field options and value autocomplete.',
|
||||
'`DataViewBase` - index patterns used to populate field options and value autocomplete.',
|
||||
type: {
|
||||
required: true,
|
||||
},
|
||||
|
|
|
@ -35,7 +35,7 @@ import {
|
|||
FieldComponent,
|
||||
OperatorComponent,
|
||||
} from '@kbn/securitysolution-autocomplete';
|
||||
import { IndexPatternBase, IndexPatternFieldBase } from '@kbn/es-query';
|
||||
import { DataViewBase, DataViewFieldBase } from '@kbn/es-query';
|
||||
|
||||
import type { AutocompleteStart } from '../../../../../../../src/plugins/data/public';
|
||||
import { HttpStart } from '../../../../../../../src/core/public';
|
||||
|
@ -52,15 +52,15 @@ export interface EntryItemProps {
|
|||
autocompleteService: AutocompleteStart;
|
||||
entry: FormattedBuilderEntry;
|
||||
httpService: HttpStart;
|
||||
indexPattern: IndexPatternBase;
|
||||
indexPattern: DataViewBase;
|
||||
showLabel: boolean;
|
||||
osTypes?: OsTypeArray;
|
||||
listType: ExceptionListType;
|
||||
listTypeSpecificIndexPatternFilter?: (
|
||||
pattern: IndexPatternBase,
|
||||
pattern: DataViewBase,
|
||||
type: ExceptionListType,
|
||||
osTypes?: OsTypeArray
|
||||
) => IndexPatternBase;
|
||||
) => DataViewBase;
|
||||
onChange: (arg: BuilderEntry, i: number) => void;
|
||||
onlyShowListOperators?: boolean;
|
||||
setErrorsExist: (arg: boolean) => void;
|
||||
|
@ -92,7 +92,7 @@ export const BuilderEntryItem: React.FC<EntryItemProps> = ({
|
|||
);
|
||||
|
||||
const handleFieldChange = useCallback(
|
||||
([newField]: IndexPatternFieldBase[]): void => {
|
||||
([newField]: DataViewFieldBase[]): void => {
|
||||
const { updatedEntry, index } = getEntryOnFieldChange(entry, newField);
|
||||
onChange(updatedEntry, index);
|
||||
},
|
||||
|
|
|
@ -19,7 +19,7 @@ import {
|
|||
getFormattedBuilderEntries,
|
||||
getUpdatedEntriesOnDelete,
|
||||
} from '@kbn/securitysolution-list-utils';
|
||||
import { IndexPatternBase } from '@kbn/es-query';
|
||||
import { DataViewBase } from '@kbn/es-query';
|
||||
|
||||
import { BuilderAndBadgeComponent } from './and_badge';
|
||||
import { BuilderEntryDeleteButtonComponent } from './entry_delete_button';
|
||||
|
@ -47,15 +47,15 @@ interface BuilderExceptionListItemProps {
|
|||
exceptionItem: ExceptionsBuilderExceptionItem;
|
||||
exceptionItemIndex: number;
|
||||
osTypes?: OsTypeArray;
|
||||
indexPattern: IndexPatternBase;
|
||||
indexPattern: DataViewBase;
|
||||
andLogicIncluded: boolean;
|
||||
isOnlyItem: boolean;
|
||||
listType: ExceptionListType;
|
||||
listTypeSpecificIndexPatternFilter?: (
|
||||
pattern: IndexPatternBase,
|
||||
pattern: DataViewBase,
|
||||
type: ExceptionListType,
|
||||
osTypes?: OsTypeArray
|
||||
) => IndexPatternBase;
|
||||
) => DataViewBase;
|
||||
onDeleteExceptionItem: (item: ExceptionsBuilderExceptionItem, index: number) => void;
|
||||
onChangeExceptionItem: (item: ExceptionsBuilderExceptionItem, index: number) => void;
|
||||
setErrorsExist: (arg: boolean) => void;
|
||||
|
|
|
@ -31,7 +31,7 @@ import {
|
|||
getDefaultNestedEmptyEntry,
|
||||
getNewExceptionItem,
|
||||
} from '@kbn/securitysolution-list-utils';
|
||||
import { IndexPatternBase } from '@kbn/es-query';
|
||||
import { DataViewBase } from '@kbn/es-query';
|
||||
|
||||
import type { AutocompleteStart } from '../../../../../../../src/plugins/data/public';
|
||||
import { AndOrBadge } from '../and_or_badge';
|
||||
|
@ -77,7 +77,7 @@ export interface ExceptionBuilderProps {
|
|||
exceptionListItems: ExceptionsBuilderExceptionItem[];
|
||||
httpService: HttpStart;
|
||||
osTypes?: OsTypeArray;
|
||||
indexPatterns: IndexPatternBase;
|
||||
indexPatterns: DataViewBase;
|
||||
isAndDisabled: boolean;
|
||||
isNestedDisabled: boolean;
|
||||
isOrDisabled: boolean;
|
||||
|
@ -86,9 +86,9 @@ export interface ExceptionBuilderProps {
|
|||
listNamespaceType: NamespaceType;
|
||||
listType: ExceptionListType;
|
||||
listTypeSpecificIndexPatternFilter?: (
|
||||
pattern: IndexPatternBase,
|
||||
pattern: DataViewBase,
|
||||
type: ExceptionListType
|
||||
) => IndexPatternBase;
|
||||
) => DataViewBase;
|
||||
onChange: (arg: OnChangeProps) => void;
|
||||
ruleName: string;
|
||||
isDisabled?: boolean;
|
||||
|
|
|
@ -52,7 +52,7 @@ import {
|
|||
isOneOfOperator,
|
||||
isOperator,
|
||||
} from '@kbn/securitysolution-list-utils';
|
||||
import { IndexPatternBase, IndexPatternFieldBase } from '@kbn/es-query';
|
||||
import { DataViewBase, DataViewFieldBase } from '@kbn/es-query';
|
||||
|
||||
import { ENTRIES_WITH_IDS } from '../../../../common/constants.mock';
|
||||
import { getEntryExistsMock } from '../../../../common/schemas/types/entry_exists.mock';
|
||||
|
@ -91,7 +91,7 @@ const getEntryMatchAnyWithIdMock = (): EntryMatchAny & { id: string } => ({
|
|||
id: '123',
|
||||
});
|
||||
|
||||
const getMockIndexPattern = (): IndexPatternBase => ({
|
||||
const getMockIndexPattern = (): DataViewBase => ({
|
||||
fields,
|
||||
id: '1234',
|
||||
title: 'logstash-*',
|
||||
|
@ -165,13 +165,10 @@ const mockEndpointFields = [
|
|||
},
|
||||
];
|
||||
|
||||
export const getEndpointField = (name: string): IndexPatternFieldBase =>
|
||||
mockEndpointFields.find((field) => field.name === name) as IndexPatternFieldBase;
|
||||
export const getEndpointField = (name: string): DataViewFieldBase =>
|
||||
mockEndpointFields.find((field) => field.name === name) as DataViewFieldBase;
|
||||
|
||||
const filterIndexPatterns = (
|
||||
patterns: IndexPatternBase,
|
||||
type: ExceptionListType
|
||||
): IndexPatternBase => {
|
||||
const filterIndexPatterns = (patterns: DataViewBase, type: ExceptionListType): DataViewBase => {
|
||||
return type === 'endpoint'
|
||||
? {
|
||||
...patterns,
|
||||
|
@ -189,7 +186,7 @@ describe('Exception builder helpers', () => {
|
|||
const payloadIndexPattern = getMockIndexPattern();
|
||||
const payloadItem: FormattedBuilderEntry = getMockNestedBuilderEntry();
|
||||
const output = getFilteredIndexPatterns(payloadIndexPattern, payloadItem, 'detection');
|
||||
const expected: IndexPatternBase = {
|
||||
const expected: DataViewBase = {
|
||||
fields: [{ ...getField('nestedField.child'), name: 'child' }],
|
||||
id: '1234',
|
||||
title: 'logstash-*',
|
||||
|
@ -201,7 +198,7 @@ describe('Exception builder helpers', () => {
|
|||
const payloadIndexPattern = getMockIndexPattern();
|
||||
const payloadItem: FormattedBuilderEntry = getMockNestedParentBuilderEntry();
|
||||
const output = getFilteredIndexPatterns(payloadIndexPattern, payloadItem, 'detection');
|
||||
const expected: IndexPatternBase & { fields: Array<Partial<FieldSpec>> } = {
|
||||
const expected: DataViewBase & { fields: Array<Partial<FieldSpec>> } = {
|
||||
fields: [{ ...getField('nestedField.child'), esTypes: ['nested'], name: 'nestedField' }],
|
||||
id: '1234',
|
||||
title: 'logstash-*',
|
||||
|
@ -216,7 +213,7 @@ describe('Exception builder helpers', () => {
|
|||
field: undefined,
|
||||
};
|
||||
const output = getFilteredIndexPatterns(payloadIndexPattern, payloadItem, 'detection');
|
||||
const expected: IndexPatternBase = {
|
||||
const expected: DataViewBase = {
|
||||
fields: [
|
||||
{ ...getField('nestedField.child') },
|
||||
{ ...getField('nestedField.nestedChild.doublyNestedChild') },
|
||||
|
@ -231,7 +228,7 @@ describe('Exception builder helpers', () => {
|
|||
const payloadIndexPattern = getMockIndexPattern();
|
||||
const payloadItem: FormattedBuilderEntry = getMockBuilderEntry();
|
||||
const output = getFilteredIndexPatterns(payloadIndexPattern, payloadItem, 'detection');
|
||||
const expected: IndexPatternBase = {
|
||||
const expected: DataViewBase = {
|
||||
fields: [...fields],
|
||||
id: '1234',
|
||||
title: 'logstash-*',
|
||||
|
@ -269,7 +266,7 @@ describe('Exception builder helpers', () => {
|
|||
value: 'some value',
|
||||
};
|
||||
const output = getFilteredIndexPatterns(payloadIndexPattern, payloadItem, 'endpoint');
|
||||
const expected: IndexPatternBase = {
|
||||
const expected: DataViewBase = {
|
||||
fields: [{ ...getEndpointField('file.Ext.code_signature.status'), name: 'status' }],
|
||||
id: '1234',
|
||||
title: 'logstash-*',
|
||||
|
@ -305,7 +302,7 @@ describe('Exception builder helpers', () => {
|
|||
type: 'string',
|
||||
},
|
||||
];
|
||||
const expected: IndexPatternBase = {
|
||||
const expected: DataViewBase = {
|
||||
fields: fieldsExpected,
|
||||
id: '1234',
|
||||
title: 'logstash-*',
|
||||
|
@ -324,7 +321,7 @@ describe('Exception builder helpers', () => {
|
|||
'endpoint',
|
||||
filterIndexPatterns
|
||||
);
|
||||
const expected: IndexPatternBase = {
|
||||
const expected: DataViewBase = {
|
||||
fields: [getEndpointField('file.Ext.code_signature.status')],
|
||||
id: '1234',
|
||||
title: 'logstash-*',
|
||||
|
@ -363,7 +360,7 @@ describe('Exception builder helpers', () => {
|
|||
type: 'string',
|
||||
},
|
||||
];
|
||||
const expected: IndexPatternBase = {
|
||||
const expected: DataViewBase = {
|
||||
fields: fieldsExpected,
|
||||
id: '1234',
|
||||
title: 'logstash-*',
|
||||
|
@ -1261,7 +1258,7 @@ describe('Exception builder helpers', () => {
|
|||
|
||||
describe('#getFormattedBuilderEntry', () => {
|
||||
test('it returns entry with a value for "correspondingKeywordField" when "item.field" is of type "text" and matching keyword field exists', () => {
|
||||
const payloadIndexPattern: IndexPatternBase = {
|
||||
const payloadIndexPattern: DataViewBase = {
|
||||
...getMockIndexPattern(),
|
||||
fields: [
|
||||
...fields,
|
||||
|
|
|
@ -12,7 +12,7 @@ import {
|
|||
toElasticsearchQuery,
|
||||
buildEsQuery,
|
||||
buildQueryFromFilters,
|
||||
IndexPatternBase,
|
||||
DataViewBase,
|
||||
} from '@kbn/es-query';
|
||||
import { IUiSettingsClient } from 'kibana/public';
|
||||
import { getEsQueryConfig } from '../../../../../../../../src/plugins/data/public';
|
||||
|
@ -38,7 +38,7 @@ export function getDefaultDatafeedQuery() {
|
|||
|
||||
export function createSearchItems(
|
||||
kibanaConfig: IUiSettingsClient,
|
||||
indexPattern: IndexPatternBase | undefined,
|
||||
indexPattern: DataViewBase | undefined,
|
||||
savedSearch: SavedSearchSavedObject | null
|
||||
) {
|
||||
// query is only used by the data visualizer as it needs
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
import { IndexPatternBase } from '@kbn/es-query';
|
||||
import { DataViewBase } from '@kbn/es-query';
|
||||
import React, { useMemo, useState } from 'react';
|
||||
import { SearchBar, TimeHistory } from '../../../../../../../src/plugins/data/public';
|
||||
import { Storage } from '../../../../../../../src/plugins/kibana_utils/public';
|
||||
|
@ -20,7 +20,7 @@ export function AlertsSearchBar({
|
|||
onQueryChange,
|
||||
query,
|
||||
}: {
|
||||
dynamicIndexPatterns: IndexPatternBase[];
|
||||
dynamicIndexPatterns: DataViewBase[];
|
||||
rangeFrom?: string;
|
||||
rangeTo?: string;
|
||||
query?: string;
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
import { EuiButtonEmpty, EuiFlexGroup, EuiFlexItem, EuiStat } from '@elastic/eui';
|
||||
|
||||
import { IndexPatternBase } from '@kbn/es-query';
|
||||
import { DataViewBase } from '@kbn/es-query';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
||||
import useAsync from 'react-use/lib/useAsync';
|
||||
|
@ -57,7 +57,7 @@ const Divider = euiStyled.div`
|
|||
|
||||
const regExpEscape = (str: string) => str.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
|
||||
const NO_INDEX_NAMES: string[] = [];
|
||||
const NO_INDEX_PATTERNS: IndexPatternBase[] = [];
|
||||
const NO_INDEX_PATTERNS: DataViewBase[] = [];
|
||||
const BASE_ALERT_REGEX = new RegExp(`\\s*${regExpEscape(ALERT_STATUS)}\\s*:\\s*"(.*?|\\*?)"`);
|
||||
const ALERT_STATUS_REGEX = new RegExp(
|
||||
`\\s*and\\s*${regExpEscape(ALERT_STATUS)}\\s*:\\s*(".+?"|\\*?)|${regExpEscape(
|
||||
|
@ -157,7 +157,7 @@ function AlertsPage() {
|
|||
});
|
||||
}, []);
|
||||
|
||||
const dynamicIndexPatternsAsyncState = useAsync(async (): Promise<IndexPatternBase[]> => {
|
||||
const dynamicIndexPatternsAsyncState = useAsync(async (): Promise<DataViewBase[]> => {
|
||||
if (indexNames.length === 0) {
|
||||
return [];
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ import {
|
|||
fromKueryExpression,
|
||||
toElasticsearchQuery,
|
||||
luceneStringToDsl,
|
||||
IndexPatternBase,
|
||||
DataViewBase,
|
||||
Query,
|
||||
} from '@kbn/es-query';
|
||||
|
||||
|
@ -23,7 +23,7 @@ const MAX_TOP_LEVEL_QUERY_SIZE = 0;
|
|||
const MAX_SHAPES_QUERY_SIZE = 10000;
|
||||
const MAX_BUCKETS_LIMIT = 65535;
|
||||
|
||||
export const getEsFormattedQuery = (query: Query, indexPattern?: IndexPatternBase) => {
|
||||
export const getEsFormattedQuery = (query: Query, indexPattern?: DataViewBase) => {
|
||||
let esFormattedQuery;
|
||||
|
||||
const queryLanguage = query.language;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue