@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.

Potentially problematic release.


This version of @elastic/esql might be problematic. Click here for more details.

Files changed (212) hide show
  1. package/LICENCE.txt +93 -0
  2. package/NOTICE.txt +5 -0
  3. package/README.md +167 -0
  4. package/lib/__tests__/fixtures.d.ts +4 -0
  5. package/lib/__tests__/fixtures.d.ts.map +1 -0
  6. package/lib/ast/builder/builder.d.ts +87 -0
  7. package/lib/ast/builder/builder.d.ts.map +1 -0
  8. package/lib/ast/builder/index.d.ts +3 -0
  9. package/lib/ast/builder/index.d.ts.map +1 -0
  10. package/lib/ast/builder/types.d.ts +18 -0
  11. package/lib/ast/builder/types.d.ts.map +1 -0
  12. package/lib/ast/grouping.d.ts +70 -0
  13. package/lib/ast/grouping.d.ts.map +1 -0
  14. package/lib/ast/index.d.ts +9 -0
  15. package/lib/ast/index.d.ts.map +1 -0
  16. package/lib/ast/is.d.ts +49 -0
  17. package/lib/ast/is.d.ts.map +1 -0
  18. package/lib/ast/location.d.ts +7 -0
  19. package/lib/ast/location.d.ts.map +1 -0
  20. package/lib/ast/mutate/commands/from/index.d.ts +4 -0
  21. package/lib/ast/mutate/commands/from/index.d.ts.map +1 -0
  22. package/lib/ast/mutate/commands/from/metadata.d.ts +63 -0
  23. package/lib/ast/mutate/commands/from/metadata.d.ts.map +1 -0
  24. package/lib/ast/mutate/commands/from/sources.d.ts +9 -0
  25. package/lib/ast/mutate/commands/from/sources.d.ts.map +1 -0
  26. package/lib/ast/mutate/commands/index.d.ts +9 -0
  27. package/lib/ast/mutate/commands/index.d.ts.map +1 -0
  28. package/lib/ast/mutate/commands/join/index.d.ts +17 -0
  29. package/lib/ast/mutate/commands/join/index.d.ts.map +1 -0
  30. package/lib/ast/mutate/commands/limit/index.d.ts +56 -0
  31. package/lib/ast/mutate/commands/limit/index.d.ts.map +1 -0
  32. package/lib/ast/mutate/commands/rerank/index.d.ts +41 -0
  33. package/lib/ast/mutate/commands/rerank/index.d.ts.map +1 -0
  34. package/lib/ast/mutate/commands/sort/index.d.ts +117 -0
  35. package/lib/ast/mutate/commands/sort/index.d.ts.map +1 -0
  36. package/lib/ast/mutate/commands/stats/index.d.ts +17 -0
  37. package/lib/ast/mutate/commands/stats/index.d.ts.map +1 -0
  38. package/lib/ast/mutate/commands/where/index.d.ts +48 -0
  39. package/lib/ast/mutate/commands/where/index.d.ts.map +1 -0
  40. package/lib/ast/mutate/generic/commands/args/index.d.ts +14 -0
  41. package/lib/ast/mutate/generic/commands/args/index.d.ts.map +1 -0
  42. package/lib/ast/mutate/generic/commands/index.d.ts +54 -0
  43. package/lib/ast/mutate/generic/commands/index.d.ts.map +1 -0
  44. package/lib/ast/mutate/generic/commands/options/index.d.ts +38 -0
  45. package/lib/ast/mutate/generic/commands/options/index.d.ts.map +1 -0
  46. package/lib/ast/mutate/generic/index.d.ts +2 -0
  47. package/lib/ast/mutate/generic/index.d.ts.map +1 -0
  48. package/lib/ast/mutate/index.d.ts +5 -0
  49. package/lib/ast/mutate/index.d.ts.map +1 -0
  50. package/lib/ast/mutate/types.d.ts +2 -0
  51. package/lib/ast/mutate/types.d.ts.map +1 -0
  52. package/lib/ast/mutate/util.d.ts +20 -0
  53. package/lib/ast/mutate/util.d.ts.map +1 -0
  54. package/lib/ast/visitor/contexts.d.ts +176 -0
  55. package/lib/ast/visitor/contexts.d.ts.map +1 -0
  56. package/lib/ast/visitor/global_visitor_context.d.ts +77 -0
  57. package/lib/ast/visitor/global_visitor_context.d.ts.map +1 -0
  58. package/lib/ast/visitor/index.d.ts +5 -0
  59. package/lib/ast/visitor/index.d.ts.map +1 -0
  60. package/lib/ast/visitor/types.d.ts +104 -0
  61. package/lib/ast/visitor/types.d.ts.map +1 -0
  62. package/lib/ast/visitor/utils.d.ts +26 -0
  63. package/lib/ast/visitor/utils.d.ts.map +1 -0
  64. package/lib/ast/visitor/visitor.d.ts +79 -0
  65. package/lib/ast/visitor/visitor.d.ts.map +1 -0
  66. package/lib/ast/walker/helpers.d.ts +23 -0
  67. package/lib/ast/walker/helpers.d.ts.map +1 -0
  68. package/lib/ast/walker/index.d.ts +2 -0
  69. package/lib/ast/walker/index.d.ts.map +1 -0
  70. package/lib/ast/walker/walker.d.ts +266 -0
  71. package/lib/ast/walker/walker.d.ts.map +1 -0
  72. package/lib/composer/composer_query.d.ts +684 -0
  73. package/lib/composer/composer_query.d.ts.map +1 -0
  74. package/lib/composer/esql.d.ts +25 -0
  75. package/lib/composer/esql.d.ts.map +1 -0
  76. package/lib/composer/index.d.ts +8 -0
  77. package/lib/composer/index.d.ts.map +1 -0
  78. package/lib/composer/parameter_hole.d.ts +11 -0
  79. package/lib/composer/parameter_hole.d.ts.map +1 -0
  80. package/lib/composer/query/index.d.ts +2 -0
  81. package/lib/composer/query/index.d.ts.map +1 -0
  82. package/lib/composer/query/query.d.ts +54 -0
  83. package/lib/composer/query/query.d.ts.map +1 -0
  84. package/lib/composer/synth/command.d.ts +7 -0
  85. package/lib/composer/synth/command.d.ts.map +1 -0
  86. package/lib/composer/synth/expression.d.ts +6 -0
  87. package/lib/composer/synth/expression.d.ts.map +1 -0
  88. package/lib/composer/synth/header.d.ts +7 -0
  89. package/lib/composer/synth/header.d.ts.map +1 -0
  90. package/lib/composer/synth/holes.d.ts +27 -0
  91. package/lib/composer/synth/holes.d.ts.map +1 -0
  92. package/lib/composer/synth/index.d.ts +7 -0
  93. package/lib/composer/synth/index.d.ts.map +1 -0
  94. package/lib/composer/synth/nodes.d.ts +104 -0
  95. package/lib/composer/synth/nodes.d.ts.map +1 -0
  96. package/lib/composer/synth/query.d.ts +7 -0
  97. package/lib/composer/synth/query.d.ts.map +1 -0
  98. package/lib/composer/synth/synth_literal_fragment.d.ts +19 -0
  99. package/lib/composer/synth/synth_literal_fragment.d.ts.map +1 -0
  100. package/lib/composer/synth/synth_node.d.ts +19 -0
  101. package/lib/composer/synth/synth_node.d.ts.map +1 -0
  102. package/lib/composer/synth/tag.d.ts +4 -0
  103. package/lib/composer/synth/tag.d.ts.map +1 -0
  104. package/lib/composer/synth/types.d.ts +65 -0
  105. package/lib/composer/synth/types.d.ts.map +1 -0
  106. package/lib/composer/types.d.ts +218 -0
  107. package/lib/composer/types.d.ts.map +1 -0
  108. package/lib/composer/util.d.ts +24 -0
  109. package/lib/composer/util.d.ts.map +1 -0
  110. package/lib/debug/index.d.ts +2 -0
  111. package/lib/debug/index.d.ts.map +1 -0
  112. package/lib/debug/print_ast.d.ts +60 -0
  113. package/lib/debug/print_ast.d.ts.map +1 -0
  114. package/lib/embedded_languages/index.d.ts +2 -0
  115. package/lib/embedded_languages/index.d.ts.map +1 -0
  116. package/lib/embedded_languages/promql/ast/builder/builder.d.ts +52 -0
  117. package/lib/embedded_languages/promql/ast/builder/builder.d.ts.map +1 -0
  118. package/lib/embedded_languages/promql/ast/builder/index.d.ts +3 -0
  119. package/lib/embedded_languages/promql/ast/builder/index.d.ts.map +1 -0
  120. package/lib/embedded_languages/promql/ast/builder/types.d.ts +12 -0
  121. package/lib/embedded_languages/promql/ast/builder/types.d.ts.map +1 -0
  122. package/lib/embedded_languages/promql/ast/is.d.ts +3 -0
  123. package/lib/embedded_languages/promql/ast/is.d.ts.map +1 -0
  124. package/lib/embedded_languages/promql/ast/traversal.d.ts +3 -0
  125. package/lib/embedded_languages/promql/ast/traversal.d.ts.map +1 -0
  126. package/lib/embedded_languages/promql/ast/walker/index.d.ts +3 -0
  127. package/lib/embedded_languages/promql/ast/walker/index.d.ts.map +1 -0
  128. package/lib/embedded_languages/promql/ast/walker/types.d.ts +93 -0
  129. package/lib/embedded_languages/promql/ast/walker/types.d.ts.map +1 -0
  130. package/lib/embedded_languages/promql/ast/walker/walker.d.ts +43 -0
  131. package/lib/embedded_languages/promql/ast/walker/walker.d.ts.map +1 -0
  132. package/lib/embedded_languages/promql/index.d.ts +8 -0
  133. package/lib/embedded_languages/promql/index.d.ts.map +1 -0
  134. package/lib/embedded_languages/promql/parser/cst_to_ast_converter.d.ts +48 -0
  135. package/lib/embedded_languages/promql/parser/cst_to_ast_converter.d.ts.map +1 -0
  136. package/lib/embedded_languages/promql/parser/index.d.ts +4 -0
  137. package/lib/embedded_languages/promql/parser/index.d.ts.map +1 -0
  138. package/lib/embedded_languages/promql/parser/parser.d.ts +65 -0
  139. package/lib/embedded_languages/promql/parser/parser.d.ts.map +1 -0
  140. package/lib/embedded_languages/promql/parser/promql_error_listener.d.ts +11 -0
  141. package/lib/embedded_languages/promql/parser/promql_error_listener.d.ts.map +1 -0
  142. package/lib/embedded_languages/promql/pretty_print/basic_pretty_printer.d.ts +65 -0
  143. package/lib/embedded_languages/promql/pretty_print/basic_pretty_printer.d.ts.map +1 -0
  144. package/lib/embedded_languages/promql/pretty_print/helpers.d.ts +34 -0
  145. package/lib/embedded_languages/promql/pretty_print/helpers.d.ts.map +1 -0
  146. package/lib/embedded_languages/promql/pretty_print/index.d.ts +2 -0
  147. package/lib/embedded_languages/promql/pretty_print/index.d.ts.map +1 -0
  148. package/lib/embedded_languages/promql/types.d.ts +355 -0
  149. package/lib/embedded_languages/promql/types.d.ts.map +1 -0
  150. package/lib/index.d.ts +7 -0
  151. package/lib/index.d.ts.map +1 -0
  152. package/lib/index.js +63055 -0
  153. package/lib/index.js.map +1 -0
  154. package/lib/index.mjs +62941 -0
  155. package/lib/index.mjs.map +1 -0
  156. package/lib/parser/antlr/esql_lexer.d.ts +223 -0
  157. package/lib/parser/antlr/esql_lexer.d.ts.map +1 -0
  158. package/lib/parser/antlr/esql_parser.d.ts +1847 -0
  159. package/lib/parser/antlr/esql_parser.d.ts.map +1 -0
  160. package/lib/parser/antlr/esql_parser_listener.d.ts +1634 -0
  161. package/lib/parser/antlr/esql_parser_listener.d.ts.map +1 -0
  162. package/lib/parser/antlr/lexer_config.d.ts +13 -0
  163. package/lib/parser/antlr/lexer_config.d.ts.map +1 -0
  164. package/lib/parser/antlr/parser_config.d.ts +7 -0
  165. package/lib/parser/antlr/parser_config.d.ts.map +1 -0
  166. package/lib/parser/antlr/promql_lexer.d.ts +71 -0
  167. package/lib/parser/antlr/promql_lexer.d.ts.map +1 -0
  168. package/lib/parser/antlr/promql_parser.d.ts +441 -0
  169. package/lib/parser/antlr/promql_parser.d.ts.map +1 -0
  170. package/lib/parser/antlr/promql_parser_listener.d.ts +354 -0
  171. package/lib/parser/antlr/promql_parser_listener.d.ts.map +1 -0
  172. package/lib/parser/core/constants.d.ts +8 -0
  173. package/lib/parser/core/constants.d.ts.map +1 -0
  174. package/lib/parser/core/cst_to_ast_converter.d.ts +262 -0
  175. package/lib/parser/core/cst_to_ast_converter.d.ts.map +1 -0
  176. package/lib/parser/core/decorations.d.ts +29 -0
  177. package/lib/parser/core/decorations.d.ts.map +1 -0
  178. package/lib/parser/core/esql_error_listener.d.ts +8 -0
  179. package/lib/parser/core/esql_error_listener.d.ts.map +1 -0
  180. package/lib/parser/core/helpers.d.ts +9 -0
  181. package/lib/parser/core/helpers.d.ts.map +1 -0
  182. package/lib/parser/core/parser.d.ts +136 -0
  183. package/lib/parser/core/parser.d.ts.map +1 -0
  184. package/lib/parser/core/tokens.d.ts +45 -0
  185. package/lib/parser/core/tokens.d.ts.map +1 -0
  186. package/lib/parser/core/types.d.ts +69 -0
  187. package/lib/parser/core/types.d.ts.map +1 -0
  188. package/lib/parser/index.d.ts +4 -0
  189. package/lib/parser/index.d.ts.map +1 -0
  190. package/lib/pretty_print/__tests__/fixtures.d.ts +5 -0
  191. package/lib/pretty_print/__tests__/fixtures.d.ts.map +1 -0
  192. package/lib/pretty_print/basic_pretty_printer.d.ts +87 -0
  193. package/lib/pretty_print/basic_pretty_printer.d.ts.map +1 -0
  194. package/lib/pretty_print/constants.d.ts +47 -0
  195. package/lib/pretty_print/constants.d.ts.map +1 -0
  196. package/lib/pretty_print/helpers.d.ts +22 -0
  197. package/lib/pretty_print/helpers.d.ts.map +1 -0
  198. package/lib/pretty_print/index.d.ts +4 -0
  199. package/lib/pretty_print/index.d.ts.map +1 -0
  200. package/lib/pretty_print/leaf_printer.d.ts +19 -0
  201. package/lib/pretty_print/leaf_printer.d.ts.map +1 -0
  202. package/lib/pretty_print/utils.d.ts +7 -0
  203. package/lib/pretty_print/utils.d.ts.map +1 -0
  204. package/lib/pretty_print/wrapping_pretty_printer.d.ts +113 -0
  205. package/lib/pretty_print/wrapping_pretty_printer.d.ts.map +1 -0
  206. package/lib/types.d.ts +523 -0
  207. package/lib/types.d.ts.map +1 -0
  208. package/lib/types.js +19 -0
  209. package/lib/types.js.map +1 -0
  210. package/lib/types.mjs +1 -0
  211. package/lib/types.mjs.map +1 -0
  212. package/package.json +98 -0
