From 0b78487fee617a0843f8cc70b1d378b1eeccb12e Mon Sep 17 00:00:00 2001 From: Liza K Date: Thu, 6 Feb 2020 10:59:23 +0200 Subject: [PATCH] Code review --- .../data/common/es_query/kuery/node_types/function.ts | 2 +- .../data/common/es_query/kuery/node_types/literal.ts | 6 ++---- src/plugins/data/common/es_query/kuery/node_types/types.ts | 6 +++--- .../data/common/es_query/kuery/node_types/wildcard.ts | 5 +++-- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/plugins/data/common/es_query/kuery/node_types/function.ts b/src/plugins/data/common/es_query/kuery/node_types/function.ts index ea432589ae9ea..5b09bc2a67349 100644 --- a/src/plugins/data/common/es_query/kuery/node_types/function.ts +++ b/src/plugins/data/common/es_query/kuery/node_types/function.ts @@ -40,7 +40,7 @@ export function buildNode(functionName: FunctionName, ...args: any[]) { // Mainly only useful in the grammar where we'll already have real argument nodes in hand export function buildNodeWithArgumentNodes( functionName: FunctionName, - ...args: any[] + args: any[] ): FunctionTypeBuildNode { if (_.isUndefined(functions[functionName])) { throw new Error(`Unknown function "${functionName}"`); diff --git a/src/plugins/data/common/es_query/kuery/node_types/literal.ts b/src/plugins/data/common/es_query/kuery/node_types/literal.ts index 4ba8a2f6ea659..070ea09e0f647 100644 --- a/src/plugins/data/common/es_query/kuery/node_types/literal.ts +++ b/src/plugins/data/common/es_query/kuery/node_types/literal.ts @@ -19,15 +19,13 @@ import { LiteralTypeBuildNode } from './types'; -type LiteralNodeValue = null | boolean | number | string; - -export function buildNode(value: LiteralNodeValue): LiteralTypeBuildNode { +export function buildNode(value: LiteralTypeBuildNode['value']): LiteralTypeBuildNode { return { type: 'literal', value, }; } -export function toElasticsearchQuery(node: LiteralTypeBuildNode): LiteralNodeValue { +export function toElasticsearchQuery(node: LiteralTypeBuildNode): LiteralTypeBuildNode['value'] { return node.value; } diff --git a/src/plugins/data/common/es_query/kuery/node_types/types.ts b/src/plugins/data/common/es_query/kuery/node_types/types.ts index 43016f0235105..1af4a20583d46 100644 --- a/src/plugins/data/common/es_query/kuery/node_types/types.ts +++ b/src/plugins/data/common/es_query/kuery/node_types/types.ts @@ -22,7 +22,7 @@ */ import { IIndexPattern } from '../../../index_patterns'; -import { JsonValue } from '..'; +import { JsonValue, KueryNode } from '..'; export type FunctionName = | 'is' @@ -37,7 +37,7 @@ export type FunctionName = interface FunctionType { buildNode: (functionName: FunctionName, ...args: any[]) => FunctionTypeBuildNode; - buildNodeWithArgumentNodes: (functionName: FunctionName, ...args: any[]) => FunctionTypeBuildNode; + buildNodeWithArgumentNodes: (functionName: FunctionName, args: any[]) => FunctionTypeBuildNode; toElasticsearchQuery: ( node: any, indexPattern?: IIndexPattern, @@ -75,7 +75,7 @@ export interface NamedArgTypeBuildNode { } interface WildcardType { - buildNode: (value: string) => WildcardTypeBuildNode; + buildNode: (value: string) => WildcardTypeBuildNode | KueryNode; test: (node: any, string: string) => boolean; toElasticsearchQuery: (node: any) => string; toQueryStringQuery: (node: any) => string; diff --git a/src/plugins/data/common/es_query/kuery/node_types/wildcard.ts b/src/plugins/data/common/es_query/kuery/node_types/wildcard.ts index 9dd04c0c3154e..87fcfa1ca2f64 100644 --- a/src/plugins/data/common/es_query/kuery/node_types/wildcard.ts +++ b/src/plugins/data/common/es_query/kuery/node_types/wildcard.ts @@ -19,6 +19,7 @@ import { fromLiteralExpression } from '../ast/ast'; import { WildcardTypeBuildNode } from './types'; +import { KueryNode } from '..'; export const wildcardSymbol = '@kuery-wildcard@'; @@ -32,9 +33,9 @@ function escapeQueryString(str: string) { return str.replace(/[+-=&|>