@voltro/runtime 0.38.0 → 0.39.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/CHANGELOG.md +276 -0
- package/THIRD-PARTY-NOTICES.md +3 -3
- package/dist/index.d.ts +52 -0
- package/dist/index.js +869 -867
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Cause as e, Clock as t, Context as n, Cron as r, Deferred as i, Duration as a, Effect as o, Either as s, Exit as c, Fiber as l, Layer as u, ManagedRuntime as d, Metric as f, MetricBoundaries as p, MetricState as m, Option as h, Queue as g, Ref as _, Schedule as v, Schema as y, Stream as b, Tracer as x } from "effect";
|
|
2
|
-
import { ENCRYPTED_PREFIX as S, and as C, attachEagerLoads as w, attributionFields as T, boolean as E, clearRetentions as ee, collectSubqueries as D, contains as te, decryptFieldsOnRead as ne, deserializeArraysOnRead as re, encryptFieldsForWrite as ie, eq as O, evaluatePredicate as k, externalChangeEvent as ae, generateId as A, getRelations as oe, getTable as j, gt as
|
|
3
|
-
import { createCipheriv as
|
|
4
|
-
import { EventEmitter as
|
|
5
|
-
import { ADMIN_SCOPE as
|
|
2
|
+
import { ENCRYPTED_PREFIX as S, and as C, attachEagerLoads as w, attributionFields as T, boolean as E, clearRetentions as ee, collectSubqueries as D, contains as te, decryptFieldsOnRead as ne, deserializeArraysOnRead as re, encryptFieldsForWrite as ie, eq as O, evaluatePredicate as k, externalChangeEvent as ae, generateId as A, getRelations as oe, getTable as j, gt as M, gte as se, hasEagerLoads as ce, id as N, inSet as le, integer as P, isEncrypted as ue, isNull as de, isTableReactive as fe, json as F, listRetentionConflicts as pe, listRetentions as me, lt as he, lte as ge, missingConflictColumns as _e, missingRequiredColumns as ve, neq as ye, or as be, planVersionedUpdate as xe, queryFor as Se, raiseChangeListenerCeiling as Ce, readableByColumns as we, registerRetention as Te, registerRetention as Ee, requireTable as De, retentionTtlMsFromEnv as Oe, retentionTtlMsFromEnv as ke, runWithWriteAttribution as Ae, serializeArraysForWrite as je, serverOnlyColumns as Me, settleVersionedUpdate as Ne, stampGeneratedId as Pe, startsWith as Fe, sweepRetention as Ie, table as I, text as L, timestamp as R, walkLeaves as Le } from "@voltro/database";
|
|
3
|
+
import { createCipheriv as Re, createDecipheriv as ze, createHash as Be, randomBytes as Ve, randomUUID as He, scryptSync as Ue } from "node:crypto";
|
|
4
|
+
import { EventEmitter as We } from "node:events";
|
|
5
|
+
import { ADMIN_SCOPE as Ge, APIKEY_ISSUE_ORG_SCOPE as Ke, APIKEY_ISSUE_OTHER_SCOPE as qe, APIKEY_ISSUE_SELF_SCOPE as Je, ApprovalExpired as Ye, ApprovalForbidden as Xe, ApprovalNotFound as Ze, ApprovalNotPending as Qe, ApprovalRejected as $e, ApprovalRequired as et, ApprovalSelfApproval as tt, ApprovalUnavailable as nt, AuthMiddleware as rt, BusinessRuleViolation as it, ConnectionHandshakeFailed as z, ConnectionInfo as at, ConnectionInfoMiddleware as ot, ConnectionKindMismatch as st, ConnectionNotDeclared as ct, ConnectionSubjectRequired as lt, EventKeyInvalid as ut, EventPayloadInvalid as dt, EventPayloadTooLarge as ft, MAX_EVENT_ENVELOPE_BYTES as pt, ScopeError as mt, SubjectService as ht, UndoConflict as gt, UndoForbidden as _t, UndoNotFound as vt, WorkflowRunHandleSchema as yt, beginIdempotent as bt, checkGuardsEffect as xt, declaredReactivityChannelKeys as St, diffRows as Ct, effectiveScopes as wt, eventRoute as Tt, failIdempotent as Et, finishIdempotent as Dt, hasEffectiveScope as Ot, isIdKeyed as kt, isOpenAccess as At, isPolicyGuard as jt, isReactivityChannelKey as Mt, parseEventRoute as Nt, publishServerError as Pt, requireScope as Ft, setPolicyGuardResolver as It, sourceKeys as Lt, strictInput as Rt, systemSubject as zt, tsMs as Bt, wsMutationIdempotencyScope as Vt } from "@voltro/protocol";
|
|
6
6
|
import { createLogger as B, log as Ht } from "@voltro/logger";
|
|
7
7
|
import { AsyncLocalStorage as Ut } from "node:async_hooks";
|
|
8
8
|
import * as Wt from "node:http";
|
|
@@ -66,7 +66,7 @@ var En = (e) => {
|
|
|
66
66
|
}
|
|
67
67
|
}, On = (e) => {
|
|
68
68
|
let t = [];
|
|
69
|
-
for (let n of
|
|
69
|
+
for (let n of Le(e)) n.conjunctive && n.path === void 0 && (n.op === "eq" && t.push({
|
|
70
70
|
column: n.column,
|
|
71
71
|
values: [n.value]
|
|
72
72
|
}), n.op === "in" && t.push({
|
|
@@ -76,14 +76,14 @@ var En = (e) => {
|
|
|
76
76
|
return t;
|
|
77
77
|
}, kn = (e) => {
|
|
78
78
|
let t = [];
|
|
79
|
-
for (let n of
|
|
79
|
+
for (let n of Le(e)) n.conjunctive && n.path === void 0 && (n.op === "gt" || n.op === "gte" || n.op === "lt" || n.op === "lte") && t.push({
|
|
80
80
|
column: n.column,
|
|
81
81
|
op: n.op,
|
|
82
82
|
threshold: n.value
|
|
83
83
|
});
|
|
84
84
|
return t;
|
|
85
85
|
}, An = (e, t) => {
|
|
86
|
-
for (let n of
|
|
86
|
+
for (let n of Le(e)) if (n.conjunctive && n.path === void 0 && n.op === "eq" && n.column === t) return n.value;
|
|
87
87
|
return null;
|
|
88
88
|
}, jn = (e, t) => {
|
|
89
89
|
let n = [];
|
|
@@ -317,7 +317,7 @@ var En = (e) => {
|
|
|
317
317
|
predicate: t,
|
|
318
318
|
indexHint: n ?? null
|
|
319
319
|
});
|
|
320
|
-
return
|
|
320
|
+
return Be("sha256").update(JSON.stringify(r)).digest("hex").slice(0, 16);
|
|
321
321
|
}, Ln = class {
|
|
322
322
|
matcher;
|
|
323
323
|
byFingerprint = /* @__PURE__ */ new Map();
|
|
@@ -532,7 +532,7 @@ var En = (e) => {
|
|
|
532
532
|
#e;
|
|
533
533
|
#t;
|
|
534
534
|
#n(e) {
|
|
535
|
-
|
|
535
|
+
fe(e.table) && this.#t.emit("change", {
|
|
536
536
|
...T(),
|
|
537
537
|
...e
|
|
538
538
|
});
|
|
@@ -544,7 +544,7 @@ var En = (e) => {
|
|
|
544
544
|
return r.#e = t.tables, r.#t = t.emitter, r.#r = t.numericCounters, r;
|
|
545
545
|
}
|
|
546
546
|
constructor(e, t = null) {
|
|
547
|
-
if (this.#i = t, this.#e = /* @__PURE__ */ new Map(), this.#t = new
|
|
547
|
+
if (this.#i = t, this.#e = /* @__PURE__ */ new Map(), this.#t = new We(), Ce(this.#t), this.#r = /* @__PURE__ */ new Map(), e) for (let [n, r] of Object.entries(e)) {
|
|
548
548
|
let e = /* @__PURE__ */ new Map();
|
|
549
549
|
for (let t of r) {
|
|
550
550
|
let n = t.id;
|
|
@@ -574,10 +574,10 @@ var En = (e) => {
|
|
|
574
574
|
}
|
|
575
575
|
async query(e) {
|
|
576
576
|
let t = Hn(e, this.#e.get(this.#o(e.table)) ?? /* @__PURE__ */ new Map(), this.#s());
|
|
577
|
-
return
|
|
577
|
+
return ce(e) ? w(t, e.eager, De(e.table), (e) => this.query(e)) : t;
|
|
578
578
|
}
|
|
579
579
|
async insert(e, t) {
|
|
580
|
-
t =
|
|
580
|
+
t = Pe(e, t);
|
|
581
581
|
let n = t;
|
|
582
582
|
if (n.id === void 0) {
|
|
583
583
|
let r = this.#l(e);
|
|
@@ -768,10 +768,10 @@ var En = (e) => {
|
|
|
768
768
|
}
|
|
769
769
|
async query(e) {
|
|
770
770
|
let t = this.buildTablesView(e), n = Hn(e, this.materialise(e.table), t);
|
|
771
|
-
return
|
|
771
|
+
return ce(e) ? w(n, e.eager, De(e.table), (e) => this.query(e)) : n;
|
|
772
772
|
}
|
|
773
773
|
async insert(e, t) {
|
|
774
|
-
t =
|
|
774
|
+
t = Pe(e, t);
|
|
775
775
|
let n = t;
|
|
776
776
|
n.id === void 0 && (n = {
|
|
777
777
|
...t,
|
|
@@ -982,7 +982,7 @@ var En = (e) => {
|
|
|
982
982
|
t.add(e.column);
|
|
983
983
|
return;
|
|
984
984
|
}
|
|
985
|
-
e.op
|
|
985
|
+
e.op !== "exists" && e.op !== "not-exists" && t.add(e.column);
|
|
986
986
|
}
|
|
987
987
|
}, U = (e, t, n) => {
|
|
988
988
|
let r = e.get(t);
|
|
@@ -1145,7 +1145,7 @@ var En = (e) => {
|
|
|
1145
1145
|
};
|
|
1146
1146
|
}, Si = (e) => {
|
|
1147
1147
|
let t = j(e);
|
|
1148
|
-
return t === void 0 ? [] :
|
|
1148
|
+
return t === void 0 ? [] : Me(t);
|
|
1149
1149
|
}, Ci = (e, t) => {
|
|
1150
1150
|
if (t.length === 0) return e;
|
|
1151
1151
|
let n = !1, r = e.map((e) => {
|
|
@@ -1157,7 +1157,7 @@ var En = (e) => {
|
|
|
1157
1157
|
}, wi = (e, t) => Ci(t, Si(e)), Ti = (e, t) => {
|
|
1158
1158
|
let n = j(e);
|
|
1159
1159
|
if (n === void 0) return [];
|
|
1160
|
-
let r =
|
|
1160
|
+
let r = Me(n), i = we(n);
|
|
1161
1161
|
if (i.length === 0) return r;
|
|
1162
1162
|
let a = [...r];
|
|
1163
1163
|
for (let { column: e, scopes: n } of i) n.some((e) => Ot(t, e)) || a.push(e);
|
|
@@ -1188,7 +1188,7 @@ var En = (e) => {
|
|
|
1188
1188
|
}
|
|
1189
1189
|
}
|
|
1190
1190
|
async subscribe(e, t, n, r, i, a, o, s) {
|
|
1191
|
-
let c = `sub_${
|
|
1191
|
+
let c = `sub_${He()}`, l = i ?? `subscription.${e.table}`, u = lr(e), d = _r(e);
|
|
1192
1192
|
e.predicate !== void 0 && this.subscriptionRegistry.subscribe(c, e.table, e.predicate, r);
|
|
1193
1193
|
for (let e of u) {
|
|
1194
1194
|
let t = this.dependentByTable.get(e);
|
|
@@ -1272,7 +1272,7 @@ var En = (e) => {
|
|
|
1272
1272
|
});
|
|
1273
1273
|
}
|
|
1274
1274
|
async subscribeComputed(e, t, n, r) {
|
|
1275
|
-
let i = `csub_${
|
|
1275
|
+
let i = `csub_${He()}`, a = r ?? "subscription.computed", o = or(), s = new Set(e.dependentTables);
|
|
1276
1276
|
for (let e of o) for (let t of e.dependsOn) s.add(t);
|
|
1277
1277
|
let c = Array.from(s);
|
|
1278
1278
|
this.warnUndeclaredRawReads(a, o.filter((e) => e.dependsOn.length === 0));
|
|
@@ -1514,7 +1514,7 @@ var En = (e) => {
|
|
|
1514
1514
|
if (e.length !== t.length) return !1;
|
|
1515
1515
|
for (let n = 0; n < e.length; n++) if (JSON.stringify(e[n]) !== JSON.stringify(t[n])) return !1;
|
|
1516
1516
|
return !0;
|
|
1517
|
-
}, Mi = (e) => typeof e == "object" && !!e && e.__voltroComputed === !0, Ni =
|
|
1517
|
+
}, Mi = (e) => typeof e == "object" && !!e && e.__voltroComputed === !0, Ni = 864e5, Pi = 36e5, Fi = /* @__PURE__ */ new Map(), Ii = /* @__PURE__ */ new Map(), Li = (e, t) => {
|
|
1518
1518
|
t === void 0 ? Ii.delete(e) : Ii.set(e, t);
|
|
1519
1519
|
}, Ri = (e) => Ii.get(e), zi = (e, t) => {
|
|
1520
1520
|
Fi.set(e, {
|
|
@@ -1609,17 +1609,17 @@ var G = /* @__PURE__ */ new Map(), Gi = (e, t) => {
|
|
|
1609
1609
|
if (e.size === 0) return !1;
|
|
1610
1610
|
for (let n of e) if (n in t) return !0;
|
|
1611
1611
|
return !1;
|
|
1612
|
-
}, ia = (e) => /^[0-9a-f]{64}$/i.test(e) ? Buffer.from(e, "hex") :
|
|
1612
|
+
}, ia = (e) => /^[0-9a-f]{64}$/i.test(e) ? Buffer.from(e, "hex") : Ue(e, "voltro:field-encryption:v1", 32), aa = (e) => {
|
|
1613
1613
|
if (e.length !== 32) throw Error(`field cipher key must be 32 bytes, got ${e.length}`);
|
|
1614
1614
|
return {
|
|
1615
1615
|
encrypt: (t) => {
|
|
1616
|
-
let n =
|
|
1616
|
+
let n = Ve(12), r = Re("aes-256-gcm", e, n), i = Buffer.concat([r.update(t, "utf8"), r.final()]), a = r.getAuthTag();
|
|
1617
1617
|
return `${S}${n.toString("base64")}:${a.toString("base64")}:${i.toString("base64")}`;
|
|
1618
1618
|
},
|
|
1619
1619
|
decrypt: (t) => {
|
|
1620
1620
|
let [n, r, i] = t.slice(S.length).split(":");
|
|
1621
1621
|
if (!n || !r || i === void 0) throw Error("field cipher: malformed ciphertext");
|
|
1622
|
-
let a =
|
|
1622
|
+
let a = ze("aes-256-gcm", e, Buffer.from(n, "base64"));
|
|
1623
1623
|
return a.setAuthTag(Buffer.from(r, "base64")), Buffer.concat([a.update(Buffer.from(i, "base64")), a.final()]).toString("utf8");
|
|
1624
1624
|
}
|
|
1625
1625
|
};
|
|
@@ -1630,7 +1630,7 @@ var G = /* @__PURE__ */ new Map(), Gi = (e, t) => {
|
|
|
1630
1630
|
if (!t) throw Error(`encryptField: ${la}`);
|
|
1631
1631
|
return t.encrypt(e);
|
|
1632
1632
|
}, da = (e) => {
|
|
1633
|
-
if (!
|
|
1633
|
+
if (!ue(e)) return e;
|
|
1634
1634
|
let t = K();
|
|
1635
1635
|
if (!t) throw Error(`decryptField: ${la}`);
|
|
1636
1636
|
return t.decrypt(e);
|
|
@@ -1699,21 +1699,21 @@ var G = /* @__PURE__ */ new Map(), Gi = (e, t) => {
|
|
|
1699
1699
|
switch (n) {
|
|
1700
1700
|
case "=": return O(t, r);
|
|
1701
1701
|
case "!=":
|
|
1702
|
-
case "<>": return
|
|
1703
|
-
case ">": return
|
|
1704
|
-
case ">=": return
|
|
1705
|
-
case "<": return
|
|
1706
|
-
case "<=": return
|
|
1707
|
-
case "in": return
|
|
1702
|
+
case "<>": return ye(t, r);
|
|
1703
|
+
case ">": return M(t, r);
|
|
1704
|
+
case ">=": return se(t, r);
|
|
1705
|
+
case "<": return he(t, r);
|
|
1706
|
+
case "<=": return ge(t, r);
|
|
1707
|
+
case "in": return le(t, r);
|
|
1708
1708
|
case "contains":
|
|
1709
1709
|
case "fts": return te(t, r);
|
|
1710
|
-
case "startsWith": return
|
|
1710
|
+
case "startsWith": return Fe(t, r);
|
|
1711
1711
|
default: return O(t, r);
|
|
1712
1712
|
}
|
|
1713
1713
|
}, Oa = (e) => {
|
|
1714
1714
|
let t = j(e);
|
|
1715
1715
|
if (t === void 0) throw Error(`unknown table '${e}' — is it declared with table()?`);
|
|
1716
|
-
return
|
|
1716
|
+
return Se(t);
|
|
1717
1717
|
}, ka = class e {
|
|
1718
1718
|
backend;
|
|
1719
1719
|
scope;
|
|
@@ -1762,7 +1762,7 @@ var G = /* @__PURE__ */ new Map(), Gi = (e, t) => {
|
|
|
1762
1762
|
}
|
|
1763
1763
|
scopedQuery() {
|
|
1764
1764
|
let e = this.query, { subject: t, schemaRegistry: n } = this.scope;
|
|
1765
|
-
!this.skipTenant && n.hasTenant(this.table) && t.tenantId != null && (e = e.where(O("tenantId", t.tenantId))), !this.skipSoftDelete && n.hasSoftDelete(this.table) && (e = e.where(
|
|
1765
|
+
!this.skipTenant && n.hasTenant(this.table) && t.tenantId != null && (e = e.where(O("tenantId", t.tenantId))), !this.skipSoftDelete && n.hasSoftDelete(this.table) && (e = e.where(de("deletedAt")));
|
|
1766
1766
|
let r = (this.scope.rowFilter ?? gi)(this.table);
|
|
1767
1767
|
return r !== void 0 && (e = e.where(r)), e;
|
|
1768
1768
|
}
|
|
@@ -1917,10 +1917,12 @@ var G = /* @__PURE__ */ new Map(), Gi = (e, t) => {
|
|
|
1917
1917
|
if (t.rowFilter === void 0 && t.subject.type !== "system" && hi()) throw Error("row filter registered, but this store was scoped without one — refusing to serve an unfiltered read.\n\nThis app called `setRowFilter`, so every scoped store must receive a resolved `rowFilter` (the serve pipeline's `withRowFilter` does this per request). Reaching here with none means a read path was built outside that spine, and continuing would serve rows the filter exists to hide — silently, which is how this was found in the first place.\n\nIf this path is deliberately unfiltered (a system sweep, a migration), pass `rowFilter: NO_ROW_FILTER` explicitly.");
|
|
1918
1918
|
let a = t.rowFilter ?? gi, o = (e, n) => {
|
|
1919
1919
|
let a = { ...n }, o = t.schemaRegistry, s = o.idScheme(e);
|
|
1920
|
-
if (s !== void 0 && a[Ra] == null)
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1920
|
+
if (s !== void 0 && a[Ra] == null) {
|
|
1921
|
+
if (s.kind === "numeric") delete a[Ra];
|
|
1922
|
+
else {
|
|
1923
|
+
let t = A(s, e);
|
|
1924
|
+
t !== null && (a[Ra] = t);
|
|
1925
|
+
}
|
|
1924
1926
|
}
|
|
1925
1927
|
if (o.hasAudit(e)) {
|
|
1926
1928
|
let e = /* @__PURE__ */ new Date();
|
|
@@ -1980,7 +1982,7 @@ var G = /* @__PURE__ */ new Map(), Gi = (e, t) => {
|
|
|
1980
1982
|
let e = { deletedAt: /* @__PURE__ */ new Date() };
|
|
1981
1983
|
return r !== null && (e.deletedBy = r), e;
|
|
1982
1984
|
}, f = (e, t, n) => {
|
|
1983
|
-
let r =
|
|
1985
|
+
let r = _e(n, t);
|
|
1984
1986
|
if (r.length !== 0) throw new Fa({
|
|
1985
1987
|
table: e,
|
|
1986
1988
|
summary: `upsert conflictColumns [${n.map((e) => `'${e}'`).join(", ")}] but the payload is missing ${r.map((e) => `'${e}'`).join(", ")}`,
|
|
@@ -1992,7 +1994,7 @@ var G = /* @__PURE__ */ new Map(), Gi = (e, t) => {
|
|
|
1992
1994
|
}, p = (e, n) => {
|
|
1993
1995
|
let r = j(e);
|
|
1994
1996
|
if (r !== void 0) {
|
|
1995
|
-
let t =
|
|
1997
|
+
let t = ve(r, n);
|
|
1996
1998
|
if (t.length > 0) throw new Fa({
|
|
1997
1999
|
table: e,
|
|
1998
2000
|
summary: `missing required column${t.length > 1 ? "s" : ""} ${t.map((e) => `'${e}'`).join(", ")} — NOT NULL with no default and not auto-stamped`,
|
|
@@ -2016,8 +2018,8 @@ var G = /* @__PURE__ */ new Map(), Gi = (e, t) => {
|
|
|
2016
2018
|
issues: o
|
|
2017
2019
|
});
|
|
2018
2020
|
}, m = t.dialect, h = (e, t) => {
|
|
2019
|
-
let n = j(e);
|
|
2020
|
-
return ie(
|
|
2021
|
+
let n = j(e), r = m ? je(t, n, m) : t;
|
|
2022
|
+
return ie(r, n, K());
|
|
2021
2023
|
}, g = process.env.VOLTRO_FIELD_DECRYPT_ON_ERROR === "null" ? "null" : "throw", _ = B({ scope: "store.fieldEncryption" }), v = /* @__PURE__ */ new Set(), b = (e) => {
|
|
2022
2024
|
let t = `${e.table}.${e.column}`;
|
|
2023
2025
|
v.has(t) || (v.add(t), _.warn("encrypted column degraded to null — could not decrypt with the active key", {
|
|
@@ -2039,11 +2041,11 @@ var G = /* @__PURE__ */ new Map(), Gi = (e, t) => {
|
|
|
2039
2041
|
r = r ? C(r, e) : e;
|
|
2040
2042
|
}
|
|
2041
2043
|
if (!e.includeDeleted && t.schemaRegistry.hasSoftDelete(n)) {
|
|
2042
|
-
let e =
|
|
2044
|
+
let e = de("deletedAt");
|
|
2043
2045
|
r = r ? C(r, e) : e;
|
|
2044
2046
|
}
|
|
2045
2047
|
if (!e.includeExpired && t.schemaRegistry.hasExpires(n)) {
|
|
2046
|
-
let e =
|
|
2048
|
+
let e = be(de("expiresAt"), M("expiresAt", /* @__PURE__ */ new Date()));
|
|
2047
2049
|
r = r ? C(r, e) : e;
|
|
2048
2050
|
}
|
|
2049
2051
|
return r = bi(a, n, r), r === e.predicate ? e : {
|
|
@@ -2089,7 +2091,7 @@ var G = /* @__PURE__ */ new Map(), Gi = (e, t) => {
|
|
|
2089
2091
|
a = u(e, a);
|
|
2090
2092
|
let d = t.schemaRegistry.versionColumn(e);
|
|
2091
2093
|
if (d !== void 0) {
|
|
2092
|
-
let t =
|
|
2094
|
+
let t = xe({
|
|
2093
2095
|
versionColumn: d,
|
|
2094
2096
|
patch: a
|
|
2095
2097
|
}), i = await n.query({
|
|
@@ -2103,7 +2105,7 @@ var G = /* @__PURE__ */ new Map(), Gi = (e, t) => {
|
|
|
2103
2105
|
take: 1,
|
|
2104
2106
|
skip: void 0,
|
|
2105
2107
|
projection: void 0
|
|
2106
|
-
}), o = i[0] === void 0 ? void 0 : i[0][d], s = typeof o == "number" && Number.isFinite(o) ? o : null, c =
|
|
2108
|
+
}), o = i[0] === void 0 ? void 0 : i[0][d], s = typeof o == "number" && Number.isFinite(o) ? o : null, c = Ne({
|
|
2107
2109
|
table: e,
|
|
2108
2110
|
id: r,
|
|
2109
2111
|
expected: t.expected,
|
|
@@ -2121,10 +2123,10 @@ var G = /* @__PURE__ */ new Map(), Gi = (e, t) => {
|
|
|
2121
2123
|
}, D = async (e, r) => (await E(e, r), t.schemaRegistry.hasSoftDelete(e) ? await n.update(e, r, d()) !== null : n.delete(e, r)), te = async (e, t, r) => n.updateMany(e, h(e, s(e, t)), r), k = async (e, t) => n.deleteMany(e, t), ae = (e, n) => i != null && t.schemaRegistry.hasTenant(e) ? C(n, O("tenantId", i)) : n, oe = async (e, t, n) => te(e, t, {
|
|
2122
2124
|
...n,
|
|
2123
2125
|
where: ae(e, n.where)
|
|
2124
|
-
}),
|
|
2126
|
+
}), se = async (e, t) => k(e, {
|
|
2125
2127
|
...t,
|
|
2126
2128
|
where: ae(e, t.where)
|
|
2127
|
-
}),
|
|
2129
|
+
}), ce = Ma({
|
|
2128
2130
|
query: w,
|
|
2129
2131
|
updateMany: te,
|
|
2130
2132
|
deleteMany: k,
|
|
@@ -2133,10 +2135,10 @@ var G = /* @__PURE__ */ new Map(), Gi = (e, t) => {
|
|
|
2133
2135
|
subject: t.subject,
|
|
2134
2136
|
schemaRegistry: t.schemaRegistry,
|
|
2135
2137
|
rowFilter: a
|
|
2136
|
-
}),
|
|
2138
|
+
}), N = ((e, t, n) => t === void 0 ? ce.updateWhere(e) : ee(e, t, n)), P = ((e, t) => t === void 0 ? ce.deleteWhere(e) : D(e, t)), ue = async (e, t) => {
|
|
2137
2139
|
let r = t.map((t) => o(e, t)), i = r.map((t) => h(e, p(e, t))), a = await c(e, r[0] ?? {}, () => n.insertMany(e, i));
|
|
2138
2140
|
return x(e, a);
|
|
2139
|
-
},
|
|
2141
|
+
}, fe = (e, t) => {
|
|
2140
2142
|
let n = Object.keys(t);
|
|
2141
2143
|
if (n.length !== 1) throw Error(`store.links('${e}'): anchor must name exactly one source column, got [${n.join(", ")}]`);
|
|
2142
2144
|
let r = n[0], i = t[r], a = j(e);
|
|
@@ -2179,9 +2181,9 @@ var G = /* @__PURE__ */ new Map(), Gi = (e, t) => {
|
|
|
2179
2181
|
let r = o(e, t), i = await c(e, r, () => n.insert(e, h(e, p(e, r))));
|
|
2180
2182
|
return x(e, [i])[0];
|
|
2181
2183
|
},
|
|
2182
|
-
insertMany: (async (e, t) =>
|
|
2184
|
+
insertMany: (async (e, t) => ue(e, t)),
|
|
2183
2185
|
links: (e, t) => {
|
|
2184
|
-
let { sourceCol: n, sourceId: r, targetCol: i } =
|
|
2186
|
+
let { sourceCol: n, sourceId: r, targetCol: i } = fe(e, t), a = async () => (await T({
|
|
2185
2187
|
table: e,
|
|
2186
2188
|
predicate: O(n, r),
|
|
2187
2189
|
order: [],
|
|
@@ -2189,12 +2191,12 @@ var G = /* @__PURE__ */ new Map(), Gi = (e, t) => {
|
|
|
2189
2191
|
skip: void 0,
|
|
2190
2192
|
take: void 0
|
|
2191
2193
|
})).map((e) => String(e[i])), o = async (t) => {
|
|
2192
|
-
t.length !== 0 && await
|
|
2194
|
+
t.length !== 0 && await ue(e, t.map((e) => ({
|
|
2193
2195
|
[n]: r,
|
|
2194
2196
|
[i]: e
|
|
2195
2197
|
})));
|
|
2196
2198
|
}, s = async (t) => {
|
|
2197
|
-
t.length !== 0 && await
|
|
2199
|
+
t.length !== 0 && await se(e, { where: C(O(n, r), le(i, t)) });
|
|
2198
2200
|
};
|
|
2199
2201
|
return {
|
|
2200
2202
|
list: a,
|
|
@@ -2235,10 +2237,10 @@ var G = /* @__PURE__ */ new Map(), Gi = (e, t) => {
|
|
|
2235
2237
|
});
|
|
2236
2238
|
else {
|
|
2237
2239
|
let s = a.get(t), c = {}, l = !1;
|
|
2238
|
-
for (let [e, t] of Object.entries(o)) e
|
|
2240
|
+
for (let [e, t] of Object.entries(o)) e !== n && e !== i && s[e] !== t && (c[e] = t, l = !0);
|
|
2239
2241
|
l && (d.push(t), await oe(e, c, { where: C(O(n, r), O(i, t)) }));
|
|
2240
2242
|
}
|
|
2241
|
-
return f.length > 0 && await
|
|
2243
|
+
return f.length > 0 && await ue(e, f), {
|
|
2242
2244
|
added: u,
|
|
2243
2245
|
removed: l,
|
|
2244
2246
|
updated: d
|
|
@@ -2251,13 +2253,13 @@ var G = /* @__PURE__ */ new Map(), Gi = (e, t) => {
|
|
|
2251
2253
|
let a = await n.patchJson(e, t, r, i);
|
|
2252
2254
|
return a === null ? null : x(e, [a])[0];
|
|
2253
2255
|
},
|
|
2254
|
-
select:
|
|
2255
|
-
update:
|
|
2256
|
-
delete:
|
|
2256
|
+
select: ce.select,
|
|
2257
|
+
update: N,
|
|
2258
|
+
delete: P,
|
|
2257
2259
|
applyDefined: Ba,
|
|
2258
2260
|
hardDelete: async (e, t) => (await E(e, t), n.delete(e, t)),
|
|
2259
2261
|
updateMany: oe,
|
|
2260
|
-
deleteMany:
|
|
2262
|
+
deleteMany: se,
|
|
2261
2263
|
upsert: async (e, t, r) => {
|
|
2262
2264
|
let i = o(e, t);
|
|
2263
2265
|
f(e, i, r.conflictColumns);
|
|
@@ -2365,13 +2367,15 @@ var G = /* @__PURE__ */ new Map(), Gi = (e, t) => {
|
|
|
2365
2367
|
let t = e.now ?? Date.now, n = e.keyPrefix ?? "voltro:ryw", r = e.channel ?? `${n}:bus`, i = e.onError ?? ((e, t) => {
|
|
2366
2368
|
process.stderr.write(`[voltro:ryw] redis ${t} failed: ${String(e)}\n`);
|
|
2367
2369
|
}), a = `${process.pid ?? 0}:${Math.random() * 1e9 | 0}:${t()}`, o = /* @__PURE__ */ new Map(), s = (e) => {
|
|
2368
|
-
if (e.senderId !== a)
|
|
2369
|
-
if (e.
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2370
|
+
if (e.senderId !== a) {
|
|
2371
|
+
if (e.op === "set") {
|
|
2372
|
+
if (e.position === void 0 || e.expiresAt === void 0) return;
|
|
2373
|
+
o.set(e.subjectKey, {
|
|
2374
|
+
position: e.position,
|
|
2375
|
+
expiresAt: e.expiresAt
|
|
2376
|
+
});
|
|
2377
|
+
} else o.delete(e.subjectKey);
|
|
2378
|
+
}
|
|
2375
2379
|
};
|
|
2376
2380
|
e.subscriber.subscribe(r).then(() => {
|
|
2377
2381
|
e.subscriber.on("message", (e, t) => {
|
|
@@ -3002,7 +3006,7 @@ var G = /* @__PURE__ */ new Map(), Gi = (e, t) => {
|
|
|
3002
3006
|
tag: r,
|
|
3003
3007
|
kind: "query"
|
|
3004
3008
|
};
|
|
3005
|
-
if (
|
|
3009
|
+
if (n === "query" || n === "mutation" || n === "action" || n === "stream") return {
|
|
3006
3010
|
tag: r,
|
|
3007
3011
|
kind: n
|
|
3008
3012
|
};
|
|
@@ -3011,13 +3015,13 @@ var G = /* @__PURE__ */ new Map(), Gi = (e, t) => {
|
|
|
3011
3015
|
let n = Ho(e);
|
|
3012
3016
|
return n === void 0 ? t() : ya(n, t);
|
|
3013
3017
|
}, Wo = (e, t, n, r) => e === "subject" ? `${t}:s:${n}` : e === "global" ? `${t}:global` : r.tenantId == null ? void 0 : `${t}:t:${r.tenantId}`, Go = (e, t) => o.async((n) => {
|
|
3014
|
-
let r =
|
|
3018
|
+
let r = Ae(t, () => o.runFork(e));
|
|
3015
3019
|
return r.addObserver((e) => {
|
|
3016
3020
|
n(e);
|
|
3017
3021
|
}), o.asVoid(l.interrupt(r));
|
|
3018
3022
|
}), Ko = (e, t, n) => ({
|
|
3019
3023
|
subject: e,
|
|
3020
|
-
traceId: t?.traceId ??
|
|
3024
|
+
traceId: t?.traceId ?? He(),
|
|
3021
3025
|
...t?.spanId === void 0 ? {} : { spanId: t.spanId },
|
|
3022
3026
|
...n === void 0 ? {} : { clientId: n }
|
|
3023
3027
|
}), qo = o.currentSpan.pipe(o.catchAll(() => o.succeed(void 0))), Jo = (e) => ({
|
|
@@ -3095,7 +3099,7 @@ var G = /* @__PURE__ */ new Map(), Gi = (e, t) => {
|
|
|
3095
3099
|
yield* o.addFinalizer(() => o.sync(() => e()));
|
|
3096
3100
|
}
|
|
3097
3101
|
})), ns = (e, t, n = "rpc.subscription", r, i, a, s) => b.unwrap(o.gen(function* () {
|
|
3098
|
-
let c = yield*
|
|
3102
|
+
let c = yield* ht, l = yield* at, u = yield* qo;
|
|
3099
3103
|
Yo(u, n, c);
|
|
3100
3104
|
let d = Ko(c, u, l.clientId), f = Ja(c.id, l.clientId), p = Qa({ subjectKey: f }, () => ea({
|
|
3101
3105
|
traceId: d.traceId,
|
|
@@ -3126,9 +3130,9 @@ var G = /* @__PURE__ */ new Map(), Gi = (e, t) => {
|
|
|
3126
3130
|
swrMs: i.swrMs
|
|
3127
3131
|
}, a?.(c), s?.(c) ?? Xo(c)), l.credentialExpiresAt, b.empty);
|
|
3128
3132
|
}).pipe(o.withSpan(n, { attributes: { "framework.kind": "subscription" } }))), rs = (e, t = "rpc.stream", n, r) => b.unwrap(o.gen(function* () {
|
|
3129
|
-
let a = yield*
|
|
3133
|
+
let a = yield* ht, s = yield* at, c = yield* qo;
|
|
3130
3134
|
Yo(c, t, a);
|
|
3131
|
-
let l = Ko(a, c, s.clientId), u = Uo(t, () => e(l)), d = o.isEffect(u) ? yield* u.pipe(o.orDie) : u, f = n === void 0 || n.length === 0 ? void 0 : () =>
|
|
3135
|
+
let l = Ko(a, c, s.clientId), u = Uo(t, () => e(l)), d = o.isEffect(u) ? yield* u.pipe(o.orDie) : u, f = n === void 0 || n.length === 0 ? void 0 : () => xt(a, n, r), p = io(f === void 0 ? d : b.unwrap(f().pipe(o.map((e) => e ? b.fail(e) : b.flatMap(d, (e) => b.unwrap(f().pipe(o.map((t) => t ? b.fail(t) : b.make(e)))))))), s.credentialExpiresAt, b.empty);
|
|
3132
3136
|
if (l.clientId === void 0) return p;
|
|
3133
3137
|
let m = l.clientId;
|
|
3134
3138
|
return b.unwrapScoped(o.gen(function* () {
|
|
@@ -3169,7 +3173,7 @@ var G = /* @__PURE__ */ new Map(), Gi = (e, t) => {
|
|
|
3169
3173
|
message: "internal server error"
|
|
3170
3174
|
};
|
|
3171
3175
|
let r = n && typeof n == "object" ? n : {}, i = {};
|
|
3172
|
-
for (let [e, t] of Object.entries(r)) e
|
|
3176
|
+
for (let [e, t] of Object.entries(r)) e !== "cause" && e !== "stack" && e !== "message" && (t === null || typeof t == "string" || typeof t == "number" || typeof t == "boolean") && (i[e] = t);
|
|
3173
3177
|
let a = n?._tag, o = n instanceof Error ? n.message : n?.message;
|
|
3174
3178
|
return {
|
|
3175
3179
|
...i,
|
|
@@ -3200,7 +3204,7 @@ var G = /* @__PURE__ */ new Map(), Gi = (e, t) => {
|
|
|
3200
3204
|
message: "a request with this idempotency key is already in flight",
|
|
3201
3205
|
traceId: e
|
|
3202
3206
|
}), gs = (e, t, n = "rpc.mutation", r, i, a) => o.gen(function* () {
|
|
3203
|
-
let s = yield*
|
|
3207
|
+
let s = yield* ht, c = yield* at, l = yield* qo;
|
|
3204
3208
|
Yo(l, n, s);
|
|
3205
3209
|
let u = Ko(s, l, c.clientId), d = i && c.idempotencyKey ? {
|
|
3206
3210
|
store: i.store,
|
|
@@ -3209,7 +3213,7 @@ var G = /* @__PURE__ */ new Map(), Gi = (e, t) => {
|
|
|
3209
3213
|
scope: Vt(s.tenantId, Ua(s), n)
|
|
3210
3214
|
} : null;
|
|
3211
3215
|
if (d) {
|
|
3212
|
-
let e = yield* o.promise(() =>
|
|
3216
|
+
let e = yield* o.promise(() => bt(d.store, d.scope, d.key, d.ttlMs, Date.now()));
|
|
3213
3217
|
if (e.kind === "replay") return r ? r.decode(e.response.body) : e.response.body;
|
|
3214
3218
|
if (e.kind === "conflict") return yield* o.die(hs(u.traceId));
|
|
3215
3219
|
}
|
|
@@ -3220,7 +3224,7 @@ var G = /* @__PURE__ */ new Map(), Gi = (e, t) => {
|
|
|
3220
3224
|
}, m = Qa({ subjectKey: f }, () => ea({
|
|
3221
3225
|
traceId: u.traceId,
|
|
3222
3226
|
...u.spanId === void 0 ? {} : { spanId: u.spanId }
|
|
3223
|
-
}, () =>
|
|
3227
|
+
}, () => Ae(p, () => Uo(n, () => e(t, u))))), h = o.isEffect(m) ? Go(m, p) : o.tryPromise({
|
|
3224
3228
|
try: () => Promise.resolve(m),
|
|
3225
3229
|
catch: (e) => e
|
|
3226
3230
|
});
|
|
@@ -3228,7 +3232,7 @@ var G = /* @__PURE__ */ new Map(), Gi = (e, t) => {
|
|
|
3228
3232
|
status: 200,
|
|
3229
3233
|
body: r ? r.encode(e) : e
|
|
3230
3234
|
}, Date.now())).pipe(o.ignore)), o.tapErrorCause(() => o.promise(() => Et(d.store, d.scope, d.key)).pipe(o.ignore))) : h).pipe(o.tapErrorCause((e) => o.sync(() => ss(n, u.traceId, e))), o.catchIf(ls, () => o.die(ds(u.traceId))), o.catchIf((e) => e instanceof Error && typeof e._tag != "string", (e) => o.die(ds(u.traceId, fs(e)))), o.catchIf((e) => a !== void 0 && typeof e?._tag == "string" && !us(a, e), (e) => o.die(ds(u.traceId, fs(e)))), o.catchAllDefect((e) => e?._tag === "InternalError" ? o.die(e) : o.die(ds(u.traceId, fs(e)))), o.annotateLogs(Jo(u)));
|
|
3231
|
-
}).pipe(o.withSpan(n, { attributes: { "framework.kind": "mutation" } })), _s =
|
|
3235
|
+
}).pipe(o.withSpan(n, { attributes: { "framework.kind": "mutation" } })), _s = 8388608, vs = (t) => {
|
|
3232
3236
|
let n = t.port ?? 4e3, r = t.host, i = t.path ?? "/ws", a = i;
|
|
3233
3237
|
Vo(t.webhookRoutes);
|
|
3234
3238
|
let s = Gt(), c = (e) => Zt.HttpServerRequest.pipe(o.flatMap((e) => o.gen(function* () {
|
|
@@ -3510,11 +3514,11 @@ var G = /* @__PURE__ */ new Map(), Gi = (e, t) => {
|
|
|
3510
3514
|
t.tracerLayer && (A = A.pipe(u.provide(t.tracerLayer)));
|
|
3511
3515
|
let oe = B({ scope: "voltro:rpc" }), j = u.launch(A).pipe(o.catchAllCause((t) => o.sync(() => {
|
|
3512
3516
|
oe.error("rpc server crashed", {}, e.squash(t)), process.exit(1);
|
|
3513
|
-
}))),
|
|
3514
|
-
return ys.add(
|
|
3517
|
+
}))), M = o.runFork(j);
|
|
3518
|
+
return ys.add(M), Os(), {
|
|
3515
3519
|
server: s,
|
|
3516
3520
|
shutdown: async () => {
|
|
3517
|
-
ys.delete(
|
|
3521
|
+
ys.delete(M), await o.runPromise(l.interrupt(M)).then(() => void 0, () => void 0);
|
|
3518
3522
|
}
|
|
3519
3523
|
};
|
|
3520
3524
|
}, ys = /* @__PURE__ */ new Set(), bs = /* @__PURE__ */ new Set(), xs = !1, Ss = (e) => (bs.add(e), () => {
|
|
@@ -3853,10 +3857,10 @@ var G = /* @__PURE__ */ new Map(), Gi = (e, t) => {
|
|
|
3853
3857
|
}),
|
|
3854
3858
|
has: (n) => t("has", n, async () => {
|
|
3855
3859
|
let t = await cc(e, n);
|
|
3856
|
-
return t === null ? !1 : oc(t, Date.now())
|
|
3860
|
+
return t === null ? !1 : !oc(t, Date.now()) || (await e.delete(q, t.id), !1);
|
|
3857
3861
|
}),
|
|
3858
3862
|
list: (n) => t("list", "", async () => {
|
|
3859
|
-
let t = Date.now(), r =
|
|
3863
|
+
let t = Date.now(), r = be(de("expiresAt"), M("expiresAt", new Date(t))), i = n === "" ? r : C(te("key", n), r), a = await e.query({
|
|
3860
3864
|
table: q,
|
|
3861
3865
|
predicate: i,
|
|
3862
3866
|
order: [],
|
|
@@ -3898,7 +3902,7 @@ var G = /* @__PURE__ */ new Map(), Gi = (e, t) => {
|
|
|
3898
3902
|
has: () => Promise.resolve(!1),
|
|
3899
3903
|
list: () => Promise.resolve([]),
|
|
3900
3904
|
clear: () => Promise.resolve()
|
|
3901
|
-
}, fc = "_voltro_api_keys", pc = (e) =>
|
|
3905
|
+
}, fc = "_voltro_api_keys", pc = (e) => Be("sha256").update(e, "utf8").digest("hex"), mc = (e = "voltro_") => `${e}${Ve(30).toString("base64url")}`, hc = (e) => ({
|
|
3902
3906
|
id: e.id,
|
|
3903
3907
|
name: e.name,
|
|
3904
3908
|
keyPrefix: e.keyPrefix,
|
|
@@ -4080,10 +4084,10 @@ var G = /* @__PURE__ */ new Map(), Gi = (e, t) => {
|
|
|
4080
4084
|
path: `${t}/issue`,
|
|
4081
4085
|
summary: "Issue an API key (the token is returned ONCE).",
|
|
4082
4086
|
guards: [sn([
|
|
4087
|
+
Ge,
|
|
4088
|
+
Je,
|
|
4083
4089
|
Ke,
|
|
4084
|
-
|
|
4085
|
-
qe,
|
|
4086
|
-
Je
|
|
4090
|
+
qe
|
|
4087
4091
|
])],
|
|
4088
4092
|
input: y.Struct({ body: y.Struct({
|
|
4089
4093
|
name: y.String,
|
|
@@ -4097,25 +4101,25 @@ var G = /* @__PURE__ */ new Map(), Gi = (e, t) => {
|
|
|
4097
4101
|
keyPrefix: y.String
|
|
4098
4102
|
}),
|
|
4099
4103
|
handler: async (t, n) => {
|
|
4100
|
-
let r = t.body, i = wc(n), a = new Set(i.scopes), o = (e) => a.has(
|
|
4104
|
+
let r = t.body, i = wc(n), a = new Set(i.scopes), o = (e) => a.has(Ge) || a.has(e), s = r.onBehalfOf === void 0 ? i.id : r.onBehalfOf;
|
|
4101
4105
|
if (s === null) {
|
|
4102
|
-
if (!o(
|
|
4103
|
-
required:
|
|
4106
|
+
if (!o(Ke)) throw new mt({
|
|
4107
|
+
required: Ke,
|
|
4104
4108
|
message: "not allowed to issue an organization key"
|
|
4105
4109
|
});
|
|
4106
4110
|
} else if (s !== i.id) {
|
|
4107
|
-
if (!o(
|
|
4108
|
-
required:
|
|
4111
|
+
if (!o(qe)) throw new mt({
|
|
4112
|
+
required: qe,
|
|
4109
4113
|
message: "not allowed to issue a key on behalf of another user"
|
|
4110
4114
|
});
|
|
4111
|
-
} else if (!o(
|
|
4112
|
-
required:
|
|
4115
|
+
} else if (!o(Je)) throw new mt({
|
|
4116
|
+
required: Je,
|
|
4113
4117
|
message: "not allowed to issue an api key"
|
|
4114
4118
|
});
|
|
4115
4119
|
let c = r.scopes ?? [...a];
|
|
4116
|
-
if (!a.has(
|
|
4120
|
+
if (!a.has(Ge)) {
|
|
4117
4121
|
let e = c.filter((e) => !a.has(e));
|
|
4118
|
-
if (e.length > 0) throw new
|
|
4122
|
+
if (e.length > 0) throw new mt({
|
|
4119
4123
|
required: String(e[0]),
|
|
4120
4124
|
message: `cannot issue a key with scopes you do not hold: ${e.join(", ")}`
|
|
4121
4125
|
});
|
|
@@ -4139,7 +4143,7 @@ var G = /* @__PURE__ */ new Map(), Gi = (e, t) => {
|
|
|
4139
4143
|
method: "GET",
|
|
4140
4144
|
path: t,
|
|
4141
4145
|
summary: "List the caller tenant's API keys (no secrets).",
|
|
4142
|
-
guards: [cn(
|
|
4146
|
+
guards: [cn(Ge)],
|
|
4143
4147
|
input: y.Struct({}),
|
|
4144
4148
|
output: y.Struct({ keys: y.Array(n) }),
|
|
4145
4149
|
handler: async (t, n) => ({ keys: [...await e.list(wc(n).tenantId)] })
|
|
@@ -4148,7 +4152,7 @@ var G = /* @__PURE__ */ new Map(), Gi = (e, t) => {
|
|
|
4148
4152
|
method: "POST",
|
|
4149
4153
|
path: `${t}/revoke`,
|
|
4150
4154
|
summary: "Revoke an API key by id.",
|
|
4151
|
-
guards: [cn(
|
|
4155
|
+
guards: [cn(Ge)],
|
|
4152
4156
|
input: y.Struct({ body: y.Struct({ id: y.String }) }),
|
|
4153
4157
|
output: y.Struct({ ok: y.Boolean }),
|
|
4154
4158
|
handler: async (t, n) => ({ ok: await e.revoke(t.body.id, wc(n).tenantId) })
|
|
@@ -4173,7 +4177,7 @@ var G = /* @__PURE__ */ new Map(), Gi = (e, t) => {
|
|
|
4173
4177
|
hardDelete: (t, n) => kc("hardDelete", t, () => e.hardDelete(t, n))
|
|
4174
4178
|
}), jc = (e) => tn.make(e.name, {
|
|
4175
4179
|
payload: Rt(e.payloadSchema),
|
|
4176
|
-
success:
|
|
4180
|
+
success: yt,
|
|
4177
4181
|
error: e.errorSchema
|
|
4178
4182
|
}), Mc = (e, t) => ({
|
|
4179
4183
|
id: t,
|
|
@@ -4532,7 +4536,7 @@ var G = /* @__PURE__ */ new Map(), Gi = (e, t) => {
|
|
|
4532
4536
|
executionId: i,
|
|
4533
4537
|
parentExecutionId: a?.parentExecutionId ?? null,
|
|
4534
4538
|
parentClosePolicy: a?.parentClosePolicy ?? null
|
|
4535
|
-
}), d = e.buildExecute(l), f = (n?.(e, d, c) ?? d)(r, i), p = u.succeed(
|
|
4539
|
+
}), d = e.buildExecute(l), f = (n?.(e, d, c) ?? d)(r, i), p = u.succeed(ht, c.subject), m = l?.store, h = m === void 0 ? f : o.provide(f, Ac(m));
|
|
4536
4540
|
return o.provide(h, p);
|
|
4537
4541
|
}));
|
|
4538
4542
|
}))), Zc = (e) => {
|
|
@@ -4551,32 +4555,32 @@ var G = /* @__PURE__ */ new Map(), Gi = (e, t) => {
|
|
|
4551
4555
|
}, Qc = Zc, $c = (e) => typeof e == "object" && !!e && e._tag === "workflowEventTrigger", el = () => {
|
|
4552
4556
|
let e = globalThis.crypto;
|
|
4553
4557
|
return typeof e?.randomUUID == "function" ? e.randomUUID() : `${Date.now().toString(36)}${Math.random().toString(36).slice(2)}`;
|
|
4554
|
-
}, tl = (e) => `${e}_${el()}`, nl = (e) => e.id ?? `${e.event}->${e.workflow}`, rl =
|
|
4555
|
-
id:
|
|
4556
|
-
name:
|
|
4557
|
-
payload:
|
|
4558
|
-
source:
|
|
4559
|
-
subject:
|
|
4560
|
-
traceId:
|
|
4561
|
-
occurredAt:
|
|
4562
|
-
}).index(["name"]).index(["source"]).index(["occurredAt"]), il =
|
|
4563
|
-
id:
|
|
4564
|
-
eventId:
|
|
4565
|
-
eventName:
|
|
4566
|
-
triggerId:
|
|
4567
|
-
workflowName:
|
|
4568
|
-
executionId:
|
|
4569
|
-
status:
|
|
4558
|
+
}, tl = (e) => `${e}_${el()}`, nl = (e) => e.id ?? `${e.event}->${e.workflow}`, rl = I("_voltro_workflow_events", {
|
|
4559
|
+
id: N({ prefix: "wfe" }),
|
|
4560
|
+
name: L(),
|
|
4561
|
+
payload: F(),
|
|
4562
|
+
source: L(),
|
|
4563
|
+
subject: F().nullable(),
|
|
4564
|
+
traceId: L().nullable(),
|
|
4565
|
+
occurredAt: R().default("now")
|
|
4566
|
+
}).index(["name"]).index(["source"]).index(["occurredAt"]), il = I("_voltro_workflow_event_deliveries", {
|
|
4567
|
+
id: N({ prefix: "wfed" }),
|
|
4568
|
+
eventId: L(),
|
|
4569
|
+
eventName: L(),
|
|
4570
|
+
triggerId: L(),
|
|
4571
|
+
workflowName: L(),
|
|
4572
|
+
executionId: L().nullable(),
|
|
4573
|
+
status: L().oneOf([
|
|
4570
4574
|
"starting",
|
|
4571
4575
|
"started",
|
|
4572
4576
|
"skipped",
|
|
4573
4577
|
"failed"
|
|
4574
4578
|
]).default("starting"),
|
|
4575
|
-
idempotencyKey:
|
|
4579
|
+
idempotencyKey: L().unique(),
|
|
4576
4580
|
skipped: E().default(!1),
|
|
4577
|
-
errorMessage:
|
|
4578
|
-
createdAt:
|
|
4579
|
-
completedAt:
|
|
4581
|
+
errorMessage: L().nullable(),
|
|
4582
|
+
createdAt: R().default("now"),
|
|
4583
|
+
completedAt: R().nullable()
|
|
4580
4584
|
}).index(["eventId"]).index(["eventName"]).index(["triggerId"]).index(["workflowName"]).index(["status"]), al = (e) => {
|
|
4581
4585
|
let t = e.makeId ?? tl, n = /* @__PURE__ */ new Map();
|
|
4582
4586
|
for (let t of e.triggers) {
|
|
@@ -4722,7 +4726,7 @@ var G = /* @__PURE__ */ new Map(), Gi = (e, t) => {
|
|
|
4722
4726
|
triggered: p
|
|
4723
4727
|
};
|
|
4724
4728
|
} };
|
|
4725
|
-
}, ol = B({ scope: "voltro:events" }), sl = 64, cl =
|
|
4729
|
+
}, ol = B({ scope: "voltro:events" }), sl = 64, cl = 3e5, ll = 1e4, ul = class {
|
|
4726
4730
|
routes = /* @__PURE__ */ new Map();
|
|
4727
4731
|
origin;
|
|
4728
4732
|
ringSize;
|
|
@@ -4928,10 +4932,10 @@ var G = /* @__PURE__ */ new Map(), Gi = (e, t) => {
|
|
|
4928
4932
|
this.routes.clear();
|
|
4929
4933
|
}
|
|
4930
4934
|
}, dl = (e) => e instanceof Error ? e.message : String(e), fl = (e, t, n, r) => o.gen(function* () {
|
|
4931
|
-
let i = y.encode(t.key), a = y.encode(t.payload), s = yield* i(n).pipe(o.mapError((e) => new
|
|
4935
|
+
let i = y.encode(t.key), a = y.encode(t.payload), s = yield* i(n).pipe(o.mapError((e) => new ut({
|
|
4932
4936
|
event: t.name,
|
|
4933
4937
|
message: dl(e)
|
|
4934
|
-
}))), c = yield* a(r).pipe(o.mapError((e) => new
|
|
4938
|
+
}))), c = yield* a(r).pipe(o.mapError((e) => new dt({
|
|
4935
4939
|
event: t.name,
|
|
4936
4940
|
message: dl(e)
|
|
4937
4941
|
}))), l = Buffer.byteLength(JSON.stringify({
|
|
@@ -4939,10 +4943,10 @@ var G = /* @__PURE__ */ new Map(), Gi = (e, t) => {
|
|
|
4939
4943
|
key: s,
|
|
4940
4944
|
payload: c
|
|
4941
4945
|
}), "utf8");
|
|
4942
|
-
if (l >
|
|
4946
|
+
if (l > pt) return yield* o.fail(new ft({
|
|
4943
4947
|
event: t.name,
|
|
4944
4948
|
bytes: l,
|
|
4945
|
-
limit:
|
|
4949
|
+
limit: pt
|
|
4946
4950
|
}));
|
|
4947
4951
|
let u = () => {
|
|
4948
4952
|
let n = e.bus.publish({
|
|
@@ -4982,9 +4986,9 @@ var G = /* @__PURE__ */ new Map(), Gi = (e, t) => {
|
|
|
4982
4986
|
return t.set(e.origin, Math.max(r, e.n)), r === 0 && n === 0 ? 0 : Math.max(0, e.n - r - 1);
|
|
4983
4987
|
};
|
|
4984
4988
|
}, yl = (e) => b.unwrapScoped(o.gen(function* () {
|
|
4985
|
-
let t = yield*
|
|
4989
|
+
let t = yield* ht, n = yield* at, r = t.tenantId ?? null, i = e.guards === void 0 ? void 0 : e.guards.filter((e) => !At(e));
|
|
4986
4990
|
if (i !== void 0 && i.length > 0) {
|
|
4987
|
-
let n = yield*
|
|
4991
|
+
let n = yield* xt(t, i, e.key);
|
|
4988
4992
|
if (n) return yield* o.fail(n);
|
|
4989
4993
|
}
|
|
4990
4994
|
let a = e.bus.deliveryFor(e.event) === "latest", s = yield* g.sliding(e.queueSize ?? (a ? 1 : 64)), c = /* @__PURE__ */ new Map(), l = e.bus.subscribe({
|
|
@@ -5009,7 +5013,7 @@ var G = /* @__PURE__ */ new Map(), Gi = (e, t) => {
|
|
|
5009
5013
|
e();
|
|
5010
5014
|
}));
|
|
5011
5015
|
}
|
|
5012
|
-
let u = a ? () => 0 : vl(c), d = i === void 0 || i.length === 0 ? void 0 : () =>
|
|
5016
|
+
let u = a ? () => 0 : vl(c), d = i === void 0 || i.length === 0 ? void 0 : () => xt(t, i, e.key), f = b.fromQueue(s, { shutdown: !0 }).pipe(b.flatMap((e) => d === void 0 ? p(e) : b.unwrap(d().pipe(o.map((t) => t ? b.fail(t) : p(e))))));
|
|
5013
5017
|
function p(t) {
|
|
5014
5018
|
return b.suspend(() => {
|
|
5015
5019
|
if (t.kind === "gap") return b.make(_l(t));
|
|
@@ -5129,48 +5133,48 @@ var G = /* @__PURE__ */ new Map(), Gi = (e, t) => {
|
|
|
5129
5133
|
}, Cl = B({ scope: "voltro:outbox" }), J = "_voltro_outbox", wl = {
|
|
5130
5134
|
kind: "typeid",
|
|
5131
5135
|
prefix: "obx"
|
|
5132
|
-
}, Tl =
|
|
5133
|
-
id:
|
|
5134
|
-
effect:
|
|
5135
|
-
payload:
|
|
5136
|
-
status:
|
|
5137
|
-
attempts:
|
|
5138
|
-
maxAttempts:
|
|
5139
|
-
nextAttemptAt:
|
|
5140
|
-
idempotencyKey:
|
|
5141
|
-
lastError:
|
|
5142
|
-
subjectId:
|
|
5143
|
-
tenantId:
|
|
5144
|
-
traceId:
|
|
5145
|
-
createdAt:
|
|
5146
|
-
deliveredAt:
|
|
5147
|
-
resendRequestedBy:
|
|
5148
|
-
resendReason:
|
|
5149
|
-
resendCount:
|
|
5136
|
+
}, Tl = I(J, {
|
|
5137
|
+
id: N({ prefix: "obx" }),
|
|
5138
|
+
effect: L(),
|
|
5139
|
+
payload: F(),
|
|
5140
|
+
status: L(),
|
|
5141
|
+
attempts: P(),
|
|
5142
|
+
maxAttempts: P(),
|
|
5143
|
+
nextAttemptAt: R(),
|
|
5144
|
+
idempotencyKey: L().nullable(),
|
|
5145
|
+
lastError: L().nullable(),
|
|
5146
|
+
subjectId: L().nullable(),
|
|
5147
|
+
tenantId: L().nullable(),
|
|
5148
|
+
traceId: L().nullable(),
|
|
5149
|
+
createdAt: R(),
|
|
5150
|
+
deliveredAt: R().nullable(),
|
|
5151
|
+
resendRequestedBy: L().nullable(),
|
|
5152
|
+
resendReason: L().nullable(),
|
|
5153
|
+
resendCount: P()
|
|
5150
5154
|
}), El = "_voltro_outbox_attempts", Dl = {
|
|
5151
5155
|
kind: "typeid",
|
|
5152
5156
|
prefix: "obxa"
|
|
5153
|
-
}, Ol =
|
|
5154
|
-
id:
|
|
5155
|
-
outboxId:
|
|
5156
|
-
effect:
|
|
5157
|
-
attempt:
|
|
5158
|
-
trigger:
|
|
5159
|
-
triggeredBy:
|
|
5160
|
-
reason:
|
|
5161
|
-
outcome:
|
|
5157
|
+
}, Ol = I(El, {
|
|
5158
|
+
id: N({ prefix: "obxa" }),
|
|
5159
|
+
outboxId: L(),
|
|
5160
|
+
effect: L(),
|
|
5161
|
+
attempt: P(),
|
|
5162
|
+
trigger: L().oneOf(["automatic", "manual"]),
|
|
5163
|
+
triggeredBy: L().nullable(),
|
|
5164
|
+
reason: L().nullable(),
|
|
5165
|
+
outcome: L().oneOf([
|
|
5162
5166
|
"delivered",
|
|
5163
5167
|
"failed",
|
|
5164
5168
|
"dead"
|
|
5165
5169
|
]),
|
|
5166
|
-
startedAt:
|
|
5167
|
-
finishedAt:
|
|
5168
|
-
durationMs:
|
|
5169
|
-
error:
|
|
5170
|
-
response:
|
|
5171
|
-
subjectId:
|
|
5172
|
-
tenantId:
|
|
5173
|
-
traceId:
|
|
5170
|
+
startedAt: R(),
|
|
5171
|
+
finishedAt: R(),
|
|
5172
|
+
durationMs: P(),
|
|
5173
|
+
error: L().nullable(),
|
|
5174
|
+
response: F().nullable(),
|
|
5175
|
+
subjectId: L().nullable(),
|
|
5176
|
+
tenantId: L().nullable(),
|
|
5177
|
+
traceId: L().nullable()
|
|
5174
5178
|
}).index(["outboxId", "attempt"]).index(["startedAt"]).index(["outcome"]), kl = (e) => {
|
|
5175
5179
|
if (e.effect.trim() === "") throw Error("defineOutboxHandler: `effect` must be a non-empty name");
|
|
5176
5180
|
if (e.maxAttempts !== void 0 && e.maxAttempts < 1) throw Error(`defineOutboxHandler("${e.effect}"): maxAttempts must be >= 1`);
|
|
@@ -5242,7 +5246,7 @@ var G = /* @__PURE__ */ new Map(), Gi = (e, t) => {
|
|
|
5242
5246
|
});
|
|
5243
5247
|
} else e.nudge?.();
|
|
5244
5248
|
}
|
|
5245
|
-
}), Ml = (e) => Math.min(1e3 * 2 ** Math.max(0, e - 1),
|
|
5249
|
+
}), Ml = (e) => Math.min(1e3 * 2 ** Math.max(0, e - 1), 3e5), Nl = 50, Pl = (e, t) => e.length <= t ? e : `${e.slice(0, t)}… [clipped]`, Fl = (e) => {
|
|
5246
5250
|
if (e == null) return null;
|
|
5247
5251
|
let t = typeof e == "object" && !Array.isArray(e) ? e : { value: e }, n;
|
|
5248
5252
|
try {
|
|
@@ -5391,42 +5395,42 @@ var G = /* @__PURE__ */ new Map(), Gi = (e, t) => {
|
|
|
5391
5395
|
}, Rl = B({ scope: "voltro:connections" }), Y = "_voltro_connections", zl = {
|
|
5392
5396
|
kind: "typeid",
|
|
5393
5397
|
prefix: "conn"
|
|
5394
|
-
}, Bl =
|
|
5395
|
-
id:
|
|
5396
|
-
connectionId:
|
|
5397
|
-
subjectId:
|
|
5398
|
-
tenantId:
|
|
5399
|
-
kind:
|
|
5400
|
-
status:
|
|
5398
|
+
}, Bl = I(Y, {
|
|
5399
|
+
id: N({ prefix: "conn" }),
|
|
5400
|
+
connectionId: L(),
|
|
5401
|
+
subjectId: L(),
|
|
5402
|
+
tenantId: L().nullable(),
|
|
5403
|
+
kind: L().oneOf(["oauth2", "pat"]),
|
|
5404
|
+
status: L().oneOf([
|
|
5401
5405
|
"connected",
|
|
5402
5406
|
"expired",
|
|
5403
5407
|
"revoked",
|
|
5404
5408
|
"error"
|
|
5405
5409
|
]),
|
|
5406
|
-
accessToken:
|
|
5407
|
-
refreshToken:
|
|
5408
|
-
expiresAt:
|
|
5409
|
-
scopes:
|
|
5410
|
-
accountId:
|
|
5411
|
-
accountLabel:
|
|
5412
|
-
lastError:
|
|
5413
|
-
refreshLockedUntil:
|
|
5414
|
-
metadata:
|
|
5415
|
-
connectedAt:
|
|
5416
|
-
updatedAt:
|
|
5410
|
+
accessToken: L(),
|
|
5411
|
+
refreshToken: L().nullable(),
|
|
5412
|
+
expiresAt: R().nullable(),
|
|
5413
|
+
scopes: L().nullable(),
|
|
5414
|
+
accountId: L().nullable(),
|
|
5415
|
+
accountLabel: L().nullable(),
|
|
5416
|
+
lastError: L().nullable(),
|
|
5417
|
+
refreshLockedUntil: R(),
|
|
5418
|
+
metadata: F().nullable(),
|
|
5419
|
+
connectedAt: R(),
|
|
5420
|
+
updatedAt: R()
|
|
5417
5421
|
}).unique("byConnectionSubject", ["connectionId", "subjectId"]).index(["subjectId"]), Vl = "_voltro_connection_grants", Hl = {
|
|
5418
5422
|
kind: "typeid",
|
|
5419
5423
|
prefix: "cgrant"
|
|
5420
|
-
}, Ul =
|
|
5421
|
-
id:
|
|
5422
|
-
state:
|
|
5423
|
-
connectionId:
|
|
5424
|
-
subjectId:
|
|
5425
|
-
tenantId:
|
|
5426
|
-
codeVerifier:
|
|
5427
|
-
redirectTo:
|
|
5428
|
-
createdAt:
|
|
5429
|
-
expiresAt:
|
|
5424
|
+
}, Ul = I(Vl, {
|
|
5425
|
+
id: N({ prefix: "cgrant" }),
|
|
5426
|
+
state: L().unique(),
|
|
5427
|
+
connectionId: L(),
|
|
5428
|
+
subjectId: L(),
|
|
5429
|
+
tenantId: L().nullable(),
|
|
5430
|
+
codeVerifier: L().nullable(),
|
|
5431
|
+
redirectTo: L(),
|
|
5432
|
+
createdAt: R(),
|
|
5433
|
+
expiresAt: R()
|
|
5430
5434
|
}).index(["expiresAt"]), Wl = /^[a-z][a-z0-9-]*$/, Gl = (e) => {
|
|
5431
5435
|
if (!Wl.test(e.id)) throw Error(`defineConnection: id "${e.id}" must be lowercase kebab-case (it becomes a URL path segment).`);
|
|
5432
5436
|
if (e.kind === "oauth2") {
|
|
@@ -5546,7 +5550,7 @@ var G = /* @__PURE__ */ new Map(), Gi = (e, t) => {
|
|
|
5546
5550
|
});
|
|
5547
5551
|
i = n.status, a = await n.text();
|
|
5548
5552
|
} catch (t) {
|
|
5549
|
-
throw new
|
|
5553
|
+
throw new z({
|
|
5550
5554
|
connectionId: e.id,
|
|
5551
5555
|
reason: `token endpoint unreachable: ${String(t)}`,
|
|
5552
5556
|
transient: !0
|
|
@@ -5558,12 +5562,12 @@ var G = /* @__PURE__ */ new Map(), Gi = (e, t) => {
|
|
|
5558
5562
|
} catch {
|
|
5559
5563
|
o = {};
|
|
5560
5564
|
}
|
|
5561
|
-
if (i < 200 || i >= 300) throw new
|
|
5565
|
+
if (i < 200 || i >= 300) throw new z({
|
|
5562
5566
|
connectionId: e.id,
|
|
5563
5567
|
reason: `token endpoint ${i}: ${o.error ?? ""} ${o.error_description ?? a.slice(0, 200)}`.trim(),
|
|
5564
5568
|
transient: i >= 500
|
|
5565
5569
|
});
|
|
5566
|
-
if (typeof o.access_token != "string" || o.access_token.length === 0) throw new
|
|
5570
|
+
if (typeof o.access_token != "string" || o.access_token.length === 0) throw new z({
|
|
5567
5571
|
connectionId: e.id,
|
|
5568
5572
|
reason: "token response carried no access_token",
|
|
5569
5573
|
transient: !1
|
|
@@ -5624,14 +5628,14 @@ var G = /* @__PURE__ */ new Map(), Gi = (e, t) => {
|
|
|
5624
5628
|
return fu.set(o, c), c;
|
|
5625
5629
|
}, vu = async (e) => {
|
|
5626
5630
|
let { store: t, subjectId: n, now: r } = e, i = e.definition, a = e.sleep ?? du, o = i.refreshSkewMs ?? 6e4, s = e.row.id;
|
|
5627
|
-
if (await t.updateMany("_voltro_connections", { refreshLockedUntil: new Date(r() + 3e4) }, { where: C(O("id", s),
|
|
5631
|
+
if (await t.updateMany("_voltro_connections", { refreshLockedUntil: new Date(r() + 3e4) }, { where: C(O("id", s), ge("refreshLockedUntil", new Date(r()))) }) === 0) {
|
|
5628
5632
|
for (let e = 0; e < 10; e++) {
|
|
5629
5633
|
await a(200);
|
|
5630
5634
|
let e = await $l(t, i.id, n);
|
|
5631
5635
|
if (e === void 0) throw new uu(i.id, n);
|
|
5632
5636
|
if (!gu(e, o, r())) return hu(i, e);
|
|
5633
5637
|
}
|
|
5634
|
-
throw new
|
|
5638
|
+
throw new z({
|
|
5635
5639
|
connectionId: i.id,
|
|
5636
5640
|
reason: "another replica held the refresh lease and did not publish a fresh token in time",
|
|
5637
5641
|
transient: !0
|
|
@@ -5643,7 +5647,7 @@ var G = /* @__PURE__ */ new Map(), Gi = (e, t) => {
|
|
|
5643
5647
|
lastError: "access token expired and no refresh token is on file — reconnect required",
|
|
5644
5648
|
refreshLockedUntil: /* @__PURE__ */ new Date(0),
|
|
5645
5649
|
updatedAt: new Date(r())
|
|
5646
|
-
}), new
|
|
5650
|
+
}), new z({
|
|
5647
5651
|
connectionId: i.id,
|
|
5648
5652
|
reason: "access token expired and no refresh token is on file — reconnect required",
|
|
5649
5653
|
transient: !1
|
|
@@ -5652,7 +5656,7 @@ var G = /* @__PURE__ */ new Map(), Gi = (e, t) => {
|
|
|
5652
5656
|
try {
|
|
5653
5657
|
l = await su(i, da(String(c)), r);
|
|
5654
5658
|
} catch (e) {
|
|
5655
|
-
let n = e instanceof
|
|
5659
|
+
let n = e instanceof z ? e : new z({
|
|
5656
5660
|
connectionId: i.id,
|
|
5657
5661
|
reason: String(e),
|
|
5658
5662
|
transient: !0
|
|
@@ -5697,7 +5701,7 @@ var G = /* @__PURE__ */ new Map(), Gi = (e, t) => {
|
|
|
5697
5701
|
}, xu = async (e) => {
|
|
5698
5702
|
let t = await globalThis.crypto.subtle.digest("SHA-256", new TextEncoder().encode(e));
|
|
5699
5703
|
return bu(new Uint8Array(t));
|
|
5700
|
-
}, Su =
|
|
5704
|
+
}, Su = 6e5, Cu = (e) => `/_voltro/connections/${e}/callback`, wu = (e) => e === void 0 || e.length === 0 || !e.startsWith("/") || e.startsWith("//") || e.startsWith("/\\") ? "/" : e, Tu = (e, t) => e.redirectUri ?? `${t.replace(/\/+$/, "")}${Cu(e.id)}`, Eu = async (e) => {
|
|
5701
5705
|
let t = (e.now ?? (() => /* @__PURE__ */ new Date()))(), { definition: n } = e, r = yu(), i = n.pkce === !1 ? null : yu(48), a = Tu(n, e.publicUrl);
|
|
5702
5706
|
await e.store.insert(Vl, {
|
|
5703
5707
|
id: A(Hl, Vl),
|
|
@@ -5733,20 +5737,20 @@ var G = /* @__PURE__ */ new Map(), Gi = (e, t) => {
|
|
|
5733
5737
|
skip: void 0,
|
|
5734
5738
|
projection: void 0
|
|
5735
5739
|
}))[0];
|
|
5736
|
-
if (n === void 0) throw new
|
|
5740
|
+
if (n === void 0) throw new z({
|
|
5737
5741
|
connectionId: "unknown",
|
|
5738
5742
|
reason: "unknown or already-used handshake state",
|
|
5739
5743
|
transient: !1
|
|
5740
5744
|
});
|
|
5741
5745
|
await e.store.delete(Vl, n.id);
|
|
5742
5746
|
let r = String(n.connectionId), i = Yl(n.expiresAt);
|
|
5743
|
-
if (i !== null && i.getTime() < t.getTime()) throw new
|
|
5747
|
+
if (i !== null && i.getTime() < t.getTime()) throw new z({
|
|
5744
5748
|
connectionId: r,
|
|
5745
5749
|
reason: "handshake expired — start again",
|
|
5746
5750
|
transient: !1
|
|
5747
5751
|
});
|
|
5748
5752
|
let a = e.registry.get(r);
|
|
5749
|
-
if (a === void 0 || a.kind !== "oauth2") throw new
|
|
5753
|
+
if (a === void 0 || a.kind !== "oauth2") throw new z({
|
|
5750
5754
|
connectionId: r,
|
|
5751
5755
|
reason: "no oauth2 connection is declared under that id",
|
|
5752
5756
|
transient: !1
|
|
@@ -5776,7 +5780,7 @@ var G = /* @__PURE__ */ new Map(), Gi = (e, t) => {
|
|
|
5776
5780
|
}, Ou = async (e, t = /* @__PURE__ */ new Date()) => {
|
|
5777
5781
|
let n = await e.query({
|
|
5778
5782
|
table: Vl,
|
|
5779
|
-
predicate:
|
|
5783
|
+
predicate: ge("expiresAt", t),
|
|
5780
5784
|
order: [],
|
|
5781
5785
|
take: void 0,
|
|
5782
5786
|
skip: void 0,
|
|
@@ -5835,11 +5839,11 @@ var G = /* @__PURE__ */ new Map(), Gi = (e, t) => {
|
|
|
5835
5839
|
};
|
|
5836
5840
|
}, Fu = (e, t) => {
|
|
5837
5841
|
let n = e.request?.subject?.id ?? null;
|
|
5838
|
-
if (n === null || n === "") throw new
|
|
5842
|
+
if (n === null || n === "") throw new lt({ connectionId: t });
|
|
5839
5843
|
return n;
|
|
5840
5844
|
}, Iu = (e, t) => {
|
|
5841
5845
|
let n = e.registry.get(t);
|
|
5842
|
-
if (n === void 0) throw new
|
|
5846
|
+
if (n === void 0) throw new ct({ connectionId: t });
|
|
5843
5847
|
return n;
|
|
5844
5848
|
}, Lu = (e) => async (t, n) => {
|
|
5845
5849
|
let r = n.request?.subject?.id ?? null;
|
|
@@ -5857,7 +5861,7 @@ var G = /* @__PURE__ */ new Map(), Gi = (e, t) => {
|
|
|
5857
5861
|
})) : ru(n.store, e.registry, r);
|
|
5858
5862
|
}, Ru = (e) => async (t, n) => {
|
|
5859
5863
|
let r = Iu(e, t.connectionId), i = Fu(n, t.connectionId);
|
|
5860
|
-
if (r.kind !== "oauth2") throw new
|
|
5864
|
+
if (r.kind !== "oauth2") throw new st({
|
|
5861
5865
|
connectionId: t.connectionId,
|
|
5862
5866
|
expected: "oauth2",
|
|
5863
5867
|
actual: r.kind
|
|
@@ -5872,13 +5876,13 @@ var G = /* @__PURE__ */ new Map(), Gi = (e, t) => {
|
|
|
5872
5876
|
});
|
|
5873
5877
|
}, zu = (e) => async (t, n) => {
|
|
5874
5878
|
let r = Iu(e, t.connectionId), i = Fu(n, t.connectionId);
|
|
5875
|
-
if (r.kind !== "pat") throw new
|
|
5879
|
+
if (r.kind !== "pat") throw new st({
|
|
5876
5880
|
connectionId: t.connectionId,
|
|
5877
5881
|
expected: "pat",
|
|
5878
5882
|
actual: r.kind
|
|
5879
5883
|
});
|
|
5880
5884
|
let a = t.token.trim();
|
|
5881
|
-
if (a.length === 0) throw new
|
|
5885
|
+
if (a.length === 0) throw new z({
|
|
5882
5886
|
connectionId: t.connectionId,
|
|
5883
5887
|
reason: "token is empty",
|
|
5884
5888
|
transient: !1
|
|
@@ -5887,7 +5891,7 @@ var G = /* @__PURE__ */ new Map(), Gi = (e, t) => {
|
|
|
5887
5891
|
if (r.validate !== void 0) try {
|
|
5888
5892
|
o = await r.validate(a);
|
|
5889
5893
|
} catch (e) {
|
|
5890
|
-
throw new
|
|
5894
|
+
throw new z({
|
|
5891
5895
|
connectionId: t.connectionId,
|
|
5892
5896
|
reason: `the provider rejected that token: ${e instanceof Error ? e.message : String(e)}`,
|
|
5893
5897
|
transient: !1
|
|
@@ -5963,7 +5967,7 @@ var G = /* @__PURE__ */ new Map(), Gi = (e, t) => {
|
|
|
5963
5967
|
td.enterWith(e);
|
|
5964
5968
|
}, rd = () => td.getStore(), id = (e, t) => td.run(e, t), ad = B({ scope: "voltro:policy" }), od, sd = (e) => {
|
|
5965
5969
|
od = e;
|
|
5966
|
-
}, cd = () => od, ld = () => {
|
|
5970
|
+
}, cd = () => od, ld = (e) => od === void 0 && (od = e, !0), ud = () => {
|
|
5967
5971
|
It((e) => o.gen(function* () {
|
|
5968
5972
|
let t = Gu(e.resourceType);
|
|
5969
5973
|
if (t === void 0) return ad.warn("policy guard denied — no resource policy registered for this type", {
|
|
@@ -5978,6 +5982,7 @@ var G = /* @__PURE__ */ new Map(), Gi = (e, t) => {
|
|
|
5978
5982
|
let r = yield* o.tryPromise({
|
|
5979
5983
|
try: async () => n({
|
|
5980
5984
|
subjectId: e.subject.id,
|
|
5985
|
+
subject: e.subject,
|
|
5981
5986
|
resourceType: e.resourceType,
|
|
5982
5987
|
resourceId: e.resourceId,
|
|
5983
5988
|
load: rd()
|
|
@@ -6000,10 +6005,10 @@ var G = /* @__PURE__ */ new Map(), Gi = (e, t) => {
|
|
|
6000
6005
|
tuples: r
|
|
6001
6006
|
});
|
|
6002
6007
|
}));
|
|
6003
|
-
}, ud = (e) => {
|
|
6004
|
-
Promise.resolve().then(e);
|
|
6005
6008
|
}, dd = (e) => {
|
|
6006
|
-
|
|
6009
|
+
Promise.resolve().then(e);
|
|
6010
|
+
}, fd = (e) => {
|
|
6011
|
+
let t = e.schedule ?? dd, n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), i = (e, t) => `${e}\u0000${t}`, a = async (t) => {
|
|
6007
6012
|
let a = r.get(t);
|
|
6008
6013
|
if (a === void 0) return;
|
|
6009
6014
|
r.delete(t);
|
|
@@ -6012,7 +6017,7 @@ var G = /* @__PURE__ */ new Map(), Gi = (e, t) => {
|
|
|
6012
6017
|
if (o.length > 0) {
|
|
6013
6018
|
let r = await e.store.query({
|
|
6014
6019
|
table: t,
|
|
6015
|
-
predicate:
|
|
6020
|
+
predicate: le("id", o),
|
|
6016
6021
|
order: [],
|
|
6017
6022
|
take: void 0,
|
|
6018
6023
|
skip: void 0,
|
|
@@ -6049,23 +6054,23 @@ var G = /* @__PURE__ */ new Map(), Gi = (e, t) => {
|
|
|
6049
6054
|
load: async (e, t) => (await o(e, [t]))[0] ?? null,
|
|
6050
6055
|
loadMany: (e, t) => o(e, t)
|
|
6051
6056
|
};
|
|
6052
|
-
},
|
|
6057
|
+
}, pd = u.effect(Kt.HttpClient, o.map(Kt.HttpClient, (e) => e.pipe(Kt.mapRequestEffect((e) => o.currentSpan.pipe(o.map((t) => e.headers.traceparent === void 0 ? Jt.setHeader(e, "traceparent", Xi({
|
|
6053
6058
|
traceId: t.traceId,
|
|
6054
6059
|
spanId: t.spanId,
|
|
6055
6060
|
sampled: t.sampled
|
|
6056
|
-
})) : e), o.catchAll(() => o.succeed(e))))))),
|
|
6061
|
+
})) : e), o.catchAll(() => o.succeed(e))))))), md = class extends Error {
|
|
6057
6062
|
url;
|
|
6058
6063
|
reason;
|
|
6059
6064
|
_tag = "SsrfBlockedError";
|
|
6060
6065
|
constructor(e, t) {
|
|
6061
6066
|
super(`SSRF: blocked outbound request to ${e} — ${t}. If this target is intentional, add its host to \`http.allowHosts\` in app.config.ts.`), this.url = e, this.reason = t, this.name = "SsrfBlockedError";
|
|
6062
6067
|
}
|
|
6063
|
-
},
|
|
6068
|
+
}, hd = (e, t) => e === 0 || e === 10 || e === 127 || e === 100 && t >= 64 && t <= 127 || e === 169 && t === 254 || e === 172 && t >= 16 && t <= 31 || e === 192 && t === 168 || e === 198 && (t === 18 || t === 19) || e >= 224, gd = (e) => e === "::" || e === "::1" || e.startsWith("fc") || e.startsWith("fd") || e.startsWith("fe80") || e.startsWith("::ffff:"), _d = (e, t, n) => n.some((n) => {
|
|
6064
6069
|
let r = n.trim().toLowerCase();
|
|
6065
6070
|
if (r === "") return !1;
|
|
6066
6071
|
let i = t === "" ? e : `${e}:${t}`;
|
|
6067
6072
|
return r === e || r === i ? !0 : r.startsWith("*.") ? e.endsWith(r.slice(1)) : !1;
|
|
6068
|
-
}),
|
|
6073
|
+
}), vd = (e, t = {}) => {
|
|
6069
6074
|
let n;
|
|
6070
6075
|
try {
|
|
6071
6076
|
n = new URL(e);
|
|
@@ -6074,30 +6079,30 @@ var G = /* @__PURE__ */ new Map(), Gi = (e, t) => {
|
|
|
6074
6079
|
}
|
|
6075
6080
|
if (n.protocol !== "http:" && n.protocol !== "https:") return `blocked scheme "${n.protocol}"`;
|
|
6076
6081
|
let r = n.hostname.replace(/^\[|\]$/g, "").toLowerCase();
|
|
6077
|
-
if (
|
|
6082
|
+
if (_d(r, n.port, t.allowHosts ?? [])) return null;
|
|
6078
6083
|
if (r === "localhost" || r.endsWith(".localhost") || r.endsWith(".internal") || r.endsWith(".local")) return `blocked host "${r}"`;
|
|
6079
6084
|
let i = /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/.exec(r);
|
|
6080
6085
|
if (i) {
|
|
6081
6086
|
let e = Number(i[1]), t = Number(i[2]);
|
|
6082
|
-
return e > 255 || t > 255 || Number(i[3]) > 255 || Number(i[4]) > 255 ? "malformed ipv4 literal" :
|
|
6087
|
+
return e > 255 || t > 255 || Number(i[3]) > 255 || Number(i[4]) > 255 ? "malformed ipv4 literal" : hd(e, t) ? `blocked private/reserved address ${r}` : null;
|
|
6083
6088
|
}
|
|
6084
6089
|
if (r.includes(":")) {
|
|
6085
6090
|
let e = /^::ffff:(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$/.exec(r);
|
|
6086
|
-
return e ?
|
|
6091
|
+
return e ? vd(`${n.protocol}//${e[1]}`, t) : gd(r) ? `blocked private/reserved address ${r}` : null;
|
|
6087
6092
|
}
|
|
6088
6093
|
return null;
|
|
6089
|
-
},
|
|
6094
|
+
}, yd = (e = {}) => u.effect(Kt.HttpClient, o.map(Kt.HttpClient, (t) => {
|
|
6090
6095
|
let n = Kt.transform(t, (t, n) => o.suspend(() => {
|
|
6091
|
-
let r =
|
|
6096
|
+
let r = vd(n.url, e);
|
|
6092
6097
|
return r === null ? t : o.fail(new qt.RequestError({
|
|
6093
6098
|
request: n,
|
|
6094
6099
|
reason: "Transport",
|
|
6095
|
-
cause: new
|
|
6100
|
+
cause: new md(n.url, r),
|
|
6096
6101
|
description: `SSRF policy: ${r}`
|
|
6097
6102
|
}));
|
|
6098
6103
|
}));
|
|
6099
6104
|
return Kt.followRedirects(n, e.maxRedirects ?? 5);
|
|
6100
|
-
})),
|
|
6105
|
+
})), bd = (e) => {
|
|
6101
6106
|
let t = e.now ?? Date.now, n = e.intervalMs ?? 3e4, r = e.maxPending ?? 500, i = /* @__PURE__ */ new Map(), a = !1, o = async () => {
|
|
6102
6107
|
if (i.size === 0) return;
|
|
6103
6108
|
let t = i;
|
|
@@ -6126,7 +6131,7 @@ var G = /* @__PURE__ */ new Map(), Gi = (e, t) => {
|
|
|
6126
6131
|
},
|
|
6127
6132
|
pending: () => i.size
|
|
6128
6133
|
};
|
|
6129
|
-
},
|
|
6134
|
+
}, xd = "voltro/audit", Sd = "voltro/softDelete", Cd = "voltro/expires", wd = "voltro/tenant", Td = "voltro/localFirst", Ed = (e) => {
|
|
6130
6135
|
let t = /* @__PURE__ */ new Map();
|
|
6131
6136
|
for (let n of e) {
|
|
6132
6137
|
let e = /* @__PURE__ */ new Set();
|
|
@@ -6174,26 +6179,26 @@ var G = /* @__PURE__ */ new Map(), Gi = (e, t) => {
|
|
|
6174
6179
|
return !1;
|
|
6175
6180
|
},
|
|
6176
6181
|
idScheme: (e) => t.get(e)?.idScheme,
|
|
6177
|
-
defaultFactories: (e) => t.get(e)?.defaultFactories ??
|
|
6178
|
-
computedFields: (e) => t.get(e)?.computedFields ??
|
|
6182
|
+
defaultFactories: (e) => t.get(e)?.defaultFactories ?? Dd,
|
|
6183
|
+
computedFields: (e) => t.get(e)?.computedFields ?? Od,
|
|
6179
6184
|
versionColumn: (e) => t.get(e)?.versionColumn,
|
|
6180
|
-
generatedColumns: (e) => t.get(e)?.generatedColumns ??
|
|
6181
|
-
crdtColumns: (e) => t.get(e)?.crdtColumns ??
|
|
6185
|
+
generatedColumns: (e) => t.get(e)?.generatedColumns ?? kd,
|
|
6186
|
+
crdtColumns: (e) => t.get(e)?.crdtColumns ?? Ad,
|
|
6182
6187
|
insertSchema: (e) => t.get(e)?.insertSchema,
|
|
6183
6188
|
validatePatchSchema: (e) => t.get(e)?.validatePatchSchema
|
|
6184
6189
|
};
|
|
6185
|
-
},
|
|
6190
|
+
}, Dd = /* @__PURE__ */ new Map(), Od = /* @__PURE__ */ new Map(), kd = /* @__PURE__ */ new Set(), Ad = /* @__PURE__ */ new Set(), jd = Ed([]), Md = B({ scope: "store.fieldEncryption" }), Nd = (e, t) => {
|
|
6186
6191
|
let n = t, r = process.env.VOLTRO_FIELD_DECRYPT_ON_ERROR === "null" ? "null" : "throw", i = /* @__PURE__ */ new Set(), a = (e) => {
|
|
6187
6192
|
let t = `${e.table}.${e.column}`;
|
|
6188
|
-
i.has(t) || (i.add(t),
|
|
6193
|
+
i.has(t) || (i.add(t), Md.warn("encrypted column degraded to null — could not decrypt with the active key", {
|
|
6189
6194
|
table: e.table,
|
|
6190
6195
|
column: e.column,
|
|
6191
6196
|
reason: e.reason,
|
|
6192
6197
|
hint: "VOLTRO_FIELD_DECRYPT_ON_ERROR=null is set — this row was likely encrypted under a different key"
|
|
6193
6198
|
}));
|
|
6194
6199
|
}, o = (e, t) => {
|
|
6195
|
-
let r = j(e);
|
|
6196
|
-
return ie(
|
|
6200
|
+
let r = j(e), i = n ? je(t, r, n) : t;
|
|
6201
|
+
return ie(i, r, K());
|
|
6197
6202
|
}, s = (e, t) => {
|
|
6198
6203
|
let i = j(e), o = ne(t, i, K(), {
|
|
6199
6204
|
onError: r,
|
|
@@ -6209,7 +6214,7 @@ var G = /* @__PURE__ */ new Map(), Gi = (e, t) => {
|
|
|
6209
6214
|
e.injectExternalChange(t);
|
|
6210
6215
|
},
|
|
6211
6216
|
...e.changeScope === void 0 ? {} : { changeScope: e.changeScope },
|
|
6212
|
-
...e.withNamespace === void 0 ? {} : { withNamespace: (n) =>
|
|
6217
|
+
...e.withNamespace === void 0 ? {} : { withNamespace: (n) => Nd(e.withNamespace(n), t) },
|
|
6213
6218
|
...e.raw === void 0 ? {} : { raw: ((...t) => e.raw(...t)) },
|
|
6214
6219
|
...e.close === void 0 ? {} : { close: (t) => e.close(t) },
|
|
6215
6220
|
...e.ping === void 0 ? {} : { ping: () => e.ping() },
|
|
@@ -6221,32 +6226,32 @@ var G = /* @__PURE__ */ new Map(), Gi = (e, t) => {
|
|
|
6221
6226
|
upsert: async (t, n, r) => c(t, await e.upsert(t, o(t, n), r)),
|
|
6222
6227
|
insertIgnore: async (t, n, r) => c(t, await e.insertIgnore(t, o(t, n), r)),
|
|
6223
6228
|
patchJson: async (t, n, r, i) => c(t, await e.patchJson(t, n, r, i)),
|
|
6224
|
-
transactional: (n) => e.transactional((e) => n(
|
|
6229
|
+
transactional: (n) => e.transactional((e) => n(Nd(e, t)))
|
|
6225
6230
|
};
|
|
6226
|
-
},
|
|
6231
|
+
}, Pd = (e, t) => {
|
|
6227
6232
|
if (t === void 0 || t.length === 0) return e;
|
|
6228
6233
|
let n = { ...e };
|
|
6229
6234
|
for (let e of t) delete n[e];
|
|
6230
6235
|
return n;
|
|
6231
|
-
}, Pd = (e, t) => {
|
|
6232
|
-
let n = j(e), r = n === void 0 ? [] : Ne(n);
|
|
6233
|
-
return r.length === 0 ? t ?? [] : t === void 0 ? r : [...t, ...r];
|
|
6234
6236
|
}, Fd = (e, t) => {
|
|
6237
|
+
let n = j(e), r = n === void 0 ? [] : Me(n);
|
|
6238
|
+
return r.length === 0 ? t ?? [] : t === void 0 ? r : [...t, ...r];
|
|
6239
|
+
}, Id = (e, t) => {
|
|
6235
6240
|
let n = j(e);
|
|
6236
6241
|
if (n === void 0) return;
|
|
6237
|
-
let r =
|
|
6242
|
+
let r = Me(n).filter((e) => t[e] !== void 0);
|
|
6238
6243
|
if (r.length !== 0) throw new La({
|
|
6239
6244
|
table: e,
|
|
6240
6245
|
columns: r
|
|
6241
6246
|
});
|
|
6242
|
-
},
|
|
6247
|
+
}, Ld = (e, t) => t.length === 0 ? e : e.map((e) => Pd(e, t)), Rd = (e, t, n, r, i) => {
|
|
6243
6248
|
let a = {
|
|
6244
6249
|
...t?.(r) ?? {},
|
|
6245
6250
|
...n?.(i) ?? {}
|
|
6246
6251
|
}, o = e;
|
|
6247
6252
|
for (let [e, t] of Object.entries(a)) t !== void 0 && (o = o.where(e, t));
|
|
6248
6253
|
return o;
|
|
6249
|
-
},
|
|
6254
|
+
}, zd = 1e3, Bd = (e, t = zd) => {
|
|
6250
6255
|
let n = (e) => typeof e == "number" && Number.isFinite(e) ? e : void 0, r = (e) => Math.max(1, Math.min(Math.floor(e), t)), i = n(e.page);
|
|
6251
6256
|
if (i !== void 0) {
|
|
6252
6257
|
let t = r(n(e.pageSize) ?? 100);
|
|
@@ -6259,37 +6264,37 @@ var G = /* @__PURE__ */ new Map(), Gi = (e, t) => {
|
|
|
6259
6264
|
limit: r(n(e.limit) ?? 100),
|
|
6260
6265
|
offset: Math.max(0, Math.floor(n(e.offset) ?? 0))
|
|
6261
6266
|
};
|
|
6262
|
-
},
|
|
6267
|
+
}, Vd = {
|
|
6263
6268
|
list: (e, t = {}) => async (n, r) => {
|
|
6264
6269
|
let i = n ?? {}, a = r.store.select(e);
|
|
6265
6270
|
if (t.columns !== void 0 && t.columns.length > 0) {
|
|
6266
|
-
let n = new Set(
|
|
6271
|
+
let n = new Set(Fd(e, void 0)), r = t.columns.filter((e) => !n.has(e));
|
|
6267
6272
|
r.length > 0 && (a = a.select(...r));
|
|
6268
6273
|
}
|
|
6269
|
-
t.include !== void 0 && (a = a.with(t.include)), a =
|
|
6274
|
+
t.include !== void 0 && (a = a.with(t.include)), a = Rd(a, t.filter, t.scope, i, r);
|
|
6270
6275
|
for (let e of t.sort ?? []) a = a.orderBy(e.column, e.direction ?? "asc");
|
|
6271
6276
|
if (t.paginate === !0) {
|
|
6272
|
-
let { limit: e, offset: n } =
|
|
6277
|
+
let { limit: e, offset: n } = Bd(i, t.maxPageSize);
|
|
6273
6278
|
a = a.limit(e).offset(n);
|
|
6274
6279
|
}
|
|
6275
|
-
return
|
|
6280
|
+
return Ld(await a.all(), Fd(e, t.redact));
|
|
6276
6281
|
},
|
|
6277
6282
|
getById: (e, t = {}) => async (n, r) => {
|
|
6278
6283
|
let i = r.store.select(e).where("id", n.id);
|
|
6279
6284
|
t.include !== void 0 && (i = i.with(t.include));
|
|
6280
6285
|
let a = await i.first();
|
|
6281
|
-
return a === null ? null :
|
|
6286
|
+
return a === null ? null : Pd(a, Fd(e, t.redact));
|
|
6282
6287
|
},
|
|
6283
|
-
create: (e, t = {}) => async (n, r) => (
|
|
6288
|
+
create: (e, t = {}) => async (n, r) => (Id(e, n), Pd(await r.store.insert(e, n), Fd(e, t.redact))),
|
|
6284
6289
|
update: (e, t = {}) => async (n, r) => {
|
|
6285
6290
|
let { id: i, ...a } = n;
|
|
6286
|
-
|
|
6291
|
+
Id(e, a);
|
|
6287
6292
|
let o = await r.store.update(e, i, a);
|
|
6288
|
-
return o === null ? null :
|
|
6293
|
+
return o === null ? null : Pd(o, Fd(e, t.redact));
|
|
6289
6294
|
},
|
|
6290
|
-
count: (e, t = {}) => async (n, r) =>
|
|
6295
|
+
count: (e, t = {}) => async (n, r) => Rd(r.store.select(e), t.filter, t.scope, n ?? {}, r).count(),
|
|
6291
6296
|
remove: (e) => async (t, n) => ({ deleted: await n.store.delete(e, t.id) })
|
|
6292
|
-
},
|
|
6297
|
+
}, Hd = (e) => {
|
|
6293
6298
|
let t = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set(), r = (e) => {
|
|
6294
6299
|
if (!n.has(e)) switch (n.add(e), e._tag) {
|
|
6295
6300
|
case "TypeLiteral":
|
|
@@ -6309,14 +6314,11 @@ var G = /* @__PURE__ */ new Map(), Gi = (e, t) => {
|
|
|
6309
6314
|
case "Transformation":
|
|
6310
6315
|
r(e.from), r(e.to);
|
|
6311
6316
|
break;
|
|
6312
|
-
case "Suspend":
|
|
6313
|
-
r(e.f());
|
|
6314
|
-
break;
|
|
6315
|
-
default: break;
|
|
6317
|
+
case "Suspend": r(e.f());
|
|
6316
6318
|
}
|
|
6317
6319
|
};
|
|
6318
6320
|
return r(e.ast), t;
|
|
6319
|
-
},
|
|
6321
|
+
}, Ud = (e) => {
|
|
6320
6322
|
let t = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set(), r = (e) => {
|
|
6321
6323
|
switch (e._tag) {
|
|
6322
6324
|
case "Literal": return e.literal === null;
|
|
@@ -6344,31 +6346,28 @@ var G = /* @__PURE__ */ new Map(), Gi = (e, t) => {
|
|
|
6344
6346
|
case "Transformation":
|
|
6345
6347
|
i(e.from), i(e.to);
|
|
6346
6348
|
break;
|
|
6347
|
-
case "Suspend":
|
|
6348
|
-
i(e.f());
|
|
6349
|
-
break;
|
|
6350
|
-
default: break;
|
|
6349
|
+
case "Suspend": i(e.f());
|
|
6351
6350
|
}
|
|
6352
6351
|
};
|
|
6353
6352
|
return i(e.ast), t;
|
|
6354
|
-
},
|
|
6353
|
+
}, Wd = (e, t) => {
|
|
6355
6354
|
let n = e.source === void 0 ? [] : Array.isArray(e.source) ? e.source : [e.source];
|
|
6356
6355
|
if (n.length === 0) return [];
|
|
6357
|
-
let r =
|
|
6356
|
+
let r = Hd(e.output), i = Ud(e.output), a = [];
|
|
6358
6357
|
for (let o of n) for (let n of t.get(o) ?? []) r.has(n) && !i.has(n) && a.push({
|
|
6359
6358
|
query: e.name,
|
|
6360
6359
|
table: o,
|
|
6361
6360
|
column: n
|
|
6362
6361
|
});
|
|
6363
6362
|
return a;
|
|
6364
|
-
},
|
|
6363
|
+
}, Gd = (e) => {
|
|
6365
6364
|
if (e.length !== 0) return `A wire-reachable query exposes a server-only column:\n${e.map((e) => ` • query '${e.query}' output declares '${e.column}' — a .serverOnly() column of '${e.table}'`).join("\n")}\nThree ways out, in order of preference:\n 1. Omit the column from the query's output schema. The crud.* read helpers strip these automatically.\n 2. Keep the KEY but type it \`Schema.Null\` — for a view that must stay wire-compatible (an importer that breaks if the key vanishes) while never sending a value. The audit accepts that, because the schema then PROVES no value can flow instead of promising it. Pair it with a \`hasX\` boolean.\n 3. Drop the .serverOnly() marker, if the column may in fact reach a client.\nNote the audit reads the DECLARED shape, not what your handler emits: a field typed \`string\` that you always set to null still fails, and should — the next edit to that handler is one line away from sending it.`;
|
|
6366
|
-
},
|
|
6365
|
+
}, Kd = (e, t) => e.cache?.scope === "global" ? (e.source === void 0 ? [] : Array.isArray(e.source) ? e.source : [e.source]).filter((e) => t.has(e)).map((t) => ({
|
|
6367
6366
|
query: e.name,
|
|
6368
6367
|
table: t
|
|
6369
|
-
})) : [],
|
|
6368
|
+
})) : [], qd = (e) => {
|
|
6370
6369
|
if (e.length !== 0) return `A cached query shares one entry across tenants:\n${e.map((e) => ` • query '${e.query}' caches scope:'global' while reading '${e.table}', a tenant()-scoped table`).join("\n")}\n\nscope:'global' stores ONE entry for every caller. On a tenant-scoped table the\nrows depend on who asked, so the first caller's rows are served to the next one.\n\nUse scope:'tenant' — one entry per org, none shared across orgs. Use 'subject'\nif the result also depends on WHICH person is asking, and 'global' only for data\nthat depends on neither.`;
|
|
6371
|
-
},
|
|
6370
|
+
}, Jd = (e, t) => {
|
|
6372
6371
|
let n, r = 0;
|
|
6373
6372
|
for (let i of t) {
|
|
6374
6373
|
let t = 0;
|
|
@@ -6379,7 +6378,7 @@ var G = /* @__PURE__ */ new Map(), Gi = (e, t) => {
|
|
|
6379
6378
|
o > r && o >= .6 && (r = o, n = i);
|
|
6380
6379
|
}
|
|
6381
6380
|
return n;
|
|
6382
|
-
},
|
|
6381
|
+
}, Yd = (e, t) => {
|
|
6383
6382
|
let n = St(), r = [];
|
|
6384
6383
|
for (let i of e) for (let e of Lt(i.source)) {
|
|
6385
6384
|
if (Mt(e)) {
|
|
@@ -6395,12 +6394,12 @@ var G = /* @__PURE__ */ new Map(), Gi = (e, t) => {
|
|
|
6395
6394
|
t.size === 0 || t.has(e) || r.push({
|
|
6396
6395
|
procedure: i.name,
|
|
6397
6396
|
source: e,
|
|
6398
|
-
didYouMean:
|
|
6397
|
+
didYouMean: Jd(e, t),
|
|
6399
6398
|
channel: !1
|
|
6400
6399
|
});
|
|
6401
6400
|
}
|
|
6402
6401
|
return r;
|
|
6403
|
-
},
|
|
6402
|
+
}, Xd = (e) => {
|
|
6404
6403
|
if (e.length === 0) return;
|
|
6405
6404
|
let t = e.map((e) => e.channel ? ` ${e.procedure}: source '${e.source}' names a reactivity channel nobody declared` : ` ${e.procedure}: source '${e.source}' matches no declared table` + (e.didYouMean === void 0 ? "" : ` — did you mean '${e.didYouMean}'?`)), n = e.some((e) => e.channel) ? "\nFor the `channel:` entries: declare it with `reactivityChannel(<name>)` and pass the\nCHANNEL as `source:`, not its key as a string. Authoring against the object is what\nmakes a channel source impossible to leave stale — you cannot import a declaration\nthat does not exist." : "";
|
|
6406
6405
|
return `${e.length} reactive source(s) name a table that does not exist:\n${t.join("\n")}\n
|
|
@@ -6409,16 +6408,16 @@ update again, which is indistinguishable from "nothing has changed" — so the
|
|
|
6409
6408
|
symptom is silence, and silence is what this surface exists to eliminate.
|
|
6410
6409
|
A \`source:\` is a STRING, so \`tsc\` cannot see a stale one and a rename leaves it
|
|
6411
6410
|
behind quietly.` + n;
|
|
6412
|
-
},
|
|
6413
|
-
let t =
|
|
6411
|
+
}, Zd = (e) => e.old ?? e.new ?? {}, Qd = (e) => String(Zd(e).id ?? ""), $d = (e) => {
|
|
6412
|
+
let t = Zd(e).tenantId;
|
|
6414
6413
|
return typeof t == "string" ? t : null;
|
|
6415
|
-
},
|
|
6416
|
-
let n =
|
|
6414
|
+
}, ef = (e) => e.op === "update" && (e.old?.deletedAt ?? null) === null && (e.new?.deletedAt ?? null) !== null, tf = (e, t) => {
|
|
6415
|
+
let n = ef(t);
|
|
6417
6416
|
return t.op !== "delete" && !n ? [] : e.filter((e) => e.targetTable === t.table && e.policy !== "keep" && (!n || e.onSoftDelete));
|
|
6418
|
-
},
|
|
6419
|
-
let r =
|
|
6417
|
+
}, nf = async (e, t, n) => {
|
|
6418
|
+
let r = tf(t, n);
|
|
6420
6419
|
if (r.length === 0) return [];
|
|
6421
|
-
let i =
|
|
6420
|
+
let i = Qd(n), a = $d(n), o = [];
|
|
6422
6421
|
for (let t of r) {
|
|
6423
6422
|
let n = await e.query({
|
|
6424
6423
|
table: t.table,
|
|
@@ -6442,7 +6441,7 @@ behind quietly.` + n;
|
|
|
6442
6441
|
});
|
|
6443
6442
|
}
|
|
6444
6443
|
return o;
|
|
6445
|
-
},
|
|
6444
|
+
}, rf = (e, t) => {
|
|
6446
6445
|
let n = [];
|
|
6447
6446
|
for (let r of e) for (let e of r.appliedPluginRefs ?? []) {
|
|
6448
6447
|
let i = e.column, a;
|
|
@@ -6461,26 +6460,26 @@ behind quietly.` + n;
|
|
|
6461
6460
|
});
|
|
6462
6461
|
}
|
|
6463
6462
|
return n.filter((e) => e.policy !== "keep");
|
|
6464
|
-
},
|
|
6463
|
+
}, af = class extends y.TaggedError()("CircuitOpen", {
|
|
6465
6464
|
name: y.String,
|
|
6466
6465
|
retryAfterMs: y.Number
|
|
6467
|
-
}) {},
|
|
6466
|
+
}) {}, of = {
|
|
6468
6467
|
tag: "closed",
|
|
6469
6468
|
failureCount: 0,
|
|
6470
6469
|
halfOpenSuccesses: 0,
|
|
6471
6470
|
openedAt: 0
|
|
6472
|
-
},
|
|
6473
|
-
let r = n.name ?? "circuit", i = a.toMillis(a.decode(n.resetTimeout)), s = n.halfOpenSuccessThreshold ?? 1, c = n.isFailure ?? (() => !0), l = yield* _.make(
|
|
6471
|
+
}, sf = { make: (n) => o.gen(function* () {
|
|
6472
|
+
let r = n.name ?? "circuit", i = a.toMillis(a.decode(n.resetTimeout)), s = n.halfOpenSuccessThreshold ?? 1, c = n.isFailure ?? (() => !0), l = yield* _.make(of), u = o.gen(function* () {
|
|
6474
6473
|
let e = yield* _.get(l);
|
|
6475
6474
|
if (e.tag === "half-open") {
|
|
6476
6475
|
let t = e.halfOpenSuccesses + 1;
|
|
6477
|
-
yield* _.set(l, t >= s ?
|
|
6476
|
+
yield* _.set(l, t >= s ? of : {
|
|
6478
6477
|
...e,
|
|
6479
6478
|
halfOpenSuccesses: t
|
|
6480
6479
|
});
|
|
6481
6480
|
return;
|
|
6482
6481
|
}
|
|
6483
|
-
e.failureCount !== 0 && (yield* _.set(l,
|
|
6482
|
+
e.failureCount !== 0 && (yield* _.set(l, of));
|
|
6484
6483
|
}), d = o.gen(function* () {
|
|
6485
6484
|
let e = yield* t.currentTimeMillis, r = yield* _.get(l);
|
|
6486
6485
|
if (r.tag === "half-open" || r.tag === "open") {
|
|
@@ -6518,7 +6517,7 @@ behind quietly.` + n;
|
|
|
6518
6517
|
if (e.isInterruptedOnly(t)) return o.void;
|
|
6519
6518
|
let n = e.failureOption(t), r = n._tag === "Some" ? n.value : void 0;
|
|
6520
6519
|
return c(r) ? d : o.void;
|
|
6521
|
-
})) : yield* o.fail(new
|
|
6520
|
+
})) : yield* o.fail(new af({
|
|
6522
6521
|
name: r,
|
|
6523
6522
|
retryAfterMs: n
|
|
6524
6523
|
}));
|
|
@@ -6527,15 +6526,15 @@ behind quietly.` + n;
|
|
|
6527
6526
|
value: _.get(l).pipe(o.map((e) => e.tag)),
|
|
6528
6527
|
enumerable: !0
|
|
6529
6528
|
}), Object.defineProperty(m, "reset", {
|
|
6530
|
-
value: _.set(l,
|
|
6529
|
+
value: _.set(l, of),
|
|
6531
6530
|
enumerable: !0
|
|
6532
6531
|
}), m;
|
|
6533
|
-
}) },
|
|
6534
|
-
|
|
6535
|
-
},
|
|
6536
|
-
|
|
6537
|
-
},
|
|
6538
|
-
let n = t.scopes === void 0 ? zt(t.id ?? "system") : zt(t.id ?? "system", t.scopes), r = t.store ??
|
|
6532
|
+
}) }, cf, lf = (e) => {
|
|
6533
|
+
cf = e;
|
|
6534
|
+
}, uf = () => {
|
|
6535
|
+
cf = void 0;
|
|
6536
|
+
}, df = () => cf, ff = async (e, t = {}) => {
|
|
6537
|
+
let n = t.scopes === void 0 ? zt(t.id ?? "system") : zt(t.id ?? "system", t.scopes), r = t.store ?? cf?.dataStore, i = t.schemaRegistry ?? cf?.schemaRegistry, a = t.dialect ?? cf?.dialect;
|
|
6539
6538
|
if (r === void 0 || i === void 0) throw Error("runAsSystem: no data store available — register one at boot via setSystemStoreHandle({ dataStore, schemaRegistry }) or pass { store, schemaRegistry } in the options.");
|
|
6540
6539
|
return e({
|
|
6541
6540
|
subject: n,
|
|
@@ -6546,20 +6545,20 @@ behind quietly.` + n;
|
|
|
6546
6545
|
rowFilter: gi
|
|
6547
6546
|
})
|
|
6548
6547
|
});
|
|
6549
|
-
},
|
|
6548
|
+
}, pf = (e) => u.mergeAll(u.succeed(rt, rt.of(({ headers: t, clientId: n }) => o.promise(async () => {
|
|
6550
6549
|
let r = await e.resolveSubject({
|
|
6551
6550
|
headers: Ui(n, t),
|
|
6552
6551
|
clientId: n
|
|
6553
6552
|
});
|
|
6554
6553
|
return Li(n, r.credentialExpiresAt), r.subject;
|
|
6555
|
-
}))), u.succeed(
|
|
6554
|
+
}))), u.succeed(ot, ot.of(({ headers: e, clientId: t }) => o.sync(() => {
|
|
6556
6555
|
let n = Ri(t) ?? wn(Ui(t, e)), r = e["idempotency-key"];
|
|
6557
6556
|
return {
|
|
6558
6557
|
clientId: t,
|
|
6559
6558
|
...r ? { idempotencyKey: r } : {},
|
|
6560
6559
|
...n === void 0 ? {} : { credentialExpiresAt: n }
|
|
6561
6560
|
};
|
|
6562
|
-
})))),
|
|
6561
|
+
})))), mf = (e) => {
|
|
6563
6562
|
let { currentRegion: t, replicaRegions: n, inner: r } = e, i = (e) => {
|
|
6564
6563
|
if (t === void 0) return {
|
|
6565
6564
|
sameRegion: [],
|
|
@@ -6587,7 +6586,7 @@ behind quietly.` + n;
|
|
|
6587
6586
|
return r.loadSnapshot();
|
|
6588
6587
|
}
|
|
6589
6588
|
};
|
|
6590
|
-
},
|
|
6589
|
+
}, hf = (e = process.env) => {
|
|
6591
6590
|
for (let t of [
|
|
6592
6591
|
"VOLTRO_REGION",
|
|
6593
6592
|
"AWS_REGION",
|
|
@@ -6599,7 +6598,7 @@ behind quietly.` + n;
|
|
|
6599
6598
|
let n = e[t];
|
|
6600
6599
|
if (typeof n == "string" && n.length > 0) return n;
|
|
6601
6600
|
}
|
|
6602
|
-
},
|
|
6601
|
+
}, gf = () => {
|
|
6603
6602
|
let e = {
|
|
6604
6603
|
primary: 0,
|
|
6605
6604
|
lagByReplica: /* @__PURE__ */ new Map()
|
|
@@ -6624,7 +6623,7 @@ behind quietly.` + n;
|
|
|
6624
6623
|
e.lagByReplica.set(t, n);
|
|
6625
6624
|
}
|
|
6626
6625
|
};
|
|
6627
|
-
},
|
|
6626
|
+
}, _f = Symbol.for("@voltro/ScheduleDefinition"), vf = (e) => typeof e == "object" && !!e && _f in e, yf = 18e5, bf = (e) => {
|
|
6628
6627
|
let t = r.parse(e.cron, e.timezone);
|
|
6629
6628
|
if (s.isLeft(t)) throw Error(`defineSchedule("${e.name}"): invalid cron expression "${e.cron}" (tz="${e.timezone}") — ${String(t.left)}`);
|
|
6630
6629
|
if (!e.timezone || e.timezone.trim() === "") throw Error(`defineSchedule("${e.name}"): timezone is required (e.g. "UTC", "Europe/Berlin").\nThe field is non-optional in \`ScheduleDefinition\`, so an ABSENT one is a tsc error and never reaches here. Arriving at this message means the value was present and EMPTY — almost always \`process.env.TZ ?? ''\` or a config lookup that missed. A reporter lost a crashloop to it, so the distinction is worth stating: this is not a check the type could have made for you.`);
|
|
@@ -6633,22 +6632,22 @@ behind quietly.` + n;
|
|
|
6633
6632
|
...e,
|
|
6634
6633
|
onOverlap: e.onOverlap ?? "skip",
|
|
6635
6634
|
backfill: e.backfill ?? "skip",
|
|
6636
|
-
maxRuntimeMs: e.maxRuntimeMs ??
|
|
6637
|
-
[
|
|
6635
|
+
maxRuntimeMs: e.maxRuntimeMs ?? yf,
|
|
6636
|
+
[_f]: !0
|
|
6638
6637
|
};
|
|
6639
|
-
},
|
|
6640
|
-
let a =
|
|
6638
|
+
}, xf = (e) => r.unsafeParse(e.cron, e.timezone), Sf = (e, t = /* @__PURE__ */ new Date()) => r.next(xf(e), t), Cf = (e, t, n, i) => {
|
|
6639
|
+
let a = xf(e), o = [], s = r.next(a, t);
|
|
6641
6640
|
for (; s.getTime() <= n.getTime() && o.length <= i;) o.push(s), s = r.next(a, s);
|
|
6642
6641
|
return o;
|
|
6643
|
-
}, X = "_voltro_wakeups",
|
|
6642
|
+
}, X = "_voltro_wakeups", wf = (e) => `${e.tenantId}:${e.kind}:${e.refId}`, Tf = (e) => ({
|
|
6644
6643
|
tenantId: String(e.tenantId),
|
|
6645
6644
|
kind: String(e.kind),
|
|
6646
6645
|
refId: String(e.refId),
|
|
6647
6646
|
wakeAt: e.wakeAt instanceof Date ? e.wakeAt : new Date(String(e.wakeAt)),
|
|
6648
6647
|
status: e.status === "fired" ? "fired" : "pending"
|
|
6649
|
-
}),
|
|
6648
|
+
}), Ef = async (e, t) => {
|
|
6650
6649
|
await e.upsert(X, {
|
|
6651
|
-
id:
|
|
6650
|
+
id: wf(t),
|
|
6652
6651
|
tenantId: t.tenantId,
|
|
6653
6652
|
kind: t.kind,
|
|
6654
6653
|
refId: t.refId,
|
|
@@ -6658,7 +6657,7 @@ behind quietly.` + n;
|
|
|
6658
6657
|
conflictColumns: ["id"],
|
|
6659
6658
|
update: ["wakeAt", "status"]
|
|
6660
6659
|
});
|
|
6661
|
-
},
|
|
6660
|
+
}, Df = async (e, t) => e.delete(X, wf(t)), Of = async (e, t) => await e.update(X, wf(t), { status: "fired" }) !== null, kf = (e, t) => ({ and: [{
|
|
6662
6661
|
column: "id",
|
|
6663
6662
|
op: "eq",
|
|
6664
6663
|
value: e
|
|
@@ -6666,16 +6665,16 @@ behind quietly.` + n;
|
|
|
6666
6665
|
column: "status",
|
|
6667
6666
|
op: "eq",
|
|
6668
6667
|
value: t
|
|
6669
|
-
}] }),
|
|
6670
|
-
await e.updateMany(X, { status: "pending" }, { where:
|
|
6671
|
-
},
|
|
6668
|
+
}] }), Af = async (e, t) => await e.updateMany(X, { status: "fired" }, { where: kf(wf(t), "pending") }) > 0, jf = async (e, t) => {
|
|
6669
|
+
await e.updateMany(X, { status: "pending" }, { where: kf(wf(t), "fired") });
|
|
6670
|
+
}, Mf = {
|
|
6672
6671
|
column: "status",
|
|
6673
6672
|
op: "eq",
|
|
6674
6673
|
value: "pending"
|
|
6675
|
-
},
|
|
6674
|
+
}, Nf = async (e, t) => {
|
|
6676
6675
|
let n = {
|
|
6677
6676
|
table: X,
|
|
6678
|
-
predicate:
|
|
6677
|
+
predicate: Mf,
|
|
6679
6678
|
order: [{
|
|
6680
6679
|
column: "wakeAt",
|
|
6681
6680
|
direction: "asc"
|
|
@@ -6684,18 +6683,18 @@ behind quietly.` + n;
|
|
|
6684
6683
|
skip: void 0,
|
|
6685
6684
|
projection: void 0
|
|
6686
6685
|
};
|
|
6687
|
-
return (await e.query(n)).map(
|
|
6688
|
-
},
|
|
6689
|
-
let r = await
|
|
6686
|
+
return (await e.query(n)).map(Tf);
|
|
6687
|
+
}, Pf = async (e, t, n = 500) => {
|
|
6688
|
+
let r = await Nf(e, n), i = t.getTime();
|
|
6690
6689
|
return r.filter((e) => e.wakeAt.getTime() <= i);
|
|
6691
|
-
},
|
|
6690
|
+
}, Ff = async (e) => (await Nf(e, 1))[0] ?? null, If = {
|
|
6692
6691
|
column: "status",
|
|
6693
6692
|
op: "eq",
|
|
6694
6693
|
value: "fired"
|
|
6695
|
-
},
|
|
6694
|
+
}, Lf = async (e, t = {}) => {
|
|
6696
6695
|
let n = {
|
|
6697
6696
|
table: X,
|
|
6698
|
-
predicate:
|
|
6697
|
+
predicate: If,
|
|
6699
6698
|
order: [{
|
|
6700
6699
|
column: "wakeAt",
|
|
6701
6700
|
direction: "asc"
|
|
@@ -6706,12 +6705,12 @@ behind quietly.` + n;
|
|
|
6706
6705
|
}, r = await e.query(n), i = t.firedOlderThan?.getTime(), a = 0;
|
|
6707
6706
|
for (let t of r) i !== void 0 && (t.wakeAt instanceof Date ? t.wakeAt : new Date(String(t.wakeAt))).getTime() >= i || await e.delete(X, String(t.id)) && a++;
|
|
6708
6707
|
return a;
|
|
6709
|
-
},
|
|
6708
|
+
}, Rf = Ec, zf = "default", Bf = {
|
|
6710
6709
|
kind: "single",
|
|
6711
6710
|
tryClaim: async () => !0
|
|
6712
|
-
},
|
|
6711
|
+
}, Vf = "_voltro_schedule_claims", Hf = 6e4, Uf = 64, Wf = (e) => Math.max((e ?? 6e4) * 64, 6e4), Gf = (e, t, n) => {
|
|
6713
6712
|
let r = async (t) => (await e.query({
|
|
6714
|
-
table:
|
|
6713
|
+
table: Vf,
|
|
6715
6714
|
order: [],
|
|
6716
6715
|
predicate: O("id", t),
|
|
6717
6716
|
projection: ["id"],
|
|
@@ -6722,7 +6721,7 @@ behind quietly.` + n;
|
|
|
6722
6721
|
if (!(r - (i.get(t) ?? 0) < n)) {
|
|
6723
6722
|
i.set(t, r);
|
|
6724
6723
|
try {
|
|
6725
|
-
await e.deleteMany(
|
|
6724
|
+
await e.deleteMany(Vf, { where: C(O("scheduleName", t), he("claimedAt", new Date(r - n))) });
|
|
6726
6725
|
} catch {}
|
|
6727
6726
|
}
|
|
6728
6727
|
};
|
|
@@ -6734,13 +6733,13 @@ behind quietly.` + n;
|
|
|
6734
6733
|
if (await r(u)) return !1;
|
|
6735
6734
|
} catch {}
|
|
6736
6735
|
try {
|
|
6737
|
-
return await e.insert(
|
|
6736
|
+
return await e.insert(Vf, {
|
|
6738
6737
|
id: u,
|
|
6739
6738
|
scheduleName: i,
|
|
6740
6739
|
bucket: l,
|
|
6741
6740
|
claimedBy: t,
|
|
6742
6741
|
claimedAt: /* @__PURE__ */ new Date()
|
|
6743
|
-
}), await a(i,
|
|
6742
|
+
}), await a(i, Wf(s)), !0;
|
|
6744
6743
|
} catch (e) {
|
|
6745
6744
|
try {
|
|
6746
6745
|
if (await r(u)) return !1;
|
|
@@ -6752,12 +6751,12 @@ behind quietly.` + n;
|
|
|
6752
6751
|
}
|
|
6753
6752
|
}
|
|
6754
6753
|
};
|
|
6755
|
-
},
|
|
6754
|
+
}, Kf = "_voltro_schedule_runs", qf = async (e, t) => {
|
|
6756
6755
|
let { store: n, coordinator: i, buildContext: a, replicaId: o, log: s, onRunEvent: c, interceptFire: l } = t, u = t.dormancy === "sleep", d = t.dormancyTenantId ?? "default", f = /* @__PURE__ */ new Map(), p = /* @__PURE__ */ new Set(), m = /* @__PURE__ */ new Map(), h = !1, g = new Map(e.map((e) => [e.name, e])), _ = (e, t) => {
|
|
6757
|
-
c?.(e,
|
|
6756
|
+
c?.(e, Yf(t));
|
|
6758
6757
|
}, v = async (e, t, r, i, a, c) => {
|
|
6759
6758
|
try {
|
|
6760
|
-
let s = `sr_${
|
|
6759
|
+
let s = `sr_${He()}`, l = await n.insert(Kf, {
|
|
6761
6760
|
id: s,
|
|
6762
6761
|
name: e.name,
|
|
6763
6762
|
status: i,
|
|
@@ -6782,7 +6781,7 @@ behind quietly.` + n;
|
|
|
6782
6781
|
}
|
|
6783
6782
|
}, y = async (e, t) => {
|
|
6784
6783
|
try {
|
|
6785
|
-
let r = await n.update(
|
|
6784
|
+
let r = await n.update(Kf, e, t);
|
|
6786
6785
|
r && _("update", r);
|
|
6787
6786
|
} catch (t) {
|
|
6788
6787
|
s.warn("schedule: failed to record run finish", {
|
|
@@ -6793,7 +6792,7 @@ behind quietly.` + n;
|
|
|
6793
6792
|
}, b = async (e) => {
|
|
6794
6793
|
try {
|
|
6795
6794
|
let t = await n.query({
|
|
6796
|
-
table:
|
|
6795
|
+
table: Kf,
|
|
6797
6796
|
predicate: {
|
|
6798
6797
|
_tag: "leaf",
|
|
6799
6798
|
column: "status",
|
|
@@ -6828,7 +6827,7 @@ behind quietly.` + n;
|
|
|
6828
6827
|
scheduleName: e.name,
|
|
6829
6828
|
trigger: n,
|
|
6830
6829
|
runId: o,
|
|
6831
|
-
subject:
|
|
6830
|
+
subject: Rf
|
|
6832
6831
|
})
|
|
6833
6832
|
};
|
|
6834
6833
|
try {
|
|
@@ -6864,7 +6863,7 @@ behind quietly.` + n;
|
|
|
6864
6863
|
let n = Z(t).includes("exceeded maxRuntimeMs"), r = Yn(t).dbMessage, i = typeof r == "string" && r !== "" ? `${Z(t)} — ${r}` : Z(t);
|
|
6865
6864
|
o && await y(o, {
|
|
6866
6865
|
status: "failed",
|
|
6867
|
-
errorTag: n ? "timeout" :
|
|
6866
|
+
errorTag: n ? "timeout" : Jf(t),
|
|
6868
6867
|
errorMessage: i,
|
|
6869
6868
|
completedAt: /* @__PURE__ */ new Date(),
|
|
6870
6869
|
durationMs: Date.now() - c
|
|
@@ -6928,8 +6927,8 @@ behind quietly.` + n;
|
|
|
6928
6927
|
}
|
|
6929
6928
|
}, w = async (e) => {
|
|
6930
6929
|
try {
|
|
6931
|
-
let t = r.next(
|
|
6932
|
-
await
|
|
6930
|
+
let t = r.next(xf(e), /* @__PURE__ */ new Date());
|
|
6931
|
+
await Ef(n, {
|
|
6933
6932
|
tenantId: d,
|
|
6934
6933
|
kind: "schedule",
|
|
6935
6934
|
refId: e.name,
|
|
@@ -6943,7 +6942,7 @@ behind quietly.` + n;
|
|
|
6943
6942
|
}
|
|
6944
6943
|
}, T = 2147483647, E = (e) => {
|
|
6945
6944
|
if (h) return;
|
|
6946
|
-
let n =
|
|
6945
|
+
let n = xf(e), i = r.next(n, /* @__PURE__ */ new Date()), a = () => {
|
|
6947
6946
|
if (h) return;
|
|
6948
6947
|
let n = i.getTime() - Date.now();
|
|
6949
6948
|
if (n > T) {
|
|
@@ -6965,7 +6964,7 @@ behind quietly.` + n;
|
|
|
6965
6964
|
let i;
|
|
6966
6965
|
try {
|
|
6967
6966
|
let t = (await n.query({
|
|
6968
|
-
table:
|
|
6967
|
+
table: Kf,
|
|
6969
6968
|
order: [{
|
|
6970
6969
|
column: "scheduledAt",
|
|
6971
6970
|
direction: "desc"
|
|
@@ -6984,17 +6983,19 @@ behind quietly.` + n;
|
|
|
6984
6983
|
return;
|
|
6985
6984
|
}
|
|
6986
6985
|
if (!i) return;
|
|
6987
|
-
let a =
|
|
6986
|
+
let a = xf(e), o = [], c = r.next(a, i), l = Date.now();
|
|
6988
6987
|
for (; c.getTime() < l && o.length < 1e3;) o.push(c), c = r.next(a, c);
|
|
6989
|
-
if (o.length !== 0)
|
|
6990
|
-
|
|
6991
|
-
|
|
6992
|
-
|
|
6993
|
-
|
|
6994
|
-
|
|
6995
|
-
|
|
6996
|
-
|
|
6997
|
-
|
|
6988
|
+
if (o.length !== 0) {
|
|
6989
|
+
if (s.info("schedule: backfill", {
|
|
6990
|
+
name: e.name,
|
|
6991
|
+
missed: o.length,
|
|
6992
|
+
policy: e.backfill
|
|
6993
|
+
}), e.backfill === "latest") {
|
|
6994
|
+
for (let n of o.slice(0, -1)) await v(e, n, null, "missed", e.trigger ?? t.defaultTrigger, "single");
|
|
6995
|
+
let n = o[o.length - 1];
|
|
6996
|
+
await S(e, n, e.trigger ?? t.defaultTrigger);
|
|
6997
|
+
} else for (let n of o) await S(e, n, e.trigger ?? t.defaultTrigger);
|
|
6998
|
+
}
|
|
6998
6999
|
}, D = e.filter((e) => (e.trigger ?? t.defaultTrigger) === "self");
|
|
6999
7000
|
s.info("scheduler: starting", {
|
|
7000
7001
|
total: e.length,
|
|
@@ -7027,7 +7028,7 @@ behind quietly.` + n;
|
|
|
7027
7028
|
let i = g.get(e);
|
|
7028
7029
|
if (!i) throw Error(`scheduler.backfillRange: unknown schedule "${e}"`);
|
|
7029
7030
|
if (!(t.getTime() < n.getTime())) throw Error(`scheduler.backfillRange("${e}"): 'from' (${t.toISOString()}) must be before 'to' (${n.toISOString()})`);
|
|
7030
|
-
let a =
|
|
7031
|
+
let a = Cf(i, t, n, r.cap);
|
|
7031
7032
|
if (a.length > r.cap) throw Error(`scheduler.backfillRange("${e}"): more than ${r.cap} occurrences in ${t.toISOString()}..${n.toISOString()} — narrow the range or raise the cap`);
|
|
7032
7033
|
let o = [];
|
|
7033
7034
|
for (let e of a) {
|
|
@@ -7046,17 +7047,17 @@ behind quietly.` + n;
|
|
|
7046
7047
|
f.clear(), s.info("scheduler: stopped");
|
|
7047
7048
|
}
|
|
7048
7049
|
};
|
|
7049
|
-
}, Z = (e) => e?.message ?? String(e),
|
|
7050
|
+
}, Z = (e) => e?.message ?? String(e), Jf = (e) => e && typeof e == "object" && "_tag" in e ? String(e._tag) : null, Yf = (e) => {
|
|
7050
7051
|
let t = {};
|
|
7051
7052
|
for (let [n, r] of Object.entries(e)) t[n] = r instanceof Date ? r.toISOString() : r;
|
|
7052
7053
|
return t;
|
|
7053
|
-
},
|
|
7054
|
+
}, Xf = 3e4, Zf = (e = process.env) => {
|
|
7054
7055
|
let t = e.VOLTRO_POLL_CEILING_MS;
|
|
7055
|
-
if (t === void 0) return
|
|
7056
|
+
if (t === void 0) return Xf;
|
|
7056
7057
|
let n = Number(t);
|
|
7057
|
-
return Number.isFinite(n) && n > 0 ? n :
|
|
7058
|
-
},
|
|
7059
|
-
let i = Math.max(t, r.maxIdleIntervalMs ??
|
|
7058
|
+
return Number.isFinite(n) && n > 0 ? n : Xf;
|
|
7059
|
+
}, Qf = (e, t, n, r) => {
|
|
7060
|
+
let i = Math.max(t, r.maxIdleIntervalMs ?? Zf()), a = !1, o, s = !1, c = t, l = !1, u = !1, d = 0, f = (e) => {
|
|
7060
7061
|
if (!a) {
|
|
7061
7062
|
if (o !== void 0 && clearTimeout(o), o = void 0, e === "disarm") {
|
|
7062
7063
|
s = !0;
|
|
@@ -7099,7 +7100,7 @@ behind quietly.` + n;
|
|
|
7099
7100
|
}), f(t);
|
|
7100
7101
|
return;
|
|
7101
7102
|
}
|
|
7102
|
-
f(
|
|
7103
|
+
f($f(s, t, c, i, r.disarmWhenIdle ?? !1));
|
|
7103
7104
|
} finally {
|
|
7104
7105
|
l = !1, u && !a && (u = !1, f(0));
|
|
7105
7106
|
}
|
|
@@ -7123,107 +7124,107 @@ behind quietly.` + n;
|
|
|
7123
7124
|
a || (a = !0, o !== void 0 && clearTimeout(o), o = void 0);
|
|
7124
7125
|
}
|
|
7125
7126
|
};
|
|
7126
|
-
},
|
|
7127
|
+
}, $f = (e, t, n, r, i = !1) => {
|
|
7127
7128
|
if (e === void 0 || !e.idle) return t;
|
|
7128
7129
|
if (e.nextDueInMs === void 0 && i) return "disarm";
|
|
7129
7130
|
let a = Math.min(Math.max(n, t) * 2, r);
|
|
7130
7131
|
return e.nextDueInMs === void 0 ? a : Math.max(t, Math.min(a, e.nextDueInMs));
|
|
7131
|
-
},
|
|
7132
|
+
}, ep = (e) => (t, n, r, i) => Qf(t, n, r, {
|
|
7132
7133
|
...e,
|
|
7133
7134
|
...i?.disarmWhenIdle === void 0 ? {} : { disarmWhenIdle: i.disarmWhenIdle }
|
|
7134
|
-
}),
|
|
7135
|
-
id:
|
|
7136
|
-
name:
|
|
7137
|
-
status:
|
|
7135
|
+
}), tp = I("_voltro_schedule_runs", {
|
|
7136
|
+
id: N({ prefix: "schrun" }),
|
|
7137
|
+
name: L(),
|
|
7138
|
+
status: L().oneOf([
|
|
7138
7139
|
"running",
|
|
7139
7140
|
"succeeded",
|
|
7140
7141
|
"failed",
|
|
7141
7142
|
"skipped",
|
|
7142
7143
|
"missed"
|
|
7143
7144
|
]).default("running"),
|
|
7144
|
-
trigger:
|
|
7145
|
+
trigger: L().oneOf([
|
|
7145
7146
|
"self",
|
|
7146
7147
|
"external",
|
|
7147
7148
|
"manual"
|
|
7148
7149
|
]).default("self"),
|
|
7149
|
-
scheduledAt:
|
|
7150
|
-
firedAt:
|
|
7151
|
-
completedAt:
|
|
7152
|
-
durationMs:
|
|
7153
|
-
errorTag:
|
|
7154
|
-
errorMessage:
|
|
7155
|
-
coordinationOutcome:
|
|
7150
|
+
scheduledAt: R(),
|
|
7151
|
+
firedAt: R().nullable(),
|
|
7152
|
+
completedAt: R().nullable(),
|
|
7153
|
+
durationMs: P().nullable(),
|
|
7154
|
+
errorTag: L().nullable(),
|
|
7155
|
+
errorMessage: L().nullable(),
|
|
7156
|
+
coordinationOutcome: L().oneOf([
|
|
7156
7157
|
"single",
|
|
7157
7158
|
"wonLock",
|
|
7158
7159
|
"lostLock",
|
|
7159
7160
|
"external",
|
|
7160
7161
|
"cluster"
|
|
7161
7162
|
]).nullable(),
|
|
7162
|
-
replicaId:
|
|
7163
|
-
result:
|
|
7164
|
-
}).index(["name", "scheduledAt"]).index(["status"]),
|
|
7165
|
-
id:
|
|
7166
|
-
scheduleName:
|
|
7167
|
-
bucket:
|
|
7168
|
-
claimedBy:
|
|
7169
|
-
claimedAt:
|
|
7170
|
-
}).index(["scheduleName", "claimedAt"]).index(["claimedAt"]),
|
|
7171
|
-
id:
|
|
7172
|
-
traceId:
|
|
7173
|
-
spanId:
|
|
7174
|
-
parentSpanId:
|
|
7175
|
-
name:
|
|
7176
|
-
kind:
|
|
7163
|
+
replicaId: L().nullable(),
|
|
7164
|
+
result: F().nullable()
|
|
7165
|
+
}).index(["name", "scheduledAt"]).index(["status"]), np = I("_voltro_schedule_claims", {
|
|
7166
|
+
id: N({ prefix: "schclaim" }),
|
|
7167
|
+
scheduleName: L(),
|
|
7168
|
+
bucket: L(),
|
|
7169
|
+
claimedBy: L(),
|
|
7170
|
+
claimedAt: R()
|
|
7171
|
+
}).index(["scheduleName", "claimedAt"]).index(["claimedAt"]), rp = I("_voltro_traces", {
|
|
7172
|
+
id: N({ prefix: "span" }),
|
|
7173
|
+
traceId: L(),
|
|
7174
|
+
spanId: L(),
|
|
7175
|
+
parentSpanId: L().nullable(),
|
|
7176
|
+
name: L(),
|
|
7177
|
+
kind: L().oneOf([
|
|
7177
7178
|
"internal",
|
|
7178
7179
|
"server",
|
|
7179
7180
|
"client",
|
|
7180
7181
|
"producer",
|
|
7181
7182
|
"consumer"
|
|
7182
7183
|
]).default("internal"),
|
|
7183
|
-
status:
|
|
7184
|
+
status: L().oneOf([
|
|
7184
7185
|
"ok",
|
|
7185
7186
|
"error",
|
|
7186
7187
|
"unset"
|
|
7187
7188
|
]).default("unset"),
|
|
7188
|
-
statusMessage:
|
|
7189
|
-
startedAt:
|
|
7190
|
-
endedAt:
|
|
7191
|
-
durationMs:
|
|
7192
|
-
attributes:
|
|
7193
|
-
events:
|
|
7194
|
-
}).index(["traceId", "startedAt"]).index(["startedAt"]).index(["status"]),
|
|
7195
|
-
id:
|
|
7196
|
-
tag:
|
|
7197
|
-
label:
|
|
7198
|
-
subjectId:
|
|
7199
|
-
tenantId:
|
|
7200
|
-
traceId:
|
|
7201
|
-
changes:
|
|
7189
|
+
statusMessage: L().nullable(),
|
|
7190
|
+
startedAt: R(),
|
|
7191
|
+
endedAt: R(),
|
|
7192
|
+
durationMs: P(),
|
|
7193
|
+
attributes: F().nullable(),
|
|
7194
|
+
events: F().nullable()
|
|
7195
|
+
}).index(["traceId", "startedAt"]).index(["startedAt"]).index(["status"]), ip = I("_voltro_undo_log", {
|
|
7196
|
+
id: N({ prefix: "undo" }),
|
|
7197
|
+
tag: L(),
|
|
7198
|
+
label: L().nullable(),
|
|
7199
|
+
subjectId: L().nullable(),
|
|
7200
|
+
tenantId: L().nullable(),
|
|
7201
|
+
traceId: L().nullable(),
|
|
7202
|
+
changes: L(),
|
|
7202
7203
|
crossesAction: E().default(!1),
|
|
7203
7204
|
undone: E().default(!1),
|
|
7204
|
-
createdAt:
|
|
7205
|
-
}).index(["subjectId", "createdAt"]),
|
|
7205
|
+
createdAt: R().default("now")
|
|
7206
|
+
}).index(["subjectId", "createdAt"]), ap = (e = process.env) => {
|
|
7206
7207
|
let t = (e.VOLTRO_UNDO ?? "").toLowerCase();
|
|
7207
7208
|
return t === "on" || t === "1" || t === "true" ? !0 : t === "off" || t === "0" || t === "false" ? !1 : e.NODE_ENV !== "production";
|
|
7208
|
-
},
|
|
7209
|
+
}, op = (e = process.env) => {
|
|
7209
7210
|
let t = (e.VOLTRO_UNDO ?? "").toLowerCase();
|
|
7210
|
-
return
|
|
7211
|
-
},
|
|
7211
|
+
return t !== "off" && t !== "0" && t !== "false";
|
|
7212
|
+
}, sp = (e) => e.startsWith("_voltro"), cp = async (e, t, n) => (await e.query({
|
|
7212
7213
|
table: t,
|
|
7213
7214
|
predicate: O("id", n),
|
|
7214
7215
|
order: []
|
|
7215
|
-
}))[0] ?? null,
|
|
7216
|
+
}))[0] ?? null, lp = (e, t) => new Proxy(e, { get(e, n, r) {
|
|
7216
7217
|
if (n === "insert") return async (n, r) => {
|
|
7217
7218
|
let i = await e.insert(n, r);
|
|
7218
|
-
return
|
|
7219
|
+
return sp(n) || t({
|
|
7219
7220
|
table: n,
|
|
7220
7221
|
op: "insert",
|
|
7221
7222
|
next: i
|
|
7222
7223
|
}), i;
|
|
7223
7224
|
};
|
|
7224
7225
|
if (n === "update") return async (n, r, i) => {
|
|
7225
|
-
let a =
|
|
7226
|
-
return
|
|
7226
|
+
let a = sp(n) ? null : await cp(e, n, r), o = await e.update(n, r, i);
|
|
7227
|
+
return sp(n) || t({
|
|
7227
7228
|
table: n,
|
|
7228
7229
|
op: "update",
|
|
7229
7230
|
id: r,
|
|
@@ -7232,8 +7233,8 @@ behind quietly.` + n;
|
|
|
7232
7233
|
}), o;
|
|
7233
7234
|
};
|
|
7234
7235
|
if (n === "delete") return async (n, r) => {
|
|
7235
|
-
let i =
|
|
7236
|
-
return !
|
|
7236
|
+
let i = sp(n) ? null : await cp(e, n, r), a = await e.delete(n, r);
|
|
7237
|
+
return !sp(n) && a && t({
|
|
7237
7238
|
table: n,
|
|
7238
7239
|
op: "delete",
|
|
7239
7240
|
id: r,
|
|
@@ -7242,10 +7243,10 @@ behind quietly.` + n;
|
|
|
7242
7243
|
};
|
|
7243
7244
|
let i = Reflect.get(e, n, r);
|
|
7244
7245
|
return typeof i == "function" ? i.bind(e) : i;
|
|
7245
|
-
} }),
|
|
7246
|
+
} }), up = (e) => {
|
|
7246
7247
|
let t = [];
|
|
7247
7248
|
return {
|
|
7248
|
-
tx:
|
|
7249
|
+
tx: lp(e, (e) => t.push(e)),
|
|
7249
7250
|
persist: async (e, n) => {
|
|
7250
7251
|
if (t.length === 0 || n.tag.startsWith("__voltro")) return;
|
|
7251
7252
|
let r = n.subject;
|
|
@@ -7261,13 +7262,13 @@ behind quietly.` + n;
|
|
|
7261
7262
|
});
|
|
7262
7263
|
}
|
|
7263
7264
|
};
|
|
7264
|
-
},
|
|
7265
|
+
}, dp = (e) => e.startsWith("_voltro"), fp = (e) => {
|
|
7265
7266
|
let t = e?.id;
|
|
7266
7267
|
return typeof t == "string" ? t : void 0;
|
|
7267
|
-
},
|
|
7268
|
+
}, pp = (e) => {
|
|
7268
7269
|
let t = /* @__PURE__ */ new Map(), n = (e, n) => {
|
|
7269
|
-
if (n == null ||
|
|
7270
|
-
let r =
|
|
7270
|
+
if (n == null || dp(e)) return;
|
|
7271
|
+
let r = fp(n);
|
|
7271
7272
|
r !== void 0 && t.set(`${e}\u0000${r}`, {
|
|
7272
7273
|
table: e,
|
|
7273
7274
|
id: r,
|
|
@@ -7292,9 +7293,9 @@ behind quietly.` + n;
|
|
|
7292
7293
|
} }),
|
|
7293
7294
|
drain: () => [...t.values()]
|
|
7294
7295
|
};
|
|
7295
|
-
},
|
|
7296
|
-
if (
|
|
7297
|
-
},
|
|
7296
|
+
}, mp = (e) => {
|
|
7297
|
+
if (e !== !0 && e !== void 0) return e === !1 ? {} : e;
|
|
7298
|
+
}, hp = async (e) => {
|
|
7298
7299
|
if (e.touched.length === 0) return;
|
|
7299
7300
|
let t = {
|
|
7300
7301
|
store: e.store,
|
|
@@ -7302,8 +7303,8 @@ behind quietly.` + n;
|
|
|
7302
7303
|
};
|
|
7303
7304
|
for (let { table: n, row: r } of e.touched) {
|
|
7304
7305
|
let e = j(n)?.appliedRules;
|
|
7305
|
-
if (
|
|
7306
|
-
let e =
|
|
7306
|
+
if (e !== void 0 && e.length !== 0) for (let i of e) {
|
|
7307
|
+
let e = mp(await i.predicate(r, t));
|
|
7307
7308
|
if (e !== void 0) {
|
|
7308
7309
|
if (i.severity === "warning") {
|
|
7309
7310
|
Ht.warn("business rule violated (warning)", {
|
|
@@ -7314,7 +7315,7 @@ behind quietly.` + n;
|
|
|
7314
7315
|
});
|
|
7315
7316
|
continue;
|
|
7316
7317
|
}
|
|
7317
|
-
throw new
|
|
7318
|
+
throw new it({
|
|
7318
7319
|
rule: i.name,
|
|
7319
7320
|
severity: "error",
|
|
7320
7321
|
...e.params === void 0 ? {} : { params: e.params },
|
|
@@ -7324,14 +7325,14 @@ behind quietly.` + n;
|
|
|
7324
7325
|
}
|
|
7325
7326
|
}
|
|
7326
7327
|
}
|
|
7327
|
-
},
|
|
7328
|
+
}, gp = (e) => {
|
|
7328
7329
|
if (e.id !== void 0) return e.id;
|
|
7329
7330
|
let t = e.next?.id;
|
|
7330
7331
|
if (typeof t == "string") return t;
|
|
7331
7332
|
let n = e.prev?.id;
|
|
7332
7333
|
return typeof n == "string" ? n : void 0;
|
|
7333
|
-
},
|
|
7334
|
-
let t =
|
|
7334
|
+
}, _p = (e) => {
|
|
7335
|
+
let t = gp(e);
|
|
7335
7336
|
switch (e.op) {
|
|
7336
7337
|
case "insert": return t === void 0 ? null : {
|
|
7337
7338
|
table: e.table,
|
|
@@ -7355,28 +7356,28 @@ behind quietly.` + n;
|
|
|
7355
7356
|
row: e.prev
|
|
7356
7357
|
};
|
|
7357
7358
|
}
|
|
7358
|
-
},
|
|
7359
|
-
if (e.crossesAction) throw new
|
|
7359
|
+
}, vp = (e) => {
|
|
7360
|
+
if (e.crossesAction) throw new yp(e.invocationId, "action");
|
|
7360
7361
|
let t = [];
|
|
7361
7362
|
for (let n = e.changes.length - 1; n >= 0; --n) {
|
|
7362
|
-
let r =
|
|
7363
|
+
let r = _p(e.changes[n]);
|
|
7363
7364
|
r !== null && t.push(r);
|
|
7364
7365
|
}
|
|
7365
7366
|
return t;
|
|
7366
|
-
},
|
|
7367
|
+
}, yp = class extends Error {
|
|
7367
7368
|
invocationId;
|
|
7368
7369
|
boundary;
|
|
7369
7370
|
_tag = "UndoBoundaryError";
|
|
7370
7371
|
constructor(e, t) {
|
|
7371
7372
|
super(t === "action" ? `cannot undo invocation ${e}: it crossed an action (external side effect)` : `cannot undo invocation ${e}: the row changed since (conflict)`), this.invocationId = e, this.boundary = t, this.name = "UndoBoundaryError";
|
|
7372
7373
|
}
|
|
7373
|
-
},
|
|
7374
|
+
}, bp = (e, t, n = ["updatedAt", "updatedBy"]) => {
|
|
7374
7375
|
if (t == null) return e == null;
|
|
7375
7376
|
if (e == null) return !1;
|
|
7376
7377
|
let r = new Set(n);
|
|
7377
7378
|
for (let [n, i] of Object.entries(t)) if (!r.has(n) && !Object.is(e[n], i) && JSON.stringify(e[n]) !== JSON.stringify(i)) return !1;
|
|
7378
7379
|
return !0;
|
|
7379
|
-
},
|
|
7380
|
+
}, xp = class {
|
|
7380
7381
|
capacity;
|
|
7381
7382
|
done = [];
|
|
7382
7383
|
undone = [];
|
|
@@ -7412,7 +7413,7 @@ behind quietly.` + n;
|
|
|
7412
7413
|
redo: [...this.undone]
|
|
7413
7414
|
};
|
|
7414
7415
|
}
|
|
7415
|
-
},
|
|
7416
|
+
}, Sp = (e, t = /* @__PURE__ */ new Set()) => e.op === "insert" ? {
|
|
7416
7417
|
table: e.table,
|
|
7417
7418
|
op: "insert",
|
|
7418
7419
|
next: e.new ?? null
|
|
@@ -7429,7 +7430,7 @@ behind quietly.` + n;
|
|
|
7429
7430
|
table: e.table,
|
|
7430
7431
|
op: "delete",
|
|
7431
7432
|
prev: e.old ?? null
|
|
7432
|
-
},
|
|
7433
|
+
}, Cp = async (e, t) => {
|
|
7433
7434
|
switch (t.op) {
|
|
7434
7435
|
case "delete":
|
|
7435
7436
|
await e.delete(t.table, t.id);
|
|
@@ -7447,21 +7448,21 @@ behind quietly.` + n;
|
|
|
7447
7448
|
await e.insert(t.table, t.row);
|
|
7448
7449
|
return;
|
|
7449
7450
|
}
|
|
7450
|
-
},
|
|
7451
|
-
for (let n of t) await
|
|
7452
|
-
},
|
|
7451
|
+
}, wp = async (e, t) => {
|
|
7452
|
+
for (let n of t) await Cp(e, n);
|
|
7453
|
+
}, Tp = (e) => e.request?.subject?.id ?? null, Ep = (e) => e === !0 || e === 1, Dp = async (e, t, n) => (await e.query({
|
|
7453
7454
|
table: t,
|
|
7454
7455
|
predicate: O("id", n),
|
|
7455
7456
|
order: []
|
|
7456
|
-
}))[0] ?? null,
|
|
7457
|
+
}))[0] ?? null, Op = (e) => {
|
|
7457
7458
|
try {
|
|
7458
7459
|
let t = JSON.parse(String(e ?? "[]"));
|
|
7459
7460
|
return Array.isArray(t) ? t : [];
|
|
7460
7461
|
} catch {
|
|
7461
7462
|
return [];
|
|
7462
7463
|
}
|
|
7463
|
-
},
|
|
7464
|
-
let n =
|
|
7464
|
+
}, kp = (e) => e.id ?? e.next?.id ?? e.prev?.id, Ap = async (e, t) => {
|
|
7465
|
+
let n = Tp(t);
|
|
7465
7466
|
return [...await t.store.query({
|
|
7466
7467
|
table: "_voltro_undo_log",
|
|
7467
7468
|
predicate: O("subjectId", n),
|
|
@@ -7470,72 +7471,72 @@ behind quietly.` + n;
|
|
|
7470
7471
|
id: String(e.id),
|
|
7471
7472
|
tag: String(e.tag ?? ""),
|
|
7472
7473
|
label: e.label ?? null,
|
|
7473
|
-
undone:
|
|
7474
|
-
crossesAction:
|
|
7474
|
+
undone: Ep(e.undone),
|
|
7475
|
+
crossesAction: Ep(e.crossesAction),
|
|
7475
7476
|
createdAt: String(e.createdAt ?? "")
|
|
7476
7477
|
}));
|
|
7477
|
-
}, Ap = async (e, t) => {
|
|
7478
|
-
let n = await Ep(t.store, "_voltro_undo_log", e.invocationId);
|
|
7479
|
-
if (!n) throw new yt({ invocationId: e.invocationId });
|
|
7480
|
-
if ((n.subjectId ?? null) !== wp(t)) throw new vt({ invocationId: e.invocationId });
|
|
7481
|
-
return n;
|
|
7482
7478
|
}, jp = async (e, t) => {
|
|
7483
|
-
let n = await
|
|
7484
|
-
if (
|
|
7485
|
-
if (
|
|
7479
|
+
let n = await Dp(t.store, "_voltro_undo_log", e.invocationId);
|
|
7480
|
+
if (!n) throw new vt({ invocationId: e.invocationId });
|
|
7481
|
+
if ((n.subjectId ?? null) !== Tp(t)) throw new _t({ invocationId: e.invocationId });
|
|
7482
|
+
return n;
|
|
7483
|
+
}, Mp = async (e, t) => {
|
|
7484
|
+
let n = await jp(e, t);
|
|
7485
|
+
if (Ep(n.undone)) return { ok: !0 };
|
|
7486
|
+
if (Ep(n.crossesAction)) throw new gt({
|
|
7486
7487
|
invocationId: e.invocationId,
|
|
7487
7488
|
reason: "action"
|
|
7488
7489
|
});
|
|
7489
|
-
let r =
|
|
7490
|
+
let r = Op(n.changes);
|
|
7490
7491
|
for (let n of r) {
|
|
7491
|
-
let r =
|
|
7492
|
-
if (r !== void 0 && !
|
|
7492
|
+
let r = kp(n);
|
|
7493
|
+
if (r !== void 0 && !bp(await Dp(t.store, n.table, r), n.next ?? null)) throw new gt({
|
|
7493
7494
|
invocationId: e.invocationId,
|
|
7494
7495
|
reason: "conflict"
|
|
7495
7496
|
});
|
|
7496
7497
|
}
|
|
7497
7498
|
let i = {
|
|
7498
7499
|
invocationId: e.invocationId,
|
|
7499
|
-
subject:
|
|
7500
|
+
subject: Tp(t),
|
|
7500
7501
|
changes: r,
|
|
7501
7502
|
crossesAction: !1
|
|
7502
7503
|
};
|
|
7503
|
-
return await
|
|
7504
|
-
},
|
|
7505
|
-
let n = await
|
|
7506
|
-
if (!
|
|
7507
|
-
for (let e of
|
|
7508
|
-
let n =
|
|
7504
|
+
return await wp(t.store, vp(i)), await t.store.update("_voltro_undo_log", e.invocationId, { undone: !0 }), { ok: !0 };
|
|
7505
|
+
}, Np = async (e, t) => {
|
|
7506
|
+
let n = await jp(e, t);
|
|
7507
|
+
if (!Ep(n.undone)) return { ok: !0 };
|
|
7508
|
+
for (let e of Op(n.changes)) {
|
|
7509
|
+
let n = kp(e);
|
|
7509
7510
|
e.op === "insert" && e.next ? await t.store.insert(e.table, e.next) : e.op === "update" && n !== void 0 && e.next ? await t.store.update(e.table, n, e.next) : e.op === "delete" && n !== void 0 && await t.store.delete(e.table, n);
|
|
7510
7511
|
}
|
|
7511
7512
|
return await t.store.update("_voltro_undo_log", e.invocationId, { undone: !1 }), { ok: !0 };
|
|
7512
|
-
},
|
|
7513
|
-
id:
|
|
7514
|
-
intentKey:
|
|
7515
|
-
procedure:
|
|
7516
|
-
kind:
|
|
7517
|
-
requestedBy:
|
|
7518
|
-
tenantId:
|
|
7519
|
-
payload:
|
|
7520
|
-
approverGuards:
|
|
7521
|
-
approverScopes:
|
|
7522
|
-
reason:
|
|
7523
|
-
status:
|
|
7524
|
-
decidedBy:
|
|
7525
|
-
decidedAt:
|
|
7526
|
-
note:
|
|
7527
|
-
traceId:
|
|
7528
|
-
requestedAt:
|
|
7529
|
-
expiresAt:
|
|
7530
|
-
consumedAt:
|
|
7531
|
-
}).index(["status", "expiresAt"]).index(["requestedBy"]),
|
|
7532
|
-
|
|
7513
|
+
}, Pp = "_voltro_approvals", Fp = 864e5, Ip = I(Pp, {
|
|
7514
|
+
id: N({ prefix: "apv" }),
|
|
7515
|
+
intentKey: L().maxLength(191),
|
|
7516
|
+
procedure: L(),
|
|
7517
|
+
kind: L(),
|
|
7518
|
+
requestedBy: L().nullable(),
|
|
7519
|
+
tenantId: L().nullable(),
|
|
7520
|
+
payload: L(),
|
|
7521
|
+
approverGuards: L(),
|
|
7522
|
+
approverScopes: L(),
|
|
7523
|
+
reason: L().nullable(),
|
|
7524
|
+
status: L().default("pending"),
|
|
7525
|
+
decidedBy: L().nullable(),
|
|
7526
|
+
decidedAt: R().nullable(),
|
|
7527
|
+
note: L().nullable(),
|
|
7528
|
+
traceId: L().nullable(),
|
|
7529
|
+
requestedAt: R().default("now"),
|
|
7530
|
+
expiresAt: R(),
|
|
7531
|
+
consumedAt: R().nullable()
|
|
7532
|
+
}).index(["status", "expiresAt"]).index(["requestedBy"]), Lp = () => {
|
|
7533
|
+
Ee({
|
|
7533
7534
|
source: "framework",
|
|
7534
|
-
table:
|
|
7535
|
+
table: Pp,
|
|
7535
7536
|
timeColumn: "requestedAt",
|
|
7536
|
-
ttlMs:
|
|
7537
|
+
ttlMs: ke(process.env.VOLTRO_APPROVALS_TTL_HOURS, 720)
|
|
7537
7538
|
});
|
|
7538
|
-
},
|
|
7539
|
+
}, Rp = (e, t) => e.map((e) => jt(e) ? {
|
|
7539
7540
|
kind: "policy",
|
|
7540
7541
|
action: e.action,
|
|
7541
7542
|
resourceType: e.resourceType,
|
|
@@ -7545,7 +7546,7 @@ behind quietly.` + n;
|
|
|
7545
7546
|
scope: typeof e.scope == "string" ? [e.scope] : [...e.scope],
|
|
7546
7547
|
mode: e.mode ?? "all",
|
|
7547
7548
|
resource: e.resource?.(t) ?? null
|
|
7548
|
-
}),
|
|
7549
|
+
}), zp = (e) => e.map((e) => e.kind === "policy" ? {
|
|
7549
7550
|
action: e.action,
|
|
7550
7551
|
resourceType: e.resourceType,
|
|
7551
7552
|
resource: () => e.resource ?? void 0
|
|
@@ -7553,7 +7554,7 @@ behind quietly.` + n;
|
|
|
7553
7554
|
scope: e.scope,
|
|
7554
7555
|
mode: e.mode,
|
|
7555
7556
|
...e.resource === null ? {} : { resource: () => e.resource ?? void 0 }
|
|
7556
|
-
}),
|
|
7557
|
+
}), Bp = (e) => e.flatMap((e) => e.kind === "policy" ? [`${e.resourceType}:${e.action}`] : [...e.scope]), Vp = (e) => {
|
|
7557
7558
|
let t = (e) => {
|
|
7558
7559
|
if (Array.isArray(e)) return e.map(t);
|
|
7559
7560
|
if (typeof e == "object" && e) {
|
|
@@ -7564,7 +7565,7 @@ behind quietly.` + n;
|
|
|
7564
7565
|
return e;
|
|
7565
7566
|
};
|
|
7566
7567
|
return JSON.stringify(t(e) ?? null);
|
|
7567
|
-
},
|
|
7568
|
+
}, Hp = (e) => {
|
|
7568
7569
|
let t = [
|
|
7569
7570
|
e.procedure,
|
|
7570
7571
|
e.requestedBy ?? "",
|
|
@@ -7572,49 +7573,49 @@ behind quietly.` + n;
|
|
|
7572
7573
|
e.payload,
|
|
7573
7574
|
e.nonce ?? ""
|
|
7574
7575
|
].map((e) => `${e.length}:${e}`).join("");
|
|
7575
|
-
return
|
|
7576
|
-
},
|
|
7576
|
+
return Be("sha256").update(t, "utf8").digest("hex");
|
|
7577
|
+
}, Up = (e) => e instanceof Date ? e.toISOString() : typeof e == "string" ? e : (/* @__PURE__ */ new Date(0)).toISOString(), Wp = (e) => e instanceof Date ? e.getTime() : typeof e == "string" ? Date.parse(e) : 0, Gp = (e) => {
|
|
7577
7578
|
try {
|
|
7578
7579
|
let t = JSON.parse(String(e ?? "[]"));
|
|
7579
7580
|
return Array.isArray(t) ? t : [];
|
|
7580
7581
|
} catch {
|
|
7581
7582
|
return [];
|
|
7582
7583
|
}
|
|
7583
|
-
},
|
|
7584
|
+
}, Kp = async (e, t) => (await e.query({
|
|
7584
7585
|
table: "_voltro_approvals",
|
|
7585
7586
|
predicate: O("intentKey", t),
|
|
7586
7587
|
order: []
|
|
7587
|
-
}))[0] ?? null,
|
|
7588
|
+
}))[0] ?? null, qp = async (e, t) => (await e.query({
|
|
7588
7589
|
table: "_voltro_approvals",
|
|
7589
7590
|
predicate: O("id", t),
|
|
7590
7591
|
order: []
|
|
7591
|
-
}))[0] ?? null,
|
|
7592
|
+
}))[0] ?? null, Jp = async (e, t, n) => {
|
|
7592
7593
|
let r = String(t.intentKey ?? ""), i = r.includes("#") ? r : `${r}#${String(t.id)}`;
|
|
7593
|
-
await e.update(
|
|
7594
|
+
await e.update(Pp, String(t.id), {
|
|
7594
7595
|
...n,
|
|
7595
7596
|
intentKey: i
|
|
7596
7597
|
});
|
|
7597
|
-
},
|
|
7598
|
+
}, Yp = (e) => {
|
|
7598
7599
|
let t = /^(\d+(?:\.\d+)?)\s*(ms|s|m|h|d)$/.exec(e.trim());
|
|
7599
7600
|
if (t === null) return null;
|
|
7600
7601
|
let n = Number(t[1]);
|
|
7601
7602
|
if (!(Number.isFinite(n) && n > 0)) return null;
|
|
7602
7603
|
let r = t[2];
|
|
7603
7604
|
return n * (r === "ms" ? 1 : r === "s" ? 1e3 : r === "m" ? 6e4 : r === "h" ? 36e5 : 864e5);
|
|
7604
|
-
},
|
|
7605
|
+
}, Xp = (e) => {
|
|
7605
7606
|
let t = e.store, n = e.now ?? Date.now, r = e.defaultExpiryMs ?? 864e5;
|
|
7606
|
-
|
|
7607
|
+
Lp();
|
|
7607
7608
|
let i = (e) => {
|
|
7608
7609
|
if (e.expiresIn === void 0) return r;
|
|
7609
|
-
let t =
|
|
7610
|
+
let t = Yp(e.expiresIn);
|
|
7610
7611
|
if (t === null) throw Error(`requiresApproval.expiresIn must be an interval like '4h' / '30m' (got ${JSON.stringify(e.expiresIn)})`);
|
|
7611
7612
|
return t;
|
|
7612
7613
|
}, a = async (e, r, a) => {
|
|
7613
|
-
let o =
|
|
7614
|
+
let o = Rp(e.policy.approvers, e.input), s = A({
|
|
7614
7615
|
kind: "typeid",
|
|
7615
7616
|
prefix: "apv"
|
|
7616
|
-
},
|
|
7617
|
-
await t.insertIgnore(
|
|
7617
|
+
}, Pp), c = n();
|
|
7618
|
+
await t.insertIgnore(Pp, {
|
|
7618
7619
|
id: s,
|
|
7619
7620
|
intentKey: r,
|
|
7620
7621
|
procedure: e.procedure,
|
|
@@ -7623,7 +7624,7 @@ behind quietly.` + n;
|
|
|
7623
7624
|
tenantId: e.subject?.tenantId ?? null,
|
|
7624
7625
|
payload: a,
|
|
7625
7626
|
approverGuards: JSON.stringify(o),
|
|
7626
|
-
approverScopes: JSON.stringify(
|
|
7627
|
+
approverScopes: JSON.stringify(Bp(o)),
|
|
7627
7628
|
reason: e.policy.reason ?? null,
|
|
7628
7629
|
status: "pending",
|
|
7629
7630
|
decidedBy: null,
|
|
@@ -7634,36 +7635,36 @@ behind quietly.` + n;
|
|
|
7634
7635
|
expiresAt: new Date(c + i(e.policy)),
|
|
7635
7636
|
consumedAt: null
|
|
7636
7637
|
}, { conflictColumns: ["intentKey"] });
|
|
7637
|
-
let l = await
|
|
7638
|
-
if (l === null) throw new
|
|
7638
|
+
let l = await Kp(t, r);
|
|
7639
|
+
if (l === null) throw new nt({
|
|
7639
7640
|
procedure: e.procedure,
|
|
7640
7641
|
message: "the approval intent was written and could not be read back"
|
|
7641
7642
|
});
|
|
7642
7643
|
return l;
|
|
7643
|
-
}, o = (e, t) => new
|
|
7644
|
+
}, o = (e, t) => new et({
|
|
7644
7645
|
approvalId: String(e.id),
|
|
7645
7646
|
procedure: String(e.procedure),
|
|
7646
|
-
expiresAt:
|
|
7647
|
-
requiredScopes:
|
|
7647
|
+
expiresAt: Up(e.expiresAt),
|
|
7648
|
+
requiredScopes: Bp(Gp(e.approverGuards)),
|
|
7648
7649
|
reason: e.reason ?? null,
|
|
7649
7650
|
created: t
|
|
7650
7651
|
});
|
|
7651
7652
|
return { admit: async (e) => {
|
|
7652
|
-
let r =
|
|
7653
|
+
let r = Vp(e.input), i = Hp({
|
|
7653
7654
|
procedure: e.procedure,
|
|
7654
7655
|
requestedBy: e.subject?.id ?? null,
|
|
7655
7656
|
tenantId: e.subject?.tenantId ?? null,
|
|
7656
7657
|
payload: r,
|
|
7657
7658
|
nonce: e.nonce
|
|
7658
|
-
}), s = await
|
|
7659
|
+
}), s = await Kp(t, i);
|
|
7659
7660
|
if (s === null) throw o(await a(e, i, r), !0);
|
|
7660
|
-
let c = String(s.status ?? "pending"), l =
|
|
7661
|
-
if ((c === "pending" || c === "approved") && n() > l) throw await
|
|
7661
|
+
let c = String(s.status ?? "pending"), l = Wp(s.expiresAt);
|
|
7662
|
+
if ((c === "pending" || c === "approved") && n() > l) throw await Jp(t, s, { status: "expired" }), new Ye({
|
|
7662
7663
|
approvalId: String(s.id),
|
|
7663
|
-
expiredAt:
|
|
7664
|
+
expiredAt: Up(s.expiresAt)
|
|
7664
7665
|
});
|
|
7665
7666
|
if (c === "pending") throw o(s, !1);
|
|
7666
|
-
if (c === "rejected") throw await
|
|
7667
|
+
if (c === "rejected") throw await Jp(t, s, {}), new $e({
|
|
7667
7668
|
approvalId: String(s.id),
|
|
7668
7669
|
decidedBy: s.decidedBy ?? null,
|
|
7669
7670
|
note: s.note ?? null
|
|
@@ -7674,18 +7675,18 @@ behind quietly.` + n;
|
|
|
7674
7675
|
consumedAt: new Date(n()),
|
|
7675
7676
|
intentKey: `${i}#${String(s.id)}`
|
|
7676
7677
|
}, { where: C(O("id", String(s.id)), O("status", "approved")) }) === 1) return;
|
|
7677
|
-
throw s = await
|
|
7678
|
+
throw s = await Kp(t, i), s === null ? o(await a(e, i, r), !0) : o(s, !1);
|
|
7678
7679
|
}
|
|
7679
|
-
throw await
|
|
7680
|
+
throw await Jp(t, s, {}), o(await a(e, i, r), !0);
|
|
7680
7681
|
} };
|
|
7681
|
-
},
|
|
7682
|
-
|
|
7683
|
-
},
|
|
7684
|
-
|
|
7685
|
-
},
|
|
7682
|
+
}, Zp, Qp = (e) => {
|
|
7683
|
+
Zp = e;
|
|
7684
|
+
}, $p = () => Zp, em = () => {
|
|
7685
|
+
Zp = void 0;
|
|
7686
|
+
}, tm = async (e) => {
|
|
7686
7687
|
if (e.policy === void 0) return;
|
|
7687
|
-
let t =
|
|
7688
|
-
if (t === void 0) throw new
|
|
7688
|
+
let t = $p();
|
|
7689
|
+
if (t === void 0) throw new nt({
|
|
7689
7690
|
procedure: e.procedure,
|
|
7690
7691
|
message: `${e.procedure} declares \`requiresApproval\` and no approvals gate is installed on this boot path, so the framework cannot record the intent or verify a decision. Refusing the call rather than running it unapproved.`
|
|
7691
7692
|
});
|
|
@@ -7697,30 +7698,30 @@ behind quietly.` + n;
|
|
|
7697
7698
|
input: e.input,
|
|
7698
7699
|
...e.traceId === void 0 ? {} : { traceId: e.traceId }
|
|
7699
7700
|
});
|
|
7700
|
-
},
|
|
7701
|
-
let n = t.now ?? Date.now, r = await
|
|
7702
|
-
if (r === null) throw new
|
|
7701
|
+
}, nm = async (e, t) => {
|
|
7702
|
+
let n = t.now ?? Date.now, r = await qp(e, t.approvalId);
|
|
7703
|
+
if (r === null) throw new Ze({ approvalId: t.approvalId });
|
|
7703
7704
|
let i = String(r.status ?? "pending");
|
|
7704
|
-
if (i !== "pending") throw new
|
|
7705
|
+
if (i !== "pending") throw new Qe({
|
|
7705
7706
|
approvalId: t.approvalId,
|
|
7706
7707
|
status: i
|
|
7707
7708
|
});
|
|
7708
|
-
if (n() >
|
|
7709
|
+
if (n() > Wp(r.expiresAt)) throw await Jp(e, r, { status: "expired" }), new Ye({
|
|
7709
7710
|
approvalId: t.approvalId,
|
|
7710
|
-
expiredAt:
|
|
7711
|
+
expiredAt: Up(r.expiresAt)
|
|
7711
7712
|
});
|
|
7712
7713
|
let a = t.approver?.id ?? null;
|
|
7713
|
-
if (a === null) throw new
|
|
7714
|
+
if (a === null) throw new Xe({
|
|
7714
7715
|
approvalId: t.approvalId,
|
|
7715
7716
|
required: null,
|
|
7716
7717
|
message: "an approval decision needs an identified subject — an anonymous caller cannot be the second human"
|
|
7717
7718
|
});
|
|
7718
|
-
if (a === (r.requestedBy ?? null)) throw new
|
|
7719
|
+
if (a === (r.requestedBy ?? null)) throw new tt({
|
|
7719
7720
|
approvalId: t.approvalId,
|
|
7720
7721
|
subjectId: a
|
|
7721
7722
|
});
|
|
7722
|
-
let s =
|
|
7723
|
-
if (c) throw new
|
|
7723
|
+
let s = zp(Gp(r.approverGuards)), c = await o.runPromise(xt(t.approver, s, JSON.parse(String(r.payload ?? "null"))));
|
|
7724
|
+
if (c) throw new Xe({
|
|
7724
7725
|
approvalId: t.approvalId,
|
|
7725
7726
|
required: c.required ?? null,
|
|
7726
7727
|
message: c.message
|
|
@@ -7732,8 +7733,8 @@ behind quietly.` + n;
|
|
|
7732
7733
|
decidedAt: new Date(n()),
|
|
7733
7734
|
note: t.note ?? null
|
|
7734
7735
|
}, { where: C(O("id", t.approvalId), O("status", "pending")) }) !== 1) {
|
|
7735
|
-
let n = await
|
|
7736
|
-
throw new
|
|
7736
|
+
let n = await qp(e, t.approvalId);
|
|
7737
|
+
throw new Qe({
|
|
7737
7738
|
approvalId: t.approvalId,
|
|
7738
7739
|
status: String(n?.status ?? "unknown")
|
|
7739
7740
|
});
|
|
@@ -7742,62 +7743,62 @@ behind quietly.` + n;
|
|
|
7742
7743
|
approvalId: t.approvalId,
|
|
7743
7744
|
status: l
|
|
7744
7745
|
};
|
|
7745
|
-
},
|
|
7746
|
+
}, rm = async (e, t, n) => {
|
|
7746
7747
|
let r = t?.id ?? null;
|
|
7747
7748
|
if (r === null) return [];
|
|
7748
7749
|
let i = n?.now ?? Date.now, a = await e.query({
|
|
7749
|
-
table:
|
|
7750
|
-
predicate:
|
|
7750
|
+
table: Pp,
|
|
7751
|
+
predicate: le("status", ["pending", "approved"]),
|
|
7751
7752
|
order: []
|
|
7752
7753
|
}), s = [];
|
|
7753
7754
|
for (let e of a) {
|
|
7754
|
-
if (i() >
|
|
7755
|
-
let n =
|
|
7756
|
-
a || await o.runPromise(
|
|
7755
|
+
if (i() > Wp(e.expiresAt)) continue;
|
|
7756
|
+
let n = Gp(e.approverGuards), a = (e.requestedBy ?? null) === r, c = a ? "requested" : null;
|
|
7757
|
+
a || await o.runPromise(xt(t, zp(n), JSON.parse(String(e.payload ?? "null")))) === null && String(e.status) === "pending" && (c = "to-decide"), c !== null && s.push({
|
|
7757
7758
|
id: String(e.id),
|
|
7758
7759
|
procedure: String(e.procedure),
|
|
7759
7760
|
kind: String(e.kind) === "action" ? "action" : "mutation",
|
|
7760
7761
|
requestedBy: e.requestedBy ?? null,
|
|
7761
7762
|
status: String(e.status ?? "pending"),
|
|
7762
7763
|
reason: e.reason ?? null,
|
|
7763
|
-
requiredScopes:
|
|
7764
|
-
requestedAt:
|
|
7765
|
-
expiresAt:
|
|
7764
|
+
requiredScopes: Bp(n),
|
|
7765
|
+
requestedAt: Up(e.requestedAt),
|
|
7766
|
+
expiresAt: Up(e.expiresAt),
|
|
7766
7767
|
decidedBy: e.decidedBy ?? null,
|
|
7767
|
-
decidedAt: e.decidedAt == null ? null :
|
|
7768
|
+
decidedAt: e.decidedAt == null ? null : Up(e.decidedAt),
|
|
7768
7769
|
note: e.note ?? null,
|
|
7769
7770
|
relation: c
|
|
7770
7771
|
});
|
|
7771
7772
|
}
|
|
7772
7773
|
return s.sort((e, t) => t.requestedAt.localeCompare(e.requestedAt)).slice(0, n?.limit ?? 50);
|
|
7773
|
-
},
|
|
7774
|
+
}, im = () => He(), am = (e) => e.request?.subject ?? null, om = async (e, t) => rm(t.store, am(t), { limit: e.limit ?? 50 }), sm = async (e, t) => nm(t.store, {
|
|
7774
7775
|
approvalId: e.approvalId,
|
|
7775
7776
|
decision: e.decision,
|
|
7776
|
-
approver:
|
|
7777
|
+
approver: am(t),
|
|
7777
7778
|
...e.note === void 0 ? {} : { note: e.note }
|
|
7778
|
-
}),
|
|
7779
|
+
}), cm = (e = process.env) => {
|
|
7779
7780
|
let t = (e.VOLTRO_TIMELINE ?? "").toLowerCase();
|
|
7780
7781
|
return t === "off" || t === "0" || t === "false" ? "off" : t === "all" ? "all" : t === "interesting" || t === "on" || t === "1" || t === "true" ? "interesting" : e.NODE_ENV === "production" ? "off" : "interesting";
|
|
7781
|
-
},
|
|
7782
|
+
}, lm = /pass(word)?|secret|token|api[_-]?key|authorization|cookie|ssn|credit[_-]?card|card[_-]?number|cvv|encrypted/i, um = "«redacted»", dm = (e) => {
|
|
7782
7783
|
if (e == null) return null;
|
|
7783
7784
|
let t = {};
|
|
7784
|
-
for (let [n, r] of Object.entries(e)) t[n] =
|
|
7785
|
+
for (let [n, r] of Object.entries(e)) t[n] = lm.test(n) ? um : r;
|
|
7785
7786
|
return t;
|
|
7786
|
-
},
|
|
7787
|
+
}, fm = (e) => {
|
|
7787
7788
|
let t = e?.id;
|
|
7788
7789
|
return typeof t == "string" ? t : void 0;
|
|
7789
|
-
},
|
|
7790
|
+
}, pm = (e, t) => {
|
|
7790
7791
|
if (t.op === "insert") {
|
|
7791
|
-
let n =
|
|
7792
|
+
let n = fm(t.new);
|
|
7792
7793
|
return n === void 0 ? e : e.filter((e) => e.id !== n);
|
|
7793
7794
|
}
|
|
7794
7795
|
if (t.op === "update") {
|
|
7795
7796
|
if (t.old == null) return e;
|
|
7796
|
-
let n =
|
|
7797
|
+
let n = fm(t.new) ?? fm(t.old);
|
|
7797
7798
|
return e.map((e) => e.id === n ? t.old : e);
|
|
7798
7799
|
}
|
|
7799
7800
|
return t.old == null ? e : [...e, t.old];
|
|
7800
|
-
},
|
|
7801
|
+
}, mm = class {
|
|
7801
7802
|
mode;
|
|
7802
7803
|
capacity;
|
|
7803
7804
|
now;
|
|
@@ -7817,8 +7818,8 @@ behind quietly.` + n;
|
|
|
7817
7818
|
ts: this.now(),
|
|
7818
7819
|
table: e.table,
|
|
7819
7820
|
op: e.op,
|
|
7820
|
-
old:
|
|
7821
|
-
new:
|
|
7821
|
+
old: dm(e.old),
|
|
7822
|
+
new: dm(e.new),
|
|
7822
7823
|
tenantId: n
|
|
7823
7824
|
}), this.ring.length > this.capacity && this.ring.shift(), t;
|
|
7824
7825
|
}
|
|
@@ -7831,23 +7832,23 @@ behind quietly.` + n;
|
|
|
7831
7832
|
}
|
|
7832
7833
|
replay(e, t, n) {
|
|
7833
7834
|
let r = this.ring.filter((n) => n.table === e && n.seq > t).sort((e, t) => t.seq - e.seq), i = n;
|
|
7834
|
-
for (let e of r) i =
|
|
7835
|
+
for (let e of r) i = pm(i, e);
|
|
7835
7836
|
return i;
|
|
7836
7837
|
}
|
|
7837
|
-
},
|
|
7838
|
-
|
|
7839
|
-
},
|
|
7840
|
-
let t =
|
|
7838
|
+
}, hm, gm = () => (hm === void 0 && (hm = new mm(cm())), hm), _m = (e) => {
|
|
7839
|
+
hm = e;
|
|
7840
|
+
}, vm = (e) => {
|
|
7841
|
+
let t = gm();
|
|
7841
7842
|
if (t.enabled) try {
|
|
7842
7843
|
t.record(e);
|
|
7843
7844
|
} catch {}
|
|
7844
|
-
},
|
|
7845
|
+
}, ym = /* @__PURE__ */ new Set([
|
|
7845
7846
|
"count",
|
|
7846
7847
|
"sum",
|
|
7847
7848
|
"avg",
|
|
7848
7849
|
"min",
|
|
7849
7850
|
"max"
|
|
7850
|
-
]),
|
|
7851
|
+
]), bm = (e) => {
|
|
7851
7852
|
if (e.joins !== void 0 && e.joins.length > 0) return {
|
|
7852
7853
|
maintainable: !1,
|
|
7853
7854
|
reason: "joins are not maintainable in v1"
|
|
@@ -7869,7 +7870,7 @@ behind quietly.` + n;
|
|
|
7869
7870
|
reason: "v1 maintains exactly one aggregation"
|
|
7870
7871
|
};
|
|
7871
7872
|
let t = e.aggregations[0];
|
|
7872
|
-
return
|
|
7873
|
+
return ym.has(t.op) ? t.op !== "count" && (t.column === void 0 || t.column.length === 0) ? {
|
|
7873
7874
|
maintainable: !1,
|
|
7874
7875
|
reason: `op '${t.op}' requires a column`
|
|
7875
7876
|
} : {
|
|
@@ -7883,7 +7884,7 @@ behind quietly.` + n;
|
|
|
7883
7884
|
maintainable: !1,
|
|
7884
7885
|
reason: `op '${t.op}' is not maintainable`
|
|
7885
7886
|
};
|
|
7886
|
-
},
|
|
7887
|
+
}, xm = "\0", Sm = (e, t) => t === void 0 || t.length === 0 ? "" : t.map((t) => JSON.stringify(e[t] ?? null)).join(xm), Cm = (e, t) => t === void 0 ? 0 : Number(e[t] ?? 0), wm = (e, t) => {
|
|
7887
7888
|
switch (e.op) {
|
|
7888
7889
|
case "count": return t.count;
|
|
7889
7890
|
case "sum": return t.sum ?? 0;
|
|
@@ -7891,10 +7892,10 @@ behind quietly.` + n;
|
|
|
7891
7892
|
case "min":
|
|
7892
7893
|
case "max": return t.count > 0 ? t.extreme ?? null : null;
|
|
7893
7894
|
}
|
|
7894
|
-
},
|
|
7895
|
+
}, Tm = (e, t) => {
|
|
7895
7896
|
let n = /* @__PURE__ */ new Map();
|
|
7896
7897
|
for (let r of t) {
|
|
7897
|
-
let t =
|
|
7898
|
+
let t = Sm(r, e.groupBy), i = n.get(t), a = Cm(r, e.column);
|
|
7898
7899
|
if (i === void 0) n.set(t, {
|
|
7899
7900
|
count: 1,
|
|
7900
7901
|
...e.op === "sum" || e.op === "avg" ? { sum: a } : {},
|
|
@@ -7910,19 +7911,19 @@ behind quietly.` + n;
|
|
|
7910
7911
|
}
|
|
7911
7912
|
}
|
|
7912
7913
|
return n;
|
|
7913
|
-
},
|
|
7914
|
+
}, Em = (e, t) => [...t.entries()].map(([t, n]) => ({
|
|
7914
7915
|
groupKey: t,
|
|
7915
|
-
value:
|
|
7916
|
-
})),
|
|
7916
|
+
value: wm(e, n)
|
|
7917
|
+
})), Dm = (e, t, n) => {
|
|
7917
7918
|
let r = new Map(t), i = /* @__PURE__ */ new Set(), a = (t) => {
|
|
7918
|
-
let n =
|
|
7919
|
+
let n = Sm(t, e.groupBy), a = r.get(n);
|
|
7919
7920
|
if (a === void 0) return;
|
|
7920
7921
|
let o = a.count - 1;
|
|
7921
7922
|
if (o <= 0) {
|
|
7922
7923
|
r.delete(n);
|
|
7923
7924
|
return;
|
|
7924
7925
|
}
|
|
7925
|
-
let s =
|
|
7926
|
+
let s = Cm(t, e.column);
|
|
7926
7927
|
e.op === "min" || e.op === "max" ? (a.extreme !== void 0 && s === a.extreme && i.add(n), r.set(n, {
|
|
7927
7928
|
count: o,
|
|
7928
7929
|
...a.extreme === void 0 ? {} : { extreme: a.extreme }
|
|
@@ -7931,7 +7932,7 @@ behind quietly.` + n;
|
|
|
7931
7932
|
...e.op === "sum" || e.op === "avg" ? { sum: (a.sum ?? 0) - s } : {}
|
|
7932
7933
|
});
|
|
7933
7934
|
}, o = (t) => {
|
|
7934
|
-
let n =
|
|
7935
|
+
let n = Sm(t, e.groupBy), i = r.get(n), a = Cm(t, e.column);
|
|
7935
7936
|
if (i === void 0) {
|
|
7936
7937
|
r.set(n, {
|
|
7937
7938
|
count: 1,
|
|
@@ -7951,15 +7952,15 @@ behind quietly.` + n;
|
|
|
7951
7952
|
state: r,
|
|
7952
7953
|
rescanGroups: [...i]
|
|
7953
7954
|
};
|
|
7954
|
-
},
|
|
7955
|
+
}, Om = (e, t, n, r) => {
|
|
7955
7956
|
if (n.length === 0) return t;
|
|
7956
|
-
let i = new Set(n), a =
|
|
7957
|
+
let i = new Set(n), a = Tm(e, r.filter((t) => i.has(Sm(t, e.groupBy)))), o = new Map(t);
|
|
7957
7958
|
for (let e of i) {
|
|
7958
7959
|
let t = a.get(e);
|
|
7959
7960
|
t === void 0 ? o.delete(e) : o.set(e, t);
|
|
7960
7961
|
}
|
|
7961
7962
|
return o;
|
|
7962
|
-
},
|
|
7963
|
+
}, km = class {
|
|
7963
7964
|
shape;
|
|
7964
7965
|
state = /* @__PURE__ */ new Map();
|
|
7965
7966
|
groups = /* @__PURE__ */ new Map();
|
|
@@ -7967,35 +7968,35 @@ behind quietly.` + n;
|
|
|
7967
7968
|
this.shape = e;
|
|
7968
7969
|
}
|
|
7969
7970
|
seed(e) {
|
|
7970
|
-
this.state =
|
|
7971
|
+
this.state = Tm(this.shape, e), this.groups.clear();
|
|
7971
7972
|
for (let t of e) {
|
|
7972
|
-
let e =
|
|
7973
|
+
let e = Sm(t, this.shape.groupBy);
|
|
7973
7974
|
this.groups.has(e) || this.groups.set(e, this.groupValues(t));
|
|
7974
7975
|
}
|
|
7975
7976
|
}
|
|
7976
7977
|
applyChange(e) {
|
|
7977
7978
|
let t = e.new;
|
|
7978
7979
|
if (t) {
|
|
7979
|
-
let e =
|
|
7980
|
+
let e = Sm(t, this.shape.groupBy);
|
|
7980
7981
|
this.groups.has(e) || this.groups.set(e, this.groupValues(t));
|
|
7981
7982
|
}
|
|
7982
|
-
let n =
|
|
7983
|
+
let n = Dm(this.shape, this.state, e);
|
|
7983
7984
|
this.state = n.state;
|
|
7984
7985
|
for (let e of this.groups.keys()) this.state.has(e) || this.groups.delete(e);
|
|
7985
7986
|
return n.rescanGroups;
|
|
7986
7987
|
}
|
|
7987
7988
|
resolveRescan(e, t) {
|
|
7988
7989
|
if (e.length === 0) return;
|
|
7989
|
-
this.state =
|
|
7990
|
+
this.state = Om(this.shape, this.state, e, t);
|
|
7990
7991
|
let n = new Set(e);
|
|
7991
7992
|
for (let e of t) {
|
|
7992
|
-
let t =
|
|
7993
|
+
let t = Sm(e, this.shape.groupBy);
|
|
7993
7994
|
n.has(t) && this.state.has(t) && !this.groups.has(t) && this.groups.set(t, this.groupValues(e));
|
|
7994
7995
|
}
|
|
7995
7996
|
for (let e of n) this.state.has(e) || this.groups.delete(e);
|
|
7996
7997
|
}
|
|
7997
7998
|
materialize() {
|
|
7998
|
-
return
|
|
7999
|
+
return Em(this.shape, this.state).map((e) => ({
|
|
7999
8000
|
groupKey: e.groupKey,
|
|
8000
8001
|
group: this.groups.get(e.groupKey) ?? {},
|
|
8001
8002
|
value: e.value
|
|
@@ -8008,19 +8009,19 @@ behind quietly.` + n;
|
|
|
8008
8009
|
for (let r of t) n[r] = e[r];
|
|
8009
8010
|
return n;
|
|
8010
8011
|
}
|
|
8011
|
-
},
|
|
8012
|
-
id:
|
|
8013
|
-
subjectId:
|
|
8014
|
-
relation:
|
|
8015
|
-
resourceType:
|
|
8016
|
-
resourceId:
|
|
8017
|
-
tenantId:
|
|
8018
|
-
createdAt:
|
|
8012
|
+
}, Am = I("_voltro_rebac_tuples", {
|
|
8013
|
+
id: N({ prefix: "rbct" }),
|
|
8014
|
+
subjectId: L(),
|
|
8015
|
+
relation: L(),
|
|
8016
|
+
resourceType: L(),
|
|
8017
|
+
resourceId: L(),
|
|
8018
|
+
tenantId: L().nullable(),
|
|
8019
|
+
createdAt: R().default("now")
|
|
8019
8020
|
}).index([
|
|
8020
8021
|
"subjectId",
|
|
8021
8022
|
"resourceType",
|
|
8022
8023
|
"resourceId"
|
|
8023
|
-
]),
|
|
8024
|
+
]), jm = async (e, t, n, r) => t === null ? [] : (await e.query({
|
|
8024
8025
|
table: "_voltro_rebac_tuples",
|
|
8025
8026
|
predicate: C(O("subjectId", t), O("resourceType", n), O("resourceId", r)),
|
|
8026
8027
|
order: [],
|
|
@@ -8032,11 +8033,11 @@ behind quietly.` + n;
|
|
|
8032
8033
|
relation: e.relation,
|
|
8033
8034
|
resourceType: e.resourceType,
|
|
8034
8035
|
resourceId: e.resourceId
|
|
8035
|
-
})),
|
|
8036
|
+
})), Mm = (e) => ({
|
|
8036
8037
|
id: e.id,
|
|
8037
8038
|
tenantId: e.tenantId,
|
|
8038
8039
|
...e.scopes === void 0 ? {} : { scopes: e.scopes }
|
|
8039
|
-
}),
|
|
8040
|
+
}), Nm = (e, t) => {
|
|
8040
8041
|
let n = t.getPolicy ?? Gu;
|
|
8041
8042
|
return (r, i) => {
|
|
8042
8043
|
let a = e[i.tag];
|
|
@@ -8049,7 +8050,7 @@ behind quietly.` + n;
|
|
|
8049
8050
|
if (s === void 0) return c("");
|
|
8050
8051
|
let l = a.resourceId(i.input);
|
|
8051
8052
|
if (l === null || l === "") return c("");
|
|
8052
|
-
let u =
|
|
8053
|
+
let u = Mm(i.subject), d = {
|
|
8053
8054
|
type: a.resourceType,
|
|
8054
8055
|
id: l,
|
|
8055
8056
|
tenantId: i.subject.tenantId
|
|
@@ -8059,7 +8060,7 @@ behind quietly.` + n;
|
|
|
8059
8060
|
tuples: e
|
|
8060
8061
|
}) ? r : c(l));
|
|
8061
8062
|
};
|
|
8062
|
-
},
|
|
8063
|
+
}, Pm = async (e, t, n) => t === null ? [] : (await e.query({
|
|
8063
8064
|
table: "_voltro_rebac_tuples",
|
|
8064
8065
|
predicate: C(O("subjectId", t), O("resourceType", n)),
|
|
8065
8066
|
order: [],
|
|
@@ -8071,18 +8072,18 @@ behind quietly.` + n;
|
|
|
8071
8072
|
relation: e.relation,
|
|
8072
8073
|
resourceType: e.resourceType,
|
|
8073
8074
|
resourceId: e.resourceId
|
|
8074
|
-
})),
|
|
8075
|
+
})), Fm = (e) => {
|
|
8075
8076
|
let t = e.getPolicy ?? Gu;
|
|
8076
8077
|
return async (n, r, i, a) => {
|
|
8077
8078
|
let o = t(r);
|
|
8078
8079
|
if (o === void 0) return [];
|
|
8079
|
-
let s =
|
|
8080
|
+
let s = Mm(n);
|
|
8080
8081
|
return $u(s, i, r, a, {
|
|
8081
8082
|
policy: o,
|
|
8082
8083
|
tuples: await e.loadSubjectTuples(s.id, r)
|
|
8083
8084
|
});
|
|
8084
8085
|
};
|
|
8085
|
-
},
|
|
8086
|
+
}, Im = (e) => {
|
|
8086
8087
|
if (typeof e.name != "string" || e.name.length === 0) throw Error("defineReaction: a non-empty `name` is required");
|
|
8087
8088
|
if (e.watch === void 0 || typeof e.watch.table != "string" || e.watch.table.length === 0) throw Error(`reaction '${e.name}': watch.table is required`);
|
|
8088
8089
|
if (e.act === void 0 || e.act.kind !== "agent" && e.act.kind !== "workflow") throw Error(`reaction '${e.name}': act must be { kind: 'agent' | 'workflow', … }`);
|
|
@@ -8090,14 +8091,14 @@ behind quietly.` + n;
|
|
|
8090
8091
|
if (e.guards.rateLimit !== void 0 && (e.guards.rateLimit.limit <= 0 || e.guards.rateLimit.windowMs <= 0)) throw Error(`reaction '${e.name}': guards.rateLimit needs positive limit + windowMs`);
|
|
8091
8092
|
if (e.guards.costBudgetUsd !== void 0 && e.guards.costBudgetUsd < 0) throw Error(`reaction '${e.name}': guards.costBudgetUsd must be >= 0`);
|
|
8092
8093
|
return e;
|
|
8093
|
-
},
|
|
8094
|
+
}, Lm = (e, t) => e === void 0 ? !0 : Array.isArray(e) ? e.includes(t) : e === t, Rm = (e) => e.new?.tenantId ?? e.old?.tenantId ?? null, zm = class {
|
|
8094
8095
|
hits = /* @__PURE__ */ new Map();
|
|
8095
8096
|
allow(e, t, n, r) {
|
|
8096
8097
|
let i = r - n, a = (this.hits.get(e) ?? []).filter((e) => e > i);
|
|
8097
8098
|
return a.length >= t ? (this.hits.set(e, a), !1) : (a.push(r), this.hits.set(e, a), !0);
|
|
8098
8099
|
}
|
|
8099
|
-
},
|
|
8100
|
-
if (t.table !== e.watch.table || !
|
|
8100
|
+
}, Bm = (e, t, n, r, i) => `${e}\u0000${t}\u0000${Math.floor(i / n)}\u0000${r}`, Vm = async (e, t, n) => {
|
|
8101
|
+
if (t.table !== e.watch.table || !Lm(e.watch.on, t.op)) return "skipped-op";
|
|
8101
8102
|
if (e.when !== void 0 && !e.when(t)) return "skipped-when";
|
|
8102
8103
|
let r = `${e.name}:${e.guards.dedupeKey(t)}`;
|
|
8103
8104
|
if (await n.dedupe.has(r)) return "skipped-dedupe";
|
|
@@ -8106,23 +8107,23 @@ behind quietly.` + n;
|
|
|
8106
8107
|
let r = n.now?.() ?? Date.now(), a = i.key === void 0 ? "" : i.key(t);
|
|
8107
8108
|
if (n.claimRateSlot !== void 0) {
|
|
8108
8109
|
let t = !1;
|
|
8109
|
-
for (let o = 0; o < i.limit; o++) if (await n.claimRateSlot(
|
|
8110
|
+
for (let o = 0; o < i.limit; o++) if (await n.claimRateSlot(Bm(e.name, a, i.windowMs, o, r))) {
|
|
8110
8111
|
t = !0;
|
|
8111
8112
|
break;
|
|
8112
8113
|
}
|
|
8113
8114
|
if (!t) return "skipped-ratelimit";
|
|
8114
8115
|
} else if (n.rateLimiter !== void 0 && !n.rateLimiter.allow(`${e.name} ${a}`, i.limit, i.windowMs, r)) return "skipped-ratelimit";
|
|
8115
8116
|
}
|
|
8116
|
-
let a =
|
|
8117
|
+
let a = Rm(t);
|
|
8117
8118
|
return e.guards.costBudgetUsd !== void 0 && n.checkBudget !== void 0 && !await n.checkBudget(a, e.guards.costBudgetUsd) ? "skipped-budget" : (await n.runAct(e.act, t, {
|
|
8118
8119
|
id: a,
|
|
8119
8120
|
via: "agent"
|
|
8120
8121
|
}), await n.dedupe.add(r), "acted");
|
|
8121
|
-
},
|
|
8122
|
+
}, Hm = /* @__PURE__ */ new Set([
|
|
8122
8123
|
"info",
|
|
8123
8124
|
"warn",
|
|
8124
8125
|
"critical"
|
|
8125
|
-
]), Q = (e, t) => /* @__PURE__ */ Error(`defineExpectation(${JSON.stringify(e)}): ${t}`),
|
|
8126
|
+
]), Q = (e, t) => /* @__PURE__ */ Error(`defineExpectation(${JSON.stringify(e)}): ${t}`), Um = (e) => {
|
|
8126
8127
|
let t = e.name;
|
|
8127
8128
|
if (typeof t != "string" || t.length === 0) throw Error("defineExpectation: a non-empty `name` is required");
|
|
8128
8129
|
if (e.on === void 0 || typeof e.on.table != "string" || e.on.table.length === 0) throw Q(t, "on.table is required — the table whose writes drive the expectation");
|
|
@@ -8151,7 +8152,7 @@ behind quietly.` + n;
|
|
|
8151
8152
|
default: throw Q(t, `unknown invariant kind ${JSON.stringify(n.kind)}`);
|
|
8152
8153
|
}
|
|
8153
8154
|
let r = e.severity ?? "warn";
|
|
8154
|
-
if (!
|
|
8155
|
+
if (!Hm.has(r)) throw Q(t, `severity must be one of info | warn | critical (got ${JSON.stringify(r)})`);
|
|
8155
8156
|
return {
|
|
8156
8157
|
_voltroExpectation: !0,
|
|
8157
8158
|
name: t,
|
|
@@ -8163,9 +8164,9 @@ behind quietly.` + n;
|
|
|
8163
8164
|
severity: r,
|
|
8164
8165
|
...e.description === void 0 ? {} : { description: e.description }
|
|
8165
8166
|
};
|
|
8166
|
-
},
|
|
8167
|
-
return (yield*
|
|
8168
|
-
}),
|
|
8167
|
+
}, Wm = (e) => typeof e == "object" && !!e && e._voltroExpectation === !0, Gm = class extends n.Tag("@voltro/ExpectationRegistry")() {}, Km = (e) => o.gen(function* () {
|
|
8168
|
+
return (yield* Gm).get(e.name);
|
|
8169
|
+
}), qm = (e) => {
|
|
8169
8170
|
if (e instanceof Date) return e.getTime();
|
|
8170
8171
|
if (typeof e == "number" && Number.isFinite(e)) return e;
|
|
8171
8172
|
if (typeof e == "string" && e.length > 0) {
|
|
@@ -8173,20 +8174,20 @@ behind quietly.` + n;
|
|
|
8173
8174
|
return Number.isNaN(t) ? null : t;
|
|
8174
8175
|
}
|
|
8175
8176
|
return null;
|
|
8176
|
-
},
|
|
8177
|
+
}, Jm = class {
|
|
8177
8178
|
maxAgeMs;
|
|
8178
8179
|
timeDependent = !0;
|
|
8179
8180
|
maintainer;
|
|
8180
8181
|
column;
|
|
8181
8182
|
constructor(e, t) {
|
|
8182
|
-
this.maxAgeMs = t, this.column = e, this.maintainer = new
|
|
8183
|
+
this.maxAgeMs = t, this.column = e, this.maintainer = new km({
|
|
8183
8184
|
op: "max",
|
|
8184
8185
|
column: e
|
|
8185
8186
|
});
|
|
8186
8187
|
}
|
|
8187
8188
|
project(e) {
|
|
8188
8189
|
if (e == null) return null;
|
|
8189
|
-
let t =
|
|
8190
|
+
let t = qm(e[this.column]);
|
|
8190
8191
|
return t === null ? null : {
|
|
8191
8192
|
...e,
|
|
8192
8193
|
[this.column]: t
|
|
@@ -8228,7 +8229,7 @@ behind quietly.` + n;
|
|
|
8228
8229
|
violated: n > this.maxAgeMs
|
|
8229
8230
|
};
|
|
8230
8231
|
}
|
|
8231
|
-
},
|
|
8232
|
+
}, Ym = class {
|
|
8232
8233
|
matches;
|
|
8233
8234
|
reduce;
|
|
8234
8235
|
timeDependent = !1;
|
|
@@ -8253,16 +8254,16 @@ behind quietly.` + n;
|
|
|
8253
8254
|
read() {
|
|
8254
8255
|
return this.reduce(this.total, this.matching);
|
|
8255
8256
|
}
|
|
8256
|
-
},
|
|
8257
|
-
if (
|
|
8257
|
+
}, Xm = (e) => e == null, Zm = (e, t, n) => {
|
|
8258
|
+
if (Xm(e)) return !1;
|
|
8258
8259
|
let r = Number(e);
|
|
8259
8260
|
return Number.isNaN(r) ? !1 : t !== void 0 && r < t || n !== void 0 && r > n;
|
|
8260
|
-
},
|
|
8261
|
+
}, Qm = (e) => {
|
|
8261
8262
|
switch (e.kind) {
|
|
8262
|
-
case "freshness": return new
|
|
8263
|
+
case "freshness": return new Jm(e.column, e.maxAgeMs);
|
|
8263
8264
|
case "nullRate": {
|
|
8264
8265
|
let t = e.column, n = e.maxRate;
|
|
8265
|
-
return new
|
|
8266
|
+
return new Ym((e) => Xm(e[t]), (e, t) => {
|
|
8266
8267
|
let r = e > 0 ? t / e : 0;
|
|
8267
8268
|
return {
|
|
8268
8269
|
metric: r,
|
|
@@ -8273,7 +8274,7 @@ behind quietly.` + n;
|
|
|
8273
8274
|
}
|
|
8274
8275
|
case "rowCount": {
|
|
8275
8276
|
let { min: t, max: n } = e;
|
|
8276
|
-
return new
|
|
8277
|
+
return new Ym(() => !1, (e) => ({
|
|
8277
8278
|
metric: e,
|
|
8278
8279
|
threshold: n ?? t ?? null,
|
|
8279
8280
|
violated: t !== void 0 && e < t || n !== void 0 && e > n
|
|
@@ -8281,7 +8282,7 @@ behind quietly.` + n;
|
|
|
8281
8282
|
}
|
|
8282
8283
|
case "valueBounds": {
|
|
8283
8284
|
let { column: t, min: n, max: r, maxViolationRate: i } = e;
|
|
8284
|
-
return new
|
|
8285
|
+
return new Ym((e) => Zm(e[t], n, r), (e, t) => {
|
|
8285
8286
|
if (i !== void 0) {
|
|
8286
8287
|
let n = e > 0 ? t / e : 0;
|
|
8287
8288
|
return {
|
|
@@ -8298,13 +8299,13 @@ behind quietly.` + n;
|
|
|
8298
8299
|
});
|
|
8299
8300
|
}
|
|
8300
8301
|
}
|
|
8301
|
-
},
|
|
8302
|
+
}, $m = (e) => ({
|
|
8302
8303
|
table: e.table,
|
|
8303
8304
|
op: e.op,
|
|
8304
8305
|
traceId: e.traceId ?? null,
|
|
8305
8306
|
subjectId: e.subjectId ?? null,
|
|
8306
8307
|
procedure: e.procedure ?? null
|
|
8307
|
-
}),
|
|
8308
|
+
}), eh = (e, t) => !t || e.metric === null ? "unknown" : e.violated ? "violated" : "holding", th = class {
|
|
8308
8309
|
def;
|
|
8309
8310
|
deps;
|
|
8310
8311
|
engine;
|
|
@@ -8317,7 +8318,7 @@ behind quietly.` + n;
|
|
|
8317
8318
|
lastEvaluatedAt = null;
|
|
8318
8319
|
lastCause = null;
|
|
8319
8320
|
constructor(e, t) {
|
|
8320
|
-
this.def = e, this.deps = t, this.engine =
|
|
8321
|
+
this.def = e, this.deps = t, this.engine = Qm(e.invariant), this.now = t.now ?? Date.now, this.threshold = null;
|
|
8321
8322
|
}
|
|
8322
8323
|
get timeDependent() {
|
|
8323
8324
|
return this.engine.timeDependent;
|
|
@@ -8346,13 +8347,13 @@ behind quietly.` + n;
|
|
|
8346
8347
|
let e = (await this.deps.queryBase()).filter((e) => this.inScope(e));
|
|
8347
8348
|
this.engine.resolveRescan(i, e);
|
|
8348
8349
|
}
|
|
8349
|
-
return this.commitReading(this.engine.read(this.now()), !0,
|
|
8350
|
+
return this.commitReading(this.engine.read(this.now()), !0, $m(e));
|
|
8350
8351
|
}
|
|
8351
8352
|
tick() {
|
|
8352
8353
|
return this.seeded ? this.commitReading(this.engine.read(this.now()), !0, null) : null;
|
|
8353
8354
|
}
|
|
8354
8355
|
commitReading(e, t, n) {
|
|
8355
|
-
let r = this.status, i =
|
|
8356
|
+
let r = this.status, i = eh(e, this.seeded);
|
|
8356
8357
|
if (this.metric = e.metric, this.threshold = e.threshold, this.lastEvaluatedAt = new Date(this.now()), i !== r) {
|
|
8357
8358
|
if (this.status = i, this.since = this.lastEvaluatedAt, i === "violated" && (this.lastCause = n), t && i === "violated" && r !== "violated") return {
|
|
8358
8359
|
kind: "violated",
|
|
@@ -8382,7 +8383,7 @@ behind quietly.` + n;
|
|
|
8382
8383
|
...this.def.description === void 0 ? {} : { description: this.def.description }
|
|
8383
8384
|
};
|
|
8384
8385
|
}
|
|
8385
|
-
},
|
|
8386
|
+
}, nh = (e) => {
|
|
8386
8387
|
let t = e.now ?? Date.now, n = e.log, r = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Map(), a = (e) => {
|
|
8387
8388
|
for (let t of r) try {
|
|
8388
8389
|
t(e);
|
|
@@ -8399,7 +8400,7 @@ behind quietly.` + n;
|
|
|
8399
8400
|
}), s = /* @__PURE__ */ new Map(), c = !1;
|
|
8400
8401
|
for (let { definition: r } of e.discovered) {
|
|
8401
8402
|
if (i.has(r.name)) throw Error(`expectation: duplicate name '${r.name}' — names must be unique across all expectations`);
|
|
8402
|
-
let e = new
|
|
8403
|
+
let e = new th(r, {
|
|
8403
8404
|
queryBase: o(r.on.table),
|
|
8404
8405
|
now: t,
|
|
8405
8406
|
...n === void 0 ? {} : { log: n }
|
|
@@ -8417,7 +8418,7 @@ behind quietly.` + n;
|
|
|
8417
8418
|
})();
|
|
8418
8419
|
let l = e.store.onChange((e) => {
|
|
8419
8420
|
let t = s.get(e.table);
|
|
8420
|
-
t
|
|
8421
|
+
t !== void 0 && t.length !== 0 && (async () => {
|
|
8421
8422
|
for (let r of t) try {
|
|
8422
8423
|
let t = await r.applyChange(e);
|
|
8423
8424
|
t !== null && a(t);
|
|
@@ -8439,7 +8440,7 @@ behind quietly.` + n;
|
|
|
8439
8440
|
await e.seed();
|
|
8440
8441
|
} catch {}
|
|
8441
8442
|
})();
|
|
8442
|
-
}, e.reconcileIntervalMs ??
|
|
8443
|
+
}, e.reconcileIntervalMs ?? 3e5);
|
|
8443
8444
|
return f.unref?.(), {
|
|
8444
8445
|
registry: {
|
|
8445
8446
|
snapshot: () => [...i.values()].map((e) => e.state()),
|
|
@@ -8453,30 +8454,30 @@ behind quietly.` + n;
|
|
|
8453
8454
|
registered: [...i.keys()],
|
|
8454
8455
|
runTick: u
|
|
8455
8456
|
};
|
|
8456
|
-
},
|
|
8457
|
+
}, rh = /* @__PURE__ */ new Set([
|
|
8457
8458
|
"info",
|
|
8458
8459
|
"warn",
|
|
8459
8460
|
"critical"
|
|
8460
|
-
]),
|
|
8461
|
+
]), ih = /* @__PURE__ */ new Set(["observe", "suspend"]), ah = (e, t) => /* @__PURE__ */ Error(`defineCostBudget(${JSON.stringify(e)}): ${t}`), oh = (e) => {
|
|
8461
8462
|
let t = /^(\d+(?:\.\d+)?)\s*(ms|s|m|h|d)$/.exec(e.trim());
|
|
8462
8463
|
if (t === null) return null;
|
|
8463
8464
|
let n = Number(t[1]);
|
|
8464
8465
|
if (!(Number.isFinite(n) && n > 0)) return null;
|
|
8465
8466
|
let r = t[2];
|
|
8466
8467
|
return n * (r === "ms" ? 1 : r === "s" ? 1e3 : r === "m" ? 6e4 : r === "h" ? 36e5 : 864e5);
|
|
8467
|
-
},
|
|
8468
|
+
}, sh = (e) => {
|
|
8468
8469
|
let t = e.name;
|
|
8469
8470
|
if (typeof t != "string" || t.length === 0) throw Error("defineCostBudget: a non-empty `name` is required");
|
|
8470
|
-
if (!(typeof e.limit == "number" && Number.isFinite(e.limit) && e.limit > 0)) throw
|
|
8471
|
-
if (e.unit !== void 0 && (typeof e.unit != "string" || e.unit.length === 0)) throw
|
|
8471
|
+
if (!(typeof e.limit == "number" && Number.isFinite(e.limit) && e.limit > 0)) throw ah(t, "a positive, finite `limit` is required");
|
|
8472
|
+
if (e.unit !== void 0 && (typeof e.unit != "string" || e.unit.length === 0)) throw ah(t, "unit, when present, must be a non-empty string");
|
|
8472
8473
|
let n = e.warnAt ?? .8;
|
|
8473
|
-
if (!(typeof n == "number" && n >= 0 && n <= 1)) throw
|
|
8474
|
+
if (!(typeof n == "number" && n >= 0 && n <= 1)) throw ah(t, "warnAt, when present, must be in [0, 1]");
|
|
8474
8475
|
let r = null;
|
|
8475
|
-
if (e.window !== void 0 && (r =
|
|
8476
|
+
if (e.window !== void 0 && (r = oh(e.window), r === null)) throw ah(t, `window must be an interval like '1h' / '24h' (got ${JSON.stringify(e.window)})`);
|
|
8476
8477
|
let i = e.severity ?? "warn";
|
|
8477
|
-
if (!
|
|
8478
|
+
if (!rh.has(i)) throw ah(t, `severity must be one of info | warn | critical (got ${JSON.stringify(i)})`);
|
|
8478
8479
|
let a = e.onExceeded ?? "observe";
|
|
8479
|
-
if (!
|
|
8480
|
+
if (!ih.has(a)) throw ah(t, `onExceeded must be observe | suspend (got ${JSON.stringify(e.onExceeded)})`);
|
|
8480
8481
|
return {
|
|
8481
8482
|
_voltroCostBudget: !0,
|
|
8482
8483
|
name: t,
|
|
@@ -8488,9 +8489,9 @@ behind quietly.` + n;
|
|
|
8488
8489
|
onExceeded: a,
|
|
8489
8490
|
...e.description === void 0 ? {} : { description: e.description }
|
|
8490
8491
|
};
|
|
8491
|
-
},
|
|
8492
|
-
return (yield*
|
|
8493
|
-
}),
|
|
8492
|
+
}, ch = (e) => typeof e == "object" && !!e && e._voltroCostBudget === !0, lh = class extends n.Tag("@voltro/CostRegistry")() {}, uh = (e, t) => o.gen(function* () {
|
|
8493
|
+
return (yield* lh).budget(e.name, t);
|
|
8494
|
+
}), dh = class {
|
|
8494
8495
|
total = 0;
|
|
8495
8496
|
byUnit = /* @__PURE__ */ new Map();
|
|
8496
8497
|
bySubscription = /* @__PURE__ */ new Map();
|
|
@@ -8509,11 +8510,11 @@ behind quietly.` + n;
|
|
|
8509
8510
|
lastUpdatedAt: this.lastUpdatedAt
|
|
8510
8511
|
};
|
|
8511
8512
|
}
|
|
8512
|
-
},
|
|
8513
|
+
}, fh = {
|
|
8513
8514
|
ok: 0,
|
|
8514
8515
|
warn: 1,
|
|
8515
8516
|
exceeded: 2
|
|
8516
|
-
},
|
|
8517
|
+
}, ph = class {
|
|
8517
8518
|
def;
|
|
8518
8519
|
tenantId;
|
|
8519
8520
|
spent = 0;
|
|
@@ -8539,7 +8540,7 @@ behind quietly.` + n;
|
|
|
8539
8540
|
}
|
|
8540
8541
|
settle(e, t, n) {
|
|
8541
8542
|
let r = this.status;
|
|
8542
|
-
return e === r ? null : (this.status = e, this.since = t,
|
|
8543
|
+
return e === r ? null : (this.status = e, this.since = t, fh[e] > fh[r] ? (this.lastCause = n, {
|
|
8543
8544
|
kind: e === "exceeded" ? "exceeded" : "warn",
|
|
8544
8545
|
state: this.state(),
|
|
8545
8546
|
cause: n
|
|
@@ -8552,7 +8553,7 @@ behind quietly.` + n;
|
|
|
8552
8553
|
apply(e, t, n) {
|
|
8553
8554
|
let r = [], i = this.rollWindow(n);
|
|
8554
8555
|
i !== null && r.push(i), this.spent += t, this.lastUpdatedAt = e.at ?? n;
|
|
8555
|
-
let a = this.settle(this.statusOf(this.spent), n,
|
|
8556
|
+
let a = this.settle(this.statusOf(this.spent), n, mh(e));
|
|
8556
8557
|
return a !== null && r.push(a), r;
|
|
8557
8558
|
}
|
|
8558
8559
|
tick(e) {
|
|
@@ -8579,12 +8580,12 @@ behind quietly.` + n;
|
|
|
8579
8580
|
...this.def.description === void 0 ? {} : { description: this.def.description }
|
|
8580
8581
|
};
|
|
8581
8582
|
}
|
|
8582
|
-
},
|
|
8583
|
+
}, mh = (e) => ({
|
|
8583
8584
|
unit: e.unit,
|
|
8584
8585
|
subscriptionId: e.subscriptionId ?? null,
|
|
8585
8586
|
procedure: e.procedure ?? null,
|
|
8586
8587
|
traceId: e.traceId ?? null
|
|
8587
|
-
}),
|
|
8588
|
+
}), hh = (e) => Number.isFinite(e) && e > 0 ? e : 0, gh = class {
|
|
8588
8589
|
now;
|
|
8589
8590
|
attribution = /* @__PURE__ */ new Map();
|
|
8590
8591
|
counters = /* @__PURE__ */ new Map();
|
|
@@ -8604,13 +8605,13 @@ behind quietly.` + n;
|
|
|
8604
8605
|
}
|
|
8605
8606
|
counterFor(e, t) {
|
|
8606
8607
|
let n = this.counters.get(e.name), r = n.get(t);
|
|
8607
|
-
return r === void 0 && (r = new
|
|
8608
|
+
return r === void 0 && (r = new ph(e, t), n.set(t, r)), r;
|
|
8608
8609
|
}
|
|
8609
8610
|
record(e) {
|
|
8610
|
-
let t =
|
|
8611
|
+
let t = hh(e.amount);
|
|
8611
8612
|
if (t === 0) return [];
|
|
8612
8613
|
let n = e.at ?? this.now(), r = this.attribution.get(e.tenantId);
|
|
8613
|
-
r === void 0 && (r = new
|
|
8614
|
+
r === void 0 && (r = new dh(), this.attribution.set(e.tenantId, r)), r.add(e, t, n);
|
|
8614
8615
|
let i = this.unitBudgets.get(e.unit);
|
|
8615
8616
|
if (this.totalBudgets.length === 0 && i === void 0) return [];
|
|
8616
8617
|
let a = [];
|
|
@@ -8663,8 +8664,8 @@ behind quietly.` + n;
|
|
|
8663
8664
|
breaches() {
|
|
8664
8665
|
return this.budgetStates().filter((e) => e.status !== "ok");
|
|
8665
8666
|
}
|
|
8666
|
-
},
|
|
8667
|
-
let t = e.now ?? Date.now, n = e.log, r = /* @__PURE__ */ new Set(), i = e.discovered.map((e) => e.definition), a = new
|
|
8667
|
+
}, _h = (e) => {
|
|
8668
|
+
let t = e.now ?? Date.now, n = e.log, r = /* @__PURE__ */ new Set(), i = e.discovered.map((e) => e.definition), a = new gh(i, {
|
|
8668
8669
|
now: t,
|
|
8669
8670
|
...n === void 0 ? {} : { log: n }
|
|
8670
8671
|
}), o = i.some((e) => e.windowMs !== null), s = (e) => {
|
|
@@ -8699,12 +8700,12 @@ behind quietly.` + n;
|
|
|
8699
8700
|
registered: i.map((e) => e.name),
|
|
8700
8701
|
runTick: l
|
|
8701
8702
|
};
|
|
8702
|
-
},
|
|
8703
|
+
}, vh = "holdout", $ = (e, t) => /* @__PURE__ */ Error(`defineExperiment(${JSON.stringify(e)}): ${t}`), yh = (e) => {
|
|
8703
8704
|
if (e == null) return null;
|
|
8704
8705
|
if (typeof e == "number") return Number.isFinite(e) ? String(e) : null;
|
|
8705
8706
|
let t = String(e);
|
|
8706
8707
|
return t.length > 0 ? t : null;
|
|
8707
|
-
},
|
|
8708
|
+
}, bh = (e) => {
|
|
8708
8709
|
let t = e.name;
|
|
8709
8710
|
if (typeof t != "string" || t.length === 0) throw Error("defineExperiment: a non-empty `name` is required");
|
|
8710
8711
|
if (e.on === void 0 || typeof e.on.table != "string" || e.on.table.length === 0) throw $(t, "on.table is required — the table whose writes drive the experiment");
|
|
@@ -8712,21 +8713,22 @@ behind quietly.` + n;
|
|
|
8712
8713
|
let n = e.subject !== void 0, r = e.variantFrom !== void 0;
|
|
8713
8714
|
if (n && r) throw $(t, "declare `subject` OR `variantFrom`, not both — they are two answers to \"which arm is this row in?\"");
|
|
8714
8715
|
let i = null, a = null;
|
|
8715
|
-
if (r)
|
|
8716
|
-
if (e.variantFrom
|
|
8717
|
-
|
|
8718
|
-
|
|
8719
|
-
|
|
8720
|
-
|
|
8721
|
-
|
|
8722
|
-
|
|
8723
|
-
|
|
8716
|
+
if (r) {
|
|
8717
|
+
if (typeof e.variantFrom == "string") {
|
|
8718
|
+
if (e.variantFrom.length === 0) throw $(t, "variantFrom, when a column name, must be non-empty");
|
|
8719
|
+
let n = e.variantFrom;
|
|
8720
|
+
a = (e) => yh(e[n]);
|
|
8721
|
+
} else if (typeof e.variantFrom == "function") {
|
|
8722
|
+
let t = e.variantFrom;
|
|
8723
|
+
a = (e) => yh(t(e));
|
|
8724
|
+
} else throw $(t, "variantFrom must be a column name or a (row) => variantName function");
|
|
8725
|
+
} else if (typeof e.subject == "string") {
|
|
8724
8726
|
if (e.subject.length === 0) throw $(t, "subject, when a column name, must be non-empty");
|
|
8725
8727
|
let n = e.subject;
|
|
8726
|
-
i = (e) =>
|
|
8728
|
+
i = (e) => yh(e[n]);
|
|
8727
8729
|
} else if (typeof e.subject == "function") {
|
|
8728
8730
|
let t = e.subject;
|
|
8729
|
-
i = (e) =>
|
|
8731
|
+
i = (e) => yh(t(e));
|
|
8730
8732
|
} else throw $(t, "subject is required — a column name or a (row) => key function (or use `variantFrom` to measure an arm something else assigned)");
|
|
8731
8733
|
if (!Array.isArray(e.variants) || e.variants.length < 2) throw $(t, "at least two variants are required (a control + one treatment)");
|
|
8732
8734
|
let o = /* @__PURE__ */ new Set(), s = [];
|
|
@@ -8743,9 +8745,9 @@ behind quietly.` + n;
|
|
|
8743
8745
|
}
|
|
8744
8746
|
let c = 0;
|
|
8745
8747
|
if (e.holdout !== void 0) {
|
|
8746
|
-
if (a !== null && e.holdout > 0) throw $(t, `holdout is meaningless with \`variantFrom\` — a holdout is carved out AT ASSIGNMENT, and this experiment does not assign. Declare the holdout arm on whatever does (a flag variant named "${
|
|
8748
|
+
if (a !== null && e.holdout > 0) throw $(t, `holdout is meaningless with \`variantFrom\` — a holdout is carved out AT ASSIGNMENT, and this experiment does not assign. Declare the holdout arm on whatever does (a flag variant named "${vh}", say) and list it in \`variants\`.`);
|
|
8747
8749
|
if (!(typeof e.holdout == "number" && e.holdout >= 0 && e.holdout < 1)) throw $(t, "holdout, when present, must be a fraction in [0, 1)");
|
|
8748
|
-
if (c = e.holdout, c > 0 && o.has("holdout")) throw $(t, `a variant may not be named ${JSON.stringify(
|
|
8750
|
+
if (c = e.holdout, c > 0 && o.has("holdout")) throw $(t, `a variant may not be named ${JSON.stringify(vh)} when holdout > 0 (reserved)`);
|
|
8749
8751
|
}
|
|
8750
8752
|
let l = e.metric;
|
|
8751
8753
|
if (l === void 0 || typeof l.kind != "string") throw $(t, "metric is required");
|
|
@@ -8777,30 +8779,30 @@ behind quietly.` + n;
|
|
|
8777
8779
|
baseline: u,
|
|
8778
8780
|
...e.description === void 0 ? {} : { description: e.description }
|
|
8779
8781
|
};
|
|
8780
|
-
},
|
|
8782
|
+
}, xh = (e) => typeof e == "object" && !!e && e._voltroExperiment === !0, Sh = (e) => {
|
|
8781
8783
|
let t = 2166136261;
|
|
8782
8784
|
for (let n = 0; n < e.length; n++) t ^= e.charCodeAt(n), t = Math.imul(t, 16777619);
|
|
8783
8785
|
return (t >>> 0) / 4294967296;
|
|
8784
|
-
},
|
|
8785
|
-
let n =
|
|
8786
|
-
if (e.holdout > 0 && n < e.holdout) return
|
|
8786
|
+
}, Ch = (e, t) => {
|
|
8787
|
+
let n = Sh(`${e.name}\u0000${t}`);
|
|
8788
|
+
if (e.holdout > 0 && n < e.holdout) return vh;
|
|
8787
8789
|
let r = e.holdout > 0 ? (n - e.holdout) / (1 - e.holdout) : n, i = e.variants.reduce((e, t) => e + t.weight, 0), a = 0;
|
|
8788
8790
|
for (let t of e.variants) if (a += t.weight / i, r < a) return t.name;
|
|
8789
8791
|
return e.variants[e.variants.length - 1].name;
|
|
8790
|
-
},
|
|
8791
|
-
return (yield*
|
|
8792
|
-
}),
|
|
8792
|
+
}, wh = (e) => e.holdout > 0 ? [...e.variants.map((e) => e.name), vh] : e.variants.map((e) => e.name), Th = class extends n.Tag("@voltro/ExperimentRegistry")() {}, Eh = (e) => o.gen(function* () {
|
|
8793
|
+
return (yield* Th).get(e.name);
|
|
8794
|
+
}), Dh = "__voltro_variant", Oh = "__voltro_metric", kh = class {
|
|
8793
8795
|
project;
|
|
8794
8796
|
maintainer;
|
|
8795
8797
|
constructor(e, t) {
|
|
8796
|
-
this.project = t, this.maintainer = new
|
|
8798
|
+
this.project = t, this.maintainer = new km(e);
|
|
8797
8799
|
}
|
|
8798
8800
|
seed(e) {
|
|
8799
8801
|
this.maintainer.seed(e.map((e) => this.project(e)).filter((e) => e !== null));
|
|
8800
8802
|
}
|
|
8801
8803
|
apply(e) {
|
|
8802
8804
|
let t = e.old ? this.project(e.old) : null, n = e.new ? this.project(e.new) : null;
|
|
8803
|
-
t
|
|
8805
|
+
(t !== null || n !== null) && (t === null ? this.maintainer.applyChange({
|
|
8804
8806
|
op: "insert",
|
|
8805
8807
|
old: null,
|
|
8806
8808
|
new: n
|
|
@@ -8817,56 +8819,56 @@ behind quietly.` + n;
|
|
|
8817
8819
|
byVariant() {
|
|
8818
8820
|
let e = /* @__PURE__ */ new Map();
|
|
8819
8821
|
for (let t of this.maintainer.materialize()) {
|
|
8820
|
-
let n = t.group[
|
|
8822
|
+
let n = t.group[Dh];
|
|
8821
8823
|
typeof n == "string" && e.set(n, t.value);
|
|
8822
8824
|
}
|
|
8823
8825
|
return e;
|
|
8824
8826
|
}
|
|
8825
|
-
},
|
|
8826
|
-
if (
|
|
8827
|
+
}, Ah = (e) => typeof e == "number" && Number.isFinite(e), jh = (e) => {
|
|
8828
|
+
if (Ah(e)) return e;
|
|
8827
8829
|
let t = Number(e);
|
|
8828
8830
|
return Number.isFinite(t) ? t : null;
|
|
8829
|
-
},
|
|
8831
|
+
}, Mh = (e, t) => new kh(e.kind === "count" ? {
|
|
8830
8832
|
op: "count",
|
|
8831
|
-
groupBy: [
|
|
8833
|
+
groupBy: [Dh]
|
|
8832
8834
|
} : {
|
|
8833
8835
|
op: e.kind === "sum" ? "sum" : "avg",
|
|
8834
|
-
column:
|
|
8835
|
-
groupBy: [
|
|
8836
|
+
column: Oh,
|
|
8837
|
+
groupBy: [Dh]
|
|
8836
8838
|
}, (n) => {
|
|
8837
8839
|
let r = t(n);
|
|
8838
8840
|
if (r === null) return null;
|
|
8839
8841
|
switch (e.kind) {
|
|
8840
|
-
case "count": return { [
|
|
8842
|
+
case "count": return { [Dh]: r };
|
|
8841
8843
|
case "sum":
|
|
8842
8844
|
case "avg": {
|
|
8843
|
-
let t =
|
|
8845
|
+
let t = jh(n[e.column]);
|
|
8844
8846
|
return t === null ? null : {
|
|
8845
|
-
[
|
|
8846
|
-
[
|
|
8847
|
+
[Dh]: r,
|
|
8848
|
+
[Oh]: t
|
|
8847
8849
|
};
|
|
8848
8850
|
}
|
|
8849
8851
|
case "conversionRate": {
|
|
8850
8852
|
let t = n[e.column], i = e.equals === void 0 ? !!t : t === e.equals;
|
|
8851
8853
|
return {
|
|
8852
|
-
[
|
|
8853
|
-
[
|
|
8854
|
+
[Dh]: r,
|
|
8855
|
+
[Oh]: +!!i
|
|
8854
8856
|
};
|
|
8855
8857
|
}
|
|
8856
8858
|
}
|
|
8857
|
-
}),
|
|
8859
|
+
}), Nh = (e) => new kh({
|
|
8858
8860
|
op: "count",
|
|
8859
|
-
groupBy: [
|
|
8861
|
+
groupBy: [Dh]
|
|
8860
8862
|
}, (t) => {
|
|
8861
8863
|
let n = e(t);
|
|
8862
|
-
return n === null ? null : { [
|
|
8863
|
-
}),
|
|
8864
|
+
return n === null ? null : { [Dh]: n };
|
|
8865
|
+
}), Ph = (e) => ({
|
|
8864
8866
|
table: e.table,
|
|
8865
8867
|
op: e.op,
|
|
8866
8868
|
traceId: e.traceId ?? null,
|
|
8867
8869
|
subjectId: e.subjectId ?? null,
|
|
8868
8870
|
procedure: e.procedure ?? null
|
|
8869
|
-
}),
|
|
8871
|
+
}), Fh = class {
|
|
8870
8872
|
def;
|
|
8871
8873
|
deps;
|
|
8872
8874
|
exposure;
|
|
@@ -8877,9 +8879,9 @@ behind quietly.` + n;
|
|
|
8877
8879
|
lastUpdatedAt = null;
|
|
8878
8880
|
declaredVariants;
|
|
8879
8881
|
constructor(e, t) {
|
|
8880
|
-
this.def = e, this.deps = t, this.now = t.now ?? Date.now, this.declaredVariants = new Set(
|
|
8882
|
+
this.def = e, this.deps = t, this.now = t.now ?? Date.now, this.declaredVariants = new Set(wh(e));
|
|
8881
8883
|
let n = (e) => this.variantOf(e);
|
|
8882
|
-
this.exposure =
|
|
8884
|
+
this.exposure = Nh(n), this.metricIsCount = e.metric.kind === "count", this.metric = this.metricIsCount ? this.exposure : Mh(e.metric, n);
|
|
8883
8885
|
}
|
|
8884
8886
|
variantOf(e) {
|
|
8885
8887
|
if (e == null) return null;
|
|
@@ -8891,7 +8893,7 @@ behind quietly.` + n;
|
|
|
8891
8893
|
}
|
|
8892
8894
|
if (this.def.subject === null) return null;
|
|
8893
8895
|
let n = this.def.subject(e);
|
|
8894
|
-
return n === null ? null :
|
|
8896
|
+
return n === null ? null : Ch(this.def, n);
|
|
8895
8897
|
}
|
|
8896
8898
|
inScope(e) {
|
|
8897
8899
|
return this.variantOf(e) !== null;
|
|
@@ -8911,12 +8913,12 @@ behind quietly.` + n;
|
|
|
8911
8913
|
};
|
|
8912
8914
|
return this.exposure.apply(r), this.metricIsCount || this.metric.apply(r), this.lastUpdatedAt = new Date(this.now()), {
|
|
8913
8915
|
result: this.result(),
|
|
8914
|
-
cause:
|
|
8916
|
+
cause: Ph(e)
|
|
8915
8917
|
};
|
|
8916
8918
|
}
|
|
8917
8919
|
result() {
|
|
8918
8920
|
let e = this.exposure.byVariant(), t = this.metricIsCount ? e : this.metric.byVariant(), n = this.def.baseline, r = this.metricValueFor(n, t, e), i = 0, a = [];
|
|
8919
|
-
for (let o of
|
|
8921
|
+
for (let o of wh(this.def)) {
|
|
8920
8922
|
let s = e.get(o) ?? 0;
|
|
8921
8923
|
i += s;
|
|
8922
8924
|
let c = this.metricValueFor(o, t, e), l = o === n, u = l || c === null || r === null ? null : c - r, d = l || c === null || r === null || r === 0 ? null : (c - r) / r;
|
|
@@ -8953,7 +8955,7 @@ behind quietly.` + n;
|
|
|
8953
8955
|
get isSeeded() {
|
|
8954
8956
|
return this.seeded;
|
|
8955
8957
|
}
|
|
8956
|
-
},
|
|
8958
|
+
}, Ih = (e) => {
|
|
8957
8959
|
let t = e.now ?? Date.now, n = e.log, r = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Map(), a = (e) => {
|
|
8958
8960
|
for (let t of r) try {
|
|
8959
8961
|
t(e);
|
|
@@ -8970,7 +8972,7 @@ behind quietly.` + n;
|
|
|
8970
8972
|
}), s = /* @__PURE__ */ new Map();
|
|
8971
8973
|
for (let { definition: r } of e.discovered) {
|
|
8972
8974
|
if (i.has(r.name)) throw Error(`experiment: duplicate name '${r.name}' — names must be unique across all experiments`);
|
|
8973
|
-
let e = new
|
|
8975
|
+
let e = new Fh(r, {
|
|
8974
8976
|
queryBase: o(r.on.table),
|
|
8975
8977
|
now: t,
|
|
8976
8978
|
...n === void 0 ? {} : { log: n }
|
|
@@ -8988,7 +8990,7 @@ behind quietly.` + n;
|
|
|
8988
8990
|
})();
|
|
8989
8991
|
let c = e.store.onChange((e) => {
|
|
8990
8992
|
let t = s.get(e.table);
|
|
8991
|
-
if (
|
|
8993
|
+
if (t !== void 0 && t.length !== 0) for (let r of t) try {
|
|
8992
8994
|
let t = r.applyChange(e);
|
|
8993
8995
|
t !== null && a(t);
|
|
8994
8996
|
} catch (e) {
|
|
@@ -9000,7 +9002,7 @@ behind quietly.` + n;
|
|
|
9000
9002
|
await e.seed();
|
|
9001
9003
|
} catch {}
|
|
9002
9004
|
})();
|
|
9003
|
-
}, e.reconcileIntervalMs ??
|
|
9005
|
+
}, e.reconcileIntervalMs ?? 3e5);
|
|
9004
9006
|
return l.unref?.(), {
|
|
9005
9007
|
registry: {
|
|
9006
9008
|
snapshot: () => [...i.values()].map((e) => e.result()),
|
|
@@ -9012,21 +9014,21 @@ behind quietly.` + n;
|
|
|
9012
9014
|
},
|
|
9013
9015
|
registered: [...i.keys()]
|
|
9014
9016
|
};
|
|
9015
|
-
},
|
|
9016
|
-
id:
|
|
9017
|
-
tenantId:
|
|
9018
|
-
kind:
|
|
9019
|
-
refId:
|
|
9020
|
-
wakeAt:
|
|
9021
|
-
status:
|
|
9022
|
-
}).index(["status", "wakeAt"]).index(["tenantId"]),
|
|
9023
|
-
let t = e.now?.() ?? /* @__PURE__ */ new Date(), n = await
|
|
9017
|
+
}, Lh = I("_voltro_wakeups", {
|
|
9018
|
+
id: N({ prefix: "wakeup" }),
|
|
9019
|
+
tenantId: L(),
|
|
9020
|
+
kind: L(),
|
|
9021
|
+
refId: L(),
|
|
9022
|
+
wakeAt: R(),
|
|
9023
|
+
status: L()
|
|
9024
|
+
}).index(["status", "wakeAt"]).index(["tenantId"]), Rh = async (e) => {
|
|
9025
|
+
let t = e.now?.() ?? /* @__PURE__ */ new Date(), n = await Pf(e.store, t, e.batchLimit ?? 100);
|
|
9024
9026
|
if (n.length === 0) return 0;
|
|
9025
9027
|
let r = 0;
|
|
9026
|
-
for (let t of n) if (await
|
|
9028
|
+
for (let t of n) if (await Af(e.store, t)) try {
|
|
9027
9029
|
await e.adapter.wake(t), r++;
|
|
9028
9030
|
} catch (n) {
|
|
9029
|
-
await
|
|
9031
|
+
await jf(e.store, t), e.log?.warn("wake: adapter failed — released for retry", {
|
|
9030
9032
|
tenantId: t.tenantId,
|
|
9031
9033
|
kind: t.kind,
|
|
9032
9034
|
refId: t.refId,
|
|
@@ -9034,11 +9036,11 @@ behind quietly.` + n;
|
|
|
9034
9036
|
});
|
|
9035
9037
|
}
|
|
9036
9038
|
return r > 0 && e.log?.info("wake: woke due deployments", { count: r }), r;
|
|
9037
|
-
},
|
|
9039
|
+
}, zh = (e, t = 1e3) => {
|
|
9038
9040
|
let n = !1, r, i = async () => {
|
|
9039
9041
|
if (!n) {
|
|
9040
9042
|
try {
|
|
9041
|
-
await
|
|
9043
|
+
await Rh(e);
|
|
9042
9044
|
} catch (t) {
|
|
9043
9045
|
e.log?.warn("wake: tick failed", { reason: t instanceof Error ? t.message : String(t) });
|
|
9044
9046
|
}
|
|
@@ -9048,10 +9050,10 @@ behind quietly.` + n;
|
|
|
9048
9050
|
return i(), { stop: () => {
|
|
9049
9051
|
n = !0, r !== void 0 && clearTimeout(r);
|
|
9050
9052
|
} };
|
|
9051
|
-
},
|
|
9053
|
+
}, Bh = (e) => ({ wake: async () => {
|
|
9052
9054
|
await e.start();
|
|
9053
|
-
} }),
|
|
9054
|
-
let t = e.fetchImpl ?? fetch, n = e.now ?? Date.now, r = e.sleep ??
|
|
9055
|
+
} }), Vh = (e) => new Promise((t) => setTimeout(t, e)), Hh = (e) => {
|
|
9056
|
+
let t = e.fetchImpl ?? fetch, n = e.now ?? Date.now, r = e.sleep ?? Vh, i = e.spawnImpl ?? Tn, a = e.startTimeoutMs ?? 3e4, o = e.healthPollMs ?? 200, s = e.stopSignal ?? "SIGTERM", c = e.stopGraceMs ?? 1e4, l, u, d = e.healthCheck ?? ((e) => e.ok), f = async () => {
|
|
9055
9057
|
try {
|
|
9056
9058
|
let n = await t(e.healthUrl);
|
|
9057
9059
|
return d(n);
|
|
@@ -9105,11 +9107,11 @@ behind quietly.` + n;
|
|
|
9105
9107
|
},
|
|
9106
9108
|
stop: m
|
|
9107
9109
|
};
|
|
9108
|
-
},
|
|
9110
|
+
}, Uh = async (e) => {
|
|
9109
9111
|
if (e.signals.connectedClients() > 0 || e.signals.inFlightRequests() > 0 || e.signals.activeWorkflowExecutions() > 0) return !1;
|
|
9110
|
-
let t = (e.now?.() ?? /* @__PURE__ */ new Date()).getTime() + (e.wakeLookaheadMs ?? 3e4), n = await
|
|
9112
|
+
let t = (e.now?.() ?? /* @__PURE__ */ new Date()).getTime() + (e.wakeLookaheadMs ?? 3e4), n = await Ff(e.store);
|
|
9111
9113
|
return !(n !== null && n.wakeAt.getTime() <= t);
|
|
9112
|
-
},
|
|
9114
|
+
}, Wh = (e, t = Date.now) => {
|
|
9113
9115
|
let n;
|
|
9114
9116
|
return {
|
|
9115
9117
|
update: (r) => {
|
|
@@ -9121,7 +9123,7 @@ behind quietly.` + n;
|
|
|
9121
9123
|
n = void 0;
|
|
9122
9124
|
}
|
|
9123
9125
|
};
|
|
9124
|
-
},
|
|
9126
|
+
}, Gh = () => {
|
|
9125
9127
|
let e = 0, t = 0;
|
|
9126
9128
|
return {
|
|
9127
9129
|
onRequestStart: () => {
|
|
@@ -9139,7 +9141,7 @@ behind quietly.` + n;
|
|
|
9139
9141
|
inFlightRequests: () => e,
|
|
9140
9142
|
openConnections: () => t
|
|
9141
9143
|
};
|
|
9142
|
-
},
|
|
9144
|
+
}, Kh = (e) => ({ run: async (t) => (e.onActivity?.(), await e.ensureAwake(), t()) }), qh = (e, t, n, r) => new Promise((i, a) => {
|
|
9143
9145
|
let o = Wt.request({
|
|
9144
9146
|
host: n,
|
|
9145
9147
|
port: r,
|
|
@@ -9150,7 +9152,7 @@ behind quietly.` + n;
|
|
|
9150
9152
|
t.writeHead(e.statusCode ?? 502, e.headers), e.pipe(t), e.on("end", i), e.on("error", a);
|
|
9151
9153
|
});
|
|
9152
9154
|
o.on("error", a), e.pipe(o);
|
|
9153
|
-
}),
|
|
9155
|
+
}), Jh = (e, t, n, r, i) => new Promise((a, o) => {
|
|
9154
9156
|
let s = Wt.request({
|
|
9155
9157
|
host: r,
|
|
9156
9158
|
port: i,
|
|
@@ -9165,21 +9167,21 @@ behind quietly.` + n;
|
|
|
9165
9167
|
};
|
|
9166
9168
|
t.on("close", s), r.on("close", s), r.on("error", o);
|
|
9167
9169
|
}), s.on("error", o), s.end();
|
|
9168
|
-
}),
|
|
9169
|
-
let t =
|
|
9170
|
+
}), Yh = (e) => {
|
|
9171
|
+
let t = Kh({
|
|
9170
9172
|
ensureAwake: () => e.supervisor.start(),
|
|
9171
9173
|
...e.onActivity === void 0 ? {} : { onActivity: e.onActivity }
|
|
9172
9174
|
}), n = e.activity, r = Wt.createServer((r, i) => {
|
|
9173
|
-
n?.onRequestStart(), i.on("close", () => n?.onRequestEnd()), t.run(() =>
|
|
9175
|
+
n?.onRequestStart(), i.on("close", () => n?.onRequestEnd()), t.run(() => qh(r, i, e.targetHost, e.targetPort)).catch((t) => {
|
|
9174
9176
|
e.log?.warn("wake-router: proxy failed", { reason: t instanceof Error ? t.message : String(t) }), i.headersSent || i.writeHead(502), i.end("wake/proxy failed");
|
|
9175
9177
|
});
|
|
9176
9178
|
});
|
|
9177
9179
|
return r.on("upgrade", (r, i, a) => {
|
|
9178
|
-
n?.onConnect(), i.on("close", () => n?.onDisconnect()), t.run(() =>
|
|
9180
|
+
n?.onConnect(), i.on("close", () => n?.onDisconnect()), t.run(() => Jh(r, i, a, e.targetHost, e.targetPort)).catch((t) => {
|
|
9179
9181
|
e.log?.warn("wake-router: upgrade proxy failed", { reason: t instanceof Error ? t.message : String(t) }), i.destroy();
|
|
9180
9182
|
});
|
|
9181
9183
|
}), r;
|
|
9182
|
-
},
|
|
9184
|
+
}, Xh = async (e) => {
|
|
9183
9185
|
try {
|
|
9184
9186
|
return (await e.query({
|
|
9185
9187
|
table: "_voltro_workflow_runs",
|
|
@@ -9196,15 +9198,15 @@ behind quietly.` + n;
|
|
|
9196
9198
|
} catch {
|
|
9197
9199
|
return 0;
|
|
9198
9200
|
}
|
|
9199
|
-
},
|
|
9200
|
-
let t =
|
|
9201
|
+
}, Zh = async (e) => {
|
|
9202
|
+
let t = Bh(e.supervisor), n = await Rh({
|
|
9201
9203
|
store: e.store,
|
|
9202
9204
|
adapter: t,
|
|
9203
9205
|
...e.now === void 0 ? {} : { now: e.now },
|
|
9204
9206
|
...e.log === void 0 ? {} : { log: e.log }
|
|
9205
9207
|
});
|
|
9206
9208
|
n > 0 && e.idleGate.reset();
|
|
9207
|
-
let r = await
|
|
9209
|
+
let r = await Uh({
|
|
9208
9210
|
store: e.store,
|
|
9209
9211
|
signals: e.signals,
|
|
9210
9212
|
...e.wakeLookaheadMs === void 0 ? {} : { wakeLookaheadMs: e.wakeLookaheadMs },
|
|
@@ -9214,12 +9216,12 @@ behind quietly.` + n;
|
|
|
9214
9216
|
woke: n,
|
|
9215
9217
|
stopped: i
|
|
9216
9218
|
};
|
|
9217
|
-
},
|
|
9218
|
-
let t =
|
|
9219
|
+
}, Qh = async (e) => {
|
|
9220
|
+
let t = Wh(e.idleGraceMs ?? 6e4), n = e.tickMs ?? 1e3, r = Gh(), i = 0, a = e.signals === void 0, o = e.signals ?? {
|
|
9219
9221
|
connectedClients: () => r.openConnections(),
|
|
9220
9222
|
inFlightRequests: () => r.inFlightRequests(),
|
|
9221
9223
|
activeWorkflowExecutions: () => i
|
|
9222
|
-
}, s =
|
|
9224
|
+
}, s = Yh({
|
|
9223
9225
|
supervisor: e.supervisor,
|
|
9224
9226
|
targetHost: e.targetHost,
|
|
9225
9227
|
targetPort: e.targetPort,
|
|
@@ -9235,10 +9237,10 @@ behind quietly.` + n;
|
|
|
9235
9237
|
});
|
|
9236
9238
|
});
|
|
9237
9239
|
e.log?.info("orchestrator: router listening", { port: c });
|
|
9238
|
-
let l = !1, u, d = e.firedRetentionMs ??
|
|
9240
|
+
let l = !1, u, d = e.firedRetentionMs ?? 6e5, f = 0, p = async () => {
|
|
9239
9241
|
if (!l) {
|
|
9240
9242
|
try {
|
|
9241
|
-
if (a && (i = await
|
|
9243
|
+
if (a && (i = await Xh(e.store)), await Zh({
|
|
9242
9244
|
store: e.store,
|
|
9243
9245
|
supervisor: e.supervisor,
|
|
9244
9246
|
signals: o,
|
|
@@ -9246,7 +9248,7 @@ behind quietly.` + n;
|
|
|
9246
9248
|
...e.wakeLookaheadMs === void 0 ? {} : { wakeLookaheadMs: e.wakeLookaheadMs },
|
|
9247
9249
|
...e.log === void 0 ? {} : { log: e.log }
|
|
9248
9250
|
}), f++ % 60 == 0) {
|
|
9249
|
-
let t = await
|
|
9251
|
+
let t = await Lf(e.store, { firedOlderThan: new Date(Date.now() - d) });
|
|
9250
9252
|
t > 0 && e.log?.info("orchestrator: pruned fired wakeups", { count: t });
|
|
9251
9253
|
}
|
|
9252
9254
|
} catch (t) {
|
|
@@ -9261,14 +9263,14 @@ behind quietly.` + n;
|
|
|
9261
9263
|
l = !0, u !== void 0 && clearTimeout(u), await new Promise((e) => s.close(() => e()));
|
|
9262
9264
|
}
|
|
9263
9265
|
};
|
|
9264
|
-
},
|
|
9266
|
+
}, $h = (e) => e, eg = class extends y.TaggedError()("AnalyticsError", {
|
|
9265
9267
|
provider: y.String,
|
|
9266
9268
|
operation: y.String,
|
|
9267
9269
|
cause: y.String
|
|
9268
|
-
}) {},
|
|
9270
|
+
}) {}, tg = class extends y.TaggedError()("AnalyticsCapabilityNotSupported", {
|
|
9269
9271
|
provider: y.String,
|
|
9270
9272
|
capability: y.String
|
|
9271
|
-
}) {},
|
|
9273
|
+
}) {}, ng = class extends n.Tag("@voltro/AnalyticsSink")() {}, rg = (e, t) => ({
|
|
9272
9274
|
info: e.info,
|
|
9273
9275
|
track: (n) => e.track(n.tenantId === void 0 ? {
|
|
9274
9276
|
...n,
|
|
@@ -9287,20 +9289,20 @@ behind quietly.` + n;
|
|
|
9287
9289
|
tenantId: t
|
|
9288
9290
|
} : n),
|
|
9289
9291
|
...e.mirror === void 0 ? {} : { mirror: e.mirror }
|
|
9290
|
-
}),
|
|
9291
|
-
let e = yield*
|
|
9292
|
+
}), ig = () => o.gen(function* () {
|
|
9293
|
+
let e = yield* ng, t = yield* o.serviceOption(ht), n = h.match(t, {
|
|
9292
9294
|
onNone: () => null,
|
|
9293
9295
|
onSome: (e) => e.tenantId ?? null
|
|
9294
9296
|
});
|
|
9295
|
-
return n === null ? e :
|
|
9296
|
-
}),
|
|
9297
|
-
let e = (e) => o.fail(new
|
|
9298
|
-
provider:
|
|
9297
|
+
return n === null ? e : rg(e, n);
|
|
9298
|
+
}), ag = "noop", og = () => {
|
|
9299
|
+
let e = (e) => o.fail(new tg({
|
|
9300
|
+
provider: ag,
|
|
9299
9301
|
capability: e
|
|
9300
9302
|
}));
|
|
9301
9303
|
return {
|
|
9302
9304
|
info: {
|
|
9303
|
-
provider:
|
|
9305
|
+
provider: ag,
|
|
9304
9306
|
capabilities: {
|
|
9305
9307
|
track: !0,
|
|
9306
9308
|
aggregate: !1,
|
|
@@ -9314,8 +9316,8 @@ behind quietly.` + n;
|
|
|
9314
9316
|
timeseries: () => e("timeseries"),
|
|
9315
9317
|
topN: () => e("topN")
|
|
9316
9318
|
};
|
|
9317
|
-
},
|
|
9318
|
-
if (e.length === 0) return
|
|
9319
|
+
}, sg = (e) => {
|
|
9320
|
+
if (e.length === 0) return og();
|
|
9319
9321
|
if (e.length === 1) return e[0];
|
|
9320
9322
|
let t = {
|
|
9321
9323
|
provider: "compose",
|
|
@@ -9332,7 +9334,7 @@ behind quietly.` + n;
|
|
|
9332
9334
|
discard: !0
|
|
9333
9335
|
}), r = (t, n) => {
|
|
9334
9336
|
let r = e.find((e) => e.info.capabilities[t]);
|
|
9335
|
-
return r === void 0 ? o.fail(new
|
|
9337
|
+
return r === void 0 ? o.fail(new tg({
|
|
9336
9338
|
provider: "compose",
|
|
9337
9339
|
capability: t
|
|
9338
9340
|
})) : n(r);
|
|
@@ -9359,11 +9361,11 @@ behind quietly.` + n;
|
|
|
9359
9361
|
topN: (e) => r("topN", (t) => t.topN(e)),
|
|
9360
9362
|
...a === void 0 ? {} : { mirror: a }
|
|
9361
9363
|
};
|
|
9362
|
-
},
|
|
9364
|
+
}, cg = (e) => {
|
|
9363
9365
|
let t = e.filter((e) => e.dispose !== void 0);
|
|
9364
9366
|
return {
|
|
9365
9367
|
kind: "compose",
|
|
9366
|
-
build: (t) =>
|
|
9368
|
+
build: (t) => sg(e.map((e) => e.build(t))),
|
|
9367
9369
|
tables: e.flatMap((e) => e.tables ?? []),
|
|
9368
9370
|
initialize: (t) => o.forEach(e, (e) => e.initialize ? e.initialize(t) : o.void, {
|
|
9369
9371
|
concurrency: 1,
|
|
@@ -9374,34 +9376,34 @@ behind quietly.` + n;
|
|
|
9374
9376
|
discard: !0
|
|
9375
9377
|
}) } : {}
|
|
9376
9378
|
};
|
|
9377
|
-
},
|
|
9379
|
+
}, lg = {
|
|
9378
9380
|
kind: "noop",
|
|
9379
|
-
build: () =>
|
|
9380
|
-
},
|
|
9381
|
+
build: () => og()
|
|
9382
|
+
}, ug = f.counter("voltro_analytics_mirror_forwarded_total", { description: "Reactive-table changes successfully applied to the analytics mirror." }), dg = f.counter("voltro_analytics_mirror_retries_total", { description: "Analytics-mirror write attempts that failed (each is retried until the budget runs out)." }), fg = f.counter("voltro_analytics_mirror_repair_queued_total", { description: "Analytics-mirror changes whose retries were exhausted and were queued for repair." }), pg = f.counter("voltro_analytics_mirror_dropped_total", { description: "Analytics-mirror changes provably lost (repair queue overflow)." }), mg = (e) => {
|
|
9381
9383
|
o.runSync(f.increment(e));
|
|
9382
|
-
},
|
|
9384
|
+
}, hg = (t) => e.pretty(t), gg = {
|
|
9383
9385
|
retryAttempts: 5,
|
|
9384
9386
|
retryBaseDelayMs: 100,
|
|
9385
9387
|
retryMaxDelayMs: 3e4,
|
|
9386
9388
|
repairIntervalMs: 6e4,
|
|
9387
9389
|
repairQueueLimit: 1e4,
|
|
9388
9390
|
versionStateLimit: 1e5
|
|
9389
|
-
},
|
|
9391
|
+
}, _g = (e) => {
|
|
9390
9392
|
let t = process.env[e];
|
|
9391
9393
|
if (t === void 0 || t.trim() === "") return;
|
|
9392
9394
|
let n = Number(t);
|
|
9393
9395
|
return Number.isFinite(n) && n >= 0 ? n : void 0;
|
|
9394
|
-
},
|
|
9395
|
-
let t =
|
|
9396
|
+
}, vg = (e) => {
|
|
9397
|
+
let t = gg, n = e ?? {};
|
|
9396
9398
|
return {
|
|
9397
|
-
retryAttempts: Math.max(1, n.retryAttempts ??
|
|
9398
|
-
retryBaseDelayMs: n.retryBaseDelayMs ??
|
|
9399
|
-
retryMaxDelayMs: n.retryMaxDelayMs ??
|
|
9400
|
-
repairIntervalMs: n.repairIntervalMs ??
|
|
9401
|
-
repairQueueLimit: Math.max(1, n.repairQueueLimit ??
|
|
9402
|
-
versionStateLimit: Math.max(1, n.versionStateLimit ??
|
|
9403
|
-
};
|
|
9404
|
-
},
|
|
9399
|
+
retryAttempts: Math.max(1, n.retryAttempts ?? _g("VOLTRO_ANALYTICS_MIRROR_RETRY_ATTEMPTS") ?? t.retryAttempts),
|
|
9400
|
+
retryBaseDelayMs: n.retryBaseDelayMs ?? _g("VOLTRO_ANALYTICS_MIRROR_RETRY_BASE_MS") ?? t.retryBaseDelayMs,
|
|
9401
|
+
retryMaxDelayMs: n.retryMaxDelayMs ?? _g("VOLTRO_ANALYTICS_MIRROR_RETRY_MAX_MS") ?? t.retryMaxDelayMs,
|
|
9402
|
+
repairIntervalMs: n.repairIntervalMs ?? _g("VOLTRO_ANALYTICS_MIRROR_REPAIR_INTERVAL_MS") ?? t.repairIntervalMs,
|
|
9403
|
+
repairQueueLimit: Math.max(1, n.repairQueueLimit ?? _g("VOLTRO_ANALYTICS_MIRROR_REPAIR_QUEUE_LIMIT") ?? t.repairQueueLimit),
|
|
9404
|
+
versionStateLimit: Math.max(1, n.versionStateLimit ?? _g("VOLTRO_ANALYTICS_MIRROR_VERSION_STATE_LIMIT") ?? t.versionStateLimit)
|
|
9405
|
+
};
|
|
9406
|
+
}, yg = {
|
|
9405
9407
|
tables: [],
|
|
9406
9408
|
detach: () => {},
|
|
9407
9409
|
flush: () => Promise.resolve(),
|
|
@@ -9412,10 +9414,10 @@ behind quietly.` + n;
|
|
|
9412
9414
|
awaitingRepair: 0,
|
|
9413
9415
|
dropped: 0
|
|
9414
9416
|
})
|
|
9415
|
-
},
|
|
9417
|
+
}, bg = (e, t) => `${e}\u0000${String(t)}`, xg = (e) => {
|
|
9416
9418
|
let { store: t, sink: n, log: r } = e, i = n.mirror;
|
|
9417
|
-
if (i === void 0 || i.tables.length === 0) return
|
|
9418
|
-
let s =
|
|
9419
|
+
if (i === void 0 || i.tables.length === 0) return yg;
|
|
9420
|
+
let s = vg(e), c = e.run ?? ((e) => o.runPromise(e)), l = i.primaryKey ?? "id", u = new Set(i.tables), d = n.info.provider, f = t.changeScope === "fleet", p = 0, m = () => {
|
|
9419
9421
|
let e = Date.now() * 1e3;
|
|
9420
9422
|
return p = e > p ? e : p + 1, p;
|
|
9421
9423
|
}, h = /* @__PURE__ */ new Map(), g = /* @__PURE__ */ new Set(), _ = /* @__PURE__ */ new Map(), y = /* @__PURE__ */ new Set(), b = 0, x = 0, S = /* @__PURE__ */ new Map(), C = (e) => {
|
|
@@ -9435,7 +9437,7 @@ behind quietly.` + n;
|
|
|
9435
9437
|
primaryKeyValue: t.pk
|
|
9436
9438
|
}).pipe(o.map((e) => (n.baseline = e ?? 0, n.baseline))) : o.succeed(n.baseline);
|
|
9437
9439
|
}), T = (e, t, n) => n.kind === "clock" ? o.succeed(n.version) : w(e, t).pipe(o.map((e) => e + n.ordinal)), E = v.exponential(a.millis(Math.max(1, s.retryBaseDelayMs)), 2).pipe(v.either(v.spaced(a.millis(Math.max(1, s.retryMaxDelayMs)))), v.intersect(v.recurs(s.retryAttempts - 1))), ee = (e, t) => o.gen(function* () {
|
|
9438
|
-
let n = yield* T(
|
|
9440
|
+
let n = yield* T(bg(e.table, e.pk), e, t.stamp);
|
|
9439
9441
|
yield* t.kind === "upsert" ? i.upsert({
|
|
9440
9442
|
table: e.table,
|
|
9441
9443
|
row: t.row,
|
|
@@ -9446,27 +9448,27 @@ behind quietly.` + n;
|
|
|
9446
9448
|
version: n
|
|
9447
9449
|
});
|
|
9448
9450
|
}), D = (e) => e instanceof Error ? `${e.name}: ${e.message}` : String(e), te = (e, t) => ee(e, t).pipe(o.tapErrorCause(() => o.sync(() => {
|
|
9449
|
-
|
|
9451
|
+
mg(dg);
|
|
9450
9452
|
})), o.retry(E), o.matchCauseEffect({
|
|
9451
9453
|
onSuccess: () => o.sync(() => {
|
|
9452
|
-
b += 1,
|
|
9454
|
+
b += 1, mg(ug);
|
|
9453
9455
|
}),
|
|
9454
9456
|
onFailure: (n) => o.sync(() => {
|
|
9455
|
-
ne(e, t,
|
|
9457
|
+
ne(e, t, hg(n));
|
|
9456
9458
|
})
|
|
9457
9459
|
})), ne = (e, t, n) => {
|
|
9458
|
-
let i =
|
|
9460
|
+
let i = bg(e.table, e.pk);
|
|
9459
9461
|
for (r.warn("analytics-mirror: change forward failed, queued for repair", {
|
|
9460
9462
|
provider: d,
|
|
9461
9463
|
table: e.table,
|
|
9462
9464
|
op: t.kind,
|
|
9463
9465
|
attempts: s.retryAttempts,
|
|
9464
9466
|
err: n
|
|
9465
|
-
}), _.set(i, e),
|
|
9467
|
+
}), _.set(i, e), mg(fg); _.size > s.repairQueueLimit;) {
|
|
9466
9468
|
let e = _.keys().next();
|
|
9467
9469
|
if (e.done === !0) break;
|
|
9468
9470
|
let t = _.get(e.value);
|
|
9469
|
-
_.delete(e.value), x += 1, pg
|
|
9471
|
+
_.delete(e.value), x += 1, mg(pg), r.error("analytics-mirror: repair queue full — change dropped, mirror is diverged", {
|
|
9470
9472
|
provider: d,
|
|
9471
9473
|
table: t?.table ?? "<unknown>",
|
|
9472
9474
|
limit: s.repairQueueLimit
|
|
@@ -9496,7 +9498,7 @@ behind quietly.` + n;
|
|
|
9496
9498
|
y.delete(t);
|
|
9497
9499
|
});
|
|
9498
9500
|
}, ae = (e, t) => {
|
|
9499
|
-
let n =
|
|
9501
|
+
let n = bg(e.table, e.pk);
|
|
9500
9502
|
h.set(n, t), !g.has(n) && (g.add(n), k(ie(n, e)));
|
|
9501
9503
|
}, A = (e) => o.tryPromise({
|
|
9502
9504
|
try: () => t.query({
|
|
@@ -9518,18 +9520,18 @@ behind quietly.` + n;
|
|
|
9518
9520
|
table: t.table,
|
|
9519
9521
|
row: r,
|
|
9520
9522
|
version: n
|
|
9521
|
-
}), _.delete(e), b += 1,
|
|
9523
|
+
}), _.delete(e), b += 1, mg(ug), !0;
|
|
9522
9524
|
}).pipe(o.catchAllCause((e) => o.sync(() => (r.warn("analytics-mirror: repair pass failed, key stays queued", {
|
|
9523
9525
|
provider: d,
|
|
9524
9526
|
table: t.table,
|
|
9525
|
-
err:
|
|
9527
|
+
err: hg(e)
|
|
9526
9528
|
}), !1)))), j = () => o.gen(function* () {
|
|
9527
9529
|
let e = [..._.entries()];
|
|
9528
9530
|
if (e.length === 0) return 0;
|
|
9529
9531
|
let t = 0;
|
|
9530
9532
|
for (let [n, r] of e) (yield* oe(n, r)) && (t += 1);
|
|
9531
9533
|
return t;
|
|
9532
|
-
}),
|
|
9534
|
+
}), M = () => {
|
|
9533
9535
|
let e = 0;
|
|
9534
9536
|
return Promise.resolve(c(j().pipe(o.tap((t) => o.sync(() => {
|
|
9535
9537
|
e = t;
|
|
@@ -9537,21 +9539,21 @@ behind quietly.` + n;
|
|
|
9537
9539
|
provider: d,
|
|
9538
9540
|
err: D(e)
|
|
9539
9541
|
}), 0));
|
|
9540
|
-
},
|
|
9541
|
-
|
|
9542
|
+
}, se = s.repairIntervalMs > 0 ? setInterval(() => {
|
|
9543
|
+
M();
|
|
9542
9544
|
}, s.repairIntervalMs) : void 0;
|
|
9543
|
-
|
|
9544
|
-
let
|
|
9545
|
+
se?.unref?.();
|
|
9546
|
+
let ce = (e) => {
|
|
9545
9547
|
if (!f) return {
|
|
9546
9548
|
kind: "clock",
|
|
9547
9549
|
version: m()
|
|
9548
9550
|
};
|
|
9549
|
-
let t = C(
|
|
9551
|
+
let t = C(bg(e.table, e.pk));
|
|
9550
9552
|
return t.ordinal += 1, {
|
|
9551
9553
|
kind: "ordinal",
|
|
9552
9554
|
ordinal: t.ordinal
|
|
9553
9555
|
};
|
|
9554
|
-
},
|
|
9556
|
+
}, N = (e) => {
|
|
9555
9557
|
if (e.op === "delete") {
|
|
9556
9558
|
let t = e.old;
|
|
9557
9559
|
if (t === null) return;
|
|
@@ -9563,7 +9565,7 @@ behind quietly.` + n;
|
|
|
9563
9565
|
};
|
|
9564
9566
|
ae(r, {
|
|
9565
9567
|
kind: "remove",
|
|
9566
|
-
stamp:
|
|
9568
|
+
stamp: ce(r)
|
|
9567
9569
|
});
|
|
9568
9570
|
return;
|
|
9569
9571
|
}
|
|
@@ -9578,15 +9580,15 @@ behind quietly.` + n;
|
|
|
9578
9580
|
ae(r, {
|
|
9579
9581
|
kind: "upsert",
|
|
9580
9582
|
row: t,
|
|
9581
|
-
stamp:
|
|
9583
|
+
stamp: ce(r)
|
|
9582
9584
|
});
|
|
9583
|
-
},
|
|
9584
|
-
u.has(e.table) &&
|
|
9585
|
+
}, le = t.onChange((e) => {
|
|
9586
|
+
u.has(e.table) && N(e);
|
|
9585
9587
|
});
|
|
9586
9588
|
return {
|
|
9587
9589
|
tables: i.tables,
|
|
9588
9590
|
detach: () => {
|
|
9589
|
-
|
|
9591
|
+
le(), se !== void 0 && clearInterval(se);
|
|
9590
9592
|
},
|
|
9591
9593
|
flush: async () => {
|
|
9592
9594
|
for (let e = 0; e < 1e3; e++) {
|
|
@@ -9594,7 +9596,7 @@ behind quietly.` + n;
|
|
|
9594
9596
|
await Promise.all([...y]);
|
|
9595
9597
|
}
|
|
9596
9598
|
},
|
|
9597
|
-
repair:
|
|
9599
|
+
repair: M,
|
|
9598
9600
|
stats: () => ({
|
|
9599
9601
|
forwarded: b,
|
|
9600
9602
|
pending: h.size,
|
|
@@ -9602,11 +9604,11 @@ behind quietly.` + n;
|
|
|
9602
9604
|
dropped: x
|
|
9603
9605
|
})
|
|
9604
9606
|
};
|
|
9605
|
-
},
|
|
9607
|
+
}, Sg = (e) => {
|
|
9606
9608
|
let t = typeof e.refresh == "string" ? { interval: e.refresh } : e.refresh, n = e.strategy ?? "replace";
|
|
9607
9609
|
if (n === "merge" && (e.mergeKey === void 0 || e.mergeKey.length === 0)) throw Error(`defineAggregate("${e.name}"): strategy: 'merge' requires mergeKey — the property on each row to upsert by`);
|
|
9608
9610
|
if (e.incremental !== void 0) {
|
|
9609
|
-
let t =
|
|
9611
|
+
let t = bm({
|
|
9610
9612
|
aggregations: [{
|
|
9611
9613
|
op: e.incremental.op,
|
|
9612
9614
|
...e.incremental.column === void 0 ? {} : { column: e.incremental.column }
|
|
@@ -9628,46 +9630,46 @@ behind quietly.` + n;
|
|
|
9628
9630
|
build: e.build,
|
|
9629
9631
|
...e.incremental === void 0 ? {} : { incremental: e.incremental }
|
|
9630
9632
|
};
|
|
9631
|
-
},
|
|
9633
|
+
}, Cg = (e) => typeof e == "object" && !!e && e._voltroAggregate === !0, wg = class extends y.TaggedError()("AggregateStale", {
|
|
9632
9634
|
name: y.String,
|
|
9633
9635
|
ageMs: y.Number,
|
|
9634
9636
|
maxAgeMs: y.Number
|
|
9635
|
-
}) {},
|
|
9637
|
+
}) {}, Tg = class extends y.TaggedError()("AggregateNotFound", { name: y.String }) {}, Eg = class extends y.TaggedError()("AggregateError", {
|
|
9636
9638
|
name: y.String,
|
|
9637
9639
|
operation: y.String,
|
|
9638
9640
|
cause: y.String
|
|
9639
|
-
}) {},
|
|
9640
|
-
return (yield*
|
|
9641
|
-
}),
|
|
9641
|
+
}) {}, Dg = class extends n.Tag("@voltro/AggregateRegistry")() {}, Og = (e) => o.gen(function* () {
|
|
9642
|
+
return (yield* Dg).getHandle(e);
|
|
9643
|
+
}), kg = (e, t, n) => {
|
|
9642
9644
|
if (e.crossTenant || !t.has(e.table) || n == null) return e;
|
|
9643
9645
|
let r = O("tenantId", n);
|
|
9644
9646
|
return {
|
|
9645
9647
|
...e,
|
|
9646
9648
|
predicate: e.predicate ? C(e.predicate, r) : r
|
|
9647
9649
|
};
|
|
9648
|
-
},
|
|
9650
|
+
}, Ag = (e, t, n) => n === "" && !e.crossTenant && t.has(e.table), jg = (e) => e?.type === "user" && e.tenantId === "", Mg = (e, t) => {
|
|
9649
9651
|
if (e.includeDeleted || !t.has(e.table)) return e;
|
|
9650
|
-
let n =
|
|
9652
|
+
let n = de("deletedAt");
|
|
9651
9653
|
return {
|
|
9652
9654
|
...e,
|
|
9653
9655
|
predicate: e.predicate ? C(e.predicate, n) : n
|
|
9654
9656
|
};
|
|
9655
|
-
},
|
|
9657
|
+
}, Ng = (e) => (t, n) => {
|
|
9656
9658
|
e.observe?.beforeScope?.({ ...t }, n);
|
|
9657
|
-
let r =
|
|
9659
|
+
let r = Mg(kg(t, e.tenantScopedTables, n.tenantId), e.softDeleteScopedTables);
|
|
9658
9660
|
return e.observe?.afterScope?.({ ...r }), r;
|
|
9659
|
-
},
|
|
9661
|
+
}, Pg = (e, t) => t, Fg = (t) => o.runPromiseExit(t).then((t) => {
|
|
9660
9662
|
if (c.isSuccess(t)) return t.value;
|
|
9661
9663
|
let n = e.failureOption(t.cause);
|
|
9662
9664
|
throw h.isSome(n) ? n.value : e.squash(t.cause);
|
|
9663
|
-
}),
|
|
9664
|
-
let i = await o.runPromise(
|
|
9665
|
+
}), Ig = (e, t) => e.pipe(o.provideService(ht, t)), Lg = async (e, t, n, r) => {
|
|
9666
|
+
let i = await o.runPromise(xt(t, e.guards, n, {
|
|
9665
9667
|
defaultDeny: r === !0,
|
|
9666
9668
|
procedure: e.name
|
|
9667
9669
|
}));
|
|
9668
9670
|
if (i) throw i;
|
|
9669
|
-
},
|
|
9670
|
-
e.requiresApproval !== void 0 && await
|
|
9671
|
+
}, Rg = async (e, t, n, r) => {
|
|
9672
|
+
e.requiresApproval !== void 0 && await tm({
|
|
9671
9673
|
procedure: e.name,
|
|
9672
9674
|
kind: t,
|
|
9673
9675
|
policy: e.requiresApproval,
|
|
@@ -9675,16 +9677,16 @@ behind quietly.` + n;
|
|
|
9675
9677
|
input: r,
|
|
9676
9678
|
traceId: n.traceId
|
|
9677
9679
|
});
|
|
9678
|
-
},
|
|
9680
|
+
}, zg = async (e) => {
|
|
9679
9681
|
if (mi() === void 0) return e;
|
|
9680
|
-
let t = await
|
|
9682
|
+
let t = await Fg(_i(e.subject, (e) => {
|
|
9681
9683
|
console.error("[voltro] row filter failed to load", e);
|
|
9682
9684
|
}));
|
|
9683
9685
|
return {
|
|
9684
9686
|
...e,
|
|
9685
9687
|
rowFilter: t
|
|
9686
9688
|
};
|
|
9687
|
-
},
|
|
9689
|
+
}, Bg = (e) => {
|
|
9688
9690
|
let t = e.descriptor.target;
|
|
9689
9691
|
if (t == null) return [];
|
|
9690
9692
|
let n = Array.isArray(t) ? t : [t], r = /* @__PURE__ */ new Set();
|
|
@@ -9693,7 +9695,7 @@ behind quietly.` + n;
|
|
|
9693
9695
|
typeof t == "string" && t.length > 0 && r.add(t);
|
|
9694
9696
|
}
|
|
9695
9697
|
return [...r];
|
|
9696
|
-
},
|
|
9698
|
+
}, Vg = async (t) => {
|
|
9697
9699
|
let n = `${t.kind}.${t.name}`, r = Date.now(), i = "ok";
|
|
9698
9700
|
try {
|
|
9699
9701
|
if (t.interceptor) {
|
|
@@ -9723,46 +9725,46 @@ behind quietly.` + n;
|
|
|
9723
9725
|
status: i
|
|
9724
9726
|
});
|
|
9725
9727
|
}
|
|
9726
|
-
},
|
|
9728
|
+
}, Hg = /* @__PURE__ */ new Set([1213, 1205]), Ug = /* @__PURE__ */ new Set([
|
|
9727
9729
|
"ER_LOCK_DEADLOCK",
|
|
9728
9730
|
"ER_LOCK_WAIT_TIMEOUT",
|
|
9729
9731
|
"40001",
|
|
9730
9732
|
"40P01"
|
|
9731
|
-
]),
|
|
9733
|
+
]), Wg = (e) => {
|
|
9732
9734
|
let t = e;
|
|
9733
9735
|
for (let e = 0; e < 6 && typeof t == "object" && t; e++) {
|
|
9734
9736
|
let e = t;
|
|
9735
|
-
if (typeof e.errno == "number" &&
|
|
9737
|
+
if (typeof e.errno == "number" && Hg.has(e.errno) || typeof e.code == "string" && Ug.has(e.code) || typeof e.sqlState == "string" && Ug.has(e.sqlState)) return !0;
|
|
9736
9738
|
t = e.cause;
|
|
9737
9739
|
}
|
|
9738
9740
|
return !1;
|
|
9739
|
-
},
|
|
9740
|
-
let n = t?.delay ?? ((e) =>
|
|
9741
|
+
}, Gg = 3, Kg = (e) => new Promise((t) => setTimeout(t, e)), qg = async (e, t) => {
|
|
9742
|
+
let n = t?.delay ?? ((e) => Kg(e * 20 + Math.floor(Math.random() * 30)));
|
|
9741
9743
|
for (let t = 1;; t++) try {
|
|
9742
9744
|
return await e();
|
|
9743
9745
|
} catch (e) {
|
|
9744
|
-
if (t >=
|
|
9746
|
+
if (t >= Gg || !Wg(e)) throw e;
|
|
9745
9747
|
await n(t);
|
|
9746
9748
|
}
|
|
9747
|
-
},
|
|
9749
|
+
}, Jg = (e) => (t, n, r) => Vg({
|
|
9748
9750
|
name: t.descriptor.name,
|
|
9749
9751
|
kind: "mutation",
|
|
9750
9752
|
input: n,
|
|
9751
9753
|
requestContext: r,
|
|
9752
|
-
target:
|
|
9754
|
+
target: Bg(t),
|
|
9753
9755
|
...e.interceptor ? { interceptor: e.interceptor } : {},
|
|
9754
9756
|
...e.recordMetric ? { recordMetric: e.recordMetric } : {},
|
|
9755
9757
|
runExecutor: async () => {
|
|
9756
|
-
await
|
|
9757
|
-
let i = await
|
|
9758
|
-
let c = e.undoCapture?.(s), l =
|
|
9758
|
+
await Lg(t.descriptor, r.subject, n, e.defaultDeny), await Rg(t.descriptor, "mutation", r, n);
|
|
9759
|
+
let i = await zg(r), a = [], s = await qg(async () => (a.length = 0, e.store.transactional(async (s) => {
|
|
9760
|
+
let c = e.undoCapture?.(s), l = pp(c ? c.tx : s), u = e.buildContext(i, l.tx, { afterCommit: (e) => {
|
|
9759
9761
|
a.push(e);
|
|
9760
|
-
} }), d = t.executor(n, u), f = o.isEffect(d) ? await e.runEffect(
|
|
9762
|
+
} }), d = t.executor(n, u), f = o.isEffect(d) ? await e.runEffect(Ig(d, r.subject), u.store) : await d;
|
|
9761
9763
|
return c && await c.persist(u.store, {
|
|
9762
9764
|
tag: t.descriptor.name,
|
|
9763
9765
|
subject: r.subject,
|
|
9764
9766
|
traceId: r.traceId
|
|
9765
|
-
}), await
|
|
9767
|
+
}), await hp({
|
|
9766
9768
|
touched: l.drain(),
|
|
9767
9769
|
store: u.store,
|
|
9768
9770
|
subject: r.subject
|
|
@@ -9771,40 +9773,40 @@ behind quietly.` + n;
|
|
|
9771
9773
|
for (let e of a) await e();
|
|
9772
9774
|
return s;
|
|
9773
9775
|
}
|
|
9774
|
-
}),
|
|
9776
|
+
}), Yg = (e) => e && typeof e == "object" && "descriptor" in e ? e.descriptor : e, Xg = (e) => typeof e == "object" && !!e && !Array.isArray(e) && "table" in e && "order" in e, Zg = (e) => {
|
|
9775
9777
|
let t = e.descriptor.source;
|
|
9776
9778
|
return t == null ? [] : typeof t == "string" ? [t] : [...t];
|
|
9777
|
-
},
|
|
9779
|
+
}, Qg = (e, t, n) => (r) => () => {
|
|
9778
9780
|
let i = e.descriptor.guards;
|
|
9779
|
-
return (!i || i.length === 0) && n !== !0 ? Promise.resolve(null) : o.runPromise(
|
|
9781
|
+
return (!i || i.length === 0) && n !== !0 ? Promise.resolve(null) : o.runPromise(xt(r, i, t, {
|
|
9780
9782
|
defaultDeny: n === !0,
|
|
9781
9783
|
procedure: e.descriptor.name
|
|
9782
9784
|
}));
|
|
9783
|
-
},
|
|
9785
|
+
}, $g = (e, t) => e.rowFilter !== void 0 || mi() === void 0 ? t(e) : o.promise(() => zg(e)).pipe(o.flatMap((e) => {
|
|
9784
9786
|
let n = t(e);
|
|
9785
9787
|
return o.isEffect(n) ? n : o.succeed(n);
|
|
9786
|
-
})),
|
|
9787
|
-
if (r.rowFilter === void 0 && mi() !== void 0) return
|
|
9788
|
-
let i = e.buildContext(r), a =
|
|
9788
|
+
})), e_ = (e) => (t, n) => (r) => {
|
|
9789
|
+
if (r.rowFilter === void 0 && mi() !== void 0) return $g(r, (r) => e_(e)(t, n)(r));
|
|
9790
|
+
let i = e.buildContext(r), a = Qg(t, n, e.defaultDeny)(r.subject), s = async () => {
|
|
9789
9791
|
let i = await a();
|
|
9790
9792
|
if (i) throw i;
|
|
9791
|
-
let s = e.buildContext(await
|
|
9792
|
-
return o.isEffect(c) ? o.runPromise(e.provideEffect(
|
|
9793
|
+
let s = e.buildContext(await zg(r)), c = t.executor(n, s);
|
|
9794
|
+
return o.isEffect(c) ? o.runPromise(e.provideEffect(Ig(c, r.subject), s.store)) : Yg(await Promise.resolve(c));
|
|
9793
9795
|
}, c = (n) => {
|
|
9794
|
-
let i =
|
|
9795
|
-
return
|
|
9796
|
+
let i = Yg(n);
|
|
9797
|
+
return Xg(i) ? e.finalize(i, r) : {
|
|
9796
9798
|
__voltroComputed: !0,
|
|
9797
9799
|
value: i,
|
|
9798
|
-
dependentTables:
|
|
9800
|
+
dependentTables: Zg(t),
|
|
9799
9801
|
tenantId: r.subject?.tenantId ?? null,
|
|
9800
9802
|
recompute: s
|
|
9801
9803
|
};
|
|
9802
9804
|
}, l = () => {
|
|
9803
9805
|
let a = t.executor(n, i);
|
|
9804
|
-
return o.isEffect(a) ? e.provideEffect(
|
|
9806
|
+
return o.isEffect(a) ? e.provideEffect(Ig(a, r.subject), i.store).pipe(o.map(c)) : a instanceof Promise ? o.promise(() => a).pipe(o.map(c)) : c(a);
|
|
9805
9807
|
}, u = () => {
|
|
9806
9808
|
let i = t.descriptor.guards;
|
|
9807
|
-
return (!i || i.length === 0) && e.defaultDeny !== !0 ? l() :
|
|
9809
|
+
return (!i || i.length === 0) && e.defaultDeny !== !0 ? l() : xt(r.subject, i, n, {
|
|
9808
9810
|
defaultDeny: e.defaultDeny === !0,
|
|
9809
9811
|
procedure: t.descriptor.name
|
|
9810
9812
|
}).pipe(o.flatMap((e) => {
|
|
@@ -9826,14 +9828,14 @@ behind quietly.` + n;
|
|
|
9826
9828
|
traceId: r.traceId,
|
|
9827
9829
|
...r.spanId === void 0 ? {} : { spanId: r.spanId }
|
|
9828
9830
|
});
|
|
9829
|
-
},
|
|
9830
|
-
let i = await
|
|
9831
|
+
}, t_ = (e) => async (t, n, r) => {
|
|
9832
|
+
let i = await zg(r), a = e_(e)(t, n)(i), s = o.isEffect(a) ? await Fg(a) : a;
|
|
9831
9833
|
return Mi(s) ? s.value : e.queryRows(s, i);
|
|
9832
|
-
},
|
|
9834
|
+
}, n_ = (e) => (t, n, r, i) => {
|
|
9833
9835
|
let a = !1, s;
|
|
9834
9836
|
return (async () => {
|
|
9835
9837
|
try {
|
|
9836
|
-
let c = await
|
|
9838
|
+
let c = await zg(r), l = e_(e)(t, n)(c), u = o.isEffect(l) ? await Fg(l) : l, d = (e) => i(e), f = Mi(u) ? await e.subscribeComputed(u, d, c) : await e.subscribeDescriptor(u, d, c);
|
|
9837
9839
|
a ? f() : s = f;
|
|
9838
9840
|
} catch (e) {
|
|
9839
9841
|
i({
|
|
@@ -9844,25 +9846,25 @@ behind quietly.` + n;
|
|
|
9844
9846
|
})(), () => {
|
|
9845
9847
|
a = !0, s?.();
|
|
9846
9848
|
};
|
|
9847
|
-
},
|
|
9849
|
+
}, r_ = (e) => (t, n, r) => Vg({
|
|
9848
9850
|
name: t.descriptor.name,
|
|
9849
9851
|
kind: "action",
|
|
9850
9852
|
input: n,
|
|
9851
9853
|
requestContext: r,
|
|
9852
|
-
target:
|
|
9854
|
+
target: Bg(t),
|
|
9853
9855
|
...e.interceptor ? { interceptor: e.interceptor } : {},
|
|
9854
9856
|
...e.recordMetric ? { recordMetric: e.recordMetric } : {},
|
|
9855
9857
|
runExecutor: async () => {
|
|
9856
|
-
await
|
|
9857
|
-
let i = e.buildContext(await
|
|
9858
|
-
return o.isEffect(a) ? e.runEffect(
|
|
9858
|
+
await Lg(t.descriptor, r.subject, n, e.defaultDeny), await Rg(t.descriptor, "action", r, n);
|
|
9859
|
+
let i = e.buildContext(await zg(r)), a = t.executor(n, i);
|
|
9860
|
+
return o.isEffect(a) ? e.runEffect(Ig(a, r.subject), i.store) : a;
|
|
9859
9861
|
}
|
|
9860
|
-
}),
|
|
9862
|
+
}), i_ = (e) => e instanceof Date ? e.toISOString() : typeof e == "string" && e.length > 0 ? e : null, a_ = (e) => typeof e == "string" && e.length > 0 ? e : null, o_ = [
|
|
9861
9863
|
"updatedAt",
|
|
9862
9864
|
"createdAt",
|
|
9863
9865
|
"updatedBy",
|
|
9864
9866
|
"createdBy"
|
|
9865
|
-
],
|
|
9867
|
+
], s_ = (e) => o_.some((t) => t in e), c_ = (e, t, n) => {
|
|
9866
9868
|
let r = {
|
|
9867
9869
|
table: t.table,
|
|
9868
9870
|
id: t.id,
|
|
@@ -9877,14 +9879,14 @@ behind quietly.` + n;
|
|
|
9877
9879
|
found: !1
|
|
9878
9880
|
};
|
|
9879
9881
|
let i = t.column === void 0 ? void 0 : e[t.column];
|
|
9880
|
-
if (!
|
|
9882
|
+
if (!s_(e)) return {
|
|
9881
9883
|
...r,
|
|
9882
9884
|
value: i,
|
|
9883
9885
|
lastWrite: null,
|
|
9884
9886
|
attribution: "none",
|
|
9885
9887
|
found: !0
|
|
9886
9888
|
};
|
|
9887
|
-
let a =
|
|
9889
|
+
let a = a_(e.updatedBy) ?? a_(e.createdBy), o = i_(e.updatedAt) ?? i_(e.createdAt);
|
|
9888
9890
|
return {
|
|
9889
9891
|
...r,
|
|
9890
9892
|
value: i,
|
|
@@ -9896,12 +9898,12 @@ behind quietly.` + n;
|
|
|
9896
9898
|
attribution: "audit",
|
|
9897
9899
|
found: !0
|
|
9898
9900
|
};
|
|
9899
|
-
},
|
|
9901
|
+
}, l_ = (e, t) => {
|
|
9900
9902
|
let n = e.map((e) => {
|
|
9901
9903
|
let n = e.newValue ?? e.value, r = t.column !== void 0 && n && typeof n == "object" ? n[t.column] : e.newValue ?? e.value;
|
|
9902
9904
|
return {
|
|
9903
|
-
actor: { id:
|
|
9904
|
-
at:
|
|
9905
|
+
actor: { id: a_(e.actor) ?? a_(e.changedBy) },
|
|
9906
|
+
at: i_(e.at) ?? i_(e.changedAt),
|
|
9905
9907
|
...e.traceId === void 0 ? {} : { traceId: e.traceId },
|
|
9906
9908
|
value: r
|
|
9907
9909
|
};
|
|
@@ -9916,12 +9918,12 @@ behind quietly.` + n;
|
|
|
9916
9918
|
history: n,
|
|
9917
9919
|
found: n.length > 0
|
|
9918
9920
|
};
|
|
9919
|
-
},
|
|
9921
|
+
}, u_ = (e) => {
|
|
9920
9922
|
let t = e.new?.id;
|
|
9921
9923
|
if (typeof t == "string") return t;
|
|
9922
9924
|
let n = e.old?.id;
|
|
9923
9925
|
return typeof n == "string" ? n : void 0;
|
|
9924
|
-
},
|
|
9926
|
+
}, d_ = (e) => {
|
|
9925
9927
|
let t = {};
|
|
9926
9928
|
if (e.op === "insert") for (let [n, r] of Object.entries(e.new ?? {})) t[n] = {
|
|
9927
9929
|
from: void 0,
|
|
@@ -9941,11 +9943,11 @@ behind quietly.` + n;
|
|
|
9941
9943
|
return {
|
|
9942
9944
|
table: e.table,
|
|
9943
9945
|
op: e.op,
|
|
9944
|
-
id:
|
|
9946
|
+
id: u_(e),
|
|
9945
9947
|
fields: t
|
|
9946
9948
|
};
|
|
9947
|
-
},
|
|
9948
|
-
let t = e.map(
|
|
9949
|
+
}, f_ = (e) => {
|
|
9950
|
+
let t = e.map(d_);
|
|
9949
9951
|
return {
|
|
9950
9952
|
rows: t,
|
|
9951
9953
|
summary: {
|
|
@@ -9954,21 +9956,21 @@ behind quietly.` + n;
|
|
|
9954
9956
|
deletes: t.filter((e) => e.op === "delete").length
|
|
9955
9957
|
}
|
|
9956
9958
|
};
|
|
9957
|
-
},
|
|
9959
|
+
}, p_ = class extends Error {
|
|
9958
9960
|
constructor() {
|
|
9959
9961
|
super("voltro:preview-rollback"), this.name = "PreviewRollback";
|
|
9960
9962
|
}
|
|
9961
|
-
},
|
|
9963
|
+
}, m_ = async (e, t) => {
|
|
9962
9964
|
let n, r = !1;
|
|
9963
9965
|
try {
|
|
9964
9966
|
await e.transactional(async (e) => {
|
|
9965
|
-
throw n = await t(e), r = !0, new
|
|
9967
|
+
throw n = await t(e), r = !0, new p_();
|
|
9966
9968
|
});
|
|
9967
9969
|
} catch (e) {
|
|
9968
|
-
if (!(e instanceof
|
|
9970
|
+
if (!(e instanceof p_)) throw e;
|
|
9969
9971
|
}
|
|
9970
9972
|
if (!r) throw Error("preview: handler did not complete");
|
|
9971
9973
|
return n;
|
|
9972
|
-
},
|
|
9974
|
+
}, h_ = "framework-runtime";
|
|
9973
9975
|
//#endregion
|
|
9974
|
-
export { Ao as API_CSP, fc as API_KEYS_TABLE, Np as APPROVALS_TABLE, Hu as AccessDenied, Tg as AggregateError, Om as AggregateMaintainer, wg as AggregateNotFound, Eg as AggregateRegistry, Cg as AggregateStale, eg as AnalyticsCapabilityNotSupported, $h as AnalyticsError, tg as AnalyticsSink, Hf as CLAIM_RETENTION_BUCKETS, Y as CONNECTIONS_TABLE, Vl as CONNECTION_GRANTS_TABLE, of as CircuitBreaker, rf as CircuitOpen, uu as ConnectionNotConnected, hh as CostAccountant, ch as CostRegistry, hg as DEFAULT_ANALYTICS_MIRROR_TUNABLES, Pp as DEFAULT_APPROVAL_EXPIRY_MS, Vf as DEFAULT_CLAIM_BUCKET_MS, $n as DEFAULT_DELIVERY_CONCURRENCY, Mo as DEFAULT_HSTS, Yf as DEFAULT_MAX_IDLE_INTERVAL_MS, _s as DEFAULT_MAX_RPC_BODY_BYTES, er as DEFAULT_RAW_READ_TRACKING_LIMIT, cu as DEFAULT_REFRESH_SKEW_MS, li as DEFAULT_ROW_FILTER_RETRY, Rf as DORMANCY_WAKEUP_TENANT, ja as DeleteBuilder, ki as Dispatcher, hl as EVENT_CLIENT_QUEUE_SIZE, gl as EVENT_LATEST_QUEUE_SIZE, Dc as EffectStore, ul as EventBus, eh as ExpectationEvaluator, Wm as ExpectationRegistry, Ph as ExperimentEvaluator, wh as ExperimentRegistry, Su as GRANT_TTL_MS, _h as HOLDOUT_VARIANT, jo as HTML_CSP, qn as InMemoryDataStore, Pn as IndexedMatcher, Sl as InstanceMembership, Dn as LinearScanMatcher, p as MetricBoundaries, ig as NOOP_ANALYTICS_PROVIDER, gi as NO_ROW_FILTER, vo as NO_TRUSTED_PROXIES, wa as NoRowFound, El as OUTBOX_ATTEMPTS_TABLE, Nl as OUTBOX_ATTEMPT_LOG_CAP, J as OUTBOX_TABLE, Ta as OptimisticLockError, Vu as REBAC_ADMIN_SCOPE, lu as REFRESH_LEASE_MS, m_ as RUNTIME_NAME, Rm as ReactionRateLimiter, eo as ReplicatedDataStore, ci as RowFilterUnavailable, Lf as SCHEDULE_SUBJECT, Ec as SYSTEM_SUBJECT, ka as SelectBuilder, La as ServerOnlyColumnWrite, pd as SsrfBlockedError, Pa as StoreOperationFailed, Ln as SubscriptionRegistry, Fa as TableValidationFailed, Ia as TenantRowNotFound, Na as TenantScopeViolation, pm as TimelineRecorder, vp as UndoBoundaryError, bp as UndoStack, Bo as UnverifiedWebhookRoute, Aa as UpdateBuilder, bd as VOLTRO_AUDIT_MIXIN_ID, Sd as VOLTRO_EXPIRES_MIXIN_ID, wd as VOLTRO_LOCAL_FIRST_MIXIN_ID, xd as VOLTRO_SOFT_DELETE_MIXIN_ID, Cd as VOLTRO_TENANT_MIXIN_ID, Lo as WEBHOOK_VERIFICATION_PROPERTY, Pc as WorkflowDeferredResultError, Hc as WorkflowPayloadError, Fc as WorkflowRateLimitedError, Ic as WorkflowSingletonHeldError, qi as _connectionStreamCount, Ji as _resetConnectionCredentialsForTest, Fp as _voltroApprovalsTable, Ul as _voltroConnectionGrantsTable, Bl as _voltroConnectionsTable, km as _voltroRebacTuplesTable, tp as _voltroScheduleClaimsTable, ep as _voltroScheduleRunsTable, np as _voltroTracesTable, rp as _voltroUndoLogTable, Ih as _voltroWakeupsTable, il as _voltroWorkflowEventDeliveriesTable, rl as _voltroWorkflowEventsTable, Ua as actingUserId, Tc as apiKeyManagementRoutes, Ui as applyConnectionCredential, Ba as applyDefined, Em as applyDelta, Sp as applyInverse, Cp as applyInverses, tf as applyPluginRefRules, bi as applyRowFilter, xi as applyRowFilterToDescriptor, jg as applySoftDeleteScope, Og as applyTenantScope, jp as applyUndoInvocation, Vp as approvalIntentKey, rm as approvalNonce, am as approvalsPendingExecutor, Qu as assertCan, ql as assertConnectionCipherConfigured, Vo as assertWebhookRoutesDeclareVerification, Sh as assignVariant, bg as attachAnalyticsMirror, th as attachExpectations, Fh as attachExperiments, gh as attachFinops, ks as awaitServerListening, Ml as backoffMs, Eu as beginOAuthConnect, zi as bindConnectionCredential, yl as bindEvent, gs as bindMutation, rs as bindStream, ns as bindSubscription, Zo as bindSubscriptionUntyped, wm as buildIvmState, d_ as buildPreview, Mm as buildRebacInterceptor, Pm as buildRebacReadFilter, Ja as buildSubjectKey, Is as buildTracingLayer, Gd as cacheScopeLeaks, Zs as cachedBackend, Zu as can, Ef as cancelWakeup, Bp as canonicalJson, Fn as canonicalize, Uf as claimGraceMs, go as classifyRequestOrigin, ym as classifyShape, $p as clearApprovalGate, mu as clearConnectionRefreshFlights, qu as clearResourcePolicies, ee as clearRetentions, lf as clearSystemStoreHandle, nf as collectPluginRefRules, bf as compileCron, Du as completeOAuthConnect, sg as composeAnalytics, og as composeAnalyticsSinks, Cu as connectionCallbackPath, Kl as connectionLabel, Yh as countRunningWorkflows, ni as counter, Sf as cronOccurrences, Bd as crud, or as currentRawReads, rd as currentRequestLoader, $a as currentRoutingContext, ta as currentTraceContext, Sc as dataStoreApiKeyStore, ic as dataStoreIdempotencyStore, lc as dataStoreKvStore, tm as decideApproval, om as decideApprovalInvocation, da as decryptField, fs as defectMessage, xg as defineAggregate, Gl as defineConnection, oh as defineCostBudget, Qc as defineEventTrigger, Ng as defineExecutor, Hm as defineExpectation, yh as defineExperiment, kl as defineOutboxHandler, Fm as defineReaction, Wu as defineResourcePolicy, yf as defineSchedule, Qh as defineSubscriber, Di as deliveredRowCount, ia as deriveKey, u_ as diffChange, Ds as drainForShutdown, Ll as drainOutbox, Nf as dueWakeups, Xu as effectiveRelations, Ad as emptySchemaRegistry, _a as enableGraphObservation, ua as encryptField, em as enforceApproval, nd as enterRequestLoader, Gs as envSecretsBackend, mp as evaluateTouchedRules, Wr as eventMetricTagCacheSizeForTests, ou as exchangeAuthorizationCode, Qi as externalSpanFromTraceparent, Yn as extractDbCause, In as fingerprintFor, Ti as forbiddenColumnsForSubject, nu as forgetCredential, Kd as formatCacheScopeLeaks, Wd as formatServerOnlyLeaks, Xi as formatTraceparent, Yd as formatUnresolvedSources, xp as forwardChangeFromCdc, Cc as frameworkApiKeyStrategy, ri as gauge, mc as generateApiKeyToken, Qp as getApprovalGate, Bi as getConnectionCredential, ju as getConnectionResolver, Ri as getCredentialExpiry, K as getFieldCipher, Gu as getResourcePolicy, mi as getRowFilter, uf as getSystemStoreHandle, hm as getTimelineRecorder, cd as getTupleSource, xm as groupKeyOf, xh as hashUnitInterval, ii as histogramMetric, c_ as historyProvenance, Qs as httpSecretsBackend, Cn as inspectWorkflow, Zp as installApprovalGate, ld as installPolicyGuardResolver, Ki as interruptConnectionStreams, gp as invertChange, So as ipToBytes, Sg as isAggregateDefinition, sh as isCostBudgetDefinition, kg as isEmptyTenantScopedRead, Um as isExpectationDefinition, bh as isExperimentDefinition, Xn as isForeignKeyViolation, Hh as isIdleNow, ls as isInfraError, va as isObservingGraph, Ag as isOrglessUserSubject, Zn as isQueryTimeout, yp as isSafeToApply, _f as isScheduleDefinition, $d as isSoftDelete, ao as isStateChangingMethod, Eo as isTrustedProxy, $c as isWorkflowEventTriggerDefinition, ir as isolateRawReadScope, Cm as ivmValue, s_ as lastWriteProvenance, ru as listConnectionStates, Ku as listResourcePolicies, me as listRetentionConflicts, he as listRetentions, Am as loadResourceTuples, Nm as loadSubjectTuples, pf as localityAwareSelector, n_ as makeActionRunner, Wf as makeAdvisoryLockCoordinator, aa as makeAesCipher, _c as makeApiKeyService, yd as makeApiKeyUsageBuffer, xc as makeApiKeyUsageFlusher, Qn as makeAppAccess, Yp as makeApprovalGate, uc as makeAsyncKv, ff as makeAuthMiddlewareLayers, vl as makeBufferGapDetector, Ws as makeBufferingSpanProcessor, Jl as makeConnectionRegistry, Nu as makeConnectionResolver, Pu as makeConnectionsFacade, $f as makeCoordinatedScheduler, dd as makeDataLoader, Bu as makeDisconnectConnectionExecutor, Ac as makeEffectStoreLayer, ml as makeEventPublisher, al as makeEventsFacade, oa as makeFieldCipher, Ma as makeFluentStore, Uh as makeIdleGate, Jc as makeLazyWorkflowFacade, Lu as makeListConnectionsExecutor, ms as makeMutationOutputCodec, qg as makeMutationRunner, e_ as makeOneShotQueryRunner, co as makeOriginGuardExemption, jl as makeOutboxFacade, Kc as makePostCommitWorkflowFacade, zh as makeProcessAdapter, $g as makeQueryDescriptorProducer, Mg as makeQueryFinalizer, Zg as makeQueryReauthorizer, t_ as makeQuerySubscriber, Wh as makeRouterActivity, fp as makeRuleCapture, Td as makeSchemaRegistry, Ru as makeStartConnectionExecutor, zu as makeSubmitTokenExecutor, lp as makeUndoCapture, Gh as makeWakeGate, Jh as makeWakeProxyServer, Gc as makeWorkflowFacade, qc as makeWorkflowFacadeWithCallerContext, Yc as makeWorkflowHandlers, Xc as makeWorkflowLayers, Rc as makeWorkflowRunHandle, Df as markWakeupFired, Tm as materializeIvm, vc as memoryApiKeyStore, hf as memoryReplicationAdapter, qa as memoryRywPositionStore, Hi as mergeCookieHeader, Qf as nextDelay, xf as nextFiring, Pf as nextWakeup, Vh as nodeProcessSupervisor, ag as noopAnalytics, cg as noopAnalyticsSpec, dc as noopKv, yo as normalizeIp, uo as normalizeOrigin, Ca as observeStore, xa as observedGraph, Ss as onProcessShutdown, Ns as otelImportFailure, Ol as outboxAttemptsTable, Tl as outboxTable, Jp as parseApprovalInterval, Zi as parseTraceparent, Uc as payloadPropertyNames, nm as pendingApprovalsFor, Ga as powerOfTwoSelector, p_ as previewInRollback, Ql as projectConnectionState, If as pruneWakeups, fl as publishEvent, cr as rawSqlPreview, Xf as readPollCeilingMs, Ju as rebacPolicyGraph, Li as recordCredentialExpiry, Kr as recordEventDelivered, qr as recordEventDropped, Gr as recordEventPublished, Jr as recordEventSubscribers, ar as recordRawRead, Yr as recordSample, ei as recordScheduleRun, $r as recordSubscriptionActive, Zr as recordSubscriptionDelivery, ba as recordTableAccess, _m as recordTimelineEvent, ti as recordWorkflowRun, Id as redactColumns, um as redactRow, Ya as redisRywPositionStore, Mp as redoUndoInvocation, su as refreshAccessToken, Gi as registerConnectionStream, Ee as registerRetention, Tf as registerWakeup, Rp as rehydrateGuards, Af as releaseWakeup, Ka as replicaHealth, $o as resetComputedQueryCacheWarnings, Ur as resetEventMetricTagCacheForTests, Sa as resetObservedGraph, Js as resetSecretsBackend, Oo as resolveClientAddress, _u as resolveConnection, Mu as resolveConnectionForSubject, mf as resolveCurrentRegion, lr as resolveDependentTables, _o as resolveOriginGuardConfig, nr as resolveReactiveConfig, Tu as resolveRedirectUri, ko as resolveRequestIsHttps, Dm as resolveRescan, _i as resolveRowFilterScope, vi as resolveRowFilterScopeFor, Ys as resolveSecret, Xs as resolveSecretSync, $s as resolveSecretsBackend, Fo as resolveSecurityHeaders, sm as resolveTimelineMode, Do as resolveTrustedProxies, Ch as resultVariantNames, ke as retentionTtlMsFromEnv, fm as reverseEventOverRows, ed as revokedIds, hi as rowFilterRegistered, ef as rulesFor, df as runAsSystem, Xh as runOrchestratorTick, Pg as runProvidedEffect, Bm as runReaction, Zh as runSingleNodeOrchestrator, Rh as runWakeLoop, Kg as runWithDeadlockRetry, ya as runWithObservedProcedure, sr as runWithRawReadScope, id as runWithRequestLoader, Qa as runWithRoutingContext, ea as runWithTraceContext, wu as sanitizeRedirectTo, Zf as scheduleCoordinated, Vd as schemaPropertyNames, zp as scopeStringsOf, Io as securityHeadersFor, Lp as serializeGuards, Si as serverOnlyColumnNames, Ud as serverOnlyLeaks, Au as setConnectionResolver, ca as setFieldCipher, pi as setRowFilter, qs as setSecretsBackend, cf as setSystemStoreHandle, gm as setTimelineRecorderForTest, sd as setTupleSource, En as settleHandlerBody, pc as sha256Hex, Es as shutdownGraceMsFromEnv, zf as singleCoordinator, oi as snapshotMetrics, si as snapshotMetricsSync, vd as ssrfGuardHttpClientLayer, _d as ssrfReason, vs as startRpcServer, Kf as startScheduler, eu as storeCredential, Ci as stripColumnsFromRows, Ei as stripForbiddenForWire, wi as stripServerOnlyForWire, Ou as sweepExpiredGrants, Le as sweepRetention, _p as synthesizeInverse, fd as tracingHttpClientLayer, Zc as triggerWorkflow, kf as tryClaimWakeup, Vi as unbindConnection, ip as undoCaptureEnabled, kp as undoLogExecutor, ap as undoSurfaceEnabled, Jd as unresolvedSources, Dg as useAggregate, rg as useAnalytics, lh as useCostBudget, Gm as useExpectation, Th as useExperiment, $u as visibleRows, Lh as wakeDueOnce, zo as webhookVerificationOf, Rg as withRowFilter, Qg as withScopedRequest, jc as workflowToRpc, cp as wrapCaptureStore, Md as wrapStoreWithBootCodec, Wa as wrapStoreWithMixinBehaviour };
|
|
9976
|
+
export { Ao as API_CSP, fc as API_KEYS_TABLE, Pp as APPROVALS_TABLE, Hu as AccessDenied, Eg as AggregateError, km as AggregateMaintainer, Tg as AggregateNotFound, Dg as AggregateRegistry, wg as AggregateStale, tg as AnalyticsCapabilityNotSupported, eg as AnalyticsError, ng as AnalyticsSink, Uf as CLAIM_RETENTION_BUCKETS, Y as CONNECTIONS_TABLE, Vl as CONNECTION_GRANTS_TABLE, sf as CircuitBreaker, af as CircuitOpen, uu as ConnectionNotConnected, gh as CostAccountant, lh as CostRegistry, gg as DEFAULT_ANALYTICS_MIRROR_TUNABLES, Fp as DEFAULT_APPROVAL_EXPIRY_MS, Hf as DEFAULT_CLAIM_BUCKET_MS, $n as DEFAULT_DELIVERY_CONCURRENCY, Mo as DEFAULT_HSTS, Xf as DEFAULT_MAX_IDLE_INTERVAL_MS, _s as DEFAULT_MAX_RPC_BODY_BYTES, er as DEFAULT_RAW_READ_TRACKING_LIMIT, cu as DEFAULT_REFRESH_SKEW_MS, li as DEFAULT_ROW_FILTER_RETRY, zf as DORMANCY_WAKEUP_TENANT, ja as DeleteBuilder, ki as Dispatcher, hl as EVENT_CLIENT_QUEUE_SIZE, gl as EVENT_LATEST_QUEUE_SIZE, Dc as EffectStore, ul as EventBus, th as ExpectationEvaluator, Gm as ExpectationRegistry, Fh as ExperimentEvaluator, Th as ExperimentRegistry, Su as GRANT_TTL_MS, vh as HOLDOUT_VARIANT, jo as HTML_CSP, qn as InMemoryDataStore, Pn as IndexedMatcher, Sl as InstanceMembership, Dn as LinearScanMatcher, p as MetricBoundaries, ag as NOOP_ANALYTICS_PROVIDER, gi as NO_ROW_FILTER, vo as NO_TRUSTED_PROXIES, wa as NoRowFound, El as OUTBOX_ATTEMPTS_TABLE, Nl as OUTBOX_ATTEMPT_LOG_CAP, J as OUTBOX_TABLE, Ta as OptimisticLockError, Vu as REBAC_ADMIN_SCOPE, lu as REFRESH_LEASE_MS, h_ as RUNTIME_NAME, zm as ReactionRateLimiter, eo as ReplicatedDataStore, ci as RowFilterUnavailable, Rf as SCHEDULE_SUBJECT, Ec as SYSTEM_SUBJECT, ka as SelectBuilder, La as ServerOnlyColumnWrite, md as SsrfBlockedError, Pa as StoreOperationFailed, Ln as SubscriptionRegistry, Fa as TableValidationFailed, Ia as TenantRowNotFound, Na as TenantScopeViolation, mm as TimelineRecorder, yp as UndoBoundaryError, xp as UndoStack, Bo as UnverifiedWebhookRoute, Aa as UpdateBuilder, xd as VOLTRO_AUDIT_MIXIN_ID, Cd as VOLTRO_EXPIRES_MIXIN_ID, Td as VOLTRO_LOCAL_FIRST_MIXIN_ID, Sd as VOLTRO_SOFT_DELETE_MIXIN_ID, wd as VOLTRO_TENANT_MIXIN_ID, Lo as WEBHOOK_VERIFICATION_PROPERTY, Pc as WorkflowDeferredResultError, Hc as WorkflowPayloadError, Fc as WorkflowRateLimitedError, Ic as WorkflowSingletonHeldError, qi as _connectionStreamCount, Ji as _resetConnectionCredentialsForTest, Ip as _voltroApprovalsTable, Ul as _voltroConnectionGrantsTable, Bl as _voltroConnectionsTable, Am as _voltroRebacTuplesTable, np as _voltroScheduleClaimsTable, tp as _voltroScheduleRunsTable, rp as _voltroTracesTable, ip as _voltroUndoLogTable, Lh as _voltroWakeupsTable, il as _voltroWorkflowEventDeliveriesTable, rl as _voltroWorkflowEventsTable, Ua as actingUserId, Tc as apiKeyManagementRoutes, Ui as applyConnectionCredential, Ba as applyDefined, Dm as applyDelta, Cp as applyInverse, wp as applyInverses, nf as applyPluginRefRules, bi as applyRowFilter, xi as applyRowFilterToDescriptor, Mg as applySoftDeleteScope, kg as applyTenantScope, Mp as applyUndoInvocation, Hp as approvalIntentKey, im as approvalNonce, om as approvalsPendingExecutor, Qu as assertCan, ql as assertConnectionCipherConfigured, Vo as assertWebhookRoutesDeclareVerification, Ch as assignVariant, xg as attachAnalyticsMirror, nh as attachExpectations, Ih as attachExperiments, _h as attachFinops, ks as awaitServerListening, Ml as backoffMs, Eu as beginOAuthConnect, zi as bindConnectionCredential, yl as bindEvent, gs as bindMutation, rs as bindStream, ns as bindSubscription, Zo as bindSubscriptionUntyped, Tm as buildIvmState, f_ as buildPreview, Nm as buildRebacInterceptor, Fm as buildRebacReadFilter, Ja as buildSubjectKey, Is as buildTracingLayer, Kd as cacheScopeLeaks, Zs as cachedBackend, Zu as can, Df as cancelWakeup, Vp as canonicalJson, Fn as canonicalize, Wf as claimGraceMs, go as classifyRequestOrigin, bm as classifyShape, em as clearApprovalGate, mu as clearConnectionRefreshFlights, qu as clearResourcePolicies, ee as clearRetentions, uf as clearSystemStoreHandle, rf as collectPluginRefRules, xf as compileCron, Du as completeOAuthConnect, cg as composeAnalytics, sg as composeAnalyticsSinks, Cu as connectionCallbackPath, Kl as connectionLabel, Xh as countRunningWorkflows, ni as counter, Cf as cronOccurrences, Vd as crud, or as currentRawReads, rd as currentRequestLoader, $a as currentRoutingContext, ta as currentTraceContext, Sc as dataStoreApiKeyStore, ic as dataStoreIdempotencyStore, lc as dataStoreKvStore, nm as decideApproval, sm as decideApprovalInvocation, da as decryptField, fs as defectMessage, Sg as defineAggregate, Gl as defineConnection, sh as defineCostBudget, Qc as defineEventTrigger, Pg as defineExecutor, Um as defineExpectation, bh as defineExperiment, kl as defineOutboxHandler, Im as defineReaction, Wu as defineResourcePolicy, bf as defineSchedule, $h as defineSubscriber, Di as deliveredRowCount, ia as deriveKey, d_ as diffChange, Ds as drainForShutdown, Ll as drainOutbox, Pf as dueWakeups, Xu as effectiveRelations, jd as emptySchemaRegistry, _a as enableGraphObservation, ua as encryptField, tm as enforceApproval, nd as enterRequestLoader, Gs as envSecretsBackend, hp as evaluateTouchedRules, Wr as eventMetricTagCacheSizeForTests, ou as exchangeAuthorizationCode, Qi as externalSpanFromTraceparent, Yn as extractDbCause, In as fingerprintFor, Ti as forbiddenColumnsForSubject, nu as forgetCredential, qd as formatCacheScopeLeaks, Gd as formatServerOnlyLeaks, Xi as formatTraceparent, Xd as formatUnresolvedSources, Sp as forwardChangeFromCdc, Cc as frameworkApiKeyStrategy, ri as gauge, mc as generateApiKeyToken, $p as getApprovalGate, Bi as getConnectionCredential, ju as getConnectionResolver, Ri as getCredentialExpiry, K as getFieldCipher, Gu as getResourcePolicy, mi as getRowFilter, df as getSystemStoreHandle, gm as getTimelineRecorder, cd as getTupleSource, Sm as groupKeyOf, Sh as hashUnitInterval, ii as histogramMetric, l_ as historyProvenance, Qs as httpSecretsBackend, Cn as inspectWorkflow, Qp as installApprovalGate, ud as installPolicyGuardResolver, Ki as interruptConnectionStreams, _p as invertChange, So as ipToBytes, Cg as isAggregateDefinition, ch as isCostBudgetDefinition, Ag as isEmptyTenantScopedRead, Wm as isExpectationDefinition, xh as isExperimentDefinition, Xn as isForeignKeyViolation, Uh as isIdleNow, ls as isInfraError, va as isObservingGraph, jg as isOrglessUserSubject, Zn as isQueryTimeout, bp as isSafeToApply, vf as isScheduleDefinition, ef as isSoftDelete, ao as isStateChangingMethod, Eo as isTrustedProxy, $c as isWorkflowEventTriggerDefinition, ir as isolateRawReadScope, wm as ivmValue, c_ as lastWriteProvenance, ru as listConnectionStates, Ku as listResourcePolicies, pe as listRetentionConflicts, me as listRetentions, jm as loadResourceTuples, Pm as loadSubjectTuples, mf as localityAwareSelector, r_ as makeActionRunner, Gf as makeAdvisoryLockCoordinator, aa as makeAesCipher, _c as makeApiKeyService, bd as makeApiKeyUsageBuffer, xc as makeApiKeyUsageFlusher, Qn as makeAppAccess, Xp as makeApprovalGate, uc as makeAsyncKv, pf as makeAuthMiddlewareLayers, vl as makeBufferGapDetector, Ws as makeBufferingSpanProcessor, Jl as makeConnectionRegistry, Nu as makeConnectionResolver, Pu as makeConnectionsFacade, ep as makeCoordinatedScheduler, fd as makeDataLoader, Bu as makeDisconnectConnectionExecutor, Ac as makeEffectStoreLayer, ml as makeEventPublisher, al as makeEventsFacade, oa as makeFieldCipher, Ma as makeFluentStore, Wh as makeIdleGate, Jc as makeLazyWorkflowFacade, Lu as makeListConnectionsExecutor, ms as makeMutationOutputCodec, Jg as makeMutationRunner, t_ as makeOneShotQueryRunner, co as makeOriginGuardExemption, jl as makeOutboxFacade, Kc as makePostCommitWorkflowFacade, Bh as makeProcessAdapter, e_ as makeQueryDescriptorProducer, Ng as makeQueryFinalizer, Qg as makeQueryReauthorizer, n_ as makeQuerySubscriber, Gh as makeRouterActivity, pp as makeRuleCapture, Ed as makeSchemaRegistry, Ru as makeStartConnectionExecutor, zu as makeSubmitTokenExecutor, up as makeUndoCapture, Kh as makeWakeGate, Yh as makeWakeProxyServer, Gc as makeWorkflowFacade, qc as makeWorkflowFacadeWithCallerContext, Yc as makeWorkflowHandlers, Xc as makeWorkflowLayers, Rc as makeWorkflowRunHandle, Of as markWakeupFired, Em as materializeIvm, vc as memoryApiKeyStore, gf as memoryReplicationAdapter, qa as memoryRywPositionStore, Hi as mergeCookieHeader, $f as nextDelay, Sf as nextFiring, Ff as nextWakeup, Hh as nodeProcessSupervisor, og as noopAnalytics, lg as noopAnalyticsSpec, dc as noopKv, yo as normalizeIp, uo as normalizeOrigin, Ca as observeStore, xa as observedGraph, Ss as onProcessShutdown, Ns as otelImportFailure, Ol as outboxAttemptsTable, Tl as outboxTable, Yp as parseApprovalInterval, Zi as parseTraceparent, Uc as payloadPropertyNames, rm as pendingApprovalsFor, Ga as powerOfTwoSelector, m_ as previewInRollback, Ql as projectConnectionState, Lf as pruneWakeups, fl as publishEvent, cr as rawSqlPreview, Zf as readPollCeilingMs, Ju as rebacPolicyGraph, Li as recordCredentialExpiry, Kr as recordEventDelivered, qr as recordEventDropped, Gr as recordEventPublished, Jr as recordEventSubscribers, ar as recordRawRead, Yr as recordSample, ei as recordScheduleRun, $r as recordSubscriptionActive, Zr as recordSubscriptionDelivery, ba as recordTableAccess, vm as recordTimelineEvent, ti as recordWorkflowRun, Ld as redactColumns, dm as redactRow, Ya as redisRywPositionStore, Np as redoUndoInvocation, su as refreshAccessToken, Gi as registerConnectionStream, ld as registerDefaultTupleSource, Te as registerRetention, Ef as registerWakeup, zp as rehydrateGuards, jf as releaseWakeup, Ka as replicaHealth, $o as resetComputedQueryCacheWarnings, Ur as resetEventMetricTagCacheForTests, Sa as resetObservedGraph, Js as resetSecretsBackend, Oo as resolveClientAddress, _u as resolveConnection, Mu as resolveConnectionForSubject, hf as resolveCurrentRegion, lr as resolveDependentTables, _o as resolveOriginGuardConfig, nr as resolveReactiveConfig, Tu as resolveRedirectUri, ko as resolveRequestIsHttps, Om as resolveRescan, _i as resolveRowFilterScope, vi as resolveRowFilterScopeFor, Ys as resolveSecret, Xs as resolveSecretSync, $s as resolveSecretsBackend, Fo as resolveSecurityHeaders, cm as resolveTimelineMode, Do as resolveTrustedProxies, wh as resultVariantNames, Oe as retentionTtlMsFromEnv, pm as reverseEventOverRows, ed as revokedIds, hi as rowFilterRegistered, tf as rulesFor, ff as runAsSystem, Zh as runOrchestratorTick, Fg as runProvidedEffect, Vm as runReaction, Qh as runSingleNodeOrchestrator, zh as runWakeLoop, qg as runWithDeadlockRetry, ya as runWithObservedProcedure, sr as runWithRawReadScope, id as runWithRequestLoader, Qa as runWithRoutingContext, ea as runWithTraceContext, wu as sanitizeRedirectTo, Qf as scheduleCoordinated, Hd as schemaPropertyNames, Bp as scopeStringsOf, Io as securityHeadersFor, Rp as serializeGuards, Si as serverOnlyColumnNames, Wd as serverOnlyLeaks, Au as setConnectionResolver, ca as setFieldCipher, pi as setRowFilter, qs as setSecretsBackend, lf as setSystemStoreHandle, _m as setTimelineRecorderForTest, sd as setTupleSource, En as settleHandlerBody, pc as sha256Hex, Es as shutdownGraceMsFromEnv, Bf as singleCoordinator, oi as snapshotMetrics, si as snapshotMetricsSync, yd as ssrfGuardHttpClientLayer, vd as ssrfReason, vs as startRpcServer, qf as startScheduler, eu as storeCredential, Ci as stripColumnsFromRows, Ei as stripForbiddenForWire, wi as stripServerOnlyForWire, Ou as sweepExpiredGrants, Ie as sweepRetention, vp as synthesizeInverse, pd as tracingHttpClientLayer, Zc as triggerWorkflow, Af as tryClaimWakeup, Vi as unbindConnection, ap as undoCaptureEnabled, Ap as undoLogExecutor, op as undoSurfaceEnabled, Yd as unresolvedSources, Og as useAggregate, ig as useAnalytics, uh as useCostBudget, Km as useExpectation, Eh as useExperiment, $u as visibleRows, Rh as wakeDueOnce, zo as webhookVerificationOf, zg as withRowFilter, $g as withScopedRequest, jc as workflowToRpc, lp as wrapCaptureStore, Nd as wrapStoreWithBootCodec, Wa as wrapStoreWithMixinBehaviour };
|