@voltro/database 0.70.0 → 0.71.1

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,4 +1,4 @@
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 v, It as ee, J as te, Jt as y, K as ne, Kt as re, L as b, Lt as ie, M as x, Mt as ae, N as S, Nt as oe, O as se, Ot as ce, P as le, Pt as ue, Q as de, Qt as fe, R as pe, Rt as me, S as he, St as ge, T as _e, Tt as ve, U as ye, Ut as be, V as xe, Vt as Se, W as Ce, Wt as we, X as Te, Xt as C, Y as Ee, Yt as De, Z as w, Zt as Oe, _ as ke, _t as Ae, a as je, an as T, at as Me, b as Ne, bt as Pe, c as Fe, ct as E, d as Ie, dt as Le, en as Re, et as ze, f as Be, ft as Ve, g as He, gt as Ue, h as We, ht as Ge, i as Ke, in as qe, it as Je, j as Ye, jt as Xe, k as Ze, kt as Qe, l as $e, lt as et, m as tt, mt as nt, n as rt, nn as it, nt as at, o as ot, on as D, ot as st, p as ct, pt as lt, q as ut, qt as O, r as dt, rn as ft, rt as pt, s as mt, sn as ht, st as gt, t as _t, tn as vt, tt as yt, u as bt, ut as xt, v as St, vt as Ct, w as wt, wt as Tt, x as Et, xt as Dt, y as k, yt as Ot, z as kt, zt as At } from "./frameworkLiveTables-CWbTSnjk.js";
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 v, It as ee, J as te, Jt as y, K as ne, Kt as re, L as b, Lt as ie, M as x, Mt as ae, N as S, Nt as oe, O as se, Ot as ce, P as le, Pt as ue, Q as de, Qt as fe, R as pe, Rt as me, S as he, St as ge, T as _e, Tt as ve, U as ye, Ut as be, V as xe, Vt as Se, W as Ce, Wt as we, X as Te, Xt as C, Y as Ee, Yt as De, Z as w, Zt as Oe, _ as ke, _t as Ae, a as je, an as T, at as Me, b as Ne, bt as Pe, c as Fe, ct as E, d as Ie, dt as Le, en as Re, et as ze, f as Be, ft as Ve, g as He, gt as Ue, h as We, ht as Ge, i as Ke, in as qe, it as Je, j as Ye, jt as Xe, k as Ze, kt as Qe, l as $e, lt as et, m as tt, mt as nt, n as rt, nn as it, nt as at, o as ot, on as D, ot as st, p as ct, pt as lt, q as ut, qt as O, r as dt, rn as ft, rt as pt, s as mt, sn as ht, st as gt, t as _t, tn as vt, tt as yt, u as bt, ut as xt, v as St, vt as Ct, w as wt, wt as Tt, x as Et, xt as Dt, y as k, yt as Ot, z as kt, zt as At } from "./frameworkLiveTables-D53uncZH.js";
2
2
  import { a as jt, i as Mt, n as Nt, o as Pt, r as Ft, s as It, t as Lt } from "./wire-B28cPjEp.js";
3
3
  import { Cause as Rt, Chunk as zt, Data as Bt, Effect as A, Exit as Vt, Metric as j, MetricBoundaries as Ht, Option as M, Runtime as Ut, Schedule as Wt, Schema as N, Stream as Gt } from "effect";
4
4
  import { createHash as Kt } from "node:crypto";
