@omgbase/oqx 0.20.0 → 0.23.0

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 (55) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/README.md +65 -0
  3. package/dist/ast.d.ts +20 -2
  4. package/dist/ast.d.ts.map +1 -1
  5. package/dist/ast.js +11 -1
  6. package/dist/ast.js.map +1 -1
  7. package/dist/build.d.ts +4 -1
  8. package/dist/build.d.ts.map +1 -1
  9. package/dist/build.js +3 -0
  10. package/dist/build.js.map +1 -1
  11. package/dist/engine.d.ts +1 -0
  12. package/dist/engine.d.ts.map +1 -1
  13. package/dist/engine.js +45 -3
  14. package/dist/engine.js.map +1 -1
  15. package/dist/index.d.ts +3 -1
  16. package/dist/index.d.ts.map +1 -1
  17. package/dist/index.js +2 -1
  18. package/dist/index.js.map +1 -1
  19. package/dist/lexer.d.ts +3 -3
  20. package/dist/lexer.d.ts.map +1 -1
  21. package/dist/lexer.js +92 -5
  22. package/dist/lexer.js.map +1 -1
  23. package/dist/optimize/analysis.d.ts.map +1 -1
  24. package/dist/optimize/analysis.js +8 -1
  25. package/dist/optimize/analysis.js.map +1 -1
  26. package/dist/parser.d.ts.map +1 -1
  27. package/dist/parser.js +58 -5
  28. package/dist/parser.js.map +1 -1
  29. package/dist/print.js +36 -17
  30. package/dist/print.js.map +1 -1
  31. package/dist/references.d.ts +26 -0
  32. package/dist/references.d.ts.map +1 -0
  33. package/dist/references.js +225 -0
  34. package/dist/references.js.map +1 -0
  35. package/dist/resolve.d.ts.map +1 -1
  36. package/dist/resolve.js +4 -0
  37. package/dist/resolve.js.map +1 -1
  38. package/dist/version.d.ts +1 -1
  39. package/dist/version.js +1 -1
  40. package/dist/walk.d.ts.map +1 -1
  41. package/dist/walk.js +8 -3
  42. package/dist/walk.js.map +1 -1
  43. package/package.json +1 -1
  44. package/src/ast.ts +31 -3
  45. package/src/build.ts +4 -1
  46. package/src/engine.ts +40 -3
  47. package/src/index.ts +3 -1
  48. package/src/lexer.ts +86 -10
  49. package/src/optimize/analysis.ts +9 -1
  50. package/src/parser.ts +51 -6
  51. package/src/print.ts +34 -7
  52. package/src/references.ts +238 -0
  53. package/src/resolve.ts +4 -0
  54. package/src/version.ts +1 -1
  55. package/src/walk.ts +7 -3
package/src/walk.ts CHANGED
@@ -97,9 +97,13 @@ export const CHILDREN: { readonly [K in AstKind]: readonly ChildKey[] } = {
97
97
  in: [{ key: "left" }, { key: "right" }],
98
98
  range: [{ key: "lo" }, { key: "hi" }],
99
99
  tuple: [{ key: "items" }],
100
+ // The interpolations; the text parts between them are strings, not nodes.
101
+ template: [{ key: "parts" }],
100
102
  };
101
103
 
102
- type Slot = AstNode | AstNode[] | null;
104
+ /** A child slot's value: a node, a list of nodes (a template's `parts` also
105
+ * holds its text strings, which the walks skip), or `null`. */
106
+ type Slot = AstNode | (AstNode | string)[] | null;
103
107
 
104
108
  function slot(node: AstNode, key: string): Slot {
105
109
  return (node as unknown as Record<string, Slot>)[key] ?? null;
@@ -134,7 +138,7 @@ export function visit(root: AstNode, visitor: Visitor): void {
134
138
  if (v === null) continue;
135
139
  const c = child.clause ?? clause;
136
140
  const d = depth + childDepth(node, child, path);
137
- if (Array.isArray(v)) for (const x of v) go(x, c, d);
141
+ if (Array.isArray(v)) { for (const x of v) if (typeof x !== "string") go(x, c, d); }
138
142
  else go(v, c, d);
139
143
  }
140
144
  path.pop();
@@ -162,7 +166,7 @@ export function transform<T extends Query | Subquery>(root: T, f: (expr: Expr, c
162
166
  let next: Slot;
163
167
  if (Array.isArray(v)) {
164
168
  let changed = false;
165
- const mapped = v.map((x) => { const y = go(x, c, d); if (y !== x) changed = true; return y; });
169
+ const mapped = v.map((x) => { if (typeof x === "string") return x; const y = go(x, c, d); if (y !== x) changed = true; return y; });
166
170
  next = changed ? mapped : v;
167
171
  } else next = go(v, c, d);
168
172
  if (next !== v) out = { ...out, [child.key]: next } as AstNode;