@voltro/database 0.8.0 → 0.10.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 +329 -7
- package/dist/index.d.ts +18 -1
- package/dist/index.js +299 -297
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
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
|
|
2
|
-
import { timestampMs as
|
|
3
|
-
import { Chunk as
|
|
4
|
-
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 _, N as v, O as y, Ot as b, P as x, Q as S, R as ee, S as C, St as w, T as te, Tt as ne, U as re, V as T, W as ie, X as ae, Y as oe, Z as se, _ as ce, _t as le, a as ue, at as de, b as fe, bt as E, c as pe, ct as me, d as he, dt as ge, et as _e, f as ve, ft as ye, g as be, gt as xe, h as Se, ht as Ce, i as D, it as we, j as Te, k as Ee, kt as O, l as De, lt as Oe, m as ke, mt as Ae, n as je, nt as Me, o as Ne, ot as Pe, p as Fe, pt as Ie, q as Le, r as Re, rt as ze, s as Be, st as Ve, t as He, tt as Ue, u as We, ut as Ge, v as Ke, vt as qe, w as Je, wt as Ye, x as Xe, xt as Ze, y as Qe, yt as k, z as $e } from "./fileBased-Cc-F1oFv.js";
|
|
2
|
+
import { timestampMs as et, timestampMsOrNull as tt } from "./wire.js";
|
|
3
|
+
import { Chunk as nt, Data as rt, Effect as it, Option as A, Schema as j, Stream as at } from "effect";
|
|
4
|
+
import { ansi as M } from "@voltro/logger";
|
|
5
5
|
//#region src/arrayCodec.ts
|
|
6
|
-
var
|
|
6
|
+
var ot = (e) => e === "mysql" || e === "mariadb" || e === "mssql" || e === "sqlite", st = (e) => {
|
|
7
7
|
let t = [];
|
|
8
8
|
for (let [n, r] of Object.entries(e.fields)) r.type === "array" && t.push(n);
|
|
9
9
|
return t;
|
|
10
|
-
},
|
|
11
|
-
if (!
|
|
12
|
-
let r =
|
|
10
|
+
}, ct = (e, t, n) => {
|
|
11
|
+
if (!ot(n) || !t) return e;
|
|
12
|
+
let r = st(t);
|
|
13
13
|
if (r.length === 0) return e;
|
|
14
14
|
let i = { ...e };
|
|
15
15
|
for (let e of r) {
|
|
@@ -17,9 +17,9 @@ var st = (e) => e === "mysql" || e === "mariadb" || e === "mssql" || e === "sqli
|
|
|
17
17
|
Array.isArray(t) && (i[e] = JSON.stringify(t));
|
|
18
18
|
}
|
|
19
19
|
return i;
|
|
20
|
-
},
|
|
21
|
-
if (!
|
|
22
|
-
let r =
|
|
20
|
+
}, lt = (e, t, n) => {
|
|
21
|
+
if (!ot(n) || !t) return e;
|
|
22
|
+
let r = st(t);
|
|
23
23
|
return r.length === 0 ? e : e.map((e) => {
|
|
24
24
|
let t;
|
|
25
25
|
for (let n of r) {
|
|
@@ -31,86 +31,86 @@ var st = (e) => e === "mysql" || e === "mariadb" || e === "mssql" || e === "sqli
|
|
|
31
31
|
}
|
|
32
32
|
return t ?? e;
|
|
33
33
|
});
|
|
34
|
-
},
|
|
34
|
+
}, ut = "enc:v1:", dt = (e) => typeof e == "string" && e.startsWith("enc:v1:"), ft = (e) => {
|
|
35
35
|
let t = [];
|
|
36
36
|
for (let [n, r] of Object.entries(e.fields)) r.encrypted === !0 && t.push(n);
|
|
37
37
|
return t;
|
|
38
|
-
},
|
|
38
|
+
}, pt = (e, t, n) => {
|
|
39
39
|
if (!t) return e;
|
|
40
|
-
let r =
|
|
40
|
+
let r = ft(t);
|
|
41
41
|
if (r.length === 0) return e;
|
|
42
42
|
let i = { ...e };
|
|
43
43
|
for (let e of r) {
|
|
44
44
|
let r = i[e];
|
|
45
|
-
if (!(r == null ||
|
|
45
|
+
if (!(r == null || dt(r))) {
|
|
46
46
|
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)`);
|
|
47
47
|
i[e] = n.encrypt(JSON.stringify(r));
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
return i;
|
|
51
|
-
},
|
|
51
|
+
}, mt = (e, t, n) => {
|
|
52
52
|
if (!t) return e;
|
|
53
|
-
let r =
|
|
53
|
+
let r = ft(t);
|
|
54
54
|
return r.length === 0 || !n ? e : e.map((e) => {
|
|
55
55
|
let t;
|
|
56
56
|
for (let i of r) {
|
|
57
57
|
let r = e[i];
|
|
58
|
-
|
|
58
|
+
dt(r) && (t ??= { ...e }, t[i] = JSON.parse(n.decrypt(r)));
|
|
59
59
|
}
|
|
60
60
|
return t ?? e;
|
|
61
61
|
});
|
|
62
|
-
},
|
|
62
|
+
}, ht = (e) => {
|
|
63
63
|
let t = (() => {
|
|
64
64
|
switch (e.type) {
|
|
65
65
|
case "id":
|
|
66
66
|
case "reference":
|
|
67
67
|
case "text":
|
|
68
|
-
case "enum": return
|
|
68
|
+
case "enum": return j.String;
|
|
69
69
|
case "integer":
|
|
70
70
|
case "real":
|
|
71
|
-
case "decimal": return
|
|
72
|
-
case "boolean": return
|
|
71
|
+
case "decimal": return j.Number;
|
|
72
|
+
case "boolean": return j.Boolean;
|
|
73
73
|
case "timestamp":
|
|
74
|
-
case "date": return
|
|
75
|
-
case "bigint": return
|
|
76
|
-
case "bytes": return
|
|
77
|
-
case "array": return
|
|
78
|
-
case "interval": return
|
|
79
|
-
default: return
|
|
74
|
+
case "date": return et;
|
|
75
|
+
case "bigint": return j.BigInt;
|
|
76
|
+
case "bytes": return j.Uint8ArrayFromSelf;
|
|
77
|
+
case "array": return j.Array(j.Unknown);
|
|
78
|
+
case "interval": return j.String;
|
|
79
|
+
default: return j.Unknown;
|
|
80
80
|
}
|
|
81
81
|
})();
|
|
82
|
-
return e.nullable === !0 ?
|
|
83
|
-
},
|
|
82
|
+
return e.nullable === !0 ? j.NullOr(t) : t;
|
|
83
|
+
}, gt = (e, t) => {
|
|
84
84
|
let n = new Set(t?.omit ?? []), r = {};
|
|
85
|
-
for (let [t, i] of Object.entries(e.fields)) n.has(t) || (r[t] =
|
|
86
|
-
return
|
|
87
|
-
},
|
|
85
|
+
for (let [t, i] of Object.entries(e.fields)) n.has(t) || (r[t] = ht(i));
|
|
86
|
+
return j.Struct(r);
|
|
87
|
+
}, N = (e) => typeof e == "function" ? e : () => e, _t = (e, t) => ({
|
|
88
88
|
kind: "one",
|
|
89
|
-
target:
|
|
89
|
+
target: N(e),
|
|
90
90
|
...t?.foreignKey === void 0 ? {} : { foreignKey: t.foreignKey },
|
|
91
91
|
...t?.sourceKey === void 0 ? {} : { sourceKey: t.sourceKey }
|
|
92
|
-
}),
|
|
92
|
+
}), vt = (e, t) => ({
|
|
93
93
|
kind: "many",
|
|
94
|
-
target:
|
|
94
|
+
target: N(e),
|
|
95
95
|
...t?.foreignKey === void 0 ? {} : { foreignKey: t.foreignKey },
|
|
96
96
|
...t?.sourceKey === void 0 ? {} : { sourceKey: t.sourceKey }
|
|
97
|
-
}),
|
|
97
|
+
}), yt = (e, t) => ({
|
|
98
98
|
kind: "manyToMany",
|
|
99
|
-
target:
|
|
100
|
-
through:
|
|
99
|
+
target: N(e),
|
|
100
|
+
through: N(t.through),
|
|
101
101
|
sourceKey: t.sourceKey,
|
|
102
102
|
targetKey: t.targetKey
|
|
103
|
-
}),
|
|
104
|
-
one:
|
|
105
|
-
many:
|
|
106
|
-
manyToMany:
|
|
107
|
-
},
|
|
103
|
+
}), bt = {
|
|
104
|
+
one: _t,
|
|
105
|
+
many: vt,
|
|
106
|
+
manyToMany: yt
|
|
107
|
+
}, xt = (e, t) => {
|
|
108
108
|
let n = typeof e == "function" ? e : () => e;
|
|
109
109
|
return {
|
|
110
110
|
source: n,
|
|
111
|
-
relations: t(
|
|
111
|
+
relations: t(bt, n())
|
|
112
112
|
};
|
|
113
|
-
},
|
|
113
|
+
}, St = (e) => {
|
|
114
114
|
if (typeof e != "object" || !e) return !1;
|
|
115
115
|
let t = e;
|
|
116
116
|
if (typeof t.source != "function" || typeof t.relations != "object" || t.relations === null) return !1;
|
|
@@ -119,64 +119,64 @@ var st = (e) => e === "mysql" || e === "mariadb" || e === "mssql" || e === "sqli
|
|
|
119
119
|
let t = e?.kind;
|
|
120
120
|
return t === "one" || t === "many" || t === "manyToMany";
|
|
121
121
|
});
|
|
122
|
-
},
|
|
122
|
+
}, Ct = _t, wt = vt, Tt = yt, P = (e, t, n) => {
|
|
123
123
|
let r = [];
|
|
124
124
|
for (let [n, i] of Object.entries(e.fields)) i.type === "reference" && i.references?.()?.tableName === t && r.push(n);
|
|
125
125
|
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>' }.`);
|
|
126
126
|
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.`);
|
|
127
127
|
return r[0];
|
|
128
|
-
},
|
|
129
|
-
let t =
|
|
128
|
+
}, Et = (e) => Object.keys(e.fields), F = (e, t) => Object.prototype.hasOwnProperty.call(e.fields, t), Dt = (e) => {
|
|
129
|
+
let t = Et(e);
|
|
130
130
|
return t.length === 0 ? "<none>" : t.join(", ");
|
|
131
|
-
},
|
|
131
|
+
}, Ot = (e, t, n) => {
|
|
132
132
|
let r = `relation '${t}' on '${e.tableName}'`, i = n.target();
|
|
133
133
|
if (n.kind === "manyToMany") {
|
|
134
134
|
let t = n.through();
|
|
135
|
-
for (let [a, o] of [["sourceKey", n.sourceKey], ["targetKey", n.targetKey]]) if (!
|
|
135
|
+
for (let [a, o] of [["sourceKey", n.sourceKey], ["targetKey", n.targetKey]]) if (!F(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}': ${Dt(t)}.`);
|
|
136
136
|
return;
|
|
137
137
|
}
|
|
138
138
|
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.`);
|
|
139
|
-
if (n.sourceKey !== void 0 && !
|
|
140
|
-
let t =
|
|
141
|
-
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}': ${
|
|
139
|
+
if (n.sourceKey !== void 0 && !F(e, n.sourceKey)) {
|
|
140
|
+
let t = F(i, n.sourceKey);
|
|
141
|
+
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}': ${Dt(e)}.`));
|
|
142
142
|
}
|
|
143
|
-
if (n.foreignKey !== void 0 && !
|
|
144
|
-
let t =
|
|
145
|
-
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}': ${
|
|
143
|
+
if (n.foreignKey !== void 0 && !F(i, n.foreignKey)) {
|
|
144
|
+
let t = F(e, n.foreignKey);
|
|
145
|
+
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}': ${Dt(i)}.`));
|
|
146
146
|
}
|
|
147
|
-
},
|
|
148
|
-
let t = e.source(), n =
|
|
147
|
+
}, kt = Symbol.for("@voltro/database/relationsRegistry"), At = globalThis, I = At[kt] ?? (At[kt] = /* @__PURE__ */ new Map()), jt = (e) => {
|
|
148
|
+
let t = e.source(), n = I.get(t.tableName);
|
|
149
149
|
if (n === void 0) {
|
|
150
|
-
|
|
150
|
+
I.set(t.tableName, new Map(Object.entries(e.relations)));
|
|
151
151
|
return;
|
|
152
152
|
}
|
|
153
153
|
for (let [r, i] of Object.entries(e.relations)) {
|
|
154
154
|
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.`);
|
|
155
155
|
n.set(r, i);
|
|
156
156
|
}
|
|
157
|
-
},
|
|
157
|
+
}, Mt = (e) => {
|
|
158
158
|
let t = 0;
|
|
159
|
-
for (let n of Object.values(e))
|
|
159
|
+
for (let n of Object.values(e)) St(n) && (jt(n), t += 1);
|
|
160
160
|
return t;
|
|
161
|
-
},
|
|
162
|
-
let t =
|
|
161
|
+
}, Nt = (e) => {
|
|
162
|
+
let t = I.get(e);
|
|
163
163
|
if (t !== void 0) return Object.fromEntries(t);
|
|
164
|
-
},
|
|
164
|
+
}, Pt = (e, t) => I.get(e)?.get(t), Ft = () => {
|
|
165
165
|
let e = [];
|
|
166
|
-
for (let [t, n] of
|
|
166
|
+
for (let [t, n] of I) for (let [r, i] of n) e.push({
|
|
167
167
|
source: t,
|
|
168
168
|
name: r,
|
|
169
169
|
relation: i
|
|
170
170
|
});
|
|
171
171
|
return e;
|
|
172
|
-
},
|
|
173
|
-
for (let [e, t] of
|
|
172
|
+
}, It = () => {
|
|
173
|
+
for (let [e, t] of I) {
|
|
174
174
|
let n = u(e);
|
|
175
|
-
if (n !== void 0) for (let [e, r] of t)
|
|
175
|
+
if (n !== void 0) for (let [e, r] of t) Ot(n, e, r);
|
|
176
176
|
}
|
|
177
|
-
},
|
|
178
|
-
|
|
179
|
-
},
|
|
177
|
+
}, Lt = () => {
|
|
178
|
+
I.clear();
|
|
179
|
+
}, Rt = (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, zt = (e) => {
|
|
180
180
|
if (e == null || typeof e != "string") return e;
|
|
181
181
|
let t = e.trim();
|
|
182
182
|
if (t.length === 0) return e;
|
|
@@ -187,7 +187,7 @@ var st = (e) => e === "mysql" || e === "mariadb" || e === "mssql" || e === "sqli
|
|
|
187
187
|
} catch {
|
|
188
188
|
return e;
|
|
189
189
|
}
|
|
190
|
-
},
|
|
190
|
+
}, Bt = (e) => e == null || typeof e == "string" ? e : typeof e == "number" || typeof e == "bigint" ? String(e) : e, Vt = (e) => {
|
|
191
191
|
if (e == null || e instanceof Date) return e;
|
|
192
192
|
if (typeof e == "string") {
|
|
193
193
|
let t = new Date(e);
|
|
@@ -198,19 +198,19 @@ var st = (e) => e === "mysql" || e === "mariadb" || e === "mssql" || e === "sqli
|
|
|
198
198
|
return isNaN(t.getTime()) ? e : t;
|
|
199
199
|
}
|
|
200
200
|
return e;
|
|
201
|
-
},
|
|
201
|
+
}, Ht = (e, t, n) => {
|
|
202
202
|
if (e == null) return e;
|
|
203
203
|
switch (t) {
|
|
204
|
-
case "boolean": return n === "postgres" ? e :
|
|
204
|
+
case "boolean": return n === "postgres" ? e : Rt(e);
|
|
205
205
|
case "json":
|
|
206
|
-
case "array": return n === "postgres" ? e :
|
|
206
|
+
case "array": return n === "postgres" ? e : zt(e);
|
|
207
207
|
case "timestamp":
|
|
208
|
-
case "date": return n === "sqlite" || n === "turso" ?
|
|
208
|
+
case "date": return n === "sqlite" || n === "turso" ? Vt(e) : e;
|
|
209
209
|
case "decimal":
|
|
210
|
-
case "bigint": return
|
|
210
|
+
case "bigint": return Bt(e);
|
|
211
211
|
default: return e;
|
|
212
212
|
}
|
|
213
|
-
},
|
|
213
|
+
}, Ut = (e, t, n) => {
|
|
214
214
|
if (e.length === 0) return e;
|
|
215
215
|
let r = u(t);
|
|
216
216
|
if (r === void 0) return e;
|
|
@@ -221,36 +221,36 @@ var st = (e) => e === "mysql" || e === "mariadb" || e === "mssql" || e === "sqli
|
|
|
221
221
|
});
|
|
222
222
|
return e.map((e) => {
|
|
223
223
|
let t = { ...e };
|
|
224
|
-
for (let { key: e, type: r } of a) e in t && (t[e] =
|
|
224
|
+
for (let { key: e, type: r } of a) e in t && (t[e] = Ht(t[e], r, n));
|
|
225
225
|
return t;
|
|
226
226
|
});
|
|
227
|
-
},
|
|
227
|
+
}, Wt = (e, t) => {
|
|
228
228
|
if (e == null) return e;
|
|
229
229
|
switch (t) {
|
|
230
230
|
case "json":
|
|
231
231
|
case "array": return typeof e == "string" ? e : JSON.stringify(e);
|
|
232
232
|
default: return e;
|
|
233
233
|
}
|
|
234
|
-
},
|
|
234
|
+
}, Gt = (e, t, n = ["json", "array"]) => {
|
|
235
235
|
let r = u(t);
|
|
236
236
|
if (r === void 0) return e;
|
|
237
237
|
let i = r.fields, a = null;
|
|
238
238
|
for (let [t, r] of Object.entries(i)) if (n.includes(r.type) && t in e) {
|
|
239
|
-
let n =
|
|
239
|
+
let n = Wt(e[t], r.type);
|
|
240
240
|
n !== e[t] && (a === null && (a = { ...e }), a[t] = n);
|
|
241
241
|
}
|
|
242
242
|
return a ?? e;
|
|
243
|
-
},
|
|
243
|
+
}, Kt = class extends Error {
|
|
244
244
|
_tag = "EagerCardinalityError";
|
|
245
245
|
constructor(e) {
|
|
246
246
|
super(e), this.name = "EagerCardinalityError";
|
|
247
247
|
}
|
|
248
|
-
},
|
|
248
|
+
}, qt = (e) => {
|
|
249
249
|
let { relationName: t, sourceTableName: n, targetTableName: r, foreignKey: i, sourceKey: a } = e, o = r === n;
|
|
250
250
|
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.");
|
|
251
|
-
},
|
|
251
|
+
}, Jt = async (e, t, n, r) => {
|
|
252
252
|
if (e.length === 0) return e;
|
|
253
|
-
let i =
|
|
253
|
+
let i = Nt(n.tableName);
|
|
254
254
|
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?`);
|
|
255
255
|
let a = e.map((e) => ({ ...e }));
|
|
256
256
|
for (let [e, o] of Object.entries(t)) {
|
|
@@ -259,36 +259,36 @@ var st = (e) => e === "mysql" || e === "mariadb" || e === "mssql" || e === "sqli
|
|
|
259
259
|
let t = Object.keys(i).join(", ") || "<none>";
|
|
260
260
|
throw Error(`unknown relation '${e}' on '${n.tableName}'. Registered relations: ${t}.`);
|
|
261
261
|
}
|
|
262
|
-
|
|
262
|
+
Ot(n, e, t), await Yt(a, e, t, o === !0 ? {} : o, n, r);
|
|
263
263
|
}
|
|
264
264
|
return a;
|
|
265
|
-
},
|
|
265
|
+
}, Yt = async (e, t, n, r, i, a) => {
|
|
266
266
|
switch (n.kind) {
|
|
267
267
|
case "one":
|
|
268
|
-
await
|
|
268
|
+
await Xt(e, t, n, r, i, a);
|
|
269
269
|
return;
|
|
270
270
|
case "many":
|
|
271
|
-
await
|
|
271
|
+
await Zt(e, t, n, r, i, a);
|
|
272
272
|
return;
|
|
273
273
|
case "manyToMany":
|
|
274
|
-
await
|
|
274
|
+
await $t(e, t, n, r, i, a);
|
|
275
275
|
return;
|
|
276
276
|
}
|
|
277
|
-
},
|
|
278
|
-
let o = n.target(), s = n.sourceKey ??
|
|
277
|
+
}, Xt = async (e, t, n, r, i, a) => {
|
|
278
|
+
let o = n.target(), s = n.sourceKey ?? en(i, o.tableName);
|
|
279
279
|
if (s !== void 0) {
|
|
280
|
-
let n =
|
|
280
|
+
let n = L(e, s), i = n.length === 0 ? [] : await tn(o, "id", n, r, a), c = new Map(i.map((e) => [e.id, e]));
|
|
281
281
|
for (let n of e) {
|
|
282
282
|
let e = n[s];
|
|
283
283
|
n[t] = e == null ? null : c.get(e) ?? null;
|
|
284
284
|
}
|
|
285
|
-
await
|
|
285
|
+
await nn(i, r.with, o, a);
|
|
286
286
|
return;
|
|
287
287
|
}
|
|
288
|
-
let c = n.foreignKey ??
|
|
288
|
+
let c = n.foreignKey ?? P(o, i.tableName, t), l = n.sourceKey ?? "id", u = L(e, l), d = u.length === 0 ? [] : await tn(o, c, u, r, a), f = /* @__PURE__ */ new Map();
|
|
289
289
|
for (let e of d) {
|
|
290
290
|
let n = e[c];
|
|
291
|
-
if (f.has(n)) throw new qt(
|
|
291
|
+
if (f.has(n)) throw new Kt(qt({
|
|
292
292
|
relationName: t,
|
|
293
293
|
sourceTableName: i.tableName,
|
|
294
294
|
targetTableName: o.tableName,
|
|
@@ -301,9 +301,9 @@ var st = (e) => e === "mysql" || e === "mariadb" || e === "mssql" || e === "sqli
|
|
|
301
301
|
let e = n[l];
|
|
302
302
|
n[t] = e == null ? null : f.get(e) ?? null;
|
|
303
303
|
}
|
|
304
|
-
await
|
|
305
|
-
},
|
|
306
|
-
let o = n.target(), s = n.foreignKey ??
|
|
304
|
+
await nn(d, r.with, o, a);
|
|
305
|
+
}, Zt = async (e, t, n, r, i, a) => {
|
|
306
|
+
let o = n.target(), s = n.foreignKey ?? P(o, i.tableName, t), c = n.sourceKey ?? "id", l = L(e, c), u = Qt(r), d = l.length === 0 ? [] : await tn(o, s, l, u, a), f = /* @__PURE__ */ new Map();
|
|
307
307
|
for (let e of d) {
|
|
308
308
|
let t = e[s], n = f.get(t);
|
|
309
309
|
n ? n.push(e) : f.set(t, [e]);
|
|
@@ -319,12 +319,12 @@ var st = (e) => e === "mysql" || e === "mariadb" || e === "mssql" || e === "sqli
|
|
|
319
319
|
let e = n[c];
|
|
320
320
|
n[t] = f.get(e) ?? [];
|
|
321
321
|
}
|
|
322
|
-
await
|
|
323
|
-
},
|
|
322
|
+
await nn(d, r.with, o, a);
|
|
323
|
+
}, Qt = (e) => {
|
|
324
324
|
let { limit: t, offset: n, ...r } = e;
|
|
325
325
|
return r;
|
|
326
|
-
},
|
|
327
|
-
let o = n.target(), s = n.through(), c =
|
|
326
|
+
}, $t = async (e, t, n, r, i, a) => {
|
|
327
|
+
let o = n.target(), s = n.through(), c = L(e, "id");
|
|
328
328
|
if (c.length === 0) {
|
|
329
329
|
for (let n of e) n[t] = [];
|
|
330
330
|
return;
|
|
@@ -345,8 +345,8 @@ var st = (e) => e === "mysql" || e === "mariadb" || e === "mssql" || e === "sqli
|
|
|
345
345
|
for (let n of e) n[t] = [];
|
|
346
346
|
return;
|
|
347
347
|
}
|
|
348
|
-
let f = await
|
|
349
|
-
await
|
|
348
|
+
let f = await tn(o, "id", L(d, n.targetKey), r, a), p = new Map(f.map((e) => [e.id, e]));
|
|
349
|
+
await nn(f, r.with, o, a);
|
|
350
350
|
let m = r.junction === void 0 ? void 0 : r.junction === !0 ? Object.keys(s.fields) : r.junction, h = /* @__PURE__ */ new Map();
|
|
351
351
|
for (let e of d) {
|
|
352
352
|
let t = e[n.sourceKey], r = e[n.targetKey], i = p.get(r);
|
|
@@ -358,16 +358,16 @@ var st = (e) => e === "mysql" || e === "mariadb" || e === "mssql" || e === "sqli
|
|
|
358
358
|
o ? o.push(a) : h.set(t, [a]);
|
|
359
359
|
}
|
|
360
360
|
for (let n of e) n[t] = h.get(n.id) ?? [];
|
|
361
|
-
},
|
|
361
|
+
}, en = (e, t) => {
|
|
362
362
|
for (let [n, r] of Object.entries(e.fields)) if (r.type === "reference" && r.references?.()?.tableName === t) return n;
|
|
363
|
-
},
|
|
363
|
+
}, L = (e, t) => {
|
|
364
364
|
let n = /* @__PURE__ */ new Set();
|
|
365
365
|
for (let r of e) {
|
|
366
366
|
let e = r[t];
|
|
367
367
|
e != null && n.add(e);
|
|
368
368
|
}
|
|
369
369
|
return [...n];
|
|
370
|
-
},
|
|
370
|
+
}, tn = (e, t, n, r, i) => {
|
|
371
371
|
let a = {
|
|
372
372
|
column: t,
|
|
373
373
|
op: "in",
|
|
@@ -381,54 +381,54 @@ var st = (e) => e === "mysql" || e === "mariadb" || e === "mssql" || e === "sqli
|
|
|
381
381
|
skip: r.offset,
|
|
382
382
|
projection: void 0
|
|
383
383
|
});
|
|
384
|
-
},
|
|
385
|
-
t !== void 0 && e.length !== 0 && (await
|
|
384
|
+
}, nn = async (e, t, n, r) => {
|
|
385
|
+
t !== void 0 && e.length !== 0 && (await Jt(e, t, n, r)).forEach((t, n) => {
|
|
386
386
|
let r = e[n];
|
|
387
387
|
for (let [e, n] of Object.entries(t)) e in r || (r[e] = n);
|
|
388
388
|
});
|
|
389
|
-
},
|
|
389
|
+
}, rn = (e) => e.eager !== void 0 && Object.keys(e.eager).length > 0, an = class extends Error {
|
|
390
390
|
_tag = "TenantNamespaceUnresolved";
|
|
391
391
|
constructor(e) {
|
|
392
392
|
super(e), this.name = "TenantNamespaceUnresolved";
|
|
393
393
|
}
|
|
394
|
-
},
|
|
394
|
+
}, on = class extends Error {
|
|
395
395
|
_tag = "TenantNamespaceInvalid";
|
|
396
396
|
constructor(e) {
|
|
397
397
|
super(e), this.name = "TenantNamespaceInvalid";
|
|
398
398
|
}
|
|
399
|
-
},
|
|
400
|
-
if (e == null || e === "") throw new
|
|
401
|
-
let t =
|
|
402
|
-
if (t.replace(/_/g, "") === "") throw new
|
|
403
|
-
let n = `${
|
|
404
|
-
if (n.length >
|
|
399
|
+
}, sn = 63, cn = "tenant_", ln = (e) => e.toLowerCase().replace(/[^a-z0-9_]/g, "_"), un = (e) => {
|
|
400
|
+
if (e == null || e === "") throw new an("namespace isolation is on but the request has no resolvable tenant (subject.tenantId is null/empty). Refusing to run against a shared/default namespace — this would be a cross-tenant read. Authenticate with a tenant-scoped subject, or disable namespace isolation for this surface.");
|
|
401
|
+
let t = ln(e);
|
|
402
|
+
if (t.replace(/_/g, "") === "") throw new on(`tenant id '${e}' has no usable identifier characters after sanitisation — cannot derive a distinct namespace.`);
|
|
403
|
+
let n = `${cn}${t}`;
|
|
404
|
+
if (n.length > sn) throw new on(`namespace '${n}' for tenant '${e}' exceeds the ${sn}-byte identifier limit. Use a shorter tenant id.`);
|
|
405
405
|
return n;
|
|
406
|
-
},
|
|
406
|
+
}, dn = (e, t) => e === null ? t : `${e}.${t}`, fn = (e, t) => {
|
|
407
407
|
let { strings: n, values: r } = e, i = t.unsafe(n[0] ?? "");
|
|
408
408
|
for (let e = 0; e < r.length; e++) i = t`${i}${r[e]}${t.unsafe(n[e + 1] ?? "")}`;
|
|
409
409
|
return t`${i}`;
|
|
410
|
-
},
|
|
411
|
-
if ("not" in e) return t`NOT (${
|
|
412
|
-
if ("and" in e) return e.and.length === 0 ? t`TRUE` : t.and(e.and.map((e) =>
|
|
413
|
-
if ("or" in e) return e.or.length === 0 ? t`FALSE` : t.or(e.or.map((e) =>
|
|
410
|
+
}, pn = (e) => e.replace(/[\\%_]/g, (e) => `\\${e}`), R = (e, t, n = null) => {
|
|
411
|
+
if ("not" in e) return t`NOT (${R(e.not, t, n)})`;
|
|
412
|
+
if ("and" in e) return e.and.length === 0 ? t`TRUE` : t.and(e.and.map((e) => R(e, t, n)));
|
|
413
|
+
if ("or" in e) return e.or.length === 0 ? t`FALSE` : t.or(e.or.map((e) => R(e, t, n)));
|
|
414
414
|
if (e.op === "subquery-in" || e.op === "subquery-not-in") {
|
|
415
|
-
let r = e, i =
|
|
415
|
+
let r = e, i = z(r.subquery, t, n);
|
|
416
416
|
return r.op === "subquery-in" ? t`${t(r.column)} IN (${i})` : t`${t(r.column)} NOT IN (${i})`;
|
|
417
417
|
}
|
|
418
418
|
if (e.op === "exists" || e.op === "not-exists") {
|
|
419
|
-
let r = e, i =
|
|
419
|
+
let r = e, i = z(r.subquery, t, n);
|
|
420
420
|
return r.op === "exists" ? t`EXISTS (${i})` : t`NOT EXISTS (${i})`;
|
|
421
421
|
}
|
|
422
422
|
let r = e, i = t(r.column), a = r.path, o = a !== void 0 && a.length > 0, s = () => t.onDialectOrElse({
|
|
423
|
-
mysql: () => t.unsafe(
|
|
424
|
-
mssql: () => t.unsafe(
|
|
425
|
-
sqlite: () => t.unsafe(
|
|
426
|
-
orElse: () => t.unsafe(
|
|
423
|
+
mysql: () => t.unsafe(D(r.column, a, "mysql")),
|
|
424
|
+
mssql: () => t.unsafe(D(r.column, a, "mssql")),
|
|
425
|
+
sqlite: () => t.unsafe(D(r.column, a, "sqlite")),
|
|
426
|
+
orElse: () => t.unsafe(D(r.column, a, "postgres"))
|
|
427
427
|
}), c = () => t.onDialectOrElse({
|
|
428
|
-
mysql: () => t.unsafe(
|
|
429
|
-
mssql: () => t.unsafe(
|
|
430
|
-
sqlite: () => t.unsafe(
|
|
431
|
-
orElse: () => t.unsafe(
|
|
428
|
+
mysql: () => t.unsafe(D(r.column, a, "mysql", { numeric: !0 })),
|
|
429
|
+
mssql: () => t.unsafe(D(r.column, a, "mssql", { numeric: !0 })),
|
|
430
|
+
sqlite: () => t.unsafe(D(r.column, a, "sqlite", { numeric: !0 })),
|
|
431
|
+
orElse: () => t.unsafe(D(r.column, a, "postgres", { numeric: !0 }))
|
|
432
432
|
}), l = o ? s() : i, u = o ? c() : i, d = (e) => o && e != null ? String(e) : e, f = (e) => o ? Number(e) : e;
|
|
433
433
|
switch (r.op) {
|
|
434
434
|
case "eq": return t`${l} = ${d(r.value)}`;
|
|
@@ -446,7 +446,7 @@ var st = (e) => e === "mysql" || e === "mariadb" || e === "mssql" || e === "sqli
|
|
|
446
446
|
return e.length === 0 ? t`TRUE` : t`${l} NOT IN ${t.in(o ? e.map((e) => d(e)) : e)}`;
|
|
447
447
|
}
|
|
448
448
|
case "contains": {
|
|
449
|
-
let e = `%${
|
|
449
|
+
let e = `%${pn(typeof r.value == "string" ? r.value : String(r.value ?? ""))}%`;
|
|
450
450
|
return t.onDialectOrElse({
|
|
451
451
|
mysql: () => t`LOWER(${l}) LIKE LOWER(${e})`,
|
|
452
452
|
mssql: () => t`LOWER(${l}) LIKE LOWER(${e})`,
|
|
@@ -496,13 +496,13 @@ var st = (e) => e === "mysql" || e === "mariadb" || e === "mssql" || e === "sqli
|
|
|
496
496
|
});
|
|
497
497
|
}
|
|
498
498
|
}
|
|
499
|
-
},
|
|
499
|
+
}, mn = (e, t) => {
|
|
500
500
|
let n = [];
|
|
501
501
|
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}`);
|
|
502
|
-
},
|
|
502
|
+
}, hn = (e, t) => t.csv(e.map((e) => {
|
|
503
503
|
let n = e.column === void 0 ? t.unsafe("*") : t`${t(e.column)}`;
|
|
504
504
|
if (e.op.startsWith("window-")) {
|
|
505
|
-
let r =
|
|
505
|
+
let r = mn(e.window ?? {}, t);
|
|
506
506
|
switch (e.op) {
|
|
507
507
|
case "window-row-number": return t`ROW_NUMBER() OVER (${r}) AS ${t(e.alias)}`;
|
|
508
508
|
case "window-rank": return t`RANK() OVER (${r}) AS ${t(e.alias)}`;
|
|
@@ -526,43 +526,43 @@ var st = (e) => e === "mysql" || e === "mariadb" || e === "mssql" || e === "sqli
|
|
|
526
526
|
return t`${t(e.column)} AS ${t(e.alias)}`;
|
|
527
527
|
default: throw Error(`compileAggregateProjection: unknown op '${e.op}'`);
|
|
528
528
|
}
|
|
529
|
-
})),
|
|
529
|
+
})), gn = (e) => `[${e.join(",")}]`, _n = (e, t) => {
|
|
530
530
|
if (e.queryVector === void 0) return null;
|
|
531
|
-
let n = t(e.column), r =
|
|
531
|
+
let n = t(e.column), r = gn(e.queryVector), i = e.distance === "cosine" ? "<=>" : e.distance === "l2" ? "<->" : "<#>", a = e.distance === "cosine" ? "VEC_DISTANCE_COSINE" : "VEC_DISTANCE_EUCLIDEAN";
|
|
532
532
|
return t.onDialectOrElse({
|
|
533
533
|
mysql: () => t`${t.unsafe(a)}(${n}, ${r})`,
|
|
534
534
|
mssql: () => t`NULL`,
|
|
535
535
|
sqlite: () => t`NULL`,
|
|
536
536
|
orElse: () => t`${n} ${t.unsafe(i)} ${r}::vector`
|
|
537
537
|
});
|
|
538
|
-
},
|
|
538
|
+
}, vn = (e, t) => {
|
|
539
539
|
let n = t.unsafe(e.useGeography ? "::geography" : "::geometry");
|
|
540
540
|
return t`ST_Distance(${t(e.column)}${n}, ${e.geom}${n})`;
|
|
541
|
-
},
|
|
542
|
-
let r = n.csv(e.columns.map((e) => n`${n(e)}`)), i = `%${
|
|
541
|
+
}, yn = (e, t) => t`${t(e.column)} <-> ${e.geom}::geometry`, bn = (e, t) => t`${t(`${e.indexName}_tsv`)}`, xn = (e, t) => `${t}_${e.indexName}_fts`, Sn = (e, t, n) => {
|
|
542
|
+
let r = n.csv(e.columns.map((e) => n`${n(e)}`)), i = `%${pn(e.query)}%`;
|
|
543
543
|
return n.onDialectOrElse({
|
|
544
544
|
mysql: () => n`MATCH(${r}) AGAINST(${e.query} IN NATURAL LANGUAGE MODE)`,
|
|
545
545
|
sqlite: () => {
|
|
546
|
-
let r = n(
|
|
546
|
+
let r = n(xn(e, t));
|
|
547
547
|
return n`${n("id")} IN (SELECT ${n("row_id")} FROM ${r} WHERE ${r} MATCH ${e.query})`;
|
|
548
548
|
},
|
|
549
549
|
mssql: () => n.or(e.columns.map((e) => n`LOWER(${n(e)}) LIKE LOWER(${i}) ESCAPE '\\'`)),
|
|
550
|
-
orElse: () => n`${
|
|
550
|
+
orElse: () => n`${bn(e, n)} @@ plainto_tsquery(${e.config ?? "english"}, ${e.query})`
|
|
551
551
|
});
|
|
552
|
-
},
|
|
553
|
-
let r = `%${
|
|
552
|
+
}, Cn = (e, t, n) => {
|
|
553
|
+
let r = `%${pn(e.query)}%`;
|
|
554
554
|
return n.onDialectOrElse({
|
|
555
555
|
mysql: () => n`MATCH(${n.csv(e.columns.map((e) => n`${n(e)}`))}) AGAINST(${e.query} IN NATURAL LANGUAGE MODE)`,
|
|
556
556
|
sqlite: () => {
|
|
557
|
-
let r = n(
|
|
557
|
+
let r = n(xn(e, t));
|
|
558
558
|
return n`COALESCE((SELECT -bm25(${r}) FROM ${r} WHERE ${r} MATCH ${e.query} AND ${r}.${n("row_id")} = ${n("id")}), 0)`;
|
|
559
559
|
},
|
|
560
560
|
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}`),
|
|
561
|
-
orElse: () => n`ts_rank(${
|
|
561
|
+
orElse: () => n`ts_rank(${bn(e, n)}, plainto_tsquery(${e.config ?? "english"}, ${e.query}))`
|
|
562
562
|
});
|
|
563
|
-
},
|
|
563
|
+
}, z = (e, t, n = null) => {
|
|
564
564
|
if (e.setOp && e.setOp.queries.length >= 2) {
|
|
565
|
-
let r = e.setOp.kind === "union" ? "UNION" : e.setOp.kind === "union-all" ? "UNION ALL" : e.setOp.kind === "intersect" ? "INTERSECT" : "EXCEPT", i = e.setOp.queries.map((e) => t`(${
|
|
565
|
+
let r = e.setOp.kind === "union" ? "UNION" : e.setOp.kind === "union-all" ? "UNION ALL" : e.setOp.kind === "intersect" ? "INTERSECT" : "EXCEPT", i = e.setOp.queries.map((e) => t`(${z(e, t, n)})`).reduce((e, n, i) => i === 0 ? n : t`${e} ${t.unsafe(r)} ${n}`), a = [];
|
|
566
566
|
if (e.order.length > 0 && a.push(t` ORDER BY ${t.csv(e.order.map((e) => e.direction === "desc" ? t`${t(e.column)} DESC` : t`${t(e.column)} ASC`))}`), e.take !== void 0) {
|
|
567
567
|
if (!Number.isInteger(e.take) || e.take < 0) throw Error(`compileSelect: invalid take ${e.take}`);
|
|
568
568
|
a.push(t` LIMIT ${t.unsafe(String(e.take))}`);
|
|
@@ -573,7 +573,7 @@ var st = (e) => e === "mysql" || e === "mariadb" || e === "mssql" || e === "sqli
|
|
|
573
573
|
}
|
|
574
574
|
return t`${i}${a.reduce((e, n) => t`${e}${n}`, t``)}`;
|
|
575
575
|
}
|
|
576
|
-
let r = e.annClause === void 0 ? null :
|
|
576
|
+
let r = e.annClause === void 0 ? null : _n(e.annClause, t);
|
|
577
577
|
e.spatialClause !== void 0 && t.onDialectOrElse({
|
|
578
578
|
mysql: () => {
|
|
579
579
|
throw Error("@voltro/plugin-postgis: spatial distance / KNN ordering is postgres-only");
|
|
@@ -586,35 +586,35 @@ var st = (e) => e === "mysql" || e === "mariadb" || e === "mssql" || e === "sqli
|
|
|
586
586
|
},
|
|
587
587
|
orElse: () => t``
|
|
588
588
|
});
|
|
589
|
-
let i = e.spatialClause?.projectAs === void 0 ? null :
|
|
589
|
+
let i = e.spatialClause?.projectAs === void 0 ? null : vn(e.spatialClause, t), a = e.aggregations && e.aggregations.length > 0 ? hn(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 ? Cn(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({
|
|
590
590
|
orElse: () => t`DISTINCT ON (${t.csv(e.distinctOn.map((e) => t`${t(e)}`))}) `,
|
|
591
591
|
mysql: () => t`DISTINCT `,
|
|
592
592
|
mssql: () => t`DISTINCT `,
|
|
593
593
|
sqlite: () => t`DISTINCT `
|
|
594
|
-
}) : e.distinct ? t`DISTINCT ` : t``, p = e.alias === void 0 ? t`${t(
|
|
594
|
+
}) : e.distinct ? t`DISTINCT ` : t``, p = e.alias === void 0 ? t`${t(dn(n, e.table))}` : t`${t(dn(n, e.table))} AS ${t(e.alias)}`, m = (e.joins ?? []).map((e) => {
|
|
595
595
|
let r = e.kind === "inner" ? "INNER" : "LEFT";
|
|
596
|
-
return t` ${t.unsafe(r)} JOIN ${t(
|
|
597
|
-
}), h = m.length > 0 ? m.reduce((e, n) => t`${e}${n}`, p) : p, g = c === void 0 ? null :
|
|
598
|
-
r !== null &&
|
|
599
|
-
for (let n of e.order)
|
|
600
|
-
let
|
|
596
|
+
return t` ${t.unsafe(r)} JOIN ${t(dn(n, e.table))} AS ${t(e.alias)} ON ${R(e.on, t, n)}`;
|
|
597
|
+
}), h = m.length > 0 ? m.reduce((e, n) => t`${e}${n}`, p) : p, g = c === void 0 ? null : Sn(c, e.table, t), _ = [e.predicate ? R(e.predicate, t, n) : null, g].filter((e) => e !== null), v = _.length > 0 ? t` WHERE ${t.and(_)}` : t``, y = e.groupBy && e.groupBy.length > 0 ? t` GROUP BY ${t.csv(e.groupBy.map((e) => t`${t(e)}`))}` : t``, b = e.having ? t` HAVING ${R(e.having, t, n)}` : t``, x = e.skip !== void 0, S = [];
|
|
598
|
+
r !== null && S.push(t`${r} ASC`), e.spatialClause?.order !== void 0 && S.push(e.spatialClause.order === "desc" ? t`${yn(e.spatialClause, t)} DESC` : t`${yn(e.spatialClause, t)} ASC`), l !== null && c?.rank?.order === !0 && S.push(t`${l} DESC`);
|
|
599
|
+
for (let n of e.order) S.push(n.direction === "desc" ? t`${t(n.column)} DESC` : t`${t(n.column)} ASC`);
|
|
600
|
+
let ee = S.length > 0 ? t` ORDER BY ${t.csv(S)}` : x ? t.onDialectOrElse({
|
|
601
601
|
mssql: () => t` ORDER BY (SELECT NULL)`,
|
|
602
602
|
orElse: () => t``
|
|
603
|
-
}) : t``,
|
|
603
|
+
}) : t``, C = (e) => {
|
|
604
604
|
if (!Number.isFinite(e) || !Number.isInteger(e) || e < 0) throw Error(`compileSelect: expected non-negative integer take/skip, got ${e}`);
|
|
605
605
|
return t.unsafe(String(e));
|
|
606
|
-
},
|
|
606
|
+
}, w = (e.ctes ?? []).map((e) => t`${t(e.name)} AS (${z(e.descriptor, t, n)})`), te = (e.ctes ?? []).some((e) => e.recursive === !0), ne = w.length > 0 ? t`WITH ${t.unsafe(te ? "RECURSIVE " : "")}${t.csv(w)} ` : t``;
|
|
607
607
|
return t.onDialectOrElse({
|
|
608
608
|
mssql: () => {
|
|
609
|
-
let n = e.take !== void 0 && !
|
|
610
|
-
return t`${
|
|
609
|
+
let n = e.take !== void 0 && !x ? t`TOP ${C(e.take)} ` : t``, r = x ? t` OFFSET ${C(e.skip)} ROWS FETCH NEXT ${C(e.take ?? 2 ** 53 - 1)} ROWS ONLY` : t``;
|
|
610
|
+
return t`${ne}SELECT ${n}${f}${d} FROM ${h}${v}${y}${b}${ee}${r}`;
|
|
611
611
|
},
|
|
612
612
|
orElse: () => {
|
|
613
|
-
let n = e.take === void 0 ? t`` : t` LIMIT ${
|
|
614
|
-
return t`${
|
|
613
|
+
let n = e.take === void 0 ? t`` : t` LIMIT ${C(e.take)}`, r = x ? t` OFFSET ${C(e.skip)}` : t``;
|
|
614
|
+
return t`${ne}SELECT ${f}${d} FROM ${h}${v}${y}${b}${ee}${n}${r}`;
|
|
615
615
|
}
|
|
616
616
|
});
|
|
617
|
-
},
|
|
617
|
+
}, wn = (e, t, n) => {
|
|
618
618
|
if (e.eager === void 0) return null;
|
|
619
619
|
let r = En(e.table, e.eager, e.sourceTable);
|
|
620
620
|
if (r === null) return null;
|
|
@@ -623,14 +623,14 @@ var st = (e) => e === "mysql" || e === "mariadb" || e === "mssql" || e === "sqli
|
|
|
623
623
|
fragment: i,
|
|
624
624
|
decode: In(r, n)
|
|
625
625
|
};
|
|
626
|
-
},
|
|
626
|
+
}, B = (e) => e.relation.kind === "one" && e.fkSide === "target", Tn = (e) => ({
|
|
627
627
|
...e,
|
|
628
628
|
branch: {
|
|
629
629
|
...e.branch,
|
|
630
630
|
limit: 2
|
|
631
631
|
}
|
|
632
632
|
}), En = (e, t, n) => {
|
|
633
|
-
let r = n ?? g(e), i =
|
|
633
|
+
let r = n ?? g(e), i = Nt(e);
|
|
634
634
|
if (i === void 0) return null;
|
|
635
635
|
let a = [];
|
|
636
636
|
for (let [e, n] of Object.entries(t)) {
|
|
@@ -651,17 +651,17 @@ var st = (e) => e === "mysql" || e === "mariadb" || e === "mssql" || e === "sqli
|
|
|
651
651
|
let r = t.sourceKey ?? jn(n, i.tableName);
|
|
652
652
|
if (r !== void 0) o = r, s = "source";
|
|
653
653
|
else try {
|
|
654
|
-
o = t.foreignKey ??
|
|
654
|
+
o = t.foreignKey ?? P(i, n.tableName, e), s = "target";
|
|
655
655
|
} catch {
|
|
656
656
|
return null;
|
|
657
657
|
}
|
|
658
658
|
} else try {
|
|
659
|
-
o = t.foreignKey ??
|
|
659
|
+
o = t.foreignKey ?? P(i, n.tableName, e), s = "target";
|
|
660
660
|
} catch {
|
|
661
661
|
return null;
|
|
662
662
|
}
|
|
663
663
|
let c = r.with === void 0 ? [] : (() => {
|
|
664
|
-
let e =
|
|
664
|
+
let e = Nt(i.tableName);
|
|
665
665
|
if (e === void 0 && Object.keys(r.with).length > 0) return null;
|
|
666
666
|
let t = [];
|
|
667
667
|
for (let [n, a] of Object.entries(r.with)) {
|
|
@@ -725,7 +725,7 @@ var st = (e) => e === "mysql" || e === "mariadb" || e === "mssql" || e === "sqli
|
|
|
725
725
|
let r = [];
|
|
726
726
|
for (let [t, n] of Object.entries(e.fields)) (n.type === "timestamp" || n.type === "date") && r.push(t);
|
|
727
727
|
let i = t.map((e) => {
|
|
728
|
-
let t = Ln(e.target, e.children, n), r = e.relation.kind === "one", i =
|
|
728
|
+
let t = Ln(e.target, e.children, n), r = e.relation.kind === "one", i = B(e), a = i ? qt({
|
|
729
729
|
relationName: e.relationName,
|
|
730
730
|
sourceTableName: e.source.tableName,
|
|
731
731
|
targetTableName: e.target.tableName,
|
|
@@ -755,7 +755,7 @@ var st = (e) => e === "mysql" || e === "mariadb" || e === "mssql" || e === "sqli
|
|
|
755
755
|
}
|
|
756
756
|
if (e.fromOverFetch) {
|
|
757
757
|
let r = n;
|
|
758
|
-
if (r.length > 1) throw new
|
|
758
|
+
if (r.length > 1) throw new Kt(e.cardinalityMessage);
|
|
759
759
|
t[e.name] = r.length === 0 ? null : e.decode(r[0]);
|
|
760
760
|
continue;
|
|
761
761
|
}
|
|
@@ -797,7 +797,7 @@ var st = (e) => e === "mysql" || e === "mariadb" || e === "mssql" || e === "sqli
|
|
|
797
797
|
return i`${a} || jsonb_build_object(${i.csv(o)})`;
|
|
798
798
|
}, Vn = (e, t, n) => {
|
|
799
799
|
switch (e.relation.kind) {
|
|
800
|
-
case "one": return
|
|
800
|
+
case "one": return B(e) ? Un(Tn(e), t, n) : Hn(e, t, n);
|
|
801
801
|
case "many": return Un(e, t, n);
|
|
802
802
|
case "manyToMany": return Wn(e, t, n);
|
|
803
803
|
}
|
|
@@ -809,12 +809,12 @@ var st = (e) => e === "mysql" || e === "mariadb" || e === "mssql" || e === "sqli
|
|
|
809
809
|
}, Un = (e, t, n) => {
|
|
810
810
|
let r = n.sql, i = n.nextAlias(), a = Bn(i, e.children, n);
|
|
811
811
|
if (a === null) return null;
|
|
812
|
-
let o = r`${U(void 0, e.foreignKey, r)} = ${U(t, e.sourceKey, r)}`, s = e.branch.where === void 0 ? r`` : r` AND ${
|
|
812
|
+
let o = r`${U(void 0, e.foreignKey, r)} = ${U(t, e.sourceKey, r)}`, s = e.branch.where === void 0 ? r`` : r` AND ${R(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)}`;
|
|
813
813
|
return r`COALESCE((SELECT jsonb_agg(${a}) FROM (SELECT * FROM ${r(e.target.tableName)} WHERE ${o}${s}${c}${l}${u}) AS ${r(i)}), '[]'::jsonb)`;
|
|
814
814
|
}, Wn = (e, t, n) => {
|
|
815
815
|
let r = n.sql, i = e.relation, a = i.through(), o = n.nextAlias(), s = n.nextAlias(), c = Bn(o, e.children, n, e.junction);
|
|
816
816
|
if (c === null) return null;
|
|
817
|
-
let l = e.branch.where === void 0 ? r`` : r` AND ${
|
|
817
|
+
let l = e.branch.where === void 0 ? r`` : r` AND ${R(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)}`;
|
|
818
818
|
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)`;
|
|
819
819
|
}, 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) => {
|
|
820
820
|
let r = n.sql, i = n.nextAlias(), a = Jn(i, t.table, t.children, n);
|
|
@@ -842,7 +842,7 @@ var st = (e) => e === "mysql" || e === "mariadb" || e === "mssql" || e === "sqli
|
|
|
842
842
|
physical: (e) => e
|
|
843
843
|
}), $n = (e, t, n) => {
|
|
844
844
|
switch (e.relation.kind) {
|
|
845
|
-
case "one": return
|
|
845
|
+
case "one": return B(e) ? tr(Tn(e), t, n) : er(e, t, n);
|
|
846
846
|
case "many": return tr(e, t, n);
|
|
847
847
|
case "manyToMany": return nr(e, t, n);
|
|
848
848
|
}
|
|
@@ -854,7 +854,7 @@ var st = (e) => e === "mysql" || e === "mariadb" || e === "mssql" || e === "sqli
|
|
|
854
854
|
}, tr = (e, t, n) => {
|
|
855
855
|
let r = n.sql, i = n.nextAlias(), a = Jn(i, e.target, e.children, n);
|
|
856
856
|
if (a === null) return null;
|
|
857
|
-
let o = r`${U(void 0, e.foreignKey, r)} = ${U(t, e.sourceKey, r)}`, s = e.branch.where === void 0 ? r`` : r` AND ${
|
|
857
|
+
let o = r`${U(void 0, e.foreignKey, r)} = ${U(t, e.sourceKey, r)}`, s = e.branch.where === void 0 ? r`` : r` AND ${R(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)}`;
|
|
858
858
|
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('[]'))`;
|
|
859
859
|
}, nr = (e, t, n) => {
|
|
860
860
|
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 : {
|
|
@@ -862,7 +862,7 @@ var st = (e) => e === "mysql" || e === "mariadb" || e === "mssql" || e === "sqli
|
|
|
862
862
|
source: Zn(o)
|
|
863
863
|
});
|
|
864
864
|
if (c === null) return null;
|
|
865
|
-
let l = e.branch.where === void 0 ? r`` : r` AND ${
|
|
865
|
+
let l = e.branch.where === void 0 ? r`` : r` AND ${R(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);
|
|
866
866
|
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('[]'))`;
|
|
867
867
|
}, rr = (e, t, n) => {
|
|
868
868
|
let r = n.sql, i = n.nextAlias(), a = H(i, t.table, t.children, n);
|
|
@@ -885,8 +885,8 @@ var st = (e) => e === "mysql" || e === "mariadb" || e === "mssql" || e === "sqli
|
|
|
885
885
|
}, ir = (e, t, n) => {
|
|
886
886
|
switch (e.relation.kind) {
|
|
887
887
|
case "one":
|
|
888
|
-
if (
|
|
889
|
-
let r =
|
|
888
|
+
if (B(e)) {
|
|
889
|
+
let r = Tn(e);
|
|
890
890
|
return n.dialect === "mariadb" ? cr(r, t, n) : or(r, t, n);
|
|
891
891
|
}
|
|
892
892
|
return ar(e, t, n);
|
|
@@ -901,7 +901,7 @@ var st = (e) => e === "mysql" || e === "mariadb" || e === "mssql" || e === "sqli
|
|
|
901
901
|
}, or = (e, t, n) => {
|
|
902
902
|
let r = n.sql, i = n.nextAlias(), a = H(i, e.target, e.children, n);
|
|
903
903
|
if (a === null) return null;
|
|
904
|
-
let o = r`${U(void 0, e.foreignKey, r)} = ${U(t, e.sourceKey, r)}`, s = e.branch.where === void 0 ? r`` : r` AND ${
|
|
904
|
+
let o = r`${U(void 0, e.foreignKey, r)} = ${U(t, e.sourceKey, r)}`, s = e.branch.where === void 0 ? r`` : r` AND ${R(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)}`;
|
|
905
905
|
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())`;
|
|
906
906
|
}, sr = (e, t, n) => {
|
|
907
907
|
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 : {
|
|
@@ -909,12 +909,12 @@ var st = (e) => e === "mysql" || e === "mariadb" || e === "mssql" || e === "sqli
|
|
|
909
909
|
source: Zn(o)
|
|
910
910
|
});
|
|
911
911
|
if (c === null) return null;
|
|
912
|
-
let l = e.branch.where === void 0 ? r`` : r` AND ${
|
|
912
|
+
let l = e.branch.where === void 0 ? r`` : r` AND ${R(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);
|
|
913
913
|
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())`;
|
|
914
914
|
}, cr = (e, t, n) => {
|
|
915
915
|
let r = n.sql, i = n.nextAlias(), a = H(i, e.target, e.children, n);
|
|
916
916
|
if (a === null) return null;
|
|
917
|
-
let o = r`${U(i, e.foreignKey, r)} = ${U(t, e.sourceKey, r)}`, s = e.branch.where === void 0 ? r`` : r` AND ${
|
|
917
|
+
let o = r`${U(i, e.foreignKey, r)} = ${U(t, e.sourceKey, r)}`, s = e.branch.where === void 0 ? r`` : r` AND ${R(J(e.branch.where), r)}`, c = e.branch.orderBy ?? [];
|
|
918
918
|
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())`;
|
|
919
919
|
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)}`;
|
|
920
920
|
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())`;
|
|
@@ -922,15 +922,15 @@ var st = (e) => e === "mysql" || e === "mariadb" || e === "mssql" || e === "sqli
|
|
|
922
922
|
let r = n.sql, i = e.relation, a = i.through(), o = n.nextAlias(), s = n.nextAlias(), c = (t) => e.junction === void 0 ? void 0 : {
|
|
923
923
|
projection: e.junction,
|
|
924
924
|
source: t
|
|
925
|
-
}, 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 ${
|
|
925
|
+
}, 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 ${R(J(e.branch.where), r)}`, f = q(e, s, r, !0), p = e.branch.orderBy ?? [];
|
|
926
926
|
if (!(e.branch.limit !== void 0 || e.branch.offset !== void 0)) {
|
|
927
927
|
let t = H(o, e.target, e.children, n, c(Qn(s)));
|
|
928
928
|
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())`;
|
|
929
929
|
}
|
|
930
|
-
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,
|
|
931
|
-
if (
|
|
932
|
-
let
|
|
933
|
-
return r`COALESCE((SELECT JSON_ARRAYAGG(${
|
|
930
|
+
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, _ = 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)}`, v = e.branch.onJunction === void 0 ? r`` : r` WHERE ${K(J(e.branch.onJunction), s, r)}`, y = H(o, e.target, e.children, n, c(Zn(o)));
|
|
931
|
+
if (y === null) return null;
|
|
932
|
+
let b = e.junction === void 0 ? r`` : Xn(e.junction, s, r);
|
|
933
|
+
return r`COALESCE((SELECT JSON_ARRAYAGG(${y} ORDER BY ${U(o, "rn", r)}) FROM (SELECT ${r(o)}.*${b}, ${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}${v}) AS ${r(o)} WHERE ${U(o, `__src_${i.sourceKey}`, r)} = ${U(t, "id", r)}${d}${_}), JSON_ARRAY())`;
|
|
934
934
|
}, ur = (e, t, n) => {
|
|
935
935
|
let r = n.sql, i = n.nextAlias(), a = dr(i, t.table, t.children, n);
|
|
936
936
|
if (a === null) return null;
|
|
@@ -953,7 +953,7 @@ var st = (e) => e === "mysql" || e === "mariadb" || e === "mssql" || e === "sqli
|
|
|
953
953
|
return a.csv(o);
|
|
954
954
|
}, fr = (e, t) => t.unsafe(`[${e.replace(/]/g, "]]")}]`), pr = (e, t, n) => {
|
|
955
955
|
switch (e.relation.kind) {
|
|
956
|
-
case "one": return
|
|
956
|
+
case "one": return B(e) ? gr(Tn(e), t, n) : mr(e, t, n);
|
|
957
957
|
case "many": return gr(e, t, n);
|
|
958
958
|
case "manyToMany": return _r(e, t, n);
|
|
959
959
|
}
|
|
@@ -992,7 +992,7 @@ var st = (e) => e === "mysql" || e === "mariadb" || e === "mssql" || e === "sqli
|
|
|
992
992
|
}, 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) => {
|
|
993
993
|
if (!Number.isFinite(e) || !Number.isInteger(e) || e < 0) throw Error(`literalInt: expected non-negative integer, got ${e}`);
|
|
994
994
|
return t.unsafe(String(e));
|
|
995
|
-
}, K = (e, t, n) =>
|
|
995
|
+
}, K = (e, t, n) => R(vr(e, t), n), q = (e, t, n, r = !1) => {
|
|
996
996
|
let i = e.branch.onJunction;
|
|
997
997
|
return i === void 0 ? n`` : n` AND ${K(r ? J(i) : i, t, n)}`;
|
|
998
998
|
}, vr = (e, t) => {
|
|
@@ -1028,16 +1028,16 @@ var st = (e) => e === "mysql" || e === "mariadb" || e === "mssql" || e === "sqli
|
|
|
1028
1028
|
let n = e();
|
|
1029
1029
|
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`);
|
|
1030
1030
|
return n();
|
|
1031
|
-
}, Tr = () => wr(() => Sr.actors, "actors"), Er = () => wr(() => Sr.tenants, "tenants"), Dr =
|
|
1032
|
-
id:
|
|
1033
|
-
kind:
|
|
1031
|
+
}, Tr = () => wr(() => Sr.actors, "actors"), Er = () => wr(() => Sr.tenants, "tenants"), Dr = T("actors", {
|
|
1032
|
+
id: k(),
|
|
1033
|
+
kind: b().oneOf([
|
|
1034
1034
|
"user",
|
|
1035
1035
|
"serviceAccount",
|
|
1036
1036
|
"apiKey",
|
|
1037
1037
|
"system"
|
|
1038
1038
|
]),
|
|
1039
|
-
displayName:
|
|
1040
|
-
createdAt:
|
|
1039
|
+
displayName: b().nullable(),
|
|
1040
|
+
createdAt: O().default("now")
|
|
1041
1041
|
}), Or = (e, t) => ({
|
|
1042
1042
|
column: e,
|
|
1043
1043
|
op: "eq",
|
|
@@ -1215,8 +1215,8 @@ var st = (e) => e === "mysql" || e === "mariadb" || e === "mssql" || e === "sqli
|
|
|
1215
1215
|
...e,
|
|
1216
1216
|
conjunctive: t
|
|
1217
1217
|
});
|
|
1218
|
-
}, ni = class extends
|
|
1219
|
-
let i =
|
|
1218
|
+
}, ni = class extends rt.TaggedError("TableStreamError") {}, ri = 1e3, ii = (e, t, n, r) => {
|
|
1219
|
+
let i = A.match(r, {
|
|
1220
1220
|
onNone: () => e.where,
|
|
1221
1221
|
onSome: (n) => e.where ? Ur(e.where, Ar(t, n)) : Ar(t, n)
|
|
1222
1222
|
});
|
|
@@ -1235,15 +1235,15 @@ var st = (e) => e === "mysql" || e === "mariadb" || e === "mssql" || e === "sqli
|
|
|
1235
1235
|
};
|
|
1236
1236
|
}, ai = (e, t) => {
|
|
1237
1237
|
let n = t.pk ?? "id", r = t.chunkSize ?? ri;
|
|
1238
|
-
return
|
|
1239
|
-
let a =
|
|
1238
|
+
return at.paginateChunkEffect(A.none(), (i) => {
|
|
1239
|
+
let a = it.tryPromise({
|
|
1240
1240
|
try: () => e.query(ii(t, n, r, i)),
|
|
1241
1241
|
catch: (e) => new ni({
|
|
1242
1242
|
table: t.table,
|
|
1243
1243
|
cause: e
|
|
1244
1244
|
})
|
|
1245
1245
|
});
|
|
1246
|
-
return (t.retry ? a.pipe(
|
|
1246
|
+
return (t.retry ? a.pipe(it.retry(t.retry)) : a).pipe(it.map((e) => [nt.fromIterable(e), e.length === r && e.length > 0 ? A.some(A.some(e[e.length - 1][n])) : A.none()]));
|
|
1247
1247
|
});
|
|
1248
1248
|
}, oi = (e) => {
|
|
1249
1249
|
let t = e.alpha ?? .5;
|
|
@@ -1280,7 +1280,7 @@ var st = (e) => e === "mysql" || e === "mariadb" || e === "mssql" || e === "sqli
|
|
|
1280
1280
|
}, ci = (e) => {
|
|
1281
1281
|
if (!Number.isInteger(e.dimensions) || e.dimensions <= 0) throw Error(`vectorEmbedding: dimensions must be a positive integer, got ${String(e.dimensions)}.`);
|
|
1282
1282
|
let t = e.as ?? "embedding", r = (t) => si(e, t);
|
|
1283
|
-
return
|
|
1283
|
+
return re({
|
|
1284
1284
|
id: "voltro/vectorEmbedding",
|
|
1285
1285
|
fields: { [t]: n(e.dimensions) },
|
|
1286
1286
|
...e.index === !1 ? {} : { indexes: [{
|
|
@@ -1304,7 +1304,7 @@ var st = (e) => e === "mysql" || e === "mariadb" || e === "mssql" || e === "sqli
|
|
|
1304
1304
|
}
|
|
1305
1305
|
}, di = (e, t) => {
|
|
1306
1306
|
if (!Number.isInteger(t) || t < 0) throw new Y(`prNumber must be a non-negative integer, got ${String(t)}`);
|
|
1307
|
-
let n =
|
|
1307
|
+
let n = ln(e);
|
|
1308
1308
|
if (n.replace(/_/g, "") === "") throw new Y(`app slug '${e}' has no usable identifier characters`);
|
|
1309
1309
|
let r = `${ui}${t}_${n}`;
|
|
1310
1310
|
if (r.length > li) throw new Y(`branch namespace '${r}' exceeds the ${li}-byte identifier limit — use a shorter app slug`);
|
|
@@ -1463,7 +1463,7 @@ var st = (e) => e === "mysql" || e === "mariadb" || e === "mssql" || e === "sqli
|
|
|
1463
1463
|
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)`);
|
|
1464
1464
|
return n;
|
|
1465
1465
|
}, Ii = (e, t) => t.servableRegions.includes(e), Li = (e, t) => {
|
|
1466
|
-
let n = Fi(e.tenantId, t), r =
|
|
1466
|
+
let n = Fi(e.tenantId, t), r = un(n.tenantId);
|
|
1467
1467
|
return {
|
|
1468
1468
|
region: n.region,
|
|
1469
1469
|
namespace: r,
|
|
@@ -1533,12 +1533,12 @@ var st = (e) => e === "mysql" || e === "mariadb" || e === "mssql" || e === "sqli
|
|
|
1533
1533
|
let t = [];
|
|
1534
1534
|
for (let n of e) t.push(...Hi(n));
|
|
1535
1535
|
return t;
|
|
1536
|
-
}, Wi = "\x1B[", Gi = `${Wi}38;2;245;158;11m`, Ki = `${Wi}38;2;16;185;129m`, qi = (e, t) => `${e}${t}${
|
|
1537
|
-
let n = t.color ?? !0, r = t.indent ?? " ", i = (e) => $(n,
|
|
1536
|
+
}, Wi = "\x1B[", Gi = `${Wi}38;2;245;158;11m`, Ki = `${Wi}38;2;16;185;129m`, qi = (e, t) => `${e}${t}${M.reset}`, $ = (e, t, n) => e ? typeof t == "function" ? t(n) : qi(t, n) : n, Ji = (e, t = {}) => {
|
|
1537
|
+
let n = t.color ?? !0, r = t.indent ?? " ", i = (e) => $(n, M.dim, e.padEnd(11)), a = (e) => $(n, (e) => M.bold(M.brand(e)), e), o = (e) => $(n, M.brightRed24, e), s = (e) => $(n, Ki, e), c = (e) => $(n, Gi, e), l = (e) => $(n, M.dim, e), u = `${c("index audit")} ${l("·")} ${$(n, M.bold, e.kind)}`, d = e.redundant.fields.length, f = Q(e.coveredBy.fields.slice(d)), p = (e, t) => {
|
|
1538
1538
|
let n = e.slice(0, t), r = e.slice(t), i = [];
|
|
1539
1539
|
return n.length > 0 && i.push(s(`[${n.join(", ")}]`)), r.length > 0 && i.push(c(`+ [${r.join(", ")}]`)), i.join(" ");
|
|
1540
1540
|
}, m = [];
|
|
1541
|
-
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
|
+
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, M.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");
|
|
1542
1542
|
}, Yi = (e, t) => ({
|
|
1543
1543
|
name: e,
|
|
1544
1544
|
body: t
|
|
@@ -1571,111 +1571,113 @@ var st = (e) => e === "mysql" || e === "mariadb" || e === "mssql" || e === "sqli
|
|
|
1571
1571
|
name: e.name,
|
|
1572
1572
|
steps: t
|
|
1573
1573
|
};
|
|
1574
|
-
}, ea = (e) => typeof e == "object" && !!e && "__migration" in e && e.__migration === !0, ta =
|
|
1575
|
-
id:
|
|
1576
|
-
name:
|
|
1577
|
-
hash:
|
|
1578
|
-
status:
|
|
1579
|
-
appliedAt:
|
|
1580
|
-
durationMs:
|
|
1581
|
-
errorMessage:
|
|
1582
|
-
errorStack:
|
|
1583
|
-
workflowRunId:
|
|
1584
|
-
createdAt:
|
|
1585
|
-
updatedAt:
|
|
1586
|
-
}).index(["status"]).reactive(), na =
|
|
1587
|
-
id:
|
|
1588
|
-
name:
|
|
1589
|
-
lifecycle:
|
|
1590
|
-
fingerprint:
|
|
1591
|
-
cronSchedule:
|
|
1592
|
-
watchedTables:
|
|
1593
|
-
nextRunAt:
|
|
1594
|
-
lastRunStatus:
|
|
1595
|
-
lastRunAt:
|
|
1596
|
-
lastRunDurationMs:
|
|
1597
|
-
lastRunRowsTouched:
|
|
1598
|
-
lastError:
|
|
1599
|
-
workflowRunId:
|
|
1600
|
-
createdAt:
|
|
1601
|
-
updatedAt:
|
|
1602
|
-
}).index(["lifecycle"]).index(["nextRunAt"]).reactive(), ra =
|
|
1603
|
-
id:
|
|
1604
|
-
fingerprint:
|
|
1605
|
-
operations:
|
|
1606
|
-
rollbackPlan:
|
|
1607
|
-
appliedBy:
|
|
1608
|
-
environment:
|
|
1609
|
-
source:
|
|
1610
|
-
onlineStrategy:
|
|
1611
|
-
durationMs:
|
|
1612
|
-
notes:
|
|
1613
|
-
squashedAt:
|
|
1614
|
-
appliedAt:
|
|
1615
|
-
createdAt:
|
|
1616
|
-
updatedAt:
|
|
1617
|
-
}).index(["fingerprint"]).index(["environment"]).reactive(), ia =
|
|
1618
|
-
id:
|
|
1619
|
-
scope:
|
|
1620
|
-
key:
|
|
1621
|
-
status:
|
|
1622
|
-
response:
|
|
1623
|
-
createdAt:
|
|
1624
|
-
}).unique(["scope", "key"]).index(["createdAt"]).reactive(), aa =
|
|
1625
|
-
id:
|
|
1626
|
-
key:
|
|
1627
|
-
value:
|
|
1628
|
-
expiresAt:
|
|
1629
|
-
createdAt:
|
|
1630
|
-
updatedAt:
|
|
1631
|
-
}).index(["expiresAt"]).reactive(), oa =
|
|
1632
|
-
id:
|
|
1633
|
-
tenantId:
|
|
1634
|
-
name:
|
|
1635
|
-
hashedKey:
|
|
1636
|
-
keyPrefix:
|
|
1637
|
-
scopes:
|
|
1638
|
-
lastUsedAt:
|
|
1639
|
-
expiresAt:
|
|
1640
|
-
revokedAt:
|
|
1641
|
-
createdBy:
|
|
1642
|
-
createdAt:
|
|
1574
|
+
}, ea = (e) => typeof e == "object" && !!e && "__migration" in e && e.__migration === !0, ta = T("_voltro_migrations", {
|
|
1575
|
+
id: k({ prefix: "mig" }),
|
|
1576
|
+
name: b(),
|
|
1577
|
+
hash: b(),
|
|
1578
|
+
status: b(),
|
|
1579
|
+
appliedAt: O().nullable(),
|
|
1580
|
+
durationMs: E().nullable(),
|
|
1581
|
+
errorMessage: b().nullable(),
|
|
1582
|
+
errorStack: b().nullable(),
|
|
1583
|
+
workflowRunId: b().nullable(),
|
|
1584
|
+
createdAt: O().default("now"),
|
|
1585
|
+
updatedAt: O().default("now").onUpdate("now")
|
|
1586
|
+
}).index(["status"]).reactive(), na = T("_voltro_seeds", {
|
|
1587
|
+
id: k({ prefix: "seed" }),
|
|
1588
|
+
name: b(),
|
|
1589
|
+
lifecycle: b(),
|
|
1590
|
+
fingerprint: b(),
|
|
1591
|
+
cronSchedule: b().nullable(),
|
|
1592
|
+
watchedTables: w().nullable(),
|
|
1593
|
+
nextRunAt: O().nullable(),
|
|
1594
|
+
lastRunStatus: b().nullable(),
|
|
1595
|
+
lastRunAt: O().nullable(),
|
|
1596
|
+
lastRunDurationMs: E().nullable(),
|
|
1597
|
+
lastRunRowsTouched: E().nullable(),
|
|
1598
|
+
lastError: b().nullable(),
|
|
1599
|
+
workflowRunId: b().nullable(),
|
|
1600
|
+
createdAt: O().default("now"),
|
|
1601
|
+
updatedAt: O().default("now").onUpdate("now")
|
|
1602
|
+
}).index(["lifecycle"]).index(["nextRunAt"]).reactive(), ra = T("_voltro_migration_plans", {
|
|
1603
|
+
id: k({ prefix: "plan" }),
|
|
1604
|
+
fingerprint: b(),
|
|
1605
|
+
operations: w(),
|
|
1606
|
+
rollbackPlan: w().nullable(),
|
|
1607
|
+
appliedBy: b(),
|
|
1608
|
+
environment: b(),
|
|
1609
|
+
source: b(),
|
|
1610
|
+
onlineStrategy: b().nullable(),
|
|
1611
|
+
durationMs: E(),
|
|
1612
|
+
notes: b().nullable(),
|
|
1613
|
+
squashedAt: O().nullable(),
|
|
1614
|
+
appliedAt: O().default("now"),
|
|
1615
|
+
createdAt: O().default("now"),
|
|
1616
|
+
updatedAt: O().default("now").onUpdate("now")
|
|
1617
|
+
}).index(["fingerprint"]).index(["environment"]).reactive(), ia = T("_voltro_idempotency", {
|
|
1618
|
+
id: k({ prefix: "idem" }),
|
|
1619
|
+
scope: b(),
|
|
1620
|
+
key: b(),
|
|
1621
|
+
status: b(),
|
|
1622
|
+
response: w().nullable(),
|
|
1623
|
+
createdAt: O().default("now")
|
|
1624
|
+
}).unique(["scope", "key"]).index(["createdAt"]).reactive(), aa = T("_voltro_kv", {
|
|
1625
|
+
id: k({ prefix: "kv" }),
|
|
1626
|
+
key: b().unique(),
|
|
1627
|
+
value: b().nullable(),
|
|
1628
|
+
expiresAt: O().nullable(),
|
|
1629
|
+
createdAt: O().default("now"),
|
|
1630
|
+
updatedAt: O().default("now").onUpdate("now")
|
|
1631
|
+
}).index(["expiresAt"]).reactive(), oa = T("_voltro_api_keys", {
|
|
1632
|
+
id: k({ prefix: "apikey" }),
|
|
1633
|
+
tenantId: b().nullable(),
|
|
1634
|
+
name: b(),
|
|
1635
|
+
hashedKey: b().unique(),
|
|
1636
|
+
keyPrefix: b(),
|
|
1637
|
+
scopes: w().nullable(),
|
|
1638
|
+
lastUsedAt: O().nullable(),
|
|
1639
|
+
expiresAt: O().nullable(),
|
|
1640
|
+
revokedAt: O().nullable(),
|
|
1641
|
+
createdBy: b().nullable(),
|
|
1642
|
+
createdAt: O().default("now")
|
|
1643
1643
|
}).index("byTenant", ["tenantId"]).reactive(), sa = [
|
|
1644
1644
|
ta,
|
|
1645
1645
|
na,
|
|
1646
1646
|
ra
|
|
1647
|
-
], ca =
|
|
1647
|
+
], ca = 512, la = (e) => {
|
|
1648
|
+
e.setMaxListeners(512);
|
|
1649
|
+
}, ua = (e, t, n) => ({
|
|
1648
1650
|
_tag: "PrimaryKeyConflictError",
|
|
1649
1651
|
table: e,
|
|
1650
1652
|
key: t,
|
|
1651
1653
|
cause: n
|
|
1652
|
-
}),
|
|
1654
|
+
}), da = (e) => typeof e == "object" && !!e && e._tag === "PrimaryKeyConflictError", fa = /* @__PURE__ */ new Map(), pa = (e) => {
|
|
1653
1655
|
if (!e.table || !e.timeColumn) throw Error("registerRetention: table + timeColumn are required");
|
|
1654
1656
|
if (!Number.isFinite(e.ttlMs) || e.ttlMs <= 0) throw Error(`registerRetention(${e.table}): ttlMs must be a positive number`);
|
|
1655
|
-
|
|
1656
|
-
},
|
|
1657
|
+
fa.set(e.table, e);
|
|
1658
|
+
}, ma = () => [...fa.values()], ha = () => fa.clear(), ga = async (e, t, n, r = 2e4) => {
|
|
1657
1659
|
let i = new Date(t - e.ttlMs), a = 0;
|
|
1658
1660
|
for (;;) {
|
|
1659
1661
|
let t = await n(e.table, e.timeColumn, i, r, e.where);
|
|
1660
1662
|
if (a += t, t < r) break;
|
|
1661
1663
|
}
|
|
1662
1664
|
return a;
|
|
1663
|
-
},
|
|
1665
|
+
}, _a = (e, t) => {
|
|
1664
1666
|
let n = Number(e ?? String(t));
|
|
1665
1667
|
return (Number.isFinite(n) && n > 0 ? n : t) * 36e5;
|
|
1666
|
-
},
|
|
1667
|
-
id:
|
|
1668
|
-
replicaId:
|
|
1669
|
-
streamName:
|
|
1670
|
-
binlogFile:
|
|
1671
|
-
binlogPosition:
|
|
1672
|
-
updatedAt:
|
|
1673
|
-
}).index(["replicaId"]),
|
|
1674
|
-
id:
|
|
1675
|
-
replicaId:
|
|
1676
|
-
streamName:
|
|
1677
|
-
ctVersion:
|
|
1678
|
-
updatedAt:
|
|
1679
|
-
}).index(["replicaId"]),
|
|
1668
|
+
}, va = "_voltro_cdc_offsets", ya = T(va, {
|
|
1669
|
+
id: k({ prefix: "cdcoff" }),
|
|
1670
|
+
replicaId: b(),
|
|
1671
|
+
streamName: b(),
|
|
1672
|
+
binlogFile: b(),
|
|
1673
|
+
binlogPosition: b(),
|
|
1674
|
+
updatedAt: O()
|
|
1675
|
+
}).index(["replicaId"]), ba = T(va, {
|
|
1676
|
+
id: k({ prefix: "cdcoff" }),
|
|
1677
|
+
replicaId: b(),
|
|
1678
|
+
streamName: b(),
|
|
1679
|
+
ctVersion: b(),
|
|
1680
|
+
updatedAt: O()
|
|
1681
|
+
}).index(["replicaId"]), xa = "postgres";
|
|
1680
1682
|
//#endregion
|
|
1681
|
-
export { Y as BranchNameInvalid, mi as BranchTransitionInvalid,
|
|
1683
|
+
export { Y as BranchNameInvalid, mi as BranchTransitionInvalid, va as CDC_OFFSETS_TABLE, ca as CHANGE_LISTENER_CEILING, me as ColumnBuilder, ut as ENCRYPTED_PREFIX, xa as ENGINE, Kt as EagerCardinalityError, He as FILE_MIGRATION_PATTERN, se as MAX_IDENTIFIER_LENGTH, ni as TableStreamError, on as TenantNamespaceInvalid, an as TenantNamespaceUnresolved, Ai as TenantRegionUnavailable, ki as TenantResidencyUnresolved, S as WARN_IDENTIFIER_LENGTH, oa as _voltroApiKeysTable, ya as _voltroCdcOffsetsTable, ia as _voltroIdempotencyTable, aa as _voltroKvTable, ra as _voltroMigrationPlansTable, ta as _voltroMigrationsTable, ba as _voltroMssqlCdcOffsetsTable, na as _voltroSeedsTable, Dr as actorsTable, Di as admitBranch, we as allEnumRenames, Ft as allRegisteredRelations, _ as allRegisteredTables, Ur as and, Oe as array, Lr as arrayContains, zr as arrayHas, Rr as arrayOverlaps, Jt as attachEagerLoads, Ui as auditAllTableIndexes, Hi as auditTableIndexes, De as avg, We as avgOver, Ge as bigint, Ri as bindResidentStore, ge as boolean, di as branchNamespaceName, ye as bytes, de as clearEnumRenames, Lt as clearRelationsRegistry, Pi as clearResidencyConfig, ha as clearRetentions, v as clearTableRegistry, ei as collectSubqueries, he as column, ht as columnSchema, wn as compileEagerJson, R as compilePredicate, fn as compileRawFragment, z as compileSelect, si as computeEmbedding, Ir as contains, ve as count, Fe as countDistinct, ke as databaseHandle, Ie as date, Ae as dbEnum, Ce as decimal, Pe as declareEnumRename, Ut as decodeRowsFromSchema, mt as decryptFieldsOnRead, $i as defineMigration, re as defineMixin, Xi as defineSeed, Se as denseRank, h as deriveTypeIdPrefix, lt as deserializeArraysOnRead, e as drainIdentifierWarnings, xe as dropped, Gt as encodeRowForSchema, pt as encryptFieldsForWrite, ft as encryptedColumnsOf, wi as enforceBranchLimits, x as ensureTableRegistered, Or as eq, pn as escapeLike, $r as evaluatePredicate, be as except, Xr as exists, Ji as formatIndexAuditIssue, sa as frameworkTables, Le as generateId, oe as generateSnowflake, le as geography, qe as geometry, Ve as getEnumRenames, Pt as getRelation, Nt as getRelations, Ni as getResidencyConfig, u as getTable, Ar as gt, jr as gte, rn as hasEagerLoads, oi as hybridSearch, k as id, Pr as inSet, Jr as inSubquery, P as inferForeignKey, E as integer, ce as intersect, Ze as interval, fi as isBranchNamespace, dt as isEncrypted, je as isFileMigration, ea as isMigrationDefinition, vi as isNeonConnection, Vr as isNotNull, Br as isNull, da as isPrimaryKeyConflictError, Ii as isRegionServable, St as isRelationsSpec, Zi as isSeedDefinition, ee as isSqliteFamily, ue as isView, w as json, Kr as jsonField, r as jsonIndex, Ke as lag, Qe as lead, ma as listRetentions, Mr as lt, Nr as lte, Oi as makeNamespaceBranchExecutor, wt as many, Tt as manyToMany, a as materializeFields, fe as max, Re as migration, Xe as min, ie as mixin, kr as neq, hi as nextBranchState, Gr as not, Zr as notExists, Fr as notInSet, Yr as notInSubquery, Ye as numeric, Ct as one, qt as oneCardinalityMessage, Wr as or, C as paginateBy, i as paginateById, Si as planBranch, gi as planBranchProvision, _i as planBranchTeardown, Ci as planBranchTeardownFor, bi as planNeonBranchProvision, xi as planNeonBranchTeardown, ua as primaryKeyConflictError, Ti as provisionBranch, zi as provisionResidentTenant, dn as qualifyTable, Je as queryFor, Ne as queryForView, $e as quoteIdent, la as raiseChangeListenerCeiling, te as rank, ne as raw, l as real, s as reference, Cr as registerCoreTables, Mt as registerDiscoveredRelations, jt as registerRelations, pa as registerRetention, p as registerTable, xt as relations, Tr as requireActors, g as requireTable, Er as requireTenants, ae as resetSnowflake, Li as residentPlacement, yi as resolveBranchMechanism, c as resolveFullTextIndex, m as resolveIdScheme, d as resolveMixinGraph, Fi as resolveTenantHome, un as resolveTenantNamespace, _a as retentionTtlMsFromEnv, o as rowNumber, gt as rowSchema, ln as sanitizeIdentifierFragment, ct as serializeArraysForWrite, Mi as setResidencyConfig, Hr as spatialPredicate, ai as streamTable, y as sum, Ee as sumOver, ga as sweepRetention, T as table, Ei as teardownBranch, b as text, O as timestamp, et as timestampMs, tt as timestampMsOrNull, t as union, Te as unionAll, _e as validateColumnName, Ue as validateIndexName, It as validateRegisteredRelations, Ot as validateRelationConfig, Me as validateTableName, ze as validateTypeIdPrefix, n as vector, f as vectorDistanceToOpclass, ci as vectorEmbedding, Be as view, pe as viewSql, ti as walkLeaves };
|