@@ -0,0 +1,8 @@
1
+ import * as antlr4 from 'antlr4';
2
+ import type { EditorError } from '../../types';
3
+ export declare class ESQLErrorListener extends antlr4.ErrorListener<unknown> {
4
+ protected errors: EditorError[];
5
+ syntaxError(recognizer: antlr4.Recognizer<unknown>, offendingSymbol: unknown, line: number, column: number, message: string, error: antlr4.RecognitionException | undefined): void;
6
+ getErrors(): EditorError[];
7
+ }
8
+ //# sourceMappingURL=esql_error_listener.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"esql_error_listener.d.ts","sourceRoot":"","sources":["../../../src/parser/core/esql_error_listener.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AAEjC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAU/C,qBAAa,iBAAkB,SAAQ,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC;IAClE,SAAS,CAAC,MAAM,EAAE,WAAW,EAAE,CAAM;IAErC,WAAW,CACT,UAAU,EAAE,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,EACtC,eAAe,EAAE,OAAO,EACxB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,CAAC,oBAAoB,GAAG,SAAS,GAC7C,IAAI;IA8BP,SAAS,IAAI,WAAW,EAAE;CAG3B"}
@@ -0,0 +1,9 @@
1
+ export declare const nonNullable: <T>(v: T) => v is NonNullable<T>;
2
+ /**
3
+ * Removes backtick quotes from around a field name and un-escapes any
4
+ * backticks (double ``) within the field name.
5
+ *
6
+ * @param field A potentially escaped field (column).
7
+ */
8
+ export declare const unescapeColumn: (field: string) => string;
9
+ //# sourceMappingURL=helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/parser/core/helpers.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,WAAW,GAAI,CAAC,EAAE,GAAG,CAAC,KAAG,CAAC,IAAI,WAAW,CAAC,CAAC,CAEvD,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,cAAc,GAAI,OAAO,MAAM,WAM3C,CAAC"}
@@ -0,0 +1,136 @@
1
+ import { type Token } from 'antlr4';
2
+ import { CommonTokenStream, type CharStream } from 'antlr4';
3
+ import { ESQLErrorListener } from './esql_error_listener';
4
+ import { default as ESQLLexer } from '../antlr/esql_lexer';
5
+ import { default as ESQLParser } from '../antlr/esql_parser';
6
+ import type { ESQLAst, ESQLAstExpression, ESQLAstHeaderCommand, ESQLAstQueryExpression, ESQLCommand, ESQLMap, ESQLProperNode, EditorError } from '../../types';
7
+ import type { EsqlParsingTarget } from './types';
8
+ export interface ParseOptions {
9
+ /**
10
+ * Whether to collect and attach to AST nodes user's custom formatting:
11
+ * comments and whitespace.
12
+ */
13
+ withFormatting?: boolean;
14
+ }
15
+ export interface ParseResult<T extends ESQLProperNode = ESQLAstQueryExpression> {
16
+ /**
17
+ * The root *QueryExpression* node of the parsed tree.
18
+ */
19
+ root: T;
20
+ /**
21
+ * List of parsed commands.
22
+ *
23
+ * @deprecated Use `root` instead.
24
+ */
25
+ ast: ESQLAst;
26
+ /**
27
+ * List of ANTLR tokens generated by the lexer.
28
+ */
29
+ tokens: Token[];
30
+ /**
31
+ * List of parsing errors.
32
+ */
33
+ errors: EditorError[];
34
+ }
35
+ export declare class Parser {
36
+ readonly src: string;
37
+ readonly options: ParseOptions;
38
+ static readonly create: (src: string, options?: ParseOptions) => Parser;
39
+ /**
40
+ * Parse a complete ES|QL query, generating an AST and a list of parsing errors.
41
+ *
42
+ * Make sure to check the returned `errors` list for any parsing issues.
43
+ *
44
+ * For example:
45
+ *
46
+ * ```typescript
47
+ * const result = Parser.parse('FROM my_index | STATS count(*)');
48
+ * ```
49
+ *
50
+ * @param src Source text to parse.
51
+ * @param options Parsing options.
52
+ */
53
+ static readonly parse: (src: string, options?: ParseOptions) => ParseResult;
54
+ /**
55
+ * Extract parsing errors from the source text without generating an AST.
56
+ *
57
+ * @param src Source text to parse for errors.
58
+ * @returns A list of parsing errors.
59
+ */
60
+ static readonly parseErrors: (src: string) => EditorError[];
61
+ static readonly parseQuery: (src: string, options?: ParseOptions) => ParseResult<ESQLAstQueryExpression>;
62
+ /**
63
+ * Parse a single ES|QL header pseudo-command, generating an AST and a list of parsing errors.
64
+ *
65
+ * Make sure to check the returned `errors` list for any parsing issues.
66
+ *
67
+ * For example:
68
+ *
69
+ * ```typescript
70
+ * const result = Parser.parseSetCommand('SET a = "foo"');
71
+ * ```
72
+ *
73
+ * @param src Source text of a SET pseudo-command to parse.
74
+ * @param options Parsing options.
75
+ * @returns A result object containing the parsed SET command, its AST, tokens, and errors.
76
+ */
77
+ static readonly parseHeaderCommand: (src: string, options?: ParseOptions) => ParseResult<ESQLAstHeaderCommand>;
78
+ /**
79
+ * Parse a single ES|QL command, generating an AST and a list of parsing errors.
80
+ *
81
+ * Make sure to check the returned `errors` list for any parsing issues.
82
+ *
83
+ * For example:
84
+ *
85
+ * ```typescript
86
+ * const result = Parser.parseCommand('ROW abc = 123');
87
+ * ```
88
+ *
89
+ * @param src Source text of a single command to parse.
90
+ * @param options Parsing options.
91
+ * @returns A result object containing the parsed command, its AST, tokens, and errors.
92
+ */
93
+ static readonly parseCommand: (src: string, options?: ParseOptions) => ParseResult<ESQLCommand>;
94
+ /**
95
+ * Parse a single ES|QL expression, generating an AST and a list of parsing errors.
96
+ *
97
+ * Make sure to check the returned `errors` list for any parsing issues.
98
+ *
99
+ * For example:
100
+ *
101
+ * ```typescript
102
+ * const result = Parser.parseExpression('count(*) + 1');
103
+ * ```
104
+ *
105
+ * @param src Source text of an expression to parse.
106
+ * @param options Parsing options.
107
+ * @returns A result object containing the parsed expression, its AST, tokens, and errors.
108
+ */
109
+ static readonly parseExpression: (src: string, options?: ParseOptions) => ParseResult<ESQLAstExpression>;
110
+ static readonly parseMap: (src: string, options?: ParseOptions) => ParseResult<ESQLMap>;
111
+ /**
112
+ * Get the first `count` tokens from the source text.
113
+ *
114
+ * @param src Text to parse for tokens.
115
+ * @param count Number of tokens to parse.
116
+ * @param visible Whether to return only visible tokens (not comments or whitespace).
117
+ * @returns An array of parsed tokens.
118
+ */
119
+ static readonly tokens: (src: string, count: number, visible?: boolean) => Token[];
120
+ readonly streams: CharStream;
121
+ readonly lexer: ESQLLexer;
122
+ readonly tokens: CommonTokenStream;
123
+ readonly parser: ESQLParser;
124
+ readonly errors: ESQLErrorListener;
125
+ constructor(src: string, options?: ParseOptions);
126
+ parseTarget<T extends ESQLProperNode>([rule, conversion,]: EsqlParsingTarget): ParseResult<T>;
127
+ parseSourceCommand(): ParseResult<ESQLCommand>;
128
+ parseProcessingCommand(): ParseResult<ESQLCommand>;
129
+ parse(): ParseResult<ESQLAstQueryExpression>;
130
+ parseErrors(): EditorError[];
131
+ }
132
+ /**
133
+ * @deprecated Use `Parser.parse` instead.
134
+ */
135
+ export declare const parse: (src: string | undefined, options?: ParseOptions) => ParseResult;
136
+ //# sourceMappingURL=parser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../../src/parser/core/parser.ts"],"names":[],"mappings":"AAOA,OAAO,EAAe,KAAK,KAAK,EAAE,MAAM,QAAQ,CAAC;AACjD,OAAO,EAAE,iB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
+ * Finds all tokens in the given range using binary search. Allows to further
5
+ * filter the tokens using a predicate.
6
+ *
7
+ * @param tokens List of ANTLR tokens.
8
+ * @param min Text position to start searching from.
9
+ * @param max Text position to stop searching at.
10
+ * @param predicate Function to test each token.
11
+ */
12
+ export declare const findTokens: (tokens: Token[], min?: number, max?: number, predicate?: (token: Token) => boolean) => Iterable<Token>;
13
+ /**
14
+ * Finds the first token in the given range using binary search. Allows to
15
+ * further filter the tokens using a predicate.
16
+ *
17
+ * @param tokens List of ANTLR tokens.
18
+ * @param min Text position to start searching from.
19
+ * @param max Text position to stop searching at.
20
+ * @param predicate Function to test each token.
21
+ * @returns The first token that matches the predicate or `null` if no token is found.
22
+ */
23
+ export declare const findFirstToken: (tokens: Token[], min?: number, max?: number, predicate?: (token: Token) => boolean) => Token | null;
24
+ /**
25
+ * Finds the first visible token in the given token range using binary search.
26
+ *
27
+ * @param tokens List of ANTLR tokens.
28
+ * @param min Text position to start searching from.
29
+ * @param max Text position to stop searching at.
30
+ * @returns The first punctuation token or `null` if no token is found.
31
+ */
32
+ export declare const findVisibleToken: (tokens: Token[], min?: number, max?: number) => Token | null;
33
+ export declare const isLikelyPunctuation: (text: string) => boolean;
34
+ /**
35
+ * Finds the first punctuation token in the given token range using binary
36
+ * search.
37
+ *
38
+ * @param tokens List of ANTLR tokens.
39
+ * @param min Text position to start searching from.
40
+ * @param max Text position to stop searching at.
41
+ * @returns The first punctuation token or `null` if no token is found.
42
+ */
43
+ export declare const findPunctuationToken: (tokens: Token[], min?: number, max?: number) => Token | null;
44
+ export declare const getPosition: (start: Pick<Token, "start" | "stop"> | null, stop?: Pick<Token, "stop"> | undefined) => ESQLLocation;
45
+ //# sourceMappingURL=tokens.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tokens.d.ts","sourceRoot":"","sources":["../../../src/parser/core/tokens.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAEpC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD;;;;;;;;GAQG;AACH,eAAO,MAAM,UAAU,GACrB,QAAQ,KAAK,EAAE,EACf,MAAK,MAAU,EACf,MAAK,MAA2D,EAChE,YAAW,CAAC,KAAK,EAAE,KAAK,KAAK,OAAoB,KAChD,QAAQ,CAAC,KAAK,CA+BhB,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,cAAc,GACzB,QAAQ,KAAK,EAAE,EACf,MAAK,MAAU,EACf,MAAK,MAA2D,EAChE,YAAW,CAAC,KAAK,EAAE,KAAK,KAAK,OAAoB,KAChD,KAAK,GAAG,IAMV,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB,GAC3B,QAAQ,KAAK,EAAE,EACf,MAAK,MAAU,EACf,MAAK,MAA2D,KAC/D,KAAK,GAAG,IAOV,CAAC;AAOF,eAAO,MAAM,mBAAmB,GAAI,MAAM,MAAM,KAAG,OACF,CAAC;AAElD;;;;;;;;GAQG;AACH,eAAO,MAAM,oBAAoB,GAC/B,QAAQ,KAAK,EAAE,EACf,MAAK,MAAU,EACf,MAAK,MAA2D,KAC/D,KAAK,GAAG,IAQV,CAAC;AAEF,eAAO,MAAM,WAAW,GACtB,OAAO,IAAI,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAAC,GAAG,IAAI,EAC3C,OAAO,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,GAAG,SAAS,KACrC,YAWF,CAAC"}
@@ -0,0 +1,69 @@
1
+ import type * as esql_parser from '../antlr/esql_parser';
2
+ import type { CstToAstConverter } from './cst_to_ast_converter';
3
+ import type { ESQLAstComment } from '../../types';
4
+ /**
5
+ * Lines of decorations per *whitespace line*. A *whitespace line* is a line
6
+ * which tracks line breaks only from the HIDDEN channel. It does not take into
7
+ * account line breaks from the DEFAULT channel, i.e. content lines. For example,
8
+ * it will ignore line breaks from triple-quoted strings, but will track line
9
+ * breaks from comments and whitespace.
10
+ *
11
+ * Each list entry represents a line of decorations.
12
+ */
13
+ export type ParsedFormattingDecorationLines = ParsedFormattingDecoration[][];
14
+ /**
15
+ * A source text decoration that we are interested in.
16
+ *
17
+ * - Comments: we preserve user comments when pretty-printing.
18
+ * - Line breaks: we allow users to specify one custom line break.
19
+ */
20
+ export type ParsedFormattingDecoration = ParsedFormattingCommentDecoration | ParsedFormattingLineBreakDecoration;
21
+ /**
22
+ * A comment AST node with additional information about its position in the
23
+ * source text.
24
+ */
25
+ export interface ParsedFormattingCommentDecoration {
26
+ type: 'comment';
27
+ /**
28
+ * Whether the comment has content on the same line to the left of it.
29
+ */
30
+ hasContentToLeft: boolean;
31
+ /**
32
+ * Whether the comment has content on the same line to the right of it.
33
+ */
34
+ hasContentToRight: boolean;
35
+ /**
36
+ * The comment AST node.
37
+ */
38
+ node: ESQLAstComment;
39
+ }
40
+ export interface ParsedFormattingLineBreakDecoration {
41
+ type: 'line-break';
42
+ /**
43
+ * The number of line breaks in the source text.
44
+ */
45
+ lines: number;
46
+ }
47
+ type Functions<T> = {
48
+ [K in keyof T]: T[K] extends (...args: unknown[]) => unknown ? K : never;
49
+ };
50
+ type GrammarRule = keyof Functions<InstanceType<typeof esql_parser.default>>;
51
+ type CstToAstConversion = keyof Functions<CstToAstConverter>;
52
+ /**
53
+ * Specifies a grammar *parsing target* for the ESQL parser. The parsing target
54
+ * is a grammar rule which is used to parse the source text. Picking a
55
+ * specific rule allows to parse any ES|QL grammar construct, such as a
56
+ * command, expression, or a query (instead of parsing the whole query).
57
+ */
58
+ export type EsqlParsingTarget = [
59
+ /**
60
+ * ANTLR grammar rule, used to parse the source text.
61
+ */
62
+ rule: GrammarRule,
63
+ /**
64
+ * The conversion to use for converting the root ANTLR CST node to a Kibana AST node.
65
+ */
66
+ conversion: CstToAstConversion
67
+ ];
68
+ export {};
69
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/parser/core/types.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,KAAK,WAAW,MAAM,sBAAsB,CAAC;AACzD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD;;;;;;;;GAQG;AACH,MAAM,MAAM,+BAA+B,GAAG,0BAA0B,EAAE,EAAE,CAAC;AAE7E;;;;;GAKG;AACH,MAAM,MAAM,0BAA0B,GAClC,iCAAiC,GACjC,mCAAmC,CAAC;AAExC;;;GAGG;AACH,MAAM,WAAW,iCAAiC;IAChD,IAAI,EAAE,SAAS,CAAC;IAEhB;;OAEG;IACH,gBAAgB,EAAE,OAAO,CAAC;IAE1B;;OAEG;IACH,iBAAiB,EAAE,OAAO,CAAC;IAE3B;;OAEG;IACH,IAAI,EAAE,cAAc,CAAC;CACtB;AAED,MAAM,WAAW,mCAAmC;IAClD,IAAI,EAAE,YAAY,CAAC;IAEnB;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;CACf;AAED,KAAK,SAAS,CAAC,CAAC,IAAI;KACjB,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,GAAG,CAAC,GAAG,KAAK;CACzE,CAAC;AACF,KAAK,WAAW,GAAG,MAAM,SAAS,CAAC,YAAY,CAAC,OAAO,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC;AAC7E,KAAK,kBAAkB,GAAG,MAAM,SAAS,CAAC,iBAAiB,CAAC,CAAC;AAE7D;;;;;GAKG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B;;OAEG;IACH,IAAI,EAAE,WAAW;IAEjB;;OAEG;IACH,UAAU,EAAE,kBAAkB;CAC/B,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { parse, Parser, type ParseOptions, type ParseResult } from './core/parser';
2
+ export { TIME_SPAN_UNITS, TIME_DURATION_UNITS, HEADER_COMMANDS, SOURCE_COMMANDS, DATE_PERIOD_UNITS, } from './core/constants';
3
+ export { ESQLErrorListener } from './core/esql_error_listener';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/parser/index.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,YAAY,EAAE,KAAK,WAAW,EAAE,MAAM,eAAe,CAAC;AAEnF,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,eAAe,EACf,eAAe,EACf,iBAAiB,GAClB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC"}
@@ -0,0 +1,5 @@
1
+ export declare const query1 = "\nfrom kibana_sample_data_logs\n| EVAL timestamp=DATE_TRUNC(3 hour, @timestamp), status = CASE( to_integer(response.keyword) >= 200 and to_integer(response.keyword) < 400, \"HTTP 2xx and 3xx\", to_integer(response.keyword) >= 400 and to_integer(response.keyword) < 500, \"HTTP 4xx\", \"HTTP 5xx\")\n| stats results = count(*) by `Over time` = BUCKET(timestamp, 50, ?_tstart, ?_tend), status\n";
2
+ export declare const query2 = "\nfrom kibana_sample_data_logs\n| sort @timestamp\n| eval t = now()\n| eval key = case(timestamp < t - 1 hour and timestamp > t - 2 hour, \"Last hour\", \"Other\")\n| stats sum = sum(bytes), count = count_distinct(clientip) by key, extension.keyword\n| eval sum_last_hour = case(key == \"Last hour\", sum), sum_rest = case(key == \"Other\", sum), count_last_hour = case(key == \"Last hour\", count), count_rest = case(key == \"Other\", count)\n| stats sum_last_hour = max(sum_last_hour), sum_rest = max(sum_rest), count_last_hour = max(count_last_hour), count_rest = max(count_rest) by key, extension.keyword\n| eval total_bytes = to_double(coalesce(sum_last_hour, 0::long) + coalesce(sum_rest, 0::long))\n| eval total_visits = to_double(coalesce(count_last_hour, 0::long) + coalesce(count_rest, 0::long))\n| eval bytes_transform = round(total_bytes / 1000000.0, 1)\n| eval bytes_transform_last_hour = round(sum_last_hour / 1000.0, 2)\n| keep count_last_hour, total_visits, bytes_transform, bytes_transform_last_hour, extension.keyword\n| stats count_last_hour = sum(count_last_hour), total_visits = sum(total_visits), bytes_transform = sum(bytes_transform), bytes_transform_last_hour = sum(bytes_transform_last_hour) by extension.keyword\n| rename total_visits as `Unique Visits (Total)`, count_last_hour as `Unique Visits (Last hour)`, bytes_transform as `Bytes(Total - MB)`, bytes_transform_last_hour as `Bytes(Last hour - KB)`, extension.keyword as `Type`\n";
3
+ export declare const query3 = "\nfrom kibana_sample_data_logs\n| keep bytes, clientip, url.keyword, response.keyword\n| EVAL type = CASE(to_integer(response.keyword) >= 400 and to_integer(response.keyword) < 500, \"4xx\", to_integer(response.keyword) >= 500, \"5xx\", \"Other\")\n| stats Visits = count(), Unique = count_distinct(clientip), p95 = percentile(bytes, 95), median = median(bytes) by type, url.keyword\n| eval count_4xx = case(type == \"4xx\", Visits), count_5xx = case(type == \"5xx\", Visits), count_rest = case(type == \"Other\", Visits)\n| stats count_4xx = sum(count_4xx), count_5xx = sum(count_5xx), count_rest = sum(count_rest), Unique = sum(Unique),`95th percentile of bytes` = max(p95), `Median of bytes` = max(median) BY url.keyword\n| eval count_4xx = COALESCE(count_4xx, 0::LONG), count_5xx = COALESCE(count_5xx, 0::LONG), count_rest = COALESCE(count_rest, 0::LONG)\n| eval total_records = TO_DOUBLE(count_4xx + count_5xx + count_rest)\n| eval percentage_4xx = count_4xx / total_records, percentage_5xx = count_5xx / total_records\n| eval percentage_4xx = round(100 * percentage_4xx, 2)\n| eval percentage_5xx = round(100 * percentage_5xx, 2)\n| drop count_4xx, count_rest, total_records\n| RENAME percentage_4xx as `HTTP 4xx`, percentage_5xx as `HTTP 5xx`\n";
4
+ export declare const query4 = "\nfrom kibana_sample_data_logs, kibana_sample_data_flights, kibana_sample_data_ecommerce,\n index1, my-data-2024-*, my-data-2025-01-*, xxxx-xxxx-xxxx-xxxx-xxxx-xxxx-xxxx-xxxx, yyyy-yyyy-yyyy-yyyy-yyyy-yyyy-yyyy-yyyy-yyyy\n METADATA _index, _id, _type, _score\n\n| sort @timestamp\n| eval t = now()\n| eval key = case(timestamp < t - 1 hour and timestamp > t - 2 hour, \"Last hour\", \"Other\")\n| stats sum = sum(bytes), count = count_distinct(clientip) by key, extension.keyword\n| eval sum_last_hour = case(key == \"Last hour\", sum), sum_rest = case(key == \"Other\", sum), count_last_hour = case(key == \"Last hour\", count), count_rest = case(key == \"Other\", count)\n| stats sum_last_hour = max(sum_last_hour), sum_rest = max(sum_rest), count_last_hour = max(count_last_hour), count_rest = max(count_rest) by key, extension.keyword\n| eval total_bytes = to_double(coalesce(sum_last_hour, 0::long) + coalesce(sum_rest, 0::long))\n| eval total_visits = to_double(coalesce(count_last_hour, 0::long) + coalesce(count_rest, 0::long))\n| eval bytes_transform = round(total_bytes / 1000000.0, 1)\n| eval bytes_transform_last_hour = round(sum_last_hour / 1000.0, 2)\n| keep count_last_hour, total_visits, bytes_transform, bytes_transform_last_hour, extension.keyword\n| stats count_last_hour = sum(count_last_hour), total_visits = sum(total_visits), bytes_transform = sum(bytes_transform), bytes_transform_last_hour = sum(bytes_transform_last_hour) by extension.keyword\n| rename total_visits as `Unique Visits (Total)`, count_last_hour as `Unique Visits (Last hour)`, bytes_transform as `Bytes(Total - MB)`, bytes_transform_last_hour as `Bytes(Last hour - KB)`, extension.keyword as `Type`\n";
5
+ //# sourceMappingURL=fixtures.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fixtures.d.ts","sourceRoot":"","sources":["../../../src/pretty_print/__tests__/fixtures.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,MAAM,uZAIlB,CAAC;AAEF,eAAO,MAAM,MAAM,07CAelB,CAAC;AAEF,eAAO,MAAM,MAAM,2uCAclB,CAAC;AAEF,eAAO,MAAM,MAAM,kqDAkBlB,CAAC"}
@@ -0,0 +1,87 @@
1
+ import type { ESQLAstExpressionNode } from '../ast/visitor/types';
2
+ import { Visitor } from '../ast/visitor';
3
+ import type { ESQLAstBaseItem, ESQLAstCommand, ESQLAstQueryExpression, ESQLMap, ESQLProperNode } from '../types';
4
+ export interface BasicPrettyPrinterOptions {
5
+ /**
6
+ * Whether to break the query into multiple lines on each pipe. Defaults to
7
+ * `false`.
8
+ */
9
+ multiline?: boolean;
10
+ /**
11
+ * Tabbing string inserted before a pipe, when `multiline` is `true`. Defaults
12
+ * to two spaces.
13
+ */
14
+ pipeTab?: string;
15
+ /**
16
+ * Whether to skip printing header commands (e.g., SET instructions).
17
+ *
18
+ * @default false
19
+ */
20
+ skipHeader?: boolean;
21
+ /**
22
+ * The default lowercase setting to use for all options. Defaults to `false`.
23
+ */
24
+ lowercase?: boolean;
25
+ /**
26
+ * Whether to lowercase command names. Defaults to `false`.
27
+ */
28
+ lowercaseCommands?: boolean;
29
+ /**
30
+ * Whether to lowercase command options. Defaults to `false`.
31
+ */
32
+ lowercaseOptions?: boolean;
33
+ /**
34
+ * Whether to lowercase function names. Defaults to `false`.
35
+ */
36
+ lowercaseFunctions?: boolean;
37
+ /**
38
+ * Whether to lowercase keywords. Defaults to `false`.
39
+ */
40
+ lowercaseKeywords?: boolean;
41
+ /**
42
+ * Map representation to use if cannot be determined from parent context.
43
+ */
44
+ mapRepresentation?: ESQLMap['representation'];
45
+ }
46
+ export type BasicPrettyPrinterMultilineOptions = Omit<BasicPrettyPrinterOptions, 'multiline'>;
47
+ export declare class BasicPrettyPrinter {
48
+ /**
49
+ * @param query ES|QL query AST to print.
50
+ * @returns A single-line string representation of the query.
51
+ */
52
+ static readonly print: (node: ESQLProperNode, opts?: BasicPrettyPrinterOptions) => string;
53
+ /**
54
+ * Print a query with each command on a separate line. It is also possible to
55
+ * specify a tabbing option for the pipe character.
56
+ *
57
+ * @param query ES|QL query AST to print.
58
+ * @param opts Options for pretty-printing.
59
+ * @returns A multi-line string representation of the query.
60
+ */
61
+ static readonly multiline: (query: ESQLAstQueryExpression, opts?: BasicPrettyPrinterMultilineOptions) => string;
62
+ /**
63
+ * @param query ES|QL query AST to print.
64
+ * @returns A single-line string representation of the query.
65
+ */
66
+ static readonly query: (query: ESQLAstQueryExpression, opts?: BasicPrettyPrinterOptions) => string;
67
+ /**
68
+ * @param command ES|QL command AST node to print.
69
+ * @returns Prints a single-line string representation of the command.
70
+ */
71
+ static readonly command: (command: ESQLAstCommand, opts?: BasicPrettyPrinterOptions) => string;
72
+ /**
73
+ * @param expression ES|QL expression AST node to print.
74
+ * @returns Prints a single-line string representation of the expression.
75
+ */
76
+ static readonly expression: (expression: ESQLAstExpressionNode, opts?: BasicPrettyPrinterOptions) => string;
77
+ protected readonly opts: Required<BasicPrettyPrinterOptions>;
78
+ constructor(opts?: BasicPrettyPrinterOptions);
79
+ protected keyword(word: string): string;
80
+ protected decorateWithComments(node: ESQLAstBaseItem, formatted: string): string;
81
+ protected simplifyMultiplicationByOne(node: ESQLAstExpressionNode, minusCount?: number): string | undefined;
82
+ protected readonly visitor: Visitor;
83
+ print(query: ESQLAstQueryExpression): any;
84
+ printCommand(command: ESQLAstCommand): any;
85
+ printExpression(expression: ESQLAstExpressionNode): any;
86
+ }
87
+ //# sourceMappingURL=basic_pretty_printer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"basic_pretty_printer.d.ts","sourceRoot":"","sources":["../../src/pretty_print/basic_pretty_printer.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAClE,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAQzC,OAAO,KAAK,EACV,eAAe,EACf,cAAc,EAEd,sBAAsB,EACtB,OAAO,EACP,cAAc,EACf,MAAM,UAAU,CAAC;AAElB,MAAM,WAAW,yBAAyB;IACxC;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB;;;OAGG;IACH,OAAO,CAAC,EAAE,MA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AAC,2BAA2B,CACnC,IAAI,EAAE,qBAAqB,EAC3B,UAAU,GAAE,MAAU,GACrB,MAAM,GAAG,SAAS;IAqDrB,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,CA4WR;IAEpB,KAAK,CAAC,KAAK,EAAE,sBAAsB;IAInC,YAAY,CAAC,OAAO,EAAE,cAAc;IAIpC,eAAe,CAAC,UAAU,EAAE,qBAAqB;CAGzD"}
@@ -0,0 +1,47 @@
1
+ /**
2
+ * This set tracks commands that don't use commas to separate their
3
+ * arguments.
4
+ *
5
+ * Normally ES|QL command arguments are separated by commas.
6
+ *
7
+ * ```
8
+ * COMMAND arg1, arg2, arg3
9
+ * ```
10
+ *
11
+ * But there are some commands (namely `dissect`) which don't
12
+ * use commas to separate their arguments.
13
+ *
14
+ * ```
15
+ * DISSECT input "pattern"
16
+ * GROK input "pattern1", "pattern2", "pattern3"
17
+ * ```
18
+ */
19
+ export declare const commandsWithNoCommaArgSeparator: Set<string>;
20
+ export declare const commandsWithSpecialCommaRules: Map<string, (argIndex: number) => boolean>;
21
+ /**
22
+ * This set tracks command options which use an equals sign to separate
23
+ * the option label from the option value.
24
+ *
25
+ * Most ES|QL commands use a space to separate the option label from the
26
+ * option value.
27
+ *
28
+ * ```
29
+ * COMMAND arg1, arg2, arg3 OPTION option
30
+ * FROM index METADATA _id
31
+ * |
32
+ * |
33
+ * space
34
+ * ```
35
+ *
36
+ * However, the `APPEND_SEPARATOR` in the `DISSECT` command uses an equals
37
+ * sign to separate the option label from the option value.
38
+ *
39
+ * ```
40
+ * DISSECT input "pattern" APPEND_SEPARATOR = "separator"
41
+ * |
42
+ * |
43
+ * equals sign
44
+ * ```
45
+ */
46
+ export declare const commandOptionsWithEqualsSeparator: Set<string>;
47
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/pretty_print/constants.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,+BAA+B,aAAmD,CAAC;AAEhG,eAAO,MAAM,6BAA6B,yBAA8B,MAAM,KAAK,OAAO,CAExF,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,iCAAiC,aAAgC,CAAC"}
@@ -0,0 +1,22 @@
1
+ import type { ESQLAstBaseItem } from '../types';
2
+ import { type WalkerAstNode } from '../ast/walker';
3
+ export interface QueryPrettyPrintStats {
4
+ /**
5
+ * `true` if the given AST has a line breaking decoration. A line breaking
6
+ * decoration is any decoration that requires a newline "\n" to be printed.
7
+ */
8
+ hasLineBreakingDecorations: boolean;
9
+ /**
10
+ * Whether the given AST has at least one single line comment to the right of
11
+ * some node.
12
+ */
13
+ hasRightSingleLineComments: boolean;
14
+ }
15
+ /**
16
+ * Walks once the given AST sub-tree and computes the pretty print stats.
17
+ *
18
+ * @param ast The part to compute the stats for.
19
+ */
20
+ export declare const getPrettyPrintStats: (ast: WalkerAstNode) => QueryPrettyPrintStats;
21
+ export declare const hasLineBreakingDecoration: (node: ESQLAstBaseItem) => boolean;
22
+ //# sourceMappingURL=helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/pretty_print/helpers.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,EAAU,KAAK,aAAa,EAAE,MAAM,eAAe,CAAC;AAE3D,MAAM,WAAW,qBAAqB;IACpC;;;OAGG;IACH,0BAA0B,EAAE,OAAO,CAAC;IAEpC;;;OAGG;IACH,0BAA0B,EAAE,OAAO,CAAC;CACrC;AAED;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,GAAI,KAAK,aAAa,KAAG,qBAkBxD,CAAC;AAEF,eAAO,MAAM,yBAAyB,GAAI,MAAM,eAAe,KAAG,OA2BjE,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { LeafPrinter } from './leaf_printer';
2
+ export { BasicPrettyPrinter, type BasicPrettyPrinterOptions, type BasicPrettyPrinterMultilineOptions, } from './basic_pretty_printer';
3
+ export { WrappingPrettyPrinter, type WrappingPrettyPrinterOptions, } from './wrapping_pretty_printer';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/pretty_print/index.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,OAAO,EACL,kBAAkB,EAClB,KAAK,yBAAyB,EAC9B,KAAK,kCAAkC,GACxC,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EACL,qBAAqB,EACrB,KAAK,4BAA4B,GAClC,MAAM,2BAA2B,CAAC"}
@@ -0,0 +1,19 @@
1
+ import type { ESQLAstComment, ESQLAstCommentMultiLine, ESQLColumn, ESQLDatePeriodLiteral, ESQLIdentifier, ESQLLiteral, ESQLParamLiteral, ESQLProperNode, ESQLSource, ESQLStringLiteral, ESQLTimeDurationLiteral } from '../types';
2
+ /**
3
+ * Printer for leaf AST nodes. The printing output of these nodes should
4
+ * typically not depend on word wrapping settings, should always return an
5
+ * atomic short string.
6
+ */
7
+ export declare const LeafPrinter: {
8
+ source: (node: ESQLSource) => string;
9
+ identifier: (node: ESQLIdentifier) => string;
10
+ column: (node: ESQLColumn) => string;
11
+ string: (node: Pick<ESQLStringLiteral, "valueUnquoted" | "unquoted">) => string;
12
+ literal: (node: ESQLLiteral) => string;
13
+ param: (node: ESQLParamLiteral) => string;
14
+ timespan: (node: ESQLTimeDurationLiteral | ESQLDatePeriodLiteral) => string;
15
+ comment: (node: ESQLAstComment) => string;
16
+ commentList: (comments: ESQLAstCommentMultiLine[]) => string;
17
+ print: (node: ESQLProperNode | ESQLAstComment) => string;
18
+ };
19
+ //# sourceMappingURL=leaf_printer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"leaf_printer.d.ts","sourceRoot":"","sources":["../../src/pretty_print/leaf_printer.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EACV,cAAc,EACd,uBAAuB,EACvB,UAAU,EACV,qBAAqB,EACrB,cAAc,EACd,WAAW,EAEX,gBAAgB,EAChB,cAAc,EACd,UAAU,EACV,iBAAiB,EACjB,uBAAuB,EACxB,MAAM,UAAU,CAAC;AAIlB;;;;GAIG;AACH,eAAO,MAAM,WAAW;mBACP,UAAU,KAAG,MAAM;uBAcf,cAAc;mBAelB,UAAU;mBAeV,IAAI,CAAC,iBAAiB,EAAE,eAAe,GAAG,UAAU,CAAC;oBAoBpD,WAAW;kBAiCb,gBAAgB;qBAYb,uBAAuB,GAAG,qBAAqB;oBAUhD,cAAc,KAAG,MAAM;4BAcf,uBAAuB,EAAE,KAAG,MAAM;kBAS5C,cAAc,GAAG,cAAc,KAAG,MAAM;CAoBvD,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Lazily retrieves a set of keywords that should be quoted in ESQL.
3
+ *
4
+ * @returns Set of keywords that should be quoted in ESQL.
5
+ */
6
+ export declare const quotableKeywords: () => Set<string>;
7
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/pretty_print/utils.ts"],"names":[],"mappings":"AAWA;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,QAAO,GAAG,CAAC,MAAM,CA6B7C,CAAC"}