@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,118 @@
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 kind of a jq token, as the jq view highlights it.
7
+ *
8
+ * @remarks
9
+ * - `ws` — spaces, tabs and line breaks.
10
+ * - `comment` — `#` to the end of its line; a backslash before the line break
11
+ * continues it.
12
+ * - `string` — a string's text, its quotes, and the `\(` and `)` around an
13
+ * interpolation; the interpolated query's tokens have their own kinds.
14
+ * - `variable` — `$name`.
15
+ * - `field` — `.name`.
16
+ * - `format` — `@name`.
17
+ * - `number` — a number literal.
18
+ * - `keyword` — `as def if then elif else end reduce foreach try catch label
19
+ * break import include module and or not` and `$__loc__`.
20
+ * - `builtin` — an identifier naming a builtin ({@link isJqBuiltin}).
21
+ * - `identifier` — any other identifier: a `def`'s name, a parameter, `true`,
22
+ * `false`, `null`.
23
+ * - `pipe` — `|`.
24
+ * - `operator` — `|= //= += -= *= /= %= == != <= >= // ?// , + - * / % < > = ?`.
25
+ * - `punctuation` — `( ) [ ] { } : ; . ..`.
26
+ * - `other` — a character the lexer cannot read.
27
+ */
28
+ export type JqTokenKind = "ws" | "comment" | "string" | "variable" | "field" | "format" | "number" | "keyword" | "builtin" | "identifier" | "pipe" | "operator" | "punctuation" | "other";
29
+ /**
30
+ * A token of jq text.
31
+ *
32
+ * @remarks
33
+ * `from` and `to` are offsets in UTF-16 code units, `to` exclusive, and
34
+ * `text` is `text.slice(from, to)` of the lexed text.
35
+ */
36
+ export interface JqToken {
37
+ /** What the token is, for highlighting. */
38
+ kind: JqTokenKind;
39
+ /** Its first offset. */
40
+ from: number;
41
+ /** The offset after its last. */
42
+ to: number;
43
+ /** Its text. */
44
+ text: string;
45
+ }
46
+ /**
47
+ * The role a token plays in the grammar: what the parser reads.
48
+ *
49
+ * @internal
50
+ */
51
+ export type JqRole = "ws" | "comment" | "field" | "ident" | "keyword" | "loc" | "variable" | "format" | "number" | "op" | "punct" | "string_start" | "string_text" | "interp_start" | "interp_end" | "string_end" | "unterminated" | "other";
52
+ /**
53
+ * A token with its grammatical role and its decoded value.
54
+ *
55
+ * @remarks
56
+ * `value` is the field, identifier or variable name (without `.` or `$`), the
57
+ * format's name (without `@`), a keyword, operator or punctuation's text, a
58
+ * number's text, or a string piece's decoded text. `error` says why a string
59
+ * piece's escapes cannot be read.
60
+ *
61
+ * @internal
62
+ */
63
+ export interface JqLexeme extends JqToken {
64
+ /** The token's role in the grammar. */
65
+ role: JqRole;
66
+ /** The token's value, as the role reads it. */
67
+ value: string;
68
+ /** Why the token's text is not valid, when it is not. */
69
+ error?: string;
70
+ }
71
+ /**
72
+ * Whether a word is one jq reserves, so no function or parameter can take it
73
+ * as a name.
74
+ *
75
+ * @param word - the word
76
+ * @returns `true` for a keyword; `not` is a builtin, so `false` for it
77
+ *
78
+ * @internal
79
+ */
80
+ export declare function isJqKeyword(word: string): boolean;
81
+ /**
82
+ * Scans jq text into lexemes: every character of the text in exactly one, in
83
+ * order.
84
+ *
85
+ * @param text - the text
86
+ * @returns its lexemes
87
+ *
88
+ * @remarks
89
+ * Strings keep jq's lexer states: a `\(` opens an interpolation that the
90
+ * matching `)` closes, with the brackets opened inside it balanced first. A
91
+ * string still open at the end of the text becomes one `unterminated` lexeme
92
+ * running to the end of its first line, and scanning resumes after it as if
93
+ * the string had not begun, so the rest of the text still reads as code.
94
+ *
95
+ * @internal
96
+ */
97
+ export declare function scanJq(text: string): JqLexeme[];
98
+ /**
99
+ * Splits jq text into tokens for highlighting.
100
+ *
101
+ * @param text - the text
102
+ * @returns its tokens: every character of the text in exactly one, in order
103
+ *
104
+ * @remarks
105
+ * A string's text, its quotes and the `\(` / `)` of its interpolations are
106
+ * `string` tokens, merged where they touch; the tokens of an interpolated
107
+ * query keep their own kinds. A string that is never closed runs to the end of
108
+ * its first line, and the rest of the text lexes as code, so highlighting
109
+ * keeps going.
110
+ *
111
+ * @example
112
+ * ```ts
113
+ * lexJq(".orders | length").map(t => t.kind);
114
+ * // ["field", "ws", "pipe", "ws", "builtin"]
115
+ * ```
116
+ */
117
+ export declare function lexJq(text: string): JqToken[];
118
+ //# sourceMappingURL=lex.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lex.d.ts","sourceRoot":"","sources":["../../../../src/query/jq/lex.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAWH;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,MAAM,WAAW,GACnB,IAAI,GAAG,SAAS,GAAG,QAAQ,GAAG,UAAU,GAAG,OAAO,GAAG,QAAQ,GAAG,QAAQ,GACxE,SAAS,GAAG,SAAS,GAAG,YAAY,GAAG,MAAM,GAAG,UAAU,GAAG,aAAa,GAAG,OAAO,CAAC;AAEzF;;;;;;GAMG;AACH,MAAM,WAAW,OAAO;IACtB,2CAA2C;IAC3C,IAAI,EAAE,WAAW,CAAC;IAClB,wBAAwB;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,iCAAiC;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,gBAAgB;IAChB,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;GAIG;AACH,MAAM,MAAM,MAAM,GACd,IAAI,GAAG,SAAS,GAChB,OAAO,GAAG,OAAO,GAAG,SAAS,GAAG,KAAK,GAAG,UAAU,GAAG,QAAQ,GAAG,QAAQ,GAAG,IAAI,GAAG,OAAO,GACzF,cAAc,GAAG,aAAa,GAAG,cAAc,GAAG,YAAY,GAAG,YAAY,GAC7E,cAAc,GAAG,OAAO,CAAC;AAE7B;;;;;;;;;;GAUG;AACH,MAAM,WAAW,QAAS,SAAQ,OAAO;IACvC,uCAAuC;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,+CAA+C;IAC/C,KAAK,EAAE,MAAM,CAAC;IACd,yDAAyD;IACzD,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAQD;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEjD;AAiGD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,EAAE,CAgK/C;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,EAAE,CAY7C"}
@@ -0,0 +1,371 @@
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 jq lexer: jq 1.8's tokens (`src/lexer.l`), with the spans the query
7
+ * editor highlights by and the parser reads.
8
+ *
9
+ * @packageDocumentation
10
+ */
11
+ import { isJqBuiltin } from "./catalog.js";
12
+ /** The words jq reserves. */
13
+ const KEYWORDS = new Set([
14
+ "as", "def", "if", "then", "elif", "else", "end", "reduce", "foreach", "try", "catch",
15
+ "label", "break", "import", "include", "module", "and", "or",
16
+ ]);
17
+ /**
18
+ * Whether a word is one jq reserves, so no function or parameter can take it
19
+ * as a name.
20
+ *
21
+ * @param word - the word
22
+ * @returns `true` for a keyword; `not` is a builtin, so `false` for it
23
+ *
24
+ * @internal
25
+ */
26
+ export function isJqKeyword(word) {
27
+ return KEYWORDS.has(word);
28
+ }
29
+ /** A surrogate without its other half. */
30
+ const LONE_SURROGATE = /[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/g;
31
+ /**
32
+ * Replaces each lone surrogate with U+FFFD, so a string's value is
33
+ * well-formed UTF-16 whether its text wrote the surrogate raw or escaped.
34
+ *
35
+ * @param text - decoded string text
36
+ * @returns the text, well-formed
37
+ */
38
+ function wellFormed(text) {
39
+ return text.replace(LONE_SURROGATE, "�");
40
+ }
41
+ /** Operators, longest first so a scan takes the longest match. */
42
+ const OPERATORS = [
43
+ "?//", "//=", "|=", "+=", "-=", "*=", "/=", "%=", "==", "!=", "<=", ">=", "//",
44
+ "|", ",", "+", "-", "*", "/", "%", "<", ">", "=", "?",
45
+ ];
46
+ const IDENT = /[a-zA-Z_][a-zA-Z_0-9]*(?:::[a-zA-Z_][a-zA-Z_0-9]*)*/y;
47
+ const FIELD = /\.[a-zA-Z_][a-zA-Z_0-9]*/y;
48
+ const VARIABLE = /\$[a-zA-Z_][a-zA-Z_0-9]*(?:::[a-zA-Z_][a-zA-Z_0-9]*)*/y;
49
+ const FORMAT = /@[a-zA-Z0-9_]+/y;
50
+ const NUMBER = /(?:[0-9]+(?:\.[0-9]*)?|\.[0-9]+)(?:[eE][+-]?[0-9]+)?/y;
51
+ const WHITESPACE = /[ \t\r\n]+/y;
52
+ const STRING_RUN = /[^\\"]+/y;
53
+ /**
54
+ * Matches a sticky pattern at an offset.
55
+ *
56
+ * @param pattern - a sticky (`y`) pattern
57
+ * @param text - the text
58
+ * @param at - the offset
59
+ * @returns the matched text, or `undefined`
60
+ */
61
+ function matchAt(pattern, text, at) {
62
+ pattern.lastIndex = at;
63
+ return pattern.exec(text)?.[0];
64
+ }
65
+ /**
66
+ * The offset of the end of the line holding an offset: its line break, or the
67
+ * end of the text.
68
+ *
69
+ * @param text - the text
70
+ * @param at - an offset on the line
71
+ * @returns the offset of the line's `\r` or `\n`, or the text's length
72
+ */
73
+ function endOfLine(text, at) {
74
+ for (let i = at; i < text.length; i++) {
75
+ const c = text.charCodeAt(i);
76
+ if (c === 10 || c === 13)
77
+ return i;
78
+ }
79
+ return text.length;
80
+ }
81
+ /**
82
+ * Decodes the escapes of a jq string, as JSON reads them.
83
+ *
84
+ * @param escapes - one or more escapes: `\"`, `\\`, `\/`, `\b`, `\f`, `\n`,
85
+ * `\r`, `\t` or `\u` and four hex digits
86
+ * @returns the decoded text, or the first escape that cannot be read
87
+ */
88
+ function decodeEscapes(escapes) {
89
+ let text = "";
90
+ let i = 0;
91
+ while (i < escapes.length) {
92
+ const c = escapes[i + 1];
93
+ switch (c) {
94
+ case "\"":
95
+ text += "\"";
96
+ i += 2;
97
+ continue;
98
+ case "\\":
99
+ text += "\\";
100
+ i += 2;
101
+ continue;
102
+ case "/":
103
+ text += "/";
104
+ i += 2;
105
+ continue;
106
+ case "b":
107
+ text += "\b";
108
+ i += 2;
109
+ continue;
110
+ case "f":
111
+ text += "\f";
112
+ i += 2;
113
+ continue;
114
+ case "n":
115
+ text += "\n";
116
+ i += 2;
117
+ continue;
118
+ case "r":
119
+ text += "\r";
120
+ i += 2;
121
+ continue;
122
+ case "t":
123
+ text += "\t";
124
+ i += 2;
125
+ continue;
126
+ case "u": {
127
+ const hex = escapes.slice(i + 2, i + 6);
128
+ if (!/^[0-9a-fA-F]{4}$/.test(hex)) {
129
+ const bad = /^\\u[a-zA-Z0-9]{0,4}/.exec(escapes.slice(i))[0];
130
+ return { invalid: bad };
131
+ }
132
+ text += String.fromCharCode(parseInt(hex, 16));
133
+ i += 6;
134
+ continue;
135
+ }
136
+ default:
137
+ return { invalid: escapes.slice(i, i + 2) };
138
+ }
139
+ }
140
+ return { text: wellFormed(text) };
141
+ }
142
+ /**
143
+ * Scans jq text into lexemes: every character of the text in exactly one, in
144
+ * order.
145
+ *
146
+ * @param text - the text
147
+ * @returns its lexemes
148
+ *
149
+ * @remarks
150
+ * Strings keep jq's lexer states: a `\(` opens an interpolation that the
151
+ * matching `)` closes, with the brackets opened inside it balanced first. A
152
+ * string still open at the end of the text becomes one `unterminated` lexeme
153
+ * running to the end of its first line, and scanning resumes after it as if
154
+ * the string had not begun, so the rest of the text still reads as code.
155
+ *
156
+ * @internal
157
+ */
158
+ export function scanJq(text) {
159
+ const out = [];
160
+ /** Open brackets, interpolations and strings, innermost last. */
161
+ const stack = [];
162
+ const push = (role, kind, from, to, value, error) => {
163
+ const lexeme = { kind, from, to, text: text.slice(from, to), role, value };
164
+ if (error !== undefined)
165
+ lexeme.error = error;
166
+ out.push(lexeme);
167
+ };
168
+ let at = 0;
169
+ for (;;) {
170
+ if (at >= text.length) {
171
+ const open = stack.findIndex(s => s.kind === "string");
172
+ if (open === -1)
173
+ break;
174
+ // A string never closed: its first line is one lexeme, and what follows
175
+ // reads as it would have without the string.
176
+ const { token, at: start } = stack[open];
177
+ out.length = token;
178
+ stack.length = open;
179
+ const end = endOfLine(text, start);
180
+ push("unterminated", "string", start, end, text.slice(start + 1, end));
181
+ at = end;
182
+ continue;
183
+ }
184
+ const top = stack[stack.length - 1];
185
+ if (top?.kind === "string") {
186
+ const c = text[at];
187
+ if (c === "\"") {
188
+ stack.pop();
189
+ push("string_end", "string", at, at + 1, "\"");
190
+ at += 1;
191
+ }
192
+ else if (c === "\\" && text[at + 1] === "(") {
193
+ stack.push({ kind: "interp", token: out.length, at });
194
+ push("interp_start", "string", at, at + 2, "\\(");
195
+ at += 2;
196
+ }
197
+ else if (c === "\\") {
198
+ let end = at;
199
+ while (text[end] === "\\" && text[end + 1] !== "(" && end + 1 < text.length) {
200
+ end += text[end + 1] === "u" ? 2 + (/^[a-zA-Z0-9]{0,4}/.exec(text.slice(end + 2, end + 6))[0].length) : 2;
201
+ }
202
+ if (end === at)
203
+ end = at + 1; // a backslash at the very end of the text
204
+ const decoded = decodeEscapes(text.slice(at, end));
205
+ if ("invalid" in decoded)
206
+ push("string_text", "string", at, end, "", `invalid escape "${decoded.invalid}" in a string`);
207
+ else
208
+ push("string_text", "string", at, end, decoded.text);
209
+ at = end;
210
+ }
211
+ else {
212
+ const run = matchAt(STRING_RUN, text, at);
213
+ push("string_text", "string", at, at + run.length, wellFormed(run));
214
+ at += run.length;
215
+ }
216
+ continue;
217
+ }
218
+ const c = text[at];
219
+ const ws = matchAt(WHITESPACE, text, at);
220
+ if (ws !== undefined) {
221
+ push("ws", "ws", at, at + ws.length, ws);
222
+ at += ws.length;
223
+ continue;
224
+ }
225
+ if (c === "#") {
226
+ let end = at + 1;
227
+ while (end < text.length) {
228
+ const d = text[end];
229
+ if (d === "\\" && (text[end + 1] === "\\" || text[end + 1] === "\n")) {
230
+ end += 2;
231
+ continue;
232
+ }
233
+ if (d === "\\" && text[end + 1] === "\r" && text[end + 2] === "\n") {
234
+ end += 3;
235
+ continue;
236
+ }
237
+ if (d === "\n" || (d === "\r" && text[end + 1] === "\n"))
238
+ break;
239
+ end += 1;
240
+ }
241
+ push("comment", "comment", at, end, text.slice(at, end));
242
+ at = end;
243
+ continue;
244
+ }
245
+ if (c === "\"") {
246
+ stack.push({ kind: "string", token: out.length, at });
247
+ push("string_start", "string", at, at + 1, "\"");
248
+ at += 1;
249
+ continue;
250
+ }
251
+ if (c === "(" || c === "[" || c === "{") {
252
+ stack.push({ kind: c, token: out.length, at });
253
+ push("punct", "punctuation", at, at + 1, c);
254
+ at += 1;
255
+ continue;
256
+ }
257
+ if (c === ")" || c === "]" || c === "}") {
258
+ const opener = c === ")" ? "(" : c === "]" ? "[" : "{";
259
+ if (top?.kind === opener) {
260
+ stack.pop();
261
+ push("punct", "punctuation", at, at + 1, c);
262
+ }
263
+ else if (top?.kind === "interp" && c === ")") {
264
+ stack.pop();
265
+ push("interp_end", "string", at, at + 1, ")");
266
+ }
267
+ else {
268
+ push("punct", "punctuation", at, at + 1, c);
269
+ }
270
+ at += 1;
271
+ continue;
272
+ }
273
+ if (c === "$" && text.startsWith("$__loc__", at) && matchAt(VARIABLE, text, at).length === 8) {
274
+ push("loc", "keyword", at, at + 8, "$__loc__");
275
+ at += 8;
276
+ continue;
277
+ }
278
+ const variable = matchAt(VARIABLE, text, at);
279
+ if (variable !== undefined) {
280
+ push("variable", "variable", at, at + variable.length, variable.slice(1));
281
+ at += variable.length;
282
+ continue;
283
+ }
284
+ const number = matchAt(NUMBER, text, at);
285
+ if (number !== undefined) {
286
+ push("number", "number", at, at + number.length, number);
287
+ at += number.length;
288
+ continue;
289
+ }
290
+ const field = matchAt(FIELD, text, at);
291
+ if (field !== undefined) {
292
+ push("field", "field", at, at + field.length, field.slice(1));
293
+ at += field.length;
294
+ continue;
295
+ }
296
+ if (text.startsWith("..", at)) {
297
+ push("punct", "punctuation", at, at + 2, "..");
298
+ at += 2;
299
+ continue;
300
+ }
301
+ if (c === "." || c === ":" || c === ";") {
302
+ push("punct", "punctuation", at, at + 1, c);
303
+ at += 1;
304
+ continue;
305
+ }
306
+ const format = matchAt(FORMAT, text, at);
307
+ if (format !== undefined) {
308
+ push("format", "format", at, at + format.length, format.slice(1));
309
+ at += format.length;
310
+ continue;
311
+ }
312
+ const ident = matchAt(IDENT, text, at);
313
+ if (ident !== undefined) {
314
+ if (KEYWORDS.has(ident))
315
+ push("keyword", "keyword", at, at + ident.length, ident);
316
+ else if (ident === "not")
317
+ push("ident", "keyword", at, at + ident.length, ident);
318
+ else
319
+ push("ident", isJqBuiltin(ident) ? "builtin" : "identifier", at, at + ident.length, ident);
320
+ at += ident.length;
321
+ continue;
322
+ }
323
+ const op = OPERATORS.find(o => text.startsWith(o, at));
324
+ if (op !== undefined) {
325
+ push("op", op === "|" ? "pipe" : "operator", at, at + op.length, op);
326
+ at += op.length;
327
+ continue;
328
+ }
329
+ // One UTF-16 code unit at a time, except a surrogate pair, which is one
330
+ // character.
331
+ const next = text[at + 1];
332
+ const width = c >= "\uD800" && c <= "\uDBFF" && next !== undefined && next >= "\uDC00" && next <= "\uDFFF" ? 2 : 1;
333
+ push("other", "other", at, at + width, text.slice(at, at + width));
334
+ at += width;
335
+ }
336
+ return out;
337
+ }
338
+ /**
339
+ * Splits jq text into tokens for highlighting.
340
+ *
341
+ * @param text - the text
342
+ * @returns its tokens: every character of the text in exactly one, in order
343
+ *
344
+ * @remarks
345
+ * A string's text, its quotes and the `\(` / `)` of its interpolations are
346
+ * `string` tokens, merged where they touch; the tokens of an interpolated
347
+ * query keep their own kinds. A string that is never closed runs to the end of
348
+ * its first line, and the rest of the text lexes as code, so highlighting
349
+ * keeps going.
350
+ *
351
+ * @example
352
+ * ```ts
353
+ * lexJq(".orders | length").map(t => t.kind);
354
+ * // ["field", "ws", "pipe", "ws", "builtin"]
355
+ * ```
356
+ */
357
+ export function lexJq(text) {
358
+ const tokens = [];
359
+ for (const { kind, from, to } of scanJq(text)) {
360
+ const last = tokens[tokens.length - 1];
361
+ if (kind === "string" && last?.kind === "string" && last.to === from) {
362
+ last.to = to;
363
+ last.text = text.slice(last.from, to);
364
+ }
365
+ else {
366
+ tokens.push({ kind, from, to, text: text.slice(from, to) });
367
+ }
368
+ }
369
+ return tokens;
370
+ }
371
+ //# sourceMappingURL=lex.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lex.js","sourceRoot":"","sources":["../../../../src/query/jq/lex.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;GAKG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AA8E3C,6BAA6B;AAC7B,MAAM,QAAQ,GAAwB,IAAI,GAAG,CAAC;IAC5C,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO;IACrF,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI;CAC7D,CAAC,CAAC;AAEH;;;;;;;;GAQG;AACH,MAAM,UAAU,WAAW,CAAC,IAAY;IACtC,OAAO,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AAC5B,CAAC;AAED,0CAA0C;AAC1C,MAAM,cAAc,GAAG,yEAAyE,CAAC;AAEjG;;;;;;GAMG;AACH,SAAS,UAAU,CAAC,IAAY;IAC9B,OAAO,IAAI,CAAC,OAAO,CAAC,cAAc,EAAE,GAAG,CAAC,CAAC;AAC3C,CAAC;AAED,kEAAkE;AAClE,MAAM,SAAS,GAAsB;IACnC,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI;IAC9E,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,G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,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,EAAE,GAAG,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,GAAG,KAAK,CAAC,CAAC,CAAC;QACnE,EAAE,IAAI,KAAK,CAAC;IACd,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,KAAK,CAAC,IAAY;IAChC,MAAM,MAAM,GAAc,EAAE,CAAC;IAC7B,KAAK,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;QAC9C,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QACvC,IAAI,IAAI,KAAK,QAAQ,IAAI,IAAI,EAAE,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,EAAE,KAAK,IAAI,EAAE,CAAC;YACrE,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;YACb,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QACxC,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC;QAC9D,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,49 @@
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 EastType, type ValueTypeOf } from "../../types.js";
6
+ import type { JqLiteralType } from "../types.js";
7
+ /** A constant a jq program writes: a {@link JqLiteralType} value. */
8
+ export type JqLiteral = ValueTypeOf<typeof JqLiteralType>;
9
+ /**
10
+ * A literal's East type and value, as the program writes it.
11
+ *
12
+ * @param literal - the literal
13
+ * @returns its type and its value
14
+ *
15
+ * @internal
16
+ */
17
+ export declare function literalValue(literal: JqLiteral): {
18
+ type: EastType;
19
+ value: unknown;
20
+ };
21
+ /**
22
+ * A string as jq's text writes it: a JSON string, written by East's JSON
23
+ * codec. The twin of python's `json_string`.
24
+ *
25
+ * @param value - the string
26
+ * @returns the string in quotes, with JSON's escapes
27
+ *
28
+ * @remarks
29
+ * Whatever writes jq text writes its strings with this: the printer's string
30
+ * literals and quoted names, a checker's fix and the names its messages quote,
31
+ * a completion, a summary's program. East's own text escapes only a backslash
32
+ * and a quote and keeps control characters as they are, which a jq string
33
+ * cannot hold, so it is not jq's.
34
+ *
35
+ * @internal
36
+ */
37
+ export declare function jsonString(value: string): string;
38
+ /**
39
+ * Reads ISO-8601 text as a DateTime, through East's RFC 3339 reader: a full
40
+ * date-time with its offset, a date-time with none (UTC), or a date (midnight
41
+ * UTC).
42
+ *
43
+ * @param text - the text
44
+ * @returns the DateTime, or `undefined` when the text is not an ISO-8601 date
45
+ *
46
+ * @internal
47
+ */
48
+ export declare function isoDateTime(text: string): Date | undefined;
49
+ //# sourceMappingURL=literals.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"literals.d.ts","sourceRoot":"","sources":["../../../../src/query/jq/literals.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAeH,OAAO,EAA6D,KAAK,QAAQ,EAAE,KAAK,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC5H,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjD,qEAAqE;AACrE,MAAM,MAAM,SAAS,GAAG,WAAW,CAAC,OAAO,aAAa,CAAC,CAAC;AAE1D;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,SAAS,GAAG;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,CAQnF;AAMD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAS1D"}
@@ -0,0 +1,78 @@
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
+ * A jq program's constants: each literal's East type and value, the ISO-8601
7
+ * text a string literal writes a DateTime as (`devdocs/QUERY.md` §7), and a
8
+ * string's jq text, which is JSON's.
9
+ *
10
+ * The checker and the translator read a literal through these alike: the
11
+ * checker to type it and to report a string that is not a date, the
12
+ * translator to give its value as the type the checker read it as.
13
+ *
14
+ * @packageDocumentation
15
+ */
16
+ import { encodeJSONFor, jsonParseDateTime } from "../../serialization/json.js";
17
+ import { BooleanType, FloatType, IntegerType, NullType, StringType } from "../../types.js";
18
+ /**
19
+ * A literal's East type and value, as the program writes it.
20
+ *
21
+ * @param literal - the literal
22
+ * @returns its type and its value
23
+ *
24
+ * @internal
25
+ */
26
+ export function literalValue(literal) {
27
+ switch (literal.type) {
28
+ case "boolean": return { type: BooleanType, value: literal.value };
29
+ case "float": return { type: FloatType, value: literal.value };
30
+ case "integer": return { type: IntegerType, value: literal.value };
31
+ case "null": return { type: NullType, value: null };
32
+ case "string": return { type: StringType, value: literal.value };
33
+ }
34
+ }
35
+ /** A String's JSON, as East's JSON codec writes it: UTF-8 bytes. */
36
+ const encodeStringJson = encodeJSONFor(StringType);
37
+ const utf8 = new TextDecoder();
38
+ /**
39
+ * A string as jq's text writes it: a JSON string, written by East's JSON
40
+ * codec. The twin of python's `json_string`.
41
+ *
42
+ * @param value - the string
43
+ * @returns the string in quotes, with JSON's escapes
44
+ *
45
+ * @remarks
46
+ * Whatever writes jq text writes its strings with this: the printer's string
47
+ * literals and quoted names, a checker's fix and the names its messages quote,
48
+ * a completion, a summary's program. East's own text escapes only a backslash
49
+ * and a quote and keeps control characters as they are, which a jq string
50
+ * cannot hold, so it is not jq's.
51
+ *
52
+ * @internal
53
+ */
54
+ export function jsonString(value) {
55
+ return utf8.decode(encodeStringJson(value));
56
+ }
57
+ /**
58
+ * Reads ISO-8601 text as a DateTime, through East's RFC 3339 reader: a full
59
+ * date-time with its offset, a date-time with none (UTC), or a date (midnight
60
+ * UTC).
61
+ *
62
+ * @param text - the text
63
+ * @returns the DateTime, or `undefined` when the text is not an ISO-8601 date
64
+ *
65
+ * @internal
66
+ */
67
+ export function isoDateTime(text) {
68
+ const forms = /^\d{4}-\d{2}-\d{2}$/.test(text) ? [`${text}T00:00:00Z`]
69
+ : /^\d{4}-\d{2}-\d{2}[Tt]\d{2}:\d{2}:\d{2}(\.\d+)?$/.test(text) ? [`${text}Z`]
70
+ : [text];
71
+ for (const form of forms) {
72
+ const ms = jsonParseDateTime(form);
73
+ if (typeof ms === "number")
74
+ return new Date(ms);
75
+ }
76
+ return undefined;
77
+ }
78
+ //# sourceMappingURL=literals.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"literals.js","sourceRoot":"","sources":["../../../../src/query/jq/literals.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAC/E,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,WAAW,EAAE,QAAQ,EAAE,UAAU,EAAmC,MAAM,gBAAgB,CAAC;AAM5H;;;;;;;GAOG;AACH,MAAM,UAAU,YAAY,CAAC,OAAkB;IAC7C,QAAQ,OAAO,CAAC,IAAI,EAAE,CAAC;QACrB,KAAK,SAAS,CAAC,CAAC,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC;QACnE,KAAK,OAAO,CAAC,CAAC,O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