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