@nongt/visql-core 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/core.js +125 -116
- package/dist/explain.js +3 -3
- package/dist/fixtures.js +3 -3
- package/dist/{issueLocation-Yn71qJyP.js → issueLocation-DY-vvgFF.js} +437 -423
- 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/ast.d.ts +15 -1
- package/dist/types/core/i18n/defaultMessages.d.ts +7 -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-api.d.ts +2 -2
- package/dist/types/sqlImport/context.d.ts +2 -2
- package/package.json +1 -1
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
import { l as ye, z as Ke, q as Se, t as
|
|
2
|
-
import { C as rr, E as nr, F as tr, G as Re, H as Qe, I as ir, J as De, K as sr, L as ar, N as or, t as cr, O as lr, P as ur,
|
|
1
|
+
import { l as ye, z as Ke, q as Se, t as P, i as Ee, y as ke, d as te, o as be, b as _e, j as $e, f as He, A as ze, D as Ve, B as he, C as Ce, M as K, F as Ye, G as ee, u as ne, H as ge, I as Ze, J as er } from "./schema-DsMO9oFE.js";
|
|
2
|
+
import { C as rr, E as nr, F as tr, G as Re, H as Qe, I as ir, J as De, K as sr, L as ar, N as or, t as cr, O as lr, P as ur, Q as fr, A as dr, z as mr, b as yr, R as Ue, M as hr, a as gr, S as Ge, T as pr, w as br, U as $r, V as vr } from "./params-Btjlj45_.js";
|
|
3
3
|
const Ae = (n) => typeof n == "object" && n !== null && !Array.isArray(n) && !(n instanceof Date), Ne = (n) => typeof n.shared == "string";
|
|
4
4
|
function me(n, a) {
|
|
5
5
|
if (Array.isArray(n)) {
|
|
6
6
|
let r = !1;
|
|
7
|
-
const
|
|
7
|
+
const $ = n.flatMap((w) => {
|
|
8
8
|
const l = me(w, a);
|
|
9
9
|
return l !== w && (r = !0), l === void 0 ? [] : [l];
|
|
10
10
|
});
|
|
11
|
-
return r ?
|
|
11
|
+
return r ? $ : n;
|
|
12
12
|
}
|
|
13
13
|
if (!Ae(n)) return n;
|
|
14
14
|
if (Ne(n)) return a(n);
|
|
15
15
|
let u = !1;
|
|
16
|
-
const s = Object.entries(n).map(([r,
|
|
17
|
-
const w = me(
|
|
18
|
-
return w !==
|
|
16
|
+
const s = Object.entries(n).map(([r, $]) => {
|
|
17
|
+
const w = me($, a);
|
|
18
|
+
return w !== $ && (u = !0), [r, w];
|
|
19
19
|
});
|
|
20
20
|
return u ? Object.fromEntries(s) : n;
|
|
21
21
|
}
|
|
22
|
-
function
|
|
22
|
+
function Dr(n) {
|
|
23
23
|
const a = new Map((n.shared ?? []).map((s) => [s.id, []])), u = (s, r) => {
|
|
24
24
|
if (Array.isArray(s)) {
|
|
25
|
-
s.forEach((
|
|
25
|
+
s.forEach(($, w) => u($, [...r, w]));
|
|
26
26
|
return;
|
|
27
27
|
}
|
|
28
28
|
if (Ae(s)) {
|
|
29
29
|
if (Ne(s)) {
|
|
30
|
-
const
|
|
31
|
-
a.set(
|
|
30
|
+
const $ = s.shared;
|
|
31
|
+
a.set($, [...a.get($) ?? [], r]);
|
|
32
32
|
return;
|
|
33
33
|
}
|
|
34
|
-
Object.entries(s).forEach(([
|
|
34
|
+
Object.entries(s).forEach(([$, w]) => u(w, [...r, $]));
|
|
35
35
|
}
|
|
36
36
|
};
|
|
37
37
|
return u(n, []), a;
|
|
38
38
|
}
|
|
39
|
-
function
|
|
39
|
+
function Fr(n, a) {
|
|
40
40
|
const u = /* @__PURE__ */ new Set([
|
|
41
41
|
...(a.shared ?? []).map((r) => r.name),
|
|
42
42
|
...Ke(n).map((r) => r.name)
|
|
@@ -45,51 +45,51 @@ function Qr(n, a) {
|
|
|
45
45
|
for (; u.has(`shared_query_${s}`); ) s += 1;
|
|
46
46
|
return `shared_query_${s}`;
|
|
47
47
|
}
|
|
48
|
-
function
|
|
49
|
-
const u = new Set(Se(a).map(
|
|
48
|
+
function wr(n, a) {
|
|
49
|
+
const u = new Set(Se(a).map(P));
|
|
50
50
|
let s = n;
|
|
51
51
|
for (let r = 2; u.has(s); r += 1) s = `${n}_${r}`;
|
|
52
52
|
return s;
|
|
53
53
|
}
|
|
54
|
-
function
|
|
55
|
-
const
|
|
54
|
+
function Sr(n, a, u, s = ye(), r) {
|
|
55
|
+
const $ = n.shared ?? [], w = $.findIndex((m) => m.id === r), l = { id: s, name: a, query: u };
|
|
56
56
|
return {
|
|
57
57
|
...n,
|
|
58
|
-
shared: w < 0 ? [
|
|
58
|
+
shared: w < 0 ? [...$, l] : [...$.slice(0, w), l, ...$.slice(w)]
|
|
59
59
|
};
|
|
60
60
|
}
|
|
61
61
|
const Fe = (n, a) => {
|
|
62
62
|
var u;
|
|
63
63
|
return (u = n.shared) == null ? void 0 : u.find((s) => s.id === a);
|
|
64
64
|
};
|
|
65
|
-
function
|
|
65
|
+
function Wr(n, a, u, s = {}) {
|
|
66
66
|
const r = Fe(n, u);
|
|
67
67
|
if (!r) return a;
|
|
68
|
-
const
|
|
68
|
+
const $ = {
|
|
69
69
|
id: s.id ?? ye(),
|
|
70
70
|
shared: u,
|
|
71
|
-
alias:
|
|
71
|
+
alias: wr(r.name, a),
|
|
72
72
|
joinType: s.joinType ?? "inner",
|
|
73
73
|
...s.on ? { on: s.on } : {}
|
|
74
74
|
};
|
|
75
|
-
return { ...a, joins: [...a.joins,
|
|
75
|
+
return { ...a, joins: [...a.joins, $] };
|
|
76
76
|
}
|
|
77
|
-
function
|
|
77
|
+
function qr(n, a, u) {
|
|
78
78
|
const s = Fe(n, u);
|
|
79
79
|
return s ? { ...a, from: { shared: u, alias: s.name } } : a;
|
|
80
80
|
}
|
|
81
|
-
function
|
|
82
|
-
const r = rr(n, s),
|
|
83
|
-
if (
|
|
81
|
+
function Jr(n, a, u = ye(), s = []) {
|
|
82
|
+
const r = rr(n, s), $ = r && nr(r).find((d) => d.id === a);
|
|
83
|
+
if (!$) return n;
|
|
84
84
|
const w = new Set((n.shared ?? []).map((d) => d.name));
|
|
85
|
-
let l =
|
|
86
|
-
for (let d = 2; w.has(l); d += 1) l = `${
|
|
87
|
-
const m =
|
|
88
|
-
return tr(m, s, (d) => d.from.query && d.from.id === a ? { ...d, from: { shared: u, alias:
|
|
85
|
+
let l = $.alias;
|
|
86
|
+
for (let d = 2; w.has(l); d += 1) l = `${$.alias}_${d}`;
|
|
87
|
+
const m = Sr(n, l, $.query, u, s[0]);
|
|
88
|
+
return tr(m, s, (d) => d.from.query && d.from.id === a ? { ...d, from: { shared: u, alias: $.alias } } : {
|
|
89
89
|
...d,
|
|
90
90
|
joins: d.joins.map((O) => {
|
|
91
91
|
if (O.id !== a || !O.query) return O;
|
|
92
|
-
const { query:
|
|
92
|
+
const { query: h, ...E } = O;
|
|
93
93
|
return { ...E, shared: u };
|
|
94
94
|
})
|
|
95
95
|
});
|
|
@@ -98,37 +98,37 @@ function We(n, a) {
|
|
|
98
98
|
const { shared: u, ...s } = n;
|
|
99
99
|
return "joinType" in s ? { ...s, query: a } : { id: ye(), alias: s.alias, query: a };
|
|
100
100
|
}
|
|
101
|
-
function
|
|
101
|
+
function Pr(n, a) {
|
|
102
102
|
const u = new Map((n.shared ?? []).map((r) => [r.id, r.query])), s = a.reduce(
|
|
103
|
-
(r,
|
|
103
|
+
(r, $) => typeof r == "object" && r !== null ? r[$] : void 0,
|
|
104
104
|
n
|
|
105
105
|
);
|
|
106
106
|
return !Ae(s) || !Ne(s) ? n : me(n, (r) => {
|
|
107
|
-
const
|
|
108
|
-
return r === s &&
|
|
107
|
+
const $ = u.get(r.shared);
|
|
108
|
+
return r === s && $ ? We(r, $) : r;
|
|
109
109
|
});
|
|
110
110
|
}
|
|
111
|
-
function
|
|
111
|
+
function Xr(n, a, u) {
|
|
112
112
|
var s;
|
|
113
113
|
return !((s = n.shared) != null && s.some((r) => r.id === a)) || u === "" ? n : {
|
|
114
114
|
...n,
|
|
115
115
|
shared: n.shared.map((r) => r.id === a ? { ...r, name: u } : r)
|
|
116
116
|
};
|
|
117
117
|
}
|
|
118
|
-
class
|
|
118
|
+
class Er extends Error {
|
|
119
119
|
constructor(a) {
|
|
120
120
|
super(`removeSharedQuery: "${a}" is a query's base: make it a sub query there instead`), this.name = "SharedBaseError";
|
|
121
121
|
}
|
|
122
122
|
}
|
|
123
|
-
function
|
|
123
|
+
function Kr(n, a, u = "subQueries") {
|
|
124
124
|
var m;
|
|
125
125
|
const s = (m = n.shared) == null ? void 0 : m.find((d) => d.id === a);
|
|
126
126
|
if (!s) return n;
|
|
127
|
-
const r = n.shared.filter((d) => d !== s), { shared:
|
|
127
|
+
const r = n.shared.filter((d) => d !== s), { shared: $, ...w } = n, l = r.length > 0 ? { ...w, shared: r } : w;
|
|
128
128
|
return me(l, (d) => {
|
|
129
129
|
if (d.shared !== a) return d;
|
|
130
130
|
if (u === "subQueries") return We(d, s.query);
|
|
131
|
-
if (!("joinType" in d)) throw new
|
|
131
|
+
if (!("joinType" in d)) throw new Er(s.name);
|
|
132
132
|
});
|
|
133
133
|
}
|
|
134
134
|
const Le = (n, a) => n.type === "binary" && n.operator === "IS NULL" && te(n.left, a);
|
|
@@ -145,15 +145,15 @@ function ve(n) {
|
|
|
145
145
|
}
|
|
146
146
|
return [];
|
|
147
147
|
}
|
|
148
|
-
function
|
|
148
|
+
function kr(n, a) {
|
|
149
149
|
const u = n.groupBy ?? [];
|
|
150
150
|
return u.length > 0 && u.every((s) => n.select.some((r) => te(r.expression, s.expression) && a.includes(be(r) ?? "")));
|
|
151
151
|
}
|
|
152
|
-
function
|
|
153
|
-
const u =
|
|
152
|
+
function Ar(n, a) {
|
|
153
|
+
const u = P(n.from), s = /* @__PURE__ */ new Map([[u, n.from.table]]), r = [u], $ = n.shared ?? [];
|
|
154
154
|
return n.joins.map((w) => {
|
|
155
|
-
var E,
|
|
156
|
-
const { id: l } = w, m = Re(w,
|
|
155
|
+
var E, k;
|
|
156
|
+
const { id: l } = w, m = Re(w, $), d = P(w);
|
|
157
157
|
s.set(d, w.table);
|
|
158
158
|
const O = ve(w.on).flatMap(([x, j]) => [[x, j], [j, x]]).filter(([x, j]) => x.table === d && r.includes(j.table ?? ""));
|
|
159
159
|
if (r.push(d), w.joinType === "cross")
|
|
@@ -164,7 +164,7 @@ function kr(n, a) {
|
|
|
164
164
|
side: m && Qe(m) ? "one" : "cross"
|
|
165
165
|
};
|
|
166
166
|
if (w.table === void 0) {
|
|
167
|
-
const x = O.length > 0 && m !== void 0 && !Ee(m) &&
|
|
167
|
+
const x = O.length > 0 && m !== void 0 && !Ee(m) && kr(m, O.map(([j]) => j.column));
|
|
168
168
|
return {
|
|
169
169
|
joinId: l,
|
|
170
170
|
key: d,
|
|
@@ -191,121 +191,121 @@ function kr(n, a) {
|
|
|
191
191
|
}).find((x) => x !== void 0) ?? {
|
|
192
192
|
joinId: l,
|
|
193
193
|
key: d,
|
|
194
|
-
parent: ((
|
|
194
|
+
parent: ((k = O[0]) == null ? void 0 : k[1].table) ?? u,
|
|
195
195
|
side: "unknown"
|
|
196
196
|
};
|
|
197
197
|
});
|
|
198
198
|
}
|
|
199
199
|
function we(n, a, u = {}) {
|
|
200
|
-
const s =
|
|
200
|
+
const s = Ar(n, a).map((l) => l.side === "unknown" && u.unknown === "repeat" ? { ...l, side: "many" } : l), r = [P(n.from), ...s.map((l) => l.key)], $ = (l) => {
|
|
201
201
|
const m = /* @__PURE__ */ new Set([l]);
|
|
202
202
|
return s.forEach((d) => {
|
|
203
203
|
m.has(d.parent) && m.add(d.key);
|
|
204
204
|
}), m;
|
|
205
205
|
}, w = /* @__PURE__ */ new Set();
|
|
206
206
|
return s.forEach((l) => {
|
|
207
|
-
const m =
|
|
207
|
+
const m = $(l.key);
|
|
208
208
|
l.side === "many" && r.filter((d) => !m.has(d)).forEach((d) => w.add(d)), l.side === "one" && m.forEach((d) => w.add(d)), l.side === "cross" && r.forEach((d) => w.add(d));
|
|
209
209
|
}), w;
|
|
210
210
|
}
|
|
211
|
-
const
|
|
212
|
-
function
|
|
213
|
-
return n.type === "field" ? n.table && a.has(n.table) ? [n.table] : [] : [...new Set(ke(n).flatMap((u) =>
|
|
211
|
+
const Nr = /* @__PURE__ */ new Set(["SUM", "AVG", "COUNT"]);
|
|
212
|
+
function Tr(n, a) {
|
|
213
|
+
return n.type === "field" ? n.table && a.has(n.table) ? [n.table] : [] : [...new Set(ke(n).flatMap((u) => Tr(u, a)))];
|
|
214
214
|
}
|
|
215
|
-
function
|
|
216
|
-
const u =
|
|
215
|
+
function Hr(n, a) {
|
|
216
|
+
const u = P(n.from);
|
|
217
217
|
return n.joins.some((r) => r.joinType === "right" || r.joinType === "full") || we(n, a).has(u) ? "many" : we(n, a, { unknown: "repeat" }).has(u) ? "unknown" : "one";
|
|
218
218
|
}
|
|
219
219
|
function qe(n, a, u = !1) {
|
|
220
|
-
const s = n.type === "function" &&
|
|
221
|
-
return n.type === "field" ? r && n.table && a.has(n.table) ? [n.table] : [] : ke(n).flatMap((
|
|
220
|
+
const s = n.type === "function" && Nr.has(n.name.toUpperCase()) && !n.distinct, r = u || s;
|
|
221
|
+
return n.type === "field" ? r && n.table && a.has(n.table) ? [n.table] : [] : ke(n).flatMap(($) => qe($, a, r));
|
|
222
222
|
}
|
|
223
|
-
function
|
|
223
|
+
function xr(n, a) {
|
|
224
224
|
const u = we(n, a), s = /* @__PURE__ */ new Set(), r = (m) => {
|
|
225
225
|
const d = m ? qe(m, u) : [];
|
|
226
226
|
return d.forEach((O) => s.add(O)), d.length > 0;
|
|
227
|
-
},
|
|
227
|
+
}, $ = n.select.filter((m) => r(m.expression)).map((m) => m.id), w = (n.orderBy ?? []).filter((m) => r(m.expression)).map((m) => m.id), l = r(n.having);
|
|
228
228
|
return {
|
|
229
229
|
tables: [...s],
|
|
230
|
-
select:
|
|
230
|
+
select: $,
|
|
231
231
|
orderBy: w,
|
|
232
232
|
having: l
|
|
233
233
|
};
|
|
234
234
|
}
|
|
235
|
-
function
|
|
235
|
+
function Br(n) {
|
|
236
236
|
return !n.distinct || !n.orderBy ? [] : n.orderBy.filter(({ expression: a }) => !(a.type === "field" && !a.column)).filter(({ expression: a }) => n.select.length === 0 ? a.type !== "field" : !n.select.some((u) => te(u.expression, ir(a)))).map(({ id: a }) => a);
|
|
237
237
|
}
|
|
238
|
-
function
|
|
238
|
+
function Ir(n, a, u, s) {
|
|
239
239
|
const r = new Map(s);
|
|
240
|
-
return Se(a).forEach((
|
|
240
|
+
return Se(a).forEach(($) => {
|
|
241
241
|
var l;
|
|
242
|
-
const w =
|
|
243
|
-
const m = Re(
|
|
242
|
+
const w = $.table !== void 0 ? (l = $e(n, $.table)) == null ? void 0 : l.columns : (() => {
|
|
243
|
+
const m = Re($, u);
|
|
244
244
|
return m && De(n, m, u);
|
|
245
245
|
})();
|
|
246
|
-
r.set(
|
|
246
|
+
r.set(P($), new Set((w ?? []).filter((m) => m.joinOnly).map((m) => m.name)));
|
|
247
247
|
}), r;
|
|
248
248
|
}
|
|
249
|
-
function
|
|
249
|
+
function Or(n, a) {
|
|
250
250
|
const u = [], s = a.shared ?? [], r = (l, m, d, O) => {
|
|
251
251
|
var E;
|
|
252
252
|
if (Array.isArray(l)) {
|
|
253
|
-
l.forEach((
|
|
253
|
+
l.forEach((k, x) => r(k, [...m, x], d, O));
|
|
254
254
|
return;
|
|
255
255
|
}
|
|
256
256
|
if (typeof l != "object" || l === null || l instanceof Date) return;
|
|
257
|
-
const
|
|
258
|
-
if (
|
|
259
|
-
const { table:
|
|
260
|
-
!O &&
|
|
257
|
+
const h = l;
|
|
258
|
+
if (h.type === "field") {
|
|
259
|
+
const { table: k, column: x } = h;
|
|
260
|
+
!O && k && x && ((E = d.get(k)) != null && E.has(x)) && u.push(m);
|
|
261
261
|
return;
|
|
262
262
|
}
|
|
263
|
-
if (
|
|
264
|
-
w(
|
|
263
|
+
if (h.type === "subquery") {
|
|
264
|
+
w(h.query, [...m, "query"], !0);
|
|
265
265
|
return;
|
|
266
266
|
}
|
|
267
|
-
if (
|
|
268
|
-
const
|
|
269
|
-
w(
|
|
267
|
+
if (h.type === "exists") {
|
|
268
|
+
const k = h.query;
|
|
269
|
+
w(k, [...m, "query"], !1, d);
|
|
270
270
|
return;
|
|
271
271
|
}
|
|
272
|
-
Object.entries(
|
|
273
|
-
},
|
|
272
|
+
Object.entries(h).forEach(([k, x]) => r(x, [...m, k], d, O));
|
|
273
|
+
}, $ = (l, m) => {
|
|
274
274
|
"union" in l ? _e(l).forEach((d, O) => w(d, [...m, "union", O], !0)) : w(l, m, !0);
|
|
275
275
|
};
|
|
276
276
|
function w(l, m, d, O) {
|
|
277
|
-
var
|
|
278
|
-
const
|
|
279
|
-
l.from.query &&
|
|
280
|
-
M.query &&
|
|
281
|
-
}), l.where && r(l.where, [...m, "where"],
|
|
277
|
+
var k, x, j;
|
|
278
|
+
const h = Ir(n, l, s, O);
|
|
279
|
+
l.from.query && $(l.from.query, [...m, "from", "query"]), l.joins.forEach((M, T) => {
|
|
280
|
+
M.query && $(M.query, [...m, "joins", T, "query"]), M.on && r(M.on, [...m, "joins", T, "on"], h, !0);
|
|
281
|
+
}), l.where && r(l.where, [...m, "where"], h, !1);
|
|
282
282
|
const E = l;
|
|
283
|
-
(
|
|
283
|
+
(k = E.select) == null || k.forEach((M, T) => r(
|
|
284
284
|
M.expression,
|
|
285
285
|
[...m, "select", T, "expression"],
|
|
286
|
-
|
|
286
|
+
h,
|
|
287
287
|
d
|
|
288
288
|
)), (x = E.groupBy) == null || x.forEach((M, T) => r(
|
|
289
289
|
M.expression,
|
|
290
290
|
[...m, "groupBy", T, "expression"],
|
|
291
|
-
|
|
291
|
+
h,
|
|
292
292
|
d
|
|
293
|
-
)), E.having && r(E.having, [...m, "having"],
|
|
293
|
+
)), E.having && r(E.having, [...m, "having"], h, !1), (j = E.orderBy) == null || j.forEach((M, T) => r(
|
|
294
294
|
M.expression,
|
|
295
295
|
[...m, "orderBy", T, "expression"],
|
|
296
|
-
|
|
296
|
+
h,
|
|
297
297
|
!1
|
|
298
298
|
));
|
|
299
299
|
}
|
|
300
|
-
return s.forEach((l, m) =>
|
|
300
|
+
return s.forEach((l, m) => $(l.query, ["shared", m, "query"])), w(a, [], !1), u;
|
|
301
301
|
}
|
|
302
|
-
function
|
|
302
|
+
function zr(n, a) {
|
|
303
303
|
return !(n === "mssql" && a === "REGEXP");
|
|
304
304
|
}
|
|
305
|
-
function
|
|
305
|
+
function jr(n, a) {
|
|
306
306
|
return !(n === "mysql" && a === "full");
|
|
307
307
|
}
|
|
308
|
-
const
|
|
308
|
+
const Vr = [
|
|
309
309
|
"invalidStructure",
|
|
310
310
|
"duplicateId",
|
|
311
311
|
"unknownTable",
|
|
@@ -345,7 +345,7 @@ const Hr = [
|
|
|
345
345
|
"sharedOrder",
|
|
346
346
|
"unusedShared",
|
|
347
347
|
"joinOnlyColumn"
|
|
348
|
-
],
|
|
348
|
+
], Yr = [
|
|
349
349
|
"fanOut",
|
|
350
350
|
"crossJoin",
|
|
351
351
|
"unlinkedJoin",
|
|
@@ -357,10 +357,10 @@ const Hr = [
|
|
|
357
357
|
"unknownAggregate",
|
|
358
358
|
"unusedShared"
|
|
359
359
|
];
|
|
360
|
-
function
|
|
360
|
+
function Mr(n) {
|
|
361
361
|
return [...n.matchAll(/([A-Za-z_][A-Za-z0-9_]*)|\[(\d+)\]/g)].map(([, a, u]) => a ?? Number(u));
|
|
362
362
|
}
|
|
363
|
-
const de = (n) => n === "integer" ? "number" : n === "dateTime" ? "date" : n, z = {
|
|
363
|
+
const Cr = /* @__PURE__ */ new Set(["binary", "logical", "not", "exists"]), de = (n) => n === "integer" ? "number" : n === "dateTime" ? "date" : n, z = {
|
|
364
364
|
text: "text",
|
|
365
365
|
integer: "a whole number",
|
|
366
366
|
number: "a number",
|
|
@@ -368,143 +368,143 @@ const de = (n) => n === "integer" ? "number" : n === "dateTime" ? "date" : n, z
|
|
|
368
368
|
dateTime: "a date and time",
|
|
369
369
|
time: "a time of day",
|
|
370
370
|
boolean: "yes / no"
|
|
371
|
-
},
|
|
372
|
-
function
|
|
371
|
+
}, B = (n) => typeof n == "object" && n !== null && !Array.isArray(n), G = (n) => typeof n == "string", Ur = ["day", "week", "month", "year"], Gr = (n) => B(n) && Ur.includes(n.unit) && Number.isSafeInteger(n.offset) && (n.anchor === void 0 || n.unit !== "day" && (n.anchor === "start" || n.anchor === "end")), Z = (n) => n === void 0 || G(n), Lr = (n) => n === null || G(n) || typeof n == "boolean" || typeof n == "bigint" || typeof n == "number" && Number.isFinite(n) || n instanceof Date && !Number.isNaN(n.getTime()), pe = (n) => B(n) && n.type === "literal" && n.value === "" && n.empty !== !0;
|
|
372
|
+
function Zr(n, a, u = {}) {
|
|
373
373
|
var Ie, Oe;
|
|
374
374
|
const s = [], r = (e, t, o, i = "error") => {
|
|
375
375
|
s.push({
|
|
376
376
|
kind: e,
|
|
377
377
|
severity: i,
|
|
378
378
|
path: t,
|
|
379
|
-
pathSegments:
|
|
379
|
+
pathSegments: Mr(t),
|
|
380
380
|
message: o
|
|
381
381
|
});
|
|
382
382
|
};
|
|
383
|
-
if (!
|
|
383
|
+
if (!B(a) || !G(a.id) || a.id === "")
|
|
384
384
|
return r("invalidStructure", "", "a query is an object with a non-empty string id"), s;
|
|
385
385
|
if (!("from" in a)) return s;
|
|
386
|
-
const
|
|
386
|
+
const $ = He(n, u.tableFilter, u.columnFilter), w = ze(u.functions ?? Ve);
|
|
387
387
|
let l = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Map(), d;
|
|
388
388
|
const O = (e, t, o, i) => {
|
|
389
389
|
G(e) && e.length > t && r("tooLong", o, `${i} is longer than ${t} characters`);
|
|
390
|
-
},
|
|
390
|
+
}, h = /* @__PURE__ */ new Set(), E = B(a) && Array.isArray(a.shared) ? a.shared : [], k = new Set(E.flatMap((e) => B(e) && G(e.id) ? [e.id] : [])), x = /* @__PURE__ */ new Map(), j = /* @__PURE__ */ new Set();
|
|
391
391
|
let M;
|
|
392
392
|
const T = (e, t) => {
|
|
393
393
|
l.has(e) && r("duplicateTableName", t, `two tables named "${e}"`);
|
|
394
394
|
}, _ = (e, t) => {
|
|
395
|
-
Ce.includes(e) && !
|
|
395
|
+
Ce.includes(e) && !jr(u.dialect, e) && r("dialectUnsupported", t, `${e.toUpperCase()} JOIN isn't in this database`);
|
|
396
396
|
}, q = (e, t, o = !1) => {
|
|
397
|
-
if (o &&
|
|
397
|
+
if (o && B(e) && e.query !== void 0) {
|
|
398
398
|
M(e, t);
|
|
399
399
|
return;
|
|
400
400
|
}
|
|
401
|
-
if (o &&
|
|
402
|
-
const { shared:
|
|
403
|
-
if (!G(
|
|
404
|
-
r("invalidStructure", t, "a shared query's place has a string `shared` and an `alias`, and no `table`"),
|
|
401
|
+
if (o && B(e) && e.shared !== void 0) {
|
|
402
|
+
const { shared: v, alias: c } = e, g = G(c) && c !== "";
|
|
403
|
+
if (!G(v) || !g || e.table !== void 0) {
|
|
404
|
+
r("invalidStructure", t, "a shared query's place has a string `shared` and an `alias`, and no `table`"), g && (T(c, `${t}.alias`), l.set(c, void 0));
|
|
405
405
|
return;
|
|
406
406
|
}
|
|
407
|
-
O(c, K, `${t}.alias`, "an alias"), T(c, `${t}.alias`), j.add(
|
|
407
|
+
O(c, K, `${t}.alias`, "an alias"), T(c, `${t}.alias`), j.add(v), k.has(v) ? x.has(v) || r("sharedOrder", `${t}.shared`, "a shared query can use only those before it") : r("unknownTable", `${t}.shared`, `no shared query "${v}"`), l.set(c, x.get(v));
|
|
408
408
|
return;
|
|
409
409
|
}
|
|
410
|
-
if (!
|
|
410
|
+
if (!B(e) || !G(e.table) || !Z(e.alias)) {
|
|
411
411
|
r("invalidStructure", t, "a table entry has a string `table` and optional `alias`");
|
|
412
412
|
return;
|
|
413
413
|
}
|
|
414
414
|
O(e.alias, K, `${t}.alias`, "an alias");
|
|
415
|
-
const i =
|
|
415
|
+
const i = $.tables.find((v) => v.name === e.table);
|
|
416
416
|
i || r("unknownTable", `${t}.table`, `unknown table "${e.table}"`), G(e.alias) && e.alias !== "" ? (T(e.alias, `${t}.alias`), l.set(e.alias, i), m.set(e.table, e.alias)) : (T(e.table, `${t}.table`), l.set(e.table, i));
|
|
417
417
|
}, W = (e, t) => {
|
|
418
418
|
ge(e) && r("misplacedWindow", t, "a window function goes only in SELECT and ORDER BY");
|
|
419
419
|
}, F = (e, t, o) => {
|
|
420
|
-
var
|
|
420
|
+
var y;
|
|
421
421
|
if (!e) return;
|
|
422
|
-
const { args: i, name:
|
|
423
|
-
t < c ? r("incomplete", o, `${
|
|
422
|
+
const { args: i, name: v } = e, c = i.filter((p) => !p.optional).length, g = (y = i[i.length - 1]) != null && y.variadic ? 1 / 0 : i.length;
|
|
423
|
+
t < c ? r("incomplete", o, `${v} needs ${c} argument(s)`) : t > g && r("argCount", o, `${v} takes ${g} argument(s)`);
|
|
424
424
|
};
|
|
425
|
-
let
|
|
425
|
+
let X, ie, se;
|
|
426
426
|
const ae = (e) => {
|
|
427
427
|
const t = e.table && (l.get(e.table) ?? (d == null ? void 0 : d.get(e.table)));
|
|
428
428
|
if (!t || Array.isArray(t)) return;
|
|
429
429
|
const o = t.columns.find((i) => i.name === e.column);
|
|
430
|
-
return o &&
|
|
431
|
-
}, V = (e) =>
|
|
430
|
+
return o && $r(o.type);
|
|
431
|
+
}, V = (e) => pr(e, ae, w), oe = u.typeMismatch ?? "warning", Y = (e, t, o) => {
|
|
432
432
|
if (e.type === "literal") {
|
|
433
|
-
if (e.value === null || e.value === "" && !e.empty || typeof e.value == "number" && !Ue(e.value) ||
|
|
433
|
+
if (e.value === null || e.value === "" && !e.empty || typeof e.value == "number" && !Ue(e.value) || br(e.value, t) !== void 0) return;
|
|
434
434
|
const c = e.value instanceof Date ? "a date" : JSON.stringify(String(e.value));
|
|
435
435
|
r("typeMismatch", o, `${c} isn't ${z[t]}`, oe);
|
|
436
436
|
return;
|
|
437
437
|
}
|
|
438
438
|
const i = V(e);
|
|
439
439
|
if (i === void 0 || de(i) === de(t)) return;
|
|
440
|
-
const
|
|
441
|
-
r("typeMismatch", o,
|
|
440
|
+
const v = `${z[i]} compared with ${z[t]}`;
|
|
441
|
+
r("typeMismatch", o, v, oe);
|
|
442
442
|
}, ce = (e) => e && e.type !== "literal" ? V(e) : void 0, Je = (e, t) => {
|
|
443
|
-
const { operator: o, left: i, right:
|
|
444
|
-
if (!
|
|
445
|
-
const c = (p,
|
|
446
|
-
if (
|
|
447
|
-
const f = ce(
|
|
443
|
+
const { operator: o, left: i, right: v } = e;
|
|
444
|
+
if (!v) return;
|
|
445
|
+
const c = (y, p, b) => {
|
|
446
|
+
if (y.type !== "param" || !y.relative) return;
|
|
447
|
+
const f = ce(p);
|
|
448
448
|
if (f === void 0 || f === "date" || f === "dateTime") return;
|
|
449
449
|
const S = `a relative date compared with ${z[f]}`;
|
|
450
|
-
r("typeMismatch",
|
|
450
|
+
r("typeMismatch", b, S, oe);
|
|
451
451
|
};
|
|
452
|
-
if (c(
|
|
453
|
-
const
|
|
454
|
-
if (
|
|
455
|
-
const
|
|
456
|
-
r("typeMismatch", `${t}.left`,
|
|
452
|
+
if (c(v, i, `${t}.right`), c(i, v, `${t}.left`), o === "LIKE" || o === "REGEXP") {
|
|
453
|
+
const y = ce(i);
|
|
454
|
+
if (y !== void 0 && y !== "text") {
|
|
455
|
+
const p = `${o} matches text, not ${z[y]}`;
|
|
456
|
+
r("typeMismatch", `${t}.left`, p, oe);
|
|
457
457
|
}
|
|
458
|
-
if (
|
|
458
|
+
if (Y(v, "text", `${t}.right`), o === "REGEXP" && v.type === "literal" && G(v.value))
|
|
459
459
|
try {
|
|
460
|
-
new RegExp(
|
|
461
|
-
} catch (
|
|
462
|
-
const
|
|
463
|
-
r("invalidPattern", `${t}.right`,
|
|
460
|
+
new RegExp(v.value);
|
|
461
|
+
} catch (p) {
|
|
462
|
+
const b = `not a regular expression: ${p.message}`;
|
|
463
|
+
r("invalidPattern", `${t}.right`, b);
|
|
464
464
|
}
|
|
465
465
|
return;
|
|
466
466
|
}
|
|
467
|
-
const
|
|
467
|
+
const g = ce(i);
|
|
468
468
|
if (o === "IN" || o === "BETWEEN") {
|
|
469
|
-
if (
|
|
470
|
-
|
|
469
|
+
if (g === void 0 || v.type !== "list") return;
|
|
470
|
+
v.items.forEach((y, p) => Y(y, g, `${t}.right.items[${p}]`));
|
|
471
471
|
return;
|
|
472
472
|
}
|
|
473
|
-
if (
|
|
473
|
+
if (g !== void 0) Y(v, g, `${t}.right`);
|
|
474
474
|
else {
|
|
475
|
-
const
|
|
476
|
-
|
|
475
|
+
const y = ce(v);
|
|
476
|
+
y !== void 0 && Y(i, y, `${t}.left`);
|
|
477
477
|
}
|
|
478
478
|
}, Te = (e) => {
|
|
479
479
|
const t = e.map(([o]) => o.type === "literal" ? Ge(o) : V(o)).find((o) => o !== void 0);
|
|
480
|
-
t !== void 0 && e.forEach(([o, i]) =>
|
|
480
|
+
t !== void 0 && e.forEach(([o, i]) => Y(o, t, i));
|
|
481
481
|
}, R = (e, t, o = !1) => {
|
|
482
|
-
if (!
|
|
482
|
+
if (!B(e) || !G(e.type)) {
|
|
483
483
|
r("invalidStructure", t, "an expression is an object with a string `type`");
|
|
484
484
|
return;
|
|
485
485
|
}
|
|
486
|
-
const i = (c) => r("invalidStructure", t, c),
|
|
487
|
-
e[c] !== void 0 && R(e[c], `${t}.${c}`,
|
|
486
|
+
const i = (c) => r("invalidStructure", t, c), v = (c, g) => {
|
|
487
|
+
e[c] !== void 0 && R(e[c], `${t}.${c}`, g);
|
|
488
488
|
};
|
|
489
|
-
switch (o && e.type === "exists" && i("EXISTS is a condition, not a value"),
|
|
489
|
+
switch (o && e.type === "exists" && i("EXISTS is a condition, not a value"), Z(e.fromSelect) || i("`fromSelect` is a column's id"), e.type) {
|
|
490
490
|
case "literal":
|
|
491
|
-
if (!
|
|
491
|
+
if (!Lr(e.value))
|
|
492
492
|
i("a literal value is a string, number, boolean, date or null");
|
|
493
493
|
else if (e.empty !== void 0 && typeof e.empty != "boolean")
|
|
494
494
|
i("a literal's `empty` is a boolean");
|
|
495
495
|
else if (pe(e))
|
|
496
496
|
r("incomplete", t, "a value not filled in");
|
|
497
497
|
else if (typeof e.value == "number" && !Ue(e.value)) {
|
|
498
|
-
const c = `a number with more than ${
|
|
498
|
+
const c = `a number with more than ${hr} significant digits is written as another number`;
|
|
499
499
|
r("tooLong", `${t}.value`, c);
|
|
500
500
|
} else
|
|
501
|
-
O(e.value,
|
|
501
|
+
O(e.value, gr, `${t}.value`, "a text value");
|
|
502
502
|
break;
|
|
503
503
|
case "param":
|
|
504
|
-
(!G(e.name) || !/^[A-Za-z_][A-Za-z0-9_]*$/.test(e.name)) && i("a param has a plain identifier as its `name`"), e.relative !== void 0 && !
|
|
504
|
+
(!G(e.name) || !/^[A-Za-z_][A-Za-z0-9_]*$/.test(e.name)) && i("a param has a plain identifier as its `name`"), e.relative !== void 0 && !Gr(e.relative) && i("a relative date has a `unit` (day, week, month or year), a whole `offset`, and an `anchor` (start or end) only for a week, month or year"), O(e.name, K, `${t}.name`, "a parameter's name");
|
|
505
505
|
break;
|
|
506
506
|
case "field":
|
|
507
|
-
if (!
|
|
507
|
+
if (!Z(e.table) || !Z(e.column))
|
|
508
508
|
i("a field has string `table` and `column`");
|
|
509
509
|
else if (e.column === void 0 || e.column === "")
|
|
510
510
|
r("incomplete", t, "a field with no column picked");
|
|
@@ -512,14 +512,14 @@ function Vr(n, a, u = {}) {
|
|
|
512
512
|
r("unqualifiedField", t, `column "${e.column}" names no table`);
|
|
513
513
|
else if (l.has(e.table)) {
|
|
514
514
|
const c = l.get(e.table);
|
|
515
|
-
if (!(Array.isArray(c) ? c.includes(e.column) : !c || c.columns.some((
|
|
516
|
-
const
|
|
517
|
-
r("unknownColumn", `${t}.column`, `unknown column "${
|
|
515
|
+
if (!(Array.isArray(c) ? c.includes(e.column) : !c || c.columns.some((y) => y.name === e.column))) {
|
|
516
|
+
const y = `${e.table}.${e.column}`;
|
|
517
|
+
r("unknownColumn", `${t}.column`, `unknown column "${y}"`);
|
|
518
518
|
}
|
|
519
519
|
} else {
|
|
520
520
|
const c = m.get(e.table);
|
|
521
|
-
let
|
|
522
|
-
c ?
|
|
521
|
+
let g = `table "${e.table}" isn't in the query`;
|
|
522
|
+
c ? g = `table "${e.table}" is named "${c}" in the query: use that` : d != null && d.has(e.table) && (g = `table "${e.table}" is the outer query's: only the EXISTS link names it`), r("tableNotInQuery", `${t}.table`, g);
|
|
523
523
|
}
|
|
524
524
|
break;
|
|
525
525
|
case "function": {
|
|
@@ -528,46 +528,46 @@ function Vr(n, a, u = {}) {
|
|
|
528
528
|
break;
|
|
529
529
|
}
|
|
530
530
|
!u.allowUnknownFunctions && !w[e.name.toUpperCase()] && r("unknownFunction", `${t}.name`, `function "${e.name}" isn't allowed`);
|
|
531
|
-
const c = w[e.name.toUpperCase()],
|
|
532
|
-
(e.over === !0 || c != null && c.aggregate) && ge(
|
|
531
|
+
const c = w[e.name.toUpperCase()], g = (b, f) => {
|
|
532
|
+
(e.over === !0 || c != null && c.aggregate) && ge(b) && r("misplacedWindow", f, "a window function can't be inside another, or inside an aggregate"), e.over === !0 && ne(b, w) && r("misplacedAggregate", f, "an aggregate can't be inside a window function: sum up in a sub query first");
|
|
533
533
|
};
|
|
534
|
-
u.dialect && (c != null && c.dialects) && !c.dialects.includes(u.dialect) && r("dialectUnsupported", `${t}.name`, `${c.name} isn't in this database`), O(e.name, K, `${t}.name`, "a function's name"), F(c, e.args.length, `${t}.args`), e.distinct !== void 0 && typeof e.distinct != "boolean" && i("a function's `distinct` is a boolean"), e.distinct === !0 && u.dialect === "mssql" && e.name.toUpperCase() === "STRING_AGG" && r("dialectUnsupported", t, "SQL Server's STRING_AGG can't join only different values"), e.args.forEach((
|
|
535
|
-
var J,
|
|
534
|
+
u.dialect && (c != null && c.dialects) && !c.dialects.includes(u.dialect) && r("dialectUnsupported", `${t}.name`, `${c.name} isn't in this database`), O(e.name, K, `${t}.name`, "a function's name"), F(c, e.args.length, `${t}.args`), e.distinct !== void 0 && typeof e.distinct != "boolean" && i("a function's `distinct` is a boolean"), e.distinct === !0 && u.dialect === "mssql" && e.name.toUpperCase() === "STRING_AGG" && r("dialectUnsupported", t, "SQL Server's STRING_AGG can't join only different values"), e.args.forEach((b, f) => {
|
|
535
|
+
var J, A, N;
|
|
536
536
|
const S = s.length;
|
|
537
|
-
R(
|
|
538
|
-
const U =
|
|
539
|
-
c && ((
|
|
540
|
-
const D = !s.slice(S).some((
|
|
541
|
-
D &&
|
|
537
|
+
R(b, `${t}.args[${f}]`, !0), c && ((J = ee(c, f)) == null ? void 0 : J.kind) === "type-name" && B(b) && O(b.value, yr, `${t}.args[${f}].value`, "a type name"), c && ((A = ee(c, f)) == null ? void 0 : A.kind) === "fixed-text" && B(b) && !(b.type === "literal" && G(b.value)) && i(`${c.name}'s ${ee(c, f).label} is a text value`);
|
|
538
|
+
const U = B(b) && b.type === "literal" ? b.value : void 0;
|
|
539
|
+
c && ((N = ee(c, f)) == null ? void 0 : N.kind) === "fixed-count" && B(b) && !(Number.isInteger(U) && U >= 0) && i(`${c.name}'s ${ee(c, f).label} is a whole number from 0`);
|
|
540
|
+
const D = !s.slice(S).some((I) => I.kind === "invalidStructure");
|
|
541
|
+
D && g(b, `${t}.args[${f}]`), c != null && c.aggregate && D && ne(b, w) && r(
|
|
542
542
|
"misplacedAggregate",
|
|
543
543
|
`${t}.args[${f}]`,
|
|
544
544
|
"an aggregate can't be inside another: sum up per group in a sub query first"
|
|
545
545
|
);
|
|
546
546
|
}), e.over !== void 0 && typeof e.over != "boolean" && i("a function's `over` is a boolean");
|
|
547
|
-
const
|
|
548
|
-
if (
|
|
547
|
+
const y = e.over === !0, p = c == null ? void 0 : c.name;
|
|
548
|
+
if (y && c && !c.window && i(`${p} isn't a window function`), !y && (c != null && c.window) && i(`${p} is a window function: it has \`over\``), e.partitionBy !== void 0) {
|
|
549
549
|
if (!Array.isArray(e.partitionBy)) {
|
|
550
550
|
i("a function's `partitionBy` is an array");
|
|
551
551
|
break;
|
|
552
552
|
}
|
|
553
|
-
|
|
553
|
+
y || i("only a window call (`over`) takes a `partitionBy`"), e.partitionBy.forEach((b, f) => {
|
|
554
554
|
const S = `${t}.partitionBy[${f}]`, U = s.length;
|
|
555
|
-
R(
|
|
555
|
+
R(b, S, !0), s.slice(U).some((D) => D.kind === "invalidStructure") || g(b, S);
|
|
556
556
|
});
|
|
557
557
|
}
|
|
558
|
-
if (
|
|
558
|
+
if (y && !(Array.isArray(e.orderBy) && e.orderBy.length > 0) && r("unorderedWindow", t, "a window function needs an ORDER BY"), e.orderBy !== void 0) {
|
|
559
559
|
if (!Array.isArray(e.orderBy)) {
|
|
560
560
|
i("a function's `orderBy` is an array");
|
|
561
561
|
break;
|
|
562
562
|
}
|
|
563
|
-
e.name.toUpperCase() !== "STRING_AGG" && !
|
|
563
|
+
e.name.toUpperCase() !== "STRING_AGG" && !y && i("only STRING_AGG and window calls take an `orderBy`"), e.orderBy.forEach((b, f) => {
|
|
564
564
|
const S = `${t}.orderBy[${f}]`;
|
|
565
|
-
if (!
|
|
565
|
+
if (!B(b) || b.direction !== "asc" && b.direction !== "desc") {
|
|
566
566
|
r("invalidStructure", S, "a sort key has an `expression` and a `direction`");
|
|
567
567
|
return;
|
|
568
568
|
}
|
|
569
569
|
const U = s.length;
|
|
570
|
-
R(
|
|
570
|
+
R(b.expression, `${S}.expression`, !0), !s.slice(U).some((D) => D.kind === "invalidStructure") && (!y && ne(b.expression, w) && r("misplacedAggregate", `${S}.expression`, "an aggregate can't be inside another"), y && g(b.expression, `${S}.expression`), e.distinct === !0 && u.dialect === "postgres" && !te(b.expression, e.args[0]) && r(
|
|
571
571
|
"dialectUnsupported",
|
|
572
572
|
`${S}.expression`,
|
|
573
573
|
"PostgreSQL orders STRING_AGG of different values by the value only"
|
|
@@ -577,26 +577,38 @@ function Vr(n, a, u = {}) {
|
|
|
577
577
|
break;
|
|
578
578
|
}
|
|
579
579
|
case "binary": {
|
|
580
|
-
e.operator !== void 0 && !
|
|
580
|
+
e.operator !== void 0 && !dr.includes(e.operator) && i(`unknown operator ${JSON.stringify(e.operator)}`), e.operator === "REGEXP" && u.dialect === "mssql" && r("dialectUnsupported", t, "SQL Server has no REGEXP");
|
|
581
581
|
const c = s.length;
|
|
582
582
|
R(e.left, `${t}.left`, !0);
|
|
583
|
-
const
|
|
584
|
-
if (
|
|
583
|
+
const g = s.slice(c).some((y) => y.kind === "incomplete");
|
|
584
|
+
if (mr(e.operator))
|
|
585
585
|
e.right !== void 0 && i(`${String(e.operator)} takes no right side`);
|
|
586
586
|
else if (e.right === void 0)
|
|
587
587
|
r("incomplete", `${t}.right`, "a comparison with nothing to compare to");
|
|
588
|
-
else if (
|
|
588
|
+
else if (B(e.right) && e.right.type === "literal" && e.right.value === null && e.operator !== "IS NOT DISTINCT FROM")
|
|
589
589
|
r("incomplete", `${t}.right`, "compared with NULL (never true): use IS NULL");
|
|
590
|
-
else if (
|
|
590
|
+
else if (B(e.right) && e.right.type === "subquery")
|
|
591
591
|
e.operator === "IN" ? ie(e.right, `${t}.right`) : r("invalidStructure", `${t}.right`, "a sub query is only IN's right side");
|
|
592
592
|
else if (e.operator === "BETWEEN") {
|
|
593
|
-
const { right:
|
|
594
|
-
(
|
|
593
|
+
const { right: y } = e, p = B(y) && y.type === "list" && Array.isArray(y.items) ? y.items : void 0;
|
|
594
|
+
(p == null ? void 0 : p.length) !== 2 ? r("invalidStructure", `${t}.right`, "BETWEEN takes its two bounds as a list (expr.between)") : p.forEach((b, f) => {
|
|
595
595
|
const S = `${t}.right.items[${f}]`;
|
|
596
|
-
|
|
596
|
+
B(b) && b.type === "literal" && b.value === null ? r("incomplete", S, "a bound of NULL (never true)") : g && pe(b) || R(b, S, !0);
|
|
597
597
|
});
|
|
598
|
-
} else
|
|
599
|
-
s.slice(c).some((
|
|
598
|
+
} else B(e.right) && e.right.type === "list" ? e.operator === "IN" ? se(e.right, `${t}.right`) : r("invalidStructure", `${t}.right`, "a list is only IN's or BETWEEN's right side") : e.operator === "IN" ? r("invalidStructure", `${t}.right`, "IN takes a list (expr.list) or a sub query") : g && pe(e.right) || R(e.right, `${t}.right`, !0);
|
|
599
|
+
s.slice(c).some((y) => y.kind === "invalidStructure") || Je(e, t);
|
|
600
|
+
break;
|
|
601
|
+
}
|
|
602
|
+
case "arithmetic": {
|
|
603
|
+
fr.includes(e.operator) || i("a calculation's operator is +, -, * or /");
|
|
604
|
+
const c = s.length;
|
|
605
|
+
["left", "right"].forEach((g) => {
|
|
606
|
+
const y = e[g], p = `${t}.${g}`;
|
|
607
|
+
y === void 0 ? r("incomplete", p, "a calculation with a side missing") : B(y) && Cr.has(y.type) ? r("invalidStructure", p, "a calculation's side is a value, not a condition") : R(y, p, !0);
|
|
608
|
+
}), s.slice(c).some((g) => g.kind === "invalidStructure") || ["left", "right"].forEach((g) => {
|
|
609
|
+
const y = e[g];
|
|
610
|
+
y !== void 0 && Y(y, "number", `${t}.${g}`);
|
|
611
|
+
});
|
|
600
612
|
break;
|
|
601
613
|
}
|
|
602
614
|
case "logical":
|
|
@@ -604,43 +616,43 @@ function Vr(n, a, u = {}) {
|
|
|
604
616
|
i("a logical node has an `operands` array");
|
|
605
617
|
break;
|
|
606
618
|
}
|
|
607
|
-
e.operands.length === 0 && r("incomplete", t, "an empty AND/OR group"), e.operands.forEach((c,
|
|
619
|
+
e.operands.length === 0 && r("incomplete", t, "an empty AND/OR group"), e.operands.forEach((c, g) => R(c, `${t}.operands[${g}]`));
|
|
608
620
|
break;
|
|
609
621
|
case "not": {
|
|
610
622
|
R(e.operand, `${t}.operand`);
|
|
611
623
|
const { operand: c } = e;
|
|
612
|
-
|
|
624
|
+
B(c) && c.type === "binary" && c.operator === "IN" && B(c.right) && c.right.type === "subquery" && r("notInSubquery", t, "NOT IN keeps no rows at all if the sub query gives a NULL: NOT EXISTS doesn't", "warning");
|
|
613
625
|
break;
|
|
614
626
|
}
|
|
615
627
|
case "if": {
|
|
616
|
-
["condition", "then"].forEach((
|
|
617
|
-
e[
|
|
628
|
+
["condition", "then"].forEach((g) => {
|
|
629
|
+
e[g] === void 0 && r("incomplete", `${t}.${g}`, `an IF with no ${g}`);
|
|
618
630
|
});
|
|
619
631
|
const c = s.length;
|
|
620
|
-
|
|
621
|
-
["then", "else"].filter((
|
|
632
|
+
v("condition", !1), v("then", !0), v("else", !0), s.slice(c).some((g) => g.kind === "invalidStructure") || Te(
|
|
633
|
+
["then", "else"].filter((g) => e[g] !== void 0).map((g) => [e[g], `${t}.${g}`])
|
|
622
634
|
);
|
|
623
635
|
break;
|
|
624
636
|
}
|
|
625
637
|
case "case": {
|
|
626
638
|
const c = s.length;
|
|
627
|
-
|
|
628
|
-
if (!
|
|
629
|
-
const
|
|
630
|
-
r("invalidStructure",
|
|
639
|
+
v("subject", !0), Array.isArray(e.branches) ? (e.branches.length === 0 && r("incomplete", t, "a CASE with no WHEN"), e.branches.forEach((y, p) => {
|
|
640
|
+
if (!B(y)) {
|
|
641
|
+
const b = `${t}.branches[${p}]`;
|
|
642
|
+
r("invalidStructure", b, "a branch has `when` and `then`");
|
|
631
643
|
return;
|
|
632
644
|
}
|
|
633
|
-
R(
|
|
645
|
+
R(y.when, `${t}.branches[${p}].when`, e.subject !== void 0), R(y.then, `${t}.branches[${p}].then`, !0);
|
|
634
646
|
})) : i("a case node has a `branches` array");
|
|
635
|
-
const
|
|
636
|
-
|
|
637
|
-
...e.branches.map((
|
|
647
|
+
const g = s.length;
|
|
648
|
+
v("else", !0), Array.isArray(e.branches) && s.slice(c).concat(s.slice(g)).every((y) => y.kind !== "invalidStructure") && Te([
|
|
649
|
+
...e.branches.map((y, p) => [y.then, `${t}.branches[${p}].then`]),
|
|
638
650
|
...e.else === void 0 ? [] : [[e.else, `${t}.else`]]
|
|
639
651
|
]);
|
|
640
652
|
break;
|
|
641
653
|
}
|
|
642
654
|
case "exists":
|
|
643
|
-
|
|
655
|
+
X(e, t);
|
|
644
656
|
break;
|
|
645
657
|
case "subquery":
|
|
646
658
|
i("a sub query is only IN's right side");
|
|
@@ -656,65 +668,65 @@ function Vr(n, a, u = {}) {
|
|
|
656
668
|
Array.isArray(e.items) ? e.items.length === 0 ? r("incomplete", t, "IN with no values") : e.items.forEach((o, i) => R(o, `${t}.items[${i}]`, !0)) : r("invalidStructure", t, "a list has an `items` array");
|
|
657
669
|
}, ie = (e, t) => {
|
|
658
670
|
const { id: o, query: i } = e;
|
|
659
|
-
if (!G(o) || o === "" || !
|
|
671
|
+
if (!G(o) || o === "" || !B(i)) {
|
|
660
672
|
r("invalidStructure", t, "a sub query has a non-empty string `id` and a `query`");
|
|
661
673
|
return;
|
|
662
674
|
}
|
|
663
|
-
|
|
664
|
-
const
|
|
675
|
+
h.has(o) && r("duplicateId", `${t}.id`, `the id "${o}" is used twice`), h.add(o);
|
|
676
|
+
const v = { inQuery: l, aliasOf: m, outerTables: d };
|
|
665
677
|
l = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Map(), d = void 0;
|
|
666
678
|
const c = s.length;
|
|
667
|
-
le(i, `${t}.query`, !1), { inQuery: l, aliasOf: m, outerTables: d } =
|
|
668
|
-
const
|
|
669
|
-
(Array.isArray(i.select) ? i.select : []).length !== 1 && r("subqueryColumns", `${t}.query.select`, "a sub query after IN picks exactly one column to compare with"),
|
|
670
|
-
},
|
|
679
|
+
le(i, `${t}.query`, !1), { inQuery: l, aliasOf: m, outerTables: d } = v;
|
|
680
|
+
const g = s.length === c;
|
|
681
|
+
(Array.isArray(i.select) ? i.select : []).length !== 1 && r("subqueryColumns", `${t}.query.select`, "a sub query after IN picks exactly one column to compare with"), g && ue(i, `${t}.query`);
|
|
682
|
+
}, X = (e, t) => {
|
|
671
683
|
const { query: o, link: i } = e;
|
|
672
|
-
if (!
|
|
684
|
+
if (!B(o) || !Array.isArray(o.joins)) {
|
|
673
685
|
r("invalidStructure", `${t}.query`, "an EXISTS has a `query` with `from` and `joins`");
|
|
674
686
|
return;
|
|
675
687
|
}
|
|
676
|
-
const
|
|
677
|
-
l = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Map(), d =
|
|
688
|
+
const v = { inQuery: l, aliasOf: m, outerTables: d };
|
|
689
|
+
l = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Map(), d = v.inQuery, [
|
|
678
690
|
[o.from, `${t}.query.from`],
|
|
679
|
-
...o.joins.map((
|
|
680
|
-
].forEach(([
|
|
691
|
+
...o.joins.map((p, b) => [p, `${t}.query.joins[${b}]`])
|
|
692
|
+
].forEach(([p, b], f) => {
|
|
681
693
|
const S = new Set(l.keys());
|
|
682
|
-
q(
|
|
694
|
+
q(p, b, f > 0), f > 0 && B(p) && _(p.joinType, `${b}.joinType`), [...l.keys()].filter((U) => !S.has(U) && v.inQuery.has(U)).forEach((U) => r(
|
|
683
695
|
"ambiguousTable",
|
|
684
|
-
`${
|
|
696
|
+
`${b}.table`,
|
|
685
697
|
`"${U}" is a table of the query around it too: give it an alias`
|
|
686
698
|
));
|
|
687
699
|
});
|
|
688
|
-
const
|
|
689
|
-
...o.joins.map((
|
|
690
|
-
|
|
691
|
-
`${t}.query.joins[${
|
|
700
|
+
const g = [
|
|
701
|
+
...o.joins.map((p, b) => [
|
|
702
|
+
B(p) ? p.on : void 0,
|
|
703
|
+
`${t}.query.joins[${b}].on`
|
|
692
704
|
]),
|
|
693
705
|
[o.where, `${t}.query.where`]
|
|
694
706
|
];
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
}), o.joins.forEach((
|
|
698
|
-
|
|
707
|
+
g.forEach(([p, b]) => {
|
|
708
|
+
p !== void 0 && R(p, b);
|
|
709
|
+
}), o.joins.forEach((p, b) => {
|
|
710
|
+
B(p) && p.joinType !== "cross" && p.on === void 0 && r("incomplete", `${t}.query.joins[${b}].on`, "a join with no ON condition");
|
|
699
711
|
});
|
|
700
|
-
const
|
|
701
|
-
l = new Map([...
|
|
702
|
-
|
|
712
|
+
const y = { inQuery: l, aliasOf: m };
|
|
713
|
+
l = new Map([...v.inQuery, ...y.inQuery]), m = new Map([...v.aliasOf, ...y.aliasOf]), d = void 0, R(i, `${t}.link`), { inQuery: l, aliasOf: m, outerTables: d } = v, [...g, [i, `${t}.link`]].forEach(([p, b]) => {
|
|
714
|
+
B(p) && ne(p, w) && r("misplacedAggregate", b, "an aggregate (SUM, COUNT, …) can't be used here"), B(p) && W(p, b);
|
|
703
715
|
});
|
|
704
716
|
};
|
|
705
717
|
const re = (e, t, o = []) => {
|
|
706
718
|
const i = new Set(o);
|
|
707
|
-
e.forEach((
|
|
708
|
-
!
|
|
719
|
+
e.forEach((v, c) => {
|
|
720
|
+
!B(v) || !G(v.id) || v.id === "" ? r("invalidStructure", `${t}[${c}]`, "every entry has a non-empty string id") : i.has(v.id) ? r("duplicateId", `${t}[${c}].id`, `id "${v.id}" is used twice`) : i.add(v.id);
|
|
709
721
|
});
|
|
710
722
|
}, xe = (e, t, o) => Array.isArray(e[t]) ? e[t] : (e[t] !== void 0 && r("invalidStructure", o, `\`${t}\` is an array`), []), le = (e, t, o) => {
|
|
711
723
|
const i = (f) => t ? `${t}.${f}` : f;
|
|
712
724
|
q(e.from, i("from"), !0);
|
|
713
|
-
const { from:
|
|
714
|
-
|
|
715
|
-
const
|
|
716
|
-
Array.isArray(e.joins) || r("invalidStructure", i("joins"), "`joins` is an array"),
|
|
717
|
-
if (
|
|
725
|
+
const { from: v } = e, c = B(v) && v.query !== void 0 ? v.id : void 0;
|
|
726
|
+
B(v) && v.query !== void 0 && (!G(c) || c === "") && r("invalidStructure", i("from"), "a derived table has a non-empty string id");
|
|
727
|
+
const g = Array.isArray(e.joins) ? e.joins : [];
|
|
728
|
+
Array.isArray(e.joins) || r("invalidStructure", i("joins"), "`joins` is an array"), g.forEach((f, S) => q(f, i(`joins[${S}]`), !0)), re(g, i("joins"), G(c) ? [c] : []), g.forEach((f, S) => {
|
|
729
|
+
if (B(f)) {
|
|
718
730
|
if (Ce.includes(f.joinType))
|
|
719
731
|
_(f.joinType, i(`joins[${S}].joinType`));
|
|
720
732
|
else {
|
|
@@ -724,235 +736,235 @@ function Vr(n, a, u = {}) {
|
|
|
724
736
|
f.joinType !== "cross" && (f.on !== void 0 ? R(f.on, i(`joins[${S}].on`)) : r("incomplete", i(`joins[${S}].on`), "a join with no ON condition"));
|
|
725
737
|
}
|
|
726
738
|
}), e.where !== void 0 && R(e.where, i("where"));
|
|
727
|
-
const
|
|
728
|
-
Array.isArray(e.select) || r("invalidStructure", i("select"), "`select` is an array"), re(
|
|
729
|
-
|
|
739
|
+
const y = Array.isArray(e.select) ? e.select : [];
|
|
740
|
+
Array.isArray(e.select) || r("invalidStructure", i("select"), "`select` is an array"), re(y, i("select")), y.forEach((f, S) => {
|
|
741
|
+
B(f) && (O(f.alias, K, i(`select[${S}].alias`), "an alias"), Z(f.alias) || r("invalidStructure", i(`select[${S}].alias`), "an alias is a string"), R(f.expression, i(`select[${S}].expression`), !0));
|
|
730
742
|
});
|
|
731
|
-
const
|
|
732
|
-
if (re(
|
|
733
|
-
|
|
743
|
+
const p = xe(e, "groupBy", i("groupBy"));
|
|
744
|
+
if (re(p, i("groupBy")), p.forEach((f, S) => {
|
|
745
|
+
B(f) && (Z(f.fromSelect) || r("invalidStructure", i(`groupBy[${S}].fromSelect`), "`fromSelect` is a column's id"), R(f.expression, i(`groupBy[${S}].expression`), !0));
|
|
734
746
|
}), e.having !== void 0 && R(e.having, i("having")), e.distinct !== void 0 && typeof e.distinct != "boolean" && r("invalidStructure", i("distinct"), "`distinct` is a boolean"), !o) {
|
|
735
747
|
["orderBy", "limit", "offset", "shared"].forEach((f) => {
|
|
736
748
|
e[f] !== void 0 && r("invalidStructure", i(f), `a derived table has no \`${f}\``);
|
|
737
749
|
});
|
|
738
750
|
return;
|
|
739
751
|
}
|
|
740
|
-
const
|
|
741
|
-
re(
|
|
742
|
-
|
|
752
|
+
const b = xe(e, "orderBy", "orderBy");
|
|
753
|
+
re(b, "orderBy"), b.forEach((f, S) => {
|
|
754
|
+
B(f) && (f.direction !== "asc" && f.direction !== "desc" && r("invalidStructure", `orderBy[${S}].direction`, 'a sort direction is "asc" or "desc"'), R(f.expression, `orderBy[${S}].expression`, !0));
|
|
743
755
|
}), ["limit", "offset"].forEach((f) => {
|
|
744
756
|
const S = e[f];
|
|
745
757
|
S !== void 0 && !(Number.isInteger(S) && S >= 0) ? r("invalidStructure", f, `\`${f}\` is a non-negative integer`) : S !== void 0 && !Number.isSafeInteger(S) && r("tooLong", f, `\`${f}\` is past ${Number.MAX_SAFE_INTEGER}, which is exact`);
|
|
746
758
|
});
|
|
747
|
-
},
|
|
748
|
-
const i = `${t}.query`, { union:
|
|
749
|
-
if (!Array.isArray(
|
|
759
|
+
}, Pe = (e, t, o) => {
|
|
760
|
+
const i = `${t}.query`, { union: v } = e;
|
|
761
|
+
if (!Array.isArray(v) || v.length < 1 || typeof e.all != "boolean") {
|
|
750
762
|
r("invalidStructure", i, "a union has one or more branches in `union`, and a boolean `all`"), T(o, `${t}.alias`), l.set(o, void 0);
|
|
751
763
|
return;
|
|
752
764
|
}
|
|
753
765
|
let c = [];
|
|
754
|
-
const
|
|
755
|
-
let
|
|
756
|
-
|
|
757
|
-
const f = `${i}.union[${
|
|
758
|
-
if (!
|
|
759
|
-
r("invalidStructure", f, "a union's branch is a query"),
|
|
766
|
+
const g = [];
|
|
767
|
+
let y = !0;
|
|
768
|
+
v.forEach((p, b) => {
|
|
769
|
+
const f = `${i}.union[${b}]`;
|
|
770
|
+
if (!B(p)) {
|
|
771
|
+
r("invalidStructure", f, "a union's branch is a query"), y = !1;
|
|
760
772
|
return;
|
|
761
773
|
}
|
|
762
774
|
const S = { inQuery: l, aliasOf: m, outerTables: d };
|
|
763
775
|
l = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Map(), d = void 0;
|
|
764
776
|
const U = s.length;
|
|
765
|
-
le(
|
|
766
|
-
const D = s.length === U, J = (Array.isArray(
|
|
777
|
+
le(p, f, !1);
|
|
778
|
+
const D = s.length === U, J = (Array.isArray(p.select) ? p.select : []).filter(B), A = D ? J.map((I) => I.expression.type === "literal" ? Ge(I.expression) : V(I.expression)) : [];
|
|
767
779
|
if ({ inQuery: l, aliasOf: m, outerTables: d } = S, !D) {
|
|
768
|
-
|
|
780
|
+
y = !1;
|
|
769
781
|
return;
|
|
770
782
|
}
|
|
771
|
-
ue(
|
|
772
|
-
const
|
|
783
|
+
ue(p, f);
|
|
784
|
+
const N = J.map((I) => be(I));
|
|
773
785
|
if (J.length === 0) {
|
|
774
|
-
r("unionColumns", `${f}.select`, "a union's branch names its columns"),
|
|
786
|
+
r("unionColumns", `${f}.select`, "a union's branch names its columns"), y = !1;
|
|
775
787
|
return;
|
|
776
788
|
}
|
|
777
|
-
if (
|
|
778
|
-
c =
|
|
779
|
-
if (
|
|
789
|
+
if (b === 0)
|
|
790
|
+
c = N, N.forEach((I, C) => {
|
|
791
|
+
if (I) return;
|
|
780
792
|
r("derivedColumnName", `${f}.select[${C}]`, "a union's column needs an alias: nothing outside could name it");
|
|
781
|
-
}),
|
|
782
|
-
|
|
793
|
+
}), N.forEach((I, C) => {
|
|
794
|
+
I && N.indexOf(I) !== C && r("derivedColumnName", `${f}.select[${C}]`, `two columns named "${I}"`);
|
|
783
795
|
});
|
|
784
|
-
else if (
|
|
785
|
-
const
|
|
786
|
-
r("unionColumns", `${f}.select`,
|
|
796
|
+
else if (N.length !== c.length) {
|
|
797
|
+
const I = `${N.length} column(s), where the first branch has ${c.length}`;
|
|
798
|
+
r("unionColumns", `${f}.select`, I);
|
|
787
799
|
return;
|
|
788
800
|
} else
|
|
789
|
-
|
|
790
|
-
if (
|
|
791
|
-
const L = `column ${C + 1} is "${String(c[C])}" in the first branch, not "${String(
|
|
801
|
+
N.forEach((I, C) => {
|
|
802
|
+
if (I === c[C]) return;
|
|
803
|
+
const L = `column ${C + 1} is "${String(c[C])}" in the first branch, not "${String(I)}"`;
|
|
792
804
|
r("unionColumns", `${f}.select[${C}]`, L);
|
|
793
805
|
});
|
|
794
|
-
|
|
795
|
-
if (
|
|
796
|
-
const L =
|
|
806
|
+
A.forEach((I, C) => {
|
|
807
|
+
if (I === void 0) return;
|
|
808
|
+
const L = g[C];
|
|
797
809
|
if (L === void 0)
|
|
798
|
-
|
|
799
|
-
else if (de(L) !== de(
|
|
800
|
-
const Q = `column "${String(c[C])}" is ${z[
|
|
810
|
+
g[C] = I;
|
|
811
|
+
else if (de(L) !== de(I)) {
|
|
812
|
+
const Q = `column "${String(c[C])}" is ${z[I]} here, ${z[L]} in a branch before`;
|
|
801
813
|
r("unionTypes", `${f}.select[${C}].expression`, Q);
|
|
802
814
|
}
|
|
803
815
|
});
|
|
804
|
-
}), T(o, `${t}.alias`), l.set(o,
|
|
816
|
+
}), T(o, `${t}.alias`), l.set(o, y ? c.filter((p) => p !== void 0) : void 0);
|
|
805
817
|
};
|
|
806
818
|
M = (e, t) => {
|
|
807
819
|
const { query: o, alias: i } = e;
|
|
808
|
-
if (e.table === void 0 &&
|
|
809
|
-
O(i, K, `${t}.alias`, "an alias"),
|
|
820
|
+
if (e.table === void 0 && B(o) && o.union !== void 0 && G(i) && i !== "") {
|
|
821
|
+
O(i, K, `${t}.alias`, "an alias"), Pe(o, t, i);
|
|
810
822
|
return;
|
|
811
823
|
}
|
|
812
|
-
if (e.table !== void 0 || !
|
|
824
|
+
if (e.table !== void 0 || !B(o) || !G(i) || i === "") {
|
|
813
825
|
r("invalidStructure", t, "a derived table has a `query` and an `alias`, and no `table`"), G(i) && i !== "" && (T(i, `${t}.alias`), l.set(i, void 0));
|
|
814
826
|
return;
|
|
815
827
|
}
|
|
816
828
|
O(i, K, `${t}.alias`, "an alias");
|
|
817
|
-
const
|
|
829
|
+
const v = { inQuery: l, aliasOf: m, outerTables: d };
|
|
818
830
|
l = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Map(), d = void 0;
|
|
819
831
|
const c = s.length;
|
|
820
|
-
le(o, `${t}.query`, !1), { inQuery: l, aliasOf: m, outerTables: d } =
|
|
821
|
-
const
|
|
822
|
-
|
|
832
|
+
le(o, `${t}.query`, !1), { inQuery: l, aliasOf: m, outerTables: d } = v;
|
|
833
|
+
const g = Array.isArray(o.select) ? o.select : [], y = [], p = (S, U) => {
|
|
834
|
+
y.includes(S) ? r("derivedColumnName", U, `two columns named "${S}"`) : y.push(S);
|
|
823
835
|
};
|
|
824
|
-
|
|
825
|
-
if (!
|
|
836
|
+
g.forEach((S, U) => {
|
|
837
|
+
if (!B(S) || !B(S.expression)) return;
|
|
826
838
|
const D = be(S);
|
|
827
|
-
D ?
|
|
839
|
+
D ? p(D, `${t}.query.select[${U}]`) : r("derivedColumnName", `${t}.query.select[${U}]`, "a derived table's column needs an alias: nothing outside could name it");
|
|
828
840
|
});
|
|
829
|
-
const
|
|
830
|
-
|
|
841
|
+
const b = s.length === c;
|
|
842
|
+
b && g.length === 0 && De($, o, E).forEach((S) => p(S.name, `${t}.query.select`)), T(i, `${t}.alias`), l.set(i, b || g.length > 0 ? y : void 0), b && ue(o, `${t}.query`);
|
|
831
843
|
const { drillAcross: f } = e;
|
|
832
|
-
f !== void 0 && !(
|
|
844
|
+
f !== void 0 && !(B(f) && typeof f.synced == "boolean" && Number.isInteger(f.copied) && f.copied >= 0) && r("invalidStructure", `${t}.drillAcross`, "`drillAcross` has a boolean `synced` and a non-negative integer `copied`");
|
|
833
845
|
};
|
|
834
846
|
const ue = (e, t) => {
|
|
835
|
-
var
|
|
836
|
-
const o = (
|
|
847
|
+
var b, f, S, U, D, J;
|
|
848
|
+
const o = (A) => t ? `${t}.${A}` : A, i = or(e);
|
|
837
849
|
if (i) {
|
|
838
|
-
const
|
|
850
|
+
const A = e.joins.findIndex((N) => (N.table ?? P(N)) === i.table);
|
|
839
851
|
r(
|
|
840
852
|
"joinOrder",
|
|
841
|
-
o(`joins[${
|
|
853
|
+
o(`joins[${A}].on`),
|
|
842
854
|
`the join condition of "${i.table}" uses "${i.needs}", which is joined after it`
|
|
843
855
|
);
|
|
844
856
|
}
|
|
845
|
-
const
|
|
846
|
-
ne(
|
|
857
|
+
const v = (A, N) => {
|
|
858
|
+
ne(A, w) && r("misplacedAggregate", N, "an aggregate (SUM, COUNT, …) can't be used here"), W(A, N);
|
|
847
859
|
};
|
|
848
|
-
if (
|
|
849
|
-
|
|
850
|
-
}), (
|
|
851
|
-
const
|
|
852
|
-
ge(
|
|
860
|
+
if (v(e.where, o("where")), e.joins.forEach((A, N) => {
|
|
861
|
+
A.joinType !== "cross" && v(A.on, o(`joins[${N}].on`));
|
|
862
|
+
}), (b = e.groupBy) == null || b.forEach((A, N) => v(A.expression, o(`groupBy[${N}].expression`))), W(e.having, o("having")), he(e, w)) {
|
|
863
|
+
const A = (N, I) => {
|
|
864
|
+
ge(N.expression) && r("groupedWindow", I, "a window function can't be in a grouped query: work it out in a sub query, and group the rows around it");
|
|
853
865
|
};
|
|
854
|
-
e.select.forEach((
|
|
866
|
+
e.select.forEach((N, I) => A(N, o(`select[${I}].expression`))), (f = e.orderBy) == null || f.forEach((N, I) => A(N, `orderBy[${I}].expression`));
|
|
855
867
|
}
|
|
856
|
-
const c = Ye(e, w),
|
|
857
|
-
if (c.selectAll && r("notGrouped", o("select"), "a grouped query has to pick its columns, not *"), e.select.forEach((
|
|
858
|
-
c.select.includes(
|
|
859
|
-
}), (S = e.orderBy) == null || S.forEach((
|
|
860
|
-
c.orderBy.includes(
|
|
861
|
-
}), c.having && r("notGrouped", o("having"), `a column in this condition ${
|
|
862
|
-
const
|
|
868
|
+
const c = Ye(e, w), g = "isn't a group key or an aggregate (SUM, COUNT, …)";
|
|
869
|
+
if (c.selectAll && r("notGrouped", o("select"), "a grouped query has to pick its columns, not *"), e.select.forEach((A, N) => {
|
|
870
|
+
c.select.includes(A.id) && r("notGrouped", o(`select[${N}].expression`), `this column ${g}`);
|
|
871
|
+
}), (S = e.orderBy) == null || S.forEach((A, N) => {
|
|
872
|
+
c.orderBy.includes(A.id) && r("notGrouped", `orderBy[${N}].expression`, `this sort key ${g}`);
|
|
873
|
+
}), c.having && r("notGrouped", o("having"), `a column in this condition ${g}`), u.dialect === "mssql") {
|
|
874
|
+
const A = [], N = (L, Q) => {
|
|
863
875
|
const [H, fe] = L.length <= Q.length ? [L, Q] : [Q, L];
|
|
864
876
|
return H.every((je, Me) => je.direction === fe[Me].direction && te(je.expression, fe[Me].expression));
|
|
865
|
-
},
|
|
877
|
+
}, I = (L) => {
|
|
866
878
|
var H;
|
|
867
|
-
return [...L.type === "function" && ((H = L.orderBy) != null && H.length) ? [L.orderBy] : [], ...ke(L).flatMap(
|
|
879
|
+
return [...L.type === "function" && ((H = L.orderBy) != null && H.length) ? [L.orderBy] : [], ...ke(L).flatMap(I)];
|
|
868
880
|
}, C = (L, Q) => {
|
|
869
|
-
|
|
870
|
-
|
|
881
|
+
I(L).forEach((H) => {
|
|
882
|
+
A.some((fe) => !N(fe, H)) && r(
|
|
871
883
|
"dialectUnsupported",
|
|
872
884
|
Q,
|
|
873
885
|
"SQL Server sorts every STRING_AGG of a query alike: this one's order differs"
|
|
874
|
-
),
|
|
886
|
+
), A.push(H);
|
|
875
887
|
});
|
|
876
888
|
};
|
|
877
889
|
e.select.forEach((L, Q) => C(L.expression, o(`select[${Q}].expression`))), e.having && C(e.having, o("having")), (U = e.orderBy) == null || U.forEach((L, Q) => C(L.expression, `orderBy[${Q}].expression`));
|
|
878
890
|
}
|
|
879
891
|
if (u.allowUnknownFunctions && he(e, w)) {
|
|
880
|
-
const
|
|
881
|
-
Ze(
|
|
892
|
+
const A = (N, I) => {
|
|
893
|
+
Ze(N, w) && r(
|
|
882
894
|
"unknownAggregate",
|
|
883
|
-
|
|
895
|
+
I,
|
|
884
896
|
"a function the editor doesn't know: it isn't made a group key, in case it sums rows up — declare it in `functions` (`aggregate: true` if it does)",
|
|
885
897
|
"warning"
|
|
886
898
|
);
|
|
887
899
|
};
|
|
888
|
-
e.select.forEach((
|
|
900
|
+
e.select.forEach((N, I) => A(N.expression, o(`select[${I}].expression`))), (D = e.orderBy) == null || D.forEach((N, I) => A(N.expression, `orderBy[${I}].expression`)), A(e.having, o("having"));
|
|
889
901
|
}
|
|
890
|
-
e.joins.forEach((
|
|
891
|
-
if (
|
|
892
|
-
const
|
|
893
|
-
|
|
902
|
+
e.joins.forEach((A, N) => {
|
|
903
|
+
if (A.joinType === "cross" || !A.on) return;
|
|
904
|
+
const I = cr(A.on), C = P(A), L = Se(e).slice(0, N + 1).map(P);
|
|
905
|
+
I.some((Q) => Q !== C && !L.includes(Q)) || I.includes(C) && I.some((Q) => L.includes(Q)) || r(
|
|
894
906
|
"unlinkedJoin",
|
|
895
|
-
o(`joins[${
|
|
907
|
+
o(`joins[${N}].on`),
|
|
896
908
|
`the join condition of "${C}" doesn't compare it with a table joined before it: every row meets every row it lets through`,
|
|
897
909
|
"warning"
|
|
898
910
|
);
|
|
899
|
-
}), e.joins.forEach((
|
|
911
|
+
}), e.joins.forEach((A, N) => {
|
|
900
912
|
var C;
|
|
901
|
-
if (!
|
|
902
|
-
lr(
|
|
913
|
+
if (!A.query || !((C = A.drillAcross) != null && C.synced)) return;
|
|
914
|
+
lr($, e, A) || r(
|
|
903
915
|
"drillAcrossOutOfStep",
|
|
904
|
-
o(`joins[${
|
|
905
|
-
`"${
|
|
916
|
+
o(`joins[${N}]`),
|
|
917
|
+
`"${A.alias}" is kept in step with the query but doesn't match its grouping`
|
|
906
918
|
);
|
|
907
|
-
const
|
|
908
|
-
|
|
919
|
+
const I = Ee(A.query) ? void 0 : A.query.from.table;
|
|
920
|
+
I !== void 0 && ur($, e, I) && r(
|
|
909
921
|
"drillAcrossFilterMixed",
|
|
910
|
-
o(`joins[${
|
|
911
|
-
`a condition of the query names both what "${
|
|
922
|
+
o(`joins[${N}]`),
|
|
923
|
+
`a condition of the query names both what "${A.alias}" shares and what it doesn't: it isn't applied to it`,
|
|
912
924
|
"warning"
|
|
913
925
|
);
|
|
914
|
-
}), e.joins.forEach((
|
|
915
|
-
|
|
926
|
+
}), e.joins.forEach((A, N) => {
|
|
927
|
+
A.joinType !== "cross" || A.query && Qe(A.query, w) || r(
|
|
916
928
|
"crossJoin",
|
|
917
|
-
o(`joins[${
|
|
918
|
-
`every row of "${
|
|
929
|
+
o(`joins[${N}]`),
|
|
930
|
+
`every row of "${P(A)}" meets every row of the query: they multiply`,
|
|
919
931
|
"warning"
|
|
920
932
|
);
|
|
921
933
|
});
|
|
922
|
-
const
|
|
934
|
+
const y = xr(e, $), p = (A) => r(
|
|
923
935
|
"fanOut",
|
|
924
|
-
|
|
925
|
-
`${
|
|
936
|
+
A,
|
|
937
|
+
`${y.tables.map((N) => `"${N}"`).join(", ")} rows repeat in this join: a sum, average or count of their columns comes out too high`,
|
|
926
938
|
"warning"
|
|
927
939
|
);
|
|
928
|
-
e.select.forEach((
|
|
929
|
-
|
|
930
|
-
}),
|
|
931
|
-
|
|
940
|
+
e.select.forEach((A, N) => {
|
|
941
|
+
y.select.includes(A.id) && p(o(`select[${N}].expression`));
|
|
942
|
+
}), y.having && p(o("having")), (J = e.orderBy) == null || J.forEach((A, N) => {
|
|
943
|
+
y.orderBy.includes(A.id) && p(`orderBy[${N}].expression`);
|
|
932
944
|
});
|
|
933
945
|
};
|
|
934
946
|
a.shared !== void 0 && !Array.isArray(a.shared) && r("invalidStructure", "shared", "`shared` is an array"), re(E, "shared");
|
|
935
947
|
const Be = /* @__PURE__ */ new Set();
|
|
936
948
|
if (E.forEach((e, t) => {
|
|
937
|
-
if (!
|
|
949
|
+
if (!B(e)) return;
|
|
938
950
|
const o = `shared[${t}]`, { name: i } = e;
|
|
939
951
|
!G(i) || i === "" ? r("invalidStructure", `${o}.name`, "a shared query has a non-empty string `name`") : (O(i, K, `${o}.name`, "a name"), Be.has(i) && r("duplicateTableName", `${o}.name`, `two shared queries named "${i}"`), Be.add(i));
|
|
940
|
-
const
|
|
941
|
-
l = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Map(), d = void 0, M({ query: e.query, alias:
|
|
942
|
-
const
|
|
943
|
-
({ inQuery: l, aliasOf: m, outerTables: d } = c), G(e.id) && x.set(e.id, Array.isArray(
|
|
952
|
+
const v = G(i) && i !== "" ? i : o, c = { inQuery: l, aliasOf: m, outerTables: d };
|
|
953
|
+
l = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Map(), d = void 0, M({ query: e.query, alias: v }, o);
|
|
954
|
+
const g = l.get(v);
|
|
955
|
+
({ inQuery: l, aliasOf: m, outerTables: d } = c), G(e.id) && x.set(e.id, Array.isArray(g) ? g : void 0);
|
|
944
956
|
}), le(a, "", !0), s.length === 0) {
|
|
945
957
|
const e = a;
|
|
946
958
|
if (ue(e, ""), u.requireLimit) {
|
|
947
959
|
const { max: o } = u.requireLimit === !0 ? {} : u.requireLimit, i = he(e, w) && !((Ie = e.groupBy) != null && Ie.length);
|
|
948
960
|
e.limit === void 0 && !i ? r("noLimit", "limit", "no LIMIT: the query reads every row", "warning") : o !== void 0 && e.limit !== void 0 && e.limit > o && r("limitTooHigh", "limit", `LIMIT ${e.limit} is above ${o}`, "warning");
|
|
949
961
|
}
|
|
950
|
-
sr(e,
|
|
962
|
+
sr(e, $).forEach((o) => {
|
|
951
963
|
r("paramConflict", "", `param "${o}" is compared against columns of different types`);
|
|
952
964
|
}), ar(e).forEach((o) => {
|
|
953
965
|
r("paramConflict", "", `param "${o}" stands for two different relative dates`);
|
|
954
966
|
});
|
|
955
|
-
const t =
|
|
967
|
+
const t = Br(e);
|
|
956
968
|
(Oe = e.orderBy) == null || Oe.forEach((o, i) => {
|
|
957
969
|
t.includes(o.id) && r(
|
|
958
970
|
"distinctSort",
|
|
@@ -961,27 +973,27 @@ function Vr(n, a, u = {}) {
|
|
|
961
973
|
);
|
|
962
974
|
});
|
|
963
975
|
}
|
|
964
|
-
s.some((e) => e.kind === "invalidStructure") ||
|
|
976
|
+
s.some((e) => e.kind === "invalidStructure") || Or(n, a).forEach((e) => r(
|
|
965
977
|
"joinOnlyColumn",
|
|
966
978
|
e.map((t, o) => typeof t == "number" ? `[${t}]` : `${o ? "." : ""}${t}`).join(""),
|
|
967
979
|
"a column for joining tables only, used outside a join's condition"
|
|
968
980
|
)), E.forEach((e, t) => {
|
|
969
|
-
!
|
|
981
|
+
!B(e) || !G(e.id) || j.has(e.id) || r("unusedShared", `shared[${t}]`, "a shared query used nowhere", "warning");
|
|
970
982
|
});
|
|
971
|
-
const
|
|
972
|
-
return s.filter((e) => e.severity === "error" || !
|
|
983
|
+
const Xe = u.hideWarnings ?? [];
|
|
984
|
+
return s.filter((e) => e.severity === "error" || !Xe.includes(e.kind));
|
|
973
985
|
}
|
|
974
|
-
function
|
|
975
|
-
relativeDate:
|
|
986
|
+
function en(n, a = {
|
|
987
|
+
relativeDate: vr
|
|
976
988
|
}) {
|
|
977
989
|
return a.relativeDate(n);
|
|
978
990
|
}
|
|
979
|
-
function
|
|
991
|
+
function rn({ unit: n, offset: a, anchor: u }) {
|
|
980
992
|
if (n === "day" && a === 0) return "today";
|
|
981
993
|
const s = a < 0 ? `minus_${-a}` : `plus_${a}`;
|
|
982
994
|
return [n, a === 0 ? "0" : s, u].filter(Boolean).join("_");
|
|
983
995
|
}
|
|
984
|
-
const
|
|
996
|
+
const _r = {
|
|
985
997
|
from: "from",
|
|
986
998
|
joins: "from",
|
|
987
999
|
where: "where",
|
|
@@ -993,44 +1005,46 @@ const Gr = {
|
|
|
993
1005
|
limit: "order",
|
|
994
1006
|
offset: "order"
|
|
995
1007
|
};
|
|
996
|
-
function
|
|
997
|
-
const { schema: s, functions: r } = u,
|
|
1008
|
+
function nn(n, a, u = {}) {
|
|
1009
|
+
const { schema: s, functions: r } = u, $ = (h, E) => typeof E == "number" ? h == null ? void 0 : h[E] : void 0, w = (h) => {
|
|
998
1010
|
var E;
|
|
999
|
-
return
|
|
1000
|
-
}, l = (
|
|
1011
|
+
return h.alias || s && h.table !== void 0 && ((E = $e(s, h.table)) == null ? void 0 : E.label) || h.table || "";
|
|
1012
|
+
}, l = (h, E) => {
|
|
1001
1013
|
var M;
|
|
1002
|
-
if (!
|
|
1003
|
-
const [
|
|
1004
|
-
switch (
|
|
1014
|
+
if (!h || E.length === 0) return [];
|
|
1015
|
+
const [k, x, j] = E;
|
|
1016
|
+
switch (h.type) {
|
|
1005
1017
|
case "logical": {
|
|
1006
|
-
const T =
|
|
1018
|
+
const T = $(h.operands, x);
|
|
1007
1019
|
return T ? [{ kind: "condition", number: x + 1 }, ...l(T, E.slice(2))] : [];
|
|
1008
1020
|
}
|
|
1009
1021
|
case "not":
|
|
1010
|
-
return [{ kind: "not" }, ...l(
|
|
1022
|
+
return [{ kind: "not" }, ...l(h.operand, E.slice(1))];
|
|
1011
1023
|
case "binary": {
|
|
1012
|
-
if (
|
|
1013
|
-
const T = { kind: "side", side:
|
|
1014
|
-
return (_ == null ? void 0 : _.type) === "subquery" && x === "query" ? [T, { kind: "inSubQuery" }, ...O(_.query, E.slice(2))] : (_ == null ? void 0 : _.type) === "list" && x === "items" &&
|
|
1024
|
+
if (k !== "left" && k !== "right") return [];
|
|
1025
|
+
const T = { kind: "side", side: k }, _ = h[k];
|
|
1026
|
+
return (_ == null ? void 0 : _.type) === "subquery" && x === "query" ? [T, { kind: "inSubQuery" }, ...O(_.query, E.slice(2))] : (_ == null ? void 0 : _.type) === "list" && x === "items" && $(_.items, j) ? [T, { kind: "listItem", number: j + 1 }] : [T, ...l(_, E.slice(1))];
|
|
1015
1027
|
}
|
|
1028
|
+
case "arithmetic":
|
|
1029
|
+
return k !== "left" && k !== "right" ? [] : [{ kind: "side", side: k }, ...l(h[k], E.slice(1))];
|
|
1016
1030
|
case "function": {
|
|
1017
|
-
const T = { kind: "function", name:
|
|
1018
|
-
if (
|
|
1019
|
-
const W = er(
|
|
1031
|
+
const T = { kind: "function", name: h.name };
|
|
1032
|
+
if (k === "args" && $(h.args, x)) {
|
|
1033
|
+
const W = er(h.name, r), F = W && ((M = ee(W, x)) == null ? void 0 : M.label);
|
|
1020
1034
|
return [
|
|
1021
1035
|
T,
|
|
1022
1036
|
{ kind: "argument", number: x + 1, ...F && { label: F } },
|
|
1023
|
-
...l(
|
|
1037
|
+
...l(h.args[x], E.slice(2))
|
|
1024
1038
|
];
|
|
1025
1039
|
}
|
|
1026
|
-
const _ =
|
|
1040
|
+
const _ = k === "partitionBy" ? $(h.partitionBy, x) : void 0;
|
|
1027
1041
|
if (_)
|
|
1028
1042
|
return [
|
|
1029
1043
|
T,
|
|
1030
1044
|
{ kind: "partitionKey", number: x + 1 },
|
|
1031
1045
|
...l(_, E.slice(2))
|
|
1032
1046
|
];
|
|
1033
|
-
const q =
|
|
1047
|
+
const q = k === "orderBy" ? $(h.orderBy, x) : void 0;
|
|
1034
1048
|
return q ? [
|
|
1035
1049
|
T,
|
|
1036
1050
|
{ kind: "sortKey", number: x + 1 },
|
|
@@ -1038,68 +1052,68 @@ function en(n, a, u = {}) {
|
|
|
1038
1052
|
] : [T];
|
|
1039
1053
|
}
|
|
1040
1054
|
case "if":
|
|
1041
|
-
return
|
|
1055
|
+
return k === "condition" || k === "then" || k === "else" ? [{ kind: "if", part: k }, ...l(h[k], E.slice(1))] : [];
|
|
1042
1056
|
case "case": {
|
|
1043
|
-
if (
|
|
1044
|
-
return [{ kind: "case", part:
|
|
1045
|
-
const T =
|
|
1057
|
+
if (k === "subject" || k === "else")
|
|
1058
|
+
return [{ kind: "case", part: k }, ...l(h[k], E.slice(1))];
|
|
1059
|
+
const T = k === "branches" ? $(h.branches, x) : void 0;
|
|
1046
1060
|
return !T || j !== "when" && j !== "then" ? [] : [
|
|
1047
1061
|
{ kind: "case", part: j, branch: x + 1 },
|
|
1048
1062
|
...l(T[j], E.slice(3))
|
|
1049
1063
|
];
|
|
1050
1064
|
}
|
|
1051
1065
|
case "exists": {
|
|
1052
|
-
const T = { kind: "exists", table: w(
|
|
1053
|
-
return
|
|
1066
|
+
const T = { kind: "exists", table: w(h.query.from) };
|
|
1067
|
+
return k === "link" ? [T, { kind: "existsLink" }] : k === "query" ? [T, ...O(h.query, E.slice(1))] : [T];
|
|
1054
1068
|
}
|
|
1055
1069
|
default:
|
|
1056
1070
|
return [];
|
|
1057
1071
|
}
|
|
1058
|
-
}, m = (
|
|
1059
|
-
if (
|
|
1060
|
-
const
|
|
1061
|
-
return E[0] === "on" ? [
|
|
1072
|
+
}, m = (h, E) => {
|
|
1073
|
+
if (h.query && E[0] === "query") return d(h.alias, h.query, E.slice(1));
|
|
1074
|
+
const k = h.query ? { kind: "subQuery", name: h.alias } : { kind: "table", name: w(h) };
|
|
1075
|
+
return E[0] === "on" ? [k, { kind: "joinCondition" }, ...l(h.on, E.slice(1))] : [k];
|
|
1062
1076
|
};
|
|
1063
|
-
function d(
|
|
1064
|
-
const j = { kind: x, name:
|
|
1065
|
-
if (!Ee(E)) return [j, ...O(E,
|
|
1066
|
-
const M =
|
|
1077
|
+
function d(h, E, k, x = "subQuery") {
|
|
1078
|
+
const j = { kind: x, name: h };
|
|
1079
|
+
if (!Ee(E)) return [j, ...O(E, k)];
|
|
1080
|
+
const M = k[0] === "union" ? $(_e(E), k[1]) : void 0;
|
|
1067
1081
|
if (!M) return [j];
|
|
1068
|
-
const T =
|
|
1069
|
-
return [j, { kind: "unionQuery", number: T }, ...O(M,
|
|
1082
|
+
const T = k[1] + 1;
|
|
1083
|
+
return [j, { kind: "unionQuery", number: T }, ...O(M, k.slice(2))];
|
|
1070
1084
|
}
|
|
1071
|
-
function O(
|
|
1085
|
+
function O(h, E) {
|
|
1072
1086
|
var q, W;
|
|
1073
|
-
const [
|
|
1087
|
+
const [k, x, j] = E, M = _r[String(k)];
|
|
1074
1088
|
if (!M) return [];
|
|
1075
1089
|
const T = { kind: "section", section: M }, _ = E.slice(3);
|
|
1076
|
-
switch (
|
|
1090
|
+
switch (k) {
|
|
1077
1091
|
// A sub query is a place of its own: no "From Tables" before it.
|
|
1078
1092
|
case "from":
|
|
1079
|
-
return
|
|
1093
|
+
return h.from.query ? x === "query" ? d(h.from.alias, h.from.query, E.slice(2)) : [{ kind: "subQuery", name: h.from.alias }] : [T, { kind: "table", name: w(h.from) }];
|
|
1080
1094
|
case "joins": {
|
|
1081
|
-
const F =
|
|
1095
|
+
const F = $(h.joins, x);
|
|
1082
1096
|
return F ? F.query ? m(F, E.slice(2)) : [T, ...m(F, E.slice(2))] : [T];
|
|
1083
1097
|
}
|
|
1084
1098
|
case "where":
|
|
1085
1099
|
case "having":
|
|
1086
|
-
return [T, ...l(
|
|
1100
|
+
return [T, ...l(h[k], E.slice(1))];
|
|
1087
1101
|
case "select": {
|
|
1088
|
-
const F =
|
|
1102
|
+
const F = $(h.select, x);
|
|
1089
1103
|
if (!F) return [T];
|
|
1090
|
-
const { expression:
|
|
1104
|
+
const { expression: X, alias: ie } = F, se = X.type === "field" && s && X.table !== void 0 ? (W = (q = $e(s, X.table)) == null ? void 0 : q.columns.find((V) => V.name === X.column)) == null ? void 0 : W.label : void 0, ae = ie || se;
|
|
1091
1105
|
return [
|
|
1092
1106
|
T,
|
|
1093
1107
|
{ kind: "column", number: x + 1, ...ae && { name: ae } },
|
|
1094
|
-
...j === "expression" ? l(
|
|
1108
|
+
...j === "expression" ? l(X, _) : []
|
|
1095
1109
|
];
|
|
1096
1110
|
}
|
|
1097
1111
|
case "groupBy":
|
|
1098
1112
|
case "orderBy": {
|
|
1099
|
-
const F =
|
|
1113
|
+
const F = $(h[k], x);
|
|
1100
1114
|
return F ? [
|
|
1101
1115
|
T,
|
|
1102
|
-
{ kind:
|
|
1116
|
+
{ kind: k === "groupBy" ? "groupKey" : "sortKey", number: x + 1 },
|
|
1103
1117
|
...j === "expression" ? l(F.expression, _) : []
|
|
1104
1118
|
] : [T];
|
|
1105
1119
|
}
|
|
@@ -1108,34 +1122,34 @@ function en(n, a, u = {}) {
|
|
|
1108
1122
|
}
|
|
1109
1123
|
}
|
|
1110
1124
|
if (a[0] === "shared") {
|
|
1111
|
-
const
|
|
1112
|
-
return
|
|
1125
|
+
const h = $(n.shared, a[1]);
|
|
1126
|
+
return h ? a[2] === "query" ? d(h.name, h.query, a.slice(3), "sharedQuery") : [{ kind: "sharedQuery", name: h.name }] : [];
|
|
1113
1127
|
}
|
|
1114
1128
|
return O(n, a);
|
|
1115
1129
|
}
|
|
1116
1130
|
export {
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1131
|
+
Vr as Q,
|
|
1132
|
+
Er as S,
|
|
1133
|
+
Sr as a,
|
|
1134
|
+
Pr as b,
|
|
1135
|
+
Xr as c,
|
|
1136
|
+
Fr as d,
|
|
1137
|
+
Dr as e,
|
|
1138
|
+
Ar as f,
|
|
1139
|
+
Tr as g,
|
|
1126
1140
|
we as h,
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
+
Hr as i,
|
|
1142
|
+
Wr as j,
|
|
1143
|
+
en as k,
|
|
1144
|
+
Yr as l,
|
|
1145
|
+
Jr as m,
|
|
1146
|
+
nn as n,
|
|
1147
|
+
zr as o,
|
|
1148
|
+
rn as p,
|
|
1149
|
+
jr as q,
|
|
1150
|
+
Kr as r,
|
|
1151
|
+
qr as s,
|
|
1152
|
+
Br as t,
|
|
1153
|
+
xr as u,
|
|
1154
|
+
Zr as v
|
|
1141
1155
|
};
|