@elastic/esql 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENCE.txt +93 -0
- package/NOTICE.txt +5 -0
- package/README.md +167 -0
- package/lib/__tests__/fixtures.d.ts +4 -0
- package/lib/__tests__/fixtures.d.ts.map +1 -0
- package/lib/ast/builder/builder.d.ts +87 -0
- package/lib/ast/builder/builder.d.ts.map +1 -0
- package/lib/ast/builder/index.d.ts +3 -0
- package/lib/ast/builder/index.d.ts.map +1 -0
- package/lib/ast/builder/types.d.ts +18 -0
- package/lib/ast/builder/types.d.ts.map +1 -0
- package/lib/ast/grouping.d.ts +70 -0
- package/lib/ast/grouping.d.ts.map +1 -0
- package/lib/ast/index.d.ts +9 -0
- package/lib/ast/index.d.ts.map +1 -0
- package/lib/ast/is.d.ts +49 -0
- package/lib/ast/is.d.ts.map +1 -0
- package/lib/ast/location.d.ts +7 -0
- package/lib/ast/location.d.ts.map +1 -0
- package/lib/ast/mutate/commands/from/index.d.ts +4 -0
- package/lib/ast/mutate/commands/from/index.d.ts.map +1 -0
- package/lib/ast/mutate/commands/from/metadata.d.ts +63 -0
- package/lib/ast/mutate/commands/from/metadata.d.ts.map +1 -0
- package/lib/ast/mutate/commands/from/sources.d.ts +9 -0
- package/lib/ast/mutate/commands/from/sources.d.ts.map +1 -0
- package/lib/ast/mutate/commands/index.d.ts +9 -0
- package/lib/ast/mutate/commands/index.d.ts.map +1 -0
- package/lib/ast/mutate/commands/join/index.d.ts +17 -0
- package/lib/ast/mutate/commands/join/index.d.ts.map +1 -0
- package/lib/ast/mutate/commands/limit/index.d.ts +56 -0
- package/lib/ast/mutate/commands/limit/index.d.ts.map +1 -0
- package/lib/ast/mutate/commands/rerank/index.d.ts +41 -0
- package/lib/ast/mutate/commands/rerank/index.d.ts.map +1 -0
- package/lib/ast/mutate/commands/sort/index.d.ts +117 -0
- package/lib/ast/mutate/commands/sort/index.d.ts.map +1 -0
- package/lib/ast/mutate/commands/stats/index.d.ts +17 -0
- package/lib/ast/mutate/commands/stats/index.d.ts.map +1 -0
- package/lib/ast/mutate/commands/where/index.d.ts +48 -0
- package/lib/ast/mutate/commands/where/index.d.ts.map +1 -0
- package/lib/ast/mutate/generic/commands/args/index.d.ts +14 -0
- package/lib/ast/mutate/generic/commands/args/index.d.ts.map +1 -0
- package/lib/ast/mutate/generic/commands/index.d.ts +54 -0
- package/lib/ast/mutate/generic/commands/index.d.ts.map +1 -0
- package/lib/ast/mutate/generic/commands/options/index.d.ts +38 -0
- package/lib/ast/mutate/generic/commands/options/index.d.ts.map +1 -0
- package/lib/ast/mutate/generic/index.d.ts +2 -0
- package/lib/ast/mutate/generic/index.d.ts.map +1 -0
- package/lib/ast/mutate/index.d.ts +5 -0
- package/lib/ast/mutate/index.d.ts.map +1 -0
- package/lib/ast/mutate/types.d.ts +2 -0
- package/lib/ast/mutate/types.d.ts.map +1 -0
- package/lib/ast/mutate/util.d.ts +20 -0
- package/lib/ast/mutate/util.d.ts.map +1 -0
- package/lib/ast/visitor/contexts.d.ts +176 -0
- package/lib/ast/visitor/contexts.d.ts.map +1 -0
- package/lib/ast/visitor/global_visitor_context.d.ts +77 -0
- package/lib/ast/visitor/global_visitor_context.d.ts.map +1 -0
- package/lib/ast/visitor/index.d.ts +5 -0
- package/lib/ast/visitor/index.d.ts.map +1 -0
- package/lib/ast/visitor/types.d.ts +104 -0
- package/lib/ast/visitor/types.d.ts.map +1 -0
- package/lib/ast/visitor/utils.d.ts +26 -0
- package/lib/ast/visitor/utils.d.ts.map +1 -0
- package/lib/ast/visitor/visitor.d.ts +79 -0
- package/lib/ast/visitor/visitor.d.ts.map +1 -0
- package/lib/ast/walker/helpers.d.ts +23 -0
- package/lib/ast/walker/helpers.d.ts.map +1 -0
- package/lib/ast/walker/index.d.ts +2 -0
- package/lib/ast/walker/index.d.ts.map +1 -0
- package/lib/ast/walker/walker.d.ts +266 -0
- package/lib/ast/walker/walker.d.ts.map +1 -0
- package/lib/composer/composer_query.d.ts +684 -0
- package/lib/composer/composer_query.d.ts.map +1 -0
- package/lib/composer/esql.d.ts +25 -0
- package/lib/composer/esql.d.ts.map +1 -0
- package/lib/composer/index.d.ts +8 -0
- package/lib/composer/index.d.ts.map +1 -0
- package/lib/composer/parameter_hole.d.ts +11 -0
- package/lib/composer/parameter_hole.d.ts.map +1 -0
- package/lib/composer/query/index.d.ts +2 -0
- package/lib/composer/query/index.d.ts.map +1 -0
- package/lib/composer/query/query.d.ts +54 -0
- package/lib/composer/query/query.d.ts.map +1 -0
- package/lib/composer/synth/command.d.ts +7 -0
- package/lib/composer/synth/command.d.ts.map +1 -0
- package/lib/composer/synth/expression.d.ts +6 -0
- package/lib/composer/synth/expression.d.ts.map +1 -0
- package/lib/composer/synth/header.d.ts +7 -0
- package/lib/composer/synth/header.d.ts.map +1 -0
- package/lib/composer/synth/holes.d.ts +27 -0
- package/lib/composer/synth/holes.d.ts.map +1 -0
- package/lib/composer/synth/index.d.ts +7 -0
- package/lib/composer/synth/index.d.ts.map +1 -0
- package/lib/composer/synth/nodes.d.ts +104 -0
- package/lib/composer/synth/nodes.d.ts.map +1 -0
- package/lib/composer/synth/query.d.ts +7 -0
- package/lib/composer/synth/query.d.ts.map +1 -0
- package/lib/composer/synth/synth_literal_fragment.d.ts +19 -0
- package/lib/composer/synth/synth_literal_fragment.d.ts.map +1 -0
- package/lib/composer/synth/synth_node.d.ts +19 -0
- package/lib/composer/synth/synth_node.d.ts.map +1 -0
- package/lib/composer/synth/tag.d.ts +4 -0
- package/lib/composer/synth/tag.d.ts.map +1 -0
- package/lib/composer/synth/types.d.ts +65 -0
- package/lib/composer/synth/types.d.ts.map +1 -0
- package/lib/composer/types.d.ts +218 -0
- package/lib/composer/types.d.ts.map +1 -0
- package/lib/composer/util.d.ts +24 -0
- package/lib/composer/util.d.ts.map +1 -0
- package/lib/debug/index.d.ts +2 -0
- package/lib/debug/index.d.ts.map +1 -0
- package/lib/debug/print_ast.d.ts +60 -0
- package/lib/debug/print_ast.d.ts.map +1 -0
- package/lib/embedded_languages/index.d.ts +2 -0
- package/lib/embedded_languages/index.d.ts.map +1 -0
- package/lib/embedded_languages/promql/ast/builder/builder.d.ts +52 -0
- package/lib/embedded_languages/promql/ast/builder/builder.d.ts.map +1 -0
- package/lib/embedded_languages/promql/ast/builder/index.d.ts +3 -0
- package/lib/embedded_languages/promql/ast/builder/index.d.ts.map +1 -0
- package/lib/embedded_languages/promql/ast/builder/types.d.ts +12 -0
- package/lib/embedded_languages/promql/ast/builder/types.d.ts.map +1 -0
- package/lib/embedded_languages/promql/ast/is.d.ts +3 -0
- package/lib/embedded_languages/promql/ast/is.d.ts.map +1 -0
- package/lib/embedded_languages/promql/ast/traversal.d.ts +3 -0
- package/lib/embedded_languages/promql/ast/traversal.d.ts.map +1 -0
- package/lib/embedded_languages/promql/ast/walker/index.d.ts +3 -0
- package/lib/embedded_languages/promql/ast/walker/index.d.ts.map +1 -0
- package/lib/embedded_languages/promql/ast/walker/types.d.ts +93 -0
- package/lib/embedded_languages/promql/ast/walker/types.d.ts.map +1 -0
- package/lib/embedded_languages/promql/ast/walker/walker.d.ts +43 -0
- package/lib/embedded_languages/promql/ast/walker/walker.d.ts.map +1 -0
- package/lib/embedded_languages/promql/index.d.ts +8 -0
- package/lib/embedded_languages/promql/index.d.ts.map +1 -0
- package/lib/embedded_languages/promql/parser/cst_to_ast_converter.d.ts +48 -0
- package/lib/embedded_languages/promql/parser/cst_to_ast_converter.d.ts.map +1 -0
- package/lib/embedded_languages/promql/parser/index.d.ts +4 -0
- package/lib/embedded_languages/promql/parser/index.d.ts.map +1 -0
- package/lib/embedded_languages/promql/parser/parser.d.ts +65 -0
- package/lib/embedded_languages/promql/parser/parser.d.ts.map +1 -0
- package/lib/embedded_languages/promql/parser/promql_error_listener.d.ts +11 -0
- package/lib/embedded_languages/promql/parser/promql_error_listener.d.ts.map +1 -0
- package/lib/embedded_languages/promql/pretty_print/basic_pretty_printer.d.ts +65 -0
- package/lib/embedded_languages/promql/pretty_print/basic_pretty_printer.d.ts.map +1 -0
- package/lib/embedded_languages/promql/pretty_print/helpers.d.ts +34 -0
- package/lib/embedded_languages/promql/pretty_print/helpers.d.ts.map +1 -0
- package/lib/embedded_languages/promql/pretty_print/index.d.ts +2 -0
- package/lib/embedded_languages/promql/pretty_print/index.d.ts.map +1 -0
- package/lib/embedded_languages/promql/types.d.ts +355 -0
- package/lib/embedded_languages/promql/types.d.ts.map +1 -0
- package/lib/index.d.ts +7 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +63055 -0
- package/lib/index.js.map +1 -0
- package/lib/index.mjs +62941 -0
- package/lib/index.mjs.map +1 -0
- package/lib/parser/antlr/esql_lexer.d.ts +223 -0
- package/lib/parser/antlr/esql_lexer.d.ts.map +1 -0
- package/lib/parser/antlr/esql_parser.d.ts +1847 -0
- package/lib/parser/antlr/esql_parser.d.ts.map +1 -0
- package/lib/parser/antlr/esql_parser_listener.d.ts +1634 -0
- package/lib/parser/antlr/esql_parser_listener.d.ts.map +1 -0
- package/lib/parser/antlr/lexer_config.d.ts +13 -0
- package/lib/parser/antlr/lexer_config.d.ts.map +1 -0
- package/lib/parser/antlr/parser_config.d.ts +7 -0
- package/lib/parser/antlr/parser_config.d.ts.map +1 -0
- package/lib/parser/antlr/promql_lexer.d.ts +71 -0
- package/lib/parser/antlr/promql_lexer.d.ts.map +1 -0
- package/lib/parser/antlr/promql_parser.d.ts +441 -0
- package/lib/parser/antlr/promql_parser.d.ts.map +1 -0
- package/lib/parser/antlr/promql_parser_listener.d.ts +354 -0
- package/lib/parser/antlr/promql_parser_listener.d.ts.map +1 -0
- package/lib/parser/core/constants.d.ts +8 -0
- package/lib/parser/core/constants.d.ts.map +1 -0
- package/lib/parser/core/cst_to_ast_converter.d.ts +262 -0
- package/lib/parser/core/cst_to_ast_converter.d.ts.map +1 -0
- package/lib/parser/core/decorations.d.ts +29 -0
- package/lib/parser/core/decorations.d.ts.map +1 -0
- package/lib/parser/core/esql_error_listener.d.ts +8 -0
- package/lib/parser/core/esql_error_listener.d.ts.map +1 -0
- package/lib/parser/core/helpers.d.ts +9 -0
- package/lib/parser/core/helpers.d.ts.map +1 -0
- package/lib/parser/core/parser.d.ts +136 -0
- package/lib/parser/core/parser.d.ts.map +1 -0
- package/lib/parser/core/tokens.d.ts +45 -0
- package/lib/parser/core/tokens.d.ts.map +1 -0
- package/lib/parser/core/types.d.ts +69 -0
- package/lib/parser/core/types.d.ts.map +1 -0
- package/lib/parser/index.d.ts +4 -0
- package/lib/parser/index.d.ts.map +1 -0
- package/lib/pretty_print/__tests__/fixtures.d.ts +5 -0
- package/lib/pretty_print/__tests__/fixtures.d.ts.map +1 -0
- package/lib/pretty_print/basic_pretty_printer.d.ts +87 -0
- package/lib/pretty_print/basic_pretty_printer.d.ts.map +1 -0
- package/lib/pretty_print/constants.d.ts +47 -0
- package/lib/pretty_print/constants.d.ts.map +1 -0
- package/lib/pretty_print/helpers.d.ts +22 -0
- package/lib/pretty_print/helpers.d.ts.map +1 -0
- package/lib/pretty_print/index.d.ts +4 -0
- package/lib/pretty_print/index.d.ts.map +1 -0
- package/lib/pretty_print/leaf_printer.d.ts +19 -0
- package/lib/pretty_print/leaf_printer.d.ts.map +1 -0
- package/lib/pretty_print/utils.d.ts +7 -0
- package/lib/pretty_print/utils.d.ts.map +1 -0
- package/lib/pretty_print/wrapping_pretty_printer.d.ts +113 -0
- package/lib/pretty_print/wrapping_pretty_printer.d.ts.map +1 -0
- package/lib/types.d.ts +523 -0
- package/lib/types.d.ts.map +1 -0
- package/lib/types.js +19 -0
- package/lib/types.js.map +1 -0
- package/lib/types.mjs +1 -0
- package/lib/types.mjs.map +1 -0
- package/package.json +98 -0
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { ESQLAstQueryExpression, ESQLColumn, ESQLCommand, ESQLCommandOption } from '../../../../types';
|
|
2
|
+
import type { Predicate } from '../../types';
|
|
3
|
+
/**
|
|
4
|
+
* Returns all METADATA field AST nodes and their corresponding parent command
|
|
5
|
+
* option nodes.
|
|
6
|
+
*
|
|
7
|
+
* @param ast The root AST node to search for metadata fields.
|
|
8
|
+
* @returns A collection of [column, option] pairs for each metadata field found.
|
|
9
|
+
*/
|
|
10
|
+
export declare const list: (ast: ESQLAstQueryExpression | ESQLCommand<"from">) => IterableIterator<[ESQLColumn, ESQLCommandOption]>;
|
|
11
|
+
/**
|
|
12
|
+
* Find a METADATA field by its name or parts.
|
|
13
|
+
*
|
|
14
|
+
* @param ast The root AST node to search for metadata fields.
|
|
15
|
+
* @param fieldName The name or parts of the field to find.
|
|
16
|
+
* @returns A 2-tuple containing the column and the option it was found in, or
|
|
17
|
+
* `undefined` if the field was not found.
|
|
18
|
+
*/
|
|
19
|
+
export declare const find: (ast: ESQLAstQueryExpression, fieldName: string | string[]) => [ESQLColumn, ESQLCommandOption] | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* Removes the first found METADATA field that satisfies the predicate.
|
|
22
|
+
*
|
|
23
|
+
* @param ast The root AST node to search for metadata fields.
|
|
24
|
+
* @param predicate The predicate function to filter fields.
|
|
25
|
+
* @returns The removed column and option, if any.
|
|
26
|
+
*/
|
|
27
|
+
export declare const removeByPredicate: (ast: ESQLAstQueryExpression, predicate: Predicate<ESQLColumn>) => [column: ESQLColumn, option: ESQLCommandOption] | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* Removes the first METADATA field that matches the given name and returns
|
|
30
|
+
* a 2-tuple (the column and the option it was removed from).
|
|
31
|
+
*
|
|
32
|
+
* @param ast The root AST node to search for metadata fields.
|
|
33
|
+
* @param fieldName The name or parts of the field to remove.
|
|
34
|
+
* @returns The removed column and option, if any.
|
|
35
|
+
*/
|
|
36
|
+
export declare const remove: (ast: ESQLAstQueryExpression, fieldName: string | string[]) => [column: ESQLColumn, option: ESQLCommandOption] | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* Insert into a specific position or append a `METADATA` field to the `FROM`
|
|
39
|
+
* command.
|
|
40
|
+
*
|
|
41
|
+
* @param ast The root AST node.
|
|
42
|
+
* @param fieldName Field name or parts as an array, e.g. `['a', 'b']`.
|
|
43
|
+
* @param index Position to insert the field at. If `-1` or not specified, the
|
|
44
|
+
* field will be appended.
|
|
45
|
+
* @returns If the field was successfully inserted, returns a 2-tuple containing
|
|
46
|
+
* the column and the option it was inserted into. Otherwise, returns
|
|
47
|
+
* `undefined`.
|
|
48
|
+
*/
|
|
49
|
+
export declare const insert: (ast: ESQLAstQueryExpression, fieldName: string | string[], index?: number) => [column: ESQLColumn, option: ESQLCommandOption] | undefined;
|
|
50
|
+
/**
|
|
51
|
+
* The `.upsert()` method works like `.insert()`, but will not insert a field
|
|
52
|
+
* if it already exists.
|
|
53
|
+
*
|
|
54
|
+
* @param ast The root AST node.
|
|
55
|
+
* @param fieldName The field name or parts as an array, e.g. `['a', 'b']`.
|
|
56
|
+
* @param index Position to insert the field at. If `-1` or not specified, the
|
|
57
|
+
* field will be appended.
|
|
58
|
+
* @returns If the field was successfully inserted, returns a 2-tuple containing
|
|
59
|
+
* the column and the option it was inserted into. Otherwise, returns
|
|
60
|
+
* `undefined`.
|
|
61
|
+
*/
|
|
62
|
+
export declare const upsert: (ast: ESQLAstQueryExpression, fieldName: string | string[], index?: number) => [column: ESQLColumn, option: ESQLCommandOption] | undefined;
|
|
63
|
+
//# sourceMappingURL=metadata.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metadata.d.ts","sourceRoot":"","sources":["../../../../../src/ast/mutate/commands/from/metadata.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EACV,sBAAsB,EACtB,UAAU,EACV,WAAW,EACX,iBAAiB,EAClB,MAAM,mBAAmB,CAAC;AAK3B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C;;;;;;GAMG;AACH,eAAO,MAAM,IAAI,GACf,KAAK,sBAAsB,GAAG,WAAW,CAAC,MAAM,CAAC,KAChD,gBAAgB,CAAC,CAAC,UAAU,EAAE,iBAAiB,CAAC,CAoClD,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,IAAI,GACf,KAAK,sBAAsB,EAC3B,WAAW,MAAM,GAAG,MAAM,EAAE,KAC3B,CAAC,UAAU,EAAE,iBAAiB,CAAC,GAAG,SAYpC,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,GAC5B,KAAK,sBAAsB,EAC3B,WAAW,SAAS,CAAC,UAAU,CAAC,KAC/B,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,iBAAiB,CAAC,GAAG,SAqBpD,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,MAAM,GACjB,KAAK,sBAAsB,EAC3B,WAAW,MAAM,GAAG,MAAM,EAAE,KAC3B,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,iBAAiB,CAAC,GAAG,SAWpD,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,MAAM,GACjB,KAAK,sBAAsB,EAC3B,WAAW,MAAM,GAAG,MAAM,EAAE,EAC5B,QAAO,MAAW,KACjB,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,iBAAiB,CAAC,GAAG,SAwBpD,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,MAAM,GACjB,KAAK,sBAAsB,EAC3B,WAAW,MAAM,GAAG,MAAM,EAAE,EAC5B,QAAO,MAAW,KACjB,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,iBAAiB,CAAC,GAAG,SAoBpD,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ESQLAstQueryExpression, ESQLCommand, ESQLSource } from '../../../../types';
|
|
2
|
+
import type { Predicate } from '../../types';
|
|
3
|
+
export declare const list: (ast: ESQLAstQueryExpression | ESQLCommand<"from">) => IterableIterator<ESQLSource>;
|
|
4
|
+
export declare const findByPredicate: (ast: ESQLAstQueryExpression, predicate: Predicate<ESQLSource>) => ESQLSource | undefined;
|
|
5
|
+
export declare const find: (ast: ESQLAstQueryExpression, index: string, cluster?: string) => ESQLSource | undefined;
|
|
6
|
+
export declare const remove: (ast: ESQLAstQueryExpression, index: string, cluster?: string) => ESQLSource | undefined;
|
|
7
|
+
export declare const insert: (ast: ESQLAstQueryExpression, indexName: string, clusterName?: string, index?: number) => ESQLSource | undefined;
|
|
8
|
+
export declare const upsert: (ast: ESQLAstQueryExpression, indexName: string, clusterName?: string, index?: number) => ESQLSource | undefined;
|
|
9
|
+
//# sourceMappingURL=sources.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sources.d.ts","sourceRoot":"","sources":["../../../../../src/ast/mutate/commands/from/sources.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,sBAAsB,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAIzF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAG7C,eAAO,MAAM,IAAI,GACf,KAAK,sBAAsB,GAAG,WAAW,CAAC,MAAM,CAAC,KAChD,gBAAgB,CAAC,UAAU,CAuB7B,CAAC;AAEF,eAAO,MAAM,eAAe,GAC1B,KAAK,sBAAsB,EAC3B,WAAW,SAAS,CAAC,UAAU,CAAC,KAC/B,UAAU,GAAG,SAEf,CAAC;AAEF,eAAO,MAAM,IAAI,GACf,KAAK,sBAAsB,EAC3B,OAAO,MAAM,EACb,UAAU,MAAM,KACf,UAAU,GAAG,SAWf,CAAC;AAEF,eAAO,MAAM,MAAM,GACjB,KAAK,sBAAsB,EAC3B,OAAO,MAAM,EACb,UAAU,MAAM,KACf,UAAU,GAAG,SAUf,CAAC;AAEF,eAAO,MAAM,MAAM,GACjB,KAAK,sBAAsB,EAC3B,WAAW,MAAM,EACjB,cAAc,MAAM,EACpB,QAAO,MAAW,KACjB,UAAU,GAAG,SAgBf,CAAC;AAEF,eAAO,MAAM,MAAM,GACjB,KAAK,sBAAsB,EAC3B,WAAW,MAAM,EACjB,cAAc,MAAM,EACpB,QAAO,MAAW,KACjB,UAAU,GAAG,SAQf,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as from from './from';
|
|
2
|
+
import * as limit from './limit';
|
|
3
|
+
import * as sort from './sort';
|
|
4
|
+
import * as stats from './stats';
|
|
5
|
+
import * as where from './where';
|
|
6
|
+
import * as join from './join';
|
|
7
|
+
import * as rerank from './rerank';
|
|
8
|
+
export { from, limit, sort, stats, where, join, rerank };
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/ast/mutate/commands/index.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC;AAC/B,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AACjC,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC;AAC/B,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AACjC,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AACjC,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC;AAC/B,OAAO,KAAK,MAAM,MAAM,UAAU,CAAC;AAEnC,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ESQLAstJoinCommand, ESQLAstQueryExpression, ESQLCommand } from '../../../../types';
|
|
2
|
+
/**
|
|
3
|
+
* Lists all "JOIN" commands in the query AST.
|
|
4
|
+
*
|
|
5
|
+
* @param ast The root AST node to search for "JOIN" commands.
|
|
6
|
+
* @returns A collection of "JOIN" commands.
|
|
7
|
+
*/
|
|
8
|
+
export declare const list: (ast: ESQLAstQueryExpression) => IterableIterator<ESQLAstJoinCommand>;
|
|
9
|
+
/**
|
|
10
|
+
* Retrieves the "JOIN" command at the specified index in order of appearance.
|
|
11
|
+
*
|
|
12
|
+
* @param ast The root AST node to search for "JOIN" commands.
|
|
13
|
+
* @param index The index of the "JOIN" command to retrieve.
|
|
14
|
+
* @returns The "JOIN" command at the specified index, if any.
|
|
15
|
+
*/
|
|
16
|
+
export declare const byIndex: (ast: ESQLAstQueryExpression, index: number) => ESQLCommand | undefined;
|
|
17
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/ast/mutate/commands/join/index.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGjG;;;;;GAKG;AACH,eAAO,MAAM,IAAI,GAAI,KAAK,sBAAsB,KAAG,gBAAgB,CAAC,kBAAkB,CAKrF,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,OAAO,GAAI,KAAK,sBAAsB,EAAE,OAAO,MAAM,KAAG,WAAW,GAAG,SAElF,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { ESQLAstQueryExpression, ESQLCommand } from '../../../../types';
|
|
2
|
+
import type { Predicate } from '../../types';
|
|
3
|
+
/**
|
|
4
|
+
* Lists all "LIMIT" commands in the query AST.
|
|
5
|
+
*
|
|
6
|
+
* @param ast The root AST node to search for "LIMIT" commands.
|
|
7
|
+
* @returns A collection of "LIMIT" commands.
|
|
8
|
+
*/
|
|
9
|
+
export declare const list: (ast: ESQLAstQueryExpression) => IterableIterator<ESQLCommand>;
|
|
10
|
+
/**
|
|
11
|
+
* Retrieves the "LIMIT" command at the specified index in order of appearance.
|
|
12
|
+
*
|
|
13
|
+
* @param ast The root AST node to search for "LIMIT" commands.
|
|
14
|
+
* @param index The index of the "LIMIT" command to retrieve.
|
|
15
|
+
* @returns The "LIMIT" command at the specified index, if any.
|
|
16
|
+
*/
|
|
17
|
+
export declare const byIndex: (ast: ESQLAstQueryExpression, index: number) => ESQLCommand | undefined;
|
|
18
|
+
/**
|
|
19
|
+
* Finds the first "LIMIT" command that satisfies the provided predicate.
|
|
20
|
+
*
|
|
21
|
+
* @param ast The root AST node to search for "LIMIT" commands.
|
|
22
|
+
* @param predicate The predicate function to apply to each "LIMIT" command.
|
|
23
|
+
* @returns The first "LIMIT" command that satisfies the predicate, if any.
|
|
24
|
+
*/
|
|
25
|
+
export declare const find: (ast: ESQLAstQueryExpression, predicate: Predicate<ESQLCommand>) => ESQLCommand | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* Deletes the specified "LIMIT" command from the query AST.
|
|
28
|
+
*
|
|
29
|
+
* @param ast The root AST node to search for "LIMIT" commands.
|
|
30
|
+
* @param index The index of the "LIMIT" command to remove.
|
|
31
|
+
* @returns The removed "LIMIT" command, if any.
|
|
32
|
+
*/
|
|
33
|
+
export declare const remove: (ast: ESQLAstQueryExpression, index?: number) => ESQLCommand | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* Sets the value of the specified "LIMIT" command. If `indexOrPredicate` is not
|
|
36
|
+
* specified will update the first "LIMIT" command found, if any.
|
|
37
|
+
*
|
|
38
|
+
* @param ast The root AST node to search for "LIMIT" commands.
|
|
39
|
+
* @param value The new value to set.
|
|
40
|
+
* @param indexOrPredicate The index of the "LIMIT" command to update, or a
|
|
41
|
+
* predicate function.
|
|
42
|
+
* @returns The updated "LIMIT" command, if any.
|
|
43
|
+
*/
|
|
44
|
+
export declare const set: (ast: ESQLAstQueryExpression, value: number, indexOrPredicate?: number | Predicate<ESQLCommand>) => ESQLCommand | undefined;
|
|
45
|
+
/**
|
|
46
|
+
* Updates the value of the specified "LIMIT" command. If the "LIMIT" command
|
|
47
|
+
* is not found, a new one will be created and appended to the query AST.
|
|
48
|
+
*
|
|
49
|
+
* @param ast The root AST node to search for "LIMIT" commands.
|
|
50
|
+
* @param value The new value to set.
|
|
51
|
+
* @param indexOrPredicate The index of the "LIMIT" command to update, or a
|
|
52
|
+
* predicate function.
|
|
53
|
+
* @returns The updated or newly created "LIMIT" command.
|
|
54
|
+
*/
|
|
55
|
+
export declare const upsert: (ast: ESQLAstQueryExpression, value: number, indexOrPredicate?: number | Predicate<ESQLCommand>) => ESQLCommand;
|
|
56
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/ast/mutate/commands/limit/index.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,sBAAsB,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAE7E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C;;;;;GAKG;AACH,eAAO,MAAM,IAAI,GAAI,KAAK,sBAAsB,KAAG,gBAAgB,CAAC,WAAW,CAE9E,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,OAAO,GAAI,KAAK,sBAAsB,EAAE,OAAO,MAAM,KAAG,WAAW,GAAG,SAElF,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,IAAI,GACf,KAAK,sBAAsB,EAC3B,WAAW,SAAS,CAAC,WAAW,CAAC,KAChC,WAAW,GAAG,SAEhB,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,MAAM,GAAI,KAAK,sBAAsB,EAAE,QAAO,MAAU,KAAG,WAAW,GAAG,SAcrF,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,GAAG,GACd,KAAK,sBAAsB,EAC3B,OAAO,MAAM,EACb,mBAAkB,MAAM,GAAG,SAAS,CAAC,WAAW,CAAK,KACpD,WAAW,GAAG,SAehB,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,MAAM,GACjB,KAAK,sBAAsB,EAC3B,OAAO,MAAM,EACb,mBAAkB,MAAM,GAAG,SAAS,CAAC,WAAW,CAAK,KACpD,WAgBF,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { ESQLAstQueryExpression, ESQLAstRerankCommand, ESQLStringLiteral, ESQLParamLiteral } from '../../../../types';
|
|
2
|
+
/**
|
|
3
|
+
* Lists all "RERANK" commands in the query AST.
|
|
4
|
+
*
|
|
5
|
+
* @param ast The root AST node to search for "RERANK" commands.
|
|
6
|
+
* @returns A collection of "RERANK" commands.
|
|
7
|
+
*/
|
|
8
|
+
export declare const list: (ast: ESQLAstQueryExpression) => IterableIterator<ESQLAstRerankCommand>;
|
|
9
|
+
/**
|
|
10
|
+
* Sets or updates the query text for the RERANK command.
|
|
11
|
+
*
|
|
12
|
+
* @param cmd The RERANK command AST node to modify.
|
|
13
|
+
* @param query The query text to set.
|
|
14
|
+
*/
|
|
15
|
+
export declare const setQuery: (cmd: ESQLAstRerankCommand, query: string | ESQLStringLiteral) => void;
|
|
16
|
+
/**
|
|
17
|
+
* Sets, updates, or removes the target field for the RERANK command.
|
|
18
|
+
* This refers to the `targetField =` portion of the command, which specifies │
|
|
19
|
+
* the new column where the rerank score will be stored. │
|
|
20
|
+
*
|
|
21
|
+
* @param cmd The RERANK command AST node to modify.
|
|
22
|
+
* @param target The name of the target field to set. If `null` the assignment is removed.
|
|
23
|
+
*/
|
|
24
|
+
export declare const setTargetField: (cmd: ESQLAstRerankCommand, target: string | null) => void;
|
|
25
|
+
/**
|
|
26
|
+
* Sets or updates the fields to be used for reranking in the ON clause.
|
|
27
|
+
*
|
|
28
|
+
* @param cmd The RERANK command AST node to modify.
|
|
29
|
+
* @param fields An array of field names or field nodes.
|
|
30
|
+
*/
|
|
31
|
+
export declare const setFields: (cmd: ESQLAstRerankCommand, fields: string[] | ESQLAstRerankCommand["fields"]) => void;
|
|
32
|
+
/**
|
|
33
|
+
* Sets a parameter in the WITH clause of the RERANK command (e.g., 'inference_id').
|
|
34
|
+
* If the parameter already exists, its value is updated. Otherwise, it is added.
|
|
35
|
+
*
|
|
36
|
+
* @param cmd The RERANK command AST node to modify.
|
|
37
|
+
* @param key The name of the parameter to set.
|
|
38
|
+
* @param value The value of the parameter.
|
|
39
|
+
*/
|
|
40
|
+
export declare const setWithParameter: (cmd: ESQLAstRerankCommand, key: string, value: string | ESQLStringLiteral | ESQLParamLiteral) => void;
|
|
41
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/ast/mutate/commands/rerank/index.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EACV,sBAAsB,EACtB,oBAAoB,EAEpB,iBAAiB,EACjB,gBAAgB,EAKjB,MAAM,mBAAmB,CAAC;AAG3B;;;;;GAKG;AACH,eAAO,MAAM,IAAI,GAAI,KAAK,sBAAsB,KAAG,gBAAgB,CAAC,oBAAoB,CAKvF,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,GAAI,KAAK,oBAAoB,EAAE,OAAO,MAAM,GAAG,iBAAiB,SAkBpF,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc,GAAI,KAAK,oBAAoB,EAAE,QAAQ,MAAM,GAAG,IAAI,SA+B9E,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,SAAS,GACpB,KAAK,oBAAoB,EACzB,QAAQ,MAAM,EAAE,GAAG,oBAAoB,CAAC,QAAQ,CAAC,SAwBlD,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB,GAC3B,KAAK,oBAAoB,EACzB,KAAK,MAAM,EACX,OAAO,MAAM,GAAG,iBAAiB,GAAG,gBAAgB,SAqErD,CAAC"}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import type { ESQLAstQueryExpression, ESQLColumn, ESQLCommand, ESQLOrderExpression } from '../../../../types';
|
|
2
|
+
import type { Predicate } from '../../types';
|
|
3
|
+
export type SortExpression = ESQLOrderExpression | ESQLColumn;
|
|
4
|
+
/**
|
|
5
|
+
* This "template" allows the developer to easily specify a new sort expression
|
|
6
|
+
* AST node, for example:
|
|
7
|
+
*
|
|
8
|
+
* ```ts
|
|
9
|
+
* // as a simple string
|
|
10
|
+
* 'column_name'
|
|
11
|
+
*
|
|
12
|
+
* // column with nested fields
|
|
13
|
+
* ['column_name', 'nested_field']
|
|
14
|
+
*
|
|
15
|
+
* // as an object with additional options
|
|
16
|
+
* { parts: 'column_name', order: 'ASC', nulls: 'NULLS FIRST' }
|
|
17
|
+
* { parts: ['column_name', 'nested_field'], order: 'DESC', nulls: 'NULLS LAST' }
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export type NewSortExpressionTemplate = string | string[] | {
|
|
21
|
+
parts: string | string[];
|
|
22
|
+
order?: ESQLOrderExpression['order'];
|
|
23
|
+
nulls?: ESQLOrderExpression['nulls'];
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Iterates through all sort commands starting from the beginning of the query.
|
|
27
|
+
* You can specify the `skip` parameter to skip a given number of sort commands.
|
|
28
|
+
*
|
|
29
|
+
* @param ast The root of the AST.
|
|
30
|
+
* @param skip Number of sort commands to skip.
|
|
31
|
+
* @returns Iterator through all sort commands.
|
|
32
|
+
*/
|
|
33
|
+
export declare const listCommands: (ast: ESQLAstQueryExpression, skip?: number) => IterableIterator<ESQLCommand>;
|
|
34
|
+
/**
|
|
35
|
+
* Returns the Nth SORT command found in the query.
|
|
36
|
+
*
|
|
37
|
+
* @param ast The root of the AST.
|
|
38
|
+
* @param index The index (N) of the sort command to return.
|
|
39
|
+
* @returns The sort command found in the AST, if any.
|
|
40
|
+
*/
|
|
41
|
+
export declare const getCommand: (ast: ESQLAstQueryExpression, index?: number) => ESQLCommand | undefined;
|
|
42
|
+
/**
|
|
43
|
+
* Returns an iterator for all sort expressions (columns and order expressions)
|
|
44
|
+
* in the query. You can specify the `skip` parameter to skip a given number of
|
|
45
|
+
* expressions.
|
|
46
|
+
*
|
|
47
|
+
* @param ast The root of the AST.
|
|
48
|
+
* @param skip Number of sort expressions to skip.
|
|
49
|
+
* @returns Iterator through sort expressions (columns and order expressions).
|
|
50
|
+
*/
|
|
51
|
+
export declare const list: (ast: ESQLAstQueryExpression, skip?: number) => IterableIterator<[sortExpression: SortExpression, sortCommand: ESQLCommand]>;
|
|
52
|
+
/**
|
|
53
|
+
* Finds the Nts sort expression that matches the predicate.
|
|
54
|
+
*
|
|
55
|
+
* @param ast The root of the AST.
|
|
56
|
+
* @param predicate A function that returns true if the sort expression matches
|
|
57
|
+
* the predicate.
|
|
58
|
+
* @param index The index of the sort expression to return. If not specified,
|
|
59
|
+
* the first sort expression that matches the predicate will be returned.
|
|
60
|
+
* @returns The sort expressions and sort command 2-tuple that matches the
|
|
61
|
+
* predicate, if any.
|
|
62
|
+
*/
|
|
63
|
+
export declare const findByPredicate: (ast: ESQLAstQueryExpression, predicate: Predicate<[sortExpression: SortExpression, sortCommand: ESQLCommand]>, index?: number) => [sortExpression: SortExpression, sortCommand: ESQLCommand] | undefined;
|
|
64
|
+
/**
|
|
65
|
+
* Finds the Nth sort expression that matches the sort expression by column
|
|
66
|
+
* name. The `parts` argument allows to specify an array of nested field names.
|
|
67
|
+
*
|
|
68
|
+
* @param ast The root of the AST.
|
|
69
|
+
* @param parts A string or an array of strings representing the column name.
|
|
70
|
+
* @returns The sort expressions and sort command 2-tuple that matches the
|
|
71
|
+
* predicate, if any.
|
|
72
|
+
*/
|
|
73
|
+
export declare const find: (ast: ESQLAstQueryExpression, parts: string | string[], index?: number) => [sortExpression: SortExpression, sortCommand: ESQLCommand] | undefined;
|
|
74
|
+
/**
|
|
75
|
+
* Removes the Nth sort expression that matches the sort expression by column
|
|
76
|
+
* name. The `parts` argument allows to specify an array of nested field names.
|
|
77
|
+
*
|
|
78
|
+
* @param ast The root of the AST.
|
|
79
|
+
* @param parts A string or an array of strings representing the column name.
|
|
80
|
+
* @param index The index of the sort expression to remove.
|
|
81
|
+
* @returns The sort expressions and sort command 2-tuple that was removed, if any.
|
|
82
|
+
*/
|
|
83
|
+
export declare const remove: (ast: ESQLAstQueryExpression, parts: string | string[], index?: number) => [sortExpression: SortExpression, sortCommand: ESQLCommand] | undefined;
|
|
84
|
+
/**
|
|
85
|
+
* Inserts a new sort expression into the specified SORT command at the
|
|
86
|
+
* specified argument position.
|
|
87
|
+
*
|
|
88
|
+
* @param sortCommand The SORT command to insert the new sort expression into.
|
|
89
|
+
* @param template The sort expression template.
|
|
90
|
+
* @param index Argument position in the command argument list.
|
|
91
|
+
* @returns The inserted sort expression.
|
|
92
|
+
*/
|
|
93
|
+
export declare const insertIntoCommand: (sortCommand: ESQLCommand, template: NewSortExpressionTemplate, index?: number) => SortExpression;
|
|
94
|
+
/**
|
|
95
|
+
* Creates a new sort expression node and inserts it into the specified SORT
|
|
96
|
+
* command at the specified argument position. If not sort command is found, a
|
|
97
|
+
* new one is created and appended to the end of the query.
|
|
98
|
+
*
|
|
99
|
+
* @param ast The root AST node.
|
|
100
|
+
* @param parts ES|QL column name parts.
|
|
101
|
+
* @param index The new column name position in command argument list.
|
|
102
|
+
* @param sortCommandIndex The index of the SORT command in the AST. E.g. 0 is the
|
|
103
|
+
* first SORT command in the AST.
|
|
104
|
+
* @returns The inserted column AST node.
|
|
105
|
+
*/
|
|
106
|
+
export declare const insertExpression: (ast: ESQLAstQueryExpression, template: NewSortExpressionTemplate, index?: number, sortCommandIndex?: number) => SortExpression;
|
|
107
|
+
/**
|
|
108
|
+
* Inserts a new SORT command with a single sort expression as its sole argument.
|
|
109
|
+
* You can specify the position to insert the command at.
|
|
110
|
+
*
|
|
111
|
+
* @param ast The root of the AST.
|
|
112
|
+
* @param template The sort expression template.
|
|
113
|
+
* @param index The position to insert the sort expression at.
|
|
114
|
+
* @returns The inserted sort expression and the command it was inserted into.
|
|
115
|
+
*/
|
|
116
|
+
export declare const insertCommand: (ast: ESQLAstQueryExpression, template: NewSortExpressionTemplate, index?: number) => [ESQLCommand, SortExpression];
|
|
117
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/ast/mutate/commands/sort/index.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EACV,sBAAsB,EACtB,UAAU,EACV,WAAW,EACX,mBAAmB,EACpB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAI7C,MAAM,MAAM,cAAc,GAAG,mBAAmB,GAAG,UAAU,CAAC;AAE9D;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,yBAAyB,GACjC,MAAM,GACN,MAAM,EAAE,GACR;IACE,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACzB,KAAK,CAAC,EAAE,mBAAmB,CAAC,OAAO,CAAC,CAAC;IACrC,KAAK,CAAC,EAAE,mBAAmB,CAAC,OAAO,CAAC,CAAC;CACtC,CAAC;AA8BN;;;;;;;GAOG;AACH,eAAO,MAAM,YAAY,GACvB,KAAK,sBAAsB,EAC3B,OAAM,MAAU,KACf,gBAAgB,CAAC,WAAW,CAgB9B,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,GACrB,KAAK,sBAAsB,EAC3B,QAAO,MAAU,KAChB,WAAW,GAAG,SAIhB,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,IAAI,GACf,KAAK,sBAAsB,EAC3B,OAAM,MAAU,KACf,gBAAgB,CAAC,CAAC,cAAc,EAAE,cAAc,EAAE,WAAW,EAAE,WAAW,CAAC,CAoB7E,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,eAAe,GAC1B,KAAK,sBAAsB,EAC3B,WAAW,SAAS,CAAC,CAAC,cAAc,EAAE,cAAc,EAAE,WAAW,EAAE,WAAW,CAAC,CAAC,EAChF,QAAQ,MAAM,KACb,CAAC,cAAc,EAAE,cAAc,EAAE,WAAW,EAAE,WAAW,CAAC,GAAG,SAE/D,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,IAAI,GACf,KAAK,sBAAsB,EAC3B,OAAO,MAAM,GAAG,MAAM,EAAE,EACxB,QAAO,MAAU,KAChB,CAAC,cAAc,EAAE,cAAc,EAAE,WAAW,EAAE,WAAW,CAAC,GAAG,SA8B/D,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,MAAM,GACjB,KAAK,sBAAsB,EAC3B,OAAO,MAAM,GAAG,MAAM,EAAE,EACxB,QAAQ,MAAM,KACb,CAAC,cAAc,EAAE,cAAc,EAAE,WAAW,EAAE,WAAW,CAAC,GAAG,SAiB/D,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,iBAAiB,GAC5B,aAAa,WAAW,EACxB,UAAU,yBAAyB,EACnC,QAAQ,MAAM,KACb,cAMF,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,gBAAgB,GAC3B,KAAK,sBAAsB,EAC3B,UAAU,yBAAyB,EACnC,QAAO,MAAW,EAClB,mBAAkB,MAAU,KAC3B,cASF,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,aAAa,GACxB,KAAK,sBAAsB,EAC3B,UAAU,yBAAyB,EACnC,QAAO,MAAW,KACjB,CAAC,WAAW,EAAE,cAAc,CAO9B,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ESQLAstQueryExpression, ESQLCommand } from '../../../../types';
|
|
2
|
+
/**
|
|
3
|
+
* Lists all "STATS" commands in the query AST.
|
|
4
|
+
*
|
|
5
|
+
* @param ast The root AST node to search for "STATS" commands.
|
|
6
|
+
* @returns A collection of "STATS" commands.
|
|
7
|
+
*/
|
|
8
|
+
export declare const list: (ast: ESQLAstQueryExpression) => IterableIterator<ESQLCommand>;
|
|
9
|
+
/**
|
|
10
|
+
* Retrieves the "STATS" command at the specified index in order of appearance.
|
|
11
|
+
*
|
|
12
|
+
* @param ast The root AST node to search for "STATS" commands.
|
|
13
|
+
* @param index The index of the "STATS" command to retrieve.
|
|
14
|
+
* @returns The "STATS" command at the specified index, if any.
|
|
15
|
+
*/
|
|
16
|
+
export declare const byIndex: (ast: ESQLAstQueryExpression, index: number) => ESQLCommand | undefined;
|
|
17
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/ast/mutate/commands/stats/index.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,sBAAsB,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAG7E;;;;;GAKG;AACH,eAAO,MAAM,IAAI,GAAI,KAAK,sBAAsB,KAAG,gBAAgB,CAAC,WAAW,CAE9E,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,OAAO,GAAI,KAAK,sBAAsB,EAAE,OAAO,MAAM,KAAG,WAAW,GAAG,SAElF,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { ESQLAstQueryExpression, ESQLColumn, ESQLCommand, ESQLIdentifier, ESQLParamLiteral, ESQLProperNode } from '../../../../types';
|
|
2
|
+
/**
|
|
3
|
+
* Lists all "WHERE" commands in the query AST.
|
|
4
|
+
*
|
|
5
|
+
* @param ast The root AST node to search for "WHERE" commands.
|
|
6
|
+
* @returns A collection of "WHERE" commands.
|
|
7
|
+
*/
|
|
8
|
+
export declare const list: (ast: ESQLAstQueryExpression) => IterableIterator<ESQLCommand>;
|
|
9
|
+
/**
|
|
10
|
+
* Retrieves the "WHERE" command at the specified index in order of appearance.
|
|
11
|
+
*
|
|
12
|
+
* @param ast The root AST node to search for "WHERE" commands.
|
|
13
|
+
* @param index The index of the "WHERE" command to retrieve.
|
|
14
|
+
* @returns The "WHERE" command at the specified index, if any.
|
|
15
|
+
*/
|
|
16
|
+
export declare const byIndex: (ast: ESQLAstQueryExpression, index: number) => ESQLCommand | undefined;
|
|
17
|
+
export type ESQLAstField = ESQLColumn | ESQLIdentifier | ESQLParamLiteral;
|
|
18
|
+
export type ESQLAstFieldTemplate = string | string[] | ESQLAstField;
|
|
19
|
+
/**
|
|
20
|
+
* Finds the first "WHERE" command which contains the specified text as one of
|
|
21
|
+
* its comparison operands. The text can represent a field (including nested
|
|
22
|
+
* fields or a single identifier), or a param. If the text starts with "?", it
|
|
23
|
+
* is assumed to be a param.
|
|
24
|
+
*
|
|
25
|
+
* Examples:
|
|
26
|
+
*
|
|
27
|
+
* ```ts
|
|
28
|
+
* byField(ast, 'field');
|
|
29
|
+
* byField(ast, ['nested', 'field']);
|
|
30
|
+
* byField(ast, '?param');
|
|
31
|
+
* byField(ast, ['nested', '?param']);
|
|
32
|
+
* byField(ast, ['nested', 'positional', 'param', '?123']);
|
|
33
|
+
* byField(ast, '?');
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* Alternatively you can build your own field template using the builder:
|
|
37
|
+
*
|
|
38
|
+
* ```ts
|
|
39
|
+
* byField(ast, Builder.expression.column({
|
|
40
|
+
* args: [Builder.identifier({ name: 'field' })]
|
|
41
|
+
* }));
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
* @param ast The root AST node search for "WHERE" commands.
|
|
45
|
+
* @param text The text or nested column name texts to search for.
|
|
46
|
+
*/
|
|
47
|
+
export declare const byField: (ast: ESQLAstQueryExpression, template: ESQLAstFieldTemplate) => [command: ESQLCommand, field: ESQLProperNode] | undefined;
|
|
48
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/ast/mutate/commands/where/index.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EACV,sBAAsB,EACtB,UAAU,EACV,WAAW,EACX,cAAc,EACd,gBAAgB,EAChB,cAAc,EACf,MAAM,mBAAmB,CAAC;AAG3B;;;;;GAKG;AACH,eAAO,MAAM,IAAI,GAAI,KAAK,sBAAsB,KAAG,gBAAgB,CAAC,WAAW,CAE9E,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,OAAO,GAAI,KAAK,sBAAsB,EAAE,OAAO,MAAM,KAAG,WAAW,GAAG,SAElF,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG,UAAU,GAAG,cAAc,GAAG,gBAAgB,CAAC;AAC1E,MAAM,MAAM,oBAAoB,GAAG,MAAM,GAAG,MAAM,EAAE,GAAG,YAAY,CAAC;AA4BpE;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,OAAO,GAClB,KAAK,sBAAsB,EAC3B,UAAU,oBAAoB,KAC7B,CAAC,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,cAAc,CAAC,GAAG,SA2BlD,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ESQLAstQueryExpression, ESQLCommand, ESQLProperNode, ESQLSingleAstItem } from '../../../../../types';
|
|
2
|
+
export declare const insert: (command: ESQLCommand, expression: ESQLSingleAstItem, index?: number) => number;
|
|
3
|
+
export declare const append: (command: ESQLCommand, expression: ESQLSingleAstItem) => number;
|
|
4
|
+
/**
|
|
5
|
+
* Searches all command arguments in the query AST node and removes the node
|
|
6
|
+
* from the command's arguments list. This function recursively searches through
|
|
7
|
+
* subqueries as well.
|
|
8
|
+
*
|
|
9
|
+
* @param ast The root AST node to search for command arguments.
|
|
10
|
+
* @param node The argument AST node to remove.
|
|
11
|
+
* @returns Returns the command that the argument was removed from, if any.
|
|
12
|
+
*/
|
|
13
|
+
export declare const remove: (ast: ESQLAstQueryExpression, node: ESQLProperNode) => ESQLCommand | undefined;
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/ast/mutate/generic/commands/args/index.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EACV,sBAAsB,EACtB,WAAW,EACX,cAAc,EACd,iBAAiB,EAClB,MAAM,sBAAsB,CAAC;AAG9B,eAAO,MAAM,MAAM,GACjB,SAAS,WAAW,EACpB,YAAY,iBAAiB,EAC7B,QAAO,MAAW,KACjB,MAqBF,CAAC;AAEF,eAAO,MAAM,MAAM,GAAI,SAAS,WAAW,EAAE,YAAY,iBAAiB,KAAG,MAE5E,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,MAAM,GACjB,KAAK,sBAAsB,EAC3B,MAAM,cAAc,KACnB,WAAW,GAAG,SAmChB,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { ESQLAstQueryExpression, ESQLCommand } from '../../../../types';
|
|
2
|
+
import type { Predicate } from '../../types';
|
|
3
|
+
export * as args from './args';
|
|
4
|
+
export * as options from './options';
|
|
5
|
+
/**
|
|
6
|
+
* Returns an iterator for all command AST nodes in the query. If a predicate is
|
|
7
|
+
* provided, only commands that satisfy the predicate will be returned.
|
|
8
|
+
*
|
|
9
|
+
* @param ast Root AST node to search for commands.
|
|
10
|
+
* @param predicate Optional predicate to filter commands.
|
|
11
|
+
* @returns A list of commands found in the AST.
|
|
12
|
+
*/
|
|
13
|
+
export declare const list: (ast: ESQLAstQueryExpression, predicate?: Predicate<ESQLCommand>) => IterableIterator<ESQLCommand>;
|
|
14
|
+
/**
|
|
15
|
+
* Returns the first command AST node at a given index in the query that
|
|
16
|
+
* satisfies the predicate. If no index is provided, the first command found
|
|
17
|
+
* will be returned.
|
|
18
|
+
*
|
|
19
|
+
* @param ast Root AST node to search for commands.
|
|
20
|
+
* @param predicate Optional predicate to filter commands.
|
|
21
|
+
* @param index The index of the command to return.
|
|
22
|
+
* @returns The command found in the AST, if any.
|
|
23
|
+
*/
|
|
24
|
+
export declare const find: (ast: ESQLAstQueryExpression, predicate?: Predicate<ESQLCommand>, index?: number) => ESQLCommand | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* Returns the first command AST node at a given index with a given name in the
|
|
27
|
+
* query. If no index is provided, the first command found will be returned.
|
|
28
|
+
*
|
|
29
|
+
* @param ast Root AST node to search for commands.
|
|
30
|
+
* @param commandName The name of the command to find.
|
|
31
|
+
* @param index The index of the command to return.
|
|
32
|
+
* @returns The command found in the AST, if any.
|
|
33
|
+
*/
|
|
34
|
+
export declare const findByName: (ast: ESQLAstQueryExpression, commandName: string, index?: number) => ESQLCommand | undefined;
|
|
35
|
+
/**
|
|
36
|
+
* Inserts a new command into the query AST node at the specified index. If the
|
|
37
|
+
* `index` is out of bounds, the command will be appended to the end of the
|
|
38
|
+
* command list.
|
|
39
|
+
*
|
|
40
|
+
* @param ast The root AST node.
|
|
41
|
+
* @param command The command AST node to insert.
|
|
42
|
+
* @param index The index to insert the command at.
|
|
43
|
+
* @returns The index the command was inserted at.
|
|
44
|
+
*/
|
|
45
|
+
export declare const insert: (ast: ESQLAstQueryExpression, command: ESQLCommand, index?: number) => number;
|
|
46
|
+
/**
|
|
47
|
+
* Adds a new command to the query AST node.
|
|
48
|
+
*
|
|
49
|
+
* @param ast The root AST node to append the command to.
|
|
50
|
+
* @param command The command AST node to append.
|
|
51
|
+
*/
|
|
52
|
+
export declare const append: (ast: ESQLAstQueryExpression, command: ESQLCommand) => void;
|
|
53
|
+
export declare const remove: (ast: ESQLAstQueryExpression, command: ESQLCommand) => boolean;
|
|
54
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/ast/mutate/generic/commands/index.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,sBAAsB,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAE7E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC;AAC/B,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AAErC;;;;;;;GAOG;AACH,eAAO,MAAM,IAAI,GACf,KAAK,sBAAsB,EAC3B,YAAY,SAAS,CAAC,WAAW,CAAC,KACjC,gBAAgB,CAAC,WAAW,CAU9B,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,IAAI,GACf,KAAK,sBAAsB,EAC3B,YAAY,SAAS,CAAC,WAAW,CAAC,EAClC,QAAO,MAAU,KAChB,WAAW,GAAG,SAUhB,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,UAAU,GACrB,KAAK,sBAAsB,EAC3B,aAAa,MAAM,EACnB,QAAO,MAAU,KAChB,WAAW,GAAG,SAEhB,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,MAAM,GACjB,KAAK,sBAAsB,EAC3B,SAAS,WAAW,EACpB,QAAO,MAAiB,KACvB,MAUF,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,MAAM,GAAI,KAAK,sBAAsB,EAAE,SAAS,WAAW,KAAG,IAE1E,CAAC;AAEF,eAAO,MAAM,MAAM,GAAI,KAAK,sBAAsB,EAAE,SAAS,WAAW,KAAG,OAY1E,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { ESQLAstQueryExpression, ESQLCommand, ESQLCommandOption } from '../../../../../types';
|
|
2
|
+
import type { Predicate } from '../../../types';
|
|
3
|
+
/**
|
|
4
|
+
* Returns the first command option AST node that satisfies the predicate.
|
|
5
|
+
*
|
|
6
|
+
* @param command The command AST node to search for options.
|
|
7
|
+
* @param predicate The predicate to filter options.
|
|
8
|
+
* @returns The option found in the command, if any.
|
|
9
|
+
*/
|
|
10
|
+
export declare const find: (command: ESQLCommand, predicate: Predicate<ESQLCommandOption>) => ESQLCommandOption | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* Returns the first command option AST node with a given name in the query.
|
|
13
|
+
*
|
|
14
|
+
* @param ast The root AST node to search for command options.
|
|
15
|
+
* @param commandName Command name to search for.
|
|
16
|
+
* @param optionName Option name to search for.
|
|
17
|
+
* @returns The option found in the command, if any.
|
|
18
|
+
*/
|
|
19
|
+
export declare const findByName: (ast: ESQLAstQueryExpression, commandName: string, optionName: string) => ESQLCommandOption | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* Inserts a command option into the command's arguments list. The option can
|
|
22
|
+
* be specified as a string or an AST node.
|
|
23
|
+
*
|
|
24
|
+
* @param command The command AST node to insert the option into.
|
|
25
|
+
* @param option The option to insert.
|
|
26
|
+
* @returns The inserted option.
|
|
27
|
+
*/
|
|
28
|
+
export declare const append: (command: ESQLCommand, option: string | ESQLCommandOption) => ESQLCommandOption;
|
|
29
|
+
/**
|
|
30
|
+
* Removes the first command option from the command's arguments list that
|
|
31
|
+
* satisfies the predicate.
|
|
32
|
+
*
|
|
33
|
+
* @param command The command AST node to remove the option from.
|
|
34
|
+
* @param predicate The predicate to filter options.
|
|
35
|
+
* @returns The removed option, if any.
|
|
36
|
+
*/
|
|
37
|
+
export declare const remove: (ast: ESQLAstQueryExpression, option: ESQLCommandOption) => boolean;
|
|
38
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/ast/mutate/generic/commands/options/index.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAEV,sBAAsB,EACtB,WAAW,EACX,iBAAiB,EAClB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAGhD;;;;;;GAMG;AACH,eAAO,MAAM,IAAI,GACf,SAAS,WAAW,EACpB,WAAW,SAAS,CAAC,iBAAiB,CAAC,KACtC,iBAAiB,GAAG,SAYtB,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,UAAU,GACrB,KAAK,sBAAsB,EAC3B,aAAa,MAAM,EACnB,YAAY,MAAM,KACjB,iBAAiB,GAAG,SAQtB,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,MAAM,GACjB,SAAS,WAAW,EACpB,QAAQ,MAAM,GAAG,iBAAiB,KACjC,iBAQF,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,MAAM,GAAI,KAAK,sBAAsB,EAAE,QAAQ,iBAAiB,KAAG,OAuC/E,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/ast/mutate/generic/index.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,QAAQ,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ast/mutate/index.ts"],"names":[],"mappings":"AAOA,mBAAmB,SAAS,CAAC;AAE7B,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AACrC,OAAO,KAAK,QAAQ,MAAM,YAAY,CAAC;AAEvC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/ast/mutate/types.ts"],"names":[],"mappings":"AAOA,MAAM,MAAM,SAAS,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,KAAK,OAAO,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Predicate } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Find the first item in an iterable (such as array) that matches a predicate.
|
|
4
|
+
*
|
|
5
|
+
* @param iterable List of items to search through.
|
|
6
|
+
* @param predicate Function to determine if an item is the one we are looking
|
|
7
|
+
* for.
|
|
8
|
+
* @returns The first item that matches the predicate, or undefined if no item
|
|
9
|
+
* matches.
|
|
10
|
+
*/
|
|
11
|
+
export declare const findByPredicate: <T>(iterable: IterableIterator<T>, predicate: Predicate<T>) => T | undefined;
|
|
12
|
+
/**
|
|
13
|
+
* Shallowly compares two arrays for equality.
|
|
14
|
+
*
|
|
15
|
+
* @param a The first array to compare.
|
|
16
|
+
* @param b The second array to compare.
|
|
17
|
+
* @returns True if the arrays are equal, false otherwise.
|
|
18
|
+
*/
|
|
19
|
+
export declare const cmpArr: <T>(a: T[], b: T[]) => boolean;
|
|
20
|
+
//# sourceMappingURL=util.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../../src/ast/mutate/util.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEzC;;;;;;;;GAQG;AACH,eAAO,MAAM,eAAe,GAAI,CAAC,EAC/B,UAAU,gBAAgB,CAAC,CAAC,CAAC,EAC7B,WAAW,SAAS,CAAC,CAAC,CAAC,KACtB,CAAC,GAAG,SAON,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,MAAM,GAAI,CAAC,EAAE,GAAG,CAAC,EAAE,EAAE,GAAG,CAAC,EAAE,KAAG,OAY1C,CAAC"}
|