@voltro/database 0.46.0 → 0.48.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
- import { $ as e, A as t, At as n, B as r, Bt as i, C as a, Ct as o, D as s, Dt as c, E as l, Et as u, F as d, Ft as f, G as p, Gt as m, H as h, Ht as g, I as ee, It as te, J as _, Jt as ne, K as re, Kt as v, L as ie, Lt as y, M as ae, Mt as oe, N as se, Nt as ce, O as le, Ot as ue, P as de, Pt as fe, Q as pe, R as me, Rt as b, S as he, St as ge, T as _e, Tt as ve, U as ye, Ut as be, V as xe, Vt as x, W as Se, Wt as Ce, X as we, Xt as S, Y as Te, Yt as C, Z as Ee, Zt as De, _ as Oe, _t as ke, a as Ae, at as je, b as Me, bt as Ne, c as Pe, ct as Fe, d as Ie, dt as Le, et as Re, f as ze, ft as Be, g as Ve, gt as He, h as Ue, ht as We, i as Ge, it as Ke, j as w, jt as qe, k as Je, kt as Ye, l as Xe, lt as Ze, m as Qe, mt as $e, n as et, nt as T, o as tt, ot as nt, p as E, pt as rt, q as it, qt as at, rt as ot, s as st, st as ct, t as lt, tt as ut, u as dt, ut as ft, v as pt, vt as mt, w as ht, wt as gt, x as _t, xt as vt, y as yt, yt as bt, z as xt, zt as D } from "./frameworkLiveTables-DNu6F6P8.js";
2
- import { timestampMs as St, timestampMsOrNull as Ct } from "./wire.js";
3
- import { Cause as O, Chunk as wt, Data as Tt, Effect as k, Exit as Et, Metric as A, MetricBoundaries as Dt, Option as j, Runtime as Ot, Schedule as kt, Schema as M, Stream as At } from "effect";
1
+ import { $ as e, A as t, At as n, B as r, Bt as i, C as a, Ct as o, D as s, Dt as c, E as l, Et as u, F as d, Ft as f, G as p, Gt as m, H as h, Ht as g, I as _, It as ee, J as v, Jt as te, K as ne, Kt as y, L as re, Lt as b, M as ie, Mt as ae, N as oe, Nt as se, O as ce, Ot as le, P as ue, Pt as de, Q as fe, R as pe, Rt as x, S as me, St as he, T as ge, Tt as _e, U as ve, Ut as ye, V as be, Vt as S, W as xe, Wt as Se, X as Ce, Xt as C, Y as we, Yt as w, Z as Te, Zt as Ee, _ as De, _t as Oe, a as ke, at as Ae, b as je, bt as Me, c as Ne, ct as Pe, d as Fe, dt as Ie, et as Le, f as Re, ft as ze, g as Be, gt as Ve, h as He, ht as Ue, i as We, it as Ge, j as T, jt as Ke, k as qe, kt as Je, l as Ye, lt as Xe, m as Ze, mt as Qe, n as $e, nt as E, o as et, ot as tt, p as D, pt as nt, q as rt, qt as it, rt as at, s as ot, st, t as ct, tt as lt, u as ut, ut as dt, v as ft, vt as pt, w as mt, wt as ht, x as gt, xt as _t, y as vt, yt, z as bt, zt as O } from "./frameworkLiveTables-DNu6F6P8.js";
2
+ import { timestampMs as xt, timestampMsOrNull as St } from "./wire.js";
3
+ import { Cause as Ct, Chunk as wt, Data as Tt, Effect as k, Exit as Et, Metric as A, MetricBoundaries as Dt, Option as j, Runtime as Ot, Schedule as kt, Schema as M, Stream as At } from "effect";
4
4
  import { AsyncLocalStorage as jt } from "node:async_hooks";
5
5
  import { createHash as Mt } from "node:crypto";
6
6
  import { TransactionConnection as Nt } from "@effect/sql/SqlClient";
@@ -141,12 +141,12 @@ var Ft = (e) => typeof e == "string" && e !== "" ? e : null, It = async (e, t, n
141
141
  });
