@nongt/visql 0.11.0 → 0.12.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.
- package/dist/{PipelineEditor-DEiKHDrr.js → PipelineEditor-DHfbOSzT.js} +3690 -3519
- package/dist/core.js +125 -116
- package/dist/explain.js +3 -3
- package/dist/fixtures.js +3 -3
- package/dist/index.js +7 -7
- package/dist/{issueLocation-Yn71qJyP.js → issueLocation-DY-vvgFF.js} +437 -423
- package/dist/mui.js +1 -1
- package/dist/{params-DVkfcD6D.js → params-Btjlj45_.js} +104 -91
- package/dist/{schema-CzKt6cN2.js → schema-DsMO9oFE.js} +133 -129
- package/dist/sql-import.js +776 -767
- package/dist/{sqlGen-BoJXaULd.js → sqlGen-DGXVba3D.js} +198 -182
- package/dist/types/core/absolutePath.d.ts +3 -0
- package/dist/types/core/ast.d.ts +15 -1
- package/dist/types/core/components/expression/ExpressionTypeSelector.d.ts +1 -1
- package/dist/types/core/components/flow/CalculationFlowNode.d.ts +5 -0
- package/dist/types/core/expressionFlow.d.ts +40 -5
- package/dist/types/core/formula.d.ts +4 -1
- package/dist/types/core/i18n/defaultMessages.d.ts +7 -0
- package/dist/types/core/i18n/messages.d.ts +5 -0
- package/dist/types/core/issueLocation.d.ts +1 -1
- package/dist/types/core/queryHelpers.d.ts +4 -1
- package/dist/types/core/sqlGen.d.ts +12 -0
- package/dist/types/core/storedQuery.d.ts +1 -1
- package/dist/types/core/valueTypes.d.ts +2 -2
- package/dist/types/core-api.d.ts +2 -2
- package/dist/types/sqlImport/context.d.ts +2 -2
- package/package.json +1 -1
|
@@ -9,6 +9,8 @@ function v(e) {
|
|
|
9
9
|
] : e.args;
|
|
10
10
|
case "binary":
|
|
11
11
|
return e.right ? [e.left, e.right] : [e.left];
|
|
12
|
+
case "arithmetic":
|
|
13
|
+
return [e.left, e.right];
|
|
12
14
|
case "logical":
|
|
13
15
|
return e.operands;
|
|
14
16
|
case "list":
|
|
@@ -48,17 +50,17 @@ function ce(e) {
|
|
|
48
50
|
}
|
|
49
51
|
function O(e, t) {
|
|
50
52
|
if (!D(e)) return t(e, 0);
|
|
51
|
-
const
|
|
52
|
-
return
|
|
53
|
+
const r = e.union.map((n, i) => t(n, i));
|
|
54
|
+
return r.every((n, i) => n === e.union[i]) ? e : { ...e, union: r };
|
|
53
55
|
}
|
|
54
56
|
function pe(e, t) {
|
|
55
57
|
if (!e.shared) return e;
|
|
56
|
-
let
|
|
57
|
-
const
|
|
58
|
+
let r = !1;
|
|
59
|
+
const n = e.shared.map((i) => {
|
|
58
60
|
const a = t(i.query, i);
|
|
59
|
-
return a === i.query ? i : (
|
|
61
|
+
return a === i.query ? i : (r = !0, { ...i, query: a });
|
|
60
62
|
});
|
|
61
|
-
return
|
|
63
|
+
return r ? { ...e, shared: n } : e;
|
|
62
64
|
}
|
|
63
65
|
function de(e) {
|
|
64
66
|
return "from" in e;
|
|
@@ -77,49 +79,51 @@ function be(e) {
|
|
|
77
79
|
return J(e).flatMap((t) => t.table === void 0 ? [] : [t.table]);
|
|
78
80
|
}
|
|
79
81
|
function j(e, t) {
|
|
80
|
-
const
|
|
82
|
+
const r = t;
|
|
81
83
|
switch (e.type) {
|
|
82
84
|
case "function":
|
|
83
85
|
return {
|
|
84
86
|
...e,
|
|
85
|
-
args: e.args.map(
|
|
86
|
-
...e.partitionBy ? { partitionBy: e.partitionBy.map(
|
|
87
|
-
...e.orderBy ? { orderBy: e.orderBy.map((
|
|
87
|
+
args: e.args.map(r),
|
|
88
|
+
...e.partitionBy ? { partitionBy: e.partitionBy.map(r) } : {},
|
|
89
|
+
...e.orderBy ? { orderBy: e.orderBy.map((n) => ({ ...n, expression: r(n.expression) })) } : {}
|
|
88
90
|
};
|
|
89
91
|
case "binary":
|
|
90
92
|
return {
|
|
91
93
|
...e,
|
|
92
|
-
left:
|
|
93
|
-
...e.right ? { right:
|
|
94
|
+
left: r(e.left),
|
|
95
|
+
...e.right ? { right: r(e.right) } : {}
|
|
94
96
|
};
|
|
97
|
+
case "arithmetic":
|
|
98
|
+
return { ...e, left: r(e.left), right: r(e.right) };
|
|
95
99
|
case "logical":
|
|
96
|
-
return { ...e, operands: e.operands.map(
|
|
100
|
+
return { ...e, operands: e.operands.map(r) };
|
|
97
101
|
case "list":
|
|
98
|
-
return { ...e, items: e.items.map(
|
|
102
|
+
return { ...e, items: e.items.map(r) };
|
|
99
103
|
case "not":
|
|
100
|
-
return { ...e, operand:
|
|
104
|
+
return { ...e, operand: r(e.operand) };
|
|
101
105
|
case "if":
|
|
102
106
|
return {
|
|
103
107
|
...e,
|
|
104
|
-
condition: e.condition &&
|
|
105
|
-
then: e.then &&
|
|
106
|
-
else: e.else &&
|
|
108
|
+
condition: e.condition && r(e.condition),
|
|
109
|
+
then: e.then && r(e.then),
|
|
110
|
+
else: e.else && r(e.else)
|
|
107
111
|
};
|
|
108
112
|
case "case":
|
|
109
113
|
return {
|
|
110
114
|
...e,
|
|
111
|
-
subject: e.subject &&
|
|
112
|
-
branches: e.branches.map((
|
|
113
|
-
else: e.else &&
|
|
115
|
+
subject: e.subject && r(e.subject),
|
|
116
|
+
branches: e.branches.map((n) => ({ when: r(n.when), then: r(n.then) })),
|
|
117
|
+
else: e.else && r(e.else)
|
|
114
118
|
};
|
|
115
119
|
case "exists":
|
|
116
120
|
return {
|
|
117
121
|
...e,
|
|
118
|
-
link:
|
|
122
|
+
link: r(e.link),
|
|
119
123
|
query: {
|
|
120
124
|
...e.query,
|
|
121
|
-
joins: e.query.joins.map((
|
|
122
|
-
...e.query.where ? { where:
|
|
125
|
+
joins: e.query.joins.map((n) => n.on ? { ...n, on: r(n.on) } : n),
|
|
126
|
+
...e.query.where ? { where: r(e.query.where) } : {}
|
|
123
127
|
}
|
|
124
128
|
};
|
|
125
129
|
default:
|
|
@@ -127,8 +131,8 @@ function j(e, t) {
|
|
|
127
131
|
}
|
|
128
132
|
}
|
|
129
133
|
function $(e, t) {
|
|
130
|
-
const
|
|
131
|
-
return
|
|
134
|
+
const r = j(e, (n) => $(n, t));
|
|
135
|
+
return r === e ? t(e) : r;
|
|
132
136
|
}
|
|
133
137
|
function he(e) {
|
|
134
138
|
return [
|
|
@@ -140,26 +144,26 @@ function he(e) {
|
|
|
140
144
|
...(e.orderBy ?? []).map((t) => t.expression)
|
|
141
145
|
];
|
|
142
146
|
}
|
|
143
|
-
function F(e, t,
|
|
147
|
+
function F(e, t, r = (n) => F(n, t)) {
|
|
144
148
|
var a, l;
|
|
145
|
-
const
|
|
149
|
+
const n = t, { shared: i } = e;
|
|
146
150
|
return {
|
|
147
151
|
...e,
|
|
148
152
|
...i ? {
|
|
149
|
-
shared: i.map((s) => ({ ...s, query: O(s.query,
|
|
153
|
+
shared: i.map((s) => ({ ...s, query: O(s.query, r) }))
|
|
150
154
|
} : {},
|
|
151
|
-
from: e.from.query ? { ...e.from, query: O(e.from.query,
|
|
152
|
-
where: e.where &&
|
|
153
|
-
joins: e.joins.map((s) => s.query ? { ...s, on: s.on &&
|
|
154
|
-
select: e.select.map((s) => ({ ...s, expression:
|
|
155
|
-
groupBy: (a = e.groupBy) == null ? void 0 : a.map((s) => ({ ...s, expression:
|
|
156
|
-
having: e.having &&
|
|
157
|
-
orderBy: (l = e.orderBy) == null ? void 0 : l.map((s) => ({ ...s, expression:
|
|
155
|
+
from: e.from.query ? { ...e.from, query: O(e.from.query, r) } : e.from,
|
|
156
|
+
where: e.where && n(e.where),
|
|
157
|
+
joins: e.joins.map((s) => s.query ? { ...s, on: s.on && n(s.on), query: O(s.query, r) } : { ...s, on: s.on && n(s.on) }),
|
|
158
|
+
select: e.select.map((s) => ({ ...s, expression: n(s.expression) })),
|
|
159
|
+
groupBy: (a = e.groupBy) == null ? void 0 : a.map((s) => ({ ...s, expression: n(s.expression) })),
|
|
160
|
+
having: e.having && n(e.having),
|
|
161
|
+
orderBy: (l = e.orderBy) == null ? void 0 : l.map((s) => ({ ...s, expression: n(s.expression) }))
|
|
158
162
|
};
|
|
159
163
|
}
|
|
160
164
|
function z(e, t) {
|
|
161
|
-
const
|
|
162
|
-
return F(e, (
|
|
165
|
+
const r = (n) => n.type === "subquery" ? { ...n, query: z(n.query, t) } : j(n, r);
|
|
166
|
+
return F(e, (n) => $(r(n), t));
|
|
163
167
|
}
|
|
164
168
|
function Z(e) {
|
|
165
169
|
return new Set([e.from, ...e.joins].map(Q));
|
|
@@ -168,8 +172,8 @@ function q(e) {
|
|
|
168
172
|
return e !== void 0 && (e.type === "exists" || v(e).some(q));
|
|
169
173
|
}
|
|
170
174
|
function ee(e) {
|
|
171
|
-
const t = Z(e.query),
|
|
172
|
-
return
|
|
175
|
+
const t = Z(e.query), r = (n) => n.type === "field" ? [n] : v(n).flatMap(r);
|
|
176
|
+
return r(e.link).filter((n) => n.table !== void 0 && !t.has(n.table));
|
|
173
177
|
}
|
|
174
178
|
const xe = {
|
|
175
179
|
"date-expr": ["date", "dateTime"],
|
|
@@ -188,13 +192,13 @@ const xe = {
|
|
|
188
192
|
];
|
|
189
193
|
function ve(e, t) {
|
|
190
194
|
if (t < e.args.length) return e.args[t];
|
|
191
|
-
const
|
|
192
|
-
return
|
|
195
|
+
const r = e.args[e.args.length - 1];
|
|
196
|
+
return r != null && r.variadic ? r : void 0;
|
|
193
197
|
}
|
|
194
|
-
function
|
|
198
|
+
function re(e) {
|
|
195
199
|
let t = e.args.length;
|
|
196
200
|
for (; t > 0 && e.args[t - 1].optional && !e.args[t - 1].default; ) t -= 1;
|
|
197
|
-
return e.args.slice(0, t).map((
|
|
201
|
+
return e.args.slice(0, t).map((r) => r.default ?? { type: "literal", value: "" });
|
|
198
202
|
}
|
|
199
203
|
const T = (e, t = "DAY") => ({
|
|
200
204
|
label: e,
|
|
@@ -640,21 +644,21 @@ function M(e, t = A) {
|
|
|
640
644
|
return t[e.toUpperCase()];
|
|
641
645
|
}
|
|
642
646
|
function Te(e, t) {
|
|
643
|
-
const
|
|
644
|
-
return M(e, t) ?? Object.values(t).find((
|
|
647
|
+
const r = e.toUpperCase();
|
|
648
|
+
return M(e, t) ?? Object.values(t).find((n) => {
|
|
645
649
|
var i;
|
|
646
|
-
return (i =
|
|
650
|
+
return (i = n.aliases) == null ? void 0 : i.some((a) => a.toUpperCase() === r);
|
|
647
651
|
});
|
|
648
652
|
}
|
|
649
|
-
function
|
|
653
|
+
function ne(e = A) {
|
|
650
654
|
return Object.keys(e).sort();
|
|
651
655
|
}
|
|
652
|
-
|
|
656
|
+
ne(A);
|
|
653
657
|
const Ee = A;
|
|
654
658
|
function ke(e) {
|
|
655
659
|
return Object.fromEntries(Object.values(e).map((t) => {
|
|
656
|
-
const
|
|
657
|
-
return [
|
|
660
|
+
const r = t.name.toUpperCase();
|
|
661
|
+
return [r, { ...t, name: r }];
|
|
658
662
|
}));
|
|
659
663
|
}
|
|
660
664
|
function we(e) {
|
|
@@ -664,7 +668,7 @@ function Ae(e, t) {
|
|
|
664
668
|
return {
|
|
665
669
|
type: "function",
|
|
666
670
|
name: t,
|
|
667
|
-
args:
|
|
671
|
+
args: re(e),
|
|
668
672
|
...e.window && { over: !0 }
|
|
669
673
|
};
|
|
670
674
|
}
|
|
@@ -672,25 +676,25 @@ function Re(e) {
|
|
|
672
676
|
return Object.fromEntries(Object.entries(e).filter(([, t]) => !t.window));
|
|
673
677
|
}
|
|
674
678
|
function Se(e, t) {
|
|
675
|
-
return Object.fromEntries(Object.entries(e).filter(([,
|
|
679
|
+
return Object.fromEntries(Object.entries(e).filter(([, r]) => !r.dialects || r.dialects.includes(t)));
|
|
676
680
|
}
|
|
677
681
|
function U(e, t) {
|
|
678
682
|
if (e === t) return !0;
|
|
679
683
|
if (e instanceof Date && t instanceof Date) return e.getTime() === t.getTime();
|
|
680
684
|
if (typeof e != "object" || typeof t != "object" || e === null || t === null) return !1;
|
|
681
|
-
const
|
|
682
|
-
return i.length === a.length && i.every((l) => U(
|
|
685
|
+
const r = e, n = t, i = Object.keys(r).filter((l) => r[l] !== void 0), a = Object.keys(n).filter((l) => n[l] !== void 0);
|
|
686
|
+
return i.length === a.length && i.every((l) => U(r[l], n[l]));
|
|
683
687
|
}
|
|
684
688
|
function ae() {
|
|
685
689
|
const e = globalThis.crypto.getRandomValues(new Uint8Array(12));
|
|
686
690
|
return Array.from(e, (t) => t.toString(16).padStart(2, "0")).join("");
|
|
687
691
|
}
|
|
688
692
|
function H(e, t) {
|
|
689
|
-
var
|
|
690
|
-
return e.type === "function" && ((
|
|
693
|
+
var r;
|
|
694
|
+
return e.type === "function" && ((r = M(e.name, t)) == null ? void 0 : r.aggregate) === !0;
|
|
691
695
|
}
|
|
692
696
|
function x(e, t) {
|
|
693
|
-
return e ? H(e, t) || v(e).some((
|
|
697
|
+
return e ? H(e, t) || v(e).some((r) => x(r, t)) : !1;
|
|
694
698
|
}
|
|
695
699
|
const se = (e) => e.type === "function" && e.over === !0;
|
|
696
700
|
function I(e) {
|
|
@@ -700,27 +704,27 @@ function P(e, t) {
|
|
|
700
704
|
return e.type === "function" && e.name.trim() !== "" && M(e.name, t) === void 0;
|
|
701
705
|
}
|
|
702
706
|
function W(e, t) {
|
|
703
|
-
return e ? P(e, t) || v(e).some((
|
|
707
|
+
return e ? P(e, t) || v(e).some((r) => W(r, t)) : !1;
|
|
704
708
|
}
|
|
705
|
-
function E(e, t,
|
|
706
|
-
return t.some((
|
|
709
|
+
function E(e, t, r) {
|
|
710
|
+
return t.some((n) => U(n, e)) ? !0 : e.type === "field" ? !e.column : e.type === "exists" ? ee(e).every((n) => E(n, t, r)) : H(e, r) || P(e, r) ? !0 : v(e).every((n) => E(n, t, r));
|
|
707
711
|
}
|
|
708
712
|
function K(e, t) {
|
|
709
|
-
return (e.groupBy ?? []).length > 0 || e.having !== void 0 || [...e.select, ...e.orderBy ?? []].some((
|
|
713
|
+
return (e.groupBy ?? []).length > 0 || e.having !== void 0 || [...e.select, ...e.orderBy ?? []].some((r) => x(r.expression, t));
|
|
710
714
|
}
|
|
711
715
|
function ye(e, t) {
|
|
712
716
|
if (K(e, t))
|
|
713
|
-
return (e.groupBy ?? []).flatMap(({ expression:
|
|
717
|
+
return (e.groupBy ?? []).flatMap(({ expression: r }) => r.type === "field" && r.table && r.column ? [`${r.table}.${r.column}`] : []);
|
|
714
718
|
}
|
|
715
719
|
function le(e, t) {
|
|
716
|
-
return x(e.having, t) || [...e.select, ...e.orderBy ?? []].some((
|
|
720
|
+
return x(e.having, t) || [...e.select, ...e.orderBy ?? []].some((r) => x(r.expression, t));
|
|
717
721
|
}
|
|
718
722
|
function Ce(e, t) {
|
|
719
|
-
return e.select.some((
|
|
723
|
+
return e.select.some((r) => x(r.expression, t));
|
|
720
724
|
}
|
|
721
725
|
function Oe(e, t) {
|
|
722
|
-
const
|
|
723
|
-
|
|
726
|
+
const r = e.groupBy ?? [], n = r.filter((o) => o.fromSelect === void 0), i = le(e, t), a = n.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(r.filter((o) => o.fromSelect !== void 0).map((o) => [o.fromSelect, o])), c = [];
|
|
727
|
+
r.forEach((o) => {
|
|
724
728
|
if (o.fromSelect === void 0) {
|
|
725
729
|
c.push(o);
|
|
726
730
|
return;
|
|
@@ -733,10 +737,10 @@ function Oe(e, t) {
|
|
|
733
737
|
expression: o.expression,
|
|
734
738
|
fromSelect: o.id
|
|
735
739
|
})), g = [...c, ...h];
|
|
736
|
-
return g.length ===
|
|
740
|
+
return g.length === r.length && g.every((o, p) => o === r[p]) ? e : { ...e, groupBy: g };
|
|
737
741
|
}
|
|
738
742
|
function Ne(e, t) {
|
|
739
|
-
const
|
|
743
|
+
const r = (e.groupBy ?? []).map((a) => a.expression), n = e.orderBy ?? [];
|
|
740
744
|
if (!K(e, t))
|
|
741
745
|
return {
|
|
742
746
|
select: [],
|
|
@@ -744,72 +748,72 @@ function Ne(e, t) {
|
|
|
744
748
|
orderBy: [],
|
|
745
749
|
having: !1
|
|
746
750
|
};
|
|
747
|
-
const i = (a) => a.filter((l) => !I(l.expression) && !E(l.expression,
|
|
751
|
+
const i = (a) => a.filter((l) => !I(l.expression) && !E(l.expression, r, t)).map((l) => l.id);
|
|
748
752
|
return {
|
|
749
753
|
select: i(e.select),
|
|
750
754
|
selectAll: e.select.length === 0,
|
|
751
|
-
orderBy: i(
|
|
752
|
-
having: e.having !== void 0 && !E(e.having,
|
|
755
|
+
orderBy: i(n),
|
|
756
|
+
having: e.having !== void 0 && !E(e.having, r, t)
|
|
753
757
|
};
|
|
754
758
|
}
|
|
755
759
|
const De = { tables: [], relations: [] };
|
|
756
|
-
function Me(e, t,
|
|
757
|
-
if (!t && !
|
|
758
|
-
const
|
|
760
|
+
function Me(e, t, r) {
|
|
761
|
+
if (!t && !r) return e;
|
|
762
|
+
const n = e.tables.filter((a) => !t || t(a)).map((a) => r ? { ...a, columns: a.columns.filter((l) => r(a, l)) } : a), i = new Set(n.map((a) => a.name));
|
|
759
763
|
return {
|
|
760
|
-
tables:
|
|
764
|
+
tables: n,
|
|
761
765
|
relations: e.relations.filter((a) => i.has(a.fromTable) && i.has(a.toTable))
|
|
762
766
|
};
|
|
763
767
|
}
|
|
764
768
|
function Ue(e) {
|
|
765
|
-
return [...e.tables].sort((t,
|
|
769
|
+
return [...e.tables].sort((t, r) => t.label.localeCompare(r.label));
|
|
766
770
|
}
|
|
767
|
-
function Ie(e, t = (
|
|
768
|
-
const
|
|
769
|
-
|
|
771
|
+
function Ie(e, t = (n) => n.group, r = e) {
|
|
772
|
+
const n = /* @__PURE__ */ new Map();
|
|
773
|
+
r.forEach((a) => {
|
|
770
774
|
const l = t(a) || void 0;
|
|
771
|
-
l !== void 0 && !
|
|
775
|
+
l !== void 0 && !n.has(l) && n.set(l, []);
|
|
772
776
|
}), e.forEach((a) => {
|
|
773
777
|
const l = t(a) || void 0;
|
|
774
|
-
|
|
778
|
+
n.set(l, [...n.get(l) ?? [], a]);
|
|
775
779
|
});
|
|
776
780
|
const i = (a) => [...a].sort((l, s) => l.label.localeCompare(s.label));
|
|
777
781
|
return [
|
|
778
|
-
...[...
|
|
779
|
-
...[...
|
|
782
|
+
...[...n].filter(([a]) => a !== void 0),
|
|
783
|
+
...[...n].filter(([a]) => a === void 0)
|
|
780
784
|
].filter(([, a]) => a.length > 0).map(([a, l]) => ({ group: a, tables: i(l) }));
|
|
781
785
|
}
|
|
782
786
|
function V(e, t) {
|
|
783
|
-
return e.tables.find((
|
|
787
|
+
return e.tables.find((r) => r.name === t);
|
|
784
788
|
}
|
|
785
|
-
function N(e, t,
|
|
786
|
-
return e.relations.find((
|
|
789
|
+
function N(e, t, r) {
|
|
790
|
+
return e.relations.find((n) => n.fromTable === t && n.toTable === r || n.fromTable === r && n.toTable === t);
|
|
787
791
|
}
|
|
788
792
|
const R = (e, t) => {
|
|
789
|
-
var
|
|
790
|
-
return ((
|
|
793
|
+
var r;
|
|
794
|
+
return ((r = V(e, t)) == null ? void 0 : r.passThrough) !== !1;
|
|
791
795
|
};
|
|
792
796
|
function B(e, t) {
|
|
793
|
-
const
|
|
794
|
-
return
|
|
797
|
+
const r = t.filter((n) => R(e, n));
|
|
798
|
+
return r.length > 0 ? r : [...t];
|
|
795
799
|
}
|
|
796
800
|
function L(e, t) {
|
|
797
|
-
const
|
|
798
|
-
return t.forEach((
|
|
799
|
-
const l = t.slice(0, i).map((c) => ({ earlier: c, r: N(e, c,
|
|
801
|
+
const r = /* @__PURE__ */ new Set();
|
|
802
|
+
return t.forEach((n, i) => {
|
|
803
|
+
const l = t.slice(0, i).map((c) => ({ earlier: c, r: N(e, c, n) })).find(({ r: c }) => c !== void 0);
|
|
800
804
|
if (!l) return;
|
|
801
|
-
(l.r.fromTable === l.earlier && l.r.toTable ===
|
|
802
|
-
}),
|
|
805
|
+
(l.r.fromTable === l.earlier && l.r.toTable === n || r.has(l.earlier)) && r.add(n);
|
|
806
|
+
}), r;
|
|
803
807
|
}
|
|
804
808
|
const X = (e, t) => e.fanOuts - t.fanOuts || e.steps - t.steps || e.order - t.order, w = (e, t) => `${t ? "^" : "_"}${e}`;
|
|
805
809
|
function Y(e, t) {
|
|
806
|
-
let
|
|
807
|
-
return e.forEach((
|
|
808
|
-
!t.has(i) && (
|
|
809
|
-
}),
|
|
810
|
+
let r;
|
|
811
|
+
return e.forEach((n, i) => {
|
|
812
|
+
!t.has(i) && (r === void 0 || X(n, e.get(r)) < 0) && (r = i);
|
|
813
|
+
}), r;
|
|
810
814
|
}
|
|
811
|
-
function ie(e, t,
|
|
812
|
-
const i = new Set(t), a = new Set(B(e, t)), l =
|
|
815
|
+
function ie(e, t, r, n = {}) {
|
|
816
|
+
const i = new Set(t), a = new Set(B(e, t)), l = n.anyShape ? /* @__PURE__ */ new Set() : L(e, t), s = /* @__PURE__ */ new Map();
|
|
813
817
|
t.forEach((m, d) => {
|
|
814
818
|
const b = w(m, l.has(m));
|
|
815
819
|
s.has(b) || s.set(b, {
|
|
@@ -830,7 +834,7 @@ function ie(e, t, n, r = {}) {
|
|
|
830
834
|
if (i.has(S) || !k && d.climbed) return;
|
|
831
835
|
const y = {
|
|
832
836
|
table: S,
|
|
833
|
-
climbed: !
|
|
837
|
+
climbed: !n.anyShape && (d.climbed || k),
|
|
834
838
|
fanOuts: d.fanOuts + (k ? 0 : 1),
|
|
835
839
|
steps: d.steps + 1,
|
|
836
840
|
order: h,
|
|
@@ -840,7 +844,7 @@ function ie(e, t, n, r = {}) {
|
|
|
840
844
|
});
|
|
841
845
|
};
|
|
842
846
|
let f = Y(s, c);
|
|
843
|
-
for (; f !== void 0 && s.get(f).table !==
|
|
847
|
+
for (; f !== void 0 && s.get(f).table !== r; )
|
|
844
848
|
c.add(f), g(f), f = Y(s, c);
|
|
845
849
|
if (f === void 0) return;
|
|
846
850
|
const o = [];
|
|
@@ -849,40 +853,40 @@ function ie(e, t, n, r = {}) {
|
|
|
849
853
|
o.unshift(p.table), p = s.get(p.from);
|
|
850
854
|
return { start: p.table, tables: o };
|
|
851
855
|
}
|
|
852
|
-
function Be(e, t,
|
|
856
|
+
function Be(e, t, r, n = {}) {
|
|
853
857
|
var i;
|
|
854
|
-
return t.includes(
|
|
858
|
+
return t.includes(r) ? [] : (i = ie(e, t, r, n)) == null ? void 0 : i.tables;
|
|
855
859
|
}
|
|
856
|
-
function Le(e, t,
|
|
857
|
-
const
|
|
858
|
-
...
|
|
860
|
+
function Le(e, t, r = {}) {
|
|
861
|
+
const n = /* @__PURE__ */ new Map(), i = (f, o, p) => n.set(f, [
|
|
862
|
+
...n.get(f) ?? [],
|
|
859
863
|
{ table: o, up: p }
|
|
860
864
|
]);
|
|
861
865
|
e.relations.forEach((f) => {
|
|
862
866
|
i(f.fromTable, f.toTable, !0), i(f.toTable, f.fromTable, !1);
|
|
863
867
|
});
|
|
864
|
-
const { skip: a = /* @__PURE__ */ new Set() } =
|
|
868
|
+
const { skip: a = /* @__PURE__ */ new Set() } = r, l = r.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)));
|
|
865
869
|
for (let f = h.shift(); f !== void 0; f = h.shift()) {
|
|
866
870
|
const o = f;
|
|
867
|
-
(
|
|
871
|
+
(n.get(o.table) ?? []).forEach(({ table: p, up: m }) => {
|
|
868
872
|
if (s.has(p) || a.has(p) || !m && o.climbed) return;
|
|
869
|
-
const d = { table: p, climbed: !
|
|
873
|
+
const d = { table: p, climbed: !r.anyShape && (o.climbed || m) }, b = w(p, d.climbed);
|
|
870
874
|
g.has(b) || (g.add(b), c.add(p), R(e, p) && h.push(d));
|
|
871
875
|
});
|
|
872
876
|
}
|
|
873
877
|
return c;
|
|
874
878
|
}
|
|
875
|
-
function Ge(e, t,
|
|
879
|
+
function Ge(e, t, r, n = {}) {
|
|
876
880
|
var m;
|
|
877
|
-
const { after: i, leftJoined: a = [] } =
|
|
878
|
-
const b = N(e, d,
|
|
879
|
-
return b !== void 0 && !(l.has(d) && b.toTable === d && b.fromTable ===
|
|
881
|
+
const { after: i, leftJoined: a = [] } = n, l = n.anyShape ? /* @__PURE__ */ new Set() : L(e, t), s = (d) => {
|
|
882
|
+
const b = N(e, d, r);
|
|
883
|
+
return b !== void 0 && !(l.has(d) && b.toTable === d && b.fromTable === r);
|
|
880
884
|
};
|
|
881
|
-
let c = R(e,
|
|
885
|
+
let c = R(e, r) ? B(e, t) : t;
|
|
882
886
|
i !== void 0 && s(i) && (c = [i]);
|
|
883
887
|
const h = c.find(s);
|
|
884
888
|
if (h === void 0) return;
|
|
885
|
-
const g = N(e, h,
|
|
889
|
+
const g = N(e, h, r), f = (m = V(e, g.fromTable)) == null ? void 0 : m.columns.find((d) => d.name === g.fromColumn), o = f != null && f.nullable || a.includes(h) ? "left" : "inner", p = {
|
|
886
890
|
type: "binary",
|
|
887
891
|
operator: "=",
|
|
888
892
|
left: { type: "field", table: g.fromTable, column: g.fromColumn },
|
|
@@ -895,18 +899,18 @@ function ue({ type: e, format: t }) {
|
|
|
895
899
|
if (t === void 0) return;
|
|
896
900
|
if (e !== "date" && e !== "dateTime" && e !== "time")
|
|
897
901
|
return `a format is for a date, date-and-time or time column, not ${e}`;
|
|
898
|
-
const
|
|
899
|
-
if (
|
|
900
|
-
if (e === "time" &&
|
|
902
|
+
const r = t.match(/YYYY|MM|DD|HH|mm|ss/g) ?? [];
|
|
903
|
+
if (r.length === 0) return `format "${t}" has none of YYYY, MM, DD, HH, mm, ss`;
|
|
904
|
+
if (e === "time" && r.some((n) => n === "YYYY" || n === "MM" || n === "DD"))
|
|
901
905
|
return `a time has no day: format "${t}" can't be written from one`;
|
|
902
906
|
}
|
|
903
907
|
function Ye(e) {
|
|
904
|
-
const t = [],
|
|
908
|
+
const t = [], r = /* @__PURE__ */ new Map();
|
|
905
909
|
e.tables.forEach((a) => {
|
|
906
|
-
|
|
910
|
+
r.has(a.name) && t.push({
|
|
907
911
|
kind: "duplicateTable",
|
|
908
912
|
message: `Table "${a.name}" is declared more than once`
|
|
909
|
-
}),
|
|
913
|
+
}), r.set(a.name, a);
|
|
910
914
|
const l = /* @__PURE__ */ new Set();
|
|
911
915
|
a.columns.forEach((s) => {
|
|
912
916
|
l.has(s.name) && t.push({
|
|
@@ -920,8 +924,8 @@ function Ye(e) {
|
|
|
920
924
|
});
|
|
921
925
|
});
|
|
922
926
|
});
|
|
923
|
-
const
|
|
924
|
-
const s =
|
|
927
|
+
const n = (a, l) => {
|
|
928
|
+
const s = r.get(a);
|
|
925
929
|
s ? s.columns.some((c) => c.name === l) || t.push({
|
|
926
930
|
kind: "unknownColumn",
|
|
927
931
|
message: `Relation references unknown column "${a}.${l}"`
|
|
@@ -931,7 +935,7 @@ function Ye(e) {
|
|
|
931
935
|
});
|
|
932
936
|
}, i = /* @__PURE__ */ new Set();
|
|
933
937
|
return e.relations.forEach((a) => {
|
|
934
|
-
|
|
938
|
+
n(a.fromTable, a.fromColumn), n(a.toTable, a.toColumn);
|
|
935
939
|
const l = _(a.fromTable, a.fromColumn), s = _(a.toTable, a.toColumn), c = [l, s].sort().join(" <-> ");
|
|
936
940
|
i.has(c) && t.push({
|
|
937
941
|
kind: "duplicateRelation",
|
|
@@ -962,11 +966,11 @@ export {
|
|
|
962
966
|
z as S,
|
|
963
967
|
Re as T,
|
|
964
968
|
we as U,
|
|
965
|
-
|
|
969
|
+
ne as V,
|
|
966
970
|
xe as W,
|
|
967
971
|
Ae as X,
|
|
968
972
|
Ie as Y,
|
|
969
|
-
|
|
973
|
+
re as Z,
|
|
970
974
|
H as _,
|
|
971
975
|
Be as a,
|
|
972
976
|
ye as a0,
|