@prisma/orm-framework 8.0.0-rc.18-dev.42 → 8.0.0-rc.18-dev.43

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 (102) hide show
  1. package/dist/{authoring-BKO7sRLw.d.mts → authoring-C8sYYHu7.d.mts} +3 -3
  2. package/dist/{authoring-BKO7sRLw.d.mts.map → authoring-C8sYYHu7.d.mts.map} +1 -1
  3. package/dist/{authoring-so3aBYD8.mjs → authoring-qO6idK5H.mjs} +24 -3
  4. package/dist/authoring-qO6idK5H.mjs.map +1 -0
  5. package/dist/{binder-WS9-1Mu9-MJi8x3Gm.d.mts → binder-63ozT0D8-BixamO0l.d.mts} +12 -10
  6. package/dist/binder-63ozT0D8-BixamO0l.d.mts.map +1 -0
  7. package/dist/{components-D-8GZwNo.d.mts → components-B3SnaxMU.d.mts} +2 -2
  8. package/dist/{components-D-8GZwNo.d.mts.map → components-B3SnaxMU.d.mts.map} +1 -1
  9. package/dist/components.d.mts +10 -10
  10. package/dist/components.mjs +4 -4
  11. package/dist/components__authoring.d.mts +4 -4
  12. package/dist/components__authoring.mjs +3 -3
  13. package/dist/components__components.d.mts +2 -2
  14. package/dist/components__control.d.mts +3 -3
  15. package/dist/components__control.mjs +3 -3
  16. package/dist/components__execution.d.mts +1 -1
  17. package/dist/components__psl-ast.d.mts +3 -3
  18. package/dist/{config-types-CfdMN7t-.d.mts → config-types-0fY7fbd7.d.mts} +6 -6
  19. package/dist/{config-types-CfdMN7t-.d.mts.map → config-types-0fY7fbd7.d.mts.map} +1 -1
  20. package/dist/config.d.mts +1 -1
  21. package/dist/config__config-types.d.mts +1 -1
  22. package/dist/contract-authoring.d.mts +34 -14
  23. package/dist/contract-authoring.d.mts.map +1 -1
  24. package/dist/contract-authoring.mjs +3 -3
  25. package/dist/{control-B5ezUWD2-BgUEggvd.d.mts → control-B5ezUWD2-D6knyncN.d.mts} +2 -2
  26. package/dist/{control-B5ezUWD2-BgUEggvd.d.mts.map → control-B5ezUWD2-D6knyncN.d.mts.map} +1 -1
  27. package/dist/control-D2ZpYj6i.d.mts +1 -0
  28. package/dist/{control-7DsPHRLi.d.mts → control-D9rb0OBR.d.mts} +18 -48
  29. package/dist/{control-7DsPHRLi.d.mts.map → control-D9rb0OBR.d.mts.map} +1 -1
  30. package/dist/{control-AlBtrJUn.mjs → control-DPasGnOD.mjs} +23 -124
  31. package/dist/control-DPasGnOD.mjs.map +1 -0
  32. package/dist/{control-KsXr4fYD-DJm_48Db.mjs → control-KsXr4fYD-B23ri5vh.mjs} +2 -2
  33. package/dist/{control-KsXr4fYD-DJm_48Db.mjs.map → control-KsXr4fYD-B23ri5vh.mjs.map} +1 -1
  34. package/dist/declarations-BgUAq1RG-ShewcVdd.mjs +459 -0
  35. package/dist/declarations-BgUAq1RG-ShewcVdd.mjs.map +1 -0
  36. package/dist/errors.d.mts +4 -4
  37. package/dist/errors.mjs +3 -3
  38. package/dist/errors__control.d.mts +2 -2
  39. package/dist/errors__control.mjs +1 -1
  40. package/dist/errors__execution.d.mts +1 -1
  41. package/dist/errors__execution.mjs +1 -1
  42. package/dist/errors__migration.d.mts +1 -1
  43. package/dist/errors__migration.mjs +1 -1
  44. package/dist/{execution-BkcXd7Tn.d.mts → execution-C00_IFA7.d.mts} +3 -3
  45. package/dist/{execution-BkcXd7Tn.d.mts.map → execution-C00_IFA7.d.mts.map} +1 -1
  46. package/dist/{execution-KLhn9sSn.mjs → execution-C_4ICly-.mjs} +2 -2
  47. package/dist/{execution-KLhn9sSn.mjs.map → execution-C_4ICly-.mjs.map} +1 -1
  48. package/dist/{execution-DXQQRCfR.d.mts → execution-CktUHYP0.d.mts} +2 -2
  49. package/dist/{execution-DXQQRCfR.d.mts.map → execution-CktUHYP0.d.mts.map} +1 -1
  50. package/dist/expressions-CMQzbnHk-fqYn-D3z.mjs +895 -0
  51. package/dist/expressions-CMQzbnHk-fqYn-D3z.mjs.map +1 -0
  52. package/dist/{framework-authoring-hZgq-M2K-Daz3kgWL.d.mts → framework-authoring-Du7xSUmg-D85Toszi.d.mts} +27 -10
  53. package/dist/framework-authoring-Du7xSUmg-D85Toszi.d.mts.map +1 -0
  54. package/dist/{framework-components-B-yaLbst-nZJUGMuf.d.mts → framework-components-DQFte83L-CIIcH8Bj.d.mts} +3 -3
  55. package/dist/{framework-components-B-yaLbst-nZJUGMuf.d.mts.map → framework-components-DQFte83L-CIIcH8Bj.d.mts.map} +1 -1
  56. package/dist/{migration-CZik9OxU.mjs → migration-Dy-tXHxh.mjs} +2 -2
  57. package/dist/{migration-CZik9OxU.mjs.map → migration-Dy-tXHxh.mjs.map} +1 -1
  58. package/dist/{migration-BVDJBmyi.d.mts → migration-K3Co0dba.d.mts} +2 -2
  59. package/dist/{migration-BVDJBmyi.d.mts.map → migration-K3Co0dba.d.mts.map} +1 -1
  60. package/dist/{parse-BxcaGLV1-BxEIfxh3.mjs → parse-bZgfjovA-Bd80h0ox.mjs} +4 -4
  61. package/dist/{parse-BxcaGLV1-BxEIfxh3.mjs.map → parse-bZgfjovA-Bd80h0ox.mjs.map} +1 -1
  62. package/dist/{parse-CJtBvEYy-BCae0181.d.mts → parse-djL5wker-DYTP4HGq.d.mts} +7 -7
  63. package/dist/{parse-CJtBvEYy-BCae0181.d.mts.map → parse-djL5wker-DYTP4HGq.d.mts.map} +1 -1
  64. package/dist/{psl-ast-BIJIW24G-B8ptjyuO.d.mts → psl-ast-B6X_rlhZ-DCrq7Zie.d.mts} +3 -3
  65. package/dist/{psl-ast-BIJIW24G-B8ptjyuO.d.mts.map → psl-ast-B6X_rlhZ-DCrq7Zie.d.mts.map} +1 -1
  66. package/dist/psl-ast-DlmFfwfZ.d.mts +2 -0
  67. package/dist/psl-parser.d.mts +22 -11
  68. package/dist/psl-parser.d.mts.map +1 -1
  69. package/dist/psl-parser.mjs +14 -110
  70. package/dist/psl-parser.mjs.map +1 -1
  71. package/dist/psl-parser__format.d.mts +1 -1
  72. package/dist/psl-parser__format.mjs +3 -3
  73. package/dist/psl-parser__format.mjs.map +1 -1
  74. package/dist/psl-parser__interpret.d.mts +16 -13
  75. package/dist/psl-parser__interpret.d.mts.map +1 -1
  76. package/dist/psl-parser__interpret.mjs +52 -48
  77. package/dist/psl-parser__interpret.mjs.map +1 -1
  78. package/dist/psl-parser__syntax.d.mts +1 -1
  79. package/dist/psl-parser__syntax.mjs +3 -3
  80. package/dist/psl-printer.d.mts +4 -4
  81. package/dist/psl-printer.mjs +1 -1
  82. package/dist/read-expression-as-Dhyvx51C-Bpn_1X05.mjs +239 -0
  83. package/dist/read-expression-as-Dhyvx51C-Bpn_1X05.mjs.map +1 -0
  84. package/dist/{temporal-presets-Cumws2z--DcYWooYJ.d.mts → temporal-presets-D_TQBbXU-DLIsE1k-.d.mts} +42 -4
  85. package/dist/temporal-presets-D_TQBbXU-DLIsE1k-.d.mts.map +1 -0
  86. package/dist/{temporal-presets-BcDyr_hK-CFplJNGz.mjs → temporal-presets-DmZDnaZV-aUZPt1LX.mjs} +189 -22
  87. package/dist/temporal-presets-DmZDnaZV-aUZPt1LX.mjs.map +1 -0
  88. package/package.json +15 -15
  89. package/dist/ast-helpers-CzydMPdh-Mi0SrZRa.mjs +0 -424
  90. package/dist/ast-helpers-CzydMPdh-Mi0SrZRa.mjs.map +0 -1
  91. package/dist/authoring-so3aBYD8.mjs.map +0 -1
  92. package/dist/binder-WS9-1Mu9-MJi8x3Gm.d.mts.map +0 -1
  93. package/dist/control-AlBtrJUn.mjs.map +0 -1
  94. package/dist/control-CIEbQ0bK.d.mts +0 -1
  95. package/dist/declarations-DuSbyF44-D-Q7-GRi.mjs +0 -930
  96. package/dist/declarations-DuSbyF44-D-Q7-GRi.mjs.map +0 -1
  97. package/dist/framework-authoring-hZgq-M2K-Daz3kgWL.d.mts.map +0 -1
  98. package/dist/psl-ast-rf0UoVty.d.mts +0 -2
  99. package/dist/resolve-C8PUf8zv-QAvnPhCt.mjs +0 -146
  100. package/dist/resolve-C8PUf8zv-QAvnPhCt.mjs.map +0 -1
  101. package/dist/temporal-presets-BcDyr_hK-CFplJNGz.mjs.map +0 -1
  102. package/dist/temporal-presets-Cumws2z--DcYWooYJ.d.mts.map +0 -1