@@ -616,7 +616,8 @@ var Xt = (e) => typeof e == "string" && e !== "" ? e : null, Zt = async (e, t, n
616
616
  if (e == null) return e;
617
617
  switch (t) {
618
618
  case "boolean": return n === "postgres" ? e : xr(e);
619
- case "json":
619
+ case "vector": return n === "postgres" ? Sr(e) : e;
620
+ case "json": return n === "postgres" || n === "mysql" || n === "mariadb" ? e : Sr(e);
620
621
  case "array": return n === "postgres" ? e : Sr(e);
621
622
  case "timestamp":
622
623
  case "date": return n === "sqlite" || n === "turso" ? wr(e) : e;
@@ -641,8 +642,9 @@ var Xt = (e) => typeof e == "string" && e !== "" ? e : null, Zt = async (e, t, n
641
642
  }, Dr = (e, t) => {
642
643
  if (e == null) return e;
643
644
  switch (t) {
644
- case "json":
645
- case "array": return typeof e == "string" ? e : JSON.stringify(e);
645
+ case "json": return JSON.stringify(e);
646
+ case "array":
647
+ case "vector": return typeof e == "string" ? e : JSON.stringify(e);
646
648
  default: return e;
647
649
  }
648
650
  }, Or = (e, t, n = ["json", "array"]) => {
@@ -1258,9 +1260,9 @@ var Xt = (e) => typeof e == "string" && e !== "" ? e : null, Zt = async (e, t, n
1258
1260
  return n(r);
1259
1261
  });
1260
1262
  }, Ii = (e, t, n) => {
1261
- let r = [];
1262
- for (let [t, n] of Object.entries(e.fields)) (n.type === "timestamp" || n.type === "date") && r.push(t);
1263
- let i = t.map((e) => {
1263
+ let r = [], i = [];
1264
+ for (let [t, n] of Object.entries(e.fields)) (n.type === "timestamp" || n.type === "date") && r.push(t), n.type === "vector" && i.push(t);
1265
+ let a = t.map((e) => {
1264
1266
  let t = Ii(e.target, e.children, n), r = e.relation.kind === "one", i = Ci(e), a = i ? Br({
1265
1267
  relationName: e.relationName,
1266
1268
  sourceTableName: e.source.tableName,
@@ -1279,11 +1281,12 @@ var Xt = (e) => typeof e == "string" && e !== "" ? e : null, Zt = async (e, t, n
1279
1281
  });
1280
1282
  return (e) => {
1281
1283
  let t = { ...e };
1284
+ for (let e of i) e in t && (t[e] = Tr(t[e], "vector", n));
1282
1285
  for (let e of r) {
1283
1286
  let r = t[e];
1284
1287
  typeof r == "string" && (t[e] = Ni(r, n));
1285
1288
  }
1286
- for (let e of i) {
1289
+ for (let e of a) {
1287
1290
  let n = t[e.name];
1288
1291
  if (n == null) {
1289
1292
  t[e.name] = e.isSingle ? null : [];
@@ -1571,76 +1574,94 @@ var Xt = (e) => typeof e == "string" && e !== "" ? e : null, Zt = async (e, t, n
1571
1574
  "serviceAccount",
1572
1575
  "apiKey",
1573
1576
  "system"
1574
- ]),
1575
- displayName: T().nullable(),
1577
+ ]).safe(),
1578
+ displayName: T().nullable().sensitive("fullName"),
1576
1579
  createdAt: D().default("now")
1577
- }), Oa = (e, t) => ({
1580
+ }), Oa = (e, t) => {
1581
+ let n = (e) => {
1582
+ if (typeof e != "string" || !/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)$/.test(e)) return null;
1583
+ let [t = "", n = ""] = e.replace(/^[+-]/, "").split("."), r = t.replace(/^0+/, "") || "0";
1584
+ return {
1585
+ negative: e.startsWith("-") && /[1-9]/.test(r + n),
1586
+ whole: r,
1587
+ fraction: n
1588
+ };
1589
+ }, r = n(e), i = n(t);
1590
+ if (!r || !i) return null;
1591
+ if (r.negative !== i.negative) return r.negative ? -1 : 1;
1592
+ let a = r.whole.length - i.whole.length;
1593
+ if (a === 0 && (a = r.whole === i.whole ? 0 : r.whole > i.whole ? 1 : -1), a === 0) {
1594
+ let e = Math.max(r.fraction.length, i.fraction.length), t = r.fraction.padEnd(e, "0"), n = i.fraction.padEnd(e, "0");
1595
+ a = t === n ? 0 : t > n ? 1 : -1;
1596
+ }
1597
+ return a === 0 ? 0 : (a > 0 ? 1 : -1) * (r.negative ? -1 : 1);
1598
+ }, ka = (e, t) => ({
1578
1599
  column: e,
1579
1600
  op: "eq",
1580
1601
  value: t
1581
- }), ka = (e, t) => ({
1602
+ }), Aa = (e, t) => ({
1582
1603
  column: e,
1583
1604
  op: "neq",
1584
1605
  value: t
1585
- }), Aa = (e, t) => ({
1606
+ }), ja = (e, t) => ({
1586
1607
  column: e,
1587
1608
  op: "gt",
1588
1609
  value: t
1589
- }), ja = (e, t) => ({
1610
+ }), Ma = (e, t) => ({
1590
1611
  column: e,
1591
1612
  op: "gte",
1592
1613
  value: t
1593
- }), Ma = (e, t) => ({
1614
+ }), Na = (e, t) => ({
1594
1615
  column: e,
1595
1616
  op: "lt",
1596
1617
  value: t
1597
- }), Na = (e, t) => ({
1618
+ }), Pa = (e, t) => ({
1598
1619
  column: e,
1599
1620
  op: "lte",
1600
1621
  value: t
1601
- }), Pa = (e, t) => ({
1622
+ }), Fa = (e, t) => ({
1602
1623
  column: e,
1603
1624
  op: "in",
1604
1625
  value: t
1605
- }), Fa = (e, t) => ({
1626
+ }), Ia = (e, t) => ({
1606
1627
  column: e,
1607
1628
  op: "notIn",
1608
1629
  value: t
1609
- }), Ia = (e, t) => ({
1630
+ }), La = (e, t) => ({
1610
1631
  column: e,
1611
1632
  op: "contains",
1612
1633
  value: t
1613
- }), La = (e, t) => ({
1634
+ }), Ra = (e, t) => ({
1614
1635
  column: e,
1615
1636
  op: "startsWith",
1616
1637
  value: t
1617
- }), Ra = (e, t) => ({
1638
+ }), za = (e, t) => ({
1618
1639
  column: e,
1619
1640
  op: "arrayContains",
1620
1641
  value: t
1621
- }), za = (e, t) => ({
1642
+ }), Ba = (e, t) => ({
1622
1643
  column: e,
1623
1644
  op: "arrayOverlaps",
1624
1645
  value: t
1625
- }), Ba = (e, t) => ({
1646
+ }), Va = (e, t) => ({
1626
1647
  column: e,
1627
1648
  op: "arrayHas",
1628
1649
  value: t
1629
- }), Va = {
1650
+ }), Ha = {
1630
1651
  column: "id",
1631
1652
  op: "in",
1632
1653
  value: []
1633
- }, Ha = (e) => ({
1654
+ }, Ua = (e) => ({
1634
1655
  column: e,
1635
1656
  op: "isNull"
1636
- }), Ua = (e) => ({
1657
+ }), Wa = (e) => ({
1637
1658
  column: e,
1638
1659
  op: "isNotNull"
1639
- }), Wa = (e, t) => ({
1660
+ }), Ga = (e, t) => ({
1640
1661
  column: e,
1641
1662
  op: "spatial",
1642
1663
  value: t
1643
- }), Ga = (...e) => ({ and: e }), Ka = (...e) => ({ or: e }), qa = (e) => ({ not: e }), Ja = (e, ...t) => {
1664
+ }), Ka = (...e) => ({ and: e }), qa = (...e) => ({ or: e }), Ja = (e) => ({ not: e }), Ya = (e, ...t) => {
1644
1665
  if (t.length === 0) throw Error(`jsonField("${e}"): at least one path segment is required`);
1645
1666
  let n = (n, r) => ({
1646
1667
  column: e,
@@ -1662,83 +1683,83 @@ var Xt = (e) => typeof e == "string" && e !== "" ? e : null, Zt = async (e, t, n
1662
1683
  isNull: () => n("isNull"),
1663
1684
  isNotNull: () => n("isNotNull")
1664
1685
  };
1665
- }, Ya = (e) => "descriptor" in e ? e.descriptor : e, Xa = (e, t) => ({
1686
+ }, Xa = (e) => "descriptor" in e ? e.descriptor : e, Za = (e, t) => ({
1666
1687
  column: e,
1667
1688
  op: "subquery-in",
1668
- subquery: Ya(t)
1669
- }), Za = (e, t) => ({
1689
+ subquery: Xa(t)
1690
+ }), Qa = (e, t) => ({
1670
1691
  column: e,
1671
1692
  op: "subquery-not-in",
1672
- subquery: Ya(t)
1673
- }), Qa = (e) => ({
1674
- op: "exists",
1675
- subquery: Ya(e)
1693
+ subquery: Xa(t)
1676
1694
  }), $a = (e) => ({
1695
+ op: "exists",
1696
+ subquery: Xa(e)
1697
+ }), eo = (e) => ({
1677
1698
  op: "not-exists",
1678
- subquery: Ya(e)
1679
- }), eo = (e, t) => e === t || e instanceof Date && t instanceof Date && e.getTime() === t.getTime(), to = (e, t) => {
1699
+ subquery: Xa(e)
1700
+ }), to = (e, t) => e === t || e instanceof Date && t instanceof Date && e.getTime() === t.getTime(), no = (e, t) => {
1680
1701
  if (e == null || t == null) return null;
1681
1702
  let n = e instanceof Date ? e.getTime() : e, r = t instanceof Date ? t.getTime() : t;
1682
1703
  return typeof n == typeof r ? n === r ? 0 : n > r ? 1 : -1 : null;
1683
- }, no = (e, t, n = null) => {
1704
+ }, ro = (e, t, n = null, r = {}) => {
1684
1705
  if (!t) return !1;
1685
- if ("not" in e) return !no(e.not, t, n);
1706
+ if ("not" in e) return !ro(e.not, t, n, r);
1686
1707
  if ("and" in e) {
1687
- for (let r of e.and) if (!no(r, t, n)) return !1;
1708
+ for (let i of e.and) if (!ro(i, t, n, r)) return !1;
1688
1709
  return !0;
1689
1710
  }
1690
1711
  if ("or" in e) {
1691
- for (let r of e.or) if (no(r, t, n)) return !0;
1712
+ for (let i of e.or) if (ro(i, t, n, r)) return !0;
1692
1713
  return !1;
1693
1714
  }
1694
1715
  if (e.op === "subquery-in" || e.op === "subquery-not-in") {
1695
1716
  if (!n) return !1;
1696
- let r = n.get(e.subquery);
1697
- if (!(r instanceof Set)) return !1;
1698
- let i = t[e.column], a = r.has(i);
1699
- return e.op === "subquery-in" ? a : !a;
1717
+ let i = n.get(e.subquery);
1718
+ if (!(i instanceof Set)) return !1;
1719
+ let a = t[e.column], o = r[e.column]?.type === "decimal" ? [...i].some((e) => Oa(a, e) === 0) : i.has(a);
1720
+ return e.op === "subquery-in" ? o : !o;
1700
1721
  }
1701
1722
  if (e.op === "exists" || e.op === "not-exists") {
1702
1723
  if (!n) return !1;
1703
1724
  let t = n.get(e.subquery), r = typeof t == "number" ? t > 0 : t instanceof Set && t.size > 0;
1704
1725
  return e.op === "exists" ? r : !r;
1705
1726
  }
1706
- let r = e, i = t[r.column];
1707
- switch (r.op) {
1708
- case "eq": return eo(i, r.value);
1709
- case "neq": return !eo(i, r.value);
1710
- case "gt": return (to(i, r.value) ?? -1) > 0;
1711
- case "gte": return (to(i, r.value) ?? -1) >= 0;
1712
- case "lt": return (to(i, r.value) ?? 1) < 0;
1713
- case "lte": return (to(i, r.value) ?? 1) <= 0;
1714
- case "in": return Array.isArray(r.value) && r.value.some((e) => eo(i, e));
1715
- case "notIn": return Array.isArray(r.value) && !r.value.some((e) => eo(i, e));
1716
- case "contains": return typeof i == "string" && typeof r.value == "string" && i.toLowerCase().includes(r.value.toLowerCase());
1717
- case "startsWith": return typeof i == "string" && typeof r.value == "string" && i.startsWith(r.value);
1727
+ let i = e, a = t[i.column], o = r[i.column]?.type === "decimal", s = (e, t) => o && e != null && t != null ? Oa(e, t) === 0 : to(e, t), c = o ? Oa : no;
1728
+ switch (i.op) {
1729
+ case "eq": return s(a, i.value);
1730
+ case "neq": return !s(a, i.value);
1731
+ case "gt": return (c(a, i.value) ?? -1) > 0;
1732
+ case "gte": return (c(a, i.value) ?? -1) >= 0;
1733
+ case "lt": return (c(a, i.value) ?? 1) < 0;
1734
+ case "lte": return (c(a, i.value) ?? 1) <= 0;
1735
+ case "in": return Array.isArray(i.value) && i.value.some((e) => s(a, e));
1736
+ case "notIn": return Array.isArray(i.value) && !i.value.some((e) => s(a, e));
1737
+ case "contains": return typeof a == "string" && typeof i.value == "string" && a.toLowerCase().includes(i.value.toLowerCase());
1738
+ case "startsWith": return typeof a == "string" && typeof i.value == "string" && a.startsWith(i.value);
1718
1739
  case "arrayContains": {
1719
- let e = Array.isArray(i) ? i : [];
1720
- return (Array.isArray(r.value) ? r.value : []).every((t) => e.includes(t));
1740
+ let e = Array.isArray(a) ? a : [];
1741
+ return (Array.isArray(i.value) ? i.value : []).every((t) => e.includes(t));
1721
1742
  }
1722
1743
  case "arrayOverlaps": {
1723
- let e = Array.isArray(i) ? i : [];
1724
- return (Array.isArray(r.value) ? r.value : []).some((t) => e.includes(t));
1744
+ let e = Array.isArray(a) ? a : [];
1745
+ return (Array.isArray(i.value) ? i.value : []).some((t) => e.includes(t));
1725
1746
  }
1726
- case "arrayHas": return Array.isArray(i) && i.includes(r.value);
1727
- case "isNull": return i == null;
1728
- case "isNotNull": return i != null;
1747
+ case "arrayHas": return Array.isArray(a) && a.includes(i.value);
1748
+ case "isNull": return a == null;
1749
+ case "isNotNull": return a != null;
1729
1750
  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.");
1730
1751
  }
1731
- }, ro = function* (e) {
1752
+ }, io = function* (e) {
1732
1753
  if ("not" in e) {
1733
- yield* ro(e.not);
1754
+ yield* io(e.not);
1734
1755
  return;
1735
1756
  }
1736
1757
  if ("and" in e) {
1737
- for (let t of e.and) yield* ro(t);
1758
+ for (let t of e.and) yield* io(t);
1738
1759
  return;
1739
1760
  }
1740
1761
  if ("or" in e) {
1741
- for (let t of e.or) yield* ro(t);
1762
+ for (let t of e.or) yield* io(t);
1742
1763
  return;
1743
1764
  }
1744
1765
  e.op === "subquery-in" || e.op === "subquery-not-in" ? yield {
@@ -1748,46 +1769,46 @@ var Xt = (e) => typeof e == "string" && e !== "" ? e : null, Zt = async (e, t, n
1748
1769
  kind: "exists",
1749
1770
  descriptor: e.subquery
1750
1771
  });
1751
- }, io = function* (e, t = !0) {
1772
+ }, ao = function* (e, t = !0) {
1752
1773
  if ("not" in e) {
1753
- yield* io(e.not, !1);
1774
+ yield* ao(e.not, !1);
1754
1775
  return;
1755
1776
  }
1756
1777
  if ("and" in e) {
1757
- for (let n of e.and) yield* io(n, t);
1778
+ for (let n of e.and) yield* ao(n, t);
1758
1779
  return;
1759
1780
  }
1760
1781
  if ("or" in e) {
1761
- for (let t of e.or) yield* io(t, !1);
1782
+ for (let t of e.or) yield* ao(t, !1);
1762
1783
  return;
1763
1784
  }
1764
1785
  e.op !== "subquery-in" && e.op !== "subquery-not-in" && e.op !== "exists" && e.op !== "not-exists" && (yield {
1765
1786
  ...e,
1766
1787
  conjunctive: t
1767
1788
  });
1768
- }, ao = (e, t) => ({
1789
+ }, oo = (e, t) => ({
1769
1790
  ...t,
1770
1791
  ...e,
1771
1792
  origin: e.origin ?? "injected"
1772
- }), oo = (e, t, n = {}) => ({
1793
+ }), so = (e, t, n = {}) => ({
1773
1794
  table: e,
1774
1795
  op: "insert",
1775
1796
  old: null,
1776
1797
  new: t,
1777
1798
  ...n
1778
- }), so = (e, t, n, r = {}) => ({
1799
+ }), co = (e, t, n, r = {}) => ({
1779
1800
  table: e,
1780
1801
  op: "update",
1781
1802
  old: t,
1782
1803
  new: n,
1783
1804
  ...r
1784
- }), co = (e, t, n = {}) => ({
1805
+ }), lo = (e, t, n = {}) => ({
1785
1806
  table: e,
1786
1807
  op: "delete",
1787
1808
  old: t,
1788
1809
  new: null,
1789
1810
  ...n
1790
- }), lo = (e, t, n = {}) => {
1811
+ }), uo = (e, t, n = {}) => {
1791
1812
  let { at: r = "2026-01-01T00:00:00.000Z", column: i = "deletedAt", ...a } = n;
1792
1813
  return {
1793
1814
  table: e,
@@ -1802,13 +1823,13 @@ var Xt = (e) => typeof e == "string" && e !== "" ? e : null, Zt = async (e, t, n
1802
1823
  },
1803
1824
  ...a
1804
1825
  };
1805
- }, uo = (e) => e == null ? "null" : e instanceof Date ? JSON.stringify(e.toISOString()) : typeof e == "bigint" ? JSON.stringify(e.toString()) : Array.isArray(e) ? `[${e.map(uo).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)}:${uo(t)}`).join(",")}}` : JSON.stringify(e) ?? "null", fo = (e) => Kt("sha256").update([
1826
+ }, fo = (e) => e == null ? "null" : e instanceof Date ? JSON.stringify(e.toISOString()) : typeof e == "bigint" ? JSON.stringify(e.toString()) : Array.isArray(e) ? `[${e.map(fo).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)}:${fo(t)}`).join(",")}}` : JSON.stringify(e) ?? "null", po = (e) => Kt("sha256").update([
1806
1827
  e.pipe,
1807
1828
  e.op,
1808
1829
  e.key,
1809
- uo(e.next),
1810
- uo(e.prev)
1811
- ].join("\0")).digest("hex").slice(0, 32), po = (e, t) => `${e}:${t}`, mo = (e) => {
1830
+ fo(e.next),
1831
+ fo(e.prev)
1832
+ ].join("\0")).digest("hex").slice(0, 32), mo = (e, t) => `${e}:${t}`, ho = (e) => {
1812
1833
  let t = e.lastIndexOf(":");
1813
1834
  if (t <= 0) return null;
1814
1835
  let n = Number(e.slice(t + 1));
@@ -1816,7 +1837,7 @@ var Xt = (e) => typeof e == "string" && e !== "" ? e : null, Zt = async (e, t, n
1816
1837
  digest: e.slice(0, t),
1817
1838
  occurrence: n
1818
1839
  };
1819
- }, ho = class {
1840
+ }, go = class {
1820
1841
  #e = /* @__PURE__ */ new Map();
1821
1842
  #t;
1822
1843
  #n;
@@ -1838,7 +1859,7 @@ var Xt = (e) => typeof e == "string" && e !== "" ? e : null, Zt = async (e, t, n
1838
1859
  }
1839
1860
  seedFromChangeKeys(e, t) {
1840
1861
  for (let n of e) {
1841
- let e = mo(n);
1862
+ let e = ho(n);
1842
1863
  if (e === null) continue;
1843
1864
  let r = this.#e.get(e.digest), i = Math.max(r?.count ?? 0, e.occurrence + 1);
1844
1865
  this.#e.set(e.digest, {
@@ -1859,29 +1880,29 @@ var Xt = (e) => typeof e == "string" && e !== "" ? e : null, Zt = async (e, t, n
1859
1880
  this.#e.delete(e.value);
1860
1881
  }
1861
1882
  }
1862
- }, go = "VOLTRO_CHANGE_CLAIMS_TTL_HOURS", _o = 1, vo = (e = process.env) => {
1863
- let t = Number(e[go]);
1883
+ }, _o = "VOLTRO_CHANGE_CLAIMS_TTL_HOURS", vo = 1, yo = (e = process.env) => {
1884
+ let t = Number(e[_o]);
1864
1885
  return (Number.isFinite(t) && t > 0 ? t : 1) * 2 * 36e5;
1865
- }, yo = new qt(), bo = (e, t) => yo.run(e, t), xo = () => yo.getStore(), So = (e) => {
1866
- let t = e ?? yo.getStore();
1886
+ }, bo = new qt(), xo = (e, t) => bo.run(e, t), So = () => bo.getStore(), Co = (e) => {
1887
+ let t = e ?? bo.getStore();
1867
1888
  return t === void 0 ? {} : {
1868
1889
  ...t.traceId === void 0 ? {} : { traceId: t.traceId },
1869
1890
  ...t.subjectId === void 0 ? {} : { subjectId: t.subjectId },
1870
1891
  ...t.procedure === void 0 ? {} : { procedure: t.procedure },
1871
1892
  ...t.via === void 0 ? {} : { via: t.via }
1872
1893
  };
1873
- }, Co = (e) => {
1874
- let t = yo.getStore();
1875
- return t === void 0 ? e(void 0) : yo.run(t, () => e(t));
1876
- }, wo = 3e4, To = 1e4, K = /* @__PURE__ */ new Map(), q = 0, Eo = (e, t, n) => `${e}\u0000${t}\u0000${String(n)}`, Do = (e) => {
1894
+ }, wo = (e) => {
1895
+ let t = bo.getStore();
1896
+ return t === void 0 ? e(void 0) : bo.run(t, () => e(t));
1897
+ }, To = 3e4, Eo = 1e4, K = /* @__PURE__ */ new Map(), q = 0, Do = (e, t, n) => `${e}\u0000${t}\u0000${String(n)}`, Oo = (e) => {
1877
1898
  for (let [t, n] of K) {
1878
- let r = n.filter((t) => e - t.at < wo);
1899
+ let r = n.filter((t) => e - t.at < To);
1879
1900
  q -= n.length - r.length, r.length === 0 ? K.delete(t) : r.length !== n.length && K.set(t, r);
1880
1901
  }
1881
- }, Oo = (e, t) => {
1902
+ }, ko = (e, t) => {
1882
1903
  if (t.traceId === void 0 && t.subjectId === void 0 && t.procedure === void 0) return;
1883
1904
  let n = Date.now();
1884
- if (q >= To && Do(n), q >= To) return;
1905
+ if (q >= Eo && Oo(n), q >= Eo) return;
1885
1906
  let r = K.get(e);
1886
1907
  r === void 0 ? K.set(e, [{
1887
1908
  attribution: t,
@@ -1890,38 +1911,38 @@ var Xt = (e) => typeof e == "string" && e !== "" ? e : null, Zt = async (e, t, n
1890
1911
  attribution: t,
1891
1912
  at: n
1892
1913
  }), q += 1;
1893
- }, ko = (e) => {
1914
+ }, Ao = (e) => {
1894
1915
  let t = K.get(e);
1895
1916
  if (t === void 0 || t.length === 0) return;
1896
1917
  let n = t.shift();
1897
- if (--q, t.length === 0 && K.delete(e), !(Date.now() - n.at >= wo)) return n.attribution;
1898
- }, Ao = (e) => (K.get(e)?.length ?? 0) > 0, J = /* @__PURE__ */ new Map(), jo = /* @__PURE__ */ new Map(), Mo = /* @__PURE__ */ new Map(), No = 250, Po = (e) => {
1899
- let t = jo.get(e);
1918
+ if (--q, t.length === 0 && K.delete(e), !(Date.now() - n.at >= To)) return n.attribution;
1919
+ }, jo = (e) => (K.get(e)?.length ?? 0) > 0, J = /* @__PURE__ */ new Map(), Mo = /* @__PURE__ */ new Map(), No = /* @__PURE__ */ new Map(), Po = 250, Fo = (e) => {
1920
+ let t = Mo.get(e);
1900
1921
  if (t === void 0) return;
1901
- jo.delete(e);
1902
- let n = Mo.get(e);
1903
- n !== void 0 && (clearTimeout(n), Mo.delete(e));
1922
+ Mo.delete(e);
1923
+ let n = No.get(e);
1924
+ n !== void 0 && (clearTimeout(n), No.delete(e));
1904
1925
  for (let e of t) e();
1905
- }, Fo = (e) => {
1906
- J.set(e, (J.get(e) ?? 0) + 1);
1907
1926
  }, Io = (e) => {
1927
+ J.set(e, (J.get(e) ?? 0) + 1);
1928
+ }, Lo = (e) => {
1908
1929
  let t = (J.get(e) ?? 0) - 1;
1909
1930
  if (t > 0) {
1910
1931
  J.set(e, t);
1911
1932
  return;
1912
1933
  }
1913
- J.delete(e), Po(e);
1914
- }, Lo = (e, t, n, r) => {
1915
- let i = n == null ? void 0 : Eo(e, t, n), a = () => r(i === void 0 ? void 0 : ko(i));
1934
+ J.delete(e), Fo(e);
1935
+ }, Ro = (e, t, n, r) => {
1936
+ let i = n == null ? void 0 : Do(e, t, n), a = () => r(i === void 0 ? void 0 : Ao(i));
1916
1937
  if (i === void 0) {
1917
1938
  a();
1918
1939
  return;
1919
1940
  }
1920
- if (Ao(i)) {
1941
+ if (jo(i)) {
1921
1942
  a();
1922
1943
  return;
1923
1944
  }
1924
- let o = jo.get(e);
1945
+ let o = Mo.get(e);
1925
1946
  if (o === void 0 && (J.get(e) ?? 0) === 0) {
1926
1947
  a();
1927
1948
  return;
@@ -1930,35 +1951,35 @@ var Xt = (e) => typeof e == "string" && e !== "" ? e : null, Zt = async (e, t, n
1930
1951
  o.push(a);
1931
1952
  return;
1932
1953
  }
1933
- jo.set(e, [a]);
1934
- let s = setTimeout(() => Po(e), No);
1935
- typeof s == "object" && typeof s.unref == "function" && s.unref(), Mo.set(e, s);
1936
- }, Ro = () => {
1954
+ Mo.set(e, [a]);
1955
+ let s = setTimeout(() => Fo(e), Po);
1956
+ typeof s == "object" && typeof s.unref == "function" && s.unref(), No.set(e, s);
1957
+ }, zo = () => {
1937
1958
  K.clear(), q = 0, J.clear();
1938
- for (let e of Mo.values()) clearTimeout(e);
1939
- Mo.clear(), jo.clear();
1940
- }, zo = () => q, Bo = 64, Vo = "\0", Ho = 32, Uo = (e, ...t) => `${e}_${Kt("sha256").update(t.map(String).join(Vo)).digest("hex").slice(0, Ho)}`, Wo = (e) => e.length + 1 + Ho, Y = /* @__PURE__ */ new Map(), Go = (e, t) => {
1959
+ for (let e of No.values()) clearTimeout(e);
1960
+ No.clear(), Mo.clear();
1961
+ }, Bo = () => q, Vo = 64, Ho = "\0", Uo = 32, Wo = (e, ...t) => `${e}_${Kt("sha256").update(t.map(String).join(Ho)).digest("hex").slice(0, Uo)}`, Go = (e) => e.length + 1 + Uo, Y = /* @__PURE__ */ new Map(), Ko = (e, t) => {
1941
1962
  Y.set(e, {
1942
1963
  recorder: t.recorder,
1943
1964
  tables: new Set(t.tables),
1944
1965
  ownTables: new Set(t.ownTables)
1945
1966
  });
1946
- }, Ko = (e) => {
1967
+ }, qo = (e) => {
1947
1968
  Y.delete(e);
1948
- }, qo = () => Y.clear(), Jo = new qt(), Yo = (e) => Jo.run({ n: 1 }, e), Xo = (e) => A.suspend(() => {
1949
- let t = Jo.getStore();
1969
+ }, Jo = () => Y.clear(), Yo = new qt(), Xo = (e) => Yo.run({ n: 1 }, e), Zo = (e) => A.suspend(() => {
1970
+ let t = Yo.getStore();
1950
1971
  if (t !== void 0) return t.n += 1, A.ensuring(e, A.sync(() => {
1951
1972
  --t.n;
1952
1973
  }));
1953
1974
  let n = { n: 1 };
1954
- return Jo.enterWith(n), A.ensuring(e, A.sync(() => {
1975
+ return Yo.enterWith(n), A.ensuring(e, A.sync(() => {
1955
1976
  --n.n;
1956
1977
  }));
1957
- }), Zo = () => (Jo.getStore()?.n ?? 0) > 0, Qo = (e) => {
1958
- if (Y.size === 0 || (Jo.getStore()?.n ?? 0) > 0) return !1;
1978
+ }), Qo = () => (Yo.getStore()?.n ?? 0) > 0, $o = (e) => {
1979
+ if (Y.size === 0 || (Yo.getStore()?.n ?? 0) > 0) return !1;
1959
1980
  for (let t of Y.values()) if (!t.ownTables.has(e) && t.tables.has(e)) return !0;
1960
1981
  return !1;
1961
- }, $o = async (e, t) => {
1982
+ }, es = async (e, t) => {
1962
1983
  if (Y.size !== 0) {
1963
1984
  for (let [n, r] of Y.entries()) if (!r.ownTables.has(t.table) && r.tables.has(t.table)) try {
1964
1985
  await r.recorder(e, t);
@@ -1967,54 +1988,54 @@ var Xt = (e) => typeof e == "string" && e !== "" ? e : null, Zt = async (e, t, n
1967
1988
  throw r === void 0 ? e : Error(`write recorder '${n}' failed while recording a ${t.op} on '${t.table}': ${r}`, { cause: e });
1968
1989
  }
1969
1990
  }
1970
- }, es = Ht.exponential({
1991
+ }, ts = Ht.exponential({
1971
1992
  start: 5e-4,
1972
1993
  factor: 2,
1973
1994
  count: 16
1974
- }), ts = j.counter("voltro_db_queries_total", { description: "Database operations executed, by dialect and operation kind." }), ns = j.histogram("voltro_db_query_duration_seconds", es, "Database operation duration in seconds, by dialect and operation kind."), rs = j.counter("voltro_db_errors_total", { description: "Database operations that threw, by dialect and operation kind." }), is = j.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." }), as = j.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." }), os = [], ss = /* @__PURE__ */ new Map(), cs = /* @__PURE__ */ new Map(), ls = /* @__PURE__ */ new Map(), us = (e, t) => {
1975
- let n = `${e}\u0000${t}`, r = ss.get(n);
1995
+ }), ns = j.counter("voltro_db_queries_total", { description: "Database operations executed, by dialect and operation kind." }), rs = j.histogram("voltro_db_query_duration_seconds", ts, "Database operation duration in seconds, by dialect and operation kind."), is = j.counter("voltro_db_errors_total", { description: "Database operations that threw, by dialect and operation kind." }), as = j.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." }), os = j.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." }), ss = [], cs = /* @__PURE__ */ new Map(), ls = /* @__PURE__ */ new Map(), us = /* @__PURE__ */ new Map(), ds = (e, t) => {
1996
+ let n = `${e}\u0000${t}`, r = cs.get(n);
1976
1997
  if (r !== void 0) return r;
1977
1998
  let i = (n) => j.tagged(j.tagged(n, "dialect", e), "op", t), a = {
1978
- count: i(ts),
1979
- duration: i(ns),
1980
- errors: i(rs)
1999
+ count: i(ns),
2000
+ duration: i(rs),
2001
+ errors: i(is)
1981
2002
  };
1982
- return ss.set(n, a), a;
1983
- }, ds = () => {
1984
- ss.clear(), cs.clear(), ls.clear();
1985
- }, fs = () => ss.size + cs.size + ls.size, ps = /* @__PURE__ */ new Map(), ms = (e, t) => {
1986
- let n = Math.max(0, (ps.get(e) ?? 0) + t);
1987
- n === 0 ? ps.delete(e) : ps.set(e, n);
1988
- let r = cs.get(e);
1989
- r === void 0 && (r = j.tagged(is, "dialect", e), cs.set(e, r)), r.unsafeUpdate(n, os);
1990
- }, hs = (e) => ps.get(e) ?? 0, gs = (e) => {
1991
- let t = us(String(e.dialect), e.op);
1992
- t.count.unsafeUpdate(1, os), t.duration.unsafeUpdate(e.durationMs / 1e3, os), e.status === "error" && t.errors.unsafeUpdate(1, os);
1993
- }, _s = async (e, t, n) => {
2003
+ return cs.set(n, a), a;
2004
+ }, fs = () => {
2005
+ cs.clear(), ls.clear(), us.clear();
2006
+ }, ps = () => cs.size + ls.size + us.size, ms = /* @__PURE__ */ new Map(), hs = (e, t) => {
2007
+ let n = Math.max(0, (ms.get(e) ?? 0) + t);
2008
+ n === 0 ? ms.delete(e) : ms.set(e, n);
2009
+ let r = ls.get(e);
2010
+ r === void 0 && (r = j.tagged(as, "dialect", e), ls.set(e, r)), r.unsafeUpdate(n, ss);
2011
+ }, gs = (e) => ms.get(e) ?? 0, _s = (e) => {
2012
+ let t = ds(String(e.dialect), e.op);
2013
+ t.count.unsafeUpdate(1, ss), t.duration.unsafeUpdate(e.durationMs / 1e3, ss), e.status === "error" && t.errors.unsafeUpdate(1, ss);
2014
+ }, vs = async (e, t, n) => {
1994
2015
  let r = performance.now(), i = String(e);
1995
- ms(i, 1);
2016
+ hs(i, 1);
1996
2017
  let a = "ok";
1997
2018
  try {
1998
2019
  return await n();
1999
2020
  } catch (e) {
2000
2021
  throw a = "error", e;
2001
2022
  } finally {
2002
- ms(i, -1), gs({
2023
+ hs(i, -1), _s({
2003
2024
  dialect: e,
2004
2025
  op: t,
2005
2026
  durationMs: performance.now() - r,
2006
2027
  status: a
2007
2028
  });
2008
2029
  }
2009
- }, vs = 3e5, ys = (e) => {
2030
+ }, ys = 3e5, bs = (e) => {
2010
2031
  if (e == null || e === "") return;
2011
2032
  let t = Number(e);
2012
2033
  return Number.isFinite(t) && t >= 0 ? Math.floor(t) : void 0;
2013
- }, bs = (e, t = process.env) => ys(t.VOLTRO_DB_EAGER_FALLBACK_WARN_INTERVAL_MS) ?? ys(e) ?? 3e5, xs = (e, t = {}) => {
2014
- let n = bs(t.warnIntervalMs), r = t.now ?? (() => Date.now()), i = /* @__PURE__ */ new Map();
2034
+ }, xs = (e, t = process.env) => bs(t.VOLTRO_DB_EAGER_FALLBACK_WARN_INTERVAL_MS) ?? bs(e) ?? 3e5, Ss = (e, t = {}) => {
2035
+ let n = xs(t.warnIntervalMs), r = t.now ?? (() => Date.now()), i = /* @__PURE__ */ new Map();
2015
2036
  return (t) => {
2016
- let a = `${t.dialect} ${t.reason}`, o = ls.get(a);
2017
- o === void 0 && (o = j.tagged(j.tagged(as, "dialect", String(t.dialect)), "reason", t.reason), ls.set(a, o)), o.unsafeUpdate(1, os);
2037
+ let a = `${t.dialect} ${t.reason}`, o = us.get(a);
2038
+ o === void 0 && (o = j.tagged(j.tagged(os, "dialect", String(t.dialect)), "reason", t.reason), us.set(a, o)), o.unsafeUpdate(1, ss);
2018
2039
  let s = `${t.table}\u0000${t.reason}`, c = i.get(s), l = c === void 0 || n > 0 && r() - c >= n, u = {
2019
2040
  table: t.table,
2020
2041
  dialect: String(t.dialect),
@@ -2028,10 +2049,10 @@ var Xt = (e) => typeof e == "string" && e !== "" ? e : null, Zt = async (e, t, n
2028
2049
  }
2029
2050
  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);
2030
2051
  };
2031
- }, Ss = (e) => {
2052
+ }, Cs = (e) => {
2032
2053
  if (Vt.isSuccess(e)) return e.value;
2033
2054
  throw Rt.squash(e.cause);
2034
- }, Cs = "10 millis", ws = 3, Ts = async (e) => {
2055
+ }, ws = "10 millis", Ts = 3, Es = (e) => Wt.exponential(ws).pipe(Wt.compose(Wt.recurs(Ts)), Wt.whileInput(e)), Ds = async (e) => {
2035
2056
  let t = 0, n = A.suspend(() => {
2036
2057
  let n = ++t;
2037
2058
  return e.withTransaction(A.flatMap(A.serviceOption(Jt), (t) => {
@@ -2042,10 +2063,10 @@ var Xt = (e) => typeof e == "string" && e !== "" ? e : null, Zt = async (e, t, n
2042
2063
  });
2043
2064
  return e.prepare === void 0 ? i : A.flatMap(e.prepare(r), () => i);
2044
2065
  })).pipe(A.catchAllDefect((t) => e.isRetryable(t) ? A.fail(t) : A.die(t)));
2045
- }), r = Wt.exponential(Cs).pipe(Wt.compose(Wt.recurs(ws)), Wt.whileInput(e.isRetryable)), i = n.pipe(A.retry(r), A.withSpan(e.span.name, { attributes: { ...e.span.attributes } }));
2046
- return _s(e.dialect, "transaction", async () => Ss(await e.runPromiseExit(e.wrapProgram === void 0 ? i : e.wrapProgram(i))));
2047
- }, Es = async (e) => {
2048
- let t = xo(), n = t === void 0 ? (e) => e() : (e) => bo(t, e), r = await Ts({
2066
+ }).pipe(A.retry(Es(e.isRetryable)), A.withSpan(e.span.name, { attributes: { ...e.span.attributes } }));
2067
+ return vs(e.dialect, "transaction", async () => Cs(await e.runPromiseExit(e.wrapProgram === void 0 ? n : e.wrapProgram(n))));
2068
+ }, Os = async (e) => {
2069
+ let t = So(), n = t === void 0 ? (e) => e() : (e) => xo(t, e), r = await Ds({
2049
2070
  ...e,
2050
2071
  body: (r) => {
2051
2072
  let i = e.makeView(r, t);
@@ -2056,50 +2077,50 @@ var Xt = (e) => typeof e == "string" && e !== "" ? e : null, Zt = async (e, t, n
2056
2077
  }
2057
2078
  });
2058
2079
  return r.view.commitEvents(), r.result;
2059
- }, Ds = /* @__PURE__ */ new Set([
2080
+ }, ks = /* @__PURE__ */ new Set([
2060
2081
  "1213",
2061
2082
  "ER_LOCK_DEADLOCK",
2062
2083
  "1205",
2063
2084
  "ER_LOCK_WAIT_TIMEOUT",
2064
2085
  "1020",
2065
2086
  "ER_CHECKREAD"
2066
- ]), Os = /* @__PURE__ */ new Set(["40001", "40P01"]), ks = /* @__PURE__ */ new Set(["1205"]), As = /* @__PURE__ */ new Set([
2087
+ ]), As = /* @__PURE__ */ new Set(["40001", "40P01"]), js = /* @__PURE__ */ new Set(["1205"]), Ms = /* @__PURE__ */ new Set([
2067
2088
  "SQLITE_BUSY",
2068
2089
  "5",
2069
2090
  "SQLITE_LOCKED",
2070
2091
  "6"
2071
- ]), js = /write-write conflict|write-read conflict|database is locked|table is locked|database is busy/i, Ms = /* @__PURE__ */ new Set([
2092
+ ]), Ns = /write-write conflict|write-read conflict|database is locked|table is locked|database is busy/i, Ps = /* @__PURE__ */ new Set([
2072
2093
  1213,
2073
2094
  1205,
2074
2095
  1020
2075
- ]), Ns = /* @__PURE__ */ new Set([
2076
- ...Ds,
2077
- ...Os,
2096
+ ]), Fs = /* @__PURE__ */ new Set([
2078
2097
  ...ks,
2079
- ...As
2080
- ]), Ps = (e) => bn(e).some(Fs), Fs = (e) => {
2098
+ ...As,
2099
+ ...js,
2100
+ ...Ms
2101
+ ]), Is = (e) => bn(e).some(Ls), Ls = (e) => {
2081
2102
  let t = e;
2082
2103
  for (let e = 0; e < 6 && typeof t == "object" && t; e++) {
2083
2104
  let e = t;
2084
- if (typeof e.errno == "number" && Ms.has(e.errno) || typeof e.number == "number" && ks.has(String(e.number)) || typeof e.code == "string" && Ns.has(e.code) || typeof e.sqlState == "string" && Os.has(e.sqlState) || typeof e.message == "string" && js.test(e.message)) return !0;
2105
+ if (typeof e.errno == "number" && Ps.has(e.errno) || typeof e.number == "number" && js.has(String(e.number)) || typeof e.code == "string" && Fs.has(e.code) || typeof e.sqlState == "string" && As.has(e.sqlState) || typeof e.message == "string" && Ns.test(e.message)) return !0;
2085
2106
  t = e.cause;
2086
2107
  }
2087
2108
  return !1;
2088
- }, Is = "voltro/expires", Ls = () => xt({
2089
- id: Is,
2109
+ }, Rs = "voltro/expires", zs = () => xt({
2110
+ id: Rs,
2090
2111
  fields: { expiresAt: D().nullable() },
2091
2112
  behaviors: { defaultWhere: () => "expiresAt IS NULL OR expiresAt > now()" }
2092
- }), Rs = "voltro/localFirst", zs = () => xt({
2093
- id: Rs,
2113
+ }), Bs = "voltro/localFirst", Vs = () => xt({
2114
+ id: Bs,
2094
2115
  fields: {}
2095
- }), Bs = (e) => e.appliedMixins.some((e) => e.id === Rs), Vs = (e) => {
2116
+ }), Hs = (e) => e.appliedMixins.some((e) => e.id === Bs), Us = (e) => {
2096
2117
  let t = [];
2097
- for (let n of Object.values(e)) Bs(n) && t.push(n.tableName);
2118
+ for (let n of Object.values(e)) Hs(n) && t.push(n.tableName);
2098
2119
  return t;
2099
- }, Hs = class extends Bt.TaggedError("TableStreamError") {}, Us = 1e3, Ws = (e, t, n, r) => {
2120
+ }, Ws = class extends Bt.TaggedError("TableStreamError") {}, Gs = 1e3, Ks = (e, t, n, r) => {
2100
2121
  let i = M.match(r, {
2101
2122
  onNone: () => e.where,
2102
- onSome: (n) => e.where ? Ga(e.where, Aa(t, n)) : Aa(t, n)
2123
+ onSome: (n) => e.where ? Ka(e.where, ja(t, n)) : ja(t, n)
2103
2124
  });
2104
2125
  return {
2105
2126
  table: e.table,
@@ -2114,19 +2135,19 @@ var Xt = (e) => typeof e == "string" && e !== "" ? e : null, Zt = async (e, t, n
2114
2135
  ...e.includeDeleted === void 0 ? {} : { includeDeleted: e.includeDeleted },
2115
2136
  ...e.crossTenant === void 0 ? {} : { crossTenant: e.crossTenant }
2116
2137
  };
2117
- }, Gs = (e, t) => {
2118
- let n = t.pk ?? "id", r = t.chunkSize ?? Us;
2138
+ }, qs = (e, t) => {
2139
+ let n = t.pk ?? "id", r = t.chunkSize ?? Gs;
2119
2140
  return Gt.paginateChunkEffect(M.none(), (i) => {
2120
2141
  let a = A.tryPromise({
2121
- try: () => e.query(Ws(t, n, r, i)),
2122
- catch: (e) => new Hs({
2142
+ try: () => e.query(Ks(t, n, r, i)),
2143
+ catch: (e) => new Ws({
2123
2144
  table: t.table,
2124
2145
  cause: e
2125
2146
  })
2126
2147
  });
2127
2148
  return (t.retry ? a.pipe(A.retry(t.retry)) : a).pipe(A.map((e) => [zt.fromIterable(e), e.length === r && e.length > 0 ? M.some(M.some(e[e.length - 1][n])) : M.none()]));
2128
2149
  });
2129
- }, Ks = (e) => {
2150
+ }, Js = (e) => {
2130
2151
  let t = e.alpha ?? .5;
2131
2152
  if (t < 0 || t > 1) throw Error(`hybridSearch: alpha must be in [0, 1], got ${t}`);
2132
2153
  return (n) => {
@@ -2153,14 +2174,14 @@ var Xt = (e) => typeof e == "string" && e !== "" ? e : null, Zt = async (e, t, n
2153
2174
  }
2154
2175
  };
2155
2176
  };
2156
- }, qs = async (e, t) => {
2177
+ }, Ys = async (e, t) => {
2157
2178
  let n = e.as ?? "embedding", r = t.row[e.from];
2158
2179
  if (typeof r != "string" || r.length === 0) return {};
2159
2180
  let i = await t.embed(r);
2160
2181
  return { [n]: i };
2161
- }, Js = (e) => {
2182
+ }, Xs = (e) => {
2162
2183
  if (!Number.isInteger(e.dimensions) || e.dimensions <= 0) throw Error(`vectorEmbedding: dimensions must be a positive integer, got ${String(e.dimensions)}.`);
2163
- let t = e.as ?? "embedding", n = (t) => qs(e, t);
2184
+ let t = e.as ?? "embedding", n = (t) => Ys(e, t);
2164
2185
  return xt({
2165
2186
  id: "voltro/vectorEmbedding",
2166
2187
  fields: { [t]: ht(e.dimensions) },
@@ -2178,19 +2199,19 @@ var Xt = (e) => typeof e == "string" && e !== "" ? e : null, Zt = async (e, t, n
2178
2199
  beforeUpdate: n
2179
2200
  }
2180
2201
  });
2181
- }, Ys = 63, Xs = "br_pr", X = class extends Error {
2202
+ }, Zs = 63, Qs = "br_pr", X = class extends Error {
2182
2203
  _tag = "BranchNameInvalid";
2183
2204
  constructor(e) {
2184
2205
  super(e), this.name = "BranchNameInvalid";
2185
2206
  }
2186
- }, Zs = (e, t) => {
2207
+ }, $s = (e, t) => {
2187
2208
  if (!Number.isInteger(t) || t < 0) throw new X(`prNumber must be a non-negative integer, got ${String(t)}`);
2188
2209
  let n = ni(e);
2189
2210
  if (n.replace(/_/g, "") === "") throw new X(`app slug '${e}' has no usable identifier characters`);
2190
- let r = `${Xs}${t}_${n}`;
2191
- if (r.length > Ys) throw new X(`branch namespace '${r}' exceeds the ${Ys}-byte identifier limit — use a shorter app slug`);
2211
+ let r = `${Qs}${t}_${n}`;
2212
+ if (r.length > Zs) throw new X(`branch namespace '${r}' exceeds the ${Zs}-byte identifier limit — use a shorter app slug`);
2192
2213
  return r;
2193
- }, Qs = (e) => e.startsWith(Xs), $s = {
2214
+ }, ec = (e) => e.startsWith(Qs), tc = {
2194
2215
  requested: {
2195
2216
  provision: "provisioning",
2196
2217
  destroy: "destroying"
@@ -2209,18 +2230,18 @@ var Xt = (e) => typeof e == "string" && e !== "" ? e : null, Zt = async (e, t, n
2209
2230
  fail: "failed"
2210
2231
  },
2211
2232
  destroyed: {}
2212
- }, ec = class extends Error {
2233
+ }, nc = class extends Error {
2213
2234
  from;
2214
2235
  event;
2215
2236
  _tag = "BranchTransitionInvalid";
2216
2237
  constructor(e, t) {
2217
2238
  super(`invalid branch transition: ${e} --${t}-->`), this.from = e, this.event = t, this.name = "BranchTransitionInvalid";
2218
2239
  }
2219
- }, tc = (e, t) => {
2220
- let n = $s[e][t];
2221
- if (n === void 0) throw new ec(e, t);
2240
+ }, rc = (e, t) => {
2241
+ let n = tc[e][t];
2242
+ if (n === void 0) throw new nc(e, t);
2222
2243
  return n;
2223
- }, nc = (e, t, n, r, i = [], a = []) => {
2244
+ }, ic = (e, t, n, r, i = [], a = []) => {
2224
2245
  if (n === "copy" && (r === void 0 || r === "")) throw new X("seed 'copy' requires a parentNamespace to snapshot from");
2225
2246
  let o = [{
2226
2247
  kind: "create-namespace",
@@ -2250,13 +2271,13 @@ var Xt = (e) => typeof e == "string" && e !== "" ? e : null, Zt = async (e, t, n
2250
2271
  kind: "seed",
2251
2272
  detail: `run boot seeds into ${e}`
2252
2273
  }), o;
2253
- }, rc = (e) => {
2254
- if (!Qs(e)) throw new X(`refusing to plan teardown of '${e}' — not a branch namespace`);
2274
+ }, ac = (e) => {
2275
+ if (!ec(e)) throw new X(`refusing to plan teardown of '${e}' — not a branch namespace`);
2255
2276
  return [{
2256
2277
  kind: "drop-namespace",
2257
2278
  detail: e
2258
2279
  }];
2259
- }, ic = (e) => {
2280
+ }, oc = (e) => {
2260
2281
  if (e === void 0 || e === "") return !1;
2261
2282
  try {
2262
2283
  let t = new URL(e).hostname.toLowerCase();
@@ -2264,27 +2285,27 @@ var Xt = (e) => typeof e == "string" && e !== "" ? e : null, Zt = async (e, t, n
2264
2285
  } catch {
2265
2286
  return /\bneon\.(tech|build)\b/i.test(e);
2266
2287
  }
2267
- }, ac = (e) => e.prefer === void 0 ? e.seed === "copy" && ic(e.dbUrl) ? "neon-cow" : "namespace" : e.prefer, oc = (e, t = {}) => [{
2288
+ }, sc = (e) => e.prefer === void 0 ? e.seed === "copy" && oc(e.dbUrl) ? "neon-cow" : "namespace" : e.prefer, cc = (e, t = {}) => [{
2268
2289
  kind: "neon-branch-create",
2269
2290
  detail: `${t.parentBranch ?? "main"} → ${e} (copy-on-write)`
2270
- }], sc = (e) => {
2271
- if (!Qs(e)) throw new X(`refusing to plan teardown of '${e}' — not a branch namespace`);
2291
+ }], lc = (e) => {
2292
+ if (!ec(e)) throw new X(`refusing to plan teardown of '${e}' — not a branch namespace`);
2272
2293
  return [{
2273
2294
  kind: "neon-branch-delete",
2274
2295
  detail: e
2275
2296
  }];
2276
- }, cc = (e) => e.mechanism === "neon-cow" ? oc(e.branchId, e.neonParentBranch === void 0 ? {} : { parentBranch: e.neonParentBranch }) : nc(e.branchId, e.tableNames, e.seed, e.parentNamespace, e.foreignKeys, e.indexNames), lc = (e, t) => e === "neon-cow" ? sc(t) : rc(t), uc = (e, t, n) => {
2297
+ }, uc = (e) => e.mechanism === "neon-cow" ? cc(e.branchId, e.neonParentBranch === void 0 ? {} : { parentBranch: e.neonParentBranch }) : ic(e.branchId, e.tableNames, e.seed, e.parentNamespace, e.foreignKeys, e.indexNames), dc = (e, t) => e === "neon-cow" ? lc(t) : ac(t), fc = (e, t, n) => {
2277
2298
  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);
2278
2299
  return {
2279
2300
  evict: i,
2280
2301
  rejectNew: r.filter((e) => !a.has(e.namespace)).length >= t.maxBranches
2281
2302
  };
2282
- }, dc = async (e, t) => {
2283
- let n = Zs(e.appSlug, e.prNumber), r = ac({
2303
+ }, pc = async (e, t) => {
2304
+ let n = $s(e.appSlug, e.prNumber), r = sc({
2284
2305
  seed: e.seed,
2285
2306
  ...e.dbUrl === void 0 ? {} : { dbUrl: e.dbUrl },
2286
2307
  ...e.prefer === void 0 ? {} : { prefer: e.prefer }
2287
- }), i = cc({
2308
+ }), i = uc({
2288
2309
  mechanism: r,
2289
2310
  branchId: n,
2290
2311
  tableNames: e.tableNames,
@@ -2313,16 +2334,16 @@ var Xt = (e) => typeof e == "string" && e !== "" ? e : null, Zt = async (e, t, n
2313
2334
  mechanism: r,
2314
2335
  steps: i
2315
2336
  };
2316
- }, fc = async (e, t, n) => {
2317
- let r = lc(t, e);
2337
+ }, mc = async (e, t, n) => {
2338
+ let r = dc(t, e);
2318
2339
  return t === "neon-cow" ? await n.neonBranchDelete(e) : await n.dropNamespace(e), r;
2319
- }, pc = (e, t, n) => uc(e, t, n), Z = (e) => `"${e.replace(/"/g, "\"\"")}"`, mc = {
2340
+ }, hc = (e, t, n) => fc(e, t, n), Z = (e) => `"${e.replace(/"/g, "\"\"")}"`, gc = {
2320
2341
  cascade: "CASCADE",
2321
2342
  restrict: "RESTRICT",
2322
2343
  setNull: "SET NULL",
2323
2344
  noAction: "NO ACTION"
2324
- }, hc = (e) => `'${e.replace(/'/g, "''")}'`, gc = (e, t) => {
2325
- let n = t.columns.map(hc).join(", ");
2345
+ }, _c = (e) => `'${e.replace(/'/g, "''")}'`, vc = (e, t) => {
2346
+ let n = t.columns.map(_c).join(", ");
2326
2347
  return `DO $voltro_branch$
2327
2348
  DECLARE derived name;
2328
2349
  BEGIN
@@ -2331,11 +2352,11 @@ BEGIN
2331
2352
  JOIN pg_class i ON i.oid = x.indexrelid
2332
2353
  JOIN pg_class c ON c.oid = x.indrelid
2333
2354
  JOIN pg_namespace nsp ON nsp.oid = c.relnamespace
2334
- WHERE nsp.nspname = ${hc(e)}
2335
- AND c.relname = ${hc(t.table)}
2355
+ WHERE nsp.nspname = ${_c(e)}
2356
+ AND c.relname = ${_c(t.table)}
2336
2357
  AND NOT x.indisprimary
2337
2358
  AND x.indisunique = ${t.unique ? "true" : "false"}
2338
- AND i.relname <> ${hc(t.name)}
2359
+ AND i.relname <> ${_c(t.name)}
2339
2360
  AND (
2340
2361
  SELECT array_agg(att.attname::text ORDER BY k.ord)
2341
2362
  FROM unnest(x.indkey::int2[]) WITH ORDINALITY AS k(attnum, ord)
@@ -2344,14 +2365,14 @@ BEGIN
2344
2365
  LIMIT 1;
2345
2366
  IF derived IS NOT NULL THEN
2346
2367
  EXECUTE format('ALTER INDEX %I.%I RENAME TO %I',
2347
- ${hc(e)}, derived, ${hc(t.name)});
2368
+ ${_c(e)}, derived, ${_c(t.name)});
2348
2369
  END IF;
2349
2370
  END
2350
2371
  $voltro_branch$`;
2351
- }, _c = (e, t) => {
2352
- let n = t.onDelete === void 0 ? "" : ` ON DELETE ${mc[t.onDelete]}`, r = t.onUpdate === void 0 ? "" : ` ON UPDATE ${mc[t.onUpdate]}`;
2372
+ }, yc = (e, t) => {
2373
+ let n = t.onDelete === void 0 ? "" : ` ON DELETE ${gc[t.onDelete]}`, r = t.onUpdate === void 0 ? "" : ` ON UPDATE ${gc[t.onUpdate]}`;
2353
2374
  return `ALTER TABLE ${Z(e)}.${Z(t.table)} ADD FOREIGN KEY (${Z(t.column)}) REFERENCES ${Z(e)}.${Z(t.targetTable)} (${Z(t.targetColumn)})${n}${r}`;
2354
- }, vc = (e) => {
2375
+ }, bc = (e) => {
2355
2376
  let t = () => {
2356
2377
  throw Error("namespace branch executor: Neon ops require a neon-cow executor (use a Neon connection for copy-on-write branches)");
2357
2378
  };
@@ -2359,24 +2380,24 @@ $voltro_branch$`;
2359
2380
  createNamespace: (t) => e.run(`CREATE SCHEMA IF NOT EXISTS ${Z(t)}`),
2360
2381
  createTable: (t, n) => e.run(`CREATE TABLE IF NOT EXISTS ${Z(t)}.${Z(n)} (LIKE ${Z(n)} INCLUDING ALL)`),
2361
2382
  copyTable: (t, n, r) => e.run(`INSERT INTO ${Z(n)}.${Z(r)} SELECT * FROM ${Z(t)}.${Z(r)}`),
2362
- addForeignKey: (t, n) => e.run(_c(t, n)),
2363
- restoreIndexName: (t, n) => e.run(gc(t, n)),
2383
+ addForeignKey: (t, n) => e.run(yc(t, n)),
2384
+ restoreIndexName: (t, n) => e.run(vc(t, n)),
2364
2385
  dropNamespace: (t) => e.run(`DROP SCHEMA IF EXISTS ${Z(t)} CASCADE`),
2365
2386
  neonBranchCreate: t,
2366
2387
  neonBranchDelete: t
2367
2388
  };
2368
- }, yc = class extends Error {
2389
+ }, xc = class extends Error {
2369
2390
  _tag = "TenantResidencyUnresolved";
2370
2391
  constructor(e) {
2371
2392
  super(e), this.name = "TenantResidencyUnresolved";
2372
2393
  }
2373
- }, bc = class extends Error {
2394
+ }, Sc = class extends Error {
2374
2395
  region;
2375
2396
  _tag = "TenantRegionUnavailable";
2376
2397
  constructor(e, t) {
2377
2398
  super(t), this.region = e, this.name = "TenantRegionUnavailable";
2378
2399
  }
2379
- }, xc, Sc = (e) => {
2400
+ }, Cc, wc = (e) => {
2380
2401
  if (e.homes === void 0) throw Error("setResidencyConfig: `homes` is required");
2381
2402
  if (e.servableRegions === void 0 || e.servableRegions.length === 0) throw Error("setResidencyConfig: `servableRegions` must be non-empty (which regions this deployment serves)");
2382
2403
  let t = /* @__PURE__ */ new Map();
@@ -2385,55 +2406,55 @@ $voltro_branch$`;
2385
2406
  if (e !== void 0 && e !== n.region) throw Error(`residency: tenant '${n.tenantId}' is mapped to two regions ('${e}' and '${n.region}')`);
2386
2407
  t.set(n.tenantId, n.region);
2387
2408
  }
2388
- return xc = e, e;
2389
- }, Cc = () => xc, wc = () => {
2390
- xc = void 0;
2391
- }, Tc = (e, t) => {
2392
- if (e == null || e === "") throw new yc("residency is on but the request has no resolvable tenant — refusing to bind a store");
2409
+ return Cc = e, e;
2410
+ }, Tc = () => Cc, Ec = () => {
2411
+ Cc = void 0;
2412
+ }, Dc = (e, t) => {
2413
+ if (e == null || e === "") throw new xc("residency is on but the request has no resolvable tenant — refusing to bind a store");
2393
2414
  let n = t.homes.find((t) => t.tenantId === e);
2394
- if (n === void 0) throw new yc(`no residency home is mapped for tenant '${e}' — refusing to fall back to a default store (would be a residency violation)`);
2415
+ if (n === void 0) throw new xc(`no residency home is mapped for tenant '${e}' — refusing to fall back to a default store (would be a residency violation)`);
2395
2416
  return n;
2396
- }, Ec = (e, t) => t.servableRegions.includes(e), Dc = (e, t) => {
2397
- let n = Tc(e.tenantId, t), r = ri(n.tenantId);
2417
+ }, Oc = (e, t) => t.servableRegions.includes(e), kc = (e, t) => {
2418
+ let n = Dc(e.tenantId, t), r = ri(n.tenantId);
2398
2419
  return {
2399
2420
  region: n.region,
2400
2421
  namespace: r,
2401
2422
  ...n.connectionKey === void 0 ? {} : { connectionKey: n.connectionKey }
2402
2423
  };
2403
- }, Oc = (e, t, n) => {
2404
- let r = Dc(e, t);
2405
- if (!Ec(r.region, t)) throw new bc(r.region, `tenant homed in region '${r.region}', which this deployment does not serve — route to the home region`);
2424
+ }, Ac = (e, t, n) => {
2425
+ let r = kc(e, t);
2426
+ if (!Oc(r.region, t)) throw new Sc(r.region, `tenant homed in region '${r.region}', which this deployment does not serve — route to the home region`);
2406
2427
  let i = n.get(r.region);
2407
- if (i === void 0) throw new bc(r.region, `no store handle for home region '${r.region}' (declared servable but not wired) — failing closed`);
2428
+ if (i === void 0) throw new Sc(r.region, `no store handle for home region '${r.region}' (declared servable but not wired) — failing closed`);
2408
2429
  return {
2409
2430
  store: i,
2410
2431
  placement: r
2411
2432
  };
2412
- }, kc = async (e, t, n, r) => {
2413
- let { store: i, placement: a } = Oc(e, t, n);
2433
+ }, jc = async (e, t, n, r) => {
2434
+ let { store: i, placement: a } = Ac(e, t, n);
2414
2435
  return await r(i, a), a;
2415
- }, Ac = (e) => {
2436
+ }, Mc = (e) => {
2416
2437
  if (typeof e == "string") return e;
2417
2438
  if ("jsonPath" in e) {
2418
2439
  let { column: t, path: n, numeric: r } = e.jsonPath;
2419
2440
  return `(json:${t}->${n.join(".")}${r ? "::num" : ""})`;
2420
2441
  }
2421
2442
  return `(${e.expr})`;
2422
- }, Q = (e) => e.map(Ac), jc = (e, t) => {
2443
+ }, Q = (e) => e.map(Mc), Nc = (e, t) => {
2423
2444
  if (e.length !== t.length) return !1;
2424
- for (let n = 0; n < e.length; n++) if (Ac(e[n]) !== Ac(t[n])) return !1;
2445
+ for (let n = 0; n < e.length; n++) if (Mc(e[n]) !== Mc(t[n])) return !1;
2425
2446
  return !0;
2426
- }, Mc = (e, t) => {
2447
+ }, Pc = (e, t) => {
2427
2448
  if (e.length >= t.length) return !1;
2428
- for (let n = 0; n < e.length; n++) if (Ac(e[n]) !== Ac(t[n])) return !1;
2449
+ for (let n = 0; n < e.length; n++) if (Mc(e[n]) !== Mc(t[n])) return !1;
2429
2450
  return !0;
2430
- }, Nc = (e) => {
2451
+ }, Fc = (e) => {
2431
2452
  let t = [], n = e.appliedIndexes, r = e.tableName;
2432
2453
  for (let e = 0; e < n.length; e++) {
2433
2454
  let i = n[e];
2434
2455
  for (let a = e + 1; a < n.length; a++) {
2435
2456
  let e = n[a];
2436
- if (jc(i.fields, e.fields)) {
2457
+ if (Nc(i.fields, e.fields)) {
2437
2458
  let [n, a] = i.name < e.name ? [i, e] : [e, i];
2438
2459
  t.push({
2439
2460
  kind: "duplicate-fields",
@@ -2444,13 +2465,13 @@ $voltro_branch$`;
2444
2465
  });
2445
2466
  continue;
2446
2467
  }
2447
- Mc(i.fields, e.fields) ? t.push({
2468
+ Pc(i.fields, e.fields) ? t.push({
2448
2469
  kind: "redundant-prefix",
2449
2470
  table: r,
2450
2471
  redundant: i,
2451
2472
  coveredBy: e,
2452
2473
  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).`
2453
- }) : Mc(e.fields, i.fields) && t.push({
2474
+ }) : Pc(e.fields, i.fields) && t.push({
2454
2475
  kind: "redundant-prefix",
2455
2476
  table: r,
2456
2477
  redundant: e,
@@ -2460,23 +2481,23 @@ $voltro_branch$`;
2460
2481
  }
2461
2482
  }
2462
2483
  return t;
2463
- }, Pc = (e) => {
2484
+ }, Ic = (e) => {
2464
2485
  let t = [];
2465
- for (let n of e) t.push(...Nc(n));
2486
+ for (let n of e) t.push(...Fc(n));
2466
2487
  return t;
2467
- }, Fc = "\x1B[", Ic = `${Fc}38;2;245;158;11m`, Lc = `${Fc}38;2;16;185;129m`, Rc = (e, t) => `${e}${t}${P.reset}`, $ = (e, t, n) => e ? typeof t == "function" ? t(n) : Rc(t, n) : n, zc = (e, t = {}) => {
2468
- let n = t.color ?? !0, r = t.indent ?? " ", i = (e) => $(n, P.dim, e.padEnd(11)), a = (e) => $(n, (e) => P.bold(P.brand(e)), e), o = (e) => $(n, P.brightRed24, e), s = (e) => $(n, Lc, e), c = (e) => $(n, Ic, e), l = (e) => $(n, P.dim, e), u = `${c("index audit")} ${l("·")} ${$(n, P.bold, e.kind)}`, d = e.redundant.fields.length, f = Q(e.coveredBy.fields.slice(d)), p = (e, t) => {
2488
+ }, Lc = "\x1B[", Rc = `${Lc}38;2;245;158;11m`, zc = `${Lc}38;2;16;185;129m`, Bc = (e, t) => `${e}${t}${P.reset}`, $ = (e, t, n) => e ? typeof t == "function" ? t(n) : Bc(t, n) : n, Vc = (e, t = {}) => {
2489
+ let n = t.color ?? !0, r = t.indent ?? " ", i = (e) => $(n, P.dim, e.padEnd(11)), a = (e) => $(n, (e) => P.bold(P.brand(e)), e), o = (e) => $(n, P.brightRed24, e), s = (e) => $(n, zc, e), c = (e) => $(n, Rc, e), l = (e) => $(n, P.dim, e), u = `${c("index audit")} ${l("·")} ${$(n, P.bold, e.kind)}`, d = e.redundant.fields.length, f = Q(e.coveredBy.fields.slice(d)), p = (e, t) => {
2469
2490
  let n = e.slice(0, t), r = e.slice(t), i = [];
2470
2491
  return n.length > 0 && i.push(s(`[${n.join(", ")}]`)), r.length > 0 && i.push(c(`+ [${r.join(", ")}]`)), i.join(" ");
2471
2492
  }, m = [];
2472
2493
  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, P.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");
2473
- }, Bc = (e, { apply: t, undo: n }) => ({
2494
+ }, Hc = (e, { apply: t, undo: n }) => ({
2474
2495
  name: e,
2475
2496
  apply: t,
2476
2497
  undo: n
2477
- }), Vc = (e) => {
2498
+ }), Uc = (e) => {
2478
2499
  if (!/^\d{14}_/.test(e.id)) throw Error(`migration "${e.id}": id must start with a 14-digit timestamp followed by "_" (convention: <YYYYMMDDHHMMSS>_<slug>)`);
2479
- let t = e.steps({ step: Bc });
2500
+ let t = e.steps({ step: Hc });
2480
2501
  if (t.length === 0) throw Error(`migration "${e.id}": at least one step is required`);
2481
2502
  return {
2482
2503
  __migration: !0,
@@ -2484,7 +2505,7 @@ $voltro_branch$`;
2484
2505
  name: e.name,
2485
2506
  steps: t
2486
2507
  };
2487
- }, Hc = (e) => typeof e == "object" && !!e && "__migration" in e && e.__migration === !0, Uc = E("_voltro_migrations", {
2508
+ }, Wc = (e) => typeof e == "object" && !!e && "__migration" in e && e.__migration === !0, Gc = E("_voltro_migrations", {
2488
2509
  id: O({ prefix: "mig" }),
2489
2510
  name: T(),
2490
2511
  hash: T(),
@@ -2496,7 +2517,7 @@ $voltro_branch$`;
2496
2517
  workflowRunId: T().nullable(),
2497
2518
  createdAt: D().default("now"),
2498
2519
  updatedAt: D().default("now").onUpdate("now")
2499
- }).index(["status"]), Wc = E("_voltro_seeds", {
2520
+ }).index(["status"]), Kc = E("_voltro_seeds", {
2500
2521
  id: O({ prefix: "seed" }),
2501
2522
  name: T(),
2502
2523
  lifecycle: T(),
@@ -2512,7 +2533,7 @@ $voltro_branch$`;
2512
2533
  workflowRunId: T().nullable(),
2513
2534
  createdAt: D().default("now"),
2514
2535
  updatedAt: D().default("now").onUpdate("now")
2515
- }).index(["lifecycle"]).index(["nextRunAt"]), Gc = E("_voltro_migration_plans", {
2536
+ }).index(["lifecycle"]).index(["nextRunAt"]), qc = E("_voltro_migration_plans", {
2516
2537
  id: O({ prefix: "plan" }),
2517
2538
  fingerprint: T(),
2518
2539
  liveFingerprint: T().nullable(),
@@ -2528,21 +2549,21 @@ $voltro_branch$`;
2528
2549
  appliedAt: D().default("now"),
2529
2550
  createdAt: D().default("now"),
2530
2551
  updatedAt: D().default("now").onUpdate("now")
2531
- }).index(["fingerprint"]).index(["environment"]), Kc = E("_voltro_idempotency", {
2552
+ }).index(["fingerprint"]).index(["environment"]), Jc = E("_voltro_idempotency", {
2532
2553
  id: O({ prefix: "idem" }),
2533
2554
  scope: T(),
2534
2555
  key: T(),
2535
2556
  status: T(),
2536
2557
  response: C().nullable(),
2537
2558
  createdAt: D().default("now")
2538
- }).unique(["scope", "key"]).index(["createdAt"]), qc = E("_voltro_kv", {
2559
+ }).unique(["scope", "key"]).index(["createdAt"]), Yc = E("_voltro_kv", {
2539
2560
  id: O({ prefix: "kv" }),
2540
2561
  key: T().unique(),
2541
2562
  value: T().nullable(),
2542
2563
  expiresAt: D().nullable(),
2543
2564
  createdAt: D().default("now"),
2544
2565
  updatedAt: D().default("now").onUpdate("now")
2545
- }).index(["expiresAt"]), Jc = E("_voltro_api_keys", {
2566
+ }).index(["expiresAt"]), Xc = E("_voltro_api_keys", {
2546
2567
  id: O({ prefix: "apikey" }),
2547
2568
  tenantId: T().nullable(),
2548
2569
  name: T(),
@@ -2557,7 +2578,7 @@ $voltro_branch$`;
2557
2578
  onBehalfOf: T().nullable(),
2558
2579
  metadata: C().nullable(),
2559
2580
  createdAt: D().default("now")
2560
- }).index("byApiKeyTenant", ["tenantId"]), Yc = E("_voltro_replica_observations", {
2581
+ }).index("byApiKeyTenant", ["tenantId"]), Zc = E("_voltro_replica_observations", {
2561
2582
  id: O({ prefix: "robs" }),
2562
2583
  replicaId: T().maxLength(191),
2563
2584
  startedAt: D(),
@@ -2566,11 +2587,11 @@ $voltro_branch$`;
2566
2587
  payload: T().nullable(),
2567
2588
  reachableAt: T().maxLength(255).nullable(),
2568
2589
  writtenAt: D().default("now").onUpdate("now")
2569
- }).unique(["replicaId", "kind"]).index(["kind"]), Xc = [
2570
- Uc,
2571
- Wc,
2572
- Gc
2573
- ], Zc = "_voltro_replace_in_progress", Qc = E(Zc, {
2590
+ }).unique(["replicaId", "kind"]).index(["kind"]), Qc = [
2591
+ Gc,
2592
+ Kc,
2593
+ qc
2594
+ ], $c = "_voltro_replace_in_progress", el = E($c, {
2574
2595
  id: O({ prefix: "repl" }),
2575
2596
  startedAt: D().default("now"),
2576
2597
  kind: T().default("replace"),
@@ -2580,10 +2601,10 @@ $voltro_branch$`;
2580
2601
  staging: T().nullable(),
2581
2602
  heartbeatAt: D().nullable(),
2582
2603
  resumable: p().nullable()
2583
- }), $c = 30, el = (e, t) => {
2604
+ }), tl = 30, nl = (e, t) => {
2584
2605
  let n = typeof t == "number" && Number.isFinite(t) && t > 0 ? t : 30, r = Number(e.VOLTRO_STAGING_STALE_MINUTES);
2585
2606
  return (Number.isFinite(r) && r > 0 ? r : n) * 6e4;
2586
- }, tl = (e) => e == null || String(e).length === 0 ? [] : String(e).split(",").map((e) => e.trim()).filter((e) => e.length > 0), nl = (e) => {
2607
+ }, rl = (e) => e == null || String(e).length === 0 ? [] : String(e).split(",").map((e) => e.trim()).filter((e) => e.length > 0), il = (e) => {
2587
2608
  let t = e.filter((e) => e.kind !== "staging");
2588
2609
  if (t.length !== 0) return `refusing to start: a destructive data operation did not finish.
2589
2610
  ${t.map((e) => {
@@ -2598,7 +2619,7 @@ ${t.map((e) => {
2598
2619
 
2599
2620
  When the data is back, or you have decided the current state is correct, clear the marker:
2600
2621
  voltro data clear-replace-marker --yes`;
2601
- }, rl = (e, t, n) => {
2622
+ }, al = (e, t, n) => {
2602
2623
  let r = e.filter((e) => e.kind === "staging");
2603
2624
  return {
2604
2625
  all: r,
@@ -2608,7 +2629,7 @@ ${t.map((e) => {
2608
2629
  return Number.isFinite(r) ? t - r >= n : !1;
2609
2630
  })
2610
2631
  };
2611
- }, il = (e, t) => {
2632
+ }, ol = (e, t) => {
2612
2633
  if (e.all.length === 0) return;
2613
2634
  let n = new Set(e.droppable.map((e) => e.id));
2614
2635
  return `staged data-import leftovers:
@@ -2617,22 +2638,22 @@ ${e.all.map((e) => {
2617
2638
  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.`;
2618
2639
  }).join("\n")}\n The target of a staged \`replace\` is untouched until one short swap at the end, so none of this is
2619
2640
  a reason to refuse the boot — it is a reason to know the disk is holding a copy of a bundle.`;
2620
- }, al = "id", ol = (e, t) => {
2641
+ }, sl = "id", cl = (e, t) => {
2621
2642
  let n = w(e);
2622
2643
  if (n === void 0) return t;
2623
- let r = n.fields[al]?.idScheme;
2624
- if (r === void 0 || t[al] != null) return t;
2644
+ let r = n.fields[sl]?.idScheme;
2645
+ if (r === void 0 || t[sl] != null) return t;
2625
2646
  if (r.kind === "numeric") {
2626
- if (!(al in t)) return t;
2647
+ if (!(sl in t)) return t;
2627
2648
  let e = { ...t };
2628
- return delete e[al], e;
2649
+ return delete e[sl], e;
2629
2650
  }
2630
2651
  let i = nt(r, e);
2631
2652
  return i === null ? t : {
2632
2653
  ...t,
2633
- [al]: i
2654
+ [sl]: i
2634
2655
  };
2635
- }, sl = (e, t) => t.map((t) => ol(e, t)), cl = {
2656
+ }, ll = (e, t) => t.map((t) => cl(e, t)), ul = {
2636
2657
  postgres: { maxBindParameters: 65535 },
2637
2658
  mysql: { maxBindParameters: 65535 },
2638
2659
  mariadb: { maxBindParameters: 65535 },
@@ -2642,25 +2663,25 @@ ${e.all.map((e) => {
2642
2663
  },
2643
2664
  sqlite: { maxBindParameters: 32766 },
2644
2665
  turso: { maxBindParameters: 32766 }
2645
- }, ll = (e) => cl[e], ul = (e) => {
2666
+ }, dl = (e) => ul[e], fl = (e) => {
2646
2667
  let t = /* @__PURE__ */ new Set();
2647
2668
  for (let n of e) for (let e of Object.keys(n)) t.add(e);
2648
2669
  return t.size;
2649
- }, dl = (e, t) => {
2670
+ }, pl = (e, t) => {
2650
2671
  if (t === void 0 || e.length === 0) return [e];
2651
- let n = Math.max(1, ul(e)), r = Math.floor(t.maxBindParameters / n), i = t.maxRowsPerStatement ?? Infinity, a = Math.max(1, Math.min(r, i));
2672
+ let n = Math.max(1, fl(e)), r = Math.floor(t.maxBindParameters / n), i = t.maxRowsPerStatement ?? Infinity, a = Math.max(1, Math.min(r, i));
2652
2673
  if (e.length <= a) return [e];
2653
2674
  let o = [];
2654
2675
  for (let t = 0; t < e.length; t += a) o.push(e.slice(t, t + a));
2655
2676
  return o;
2656
- }, fl = (e, t) => {
2677
+ }, ml = (e, t) => {
2657
2678
  let n = [], r = t;
2658
2679
  for (let [t, i] of Object.entries(e.fields)) {
2659
2680
  let e = i;
2660
2681
  e.nullable || e.hasDefault || e.idScheme !== void 0 || e.generatedAs !== void 0 || (r[t] === void 0 || r[t] === null) && n.push(t);
2661
2682
  }
2662
2683
  return n;
2663
- }, pl = (e, t, n) => {
2684
+ }, hl = (e, t, n) => {
2664
2685
  let r = n, i = new Set(e === void 0 ? [] : Object.entries(e.fields).filter(([, e]) => e.generatedAs !== void 0).map(([e]) => e)), a = [];
2665
2686
  for (let e of t) i.has(e) || (r[e] === void 0 ? a.push({
2666
2687
  column: e,
@@ -2670,39 +2691,36 @@ ${e.all.map((e) => {
2670
2691
  reason: "null"
2671
2692
  }));
2672
2693
  return a;
2673
- }, ml = (e, t, n) => e.insert(t.tableName, n), hl = (e, t, n) => e.insertMany(t.tableName, n), gl = (e, t, n, r) => e.upsert(t.tableName, n, {
2694
+ }, gl = (e, t, n) => e.insert(t.tableName, n), _l = (e, t, n) => e.insertMany(t.tableName, n), vl = (e, t, n, r) => e.upsert(t.tableName, n, {
2674
2695
  conflictColumns: r.conflictColumns,
2675
2696
  ...r.update === void 0 ? {} : { update: r.update },
2676
2697
  ...r.updateValues === void 0 ? {} : { updateValues: r.updateValues }
2677
- }), _l = async (e, t, n, r) => {
2698
+ }), yl = async (e, t, n, r) => {
2678
2699
  if (e.upsertWithOutcome === void 0) throw Error("upsertRowOutcome: this store does not implement `upsertWithOutcome`. It is provided by the framework's store wrapper, so `ctx.store` has it; a hand-written DataStore must add it.");
2679
2700
  return e.upsertWithOutcome(t.tableName, n, {
2680
2701
  conflictColumns: r.conflictColumns,
2681
2702
  ...r.update === void 0 ? {} : { update: r.update },
2682
2703
  ...r.updateValues === void 0 ? {} : { updateValues: r.updateValues }
2683
2704
  });
2684
- }, vl = async (e, t, n, r) => {
2685
- if (e.insertIgnoreWithOutcome === void 0) throw Error("insertIgnoreRowOutcome: this store does not implement `insertIgnoreWithOutcome`. It is provided by the framework's store wrapper, so `ctx.store` has it; a hand-written DataStore must add it.");
2686
- return e.insertIgnoreWithOutcome(t.tableName, n, { conflictColumns: r.conflictColumns });
2687
- }, yl = (e, t, n, r) => e.updateMany(t.tableName, n, { where: r.where }), bl = 512, xl = (e) => {
2705
+ }, bl = async (e, t, n, r) => e.insertIgnoreWithOutcome(t.tableName, n, { conflictColumns: r.conflictColumns }), xl = (e, t, n, r) => e.updateMany(t.tableName, n, { where: r.where }), Sl = 512, Cl = (e) => {
2688
2706
  e.setMaxListeners(512);
2689
- }, Sl = (e, t, n) => ({
2707
+ }, wl = (e, t, n) => ({
2690
2708
  _tag: "PrimaryKeyConflictError",
2691
2709
  table: e,
2692
2710
  key: t,
2693
2711
  cause: n
2694
- }), Cl = (e) => typeof e == "object" && !!e && e._tag === "PrimaryKeyConflictError", wl = {
2712
+ }), Tl = (e) => typeof e == "object" && !!e && e._tag === "PrimaryKeyConflictError", El = {
2695
2713
  postgres: 5432,
2696
2714
  mysql: 3306,
2697
2715
  mariadb: 3306,
2698
2716
  mssql: 1433
2699
- }, Tl = /* @__PURE__ */ new Set([
2717
+ }, Dl = /* @__PURE__ */ new Set([
2700
2718
  "localhost",
2701
2719
  "127.0.0.1",
2702
2720
  "::1",
2703
2721
  "[::1]",
2704
2722
  "0.0.0.0"
2705
- ]), El = (e) => {
2723
+ ]), Ol = (e) => {
2706
2724
  let t = e.host, n = e.port, r = e.database;
2707
2725
  if (e.url !== void 0 && e.url !== "") try {
2708
2726
  let i = new URL(e.url);
@@ -2711,29 +2729,29 @@ ${e.all.map((e) => {
2711
2729
  return;
2712
2730
  }
2713
2731
  if (t === void 0 || t === "" || r === void 0 || r === "") return;
2714
- let i = n ?? wl[(e.dialect ?? "").toLowerCase()];
2732
+ let i = n ?? El[(e.dialect ?? "").toLowerCase()];
2715
2733
  if (i === void 0 || !Number.isFinite(i)) return;
2716
2734
  let a = t.toLowerCase();
2717
2735
  return {
2718
- host: Tl.has(a) ? "localhost" : a,
2736
+ host: Dl.has(a) ? "localhost" : a,
2719
2737
  port: i,
2720
2738
  database: r.toLowerCase()
2721
2739
  };
2722
- }, Dl = (e) => {
2723
- let t = El(e);
2740
+ }, kl = (e) => {
2741
+ let t = Ol(e);
2724
2742
  if (t !== void 0) return Kt("sha256").update(`${t.host}\u0000${t.port}\u0000${t.database}`).digest("hex").slice(0, 32);
2725
- }, Ol = (e, t) => e === void 0 || t === void 0 ? "unknown" : e === t ? "same" : "different", kl = {
2743
+ }, Al = (e, t) => e === void 0 || t === void 0 ? "unknown" : e === t ? "same" : "different", jl = {
2726
2744
  app: 3,
2727
2745
  plugin: 2,
2728
2746
  framework: 1
2729
- }, Al = /* @__PURE__ */ new Map(), jl = [], Ml = () => [...jl], Nl = (e) => {
2747
+ }, Ml = /* @__PURE__ */ new Map(), Nl = [], Pl = () => [...Nl], Fl = (e) => {
2730
2748
  if (!e.table || !e.timeColumn) throw Error("registerRetention: table + timeColumn are required");
2731
2749
  if (!Number.isFinite(e.ttlMs) || e.ttlMs <= 0) throw Error(`registerRetention(${e.table}): ttlMs must be a positive number`);
2732
- let t = e.source ?? "app", n = Al.get(e.table);
2750
+ let t = e.source ?? "app", n = Ml.get(e.table);
2733
2751
  if (n !== void 0) {
2734
2752
  let r = n.source ?? "app", i = n.ttlMs !== e.ttlMs || n.where !== void 0 != (e.where !== void 0);
2735
- if (kl[t] < kl[r]) {
2736
- i && jl.push({
2753
+ if (jl[t] < jl[r]) {
2754
+ i && Nl.push({
2737
2755
  table: e.table,
2738
2756
  kept: {
2739
2757
  source: r,
@@ -2746,7 +2764,7 @@ ${e.all.map((e) => {
2746
2764
  });
2747
2765
  return;
2748
2766
  }
2749
- i && r !== t && jl.push({
2767
+ i && r !== t && Nl.push({
2750
2768
  table: e.table,
2751
2769
  kept: {
2752
2770
  source: t,
@@ -2758,13 +2776,13 @@ ${e.all.map((e) => {
2758
2776
  }
2759
2777
  });
2760
2778
  }
2761
- Al.set(e.table, {
2779
+ Ml.set(e.table, {
2762
2780
  ...e,
2763
2781
  source: t
2764
2782
  });
2765
- }, Pl = () => [...Al.values()], Fl = () => {
2766
- Al.clear(), jl.length = 0;
2767
- }, Il = async (e, t, n, r = 2e4) => {
2783
+ }, Il = () => [...Ml.values()], Ll = () => {
2784
+ Ml.clear(), Nl.length = 0;
2785
+ }, Rl = async (e, t, n, r = 2e4) => {
2768
2786
  let i = new Date(t - e.ttlMs), a = 0;
2769
2787
  try {
2770
2788
  for (;;) {
@@ -2772,26 +2790,26 @@ ${e.all.map((e) => {
2772
2790
  if (a += t, t < r) break;
2773
2791
  }
2774
2792
  } catch (t) {
2775
- throw A.runSync(j.increment(j.tagged(Rl, "table", e.table))), t;
2793
+ throw A.runSync(j.increment(j.tagged(Bl, "table", e.table))), t;
2776
2794
  }
2777
- return a > 0 && A.runSync(j.incrementBy(j.tagged(Ll, "table", e.table), a)), a;
2778
- }, Ll = j.counter("voltro_retention_swept_rows_total"), Rl = j.counter("voltro_retention_sweep_errors_total"), zl = (e, t) => {
2795
+ return a > 0 && A.runSync(j.incrementBy(j.tagged(zl, "table", e.table), a)), a;
2796
+ }, zl = j.counter("voltro_retention_swept_rows_total"), Bl = j.counter("voltro_retention_sweep_errors_total"), Vl = (e, t) => {
2779
2797
  let n = Number(e ?? String(t));
2780
2798
  return (Number.isFinite(n) && n > 0 ? n : t) * 36e5;
2781
- }, Bl = "_voltro_cdc_offsets", Vl = E(Bl, {
2799
+ }, Hl = "_voltro_cdc_offsets", Ul = E(Hl, {
2782
2800
  id: O({ prefix: "cdcoff" }),
2783
2801
  replicaId: T(),
2784
2802
  streamName: T(),
2785
2803
  binlogFile: T(),
2786
2804
  binlogPosition: T(),
2787
2805
  updatedAt: D()
2788
- }).index(["replicaId"]), Hl = E(Bl, {
2806
+ }).index(["replicaId"]), Wl = E(Hl, {
2789
2807
  id: O({ prefix: "cdcoff" }),
2790
2808
  replicaId: T(),
2791
2809
  streamName: T(),
2792
2810
  ctVersion: T(),
2793
2811
  updatedAt: D()
2794
- }).index(["replicaId"]), Ul = "_voltro_data_transfers", Wl = E(Ul, {
2812
+ }).index(["replicaId"]), Gl = "_voltro_data_transfers", Kl = E(Gl, {
2795
2813
  id: O({ prefix: "dimp" }),
2796
2814
  startedAt: D().default("now"),
2797
2815
  finishedAt: D().nullable(),
@@ -2804,13 +2822,13 @@ ${e.all.map((e) => {
2804
2822
  rowsWritten: y().default(0),
2805
2823
  failure: T().nullable(),
2806
2824
  staged: p().nullable()
2807
- }).renamedFrom("_voltro_data_imports").nonReactive(), Gl = (e) => {
2825
+ }).renamedFrom("_voltro_data_imports").nonReactive(), ql = (e) => {
2808
2826
  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)";
2809
2827
  return `${t} · ${r} · via ${e.via}${i}` + (e.bundle === null ? "" : ` · from ${e.bundle}`) + (e.sourceFingerprint === null ? "" : ` · source schema ${e.sourceFingerprint}`);
2810
- }, Kl = 255, ql = (e) => e == null ? "null" : typeof e == "string" || typeof e == "number" || typeof e == "boolean" ? JSON.stringify(e) : Array.isArray(e) ? `[${e.map(ql).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)}:${ql(t)}`).join(",")}}` : JSON.stringify(String(e)), Jl = (e) => {
2828
+ }, Jl = 255, Yl = (e) => e == null ? "null" : typeof e == "string" || typeof e == "number" || typeof e == "boolean" ? JSON.stringify(e) : Array.isArray(e) ? `[${e.map(Yl).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)}:${Yl(t)}`).join(",")}}` : JSON.stringify(String(e)), Xl = (e) => {
2811
2829
  if (e == null) return null;
2812
- let t = typeof e == "string" ? e : ql(e);
2830
+ let t = typeof e == "string" ? e : Yl(e);
2813
2831
  return t.length > 255 ? t.slice(0, 255) : t;
2814
- }, Yl = "postgres";
2832
+ }, Zl = "postgres";
2815
2833
  //#endregion
2816
- export { st as AUTO_FILLED_COLUMNS, rn as BOUND_ENCRYPTED_PREFIX, cl as BULK_INSERT_LIMITS, X as BranchNameInvalid, ec as BranchTransitionInvalid, Bl as CDC_OFFSETS_TABLE, go as CHANGE_CLAIM_TTL_ENV, bl as CHANGE_LISTENER_CEILING, Xe as ColumnBuilder, Ul as DATA_TRANSFERS_TABLE, at as DEFAULT_ACQUIRE_TIMEOUT_MS, _o as DEFAULT_CHANGE_CLAIM_TTL_HOURS, vs as DEFAULT_EAGER_FALLBACK_WARN_INTERVAL_MS, _t as DEFAULT_SOFT_DROP_RETENTION_DAYS, fr as DEFAULT_SUBJECT_GRAPH_DEPTH, nn as ENCRYPTED_PREFIX, Yl as ENGINE, zr as EagerCardinalityError, bt as FILE_MIGRATION_PATTERN, rt as FRAMEWORK_LIVE_TABLES, sn as FieldDecryptionError, Bo as ID_COLUMN_MAX_LENGTH, Ft as INITIAL_VERSION, Va as MATCHES_NO_ROWS, Ct as MAX_IDENTIFIER_LENGTH, ks as MSSQL_TRANSIENT_NUMBERS, Ds as MYSQL_TRANSIENT_CODES, ho as OccurrenceCounter, Os as POSTGRES_TRANSIENT_STATES, Zc as REPLACE_IN_PROGRESS_TABLE, Kl as SCOPE_KEY_MAX_LENGTH, ae as SELF_REFERENCE_TARGET, As as SQLITE_TRANSIENT_CODES, $c as STAGING_STALE_MINUTES, dt as STAGING_TABLE_PREFIX, Yt as SqlClient, js as TURSO_TRANSIENT_MESSAGE, Hs as TableStreamError, $r as TenantNamespaceInvalid, Qr as TenantNamespaceUnresolved, bc as TenantRegionUnavailable, yc as TenantResidencyUnresolved, Is as VOLTRO_EXPIRES_MIXIN_ID, Rs as VOLTRO_LOCAL_FIRST_MIXIN_ID, Mt as VersionConflict, Ot as WARN_IDENTIFIER_LENGTH, Jc as _voltroApiKeysTable, Vl as _voltroCdcOffsetsTable, Wl as _voltroDataTransfersTable, Kc as _voltroIdempotencyTable, qc as _voltroKvTable, Gc as _voltroMigrationPlansTable, Uc as _voltroMigrationsTable, Hl as _voltroMssqlCdcOffsetsTable, Qc as _voltroReplaceInProgressTable, Yc as _voltroReplicaObservationsTable, Wc as _voltroSeedsTable, Da as actorsTable, pc as admitBranch, Ke as agedSoftDropSnapshots, ve as allEnumRenames, lr as allRegisteredRelations, te as allRegisteredTables, Ga as and, Lr as applyJsonPatch, oe as array, Ra as arrayContains, Ba as arrayHas, za as arrayOverlaps, Vr as attachEagerLoads, So as attributionFields, Eo as attributionKey, Pc as auditAllTableIndexes, Nc as auditTableIndexes, wt as avg, _e as avgOver, Fo as beginLocalWrite, ue as bigint, Oc as bindResidentStore, p as boolean, Zs as branchNamespaceName, ll as bulkInsertLimitsFor, ee as bytes, bn as causeBranches, co as changeDelete, fo as changeDigest, oo as changeInsert, lo as changeSoftDelete, so as changeUpdate, dl as chunkRowsForInsert, ko as claimPendingAttribution, An as classifyConstraintViolation, d as clearEnumRenames, Ro as clearPendingAttribution, dr as clearRelationsRegistry, wc as clearResidencyConfig, Fl as clearRetentions, Ee as clearTableRegistry, qo as clearWriteRecorders, G as coercePredicateForSqlite, si as coercePredicateValue, ci as coercePredicateValues, ya as coerceValueForSqlite, ro as collectSubqueries, u as column, zn as columnSchema, ul as columnsPerRow, Si as compileEagerJson, Rr as compileJsonPatch, R as compilePredicate, li as compileRawFragment, xi as compileSelect, po as composeChangeKey, qs as computeEmbedding, Dl as connectionIdentity, Ia as contains, c as count, se as countDistinct, ie as crdtDoc, me as crdtManagedColumns, At as crdtManagedColumnsOf, a as crdtText, xo as currentWriteAttribution, Ze as databaseHandle, Se as date, _ as dbEnum, fs as dbMetricTagCacheSizeForTests, hs as dbOperationsInFlight, be as decimal, l as declareEnumRename, fn as decodeFieldValue, Er as decodeRowsFromSchema, vn as decryptFieldsOnRead, Vc as defineMigration, xt as defineMixin, ct as defineSeed, n as denseRank, yr as deriveSubjectGraph, lt as deriveTypeIdPrefix, Uo as derivedRowId, Wo as derivedRowIdLength, je as describeAgedSoftDropSnapshots, Nn as describeDriverError, Pn as describeRowBindings, Gl as describeTransferRun, tn as deserializeArraysOnRead, Pe as drainIdentifierWarnings, we as dropped, un as encodeFieldValue, Or as encodeRowForSchema, _n as encryptFieldsForWrite, hn as encryptedColumnsOf, Io as endLocalWrite, uc as enforceBranchLimits, Te as ensureTableRegistered, Oa as eq, ui as escapeLike, no as evaluatePredicate, Ye as except, Qa as exists, Ls as expires, ao as externalChangeEvent, Cn as extractDbCause, an as fieldBinding, tt as fireSchemaChangeSeeds, We as fireTenantCreateSeeds, zc as formatIndexAuditIssue, br as formatSubjectGraph, Xc as frameworkTables, nt as generateId, Ue as generateSnowflake, h as geography, re as geometry, ce as getEnumRenames, cr as getRelation, sr as getRelations, Cc as getResidencyConfig, w as getTable, Aa as gt, ja as gte, Zr as hasEagerLoads, Ks as hybridSearch, O as id, Pa as inSet, Xa as inSubquery, Qn as inferForeignKey, vl as insertIgnoreRowOutcome, hl as insertManyRows, ml as insertRow, y as integer, nl as interruptedReplaceRefusal, x as intersect, De as interval, on as isBoundCiphertext, Qs as isBranchNamespace, Nr as isCompositeRowKey, qn as isEmptyRelationsSpec, ln as isEncrypted, cn as isFieldDecryptionError, Ie as isFileMigration, jn as isForeignKeyViolation, ot as isFrameworkOwnedLiveTable, Bs as isLocalFirst, Hc as isMigrationDefinition, pt as isMysqlFamily, ic as isNeonConnection, Ua as isNotNull, Ha as isNull, Cl as isPrimaryKeyConflictError, Mn as isQueryTimeout, pn as isRawEncoding, Ec as isRegionServable, Jn as isRelationsSpec, He as isSeedDefinition, mt as isSoftDropSnapshotName, Je as isSqliteFamily, Fe as isStagingTableName, de as isTableReactive, Ps as isTransientContention, Ne as isView, C as json, Ja as jsonField, gt as jsonIndex, Pr as jsonPatchAssignments, S as lag, le as lead, Ml as listRetentionConflicts, Pl as listRetentions, zs as localFirst, Vs as localFirstTables, Ma as lt, Na as lte, xs as makeEagerFallbackReporter, vc as makeNamespaceBranchExecutor, Xn as many, Zn as manyToMany, Oe as materializeFields, f as max, Be as migration, v as min, pl as missingConflictColumns, fl as missingRequiredColumns, Le as mixin, ka as neq, tc as nextBranchState, El as normaliseTarget, Ir as normalizeJsonPatchValue, qa as not, $a as notExists, Fa as notInSet, Za as notInSubquery, fe as numeric, _s as observeDbOp, vo as occurrenceWindowMs, Yn as one, Br as oneCardinalityMessage, Ka as or, b as orderClausesOf, pe as paginateBy, kt as paginateById, mo as parseChangeKey, zo as pendingAttributionCount, cc as planBranch, nc as planBranchProvision, rc as planBranchTeardown, lc as planBranchTeardownFor, oc as planNeonBranchProvision, sc as planNeonBranchTeardown, jt as planVersionedUpdate, Qe as pluginRef, r as pluginRefSpecOf, Sl as primaryKeyConflictError, dc as provisionBranch, kc as provisionResidentTenant, ii as qualifyTable, i as queryFor, Et as queryForView, Me as quoteIdent, xl as raiseChangeListenerCeiling, xe as rank, t as raw, Re as readableByColumns, vt as real, gs as recordDbOp, Qo as recordsTable, it as reference, Ln as refuseWrite, Ca as registerCoreTables, or as registerDiscoveredRelations, Oo as registerPendingAttribution, ar as registerRelations, Nl as registerRetention, e as registerTable, Go as registerWriteRecorder, Kn as relations, Ta as requireActors, ze as requireTable, Ea as requireTenants, ds as resetDbMetricTagCacheForTests, Ae as resetSnowflake, Dc as residentPlacement, Zt as resolveActorSnapshot, ac as resolveBranchMechanism, bs as resolveEagerFallbackWarnIntervalMs, Lo as resolveEchoAttribution, g as resolveFullTextIndex, Ge as resolveIdScheme, Ve as resolveMixinGraph, Tc as resolveTenantHome, ri as resolveTenantNamespace, zl as retentionTtlMsFromEnv, jr as rowKeyColumns, Mr as rowKeyIdentity, ye as rowNumber, Bn as rowSchema, Ts as runRetryingTransaction, Es as runStoreTransaction, bo as runWithWriteAttribution, $o as runWriteRecorders, Ol as sameDatabase, ni as sanitizeIdentifierFragment, Jl as scopeKeyOf, ft as selfReference, en as serializeArraysForWrite, qe as serverOnlyColumns, Sc as setResidencyConfig, ke as setSchemaChangeSeedHook, St as setTenantCreateSeedHook, Ss as settleTransactionExit, Pt as settleVersionedUpdate, $e as softDropSnapshotStamp, Wa as spatialPredicate, il as stagingLeftoverReport, rl as stagingLeftovers, tl as stagingNamesOf, el as stagingStaleAfterMs, ol as stampGeneratedId, sl as stampGeneratedIds, La as startsWith, Rn as storeRefusalOf, Gs as streamTable, Ce as sum, m as sumOver, Yo as suspendWriteRecorders, Xo as suspendWriteRecordersEffect, Il as sweepRetention, E as table, fc as teardownBranch, T as text, D as timestamp, Lt as timestampMs, Nt as timestampMsOrNull, ne as union, ut as unionAll, yt as unregisterTable, Ko as unregisterWriteRecorder, yl as updateManyRow, gl as upsertRow, _l as upsertRowOutcome, Ar as upsertUpdatePatch, kr as upsertUpdateValues, Dt as validateColumnName, ge as validateIndexName, ur as validateRegisteredRelations, nr as validateRelationConfig, s as validateTableName, Tt as validateTypeIdPrefix, ht as vector, et as vectorDistanceToOpclass, Js as vectorEmbedding, It as versionColumnOf, he as view, o as viewSql, io as walkLeaves, wn as wireSafeCause, Co as withCapturedAttribution, Zo as writeRecordersSuspended };
2834
+ export { st as AUTO_FILLED_COLUMNS, rn as BOUND_ENCRYPTED_PREFIX, ul as BULK_INSERT_LIMITS, X as BranchNameInvalid, nc as BranchTransitionInvalid, Hl as CDC_OFFSETS_TABLE, _o as CHANGE_CLAIM_TTL_ENV, Sl as CHANGE_LISTENER_CEILING, Xe as ColumnBuilder, Gl as DATA_TRANSFERS_TABLE, at as DEFAULT_ACQUIRE_TIMEOUT_MS, vo as DEFAULT_CHANGE_CLAIM_TTL_HOURS, ys as DEFAULT_EAGER_FALLBACK_WARN_INTERVAL_MS, _t as DEFAULT_SOFT_DROP_RETENTION_DAYS, fr as DEFAULT_SUBJECT_GRAPH_DEPTH, nn as ENCRYPTED_PREFIX, Zl as ENGINE, zr as EagerCardinalityError, bt as FILE_MIGRATION_PATTERN, rt as FRAMEWORK_LIVE_TABLES, sn as FieldDecryptionError, Vo as ID_COLUMN_MAX_LENGTH, Ft as INITIAL_VERSION, Ha as MATCHES_NO_ROWS, Ct as MAX_IDENTIFIER_LENGTH, js as MSSQL_TRANSIENT_NUMBERS, ks as MYSQL_TRANSIENT_CODES, go as OccurrenceCounter, As as POSTGRES_TRANSIENT_STATES, $c as REPLACE_IN_PROGRESS_TABLE, Jl as SCOPE_KEY_MAX_LENGTH, ae as SELF_REFERENCE_TARGET, Ms as SQLITE_TRANSIENT_CODES, tl as STAGING_STALE_MINUTES, dt as STAGING_TABLE_PREFIX, Yt as SqlClient, Ns as TURSO_TRANSIENT_MESSAGE, Ws as TableStreamError, $r as TenantNamespaceInvalid, Qr as TenantNamespaceUnresolved, Sc as TenantRegionUnavailable, xc as TenantResidencyUnresolved, Rs as VOLTRO_EXPIRES_MIXIN_ID, Bs as VOLTRO_LOCAL_FIRST_MIXIN_ID, Mt as VersionConflict, Ot as WARN_IDENTIFIER_LENGTH, Xc as _voltroApiKeysTable, Ul as _voltroCdcOffsetsTable, Kl as _voltroDataTransfersTable, Jc as _voltroIdempotencyTable, Yc as _voltroKvTable, qc as _voltroMigrationPlansTable, Gc as _voltroMigrationsTable, Wl as _voltroMssqlCdcOffsetsTable, el as _voltroReplaceInProgressTable, Zc as _voltroReplicaObservationsTable, Kc as _voltroSeedsTable, Da as actorsTable, hc as admitBranch, Ke as agedSoftDropSnapshots, ve as allEnumRenames, lr as allRegisteredRelations, te as allRegisteredTables, Ka as and, Lr as applyJsonPatch, oe as array, za as arrayContains, Va as arrayHas, Ba as arrayOverlaps, Vr as attachEagerLoads, Co as attributionFields, Do as attributionKey, Ic as auditAllTableIndexes, Fc as auditTableIndexes, wt as avg, _e as avgOver, Io as beginLocalWrite, ue as bigint, Ac as bindResidentStore, p as boolean, $s as branchNamespaceName, dl as bulkInsertLimitsFor, ee as bytes, bn as causeBranches, lo as changeDelete, po as changeDigest, so as changeInsert, uo as changeSoftDelete, co as changeUpdate, pl as chunkRowsForInsert, Ao as claimPendingAttribution, An as classifyConstraintViolation, d as clearEnumRenames, zo as clearPendingAttribution, dr as clearRelationsRegistry, Ec as clearResidencyConfig, Ll as clearRetentions, Ee as clearTableRegistry, Jo as clearWriteRecorders, G as coercePredicateForSqlite, si as coercePredicateValue, ci as coercePredicateValues, ya as coerceValueForSqlite, io as collectSubqueries, u as column, zn as columnSchema, fl as columnsPerRow, Oa as compareDecimal, Si as compileEagerJson, Rr as compileJsonPatch, R as compilePredicate, li as compileRawFragment, xi as compileSelect, mo as composeChangeKey, Ys as computeEmbedding, kl as connectionIdentity, La as contains, c as count, se as countDistinct, ie as crdtDoc, me as crdtManagedColumns, At as crdtManagedColumnsOf, a as crdtText, So as currentWriteAttribution, Ze as databaseHandle, Se as date, _ as dbEnum, ps as dbMetricTagCacheSizeForTests, gs as dbOperationsInFlight, be as decimal, l as declareEnumRename, fn as decodeFieldValue, Er as decodeRowsFromSchema, vn as decryptFieldsOnRead, Uc as defineMigration, xt as defineMixin, ct as defineSeed, n as denseRank, yr as deriveSubjectGraph, lt as deriveTypeIdPrefix, Wo as derivedRowId, Go as derivedRowIdLength, je as describeAgedSoftDropSnapshots, Nn as describeDriverError, Pn as describeRowBindings, ql as describeTransferRun, tn as deserializeArraysOnRead, Pe as drainIdentifierWarnings, we as dropped, un as encodeFieldValue, Or as encodeRowForSchema, _n as encryptFieldsForWrite, hn as encryptedColumnsOf, Lo as endLocalWrite, fc as enforceBranchLimits, Te as ensureTableRegistered, ka as eq, ui as escapeLike, ro as evaluatePredicate, Ye as except, $a as exists, zs as expires, oo as externalChangeEvent, Cn as extractDbCause, an as fieldBinding, tt as fireSchemaChangeSeeds, We as fireTenantCreateSeeds, Vc as formatIndexAuditIssue, br as formatSubjectGraph, Qc as frameworkTables, nt as generateId, Ue as generateSnowflake, h as geography, re as geometry, ce as getEnumRenames, cr as getRelation, sr as getRelations, Tc as getResidencyConfig, w as getTable, ja as gt, Ma as gte, Zr as hasEagerLoads, Js as hybridSearch, O as id, Fa as inSet, Za as inSubquery, Qn as inferForeignKey, bl as insertIgnoreRowOutcome, _l as insertManyRows, gl as insertRow, y as integer, il as interruptedReplaceRefusal, x as intersect, De as interval, on as isBoundCiphertext, ec as isBranchNamespace, Nr as isCompositeRowKey, qn as isEmptyRelationsSpec, ln as isEncrypted, cn as isFieldDecryptionError, Ie as isFileMigration, jn as isForeignKeyViolation, ot as isFrameworkOwnedLiveTable, Hs as isLocalFirst, Wc as isMigrationDefinition, pt as isMysqlFamily, oc as isNeonConnection, Wa as isNotNull, Ua as isNull, Tl as isPrimaryKeyConflictError, Mn as isQueryTimeout, pn as isRawEncoding, Oc as isRegionServable, Jn as isRelationsSpec, He as isSeedDefinition, mt as isSoftDropSnapshotName, Je as isSqliteFamily, Fe as isStagingTableName, de as isTableReactive, Is as isTransientContention, Ne as isView, C as json, Ya as jsonField, gt as jsonIndex, Pr as jsonPatchAssignments, S as lag, le as lead, Pl as listRetentionConflicts, Il as listRetentions, Vs as localFirst, Us as localFirstTables, Na as lt, Pa as lte, Ss as makeEagerFallbackReporter, bc as makeNamespaceBranchExecutor, Xn as many, Zn as manyToMany, Oe as materializeFields, f as max, Be as migration, v as min, hl as missingConflictColumns, ml as missingRequiredColumns, Le as mixin, Aa as neq, rc as nextBranchState, Ol as normaliseTarget, Ir as normalizeJsonPatchValue, Ja as not, eo as notExists, Ia as notInSet, Qa as notInSubquery, fe as numeric, vs as observeDbOp, yo as occurrenceWindowMs, Yn as one, Br as oneCardinalityMessage, qa as or, b as orderClausesOf, pe as paginateBy, kt as paginateById, ho as parseChangeKey, Bo as pendingAttributionCount, uc as planBranch, ic as planBranchProvision, ac as planBranchTeardown, dc as planBranchTeardownFor, cc as planNeonBranchProvision, lc as planNeonBranchTeardown, jt as planVersionedUpdate, Qe as pluginRef, r as pluginRefSpecOf, wl as primaryKeyConflictError, pc as provisionBranch, jc as provisionResidentTenant, ii as qualifyTable, i as queryFor, Et as queryForView, Me as quoteIdent, Cl as raiseChangeListenerCeiling, xe as rank, t as raw, Re as readableByColumns, vt as real, _s as recordDbOp, $o as recordsTable, it as reference, Ln as refuseWrite, Ca as registerCoreTables, or as registerDiscoveredRelations, ko as registerPendingAttribution, ar as registerRelations, Fl as registerRetention, e as registerTable, Ko as registerWriteRecorder, Kn as relations, Ta as requireActors, ze as requireTable, Ea as requireTenants, fs as resetDbMetricTagCacheForTests, Ae as resetSnowflake, kc as residentPlacement, Zt as resolveActorSnapshot, sc as resolveBranchMechanism, xs as resolveEagerFallbackWarnIntervalMs, Ro as resolveEchoAttribution, g as resolveFullTextIndex, Ge as resolveIdScheme, Ve as resolveMixinGraph, Dc as resolveTenantHome, ri as resolveTenantNamespace, Vl as retentionTtlMsFromEnv, jr as rowKeyColumns, Mr as rowKeyIdentity, ye as rowNumber, Bn as rowSchema, Ds as runRetryingTransaction, Os as runStoreTransaction, xo as runWithWriteAttribution, es as runWriteRecorders, Al as sameDatabase, ni as sanitizeIdentifierFragment, Xl as scopeKeyOf, ft as selfReference, en as serializeArraysForWrite, qe as serverOnlyColumns, wc as setResidencyConfig, ke as setSchemaChangeSeedHook, St as setTenantCreateSeedHook, Cs as settleTransactionExit, Pt as settleVersionedUpdate, $e as softDropSnapshotStamp, Ga as spatialPredicate, ol as stagingLeftoverReport, al as stagingLeftovers, rl as stagingNamesOf, nl as stagingStaleAfterMs, cl as stampGeneratedId, ll as stampGeneratedIds, Ra as startsWith, Rn as storeRefusalOf, qs as streamTable, Ce as sum, m as sumOver, Xo as suspendWriteRecorders, Zo as suspendWriteRecordersEffect, Rl as sweepRetention, E as table, mc as teardownBranch, T as text, D as timestamp, Lt as timestampMs, Nt as timestampMsOrNull, Es as transactionRetrySchedule, ne as union, ut as unionAll, yt as unregisterTable, qo as unregisterWriteRecorder, xl as updateManyRow, vl as upsertRow, yl as upsertRowOutcome, Ar as upsertUpdatePatch, kr as upsertUpdateValues, Dt as validateColumnName, ge as validateIndexName, ur as validateRegisteredRelations, nr as validateRelationConfig, s as validateTableName, Tt as validateTypeIdPrefix, ht as vector, et as vectorDistanceToOpclass, Xs as vectorEmbedding, It as versionColumnOf, he as view, o as viewSql, ao as walkLeaves, wn as wireSafeCause, wo as withCapturedAttribution, Qo as writeRecordersSuspended };