@voltro/database 0.83.1 → 0.84.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 +642 -0
- package/dist/index.d.ts +67 -33
- package/dist/index.js +657 -654
- package/dist/replaceInProgress-DUHl5JEz.js +3557 -0
- package/dist/sql.d.ts +196 -0
- package/dist/sql.js +2613 -1529
- package/package.json +2 -2
- package/dist/replaceInProgress-Z1aAw3GD.js +0 -2365
package/dist/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { $ as e, $n as t, $
|
|
2
|
-
import { a as
|
|
3
|
-
import { Cause as
|
|
4
|
-
import { createHash as
|
|
5
|
-
import { AsyncLocalStorage as
|
|
6
|
-
import { TransactionConnection as
|
|
7
|
-
import { ansi as
|
|
8
|
-
import { SqlClient as
|
|
1
|
+
import { $ as e, $n as t, $r as n, $t as r, A as i, An as a, Ar as o, At as s, B as c, Bn as l, Br as u, Bt as d, C as f, Cn as p, Cr as m, Ct as h, D as g, Dn as _, Dr as v, Dt as ee, E as te, En as ne, Er as re, Et as ie, F as ae, Fn as oe, Fr as se, G as ce, Gn as le, Gr as y, H as ue, Hn as de, Hr as fe, Ht as pe, I as me, In as he, Ir as ge, It as _e, J as ve, Jn as ye, Jr as be, K as xe, Kn as Se, Kr as Ce, Kt as we, L as Te, Ln as Ee, Lr as De, Lt as Oe, M as ke, Mn as Ae, Mr as je, Mt as Me, N as Ne, Nn as Pe, Nr as Fe, Nt as Ie, O as Le, On as Re, Or as ze, Ot as Be, P as Ve, Pn as He, Pr as Ue, Pt as We, Q as Ge, Qn as Ke, Qr as b, R as qe, Rn as Je, Rr as Ye, Rt as Xe, S as Ze, Sn as Qe, Sr as $e, St as et, T as tt, Tn as nt, Tr as rt, Tt as it, U as at, Un as ot, Ur as st, Ut as ct, V as lt, Vn as x, Vr as ut, Vt as dt, W as ft, Wn as pt, Wr as mt, Wt as ht, X as gt, Xn as _t, Xr as vt, Y as yt, Yn as bt, Yr as xt, Z as St, Zn as Ct, Zr as wt, _ as Tt, _n as Et, _r as Dt, _t as Ot, a as kt, an as At, ar as jt, at as Mt, b as Nt, bn as Pt, br as Ft, bt as It, c as Lt, cn as Rt, cr as zt, ct as Bt, d as Vt, dn as Ht, dr as Ut, dt as Wt, ei as Gt, en as Kt, er as qt, et as Jt, f as Yt, fn as Xt, fr as Zt, ft as Qt, g as $t, gn as S, gr as en, gt as tn, h as nn, hn as rn, hr as an, ht as on, i as sn, in as cn, ir as C, it as ln, j as un, jn as dn, jr as fn, jt as pn, kn as mn, kr as hn, kt as gn, l as _n, ln as vn, lr as yn, lt as bn, m as xn, mn as Sn, mr as Cn, mt as wn, n as Tn, nn as En, nr as Dn, nt as On, o as kn, on as An, or as jn, ot as Mn, p as Nn, pn as Pn, pr as Fn, pt as In, q as Ln, qn as Rn, qr as zn, r as Bn, rn as Vn, rr as Hn, rt as Un, s as Wn, sn as Gn, sr as Kn, st as qn, t as Jn, tn as Yn, tr as Xn, tt as Zn, u as Qn, un as $n, ur as er, ut as tr, v as nr, vn as rr, vr as ir, vt as ar, w as or, wn as sr, wr as cr, wt as lr, x as ur, xn as dr, xr as fr, xt as pr, y as mr, yn as hr, yr as gr, yt as _r, z as vr, zn as yr, zr as br, zt as xr } from "./replaceInProgress-DUHl5JEz.js";
|
|
2
|
+
import { a as Sr, i as Cr, n as wr, o as Tr, r as Er, s as Dr, t as Or } from "./wire-B28cPjEp.js";
|
|
3
|
+
import { Cause as kr, Chunk as Ar, Data as jr, Effect as w, Exit as Mr, Metric as T, MetricBoundaries as Nr, Option as E, Schedule as Pr, Schema as D, Stream as Fr } from "effect";
|
|
4
|
+
import { createHash as Ir } from "node:crypto";
|
|
5
|
+
import { AsyncLocalStorage as Lr } from "node:async_hooks";
|
|
6
|
+
import { TransactionConnection as Rr } from "@effect/sql/SqlClient";
|
|
7
|
+
import { ansi as O } from "@voltro/logger";
|
|
8
|
+
import { SqlClient as zr } from "@effect/sql";
|
|
9
9
|
//#region src/actorSnapshot.ts
|
|
10
|
-
var
|
|
10
|
+
var Br = (e) => typeof e == "string" && e !== "" ? e : null, Vr = async (e, t, n) => {
|
|
11
11
|
if (t != null && t !== "") try {
|
|
12
12
|
let r = (await e.query({
|
|
13
13
|
table: "actors",
|
|
@@ -23,20 +23,20 @@ var Nr = (e) => typeof e == "string" && e !== "" ? e : null, Pr = async (e, t, n
|
|
|
23
23
|
}))[0];
|
|
24
24
|
return r === void 0 ? void 0 : {
|
|
25
25
|
id: t,
|
|
26
|
-
type:
|
|
27
|
-
displayName:
|
|
28
|
-
email:
|
|
26
|
+
type: Br(r.kind) ?? n,
|
|
27
|
+
displayName: Br(r.displayName),
|
|
28
|
+
email: Br(r.email)
|
|
29
29
|
};
|
|
30
30
|
} catch {
|
|
31
31
|
return;
|
|
32
32
|
}
|
|
33
|
-
},
|
|
33
|
+
}, Hr = (e) => e === "mysql" || e === "mariadb" || e === "mssql" || e === "sqlite", Ur = (e) => {
|
|
34
34
|
let t = [];
|
|
35
35
|
for (let [n, r] of Object.entries(e.fields)) r.type === "array" && t.push(n);
|
|
36
36
|
return t;
|
|
37
|
-
},
|
|
38
|
-
if (!
|
|
39
|
-
let r =
|
|
37
|
+
}, Wr = (e, t, n) => {
|
|
38
|
+
if (!Hr(n) || !t) return e;
|
|
39
|
+
let r = Ur(t);
|
|
40
40
|
if (r.length === 0) return e;
|
|
41
41
|
let i = { ...e };
|
|
42
42
|
for (let e of r) {
|
|
@@ -44,9 +44,9 @@ var Nr = (e) => typeof e == "string" && e !== "" ? e : null, Pr = async (e, t, n
|
|
|
44
44
|
Array.isArray(t) && (i[e] = JSON.stringify(t));
|
|
45
45
|
}
|
|
46
46
|
return i;
|
|
47
|
-
},
|
|
48
|
-
if (!
|
|
49
|
-
let r =
|
|
47
|
+
}, Gr = (e, t, n) => {
|
|
48
|
+
if (!Hr(n) || !t) return e;
|
|
49
|
+
let r = Ur(t);
|
|
50
50
|
return r.length === 0 ? e : e.map((e) => {
|
|
51
51
|
let t;
|
|
52
52
|
for (let n of r) {
|
|
@@ -58,13 +58,13 @@ var Nr = (e) => typeof e == "string" && e !== "" ? e : null, Pr = async (e, t, n
|
|
|
58
58
|
}
|
|
59
59
|
return t ?? e;
|
|
60
60
|
});
|
|
61
|
-
},
|
|
61
|
+
}, Kr = "enc:v1:", qr = "enc:v2:", Jr = (e, t, n) => {
|
|
62
62
|
let r = `${e}:${t}`, i = n == null || n === "" ? void 0 : String(n);
|
|
63
63
|
return i === void 0 ? { column: r } : {
|
|
64
64
|
column: r,
|
|
65
65
|
row: `${r}:${i}`
|
|
66
66
|
};
|
|
67
|
-
},
|
|
67
|
+
}, Yr = (e) => typeof e == "string" && e.startsWith("enc:v2:"), Xr = class extends Error {
|
|
68
68
|
_tag = "FieldDecryptionError";
|
|
69
69
|
table;
|
|
70
70
|
column;
|
|
@@ -72,7 +72,7 @@ var Nr = (e) => typeof e == "string" && e !== "" ? e : null, Pr = async (e, t, n
|
|
|
72
72
|
constructor(e) {
|
|
73
73
|
super(`column "${e.table}.${e.column}" is .encrypted() but could not be decrypted (${e.reason}) — the stored value was most likely encrypted under a different key`), this.name = "FieldDecryptionError", this.table = e.table, this.column = e.column, this.reason = e.reason;
|
|
74
74
|
}
|
|
75
|
-
},
|
|
75
|
+
}, Zr = (e) => typeof e == "object" && !!e && e._tag === "FieldDecryptionError", Qr = (e) => typeof e == "string" && (e.startsWith("enc:v1:") || e.startsWith("enc:v2:")), $r = (e, t, n) => e.encrypt(JSON.stringify(t), n), ei = /* @__PURE__ */ new Set([
|
|
76
76
|
"text",
|
|
77
77
|
"id",
|
|
78
78
|
"reference",
|
|
@@ -80,51 +80,51 @@ var Nr = (e) => typeof e == "string" && e !== "" ? e : null, Pr = async (e, t, n
|
|
|
80
80
|
"uuid",
|
|
81
81
|
"email",
|
|
82
82
|
"url"
|
|
83
|
-
]),
|
|
83
|
+
]), ti = (e, t, n, r) => {
|
|
84
84
|
let i = e.decrypt(t, r), a;
|
|
85
85
|
try {
|
|
86
86
|
a = JSON.parse(i);
|
|
87
87
|
} catch {
|
|
88
88
|
return i;
|
|
89
89
|
}
|
|
90
|
-
return typeof a == "string" ? a : n === void 0 ||
|
|
91
|
-
},
|
|
90
|
+
return typeof a == "string" ? a : n === void 0 || ei.has(n) ? i : a;
|
|
91
|
+
}, ni = (e, t, n, r) => {
|
|
92
92
|
let i = e.decrypt(t, r);
|
|
93
93
|
try {
|
|
94
|
-
return typeof JSON.parse(i) == "string" ? !1 : n === void 0 ||
|
|
94
|
+
return typeof JSON.parse(i) == "string" ? !1 : n === void 0 || ei.has(n) ? !0 : void 0;
|
|
95
95
|
} catch {
|
|
96
96
|
return !0;
|
|
97
97
|
}
|
|
98
|
-
},
|
|
98
|
+
}, ri = (e, t) => e.fields[t]?.type, ii = (e) => {
|
|
99
99
|
let t = [];
|
|
100
100
|
for (let [n, r] of Object.entries(e.fields)) r.encrypted === !0 && t.push(n);
|
|
101
101
|
return t;
|
|
102
|
-
},
|
|
102
|
+
}, ai = "id", oi = (e, t, n, r) => {
|
|
103
103
|
if (!t) return e;
|
|
104
|
-
let i =
|
|
104
|
+
let i = ii(t);
|
|
105
105
|
if (i.length === 0) return e;
|
|
106
|
-
let a = t.tableName ?? "?", o = r ?? e[
|
|
106
|
+
let a = t.tableName ?? "?", o = r ?? e[ai], s = { ...e };
|
|
107
107
|
for (let e of i) {
|
|
108
108
|
let t = s[e];
|
|
109
|
-
if (!(t == null ||
|
|
109
|
+
if (!(t == null || Qr(t))) {
|
|
110
110
|
if (!n) throw Error(`column "${a}.${e}" is .encrypted() but no field cipher is registered — set VOLTRO_FIELD_ENCRYPTION_KEY (\`voltro dev\` mints one; \`voltro serve\` refuses to boot without it); in a test, pass \`fieldEncryptionKey\` to makeTestContext`);
|
|
111
|
-
s[e] =
|
|
111
|
+
s[e] = $r(n, t, Jr(a, e, o));
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
114
|
return s;
|
|
115
|
-
},
|
|
115
|
+
}, si = (e, t, n, r) => {
|
|
116
116
|
if (!t) return e;
|
|
117
|
-
let i =
|
|
117
|
+
let i = ii(t);
|
|
118
118
|
if (i.length === 0 || !n) return e;
|
|
119
119
|
let a = r?.onError ?? "throw", o = t.tableName ?? "?";
|
|
120
120
|
return e.map((e) => {
|
|
121
121
|
let s;
|
|
122
122
|
for (let c of i) {
|
|
123
123
|
let i = e[c];
|
|
124
|
-
if (
|
|
124
|
+
if (Qr(i)) {
|
|
125
125
|
s ??= { ...e };
|
|
126
126
|
try {
|
|
127
|
-
s[c] =
|
|
127
|
+
s[c] = ti(n, i, ri(t, c), Jr(o, c, r?.rowId ?? e[ai]));
|
|
128
128
|
} catch (e) {
|
|
129
129
|
let t = String(e?.message ?? e);
|
|
130
130
|
if (a === "null") {
|
|
@@ -135,7 +135,7 @@ var Nr = (e) => typeof e == "string" && e !== "" ? e : null, Pr = async (e, t, n
|
|
|
135
135
|
});
|
|
136
136
|
continue;
|
|
137
137
|
}
|
|
138
|
-
throw new
|
|
138
|
+
throw new Xr({
|
|
139
139
|
table: o,
|
|
140
140
|
column: c,
|
|
141
141
|
reason: t
|
|
@@ -145,77 +145,77 @@ var Nr = (e) => typeof e == "string" && e !== "" ? e : null, Pr = async (e, t, n
|
|
|
145
145
|
}
|
|
146
146
|
return s ?? e;
|
|
147
147
|
});
|
|
148
|
-
},
|
|
149
|
-
let t =
|
|
150
|
-
return Object.defineProperty(t,
|
|
148
|
+
}, ci = Symbol.for("@voltro/database/storeRefusal"), li = (e) => {
|
|
149
|
+
let t = C(e.detail);
|
|
150
|
+
return Object.defineProperty(t, ci, {
|
|
151
151
|
value: e,
|
|
152
152
|
enumerable: !1
|
|
153
153
|
}), t;
|
|
154
|
-
},
|
|
155
|
-
for (let t of
|
|
154
|
+
}, ui = (e) => {
|
|
155
|
+
for (let t of jn(e)) {
|
|
156
156
|
let e = t;
|
|
157
157
|
for (let t = 0; e != null && t < 8; t += 1) {
|
|
158
|
-
let t = e[
|
|
158
|
+
let t = e[ci];
|
|
159
159
|
if (t !== void 0) return t;
|
|
160
160
|
e = e.cause;
|
|
161
161
|
}
|
|
162
162
|
}
|
|
163
|
-
},
|
|
163
|
+
}, di = (e) => {
|
|
164
164
|
let t = (() => {
|
|
165
165
|
switch (e.type) {
|
|
166
|
-
case "id": return e.idScheme?.kind === "numeric" ?
|
|
166
|
+
case "id": return e.idScheme?.kind === "numeric" ? D.Number : D.String;
|
|
167
167
|
case "text":
|
|
168
|
-
case "enum": return
|
|
169
|
-
case "reference": return e.referenceStorage === "numeric" ?
|
|
168
|
+
case "enum": return D.String;
|
|
169
|
+
case "reference": return e.referenceStorage === "numeric" ? D.Number : D.String;
|
|
170
170
|
case "integer":
|
|
171
171
|
case "real":
|
|
172
|
-
case "decimal": return
|
|
173
|
-
case "boolean": return
|
|
172
|
+
case "decimal": return D.Number;
|
|
173
|
+
case "boolean": return D.Boolean;
|
|
174
174
|
case "timestamp":
|
|
175
|
-
case "date": return
|
|
176
|
-
case "bigint": return
|
|
177
|
-
case "bytes": return
|
|
178
|
-
case "array": return
|
|
179
|
-
case "interval": return
|
|
180
|
-
default: return
|
|
175
|
+
case "date": return Or;
|
|
176
|
+
case "bigint": return D.BigInt;
|
|
177
|
+
case "bytes": return D.Uint8ArrayFromBase64;
|
|
178
|
+
case "array": return D.Array(D.Unknown);
|
|
179
|
+
case "interval": return D.String;
|
|
180
|
+
default: return D.Unknown;
|
|
181
181
|
}
|
|
182
182
|
})();
|
|
183
|
-
return e.nullable === !0 ?
|
|
184
|
-
},
|
|
183
|
+
return e.nullable === !0 ? D.NullOr(t) : t;
|
|
184
|
+
}, fi = (e, t) => {
|
|
185
185
|
let n = new Set(t?.omit ?? []), r = {};
|
|
186
|
-
for (let [t, i] of Object.entries(e.fields)) n.has(t) || (r[t] =
|
|
187
|
-
return
|
|
188
|
-
},
|
|
186
|
+
for (let [t, i] of Object.entries(e.fields)) n.has(t) || (r[t] = di(i));
|
|
187
|
+
return D.Struct(r);
|
|
188
|
+
}, pi = (e) => typeof e == "function" ? e : () => e, mi = (e, t) => ({
|
|
189
189
|
kind: "one",
|
|
190
|
-
target:
|
|
190
|
+
target: pi(e),
|
|
191
191
|
...t?.foreignKey === void 0 ? {} : { foreignKey: t.foreignKey },
|
|
192
192
|
...t?.sourceKey === void 0 ? {} : { sourceKey: t.sourceKey }
|
|
193
|
-
}),
|
|
193
|
+
}), hi = (e, t) => ({
|
|
194
194
|
kind: "many",
|
|
195
|
-
target:
|
|
195
|
+
target: pi(e),
|
|
196
196
|
...t?.foreignKey === void 0 ? {} : { foreignKey: t.foreignKey },
|
|
197
197
|
...t?.sourceKey === void 0 ? {} : { sourceKey: t.sourceKey }
|
|
198
|
-
}),
|
|
198
|
+
}), gi = (e, t) => ({
|
|
199
199
|
kind: "manyToMany",
|
|
200
|
-
target:
|
|
201
|
-
through:
|
|
200
|
+
target: pi(e),
|
|
201
|
+
through: pi(t.through),
|
|
202
202
|
sourceKey: t.sourceKey,
|
|
203
203
|
targetKey: t.targetKey
|
|
204
|
-
}),
|
|
205
|
-
one:
|
|
206
|
-
many:
|
|
207
|
-
manyToMany:
|
|
208
|
-
},
|
|
204
|
+
}), _i = {
|
|
205
|
+
one: mi,
|
|
206
|
+
many: hi,
|
|
207
|
+
manyToMany: gi
|
|
208
|
+
}, vi = (e, t) => {
|
|
209
209
|
let n = typeof e == "function" ? e : () => e;
|
|
210
210
|
return {
|
|
211
211
|
source: n,
|
|
212
|
-
relations: t(
|
|
212
|
+
relations: t(_i, n())
|
|
213
213
|
};
|
|
214
|
-
},
|
|
214
|
+
}, yi = (e) => {
|
|
215
215
|
if (typeof e != "object" || !e) return !1;
|
|
216
216
|
let t = e;
|
|
217
217
|
return typeof t.source != "function" || typeof t.relations != "object" || t.relations === null ? !1 : Object.keys(t.relations).length === 0;
|
|
218
|
-
},
|
|
218
|
+
}, bi = (e) => {
|
|
219
219
|
if (typeof e != "object" || !e) return !1;
|
|
220
220
|
let t = e;
|
|
221
221
|
if (typeof t.source != "function" || typeof t.relations != "object" || t.relations === null) return !1;
|
|
@@ -224,35 +224,35 @@ var Nr = (e) => typeof e == "string" && e !== "" ? e : null, Pr = async (e, t, n
|
|
|
224
224
|
let t = e?.kind;
|
|
225
225
|
return t === "one" || t === "many" || t === "manyToMany";
|
|
226
226
|
});
|
|
227
|
-
},
|
|
227
|
+
}, xi = mi, Si = hi, Ci = gi, k = (e, t, n) => {
|
|
228
228
|
let r = [];
|
|
229
229
|
for (let [n, i] of Object.entries(e.fields)) i.type === "reference" && i.references?.()?.tableName === t && r.push(n);
|
|
230
|
-
if (r.length === 0) throw
|
|
231
|
-
if (r.length > 1) throw
|
|
230
|
+
if (r.length === 0) throw C(`relation '${n}': no reference() column on '${e.tableName}' points at '${t}'. Either add one or pass an explicit { foreignKey: '<column>' }.`);
|
|
231
|
+
if (r.length > 1) throw C(`relation '${n}': multiple reference() columns on '${e.tableName}' point at '${t}' (${r.join(", ")}). Pass an explicit { foreignKey: '<column>' } to disambiguate.`);
|
|
232
232
|
return r[0];
|
|
233
|
-
},
|
|
234
|
-
let t =
|
|
233
|
+
}, wi = (e) => Object.keys(e.fields), Ti = (e, t) => Object.prototype.hasOwnProperty.call(e.fields, t), Ei = (e) => {
|
|
234
|
+
let t = wi(e);
|
|
235
235
|
return t.length === 0 ? "<none>" : t.join(", ");
|
|
236
|
-
},
|
|
236
|
+
}, Di = (e, t, n) => {
|
|
237
237
|
let r = `relation '${t}' on '${e.tableName}'`, i = n.target();
|
|
238
238
|
if (n.kind === "manyToMany") {
|
|
239
239
|
let t = n.through();
|
|
240
|
-
for (let [a, o] of [["sourceKey", n.sourceKey], ["targetKey", n.targetKey]]) if (!
|
|
240
|
+
for (let [a, o] of [["sourceKey", n.sourceKey], ["targetKey", n.targetKey]]) if (!Ti(t, o)) throw C(`${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}': ${Ei(t)}.`);
|
|
241
241
|
return;
|
|
242
242
|
}
|
|
243
|
-
if (n.sourceKey !== void 0 && n.foreignKey !== void 0) throw
|
|
244
|
-
if (n.sourceKey !== void 0 && !
|
|
245
|
-
let t =
|
|
246
|
-
throw
|
|
243
|
+
if (n.sourceKey !== void 0 && n.foreignKey !== void 0) throw C(`${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.`);
|
|
244
|
+
if (n.sourceKey !== void 0 && !Ti(e, n.sourceKey)) {
|
|
245
|
+
let t = Ti(i, n.sourceKey);
|
|
246
|
+
throw C(`${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}': ${Ei(e)}.`));
|
|
247
247
|
}
|
|
248
|
-
if (n.foreignKey !== void 0 && !
|
|
249
|
-
let t =
|
|
250
|
-
throw
|
|
248
|
+
if (n.foreignKey !== void 0 && !Ti(i, n.foreignKey)) {
|
|
249
|
+
let t = Ti(e, n.foreignKey);
|
|
250
|
+
throw C(`${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}': ${Ei(i)}.`));
|
|
251
251
|
}
|
|
252
|
-
},
|
|
253
|
-
let t = e.source(), n =
|
|
252
|
+
}, Oi = Symbol.for("@voltro/database/relationsRegistry"), ki = globalThis, A = ki[Oi] ?? (ki[Oi] = /* @__PURE__ */ new Map()), Ai = (e) => {
|
|
253
|
+
let t = e.source(), n = A.get(t.tableName);
|
|
254
254
|
if (n === void 0) {
|
|
255
|
-
|
|
255
|
+
A.set(t.tableName, new Map(Object.entries(e.relations)));
|
|
256
256
|
return;
|
|
257
257
|
}
|
|
258
258
|
for (let [r, i] of Object.entries(e.relations)) {
|
|
@@ -262,33 +262,33 @@ var Nr = (e) => typeof e == "string" && e !== "" ? e : null, Pr = async (e, t, n
|
|
|
262
262
|
n.set(r, i);
|
|
263
263
|
}
|
|
264
264
|
}
|
|
265
|
-
},
|
|
265
|
+
}, ji = (e) => {
|
|
266
266
|
let t = 0;
|
|
267
|
-
for (let n of Object.values(e))
|
|
267
|
+
for (let n of Object.values(e)) bi(n) && (Ai(n), t += 1);
|
|
268
268
|
return t;
|
|
269
|
-
},
|
|
270
|
-
let t =
|
|
269
|
+
}, Mi = (e) => {
|
|
270
|
+
let t = A.get(e);
|
|
271
271
|
if (t !== void 0) return Object.fromEntries(t);
|
|
272
|
-
},
|
|
272
|
+
}, Ni = (e, t) => A.get(e)?.get(t), Pi = () => {
|
|
273
273
|
let e = [];
|
|
274
|
-
for (let [t, n] of
|
|
274
|
+
for (let [t, n] of A) for (let [r, i] of n) e.push({
|
|
275
275
|
source: t,
|
|
276
276
|
name: r,
|
|
277
277
|
relation: i
|
|
278
278
|
});
|
|
279
279
|
return e;
|
|
280
|
-
},
|
|
281
|
-
for (let [e, t] of
|
|
282
|
-
let n =
|
|
283
|
-
if (n !== void 0) for (let [e, r] of t)
|
|
284
|
-
}
|
|
285
|
-
},
|
|
286
|
-
|
|
287
|
-
},
|
|
280
|
+
}, Fi = () => {
|
|
281
|
+
for (let [e, t] of A) {
|
|
282
|
+
let n = a(e);
|
|
283
|
+
if (n !== void 0) for (let [e, r] of t) Di(n, e, r);
|
|
284
|
+
}
|
|
285
|
+
}, Ii = () => {
|
|
286
|
+
A.clear();
|
|
287
|
+
}, Li = 4, Ri = (e) => Object.keys(e.fields), zi = (e, t) => Object.prototype.hasOwnProperty.call(e.fields, t), Bi = (e, t) => {
|
|
288
288
|
let n = [];
|
|
289
289
|
for (let [r, i] of Object.entries(e.fields)) i.type === "reference" && i.references?.()?.tableName === t && n.push(r);
|
|
290
290
|
return n;
|
|
291
|
-
},
|
|
291
|
+
}, Vi = (e, t) => {
|
|
292
292
|
let n = [];
|
|
293
293
|
for (let r of t) {
|
|
294
294
|
if (r.source !== e) continue;
|
|
@@ -305,7 +305,7 @@ var Nr = (e) => typeof e == "string" && e !== "" ? e : null, Pr = async (e, t, n
|
|
|
305
305
|
} catch {
|
|
306
306
|
continue;
|
|
307
307
|
}
|
|
308
|
-
if (!
|
|
308
|
+
if (!zi(e, t.sourceKey)) continue;
|
|
309
309
|
n.push({
|
|
310
310
|
table: e.tableName,
|
|
311
311
|
foreignKey: t.sourceKey,
|
|
@@ -314,8 +314,8 @@ var Nr = (e) => typeof e == "string" && e !== "" ? e : null, Pr = async (e, t, n
|
|
|
314
314
|
continue;
|
|
315
315
|
}
|
|
316
316
|
if (t.sourceKey !== void 0) continue;
|
|
317
|
-
let a =
|
|
318
|
-
if (o === void 0 || !
|
|
317
|
+
let a = Bi(i, e), o = t.foreignKey ?? (a.length === 1 ? a[0] : void 0);
|
|
318
|
+
if (o === void 0 || !zi(i, o)) continue;
|
|
319
319
|
let s = i.fields[o];
|
|
320
320
|
n.push({
|
|
321
321
|
table: i.tableName,
|
|
@@ -324,9 +324,9 @@ var Nr = (e) => typeof e == "string" && e !== "" ? e : null, Pr = async (e, t, n
|
|
|
324
324
|
});
|
|
325
325
|
}
|
|
326
326
|
return n;
|
|
327
|
-
},
|
|
327
|
+
}, Hi = (e, t) => {
|
|
328
328
|
let n = [];
|
|
329
|
-
for (let r of t) if (r.tableName !== e) for (let t of
|
|
329
|
+
for (let r of t) if (r.tableName !== e) for (let t of Bi(r, e)) {
|
|
330
330
|
let e = r.fields[t];
|
|
331
331
|
n.push({
|
|
332
332
|
table: r.tableName,
|
|
@@ -335,8 +335,8 @@ var Nr = (e) => typeof e == "string" && e !== "" ? e : null, Pr = async (e, t, n
|
|
|
335
335
|
});
|
|
336
336
|
}
|
|
337
337
|
return n;
|
|
338
|
-
},
|
|
339
|
-
let t = e.tables ??
|
|
338
|
+
}, Ui = (e) => `${e.table}\u0000${e.hops.map((e) => `${e.table}.${e.foreignKey}<-${e.parentKey}`).join("|")}`, Wi = (e) => {
|
|
339
|
+
let t = e.tables ?? _(), n = e.relations ?? Pi(), r = e.maxDepth ?? 4, i = new Set(e.exclude ?? []), a = new Map(t.map((e) => [e.tableName, e])), o = [];
|
|
340
340
|
if (!a.has(e.subjectTable)) return {
|
|
341
341
|
subjectTable: e.subjectTable,
|
|
342
342
|
paths: [],
|
|
@@ -351,11 +351,11 @@ var Nr = (e) => typeof e == "string" && e !== "" ? e : null, Pr = async (e, t, n
|
|
|
351
351
|
hops: [],
|
|
352
352
|
depth: 0,
|
|
353
353
|
via: "relation"
|
|
354
|
-
}, c = [s], l = /* @__PURE__ */ new Set([
|
|
354
|
+
}, c = [s], l = /* @__PURE__ */ new Set([Ui(s)]), u = /* @__PURE__ */ new Set(), d = [s];
|
|
355
355
|
for (let e = 1; e <= r; e++) {
|
|
356
356
|
let r = [];
|
|
357
357
|
for (let a of d) {
|
|
358
|
-
let s =
|
|
358
|
+
let s = Vi(a.table, n), d = Hi(a.table, t), f = [...s.map((e) => [e, "relation"]), ...d.map((e) => [e, "reference"])];
|
|
359
359
|
for (let [t, n] of f) {
|
|
360
360
|
if (i.has(t.table)) {
|
|
361
361
|
o.push({
|
|
@@ -373,7 +373,7 @@ var Nr = (e) => typeof e == "string" && e !== "" ? e : null, Pr = async (e, t, n
|
|
|
373
373
|
hops: [...a.hops, t],
|
|
374
374
|
depth: e,
|
|
375
375
|
via: n
|
|
376
|
-
}, f =
|
|
376
|
+
}, f = Ui(d);
|
|
377
377
|
l.has(f) || (l.add(f), c.push(d), r.push(d));
|
|
378
378
|
}
|
|
379
379
|
}
|
|
@@ -383,7 +383,7 @@ var Nr = (e) => typeof e == "string" && e !== "" ? e : null, Pr = async (e, t, n
|
|
|
383
383
|
}
|
|
384
384
|
d = r;
|
|
385
385
|
}
|
|
386
|
-
for (let e of d) (
|
|
386
|
+
for (let e of d) (Vi(e.table, n).length > 0 || Hi(e.table, t).length > 0) && o.push({
|
|
387
387
|
kind: "depth-truncated",
|
|
388
388
|
table: e.table,
|
|
389
389
|
detail: `stopped at maxDepth ${r}; tables linked FROM '${e.table}' were not explored`
|
|
@@ -392,14 +392,14 @@ var Nr = (e) => typeof e == "string" && e !== "" ? e : null, Pr = async (e, t, n
|
|
|
392
392
|
for (let n of t) f.has(n.tableName) || i.has(n.tableName) || o.push({
|
|
393
393
|
kind: "unreachable",
|
|
394
394
|
table: n.tableName,
|
|
395
|
-
detail: `no relation() and no reference() column links '${n.tableName}' to '${e.subjectTable}'. If it holds subject data through a plain column, a polymorphic (type,id) pair, JSON or free text, add an explicit subjectScopes entry — this derivation cannot see it. Columns: ${
|
|
395
|
+
detail: `no relation() and no reference() column links '${n.tableName}' to '${e.subjectTable}'. If it holds subject data through a plain column, a polymorphic (type,id) pair, JSON or free text, add an explicit subjectScopes entry — this derivation cannot see it. Columns: ${Ri(n).join(", ")}`
|
|
396
396
|
});
|
|
397
397
|
return {
|
|
398
398
|
subjectTable: e.subjectTable,
|
|
399
399
|
paths: c,
|
|
400
400
|
limitations: o
|
|
401
401
|
};
|
|
402
|
-
},
|
|
402
|
+
}, Gi = (e) => {
|
|
403
403
|
let t = [`subject graph · ${e.subjectTable} · ${e.paths.length} table(s) reachable`];
|
|
404
404
|
for (let n of e.paths) {
|
|
405
405
|
let r = n.hops.length === 0 ? `${e.subjectTable} (the subject row itself)` : [e.subjectTable, ...n.hops.map((e) => `${e.table}.${e.foreignKey}`)].join(" → ");
|
|
@@ -407,12 +407,12 @@ var Nr = (e) => typeof e == "string" && e !== "" ? e : null, Pr = async (e, t, n
|
|
|
407
407
|
}
|
|
408
408
|
let n = e.limitations.filter((e) => e.kind === "depth-truncated"), r = e.limitations.filter((e) => e.kind === "unreachable"), i = e.limitations.filter((e) => e.kind === "excluded");
|
|
409
409
|
return t.push(""), t.push(" WHAT THIS CANNOT SEE — a DSAR is only as complete as this list is short:"), n.length > 0 && t.push(` depth-truncated (${n.length}): ${n.map((e) => e.table).join(", ")}`), i.length > 0 && t.push(` excluded (${i.length}): ${[...new Set(i.map((e) => e.table))].join(", ")}`), t.push(r.length === 0 ? " unreachable: none — every registered table is linked to the subject." : ` unreachable (${r.length}): ${r.map((e) => e.table).join(", ")}`), t.push(" Always outside this graph: object storage / uploaded files, external processors,"), t.push(" log and metric sinks, backups, and any subject id embedded in JSON or free text."), t.join("\n");
|
|
410
|
-
},
|
|
410
|
+
}, Ki = (e) => Object.fromEntries(Object.entries(e.updateValues ?? {}).filter(([t, n]) => {
|
|
411
411
|
if (n === void 0) return !1;
|
|
412
|
-
if (t === "id" || e.conflictColumns.includes(t)) throw
|
|
412
|
+
if (t === "id" || e.conflictColumns.includes(t)) throw C(`upsert: updateValues cannot rewrite row identity column '${t}'`);
|
|
413
413
|
return !0;
|
|
414
|
-
})),
|
|
415
|
-
let r =
|
|
414
|
+
})), qi = (e, t, n) => {
|
|
415
|
+
let r = Ki(n);
|
|
416
416
|
if (typeof n.update == "function") return {
|
|
417
417
|
...n.update(t),
|
|
418
418
|
...r
|
|
@@ -422,21 +422,21 @@ var Nr = (e) => typeof e == "string" && e !== "" ? e : null, Pr = async (e, t, n
|
|
|
422
422
|
...Object.fromEntries(i.filter((t) => t in e).map((t) => [t, e[t]])),
|
|
423
423
|
...r
|
|
424
424
|
};
|
|
425
|
-
},
|
|
425
|
+
}, Ji = (e) => typeof e == "string" ? [["id", e]] : Object.entries(e).map(([e, t]) => [e, t]), Yi = (e) => {
|
|
426
426
|
if (typeof e == "string") return e;
|
|
427
427
|
let t = Object.entries(e);
|
|
428
428
|
return t.length === 1 ? String(t[0][1]) : t.slice().sort(([e], [t]) => e < t ? -1 : +(e > t)).map(([e, t]) => `${e}=${String(t)}`).join("\0");
|
|
429
|
-
},
|
|
430
|
-
let r = new Set(
|
|
429
|
+
}, Xi = (e) => typeof e != "string", Zi = (e, t, n) => {
|
|
430
|
+
let r = new Set(Ji(e).map(([e]) => e)), i = t.split(".")[0];
|
|
431
431
|
return Object.fromEntries(Object.entries(n ?? {}).filter(([e, t]) => {
|
|
432
432
|
if (t === void 0) return !1;
|
|
433
|
-
if (r.has(e) || e === i) throw
|
|
433
|
+
if (r.has(e) || e === i) throw C(`patchJson: additionalPatch cannot rewrite the primary key or patched JSON column '${e}'`);
|
|
434
434
|
return !0;
|
|
435
435
|
}));
|
|
436
|
-
},
|
|
437
|
-
let [r, ...i] = t.split("."), a =
|
|
436
|
+
}, Qi = (e) => typeof e == "object" && !!e && !Array.isArray(e), $i = (e) => JSON.parse(JSON.stringify(e ?? null)), ea = (e, t, n) => {
|
|
437
|
+
let [r, ...i] = t.split("."), a = $i(n), o = e[r], s = (e, t) => {
|
|
438
438
|
if (t === i.length) return a;
|
|
439
|
-
let n =
|
|
439
|
+
let n = Qi(e) ? e : {}, r = i[t], o = Object.hasOwn(n, r) ? n[r] : void 0;
|
|
440
440
|
return {
|
|
441
441
|
...n,
|
|
442
442
|
[r]: s(o, t + 1)
|
|
@@ -444,14 +444,14 @@ var Nr = (e) => typeof e == "string" && e !== "" ? e : null, Pr = async (e, t, n
|
|
|
444
444
|
};
|
|
445
445
|
return {
|
|
446
446
|
...e,
|
|
447
|
-
[r]: i.length === 0 ?
|
|
447
|
+
[r]: i.length === 0 ? Qi(o) && Qi(a) ? {
|
|
448
448
|
...o,
|
|
449
449
|
...a
|
|
450
450
|
} : a : s(o, 0)
|
|
451
451
|
};
|
|
452
|
-
},
|
|
453
|
-
let [a, ...o] = n.split("."), s = i ?? e`${e(a)}`, c =
|
|
454
|
-
if ((t === "sqlite" || t === "turso") && (o.some(l) || o.length === 0 &&
|
|
452
|
+
}, ta = (e, t, n, r, i) => {
|
|
453
|
+
let [a, ...o] = n.split("."), s = i ?? e`${e(a)}`, c = $i(r), l = (e) => /["\\\u0000-\u001f]/.test(e);
|
|
454
|
+
if ((t === "sqlite" || t === "turso") && (o.some(l) || o.length === 0 && Qi(c) && Object.keys(c).some(l))) {
|
|
455
455
|
let t = 0, n = (t) => e`CASE WHEN (SELECT _voltro_json_escape_probe.key FROM json_each(${String.raw`{"\u0061":0}`}) AS _voltro_json_escape_probe) = ${String.raw`\u0061`}
|
|
456
456
|
THEN json_extract('"' || replace(${t}.key, '"', ${String.raw`\"`}) || '"', '$')
|
|
457
457
|
ELSE ${t}.key END`, r = (r) => {
|
|
@@ -493,7 +493,7 @@ var Nr = (e) => typeof e == "string" && e !== "" ? e : null, Pr = async (e, t, n
|
|
|
493
493
|
return t === "mysql" || t === "mariadb" ? e`JSON_SET(${n}, ${o}, JSON_EXTRACT(${i}, '$'))` : t === "mssql" ? a === null ? e`JSON_MODIFY(JSON_MODIFY(${n}, ${o}, 0), ${`strict ${o}`}, NULL)` : typeof a == "boolean" ? e`JSON_MODIFY(${n}, ${o}, CAST(${+!!a} AS bit))` : typeof a == "string" || typeof a == "number" ? e`JSON_MODIFY(${n}, ${o}, ${a})` : e`JSON_MODIFY(${n}, ${o}, JSON_QUERY(${i}))` : e`json_set(${n}, ${o}, json(${i}))`;
|
|
494
494
|
}, v;
|
|
495
495
|
if (o.length === 0) {
|
|
496
|
-
if (!
|
|
496
|
+
if (!Qi(c)) v = g(c);
|
|
497
497
|
else {
|
|
498
498
|
v = h([]);
|
|
499
499
|
for (let [e, t] of Object.entries(c)) v = _(v, [e], g(t), t);
|
|
@@ -507,55 +507,55 @@ var Nr = (e) => typeof e == "string" && e !== "" ? e : null, Pr = async (e, t, n
|
|
|
507
507
|
v = _(v, o, g(c), c);
|
|
508
508
|
}
|
|
509
509
|
return e`${e(a)} = ${v}`;
|
|
510
|
-
},
|
|
510
|
+
}, na = class extends Error {
|
|
511
511
|
_tag = "EagerCardinalityError";
|
|
512
512
|
constructor(e) {
|
|
513
513
|
super(e), this.name = "EagerCardinalityError";
|
|
514
514
|
}
|
|
515
|
-
},
|
|
515
|
+
}, ra = (e) => {
|
|
516
516
|
let { relationName: t, sourceTableName: n, targetTableName: r, foreignKey: i, sourceKey: a } = e, o = r === n;
|
|
517
517
|
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.");
|
|
518
|
-
},
|
|
518
|
+
}, ia = async (e, t, n, r) => {
|
|
519
519
|
if (e.length === 0) return e;
|
|
520
|
-
let i =
|
|
521
|
-
if (i === void 0) throw
|
|
520
|
+
let i = Mi(n.tableName);
|
|
521
|
+
if (i === void 0) throw C(`cannot eager-load on '${n.tableName}': no relations registered. Did you forget to declare \`relations(${n.tableName}, ...)\` or import the file that does?`);
|
|
522
522
|
let a = e.map((e) => ({ ...e }));
|
|
523
523
|
for (let [e, o] of Object.entries(t)) {
|
|
524
524
|
let t = i[e];
|
|
525
525
|
if (t === void 0) {
|
|
526
526
|
let t = Object.keys(i).join(", ") || "<none>";
|
|
527
|
-
throw
|
|
527
|
+
throw C(`unknown relation '${e}' on '${n.tableName}'. Registered relations: ${t}.`);
|
|
528
528
|
}
|
|
529
|
-
|
|
529
|
+
Di(n, e, t), await aa(a, e, t, o === !0 ? {} : o, n, r);
|
|
530
530
|
}
|
|
531
531
|
return a;
|
|
532
|
-
},
|
|
532
|
+
}, aa = async (e, t, n, r, i, a) => {
|
|
533
533
|
switch (n.kind) {
|
|
534
534
|
case "one":
|
|
535
|
-
await
|
|
535
|
+
await oa(e, t, n, r, i, a);
|
|
536
536
|
return;
|
|
537
537
|
case "many":
|
|
538
|
-
await
|
|
538
|
+
await sa(e, t, n, r, i, a);
|
|
539
539
|
return;
|
|
540
540
|
case "manyToMany":
|
|
541
|
-
await
|
|
541
|
+
await la(e, t, n, r, i, a);
|
|
542
542
|
return;
|
|
543
543
|
}
|
|
544
|
-
},
|
|
545
|
-
let o = n.target(), s = n.sourceKey ??
|
|
544
|
+
}, oa = async (e, t, n, r, i, a) => {
|
|
545
|
+
let o = n.target(), s = n.sourceKey ?? ua(i, o.tableName);
|
|
546
546
|
if (s !== void 0) {
|
|
547
|
-
let n =
|
|
547
|
+
let n = M(e, s), c = n.length === 0 ? [] : await da(o, "id", n, r, a), l = new Map(c.map((e) => [j(o, "id", e.id), e]));
|
|
548
548
|
for (let n of e) {
|
|
549
|
-
let e = n[s];
|
|
550
|
-
n[t] = e == null ? null :
|
|
549
|
+
let e = j(i, s, n[s]);
|
|
550
|
+
n[t] = e == null ? null : l.get(e) ?? null;
|
|
551
551
|
}
|
|
552
|
-
await
|
|
552
|
+
await fa(c, r.with, o, a);
|
|
553
553
|
return;
|
|
554
554
|
}
|
|
555
|
-
let c = n.foreignKey ??
|
|
555
|
+
let c = n.foreignKey ?? k(o, i.tableName, t), l = n.sourceKey ?? "id", u = M(e, l), d = u.length === 0 ? [] : await da(o, c, u, r, a), f = /* @__PURE__ */ new Map();
|
|
556
556
|
for (let e of d) {
|
|
557
|
-
let n = e[c];
|
|
558
|
-
if (f.has(n)) throw new
|
|
557
|
+
let n = j(o, c, e[c]);
|
|
558
|
+
if (f.has(n)) throw new na(ra({
|
|
559
559
|
relationName: t,
|
|
560
560
|
sourceTableName: i.tableName,
|
|
561
561
|
targetTableName: o.tableName,
|
|
@@ -565,14 +565,14 @@ var Nr = (e) => typeof e == "string" && e !== "" ? e : null, Pr = async (e, t, n
|
|
|
565
565
|
f.set(n, e);
|
|
566
566
|
}
|
|
567
567
|
for (let n of e) {
|
|
568
|
-
let e = n[l];
|
|
568
|
+
let e = j(i, l, n[l]);
|
|
569
569
|
n[t] = e == null ? null : f.get(e) ?? null;
|
|
570
570
|
}
|
|
571
|
-
await
|
|
572
|
-
},
|
|
573
|
-
let o = n.target(), s = n.foreignKey ??
|
|
571
|
+
await fa(d, r.with, o, a);
|
|
572
|
+
}, sa = async (e, t, n, r, i, a) => {
|
|
573
|
+
let o = n.target(), s = n.foreignKey ?? k(o, i.tableName, t), c = n.sourceKey ?? "id", l = M(e, c), u = ca(r), d = l.length === 0 ? [] : await da(o, s, l, u, a), f = /* @__PURE__ */ new Map();
|
|
574
574
|
for (let e of d) {
|
|
575
|
-
let t = e[s], n = f.get(t);
|
|
575
|
+
let t = j(o, s, e[s]), n = f.get(t);
|
|
576
576
|
n ? n.push(e) : f.set(t, [e]);
|
|
577
577
|
}
|
|
578
578
|
if (r.limit !== void 0 || r.offset !== void 0) {
|
|
@@ -583,15 +583,15 @@ var Nr = (e) => typeof e == "string" && e !== "" ? e : null, Pr = async (e, t, n
|
|
|
583
583
|
}
|
|
584
584
|
}
|
|
585
585
|
for (let n of e) {
|
|
586
|
-
let e = n[c];
|
|
586
|
+
let e = j(i, c, n[c]);
|
|
587
587
|
n[t] = f.get(e) ?? [];
|
|
588
588
|
}
|
|
589
|
-
await
|
|
590
|
-
},
|
|
589
|
+
await fa(d, r.with, o, a);
|
|
590
|
+
}, ca = (e) => {
|
|
591
591
|
let { limit: t, offset: n, ...r } = e;
|
|
592
592
|
return r;
|
|
593
|
-
},
|
|
594
|
-
let o = n.target(), s = n.through(), c =
|
|
593
|
+
}, la = async (e, t, n, r, i, a) => {
|
|
594
|
+
let o = n.target(), s = n.through(), c = M(e, "id");
|
|
595
595
|
if (c.length === 0) {
|
|
596
596
|
for (let n of e) n[t] = [];
|
|
597
597
|
return;
|
|
@@ -612,11 +612,11 @@ var Nr = (e) => typeof e == "string" && e !== "" ? e : null, Pr = async (e, t, n
|
|
|
612
612
|
for (let n of e) n[t] = [];
|
|
613
613
|
return;
|
|
614
614
|
}
|
|
615
|
-
let f = await
|
|
616
|
-
await
|
|
617
|
-
let m = r.junction === void 0 ? void 0 : r.junction === !0 ?
|
|
615
|
+
let f = await da(o, "id", M(d, n.targetKey), r, a), p = new Map(f.map((e) => [j(o, "id", e.id), e]));
|
|
616
|
+
await fa(f, r.with, o, a);
|
|
617
|
+
let m = r.junction === void 0 ? void 0 : r.junction === !0 ? y(s) : r.junction, h = /* @__PURE__ */ new Map();
|
|
618
618
|
for (let e of d) {
|
|
619
|
-
let t = e[n.sourceKey], r = e[n.targetKey], i = p.get(r);
|
|
619
|
+
let t = j(s, n.sourceKey, e[n.sourceKey]), r = j(s, n.targetKey, e[n.targetKey]), i = p.get(r);
|
|
620
620
|
if (i === void 0) continue;
|
|
621
621
|
let a = m === void 0 ? i : {
|
|
622
622
|
...i,
|
|
@@ -624,17 +624,17 @@ var Nr = (e) => typeof e == "string" && e !== "" ? e : null, Pr = async (e, t, n
|
|
|
624
624
|
}, o = h.get(t);
|
|
625
625
|
o ? o.push(a) : h.set(t, [a]);
|
|
626
626
|
}
|
|
627
|
-
for (let n of e) n[t] = h.get(n.id) ?? [];
|
|
628
|
-
},
|
|
627
|
+
for (let n of e) n[t] = h.get(j(i, "id", n.id)) ?? [];
|
|
628
|
+
}, j = (e, t, n) => e.fields[t]?.type === "decimal" ? d(n) ?? n : n, ua = (e, t) => {
|
|
629
629
|
for (let [n, r] of Object.entries(e.fields)) if (r.type === "reference" && r.references?.()?.tableName === t) return n;
|
|
630
|
-
},
|
|
630
|
+
}, M = (e, t) => {
|
|
631
631
|
let n = /* @__PURE__ */ new Set();
|
|
632
632
|
for (let r of e) {
|
|
633
633
|
let e = r[t];
|
|
634
634
|
e != null && n.add(e);
|
|
635
635
|
}
|
|
636
636
|
return [...n];
|
|
637
|
-
},
|
|
637
|
+
}, da = (e, t, n, r, i) => {
|
|
638
638
|
let a = {
|
|
639
639
|
column: t,
|
|
640
640
|
op: "in",
|
|
@@ -648,34 +648,37 @@ var Nr = (e) => typeof e == "string" && e !== "" ? e : null, Pr = async (e, t, n
|
|
|
648
648
|
skip: r.offset,
|
|
649
649
|
projection: void 0
|
|
650
650
|
});
|
|
651
|
-
},
|
|
652
|
-
t !== void 0 && e.length !== 0 && (await
|
|
651
|
+
}, fa = async (e, t, n, r) => {
|
|
652
|
+
t !== void 0 && e.length !== 0 && (await ia(e, t, n, r)).forEach((t, n) => {
|
|
653
653
|
let r = e[n];
|
|
654
654
|
for (let [e, n] of Object.entries(t)) e in r || (r[e] = n);
|
|
655
655
|
});
|
|
656
|
-
},
|
|
656
|
+
}, pa = (e) => e.eager !== void 0 && Object.keys(e.eager).length > 0, ma = (e, t, n) => {
|
|
657
657
|
if (e.eager === void 0) return null;
|
|
658
|
-
let r =
|
|
659
|
-
if (r === null) return null;
|
|
660
|
-
let i =
|
|
658
|
+
let r = _a(e.table, e.eager, e.sourceTable);
|
|
659
|
+
if (r === null || n === "sqlite" && ha(r)) return null;
|
|
660
|
+
let i = wa(n, e, r, Ca(t, n));
|
|
661
661
|
return i === null ? null : {
|
|
662
662
|
fragment: i,
|
|
663
|
-
decode:
|
|
663
|
+
decode: Da(r, n)
|
|
664
664
|
};
|
|
665
|
-
},
|
|
665
|
+
}, ha = (e) => Object.values(e.table.fields).some(we) || e.children.some((e) => ha({
|
|
666
|
+
table: e.target,
|
|
667
|
+
children: e.children
|
|
668
|
+
}) || e.relation.kind === "manyToMany" && Object.values(e.relation.through().fields).some(we)), N = (e) => e.relation.kind === "one" && e.fkSide === "target", ga = (e) => ({
|
|
666
669
|
...e,
|
|
667
670
|
branch: {
|
|
668
671
|
...e.branch,
|
|
669
672
|
limit: 2
|
|
670
673
|
}
|
|
671
|
-
}),
|
|
672
|
-
let r = n ??
|
|
674
|
+
}), _a = (e, t, n) => {
|
|
675
|
+
let r = n ?? Pe(e), i = Mi(e);
|
|
673
676
|
if (i === void 0) return null;
|
|
674
677
|
let a = [];
|
|
675
678
|
for (let [e, n] of Object.entries(t)) {
|
|
676
679
|
let t = i[e];
|
|
677
680
|
if (t === void 0) return null;
|
|
678
|
-
let o =
|
|
681
|
+
let o = va(e, t, r, n === !0 ? {} : n);
|
|
679
682
|
if (o === null) return null;
|
|
680
683
|
a.push(o);
|
|
681
684
|
}
|
|
@@ -683,30 +686,30 @@ var Nr = (e) => typeof e == "string" && e !== "" ? e : null, Pr = async (e, t, n
|
|
|
683
686
|
table: r,
|
|
684
687
|
children: a
|
|
685
688
|
};
|
|
686
|
-
},
|
|
689
|
+
}, va = (e, t, n, r) => {
|
|
687
690
|
let i = t.target(), a = (t.kind === "manyToMany" ? void 0 : t.sourceKey) ?? "id", o, s;
|
|
688
691
|
if (t.kind === "manyToMany") o = t.targetKey, s = "target";
|
|
689
692
|
else if (t.kind === "one") {
|
|
690
|
-
let r = t.sourceKey ??
|
|
693
|
+
let r = t.sourceKey ?? Sa(n, i.tableName);
|
|
691
694
|
if (r !== void 0) o = r, s = "source";
|
|
692
695
|
else try {
|
|
693
|
-
o = t.foreignKey ??
|
|
696
|
+
o = t.foreignKey ?? k(i, n.tableName, e), s = "target";
|
|
694
697
|
} catch {
|
|
695
698
|
return null;
|
|
696
699
|
}
|
|
697
700
|
} else try {
|
|
698
|
-
o = t.foreignKey ??
|
|
701
|
+
o = t.foreignKey ?? k(i, n.tableName, e), s = "target";
|
|
699
702
|
} catch {
|
|
700
703
|
return null;
|
|
701
704
|
}
|
|
702
705
|
let c = r.with === void 0 ? [] : (() => {
|
|
703
|
-
let e =
|
|
706
|
+
let e = Mi(i.tableName);
|
|
704
707
|
if (e === void 0 && Object.keys(r.with).length > 0) return null;
|
|
705
708
|
let t = [];
|
|
706
709
|
for (let [n, a] of Object.entries(r.with)) {
|
|
707
710
|
let r = e?.[n];
|
|
708
711
|
if (r === void 0) return null;
|
|
709
|
-
let o =
|
|
712
|
+
let o = va(n, r, i, a === !0 ? {} : a);
|
|
710
713
|
if (o === null) return null;
|
|
711
714
|
t.push(o);
|
|
712
715
|
}
|
|
@@ -722,11 +725,11 @@ var Nr = (e) => typeof e == "string" && e !== "" ? e : null, Pr = async (e, t, n
|
|
|
722
725
|
fkSide: s,
|
|
723
726
|
branch: r,
|
|
724
727
|
children: c,
|
|
725
|
-
junction:
|
|
728
|
+
junction: ya(t, r)
|
|
726
729
|
};
|
|
727
|
-
},
|
|
730
|
+
}, ya = (e, t) => {
|
|
728
731
|
if (e.kind !== "manyToMany" || t.junction === void 0) return;
|
|
729
|
-
let n = e.through(), r =
|
|
732
|
+
let n = e.through(), r = y(n), i = t.junction === !0 ? r : t.junction, a = i.filter((e) => r.includes(e));
|
|
730
733
|
return {
|
|
731
734
|
through: n,
|
|
732
735
|
requested: i,
|
|
@@ -736,35 +739,35 @@ var Nr = (e) => typeof e == "string" && e !== "" ? e : null, Pr = async (e, t, n
|
|
|
736
739
|
return t !== void 0 && (t.type === "timestamp" || t.type === "date");
|
|
737
740
|
})
|
|
738
741
|
};
|
|
739
|
-
},
|
|
742
|
+
}, ba = (e) => `__j_${e}`, xa = "__j", Sa = (e, t) => {
|
|
740
743
|
for (let [n, r] of Object.entries(e.fields)) if (r.type === "reference" && r.references?.()?.tableName === t) return n;
|
|
741
|
-
},
|
|
744
|
+
}, Ca = (e, t) => {
|
|
742
745
|
let n = 0;
|
|
743
746
|
return {
|
|
744
747
|
sql: e,
|
|
745
748
|
dialect: t,
|
|
746
749
|
nextAlias: () => `__a${n++}`
|
|
747
750
|
};
|
|
748
|
-
},
|
|
751
|
+
}, wa = (e, t, n, r) => {
|
|
749
752
|
switch (e) {
|
|
750
|
-
case "postgres": return
|
|
753
|
+
case "postgres": return Aa(t, n, r);
|
|
751
754
|
case "sqlite":
|
|
752
|
-
case "turso": return
|
|
755
|
+
case "turso": return Ra(t, n, r);
|
|
753
756
|
case "mysql":
|
|
754
|
-
case "mariadb": return
|
|
755
|
-
case "mssql": return
|
|
757
|
+
case "mariadb": return Ja(t, n, r);
|
|
758
|
+
case "mssql": return to(t, n, r);
|
|
756
759
|
}
|
|
757
|
-
},
|
|
758
|
-
let n =
|
|
760
|
+
}, Ta = (e, t) => t === "mssql" && !Ea.test(e) ? /* @__PURE__ */ new Date(`${e}Z`) : new Date(e), Ea = /(?:Z|[+-]\d{2}:?\d{2})$/, Da = (e, t) => {
|
|
761
|
+
let n = Oa(e.table, e.children, t);
|
|
759
762
|
return (e) => e.map((e) => {
|
|
760
763
|
let t = e.__row, r = typeof t == "string" ? JSON.parse(t) : t;
|
|
761
764
|
return n(r);
|
|
762
765
|
});
|
|
763
|
-
},
|
|
766
|
+
}, Oa = (e, t, n) => {
|
|
764
767
|
let r = [], i = [];
|
|
765
768
|
for (let [t, n] of Object.entries(e.fields)) (n.type === "timestamp" || n.type === "date") && r.push(t), n.type === "vector" && i.push(t);
|
|
766
769
|
let a = t.map((e) => {
|
|
767
|
-
let t =
|
|
770
|
+
let t = Oa(e.target, e.children, n), r = e.relation.kind === "one", i = N(e), a = i ? ra({
|
|
768
771
|
relationName: e.relationName,
|
|
769
772
|
sourceTableName: e.source.tableName,
|
|
770
773
|
targetTableName: e.target.tableName,
|
|
@@ -777,15 +780,15 @@ var Nr = (e) => typeof e == "string" && e !== "" ? e : null, Pr = async (e, t, n
|
|
|
777
780
|
isSingle: r,
|
|
778
781
|
fromOverFetch: i,
|
|
779
782
|
cardinalityMessage: a,
|
|
780
|
-
junction:
|
|
783
|
+
junction: ka(e.junction, n)
|
|
781
784
|
};
|
|
782
785
|
});
|
|
783
786
|
return (e) => {
|
|
784
787
|
let t = { ...e };
|
|
785
|
-
for (let e of i) e in t && (t[e] =
|
|
788
|
+
for (let e of i) e in t && (t[e] = dt(t[e], "vector", n));
|
|
786
789
|
for (let e of r) {
|
|
787
790
|
let r = t[e];
|
|
788
|
-
typeof r == "string" && (t[e] =
|
|
791
|
+
typeof r == "string" && (t[e] = Ta(r, n));
|
|
789
792
|
}
|
|
790
793
|
for (let e of a) {
|
|
791
794
|
let n = t[e.name];
|
|
@@ -795,7 +798,7 @@ var Nr = (e) => typeof e == "string" && e !== "" ? e : null, Pr = async (e, t, n
|
|
|
795
798
|
}
|
|
796
799
|
if (e.fromOverFetch) {
|
|
797
800
|
let r = n;
|
|
798
|
-
if (r.length > 1) throw new
|
|
801
|
+
if (r.length > 1) throw new na(e.cardinalityMessage);
|
|
799
802
|
t[e.name] = r.length === 0 ? null : e.decode(r[0]);
|
|
800
803
|
continue;
|
|
801
804
|
}
|
|
@@ -807,213 +810,213 @@ var Nr = (e) => typeof e == "string" && e !== "" ? e : null, Pr = async (e, t, n
|
|
|
807
810
|
}
|
|
808
811
|
return t;
|
|
809
812
|
};
|
|
810
|
-
},
|
|
813
|
+
}, ka = (e, t) => {
|
|
811
814
|
if (e === void 0) return;
|
|
812
815
|
let n = new Set(e.dateColumns), r = e.requested;
|
|
813
816
|
return (e) => {
|
|
814
817
|
let i = e._junction ?? {}, a = {};
|
|
815
818
|
for (let e of r) {
|
|
816
819
|
let r = i[e];
|
|
817
|
-
a[e] = n.has(e) && typeof r == "string" ?
|
|
820
|
+
a[e] = n.has(e) && typeof r == "string" ? Ta(r, t) : r;
|
|
818
821
|
}
|
|
819
822
|
return {
|
|
820
823
|
...e,
|
|
821
824
|
_junction: a
|
|
822
825
|
};
|
|
823
826
|
};
|
|
824
|
-
},
|
|
825
|
-
let r = n.sql, i = n.nextAlias(), a = r(t.table.tableName), o = r(i), s =
|
|
826
|
-
return s === null ? null : r`SELECT ${s} AS "__row" FROM ${a} AS ${o}${e.predicate ? r` WHERE ${
|
|
827
|
-
},
|
|
828
|
-
let i = n.sql, a = r === void 0 ? i`to_jsonb(${i(e)}.*)` : i`(to_jsonb(${i(e)}.*) - ${
|
|
827
|
+
}, Aa = (e, t, n) => {
|
|
828
|
+
let r = n.sql, i = n.nextAlias(), a = r(t.table.tableName), o = r(i), s = ja(i, t.children, n);
|
|
829
|
+
return s === null ? null : r`SELECT ${s} AS "__row" FROM ${a} AS ${o}${e.predicate ? r` WHERE ${z(e.predicate, i, r)}` : r``}${S(e).length > 0 ? r` ORDER BY ${r.csv(S(e).map((e) => e.direction === "desc" ? r`${I(i, e.column, r)} DESC` : r`${I(i, e.column, r)} ASC`))}` : r``}${e.take === void 0 ? r`` : r` LIMIT ${R(e.take, r)}`}${e.skip === void 0 ? r`` : r` OFFSET ${R(e.skip, r)}`}`;
|
|
830
|
+
}, ja = (e, t, n, r) => {
|
|
831
|
+
let i = n.sql, a = r === void 0 ? i`to_jsonb(${i(e)}.*)` : i`(to_jsonb(${i(e)}.*) - ${L(xa, i)}::text)`;
|
|
829
832
|
if (t.length === 0 && r === void 0) return a;
|
|
830
833
|
let o = [];
|
|
831
|
-
r !== void 0 && o.push(i`${
|
|
834
|
+
r !== void 0 && o.push(i`${L("_junction", i)}, ${I(e, xa, i)}`);
|
|
832
835
|
for (let r of t) {
|
|
833
|
-
let t =
|
|
836
|
+
let t = Ma(r, e, n);
|
|
834
837
|
if (t === null) return null;
|
|
835
|
-
o.push(i`${
|
|
838
|
+
o.push(i`${L(r.relationName, i)}, ${t}`);
|
|
836
839
|
}
|
|
837
840
|
return i`${a} || jsonb_build_object(${i.csv(o)})`;
|
|
838
|
-
},
|
|
841
|
+
}, Ma = (e, t, n) => {
|
|
839
842
|
switch (e.relation.kind) {
|
|
840
|
-
case "one": return
|
|
841
|
-
case "many": return
|
|
842
|
-
case "manyToMany": return
|
|
843
|
+
case "one": return N(e) ? Pa(ga(e), t, n) : Na(e, t, n);
|
|
844
|
+
case "many": return Pa(e, t, n);
|
|
845
|
+
case "manyToMany": return Fa(e, t, n);
|
|
843
846
|
}
|
|
844
|
-
},
|
|
845
|
-
let r = n.sql, i = n.nextAlias(), a =
|
|
847
|
+
}, Na = (e, t, n) => {
|
|
848
|
+
let r = n.sql, i = n.nextAlias(), a = ja(i, e.children, n);
|
|
846
849
|
if (a === null) return null;
|
|
847
|
-
let o = e.fkSide === "source" ? r`${
|
|
850
|
+
let o = e.fkSide === "source" ? r`${I(i, "id", r)} = ${I(t, e.foreignKey, r)}` : r`${I(i, e.foreignKey, r)} = ${I(t, e.sourceKey, r)}`, s = e.branch.where === void 0 ? r`` : r` AND ${z(e.branch.where, i, r)}`, c = P(i, e.branch.orderBy, r);
|
|
848
851
|
return r`(SELECT ${a} FROM ${r(e.target.tableName)} AS ${r(i)} WHERE ${o}${s}${c} LIMIT 1)`;
|
|
849
|
-
},
|
|
850
|
-
let r = n.sql, i = n.nextAlias(), a =
|
|
852
|
+
}, Pa = (e, t, n) => {
|
|
853
|
+
let r = n.sql, i = n.nextAlias(), a = ja(i, e.children, n);
|
|
851
854
|
if (a === null) return null;
|
|
852
|
-
let o = r`${
|
|
855
|
+
let o = r`${I(void 0, e.foreignKey, r)} = ${I(t, e.sourceKey, r)}`, s = e.branch.where === void 0 ? r`` : r` AND ${h(e.branch.where, r)}`, c = La(e.branch.orderBy, r), l = e.branch.limit === void 0 ? r`` : r` LIMIT ${R(e.branch.limit, r)}`, u = e.branch.offset === void 0 ? r`` : r` OFFSET ${R(e.branch.offset, r)}`;
|
|
853
856
|
return r`COALESCE((SELECT jsonb_agg(${a}) FROM (SELECT * FROM ${r(e.target.tableName)} WHERE ${o}${s}${c}${l}${u}) AS ${r(i)}), '[]'::jsonb)`;
|
|
854
|
-
},
|
|
855
|
-
let r = n.sql, i = e.relation, a = i.through(), o = n.nextAlias(), s = n.nextAlias(), c =
|
|
857
|
+
}, Fa = (e, t, n) => {
|
|
858
|
+
let r = n.sql, i = e.relation, a = i.through(), o = n.nextAlias(), s = n.nextAlias(), c = ja(o, e.children, n, e.junction);
|
|
856
859
|
if (c === null) return null;
|
|
857
|
-
let l = e.branch.where === void 0 ? r`` : r` AND ${
|
|
858
|
-
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 ${
|
|
859
|
-
},
|
|
860
|
-
let r = n.sql, i = n.nextAlias(), a =
|
|
860
|
+
let l = e.branch.where === void 0 ? r`` : r` AND ${h(e.branch.where, r)}`, u = lo(e, s, r), d = P(o, e.branch.orderBy, r), f = e.branch.limit === void 0 ? r`` : r` LIMIT ${R(e.branch.limit, r)}`, p = e.branch.offset === void 0 ? r`` : r` OFFSET ${R(e.branch.offset, r)}`, m = e.junction === void 0 ? r`` : r`, ${Ia(e.junction, s, r)} AS ${r(xa)}`;
|
|
861
|
+
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 ${I(o, "id", r)} = ${I(s, i.targetKey, r)} WHERE ${I(s, i.sourceKey, r)} = ${I(t, "id", r)}${u}${l}${d}${f}${p}) AS ${r(o)}), '[]'::jsonb)`;
|
|
862
|
+
}, Ia = (e, t, n) => e.present.length === 0 ? n`jsonb_build_object()` : n`jsonb_build_object(${n.csv(e.present.map((e) => n`${L(e, n)}, ${I(t, e, n)}`))})`, P = (e, t, n) => t === void 0 || t.length === 0 ? n`` : n` ORDER BY ${n.csv(t.map((t) => t.direction === "desc" ? n`${I(e, t.column, n)} DESC` : n`${I(e, t.column, n)} ASC`))}`, La = (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`))}`, Ra = (e, t, n) => {
|
|
863
|
+
let r = n.sql, i = n.nextAlias(), a = za(i, t.table, t.children, n);
|
|
861
864
|
if (a === null) return null;
|
|
862
|
-
let o = e.predicate ? r` WHERE ${
|
|
865
|
+
let o = e.predicate ? r` WHERE ${z(e.predicate, i, r)}` : r``, s = S(e).length > 0 ? r` ORDER BY ${r.csv(S(e).map((e) => e.direction === "desc" ? r`${I(i, e.column, r)} DESC` : r`${I(i, e.column, r)} ASC`))}` : r``, c = e.take === void 0 ? r`` : r` LIMIT ${R(e.take, r)}`, l = e.skip === void 0 ? r`` : r` OFFSET ${R(e.skip, r)}`;
|
|
863
866
|
return r`SELECT ${a} AS "__row" FROM ${r(t.table.tableName)} AS ${r(i)}${o}${s}${c}${l}`;
|
|
864
|
-
},
|
|
867
|
+
}, za = (e, t, n, r, i) => {
|
|
865
868
|
let a = r.sql, o = [];
|
|
866
|
-
for (let n of
|
|
867
|
-
let r =
|
|
868
|
-
o.push(a`${
|
|
869
|
+
for (let n of y(t)) {
|
|
870
|
+
let r = I(e, n, a), i = t.fields[n]?.type === "bigint" ? a`CAST(${r} AS TEXT)` : r;
|
|
871
|
+
o.push(a`${L(n, a)}, ${i}`);
|
|
869
872
|
}
|
|
870
873
|
if (i !== void 0) {
|
|
871
|
-
let e =
|
|
872
|
-
o.push(a`${
|
|
874
|
+
let e = Ba(i.projection, i.source, a);
|
|
875
|
+
o.push(a`${L("_junction", a)}, json_object(${e})`);
|
|
873
876
|
}
|
|
874
877
|
for (let t of n) {
|
|
875
|
-
let n =
|
|
878
|
+
let n = Wa(t, e, r);
|
|
876
879
|
if (n === null) return null;
|
|
877
|
-
o.push(a`${
|
|
880
|
+
o.push(a`${L(t.relationName, a)}, ${n}`);
|
|
878
881
|
}
|
|
879
882
|
return a`json_object(${a.csv(o)})`;
|
|
880
|
-
},
|
|
881
|
-
let i =
|
|
883
|
+
}, Ba = (e, t, n) => e.present.length === 0 ? n`` : n.csv(e.present.map((r) => {
|
|
884
|
+
let i = I(t.alias, t.physical(r), n), a = e.through.fields[r]?.type === "bigint" ? n.onDialectOrElse({
|
|
882
885
|
sqlite: () => n`CAST(${i} AS TEXT)`,
|
|
883
886
|
orElse: () => i
|
|
884
887
|
}) : i;
|
|
885
|
-
return n`${
|
|
886
|
-
})),
|
|
888
|
+
return n`${L(r, n)}, ${a}`;
|
|
889
|
+
})), Va = (e, t, n) => e.present.length === 0 ? n`` : n`, ${n.csv(e.present.map((e) => n`${I(t, e, n)} AS ${n(ba(e))}`))}`, Ha = (e) => ({
|
|
887
890
|
alias: e,
|
|
888
|
-
physical:
|
|
889
|
-
}),
|
|
891
|
+
physical: ba
|
|
892
|
+
}), Ua = (e) => ({
|
|
890
893
|
alias: e,
|
|
891
894
|
physical: (e) => e
|
|
892
|
-
}),
|
|
895
|
+
}), Wa = (e, t, n) => {
|
|
893
896
|
switch (e.relation.kind) {
|
|
894
|
-
case "one": return
|
|
895
|
-
case "many": return
|
|
896
|
-
case "manyToMany": return
|
|
897
|
+
case "one": return N(e) ? Ka(ga(e), t, n) : Ga(e, t, n);
|
|
898
|
+
case "many": return Ka(e, t, n);
|
|
899
|
+
case "manyToMany": return qa(e, t, n);
|
|
897
900
|
}
|
|
898
|
-
},
|
|
899
|
-
let r = n.sql, i = n.nextAlias(), a =
|
|
901
|
+
}, Ga = (e, t, n) => {
|
|
902
|
+
let r = n.sql, i = n.nextAlias(), a = za(i, e.target, e.children, n);
|
|
900
903
|
if (a === null) return null;
|
|
901
|
-
let o = e.fkSide === "source" ? r`${
|
|
904
|
+
let o = e.fkSide === "source" ? r`${I(i, "id", r)} = ${I(t, e.foreignKey, r)}` : r`${I(i, e.foreignKey, r)} = ${I(t, e.sourceKey, r)}`;
|
|
902
905
|
return r`(SELECT ${a} FROM ${r(e.target.tableName)} AS ${r(i)} WHERE ${o} LIMIT 1)`;
|
|
903
|
-
},
|
|
904
|
-
let r = n.sql, i = n.nextAlias(), a =
|
|
906
|
+
}, Ka = (e, t, n) => {
|
|
907
|
+
let r = n.sql, i = n.nextAlias(), a = za(i, e.target, e.children, n);
|
|
905
908
|
if (a === null) return null;
|
|
906
|
-
let o = r`${
|
|
909
|
+
let o = r`${I(void 0, e.foreignKey, r)} = ${I(t, e.sourceKey, r)}`, s = e.branch.where === void 0 ? r`` : r` AND ${h(B(e.branch.where), r)}`, c = La(e.branch.orderBy, r), l = e.branch.limit === void 0 ? r`` : r` LIMIT ${R(e.branch.limit, r)}`, u = e.branch.offset === void 0 ? r`` : r` OFFSET ${R(e.branch.offset, r)}`;
|
|
907
910
|
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('[]'))`;
|
|
908
|
-
},
|
|
909
|
-
let r = n.sql, i = e.relation, a = i.through(), o = n.nextAlias(), s = n.nextAlias(), c =
|
|
911
|
+
}, qa = (e, t, n) => {
|
|
912
|
+
let r = n.sql, i = e.relation, a = i.through(), o = n.nextAlias(), s = n.nextAlias(), c = za(o, e.target, e.children, n, e.junction === void 0 ? void 0 : {
|
|
910
913
|
projection: e.junction,
|
|
911
|
-
source:
|
|
914
|
+
source: Ha(o)
|
|
912
915
|
});
|
|
913
916
|
if (c === null) return null;
|
|
914
|
-
let l = e.branch.where === void 0 ? r`` : r` AND ${
|
|
915
|
-
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 ${
|
|
916
|
-
},
|
|
917
|
-
let r = n.sql, i = n.nextAlias(), a =
|
|
917
|
+
let l = e.branch.where === void 0 ? r`` : r` AND ${h(B(e.branch.where), r)}`, u = lo(e, s, r, !0), d = P(o, e.branch.orderBy, r), f = e.branch.limit === void 0 ? r`` : r` LIMIT ${R(e.branch.limit, r)}`, p = e.branch.offset === void 0 ? r`` : r` OFFSET ${R(e.branch.offset, r)}`, m = e.junction === void 0 ? r`` : Va(e.junction, s, r);
|
|
918
|
+
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 ${I(o, "id", r)} = ${I(s, i.targetKey, r)} WHERE ${I(s, i.sourceKey, r)} = ${I(t, "id", r)}${u}${l}${d}${f}${p}) AS ${r(o)}), json('[]'))`;
|
|
919
|
+
}, Ja = (e, t, n) => {
|
|
920
|
+
let r = n.sql, i = n.nextAlias(), a = F(i, t.table, t.children, n);
|
|
918
921
|
if (a === null) return null;
|
|
919
|
-
let o = e.predicate ? r` WHERE ${
|
|
922
|
+
let o = e.predicate ? r` WHERE ${z(e.predicate, i, r)}` : r``, s = S(e).length > 0 ? r` ORDER BY ${r.csv(S(e).map((e) => e.direction === "desc" ? r`${I(i, e.column, r)} DESC` : r`${I(i, e.column, r)} ASC`))}` : r``, c = e.take === void 0 ? r`` : r` LIMIT ${R(e.take, r)}`, l = e.skip === void 0 ? r`` : r` OFFSET ${R(e.skip, r)}`;
|
|
920
923
|
return r`SELECT ${a} AS \`__row\` FROM ${r(t.table.tableName)} AS ${r(i)}${o}${s}${c}${l}`;
|
|
921
|
-
},
|
|
924
|
+
}, F = (e, t, n, r, i) => {
|
|
922
925
|
let a = r.sql, o = [];
|
|
923
|
-
for (let n of
|
|
926
|
+
for (let n of y(t)) o.push(a`${L(n, a)}, ${I(e, n, a)}`);
|
|
924
927
|
if (i !== void 0) {
|
|
925
|
-
let e =
|
|
926
|
-
o.push(a`${
|
|
928
|
+
let e = Ba(i.projection, i.source, a);
|
|
929
|
+
o.push(a`${L("_junction", a)}, JSON_OBJECT(${e})`);
|
|
927
930
|
}
|
|
928
931
|
for (let t of n) {
|
|
929
|
-
let n =
|
|
932
|
+
let n = Ya(t, e, r);
|
|
930
933
|
if (n === null) return null;
|
|
931
|
-
o.push(a`${
|
|
934
|
+
o.push(a`${L(t.relationName, a)}, ${n}`);
|
|
932
935
|
}
|
|
933
936
|
return a`JSON_OBJECT(${a.csv(o)})`;
|
|
934
|
-
},
|
|
937
|
+
}, Ya = (e, t, n) => {
|
|
935
938
|
switch (e.relation.kind) {
|
|
936
939
|
case "one":
|
|
937
|
-
if (
|
|
938
|
-
let r =
|
|
939
|
-
return n.dialect === "mariadb" ?
|
|
940
|
+
if (N(e)) {
|
|
941
|
+
let r = ga(e);
|
|
942
|
+
return n.dialect === "mariadb" ? $a(r, t, n) : Za(r, t, n);
|
|
940
943
|
}
|
|
941
|
-
return
|
|
942
|
-
case "many": return n.dialect === "mariadb" ?
|
|
943
|
-
case "manyToMany": return n.dialect === "mariadb" ?
|
|
944
|
+
return Xa(e, t, n);
|
|
945
|
+
case "many": return n.dialect === "mariadb" ? $a(e, t, n) : Za(e, t, n);
|
|
946
|
+
case "manyToMany": return n.dialect === "mariadb" ? eo(e, t, n) : Qa(e, t, n);
|
|
944
947
|
}
|
|
945
|
-
},
|
|
946
|
-
let r = n.sql, i = n.nextAlias(), a =
|
|
948
|
+
}, Xa = (e, t, n) => {
|
|
949
|
+
let r = n.sql, i = n.nextAlias(), a = F(i, e.target, e.children, n);
|
|
947
950
|
if (a === null) return null;
|
|
948
|
-
let o = e.fkSide === "source" ? r`${
|
|
951
|
+
let o = e.fkSide === "source" ? r`${I(i, "id", r)} = ${I(t, e.foreignKey, r)}` : r`${I(i, e.foreignKey, r)} = ${I(t, e.sourceKey, r)}`;
|
|
949
952
|
return r`(SELECT ${a} FROM ${r(e.target.tableName)} AS ${r(i)} WHERE ${o} LIMIT 1)`;
|
|
950
|
-
},
|
|
951
|
-
let r = n.sql, i = n.nextAlias(), a =
|
|
953
|
+
}, Za = (e, t, n) => {
|
|
954
|
+
let r = n.sql, i = n.nextAlias(), a = F(i, e.target, e.children, n);
|
|
952
955
|
if (a === null) return null;
|
|
953
|
-
let o = r`${
|
|
956
|
+
let o = r`${I(void 0, e.foreignKey, r)} = ${I(t, e.sourceKey, r)}`, s = e.branch.where === void 0 ? r`` : r` AND ${h(B(e.branch.where), r)}`, c = La(e.branch.orderBy, r), l = e.branch.limit === void 0 ? r`` : r` LIMIT ${R(e.branch.limit, r)}`, u = e.branch.offset === void 0 ? r`` : r` OFFSET ${R(e.branch.offset, r)}`;
|
|
954
957
|
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())`;
|
|
955
|
-
},
|
|
956
|
-
let r = n.sql, i = e.relation, a = i.through(), o = n.nextAlias(), s = n.nextAlias(), c =
|
|
958
|
+
}, Qa = (e, t, n) => {
|
|
959
|
+
let r = n.sql, i = e.relation, a = i.through(), o = n.nextAlias(), s = n.nextAlias(), c = F(o, e.target, e.children, n, e.junction === void 0 ? void 0 : {
|
|
957
960
|
projection: e.junction,
|
|
958
|
-
source:
|
|
961
|
+
source: Ha(o)
|
|
959
962
|
});
|
|
960
963
|
if (c === null) return null;
|
|
961
|
-
let l = e.branch.where === void 0 ? r`` : r` AND ${
|
|
962
|
-
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 ${
|
|
963
|
-
},
|
|
964
|
-
let r = n.sql, i = n.nextAlias(), a =
|
|
964
|
+
let l = e.branch.where === void 0 ? r`` : r` AND ${h(B(e.branch.where), r)}`, u = lo(e, s, r, !0), d = P(o, e.branch.orderBy, r), f = e.branch.limit === void 0 ? r`` : r` LIMIT ${R(e.branch.limit, r)}`, p = e.branch.offset === void 0 ? r`` : r` OFFSET ${R(e.branch.offset, r)}`, m = e.junction === void 0 ? r`` : Va(e.junction, s, r);
|
|
965
|
+
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 ${I(o, "id", r)} = ${I(s, i.targetKey, r)} WHERE ${I(s, i.sourceKey, r)} = ${I(t, "id", r)}${u}${l}${d}${f}${p}) AS ${r(o)}), JSON_ARRAY())`;
|
|
966
|
+
}, $a = (e, t, n) => {
|
|
967
|
+
let r = n.sql, i = n.nextAlias(), a = F(i, e.target, e.children, n);
|
|
965
968
|
if (a === null) return null;
|
|
966
|
-
let o = r`${
|
|
967
|
-
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`${
|
|
968
|
-
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 ${
|
|
969
|
-
return r`COALESCE((SELECT JSON_ARRAYAGG(${a} ORDER BY ${
|
|
970
|
-
},
|
|
969
|
+
let o = r`${I(i, e.foreignKey, r)} = ${I(t, e.sourceKey, r)}`, s = e.branch.where === void 0 ? r`` : r` AND ${h(B(e.branch.where), r)}`, c = e.branch.orderBy ?? [];
|
|
970
|
+
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`${I(i, e.column, r)} DESC` : r`${I(i, e.column, r)} ASC`))}` : r``}) FROM ${r(e.target.tableName)} AS ${r(i)} WHERE ${o}${s}), JSON_ARRAY())`;
|
|
971
|
+
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 ${I(i, "rn", r)} > ${R(d, r)} AND ${I(i, "rn", r)} <= ${R(d + u, r)}` : u === void 0 ? r` AND ${I(i, "rn", r)} > ${R(d, r)}` : r` AND ${I(i, "rn", r)} <= ${R(u, r)}`;
|
|
972
|
+
return r`COALESCE((SELECT JSON_ARRAYAGG(${a} ORDER BY ${I(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())`;
|
|
973
|
+
}, eo = (e, t, n) => {
|
|
971
974
|
let r = n.sql, i = e.relation, a = i.through(), o = n.nextAlias(), s = n.nextAlias(), c = (t) => e.junction === void 0 ? void 0 : {
|
|
972
975
|
projection: e.junction,
|
|
973
976
|
source: t
|
|
974
|
-
}, l = r`${
|
|
977
|
+
}, l = r`${I(s, i.sourceKey, r)} = ${I(t, "id", r)}`, u = r`${I(o, "id", r)} = ${I(s, i.targetKey, r)}`, d = e.branch.where === void 0 ? r`` : r` AND ${h(B(e.branch.where), r)}`, f = lo(e, s, r, !0), p = e.branch.orderBy ?? [];
|
|
975
978
|
if (e.branch.limit === void 0 && e.branch.offset === void 0) {
|
|
976
|
-
let t =
|
|
977
|
-
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`${
|
|
979
|
+
let t = F(o, e.target, e.children, n, c(Ua(s)));
|
|
980
|
+
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`${I(o, e.column, r)} DESC` : r`${I(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())`;
|
|
978
981
|
}
|
|
979
|
-
let m = p.length > 0 ? r` ORDER BY ${r.csv(p.map((e) => e.direction === "desc" ? r`${
|
|
980
|
-
if (
|
|
981
|
-
let
|
|
982
|
-
return r`COALESCE((SELECT JSON_ARRAYAGG(${
|
|
983
|
-
},
|
|
984
|
-
let r = n.sql, i = n.nextAlias(), a =
|
|
982
|
+
let m = p.length > 0 ? r` ORDER BY ${r.csv(p.map((e) => e.direction === "desc" ? r`${I(o, e.column, r)} DESC` : r`${I(o, e.column, r)} ASC`))}` : r` ORDER BY ${I(o, "id", r)}`, g = e.branch.limit, _ = e.branch.offset, v = g !== void 0 && _ !== void 0 ? r` AND ${I(o, "rn", r)} > ${R(_, r)} AND ${I(o, "rn", r)} <= ${R(_ + g, r)}` : g === void 0 ? r` AND ${I(o, "rn", r)} > ${R(_, r)}` : r` AND ${I(o, "rn", r)} <= ${R(g, r)}`, ee = e.branch.onJunction === void 0 ? r`` : r` WHERE ${z(B(e.branch.onJunction), s, r)}`, te = F(o, e.target, e.children, n, c(Ha(o)));
|
|
983
|
+
if (te === null) return null;
|
|
984
|
+
let ne = e.junction === void 0 ? r`` : Va(e.junction, s, r);
|
|
985
|
+
return r`COALESCE((SELECT JSON_ARRAYAGG(${te} ORDER BY ${I(o, "rn", r)}) FROM (SELECT ${r(o)}.*${ne}, ${I(s, i.sourceKey, r)} AS ${r(`__src_${i.sourceKey}`)}, ROW_NUMBER() OVER (PARTITION BY ${I(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}${ee}) AS ${r(o)} WHERE ${I(o, `__src_${i.sourceKey}`, r)} = ${I(t, "id", r)}${d}${v}), JSON_ARRAY())`;
|
|
986
|
+
}, to = (e, t, n) => {
|
|
987
|
+
let r = n.sql, i = n.nextAlias(), a = no(i, t.table, t.children, n);
|
|
985
988
|
if (a === null) return null;
|
|
986
|
-
let o = e.predicate ? r` WHERE ${
|
|
989
|
+
let o = e.predicate ? r` WHERE ${z(e.predicate, i, r)}` : r``, s = S(e).length > 0 ? r` ORDER BY ${r.csv(S(e).map((e) => e.direction === "desc" ? r`${I(i, e.column, r)} DESC` : r`${I(i, e.column, r)} ASC`))}` : r``, c = r``, l = r``;
|
|
987
990
|
if (e.skip !== void 0) {
|
|
988
|
-
let t =
|
|
989
|
-
l = e.take === void 0 ? r`${t} OFFSET ${
|
|
990
|
-
} else e.take !== void 0 && (c = r`TOP ${
|
|
991
|
+
let t = S(e).length > 0 ? s : r` ORDER BY (SELECT NULL)`;
|
|
992
|
+
l = e.take === void 0 ? r`${t} OFFSET ${R(e.skip, r)} ROWS` : r`${t} OFFSET ${R(e.skip, r)} ROWS FETCH NEXT ${R(e.take, r)} ROWS ONLY`;
|
|
993
|
+
} else e.take !== void 0 && (c = r`TOP ${R(e.take, r)} `);
|
|
991
994
|
let u = e.skip === void 0 ? s : r``;
|
|
992
995
|
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}`;
|
|
993
|
-
},
|
|
996
|
+
}, no = (e, t, n, r, i) => {
|
|
994
997
|
let a = r.sql, o = [];
|
|
995
|
-
for (let n of
|
|
996
|
-
if (i !== void 0) for (let e of i.projection.present) o.push(a`${
|
|
998
|
+
for (let n of y(t)) o.push(a`${I(e, n, a)} AS ${a(n)}`);
|
|
999
|
+
if (i !== void 0) for (let e of i.projection.present) o.push(a`${I(i.source.alias, i.source.physical(e), a)} AS ${ro(`_junction.${e}`, a)}`);
|
|
997
1000
|
for (let t of n) {
|
|
998
|
-
let n =
|
|
1001
|
+
let n = io(t, e, r);
|
|
999
1002
|
if (n === null) return null;
|
|
1000
1003
|
o.push(n);
|
|
1001
1004
|
}
|
|
1002
1005
|
return a.csv(o);
|
|
1003
|
-
},
|
|
1006
|
+
}, ro = (e, t) => t.unsafe(`[${e.replace(/]/g, "]]")}]`), io = (e, t, n) => {
|
|
1004
1007
|
switch (e.relation.kind) {
|
|
1005
|
-
case "one": return
|
|
1006
|
-
case "many": return
|
|
1007
|
-
case "manyToMany": return
|
|
1008
|
+
case "one": return N(e) ? so(ga(e), t, n) : ao(e, t, n);
|
|
1009
|
+
case "many": return so(e, t, n);
|
|
1010
|
+
case "manyToMany": return co(e, t, n);
|
|
1008
1011
|
}
|
|
1009
|
-
},
|
|
1010
|
-
let r = n.sql, i = n.nextAlias(), a =
|
|
1012
|
+
}, ao = (e, t, n) => {
|
|
1013
|
+
let r = n.sql, i = n.nextAlias(), a = no(i, e.target, e.children, n);
|
|
1011
1014
|
if (a === null) return null;
|
|
1012
|
-
let o = e.fkSide === "source" ? r`${
|
|
1015
|
+
let o = e.fkSide === "source" ? r`${I(i, "id", r)} = ${I(t, e.foreignKey, r)}` : r`${I(i, e.foreignKey, r)} = ${I(t, e.sourceKey, r)}`;
|
|
1013
1016
|
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)}`;
|
|
1014
|
-
},
|
|
1017
|
+
}, oo = (e, t, n) => {
|
|
1015
1018
|
if (e.offset !== void 0) {
|
|
1016
|
-
let r = e.orderBy && e.orderBy.length > 0 ? t : n` ORDER BY (SELECT NULL)`, i = e.limit === void 0 ? n`${r} OFFSET ${
|
|
1019
|
+
let r = e.orderBy && e.orderBy.length > 0 ? t : n` ORDER BY (SELECT NULL)`, i = e.limit === void 0 ? n`${r} OFFSET ${R(e.offset, n)} ROWS` : n`${r} OFFSET ${R(e.offset, n)} ROWS FETCH NEXT ${R(e.limit, n)} ROWS ONLY`;
|
|
1017
1020
|
return {
|
|
1018
1021
|
top: n``,
|
|
1019
1022
|
pagination: i,
|
|
@@ -1021,36 +1024,36 @@ var Nr = (e) => typeof e == "string" && e !== "" ? e : null, Pr = async (e, t, n
|
|
|
1021
1024
|
};
|
|
1022
1025
|
}
|
|
1023
1026
|
return {
|
|
1024
|
-
top: e.limit === void 0 ? n`` : n`TOP ${
|
|
1027
|
+
top: e.limit === void 0 ? n`` : n`TOP ${R(e.limit, n)} `,
|
|
1025
1028
|
pagination: n``,
|
|
1026
1029
|
finalOrder: t
|
|
1027
1030
|
};
|
|
1028
|
-
},
|
|
1029
|
-
let r = n.sql, i = n.nextAlias(), a =
|
|
1031
|
+
}, so = (e, t, n) => {
|
|
1032
|
+
let r = n.sql, i = n.nextAlias(), a = no(i, e.target, e.children, n);
|
|
1030
1033
|
if (a === null) return null;
|
|
1031
|
-
let o = e.branch.where === void 0 ? r`` : r` AND ${
|
|
1032
|
-
return r`ISNULL(JSON_QUERY((SELECT ${c}${a} FROM ${r(e.target.tableName)} AS ${r(i)} WHERE ${
|
|
1033
|
-
},
|
|
1034
|
-
let r = n.sql, i = e.relation, a = i.through(), o = n.nextAlias(), s = n.nextAlias(), c =
|
|
1034
|
+
let o = e.branch.where === void 0 ? r`` : r` AND ${z(e.branch.where, i, r)}`, s = P(i, e.branch.orderBy, r), { top: c, pagination: l, finalOrder: u } = oo(e.branch, s, r);
|
|
1035
|
+
return r`ISNULL(JSON_QUERY((SELECT ${c}${a} FROM ${r(e.target.tableName)} AS ${r(i)} WHERE ${I(i, e.foreignKey, r)} = ${I(t, e.sourceKey, r)}${o}${u}${l} FOR JSON PATH, INCLUDE_NULL_VALUES)), JSON_QUERY('[]')) AS ${r(e.relationName)}`;
|
|
1036
|
+
}, co = (e, t, n) => {
|
|
1037
|
+
let r = n.sql, i = e.relation, a = i.through(), o = n.nextAlias(), s = n.nextAlias(), c = no(o, e.target, e.children, n, e.junction === void 0 ? void 0 : {
|
|
1035
1038
|
projection: e.junction,
|
|
1036
|
-
source:
|
|
1039
|
+
source: Ua(s)
|
|
1037
1040
|
});
|
|
1038
1041
|
if (c === null) return null;
|
|
1039
|
-
let l = e.branch.where === void 0 ? r`` : r` AND ${
|
|
1040
|
-
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 ${
|
|
1041
|
-
},
|
|
1042
|
-
if (!Number.isFinite(e) || !Number.isInteger(e) || e < 0) throw
|
|
1042
|
+
let l = e.branch.where === void 0 ? r`` : r` AND ${z(e.branch.where, o, r)}`, u = lo(e, s, r), d = P(o, e.branch.orderBy, r), { top: f, pagination: p, finalOrder: m } = oo(e.branch, d, r);
|
|
1043
|
+
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 ${I(o, "id", r)} = ${I(s, i.targetKey, r)} WHERE ${I(s, i.sourceKey, r)} = ${I(t, "id", r)}${u}${l}${m}${p} FOR JSON PATH, INCLUDE_NULL_VALUES)), JSON_QUERY('[]')) AS ${r(e.relationName)}`;
|
|
1044
|
+
}, I = (e, t, n) => e === void 0 ? n`${n(t)}` : n`${n(e)}.${n(t)}`, L = (e, t) => t.unsafe(`'${e.replace(/'/g, "''")}'`), R = (e, t) => {
|
|
1045
|
+
if (!Number.isFinite(e) || !Number.isInteger(e) || e < 0) throw C(`literalInt: expected non-negative integer, got ${e}`);
|
|
1043
1046
|
return t.unsafe(String(e));
|
|
1044
|
-
},
|
|
1045
|
-
let r =
|
|
1046
|
-
return
|
|
1047
|
-
},
|
|
1047
|
+
}, z = (e, t, n) => {
|
|
1048
|
+
let r = uo(e, t);
|
|
1049
|
+
return h(r, n);
|
|
1050
|
+
}, lo = (e, t, n, r = !1) => {
|
|
1048
1051
|
let i = e.branch.onJunction;
|
|
1049
|
-
return i === void 0 ? n`` : n` AND ${
|
|
1050
|
-
},
|
|
1051
|
-
if ("not" in e) return { not:
|
|
1052
|
-
if ("and" in e) return { and: e.and.map((e) =>
|
|
1053
|
-
if ("or" in e) return { or: e.or.map((e) =>
|
|
1052
|
+
return i === void 0 ? n`` : n` AND ${z(r ? B(i) : i, t, n)}`;
|
|
1053
|
+
}, uo = (e, t) => {
|
|
1054
|
+
if ("not" in e) return { not: uo(e.not, t) };
|
|
1055
|
+
if ("and" in e) return { and: e.and.map((e) => uo(e, t)) };
|
|
1056
|
+
if ("or" in e) return { or: e.or.map((e) => uo(e, t)) };
|
|
1054
1057
|
if (e.op === "subquery-in" || e.op === "subquery-not-in") {
|
|
1055
1058
|
let n = e;
|
|
1056
1059
|
return {
|
|
@@ -1063,57 +1066,57 @@ var Nr = (e) => typeof e == "string" && e !== "" ? e : null, Pr = async (e, t, n
|
|
|
1063
1066
|
return {
|
|
1064
1067
|
...n,
|
|
1065
1068
|
column: `${t}.${n.column}`,
|
|
1066
|
-
...
|
|
1069
|
+
...Xe(n.value) ? { value: Oe(`${t}.${n.value.column}`) } : {}
|
|
1067
1070
|
};
|
|
1068
|
-
},
|
|
1069
|
-
if ("not" in e) return { not:
|
|
1070
|
-
if ("and" in e) return { and: e.and.map((e) =>
|
|
1071
|
-
if ("or" in e) return { or: e.or.map((e) =>
|
|
1071
|
+
}, B = (e) => {
|
|
1072
|
+
if ("not" in e) return { not: B(e.not) };
|
|
1073
|
+
if ("and" in e) return { and: e.and.map((e) => B(e)) };
|
|
1074
|
+
if ("or" in e) return { or: e.or.map((e) => B(e)) };
|
|
1072
1075
|
if (e.op === "subquery-in" || e.op === "subquery-not-in" || e.op === "exists" || e.op === "not-exists") return e;
|
|
1073
1076
|
let t = e;
|
|
1074
1077
|
return {
|
|
1075
1078
|
...t,
|
|
1076
|
-
value:
|
|
1079
|
+
value: _e(t.value)
|
|
1077
1080
|
};
|
|
1078
|
-
},
|
|
1079
|
-
e.actors !== void 0 && (
|
|
1080
|
-
},
|
|
1081
|
+
}, fo = Symbol.for("@voltro/database/coreTablesRegistry"), po = globalThis, mo = po[fo] ?? (po[fo] = {}), ho = (e) => {
|
|
1082
|
+
e.actors !== void 0 && (mo.actors = e.actors), e.tenants !== void 0 && (mo.tenants = e.tenants);
|
|
1083
|
+
}, go = (e, t) => () => {
|
|
1081
1084
|
let n = e();
|
|
1082
1085
|
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`);
|
|
1083
1086
|
return n();
|
|
1084
|
-
},
|
|
1085
|
-
id:
|
|
1086
|
-
kind:
|
|
1087
|
+
}, _o = () => go(() => mo.actors, "actors"), vo = () => go(() => mo.tenants, "tenants"), yo = x("actors", {
|
|
1088
|
+
id: br(),
|
|
1089
|
+
kind: b().oneOf([
|
|
1087
1090
|
"user",
|
|
1088
1091
|
"serviceAccount",
|
|
1089
1092
|
"apiKey",
|
|
1090
1093
|
"system"
|
|
1091
1094
|
]).safe(),
|
|
1092
|
-
displayName:
|
|
1093
|
-
createdAt:
|
|
1094
|
-
}),
|
|
1095
|
+
displayName: b().nullable().sensitive("fullName"),
|
|
1096
|
+
createdAt: n().default("now")
|
|
1097
|
+
}), bo = (e, t) => ({
|
|
1095
1098
|
...t,
|
|
1096
1099
|
...e,
|
|
1097
1100
|
origin: e.origin ?? "injected"
|
|
1098
|
-
}),
|
|
1101
|
+
}), xo = (e, t, n = {}) => ({
|
|
1099
1102
|
table: e,
|
|
1100
1103
|
op: "insert",
|
|
1101
1104
|
old: null,
|
|
1102
1105
|
new: t,
|
|
1103
1106
|
...n
|
|
1104
|
-
}),
|
|
1107
|
+
}), So = (e, t, n, r = {}) => ({
|
|
1105
1108
|
table: e,
|
|
1106
1109
|
op: "update",
|
|
1107
1110
|
old: t,
|
|
1108
1111
|
new: n,
|
|
1109
1112
|
...r
|
|
1110
|
-
}),
|
|
1113
|
+
}), Co = (e, t, n = {}) => ({
|
|
1111
1114
|
table: e,
|
|
1112
1115
|
op: "delete",
|
|
1113
1116
|
old: t,
|
|
1114
1117
|
new: null,
|
|
1115
1118
|
...n
|
|
1116
|
-
}),
|
|
1119
|
+
}), wo = (e, t, n = {}) => {
|
|
1117
1120
|
let { at: r = "2026-01-01T00:00:00.000Z", column: i = "deletedAt", ...a } = n;
|
|
1118
1121
|
return {
|
|
1119
1122
|
table: e,
|
|
@@ -1128,13 +1131,13 @@ var Nr = (e) => typeof e == "string" && e !== "" ? e : null, Pr = async (e, t, n
|
|
|
1128
1131
|
},
|
|
1129
1132
|
...a
|
|
1130
1133
|
};
|
|
1131
|
-
},
|
|
1134
|
+
}, To = (e) => e == null ? "null" : e instanceof Date ? JSON.stringify(e.toISOString()) : typeof e == "bigint" ? JSON.stringify(e.toString()) : Array.isArray(e) ? `[${e.map(To).join(",")}]` : typeof e == "object" ? `{${Object.entries(e).filter(([, e]) => e !== void 0).sort(([e], [t]) => e < t ? -1 : +(e > t)).map(([e, t]) => `${JSON.stringify(e)}:${To(t)}`).join(",")}}` : JSON.stringify(e) ?? "null", Eo = (e) => Ir("sha256").update([
|
|
1132
1135
|
e.pipe,
|
|
1133
1136
|
e.op,
|
|
1134
1137
|
e.key,
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
].join("\0")).digest("hex").slice(0, 32),
|
|
1138
|
+
To(e.next),
|
|
1139
|
+
To(e.prev)
|
|
1140
|
+
].join("\0")).digest("hex").slice(0, 32), Do = (e, t) => `${e}:${t}`, Oo = (e) => {
|
|
1138
1141
|
let t = e.lastIndexOf(":");
|
|
1139
1142
|
if (t <= 0) return null;
|
|
1140
1143
|
let n = Number(e.slice(t + 1));
|
|
@@ -1142,7 +1145,7 @@ var Nr = (e) => typeof e == "string" && e !== "" ? e : null, Pr = async (e, t, n
|
|
|
1142
1145
|
digest: e.slice(0, t),
|
|
1143
1146
|
occurrence: n
|
|
1144
1147
|
};
|
|
1145
|
-
},
|
|
1148
|
+
}, ko = class {
|
|
1146
1149
|
#e = /* @__PURE__ */ new Map();
|
|
1147
1150
|
#t;
|
|
1148
1151
|
#n;
|
|
@@ -1164,7 +1167,7 @@ var Nr = (e) => typeof e == "string" && e !== "" ? e : null, Pr = async (e, t, n
|
|
|
1164
1167
|
}
|
|
1165
1168
|
seedFromChangeKeys(e, t) {
|
|
1166
1169
|
for (let n of e) {
|
|
1167
|
-
let e =
|
|
1170
|
+
let e = Oo(n);
|
|
1168
1171
|
if (e === null) continue;
|
|
1169
1172
|
let r = this.#e.get(e.digest), i = Math.max(r?.count ?? 0, e.occurrence + 1);
|
|
1170
1173
|
this.#e.set(e.digest, {
|
|
@@ -1185,70 +1188,70 @@ var Nr = (e) => typeof e == "string" && e !== "" ? e : null, Pr = async (e, t, n
|
|
|
1185
1188
|
this.#e.delete(e.value);
|
|
1186
1189
|
}
|
|
1187
1190
|
}
|
|
1188
|
-
},
|
|
1189
|
-
let t = Number(e[
|
|
1191
|
+
}, Ao = "VOLTRO_CHANGE_CLAIMS_TTL_HOURS", jo = 1, Mo = (e = process.env) => {
|
|
1192
|
+
let t = Number(e[Ao]);
|
|
1190
1193
|
return (Number.isFinite(t) && t > 0 ? t : 1) * 2 * 36e5;
|
|
1191
|
-
},
|
|
1192
|
-
let t = e ??
|
|
1194
|
+
}, No = new Lr(), Po = (e, t) => No.run(e, t), Fo = () => No.getStore(), Io = (e) => {
|
|
1195
|
+
let t = e ?? No.getStore();
|
|
1193
1196
|
return t === void 0 ? {} : {
|
|
1194
1197
|
...t.traceId === void 0 ? {} : { traceId: t.traceId },
|
|
1195
1198
|
...t.subjectId === void 0 ? {} : { subjectId: t.subjectId },
|
|
1196
1199
|
...t.procedure === void 0 ? {} : { procedure: t.procedure },
|
|
1197
1200
|
...t.via === void 0 ? {} : { via: t.via }
|
|
1198
1201
|
};
|
|
1199
|
-
},
|
|
1200
|
-
let t =
|
|
1201
|
-
return t === void 0 ? e(void 0) :
|
|
1202
|
-
},
|
|
1203
|
-
for (let [t, n] of
|
|
1204
|
-
let r = n.filter((t) => e - t.at <
|
|
1205
|
-
|
|
1206
|
-
}
|
|
1207
|
-
},
|
|
1202
|
+
}, Lo = (e) => {
|
|
1203
|
+
let t = No.getStore();
|
|
1204
|
+
return t === void 0 ? e(void 0) : No.run(t, () => e(t));
|
|
1205
|
+
}, Ro = 3e4, zo = 1e4, V = /* @__PURE__ */ new Map(), H = 0, Bo = (e, t, n) => `${e}\u0000${t}\u0000${String(n)}`, Vo = (e) => {
|
|
1206
|
+
for (let [t, n] of V) {
|
|
1207
|
+
let r = n.filter((t) => e - t.at < Ro);
|
|
1208
|
+
H -= n.length - r.length, r.length === 0 ? V.delete(t) : r.length !== n.length && V.set(t, r);
|
|
1209
|
+
}
|
|
1210
|
+
}, Ho = (e, t) => {
|
|
1208
1211
|
if (t.traceId === void 0 && t.subjectId === void 0 && t.procedure === void 0) return;
|
|
1209
1212
|
let n = Date.now();
|
|
1210
|
-
if (
|
|
1211
|
-
let r =
|
|
1212
|
-
r === void 0 ?
|
|
1213
|
+
if (H >= zo && Vo(n), H >= zo) return;
|
|
1214
|
+
let r = V.get(e);
|
|
1215
|
+
r === void 0 ? V.set(e, [{
|
|
1213
1216
|
attribution: t,
|
|
1214
1217
|
at: n
|
|
1215
1218
|
}]) : r.push({
|
|
1216
1219
|
attribution: t,
|
|
1217
1220
|
at: n
|
|
1218
|
-
}),
|
|
1219
|
-
},
|
|
1220
|
-
let t =
|
|
1221
|
+
}), H += 1;
|
|
1222
|
+
}, Uo = (e) => {
|
|
1223
|
+
let t = V.get(e);
|
|
1221
1224
|
if (t === void 0 || t.length === 0) return;
|
|
1222
1225
|
let n = t.shift();
|
|
1223
|
-
if (--
|
|
1224
|
-
},
|
|
1225
|
-
let t =
|
|
1226
|
+
if (--H, t.length === 0 && V.delete(e), !(Date.now() - n.at >= Ro)) return n.attribution;
|
|
1227
|
+
}, Wo = (e) => (V.get(e)?.length ?? 0) > 0, U = /* @__PURE__ */ new Map(), W = /* @__PURE__ */ new Map(), G = /* @__PURE__ */ new Map(), Go = 250, Ko = (e) => {
|
|
1228
|
+
let t = W.get(e);
|
|
1226
1229
|
if (t === void 0) return;
|
|
1227
|
-
|
|
1228
|
-
let n =
|
|
1229
|
-
n !== void 0 && (clearTimeout(n),
|
|
1230
|
+
W.delete(e);
|
|
1231
|
+
let n = G.get(e);
|
|
1232
|
+
n !== void 0 && (clearTimeout(n), G.delete(e));
|
|
1230
1233
|
for (let e of t) e();
|
|
1231
|
-
},
|
|
1232
|
-
|
|
1233
|
-
},
|
|
1234
|
-
let t = (
|
|
1234
|
+
}, qo = (e) => {
|
|
1235
|
+
U.set(e, (U.get(e) ?? 0) + 1);
|
|
1236
|
+
}, Jo = (e) => {
|
|
1237
|
+
let t = (U.get(e) ?? 0) - 1;
|
|
1235
1238
|
if (t > 0) {
|
|
1236
|
-
|
|
1239
|
+
U.set(e, t);
|
|
1237
1240
|
return;
|
|
1238
1241
|
}
|
|
1239
|
-
|
|
1240
|
-
},
|
|
1241
|
-
let i = n == null ? void 0 :
|
|
1242
|
+
U.delete(e), Ko(e);
|
|
1243
|
+
}, Yo = (e, t, n, r) => {
|
|
1244
|
+
let i = n == null ? void 0 : Bo(e, t, n), a = () => r(i === void 0 ? void 0 : Uo(i));
|
|
1242
1245
|
if (i === void 0) {
|
|
1243
1246
|
a();
|
|
1244
1247
|
return;
|
|
1245
1248
|
}
|
|
1246
|
-
if (
|
|
1249
|
+
if (Wo(i)) {
|
|
1247
1250
|
a();
|
|
1248
1251
|
return;
|
|
1249
1252
|
}
|
|
1250
|
-
let o =
|
|
1251
|
-
if (o === void 0 && (
|
|
1253
|
+
let o = W.get(e);
|
|
1254
|
+
if (o === void 0 && (U.get(e) ?? 0) === 0) {
|
|
1252
1255
|
a();
|
|
1253
1256
|
return;
|
|
1254
1257
|
}
|
|
@@ -1256,91 +1259,91 @@ var Nr = (e) => typeof e == "string" && e !== "" ? e : null, Pr = async (e, t, n
|
|
|
1256
1259
|
o.push(a);
|
|
1257
1260
|
return;
|
|
1258
1261
|
}
|
|
1259
|
-
|
|
1260
|
-
let s = setTimeout(() =>
|
|
1261
|
-
typeof s == "object" && typeof s.unref == "function" && s.unref(),
|
|
1262
|
-
},
|
|
1263
|
-
|
|
1264
|
-
for (let e of
|
|
1265
|
-
|
|
1266
|
-
},
|
|
1267
|
-
|
|
1262
|
+
W.set(e, [a]);
|
|
1263
|
+
let s = setTimeout(() => Ko(e), Go);
|
|
1264
|
+
typeof s == "object" && typeof s.unref == "function" && s.unref(), G.set(e, s);
|
|
1265
|
+
}, Xo = () => {
|
|
1266
|
+
V.clear(), H = 0, U.clear();
|
|
1267
|
+
for (let e of G.values()) clearTimeout(e);
|
|
1268
|
+
G.clear(), W.clear();
|
|
1269
|
+
}, Zo = () => H, Qo = 64, $o = "\0", es = 32, ts = (e, ...t) => `${e}_${Ir("sha256").update(t.map(String).join($o)).digest("hex").slice(0, es)}`, ns = (e) => e.length + 1 + es, K = /* @__PURE__ */ new Map(), rs = (e, t) => {
|
|
1270
|
+
K.set(e, {
|
|
1268
1271
|
recorder: t.recorder,
|
|
1269
1272
|
tables: new Set(t.tables),
|
|
1270
1273
|
ownTables: new Set(t.ownTables)
|
|
1271
1274
|
});
|
|
1272
|
-
},
|
|
1273
|
-
|
|
1274
|
-
},
|
|
1275
|
-
let t =
|
|
1276
|
-
if (t !== void 0) return t.n += 1,
|
|
1275
|
+
}, is = (e) => {
|
|
1276
|
+
K.delete(e);
|
|
1277
|
+
}, as = () => K.clear(), q = new Lr(), os = (e) => q.run({ n: 1 }, e), ss = (e) => w.suspend(() => {
|
|
1278
|
+
let t = q.getStore();
|
|
1279
|
+
if (t !== void 0) return t.n += 1, w.ensuring(e, w.sync(() => {
|
|
1277
1280
|
--t.n;
|
|
1278
1281
|
}));
|
|
1279
1282
|
let n = { n: 1 };
|
|
1280
|
-
return
|
|
1283
|
+
return q.enterWith(n), w.ensuring(e, w.sync(() => {
|
|
1281
1284
|
--n.n;
|
|
1282
1285
|
}));
|
|
1283
|
-
}),
|
|
1284
|
-
if (
|
|
1285
|
-
for (let t of
|
|
1286
|
+
}), cs = () => (q.getStore()?.n ?? 0) > 0, ls = (e) => {
|
|
1287
|
+
if (K.size === 0 || (q.getStore()?.n ?? 0) > 0) return !1;
|
|
1288
|
+
for (let t of K.values()) if (!t.ownTables.has(e) && t.tables.has(e)) return !0;
|
|
1286
1289
|
return !1;
|
|
1287
|
-
},
|
|
1288
|
-
if (
|
|
1289
|
-
for (let [n, r] of
|
|
1290
|
+
}, us = async (e, t) => {
|
|
1291
|
+
if (K.size !== 0) {
|
|
1292
|
+
for (let [n, r] of K.entries()) if (!r.ownTables.has(t.table) && r.tables.has(t.table)) try {
|
|
1290
1293
|
await r.recorder(e, t);
|
|
1291
1294
|
} catch (e) {
|
|
1292
|
-
let r =
|
|
1295
|
+
let r = yn(e);
|
|
1293
1296
|
throw r === void 0 ? e : Error(`write recorder '${n}' failed while recording a ${t.op} on '${t.table}': ${r}`, { cause: e });
|
|
1294
1297
|
}
|
|
1295
1298
|
}
|
|
1296
|
-
},
|
|
1299
|
+
}, ds = Nr.exponential({
|
|
1297
1300
|
start: 5e-4,
|
|
1298
1301
|
factor: 2,
|
|
1299
1302
|
count: 16
|
|
1300
|
-
}),
|
|
1301
|
-
let n = `${e}\u0000${t}`, r =
|
|
1303
|
+
}), fs = T.counter("voltro_db_queries_total", { description: "Database operations executed, by dialect and operation kind." }), ps = T.histogram("voltro_db_query_duration_seconds", ds, "Database operation duration in seconds, by dialect and operation kind."), ms = T.counter("voltro_db_errors_total", { description: "Database operations that threw, by dialect and operation kind." }), hs = T.gauge("voltro_db_operations_in_flight", { description: "Database operations currently executing, by dialect. An upper bound on connections the framework holds; NOT the driver pool's waiting count." }), gs = T.counter("voltro_db_eager_fallback_total", { description: "Eager-load queries that degraded from the single-roundtrip JSON-agg path to the multi-query walker, by dialect and reason." }), J = [], _s = /* @__PURE__ */ new Map(), vs = /* @__PURE__ */ new Map(), ys = /* @__PURE__ */ new Map(), bs = (e, t) => {
|
|
1304
|
+
let n = `${e}\u0000${t}`, r = _s.get(n);
|
|
1302
1305
|
if (r !== void 0) return r;
|
|
1303
|
-
let i = (n) =>
|
|
1304
|
-
count: i(
|
|
1305
|
-
duration: i(
|
|
1306
|
-
errors: i(
|
|
1306
|
+
let i = (n) => T.tagged(T.tagged(n, "dialect", e), "op", t), a = {
|
|
1307
|
+
count: i(fs),
|
|
1308
|
+
duration: i(ps),
|
|
1309
|
+
errors: i(ms)
|
|
1307
1310
|
};
|
|
1308
|
-
return
|
|
1309
|
-
},
|
|
1310
|
-
|
|
1311
|
-
},
|
|
1312
|
-
let n = Math.max(0, (
|
|
1313
|
-
n === 0 ?
|
|
1314
|
-
let r =
|
|
1315
|
-
r === void 0 && (r =
|
|
1316
|
-
},
|
|
1317
|
-
let t =
|
|
1318
|
-
t.count.unsafeUpdate(1,
|
|
1319
|
-
},
|
|
1311
|
+
return _s.set(n, a), a;
|
|
1312
|
+
}, xs = () => {
|
|
1313
|
+
_s.clear(), vs.clear(), ys.clear();
|
|
1314
|
+
}, Ss = () => _s.size + vs.size + ys.size, Cs = /* @__PURE__ */ new Map(), ws = (e, t) => {
|
|
1315
|
+
let n = Math.max(0, (Cs.get(e) ?? 0) + t);
|
|
1316
|
+
n === 0 ? Cs.delete(e) : Cs.set(e, n);
|
|
1317
|
+
let r = vs.get(e);
|
|
1318
|
+
r === void 0 && (r = T.tagged(hs, "dialect", e), vs.set(e, r)), r.unsafeUpdate(n, J);
|
|
1319
|
+
}, Ts = (e) => Cs.get(e) ?? 0, Es = (e) => {
|
|
1320
|
+
let t = bs(String(e.dialect), e.op);
|
|
1321
|
+
t.count.unsafeUpdate(1, J), t.duration.unsafeUpdate(e.durationMs / 1e3, J), e.status === "error" && t.errors.unsafeUpdate(1, J);
|
|
1322
|
+
}, Ds = async (e, t, n) => {
|
|
1320
1323
|
let r = performance.now(), i = String(e);
|
|
1321
|
-
|
|
1324
|
+
ws(i, 1);
|
|
1322
1325
|
let a = "ok";
|
|
1323
1326
|
try {
|
|
1324
1327
|
return await n();
|
|
1325
1328
|
} catch (e) {
|
|
1326
1329
|
throw a = "error", e;
|
|
1327
1330
|
} finally {
|
|
1328
|
-
|
|
1331
|
+
ws(i, -1), Es({
|
|
1329
1332
|
dialect: e,
|
|
1330
1333
|
op: t,
|
|
1331
1334
|
durationMs: performance.now() - r,
|
|
1332
1335
|
status: a
|
|
1333
1336
|
});
|
|
1334
1337
|
}
|
|
1335
|
-
},
|
|
1338
|
+
}, Os = 3e5, ks = (e) => {
|
|
1336
1339
|
if (e == null || e === "") return;
|
|
1337
1340
|
let t = Number(e);
|
|
1338
1341
|
return Number.isFinite(t) && t >= 0 ? Math.floor(t) : void 0;
|
|
1339
|
-
},
|
|
1340
|
-
let n =
|
|
1342
|
+
}, As = (e, t = process.env) => ks(t.VOLTRO_DB_EAGER_FALLBACK_WARN_INTERVAL_MS) ?? ks(e) ?? 3e5, js = (e, t = {}) => {
|
|
1343
|
+
let n = As(t.warnIntervalMs), r = t.now ?? (() => Date.now()), i = /* @__PURE__ */ new Map();
|
|
1341
1344
|
return (t) => {
|
|
1342
|
-
let a = `${t.dialect} ${t.reason}`, o =
|
|
1343
|
-
o === void 0 && (o =
|
|
1345
|
+
let a = `${t.dialect} ${t.reason}`, o = ys.get(a);
|
|
1346
|
+
o === void 0 && (o = T.tagged(T.tagged(gs, "dialect", String(t.dialect)), "reason", t.reason), ys.set(a, o)), o.unsafeUpdate(1, J);
|
|
1344
1347
|
let s = `${t.table}\u0000${t.reason}`, c = i.get(s), l = c === void 0 || n > 0 && r() - c >= n, u = {
|
|
1345
1348
|
table: t.table,
|
|
1346
1349
|
dialect: String(t.dialect),
|
|
@@ -1354,37 +1357,37 @@ var Nr = (e) => typeof e == "string" && e !== "" ? e : null, Pr = async (e, t, n
|
|
|
1354
1357
|
}
|
|
1355
1358
|
i.set(s, r()), e.warn(t.reason === "execute-failed" ? "eager-load JSON-agg statement FAILED and was re-run on the multi-query walker — this query pays both paths on every call. Counted as voltro_db_eager_fallback_total{reason=\"execute-failed\"}." : "eager-load could not be compiled to a single JSON-agg roundtrip and is running on the multi-query walker — one round trip per relation level, on every call. Counted as voltro_db_eager_fallback_total{reason=\"not-compilable\"}.", u);
|
|
1356
1359
|
};
|
|
1357
|
-
},
|
|
1358
|
-
if (
|
|
1359
|
-
throw
|
|
1360
|
-
},
|
|
1361
|
-
let t = 0, n =
|
|
1360
|
+
}, Ms = (e) => {
|
|
1361
|
+
if (Mr.isSuccess(e)) return e.value;
|
|
1362
|
+
throw kr.squash(e.cause);
|
|
1363
|
+
}, Ns = "10 millis", Ps = 3, Fs = (e) => Pr.exponential(Ns).pipe(Pr.compose(Pr.recurs(Ps)), Pr.whileInput(e)), Is = async (e) => {
|
|
1364
|
+
let t = 0, n = w.suspend(() => {
|
|
1362
1365
|
let n = ++t;
|
|
1363
|
-
return e.withTransaction(
|
|
1364
|
-
if (
|
|
1365
|
-
let r = t.value, i =
|
|
1366
|
+
return e.withTransaction(w.flatMap(w.serviceOption(Rr), (t) => {
|
|
1367
|
+
if (E.isNone(t)) return w.fail(/* @__PURE__ */ Error(`${e.label}: TransactionConnection unexpectedly missing inside withTransaction.`));
|
|
1368
|
+
let r = t.value, i = w.tryPromise({
|
|
1366
1369
|
try: () => e.body(r, n),
|
|
1367
1370
|
catch: (e) => e
|
|
1368
1371
|
});
|
|
1369
|
-
return e.prepare === void 0 ? i :
|
|
1370
|
-
})).pipe(
|
|
1371
|
-
}).pipe(
|
|
1372
|
-
return
|
|
1373
|
-
},
|
|
1372
|
+
return e.prepare === void 0 ? i : w.flatMap(e.prepare(r), () => i);
|
|
1373
|
+
})).pipe(w.catchAllDefect((t) => e.isRetryable(t) ? w.fail(t) : w.die(t)));
|
|
1374
|
+
}).pipe(w.retry(Fs(e.isRetryable)), w.withSpan(e.span.name, { attributes: { ...e.span.attributes } }));
|
|
1375
|
+
return Ds(e.dialect, "transaction", async () => Ms(await e.runPromiseExit(e.wrapProgram === void 0 ? n : e.wrapProgram(n))));
|
|
1376
|
+
}, Ls = class extends Error {
|
|
1374
1377
|
swallowed;
|
|
1375
1378
|
_tag = "TransactionAborted";
|
|
1376
1379
|
constructor(e, t) {
|
|
1377
1380
|
super(`${e}: a statement failed inside this transaction and the error was caught, but the database had already aborted the transaction — every later statement was refused, and COMMIT would have rolled back ALL of its writes, including the ones that succeeded. Nothing was committed.
|
|
1378
|
-
the caught failure: ${
|
|
1381
|
+
the caught failure: ${Vs(t)}\n to tolerate a failing statement and keep the rest, run it inside \`tx.savepoint(() => …)\` — only that statement is rolled back. To keep all-or-nothing, let the error propagate.`, { cause: t }), this.swallowed = t, this.name = "TransactionAbortedError";
|
|
1379
1382
|
}
|
|
1380
|
-
},
|
|
1383
|
+
}, Rs = (e, t = "transactional()") => {
|
|
1381
1384
|
let n = 0, r, i = (e) => {
|
|
1382
1385
|
r === void 0 && (r = { error: e });
|
|
1383
1386
|
};
|
|
1384
1387
|
return {
|
|
1385
1388
|
track: (a) => r === void 0 ? n > 0 ? a() : a().catch((t) => {
|
|
1386
1389
|
throw e(t) && i(t), t;
|
|
1387
|
-
}) : Promise.reject(new
|
|
1390
|
+
}) : Promise.reject(new Ls(t, r.error)),
|
|
1388
1391
|
inSavepoint: async (e) => {
|
|
1389
1392
|
n++;
|
|
1390
1393
|
try {
|
|
@@ -1396,7 +1399,7 @@ var Nr = (e) => typeof e == "string" && e !== "" ? e : null, Pr = async (e, t, n
|
|
|
1396
1399
|
record: i,
|
|
1397
1400
|
abortedBy: () => r
|
|
1398
1401
|
};
|
|
1399
|
-
},
|
|
1402
|
+
}, zs = async (e, t) => {
|
|
1400
1403
|
let { tracker: n, name: r, exec: i, spelling: a } = e;
|
|
1401
1404
|
await n.track(() => i(a === "mssql" ? `SAVE TRANSACTION ${r}` : `SAVEPOINT ${r}`));
|
|
1402
1405
|
try {
|
|
@@ -1405,8 +1408,8 @@ var Nr = (e) => typeof e == "string" && e !== "" ? e : null, Pr = async (e, t, n
|
|
|
1405
1408
|
} catch (e) {
|
|
1406
1409
|
throw await i(a === "mssql" ? `ROLLBACK TRANSACTION ${r}` : `ROLLBACK TO SAVEPOINT ${r}`).catch((e) => n.record(e)), a === "standard" && await i(`RELEASE SAVEPOINT ${r}`).catch(() => void 0), e;
|
|
1407
1410
|
}
|
|
1408
|
-
},
|
|
1409
|
-
for (let t of
|
|
1411
|
+
}, Bs = (e) => e instanceof Ls || typeof e == "object" && !!e && e._tag === "TransactionAborted", Vs = (e) => {
|
|
1412
|
+
for (let t of jn(e)) {
|
|
1410
1413
|
let e = t;
|
|
1411
1414
|
for (let t = 0; t < 5 && typeof e == "object" && e; t++) {
|
|
1412
1415
|
let t = e.code, n = e.message;
|
|
@@ -1415,14 +1418,14 @@ var Nr = (e) => typeof e == "string" && e !== "" ? e : null, Pr = async (e, t, n
|
|
|
1415
1418
|
}
|
|
1416
1419
|
}
|
|
1417
1420
|
return e instanceof Error ? e.message : String(e);
|
|
1418
|
-
},
|
|
1419
|
-
let t =
|
|
1421
|
+
}, Hs = async (e) => {
|
|
1422
|
+
let t = Fo(), n = t === void 0 ? (e) => e() : (e) => Po(t, e), r = await Is({
|
|
1420
1423
|
...e,
|
|
1421
1424
|
body: (r) => {
|
|
1422
1425
|
let i = e.makeView(r, t);
|
|
1423
1426
|
return n(() => e.work(i)).then((t) => {
|
|
1424
1427
|
let n = i.abortedBy?.();
|
|
1425
|
-
if (n !== void 0) throw e.isRetryable(n.error) ? n.error : new
|
|
1428
|
+
if (n !== void 0) throw e.isRetryable(n.error) ? n.error : new Ls(e.label, n.error);
|
|
1426
1429
|
return {
|
|
1427
1430
|
result: t,
|
|
1428
1431
|
view: i
|
|
@@ -1434,50 +1437,50 @@ var Nr = (e) => typeof e == "string" && e !== "" ? e : null, Pr = async (e, t, n
|
|
|
1434
1437
|
}
|
|
1435
1438
|
});
|
|
1436
1439
|
return r.view.commitEvents(), r.result;
|
|
1437
|
-
},
|
|
1440
|
+
}, Us = /* @__PURE__ */ new Set([
|
|
1438
1441
|
"1213",
|
|
1439
1442
|
"ER_LOCK_DEADLOCK",
|
|
1440
1443
|
"1205",
|
|
1441
1444
|
"ER_LOCK_WAIT_TIMEOUT",
|
|
1442
1445
|
"1020",
|
|
1443
1446
|
"ER_CHECKREAD"
|
|
1444
|
-
]),
|
|
1447
|
+
]), Ws = /* @__PURE__ */ new Set(["40001", "40P01"]), Gs = /* @__PURE__ */ new Set(["1205"]), Ks = /* @__PURE__ */ new Set([
|
|
1445
1448
|
"SQLITE_BUSY",
|
|
1446
1449
|
"5",
|
|
1447
1450
|
"SQLITE_LOCKED",
|
|
1448
1451
|
"6"
|
|
1449
|
-
]),
|
|
1452
|
+
]), qs = /write-write conflict|write-read conflict|database is locked|table is locked|database is busy/i, Js = /* @__PURE__ */ new Set([
|
|
1450
1453
|
1213,
|
|
1451
1454
|
1205,
|
|
1452
1455
|
1020
|
|
1453
|
-
]),
|
|
1454
|
-
...
|
|
1455
|
-
...
|
|
1456
|
-
...
|
|
1457
|
-
...
|
|
1458
|
-
]),
|
|
1456
|
+
]), Ys = /* @__PURE__ */ new Set([
|
|
1457
|
+
...Us,
|
|
1458
|
+
...Ws,
|
|
1459
|
+
...Gs,
|
|
1460
|
+
...Ks
|
|
1461
|
+
]), Xs = (e) => jn(e).some(Zs), Zs = (e) => {
|
|
1459
1462
|
let t = e;
|
|
1460
1463
|
for (let e = 0; e < 6 && typeof t == "object" && t; e++) {
|
|
1461
1464
|
let e = t;
|
|
1462
|
-
if (typeof e.errno == "number" &&
|
|
1465
|
+
if (typeof e.errno == "number" && Js.has(e.errno) || typeof e.number == "number" && Gs.has(String(e.number)) || typeof e.code == "string" && Ys.has(e.code) || typeof e.sqlState == "string" && Ws.has(e.sqlState) || typeof e.message == "string" && qs.test(e.message)) return !0;
|
|
1463
1466
|
t = e.cause;
|
|
1464
1467
|
}
|
|
1465
1468
|
return !1;
|
|
1466
|
-
},
|
|
1467
|
-
id:
|
|
1468
|
-
fields: { expiresAt:
|
|
1469
|
+
}, Qs = "voltro/expires", $s = () => ot({
|
|
1470
|
+
id: Qs,
|
|
1471
|
+
fields: { expiresAt: n().nullable() },
|
|
1469
1472
|
behaviors: { defaultWhere: () => "expiresAt IS NULL OR expiresAt > now()" }
|
|
1470
|
-
}),
|
|
1471
|
-
id:
|
|
1473
|
+
}), ec = "voltro/localFirst", tc = () => ot({
|
|
1474
|
+
id: ec,
|
|
1472
1475
|
fields: {}
|
|
1473
|
-
}),
|
|
1476
|
+
}), nc = (e) => e.appliedMixins.some((e) => e.id === ec), rc = (e) => {
|
|
1474
1477
|
let t = [];
|
|
1475
|
-
for (let n of Object.values(e))
|
|
1478
|
+
for (let n of Object.values(e)) nc(n) && t.push(n.tableName);
|
|
1476
1479
|
return t;
|
|
1477
|
-
},
|
|
1478
|
-
let i =
|
|
1480
|
+
}, ic = class extends jr.TaggedError("TableStreamError") {}, ac = 1e3, oc = (e, t, n, r) => {
|
|
1481
|
+
let i = E.match(r, {
|
|
1479
1482
|
onNone: () => e.where,
|
|
1480
|
-
onSome: (n) => e.where ?
|
|
1483
|
+
onSome: (n) => e.where ? gt(e.where, Mt(t, n)) : Mt(t, n)
|
|
1481
1484
|
});
|
|
1482
1485
|
return {
|
|
1483
1486
|
table: e.table,
|
|
@@ -1492,19 +1495,19 @@ var Nr = (e) => typeof e == "string" && e !== "" ? e : null, Pr = async (e, t, n
|
|
|
1492
1495
|
...e.includeDeleted === void 0 ? {} : { includeDeleted: e.includeDeleted },
|
|
1493
1496
|
...e.crossTenant === void 0 ? {} : { crossTenant: e.crossTenant }
|
|
1494
1497
|
};
|
|
1495
|
-
},
|
|
1496
|
-
let n = t.pk ?? "id", r = t.chunkSize ??
|
|
1497
|
-
return
|
|
1498
|
-
let a =
|
|
1499
|
-
try: () => e.query(
|
|
1500
|
-
catch: (e) => new
|
|
1498
|
+
}, sc = (e, t) => {
|
|
1499
|
+
let n = t.pk ?? "id", r = t.chunkSize ?? ac;
|
|
1500
|
+
return Fr.paginateChunkEffect(E.none(), (i) => {
|
|
1501
|
+
let a = w.tryPromise({
|
|
1502
|
+
try: () => e.query(oc(t, n, r, i)),
|
|
1503
|
+
catch: (e) => new ic({
|
|
1501
1504
|
table: t.table,
|
|
1502
1505
|
cause: e
|
|
1503
1506
|
})
|
|
1504
1507
|
});
|
|
1505
|
-
return (t.retry ? a.pipe(
|
|
1508
|
+
return (t.retry ? a.pipe(w.retry(t.retry)) : a).pipe(w.map((e) => [Ar.fromIterable(e), e.length === r && e.length > 0 ? E.some(E.some(e[e.length - 1][n])) : E.none()]));
|
|
1506
1509
|
});
|
|
1507
|
-
},
|
|
1510
|
+
}, cc = (e) => {
|
|
1508
1511
|
let t = e.alpha ?? .5;
|
|
1509
1512
|
if (t < 0 || t > 1) throw Error(`hybridSearch: alpha must be in [0, 1], got ${t}`);
|
|
1510
1513
|
return (n) => {
|
|
@@ -1518,7 +1521,7 @@ var Nr = (e) => typeof e == "string" && e !== "" ? e : null, Pr = async (e, t, n
|
|
|
1518
1521
|
queryText: e.vector.query,
|
|
1519
1522
|
distance: e.vector.distance ?? "cosine",
|
|
1520
1523
|
alpha: t
|
|
1521
|
-
}, i =
|
|
1524
|
+
}, i = dr(n.table, e.fts.indexName, n.fullTextIndexes);
|
|
1522
1525
|
return {
|
|
1523
1526
|
...n,
|
|
1524
1527
|
annClause: r,
|
|
@@ -1531,17 +1534,17 @@ var Nr = (e) => typeof e == "string" && e !== "" ? e : null, Pr = async (e, t, n
|
|
|
1531
1534
|
}
|
|
1532
1535
|
};
|
|
1533
1536
|
};
|
|
1534
|
-
},
|
|
1537
|
+
}, lc = async (e, t) => {
|
|
1535
1538
|
let n = e.as ?? "embedding", r = t.row[e.from];
|
|
1536
1539
|
if (typeof r != "string" || r.length === 0) return {};
|
|
1537
1540
|
let i = await t.embed(r);
|
|
1538
1541
|
return { [n]: i };
|
|
1539
|
-
},
|
|
1542
|
+
}, uc = (e) => {
|
|
1540
1543
|
if (!Number.isInteger(e.dimensions) || e.dimensions <= 0) throw Error(`vectorEmbedding: dimensions must be a positive integer, got ${String(e.dimensions)}.`);
|
|
1541
|
-
let t = e.as ?? "embedding", n = (t) =>
|
|
1542
|
-
return
|
|
1544
|
+
let t = e.as ?? "embedding", n = (t) => lc(e, t);
|
|
1545
|
+
return ot({
|
|
1543
1546
|
id: "voltro/vectorEmbedding",
|
|
1544
|
-
fields: { [t]:
|
|
1547
|
+
fields: { [t]: Gt(e.dimensions) },
|
|
1545
1548
|
...e.index === !1 ? {} : { indexes: [{
|
|
1546
1549
|
fields: [t],
|
|
1547
1550
|
kind: "hnsw",
|
|
@@ -1556,19 +1559,19 @@ var Nr = (e) => typeof e == "string" && e !== "" ? e : null, Pr = async (e, t, n
|
|
|
1556
1559
|
beforeUpdate: n
|
|
1557
1560
|
}
|
|
1558
1561
|
});
|
|
1559
|
-
},
|
|
1562
|
+
}, dc = 63, fc = "br_pr", Y = class extends Error {
|
|
1560
1563
|
_tag = "BranchNameInvalid";
|
|
1561
1564
|
constructor(e) {
|
|
1562
1565
|
super(e), this.name = "BranchNameInvalid";
|
|
1563
1566
|
}
|
|
1564
|
-
},
|
|
1567
|
+
}, pc = (e, t) => {
|
|
1565
1568
|
if (!Number.isInteger(t) || t < 0) throw new Y(`prNumber must be a non-negative integer, got ${String(t)}`);
|
|
1566
|
-
let n =
|
|
1569
|
+
let n = We(e);
|
|
1567
1570
|
if (n.replace(/_/g, "") === "") throw new Y(`app slug '${e}' has no usable identifier characters`);
|
|
1568
|
-
let r = `${
|
|
1569
|
-
if (r.length >
|
|
1571
|
+
let r = `${fc}${t}_${n}`;
|
|
1572
|
+
if (r.length > dc) throw new Y(`branch namespace '${r}' exceeds the ${dc}-byte identifier limit — use a shorter app slug`);
|
|
1570
1573
|
return r;
|
|
1571
|
-
},
|
|
1574
|
+
}, mc = (e) => e.startsWith(fc), hc = {
|
|
1572
1575
|
requested: {
|
|
1573
1576
|
provision: "provisioning",
|
|
1574
1577
|
destroy: "destroying"
|
|
@@ -1587,18 +1590,18 @@ var Nr = (e) => typeof e == "string" && e !== "" ? e : null, Pr = async (e, t, n
|
|
|
1587
1590
|
fail: "failed"
|
|
1588
1591
|
},
|
|
1589
1592
|
destroyed: {}
|
|
1590
|
-
},
|
|
1593
|
+
}, gc = class extends Error {
|
|
1591
1594
|
from;
|
|
1592
1595
|
event;
|
|
1593
1596
|
_tag = "BranchTransitionInvalid";
|
|
1594
1597
|
constructor(e, t) {
|
|
1595
1598
|
super(`invalid branch transition: ${e} --${t}-->`), this.from = e, this.event = t, this.name = "BranchTransitionInvalid";
|
|
1596
1599
|
}
|
|
1597
|
-
},
|
|
1598
|
-
let n =
|
|
1599
|
-
if (n === void 0) throw new
|
|
1600
|
+
}, _c = (e, t) => {
|
|
1601
|
+
let n = hc[e][t];
|
|
1602
|
+
if (n === void 0) throw new gc(e, t);
|
|
1600
1603
|
return n;
|
|
1601
|
-
},
|
|
1604
|
+
}, vc = (e, t, n, r, i = [], a = []) => {
|
|
1602
1605
|
if (n === "copy" && (r === void 0 || r === "")) throw new Y("seed 'copy' requires a parentNamespace to snapshot from");
|
|
1603
1606
|
let o = [{
|
|
1604
1607
|
kind: "create-namespace",
|
|
@@ -1628,13 +1631,13 @@ var Nr = (e) => typeof e == "string" && e !== "" ? e : null, Pr = async (e, t, n
|
|
|
1628
1631
|
kind: "seed",
|
|
1629
1632
|
detail: `run boot seeds into ${e}`
|
|
1630
1633
|
}), o;
|
|
1631
|
-
},
|
|
1632
|
-
if (!
|
|
1634
|
+
}, yc = (e) => {
|
|
1635
|
+
if (!mc(e)) throw new Y(`refusing to plan teardown of '${e}' — not a branch namespace`);
|
|
1633
1636
|
return [{
|
|
1634
1637
|
kind: "drop-namespace",
|
|
1635
1638
|
detail: e
|
|
1636
1639
|
}];
|
|
1637
|
-
},
|
|
1640
|
+
}, bc = (e) => {
|
|
1638
1641
|
if (e === void 0 || e === "") return !1;
|
|
1639
1642
|
try {
|
|
1640
1643
|
let t = new URL(e).hostname.toLowerCase();
|
|
@@ -1642,27 +1645,27 @@ var Nr = (e) => typeof e == "string" && e !== "" ? e : null, Pr = async (e, t, n
|
|
|
1642
1645
|
} catch {
|
|
1643
1646
|
return /\bneon\.(tech|build)\b/i.test(e);
|
|
1644
1647
|
}
|
|
1645
|
-
},
|
|
1648
|
+
}, xc = (e) => e.prefer === void 0 ? e.seed === "copy" && bc(e.dbUrl) ? "neon-cow" : "namespace" : e.prefer, Sc = (e, t = {}) => [{
|
|
1646
1649
|
kind: "neon-branch-create",
|
|
1647
1650
|
detail: `${t.parentBranch ?? "main"} → ${e} (copy-on-write)`
|
|
1648
|
-
}],
|
|
1649
|
-
if (!
|
|
1651
|
+
}], Cc = (e) => {
|
|
1652
|
+
if (!mc(e)) throw new Y(`refusing to plan teardown of '${e}' — not a branch namespace`);
|
|
1650
1653
|
return [{
|
|
1651
1654
|
kind: "neon-branch-delete",
|
|
1652
1655
|
detail: e
|
|
1653
1656
|
}];
|
|
1654
|
-
},
|
|
1657
|
+
}, wc = (e) => e.mechanism === "neon-cow" ? Sc(e.branchId, e.neonParentBranch === void 0 ? {} : { parentBranch: e.neonParentBranch }) : vc(e.branchId, e.tableNames, e.seed, e.parentNamespace, e.foreignKeys, e.indexNames), Tc = (e, t) => e === "neon-cow" ? Cc(t) : yc(t), Ec = (e, t, n) => {
|
|
1655
1658
|
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);
|
|
1656
1659
|
return {
|
|
1657
1660
|
evict: i,
|
|
1658
1661
|
rejectNew: r.filter((e) => !a.has(e.namespace)).length >= t.maxBranches
|
|
1659
1662
|
};
|
|
1660
|
-
},
|
|
1661
|
-
let n =
|
|
1663
|
+
}, Dc = async (e, t) => {
|
|
1664
|
+
let n = pc(e.appSlug, e.prNumber), r = xc({
|
|
1662
1665
|
seed: e.seed,
|
|
1663
1666
|
...e.dbUrl === void 0 ? {} : { dbUrl: e.dbUrl },
|
|
1664
1667
|
...e.prefer === void 0 ? {} : { prefer: e.prefer }
|
|
1665
|
-
}), i =
|
|
1668
|
+
}), i = wc({
|
|
1666
1669
|
mechanism: r,
|
|
1667
1670
|
branchId: n,
|
|
1668
1671
|
tableNames: e.tableNames,
|
|
@@ -1691,15 +1694,15 @@ var Nr = (e) => typeof e == "string" && e !== "" ? e : null, Pr = async (e, t, n
|
|
|
1691
1694
|
mechanism: r,
|
|
1692
1695
|
steps: i
|
|
1693
1696
|
};
|
|
1694
|
-
},
|
|
1695
|
-
let r =
|
|
1697
|
+
}, Oc = async (e, t, n) => {
|
|
1698
|
+
let r = Tc(t, e);
|
|
1696
1699
|
return t === "neon-cow" ? await n.neonBranchDelete(e) : await n.dropNamespace(e), r;
|
|
1697
|
-
},
|
|
1700
|
+
}, kc = (e, t, n) => Ec(e, t, n), X = (e) => `"${e.replace(/"/g, "\"\"")}"`, Ac = {
|
|
1698
1701
|
cascade: "CASCADE",
|
|
1699
1702
|
restrict: "RESTRICT",
|
|
1700
1703
|
setNull: "SET NULL",
|
|
1701
1704
|
noAction: "NO ACTION"
|
|
1702
|
-
}, Z = (e) => `'${e.replace(/'/g, "''")}'`,
|
|
1705
|
+
}, Z = (e) => `'${e.replace(/'/g, "''")}'`, jc = (e, t) => {
|
|
1703
1706
|
let n = t.columns.map(Z).join(", ");
|
|
1704
1707
|
return `DO $voltro_branch$
|
|
1705
1708
|
DECLARE derived name;
|
|
@@ -1726,10 +1729,10 @@ BEGIN
|
|
|
1726
1729
|
END IF;
|
|
1727
1730
|
END
|
|
1728
1731
|
$voltro_branch$`;
|
|
1729
|
-
},
|
|
1730
|
-
let n = t.onDelete === void 0 ? "" : ` ON DELETE ${
|
|
1732
|
+
}, Mc = (e, t) => {
|
|
1733
|
+
let n = t.onDelete === void 0 ? "" : ` ON DELETE ${Ac[t.onDelete]}`, r = t.onUpdate === void 0 ? "" : ` ON UPDATE ${Ac[t.onUpdate]}`;
|
|
1731
1734
|
return `ALTER TABLE ${X(e)}.${X(t.table)} ADD FOREIGN KEY (${X(t.column)}) REFERENCES ${X(e)}.${X(t.targetTable)} (${X(t.targetColumn)})${n}${r}`;
|
|
1732
|
-
},
|
|
1735
|
+
}, Nc = (e) => {
|
|
1733
1736
|
let t = () => {
|
|
1734
1737
|
throw Error("namespace branch executor: Neon ops require a neon-cow executor (use a Neon connection for copy-on-write branches)");
|
|
1735
1738
|
};
|
|
@@ -1737,24 +1740,24 @@ $voltro_branch$`;
|
|
|
1737
1740
|
createNamespace: (t) => e.run(`CREATE SCHEMA IF NOT EXISTS ${X(t)}`),
|
|
1738
1741
|
createTable: (t, n) => e.run(`CREATE TABLE IF NOT EXISTS ${X(t)}.${X(n)} (LIKE ${X(n)} INCLUDING ALL)`),
|
|
1739
1742
|
copyTable: (t, n, r) => e.run(`INSERT INTO ${X(n)}.${X(r)} SELECT * FROM ${X(t)}.${X(r)}`),
|
|
1740
|
-
addForeignKey: (t, n) => e.run(
|
|
1741
|
-
restoreIndexName: (t, n) => e.run(
|
|
1743
|
+
addForeignKey: (t, n) => e.run(Mc(t, n)),
|
|
1744
|
+
restoreIndexName: (t, n) => e.run(jc(t, n)),
|
|
1742
1745
|
dropNamespace: (t) => e.run(`DROP SCHEMA IF EXISTS ${X(t)} CASCADE`),
|
|
1743
1746
|
neonBranchCreate: t,
|
|
1744
1747
|
neonBranchDelete: t
|
|
1745
1748
|
};
|
|
1746
|
-
},
|
|
1749
|
+
}, Pc = class extends Error {
|
|
1747
1750
|
_tag = "TenantResidencyUnresolved";
|
|
1748
1751
|
constructor(e) {
|
|
1749
1752
|
super(e), this.name = "TenantResidencyUnresolved";
|
|
1750
1753
|
}
|
|
1751
|
-
},
|
|
1754
|
+
}, Fc = class extends Error {
|
|
1752
1755
|
region;
|
|
1753
1756
|
_tag = "TenantRegionUnavailable";
|
|
1754
1757
|
constructor(e, t) {
|
|
1755
1758
|
super(t), this.region = e, this.name = "TenantRegionUnavailable";
|
|
1756
1759
|
}
|
|
1757
|
-
},
|
|
1760
|
+
}, Ic, Lc = (e) => {
|
|
1758
1761
|
if (e.homes === void 0) throw Error("setResidencyConfig: `homes` is required");
|
|
1759
1762
|
if (e.servableRegions === void 0 || e.servableRegions.length === 0) throw Error("setResidencyConfig: `servableRegions` must be non-empty (which regions this deployment serves)");
|
|
1760
1763
|
let t = /* @__PURE__ */ new Map();
|
|
@@ -1763,55 +1766,55 @@ $voltro_branch$`;
|
|
|
1763
1766
|
if (e !== void 0 && e !== n.region) throw Error(`residency: tenant '${n.tenantId}' is mapped to two regions ('${e}' and '${n.region}')`);
|
|
1764
1767
|
t.set(n.tenantId, n.region);
|
|
1765
1768
|
}
|
|
1766
|
-
return
|
|
1767
|
-
},
|
|
1768
|
-
|
|
1769
|
-
},
|
|
1770
|
-
if (e == null || e === "") throw new
|
|
1769
|
+
return Ic = e, e;
|
|
1770
|
+
}, Rc = () => Ic, zc = () => {
|
|
1771
|
+
Ic = void 0;
|
|
1772
|
+
}, Bc = (e, t) => {
|
|
1773
|
+
if (e == null || e === "") throw new Pc("residency is on but the request has no resolvable tenant — refusing to bind a store");
|
|
1771
1774
|
let n = t.homes.find((t) => t.tenantId === e);
|
|
1772
|
-
if (n === void 0) throw new
|
|
1775
|
+
if (n === void 0) throw new Pc(`no residency home is mapped for tenant '${e}' — refusing to fall back to a default store (would be a residency violation)`);
|
|
1773
1776
|
return n;
|
|
1774
|
-
},
|
|
1775
|
-
let n =
|
|
1777
|
+
}, Vc = (e, t) => t.servableRegions.includes(e), Hc = (e, t) => {
|
|
1778
|
+
let n = Bc(e.tenantId, t), r = Ie(n.tenantId);
|
|
1776
1779
|
return {
|
|
1777
1780
|
region: n.region,
|
|
1778
1781
|
namespace: r,
|
|
1779
1782
|
...n.connectionKey === void 0 ? {} : { connectionKey: n.connectionKey }
|
|
1780
1783
|
};
|
|
1781
|
-
},
|
|
1782
|
-
let r =
|
|
1783
|
-
if (!
|
|
1784
|
+
}, Uc = (e, t, n) => {
|
|
1785
|
+
let r = Hc(e, t);
|
|
1786
|
+
if (!Vc(r.region, t)) throw new Fc(r.region, `tenant homed in region '${r.region}', which this deployment does not serve — route to the home region`);
|
|
1784
1787
|
let i = n.get(r.region);
|
|
1785
|
-
if (i === void 0) throw new
|
|
1788
|
+
if (i === void 0) throw new Fc(r.region, `no store handle for home region '${r.region}' (declared servable but not wired) — failing closed`);
|
|
1786
1789
|
return {
|
|
1787
1790
|
store: i,
|
|
1788
1791
|
placement: r
|
|
1789
1792
|
};
|
|
1790
|
-
},
|
|
1791
|
-
let { store: i, placement: a } =
|
|
1793
|
+
}, Wc = async (e, t, n, r) => {
|
|
1794
|
+
let { store: i, placement: a } = Uc(e, t, n);
|
|
1792
1795
|
return await r(i, a), a;
|
|
1793
|
-
},
|
|
1796
|
+
}, Gc = (e) => {
|
|
1794
1797
|
if (typeof e == "string") return e;
|
|
1795
1798
|
if ("jsonPath" in e) {
|
|
1796
1799
|
let { column: t, path: n, numeric: r } = e.jsonPath;
|
|
1797
1800
|
return `(json:${t}->${n.join(".")}${r ? "::num" : ""})`;
|
|
1798
1801
|
}
|
|
1799
1802
|
return `(${e.expr})`;
|
|
1800
|
-
}, Q = (e) => e.map(
|
|
1803
|
+
}, Q = (e) => e.map(Gc), Kc = (e, t) => {
|
|
1801
1804
|
if (e.length !== t.length) return !1;
|
|
1802
|
-
for (let n = 0; n < e.length; n++) if (
|
|
1805
|
+
for (let n = 0; n < e.length; n++) if (Gc(e[n]) !== Gc(t[n])) return !1;
|
|
1803
1806
|
return !0;
|
|
1804
|
-
},
|
|
1807
|
+
}, qc = (e, t) => {
|
|
1805
1808
|
if (e.length >= t.length) return !1;
|
|
1806
|
-
for (let n = 0; n < e.length; n++) if (
|
|
1809
|
+
for (let n = 0; n < e.length; n++) if (Gc(e[n]) !== Gc(t[n])) return !1;
|
|
1807
1810
|
return !0;
|
|
1808
|
-
},
|
|
1811
|
+
}, Jc = (e) => {
|
|
1809
1812
|
let t = [], n = e.appliedIndexes, r = e.tableName;
|
|
1810
1813
|
for (let e = 0; e < n.length; e++) {
|
|
1811
1814
|
let i = n[e];
|
|
1812
1815
|
for (let a = e + 1; a < n.length; a++) {
|
|
1813
1816
|
let e = n[a];
|
|
1814
|
-
if (
|
|
1817
|
+
if (Kc(i.fields, e.fields)) {
|
|
1815
1818
|
let [n, a] = i.name < e.name ? [i, e] : [e, i];
|
|
1816
1819
|
t.push({
|
|
1817
1820
|
kind: "duplicate-fields",
|
|
@@ -1822,13 +1825,13 @@ $voltro_branch$`;
|
|
|
1822
1825
|
});
|
|
1823
1826
|
continue;
|
|
1824
1827
|
}
|
|
1825
|
-
|
|
1828
|
+
qc(i.fields, e.fields) ? t.push({
|
|
1826
1829
|
kind: "redundant-prefix",
|
|
1827
1830
|
table: r,
|
|
1828
1831
|
redundant: i,
|
|
1829
1832
|
coveredBy: e,
|
|
1830
1833
|
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).`
|
|
1831
|
-
}) :
|
|
1834
|
+
}) : qc(e.fields, i.fields) && t.push({
|
|
1832
1835
|
kind: "redundant-prefix",
|
|
1833
1836
|
table: r,
|
|
1834
1837
|
redundant: e,
|
|
@@ -1838,23 +1841,23 @@ $voltro_branch$`;
|
|
|
1838
1841
|
}
|
|
1839
1842
|
}
|
|
1840
1843
|
return t;
|
|
1841
|
-
},
|
|
1844
|
+
}, Yc = (e) => {
|
|
1842
1845
|
let t = [];
|
|
1843
|
-
for (let n of e) t.push(...
|
|
1846
|
+
for (let n of e) t.push(...Jc(n));
|
|
1844
1847
|
return t;
|
|
1845
|
-
},
|
|
1846
|
-
let n = t.color ?? !0, r = t.indent ?? " ", i = (e) => $(n,
|
|
1848
|
+
}, Xc = "\x1B[", Zc = `${Xc}38;2;245;158;11m`, Qc = `${Xc}38;2;16;185;129m`, $c = (e, t) => `${e}${t}${O.reset}`, $ = (e, t, n) => e ? typeof t == "function" ? t(n) : $c(t, n) : n, el = (e, t = {}) => {
|
|
1849
|
+
let n = t.color ?? !0, r = t.indent ?? " ", i = (e) => $(n, O.dim, e.padEnd(11)), a = (e) => $(n, (e) => O.bold(O.brand(e)), e), o = (e) => $(n, O.brightRed24, e), s = (e) => $(n, Qc, e), c = (e) => $(n, Zc, e), l = (e) => $(n, O.dim, e), u = `${c("index audit")} ${l("·")} ${$(n, O.bold, e.kind)}`, d = e.redundant.fields.length, f = Q(e.coveredBy.fields.slice(d)), p = (e, t) => {
|
|
1847
1850
|
let n = e.slice(0, t), r = e.slice(t), i = [];
|
|
1848
1851
|
return n.length > 0 && i.push(s(`[${n.join(", ")}]`)), r.length > 0 && i.push(c(`+ [${r.join(", ")}]`)), i.join(" ");
|
|
1849
1852
|
}, m = [];
|
|
1850
|
-
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,
|
|
1851
|
-
},
|
|
1853
|
+
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, O.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");
|
|
1854
|
+
}, tl = (e, { apply: t, undo: n }) => ({
|
|
1852
1855
|
name: e,
|
|
1853
1856
|
apply: t,
|
|
1854
1857
|
undo: n
|
|
1855
|
-
}),
|
|
1858
|
+
}), nl = (e) => {
|
|
1856
1859
|
if (!/^\d{14}_/.test(e.id)) throw Error(`migration "${e.id}": id must start with a 14-digit timestamp followed by "_" (convention: <YYYYMMDDHHMMSS>_<slug>)`);
|
|
1857
|
-
let t = e.steps({ step:
|
|
1860
|
+
let t = e.steps({ step: tl });
|
|
1858
1861
|
if (t.length === 0) throw Error(`migration "${e.id}": at least one step is required`);
|
|
1859
1862
|
return {
|
|
1860
1863
|
__migration: !0,
|
|
@@ -1862,42 +1865,42 @@ $voltro_branch$`;
|
|
|
1862
1865
|
name: e.name,
|
|
1863
1866
|
steps: t
|
|
1864
1867
|
};
|
|
1865
|
-
},
|
|
1868
|
+
}, rl = (e) => typeof e == "object" && !!e && "__migration" in e && e.__migration === !0, il = mr.tableName, al = (e) => Ir("sha256").update(`${e.type}\u0000${e.id}`, "utf8").digest("hex"), ol = async (e, t) => {
|
|
1866
1869
|
let [n] = await e.query({
|
|
1867
|
-
table:
|
|
1868
|
-
predicate:
|
|
1870
|
+
table: il,
|
|
1871
|
+
predicate: On("id", al(t)),
|
|
1869
1872
|
order: [],
|
|
1870
1873
|
take: 1,
|
|
1871
1874
|
skip: void 0,
|
|
1872
1875
|
projection: void 0
|
|
1873
1876
|
}), r = n?.tenantId;
|
|
1874
1877
|
return typeof r == "string" ? r : null;
|
|
1875
|
-
},
|
|
1876
|
-
await e.upsert(
|
|
1877
|
-
id:
|
|
1878
|
+
}, sl = async (e, t, n) => {
|
|
1879
|
+
await e.upsert(il, {
|
|
1880
|
+
id: al(t),
|
|
1878
1881
|
subjectType: t.type,
|
|
1879
1882
|
subjectId: t.id,
|
|
1880
1883
|
tenantId: n,
|
|
1881
1884
|
selectedAt: /* @__PURE__ */ new Date()
|
|
1882
1885
|
}, { conflictColumns: ["id"] });
|
|
1883
|
-
},
|
|
1884
|
-
await e.delete(
|
|
1885
|
-
},
|
|
1886
|
-
let n =
|
|
1886
|
+
}, cl = async (e, t) => {
|
|
1887
|
+
await e.delete(il, al(t));
|
|
1888
|
+
}, ll = "id", ul = (e, t) => {
|
|
1889
|
+
let n = a(e);
|
|
1887
1890
|
if (n === void 0) return t;
|
|
1888
|
-
let r = n.fields[
|
|
1889
|
-
if (r === void 0 || t[
|
|
1891
|
+
let r = n.fields[ll]?.idScheme;
|
|
1892
|
+
if (r === void 0 || t[ll] != null) return t;
|
|
1890
1893
|
if (r.kind === "numeric") {
|
|
1891
|
-
if (!(
|
|
1894
|
+
if (!(ll in t)) return t;
|
|
1892
1895
|
let e = { ...t };
|
|
1893
|
-
return delete e[
|
|
1896
|
+
return delete e[ll], e;
|
|
1894
1897
|
}
|
|
1895
|
-
let i =
|
|
1898
|
+
let i = Rn(r, e);
|
|
1896
1899
|
return i === null ? t : {
|
|
1897
1900
|
...t,
|
|
1898
|
-
[
|
|
1901
|
+
[ll]: i
|
|
1899
1902
|
};
|
|
1900
|
-
},
|
|
1903
|
+
}, dl = (e, t) => t.map((t) => ul(e, t)), fl = {
|
|
1901
1904
|
postgres: { maxBindParameters: 65535 },
|
|
1902
1905
|
mysql: { maxBindParameters: 65535 },
|
|
1903
1906
|
mariadb: { maxBindParameters: 65535 },
|
|
@@ -1907,25 +1910,25 @@ $voltro_branch$`;
|
|
|
1907
1910
|
},
|
|
1908
1911
|
sqlite: { maxBindParameters: 32766 },
|
|
1909
1912
|
turso: { maxBindParameters: 32766 }
|
|
1910
|
-
},
|
|
1913
|
+
}, pl = (e) => fl[e], ml = (e) => {
|
|
1911
1914
|
let t = /* @__PURE__ */ new Set();
|
|
1912
1915
|
for (let n of e) for (let e of Object.keys(n)) t.add(e);
|
|
1913
1916
|
return t.size;
|
|
1914
|
-
},
|
|
1917
|
+
}, hl = (e, t) => {
|
|
1915
1918
|
if (t === void 0 || e.length === 0) return [e];
|
|
1916
|
-
let n = Math.max(1,
|
|
1919
|
+
let n = Math.max(1, ml(e)), r = Math.floor(t.maxBindParameters / n), i = t.maxRowsPerStatement ?? Infinity, a = Math.max(1, Math.min(r, i));
|
|
1917
1920
|
if (e.length <= a) return [e];
|
|
1918
1921
|
let o = [];
|
|
1919
1922
|
for (let t = 0; t < e.length; t += a) o.push(e.slice(t, t + a));
|
|
1920
1923
|
return o;
|
|
1921
|
-
},
|
|
1924
|
+
}, gl = (e, t) => {
|
|
1922
1925
|
let n = [], r = t;
|
|
1923
1926
|
for (let [t, i] of Object.entries(e.fields)) {
|
|
1924
1927
|
let e = i;
|
|
1925
1928
|
e.nullable || e.hasDefault || e.idScheme !== void 0 || e.generatedAs !== void 0 || (r[t] === void 0 || r[t] === null) && n.push(t);
|
|
1926
1929
|
}
|
|
1927
1930
|
return n;
|
|
1928
|
-
},
|
|
1931
|
+
}, _l = (e, t, n) => {
|
|
1929
1932
|
let r = n, i = new Set(e === void 0 ? [] : Object.entries(e.fields).filter(([, e]) => e.generatedAs !== void 0).map(([e]) => e)), a = [];
|
|
1930
1933
|
for (let e of t) i.has(e) || (r[e] === void 0 ? a.push({
|
|
1931
1934
|
column: e,
|
|
@@ -1935,36 +1938,36 @@ $voltro_branch$`;
|
|
|
1935
1938
|
reason: "null"
|
|
1936
1939
|
}));
|
|
1937
1940
|
return a;
|
|
1938
|
-
},
|
|
1941
|
+
}, vl = (e, t, n) => e.insert(t.tableName, n), yl = (e, t, n) => e.insertMany(t.tableName, n), bl = (e, t, n, r) => e.upsert(t.tableName, n, {
|
|
1939
1942
|
conflictColumns: r.conflictColumns,
|
|
1940
1943
|
...r.update === void 0 ? {} : { update: r.update },
|
|
1941
1944
|
...r.updateValues === void 0 ? {} : { updateValues: r.updateValues }
|
|
1942
|
-
}),
|
|
1943
|
-
if (e.upsertWithOutcome === void 0) throw
|
|
1945
|
+
}), xl = async (e, t, n, r) => {
|
|
1946
|
+
if (e.upsertWithOutcome === void 0) throw C("upsertRowOutcome: this store does not implement `upsertWithOutcome`. It is provided by the framework's store wrapper, so `ctx.store` has it; a hand-written DataStore must add it.");
|
|
1944
1947
|
return e.upsertWithOutcome(t.tableName, n, {
|
|
1945
1948
|
conflictColumns: r.conflictColumns,
|
|
1946
1949
|
...r.update === void 0 ? {} : { update: r.update },
|
|
1947
1950
|
...r.updateValues === void 0 ? {} : { updateValues: r.updateValues }
|
|
1948
1951
|
});
|
|
1949
|
-
},
|
|
1952
|
+
}, Sl = async (e, t, n, r) => e.insertIgnoreWithOutcome(t.tableName, n, { conflictColumns: r.conflictColumns }), Cl = (e, t, n, r) => e.updateMany(t.tableName, n, { where: r.where }), wl = 512, Tl = (e) => {
|
|
1950
1953
|
e.setMaxListeners(512);
|
|
1951
|
-
},
|
|
1954
|
+
}, El = (e, t, n) => ({
|
|
1952
1955
|
_tag: "PrimaryKeyConflictError",
|
|
1953
1956
|
table: e,
|
|
1954
1957
|
key: t,
|
|
1955
1958
|
cause: n
|
|
1956
|
-
}),
|
|
1959
|
+
}), Dl = (e) => typeof e == "object" && !!e && e._tag === "PrimaryKeyConflictError", Ol = {
|
|
1957
1960
|
postgres: 5432,
|
|
1958
1961
|
mysql: 3306,
|
|
1959
1962
|
mariadb: 3306,
|
|
1960
1963
|
mssql: 1433
|
|
1961
|
-
},
|
|
1964
|
+
}, kl = /* @__PURE__ */ new Set([
|
|
1962
1965
|
"localhost",
|
|
1963
1966
|
"127.0.0.1",
|
|
1964
1967
|
"::1",
|
|
1965
1968
|
"[::1]",
|
|
1966
1969
|
"0.0.0.0"
|
|
1967
|
-
]),
|
|
1970
|
+
]), Al = (e) => {
|
|
1968
1971
|
let t = e.host, n = e.port, r = e.database;
|
|
1969
1972
|
if (e.url !== void 0 && e.url !== "") try {
|
|
1970
1973
|
let i = new URL(e.url);
|
|
@@ -1973,29 +1976,29 @@ $voltro_branch$`;
|
|
|
1973
1976
|
return;
|
|
1974
1977
|
}
|
|
1975
1978
|
if (t === void 0 || t === "" || r === void 0 || r === "") return;
|
|
1976
|
-
let i = n ??
|
|
1979
|
+
let i = n ?? Ol[(e.dialect ?? "").toLowerCase()];
|
|
1977
1980
|
if (i === void 0 || !Number.isFinite(i)) return;
|
|
1978
1981
|
let a = t.toLowerCase();
|
|
1979
1982
|
return {
|
|
1980
|
-
host:
|
|
1983
|
+
host: kl.has(a) ? "localhost" : a,
|
|
1981
1984
|
port: i,
|
|
1982
1985
|
database: r.toLowerCase()
|
|
1983
1986
|
};
|
|
1984
|
-
},
|
|
1985
|
-
let t =
|
|
1986
|
-
if (t !== void 0) return
|
|
1987
|
-
},
|
|
1987
|
+
}, jl = (e) => {
|
|
1988
|
+
let t = Al(e);
|
|
1989
|
+
if (t !== void 0) return Ir("sha256").update(`${t.host}\u0000${t.port}\u0000${t.database}`).digest("hex").slice(0, 32);
|
|
1990
|
+
}, Ml = (e, t) => e === void 0 || t === void 0 ? "unknown" : e === t ? "same" : "different", Nl = {
|
|
1988
1991
|
app: 3,
|
|
1989
1992
|
plugin: 2,
|
|
1990
1993
|
framework: 1
|
|
1991
|
-
},
|
|
1994
|
+
}, Pl = /* @__PURE__ */ new Map(), Fl = [], Il = () => [...Fl], Ll = (e) => {
|
|
1992
1995
|
if (!e.table || !e.timeColumn) throw Error("registerRetention: table + timeColumn are required");
|
|
1993
1996
|
if (!Number.isFinite(e.ttlMs) || e.ttlMs <= 0) throw Error(`registerRetention(${e.table}): ttlMs must be a positive number`);
|
|
1994
|
-
let t = e.source ?? "app", n =
|
|
1997
|
+
let t = e.source ?? "app", n = Pl.get(e.table);
|
|
1995
1998
|
if (n !== void 0) {
|
|
1996
1999
|
let r = n.source ?? "app", i = n.ttlMs !== e.ttlMs || n.timeColumn !== e.timeColumn || JSON.stringify(n.activityColumns ?? []) !== JSON.stringify(e.activityColumns ?? []) || JSON.stringify(n.where) !== JSON.stringify(e.where);
|
|
1997
|
-
if (
|
|
1998
|
-
i &&
|
|
2000
|
+
if (Nl[t] < Nl[r]) {
|
|
2001
|
+
i && Fl.push({
|
|
1999
2002
|
table: e.table,
|
|
2000
2003
|
kept: {
|
|
2001
2004
|
source: r,
|
|
@@ -2008,7 +2011,7 @@ $voltro_branch$`;
|
|
|
2008
2011
|
});
|
|
2009
2012
|
return;
|
|
2010
2013
|
}
|
|
2011
|
-
i && r !== t &&
|
|
2014
|
+
i && r !== t && Fl.push({
|
|
2012
2015
|
table: e.table,
|
|
2013
2016
|
kept: {
|
|
2014
2017
|
source: t,
|
|
@@ -2020,59 +2023,59 @@ $voltro_branch$`;
|
|
|
2020
2023
|
}
|
|
2021
2024
|
});
|
|
2022
2025
|
}
|
|
2023
|
-
|
|
2026
|
+
Pl.set(e.table, {
|
|
2024
2027
|
...e,
|
|
2025
2028
|
source: t
|
|
2026
2029
|
});
|
|
2027
|
-
},
|
|
2028
|
-
|
|
2029
|
-
},
|
|
2030
|
-
let i = new Date(t - e.ttlMs), a = (e.activityColumns ?? []).map((e) =>
|
|
2030
|
+
}, Rl = () => [...Pl.values()], zl = () => {
|
|
2031
|
+
Pl.clear(), Fl.length = 0;
|
|
2032
|
+
}, Bl = async (e, t, n, r = 2e4) => {
|
|
2033
|
+
let i = new Date(t - e.ttlMs), a = (e.activityColumns ?? []).map((e) => _r(tr(e), Qt(e, i))), o = a.length === 0 ? e.where : gt(...e.where === void 0 ? [] : [e.where], ...a), s = 0;
|
|
2031
2034
|
try {
|
|
2032
2035
|
for (;;) {
|
|
2033
2036
|
let t = await n(e.table, e.timeColumn, i, r, o);
|
|
2034
2037
|
if (s += t, t < r) break;
|
|
2035
2038
|
}
|
|
2036
2039
|
} catch (t) {
|
|
2037
|
-
throw
|
|
2040
|
+
throw w.runSync(T.increment(T.tagged(Hl, "table", e.table))), t;
|
|
2038
2041
|
}
|
|
2039
|
-
return s > 0 &&
|
|
2040
|
-
},
|
|
2042
|
+
return s > 0 && w.runSync(T.incrementBy(T.tagged(Vl, "table", e.table), s)), s;
|
|
2043
|
+
}, Vl = T.counter("voltro_retention_swept_rows_total"), Hl = T.counter("voltro_retention_sweep_errors_total"), Ul = (e, t) => {
|
|
2041
2044
|
let n = Number(e ?? String(t));
|
|
2042
2045
|
return (Number.isFinite(n) && n > 0 ? n : t) * 36e5;
|
|
2043
|
-
},
|
|
2044
|
-
id:
|
|
2045
|
-
replicaId:
|
|
2046
|
-
streamName:
|
|
2047
|
-
binlogFile:
|
|
2048
|
-
binlogPosition:
|
|
2049
|
-
updatedAt:
|
|
2050
|
-
}).index(["replicaId"]),
|
|
2051
|
-
id:
|
|
2052
|
-
replicaId:
|
|
2053
|
-
streamName:
|
|
2054
|
-
ctVersion:
|
|
2055
|
-
updatedAt:
|
|
2056
|
-
}).index(["replicaId"]),
|
|
2057
|
-
id:
|
|
2058
|
-
startedAt:
|
|
2059
|
-
finishedAt:
|
|
2060
|
-
direction:
|
|
2061
|
-
mode:
|
|
2062
|
-
via:
|
|
2063
|
-
bundle:
|
|
2064
|
-
sourceFingerprint:
|
|
2065
|
-
tablesWritten:
|
|
2066
|
-
rowsWritten:
|
|
2067
|
-
failure:
|
|
2068
|
-
staged:
|
|
2069
|
-
}).renamedFrom("_voltro_data_imports").nonReactive(),
|
|
2046
|
+
}, Wl = "_voltro_cdc_offsets", Gl = x(Wl, {
|
|
2047
|
+
id: br({ prefix: "cdcoff" }),
|
|
2048
|
+
replicaId: b(),
|
|
2049
|
+
streamName: b(),
|
|
2050
|
+
binlogFile: b(),
|
|
2051
|
+
binlogPosition: b(),
|
|
2052
|
+
updatedAt: n()
|
|
2053
|
+
}).index(["replicaId"]), Kl = x(Wl, {
|
|
2054
|
+
id: br({ prefix: "cdcoff" }),
|
|
2055
|
+
replicaId: b(),
|
|
2056
|
+
streamName: b(),
|
|
2057
|
+
ctVersion: b(),
|
|
2058
|
+
updatedAt: n()
|
|
2059
|
+
}).index(["replicaId"]), ql = "_voltro_data_transfers", Jl = x(ql, {
|
|
2060
|
+
id: br({ prefix: "dimp" }),
|
|
2061
|
+
startedAt: n().default("now"),
|
|
2062
|
+
finishedAt: n().nullable(),
|
|
2063
|
+
direction: b().default("import"),
|
|
2064
|
+
mode: b(),
|
|
2065
|
+
via: b(),
|
|
2066
|
+
bundle: b().nullable(),
|
|
2067
|
+
sourceFingerprint: b().nullable(),
|
|
2068
|
+
tablesWritten: u().default(0),
|
|
2069
|
+
rowsWritten: u().default(0),
|
|
2070
|
+
failure: b().nullable(),
|
|
2071
|
+
staged: rt().nullable()
|
|
2072
|
+
}).renamedFrom("_voltro_data_imports").nonReactive(), Yl = (e) => {
|
|
2070
2073
|
let t = Number.isFinite(e.startedAt.getTime()) ? e.startedAt.toISOString() : "an unknown time", n = e.direction === "import" ? e.mode : `${e.direction} ${e.mode}`, r = e.failure === null ? e.finishedAt === null ? `${n} — started and never reported finishing` : e.direction === "backup" || e.direction === "restore" ? `${n} — finished${e.rowsWritten > 0 ? ` (${e.rowsWritten} blob(s))` : ""}` : `${n} — ${e.rowsWritten} row(s) across ${e.tablesWritten} table(s)` : `FAILED ${n} — ${e.failure}`, i = e.staged === null ? "" : e.staged ? " · staged (target untouched until the swap)" : " · NOT staged (target emptied first)";
|
|
2071
2074
|
return `${t} · ${r} · via ${e.via}${i}` + (e.bundle === null ? "" : ` · from ${e.bundle}`) + (e.sourceFingerprint === null ? "" : ` · source schema ${e.sourceFingerprint}`);
|
|
2072
|
-
},
|
|
2075
|
+
}, Xl = 255, Zl = (e) => e == null ? "null" : typeof e == "string" || typeof e == "number" || typeof e == "boolean" ? JSON.stringify(e) : Array.isArray(e) ? `[${e.map(Zl).join(",")}]` : typeof e == "object" ? `{${Object.entries(e).filter(([, e]) => e !== void 0).sort(([e], [t]) => e < t ? -1 : +(e > t)).map(([e, t]) => `${JSON.stringify(e)}:${Zl(t)}`).join(",")}}` : JSON.stringify(String(e)), Ql = (e) => {
|
|
2073
2076
|
if (e == null) return null;
|
|
2074
|
-
let t = typeof e == "string" ? e :
|
|
2077
|
+
let t = typeof e == "string" ? e : Zl(e);
|
|
2075
2078
|
return t.length > 255 ? t.slice(0, 255) : t;
|
|
2076
|
-
},
|
|
2079
|
+
}, $l = "postgres";
|
|
2077
2080
|
//#endregion
|
|
2078
|
-
export {
|
|
2081
|
+
export { yr as AUTO_FILLED_COLUMNS, qr as BOUND_ENCRYPTED_PREFIX, fl as BULK_INSERT_LIMITS, Y as BranchNameInvalid, gc as BranchTransitionInvalid, Wl as CDC_OFFSETS_TABLE, Ao as CHANGE_CLAIM_TTL_ENV, wl as CHANGE_LISTENER_CEILING, fr as ColumnBuilder, ql as DATA_TRANSFERS_TABLE, oe as DEFAULT_ACQUIRE_TIMEOUT_MS, jo as DEFAULT_CHANGE_CLAIM_TTL_HOURS, Os as DEFAULT_EAGER_FALLBACK_WARN_INTERVAL_MS, ur as DEFAULT_SOFT_DROP_RETENTION_DAYS, Li as DEFAULT_SUBJECT_GRAPH_DEPTH, Kr as ENCRYPTED_PREFIX, $l as ENGINE, na as EagerCardinalityError, un as FILE_MIGRATION_PATTERN, Ze as FRAMEWORK_LIVE_TABLES, Xr as FieldDecryptionError, Qo as ID_COLUMN_MAX_LENGTH, Er as INITIAL_VERSION, ke as IrreversibleMigrationError, yt as MATCHES_NO_ROWS, Ct as MAX_IDENTIFIER_LENGTH, Ne as MIGRATION_PHASES, Gs as MSSQL_TRANSIENT_NUMBERS, Us as MYSQL_TRANSIENT_CODES, Ve as MigrationExpectationFailed, ae as MigrationNeedsSqlClient, me as MigrationSkipped, ko as OccurrenceCounter, Ws as POSTGRES_TRANSIENT_STATES, Jn as REPLACE_IN_PROGRESS_TABLE, Te as RewriteUnstableError, Xl as SCOPE_KEY_MAX_LENGTH, $e as SELF_REFERENCE_TARGET, Ks as SQLITE_TRANSIENT_CODES, Tn as STAGING_STALE_MINUTES, f as STAGING_TABLE_PREFIX, zr as SqlClient, il as TENANT_SELECTIONS_TABLE, qs as TURSO_TRANSIENT_MESSAGE, ic as TableStreamError, s as TenantNamespaceInvalid, pn as TenantNamespaceUnresolved, Fc as TenantRegionUnavailable, Pc as TenantResidencyUnresolved, Ls as TransactionAbortedError, qe as TransactionBrokenByBodyError, Qs as VOLTRO_EXPIRES_MIXIN_ID, ec as VOLTRO_LOCAL_FIRST_MIXIN_ID, Cr as VersionConflict, Ke as WARN_IDENTIFIER_LENGTH, _n as _voltroApiKeysTable, Gl as _voltroCdcOffsetsTable, Jl as _voltroDataTransfersTable, Qn as _voltroDevicesTable, Vt as _voltroIdempotencyTable, Yt as _voltroKvTable, Nn as _voltroMigrationPlansTable, xn as _voltroMigrationsTable, Kl as _voltroMssqlCdcOffsetsTable, nn as _voltroPluginMigrationsTable, Bn as _voltroReplaceInProgressTable, $t as _voltroReplicaObservationsTable, Tt as _voltroSchemaOwnerTable, nr as _voltroSeedsTable, mr as _voltroTenantSelectionsTable, yo as actorsTable, kc as admitBranch, or as agedSoftDropSnapshots, an as allEnumRenames, Pi as allRegisteredRelations, _ as allRegisteredTables, gt as and, ea as applyJsonPatch, m as array, St as arrayContains, Ge as arrayHas, e as arrayOverlaps, ia as attachEagerLoads, Io as attributionFields, Bo as attributionKey, Yc as auditAllTableIndexes, Jc as auditTableIndexes, C as authoredError, jt as authoredMessageOf, Vn as avg, cn as avgOver, qo as beginLocalWrite, cr as bigint, Uc as bindResidentStore, rt as boolean, pc as branchNamespaceName, pl as bulkInsertLimitsFor, re as bytes, jn as causeBranches, Co as changeDelete, Eo as changeDigest, xo as changeInsert, wo as changeSoftDelete, So as changeUpdate, hl as chunkRowsForInsert, Uo as claimPendingAttribution, Kn as classifyConstraintViolation, en as clearEnumRenames, Xo as clearPendingAttribution, Ii as clearRelationsRegistry, zc as clearResidencyConfig, zl as clearRetentions, Re as clearTableRegistry, as as clearWriteRecorders, B as coercePredicateForSqlite, Be as coercePredicateValue, gn as coercePredicateValues, _e as coerceValueForSqlite, Jt as collectSubqueries, At as column, Oe as columnRef, di as columnSchema, ml as columnsPerRow, xr as compareDecimal, ma as compileEagerJson, ta as compileJsonPatch, h as compilePredicate, lr as compileRawFragment, it as compileRowProjection, ie as compileSelect, Do as composeChangeKey, lc as computeEmbedding, jl as connectionIdentity, Zn as contains, An as count, Gn as countDistinct, v as crdtCounter, ze as crdtDoc, hn as crdtManagedColumns, o as crdtManagedColumnsOf, fn as crdtSealed, je as crdtText, Fo as currentWriteAttribution, Rt as databaseHandle, Fe as date, Ue as dbEnum, Ss as dbMetricTagCacheSizeForTests, Ts as dbOperationsInFlight, se as decimal, Dt as declareEnumRename, ti as decodeFieldValue, pe as decodeRowsForTable, ct as decodeRowsFromSchema, si as decryptFieldsOnRead, nl as defineMigration, ot as defineMixin, at as defineSeed, cl as deleteTenantSelection, vn as denseRank, Wi as deriveSubjectGraph, Se as deriveTypeIdPrefix, ts as derivedRowId, ns as derivedRowIdLength, tt as describeAgedSoftDropSnapshots, zt as describeCharsetRefusal, yn as describeDriverError, er as describeRowBindings, Yl as describeTransferRun, Gr as deserializeArraysOnRead, t as drainIdentifierWarnings, ge as dropped, $r as encodeFieldValue, ht as encodeRowForSchema, oi as encryptFieldsForWrite, ii as encryptedColumnsOf, Jo as endLocalWrite, Ec as enforceBranchLimits, mn as ensureTableRegistered, On as eq, ee as escapeLike, Un as evaluatePredicate, $n as except, ln as exists, $s as expires, bo as externalChangeEvent, Ut as extractDbCause, Jr as fieldBinding, ft as fireSchemaChangeSeeds, ce as fireTenantCreateSeeds, el as formatIndexAuditIssue, Gi as formatSubjectGraph, Nt as frameworkTables, Rn as generateId, bt as generateSnowflake, De as geography, Ye as geometry, ir as getEnumRenames, Ni as getRelation, Mi as getRelations, Rc as getResidencyConfig, a as getTable, Mt as gt, Mn as gte, pa as hasEagerLoads, cc as hybridSearch, br as id, qn as inSet, Bt as inSubquery, k as inferForeignKey, Sl as insertIgnoreRowOutcome, yl as insertManyRows, vl as insertRow, u as integer, sn as interruptedReplaceRefusal, Ht as intersect, ut as interval, vr as irreversible, c as irreversibleReason, Yr as isBoundCiphertext, mc as isBranchNamespace, Xe as isColumnReference, Xi as isCompositeRowKey, yi as isEmptyRelationsSpec, Qr as isEncrypted, Zr as isFieldDecryptionError, lt as isFileMigration, Zt as isForeignKeyViolation, te as isFrameworkOwnedLiveTable, nc as isLocalFirst, rl as isMigrationDefinition, he as isMysqlFamily, bc as isNeonConnection, bn as isNotNull, tr as isNull, Dl as isPrimaryKeyConflictError, Fn as isQueryTimeout, ni as isRawEncoding, Vc as isRegionServable, bi as isRelationsSpec, xe as isSeedDefinition, g as isSoftDropSnapshotName, Ee as isSqliteFamily, Le as isStagingTableName, dn as isTableReactive, Bs as isTransactionAbortedError, Xs as isTransientContention, r as isView, fe as json, Wt as jsonField, l as jsonIndex, Zi as jsonPatchAssignments, Xt as lag, Pn as lead, Il as listRetentionConflicts, Rl as listRetentions, tc as localFirst, rc as localFirstTables, Qt as lt, In as lte, js as makeEagerFallbackReporter, Nc as makeNamespaceBranchExecutor, Rs as makeTransactionAbortTracker, Si as many, Ci as manyToMany, st as materializeFields, Sn as max, ue as migration, rn as min, _l as missingConflictColumns, gl as missingRequiredColumns, pt as mixin, wn as neq, _c as nextBranchState, Al as normaliseTarget, $i as normalizeJsonPatchValue, on as not, tn as notExists, Ot as notInSet, ar as notInSubquery, mt as numeric, Ds as observeDbOp, Mo as occurrenceWindowMs, xi as one, ra as oneCardinalityMessage, _r as or, S as orderClausesOf, Et as paginateBy, rr as paginateById, Oo as parseChangeKey, Zo as pendingAttributionCount, y as persistedColumns, wc as planBranch, vc as planBranchProvision, yc as planBranchTeardown, Tc as planBranchTeardownFor, Sc as planNeonBranchProvision, Cc as planNeonBranchTeardown, Sr as planVersionedUpdate, gr as pluginRef, Ft as pluginRefSpecOf, El as primaryKeyConflictError, Dc as provisionBranch, Wc as provisionResidentTenant, Me as qualifyTable, hr as queryFor, Kt as queryForView, Je as quoteIdent, Tl as raiseChangeListenerCeiling, Pt as rank, Ce as raw, ol as readTenantSelection, zn as readableByColumns, be as real, Es as recordDbOp, ls as recordsTable, xt as reference, li as refuseWrite, ho as registerCoreTables, ji as registerDiscoveredRelations, Ho as registerPendingAttribution, Ai as registerRelations, Ll as registerRetention, Ae as registerTable, rs as registerWriteRecorder, vi as relations, _o as requireActors, Pe as requireTable, vo as requireTenants, xs as resetDbMetricTagCacheForTests, _t as resetSnowflake, Hc as residentPlacement, Vr as resolveActorSnapshot, xc as resolveBranchMechanism, As as resolveEagerFallbackWarnIntervalMs, Yo as resolveEchoAttribution, dr as resolveFullTextIndex, ye as resolveIdScheme, le as resolveMixinGraph, Bc as resolveTenantHome, Ie as resolveTenantNamespace, Ul as retentionTtlMsFromEnv, Ji as rowKeyColumns, Yi as rowKeyIdentity, Qe as rowNumber, fi as rowSchema, Is as runRetryingTransaction, zs as runSavepoint, Hs as runStoreTransaction, Po as runWithWriteAttribution, us as runWriteRecorders, Ml as sameDatabase, We as sanitizeIdentifierFragment, Ql as scopeKeyOf, vt as selfReference, Wr as serializeArraysForWrite, wt as serverOnlyColumns, Lc as setResidencyConfig, Ln as setSchemaChangeSeedHook, ve as setTenantCreateSeedHook, Ms as settleTransactionExit, Tr as settleVersionedUpdate, i as softDropSnapshotStamp, It as spatialPredicate, kt as stagingLeftoverReport, kn as stagingLeftovers, Wn as stagingNamesOf, Lt as stagingStaleAfterMs, ul as stampGeneratedId, dl as stampGeneratedIds, pr as startsWith, ui as storeRefusalOf, sc as streamTable, p as sum, sr as sumOver, os as suspendWriteRecorders, ss as suspendWriteRecordersEffect, Bl as sweepRetention, x as table, Oc as teardownBranch, al as tenantSelectionId, b as text, n as timestamp, Or as timestampMs, wr as timestampMsOrNull, Fs as transactionRetrySchedule, nt as union, ne as unionAll, He as unregisterTable, is as unregisterWriteRecorder, Cl as updateManyRow, bl as upsertRow, xl as upsertRowOutcome, qi as upsertUpdatePatch, Ki as upsertUpdateValues, qt as validateColumnName, Xn as validateIndexName, Fi as validateRegisteredRelations, Di as validateRelationConfig, Dn as validateTableName, Hn as validateTypeIdPrefix, Gt as vector, de as vectorDistanceToOpclass, uc as vectorEmbedding, Dr as versionColumnOf, Yn as view, En as viewSql, et as walkLeaves, Cn as wireSafeCause, Lo as withCapturedAttribution, cs as writeRecordersSuspended, sl as writeTenantSelection };
|