@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.
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,48 @@
1
+ import * as cst from '../../../parser/antlr/promql_parser';
2
+ import type * as ast from '../types';
3
+ import type { PromQLParser } from './parser';
4
+ /**
5
+ * Transforms an ANTLR PromQL Concrete Syntax Tree (CST) into a
6
+ * Kibana Abstract Syntax Tree (AST).
7
+ */
8
+ export declare class PromQLCstToAstConverter {
9
+ protected readonly parser: PromQLParser;
10
+ /**
11
+ * Character offset to add to all location values.
12
+ */
13
+ private readonly offset;
14
+ constructor(parser: PromQLParser);
15
+ private getParserFields;
16
+ private createParserFieldsFromToken;
17
+ private fromParserRuleToUnknown;
18
+ fromSingleStatement(ctx: cst.SingleStatementContext): ast.PromQLAstQueryExpression | undefined;
19
+ fromExpression(ctx: cst.ExpressionContext): ast.PromQLAstExpression | undefined;
20
+ private fromArithmeticUnary;
21
+ private fromValueExpression;
22
+ private fromValue;
23
+ private fromFunction;
24
+ private fromGrouping;
25
+ private fromLabelList;
26
+ private fromSelector;
27
+ private fromSeriesMatcher;
28
+ private fromLabels;
29
+ private fromLabel;
30
+ private fromLabelName;
31
+ private fromArithmeticBinary;
32
+ private toBinaryOperator;
33
+ private fromModifier;
34
+ private fromParenthesized;
35
+ private fromSubquery;
36
+ private fromEvaluation;
37
+ private fromOffset;
38
+ private fromAt;
39
+ private fromDuration;
40
+ private fromConstant;
41
+ private fromNumber;
42
+ private fromString;
43
+ private fromStringToken;
44
+ private unquoteString;
45
+ private fromTimeValue;
46
+ private fromIdentifier;
47
+ }
48
+ //# sourceMappingURL=cst_to_ast_converter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cst_to_ast_converter.d.ts","sourceRoot":"","sources":["../../../../src/embedded_languages/promql/parser/cst_to_ast_converter.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,GAAG,MAAM,qCAAqC,CAAC;AAI3D,OAAO,KAAK,KAAK,GAAG,MAAM,UAAU,CAAC;AACrC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAI7C;;;GAGG;AACH,qBAAa,uBAAuB;IAMtB,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,YAAY;IALnD;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;gBAED,MAAM,EAAE,YAAY;IAMnD,OAAO,CAAC,eAAe;IAYvB,OAAO,CAAC,2BAA2B;IAenC,OAAO,CAAC,uBAAuB;IAcxB,mBAAmB,CACxB,GAAG,EAAE,GAAG,CAAC,sBAAsB,GAC9B,GAAG,CAAC,wBAAwB,GAAG,SAAS;IAgBpC,cAAc,CAAC,GAAG,EAAE,GAAG,CAAC,iBAAiB,GAAG,GAAG,CAAC,mBAAmB,GAAG,SAAS;IAkCtF,OAAO,CAAC,mBAAmB;IAqB3B,OAAO,CAAC,mBAAmB;IAS3B,OAAO,CAAC,SAAS;IAqBjB,OAAO,CAAC,YAAY;IAyDpB,OAAO,CAAC,YAAY;IAmBpB,OAAO,CAAC,aAAa;IAiBrB,OAAO,CAAC,YAAY;IA8CpB,OAAO,CAAC,iBAAiB;IA6BzB,OAAO,CAAC,UAAU;IAsBlB,OAAO,CAAC,SAAS;IAoCjB,OAAO,CAAC,aAAa;IAqBrB,OAAO,CAAC,oBAAoB;IAoD5B,OAAO,CAAC,gBAAgB;IAMxB,OAAO,CAAC,YAAY;IAkDpB,OAAO,CAAC,iBAAiB;IAmBzB,OAAO,CAAC,YAAY;IAwEpB,OAAO,CAAC,cAAc;IAoBtB,OAAO,CAAC,UAAU;IAkBlB,OAAO,CAAC,MAAM;IA+Bd,OAAO,CAAC,YAAY;IAYpB,OAAO,CAAC,YAAY;IAqBpB,OAAO,CAAC,UAAU;IAoClB,OAAO,CAAC,UAAU;IAUlB,OAAO,CAAC,eAAe;IAWvB,OAAO,CAAC,aAAa;IAwCrB,OAAO,CAAC,aAAa;IAyBrB,OAAO,CAAC,cAAc;CAiBvB"}
@@ -0,0 +1,4 @@
1
+ export { PromQLParser, type PromQLParseOptions } from './parser';
2
+ export { PromQLErrorListener } from './promql_error_listener';
3
+ export { PromQLCstToAstConverter } from './cst_to_ast_converter';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/embedded_languages/promql/parser/index.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,YAAY,EAAE,KAAK,kBAAkB,EAAE,MAAM,UAAU,CAAC;AACjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC"}
@@ -0,0 +1,65 @@
1
+ import { CommonTokenStream, type CharStream } from 'antlr4';
2
+ import { default as PromQLLexer } from '../../../parser/antlr/promql_lexer';
3
+ import { default as PromQLParserGenerated } from '../../../parser/antlr/promql_parser';
4
+ import { PromQLErrorListener } from './promql_error_listener';
5
+ import type { PromQLAstQueryExpression, PromQLParseResult } from '../types';
6
+ import type { EditorError } from '../../../types';
7
+ export interface PromQLParseOptions {
8
+ /**
9
+ * Character offset where the PromQL query begins. This is useful when
10
+ * PromQL queries are embedded inside other queries (e.g., ES|QL).
11
+ * The offset will be added to all location values in the AST.
12
+ */
13
+ offset?: number;
14
+ }
15
+ /**
16
+ * Parser for PromQL queries.
17
+ *
18
+ * This parser transforms PromQL source text into an Abstract Syntax Tree (AST)
19
+ * that can be used for analysis, validation, and transformation.
20
+ */
21
+ export declare class PromQLParser {
22
+ readonly src: string;
23
+ readonly options: PromQLParseOptions;
24
+ /**
25
+ * Create a new PromQL parser instance.
26
+ */
27
+ static readonly create: (src: string, options?: PromQLParseOptions) => PromQLParser;
28
+ /**
29
+ * Parse a complete PromQL query, generating an AST and a list of parsing errors.
30
+ *
31
+ * Make sure to check the returned `errors` list for any parsing issues.
32
+ *
33
+ * For example:
34
+ *
35
+ * ```typescript
36
+ * const result = PromQLParser.parse('rate(http_requests_total[5m])');
37
+ * ```
38
+ *
39
+ * @param src Source text to parse.
40
+ * @param options Parsing options.
41
+ */
42
+ static readonly parse: (src: string, options?: PromQLParseOptions) => PromQLParseResult;
43
+ /**
44
+ * Extract parsing errors from the source text without generating an AST.
45
+ *
46
+ * @param src Source text to parse for errors.
47
+ * @returns A list of parsing errors.
48
+ */
49
+ static readonly parseErrors: (src: string) => EditorError[];
50
+ readonly streams: CharStream;
51
+ readonly lexer: PromQLLexer;
52
+ readonly tokens: CommonTokenStream;
53
+ readonly parser: PromQLParserGenerated;
54
+ readonly errors: PromQLErrorListener;
55
+ constructor(src: string, options?: PromQLParseOptions);
56
+ /**
57
+ * Parse the source text and return the AST.
58
+ */
59
+ parse(): PromQLParseResult<PromQLAstQueryExpression>;
60
+ /**
61
+ * Parse the source text and return only the errors.
62
+ */
63
+ parseErrors(): EditorError[];
64
+ }
65
+ //# sourceMappingURL=parser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../../../src/embedded_languages/promql/parser/parser.ts"],"names":[],"mappings":"AAOA,OAAO,EAAe,iBAAiB,EAAE,KAAK,UAAU,EAAE,MAAM,QAAQ,CAAC;AACzE,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,oCAAoC,CAAC;AAC5E,OAAO,EAAE,OAAO,IAAI,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AACvF,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAG9D,OAAO,KAAK,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAC5E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD,MAAM,WAAW,kBAAkB;IACjC;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;;GAKG;AACH,qBAAa,YAAY;aA2CL,GAAG,EAAE,MAAM;aACX,OAAO,EAAE,kBAAkB;IA3C7C;;OAEG;IACH,gBAAuB,MAAM,GAAI,KAAK,MAAM,EAAE,UAAU,kBAAkB,kBAExE;IAEF;;;;;;;;;;;;;OAaG;IACH,gBAAuB,KAAK,GAAI,KAAK,MAAM,EAAE,UAAU,kBAAkB,KAAG,iBAAiB,CAE3F;IAEF;;;;;OAKG;IACH,gBAAuB,WAAW,GAAI,KAAK,MAAM,KAAG,WAAW,EAAE,CAE/D;IAEF,SAAgB,OAAO,EAAE,UAAU,CAAC;IACpC,SAAgB,KAAK,EAAE,WAAW,CAAC;IACnC,SAAgB,MAAM,EAAE,iBAAiB,CAAC;IAC1C,SAAgB,MAAM,EAAE,qBAAqB,CAAC;IAC9C,SAAgB,MAAM,sBAA6B;gBAGjC,GAAG,EAAE,MAAM,EACX,OAAO,GAAE,kBAAuB;IAclD;;OAEG;IACI,KAAK,IAAI,iBAAiB,CAAC,wBAAwB,CAAC;IA2B3D;;OAEG;IACI,WAAW,IAAI,WAAW,EAAE;CAIpC"}
@@ -0,0 +1,11 @@
1
+ import * as antlr4 from 'antlr4';
2
+ import type { EditorError } from '../../../types';
3
+ /**
4
+ * Error listener for PromQL parsing that collects syntax errors.
5
+ */
6
+ export declare class PromQLErrorListener extends antlr4.ErrorListener<unknown> {
7
+ protected errors: EditorError[];
8
+ syntaxError(_recognizer: antlr4.Recognizer<unknown>, offendingSymbol: unknown, line: number, column: number, message: string, _error: antlr4.RecognitionException | undefined): void;
9
+ getErrors(): EditorError[];
10
+ }
11
+ //# sourceMappingURL=promql_error_listener.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"promql_error_listener.d.ts","sourceRoot":"","sources":["../../../../src/embedded_languages/promql/parser/promql_error_listener.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AAEjC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC;IACpE,SAAS,CAAC,MAAM,EAAE,WAAW,EAAE,CAAM;IAErC,WAAW,CACT,WAAW,EAAE,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,EACvC,eAAe,EAAE,OAAO,EACxB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,CAAC,oBAAoB,GAAG,SAAS,GAC9C,IAAI;IAkBP,SAAS,IAAI,WAAW,EAAE;CAG3B"}
@@ -0,0 +1,65 @@
1
+ import type { PromQLAstExpression, PromQLAstQueryExpression, PromQLBinaryExpression, PromQLFunction, PromQLGrouping, PromQLGroupModifier, PromQLIdentifier, PromQLLabel, PromQLLabelMap, PromQLLabelName, PromQLLiteral, PromQLModifier, PromQLNumericLiteral, PromQLParens, PromQLSelector, PromQLStringLiteral, PromQLSubquery, PromQLTimeValue, PromQLUnaryExpression, PromQLEvaluation, PromQLOffset, PromQLAt } from '../types';
2
+ export interface PromQLBasicPrettyPrinterOptions {
3
+ /**
4
+ * Whether to lowercase function and aggregation names.
5
+ * @default false (keeps original case)
6
+ */
7
+ lowercaseFunctions?: boolean;
8
+ /**
9
+ * Whether to lowercase keywords like `by`, `without`, `on`, `ignoring`, etc.
10
+ * @default false (keeps original case)
11
+ */
12
+ lowercaseKeywords?: boolean;
13
+ /**
14
+ * Whether to lowercase operators like `and`, `or`, `unless`.
15
+ * @default false (keeps original case)
16
+ */
17
+ lowercaseOperators?: boolean;
18
+ }
19
+ /**
20
+ * A basic pretty-printer for PromQL AST nodes that outputs a single-line
21
+ * string representation with minimal formatting (one space between nodes).
22
+ */
23
+ export declare class PromQLBasicPrettyPrinter {
24
+ /**
25
+ * Print any PromQL AST node.
26
+ */
27
+ static readonly print: (node: PromQLAstQueryExpression | PromQLAstExpression, opts?: PromQLBasicPrettyPrinterOptions) => string;
28
+ /**
29
+ * Print a PromQL query expression.
30
+ */
31
+ static readonly query: (query: PromQLAstQueryExpression, opts?: PromQLBasicPrettyPrinterOptions) => string;
32
+ /**
33
+ * Print a PromQL expression.
34
+ */
35
+ static readonly expression: (expr: PromQLAstExpression, opts?: PromQLBasicPrettyPrinterOptions) => string;
36
+ protected readonly opts: Required<PromQLBasicPrettyPrinterOptions>;
37
+ constructor(opts?: PromQLBasicPrettyPrinterOptions);
38
+ print(node: PromQLAstQueryExpression | PromQLAstExpression): string;
39
+ printQuery(query: PromQLAstQueryExpression): string;
40
+ printExpression(expr: PromQLAstExpression | undefined): string;
41
+ protected printFunction(node: PromQLFunction): string;
42
+ protected printGrouping(node: PromQLGrouping): string;
43
+ protected printSelector(node: PromQLSelector): string;
44
+ protected printLabelMap(node: PromQLLabelMap): string;
45
+ protected printLabel(node: PromQLLabel): string;
46
+ protected printLabelName(node: PromQLLabelName): string;
47
+ protected printEvaluation(node: PromQLEvaluation): string;
48
+ protected printOffset(node: PromQLOffset): string;
49
+ protected printAt(node: PromQLAt): string;
50
+ protected printBinaryExpression(node: PromQLBinaryExpression): string;
51
+ protected printModifier(node: PromQLModifier): string;
52
+ protected printGroupModifier(node: PromQLGroupModifier): string;
53
+ protected formatOperator(op: string): string;
54
+ protected printUnaryExpression(node: PromQLUnaryExpression): string;
55
+ protected printSubquery(node: PromQLSubquery): string;
56
+ protected printParens(node: PromQLParens): string;
57
+ protected printLiteral(node: PromQLLiteral): string;
58
+ protected printIntegerLiteral(node: PromQLNumericLiteral): string;
59
+ protected printDecimalLiteral(node: PromQLNumericLiteral): string;
60
+ protected printHexLiteral(node: PromQLNumericLiteral): string;
61
+ protected printStringLiteral(node: PromQLStringLiteral): string;
62
+ protected printTimeLiteral(node: PromQLTimeValue): string;
63
+ protected printIdentifier(node: PromQLIdentifier): string;
64
+ }
65
+ //# sourceMappingURL=basic_pretty_printer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"basic_pretty_printer.d.ts","sourceRoot":"","sources":["../../../../src/embedded_languages/promql/pretty_print/basic_pretty_printer.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EACV,mBAAmB,EACnB,wBAAwB,EACxB,sBAAsB,EACtB,cAAc,EACd,cAAc,EACd,mBAAmB,EACnB,gBAAgB,EAChB,WAAW,EACX,cAAc,EACd,eAAe,EACf,aAAa,EACb,cAAc,EACd,oBAAoB,EACpB,YAAY,EACZ,cAAc,EACd,mBAAmB,EACnB,cAAc,EACd,eAAe,EACf,qBAAqB,EACrB,gBAAgB,EAChB,YAAY,EACZ,QAAQ,EACT,MAAM,UAAU,CAAC;AAOlB,MAAM,WAAW,+BAA+B;IAC9C;;;OAGG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAE7B;;;OAGG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAE5B;;;OAGG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAED;;;GAGG;AACH,qBAAa,wBAAwB;IACnC;;OAEG;IACH,gBAAuB,KAAK,GAC1B,MAAM,wBAAwB,GAAG,mBAAmB,EACpD,OAAO,+BAA+B,KACrC,MAAM,CAGP;IAEF;;OAEG;IACH,gBAAuB,KAAK,GAC1B,OAAO,wBAAwB,EAC/B,OAAO,+BAA+B,KACrC,MAAM,CAGP;IAEF;;OAEG;IACH,gBAAuB,UAAU,GAC/B,MAAM,mBAAmB,EACzB,OAAO,+BAA+B,KACrC,MAAM,CAGP;IAEF,SAAS,CAAC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,+BAA+B,CAAC,CAAC;gBAEvD,IAAI,GAA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I,EAAE,aAAa,GAAG,MAAM;IAiBnD,SAAS,CAAC,mBAAmB,CAAC,IAAI,EAAE,oBAAoB,GAAG,MAAM;IAIjE,SAAS,CAAC,mBAAmB,CAAC,IAAI,EAAE,oBAAoB,GAAG,MAAM;IAmBjE,SAAS,CAAC,eAAe,CAAC,IAAI,EAAE,oBAAoB,GAAG,MAAM;IAI7D,SAAS,CAAC,kBAAkB,CAAC,IAAI,EAAE,mBAAmB,GAAG,MAAM;IAoB/D,SAAS,CAAC,gBAAgB,CAAC,IAAI,EAAE,eAAe,GAAG,MAAM;IAIzD,SAAS,CAAC,eAAe,CAAC,IAAI,EAAE,gBAAgB,GAAG,MAAM;CAG1D"}
@@ -0,0 +1,34 @@
1
+ import type { PromQLAstExpression, PromQLBinaryOperator } from '../types';
2
+ /**
3
+ * Precedence groups for PromQL binary operators. Higher numeric value means
4
+ * tighter binding.
5
+ */
6
+ export declare enum PromQLPrecedenceGroup {
7
+ none = 0,
8
+ or = 1,
9
+ andUnless = 2,
10
+ comparison = 3,
11
+ additive = 4,
12
+ multiplicative = 5,
13
+ power = 6
14
+ }
15
+ /**
16
+ * Returns the precedence group for a PromQL AST expression node. Non-binary
17
+ * expressions return `PromQLPrecedenceGroup.none`.
18
+ */
19
+ export declare const promqlBinaryPrecedenceGroup: (node: PromQLAstExpression) => PromQLPrecedenceGroup;
20
+ /**
21
+ * Returns whether a PromQL binary operator is right-associative.
22
+ *
23
+ * In PromQL, `^` (power/exponentiation) is the **only** right-associative
24
+ * binary operator. All others (`+`, `-`, `*`, `/`, `%`, comparisons, `and`,
25
+ * `or`, `unless`) are left-associative.
26
+ *
27
+ * This matters for parens insertion of same-precedence children:
28
+ *
29
+ * - Right-associative: the **left** child needs parens to override natural
30
+ * grouping (`(a ^ b) ^ c` — without parens it would be `a ^ (b ^ c)`).
31
+ * - Left-associative: the **right** child needs parens (`a - (b + c)`).
32
+ */
33
+ export declare const isPromQLRightAssociative: (op: PromQLBinaryOperator) => boolean;
34
+ //# sourceMappingURL=helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../../src/embedded_languages/promql/pretty_print/helpers.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAE1E;;;GAGG;AACH,oBAAY,qBAAqB;IAC/B,IAAI,IAAI;IACR,EAAE,IAAI;IACN,SAAS,IAAI;IACb,UAAU,IAAI;IACd,QAAQ,IAAI;IACZ,cAAc,IAAI;IAClB,KAAK,IAAI;CACV;AAED;;;GAGG;AACH,eAAO,MAAM,2BAA2B,GAAI,MAAM,mBAAmB,KAAG,qBA8BvE,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,wBAAwB,GAAI,IAAI,oBAAoB,KAAG,OAAqB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { PromQLBasicPrettyPrinter, type PromQLBasicPrettyPrinterOptions, } from './basic_pretty_printer';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/embedded_languages/promql/pretty_print/index.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,wBAAwB,EACxB,KAAK,+BAA+B,GACrC,MAAM,wBAAwB,CAAC"}
@@ -0,0 +1,355 @@
1
+ import type { ESQLLocation, EditorError, ESQLAstBaseItem } from '../../types';
2
+ /**
3
+ * All PromQL AST nodes have a `dialect: 'promql'` property to distinguish them
4
+ * from ES|QL AST nodes.
5
+ */
6
+ export interface PromQLAstNodeBase<Name = string> extends ESQLAstBaseItem<Name> {
7
+ dialect: 'promql';
8
+ name: Name;
9
+ text: string;
10
+ location: ESQLLocation;
11
+ incomplete: boolean;
12
+ }
13
+ /**
14
+ * Represents a complete PromQL query expression.
15
+ */
16
+ export interface PromQLAstQueryExpression extends PromQLAstNodeBase<''> {
17
+ type: 'query';
18
+ /**
19
+ * The main expression of the query. May be undefined for incomplete queries.
20
+ */
21
+ expression?: PromQLAstExpression;
22
+ }
23
+ /**
24
+ * All possible PromQL expressions.
25
+ */
26
+ export type PromQLAstExpression = PromQLFunction | PromQLSelector | PromQLBinaryExpression | PromQLUnaryExpression | PromQLSubquery | PromQLParens | PromQLLiteral | PromQLIdentifier | PromQLUnknownItem;
27
+ /**
28
+ * A PromQL AST node.
29
+ */
30
+ export type PromQLAstNode = PromQLAstQueryExpression | PromQLAstExpression | PromQLGrouping | PromQLLabelMap | PromQLLabel | PromQLEvaluation | PromQLOffset | PromQLAt | PromQLModifier | PromQLGroupModifier;
31
+ /**
32
+ * Represents a PromQL function call.
33
+ *
34
+ * ```promql
35
+ * rate(http_requests_total[5m])
36
+ * sum by (job) (rate(http_requests_total[5m]))
37
+ * avg (cpu_usage) without (instance)
38
+ * ```
39
+ */
40
+ export interface PromQLFunction extends PromQLAstNodeBase {
41
+ type: 'function';
42
+ /**
43
+ * Function arguments, with at least one argument, unless the
44
+ * function is incomplete.
45
+ */
46
+ args: PromQLAstExpression[];
47
+ /**
48
+ * Optional grouping clause (BY or WITHOUT).
49
+ */
50
+ grouping?: PromQLGrouping;
51
+ /**
52
+ * Position of the grouping clause relative to the function arguments.
53
+ *
54
+ * - `'before'`: `sum by (job) (...)` - grouping appears before the arguments
55
+ * - `'after'`: `sum(...) by (job)` - grouping appears after the arguments
56
+ *
57
+ * Only set when `grouping` is defined.
58
+ */
59
+ groupingPosition?: 'before' | 'after';
60
+ }
61
+ /**
62
+ * Represents grouping modifiers in aggregation functions.
63
+ *
64
+ * ```promql
65
+ * sum by (job, instance) (...)
66
+ * avg (...) without (cpu)
67
+ * ```
68
+ */
69
+ export interface PromQLGrouping extends PromQLAstNodeBase<'by' | 'without'> {
70
+ type: 'grouping';
71
+ args: PromQLLabelName[];
72
+ }
73
+ /**
74
+ * Represents a label matcher in a selector.
75
+ *
76
+ * ```promql
77
+ * {job="api", status=~"5.."}
78
+ * ```
79
+ */
80
+ export interface PromQLLabel extends PromQLAstNodeBase {
81
+ type: 'label';
82
+ /**
83
+ * The label name.
84
+ */
85
+ labelName: PromQLLabelName;
86
+ /**
87
+ * The match operator: =, !=, =~, !~
88
+ */
89
+ operator: PromQLLabelMatchOperator;
90
+ /**
91
+ * The label value (string literal).
92
+ */
93
+ value?: PromQLStringLiteral;
94
+ }
95
+ export type PromQLLabelMatchOperator = '=' | '!=' | '=~' | '!~';
96
+ /**
97
+ * Represents a label name which can be an identifier, string, or number.
98
+ */
99
+ export type PromQLLabelName = PromQLIdentifier | PromQLStringLiteral | PromQLNumericLiteral;
100
+ /**
101
+ * Represents the label map (curly braces with label matchers) in a selector.
102
+ *
103
+ * ```promql
104
+ * {}
105
+ * {job="api"}
106
+ * {job="api", status=~"5.."}
107
+ * ```
108
+ */
109
+ export interface PromQLLabelMap extends PromQLAstNodeBase<''> {
110
+ type: 'label-map';
111
+ /**
112
+ * The label matchers inside the curly braces.
113
+ */
114
+ args: PromQLLabel[];
115
+ }
116
+ /**
117
+ * Represents a PromQL selector (instant vector or range vector).
118
+ *
119
+ * @example
120
+ * ```promql
121
+ * {}
122
+ * {label1="value1"}
123
+ * {label1="value1", label2!="value2"}
124
+ * {label1="value1", label2!="value2"}[]
125
+ * {label1="value1", label2!="value2"}[5m]
126
+ * http_requests_total
127
+ * http_requests_total{}
128
+ * http_requests_total{label="value", label2!="value2"}
129
+ * http_requests_total{job="api"}[]
130
+ * http_requests_total{job="api"}[5m]
131
+ * http_requests_total{job="api"}[5m] offset - 5m
132
+ * http_requests_total{job="api"}[5m] offset - 123 at - 5m
133
+ * ```
134
+ */
135
+ export interface PromQLSelector extends PromQLAstNodeBase {
136
+ type: 'selector';
137
+ /**
138
+ * The metric name (can be empty for label-only selectors).
139
+ */
140
+ metric?: PromQLIdentifier;
141
+ /**
142
+ * Label map containing label matchers in curly braces.
143
+ */
144
+ labelMap?: PromQLLabelMap;
145
+ /**
146
+ * Optional range duration in square brackets.
147
+ * Makes this a range vector selector.
148
+ */
149
+ duration?: PromQLAstExpression;
150
+ /**
151
+ * Optional evaluation modifiers (offset and @).
152
+ */
153
+ evaluation?: PromQLEvaluation;
154
+ /**
155
+ * All children of the selector in order: [metric?, labelMap?, duration?, evaluation?].
156
+ * Undefined elements are not included in the array.
157
+ */
158
+ args: Array<PromQLIdentifier | PromQLLabelMap | PromQLAstExpression | PromQLEvaluation>;
159
+ }
160
+ /**
161
+ * Represents evaluation modifiers: offset and @ timestamp.
162
+ *
163
+ * ```promql
164
+ * http_requests_total offset 5m
165
+ * http_requests_total @ 1609459200
166
+ * http_requests_total offset 5m @ 1609459200
167
+ * ```
168
+ */
169
+ export interface PromQLEvaluation extends PromQLAstNodeBase<'evaluation'> {
170
+ type: 'evaluation';
171
+ offset?: PromQLOffset;
172
+ at?: PromQLAt;
173
+ }
174
+ /**
175
+ * Represents an offset modifier.
176
+ *
177
+ * ```promql
178
+ * offset 5m
179
+ * offset -5m
180
+ * ```
181
+ */
182
+ export interface PromQLOffset extends PromQLAstNodeBase<'offset'> {
183
+ type: 'offset';
184
+ negative: boolean;
185
+ duration: PromQLAstExpression;
186
+ }
187
+ /**
188
+ * Represents an @ timestamp modifier.
189
+ *
190
+ * ```promql
191
+ * @ 1609459200
192
+ * @ start()
193
+ * @ end()
194
+ * ```
195
+ */
196
+ export interface PromQLAt extends PromQLAstNodeBase<'at'> {
197
+ type: 'at';
198
+ negative: boolean;
199
+ value: PromQLTimeValue | PromQLAtModifier;
200
+ }
201
+ export type PromQLAtModifier = 'start()' | 'end()';
202
+ /**
203
+ * Represents a binary expression in PromQL.
204
+ *
205
+ * ```promql
206
+ * a + b
207
+ * a == bool b
208
+ * a * on(job) b
209
+ * ```
210
+ */
211
+ export interface PromQLBinaryExpression<Name extends PromQLBinaryOperator = PromQLBinaryOperator> extends PromQLAstNodeBase<Name> {
212
+ type: 'binary-expression';
213
+ left: PromQLAstExpression;
214
+ right: PromQLAstExpression;
215
+ /**
216
+ * For comparison operators, whether BOOL modifier is present.
217
+ */
218
+ bool?: boolean;
219
+ /**
220
+ * Optional vector matching modifier.
221
+ */
222
+ modifier?: PromQLModifier;
223
+ }
224
+ export type PromQLBinaryOperator = PromQLArithmeticOperator | PromQLComparisonOperator | PromQLSetOperator;
225
+ export type PromQLArithmeticOperator = '+' | '-' | '*' | '/' | '%' | '^';
226
+ export type PromQLComparisonOperator = '==' | '!=' | '>' | '>=' | '<' | '<=';
227
+ export type PromQLSetOperator = 'and' | 'or' | 'unless';
228
+ /**
229
+ * Represents vector matching modifiers.
230
+ *
231
+ * ```promql
232
+ * a + on(job) b
233
+ * a + ignoring(instance) group_left(job) b
234
+ * ```
235
+ */
236
+ export interface PromQLModifier extends PromQLAstNodeBase<'on' | 'ignoring'> {
237
+ type: 'modifier';
238
+ labels: PromQLLabelName[];
239
+ groupModifier?: PromQLGroupModifier;
240
+ }
241
+ /**
242
+ * Represents group_left or group_right modifier.
243
+ */
244
+ export interface PromQLGroupModifier extends PromQLAstNodeBase<'group_left' | 'group_right'> {
245
+ type: 'group-modifier';
246
+ labels: PromQLLabelName[];
247
+ }
248
+ /**
249
+ * Represents a unary expression in PromQL.
250
+ *
251
+ * ```promql
252
+ * -vector
253
+ * +vector
254
+ * ```
255
+ */
256
+ export interface PromQLUnaryExpression extends PromQLAstNodeBase<'+' | '-'> {
257
+ type: 'unary-expression';
258
+ arg: PromQLAstExpression;
259
+ }
260
+ /**
261
+ * Represents a subquery expression.
262
+ *
263
+ * ```promql
264
+ * rate(http_requests_total[5m])[30m:1m]
265
+ * ```
266
+ */
267
+ export interface PromQLSubquery extends PromQLAstNodeBase<'subquery'> {
268
+ type: 'subquery';
269
+ expr: PromQLAstExpression;
270
+ range: PromQLAstExpression;
271
+ resolution?: PromQLAstExpression;
272
+ evaluation?: PromQLEvaluation;
273
+ }
274
+ /**
275
+ * Represents a parenthesized expression.
276
+ *
277
+ * ```promql
278
+ * (a + b)
279
+ * ```
280
+ */
281
+ export interface PromQLParens extends PromQLAstNodeBase<''> {
282
+ type: 'parens';
283
+ child: PromQLAstExpression;
284
+ }
285
+ export type PromQLLiteral = PromQLNumericLiteral | PromQLStringLiteral | PromQLTimeValue;
286
+ /**
287
+ * Represents a numeric literal (integer, decimal, or hexadecimal).
288
+ */
289
+ export interface PromQLNumericLiteral extends PromQLAstNodeBase {
290
+ type: 'literal';
291
+ literalType: 'integer' | 'decimal' | 'hexadecimal';
292
+ value: number;
293
+ }
294
+ /**
295
+ * Represents a string literal.
296
+ */
297
+ export interface PromQLStringLiteral extends PromQLAstNodeBase {
298
+ type: 'literal';
299
+ literalType: 'string';
300
+ value: string;
301
+ valueUnquoted: string;
302
+ }
303
+ /**
304
+ * Represents a time/duration value.
305
+ *
306
+ * ```promql
307
+ * 5m
308
+ * 1h30m
309
+ * :5m
310
+ * ```
311
+ */
312
+ export interface PromQLTimeValue extends PromQLAstNodeBase {
313
+ type: 'literal';
314
+ literalType: 'time';
315
+ value: string;
316
+ }
317
+ /**
318
+ * Represents an identifier (metric name, label name, function name).
319
+ */
320
+ export interface PromQLIdentifier extends PromQLAstNodeBase {
321
+ type: 'identifier';
322
+ }
323
+ /**
324
+ * Represents an unknown or unrecognized item in the AST.
325
+ */
326
+ export interface PromQLUnknownItem extends PromQLAstNodeBase<'unknown'> {
327
+ type: 'unknown';
328
+ }
329
+ /**
330
+ * Result of parsing a PromQL query.
331
+ */
332
+ export interface PromQLParseResult<T extends PromQLAstNode = PromQLAstQueryExpression> {
333
+ /**
334
+ * The root node of the parsed tree.
335
+ */
336
+ root: T;
337
+ /**
338
+ * List of parsing errors.
339
+ */
340
+ errors: EditorError[];
341
+ }
342
+ /**
343
+ * Result of PromQL AST position detection (via PromqlWalker).
344
+ */
345
+ export interface PromQLPositionResult {
346
+ /**
347
+ * The deepest node containing the offset.
348
+ */
349
+ node: PromQLAstNode | undefined;
350
+ /**
351
+ * Parent node of the current node.
352
+ */
353
+ parent: PromQLAstNode | undefined;
354
+ }
355
+ //# sourceMappingURL=types.d.ts.map
@@ -0,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,CAAC;IACd,aAAa,EAAE,MAAM,CAAC;CACvB;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,eAAgB,SAAQ,iBAAiB;IACxD,IAAI,EAAE,SAAS,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;CACf;AAID;;GAEG;AACH,MAAM,WAAW,gBAAiB,SAAQ,iBAAiB;IACzD,IAAI,EAAE,YAAY,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAkB,SAAQ,iBAAiB,CAAC,SAAS,CAAC;IACrE,IAAI,EAAE,SAAS,CAAC;CACjB;AAID;;GAEG;AACH,MAAM,WAAW,iBAAiB,CAAC,CAAC,SAAS,aAAa,GAAG,wBAAwB;IACnF;;OAEG;IACH,IAAI,EAAE,CAAC,CAAC;IAER;;OAEG;IACH,MAAM,EAAE,WAAW,EAAE,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC;;OAEG;IACH,IAAI,EAAE,aAAa,GAAG,SAAS,CAAC;IAEhC;;OAEG;IACH,MAAM,EAAE,aAAa,GAAG,SAAS,CAAC;CACnC"}
package/lib/index.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ export * from './parser';
2
+ export * from './ast';
3
+ export * from './composer';
4
+ export * from './pretty_print';
5
+ export * from './embedded_languages';
6
+ export * from './debug';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAOA,cAAc,UAAU,CAAC;AACzB,cAAc,OAAO,CAAC;AACtB,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC;AACrC,cAAc,SAAS,CAAC"}