@nongt/visql 0.3.1 → 0.4.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.
@@ -3,7 +3,7 @@ import { createContext as _e, useContext as qe, useMemo as be, useState as Ie, u
3
3
  import te from "clsx";
4
4
  import { NavArrowDownSolid as xt, Trash as ct, Plus as Pn, DatabaseScript as io, EditPencil as Oc, Xmark as ao, Expand as Ln, NavArrowUpSolid as St, NetworkLeft as lo, MinusSquare as is, PlusCircleSolid as Mt, CheckSquareSolid as Na, Square as Ia, WarningTriangle as co, KeyframesPlus as qc, Collapse as Dc, MinusSquareDashed as Lc, Search as Fc, XmarkCircleSolid as Sa, Play as Rc } from "iconoir-react";
5
5
  import { Position as xe, Handle as ve, useReactFlow as gr, useStore as di, useUpdateNodeInternals as uo, useStoreApi as Pc, useInternalNode as Mc, ViewportPortal as _c, useNodesState as Ca, useEdgesState as Ta, applyNodeChanges as Ea, ReactFlow as ka, Controls as Ba, Background as Aa, ReactFlowProvider as Oa } from "@xyflow/react";
6
- import { L as $c, N as ht, O as Us, P as qa, R as Da, T as La, U as Fa, V as as, D as Ra, W as jc, X as Uc, Y as zc, Z as Gc, _ as Hc, $ as Qc, a0 as ui, a1 as Vc, a2 as Wc, a3 as Yc, a4 as Kc, b as Jc, a as ho, a5 as Xc, a6 as Zc, M as ed, a7 as Pa, a8 as Ma, H as hi, a9 as Dr, aa as fi, ab as td, ac as nd, ad as rd, ae as sd, K as _a, af as od, c as Ts, ag as id, J as ad, ah as rt, ai as ld, aj as rr, ak as cd, al as pi, am as dd, an as ud, ao as hd, ap as mi, aq as gi, A as fd, z as pd, p as md, ar as $a, n as gd, m as yd, as as yi, at as bd, au as bi, e as xi, s as xd, f as vd, l as wd, j as vi, h as Nd, u as Id, r as Sd, g as Cd, w as Td, x as Ed, v as kd, t as Bd, av as wi, aw as Es, ax as ks, ay as Ni, az as Ad, q as Od, d as qd } from "./issueLocation-Cw5sttQL.js";
6
+ import { L as $c, N as ht, O as Us, P as qa, R as Da, T as La, U as Fa, V as as, D as Ra, W as jc, X as Uc, Y as zc, Z as Gc, _ as Hc, $ as Qc, a0 as ui, a1 as Vc, a2 as Wc, a3 as Yc, a4 as Kc, b as Jc, a as ho, a5 as Xc, a6 as Zc, M as ed, a7 as Pa, a8 as Ma, H as hi, a9 as Dr, aa as fi, ab as td, ac as nd, ad as rd, ae as sd, K as _a, af as od, c as Ts, ag as id, J as ad, ah as rt, ai as ld, aj as rr, ak as cd, al as pi, am as dd, an as ud, ao as hd, ap as mi, aq as gi, A as fd, z as pd, p as md, ar as $a, n as gd, m as yd, as as yi, at as bd, au as bi, e as xi, s as xd, f as vd, l as wd, j as vi, h as Nd, u as Id, r as Sd, g as Cd, w as Td, x as Ed, v as kd, t as Bd, av as wi, aw as Es, ax as ks, ay as Ni, az as Ad, q as Od, d as qd } from "./issueLocation-CWUdTtCh.js";
7
7
  import { t as Dd, d as ja, a as Ld, s as Ua, i as za, b as Fd } from "./calendarDate-CYlr9TvX.js";
8
8
  import { t as qn, R as Ga, a as Rd, D as Ii, r as Pd, d as Md } from "./tokens-BTaVMSOx.js";
9
9
  import { D as Mn, J as Gt, P as ls, t as Nt, k as Ve, y as Ha, E as Qa, a as _d, R as $d, S as jd, d as Jt, A as lr, T as Ud, M as yr, p as Va, U as Wa, q as jr, i as zs, l as zd, V as Ya, e as Ka, j as Gd, r as Hd, f as Qd, L as Vd, v as Wd, W as Si, X as Yd, u as Kd, b as Jd, h as Ja } from "./schema-z95dxLxu.js";
@@ -1,68 +1,117 @@
1
- var Et = Object.defineProperty;
2
- var Tt = (t, e, r) => e in t ? Et(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
3
- var b = (t, e, r) => Tt(t, typeof e != "symbol" ? e + "" : e, r);
4
- import { B as x, q as d, F as yt, g as F, d as H, t as Q, h as pt, w as k, o as X, H as At, k as mt, b as gt, i as Dt } from "./schema-z95dxLxu.js";
5
- import { ag as D, aA as V, aB as Nt, aC as Ot, aD as ht, aj as Rt, V as St, ap as It, aE as y, al as bt, a7 as Ct, aF as Lt, aG as W, $ as Mt } from "./issueLocation-Cw5sttQL.js";
6
- import { s as J } from "./calendarDate-CYlr9TvX.js";
7
- class wt extends Error {
8
- constructor(r, n, s) {
9
- super(`scopeQuery: the query at ${r.length ? r.join(".") : "the top"} reads "${n}" but can't reach "${s}", which the condition names`);
1
+ var At = Object.defineProperty;
2
+ var mt = (t, e, r) => e in t ? At(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
3
+ var I = (t, e, r) => mt(t, typeof e != "symbol" ? e + "" : e, r);
4
+ import { q as b, F as gt, G as ht, g as w, o as Y, d as x, t as W, h as Dt, w as J, H as Nt, k as Ot, b as St, i as Rt } from "./schema-z95dxLxu.js";
5
+ import { ag as N, aA as K, aB as bt, aC as It, aD as Ct, aj as Lt, V as Mt, ap as wt, aE as p, al as Ft, a7 as qt, aF as Ut, aG as z, $ as vt } from "./issueLocation-CWUdTtCh.js";
6
+ import { s as Z } from "./calendarDate-CYlr9TvX.js";
7
+ class dt extends Error {
8
+ constructor(r, n, s, i) {
9
+ const a = i ? `"${n}" (as "${i}")` : `"${n}"`;
10
+ super(`scopeQuery: the query at ${r.length ? r.join(".") : "the top"} reads ${a} but can't reach "${s}", which the condition names`);
10
11
  /** Where the body is, as keys into the query (validateQuery's
11
12
  * `pathSegments` style). */
12
- b(this, "path");
13
+ I(this, "path");
13
14
  /** The table it reads that needs scope. */
14
- b(this, "table");
15
- this.name = "ScopeError", this.path = r, this.table = n;
15
+ I(this, "table");
16
+ /** The alias that copy of the table goes by, when it has one (a self
17
+ * join reads a table more than once, issue 216). */
18
+ I(this, "alias");
19
+ this.name = "ScopeError", this.path = r, this.table = n, i && (this.alias = i);
16
20
  }
17
21
  }
18
- const K = (t) => Object.prototype.toString.call(t) === "[object Object]", Ft = (t) => Array.isArray(t.joins) && K(t.from);
19
- function C(t, e, r) {
22
+ const P = (t) => Object.prototype.toString.call(t) === "[object Object]", Bt = (t) => Array.isArray(t.joins) && P(t.from);
23
+ function F(t, e, r) {
20
24
  if (Array.isArray(t)) {
21
- const a = t.map((o, f) => C(o, [...e, f], r));
25
+ const a = t.map((o, f) => F(o, [...e, f], r));
22
26
  return a.every((o, f) => o === t[f]) ? t : a;
23
27
  }
24
- if (!K(t)) return t;
28
+ if (!P(t)) return t;
25
29
  let n = !1;
26
30
  const s = Object.entries(t).map(([a, o]) => {
27
- const f = C(o, [...e, a], r);
31
+ const f = F(o, [...e, a], r);
28
32
  return f !== o && (n = !0), [a, f];
29
33
  }), i = n ? Object.fromEntries(s) : t;
30
- return Ft(i) ? r(i, e) : i;
31
- }
32
- const z = (t, e) => x(t).find(e.requires);
33
- function Z(t, e) {
34
- return t ? F(t, e) ? !0 : t.type === "logical" && t.operator === "AND" && t.operands.some((r) => F(r, e)) : !1;
35
- }
36
- function j(t, e, r, n) {
37
- const s = z(e, r);
38
- if (!s || Z(e.where, r.condition)) return e;
39
- const i = e, a = x(i), o = d(i).flatMap(($) => $.alias ? [$.alias] : []), f = V(r.condition).find(($) => !o.includes($) && yt(t, a, $) === void 0);
40
- if (f) throw new wt(n, s, f);
41
- const { joins: u } = Nt(
42
- t,
43
- {
44
- id: "",
45
- from: e.from,
46
- joins: e.joins,
47
- select: []
48
- },
49
- r.condition
50
- ), { where: c } = e;
51
- let l = r.condition;
52
- return (c == null ? void 0 : c.type) === "logical" && c.operator === "AND" ? l = { ...c, operands: [...c.operands, r.condition] } : c && (l = { type: "logical", operator: "AND", operands: [c, r.condition] }), { ...e, joins: u, where: l };
34
+ return Bt(i) ? r(i, e) : i;
53
35
  }
54
- function le(t, e, r) {
55
- const n = j(t, e, r, []), s = D(t, e, n), i = C(s, [], (a, o) => o.length === 0 ? a : j(t, a, r, o));
56
- return D(t, s, i);
36
+ const tt = (t, e) => b(t).flatMap((r) => r.table !== void 0 && e.requires(r.table) ? [{ table: r.table, ...r.alias ? { alias: r.alias } : {}, ref: r.alias ?? r.table }] : []), jt = (t) => b(t).flatMap((e) => {
37
+ const r = e.alias ?? e.table;
38
+ return r === void 0 ? [] : [r];
39
+ });
40
+ function d(t, e) {
41
+ if (t.type === "field") {
42
+ const r = t.table && e.get(t.table);
43
+ return r ? { ...t, table: r } : t;
44
+ }
45
+ return Y(t, (r) => d(r, e));
46
+ }
47
+ const et = (t) => t ? t.type === "logical" && t.operator === "AND" ? t.operands : [t] : [];
48
+ function _t(t, e) {
49
+ if (e.type !== "binary" || !e.left || !e.right) return !1;
50
+ const r = { ...e, left: e.right, right: e.left };
51
+ return t.joins.some((n) => et(n.on).some((s) => w(s, e) || w(s, r)));
52
+ }
53
+ function rt(t, e, r, n) {
54
+ const s = /* @__PURE__ */ new Map([[r.table, r.ref]]), i = [], a = new Set(jt(e)), o = b(e).flatMap((u) => u.alias ? [u.alias] : []);
55
+ let f;
56
+ return K(n.condition).forEach((u) => {
57
+ if (f || s.has(u) || o.includes(u)) return;
58
+ const c = gt(t, [...s.keys()], u);
59
+ if (!c) {
60
+ f = u;
61
+ return;
62
+ }
63
+ c.forEach((l) => {
64
+ const $ = ht(t, [...s.keys()], l);
65
+ if (!$) return;
66
+ const T = (m) => d($.on, new Map([...s, [l, m]])), A = b(e).flatMap((m) => m.table === l ? [m.alias ?? l] : []).find((m) => _t(e, T(m)));
67
+ if (A) {
68
+ s.set(l, A);
69
+ return;
70
+ }
71
+ let h = l;
72
+ for (let m = 2; a.has(h); m += 1) h = `${l}_${m}`;
73
+ a.add(h), s.set(l, h), i.push({
74
+ id: bt(),
75
+ table: l,
76
+ ...h !== l ? { alias: h } : {},
77
+ joinType: $.joinType,
78
+ on: T(h)
79
+ });
80
+ });
81
+ }), { joins: i, condition: d(n.condition, s), ...f ? { missing: f } : {} };
82
+ }
83
+ function nt(t, e) {
84
+ return et(t).some((r) => w(r, e));
85
+ }
86
+ function Ht(t, e) {
87
+ return (t == null ? void 0 : t.type) === "logical" && t.operator === "AND" ? { ...t, operands: [...t.operands, e] } : t ? { type: "logical", operator: "AND", operands: [t, e] } : e;
88
+ }
89
+ function Q(t, e, r, n) {
90
+ return tt(e, r).reduce((s, i) => {
91
+ const a = rt(t, s, i, r);
92
+ if (a.missing) throw new dt(n, i.table, a.missing, i.alias);
93
+ const o = nt(s.where, a.condition);
94
+ return a.joins.length === 0 && o ? s : {
95
+ ...s,
96
+ joins: [...s.joins, ...a.joins],
97
+ where: o ? s.where : Ht(s.where, a.condition)
98
+ };
99
+ }, e);
57
100
  }
58
- function $e(t, e) {
59
- const r = [];
60
- return C(t, [], (n, s) => {
61
- const i = z(n, e);
62
- return i && !Z(n.where, e.condition) && r.push({ path: s, table: i }), n;
63
- }), r;
101
+ function ge(t, e, r) {
102
+ const n = Q(t, e, r, []), s = N(t, e, n), i = F(s, [], (a, o) => o.length === 0 ? a : Q(t, a, r, o));
103
+ return N(t, s, i);
64
104
  }
65
- const qt = (t) => typeof t == "object" && t !== null && !(t instanceof Date), Y = {
105
+ function he(t, e, r) {
106
+ if (!P(t) || !Array.isArray(t.tables))
107
+ throw new TypeError("unscopedBodies takes (schema, query, rule) since 0.4.0");
108
+ const n = [];
109
+ return F(e, [], (s, i) => (tt(s, r).forEach((a) => {
110
+ const o = rt(t, s, a, r);
111
+ (o.missing || o.joins.length > 0 || !nt(s.where, o.condition)) && n.push({ path: i, table: a.table, ...a.alias ? { alias: a.alias } : {} });
112
+ }), s)), n;
113
+ }
114
+ const Yt = (t) => typeof t == "object" && t !== null && !(t instanceof Date), k = {
66
115
  /** A column: `expr.field('orders', 'status')`. */
67
116
  field: (t, e) => ({ type: "field", table: t, column: e }),
68
117
  /** A literal value, written into the SQL (as a bound parameter by
@@ -129,7 +178,7 @@ const qt = (t) => typeof t == "object" && t !== null && !(t instanceof Date), Y
129
178
  type: "binary",
130
179
  operator: "IN",
131
180
  left: t,
132
- right: Array.isArray(e) ? Y.list(...e) : e
181
+ right: Array.isArray(e) ? k.list(...e) : e
133
182
  }),
134
183
  /** `left BETWEEN low AND high` (issue 169), both bounds included: each a
135
184
  * value or an expression (a param, a relative date). NOT BETWEEN:
@@ -138,13 +187,13 @@ const qt = (t) => typeof t == "object" && t !== null && !(t instanceof Date), Y
138
187
  type: "binary",
139
188
  operator: "BETWEEN",
140
189
  left: t,
141
- right: Y.list(e, r)
190
+ right: k.list(e, r)
142
191
  }),
143
192
  /** IN's values: each a value (`expr.list(1, 2)`) or an expression
144
193
  * (`expr.list(expr.param('a'), expr.param('b'))`). */
145
194
  list: (...t) => ({
146
195
  type: "list",
147
- items: t.map((e) => qt(e) ? e : { type: "literal", value: e })
196
+ items: t.map((e) => Yt(e) ? e : { type: "literal", value: e })
148
197
  }),
149
198
  /** A query of its own for IN to compare with, selecting `select` — one
150
199
  * column. Its tables are its own: it sees nothing of the query around
@@ -153,91 +202,91 @@ const qt = (t) => typeof t == "object" && t !== null && !(t instanceof Date), Y
153
202
  * 'customer_id') }))`. */
154
203
  subquery: ({ select: t, ...e }) => ({
155
204
  type: "subquery",
156
- id: H(),
157
- query: { joins: [], ...e, select: [{ id: H(), expression: t }] }
205
+ id: x(),
206
+ query: { joins: [], ...e, select: [{ id: x(), expression: t }] }
158
207
  })
159
208
  };
160
- function Ee(t, e, r) {
161
- return y(t, e, { type: "setBaseTable", table: r });
209
+ function De(t, e, r) {
210
+ return p(t, e, { type: "setBaseTable", table: r });
162
211
  }
163
- function Te(t, e, r, n = {}) {
212
+ function Ne(t, e, r, n = {}) {
164
213
  const s = { type: "addJoin", table: r, ...n };
165
- return y(t, e, s);
214
+ return p(t, e, s);
166
215
  }
167
- function ye(t, e, r) {
168
- return y(t, e, { type: "removeJoin", joinId: r });
216
+ function Oe(t, e, r) {
217
+ return p(t, e, { type: "removeJoin", joinId: r });
169
218
  }
170
- function Ut(t, e, r, n = {}) {
171
- const s = Ot(e), i = V(r);
219
+ function Pt(t, e, r, n = {}) {
220
+ const s = It(e), i = K(r);
172
221
  if (s && i.some((u) => u !== s.alias)) {
173
222
  if (i.includes(s.alias))
174
223
  throw new Error("addCondition: a condition names both the union and tables of its branches: add it in two parts");
175
224
  return s.query.union.forEach((u) => {
176
- const c = u.from.table, l = new Set(d(u).map(Q)), $ = ht(t, c), p = i.find((A) => !l.has(A) && !$.has(A));
177
- if (p)
178
- throw new Error(`addCondition: "${p}" can't be reached from "${c}", one of the union's tables: a condition must reach every branch`);
179
- }), s.query.union.reduce((u, c, l) => Rt(
225
+ const c = u.from.table, l = new Set(b(u).map(W)), $ = Ct(t, c), T = i.find((A) => !l.has(A) && !$.has(A));
226
+ if (T)
227
+ throw new Error(`addCondition: "${T}" can't be reached from "${c}", one of the union's tables: a condition must reach every branch`);
228
+ }), s.query.union.reduce((u, c, l) => Lt(
180
229
  u,
181
- [St(s.id, l)],
182
- ($) => Ut(t, $, r, n)
230
+ [Mt(s.id, l)],
231
+ ($) => Pt(t, $, r, n)
183
232
  ), e);
184
233
  }
185
234
  const a = n.operator ?? "AND", { where: o } = e;
186
235
  let f;
187
- return o ? o.type === "logical" && o.operator === a ? f = { ...o, operands: [...o.operands, r] } : f = { type: "logical", operator: a, operands: [o, r] } : f = r, D(t, e, It(t, e, f));
236
+ return o ? o.type === "logical" && o.operator === a ? f = { ...o, operands: [...o.operands, r] } : f = { type: "logical", operator: a, operands: [o, r] } : f = r, N(t, e, wt(t, e, f));
188
237
  }
189
- function pe(t, e, r, n) {
190
- const s = y(t, e, { type: "addSelectItem" }), i = s.select[s.select.length - 1].id, a = y(t, s, {
238
+ function Se(t, e, r, n) {
239
+ const s = p(t, e, { type: "addSelectItem" }), i = s.select[s.select.length - 1].id, a = p(t, s, {
191
240
  type: "setSelectExpression",
192
241
  selectId: i,
193
242
  expression: r
194
- }), o = n === void 0 ? a : y(t, a, { type: "setSelectAlias", selectId: i, alias: n });
195
- return D(t, e, o);
243
+ }), o = n === void 0 ? a : p(t, a, { type: "setSelectAlias", selectId: i, alias: n });
244
+ return N(t, e, o);
196
245
  }
197
- function Ae(t, e, r) {
198
- const n = y(t, e, { type: "addGroupByItem" }), { id: s } = n.groupBy[n.groupBy.length - 1], i = y(t, n, {
246
+ function Re(t, e, r) {
247
+ const n = p(t, e, { type: "addGroupByItem" }), { id: s } = n.groupBy[n.groupBy.length - 1], i = p(t, n, {
199
248
  type: "setGroupByExpression",
200
249
  groupById: s,
201
250
  expression: r
202
251
  });
203
- return D(t, e, i);
252
+ return N(t, e, i);
204
253
  }
205
- function me(t, e, r) {
206
- return D(t, e, bt(t, e, r));
254
+ function be(t, e, r) {
255
+ return N(t, e, Ft(t, e, r));
207
256
  }
208
- function ge(t, e, r, n = "asc") {
209
- const s = y(t, e, { type: "addOrderByItem" }), { id: i } = s.orderBy[s.orderBy.length - 1], a = y(t, s, {
257
+ function Ie(t, e, r, n = "asc") {
258
+ const s = p(t, e, { type: "addOrderByItem" }), { id: i } = s.orderBy[s.orderBy.length - 1], a = p(t, s, {
210
259
  type: "setOrderByExpression",
211
260
  orderById: i,
212
261
  expression: r
213
- }), o = y(t, a, {
262
+ }), o = p(t, a, {
214
263
  type: "setOrderByDirection",
215
264
  orderById: i,
216
265
  direction: n
217
266
  });
218
- return D(t, e, o);
267
+ return N(t, e, o);
219
268
  }
220
- function De(t, e, r) {
269
+ function Ce(t, e, r) {
221
270
  let n = e;
222
- return "limit" in r && (n = y(t, n, { type: "setLimit", limit: r.limit })), "offset" in r && (n = y(t, n, { type: "setOffset", offset: r.offset })), n;
271
+ return "limit" in r && (n = p(t, n, { type: "setLimit", limit: r.limit })), "offset" in r && (n = p(t, n, { type: "setOffset", offset: r.offset })), n;
223
272
  }
224
- function Ne(t, e, r) {
225
- return y(t, e, { type: "setDistinct", distinct: r });
273
+ function Le(t, e, r) {
274
+ return p(t, e, { type: "setDistinct", distinct: r });
226
275
  }
227
- function Oe(t) {
228
- if (!pt(t)) throw new Error(`query "${t.id}" has no base table yet`);
276
+ function Me(t) {
277
+ if (!Dt(t)) throw new Error(`query "${t.id}" has no base table yet`);
229
278
  return t;
230
279
  }
231
- const q = 4;
232
- class h extends Error {
280
+ const B = 4;
281
+ class R extends Error {
233
282
  constructor(r, n) {
234
283
  super(n);
235
- b(this, "kind");
284
+ I(this, "kind");
236
285
  this.name = "QueryFormatError", this.kind = r;
237
286
  }
238
287
  }
239
- const I = (t) => typeof t == "object" && t !== null && !Array.isArray(t);
240
- function vt(t) {
288
+ const M = (t) => typeof t == "object" && t !== null && !Array.isArray(t);
289
+ function Gt(t) {
241
290
  const e = [];
242
291
  let r = 0;
243
292
  for (; r < t.length; ) {
@@ -256,65 +305,65 @@ function vt(t) {
256
305
  }
257
306
  return e;
258
307
  }
259
- function Bt(t) {
308
+ function xt(t) {
260
309
  const e = (r) => {
261
310
  if (Array.isArray(r)) return r.map(e);
262
- if (!I(r)) return r;
311
+ if (!M(r)) return r;
263
312
  const n = Object.fromEntries(Object.entries(r).map(([a, o]) => [a, e(o)])), { right: s } = n;
264
- if (n.type !== "binary" || n.operator !== "IN" || !I(s) || s.type === "subquery" || s.type === "list") return n;
265
- const i = s.type === "literal" && typeof s.value == "string" ? vt(s.value).map((a) => ({ type: "literal", value: a })) : [s];
313
+ if (n.type !== "binary" || n.operator !== "IN" || !M(s) || s.type === "subquery" || s.type === "list") return n;
314
+ const i = s.type === "literal" && typeof s.value == "string" ? Gt(s.value).map((a) => ({ type: "literal", value: a })) : [s];
266
315
  return { ...n, right: { type: "list", items: i } };
267
316
  };
268
317
  return e(t);
269
318
  }
270
- const dt = (t) => t, _t = (t) => t, Ht = [Bt, dt, _t];
271
- function jt(t, e, r) {
319
+ const Qt = (t) => t, kt = (t) => t, Xt = [xt, Qt, kt];
320
+ function Vt(t, e, r) {
272
321
  return r.slice(e - 1).reduce((n, s) => s(n), t);
273
322
  }
274
- function L(t, e) {
275
- return Array.isArray(t) ? t.map((r) => L(r, e)) : I(t) ? t.type === "literal" ? e(t) : Object.fromEntries(Object.entries(t).map(([r, n]) => [r, L(n, e)])) : t;
323
+ function q(t, e) {
324
+ return Array.isArray(t) ? t.map((r) => q(r, e)) : M(t) ? t.type === "literal" ? e(t) : Object.fromEntries(Object.entries(t).map(([r, n]) => [r, q(n, e)])) : t;
276
325
  }
277
- function Yt(t) {
326
+ function Wt(t) {
278
327
  return t.value instanceof Date ? { ...t, value: t.value.toISOString(), valueType: "date" } : typeof t.value == "bigint" ? { ...t, value: String(t.value), valueType: "bigint" } : t;
279
328
  }
280
- function Pt(t) {
329
+ function Jt(t) {
281
330
  if (t.valueType === void 0) return t;
282
331
  const { valueType: e, ...r } = t, n = String(r.value);
283
332
  let s;
284
333
  if (e === "date") {
285
334
  if (s = new Date(n), Number.isNaN(s.getTime()))
286
- throw new h("invalid", `not a date: ${JSON.stringify(n)}`);
335
+ throw new R("invalid", `not a date: ${JSON.stringify(n)}`);
287
336
  } else if (e === "bigint" && /^-?\d+$/.test(n))
288
337
  s = BigInt(n);
289
338
  else {
290
339
  const i = String(e);
291
- throw new h("invalid", `can't read a ${i} from ${JSON.stringify(n)}`);
340
+ throw new R("invalid", `can't read a ${i} from ${JSON.stringify(n)}`);
292
341
  }
293
342
  return { ...r, value: s };
294
343
  }
295
- function he(t) {
344
+ function we(t) {
296
345
  return {
297
- version: q,
298
- query: L(t, Yt)
346
+ version: B,
347
+ query: q(t, Wt)
299
348
  };
300
349
  }
301
- function Re(t) {
302
- if (!I(t))
303
- throw new h("invalid", "a stored query is an object");
350
+ function Fe(t) {
351
+ if (!M(t))
352
+ throw new R("invalid", "a stored query is an object");
304
353
  const { version: e } = t;
305
354
  if (typeof e != "number" || !Number.isInteger(e) || e < 1)
306
- throw new h("invalid", "a stored query has a whole-number version from 1");
307
- if (e > q)
308
- throw new h(
355
+ throw new R("invalid", "a stored query has a whole-number version from 1");
356
+ if (e > B)
357
+ throw new R(
309
358
  "newerVersion",
310
- `stored in format ${e}; this version reads up to ${q}`
359
+ `stored in format ${e}; this version reads up to ${B}`
311
360
  );
312
- const r = jt(t.query, e, Ht);
313
- if (!I(r) || typeof r.id != "string")
314
- throw new h("invalid", "a stored query has a query with a string id");
315
- return L(r, Pt);
361
+ const r = Vt(t.query, e, Xt);
362
+ if (!M(r) || typeof r.id != "string")
363
+ throw new R("invalid", "a stored query has a query with a string id");
364
+ return q(r, Jt);
316
365
  }
317
- function U(t, e) {
366
+ function j(t, e) {
318
367
  const r = new Map(e == null ? void 0 : e.tableOf), n = new Set(e == null ? void 0 : e.aliases), s = new Set(e == null ? void 0 : e.derived);
319
368
  return t.forEach(({ table: i, alias: a }) => {
320
369
  if (i === void 0) {
@@ -328,11 +377,11 @@ function U(t, e) {
328
377
  n.delete(i), s.delete(i);
329
378
  }), { tableOf: r, aliases: n, derived: s };
330
379
  }
331
- function Gt(t, e, r) {
332
- const n = t.on && S(t.on, e, r);
333
- return t.query ? { ...t, on: n, query: At(t.query, (s) => M(s, r)) } : t.shared !== void 0 ? { ...t, on: n } : { ...t, on: n, table: r(t.table) };
380
+ function Kt(t, e, r) {
381
+ const n = t.on && L(t.on, e, r);
382
+ return t.query ? { ...t, on: n, query: Nt(t.query, (s) => U(s, r)) } : t.shared !== void 0 ? { ...t, on: n } : { ...t, on: n, table: r(t.table) };
334
383
  }
335
- function S(t, e, r) {
384
+ function L(t, e, r) {
336
385
  if (t.type === "field") {
337
386
  if (!t.table || e.derived.has(t.table)) return t;
338
387
  const n = e.tableOf.get(t.table) ?? t.table;
@@ -342,27 +391,27 @@ function S(t, e, r) {
342
391
  ...t.column ? { column: r(n, t.column) } : {}
343
392
  };
344
393
  }
345
- if (t.type === "subquery") return { ...t, query: M(t.query, r) };
394
+ if (t.type === "subquery") return { ...t, query: U(t.query, r) };
346
395
  if (t.type === "exists") {
347
- const { query: n } = t, s = [n.from, ...n.joins], i = U(s), a = U(s, e);
396
+ const { query: n } = t, s = [n.from, ...n.joins], i = j(s), a = j(s, e);
348
397
  return {
349
398
  ...t,
350
- link: S(t.link, a, r),
399
+ link: L(t.link, a, r),
351
400
  query: {
352
401
  ...n,
353
402
  from: { ...n.from, table: r(n.from.table) },
354
- joins: n.joins.map((o) => Gt(o, i, r)),
355
- ...n.where ? { where: S(n.where, i, r) } : {}
403
+ joins: n.joins.map((o) => Kt(o, i, r)),
404
+ ...n.where ? { where: L(n.where, i, r) } : {}
356
405
  }
357
406
  };
358
407
  }
359
- return X(t, (n) => S(n, e, r));
408
+ return Y(t, (n) => L(n, e, r));
360
409
  }
361
- function M(t, e) {
362
- const r = U([t.from, ...t.joins]), n = k(
410
+ function U(t, e) {
411
+ const r = j([t.from, ...t.joins]), n = J(
363
412
  t,
364
- (s) => S(s, r, e),
365
- (s) => M(s, e)
413
+ (s) => L(s, r, e),
414
+ (s) => U(s, e)
366
415
  );
367
416
  return {
368
417
  ...n,
@@ -370,11 +419,11 @@ function M(t, e) {
370
419
  joins: n.joins.map((s) => s.table === void 0 ? s : { ...s, table: e(s.table) })
371
420
  };
372
421
  }
373
- function v(t, e) {
374
- if (Array.isArray(t)) return t.map((s) => v(s, e));
422
+ function _(t, e) {
423
+ if (Array.isArray(t)) return t.map((s) => _(s, e));
375
424
  if (typeof t != "object" || t === null || t instanceof Date) return t;
376
425
  const r = Object.fromEntries(Object.entries(t).map(
377
- ([s, i]) => [s, v(i, e)]
426
+ ([s, i]) => [s, _(i, e)]
378
427
  ));
379
428
  if (!("from" in r) || !Array.isArray(r.joins)) return r;
380
429
  const n = (s) => s.table !== void 0 && !s.alias && e(s.table) !== s.table ? { ...s, alias: s.table } : s;
@@ -384,42 +433,42 @@ function v(t, e) {
384
433
  joins: r.joins.map(n)
385
434
  };
386
435
  }
387
- function xt(t, e) {
388
- return M(v(t, e), e);
436
+ function zt(t, e) {
437
+ return U(_(t, e), e);
389
438
  }
390
- const Qt = /^(\d{2}):(\d{2})(?::(\d{2}))?$/, P = /YYYY|MM|DD|HH|mm|ss/g, O = (t, e = 2) => String(t).padStart(e, "0");
391
- function tt(t, e) {
439
+ const Zt = /^(\d{2}):(\d{2})(?::(\d{2}))?$/, X = /YYYY|MM|DD|HH|mm|ss/g, S = (t, e = 2) => String(t).padStart(e, "0");
440
+ function st(t, e) {
392
441
  let r;
393
- const n = typeof t == "string" ? Qt.exec(t.trim()) : null;
442
+ const n = typeof t == "string" ? Zt.exec(t.trim()) : null;
394
443
  if (n)
395
444
  r = { HH: n[1], mm: n[2], ss: n[3] ?? "00" };
396
445
  else {
397
- const a = typeof t == "string" ? Ct(t, "dateTime") : t;
446
+ const a = typeof t == "string" ? qt(t, "dateTime") : t;
398
447
  a instanceof Date && (r = {
399
- YYYY: O(a.getUTCFullYear(), 4),
400
- MM: O(a.getUTCMonth() + 1),
401
- DD: O(a.getUTCDate()),
402
- HH: O(a.getUTCHours()),
403
- mm: O(a.getUTCMinutes()),
404
- ss: O(a.getUTCSeconds())
448
+ YYYY: S(a.getUTCFullYear(), 4),
449
+ MM: S(a.getUTCMonth() + 1),
450
+ DD: S(a.getUTCDate()),
451
+ HH: S(a.getUTCHours()),
452
+ mm: S(a.getUTCMinutes()),
453
+ ss: S(a.getUTCSeconds())
405
454
  });
406
455
  }
407
456
  if (!r) return t;
408
457
  const s = r;
409
- return (e.match(P) ?? []).some((a) => s[a] === void 0) ? t : e.replace(P, (a) => s[a]);
458
+ return (e.match(X) ?? []).some((a) => s[a] === void 0) ? t : e.replace(X, (a) => s[a]);
410
459
  }
411
- function et(t, e) {
460
+ function it(t, e) {
412
461
  const r = /* @__PURE__ */ new Map(), n = (s) => {
413
462
  const i = /* @__PURE__ */ new Map();
414
- d(s).forEach((u) => i.set(Q(u), u.table));
463
+ b(s).forEach((u) => i.set(W(u), u.table));
415
464
  const a = (u) => {
416
465
  if ((u == null ? void 0 : u.type) !== "field" || !u.table || !u.column) return;
417
- const c = i.has(u.table) ? i.get(u.table) : u.table, l = c === void 0 ? void 0 : mt(e, c), $ = l == null ? void 0 : l.columns.find((p) => p.name === u.column);
466
+ const c = i.has(u.table) ? i.get(u.table) : u.table, l = c === void 0 ? void 0 : Ot(e, c), $ = l == null ? void 0 : l.columns.find((T) => T.name === u.column);
418
467
  return $ == null ? void 0 : $.format;
419
468
  }, o = (u, c) => {
420
469
  switch (u.type) {
421
470
  case "literal":
422
- return { ...u, value: tt(u.value, c) };
471
+ return { ...u, value: st(u.value, c) };
423
472
  case "list":
424
473
  return { ...u, items: u.items.map((l) => o(l, c)) };
425
474
  case "param":
@@ -429,7 +478,7 @@ function et(t, e) {
429
478
  }
430
479
  }, f = (u) => {
431
480
  if (u.type === "subquery") return { ...u, query: n(u.query) };
432
- const c = X(u, f);
481
+ const c = Y(u, f);
433
482
  if (c.type !== "binary" || !c.right) return c;
434
483
  const l = a(c.left), $ = a(c.right);
435
484
  return {
@@ -438,16 +487,16 @@ function et(t, e) {
438
487
  right: l ? o(c.right, l) : c.right
439
488
  };
440
489
  };
441
- return k(s, f, (u) => n(u));
490
+ return J(s, f, (u) => n(u));
442
491
  };
443
492
  return { query: n(t), params: r };
444
493
  }
445
- const Se = ["mysql", "mssql", "postgres"], Ie = {
494
+ const qe = ["mysql", "mssql", "postgres"], Ue = {
446
495
  mysql: "MySQL",
447
496
  mssql: "SQL Server",
448
497
  postgres: "PostgreSQL"
449
498
  };
450
- function m(t, e) {
499
+ function g(t, e) {
451
500
  const r = t.replace(/[\uE000-\uE003]/g, "");
452
501
  switch (e) {
453
502
  case "mysql":
@@ -460,27 +509,27 @@ function m(t, e) {
460
509
  return `"${r.replace(/"/g, '""')}"`;
461
510
  }
462
511
  }
463
- const kt = /^[A-Za-z_][A-Za-z0-9_]*$/, rt = (t) => `${t}`, Xt = /\uE000(\d+)\uE000/g;
464
- let N;
465
- function be(t, e) {
466
- N = { ...t, writing: [] };
512
+ const te = /^[A-Za-z_][A-Za-z0-9_]*$/, ot = (t) => `${t}`, ee = /\uE000(\d+)\uE000/g;
513
+ let O;
514
+ function ve(t, e) {
515
+ O = { ...t, writing: [] };
467
516
  try {
468
517
  return e();
469
518
  } finally {
470
- N = void 0;
519
+ O = void 0;
471
520
  }
472
521
  }
473
- function nt(t, e, r) {
522
+ function at(t, e, r) {
474
523
  if (typeof t != "object" || t === null || t instanceof Date) return;
475
524
  let n;
476
525
  return Object.entries(t).some(([s, i]) => {
477
526
  const a = [...r, Array.isArray(t) ? Number(s) : s];
478
- return n = i === e ? a : nt(i, e, a), n !== void 0;
527
+ return n = i === e ? a : at(i, e, a), n !== void 0;
479
528
  }), n;
480
529
  }
481
- function T(t, e) {
482
- if (!N) return e();
483
- const { writing: r, paths: n } = N, s = r[r.length - 1], i = typeof t == "string" ? [t] : nt(s.value, t, s.path);
530
+ function y(t, e) {
531
+ if (!O) return e();
532
+ const { writing: r, paths: n } = O, s = r[r.length - 1], i = typeof t == "string" ? [t] : at(s.value, t, s.path);
484
533
  if (!i) return e();
485
534
  r.push({ value: t, path: i });
486
535
  try {
@@ -489,7 +538,7 @@ function T(t, e) {
489
538
  r.pop();
490
539
  }
491
540
  }
492
- const Vt = {
541
+ const re = {
493
542
  mysql: {
494
543
  text: "CHAR",
495
544
  integer: "SIGNED",
@@ -518,24 +567,24 @@ const Vt = {
518
567
  boolean: "boolean"
519
568
  }
520
569
  };
521
- function Wt(t, e) {
570
+ function ne(t, e) {
522
571
  var n;
523
- const r = (n = Vt[e]) == null ? void 0 : n[t];
572
+ const r = (n = re[e]) == null ? void 0 : n[t];
524
573
  return r ? e === "postgres" ? `NULL::${r}` : `CAST(NULL AS ${r})` : "NULL";
525
574
  }
526
- function st(t, e, r) {
575
+ function ut(t, e, r) {
527
576
  if (t == null) return "NULL";
528
577
  if (r)
529
- return r.values.push(t), rt(r.values.length - 1);
578
+ return r.values.push(t), ot(r.values.length - 1);
530
579
  if (typeof t == "boolean")
531
580
  return e === "mssql" ? t ? "1" : "0" : t ? "TRUE" : "FALSE";
532
581
  if (typeof t == "string") {
533
- const n = N ? t.replace(/[\uE001-\uE003]/g, "") : t;
582
+ const n = O ? t.replace(/[\uE001-\uE003]/g, "") : t;
534
583
  return n === "" ? "''" : `'${n.replace(/'/g, "''")}'`;
535
584
  }
536
- return typeof t == "number" || typeof t == "bigint" ? String(t) : t instanceof Date ? `'${J(t)}'` : String(t);
585
+ return typeof t == "number" || typeof t == "bigint" ? String(t) : t instanceof Date ? `'${Z(t)}'` : String(t);
537
586
  }
538
- function Jt(t, e) {
587
+ function se(t, e) {
539
588
  switch (t) {
540
589
  case "!=":
541
590
  return e === "mssql" ? "<>" : "!=";
@@ -547,10 +596,10 @@ function Jt(t, e) {
547
596
  return t;
548
597
  }
549
598
  }
550
- function g(t) {
599
+ function D(t) {
551
600
  return (t == null ? void 0 : t.type) === "literal" && typeof t.value == "string" && /^[A-Za-z_]+$/.test(t.value) ? t.value.toUpperCase() : "DAY";
552
601
  }
553
- const w = {
602
+ const v = {
554
603
  YEAR: "year",
555
604
  QUARTER: "quarter",
556
605
  MONTH: "month",
@@ -560,43 +609,43 @@ const w = {
560
609
  MINUTE: "minute",
561
610
  SECOND: "second",
562
611
  MILLISECOND: "millisecond"
563
- }, Kt = {
612
+ }, ie = {
564
613
  // ---- Date arithmetic ----
565
614
  DATE_ADD: ([t, e], r, n, s) => {
566
615
  var a;
567
- const i = g(r[2]);
616
+ const i = D(r[2]);
568
617
  switch (n) {
569
618
  case "mysql":
570
619
  return i === "MILLISECOND" ? `DATE_ADD(${t}, INTERVAL (${e}) * 1000 MICROSECOND)` : `DATE_ADD(${t}, INTERVAL ${e} ${i})`;
571
620
  case "postgres": {
572
- const o = w[i] ?? i.toLowerCase();
621
+ const o = v[i] ?? i.toLowerCase();
573
622
  return !s && ((a = r[1]) == null ? void 0 : a.type) === "literal" && typeof r[1].value == "number" ? `(${t} + INTERVAL '${r[1].value} ${o}')` : `(${t} + (${e} * INTERVAL '1 ${o}'))`;
574
623
  }
575
624
  case "mssql":
576
625
  return `DATEADD(${i}, ${e}, ${t})`;
577
626
  default:
578
- return `DATE_ADD(${t}, ${e}, ${g(r[2])})`;
627
+ return `DATE_ADD(${t}, ${e}, ${D(r[2])})`;
579
628
  }
580
629
  },
581
630
  DATE_SUB: ([t, e], r, n, s) => {
582
631
  var a;
583
- const i = g(r[2]);
632
+ const i = D(r[2]);
584
633
  switch (n) {
585
634
  case "mysql":
586
635
  return i === "MILLISECOND" ? `DATE_SUB(${t}, INTERVAL (${e}) * 1000 MICROSECOND)` : `DATE_SUB(${t}, INTERVAL ${e} ${i})`;
587
636
  case "postgres": {
588
- const o = w[i] ?? i.toLowerCase();
637
+ const o = v[i] ?? i.toLowerCase();
589
638
  return !s && ((a = r[1]) == null ? void 0 : a.type) === "literal" && typeof r[1].value == "number" ? `(${t} - INTERVAL '${r[1].value} ${o}')` : `(${t} - (${e} * INTERVAL '1 ${o}'))`;
590
639
  }
591
640
  case "mssql":
592
641
  return `DATEADD(${i}, -(${e}), ${t})`;
593
642
  default:
594
- return `DATE_SUB(${t}, ${e}, ${g(r[2])})`;
643
+ return `DATE_SUB(${t}, ${e}, ${D(r[2])})`;
595
644
  }
596
645
  },
597
646
  // ---- Date diff ----
598
647
  DATEDIFF: ([t, e], r, n) => {
599
- const s = g(r[2]);
648
+ const s = D(r[2]);
600
649
  switch (n) {
601
650
  case "mysql":
602
651
  return `TIMESTAMPDIFF(${s}, ${t}, ${e})`;
@@ -635,7 +684,7 @@ const w = {
635
684
  },
636
685
  // ---- Date extract ----
637
686
  EXTRACT: ([t], e, r) => {
638
- const n = g(e[1]);
687
+ const n = D(e[1]);
639
688
  switch (r) {
640
689
  case "mysql":
641
690
  return n === "MILLISECOND" ? `FLOOR(MICROSECOND(${t}) / 1000)` : `EXTRACT(${n} FROM ${t})`;
@@ -649,7 +698,7 @@ const w = {
649
698
  },
650
699
  // ---- Date truncation ----
651
700
  DATE_TRUNC: ([t], e, r) => {
652
- const n = g(e[1]);
701
+ const n = D(e[1]);
653
702
  switch (r) {
654
703
  case "mysql":
655
704
  switch (n) {
@@ -675,7 +724,7 @@ const w = {
675
724
  return `/* unknown unit: ${n} */`;
676
725
  }
677
726
  case "postgres":
678
- return `DATE_TRUNC('${w[n] ?? n.toLowerCase()}', ${t})`;
727
+ return `DATE_TRUNC('${v[n] ?? n.toLowerCase()}', ${t})`;
679
728
  case "mssql":
680
729
  switch (n) {
681
730
  case "YEAR":
@@ -720,68 +769,68 @@ const w = {
720
769
  // The separator goes into the SQL as a literal even in parameterized SQL:
721
770
  // MySQL's SEPARATOR takes nothing else.
722
771
  STRING_AGG: ([t = "??"], e, r, n, s, i) => {
723
- const a = e[1] ?? { type: "literal", value: ", " }, o = a.type === "literal" && typeof a.value == "string" ? st(a.value, r) : "??", f = s.distinct ? "DISTINCT " : "", u = ($) => {
724
- var p;
725
- return (p = s.orderBy) != null && p.length ? `ORDER BY ${s.orderBy.map((A) => `${$(A)} ${A.direction === "desc" ? "DESC" : "ASC"}`).join(", ")}` : "";
772
+ const a = e[1] ?? { type: "literal", value: ", " }, o = a.type === "literal" && typeof a.value == "string" ? ut(a.value, r) : "??", f = s.distinct ? "DISTINCT " : "", u = ($) => {
773
+ var T;
774
+ return (T = s.orderBy) != null && T.length ? `ORDER BY ${s.orderBy.map((A) => `${$(A)} ${A.direction === "desc" ? "DESC" : "ASC"}`).join(", ")}` : "";
726
775
  }, c = ($) => i($.expression), l = ($) => $ ? ` ${$}` : "";
727
776
  switch (r) {
728
777
  case "mysql":
729
778
  return `GROUP_CONCAT(${f}${t}${l(u(c))} SEPARATOR ${o})`;
730
779
  case "postgres": {
731
- const $ = `CAST(${t} AS TEXT)`, p = u((A) => {
780
+ const $ = `CAST(${t} AS TEXT)`, T = u((A) => {
732
781
  if (!s.distinct) return c(A);
733
- if (F(A.expression, e[0])) return $;
782
+ if (w(A.expression, e[0])) return $;
734
783
  throw new Error("PostgreSQL orders STRING_AGG of different values by the value only");
735
784
  });
736
- return `STRING_AGG(${f}${$}, ${o}${l(p)})`;
785
+ return `STRING_AGG(${f}${$}, ${o}${l(T)})`;
737
786
  }
738
787
  case "mssql": {
739
788
  if (s.distinct)
740
789
  throw new Error("SQL Server's STRING_AGG can't join only different values");
741
- const $ = u(c), p = $ ? ` WITHIN GROUP (${$})` : "";
742
- return `STRING_AGG(CAST(${t} AS NVARCHAR(MAX)), ${o})${p}`;
790
+ const $ = u(c), T = $ ? ` WITHIN GROUP (${$})` : "";
791
+ return `STRING_AGG(CAST(${t} AS NVARCHAR(MAX)), ${o})${T}`;
743
792
  }
744
793
  default:
745
794
  return `STRING_AGG(${f}${t}, ${o}${l(u(c))})`;
746
795
  }
747
796
  }
748
797
  };
749
- function R(t) {
798
+ function C(t) {
750
799
  return t.type === "binary" || t.type === "logical" || t.type === "if" || t.type === "case";
751
800
  }
752
801
  function E(t, e, r, n) {
753
- return T(t, () => zt(t, e, r, n));
802
+ return y(t, () => oe(t, e, r, n));
754
803
  }
755
- function G(t, e, r, n) {
804
+ function V(t, e, r, n) {
756
805
  const s = (i) => {
757
806
  if (!i) return "??";
758
807
  const a = E(i, e, r, n);
759
- return R(i) ? `(${a})` : a;
808
+ return C(i) ? `(${a})` : a;
760
809
  };
761
- return T(t, () => {
810
+ return y(t, () => {
762
811
  const [i, a] = t.type === "list" ? t.items : [t];
763
812
  return `${s(i)} AND ${s(a)}`;
764
813
  });
765
814
  }
766
- function zt(t, e, r, n) {
815
+ function oe(t, e, r, n) {
767
816
  var a;
768
817
  const s = " ".repeat(r), i = " ".repeat(r + 1);
769
818
  switch (t.type) {
770
819
  case "literal":
771
- return t.value === "" && !t.empty ? "??" : t.value === null && t.as ? Wt(t.as, e) : st(t.value, e, n);
820
+ return t.value === "" && !t.empty ? "??" : t.value === null && t.as ? ne(t.as, e) : ut(t.value, e, n);
772
821
  case "param": {
773
- if (!n) return kt.test(t.name) ? `:${t.name}` : "??";
822
+ if (!n) return te.test(t.name) ? `:${t.name}` : "??";
774
823
  if (!n.named.has(t.name))
775
824
  throw new Error(`no value for parameter "${t.name}"`);
776
- return n.values.push(n.named.get(t.name)), rt(n.values.length - 1);
825
+ return n.values.push(n.named.get(t.name)), ot(n.values.length - 1);
777
826
  }
778
827
  case "field": {
779
828
  if (!t.column) return "??";
780
- const o = m(t.column, e);
781
- return t.table ? `${m(t.table, e)}.${o}` : o;
829
+ const o = g(t.column, e);
830
+ return t.table ? `${g(t.table, e)}.${o}` : o;
782
831
  }
783
832
  case "function": {
784
- const o = t.args.map((l) => E(l, e, r, n)), f = Kt[t.name.toUpperCase()];
833
+ const o = t.args.map((l) => E(l, e, r, n)), f = ie[t.name.toUpperCase()];
785
834
  if (f)
786
835
  return f(
787
836
  o,
@@ -797,14 +846,14 @@ function zt(t, e, r, n) {
797
846
  return `${u}(${c}${o.join(", ")})`;
798
847
  }
799
848
  case "binary": {
800
- const o = t.operator ? Jt(t.operator, e) : "=", f = E(t.left, e, r, n), u = R(t.left) ? `(${f})` : f;
801
- if (Mt(t.operator)) return `${u} ${o}`;
849
+ const o = t.operator ? se(t.operator, e) : "=", f = E(t.left, e, r, n), u = C(t.left) ? `(${f})` : f;
850
+ if (vt(t.operator)) return `${u} ${o}`;
802
851
  if (!t.right) return `${u} ${o} ??`;
803
852
  if (o === "BETWEEN")
804
- return `${u} BETWEEN ${G(t.right, e, r, n)}`;
853
+ return `${u} BETWEEN ${V(t.right, e, r, n)}`;
805
854
  if (o === "IN")
806
855
  return t.right.type === "list" ? `${u} IN ${E(t.right, e, r, n)}` : `${u} IN (${E(t.right, e, r, n)})`;
807
- const c = E(t.right, e, r, n), l = R(t.right) ? `(${c})` : c;
856
+ const c = E(t.right, e, r, n), l = C(t.right) ? `(${c})` : c;
808
857
  return `${u} ${o} ${l}`;
809
858
  }
810
859
  case "logical": {
@@ -827,11 +876,11 @@ ${s})`;
827
876
  const { operand: o } = t;
828
877
  if (o.type === "binary" && o.operator === "IN" && ((a = o.right) == null ? void 0 : a.type) === "subquery") {
829
878
  const f = E(o.left, e, r, n);
830
- return `${R(o.left) ? `(${f})` : f} NOT IN (${E(o.right, e, r, n)})`;
879
+ return `${C(o.left) ? `(${f})` : f} NOT IN (${E(o.right, e, r, n)})`;
831
880
  }
832
881
  if (o.type === "binary" && o.operator === "BETWEEN" && o.right) {
833
882
  const f = E(o.left, e, r, n);
834
- return `${R(o.left) ? `(${f})` : f} NOT BETWEEN ${G(o.right, e, r, n)}`;
883
+ return `${C(o.left) ? `(${f})` : f} NOT BETWEEN ${V(o.right, e, r, n)}`;
835
884
  }
836
885
  if (o.type === "logical" || o.type === "not") {
837
886
  const f = E(o, e, r + 1, n);
@@ -865,11 +914,11 @@ ${[
865
914
  "SELECT 1",
866
915
  // The clauses below write their expressions with formatNode.
867
916
  // eslint-disable-next-line @typescript-eslint/no-use-before-define
868
- ct(o.from, e),
917
+ Et(o.from, e),
869
918
  // eslint-disable-next-line @typescript-eslint/no-use-before-define
870
- ...o.joins.map(($) => ft($, e, n)),
919
+ ...o.joins.map(($) => Tt($, e, n)),
871
920
  // eslint-disable-next-line @typescript-eslint/no-use-before-define
872
- it(c, e, n)
921
+ ct(c, e, n)
873
922
  ].join(`
874
923
  `).replace(/^/gm, i)}
875
924
  ${s})`;
@@ -881,129 +930,129 @@ ${s})`;
881
930
  return `(${t.items.map((o) => E(o, e, r, n)).join(", ") || "??"})`;
882
931
  case "subquery":
883
932
  return `
884
- ${_(t.query, e, n).join(`
933
+ ${G(t.query, e, n).join(`
885
934
  `).replace(/^/gm, i)}
886
935
  ${s}`;
887
936
  default:
888
937
  return "/* unknown */";
889
938
  }
890
939
  }
891
- function it(t, e, r) {
940
+ function ct(t, e, r) {
892
941
  return `WHERE
893
942
  ${E(t, e, 1, r)}`;
894
943
  }
895
- const Zt = {
944
+ const ae = {
896
945
  inner: "INNER JOIN",
897
946
  left: "LEFT JOIN",
898
947
  right: "RIGHT JOIN",
899
948
  full: "FULL JOIN",
900
949
  cross: "CROSS JOIN"
901
950
  };
902
- let ot = /* @__PURE__ */ new Map();
903
- function at(t, e, r) {
904
- return t.shared !== void 0 ? m(ot.get(t.shared) ?? "??", e) : t.query ? `(
905
- ${ut(t.query, e, r).replace(/^/gm, " ")}
906
- )` : m(t.table, e);
951
+ let ft = /* @__PURE__ */ new Map();
952
+ function lt(t, e, r) {
953
+ return t.shared !== void 0 ? g(ft.get(t.shared) ?? "??", e) : t.query ? `(
954
+ ${$t(t.query, e, r).replace(/^/gm, " ")}
955
+ )` : g(t.table, e);
907
956
  }
908
- function ut(t, e, r) {
909
- return gt(t).map((n) => _(n, e, r).join(`
910
- `)).join(Dt(t) && !t.all ? `
957
+ function $t(t, e, r) {
958
+ return St(t).map((n) => G(n, e, r).join(`
959
+ `)).join(Rt(t) && !t.all ? `
911
960
  UNION
912
961
  ` : `
913
962
  UNION ALL
914
963
  `);
915
964
  }
916
- function te(t, e, r) {
965
+ function ue(t, e, r) {
917
966
  return t.length === 0 ? [] : [`WITH
918
- ${t.map((s) => T(s, () => {
919
- const i = ut(s.query, e, r).replace(/^/gm, " ");
920
- return ` ${m(s.name, e)} AS (
967
+ ${t.map((s) => y(s, () => {
968
+ const i = $t(s.query, e, r).replace(/^/gm, " ");
969
+ return ` ${g(s.name, e)} AS (
921
970
  ${i}
922
971
  )`;
923
972
  })).join(`,
924
973
  `)}`];
925
974
  }
926
- function ct(t, e, r) {
927
- const n = t.alias ? ` AS ${m(t.alias, e)}` : "";
928
- return `FROM ${T(t, () => `${at(t, e, r)}${n}`)}`;
975
+ function Et(t, e, r) {
976
+ const n = t.alias ? ` AS ${g(t.alias, e)}` : "";
977
+ return `FROM ${y(t, () => `${lt(t, e, r)}${n}`)}`;
929
978
  }
930
- function ft(t, e, r) {
931
- return T(t, () => {
932
- const n = at(t, e, r), s = t.alias ? ` AS ${m(t.alias, e)}` : "";
979
+ function Tt(t, e, r) {
980
+ return y(t, () => {
981
+ const n = lt(t, e, r), s = t.alias ? ` AS ${g(t.alias, e)}` : "";
933
982
  if (t.joinType === "cross") return `CROSS JOIN ${n}${s}`;
934
983
  const i = t.on ? E(t.on, e, 1, r) : "/* unconfigured */";
935
- return `${Zt[t.joinType]} ${n}${s}
984
+ return `${ae[t.joinType]} ${n}${s}
936
985
  ON ${i}`;
937
986
  });
938
987
  }
939
- function ee(t, e, r, n = "SELECT") {
940
- if (t.length === 0) return `${n} ${T(t, () => "*")}`;
941
- const s = t.map((i) => T(i, () => {
942
- const a = E(i.expression, e, 1, r), o = i.alias ? ` AS ${m(i.alias, e)}` : "";
988
+ function ce(t, e, r, n = "SELECT") {
989
+ if (t.length === 0) return `${n} ${y(t, () => "*")}`;
990
+ const s = t.map((i) => y(i, () => {
991
+ const a = E(i.expression, e, 1, r), o = i.alias ? ` AS ${g(i.alias, e)}` : "";
943
992
  return `${a}${o}`;
944
993
  }));
945
994
  return `${n}
946
995
  ${s.join(`,
947
996
  `)}`;
948
997
  }
949
- function re(t, e, r) {
998
+ function fe(t, e, r) {
950
999
  return `GROUP BY
951
- ${t.map((s) => T(
1000
+ ${t.map((s) => y(
952
1001
  s,
953
1002
  () => E(s.expression, e, 1, r)
954
1003
  )).join(`,
955
1004
  `)}`;
956
1005
  }
957
- function ne(t, e, r) {
1006
+ function le(t, e, r) {
958
1007
  return `HAVING
959
1008
  ${E(t, e, 1, r)}`;
960
1009
  }
961
- function se(t, e, r, n) {
1010
+ function $e(t, e, r, n) {
962
1011
  return `ORDER BY
963
- ${t.map((i) => T(i, () => `${E(n(i.expression), e, 1, r)} ${i.direction === "desc" ? "DESC" : "ASC"}`)).join(`,
1012
+ ${t.map((i) => y(i, () => `${E(n(i.expression), e, 1, r)} ${i.direction === "desc" ? "DESC" : "ASC"}`)).join(`,
964
1013
  `)}`;
965
1014
  }
966
- const B = (t) => t !== void 0 && Number.isInteger(t) && t >= 0 ? t : void 0;
967
- function lt(t, e) {
968
- const r = e.resolveName ? xt(t, e.resolveName) : t;
969
- return e.defaultLimit !== void 0 && B(r.limit) === void 0 ? { ...r, limit: e.defaultLimit } : r;
1015
+ const H = (t) => t !== void 0 && Number.isInteger(t) && t >= 0 ? t : void 0;
1016
+ function yt(t, e) {
1017
+ const r = e.resolveName ? zt(t, e.resolveName) : t;
1018
+ return e.defaultLimit !== void 0 && H(r.limit) === void 0 ? { ...r, limit: e.defaultLimit } : r;
970
1019
  }
971
- const ie = "18446744073709551615";
972
- function _(t, e, r, n = `SELECT${t.distinct ? " DISTINCT" : ""}`) {
1020
+ const Ee = "18446744073709551615";
1021
+ function G(t, e, r, n = `SELECT${t.distinct ? " DISTINCT" : ""}`) {
973
1022
  const s = [
974
- ee(t.select, e, r, n),
975
- ct(t.from, e, r),
976
- ...t.joins.map((a) => ft(a, e, r))
1023
+ ce(t.select, e, r, n),
1024
+ Et(t.from, e, r),
1025
+ ...t.joins.map((a) => Tt(a, e, r))
977
1026
  ];
978
- t.where && s.push(it(t.where, e, r));
1027
+ t.where && s.push(ct(t.where, e, r));
979
1028
  const i = t.groupBy ?? [];
980
- if (i.length > 0 && s.push(re(i, e, r)), t.having) {
981
- const a = e === "mysql" ? W(t.having, t) : t.having;
982
- s.push(ne(a, e, r));
1029
+ if (i.length > 0 && s.push(fe(i, e, r)), t.having) {
1030
+ const a = e === "mysql" ? z(t.having, t) : t.having;
1031
+ s.push(le(a, e, r));
983
1032
  }
984
1033
  return s;
985
1034
  }
986
- function $t(t, e, r) {
987
- N && (N.writing = [{ value: t, path: [] }]), ot = new Map((t.shared ?? []).map((c) => [c.id, c.name]));
988
- const n = te(t.shared ?? [], e, r), s = B(t.limit), i = B(t.offset) || void 0, a = t.orderBy ?? [], o = e === "mssql" && s !== void 0 && i === void 0, f = `SELECT${t.distinct ? " DISTINCT" : ""}${o ? ` ${T("limit", () => `TOP (${s})`)}` : ""}`, u = _(t, e, r, f);
989
- if (a.length > 0 && u.push(se(a, e, r, (c) => e === "mysql" ? W(c, t) : c)), e === "mssql") {
1035
+ function pt(t, e, r) {
1036
+ O && (O.writing = [{ value: t, path: [] }]), ft = new Map((t.shared ?? []).map((c) => [c.id, c.name]));
1037
+ const n = ue(t.shared ?? [], e, r), s = H(t.limit), i = H(t.offset) || void 0, a = t.orderBy ?? [], o = e === "mssql" && s !== void 0 && i === void 0, f = `SELECT${t.distinct ? " DISTINCT" : ""}${o ? ` ${y("limit", () => `TOP (${s})`)}` : ""}`, u = G(t, e, r, f);
1038
+ if (a.length > 0 && u.push($e(a, e, r, (c) => e === "mysql" ? z(c, t) : c)), e === "mssql") {
990
1039
  if (i !== void 0) {
991
1040
  a.length === 0 && u.push("ORDER BY (SELECT NULL)");
992
- const c = s !== void 0 ? ` ${T("limit", () => `FETCH NEXT ${s} ROWS ONLY`)}` : "";
993
- u.push(`${T("offset", () => `OFFSET ${i} ROWS`)}${c}`);
1041
+ const c = s !== void 0 ? ` ${y("limit", () => `FETCH NEXT ${s} ROWS ONLY`)}` : "";
1042
+ u.push(`${y("offset", () => `OFFSET ${i} ROWS`)}${c}`);
994
1043
  }
995
1044
  } else if (s !== void 0 || i !== void 0) {
996
- const c = s !== void 0 || e === "mysql" ? T(s !== void 0 ? "limit" : {}, () => `LIMIT ${s ?? ie}`) : "", l = i !== void 0 ? T("offset", () => `OFFSET ${i}`) : "";
1045
+ const c = s !== void 0 || e === "mysql" ? y(s !== void 0 ? "limit" : {}, () => `LIMIT ${s ?? Ee}`) : "", l = i !== void 0 ? y("offset", () => `OFFSET ${i}`) : "";
997
1046
  u.push([c, l].filter(Boolean).join(" "));
998
1047
  }
999
1048
  return [...n, ...u].join(`
1000
1049
  `);
1001
1050
  }
1002
- function Ce(t, e, r = {}) {
1003
- const n = r.values ? Lt(t, r.values) : t, s = r.schema ? et(n, r.schema).query : n;
1004
- return $t(lt(s, r), e);
1051
+ function de(t, e, r = {}) {
1052
+ const n = r.values ? Ut(t, r.values) : t, s = r.schema ? it(n, r.schema).query : n;
1053
+ return pt(yt(s, r), e);
1005
1054
  }
1006
- function oe(t, e) {
1055
+ function Te(t, e) {
1007
1056
  switch (t) {
1008
1057
  case "mysql":
1009
1058
  return "?";
@@ -1015,42 +1064,42 @@ function oe(t, e) {
1015
1064
  return "?";
1016
1065
  }
1017
1066
  }
1018
- function Le(t, e, r = {}) {
1019
- const n = r.schema ? et(t, r.schema) : { query: t, params: /* @__PURE__ */ new Map() }, s = {
1067
+ function Be(t, e, r = {}) {
1068
+ const n = r.schema ? it(t, r.schema) : { query: t, params: /* @__PURE__ */ new Map() }, s = {
1020
1069
  values: [],
1021
1070
  named: new Map(Object.entries(r.values ?? {}).map(([u, c]) => {
1022
1071
  const l = n.params.get(u);
1023
- return [u, l ? tt(c, l) : c];
1072
+ return [u, l ? st(c, l) : c];
1024
1073
  }))
1025
- }, i = lt(n.query, r), a = $t(i, e, s), o = [];
1026
- return { sql: a.replace(Xt, (u, c) => {
1074
+ }, i = yt(n.query, r), a = pt(i, e, s), o = [];
1075
+ return { sql: a.replace(ee, (u, c) => {
1027
1076
  const l = s.values[Number(c)];
1028
- return o.push(l instanceof Date ? J(l) : l), oe(e, o.length);
1077
+ return o.push(l instanceof Date ? Z(l) : l), Te(e, o.length);
1029
1078
  }), params: o };
1030
1079
  }
1031
1080
  export {
1032
- Se as D,
1033
- q as Q,
1034
- wt as S,
1035
- Le as a,
1036
- Ce as b,
1037
- Ut as c,
1038
- Ae as d,
1039
- Te as e,
1040
- ge as f,
1041
- pe as g,
1042
- Y as h,
1043
- Oe as i,
1044
- Ee as j,
1045
- Ne as k,
1046
- me as l,
1047
- De as m,
1048
- h as n,
1049
- Re as o,
1050
- he as p,
1051
- Ie as q,
1052
- ye as r,
1053
- le as s,
1054
- $e as u,
1055
- be as w
1081
+ qe as D,
1082
+ B as Q,
1083
+ dt as S,
1084
+ Be as a,
1085
+ de as b,
1086
+ Pt as c,
1087
+ Re as d,
1088
+ Ne as e,
1089
+ Ie as f,
1090
+ Se as g,
1091
+ k as h,
1092
+ Me as i,
1093
+ De as j,
1094
+ Le as k,
1095
+ be as l,
1096
+ Ce as m,
1097
+ R as n,
1098
+ Fe as o,
1099
+ we as p,
1100
+ Ue as q,
1101
+ Oe as r,
1102
+ ge as s,
1103
+ he as u,
1104
+ ve as w
1056
1105
  };
package/dist/core.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { D as e, E as r, M as o, b as n, f as i, a as d, h as t, i as u, v as l } from "./schema-z95dxLxu.js";
2
- import { M as m, a as E, b as T, Q as y, I as c, S as h, d as p, p as Q, e as _, f as U, g as b, c as A, h as M, K as N, B as D, q as I, k as B, t as f, v, m as L, G as C, H as R, w as F, r as G, x as q, i as x, C as H, E as P, F as g, y as k, s as O, z as X, A as Y, j, o as J, l as w, n as K, u as z, J as W } from "./issueLocation-Cw5sttQL.js";
2
+ import { M as m, a as E, b as T, Q as y, I as c, S as h, d as p, p as Q, e as _, f as U, g as b, c as A, h as M, K as N, B as D, q as I, k as B, t as f, v, m as L, G as C, H as R, w as F, r as G, x as q, i as x, C as H, E as P, F as g, y as k, s as O, z as X, A as Y, j, o as J, l as w, n as K, u as z, J as W } from "./issueLocation-CWUdTtCh.js";
3
3
  import { c as Z, f as $, i as aa } from "./calendarDate-CYlr9TvX.js";
4
- import { D as ea, q as ra, Q as oa, n as na, S as ia, c as da, d as ta, e as ua, f as la, g as Sa, a as ma, b as Ea, h as Ta, o as ya, r as ca, i as ha, p as pa, s as Qa, j as _a, k as Ua, l as ba, m as Aa, u as Ma } from "./core-api-BDCnbFHY.js";
4
+ import { D as ea, q as ra, Q as oa, n as na, S as ia, c as da, d as ta, e as ua, f as la, g as Sa, a as ma, b as Ea, h as Ta, o as ya, r as ca, i as ha, p as pa, s as Qa, j as _a, k as Ua, l as ba, m as Aa, u as Ma } from "./core-api-DcJQGdVP.js";
5
5
  export {
6
6
  e as DEFAULT_FUNCTIONS,
7
7
  ea as DIALECTS,
package/dist/index.js CHANGED
@@ -1,9 +1,9 @@
1
- import { P as Q, f as U, a as D } from "./PipelineEditor-DNZkDSaY.js";
1
+ import { P as Q, f as U, a as D } from "./PipelineEditor-BoFPDUmi.js";
2
2
  import { D as b, E as x, M as B, b as F, f as I, a as v, h as L, i as P, v as R } from "./schema-z95dxLxu.js";
3
- import { D as k, M as q, a as C, b as G, Q as H, I as w, S as X, d as W, p as Y, e as j, f as J, g as z, c as K, h as V, K as Z, B as $, q as ee, k as ae, t as se, v as te, m as re, G as ne, H as oe, w as ie, r as de, x as ce, i as ue, C as le, E as fe, F as me, y as he, s as pe, z as Se, A as Ee, j as Te, o as ge, l as Ne, n as _e, u as ye, J as Ae } from "./issueLocation-Cw5sttQL.js";
3
+ import { D as k, M as q, a as C, b as G, Q as H, I as w, S as X, d as W, p as Y, e as j, f as J, g as z, c as K, h as V, K as Z, B as $, q as ee, k as ae, t as se, v as te, m as re, G as ne, H as oe, w as ie, r as de, x as ce, i as ue, C as le, E as fe, F as me, y as he, s as pe, z as Se, A as Ee, j as Te, o as ge, l as Ne, n as _e, u as ye, J as Ae } from "./issueLocation-CWUdTtCh.js";
4
4
  import { c as Ue, f as De, i as Me } from "./calendarDate-CYlr9TvX.js";
5
- import { w as m, a as h, b as p } from "./core-api-BDCnbFHY.js";
6
- import { D as xe, q as Be, Q as Fe, n as Ie, S as ve, c as Le, d as Pe, e as Re, f as Oe, g as ke, h as qe, o as Ce, r as Ge, i as He, p as we, s as Xe, j as We, k as Ye, l as je, m as Je, u as ze } from "./core-api-BDCnbFHY.js";
5
+ import { w as m, a as h, b as p } from "./core-api-DcJQGdVP.js";
6
+ import { D as xe, q as Be, Q as Fe, n as Ie, S as ve, c as Le, d as Pe, e as Re, f as Oe, g as ke, h as qe, o as Ce, r as Ge, i as He, p as we, s as Xe, j as We, k as Ye, l as je, m as Je, u as ze } from "./core-api-DcJQGdVP.js";
7
7
  import { D as Ve } from "./tokens-BTaVMSOx.js";
8
8
  function T(n, s, e = {}) {
9
9
  const a = { paths: [] }, t = m(a, () => e.parameterized ? h(n, s, e).sql : p(n, s, e));
@@ -3123,7 +3123,7 @@ export {
3123
3123
  ti as a8,
3124
3124
  ls as a9,
3125
3125
  ne as aA,
3126
- de as aB,
3126
+ Ee as aB,
3127
3127
  Ve as aC,
3128
3128
  ke as aD,
3129
3129
  en as aE,
package/dist/mui.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { jsx as n, jsxs as P } from "react/jsx-runtime";
2
2
  import { useMemo as H, useState as w, useRef as A, useLayoutEffect as G } from "react";
3
- import { P as K } from "./PipelineEditor-DNZkDSaY.js";
3
+ import { P as K } from "./PipelineEditor-BoFPDUmi.js";
4
4
  import Q from "@emotion/cache";
5
5
  import { CacheProvider as U } from "@emotion/react";
6
6
  import { TextField as R, Menu as J, ListSubheader as _, MenuItem as $, Box as y, createFilterOptions as X, Autocomplete as D, Select as Y, InputBase as Z, Button as ee, IconButton as te, Tooltip as oe, Chip as re } from "@mui/material";
@@ -131,6 +131,7 @@ export type PipelineAction = {
131
131
  } | {
132
132
  type: 'clearPaging';
133
133
  };
134
+ export declare function generateJoinId(): string;
134
135
  /** Every distinct table referenced by a field in `ast` (deduplicated, in first-seen
135
136
  * order) — used to auto-add tables to the pipeline as a WHERE condition references
136
137
  * them. Only fields with an explicit `.table` count — an unqualified field doesn't
@@ -18,7 +18,10 @@ export declare class ScopeError extends Error {
18
18
  readonly path: (string | number)[];
19
19
  /** The table it reads that needs scope. */
20
20
  readonly table: string;
21
- constructor(path: (string | number)[], table: string, missing: string);
21
+ /** The alias that copy of the table goes by, when it has one (a self
22
+ * join reads a table more than once, issue 216). */
23
+ readonly alias?: string;
24
+ constructor(path: (string | number)[], table: string, missing: string, alias?: string);
22
25
  }
23
26
  /** `query` with `rule.condition` in **every** body that reads a table
24
27
  * `rule.requires` accepts (issue 151): the query itself, each derived
@@ -35,11 +38,14 @@ export declare class ScopeError extends Error {
35
38
  * left out is exactly the leak.
36
39
  * Call it after validateQuery, on the checked query. */
37
40
  export declare function scopeQuery(schema: DatabaseSchema, query: QueryPipeline, rule: ScopeRule): QueryPipeline;
38
- /** Every body of `query` that reads a table `rule.requires` accepts without
39
- * `rule.condition` ANDed at the top of its WHERE — where it is, and the
40
- * table. Empty: `query` is scoped everywhere (see scopeQuery). For a query
41
- * built or received some other way. */
42
- export declare function unscopedBodies(query: QueryPipeline, rule: ScopeRule): {
41
+ /** Every copy of a table `rule.requires` accepts, in every body of `query`,
42
+ * that isn't scoped: the condition's tables not joined through it, or the
43
+ * condition naming them not ANDed at the top of its WHERE — where it is,
44
+ * the table, and the alias that copy goes by (a self join reads a table
45
+ * more than once, issue 216). Empty: `query` is scoped everywhere (see
46
+ * scopeQuery). For a query built or received some other way. */
47
+ export declare function unscopedBodies(schema: DatabaseSchema, query: QueryPipeline, rule: ScopeRule): {
43
48
  path: (string | number)[];
44
49
  table: string;
50
+ alias?: string;
45
51
  }[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nongt/visql",
3
- "version": "0.3.1",
3
+ "version": "0.4.0",
4
4
  "description": "A visual SQL query editor for React: build a whole query on a node canvas, store it as JSON, turn it into SQL.",
5
5
  "keywords": [
6
6
  "sql",