@nongt/visql 0.10.1 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/dist/{MuiTimePicker-DRqT6ByZ.js → MuiTimePicker-CROJXSCL.js} +1 -1
  2. package/dist/{PipelineEditor-CGTZGbmf.js → PipelineEditor-DEiKHDrr.js} +3646 -3514
  3. package/dist/core.js +137 -119
  4. package/dist/explain.js +3 -3
  5. package/dist/fixtures.js +1 -1
  6. package/dist/index.js +102 -110
  7. package/dist/issueLocation-Yn71qJyP.js +1141 -0
  8. package/dist/mui-date-pickers-host.js +1 -1
  9. package/dist/mui-date-pickers.js +1 -1
  10. package/dist/mui.js +2 -2
  11. package/dist/{params-DkVFbMQn.js → params-DVkfcD6D.js} +245 -229
  12. package/dist/{schema-CgL10bid.js → schema-CzKt6cN2.js} +230 -152
  13. package/dist/sql-import.js +855 -821
  14. package/dist/{sqlGen-C1kZwvWI.js → sqlGen-BoJXaULd.js} +331 -309
  15. package/dist/{tokens-DV5rTGMj.js → tokens-3SURLAkL.js} +15 -14
  16. package/dist/types/core/FunctionsContext.d.ts +8 -2
  17. package/dist/types/core/ast.d.ts +9 -1
  18. package/dist/types/core/components/flow/WindowKeys.d.ts +10 -0
  19. package/dist/types/core/expressionFlow.d.ts +8 -0
  20. package/dist/types/core/functionRegistry.d.ts +15 -2
  21. package/dist/types/core/grouping.d.ts +6 -1
  22. package/dist/types/core/i18n/defaultMessages.d.ts +16 -0
  23. package/dist/types/core/i18n/messages.d.ts +12 -0
  24. package/dist/types/core/issueLocation.d.ts +5 -0
  25. package/dist/types/core/queryHelpers.d.ts +9 -1
  26. package/dist/types/core/queryValidation.d.ts +11 -1
  27. package/dist/types/core/storedQuery.d.ts +1 -1
  28. package/dist/types/core/theme/appearance.d.ts +4 -1
  29. package/dist/types/core/theme/looks.d.ts +6 -5
  30. package/dist/types/core/theme/tokens.d.ts +6 -3
  31. package/dist/types/sqlImport/syntax.d.ts +11 -2
  32. package/package.json +1 -1
  33. package/dist/issueLocation-BlQ280IE.js +0 -1108