142
142
  }, $t = (e) => {
143
143
  let t = e;
144
- for (let e = 0; e < 4 && Ot.isFiberFailure(t); e++) t = O.squash(t[Ot.FiberFailureCauseId]);
144
+ for (let e = 0; e < 4 && Ot.isFiberFailure(t); e++) t = Ct.squash(t[Ot.FiberFailureCauseId]);
145
145
  return t;
146
146
  }, en = (e, t = 0) => {
147
147
  if (t >= 4 || !Ot.isFiberFailure(e)) return [e];
148
- let n = e[Ot.FiberFailureCauseId], r = [...O.failures(n), ...O.defects(n)];
149
- if (r.length === 0) return [O.squash(n)];
148
+ let n = e[Ot.FiberFailureCauseId], r = [...Ct.failures(n), ...Ct.defects(n)];
149
+ if (r.length === 0) return [Ct.squash(n)];
150
150
  let i = [];
151
151
  for (let e of r.slice(0, 8)) i.push(...en(e, t + 1));
152
152
  return i;
@@ -323,7 +323,7 @@ var Ft = (e) => typeof e == "string" && e !== "" ? e : null, It = async (e, t, n
323
323
  case "decimal": return M.Number;
324
324
  case "boolean": return M.Boolean;
325
325
  case "timestamp":
326
- case "date": return St;
326
+ case "date": return xt;
327
327
  case "bigint": return M.BigInt;
328
328
  case "bytes": return M.Uint8ArrayFromBase64;
329
329
  case "array": return M.Array(M.Unknown);
@@ -805,15 +805,15 @@ var Ft = (e) => typeof e == "string" && e !== "" ? e : null, It = async (e, t, n
805
805
  return r.op === "exists" ? t`EXISTS (${i})` : t`NOT EXISTS (${i})`;
806
806
  }
807
807
  let i = e, a = t(i.column), o = i.path, s = o !== void 0 && o.length > 0, c = () => t.onDialectOrElse({
808
- mysql: () => t.unsafe(E(i.column, o, "mysql")),
809
- mssql: () => t.unsafe(E(i.column, o, "mssql")),
810
- sqlite: () => t.unsafe(E(i.column, o, "sqlite")),
811
- orElse: () => t.unsafe(E(i.column, o, "postgres"))
808
+ mysql: () => t.unsafe(D(i.column, o, "mysql")),
809
+ mssql: () => t.unsafe(D(i.column, o, "mssql")),
810
+ sqlite: () => t.unsafe(D(i.column, o, "sqlite")),
811
+ orElse: () => t.unsafe(D(i.column, o, "postgres"))
812
812
  }), l = () => t.onDialectOrElse({
813
- mysql: () => t.unsafe(E(i.column, o, "mysql", { numeric: !0 })),
814
- mssql: () => t.unsafe(E(i.column, o, "mssql", { numeric: !0 })),
815
- sqlite: () => t.unsafe(E(i.column, o, "sqlite", { numeric: !0 })),
816
- orElse: () => t.unsafe(E(i.column, o, "postgres", { numeric: !0 }))
813
+ mysql: () => t.unsafe(D(i.column, o, "mysql", { numeric: !0 })),
814
+ mssql: () => t.unsafe(D(i.column, o, "mssql", { numeric: !0 })),
815
+ sqlite: () => t.unsafe(D(i.column, o, "sqlite", { numeric: !0 })),
816
+ orElse: () => t.unsafe(D(i.column, o, "postgres", { numeric: !0 }))
817
817
  }), u = s ? c() : a, d = s ? l() : a, f = (e) => s && e != null ? String(e) : e, m = (e) => s ? Number(e) : e, h = s || r === void 0 ? void 0 : p(r)?.fields?.[i.column]?.type, g = (e) => Tr(h, e);
818
818
  switch (i.op) {
819
819
  case "eq": return t`${u} = ${f(g(i.value))}`;
@@ -955,7 +955,7 @@ var Ft = (e) => typeof e == "string" && e !== "" ? e : null, It = async (e, t, n
955
955
  }, zr = (e, t, n = null) => {
956
956
  if (e.setOp && e.setOp.queries.length >= 2) {
957
957
  let r = e.setOp.kind === "union" ? "UNION" : e.setOp.kind === "union-all" ? "UNION ALL" : e.setOp.kind === "intersect" ? "INTERSECT" : "EXCEPT", i = e.setOp.queries.map((e) => t`(${zr(e, t, n)})`).reduce((e, n, i) => i === 0 ? n : t`${e} ${t.unsafe(r)} ${n}`), a = [];
958
- if (w(e).length > 0 && a.push(t` ORDER BY ${t.csv(w(e).map((e) => e.direction === "desc" ? t`${t(e.column)} DESC` : t`${t(e.column)} ASC`))}`), e.take !== void 0) {
958
+ if (T(e).length > 0 && a.push(t` ORDER BY ${t.csv(T(e).map((e) => e.direction === "desc" ? t`${t(e.column)} DESC` : t`${t(e.column)} ASC`))}`), e.take !== void 0) {
959
959
  if (!Number.isInteger(e.take) || e.take < 0) throw Error(`compileSelect: invalid take ${e.take}`);
960
960
  a.push(t` LIMIT ${t.unsafe(String(e.take))}`);
961
961
  }
@@ -986,24 +986,24 @@ var Ft = (e) => typeof e == "string" && e !== "" ? e : null, It = async (e, t, n
986
986
  }) : e.distinct ? t`DISTINCT ` : t``, p = e.alias === void 0 ? t`${t(Sr(n, e.table))}` : t`${t(Sr(n, e.table))} AS ${t(e.alias)}`, m = (e.joins ?? []).map((e) => {
987
987
  let r = e.kind === "inner" ? "INNER" : "LEFT";
988
988
  return t` ${t.unsafe(r)} JOIN ${t(Sr(n, e.table))} AS ${t(e.alias)} ON ${L(e.on, t, n)}`;
989
- }), h = m.length > 0 ? m.reduce((e, n) => t`${e}${n}`, p) : p, g = c === void 0 ? null : Lr(c, e.table, t), ee = [e.predicate ? L(e.predicate, t, n, e.table) : null, g].filter((e) => e !== null), te = ee.length > 0 ? t` WHERE ${t.and(ee)}` : t``, _ = e.groupBy && e.groupBy.length > 0 ? t` GROUP BY ${t.csv(e.groupBy.map((e) => t`${t(e)}`))}` : t``, ne = e.having ? t` HAVING ${L(e.having, t, n, e.table)}` : t``, re = e.skip !== void 0, v = [];
990
- r !== null && v.push(t`${r} ASC`), e.spatialClause?.order !== void 0 && v.push(e.spatialClause.order === "desc" ? t`${Pr(e.spatialClause, t)} DESC` : t`${Pr(e.spatialClause, t)} ASC`), l !== null && c?.rank?.order === !0 && v.push(t`${l} DESC`);
991
- for (let n of w(e)) v.push(n.direction === "desc" ? t`${t(n.column)} DESC` : t`${t(n.column)} ASC`);
992
- let ie = v.length > 0 ? t` ORDER BY ${t.csv(v)}` : re ? t.onDialectOrElse({
989
+ }), h = m.length > 0 ? m.reduce((e, n) => t`${e}${n}`, p) : p, g = c === void 0 ? null : Lr(c, e.table, t), _ = [e.predicate ? L(e.predicate, t, n, e.table) : null, g].filter((e) => e !== null), ee = _.length > 0 ? t` WHERE ${t.and(_)}` : t``, v = e.groupBy && e.groupBy.length > 0 ? t` GROUP BY ${t.csv(e.groupBy.map((e) => t`${t(e)}`))}` : t``, te = e.having ? t` HAVING ${L(e.having, t, n, e.table)}` : t``, ne = e.skip !== void 0, y = [];
990
+ r !== null && y.push(t`${r} ASC`), e.spatialClause?.order !== void 0 && y.push(e.spatialClause.order === "desc" ? t`${Pr(e.spatialClause, t)} DESC` : t`${Pr(e.spatialClause, t)} ASC`), l !== null && c?.rank?.order === !0 && y.push(t`${l} DESC`);
991
+ for (let n of T(e)) y.push(n.direction === "desc" ? t`${t(n.column)} DESC` : t`${t(n.column)} ASC`);
992
+ let re = y.length > 0 ? t` ORDER BY ${t.csv(y)}` : ne ? t.onDialectOrElse({
993
993
  mssql: () => t` ORDER BY (SELECT NULL)`,
994
994
  orElse: () => t``
995
- }) : t``, y = (e) => {
995
+ }) : t``, b = (e) => {
996
996
  if (!Number.isFinite(e) || !Number.isInteger(e) || e < 0) throw Error(`compileSelect: expected non-negative integer take/skip, got ${e}`);
997
997
  return t.unsafe(String(e));
998
- }, ae = (e.ctes ?? []).map((e) => t`${t(e.name)} AS (${zr(e.descriptor, t, n)})`), oe = (e.ctes ?? []).some((e) => e.recursive === !0), se = ae.length > 0 ? t`WITH ${t.unsafe(oe ? "RECURSIVE " : "")}${t.csv(ae)} ` : t``;
998
+ }, ie = (e.ctes ?? []).map((e) => t`${t(e.name)} AS (${zr(e.descriptor, t, n)})`), ae = (e.ctes ?? []).some((e) => e.recursive === !0), oe = ie.length > 0 ? t`WITH ${t.unsafe(ae ? "RECURSIVE " : "")}${t.csv(ie)} ` : t``;
999
999
  return t.onDialectOrElse({
1000
1000
  mssql: () => {
1001
- let n = e.take !== void 0 && !re ? t`TOP ${y(e.take)} ` : t``, r = re ? t` OFFSET ${y(e.skip)} ROWS FETCH NEXT ${y(e.take ?? 2 ** 53 - 1)} ROWS ONLY` : t``;
1002
- return t`${se}SELECT ${n}${f}${d} FROM ${h}${te}${_}${ne}${ie}${r}`;
1001
+ let n = e.take !== void 0 && !ne ? t`TOP ${b(e.take)} ` : t``, r = ne ? t` OFFSET ${b(e.skip)} ROWS FETCH NEXT ${b(e.take ?? 2 ** 53 - 1)} ROWS ONLY` : t``;
1002
+ return t`${oe}SELECT ${n}${f}${d} FROM ${h}${ee}${v}${te}${re}${r}`;
1003
1003
  },
1004
1004
  orElse: () => {
1005
- let n = e.take === void 0 ? t`` : t` LIMIT ${y(e.take)}`, r = re ? t` OFFSET ${y(e.skip)}` : t``;
1006
- return t`${se}SELECT ${f}${d} FROM ${h}${te}${_}${ne}${ie}${n}${r}`;
1005
+ let n = e.take === void 0 ? t`` : t` LIMIT ${b(e.take)}`, r = ne ? t` OFFSET ${b(e.skip)}` : t``;
1006
+ return t`${oe}SELECT ${f}${d} FROM ${h}${ee}${v}${te}${re}${n}${r}`;
1007
1007
  }
1008
1008
  });
1009
1009
  }, Br = (e, t, n) => {
@@ -1022,7 +1022,7 @@ var Ft = (e) => typeof e == "string" && e !== "" ? e : null, It = async (e, t, n
1022
1022
  limit: 2
1023
1023
  }
1024
1024
  }), Ur = (e, t, n) => {
1025
- let r = n ?? _(e), i = Fn(e);
1025
+ let r = n ?? v(e), i = Fn(e);
1026
1026
  if (i === void 0) return null;
1027
1027
  let a = [];
1028
1028
  for (let [e, n] of Object.entries(t)) {
@@ -1175,7 +1175,7 @@ var Ft = (e) => typeof e == "string" && e !== "" ? e : null, It = async (e, t, n
1175
1175
  };
1176
1176
  }, ni = (e, t, n) => {
1177
1177
  let r = n.sql, i = n.nextAlias(), a = r(t.table.tableName), o = r(i), s = ri(i, t.children, n);
1178
- return s === null ? null : r`SELECT ${s} AS "__row" FROM ${a} AS ${o}${e.predicate ? r` WHERE ${U(e.predicate, i, r)}` : r``}${w(e).length > 0 ? r` ORDER BY ${r.csv(w(e).map((e) => e.direction === "desc" ? r`${B(i, e.column, r)} DESC` : r`${B(i, e.column, r)} ASC`))}` : r``}${e.take === void 0 ? r`` : r` LIMIT ${H(e.take, r)}`}${e.skip === void 0 ? r`` : r` OFFSET ${H(e.skip, r)}`}`;
1178
+ return s === null ? null : r`SELECT ${s} AS "__row" FROM ${a} AS ${o}${e.predicate ? r` WHERE ${U(e.predicate, i, r)}` : r``}${T(e).length > 0 ? r` ORDER BY ${r.csv(T(e).map((e) => e.direction === "desc" ? r`${B(i, e.column, r)} DESC` : r`${B(i, e.column, r)} ASC`))}` : r``}${e.take === void 0 ? r`` : r` LIMIT ${H(e.take, r)}`}${e.skip === void 0 ? r`` : r` OFFSET ${H(e.skip, r)}`}`;
1179
1179
  }, ri = (e, t, n, r) => {
1180
1180
  let i = n.sql, a = r === void 0 ? i`to_jsonb(${i(e)}.*)` : i`(to_jsonb(${i(e)}.*) - ${V(qr, i)}::text)`;
1181
1181
  if (t.length === 0 && r === void 0) return a;
@@ -1211,7 +1211,7 @@ var Ft = (e) => typeof e == "string" && e !== "" ? e : null, It = async (e, t, n
1211
1211
  }, ci = (e, t, n) => e.present.length === 0 ? n`jsonb_build_object()` : n`jsonb_build_object(${n.csv(e.present.map((e) => n`${V(e, n)}, ${B(t, e, n)}`))})`, R = (e, t, n) => t === void 0 || t.length === 0 ? n`` : n` ORDER BY ${n.csv(t.map((t) => t.direction === "desc" ? n`${B(e, t.column, n)} DESC` : n`${B(e, t.column, n)} ASC`))}`, li = (e, t) => e === void 0 || e.length === 0 ? t`` : t` ORDER BY ${t.csv(e.map((e) => e.direction === "desc" ? t`${t(e.column)} DESC` : t`${t(e.column)} ASC`))}`, ui = (e, t, n) => {
1212
1212
  let r = n.sql, i = n.nextAlias(), a = di(i, t.table, t.children, n);
1213
1213
  if (a === null) return null;
1214
- let o = e.predicate ? r` WHERE ${U(e.predicate, i, r)}` : r``, s = w(e).length > 0 ? r` ORDER BY ${r.csv(w(e).map((e) => e.direction === "desc" ? r`${B(i, e.column, r)} DESC` : r`${B(i, e.column, r)} ASC`))}` : r``, c = e.take === void 0 ? r`` : r` LIMIT ${H(e.take, r)}`, l = e.skip === void 0 ? r`` : r` OFFSET ${H(e.skip, r)}`;
1214
+ let o = e.predicate ? r` WHERE ${U(e.predicate, i, r)}` : r``, s = T(e).length > 0 ? r` ORDER BY ${r.csv(T(e).map((e) => e.direction === "desc" ? r`${B(i, e.column, r)} DESC` : r`${B(i, e.column, r)} ASC`))}` : r``, c = e.take === void 0 ? r`` : r` LIMIT ${H(e.take, r)}`, l = e.skip === void 0 ? r`` : r` OFFSET ${H(e.skip, r)}`;
1215
1215
  return r`SELECT ${a} AS "__row" FROM ${r(t.table.tableName)} AS ${r(i)}${o}${s}${c}${l}`;
1216
1216
  }, di = (e, t, n, r, i) => {
1217
1217
  let a = r.sql, o = [];
@@ -1259,7 +1259,7 @@ var Ft = (e) => typeof e == "string" && e !== "" ? e : null, It = async (e, t, n
1259
1259
  }, bi = (e, t, n) => {
1260
1260
  let r = n.sql, i = n.nextAlias(), a = z(i, t.table, t.children, n);
1261
1261
  if (a === null) return null;
1262
- let o = e.predicate ? r` WHERE ${U(e.predicate, i, r)}` : r``, s = w(e).length > 0 ? r` ORDER BY ${r.csv(w(e).map((e) => e.direction === "desc" ? r`${B(i, e.column, r)} DESC` : r`${B(i, e.column, r)} ASC`))}` : r``, c = e.take === void 0 ? r`` : r` LIMIT ${H(e.take, r)}`, l = e.skip === void 0 ? r`` : r` OFFSET ${H(e.skip, r)}`;
1262
+ let o = e.predicate ? r` WHERE ${U(e.predicate, i, r)}` : r``, s = T(e).length > 0 ? r` ORDER BY ${r.csv(T(e).map((e) => e.direction === "desc" ? r`${B(i, e.column, r)} DESC` : r`${B(i, e.column, r)} ASC`))}` : r``, c = e.take === void 0 ? r`` : r` LIMIT ${H(e.take, r)}`, l = e.skip === void 0 ? r`` : r` OFFSET ${H(e.skip, r)}`;
1263
1263
  return r`SELECT ${a} AS \`__row\` FROM ${r(t.table.tableName)} AS ${r(i)}${o}${s}${c}${l}`;
1264
1264
  }, z = (e, t, n, r, i) => {
1265
1265
  let a = r.sql, o = [];
@@ -1319,16 +1319,16 @@ var Ft = (e) => typeof e == "string" && e !== "" ? e : null, It = async (e, t, n
1319
1319
  let t = z(o, e.target, e.children, n, c(hi(s)));
1320
1320
  return t === null ? null : r`COALESCE((SELECT JSON_ARRAYAGG(${t}${p.length > 0 ? r` ORDER BY ${r.csv(p.map((e) => e.direction === "desc" ? r`${B(o, e.column, r)} DESC` : r`${B(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())`;
1321
1321
  }
1322
- let m = p.length > 0 ? r` ORDER BY ${r.csv(p.map((e) => e.direction === "desc" ? r`${B(o, e.column, r)} DESC` : r`${B(o, e.column, r)} ASC`))}` : r` ORDER BY ${B(o, "id", r)}`, h = e.branch.limit, g = e.branch.offset, ee = h !== void 0 && g !== void 0 ? r` AND ${B(o, "rn", r)} > ${H(g, r)} AND ${B(o, "rn", r)} <= ${H(g + h, r)}` : h === void 0 ? r` AND ${B(o, "rn", r)} > ${H(g, r)}` : r` AND ${B(o, "rn", r)} <= ${H(h, r)}`, te = e.branch.onJunction === void 0 ? r`` : r` WHERE ${U(W(e.branch.onJunction), s, r)}`, _ = z(o, e.target, e.children, n, c(mi(o)));
1323
- if (_ === null) return null;
1324
- let ne = e.junction === void 0 ? r`` : pi(e.junction, s, r);
1325
- return r`COALESCE((SELECT JSON_ARRAYAGG(${_} ORDER BY ${B(o, "rn", r)}) FROM (SELECT ${r(o)}.*${ne}, ${B(s, i.sourceKey, r)} AS ${r(`__src_${i.sourceKey}`)}, ROW_NUMBER() OVER (PARTITION BY ${B(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}${te}) AS ${r(o)} WHERE ${B(o, `__src_${i.sourceKey}`, r)} = ${B(t, "id", r)}${d}${ee}), JSON_ARRAY())`;
1322
+ let m = p.length > 0 ? r` ORDER BY ${r.csv(p.map((e) => e.direction === "desc" ? r`${B(o, e.column, r)} DESC` : r`${B(o, e.column, r)} ASC`))}` : r` ORDER BY ${B(o, "id", r)}`, h = e.branch.limit, g = e.branch.offset, _ = h !== void 0 && g !== void 0 ? r` AND ${B(o, "rn", r)} > ${H(g, r)} AND ${B(o, "rn", r)} <= ${H(g + h, r)}` : h === void 0 ? r` AND ${B(o, "rn", r)} > ${H(g, r)}` : r` AND ${B(o, "rn", r)} <= ${H(h, r)}`, ee = e.branch.onJunction === void 0 ? r`` : r` WHERE ${U(W(e.branch.onJunction), s, r)}`, v = z(o, e.target, e.children, n, c(mi(o)));
1323
+ if (v === null) return null;
1324
+ let te = e.junction === void 0 ? r`` : pi(e.junction, s, r);
1325
+ return r`COALESCE((SELECT JSON_ARRAYAGG(${v} ORDER BY ${B(o, "rn", r)}) FROM (SELECT ${r(o)}.*${te}, ${B(s, i.sourceKey, r)} AS ${r(`__src_${i.sourceKey}`)}, ROW_NUMBER() OVER (PARTITION BY ${B(s, i.sourceKey, r)}${m}) AS rn FROM ${r(a.tableName)} AS ${r(s)} INNER JOIN ${r(e.target.tableName)} AS ${r(o)} ON ${u}${ee}) AS ${r(o)} WHERE ${B(o, `__src_${i.sourceKey}`, r)} = ${B(t, "id", r)}${d}${_}), JSON_ARRAY())`;
1326
1326
  }, Di = (e, t, n) => {
1327
1327
  let r = n.sql, i = n.nextAlias(), a = Oi(i, t.table, t.children, n);
1328
1328
  if (a === null) return null;
1329
- let o = e.predicate ? r` WHERE ${U(e.predicate, i, r)}` : r``, s = w(e).length > 0 ? r` ORDER BY ${r.csv(w(e).map((e) => e.direction === "desc" ? r`${B(i, e.column, r)} DESC` : r`${B(i, e.column, r)} ASC`))}` : r``, c = r``, l = r``;
1329
+ let o = e.predicate ? r` WHERE ${U(e.predicate, i, r)}` : r``, s = T(e).length > 0 ? r` ORDER BY ${r.csv(T(e).map((e) => e.direction === "desc" ? r`${B(i, e.column, r)} DESC` : r`${B(i, e.column, r)} ASC`))}` : r``, c = r``, l = r``;
1330
1330
  if (e.skip !== void 0) {
1331
- let t = w(e).length > 0 ? s : r` ORDER BY (SELECT NULL)`;
1331
+ let t = T(e).length > 0 ? s : r` ORDER BY (SELECT NULL)`;
1332
1332
  l = e.take === void 0 ? r`${t} OFFSET ${H(e.skip, r)} ROWS` : r`${t} OFFSET ${H(e.skip, r)} ROWS FETCH NEXT ${H(e.take, r)} ROWS ONLY`;
1333
1333
  } else e.take !== void 0 && (c = r`TOP ${H(e.take, r)} `);
1334
1334
  let u = e.skip === void 0 ? s : r``;
@@ -1420,16 +1420,16 @@ var Ft = (e) => typeof e == "string" && e !== "" ? e : null, It = async (e, t, n
1420
1420
  let n = e();
1421
1421
  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`);
1422
1422
  return n();
1423
- }, Ui = () => Hi(() => Bi.actors, "actors"), Wi = () => Hi(() => Bi.tenants, "tenants"), Gi = T("actors", {
1424
- id: b(),
1425
- kind: C().oneOf([
1423
+ }, Ui = () => Hi(() => Bi.actors, "actors"), Wi = () => Hi(() => Bi.tenants, "tenants"), Gi = E("actors", {
1424
+ id: x(),
1425
+ kind: w().oneOf([
1426
1426
  "user",
1427
1427
  "serviceAccount",
1428
1428
  "apiKey",
1429
1429
  "system"
1430
1430
  ]),
1431
- displayName: C().nullable(),
1432
- createdAt: S().default("now")
1431
+ displayName: w().nullable(),
1432
+ createdAt: C().default("now")
1433
1433
  }), Ki = (e, t) => ({
1434
1434
  column: e,
1435
1435
  op: "eq",
@@ -1741,11 +1741,20 @@ var Ft = (e) => typeof e == "string" && e !== "" ? e : null, It = async (e, t, n
1741
1741
  });
1742
1742
  }, to = (e) => {
1743
1743
  J.delete(e);
1744
- }, no = () => J.clear(), ro = (e) => {
1745
- if (J.size === 0) return !1;
1744
+ }, no = () => J.clear(), ro = new jt(), io = (e) => ro.run({ n: 1 }, e), ao = (e) => k.suspend(() => {
1745
+ let t = ro.getStore();
1746
+ if (t !== void 0) return t.n += 1, k.ensuring(e, k.sync(() => {
1747
+ --t.n;
1748
+ }));
1749
+ let n = { n: 1 };
1750
+ return ro.enterWith(n), k.ensuring(e, k.sync(() => {
1751
+ --n.n;
1752
+ }));
1753
+ }), oo = () => (ro.getStore()?.n ?? 0) > 0, so = (e) => {
1754
+ if (J.size === 0 || (ro.getStore()?.n ?? 0) > 0) return !1;
1746
1755
  for (let t of J.values()) if (!t.ownTables.has(e) && t.tables.has(e)) return !0;
1747
1756
  return !1;
1748
- }, io = async (e, t) => {
1757
+ }, co = async (e, t) => {
1749
1758
  if (J.size !== 0) {
1750
1759
  for (let [n, r] of J.entries()) if (!r.ownTables.has(t.table) && r.tables.has(t.table)) try {
1751
1760
  await r.recorder(e, t);
@@ -1754,54 +1763,54 @@ var Ft = (e) => typeof e == "string" && e !== "" ? e : null, It = async (e, t, n
1754
1763
  throw r === void 0 ? e : Error(`write recorder '${n}' failed while recording a ${t.op} on '${t.table}': ${r}`, { cause: e });
1755
1764
  }
1756
1765
  }
1757
- }, ao = Dt.exponential({
1766
+ }, lo = Dt.exponential({
1758
1767
  start: 5e-4,
1759
1768
  factor: 2,
1760
1769
  count: 16
1761
- }), oo = A.counter("voltro_db_queries_total", { description: "Database operations executed, by dialect and operation kind." }), so = A.histogram("voltro_db_query_duration_seconds", ao, "Database operation duration in seconds, by dialect and operation kind."), co = A.counter("voltro_db_errors_total", { description: "Database operations that threw, by dialect and operation kind." }), lo = A.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." }), uo = A.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." }), fo = [], po = /* @__PURE__ */ new Map(), mo = /* @__PURE__ */ new Map(), ho = /* @__PURE__ */ new Map(), go = (e, t) => {
1762
- let n = `${e}\u0000${t}`, r = po.get(n);
1770
+ }), uo = A.counter("voltro_db_queries_total", { description: "Database operations executed, by dialect and operation kind." }), fo = A.histogram("voltro_db_query_duration_seconds", lo, "Database operation duration in seconds, by dialect and operation kind."), po = A.counter("voltro_db_errors_total", { description: "Database operations that threw, by dialect and operation kind." }), mo = A.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." }), ho = A.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." }), go = [], _o = /* @__PURE__ */ new Map(), vo = /* @__PURE__ */ new Map(), yo = /* @__PURE__ */ new Map(), bo = (e, t) => {
1771
+ let n = `${e}\u0000${t}`, r = _o.get(n);
1763
1772
  if (r !== void 0) return r;
1764
1773
  let i = (n) => A.tagged(A.tagged(n, "dialect", e), "op", t), a = {
1765
- count: i(oo),
1766
- duration: i(so),
1767
- errors: i(co)
1774
+ count: i(uo),
1775
+ duration: i(fo),
1776
+ errors: i(po)
1768
1777
  };
1769
- return po.set(n, a), a;
1770
- }, _o = () => {
1771
- po.clear(), mo.clear(), ho.clear();
1772
- }, vo = () => po.size + mo.size + ho.size, yo = /* @__PURE__ */ new Map(), bo = (e, t) => {
1773
- let n = Math.max(0, (yo.get(e) ?? 0) + t);
1774
- n === 0 ? yo.delete(e) : yo.set(e, n);
1775
- let r = mo.get(e);
1776
- r === void 0 && (r = A.tagged(lo, "dialect", e), mo.set(e, r)), r.unsafeUpdate(n, fo);
1777
- }, xo = (e) => yo.get(e) ?? 0, So = (e) => {
1778
- let t = go(String(e.dialect), e.op);
1779
- t.count.unsafeUpdate(1, fo), t.duration.unsafeUpdate(e.durationMs / 1e3, fo), e.status === "error" && t.errors.unsafeUpdate(1, fo);
1780
- }, Co = async (e, t, n) => {
1778
+ return _o.set(n, a), a;
1779
+ }, xo = () => {
1780
+ _o.clear(), vo.clear(), yo.clear();
1781
+ }, So = () => _o.size + vo.size + yo.size, Co = /* @__PURE__ */ new Map(), wo = (e, t) => {
1782
+ let n = Math.max(0, (Co.get(e) ?? 0) + t);
1783
+ n === 0 ? Co.delete(e) : Co.set(e, n);
1784
+ let r = vo.get(e);
1785
+ r === void 0 && (r = A.tagged(mo, "dialect", e), vo.set(e, r)), r.unsafeUpdate(n, go);
1786
+ }, To = (e) => Co.get(e) ?? 0, Eo = (e) => {
1787
+ let t = bo(String(e.dialect), e.op);
1788
+ t.count.unsafeUpdate(1, go), t.duration.unsafeUpdate(e.durationMs / 1e3, go), e.status === "error" && t.errors.unsafeUpdate(1, go);
1789
+ }, Do = async (e, t, n) => {
1781
1790
  let r = performance.now(), i = String(e);
1782
- bo(i, 1);
1791
+ wo(i, 1);
1783
1792
  let a = "ok";
1784
1793
  try {
1785
1794
  return await n();
1786
1795
  } catch (e) {
1787
1796
  throw a = "error", e;
1788
1797
  } finally {
1789
- bo(i, -1), So({
1798
+ wo(i, -1), Eo({
1790
1799
  dialect: e,
1791
1800
  op: t,
1792
1801
  durationMs: performance.now() - r,
1793
1802
  status: a
1794
1803
  });
1795
1804
  }
1796
- }, wo = 3e5, To = (e) => {
1805
+ }, Oo = 3e5, ko = (e) => {
1797
1806
  if (e == null || e === "") return;
1798
1807
  let t = Number(e);
1799
1808
  return Number.isFinite(t) && t >= 0 ? Math.floor(t) : void 0;
1800
- }, Eo = (e, t = process.env) => To(t.VOLTRO_DB_EAGER_FALLBACK_WARN_INTERVAL_MS) ?? To(e) ?? 3e5, Do = (e, t = {}) => {
1801
- let n = Eo(t.warnIntervalMs), r = t.now ?? (() => Date.now()), i = /* @__PURE__ */ new Map();
1809
+ }, Ao = (e, t = process.env) => ko(t.VOLTRO_DB_EAGER_FALLBACK_WARN_INTERVAL_MS) ?? ko(e) ?? 3e5, jo = (e, t = {}) => {
1810
+ let n = Ao(t.warnIntervalMs), r = t.now ?? (() => Date.now()), i = /* @__PURE__ */ new Map();
1802
1811
  return (t) => {
1803
- let a = `${t.dialect} ${t.reason}`, o = ho.get(a);
1804
- o === void 0 && (o = A.tagged(A.tagged(uo, "dialect", String(t.dialect)), "reason", t.reason), ho.set(a, o)), o.unsafeUpdate(1, fo);
1812
+ let a = `${t.dialect} ${t.reason}`, o = yo.get(a);
1813
+ o === void 0 && (o = A.tagged(A.tagged(ho, "dialect", String(t.dialect)), "reason", t.reason), yo.set(a, o)), o.unsafeUpdate(1, go);
1805
1814
  let s = `${t.table}\u0000${t.reason}`, c = i.get(s), l = c === void 0 || n > 0 && r() - c >= n, u = {
1806
1815
  table: t.table,
1807
1816
  dialect: String(t.dialect),
@@ -1815,10 +1824,10 @@ var Ft = (e) => typeof e == "string" && e !== "" ? e : null, It = async (e, t, n
1815
1824
  }
1816
1825
  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);
1817
1826
  };
1818
- }, Oo = (e) => {
1827
+ }, Mo = (e) => {
1819
1828
  if (Et.isSuccess(e)) return e.value;
1820
- throw O.squash(e.cause);
1821
- }, ko = "10 millis", Ao = 3, jo = async (e) => {
1829
+ throw Ct.squash(e.cause);
1830
+ }, No = "10 millis", Po = 3, Fo = async (e) => {
1822
1831
  let t = 0, n = k.suspend(() => {
1823
1832
  let n = ++t;
1824
1833
  return e.withTransaction(k.flatMap(k.serviceOption(Nt), (t) => {
@@ -1829,10 +1838,10 @@ var Ft = (e) => typeof e == "string" && e !== "" ? e : null, It = async (e, t, n
1829
1838
  });
1830
1839
  return e.prepare === void 0 ? i : k.flatMap(e.prepare(r), () => i);
1831
1840
  })).pipe(k.catchAllDefect((t) => e.isRetryable(t) ? k.fail(t) : k.die(t)));
1832
- }), r = kt.exponential(ko).pipe(kt.compose(kt.recurs(Ao)), kt.whileInput(e.isRetryable)), i = n.pipe(k.retry(r), k.withSpan(e.span.name, { attributes: { ...e.span.attributes } }));
1833
- return Co(e.dialect, "transaction", async () => Oo(await e.runPromiseExit(e.wrapProgram === void 0 ? i : e.wrapProgram(i))));
1834
- }, Mo = async (e) => {
1835
- let t = Aa(), n = t === void 0 ? (e) => e() : (e) => ka(t, e), r = await jo({
1841
+ }), r = kt.exponential(No).pipe(kt.compose(kt.recurs(Po)), kt.whileInput(e.isRetryable)), i = n.pipe(k.retry(r), k.withSpan(e.span.name, { attributes: { ...e.span.attributes } }));
1842
+ return Do(e.dialect, "transaction", async () => Mo(await e.runPromiseExit(e.wrapProgram === void 0 ? i : e.wrapProgram(i))));
1843
+ }, Io = async (e) => {
1844
+ let t = Aa(), n = t === void 0 ? (e) => e() : (e) => ka(t, e), r = await Fo({
1836
1845
  ...e,
1837
1846
  body: (r) => {
1838
1847
  let i = e.makeView(r, t);
@@ -1843,14 +1852,14 @@ var Ft = (e) => typeof e == "string" && e !== "" ? e : null, It = async (e, t, n
1843
1852
  }
1844
1853
  });
1845
1854
  return r.view.commitEvents(), r.result;
1846
- }, No = class extends M.TaggedError()("VersionConflict", {
1855
+ }, Lo = class extends M.TaggedError()("VersionConflict", {
1847
1856
  table: M.String,
1848
1857
  id: M.String,
1849
1858
  expected: M.Number,
1850
1859
  actual: M.NullOr(M.Number)
1851
- }) {}, Po = (e) => {
1860
+ }) {}, Ro = (e) => {
1852
1861
  for (let [t, n] of Object.entries(e)) if (n?.definition?.versionColumn === !0) return t;
1853
- }, Fo = (e) => {
1862
+ }, zo = (e) => {
1854
1863
  let { versionColumn: t, patch: n } = e;
1855
1864
  if (t === void 0) return {
1856
1865
  nextVersion: void 0,
@@ -1863,25 +1872,25 @@ var Ft = (e) => typeof e == "string" && e !== "" ? e : null, It = async (e, t, n
1863
1872
  expected: i,
1864
1873
  patch: a
1865
1874
  };
1866
- }, Io = (e) => {
1867
- if (e.expected !== void 0 && (e.current === null || e.current !== e.expected)) return new No({
1875
+ }, Bo = (e) => {
1876
+ if (e.expected !== void 0 && (e.current === null || e.current !== e.expected)) return new Lo({
1868
1877
  table: e.table,
1869
1878
  id: e.id,
1870
1879
  expected: e.expected,
1871
1880
  actual: e.current
1872
1881
  });
1873
- }, Lo = 1, Ro = "voltro/expires", zo = () => Ke({
1874
- id: Ro,
1875
- fields: { expiresAt: S().nullable() },
1882
+ }, Vo = 1, Ho = "voltro/expires", Uo = () => Ge({
1883
+ id: Ho,
1884
+ fields: { expiresAt: C().nullable() },
1876
1885
  behaviors: { defaultWhere: () => "expiresAt IS NULL OR expiresAt > now()" }
1877
- }), Bo = "voltro/localFirst", Vo = () => Ke({
1878
- id: Bo,
1886
+ }), Wo = "voltro/localFirst", Go = () => Ge({
1887
+ id: Wo,
1879
1888
  fields: {}
1880
- }), Ho = (e) => e.appliedMixins.some((e) => e.id === Bo), Uo = (e) => {
1889
+ }), Ko = (e) => e.appliedMixins.some((e) => e.id === Wo), qo = (e) => {
1881
1890
  let t = [];
1882
- for (let n of Object.values(e)) Ho(n) && t.push(n.tableName);
1891
+ for (let n of Object.values(e)) Ko(n) && t.push(n.tableName);
1883
1892
  return t;
1884
- }, Wo = class extends Tt.TaggedError("TableStreamError") {}, Go = 1e3, Ko = (e, t, n, r) => {
1893
+ }, Jo = class extends Tt.TaggedError("TableStreamError") {}, Yo = 1e3, Xo = (e, t, n, r) => {
1885
1894
  let i = j.match(r, {
1886
1895
  onNone: () => e.where,
1887
1896
  onSome: (n) => e.where ? la(e.where, Ji(t, n)) : Ji(t, n)
@@ -1899,19 +1908,19 @@ var Ft = (e) => typeof e == "string" && e !== "" ? e : null, It = async (e, t, n
1899
1908
  ...e.includeDeleted === void 0 ? {} : { includeDeleted: e.includeDeleted },
1900
1909
  ...e.crossTenant === void 0 ? {} : { crossTenant: e.crossTenant }
1901
1910
  };
1902
- }, qo = (e, t) => {
1903
- let n = t.pk ?? "id", r = t.chunkSize ?? Go;
1911
+ }, Zo = (e, t) => {
1912
+ let n = t.pk ?? "id", r = t.chunkSize ?? Yo;
1904
1913
  return At.paginateChunkEffect(j.none(), (i) => {
1905
1914
  let a = k.tryPromise({
1906
- try: () => e.query(Ko(t, n, r, i)),
1907
- catch: (e) => new Wo({
1915
+ try: () => e.query(Xo(t, n, r, i)),
1916
+ catch: (e) => new Jo({
1908
1917
  table: t.table,
1909
1918
  cause: e
1910
1919
  })
1911
1920
  });
1912
1921
  return (t.retry ? a.pipe(k.retry(t.retry)) : a).pipe(k.map((e) => [wt.fromIterable(e), e.length === r && e.length > 0 ? j.some(j.some(e[e.length - 1][n])) : j.none()]));
1913
1922
  });
1914
- }, Jo = (e) => {
1923
+ }, Qo = (e) => {
1915
1924
  let t = e.alpha ?? .5;
1916
1925
  if (t < 0 || t > 1) throw Error(`hybridSearch: alpha must be in [0, 1], got ${t}`);
1917
1926
  return (n) => {
@@ -1925,7 +1934,7 @@ var Ft = (e) => typeof e == "string" && e !== "" ? e : null, It = async (e, t, n
1925
1934
  queryText: e.vector.query,
1926
1935
  distance: e.vector.distance ?? "cosine",
1927
1936
  alpha: t
1928
- }, i = ee(n.table, e.fts.indexName, n.fullTextIndexes);
1937
+ }, i = _(n.table, e.fts.indexName, n.fullTextIndexes);
1929
1938
  return {
1930
1939
  ...n,
1931
1940
  annClause: r,
@@ -1938,17 +1947,17 @@ var Ft = (e) => typeof e == "string" && e !== "" ? e : null, It = async (e, t, n
1938
1947
  }
1939
1948
  };
1940
1949
  };
1941
- }, Yo = async (e, t) => {
1950
+ }, $o = async (e, t) => {
1942
1951
  let n = e.as ?? "embedding", r = t.row[e.from];
1943
1952
  if (typeof r != "string" || r.length === 0) return {};
1944
1953
  let i = await t.embed(r);
1945
1954
  return { [n]: i };
1946
- }, Xo = (e) => {
1955
+ }, es = (e) => {
1947
1956
  if (!Number.isInteger(e.dimensions) || e.dimensions <= 0) throw Error(`vectorEmbedding: dimensions must be a positive integer, got ${String(e.dimensions)}.`);
1948
- let t = e.as ?? "embedding", n = (t) => Yo(e, t);
1949
- return Ke({
1957
+ let t = e.as ?? "embedding", n = (t) => $o(e, t);
1958
+ return Ge({
1950
1959
  id: "voltro/vectorEmbedding",
1951
- fields: { [t]: De(e.dimensions) },
1960
+ fields: { [t]: Ee(e.dimensions) },
1952
1961
  ...e.index === !1 ? {} : { indexes: [{
1953
1962
  fields: [t],
1954
1963
  kind: "hnsw",
@@ -1963,19 +1972,19 @@ var Ft = (e) => typeof e == "string" && e !== "" ? e : null, It = async (e, t, n
1963
1972
  beforeUpdate: n
1964
1973
  }
1965
1974
  });
1966
- }, Zo = 63, Qo = "br_pr", Y = class extends Error {
1975
+ }, ts = 63, ns = "br_pr", Y = class extends Error {
1967
1976
  _tag = "BranchNameInvalid";
1968
1977
  constructor(e) {
1969
1978
  super(e), this.name = "BranchNameInvalid";
1970
1979
  }
1971
- }, $o = (e, t) => {
1980
+ }, rs = (e, t) => {
1972
1981
  if (!Number.isInteger(t) || t < 0) throw new Y(`prNumber must be a non-negative integer, got ${String(t)}`);
1973
1982
  let n = br(e);
1974
1983
  if (n.replace(/_/g, "") === "") throw new Y(`app slug '${e}' has no usable identifier characters`);
1975
- let r = `${Qo}${t}_${n}`;
1976
- if (r.length > Zo) throw new Y(`branch namespace '${r}' exceeds the ${Zo}-byte identifier limit — use a shorter app slug`);
1984
+ let r = `${ns}${t}_${n}`;
1985
+ if (r.length > ts) throw new Y(`branch namespace '${r}' exceeds the ${ts}-byte identifier limit — use a shorter app slug`);
1977
1986
  return r;
1978
- }, es = (e) => e.startsWith(Qo), ts = {
1987
+ }, is = (e) => e.startsWith(ns), as = {
1979
1988
  requested: {
1980
1989
  provision: "provisioning",
1981
1990
  destroy: "destroying"
@@ -1994,18 +2003,18 @@ var Ft = (e) => typeof e == "string" && e !== "" ? e : null, It = async (e, t, n
1994
2003
  fail: "failed"
1995
2004
  },
1996
2005
  destroyed: {}
1997
- }, ns = class extends Error {
2006
+ }, os = class extends Error {
1998
2007
  from;
1999
2008
  event;
2000
2009
  _tag = "BranchTransitionInvalid";
2001
2010
  constructor(e, t) {
2002
2011
  super(`invalid branch transition: ${e} --${t}-->`), this.from = e, this.event = t, this.name = "BranchTransitionInvalid";
2003
2012
  }
2004
- }, rs = (e, t) => {
2005
- let n = ts[e][t];
2006
- if (n === void 0) throw new ns(e, t);
2013
+ }, ss = (e, t) => {
2014
+ let n = as[e][t];
2015
+ if (n === void 0) throw new os(e, t);
2007
2016
  return n;
2008
- }, is = (e, t, n, r, i = [], a = []) => {
2017
+ }, cs = (e, t, n, r, i = [], a = []) => {
2009
2018
  if (n === "copy" && (r === void 0 || r === "")) throw new Y("seed 'copy' requires a parentNamespace to snapshot from");
2010
2019
  let o = [{
2011
2020
  kind: "create-namespace",
@@ -2035,13 +2044,13 @@ var Ft = (e) => typeof e == "string" && e !== "" ? e : null, It = async (e, t, n
2035
2044
  kind: "seed",
2036
2045
  detail: `run boot seeds into ${e}`
2037
2046
  }), o;
2038
- }, as = (e) => {
2039
- if (!es(e)) throw new Y(`refusing to plan teardown of '${e}' — not a branch namespace`);
2047
+ }, ls = (e) => {
2048
+ if (!is(e)) throw new Y(`refusing to plan teardown of '${e}' — not a branch namespace`);
2040
2049
  return [{
2041
2050
  kind: "drop-namespace",
2042
2051
  detail: e
2043
2052
  }];
2044
- }, os = (e) => {
2053
+ }, us = (e) => {
2045
2054
  if (e === void 0 || e === "") return !1;
2046
2055
  try {
2047
2056
  let t = new URL(e).hostname.toLowerCase();
@@ -2049,27 +2058,27 @@ var Ft = (e) => typeof e == "string" && e !== "" ? e : null, It = async (e, t, n
2049
2058
  } catch {
2050
2059
  return /\bneon\.(tech|build)\b/i.test(e);
2051
2060
  }
2052
- }, ss = (e) => e.prefer === void 0 ? e.seed === "copy" && os(e.dbUrl) ? "neon-cow" : "namespace" : e.prefer, cs = (e, t = {}) => [{
2061
+ }, ds = (e) => e.prefer === void 0 ? e.seed === "copy" && us(e.dbUrl) ? "neon-cow" : "namespace" : e.prefer, fs = (e, t = {}) => [{
2053
2062
  kind: "neon-branch-create",
2054
2063
  detail: `${t.parentBranch ?? "main"} → ${e} (copy-on-write)`
2055
- }], ls = (e) => {
2056
- if (!es(e)) throw new Y(`refusing to plan teardown of '${e}' — not a branch namespace`);
2064
+ }], ps = (e) => {
2065
+ if (!is(e)) throw new Y(`refusing to plan teardown of '${e}' — not a branch namespace`);
2057
2066
  return [{
2058
2067
  kind: "neon-branch-delete",
2059
2068
  detail: e
2060
2069
  }];
2061
- }, us = (e) => e.mechanism === "neon-cow" ? cs(e.branchId, e.neonParentBranch === void 0 ? {} : { parentBranch: e.neonParentBranch }) : is(e.branchId, e.tableNames, e.seed, e.parentNamespace, e.foreignKeys, e.indexNames), ds = (e, t) => e === "neon-cow" ? ls(t) : as(t), fs = (e, t, n) => {
2070
+ }, ms = (e) => e.mechanism === "neon-cow" ? fs(e.branchId, e.neonParentBranch === void 0 ? {} : { parentBranch: e.neonParentBranch }) : cs(e.branchId, e.tableNames, e.seed, e.parentNamespace, e.foreignKeys, e.indexNames), hs = (e, t) => e === "neon-cow" ? ps(t) : ls(t), gs = (e, t, n) => {
2062
2071
  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);
2063
2072
  return {
2064
2073
  evict: i,
2065
2074
  rejectNew: r.filter((e) => !a.has(e.namespace)).length >= t.maxBranches
2066
2075
  };
2067
- }, ps = async (e, t) => {
2068
- let n = $o(e.appSlug, e.prNumber), r = ss({
2076
+ }, _s = async (e, t) => {
2077
+ let n = rs(e.appSlug, e.prNumber), r = ds({
2069
2078
  seed: e.seed,
2070
2079
  ...e.dbUrl === void 0 ? {} : { dbUrl: e.dbUrl },
2071
2080
  ...e.prefer === void 0 ? {} : { prefer: e.prefer }
2072
- }), i = us({
2081
+ }), i = ms({
2073
2082
  mechanism: r,
2074
2083
  branchId: n,
2075
2084
  tableNames: e.tableNames,
@@ -2098,15 +2107,15 @@ var Ft = (e) => typeof e == "string" && e !== "" ? e : null, It = async (e, t, n
2098
2107
  mechanism: r,
2099
2108
  steps: i
2100
2109
  };
2101
- }, ms = async (e, t, n) => {
2102
- let r = ds(t, e);
2110
+ }, vs = async (e, t, n) => {
2111
+ let r = hs(t, e);
2103
2112
  return t === "neon-cow" ? await n.neonBranchDelete(e) : await n.dropNamespace(e), r;
2104
- }, hs = (e, t, n) => fs(e, t, n), X = (e) => `"${e.replace(/"/g, "\"\"")}"`, gs = {
2113
+ }, ys = (e, t, n) => gs(e, t, n), X = (e) => `"${e.replace(/"/g, "\"\"")}"`, bs = {
2105
2114
  cascade: "CASCADE",
2106
2115
  restrict: "RESTRICT",
2107
2116
  setNull: "SET NULL",
2108
2117
  noAction: "NO ACTION"
2109
- }, Z = (e) => `'${e.replace(/'/g, "''")}'`, _s = (e, t) => {
2118
+ }, Z = (e) => `'${e.replace(/'/g, "''")}'`, xs = (e, t) => {
2110
2119
  let n = t.columns.map(Z).join(", ");
2111
2120
  return `DO $voltro_branch$
2112
2121
  DECLARE derived name;
@@ -2133,10 +2142,10 @@ BEGIN
2133
2142
  END IF;
2134
2143
  END
2135
2144
  $voltro_branch$`;
2136
- }, vs = (e, t) => {
2137
- let n = t.onDelete === void 0 ? "" : ` ON DELETE ${gs[t.onDelete]}`, r = t.onUpdate === void 0 ? "" : ` ON UPDATE ${gs[t.onUpdate]}`;
2145
+ }, Ss = (e, t) => {
2146
+ let n = t.onDelete === void 0 ? "" : ` ON DELETE ${bs[t.onDelete]}`, r = t.onUpdate === void 0 ? "" : ` ON UPDATE ${bs[t.onUpdate]}`;
2138
2147
  return `ALTER TABLE ${X(e)}.${X(t.table)} ADD FOREIGN KEY (${X(t.column)}) REFERENCES ${X(e)}.${X(t.targetTable)} (${X(t.targetColumn)})${n}${r}`;
2139
- }, ys = (e) => {
2148
+ }, Cs = (e) => {
2140
2149
  let t = () => {
2141
2150
  throw Error("namespace branch executor: Neon ops require a neon-cow executor (use a Neon connection for copy-on-write branches)");
2142
2151
  };
@@ -2144,24 +2153,24 @@ $voltro_branch$`;
2144
2153
  createNamespace: (t) => e.run(`CREATE SCHEMA IF NOT EXISTS ${X(t)}`),
2145
2154
  createTable: (t, n) => e.run(`CREATE TABLE IF NOT EXISTS ${X(t)}.${X(n)} (LIKE ${X(n)} INCLUDING ALL)`),
2146
2155
  copyTable: (t, n, r) => e.run(`INSERT INTO ${X(n)}.${X(r)} SELECT * FROM ${X(t)}.${X(r)}`),
2147
- addForeignKey: (t, n) => e.run(vs(t, n)),
2148
- restoreIndexName: (t, n) => e.run(_s(t, n)),
2156
+ addForeignKey: (t, n) => e.run(Ss(t, n)),
2157
+ restoreIndexName: (t, n) => e.run(xs(t, n)),
2149
2158
  dropNamespace: (t) => e.run(`DROP SCHEMA IF EXISTS ${X(t)} CASCADE`),
2150
2159
  neonBranchCreate: t,
2151
2160
  neonBranchDelete: t
2152
2161
  };
2153
- }, bs = class extends Error {
2162
+ }, ws = class extends Error {
2154
2163
  _tag = "TenantResidencyUnresolved";
2155
2164
  constructor(e) {
2156
2165
  super(e), this.name = "TenantResidencyUnresolved";
2157
2166
  }
2158
- }, xs = class extends Error {
2167
+ }, Ts = class extends Error {
2159
2168
  region;
2160
2169
  _tag = "TenantRegionUnavailable";
2161
2170
  constructor(e, t) {
2162
2171
  super(t), this.region = e, this.name = "TenantRegionUnavailable";
2163
2172
  }
2164
- }, Ss, Cs = (e) => {
2173
+ }, Es, Ds = (e) => {
2165
2174
  if (e.homes === void 0) throw Error("setResidencyConfig: `homes` is required");
2166
2175
  if (e.servableRegions === void 0 || e.servableRegions.length === 0) throw Error("setResidencyConfig: `servableRegions` must be non-empty (which regions this deployment serves)");
2167
2176
  let t = /* @__PURE__ */ new Map();
@@ -2170,55 +2179,55 @@ $voltro_branch$`;
2170
2179
  if (e !== void 0 && e !== n.region) throw Error(`residency: tenant '${n.tenantId}' is mapped to two regions ('${e}' and '${n.region}')`);
2171
2180
  t.set(n.tenantId, n.region);
2172
2181
  }
2173
- return Ss = e, e;
2174
- }, ws = () => Ss, Ts = () => {
2175
- Ss = void 0;
2176
- }, Es = (e, t) => {
2177
- if (e == null || e === "") throw new bs("residency is on but the request has no resolvable tenant — refusing to bind a store");
2182
+ return Es = e, e;
2183
+ }, Os = () => Es, ks = () => {
2184
+ Es = void 0;
2185
+ }, As = (e, t) => {
2186
+ if (e == null || e === "") throw new ws("residency is on but the request has no resolvable tenant — refusing to bind a store");
2178
2187
  let n = t.homes.find((t) => t.tenantId === e);
2179
- if (n === void 0) throw new bs(`no residency home is mapped for tenant '${e}' — refusing to fall back to a default store (would be a residency violation)`);
2188
+ if (n === void 0) throw new ws(`no residency home is mapped for tenant '${e}' — refusing to fall back to a default store (would be a residency violation)`);
2180
2189
  return n;
2181
- }, Ds = (e, t) => t.servableRegions.includes(e), Os = (e, t) => {
2182
- let n = Es(e.tenantId, t), r = xr(n.tenantId);
2190
+ }, js = (e, t) => t.servableRegions.includes(e), Ms = (e, t) => {
2191
+ let n = As(e.tenantId, t), r = xr(n.tenantId);
2183
2192
  return {
2184
2193
  region: n.region,
2185
2194
  namespace: r,
2186
2195
  ...n.connectionKey === void 0 ? {} : { connectionKey: n.connectionKey }
2187
2196
  };
2188
- }, ks = (e, t, n) => {
2189
- let r = Os(e, t);
2190
- if (!Ds(r.region, t)) throw new xs(r.region, `tenant homed in region '${r.region}', which this deployment does not serve — route to the home region`);
2197
+ }, Ns = (e, t, n) => {
2198
+ let r = Ms(e, t);
2199
+ if (!js(r.region, t)) throw new Ts(r.region, `tenant homed in region '${r.region}', which this deployment does not serve — route to the home region`);
2191
2200
  let i = n.get(r.region);
2192
- if (i === void 0) throw new xs(r.region, `no store handle for home region '${r.region}' (declared servable but not wired) — failing closed`);
2201
+ if (i === void 0) throw new Ts(r.region, `no store handle for home region '${r.region}' (declared servable but not wired) — failing closed`);
2193
2202
  return {
2194
2203
  store: i,
2195
2204
  placement: r
2196
2205
  };
2197
- }, As = async (e, t, n, r) => {
2198
- let { store: i, placement: a } = ks(e, t, n);
2206
+ }, Ps = async (e, t, n, r) => {
2207
+ let { store: i, placement: a } = Ns(e, t, n);
2199
2208
  return await r(i, a), a;
2200
- }, js = (e) => {
2209
+ }, Fs = (e) => {
2201
2210
  if (typeof e == "string") return e;
2202
2211
  if ("jsonPath" in e) {
2203
2212
  let { column: t, path: n, numeric: r } = e.jsonPath;
2204
2213
  return `(json:${t}->${n.join(".")}${r ? "::num" : ""})`;
2205
2214
  }
2206
2215
  return `(${e.expr})`;
2207
- }, Q = (e) => e.map(js), Ms = (e, t) => {
2216
+ }, Q = (e) => e.map(Fs), Is = (e, t) => {
2208
2217
  if (e.length !== t.length) return !1;
2209
- for (let n = 0; n < e.length; n++) if (js(e[n]) !== js(t[n])) return !1;
2218
+ for (let n = 0; n < e.length; n++) if (Fs(e[n]) !== Fs(t[n])) return !1;
2210
2219
  return !0;
2211
- }, Ns = (e, t) => {
2220
+ }, Ls = (e, t) => {
2212
2221
  if (e.length >= t.length) return !1;
2213
- for (let n = 0; n < e.length; n++) if (js(e[n]) !== js(t[n])) return !1;
2222
+ for (let n = 0; n < e.length; n++) if (Fs(e[n]) !== Fs(t[n])) return !1;
2214
2223
  return !0;
2215
- }, Ps = (e) => {
2224
+ }, Rs = (e) => {
2216
2225
  let t = [], n = e.appliedIndexes, r = e.tableName;
2217
2226
  for (let e = 0; e < n.length; e++) {
2218
2227
  let i = n[e];
2219
2228
  for (let a = e + 1; a < n.length; a++) {
2220
2229
  let e = n[a];
2221
- if (Ms(i.fields, e.fields)) {
2230
+ if (Is(i.fields, e.fields)) {
2222
2231
  let [n, a] = i.name < e.name ? [i, e] : [e, i];
2223
2232
  t.push({
2224
2233
  kind: "duplicate-fields",
@@ -2229,13 +2238,13 @@ $voltro_branch$`;
2229
2238
  });
2230
2239
  continue;
2231
2240
  }
2232
- Ns(i.fields, e.fields) ? t.push({
2241
+ Ls(i.fields, e.fields) ? t.push({
2233
2242
  kind: "redundant-prefix",
2234
2243
  table: r,
2235
2244
  redundant: i,
2236
2245
  coveredBy: e,
2237
2246
  message: `'${r}' index '${i.name}' on [${Q(i.fields).join(", ")}] is a leading prefix of '${e.name}' on [${Q(e.fields).join(", ")}]. Every B-tree dialect we support (Postgres / MySQL / MariaDB / MSSQL / SQLite) can serve a [${Q(i.fields).join(", ")}] query from '${e.name}' too via the leading-prefix rule, so '${i.name}' adds write cost without read benefit. Drop '${i.name}' — unless you specifically need a smaller index for cache locality on a write-heavy table (rare; profile first).`
2238
- }) : Ns(e.fields, i.fields) && t.push({
2247
+ }) : Ls(e.fields, i.fields) && t.push({
2239
2248
  kind: "redundant-prefix",
2240
2249
  table: r,
2241
2250
  redundant: e,
@@ -2245,23 +2254,23 @@ $voltro_branch$`;
2245
2254
  }
2246
2255
  }
2247
2256
  return t;
2248
- }, Fs = (e) => {
2257
+ }, zs = (e) => {
2249
2258
  let t = [];
2250
- for (let n of e) t.push(...Ps(n));
2259
+ for (let n of e) t.push(...Rs(n));
2251
2260
  return t;
2252
- }, Is = "\x1B[", Ls = `${Is}38;2;245;158;11m`, Rs = `${Is}38;2;16;185;129m`, zs = (e, t) => `${e}${t}${N.reset}`, $ = (e, t, n) => e ? typeof t == "function" ? t(n) : zs(t, n) : n, Bs = (e, t = {}) => {
2253
- let n = t.color ?? !0, r = t.indent ?? " ", i = (e) => $(n, N.dim, e.padEnd(11)), a = (e) => $(n, (e) => N.bold(N.brand(e)), e), o = (e) => $(n, N.brightRed24, e), s = (e) => $(n, Rs, e), c = (e) => $(n, Ls, e), l = (e) => $(n, N.dim, e), u = `${c("index audit")} ${l("·")} ${$(n, N.bold, e.kind)}`, d = e.redundant.fields.length, f = Q(e.coveredBy.fields.slice(d)), p = (e, t) => {
2261
+ }, Bs = "\x1B[", Vs = `${Bs}38;2;245;158;11m`, Hs = `${Bs}38;2;16;185;129m`, Us = (e, t) => `${e}${t}${N.reset}`, $ = (e, t, n) => e ? typeof t == "function" ? t(n) : Us(t, n) : n, Ws = (e, t = {}) => {
2262
+ let n = t.color ?? !0, r = t.indent ?? " ", i = (e) => $(n, N.dim, e.padEnd(11)), a = (e) => $(n, (e) => N.bold(N.brand(e)), e), o = (e) => $(n, N.brightRed24, e), s = (e) => $(n, Hs, e), c = (e) => $(n, Vs, e), l = (e) => $(n, N.dim, e), u = `${c("index audit")} ${l("·")} ${$(n, N.bold, e.kind)}`, d = e.redundant.fields.length, f = Q(e.coveredBy.fields.slice(d)), p = (e, t) => {
2254
2263
  let n = e.slice(0, t), r = e.slice(t), i = [];
2255
2264
  return n.length > 0 && i.push(s(`[${n.join(", ")}]`)), r.length > 0 && i.push(c(`+ [${r.join(", ")}]`)), i.join(" ");
2256
2265
  }, m = [];
2257
2266
  return m.push(u), m.push(""), m.push(`${i("table")}${a(e.table)}`), m.push(""), m.push(`${i("redundant")}${o(e.redundant.name)}`), m.push(`${i("")}${p(Q(e.redundant.fields), d)}`), m.push(""), m.push(`${i("covered by")}${s(e.coveredBy.name)}`), m.push(`${i("")}${p(Q(e.coveredBy.fields), d)}`), f.length > 0 && m.push(`${i("")}${l(`└ extra columns: ${f.join(", ")}`)}`), m.push(""), e.kind === "redundant-prefix" ? (m.push(`${i("why")}B-tree indexes serve queries that filter on a LEADING PREFIX of`), m.push(`${i("")}their column list. The wider index already covers every`), m.push(`${i("")}query the narrower one can serve.`), m.push(`${i("")}${l("Same rule on Postgres / MySQL / MariaDB / MSSQL / SQLite.")}`)) : (m.push(`${i("why")}Two indexes on the same columns under different names.`), m.push(`${i("")}The B-tree engine builds both — same coverage, double cost.`), m.push(`${i("")}${l("Same rule on Postgres / MySQL / MariaDB / MSSQL / SQLite.")}`)), m.push(""), m.push(`${i("cost")}Every ${a("INSERT")} / ${a("UPDATE")} / ${a("DELETE")} on this table writes`), m.push(`${i("")}to ${$(n, N.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");
2258
- }, Vs = (e, { apply: t, undo: n }) => ({
2267
+ }, Gs = (e, { apply: t, undo: n }) => ({
2259
2268
  name: e,
2260
2269
  apply: t,
2261
2270
  undo: n
2262
- }), Hs = (e) => {
2271
+ }), Ks = (e) => {
2263
2272
  if (!/^\d{14}_/.test(e.id)) throw Error(`migration "${e.id}": id must start with a 14-digit timestamp followed by "_" (convention: <YYYYMMDDHHMMSS>_<slug>)`);
2264
- let t = e.steps({ step: Vs });
2273
+ let t = e.steps({ step: Gs });
2265
2274
  if (t.length === 0) throw Error(`migration "${e.id}": at least one step is required`);
2266
2275
  return {
2267
2276
  __migration: !0,
@@ -2269,90 +2278,90 @@ $voltro_branch$`;
2269
2278
  name: e.name,
2270
2279
  steps: t
2271
2280
  };
2272
- }, Us = (e) => typeof e == "object" && !!e && "__migration" in e && e.__migration === !0, Ws = T("_voltro_migrations", {
2273
- id: b({ prefix: "mig" }),
2274
- name: C(),
2275
- hash: C(),
2276
- status: C(),
2277
- appliedAt: S().nullable(),
2278
- durationMs: D().nullable(),
2279
- errorMessage: C().nullable(),
2280
- errorStack: C().nullable(),
2281
- workflowRunId: C().nullable(),
2282
- createdAt: S().default("now"),
2283
- updatedAt: S().default("now").onUpdate("now")
2284
- }).index(["status"]), Gs = T("_voltro_seeds", {
2285
- id: b({ prefix: "seed" }),
2286
- name: C(),
2287
- lifecycle: C(),
2288
- fingerprint: C(),
2289
- cronSchedule: C().nullable(),
2290
- watchedTables: x().nullable(),
2291
- nextRunAt: S().nullable(),
2292
- lastRunStatus: C().nullable(),
2293
- lastRunAt: S().nullable(),
2294
- lastRunDurationMs: D().nullable(),
2295
- lastRunRowsTouched: D().nullable(),
2296
- lastError: C().nullable(),
2297
- workflowRunId: C().nullable(),
2298
- createdAt: S().default("now"),
2299
- updatedAt: S().default("now").onUpdate("now")
2300
- }).index(["lifecycle"]).index(["nextRunAt"]), Ks = T("_voltro_migration_plans", {
2301
- id: b({ prefix: "plan" }),
2302
- fingerprint: C(),
2303
- liveFingerprint: C().nullable(),
2304
- operations: x(),
2305
- rollbackPlan: x().nullable(),
2306
- appliedBy: C(),
2307
- environment: C(),
2308
- source: C(),
2309
- onlineStrategy: C().nullable(),
2310
- durationMs: D(),
2311
- notes: C().nullable(),
2312
- squashedAt: S().nullable(),
2313
- appliedAt: S().default("now"),
2314
- createdAt: S().default("now"),
2315
- updatedAt: S().default("now").onUpdate("now")
2316
- }).index(["fingerprint"]).index(["environment"]), qs = T("_voltro_idempotency", {
2317
- id: b({ prefix: "idem" }),
2318
- scope: C(),
2319
- key: C(),
2320
- status: C(),
2321
- response: x().nullable(),
2322
- createdAt: S().default("now")
2323
- }).unique(["scope", "key"]).index(["createdAt"]), Js = T("_voltro_kv", {
2324
- id: b({ prefix: "kv" }),
2325
- key: C().unique(),
2326
- value: C().nullable(),
2327
- expiresAt: S().nullable(),
2328
- createdAt: S().default("now"),
2329
- updatedAt: S().default("now").onUpdate("now")
2330
- }).index(["expiresAt"]), Ys = T("_voltro_api_keys", {
2331
- id: b({ prefix: "apikey" }),
2332
- tenantId: C().nullable(),
2333
- name: C(),
2334
- hashedKey: C().maxLength(64).unique(),
2335
- keyPrefix: C(),
2336
- scopes: x().nullable(),
2337
- lastUsedAt: S().nullable(),
2338
- requestCount: D().default(0),
2339
- expiresAt: S().nullable(),
2340
- revokedAt: S().nullable(),
2341
- createdBy: C().nullable(),
2342
- onBehalfOf: C().nullable(),
2343
- metadata: x().nullable(),
2344
- createdAt: S().default("now")
2345
- }).index("byApiKeyTenant", ["tenantId"]), Xs = [
2346
- Ws,
2347
- Gs,
2348
- Ks
2349
- ], Zs = "_voltro_replace_in_progress", Qs = T(Zs, {
2350
- id: b({ prefix: "repl" }),
2351
- startedAt: S().default("now"),
2352
- tables: C(),
2353
- capture: C().nullable(),
2354
- via: C()
2355
- }), $s = (e) => {
2281
+ }, qs = (e) => typeof e == "object" && !!e && "__migration" in e && e.__migration === !0, Js = E("_voltro_migrations", {
2282
+ id: x({ prefix: "mig" }),
2283
+ name: w(),
2284
+ hash: w(),
2285
+ status: w(),
2286
+ appliedAt: C().nullable(),
2287
+ durationMs: O().nullable(),
2288
+ errorMessage: w().nullable(),
2289
+ errorStack: w().nullable(),
2290
+ workflowRunId: w().nullable(),
2291
+ createdAt: C().default("now"),
2292
+ updatedAt: C().default("now").onUpdate("now")
2293
+ }).index(["status"]), Ys = E("_voltro_seeds", {
2294
+ id: x({ prefix: "seed" }),
2295
+ name: w(),
2296
+ lifecycle: w(),
2297
+ fingerprint: w(),
2298
+ cronSchedule: w().nullable(),
2299
+ watchedTables: S().nullable(),
2300
+ nextRunAt: C().nullable(),
2301
+ lastRunStatus: w().nullable(),
2302
+ lastRunAt: C().nullable(),
2303
+ lastRunDurationMs: O().nullable(),
2304
+ lastRunRowsTouched: O().nullable(),
2305
+ lastError: w().nullable(),
2306
+ workflowRunId: w().nullable(),
2307
+ createdAt: C().default("now"),
2308
+ updatedAt: C().default("now").onUpdate("now")
2309
+ }).index(["lifecycle"]).index(["nextRunAt"]), Xs = E("_voltro_migration_plans", {
2310
+ id: x({ prefix: "plan" }),
2311
+ fingerprint: w(),
2312
+ liveFingerprint: w().nullable(),
2313
+ operations: S(),
2314
+ rollbackPlan: S().nullable(),
2315
+ appliedBy: w(),
2316
+ environment: w(),
2317
+ source: w(),
2318
+ onlineStrategy: w().nullable(),
2319
+ durationMs: O(),
2320
+ notes: w().nullable(),
2321
+ squashedAt: C().nullable(),
2322
+ appliedAt: C().default("now"),
2323
+ createdAt: C().default("now"),
2324
+ updatedAt: C().default("now").onUpdate("now")
2325
+ }).index(["fingerprint"]).index(["environment"]), Zs = E("_voltro_idempotency", {
2326
+ id: x({ prefix: "idem" }),
2327
+ scope: w(),
2328
+ key: w(),
2329
+ status: w(),
2330
+ response: S().nullable(),
2331
+ createdAt: C().default("now")
2332
+ }).unique(["scope", "key"]).index(["createdAt"]), Qs = E("_voltro_kv", {
2333
+ id: x({ prefix: "kv" }),
2334
+ key: w().unique(),
2335
+ value: w().nullable(),
2336
+ expiresAt: C().nullable(),
2337
+ createdAt: C().default("now"),
2338
+ updatedAt: C().default("now").onUpdate("now")
2339
+ }).index(["expiresAt"]), $s = E("_voltro_api_keys", {
2340
+ id: x({ prefix: "apikey" }),
2341
+ tenantId: w().nullable(),
2342
+ name: w(),
2343
+ hashedKey: w().maxLength(64).unique(),
2344
+ keyPrefix: w(),
2345
+ scopes: S().nullable(),
2346
+ lastUsedAt: C().nullable(),
2347
+ requestCount: O().default(0),
2348
+ expiresAt: C().nullable(),
2349
+ revokedAt: C().nullable(),
2350
+ createdBy: w().nullable(),
2351
+ onBehalfOf: w().nullable(),
2352
+ metadata: S().nullable(),
2353
+ createdAt: C().default("now")
2354
+ }).index("byApiKeyTenant", ["tenantId"]), ec = [
2355
+ Js,
2356
+ Ys,
2357
+ Xs
2358
+ ], tc = "_voltro_replace_in_progress", nc = E(tc, {
2359
+ id: x({ prefix: "repl" }),
2360
+ startedAt: C().default("now"),
2361
+ tables: w(),
2362
+ capture: w().nullable(),
2363
+ via: w()
2364
+ }), rc = (e) => {
2356
2365
  if (e.length !== 0) return `refusing to start: a destructive import did not finish.
2357
2366
  ${e.map((e) => {
2358
2367
  let t = Number.isFinite(e.startedAt.getTime()) ? `${Math.max(0, Math.round((Date.now() - e.startedAt.getTime()) / 6e4))} minute(s) ago` : "at an unknown time";
@@ -2364,22 +2373,22 @@ ${e.map((e) => {
2364
2373
 
2365
2374
  When the data is back, or you have decided the current state is correct, clear the marker:
2366
2375
  voltro data clear-replace-marker --yes`;
2367
- }, ec = "id", tc = (e, t) => {
2376
+ }, ic = "id", ac = (e, t) => {
2368
2377
  let n = p(e);
2369
2378
  if (n === void 0) return t;
2370
- let r = n.fields[ec]?.idScheme;
2371
- if (r === void 0 || t[ec] != null) return t;
2379
+ let r = n.fields[ic]?.idScheme;
2380
+ if (r === void 0 || t[ic] != null) return t;
2372
2381
  if (r.kind === "numeric") {
2373
- if (!(ec in t)) return t;
2382
+ if (!(ic in t)) return t;
2374
2383
  let e = { ...t };
2375
- return delete e[ec], e;
2384
+ return delete e[ic], e;
2376
2385
  }
2377
- let i = Fe(r, e);
2386
+ let i = Pe(r, e);
2378
2387
  return i === null ? t : {
2379
2388
  ...t,
2380
- [ec]: i
2389
+ [ic]: i
2381
2390
  };
2382
- }, nc = (e, t) => t.map((t) => tc(e, t)), rc = {
2391
+ }, oc = (e, t) => t.map((t) => ac(e, t)), sc = {
2383
2392
  postgres: { maxBindParameters: 65535 },
2384
2393
  mysql: { maxBindParameters: 65535 },
2385
2394
  mariadb: { maxBindParameters: 65535 },
@@ -2389,49 +2398,49 @@ ${e.map((e) => {
2389
2398
  },
2390
2399
  sqlite: { maxBindParameters: 32766 },
2391
2400
  turso: { maxBindParameters: 32766 }
2392
- }, ic = (e) => rc[e], ac = (e) => {
2401
+ }, cc = (e) => sc[e], lc = (e) => {
2393
2402
  let t = /* @__PURE__ */ new Set();
2394
2403
  for (let n of e) for (let e of Object.keys(n)) t.add(e);
2395
2404
  return t.size;
2396
- }, oc = (e, t) => {
2405
+ }, uc = (e, t) => {
2397
2406
  if (t === void 0 || e.length === 0) return [e];
2398
- let n = Math.max(1, ac(e)), r = Math.floor(t.maxBindParameters / n), i = t.maxRowsPerStatement ?? Infinity, a = Math.max(1, Math.min(r, i));
2407
+ let n = Math.max(1, lc(e)), r = Math.floor(t.maxBindParameters / n), i = t.maxRowsPerStatement ?? Infinity, a = Math.max(1, Math.min(r, i));
2399
2408
  if (e.length <= a) return [e];
2400
2409
  let o = [];
2401
2410
  for (let t = 0; t < e.length; t += a) o.push(e.slice(t, t + a));
2402
2411
  return o;
2403
- }, sc = (e, t) => {
2412
+ }, dc = (e, t) => {
2404
2413
  let n = [], r = t;
2405
2414
  for (let [t, i] of Object.entries(e.fields)) {
2406
2415
  let e = i;
2407
2416
  e.nullable || e.hasDefault || e.idScheme !== void 0 || e.generatedAs !== void 0 || (r[t] === void 0 || r[t] === null) && n.push(t);
2408
2417
  }
2409
2418
  return n;
2410
- }, cc = (e, t) => {
2419
+ }, fc = (e, t) => {
2411
2420
  let n = t;
2412
2421
  return e.filter((e) => n[e] === void 0 || n[e] === null);
2413
- }, lc = (e, t, n) => e.insert(t.tableName, n), uc = (e, t, n, r) => e.upsert(t.tableName, n, {
2422
+ }, pc = (e, t, n) => e.insert(t.tableName, n), mc = (e, t, n, r) => e.upsert(t.tableName, n, {
2414
2423
  conflictColumns: r.conflictColumns,
2415
2424
  ...r.update === void 0 ? {} : { update: r.update }
2416
- }), dc = (e, t, n, r) => e.updateMany(t.tableName, n, { where: r.where }), fc = 512, pc = (e) => {
2425
+ }), hc = (e, t, n, r) => e.updateMany(t.tableName, n, { where: r.where }), gc = 512, _c = (e) => {
2417
2426
  e.setMaxListeners(512);
2418
- }, mc = (e, t, n) => ({
2427
+ }, vc = (e, t, n) => ({
2419
2428
  _tag: "PrimaryKeyConflictError",
2420
2429
  table: e,
2421
2430
  key: t,
2422
2431
  cause: n
2423
- }), hc = (e) => typeof e == "object" && !!e && e._tag === "PrimaryKeyConflictError", gc = {
2432
+ }), yc = (e) => typeof e == "object" && !!e && e._tag === "PrimaryKeyConflictError", bc = {
2424
2433
  postgres: 5432,
2425
2434
  mysql: 3306,
2426
2435
  mariadb: 3306,
2427
2436
  mssql: 1433
2428
- }, _c = /* @__PURE__ */ new Set([
2437
+ }, xc = /* @__PURE__ */ new Set([
2429
2438
  "localhost",
2430
2439
  "127.0.0.1",
2431
2440
  "::1",
2432
2441
  "[::1]",
2433
2442
  "0.0.0.0"
2434
- ]), vc = (e) => {
2443
+ ]), Sc = (e) => {
2435
2444
  let t = e.host, n = e.port, r = e.database;
2436
2445
  if (e.url !== void 0 && e.url !== "") try {
2437
2446
  let i = new URL(e.url);
@@ -2440,29 +2449,29 @@ ${e.map((e) => {
2440
2449
  return;
2441
2450
  }
2442
2451
  if (t === void 0 || t === "" || r === void 0 || r === "") return;
2443
- let i = n ?? gc[(e.dialect ?? "").toLowerCase()];
2452
+ let i = n ?? bc[(e.dialect ?? "").toLowerCase()];
2444
2453
  if (i === void 0 || !Number.isFinite(i)) return;
2445
2454
  let a = t.toLowerCase();
2446
2455
  return {
2447
- host: _c.has(a) ? "localhost" : a,
2456
+ host: xc.has(a) ? "localhost" : a,
2448
2457
  port: i,
2449
2458
  database: r.toLowerCase()
2450
2459
  };
2451
- }, yc = (e) => {
2452
- let t = vc(e);
2460
+ }, Cc = (e) => {
2461
+ let t = Sc(e);
2453
2462
  if (t !== void 0) return Mt("sha256").update(`${t.host}\u0000${t.port}\u0000${t.database}`).digest("hex").slice(0, 32);
2454
- }, bc = (e, t) => e === void 0 || t === void 0 ? "unknown" : e === t ? "same" : "different", xc = {
2463
+ }, wc = (e, t) => e === void 0 || t === void 0 ? "unknown" : e === t ? "same" : "different", Tc = {
2455
2464
  app: 3,
2456
2465
  plugin: 2,
2457
2466
  framework: 1
2458
- }, Sc = /* @__PURE__ */ new Map(), Cc = [], wc = () => [...Cc], Tc = (e) => {
2467
+ }, Ec = /* @__PURE__ */ new Map(), Dc = [], Oc = () => [...Dc], kc = (e) => {
2459
2468
  if (!e.table || !e.timeColumn) throw Error("registerRetention: table + timeColumn are required");
2460
2469
  if (!Number.isFinite(e.ttlMs) || e.ttlMs <= 0) throw Error(`registerRetention(${e.table}): ttlMs must be a positive number`);
2461
- let t = e.source ?? "app", n = Sc.get(e.table);
2470
+ let t = e.source ?? "app", n = Ec.get(e.table);
2462
2471
  if (n !== void 0) {
2463
2472
  let r = n.source ?? "app", i = n.ttlMs !== e.ttlMs || n.where !== void 0 != (e.where !== void 0);
2464
- if (xc[t] < xc[r]) {
2465
- i && Cc.push({
2473
+ if (Tc[t] < Tc[r]) {
2474
+ i && Dc.push({
2466
2475
  table: e.table,
2467
2476
  kept: {
2468
2477
  source: r,
@@ -2475,7 +2484,7 @@ ${e.map((e) => {
2475
2484
  });
2476
2485
  return;
2477
2486
  }
2478
- i && r !== t && Cc.push({
2487
+ i && r !== t && Dc.push({
2479
2488
  table: e.table,
2480
2489
  kept: {
2481
2490
  source: t,
@@ -2487,35 +2496,46 @@ ${e.map((e) => {
2487
2496
  }
2488
2497
  });
2489
2498
  }
2490
- Sc.set(e.table, {
2499
+ Ec.set(e.table, {
2491
2500
  ...e,
2492
2501
  source: t
2493
2502
  });
2494
- }, Ec = () => [...Sc.values()], Dc = () => {
2495
- Sc.clear(), Cc.length = 0;
2496
- }, Oc = async (e, t, n, r = 2e4) => {
2503
+ }, Ac = () => [...Ec.values()], jc = () => {
2504
+ Ec.clear(), Dc.length = 0;
2505
+ }, Mc = async (e, t, n, r = 2e4) => {
2497
2506
  let i = new Date(t - e.ttlMs), a = 0;
2498
2507
  for (;;) {
2499
2508
  let t = await n(e.table, e.timeColumn, i, r, e.where);
2500
2509
  if (a += t, t < r) break;
2501
2510
  }
2502
2511
  return a;
2503
- }, kc = (e, t) => {
2512
+ }, Nc = (e, t) => {
2504
2513
  let n = Number(e ?? String(t));
2505
2514
  return (Number.isFinite(n) && n > 0 ? n : t) * 36e5;
2506
- }, Ac = "_voltro_cdc_offsets", jc = T(Ac, {
2507
- id: b({ prefix: "cdcoff" }),
2508
- replicaId: C(),
2509
- streamName: C(),
2510
- binlogFile: C(),
2511
- binlogPosition: C(),
2512
- updatedAt: S()
2513
- }).index(["replicaId"]), Mc = T(Ac, {
2514
- id: b({ prefix: "cdcoff" }),
2515
- replicaId: C(),
2516
- streamName: C(),
2517
- ctVersion: C(),
2518
- updatedAt: S()
2519
- }).index(["replicaId"]), Nc = "postgres";
2515
+ }, Pc = "_voltro_cdc_offsets", Fc = E(Pc, {
2516
+ id: x({ prefix: "cdcoff" }),
2517
+ replicaId: w(),
2518
+ streamName: w(),
2519
+ binlogFile: w(),
2520
+ binlogPosition: w(),
2521
+ updatedAt: C()
2522
+ }).index(["replicaId"]), Ic = E(Pc, {
2523
+ id: x({ prefix: "cdcoff" }),
2524
+ replicaId: w(),
2525
+ streamName: w(),
2526
+ ctVersion: w(),
2527
+ updatedAt: C()
2528
+ }).index(["replicaId"]), Lc = "_voltro_data_imports", Rc = E(Lc, {
2529
+ id: x({ prefix: "dimp" }),
2530
+ startedAt: C().default("now"),
2531
+ finishedAt: C().nullable(),
2532
+ mode: w(),
2533
+ via: w(),
2534
+ bundle: w().nullable(),
2535
+ sourceFingerprint: w().nullable(),
2536
+ tablesWritten: O().default(0),
2537
+ rowsWritten: O().default(0),
2538
+ failure: w().nullable()
2539
+ }).nonReactive(), zc = (e) => `${Number.isFinite(e.startedAt.getTime()) ? e.startedAt.toISOString() : "an unknown time"} · ${e.failure === null ? e.finishedAt === null ? `${e.mode} — started and never reported finishing` : `${e.mode} — ${e.rowsWritten} row(s) across ${e.tablesWritten} table(s)` : `FAILED ${e.mode} — ${e.failure}`} · via ${e.via}` + (e.bundle === null ? "" : ` · from ${e.bundle}`) + (e.sourceFingerprint === null ? "" : ` · source schema ${e.sourceFingerprint}`), Bc = "postgres";
2520
2540
  //#endregion
2521
- export { Re as AUTO_FILLED_COLUMNS, rc as BULK_INSERT_LIMITS, Y as BranchNameInvalid, ns as BranchTransitionInvalid, Ac as CDC_OFFSETS_TABLE, fc as CHANGE_LISTENER_CEILING, ve as ColumnBuilder, we as DEFAULT_ACQUIRE_TIMEOUT_MS, wo as DEFAULT_EAGER_FALLBACK_WARN_INTERVAL_MS, Bn as DEFAULT_SUBJECT_GRAPH_DEPTH, Vt as ENCRYPTED_PREFIX, Nc as ENGINE, rr as EagerCardinalityError, Ge as FILE_MIGRATION_PATTERN, lt as FRAMEWORK_LIVE_TABLES, Ht as FieldDecryptionError, Ya as ID_COLUMN_MAX_LENGTH, Lo as INITIAL_VERSION, aa as MATCHES_NO_ROWS, Be as MAX_IDENTIFIER_LENGTH, Zs as REPLACE_IN_PROGRESS_TABLE, Pt as SqlClient, Wo as TableStreamError, _r as TenantNamespaceInvalid, gr as TenantNamespaceUnresolved, xs as TenantRegionUnavailable, bs as TenantResidencyUnresolved, Ro as VOLTRO_EXPIRES_MIXIN_ID, Bo as VOLTRO_LOCAL_FIRST_MIXIN_ID, No as VersionConflict, rt as WARN_IDENTIFIER_LENGTH, Ys as _voltroApiKeysTable, jc as _voltroCdcOffsetsTable, qs as _voltroIdempotencyTable, Js as _voltroKvTable, Ks as _voltroMigrationPlansTable, Ws as _voltroMigrationsTable, Mc as _voltroMssqlCdcOffsetsTable, Qs as _voltroReplaceInProgressTable, Gs as _voltroSeedsTable, Gi as actorsTable, hs as admitBranch, bt as allEnumRenames, Ln as allRegisteredRelations, h as allRegisteredTables, la as and, u as array, na as arrayContains, ia as arrayHas, ra as arrayOverlaps, ar as attachEagerLoads, ja as attributionFields, Fa as attributionKey, Fs as auditAllTableIndexes, Ps as auditTableIndexes, pt as avg, yt as avgOver, Wa as beginLocalWrite, c as bigint, ks as bindResidentStore, ue as boolean, $o as branchNamespaceName, ic as bulkInsertLimitsFor, Ye as bytes, Ea as changeDelete, wa as changeInsert, Da as changeSoftDelete, Ta as changeUpdate, oc as chunkRowsForInsert, Ra as claimPendingAttribution, sn as classifyConstraintViolation, Ne as clearEnumRenames, qa as clearPendingAttribution, zn as clearRelationsRegistry, Ts as clearResidencyConfig, Dc as clearRetentions, ye as clearTableRegistry, no as clearWriteRecorders, Tr as coercePredicateValue, Er as coercePredicateValues, xa as collectSubqueries, Me as column, pn as columnSchema, ac as columnsPerRow, Br as compileEagerJson, L as compilePredicate, Dr as compileRawFragment, zr as compileSelect, Yo as computeEmbedding, yc as connectionIdentity, ea as contains, _t as count, he as countDistinct, n as crdtManagedColumns, qe as crdtText, Aa as currentWriteAttribution, a as databaseHandle, oe as date, ce as dbEnum, vo as dbMetricTagCacheSizeForTests, xo as dbOperationsInFlight, fe as decimal, vt as declareEnumRename, qt as decodeFieldValue, er as decodeRowsFromSchema, Qt as decryptFieldsOnRead, Hs as defineMigration, Ke as defineMixin, st as defineSeed, ht as denseRank, qn as deriveSubjectGraph, ct as deriveTypeIdPrefix, Qa as derivedRowId, $a as derivedRowIdLength, un as describeDriverError, dn as describeRowBindings, Bt as deserializeArraysOnRead, $e as drainIdentifierWarnings, f as dropped, Gt as encodeFieldValue, nr as encodeRowForSchema, Zt as encryptFieldsForWrite, Xt as encryptedColumnsOf, Ga as endLocalWrite, fs as enforceBranchLimits, Se as ensureTableRegistered, Ki as eq, Or as escapeLike, ba as evaluatePredicate, _e as except, ga as exists, zo as expires, Ca as externalChangeEvent, rn as extractDbCause, Pe as fireSchemaChangeSeeds, Xe as fireTenantCreateSeeds, Bs as formatIndexAuditIssue, Jn as formatSubjectGraph, Xs as frameworkTables, Fe as generateId, ft as generateSnowflake, te as geography, y as geometry, ge as getEnumRenames, In as getRelation, Fn as getRelations, ws as getResidencyConfig, p as getTable, Ji as gt, Yi as gte, hr as hasEagerLoads, Jo as hybridSearch, b as id, Qi as inSet, ma as inSubquery, En as inferForeignKey, lc as insertRow, D as integer, $s as interruptedReplaceRefusal, l as intersect, i as interval, es as isBranchNamespace, xn as isEmptyRelationsSpec, Wt as isEncrypted, Ut as isFieldDecryptionError, Ae as isFileMigration, cn as isForeignKeyViolation, et as isFrameworkOwnedLiveTable, Ho as isLocalFirst, Us as isMigrationDefinition, Ee as isMysqlFamily, os as isNeonConnection, sa as isNotNull, oa as isNull, hc as isPrimaryKeyConflictError, ln as isQueryTimeout, Jt as isRawEncoding, Ds as isRegionServable, Sn as isRelationsSpec, dt as isSeedDefinition, pe as isSqliteFamily, re as isTableReactive, Qe as isView, x as json, fa as jsonField, ut as jsonIndex, s as lag, le as lead, wc as listRetentionConflicts, Ec as listRetentions, Vo as localFirst, Uo as localFirstTables, Xi as lt, Zi as lte, Do as makeEagerFallbackReporter, ys as makeNamespaceBranchExecutor, wn as many, Tn as manyToMany, g as materializeFields, Je as max, tt as migration, t as min, cc as missingConflictColumns, sc as missingRequiredColumns, je as mixin, qi as neq, rs as nextBranchState, vc as normaliseTarget, da as not, _a as notExists, $i as notInSet, ha as notInSubquery, be as numeric, Co as observeDbOp, Cn as one, ir as oneCardinalityMessage, ua as or, w as orderClausesOf, ae as paginateBy, se as paginateById, Ja as pendingAttributionCount, us as planBranch, is as planBranchProvision, as as planBranchTeardown, ds as planBranchTeardownFor, cs as planNeonBranchProvision, ls as planNeonBranchTeardown, Fo as planVersionedUpdate, o as pluginRef, gt as pluginRefSpecOf, mc as primaryKeyConflictError, ps as provisionBranch, As as provisionResidentTenant, Sr as qualifyTable, de as queryFor, Ue as queryForView, e as quoteIdent, pc as raiseChangeListenerCeiling, d as rank, Ce as raw, m as readableByColumns, v as real, So as recordDbOp, ro as recordsTable, at as reference, Vi as registerCoreTables, Pn as registerDiscoveredRelations, La as registerPendingAttribution, Nn as registerRelations, Tc as registerRetention, it as registerTable, eo as registerWriteRecorder, bn as relations, Ui as requireActors, _ as requireTable, Wi as requireTenants, _o as resetDbMetricTagCacheForTests, Le as resetSnowflake, Os as residentPlacement, It as resolveActorSnapshot, ss as resolveBranchMechanism, Eo as resolveEagerFallbackWarnIntervalMs, Ka as resolveEchoAttribution, ee as resolveFullTextIndex, Ze as resolveIdScheme, nt as resolveMixinGraph, Es as resolveTenantHome, xr as resolveTenantNamespace, kc as retentionTtlMsFromEnv, ie as rowNumber, mn as rowSchema, jo as runRetryingTransaction, Mo as runStoreTransaction, ka as runWithWriteAttribution, io as runWriteRecorders, bc as sameDatabase, br as sanitizeIdentifierFragment, zt as serializeArraysForWrite, ne as serverOnlyColumns, Cs as setResidencyConfig, Ie as setSchemaChangeSeedHook, ze as setTenantCreateSeedHook, Oo as settleTransactionExit, Io as settleVersionedUpdate, ca as spatialPredicate, tc as stampGeneratedId, nc as stampGeneratedIds, ta as startsWith, qo as streamTable, me as sum, xt as sumOver, Oc as sweepRetention, T as table, ms as teardownBranch, C as text, S as timestamp, St as timestampMs, Ct as timestampMsOrNull, r as union, xe as unionAll, Te as unregisterTable, to as unregisterWriteRecorder, dc as updateManyRow, uc as upsertRow, We as validateColumnName, He as validateIndexName, Rn as validateRegisteredRelations, An as validateRelationConfig, ke as validateTableName, mt as validateTypeIdPrefix, De as vector, ot as vectorDistanceToOpclass, Xo as vectorEmbedding, Po as versionColumnOf, Ve as view, Oe as viewSql, Sa as walkLeaves, Ma as withCapturedAttribution };
2541
+ export { Le as AUTO_FILLED_COLUMNS, sc as BULK_INSERT_LIMITS, Y as BranchNameInvalid, os as BranchTransitionInvalid, Pc as CDC_OFFSETS_TABLE, gc as CHANGE_LISTENER_CEILING, _e as ColumnBuilder, Ce as DEFAULT_ACQUIRE_TIMEOUT_MS, Oo as DEFAULT_EAGER_FALLBACK_WARN_INTERVAL_MS, Bn as DEFAULT_SUBJECT_GRAPH_DEPTH, Vt as ENCRYPTED_PREFIX, Bc as ENGINE, rr as EagerCardinalityError, We as FILE_MIGRATION_PATTERN, ct as FRAMEWORK_LIVE_TABLES, Ht as FieldDecryptionError, Ya as ID_COLUMN_MAX_LENGTH, Lc as IMPORT_RUNS_TABLE, Vo as INITIAL_VERSION, aa as MATCHES_NO_ROWS, ze as MAX_IDENTIFIER_LENGTH, tc as REPLACE_IN_PROGRESS_TABLE, Pt as SqlClient, Jo as TableStreamError, _r as TenantNamespaceInvalid, gr as TenantNamespaceUnresolved, Ts as TenantRegionUnavailable, ws as TenantResidencyUnresolved, Ho as VOLTRO_EXPIRES_MIXIN_ID, Wo as VOLTRO_LOCAL_FIRST_MIXIN_ID, Lo as VersionConflict, nt as WARN_IDENTIFIER_LENGTH, $s as _voltroApiKeysTable, Fc as _voltroCdcOffsetsTable, Zs as _voltroIdempotencyTable, Rc as _voltroImportRunsTable, Qs as _voltroKvTable, Xs as _voltroMigrationPlansTable, Js as _voltroMigrationsTable, Ic as _voltroMssqlCdcOffsetsTable, nc as _voltroReplaceInProgressTable, Ys as _voltroSeedsTable, Gi as actorsTable, ys as admitBranch, yt as allEnumRenames, Ln as allRegisteredRelations, h as allRegisteredTables, la as and, u as array, na as arrayContains, ia as arrayHas, ra as arrayOverlaps, ar as attachEagerLoads, ja as attributionFields, Fa as attributionKey, zs as auditAllTableIndexes, Rs as auditTableIndexes, ft as avg, vt as avgOver, Wa as beginLocalWrite, c as bigint, Ns as bindResidentStore, le as boolean, rs as branchNamespaceName, cc as bulkInsertLimitsFor, Je as bytes, Ea as changeDelete, wa as changeInsert, Da as changeSoftDelete, Ta as changeUpdate, uc as chunkRowsForInsert, Ra as claimPendingAttribution, sn as classifyConstraintViolation, Me as clearEnumRenames, qa as clearPendingAttribution, zn as clearRelationsRegistry, ks as clearResidencyConfig, jc as clearRetentions, ve as clearTableRegistry, no as clearWriteRecorders, Tr as coercePredicateValue, Er as coercePredicateValues, xa as collectSubqueries, je as column, pn as columnSchema, lc as columnsPerRow, Br as compileEagerJson, L as compilePredicate, Dr as compileRawFragment, zr as compileSelect, $o as computeEmbedding, Cc as connectionIdentity, ea as contains, gt as count, me as countDistinct, n as crdtManagedColumns, Ke as crdtText, Aa as currentWriteAttribution, a as databaseHandle, ae as date, se as dbEnum, So as dbMetricTagCacheSizeForTests, To as dbOperationsInFlight, de as decimal, _t as declareEnumRename, qt as decodeFieldValue, er as decodeRowsFromSchema, Qt as decryptFieldsOnRead, Ks as defineMigration, Ge as defineMixin, ot as defineSeed, mt as denseRank, qn as deriveSubjectGraph, st as deriveTypeIdPrefix, Qa as derivedRowId, $a as derivedRowIdLength, un as describeDriverError, zc as describeImportRun, dn as describeRowBindings, Bt as deserializeArraysOnRead, Qe as drainIdentifierWarnings, f as dropped, Gt as encodeFieldValue, nr as encodeRowForSchema, Zt as encryptFieldsForWrite, Xt as encryptedColumnsOf, Ga as endLocalWrite, gs as enforceBranchLimits, xe as ensureTableRegistered, Ki as eq, Or as escapeLike, ba as evaluatePredicate, ge as except, ga as exists, Uo as expires, Ca as externalChangeEvent, rn as extractDbCause, Ne as fireSchemaChangeSeeds, Ye as fireTenantCreateSeeds, Ws as formatIndexAuditIssue, Jn as formatSubjectGraph, ec as frameworkTables, Pe as generateId, dt as generateSnowflake, ee as geography, b as geometry, he as getEnumRenames, In as getRelation, Fn as getRelations, Os as getResidencyConfig, p as getTable, Ji as gt, Yi as gte, hr as hasEagerLoads, Qo as hybridSearch, x as id, Qi as inSet, ma as inSubquery, En as inferForeignKey, pc as insertRow, O as integer, rc as interruptedReplaceRefusal, l as intersect, i as interval, is as isBranchNamespace, xn as isEmptyRelationsSpec, Wt as isEncrypted, Ut as isFieldDecryptionError, ke as isFileMigration, cn as isForeignKeyViolation, $e as isFrameworkOwnedLiveTable, Ko as isLocalFirst, qs as isMigrationDefinition, Te as isMysqlFamily, us as isNeonConnection, sa as isNotNull, oa as isNull, yc as isPrimaryKeyConflictError, ln as isQueryTimeout, Jt as isRawEncoding, js as isRegionServable, Sn as isRelationsSpec, ut as isSeedDefinition, fe as isSqliteFamily, ne as isTableReactive, Ze as isView, S as json, fa as jsonField, lt as jsonIndex, s as lag, ce as lead, Oc as listRetentionConflicts, Ac as listRetentions, Go as localFirst, qo as localFirstTables, Xi as lt, Zi as lte, jo as makeEagerFallbackReporter, Cs as makeNamespaceBranchExecutor, wn as many, Tn as manyToMany, g as materializeFields, qe as max, et as migration, t as min, fc as missingConflictColumns, dc as missingRequiredColumns, Ae as mixin, qi as neq, ss as nextBranchState, Sc as normaliseTarget, da as not, _a as notExists, $i as notInSet, ha as notInSubquery, ye as numeric, Do as observeDbOp, Cn as one, ir as oneCardinalityMessage, ua as or, T as orderClausesOf, ie as paginateBy, oe as paginateById, Ja as pendingAttributionCount, ms as planBranch, cs as planBranchProvision, ls as planBranchTeardown, hs as planBranchTeardownFor, fs as planNeonBranchProvision, ps as planNeonBranchTeardown, zo as planVersionedUpdate, o as pluginRef, ht as pluginRefSpecOf, vc as primaryKeyConflictError, _s as provisionBranch, Ps as provisionResidentTenant, Sr as qualifyTable, ue as queryFor, He as queryForView, e as quoteIdent, _c as raiseChangeListenerCeiling, d as rank, Se as raw, m as readableByColumns, y as real, Eo as recordDbOp, so as recordsTable, it as reference, Vi as registerCoreTables, Pn as registerDiscoveredRelations, La as registerPendingAttribution, Nn as registerRelations, kc as registerRetention, rt as registerTable, eo as registerWriteRecorder, bn as relations, Ui as requireActors, v as requireTable, Wi as requireTenants, xo as resetDbMetricTagCacheForTests, Ie as resetSnowflake, Ms as residentPlacement, It as resolveActorSnapshot, ds as resolveBranchMechanism, Ao as resolveEagerFallbackWarnIntervalMs, Ka as resolveEchoAttribution, _ as resolveFullTextIndex, Xe as resolveIdScheme, tt as resolveMixinGraph, As as resolveTenantHome, xr as resolveTenantNamespace, Nc as retentionTtlMsFromEnv, re as rowNumber, mn as rowSchema, Fo as runRetryingTransaction, Io as runStoreTransaction, ka as runWithWriteAttribution, co as runWriteRecorders, wc as sameDatabase, br as sanitizeIdentifierFragment, zt as serializeArraysForWrite, te as serverOnlyColumns, Ds as setResidencyConfig, Fe as setSchemaChangeSeedHook, Re as setTenantCreateSeedHook, Mo as settleTransactionExit, Bo as settleVersionedUpdate, ca as spatialPredicate, ac as stampGeneratedId, oc as stampGeneratedIds, ta as startsWith, Zo as streamTable, pe as sum, bt as sumOver, io as suspendWriteRecorders, ao as suspendWriteRecordersEffect, Mc as sweepRetention, E as table, vs as teardownBranch, w as text, C as timestamp, xt as timestampMs, St as timestampMsOrNull, r as union, be as unionAll, we as unregisterTable, to as unregisterWriteRecorder, hc as updateManyRow, mc as upsertRow, Ue as validateColumnName, Ve as validateIndexName, Rn as validateRegisteredRelations, An as validateRelationConfig, Oe as validateTableName, pt as validateTypeIdPrefix, Ee as vector, at as vectorDistanceToOpclass, es as vectorEmbedding, Ro as versionColumnOf, Be as view, De as viewSql, Sa as walkLeaves, Ma as withCapturedAttribution, oo as writeRecordersSuspended };