@voltro/database 0.55.0 → 0.56.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,8 +1,8 @@
1
1
  import { $ as e, $t as t, A as n, At as r, B as i, Bt as a, C as o, Ct as s, D as c, Dt as l, E as u, Et as d, F as f, Ft as p, G as m, Gt as h, H as g, Ht as _, I as ee, It as te, J as ne, Jt as v, K as y, Kt as re, L as b, Lt as ie, M as ae, Mt as oe, N as x, Nt as se, O as ce, Ot as le, P as ue, Pt as de, Q as fe, Qt as pe, R as me, Rt as he, S as ge, St as _e, T as ve, Tt as ye, U as be, Ut as S, V as xe, Vt as Se, W as Ce, Wt as we, X as Te, Xt as Ee, Y as De, Yt as Oe, Z as ke, Zt as Ae, _ as je, _t as Me, a as Ne, at as Pe, b as Fe, bt as Ie, c as Le, ct as Re, d as ze, dt as Be, en as C, et as Ve, f as He, ft as Ue, g as We, gt as Ge, h as w, ht as Ke, it as T, j as qe, jt as Je, k as Ye, kt as Xe, l as Ze, lt as Qe, m as $e, mt as et, n as tt, nt, o as rt, ot as it, p as at, pt as ot, q as E, qt as st, r as ct, rt as lt, s as ut, st as dt, t as ft, tn as pt, tt as mt, u as ht, ut as gt, v as _t, vt, w as yt, wt as bt, x as xt, xt as St, y as Ct, yt as wt, z as Tt, zt as Et } from "./frameworkLiveTables-CwDemhjW.js";
2
2
  import { timestampMs as Dt, timestampMsOrNull as Ot } from "./wire.js";
3
3
  import { Cause as kt, Chunk as At, Data as jt, Effect as D, Exit as Mt, Metric as O, MetricBoundaries as Nt, Option as k, Runtime as Pt, Schedule as Ft, Schema as A, Stream as It } from "effect";
4
- import { AsyncLocalStorage as Lt } from "node:async_hooks";
5
- import { createHash as Rt } from "node:crypto";
4
+ import { createHash as Lt } from "node:crypto";
5
+ import { AsyncLocalStorage as Rt } from "node:async_hooks";
6
6
  import { TransactionConnection as zt } from "@effect/sql/SqlClient";
7
7
  import { ansi as j } from "@voltro/logger";
8
8
  import { SqlClient as Bt } from "@effect/sql";
@@ -1206,7 +1206,7 @@ var Vt = (e) => typeof e == "string" && e !== "" ? e : null, Ht = async (e, t, n
1206
1206
  }, fi = (e, t, n) => {
1207
1207
  let r = n.sql, i = e.relation, a = i.through(), o = n.nextAlias(), s = n.nextAlias(), c = ci(o, e.children, n, e.junction);
1208
1208
  if (c === null) return null;
1209
- let l = e.branch.where === void 0 ? r`` : r` AND ${I(e.branch.where, r)}`, u = U(e, s, r), d = L(o, e.branch.orderBy, r), f = e.branch.limit === void 0 ? r`` : r` LIMIT ${V(e.branch.limit, r)}`, p = e.branch.offset === void 0 ? r`` : r` OFFSET ${V(e.branch.offset, r)}`, m = e.junction === void 0 ? r`` : r`, ${pi(e.junction, s, r)} AS ${r(Qr)}`;
1209
+ let l = e.branch.where === void 0 ? r`` : r` AND ${I(e.branch.where, r)}`, u = Bi(e, s, r), d = L(o, e.branch.orderBy, r), f = e.branch.limit === void 0 ? r`` : r` LIMIT ${V(e.branch.limit, r)}`, p = e.branch.offset === void 0 ? r`` : r` OFFSET ${V(e.branch.offset, r)}`, m = e.junction === void 0 ? r`` : r`, ${pi(e.junction, s, r)} AS ${r(Qr)}`;
1210
1210
  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 ${z(o, "id", r)} = ${z(s, i.targetKey, r)} WHERE ${z(s, i.sourceKey, r)} = ${z(t, "id", r)}${u}${l}${d}${f}${p}) AS ${r(o)}), '[]'::jsonb)`;
1211
1211
  }, pi = (e, t, n) => e.present.length === 0 ? n`jsonb_build_object()` : n`jsonb_build_object(${n.csv(e.present.map((e) => n`${B(e, n)}, ${z(t, e, n)}`))})`, L = (e, t, n) => t === void 0 || t.length === 0 ? n`` : n` ORDER BY ${n.csv(t.map((t) => t.direction === "desc" ? n`${z(e, t.column, n)} DESC` : n`${z(e, t.column, n)} ASC`))}`, mi = (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`))}`, hi = (e, t, n) => {
1212
1212
  let r = n.sql, i = n.nextAlias(), a = gi(i, t.table, t.children, n);
@@ -1246,7 +1246,7 @@ var Vt = (e) => typeof e == "string" && e !== "" ? e : null, Ht = async (e, t, n
1246
1246
  }, Ci = (e, t, n) => {
1247
1247
  let r = n.sql, i = n.nextAlias(), a = gi(i, e.target, e.children, n);
1248
1248
  if (a === null) return null;
1249
- let o = r`${z(void 0, e.foreignKey, r)} = ${z(t, e.sourceKey, r)}`, s = e.branch.where === void 0 ? r`` : r` AND ${I(W(e.branch.where), r)}`, c = mi(e.branch.orderBy, r), l = e.branch.limit === void 0 ? r`` : r` LIMIT ${V(e.branch.limit, r)}`, u = e.branch.offset === void 0 ? r`` : r` OFFSET ${V(e.branch.offset, r)}`;
1249
+ let o = r`${z(void 0, e.foreignKey, r)} = ${z(t, e.sourceKey, r)}`, s = e.branch.where === void 0 ? r`` : r` AND ${I(U(e.branch.where), r)}`, c = mi(e.branch.orderBy, r), l = e.branch.limit === void 0 ? r`` : r` LIMIT ${V(e.branch.limit, r)}`, u = e.branch.offset === void 0 ? r`` : r` OFFSET ${V(e.branch.offset, r)}`;
1250
1250
  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('[]'))`;
1251
1251
  }, wi = (e, t, n) => {
1252
1252
  let r = n.sql, i = e.relation, a = i.through(), o = n.nextAlias(), s = n.nextAlias(), c = gi(o, e.target, e.children, n, e.junction === void 0 ? void 0 : {
@@ -1254,7 +1254,7 @@ var Vt = (e) => typeof e == "string" && e !== "" ? e : null, Ht = async (e, t, n
1254
1254
  source: yi(o)
1255
1255
  });
1256
1256
  if (c === null) return null;
1257
- let l = e.branch.where === void 0 ? r`` : r` AND ${I(W(e.branch.where), r)}`, u = U(e, s, r, !0), d = L(o, e.branch.orderBy, r), f = e.branch.limit === void 0 ? r`` : r` LIMIT ${V(e.branch.limit, r)}`, p = e.branch.offset === void 0 ? r`` : r` OFFSET ${V(e.branch.offset, r)}`, m = e.junction === void 0 ? r`` : vi(e.junction, s, r);
1257
+ let l = e.branch.where === void 0 ? r`` : r` AND ${I(U(e.branch.where), r)}`, u = Bi(e, s, r, !0), d = L(o, e.branch.orderBy, r), f = e.branch.limit === void 0 ? r`` : r` LIMIT ${V(e.branch.limit, r)}`, p = e.branch.offset === void 0 ? r`` : r` OFFSET ${V(e.branch.offset, r)}`, m = e.junction === void 0 ? r`` : vi(e.junction, s, r);
1258
1258
  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 ${z(o, "id", r)} = ${z(s, i.targetKey, r)} WHERE ${z(s, i.sourceKey, r)} = ${z(t, "id", r)}${u}${l}${d}${f}${p}) AS ${r(o)}), json('[]'))`;
1259
1259
  }, Ti = (e, t, n) => {
1260
1260
  let r = n.sql, i = n.nextAlias(), a = R(i, t.table, t.children, n);
@@ -1293,7 +1293,7 @@ var Vt = (e) => typeof e == "string" && e !== "" ? e : null, Ht = async (e, t, n
1293
1293
  }, Oi = (e, t, n) => {
1294
1294
  let r = n.sql, i = n.nextAlias(), a = R(i, e.target, e.children, n);
1295
1295
  if (a === null) return null;
1296
- let o = r`${z(void 0, e.foreignKey, r)} = ${z(t, e.sourceKey, r)}`, s = e.branch.where === void 0 ? r`` : r` AND ${I(W(e.branch.where), r)}`, c = mi(e.branch.orderBy, r), l = e.branch.limit === void 0 ? r`` : r` LIMIT ${V(e.branch.limit, r)}`, u = e.branch.offset === void 0 ? r`` : r` OFFSET ${V(e.branch.offset, r)}`;
1296
+ let o = r`${z(void 0, e.foreignKey, r)} = ${z(t, e.sourceKey, r)}`, s = e.branch.where === void 0 ? r`` : r` AND ${I(U(e.branch.where), r)}`, c = mi(e.branch.orderBy, r), l = e.branch.limit === void 0 ? r`` : r` LIMIT ${V(e.branch.limit, r)}`, u = e.branch.offset === void 0 ? r`` : r` OFFSET ${V(e.branch.offset, r)}`;
1297
1297
  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())`;
