@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 @@
1
+ {"version":3,"sources":["../src/types.ts"],"sourcesContent":["/*\n * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one\n * or more contributor license agreements. Licensed under the Elastic License\n * 2.0; you may not use this file except in compliance with the Elastic License\n * 2.0.\n */\nimport type { PromQLAstQueryExpression } from './embedded_languages/promql/types';\n\n/**\n * @deprecated A full query AST is represented by {@link ESQLAstQueryExpression} type.\n */\nexport type ESQLAst = ESQLAstCommand[];\n\nexport type ESQLAstCommand =\n | ESQLCommand\n | ESQLAstJoinCommand\n | ESQLAstChangePointCommand\n | ESQLAstRerankCommand\n | ESQLAstCompletionCommand\n | ESQLAstFuseCommand\n | ESQLAstForkCommand;\n\nexport type ESQLAstAllCommands = ESQLAstCommand | ESQLAstHeaderCommand;\n\nexport type ESQLAstNode = ESQLAstCommand | ESQLAstHeaderCommand | ESQLAstExpression | ESQLAstItem;\n\n/**\n * Represents an *expression* in the AST.\n */\nexport type ESQLAstExpression = ESQLSingleAstItem;\n\nexport type ESQLSingleAstItem =\n | ESQLAstQueryExpression\n | ESQLFunction\n | ESQLCommandOption\n | ESQLSource\n | ESQLParens\n | ESQLColumn\n | ESQLDatePeriodLiteral\n | ESQLTimeDurationLiteral\n | ESQLList\n | ESQLLiteral\n | ESQLIdentifier\n | ESQLInlineCast\n | ESQLOrderExpression\n | ESQLUnknownItem\n | ESQLMap\n | ESQLMapEntry\n | PromQLAstQueryExpression;\n\n/**\n * A field is either an index field `this.is.field`, or it is a field assignment\n * `new_field = 123`, in which case it is a binary expression with \"=\" operator.\n *\n * Also, a field can be specified as a parameter.\n *\n * ```\n * EVAL this.is.a.nested.field\n * EVAL new_field = 123\n * EVAL ?param\n * EVAL ?param = 123\n * ```\n */\nexport type ESQLAstField = ESQLColumn | ESQLBinaryExpression | ESQLAstExpression | ESQLParam;\n\n/**\n * An array of AST nodes represents different things in different contexts.\n * For example, in command top level arguments it is treated as an \"assignment expression\".\n */\nexport type ESQLAstItem = ESQLSingleAstItem | ESQLAstItem[];\n\nexport type ESQLAstNodeWithArgs = ESQLCommand | ESQLCommandOption | ESQLFunction;\nexport type ESQLAstNodeWithChildren = ESQLAstNodeWithArgs | ESQLList;\n\n/**\n * *Proper* are nodes which are objects with `type` property, once we get rid\n * of the nodes which are plain arrays, all nodes will be *proper* and we can\n * remove this type.\n */\nexport type ESQLProperNode = ESQLAstExpression | ESQLAstCommand | ESQLAstHeaderCommand;\n\nexport interface ESQLLocation {\n min: number;\n max: number;\n}\n\nexport interface ESQLAstBaseItem<Name = string> {\n name: Name;\n text: string;\n location: ESQLLocation;\n incomplete: boolean;\n formatting?: ESQLAstNodeFormatting;\n}\n\n/**\n * Contains optional formatting information used by the pretty printer.\n */\nexport interface ESQLAstNodeFormatting {\n top?: ESQLAstComment[];\n left?: ESQLAstCommentMultiLine[];\n right?: ESQLAstCommentMultiLine[];\n rightSingleLine?: ESQLAstCommentSingleLine;\n bottom?: ESQLAstComment[];\n}\n\nexport interface ESQLCommand<Name = string> extends ESQLAstBaseItem<Name> {\n type: 'command';\n\n /**\n * The subtype of the command. For example, the `JOIN` command can be: (1)\n * LOOKUP JOIN, (2) LEFT JOIN, (3) RIGHT JOIN.\n */\n commandType?: string;\n\n args: ESQLAstItem[];\n}\n\nexport interface ESQLAstJoinCommand extends ESQLCommand<'join'> {\n commandType: 'lookup' | 'left' | 'right';\n}\n\nexport interface ESQLAstChangePointCommand extends ESQLCommand<'change_point'> {\n value: ESQLColumn;\n key?: ESQLColumn;\n target?: {\n type: ESQLColumn;\n pvalue: ESQLColumn;\n };\n}\n\nexport interface ESQLAstCompletionCommand extends ESQLCommand<'completion'> {\n prompt: ESQLAstExpression;\n inferenceId: ESQLLiteral;\n targetField?: ESQLColumn;\n}\n\nexport interface ESQLAstFuseCommand extends ESQLCommand<'fuse'> {\n fuseType?: ESQLIdentifier;\n}\n\nexport interface ESQLAstRerankCommand extends ESQLCommand<'rerank'> {\n query: ESQLLiteral;\n fields: ESQLAstField[];\n targetField?: ESQLColumn;\n inferenceId: ESQLLiteral | undefined;\n}\n\nexport interface ESQLAstForkCommand extends ESQLCommand<'fork'> {\n args: ESQLForkParens[];\n}\n\nexport interface ESQLAstMmrCommand extends ESQLCommand<'mmr'> {\n queryVector?: ESQLSingleAstItem;\n diversifyField: ESQLSingleAstItem;\n limit: ESQLSingleAstItem;\n namedParameters?: ESQLSingleAstItem;\n}\n\n/**\n * Represents a PROMQL command.\n *\n * ```\n * PROMQL query\n * PROMQL ( name = )? ( query )\n * PROMQL key1=value1 key2=value2... query\n * PROMQL key1=value1 key2=value2... ( name = )? ( query )\n * ```\n *\n * - Optional params use assignment syntax: \"key = value\"\n * - Optional `name` assignment before parentheses: name = ( query )\n * - Query can be specified without parentheses\n */\nexport interface ESQLAstPromqlCommand extends ESQLCommand<'promql'> {\n params?: ESQLMap;\n query?: ESQLAstPromqlCommandQuery;\n args: ESQLAstPromqlCommandArgs;\n}\n\nexport type ESQLAstPromqlCommandArgs =\n /** With params map and query */\n | [params: ESQLMap, query: ESQLAstPromqlCommandQuery]\n\n /** Query only, without params */\n | [query: ESQLAstPromqlCommandQuery]\n\n /** Below versions are in case the command is `.incomplete: true`. */\n | [params: ESQLMap]\n | [];\n\nexport type ESQLAstPromqlCommandQuery =\n /** query */\n | ESQLAstPromqlQuery\n\n /** ( query ) */\n | ESQLParens\n\n /** name = ( query ) */\n | ESQLBinaryExpression<'='>;\n\n/**\n * This will be replaced in the future with a proper PROMQL query AST.\n * For now, we just represent the query as an \"unknown\" node.\n */\nexport type ESQLAstPromqlQuery = PromQLAstQueryExpression;\n\n/**\n * Represents a header pseudo-command, such as SET.\n *\n * Example:\n *\n * ```\n * SET setting1 = \"value1\", setting2 = \"value2\";\n * ```\n */\nexport interface ESQLAstHeaderCommand<\n Name extends string = string,\n Arg = ESQLAstExpression,\n> extends ESQLAstBaseItem {\n type: 'header-command';\n\n /** Name of the command */\n name: Name;\n\n /**\n * Represents the arguments for the command. It has to be a list, because\n * even the SET command was initially designed to accept multiple\n * assignments.\n *\n * Example:\n *\n * ```\n * SET setting1 = \"value1\", setting2 = \"value2\"\n * ```\n */\n args: Arg[];\n}\n\nexport type ESQLAstSetHeaderCommand = ESQLAstHeaderCommand<\n 'set',\n ESQLBinaryExpression<BinaryExpressionAssignmentOperator>\n>;\n\nexport type ESQLIdentifierOrParam = ESQLIdentifier | ESQLParamLiteral;\n\nexport interface ESQLCommandOption extends ESQLAstBaseItem {\n type: 'option';\n args: ESQLAstItem[];\n}\n\nexport interface ESQLAstQueryExpression extends ESQLAstBaseItem<''> {\n type: 'query';\n header?: ESQLAstHeaderCommand[];\n commands: ESQLAstCommand[];\n}\n\n/**\n * We coalesce all function calls and expressions into a single \"function\"\n * node type. This subtype is used to distinguish between different types\n * of function calls and expressions.\n *\n * - `variadic-call` is a function call with any number of arguments: fn(a, b, c, ...)\n * - `unary-expression` is a unary expression: -a, +a, NOT a, ...\n * - `binary-expression` is a binary expression: a + b, a - b, a * b, ...\n */\nexport type FunctionSubtype =\n | 'variadic-call' // fn(a, b, c, ...)\n | 'unary-expression' // -a, +a, NOT a, ...\n | 'postfix-unary-expression' // a IS NULL, a IS NOT NULL, ...\n | 'binary-expression'; // a + b, a - b, a * b, ...\n\nexport interface ESQLFunction<\n Subtype extends FunctionSubtype = FunctionSubtype,\n Name extends string = string,\n> extends ESQLAstBaseItem<Name> {\n type: 'function';\n\n /**\n * Default is 'variadic-call'.\n */\n subtype?: Subtype;\n\n /**\n * A node representing the function or operator being called.\n */\n operator?: ESQLIdentifier | ESQLParamLiteral;\n\n args: ESQLAstItem[];\n}\n\nexport interface ESQLFunctionCallExpression extends ESQLFunction<'variadic-call'> {\n subtype: 'variadic-call';\n args: ESQLAstItem[];\n}\n\nexport interface ESQLUnaryExpression<Name extends string = string> extends ESQLFunction<\n 'unary-expression',\n Name\n> {\n subtype: 'unary-expression';\n args: [ESQLAstItem];\n}\n\nexport interface ESQLPostfixUnaryExpression<Name extends string = string> extends ESQLFunction<\n 'postfix-unary-expression',\n Name\n> {\n subtype: 'postfix-unary-expression';\n args: [ESQLAstItem];\n}\n\n/**\n * Represents an order expression used in SORT commands.\n *\n * ```\n * ... | SORT field ASC NULLS FIRST\n * ```\n */\nexport interface ESQLOrderExpression extends ESQLAstBaseItem {\n type: 'order';\n order: '' | 'ASC' | 'DESC';\n nulls: '' | 'NULLS FIRST' | 'NULLS LAST';\n args: [field: ESQLAstItem];\n}\n\nexport interface ESQLBinaryExpression<\n Name extends BinaryExpressionOperator = BinaryExpressionOperator,\n> extends ESQLFunction<'binary-expression', Name> {\n subtype: 'binary-expression';\n args: [ESQLAstItem, ESQLAstItem];\n}\n\nexport type BinaryExpressionOperator =\n | BinaryExpressionArithmeticOperator\n | BinaryExpressionAssignmentOperator\n | BinaryExpressionComparisonOperator\n | BinaryExpressionRegexOperator\n | BinaryExpressionRenameOperator\n | BinaryExpressionWhereOperator\n | BinaryExpressionMatchOperator\n | BinaryExpressionIn\n | BinaryExpressionLogical;\n\nexport type BinaryExpressionArithmeticOperator = '+' | '-' | '*' | '/' | '%';\nexport type BinaryExpressionAssignmentOperator = '=';\nexport type BinaryExpressionComparisonOperator = '==' | '=~' | '!=' | '<' | '<=' | '>' | '>=';\nexport type BinaryExpressionRegexOperator = 'like' | 'not like' | 'rlike' | 'not rlike';\nexport type BinaryExpressionRenameOperator = 'as';\nexport type BinaryExpressionWhereOperator = 'where';\nexport type BinaryExpressionMatchOperator = ':';\nexport type BinaryExpressionIn = 'in' | 'not in';\nexport type BinaryExpressionLogical = 'and' | 'or';\n\nexport interface ESQLInlineCast<ValueType = ESQLAstItem> extends ESQLAstBaseItem {\n type: 'inlineCast';\n value: ValueType;\n castType: string;\n}\n\n/**\n * This node represents something the AST generator\n * didn't recognize in the ANTLR parse tree.\n *\n * It can show up if the AST generator code is out of sync\n * with the ANTLR grammar or if there is some idiosyncrasy\n * or bug in the parse tree.\n *\n * These nodes can be ignored for the purpose of validation\n * and autocomplete, but they may be helpful in detecting bugs.\n */\nexport interface ESQLUnknownItem extends ESQLAstBaseItem {\n type: 'unknown';\n}\n\nexport interface ESQLSource extends ESQLAstBaseItem {\n type: 'source';\n sourceType: 'index' | 'policy';\n\n /**\n * Represents the prefix part of the source identifier. Empty string if not\n * present. Used in index pattern as the cluster identifier or as \"mode\" in\n * enrich policy.\n *\n * ```\n * FROM [<prefix>:]<index>\n * ```\n */\n prefix?: ESQLStringLiteral | undefined;\n\n /**\n * Represents the index part of the source identifier. Unescaped and unquoted.\n *\n * ```\n * FROM [<cluster>:]<index>\n * ```\n */\n index?: ESQLStringLiteral | undefined;\n\n /**\n * Represents the selector (component) part of the source identifier.\n *\n * ```\n * FROM <index>[::<selector>]\n * ```\n */\n selector?: ESQLStringLiteral | undefined;\n}\n\n/**\n * Represents any expression wrapped in parentheses.\n *\n * ```\n * FROM ( <query> )\n * ```\n */\nexport interface ESQLParens extends ESQLAstBaseItem {\n type: 'parens';\n child: ESQLAstExpression;\n}\n\nexport interface ESQLForkParens extends ESQLParens {\n child: ESQLAstQueryExpression;\n}\n\nexport interface ESQLColumn extends ESQLAstBaseItem {\n type: 'column';\n\n /**\n * Optional qualifier for the column, e.g. index name or alias.\n *\n * @example\n *\n * ```esql\n * [index].[column]\n * [index].[nested.column.part]\n * ```\n *\n * `index` is the qualifier.\n */\n qualifier?: ESQLIdentifier;\n\n /**\n * A ES|QL column name can be composed of multiple parts,\n * e.g: part1.part2.`part``3️⃣`.?param. Where parts can be quoted, or not\n * quoted, or even be a parameter.\n *\n * The args list contains the parts of the column name.\n */\n args: Array<ESQLIdentifier | ESQLParam>;\n\n /**\n * An identifier can be composed of multiple parts, e.g: part1.part2.`part``3️⃣`.\n * This property contains the parsed unquoted parts of the identifier.\n * For example: `['part1', 'part2', 'part`3️⃣']`.\n */\n parts: string[];\n\n /**\n * @deprecated\n *\n * An identifier can be composed of multiple parts, e.g: part1.part2.`part3️⃣`\n *\n * Each part can be quoted or not quoted independently. A single `quoted`\n * property is not enough to represent the identifier. Use `parts` instead.\n */\n quoted: boolean;\n}\n\n/**\n * Represents list-like structures where elements are separated by commas.\n *\n * *Literal lists* use square brackets and can contain only\n * string, number, or boolean literals and all elements must be of the same\n * type:\n *\n * ```\n * [1, 2, 3]\n * ```\n *\n * *Tuple lists* use round brackets and can contain any type of expression.\n * Tuple list are used in the `IN` expression:\n *\n * ```\n * a IN (\"abc\", \"def\")\n * ```\n */\nexport interface ESQLList extends ESQLAstBaseItem {\n type: 'list';\n\n /**\n * Represents various types of lists in ES|QL language.\n *\n * - `literal` - a literal list using square brackets, e.g. `[1, 2, 3]`\n * - `tuple` - a tuple list using round brackets, e.g. `(a, b, c)`\n * - `bare` - a bare list without any enclosing brackets, e.g. `a, b, c`\n *\n * @default 'literal'\n */\n subtype?: 'literal' | 'tuple' | 'bare';\n\n values: ESQLAstExpression[];\n}\n\n/**\n * Represents a ES|QL \"map\" object, a list of key-value pairs. Can have different\n * *representation* styles, such as \"map\" or \"listpairs\". The representation\n * style affects how the map is pretty-printed.\n */\nexport interface ESQLMap extends ESQLAstBaseItem {\n type: 'map';\n entries: ESQLMapEntry[];\n\n /**\n * Specifies how the key-value pairs are represented.\n *\n * @default 'map'\n *\n * `map` example:\n *\n * ```\n * { \"key1\": \"value1\", \"key2\": \"value2\" }\n * ```\n *\n * `listpairs` example:\n *\n * ```\n * key1 value1 key2 value2\n * ```\n *\n * `assignment` example:\n *\n * ```\n * key1=value1 key2=value2\n * ```\n */\n representation?: 'map' | 'listpairs' | 'assignment';\n}\n\n/**\n * Represents a key-value pair in a ES|QL map object.\n */\nexport interface ESQLMapEntry extends ESQLAstBaseItem {\n type: 'map-entry';\n key: ESQLAstExpression;\n value: ESQLAstExpression;\n}\n\nexport type ESQLNumericLiteralType = 'double' | 'integer';\n\nexport type ESQLLiteral =\n | ESQLDecimalLiteral\n | ESQLIntegerLiteral\n | ESQLBooleanLiteral\n | ESQLNullLiteral\n | ESQLStringLiteral\n | ESQLTimeDurationLiteral\n | ESQLDatePeriodLiteral\n | ESQLParamLiteral<string>;\n\n// Exporting here to prevent TypeScript error TS4058\n// Return type of exported function has or is using name 'ESQLNumericLiteral' from external module\n// @internal\nexport interface ESQLNumericLiteral<T extends ESQLNumericLiteralType> extends ESQLAstBaseItem {\n type: 'literal';\n literalType: T;\n value: number;\n}\n// We cast anything as decimal (e.g. 32.12) as generic decimal numeric type here\n// @internal\nexport type ESQLDecimalLiteral = ESQLNumericLiteral<'double'>;\n\n// @internal\nexport type ESQLIntegerLiteral = ESQLNumericLiteral<'integer'>;\n\n// @internal\nexport interface ESQLBooleanLiteral extends ESQLAstBaseItem {\n type: 'literal';\n literalType: 'boolean';\n value: string;\n}\n\n// @internal\nexport interface ESQLNullLiteral extends ESQLAstBaseItem {\n type: 'literal';\n literalType: 'null';\n value: string;\n}\n\n// @internal\nexport interface ESQLStringLiteral extends ESQLAstBaseItem {\n type: 'literal';\n\n literalType: 'keyword';\n\n value: string;\n valueUnquoted: string;\n\n /**\n * Whether the string was parsed as \"unqouted\" and/or can be pretty-printed\n * unquoted, i.e. in the source text it did not have any quotes (not single \",\n * not triple \"\"\") quotes. This happens in FROM command source parsing, the\n * cluster and selector can be unquoted strings:\n *\n * ```\n * FROM <cluster>:index:<selector>\n * ```\n */\n unquoted?: boolean;\n}\n\nexport interface ESQLBaseTimeSpanLiteral<\n T extends 'time_duration' | 'date_period',\n> extends ESQLAstBaseItem {\n type: 'literal';\n literalType: T;\n value: string;\n unit: string;\n quantity: number;\n}\nexport type ESQLDatePeriodLiteral = ESQLBaseTimeSpanLiteral<'date_period'>;\nexport type ESQLTimeDurationLiteral = ESQLBaseTimeSpanLiteral<'time_duration'>;\nexport type ESQLTimeSpanLiteral = ESQLDatePeriodLiteral | ESQLTimeDurationLiteral;\n\n// @internal\nexport interface ESQLParamLiteral<\n ParamType extends string = string,\n ParamKind extends ESQLParamKinds = ESQLParamKinds,\n> extends ESQLAstBaseItem {\n type: 'literal';\n literalType: 'param';\n paramKind: ParamKind;\n paramType: ParamType;\n value: string | number;\n}\n\nexport type ESQLParamKinds = '?' | '??';\n\n/**\n * *Unnamed* parameter is not named, just a question mark \"?\".\n *\n * @internal\n */\nexport type ESQLUnnamedParamLiteral<ParamKind extends ESQLParamKinds = ESQLParamKinds> =\n ESQLParamLiteral<'unnamed', ParamKind>;\n\n/**\n * *Named* parameter is a question mark followed by a name \"?name\".\n *\n * @internal\n */\nexport interface ESQLNamedParamLiteral<\n ParamKind extends ESQLParamKinds = ESQLParamKinds,\n> extends ESQLParamLiteral<'named', ParamKind> {\n value: string;\n}\n\n/**\n * *Positional* parameter is a question mark followed by a number \"?1\".\n *\n * @internal\n */\nexport interface ESQLPositionalParamLiteral<\n ParamKind extends ESQLParamKinds = ESQLParamKinds,\n> extends ESQLParamLiteral<'positional', ParamKind> {\n value: number;\n}\n\nexport type ESQLParam =\n | ESQLUnnamedParamLiteral\n | ESQLNamedParamLiteral\n | ESQLPositionalParamLiteral;\n\nexport interface ESQLIdentifier extends ESQLAstBaseItem {\n type: 'identifier';\n}\n\nexport interface ESQLMessage {\n type: 'error' | 'warning';\n text: string;\n location: ESQLLocation;\n code: string;\n errorType?: 'semantic';\n requiresCallback?: 'getColumnsFor' | 'getSources' | 'getPolicies' | 'getJoinIndices' | string;\n underlinedWarning?: boolean;\n}\n\nexport interface EditorError {\n startLineNumber: number;\n endLineNumber: number;\n startColumn: number;\n endColumn: number;\n message: string;\n code: string;\n severity: 'error' | 'warning' | number;\n}\n\nexport interface ESQLAstGenericComment<SubType extends 'single-line' | 'multi-line'> {\n type: 'comment';\n subtype: SubType;\n text: string;\n location?: ESQLLocation;\n}\n\nexport type ESQLAstCommentSingleLine = ESQLAstGenericComment<'single-line'>;\nexport type ESQLAstCommentMultiLine = ESQLAstGenericComment<'multi-line'>;\nexport type ESQLAstComment = ESQLAstCommentSingleLine | ESQLAstCommentMultiLine;\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
package/lib/types.mjs ADDED
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=types.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
package/package.json ADDED
@@ -0,0 +1,98 @@
1
+ {
2
+ "name": "@elastic/esql",
3
+ "version": "0.0.1",
4
+ "author": "Kibana ES|QL team",
5
+ "description": "A set of ts tools to parse, build and transform ES|QL queries programatically.",
6
+ "packageManager": "yarn@1.22.22",
7
+ "main": "./lib/index.js",
8
+ "types": "./lib/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./lib/index.d.ts",
12
+ "import": "./lib/index.mjs",
13
+ "require": "./lib/index.js",
14
+ "default": "./lib/index.js"
15
+ },
16
+ "./types": {
17
+ "types": "./lib/types.d.ts",
18
+ "import": "./lib/types.mjs",
19
+ "require": "./lib/types.js",
20
+ "default": "./lib/types.js"
21
+ }
22
+ },
23
+ "typesVersions": {
24
+ "*": {
25
+ "types": [
26
+ "./lib/types.d.ts"
27
+ ]
28
+ }
29
+ },
30
+ "files": [
31
+ "NOTICE.txt",
32
+ "LICENSE.txt",
33
+ "lib"
34
+ ],
35
+ "scripts": {
36
+ "test": "jest",
37
+ "lint": "eslint .",
38
+ "lint:fix": "eslint . --fix",
39
+ "format": "prettier --write .",
40
+ "format:check": "prettier --check .",
41
+ "build": "tsup && tsc",
42
+ "prebuild:antlr4": "brew bundle --file=./.buildkite/scripts/antlr4_tools/brewfile",
43
+ "build:antlr4": "npm run build:antlr4:esql && npm run build:antlr4:promql",
44
+ "build:antlr4:esql": "npm run build:antlr4:esql:lexer && npm run build:antlr4:esql:parser",
45
+ "postbuild:antlr4:esql": "./.buildkite/scripts/postbuild.sh esql",
46
+ "build:antlr4:esql:parser": "antlr -Dlanguage=TypeScript -lib src/parser/antlr/parser src/parser/antlr/esql_parser.g4",
47
+ "build:antlr4:esql:lexer": "antlr -Dlanguage=TypeScript -lib src/parser/antlr/lexer src/parser/antlr/esql_lexer.g4",
48
+ "build:antlr4:promql": "npm run build:antlr4:promql:lexer && npm run build:antlr4:promql:parser",
49
+ "postbuild:antlr4:promql": "./.buildkite/scripts/postbuild.sh promql",
50
+ "build:antlr4:promql:parser": "antlr -Dlanguage=TypeScript src/parser/antlr/promql_parser.g4",
51
+ "build:antlr4:promql:lexer": "antlr -Dlanguage=TypeScript src/parser/antlr/promql_lexer.g4",
52
+ "semantic-release": "semantic-release --dry-run --debug",
53
+ "prepare": "husky"
54
+ },
55
+ "repository": "https://github.com/elastic/esql-js.git",
56
+ "license": "Elastic License 2.0",
57
+ "sideEffects": false,
58
+ "devDependencies": {
59
+ "@babel/eslint-parser": "7.28.6",
60
+ "@babel/runtime": "7.28.6",
61
+ "@eslint/js": "10.0.1",
62
+ "@semantic-release/changelog": "6.0.3",
63
+ "@semantic-release/commit-analyzer": "13.0.1",
64
+ "@semantic-release/github": "12.0.6",
65
+ "@semantic-release/npm": "13.1.4",
66
+ "@semantic-release/release-notes-generator": "14.1.0",
67
+ "@types/jest": "29.5.14",
68
+ "eslint": "10.0.0",
69
+ "eslint-config-prettier": "10.1.8",
70
+ "husky": "9.1.7",
71
+ "jest": "29.7.0",
72
+ "lint-staged": "16.2.7",
73
+ "prettier": "3.8.1",
74
+ "semantic-release": "25.0.3",
75
+ "ts-jest": "29.4.6",
76
+ "tsup": "8.5.1",
77
+ "typescript": "5.9.3",
78
+ "typescript-eslint": "8.55.0"
79
+ },
80
+ "dependencies": {
81
+ "antlr4": "4.13.2",
82
+ "tree-dump": "1.1.0",
83
+ "tslib": "2.8.1"
84
+ },
85
+ "lint-staged": {
86
+ "*.ts": [
87
+ "eslint --fix",
88
+ "prettier --write"
89
+ ],
90
+ "*.{json,yml,yaml}": [
91
+ "prettier --write"
92
+ ]
93
+ },
94
+ "private": false,
95
+ "publishConfig": {
96
+ "access": "public"
97
+ }
98
+ }