@@ -1,7 +1,12 @@
1
- function k(e) {
1
+ function v(e) {
2
2
  switch (e.type) {
3
+ // In the order the SQL writes them: arguments, PARTITION BY, ORDER BY.
3
4
  case "function":
4
- return e.orderBy ? [...e.args, ...e.orderBy.map((t) => t.expression)] : e.args;
5
+ return e.orderBy || e.partitionBy ? [
6
+ ...e.args,
7
+ ...e.partitionBy ?? [],
8
+ ...(e.orderBy ?? []).map((t) => t.expression)
9
+ ] : e.args;
5
10
  case "binary":
6
11
  return e.right ? [e.left, e.right] : [e.left];
7
12
  case "logical":
@@ -31,22 +36,22 @@ function k(e) {
31
36
  return [];
32
37
  }
33
38
  }
34
- const le = ["inner", "left", "right", "full", "cross"];
35
- function M(e) {
39
+ const oe = ["inner", "left", "right", "full", "cross"];
40
+ function D(e) {
36
41
  return "union" in e;
37
42
  }
38
- function ie(e) {
39
- return M(e) ? e.union : [e];
43
+ function fe(e) {
44
+ return D(e) ? e.union : [e];
40
45
  }
41
- function ue(e) {
42
- return M(e) ? e.union[0] : e;
46
+ function ce(e) {
47
+ return D(e) ? e.union[0] : e;
43
48
  }
44
- function w(e, t) {
45
- if (!M(e)) return t(e, 0);
49
+ function O(e, t) {
50
+ if (!D(e)) return t(e, 0);
46
51
  const n = e.union.map((r, i) => t(r, i));
47
52
  return n.every((r, i) => r === e.union[i]) ? e : { ...e, union: n };
48
53
  }
49
- function oe(e, t) {
54
+ function pe(e, t) {
50
55
  if (!e.shared) return e;
51
56
  let n = !1;
52
57
  const r = e.shared.map((i) => {
@@ -55,29 +60,30 @@ function oe(e, t) {
55
60
  });
56
61
  return n ? { ...e, shared: r } : e;
57
62
  }
58
- function fe(e) {
63
+ function de(e) {
59
64
  return "from" in e;
60
65
  }
61
- const ce = 63;
62
- function K(e) {
66
+ const me = 63;
67
+ function Q(e) {
63
68
  return e.alias || e.table || "";
64
69
  }
65
- function pe(e) {
70
+ function ge(e) {
66
71
  return e.alias ? e.alias : e.expression.type === "field" ? e.expression.column : void 0;
67
72
  }
68
- function Q(e) {
73
+ function J(e) {
69
74
  return [e.from, ...e.joins];
70
75
  }
71
- function de(e) {
72
- return Q(e).flatMap((t) => t.table === void 0 ? [] : [t.table]);
76
+ function be(e) {
77
+ return J(e).flatMap((t) => t.table === void 0 ? [] : [t.table]);
73
78
  }
74
- function $(e, t) {
79
+ function j(e, t) {
75
80
  const n = t;
76
81
  switch (e.type) {
77
82
  case "function":
78
83
  return {
79
84
  ...e,
80
85
  args: e.args.map(n),
86
+ ...e.partitionBy ? { partitionBy: e.partitionBy.map(n) } : {},
81
87
  ...e.orderBy ? { orderBy: e.orderBy.map((r) => ({ ...r, expression: n(r.expression) })) } : {}
82
88
  };
83
89
  case "binary":
@@ -120,11 +126,11 @@ function $(e, t) {
120
126
  return e;
121
127
  }
122
128
  }
123
- function j(e, t) {
124
- const n = $(e, (r) => j(r, t));
129
+ function $(e, t) {
130
+ const n = j(e, (r) => $(r, t));
125
131
  return n === e ? t(e) : n;
126
132
  }
127
- function me(e) {
133
+ function he(e) {
128
134
  return [
129
135
  ...e.where ? [e.where] : [],
130
136
  ...e.joins.flatMap((t) => t.on ? [t.on] : []),
@@ -134,42 +140,42 @@ function me(e) {
134
140
  ...(e.orderBy ?? []).map((t) => t.expression)
135
141
  ];
136
142
  }
137
- function _(e, t, n = (r) => _(r, t)) {
143
+ function F(e, t, n = (r) => F(r, t)) {
138
144
  var a, l;
139
145
  const r = t, { shared: i } = e;
140
146
  return {
141
147
  ...e,
142
148
  ...i ? {
143
- shared: i.map((s) => ({ ...s, query: w(s.query, n) }))
149
+ shared: i.map((s) => ({ ...s, query: O(s.query, n) }))
144
150
  } : {},
145
- from: e.from.query ? { ...e.from, query: w(e.from.query, n) } : e.from,
151
+ from: e.from.query ? { ...e.from, query: O(e.from.query, n) } : e.from,
146
152
  where: e.where && r(e.where),
147
- joins: e.joins.map((s) => s.query ? { ...s, on: s.on && r(s.on), query: w(s.query, n) } : { ...s, on: s.on && r(s.on) }),
153
+ joins: e.joins.map((s) => s.query ? { ...s, on: s.on && r(s.on), query: O(s.query, n) } : { ...s, on: s.on && r(s.on) }),
148
154
  select: e.select.map((s) => ({ ...s, expression: r(s.expression) })),
149
155
  groupBy: (a = e.groupBy) == null ? void 0 : a.map((s) => ({ ...s, expression: r(s.expression) })),
150
156
  having: e.having && r(e.having),
151
157
  orderBy: (l = e.orderBy) == null ? void 0 : l.map((s) => ({ ...s, expression: r(s.expression) }))
152
158
  };
153
159
  }
154
- function J(e, t) {
155
- const n = (r) => r.type === "subquery" ? { ...r, query: J(r.query, t) } : $(r, n);
156
- return _(e, (r) => j(n(r), t));
157
- }
158
- function z(e) {
159
- return new Set([e.from, ...e.joins].map(K));
160
+ function z(e, t) {
161
+ const n = (r) => r.type === "subquery" ? { ...r, query: z(r.query, t) } : j(r, n);
162
+ return F(e, (r) => $(n(r), t));
160
163
  }
161
164
  function Z(e) {
162
- return e !== void 0 && (e.type === "exists" || k(e).some(Z));
165
+ return new Set([e.from, ...e.joins].map(Q));
163
166
  }
164
167
  function q(e) {
165
- const t = z(e.query), n = (r) => r.type === "field" ? [r] : k(r).flatMap(n);
168
+ return e !== void 0 && (e.type === "exists" || v(e).some(q));
169
+ }
170
+ function ee(e) {
171
+ const t = Z(e.query), n = (r) => r.type === "field" ? [r] : v(r).flatMap(n);
166
172
  return n(e.link).filter((r) => r.table !== void 0 && !t.has(r.table));
167
173
  }
168
- const ge = {
174
+ const xe = {
169
175
  "date-expr": ["date", "dateTime"],
170
176
  "num-expr": ["integer", "decimal"],
171
177
  "str-expr": ["varchar"]
172
- }, u = { type: "field" }, ee = [
178
+ }, u = { type: "field" }, te = [
173
179
  "YEAR",
174
180
  "QUARTER",
175
181
  "MONTH",
@@ -180,18 +186,20 @@ const ge = {
180
186
  "SECOND",
181
187
  "MILLISECOND"
182
188
  ];
183
- function be(e, t) {
189
+ function ve(e, t) {
184
190
  if (t < e.args.length) return e.args[t];
185
191
  const n = e.args[e.args.length - 1];
186
192
  return n != null && n.variadic ? n : void 0;
187
193
  }
188
- function he(e) {
189
- return e.args.map((t) => t.default ?? { type: "literal", value: "" });
194
+ function ne(e) {
195
+ let t = e.args.length;
196
+ for (; t > 0 && e.args[t - 1].optional && !e.args[t - 1].default; ) t -= 1;
197
+ return e.args.slice(0, t).map((n) => n.default ?? { type: "literal", value: "" });
190
198
  }
191
199
  const T = (e, t = "DAY") => ({
192
200
  label: e,
193
201
  kind: "unit",
194
- choices: ee,
202
+ choices: te,
195
203
  default: { type: "literal", value: t }
196
204
  }), A = {
197
205
  // ---- Aggregate ----
@@ -251,6 +259,57 @@ const T = (e, t = "DAY") => ({
251
259
  }
252
260
  ]
253
261
  },
262
+ // ---- Window (issue 20) ----
263
+ // Each is written with OVER (PARTITION BY … ORDER BY …): see sqlGen.
264
+ // LAG / LEAD's offset is written into the SQL, MySQL taking nothing else.
265
+ LAG: {
266
+ name: "LAG",
267
+ returns: "arg",
268
+ window: !0,
269
+ args: [
270
+ { label: "value", kind: "expr", default: u },
271
+ {
272
+ label: "rows back",
273
+ kind: "fixed-count",
274
+ optional: !0,
275
+ default: { type: "literal", value: 1 }
276
+ },
277
+ { label: "default", kind: "expr", optional: !0 }
278
+ ]
279
+ },
280
+ LEAD: {
281
+ name: "LEAD",
282
+ returns: "arg",
283
+ window: !0,
284
+ args: [
285
+ { label: "value", kind: "expr", default: u },
286
+ {
287
+ label: "rows ahead",
288
+ kind: "fixed-count",
289
+ optional: !0,
290
+ default: { type: "literal", value: 1 }
291
+ },
292
+ { label: "default", kind: "expr", optional: !0 }
293
+ ]
294
+ },
295
+ ROW_NUMBER: {
296
+ name: "ROW_NUMBER",
297
+ returns: "integer",
298
+ window: !0,
299
+ args: []
300
+ },
301
+ RANK: {
302
+ name: "RANK",
303
+ returns: "integer",
304
+ window: !0,
305
+ args: []
306
+ },
307
+ DENSE_RANK: {
308
+ name: "DENSE_RANK",
309
+ returns: "integer",
310
+ window: !0,
311
+ args: []
312
+ },
254
313
  // ---- Date arithmetic ----
255
314
  DATE_ADD: {
256
315
  name: "DATE_ADD",
@@ -577,31 +636,42 @@ const T = (e, t = "DAY") => ({
577
636
  ]
578
637
  }
579
638
  };
580
- function D(e, t = A) {
639
+ function M(e, t = A) {
581
640
  return t[e.toUpperCase()];
582
641
  }
583
- function xe(e, t) {
642
+ function Te(e, t) {
584
643
  const n = e.toUpperCase();
585
- return D(e, t) ?? Object.values(t).find((r) => {
644
+ return M(e, t) ?? Object.values(t).find((r) => {
586
645
  var i;
587
646
  return (i = r.aliases) == null ? void 0 : i.some((a) => a.toUpperCase() === n);
588
647
  });
589
648
  }
590
- function te(e = A) {
649
+ function re(e = A) {
591
650
  return Object.keys(e).sort();
592
651
  }
593
- te(A);
594
- const Te = A;
595
- function ve(e) {
652
+ re(A);
653
+ const Ee = A;
654
+ function ke(e) {
596
655
  return Object.fromEntries(Object.values(e).map((t) => {
597
656
  const n = t.name.toUpperCase();
598
657
  return [n, { ...t, name: n }];
599
658
  }));
600
659
  }
601
- function ke(e) {
660
+ function we(e) {
602
661
  return Object.fromEntries(Object.entries(e).filter(([, t]) => !t.aggregate));
603
662
  }
604
- function Ee(e, t) {
663
+ function Ae(e, t) {
664
+ return {
665
+ type: "function",
666
+ name: t,
667
+ args: ne(e),
668
+ ...e.window && { over: !0 }
669
+ };
670
+ }
671
+ function Re(e) {
672
+ return Object.fromEntries(Object.entries(e).filter(([, t]) => !t.window));
673
+ }
674
+ function Se(e, t) {
605
675
  return Object.fromEntries(Object.entries(e).filter(([, n]) => !n.dialects || n.dialects.includes(t)));
606
676
  }
607
677
  function U(e, t) {
@@ -611,41 +681,45 @@ function U(e, t) {
611
681
  const n = e, r = t, i = Object.keys(n).filter((l) => n[l] !== void 0), a = Object.keys(r).filter((l) => r[l] !== void 0);
612
682
  return i.length === a.length && i.every((l) => U(n[l], r[l]));
613
683
  }
614
- function ne() {
684
+ function ae() {
615
685
  const e = globalThis.crypto.getRandomValues(new Uint8Array(12));
616
686
  return Array.from(e, (t) => t.toString(16).padStart(2, "0")).join("");
617
687
  }
618
- function F(e, t) {
688
+ function H(e, t) {
619
689
  var n;
620
- return e.type === "function" && ((n = D(e.name, t)) == null ? void 0 : n.aggregate) === !0;
690
+ return e.type === "function" && ((n = M(e.name, t)) == null ? void 0 : n.aggregate) === !0;
621
691
  }
622
692
  function x(e, t) {
623
- return e ? F(e, t) || k(e).some((n) => x(n, t)) : !1;
693
+ return e ? H(e, t) || v(e).some((n) => x(n, t)) : !1;
624
694
  }
625
- function H(e, t) {
626
- return e.type === "function" && e.name.trim() !== "" && D(e.name, t) === void 0;
695
+ const se = (e) => e.type === "function" && e.over === !0;
696
+ function I(e) {
697
+ return e ? se(e) || v(e).some(I) : !1;
627
698
  }
628
699
  function P(e, t) {
629
- return e ? H(e, t) || k(e).some((n) => P(n, t)) : !1;
630
- }
631
- function v(e, t, n) {
632
- return t.some((r) => U(r, e)) ? !0 : e.type === "field" ? !e.column : e.type === "exists" ? q(e).every((r) => v(r, t, n)) : F(e, n) || H(e, n) ? !0 : k(e).every((r) => v(r, t, n));
700
+ return e.type === "function" && e.name.trim() !== "" && M(e.name, t) === void 0;
633
701
  }
634
702
  function W(e, t) {
703
+ return e ? P(e, t) || v(e).some((n) => W(n, t)) : !1;
704
+ }
705
+ function E(e, t, n) {
706
+ return t.some((r) => U(r, e)) ? !0 : e.type === "field" ? !e.column : e.type === "exists" ? ee(e).every((r) => E(r, t, n)) : H(e, n) || P(e, n) ? !0 : v(e).every((r) => E(r, t, n));
707
+ }
708
+ function K(e, t) {
635
709
  return (e.groupBy ?? []).length > 0 || e.having !== void 0 || [...e.select, ...e.orderBy ?? []].some((n) => x(n.expression, t));
636
710
  }
637
- function Se(e, t) {
638
- if (W(e, t))
711
+ function ye(e, t) {
712
+ if (K(e, t))
639
713
  return (e.groupBy ?? []).flatMap(({ expression: n }) => n.type === "field" && n.table && n.column ? [`${n.table}.${n.column}`] : []);
640
714
  }
641
- function re(e, t) {
715
+ function le(e, t) {
642
716
  return x(e.having, t) || [...e.select, ...e.orderBy ?? []].some((n) => x(n.expression, t));
643
717
  }
644
- function Ae(e, t) {
718
+ function Ce(e, t) {
645
719
  return e.select.some((n) => x(n.expression, t));
646
720
  }
647
- function Re(e, t) {
648
- const n = e.groupBy ?? [], r = n.filter((o) => o.fromSelect === void 0), i = re(e, t), a = r.map((o) => o.expression), l = i ? e.select.filter((o) => x(o.expression, t) || P(o.expression, t) || v(o.expression, a, t) ? !1 : (a.push(o.expression), !0)) : [], s = new Map(n.filter((o) => o.fromSelect !== void 0).map((o) => [o.fromSelect, o])), c = [];
721
+ function Oe(e, t) {
722
+ const n = e.groupBy ?? [], r = n.filter((o) => o.fromSelect === void 0), i = le(e, t), a = r.map((o) => o.expression), l = i ? e.select.filter((o) => x(o.expression, t) || I(o.expression) || W(o.expression, t) || E(o.expression, a, t) ? !1 : (a.push(o.expression), !0)) : [], s = new Map(n.filter((o) => o.fromSelect !== void 0).map((o) => [o.fromSelect, o])), c = [];
649
723
  n.forEach((o) => {
650
724
  if (o.fromSelect === void 0) {
651
725
  c.push(o);
@@ -655,31 +729,31 @@ function Re(e, t) {
655
729
  p && c.push(U(o.expression, p.expression) ? o : { ...o, expression: p.expression });
656
730
  });
657
731
  const h = l.filter((o) => !s.has(o.id)).map((o) => ({
658
- id: ne(),
732
+ id: ae(),
659
733
  expression: o.expression,
660
734
  fromSelect: o.id
661
735
  })), g = [...c, ...h];
662
736
  return g.length === n.length && g.every((o, p) => o === n[p]) ? e : { ...e, groupBy: g };
663
737
  }
664
- function Ce(e, t) {
738
+ function Ne(e, t) {
665
739
  const n = (e.groupBy ?? []).map((a) => a.expression), r = e.orderBy ?? [];
666
- if (!W(e, t))
740
+ if (!K(e, t))
667
741
  return {
668
742
  select: [],
669
743
  selectAll: !1,
670
744
  orderBy: [],
671
745
  having: !1
672
746
  };
673
- const i = (a) => a.filter((l) => !v(l.expression, n, t)).map((l) => l.id);
747
+ const i = (a) => a.filter((l) => !I(l.expression) && !E(l.expression, n, t)).map((l) => l.id);
674
748
  return {
675
749
  select: i(e.select),
676
750
  selectAll: e.select.length === 0,
677
751
  orderBy: i(r),
678
- having: e.having !== void 0 && !v(e.having, n, t)
752
+ having: e.having !== void 0 && !E(e.having, n, t)
679
753
  };
680
754
  }
681
- const Oe = { tables: [], relations: [] };
682
- function ye(e, t, n) {
755
+ const De = { tables: [], relations: [] };
756
+ function Me(e, t, n) {
683
757
  if (!t && !n) return e;
684
758
  const r = e.tables.filter((a) => !t || t(a)).map((a) => n ? { ...a, columns: a.columns.filter((l) => n(a, l)) } : a), i = new Set(r.map((a) => a.name));
685
759
  return {
@@ -687,10 +761,10 @@ function ye(e, t, n) {
687
761
  relations: e.relations.filter((a) => i.has(a.fromTable) && i.has(a.toTable))
688
762
  };
689
763
  }
690
- function we(e) {
764
+ function Ue(e) {
691
765
  return [...e.tables].sort((t, n) => t.label.localeCompare(n.label));
692
766
  }
693
- function Ne(e, t = (r) => r.group, n = e) {
767
+ function Ie(e, t = (r) => r.group, n = e) {
694
768
  const r = /* @__PURE__ */ new Map();
695
769
  n.forEach((a) => {
696
770
  const l = t(a) || void 0;
@@ -715,11 +789,11 @@ const R = (e, t) => {
715
789
  var n;
716
790
  return ((n = V(e, t)) == null ? void 0 : n.passThrough) !== !1;
717
791
  };
718
- function I(e, t) {
792
+ function B(e, t) {
719
793
  const n = t.filter((r) => R(e, r));
720
794
  return n.length > 0 ? n : [...t];
721
795
  }
722
- function B(e, t) {
796
+ function L(e, t) {
723
797
  const n = /* @__PURE__ */ new Set();
724
798
  return t.forEach((r, i) => {
725
799
  const l = t.slice(0, i).map((c) => ({ earlier: c, r: N(e, c, r) })).find(({ r: c }) => c !== void 0);
@@ -727,17 +801,17 @@ function B(e, t) {
727
801
  (l.r.fromTable === l.earlier && l.r.toTable === r || n.has(l.earlier)) && n.add(r);
728
802
  }), n;
729
803
  }
730
- const X = (e, t) => e.fanOuts - t.fanOuts || e.steps - t.steps || e.order - t.order, S = (e, t) => `${t ? "^" : "_"}${e}`;
731
- function G(e, t) {
804
+ const X = (e, t) => e.fanOuts - t.fanOuts || e.steps - t.steps || e.order - t.order, w = (e, t) => `${t ? "^" : "_"}${e}`;
805
+ function Y(e, t) {
732
806
  let n;
733
807
  return e.forEach((r, i) => {
734
808
  !t.has(i) && (n === void 0 || X(r, e.get(n)) < 0) && (n = i);
735
809
  }), n;
736
810
  }
737
- function ae(e, t, n, r = {}) {
738
- const i = new Set(t), a = new Set(I(e, t)), l = r.anyShape ? /* @__PURE__ */ new Set() : B(e, t), s = /* @__PURE__ */ new Map();
811
+ function ie(e, t, n, r = {}) {
812
+ const i = new Set(t), a = new Set(B(e, t)), l = r.anyShape ? /* @__PURE__ */ new Set() : L(e, t), s = /* @__PURE__ */ new Map();
739
813
  t.forEach((m, d) => {
740
- const b = S(m, l.has(m));
814
+ const b = w(m, l.has(m));
741
815
  s.has(b) || s.set(b, {
742
816
  table: m,
743
817
  climbed: l.has(m),
@@ -752,22 +826,22 @@ function ae(e, t, n, r = {}) {
752
826
  const d = s.get(m);
753
827
  d.steps > 0 && !R(e, d.table) || e.relations.forEach((b) => {
754
828
  if (b.fromTable !== d.table && b.toTable !== d.table) return;
755
- const E = b.fromTable === d.table, C = E ? b.toTable : b.fromTable;
756
- if (i.has(C) || !E && d.climbed) return;
757
- const O = {
758
- table: C,
759
- climbed: !r.anyShape && (d.climbed || E),
760
- fanOuts: d.fanOuts + (E ? 0 : 1),
829
+ const k = b.fromTable === d.table, S = k ? b.toTable : b.fromTable;
830
+ if (i.has(S) || !k && d.climbed) return;
831
+ const y = {
832
+ table: S,
833
+ climbed: !r.anyShape && (d.climbed || k),
834
+ fanOuts: d.fanOuts + (k ? 0 : 1),
761
835
  steps: d.steps + 1,
762
836
  order: h,
763
837
  from: m
764
- }, y = S(C, O.climbed), L = s.get(y);
765
- c.has(y) || L && X(O, { ...L, order: h }) >= 0 || (s.set(y, O), h += 1);
838
+ }, C = w(S, y.climbed), G = s.get(C);
839
+ c.has(C) || G && X(y, { ...G, order: h }) >= 0 || (s.set(C, y), h += 1);
766
840
  });
767
841
  };
768
- let f = G(s, c);
842
+ let f = Y(s, c);
769
843
  for (; f !== void 0 && s.get(f).table !== n; )
770
- c.add(f), g(f), f = G(s, c);
844
+ c.add(f), g(f), f = Y(s, c);
771
845
  if (f === void 0) return;
772
846
  const o = [];
773
847
  let p = s.get(f);
@@ -775,11 +849,11 @@ function ae(e, t, n, r = {}) {
775
849
  o.unshift(p.table), p = s.get(p.from);
776
850
  return { start: p.table, tables: o };
777
851
  }
778
- function Me(e, t, n, r = {}) {
852
+ function Be(e, t, n, r = {}) {
779
853
  var i;
780
- return t.includes(n) ? [] : (i = ae(e, t, n, r)) == null ? void 0 : i.tables;
854
+ return t.includes(n) ? [] : (i = ie(e, t, n, r)) == null ? void 0 : i.tables;
781
855
  }
782
- function De(e, t, n = {}) {
856
+ function Le(e, t, n = {}) {
783
857
  const r = /* @__PURE__ */ new Map(), i = (f, o, p) => r.set(f, [
784
858
  ...r.get(f) ?? [],
785
859
  { table: o, up: p }
@@ -787,24 +861,24 @@ function De(e, t, n = {}) {
787
861
  e.relations.forEach((f) => {
788
862
  i(f.fromTable, f.toTable, !0), i(f.toTable, f.fromTable, !1);
789
863
  });
790
- const { skip: a = /* @__PURE__ */ new Set() } = n, l = n.anyShape ? /* @__PURE__ */ new Set() : B(e, t), s = new Set(t), c = new Set(t), h = I(e, t).map((f) => ({ table: f, climbed: l.has(f) })), g = new Set(h.map((f) => S(f.table, f.climbed)));
864
+ const { skip: a = /* @__PURE__ */ new Set() } = n, l = n.anyShape ? /* @__PURE__ */ new Set() : L(e, t), s = new Set(t), c = new Set(t), h = B(e, t).map((f) => ({ table: f, climbed: l.has(f) })), g = new Set(h.map((f) => w(f.table, f.climbed)));
791
865
  for (let f = h.shift(); f !== void 0; f = h.shift()) {
792
866
  const o = f;
793
867
  (r.get(o.table) ?? []).forEach(({ table: p, up: m }) => {
794
868
  if (s.has(p) || a.has(p) || !m && o.climbed) return;
795
- const d = { table: p, climbed: !n.anyShape && (o.climbed || m) }, b = S(p, d.climbed);
869
+ const d = { table: p, climbed: !n.anyShape && (o.climbed || m) }, b = w(p, d.climbed);
796
870
  g.has(b) || (g.add(b), c.add(p), R(e, p) && h.push(d));
797
871
  });
798
872
  }
799
873
  return c;
800
874
  }
801
- function Ue(e, t, n, r = {}) {
875
+ function Ge(e, t, n, r = {}) {
802
876
  var m;
803
- const { after: i, leftJoined: a = [] } = r, l = r.anyShape ? /* @__PURE__ */ new Set() : B(e, t), s = (d) => {
877
+ const { after: i, leftJoined: a = [] } = r, l = r.anyShape ? /* @__PURE__ */ new Set() : L(e, t), s = (d) => {
804
878
  const b = N(e, d, n);
805
879
  return b !== void 0 && !(l.has(d) && b.toTable === d && b.fromTable === n);
806
880
  };
807
- let c = R(e, n) ? I(e, t) : t;
881
+ let c = R(e, n) ? B(e, t) : t;
808
882
  i !== void 0 && s(i) && (c = [i]);
809
883
  const h = c.find(s);
810
884
  if (h === void 0) return;
@@ -816,8 +890,8 @@ function Ue(e, t, n, r = {}) {
816
890
  };
817
891
  return { joinType: o, on: p };
818
892
  }
819
- const Y = (e, t) => `${e}.${t}`;
820
- function se({ type: e, format: t }) {
893
+ const _ = (e, t) => `${e}.${t}`;
894
+ function ue({ type: e, format: t }) {
821
895
  if (t === void 0) return;
822
896
  if (e !== "date" && e !== "dateTime" && e !== "time")
823
897
  return `a format is for a date, date-and-time or time column, not ${e}`;
@@ -826,7 +900,7 @@ function se({ type: e, format: t }) {
826
900
  if (e === "time" && n.some((r) => r === "YYYY" || r === "MM" || r === "DD"))
827
901
  return `a time has no day: format "${t}" can't be written from one`;
828
902
  }
829
- function Ie(e) {
903
+ function Ye(e) {
830
904
  const t = [], n = /* @__PURE__ */ new Map();
831
905
  e.tables.forEach((a) => {
832
906
  n.has(a.name) && t.push({
@@ -839,7 +913,7 @@ function Ie(e) {
839
913
  kind: "duplicateColumn",
840
914
  message: `Column "${a.name}.${s.name}" is declared more than once`
841
915
  }), l.add(s.name);
842
- const c = se(s);
916
+ const c = ue(s);
843
917
  c && t.push({
844
918
  kind: "invalidFormat",
845
919
  message: `Column "${a.name}.${s.name}": ${c}`
@@ -858,7 +932,7 @@ function Ie(e) {
858
932
  }, i = /* @__PURE__ */ new Set();
859
933
  return e.relations.forEach((a) => {
860
934
  r(a.fromTable, a.fromColumn), r(a.toTable, a.toColumn);
861
- const l = Y(a.fromTable, a.fromColumn), s = Y(a.toTable, a.toColumn), c = [l, s].sort().join(" <-> ");
935
+ const l = _(a.fromTable, a.fromColumn), s = _(a.toTable, a.toColumn), c = [l, s].sort().join(" <-> ");
862
936
  i.has(c) && t.push({
863
937
  kind: "duplicateRelation",
864
938
  message: `Relation ${l} -> ${s} is declared more than once (declare each foreign key once)`
@@ -866,56 +940,60 @@ function Ie(e) {
866
940
  }), t;
867
941
  }
868
942
  export {
869
- ve as A,
870
- W as B,
871
- le as C,
872
- Te as D,
873
- Oe as E,
874
- Ce as F,
875
- be as G,
876
- P as H,
877
- D as I,
878
- me as J,
879
- oe as K,
880
- z as L,
881
- ce as M,
943
+ se as $,
944
+ ke as A,
945
+ K as B,
946
+ oe as C,
947
+ Ee as D,
948
+ De as E,
949
+ Ne as F,
950
+ ve as G,
951
+ I as H,
952
+ W as I,
953
+ M as J,
954
+ he as K,
955
+ pe as L,
956
+ me as M,
882
957
  Z as N,
883
- de as O,
884
- ae as P,
885
- j as Q,
886
- J as R,
887
- ke as S,
888
- te as T,
889
- ge as U,
890
- he as V,
891
- Ne as W,
892
- F as X,
893
- Se as Y,
894
- Ae as Z,
895
- Me as a,
896
- ie as b,
897
- Ee as c,
958
+ q as O,
959
+ be as P,
960
+ ie as Q,
961
+ $ as R,
962
+ z as S,
963
+ Re as T,
964
+ we as U,
965
+ re as V,
966
+ xe as W,
967
+ Ae as X,
968
+ Ie as Y,
969
+ ne as Z,
970
+ H as _,
971
+ Be as a,
972
+ ye as a0,
973
+ Ce as a1,
974
+ fe as b,
975
+ Se as c,
898
976
  U as d,
899
- _ as e,
900
- ye as f,
901
- w as g,
902
- fe as h,
903
- M as i,
977
+ F as e,
978
+ Me as f,
979
+ O as g,
980
+ de as h,
981
+ D as i,
904
982
  V as j,
905
- ee as k,
906
- ne as l,
907
- $ as m,
908
- ue as n,
909
- pe as o,
910
- xe as p,
911
- Q as q,
912
- De as r,
913
- Ue as s,
914
- K as t,
983
+ te as k,
984
+ ae as l,
985
+ j as m,
986
+ ce as n,
987
+ ge as o,
988
+ Te as p,
989
+ J as q,
990
+ Le as r,
991
+ Ge as s,
992
+ Q as t,
915
993
  x as u,
916
- Ie as v,
917
- re as w,
918
- Re as x,
919
- k as y,
920
- we as z
994
+ Ye as v,
995
+ le as w,
996
+ Oe as x,
997
+ v as y,
998
+ Ue as z
921
999
  };