mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 09:19:04 -04:00
* Explicit namespaces for esQuery and esQuery * Remove unnecessary file from siem * remove jsonvalue definition from siem * server FieldFormatsRegistry, Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com> Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
This commit is contained in:
parent
5d3922fb9e
commit
47cb2d15fd
33 changed files with 194 additions and 137 deletions
|
@ -21,7 +21,7 @@ import { get, set } from 'lodash';
|
|||
import { SavedObjectsErrorHelpers } from './errors';
|
||||
import { IndexMapping } from '../../mappings';
|
||||
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
|
||||
import { esKuery } from '../../../../../plugins/data/server';
|
||||
import { esKuery, KueryNode } from '../../../../../plugins/data/server';
|
||||
|
||||
const astFunctionType = ['is', 'range', 'nested'];
|
||||
|
||||
|
@ -29,7 +29,7 @@ export const validateConvertFilterToKueryNode = (
|
|||
allowedTypes: string[],
|
||||
filter: string,
|
||||
indexMapping: IndexMapping
|
||||
): esKuery.KueryNode | undefined => {
|
||||
): KueryNode | undefined => {
|
||||
if (filter && filter.length > 0 && indexMapping) {
|
||||
const filterKueryNode = esKuery.fromKueryExpression(filter);
|
||||
|
||||
|
@ -59,7 +59,7 @@ export const validateConvertFilterToKueryNode = (
|
|||
|
||||
validationFilterKuery.forEach(item => {
|
||||
const path: string[] = item.astPath.length === 0 ? [] : item.astPath.split('.');
|
||||
const existingKueryNode: esKuery.KueryNode =
|
||||
const existingKueryNode: KueryNode =
|
||||
path.length === 0 ? filterKueryNode : get(filterKueryNode, path);
|
||||
if (item.isSavedObjectAttr) {
|
||||
existingKueryNode.arguments[0].value = existingKueryNode.arguments[0].value.split('.')[1];
|
||||
|
@ -95,7 +95,7 @@ interface ValidateFilterKueryNode {
|
|||
}
|
||||
|
||||
interface ValidateFilterKueryNodeParams {
|
||||
astFilter: esKuery.KueryNode;
|
||||
astFilter: KueryNode;
|
||||
types: string[];
|
||||
indexMapping: IndexMapping;
|
||||
hasNestedKey?: boolean;
|
||||
|
@ -114,50 +114,47 @@ export const validateFilterKueryNode = ({
|
|||
path = 'arguments',
|
||||
}: ValidateFilterKueryNodeParams): ValidateFilterKueryNode[] => {
|
||||
let localNestedKeys: string | undefined;
|
||||
return astFilter.arguments.reduce(
|
||||
(kueryNode: string[], ast: esKuery.KueryNode, index: number) => {
|
||||
if (hasNestedKey && ast.type === 'literal' && ast.value != null) {
|
||||
localNestedKeys = ast.value;
|
||||
}
|
||||
if (ast.arguments) {
|
||||
const myPath = `${path}.${index}`;
|
||||
return [
|
||||
...kueryNode,
|
||||
...validateFilterKueryNode({
|
||||
astFilter: ast,
|
||||
return astFilter.arguments.reduce((kueryNode: string[], ast: KueryNode, index: number) => {
|
||||
if (hasNestedKey && ast.type === 'literal' && ast.value != null) {
|
||||
localNestedKeys = ast.value;
|
||||
}
|
||||
if (ast.arguments) {
|
||||
const myPath = `${path}.${index}`;
|
||||
return [
|
||||
...kueryNode,
|
||||
...validateFilterKueryNode({
|
||||
astFilter: ast,
|
||||
types,
|
||||
indexMapping,
|
||||
storeValue: ast.type === 'function' && astFunctionType.includes(ast.function),
|
||||
path: `${myPath}.arguments`,
|
||||
hasNestedKey: ast.type === 'function' && ast.function === 'nested',
|
||||
nestedKeys: localNestedKeys,
|
||||
}),
|
||||
];
|
||||
}
|
||||
if (storeValue && index === 0) {
|
||||
const splitPath = path.split('.');
|
||||
return [
|
||||
...kueryNode,
|
||||
{
|
||||
astPath: splitPath.slice(0, splitPath.length - 1).join('.'),
|
||||
error: hasFilterKeyError(
|
||||
nestedKeys != null ? `${nestedKeys}.${ast.value}` : ast.value,
|
||||
types,
|
||||
indexMapping,
|
||||
storeValue: ast.type === 'function' && astFunctionType.includes(ast.function),
|
||||
path: `${myPath}.arguments`,
|
||||
hasNestedKey: ast.type === 'function' && ast.function === 'nested',
|
||||
nestedKeys: localNestedKeys,
|
||||
}),
|
||||
];
|
||||
}
|
||||
if (storeValue && index === 0) {
|
||||
const splitPath = path.split('.');
|
||||
return [
|
||||
...kueryNode,
|
||||
{
|
||||
astPath: splitPath.slice(0, splitPath.length - 1).join('.'),
|
||||
error: hasFilterKeyError(
|
||||
nestedKeys != null ? `${nestedKeys}.${ast.value}` : ast.value,
|
||||
types,
|
||||
indexMapping
|
||||
),
|
||||
isSavedObjectAttr: isSavedObjectAttr(
|
||||
nestedKeys != null ? `${nestedKeys}.${ast.value}` : ast.value,
|
||||
indexMapping
|
||||
),
|
||||
key: nestedKeys != null ? `${nestedKeys}.${ast.value}` : ast.value,
|
||||
type: getType(nestedKeys != null ? `${nestedKeys}.${ast.value}` : ast.value),
|
||||
},
|
||||
];
|
||||
}
|
||||
return kueryNode;
|
||||
},
|
||||
[]
|
||||
);
|
||||
indexMapping
|
||||
),
|
||||
isSavedObjectAttr: isSavedObjectAttr(
|
||||
nestedKeys != null ? `${nestedKeys}.${ast.value}` : ast.value,
|
||||
indexMapping
|
||||
),
|
||||
key: nestedKeys != null ? `${nestedKeys}.${ast.value}` : ast.value,
|
||||
type: getType(nestedKeys != null ? `${nestedKeys}.${ast.value}` : ast.value),
|
||||
},
|
||||
];
|
||||
}
|
||||
return kueryNode;
|
||||
}, []);
|
||||
};
|
||||
|
||||
const getType = (key: string | undefined | null) =>
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
|
||||
import { esKuery } from '../../../../../../plugins/data/server';
|
||||
import { esKuery, KueryNode } from '../../../../../../plugins/data/server';
|
||||
|
||||
import { getRootPropertiesObjects, IndexMapping } from '../../../mappings';
|
||||
import { ISavedObjectTypeRegistry } from '../../../saved_objects_type_registry';
|
||||
|
@ -96,7 +96,7 @@ interface QueryParams {
|
|||
searchFields?: string[];
|
||||
defaultSearchOperator?: string;
|
||||
hasReference?: HasReferenceQueryParams;
|
||||
kueryNode?: esKuery.KueryNode;
|
||||
kueryNode?: KueryNode;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -23,7 +23,7 @@ import { IndexMapping } from '../../../mappings';
|
|||
import { getQueryParams } from './query_params';
|
||||
import { getSortingParams } from './sorting_params';
|
||||
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
|
||||
import { esKuery } from '../../../../../../plugins/data/server';
|
||||
import { KueryNode } from '../../../../../../plugins/data/server';
|
||||
import { ISavedObjectTypeRegistry } from '../../../saved_objects_type_registry';
|
||||
|
||||
interface GetSearchDslOptions {
|
||||
|
@ -38,7 +38,7 @@ interface GetSearchDslOptions {
|
|||
type: string;
|
||||
id: string;
|
||||
};
|
||||
kueryNode?: esKuery.KueryNode;
|
||||
kueryNode?: KueryNode;
|
||||
}
|
||||
|
||||
export function getSearchDsl(
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
import * as esQuery from './es_query';
|
||||
export * from './es_query';
|
||||
import * as esFilters from './filters';
|
||||
import * as esKuery from './kuery';
|
||||
export * from './kuery';
|
||||
|
||||
export { esFilters, esQuery, esKuery };
|
||||
export { esFilters };
|
||||
|
|
|
@ -19,11 +19,12 @@
|
|||
|
||||
import { nodeTypes } from '../node_types/index';
|
||||
import { KQLSyntaxError } from '../kuery_syntax_error';
|
||||
import { KueryNode, JsonObject, DslQuery, KueryParseOptions } from '../types';
|
||||
import { KueryNode, DslQuery, KueryParseOptions } from '../types';
|
||||
import { IIndexPattern } from '../../../index_patterns/types';
|
||||
|
||||
// @ts-ignore
|
||||
import { parse as parseKuery } from './_generated_/kuery';
|
||||
import { JsonObject } from '../../../../../kibana_utils/public';
|
||||
|
||||
const fromExpression = (
|
||||
expression: string | DslQuery,
|
||||
|
|
|
@ -20,21 +20,21 @@
|
|||
import { repeat } from 'lodash';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
|
||||
const endOfInputText = i18n.translate('data.common.esQuery.kql.errors.endOfInputText', {
|
||||
const endOfInputText = i18n.translate('data.common.kql.errors.endOfInputText', {
|
||||
defaultMessage: 'end of input',
|
||||
});
|
||||
|
||||
const grammarRuleTranslations: Record<string, string> = {
|
||||
fieldName: i18n.translate('data.common.esQuery.kql.errors.fieldNameText', {
|
||||
fieldName: i18n.translate('data.common.kql.errors.fieldNameText', {
|
||||
defaultMessage: 'field name',
|
||||
}),
|
||||
value: i18n.translate('data.common.esQuery.kql.errors.valueText', {
|
||||
value: i18n.translate('data.common.kql.errors.valueText', {
|
||||
defaultMessage: 'value',
|
||||
}),
|
||||
literal: i18n.translate('data.common.esQuery.kql.errors.literalText', {
|
||||
literal: i18n.translate('data.common.kql.errors.literalText', {
|
||||
defaultMessage: 'literal',
|
||||
}),
|
||||
whitespace: i18n.translate('data.common.esQuery.kql.errors.whitespaceText', {
|
||||
whitespace: i18n.translate('data.common.kql.errors.whitespaceText', {
|
||||
defaultMessage: 'whitespace',
|
||||
}),
|
||||
};
|
||||
|
@ -61,7 +61,7 @@ export class KQLSyntaxError extends Error {
|
|||
|
||||
const translatedExpectationText = translatedExpectations.join(', ');
|
||||
|
||||
message = i18n.translate('data.common.esQuery.kql.errors.syntaxError', {
|
||||
message = i18n.translate('data.common.kql.errors.syntaxError', {
|
||||
defaultMessage: 'Expected {expectedList} but {foundInput} found.',
|
||||
values: {
|
||||
expectedList: translatedExpectationText,
|
||||
|
|
|
@ -22,7 +22,7 @@ import _ from 'lodash';
|
|||
import { functions } from '../functions';
|
||||
import { IIndexPattern } from '../../..';
|
||||
import { FunctionName, FunctionTypeBuildNode } from './types';
|
||||
import { JsonValue } from '..';
|
||||
import { JsonValue } from '../../../../../kibana_utils/public';
|
||||
|
||||
export function buildNode(functionName: FunctionName, ...args: any[]) {
|
||||
const kueryFunction = functions[functionName];
|
||||
|
|
|
@ -21,7 +21,7 @@ import _ from 'lodash';
|
|||
import * as ast from '../ast';
|
||||
import { nodeTypes } from '../node_types';
|
||||
import { NamedArgTypeBuildNode } from './types';
|
||||
import { JsonObject } from '../types';
|
||||
import { JsonObject } from '../../../../../kibana_utils/public';
|
||||
|
||||
export function buildNode(name: string, value: any): NamedArgTypeBuildNode {
|
||||
const argumentNode =
|
||||
|
|
|
@ -22,7 +22,8 @@
|
|||
*/
|
||||
|
||||
import { IIndexPattern } from '../../../index_patterns';
|
||||
import { JsonValue, KueryNode } from '..';
|
||||
import { JsonValue } from '../../../../../kibana_utils/public';
|
||||
import { KueryNode } from '..';
|
||||
|
||||
export type FunctionName =
|
||||
| 'is'
|
||||
|
|
|
@ -38,10 +38,3 @@ export interface KueryParseOptions {
|
|||
}
|
||||
|
||||
export { nodeTypes } from './node_types';
|
||||
|
||||
export type JsonArray = JsonValue[];
|
||||
export type JsonValue = null | boolean | number | string | JsonObject | JsonArray;
|
||||
|
||||
export interface JsonObject {
|
||||
[key: string]: JsonValue;
|
||||
}
|
||||
|
|
|
@ -19,13 +19,44 @@
|
|||
|
||||
import { PluginInitializerContext } from '../../../core/public';
|
||||
|
||||
/*
|
||||
* esQuery and esKuery helper namespaces:
|
||||
*/
|
||||
|
||||
import {
|
||||
doesKueryExpressionHaveLuceneSyntaxError,
|
||||
fromKueryExpression,
|
||||
toElasticsearchQuery,
|
||||
nodeTypes,
|
||||
buildEsQuery,
|
||||
getEsQueryConfig,
|
||||
buildQueryFromFilters,
|
||||
luceneStringToDsl,
|
||||
decorateQuery,
|
||||
} from '../common';
|
||||
|
||||
export const esKuery = {
|
||||
nodeTypes,
|
||||
doesKueryExpressionHaveLuceneSyntaxError,
|
||||
fromKueryExpression,
|
||||
toElasticsearchQuery,
|
||||
};
|
||||
|
||||
export const esQuery = {
|
||||
buildEsQuery,
|
||||
getEsQueryConfig,
|
||||
buildQueryFromFilters,
|
||||
luceneStringToDsl,
|
||||
decorateQuery,
|
||||
};
|
||||
|
||||
/*
|
||||
* Field Formatters helper namespace:
|
||||
*/
|
||||
|
||||
import {
|
||||
FieldFormat,
|
||||
FieldFormatsRegistry, // exported only for tests. Consider mock.
|
||||
FieldFormatsRegistry,
|
||||
DEFAULT_CONVERTER_COLOR,
|
||||
HTML_CONTEXT_TYPE,
|
||||
TEXT_CONTEXT_TYPE,
|
||||
|
@ -84,6 +115,7 @@ export function plugin(initializerContext: PluginInitializerContext) {
|
|||
export { IRequestTypesMap, IResponseTypesMap } from './search';
|
||||
export * from './types';
|
||||
export {
|
||||
EsQueryConfig,
|
||||
// index patterns
|
||||
IIndexPattern,
|
||||
IFieldType,
|
||||
|
@ -123,8 +155,7 @@ export * from './field_formats';
|
|||
export {
|
||||
// es query
|
||||
esFilters,
|
||||
esKuery,
|
||||
esQuery,
|
||||
KueryNode,
|
||||
// index patterns
|
||||
isFilterable,
|
||||
// kbn field types
|
||||
|
|
|
@ -73,12 +73,15 @@ import _ from 'lodash';
|
|||
import { normalizeSortRequest } from './normalize_sort_request';
|
||||
import { filterDocvalueFields } from './filter_docvalue_fields';
|
||||
import { fieldWildcardFilter } from '../../../../kibana_utils/public';
|
||||
import { esFilters, esQuery, SearchRequest } from '../..';
|
||||
|
||||
import { esFilters, SearchRequest } from '../..';
|
||||
|
||||
import { SearchSourceOptions, SearchSourceFields } from './types';
|
||||
import { fetchSoon, FetchOptions, RequestFailure } from '../fetch';
|
||||
|
||||
import { getSearchService, getUiSettings, getInjectedMetadata } from '../../services';
|
||||
import { getHighlightRequest } from '../../../common';
|
||||
import { getEsQueryConfig, buildEsQuery } from '../../../common/es_query';
|
||||
import { getHighlightRequest } from '../../../common/field_formats';
|
||||
|
||||
export type ISearchSource = Pick<SearchSource, keyof SearchSource>;
|
||||
|
||||
|
@ -379,8 +382,8 @@ export class SearchSource {
|
|||
_.set(body, '_source.includes', remainingFields);
|
||||
}
|
||||
|
||||
const esQueryConfigs = esQuery.getEsQueryConfig(getUiSettings());
|
||||
body.query = esQuery.buildEsQuery(index, query, filters, esQueryConfigs);
|
||||
const esQueryConfigs = getEsQueryConfig(getUiSettings());
|
||||
body.query = buildEsQuery(index, query, filters, esQueryConfigs);
|
||||
|
||||
if (highlightAll && body.query) {
|
||||
body.highlight = getHighlightRequest(body.query, getUiSettings().get('doc_table:highlight'));
|
||||
|
|
|
@ -41,10 +41,10 @@ import {
|
|||
Query,
|
||||
PersistedLog,
|
||||
getQueryLog,
|
||||
esKuery,
|
||||
} from '../..';
|
||||
import { useKibana, toMountPoint } from '../../../../kibana_react/public';
|
||||
import { QueryStringInput } from './query_string_input';
|
||||
import { doesKueryExpressionHaveLuceneSyntaxError } from '../../../common';
|
||||
|
||||
interface Props {
|
||||
query?: Query;
|
||||
|
@ -298,7 +298,7 @@ function QueryBarTopRowUI(props: Props) {
|
|||
language === 'kuery' &&
|
||||
typeof query === 'string' &&
|
||||
(!storage || !storage.get('kibana.luceneSyntaxWarningOptOut')) &&
|
||||
esKuery.doesKueryExpressionHaveLuceneSyntaxError(query)
|
||||
doesKueryExpressionHaveLuceneSyntaxError(query)
|
||||
) {
|
||||
const toast = notifications!.toasts.addWarning({
|
||||
title: intl.formatMessage({
|
||||
|
|
|
@ -20,13 +20,36 @@
|
|||
import { PluginInitializerContext } from '../../../core/server';
|
||||
import { DataServerPlugin, DataPluginSetup, DataPluginStart } from './plugin';
|
||||
|
||||
/*
|
||||
* esQuery and esKuery helper namespaces:
|
||||
*/
|
||||
|
||||
import {
|
||||
nodeTypes,
|
||||
fromKueryExpression,
|
||||
toElasticsearchQuery,
|
||||
buildEsQuery,
|
||||
getEsQueryConfig,
|
||||
} from '../common';
|
||||
|
||||
export const esKuery = {
|
||||
nodeTypes,
|
||||
fromKueryExpression,
|
||||
toElasticsearchQuery,
|
||||
};
|
||||
|
||||
export const esQuery = {
|
||||
getEsQueryConfig,
|
||||
buildEsQuery,
|
||||
};
|
||||
|
||||
/*
|
||||
* Field Formatters helper namespace:
|
||||
*/
|
||||
|
||||
import {
|
||||
FieldFormatsRegistry,
|
||||
FieldFormat,
|
||||
FieldFormatsRegistry, // exported only for tests. Consider mock.
|
||||
BoolFormat,
|
||||
BytesFormat,
|
||||
ColorFormat,
|
||||
|
@ -45,8 +68,8 @@ import {
|
|||
} from '../common/field_formats';
|
||||
|
||||
export const fieldFormats = {
|
||||
FieldFormatsRegistry,
|
||||
FieldFormat,
|
||||
FieldFormatsRegistry, // exported only for tests. Consider mock.
|
||||
|
||||
BoolFormat,
|
||||
BytesFormat,
|
||||
|
@ -75,10 +98,10 @@ export function plugin(initializerContext: PluginInitializerContext) {
|
|||
export { IRequestTypesMap, IResponseTypesMap } from './search';
|
||||
|
||||
export {
|
||||
EsQueryConfig,
|
||||
// es query
|
||||
esFilters,
|
||||
esKuery,
|
||||
esQuery,
|
||||
KueryNode,
|
||||
// kbn field types
|
||||
castEsToKbnFieldTypeName,
|
||||
getKbnFieldType,
|
||||
|
|
|
@ -21,5 +21,6 @@ export * from './defer';
|
|||
export * from './of';
|
||||
export * from './ui';
|
||||
export * from './state_containers';
|
||||
export * from './typed_json';
|
||||
export { createGetterSetter, Get, Set } from './create_getter_setter';
|
||||
export { distinctUntilChangedWithInitialValue } from './distinct_until_changed_with_initial_value';
|
||||
|
|
27
src/plugins/kibana_utils/common/typed_json.ts
Normal file
27
src/plugins/kibana_utils/common/typed_json.ts
Normal file
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
export type JsonValue = null | boolean | number | string | JsonObject | JsonArray;
|
||||
|
||||
export interface JsonObject {
|
||||
[key: string]: JsonValue;
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
||||
export interface JsonArray extends Array<JsonValue> {}
|
|
@ -26,6 +26,9 @@ export {
|
|||
Set,
|
||||
UiComponent,
|
||||
UiComponentInstance,
|
||||
JsonValue,
|
||||
JsonObject,
|
||||
JsonArray,
|
||||
} from '../common';
|
||||
export * from './core';
|
||||
export * from './errors';
|
||||
|
|
|
@ -6,15 +6,7 @@
|
|||
|
||||
import { FontawesomeIcon } from '../helpers/style_choices';
|
||||
import { WorkspaceField, AdvancedSettings } from './app_state';
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
||||
interface JsonArray extends Array<JsonValue> {}
|
||||
|
||||
type JsonValue = null | boolean | number | string | JsonObject | JsonArray;
|
||||
|
||||
interface JsonObject {
|
||||
[key: string]: JsonValue;
|
||||
}
|
||||
import { JsonObject } from '../../../../../../src/plugins/kibana_utils/public';
|
||||
|
||||
export interface WorkspaceNode {
|
||||
x: number;
|
||||
|
|
|
@ -26,6 +26,7 @@ import { getFilters } from './get_filters';
|
|||
|
||||
import {
|
||||
esQuery,
|
||||
EsQueryConfig,
|
||||
esFilters,
|
||||
IIndexPattern,
|
||||
Query,
|
||||
|
@ -45,7 +46,7 @@ const getEsQueryConfig = async (config: any) => {
|
|||
allowLeadingWildcards,
|
||||
queryStringOptions,
|
||||
ignoreFilterIfFieldNotInIndex,
|
||||
} as esQuery.EsQueryConfig;
|
||||
} as EsQueryConfig;
|
||||
};
|
||||
|
||||
const getUiSettings = async (config: any) => {
|
||||
|
|
|
@ -3,15 +3,7 @@
|
|||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
export type JsonValue = null | boolean | number | string | JsonObject | JsonArray;
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
||||
export interface JsonArray extends Array<JsonValue> {}
|
||||
|
||||
export interface JsonObject {
|
||||
[key: string]: JsonValue;
|
||||
}
|
||||
import { JsonObject } from '../../../../../src/plugins/kibana_utils/public';
|
||||
|
||||
export type ESQuery = ESRangeQuery | ESQueryStringQuery | ESMatchQuery | ESTermQuery | JsonObject;
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ import { mockIndexPattern } from '../../mock';
|
|||
import { mockDataProviders } from './data_providers/mock/mock_data_providers';
|
||||
import { buildGlobalQuery, combineQueries } from './helpers';
|
||||
import { mockBrowserFields } from '../../containers/source/mock';
|
||||
import { esQuery, esFilters } from '../../../../../../../src/plugins/data/public';
|
||||
import { EsQueryConfig, esFilters } from '../../../../../../../src/plugins/data/public';
|
||||
|
||||
const cleanUpKqlQuery = (str: string) => str.replace(/\n/g, '').replace(/\s\s+/g, ' ');
|
||||
const startDate = new Date('2018-03-23T18:49:23.132Z').valueOf();
|
||||
|
@ -116,7 +116,7 @@ describe('Build KQL Query', () => {
|
|||
});
|
||||
|
||||
describe('Combined Queries', () => {
|
||||
const config: esQuery.EsQueryConfig = {
|
||||
const config: EsQueryConfig = {
|
||||
allowLeadingWildcards: true,
|
||||
queryStringOptions: {},
|
||||
ignoreFilterIfFieldNotInIndex: true,
|
||||
|
|
|
@ -14,7 +14,7 @@ import { BrowserFields } from '../../containers/source';
|
|||
import {
|
||||
IIndexPattern,
|
||||
Query,
|
||||
esQuery,
|
||||
EsQueryConfig,
|
||||
esFilters,
|
||||
} from '../../../../../../../src/plugins/data/public';
|
||||
|
||||
|
@ -105,7 +105,7 @@ export const combineQueries = ({
|
|||
end,
|
||||
isEventViewer,
|
||||
}: {
|
||||
config: esQuery.EsQueryConfig;
|
||||
config: EsQueryConfig;
|
||||
dataProviders: DataProvider[];
|
||||
indexPattern: IIndexPattern;
|
||||
browserFields: BrowserFields;
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
import { isEmpty, isString, flow } from 'lodash/fp';
|
||||
import {
|
||||
EsQueryConfig,
|
||||
Query,
|
||||
esFilters,
|
||||
esQuery,
|
||||
|
@ -13,6 +14,8 @@ import {
|
|||
IIndexPattern,
|
||||
} from '../../../../../../../src/plugins/data/public';
|
||||
|
||||
import { JsonObject } from '../../../../../../../src/plugins/kibana_utils/public';
|
||||
|
||||
import { KueryFilterQuery } from '../../store';
|
||||
|
||||
export const convertKueryToElasticSearchQuery = (
|
||||
|
@ -33,7 +36,7 @@ export const convertKueryToElasticSearchQuery = (
|
|||
export const convertKueryToDslFilter = (
|
||||
kueryExpression: string,
|
||||
indexPattern: IIndexPattern
|
||||
): esKuery.JsonObject => {
|
||||
): JsonObject => {
|
||||
try {
|
||||
return kueryExpression
|
||||
? esKuery.toElasticsearchQuery(esKuery.fromKueryExpression(kueryExpression), indexPattern)
|
||||
|
@ -87,7 +90,7 @@ export const convertToBuildEsQuery = ({
|
|||
queries,
|
||||
filters,
|
||||
}: {
|
||||
config: esQuery.EsQueryConfig;
|
||||
config: EsQueryConfig;
|
||||
indexPattern: IIndexPattern;
|
||||
queries: Query[];
|
||||
filters: esFilters.Filter[];
|
||||
|
|
|
@ -5,8 +5,7 @@
|
|||
*/
|
||||
|
||||
import { get, isEmpty } from 'lodash/fp';
|
||||
import { esKuery } from '../../../../../../../../../src/plugins/data/common';
|
||||
import { esFilters } from '../../../../../../../../../src/plugins/data/public';
|
||||
import { esFilters, esKuery, KueryNode } from '../../../../../../../../../src/plugins/data/public';
|
||||
import {
|
||||
DataProvider,
|
||||
DataProvidersAnd,
|
||||
|
@ -34,7 +33,7 @@ const templateFields = [
|
|||
];
|
||||
|
||||
export const findValueToChangeInQuery = (
|
||||
keuryNode: esKuery.KueryNode,
|
||||
keuryNode: KueryNode,
|
||||
valueToChange: FindValueToChangeInQuery[] = []
|
||||
): FindValueToChangeInQuery[] => {
|
||||
let localValueToChange = valueToChange;
|
||||
|
@ -48,7 +47,7 @@ export const findValueToChangeInQuery = (
|
|||
];
|
||||
}
|
||||
return keuryNode.arguments.reduce(
|
||||
(addValueToChange: FindValueToChangeInQuery[], ast: esKuery.KueryNode) => {
|
||||
(addValueToChange: FindValueToChangeInQuery[], ast: KueryNode) => {
|
||||
if (ast.function === 'is' && templateFields.includes(ast.arguments[0].value)) {
|
||||
return [
|
||||
...addValueToChange,
|
||||
|
|
|
@ -11,8 +11,7 @@ import { connect } from 'react-redux';
|
|||
import { Dispatch } from 'redux';
|
||||
import { ActionCreator } from 'typescript-fsa';
|
||||
|
||||
import { esFilters, esQuery } from '../../../../../../../../../src/plugins/data/common/es_query';
|
||||
import { Query } from '../../../../../../../../../src/plugins/data/common/query';
|
||||
import { esFilters, esQuery, Query } from '../../../../../../../../../src/plugins/data/public';
|
||||
import { useFetchIndexPatterns } from '../../../../containers/detection_engine/rules/fetch_index_patterns';
|
||||
import { StatefulEventsViewer } from '../../../../components/events_viewer';
|
||||
import { HeaderSection } from '../../../../components/header_section';
|
||||
|
|
|
@ -12,8 +12,7 @@ import { isEmpty } from 'lodash/fp';
|
|||
|
||||
import { HeaderSection } from '../../../../components/header_section';
|
||||
import { SignalsHistogram } from './signals_histogram';
|
||||
import { Query } from '../../../../../../../../../src/plugins/data/common/query';
|
||||
import { esFilters, esQuery } from '../../../../../../../../../src/plugins/data/common/es_query';
|
||||
import { esFilters, esQuery, Query } from '../../../../../../../../../src/plugins/data/public';
|
||||
import { RegisterQuery, SignalsHistogramOption, SignalsAggregation, SignalsTotal } from './types';
|
||||
import { signalsHistogramOptions } from './config';
|
||||
import { getDetectionEngineUrl } from '../../../../components/link_to';
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
import { UserInputError } from 'apollo-server-errors';
|
||||
import { isEmpty, isPlainObject, isString } from 'lodash/fp';
|
||||
|
||||
import { JsonObject } from '../../common/typed_json';
|
||||
import { JsonObject } from '../../../../../../src/plugins/kibana_utils/public';
|
||||
|
||||
export const parseFilterQuery = (filterQuery: string): JsonObject => {
|
||||
try {
|
||||
|
|
|
@ -5,8 +5,7 @@
|
|||
*/
|
||||
|
||||
import { combineFiltersAndUserSearch, stringifyKueries } from '../lib/helper';
|
||||
import { esKuery } from '../../../../../../src/plugins/data/common/es_query';
|
||||
import { IIndexPattern } from '../../../../../../src/plugins/data/common/index_patterns';
|
||||
import { esKuery, IIndexPattern } from '../../../../../../src/plugins/data/public';
|
||||
|
||||
const getKueryString = (urlFilters: string): string => {
|
||||
let kueryString = '';
|
||||
|
|
|
@ -5,11 +5,10 @@
|
|||
*/
|
||||
|
||||
import { setupGetConjunctionSuggestions } from './conjunction';
|
||||
import { QuerySuggestionGetFnArgs, esKuery } from '../../../../../../../src/plugins/data/public';
|
||||
import { QuerySuggestionGetFnArgs, KueryNode } from '../../../../../../../src/plugins/data/public';
|
||||
import { coreMock } from '../../../../../../../src/core/public/mocks';
|
||||
|
||||
const mockKueryNode = (kueryNode: Partial<esKuery.KueryNode>) =>
|
||||
(kueryNode as unknown) as esKuery.KueryNode;
|
||||
const mockKueryNode = (kueryNode: Partial<KueryNode>) => (kueryNode as unknown) as KueryNode;
|
||||
|
||||
describe('Kuery conjunction suggestions', () => {
|
||||
const querySuggestionsArgs = (null as unknown) as QuerySuggestionGetFnArgs;
|
||||
|
|
|
@ -9,12 +9,11 @@ import { setupGetFieldSuggestions } from './field';
|
|||
import {
|
||||
isFilterable,
|
||||
QuerySuggestionGetFnArgs,
|
||||
esKuery,
|
||||
KueryNode,
|
||||
} from '../../../../../../../src/plugins/data/public';
|
||||
import { coreMock } from '../../../../../../../src/core/public/mocks';
|
||||
|
||||
const mockKueryNode = (kueryNode: Partial<esKuery.KueryNode>) =>
|
||||
(kueryNode as unknown) as esKuery.KueryNode;
|
||||
const mockKueryNode = (kueryNode: Partial<KueryNode>) => (kueryNode as unknown) as KueryNode;
|
||||
|
||||
describe('Kuery field suggestions', () => {
|
||||
let querySuggestionsArgs: QuerySuggestionGetFnArgs;
|
||||
|
|
|
@ -6,11 +6,10 @@
|
|||
import indexPatternResponse from './__fixtures__/index_pattern_response.json';
|
||||
|
||||
import { setupGetOperatorSuggestions } from './operator';
|
||||
import { QuerySuggestionGetFnArgs, esKuery } from '../../../../../../../src/plugins/data/public';
|
||||
import { QuerySuggestionGetFnArgs, KueryNode } from '../../../../../../../src/plugins/data/public';
|
||||
import { coreMock } from '../../../../../../../src/core/public/mocks';
|
||||
|
||||
const mockKueryNode = (kueryNode: Partial<esKuery.KueryNode>) =>
|
||||
(kueryNode as unknown) as esKuery.KueryNode;
|
||||
const mockKueryNode = (kueryNode: Partial<KueryNode>) => (kueryNode as unknown) as KueryNode;
|
||||
|
||||
describe('Kuery operator suggestions', () => {
|
||||
let getSuggestions: ReturnType<typeof setupGetOperatorSuggestions>;
|
||||
|
|
|
@ -6,14 +6,11 @@
|
|||
|
||||
import { CoreSetup } from 'kibana/public';
|
||||
import {
|
||||
esKuery,
|
||||
KueryNode,
|
||||
QuerySuggestionBasic,
|
||||
QuerySuggestionGetFnArgs,
|
||||
} from '../../../../../../../src/plugins/data/public';
|
||||
|
||||
export type KqlQuerySuggestionProvider<T = QuerySuggestionBasic> = (
|
||||
core: CoreSetup
|
||||
) => (
|
||||
querySuggestionsGetFnArgs: QuerySuggestionGetFnArgs,
|
||||
kueryNode: esKuery.KueryNode
|
||||
) => Promise<T[]>;
|
||||
) => (querySuggestionsGetFnArgs: QuerySuggestionGetFnArgs, kueryNode: KueryNode) => Promise<T[]>;
|
||||
|
|
|
@ -6,11 +6,10 @@
|
|||
import { setupGetValueSuggestions } from './value';
|
||||
import indexPatternResponse from './__fixtures__/index_pattern_response.json';
|
||||
import { coreMock } from '../../../../../../../src/core/public/mocks';
|
||||
import { QuerySuggestionGetFnArgs, esKuery } from '../../../../../../../src/plugins/data/public';
|
||||
import { QuerySuggestionGetFnArgs, KueryNode } from '../../../../../../../src/plugins/data/public';
|
||||
import { setAutocompleteService } from '../../../services';
|
||||
|
||||
const mockKueryNode = (kueryNode: Partial<esKuery.KueryNode>) =>
|
||||
(kueryNode as unknown) as esKuery.KueryNode;
|
||||
const mockKueryNode = (kueryNode: Partial<KueryNode>) => (kueryNode as unknown) as KueryNode;
|
||||
|
||||
describe('Kuery value suggestions', () => {
|
||||
let getSuggestions: ReturnType<typeof setupGetValueSuggestions>;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue