@elaraai/east 1.0.83 → 1.0.85

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 (252) hide show
  1. package/dist/src/analyze.d.ts.map +1 -1
  2. package/dist/src/analyze.js +48 -0
  3. package/dist/src/analyze.js.map +1 -1
  4. package/dist/src/ast_to_ir.coerce_to.spec.js +4 -4
  5. package/dist/src/ast_to_ir.coerce_to.spec.js.map +1 -1
  6. package/dist/src/ast_to_ir.d.ts +6 -1
  7. package/dist/src/ast_to_ir.d.ts.map +1 -1
  8. package/dist/src/ast_to_ir.js +20 -7
  9. package/dist/src/ast_to_ir.js.map +1 -1
  10. package/dist/src/builtins.d.ts +1 -1
  11. package/dist/src/builtins.d.ts.map +1 -1
  12. package/dist/src/builtins.js +52 -0
  13. package/dist/src/builtins.js.map +1 -1
  14. package/dist/src/codegen/canonical.d.ts +37 -0
  15. package/dist/src/codegen/canonical.d.ts.map +1 -0
  16. package/dist/src/codegen/canonical.js +208 -0
  17. package/dist/src/codegen/canonical.js.map +1 -0
  18. package/dist/src/codegen/codegen.spec.js +132 -201
  19. package/dist/src/codegen/codegen.spec.js.map +1 -1
  20. package/dist/src/codegen/printer.d.ts.map +1 -1
  21. package/dist/src/codegen/printer.js +142 -24
  22. package/dist/src/codegen/printer.js.map +1 -1
  23. package/dist/src/codegen/spellings.d.ts +4 -1
  24. package/dist/src/codegen/spellings.d.ts.map +1 -1
  25. package/dist/src/codegen/spellings.js +5 -1
  26. package/dist/src/codegen/spellings.js.map +1 -1
  27. package/dist/src/compile/builtins/index.d.ts.map +1 -1
  28. package/dist/src/compile/builtins/index.js +2 -0
  29. package/dist/src/compile/builtins/index.js.map +1 -1
  30. package/dist/src/compile/builtins/primitives.d.ts.map +1 -1
  31. package/dist/src/compile/builtins/primitives.js +2 -1
  32. package/dist/src/compile/builtins/primitives.js.map +1 -1
  33. package/dist/src/compile/builtins/query.d.ts +10 -0
  34. package/dist/src/compile/builtins/query.d.ts.map +1 -0
  35. package/dist/src/compile/builtins/query.js +5 -0
  36. package/dist/src/compile/builtins/query.js.map +1 -0
  37. package/dist/src/expr/block.d.ts.map +1 -1
  38. package/dist/src/expr/block.js +2 -1
  39. package/dist/src/expr/block.js.map +1 -1
  40. package/dist/src/expr/index.d.ts +75 -47
  41. package/dist/src/expr/index.d.ts.map +1 -1
  42. package/dist/src/expr/index.js +31 -0
  43. package/dist/src/expr/index.js.map +1 -1
  44. package/dist/src/expr/libs/datetime.d.ts +20 -20
  45. package/dist/src/expr/libs/datetime.d.ts.map +1 -1
  46. package/dist/src/expr/libs/datetime.js +208 -167
  47. package/dist/src/expr/libs/datetime.js.map +1 -1
  48. package/dist/src/expr/libs/float.d.ts +15 -15
  49. package/dist/src/expr/libs/float.d.ts.map +1 -1
  50. package/dist/src/expr/libs/float.js +298 -267
  51. package/dist/src/expr/libs/float.js.map +1 -1
  52. package/dist/src/expr/libs/integer.d.ts +12 -12
  53. package/dist/src/expr/libs/integer.d.ts.map +1 -1
  54. package/dist/src/expr/libs/integer.js +219 -194
  55. package/dist/src/expr/libs/integer.js.map +1 -1
  56. package/dist/src/expr/libs/lazy.d.ts +28 -0
  57. package/dist/src/expr/libs/lazy.d.ts.map +1 -0
  58. package/dist/src/expr/libs/lazy.js +55 -0
  59. package/dist/src/expr/libs/lazy.js.map +1 -0
  60. package/dist/src/expr/libs/lazy.spec.d.ts +6 -0
  61. package/dist/src/expr/libs/lazy.spec.d.ts.map +1 -0
  62. package/dist/src/expr/libs/lazy.spec.js +102 -0
  63. package/dist/src/expr/libs/lazy.spec.js.map +1 -0
  64. package/dist/src/expr/query.d.ts +60 -0
  65. package/dist/src/expr/query.d.ts.map +1 -0
  66. package/dist/src/expr/query.js +84 -0
  67. package/dist/src/expr/query.js.map +1 -0
  68. package/dist/src/index.d.ts +3 -0
  69. package/dist/src/index.d.ts.map +1 -1
  70. package/dist/src/index.js +3 -0
  71. package/dist/src/index.js.map +1 -1
  72. package/dist/src/internal.d.ts +4 -0
  73. package/dist/src/internal.d.ts.map +1 -1
  74. package/dist/src/internal.js +9 -0
  75. package/dist/src/internal.js.map +1 -1
  76. package/dist/src/location.d.ts +22 -0
  77. package/dist/src/location.d.ts.map +1 -1
  78. package/dist/src/location.js +31 -0
  79. package/dist/src/location.js.map +1 -1
  80. package/dist/src/naming.d.ts +12 -7
  81. package/dist/src/naming.d.ts.map +1 -1
  82. package/dist/src/naming.js +30 -13
  83. package/dist/src/naming.js.map +1 -1
  84. package/dist/src/naming.spec.js +49 -0
  85. package/dist/src/naming.spec.js.map +1 -1
  86. package/dist/src/portable.spec.d.ts +6 -0
  87. package/dist/src/portable.spec.d.ts.map +1 -0
  88. package/dist/src/portable.spec.js +181 -0
  89. package/dist/src/portable.spec.js.map +1 -0
  90. package/dist/src/query/evaluate.d.ts +98 -0
  91. package/dist/src/query/evaluate.d.ts.map +1 -0
  92. package/dist/src/query/evaluate.js +193 -0
  93. package/dist/src/query/evaluate.js.map +1 -0
  94. package/dist/src/query/index.d.ts +17 -0
  95. package/dist/src/query/index.d.ts.map +1 -0
  96. package/dist/src/query/index.js +17 -0
  97. package/dist/src/query/index.js.map +1 -0
  98. package/dist/src/query/jq/catalog.d.ts +174 -0
  99. package/dist/src/query/jq/catalog.d.ts.map +1 -0
  100. package/dist/src/query/jq/catalog.js +1740 -0
  101. package/dist/src/query/jq/catalog.js.map +1 -0
  102. package/dist/src/query/jq/check.d.ts +210 -0
  103. package/dist/src/query/jq/check.d.ts.map +1 -0
  104. package/dist/src/query/jq/check.js +2261 -0
  105. package/dist/src/query/jq/check.js.map +1 -0
  106. package/dist/src/query/jq/complete.d.ts +89 -0
  107. package/dist/src/query/jq/complete.d.ts.map +1 -0
  108. package/dist/src/query/jq/complete.js +320 -0
  109. package/dist/src/query/jq/complete.js.map +1 -0
  110. package/dist/src/query/jq/describe.d.ts +53 -0
  111. package/dist/src/query/jq/describe.d.ts.map +1 -0
  112. package/dist/src/query/jq/describe.js +149 -0
  113. package/dist/src/query/jq/describe.js.map +1 -0
  114. package/dist/src/query/jq/lex.d.ts +118 -0
  115. package/dist/src/query/jq/lex.d.ts.map +1 -0
  116. package/dist/src/query/jq/lex.js +371 -0
  117. package/dist/src/query/jq/lex.js.map +1 -0
  118. package/dist/src/query/jq/literals.d.ts +49 -0
  119. package/dist/src/query/jq/literals.d.ts.map +1 -0
  120. package/dist/src/query/jq/literals.js +78 -0
  121. package/dist/src/query/jq/literals.js.map +1 -0
  122. package/dist/src/query/jq/messages.d.ts +126 -0
  123. package/dist/src/query/jq/messages.d.ts.map +1 -0
  124. package/dist/src/query/jq/messages.js +172 -0
  125. package/dist/src/query/jq/messages.js.map +1 -0
  126. package/dist/src/query/jq/parse.d.ts +70 -0
  127. package/dist/src/query/jq/parse.d.ts.map +1 -0
  128. package/dist/src/query/jq/parse.js +1013 -0
  129. package/dist/src/query/jq/parse.js.map +1 -0
  130. package/dist/src/query/jq/print.d.ts +59 -0
  131. package/dist/src/query/jq/print.d.ts.map +1 -0
  132. package/dist/src/query/jq/print.js +587 -0
  133. package/dist/src/query/jq/print.js.map +1 -0
  134. package/dist/src/query/jq/shapes.d.ts +345 -0
  135. package/dist/src/query/jq/shapes.d.ts.map +1 -0
  136. package/dist/src/query/jq/shapes.js +584 -0
  137. package/dist/src/query/jq/shapes.js.map +1 -0
  138. package/dist/src/query/jq/spans.d.ts +133 -0
  139. package/dist/src/query/jq/spans.d.ts.map +1 -0
  140. package/dist/src/query/jq/spans.js +195 -0
  141. package/dist/src/query/jq/spans.js.map +1 -0
  142. package/dist/src/query/jq/split.d.ts +334 -0
  143. package/dist/src/query/jq/split.d.ts.map +1 -0
  144. package/dist/src/query/jq/split.js +2108 -0
  145. package/dist/src/query/jq/split.js.map +1 -0
  146. package/dist/src/query/jq/strftime.d.ts +20 -0
  147. package/dist/src/query/jq/strftime.d.ts.map +1 -0
  148. package/dist/src/query/jq/strftime.js +65 -0
  149. package/dist/src/query/jq/strftime.js.map +1 -0
  150. package/dist/src/query/jq/summary.d.ts +139 -0
  151. package/dist/src/query/jq/summary.d.ts.map +1 -0
  152. package/dist/src/query/jq/summary.js +222 -0
  153. package/dist/src/query/jq/summary.js.map +1 -0
  154. package/dist/src/query/jq/translate-builtins.d.ts +21 -0
  155. package/dist/src/query/jq/translate-builtins.d.ts.map +1 -0
  156. package/dist/src/query/jq/translate-builtins.js +1873 -0
  157. package/dist/src/query/jq/translate-builtins.js.map +1 -0
  158. package/dist/src/query/jq/translate.d.ts +627 -0
  159. package/dist/src/query/jq/translate.d.ts.map +1 -0
  160. package/dist/src/query/jq/translate.js +3364 -0
  161. package/dist/src/query/jq/translate.js.map +1 -0
  162. package/dist/src/query/types.d.ts +505 -0
  163. package/dist/src/query/types.d.ts.map +1 -0
  164. package/dist/src/query/types.js +231 -0
  165. package/dist/src/query/types.js.map +1 -0
  166. package/dist/src/runner_exec.d.ts +134 -0
  167. package/dist/src/runner_exec.d.ts.map +1 -0
  168. package/dist/src/runner_exec.js +371 -0
  169. package/dist/src/runner_exec.js.map +1 -0
  170. package/dist/src/runner_exec.spec.d.ts +6 -0
  171. package/dist/src/runner_exec.spec.d.ts.map +1 -0
  172. package/dist/src/runner_exec.spec.js +198 -0
  173. package/dist/src/runner_exec.spec.js.map +1 -0
  174. package/dist/src/runner_io.d.ts +370 -0
  175. package/dist/src/runner_io.d.ts.map +1 -0
  176. package/dist/src/runner_io.js +563 -0
  177. package/dist/src/runner_io.js.map +1 -0
  178. package/dist/src/runner_io.spec.d.ts +6 -0
  179. package/dist/src/runner_io.spec.d.ts.map +1 -0
  180. package/dist/src/runner_io.spec.js +224 -0
  181. package/dist/src/runner_io.spec.js.map +1 -0
  182. package/dist/src/runner_merge.d.ts +95 -0
  183. package/dist/src/runner_merge.d.ts.map +1 -0
  184. package/dist/src/runner_merge.js +238 -0
  185. package/dist/src/runner_merge.js.map +1 -0
  186. package/dist/src/runner_protocol.d.ts +60 -6
  187. package/dist/src/runner_protocol.d.ts.map +1 -1
  188. package/dist/src/runner_protocol.js +48 -6
  189. package/dist/src/runner_protocol.js.map +1 -1
  190. package/dist/src/serialization/beast2/index.d.ts +2 -2
  191. package/dist/src/serialization/beast2/index.d.ts.map +1 -1
  192. package/dist/src/serialization/beast2/index.js +1 -1
  193. package/dist/src/serialization/beast2/index.js.map +1 -1
  194. package/dist/src/serialization/beast2/v5/frames.d.ts +10 -6
  195. package/dist/src/serialization/beast2/v5/frames.d.ts.map +1 -1
  196. package/dist/src/serialization/beast2/v5/frames.js +10 -6
  197. package/dist/src/serialization/beast2/v5/frames.js.map +1 -1
  198. package/dist/src/serialization/beast2/v5/frames.spec.d.ts +6 -0
  199. package/dist/src/serialization/beast2/v5/frames.spec.d.ts.map +1 -0
  200. package/dist/src/serialization/beast2/v5/frames.spec.js +42 -0
  201. package/dist/src/serialization/beast2/v5/frames.spec.js.map +1 -0
  202. package/dist/src/serialization/beast2/v5/index.spec.js +108 -0
  203. package/dist/src/serialization/beast2/v5/index.spec.js.map +1 -1
  204. package/dist/src/serialization/beast2/v5/lazy.d.ts +74 -7
  205. package/dist/src/serialization/beast2/v5/lazy.d.ts.map +1 -1
  206. package/dist/src/serialization/beast2/v5/lazy.js +129 -27
  207. package/dist/src/serialization/beast2/v5/lazy.js.map +1 -1
  208. package/dist/src/serialization/beast2/v5/lazy.spec.js +251 -16
  209. package/dist/src/serialization/beast2/v5/lazy.spec.js.map +1 -1
  210. package/dist/src/serialization/beast2/v5/stream.d.ts +139 -23
  211. package/dist/src/serialization/beast2/v5/stream.d.ts.map +1 -1
  212. package/dist/src/serialization/beast2/v5/stream.js +196 -44
  213. package/dist/src/serialization/beast2/v5/stream.js.map +1 -1
  214. package/dist/src/serialization/beast2/v5/type-section.d.ts.map +1 -1
  215. package/dist/src/serialization/beast2/v5/type-section.js +25 -12
  216. package/dist/src/serialization/beast2/v5/type-section.js.map +1 -1
  217. package/dist/src/serialization/beast2/v5/type-section.spec.d.ts +6 -0
  218. package/dist/src/serialization/beast2/v5/type-section.spec.d.ts.map +1 -0
  219. package/dist/src/serialization/beast2/v5/type-section.spec.js +41 -0
  220. package/dist/src/serialization/beast2/v5/type-section.spec.js.map +1 -0
  221. package/dist/src/serialization/beast2/v5/weight.d.ts +36 -0
  222. package/dist/src/serialization/beast2/v5/weight.d.ts.map +1 -0
  223. package/dist/src/serialization/beast2/v5/weight.js +238 -0
  224. package/dist/src/serialization/beast2/v5/weight.js.map +1 -0
  225. package/dist/src/serialization/crc32.d.ts +38 -0
  226. package/dist/src/serialization/crc32.d.ts.map +1 -0
  227. package/dist/src/serialization/crc32.js +70 -0
  228. package/dist/src/serialization/crc32.js.map +1 -0
  229. package/dist/src/serialization/crc32.spec.d.ts +6 -0
  230. package/dist/src/serialization/crc32.spec.d.ts.map +1 -0
  231. package/dist/src/serialization/crc32.spec.js +92 -0
  232. package/dist/src/serialization/crc32.spec.js.map +1 -0
  233. package/dist/src/serialization/east-inferred.spec.js +4 -0
  234. package/dist/src/serialization/east-inferred.spec.js.map +1 -1
  235. package/dist/src/serialization/east.d.ts.map +1 -1
  236. package/dist/src/serialization/east.js +134 -110
  237. package/dist/src/serialization/east.js.map +1 -1
  238. package/dist/src/serialization/east.spec.js +185 -4
  239. package/dist/src/serialization/east.spec.js.map +1 -1
  240. package/dist/src/serialization/east_text.d.ts +25 -0
  241. package/dist/src/serialization/east_text.d.ts.map +1 -0
  242. package/dist/src/serialization/east_text.js +29 -0
  243. package/dist/src/serialization/east_text.js.map +1 -0
  244. package/dist/src/serialization/index.d.ts +1 -1
  245. package/dist/src/serialization/index.d.ts.map +1 -1
  246. package/dist/src/serialization/index.js +1 -1
  247. package/dist/src/serialization/index.js.map +1 -1
  248. package/dist/src/types.d.ts +1 -1
  249. package/dist/src/types.d.ts.map +1 -1
  250. package/dist/src/types.js +7 -6
  251. package/dist/src/types.js.map +1 -1
  252. package/package.json +7 -4
@@ -0,0 +1,126 @@
1
+ /**
2
+ * Copyright (c) 2025 Elara AI Pty Ltd
3
+ * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details.
4
+ */
5
+ import type { ValueTypeOf } from "../../types.js";
6
+ import type { QueryErrorType, QueryFixType } from "../types.js";
7
+ import { type JqRange } from "./spans.js";
8
+ /** A diagnostic, as the query wire types hold it. @internal */
9
+ export type QueryError = ValueTypeOf<typeof QueryErrorType>;
10
+ /** A one-click fix. @internal */
11
+ export type QueryFix = ValueTypeOf<typeof QueryFixType>;
12
+ /**
13
+ * Builds a diagnostic.
14
+ *
15
+ * @param text - the program's text
16
+ * @param code - the diagnostic's code
17
+ * @param range - the text it is about, or `undefined`
18
+ * @param message - its sentence, led by its code
19
+ * @param options - suggestions (replacement texts for the range, best first),
20
+ * fixes, and `warning` for a lint
21
+ * @returns the diagnostic
22
+ *
23
+ * @internal
24
+ */
25
+ export declare function report(text: string, code: string, range: JqRange | undefined, message: string, options?: {
26
+ suggestions?: string[];
27
+ fixes?: QueryFix[];
28
+ warning?: boolean;
29
+ }): QueryError;
30
+ /**
31
+ * A fix of one edit.
32
+ *
33
+ * @param label - what the fix does
34
+ * @param from - where the replaced text starts
35
+ * @param to - where it ends
36
+ * @param insert - the new text
37
+ * @returns the fix
38
+ *
39
+ * @internal
40
+ */
41
+ export declare function edit(label: string, from: number, to: number, insert: string): QueryFix;
42
+ /**
43
+ * The edit distance between two names: insertions, deletions and
44
+ * substitutions of UTF-16 code units.
45
+ *
46
+ * @internal
47
+ */
48
+ export declare function distance(a: string, b: string): number;
49
+ /**
50
+ * The names closest to a misspelt one: within `max(2, ⌊length / 3⌋)` edits,
51
+ * or containing it, or contained in it, nearest first, then in the order
52
+ * given.
53
+ *
54
+ * @param name - the name as written
55
+ * @param candidates - the names it could have meant
56
+ * @returns up to three suggestions
57
+ *
58
+ * @internal
59
+ */
60
+ export declare function closest(name: string, candidates: Iterable<string>): string[];
61
+ /**
62
+ * Lists names in a sentence: `a`, `a and b`, `a, b and c`.
63
+ *
64
+ * @internal
65
+ */
66
+ export declare function listWords(names: readonly string[]): string;
67
+ /** The sentences, by situation. @internal */
68
+ export declare const MESSAGES: {
69
+ readonly unknownField: (field: string, type: string, suggestion?: string) => string;
70
+ readonly unknownDataset: (field: string, suggestion?: string) => string;
71
+ readonly unknownPayloadField: (field: string, suggestion?: string) => string;
72
+ readonly unknownVariantField: (field: string, path: string) => string;
73
+ readonly unknownCase: (path: string, name: string, cases: readonly string[], suggestion?: string) => string;
74
+ readonly unknownType: (name: string, names: readonly string[], suggestion?: string) => string;
75
+ readonly unknownFunction: (name: string, arity: number, suggestion?: string) => string;
76
+ readonly unknownVariable: (name: string) => string;
77
+ readonly unknownLabel: (name: string) => string;
78
+ readonly arity: (name: string, arities: readonly number[], given: number) => string;
79
+ readonly notAField: (field: string, type: string) => string;
80
+ readonly notIterable: (form: string, type: string) => string;
81
+ readonly notIterableNull: (form: string, type: string) => string;
82
+ readonly notIndexable: (target: string, type: string) => string;
83
+ readonly keyType: (form: string, key: string, keyText: string, given: string) => string;
84
+ readonly mutableKey: (keyText: string, given: string) => string;
85
+ readonly sliceBound: (given: string) => string;
86
+ readonly sliceUpdate: (form: string, given: string) => string;
87
+ readonly stringSlice: (form: string) => string;
88
+ readonly updateKey: (text: string) => string;
89
+ readonly walkUpdate: (path: string, from: string, to: string) => string;
90
+ readonly structKey: (form: string) => string;
91
+ readonly compares: (op: string, left: string, right: string) => string;
92
+ readonly neverEqual: (op: string) => "type_mismatch: Integer == Float is never true here." | "type_mismatch: Integer != Float is always true here.";
93
+ readonly arithmetic: (op: string, left: string, right: string) => string;
94
+ readonly negate: (type: string) => string;
95
+ readonly wholeVariant: (path: string, type: string) => string;
96
+ readonly narrowFirst: (path: string, type: string, caseName: string, variantPath: string, leaf: string) => string;
97
+ readonly input: (name: string, expected: string, given: string) => string;
98
+ readonly dateAsString: (name: string) => string;
99
+ readonly argument: (name: string, position: string, expected: string, given: string) => string;
100
+ readonly runArgument: (name: string, element: string, given: string, wrapped: string) => string;
101
+ readonly literalArgument: (name: string, position: string, expected: string) => string;
102
+ readonly isoDate: (value: string) => string;
103
+ readonly emptyRange: (text: string) => string;
104
+ readonly regex: (pattern: string, reason: string) => string;
105
+ readonly replacement: (name: string) => string;
106
+ readonly mixedDelete: (text: string) => string;
107
+ readonly mixedKeys: () => string;
108
+ readonly noCommonType: (a: string, b: string) => string;
109
+ readonly accumulator: (form: string, first: string, next: string) => string;
110
+ readonly recursion: (name: string) => string;
111
+ readonly excluded: (name: string) => string;
112
+ readonly unavailable: (name: string, reason: string) => string;
113
+ readonly notYet: (name: string) => string;
114
+ readonly tooling: (name: string) => string;
115
+ readonly wholeRoot: (names: readonly string[]) => string;
116
+ readonly asyncCall: () => string;
117
+ readonly recursiveFilter: (name: string) => string;
118
+ readonly regexFlag: (flag: string) => string;
119
+ readonly formatCode: (code: string) => string;
120
+ readonly duplicateOutputs: (generator: string) => string;
121
+ readonly arrayOnElement: (name: string, stream: string, type: string, collected: string) => string;
122
+ readonly duplicateKey: (key: string) => string;
123
+ readonly neverMissing: (path: string, type: string) => string;
124
+ readonly longRange: (text: string, count: string) => string;
125
+ };
126
+ //# sourceMappingURL=messages.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../../../src/query/jq/messages.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAUH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChE,OAAO,EAAe,KAAK,OAAO,EAAE,MAAM,YAAY,CAAC;AAEvD,+DAA+D;AAC/D,MAAM,MAAM,UAAU,GAAG,WAAW,CAAC,OAAO,cAAc,CAAC,CAAC;AAC5D,iCAAiC;AACjC,MAAM,MAAM,QAAQ,GAAG,WAAW,CAAC,OAAO,YAAY,CAAC,CAAC;AAExD;;;;;;;;;;;;GAYG;AACH,wBAAgB,MAAM,CACpB,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAA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AAM;mCAE7C,MAAM,SAAS,MAAM;iCACvB,MAAM;iCACN,MAAM,SAAS,MAAM;iCACrB,MAAM;+BACR,MAAM;gCACL,MAAM,QAAQ,MAAM,MAAM,MAAM;+BAEjC,MAAM;4BACT,MAAM,QAAQ,MAAM,SAAS,MAAM;8BACjC,MAAM;8BAGN,MAAM,QAAQ,MAAM,SAAS,MAAM;4BACrC,MAAM;kCACA,MAAM,QAAQ,MAAM;iCAErB,MAAM,QAAQ,MAAM,YAAY,MAAM,eAAe,MAAM,QAAQ,MAAM;2BAE/E,MAAM,YAAY,MAAM,SAAS,MAAM;kCAChC,MAAM;8BAEV,MAAM,YAAY,MAAM,YAAY,MAAM,SAAS,MAAM;iCAEtD,MAAM,WAAW,MAAM,SAAS,MAAM,WAAW,MAAM;qCAEnD,MAAM,YAAY,MAAM,YAAY,MAAM;8BAEjD,MAAM;gCACJ,MAAM;8BACR,MAAM,UAAU,MAAM;iCACnB,MAAM;iCAEN,MAAM;;+BAER,MAAM,KAAK,MAAM;iCACf,MAAM,SAAS,MAAM,QAAQ,MAAM;+BAErC,MAAM;8BACP,MAAM;iCACH,MAAM,UAAU,MAAM;4BAC3B,MAAM;6BACL,MAAM;gCACH,SAAS,MAAM,EAAE;;qCAGZ,MAAM;+BAEZ,MAAM;gCACL,MAAM;2CAEK,MAAM;oCAEb,MAAM,UAAU,MAAM,QAAQ,MAAM,aAAa,MAAM;iCAE1D,MAAM;kCACL,MAAM,QAAQ,MAAM;+BACvB,MAAM,SAAS,MAAM;CAE/B,CAAC"}
@@ -0,0 +1,172 @@
1
+ /**
2
+ * Copyright (c) 2025 Elara AI Pty Ltd
3
+ * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details.
4
+ */
5
+ /**
6
+ * The checker's diagnostics: every sentence it says, in one place, because the
7
+ * python twin must say the same words (`devdocs/QUERY.md` §12 lists them).
8
+ *
9
+ * @packageDocumentation
10
+ */
11
+ import { none, some, variant } from "../../containers/variant.js";
12
+ import { toQuerySpan } from "./spans.js";
13
+ /**
14
+ * Builds a diagnostic.
15
+ *
16
+ * @param text - the program's text
17
+ * @param code - the diagnostic's code
18
+ * @param range - the text it is about, or `undefined`
19
+ * @param message - its sentence, led by its code
20
+ * @param options - suggestions (replacement texts for the range, best first),
21
+ * fixes, and `warning` for a lint
22
+ * @returns the diagnostic
23
+ *
24
+ * @internal
25
+ */
26
+ export function report(text, code, range, message, options = {}) {
27
+ return {
28
+ code,
29
+ fixes: options.fixes ?? [],
30
+ message,
31
+ severity: options.warning === true ? variant("warning", null) : variant("error", null),
32
+ span: range === undefined ? none : some(toQuerySpan(text, range.from, range.to)),
33
+ suggestions: options.suggestions ?? [],
34
+ };
35
+ }
36
+ /**
37
+ * A fix of one edit.
38
+ *
39
+ * @param label - what the fix does
40
+ * @param from - where the replaced text starts
41
+ * @param to - where it ends
42
+ * @param insert - the new text
43
+ * @returns the fix
44
+ *
45
+ * @internal
46
+ */
47
+ export function edit(label, from, to, insert) {
48
+ return { edits: [{ insert, length: BigInt(to - from), offset: BigInt(from) }], label };
49
+ }
50
+ /**
51
+ * The edit distance between two names: insertions, deletions and
52
+ * substitutions of UTF-16 code units.
53
+ *
54
+ * @internal
55
+ */
56
+ export function distance(a, b) {
57
+ let previous = Array.from({ length: b.length + 1 }, (_, j) => j);
58
+ for (let i = 1; i <= a.length; i++) {
59
+ const current = [i];
60
+ for (let j = 1; j <= b.length; j++) {
61
+ current[j] = Math.min(previous[j] + 1, current[j - 1] + 1, previous[j - 1] + (a[i - 1] === b[j - 1] ? 0 : 1));
62
+ }
63
+ previous = current;
64
+ }
65
+ return previous[b.length];
66
+ }
67
+ /**
68
+ * The names closest to a misspelt one: within `max(2, ⌊length / 3⌋)` edits,
69
+ * or containing it, or contained in it, nearest first, then in the order
70
+ * given.
71
+ *
72
+ * @param name - the name as written
73
+ * @param candidates - the names it could have meant
74
+ * @returns up to three suggestions
75
+ *
76
+ * @internal
77
+ */
78
+ export function closest(name, candidates) {
79
+ const limit = Math.max(2, Math.floor(name.length / 3));
80
+ const scored = [];
81
+ let order = 0;
82
+ for (const candidate of candidates) {
83
+ const d = distance(name.toLowerCase(), candidate.toLowerCase());
84
+ const related = name.length >= 3 && (candidate.includes(name) || name.includes(candidate));
85
+ if (d <= limit || related)
86
+ scored.push({ candidate, score: related ? Math.min(d, limit) : d, order: order++ });
87
+ else
88
+ order++;
89
+ }
90
+ scored.sort((x, y) => x.score - y.score || x.order - y.order);
91
+ return scored.slice(0, 3).map(s => s.candidate);
92
+ }
93
+ /**
94
+ * Lists names in a sentence: `a`, `a and b`, `a, b and c`.
95
+ *
96
+ * @internal
97
+ */
98
+ export function listWords(names) {
99
+ if (names.length <= 1)
100
+ return names.join("");
101
+ return `${names.slice(0, -1).join(", ")} and ${names[names.length - 1]}`;
102
+ }
103
+ /** "a" or "an" before a type's name. */
104
+ function article(word) {
105
+ return /^[AEIOU]/i.test(word) ? "an" : "a";
106
+ }
107
+ /** The sentences, by situation. @internal */
108
+ export const MESSAGES = {
109
+ unknownField: (field, type, suggestion) => `unknown_field: ${field} is not a field of ${type}.${suggestion === undefined ? "" : ` Did you mean ${suggestion}?`}`,
110
+ unknownDataset: (field, suggestion) => `unknown_field: ${field} is not a dataset in this workspace.${suggestion === undefined ? "" : ` Did you mean ${suggestion}?`}`,
111
+ unknownPayloadField: (field, suggestion) => `unknown_field: ${field} is not a field of any case of this variant.${suggestion === undefined ? "" : ` Did you mean ${suggestion}?`}`,
112
+ unknownVariantField: (field, path) => `unknown_field: ${field} is not a field of ${path}: a variant reads as {type, value}.`,
113
+ unknownCase: (path, name, cases, suggestion) => suggestion === undefined
114
+ ? `unknown_case: ${path} has no case ${name}; its cases are ${listWords(cases)}.`
115
+ : `unknown_case: ${path} has no case ${name}. Did you mean ${suggestion}?`,
116
+ unknownType: (name, names, suggestion) => suggestion === undefined
117
+ ? `unknown_case: type gives ${listWords(names.map(n => `"${n}"`))}, never ${name}.`
118
+ : `unknown_case: type never gives ${name}. Did you mean ${suggestion}?`,
119
+ unknownFunction: (name, arity, suggestion) => `unknown_function: ${name}/${arity} is not a builtin or a def.${suggestion === undefined ? "" : ` Did you mean ${suggestion}?`}`,
120
+ unknownVariable: (name) => `unknown_function: $${name} is not bound here.`,
121
+ unknownLabel: (name) => `unknown_function: there is no label $${name} around this break.`,
122
+ arity: (name, arities, given) => `arity: ${name} takes ${listWords(arities.map(String))} argument${arities.length === 1 && arities[0] === 1 ? "" : "s"}, not ${given}.`,
123
+ notAField: (field, type) => `type_mismatch: ${field} reads a field, but its input is ${type}.`,
124
+ notIterable: (form, type) => `not_iterable: ${form} needs an array; its input is ${type}.`,
125
+ notIterableNull: (form, type) => `not_iterable: ${form} needs an array; its input is ${type}. Use ${form}? to skip null.`,
126
+ notIndexable: (target, type) => `not_indexable: ${target} is ${type}.`,
127
+ keyType: (form, key, keyText, given) => `type_mismatch: ${form} needs ${article(key)} ${key} key; ${keyText} is ${given}.`,
128
+ mutableKey: (keyText, given) => `type_mismatch: ${keyText} is ${given}, and a dict's keys must be immutable.`,
129
+ sliceBound: (given) => `type_mismatch: .[a:b] needs Integer bounds, got ${given}.`,
130
+ sliceUpdate: (form, given) => `type_mismatch: ${form} is updated with an array, not ${given}.`,
131
+ stringSlice: (form) => `type_mismatch: ${form} cannot update part of a string; update the whole string.`,
132
+ updateKey: (text) => `unsupported: ${text} gives more or fewer than one value; an update's keys and bounds give one each.`,
133
+ walkUpdate: (path, from, to) => `type_mismatch: an update through ${path} keeps each value's type, but here ${from} would become ${to}.`,
134
+ structKey: (form) => `type_mismatch: ${form} on a struct needs a literal field name; a computed name needs a dict.`,
135
+ compares: (op, left, right) => `type_mismatch: ${op} compares ${left} with ${right}.`,
136
+ neverEqual: (op) => op === "=="
137
+ ? "type_mismatch: Integer == Float is never true here."
138
+ : "type_mismatch: Integer != Float is always true here.",
139
+ arithmetic: (op, left, right) => `type_mismatch: ${left} ${op} ${right} is not defined.`,
140
+ negate: (type) => `type_mismatch: - negates a number, not ${type}.`,
141
+ wholeVariant: (path, type) => `type_mismatch: ${path} is ${type}; variants read as {type, value} — compare ${path}.type with a case name.`,
142
+ narrowFirst: (path, type, caseName, variantPath, leaf) => `type_mismatch: ${path} is ${type} here — only the "${caseName}" case of ${variantPath} has ${leaf}. Narrow first with select(${variantPath}.type == "${caseName}").`,
143
+ input: (name, expected, given) => `type_mismatch: ${name} needs ${expected}; its input is ${given}.`,
144
+ dateAsString: (name) => `type_mismatch: ${name} needs a string; its input is DateTime. Compare its parts (year == 2026 and month == 9), or its text (todate | ${name}(…)).`,
145
+ argument: (name, position, expected, given) => `type_mismatch: ${name}'s ${position} argument must be ${expected}, not ${given}.`,
146
+ runArgument: (name, element, given, wrapped) => `type_mismatch: ${name} takes an array as a run of elements, which must be ${element}, not ${given}. To find one element, wrap it: ${wrapped}.`,
147
+ literalArgument: (name, position, expected) => `type_mismatch: ${name}'s ${position} argument must be ${expected}, written in the query.`,
148
+ isoDate: (value) => `type_mismatch: ${value} is not an ISO-8601 date — DateTime literals are parsed at check time.`,
149
+ emptyRange: (text) => `type_mismatch: ${text} yields nothing.`,
150
+ regex: (pattern, reason) => `type_mismatch: ${pattern} is not an East regular expression: ${reason}.`,
151
+ replacement: (name) => `type_mismatch: ${name}'s replacement can interpolate only the pattern's named groups, as \\(.name).`,
152
+ mixedDelete: (text) => `ambiguous_output: ${text} leaves values of different types where one type must hold them all.`,
153
+ mixedKeys: () => "type_mismatch: an object's keys are all written as names, or all computed — a struct or a dict, not both.",
154
+ noCommonType: (a, b) => `ambiguous_output: ${a} and ${b} have no common type.`,
155
+ accumulator: (form, first, next) => `cannot_infer: the accumulator of this ${form} is ${first}, then ${next}; start it with a value of the final type.`,
156
+ recursion: (name) => `cannot_infer: ${name} does not settle on one type for this input. Use recurse, while or until.`,
157
+ excluded: (name) => `unsupported: ${name} is excluded — queries are deterministic and have no host access.`,
158
+ unavailable: (name, reason) => `unsupported: ${name} is not available in queries: ${reason}.`,
159
+ notYet: (name) => `unsupported: ${name} is not available in queries yet.`,
160
+ tooling: (name) => `unsupported: ${name} is tooling: it needs the TypeScript IR printers, which queries do not have yet.`,
161
+ wholeRoot: (names) => `unsupported: reading the whole root loads every dataset — name them: ${names.slice(0, 3).map(n => `.${n}`).join(", ")}${names.length > 3 ? ", …" : ""}.`,
162
+ asyncCall: () => "unsupported: call cannot run an async function.",
163
+ recursiveFilter: (name) => `unsupported: ${name} calls itself and takes a filter parameter. Use recurse, while or until.`,
164
+ regexFlag: (flag) => `unsupported: regex flag "${flag}" — East regular expressions take the flags g and i.`,
165
+ formatCode: (code) => `unsupported: %${code} — strftime and strptime take %Y %m %d %H %M %S %b %B %a %A %F %T and %%.`,
166
+ duplicateOutputs: (generator) => `duplicate_outputs: select(${generator} | …) emits the row once per matching element. Use any(${generator}; …).`,
167
+ arrayOnElement: (name, stream, type, collected) => `array_builtin_on_element: ${name} needs an array, but runs here on each element of ${stream}, which is ${type}. Collect the stream first: ${collected}.`,
168
+ duplicateKey: (key) => `duplicate_key: ${key} is set twice in this object; the last one wins.`,
169
+ neverMissing: (path, type) => `never_missing: ${path} is ${type}, never null, so //= changes nothing.`,
170
+ longRange: (text, count) => `long_range: ${text} gives ${count} values; a query returns 1 000 at most by default.`,
171
+ };
172
+ //# sourceMappingURL=messages.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"messages.js","sourceRoot":"","sources":["../../../../src/query/jq/messages.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;GAKG;AAEH,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAGlE,OAAO,EAAE,WAAW,EAAgB,MAAM,YAAY,CAAC;AAOvD;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,MAAM,CACpB,IAAY,EAAE,IAAY,EAAE,KAA0B,EAAE,OAAe,EACvE,UAA6E,EAAE;IAE/E,OAAO;QACL,IAAI;QACJ,KAAK,EAAE,OAAO,CAAC,KAAK,IAAI,EAAE;QAC1B,OAAO;QAC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elara AI Pty Ltd
3
+ * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details.
4
+ */
5
+ /**
6
+ * The jq parser: jq 1.8's grammar (`src/parser.y`) into {@link JqType}
7
+ * values, with a span for every node and `syntax` diagnostics.
8
+ *
9
+ * @packageDocumentation
10
+ */
11
+ import { type option } from "../../containers/variant.js";
12
+ import type { ValueTypeOf } from "../../types.js";
13
+ import type { QueryErrorType } from "../types.js";
14
+ import { type JqNode, type JqSpans } from "./spans.js";
15
+ /** A diagnostic, as the query wire types hold it. */
16
+ type QueryError = ValueTypeOf<typeof QueryErrorType>;
17
+ /**
18
+ * A parsed jq program.
19
+ *
20
+ * @remarks
21
+ * `program` is `none` when any diagnostic was reported, and `spans` is then
22
+ * empty. Otherwise `spans` holds the range of text of every node of
23
+ * `program`, the root's (`""`) covering the whole text. A node's range leaves
24
+ * out the parentheses around it and takes in those around its operands, so
25
+ * `printJq` gives the same ranges for the text it prints.
26
+ */
27
+ export interface ParsedJq {
28
+ /** The text that was parsed. */
29
+ text: string;
30
+ /** The program, or `none` when the text has a syntax problem. */
31
+ program: option<JqNode>;
32
+ /** Where each node of the program is in the text, by its path. */
33
+ spans: JqSpans;
34
+ /** The syntax problems, each with its span and any fix. */
35
+ diagnostics: QueryError[];
36
+ }
37
+ /**
38
+ * Parses jq text into a {@link JqType} program.
39
+ *
40
+ * @param text - jq 1.8 text
41
+ * @returns the program with the span of every node, or `none` with the
42
+ * problems that stopped it
43
+ *
44
+ * @remarks
45
+ * The parser keeps jq's sugar, so printing gives back what was written:
46
+ * `.a.b` is two `field` nodes, `.a?` sets `optional`, and `f?` is a `try`
47
+ * with no `catch`. A literal is the typed East value it writes
48
+ * (`JqLiteralType`): a number written without `.` or an exponent is an
49
+ * Integer (64-bit; larger is a problem), any other number a Float, and a
50
+ * string without interpolation a String. `$__loc__` is the variable
51
+ * `__loc__`; `import`, `include` and `module` are `unsupported`.
52
+ *
53
+ * A problem is a `syntax` diagnostic with its span, and a fix where one is
54
+ * obvious: an unclosed bracket or string is closed, a trailing `|` removed.
55
+ * After a problem the parser resumes at the next `|` outside every bracket,
56
+ * so one typo reports one problem.
57
+ *
58
+ * @example
59
+ * ```ts
60
+ * const parsed = parseJq(".orders | length");
61
+ * parsed.program.type; // "some"
62
+ * parsed.spans.get("pipe.left"); // { from: 0, to: 7 }
63
+ *
64
+ * parseJq(".orders |").diagnostics[0]!.message;
65
+ * // 'syntax: expected a filter after "|".'
66
+ * ```
67
+ */
68
+ export declare function parseJq(text: string): ParsedJq;
69
+ export {};
70
+ //# sourceMappingURL=parse.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../../../../src/query/jq/parse.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;GAKG;AAEH,OAAO,EAAuB,KAAK,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAC/E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,KAAK,EAAE,cAAc,EAAgB,MAAM,aAAa,CAAC;AAEhE,OAAO,EAEL,KAAK,MAAM,EAAgC,KAAK,OAAO,EACxD,MAAM,YAAY,CAAC;AAEpB,qDAAqD;AACrD,KAAK,UAAU,GAAG,WAAW,CAAC,OAAO,cAAc,CAAC,CAAC;AAOrD;;;;;;;;;GASG;AACH,MAAM,WAAW,QAAQ;IACvB,gCAAgC;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,iEAAiE;IACjE,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IACxB,kEAAkE;IAClE,KAAK,EAAE,OAAO,CAAC;IACf,2DAA2D;IAC3D,WAAW,EAAE,UAAU,EAAE,CAAC;CAC3B;AA85BD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,CAiC9C"}