@voltro/runtime 0.7.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -0
- package/dist/index.d.ts +18 -1
- package/dist/index.js +740 -740
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -3,22 +3,22 @@ import { createCipheriv as ue, createDecipheriv as de, createHash as fe, randomB
|
|
|
3
3
|
import { EventEmitter as ge } from "node:events";
|
|
4
4
|
import { ADMIN_SCOPE as _e, ConnectionHandshakeFailed as k, ConnectionInfo as ve, ConnectionKindMismatch as ye, ConnectionNotDeclared as be, ConnectionSubjectRequired as xe, SubjectService as Se, UndoConflict as Ce, UndoForbidden as we, UndoNotFound as Te, WorkflowRunHandleSchema as Ee, checkGuardsEffect as De, diffRows as Oe, effectiveScopes as ke, hasEffectiveScope as Ae, isIdKeyed as je, publishServerError as Me, requireScope as Ne, setPolicyGuardResolver as Pe, systemSubject as Fe, tsMs as Ie } from "@voltro/protocol";
|
|
5
5
|
import { createLogger as A } from "@voltro/logger";
|
|
6
|
-
import { Cause as j, Clock as Le, Context as Re, Cron as
|
|
7
|
-
import * as
|
|
8
|
-
import { createServer as
|
|
9
|
-
import { HttpClient as
|
|
10
|
-
import { NodeContext as
|
|
11
|
-
import { Rpc as
|
|
12
|
-
import { defineRestRoute as
|
|
13
|
-
import { AsyncLocalStorage as
|
|
14
|
-
import { SpanKind as
|
|
15
|
-
import { Kv as
|
|
16
|
-
import { apiKeyStrategy as
|
|
17
|
-
import { getCurrentWorkflowExecutionId as
|
|
18
|
-
import { ArrayFormatter as
|
|
19
|
-
import { spawn as
|
|
6
|
+
import { Cause as j, Clock as Le, Context as Re, Cron as ze, Deferred as Be, Duration as Ve, Effect as M, Either as He, Exit as Ue, Layer as N, ManagedRuntime as We, Metric as P, MetricBoundaries as Ge, MetricState as Ke, Option as F, Ref as I, Schedule as qe, Schema as L, Stream as R, Tracer as Je } from "effect";
|
|
7
|
+
import * as Ye from "node:http";
|
|
8
|
+
import { createServer as Xe } from "node:http";
|
|
9
|
+
import { HttpClient as Ze, HttpClientRequest as Qe, HttpLayerRouter as z, HttpServer as $e, HttpServerRequest as et, HttpServerResponse as B } from "@effect/platform";
|
|
10
|
+
import { NodeContext as tt, NodeHttpServer as nt, NodeRuntime as rt } from "@effect/platform-node";
|
|
11
|
+
import { Rpc as it, RpcSerialization as at, RpcServer as ot } from "@effect/rpc";
|
|
12
|
+
import { defineRestRoute as st, dispatchSharedPath as ct, requireScope as lt } from "@voltro/protocol/rest";
|
|
13
|
+
import { AsyncLocalStorage as ut } from "node:async_hooks";
|
|
14
|
+
import { SpanKind as dt, SpanStatusCode as ft } from "@opentelemetry/api";
|
|
15
|
+
import { Kv as pt, KvError as mt, KvStore as ht, layerConnections as gt, layerMemory as _t, layerRedis as vt } from "@voltro/kv";
|
|
16
|
+
import { apiKeyStrategy as yt } from "@voltro/protocol/apikey";
|
|
17
|
+
import { getCurrentWorkflowExecutionId as bt, inspectWorkflow as xt } from "@voltro/workflow";
|
|
18
|
+
import { ArrayFormatter as St } from "effect/ParseResult";
|
|
19
|
+
import { spawn as Ct } from "node:child_process";
|
|
20
20
|
//#region src/matcher.ts
|
|
21
|
-
var
|
|
21
|
+
var wt = class {
|
|
22
22
|
byTable = /* @__PURE__ */ new Map();
|
|
23
23
|
register(e) {
|
|
24
24
|
let t = this.byTable.get(e.table);
|
|
@@ -59,7 +59,7 @@ var Ct = class {
|
|
|
59
59
|
});
|
|
60
60
|
return { perTable: e };
|
|
61
61
|
}
|
|
62
|
-
},
|
|
62
|
+
}, Tt = (e) => {
|
|
63
63
|
let t = [];
|
|
64
64
|
for (let n of le(e)) n.conjunctive && n.path === void 0 && (n.op === "eq" && t.push({
|
|
65
65
|
column: n.column,
|
|
@@ -69,7 +69,7 @@ var Ct = class {
|
|
|
69
69
|
values: n.value
|
|
70
70
|
}));
|
|
71
71
|
return t;
|
|
72
|
-
},
|
|
72
|
+
}, Et = (e) => {
|
|
73
73
|
let t = [];
|
|
74
74
|
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({
|
|
75
75
|
column: n.column,
|
|
@@ -77,10 +77,10 @@ var Ct = class {
|
|
|
77
77
|
threshold: n.value
|
|
78
78
|
});
|
|
79
79
|
return t;
|
|
80
|
-
},
|
|
80
|
+
}, Dt = (e, t) => {
|
|
81
81
|
for (let n of le(e)) if (n.conjunctive && n.path === void 0 && n.op === "eq" && n.column === t) return n.value;
|
|
82
82
|
return null;
|
|
83
|
-
},
|
|
83
|
+
}, Ot = (e, t) => {
|
|
84
84
|
let n = [];
|
|
85
85
|
for (let r of e) {
|
|
86
86
|
let e = t(r);
|
|
@@ -88,8 +88,8 @@ var Ct = class {
|
|
|
88
88
|
n.push(`${typeof e}:${String(e)}`);
|
|
89
89
|
}
|
|
90
90
|
return n.join("|");
|
|
91
|
-
},
|
|
92
|
-
let r =
|
|
91
|
+
}, kt = (e, t) => e === null || t === null ? null : e === t ? 0 : typeof e == typeof t ? e > t ? 1 : -1 : null, At = (e, t, n) => {
|
|
92
|
+
let r = kt(e, n);
|
|
93
93
|
if (r === null) return !1;
|
|
94
94
|
switch (t) {
|
|
95
95
|
case "gt": return r > 0;
|
|
@@ -97,7 +97,7 @@ var Ct = class {
|
|
|
97
97
|
case "lt": return r < 0;
|
|
98
98
|
case "lte": return r <= 0;
|
|
99
99
|
}
|
|
100
|
-
},
|
|
100
|
+
}, jt = class {
|
|
101
101
|
columnByTable = /* @__PURE__ */ new Map();
|
|
102
102
|
rangeByTable = /* @__PURE__ */ new Map();
|
|
103
103
|
tupleByTable = /* @__PURE__ */ new Map();
|
|
@@ -105,9 +105,9 @@ var Ct = class {
|
|
|
105
105
|
subscriptions = /* @__PURE__ */ new Map();
|
|
106
106
|
register(e) {
|
|
107
107
|
this.columnByTable.has(e.table) || this.columnByTable.set(e.table, /* @__PURE__ */ new Map()), this.rangeByTable.has(e.table) || this.rangeByTable.set(e.table, /* @__PURE__ */ new Map()), this.tupleByTable.has(e.table) || this.tupleByTable.set(e.table, /* @__PURE__ */ new Map()), this.unindexedByTable.has(e.table) || this.unindexedByTable.set(e.table, /* @__PURE__ */ new Set());
|
|
108
|
-
let t =
|
|
108
|
+
let t = Tt(e.predicate), n = Et(e.predicate);
|
|
109
109
|
if (e.usingIndex !== void 0) {
|
|
110
|
-
let r = e.usingIndex, i =
|
|
110
|
+
let r = e.usingIndex, i = Ot(r.fields, (t) => Dt(e.predicate, t));
|
|
111
111
|
if (i !== null) {
|
|
112
112
|
let a = `${r.name}|${i}`, o = this.tupleByTable.get(e.table), s = o.get(a);
|
|
113
113
|
s || (s = /* @__PURE__ */ new Set(), o.set(a, s)), s.add(e.id), this.subscriptions.set(e.id, {
|
|
@@ -252,7 +252,7 @@ var Ct = class {
|
|
|
252
252
|
}
|
|
253
253
|
}
|
|
254
254
|
for (let [e, a] of i) {
|
|
255
|
-
let i =
|
|
255
|
+
let i = Ot(a, (e) => t[e]);
|
|
256
256
|
if (i === null) continue;
|
|
257
257
|
let o = r.get(`${e}|${i}`);
|
|
258
258
|
if (o) for (let e of o) n.add(e);
|
|
@@ -266,7 +266,7 @@ var Ct = class {
|
|
|
266
266
|
let a = this.rangeByTable.get(e);
|
|
267
267
|
if (a) for (let [e, r] of a) {
|
|
268
268
|
let i = t[e];
|
|
269
|
-
if (i !== null) for (let [e, t] of r) for (let r of t)
|
|
269
|
+
if (i !== null) for (let [e, t] of r) for (let r of t) At(i, e, r.threshold) && n.add(r.subId);
|
|
270
270
|
}
|
|
271
271
|
return n;
|
|
272
272
|
}
|
|
@@ -275,7 +275,7 @@ var Ct = class {
|
|
|
275
275
|
let e = t[n.column];
|
|
276
276
|
if (n.kind === "eq") {
|
|
277
277
|
if (e !== n.value) return !1;
|
|
278
|
-
} else if (!
|
|
278
|
+
} else if (!At(e, n.op, n.threshold)) return !1;
|
|
279
279
|
}
|
|
280
280
|
return !0;
|
|
281
281
|
}
|
|
@@ -297,23 +297,23 @@ var Ct = class {
|
|
|
297
297
|
}
|
|
298
298
|
return i;
|
|
299
299
|
}
|
|
300
|
-
},
|
|
300
|
+
}, Mt = (e) => {
|
|
301
301
|
if (e == null) return null;
|
|
302
|
-
if (Array.isArray(e)) return e.map(
|
|
302
|
+
if (Array.isArray(e)) return e.map(Mt);
|
|
303
303
|
if (typeof e == "object") {
|
|
304
304
|
let t = e, n = Object.keys(t).sort(), r = {};
|
|
305
|
-
for (let e of n) r[e] =
|
|
305
|
+
for (let e of n) r[e] = Mt(t[e]);
|
|
306
306
|
return r;
|
|
307
307
|
}
|
|
308
308
|
return e;
|
|
309
|
-
},
|
|
310
|
-
let r =
|
|
309
|
+
}, Nt = (e, t, n) => {
|
|
310
|
+
let r = Mt({
|
|
311
311
|
table: e,
|
|
312
312
|
predicate: t,
|
|
313
313
|
indexHint: n ?? null
|
|
314
314
|
});
|
|
315
315
|
return fe("sha256").update(JSON.stringify(r)).digest("hex").slice(0, 16);
|
|
316
|
-
},
|
|
316
|
+
}, Pt = class {
|
|
317
317
|
matcher;
|
|
318
318
|
byFingerprint = /* @__PURE__ */ new Map();
|
|
319
319
|
byClient = /* @__PURE__ */ new Map();
|
|
@@ -332,7 +332,7 @@ var Ct = class {
|
|
|
332
332
|
} catch {}
|
|
333
333
|
}
|
|
334
334
|
subscribe(e, t, n, r) {
|
|
335
|
-
let i =
|
|
335
|
+
let i = Nt(t, n, r?.name), a = this.byFingerprint.get(i);
|
|
336
336
|
return a ? (a.subscribers.add(e), this.byClient.set(e, i), this.notifyChange(), {
|
|
337
337
|
fingerprint: i,
|
|
338
338
|
deduplicated: !0
|
|
@@ -390,7 +390,7 @@ var Ct = class {
|
|
|
390
390
|
});
|
|
391
391
|
return e;
|
|
392
392
|
}
|
|
393
|
-
},
|
|
393
|
+
}, Ft = (e, t) => t.length === 0 ? e : [...e].sort((e, n) => {
|
|
394
394
|
for (let r of t) {
|
|
395
395
|
let t = e[r.column], i = n[r.column];
|
|
396
396
|
if (t === i) continue;
|
|
@@ -400,7 +400,7 @@ var Ct = class {
|
|
|
400
400
|
return r.direction === "asc" ? a : -a;
|
|
401
401
|
}
|
|
402
402
|
return 0;
|
|
403
|
-
}),
|
|
403
|
+
}), It = (e, t, n) => {
|
|
404
404
|
let r = t.split("."), i = r[0], a = r.slice(1), o = (e) => typeof e == "object" && !!e && !Array.isArray(e), s = e[i], c;
|
|
405
405
|
if (a.length === 0) c = o(s) && o(n) ? {
|
|
406
406
|
...s,
|
|
@@ -418,11 +418,11 @@ var Ct = class {
|
|
|
418
418
|
...e,
|
|
419
419
|
[i]: c
|
|
420
420
|
};
|
|
421
|
-
},
|
|
421
|
+
}, Lt = (e, t, n) => !e || d(e, t, n), V = (e, t) => {
|
|
422
422
|
let n = /* @__PURE__ */ new Map();
|
|
423
423
|
if (!e) return n;
|
|
424
424
|
for (let r of a(e)) {
|
|
425
|
-
let e = t.get(r.descriptor.table) ?? /* @__PURE__ */ new Map(), i =
|
|
425
|
+
let e = t.get(r.descriptor.table) ?? /* @__PURE__ */ new Map(), i = V(r.descriptor.predicate, t), a = Rt(r.descriptor, e, t, i);
|
|
426
426
|
if (r.kind === "exists") n.set(r.descriptor, a.length);
|
|
427
427
|
else {
|
|
428
428
|
let e = r.descriptor.projection, t = /* @__PURE__ */ new Set();
|
|
@@ -437,15 +437,15 @@ var Ct = class {
|
|
|
437
437
|
}
|
|
438
438
|
}
|
|
439
439
|
return n;
|
|
440
|
-
},
|
|
441
|
-
let i = r ??
|
|
440
|
+
}, Rt = (e, t, n = /* @__PURE__ */ new Map(), r = null) => {
|
|
441
|
+
let i = r ?? V(e.predicate, n), a = [...t.values()].filter((t) => Lt(e.predicate, t, i));
|
|
442
442
|
if (e.aggregations && e.aggregations.length > 0) {
|
|
443
|
-
let t =
|
|
443
|
+
let t = zt(a, e.aggregations, e.groupBy);
|
|
444
444
|
if (!e.having) return t;
|
|
445
|
-
let r =
|
|
446
|
-
return t.filter((t) =>
|
|
445
|
+
let r = V(e.having, n);
|
|
446
|
+
return t.filter((t) => Lt(e.having, t, r));
|
|
447
447
|
}
|
|
448
|
-
let o =
|
|
448
|
+
let o = Ft(a, e.order), s = e.skip ? o.slice(e.skip) : o, c = e.take === void 0 ? s : s.slice(0, e.take);
|
|
449
449
|
if (!e.projection) return c;
|
|
450
450
|
let l = e.projection;
|
|
451
451
|
return c.map((e) => {
|
|
@@ -453,7 +453,7 @@ var Ct = class {
|
|
|
453
453
|
for (let n of l) t[n] = e[n];
|
|
454
454
|
return t;
|
|
455
455
|
});
|
|
456
|
-
},
|
|
456
|
+
}, zt = (e, t, n) => {
|
|
457
457
|
let r = /* @__PURE__ */ new Map();
|
|
458
458
|
for (let t of e) {
|
|
459
459
|
let e = {};
|
|
@@ -471,11 +471,11 @@ var Ct = class {
|
|
|
471
471
|
let i = [];
|
|
472
472
|
for (let e of r.values()) {
|
|
473
473
|
let n = { ...e.keyVals };
|
|
474
|
-
for (let r of t) n[r.alias] =
|
|
474
|
+
for (let r of t) n[r.alias] = Bt(r, e.rows);
|
|
475
475
|
i.push(n);
|
|
476
476
|
}
|
|
477
477
|
return i;
|
|
478
|
-
},
|
|
478
|
+
}, Bt = (e, t) => {
|
|
479
479
|
switch (e.op) {
|
|
480
480
|
case "count": return e.column === void 0 ? t.length : t.reduce((t, n) => t + +(n[e.column] !== null && n[e.column] !== void 0), 0);
|
|
481
481
|
case "count-distinct": {
|
|
@@ -519,7 +519,7 @@ var Ct = class {
|
|
|
519
519
|
}
|
|
520
520
|
default: throw Error(`computeAggregates: unknown op '${e.op}'`);
|
|
521
521
|
}
|
|
522
|
-
},
|
|
522
|
+
}, Vt = "\0", Ht = (e, t) => e === null ? t : `${e}${Vt}${t}`, Ut = class e {
|
|
523
523
|
#e;
|
|
524
524
|
#t;
|
|
525
525
|
#n;
|
|
@@ -535,7 +535,7 @@ var Ct = class {
|
|
|
535
535
|
let n = t.id;
|
|
536
536
|
n && e.set(n, t);
|
|
537
537
|
}
|
|
538
|
-
this.#e.set(
|
|
538
|
+
this.#e.set(Ht(t, n), e);
|
|
539
539
|
}
|
|
540
540
|
}
|
|
541
541
|
withNamespace(t) {
|
|
@@ -546,11 +546,11 @@ var Ct = class {
|
|
|
546
546
|
}, t);
|
|
547
547
|
}
|
|
548
548
|
#a(e) {
|
|
549
|
-
return
|
|
549
|
+
return Ht(this.#r, e);
|
|
550
550
|
}
|
|
551
551
|
#o() {
|
|
552
|
-
let e = /* @__PURE__ */ new Map(), t = this.#r === null ? null : `${this.#r}${
|
|
553
|
-
for (let [n, r] of this.#e) t === null ? n.includes(
|
|
552
|
+
let e = /* @__PURE__ */ new Map(), t = this.#r === null ? null : `${this.#r}${Vt}`;
|
|
553
|
+
for (let [n, r] of this.#e) t === null ? n.includes(Vt) || e.set(n, r) : n.startsWith(t) && e.set(n.slice(t.length), r);
|
|
554
554
|
return e;
|
|
555
555
|
}
|
|
556
556
|
#s(e) {
|
|
@@ -558,7 +558,7 @@ var Ct = class {
|
|
|
558
558
|
return n || (n = /* @__PURE__ */ new Map(), this.#e.set(t, n)), n;
|
|
559
559
|
}
|
|
560
560
|
async query(e) {
|
|
561
|
-
let t =
|
|
561
|
+
let t = Rt(e, this.#e.get(this.#a(e.table)) ?? /* @__PURE__ */ new Map(), this.#o());
|
|
562
562
|
return _(e) ? n(t, e.eager, ae(e.table), (e) => this.query(e)) : t;
|
|
563
563
|
}
|
|
564
564
|
async insert(e, t) {
|
|
@@ -588,7 +588,7 @@ var Ct = class {
|
|
|
588
588
|
if (!i) return null;
|
|
589
589
|
let a = i.get(t);
|
|
590
590
|
if (!a) return null;
|
|
591
|
-
let o =
|
|
591
|
+
let o = It(a, n, r);
|
|
592
592
|
return i.set(t, o), this.#t.emit("change", {
|
|
593
593
|
table: e,
|
|
594
594
|
op: "update",
|
|
@@ -630,7 +630,7 @@ var Ct = class {
|
|
|
630
630
|
async updateMany(e, t, n) {
|
|
631
631
|
let r = this.#e.get(this.#a(e));
|
|
632
632
|
if (!r) return 0;
|
|
633
|
-
let i =
|
|
633
|
+
let i = V(n.where, this.#o()), a = 0;
|
|
634
634
|
for (let [o, s] of r) {
|
|
635
635
|
if (!d(n.where, s, i)) continue;
|
|
636
636
|
let c = {
|
|
@@ -649,7 +649,7 @@ var Ct = class {
|
|
|
649
649
|
async deleteMany(e, t) {
|
|
650
650
|
let n = this.#e.get(this.#a(e));
|
|
651
651
|
if (!n) return 0;
|
|
652
|
-
let r =
|
|
652
|
+
let r = V(t.where, this.#o()), i = [];
|
|
653
653
|
for (let [e, a] of n) d(t.where, a, r) && i.push([e, a]);
|
|
654
654
|
for (let [t, r] of i) n.delete(t), this.#t.emit("change", {
|
|
655
655
|
table: e,
|
|
@@ -688,7 +688,7 @@ var Ct = class {
|
|
|
688
688
|
}
|
|
689
689
|
}
|
|
690
690
|
async transactional(e) {
|
|
691
|
-
let t = new
|
|
691
|
+
let t = new Wt(this.#u());
|
|
692
692
|
try {
|
|
693
693
|
let n = await e(t);
|
|
694
694
|
return t.commit(), n;
|
|
@@ -724,7 +724,7 @@ var Ct = class {
|
|
|
724
724
|
allocateNumericId: (e) => this.#c(e)
|
|
725
725
|
};
|
|
726
726
|
}
|
|
727
|
-
},
|
|
727
|
+
}, Wt = class {
|
|
728
728
|
parent;
|
|
729
729
|
overlay = /* @__PURE__ */ new Map();
|
|
730
730
|
tombstones = /* @__PURE__ */ new Map();
|
|
@@ -754,7 +754,7 @@ var Ct = class {
|
|
|
754
754
|
return t || (t = /* @__PURE__ */ new Map(), this.overlay.set(e, t)), t;
|
|
755
755
|
}
|
|
756
756
|
async query(e) {
|
|
757
|
-
let t = this.buildTablesView(e), r =
|
|
757
|
+
let t = this.buildTablesView(e), r = Rt(e, this.materialise(e.table), t);
|
|
758
758
|
return _(e) ? n(r, e.eager, ae(e.table), (e) => this.query(e)) : r;
|
|
759
759
|
}
|
|
760
760
|
async insert(e, t) {
|
|
@@ -793,7 +793,7 @@ var Ct = class {
|
|
|
793
793
|
async patchJson(e, t, n, r) {
|
|
794
794
|
let i = this.materialise(e).get(t);
|
|
795
795
|
if (!i) return null;
|
|
796
|
-
let a =
|
|
796
|
+
let a = It(i, n, r);
|
|
797
797
|
return this.getOrCreateOverlay(e).set(t, a), this.events.push({
|
|
798
798
|
table: e,
|
|
799
799
|
op: "update",
|
|
@@ -814,7 +814,7 @@ var Ct = class {
|
|
|
814
814
|
}), !0;
|
|
815
815
|
}
|
|
816
816
|
async updateMany(e, t, n) {
|
|
817
|
-
let r = this.materialise(e), i =
|
|
817
|
+
let r = this.materialise(e), i = V(n.where, this.buildTablesViewForPred(n.where)), a = 0;
|
|
818
818
|
for (let [o, s] of r) {
|
|
819
819
|
if (!d(n.where, s, i)) continue;
|
|
820
820
|
let r = {
|
|
@@ -831,7 +831,7 @@ var Ct = class {
|
|
|
831
831
|
return a;
|
|
832
832
|
}
|
|
833
833
|
async deleteMany(e, t) {
|
|
834
|
-
let n = this.materialise(e), r =
|
|
834
|
+
let n = this.materialise(e), r = V(t.where, this.buildTablesViewForPred(t.where)), i = 0, a = this.tombstones.get(e);
|
|
835
835
|
for (let [o, s] of n) d(t.where, s, r) && (this.overlay.get(e)?.delete(o), a || (a = /* @__PURE__ */ new Set(), this.tombstones.set(e, a)), a.add(o), this.events.push({
|
|
836
836
|
table: e,
|
|
837
837
|
op: "delete",
|
|
@@ -894,7 +894,7 @@ var Ct = class {
|
|
|
894
894
|
discard() {
|
|
895
895
|
this.settled || (this.settled = !0, this.overlay.clear(), this.tombstones.clear(), this.events.length = 0);
|
|
896
896
|
}
|
|
897
|
-
},
|
|
897
|
+
}, Gt = (e) => {
|
|
898
898
|
let t = {}, n = [], r = e;
|
|
899
899
|
for (let e = 0; e < 8 && typeof r == "object" && r; e++) {
|
|
900
900
|
let e = r;
|
|
@@ -905,23 +905,23 @@ var Ct = class {
|
|
|
905
905
|
(o || s) && n.push(`${o || "Error"}${s ? `: ${s.slice(0, 200)}` : ""}`), r = e.cause;
|
|
906
906
|
}
|
|
907
907
|
return n.length > 0 && (t.dbCauseChain = n.join(" ← "), t.dbMessage === void 0 && (t.dbMessage = n[n.length - 1])), t;
|
|
908
|
-
},
|
|
908
|
+
}, Kt = (e) => {
|
|
909
909
|
let t = e.dbCode;
|
|
910
910
|
return t === "23503" || e.dbErrno === 1452 || t === 547 || t === "SQLITE_CONSTRAINT_FOREIGNKEY";
|
|
911
|
-
},
|
|
911
|
+
}, qt = (e) => ({
|
|
912
912
|
has: (t) => Ae(e, t),
|
|
913
913
|
hasAny: (t) => t.some((t) => Ae(e, t)),
|
|
914
914
|
require: (t) => Ne(e, t),
|
|
915
915
|
get scopes() {
|
|
916
916
|
return ke(e);
|
|
917
917
|
}
|
|
918
|
-
}),
|
|
918
|
+
}), Jt = (e) => {
|
|
919
919
|
let t = /* @__PURE__ */ new Set();
|
|
920
|
-
return
|
|
921
|
-
},
|
|
922
|
-
if (t.add(e.table), e.eager !== void 0 &&
|
|
923
|
-
if (e.ctes !== void 0) for (let n of e.ctes)
|
|
924
|
-
},
|
|
920
|
+
return Yt(e, t), t;
|
|
921
|
+
}, Yt = (e, t) => {
|
|
922
|
+
if (t.add(e.table), e.eager !== void 0 && Xt(e.table, e.eager, t), e.setOp !== void 0) for (let n of e.setOp.queries) Yt(n, t);
|
|
923
|
+
if (e.ctes !== void 0) for (let n of e.ctes) Yt(n.descriptor, t);
|
|
924
|
+
}, Xt = (e, t, n) => {
|
|
925
925
|
let r = p(e);
|
|
926
926
|
if (r !== void 0) for (let [e, i] of Object.entries(t)) {
|
|
927
927
|
let t = r[e];
|
|
@@ -929,24 +929,24 @@ var Ct = class {
|
|
|
929
929
|
let a = i === !0 ? {} : i;
|
|
930
930
|
if (t.kind === "manyToMany") {
|
|
931
931
|
let e = t.through().tableName, r = t.target().tableName;
|
|
932
|
-
n.add(e), n.add(r), a.with !== void 0 &&
|
|
932
|
+
n.add(e), n.add(r), a.with !== void 0 && Xt(r, a.with, n);
|
|
933
933
|
} else {
|
|
934
934
|
let e = t.target().tableName;
|
|
935
|
-
n.add(e), a.with !== void 0 &&
|
|
935
|
+
n.add(e), a.with !== void 0 && Xt(e, a.with, n);
|
|
936
936
|
}
|
|
937
937
|
}
|
|
938
|
-
},
|
|
938
|
+
}, Zt = (e) => e.setOp !== void 0 || e.ctes !== void 0 && e.ctes.length > 0 || e.aggregations !== void 0 && e.aggregations.some((e) => e.op.startsWith("window-")), Qt = /* @__PURE__ */ new Set(["*"]), $t = (e, t) => {
|
|
939
939
|
if (e !== void 0) {
|
|
940
940
|
if ("not" in e) {
|
|
941
|
-
|
|
941
|
+
$t(e.not, t);
|
|
942
942
|
return;
|
|
943
943
|
}
|
|
944
944
|
if ("and" in e) {
|
|
945
|
-
for (let n of e.and)
|
|
945
|
+
for (let n of e.and) $t(n, t);
|
|
946
946
|
return;
|
|
947
947
|
}
|
|
948
948
|
if ("or" in e) {
|
|
949
|
-
for (let n of e.or)
|
|
949
|
+
for (let n of e.or) $t(n, t);
|
|
950
950
|
return;
|
|
951
951
|
}
|
|
952
952
|
if (e.op === "subquery-in" || e.op === "subquery-not-in") {
|
|
@@ -955,11 +955,11 @@ var Ct = class {
|
|
|
955
955
|
}
|
|
956
956
|
e.op === "exists" || e.op === "not-exists" || t.add(e.column);
|
|
957
957
|
}
|
|
958
|
-
},
|
|
958
|
+
}, H = (e, t, n) => {
|
|
959
959
|
let r = e.get(t);
|
|
960
960
|
r === void 0 && (r = /* @__PURE__ */ new Set(), e.set(t, r));
|
|
961
961
|
for (let e of n) r.add(e);
|
|
962
|
-
},
|
|
962
|
+
}, en = (e, t, n) => {
|
|
963
963
|
let r = p(e);
|
|
964
964
|
if (r !== void 0) for (let [i, a] of Object.entries(t)) {
|
|
965
965
|
let t = r[i];
|
|
@@ -967,65 +967,65 @@ var Ct = class {
|
|
|
967
967
|
let o = a === !0 ? {} : a;
|
|
968
968
|
if (t.kind === "manyToMany") {
|
|
969
969
|
let r = t.through(), i = t.target();
|
|
970
|
-
|
|
970
|
+
H(n, r.tableName, [t.sourceKey, t.targetKey]), H(n, e, ["id"]), H(n, i.tableName, ["id"]), tn(i.tableName, o, n), o.with !== void 0 && en(i.tableName, o.with, n);
|
|
971
971
|
continue;
|
|
972
972
|
}
|
|
973
973
|
let s = t.target();
|
|
974
|
-
t.foreignKey !== void 0 &&
|
|
974
|
+
t.foreignKey !== void 0 && H(n, s.tableName, [t.foreignKey]), t.sourceKey === void 0 ? H(n, e, ["id"]) : H(n, e, [t.sourceKey]), H(n, s.tableName, ["id"]), tn(s.tableName, o, n), o.with !== void 0 && en(s.tableName, o.with, n);
|
|
975
975
|
}
|
|
976
|
-
},
|
|
976
|
+
}, tn = (e, t, n) => {
|
|
977
977
|
if (t.where !== void 0) {
|
|
978
978
|
let r = /* @__PURE__ */ new Set();
|
|
979
|
-
|
|
979
|
+
$t(t.where, r), H(n, e, r);
|
|
980
980
|
}
|
|
981
|
-
t.orderBy !== void 0 &&
|
|
981
|
+
t.orderBy !== void 0 && H(n, e, t.orderBy.map((e) => e.column));
|
|
982
982
|
let r = m(e);
|
|
983
|
-
r === void 0 ?
|
|
984
|
-
},
|
|
983
|
+
r === void 0 ? H(n, e, ["*"]) : H(n, e, Object.keys(r.fields));
|
|
984
|
+
}, nn = (e) => {
|
|
985
985
|
let t = /* @__PURE__ */ new Map();
|
|
986
|
-
if (
|
|
987
|
-
for (let n of
|
|
986
|
+
if (Zt(e)) {
|
|
987
|
+
for (let n of Jt(e)) H(t, n, ["*"]);
|
|
988
988
|
return t;
|
|
989
989
|
}
|
|
990
990
|
let n = /* @__PURE__ */ new Set();
|
|
991
991
|
if (e.projection !== void 0) for (let t of e.projection) n.add(t);
|
|
992
992
|
else n.add("*");
|
|
993
|
-
|
|
993
|
+
$t(e.predicate, n);
|
|
994
994
|
for (let t of e.order) n.add(t.column);
|
|
995
|
-
return
|
|
996
|
-
},
|
|
997
|
-
if (e.op === "insert" || e.op === "delete" || e.old === null || e.new === null) return
|
|
995
|
+
return H(t, e.table, n), e.eager !== void 0 && en(e.table, e.eager, t), t;
|
|
996
|
+
}, rn = (e) => {
|
|
997
|
+
if (e.op === "insert" || e.op === "delete" || e.old === null || e.new === null) return Qt;
|
|
998
998
|
let t = /* @__PURE__ */ new Set(), n = e.old, r = e.new, i = /* @__PURE__ */ new Set([...Object.keys(n), ...Object.keys(r)]);
|
|
999
999
|
for (let e of i) Object.is(n[e], r[e]) || t.add(e);
|
|
1000
1000
|
return t;
|
|
1001
|
-
},
|
|
1001
|
+
}, an = (e, t) => {
|
|
1002
1002
|
let n = t.get(e.table);
|
|
1003
1003
|
if (n === void 0) return !1;
|
|
1004
1004
|
if (n.has("*")) return !0;
|
|
1005
|
-
let r =
|
|
1005
|
+
let r = rn(e);
|
|
1006
1006
|
if (r.has("*")) return !0;
|
|
1007
1007
|
for (let e of r) if (n.has(e)) return !0;
|
|
1008
1008
|
return !1;
|
|
1009
|
-
},
|
|
1009
|
+
}, on = Ge.exponential({
|
|
1010
1010
|
start: .001,
|
|
1011
1011
|
factor: 2,
|
|
1012
1012
|
count: 16
|
|
1013
|
-
}),
|
|
1014
|
-
let t = e.durationMs / 1e3, n = e.kind === "rpc" ?
|
|
1015
|
-
|
|
1016
|
-
},
|
|
1017
|
-
let t =
|
|
1018
|
-
|
|
1019
|
-
},
|
|
1020
|
-
let n =
|
|
1021
|
-
r === 0 ?
|
|
1022
|
-
},
|
|
1013
|
+
}), sn = P.counter("voltro_rpc_requests_total", { description: "Total RPC handler invocations." }), cn = P.counter("voltro_rpc_errors_total", { description: "RPC handler invocations that errored." }), ln = P.histogram("voltro_rpc_duration_seconds", on, "RPC handler duration in seconds."), un = P.counter("voltro_http_requests_total", { description: "Total HTTP route invocations." }), dn = P.histogram("voltro_http_duration_seconds", on, "HTTP route duration in seconds."), fn = P.histogram("voltro_plugin_hook_duration_seconds", on, "Plugin interceptor duration in seconds."), pn = P.counter("voltro_plugin_hook_errors_total", { description: "Plugin interceptor invocations that errored." }), mn = P.counter("voltro_subscription_deliveries_total", { description: "Total subscription deliveries (snapshot + delta)." }), hn = P.histogram("voltro_subscription_delivery_seconds", on, "Subscription delivery produce→push latency in seconds."), gn = P.gauge("voltro_subscriptions_active", { description: "Currently-open subscriptions." }), _n = (e) => {
|
|
1014
|
+
let t = e.durationMs / 1e3, n = e.kind === "rpc" ? M.zipRight(P.increment(sn).pipe(M.tagMetrics("tag", e.tag), M.tagMetrics("status", e.status)), M.zipRight(P.update(ln, t).pipe(M.tagMetrics("tag", e.tag)), e.status === "error" ? P.increment(cn).pipe(M.tagMetrics("tag", e.tag)) : M.void)) : e.kind === "request" ? M.zipRight(P.increment(un).pipe(M.tagMetrics("route", e.tag), M.tagMetrics("status", e.status)), P.update(dn, t).pipe(M.tagMetrics("route", e.tag))) : M.zipRight(P.update(fn, t).pipe(M.tagMetrics("hook", e.tag)), e.status === "error" ? P.increment(pn).pipe(M.tagMetrics("hook", e.tag)) : M.void);
|
|
1015
|
+
M.runSync(n);
|
|
1016
|
+
}, vn = (e) => e.startsWith("subscription.") ? e.slice(13) : e, yn = (e) => {
|
|
1017
|
+
let t = vn(e.label);
|
|
1018
|
+
M.runSync(M.zipRight(P.increment(mn).pipe(M.tagMetrics("tag", t), M.tagMetrics("kind", e.kind)), P.update(hn, e.durationMs / 1e3).pipe(M.tagMetrics("tag", t), M.tagMetrics("kind", e.kind))));
|
|
1019
|
+
}, bn = /* @__PURE__ */ new Map(), U = (e, t) => {
|
|
1020
|
+
let n = vn(e), r = Math.max(0, (bn.get(n) ?? 0) + t);
|
|
1021
|
+
r === 0 ? bn.delete(n) : bn.set(n, r), M.runSync(P.set(gn, r).pipe(M.tagMetrics("tag", n)));
|
|
1022
|
+
}, xn = (e, t) => P.counter(e, t === void 0 ? {} : { description: t }), Sn = (e, t) => P.gauge(e, t === void 0 ? {} : { description: t }), Cn = (e, t = on, n) => P.histogram(e, t, n), wn = (e) => {
|
|
1023
1023
|
let t = {};
|
|
1024
1024
|
for (let n of e) t[n.key] = n.value;
|
|
1025
1025
|
return t;
|
|
1026
|
-
},
|
|
1027
|
-
let t = e.metricKey.name, n =
|
|
1028
|
-
if (
|
|
1026
|
+
}, Tn = P.snapshot.pipe(M.map((e) => e.map((e) => {
|
|
1027
|
+
let t = e.metricKey.name, n = wn(e.metricKey.tags), r = F.getOrUndefined(e.metricKey.description), i = r === void 0 ? {} : { description: r }, a = e.metricState;
|
|
1028
|
+
if (Ke.isHistogramState(a)) return {
|
|
1029
1029
|
name: t,
|
|
1030
1030
|
labels: n,
|
|
1031
1031
|
...i,
|
|
@@ -1037,14 +1037,14 @@ var Ct = class {
|
|
|
1037
1037
|
sum: a.sum,
|
|
1038
1038
|
count: a.count
|
|
1039
1039
|
};
|
|
1040
|
-
if (
|
|
1040
|
+
if (Ke.isGaugeState(a)) return {
|
|
1041
1041
|
name: t,
|
|
1042
1042
|
labels: n,
|
|
1043
1043
|
...i,
|
|
1044
1044
|
type: "gauge",
|
|
1045
1045
|
value: Number(a.value)
|
|
1046
1046
|
};
|
|
1047
|
-
if (
|
|
1047
|
+
if (Ke.isSummaryState(a)) return {
|
|
1048
1048
|
name: t,
|
|
1049
1049
|
labels: n,
|
|
1050
1050
|
...i,
|
|
@@ -1056,7 +1056,7 @@ var Ct = class {
|
|
|
1056
1056
|
value: t.value
|
|
1057
1057
|
}] : [])
|
|
1058
1058
|
};
|
|
1059
|
-
if (
|
|
1059
|
+
if (Ke.isFrequencyState(a)) {
|
|
1060
1060
|
let e = {};
|
|
1061
1061
|
for (let [t, n] of a.occurrences) e[t] = n;
|
|
1062
1062
|
return {
|
|
@@ -1074,25 +1074,25 @@ var Ct = class {
|
|
|
1074
1074
|
type: "counter",
|
|
1075
1075
|
value: Number(a.count)
|
|
1076
1076
|
};
|
|
1077
|
-
}))),
|
|
1078
|
-
|
|
1079
|
-
},
|
|
1080
|
-
if (e === void 0 || t.type === "system") return
|
|
1081
|
-
let r = e.retry ??
|
|
1082
|
-
return (r === !1 ? i :
|
|
1083
|
-
},
|
|
1077
|
+
}))), En = () => M.runSync(Tn), Dn = class extends L.TaggedError()("RowFilterUnavailable", { cause: L.String }) {}, On = qe.exponential("20 millis").pipe(qe.intersect(qe.recurs(2))), kn, An = (e) => {
|
|
1078
|
+
kn = e;
|
|
1079
|
+
}, jn = () => kn, Mn = () => void 0, Nn = (e, t) => Pn(kn, e, t), Pn = (e, t, n) => {
|
|
1080
|
+
if (e === void 0 || t.type === "system") return M.succeed(Mn);
|
|
1081
|
+
let r = e.retry ?? On, i = e.load(t);
|
|
1082
|
+
return (r === !1 ? i : M.retry(i, r)).pipe(M.map((t) => (n) => e.predicate(t, n)), M.catchAll((t) => M.suspend(() => (n?.(t), e.onLoadError === "deny" ? M.succeed(Fn) : M.fail(new Dn({ cause: String(t) }))))));
|
|
1083
|
+
}, Fn = () => ({
|
|
1084
1084
|
column: "id",
|
|
1085
1085
|
op: "isNull"
|
|
1086
|
-
}),
|
|
1086
|
+
}), In = (e, n, r) => {
|
|
1087
1087
|
let i = e(n);
|
|
1088
1088
|
return i === void 0 ? r : r ? t(r, i) : i;
|
|
1089
|
-
},
|
|
1090
|
-
let n =
|
|
1089
|
+
}, Ln = (e, t) => {
|
|
1090
|
+
let n = In(e, t.table, t.predicate);
|
|
1091
1091
|
return n === t.predicate ? t : {
|
|
1092
1092
|
...t,
|
|
1093
1093
|
predicate: n
|
|
1094
1094
|
};
|
|
1095
|
-
},
|
|
1095
|
+
}, W = A({ scope: "voltro:dispatcher" }), Rn = (e) => typeof e == "object" && !!e && e._tag === "ScopeError", zn = class {
|
|
1096
1096
|
deps;
|
|
1097
1097
|
subscriptionRegistry;
|
|
1098
1098
|
matcher;
|
|
@@ -1102,12 +1102,12 @@ var Ct = class {
|
|
|
1102
1102
|
computedSubs = /* @__PURE__ */ new Map();
|
|
1103
1103
|
computedByTable = /* @__PURE__ */ new Map();
|
|
1104
1104
|
constructor(e) {
|
|
1105
|
-
this.deps = e, this.matcher = new
|
|
1105
|
+
this.deps = e, this.matcher = new jt(), this.subscriptionRegistry = new Pt(this.matcher), this.unsubscribeChange = e.store.onChange((e) => {
|
|
1106
1106
|
this.handleChange(e);
|
|
1107
1107
|
});
|
|
1108
1108
|
}
|
|
1109
1109
|
async subscribe(e, t, n, r, i, a, o, s) {
|
|
1110
|
-
let c = `sub_${me()}`, l = i ?? `subscription.${e.table}`, u =
|
|
1110
|
+
let c = `sub_${me()}`, l = i ?? `subscription.${e.table}`, u = Jt(e), d = nn(e);
|
|
1111
1111
|
e.predicate !== void 0 && this.subscriptionRegistry.subscribe(c, e.table, e.predicate, r);
|
|
1112
1112
|
for (let e of u) {
|
|
1113
1113
|
let t = this.dependentByTable.get(e);
|
|
@@ -1121,7 +1121,7 @@ var Ct = class {
|
|
|
1121
1121
|
}
|
|
1122
1122
|
}, h, g;
|
|
1123
1123
|
try {
|
|
1124
|
-
h = s === void 0 ? e :
|
|
1124
|
+
h = s === void 0 ? e : Ln(await s(), e), g = this.deps.cache !== void 0 && a !== void 0 ? await this.deps.cache.wrap(a, p, () => this.deps.store.query(h)) : await this.deps.store.query(h);
|
|
1125
1125
|
} catch (e) {
|
|
1126
1126
|
throw m(), e;
|
|
1127
1127
|
}
|
|
@@ -1138,7 +1138,7 @@ var Ct = class {
|
|
|
1138
1138
|
cacheBinding: a,
|
|
1139
1139
|
reauthorize: o,
|
|
1140
1140
|
refilter: s
|
|
1141
|
-
}),
|
|
1141
|
+
}), U(l, 1), t({
|
|
1142
1142
|
_tag: "snapshot",
|
|
1143
1143
|
revision: 0,
|
|
1144
1144
|
data: g
|
|
@@ -1154,16 +1154,16 @@ var Ct = class {
|
|
|
1154
1154
|
durationMs: _ - f,
|
|
1155
1155
|
rowCount: g.length
|
|
1156
1156
|
}), () => {
|
|
1157
|
-
this.subscriptions.delete(c),
|
|
1157
|
+
this.subscriptions.delete(c), U(l, -1), m();
|
|
1158
1158
|
};
|
|
1159
1159
|
}
|
|
1160
1160
|
revokeSubscription(e, t, n = "guards no longer satisfied") {
|
|
1161
|
-
this.subscriptions.delete(e.id),
|
|
1161
|
+
this.subscriptions.delete(e.id), U(e.label, -1), this.subscriptionRegistry.unsubscribe(e.id);
|
|
1162
1162
|
for (let t of e.dependentTables) {
|
|
1163
1163
|
let n = this.dependentByTable.get(t);
|
|
1164
1164
|
n !== void 0 && (n.delete(e.id), n.size === 0 && this.dependentByTable.delete(t));
|
|
1165
1165
|
}
|
|
1166
|
-
|
|
1166
|
+
W.warn(`subscription revoked mid-stream — ${n}`, {
|
|
1167
1167
|
id: e.id,
|
|
1168
1168
|
label: e.label,
|
|
1169
1169
|
traceId: e.context.traceId
|
|
@@ -1173,12 +1173,12 @@ var Ct = class {
|
|
|
1173
1173
|
});
|
|
1174
1174
|
}
|
|
1175
1175
|
revokeComputed(e, t) {
|
|
1176
|
-
this.computedSubs.delete(e.id),
|
|
1176
|
+
this.computedSubs.delete(e.id), U(e.label, -1);
|
|
1177
1177
|
for (let t of e.tables) {
|
|
1178
1178
|
let n = this.computedByTable.get(t);
|
|
1179
1179
|
n !== void 0 && (n.delete(e.id), n.size === 0 && this.computedByTable.delete(t));
|
|
1180
1180
|
}
|
|
1181
|
-
|
|
1181
|
+
W.warn("computed subscription revoked mid-stream — guards no longer satisfied", {
|
|
1182
1182
|
id: e.id,
|
|
1183
1183
|
label: e.label,
|
|
1184
1184
|
traceId: e.context.traceId
|
|
@@ -1196,10 +1196,10 @@ var Ct = class {
|
|
|
1196
1196
|
context: n,
|
|
1197
1197
|
label: r ?? "subscription.computed",
|
|
1198
1198
|
tables: a,
|
|
1199
|
-
lastJson:
|
|
1199
|
+
lastJson: Bn(e.value),
|
|
1200
1200
|
revision: 0
|
|
1201
1201
|
};
|
|
1202
|
-
this.computedSubs.set(i, o),
|
|
1202
|
+
this.computedSubs.set(i, o), U(o.label, 1);
|
|
1203
1203
|
for (let e of a) {
|
|
1204
1204
|
let t = this.computedByTable.get(e);
|
|
1205
1205
|
t === void 0 && (t = /* @__PURE__ */ new Set(), this.computedByTable.set(e, t)), t.add(i);
|
|
@@ -1219,7 +1219,7 @@ var Ct = class {
|
|
|
1219
1219
|
durationMs: Date.now() - s,
|
|
1220
1220
|
rowCount: 1
|
|
1221
1221
|
}), () => {
|
|
1222
|
-
this.computedSubs.delete(i),
|
|
1222
|
+
this.computedSubs.delete(i), U(o.label, -1);
|
|
1223
1223
|
for (let e of a) {
|
|
1224
1224
|
let t = this.computedByTable.get(e);
|
|
1225
1225
|
t !== void 0 && (t.delete(i), t.size === 0 && this.computedByTable.delete(e));
|
|
@@ -1229,7 +1229,7 @@ var Ct = class {
|
|
|
1229
1229
|
async recomputeComputed(e) {
|
|
1230
1230
|
let t = Date.now();
|
|
1231
1231
|
try {
|
|
1232
|
-
let n = await e.recompute(), r =
|
|
1232
|
+
let n = await e.recompute(), r = Bn(n);
|
|
1233
1233
|
if (r === e.lastJson) return;
|
|
1234
1234
|
e.lastJson = r, e.revision += 1;
|
|
1235
1235
|
let i = Date.now();
|
|
@@ -1248,11 +1248,11 @@ var Ct = class {
|
|
|
1248
1248
|
rowCount: 1
|
|
1249
1249
|
});
|
|
1250
1250
|
} catch (t) {
|
|
1251
|
-
if (
|
|
1251
|
+
if (Rn(t)) {
|
|
1252
1252
|
this.revokeComputed(e, t);
|
|
1253
1253
|
return;
|
|
1254
1254
|
}
|
|
1255
|
-
|
|
1255
|
+
W.warn("computed recompute failed; subscriber left on last value", {
|
|
1256
1256
|
id: e.id,
|
|
1257
1257
|
label: e.label,
|
|
1258
1258
|
traceId: e.context.traceId
|
|
@@ -1287,7 +1287,7 @@ var Ct = class {
|
|
|
1287
1287
|
for (let e of n) r.add(e.subscriberId);
|
|
1288
1288
|
let i = this.dependentByTable.get(e.table);
|
|
1289
1289
|
if (i !== void 0) for (let e of i) r.add(e);
|
|
1290
|
-
if (
|
|
1290
|
+
if (W.trace("handleChange", {
|
|
1291
1291
|
table: e.table,
|
|
1292
1292
|
op: e.op,
|
|
1293
1293
|
matcher: n.length,
|
|
@@ -1298,10 +1298,10 @@ var Ct = class {
|
|
|
1298
1298
|
for (let t of r) {
|
|
1299
1299
|
let n = this.subscriptions.get(t);
|
|
1300
1300
|
if (!n) {
|
|
1301
|
-
|
|
1301
|
+
W.trace("missing subscription", { subscriberId: t });
|
|
1302
1302
|
continue;
|
|
1303
1303
|
}
|
|
1304
|
-
if (!
|
|
1304
|
+
if (!an(e, n.relevantFields)) {
|
|
1305
1305
|
o++;
|
|
1306
1306
|
continue;
|
|
1307
1307
|
}
|
|
@@ -1324,11 +1324,11 @@ var Ct = class {
|
|
|
1324
1324
|
this.revokeSubscription(n, e, "row filter unavailable");
|
|
1325
1325
|
continue;
|
|
1326
1326
|
}
|
|
1327
|
-
i =
|
|
1327
|
+
i = Ln(e, n.baseDescriptor);
|
|
1328
1328
|
}
|
|
1329
1329
|
let o = await this.deps.store.query(i), s = n.lastDelivered;
|
|
1330
|
-
if (
|
|
1331
|
-
|
|
1330
|
+
if (Vn(o, s)) {
|
|
1331
|
+
W.trace("suppressed no-op delta", {
|
|
1332
1332
|
subscriberId: t,
|
|
1333
1333
|
table: e.table
|
|
1334
1334
|
});
|
|
@@ -1356,7 +1356,7 @@ var Ct = class {
|
|
|
1356
1356
|
rowCount: o.length
|
|
1357
1357
|
});
|
|
1358
1358
|
} catch (r) {
|
|
1359
|
-
|
|
1359
|
+
W.warn("reactive re-query failed; subscriber left on last snapshot", {
|
|
1360
1360
|
subscriberId: t,
|
|
1361
1361
|
label: n.label,
|
|
1362
1362
|
table: e.table,
|
|
@@ -1364,66 +1364,66 @@ var Ct = class {
|
|
|
1364
1364
|
}, r);
|
|
1365
1365
|
}
|
|
1366
1366
|
}
|
|
1367
|
-
o > 0 &&
|
|
1367
|
+
o > 0 && W.trace("handleChange/prefiltered", {
|
|
1368
1368
|
table: e.table,
|
|
1369
1369
|
op: e.op,
|
|
1370
1370
|
skipped: o
|
|
1371
1371
|
});
|
|
1372
1372
|
}
|
|
1373
|
-
},
|
|
1373
|
+
}, Bn = (e) => {
|
|
1374
1374
|
try {
|
|
1375
1375
|
return JSON.stringify(e) ?? "null";
|
|
1376
1376
|
} catch {
|
|
1377
1377
|
return String(e);
|
|
1378
1378
|
}
|
|
1379
|
-
},
|
|
1379
|
+
}, Vn = (e, t) => {
|
|
1380
1380
|
if (e === t) return !0;
|
|
1381
1381
|
if (e.length !== t.length) return !1;
|
|
1382
1382
|
for (let n = 0; n < e.length; n++) if (JSON.stringify(e[n]) !== JSON.stringify(t[n])) return !1;
|
|
1383
1383
|
return !0;
|
|
1384
|
-
},
|
|
1385
|
-
|
|
1384
|
+
}, Hn = (e) => typeof e == "object" && !!e && e.__voltroComputed === !0, Un = 1440 * 60 * 1e3, Wn = 3600 * 1e3, G = /* @__PURE__ */ new Map(), Gn = /* @__PURE__ */ new Set(), Kn = (e, t) => {
|
|
1385
|
+
G.set(e, {
|
|
1386
1386
|
subject: t,
|
|
1387
1387
|
touchedAt: Date.now()
|
|
1388
1388
|
});
|
|
1389
|
-
for (let n of
|
|
1389
|
+
for (let n of Gn) try {
|
|
1390
1390
|
n(e, t);
|
|
1391
1391
|
} catch {}
|
|
1392
|
-
}, Kn = (e) => {
|
|
1393
|
-
let t = K.get(e);
|
|
1394
|
-
if (t) return t.touchedAt = Date.now(), t.subject;
|
|
1395
1392
|
}, qn = (e) => {
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
},
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1393
|
+
let t = G.get(e);
|
|
1394
|
+
if (t) return t.touchedAt = Date.now(), t.subject;
|
|
1395
|
+
}, Jn = (e) => {
|
|
1396
|
+
G.delete(e);
|
|
1397
|
+
}, Yn = (e) => (Gn.add(e), () => {
|
|
1398
|
+
Gn.delete(e);
|
|
1399
|
+
}), Xn = setInterval(() => {
|
|
1400
|
+
let e = Date.now() - Un;
|
|
1401
|
+
for (let [t, n] of G) n.touchedAt < e && G.delete(t);
|
|
1402
|
+
}, Wn);
|
|
1403
|
+
typeof Xn == "object" && Xn && "unref" in Xn && Xn.unref();
|
|
1404
|
+
var K = /* @__PURE__ */ new Map(), Zn = (e, t) => {
|
|
1405
|
+
let n = K.get(e);
|
|
1406
|
+
return n || (n = /* @__PURE__ */ new Set(), K.set(e, n)), n.add(t), () => {
|
|
1407
|
+
let n = K.get(e);
|
|
1408
|
+
n && (n.delete(t), n.size === 0 && K.delete(e));
|
|
1409
1409
|
};
|
|
1410
|
-
},
|
|
1411
|
-
let t =
|
|
1410
|
+
}, Qn = (e) => {
|
|
1411
|
+
let t = K.get(e);
|
|
1412
1412
|
if (t) {
|
|
1413
1413
|
for (let e of [...t]) try {
|
|
1414
1414
|
e();
|
|
1415
1415
|
} catch {}
|
|
1416
|
-
|
|
1416
|
+
K.delete(e);
|
|
1417
1417
|
}
|
|
1418
|
-
},
|
|
1419
|
-
|
|
1420
|
-
},
|
|
1418
|
+
}, $n = (e) => K.get(e)?.size ?? 0, er = () => {
|
|
1419
|
+
G.clear(), K.clear();
|
|
1420
|
+
}, tr = () => [...G.entries()].map(([e, t]) => ({
|
|
1421
1421
|
clientId: e,
|
|
1422
1422
|
subjectType: t.subject.type,
|
|
1423
1423
|
tenantId: t.subject.tenantId
|
|
1424
|
-
})),
|
|
1424
|
+
})), nr = /^00-([0-9a-f]{32})-([0-9a-f]{16})-([0-9a-f]{2})$/, rr = (e) => `00-${e.traceId}-${e.spanId}-${e.sampled ? "01" : "00"}`, ir = (e) => {
|
|
1425
1425
|
if (typeof e != "string") return null;
|
|
1426
|
-
let t =
|
|
1426
|
+
let t = nr.exec(e.trim().toLowerCase());
|
|
1427
1427
|
if (t === null) return null;
|
|
1428
1428
|
let [, n, r, i] = t;
|
|
1429
1429
|
return n === "0".repeat(32) || r === "0".repeat(16) ? null : {
|
|
@@ -1431,14 +1431,14 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
1431
1431
|
spanId: r,
|
|
1432
1432
|
sampled: (parseInt(i, 16) & 1) == 1
|
|
1433
1433
|
};
|
|
1434
|
-
},
|
|
1435
|
-
let t =
|
|
1436
|
-
if (t !== null) return
|
|
1434
|
+
}, ar = (e) => {
|
|
1435
|
+
let t = ir(e);
|
|
1436
|
+
if (t !== null) return Je.externalSpan({
|
|
1437
1437
|
traceId: t.traceId,
|
|
1438
1438
|
spanId: t.spanId,
|
|
1439
1439
|
sampled: t.sampled
|
|
1440
1440
|
});
|
|
1441
|
-
},
|
|
1441
|
+
}, or = new ut(), sr = (e, t) => or.run(e, t), cr = () => or.getStore(), lr = (e = {}) => {
|
|
1442
1442
|
let t = e.random ?? Math.random, n = /* @__PURE__ */ new Map(), r = (e) => n.get(e) ?? 0;
|
|
1443
1443
|
return {
|
|
1444
1444
|
pick(e) {
|
|
@@ -1463,7 +1463,7 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
1463
1463
|
}));
|
|
1464
1464
|
}
|
|
1465
1465
|
};
|
|
1466
|
-
},
|
|
1466
|
+
}, ur = (e = {}) => {
|
|
1467
1467
|
let t = e.thresholdFailures ?? 3, n = e.windowMs ?? 1e4, r = e.blackoutMs ?? 6e4, i = e.now ?? Date.now, a = /* @__PURE__ */ new Map(), o = (e) => {
|
|
1468
1468
|
let t = a.get(e);
|
|
1469
1469
|
return t === void 0 && (t = {
|
|
@@ -1497,7 +1497,7 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
1497
1497
|
}));
|
|
1498
1498
|
}
|
|
1499
1499
|
};
|
|
1500
|
-
},
|
|
1500
|
+
}, dr = (e = {}) => {
|
|
1501
1501
|
let t = e.now ?? Date.now, n = /* @__PURE__ */ new Map();
|
|
1502
1502
|
return {
|
|
1503
1503
|
get(e) {
|
|
@@ -1520,7 +1520,7 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
1520
1520
|
return n.size;
|
|
1521
1521
|
}
|
|
1522
1522
|
};
|
|
1523
|
-
},
|
|
1523
|
+
}, fr = (e, t) => e === null ? t === void 0 ? "anon:bg" : `anon:${t}` : `subject:${e}`, pr = (e) => {
|
|
1524
1524
|
let t = e.now ?? Date.now, n = e.keyPrefix ?? "voltro:ryw", r = e.channel ?? `${n}:bus`, i = e.onError ?? ((e, t) => {
|
|
1525
1525
|
process.stderr.write(`[voltro:ryw] redis ${t} failed: ${String(e)}\n`);
|
|
1526
1526
|
}), a = `${process.pid ?? 0}:${Math.random() * 1e9 | 0}:${t()}`, o = /* @__PURE__ */ new Map(), s = (e) => {
|
|
@@ -1579,7 +1579,7 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
1579
1579
|
return o.size;
|
|
1580
1580
|
}
|
|
1581
1581
|
};
|
|
1582
|
-
},
|
|
1582
|
+
}, mr = A({ scope: "voltro:replication" }), hr = new ut(), gr = (e, t) => hr.run(e, t), _r = () => hr.getStore(), vr = class {
|
|
1583
1583
|
primary;
|
|
1584
1584
|
replicas;
|
|
1585
1585
|
adapter;
|
|
@@ -1592,10 +1592,10 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
1592
1592
|
recordRouting;
|
|
1593
1593
|
now;
|
|
1594
1594
|
constructor(e) {
|
|
1595
|
-
this.primary = e.primary, this.replicas = e.replicas, this.adapter = e.replicationAdapter, this.policy = e.rywPolicy ?? "fallback", this.rywTtlMs = e.rywTtlMs ?? 3e4, this.rywMaxWaitMs = e.rywMaxWaitMs ?? 500, this.now = e.now ?? Date.now, this.rywStore = e.rywStore ??
|
|
1595
|
+
this.primary = e.primary, this.replicas = e.replicas, this.adapter = e.replicationAdapter, this.policy = e.rywPolicy ?? "fallback", this.rywTtlMs = e.rywTtlMs ?? 3e4, this.rywMaxWaitMs = e.rywMaxWaitMs ?? 500, this.now = e.now ?? Date.now, this.rywStore = e.rywStore ?? dr({ now: this.now }), this.selector = e.replicaSelector ?? lr(), this.health = e.replicaHealth ?? ur({ now: this.now }), e.recordRouting !== void 0 && (this.recordRouting = e.recordRouting);
|
|
1596
1596
|
}
|
|
1597
1597
|
async query(e) {
|
|
1598
|
-
let t =
|
|
1598
|
+
let t = hr.getStore(), n = t?.subjectKey ?? "anon:bg";
|
|
1599
1599
|
if (t?.forcePrimary === !0) return this.emitRouting({
|
|
1600
1600
|
target: "primary",
|
|
1601
1601
|
replicaIndex: null,
|
|
@@ -1659,7 +1659,7 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
1659
1659
|
waitMs: 0
|
|
1660
1660
|
}), r;
|
|
1661
1661
|
} catch (r) {
|
|
1662
|
-
return this.health.reportFailure(i, String(r)),
|
|
1662
|
+
return this.health.reportFailure(i, String(r)), mr.warn("replica query failed; falling back to primary", {
|
|
1663
1663
|
idx: a,
|
|
1664
1664
|
err: r
|
|
1665
1665
|
}), this.emitRouting({
|
|
@@ -1728,7 +1728,7 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
1728
1728
|
fallbackReason: "wait-timeout"
|
|
1729
1729
|
}), this.primary.query(e);
|
|
1730
1730
|
}
|
|
1731
|
-
await
|
|
1731
|
+
await yr(10);
|
|
1732
1732
|
}
|
|
1733
1733
|
}
|
|
1734
1734
|
async insert(e, t) {
|
|
@@ -1768,8 +1768,8 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
1768
1768
|
return await this.stampPostWrite(), r;
|
|
1769
1769
|
}
|
|
1770
1770
|
async transactional(e) {
|
|
1771
|
-
let t = await
|
|
1772
|
-
subjectKey:
|
|
1771
|
+
let t = await gr({
|
|
1772
|
+
subjectKey: hr.getStore()?.subjectKey ?? "anon:bg",
|
|
1773
1773
|
forcePrimary: !0
|
|
1774
1774
|
}, () => this.primary.transactional(e));
|
|
1775
1775
|
return await this.stampPostWrite(), t;
|
|
@@ -1785,7 +1785,7 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
1785
1785
|
}
|
|
1786
1786
|
async stampPostWrite() {
|
|
1787
1787
|
if (this.replicas.length === 0) return;
|
|
1788
|
-
let e =
|
|
1788
|
+
let e = hr.getStore()?.subjectKey ?? "anon:bg";
|
|
1789
1789
|
try {
|
|
1790
1790
|
let t = await this.adapter.capturePrimaryPosition(this.primary);
|
|
1791
1791
|
this.rywStore.set(e, {
|
|
@@ -1793,37 +1793,37 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
1793
1793
|
expiresAt: this.now() + this.rywTtlMs
|
|
1794
1794
|
});
|
|
1795
1795
|
} catch (e) {
|
|
1796
|
-
|
|
1796
|
+
mr.warn("failed to capture primary position; RYW skipped", { err: e });
|
|
1797
1797
|
}
|
|
1798
1798
|
}
|
|
1799
1799
|
emitRouting(e) {
|
|
1800
1800
|
this.recordRouting?.(e);
|
|
1801
1801
|
}
|
|
1802
|
-
},
|
|
1802
|
+
}, yr = (e) => new Promise((t) => setTimeout(t, e)), br = (e, t, n) => ({
|
|
1803
1803
|
subject: e,
|
|
1804
1804
|
traceId: t?.traceId ?? me(),
|
|
1805
1805
|
...t?.spanId === void 0 ? {} : { spanId: t.spanId },
|
|
1806
1806
|
...n === void 0 ? {} : { clientId: n }
|
|
1807
|
-
}),
|
|
1807
|
+
}), xr = M.currentSpan.pipe(M.catchAll(() => M.succeed(void 0))), Sr = (e) => ({
|
|
1808
1808
|
traceId: e.traceId,
|
|
1809
1809
|
...e.spanId === void 0 ? {} : { spanId: e.spanId }
|
|
1810
|
-
}),
|
|
1810
|
+
}), Cr = (e, t, n) => {
|
|
1811
1811
|
e !== void 0 && (e.attribute("rpc.tag", t), e.attribute("subject.type", n.type), n.tenantId !== void 0 && n.tenantId !== null && e.attribute("tenant.id", n.tenantId));
|
|
1812
|
-
},
|
|
1813
|
-
if (
|
|
1814
|
-
let t = await
|
|
1812
|
+
}, wr = (e) => {
|
|
1813
|
+
if (jn() !== void 0) return async () => {
|
|
1814
|
+
let t = await M.runPromise(M.either(Nn(e, (e) => {
|
|
1815
1815
|
console.error("[voltro] row filter failed to load — subscription", e);
|
|
1816
1816
|
})));
|
|
1817
1817
|
if (t._tag === "Left") throw t.left;
|
|
1818
1818
|
return t.right;
|
|
1819
1819
|
};
|
|
1820
|
-
},
|
|
1821
|
-
let l = yield*
|
|
1820
|
+
}, Tr = (e, t, n, r, i, a, o, s) => R.asyncScoped((c) => M.gen(function* () {
|
|
1821
|
+
let l = yield* M.tryPromise(() => t.subscribe(e, (e) => {
|
|
1822
1822
|
c.single(e);
|
|
1823
|
-
}, n, r, i, a, o, s)).pipe(
|
|
1824
|
-
onFailure: (e) => (
|
|
1823
|
+
}, n, r, i, a, o, s)).pipe(M.matchCause({
|
|
1824
|
+
onFailure: (e) => (jr(`subscription.${i}`, n.traceId, e), {
|
|
1825
1825
|
ok: !1,
|
|
1826
|
-
error:
|
|
1826
|
+
error: Fr(e)
|
|
1827
1827
|
}),
|
|
1828
1828
|
onSuccess: (e) => ({
|
|
1829
1829
|
ok: !0,
|
|
@@ -1838,22 +1838,22 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
1838
1838
|
return;
|
|
1839
1839
|
}
|
|
1840
1840
|
let u = l.unsubscribe;
|
|
1841
|
-
if (yield*
|
|
1842
|
-
let e =
|
|
1841
|
+
if (yield* M.addFinalizer(() => M.sync(() => u())), n.clientId !== void 0) {
|
|
1842
|
+
let e = Zn(n.clientId, () => {
|
|
1843
1843
|
c.end();
|
|
1844
1844
|
});
|
|
1845
|
-
yield*
|
|
1845
|
+
yield* M.addFinalizer(() => M.sync(() => e()));
|
|
1846
1846
|
}
|
|
1847
|
-
})),
|
|
1848
|
-
let a = yield*
|
|
1847
|
+
})), Er = (e, t, n, r) => R.asyncScoped((i) => M.gen(function* () {
|
|
1848
|
+
let a = yield* M.tryPromise(() => t.subscribeComputed(e, (e) => {
|
|
1849
1849
|
i.single(e._tag === "snapshot" ? {
|
|
1850
1850
|
...e,
|
|
1851
1851
|
computed: !0
|
|
1852
1852
|
} : e);
|
|
1853
|
-
}, n, r)).pipe(
|
|
1854
|
-
onFailure: (e) => (
|
|
1853
|
+
}, n, r)).pipe(M.matchCause({
|
|
1854
|
+
onFailure: (e) => (jr(`subscription.${r}`, n.traceId, e), {
|
|
1855
1855
|
ok: !1,
|
|
1856
|
-
error:
|
|
1856
|
+
error: Fr(e)
|
|
1857
1857
|
}),
|
|
1858
1858
|
onSuccess: (e) => ({
|
|
1859
1859
|
ok: !0,
|
|
@@ -1868,22 +1868,22 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
1868
1868
|
return;
|
|
1869
1869
|
}
|
|
1870
1870
|
let o = a.unsubscribe;
|
|
1871
|
-
if (yield*
|
|
1872
|
-
let e =
|
|
1871
|
+
if (yield* M.addFinalizer(() => M.sync(() => o())), n.clientId !== void 0) {
|
|
1872
|
+
let e = Zn(n.clientId, () => {
|
|
1873
1873
|
i.end();
|
|
1874
1874
|
});
|
|
1875
|
-
yield*
|
|
1875
|
+
yield* M.addFinalizer(() => M.sync(() => e()));
|
|
1876
1876
|
}
|
|
1877
|
-
})),
|
|
1878
|
-
let s = yield* Se, c = yield* ve, l = yield*
|
|
1879
|
-
|
|
1880
|
-
let u =
|
|
1877
|
+
})), Dr = (e, t, n = "rpc.subscription", r, i, a, o) => R.unwrap(M.gen(function* () {
|
|
1878
|
+
let s = yield* Se, c = yield* ve, l = yield* xr;
|
|
1879
|
+
Cr(l, n, s);
|
|
1880
|
+
let u = br(s, l, c.clientId), d = fr(s.id, c.clientId), f = gr({ subjectKey: d }, () => sr({
|
|
1881
1881
|
traceId: u.traceId,
|
|
1882
1882
|
...u.spanId === void 0 ? {} : { spanId: u.spanId }
|
|
1883
|
-
}, () => e(u))), p =
|
|
1884
|
-
onFailure: (e) => (
|
|
1883
|
+
}, () => e(u))), p = M.isEffect(f) ? yield* f.pipe(M.matchCause({
|
|
1884
|
+
onFailure: (e) => (jr(`subscription.${n}`, u.traceId, e), {
|
|
1885
1885
|
ok: !1,
|
|
1886
|
-
error:
|
|
1886
|
+
error: Fr(e)
|
|
1887
1887
|
}),
|
|
1888
1888
|
onSuccess: (e) => ({
|
|
1889
1889
|
ok: !0,
|
|
@@ -1893,43 +1893,43 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
1893
1893
|
ok: !0,
|
|
1894
1894
|
value: f
|
|
1895
1895
|
};
|
|
1896
|
-
if (!p.ok) return
|
|
1896
|
+
if (!p.ok) return R.make({
|
|
1897
1897
|
_tag: "error",
|
|
1898
1898
|
error: p.error
|
|
1899
1899
|
});
|
|
1900
1900
|
let m = p.value;
|
|
1901
|
-
if (
|
|
1901
|
+
if (Hn(m)) return Er(m, t, u, n);
|
|
1902
1902
|
let h = m, g = r?.(h);
|
|
1903
|
-
return
|
|
1903
|
+
return Tr(h, t, u, g, n, i === void 0 ? void 0 : {
|
|
1904
1904
|
key: i.scope === "subject" ? `${i.baseKey}:s:${d}` : `${i.baseKey}:global`,
|
|
1905
1905
|
ttlMs: i.ttlMs,
|
|
1906
1906
|
swrMs: i.swrMs
|
|
1907
|
-
}, a?.(s), o?.(s) ??
|
|
1908
|
-
}).pipe(
|
|
1909
|
-
let n = yield* Se, r = yield* ve, i = yield*
|
|
1910
|
-
|
|
1911
|
-
let a =
|
|
1907
|
+
}, a?.(s), o?.(s) ?? wr(s));
|
|
1908
|
+
}).pipe(M.withSpan(n, { attributes: { "framework.kind": "subscription" } }))), Or = (e, t = "rpc.stream") => R.unwrap(M.gen(function* () {
|
|
1909
|
+
let n = yield* Se, r = yield* ve, i = yield* xr;
|
|
1910
|
+
Cr(i, t, n);
|
|
1911
|
+
let a = br(n, i, r.clientId), o = e(a), s = M.isEffect(o) ? yield* o.pipe(M.orDie) : o;
|
|
1912
1912
|
if (a.clientId === void 0) return s;
|
|
1913
1913
|
let c = a.clientId;
|
|
1914
|
-
return
|
|
1915
|
-
let e = yield*
|
|
1916
|
-
|
|
1914
|
+
return R.unwrapScoped(M.gen(function* () {
|
|
1915
|
+
let e = yield* Be.make(), t = Zn(c, () => {
|
|
1916
|
+
Be.unsafeDone(e, M.void);
|
|
1917
1917
|
});
|
|
1918
|
-
return yield*
|
|
1918
|
+
return yield* M.addFinalizer(() => M.sync(() => t())), s.pipe(R.interruptWhen(Be.await(e)));
|
|
1919
1919
|
}));
|
|
1920
|
-
}).pipe(
|
|
1920
|
+
}).pipe(M.withSpan(t, { attributes: { "framework.kind": "stream" } }))), kr = A({ scope: "voltro:rpc" }), Ar = A({ scope: "voltro:http" }), jr = (e, t, n) => {
|
|
1921
1921
|
if (j.isInterruptedOnly(n)) return;
|
|
1922
|
-
let r = j.squash(n), i = r?._tag, a = r instanceof Error ? r.message : r?.message ?? String(r), o = j.dieOption(n)._tag === "Some", s =
|
|
1922
|
+
let r = j.squash(n), i = r?._tag, a = r instanceof Error ? r.message : r?.message ?? String(r), o = j.dieOption(n)._tag === "Some", s = Gt(r), c = {
|
|
1923
1923
|
traceId: t,
|
|
1924
1924
|
...i === void 0 ? {} : { errorTag: i },
|
|
1925
1925
|
...s
|
|
1926
1926
|
}, l = a === "Failed to execute statement" && typeof s.dbMessage == "string" ? s.dbMessage : a;
|
|
1927
|
-
o ?
|
|
1928
|
-
},
|
|
1927
|
+
o ? kr.error(`${e} failed: ${l}`, c) : kr.warn(`${e} failed: ${l}`, c);
|
|
1928
|
+
}, Mr = /* @__PURE__ */ new Set(["SqlError", "ResultLengthMismatch"]), Nr = (e) => typeof e == "object" && !!e && typeof e._tag == "string" && Mr.has(e._tag), Pr = (e) => ({
|
|
1929
1929
|
_tag: "InternalError",
|
|
1930
1930
|
message: "internal server error",
|
|
1931
1931
|
traceId: e
|
|
1932
|
-
}),
|
|
1932
|
+
}), Fr = (e) => {
|
|
1933
1933
|
let t = j.squash(e);
|
|
1934
1934
|
t && typeof t == "object" && t._tag === "UnknownException" && (t = t.error ?? t.cause ?? t);
|
|
1935
1935
|
let n = t && typeof t == "object" ? t : {}, r = {};
|
|
@@ -1940,43 +1940,43 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
1940
1940
|
...typeof i == "string" ? { _tag: i } : {},
|
|
1941
1941
|
message: typeof a == "string" ? a : String(t)
|
|
1942
1942
|
};
|
|
1943
|
-
},
|
|
1944
|
-
let r = yield* Se, i = yield* ve, a = yield*
|
|
1945
|
-
|
|
1946
|
-
let o =
|
|
1943
|
+
}, Ir = (e, t, n = "rpc.mutation") => M.gen(function* () {
|
|
1944
|
+
let r = yield* Se, i = yield* ve, a = yield* xr;
|
|
1945
|
+
Cr(a, n, r);
|
|
1946
|
+
let o = br(r, a, i.clientId), s = gr({ subjectKey: fr(r.id, i.clientId) }, () => sr({
|
|
1947
1947
|
traceId: o.traceId,
|
|
1948
1948
|
...o.spanId === void 0 ? {} : { spanId: o.spanId }
|
|
1949
1949
|
}, () => e(t, o)));
|
|
1950
|
-
return yield* (
|
|
1950
|
+
return yield* (M.isEffect(s) ? s : M.tryPromise({
|
|
1951
1951
|
try: () => Promise.resolve(s),
|
|
1952
1952
|
catch: (e) => e
|
|
1953
|
-
})).pipe(
|
|
1954
|
-
}).pipe(
|
|
1955
|
-
let t = e.port ?? 4e3, n = e.path ?? "/ws", r =
|
|
1956
|
-
if (!e.inspectRoute) return
|
|
1953
|
+
})).pipe(M.tapErrorCause((e) => M.sync(() => jr(n, o.traceId, e))), M.catchIf(Nr, () => M.die(Pr(o.traceId))), M.annotateLogs(Sr(o)));
|
|
1954
|
+
}).pipe(M.withSpan(n, { attributes: { "framework.kind": "mutation" } })), Lr = 8 * 1024 * 1024, Rr = (e) => {
|
|
1955
|
+
let t = e.port ?? 4e3, n = e.path ?? "/ws", r = Xe(), i = (t) => et.HttpServerRequest.pipe(M.flatMap((t) => M.gen(function* () {
|
|
1956
|
+
if (!e.inspectRoute) return B.text("inspect route not configured", { status: 404 });
|
|
1957
1957
|
let n = {};
|
|
1958
1958
|
for (let [e, r] of Object.entries(t.headers)) r !== void 0 && (n[e.toLowerCase()] = Array.isArray(r) ? r.join(", ") : r);
|
|
1959
1959
|
let r;
|
|
1960
|
-
t.method !== "GET" && t.method !== "HEAD" && t.method !== "OPTIONS" && (r = yield* t.text.pipe(
|
|
1961
|
-
let i = e.inspectRoute.handle(t.url, n, t.method, r), a = i instanceof Promise ? yield*
|
|
1962
|
-
return a === null ?
|
|
1960
|
+
t.method !== "GET" && t.method !== "HEAD" && t.method !== "OPTIONS" && (r = yield* t.text.pipe(M.orElseSucceed(() => "")));
|
|
1961
|
+
let i = e.inspectRoute.handle(t.url, n, t.method, r), a = i instanceof Promise ? yield* M.promise(() => i) : i;
|
|
1962
|
+
return a === null ? B.text("inspect route not found", { status: 404 }) : B.text(a.body, {
|
|
1963
1963
|
status: a.status,
|
|
1964
1964
|
contentType: a.contentType,
|
|
1965
1965
|
headers: a.headers ?? {}
|
|
1966
1966
|
});
|
|
1967
|
-
}))), a = () =>
|
|
1967
|
+
}))), a = () => et.HttpServerRequest.pipe(M.flatMap((t) => {
|
|
1968
1968
|
let n = e.inspectStream;
|
|
1969
|
-
if (!n) return
|
|
1969
|
+
if (!n) return M.succeed(B.text("inspect stream not configured", { status: 404 }));
|
|
1970
1970
|
let r = {};
|
|
1971
1971
|
for (let [e, n] of Object.entries(t.headers)) n !== void 0 && (r[e.toLowerCase()] = Array.isArray(n) ? n.join(", ") : n);
|
|
1972
1972
|
let i = n.corsHeaders(r.origin);
|
|
1973
|
-
if (n.isDisabled()) return
|
|
1973
|
+
if (n.isDisabled()) return M.succeed(B.text(JSON.stringify({ error: "inspect disabled (VOLTRO_INSPECT=off)" }), {
|
|
1974
1974
|
status: 503,
|
|
1975
1975
|
contentType: "application/json; charset=utf-8",
|
|
1976
1976
|
headers: i
|
|
1977
1977
|
}));
|
|
1978
1978
|
let a = n.authorize(r);
|
|
1979
|
-
if (!a.ok) return
|
|
1979
|
+
if (!a.ok) return M.succeed(B.text(JSON.stringify({
|
|
1980
1980
|
error: "unauthorized",
|
|
1981
1981
|
reason: a.reason
|
|
1982
1982
|
}), {
|
|
@@ -1988,18 +1988,18 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
1988
1988
|
if (!f || e.indexOf("event: ") !== 0) return !0;
|
|
1989
1989
|
let t = e.indexOf("\n", 7);
|
|
1990
1990
|
return t < 0 || f.has(e.slice(7, t).trim());
|
|
1991
|
-
}, m =
|
|
1991
|
+
}, m = R.asyncScoped((e) => M.gen(function* () {
|
|
1992
1992
|
if (e.single(o.encode("retry: 5000\n\n")), !u) for (let t of n.replay()) p(t) && e.single(o.encode(t));
|
|
1993
1993
|
let t = n.subscribe((t) => {
|
|
1994
1994
|
p(t) && e.single(o.encode(t));
|
|
1995
1995
|
}), r = setInterval(() => {
|
|
1996
1996
|
e.single(o.encode(n.keepAlive()));
|
|
1997
1997
|
}, s);
|
|
1998
|
-
yield*
|
|
1998
|
+
yield* M.addFinalizer(() => M.sync(() => {
|
|
1999
1999
|
clearInterval(r), t();
|
|
2000
2000
|
}));
|
|
2001
2001
|
}));
|
|
2002
|
-
return
|
|
2002
|
+
return M.succeed(B.stream(m, {
|
|
2003
2003
|
status: 200,
|
|
2004
2004
|
headers: {
|
|
2005
2005
|
"content-type": "text/event-stream; charset=utf-8",
|
|
@@ -2009,57 +2009,57 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
2009
2009
|
...i
|
|
2010
2010
|
}
|
|
2011
2011
|
}));
|
|
2012
|
-
})), o =
|
|
2013
|
-
if (!e.inspectRoute) return
|
|
2012
|
+
})), o = z.add("*", "/_voltro/inspect/*", et.HttpServerRequest.pipe(M.flatMap((t) => M.gen(function* () {
|
|
2013
|
+
if (!e.inspectRoute) return B.text("inspect route not configured", { status: 404 });
|
|
2014
2014
|
let n = {};
|
|
2015
2015
|
for (let [e, r] of Object.entries(t.headers)) r !== void 0 && (n[e.toLowerCase()] = Array.isArray(r) ? r.join(", ") : r);
|
|
2016
2016
|
let r;
|
|
2017
|
-
t.method !== "GET" && t.method !== "HEAD" && t.method !== "OPTIONS" && (r = yield* t.text.pipe(
|
|
2018
|
-
let i = e.inspectRoute.handle(t.url, n, t.method, r), a = i instanceof Promise ? yield*
|
|
2019
|
-
return a === null ?
|
|
2017
|
+
t.method !== "GET" && t.method !== "HEAD" && t.method !== "OPTIONS" && (r = yield* t.text.pipe(M.orElseSucceed(() => "")));
|
|
2018
|
+
let i = e.inspectRoute.handle(t.url, n, t.method, r), a = i instanceof Promise ? yield* M.promise(() => i) : i;
|
|
2019
|
+
return a === null ? B.text("inspect route not found", { status: 404 }) : B.text(a.body, {
|
|
2020
2020
|
status: a.status,
|
|
2021
2021
|
contentType: a.contentType,
|
|
2022
2022
|
headers: a.headers ?? {}
|
|
2023
2023
|
});
|
|
2024
|
-
})))), s =
|
|
2025
|
-
e.inspectRoute !== void 0 && (s = e.inspectStream === void 0 ?
|
|
2026
|
-
let c =
|
|
2024
|
+
})))), s = N.empty;
|
|
2025
|
+
e.inspectRoute !== void 0 && (s = e.inspectStream === void 0 ? N.mergeAll(z.add("*", "/_voltro/inspect", i(!0)), o) : N.mergeAll(z.add("GET", "/_voltro/inspect/stream", a()), z.add("*", "/_voltro/inspect", i(!0)), o));
|
|
2026
|
+
let c = N.empty;
|
|
2027
2027
|
if (e.webhookRoutes !== void 0 && e.webhookRoutes.size > 0) {
|
|
2028
|
-
let t = (e) =>
|
|
2028
|
+
let t = (e) => et.HttpServerRequest.pipe(M.flatMap((t) => M.gen(function* () {
|
|
2029
2029
|
let n = {};
|
|
2030
2030
|
for (let [e, r] of Object.entries(t.headers)) r !== void 0 && (n[e.toLowerCase()] = Array.isArray(r) ? r.join(", ") : r);
|
|
2031
|
-
let r = t.method !== "GET" && t.method !== "HEAD" ? yield* t.text.pipe(
|
|
2031
|
+
let r = t.method !== "GET" && t.method !== "HEAD" ? yield* t.text.pipe(M.orElseSucceed(() => "")) : "", i = new TextEncoder().encode(r), a = t.url.split("?")[0], o = ar(n.traceparent), s = yield* M.promise(() => e.handle({
|
|
2032
2032
|
method: t.method,
|
|
2033
2033
|
path: a,
|
|
2034
2034
|
headers: n,
|
|
2035
2035
|
rawBody: i
|
|
2036
|
-
})).pipe(
|
|
2036
|
+
})).pipe(M.withSpan(`webhook${a}`, {
|
|
2037
2037
|
attributes: {
|
|
2038
2038
|
"framework.kind": "webhook",
|
|
2039
2039
|
"http.route": a
|
|
2040
2040
|
},
|
|
2041
2041
|
...o ? { parent: o } : {}
|
|
2042
2042
|
}));
|
|
2043
|
-
return
|
|
2043
|
+
return B.text(s.body, {
|
|
2044
2044
|
status: s.status,
|
|
2045
2045
|
contentType: s.contentType
|
|
2046
2046
|
});
|
|
2047
|
-
}))), n = Array.from(e.webhookRoutes.entries()).map(([e, n]) =>
|
|
2048
|
-
c =
|
|
2047
|
+
}))), n = Array.from(e.webhookRoutes.entries()).map(([e, n]) => z.add("*", e, t(n)));
|
|
2048
|
+
c = N.mergeAll(...n);
|
|
2049
2049
|
}
|
|
2050
|
-
let l =
|
|
2050
|
+
let l = N.empty;
|
|
2051
2051
|
if (e.httpRoutes !== void 0 && e.httpRoutes.length > 0) {
|
|
2052
|
-
let t = (e) =>
|
|
2052
|
+
let t = (e) => et.HttpServerRequest.pipe(M.flatMap((t) => M.gen(function* () {
|
|
2053
2053
|
let n = {};
|
|
2054
2054
|
for (let [e, r] of Object.entries(t.headers)) r !== void 0 && (n[e.toLowerCase()] = Array.isArray(r) ? r.join(", ") : r);
|
|
2055
|
-
let r = t.url.indexOf("?"), i = r >= 0 ? t.url.slice(0, r) : t.url, a = r >= 0 ? t.url.slice(r + 1) : "", o = t.method !== "GET" && t.method !== "HEAD" ? new Uint8Array(yield* t.arrayBuffer.pipe(
|
|
2055
|
+
let r = t.url.indexOf("?"), i = r >= 0 ? t.url.slice(0, r) : t.url, a = r >= 0 ? t.url.slice(r + 1) : "", o = t.method !== "GET" && t.method !== "HEAD" ? new Uint8Array(yield* t.arrayBuffer.pipe(M.orElseSucceed(() => /* @__PURE__ */ new ArrayBuffer(0)))) : /* @__PURE__ */ new Uint8Array(), s = {
|
|
2056
2056
|
method: t.method,
|
|
2057
2057
|
path: i,
|
|
2058
2058
|
query: a,
|
|
2059
2059
|
headers: n,
|
|
2060
2060
|
rawBody: o
|
|
2061
|
-
}, c = yield*
|
|
2062
|
-
c.status >= 500 &&
|
|
2061
|
+
}, c = yield* M.promise(() => ct(e, s));
|
|
2062
|
+
c.status >= 500 && Ar.warn(`${t.method} ${i} → ${c.status}`, {
|
|
2063
2063
|
method: t.method,
|
|
2064
2064
|
path: i,
|
|
2065
2065
|
status: c.status,
|
|
@@ -2070,45 +2070,45 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
2070
2070
|
...c.contentType ? { contentType: c.contentType } : {},
|
|
2071
2071
|
headers: l
|
|
2072
2072
|
};
|
|
2073
|
-
return c.body instanceof Uint8Array ?
|
|
2074
|
-
})),
|
|
2073
|
+
return c.body instanceof Uint8Array ? B.uint8Array(c.body, u) : B.text(c.body ?? "", u);
|
|
2074
|
+
})), M.tapErrorCause((t) => j.isInterruptedOnly(t) ? M.void : M.sync(() => Ar.error(`${e.map((e) => e.method).join("|")} ${e[0].path} threw`, { path: e[0].path }, j.squash(t))))), n = /* @__PURE__ */ new Map();
|
|
2075
2075
|
for (let t of e.httpRoutes) {
|
|
2076
2076
|
let e = n.get(t.path);
|
|
2077
2077
|
e ? e.push(t) : n.set(t.path, [t]);
|
|
2078
2078
|
}
|
|
2079
2079
|
let r = [...n.entries()].flatMap(([e, n]) => {
|
|
2080
2080
|
let r = n.length === 1 ? n[0].method : "*", i = t(n);
|
|
2081
|
-
return [
|
|
2081
|
+
return [z.add(r, e, i), z.add(r, `${e}/*`, i)];
|
|
2082
2082
|
});
|
|
2083
|
-
l =
|
|
2083
|
+
l = N.mergeAll(...r);
|
|
2084
2084
|
}
|
|
2085
|
-
let u =
|
|
2086
|
-
let e = yield*
|
|
2087
|
-
yield*
|
|
2085
|
+
let u = ot.layerProtocolWebsocketRouter({ path: n }), d = ot.layer(e.group), f = ot.layer(e.group).pipe(N.provide(ot.layerProtocolHttpRouter({ path: "/rpc" })), N.provide(at.layerJson), N.provide(e.httpHandlersLayer ?? e.handlersLayer)), p = N.scopedDiscard(M.gen(function* () {
|
|
2086
|
+
let e = yield* ot.Protocol;
|
|
2087
|
+
yield* M.forkScoped(M.gen(function* () {
|
|
2088
2088
|
let t = yield* e.disconnects.take;
|
|
2089
|
-
|
|
2090
|
-
}).pipe(
|
|
2091
|
-
})), m =
|
|
2092
|
-
let t = yield*
|
|
2089
|
+
Jn(t), Qn(t);
|
|
2090
|
+
}).pipe(M.forever));
|
|
2091
|
+
})), m = N.mergeAll(d, p).pipe(N.provide(u), N.provide(at.layerJson), N.provide(e.handlersLayer)), h = N.mergeAll(m, f, s, c, l), g = e.pluginHttpInterceptor, _ = e.healthCheck, v = Number(process.env.VOLTRO_MAX_RPC_BODY_BYTES), y = e.maxRpcBodyBytes ?? (Number.isFinite(v) && v > 0 ? v : 8388608), b = { "cache-control": "no-store" }, x = (e) => M.gen(function* () {
|
|
2092
|
+
let t = yield* et.HttpServerRequest, n = {};
|
|
2093
2093
|
for (let [e, r] of Object.entries(t.headers)) r !== void 0 && (n[e.toLowerCase()] = Array.isArray(r) ? r.join(", ") : r);
|
|
2094
2094
|
let r = t.url.indexOf("?"), i = r === -1 ? t.url : t.url.slice(0, r);
|
|
2095
2095
|
if (t.method === "POST" && i === "/rpc") {
|
|
2096
2096
|
let e = n["content-length"];
|
|
2097
|
-
if (e !== void 0 && Number(e) > y) return
|
|
2097
|
+
if (e !== void 0 && Number(e) > y) return B.text("rpc payload too large", {
|
|
2098
2098
|
status: 413,
|
|
2099
2099
|
headers: b
|
|
2100
2100
|
});
|
|
2101
2101
|
}
|
|
2102
|
-
if (_ && (i === "/internal/liveness" || i === "/internal/readiness")) return i === "/internal/liveness" ?
|
|
2102
|
+
if (_ && (i === "/internal/liveness" || i === "/internal/readiness")) return i === "/internal/liveness" ? B.text("ok", {
|
|
2103
2103
|
status: 200,
|
|
2104
2104
|
headers: b
|
|
2105
|
-
}) : _.isReady() ? _.ping && !(yield*
|
|
2105
|
+
}) : _.isReady() ? _.ping && !(yield* M.tryPromise(() => _.ping()).pipe(M.orElseSucceed(() => !1))) ? B.text("not-ready: dependency", {
|
|
2106
2106
|
status: 503,
|
|
2107
2107
|
headers: b
|
|
2108
|
-
}) :
|
|
2108
|
+
}) : B.text("ready", {
|
|
2109
2109
|
status: 200,
|
|
2110
2110
|
headers: b
|
|
2111
|
-
}) :
|
|
2111
|
+
}) : B.text("not-ready", {
|
|
2112
2112
|
status: 503,
|
|
2113
2113
|
headers: b
|
|
2114
2114
|
});
|
|
@@ -2119,23 +2119,23 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
2119
2119
|
} catch {
|
|
2120
2120
|
s = void 0;
|
|
2121
2121
|
}
|
|
2122
|
-
let c = o ?? s, l = yield*
|
|
2122
|
+
let c = o ?? s, l = yield* M.tryPromise(() => g(async () => null, {
|
|
2123
2123
|
method: t.method,
|
|
2124
2124
|
path: i,
|
|
2125
2125
|
headers: n,
|
|
2126
2126
|
remoteAddr: c
|
|
2127
|
-
})).pipe(
|
|
2128
|
-
return l === null ? yield* e :
|
|
2127
|
+
})).pipe(M.orElseSucceed(() => null));
|
|
2128
|
+
return l === null ? yield* e : B.text(l.body ?? "", {
|
|
2129
2129
|
status: l.status,
|
|
2130
2130
|
...l.headers ? { headers: l.headers } : {}
|
|
2131
2131
|
});
|
|
2132
|
-
}), S =
|
|
2133
|
-
e.tracerLayer && (S = S.pipe(
|
|
2134
|
-
let C = A({ scope: "voltro:rpc" }), ee =
|
|
2132
|
+
}), S = N.unwrapEffect(z.toHttpEffect(h).pipe(M.map((e) => $e.serve(x(e))))).pipe(N.provide(nt.layer(() => r, { port: t })), N.provide(tt.layer));
|
|
2133
|
+
e.tracerLayer && (S = S.pipe(N.provide(e.tracerLayer)));
|
|
2134
|
+
let C = A({ scope: "voltro:rpc" }), ee = N.launch(S).pipe(M.catchAllCause((e) => M.sync(() => {
|
|
2135
2135
|
C.error("rpc server crashed", {}, j.squash(e)), process.exit(1);
|
|
2136
2136
|
})));
|
|
2137
|
-
return
|
|
2138
|
-
},
|
|
2137
|
+
return rt.runMain(ee, { disableErrorReporting: !0 }), r;
|
|
2138
|
+
}, zr = (e, t = 1e4) => new Promise((n, r) => {
|
|
2139
2139
|
if (e.listening) {
|
|
2140
2140
|
n();
|
|
2141
2141
|
return;
|
|
@@ -2151,13 +2151,13 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
2151
2151
|
o(e);
|
|
2152
2152
|
}
|
|
2153
2153
|
a = setTimeout(() => o(/* @__PURE__ */ Error(`rpc server did not bind within ${t}ms`)), t), e.on("listening", s), e.on("error", c);
|
|
2154
|
-
}),
|
|
2154
|
+
}), Br = () => {
|
|
2155
2155
|
let e = process.env.FRAMEWORK_TRACING?.toLowerCase();
|
|
2156
2156
|
return e === "console" || e === "otlp" || e === "off" ? e : process.env.OTEL_EXPORTER_OTLP_ENDPOINT || process.env.OTEL_EXPORTER_OTLP_TRACES_ENDPOINT ? "otlp" : "off";
|
|
2157
|
-
},
|
|
2157
|
+
}, Vr = () => {
|
|
2158
2158
|
let e = process.env.FRAMEWORK_METRICS?.toLowerCase();
|
|
2159
2159
|
return e === "console" || e === "otlp" || e === "off" ? e : process.env.OTEL_EXPORTER_OTLP_ENDPOINT || process.env.OTEL_EXPORTER_OTLP_METRICS_ENDPOINT ? "otlp" : "off";
|
|
2160
|
-
},
|
|
2160
|
+
}, Hr = async () => {
|
|
2161
2161
|
let [e, t, n, r, i] = await Promise.all([
|
|
2162
2162
|
import("@opentelemetry/sdk-trace-base"),
|
|
2163
2163
|
import("@opentelemetry/sdk-metrics"),
|
|
@@ -2172,7 +2172,7 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
2172
2172
|
otlpMetrics: r,
|
|
2173
2173
|
nodeSdk: i
|
|
2174
2174
|
};
|
|
2175
|
-
},
|
|
2175
|
+
}, Ur = (e, t, n) => {
|
|
2176
2176
|
let { PeriodicExportingMetricReader: r, ConsoleMetricExporter: i, InMemoryMetricExporter: a, AggregationTemporality: o } = e.sdkMetrics;
|
|
2177
2177
|
if (t === "off") return {
|
|
2178
2178
|
reader: void 0,
|
|
@@ -2195,23 +2195,23 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
2195
2195
|
}),
|
|
2196
2196
|
inMemory: void 0
|
|
2197
2197
|
};
|
|
2198
|
-
},
|
|
2199
|
-
let t = e.mode ??
|
|
2198
|
+
}, Wr = async (e = {}) => {
|
|
2199
|
+
let t = e.mode ?? Br(), n = e.metricsMode ?? Vr(), r = e.extraSpanProcessors ?? [], i = e.extraMetricReaders ?? [];
|
|
2200
2200
|
if (t === "off" && e.traceSink === void 0 && n === "off" && r.length === 0 && i.length === 0) return {
|
|
2201
|
-
layer:
|
|
2201
|
+
layer: N.empty,
|
|
2202
2202
|
mode: t,
|
|
2203
2203
|
bufferOnly: !1,
|
|
2204
2204
|
inMemoryExporter: void 0,
|
|
2205
2205
|
metricsMode: n,
|
|
2206
2206
|
inMemoryMetricExporter: void 0
|
|
2207
2207
|
};
|
|
2208
|
-
let a = await
|
|
2208
|
+
let a = await Hr(), { ConsoleSpanExporter: o, InMemorySpanExporter: s, SimpleSpanProcessor: c, BatchSpanProcessor: l } = a.sdkTrace, u = t === "off", d = e.serviceName ?? process.env.OTEL_SERVICE_NAME ?? "voltro-app", f, p;
|
|
2209
2209
|
e.spanProcessor ? p = e.spanProcessor : u ? p = void 0 : t === "memory" ? (f = new s(), p = new c(f)) : p = t === "console" ? new c(new o()) : new l(new a.otlpTrace.OTLPTraceExporter());
|
|
2210
2210
|
let m = [
|
|
2211
2211
|
...e.traceSink ? [e.traceSink] : [],
|
|
2212
2212
|
...p ? [p] : [],
|
|
2213
2213
|
...r
|
|
2214
|
-
], h = m.length === 1 ? m[0] : m, { reader: g, inMemory: _ } =
|
|
2214
|
+
], h = m.length === 1 ? m[0] : m, { reader: g, inMemory: _ } = Ur(a, n, e.metricExportIntervalMillis ?? (process.env.OTEL_METRIC_EXPORT_INTERVAL ? Number(process.env.OTEL_METRIC_EXPORT_INTERVAL) : 6e4)), v = [...g ? [g] : [], ...i], y = v.length === 0 ? void 0 : v.length === 1 ? v[0] : v, b = {
|
|
2215
2215
|
serviceName: d,
|
|
2216
2216
|
...e.serviceVersion ? { serviceVersion: e.serviceVersion } : {},
|
|
2217
2217
|
...e.resourceAttributes ? { attributes: e.resourceAttributes } : {}
|
|
@@ -2229,18 +2229,18 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
2229
2229
|
metricsMode: n,
|
|
2230
2230
|
inMemoryMetricExporter: _
|
|
2231
2231
|
};
|
|
2232
|
-
},
|
|
2233
|
-
[
|
|
2234
|
-
[
|
|
2235
|
-
[
|
|
2236
|
-
[
|
|
2237
|
-
[
|
|
2238
|
-
},
|
|
2232
|
+
}, Gr = {
|
|
2233
|
+
[dt.INTERNAL]: "internal",
|
|
2234
|
+
[dt.SERVER]: "server",
|
|
2235
|
+
[dt.CLIENT]: "client",
|
|
2236
|
+
[dt.PRODUCER]: "producer",
|
|
2237
|
+
[dt.CONSUMER]: "consumer"
|
|
2238
|
+
}, Kr = (e) => e[0] * 1e3 + e[1] / 1e6, qr = 512, Jr = 48, Yr = (e) => {
|
|
2239
2239
|
let t = {}, n = 0;
|
|
2240
2240
|
for (let r in e) {
|
|
2241
|
-
if (n >=
|
|
2241
|
+
if (n >= Jr) break;
|
|
2242
2242
|
let i = e[r];
|
|
2243
|
-
if (typeof i == "string") t[r] = i.length >
|
|
2243
|
+
if (typeof i == "string") t[r] = i.length > qr ? `${i.slice(0, qr)}…` : i;
|
|
2244
2244
|
else if (typeof i == "number" || typeof i == "boolean" || i == null) t[r] = i;
|
|
2245
2245
|
else {
|
|
2246
2246
|
let e;
|
|
@@ -2249,49 +2249,49 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
2249
2249
|
} catch {
|
|
2250
2250
|
e = String(i);
|
|
2251
2251
|
}
|
|
2252
|
-
t[r] = e.length >
|
|
2252
|
+
t[r] = e.length > qr ? `${e.slice(0, qr)}…` : e;
|
|
2253
2253
|
}
|
|
2254
2254
|
n++;
|
|
2255
2255
|
}
|
|
2256
2256
|
return t;
|
|
2257
|
-
},
|
|
2258
|
-
[
|
|
2259
|
-
[
|
|
2260
|
-
[
|
|
2261
|
-
},
|
|
2257
|
+
}, Xr = {
|
|
2258
|
+
[ft.UNSET]: "unset",
|
|
2259
|
+
[ft.OK]: "ok",
|
|
2260
|
+
[ft.ERROR]: "error"
|
|
2261
|
+
}, Zr = (e) => {
|
|
2262
2262
|
let t = e.spanContext(), n = e.events.length > 0 ? e.events.slice(0, 16).map((e) => ({
|
|
2263
2263
|
name: e.name,
|
|
2264
|
-
tsMs:
|
|
2265
|
-
...e.attributes ? { attributes:
|
|
2264
|
+
tsMs: Kr(e.time),
|
|
2265
|
+
...e.attributes ? { attributes: Yr(e.attributes) } : {}
|
|
2266
2266
|
})) : void 0;
|
|
2267
2267
|
return {
|
|
2268
2268
|
traceId: t.traceId,
|
|
2269
2269
|
spanId: t.spanId,
|
|
2270
2270
|
parentSpanId: e.parentSpanContext?.spanId ?? null,
|
|
2271
2271
|
name: e.name,
|
|
2272
|
-
kind:
|
|
2273
|
-
attributes:
|
|
2274
|
-
startMs:
|
|
2275
|
-
endMs:
|
|
2276
|
-
durationMs:
|
|
2277
|
-
status:
|
|
2272
|
+
kind: Gr[e.kind] ?? "internal",
|
|
2273
|
+
attributes: Yr(e.attributes),
|
|
2274
|
+
startMs: Kr(e.startTime),
|
|
2275
|
+
endMs: Kr(e.endTime),
|
|
2276
|
+
durationMs: Kr(e.duration),
|
|
2277
|
+
status: Xr[e.status.code] ?? "unset",
|
|
2278
2278
|
...e.status.message ? { statusMessage: e.status.message } : {},
|
|
2279
2279
|
...n ? { events: n } : {}
|
|
2280
2280
|
};
|
|
2281
|
-
},
|
|
2281
|
+
}, Qr = (e) => ({
|
|
2282
2282
|
onStart: () => {},
|
|
2283
2283
|
onEnd: (t) => {
|
|
2284
2284
|
try {
|
|
2285
|
-
e(
|
|
2285
|
+
e(Zr(t));
|
|
2286
2286
|
} catch {}
|
|
2287
2287
|
},
|
|
2288
2288
|
forceFlush: () => Promise.resolve(),
|
|
2289
2289
|
shutdown: () => Promise.resolve()
|
|
2290
|
-
}),
|
|
2291
|
-
|
|
2292
|
-
},
|
|
2293
|
-
|
|
2294
|
-
},
|
|
2290
|
+
}), $r = { get: (e) => Promise.resolve(process.env[e]) }, ei = $r, ti = (e) => {
|
|
2291
|
+
ei = e;
|
|
2292
|
+
}, ni = () => {
|
|
2293
|
+
ei = $r;
|
|
2294
|
+
}, ri = async (e) => await ei.get(e) ?? process.env[e], ii = (e) => process.env[e], ai = (e, t = 6e4, n = () => Date.now()) => {
|
|
2295
2295
|
let r = /* @__PURE__ */ new Map();
|
|
2296
2296
|
return { get: async (i) => {
|
|
2297
2297
|
let a = r.get(i);
|
|
@@ -2302,12 +2302,12 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
2302
2302
|
at: n()
|
|
2303
2303
|
}), o;
|
|
2304
2304
|
} };
|
|
2305
|
-
},
|
|
2305
|
+
}, oi = (e) => {
|
|
2306
2306
|
let t = {
|
|
2307
2307
|
accept: "application/json",
|
|
2308
2308
|
...e.headers ?? {}
|
|
2309
2309
|
};
|
|
2310
|
-
if (e.perKey) return
|
|
2310
|
+
if (e.perKey) return ai({ get: async (n) => {
|
|
2311
2311
|
let r = await fetch(`${e.url.replace(/\/$/, "")}/${encodeURIComponent(n)}`, { headers: t });
|
|
2312
2312
|
if (!r.ok) return;
|
|
2313
2313
|
let i = await r.json();
|
|
@@ -2318,7 +2318,7 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
2318
2318
|
let t = (await a())[e];
|
|
2319
2319
|
return typeof t == "string" ? t : void 0;
|
|
2320
2320
|
} };
|
|
2321
|
-
},
|
|
2321
|
+
}, si = (e) => e === void 0 || e === "env" || typeof e == "object" && e.kind === "env" ? $r : e.kind === "custom" ? e.backend : e.kind === "http" ? oi(e) : $r, ci = (e) => /^[0-9a-f]{64}$/i.test(e) ? Buffer.from(e, "hex") : he(e, "voltro:field-encryption:v1", 32), li = (t) => {
|
|
2322
2322
|
if (t.length !== 32) throw Error(`field cipher key must be 32 bytes, got ${t.length}`);
|
|
2323
2323
|
return {
|
|
2324
2324
|
encrypt: (n) => {
|
|
@@ -2332,16 +2332,16 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
2332
2332
|
return o.setAuthTag(Buffer.from(i, "base64")), Buffer.concat([o.update(Buffer.from(a, "base64")), o.final()]).toString("utf8");
|
|
2333
2333
|
}
|
|
2334
2334
|
};
|
|
2335
|
-
},
|
|
2336
|
-
|
|
2337
|
-
},
|
|
2338
|
-
let t =
|
|
2339
|
-
if (!t) throw Error(`encryptField: ${
|
|
2335
|
+
}, ui = (e) => li(ci(e)), di, fi = (e) => {
|
|
2336
|
+
di = e;
|
|
2337
|
+
}, pi = () => di, mi = "no field cipher registered — enable `@voltro/plugin-governance` `governancePlugin({ fieldEncryption: { key } })` (or call setFieldCipher) so a key is available.", q = (e) => {
|
|
2338
|
+
let t = pi();
|
|
2339
|
+
if (!t) throw Error(`encryptField: ${mi}`);
|
|
2340
2340
|
return t.encrypt(e);
|
|
2341
2341
|
}, hi = (e) => {
|
|
2342
2342
|
if (!x(e)) return e;
|
|
2343
|
-
let t =
|
|
2344
|
-
if (!t) throw Error(`decryptField: ${
|
|
2343
|
+
let t = pi();
|
|
2344
|
+
if (!t) throw Error(`decryptField: ${mi}`);
|
|
2345
2345
|
return t.decrypt(e);
|
|
2346
2346
|
}, gi = "_voltro_idempotency", _i = (e) => {
|
|
2347
2347
|
if (e == null) return null;
|
|
@@ -2419,9 +2419,9 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
2419
2419
|
skip: void 0,
|
|
2420
2420
|
projection: void 0
|
|
2421
2421
|
}))[0] ?? null, Ti = (e) => {
|
|
2422
|
-
let n = (e, t, n) =>
|
|
2422
|
+
let n = (e, t, n) => M.tryPromise({
|
|
2423
2423
|
try: n,
|
|
2424
|
-
catch: (n) => new
|
|
2424
|
+
catch: (n) => new mt({
|
|
2425
2425
|
operation: e,
|
|
2426
2426
|
key: t,
|
|
2427
2427
|
cause: String(n)
|
|
@@ -2430,7 +2430,7 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
2430
2430
|
return {
|
|
2431
2431
|
get: (t) => n("get", t, async () => {
|
|
2432
2432
|
let n = await wi(e, t);
|
|
2433
|
-
return n === null ?
|
|
2433
|
+
return n === null ? F.none() : Si(n, Date.now()) ? (await e.delete(J, n.id), F.none()) : F.some(Ci(n.value));
|
|
2434
2434
|
}),
|
|
2435
2435
|
set: (t, r, i) => n("set", t, async () => {
|
|
2436
2436
|
let n = Date.now(), a = i?.ttlMs !== void 0 && i.ttlMs > 0 ? new Date(n + i.ttlMs) : null, o = f({
|
|
@@ -2482,10 +2482,10 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
2482
2482
|
})
|
|
2483
2483
|
};
|
|
2484
2484
|
}, Ei = async ({ store: e, env: t = process.env }) => {
|
|
2485
|
-
let n = (t.KV_BACKEND ?? "database").toLowerCase(), r = n === "redis" ? "redis" : n === "memory" ? "memory" : "database", i = r === "redis" ?
|
|
2485
|
+
let n = (t.KV_BACKEND ?? "database").toLowerCase(), r = n === "redis" ? "redis" : n === "memory" ? "memory" : "database", i = r === "redis" ? vt(t.KV_KEY_PREFIX ? { keyPrefix: t.KV_KEY_PREFIX } : {}).pipe(N.provide(gt)) : r === "memory" ? _t() : N.succeed(ht, ht.of(Ti(e))), a = We.make(pt.Default.pipe(N.provide(i))), o = await a.runPromise(pt);
|
|
2486
2486
|
return {
|
|
2487
2487
|
kv: {
|
|
2488
|
-
get: (e) => a.runPromise(o.get(e)).then((e) =>
|
|
2488
|
+
get: (e) => a.runPromise(o.get(e)).then((e) => F.getOrUndefined(e)),
|
|
2489
2489
|
getOrElse: (e, t) => a.runPromise(o.getOrElse(e, t)),
|
|
2490
2490
|
set: (e, t, n) => a.runPromise(o.set(e, t, n)),
|
|
2491
2491
|
delete: (e) => a.runPromise(o.delete(e)),
|
|
@@ -2630,7 +2630,7 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
2630
2630
|
await e.update(Oi, t, n(r));
|
|
2631
2631
|
}
|
|
2632
2632
|
};
|
|
2633
|
-
}, Ri = (e, t = {}) =>
|
|
2633
|
+
}, Ri = (e, t = {}) => yt({
|
|
2634
2634
|
id: "voltro-apikey",
|
|
2635
2635
|
...t.prefix ? { prefix: t.prefix } : {},
|
|
2636
2636
|
resolveKey: (t) => e.resolveByHash(t)
|
|
@@ -2641,32 +2641,32 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
2641
2641
|
tenantId: t.tenantId ?? null
|
|
2642
2642
|
};
|
|
2643
2643
|
}, Bi = (e, t = "/v1/api-keys") => {
|
|
2644
|
-
let n =
|
|
2645
|
-
id:
|
|
2646
|
-
name:
|
|
2647
|
-
keyPrefix:
|
|
2648
|
-
tenantId:
|
|
2649
|
-
scopes:
|
|
2650
|
-
lastUsedAt:
|
|
2651
|
-
expiresAt:
|
|
2652
|
-
revokedAt:
|
|
2653
|
-
createdAt:
|
|
2644
|
+
let n = L.Struct({
|
|
2645
|
+
id: L.String,
|
|
2646
|
+
name: L.String,
|
|
2647
|
+
keyPrefix: L.String,
|
|
2648
|
+
tenantId: L.NullOr(L.String),
|
|
2649
|
+
scopes: L.Array(L.String),
|
|
2650
|
+
lastUsedAt: L.NullOr(L.Number),
|
|
2651
|
+
expiresAt: L.NullOr(L.Number),
|
|
2652
|
+
revokedAt: L.NullOr(L.Number),
|
|
2653
|
+
createdAt: L.Number
|
|
2654
2654
|
});
|
|
2655
2655
|
return [
|
|
2656
|
-
|
|
2656
|
+
st({
|
|
2657
2657
|
method: "POST",
|
|
2658
2658
|
path: `${t}/issue`,
|
|
2659
2659
|
summary: "Issue an API key (the token is returned ONCE).",
|
|
2660
|
-
guards: [
|
|
2661
|
-
input:
|
|
2662
|
-
name:
|
|
2663
|
-
scopes:
|
|
2664
|
-
expiresInDays:
|
|
2660
|
+
guards: [lt(_e)],
|
|
2661
|
+
input: L.Struct({ body: L.Struct({
|
|
2662
|
+
name: L.String,
|
|
2663
|
+
scopes: L.optional(L.Array(L.String)),
|
|
2664
|
+
expiresInDays: L.optional(L.Number)
|
|
2665
2665
|
}) }),
|
|
2666
|
-
output:
|
|
2667
|
-
id:
|
|
2668
|
-
token:
|
|
2669
|
-
keyPrefix:
|
|
2666
|
+
output: L.Struct({
|
|
2667
|
+
id: L.String,
|
|
2668
|
+
token: L.String,
|
|
2669
|
+
keyPrefix: L.String
|
|
2670
2670
|
}),
|
|
2671
2671
|
handler: async (t, n) => {
|
|
2672
2672
|
let r = t.body, i = zi(n), a = await e.issue({
|
|
@@ -2683,53 +2683,53 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
2683
2683
|
};
|
|
2684
2684
|
}
|
|
2685
2685
|
}),
|
|
2686
|
-
|
|
2686
|
+
st({
|
|
2687
2687
|
method: "GET",
|
|
2688
2688
|
path: t,
|
|
2689
2689
|
summary: "List the caller tenant's API keys (no secrets).",
|
|
2690
|
-
guards: [
|
|
2691
|
-
input:
|
|
2692
|
-
output:
|
|
2690
|
+
guards: [lt(_e)],
|
|
2691
|
+
input: L.Struct({}),
|
|
2692
|
+
output: L.Struct({ keys: L.Array(n) }),
|
|
2693
2693
|
handler: async (t, n) => ({ keys: [...await e.list(zi(n).tenantId)] })
|
|
2694
2694
|
}),
|
|
2695
|
-
|
|
2695
|
+
st({
|
|
2696
2696
|
method: "POST",
|
|
2697
2697
|
path: `${t}/revoke`,
|
|
2698
2698
|
summary: "Revoke an API key by id.",
|
|
2699
|
-
guards: [
|
|
2700
|
-
input:
|
|
2701
|
-
output:
|
|
2699
|
+
guards: [lt(_e)],
|
|
2700
|
+
input: L.Struct({ body: L.Struct({ id: L.String }) }),
|
|
2701
|
+
output: L.Struct({ ok: L.Boolean }),
|
|
2702
2702
|
handler: async (t, n) => ({ ok: await e.revoke(t.body.id) })
|
|
2703
2703
|
})
|
|
2704
2704
|
];
|
|
2705
|
-
}, Vi = class extends
|
|
2706
|
-
table:
|
|
2707
|
-
reason:
|
|
2708
|
-
}) {}, Hi = class extends
|
|
2709
|
-
operation:
|
|
2710
|
-
table:
|
|
2711
|
-
cause:
|
|
2712
|
-
}) {}, Ui = class extends
|
|
2713
|
-
table:
|
|
2714
|
-
summary:
|
|
2715
|
-
issues:
|
|
2716
|
-
path:
|
|
2717
|
-
message:
|
|
2705
|
+
}, Vi = class extends L.TaggedError()("TenantScopeViolation", {
|
|
2706
|
+
table: L.String,
|
|
2707
|
+
reason: L.String
|
|
2708
|
+
}) {}, Hi = class extends L.TaggedError()("StoreOperationFailed", {
|
|
2709
|
+
operation: L.String,
|
|
2710
|
+
table: L.String,
|
|
2711
|
+
cause: L.String
|
|
2712
|
+
}) {}, Ui = class extends L.TaggedError()("TableValidationFailed", {
|
|
2713
|
+
table: L.String,
|
|
2714
|
+
summary: L.String,
|
|
2715
|
+
issues: L.Array(L.Struct({
|
|
2716
|
+
path: L.String,
|
|
2717
|
+
message: L.String
|
|
2718
2718
|
}))
|
|
2719
2719
|
}) {}, Wi = class extends Re.Tag("@voltro/EffectStore")() {}, Gi = (e, t) => (n) => n instanceof Vi ? n : new Hi({
|
|
2720
2720
|
operation: e,
|
|
2721
2721
|
table: t,
|
|
2722
2722
|
cause: String(n)
|
|
2723
|
-
}), Ki = (e, t, n) =>
|
|
2723
|
+
}), Ki = (e, t, n) => M.tryPromise({
|
|
2724
2724
|
try: n,
|
|
2725
2725
|
catch: Gi(e, t)
|
|
2726
|
-
}), qi = (e) =>
|
|
2726
|
+
}), qi = (e) => N.succeed(Wi, {
|
|
2727
2727
|
query: ((t) => Ki("query", t.table, () => e.query(t))),
|
|
2728
2728
|
insert: (t, n) => Ki("insert", t, () => e.insert(t, n)),
|
|
2729
2729
|
update: (t, n, r) => Ki("update", t, () => e.update(t, n, r)),
|
|
2730
2730
|
delete: (t, n) => Ki("delete", t, () => e.delete(t, n)),
|
|
2731
2731
|
hardDelete: (t, n) => Ki("hardDelete", t, () => e.hardDelete(t, n))
|
|
2732
|
-
}), Ji = (e) =>
|
|
2732
|
+
}), Ji = (e) => it.make(e.name, {
|
|
2733
2733
|
payload: e.payloadSchema,
|
|
2734
2734
|
success: Ee,
|
|
2735
2735
|
error: e.errorSchema
|
|
@@ -2759,7 +2759,7 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
2759
2759
|
};
|
|
2760
2760
|
if (typeof n == "object" && n && n._tag === "Complete") {
|
|
2761
2761
|
let r = n.exit;
|
|
2762
|
-
return
|
|
2762
|
+
return Ue.isSuccess(r) ? {
|
|
2763
2763
|
id: t,
|
|
2764
2764
|
workflowName: e,
|
|
2765
2765
|
executionId: t,
|
|
@@ -2787,7 +2787,7 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
2787
2787
|
}, r = async (t, r) => {
|
|
2788
2788
|
let i = n(t);
|
|
2789
2789
|
return Qi(t, r, await e.runEffect(i.poll(r)));
|
|
2790
|
-
}, i = async () => e.runEffect(
|
|
2790
|
+
}, i = async () => e.runEffect(bt()), a = async (t, r, i) => {
|
|
2791
2791
|
let a = n(t), o;
|
|
2792
2792
|
return i?.callerContext !== void 0 && (o = await e.runEffect(a.executionId(r)), await e.rememberStartContext?.(t, o, i.callerContext)), i?.wait ? (await e.runEffect(a.execute(r)), Yi(t, o ?? await e.runEffect(a.executionId(r)))) : Yi(t, await e.runEffect(a.execute(r, { discard: !0 })));
|
|
2793
2793
|
};
|
|
@@ -2917,18 +2917,18 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
2917
2917
|
};
|
|
2918
2918
|
}, ia = (e, t) => {
|
|
2919
2919
|
let n = {};
|
|
2920
|
-
for (let r of e) n[r.definition.name] = (e) => (t ?
|
|
2920
|
+
for (let r of e) n[r.definition.name] = (e) => (t ? M.promise(() => t.start(r.definition.name, e)) : r.definition.execute(e, { discard: !0 }).pipe(M.map((e) => Yi(r.definition.name, e)))).pipe(M.withSpan(`workflow.${r.definition.name}`, { attributes: { "framework.kind": "workflow" } }));
|
|
2921
2921
|
return n;
|
|
2922
2922
|
}, aa = (e, t, n) => e.map((e) => e.definition.toLayer(((r, i) => {
|
|
2923
2923
|
let a = t.resolveStartContext?.(e.definition.name, i);
|
|
2924
|
-
return (a === void 0 ?
|
|
2924
|
+
return (a === void 0 ? M.succeed(void 0) : M.promise(() => Promise.resolve(a))).pipe(M.flatMap((a) => {
|
|
2925
2925
|
let o = t.buildContext(a, {
|
|
2926
2926
|
workflowName: e.definition.name,
|
|
2927
2927
|
executionId: i,
|
|
2928
2928
|
parentExecutionId: a?.parentExecutionId ?? null,
|
|
2929
2929
|
parentClosePolicy: a?.parentClosePolicy ?? null
|
|
2930
2930
|
}), s = e.buildExecute(o), c = (n?.(e, s, a) ?? s)(r, i), l = o?.store;
|
|
2931
|
-
return l === void 0 ? c :
|
|
2931
|
+
return l === void 0 ? c : M.provide(c, qi(l));
|
|
2932
2932
|
}));
|
|
2933
2933
|
}))), oa = (e) => ({
|
|
2934
2934
|
_tag: "workflowEventTrigger",
|
|
@@ -3410,7 +3410,7 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
3410
3410
|
}
|
|
3411
3411
|
return e;
|
|
3412
3412
|
}, Ra = (e) => e.label ?? e.id, za = (e) => {
|
|
3413
|
-
if (e.length !== 0 &&
|
|
3413
|
+
if (e.length !== 0 && pi() === void 0) throw Error(`connections: ${e.length} connection(s) declared (${e.map((e) => e.id).join(", ")}) but no field cipher is registered. Connection tokens are stored encrypted and there is no plaintext fallback. Enable \`@voltro/plugin-governance\` with \`governancePlugin({ fieldEncryption: { key: env.FIELD_ENCRYPTION_KEY } })\` (or call setFieldCipher at boot).`);
|
|
3414
3414
|
}, Ba = (e) => {
|
|
3415
3415
|
let t = /* @__PURE__ */ new Map();
|
|
3416
3416
|
for (let n of e) {
|
|
@@ -3462,8 +3462,8 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
3462
3462
|
tenantId: e.tenantId,
|
|
3463
3463
|
kind: e.definition.kind,
|
|
3464
3464
|
status: "connected",
|
|
3465
|
-
accessToken:
|
|
3466
|
-
refreshToken: e.tokens.refreshToken === void 0 ? null :
|
|
3465
|
+
accessToken: q(e.tokens.accessToken),
|
|
3466
|
+
refreshToken: e.tokens.refreshToken === void 0 ? null : q(e.tokens.refreshToken),
|
|
3467
3467
|
expiresAt: n,
|
|
3468
3468
|
scopes: e.tokens.scopes.length > 0 ? e.tokens.scopes.join(" ") : null,
|
|
3469
3469
|
accountId: e.account?.accountId ?? null,
|
|
@@ -3634,7 +3634,7 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
3634
3634
|
refreshLockedUntil: /* @__PURE__ */ new Date(0),
|
|
3635
3635
|
updatedAt: new Date(i()),
|
|
3636
3636
|
...t.transient ? {} : {
|
|
3637
|
-
accessToken:
|
|
3637
|
+
accessToken: q(""),
|
|
3638
3638
|
refreshToken: null,
|
|
3639
3639
|
expiresAt: null
|
|
3640
3640
|
}
|
|
@@ -3646,8 +3646,8 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
3646
3646
|
}
|
|
3647
3647
|
let f = {
|
|
3648
3648
|
status: "connected",
|
|
3649
|
-
accessToken:
|
|
3650
|
-
...d.refreshToken === void 0 ? {} : { refreshToken:
|
|
3649
|
+
accessToken: q(d.accessToken),
|
|
3650
|
+
...d.refreshToken === void 0 ? {} : { refreshToken: q(d.refreshToken) },
|
|
3651
3651
|
expiresAt: d.expiresAt === void 0 ? null : new Date(d.expiresAt),
|
|
3652
3652
|
...d.scopes.length > 0 ? { scopes: d.scopes.join(" ") } : {},
|
|
3653
3653
|
lastError: null,
|
|
@@ -3676,7 +3676,7 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
3676
3676
|
connectionId: n.id,
|
|
3677
3677
|
subjectId: e.subjectId,
|
|
3678
3678
|
tenantId: e.tenantId,
|
|
3679
|
-
codeVerifier: i === null ? null :
|
|
3679
|
+
codeVerifier: i === null ? null : q(i),
|
|
3680
3680
|
redirectTo: _o(e.redirectTo),
|
|
3681
3681
|
createdAt: t,
|
|
3682
3682
|
expiresAt: new Date(t.getTime() + ho)
|
|
@@ -3879,10 +3879,10 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
3879
3879
|
ko(e, t.connectionId);
|
|
3880
3880
|
let r = Oo(n, t.connectionId);
|
|
3881
3881
|
return { ok: await Ja(n.store, t.connectionId, r) };
|
|
3882
|
-
}, Po = "admin:full", Fo = class extends
|
|
3883
|
-
action:
|
|
3884
|
-
resourceType:
|
|
3885
|
-
resourceId:
|
|
3882
|
+
}, Po = "admin:full", Fo = class extends L.TaggedError()("AccessDenied", {
|
|
3883
|
+
action: L.String,
|
|
3884
|
+
resourceType: L.String,
|
|
3885
|
+
resourceId: L.String
|
|
3886
3886
|
}) {}, Io = /* @__PURE__ */ new Map(), Lo = (e) => {
|
|
3887
3887
|
if (typeof e.resourceType != "string" || e.resourceType.length === 0) throw Error("defineResourcePolicy: a non-empty `resourceType` is required");
|
|
3888
3888
|
if (e.actions === void 0 || Object.keys(e.actions).length === 0) throw Error(`resource policy '${e.resourceType}': at least one action is required`);
|
|
@@ -3933,7 +3933,7 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
3933
3933
|
}, Jo = A({ scope: "voltro:policy" }), Yo, Xo = (e) => {
|
|
3934
3934
|
Yo = e;
|
|
3935
3935
|
}, Zo = () => Yo, Qo = () => {
|
|
3936
|
-
Pe((e) =>
|
|
3936
|
+
Pe((e) => M.gen(function* () {
|
|
3937
3937
|
let t = Ro(e.resourceType);
|
|
3938
3938
|
if (t === void 0) return Jo.warn("policy guard denied — no resource policy registered for this type", {
|
|
3939
3939
|
resourceType: e.resourceType,
|
|
@@ -3944,17 +3944,17 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
3944
3944
|
resourceType: e.resourceType,
|
|
3945
3945
|
action: e.action
|
|
3946
3946
|
}), !1;
|
|
3947
|
-
let r = yield*
|
|
3947
|
+
let r = yield* M.tryPromise({
|
|
3948
3948
|
try: async () => n({
|
|
3949
3949
|
subjectId: e.subject.id,
|
|
3950
3950
|
resourceType: e.resourceType,
|
|
3951
3951
|
resourceId: e.resourceId
|
|
3952
3952
|
}),
|
|
3953
3953
|
catch: (e) => e
|
|
3954
|
-
}).pipe(
|
|
3954
|
+
}).pipe(M.catchAll((t) => (Jo.error("policy guard denied — tuple source failed", {
|
|
3955
3955
|
resourceType: e.resourceType,
|
|
3956
3956
|
resourceId: e.resourceId
|
|
3957
|
-
}, t),
|
|
3957
|
+
}, t), M.succeed([])))), i = e.subject;
|
|
3958
3958
|
return Wo({
|
|
3959
3959
|
id: e.subject.id,
|
|
3960
3960
|
tenantId: i.tenantId ?? null,
|
|
@@ -4017,11 +4017,11 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
4017
4017
|
load: async (e, t) => (await o(e, [t]))[0] ?? null,
|
|
4018
4018
|
loadMany: (e, t) => o(e, t)
|
|
4019
4019
|
};
|
|
4020
|
-
}, ts =
|
|
4020
|
+
}, ts = N.effect(Ze.HttpClient, M.map(Ze.HttpClient, (e) => e.pipe(Ze.mapRequestEffect((e) => M.currentSpan.pipe(M.map((t) => e.headers.traceparent === void 0 ? Qe.setHeader(e, "traceparent", rr({
|
|
4021
4021
|
traceId: t.traceId,
|
|
4022
4022
|
spanId: t.spanId,
|
|
4023
4023
|
sampled: t.sampled
|
|
4024
|
-
})) : e),
|
|
4024
|
+
})) : e), M.catchAll(() => M.succeed(e))))))), ns = "voltro/audit", rs = "voltro/softDelete", is = "voltro/tenant", as = (e) => {
|
|
4025
4025
|
let t = /* @__PURE__ */ new Map();
|
|
4026
4026
|
for (let n of e) {
|
|
4027
4027
|
let e = /* @__PURE__ */ new Set();
|
|
@@ -4069,16 +4069,16 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
4069
4069
|
insertSchema: (e) => t.get(e)?.insertSchema,
|
|
4070
4070
|
validatePatchSchema: (e) => t.get(e)?.validatePatchSchema
|
|
4071
4071
|
};
|
|
4072
|
-
}, os = /* @__PURE__ */ new Map(), ss = /* @__PURE__ */ new Map(), cs = as([]), ls = class extends
|
|
4073
|
-
table:
|
|
4074
|
-
found:
|
|
4072
|
+
}, os = /* @__PURE__ */ new Map(), ss = /* @__PURE__ */ new Map(), cs = as([]), ls = class extends L.TaggedError()("NoRowFound", {
|
|
4073
|
+
table: L.String,
|
|
4074
|
+
found: L.Number
|
|
4075
4075
|
}) {
|
|
4076
4076
|
get message() {
|
|
4077
4077
|
return this.found === 0 ? `expected exactly one row in '${this.table}', found none` : `expected exactly one row in '${this.table}', found more than one`;
|
|
4078
4078
|
}
|
|
4079
|
-
}, us = class extends
|
|
4080
|
-
table:
|
|
4081
|
-
expected:
|
|
4079
|
+
}, us = class extends L.TaggedError()("OptimisticLockError", {
|
|
4080
|
+
table: L.String,
|
|
4081
|
+
expected: L.Number
|
|
4082
4082
|
}) {
|
|
4083
4083
|
get message() {
|
|
4084
4084
|
return `optimistic lock failed on '${this.table}': expected version ${this.expected}`;
|
|
@@ -4155,7 +4155,7 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
4155
4155
|
scopedQuery() {
|
|
4156
4156
|
let e = this.query, { subject: t, schemaRegistry: n } = this.scope;
|
|
4157
4157
|
!this.skipTenant && n.hasTenant(this.table) && t.tenantId != null && (e = e.where(u("tenantId", t.tenantId))), !this.skipSoftDelete && n.hasSoftDelete(this.table) && (e = e.where(S("deletedAt")));
|
|
4158
|
-
let r = (this.scope.rowFilter ??
|
|
4158
|
+
let r = (this.scope.rowFilter ?? Mn)(this.table);
|
|
4159
4159
|
return r !== void 0 && (e = e.where(r)), e;
|
|
4160
4160
|
}
|
|
4161
4161
|
async all() {
|
|
@@ -4278,7 +4278,7 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
4278
4278
|
reason: xs
|
|
4279
4279
|
});
|
|
4280
4280
|
}, Cs = (e, n) => {
|
|
4281
|
-
let r = n.subject.id, i = n.subject.tenantId, a = n.rowFilter ??
|
|
4281
|
+
let r = n.subject.id, i = n.subject.tenantId, a = n.rowFilter ?? Mn, o = (e, t) => {
|
|
4282
4282
|
let a = { ...t }, o = n.schemaRegistry, s = o.idScheme(e);
|
|
4283
4283
|
if (s !== void 0 && a[vs] == null) if (s.kind === "numeric") delete a[vs];
|
|
4284
4284
|
else {
|
|
@@ -4304,8 +4304,8 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
4304
4304
|
try {
|
|
4305
4305
|
return await r();
|
|
4306
4306
|
} catch (n) {
|
|
4307
|
-
let r =
|
|
4308
|
-
if (
|
|
4307
|
+
let r = Gt(n);
|
|
4308
|
+
if (Kt(r)) {
|
|
4309
4309
|
let n = t.tenantId, i = `${r.dbConstraint ?? ""} ${r.dbColumn ?? ""} ${r.dbMessage ?? ""} ${r.dbCauseChain ?? ""}`.toLowerCase();
|
|
4310
4310
|
if (i.includes("tenantid") || /\btenants\b/.test(i) || n != null && i.includes(String(n).toLowerCase())) throw new Vi({
|
|
4311
4311
|
table: e,
|
|
@@ -4326,9 +4326,9 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
4326
4326
|
}, g = (e, t) => {
|
|
4327
4327
|
let r = n.schemaRegistry.validatePatchSchema(e);
|
|
4328
4328
|
if (r === void 0) return t;
|
|
4329
|
-
let i =
|
|
4329
|
+
let i = L.decodeUnknownEither(r)(t);
|
|
4330
4330
|
if (i._tag === "Right") return t;
|
|
4331
|
-
let a =
|
|
4331
|
+
let a = St.formatErrorSync(i.left).map((e) => ({
|
|
4332
4332
|
path: e.path.length === 0 ? "<root>" : e.path.join("."),
|
|
4333
4333
|
message: e.message
|
|
4334
4334
|
})), o = a[0];
|
|
@@ -4343,9 +4343,9 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
4343
4343
|
}, v = (e, t) => {
|
|
4344
4344
|
let r = n.schemaRegistry.insertSchema(e);
|
|
4345
4345
|
if (r === void 0) return t;
|
|
4346
|
-
let i =
|
|
4346
|
+
let i = L.decodeUnknownEither(r)(t);
|
|
4347
4347
|
if (i._tag === "Right") return t;
|
|
4348
|
-
let a =
|
|
4348
|
+
let a = St.formatErrorSync(i.left).map((e) => ({
|
|
4349
4349
|
path: e.path.length === 0 ? "<root>" : e.path.join("."),
|
|
4350
4350
|
message: e.message
|
|
4351
4351
|
})), o = a[0];
|
|
@@ -4356,9 +4356,9 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
4356
4356
|
});
|
|
4357
4357
|
}, y = n.dialect, b = (e, t) => {
|
|
4358
4358
|
let n = m(e);
|
|
4359
|
-
return l(y ? se(t, n, y) : t, n,
|
|
4359
|
+
return l(y ? se(t, n, y) : t, n, pi());
|
|
4360
4360
|
}, x = (e, t) => {
|
|
4361
|
-
let n = m(e), r = s(t, n,
|
|
4361
|
+
let n = m(e), r = s(t, n, pi());
|
|
4362
4362
|
return y ? c(r, n, y) : r;
|
|
4363
4363
|
}, C = (e) => {
|
|
4364
4364
|
let r = e.table, o = e.predicate;
|
|
@@ -4370,7 +4370,7 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
4370
4370
|
let e = S("deletedAt");
|
|
4371
4371
|
o = o ? t(o, e) : e;
|
|
4372
4372
|
}
|
|
4373
|
-
return o =
|
|
4373
|
+
return o = In(a, r, o), o === e.predicate ? e : {
|
|
4374
4374
|
...e,
|
|
4375
4375
|
predicate: o
|
|
4376
4376
|
};
|
|
@@ -4472,30 +4472,30 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
4472
4472
|
injectExternalChange: (t) => e.injectExternalChange(t),
|
|
4473
4473
|
...e.changeScope === void 0 ? {} : { changeScope: e.changeScope }
|
|
4474
4474
|
};
|
|
4475
|
-
}, ws = class extends
|
|
4476
|
-
name:
|
|
4477
|
-
retryAfterMs:
|
|
4475
|
+
}, ws = class extends L.TaggedError()("CircuitOpen", {
|
|
4476
|
+
name: L.String,
|
|
4477
|
+
retryAfterMs: L.Number
|
|
4478
4478
|
}) {}, Ts = {
|
|
4479
4479
|
tag: "closed",
|
|
4480
4480
|
failureCount: 0,
|
|
4481
4481
|
halfOpenSuccesses: 0,
|
|
4482
4482
|
openedAt: 0
|
|
4483
|
-
}, Es = { make: (e) =>
|
|
4484
|
-
let t = e.name ?? "circuit", n =
|
|
4485
|
-
let e = yield*
|
|
4483
|
+
}, Es = { make: (e) => M.gen(function* () {
|
|
4484
|
+
let t = e.name ?? "circuit", n = Ve.toMillis(Ve.decode(e.resetTimeout)), r = e.halfOpenSuccessThreshold ?? 1, i = e.isFailure ?? (() => !0), a = yield* I.make(Ts), o = M.gen(function* () {
|
|
4485
|
+
let e = yield* I.get(a);
|
|
4486
4486
|
if (e.tag === "half-open") {
|
|
4487
4487
|
let t = e.halfOpenSuccesses + 1;
|
|
4488
|
-
yield*
|
|
4488
|
+
yield* I.set(a, t >= r ? Ts : {
|
|
4489
4489
|
...e,
|
|
4490
4490
|
halfOpenSuccesses: t
|
|
4491
4491
|
});
|
|
4492
4492
|
return;
|
|
4493
4493
|
}
|
|
4494
|
-
e.failureCount !== 0 && (yield*
|
|
4495
|
-
}), s =
|
|
4496
|
-
let t = yield* Le.currentTimeMillis, n = yield*
|
|
4494
|
+
e.failureCount !== 0 && (yield* I.set(a, Ts));
|
|
4495
|
+
}), s = M.gen(function* () {
|
|
4496
|
+
let t = yield* Le.currentTimeMillis, n = yield* I.get(a);
|
|
4497
4497
|
if (n.tag === "half-open" || n.tag === "open") {
|
|
4498
|
-
yield*
|
|
4498
|
+
yield* I.set(a, {
|
|
4499
4499
|
tag: "open",
|
|
4500
4500
|
failureCount: e.failureThreshold,
|
|
4501
4501
|
halfOpenSuccesses: 0,
|
|
@@ -4504,7 +4504,7 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
4504
4504
|
return;
|
|
4505
4505
|
}
|
|
4506
4506
|
let r = n.failureCount + 1;
|
|
4507
|
-
yield*
|
|
4507
|
+
yield* I.set(a, r >= e.failureThreshold ? {
|
|
4508
4508
|
tag: "open",
|
|
4509
4509
|
failureCount: r,
|
|
4510
4510
|
halfOpenSuccesses: 0,
|
|
@@ -4513,39 +4513,39 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
4513
4513
|
...n,
|
|
4514
4514
|
failureCount: r
|
|
4515
4515
|
});
|
|
4516
|
-
}), c =
|
|
4517
|
-
let e = yield*
|
|
4516
|
+
}), c = M.gen(function* () {
|
|
4517
|
+
let e = yield* I.get(a);
|
|
4518
4518
|
if (e.tag !== "open") return null;
|
|
4519
4519
|
let t = (yield* Le.currentTimeMillis) - e.openedAt;
|
|
4520
|
-
return t >= n ? (yield*
|
|
4520
|
+
return t >= n ? (yield* I.set(a, {
|
|
4521
4521
|
tag: "half-open",
|
|
4522
4522
|
failureCount: 0,
|
|
4523
4523
|
halfOpenSuccesses: 0,
|
|
4524
4524
|
openedAt: e.openedAt
|
|
4525
4525
|
}), null) : n - t;
|
|
4526
|
-
}), l = (e) =>
|
|
4526
|
+
}), l = (e) => M.gen(function* () {
|
|
4527
4527
|
let n = yield* c;
|
|
4528
|
-
return n === null ? yield* e.pipe(
|
|
4529
|
-
if (j.isInterruptedOnly(e)) return
|
|
4528
|
+
return n === null ? yield* e.pipe(M.tap(() => o), M.tapErrorCause((e) => {
|
|
4529
|
+
if (j.isInterruptedOnly(e)) return M.void;
|
|
4530
4530
|
let t = j.failureOption(e), n = t._tag === "Some" ? t.value : void 0;
|
|
4531
|
-
return i(n) ? s :
|
|
4532
|
-
})) : yield*
|
|
4531
|
+
return i(n) ? s : M.void;
|
|
4532
|
+
})) : yield* M.fail(new ws({
|
|
4533
4533
|
name: t,
|
|
4534
4534
|
retryAfterMs: n
|
|
4535
4535
|
}));
|
|
4536
4536
|
}), u = ((e) => l(e));
|
|
4537
4537
|
return Object.defineProperty(u, "state", {
|
|
4538
|
-
value:
|
|
4538
|
+
value: I.get(a).pipe(M.map((e) => e.tag)),
|
|
4539
4539
|
enumerable: !0
|
|
4540
4540
|
}), Object.defineProperty(u, "reset", {
|
|
4541
|
-
value:
|
|
4541
|
+
value: I.set(a, Ts),
|
|
4542
4542
|
enumerable: !0
|
|
4543
4543
|
}), u;
|
|
4544
4544
|
}) }, Ds, Os = (e) => {
|
|
4545
4545
|
Ds = e;
|
|
4546
4546
|
}, ks = () => {
|
|
4547
4547
|
Ds = void 0;
|
|
4548
|
-
}, As = async (e, t = {}) => {
|
|
4548
|
+
}, As = () => Ds, js = async (e, t = {}) => {
|
|
4549
4549
|
let n = t.scopes === void 0 ? Fe(t.id ?? "system") : Fe(t.id ?? "system", t.scopes), r = t.store ?? Ds?.dataStore, i = t.schemaRegistry ?? Ds?.schemaRegistry, a = t.dialect ?? Ds?.dialect;
|
|
4550
4550
|
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.");
|
|
4551
4551
|
return e({
|
|
@@ -4556,7 +4556,7 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
4556
4556
|
...a === void 0 ? {} : { dialect: a }
|
|
4557
4557
|
})
|
|
4558
4558
|
});
|
|
4559
|
-
},
|
|
4559
|
+
}, Ms = (e) => {
|
|
4560
4560
|
let { currentRegion: t, replicaRegions: n, inner: r } = e, i = (e) => {
|
|
4561
4561
|
if (t === void 0) return {
|
|
4562
4562
|
sameRegion: [],
|
|
@@ -4584,7 +4584,7 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
4584
4584
|
return r.loadSnapshot();
|
|
4585
4585
|
}
|
|
4586
4586
|
};
|
|
4587
|
-
},
|
|
4587
|
+
}, Ns = (e = process.env) => {
|
|
4588
4588
|
for (let t of [
|
|
4589
4589
|
"VOLTRO_REGION",
|
|
4590
4590
|
"AWS_REGION",
|
|
@@ -4596,7 +4596,7 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
4596
4596
|
let n = e[t];
|
|
4597
4597
|
if (typeof n == "string" && n.length > 0) return n;
|
|
4598
4598
|
}
|
|
4599
|
-
},
|
|
4599
|
+
}, Ps = () => {
|
|
4600
4600
|
let e = {
|
|
4601
4601
|
primary: 0,
|
|
4602
4602
|
lagByReplica: /* @__PURE__ */ new Map()
|
|
@@ -4621,27 +4621,27 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
4621
4621
|
e.lagByReplica.set(t, n);
|
|
4622
4622
|
}
|
|
4623
4623
|
};
|
|
4624
|
-
},
|
|
4625
|
-
let t =
|
|
4626
|
-
if (
|
|
4624
|
+
}, Fs = Symbol.for("@voltro/ScheduleDefinition"), Is = (e) => typeof e == "object" && !!e && Fs in e, Ls = 30 * 6e4, Rs = (e) => {
|
|
4625
|
+
let t = ze.parse(e.cron, e.timezone);
|
|
4626
|
+
if (He.isLeft(t)) throw Error(`defineSchedule("${e.name}"): invalid cron expression "${e.cron}" (tz="${e.timezone}") — ${String(t.left)}`);
|
|
4627
4627
|
if (!e.timezone || e.timezone.trim() === "") throw Error(`defineSchedule("${e.name}"): timezone is required (e.g. "UTC", "Europe/Berlin")`);
|
|
4628
4628
|
if (e.handler === void 0 && e.workflow === void 0) throw Error(`defineSchedule("${e.name}"): define either handler or workflow`);
|
|
4629
4629
|
return {
|
|
4630
4630
|
...e,
|
|
4631
4631
|
onOverlap: e.onOverlap ?? "skip",
|
|
4632
4632
|
backfill: e.backfill ?? "skip",
|
|
4633
|
-
maxRuntimeMs: e.maxRuntimeMs ??
|
|
4634
|
-
[
|
|
4633
|
+
maxRuntimeMs: e.maxRuntimeMs ?? Ls,
|
|
4634
|
+
[Fs]: !0
|
|
4635
4635
|
};
|
|
4636
|
-
},
|
|
4636
|
+
}, zs = (e) => ze.unsafeParse(e.cron, e.timezone), Bs = (e, t = /* @__PURE__ */ new Date()) => ze.next(zs(e), t), Z = "_voltro_wakeups", Vs = (e) => `${e.tenantId}:${e.kind}:${e.refId}`, Hs = (e) => ({
|
|
4637
4637
|
tenantId: String(e.tenantId),
|
|
4638
4638
|
kind: String(e.kind),
|
|
4639
4639
|
refId: String(e.refId),
|
|
4640
4640
|
wakeAt: e.wakeAt instanceof Date ? e.wakeAt : new Date(String(e.wakeAt)),
|
|
4641
4641
|
status: e.status === "fired" ? "fired" : "pending"
|
|
4642
|
-
}),
|
|
4642
|
+
}), Us = async (e, t) => {
|
|
4643
4643
|
await e.upsert(Z, {
|
|
4644
|
-
id:
|
|
4644
|
+
id: Vs(t),
|
|
4645
4645
|
tenantId: t.tenantId,
|
|
4646
4646
|
kind: t.kind,
|
|
4647
4647
|
refId: t.refId,
|
|
@@ -4651,7 +4651,7 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
4651
4651
|
conflictColumns: ["id"],
|
|
4652
4652
|
update: ["wakeAt", "status"]
|
|
4653
4653
|
});
|
|
4654
|
-
},
|
|
4654
|
+
}, Ws = async (e, t) => e.delete(Z, Vs(t)), Gs = async (e, t) => await e.update(Z, Vs(t), { status: "fired" }) !== null, Ks = (e, t) => ({ and: [{
|
|
4655
4655
|
column: "id",
|
|
4656
4656
|
op: "eq",
|
|
4657
4657
|
value: e
|
|
@@ -4659,16 +4659,16 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
4659
4659
|
column: "status",
|
|
4660
4660
|
op: "eq",
|
|
4661
4661
|
value: t
|
|
4662
|
-
}] }),
|
|
4663
|
-
await e.updateMany(Z, { status: "pending" }, { where:
|
|
4664
|
-
},
|
|
4662
|
+
}] }), qs = async (e, t) => await e.updateMany(Z, { status: "fired" }, { where: Ks(Vs(t), "pending") }) > 0, Js = async (e, t) => {
|
|
4663
|
+
await e.updateMany(Z, { status: "pending" }, { where: Ks(Vs(t), "fired") });
|
|
4664
|
+
}, Ys = {
|
|
4665
4665
|
column: "status",
|
|
4666
4666
|
op: "eq",
|
|
4667
4667
|
value: "pending"
|
|
4668
|
-
},
|
|
4668
|
+
}, Xs = async (e, t) => {
|
|
4669
4669
|
let n = {
|
|
4670
4670
|
table: Z,
|
|
4671
|
-
predicate:
|
|
4671
|
+
predicate: Ys,
|
|
4672
4672
|
order: [{
|
|
4673
4673
|
column: "wakeAt",
|
|
4674
4674
|
direction: "asc"
|
|
@@ -4677,18 +4677,18 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
4677
4677
|
skip: void 0,
|
|
4678
4678
|
projection: void 0
|
|
4679
4679
|
};
|
|
4680
|
-
return (await e.query(n)).map(
|
|
4681
|
-
},
|
|
4682
|
-
let r = await
|
|
4680
|
+
return (await e.query(n)).map(Hs);
|
|
4681
|
+
}, Zs = async (e, t, n = 500) => {
|
|
4682
|
+
let r = await Xs(e, n), i = t.getTime();
|
|
4683
4683
|
return r.filter((e) => e.wakeAt.getTime() <= i);
|
|
4684
|
-
},
|
|
4684
|
+
}, Qs = async (e) => (await Xs(e, 1))[0] ?? null, $s = {
|
|
4685
4685
|
column: "status",
|
|
4686
4686
|
op: "eq",
|
|
4687
4687
|
value: "fired"
|
|
4688
|
-
},
|
|
4688
|
+
}, ec = async (e, t = {}) => {
|
|
4689
4689
|
let n = {
|
|
4690
4690
|
table: Z,
|
|
4691
|
-
predicate:
|
|
4691
|
+
predicate: $s,
|
|
4692
4692
|
order: [{
|
|
4693
4693
|
column: "wakeAt",
|
|
4694
4694
|
direction: "asc"
|
|
@@ -4699,12 +4699,12 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
4699
4699
|
}, r = await e.query(n), i = t.firedOlderThan?.getTime(), a = 0;
|
|
4700
4700
|
for (let t of r) i !== void 0 && (t.wakeAt instanceof Date ? t.wakeAt : new Date(String(t.wakeAt))).getTime() >= i || await e.delete(Z, String(t.id)) && a++;
|
|
4701
4701
|
return a;
|
|
4702
|
-
},
|
|
4702
|
+
}, tc = {
|
|
4703
4703
|
kind: "single",
|
|
4704
4704
|
tryClaim: async () => !0
|
|
4705
|
-
},
|
|
4705
|
+
}, nc = "_voltro_schedule_claims", rc = (e, t, n) => {
|
|
4706
4706
|
let r = async (t) => (await e.query({
|
|
4707
|
-
table:
|
|
4707
|
+
table: nc,
|
|
4708
4708
|
order: [],
|
|
4709
4709
|
predicate: void 0,
|
|
4710
4710
|
projection: ["id"],
|
|
@@ -4719,7 +4719,7 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
4719
4719
|
if (await r(s)) return !1;
|
|
4720
4720
|
} catch {}
|
|
4721
4721
|
try {
|
|
4722
|
-
return await e.insert(
|
|
4722
|
+
return await e.insert(nc, {
|
|
4723
4723
|
id: s,
|
|
4724
4724
|
scheduleName: i,
|
|
4725
4725
|
bucket: o,
|
|
@@ -4737,12 +4737,12 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
4737
4737
|
}
|
|
4738
4738
|
}
|
|
4739
4739
|
};
|
|
4740
|
-
},
|
|
4740
|
+
}, ic = "_voltro_schedule_runs", ac = async (e, t) => {
|
|
4741
4741
|
let { store: n, coordinator: r, buildContext: i, replicaId: a, log: o, onRunEvent: s, interceptFire: c } = t, l = t.dormancy === "sleep", u = t.dormancyTenantId ?? "default", d = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Set(), p = /* @__PURE__ */ new Map(), m = !1, h = new Map(e.map((e) => [e.name, e])), g = (e, t) => {
|
|
4742
|
-
s?.(e,
|
|
4742
|
+
s?.(e, sc(t));
|
|
4743
4743
|
}, _ = async (e, t, r, i, s, c) => {
|
|
4744
4744
|
try {
|
|
4745
|
-
let o = `sr_${me()}`, l = await n.insert(
|
|
4745
|
+
let o = `sr_${me()}`, l = await n.insert(ic, {
|
|
4746
4746
|
id: o,
|
|
4747
4747
|
name: e.name,
|
|
4748
4748
|
status: i,
|
|
@@ -4767,7 +4767,7 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
4767
4767
|
}
|
|
4768
4768
|
}, v = async (e, t) => {
|
|
4769
4769
|
try {
|
|
4770
|
-
let r = await n.update(
|
|
4770
|
+
let r = await n.update(ic, e, t);
|
|
4771
4771
|
r && g("update", r);
|
|
4772
4772
|
} catch (t) {
|
|
4773
4773
|
o.warn("schedule: failed to record run finish", {
|
|
@@ -4778,7 +4778,7 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
4778
4778
|
}, y = async (e) => {
|
|
4779
4779
|
try {
|
|
4780
4780
|
let t = await n.query({
|
|
4781
|
-
table:
|
|
4781
|
+
table: ic,
|
|
4782
4782
|
predicate: {
|
|
4783
4783
|
_tag: "leaf",
|
|
4784
4784
|
column: "status",
|
|
@@ -4843,7 +4843,7 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
4843
4843
|
let n = Q(t).includes("exceeded maxRuntimeMs");
|
|
4844
4844
|
s && await v(s, {
|
|
4845
4845
|
status: "failed",
|
|
4846
|
-
errorTag: n ? "timeout" :
|
|
4846
|
+
errorTag: n ? "timeout" : oc(t),
|
|
4847
4847
|
errorMessage: Q(t),
|
|
4848
4848
|
completedAt: /* @__PURE__ */ new Date(),
|
|
4849
4849
|
durationMs: Date.now() - l
|
|
@@ -4900,8 +4900,8 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
4900
4900
|
}
|
|
4901
4901
|
}, C = async (e) => {
|
|
4902
4902
|
try {
|
|
4903
|
-
let t =
|
|
4904
|
-
await
|
|
4903
|
+
let t = ze.next(zs(e), /* @__PURE__ */ new Date());
|
|
4904
|
+
await Us(n, {
|
|
4905
4905
|
tenantId: u,
|
|
4906
4906
|
kind: "schedule",
|
|
4907
4907
|
refId: e.name,
|
|
@@ -4915,7 +4915,7 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
4915
4915
|
}
|
|
4916
4916
|
}, ee = 2147483647, w = (e) => {
|
|
4917
4917
|
if (m) return;
|
|
4918
|
-
let n =
|
|
4918
|
+
let n = zs(e), r = ze.next(n, /* @__PURE__ */ new Date()), i = () => {
|
|
4919
4919
|
if (m) return;
|
|
4920
4920
|
let n = r.getTime() - Date.now();
|
|
4921
4921
|
if (n > ee) {
|
|
@@ -4937,7 +4937,7 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
4937
4937
|
let r;
|
|
4938
4938
|
try {
|
|
4939
4939
|
let t = (await n.query({
|
|
4940
|
-
table:
|
|
4940
|
+
table: ic,
|
|
4941
4941
|
order: [{
|
|
4942
4942
|
column: "scheduledAt",
|
|
4943
4943
|
direction: "desc"
|
|
@@ -4956,8 +4956,8 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
4956
4956
|
return;
|
|
4957
4957
|
}
|
|
4958
4958
|
if (!r) return;
|
|
4959
|
-
let i =
|
|
4960
|
-
for (; s.getTime() < c && a.length < 1e3;) a.push(s), s =
|
|
4959
|
+
let i = zs(e), a = [], s = ze.next(i, r), c = Date.now();
|
|
4960
|
+
for (; s.getTime() < c && a.length < 1e3;) a.push(s), s = ze.next(i, s);
|
|
4961
4961
|
if (a.length !== 0) if (o.info("schedule: backfill", {
|
|
4962
4962
|
name: e.name,
|
|
4963
4963
|
missed: a.length,
|
|
@@ -5001,11 +5001,11 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
5001
5001
|
d.clear(), o.info("scheduler: stopped");
|
|
5002
5002
|
}
|
|
5003
5003
|
};
|
|
5004
|
-
}, Q = (e) => e?.message ?? String(e),
|
|
5004
|
+
}, Q = (e) => e?.message ?? String(e), oc = (e) => e && typeof e == "object" && "_tag" in e ? String(e._tag) : null, sc = (e) => {
|
|
5005
5005
|
let t = {};
|
|
5006
5006
|
for (let [n, r] of Object.entries(e)) t[n] = r instanceof Date ? r.toISOString() : r;
|
|
5007
5007
|
return t;
|
|
5008
|
-
},
|
|
5008
|
+
}, cc = (e, t, n, r) => {
|
|
5009
5009
|
let i = !1, a, o = async () => {
|
|
5010
5010
|
if (i) return;
|
|
5011
5011
|
let a = new Date(Math.floor(Date.now() / t) * t), o = !1;
|
|
@@ -5035,7 +5035,7 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
5035
5035
|
i || (i = !0, a && clearInterval(a), a = void 0);
|
|
5036
5036
|
}
|
|
5037
5037
|
};
|
|
5038
|
-
},
|
|
5038
|
+
}, lc = (e) => (t, n, r) => cc(t, n, r, e), uc = E("_voltro_schedule_runs", {
|
|
5039
5039
|
id: v({ prefix: "schrun" }),
|
|
5040
5040
|
name: D(),
|
|
5041
5041
|
status: D().oneOf([
|
|
@@ -5065,13 +5065,13 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
5065
5065
|
]).nullable(),
|
|
5066
5066
|
replicaId: D().nullable(),
|
|
5067
5067
|
result: C().nullable()
|
|
5068
|
-
}).index(["name", "scheduledAt"]).index(["status"]),
|
|
5068
|
+
}).index(["name", "scheduledAt"]).index(["status"]), dc = E("_voltro_schedule_claims", {
|
|
5069
5069
|
id: v({ prefix: "schclaim" }),
|
|
5070
5070
|
scheduleName: D(),
|
|
5071
5071
|
bucket: D(),
|
|
5072
5072
|
claimedBy: D(),
|
|
5073
5073
|
claimedAt: O()
|
|
5074
|
-
}).index(["scheduleName", "bucket"]).index(["claimedAt"]),
|
|
5074
|
+
}).index(["scheduleName", "bucket"]).index(["claimedAt"]), fc = E("_voltro_traces", {
|
|
5075
5075
|
id: v({ prefix: "span" }),
|
|
5076
5076
|
traceId: D(),
|
|
5077
5077
|
spanId: D(),
|
|
@@ -5095,7 +5095,7 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
5095
5095
|
durationMs: b(),
|
|
5096
5096
|
attributes: C().nullable(),
|
|
5097
5097
|
events: C().nullable()
|
|
5098
|
-
}).index(["traceId", "startedAt"]).index(["startedAt"]).index(["status"]),
|
|
5098
|
+
}).index(["traceId", "startedAt"]).index(["startedAt"]).index(["status"]), pc = E("_voltro_undo_log", {
|
|
5099
5099
|
id: v({ prefix: "undo" }),
|
|
5100
5100
|
tag: D(),
|
|
5101
5101
|
label: D().nullable(),
|
|
@@ -5106,25 +5106,25 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
5106
5106
|
crossesAction: r().default(!1),
|
|
5107
5107
|
undone: r().default(!1),
|
|
5108
5108
|
createdAt: O().default("now")
|
|
5109
|
-
}).index(["subjectId", "createdAt"]).reactive(),
|
|
5109
|
+
}).index(["subjectId", "createdAt"]).reactive(), mc = (e = process.env) => {
|
|
5110
5110
|
let t = (e.VOLTRO_UNDO ?? "").toLowerCase();
|
|
5111
5111
|
return t === "on" || t === "1" || t === "true" ? !0 : t === "off" || t === "0" || t === "false" ? !1 : e.NODE_ENV !== "production";
|
|
5112
|
-
},
|
|
5112
|
+
}, hc = (e) => e.startsWith("_voltro"), gc = async (e, t, n) => (await e.query({
|
|
5113
5113
|
table: t,
|
|
5114
5114
|
predicate: u("id", n),
|
|
5115
5115
|
order: []
|
|
5116
|
-
}))[0] ?? null,
|
|
5116
|
+
}))[0] ?? null, _c = (e, t) => new Proxy(e, { get(e, n, r) {
|
|
5117
5117
|
if (n === "insert") return async (n, r) => {
|
|
5118
5118
|
let i = await e.insert(n, r);
|
|
5119
|
-
return
|
|
5119
|
+
return hc(n) || t({
|
|
5120
5120
|
table: n,
|
|
5121
5121
|
op: "insert",
|
|
5122
5122
|
next: i
|
|
5123
5123
|
}), i;
|
|
5124
5124
|
};
|
|
5125
5125
|
if (n === "update") return async (n, r, i) => {
|
|
5126
|
-
let a =
|
|
5127
|
-
return
|
|
5126
|
+
let a = hc(n) ? null : await gc(e, n, r), o = await e.update(n, r, i);
|
|
5127
|
+
return hc(n) || t({
|
|
5128
5128
|
table: n,
|
|
5129
5129
|
op: "update",
|
|
5130
5130
|
id: r,
|
|
@@ -5133,8 +5133,8 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
5133
5133
|
}), o;
|
|
5134
5134
|
};
|
|
5135
5135
|
if (n === "delete") return async (n, r) => {
|
|
5136
|
-
let i =
|
|
5137
|
-
return !
|
|
5136
|
+
let i = hc(n) ? null : await gc(e, n, r), a = await e.delete(n, r);
|
|
5137
|
+
return !hc(n) && a && t({
|
|
5138
5138
|
table: n,
|
|
5139
5139
|
op: "delete",
|
|
5140
5140
|
id: r,
|
|
@@ -5143,10 +5143,10 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
5143
5143
|
};
|
|
5144
5144
|
let i = Reflect.get(e, n, r);
|
|
5145
5145
|
return typeof i == "function" ? i.bind(e) : i;
|
|
5146
|
-
} }),
|
|
5146
|
+
} }), vc = (e) => {
|
|
5147
5147
|
let t = [];
|
|
5148
5148
|
return {
|
|
5149
|
-
tx:
|
|
5149
|
+
tx: _c(e, (e) => t.push(e)),
|
|
5150
5150
|
persist: async (e, n) => {
|
|
5151
5151
|
if (t.length === 0 || n.tag.startsWith("__voltro")) return;
|
|
5152
5152
|
let r = n.subject;
|
|
@@ -5162,14 +5162,14 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
5162
5162
|
});
|
|
5163
5163
|
}
|
|
5164
5164
|
};
|
|
5165
|
-
},
|
|
5165
|
+
}, yc = (e) => {
|
|
5166
5166
|
if (e.id !== void 0) return e.id;
|
|
5167
5167
|
let t = e.next?.id;
|
|
5168
5168
|
if (typeof t == "string") return t;
|
|
5169
5169
|
let n = e.prev?.id;
|
|
5170
5170
|
return typeof n == "string" ? n : void 0;
|
|
5171
|
-
},
|
|
5172
|
-
let t =
|
|
5171
|
+
}, bc = (e) => {
|
|
5172
|
+
let t = yc(e);
|
|
5173
5173
|
switch (e.op) {
|
|
5174
5174
|
case "insert": return t === void 0 ? null : {
|
|
5175
5175
|
table: e.table,
|
|
@@ -5193,28 +5193,28 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
5193
5193
|
row: e.prev
|
|
5194
5194
|
};
|
|
5195
5195
|
}
|
|
5196
|
-
},
|
|
5197
|
-
if (e.crossesAction) throw new
|
|
5196
|
+
}, xc = (e) => {
|
|
5197
|
+
if (e.crossesAction) throw new Sc(e.invocationId, "action");
|
|
5198
5198
|
let t = [];
|
|
5199
5199
|
for (let n = e.changes.length - 1; n >= 0; --n) {
|
|
5200
|
-
let r =
|
|
5200
|
+
let r = bc(e.changes[n]);
|
|
5201
5201
|
r !== null && t.push(r);
|
|
5202
5202
|
}
|
|
5203
5203
|
return t;
|
|
5204
|
-
},
|
|
5204
|
+
}, Sc = class extends Error {
|
|
5205
5205
|
invocationId;
|
|
5206
5206
|
boundary;
|
|
5207
5207
|
_tag = "UndoBoundaryError";
|
|
5208
5208
|
constructor(e, t) {
|
|
5209
5209
|
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";
|
|
5210
5210
|
}
|
|
5211
|
-
},
|
|
5211
|
+
}, Cc = (e, t, n = ["updatedAt", "updatedBy"]) => {
|
|
5212
5212
|
if (t == null) return e == null;
|
|
5213
5213
|
if (e == null) return !1;
|
|
5214
5214
|
let r = new Set(n);
|
|
5215
5215
|
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;
|
|
5216
5216
|
return !0;
|
|
5217
|
-
},
|
|
5217
|
+
}, wc = class {
|
|
5218
5218
|
capacity;
|
|
5219
5219
|
done = [];
|
|
5220
5220
|
undone = [];
|
|
@@ -5250,7 +5250,7 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
5250
5250
|
redo: [...this.undone]
|
|
5251
5251
|
};
|
|
5252
5252
|
}
|
|
5253
|
-
},
|
|
5253
|
+
}, Tc = (e, t = /* @__PURE__ */ new Set()) => e.op === "insert" ? {
|
|
5254
5254
|
table: e.table,
|
|
5255
5255
|
op: "insert",
|
|
5256
5256
|
next: e.new ?? null
|
|
@@ -5267,7 +5267,7 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
5267
5267
|
table: e.table,
|
|
5268
5268
|
op: "delete",
|
|
5269
5269
|
prev: e.old ?? null
|
|
5270
|
-
},
|
|
5270
|
+
}, Ec = async (e, t) => {
|
|
5271
5271
|
switch (t.op) {
|
|
5272
5272
|
case "delete":
|
|
5273
5273
|
await e.delete(t.table, t.id);
|
|
@@ -5285,21 +5285,21 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
5285
5285
|
await e.insert(t.table, t.row);
|
|
5286
5286
|
return;
|
|
5287
5287
|
}
|
|
5288
|
-
},
|
|
5289
|
-
for (let n of t) await
|
|
5290
|
-
},
|
|
5288
|
+
}, Dc = async (e, t) => {
|
|
5289
|
+
for (let n of t) await Ec(e, n);
|
|
5290
|
+
}, Oc = (e) => e.request?.subject?.id ?? null, kc = (e) => e === !0 || e === 1, Ac = async (e, t, n) => (await e.query({
|
|
5291
5291
|
table: t,
|
|
5292
5292
|
predicate: u("id", n),
|
|
5293
5293
|
order: []
|
|
5294
|
-
}))[0] ?? null,
|
|
5294
|
+
}))[0] ?? null, jc = (e) => {
|
|
5295
5295
|
try {
|
|
5296
5296
|
let t = JSON.parse(String(e ?? "[]"));
|
|
5297
5297
|
return Array.isArray(t) ? t : [];
|
|
5298
5298
|
} catch {
|
|
5299
5299
|
return [];
|
|
5300
5300
|
}
|
|
5301
|
-
},
|
|
5302
|
-
let n =
|
|
5301
|
+
}, Mc = (e) => e.id ?? e.next?.id ?? e.prev?.id, Nc = async (e, t) => {
|
|
5302
|
+
let n = Oc(t);
|
|
5303
5303
|
return [...await t.store.query({
|
|
5304
5304
|
table: "_voltro_undo_log",
|
|
5305
5305
|
predicate: u("subjectId", n),
|
|
@@ -5308,68 +5308,68 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
5308
5308
|
id: String(e.id),
|
|
5309
5309
|
tag: String(e.tag ?? ""),
|
|
5310
5310
|
label: e.label ?? null,
|
|
5311
|
-
undone:
|
|
5312
|
-
crossesAction:
|
|
5311
|
+
undone: kc(e.undone),
|
|
5312
|
+
crossesAction: kc(e.crossesAction),
|
|
5313
5313
|
createdAt: String(e.createdAt ?? "")
|
|
5314
5314
|
}));
|
|
5315
|
-
},
|
|
5316
|
-
let n = await
|
|
5315
|
+
}, Pc = async (e, t) => {
|
|
5316
|
+
let n = await Ac(t.store, "_voltro_undo_log", e.invocationId);
|
|
5317
5317
|
if (!n) throw new Te({ invocationId: e.invocationId });
|
|
5318
|
-
if ((n.subjectId ?? null) !==
|
|
5318
|
+
if ((n.subjectId ?? null) !== Oc(t)) throw new we({ invocationId: e.invocationId });
|
|
5319
5319
|
return n;
|
|
5320
|
-
},
|
|
5321
|
-
let n = await
|
|
5322
|
-
if (
|
|
5323
|
-
if (
|
|
5320
|
+
}, Fc = async (e, t) => {
|
|
5321
|
+
let n = await Pc(e, t);
|
|
5322
|
+
if (kc(n.undone)) return { ok: !0 };
|
|
5323
|
+
if (kc(n.crossesAction)) throw new Ce({
|
|
5324
5324
|
invocationId: e.invocationId,
|
|
5325
5325
|
reason: "action"
|
|
5326
5326
|
});
|
|
5327
|
-
let r =
|
|
5327
|
+
let r = jc(n.changes);
|
|
5328
5328
|
for (let n of r) {
|
|
5329
|
-
let r =
|
|
5330
|
-
if (r !== void 0 && !
|
|
5329
|
+
let r = Mc(n);
|
|
5330
|
+
if (r !== void 0 && !Cc(await Ac(t.store, n.table, r), n.next ?? null)) throw new Ce({
|
|
5331
5331
|
invocationId: e.invocationId,
|
|
5332
5332
|
reason: "conflict"
|
|
5333
5333
|
});
|
|
5334
5334
|
}
|
|
5335
5335
|
let i = {
|
|
5336
5336
|
invocationId: e.invocationId,
|
|
5337
|
-
subject:
|
|
5337
|
+
subject: Oc(t),
|
|
5338
5338
|
changes: r,
|
|
5339
5339
|
crossesAction: !1
|
|
5340
5340
|
};
|
|
5341
|
-
return await
|
|
5342
|
-
},
|
|
5343
|
-
let n = await
|
|
5344
|
-
if (!
|
|
5345
|
-
for (let e of
|
|
5346
|
-
let n =
|
|
5341
|
+
return await Dc(t.store, xc(i)), await t.store.update("_voltro_undo_log", e.invocationId, { undone: !0 }), { ok: !0 };
|
|
5342
|
+
}, Ic = async (e, t) => {
|
|
5343
|
+
let n = await Pc(e, t);
|
|
5344
|
+
if (!kc(n.undone)) return { ok: !0 };
|
|
5345
|
+
for (let e of jc(n.changes)) {
|
|
5346
|
+
let n = Mc(e);
|
|
5347
5347
|
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);
|
|
5348
5348
|
}
|
|
5349
5349
|
return await t.store.update("_voltro_undo_log", e.invocationId, { undone: !1 }), { ok: !0 };
|
|
5350
|
-
},
|
|
5350
|
+
}, Lc = (e = process.env) => {
|
|
5351
5351
|
let t = (e.VOLTRO_TIMELINE ?? "").toLowerCase();
|
|
5352
5352
|
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";
|
|
5353
|
-
},
|
|
5353
|
+
}, Rc = /pass(word)?|secret|token|api[_-]?key|authorization|cookie|ssn|credit[_-]?card|card[_-]?number|cvv|encrypted/i, zc = "«redacted»", Bc = (e) => {
|
|
5354
5354
|
if (e == null) return null;
|
|
5355
5355
|
let t = {};
|
|
5356
|
-
for (let [n, r] of Object.entries(e)) t[n] =
|
|
5356
|
+
for (let [n, r] of Object.entries(e)) t[n] = Rc.test(n) ? zc : r;
|
|
5357
5357
|
return t;
|
|
5358
|
-
},
|
|
5358
|
+
}, Vc = (e) => {
|
|
5359
5359
|
let t = e?.id;
|
|
5360
5360
|
return typeof t == "string" ? t : void 0;
|
|
5361
|
-
},
|
|
5361
|
+
}, Hc = (e, t) => {
|
|
5362
5362
|
if (t.op === "insert") {
|
|
5363
|
-
let n =
|
|
5363
|
+
let n = Vc(t.new);
|
|
5364
5364
|
return n === void 0 ? e : e.filter((e) => e.id !== n);
|
|
5365
5365
|
}
|
|
5366
5366
|
if (t.op === "update") {
|
|
5367
5367
|
if (t.old == null) return e;
|
|
5368
|
-
let n =
|
|
5368
|
+
let n = Vc(t.new) ?? Vc(t.old);
|
|
5369
5369
|
return e.map((e) => e.id === n ? t.old : e);
|
|
5370
5370
|
}
|
|
5371
5371
|
return t.old == null ? e : [...e, t.old];
|
|
5372
|
-
},
|
|
5372
|
+
}, Uc = class {
|
|
5373
5373
|
mode;
|
|
5374
5374
|
capacity;
|
|
5375
5375
|
now;
|
|
@@ -5389,8 +5389,8 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
5389
5389
|
ts: this.now(),
|
|
5390
5390
|
table: e.table,
|
|
5391
5391
|
op: e.op,
|
|
5392
|
-
old:
|
|
5393
|
-
new:
|
|
5392
|
+
old: Bc(e.old),
|
|
5393
|
+
new: Bc(e.new),
|
|
5394
5394
|
tenantId: n
|
|
5395
5395
|
}), this.ring.length > this.capacity && this.ring.shift(), t;
|
|
5396
5396
|
}
|
|
@@ -5403,23 +5403,23 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
5403
5403
|
}
|
|
5404
5404
|
replay(e, t, n) {
|
|
5405
5405
|
let r = this.ring.filter((n) => n.table === e && n.seq > t).sort((e, t) => t.seq - e.seq), i = n;
|
|
5406
|
-
for (let e of r) i =
|
|
5406
|
+
for (let e of r) i = Hc(i, e);
|
|
5407
5407
|
return i;
|
|
5408
5408
|
}
|
|
5409
|
-
},
|
|
5410
|
-
|
|
5411
|
-
},
|
|
5412
|
-
let t =
|
|
5409
|
+
}, Wc, Gc = () => (Wc === void 0 && (Wc = new Uc(Lc())), Wc), Kc = (e) => {
|
|
5410
|
+
Wc = e;
|
|
5411
|
+
}, qc = (e) => {
|
|
5412
|
+
let t = Gc();
|
|
5413
5413
|
if (t.enabled) try {
|
|
5414
5414
|
t.record(e);
|
|
5415
5415
|
} catch {}
|
|
5416
|
-
},
|
|
5416
|
+
}, Jc = /* @__PURE__ */ new Set([
|
|
5417
5417
|
"count",
|
|
5418
5418
|
"sum",
|
|
5419
5419
|
"avg",
|
|
5420
5420
|
"min",
|
|
5421
5421
|
"max"
|
|
5422
|
-
]),
|
|
5422
|
+
]), Yc = (e) => {
|
|
5423
5423
|
if (e.joins !== void 0 && e.joins.length > 0) return {
|
|
5424
5424
|
maintainable: !1,
|
|
5425
5425
|
reason: "joins are not maintainable in v1"
|
|
@@ -5441,7 +5441,7 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
5441
5441
|
reason: "v1 maintains exactly one aggregation"
|
|
5442
5442
|
};
|
|
5443
5443
|
let t = e.aggregations[0];
|
|
5444
|
-
return
|
|
5444
|
+
return Jc.has(t.op) ? t.op !== "count" && (t.column === void 0 || t.column.length === 0) ? {
|
|
5445
5445
|
maintainable: !1,
|
|
5446
5446
|
reason: `op '${t.op}' requires a column`
|
|
5447
5447
|
} : {
|
|
@@ -5455,7 +5455,7 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
5455
5455
|
maintainable: !1,
|
|
5456
5456
|
reason: `op '${t.op}' is not maintainable`
|
|
5457
5457
|
};
|
|
5458
|
-
},
|
|
5458
|
+
}, Xc = "\0", $ = (e, t) => t === void 0 || t.length === 0 ? "" : t.map((t) => JSON.stringify(e[t] ?? null)).join(Xc), Zc = (e, t) => t === void 0 ? 0 : Number(e[t] ?? 0), Qc = (e, t) => {
|
|
5459
5459
|
switch (e.op) {
|
|
5460
5460
|
case "count": return t.count;
|
|
5461
5461
|
case "sum": return t.sum ?? 0;
|
|
@@ -5463,10 +5463,10 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
5463
5463
|
case "min":
|
|
5464
5464
|
case "max": return t.count > 0 ? t.extreme ?? null : null;
|
|
5465
5465
|
}
|
|
5466
|
-
},
|
|
5466
|
+
}, $c = (e, t) => {
|
|
5467
5467
|
let n = /* @__PURE__ */ new Map();
|
|
5468
5468
|
for (let r of t) {
|
|
5469
|
-
let t = $(r, e.groupBy), i = n.get(t), a =
|
|
5469
|
+
let t = $(r, e.groupBy), i = n.get(t), a = Zc(r, e.column);
|
|
5470
5470
|
if (i === void 0) n.set(t, {
|
|
5471
5471
|
count: 1,
|
|
5472
5472
|
...e.op === "sum" || e.op === "avg" ? { sum: a } : {},
|
|
@@ -5482,10 +5482,10 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
5482
5482
|
}
|
|
5483
5483
|
}
|
|
5484
5484
|
return n;
|
|
5485
|
-
},
|
|
5485
|
+
}, el = (e, t) => [...t.entries()].map(([t, n]) => ({
|
|
5486
5486
|
groupKey: t,
|
|
5487
|
-
value:
|
|
5488
|
-
})),
|
|
5487
|
+
value: Qc(e, n)
|
|
5488
|
+
})), tl = (e, t, n) => {
|
|
5489
5489
|
let r = new Map(t), i = /* @__PURE__ */ new Set(), a = (t) => {
|
|
5490
5490
|
let n = $(t, e.groupBy), a = r.get(n);
|
|
5491
5491
|
if (a === void 0) return;
|
|
@@ -5494,7 +5494,7 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
5494
5494
|
r.delete(n);
|
|
5495
5495
|
return;
|
|
5496
5496
|
}
|
|
5497
|
-
let s =
|
|
5497
|
+
let s = Zc(t, e.column);
|
|
5498
5498
|
e.op === "min" || e.op === "max" ? (a.extreme !== void 0 && s === a.extreme && i.add(n), r.set(n, {
|
|
5499
5499
|
count: o,
|
|
5500
5500
|
...a.extreme === void 0 ? {} : { extreme: a.extreme }
|
|
@@ -5503,7 +5503,7 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
5503
5503
|
...e.op === "sum" || e.op === "avg" ? { sum: (a.sum ?? 0) - s } : {}
|
|
5504
5504
|
});
|
|
5505
5505
|
}, o = (t) => {
|
|
5506
|
-
let n = $(t, e.groupBy), i = r.get(n), a =
|
|
5506
|
+
let n = $(t, e.groupBy), i = r.get(n), a = Zc(t, e.column);
|
|
5507
5507
|
if (i === void 0) {
|
|
5508
5508
|
r.set(n, {
|
|
5509
5509
|
count: 1,
|
|
@@ -5523,15 +5523,15 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
5523
5523
|
state: r,
|
|
5524
5524
|
rescanGroups: [...i]
|
|
5525
5525
|
};
|
|
5526
|
-
},
|
|
5526
|
+
}, nl = (e, t, n, r) => {
|
|
5527
5527
|
if (n.length === 0) return t;
|
|
5528
|
-
let i = new Set(n), a =
|
|
5528
|
+
let i = new Set(n), a = $c(e, r.filter((t) => i.has($(t, e.groupBy)))), o = new Map(t);
|
|
5529
5529
|
for (let e of i) {
|
|
5530
5530
|
let t = a.get(e);
|
|
5531
5531
|
t === void 0 ? o.delete(e) : o.set(e, t);
|
|
5532
5532
|
}
|
|
5533
5533
|
return o;
|
|
5534
|
-
},
|
|
5534
|
+
}, rl = class {
|
|
5535
5535
|
shape;
|
|
5536
5536
|
state = /* @__PURE__ */ new Map();
|
|
5537
5537
|
groups = /* @__PURE__ */ new Map();
|
|
@@ -5539,7 +5539,7 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
5539
5539
|
this.shape = e;
|
|
5540
5540
|
}
|
|
5541
5541
|
seed(e) {
|
|
5542
|
-
this.state =
|
|
5542
|
+
this.state = $c(this.shape, e), this.groups.clear();
|
|
5543
5543
|
for (let t of e) {
|
|
5544
5544
|
let e = $(t, this.shape.groupBy);
|
|
5545
5545
|
this.groups.has(e) || this.groups.set(e, this.groupValues(t));
|
|
@@ -5551,14 +5551,14 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
5551
5551
|
let e = $(t, this.shape.groupBy);
|
|
5552
5552
|
this.groups.has(e) || this.groups.set(e, this.groupValues(t));
|
|
5553
5553
|
}
|
|
5554
|
-
let n =
|
|
5554
|
+
let n = tl(this.shape, this.state, e);
|
|
5555
5555
|
this.state = n.state;
|
|
5556
5556
|
for (let e of this.groups.keys()) this.state.has(e) || this.groups.delete(e);
|
|
5557
5557
|
return n.rescanGroups;
|
|
5558
5558
|
}
|
|
5559
5559
|
resolveRescan(e, t) {
|
|
5560
5560
|
if (e.length === 0) return;
|
|
5561
|
-
this.state =
|
|
5561
|
+
this.state = nl(this.shape, this.state, e, t);
|
|
5562
5562
|
let n = new Set(e);
|
|
5563
5563
|
for (let e of t) {
|
|
5564
5564
|
let t = $(e, this.shape.groupBy);
|
|
@@ -5567,7 +5567,7 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
5567
5567
|
for (let e of n) this.state.has(e) || this.groups.delete(e);
|
|
5568
5568
|
}
|
|
5569
5569
|
materialize() {
|
|
5570
|
-
return
|
|
5570
|
+
return el(this.shape, this.state).map((e) => ({
|
|
5571
5571
|
groupKey: e.groupKey,
|
|
5572
5572
|
group: this.groups.get(e.groupKey) ?? {},
|
|
5573
5573
|
value: e.value
|
|
@@ -5580,7 +5580,7 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
5580
5580
|
for (let r of t) n[r] = e[r];
|
|
5581
5581
|
return n;
|
|
5582
5582
|
}
|
|
5583
|
-
},
|
|
5583
|
+
}, il = E("_voltro_rebac_tuples", {
|
|
5584
5584
|
id: v({ prefix: "rbct" }),
|
|
5585
5585
|
subjectId: D(),
|
|
5586
5586
|
relation: D(),
|
|
@@ -5592,7 +5592,7 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
5592
5592
|
"subjectId",
|
|
5593
5593
|
"resourceType",
|
|
5594
5594
|
"resourceId"
|
|
5595
|
-
]).reactive(),
|
|
5595
|
+
]).reactive(), al = async (e, n, r, i) => n === null ? [] : (await e.query({
|
|
5596
5596
|
table: "_voltro_rebac_tuples",
|
|
5597
5597
|
predicate: t(u("subjectId", n), u("resourceType", r), u("resourceId", i)),
|
|
5598
5598
|
order: [],
|
|
@@ -5604,16 +5604,16 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
5604
5604
|
relation: e.relation,
|
|
5605
5605
|
resourceType: e.resourceType,
|
|
5606
5606
|
resourceId: e.resourceId
|
|
5607
|
-
})),
|
|
5607
|
+
})), ol = (e) => ({
|
|
5608
5608
|
id: e.id,
|
|
5609
5609
|
tenantId: e.tenantId,
|
|
5610
5610
|
...e.scopes === void 0 ? {} : { scopes: e.scopes }
|
|
5611
|
-
}),
|
|
5611
|
+
}), sl = (e, t) => {
|
|
5612
5612
|
let n = t.getPolicy ?? Ro;
|
|
5613
5613
|
return (r, i) => {
|
|
5614
5614
|
let a = e[i.tag];
|
|
5615
5615
|
if (a === void 0) return r;
|
|
5616
|
-
let o = n(a.resourceType), s = (e) =>
|
|
5616
|
+
let o = n(a.resourceType), s = (e) => M.fail(new Fo({
|
|
5617
5617
|
action: a.action,
|
|
5618
5618
|
resourceType: a.resourceType,
|
|
5619
5619
|
resourceId: e
|
|
@@ -5621,17 +5621,17 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
5621
5621
|
if (o === void 0) return s("");
|
|
5622
5622
|
let c = a.resourceId(i.input);
|
|
5623
5623
|
if (c === null || c === "") return s("");
|
|
5624
|
-
let l =
|
|
5624
|
+
let l = ol(i.subject), u = {
|
|
5625
5625
|
type: a.resourceType,
|
|
5626
5626
|
id: c,
|
|
5627
5627
|
tenantId: i.subject.tenantId
|
|
5628
5628
|
};
|
|
5629
|
-
return
|
|
5629
|
+
return M.flatMap(M.promise(async () => t.loadTuples(l.id, a.resourceType, c)), (e) => Wo(l, a.action, u, {
|
|
5630
5630
|
policy: o,
|
|
5631
5631
|
tuples: e
|
|
5632
5632
|
}) ? r : s(c));
|
|
5633
5633
|
};
|
|
5634
|
-
},
|
|
5634
|
+
}, cl = async (e, n, r) => n === null ? [] : (await e.query({
|
|
5635
5635
|
table: "_voltro_rebac_tuples",
|
|
5636
5636
|
predicate: t(u("subjectId", n), u("resourceType", r)),
|
|
5637
5637
|
order: [],
|
|
@@ -5643,18 +5643,18 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
5643
5643
|
relation: e.relation,
|
|
5644
5644
|
resourceType: e.resourceType,
|
|
5645
5645
|
resourceId: e.resourceId
|
|
5646
|
-
})),
|
|
5646
|
+
})), ll = (e) => {
|
|
5647
5647
|
let t = e.getPolicy ?? Ro;
|
|
5648
5648
|
return async (n, r, i, a) => {
|
|
5649
5649
|
let o = t(r);
|
|
5650
5650
|
if (o === void 0) return [];
|
|
5651
|
-
let s =
|
|
5651
|
+
let s = ol(n);
|
|
5652
5652
|
return Ko(s, i, r, a, {
|
|
5653
5653
|
policy: o,
|
|
5654
5654
|
tuples: await e.loadSubjectTuples(s.id, r)
|
|
5655
5655
|
});
|
|
5656
5656
|
};
|
|
5657
|
-
},
|
|
5657
|
+
}, ul = (e) => {
|
|
5658
5658
|
if (typeof e.name != "string" || e.name.length === 0) throw Error("defineReaction: a non-empty `name` is required");
|
|
5659
5659
|
if (e.watch === void 0 || typeof e.watch.table != "string" || e.watch.table.length === 0) throw Error(`reaction '${e.name}': watch.table is required`);
|
|
5660
5660
|
if (e.act === void 0 || e.act.kind !== "agent" && e.act.kind !== "workflow") throw Error(`reaction '${e.name}': act must be { kind: 'agent' | 'workflow', … }`);
|
|
@@ -5662,14 +5662,14 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
5662
5662
|
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`);
|
|
5663
5663
|
if (e.guards.costBudgetUsd !== void 0 && e.guards.costBudgetUsd < 0) throw Error(`reaction '${e.name}': guards.costBudgetUsd must be >= 0`);
|
|
5664
5664
|
return e;
|
|
5665
|
-
},
|
|
5665
|
+
}, dl = (e, t) => e === void 0 ? !0 : Array.isArray(e) ? e.includes(t) : e === t, fl = (e) => e.new?.tenantId ?? e.old?.tenantId ?? null, pl = class {
|
|
5666
5666
|
hits = /* @__PURE__ */ new Map();
|
|
5667
5667
|
allow(e, t, n, r) {
|
|
5668
5668
|
let i = r - n, a = (this.hits.get(e) ?? []).filter((e) => e > i);
|
|
5669
5669
|
return a.length >= t ? (this.hits.set(e, a), !1) : (a.push(r), this.hits.set(e, a), !0);
|
|
5670
5670
|
}
|
|
5671
|
-
},
|
|
5672
|
-
if (t.table !== e.watch.table || !
|
|
5671
|
+
}, ml = async (e, t, n) => {
|
|
5672
|
+
if (t.table !== e.watch.table || !dl(e.watch.on, t.op)) return "skipped-op";
|
|
5673
5673
|
if (e.when !== void 0 && !e.when(t)) return "skipped-when";
|
|
5674
5674
|
let r = `${e.name}:${e.guards.dedupeKey(t)}`;
|
|
5675
5675
|
if (await n.dedupe.has(r)) return "skipped-dedupe";
|
|
@@ -5678,26 +5678,26 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
5678
5678
|
let t = n.now?.() ?? Date.now();
|
|
5679
5679
|
if (!n.rateLimiter.allow(e.name, i.limit, i.windowMs, t)) return "skipped-ratelimit";
|
|
5680
5680
|
}
|
|
5681
|
-
let a =
|
|
5681
|
+
let a = fl(t);
|
|
5682
5682
|
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, {
|
|
5683
5683
|
id: a,
|
|
5684
5684
|
via: "agent"
|
|
5685
5685
|
}), await n.dedupe.add(r), "acted");
|
|
5686
|
-
},
|
|
5686
|
+
}, hl = E("_voltro_wakeups", {
|
|
5687
5687
|
id: v({ prefix: "wakeup" }),
|
|
5688
5688
|
tenantId: D(),
|
|
5689
5689
|
kind: D(),
|
|
5690
5690
|
refId: D(),
|
|
5691
5691
|
wakeAt: O(),
|
|
5692
5692
|
status: D()
|
|
5693
|
-
}).index(["status", "wakeAt"]).index(["tenantId"]),
|
|
5694
|
-
let t = e.now?.() ?? /* @__PURE__ */ new Date(), n = await
|
|
5693
|
+
}).index(["status", "wakeAt"]).index(["tenantId"]), gl = async (e) => {
|
|
5694
|
+
let t = e.now?.() ?? /* @__PURE__ */ new Date(), n = await Zs(e.store, t, e.batchLimit ?? 100);
|
|
5695
5695
|
if (n.length === 0) return 0;
|
|
5696
5696
|
let r = 0;
|
|
5697
|
-
for (let t of n) if (await
|
|
5697
|
+
for (let t of n) if (await qs(e.store, t)) try {
|
|
5698
5698
|
await e.adapter.wake(t), r++;
|
|
5699
5699
|
} catch (n) {
|
|
5700
|
-
await
|
|
5700
|
+
await Js(e.store, t), e.log?.warn("wake: adapter failed — released for retry", {
|
|
5701
5701
|
tenantId: t.tenantId,
|
|
5702
5702
|
kind: t.kind,
|
|
5703
5703
|
refId: t.refId,
|
|
@@ -5705,11 +5705,11 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
5705
5705
|
});
|
|
5706
5706
|
}
|
|
5707
5707
|
return r > 0 && e.log?.info("wake: woke due deployments", { count: r }), r;
|
|
5708
|
-
},
|
|
5708
|
+
}, _l = (e, t = 1e3) => {
|
|
5709
5709
|
let n = !1, r, i = async () => {
|
|
5710
5710
|
if (!n) {
|
|
5711
5711
|
try {
|
|
5712
|
-
await
|
|
5712
|
+
await gl(e);
|
|
5713
5713
|
} catch (t) {
|
|
5714
5714
|
e.log?.warn("wake: tick failed", { reason: t instanceof Error ? t.message : String(t) });
|
|
5715
5715
|
}
|
|
@@ -5719,10 +5719,10 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
5719
5719
|
return i(), { stop: () => {
|
|
5720
5720
|
n = !0, r !== void 0 && clearTimeout(r);
|
|
5721
5721
|
} };
|
|
5722
|
-
},
|
|
5722
|
+
}, vl = (e) => ({ wake: async () => {
|
|
5723
5723
|
await e.start();
|
|
5724
|
-
} }),
|
|
5725
|
-
let t = e.fetchImpl ?? fetch, n = e.now ?? Date.now, r = e.sleep ??
|
|
5724
|
+
} }), yl = (e) => new Promise((t) => setTimeout(t, e)), bl = (e) => {
|
|
5725
|
+
let t = e.fetchImpl ?? fetch, n = e.now ?? Date.now, r = e.sleep ?? yl, i = e.spawnImpl ?? Ct, 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 () => {
|
|
5726
5726
|
try {
|
|
5727
5727
|
let n = await t(e.healthUrl);
|
|
5728
5728
|
return d(n);
|
|
@@ -5776,11 +5776,11 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
5776
5776
|
},
|
|
5777
5777
|
stop: m
|
|
5778
5778
|
};
|
|
5779
|
-
},
|
|
5779
|
+
}, xl = async (e) => {
|
|
5780
5780
|
if (e.signals.connectedClients() > 0 || e.signals.inFlightRequests() > 0 || e.signals.activeWorkflowExecutions() > 0) return !1;
|
|
5781
|
-
let t = (e.now?.() ?? /* @__PURE__ */ new Date()).getTime() + (e.wakeLookaheadMs ?? 3e4), n = await
|
|
5781
|
+
let t = (e.now?.() ?? /* @__PURE__ */ new Date()).getTime() + (e.wakeLookaheadMs ?? 3e4), n = await Qs(e.store);
|
|
5782
5782
|
return !(n !== null && n.wakeAt.getTime() <= t);
|
|
5783
|
-
},
|
|
5783
|
+
}, Sl = (e, t = Date.now) => {
|
|
5784
5784
|
let n;
|
|
5785
5785
|
return {
|
|
5786
5786
|
update: (r) => {
|
|
@@ -5792,7 +5792,7 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
5792
5792
|
n = void 0;
|
|
5793
5793
|
}
|
|
5794
5794
|
};
|
|
5795
|
-
},
|
|
5795
|
+
}, Cl = () => {
|
|
5796
5796
|
let e = 0, t = 0;
|
|
5797
5797
|
return {
|
|
5798
5798
|
onRequestStart: () => {
|
|
@@ -5810,8 +5810,8 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
5810
5810
|
inFlightRequests: () => e,
|
|
5811
5811
|
openConnections: () => t
|
|
5812
5812
|
};
|
|
5813
|
-
},
|
|
5814
|
-
let o =
|
|
5813
|
+
}, wl = (e) => ({ run: async (t) => (e.onActivity?.(), await e.ensureAwake(), t()) }), Tl = (e, t, n, r) => new Promise((i, a) => {
|
|
5814
|
+
let o = Ye.request({
|
|
5815
5815
|
host: n,
|
|
5816
5816
|
port: r,
|
|
5817
5817
|
method: e.method,
|
|
@@ -5821,8 +5821,8 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
5821
5821
|
t.writeHead(e.statusCode ?? 502, e.headers), e.pipe(t), e.on("end", i), e.on("error", a);
|
|
5822
5822
|
});
|
|
5823
5823
|
o.on("error", a), e.pipe(o);
|
|
5824
|
-
}),
|
|
5825
|
-
let s =
|
|
5824
|
+
}), El = (e, t, n, r, i) => new Promise((a, o) => {
|
|
5825
|
+
let s = Ye.request({
|
|
5826
5826
|
host: r,
|
|
5827
5827
|
port: i,
|
|
5828
5828
|
method: e.method,
|
|
@@ -5836,21 +5836,21 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
5836
5836
|
};
|
|
5837
5837
|
t.on("close", s), r.on("close", s), r.on("error", o);
|
|
5838
5838
|
}), s.on("error", o), s.end();
|
|
5839
|
-
}),
|
|
5840
|
-
let t =
|
|
5839
|
+
}), Dl = (e) => {
|
|
5840
|
+
let t = wl({
|
|
5841
5841
|
ensureAwake: () => e.supervisor.start(),
|
|
5842
5842
|
...e.onActivity === void 0 ? {} : { onActivity: e.onActivity }
|
|
5843
|
-
}), n = e.activity, r =
|
|
5844
|
-
n?.onRequestStart(), i.on("close", () => n?.onRequestEnd()), t.run(() =>
|
|
5843
|
+
}), n = e.activity, r = Ye.createServer((r, i) => {
|
|
5844
|
+
n?.onRequestStart(), i.on("close", () => n?.onRequestEnd()), t.run(() => Tl(r, i, e.targetHost, e.targetPort)).catch((t) => {
|
|
5845
5845
|
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");
|
|
5846
5846
|
});
|
|
5847
5847
|
});
|
|
5848
5848
|
return r.on("upgrade", (r, i, a) => {
|
|
5849
|
-
n?.onConnect(), i.on("close", () => n?.onDisconnect()), t.run(() =>
|
|
5849
|
+
n?.onConnect(), i.on("close", () => n?.onDisconnect()), t.run(() => El(r, i, a, e.targetHost, e.targetPort)).catch((t) => {
|
|
5850
5850
|
e.log?.warn("wake-router: upgrade proxy failed", { reason: t instanceof Error ? t.message : String(t) }), i.destroy();
|
|
5851
5851
|
});
|
|
5852
5852
|
}), r;
|
|
5853
|
-
},
|
|
5853
|
+
}, Ol = async (e) => {
|
|
5854
5854
|
try {
|
|
5855
5855
|
return (await e.query({
|
|
5856
5856
|
table: "_voltro_workflow_runs",
|
|
@@ -5867,15 +5867,15 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
5867
5867
|
} catch {
|
|
5868
5868
|
return 0;
|
|
5869
5869
|
}
|
|
5870
|
-
},
|
|
5871
|
-
let t =
|
|
5870
|
+
}, kl = async (e) => {
|
|
5871
|
+
let t = vl(e.supervisor), n = await gl({
|
|
5872
5872
|
store: e.store,
|
|
5873
5873
|
adapter: t,
|
|
5874
5874
|
...e.now === void 0 ? {} : { now: e.now },
|
|
5875
5875
|
...e.log === void 0 ? {} : { log: e.log }
|
|
5876
5876
|
});
|
|
5877
5877
|
n > 0 && e.idleGate.reset();
|
|
5878
|
-
let r = await
|
|
5878
|
+
let r = await xl({
|
|
5879
5879
|
store: e.store,
|
|
5880
5880
|
signals: e.signals,
|
|
5881
5881
|
...e.wakeLookaheadMs === void 0 ? {} : { wakeLookaheadMs: e.wakeLookaheadMs },
|
|
@@ -5885,12 +5885,12 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
5885
5885
|
woke: n,
|
|
5886
5886
|
stopped: i
|
|
5887
5887
|
};
|
|
5888
|
-
},
|
|
5889
|
-
let t =
|
|
5888
|
+
}, Al = async (e) => {
|
|
5889
|
+
let t = Sl(e.idleGraceMs ?? 6e4), n = e.tickMs ?? 1e3, r = Cl(), i = 0, a = e.signals === void 0, o = e.signals ?? {
|
|
5890
5890
|
connectedClients: () => r.openConnections(),
|
|
5891
5891
|
inFlightRequests: () => r.inFlightRequests(),
|
|
5892
5892
|
activeWorkflowExecutions: () => i
|
|
5893
|
-
}, s =
|
|
5893
|
+
}, s = Dl({
|
|
5894
5894
|
supervisor: e.supervisor,
|
|
5895
5895
|
targetHost: e.targetHost,
|
|
5896
5896
|
targetPort: e.targetPort,
|
|
@@ -5909,7 +5909,7 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
5909
5909
|
let l = !1, u, d = e.firedRetentionMs ?? 10 * 6e4, f = 0, p = async () => {
|
|
5910
5910
|
if (!l) {
|
|
5911
5911
|
try {
|
|
5912
|
-
if (a && (i = await
|
|
5912
|
+
if (a && (i = await Ol(e.store)), await kl({
|
|
5913
5913
|
store: e.store,
|
|
5914
5914
|
supervisor: e.supervisor,
|
|
5915
5915
|
signals: o,
|
|
@@ -5917,7 +5917,7 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
5917
5917
|
...e.wakeLookaheadMs === void 0 ? {} : { wakeLookaheadMs: e.wakeLookaheadMs },
|
|
5918
5918
|
...e.log === void 0 ? {} : { log: e.log }
|
|
5919
5919
|
}), f++ % 60 == 0) {
|
|
5920
|
-
let t = await
|
|
5920
|
+
let t = await ec(e.store, { firedOlderThan: new Date(Date.now() - d) });
|
|
5921
5921
|
t > 0 && e.log?.info("orchestrator: pruned fired wakeups", { count: t });
|
|
5922
5922
|
}
|
|
5923
5923
|
} catch (t) {
|
|
@@ -5932,14 +5932,14 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
5932
5932
|
l = !0, u !== void 0 && clearTimeout(u), await new Promise((e) => s.close(() => e()));
|
|
5933
5933
|
}
|
|
5934
5934
|
};
|
|
5935
|
-
},
|
|
5936
|
-
provider:
|
|
5937
|
-
operation:
|
|
5938
|
-
cause:
|
|
5939
|
-
}) {},
|
|
5940
|
-
provider:
|
|
5941
|
-
capability:
|
|
5942
|
-
}) {},
|
|
5935
|
+
}, jl = (e) => e, Ml = class extends L.TaggedError()("AnalyticsError", {
|
|
5936
|
+
provider: L.String,
|
|
5937
|
+
operation: L.String,
|
|
5938
|
+
cause: L.String
|
|
5939
|
+
}) {}, Nl = class extends L.TaggedError()("AnalyticsCapabilityNotSupported", {
|
|
5940
|
+
provider: L.String,
|
|
5941
|
+
capability: L.String
|
|
5942
|
+
}) {}, Pl = class extends Re.Tag("@voltro/AnalyticsSink")() {}, Fl = (e, t) => ({
|
|
5943
5943
|
info: e.info,
|
|
5944
5944
|
track: (n) => e.track(n.tenantId === void 0 ? {
|
|
5945
5945
|
...n,
|
|
@@ -5958,20 +5958,20 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
5958
5958
|
tenantId: t
|
|
5959
5959
|
} : n),
|
|
5960
5960
|
...e.mirror === void 0 ? {} : { mirror: e.mirror }
|
|
5961
|
-
}),
|
|
5962
|
-
let e = yield*
|
|
5961
|
+
}), Il = () => M.gen(function* () {
|
|
5962
|
+
let e = yield* Pl, t = yield* M.serviceOption(Se), n = F.match(t, {
|
|
5963
5963
|
onNone: () => null,
|
|
5964
5964
|
onSome: (e) => e.tenantId ?? null
|
|
5965
5965
|
});
|
|
5966
|
-
return n === null ? e :
|
|
5967
|
-
}),
|
|
5968
|
-
let e = (e) =>
|
|
5969
|
-
provider:
|
|
5966
|
+
return n === null ? e : Fl(e, n);
|
|
5967
|
+
}), Ll = "noop", Rl = () => {
|
|
5968
|
+
let e = (e) => M.fail(new Nl({
|
|
5969
|
+
provider: Ll,
|
|
5970
5970
|
capability: e
|
|
5971
5971
|
}));
|
|
5972
5972
|
return {
|
|
5973
5973
|
info: {
|
|
5974
|
-
provider:
|
|
5974
|
+
provider: Ll,
|
|
5975
5975
|
capabilities: {
|
|
5976
5976
|
track: !0,
|
|
5977
5977
|
aggregate: !1,
|
|
@@ -5980,13 +5980,13 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
5980
5980
|
mirror: !1
|
|
5981
5981
|
}
|
|
5982
5982
|
},
|
|
5983
|
-
track: () =>
|
|
5983
|
+
track: () => M.void,
|
|
5984
5984
|
aggregate: () => e("aggregate"),
|
|
5985
5985
|
timeseries: () => e("timeseries"),
|
|
5986
5986
|
topN: () => e("topN")
|
|
5987
5987
|
};
|
|
5988
|
-
},
|
|
5989
|
-
if (e.length === 0) return
|
|
5988
|
+
}, zl = (e) => {
|
|
5989
|
+
if (e.length === 0) return Rl();
|
|
5990
5990
|
if (e.length === 1) return e[0];
|
|
5991
5991
|
let t = {
|
|
5992
5992
|
provider: "compose",
|
|
@@ -5998,22 +5998,22 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
5998
5998
|
mirror: e.some((e) => e.info.capabilities.mirror)
|
|
5999
5999
|
},
|
|
6000
6000
|
detail: { members: e.map((e) => e.info) }
|
|
6001
|
-
}, n = (t) =>
|
|
6001
|
+
}, n = (t) => M.forEach(e, (e) => e.track(t).pipe(M.catchAll((t) => M.logWarning(`analytics-sink ${e.info.provider} track failed`, { err: t }))), {
|
|
6002
6002
|
concurrency: "unbounded",
|
|
6003
6003
|
discard: !0
|
|
6004
6004
|
}), r = (t, n) => {
|
|
6005
6005
|
let r = e.find((e) => e.info.capabilities[t]);
|
|
6006
|
-
return r === void 0 ?
|
|
6006
|
+
return r === void 0 ? M.fail(new Nl({
|
|
6007
6007
|
provider: "compose",
|
|
6008
6008
|
capability: t
|
|
6009
6009
|
})) : n(r);
|
|
6010
6010
|
}, i = e.filter((e) => e.mirror !== void 0), a = i.length === 0 ? void 0 : {
|
|
6011
6011
|
tables: Array.from(new Set(i.flatMap((e) => e.mirror.tables))),
|
|
6012
|
-
upsert: (e, t) =>
|
|
6012
|
+
upsert: (e, t) => M.forEach(i.filter((t) => t.mirror.tables.includes(e)), (n) => n.mirror.upsert(e, t), {
|
|
6013
6013
|
concurrency: "unbounded",
|
|
6014
6014
|
discard: !0
|
|
6015
6015
|
}),
|
|
6016
|
-
remove: (e, t) =>
|
|
6016
|
+
remove: (e, t) => M.forEach(i.filter((t) => t.mirror.tables.includes(e)), (n) => n.mirror.remove(e, t), {
|
|
6017
6017
|
concurrency: "unbounded",
|
|
6018
6018
|
discard: !0
|
|
6019
6019
|
})
|
|
@@ -6026,42 +6026,42 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
6026
6026
|
topN: (e) => r("topN", (t) => t.topN(e)),
|
|
6027
6027
|
...a === void 0 ? {} : { mirror: a }
|
|
6028
6028
|
};
|
|
6029
|
-
},
|
|
6029
|
+
}, Bl = (e) => {
|
|
6030
6030
|
let t = e.filter((e) => e.dispose !== void 0);
|
|
6031
6031
|
return {
|
|
6032
6032
|
kind: "compose",
|
|
6033
|
-
build: (t) =>
|
|
6033
|
+
build: (t) => zl(e.map((e) => e.build(t))),
|
|
6034
6034
|
tables: e.flatMap((e) => e.tables ?? []),
|
|
6035
|
-
initialize: (t) =>
|
|
6035
|
+
initialize: (t) => M.forEach(e, (e) => e.initialize ? e.initialize(t) : M.void, {
|
|
6036
6036
|
concurrency: 1,
|
|
6037
6037
|
discard: !0
|
|
6038
6038
|
}),
|
|
6039
|
-
...t.length > 0 ? { dispose: (e) =>
|
|
6039
|
+
...t.length > 0 ? { dispose: (e) => M.forEach(t, (t) => t.dispose(e), {
|
|
6040
6040
|
concurrency: 1,
|
|
6041
6041
|
discard: !0
|
|
6042
6042
|
}) } : {}
|
|
6043
6043
|
};
|
|
6044
|
-
}, Bl = {
|
|
6045
|
-
kind: "noop",
|
|
6046
|
-
build: () => Ll()
|
|
6047
6044
|
}, Vl = {
|
|
6045
|
+
kind: "noop",
|
|
6046
|
+
build: () => Rl()
|
|
6047
|
+
}, Hl = {
|
|
6048
6048
|
tables: [],
|
|
6049
6049
|
detach: () => {}
|
|
6050
|
-
},
|
|
6050
|
+
}, Ul = (e) => {
|
|
6051
6051
|
let { store: t, sink: n, log: r } = e, i = n.mirror;
|
|
6052
|
-
if (i === void 0 || i.tables.length === 0) return
|
|
6053
|
-
let a = e.run ?? ((e) =>
|
|
6052
|
+
if (i === void 0 || i.tables.length === 0) return Hl;
|
|
6053
|
+
let a = e.run ?? ((e) => M.runPromise(e)), o = i.primaryKey ?? "id", s = new Set(i.tables), c = (e) => {
|
|
6054
6054
|
if (e.op === "delete") {
|
|
6055
6055
|
let t = e.old;
|
|
6056
|
-
if (t === null) return
|
|
6056
|
+
if (t === null) return M.void;
|
|
6057
6057
|
let n = t[o];
|
|
6058
|
-
return n === void 0 ?
|
|
6058
|
+
return n === void 0 ? M.void : i.remove(e.table, n);
|
|
6059
6059
|
}
|
|
6060
6060
|
let t = e.new;
|
|
6061
|
-
return t === null ?
|
|
6061
|
+
return t === null ? M.void : i.upsert(e.table, t);
|
|
6062
6062
|
}, l = t.onChange((e) => {
|
|
6063
6063
|
if (!s.has(e.table)) return;
|
|
6064
|
-
let t = c(e).pipe(
|
|
6064
|
+
let t = c(e).pipe(M.catchAll((t) => M.sync(() => r.warn("analytics-mirror: change forward failed", {
|
|
6065
6065
|
provider: n.info.provider,
|
|
6066
6066
|
table: e.table,
|
|
6067
6067
|
op: e.op,
|
|
@@ -6073,11 +6073,11 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
6073
6073
|
tables: i.tables,
|
|
6074
6074
|
detach: l
|
|
6075
6075
|
};
|
|
6076
|
-
},
|
|
6076
|
+
}, Wl = (e) => {
|
|
6077
6077
|
let t = typeof e.refresh == "string" ? { interval: e.refresh } : e.refresh, n = e.strategy ?? "replace";
|
|
6078
6078
|
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`);
|
|
6079
6079
|
if (e.incremental !== void 0) {
|
|
6080
|
-
let t =
|
|
6080
|
+
let t = Yc({
|
|
6081
6081
|
aggregations: [{
|
|
6082
6082
|
op: e.incremental.op,
|
|
6083
6083
|
...e.incremental.column === void 0 ? {} : { column: e.incremental.column }
|
|
@@ -6099,51 +6099,51 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
6099
6099
|
build: e.build,
|
|
6100
6100
|
...e.incremental === void 0 ? {} : { incremental: e.incremental }
|
|
6101
6101
|
};
|
|
6102
|
-
},
|
|
6103
|
-
name:
|
|
6104
|
-
ageMs:
|
|
6105
|
-
maxAgeMs:
|
|
6106
|
-
}) {},
|
|
6107
|
-
name:
|
|
6108
|
-
operation:
|
|
6109
|
-
cause:
|
|
6110
|
-
}) {},
|
|
6111
|
-
return (yield*
|
|
6112
|
-
}),
|
|
6102
|
+
}, Gl = (e) => typeof e == "object" && !!e && e._voltroAggregate === !0, Kl = class extends L.TaggedError()("AggregateStale", {
|
|
6103
|
+
name: L.String,
|
|
6104
|
+
ageMs: L.Number,
|
|
6105
|
+
maxAgeMs: L.Number
|
|
6106
|
+
}) {}, ql = class extends L.TaggedError()("AggregateNotFound", { name: L.String }) {}, Jl = class extends L.TaggedError()("AggregateError", {
|
|
6107
|
+
name: L.String,
|
|
6108
|
+
operation: L.String,
|
|
6109
|
+
cause: L.String
|
|
6110
|
+
}) {}, Yl = class extends Re.Tag("@voltro/AggregateRegistry")() {}, Xl = (e) => M.gen(function* () {
|
|
6111
|
+
return (yield* Yl).getHandle(e);
|
|
6112
|
+
}), Zl = (e, n, r) => {
|
|
6113
6113
|
if (e.crossTenant || !n.has(e.table) || r == null) return e;
|
|
6114
6114
|
let i = u("tenantId", r);
|
|
6115
6115
|
return {
|
|
6116
6116
|
...e,
|
|
6117
6117
|
predicate: e.predicate ? t(e.predicate, i) : i
|
|
6118
6118
|
};
|
|
6119
|
-
},
|
|
6119
|
+
}, Ql = (e, n) => {
|
|
6120
6120
|
if (e.includeDeleted || !n.has(e.table)) return e;
|
|
6121
6121
|
let r = S("deletedAt");
|
|
6122
6122
|
return {
|
|
6123
6123
|
...e,
|
|
6124
6124
|
predicate: e.predicate ? t(e.predicate, r) : r
|
|
6125
6125
|
};
|
|
6126
|
-
},
|
|
6127
|
-
if (
|
|
6126
|
+
}, $l = (e) => M.runPromiseExit(e).then((e) => {
|
|
6127
|
+
if (Ue.isSuccess(e)) return e.value;
|
|
6128
6128
|
let t = j.failureOption(e.cause);
|
|
6129
|
-
throw
|
|
6130
|
-
}),
|
|
6131
|
-
let r = await
|
|
6129
|
+
throw F.isSome(t) ? t.value : j.squash(e.cause);
|
|
6130
|
+
}), eu = (e, t) => e.pipe(M.provideService(Se, t)), tu = async (e, t, n) => {
|
|
6131
|
+
let r = await M.runPromise(De(t, e.guards, n));
|
|
6132
6132
|
if (r) throw r;
|
|
6133
|
-
},
|
|
6134
|
-
if (
|
|
6135
|
-
let t = await
|
|
6133
|
+
}, nu = async (e) => {
|
|
6134
|
+
if (jn() === void 0) return e;
|
|
6135
|
+
let t = await $l(Nn(e.subject, (e) => {
|
|
6136
6136
|
console.error("[voltro] row filter failed to load", e);
|
|
6137
6137
|
}));
|
|
6138
6138
|
return {
|
|
6139
6139
|
...e,
|
|
6140
6140
|
rowFilter: t
|
|
6141
6141
|
};
|
|
6142
|
-
},
|
|
6142
|
+
}, ru = async (e) => {
|
|
6143
6143
|
let t = `${e.kind}.${e.name}`, n = Date.now(), r = "ok";
|
|
6144
6144
|
try {
|
|
6145
6145
|
if (e.interceptor) {
|
|
6146
|
-
let t =
|
|
6146
|
+
let t = M.tryPromise({
|
|
6147
6147
|
try: () => e.runExecutor(),
|
|
6148
6148
|
catch: (e) => e
|
|
6149
6149
|
}), n = e.interceptor(t, {
|
|
@@ -6153,8 +6153,8 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
6153
6153
|
subject: e.requestContext.subject,
|
|
6154
6154
|
traceId: e.requestContext.traceId,
|
|
6155
6155
|
...e.requestContext.spanId === void 0 ? {} : { spanId: e.requestContext.spanId }
|
|
6156
|
-
}), r = await
|
|
6157
|
-
if (
|
|
6156
|
+
}), r = await M.runPromiseExit(n);
|
|
6157
|
+
if (Ue.isSuccess(r)) return r.value;
|
|
6158
6158
|
throw j.squash(r.cause);
|
|
6159
6159
|
}
|
|
6160
6160
|
return await e.runExecutor();
|
|
@@ -6168,28 +6168,28 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
6168
6168
|
status: r
|
|
6169
6169
|
});
|
|
6170
6170
|
}
|
|
6171
|
-
},
|
|
6171
|
+
}, iu = /* @__PURE__ */ new Set([1213, 1205]), au = /* @__PURE__ */ new Set([
|
|
6172
6172
|
"ER_LOCK_DEADLOCK",
|
|
6173
6173
|
"ER_LOCK_WAIT_TIMEOUT",
|
|
6174
6174
|
"40001",
|
|
6175
6175
|
"40P01"
|
|
6176
|
-
]),
|
|
6176
|
+
]), ou = (e) => {
|
|
6177
6177
|
let t = e;
|
|
6178
6178
|
for (let e = 0; e < 6 && typeof t == "object" && t; e++) {
|
|
6179
6179
|
let e = t;
|
|
6180
|
-
if (typeof e.errno == "number" &&
|
|
6180
|
+
if (typeof e.errno == "number" && iu.has(e.errno) || typeof e.code == "string" && au.has(e.code) || typeof e.sqlState == "string" && au.has(e.sqlState)) return !0;
|
|
6181
6181
|
t = e.cause;
|
|
6182
6182
|
}
|
|
6183
6183
|
return !1;
|
|
6184
|
-
},
|
|
6185
|
-
let n = t?.delay ?? ((e) =>
|
|
6184
|
+
}, su = 3, cu = (e) => new Promise((t) => setTimeout(t, e)), lu = async (e, t) => {
|
|
6185
|
+
let n = t?.delay ?? ((e) => cu(e * 20 + Math.floor(Math.random() * 30)));
|
|
6186
6186
|
for (let t = 1;; t++) try {
|
|
6187
6187
|
return await e();
|
|
6188
6188
|
} catch (e) {
|
|
6189
|
-
if (t >=
|
|
6189
|
+
if (t >= su || !ou(e)) throw e;
|
|
6190
6190
|
await n(t);
|
|
6191
6191
|
}
|
|
6192
|
-
},
|
|
6192
|
+
}, uu = (e) => (t, n, r) => ru({
|
|
6193
6193
|
name: t.descriptor.name,
|
|
6194
6194
|
kind: "mutation",
|
|
6195
6195
|
input: n,
|
|
@@ -6197,11 +6197,11 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
6197
6197
|
...e.interceptor ? { interceptor: e.interceptor } : {},
|
|
6198
6198
|
...e.recordMetric ? { recordMetric: e.recordMetric } : {},
|
|
6199
6199
|
runExecutor: async () => {
|
|
6200
|
-
await
|
|
6201
|
-
let i = await
|
|
6200
|
+
await tu(t.descriptor, r.subject, n);
|
|
6201
|
+
let i = await nu(r), a = [], o = await lu(async () => (a.length = 0, e.store.transactional(async (o) => {
|
|
6202
6202
|
let s = e.undoCapture?.(o), c = s ? s.tx : o, l = e.buildContext(i, c, { afterCommit: (e) => {
|
|
6203
6203
|
a.push(e);
|
|
6204
|
-
} }), u = t.executor(n, l), d =
|
|
6204
|
+
} }), u = t.executor(n, l), d = M.isEffect(u) ? await e.runEffect(eu(u, r.subject), l.store) : await u;
|
|
6205
6205
|
return s && await s.persist(l.store, {
|
|
6206
6206
|
tag: t.descriptor.name,
|
|
6207
6207
|
subject: r.subject,
|
|
@@ -6211,42 +6211,42 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
6211
6211
|
for (let e of a) await e();
|
|
6212
6212
|
return o;
|
|
6213
6213
|
}
|
|
6214
|
-
}),
|
|
6214
|
+
}), du = (e) => e && typeof e == "object" && "descriptor" in e ? e.descriptor : e, fu = (e) => typeof e == "object" && !!e && !Array.isArray(e) && "table" in e && "order" in e, pu = (e) => {
|
|
6215
6215
|
let t = e.descriptor.source;
|
|
6216
6216
|
return t == null ? [] : typeof t == "string" ? [t] : [...t];
|
|
6217
|
-
},
|
|
6217
|
+
}, mu = (e, t) => (n) => () => {
|
|
6218
6218
|
let r = e.descriptor.guards;
|
|
6219
|
-
return !r || r.length === 0 ? Promise.resolve(null) :
|
|
6220
|
-
},
|
|
6221
|
-
let i = e.buildContext(r), a =
|
|
6219
|
+
return !r || r.length === 0 ? Promise.resolve(null) : M.runPromise(De(n, r, t));
|
|
6220
|
+
}, hu = (e) => (t, n) => (r) => {
|
|
6221
|
+
let i = e.buildContext(r), a = mu(t, n)(r.subject), o = async () => {
|
|
6222
6222
|
let i = await a();
|
|
6223
6223
|
if (i) throw i;
|
|
6224
|
-
let o = e.buildContext(await
|
|
6225
|
-
return
|
|
6224
|
+
let o = e.buildContext(await nu(r)), s = t.executor(n, o);
|
|
6225
|
+
return M.isEffect(s) ? M.runPromise(e.provideEffect(eu(s, r.subject), o.store)) : du(await Promise.resolve(s));
|
|
6226
6226
|
}, s = (n) => {
|
|
6227
|
-
let i =
|
|
6228
|
-
return
|
|
6227
|
+
let i = du(n);
|
|
6228
|
+
return fu(i) ? e.finalize(i, r) : {
|
|
6229
6229
|
__voltroComputed: !0,
|
|
6230
6230
|
value: i,
|
|
6231
|
-
dependentTables:
|
|
6231
|
+
dependentTables: pu(t),
|
|
6232
6232
|
tenantId: r.subject?.tenantId ?? null,
|
|
6233
6233
|
recompute: o
|
|
6234
6234
|
};
|
|
6235
6235
|
}, c = () => {
|
|
6236
6236
|
let a = t.executor(n, i);
|
|
6237
|
-
return
|
|
6237
|
+
return M.isEffect(a) ? e.provideEffect(eu(a, r.subject), i.store).pipe(M.map(s)) : a instanceof Promise ? M.promise(() => a).pipe(M.map(s)) : s(a);
|
|
6238
6238
|
}, l = () => {
|
|
6239
6239
|
let e = t.descriptor.guards;
|
|
6240
|
-
return !e || e.length === 0 ? c() : De(r.subject, e, n).pipe(
|
|
6241
|
-
if (e) return
|
|
6240
|
+
return !e || e.length === 0 ? c() : De(r.subject, e, n).pipe(M.flatMap((e) => {
|
|
6241
|
+
if (e) return M.fail(e);
|
|
6242
6242
|
let t = c();
|
|
6243
|
-
return
|
|
6243
|
+
return M.isEffect(t) ? t : M.succeed(t);
|
|
6244
6244
|
}));
|
|
6245
6245
|
};
|
|
6246
6246
|
if (!e.interceptor) return l();
|
|
6247
|
-
let u =
|
|
6247
|
+
let u = M.suspend(() => {
|
|
6248
6248
|
let e = l();
|
|
6249
|
-
return
|
|
6249
|
+
return M.isEffect(e) ? e : M.succeed(e);
|
|
6250
6250
|
});
|
|
6251
6251
|
return e.interceptor(u, {
|
|
6252
6252
|
tag: t.descriptor.name,
|
|
@@ -6256,7 +6256,7 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
6256
6256
|
traceId: r.traceId,
|
|
6257
6257
|
...r.spanId === void 0 ? {} : { spanId: r.spanId }
|
|
6258
6258
|
});
|
|
6259
|
-
},
|
|
6259
|
+
}, gu = (e) => (t, n, r) => ru({
|
|
6260
6260
|
name: t.descriptor.name,
|
|
6261
6261
|
kind: "action",
|
|
6262
6262
|
input: n,
|
|
@@ -6264,16 +6264,16 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
6264
6264
|
...e.interceptor ? { interceptor: e.interceptor } : {},
|
|
6265
6265
|
...e.recordMetric ? { recordMetric: e.recordMetric } : {},
|
|
6266
6266
|
runExecutor: async () => {
|
|
6267
|
-
await
|
|
6268
|
-
let i = e.buildContext(await
|
|
6269
|
-
return
|
|
6267
|
+
await tu(t.descriptor, r.subject, n);
|
|
6268
|
+
let i = e.buildContext(await nu(r)), a = t.executor(n, i);
|
|
6269
|
+
return M.isEffect(a) ? e.runEffect(eu(a, r.subject), i.store) : a;
|
|
6270
6270
|
}
|
|
6271
|
-
}),
|
|
6271
|
+
}), _u = (e) => e instanceof Date ? e.toISOString() : typeof e == "string" && e.length > 0 ? e : null, vu = (e) => typeof e == "string" && e.length > 0 ? e : null, yu = [
|
|
6272
6272
|
"updatedAt",
|
|
6273
6273
|
"createdAt",
|
|
6274
6274
|
"updatedBy",
|
|
6275
6275
|
"createdBy"
|
|
6276
|
-
],
|
|
6276
|
+
], bu = (e) => yu.some((t) => t in e), xu = (e, t, n) => {
|
|
6277
6277
|
let r = {
|
|
6278
6278
|
table: t.table,
|
|
6279
6279
|
id: t.id,
|
|
@@ -6288,14 +6288,14 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
6288
6288
|
found: !1
|
|
6289
6289
|
};
|
|
6290
6290
|
let i = t.column === void 0 ? void 0 : e[t.column];
|
|
6291
|
-
if (!
|
|
6291
|
+
if (!bu(e)) return {
|
|
6292
6292
|
...r,
|
|
6293
6293
|
value: i,
|
|
6294
6294
|
lastWrite: null,
|
|
6295
6295
|
attribution: "none",
|
|
6296
6296
|
found: !0
|
|
6297
6297
|
};
|
|
6298
|
-
let a =
|
|
6298
|
+
let a = vu(e.updatedBy) ?? vu(e.createdBy), o = _u(e.updatedAt) ?? _u(e.createdAt);
|
|
6299
6299
|
return {
|
|
6300
6300
|
...r,
|
|
6301
6301
|
value: i,
|
|
@@ -6307,12 +6307,12 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
6307
6307
|
attribution: "audit",
|
|
6308
6308
|
found: !0
|
|
6309
6309
|
};
|
|
6310
|
-
},
|
|
6310
|
+
}, Su = (e, t) => {
|
|
6311
6311
|
let n = e.map((e) => {
|
|
6312
6312
|
let n = e.newValue ?? e.value, r = t.column !== void 0 && n && typeof n == "object" ? n[t.column] : e.newValue ?? e.value;
|
|
6313
6313
|
return {
|
|
6314
|
-
actor: { id:
|
|
6315
|
-
at:
|
|
6314
|
+
actor: { id: vu(e.actor) ?? vu(e.changedBy) },
|
|
6315
|
+
at: _u(e.at) ?? _u(e.changedAt),
|
|
6316
6316
|
...e.traceId === void 0 ? {} : { traceId: e.traceId },
|
|
6317
6317
|
value: r
|
|
6318
6318
|
};
|
|
@@ -6327,12 +6327,12 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
6327
6327
|
history: n,
|
|
6328
6328
|
found: n.length > 0
|
|
6329
6329
|
};
|
|
6330
|
-
},
|
|
6330
|
+
}, Cu = (e) => {
|
|
6331
6331
|
let t = e.new?.id;
|
|
6332
6332
|
if (typeof t == "string") return t;
|
|
6333
6333
|
let n = e.old?.id;
|
|
6334
6334
|
return typeof n == "string" ? n : void 0;
|
|
6335
|
-
},
|
|
6335
|
+
}, wu = (e) => {
|
|
6336
6336
|
let t = {};
|
|
6337
6337
|
if (e.op === "insert") for (let [n, r] of Object.entries(e.new ?? {})) t[n] = {
|
|
6338
6338
|
from: void 0,
|
|
@@ -6352,11 +6352,11 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
6352
6352
|
return {
|
|
6353
6353
|
table: e.table,
|
|
6354
6354
|
op: e.op,
|
|
6355
|
-
id:
|
|
6355
|
+
id: Cu(e),
|
|
6356
6356
|
fields: t
|
|
6357
6357
|
};
|
|
6358
|
-
},
|
|
6359
|
-
let t = e.map(
|
|
6358
|
+
}, Tu = (e) => {
|
|
6359
|
+
let t = e.map(wu);
|
|
6360
6360
|
return {
|
|
6361
6361
|
rows: t,
|
|
6362
6362
|
summary: {
|
|
@@ -6365,21 +6365,21 @@ var q = /* @__PURE__ */ new Map(), Xn = (e, t) => {
|
|
|
6365
6365
|
deletes: t.filter((e) => e.op === "delete").length
|
|
6366
6366
|
}
|
|
6367
6367
|
};
|
|
6368
|
-
},
|
|
6368
|
+
}, Eu = class extends Error {
|
|
6369
6369
|
constructor() {
|
|
6370
6370
|
super("voltro:preview-rollback"), this.name = "PreviewRollback";
|
|
6371
6371
|
}
|
|
6372
|
-
},
|
|
6372
|
+
}, Du = async (e, t) => {
|
|
6373
6373
|
let n, r = !1;
|
|
6374
6374
|
try {
|
|
6375
6375
|
await e.transactional(async (e) => {
|
|
6376
|
-
throw n = await t(e), r = !0, new
|
|
6376
|
+
throw n = await t(e), r = !0, new Eu();
|
|
6377
6377
|
});
|
|
6378
6378
|
} catch (e) {
|
|
6379
|
-
if (!(e instanceof
|
|
6379
|
+
if (!(e instanceof Eu)) throw e;
|
|
6380
6380
|
}
|
|
6381
6381
|
if (!r) throw Error("preview: handler did not complete");
|
|
6382
6382
|
return n;
|
|
6383
|
-
},
|
|
6383
|
+
}, Ou = "framework-runtime";
|
|
6384
6384
|
//#endregion
|
|
6385
|
-
export { Oi as API_KEYS_TABLE, Fo as AccessDenied,
|
|
6385
|
+
export { Oi as API_KEYS_TABLE, Fo as AccessDenied, Jl as AggregateError, rl as AggregateMaintainer, ql as AggregateNotFound, Yl as AggregateRegistry, Kl as AggregateStale, Nl as AnalyticsCapabilityNotSupported, Ml as AnalyticsError, Pl as AnalyticsSink, X as CONNECTIONS_TABLE, Na as CONNECTION_GRANTS_TABLE, Es as CircuitBreaker, ws as CircuitOpen, no as ConnectionNotConnected, Lr as DEFAULT_MAX_RPC_BODY_BYTES, eo as DEFAULT_REFRESH_SKEW_MS, On as DEFAULT_ROW_FILTER_RETRY, gs as DeleteBuilder, zn as Dispatcher, Wi as EffectStore, ho as GRANT_TTL_MS, Ut as InMemoryDataStore, jt as IndexedMatcher, wt as LinearScanMatcher, Ge as MetricBoundaries, Ll as NOOP_ANALYTICS_PROVIDER, Mn as NO_ROW_FILTER, ls as NoRowFound, va as OUTBOX_ATTEMPTS_TABLE, Ta as OUTBOX_ATTEMPT_LOG_CAP, Y as OUTBOX_TABLE, us as OptimisticLockError, Po as REBAC_ADMIN_SCOPE, to as REFRESH_LEASE_MS, Ou as RUNTIME_NAME, pl as ReactionRateLimiter, vr as ReplicatedDataStore, Dn as RowFilterUnavailable, ms as SelectBuilder, Hi as StoreOperationFailed, Pt as SubscriptionRegistry, Ui as TableValidationFailed, Vi as TenantScopeViolation, Uc as TimelineRecorder, Sc as UndoBoundaryError, wc as UndoStack, hs as UpdateBuilder, ns as VOLTRO_AUDIT_MIXIN_ID, rs as VOLTRO_SOFT_DELETE_MIXIN_ID, is as VOLTRO_TENANT_MIXIN_ID, $n as _connectionStreamCount, er as _resetConnectionSubjectsForTest, Fa as _voltroConnectionGrantsTable, Ma as _voltroConnectionsTable, il as _voltroRebacTuplesTable, dc as _voltroScheduleClaimsTable, uc as _voltroScheduleRunsTable, fc as _voltroTracesTable, pc as _voltroUndoLogTable, hl as _voltroWakeupsTable, pa as _voltroWorkflowEventDeliveriesTable, fa as _voltroWorkflowEventsTable, Bi as apiKeyManagementRoutes, bs as applyDefined, tl as applyDelta, Ec as applyInverse, Dc as applyInverses, In as applyRowFilter, Ln as applyRowFilterToDescriptor, Ql as applySoftDeleteScope, Zl as applyTenantScope, Fc as applyUndoInvocation, Go as assertCan, za as assertConnectionCipherConfigured, Ul as attachAnalyticsMirror, zr as awaitServerListening, wa as backoffMs, yo as beginOAuthConnect, Kn as bindConnectionSubject, Ir as bindMutation, Or as bindStream, Dr as bindSubscription, Tr as bindSubscriptionUntyped, $c as buildIvmState, Tu as buildPreview, sl as buildRebacInterceptor, ll as buildRebacReadFilter, fr as buildSubjectKey, Wr as buildTracingLayer, ai as cachedBackend, Wo as can, Ws as cancelWakeup, Yc as classifyShape, oo as clearConnectionRefreshFlights, Bo as clearResourcePolicies, i as clearRetentions, ks as clearSystemStoreHandle, zs as compileCron, bo as completeOAuthConnect, Bl as composeAnalytics, zl as composeAnalyticsSinks, go as connectionCallbackPath, Ra as connectionLabel, tr as connectionSubjectsSnapshot, Ol as countRunningWorkflows, xn as counter, _r as currentRoutingContext, cr as currentTraceContext, Li as dataStoreApiKeyStore, bi as dataStoreIdempotencyStore, Ti as dataStoreKvStore, hi as decryptField, Wl as defineAggregate, La as defineConnection, sa as defineEventTrigger, xa as defineOutboxHandler, ul as defineReaction, Lo as defineResourcePolicy, Rs as defineSchedule, jl as defineSubscriber, ci as deriveKey, wu as diffChange, ka as drainOutbox, Zs as dueWakeups, Uo as effectiveRelations, cs as emptySchemaRegistry, q as encryptField, $r as envSecretsBackend, Qa as exchangeAuthorizationCode, ar as externalSpanFromTraceparent, Gt as extractDbCause, Nt as fingerprintFor, Ja as forgetCredential, rr as formatTraceparent, Tc as forwardChangeFromCdc, Ri as frameworkApiKeyStrategy, Sn as gauge, Ai as generateApiKeyToken, wo as getConnectionResolver, qn as getConnectionSubject, pi as getFieldCipher, Ro as getResourcePolicy, jn as getRowFilter, As as getSystemStoreHandle, Gc as getTimelineRecorder, Zo as getTupleSource, $ as groupKeyOf, Cn as histogramMetric, Su as historyProvenance, oi as httpSecretsBackend, xt as inspectWorkflow, Qo as installPolicyGuardResolver, Qn as interruptConnectionStreams, bc as invertChange, Gl as isAggregateDefinition, Kt as isForeignKeyViolation, xl as isIdleNow, Nr as isInfraError, Cc as isSafeToApply, Is as isScheduleDefinition, ca as isWorkflowEventTriggerDefinition, Qc as ivmValue, xu as lastWriteProvenance, Ya as listConnectionStates, zo as listResourcePolicies, ee as listRetentions, al as loadResourceTuples, cl as loadSubjectTuples, Ms as localityAwareSelector, gu as makeActionRunner, rc as makeAdvisoryLockCoordinator, li as makeAesCipher, Ni as makeApiKeyService, qt as makeAppAccess, Ei as makeAsyncKv, Qr as makeBufferingSpanProcessor, Ba as makeConnectionRegistry, Eo as makeConnectionResolver, Do as makeConnectionsFacade, lc as makeCoordinatedScheduler, es as makeDataLoader, No as makeDisconnectConnectionExecutor, qi as makeEffectStoreLayer, ma as makeEventsFacade, ui as makeFieldCipher, _s as makeFluentStore, Sl as makeIdleGate, ra as makeLazyWorkflowFacade, Ao as makeListConnectionsExecutor, uu as makeMutationRunner, Ca as makeOutboxFacade, ta as makePostCommitWorkflowFacade, vl as makeProcessAdapter, hu as makeQueryDescriptorProducer, mu as makeQueryReauthorizer, Cl as makeRouterActivity, as as makeSchemaRegistry, jo as makeStartConnectionExecutor, Mo as makeSubmitTokenExecutor, vc as makeUndoCapture, wl as makeWakeGate, Dl as makeWakeProxyServer, ea as makeWorkflowFacade, na as makeWorkflowFacadeWithCallerContext, ia as makeWorkflowHandlers, aa as makeWorkflowLayers, Xi as makeWorkflowRunHandle, Gs as markWakeupFired, el as materializeIvm, Pi as memoryApiKeyStore, Ps as memoryReplicationAdapter, dr as memoryRywPositionStore, Bs as nextFiring, Qs as nextWakeup, bl as nodeProcessSupervisor, Rl as noopAnalytics, Vl as noopAnalyticsSpec, Di as noopKv, Yn as onBindConnectionSubject, ba as outboxAttemptsTable, _a as outboxTable, ir as parseTraceparent, lr as powerOfTwoSelector, Du as previewInRollback, Wa as projectConnectionState, ec as pruneWakeups, Vo as rebacPolicyGraph, _n as recordSample, U as recordSubscriptionActive, yn as recordSubscriptionDelivery, qc as recordTimelineEvent, Bc as redactRow, pr as redisRywPositionStore, Ic as redoUndoInvocation, $a as refreshAccessToken, Zn as registerConnectionStream, ie as registerRetention, Us as registerWakeup, Js as releaseWakeup, ur as replicaHealth, ni as resetSecretsBackend, lo as resolveConnection, To as resolveConnectionForSubject, Ns as resolveCurrentRegion, Jt as resolveDependentTables, vo as resolveRedirectUri, nl as resolveRescan, Nn as resolveRowFilterScope, Pn as resolveRowFilterScopeFor, ri as resolveSecret, ii as resolveSecretSync, si as resolveSecretsBackend, Lc as resolveTimelineMode, oe as retentionTtlMsFromEnv, Hc as reverseEventOverRows, qo as revokedIds, js as runAsSystem, kl as runOrchestratorTick, $l as runProvidedEffect, ml as runReaction, Al as runSingleNodeOrchestrator, _l as runWakeLoop, lu as runWithDeadlockRetry, gr as runWithRoutingContext, sr as runWithTraceContext, _o as sanitizeRedirectTo, cc as scheduleCoordinated, Co as setConnectionResolver, fi as setFieldCipher, An as setRowFilter, ti as setSecretsBackend, Os as setSystemStoreHandle, Kc as setTimelineRecorderForTest, Xo as setTupleSource, ki as sha256Hex, tc as singleCoordinator, Tn as snapshotMetrics, En as snapshotMetricsSync, Rr as startRpcServer, ac as startScheduler, Ka as storeCredential, xo as sweepExpiredGrants, ce as sweepRetention, xc as synthesizeInverse, ts as tracingHttpClientLayer, oa as triggerWorkflow, qs as tryClaimWakeup, Jn as unbindConnectionSubject, mc as undoCaptureEnabled, Nc as undoLogExecutor, Xl as useAggregate, Il as useAnalytics, Ko as visibleRows, gl as wakeDueOnce, nu as withRowFilter, Ji as workflowToRpc, _c as wrapCaptureStore, Cs as wrapStoreWithMixinBehaviour };
|