@@ -0,0 +1,895 @@
1
+ import { P as resolvePslBacktickEscapes, l as canonicalizeTaggedLiteralBody } from "./temporal-presets-DmZDnaZV-aUZPt1LX.mjs";
2
+ import { r as isTerminatedStringLiteral } from "./tokenizer-C-GTKKjR-B1vOzJy0.mjs";
3
+ //#region ../../../1-framework/2-authoring/psl-parser/dist/expressions-CMQzbnHk.mjs
4
+ /**
5
+ * A token in the red tree. Unlike the green-layer {@link Token} (kind + text
6
+ * only), a red token also carries its absolute `offset` within the source and a
7
+ * link back to its `parent` {@link SyntaxNode}, so a cursor anchored on a token
8
+ * can walk outward (parent, previous/next token, siblings) without re-scanning
9
+ * from the document root.
10
+ */
11
+ var SyntaxToken = class {
12
+ green;
13
+ kind;
14
+ text;
15
+ offset;
16
+ parent;
17
+ /** Position within the parent's children, enabling O(1) sibling navigation without rescanning the green layer. */
18
+ index;
19
+ constructor(green, offset, parent, index) {
20
+ this.green = green;
21
+ this.kind = green.kind;
22
+ this.text = green.text;
23
+ this.offset = offset;
24
+ this.parent = parent;
25
+ this.index = index;
26
+ }
27
+ get textLength() {
28
+ return this.text.length;
29
+ }
30
+ get endOffset() {
31
+ return this.offset + this.textLength;
32
+ }
33
+ /** Whether `offset` falls within this token, inclusive of both ends. */
34
+ isInside(offset) {
35
+ return offset >= this.offset && offset <= this.endOffset;
36
+ }
37
+ isOutside(offset) {
38
+ return !this.isInside(offset);
39
+ }
40
+ /** The sibling element immediately after this token within its parent. */
41
+ get nextSiblingOrToken() {
42
+ return this.parent.childAt(this.index + 1);
43
+ }
44
+ /** The sibling element immediately before this token within its parent. */
45
+ get prevSiblingOrToken() {
46
+ return this.parent.childAt(this.index - 1);
47
+ }
48
+ /** The next token in document order, crossing node boundaries. */
49
+ get nextToken() {
50
+ for (let el = climbingNext(this); el !== void 0; el = climbingNext(el)) {
51
+ const token = firstToken(el);
52
+ if (token !== void 0) return token;
53
+ }
54
+ }
55
+ /** The previous token in document order, crossing node boundaries. */
56
+ get prevToken() {
57
+ for (let el = climbingPrev(this); el !== void 0; el = climbingPrev(el)) {
58
+ const token = lastToken(el);
59
+ if (token !== void 0) return token;
60
+ }
61
+ }
62
+ };
63
+ var TokenAtOffset = class TokenAtOffset {
64
+ #state;
65
+ constructor(state) {
66
+ this.#state = state;
67
+ }
68
+ static none() {
69
+ return new TokenAtOffset({ kind: "none" });
70
+ }
71
+ static single(token) {
72
+ return new TokenAtOffset({
73
+ kind: "single",
74
+ token
75
+ });
76
+ }
77
+ static between(left, right) {
78
+ return new TokenAtOffset({
79
+ kind: "between",
80
+ left,
81
+ right
82
+ });
83
+ }
84
+ get isEmpty() {
85
+ return this.#state.kind === "none";
86
+ }
87
+ get isBetween() {
88
+ return this.#state.kind === "between";
89
+ }
90
+ leftBiased() {
91
+ switch (this.#state.kind) {
92
+ case "none": return;
93
+ case "single": return this.#state.token;
94
+ case "between": return this.#state.left;
95
+ }
96
+ }
97
+ rightBiased() {
98
+ switch (this.#state.kind) {
99
+ case "none": return;
100
+ case "single": return this.#state.token;
101
+ case "between": return this.#state.right;
102
+ }
103
+ }
104
+ };
105
+ var SyntaxNode = class SyntaxNode {
106
+ green;
107
+ offset;
108
+ parent;
109
+ /** Position within the parent's children, enabling O(1) sibling navigation without rescanning the green layer. */
110
+ index;
111
+ #childSlots;
112
+ #childOffsets;
113
+ constructor(green, offset, parent, index) {
114
+ this.green = green;
115
+ this.offset = offset;
116
+ this.parent = parent;
117
+ this.index = index;
118
+ }
119
+ #slots() {
120
+ let slots = this.#childSlots;
121
+ if (slots === void 0) {
122
+ slots = new Array(this.green.children.length).fill(void 0);
123
+ this.#childSlots = slots;
124
+ }
125
+ return slots;
126
+ }
127
+ #childOffset(index) {
128
+ let offsets = this.#childOffsets;
129
+ if (offsets === void 0) {
130
+ offsets = [];
131
+ this.#childOffsets = offsets;
132
+ }
133
+ for (let known = offsets.length; known <= index; known++) {
134
+ const previousOffset = offsets[known - 1];
135
+ const previousChild = this.green.children[known - 1];
136
+ offsets.push(previousOffset === void 0 || previousChild === void 0 ? this.offset : previousOffset + elementTextLength(previousChild));
137
+ }
138
+ return offsets[index] ?? this.offset;
139
+ }
140
+ childAt(index) {
141
+ const green = this.green.children[index];
142
+ if (green === void 0) return void 0;
143
+ const slots = this.#slots();
144
+ const cached = slots[index];
145
+ if (cached !== void 0) return cached;
146
+ const created = wrapElement(green, this.#childOffset(index), this, index);
147
+ slots[index] = created;
148
+ return created;
149
+ }
150
+ get kind() {
151
+ return this.green.kind;
152
+ }
153
+ get textLength() {
154
+ return this.green.textLength;
155
+ }
156
+ get endOffset() {
157
+ return this.offset + this.textLength;
158
+ }
159
+ /** Whether `offset` falls within this node, inclusive of both ends. */
160
+ isInside(offset) {
161
+ return offset >= this.offset && offset <= this.endOffset;
162
+ }
163
+ isOutside(offset) {
164
+ return !this.isInside(offset);
165
+ }
166
+ get firstChild() {
167
+ return this.childAt(0);
168
+ }
169
+ get lastChild() {
170
+ return this.childAt(this.green.children.length - 1);
171
+ }
172
+ get nextSibling() {
173
+ return this.parent?.childAt(this.index + 1);
174
+ }
175
+ get prevSibling() {
176
+ return this.parent?.childAt(this.index - 1);
177
+ }
178
+ /** The sibling element immediately after this node within its parent. */
179
+ get nextSiblingOrToken() {
180
+ return this.nextSibling;
181
+ }
182
+ /** The sibling element immediately before this node within its parent. */
183
+ get prevSiblingOrToken() {
184
+ return this.prevSibling;
185
+ }
186
+ /** The first token in this subtree (depth-first), or `undefined` if empty. */
187
+ get firstToken() {
188
+ return firstToken(this);
189
+ }
190
+ /** The last token in this subtree (depth-first), or `undefined` if empty. */
191
+ get lastToken() {
192
+ return lastToken(this);
193
+ }
194
+ *children() {
195
+ const count = this.green.children.length;
196
+ for (let index = 0; index < count; index++) {
197
+ const child = this.childAt(index);
198
+ if (child !== void 0) yield child;
199
+ }
200
+ }
201
+ *childNodes() {
202
+ for (const child of this.children()) if (child instanceof SyntaxNode) yield child;
203
+ }
204
+ root() {
205
+ let current = this;
206
+ for (const parent of this.ancestors()) current = parent;
207
+ return current;
208
+ }
209
+ *ancestors() {
210
+ let current = this.parent;
211
+ while (current) {
212
+ yield current;
213
+ current = current.parent;
214
+ }
215
+ }
216
+ /** The nearest match, testing this node itself before walking its ancestors. */
217
+ findAncestor(cast) {
218
+ const self = cast(this);
219
+ if (self !== void 0) return self;
220
+ for (const ancestor of this.ancestors()) {
221
+ const result = cast(ancestor);
222
+ if (result !== void 0) return result;
223
+ }
224
+ }
225
+ *descendants() {
226
+ const stack = [this];
227
+ for (let el = stack.pop(); el !== void 0; el = stack.pop()) {
228
+ yield el;
229
+ if (el instanceof SyntaxNode) {
230
+ const children = Array.from(el.children());
231
+ for (let i = children.length - 1; i >= 0; i--) {
232
+ const child = children[i];
233
+ if (child !== void 0) stack.push(child);
234
+ }
235
+ }
236
+ }
237
+ }
238
+ *tokens() {
239
+ for (const el of this.descendants()) if (el instanceof SyntaxToken) yield el;
240
+ }
241
+ /**
242
+ * The token(s) at `offset`. The between-two-tokens case (offset exactly on a
243
+ * token seam) is represented explicitly so callers can left/right bias.
244
+ */
245
+ tokenAtOffset(offset) {
246
+ return tokenAtOffsetOf(this, offset);
247
+ }
248
+ /**
249
+ * The smallest element fully containing the range `[start, end]`. At a seam
250
+ * (and for empty ranges) the left-hand element is preferred, matching
251
+ * {@link containsOffset}'s inclusive span.
252
+ */
253
+ coveringElement(start, end) {
254
+ let result = this;
255
+ for (;;) {
256
+ if (result instanceof SyntaxToken) return result;
257
+ let next;
258
+ for (const child of result.children()) if (containsRange(child, start, end)) {
259
+ next = child;
260
+ break;
261
+ }
262
+ if (next === void 0) return result;
263
+ result = next;
264
+ }
265
+ }
266
+ };
267
+ function elementTextLength(el) {
268
+ return el.type === "token" ? el.text.length : el.textLength;
269
+ }
270
+ function elementLength(el) {
271
+ return el instanceof SyntaxToken ? el.text.length : el.textLength;
272
+ }
273
+ /**
274
+ * Whether `el` contains `offset`. The span is inclusive on both ends so a seam
275
+ * offset touches both neighbours.
276
+ */
277
+ function containsOffset(el, offset) {
278
+ const start = el.offset;
279
+ const len = elementLength(el);
280
+ return offset >= start && offset <= start + len;
281
+ }
282
+ function containsRange(el, start, end) {
283
+ const elStart = el.offset;
284
+ const len = elementLength(el);
285
+ return elStart <= start && end <= elStart + len;
286
+ }
287
+ function tokenAtOffsetOf(el, offset) {
288
+ if (el instanceof SyntaxToken) return TokenAtOffset.single(el);
289
+ let left;
290
+ let right;
291
+ for (const child of el.children()) {
292
+ if (!containsOffset(child, offset)) continue;
293
+ if (left === void 0) left = child;
294
+ else {
295
+ right = child;
296
+ break;
297
+ }
298
+ }
299
+ if (left === void 0) return TokenAtOffset.none();
300
+ if (right === void 0) return tokenAtOffsetOf(left, offset);
301
+ const leftToken = tokenAtOffsetOf(left, offset).rightBiased();
302
+ const rightToken = tokenAtOffsetOf(right, offset).leftBiased();
303
+ if (leftToken !== void 0 && rightToken !== void 0) return TokenAtOffset.between(leftToken, rightToken);
304
+ if (leftToken !== void 0) return TokenAtOffset.single(leftToken);
305
+ if (rightToken !== void 0) return TokenAtOffset.single(rightToken);
306
+ return TokenAtOffset.none();
307
+ }
308
+ function firstToken(el) {
309
+ if (el instanceof SyntaxToken) return el;
310
+ for (const child of el.children()) {
311
+ const token = firstToken(child);
312
+ if (token !== void 0) return token;
313
+ }
314
+ }
315
+ function lastToken(el) {
316
+ if (el instanceof SyntaxToken) return el;
317
+ const children = Array.from(el.children());
318
+ for (let i = children.length - 1; i >= 0; i--) {
319
+ const child = children[i];
320
+ if (child !== void 0) {
321
+ const token = lastToken(child);
322
+ if (token !== void 0) return token;
323
+ }
324
+ }
325
+ }
326
+ function climbingNext(el) {
327
+ let current = el;
328
+ for (;;) {
329
+ const parent = current.parent;
330
+ if (parent === void 0) return void 0;
331
+ const sibling = parent.childAt(current.index + 1);
332
+ if (sibling !== void 0) return sibling;
333
+ current = parent;
334
+ }
335
+ }
336
+ function climbingPrev(el) {
337
+ let current = el;
338
+ for (;;) {
339
+ const parent = current.parent;
340
+ if (parent === void 0) return void 0;
341
+ const sibling = parent.childAt(current.index - 1);
342
+ if (sibling !== void 0) return sibling;
343
+ current = parent;
344
+ }
345
+ }
346
+ function wrapElement(green, offset, parent, index) {
347
+ if (green.type === "token") return new SyntaxToken(green, offset, parent, index);
348
+ return new SyntaxNode(green, offset, parent, index);
349
+ }
350
+ function createSyntaxTree(green) {
351
+ return new SyntaxNode(green, 0, void 0, 0);
352
+ }
353
+ /**
354
+ * Walks back through `node`'s preceding sibling tokens collecting a
355
+ * contiguous `///` run: only whitespace and single newlines may sit between
356
+ * consecutive `///` lines. Stops at a blank line, a non-`///` comment, or any
357
+ * other non-trivia element. Each line has its `///` marker and one following
358
+ * space stripped; the lines join with `\n`.
359
+ */
360
+ function readDocComment(node) {
361
+ const lines = [];
362
+ let current = node;
363
+ let newlinesSinceComment = 0;
364
+ for (;;) {
365
+ const sibling = current.prevSiblingOrToken;
366
+ if (!(sibling instanceof SyntaxToken)) break;
367
+ if (sibling.kind === "Whitespace") {
368
+ current = sibling;
369
+ continue;
370
+ }
371
+ if (sibling.kind === "Newline") {
372
+ newlinesSinceComment += 1;
373
+ if (newlinesSinceComment > 1) break;
374
+ current = sibling;
375
+ continue;
376
+ }
377
+ if (sibling.kind === "Comment" && sibling.text.startsWith("///")) {
378
+ lines.push(stripDocCommentMarker(sibling.text));
379
+ newlinesSinceComment = 0;
380
+ current = sibling;
381
+ continue;
382
+ }
383
+ break;
384
+ }
385
+ return lines.length === 0 ? void 0 : lines.reverse().join("\n");
386
+ }
387
+ function stripDocCommentMarker(text) {
388
+ const withoutMarker = text.slice(3);
389
+ return withoutMarker.startsWith(" ") ? withoutMarker.slice(1) : withoutMarker;
390
+ }
391
+ function findChildToken(node, kind) {
392
+ for (const child of node.children()) if (!(child instanceof SyntaxNode) && child.kind === kind) return child;
393
+ }
394
+ function findFirstChild(node, cast) {
395
+ for (const child of node.childNodes()) {
396
+ const result = cast(child);
397
+ if (result !== void 0) return result;
398
+ }
399
+ }
400
+ function* filterChildren(node, cast) {
401
+ for (const child of node.childNodes()) {
402
+ const result = cast(child);
403
+ if (result !== void 0) yield result;
404
+ }
405
+ }
406
+ function any(...casts) {
407
+ return (node) => {
408
+ for (const cast of casts) {
409
+ const result = cast(node);
410
+ if (result !== void 0) return result;
411
+ }
412
+ };
413
+ }
414
+ /**
415
+ * Raw source text of a CST node, verbatim (quotes and brackets preserved). For
416
+ * the decoded value of a string literal, decode it instead.
417
+ */
418
+ function printSyntax(node) {
419
+ let text = "";
420
+ for (const token of node.tokens()) text += token.text;
421
+ return text;
422
+ }
423
+ var IdentifierAst = class IdentifierAst {
424
+ syntax;
425
+ constructor(syntax) {
426
+ this.syntax = syntax;
427
+ }
428
+ token() {
429
+ return findChildToken(this.syntax, "Ident");
430
+ }
431
+ name() {
432
+ return this.token()?.text;
433
+ }
434
+ static cast(node) {
435
+ return node.kind === "Identifier" ? new IdentifierAst(node) : void 0;
436
+ }
437
+ };
438
+ /** A namespace-qualified name, e.g. `pgvector.Vector` or `supabase:auth.User`. */
439
+ var QualifiedNameAst = class QualifiedNameAst {
440
+ syntax;
441
+ constructor(syntax) {
442
+ this.syntax = syntax;
443
+ }
444
+ #segmentBefore(boundary) {
445
+ let found;
446
+ for (const segment of filterChildren(this.syntax, IdentifierAst.cast)) {
447
+ if (segment.syntax.offset >= boundary) break;
448
+ found = segment;
449
+ }
450
+ return found;
451
+ }
452
+ #segmentAfter(boundary) {
453
+ for (const segment of filterChildren(this.syntax, IdentifierAst.cast)) if (segment.syntax.offset > boundary) return segment;
454
+ }
455
+ #separatorCount(kind) {
456
+ let count = 0;
457
+ for (const child of this.syntax.children()) if (!(child instanceof SyntaxNode) && child.kind === kind) count++;
458
+ return count;
459
+ }
460
+ colon() {
461
+ return findChildToken(this.syntax, "Colon");
462
+ }
463
+ dot() {
464
+ return findChildToken(this.syntax, "Dot");
465
+ }
466
+ space() {
467
+ const colon = this.colon();
468
+ if (!colon) return void 0;
469
+ return this.#segmentBefore(colon.offset);
470
+ }
471
+ namespace() {
472
+ const dot = this.dot();
473
+ if (!dot) return void 0;
474
+ return this.#segmentBefore(dot.offset);
475
+ }
476
+ identifier() {
477
+ const dot = this.dot();
478
+ if (dot) return this.#segmentAfter(dot.offset);
479
+ const colon = this.colon();
480
+ if (colon) return this.#segmentAfter(colon.offset);
481
+ return findFirstChild(this.syntax, IdentifierAst.cast);
482
+ }
483
+ segments() {
484
+ return filterChildren(this.syntax, IdentifierAst.cast);
485
+ }
486
+ /**
487
+ * Every identifier segment, in source order. A bare `Vector` yields
488
+ * `['Vector']`; a qualified `pgvector.Vector` yields `['pgvector', 'Vector']`.
489
+ */
490
+ path() {
491
+ const segments = [];
492
+ for (const segment of this.segments()) {
493
+ const text = segment.token()?.text;
494
+ if (text !== void 0) segments.push(text);
495
+ }
496
+ return segments;
497
+ }
498
+ /** True iff this is a single unqualified identifier whose text equals `name`. */
499
+ isSimpleName(name) {
500
+ if (this.dot() !== void 0 || this.colon() !== void 0) return false;
501
+ return this.identifier()?.token()?.text === name;
502
+ }
503
+ /**
504
+ * Flags a malformed name with more qualifier segments than allowed (a second
505
+ * `:`-space or a second `.`-namespace).
506
+ */
507
+ isOverQualified() {
508
+ return this.#separatorCount("Dot") > 1 || this.#separatorCount("Colon") > 1;
509
+ }
510
+ static cast(node) {
511
+ return node.kind === "QualifiedName" ? new QualifiedNameAst(node) : void 0;
512
+ }
513
+ };
514
+ var FunctionCallAst = class FunctionCallAst {
515
+ syntax;
516
+ constructor(syntax) {
517
+ this.syntax = syntax;
518
+ }
519
+ /** The callee when it is a bare name, such as `now` in `now()`; `undefined` when the callee is dotted. */
520
+ name() {
521
+ return findFirstChild(this.syntax, QualifiedNameAst.cast);
522
+ }
523
+ /**
524
+ * The callee's segments, in source order. A bare `Vector(…)` yields
525
+ * `['Vector']`; `pgvector.Vector(…)` yields `['pgvector', 'Vector']`;
526
+ * `address.geo.lat(…)` yields `['address', 'geo', 'lat']`. Empty when the
527
+ * call carries no identifier.
528
+ */
529
+ path() {
530
+ return segmentNames((this.name() ?? this.memberPath())?.syntax ?? this.syntax);
531
+ }
532
+ /** The callee when it is dotted, such as `address.city` in `address.city(sort: Asc)`; `undefined` for a bare callee. */
533
+ memberPath() {
534
+ return findFirstChild(this.syntax, PathExprAst.cast);
535
+ }
536
+ lparen() {
537
+ return findChildToken(this.syntax, "LParen");
538
+ }
539
+ rparen() {
540
+ return findChildToken(this.syntax, "RParen");
541
+ }
542
+ *args() {
543
+ yield* filterChildren(this.syntax, AttributeArgAst.cast);
544
+ }
545
+ static cast(node) {
546
+ return node.kind === "FunctionCall" ? new FunctionCallAst(node) : void 0;
547
+ }
548
+ };
549
+ function segmentNames(node) {
550
+ const segments = [];
551
+ for (const segment of filterChildren(node, IdentifierAst.cast)) {
552
+ const text = segment.token()?.text;
553
+ if (text !== void 0) segments.push(text);
554
+ }
555
+ return segments;
556
+ }
557
+ /** A dotted member path in expression position, such as `address.city` in `@@index([address.city])`. */
558
+ var PathExprAst = class PathExprAst {
559
+ syntax;
560
+ constructor(syntax) {
561
+ this.syntax = syntax;
562
+ }
563
+ *segments() {
564
+ yield* filterChildren(this.syntax, IdentifierAst.cast);
565
+ }
566
+ /**
567
+ * The segment names, in source order: `['address', 'city']` for `address.city`. A path that ends
568
+ * in a `.` with no name after it, as in `address.`, ends in an empty name.
569
+ */
570
+ path() {
571
+ const segments = segmentNames(this.syntax);
572
+ return this.syntax.lastToken?.kind === "Dot" ? [...segments, ""] : segments;
573
+ }
574
+ static cast(node) {
575
+ return node.kind === "PathExpr" ? new PathExprAst(node) : void 0;
576
+ }
577
+ };
578
+ var ArrayLiteralAst = class ArrayLiteralAst {
579
+ syntax;
580
+ constructor(syntax) {
581
+ this.syntax = syntax;
582
+ }
583
+ lbracket() {
584
+ return findChildToken(this.syntax, "LBracket");
585
+ }
586
+ rbracket() {
587
+ return findChildToken(this.syntax, "RBracket");
588
+ }
589
+ *elements() {
590
+ yield* filterChildren(this.syntax, castExpression);
591
+ }
592
+ static cast(node) {
593
+ return node.kind === "ArrayLiteral" ? new ArrayLiteralAst(node) : void 0;
594
+ }
595
+ };
596
+ const HEX = /^[0-9a-fA-F]+$/;
597
+ function decodeFixedHex(raw, start, width) {
598
+ if (start + width > raw.length) return void 0;
599
+ const hex = raw.slice(start, start + width);
600
+ if (!HEX.test(hex)) return void 0;
601
+ return String.fromCharCode(Number.parseInt(hex, 16));
602
+ }
603
+ function decodeStringLiteral(raw) {
604
+ let out = "";
605
+ let i = 0;
606
+ while (i < raw.length) {
607
+ const ch = raw.charAt(i);
608
+ if (ch !== "\\" || i + 1 >= raw.length) {
609
+ out += ch;
610
+ i++;
611
+ continue;
612
+ }
613
+ const next = raw.charAt(i + 1);
614
+ switch (next) {
615
+ case "/":
616
+ out += "/";
617
+ i += 2;
618
+ continue;
619
+ case "b":
620
+ out += "\b";
621
+ i += 2;
622
+ continue;
623
+ case "f":
624
+ out += "\f";
625
+ i += 2;
626
+ continue;
627
+ case "n":
628
+ out += "\n";
629
+ i += 2;
630
+ continue;
631
+ case "r":
632
+ out += "\r";
633
+ i += 2;
634
+ continue;
635
+ case "t":
636
+ out += " ";
637
+ i += 2;
638
+ continue;
639
+ case "\"":
640
+ out += "\"";
641
+ i += 2;
642
+ continue;
643
+ case "'":
644
+ out += "'";
645
+ i += 2;
646
+ continue;
647
+ case "\\":
648
+ out += "\\";
649
+ i += 2;
650
+ continue;
651
+ case "x": {
652
+ const decoded = decodeFixedHex(raw, i + 2, 2);
653
+ if (decoded === void 0) {
654
+ out += "\\x";
655
+ i += 2;
656
+ continue;
657
+ }
658
+ out += decoded;
659
+ i += 4;
660
+ continue;
661
+ }
662
+ case "u": {
663
+ const decoded = decodeFixedHex(raw, i + 2, 4);
664
+ if (decoded === void 0) {
665
+ out += "\\u";
666
+ i += 2;
667
+ continue;
668
+ }
669
+ out += decoded;
670
+ i += 6;
671
+ continue;
672
+ }
673
+ default:
674
+ out += `\\${next}`;
675
+ i += 2;
676
+ continue;
677
+ }
678
+ }
679
+ return out;
680
+ }
681
+ var StringLiteralExprAst = class StringLiteralExprAst {
682
+ syntax;
683
+ constructor(syntax) {
684
+ this.syntax = syntax;
685
+ }
686
+ token() {
687
+ return findChildToken(this.syntax, "StringLiteral");
688
+ }
689
+ quote() {
690
+ const quote = this.token()?.text.charAt(0);
691
+ return quote === "\"" || quote === "'" || quote === "`" ? quote : void 0;
692
+ }
693
+ /**
694
+ * The decoded string. A `"` or `'` string resolves the usual escapes; a backtick string resolves
695
+ * only `` \` `` and `\\`, keeping every other backslash sequence as written.
696
+ */
697
+ value() {
698
+ const tok = this.token();
699
+ if (!tok) return void 0;
700
+ const raw = isTerminatedStringLiteral(tok.text) ? tok.text.slice(1, -1) : tok.text.slice(1);
701
+ return this.quote() === "`" ? resolvePslBacktickEscapes(raw) : decodeStringLiteral(raw);
702
+ }
703
+ static cast(node) {
704
+ return node.kind === "StringLiteralExpr" ? new StringLiteralExprAst(node) : void 0;
705
+ }
706
+ };
707
+ /** `` tag`body` ``, `tag"body"`, or `tag'body'`: a qualified-name tag followed by a string literal. */
708
+ var TaggedLiteralExprAst = class TaggedLiteralExprAst {
709
+ syntax;
710
+ constructor(syntax) {
711
+ this.syntax = syntax;
712
+ }
713
+ tag() {
714
+ return findFirstChild(this.syntax, QualifiedNameAst.cast);
715
+ }
716
+ /** The tag without trivia, e.g. `postgis.geometry`. */
717
+ tagName() {
718
+ const tag = this.tag();
719
+ const space = tag?.space()?.name();
720
+ const namespace = tag?.namespace()?.name();
721
+ return (space === void 0 ? "" : `${space}:`) + (namespace === void 0 ? "" : `${namespace}.`) + (tag?.identifier()?.name() ?? "");
722
+ }
723
+ literal() {
724
+ return findFirstChild(this.syntax, StringLiteralExprAst.cast);
725
+ }
726
+ canonicalization() {
727
+ return canonicalizeTaggedLiteralBody(this.literal()?.value() ?? "");
728
+ }
729
+ /** The canonical text shared with the TypeScript `sql` tag, or `undefined` when canonicalization fails. */
730
+ text() {
731
+ const result = this.canonicalization();
732
+ return result.ok ? result.text : void 0;
733
+ }
734
+ static cast(node) {
735
+ return node.kind === "TaggedLiteral" ? new TaggedLiteralExprAst(node) : void 0;
736
+ }
737
+ };
738
+ var NumberLiteralExprAst = class NumberLiteralExprAst {
739
+ syntax;
740
+ constructor(syntax) {
741
+ this.syntax = syntax;
742
+ }
743
+ token() {
744
+ return findChildToken(this.syntax, "NumberLiteral");
745
+ }
746
+ value() {
747
+ const tok = this.token();
748
+ if (!tok) return void 0;
749
+ return Number(tok.text);
750
+ }
751
+ static cast(node) {
752
+ return node.kind === "NumberLiteralExpr" ? new NumberLiteralExprAst(node) : void 0;
753
+ }
754
+ };
755
+ var BooleanLiteralExprAst = class BooleanLiteralExprAst {
756
+ syntax;
757
+ constructor(syntax) {
758
+ this.syntax = syntax;
759
+ }
760
+ token() {
761
+ return findChildToken(this.syntax, "Ident");
762
+ }
763
+ value() {
764
+ const tok = this.token();
765
+ if (!tok) return void 0;
766
+ if (tok.text === "true") return true;
767
+ if (tok.text === "false") return false;
768
+ }
769
+ static cast(node) {
770
+ return node.kind === "BooleanLiteralExpr" ? new BooleanLiteralExprAst(node) : void 0;
771
+ }
772
+ };
773
+ var ObjectLiteralExprAst = class ObjectLiteralExprAst {
774
+ syntax;
775
+ constructor(syntax) {
776
+ this.syntax = syntax;
777
+ }
778
+ lbrace() {
779
+ return findChildToken(this.syntax, "LBrace");
780
+ }
781
+ rbrace() {
782
+ return findChildToken(this.syntax, "RBrace");
783
+ }
784
+ *fields() {
785
+ yield* filterChildren(this.syntax, ObjectFieldAst.cast);
786
+ }
787
+ static cast(node) {
788
+ return node.kind === "ObjectLiteralExpr" ? new ObjectLiteralExprAst(node) : void 0;
789
+ }
790
+ };
791
+ var ObjectFieldAst = class ObjectFieldAst {
792
+ syntax;
793
+ constructor(syntax) {
794
+ this.syntax = syntax;
795
+ }
796
+ key() {
797
+ for (const child of this.syntax.children()) {
798
+ if (!(child instanceof SyntaxNode)) {
799
+ if (child.kind === "Colon") break;
800
+ continue;
801
+ }
802
+ return IdentifierAst.cast(child);
803
+ }
804
+ }
805
+ /**
806
+ * The field's logical key name, unquoted. An identifier key (`length:`) yields
807
+ * its text; a string-literal key (`"length":`) yields the decoded string.
808
+ * `undefined` when the field carries no key node.
809
+ */
810
+ keyName() {
811
+ for (const child of this.syntax.children()) {
812
+ if (!(child instanceof SyntaxNode)) {
813
+ if (child.kind === "Colon") break;
814
+ continue;
815
+ }
816
+ const identifier = IdentifierAst.cast(child);
817
+ if (identifier) return identifier.token()?.text;
818
+ const stringKey = StringLiteralExprAst.cast(child);
819
+ if (stringKey) return stringKey.value();
820
+ return;
821
+ }
822
+ }
823
+ colon() {
824
+ return findChildToken(this.syntax, "Colon");
825
+ }
826
+ value() {
827
+ if (this.colon()) {
828
+ let pastColon = false;
829
+ for (const child of this.syntax.children()) {
830
+ if (!(child instanceof SyntaxNode)) {
831
+ if (child.kind === "Colon") pastColon = true;
832
+ continue;
833
+ }
834
+ if (pastColon) {
835
+ const expr = castExpression(child);
836
+ if (expr) return expr;
837
+ }
838
+ }
839
+ return;
840
+ }
841
+ return findFirstChild(this.syntax, castExpression);
842
+ }
843
+ static cast(node) {
844
+ return node.kind === "ObjectField" ? new ObjectFieldAst(node) : void 0;
845
+ }
846
+ };
847
+ /** Every dotted path in an expression: the expression itself, a dotted callee, or a path inside a list, record or call argument. */
848
+ function dottedPathsIn(expression) {
849
+ const paths = [];
850
+ for (const element of expression.syntax.descendants()) {
851
+ const path = element instanceof SyntaxNode ? PathExprAst.cast(element) : void 0;
852
+ if (path !== void 0) paths.push(path);
853
+ }
854
+ return paths;
855
+ }
856
+ function castExpression(node) {
857
+ return FunctionCallAst.cast(node) ?? ArrayLiteralAst.cast(node) ?? StringLiteralExprAst.cast(node) ?? TaggedLiteralExprAst.cast(node) ?? NumberLiteralExprAst.cast(node) ?? BooleanLiteralExprAst.cast(node) ?? ObjectLiteralExprAst.cast(node) ?? PathExprAst.cast(node) ?? IdentifierAst.cast(node);
858
+ }
859
+ var AttributeArgAst = class AttributeArgAst {
860
+ syntax;
861
+ constructor(syntax) {
862
+ this.syntax = syntax;
863
+ }
864
+ name() {
865
+ if (!this.colon()) return void 0;
866
+ return findFirstChild(this.syntax, IdentifierAst.cast);
867
+ }
868
+ colon() {
869
+ return findChildToken(this.syntax, "Colon");
870
+ }
871
+ value() {
872
+ if (this.colon()) {
873
+ let pastColon = false;
874
+ for (const child of this.syntax.children()) {
875
+ if (!(child instanceof SyntaxNode)) {
876
+ if (child.kind === "Colon") pastColon = true;
877
+ continue;
878
+ }
879
+ if (pastColon) {
880
+ const expr = castExpression(child);
881
+ if (expr) return expr;
882
+ }
883
+ }
884
+ return;
885
+ }
886
+ return findFirstChild(this.syntax, castExpression);
887
+ }
888
+ static cast(node) {
889
+ return node.kind === "AttributeArg" ? new AttributeArgAst(node) : void 0;
890
+ }
891
+ };
892
+ //#endregion
893
+ export { printSyntax as C, findFirstChild as S, castExpression as _, IdentifierAst as a, filterChildren as b, ObjectLiteralExprAst as c, StringLiteralExprAst as d, SyntaxNode as f, any as g, TokenAtOffset as h, FunctionCallAst as i, PathExprAst as l, TaggedLiteralExprAst as m, AttributeArgAst as n, NumberLiteralExprAst as o, SyntaxToken as p, BooleanLiteralExprAst as r, ObjectFieldAst as s, ArrayLiteralAst as t, QualifiedNameAst as u, createSyntaxTree as v, readDocComment as w, findChildToken as x, dottedPathsIn as y };
894
+
895
+ //# sourceMappingURL=expressions-CMQzbnHk-fqYn-D3z.mjs.map