@nongt/visql-core 0.6.1 → 0.7.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.
@@ -1,8 +1,8 @@
1
1
  var qt = Object.defineProperty;
2
2
  var Ut = (t, e, r) => e in t ? qt(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
3
3
  var M = (t, e, r) => Ut(t, typeof e != "symbol" ? e + "" : e, r);
4
- import { q as U, g as B, F as vt, G as Bt, o as K, d as nt, t as ft, h as jt, w as lt, H as _t, k as Ht, b as Yt, i as Pt } from "./schema-z95dxLxu.js";
5
- import { ai as R, aC as k, aD as Gt, aE as xt, aF as kt, al as Qt, V as Xt, ar as Vt, aG as A, an as Wt, a8 as Jt, aH as Kt, aI as $t, $ as zt } from "./issueLocation-BcILIZqd.js";
4
+ import { q as U, g as B, F as vt, G as Bt, o as K, d as nt, t as ft, h as jt, w as lt, H as _t, k as Ht, b as Yt, i as Pt } from "./schema-DFC26AhZ.js";
5
+ import { aj as R, aD as k, aE as Gt, aF as xt, aG as kt, am as Qt, V as Xt, as as Jt, aH as A, ao as Vt, a8 as Wt, aI as Kt, aJ as $t, $ as zt } from "./issueLocation-732-e0B8.js";
6
6
  import { s as Et } from "./calendarDate-CYlr9TvX.js";
7
7
  class Zt extends Error {
8
8
  constructor(r, n, s, o) {
@@ -269,7 +269,7 @@ function se(t, e, r, n = {}) {
269
269
  }
270
270
  const a = n.operator ?? "AND", { where: i } = e;
271
271
  let c;
272
- return i ? i.type === "logical" && i.operator === a ? c = { ...i, operands: [...i.operands, r] } : c = { type: "logical", operator: a, operands: [i, r] } : c = r, R(t, e, Vt(t, e, c));
272
+ return i ? i.type === "logical" && i.operator === a ? c = { ...i, operands: [...i.operands, r] } : c = { type: "logical", operator: a, operands: [i, r] } : c = r, R(t, e, Jt(t, e, c));
273
273
  }
274
274
  function Ye(t, e, r, n) {
275
275
  const s = A(t, e, { type: "addSelectItem" }), o = s.select[s.select.length - 1].id, a = A(t, s, {
@@ -288,7 +288,7 @@ function Pe(t, e, r) {
288
288
  return R(t, e, o);
289
289
  }
290
290
  function Ge(t, e, r) {
291
- return R(t, e, Wt(t, e, r));
291
+ return R(t, e, Vt(t, e, r));
292
292
  }
293
293
  function xe(t, e, r, n = "asc") {
294
294
  const s = A(t, e, { type: "addOrderByItem" }), { id: o } = s.orderBy[s.orderBy.length - 1], a = A(t, s, {
@@ -377,13 +377,13 @@ function $e(t) {
377
377
  }
378
378
  return { ...r, value: s };
379
379
  }
380
- function Ve(t) {
380
+ function Je(t) {
381
381
  return {
382
382
  version: X,
383
383
  query: _(t, le)
384
384
  };
385
385
  }
386
- function We(t) {
386
+ function Ve(t) {
387
387
  if (!q(t))
388
388
  throw new w("invalid", "a stored query is an object");
389
389
  const { version: e } = t;
@@ -399,7 +399,7 @@ function We(t) {
399
399
  throw new w("invalid", "a stored query has a query with a string id");
400
400
  return _(r, $e);
401
401
  }
402
- function V(t, e) {
402
+ function J(t, e) {
403
403
  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);
404
404
  return t.forEach(({ table: o, alias: a }) => {
405
405
  if (o === void 0) {
@@ -429,7 +429,7 @@ function F(t, e, r) {
429
429
  }
430
430
  if (t.type === "subquery") return { ...t, query: Y(t.query, r) };
431
431
  if (t.type === "exists") {
432
- const { query: n } = t, s = [n.from, ...n.joins], o = V(s), a = V(s, e);
432
+ const { query: n } = t, s = [n.from, ...n.joins], o = J(s), a = J(s, e);
433
433
  return {
434
434
  ...t,
435
435
  link: F(t.link, a, r),
@@ -444,7 +444,7 @@ function F(t, e, r) {
444
444
  return K(t, (n) => F(n, e, r));
445
445
  }
446
446
  function Y(t, e) {
447
- const r = V([t.from, ...t.joins]), n = lt(
447
+ const r = J([t.from, ...t.joins]), n = lt(
448
448
  t,
449
449
  (s) => F(s, r, e),
450
450
  (s) => Y(s, e)
@@ -455,11 +455,11 @@ function Y(t, e) {
455
455
  joins: n.joins.map((s) => s.table === void 0 ? s : { ...s, table: e(s.table) })
456
456
  };
457
457
  }
458
- function W(t, e) {
459
- if (Array.isArray(t)) return t.map((s) => W(s, e));
458
+ function V(t, e) {
459
+ if (Array.isArray(t)) return t.map((s) => V(s, e));
460
460
  if (typeof t != "object" || t === null || t instanceof Date) return t;
461
461
  const r = Object.fromEntries(Object.entries(t).map(
462
- ([s, o]) => [s, W(o, e)]
462
+ ([s, o]) => [s, V(o, e)]
463
463
  ));
464
464
  if (!("from" in r) || !Array.isArray(r.joins)) return r;
465
465
  const n = (s) => s.table !== void 0 && !s.alias && e(s.table) !== s.table ? { ...s, alias: s.table } : s;
@@ -470,7 +470,7 @@ function W(t, e) {
470
470
  };
471
471
  }
472
472
  function ye(t, e) {
473
- return Y(W(t, e), e);
473
+ return Y(V(t, e), e);
474
474
  }
475
475
  const pe = /^(\d{2}):(\d{2})(?::(\d{2}))?$/, ut = /YYYY|MM|DD|HH|mm|ss/g, C = (t, e = 2) => String(t).padStart(e, "0");
476
476
  function ht(t, e) {
@@ -479,7 +479,7 @@ function ht(t, e) {
479
479
  if (n)
480
480
  r = { HH: n[1], mm: n[2], ss: n[3] ?? "00" };
481
481
  else {
482
- const a = typeof t == "string" ? Jt(t, "dateTime") : t;
482
+ const a = typeof t == "string" ? Wt(t, "dateTime") : t;
483
483
  a instanceof Date && (r = {
484
484
  YYYY: C(a.getUTCFullYear(), 4),
485
485
  MM: C(a.getUTCMonth() + 1),
@@ -527,7 +527,7 @@ function Ot(t, e) {
527
527
  };
528
528
  return { query: n(t), params: r };
529
529
  }
530
- const Je = ["mysql", "mssql", "postgres"], Ke = {
530
+ const We = ["mysql", "mssql", "postgres"], Ke = {
531
531
  mysql: "MySQL",
532
532
  mssql: "SQL Server",
533
533
  postgres: "PostgreSQL"
@@ -1048,10 +1048,10 @@ function Ce(t, e, r, n) {
1048
1048
  ${t.map((o) => T(o, () => `${E(n(o.expression), e, 1, r)} ${o.direction === "desc" ? "DESC" : "ASC"}`)).join(`,
1049
1049
  `)}`;
1050
1050
  }
1051
- const J = (t) => t !== void 0 && Number.isInteger(t) && t >= 0 ? t : void 0;
1051
+ const W = (t) => t !== void 0 && Number.isInteger(t) && t >= 0 ? t : void 0;
1052
1052
  function Mt(t, e) {
1053
1053
  const r = e.resolveName ? ye(t, e.resolveName) : t;
1054
- return e.defaultLimit !== void 0 && J(r.limit) === void 0 ? { ...r, limit: e.defaultLimit } : r;
1054
+ return e.defaultLimit !== void 0 && W(r.limit) === void 0 ? { ...r, limit: e.defaultLimit } : r;
1055
1055
  }
1056
1056
  const we = "18446744073709551615";
1057
1057
  function z(t, e, r, n = `SELECT${t.distinct ? " DISTINCT" : ""}`) {
@@ -1070,7 +1070,7 @@ function z(t, e, r, n = `SELECT${t.distinct ? " DISTINCT" : ""}`) {
1070
1070
  }
1071
1071
  function dt(t, e, r) {
1072
1072
  I && (I.writing = [{ value: t, path: [] }]), Rt = new Map((t.shared ?? []).map((f) => [f.id, f.name]));
1073
- const n = Se(t.shared ?? [], e, r), s = J(t.limit), o = J(t.offset) || void 0, a = t.orderBy ?? [], i = e === "mssql" && s !== void 0 && o === void 0, c = `SELECT${t.distinct ? " DISTINCT" : ""}${i ? ` ${T("limit", () => `TOP (${s})`)}` : ""}`, u = z(t, e, r, c);
1073
+ const n = Se(t.shared ?? [], e, r), s = W(t.limit), o = W(t.offset) || void 0, a = t.orderBy ?? [], i = e === "mssql" && s !== void 0 && o === void 0, c = `SELECT${t.distinct ? " DISTINCT" : ""}${i ? ` ${T("limit", () => `TOP (${s})`)}` : ""}`, u = z(t, e, r, c);
1074
1074
  if (a.length > 0 && u.push(Ce(a, e, r, (f) => e === "mysql" ? $t(f, t) : f)), e === "mssql") {
1075
1075
  if (o !== void 0) {
1076
1076
  a.length === 0 && u.push("ORDER BY (SELECT NULL)");
@@ -1114,7 +1114,7 @@ function tr(t, e, r = {}) {
1114
1114
  }), params: i };
1115
1115
  }
1116
1116
  export {
1117
- Je as D,
1117
+ We as D,
1118
1118
  X as Q,
1119
1119
  Zt as S,
1120
1120
  tr as a,
@@ -1131,8 +1131,8 @@ export {
1131
1131
  Ge as l,
1132
1132
  ke as m,
1133
1133
  w as n,
1134
- We as o,
1135
- Ve as p,
1134
+ Ve as o,
1135
+ Je as p,
1136
1136
  Ke as q,
1137
1137
  He as r,
1138
1138
  ve as s,
package/dist/core.js CHANGED
@@ -1,7 +1,7 @@
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-BcILIZqd.js";
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-DFC26AhZ.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-732-e0B8.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-D4QbGLG-.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-BsEMnDQ1.js";
5
5
  export {
6
6
  e as DEFAULT_FUNCTIONS,
7
7
  ea as DIALECTS,
@@ -1,4 +1,4 @@
1
- import { D as $e, h as ue, q as Q, t as D, i as H, s as Xn, l as le, u as Kn, w as Pe, e as Ve, x as dn, k as z, r as fe, o as xe, j as K, y as Yn, d as W, z as Jt, A as me, B as Be, C as Pt, M as Y, F as zn, G as Vt, g as Z, H as We, I as fn, b as be, J as Zn, n as Wt, K as et, f as Ht, L as Xt, N as Mn, O as On, P as Ge, Q as Kt } from "./schema-z95dxLxu.js";
1
+ import { D as $e, h as ue, q as Q, t as D, i as H, s as Xn, l as le, u as Kn, w as Pe, e as Ve, x as dn, k as z, r as fe, o as xe, j as K, y as Yn, d as W, z as Jt, A as Be, B as me, C as Pt, M as Y, F as zn, G as Vt, g as Z, H as We, I as fn, b as be, J as Zn, n as Wt, K as et, f as Ht, L as Xt, N as Mn, O as On, P as Ge, Q as Kt } from "./schema-DFC26AhZ.js";
2
2
  import { c as Yt, s as zt, b as nt } from "./calendarDate-CYlr9TvX.js";
3
3
  const Zt = 1e3, tt = 15, er = 40, ls = 100;
4
4
  function nr(e) {
@@ -354,6 +354,8 @@ const ar = {
354
354
  openUnionBranch: (e) => `Open ${e}'s query`,
355
355
  removeUnionBranch: (e) => `Remove ${e}'s query`,
356
356
  joinTableGroup: "Join a table",
357
+ /** The heading over tables in no group, when others have one. */
358
+ otherTablesGroup: "Other tables",
357
359
  /** Free-form unions (issue 153): a new one, the query as one's first
358
360
  * query, another query for one, and a new query's canvas. */
359
361
  createUnion: "Create Union",
@@ -3215,41 +3217,42 @@ export {
3215
3217
  nr as a7,
3216
3218
  vn as a8,
3217
3219
  ai as a9,
3218
- tr as aA,
3219
- rt as aB,
3220
- ne as aC,
3221
- Ae as aD,
3222
- Xe as aE,
3223
- Ce as aF,
3224
- tn as aG,
3225
- ni as aH,
3226
- zs as aI,
3227
- fs as aa,
3228
- Es as ab,
3229
- lt as ac,
3230
- Ss as ad,
3231
- vs as ae,
3232
- es as af,
3233
- Xr as ag,
3234
- at as ah,
3235
- Zs as ai,
3236
- us as aj,
3237
- Ns as ak,
3238
- mn as al,
3239
- pr as am,
3240
- ms as an,
3241
- hr as ao,
3242
- mr as ap,
3243
- He as aq,
3244
- Ts as ar,
3245
- Fn as as,
3246
- dt as at,
3247
- Fr as au,
3248
- _r as av,
3249
- oe as aw,
3250
- ds as ax,
3251
- ws as ay,
3252
- $s as az,
3220
+ $s as aA,
3221
+ tr as aB,
3222
+ rt as aC,
3223
+ ne as aD,
3224
+ Ae as aE,
3225
+ Xe as aF,
3226
+ Ce as aG,
3227
+ tn as aH,
3228
+ ni as aI,
3229
+ zs as aJ,
3230
+ ct as aa,
3231
+ fs as ab,
3232
+ vs as ac,
3233
+ Es as ad,
3234
+ lt as ae,
3235
+ Ss as af,
3236
+ es as ag,
3237
+ Xr as ah,
3238
+ at as ai,
3239
+ Zs as aj,
3240
+ us as ak,
3241
+ Ns as al,
3242
+ mn as am,
3243
+ pr as an,
3244
+ ms as ao,
3245
+ hr as ap,
3246
+ mr as aq,
3247
+ He as ar,
3248
+ Ts as as,
3249
+ Fn as at,
3250
+ dt as au,
3251
+ Fr as av,
3252
+ _r as aw,
3253
+ oe as ax,
3254
+ ds as ay,
3255
+ ws as az,
3253
3256
  er as b,
3254
3257
  ys as c,
3255
3258
  Us as d,
@@ -43,15 +43,15 @@ function Q(e) {
43
43
  }
44
44
  function T(e, t) {
45
45
  if (!v(e)) return t(e, 0);
46
- const r = e.union.map((a, u) => t(a, u));
47
- return r.every((a, u) => a === e.union[u]) ? e : { ...e, union: r };
46
+ const r = e.union.map((a, i) => t(a, i));
47
+ return r.every((a, i) => a === e.union[i]) ? e : { ...e, union: r };
48
48
  }
49
49
  function K(e, t) {
50
50
  if (!e.shared) return e;
51
51
  let r = !1;
52
- const a = e.shared.map((u) => {
53
- const n = t(u.query, u);
54
- return n === u.query ? u : (r = !0, { ...u, query: n });
52
+ const a = e.shared.map((i) => {
53
+ const n = t(i.query, i);
54
+ return n === i.query ? i : (r = !0, { ...i, query: n });
55
55
  });
56
56
  return r ? { ...e, shared: a } : e;
57
57
  }
@@ -135,20 +135,20 @@ function ee(e) {
135
135
  ];
136
136
  }
137
137
  function S(e, t, r = (a) => S(a, t)) {
138
- var n, l;
139
- const a = t, { shared: u } = e;
138
+ var n, s;
139
+ const a = t, { shared: i } = e;
140
140
  return {
141
141
  ...e,
142
- ...u ? {
143
- shared: u.map((s) => ({ ...s, query: T(s.query, r) }))
142
+ ...i ? {
143
+ shared: i.map((l) => ({ ...l, query: T(l.query, r) }))
144
144
  } : {},
145
145
  from: e.from.query ? { ...e.from, query: T(e.from.query, r) } : e.from,
146
146
  where: e.where && a(e.where),
147
- joins: e.joins.map((s) => s.query ? { ...s, on: s.on && a(s.on), query: T(s.query, r) } : { ...s, on: s.on && a(s.on) }),
148
- select: e.select.map((s) => ({ ...s, expression: a(s.expression) })),
149
- groupBy: (n = e.groupBy) == null ? void 0 : n.map((s) => ({ ...s, expression: a(s.expression) })),
147
+ joins: e.joins.map((l) => l.query ? { ...l, on: l.on && a(l.on), query: T(l.query, r) } : { ...l, on: l.on && a(l.on) }),
148
+ select: e.select.map((l) => ({ ...l, expression: a(l.expression) })),
149
+ groupBy: (n = e.groupBy) == null ? void 0 : n.map((l) => ({ ...l, expression: a(l.expression) })),
150
150
  having: e.having && a(e.having),
151
- orderBy: (l = e.orderBy) == null ? void 0 : l.map((s) => ({ ...s, expression: a(s.expression) }))
151
+ orderBy: (s = e.orderBy) == null ? void 0 : s.map((l) => ({ ...l, expression: a(l.expression) }))
152
152
  };
153
153
  }
154
154
  function w(e, t) {
@@ -169,7 +169,7 @@ const te = {
169
169
  "date-expr": ["date", "dateTime"],
170
170
  "num-expr": ["integer", "decimal"],
171
171
  "str-expr": ["varchar"]
172
- }, i = { type: "field" }, Y = [
172
+ }, u = { type: "field" }, Y = [
173
173
  "YEAR",
174
174
  "QUARTER",
175
175
  "MONTH",
@@ -205,32 +205,32 @@ const d = (e, t = "DAY") => ({
205
205
  label: "value",
206
206
  kind: "expr",
207
207
  optional: !0,
208
- default: i
208
+ default: u
209
209
  }]
210
210
  },
211
211
  SUM: {
212
212
  name: "SUM",
213
213
  returns: "number",
214
214
  aggregate: !0,
215
- args: [{ label: "value", kind: "num-expr", default: i }]
215
+ args: [{ label: "value", kind: "num-expr", default: u }]
216
216
  },
217
217
  AVG: {
218
218
  name: "AVG",
219
219
  returns: "number",
220
220
  aggregate: !0,
221
- args: [{ label: "value", kind: "num-expr", default: i }]
221
+ args: [{ label: "value", kind: "num-expr", default: u }]
222
222
  },
223
223
  MIN: {
224
224
  name: "MIN",
225
225
  returns: "arg",
226
226
  aggregate: !0,
227
- args: [{ label: "value", kind: "expr", default: i }]
227
+ args: [{ label: "value", kind: "expr", default: u }]
228
228
  },
229
229
  MAX: {
230
230
  name: "MAX",
231
231
  returns: "arg",
232
232
  aggregate: !0,
233
- args: [{ label: "value", kind: "expr", default: i }]
233
+ args: [{ label: "value", kind: "expr", default: u }]
234
234
  },
235
235
  // A group's values joined into one text (issue 137). Written in each
236
236
  // dialect's own form (see sqlGen); `distinct` on the call joins the
@@ -242,7 +242,7 @@ const d = (e, t = "DAY") => ({
242
242
  aggregate: !0,
243
243
  aliases: ["GROUP_CONCAT", "LISTAGG"],
244
244
  args: [
245
- { label: "value", kind: "expr", default: i },
245
+ { label: "value", kind: "expr", default: u },
246
246
  {
247
247
  label: "separator",
248
248
  kind: "fixed-text",
@@ -256,7 +256,7 @@ const d = (e, t = "DAY") => ({
256
256
  name: "DATE_ADD",
257
257
  returns: "arg",
258
258
  args: [
259
- { label: "date", kind: "date-expr", default: i },
259
+ { label: "date", kind: "date-expr", default: u },
260
260
  { label: "amount", kind: "num-expr", default: { type: "literal", value: 1 } },
261
261
  d("unit")
262
262
  ]
@@ -265,7 +265,7 @@ const d = (e, t = "DAY") => ({
265
265
  name: "DATE_SUB",
266
266
  returns: "arg",
267
267
  args: [
268
- { label: "date", kind: "date-expr", default: i },
268
+ { label: "date", kind: "date-expr", default: u },
269
269
  { label: "amount", kind: "num-expr", default: { type: "literal", value: 1 } },
270
270
  d("unit")
271
271
  ]
@@ -275,8 +275,8 @@ const d = (e, t = "DAY") => ({
275
275
  name: "DATEDIFF",
276
276
  returns: "integer",
277
277
  args: [
278
- { label: "start", kind: "date-expr", default: i },
279
- { label: "end", kind: "date-expr", default: i },
278
+ { label: "start", kind: "date-expr", default: u },
279
+ { label: "end", kind: "date-expr", default: u },
280
280
  d("unit")
281
281
  ]
282
282
  },
@@ -285,7 +285,7 @@ const d = (e, t = "DAY") => ({
285
285
  name: "EXTRACT",
286
286
  returns: "integer",
287
287
  args: [
288
- { label: "date", kind: "date-expr", default: i },
288
+ { label: "date", kind: "date-expr", default: u },
289
289
  d("unit", "YEAR")
290
290
  ]
291
291
  },
@@ -293,7 +293,7 @@ const d = (e, t = "DAY") => ({
293
293
  name: "DATE_TRUNC",
294
294
  returns: "arg",
295
295
  args: [
296
- { label: "date", kind: "date-expr", default: i },
296
+ { label: "date", kind: "date-expr", default: u },
297
297
  d("unit")
298
298
  ]
299
299
  },
@@ -301,7 +301,7 @@ const d = (e, t = "DAY") => ({
301
301
  CAST: {
302
302
  name: "CAST",
303
303
  args: [
304
- { label: "value", kind: "expr", default: i },
304
+ { label: "value", kind: "expr", default: u },
305
305
  {
306
306
  label: "type",
307
307
  kind: "type-name",
@@ -318,7 +318,7 @@ const d = (e, t = "DAY") => ({
318
318
  label: "value",
319
319
  kind: "expr",
320
320
  variadic: !0,
321
- default: i
321
+ default: u
322
322
  }
323
323
  ]
324
324
  },
@@ -326,7 +326,7 @@ const d = (e, t = "DAY") => ({
326
326
  name: "IFNULL",
327
327
  returns: "arg",
328
328
  args: [
329
- { label: "value", kind: "expr", default: i },
329
+ { label: "value", kind: "expr", default: u },
330
330
  { label: "fallback", kind: "expr", default: { type: "literal", value: null } }
331
331
  ]
332
332
  },
@@ -334,7 +334,7 @@ const d = (e, t = "DAY") => ({
334
334
  name: "NULLIF",
335
335
  returns: "arg",
336
336
  args: [
337
- { label: "value", kind: "expr", default: i },
337
+ { label: "value", kind: "expr", default: u },
338
338
  { label: "compare", kind: "expr", default: { type: "literal", value: "" } }
339
339
  ]
340
340
  },
@@ -347,7 +347,7 @@ const d = (e, t = "DAY") => ({
347
347
  label: "value",
348
348
  kind: "str-expr",
349
349
  variadic: !0,
350
- default: i
350
+ default: u
351
351
  }
352
352
  ]
353
353
  },
@@ -355,7 +355,7 @@ const d = (e, t = "DAY") => ({
355
355
  name: "SUBSTR",
356
356
  returns: "text",
357
357
  args: [
358
- { label: "string", kind: "str-expr", default: i },
358
+ { label: "string", kind: "str-expr", default: u },
359
359
  { label: "start", kind: "num-expr", default: { type: "literal", value: 1 } },
360
360
  {
361
361
  label: "length",
@@ -369,7 +369,7 @@ const d = (e, t = "DAY") => ({
369
369
  name: "REPLACE",
370
370
  returns: "text",
371
371
  args: [
372
- { label: "string", kind: "str-expr", default: i },
372
+ { label: "string", kind: "str-expr", default: u },
373
373
  { label: "find", kind: "str-expr", default: { type: "literal", value: "" } },
374
374
  { label: "replace", kind: "str-expr", default: { type: "literal", value: "" } }
375
375
  ]
@@ -379,7 +379,7 @@ const d = (e, t = "DAY") => ({
379
379
  name: "ROUND",
380
380
  returns: "number",
381
381
  args: [
382
- { label: "value", kind: "num-expr", default: i },
382
+ { label: "value", kind: "num-expr", default: u },
383
383
  {
384
384
  label: "decimals",
385
385
  kind: "num-expr",
@@ -392,7 +392,7 @@ const d = (e, t = "DAY") => ({
392
392
  name: "MOD",
393
393
  returns: "number",
394
394
  args: [
395
- { label: "value", kind: "num-expr", default: i },
395
+ { label: "value", kind: "num-expr", default: u },
396
396
  { label: "divisor", kind: "num-expr", default: { type: "literal", value: 1 } }
397
397
  ]
398
398
  },
@@ -401,21 +401,21 @@ const d = (e, t = "DAY") => ({
401
401
  name: "ABS",
402
402
  returns: "arg",
403
403
  args: [
404
- { label: "value", kind: "num-expr", default: i }
404
+ { label: "value", kind: "num-expr", default: u }
405
405
  ]
406
406
  },
407
407
  CEIL: {
408
408
  name: "CEIL",
409
409
  returns: "integer",
410
410
  args: [
411
- { label: "value", kind: "num-expr", default: i }
411
+ { label: "value", kind: "num-expr", default: u }
412
412
  ]
413
413
  },
414
414
  FLOOR: {
415
415
  name: "FLOOR",
416
416
  returns: "integer",
417
417
  args: [
418
- { label: "value", kind: "num-expr", default: i }
418
+ { label: "value", kind: "num-expr", default: u }
419
419
  ]
420
420
  },
421
421
  // ---- String (single-arg) ----
@@ -423,42 +423,42 @@ const d = (e, t = "DAY") => ({
423
423
  name: "LENGTH",
424
424
  returns: "integer",
425
425
  args: [
426
- { label: "string", kind: "str-expr", default: i }
426
+ { label: "string", kind: "str-expr", default: u }
427
427
  ]
428
428
  },
429
429
  LOWER: {
430
430
  name: "LOWER",
431
431
  returns: "text",
432
432
  args: [
433
- { label: "string", kind: "str-expr", default: i }
433
+ { label: "string", kind: "str-expr", default: u }
434
434
  ]
435
435
  },
436
436
  UPPER: {
437
437
  name: "UPPER",
438
438
  returns: "text",
439
439
  args: [
440
- { label: "string", kind: "str-expr", default: i }
440
+ { label: "string", kind: "str-expr", default: u }
441
441
  ]
442
442
  },
443
443
  LTRIM: {
444
444
  name: "LTRIM",
445
445
  returns: "text",
446
446
  args: [
447
- { label: "string", kind: "str-expr", default: i }
447
+ { label: "string", kind: "str-expr", default: u }
448
448
  ]
449
449
  },
450
450
  RTRIM: {
451
451
  name: "RTRIM",
452
452
  returns: "text",
453
453
  args: [
454
- { label: "string", kind: "str-expr", default: i }
454
+ { label: "string", kind: "str-expr", default: u }
455
455
  ]
456
456
  },
457
457
  TRIM: {
458
458
  name: "TRIM",
459
459
  returns: "text",
460
460
  args: [
461
- { label: "string", kind: "str-expr", default: i }
461
+ { label: "string", kind: "str-expr", default: u }
462
462
  ]
463
463
  },
464
464
  // ---- String (multi-arg) ----
@@ -466,7 +466,7 @@ const d = (e, t = "DAY") => ({
466
466
  name: "INSTR",
467
467
  returns: "integer",
468
468
  args: [
469
- { label: "string", kind: "str-expr", default: i },
469
+ { label: "string", kind: "str-expr", default: u },
470
470
  { label: "substring", kind: "str-expr", default: { type: "literal", value: "" } }
471
471
  ]
472
472
  },
@@ -474,7 +474,7 @@ const d = (e, t = "DAY") => ({
474
474
  name: "LEFT",
475
475
  returns: "text",
476
476
  args: [
477
- { label: "string", kind: "str-expr", default: i },
477
+ { label: "string", kind: "str-expr", default: u },
478
478
  { label: "length", kind: "num-expr", default: { type: "literal", value: 1 } }
479
479
  ]
480
480
  },
@@ -482,7 +482,7 @@ const d = (e, t = "DAY") => ({
482
482
  name: "RIGHT",
483
483
  returns: "text",
484
484
  args: [
485
- { label: "string", kind: "str-expr", default: i },
485
+ { label: "string", kind: "str-expr", default: u },
486
486
  { label: "length", kind: "num-expr", default: { type: "literal", value: 1 } }
487
487
  ]
488
488
  },
@@ -490,7 +490,7 @@ const d = (e, t = "DAY") => ({
490
490
  name: "SUBSTRING",
491
491
  returns: "text",
492
492
  args: [
493
- { label: "string", kind: "str-expr", default: i },
493
+ { label: "string", kind: "str-expr", default: u },
494
494
  { label: "start", kind: "num-expr", default: { type: "literal", value: 1 } },
495
495
  {
496
496
  label: "length",
@@ -504,7 +504,7 @@ const d = (e, t = "DAY") => ({
504
504
  CONVERT: {
505
505
  name: "CONVERT",
506
506
  args: [
507
- { label: "value", kind: "expr", default: i },
507
+ { label: "value", kind: "expr", default: u },
508
508
  { label: "type", kind: "type-name", default: { type: "literal", value: "INTEGER" } }
509
509
  ]
510
510
  },
@@ -524,56 +524,56 @@ const d = (e, t = "DAY") => ({
524
524
  name: "DATE",
525
525
  returns: "date",
526
526
  args: [
527
- { label: "expr", kind: "date-expr", default: i }
527
+ { label: "expr", kind: "date-expr", default: u }
528
528
  ]
529
529
  },
530
530
  TIME: {
531
531
  name: "TIME",
532
532
  returns: "time",
533
533
  args: [
534
- { label: "expr", kind: "date-expr", default: i }
534
+ { label: "expr", kind: "date-expr", default: u }
535
535
  ]
536
536
  },
537
537
  DAY: {
538
538
  name: "DAY",
539
539
  returns: "integer",
540
540
  args: [
541
- { label: "date", kind: "date-expr", default: i }
541
+ { label: "date", kind: "date-expr", default: u }
542
542
  ]
543
543
  },
544
544
  MONTH: {
545
545
  name: "MONTH",
546
546
  returns: "integer",
547
547
  args: [
548
- { label: "date", kind: "date-expr", default: i }
548
+ { label: "date", kind: "date-expr", default: u }
549
549
  ]
550
550
  },
551
551
  YEAR: {
552
552
  name: "YEAR",
553
553
  returns: "integer",
554
554
  args: [
555
- { label: "date", kind: "date-expr", default: i }
555
+ { label: "date", kind: "date-expr", default: u }
556
556
  ]
557
557
  },
558
558
  HOUR: {
559
559
  name: "HOUR",
560
560
  returns: "integer",
561
561
  args: [
562
- { label: "time", kind: "date-expr", default: i }
562
+ { label: "time", kind: "date-expr", default: u }
563
563
  ]
564
564
  },
565
565
  MINUTE: {
566
566
  name: "MINUTE",
567
567
  returns: "integer",
568
568
  args: [
569
- { label: "time", kind: "date-expr", default: i }
569
+ { label: "time", kind: "date-expr", default: u }
570
570
  ]
571
571
  },
572
572
  SECOND: {
573
573
  name: "SECOND",
574
574
  returns: "integer",
575
575
  args: [
576
- { label: "time", kind: "date-expr", default: i }
576
+ { label: "time", kind: "date-expr", default: u }
577
577
  ]
578
578
  }
579
579
  };
@@ -583,8 +583,8 @@ function k(e, t = h) {
583
583
  function ne(e, t) {
584
584
  const r = e.toUpperCase();
585
585
  return k(e, t) ?? Object.values(t).find((a) => {
586
- var u;
587
- return (u = a.aliases) == null ? void 0 : u.some((n) => n.toUpperCase() === r);
586
+ var i;
587
+ return (i = a.aliases) == null ? void 0 : i.some((n) => n.toUpperCase() === r);
588
588
  });
589
589
  }
590
590
  function j(e = h) {
@@ -608,8 +608,8 @@ function E(e, t) {
608
608
  if (e === t) return !0;
609
609
  if (e instanceof Date && t instanceof Date) return e.getTime() === t.getTime();
610
610
  if (typeof e != "object" || typeof t != "object" || e === null || t === null) return !1;
611
- const r = e, a = t, u = Object.keys(r).filter((l) => r[l] !== void 0), n = Object.keys(a).filter((l) => a[l] !== void 0);
612
- return u.length === n.length && u.every((l) => E(r[l], a[l]));
611
+ const r = e, a = t, i = Object.keys(r).filter((s) => r[s] !== void 0), n = Object.keys(a).filter((s) => a[s] !== void 0);
612
+ return i.length === n.length && i.every((s) => E(r[s], a[s]));
613
613
  }
614
614
  function F() {
615
615
  const e = globalThis.crypto.getRandomValues(new Uint8Array(12));
@@ -625,17 +625,17 @@ function p(e, t) {
625
625
  function O(e, t) {
626
626
  return e.type === "function" && e.name.trim() !== "" && k(e.name, t) === void 0;
627
627
  }
628
- function D(e, t) {
629
- return e ? O(e, t) || b(e).some((r) => D(r, t)) : !1;
628
+ function M(e, t) {
629
+ return e ? O(e, t) || b(e).some((r) => M(r, t)) : !1;
630
630
  }
631
631
  function g(e, t, r) {
632
632
  return t.some((a) => E(a, e)) ? !0 : e.type === "field" ? !e.column : e.type === "exists" ? G(e).every((a) => g(a, t, r)) : N(e, r) || O(e, r) ? !0 : b(e).every((a) => g(a, t, r));
633
633
  }
634
- function M(e, t) {
634
+ function D(e, t) {
635
635
  return (e.groupBy ?? []).length > 0 || e.having !== void 0 || [...e.select, ...e.orderBy ?? []].some((r) => p(r.expression, t));
636
636
  }
637
637
  function oe(e, t) {
638
- if (M(e, t))
638
+ if (D(e, t))
639
639
  return (e.groupBy ?? []).flatMap(({ expression: r }) => r.type === "field" && r.table && r.column ? [`${r.table}.${r.column}`] : []);
640
640
  }
641
641
  function H(e, t) {
@@ -645,16 +645,16 @@ function fe(e, t) {
645
645
  return e.select.some((r) => p(r.expression, t));
646
646
  }
647
647
  function ce(e, t) {
648
- const r = e.groupBy ?? [], a = r.filter((o) => o.fromSelect === void 0), u = H(e, t), n = a.map((o) => o.expression), l = u ? e.select.filter((o) => p(o.expression, t) || D(o.expression, t) || g(o.expression, n, t) ? !1 : (n.push(o.expression), !0)) : [], s = new Map(r.filter((o) => o.fromSelect !== void 0).map((o) => [o.fromSelect, o])), f = [];
648
+ const r = e.groupBy ?? [], a = r.filter((o) => o.fromSelect === void 0), i = H(e, t), n = a.map((o) => o.expression), s = i ? e.select.filter((o) => p(o.expression, t) || M(o.expression, t) || g(o.expression, n, t) ? !1 : (n.push(o.expression), !0)) : [], l = new Map(r.filter((o) => o.fromSelect !== void 0).map((o) => [o.fromSelect, o])), f = [];
649
649
  r.forEach((o) => {
650
650
  if (o.fromSelect === void 0) {
651
651
  f.push(o);
652
652
  return;
653
653
  }
654
- const m = l.find((U) => U.id === o.fromSelect);
654
+ const m = s.find((U) => U.id === o.fromSelect);
655
655
  m && f.push(E(o.expression, m.expression) ? o : { ...o, expression: m.expression });
656
656
  });
657
- const c = l.filter((o) => !s.has(o.id)).map((o) => ({
657
+ const c = s.filter((o) => !l.has(o.id)).map((o) => ({
658
658
  id: F(),
659
659
  expression: o.expression,
660
660
  fromSelect: o.id
@@ -663,78 +663,93 @@ function ce(e, t) {
663
663
  }
664
664
  function pe(e, t) {
665
665
  const r = (e.groupBy ?? []).map((n) => n.expression), a = e.orderBy ?? [];
666
- if (!M(e, t))
666
+ if (!D(e, t))
667
667
  return {
668
668
  select: [],
669
669
  selectAll: !1,
670
670
  orderBy: [],
671
671
  having: !1
672
672
  };
673
- const u = (n) => n.filter((l) => !g(l.expression, r, t)).map((l) => l.id);
673
+ const i = (n) => n.filter((s) => !g(s.expression, r, t)).map((s) => s.id);
674
674
  return {
675
- select: u(e.select),
675
+ select: i(e.select),
676
676
  selectAll: e.select.length === 0,
677
- orderBy: u(a),
677
+ orderBy: i(a),
678
678
  having: e.having !== void 0 && !g(e.having, r, t)
679
679
  };
680
680
  }
681
681
  const me = { tables: [], relations: [] };
682
682
  function de(e, t, r) {
683
683
  if (!t && !r) return e;
684
- const a = e.tables.filter((n) => !t || t(n)).map((n) => r ? { ...n, columns: n.columns.filter((l) => r(n, l)) } : n), u = new Set(a.map((n) => n.name));
684
+ const a = e.tables.filter((n) => !t || t(n)).map((n) => r ? { ...n, columns: n.columns.filter((s) => r(n, s)) } : n), i = new Set(a.map((n) => n.name));
685
685
  return {
686
686
  tables: a,
687
- relations: e.relations.filter((n) => u.has(n.fromTable) && u.has(n.toTable))
687
+ relations: e.relations.filter((n) => i.has(n.fromTable) && i.has(n.toTable))
688
688
  };
689
689
  }
690
690
  function ge(e) {
691
691
  return [...e.tables].sort((t, r) => t.label.localeCompare(r.label));
692
692
  }
693
+ function be(e, t = (a) => a.group, r = e) {
694
+ const a = /* @__PURE__ */ new Map();
695
+ r.forEach((n) => {
696
+ const s = t(n) || void 0;
697
+ s !== void 0 && !a.has(s) && a.set(s, []);
698
+ }), e.forEach((n) => {
699
+ const s = t(n) || void 0;
700
+ a.set(s, [...a.get(s) ?? [], n]);
701
+ });
702
+ const i = (n) => [...n].sort((s, l) => s.label.localeCompare(l.label));
703
+ return [
704
+ ...[...a].filter(([n]) => n !== void 0),
705
+ ...[...a].filter(([n]) => n === void 0)
706
+ ].filter(([, n]) => n.length > 0).map(([n, s]) => ({ group: n, tables: i(s) }));
707
+ }
693
708
  function _(e, t) {
694
709
  return e.tables.find((r) => r.name === t);
695
710
  }
696
711
  function $(e, t, r) {
697
712
  return e.relations.find((a) => a.fromTable === t && a.toTable === r || a.fromTable === r && a.toTable === t);
698
713
  }
699
- function be(e, t, r) {
714
+ function he(e, t, r) {
700
715
  if (t.includes(r)) return [];
701
- const a = /* @__PURE__ */ new Map(), u = new Set(t), n = [...t];
702
- for (; n.length > 0 && !u.has(r); ) {
716
+ const a = /* @__PURE__ */ new Map(), i = new Set(t), n = [...t];
717
+ for (; n.length > 0 && !i.has(r); ) {
703
718
  const f = n.shift();
704
719
  e.relations.filter((c) => c.fromTable === f || c.toTable === f).map((c) => c.fromTable === f ? c.toTable : c.fromTable).forEach((c) => {
705
- u.has(c) || (u.add(c), a.set(c, f), n.push(c));
720
+ i.has(c) || (i.add(c), a.set(c, f), n.push(c));
706
721
  });
707
722
  }
708
- if (!u.has(r)) return;
709
- const l = [];
710
- let s = r;
711
- for (; !t.includes(s); )
712
- l.unshift(s), s = a.get(s);
713
- return l;
714
- }
715
- function he(e, t) {
716
- const r = /* @__PURE__ */ new Map(), a = (l, s) => r.set(l, [...r.get(l) ?? [], s]);
717
- e.relations.forEach((l) => {
718
- a(l.fromTable, l.toTable), a(l.toTable, l.fromTable);
723
+ if (!i.has(r)) return;
724
+ const s = [];
725
+ let l = r;
726
+ for (; !t.includes(l); )
727
+ s.unshift(l), l = a.get(l);
728
+ return s;
729
+ }
730
+ function xe(e, t) {
731
+ const r = /* @__PURE__ */ new Map(), a = (s, l) => r.set(s, [...r.get(s) ?? [], l]);
732
+ e.relations.forEach((s) => {
733
+ a(s.fromTable, s.toTable), a(s.toTable, s.fromTable);
719
734
  });
720
- const u = new Set(t), n = [...t];
721
- for (let l = n.shift(); l !== void 0; l = n.shift())
722
- (r.get(l) ?? []).forEach((s) => {
723
- u.has(s) || (u.add(s), n.push(s));
735
+ const i = new Set(t), n = [...t];
736
+ for (let s = n.shift(); s !== void 0; s = n.shift())
737
+ (r.get(s) ?? []).forEach((l) => {
738
+ i.has(l) || (i.add(l), n.push(l));
724
739
  });
725
- return u;
740
+ return i;
726
741
  }
727
- function xe(e, t, r) {
728
- var s;
742
+ function Te(e, t, r) {
743
+ var l;
729
744
  const a = t.map((f) => $(e, f, r)).find((f) => f !== void 0);
730
745
  if (!a) return;
731
- const u = (s = _(e, a.fromTable)) == null ? void 0 : s.columns.find((f) => f.name === a.fromColumn), n = u != null && u.nullable ? "left" : "inner", l = {
746
+ const i = (l = _(e, a.fromTable)) == null ? void 0 : l.columns.find((f) => f.name === a.fromColumn), n = i != null && i.nullable ? "left" : "inner", s = {
732
747
  type: "binary",
733
748
  operator: "=",
734
749
  left: { type: "field", table: a.fromTable, column: a.fromColumn },
735
750
  right: { type: "field", table: a.toTable, column: a.toColumn }
736
751
  };
737
- return { joinType: n, on: l };
752
+ return { joinType: n, on: s };
738
753
  }
739
754
  const A = (e, t) => `${e}.${t}`;
740
755
  function P({ type: e, format: t }) {
@@ -746,70 +761,71 @@ function P({ type: e, format: t }) {
746
761
  if (e === "time" && r.some((a) => a === "YYYY" || a === "MM" || a === "DD"))
747
762
  return `a time has no day: format "${t}" can't be written from one`;
748
763
  }
749
- function Te(e) {
764
+ function ve(e) {
750
765
  const t = [], r = /* @__PURE__ */ new Map();
751
766
  e.tables.forEach((n) => {
752
767
  r.has(n.name) && t.push({
753
768
  kind: "duplicateTable",
754
769
  message: `Table "${n.name}" is declared more than once`
755
770
  }), r.set(n.name, n);
756
- const l = /* @__PURE__ */ new Set();
757
- n.columns.forEach((s) => {
758
- l.has(s.name) && t.push({
771
+ const s = /* @__PURE__ */ new Set();
772
+ n.columns.forEach((l) => {
773
+ s.has(l.name) && t.push({
759
774
  kind: "duplicateColumn",
760
- message: `Column "${n.name}.${s.name}" is declared more than once`
761
- }), l.add(s.name);
762
- const f = P(s);
775
+ message: `Column "${n.name}.${l.name}" is declared more than once`
776
+ }), s.add(l.name);
777
+ const f = P(l);
763
778
  f && t.push({
764
779
  kind: "invalidFormat",
765
- message: `Column "${n.name}.${s.name}": ${f}`
780
+ message: `Column "${n.name}.${l.name}": ${f}`
766
781
  });
767
782
  });
768
783
  });
769
- const a = (n, l) => {
770
- const s = r.get(n);
771
- s ? s.columns.some((f) => f.name === l) || t.push({
784
+ const a = (n, s) => {
785
+ const l = r.get(n);
786
+ l ? l.columns.some((f) => f.name === s) || t.push({
772
787
  kind: "unknownColumn",
773
- message: `Relation references unknown column "${n}.${l}"`
788
+ message: `Relation references unknown column "${n}.${s}"`
774
789
  }) : t.push({
775
790
  kind: "unknownTable",
776
791
  message: `Relation references unknown table "${n}"`
777
792
  });
778
- }, u = /* @__PURE__ */ new Set();
793
+ }, i = /* @__PURE__ */ new Set();
779
794
  return e.relations.forEach((n) => {
780
795
  a(n.fromTable, n.fromColumn), a(n.toTable, n.toColumn);
781
- const l = A(n.fromTable, n.fromColumn), s = A(n.toTable, n.toColumn), f = [l, s].sort().join(" <-> ");
782
- u.has(f) && t.push({
796
+ const s = A(n.fromTable, n.fromColumn), l = A(n.toTable, n.toColumn), f = [s, l].sort().join(" <-> ");
797
+ i.has(f) && t.push({
783
798
  kind: "duplicateRelation",
784
- message: `Relation ${l} -> ${s} is declared more than once (declare each foreign key once)`
785
- }), u.add(f);
799
+ message: `Relation ${s} -> ${l} is declared more than once (declare each foreign key once)`
800
+ }), i.add(f);
786
801
  }), t;
787
802
  }
788
803
  export {
789
- ge as A,
790
- q as B,
791
- he as C,
804
+ q as A,
805
+ ge as B,
806
+ xe as C,
792
807
  se as D,
793
808
  me as E,
794
- be as F,
795
- xe as G,
809
+ he as F,
810
+ Te as G,
796
811
  T as H,
797
812
  C as I,
798
813
  k as J,
799
814
  w as K,
800
815
  le as L,
801
816
  z as M,
802
- M as N,
817
+ D as N,
803
818
  W as O,
804
819
  re as P,
805
- D as Q,
820
+ M as Q,
806
821
  ie as R,
807
822
  j as S,
808
823
  te as T,
809
824
  ae as U,
810
- N as V,
811
- oe as W,
812
- fe as X,
825
+ be as V,
826
+ N as W,
827
+ oe as X,
828
+ fe as Y,
813
829
  ue as a,
814
830
  X as b,
815
831
  Y as c,
@@ -831,7 +847,7 @@ export {
831
847
  ee as s,
832
848
  I as t,
833
849
  pe as u,
834
- Te as v,
850
+ ve as v,
835
851
  S as w,
836
852
  K as x,
837
853
  B as y,
@@ -1,7 +1,7 @@
1
1
  var kt = Object.defineProperty;
2
2
  var Ct = (o, T, U) => T in o ? kt(o, T, { enumerable: !0, configurable: !0, writable: !0, value: U }) : o[T] = U;
3
3
  var gt = (o, T, U) => Ct(o, typeof T != "symbol" ? T + "" : T, U);
4
- import { c as Dt, d as nt, p as It, D as Ut, e as bt, g as Rt, j as Mt, q as qt, k as Nt, l as wt, m as xt, n as Ft, t as $t, o as Bt, r as Wt } from "./schema-z95dxLxu.js";
4
+ import { c as Dt, d as nt, p as It, D as Ut, e as bt, g as Rt, j as Mt, q as qt, k as Nt, l as wt, m as xt, n as Ft, t as $t, o as Bt, r as Wt } from "./schema-DFC26AhZ.js";
5
5
  import { t as Pt, f as _t, a as Gt } from "./calendarDate-CYlr9TvX.js";
6
6
  function Lt(o, T, U = T) {
7
7
  const L = o.slice(0, T);
@@ -113,6 +113,8 @@ export declare const DEFAULT_MESSAGES: {
113
113
  openUnionBranch: (table: string) => string;
114
114
  removeUnionBranch: (table: string) => string;
115
115
  joinTableGroup: string;
116
+ /** The heading over tables in no group, when others have one. */
117
+ otherTablesGroup: string;
116
118
  /** Free-form unions (issue 153): a new one, the query as one's first
117
119
  * query, another query for one, and a new query's canvas. */
118
120
  createUnion: string;
@@ -9,6 +9,13 @@ export interface Table {
9
9
  name: string;
10
10
  label: string;
11
11
  columns: TableColumn[];
12
+ /** The heading the table pickers list it under, such as its business
13
+ * area. Groups come in the order of their first table in the schema. */
14
+ group?: string;
15
+ /** A line under the label in the table pickers. The search matches it. */
16
+ description?: string;
17
+ /** Anything the host's own code needs about the table. Never read here. */
18
+ meta?: unknown;
12
19
  }
13
20
  export interface TableColumn {
14
21
  name: string;
@@ -75,6 +82,18 @@ export declare function filterSchema(schema: DatabaseSchema, tableFilter?: (tabl
75
82
  /** Every table in the schema, sorted by label — the canonical source for both
76
83
  * FieldView's column picker and FromFlowNode's table pickers. */
77
84
  export declare function allTables(schema: DatabaseSchema): Table[];
85
+ /** One heading's tables in a table picker: `group` undefined for the
86
+ * tables in no group. */
87
+ export interface TableGroup {
88
+ group: string | undefined;
89
+ tables: Table[];
90
+ }
91
+ /** `tables` as a table picker lists them (issue 245): the groups in the
92
+ * order of their first table in `order` (the whole schema, whose order the
93
+ * host decides, so every picker has its groups in the same order), the
94
+ * tables in each sorted by label, and the tables in no group last. With no
95
+ * group at all, one list sorted by label, as before. */
96
+ export declare function tableGroups(tables: readonly Table[], groupOf?: (table: Table) => string | undefined, order?: readonly Table[]): TableGroup[];
78
97
  export declare function findTable(schema: DatabaseSchema, name: string): Table | undefined;
79
98
  /** Every foreign key touching `tableName`, in either direction — whether it
80
99
  * holds the key or is referenced by one. */
@@ -14,7 +14,7 @@ export { relativeDateLabel } from './core/relativeDates.js';
14
14
  export { QUERY_FORMAT_VERSION, QueryFormatError, loadQuery, saveQuery, type StoredQuery, } from './core/storedQuery.js';
15
15
  export type { ResolveName } from './core/resolveNames.js';
16
16
  export { astToParameterizedSql, astToSql, DIALECTS, DIALECT_LABELS, type ParameterizedSql, type ParameterizedSqlOptions, type SqlDialect, } from './core/sqlGen.js';
17
- export { EMPTY_SCHEMA, filterSchema, validateSchema, type DatabaseColumnType, type DatabaseSchema, type ColumnOption, type Relation, type SchemaIssue, type SchemaIssueKind, type Table, type TableColumn, } from './core/schema.js';
17
+ export { EMPTY_SCHEMA, filterSchema, validateSchema, type DatabaseColumnType, type DatabaseSchema, type ColumnOption, type Relation, type SchemaIssue, type SchemaIssueKind, type Table, type TableColumn, type TableGroup, } from './core/schema.js';
18
18
  export { QUERY_ISSUE_KINDS, QUERY_WARNING_KINDS, validateQuery, type QueryIssue, type QueryIssueKind, type QueryWarningKind, type QueryIssueSeverity, type ValidateQueryOptions, } from './core/queryValidation.js';
19
19
  export { default as issueLocation, type IssueLocationStep } from './core/issueLocation.js';
20
20
  export { DEFAULT_FUNCTIONS, functionsForDialect, type ArgDef, type ArgKind, type FunctionRegistry, type FunctionSignature, } from './core/functionRegistry.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nongt/visql-core",
3
- "version": "0.6.1",
3
+ "version": "0.7.0",
4
4
  "description": "The query logic of @nongt/visql, for a backend: load, check, scope, write SQL, import SQL. No React, no dependencies.",
5
5
  "keywords": [
6
6
  "sql",