1298
1298
  }, ki = (e, t, n) => {
1299
1299
  let r = n.sql, i = e.relation, a = i.through(), o = n.nextAlias(), s = n.nextAlias(), c = R(o, e.target, e.children, n, e.junction === void 0 ? void 0 : {
@@ -1301,12 +1301,12 @@ var Vt = (e) => typeof e == "string" && e !== "" ? e : null, Ht = async (e, t, n
1301
1301
  source: yi(o)
1302
1302
  });
1303
1303
  if (c === null) return null;
1304
- let l = e.branch.where === void 0 ? r`` : r` AND ${I(W(e.branch.where), r)}`, u = U(e, s, r, !0), d = L(o, e.branch.orderBy, r), f = e.branch.limit === void 0 ? r`` : r` LIMIT ${V(e.branch.limit, r)}`, p = e.branch.offset === void 0 ? r`` : r` OFFSET ${V(e.branch.offset, r)}`, m = e.junction === void 0 ? r`` : vi(e.junction, s, r);
1304
+ let l = e.branch.where === void 0 ? r`` : r` AND ${I(U(e.branch.where), r)}`, u = Bi(e, s, r, !0), d = L(o, e.branch.orderBy, r), f = e.branch.limit === void 0 ? r`` : r` LIMIT ${V(e.branch.limit, r)}`, p = e.branch.offset === void 0 ? r`` : r` OFFSET ${V(e.branch.offset, r)}`, m = e.junction === void 0 ? r`` : vi(e.junction, s, r);
1305
1305
  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 ${z(o, "id", r)} = ${z(s, i.targetKey, r)} WHERE ${z(s, i.sourceKey, r)} = ${z(t, "id", r)}${u}${l}${d}${f}${p}) AS ${r(o)}), JSON_ARRAY())`;
1306
1306
  }, Ai = (e, t, n) => {
1307
1307
  let r = n.sql, i = n.nextAlias(), a = R(i, e.target, e.children, n);
1308
1308
  if (a === null) return null;
1309
- let o = r`${z(i, e.foreignKey, r)} = ${z(t, e.sourceKey, r)}`, s = e.branch.where === void 0 ? r`` : r` AND ${I(W(e.branch.where), r)}`, c = e.branch.orderBy ?? [];
1309
+ let o = r`${z(i, e.foreignKey, r)} = ${z(t, e.sourceKey, r)}`, s = e.branch.where === void 0 ? r`` : r` AND ${I(U(e.branch.where), r)}`, c = e.branch.orderBy ?? [];
1310
1310
  if (e.branch.limit === void 0 && e.branch.offset === void 0) return r`COALESCE((SELECT JSON_ARRAYAGG(${a}${c.length > 0 ? r` ORDER BY ${r.csv(c.map((e) => e.direction === "desc" ? r`${z(i, e.column, r)} DESC` : r`${z(i, e.column, r)} ASC`))}` : r``}) FROM ${r(e.target.tableName)} AS ${r(i)} WHERE ${o}${s}), JSON_ARRAY())`;
1311
1311
  let l = c.length > 0 ? r` ORDER BY ${r.csv(c.map((e) => e.direction === "desc" ? r`${r(e.column)} DESC` : r`${r(e.column)} ASC`))}` : r` ORDER BY ${r("id")}`, u = e.branch.limit, d = e.branch.offset, f = u !== void 0 && d !== void 0 ? r` AND ${z(i, "rn", r)} > ${V(d, r)} AND ${z(i, "rn", r)} <= ${V(d + u, r)}` : u === void 0 ? r` AND ${z(i, "rn", r)} > ${V(d, r)}` : r` AND ${z(i, "rn", r)} <= ${V(u, r)}`;
1312
1312
  return r`COALESCE((SELECT JSON_ARRAYAGG(${a} ORDER BY ${z(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())`;
@@ -1314,12 +1314,12 @@ var Vt = (e) => typeof e == "string" && e !== "" ? e : null, Ht = async (e, t, n
1314
1314
  let r = n.sql, i = e.relation, a = i.through(), o = n.nextAlias(), s = n.nextAlias(), c = (t) => e.junction === void 0 ? void 0 : {
1315
1315
  projection: e.junction,
1316
1316
  source: t
1317
- }, l = r`${z(s, i.sourceKey, r)} = ${z(t, "id", r)}`, u = r`${z(o, "id", r)} = ${z(s, i.targetKey, r)}`, d = e.branch.where === void 0 ? r`` : r` AND ${I(W(e.branch.where), r)}`, f = U(e, s, r, !0), p = e.branch.orderBy ?? [];
1317
+ }, l = r`${z(s, i.sourceKey, r)} = ${z(t, "id", r)}`, u = r`${z(o, "id", r)} = ${z(s, i.targetKey, r)}`, d = e.branch.where === void 0 ? r`` : r` AND ${I(U(e.branch.where), r)}`, f = Bi(e, s, r, !0), p = e.branch.orderBy ?? [];
1318
1318
  if (e.branch.limit === void 0 && e.branch.offset === void 0) {
1319
1319
  let t = R(o, e.target, e.children, n, c(bi(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`${z(o, e.column, r)} DESC` : r`${z(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`${z(o, e.column, r)} DESC` : r`${z(o, e.column, r)} ASC`))}` : r` ORDER BY ${z(o, "id", r)}`, h = e.branch.limit, g = e.branch.offset, _ = h !== void 0 && g !== void 0 ? r` AND ${z(o, "rn", r)} > ${V(g, r)} AND ${z(o, "rn", r)} <= ${V(g + h, r)}` : h === void 0 ? r` AND ${z(o, "rn", r)} > ${V(g, r)}` : r` AND ${z(o, "rn", r)} <= ${V(h, r)}`, ee = e.branch.onJunction === void 0 ? r`` : r` WHERE ${H(W(e.branch.onJunction), s, r)}`, te = R(o, e.target, e.children, n, c(yi(o)));
1322
+ let m = p.length > 0 ? r` ORDER BY ${r.csv(p.map((e) => e.direction === "desc" ? r`${z(o, e.column, r)} DESC` : r`${z(o, e.column, r)} ASC`))}` : r` ORDER BY ${z(o, "id", r)}`, h = e.branch.limit, g = e.branch.offset, _ = h !== void 0 && g !== void 0 ? r` AND ${z(o, "rn", r)} > ${V(g, r)} AND ${z(o, "rn", r)} <= ${V(g + h, r)}` : h === void 0 ? r` AND ${z(o, "rn", r)} > ${V(g, r)}` : r` AND ${z(o, "rn", r)} <= ${V(h, r)}`, ee = e.branch.onJunction === void 0 ? r`` : r` WHERE ${H(U(e.branch.onJunction), s, r)}`, te = R(o, e.target, e.children, n, c(yi(o)));
1323
1323
  if (te === null) return null;
1324
1324
  let ne = e.junction === void 0 ? r`` : vi(e.junction, s, r);
1325
1325
  return r`COALESCE((SELECT JSON_ARRAYAGG(${te} ORDER BY ${z(o, "rn", r)}) FROM (SELECT ${r(o)}.*${ne}, ${z(s, i.sourceKey, r)} AS ${r(`__src_${i.sourceKey}`)}, ROW_NUMBER() OVER (PARTITION BY ${z(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 ${z(o, `__src_${i.sourceKey}`, r)} = ${z(t, "id", r)}${d}${_}), JSON_ARRAY())`;
@@ -1379,18 +1379,18 @@ var Vt = (e) => typeof e == "string" && e !== "" ? e : null, Ht = async (e, t, n
1379
1379
  source: bi(s)
1380
1380
  });
1381
1381
  if (c === null) return null;
1382
- let l = e.branch.where === void 0 ? r`` : r` AND ${H(e.branch.where, o, r)}`, u = U(e, s, r), d = L(o, e.branch.orderBy, r), { top: f, pagination: p, finalOrder: m } = Li(e.branch, d, r);
1382
+ let l = e.branch.where === void 0 ? r`` : r` AND ${H(e.branch.where, o, r)}`, u = Bi(e, s, r), d = L(o, e.branch.orderBy, r), { top: f, pagination: p, finalOrder: m } = Li(e.branch, d, r);
1383
1383
  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 ${z(o, "id", r)} = ${z(s, i.targetKey, r)} WHERE ${z(s, i.sourceKey, r)} = ${z(t, "id", r)}${u}${l}${m}${p} FOR JSON PATH, INCLUDE_NULL_VALUES)), JSON_QUERY('[]')) AS ${r(e.relationName)}`;
1384
1384
  }, z = (e, t, n) => e === void 0 ? n`${n(t)}` : n`${n(e)}.${n(t)}`, B = (e, t) => t.unsafe(`'${e.replace(/'/g, "''")}'`), V = (e, t) => {
1385
1385
  if (!Number.isFinite(e) || !Number.isInteger(e) || e < 0) throw Error(`literalInt: expected non-negative integer, got ${e}`);
1386
1386
  return t.unsafe(String(e));
1387
- }, H = (e, t, n) => I(Bi(e, t), n), U = (e, t, n, r = !1) => {
1387
+ }, H = (e, t, n) => I(Vi(e, t), n), Bi = (e, t, n, r = !1) => {
1388
1388
  let i = e.branch.onJunction;
1389
- return i === void 0 ? n`` : n` AND ${H(r ? W(i) : i, t, n)}`;
1390
- }, Bi = (e, t) => {
1391
- if ("not" in e) return { not: Bi(e.not, t) };
1392
- if ("and" in e) return { and: e.and.map((e) => Bi(e, t)) };
1393
- if ("or" in e) return { or: e.or.map((e) => Bi(e, t)) };
1389
+ return i === void 0 ? n`` : n` AND ${H(r ? U(i) : i, t, n)}`;
1390
+ }, Vi = (e, t) => {
1391
+ if ("not" in e) return { not: Vi(e.not, t) };
1392
+ if ("and" in e) return { and: e.and.map((e) => Vi(e, t)) };
1393
+ if ("or" in e) return { or: e.or.map((e) => Vi(e, t)) };
1394
1394
  if (e.op === "subquery-in" || e.op === "subquery-not-in") {
1395
1395
  let n = e;
1396
1396
  return {
@@ -1404,23 +1404,23 @@ var Vt = (e) => typeof e == "string" && e !== "" ? e : null, Ht = async (e, t, n
1404
1404
  ...n,
1405
1405
  column: `${t}.${n.column}`
1406
1406
  };
1407
- }, W = (e) => {
1408
- if ("not" in e) return { not: W(e.not) };
1409
- if ("and" in e) return { and: e.and.map((e) => W(e)) };
1410
- if ("or" in e) return { or: e.or.map((e) => W(e)) };
1407
+ }, U = (e) => {
1408
+ if ("not" in e) return { not: U(e.not) };
1409
+ if ("and" in e) return { and: e.and.map((e) => U(e)) };
1410
+ if ("or" in e) return { or: e.or.map((e) => U(e)) };
1411
1411
  if (e.op === "subquery-in" || e.op === "subquery-not-in" || e.op === "exists" || e.op === "not-exists") return e;
1412
1412
  let t = e;
1413
1413
  return {
1414
1414
  ...t,
1415
- value: Vi(t.value)
1415
+ value: Hi(t.value)
1416
1416
  };
1417
- }, Vi = (e) => e == null ? e : e instanceof Date ? e.toISOString() : typeof e == "boolean" ? +!!e : Array.isArray(e) ? e.map((e) => Vi(e)) : e, Hi = Symbol.for("@voltro/database/coreTablesRegistry"), Ui = globalThis, Wi = Ui[Hi] ?? (Ui[Hi] = {}), Gi = (e) => {
1418
- e.actors !== void 0 && (Wi.actors = e.actors), e.tenants !== void 0 && (Wi.tenants = e.tenants);
1419
- }, Ki = (e, t) => () => {
1417
+ }, Hi = (e) => e == null ? e : e instanceof Date ? e.toISOString() : typeof e == "boolean" ? +!!e : Array.isArray(e) ? e.map((e) => Hi(e)) : e, Ui = Symbol.for("@voltro/database/coreTablesRegistry"), Wi = globalThis, Gi = Wi[Ui] ?? (Wi[Ui] = {}), Ki = (e) => {
1418
+ e.actors !== void 0 && (Gi.actors = e.actors), e.tenants !== void 0 && (Gi.tenants = e.tenants);
1419
+ }, qi = (e, t) => () => {
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
- }, qi = () => Ki(() => Wi.actors, "actors"), Ji = () => Ki(() => Wi.tenants, "tenants"), Yi = T("actors", {
1423
+ }, Ji = () => qi(() => Gi.actors, "actors"), Yi = () => qi(() => Gi.tenants, "tenants"), Xi = T("actors", {
1424
1424
  id: _(),
1425
1425
  kind: t().oneOf([
1426
1426
  "user",
@@ -1430,73 +1430,73 @@ var Vt = (e) => typeof e == "string" && e !== "" ? e : null, Ht = async (e, t, n
1430
1430
  ]),
1431
1431
  displayName: t().nullable(),
1432
1432
  createdAt: C().default("now")
1433
- }), Xi = (e, t) => ({
1433
+ }), Zi = (e, t) => ({
1434
1434
  column: e,
1435
1435
  op: "eq",
1436
1436
  value: t
1437
- }), Zi = (e, t) => ({
1437
+ }), Qi = (e, t) => ({
1438
1438
  column: e,
1439
1439
  op: "neq",
1440
1440
  value: t
1441
- }), Qi = (e, t) => ({
1441
+ }), $i = (e, t) => ({
1442
1442
  column: e,
1443
1443
  op: "gt",
1444
1444
  value: t
1445
- }), $i = (e, t) => ({
1445
+ }), ea = (e, t) => ({
1446
1446
  column: e,
1447
1447
  op: "gte",
1448
1448
  value: t
1449
- }), ea = (e, t) => ({
1449
+ }), ta = (e, t) => ({
1450
1450
  column: e,
1451
1451
  op: "lt",
1452
1452
  value: t
1453
- }), ta = (e, t) => ({
1453
+ }), na = (e, t) => ({
1454
1454
  column: e,
1455
1455
  op: "lte",
1456
1456
  value: t
1457
- }), na = (e, t) => ({
1457
+ }), ra = (e, t) => ({
1458
1458
  column: e,
1459
1459
  op: "in",
1460
1460
  value: t
1461
- }), ra = (e, t) => ({
1461
+ }), ia = (e, t) => ({
1462
1462
  column: e,
1463
1463
  op: "notIn",
1464
1464
  value: t
1465
- }), ia = (e, t) => ({
1465
+ }), aa = (e, t) => ({
1466
1466
  column: e,
1467
1467
  op: "contains",
1468
1468
  value: t
1469
- }), aa = (e, t) => ({
1469
+ }), oa = (e, t) => ({
1470
1470
  column: e,
1471
1471
  op: "startsWith",
1472
1472
  value: t
1473
- }), oa = (e, t) => ({
1473
+ }), sa = (e, t) => ({
1474
1474
  column: e,
1475
1475
  op: "arrayContains",
1476
1476
  value: t
1477
- }), sa = (e, t) => ({
1477
+ }), ca = (e, t) => ({
1478
1478
  column: e,
1479
1479
  op: "arrayOverlaps",
1480
1480
  value: t
1481
- }), ca = (e, t) => ({
1481
+ }), la = (e, t) => ({
1482
1482
  column: e,
1483
1483
  op: "arrayHas",
1484
1484
  value: t
1485
- }), la = {
1485
+ }), ua = {
1486
1486
  column: "id",
1487
1487
  op: "in",
1488
1488
  value: []
1489
- }, ua = (e) => ({
1489
+ }, da = (e) => ({
1490
1490
  column: e,
1491
1491
  op: "isNull"
1492
- }), da = (e) => ({
1492
+ }), fa = (e) => ({
1493
1493
  column: e,
1494
1494
  op: "isNotNull"
1495
- }), fa = (e, t) => ({
1495
+ }), pa = (e, t) => ({
1496
1496
  column: e,
1497
1497
  op: "spatial",
1498
1498
  value: t
1499
- }), pa = (...e) => ({ and: e }), ma = (...e) => ({ or: e }), ha = (e) => ({ not: e }), ga = (e, ...t) => {
1499
+ }), ma = (...e) => ({ and: e }), ha = (...e) => ({ or: e }), ga = (e) => ({ not: e }), _a = (e, ...t) => {
1500
1500
  if (t.length === 0) throw Error(`jsonField("${e}"): at least one path segment is required`);
1501
1501
  let n = (n, r) => ({
1502
1502
  column: e,
@@ -1518,33 +1518,33 @@ var Vt = (e) => typeof e == "string" && e !== "" ? e : null, Ht = async (e, t, n
1518
1518
  isNull: () => n("isNull"),
1519
1519
  isNotNull: () => n("isNotNull")
1520
1520
  };
1521
- }, _a = (e) => "descriptor" in e ? e.descriptor : e, va = (e, t) => ({
1521
+ }, va = (e) => "descriptor" in e ? e.descriptor : e, ya = (e, t) => ({
1522
1522
  column: e,
1523
1523
  op: "subquery-in",
1524
- subquery: _a(t)
1525
- }), ya = (e, t) => ({
1524
+ subquery: va(t)
1525
+ }), ba = (e, t) => ({
1526
1526
  column: e,
1527
1527
  op: "subquery-not-in",
1528
- subquery: _a(t)
1529
- }), ba = (e) => ({
1530
- op: "exists",
1531
- subquery: _a(e)
1528
+ subquery: va(t)
1532
1529
  }), xa = (e) => ({
1530
+ op: "exists",
1531
+ subquery: va(e)
1532
+ }), Sa = (e) => ({
1533
1533
  op: "not-exists",
1534
- subquery: _a(e)
1535
- }), Sa = (e, t) => e === t || e instanceof Date && t instanceof Date && e.getTime() === t.getTime(), Ca = (e, t) => {
1534
+ subquery: va(e)
1535
+ }), Ca = (e, t) => e === t || e instanceof Date && t instanceof Date && e.getTime() === t.getTime(), wa = (e, t) => {
1536
1536
  if (e == null || t == null) return null;
1537
1537
  let n = e instanceof Date ? e.getTime() : e, r = t instanceof Date ? t.getTime() : t;
1538
1538
  return typeof n == typeof r ? n === r ? 0 : n > r ? 1 : -1 : null;
1539
- }, wa = (e, t, n = null) => {
1539
+ }, Ta = (e, t, n = null) => {
1540
1540
  if (!t) return !1;
1541
- if ("not" in e) return !wa(e.not, t, n);
1541
+ if ("not" in e) return !Ta(e.not, t, n);
1542
1542
  if ("and" in e) {
1543
- for (let r of e.and) if (!wa(r, t, n)) return !1;
1543
+ for (let r of e.and) if (!Ta(r, t, n)) return !1;
1544
1544
  return !0;
1545
1545
  }
1546
1546
  if ("or" in e) {
1547
- for (let r of e.or) if (wa(r, t, n)) return !0;
1547
+ for (let r of e.or) if (Ta(r, t, n)) return !0;
1548
1548
  return !1;
1549
1549
  }
1550
1550
  if (e.op === "subquery-in" || e.op === "subquery-not-in") {
@@ -1561,14 +1561,14 @@ var Vt = (e) => typeof e == "string" && e !== "" ? e : null, Ht = async (e, t, n
1561
1561
  }
1562
1562
  let r = e, i = t[r.column];
1563
1563
  switch (r.op) {
1564
- case "eq": return Sa(i, r.value);
1565
- case "neq": return !Sa(i, r.value);
1566
- case "gt": return (Ca(i, r.value) ?? -1) > 0;
1567
- case "gte": return (Ca(i, r.value) ?? -1) >= 0;
1568
- case "lt": return (Ca(i, r.value) ?? 1) < 0;
1569
- case "lte": return (Ca(i, r.value) ?? 1) <= 0;
1570
- case "in": return Array.isArray(r.value) && r.value.some((e) => Sa(i, e));
1571
- case "notIn": return Array.isArray(r.value) && !r.value.some((e) => Sa(i, e));
1564
+ case "eq": return Ca(i, r.value);
1565
+ case "neq": return !Ca(i, r.value);
1566
+ case "gt": return (wa(i, r.value) ?? -1) > 0;
1567
+ case "gte": return (wa(i, r.value) ?? -1) >= 0;
1568
+ case "lt": return (wa(i, r.value) ?? 1) < 0;
1569
+ case "lte": return (wa(i, r.value) ?? 1) <= 0;
1570
+ case "in": return Array.isArray(r.value) && r.value.some((e) => Ca(i, e));
1571
+ case "notIn": return Array.isArray(r.value) && !r.value.some((e) => Ca(i, e));
1572
1572
  case "contains": return typeof i == "string" && typeof r.value == "string" && i.toLowerCase().includes(r.value.toLowerCase());
1573
1573
  case "startsWith": return typeof i == "string" && typeof r.value == "string" && i.startsWith(r.value);
1574
1574
  case "arrayContains": {
@@ -1584,17 +1584,17 @@ var Vt = (e) => typeof e == "string" && e !== "" ? e : null, Ht = async (e, t, n
1584
1584
  case "isNotNull": return i != null;
1585
1585
  case "spatial": throw Error("@voltro/plugin-postgis: spatial predicates (ST_DWithin / ST_Contains / ST_Within / ST_Intersects / bbox &&) are not evaluable in-memory — use them in one-shot ctx.store.query reads, not reactive subscriptions.");
1586
1586
  }
1587
- }, Ta = function* (e) {
1587
+ }, Ea = function* (e) {
1588
1588
  if ("not" in e) {
1589
- yield* Ta(e.not);
1589
+ yield* Ea(e.not);
1590
1590
  return;
1591
1591
  }
1592
1592
  if ("and" in e) {
1593
- for (let t of e.and) yield* Ta(t);
1593
+ for (let t of e.and) yield* Ea(t);
1594
1594
  return;
1595
1595
  }
1596
1596
  if ("or" in e) {
1597
- for (let t of e.or) yield* Ta(t);
1597
+ for (let t of e.or) yield* Ea(t);
1598
1598
  return;
1599
1599
  }
1600
1600
  e.op === "subquery-in" || e.op === "subquery-not-in" ? yield {
@@ -1604,46 +1604,46 @@ var Vt = (e) => typeof e == "string" && e !== "" ? e : null, Ht = async (e, t, n
1604
1604
  kind: "exists",
1605
1605
  descriptor: e.subquery
1606
1606
  });
1607
- }, Ea = function* (e, t = !0) {
1607
+ }, Da = function* (e, t = !0) {
1608
1608
  if ("not" in e) {
1609
- yield* Ea(e.not, !1);
1609
+ yield* Da(e.not, !1);
1610
1610
  return;
1611
1611
  }
1612
1612
  if ("and" in e) {
1613
- for (let n of e.and) yield* Ea(n, t);
1613
+ for (let n of e.and) yield* Da(n, t);
1614
1614
  return;
1615
1615
  }
1616
1616
  if ("or" in e) {
1617
- for (let t of e.or) yield* Ea(t, !1);
1617
+ for (let t of e.or) yield* Da(t, !1);
1618
1618
  return;
1619
1619
  }
1620
1620
  e.op !== "subquery-in" && e.op !== "subquery-not-in" && e.op !== "exists" && e.op !== "not-exists" && (yield {
1621
1621
  ...e,
1622
1622
  conjunctive: t
1623
1623
  });
1624
- }, Da = (e, t) => ({
1624
+ }, Oa = (e, t) => ({
1625
1625
  ...t,
1626
1626
  ...e,
1627
1627
  origin: e.origin ?? "injected"
1628
- }), Oa = (e, t, n = {}) => ({
1628
+ }), ka = (e, t, n = {}) => ({
1629
1629
  table: e,
1630
1630
  op: "insert",
1631
1631
  old: null,
1632
1632
  new: t,
1633
1633
  ...n
1634
- }), ka = (e, t, n, r = {}) => ({
1634
+ }), Aa = (e, t, n, r = {}) => ({
1635
1635
  table: e,
1636
1636
  op: "update",
1637
1637
  old: t,
1638
1638
  new: n,
1639
1639
  ...r
1640
- }), Aa = (e, t, n = {}) => ({
1640
+ }), ja = (e, t, n = {}) => ({
1641
1641
  table: e,
1642
1642
  op: "delete",
1643
1643
  old: t,
1644
1644
  new: null,
1645
1645
  ...n
1646
- }), ja = (e, t, n = {}) => {
1646
+ }), Ma = (e, t, n = {}) => {
1647
1647
  let { at: r = "2026-01-01T00:00:00.000Z", column: i = "deletedAt", ...a } = n;
1648
1648
  return {
1649
1649
  table: e,
@@ -1658,67 +1658,127 @@ var Vt = (e) => typeof e == "string" && e !== "" ? e : null, Ht = async (e, t, n
1658
1658
  },
1659
1659
  ...a
1660
1660
  };
1661
- }, Ma = new Lt(), Na = (e, t) => Ma.run(e, t), Pa = () => Ma.getStore(), Fa = (e) => {
1662
- let t = e ?? Ma.getStore();
1661
+ }, Na = (e) => e == null ? "null" : e instanceof Date ? JSON.stringify(e.toISOString()) : typeof e == "bigint" ? JSON.stringify(e.toString()) : Array.isArray(e) ? `[${e.map(Na).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)}:${Na(t)}`).join(",")}}` : JSON.stringify(e) ?? "null", Pa = (e) => Lt("sha256").update([
1662
+ e.pipe,
1663
+ e.op,
1664
+ e.key,
1665
+ Na(e.next),
1666
+ Na(e.prev)
1667
+ ].join("\0")).digest("hex").slice(0, 32), Fa = (e, t) => `${e}:${t}`, Ia = (e) => {
1668
+ let t = e.lastIndexOf(":");
1669
+ if (t <= 0) return null;
1670
+ let n = Number(e.slice(t + 1));
1671
+ return !Number.isInteger(n) || n < 0 ? null : {
1672
+ digest: e.slice(0, t),
1673
+ occurrence: n
1674
+ };
1675
+ }, La = class {
1676
+ #e = /* @__PURE__ */ new Map();
1677
+ #t;
1678
+ #n;
1679
+ constructor(e) {
1680
+ this.#t = e.windowMs, this.#n = Math.max(1, e.maxEntries);
1681
+ }
1682
+ get size() {
1683
+ return this.#e.size;
1684
+ }
1685
+ next(e, t) {
1686
+ let n = this.#e.get(e);
1687
+ if (n === void 0) return this.#e.set(e, {
1688
+ count: 1,
1689
+ lastMs: t
1690
+ }), this.#r(), 0;
1691
+ n.lastMs = t;
1692
+ let r = n.count;
1693
+ return n.count += 1, this.#e.delete(e), this.#e.set(e, n), r;
1694
+ }
1695
+ seedFromChangeKeys(e, t) {
1696
+ for (let n of e) {
1697
+ let e = Ia(n);
1698
+ if (e === null) continue;
1699
+ let r = this.#e.get(e.digest), i = Math.max(r?.count ?? 0, e.occurrence + 1);
1700
+ this.#e.set(e.digest, {
1701
+ count: i,
1702
+ lastMs: r?.lastMs ?? t
1703
+ });
1704
+ }
1705
+ this.#r();
1706
+ }
1707
+ prune(e) {
1708
+ let t = e - this.#t;
1709
+ for (let [e, n] of this.#e) n.lastMs < t && this.#e.delete(e);
1710
+ }
1711
+ #r() {
1712
+ for (; this.#e.size > this.#n;) {
1713
+ let e = this.#e.keys().next();
1714
+ if (e.done === !0) return;
1715
+ this.#e.delete(e.value);
1716
+ }
1717
+ }
1718
+ }, Ra = "VOLTRO_CHANGE_CLAIMS_TTL_HOURS", za = 1, Ba = (e = process.env) => {
1719
+ let t = Number(e[Ra]);
1720
+ return (Number.isFinite(t) && t > 0 ? t : 1) * 2 * 36e5;
1721
+ }, Va = new Rt(), Ha = (e, t) => Va.run(e, t), Ua = () => Va.getStore(), Wa = (e) => {
1722
+ let t = e ?? Va.getStore();
1663
1723
  return t === void 0 ? {} : {
1664
1724
  ...t.traceId === void 0 ? {} : { traceId: t.traceId },
1665
1725
  ...t.subjectId === void 0 ? {} : { subjectId: t.subjectId },
1666
1726
  ...t.procedure === void 0 ? {} : { procedure: t.procedure },
1667
1727
  ...t.via === void 0 ? {} : { via: t.via }
1668
1728
  };
1669
- }, Ia = (e) => {
1670
- let t = Ma.getStore();
1671
- return t === void 0 ? e(void 0) : Ma.run(t, () => e(t));
1672
- }, La = 3e4, Ra = 1e4, G = /* @__PURE__ */ new Map(), K = 0, za = (e, t, n) => `${e}\u0000${t}\u0000${String(n)}`, Ba = (e) => {
1673
- for (let [t, n] of G) {
1674
- let r = n.filter((t) => e - t.at < La);
1675
- K -= n.length - r.length, r.length === 0 ? G.delete(t) : r.length !== n.length && G.set(t, r);
1676
- }
1677
- }, Va = (e, t) => {
1729
+ }, Ga = (e) => {
1730
+ let t = Va.getStore();
1731
+ return t === void 0 ? e(void 0) : Va.run(t, () => e(t));
1732
+ }, Ka = 3e4, qa = 1e4, W = /* @__PURE__ */ new Map(), G = 0, Ja = (e, t, n) => `${e}\u0000${t}\u0000${String(n)}`, Ya = (e) => {
1733
+ for (let [t, n] of W) {
1734
+ let r = n.filter((t) => e - t.at < Ka);
1735
+ G -= n.length - r.length, r.length === 0 ? W.delete(t) : r.length !== n.length && W.set(t, r);
1736
+ }
1737
+ }, Xa = (e, t) => {
1678
1738
  if (t.traceId === void 0 && t.subjectId === void 0 && t.procedure === void 0) return;
1679
1739
  let n = Date.now();
1680
- if (K >= Ra && Ba(n), K >= Ra) return;
1681
- let r = G.get(e);
1682
- r === void 0 ? G.set(e, [{
1740
+ if (G >= qa && Ya(n), G >= qa) return;
1741
+ let r = W.get(e);
1742
+ r === void 0 ? W.set(e, [{
1683
1743
  attribution: t,
1684
1744
  at: n
1685
1745
  }]) : r.push({
1686
1746
  attribution: t,
1687
1747
  at: n
1688
- }), K += 1;
1689
- }, Ha = (e) => {
1690
- let t = G.get(e);
1748
+ }), G += 1;
1749
+ }, Za = (e) => {
1750
+ let t = W.get(e);
1691
1751
  if (t === void 0 || t.length === 0) return;
1692
1752
  let n = t.shift();
1693
- if (--K, t.length === 0 && G.delete(e), !(Date.now() - n.at >= La)) return n.attribution;
1694
- }, Ua = (e) => (G.get(e)?.length ?? 0) > 0, q = /* @__PURE__ */ new Map(), Wa = /* @__PURE__ */ new Map(), Ga = /* @__PURE__ */ new Map(), Ka = 250, qa = (e) => {
1695
- let t = Wa.get(e);
1753
+ if (--G, t.length === 0 && W.delete(e), !(Date.now() - n.at >= Ka)) return n.attribution;
1754
+ }, Qa = (e) => (W.get(e)?.length ?? 0) > 0, K = /* @__PURE__ */ new Map(), $a = /* @__PURE__ */ new Map(), eo = /* @__PURE__ */ new Map(), to = 250, no = (e) => {
1755
+ let t = $a.get(e);
1696
1756
  if (t === void 0) return;
1697
- Wa.delete(e);
1698
- let n = Ga.get(e);
1699
- n !== void 0 && (clearTimeout(n), Ga.delete(e));
1757
+ $a.delete(e);
1758
+ let n = eo.get(e);
1759
+ n !== void 0 && (clearTimeout(n), eo.delete(e));
1700
1760
  for (let e of t) e();
1701
- }, Ja = (e) => {
1702
- q.set(e, (q.get(e) ?? 0) + 1);
1703
- }, Ya = (e) => {
1704
- let t = (q.get(e) ?? 0) - 1;
1761
+ }, ro = (e) => {
1762
+ K.set(e, (K.get(e) ?? 0) + 1);
1763
+ }, io = (e) => {
1764
+ let t = (K.get(e) ?? 0) - 1;
1705
1765
  if (t > 0) {
1706
- q.set(e, t);
1766
+ K.set(e, t);
1707
1767
  return;
1708
1768
  }
1709
- q.delete(e), qa(e);
1710
- }, Xa = (e, t, n, r) => {
1711
- let i = n == null ? void 0 : za(e, t, n), a = () => r(i === void 0 ? void 0 : Ha(i));
1769
+ K.delete(e), no(e);
1770
+ }, ao = (e, t, n, r) => {
1771
+ let i = n == null ? void 0 : Ja(e, t, n), a = () => r(i === void 0 ? void 0 : Za(i));
1712
1772
  if (i === void 0) {
1713
1773
  a();
1714
1774
  return;
1715
1775
  }
1716
- if (Ua(i)) {
1776
+ if (Qa(i)) {
1717
1777
  a();
1718
1778
  return;
1719
1779
  }
1720
- let o = Wa.get(e);
1721
- if (o === void 0 && (q.get(e) ?? 0) === 0) {
1780
+ let o = $a.get(e);
1781
+ if (o === void 0 && (K.get(e) ?? 0) === 0) {
1722
1782
  a();
1723
1783
  return;
1724
1784
  }
@@ -1726,91 +1786,91 @@ var Vt = (e) => typeof e == "string" && e !== "" ? e : null, Ht = async (e, t, n
1726
1786
  o.push(a);
1727
1787
  return;
1728
1788
  }
1729
- Wa.set(e, [a]);
1730
- let s = setTimeout(() => qa(e), Ka);
1731
- typeof s == "object" && typeof s.unref == "function" && s.unref(), Ga.set(e, s);
1732
- }, Za = () => {
1733
- G.clear(), K = 0, q.clear();
1734
- for (let e of Ga.values()) clearTimeout(e);
1735
- Ga.clear(), Wa.clear();
1736
- }, Qa = () => K, $a = 64, eo = "\0", to = 32, no = (e, ...t) => `${e}_${Rt("sha256").update(t.map(String).join(eo)).digest("hex").slice(0, to)}`, ro = (e) => e.length + 1 + to, J = /* @__PURE__ */ new Map(), io = (e, t) => {
1737
- J.set(e, {
1789
+ $a.set(e, [a]);
1790
+ let s = setTimeout(() => no(e), to);
1791
+ typeof s == "object" && typeof s.unref == "function" && s.unref(), eo.set(e, s);
1792
+ }, oo = () => {
1793
+ W.clear(), G = 0, K.clear();
1794
+ for (let e of eo.values()) clearTimeout(e);
1795
+ eo.clear(), $a.clear();
1796
+ }, so = () => G, co = 64, lo = "\0", uo = 32, fo = (e, ...t) => `${e}_${Lt("sha256").update(t.map(String).join(lo)).digest("hex").slice(0, uo)}`, po = (e) => e.length + 1 + uo, q = /* @__PURE__ */ new Map(), mo = (e, t) => {
1797
+ q.set(e, {
1738
1798
  recorder: t.recorder,
1739
1799
  tables: new Set(t.tables),
1740
1800
  ownTables: new Set(t.ownTables)
1741
1801
  });
1742
- }, ao = (e) => {
1743
- J.delete(e);
1744
- }, oo = () => J.clear(), so = new Lt(), co = (e) => so.run({ n: 1 }, e), lo = (e) => D.suspend(() => {
1745
- let t = so.getStore();
1802
+ }, ho = (e) => {
1803
+ q.delete(e);
1804
+ }, go = () => q.clear(), _o = new Rt(), vo = (e) => _o.run({ n: 1 }, e), yo = (e) => D.suspend(() => {
1805
+ let t = _o.getStore();
1746
1806
  if (t !== void 0) return t.n += 1, D.ensuring(e, D.sync(() => {
1747
1807
  --t.n;
1748
1808
  }));
1749
1809
  let n = { n: 1 };
1750
- return so.enterWith(n), D.ensuring(e, D.sync(() => {
1810
+ return _o.enterWith(n), D.ensuring(e, D.sync(() => {
1751
1811
  --n.n;
1752
1812
  }));
1753
- }), uo = () => (so.getStore()?.n ?? 0) > 0, fo = (e) => {
1754
- if (J.size === 0 || (so.getStore()?.n ?? 0) > 0) return !1;
1755
- for (let t of J.values()) if (!t.ownTables.has(e) && t.tables.has(e)) return !0;
1813
+ }), bo = () => (_o.getStore()?.n ?? 0) > 0, xo = (e) => {
1814
+ if (q.size === 0 || (_o.getStore()?.n ?? 0) > 0) return !1;
1815
+ for (let t of q.values()) if (!t.ownTables.has(e) && t.tables.has(e)) return !0;
1756
1816
  return !1;
1757
- }, po = async (e, t) => {
1758
- if (J.size !== 0) {
1759
- for (let [n, r] of J.entries()) if (!r.ownTables.has(t.table) && r.tables.has(t.table)) try {
1817
+ }, So = async (e, t) => {
1818
+ if (q.size !== 0) {
1819
+ for (let [n, r] of q.entries()) if (!r.ownTables.has(t.table) && r.tables.has(t.table)) try {
1760
1820
  await r.recorder(e, t);
1761
1821
  } catch (e) {
1762
1822
  let r = gn(e);
1763
1823
  throw r === void 0 ? e : Error(`write recorder '${n}' failed while recording a ${t.op} on '${t.table}': ${r}`, { cause: e });
1764
1824
  }
1765
1825
  }
1766
- }, mo = Nt.exponential({
1826
+ }, Co = Nt.exponential({
1767
1827
  start: 5e-4,
1768
1828
  factor: 2,
1769
1829
  count: 16
1770
- }), ho = O.counter("voltro_db_queries_total", { description: "Database operations executed, by dialect and operation kind." }), go = O.histogram("voltro_db_query_duration_seconds", mo, "Database operation duration in seconds, by dialect and operation kind."), _o = O.counter("voltro_db_errors_total", { description: "Database operations that threw, by dialect and operation kind." }), vo = O.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." }), yo = O.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." }), bo = [], xo = /* @__PURE__ */ new Map(), So = /* @__PURE__ */ new Map(), Co = /* @__PURE__ */ new Map(), wo = (e, t) => {
1771
- let n = `${e}\u0000${t}`, r = xo.get(n);
1830
+ }), wo = O.counter("voltro_db_queries_total", { description: "Database operations executed, by dialect and operation kind." }), To = O.histogram("voltro_db_query_duration_seconds", Co, "Database operation duration in seconds, by dialect and operation kind."), Eo = O.counter("voltro_db_errors_total", { description: "Database operations that threw, by dialect and operation kind." }), Do = O.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." }), Oo = O.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." }), ko = [], Ao = /* @__PURE__ */ new Map(), jo = /* @__PURE__ */ new Map(), Mo = /* @__PURE__ */ new Map(), No = (e, t) => {
1831
+ let n = `${e}\u0000${t}`, r = Ao.get(n);
1772
1832
  if (r !== void 0) return r;
1773
1833
  let i = (n) => O.tagged(O.tagged(n, "dialect", e), "op", t), a = {
1774
- count: i(ho),
1775
- duration: i(go),
1776
- errors: i(_o)
1834
+ count: i(wo),
1835
+ duration: i(To),
1836
+ errors: i(Eo)
1777
1837
  };
1778
- return xo.set(n, a), a;
1779
- }, To = () => {
1780
- xo.clear(), So.clear(), Co.clear();
1781
- }, Eo = () => xo.size + So.size + Co.size, Do = /* @__PURE__ */ new Map(), Oo = (e, t) => {
1782
- let n = Math.max(0, (Do.get(e) ?? 0) + t);
1783
- n === 0 ? Do.delete(e) : Do.set(e, n);
1784
- let r = So.get(e);
1785
- r === void 0 && (r = O.tagged(vo, "dialect", e), So.set(e, r)), r.unsafeUpdate(n, bo);
1786
- }, ko = (e) => Do.get(e) ?? 0, Ao = (e) => {
1787
- let t = wo(String(e.dialect), e.op);
1788
- t.count.unsafeUpdate(1, bo), t.duration.unsafeUpdate(e.durationMs / 1e3, bo), e.status === "error" && t.errors.unsafeUpdate(1, bo);
1789
- }, jo = async (e, t, n) => {
1838
+ return Ao.set(n, a), a;
1839
+ }, Po = () => {
1840
+ Ao.clear(), jo.clear(), Mo.clear();
1841
+ }, Fo = () => Ao.size + jo.size + Mo.size, Io = /* @__PURE__ */ new Map(), Lo = (e, t) => {
1842
+ let n = Math.max(0, (Io.get(e) ?? 0) + t);
1843
+ n === 0 ? Io.delete(e) : Io.set(e, n);
1844
+ let r = jo.get(e);
1845
+ r === void 0 && (r = O.tagged(Do, "dialect", e), jo.set(e, r)), r.unsafeUpdate(n, ko);
1846
+ }, Ro = (e) => Io.get(e) ?? 0, zo = (e) => {
1847
+ let t = No(String(e.dialect), e.op);
1848
+ t.count.unsafeUpdate(1, ko), t.duration.unsafeUpdate(e.durationMs / 1e3, ko), e.status === "error" && t.errors.unsafeUpdate(1, ko);
1849
+ }, Bo = async (e, t, n) => {
1790
1850
  let r = performance.now(), i = String(e);
1791
- Oo(i, 1);
1851
+ Lo(i, 1);
1792
1852
  let a = "ok";
1793
1853
  try {
1794
1854
  return await n();
1795
1855
  } catch (e) {
1796
1856
  throw a = "error", e;
1797
1857
  } finally {
1798
- Oo(i, -1), Ao({
1858
+ Lo(i, -1), zo({
1799
1859
  dialect: e,
1800
1860
  op: t,
1801
1861
  durationMs: performance.now() - r,
1802
1862
  status: a
1803
1863
  });
1804
1864
  }
1805
- }, Mo = 3e5, No = (e) => {
1865
+ }, Vo = 3e5, Ho = (e) => {
1806
1866
  if (e == null || e === "") return;
1807
1867
  let t = Number(e);
1808
1868
  return Number.isFinite(t) && t >= 0 ? Math.floor(t) : void 0;
1809
- }, Po = (e, t = process.env) => No(t.VOLTRO_DB_EAGER_FALLBACK_WARN_INTERVAL_MS) ?? No(e) ?? 3e5, Fo = (e, t = {}) => {
1810
- let n = Po(t.warnIntervalMs), r = t.now ?? (() => Date.now()), i = /* @__PURE__ */ new Map();
1869
+ }, Uo = (e, t = process.env) => Ho(t.VOLTRO_DB_EAGER_FALLBACK_WARN_INTERVAL_MS) ?? Ho(e) ?? 3e5, Wo = (e, t = {}) => {
1870
+ let n = Uo(t.warnIntervalMs), r = t.now ?? (() => Date.now()), i = /* @__PURE__ */ new Map();
1811
1871
  return (t) => {
1812
- let a = `${t.dialect} ${t.reason}`, o = Co.get(a);
1813
- o === void 0 && (o = O.tagged(O.tagged(yo, "dialect", String(t.dialect)), "reason", t.reason), Co.set(a, o)), o.unsafeUpdate(1, bo);
1872
+ let a = `${t.dialect} ${t.reason}`, o = Mo.get(a);
1873
+ o === void 0 && (o = O.tagged(O.tagged(Oo, "dialect", String(t.dialect)), "reason", t.reason), Mo.set(a, o)), o.unsafeUpdate(1, ko);
1814
1874
  let s = `${t.table}\u0000${t.reason}`, c = i.get(s), l = c === void 0 || n > 0 && r() - c >= n, u = {
1815
1875
  table: t.table,
1816
1876
  dialect: String(t.dialect),
@@ -1824,10 +1884,10 @@ var Vt = (e) => typeof e == "string" && e !== "" ? e : null, Ht = async (e, t, n
1824
1884
  }
1825
1885
  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);
1826
1886
  };
1827
- }, Io = (e) => {
1887
+ }, Go = (e) => {
1828
1888
  if (Mt.isSuccess(e)) return e.value;
1829
1889
  throw kt.squash(e.cause);
1830
- }, Lo = "10 millis", Ro = 3, zo = async (e) => {
1890
+ }, Ko = "10 millis", qo = 3, Jo = async (e) => {
1831
1891
  let t = 0, n = D.suspend(() => {
1832
1892
  let n = ++t;
1833
1893
  return e.withTransaction(D.flatMap(D.serviceOption(zt), (t) => {
@@ -1838,10 +1898,10 @@ var Vt = (e) => typeof e == "string" && e !== "" ? e : null, Ht = async (e, t, n
1838
1898
  });
1839
1899
  return e.prepare === void 0 ? i : D.flatMap(e.prepare(r), () => i);
1840
1900
  })).pipe(D.catchAllDefect((t) => e.isRetryable(t) ? D.fail(t) : D.die(t)));
1841
- }), r = Ft.exponential(Lo).pipe(Ft.compose(Ft.recurs(Ro)), Ft.whileInput(e.isRetryable)), i = n.pipe(D.retry(r), D.withSpan(e.span.name, { attributes: { ...e.span.attributes } }));
1842
- return jo(e.dialect, "transaction", async () => Io(await e.runPromiseExit(e.wrapProgram === void 0 ? i : e.wrapProgram(i))));
1843
- }, Bo = async (e) => {
1844
- let t = Pa(), n = t === void 0 ? (e) => e() : (e) => Na(t, e), r = await zo({
1901
+ }), r = Ft.exponential(Ko).pipe(Ft.compose(Ft.recurs(qo)), Ft.whileInput(e.isRetryable)), i = n.pipe(D.retry(r), D.withSpan(e.span.name, { attributes: { ...e.span.attributes } }));
1902
+ return Bo(e.dialect, "transaction", async () => Go(await e.runPromiseExit(e.wrapProgram === void 0 ? i : e.wrapProgram(i))));
1903
+ }, Yo = async (e) => {
1904
+ let t = Ua(), n = t === void 0 ? (e) => e() : (e) => Ha(t, e), r = await Jo({
1845
1905
  ...e,
1846
1906
  body: (r) => {
1847
1907
  let i = e.makeView(r, t);
@@ -1852,14 +1912,14 @@ var Vt = (e) => typeof e == "string" && e !== "" ? e : null, Ht = async (e, t, n
1852
1912
  }
1853
1913
  });
1854
1914
  return r.view.commitEvents(), r.result;
1855
- }, Vo = class extends A.TaggedError()("VersionConflict", {
1915
+ }, Xo = class extends A.TaggedError()("VersionConflict", {
1856
1916
  table: A.String,
1857
1917
  id: A.String,
1858
1918
  expected: A.Number,
1859
1919
  actual: A.NullOr(A.Number)
1860
- }) {}, Ho = (e) => {
1920
+ }) {}, Zo = (e) => {
1861
1921
  for (let [t, n] of Object.entries(e)) if (n?.definition?.versionColumn === !0) return t;
1862
- }, Uo = (e) => {
1922
+ }, Qo = (e) => {
1863
1923
  let { versionColumn: t, patch: n } = e;
1864
1924
  if (t === void 0) return {
1865
1925
  nextVersion: void 0,
@@ -1872,28 +1932,28 @@ var Vt = (e) => typeof e == "string" && e !== "" ? e : null, Ht = async (e, t, n
1872
1932
  expected: i,
1873
1933
  patch: a
1874
1934
  };
1875
- }, Wo = (e) => {
1876
- if (e.expected !== void 0 && (e.current === null || e.current !== e.expected)) return new Vo({
1935
+ }, $o = (e) => {
1936
+ if (e.expected !== void 0 && (e.current === null || e.current !== e.expected)) return new Xo({
1877
1937
  table: e.table,
1878
1938
  id: e.id,
1879
1939
  expected: e.expected,
1880
1940
  actual: e.current
1881
1941
  });
1882
- }, Go = 1, Ko = "voltro/expires", qo = () => it({
1883
- id: Ko,
1942
+ }, es = 1, ts = "voltro/expires", ns = () => it({
1943
+ id: ts,
1884
1944
  fields: { expiresAt: C().nullable() },
1885
1945
  behaviors: { defaultWhere: () => "expiresAt IS NULL OR expiresAt > now()" }
1886
- }), Jo = "voltro/localFirst", Yo = () => it({
1887
- id: Jo,
1946
+ }), rs = "voltro/localFirst", is = () => it({
1947
+ id: rs,
1888
1948
  fields: {}
1889
- }), Xo = (e) => e.appliedMixins.some((e) => e.id === Jo), Zo = (e) => {
1949
+ }), as = (e) => e.appliedMixins.some((e) => e.id === rs), os = (e) => {
1890
1950
  let t = [];
1891
- for (let n of Object.values(e)) Xo(n) && t.push(n.tableName);
1951
+ for (let n of Object.values(e)) as(n) && t.push(n.tableName);
1892
1952
  return t;
1893
- }, Qo = class extends jt.TaggedError("TableStreamError") {}, $o = 1e3, es = (e, t, n, r) => {
1953
+ }, ss = class extends jt.TaggedError("TableStreamError") {}, cs = 1e3, ls = (e, t, n, r) => {
1894
1954
  let i = k.match(r, {
1895
1955
  onNone: () => e.where,
1896
- onSome: (n) => e.where ? pa(e.where, Qi(t, n)) : Qi(t, n)
1956
+ onSome: (n) => e.where ? ma(e.where, $i(t, n)) : $i(t, n)
1897
1957
  });
1898
1958
  return {
1899
1959
  table: e.table,
@@ -1908,19 +1968,19 @@ var Vt = (e) => typeof e == "string" && e !== "" ? e : null, Ht = async (e, t, n
1908
1968
  ...e.includeDeleted === void 0 ? {} : { includeDeleted: e.includeDeleted },
1909
1969
  ...e.crossTenant === void 0 ? {} : { crossTenant: e.crossTenant }
1910
1970
  };
1911
- }, ts = (e, t) => {
1912
- let n = t.pk ?? "id", r = t.chunkSize ?? $o;
1971
+ }, us = (e, t) => {
1972
+ let n = t.pk ?? "id", r = t.chunkSize ?? cs;
1913
1973
  return It.paginateChunkEffect(k.none(), (i) => {
1914
1974
  let a = D.tryPromise({
1915
- try: () => e.query(es(t, n, r, i)),
1916
- catch: (e) => new Qo({
1975
+ try: () => e.query(ls(t, n, r, i)),
1976
+ catch: (e) => new ss({
1917
1977
  table: t.table,
1918
1978
  cause: e
1919
1979
  })
1920
1980
  });
1921
1981
  return (t.retry ? a.pipe(D.retry(t.retry)) : a).pipe(D.map((e) => [At.fromIterable(e), e.length === r && e.length > 0 ? k.some(k.some(e[e.length - 1][n])) : k.none()]));
1922
1982
  });
1923
- }, ns = (e) => {
1983
+ }, ds = (e) => {
1924
1984
  let t = e.alpha ?? .5;
1925
1985
  if (t < 0 || t > 1) throw Error(`hybridSearch: alpha must be in [0, 1], got ${t}`);
1926
1986
  return (n) => {
@@ -1947,14 +2007,14 @@ var Vt = (e) => typeof e == "string" && e !== "" ? e : null, Ht = async (e, t, n
1947
2007
  }
1948
2008
  };
1949
2009
  };
1950
- }, rs = async (e, t) => {
2010
+ }, fs = async (e, t) => {
1951
2011
  let n = e.as ?? "embedding", r = t.row[e.from];
1952
2012
  if (typeof r != "string" || r.length === 0) return {};
1953
2013
  let i = await t.embed(r);
1954
2014
  return { [n]: i };
1955
- }, is = (e) => {
2015
+ }, ps = (e) => {
1956
2016
  if (!Number.isInteger(e.dimensions) || e.dimensions <= 0) throw Error(`vectorEmbedding: dimensions must be a positive integer, got ${String(e.dimensions)}.`);
1957
- let t = e.as ?? "embedding", n = (t) => rs(e, t);
2017
+ let t = e.as ?? "embedding", n = (t) => fs(e, t);
1958
2018
  return it({
1959
2019
  id: "voltro/vectorEmbedding",
1960
2020
  fields: { [t]: pt(e.dimensions) },
@@ -1972,19 +2032,19 @@ var Vt = (e) => typeof e == "string" && e !== "" ? e : null, Ht = async (e, t, n
1972
2032
  beforeUpdate: n
1973
2033
  }
1974
2034
  });
1975
- }, as = 63, os = "br_pr", Y = class extends Error {
2035
+ }, ms = 63, hs = "br_pr", J = class extends Error {
1976
2036
  _tag = "BranchNameInvalid";
1977
2037
  constructor(e) {
1978
2038
  super(e), this.name = "BranchNameInvalid";
1979
2039
  }
1980
- }, ss = (e, t) => {
1981
- if (!Number.isInteger(t) || t < 0) throw new Y(`prNumber must be a non-negative integer, got ${String(t)}`);
2040
+ }, gs = (e, t) => {
2041
+ if (!Number.isInteger(t) || t < 0) throw new J(`prNumber must be a non-negative integer, got ${String(t)}`);
1982
2042
  let n = Tr(e);
1983
- if (n.replace(/_/g, "") === "") throw new Y(`app slug '${e}' has no usable identifier characters`);
1984
- let r = `${os}${t}_${n}`;
1985
- if (r.length > as) throw new Y(`branch namespace '${r}' exceeds the ${as}-byte identifier limit — use a shorter app slug`);
2043
+ if (n.replace(/_/g, "") === "") throw new J(`app slug '${e}' has no usable identifier characters`);
2044
+ let r = `${hs}${t}_${n}`;
2045
+ if (r.length > ms) throw new J(`branch namespace '${r}' exceeds the ${ms}-byte identifier limit — use a shorter app slug`);
1986
2046
  return r;
1987
- }, cs = (e) => e.startsWith(os), ls = {
2047
+ }, _s = (e) => e.startsWith(hs), vs = {
1988
2048
  requested: {
1989
2049
  provision: "provisioning",
1990
2050
  destroy: "destroying"
@@ -2003,19 +2063,19 @@ var Vt = (e) => typeof e == "string" && e !== "" ? e : null, Ht = async (e, t, n
2003
2063
  fail: "failed"
2004
2064
  },
2005
2065
  destroyed: {}
2006
- }, us = class extends Error {
2066
+ }, ys = class extends Error {
2007
2067
  from;
2008
2068
  event;
2009
2069
  _tag = "BranchTransitionInvalid";
2010
2070
  constructor(e, t) {
2011
2071
  super(`invalid branch transition: ${e} --${t}-->`), this.from = e, this.event = t, this.name = "BranchTransitionInvalid";
2012
2072
  }
2013
- }, ds = (e, t) => {
2014
- let n = ls[e][t];
2015
- if (n === void 0) throw new us(e, t);
2073
+ }, bs = (e, t) => {
2074
+ let n = vs[e][t];
2075
+ if (n === void 0) throw new ys(e, t);
2016
2076
  return n;
2017
- }, fs = (e, t, n, r, i = [], a = []) => {
2018
- if (n === "copy" && (r === void 0 || r === "")) throw new Y("seed 'copy' requires a parentNamespace to snapshot from");
2077
+ }, xs = (e, t, n, r, i = [], a = []) => {
2078
+ if (n === "copy" && (r === void 0 || r === "")) throw new J("seed 'copy' requires a parentNamespace to snapshot from");
2019
2079
  let o = [{
2020
2080
  kind: "create-namespace",
2021
2081
  detail: e
@@ -2044,13 +2104,13 @@ var Vt = (e) => typeof e == "string" && e !== "" ? e : null, Ht = async (e, t, n
2044
2104
  kind: "seed",
2045
2105
  detail: `run boot seeds into ${e}`
2046
2106
  }), o;
2047
- }, ps = (e) => {
2048
- if (!cs(e)) throw new Y(`refusing to plan teardown of '${e}' — not a branch namespace`);
2107
+ }, Ss = (e) => {
2108
+ if (!_s(e)) throw new J(`refusing to plan teardown of '${e}' — not a branch namespace`);
2049
2109
  return [{
2050
2110
  kind: "drop-namespace",
2051
2111
  detail: e
2052
2112
  }];
2053
- }, ms = (e) => {
2113
+ }, Cs = (e) => {
2054
2114
  if (e === void 0 || e === "") return !1;
2055
2115
  try {
2056
2116
  let t = new URL(e).hostname.toLowerCase();
@@ -2058,27 +2118,27 @@ var Vt = (e) => typeof e == "string" && e !== "" ? e : null, Ht = async (e, t, n
2058
2118
  } catch {
2059
2119
  return /\bneon\.(tech|build)\b/i.test(e);
2060
2120
  }
2061
- }, hs = (e) => e.prefer === void 0 ? e.seed === "copy" && ms(e.dbUrl) ? "neon-cow" : "namespace" : e.prefer, gs = (e, t = {}) => [{
2121
+ }, ws = (e) => e.prefer === void 0 ? e.seed === "copy" && Cs(e.dbUrl) ? "neon-cow" : "namespace" : e.prefer, Ts = (e, t = {}) => [{
2062
2122
  kind: "neon-branch-create",
2063
2123
  detail: `${t.parentBranch ?? "main"} → ${e} (copy-on-write)`
2064
- }], _s = (e) => {
2065
- if (!cs(e)) throw new Y(`refusing to plan teardown of '${e}' — not a branch namespace`);
2124
+ }], Es = (e) => {
2125
+ if (!_s(e)) throw new J(`refusing to plan teardown of '${e}' — not a branch namespace`);
2066
2126
  return [{
2067
2127
  kind: "neon-branch-delete",
2068
2128
  detail: e
2069
2129
  }];
2070
- }, vs = (e) => e.mechanism === "neon-cow" ? gs(e.branchId, e.neonParentBranch === void 0 ? {} : { parentBranch: e.neonParentBranch }) : fs(e.branchId, e.tableNames, e.seed, e.parentNamespace, e.foreignKeys, e.indexNames), ys = (e, t) => e === "neon-cow" ? _s(t) : ps(t), bs = (e, t, n) => {
2130
+ }, Ds = (e) => e.mechanism === "neon-cow" ? Ts(e.branchId, e.neonParentBranch === void 0 ? {} : { parentBranch: e.neonParentBranch }) : xs(e.branchId, e.tableNames, e.seed, e.parentNamespace, e.foreignKeys, e.indexNames), Os = (e, t) => e === "neon-cow" ? Es(t) : Ss(t), ks = (e, t, n) => {
2071
2131
  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);
2072
2132
  return {
2073
2133
  evict: i,
2074
2134
  rejectNew: r.filter((e) => !a.has(e.namespace)).length >= t.maxBranches
2075
2135
  };
2076
- }, xs = async (e, t) => {
2077
- let n = ss(e.appSlug, e.prNumber), r = hs({
2136
+ }, As = async (e, t) => {
2137
+ let n = gs(e.appSlug, e.prNumber), r = ws({
2078
2138
  seed: e.seed,
2079
2139
  ...e.dbUrl === void 0 ? {} : { dbUrl: e.dbUrl },
2080
2140
  ...e.prefer === void 0 ? {} : { prefer: e.prefer }
2081
- }), i = vs({
2141
+ }), i = Ds({
2082
2142
  mechanism: r,
2083
2143
  branchId: n,
2084
2144
  tableNames: e.tableNames,
@@ -2107,16 +2167,16 @@ var Vt = (e) => typeof e == "string" && e !== "" ? e : null, Ht = async (e, t, n
2107
2167
  mechanism: r,
2108
2168
  steps: i
2109
2169
  };
2110
- }, Ss = async (e, t, n) => {
2111
- let r = ys(t, e);
2170
+ }, js = async (e, t, n) => {
2171
+ let r = Os(t, e);
2112
2172
  return t === "neon-cow" ? await n.neonBranchDelete(e) : await n.dropNamespace(e), r;
2113
- }, Cs = (e, t, n) => bs(e, t, n), X = (e) => `"${e.replace(/"/g, "\"\"")}"`, ws = {
2173
+ }, Ms = (e, t, n) => ks(e, t, n), Y = (e) => `"${e.replace(/"/g, "\"\"")}"`, Ns = {
2114
2174
  cascade: "CASCADE",
2115
2175
  restrict: "RESTRICT",
2116
2176
  setNull: "SET NULL",
2117
2177
  noAction: "NO ACTION"
2118
- }, Z = (e) => `'${e.replace(/'/g, "''")}'`, Ts = (e, t) => {
2119
- let n = t.columns.map(Z).join(", ");
2178
+ }, X = (e) => `'${e.replace(/'/g, "''")}'`, Ps = (e, t) => {
2179
+ let n = t.columns.map(X).join(", ");
2120
2180
  return `DO $voltro_branch$
2121
2181
  DECLARE derived name;
2122
2182
  BEGIN
@@ -2125,11 +2185,11 @@ BEGIN
2125
2185
  JOIN pg_class i ON i.oid = x.indexrelid
2126
2186
  JOIN pg_class c ON c.oid = x.indrelid
2127
2187
  JOIN pg_namespace nsp ON nsp.oid = c.relnamespace
2128
- WHERE nsp.nspname = ${Z(e)}
2129
- AND c.relname = ${Z(t.table)}
2188
+ WHERE nsp.nspname = ${X(e)}
2189
+ AND c.relname = ${X(t.table)}
2130
2190
  AND NOT x.indisprimary
2131
2191
  AND x.indisunique = ${t.unique ? "true" : "false"}
2132
- AND i.relname <> ${Z(t.name)}
2192
+ AND i.relname <> ${X(t.name)}
2133
2193
  AND (
2134
2194
  SELECT array_agg(att.attname::text ORDER BY k.ord)
2135
2195
  FROM unnest(x.indkey::int2[]) WITH ORDINALITY AS k(attnum, ord)
@@ -2138,39 +2198,39 @@ BEGIN
2138
2198
  LIMIT 1;
2139
2199
  IF derived IS NOT NULL THEN
2140
2200
  EXECUTE format('ALTER INDEX %I.%I RENAME TO %I',
2141
- ${Z(e)}, derived, ${Z(t.name)});
2201
+ ${X(e)}, derived, ${X(t.name)});
2142
2202
  END IF;
2143
2203
  END
2144
2204
  $voltro_branch$`;
2145
- }, Es = (e, t) => {
2146
- let n = t.onDelete === void 0 ? "" : ` ON DELETE ${ws[t.onDelete]}`, r = t.onUpdate === void 0 ? "" : ` ON UPDATE ${ws[t.onUpdate]}`;
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}`;
2148
- }, Ds = (e) => {
2205
+ }, Fs = (e, t) => {
2206
+ let n = t.onDelete === void 0 ? "" : ` ON DELETE ${Ns[t.onDelete]}`, r = t.onUpdate === void 0 ? "" : ` ON UPDATE ${Ns[t.onUpdate]}`;
2207
+ return `ALTER TABLE ${Y(e)}.${Y(t.table)} ADD FOREIGN KEY (${Y(t.column)}) REFERENCES ${Y(e)}.${Y(t.targetTable)} (${Y(t.targetColumn)})${n}${r}`;
2208
+ }, Is = (e) => {
2149
2209
  let t = () => {
2150
2210
  throw Error("namespace branch executor: Neon ops require a neon-cow executor (use a Neon connection for copy-on-write branches)");
2151
2211
  };
2152
2212
  return {
2153
- createNamespace: (t) => e.run(`CREATE SCHEMA IF NOT EXISTS ${X(t)}`),
2154
- createTable: (t, n) => e.run(`CREATE TABLE IF NOT EXISTS ${X(t)}.${X(n)} (LIKE ${X(n)} INCLUDING ALL)`),
2155
- copyTable: (t, n, r) => e.run(`INSERT INTO ${X(n)}.${X(r)} SELECT * FROM ${X(t)}.${X(r)}`),
2156
- addForeignKey: (t, n) => e.run(Es(t, n)),
2157
- restoreIndexName: (t, n) => e.run(Ts(t, n)),
2158
- dropNamespace: (t) => e.run(`DROP SCHEMA IF EXISTS ${X(t)} CASCADE`),
2213
+ createNamespace: (t) => e.run(`CREATE SCHEMA IF NOT EXISTS ${Y(t)}`),
2214
+ createTable: (t, n) => e.run(`CREATE TABLE IF NOT EXISTS ${Y(t)}.${Y(n)} (LIKE ${Y(n)} INCLUDING ALL)`),
2215
+ copyTable: (t, n, r) => e.run(`INSERT INTO ${Y(n)}.${Y(r)} SELECT * FROM ${Y(t)}.${Y(r)}`),
2216
+ addForeignKey: (t, n) => e.run(Fs(t, n)),
2217
+ restoreIndexName: (t, n) => e.run(Ps(t, n)),
2218
+ dropNamespace: (t) => e.run(`DROP SCHEMA IF EXISTS ${Y(t)} CASCADE`),
2159
2219
  neonBranchCreate: t,
2160
2220
  neonBranchDelete: t
2161
2221
  };
2162
- }, Os = class extends Error {
2222
+ }, Ls = class extends Error {
2163
2223
  _tag = "TenantResidencyUnresolved";
2164
2224
  constructor(e) {
2165
2225
  super(e), this.name = "TenantResidencyUnresolved";
2166
2226
  }
2167
- }, ks = class extends Error {
2227
+ }, Rs = class extends Error {
2168
2228
  region;
2169
2229
  _tag = "TenantRegionUnavailable";
2170
2230
  constructor(e, t) {
2171
2231
  super(t), this.region = e, this.name = "TenantRegionUnavailable";
2172
2232
  }
2173
- }, As, js = (e) => {
2233
+ }, zs, Bs = (e) => {
2174
2234
  if (e.homes === void 0) throw Error("setResidencyConfig: `homes` is required");
2175
2235
  if (e.servableRegions === void 0 || e.servableRegions.length === 0) throw Error("setResidencyConfig: `servableRegions` must be non-empty (which regions this deployment serves)");
2176
2236
  let t = /* @__PURE__ */ new Map();
@@ -2179,98 +2239,98 @@ $voltro_branch$`;
2179
2239
  if (e !== void 0 && e !== n.region) throw Error(`residency: tenant '${n.tenantId}' is mapped to two regions ('${e}' and '${n.region}')`);
2180
2240
  t.set(n.tenantId, n.region);
2181
2241
  }
2182
- return As = e, e;
2183
- }, Ms = () => As, Ns = () => {
2184
- As = void 0;
2185
- }, Ps = (e, t) => {
2186
- if (e == null || e === "") throw new Os("residency is on but the request has no resolvable tenant — refusing to bind a store");
2242
+ return zs = e, e;
2243
+ }, Vs = () => zs, Hs = () => {
2244
+ zs = void 0;
2245
+ }, Us = (e, t) => {
2246
+ if (e == null || e === "") throw new Ls("residency is on but the request has no resolvable tenant — refusing to bind a store");
2187
2247
  let n = t.homes.find((t) => t.tenantId === e);
2188
- if (n === void 0) throw new Os(`no residency home is mapped for tenant '${e}' — refusing to fall back to a default store (would be a residency violation)`);
2248
+ if (n === void 0) throw new Ls(`no residency home is mapped for tenant '${e}' — refusing to fall back to a default store (would be a residency violation)`);
2189
2249
  return n;
2190
- }, Fs = (e, t) => t.servableRegions.includes(e), Is = (e, t) => {
2191
- let n = Ps(e.tenantId, t), r = Er(n.tenantId);
2250
+ }, Ws = (e, t) => t.servableRegions.includes(e), Gs = (e, t) => {
2251
+ let n = Us(e.tenantId, t), r = Er(n.tenantId);
2192
2252
  return {
2193
2253
  region: n.region,
2194
2254
  namespace: r,
2195
2255
  ...n.connectionKey === void 0 ? {} : { connectionKey: n.connectionKey }
2196
2256
  };
2197
- }, Ls = (e, t, n) => {
2198
- let r = Is(e, t);
2199
- if (!Fs(r.region, t)) throw new ks(r.region, `tenant homed in region '${r.region}', which this deployment does not serve — route to the home region`);
2257
+ }, Ks = (e, t, n) => {
2258
+ let r = Gs(e, t);
2259
+ if (!Ws(r.region, t)) throw new Rs(r.region, `tenant homed in region '${r.region}', which this deployment does not serve — route to the home region`);
2200
2260
  let i = n.get(r.region);
2201
- if (i === void 0) throw new ks(r.region, `no store handle for home region '${r.region}' (declared servable but not wired) — failing closed`);
2261
+ if (i === void 0) throw new Rs(r.region, `no store handle for home region '${r.region}' (declared servable but not wired) — failing closed`);
2202
2262
  return {
2203
2263
  store: i,
2204
2264
  placement: r
2205
2265
  };
2206
- }, Rs = async (e, t, n, r) => {
2207
- let { store: i, placement: a } = Ls(e, t, n);
2266
+ }, qs = async (e, t, n, r) => {
2267
+ let { store: i, placement: a } = Ks(e, t, n);
2208
2268
  return await r(i, a), a;
2209
- }, zs = (e) => {
2269
+ }, Js = (e) => {
2210
2270
  if (typeof e == "string") return e;
2211
2271
  if ("jsonPath" in e) {
2212
2272
  let { column: t, path: n, numeric: r } = e.jsonPath;
2213
2273
  return `(json:${t}->${n.join(".")}${r ? "::num" : ""})`;
2214
2274
  }
2215
2275
  return `(${e.expr})`;
2216
- }, Q = (e) => e.map(zs), Bs = (e, t) => {
2276
+ }, Z = (e) => e.map(Js), Ys = (e, t) => {
2217
2277
  if (e.length !== t.length) return !1;
2218
- for (let n = 0; n < e.length; n++) if (zs(e[n]) !== zs(t[n])) return !1;
2278
+ for (let n = 0; n < e.length; n++) if (Js(e[n]) !== Js(t[n])) return !1;
2219
2279
  return !0;
2220
- }, Vs = (e, t) => {
2280
+ }, Xs = (e, t) => {
2221
2281
  if (e.length >= t.length) return !1;
2222
- for (let n = 0; n < e.length; n++) if (zs(e[n]) !== zs(t[n])) return !1;
2282
+ for (let n = 0; n < e.length; n++) if (Js(e[n]) !== Js(t[n])) return !1;
2223
2283
  return !0;
2224
- }, Hs = (e) => {
2284
+ }, Zs = (e) => {
2225
2285
  let t = [], n = e.appliedIndexes, r = e.tableName;
2226
2286
  for (let e = 0; e < n.length; e++) {
2227
2287
  let i = n[e];
2228
2288
  for (let a = e + 1; a < n.length; a++) {
2229
2289
  let e = n[a];
2230
- if (Bs(i.fields, e.fields)) {
2290
+ if (Ys(i.fields, e.fields)) {
2231
2291
  let [n, a] = i.name < e.name ? [i, e] : [e, i];
2232
2292
  t.push({
2233
2293
  kind: "duplicate-fields",
2234
2294
  table: r,
2235
2295
  redundant: n,
2236
2296
  coveredBy: a,
2237
- message: `'${r}' has two indexes on the same fields [${Q(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).`
2297
+ 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).`
2238
2298
  });
2239
2299
  continue;
2240
2300
  }
2241
- Vs(i.fields, e.fields) ? t.push({
2301
+ Xs(i.fields, e.fields) ? t.push({
2242
2302
  kind: "redundant-prefix",
2243
2303
  table: r,
2244
2304
  redundant: i,
2245
2305
  coveredBy: e,
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).`
2247
- }) : Vs(e.fields, i.fields) && t.push({
2306
+ 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).`
2307
+ }) : Xs(e.fields, i.fields) && t.push({
2248
2308
  kind: "redundant-prefix",
2249
2309
  table: r,
2250
2310
  redundant: e,
2251
2311
  coveredBy: i,
2252
- message: `'${r}' index '${e.name}' on [${Q(e.fields).join(", ")}] is a leading prefix of '${i.name}' on [${Q(i.fields).join(", ")}]. Every B-tree dialect we support (Postgres / MySQL / MariaDB / MSSQL / SQLite) can serve a [${Q(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).`
2312
+ 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).`
2253
2313
  });
2254
2314
  }
2255
2315
  }
2256
2316
  return t;
2257
- }, Us = (e) => {
2317
+ }, Qs = (e) => {
2258
2318
  let t = [];
2259
- for (let n of e) t.push(...Hs(n));
2319
+ for (let n of e) t.push(...Zs(n));
2260
2320
  return t;
2261
- }, Ws = "\x1B[", Gs = `${Ws}38;2;245;158;11m`, Ks = `${Ws}38;2;16;185;129m`, qs = (e, t) => `${e}${t}${j.reset}`, $ = (e, t, n) => e ? typeof t == "function" ? t(n) : qs(t, n) : n, Js = (e, t = {}) => {
2262
- let n = t.color ?? !0, r = t.indent ?? " ", i = (e) => $(n, j.dim, e.padEnd(11)), a = (e) => $(n, (e) => j.bold(j.brand(e)), e), o = (e) => $(n, j.brightRed24, e), s = (e) => $(n, Ks, e), c = (e) => $(n, Gs, e), l = (e) => $(n, j.dim, e), u = `${c("index audit")} ${l("·")} ${$(n, j.bold, e.kind)}`, d = e.redundant.fields.length, f = Q(e.coveredBy.fields.slice(d)), p = (e, t) => {
2321
+ }, $s = "\x1B[", ec = `${$s}38;2;245;158;11m`, tc = `${$s}38;2;16;185;129m`, nc = (e, t) => `${e}${t}${j.reset}`, Q = (e, t, n) => e ? typeof t == "function" ? t(n) : nc(t, n) : n, rc = (e, t = {}) => {
2322
+ let n = t.color ?? !0, r = t.indent ?? " ", i = (e) => Q(n, j.dim, e.padEnd(11)), a = (e) => Q(n, (e) => j.bold(j.brand(e)), e), o = (e) => Q(n, j.brightRed24, e), s = (e) => Q(n, tc, e), c = (e) => Q(n, ec, e), l = (e) => Q(n, j.dim, e), u = `${c("index audit")} ${l("·")} ${Q(n, j.bold, e.kind)}`, d = e.redundant.fields.length, f = Z(e.coveredBy.fields.slice(d)), p = (e, t) => {
2263
2323
  let n = e.slice(0, t), r = e.slice(t), i = [];
2264
2324
  return n.length > 0 && i.push(s(`[${n.join(", ")}]`)), r.length > 0 && i.push(c(`+ [${r.join(", ")}]`)), i.join(" ");
2265
2325
  }, m = [];
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, j.bold, "both")} B-trees. Pure write overhead, zero read benefit.`), m.push(""), m.push(`${i("fix")}Drop ${o(e.redundant.name)}`), m.push(`${i("")}${l("Keep only if profiling shows the smaller index gives a")}`), m.push(`${i("")}${l("measurable cache-locality boost on a write-heavy hot path.")}`), m.push(`${i("")}${l("Silence with VOLTRO_INDEX_AUDIT=off if intentional.")}`), m.map((e) => `${r}${e}`).join("\n");
2267
- }, Ys = (e, { apply: t, undo: n }) => ({
2326
+ 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, j.bold, "both")} B-trees. Pure write overhead, zero read benefit.`), m.push(""), m.push(`${i("fix")}Drop ${o(e.redundant.name)}`), m.push(`${i("")}${l("Keep only if profiling shows the smaller index gives a")}`), m.push(`${i("")}${l("measurable cache-locality boost on a write-heavy hot path.")}`), m.push(`${i("")}${l("Silence with VOLTRO_INDEX_AUDIT=off if intentional.")}`), m.map((e) => `${r}${e}`).join("\n");
2327
+ }, ic = (e, { apply: t, undo: n }) => ({
2268
2328
  name: e,
2269
2329
  apply: t,
2270
2330
  undo: n
2271
- }), Xs = (e) => {
2331
+ }), ac = (e) => {
2272
2332
  if (!/^\d{14}_/.test(e.id)) throw Error(`migration "${e.id}": id must start with a 14-digit timestamp followed by "_" (convention: <YYYYMMDDHHMMSS>_<slug>)`);
2273
- let t = e.steps({ step: Ys });
2333
+ let t = e.steps({ step: ic });
2274
2334
  if (t.length === 0) throw Error(`migration "${e.id}": at least one step is required`);
2275
2335
  return {
2276
2336
  __migration: !0,
@@ -2278,7 +2338,7 @@ $voltro_branch$`;
2278
2338
  name: e.name,
2279
2339
  steps: t
2280
2340
  };
2281
- }, Zs = (e) => typeof e == "object" && !!e && "__migration" in e && e.__migration === !0, Qs = T("_voltro_migrations", {
2341
+ }, oc = (e) => typeof e == "object" && !!e && "__migration" in e && e.__migration === !0, sc = T("_voltro_migrations", {
2282
2342
  id: _({ prefix: "mig" }),
2283
2343
  name: t(),
2284
2344
  hash: t(),
@@ -2290,7 +2350,7 @@ $voltro_branch$`;
2290
2350
  workflowRunId: t().nullable(),
2291
2351
  createdAt: C().default("now"),
2292
2352
  updatedAt: C().default("now").onUpdate("now")
2293
- }).index(["status"]), $s = T("_voltro_seeds", {
2353
+ }).index(["status"]), cc = T("_voltro_seeds", {
2294
2354
  id: _({ prefix: "seed" }),
2295
2355
  name: t(),
2296
2356
  lifecycle: t(),
@@ -2306,7 +2366,7 @@ $voltro_branch$`;
2306
2366
  workflowRunId: t().nullable(),
2307
2367
  createdAt: C().default("now"),
2308
2368
  updatedAt: C().default("now").onUpdate("now")
2309
- }).index(["lifecycle"]).index(["nextRunAt"]), ec = T("_voltro_migration_plans", {
2369
+ }).index(["lifecycle"]).index(["nextRunAt"]), lc = T("_voltro_migration_plans", {
2310
2370
  id: _({ prefix: "plan" }),
2311
2371
  fingerprint: t(),
2312
2372
  liveFingerprint: t().nullable(),
@@ -2322,21 +2382,21 @@ $voltro_branch$`;
2322
2382
  appliedAt: C().default("now"),
2323
2383
  createdAt: C().default("now"),
2324
2384
  updatedAt: C().default("now").onUpdate("now")
2325
- }).index(["fingerprint"]).index(["environment"]), tc = T("_voltro_idempotency", {
2385
+ }).index(["fingerprint"]).index(["environment"]), uc = T("_voltro_idempotency", {
2326
2386
  id: _({ prefix: "idem" }),
2327
2387
  scope: t(),
2328
2388
  key: t(),
2329
2389
  status: t(),
2330
2390
  response: h().nullable(),
2331
2391
  createdAt: C().default("now")
2332
- }).unique(["scope", "key"]).index(["createdAt"]), nc = T("_voltro_kv", {
2392
+ }).unique(["scope", "key"]).index(["createdAt"]), dc = T("_voltro_kv", {
2333
2393
  id: _({ prefix: "kv" }),
2334
2394
  key: t().unique(),
2335
2395
  value: t().nullable(),
2336
2396
  expiresAt: C().nullable(),
2337
2397
  createdAt: C().default("now"),
2338
2398
  updatedAt: C().default("now").onUpdate("now")
2339
- }).index(["expiresAt"]), rc = T("_voltro_api_keys", {
2399
+ }).index(["expiresAt"]), fc = T("_voltro_api_keys", {
2340
2400
  id: _({ prefix: "apikey" }),
2341
2401
  tenantId: t().nullable(),
2342
2402
  name: t(),
@@ -2351,11 +2411,20 @@ $voltro_branch$`;
2351
2411
  onBehalfOf: t().nullable(),
2352
2412
  metadata: h().nullable(),
2353
2413
  createdAt: C().default("now")
2354
- }).index("byApiKeyTenant", ["tenantId"]), ic = [
2355
- Qs,
2356
- $s,
2357
- ec
2358
- ], ac = "_voltro_replace_in_progress", oc = T(ac, {
2414
+ }).index("byApiKeyTenant", ["tenantId"]), pc = T("_voltro_replica_observations", {
2415
+ id: _({ prefix: "robs" }),
2416
+ replicaId: t().maxLength(191),
2417
+ startedAt: C(),
2418
+ version: t().maxLength(64).nullable(),
2419
+ kind: t().maxLength(64),
2420
+ payload: t().nullable(),
2421
+ reachableAt: t().maxLength(255).nullable(),
2422
+ writtenAt: C().default("now").onUpdate("now")
2423
+ }).unique(["replicaId", "kind"]).index(["kind"]), mc = [
2424
+ sc,
2425
+ cc,
2426
+ lc
2427
+ ], hc = "_voltro_replace_in_progress", gc = T(hc, {
2359
2428
  id: _({ prefix: "repl" }),
2360
2429
  startedAt: C().default("now"),
2361
2430
  kind: t().default("replace"),
@@ -2365,10 +2434,10 @@ $voltro_branch$`;
2365
2434
  staging: t().nullable(),
2366
2435
  heartbeatAt: C().nullable(),
2367
2436
  resumable: r().nullable()
2368
- }), sc = 30, cc = (e, t) => {
2437
+ }), _c = 30, vc = (e, t) => {
2369
2438
  let n = typeof t == "number" && Number.isFinite(t) && t > 0 ? t : 30, r = Number(e.VOLTRO_STAGING_STALE_MINUTES);
2370
2439
  return (Number.isFinite(r) && r > 0 ? r : n) * 6e4;
2371
- }, lc = (e) => e == null || String(e).length === 0 ? [] : String(e).split(",").map((e) => e.trim()).filter((e) => e.length > 0), uc = (e) => {
2440
+ }, yc = (e) => e == null || String(e).length === 0 ? [] : String(e).split(",").map((e) => e.trim()).filter((e) => e.length > 0), bc = (e) => {
2372
2441
  let t = e.filter((e) => e.kind !== "staging");
2373
2442
  if (t.length !== 0) return `refusing to start: a destructive data operation did not finish.
2374
2443
  ${t.map((e) => {
@@ -2383,7 +2452,7 @@ ${t.map((e) => {
2383
2452
 
2384
2453
  When the data is back, or you have decided the current state is correct, clear the marker:
2385
2454
  voltro data clear-replace-marker --yes`;
2386
- }, dc = (e, t, n) => {
2455
+ }, xc = (e, t, n) => {
2387
2456
  let r = e.filter((e) => e.kind === "staging");
2388
2457
  return {
2389
2458
  all: r,
@@ -2393,7 +2462,7 @@ ${t.map((e) => {
2393
2462
  return Number.isFinite(r) ? t - r >= n : !1;
2394
2463
  })
2395
2464
  };
2396
- }, fc = (e, t) => {
2465
+ }, Sc = (e, t) => {
2397
2466
  if (e.all.length === 0) return;
2398
2467
  let n = new Set(e.droppable.map((e) => e.id));
2399
2468
  return `staged data-import leftovers:
@@ -2402,22 +2471,22 @@ ${e.all.map((e) => {
2402
2471
  return n.has(e.id) ? ` - ${a} — DROPPED: the run is not resumable and has been silent long enough that nothing is loading into them.` : e.resumable ? ` - ${a} — KEPT: the run was started \`--no-atomic\`, so these ARE its resume point. Re-run the same\n bundle to continue from them, or drop them with: voltro data clear-staging --yes` : ` - ${a} — KEPT: still beating, so an import is loading into them right now.`;
2403
2472
  }).join("\n")}\n The target of a staged \`replace\` is untouched until one short swap at the end, so none of this is
2404
2473
  a reason to refuse the boot — it is a reason to know the disk is holding a copy of a bundle.`;
2405
- }, pc = "id", mc = (e, t) => {
2474
+ }, $ = "id", Cc = (e, t) => {
2406
2475
  let n = E(e);
2407
2476
  if (n === void 0) return t;
2408
- let r = n.fields[pc]?.idScheme;
2409
- if (r === void 0 || t[pc] != null) return t;
2477
+ let r = n.fields[$]?.idScheme;
2478
+ if (r === void 0 || t[$] != null) return t;
2410
2479
  if (r.kind === "numeric") {
2411
- if (!(pc in t)) return t;
2480
+ if (!($ in t)) return t;
2412
2481
  let e = { ...t };
2413
- return delete e[pc], e;
2482
+ return delete e[$], e;
2414
2483
  }
2415
2484
  let i = gt(r, e);
2416
2485
  return i === null ? t : {
2417
2486
  ...t,
2418
- [pc]: i
2487
+ [$]: i
2419
2488
  };
2420
- }, hc = (e, t) => t.map((t) => mc(e, t)), gc = {
2489
+ }, wc = (e, t) => t.map((t) => Cc(e, t)), Tc = {
2421
2490
  postgres: { maxBindParameters: 65535 },
2422
2491
  mysql: { maxBindParameters: 65535 },
2423
2492
  mariadb: { maxBindParameters: 65535 },
@@ -2427,25 +2496,25 @@ ${e.all.map((e) => {
2427
2496
  },
2428
2497
  sqlite: { maxBindParameters: 32766 },
2429
2498
  turso: { maxBindParameters: 32766 }
2430
- }, _c = (e) => gc[e], vc = (e) => {
2499
+ }, Ec = (e) => Tc[e], Dc = (e) => {
2431
2500
  let t = /* @__PURE__ */ new Set();
2432
2501
  for (let n of e) for (let e of Object.keys(n)) t.add(e);
2433
2502
  return t.size;
2434
- }, yc = (e, t) => {
2503
+ }, Oc = (e, t) => {
2435
2504
  if (t === void 0 || e.length === 0) return [e];
2436
- let n = Math.max(1, vc(e)), r = Math.floor(t.maxBindParameters / n), i = t.maxRowsPerStatement ?? Infinity, a = Math.max(1, Math.min(r, i));
2505
+ let n = Math.max(1, Dc(e)), r = Math.floor(t.maxBindParameters / n), i = t.maxRowsPerStatement ?? Infinity, a = Math.max(1, Math.min(r, i));
2437
2506
  if (e.length <= a) return [e];
2438
2507
  let o = [];
2439
2508
  for (let t = 0; t < e.length; t += a) o.push(e.slice(t, t + a));
2440
2509
  return o;
2441
- }, bc = (e, t) => {
2510
+ }, kc = (e, t) => {
2442
2511
  let n = [], r = t;
2443
2512
  for (let [t, i] of Object.entries(e.fields)) {
2444
2513
  let e = i;
2445
2514
  e.nullable || e.hasDefault || e.idScheme !== void 0 || e.generatedAs !== void 0 || (r[t] === void 0 || r[t] === null) && n.push(t);
2446
2515
  }
2447
2516
  return n;
2448
- }, xc = (e, t, n) => {
2517
+ }, Ac = (e, t, n) => {
2449
2518
  let r = n, i = new Set(e === void 0 ? [] : Object.entries(e.fields).filter(([, e]) => e.generatedAs !== void 0).map(([e]) => e)), a = [];
2450
2519
  for (let e of t) i.has(e) || (r[e] === void 0 ? a.push({
2451
2520
  column: e,
@@ -2455,28 +2524,28 @@ ${e.all.map((e) => {
2455
2524
  reason: "null"
2456
2525
  }));
2457
2526
  return a;
2458
- }, Sc = (e, t, n) => e.insert(t.tableName, n), Cc = (e, t, n, r) => e.upsert(t.tableName, n, {
2527
+ }, jc = (e, t, n) => e.insert(t.tableName, n), Mc = (e, t, n, r) => e.upsert(t.tableName, n, {
2459
2528
  conflictColumns: r.conflictColumns,
2460
2529
  ...r.update === void 0 ? {} : { update: r.update }
2461
- }), wc = (e, t, n, r) => e.updateMany(t.tableName, n, { where: r.where }), Tc = 512, Ec = (e) => {
2530
+ }), Nc = (e, t, n, r) => e.updateMany(t.tableName, n, { where: r.where }), Pc = 512, Fc = (e) => {
2462
2531
  e.setMaxListeners(512);
2463
- }, Dc = (e, t, n) => ({
2532
+ }, Ic = (e, t, n) => ({
2464
2533
  _tag: "PrimaryKeyConflictError",
2465
2534
  table: e,
2466
2535
  key: t,
2467
2536
  cause: n
2468
- }), Oc = (e) => typeof e == "object" && !!e && e._tag === "PrimaryKeyConflictError", kc = {
2537
+ }), Lc = (e) => typeof e == "object" && !!e && e._tag === "PrimaryKeyConflictError", Rc = {
2469
2538
  postgres: 5432,
2470
2539
  mysql: 3306,
2471
2540
  mariadb: 3306,
2472
2541
  mssql: 1433
2473
- }, Ac = /* @__PURE__ */ new Set([
2542
+ }, zc = /* @__PURE__ */ new Set([
2474
2543
  "localhost",
2475
2544
  "127.0.0.1",
2476
2545
  "::1",
2477
2546
  "[::1]",
2478
2547
  "0.0.0.0"
2479
- ]), jc = (e) => {
2548
+ ]), Bc = (e) => {
2480
2549
  let t = e.host, n = e.port, r = e.database;
2481
2550
  if (e.url !== void 0 && e.url !== "") try {
2482
2551
  let i = new URL(e.url);
@@ -2485,29 +2554,29 @@ ${e.all.map((e) => {
2485
2554
  return;
2486
2555
  }
2487
2556
  if (t === void 0 || t === "" || r === void 0 || r === "") return;
2488
- let i = n ?? kc[(e.dialect ?? "").toLowerCase()];
2557
+ let i = n ?? Rc[(e.dialect ?? "").toLowerCase()];
2489
2558
  if (i === void 0 || !Number.isFinite(i)) return;
2490
2559
  let a = t.toLowerCase();
2491
2560
  return {
2492
- host: Ac.has(a) ? "localhost" : a,
2561
+ host: zc.has(a) ? "localhost" : a,
2493
2562
  port: i,
2494
2563
  database: r.toLowerCase()
2495
2564
  };
2496
- }, Mc = (e) => {
2497
- let t = jc(e);
2498
- if (t !== void 0) return Rt("sha256").update(`${t.host}\u0000${t.port}\u0000${t.database}`).digest("hex").slice(0, 32);
2499
- }, Nc = (e, t) => e === void 0 || t === void 0 ? "unknown" : e === t ? "same" : "different", Pc = {
2565
+ }, Vc = (e) => {
2566
+ let t = Bc(e);
2567
+ if (t !== void 0) return Lt("sha256").update(`${t.host}\u0000${t.port}\u0000${t.database}`).digest("hex").slice(0, 32);
2568
+ }, Hc = (e, t) => e === void 0 || t === void 0 ? "unknown" : e === t ? "same" : "different", Uc = {
2500
2569
  app: 3,
2501
2570
  plugin: 2,
2502
2571
  framework: 1
2503
- }, Fc = /* @__PURE__ */ new Map(), Ic = [], Lc = () => [...Ic], Rc = (e) => {
2572
+ }, Wc = /* @__PURE__ */ new Map(), Gc = [], Kc = () => [...Gc], qc = (e) => {
2504
2573
  if (!e.table || !e.timeColumn) throw Error("registerRetention: table + timeColumn are required");
2505
2574
  if (!Number.isFinite(e.ttlMs) || e.ttlMs <= 0) throw Error(`registerRetention(${e.table}): ttlMs must be a positive number`);
2506
- let t = e.source ?? "app", n = Fc.get(e.table);
2575
+ let t = e.source ?? "app", n = Wc.get(e.table);
2507
2576
  if (n !== void 0) {
2508
2577
  let r = n.source ?? "app", i = n.ttlMs !== e.ttlMs || n.where !== void 0 != (e.where !== void 0);
2509
- if (Pc[t] < Pc[r]) {
2510
- i && Ic.push({
2578
+ if (Uc[t] < Uc[r]) {
2579
+ i && Gc.push({
2511
2580
  table: e.table,
2512
2581
  kept: {
2513
2582
  source: r,
@@ -2520,7 +2589,7 @@ ${e.all.map((e) => {
2520
2589
  });
2521
2590
  return;
2522
2591
  }
2523
- i && r !== t && Ic.push({
2592
+ i && r !== t && Gc.push({
2524
2593
  table: e.table,
2525
2594
  kept: {
2526
2595
  source: t,
@@ -2532,36 +2601,36 @@ ${e.all.map((e) => {
2532
2601
  }
2533
2602
  });
2534
2603
  }
2535
- Fc.set(e.table, {
2604
+ Wc.set(e.table, {
2536
2605
  ...e,
2537
2606
  source: t
2538
2607
  });
2539
- }, zc = () => [...Fc.values()], Bc = () => {
2540
- Fc.clear(), Ic.length = 0;
2541
- }, Vc = async (e, t, n, r = 2e4) => {
2608
+ }, Jc = () => [...Wc.values()], Yc = () => {
2609
+ Wc.clear(), Gc.length = 0;
2610
+ }, Xc = async (e, t, n, r = 2e4) => {
2542
2611
  let i = new Date(t - e.ttlMs), a = 0;
2543
2612
  for (;;) {
2544
2613
  let t = await n(e.table, e.timeColumn, i, r, e.where);
2545
2614
  if (a += t, t < r) break;
2546
2615
  }
2547
2616
  return a;
2548
- }, Hc = (e, t) => {
2617
+ }, Zc = (e, t) => {
2549
2618
  let n = Number(e ?? String(t));
2550
2619
  return (Number.isFinite(n) && n > 0 ? n : t) * 36e5;
2551
- }, Uc = "_voltro_cdc_offsets", Wc = T(Uc, {
2620
+ }, Qc = "_voltro_cdc_offsets", $c = T(Qc, {
2552
2621
  id: _({ prefix: "cdcoff" }),
2553
2622
  replicaId: t(),
2554
2623
  streamName: t(),
2555
2624
  binlogFile: t(),
2556
2625
  binlogPosition: t(),
2557
2626
  updatedAt: C()
2558
- }).index(["replicaId"]), Gc = T(Uc, {
2627
+ }).index(["replicaId"]), el = T(Qc, {
2559
2628
  id: _({ prefix: "cdcoff" }),
2560
2629
  replicaId: t(),
2561
2630
  streamName: t(),
2562
2631
  ctVersion: t(),
2563
2632
  updatedAt: C()
2564
- }).index(["replicaId"]), Kc = "_voltro_data_transfers", qc = T(Kc, {
2633
+ }).index(["replicaId"]), tl = "_voltro_data_transfers", nl = T(tl, {
2565
2634
  id: _({ prefix: "dimp" }),
2566
2635
  startedAt: C().default("now"),
2567
2636
  finishedAt: C().nullable(),
@@ -2574,9 +2643,9 @@ ${e.all.map((e) => {
2574
2643
  rowsWritten: S().default(0),
2575
2644
  failure: t().nullable(),
2576
2645
  staged: r().nullable()
2577
- }).renamedFrom("_voltro_data_imports").nonReactive(), Jc = (e) => {
2646
+ }).renamedFrom("_voltro_data_imports").nonReactive(), rl = (e) => {
2578
2647
  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)";
2579
2648
  return `${t} · ${r} · via ${e.via}${i}` + (e.bundle === null ? "" : ` · from ${e.bundle}`) + (e.sourceFingerprint === null ? "" : ` · source schema ${e.sourceFingerprint}`);
2580
- }, Yc = "postgres";
2649
+ }, il = "postgres";
2581
2650
  //#endregion
2582
- export { nt as AUTO_FILLED_COLUMNS, gc as BULK_INSERT_LIMITS, Y as BranchNameInvalid, us as BranchTransitionInvalid, Uc as CDC_OFFSETS_TABLE, Tc as CHANGE_LISTENER_CEILING, l as ColumnBuilder, Kc as DATA_TRANSFERS_TABLE, fe as DEFAULT_ACQUIRE_TIMEOUT_MS, Mo as DEFAULT_EAGER_FALLBACK_WARN_INTERVAL_MS, Gn as DEFAULT_SUBJECT_GRAPH_DEPTH, qt as ENCRYPTED_PREFIX, Yc as ENGINE, cr as EagerCardinalityError, rt as FILE_MIGRATION_PATTERN, ft as FRAMEWORK_LIVE_TABLES, Jt as FieldDecryptionError, $a as ID_COLUMN_MAX_LENGTH, Go as INITIAL_VERSION, la as MATCHES_NO_ROWS, et as MAX_IDENTIFIER_LENGTH, ac as REPLACE_IN_PROGRESS_TABLE, sc as STAGING_STALE_MINUTES, tt as STAGING_TABLE_PREFIX, Bt as SqlClient, Qo as TableStreamError, Sr as TenantNamespaceInvalid, xr as TenantNamespaceUnresolved, ks as TenantRegionUnavailable, Os as TenantResidencyUnresolved, Ko as VOLTRO_EXPIRES_MIXIN_ID, Jo as VOLTRO_LOCAL_FIRST_MIXIN_ID, Vo as VersionConflict, Ke as WARN_IDENTIFIER_LENGTH, rc as _voltroApiKeysTable, Wc as _voltroCdcOffsetsTable, qc as _voltroDataTransfersTable, tc as _voltroIdempotencyTable, nc as _voltroKvTable, ec as _voltroMigrationPlansTable, Qs as _voltroMigrationsTable, Gc as _voltroMssqlCdcOffsetsTable, oc as _voltroReplaceInProgressTable, $s as _voltroSeedsTable, Yi as actorsTable, Cs as admitBranch, St as allEnumRenames, Hn as allRegisteredRelations, Ce as allRegisteredTables, pa as and, le as array, oa as arrayContains, ca as arrayHas, sa as arrayOverlaps, ur as attachEagerLoads, Fa as attributionFields, za as attributionKey, Us as auditAllTableIndexes, Hs as auditTableIndexes, Fe as avg, xt as avgOver, Ja as beginLocalWrite, Xe as bigint, Ls as bindResidentStore, r as boolean, ss as branchNamespaceName, _c as bulkInsertLimitsFor, Je as bytes, Aa as changeDelete, Oa as changeInsert, ja as changeSoftDelete, ka as changeUpdate, yc as chunkRowsForInsert, Ha as claimPendingAttribution, pn as classifyConstraintViolation, _e as clearEnumRenames, Za as clearPendingAttribution, Wn as clearRelationsRegistry, Ns as clearResidencyConfig, Bc as clearRetentions, m as clearTableRegistry, oo as clearWriteRecorders, W as coercePredicateForSqlite, Ar as coercePredicateValue, jr as coercePredicateValues, Vi as coerceValueForSqlite, Ta as collectSubqueries, ge as column, yn as columnSchema, vc as columnsPerRow, Gr as compileEagerJson, I as compilePredicate, Mr as compileRawFragment, Wr as compileSelect, rs as computeEmbedding, Mc as connectionIdentity, ia as contains, o as count, yt as countDistinct, oe as crdtDoc, se as crdtManagedColumns, de as crdtManagedColumnsOf, p as crdtText, Pa as currentWriteAttribution, ve as databaseHandle, te as date, ie as dbEnum, Eo as dbMetricTagCacheSizeForTests, ko as dbOperationsInFlight, he as decimal, s as declareEnumRename, $t as decodeFieldValue, ar as decodeRowsFromSchema, an as decryptFieldsOnRead, Xs as defineMigration, it as defineMixin, Ze as defineSeed, u as denseRank, Qn as deriveSubjectGraph, Qe as deriveTypeIdPrefix, no as derivedRowId, ro as derivedRowIdLength, gn as describeDriverError, _n as describeRowBindings, Jc as describeTransferRun, Kt as deserializeArraysOnRead, Ge as drainIdentifierWarnings, Et as dropped, Zt as encodeFieldValue, sr as encodeRowForSchema, rn as encryptFieldsForWrite, nn as encryptedColumnsOf, Ya as endLocalWrite, bs as enforceBranchLimits, y as ensureTableRegistered, Xi as eq, Nr as escapeLike, wa as evaluatePredicate, c as except, ba as exists, qo as expires, Da as externalChangeEvent, un as extractDbCause, ht as fireSchemaChangeSeeds, ze as fireTenantCreateSeeds, Js as formatIndexAuditIssue, $n as formatSubjectGraph, ic as frameworkTables, gt as generateId, Ue as generateSnowflake, a as geography, Se as geometry, bt as getEnumRenames, Vn as getRelation, Bn as getRelations, Ms as getResidencyConfig, E as getTable, Qi as gt, $i as gte, br as hasEagerLoads, ns as hybridSearch, _ as id, na as inSet, va as inSubquery, P as inferForeignKey, Sc as insertRow, S as integer, uc as interruptedReplaceRefusal, ce as intersect, we as interval, cs as isBranchNamespace, Dn as isEmptyRelationsSpec, Xt as isEncrypted, Yt as isFieldDecryptionError, ut as isFileMigration, mn as isForeignKeyViolation, ct as isFrameworkOwnedLiveTable, Xo as isLocalFirst, Zs as isMigrationDefinition, e as isMysqlFamily, ms as isNeonConnection, da as isNotNull, ua as isNull, Oc as isPrimaryKeyConflictError, hn as isQueryTimeout, en as isRawEncoding, Fs as isRegionServable, On as isRelationsSpec, He as isSeedDefinition, Ve as isSqliteFamily, Ne as isStagingTableName, ne as isTableReactive, We as isView, h as json, ga as jsonField, lt as jsonIndex, Ye as lag, n as lead, Lc as listRetentionConflicts, zc as listRetentions, Yo as localFirst, Zo as localFirstTables, ea as lt, ta as lte, Fo as makeEagerFallbackReporter, Ds as makeNamespaceBranchExecutor, An as many, jn as manyToMany, re as materializeFields, qe as max, Le as migration, ae as min, xc as missingConflictColumns, bc as missingRequiredColumns, dt as mixin, Zi as neq, ds as nextBranchState, jc as normaliseTarget, ha as not, xa as notExists, ra as notInSet, ya as notInSubquery, st as numeric, jo as observeDbOp, kn as one, lr as oneCardinalityMessage, ma as or, x as orderClausesOf, ue as paginateBy, f as paginateById, Qa as pendingAttributionCount, vs as planBranch, fs as planBranchProvision, ps as planBranchTeardown, ys as planBranchTeardownFor, gs as planNeonBranchProvision, _s as planNeonBranchTeardown, Uo as planVersionedUpdate, ye as pluginRef, d as pluginRefSpecOf, Dc as primaryKeyConflictError, xs as provisionBranch, Rs as provisionResidentTenant, Dr as qualifyTable, ee as queryFor, je as queryForView, mt as quoteIdent, Ec as raiseChangeListenerCeiling, b as rank, v as raw, Oe as readableByColumns, Ee as real, Ao as recordDbOp, fo as recordsTable, Ae as reference, Gi as registerCoreTables, zn as registerDiscoveredRelations, Va as registerPendingAttribution, Rn as registerRelations, Rc as registerRetention, De as registerTable, io as registerWriteRecorder, En as relations, qi as requireActors, Te as requireTable, Ji as requireTenants, To as resetDbMetricTagCacheForTests, ot as resetSnowflake, Is as residentPlacement, Ht as resolveActorSnapshot, hs as resolveBranchMechanism, Po as resolveEagerFallbackWarnIntervalMs, Xa as resolveEchoAttribution, me as resolveFullTextIndex, Be as resolveIdScheme, Re as resolveMixinGraph, Ps as resolveTenantHome, Er as resolveTenantNamespace, Hc as retentionTtlMsFromEnv, Tt as rowNumber, bn as rowSchema, zo as runRetryingTransaction, Bo as runStoreTransaction, Na as runWithWriteAttribution, po as runWriteRecorders, Nc as sameDatabase, Tr as sanitizeIdentifierFragment, Gt as serializeArraysForWrite, pe as serverOnlyColumns, js as setResidencyConfig, at as setSchemaChangeSeedHook, $e as setTenantCreateSeedHook, Io as settleTransactionExit, Wo as settleVersionedUpdate, fa as spatialPredicate, fc as stagingLeftoverReport, dc as stagingLeftovers, lc as stagingNamesOf, cc as stagingStaleAfterMs, mc as stampGeneratedId, hc as stampGeneratedIds, aa as startsWith, ts as streamTable, i as sum, xe as sumOver, co as suspendWriteRecorders, lo as suspendWriteRecordersEffect, Vc as sweepRetention, T as table, Ss as teardownBranch, t as text, C as timestamp, Dt as timestampMs, Ot as timestampMsOrNull, g as union, be as unionAll, ke as unregisterTable, ao as unregisterWriteRecorder, wc as updateManyRow, Cc as upsertRow, Me as validateColumnName, vt as validateIndexName, Un as validateRegisteredRelations, Fn as validateRelationConfig, wt as validateTableName, Ie as validateTypeIdPrefix, pt as vector, Pe as vectorDistanceToOpclass, is as vectorEmbedding, Ho as versionColumnOf, _t as view, Ct as viewSql, Ea as walkLeaves, Ia as withCapturedAttribution, uo as writeRecordersSuspended };
2651
+ export { nt as AUTO_FILLED_COLUMNS, Tc as BULK_INSERT_LIMITS, J as BranchNameInvalid, ys as BranchTransitionInvalid, Qc as CDC_OFFSETS_TABLE, Ra as CHANGE_CLAIM_TTL_ENV, Pc as CHANGE_LISTENER_CEILING, l as ColumnBuilder, tl as DATA_TRANSFERS_TABLE, fe as DEFAULT_ACQUIRE_TIMEOUT_MS, za as DEFAULT_CHANGE_CLAIM_TTL_HOURS, Vo as DEFAULT_EAGER_FALLBACK_WARN_INTERVAL_MS, Gn as DEFAULT_SUBJECT_GRAPH_DEPTH, qt as ENCRYPTED_PREFIX, il as ENGINE, cr as EagerCardinalityError, rt as FILE_MIGRATION_PATTERN, ft as FRAMEWORK_LIVE_TABLES, Jt as FieldDecryptionError, co as ID_COLUMN_MAX_LENGTH, es as INITIAL_VERSION, ua as MATCHES_NO_ROWS, et as MAX_IDENTIFIER_LENGTH, La as OccurrenceCounter, hc as REPLACE_IN_PROGRESS_TABLE, _c as STAGING_STALE_MINUTES, tt as STAGING_TABLE_PREFIX, Bt as SqlClient, ss as TableStreamError, Sr as TenantNamespaceInvalid, xr as TenantNamespaceUnresolved, Rs as TenantRegionUnavailable, Ls as TenantResidencyUnresolved, ts as VOLTRO_EXPIRES_MIXIN_ID, rs as VOLTRO_LOCAL_FIRST_MIXIN_ID, Xo as VersionConflict, Ke as WARN_IDENTIFIER_LENGTH, fc as _voltroApiKeysTable, $c as _voltroCdcOffsetsTable, nl as _voltroDataTransfersTable, uc as _voltroIdempotencyTable, dc as _voltroKvTable, lc as _voltroMigrationPlansTable, sc as _voltroMigrationsTable, el as _voltroMssqlCdcOffsetsTable, gc as _voltroReplaceInProgressTable, pc as _voltroReplicaObservationsTable, cc as _voltroSeedsTable, Xi as actorsTable, Ms as admitBranch, St as allEnumRenames, Hn as allRegisteredRelations, Ce as allRegisteredTables, ma as and, le as array, sa as arrayContains, la as arrayHas, ca as arrayOverlaps, ur as attachEagerLoads, Wa as attributionFields, Ja as attributionKey, Qs as auditAllTableIndexes, Zs as auditTableIndexes, Fe as avg, xt as avgOver, ro as beginLocalWrite, Xe as bigint, Ks as bindResidentStore, r as boolean, gs as branchNamespaceName, Ec as bulkInsertLimitsFor, Je as bytes, ja as changeDelete, Pa as changeDigest, ka as changeInsert, Ma as changeSoftDelete, Aa as changeUpdate, Oc as chunkRowsForInsert, Za as claimPendingAttribution, pn as classifyConstraintViolation, _e as clearEnumRenames, oo as clearPendingAttribution, Wn as clearRelationsRegistry, Hs as clearResidencyConfig, Yc as clearRetentions, m as clearTableRegistry, go as clearWriteRecorders, U as coercePredicateForSqlite, Ar as coercePredicateValue, jr as coercePredicateValues, Hi as coerceValueForSqlite, Ea as collectSubqueries, ge as column, yn as columnSchema, Dc as columnsPerRow, Gr as compileEagerJson, I as compilePredicate, Mr as compileRawFragment, Wr as compileSelect, Fa as composeChangeKey, fs as computeEmbedding, Vc as connectionIdentity, aa as contains, o as count, yt as countDistinct, oe as crdtDoc, se as crdtManagedColumns, de as crdtManagedColumnsOf, p as crdtText, Ua as currentWriteAttribution, ve as databaseHandle, te as date, ie as dbEnum, Fo as dbMetricTagCacheSizeForTests, Ro as dbOperationsInFlight, he as decimal, s as declareEnumRename, $t as decodeFieldValue, ar as decodeRowsFromSchema, an as decryptFieldsOnRead, ac as defineMigration, it as defineMixin, Ze as defineSeed, u as denseRank, Qn as deriveSubjectGraph, Qe as deriveTypeIdPrefix, fo as derivedRowId, po as derivedRowIdLength, gn as describeDriverError, _n as describeRowBindings, rl as describeTransferRun, Kt as deserializeArraysOnRead, Ge as drainIdentifierWarnings, Et as dropped, Zt as encodeFieldValue, sr as encodeRowForSchema, rn as encryptFieldsForWrite, nn as encryptedColumnsOf, io as endLocalWrite, ks as enforceBranchLimits, y as ensureTableRegistered, Zi as eq, Nr as escapeLike, Ta as evaluatePredicate, c as except, xa as exists, ns as expires, Oa as externalChangeEvent, un as extractDbCause, ht as fireSchemaChangeSeeds, ze as fireTenantCreateSeeds, rc as formatIndexAuditIssue, $n as formatSubjectGraph, mc as frameworkTables, gt as generateId, Ue as generateSnowflake, a as geography, Se as geometry, bt as getEnumRenames, Vn as getRelation, Bn as getRelations, Vs as getResidencyConfig, E as getTable, $i as gt, ea as gte, br as hasEagerLoads, ds as hybridSearch, _ as id, ra as inSet, ya as inSubquery, P as inferForeignKey, jc as insertRow, S as integer, bc as interruptedReplaceRefusal, ce as intersect, we as interval, _s as isBranchNamespace, Dn as isEmptyRelationsSpec, Xt as isEncrypted, Yt as isFieldDecryptionError, ut as isFileMigration, mn as isForeignKeyViolation, ct as isFrameworkOwnedLiveTable, as as isLocalFirst, oc as isMigrationDefinition, e as isMysqlFamily, Cs as isNeonConnection, fa as isNotNull, da as isNull, Lc as isPrimaryKeyConflictError, hn as isQueryTimeout, en as isRawEncoding, Ws as isRegionServable, On as isRelationsSpec, He as isSeedDefinition, Ve as isSqliteFamily, Ne as isStagingTableName, ne as isTableReactive, We as isView, h as json, _a as jsonField, lt as jsonIndex, Ye as lag, n as lead, Kc as listRetentionConflicts, Jc as listRetentions, is as localFirst, os as localFirstTables, ta as lt, na as lte, Wo as makeEagerFallbackReporter, Is as makeNamespaceBranchExecutor, An as many, jn as manyToMany, re as materializeFields, qe as max, Le as migration, ae as min, Ac as missingConflictColumns, kc as missingRequiredColumns, dt as mixin, Qi as neq, bs as nextBranchState, Bc as normaliseTarget, ga as not, Sa as notExists, ia as notInSet, ba as notInSubquery, st as numeric, Bo as observeDbOp, Ba as occurrenceWindowMs, kn as one, lr as oneCardinalityMessage, ha as or, x as orderClausesOf, ue as paginateBy, f as paginateById, Ia as parseChangeKey, so as pendingAttributionCount, Ds as planBranch, xs as planBranchProvision, Ss as planBranchTeardown, Os as planBranchTeardownFor, Ts as planNeonBranchProvision, Es as planNeonBranchTeardown, Qo as planVersionedUpdate, ye as pluginRef, d as pluginRefSpecOf, Ic as primaryKeyConflictError, As as provisionBranch, qs as provisionResidentTenant, Dr as qualifyTable, ee as queryFor, je as queryForView, mt as quoteIdent, Fc as raiseChangeListenerCeiling, b as rank, v as raw, Oe as readableByColumns, Ee as real, zo as recordDbOp, xo as recordsTable, Ae as reference, Ki as registerCoreTables, zn as registerDiscoveredRelations, Xa as registerPendingAttribution, Rn as registerRelations, qc as registerRetention, De as registerTable, mo as registerWriteRecorder, En as relations, Ji as requireActors, Te as requireTable, Yi as requireTenants, Po as resetDbMetricTagCacheForTests, ot as resetSnowflake, Gs as residentPlacement, Ht as resolveActorSnapshot, ws as resolveBranchMechanism, Uo as resolveEagerFallbackWarnIntervalMs, ao as resolveEchoAttribution, me as resolveFullTextIndex, Be as resolveIdScheme, Re as resolveMixinGraph, Us as resolveTenantHome, Er as resolveTenantNamespace, Zc as retentionTtlMsFromEnv, Tt as rowNumber, bn as rowSchema, Jo as runRetryingTransaction, Yo as runStoreTransaction, Ha as runWithWriteAttribution, So as runWriteRecorders, Hc as sameDatabase, Tr as sanitizeIdentifierFragment, Gt as serializeArraysForWrite, pe as serverOnlyColumns, Bs as setResidencyConfig, at as setSchemaChangeSeedHook, $e as setTenantCreateSeedHook, Go as settleTransactionExit, $o as settleVersionedUpdate, pa as spatialPredicate, Sc as stagingLeftoverReport, xc as stagingLeftovers, yc as stagingNamesOf, vc as stagingStaleAfterMs, Cc as stampGeneratedId, wc as stampGeneratedIds, oa as startsWith, us as streamTable, i as sum, xe as sumOver, vo as suspendWriteRecorders, yo as suspendWriteRecordersEffect, Xc as sweepRetention, T as table, js as teardownBranch, t as text, C as timestamp, Dt as timestampMs, Ot as timestampMsOrNull, g as union, be as unionAll, ke as unregisterTable, ho as unregisterWriteRecorder, Nc as updateManyRow, Mc as upsertRow, Me as validateColumnName, vt as validateIndexName, Un as validateRegisteredRelations, Fn as validateRelationConfig, wt as validateTableName, Ie as validateTypeIdPrefix, pt as vector, Pe as vectorDistanceToOpclass, ps as vectorEmbedding, Zo as versionColumnOf, _t as view, Ct as viewSql, Da as walkLeaves, Ga as withCapturedAttribution, bo as writeRecordersSuspended };