@voltro/database 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/dist/index.d.ts +40 -0
- package/dist/index.js +489 -489
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { $ as e, A as t, At as n, B as r, C as i, Ct as a, D as o, Dt as s, E as c, Et as l, F as u, G as d, H as f, I as p, J as m, K as h, L as g, M as ee, N as
|
|
2
|
-
import { Chunk as
|
|
3
|
-
import { ansi as
|
|
1
|
+
import { $ as e, A as t, At as n, B as r, C as i, Ct as a, D as o, Dt as s, E as c, Et as l, F as u, G as d, H as f, I as p, J as m, K as h, L as g, M as ee, N as _, O as v, Ot as y, P as b, Q as x, R as te, S, St as C, T as ne, Tt as re, U as ie, V as w, W as ae, X as oe, Y as se, Z as ce, _ as le, _t as ue, a as de, at as fe, b as pe, bt as T, c as me, ct as he, d as ge, dt as _e, et as ve, f as ye, ft as be, g as xe, gt as Se, h as Ce, ht as we, i as E, it as Te, j as Ee, k as De, kt as D, l as Oe, lt as ke, m as Ae, mt as je, n as Me, nt as Ne, o as Pe, ot as Fe, p as Ie, pt as Le, q as Re, r as ze, rt as Be, s as Ve, st as He, t as Ue, tt as We, u as Ge, ut as Ke, v as qe, vt as Je, w as Ye, wt as Xe, x as Ze, xt as Qe, y as $e, yt as O, z as et } from "./fileBased-Cc-F1oFv.js";
|
|
2
|
+
import { Chunk as tt, Data as nt, Effect as rt, Option as k, Schema as A, Stream as it } from "effect";
|
|
3
|
+
import { ansi as j } from "@voltro/logger";
|
|
4
4
|
//#region src/arrayCodec.ts
|
|
5
|
-
var
|
|
5
|
+
var at = (e) => e === "mysql" || e === "mariadb" || e === "mssql" || e === "sqlite", ot = (e) => {
|
|
6
6
|
let t = [];
|
|
7
7
|
for (let [n, r] of Object.entries(e.fields)) r.type === "array" && t.push(n);
|
|
8
8
|
return t;
|
|
9
|
-
},
|
|
10
|
-
if (!
|
|
11
|
-
let r =
|
|
9
|
+
}, st = (e, t, n) => {
|
|
10
|
+
if (!at(n) || !t) return e;
|
|
11
|
+
let r = ot(t);
|
|
12
12
|
if (r.length === 0) return e;
|
|
13
13
|
let i = { ...e };
|
|
14
14
|
for (let e of r) {
|
|
@@ -16,9 +16,9 @@ var ot = (e) => e === "mysql" || e === "mariadb" || e === "mssql" || e === "sqli
|
|
|
16
16
|
Array.isArray(t) && (i[e] = JSON.stringify(t));
|
|
17
17
|
}
|
|
18
18
|
return i;
|
|
19
|
-
},
|
|
20
|
-
if (!
|
|
21
|
-
let r =
|
|
19
|
+
}, ct = (e, t, n) => {
|
|
20
|
+
if (!at(n) || !t) return e;
|
|
21
|
+
let r = ot(t);
|
|
22
22
|
return r.length === 0 ? e : e.map((e) => {
|
|
23
23
|
let t;
|
|
24
24
|
for (let n of r) {
|
|
@@ -30,86 +30,86 @@ var ot = (e) => e === "mysql" || e === "mariadb" || e === "mssql" || e === "sqli
|
|
|
30
30
|
}
|
|
31
31
|
return t ?? e;
|
|
32
32
|
});
|
|
33
|
-
},
|
|
33
|
+
}, lt = "enc:v1:", ut = (e) => typeof e == "string" && e.startsWith("enc:v1:"), dt = (e) => {
|
|
34
34
|
let t = [];
|
|
35
35
|
for (let [n, r] of Object.entries(e.fields)) r.encrypted === !0 && t.push(n);
|
|
36
36
|
return t;
|
|
37
|
-
},
|
|
37
|
+
}, ft = (e, t, n) => {
|
|
38
38
|
if (!t) return e;
|
|
39
|
-
let r =
|
|
39
|
+
let r = dt(t);
|
|
40
40
|
if (r.length === 0) return e;
|
|
41
41
|
let i = { ...e };
|
|
42
42
|
for (let e of r) {
|
|
43
43
|
let r = i[e];
|
|
44
|
-
if (!(r == null ||
|
|
44
|
+
if (!(r == null || ut(r))) {
|
|
45
45
|
if (!n) throw Error(`column "${t.tableName ?? "?"}.${e}" is .encrypted() but no field cipher is registered — wire @voltro/plugin-governance's fieldEncryption (key via the Secrets-Resolver)`);
|
|
46
46
|
i[e] = n.encrypt(JSON.stringify(r));
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
return i;
|
|
50
|
-
},
|
|
50
|
+
}, pt = (e, t, n) => {
|
|
51
51
|
if (!t) return e;
|
|
52
|
-
let r =
|
|
52
|
+
let r = dt(t);
|
|
53
53
|
return r.length === 0 || !n ? e : e.map((e) => {
|
|
54
54
|
let t;
|
|
55
55
|
for (let i of r) {
|
|
56
56
|
let r = e[i];
|
|
57
|
-
|
|
57
|
+
ut(r) && (t ??= { ...e }, t[i] = JSON.parse(n.decrypt(r)));
|
|
58
58
|
}
|
|
59
59
|
return t ?? e;
|
|
60
60
|
});
|
|
61
|
-
}, ht = (e) => {
|
|
61
|
+
}, mt = A.DateFromNumber, ht = A.NullOr(mt), gt = (e) => {
|
|
62
62
|
let t = (() => {
|
|
63
63
|
switch (e.type) {
|
|
64
64
|
case "id":
|
|
65
65
|
case "reference":
|
|
66
66
|
case "text":
|
|
67
|
-
case "enum": return
|
|
67
|
+
case "enum": return A.String;
|
|
68
68
|
case "integer":
|
|
69
69
|
case "real":
|
|
70
|
-
case "decimal": return
|
|
71
|
-
case "boolean": return
|
|
70
|
+
case "decimal": return A.Number;
|
|
71
|
+
case "boolean": return A.Boolean;
|
|
72
72
|
case "timestamp":
|
|
73
|
-
case "date": return
|
|
74
|
-
case "bigint": return
|
|
75
|
-
case "bytes": return
|
|
76
|
-
case "array": return
|
|
77
|
-
case "interval": return
|
|
78
|
-
default: return
|
|
73
|
+
case "date": return mt;
|
|
74
|
+
case "bigint": return A.BigInt;
|
|
75
|
+
case "bytes": return A.Uint8ArrayFromSelf;
|
|
76
|
+
case "array": return A.Array(A.Unknown);
|
|
77
|
+
case "interval": return A.String;
|
|
78
|
+
default: return A.Unknown;
|
|
79
79
|
}
|
|
80
80
|
})();
|
|
81
|
-
return e.nullable === !0 ?
|
|
82
|
-
},
|
|
81
|
+
return e.nullable === !0 ? A.NullOr(t) : t;
|
|
82
|
+
}, _t = (e, t) => {
|
|
83
83
|
let n = new Set(t?.omit ?? []), r = {};
|
|
84
|
-
for (let [t, i] of Object.entries(e.fields)) n.has(t) || (r[t] =
|
|
85
|
-
return
|
|
86
|
-
},
|
|
84
|
+
for (let [t, i] of Object.entries(e.fields)) n.has(t) || (r[t] = gt(i));
|
|
85
|
+
return A.Struct(r);
|
|
86
|
+
}, vt = (e) => typeof e == "function" ? e : () => e, yt = (e, t) => ({
|
|
87
87
|
kind: "one",
|
|
88
|
-
target:
|
|
88
|
+
target: vt(e),
|
|
89
89
|
...t?.foreignKey === void 0 ? {} : { foreignKey: t.foreignKey },
|
|
90
90
|
...t?.sourceKey === void 0 ? {} : { sourceKey: t.sourceKey }
|
|
91
|
-
}),
|
|
91
|
+
}), bt = (e, t) => ({
|
|
92
92
|
kind: "many",
|
|
93
|
-
target:
|
|
93
|
+
target: vt(e),
|
|
94
94
|
...t?.foreignKey === void 0 ? {} : { foreignKey: t.foreignKey },
|
|
95
95
|
...t?.sourceKey === void 0 ? {} : { sourceKey: t.sourceKey }
|
|
96
|
-
}),
|
|
96
|
+
}), xt = (e, t) => ({
|
|
97
97
|
kind: "manyToMany",
|
|
98
|
-
target:
|
|
99
|
-
through:
|
|
98
|
+
target: vt(e),
|
|
99
|
+
through: vt(t.through),
|
|
100
100
|
sourceKey: t.sourceKey,
|
|
101
101
|
targetKey: t.targetKey
|
|
102
|
-
}),
|
|
103
|
-
one:
|
|
104
|
-
many:
|
|
105
|
-
manyToMany:
|
|
106
|
-
},
|
|
102
|
+
}), St = {
|
|
103
|
+
one: yt,
|
|
104
|
+
many: bt,
|
|
105
|
+
manyToMany: xt
|
|
106
|
+
}, Ct = (e, t) => {
|
|
107
107
|
let n = typeof e == "function" ? e : () => e;
|
|
108
108
|
return {
|
|
109
109
|
source: n,
|
|
110
|
-
relations: t(
|
|
110
|
+
relations: t(St, n())
|
|
111
111
|
};
|
|
112
|
-
},
|
|
112
|
+
}, wt = (e) => {
|
|
113
113
|
if (typeof e != "object" || !e) return !1;
|
|
114
114
|
let t = e;
|
|
115
115
|
if (typeof t.source != "function" || typeof t.relations != "object" || t.relations === null) return !1;
|
|
@@ -118,63 +118,63 @@ var ot = (e) => e === "mysql" || e === "mariadb" || e === "mssql" || e === "sqli
|
|
|
118
118
|
let t = e?.kind;
|
|
119
119
|
return t === "one" || t === "many" || t === "manyToMany";
|
|
120
120
|
});
|
|
121
|
-
},
|
|
121
|
+
}, Tt = yt, Et = bt, Dt = xt, M = (e, t, n) => {
|
|
122
122
|
let r = [];
|
|
123
123
|
for (let [n, i] of Object.entries(e.fields)) i.type === "reference" && i.references?.()?.tableName === t && r.push(n);
|
|
124
124
|
if (r.length === 0) throw Error(`relation '${n}': no reference() column on '${e.tableName}' points at '${t}'. Either add one or pass an explicit { foreignKey: '<column>' }.`);
|
|
125
125
|
if (r.length > 1) throw Error(`relation '${n}': multiple reference() columns on '${e.tableName}' point at '${t}' (${r.join(", ")}). Pass an explicit { foreignKey: '<column>' } to disambiguate.`);
|
|
126
126
|
return r[0];
|
|
127
|
-
},
|
|
128
|
-
let t =
|
|
127
|
+
}, Ot = (e) => Object.keys(e.fields), N = (e, t) => Object.prototype.hasOwnProperty.call(e.fields, t), kt = (e) => {
|
|
128
|
+
let t = Ot(e);
|
|
129
129
|
return t.length === 0 ? "<none>" : t.join(", ");
|
|
130
|
-
},
|
|
130
|
+
}, At = (e, t, n) => {
|
|
131
131
|
let r = `relation '${t}' on '${e.tableName}'`, i = n.target();
|
|
132
132
|
if (n.kind === "manyToMany") {
|
|
133
133
|
let t = n.through();
|
|
134
|
-
for (let [a, o] of [["sourceKey", n.sourceKey], ["targetKey", n.targetKey]]) if (!
|
|
134
|
+
for (let [a, o] of [["sourceKey", n.sourceKey], ["targetKey", n.targetKey]]) if (!N(t, o)) throw Error(`${r}: manyToMany ${a} '${o}' is not a column on the junction table '${t.tableName}'. Both keys name columns on the JUNCTION — ${a === "sourceKey" ? `sourceKey points at '${e.tableName}'` : `targetKey points at '${i.tableName}'`}. Columns on '${t.tableName}': ${kt(t)}.`);
|
|
135
135
|
return;
|
|
136
136
|
}
|
|
137
137
|
if (n.sourceKey !== void 0 && n.foreignKey !== void 0) throw Error(`${r}: pass EITHER sourceKey OR foreignKey, not both. sourceKey '${n.sourceKey}' names a column on the source ('${e.tableName}') holding the target's id; foreignKey '${n.foreignKey}' names a column on the target ('${i.tableName}') holding the source's id. With both, foreignKey is ignored.`);
|
|
138
|
-
if (n.sourceKey !== void 0 && !
|
|
139
|
-
let t =
|
|
140
|
-
throw Error(`${r}: sourceKey '${n.sourceKey}' is not a column on the source table '${e.tableName}'.` + (t ? ` It IS a column on the target '${i.tableName}' — you probably want { foreignKey: '${n.sourceKey}' }, which names the column on the TARGET that holds this table's id.` : ` Columns on '${e.tableName}': ${
|
|
138
|
+
if (n.sourceKey !== void 0 && !N(e, n.sourceKey)) {
|
|
139
|
+
let t = N(i, n.sourceKey);
|
|
140
|
+
throw Error(`${r}: sourceKey '${n.sourceKey}' is not a column on the source table '${e.tableName}'.` + (t ? ` It IS a column on the target '${i.tableName}' — you probably want { foreignKey: '${n.sourceKey}' }, which names the column on the TARGET that holds this table's id.` : ` Columns on '${e.tableName}': ${kt(e)}.`));
|
|
141
141
|
}
|
|
142
|
-
if (n.foreignKey !== void 0 && !
|
|
143
|
-
let t =
|
|
144
|
-
throw Error(`${r}: foreignKey '${n.foreignKey}' is not a column on the target table '${i.tableName}'.` + (t ? ` It IS a column on the source '${e.tableName}' — you want { sourceKey: '${n.foreignKey}' }. foreignKey names the column on the TARGET that points back at this table; sourceKey names the column on THIS table that holds the target's id.` : ` Columns on '${i.tableName}': ${
|
|
142
|
+
if (n.foreignKey !== void 0 && !N(i, n.foreignKey)) {
|
|
143
|
+
let t = N(e, n.foreignKey);
|
|
144
|
+
throw Error(`${r}: foreignKey '${n.foreignKey}' is not a column on the target table '${i.tableName}'.` + (t ? ` It IS a column on the source '${e.tableName}' — you want { sourceKey: '${n.foreignKey}' }. foreignKey names the column on the TARGET that points back at this table; sourceKey names the column on THIS table that holds the target's id.` : ` Columns on '${i.tableName}': ${kt(i)}.`));
|
|
145
145
|
}
|
|
146
|
-
},
|
|
147
|
-
let t = e.source(), n =
|
|
146
|
+
}, jt = Symbol.for("@voltro/database/relationsRegistry"), Mt = globalThis, P = Mt[jt] ?? (Mt[jt] = /* @__PURE__ */ new Map()), Nt = (e) => {
|
|
147
|
+
let t = e.source(), n = P.get(t.tableName);
|
|
148
148
|
if (n === void 0) {
|
|
149
|
-
|
|
149
|
+
P.set(t.tableName, new Map(Object.entries(e.relations)));
|
|
150
150
|
return;
|
|
151
151
|
}
|
|
152
152
|
for (let [r, i] of Object.entries(e.relations)) {
|
|
153
153
|
if (n.has(r)) throw Error(`duplicate relation '${r}' on '${t.tableName}': two relations() blocks both declare it. Pick distinct names or merge them into one block.`);
|
|
154
154
|
n.set(r, i);
|
|
155
155
|
}
|
|
156
|
-
},
|
|
156
|
+
}, Pt = (e) => {
|
|
157
157
|
let t = 0;
|
|
158
|
-
for (let n of Object.values(e))
|
|
158
|
+
for (let n of Object.values(e)) wt(n) && (Nt(n), t += 1);
|
|
159
159
|
return t;
|
|
160
|
-
},
|
|
161
|
-
let t =
|
|
160
|
+
}, F = (e) => {
|
|
161
|
+
let t = P.get(e);
|
|
162
162
|
if (t !== void 0) return Object.fromEntries(t);
|
|
163
|
-
}, Ft = (e, t) =>
|
|
163
|
+
}, Ft = (e, t) => P.get(e)?.get(t), It = () => {
|
|
164
164
|
let e = [];
|
|
165
|
-
for (let [t, n] of
|
|
165
|
+
for (let [t, n] of P) for (let [r, i] of n) e.push({
|
|
166
166
|
source: t,
|
|
167
167
|
name: r,
|
|
168
168
|
relation: i
|
|
169
169
|
});
|
|
170
170
|
return e;
|
|
171
171
|
}, Lt = () => {
|
|
172
|
-
for (let [e, t] of
|
|
172
|
+
for (let [e, t] of P) {
|
|
173
173
|
let n = u(e);
|
|
174
|
-
if (n !== void 0) for (let [e, r] of t)
|
|
174
|
+
if (n !== void 0) for (let [e, r] of t) At(n, e, r);
|
|
175
175
|
}
|
|
176
176
|
}, Rt = () => {
|
|
177
|
-
|
|
177
|
+
P.clear();
|
|
178
178
|
}, zt = (e) => e == null || typeof e == "boolean" ? e : typeof e == "number" ? e !== 0 : typeof e == "bigint" ? e !== 0n : typeof e == "string" ? e === "1" || e.toLowerCase() === "true" : e, Bt = (e) => {
|
|
179
179
|
if (e == null || typeof e != "string") return e;
|
|
180
180
|
let t = e.trim();
|
|
@@ -249,7 +249,7 @@ var ot = (e) => e === "mysql" || e === "mariadb" || e === "mssql" || e === "sqli
|
|
|
249
249
|
return `relation '${t}' on '${n}' is declared \`one\`, but ${r}.${i} matches MORE than one row for the same ${n}.${a} — so there is no single related row to return.` + (o ? ` Because this relation is self-referential, check which side the key is on: \`foreignKey: '${i}'\` means "rows whose ${i} points AT me" (my children — there can be many). If you meant "the row my ${i} points to" (my parent), that is \`sourceKey: '${i}'\`.` : " Use `many(...)` if several are expected, or narrow the key.");
|
|
250
250
|
}, Yt = async (e, t, n, r) => {
|
|
251
251
|
if (e.length === 0) return e;
|
|
252
|
-
let i =
|
|
252
|
+
let i = F(n.tableName);
|
|
253
253
|
if (i === void 0) throw Error(`cannot eager-load on '${n.tableName}': no relations registered. Did you forget to declare \`relations(${n.tableName}, ...)\` or import the file that does?`);
|
|
254
254
|
let a = e.map((e) => ({ ...e }));
|
|
255
255
|
for (let [e, o] of Object.entries(t)) {
|
|
@@ -258,7 +258,7 @@ var ot = (e) => e === "mysql" || e === "mariadb" || e === "mssql" || e === "sqli
|
|
|
258
258
|
let t = Object.keys(i).join(", ") || "<none>";
|
|
259
259
|
throw Error(`unknown relation '${e}' on '${n.tableName}'. Registered relations: ${t}.`);
|
|
260
260
|
}
|
|
261
|
-
|
|
261
|
+
At(n, e, t), await Xt(a, e, t, o === !0 ? {} : o, n, r);
|
|
262
262
|
}
|
|
263
263
|
return a;
|
|
264
264
|
}, Xt = async (e, t, n, r, i, a) => {
|
|
@@ -276,7 +276,7 @@ var ot = (e) => e === "mysql" || e === "mariadb" || e === "mssql" || e === "sqli
|
|
|
276
276
|
}, Zt = async (e, t, n, r, i, a) => {
|
|
277
277
|
let o = n.target(), s = n.sourceKey ?? tn(i, o.tableName);
|
|
278
278
|
if (s !== void 0) {
|
|
279
|
-
let n =
|
|
279
|
+
let n = I(e, s), i = n.length === 0 ? [] : await nn(o, "id", n, r, a), c = new Map(i.map((e) => [e.id, e]));
|
|
280
280
|
for (let n of e) {
|
|
281
281
|
let e = n[s];
|
|
282
282
|
n[t] = e == null ? null : c.get(e) ?? null;
|
|
@@ -284,7 +284,7 @@ var ot = (e) => e === "mysql" || e === "mariadb" || e === "mssql" || e === "sqli
|
|
|
284
284
|
await rn(i, r.with, o, a);
|
|
285
285
|
return;
|
|
286
286
|
}
|
|
287
|
-
let c = n.foreignKey ??
|
|
287
|
+
let c = n.foreignKey ?? M(o, i.tableName, t), l = n.sourceKey ?? "id", u = I(e, l), d = u.length === 0 ? [] : await nn(o, c, u, r, a), f = /* @__PURE__ */ new Map();
|
|
288
288
|
for (let e of d) {
|
|
289
289
|
let n = e[c];
|
|
290
290
|
if (f.has(n)) throw new qt(Jt({
|
|
@@ -302,7 +302,7 @@ var ot = (e) => e === "mysql" || e === "mariadb" || e === "mssql" || e === "sqli
|
|
|
302
302
|
}
|
|
303
303
|
await rn(d, r.with, o, a);
|
|
304
304
|
}, Qt = async (e, t, n, r, i, a) => {
|
|
305
|
-
let o = n.target(), s = n.foreignKey ??
|
|
305
|
+
let o = n.target(), s = n.foreignKey ?? M(o, i.tableName, t), c = n.sourceKey ?? "id", l = I(e, c), u = $t(r), d = l.length === 0 ? [] : await nn(o, s, l, u, a), f = /* @__PURE__ */ new Map();
|
|
306
306
|
for (let e of d) {
|
|
307
307
|
let t = e[s], n = f.get(t);
|
|
308
308
|
n ? n.push(e) : f.set(t, [e]);
|
|
@@ -323,7 +323,7 @@ var ot = (e) => e === "mysql" || e === "mariadb" || e === "mssql" || e === "sqli
|
|
|
323
323
|
let { limit: t, offset: n, ...r } = e;
|
|
324
324
|
return r;
|
|
325
325
|
}, en = async (e, t, n, r, i, a) => {
|
|
326
|
-
let o = n.target(), s = n.through(), c =
|
|
326
|
+
let o = n.target(), s = n.through(), c = I(e, "id");
|
|
327
327
|
if (c.length === 0) {
|
|
328
328
|
for (let n of e) n[t] = [];
|
|
329
329
|
return;
|
|
@@ -344,7 +344,7 @@ var ot = (e) => e === "mysql" || e === "mariadb" || e === "mssql" || e === "sqli
|
|
|
344
344
|
for (let n of e) n[t] = [];
|
|
345
345
|
return;
|
|
346
346
|
}
|
|
347
|
-
let f = await nn(o, "id",
|
|
347
|
+
let f = await nn(o, "id", I(d, n.targetKey), r, a), p = new Map(f.map((e) => [e.id, e]));
|
|
348
348
|
await rn(f, r.with, o, a);
|
|
349
349
|
let m = r.junction === void 0 ? void 0 : r.junction === !0 ? Object.keys(s.fields) : r.junction, h = /* @__PURE__ */ new Map();
|
|
350
350
|
for (let e of d) {
|
|
@@ -359,7 +359,7 @@ var ot = (e) => e === "mysql" || e === "mariadb" || e === "mssql" || e === "sqli
|
|
|
359
359
|
for (let n of e) n[t] = h.get(n.id) ?? [];
|
|
360
360
|
}, tn = (e, t) => {
|
|
361
361
|
for (let [n, r] of Object.entries(e.fields)) if (r.type === "reference" && r.references?.()?.tableName === t) return n;
|
|
362
|
-
},
|
|
362
|
+
}, I = (e, t) => {
|
|
363
363
|
let n = /* @__PURE__ */ new Set();
|
|
364
364
|
for (let r of e) {
|
|
365
365
|
let e = r[t];
|
|
@@ -402,11 +402,11 @@ var ot = (e) => e === "mysql" || e === "mariadb" || e === "mssql" || e === "sqli
|
|
|
402
402
|
let n = `${ln}${t}`;
|
|
403
403
|
if (n.length > cn) throw new sn(`namespace '${n}' for tenant '${e}' exceeds the ${cn}-byte identifier limit. Use a shorter tenant id.`);
|
|
404
404
|
return n;
|
|
405
|
-
},
|
|
405
|
+
}, fn = (e, t) => e === null ? t : `${e}.${t}`, pn = (e, t) => {
|
|
406
406
|
let { strings: n, values: r } = e, i = t.unsafe(n[0] ?? "");
|
|
407
407
|
for (let e = 0; e < r.length; e++) i = t`${i}${r[e]}${t.unsafe(n[e + 1] ?? "")}`;
|
|
408
408
|
return t`${i}`;
|
|
409
|
-
},
|
|
409
|
+
}, mn = (e) => e.replace(/[\\%_]/g, (e) => `\\${e}`), L = (e, t, n = null) => {
|
|
410
410
|
if ("not" in e) return t`NOT (${L(e.not, t, n)})`;
|
|
411
411
|
if ("and" in e) return e.and.length === 0 ? t`TRUE` : t.and(e.and.map((e) => L(e, t, n)));
|
|
412
412
|
if ("or" in e) return e.or.length === 0 ? t`FALSE` : t.or(e.or.map((e) => L(e, t, n)));
|
|
@@ -419,15 +419,15 @@ var ot = (e) => e === "mysql" || e === "mariadb" || e === "mssql" || e === "sqli
|
|
|
419
419
|
return r.op === "exists" ? t`EXISTS (${i})` : t`NOT EXISTS (${i})`;
|
|
420
420
|
}
|
|
421
421
|
let r = e, i = t(r.column), a = r.path, o = a !== void 0 && a.length > 0, s = () => t.onDialectOrElse({
|
|
422
|
-
mysql: () => t.unsafe(
|
|
423
|
-
mssql: () => t.unsafe(
|
|
424
|
-
sqlite: () => t.unsafe(
|
|
425
|
-
orElse: () => t.unsafe(
|
|
422
|
+
mysql: () => t.unsafe(E(r.column, a, "mysql")),
|
|
423
|
+
mssql: () => t.unsafe(E(r.column, a, "mssql")),
|
|
424
|
+
sqlite: () => t.unsafe(E(r.column, a, "sqlite")),
|
|
425
|
+
orElse: () => t.unsafe(E(r.column, a, "postgres"))
|
|
426
426
|
}), c = () => t.onDialectOrElse({
|
|
427
|
-
mysql: () => t.unsafe(
|
|
428
|
-
mssql: () => t.unsafe(
|
|
429
|
-
sqlite: () => t.unsafe(
|
|
430
|
-
orElse: () => t.unsafe(
|
|
427
|
+
mysql: () => t.unsafe(E(r.column, a, "mysql", { numeric: !0 })),
|
|
428
|
+
mssql: () => t.unsafe(E(r.column, a, "mssql", { numeric: !0 })),
|
|
429
|
+
sqlite: () => t.unsafe(E(r.column, a, "sqlite", { numeric: !0 })),
|
|
430
|
+
orElse: () => t.unsafe(E(r.column, a, "postgres", { numeric: !0 }))
|
|
431
431
|
}), l = o ? s() : i, u = o ? c() : i, d = (e) => o && e != null ? String(e) : e, f = (e) => o ? Number(e) : e;
|
|
432
432
|
switch (r.op) {
|
|
433
433
|
case "eq": return t`${l} = ${d(r.value)}`;
|
|
@@ -445,7 +445,7 @@ var ot = (e) => e === "mysql" || e === "mariadb" || e === "mssql" || e === "sqli
|
|
|
445
445
|
return e.length === 0 ? t`TRUE` : t`${l} NOT IN ${t.in(o ? e.map((e) => d(e)) : e)}`;
|
|
446
446
|
}
|
|
447
447
|
case "contains": {
|
|
448
|
-
let e = `%${
|
|
448
|
+
let e = `%${mn(typeof r.value == "string" ? r.value : String(r.value ?? ""))}%`;
|
|
449
449
|
return t.onDialectOrElse({
|
|
450
450
|
mysql: () => t`LOWER(${l}) LIKE LOWER(${e})`,
|
|
451
451
|
mssql: () => t`LOWER(${l}) LIKE LOWER(${e})`,
|
|
@@ -495,13 +495,13 @@ var ot = (e) => e === "mysql" || e === "mariadb" || e === "mssql" || e === "sqli
|
|
|
495
495
|
});
|
|
496
496
|
}
|
|
497
497
|
}
|
|
498
|
-
},
|
|
498
|
+
}, hn = (e, t) => {
|
|
499
499
|
let n = [];
|
|
500
500
|
return e.partitionBy && e.partitionBy.length > 0 && n.push(t`PARTITION BY ${t.csv(e.partitionBy.map((e) => t`${t(e)}`))}`), e.orderBy && e.orderBy.length > 0 && n.push(t`ORDER BY ${t.csv(e.orderBy.map((e) => e.direction === "desc" ? t`${t(e.column)} DESC` : t`${t(e.column)} ASC`))}`), n.length === 0 ? t`` : n.length === 1 ? n[0] : n.reduce((e, n, r) => r === 0 ? n : t`${e} ${n}`);
|
|
501
|
-
},
|
|
501
|
+
}, gn = (e, t) => t.csv(e.map((e) => {
|
|
502
502
|
let n = e.column === void 0 ? t.unsafe("*") : t`${t(e.column)}`;
|
|
503
503
|
if (e.op.startsWith("window-")) {
|
|
504
|
-
let r =
|
|
504
|
+
let r = hn(e.window ?? {}, t);
|
|
505
505
|
switch (e.op) {
|
|
506
506
|
case "window-row-number": return t`ROW_NUMBER() OVER (${r}) AS ${t(e.alias)}`;
|
|
507
507
|
case "window-rank": return t`RANK() OVER (${r}) AS ${t(e.alias)}`;
|
|
@@ -525,39 +525,39 @@ var ot = (e) => e === "mysql" || e === "mariadb" || e === "mssql" || e === "sqli
|
|
|
525
525
|
return t`${t(e.column)} AS ${t(e.alias)}`;
|
|
526
526
|
default: throw Error(`compileAggregateProjection: unknown op '${e.op}'`);
|
|
527
527
|
}
|
|
528
|
-
})),
|
|
528
|
+
})), _n = (e) => `[${e.join(",")}]`, vn = (e, t) => {
|
|
529
529
|
if (e.queryVector === void 0) return null;
|
|
530
|
-
let n = t(e.column), r =
|
|
530
|
+
let n = t(e.column), r = _n(e.queryVector), i = e.distance === "cosine" ? "<=>" : e.distance === "l2" ? "<->" : "<#>", a = e.distance === "cosine" ? "VEC_DISTANCE_COSINE" : "VEC_DISTANCE_EUCLIDEAN";
|
|
531
531
|
return t.onDialectOrElse({
|
|
532
532
|
mysql: () => t`${t.unsafe(a)}(${n}, ${r})`,
|
|
533
533
|
mssql: () => t`NULL`,
|
|
534
534
|
sqlite: () => t`NULL`,
|
|
535
535
|
orElse: () => t`${n} ${t.unsafe(i)} ${r}::vector`
|
|
536
536
|
});
|
|
537
|
-
},
|
|
537
|
+
}, yn = (e, t) => {
|
|
538
538
|
let n = t.unsafe(e.useGeography ? "::geography" : "::geometry");
|
|
539
539
|
return t`ST_Distance(${t(e.column)}${n}, ${e.geom}${n})`;
|
|
540
|
-
},
|
|
541
|
-
let r = n.csv(e.columns.map((e) => n`${n(e)}`)), i = `%${
|
|
540
|
+
}, bn = (e, t) => t`${t(e.column)} <-> ${e.geom}::geometry`, xn = (e, t) => t`${t(`${e.indexName}_tsv`)}`, Sn = (e, t) => `${t}_${e.indexName}_fts`, Cn = (e, t, n) => {
|
|
541
|
+
let r = n.csv(e.columns.map((e) => n`${n(e)}`)), i = `%${mn(e.query)}%`;
|
|
542
542
|
return n.onDialectOrElse({
|
|
543
543
|
mysql: () => n`MATCH(${r}) AGAINST(${e.query} IN NATURAL LANGUAGE MODE)`,
|
|
544
544
|
sqlite: () => {
|
|
545
|
-
let r = n(
|
|
545
|
+
let r = n(Sn(e, t));
|
|
546
546
|
return n`${n("id")} IN (SELECT ${n("row_id")} FROM ${r} WHERE ${r} MATCH ${e.query})`;
|
|
547
547
|
},
|
|
548
548
|
mssql: () => n.or(e.columns.map((e) => n`LOWER(${n(e)}) LIKE LOWER(${i}) ESCAPE '\\'`)),
|
|
549
|
-
orElse: () => n`${
|
|
549
|
+
orElse: () => n`${xn(e, n)} @@ plainto_tsquery(${e.config ?? "english"}, ${e.query})`
|
|
550
550
|
});
|
|
551
|
-
},
|
|
552
|
-
let r = `%${
|
|
551
|
+
}, wn = (e, t, n) => {
|
|
552
|
+
let r = `%${mn(e.query)}%`;
|
|
553
553
|
return n.onDialectOrElse({
|
|
554
554
|
mysql: () => n`MATCH(${n.csv(e.columns.map((e) => n`${n(e)}`))}) AGAINST(${e.query} IN NATURAL LANGUAGE MODE)`,
|
|
555
555
|
sqlite: () => {
|
|
556
|
-
let r = n(
|
|
556
|
+
let r = n(Sn(e, t));
|
|
557
557
|
return n`COALESCE((SELECT -bm25(${r}) FROM ${r} WHERE ${r} MATCH ${e.query} AND ${r}.${n("row_id")} = ${n("id")}), 0)`;
|
|
558
558
|
},
|
|
559
559
|
mssql: () => e.columns.map((e) => n`(CASE WHEN LOWER(${n(e)}) LIKE LOWER(${r}) ESCAPE '\\' THEN 1 ELSE 0 END)`).reduce((e, t, r) => r === 0 ? t : n`${e} + ${t}`),
|
|
560
|
-
orElse: () => n`ts_rank(${
|
|
560
|
+
orElse: () => n`ts_rank(${xn(e, n)}, plainto_tsquery(${e.config ?? "english"}, ${e.query}))`
|
|
561
561
|
});
|
|
562
562
|
}, R = (e, t, n = null) => {
|
|
563
563
|
if (e.setOp && e.setOp.queries.length >= 2) {
|
|
@@ -572,7 +572,7 @@ var ot = (e) => e === "mysql" || e === "mariadb" || e === "mssql" || e === "sqli
|
|
|
572
572
|
}
|
|
573
573
|
return t`${i}${a.reduce((e, n) => t`${e}${n}`, t``)}`;
|
|
574
574
|
}
|
|
575
|
-
let r = e.annClause === void 0 ? null :
|
|
575
|
+
let r = e.annClause === void 0 ? null : vn(e.annClause, t);
|
|
576
576
|
e.spatialClause !== void 0 && t.onDialectOrElse({
|
|
577
577
|
mysql: () => {
|
|
578
578
|
throw Error("@voltro/plugin-postgis: spatial distance / KNN ordering is postgres-only");
|
|
@@ -585,57 +585,57 @@ var ot = (e) => e === "mysql" || e === "mariadb" || e === "mssql" || e === "sqli
|
|
|
585
585
|
},
|
|
586
586
|
orElse: () => t``
|
|
587
587
|
});
|
|
588
|
-
let i = e.spatialClause?.projectAs === void 0 ? null :
|
|
588
|
+
let i = e.spatialClause?.projectAs === void 0 ? null : yn(e.spatialClause, t), a = e.aggregations && e.aggregations.length > 0 ? gn(e.aggregations, t) : e.joinedProjection && e.joinedProjection.length > 0 ? t.csv(e.joinedProjection.map((e) => t`${t(e.source)} AS ${t(e.outputKey)}`)) : e.projection && e.projection.length > 0 ? t.csv(e.projection.map((e) => t`${t(e)}`)) : t`*`, o = (e.aggregations && e.aggregations.length > 0) === !0, s = r !== null && !o ? t`${a}, ${r} AS ${t("distance")}` : a, c = e.fullTextSearch, l = c?.rank !== void 0 && !o ? wn(c, e.table, t) : null, u = l !== null && c?.rank !== void 0 ? t`${s}, ${l} AS ${t(c.rank.alias)}` : s, d = i !== null && !o && e.spatialClause?.projectAs !== void 0 ? t`${u}, ${i} AS ${t(e.spatialClause.projectAs)}` : u, f = e.distinctOn && e.distinctOn.length > 0 ? t.onDialectOrElse({
|
|
589
589
|
orElse: () => t`DISTINCT ON (${t.csv(e.distinctOn.map((e) => t`${t(e)}`))}) `,
|
|
590
590
|
mysql: () => t`DISTINCT `,
|
|
591
591
|
mssql: () => t`DISTINCT `,
|
|
592
592
|
sqlite: () => t`DISTINCT `
|
|
593
|
-
}) : e.distinct ? t`DISTINCT ` : t``, p = e.alias === void 0 ? t`${t(
|
|
593
|
+
}) : e.distinct ? t`DISTINCT ` : t``, p = e.alias === void 0 ? t`${t(fn(n, e.table))}` : t`${t(fn(n, e.table))} AS ${t(e.alias)}`, m = (e.joins ?? []).map((e) => {
|
|
594
594
|
let r = e.kind === "inner" ? "INNER" : "LEFT";
|
|
595
|
-
return t` ${t.unsafe(r)} JOIN ${t(
|
|
596
|
-
}), h = m.length > 0 ? m.reduce((e, n) => t`${e}${n}`, p) : p, g = c === void 0 ? null :
|
|
597
|
-
r !== null &&
|
|
598
|
-
for (let n of e.order)
|
|
599
|
-
let
|
|
595
|
+
return t` ${t.unsafe(r)} JOIN ${t(fn(n, e.table))} AS ${t(e.alias)} ON ${L(e.on, t, n)}`;
|
|
596
|
+
}), h = m.length > 0 ? m.reduce((e, n) => t`${e}${n}`, p) : p, g = c === void 0 ? null : Cn(c, e.table, t), ee = [e.predicate ? L(e.predicate, t, n) : null, g].filter((e) => e !== null), _ = ee.length > 0 ? t` WHERE ${t.and(ee)}` : t``, v = e.groupBy && e.groupBy.length > 0 ? t` GROUP BY ${t.csv(e.groupBy.map((e) => t`${t(e)}`))}` : t``, y = e.having ? t` HAVING ${L(e.having, t, n)}` : t``, b = e.skip !== void 0, x = [];
|
|
597
|
+
r !== null && x.push(t`${r} ASC`), e.spatialClause?.order !== void 0 && x.push(e.spatialClause.order === "desc" ? t`${bn(e.spatialClause, t)} DESC` : t`${bn(e.spatialClause, t)} ASC`), l !== null && c?.rank?.order === !0 && x.push(t`${l} DESC`);
|
|
598
|
+
for (let n of e.order) x.push(n.direction === "desc" ? t`${t(n.column)} DESC` : t`${t(n.column)} ASC`);
|
|
599
|
+
let te = x.length > 0 ? t` ORDER BY ${t.csv(x)}` : b ? t.onDialectOrElse({
|
|
600
600
|
mssql: () => t` ORDER BY (SELECT NULL)`,
|
|
601
601
|
orElse: () => t``
|
|
602
|
-
}) : t``,
|
|
602
|
+
}) : t``, S = (e) => {
|
|
603
603
|
if (!Number.isFinite(e) || !Number.isInteger(e) || e < 0) throw Error(`compileSelect: expected non-negative integer take/skip, got ${e}`);
|
|
604
604
|
return t.unsafe(String(e));
|
|
605
|
-
},
|
|
605
|
+
}, C = (e.ctes ?? []).map((e) => t`${t(e.name)} AS (${R(e.descriptor, t, n)})`), ne = (e.ctes ?? []).some((e) => e.recursive === !0), re = C.length > 0 ? t`WITH ${t.unsafe(ne ? "RECURSIVE " : "")}${t.csv(C)} ` : t``;
|
|
606
606
|
return t.onDialectOrElse({
|
|
607
607
|
mssql: () => {
|
|
608
|
-
let n = e.take !== void 0 && !
|
|
609
|
-
return t`${
|
|
608
|
+
let n = e.take !== void 0 && !b ? t`TOP ${S(e.take)} ` : t``, r = b ? t` OFFSET ${S(e.skip)} ROWS FETCH NEXT ${S(e.take ?? 2 ** 53 - 1)} ROWS ONLY` : t``;
|
|
609
|
+
return t`${re}SELECT ${n}${f}${d} FROM ${h}${_}${v}${y}${te}${r}`;
|
|
610
610
|
},
|
|
611
611
|
orElse: () => {
|
|
612
|
-
let n = e.take === void 0 ? t`` : t` LIMIT ${
|
|
613
|
-
return t`${
|
|
612
|
+
let n = e.take === void 0 ? t`` : t` LIMIT ${S(e.take)}`, r = b ? t` OFFSET ${S(e.skip)}` : t``;
|
|
613
|
+
return t`${re}SELECT ${f}${d} FROM ${h}${_}${v}${y}${te}${n}${r}`;
|
|
614
614
|
}
|
|
615
615
|
});
|
|
616
|
-
},
|
|
616
|
+
}, Tn = (e, t, n) => {
|
|
617
617
|
if (e.eager === void 0) return null;
|
|
618
|
-
let r =
|
|
618
|
+
let r = En(e.table, e.eager, e.sourceTable);
|
|
619
619
|
if (r === null) return null;
|
|
620
|
-
let i =
|
|
620
|
+
let i = Nn(n, e, r, Mn(t, n));
|
|
621
621
|
return i === null ? null : {
|
|
622
622
|
fragment: i,
|
|
623
|
-
decode:
|
|
623
|
+
decode: In(r, n)
|
|
624
624
|
};
|
|
625
|
-
}, z = (e) => e.relation.kind === "one" && e.fkSide === "target",
|
|
625
|
+
}, z = (e) => e.relation.kind === "one" && e.fkSide === "target", B = (e) => ({
|
|
626
626
|
...e,
|
|
627
627
|
branch: {
|
|
628
628
|
...e.branch,
|
|
629
629
|
limit: 2
|
|
630
630
|
}
|
|
631
|
-
}),
|
|
632
|
-
let r = n ?? g(e), i =
|
|
631
|
+
}), En = (e, t, n) => {
|
|
632
|
+
let r = n ?? g(e), i = F(e);
|
|
633
633
|
if (i === void 0) return null;
|
|
634
634
|
let a = [];
|
|
635
635
|
for (let [e, n] of Object.entries(t)) {
|
|
636
636
|
let t = i[e];
|
|
637
637
|
if (t === void 0) return null;
|
|
638
|
-
let o =
|
|
638
|
+
let o = Dn(e, t, r, n === !0 ? {} : n);
|
|
639
639
|
if (o === null) return null;
|
|
640
640
|
a.push(o);
|
|
641
641
|
}
|
|
@@ -643,30 +643,30 @@ var ot = (e) => e === "mysql" || e === "mariadb" || e === "mssql" || e === "sqli
|
|
|
643
643
|
table: r,
|
|
644
644
|
children: a
|
|
645
645
|
};
|
|
646
|
-
},
|
|
646
|
+
}, Dn = (e, t, n, r) => {
|
|
647
647
|
let i = t.target(), a = (t.kind === "manyToMany" ? void 0 : t.sourceKey) ?? "id", o, s;
|
|
648
648
|
if (t.kind === "manyToMany") o = t.targetKey, s = "target";
|
|
649
649
|
else if (t.kind === "one") {
|
|
650
|
-
let r = t.sourceKey ??
|
|
650
|
+
let r = t.sourceKey ?? jn(n, i.tableName);
|
|
651
651
|
if (r !== void 0) o = r, s = "source";
|
|
652
652
|
else try {
|
|
653
|
-
o = t.foreignKey ??
|
|
653
|
+
o = t.foreignKey ?? M(i, n.tableName, e), s = "target";
|
|
654
654
|
} catch {
|
|
655
655
|
return null;
|
|
656
656
|
}
|
|
657
657
|
} else try {
|
|
658
|
-
o = t.foreignKey ??
|
|
658
|
+
o = t.foreignKey ?? M(i, n.tableName, e), s = "target";
|
|
659
659
|
} catch {
|
|
660
660
|
return null;
|
|
661
661
|
}
|
|
662
662
|
let c = r.with === void 0 ? [] : (() => {
|
|
663
|
-
let e =
|
|
663
|
+
let e = F(i.tableName);
|
|
664
664
|
if (e === void 0 && Object.keys(r.with).length > 0) return null;
|
|
665
665
|
let t = [];
|
|
666
666
|
for (let [n, a] of Object.entries(r.with)) {
|
|
667
667
|
let r = e?.[n];
|
|
668
668
|
if (r === void 0) return null;
|
|
669
|
-
let o =
|
|
669
|
+
let o = Dn(n, r, i, a === !0 ? {} : a);
|
|
670
670
|
if (o === null) return null;
|
|
671
671
|
t.push(o);
|
|
672
672
|
}
|
|
@@ -682,9 +682,9 @@ var ot = (e) => e === "mysql" || e === "mariadb" || e === "mssql" || e === "sqli
|
|
|
682
682
|
fkSide: s,
|
|
683
683
|
branch: r,
|
|
684
684
|
children: c,
|
|
685
|
-
junction:
|
|
685
|
+
junction: On(t, r)
|
|
686
686
|
};
|
|
687
|
-
},
|
|
687
|
+
}, On = (e, t) => {
|
|
688
688
|
if (e.kind !== "manyToMany" || t.junction === void 0) return;
|
|
689
689
|
let n = e.through(), r = t.junction === !0 ? Object.keys(n.fields) : t.junction, i = r.filter((e) => e in n.fields);
|
|
690
690
|
return {
|
|
@@ -696,35 +696,35 @@ var ot = (e) => e === "mysql" || e === "mariadb" || e === "mssql" || e === "sqli
|
|
|
696
696
|
return t !== void 0 && (t.type === "timestamp" || t.type === "date");
|
|
697
697
|
})
|
|
698
698
|
};
|
|
699
|
-
},
|
|
699
|
+
}, kn = (e) => `__j_${e}`, An = "__j", jn = (e, t) => {
|
|
700
700
|
for (let [n, r] of Object.entries(e.fields)) if (r.type === "reference" && r.references?.()?.tableName === t) return n;
|
|
701
|
-
},
|
|
701
|
+
}, Mn = (e, t) => {
|
|
702
702
|
let n = 0;
|
|
703
703
|
return {
|
|
704
704
|
sql: e,
|
|
705
705
|
dialect: t,
|
|
706
706
|
nextAlias: () => `__a${n++}`
|
|
707
707
|
};
|
|
708
|
-
},
|
|
708
|
+
}, Nn = (e, t, n, r) => {
|
|
709
709
|
switch (e) {
|
|
710
|
-
case "postgres": return
|
|
710
|
+
case "postgres": return zn(t, n, r);
|
|
711
711
|
case "sqlite":
|
|
712
|
-
case "turso": return
|
|
712
|
+
case "turso": return qn(t, n, r);
|
|
713
713
|
case "mysql":
|
|
714
|
-
case "mariadb": return
|
|
715
|
-
case "mssql": return
|
|
714
|
+
case "mariadb": return rr(t, n, r);
|
|
715
|
+
case "mssql": return ur(t, n, r);
|
|
716
716
|
}
|
|
717
|
-
},
|
|
718
|
-
let n =
|
|
717
|
+
}, Pn = (e, t) => t === "mssql" && !Fn.test(e) ? /* @__PURE__ */ new Date(`${e}Z`) : new Date(e), Fn = /(?:Z|[+-]\d{2}:?\d{2})$/, In = (e, t) => {
|
|
718
|
+
let n = Ln(e.table, e.children, t);
|
|
719
719
|
return (e) => e.map((e) => {
|
|
720
720
|
let t = e.__row, r = typeof t == "string" ? JSON.parse(t) : t;
|
|
721
721
|
return n(r);
|
|
722
722
|
});
|
|
723
|
-
},
|
|
723
|
+
}, Ln = (e, t, n) => {
|
|
724
724
|
let r = [];
|
|
725
725
|
for (let [t, n] of Object.entries(e.fields)) (n.type === "timestamp" || n.type === "date") && r.push(t);
|
|
726
726
|
let i = t.map((e) => {
|
|
727
|
-
let t =
|
|
727
|
+
let t = Ln(e.target, e.children, n), r = e.relation.kind === "one", i = z(e), a = i ? Jt({
|
|
728
728
|
relationName: e.relationName,
|
|
729
729
|
sourceTableName: e.source.tableName,
|
|
730
730
|
targetTableName: e.target.tableName,
|
|
@@ -737,14 +737,14 @@ var ot = (e) => e === "mysql" || e === "mariadb" || e === "mssql" || e === "sqli
|
|
|
737
737
|
isSingle: r,
|
|
738
738
|
fromOverFetch: i,
|
|
739
739
|
cardinalityMessage: a,
|
|
740
|
-
junction:
|
|
740
|
+
junction: Rn(e.junction, n)
|
|
741
741
|
};
|
|
742
742
|
});
|
|
743
743
|
return (e) => {
|
|
744
744
|
let t = { ...e };
|
|
745
745
|
for (let e of r) {
|
|
746
746
|
let r = t[e];
|
|
747
|
-
typeof r == "string" && (t[e] =
|
|
747
|
+
typeof r == "string" && (t[e] = Pn(r, n));
|
|
748
748
|
}
|
|
749
749
|
for (let e of i) {
|
|
750
750
|
let n = t[e.name];
|
|
@@ -766,204 +766,204 @@ var ot = (e) => e === "mysql" || e === "mariadb" || e === "mssql" || e === "sqli
|
|
|
766
766
|
}
|
|
767
767
|
return t;
|
|
768
768
|
};
|
|
769
|
-
},
|
|
769
|
+
}, Rn = (e, t) => {
|
|
770
770
|
if (e === void 0) return;
|
|
771
771
|
let n = new Set(e.dateColumns), r = e.requested;
|
|
772
772
|
return (e) => {
|
|
773
773
|
let i = e._junction ?? {}, a = {};
|
|
774
774
|
for (let e of r) {
|
|
775
775
|
let r = i[e];
|
|
776
|
-
a[e] = n.has(e) && typeof r == "string" ?
|
|
776
|
+
a[e] = n.has(e) && typeof r == "string" ? Pn(r, t) : r;
|
|
777
777
|
}
|
|
778
778
|
return {
|
|
779
779
|
...e,
|
|
780
780
|
_junction: a
|
|
781
781
|
};
|
|
782
782
|
};
|
|
783
|
-
},
|
|
784
|
-
let r = n.sql, i = n.nextAlias(), a = r(t.table.tableName), o = r(i), s =
|
|
785
|
-
return s === null ? null : r`SELECT ${s} AS "__row" FROM ${a} AS ${o}${e.predicate ? r` WHERE ${
|
|
786
|
-
},
|
|
787
|
-
let i = n.sql, a = r === void 0 ? i`to_jsonb(${i(e)}.*)` : i`(to_jsonb(${i(e)}.*) - ${
|
|
783
|
+
}, zn = (e, t, n) => {
|
|
784
|
+
let r = n.sql, i = n.nextAlias(), a = r(t.table.tableName), o = r(i), s = Bn(i, t.children, n);
|
|
785
|
+
return s === null ? null : r`SELECT ${s} AS "__row" FROM ${a} AS ${o}${e.predicate ? r` WHERE ${K(e.predicate, i, r)}` : r``}${e.order.length > 0 ? r` ORDER BY ${r.csv(e.order.map((e) => e.direction === "desc" ? r`${U(i, e.column, r)} DESC` : r`${U(i, e.column, r)} ASC`))}` : r``}${e.take === void 0 ? r`` : r` LIMIT ${G(e.take, r)}`}${e.skip === void 0 ? r`` : r` OFFSET ${G(e.skip, r)}`}`;
|
|
786
|
+
}, Bn = (e, t, n, r) => {
|
|
787
|
+
let i = n.sql, a = r === void 0 ? i`to_jsonb(${i(e)}.*)` : i`(to_jsonb(${i(e)}.*) - ${W(An, i)}::text)`;
|
|
788
788
|
if (t.length === 0 && r === void 0) return a;
|
|
789
789
|
let o = [];
|
|
790
|
-
r !== void 0 && o.push(i`${
|
|
790
|
+
r !== void 0 && o.push(i`${W("_junction", i)}, ${U(e, An, i)}`);
|
|
791
791
|
for (let r of t) {
|
|
792
|
-
let t =
|
|
792
|
+
let t = Vn(r, e, n);
|
|
793
793
|
if (t === null) return null;
|
|
794
|
-
o.push(i`${
|
|
794
|
+
o.push(i`${W(r.relationName, i)}, ${t}`);
|
|
795
795
|
}
|
|
796
796
|
return i`${a} || jsonb_build_object(${i.csv(o)})`;
|
|
797
|
-
},
|
|
797
|
+
}, Vn = (e, t, n) => {
|
|
798
798
|
switch (e.relation.kind) {
|
|
799
|
-
case "one": return z(e) ?
|
|
800
|
-
case "many": return
|
|
801
|
-
case "manyToMany": return
|
|
799
|
+
case "one": return z(e) ? Un(B(e), t, n) : Hn(e, t, n);
|
|
800
|
+
case "many": return Un(e, t, n);
|
|
801
|
+
case "manyToMany": return Wn(e, t, n);
|
|
802
802
|
}
|
|
803
|
-
},
|
|
804
|
-
let r = n.sql, i = n.nextAlias(), a =
|
|
803
|
+
}, Hn = (e, t, n) => {
|
|
804
|
+
let r = n.sql, i = n.nextAlias(), a = Bn(i, e.children, n);
|
|
805
805
|
if (a === null) return null;
|
|
806
|
-
let o = e.fkSide === "source" ? r`${
|
|
806
|
+
let o = e.fkSide === "source" ? r`${U(i, "id", r)} = ${U(t, e.foreignKey, r)}` : r`${U(i, e.foreignKey, r)} = ${U(t, e.sourceKey, r)}`, s = e.branch.where === void 0 ? r`` : r` AND ${K(e.branch.where, i, r)}`, c = V(i, e.branch.orderBy, r);
|
|
807
807
|
return r`(SELECT ${a} FROM ${r(e.target.tableName)} AS ${r(i)} WHERE ${o}${s}${c} LIMIT 1)`;
|
|
808
|
-
},
|
|
809
|
-
let r = n.sql, i = n.nextAlias(), a =
|
|
808
|
+
}, Un = (e, t, n) => {
|
|
809
|
+
let r = n.sql, i = n.nextAlias(), a = Bn(i, e.children, n);
|
|
810
810
|
if (a === null) return null;
|
|
811
|
-
let o = r`${
|
|
811
|
+
let o = r`${U(void 0, e.foreignKey, r)} = ${U(t, e.sourceKey, r)}`, s = e.branch.where === void 0 ? r`` : r` AND ${L(e.branch.where, r)}`, c = Kn(e.branch.orderBy, r), l = e.branch.limit === void 0 ? r`` : r` LIMIT ${G(e.branch.limit, r)}`, u = e.branch.offset === void 0 ? r`` : r` OFFSET ${G(e.branch.offset, r)}`;
|
|
812
812
|
return r`COALESCE((SELECT jsonb_agg(${a}) FROM (SELECT * FROM ${r(e.target.tableName)} WHERE ${o}${s}${c}${l}${u}) AS ${r(i)}), '[]'::jsonb)`;
|
|
813
|
-
},
|
|
814
|
-
let r = n.sql, i = e.relation, a = i.through(), o = n.nextAlias(), s = n.nextAlias(), c =
|
|
813
|
+
}, Wn = (e, t, n) => {
|
|
814
|
+
let r = n.sql, i = e.relation, a = i.through(), o = n.nextAlias(), s = n.nextAlias(), c = Bn(o, e.children, n, e.junction);
|
|
815
815
|
if (c === null) return null;
|
|
816
|
-
let l = e.branch.where === void 0 ? r`` : r` AND ${L(e.branch.where, r)}`, u =
|
|
817
|
-
return r`COALESCE((SELECT jsonb_agg(${c}) FROM (SELECT ${r(o)}.*${m} FROM ${r(a.tableName)} AS ${r(s)} INNER JOIN ${r(e.target.tableName)} AS ${r(o)} ON ${
|
|
818
|
-
},
|
|
819
|
-
let r = n.sql, i = n.nextAlias(), a =
|
|
816
|
+
let l = e.branch.where === void 0 ? r`` : r` AND ${L(e.branch.where, r)}`, u = q(e, s, r), d = V(o, e.branch.orderBy, r), f = e.branch.limit === void 0 ? r`` : r` LIMIT ${G(e.branch.limit, r)}`, p = e.branch.offset === void 0 ? r`` : r` OFFSET ${G(e.branch.offset, r)}`, m = e.junction === void 0 ? r`` : r`, ${Gn(e.junction, s, r)} AS ${r(An)}`;
|
|
817
|
+
return r`COALESCE((SELECT jsonb_agg(${c}) FROM (SELECT ${r(o)}.*${m} FROM ${r(a.tableName)} AS ${r(s)} INNER JOIN ${r(e.target.tableName)} AS ${r(o)} ON ${U(o, "id", r)} = ${U(s, i.targetKey, r)} WHERE ${U(s, i.sourceKey, r)} = ${U(t, "id", r)}${u}${l}${d}${f}${p}) AS ${r(o)}), '[]'::jsonb)`;
|
|
818
|
+
}, Gn = (e, t, n) => e.present.length === 0 ? n`jsonb_build_object()` : n`jsonb_build_object(${n.csv(e.present.map((e) => n`${W(e, n)}, ${U(t, e, n)}`))})`, V = (e, t, n) => t === void 0 || t.length === 0 ? n`` : n` ORDER BY ${n.csv(t.map((t) => t.direction === "desc" ? n`${U(e, t.column, n)} DESC` : n`${U(e, t.column, n)} ASC`))}`, Kn = (e, t) => e === void 0 || e.length === 0 ? t`` : t` ORDER BY ${t.csv(e.map((e) => e.direction === "desc" ? t`${t(e.column)} DESC` : t`${t(e.column)} ASC`))}`, qn = (e, t, n) => {
|
|
819
|
+
let r = n.sql, i = n.nextAlias(), a = Jn(i, t.table, t.children, n);
|
|
820
820
|
if (a === null) return null;
|
|
821
|
-
let o = e.predicate ? r` WHERE ${
|
|
821
|
+
let o = e.predicate ? r` WHERE ${K(e.predicate, i, r)}` : r``, s = e.order.length > 0 ? r` ORDER BY ${r.csv(e.order.map((e) => e.direction === "desc" ? r`${U(i, e.column, r)} DESC` : r`${U(i, e.column, r)} ASC`))}` : r``, c = e.take === void 0 ? r`` : r` LIMIT ${G(e.take, r)}`, l = e.skip === void 0 ? r`` : r` OFFSET ${G(e.skip, r)}`;
|
|
822
822
|
return r`SELECT ${a} AS "__row" FROM ${r(t.table.tableName)} AS ${r(i)}${o}${s}${c}${l}`;
|
|
823
|
-
},
|
|
823
|
+
}, Jn = (e, t, n, r, i) => {
|
|
824
824
|
let a = r.sql, o = [];
|
|
825
|
-
for (let n of Object.keys(t.fields)) o.push(a`${
|
|
825
|
+
for (let n of Object.keys(t.fields)) o.push(a`${W(n, a)}, ${U(e, n, a)}`);
|
|
826
826
|
if (i !== void 0) {
|
|
827
|
-
let e =
|
|
828
|
-
o.push(a`${
|
|
827
|
+
let e = Yn(i.projection, i.source, a);
|
|
828
|
+
o.push(a`${W("_junction", a)}, json_object(${e})`);
|
|
829
829
|
}
|
|
830
830
|
for (let t of n) {
|
|
831
|
-
let n =
|
|
831
|
+
let n = $n(t, e, r);
|
|
832
832
|
if (n === null) return null;
|
|
833
|
-
o.push(a`${
|
|
833
|
+
o.push(a`${W(t.relationName, a)}, ${n}`);
|
|
834
834
|
}
|
|
835
835
|
return a`json_object(${a.csv(o)})`;
|
|
836
|
-
},
|
|
836
|
+
}, Yn = (e, t, n) => e.present.length === 0 ? n`` : n.csv(e.present.map((e) => n`${W(e, n)}, ${U(t.alias, t.physical(e), n)}`)), Xn = (e, t, n) => e.present.length === 0 ? n`` : n`, ${n.csv(e.present.map((e) => n`${U(t, e, n)} AS ${n(kn(e))}`))}`, Zn = (e) => ({
|
|
837
837
|
alias: e,
|
|
838
|
-
physical:
|
|
839
|
-
}),
|
|
838
|
+
physical: kn
|
|
839
|
+
}), Qn = (e) => ({
|
|
840
840
|
alias: e,
|
|
841
841
|
physical: (e) => e
|
|
842
|
-
}),
|
|
842
|
+
}), $n = (e, t, n) => {
|
|
843
843
|
switch (e.relation.kind) {
|
|
844
|
-
case "one": return z(e) ?
|
|
845
|
-
case "many": return
|
|
846
|
-
case "manyToMany": return
|
|
844
|
+
case "one": return z(e) ? tr(B(e), t, n) : er(e, t, n);
|
|
845
|
+
case "many": return tr(e, t, n);
|
|
846
|
+
case "manyToMany": return nr(e, t, n);
|
|
847
847
|
}
|
|
848
|
-
},
|
|
849
|
-
let r = n.sql, i = n.nextAlias(), a =
|
|
848
|
+
}, er = (e, t, n) => {
|
|
849
|
+
let r = n.sql, i = n.nextAlias(), a = Jn(i, e.target, e.children, n);
|
|
850
850
|
if (a === null) return null;
|
|
851
|
-
let o = e.fkSide === "source" ? r`${
|
|
851
|
+
let o = e.fkSide === "source" ? r`${U(i, "id", r)} = ${U(t, e.foreignKey, r)}` : r`${U(i, e.foreignKey, r)} = ${U(t, e.sourceKey, r)}`;
|
|
852
852
|
return r`(SELECT ${a} FROM ${r(e.target.tableName)} AS ${r(i)} WHERE ${o} LIMIT 1)`;
|
|
853
|
-
},
|
|
854
|
-
let r = n.sql, i = n.nextAlias(), a =
|
|
853
|
+
}, tr = (e, t, n) => {
|
|
854
|
+
let r = n.sql, i = n.nextAlias(), a = Jn(i, e.target, e.children, n);
|
|
855
855
|
if (a === null) return null;
|
|
856
|
-
let o = r`${
|
|
856
|
+
let o = r`${U(void 0, e.foreignKey, r)} = ${U(t, e.sourceKey, r)}`, s = e.branch.where === void 0 ? r`` : r` AND ${L(J(e.branch.where), r)}`, c = Kn(e.branch.orderBy, r), l = e.branch.limit === void 0 ? r`` : r` LIMIT ${G(e.branch.limit, r)}`, u = e.branch.offset === void 0 ? r`` : r` OFFSET ${G(e.branch.offset, r)}`;
|
|
857
857
|
return r`COALESCE((SELECT json_group_array(${a}) FROM (SELECT * FROM ${r(e.target.tableName)} WHERE ${o}${s}${c}${l}${u}) AS ${r(i)}), json('[]'))`;
|
|
858
|
-
},
|
|
859
|
-
let r = n.sql, i = e.relation, a = i.through(), o = n.nextAlias(), s = n.nextAlias(), c =
|
|
858
|
+
}, nr = (e, t, n) => {
|
|
859
|
+
let r = n.sql, i = e.relation, a = i.through(), o = n.nextAlias(), s = n.nextAlias(), c = Jn(o, e.target, e.children, n, e.junction === void 0 ? void 0 : {
|
|
860
860
|
projection: e.junction,
|
|
861
|
-
source:
|
|
861
|
+
source: Zn(o)
|
|
862
862
|
});
|
|
863
863
|
if (c === null) return null;
|
|
864
|
-
let l = e.branch.where === void 0 ? r`` : r` AND ${L(
|
|
865
|
-
return r`COALESCE((SELECT json_group_array(${c}) FROM (SELECT ${r(o)}.*${m} FROM ${r(a.tableName)} AS ${r(s)} INNER JOIN ${r(e.target.tableName)} AS ${r(o)} ON ${
|
|
866
|
-
},
|
|
867
|
-
let r = n.sql, i = n.nextAlias(), a =
|
|
864
|
+
let l = e.branch.where === void 0 ? r`` : r` AND ${L(J(e.branch.where), r)}`, u = q(e, s, r, !0), d = V(o, e.branch.orderBy, r), f = e.branch.limit === void 0 ? r`` : r` LIMIT ${G(e.branch.limit, r)}`, p = e.branch.offset === void 0 ? r`` : r` OFFSET ${G(e.branch.offset, r)}`, m = e.junction === void 0 ? r`` : Xn(e.junction, s, r);
|
|
865
|
+
return r`COALESCE((SELECT json_group_array(${c}) FROM (SELECT ${r(o)}.*${m} FROM ${r(a.tableName)} AS ${r(s)} INNER JOIN ${r(e.target.tableName)} AS ${r(o)} ON ${U(o, "id", r)} = ${U(s, i.targetKey, r)} WHERE ${U(s, i.sourceKey, r)} = ${U(t, "id", r)}${u}${l}${d}${f}${p}) AS ${r(o)}), json('[]'))`;
|
|
866
|
+
}, rr = (e, t, n) => {
|
|
867
|
+
let r = n.sql, i = n.nextAlias(), a = H(i, t.table, t.children, n);
|
|
868
868
|
if (a === null) return null;
|
|
869
|
-
let o = e.predicate ? r` WHERE ${
|
|
869
|
+
let o = e.predicate ? r` WHERE ${K(e.predicate, i, r)}` : r``, s = e.order.length > 0 ? r` ORDER BY ${r.csv(e.order.map((e) => e.direction === "desc" ? r`${U(i, e.column, r)} DESC` : r`${U(i, e.column, r)} ASC`))}` : r``, c = e.take === void 0 ? r`` : r` LIMIT ${G(e.take, r)}`, l = e.skip === void 0 ? r`` : r` OFFSET ${G(e.skip, r)}`;
|
|
870
870
|
return r`SELECT ${a} AS \`__row\` FROM ${r(t.table.tableName)} AS ${r(i)}${o}${s}${c}${l}`;
|
|
871
|
-
},
|
|
871
|
+
}, H = (e, t, n, r, i) => {
|
|
872
872
|
let a = r.sql, o = [];
|
|
873
|
-
for (let n of Object.keys(t.fields)) o.push(a`${
|
|
873
|
+
for (let n of Object.keys(t.fields)) o.push(a`${W(n, a)}, ${U(e, n, a)}`);
|
|
874
874
|
if (i !== void 0) {
|
|
875
|
-
let e =
|
|
876
|
-
o.push(a`${
|
|
875
|
+
let e = Yn(i.projection, i.source, a);
|
|
876
|
+
o.push(a`${W("_junction", a)}, JSON_OBJECT(${e})`);
|
|
877
877
|
}
|
|
878
878
|
for (let t of n) {
|
|
879
|
-
let n =
|
|
879
|
+
let n = ir(t, e, r);
|
|
880
880
|
if (n === null) return null;
|
|
881
|
-
o.push(a`${
|
|
881
|
+
o.push(a`${W(t.relationName, a)}, ${n}`);
|
|
882
882
|
}
|
|
883
883
|
return a`JSON_OBJECT(${a.csv(o)})`;
|
|
884
|
-
},
|
|
884
|
+
}, ir = (e, t, n) => {
|
|
885
885
|
switch (e.relation.kind) {
|
|
886
886
|
case "one":
|
|
887
887
|
if (z(e)) {
|
|
888
|
-
let r =
|
|
889
|
-
return n.dialect === "mariadb" ?
|
|
888
|
+
let r = B(e);
|
|
889
|
+
return n.dialect === "mariadb" ? cr(r, t, n) : or(r, t, n);
|
|
890
890
|
}
|
|
891
|
-
return
|
|
892
|
-
case "many": return n.dialect === "mariadb" ?
|
|
893
|
-
case "manyToMany": return n.dialect === "mariadb" ?
|
|
891
|
+
return ar(e, t, n);
|
|
892
|
+
case "many": return n.dialect === "mariadb" ? cr(e, t, n) : or(e, t, n);
|
|
893
|
+
case "manyToMany": return n.dialect === "mariadb" ? lr(e, t, n) : sr(e, t, n);
|
|
894
894
|
}
|
|
895
|
-
},
|
|
896
|
-
let r = n.sql, i = n.nextAlias(), a =
|
|
895
|
+
}, ar = (e, t, n) => {
|
|
896
|
+
let r = n.sql, i = n.nextAlias(), a = H(i, e.target, e.children, n);
|
|
897
897
|
if (a === null) return null;
|
|
898
|
-
let o = e.fkSide === "source" ? r`${
|
|
898
|
+
let o = e.fkSide === "source" ? r`${U(i, "id", r)} = ${U(t, e.foreignKey, r)}` : r`${U(i, e.foreignKey, r)} = ${U(t, e.sourceKey, r)}`;
|
|
899
899
|
return r`(SELECT ${a} FROM ${r(e.target.tableName)} AS ${r(i)} WHERE ${o} LIMIT 1)`;
|
|
900
|
-
},
|
|
901
|
-
let r = n.sql, i = n.nextAlias(), a =
|
|
900
|
+
}, or = (e, t, n) => {
|
|
901
|
+
let r = n.sql, i = n.nextAlias(), a = H(i, e.target, e.children, n);
|
|
902
902
|
if (a === null) return null;
|
|
903
|
-
let o = r`${
|
|
903
|
+
let o = r`${U(void 0, e.foreignKey, r)} = ${U(t, e.sourceKey, r)}`, s = e.branch.where === void 0 ? r`` : r` AND ${L(J(e.branch.where), r)}`, c = Kn(e.branch.orderBy, r), l = e.branch.limit === void 0 ? r`` : r` LIMIT ${G(e.branch.limit, r)}`, u = e.branch.offset === void 0 ? r`` : r` OFFSET ${G(e.branch.offset, r)}`;
|
|
904
904
|
return r`COALESCE((SELECT JSON_ARRAYAGG(${a}) FROM (SELECT * FROM ${r(e.target.tableName)} WHERE ${o}${s}${c}${l}${u}) AS ${r(i)}), JSON_ARRAY())`;
|
|
905
|
-
},
|
|
906
|
-
let r = n.sql, i = e.relation, a = i.through(), o = n.nextAlias(), s = n.nextAlias(), c =
|
|
905
|
+
}, sr = (e, t, n) => {
|
|
906
|
+
let r = n.sql, i = e.relation, a = i.through(), o = n.nextAlias(), s = n.nextAlias(), c = H(o, e.target, e.children, n, e.junction === void 0 ? void 0 : {
|
|
907
907
|
projection: e.junction,
|
|
908
|
-
source:
|
|
908
|
+
source: Zn(o)
|
|
909
909
|
});
|
|
910
910
|
if (c === null) return null;
|
|
911
|
-
let l = e.branch.where === void 0 ? r`` : r` AND ${L(
|
|
912
|
-
return r`COALESCE((SELECT JSON_ARRAYAGG(${c}) FROM (SELECT ${r(o)}.*${m} FROM ${r(a.tableName)} AS ${r(s)} INNER JOIN ${r(e.target.tableName)} AS ${r(o)} ON ${
|
|
913
|
-
}, sr = (e, t, n) => {
|
|
914
|
-
let r = n.sql, i = n.nextAlias(), a = V(i, e.target, e.children, n);
|
|
915
|
-
if (a === null) return null;
|
|
916
|
-
let o = r`${H(i, e.foreignKey, r)} = ${H(t, e.sourceKey, r)}`, s = e.branch.where === void 0 ? r`` : r` AND ${L(q(e.branch.where), r)}`, c = e.branch.orderBy ?? [];
|
|
917
|
-
if (!(e.branch.limit !== void 0 || e.branch.offset !== void 0)) return r`COALESCE((SELECT JSON_ARRAYAGG(${a}${c.length > 0 ? r` ORDER BY ${r.csv(c.map((e) => e.direction === "desc" ? r`${H(i, e.column, r)} DESC` : r`${H(i, e.column, r)} ASC`))}` : r``}) FROM ${r(e.target.tableName)} AS ${r(i)} WHERE ${o}${s}), JSON_ARRAY())`;
|
|
918
|
-
let l = c.length > 0 ? r` ORDER BY ${r.csv(c.map((e) => e.direction === "desc" ? r`${r(e.column)} DESC` : r`${r(e.column)} ASC`))}` : r` ORDER BY ${r("id")}`, u = e.branch.limit, d = e.branch.offset, f = u !== void 0 && d !== void 0 ? r` AND ${H(i, "rn", r)} > ${W(d, r)} AND ${H(i, "rn", r)} <= ${W(d + u, r)}` : u === void 0 ? r` AND ${H(i, "rn", r)} > ${W(d, r)}` : r` AND ${H(i, "rn", r)} <= ${W(u, r)}`;
|
|
919
|
-
return r`COALESCE((SELECT JSON_ARRAYAGG(${a} ORDER BY ${H(i, "rn", r)}) FROM (SELECT *, ROW_NUMBER() OVER (PARTITION BY ${r(e.foreignKey)}${l}) AS rn FROM ${r(e.target.tableName)}) AS ${r(i)} WHERE ${o}${s}${f}), JSON_ARRAY())`;
|
|
911
|
+
let l = e.branch.where === void 0 ? r`` : r` AND ${L(J(e.branch.where), r)}`, u = q(e, s, r, !0), d = V(o, e.branch.orderBy, r), f = e.branch.limit === void 0 ? r`` : r` LIMIT ${G(e.branch.limit, r)}`, p = e.branch.offset === void 0 ? r`` : r` OFFSET ${G(e.branch.offset, r)}`, m = e.junction === void 0 ? r`` : Xn(e.junction, s, r);
|
|
912
|
+
return r`COALESCE((SELECT JSON_ARRAYAGG(${c}) FROM (SELECT ${r(o)}.*${m} FROM ${r(a.tableName)} AS ${r(s)} INNER JOIN ${r(e.target.tableName)} AS ${r(o)} ON ${U(o, "id", r)} = ${U(s, i.targetKey, r)} WHERE ${U(s, i.sourceKey, r)} = ${U(t, "id", r)}${u}${l}${d}${f}${p}) AS ${r(o)}), JSON_ARRAY())`;
|
|
920
913
|
}, cr = (e, t, n) => {
|
|
914
|
+
let r = n.sql, i = n.nextAlias(), a = H(i, e.target, e.children, n);
|
|
915
|
+
if (a === null) return null;
|
|
916
|
+
let o = r`${U(i, e.foreignKey, r)} = ${U(t, e.sourceKey, r)}`, s = e.branch.where === void 0 ? r`` : r` AND ${L(J(e.branch.where), r)}`, c = e.branch.orderBy ?? [];
|
|
917
|
+
if (!(e.branch.limit !== void 0 || e.branch.offset !== void 0)) return r`COALESCE((SELECT JSON_ARRAYAGG(${a}${c.length > 0 ? r` ORDER BY ${r.csv(c.map((e) => e.direction === "desc" ? r`${U(i, e.column, r)} DESC` : r`${U(i, e.column, r)} ASC`))}` : r``}) FROM ${r(e.target.tableName)} AS ${r(i)} WHERE ${o}${s}), JSON_ARRAY())`;
|
|
918
|
+
let l = c.length > 0 ? r` ORDER BY ${r.csv(c.map((e) => e.direction === "desc" ? r`${r(e.column)} DESC` : r`${r(e.column)} ASC`))}` : r` ORDER BY ${r("id")}`, u = e.branch.limit, d = e.branch.offset, f = u !== void 0 && d !== void 0 ? r` AND ${U(i, "rn", r)} > ${G(d, r)} AND ${U(i, "rn", r)} <= ${G(d + u, r)}` : u === void 0 ? r` AND ${U(i, "rn", r)} > ${G(d, r)}` : r` AND ${U(i, "rn", r)} <= ${G(u, r)}`;
|
|
919
|
+
return r`COALESCE((SELECT JSON_ARRAYAGG(${a} ORDER BY ${U(i, "rn", r)}) FROM (SELECT *, ROW_NUMBER() OVER (PARTITION BY ${r(e.foreignKey)}${l}) AS rn FROM ${r(e.target.tableName)}) AS ${r(i)} WHERE ${o}${s}${f}), JSON_ARRAY())`;
|
|
920
|
+
}, lr = (e, t, n) => {
|
|
921
921
|
let r = n.sql, i = e.relation, a = i.through(), o = n.nextAlias(), s = n.nextAlias(), c = (t) => e.junction === void 0 ? void 0 : {
|
|
922
922
|
projection: e.junction,
|
|
923
923
|
source: t
|
|
924
|
-
}, l = r`${
|
|
924
|
+
}, l = r`${U(s, i.sourceKey, r)} = ${U(t, "id", r)}`, u = r`${U(o, "id", r)} = ${U(s, i.targetKey, r)}`, d = e.branch.where === void 0 ? r`` : r` AND ${L(J(e.branch.where), r)}`, f = q(e, s, r, !0), p = e.branch.orderBy ?? [];
|
|
925
925
|
if (!(e.branch.limit !== void 0 || e.branch.offset !== void 0)) {
|
|
926
|
-
let t =
|
|
927
|
-
return t === null ? null : r`COALESCE((SELECT JSON_ARRAYAGG(${t}${p.length > 0 ? r` ORDER BY ${r.csv(p.map((e) => e.direction === "desc" ? r`${
|
|
928
|
-
}
|
|
929
|
-
let m = p.length > 0 ? r` ORDER BY ${r.csv(p.map((e) => e.direction === "desc" ? r`${
|
|
930
|
-
if (
|
|
931
|
-
let
|
|
932
|
-
return r`COALESCE((SELECT JSON_ARRAYAGG(${
|
|
933
|
-
},
|
|
934
|
-
let r = n.sql, i = n.nextAlias(), a =
|
|
926
|
+
let t = H(o, e.target, e.children, n, c(Qn(s)));
|
|
927
|
+
return t === null ? null : r`COALESCE((SELECT JSON_ARRAYAGG(${t}${p.length > 0 ? r` ORDER BY ${r.csv(p.map((e) => e.direction === "desc" ? r`${U(o, e.column, r)} DESC` : r`${U(o, e.column, r)} ASC`))}` : r``}) FROM ${r(a.tableName)} AS ${r(s)} INNER JOIN ${r(e.target.tableName)} AS ${r(o)} ON ${u} WHERE ${l}${f}${d}), JSON_ARRAY())`;
|
|
928
|
+
}
|
|
929
|
+
let m = p.length > 0 ? r` ORDER BY ${r.csv(p.map((e) => e.direction === "desc" ? r`${U(o, e.column, r)} DESC` : r`${U(o, e.column, r)} ASC`))}` : r` ORDER BY ${U(o, "id", r)}`, h = e.branch.limit, g = e.branch.offset, ee = h !== void 0 && g !== void 0 ? r` AND ${U(o, "rn", r)} > ${G(g, r)} AND ${U(o, "rn", r)} <= ${G(g + h, r)}` : h === void 0 ? r` AND ${U(o, "rn", r)} > ${G(g, r)}` : r` AND ${U(o, "rn", r)} <= ${G(h, r)}`, _ = e.branch.onJunction === void 0 ? r`` : r` WHERE ${K(J(e.branch.onJunction), s, r)}`, v = H(o, e.target, e.children, n, c(Zn(o)));
|
|
930
|
+
if (v === null) return null;
|
|
931
|
+
let y = e.junction === void 0 ? r`` : Xn(e.junction, s, r);
|
|
932
|
+
return r`COALESCE((SELECT JSON_ARRAYAGG(${v} ORDER BY ${U(o, "rn", r)}) FROM (SELECT ${r(o)}.*${y}, ${U(s, i.sourceKey, r)} AS ${r(`__src_${i.sourceKey}`)}, ROW_NUMBER() OVER (PARTITION BY ${U(s, i.sourceKey, r)}${m}) AS rn FROM ${r(a.tableName)} AS ${r(s)} INNER JOIN ${r(e.target.tableName)} AS ${r(o)} ON ${u}${_}) AS ${r(o)} WHERE ${U(o, `__src_${i.sourceKey}`, r)} = ${U(t, "id", r)}${d}${ee}), JSON_ARRAY())`;
|
|
933
|
+
}, ur = (e, t, n) => {
|
|
934
|
+
let r = n.sql, i = n.nextAlias(), a = dr(i, t.table, t.children, n);
|
|
935
935
|
if (a === null) return null;
|
|
936
|
-
let o = e.predicate ? r` WHERE ${
|
|
936
|
+
let o = e.predicate ? r` WHERE ${K(e.predicate, i, r)}` : r``, s = e.order.length > 0 ? r` ORDER BY ${r.csv(e.order.map((e) => e.direction === "desc" ? r`${U(i, e.column, r)} DESC` : r`${U(i, e.column, r)} ASC`))}` : r``, c = r``, l = r``;
|
|
937
937
|
if (e.skip !== void 0) {
|
|
938
938
|
let t = e.order.length > 0 ? s : r` ORDER BY (SELECT NULL)`;
|
|
939
|
-
l = e.take === void 0 ? r`${t} OFFSET ${
|
|
940
|
-
} else e.take !== void 0 && (c = r`TOP ${
|
|
939
|
+
l = e.take === void 0 ? r`${t} OFFSET ${G(e.skip, r)} ROWS` : r`${t} OFFSET ${G(e.skip, r)} ROWS FETCH NEXT ${G(e.take, r)} ROWS ONLY`;
|
|
940
|
+
} else e.take !== void 0 && (c = r`TOP ${G(e.take, r)} `);
|
|
941
941
|
let u = e.skip === void 0 ? s : r``;
|
|
942
942
|
return r`SELECT ${c}(SELECT ${a} FOR JSON PATH, INCLUDE_NULL_VALUES, WITHOUT_ARRAY_WRAPPER) AS ${r("__row")} FROM ${r(t.table.tableName)} AS ${r(i)}${o}${u}${l}`;
|
|
943
|
-
},
|
|
943
|
+
}, dr = (e, t, n, r, i) => {
|
|
944
944
|
let a = r.sql, o = [];
|
|
945
|
-
for (let n of Object.keys(t.fields)) o.push(a`${
|
|
946
|
-
if (i !== void 0) for (let e of i.projection.present) o.push(a`${
|
|
945
|
+
for (let n of Object.keys(t.fields)) o.push(a`${U(e, n, a)} AS ${a(n)}`);
|
|
946
|
+
if (i !== void 0) for (let e of i.projection.present) o.push(a`${U(i.source.alias, i.source.physical(e), a)} AS ${fr(`_junction.${e}`, a)}`);
|
|
947
947
|
for (let t of n) {
|
|
948
|
-
let n =
|
|
948
|
+
let n = pr(t, e, r);
|
|
949
949
|
if (n === null) return null;
|
|
950
950
|
o.push(n);
|
|
951
951
|
}
|
|
952
952
|
return a.csv(o);
|
|
953
|
-
},
|
|
953
|
+
}, fr = (e, t) => t.unsafe(`[${e.replace(/]/g, "]]")}]`), pr = (e, t, n) => {
|
|
954
954
|
switch (e.relation.kind) {
|
|
955
|
-
case "one": return z(e) ?
|
|
956
|
-
case "many": return
|
|
957
|
-
case "manyToMany": return
|
|
955
|
+
case "one": return z(e) ? gr(B(e), t, n) : mr(e, t, n);
|
|
956
|
+
case "many": return gr(e, t, n);
|
|
957
|
+
case "manyToMany": return _r(e, t, n);
|
|
958
958
|
}
|
|
959
|
-
},
|
|
960
|
-
let r = n.sql, i = n.nextAlias(), a =
|
|
959
|
+
}, mr = (e, t, n) => {
|
|
960
|
+
let r = n.sql, i = n.nextAlias(), a = dr(i, e.target, e.children, n);
|
|
961
961
|
if (a === null) return null;
|
|
962
|
-
let o = e.fkSide === "source" ? r`${
|
|
962
|
+
let o = e.fkSide === "source" ? r`${U(i, "id", r)} = ${U(t, e.foreignKey, r)}` : r`${U(i, e.foreignKey, r)} = ${U(t, e.sourceKey, r)}`;
|
|
963
963
|
return r`JSON_QUERY((SELECT TOP 1 ${a} FROM ${r(e.target.tableName)} AS ${r(i)} WHERE ${o} FOR JSON PATH, INCLUDE_NULL_VALUES, WITHOUT_ARRAY_WRAPPER)) AS ${r(e.relationName)}`;
|
|
964
|
-
},
|
|
964
|
+
}, hr = (e, t, n) => {
|
|
965
965
|
if (e.offset !== void 0) {
|
|
966
|
-
let r = e.orderBy && e.orderBy.length > 0 ? t : n` ORDER BY (SELECT NULL)`, i = e.limit === void 0 ? n`${r} OFFSET ${
|
|
966
|
+
let r = e.orderBy && e.orderBy.length > 0 ? t : n` ORDER BY (SELECT NULL)`, i = e.limit === void 0 ? n`${r} OFFSET ${G(e.offset, n)} ROWS` : n`${r} OFFSET ${G(e.offset, n)} ROWS FETCH NEXT ${G(e.limit, n)} ROWS ONLY`;
|
|
967
967
|
return {
|
|
968
968
|
top: n``,
|
|
969
969
|
pagination: i,
|
|
@@ -971,33 +971,33 @@ var ot = (e) => e === "mysql" || e === "mariadb" || e === "mssql" || e === "sqli
|
|
|
971
971
|
};
|
|
972
972
|
}
|
|
973
973
|
return {
|
|
974
|
-
top: e.limit === void 0 ? n`` : n`TOP ${
|
|
974
|
+
top: e.limit === void 0 ? n`` : n`TOP ${G(e.limit, n)} `,
|
|
975
975
|
pagination: n``,
|
|
976
976
|
finalOrder: t
|
|
977
977
|
};
|
|
978
|
-
}, hr = (e, t, n) => {
|
|
979
|
-
let r = n.sql, i = n.nextAlias(), a = ur(i, e.target, e.children, n);
|
|
980
|
-
if (a === null) return null;
|
|
981
|
-
let o = e.branch.where === void 0 ? r`` : r` AND ${G(e.branch.where, i, r)}`, s = B(i, e.branch.orderBy, r), { top: c, pagination: l, finalOrder: u } = mr(e.branch, s, r);
|
|
982
|
-
return r`ISNULL(JSON_QUERY((SELECT ${c}${a} FROM ${r(e.target.tableName)} AS ${r(i)} WHERE ${H(i, e.foreignKey, r)} = ${H(t, e.sourceKey, r)}${o}${u}${l} FOR JSON PATH, INCLUDE_NULL_VALUES)), JSON_QUERY('[]')) AS ${r(e.relationName)}`;
|
|
983
978
|
}, gr = (e, t, n) => {
|
|
984
|
-
let r = n.sql, i =
|
|
979
|
+
let r = n.sql, i = n.nextAlias(), a = dr(i, e.target, e.children, n);
|
|
980
|
+
if (a === null) return null;
|
|
981
|
+
let o = e.branch.where === void 0 ? r`` : r` AND ${K(e.branch.where, i, r)}`, s = V(i, e.branch.orderBy, r), { top: c, pagination: l, finalOrder: u } = hr(e.branch, s, r);
|
|
982
|
+
return r`ISNULL(JSON_QUERY((SELECT ${c}${a} FROM ${r(e.target.tableName)} AS ${r(i)} WHERE ${U(i, e.foreignKey, r)} = ${U(t, e.sourceKey, r)}${o}${u}${l} FOR JSON PATH, INCLUDE_NULL_VALUES)), JSON_QUERY('[]')) AS ${r(e.relationName)}`;
|
|
983
|
+
}, _r = (e, t, n) => {
|
|
984
|
+
let r = n.sql, i = e.relation, a = i.through(), o = n.nextAlias(), s = n.nextAlias(), c = dr(o, e.target, e.children, n, e.junction === void 0 ? void 0 : {
|
|
985
985
|
projection: e.junction,
|
|
986
|
-
source:
|
|
986
|
+
source: Qn(s)
|
|
987
987
|
});
|
|
988
988
|
if (c === null) return null;
|
|
989
|
-
let l = e.branch.where === void 0 ? r`` : r` AND ${
|
|
990
|
-
return r`ISNULL(JSON_QUERY((SELECT ${f}${c} FROM ${r(a.tableName)} AS ${r(s)} INNER JOIN ${r(e.target.tableName)} AS ${r(o)} ON ${
|
|
991
|
-
},
|
|
989
|
+
let l = e.branch.where === void 0 ? r`` : r` AND ${K(e.branch.where, o, r)}`, u = q(e, s, r), d = V(o, e.branch.orderBy, r), { top: f, pagination: p, finalOrder: m } = hr(e.branch, d, r);
|
|
990
|
+
return r`ISNULL(JSON_QUERY((SELECT ${f}${c} FROM ${r(a.tableName)} AS ${r(s)} INNER JOIN ${r(e.target.tableName)} AS ${r(o)} ON ${U(o, "id", r)} = ${U(s, i.targetKey, r)} WHERE ${U(s, i.sourceKey, r)} = ${U(t, "id", r)}${u}${l}${m}${p} FOR JSON PATH, INCLUDE_NULL_VALUES)), JSON_QUERY('[]')) AS ${r(e.relationName)}`;
|
|
991
|
+
}, U = (e, t, n) => e === void 0 ? n`${n(t)}` : n`${n(e)}.${n(t)}`, W = (e, t) => t.unsafe(`'${e.replace(/'/g, "''")}'`), G = (e, t) => {
|
|
992
992
|
if (!Number.isFinite(e) || !Number.isInteger(e) || e < 0) throw Error(`literalInt: expected non-negative integer, got ${e}`);
|
|
993
993
|
return t.unsafe(String(e));
|
|
994
|
-
},
|
|
994
|
+
}, K = (e, t, n) => L(vr(e, t), n), q = (e, t, n, r = !1) => {
|
|
995
995
|
let i = e.branch.onJunction;
|
|
996
|
-
return i === void 0 ? n`` : n` AND ${
|
|
997
|
-
},
|
|
998
|
-
if ("not" in e) return { not:
|
|
999
|
-
if ("and" in e) return { and: e.and.map((e) =>
|
|
1000
|
-
if ("or" in e) return { or: e.or.map((e) =>
|
|
996
|
+
return i === void 0 ? n`` : n` AND ${K(r ? J(i) : i, t, n)}`;
|
|
997
|
+
}, vr = (e, t) => {
|
|
998
|
+
if ("not" in e) return { not: vr(e.not, t) };
|
|
999
|
+
if ("and" in e) return { and: e.and.map((e) => vr(e, t)) };
|
|
1000
|
+
if ("or" in e) return { or: e.or.map((e) => vr(e, t)) };
|
|
1001
1001
|
if (e.op === "subquery-in" || e.op === "subquery-not-in") {
|
|
1002
1002
|
let n = e;
|
|
1003
1003
|
return {
|
|
@@ -1011,91 +1011,91 @@ var ot = (e) => e === "mysql" || e === "mariadb" || e === "mssql" || e === "sqli
|
|
|
1011
1011
|
...n,
|
|
1012
1012
|
column: `${t}.${n.column}`
|
|
1013
1013
|
};
|
|
1014
|
-
},
|
|
1015
|
-
if ("not" in e) return { not:
|
|
1016
|
-
if ("and" in e) return { and: e.and.map((e) =>
|
|
1017
|
-
if ("or" in e) return { or: e.or.map((e) =>
|
|
1014
|
+
}, J = (e) => {
|
|
1015
|
+
if ("not" in e) return { not: J(e.not) };
|
|
1016
|
+
if ("and" in e) return { and: e.and.map((e) => J(e)) };
|
|
1017
|
+
if ("or" in e) return { or: e.or.map((e) => J(e)) };
|
|
1018
1018
|
if (e.op === "subquery-in" || e.op === "subquery-not-in" || e.op === "exists" || e.op === "not-exists") return e;
|
|
1019
1019
|
let t = e;
|
|
1020
1020
|
return {
|
|
1021
1021
|
...t,
|
|
1022
|
-
value:
|
|
1022
|
+
value: yr(t.value)
|
|
1023
1023
|
};
|
|
1024
|
-
},
|
|
1025
|
-
e.actors !== void 0 && (
|
|
1026
|
-
},
|
|
1024
|
+
}, yr = (e) => e == null ? e : e instanceof Date ? e.toISOString() : typeof e == "boolean" ? +!!e : Array.isArray(e) ? e.map((e) => yr(e)) : e, br = Symbol.for("@voltro/database/coreTablesRegistry"), xr = globalThis, Sr = xr[br] ?? (xr[br] = {}), Cr = (e) => {
|
|
1025
|
+
e.actors !== void 0 && (Sr.actors = e.actors), e.tenants !== void 0 && (Sr.tenants = e.tenants);
|
|
1026
|
+
}, wr = (e, t) => () => {
|
|
1027
1027
|
let n = e();
|
|
1028
1028
|
if (n === void 0) throw Error(`core '${t}' table not registered; expected the framework CLI or your migrate step to call registerCoreTables({ ${t}: () => ${t}Table }) before the database handle is constructed`);
|
|
1029
1029
|
return n();
|
|
1030
|
-
},
|
|
1031
|
-
id:
|
|
1032
|
-
kind:
|
|
1030
|
+
}, Tr = () => wr(() => Sr.actors, "actors"), Er = () => wr(() => Sr.tenants, "tenants"), Dr = w("actors", {
|
|
1031
|
+
id: O(),
|
|
1032
|
+
kind: y().oneOf([
|
|
1033
1033
|
"user",
|
|
1034
1034
|
"serviceAccount",
|
|
1035
1035
|
"apiKey",
|
|
1036
1036
|
"system"
|
|
1037
1037
|
]),
|
|
1038
|
-
displayName:
|
|
1039
|
-
createdAt:
|
|
1040
|
-
}),
|
|
1038
|
+
displayName: y().nullable(),
|
|
1039
|
+
createdAt: D().default("now")
|
|
1040
|
+
}), Or = (e, t) => ({
|
|
1041
1041
|
column: e,
|
|
1042
1042
|
op: "eq",
|
|
1043
1043
|
value: t
|
|
1044
|
-
}),
|
|
1044
|
+
}), kr = (e, t) => ({
|
|
1045
1045
|
column: e,
|
|
1046
1046
|
op: "neq",
|
|
1047
1047
|
value: t
|
|
1048
|
-
}),
|
|
1048
|
+
}), Ar = (e, t) => ({
|
|
1049
1049
|
column: e,
|
|
1050
1050
|
op: "gt",
|
|
1051
1051
|
value: t
|
|
1052
|
-
}),
|
|
1052
|
+
}), jr = (e, t) => ({
|
|
1053
1053
|
column: e,
|
|
1054
1054
|
op: "gte",
|
|
1055
1055
|
value: t
|
|
1056
|
-
}),
|
|
1056
|
+
}), Mr = (e, t) => ({
|
|
1057
1057
|
column: e,
|
|
1058
1058
|
op: "lt",
|
|
1059
1059
|
value: t
|
|
1060
|
-
}),
|
|
1060
|
+
}), Nr = (e, t) => ({
|
|
1061
1061
|
column: e,
|
|
1062
1062
|
op: "lte",
|
|
1063
1063
|
value: t
|
|
1064
|
-
}),
|
|
1064
|
+
}), Pr = (e, t) => ({
|
|
1065
1065
|
column: e,
|
|
1066
1066
|
op: "in",
|
|
1067
1067
|
value: t
|
|
1068
|
-
}),
|
|
1068
|
+
}), Fr = (e, t) => ({
|
|
1069
1069
|
column: e,
|
|
1070
1070
|
op: "notIn",
|
|
1071
1071
|
value: t
|
|
1072
|
-
}),
|
|
1072
|
+
}), Ir = (e, t) => ({
|
|
1073
1073
|
column: e,
|
|
1074
1074
|
op: "contains",
|
|
1075
1075
|
value: t
|
|
1076
|
-
}),
|
|
1076
|
+
}), Lr = (e, t) => ({
|
|
1077
1077
|
column: e,
|
|
1078
1078
|
op: "arrayContains",
|
|
1079
1079
|
value: t
|
|
1080
|
-
}),
|
|
1080
|
+
}), Rr = (e, t) => ({
|
|
1081
1081
|
column: e,
|
|
1082
1082
|
op: "arrayOverlaps",
|
|
1083
1083
|
value: t
|
|
1084
|
-
}),
|
|
1084
|
+
}), zr = (e, t) => ({
|
|
1085
1085
|
column: e,
|
|
1086
1086
|
op: "arrayHas",
|
|
1087
1087
|
value: t
|
|
1088
|
-
}),
|
|
1088
|
+
}), Br = (e) => ({
|
|
1089
1089
|
column: e,
|
|
1090
1090
|
op: "isNull"
|
|
1091
|
-
}),
|
|
1091
|
+
}), Vr = (e) => ({
|
|
1092
1092
|
column: e,
|
|
1093
1093
|
op: "isNotNull"
|
|
1094
|
-
}),
|
|
1094
|
+
}), Hr = (e, t) => ({
|
|
1095
1095
|
column: e,
|
|
1096
1096
|
op: "spatial",
|
|
1097
1097
|
value: t
|
|
1098
|
-
}),
|
|
1098
|
+
}), Ur = (...e) => ({ and: e }), Wr = (...e) => ({ or: e }), Gr = (e) => ({ not: e }), Kr = (e, ...t) => {
|
|
1099
1099
|
if (t.length === 0) throw Error(`jsonField("${e}"): at least one path segment is required`);
|
|
1100
1100
|
let n = (n, r) => ({
|
|
1101
1101
|
column: e,
|
|
@@ -1116,29 +1116,29 @@ var ot = (e) => e === "mysql" || e === "mariadb" || e === "mssql" || e === "sqli
|
|
|
1116
1116
|
isNull: () => n("isNull"),
|
|
1117
1117
|
isNotNull: () => n("isNotNull")
|
|
1118
1118
|
};
|
|
1119
|
-
},
|
|
1119
|
+
}, qr = (e) => "descriptor" in e ? e.descriptor : e, Jr = (e, t) => ({
|
|
1120
1120
|
column: e,
|
|
1121
1121
|
op: "subquery-in",
|
|
1122
|
-
subquery:
|
|
1123
|
-
}),
|
|
1122
|
+
subquery: qr(t)
|
|
1123
|
+
}), Yr = (e, t) => ({
|
|
1124
1124
|
column: e,
|
|
1125
1125
|
op: "subquery-not-in",
|
|
1126
|
-
subquery:
|
|
1127
|
-
}), Yr = (e) => ({
|
|
1128
|
-
op: "exists",
|
|
1129
|
-
subquery: Kr(e)
|
|
1126
|
+
subquery: qr(t)
|
|
1130
1127
|
}), Xr = (e) => ({
|
|
1128
|
+
op: "exists",
|
|
1129
|
+
subquery: qr(e)
|
|
1130
|
+
}), Zr = (e) => ({
|
|
1131
1131
|
op: "not-exists",
|
|
1132
|
-
subquery:
|
|
1133
|
-
}),
|
|
1132
|
+
subquery: qr(e)
|
|
1133
|
+
}), Qr = (e, t) => e == null || t == null ? null : typeof e == typeof t ? e === t ? 0 : e > t ? 1 : -1 : null, $r = (e, t, n = null) => {
|
|
1134
1134
|
if (!t) return !1;
|
|
1135
|
-
if ("not" in e) return
|
|
1135
|
+
if ("not" in e) return !$r(e.not, t, n);
|
|
1136
1136
|
if ("and" in e) {
|
|
1137
|
-
for (let r of e.and) if (
|
|
1137
|
+
for (let r of e.and) if (!$r(r, t, n)) return !1;
|
|
1138
1138
|
return !0;
|
|
1139
1139
|
}
|
|
1140
1140
|
if ("or" in e) {
|
|
1141
|
-
for (let r of e.or) if (
|
|
1141
|
+
for (let r of e.or) if ($r(r, t, n)) return !0;
|
|
1142
1142
|
return !1;
|
|
1143
1143
|
}
|
|
1144
1144
|
if (e.op === "subquery-in" || e.op === "subquery-not-in") {
|
|
@@ -1157,10 +1157,10 @@ var ot = (e) => e === "mysql" || e === "mariadb" || e === "mssql" || e === "sqli
|
|
|
1157
1157
|
switch (r.op) {
|
|
1158
1158
|
case "eq": return i === r.value;
|
|
1159
1159
|
case "neq": return i !== r.value;
|
|
1160
|
-
case "gt": return (
|
|
1161
|
-
case "gte": return (
|
|
1162
|
-
case "lt": return (
|
|
1163
|
-
case "lte": return (
|
|
1160
|
+
case "gt": return (Qr(i, r.value) ?? -1) > 0;
|
|
1161
|
+
case "gte": return (Qr(i, r.value) ?? -1) >= 0;
|
|
1162
|
+
case "lt": return (Qr(i, r.value) ?? 1) < 0;
|
|
1163
|
+
case "lte": return (Qr(i, r.value) ?? 1) <= 0;
|
|
1164
1164
|
case "in": return Array.isArray(r.value) && r.value.includes(i);
|
|
1165
1165
|
case "notIn": return Array.isArray(r.value) && !r.value.includes(i);
|
|
1166
1166
|
case "contains": return typeof i == "string" && typeof r.value == "string" && i.toLowerCase().includes(r.value.toLowerCase());
|
|
@@ -1177,17 +1177,17 @@ var ot = (e) => e === "mysql" || e === "mariadb" || e === "mssql" || e === "sqli
|
|
|
1177
1177
|
case "isNotNull": return i != null;
|
|
1178
1178
|
case "spatial": throw Error("@voltro/plugin-postgis: spatial predicates (ST_DWithin / ST_Contains / ST_Within / ST_Intersects / bbox &&) are not evaluable in-memory — use them in one-shot ctx.store.query reads, not reactive subscriptions.");
|
|
1179
1179
|
}
|
|
1180
|
-
},
|
|
1180
|
+
}, ei = function* (e) {
|
|
1181
1181
|
if ("not" in e) {
|
|
1182
|
-
yield*
|
|
1182
|
+
yield* ei(e.not);
|
|
1183
1183
|
return;
|
|
1184
1184
|
}
|
|
1185
1185
|
if ("and" in e) {
|
|
1186
|
-
for (let t of e.and) yield*
|
|
1186
|
+
for (let t of e.and) yield* ei(t);
|
|
1187
1187
|
return;
|
|
1188
1188
|
}
|
|
1189
1189
|
if ("or" in e) {
|
|
1190
|
-
for (let t of e.or) yield*
|
|
1190
|
+
for (let t of e.or) yield* ei(t);
|
|
1191
1191
|
return;
|
|
1192
1192
|
}
|
|
1193
1193
|
e.op === "subquery-in" || e.op === "subquery-not-in" ? yield {
|
|
@@ -1197,27 +1197,27 @@ var ot = (e) => e === "mysql" || e === "mariadb" || e === "mssql" || e === "sqli
|
|
|
1197
1197
|
kind: "exists",
|
|
1198
1198
|
descriptor: e.subquery
|
|
1199
1199
|
});
|
|
1200
|
-
},
|
|
1200
|
+
}, ti = function* (e, t = !0) {
|
|
1201
1201
|
if ("not" in e) {
|
|
1202
|
-
yield*
|
|
1202
|
+
yield* ti(e.not, !1);
|
|
1203
1203
|
return;
|
|
1204
1204
|
}
|
|
1205
1205
|
if ("and" in e) {
|
|
1206
|
-
for (let n of e.and) yield*
|
|
1206
|
+
for (let n of e.and) yield* ti(n, t);
|
|
1207
1207
|
return;
|
|
1208
1208
|
}
|
|
1209
1209
|
if ("or" in e) {
|
|
1210
|
-
for (let t of e.or) yield*
|
|
1210
|
+
for (let t of e.or) yield* ti(t, !1);
|
|
1211
1211
|
return;
|
|
1212
1212
|
}
|
|
1213
1213
|
e.op === "subquery-in" || e.op === "subquery-not-in" || e.op === "exists" || e.op === "not-exists" || (yield {
|
|
1214
1214
|
...e,
|
|
1215
1215
|
conjunctive: t
|
|
1216
1216
|
});
|
|
1217
|
-
},
|
|
1218
|
-
let i =
|
|
1217
|
+
}, ni = class extends nt.TaggedError("TableStreamError") {}, ri = 1e3, ii = (e, t, n, r) => {
|
|
1218
|
+
let i = k.match(r, {
|
|
1219
1219
|
onNone: () => e.where,
|
|
1220
|
-
onSome: (n) => e.where ?
|
|
1220
|
+
onSome: (n) => e.where ? Ur(e.where, Ar(t, n)) : Ar(t, n)
|
|
1221
1221
|
});
|
|
1222
1222
|
return {
|
|
1223
1223
|
table: e.table,
|
|
@@ -1232,19 +1232,19 @@ var ot = (e) => e === "mysql" || e === "mariadb" || e === "mssql" || e === "sqli
|
|
|
1232
1232
|
...e.includeDeleted === void 0 ? {} : { includeDeleted: e.includeDeleted },
|
|
1233
1233
|
...e.crossTenant === void 0 ? {} : { crossTenant: e.crossTenant }
|
|
1234
1234
|
};
|
|
1235
|
-
},
|
|
1236
|
-
let n = t.pk ?? "id", r = t.chunkSize ??
|
|
1237
|
-
return
|
|
1238
|
-
let a =
|
|
1239
|
-
try: () => e.query(
|
|
1240
|
-
catch: (e) => new
|
|
1235
|
+
}, ai = (e, t) => {
|
|
1236
|
+
let n = t.pk ?? "id", r = t.chunkSize ?? ri;
|
|
1237
|
+
return it.paginateChunkEffect(k.none(), (i) => {
|
|
1238
|
+
let a = rt.tryPromise({
|
|
1239
|
+
try: () => e.query(ii(t, n, r, i)),
|
|
1240
|
+
catch: (e) => new ni({
|
|
1241
1241
|
table: t.table,
|
|
1242
1242
|
cause: e
|
|
1243
1243
|
})
|
|
1244
1244
|
});
|
|
1245
|
-
return (t.retry ? a.pipe(
|
|
1245
|
+
return (t.retry ? a.pipe(rt.retry(t.retry)) : a).pipe(rt.map((e) => [tt.fromIterable(e), e.length === r && e.length > 0 ? k.some(k.some(e[e.length - 1][n])) : k.none()]));
|
|
1246
1246
|
});
|
|
1247
|
-
},
|
|
1247
|
+
}, oi = (e) => {
|
|
1248
1248
|
let t = e.alpha ?? .5;
|
|
1249
1249
|
if (t < 0 || t > 1) throw Error(`hybridSearch: alpha must be in [0, 1], got ${t}`);
|
|
1250
1250
|
return (n) => {
|
|
@@ -1271,15 +1271,15 @@ var ot = (e) => e === "mysql" || e === "mariadb" || e === "mssql" || e === "sqli
|
|
|
1271
1271
|
}
|
|
1272
1272
|
};
|
|
1273
1273
|
};
|
|
1274
|
-
},
|
|
1274
|
+
}, si = async (e, t) => {
|
|
1275
1275
|
let n = e.as ?? "embedding", r = t.row[e.from];
|
|
1276
1276
|
if (typeof r != "string" || r.length === 0) return {};
|
|
1277
1277
|
let i = await t.embed(r);
|
|
1278
1278
|
return { [n]: i };
|
|
1279
|
-
},
|
|
1279
|
+
}, ci = (e) => {
|
|
1280
1280
|
if (!Number.isInteger(e.dimensions) || e.dimensions <= 0) throw Error(`vectorEmbedding: dimensions must be a positive integer, got ${String(e.dimensions)}.`);
|
|
1281
|
-
let t = e.as ?? "embedding", r = (t) =>
|
|
1282
|
-
return
|
|
1281
|
+
let t = e.as ?? "embedding", r = (t) => si(e, t);
|
|
1282
|
+
return ie({
|
|
1283
1283
|
id: "voltro/vectorEmbedding",
|
|
1284
1284
|
fields: { [t]: n(e.dimensions) },
|
|
1285
1285
|
...e.index === !1 ? {} : { indexes: [{
|
|
@@ -1296,19 +1296,19 @@ var ot = (e) => e === "mysql" || e === "mariadb" || e === "mssql" || e === "sqli
|
|
|
1296
1296
|
beforeUpdate: r
|
|
1297
1297
|
}
|
|
1298
1298
|
});
|
|
1299
|
-
},
|
|
1299
|
+
}, li = 63, ui = "br_pr", Y = class extends Error {
|
|
1300
1300
|
_tag = "BranchNameInvalid";
|
|
1301
1301
|
constructor(e) {
|
|
1302
1302
|
super(e), this.name = "BranchNameInvalid";
|
|
1303
1303
|
}
|
|
1304
|
-
},
|
|
1304
|
+
}, di = (e, t) => {
|
|
1305
1305
|
if (!Number.isInteger(t) || t < 0) throw new Y(`prNumber must be a non-negative integer, got ${String(t)}`);
|
|
1306
1306
|
let n = un(e);
|
|
1307
1307
|
if (n.replace(/_/g, "") === "") throw new Y(`app slug '${e}' has no usable identifier characters`);
|
|
1308
|
-
let r = `${
|
|
1309
|
-
if (r.length >
|
|
1308
|
+
let r = `${ui}${t}_${n}`;
|
|
1309
|
+
if (r.length > li) throw new Y(`branch namespace '${r}' exceeds the ${li}-byte identifier limit — use a shorter app slug`);
|
|
1310
1310
|
return r;
|
|
1311
|
-
},
|
|
1311
|
+
}, fi = (e) => e.startsWith(ui), pi = {
|
|
1312
1312
|
requested: {
|
|
1313
1313
|
provision: "provisioning",
|
|
1314
1314
|
destroy: "destroying"
|
|
@@ -1327,18 +1327,18 @@ var ot = (e) => e === "mysql" || e === "mariadb" || e === "mssql" || e === "sqli
|
|
|
1327
1327
|
fail: "failed"
|
|
1328
1328
|
},
|
|
1329
1329
|
destroyed: {}
|
|
1330
|
-
},
|
|
1330
|
+
}, mi = class extends Error {
|
|
1331
1331
|
from;
|
|
1332
1332
|
event;
|
|
1333
1333
|
_tag = "BranchTransitionInvalid";
|
|
1334
1334
|
constructor(e, t) {
|
|
1335
1335
|
super(`invalid branch transition: ${e} --${t}-->`), this.from = e, this.event = t, this.name = "BranchTransitionInvalid";
|
|
1336
1336
|
}
|
|
1337
|
-
},
|
|
1338
|
-
let n =
|
|
1339
|
-
if (n === void 0) throw new
|
|
1337
|
+
}, hi = (e, t) => {
|
|
1338
|
+
let n = pi[e][t];
|
|
1339
|
+
if (n === void 0) throw new mi(e, t);
|
|
1340
1340
|
return n;
|
|
1341
|
-
},
|
|
1341
|
+
}, gi = (e, t, n, r) => {
|
|
1342
1342
|
if (n === "copy" && (r === void 0 || r === "")) throw new Y("seed 'copy' requires a parentNamespace to snapshot from");
|
|
1343
1343
|
let i = [{
|
|
1344
1344
|
kind: "create-namespace",
|
|
@@ -1359,13 +1359,13 @@ var ot = (e) => e === "mysql" || e === "mariadb" || e === "mssql" || e === "sqli
|
|
|
1359
1359
|
detail: `run boot seeds into ${e}`
|
|
1360
1360
|
});
|
|
1361
1361
|
return i;
|
|
1362
|
-
},
|
|
1363
|
-
if (!
|
|
1362
|
+
}, _i = (e) => {
|
|
1363
|
+
if (!fi(e)) throw new Y(`refusing to plan teardown of '${e}' — not a branch namespace`);
|
|
1364
1364
|
return [{
|
|
1365
1365
|
kind: "drop-namespace",
|
|
1366
1366
|
detail: e
|
|
1367
1367
|
}];
|
|
1368
|
-
},
|
|
1368
|
+
}, vi = (e) => {
|
|
1369
1369
|
if (e === void 0 || e === "") return !1;
|
|
1370
1370
|
try {
|
|
1371
1371
|
let t = new URL(e).hostname.toLowerCase();
|
|
@@ -1373,27 +1373,27 @@ var ot = (e) => e === "mysql" || e === "mariadb" || e === "mssql" || e === "sqli
|
|
|
1373
1373
|
} catch {
|
|
1374
1374
|
return /\bneon\.(tech|build)\b/i.test(e);
|
|
1375
1375
|
}
|
|
1376
|
-
},
|
|
1376
|
+
}, yi = (e) => e.prefer === void 0 ? e.seed === "copy" && vi(e.dbUrl) ? "neon-cow" : "namespace" : e.prefer, bi = (e, t = {}) => [{
|
|
1377
1377
|
kind: "neon-branch-create",
|
|
1378
1378
|
detail: `${t.parentBranch ?? "main"} → ${e} (copy-on-write)`
|
|
1379
|
-
}],
|
|
1380
|
-
if (!
|
|
1379
|
+
}], xi = (e) => {
|
|
1380
|
+
if (!fi(e)) throw new Y(`refusing to plan teardown of '${e}' — not a branch namespace`);
|
|
1381
1381
|
return [{
|
|
1382
1382
|
kind: "neon-branch-delete",
|
|
1383
1383
|
detail: e
|
|
1384
1384
|
}];
|
|
1385
|
-
},
|
|
1385
|
+
}, Si = (e) => e.mechanism === "neon-cow" ? bi(e.branchId, e.neonParentBranch === void 0 ? {} : { parentBranch: e.neonParentBranch }) : gi(e.branchId, e.tableNames, e.seed, e.parentNamespace), Ci = (e, t) => e === "neon-cow" ? xi(t) : _i(t), wi = (e, t, n) => {
|
|
1386
1386
|
let r = e.filter((e) => e.state !== "destroyed" && e.state !== "destroying"), i = r.filter((e) => n - e.createdAtMs > t.ttlMs).map((e) => e.namespace), a = new Set(i);
|
|
1387
1387
|
return {
|
|
1388
1388
|
evict: i,
|
|
1389
1389
|
rejectNew: r.filter((e) => !a.has(e.namespace)).length >= t.maxBranches
|
|
1390
1390
|
};
|
|
1391
|
-
},
|
|
1392
|
-
let n =
|
|
1391
|
+
}, Ti = async (e, t) => {
|
|
1392
|
+
let n = di(e.appSlug, e.prNumber), r = yi({
|
|
1393
1393
|
seed: e.seed,
|
|
1394
1394
|
...e.dbUrl === void 0 ? {} : { dbUrl: e.dbUrl },
|
|
1395
1395
|
...e.prefer === void 0 ? {} : { prefer: e.prefer }
|
|
1396
|
-
}), i =
|
|
1396
|
+
}), i = Si({
|
|
1397
1397
|
mechanism: r,
|
|
1398
1398
|
branchId: n,
|
|
1399
1399
|
tableNames: e.tableNames,
|
|
@@ -1418,10 +1418,10 @@ var ot = (e) => e === "mysql" || e === "mariadb" || e === "mssql" || e === "sqli
|
|
|
1418
1418
|
mechanism: r,
|
|
1419
1419
|
steps: i
|
|
1420
1420
|
};
|
|
1421
|
-
},
|
|
1422
|
-
let r =
|
|
1421
|
+
}, Ei = async (e, t, n) => {
|
|
1422
|
+
let r = Ci(t, e);
|
|
1423
1423
|
return t === "neon-cow" ? await n.neonBranchDelete(e) : await n.dropNamespace(e), r;
|
|
1424
|
-
},
|
|
1424
|
+
}, Di = (e, t, n) => wi(e, t, n), X = (e) => `"${e.replace(/"/g, "\"\"")}"`, Oi = (e) => {
|
|
1425
1425
|
let t = () => {
|
|
1426
1426
|
throw Error("namespace branch executor: Neon ops require a neon-cow executor (use a Neon connection for copy-on-write branches)");
|
|
1427
1427
|
};
|
|
@@ -1433,18 +1433,18 @@ var ot = (e) => e === "mysql" || e === "mariadb" || e === "mssql" || e === "sqli
|
|
|
1433
1433
|
neonBranchCreate: t,
|
|
1434
1434
|
neonBranchDelete: t
|
|
1435
1435
|
};
|
|
1436
|
-
},
|
|
1436
|
+
}, ki = class extends Error {
|
|
1437
1437
|
_tag = "TenantResidencyUnresolved";
|
|
1438
1438
|
constructor(e) {
|
|
1439
1439
|
super(e), this.name = "TenantResidencyUnresolved";
|
|
1440
1440
|
}
|
|
1441
|
-
},
|
|
1441
|
+
}, Ai = class extends Error {
|
|
1442
1442
|
region;
|
|
1443
1443
|
_tag = "TenantRegionUnavailable";
|
|
1444
1444
|
constructor(e, t) {
|
|
1445
1445
|
super(t), this.region = e, this.name = "TenantRegionUnavailable";
|
|
1446
1446
|
}
|
|
1447
|
-
},
|
|
1447
|
+
}, ji, Mi = (e) => {
|
|
1448
1448
|
if (e.homes === void 0) throw Error("setResidencyConfig: `homes` is required");
|
|
1449
1449
|
if (e.servableRegions === void 0 || e.servableRegions.length === 0) throw Error("setResidencyConfig: `servableRegions` must be non-empty (which regions this deployment serves)");
|
|
1450
1450
|
let t = /* @__PURE__ */ new Map();
|
|
@@ -1453,32 +1453,32 @@ var ot = (e) => e === "mysql" || e === "mariadb" || e === "mssql" || e === "sqli
|
|
|
1453
1453
|
if (e !== void 0 && e !== n.region) throw Error(`residency: tenant '${n.tenantId}' is mapped to two regions ('${e}' and '${n.region}')`);
|
|
1454
1454
|
t.set(n.tenantId, n.region);
|
|
1455
1455
|
}
|
|
1456
|
-
return
|
|
1457
|
-
},
|
|
1458
|
-
|
|
1459
|
-
},
|
|
1460
|
-
if (e == null || e === "") throw new
|
|
1456
|
+
return ji = e, e;
|
|
1457
|
+
}, Ni = () => ji, Pi = () => {
|
|
1458
|
+
ji = void 0;
|
|
1459
|
+
}, Fi = (e, t) => {
|
|
1460
|
+
if (e == null || e === "") throw new ki("residency is on but the request has no resolvable tenant — refusing to bind a store");
|
|
1461
1461
|
let n = t.homes.find((t) => t.tenantId === e);
|
|
1462
|
-
if (n === void 0) throw new
|
|
1462
|
+
if (n === void 0) throw new ki(`no residency home is mapped for tenant '${e}' — refusing to fall back to a default store (would be a residency violation)`);
|
|
1463
1463
|
return n;
|
|
1464
|
-
},
|
|
1465
|
-
let n =
|
|
1464
|
+
}, Ii = (e, t) => t.servableRegions.includes(e), Li = (e, t) => {
|
|
1465
|
+
let n = Fi(e.tenantId, t), r = dn(n.tenantId);
|
|
1466
1466
|
return {
|
|
1467
1467
|
region: n.region,
|
|
1468
1468
|
namespace: r,
|
|
1469
1469
|
...n.connectionKey === void 0 ? {} : { connectionKey: n.connectionKey }
|
|
1470
1470
|
};
|
|
1471
|
-
},
|
|
1472
|
-
let r =
|
|
1473
|
-
if (!
|
|
1471
|
+
}, Ri = (e, t, n) => {
|
|
1472
|
+
let r = Li(e, t);
|
|
1473
|
+
if (!Ii(r.region, t)) throw new Ai(r.region, `tenant homed in region '${r.region}', which this deployment does not serve — route to the home region`);
|
|
1474
1474
|
let i = n.get(r.region);
|
|
1475
|
-
if (i === void 0) throw new
|
|
1475
|
+
if (i === void 0) throw new Ai(r.region, `no store handle for home region '${r.region}' (declared servable but not wired) — failing closed`);
|
|
1476
1476
|
return {
|
|
1477
1477
|
store: i,
|
|
1478
1478
|
placement: r
|
|
1479
1479
|
};
|
|
1480
|
-
},
|
|
1481
|
-
let { store: i, placement: a } =
|
|
1480
|
+
}, zi = async (e, t, n, r) => {
|
|
1481
|
+
let { store: i, placement: a } = Ri(e, t, n);
|
|
1482
1482
|
return await r(i, a), a;
|
|
1483
1483
|
}, Z = (e) => {
|
|
1484
1484
|
if (typeof e == "string") return e;
|
|
@@ -1487,21 +1487,21 @@ var ot = (e) => e === "mysql" || e === "mariadb" || e === "mssql" || e === "sqli
|
|
|
1487
1487
|
return `(json:${t}->${n.join(".")}${r ? "::num" : ""})`;
|
|
1488
1488
|
}
|
|
1489
1489
|
return `(${e.expr})`;
|
|
1490
|
-
}, Q = (e) => e.map(Z),
|
|
1490
|
+
}, Q = (e) => e.map(Z), Bi = (e, t) => {
|
|
1491
1491
|
if (e.length !== t.length) return !1;
|
|
1492
1492
|
for (let n = 0; n < e.length; n++) if (Z(e[n]) !== Z(t[n])) return !1;
|
|
1493
1493
|
return !0;
|
|
1494
|
-
},
|
|
1494
|
+
}, Vi = (e, t) => {
|
|
1495
1495
|
if (e.length >= t.length) return !1;
|
|
1496
1496
|
for (let n = 0; n < e.length; n++) if (Z(e[n]) !== Z(t[n])) return !1;
|
|
1497
1497
|
return !0;
|
|
1498
|
-
},
|
|
1498
|
+
}, Hi = (e) => {
|
|
1499
1499
|
let t = [], n = e.appliedIndexes, r = e.tableName;
|
|
1500
1500
|
for (let e = 0; e < n.length; e++) {
|
|
1501
1501
|
let i = n[e];
|
|
1502
1502
|
for (let a = e + 1; a < n.length; a++) {
|
|
1503
1503
|
let e = n[a];
|
|
1504
|
-
if (
|
|
1504
|
+
if (Bi(i.fields, e.fields)) {
|
|
1505
1505
|
let [n, a] = i.name < e.name ? [i, e] : [e, i];
|
|
1506
1506
|
t.push({
|
|
1507
1507
|
kind: "duplicate-fields",
|
|
@@ -1512,13 +1512,13 @@ var ot = (e) => e === "mysql" || e === "mariadb" || e === "mssql" || e === "sqli
|
|
|
1512
1512
|
});
|
|
1513
1513
|
continue;
|
|
1514
1514
|
}
|
|
1515
|
-
|
|
1515
|
+
Vi(i.fields, e.fields) ? t.push({
|
|
1516
1516
|
kind: "redundant-prefix",
|
|
1517
1517
|
table: r,
|
|
1518
1518
|
redundant: i,
|
|
1519
1519
|
coveredBy: e,
|
|
1520
1520
|
message: `'${r}' index '${i.name}' on [${Q(i.fields).join(", ")}] is a leading prefix of '${e.name}' on [${Q(e.fields).join(", ")}]. Every B-tree dialect we support (Postgres / MySQL / MariaDB / MSSQL / SQLite) can serve a [${Q(i.fields).join(", ")}] query from '${e.name}' too via the leading-prefix rule, so '${i.name}' adds write cost without read benefit. Drop '${i.name}' — unless you specifically need a smaller index for cache locality on a write-heavy table (rare; profile first).`
|
|
1521
|
-
}) :
|
|
1521
|
+
}) : Vi(e.fields, i.fields) && t.push({
|
|
1522
1522
|
kind: "redundant-prefix",
|
|
1523
1523
|
table: r,
|
|
1524
1524
|
redundant: e,
|
|
@@ -1528,23 +1528,23 @@ var ot = (e) => e === "mysql" || e === "mariadb" || e === "mssql" || e === "sqli
|
|
|
1528
1528
|
}
|
|
1529
1529
|
}
|
|
1530
1530
|
return t;
|
|
1531
|
-
},
|
|
1531
|
+
}, Ui = (e) => {
|
|
1532
1532
|
let t = [];
|
|
1533
|
-
for (let n of e) t.push(...
|
|
1533
|
+
for (let n of e) t.push(...Hi(n));
|
|
1534
1534
|
return t;
|
|
1535
|
-
},
|
|
1536
|
-
let n = t.color ?? !0, r = t.indent ?? " ", i = (e) => $(n,
|
|
1535
|
+
}, Wi = "\x1B[", Gi = `${Wi}38;2;245;158;11m`, Ki = `${Wi}38;2;16;185;129m`, qi = (e, t) => `${e}${t}${j.reset}`, $ = (e, t, n) => e ? typeof t == "function" ? t(n) : qi(t, n) : n, Ji = (e, t = {}) => {
|
|
1536
|
+
let n = t.color ?? !0, r = t.indent ?? " ", i = (e) => $(n, j.dim, e.padEnd(11)), a = (e) => $(n, (e) => j.bold(j.brand(e)), e), o = (e) => $(n, j.brightRed24, e), s = (e) => $(n, Ki, e), c = (e) => $(n, Gi, e), l = (e) => $(n, j.dim, e), u = `${c("index audit")} ${l("·")} ${$(n, j.bold, e.kind)}`, d = e.redundant.fields.length, f = Q(e.coveredBy.fields.slice(d)), p = (e, t) => {
|
|
1537
1537
|
let n = e.slice(0, t), r = e.slice(t), i = [];
|
|
1538
1538
|
return n.length > 0 && i.push(s(`[${n.join(", ")}]`)), r.length > 0 && i.push(c(`+ [${r.join(", ")}]`)), i.join(" ");
|
|
1539
1539
|
}, m = [];
|
|
1540
|
-
return m.push(u), m.push(""), m.push(`${i("table")}${a(e.table)}`), m.push(""), m.push(`${i("redundant")}${o(e.redundant.name)}`), m.push(`${i("")}${p(Q(e.redundant.fields), d)}`), m.push(""), m.push(`${i("covered by")}${s(e.coveredBy.name)}`), m.push(`${i("")}${p(Q(e.coveredBy.fields), d)}`), f.length > 0 && m.push(`${i("")}${l(`└ extra columns: ${f.join(", ")}`)}`), m.push(""), e.kind === "redundant-prefix" ? (m.push(`${i("why")}B-tree indexes serve queries that filter on a LEADING PREFIX of`), m.push(`${i("")}their column list. The wider index already covers every`), m.push(`${i("")}query the narrower one can serve.`), m.push(`${i("")}${l("Same rule on Postgres / MySQL / MariaDB / MSSQL / SQLite.")}`)) : (m.push(`${i("why")}Two indexes on the same columns under different names.`), m.push(`${i("")}The B-tree engine builds both — same coverage, double cost.`), m.push(`${i("")}${l("Same rule on Postgres / MySQL / MariaDB / MSSQL / SQLite.")}`)), m.push(""), m.push(`${i("cost")}Every ${a("INSERT")} / ${a("UPDATE")} / ${a("DELETE")} on this table writes`), m.push(`${i("")}to ${$(n,
|
|
1541
|
-
},
|
|
1540
|
+
return m.push(u), m.push(""), m.push(`${i("table")}${a(e.table)}`), m.push(""), m.push(`${i("redundant")}${o(e.redundant.name)}`), m.push(`${i("")}${p(Q(e.redundant.fields), d)}`), m.push(""), m.push(`${i("covered by")}${s(e.coveredBy.name)}`), m.push(`${i("")}${p(Q(e.coveredBy.fields), d)}`), f.length > 0 && m.push(`${i("")}${l(`└ extra columns: ${f.join(", ")}`)}`), m.push(""), e.kind === "redundant-prefix" ? (m.push(`${i("why")}B-tree indexes serve queries that filter on a LEADING PREFIX of`), m.push(`${i("")}their column list. The wider index already covers every`), m.push(`${i("")}query the narrower one can serve.`), m.push(`${i("")}${l("Same rule on Postgres / MySQL / MariaDB / MSSQL / SQLite.")}`)) : (m.push(`${i("why")}Two indexes on the same columns under different names.`), m.push(`${i("")}The B-tree engine builds both — same coverage, double cost.`), m.push(`${i("")}${l("Same rule on Postgres / MySQL / MariaDB / MSSQL / SQLite.")}`)), m.push(""), m.push(`${i("cost")}Every ${a("INSERT")} / ${a("UPDATE")} / ${a("DELETE")} on this table writes`), m.push(`${i("")}to ${$(n, j.bold, "both")} B-trees. Pure write overhead, zero read benefit.`), m.push(""), m.push(`${i("fix")}Drop ${o(e.redundant.name)}`), m.push(`${i("")}${l("Keep only if profiling shows the smaller index gives a")}`), m.push(`${i("")}${l("measurable cache-locality boost on a write-heavy hot path.")}`), m.push(`${i("")}${l("Silence with VOLTRO_INDEX_AUDIT=off if intentional.")}`), m.map((e) => `${r}${e}`).join("\n");
|
|
1541
|
+
}, Yi = (e, t) => ({
|
|
1542
1542
|
name: e,
|
|
1543
1543
|
body: t
|
|
1544
|
-
}),
|
|
1544
|
+
}), Xi = (e) => {
|
|
1545
1545
|
if (e.lifecycle === "cron" && !e.cron) throw Error(`seed "${e.id}": lifecycle 'cron' requires a 'cron' field`);
|
|
1546
1546
|
if (e.lifecycle === "onSchemaChange" && (!e.watchedTables || e.watchedTables.length === 0)) throw Error(`seed "${e.id}": lifecycle 'onSchemaChange' requires at least one entry in 'watchedTables'`);
|
|
1547
|
-
let t = e.steps({ step:
|
|
1547
|
+
let t = e.steps({ step: Yi });
|
|
1548
1548
|
if (t.length === 0) throw Error(`seed "${e.id}": at least one step is required`);
|
|
1549
1549
|
return {
|
|
1550
1550
|
__seed: !0,
|
|
@@ -1556,13 +1556,13 @@ var ot = (e) => e === "mysql" || e === "mariadb" || e === "mssql" || e === "sqli
|
|
|
1556
1556
|
...e.fingerprint === void 0 ? {} : { fingerprint: e.fingerprint },
|
|
1557
1557
|
steps: t
|
|
1558
1558
|
};
|
|
1559
|
-
},
|
|
1559
|
+
}, Zi = (e) => typeof e == "object" && !!e && "__seed" in e && e.__seed === !0, Qi = (e, { apply: t, undo: n }) => ({
|
|
1560
1560
|
name: e,
|
|
1561
1561
|
apply: t,
|
|
1562
1562
|
undo: n
|
|
1563
|
-
}),
|
|
1563
|
+
}), $i = (e) => {
|
|
1564
1564
|
if (!/^\d{14}_/.test(e.id)) throw Error(`migration "${e.id}": id must start with a 14-digit timestamp followed by "_" (convention: <YYYYMMDDHHMMSS>_<slug>)`);
|
|
1565
|
-
let t = e.steps({ step:
|
|
1565
|
+
let t = e.steps({ step: Qi });
|
|
1566
1566
|
if (t.length === 0) throw Error(`migration "${e.id}": at least one step is required`);
|
|
1567
1567
|
return {
|
|
1568
1568
|
__migration: !0,
|
|
@@ -1570,111 +1570,111 @@ var ot = (e) => e === "mysql" || e === "mariadb" || e === "mssql" || e === "sqli
|
|
|
1570
1570
|
name: e.name,
|
|
1571
1571
|
steps: t
|
|
1572
1572
|
};
|
|
1573
|
-
},
|
|
1574
|
-
id:
|
|
1575
|
-
name:
|
|
1576
|
-
hash:
|
|
1577
|
-
status:
|
|
1578
|
-
appliedAt:
|
|
1579
|
-
durationMs:
|
|
1580
|
-
errorMessage:
|
|
1581
|
-
errorStack:
|
|
1582
|
-
workflowRunId:
|
|
1583
|
-
createdAt:
|
|
1584
|
-
updatedAt:
|
|
1585
|
-
}).index(["status"]).reactive(),
|
|
1586
|
-
id:
|
|
1587
|
-
name:
|
|
1588
|
-
lifecycle:
|
|
1589
|
-
fingerprint:
|
|
1590
|
-
cronSchedule:
|
|
1591
|
-
watchedTables:
|
|
1592
|
-
nextRunAt:
|
|
1593
|
-
lastRunStatus:
|
|
1594
|
-
lastRunAt:
|
|
1595
|
-
lastRunDurationMs:
|
|
1596
|
-
lastRunRowsTouched:
|
|
1597
|
-
lastError:
|
|
1598
|
-
workflowRunId:
|
|
1599
|
-
createdAt:
|
|
1600
|
-
updatedAt:
|
|
1601
|
-
}).index(["lifecycle"]).index(["nextRunAt"]).reactive(),
|
|
1602
|
-
id:
|
|
1603
|
-
fingerprint:
|
|
1604
|
-
operations:
|
|
1605
|
-
rollbackPlan:
|
|
1606
|
-
appliedBy:
|
|
1607
|
-
environment:
|
|
1608
|
-
source:
|
|
1609
|
-
onlineStrategy:
|
|
1610
|
-
durationMs:
|
|
1611
|
-
notes:
|
|
1612
|
-
squashedAt:
|
|
1613
|
-
appliedAt:
|
|
1614
|
-
createdAt:
|
|
1615
|
-
updatedAt:
|
|
1616
|
-
}).index(["fingerprint"]).index(["environment"]).reactive(),
|
|
1617
|
-
id:
|
|
1618
|
-
scope:
|
|
1619
|
-
key:
|
|
1620
|
-
status:
|
|
1621
|
-
response:
|
|
1622
|
-
createdAt:
|
|
1623
|
-
}).unique(["scope", "key"]).index(["createdAt"]).reactive(),
|
|
1624
|
-
id:
|
|
1625
|
-
key:
|
|
1626
|
-
value:
|
|
1627
|
-
expiresAt:
|
|
1628
|
-
createdAt:
|
|
1629
|
-
updatedAt:
|
|
1630
|
-
}).index(["expiresAt"]).reactive(),
|
|
1631
|
-
id:
|
|
1632
|
-
tenantId:
|
|
1633
|
-
name:
|
|
1634
|
-
hashedKey:
|
|
1635
|
-
keyPrefix:
|
|
1636
|
-
scopes:
|
|
1637
|
-
lastUsedAt:
|
|
1638
|
-
expiresAt:
|
|
1639
|
-
revokedAt:
|
|
1640
|
-
createdBy:
|
|
1641
|
-
createdAt:
|
|
1642
|
-
}).index("byTenant", ["tenantId"]).reactive(),
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
],
|
|
1573
|
+
}, ea = (e) => typeof e == "object" && !!e && "__migration" in e && e.__migration === !0, ta = w("_voltro_migrations", {
|
|
1574
|
+
id: O({ prefix: "mig" }),
|
|
1575
|
+
name: y(),
|
|
1576
|
+
hash: y(),
|
|
1577
|
+
status: y(),
|
|
1578
|
+
appliedAt: D().nullable(),
|
|
1579
|
+
durationMs: T().nullable(),
|
|
1580
|
+
errorMessage: y().nullable(),
|
|
1581
|
+
errorStack: y().nullable(),
|
|
1582
|
+
workflowRunId: y().nullable(),
|
|
1583
|
+
createdAt: D().default("now"),
|
|
1584
|
+
updatedAt: D().default("now").onUpdate("now")
|
|
1585
|
+
}).index(["status"]).reactive(), na = w("_voltro_seeds", {
|
|
1586
|
+
id: O({ prefix: "seed" }),
|
|
1587
|
+
name: y(),
|
|
1588
|
+
lifecycle: y(),
|
|
1589
|
+
fingerprint: y(),
|
|
1590
|
+
cronSchedule: y().nullable(),
|
|
1591
|
+
watchedTables: C().nullable(),
|
|
1592
|
+
nextRunAt: D().nullable(),
|
|
1593
|
+
lastRunStatus: y().nullable(),
|
|
1594
|
+
lastRunAt: D().nullable(),
|
|
1595
|
+
lastRunDurationMs: T().nullable(),
|
|
1596
|
+
lastRunRowsTouched: T().nullable(),
|
|
1597
|
+
lastError: y().nullable(),
|
|
1598
|
+
workflowRunId: y().nullable(),
|
|
1599
|
+
createdAt: D().default("now"),
|
|
1600
|
+
updatedAt: D().default("now").onUpdate("now")
|
|
1601
|
+
}).index(["lifecycle"]).index(["nextRunAt"]).reactive(), ra = w("_voltro_migration_plans", {
|
|
1602
|
+
id: O({ prefix: "plan" }),
|
|
1603
|
+
fingerprint: y(),
|
|
1604
|
+
operations: C(),
|
|
1605
|
+
rollbackPlan: C().nullable(),
|
|
1606
|
+
appliedBy: y(),
|
|
1607
|
+
environment: y(),
|
|
1608
|
+
source: y(),
|
|
1609
|
+
onlineStrategy: y().nullable(),
|
|
1610
|
+
durationMs: T(),
|
|
1611
|
+
notes: y().nullable(),
|
|
1612
|
+
squashedAt: D().nullable(),
|
|
1613
|
+
appliedAt: D().default("now"),
|
|
1614
|
+
createdAt: D().default("now"),
|
|
1615
|
+
updatedAt: D().default("now").onUpdate("now")
|
|
1616
|
+
}).index(["fingerprint"]).index(["environment"]).reactive(), ia = w("_voltro_idempotency", {
|
|
1617
|
+
id: O({ prefix: "idem" }),
|
|
1618
|
+
scope: y(),
|
|
1619
|
+
key: y(),
|
|
1620
|
+
status: y(),
|
|
1621
|
+
response: C().nullable(),
|
|
1622
|
+
createdAt: D().default("now")
|
|
1623
|
+
}).unique(["scope", "key"]).index(["createdAt"]).reactive(), aa = w("_voltro_kv", {
|
|
1624
|
+
id: O({ prefix: "kv" }),
|
|
1625
|
+
key: y().unique(),
|
|
1626
|
+
value: y().nullable(),
|
|
1627
|
+
expiresAt: D().nullable(),
|
|
1628
|
+
createdAt: D().default("now"),
|
|
1629
|
+
updatedAt: D().default("now").onUpdate("now")
|
|
1630
|
+
}).index(["expiresAt"]).reactive(), oa = w("_voltro_api_keys", {
|
|
1631
|
+
id: O({ prefix: "apikey" }),
|
|
1632
|
+
tenantId: y().nullable(),
|
|
1633
|
+
name: y(),
|
|
1634
|
+
hashedKey: y().unique(),
|
|
1635
|
+
keyPrefix: y(),
|
|
1636
|
+
scopes: C().nullable(),
|
|
1637
|
+
lastUsedAt: D().nullable(),
|
|
1638
|
+
expiresAt: D().nullable(),
|
|
1639
|
+
revokedAt: D().nullable(),
|
|
1640
|
+
createdBy: y().nullable(),
|
|
1641
|
+
createdAt: D().default("now")
|
|
1642
|
+
}).index("byTenant", ["tenantId"]).reactive(), sa = [
|
|
1643
|
+
ta,
|
|
1644
|
+
na,
|
|
1645
|
+
ra
|
|
1646
|
+
], ca = (e, t, n) => ({
|
|
1647
1647
|
_tag: "PrimaryKeyConflictError",
|
|
1648
1648
|
table: e,
|
|
1649
1649
|
key: t,
|
|
1650
1650
|
cause: n
|
|
1651
|
-
}),
|
|
1651
|
+
}), la = (e) => typeof e == "object" && !!e && e._tag === "PrimaryKeyConflictError", ua = /* @__PURE__ */ new Map(), da = (e) => {
|
|
1652
1652
|
if (!e.table || !e.timeColumn) throw Error("registerRetention: table + timeColumn are required");
|
|
1653
1653
|
if (!Number.isFinite(e.ttlMs) || e.ttlMs <= 0) throw Error(`registerRetention(${e.table}): ttlMs must be a positive number`);
|
|
1654
|
-
|
|
1655
|
-
},
|
|
1654
|
+
ua.set(e.table, e);
|
|
1655
|
+
}, fa = () => [...ua.values()], pa = () => ua.clear(), ma = async (e, t, n, r = 2e4) => {
|
|
1656
1656
|
let i = new Date(t - e.ttlMs), a = 0;
|
|
1657
1657
|
for (;;) {
|
|
1658
1658
|
let t = await n(e.table, e.timeColumn, i, r, e.where);
|
|
1659
1659
|
if (a += t, t < r) break;
|
|
1660
1660
|
}
|
|
1661
1661
|
return a;
|
|
1662
|
-
},
|
|
1662
|
+
}, ha = (e, t) => {
|
|
1663
1663
|
let n = Number(e ?? String(t));
|
|
1664
1664
|
return (Number.isFinite(n) && n > 0 ? n : t) * 36e5;
|
|
1665
|
-
},
|
|
1666
|
-
id:
|
|
1667
|
-
replicaId:
|
|
1668
|
-
streamName:
|
|
1669
|
-
binlogFile:
|
|
1670
|
-
binlogPosition:
|
|
1671
|
-
updatedAt:
|
|
1672
|
-
}).index(["replicaId"]),
|
|
1673
|
-
id:
|
|
1674
|
-
replicaId:
|
|
1675
|
-
streamName:
|
|
1676
|
-
ctVersion:
|
|
1677
|
-
updatedAt:
|
|
1678
|
-
}).index(["replicaId"]),
|
|
1665
|
+
}, ga = "_voltro_cdc_offsets", _a = w(ga, {
|
|
1666
|
+
id: O({ prefix: "cdcoff" }),
|
|
1667
|
+
replicaId: y(),
|
|
1668
|
+
streamName: y(),
|
|
1669
|
+
binlogFile: y(),
|
|
1670
|
+
binlogPosition: y(),
|
|
1671
|
+
updatedAt: D()
|
|
1672
|
+
}).index(["replicaId"]), va = w(ga, {
|
|
1673
|
+
id: O({ prefix: "cdcoff" }),
|
|
1674
|
+
replicaId: y(),
|
|
1675
|
+
streamName: y(),
|
|
1676
|
+
ctVersion: y(),
|
|
1677
|
+
updatedAt: D()
|
|
1678
|
+
}).index(["replicaId"]), ya = "postgres";
|
|
1679
1679
|
//#endregion
|
|
1680
|
-
export { Y as BranchNameInvalid,
|
|
1680
|
+
export { Y as BranchNameInvalid, mi as BranchTransitionInvalid, ga as CDC_OFFSETS_TABLE, he as ColumnBuilder, lt as ENCRYPTED_PREFIX, ya as ENGINE, qt as EagerCardinalityError, Ue as FILE_MIGRATION_PATTERN, ce as MAX_IDENTIFIER_LENGTH, ni as TableStreamError, sn as TenantNamespaceInvalid, on as TenantNamespaceUnresolved, Ai as TenantRegionUnavailable, ki as TenantResidencyUnresolved, x as WARN_IDENTIFIER_LENGTH, oa as _voltroApiKeysTable, _a as _voltroCdcOffsetsTable, ia as _voltroIdempotencyTable, aa as _voltroKvTable, ra as _voltroMigrationPlansTable, ta as _voltroMigrationsTable, va as _voltroMssqlCdcOffsetsTable, na as _voltroSeedsTable, Dr as actorsTable, Di as admitBranch, Te as allEnumRenames, It as allRegisteredRelations, ee as allRegisteredTables, Ur as and, ke as array, Lr as arrayContains, zr as arrayHas, Rr as arrayOverlaps, Yt as attachEagerLoads, Ui as auditAllTableIndexes, Hi as auditTableIndexes, Oe as avg, Ge as avgOver, Ke as bigint, Ri as bindResidentStore, _e as boolean, di as branchNamespaceName, be as bytes, fe as clearEnumRenames, Rt as clearRelationsRegistry, Pi as clearResidencyConfig, pa as clearRetentions, _ as clearTableRegistry, ei as collectSubqueries, ge as column, gt as columnSchema, Tn as compileEagerJson, L as compilePredicate, pn as compileRawFragment, R as compileSelect, si as computeEmbedding, Ir as contains, ye as count, Ie as countDistinct, Ae as databaseHandle, Le as date, je as dbEnum, we as decimal, Fe as declareEnumRename, Wt as decodeRowsFromSchema, pt as decryptFieldsOnRead, $i as defineMigration, ie as defineMixin, Xi as defineSeed, Ce as denseRank, h as deriveTypeIdPrefix, ct as deserializeArraysOnRead, e as drainIdentifierWarnings, Se as dropped, Kt as encodeRowForSchema, ft as encryptFieldsForWrite, dt as encryptedColumnsOf, wi as enforceBranchLimits, b as ensureTableRegistered, Or as eq, mn as escapeLike, $r as evaluatePredicate, xe as except, Xr as exists, Ji as formatIndexAuditIssue, sa as frameworkTables, Re as generateId, se as generateSnowflake, ue as geography, Je as geometry, He as getEnumRenames, Ft as getRelation, F as getRelations, Ni as getResidencyConfig, u as getTable, Ar as gt, jr as gte, an as hasEagerLoads, oi as hybridSearch, O as id, Pr as inSet, Jr as inSubquery, M as inferForeignKey, T as integer, le as intersect, Qe as interval, fi as isBranchNamespace, ut as isEncrypted, Me as isFileMigration, ea as isMigrationDefinition, vi as isNeonConnection, Vr as isNotNull, Br as isNull, la as isPrimaryKeyConflictError, Ii as isRegionServable, wt as isRelationsSpec, Zi as isSeedDefinition, te as isSqliteFamily, de as isView, C as json, Kr as jsonField, r as jsonIndex, qe as lag, $e as lead, fa as listRetentions, Mr as lt, Nr as lte, Oi as makeNamespaceBranchExecutor, Et as many, Dt as manyToMany, a as materializeFields, pe as max, ze as migration, Ze as min, ae as mixin, kr as neq, hi as nextBranchState, Gr as not, Zr as notExists, Fr as notInSet, Yr as notInSubquery, Xe as numeric, Tt as one, Jt as oneCardinalityMessage, Wr as or, S as paginateBy, i as paginateById, Si as planBranch, gi as planBranchProvision, _i as planBranchTeardown, Ci as planBranchTeardownFor, bi as planNeonBranchProvision, xi as planNeonBranchTeardown, ca as primaryKeyConflictError, Ti as provisionBranch, zi as provisionResidentTenant, fn as qualifyTable, Ye as queryFor, Pe as queryForView, et as quoteIdent, ne as rank, re as raw, l as real, s as reference, Cr as registerCoreTables, Pt as registerDiscoveredRelations, Nt as registerRelations, da as registerRetention, p as registerTable, Ct as relations, Tr as requireActors, g as requireTable, Er as requireTenants, oe as resetSnowflake, Li as residentPlacement, yi as resolveBranchMechanism, c as resolveFullTextIndex, m as resolveIdScheme, d as resolveMixinGraph, Fi as resolveTenantHome, dn as resolveTenantNamespace, ha as retentionTtlMsFromEnv, o as rowNumber, _t as rowSchema, un as sanitizeIdentifierFragment, st as serializeArraysForWrite, Mi as setResidencyConfig, Hr as spatialPredicate, ai as streamTable, v as sum, De as sumOver, ma as sweepRetention, w as table, Ei as teardownBranch, y as text, D as timestamp, mt as timestampMs, ht as timestampMsOrNull, t as union, Ee as unionAll, ve as validateColumnName, We as validateIndexName, Lt as validateRegisteredRelations, At as validateRelationConfig, Ne as validateTableName, Be as validateTypeIdPrefix, n as vector, f as vectorDistanceToOpclass, ci as vectorEmbedding, Ve as view, me as viewSql, ti as walkLeaves };
|