@voltro/runtime 0.72.0 → 0.74.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 +215 -0
- package/dist/index.d.ts +76 -0
- package/dist/index.js +879 -875
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -6060,31 +6060,35 @@ var Gs = (e, t) => {
|
|
|
6060
6060
|
r(o.fail(np("transactional", "<transaction>")(e)));
|
|
6061
6061
|
});
|
|
6062
6062
|
}))
|
|
6063
|
-
}), sp = (e) => u.succeed($f, op(e)), cp =
|
|
6063
|
+
}), sp = (e) => u.succeed($f, op(e)), cp = (e) => ({
|
|
6064
|
+
conflictColumns: e.conflictColumns,
|
|
6065
|
+
...e.update === void 0 ? {} : { update: e.update },
|
|
6066
|
+
...e.updateValues === void 0 ? {} : { updateValues: e.updateValues }
|
|
6067
|
+
}), lp = (e, t, n) => e.insert(t.tableName, n), up = (e, t, n) => e.insertMany(t.tableName, n), dp = (e, t, n, r) => e.upsert(t.tableName, n, cp(r)), fp = (e, t, n, r) => e.upsertWithOutcome(t.tableName, n, cp(r)), pp = (e, t, n, r) => e.insertIgnoreWithOutcome(t.tableName, n, { conflictColumns: r.conflictColumns }), mp = class extends x.TaggedError()("WorkflowStartNotExecuted", {
|
|
6064
6068
|
workflowName: x.String,
|
|
6065
6069
|
handleId: x.String,
|
|
6066
6070
|
reason: x.Literal("dropped", "skipped", "superseded", "cancelled", "abandoned", "rejected"),
|
|
6067
6071
|
failureId: x.NullOr(x.String),
|
|
6068
6072
|
incumbentExecutionId: x.NullOr(x.String)
|
|
6069
|
-
}) {},
|
|
6073
|
+
}) {}, hp = H({ scope: "voltro:workflow" }), gp = /* @__PURE__ */ new Set(), _p = 1e3, vp = /* @__PURE__ */ new Set([
|
|
6070
6074
|
"succeeded",
|
|
6071
6075
|
"failed",
|
|
6072
6076
|
"cancelled"
|
|
6073
|
-
]),
|
|
6077
|
+
]), yp = async (e, t) => {
|
|
6074
6078
|
try {
|
|
6075
6079
|
return (await e({
|
|
6076
6080
|
idPrefix: t,
|
|
6077
6081
|
limit: 5
|
|
6078
|
-
})).find((e) => e.executionId === t &&
|
|
6082
|
+
})).find((e) => e.executionId === t && vp.has(e.status));
|
|
6079
6083
|
} catch {
|
|
6080
6084
|
return;
|
|
6081
6085
|
}
|
|
6082
|
-
},
|
|
6086
|
+
}, bp = (e, t, n) => ({
|
|
6083
6087
|
id: t,
|
|
6084
6088
|
workflowName: e,
|
|
6085
6089
|
executionId: t,
|
|
6086
6090
|
status: n
|
|
6087
|
-
}),
|
|
6091
|
+
}), xp = (e, t) => t.kind === "queued" ? {
|
|
6088
6092
|
id: t.receiptId,
|
|
6089
6093
|
workflowName: e,
|
|
6090
6094
|
executionId: null,
|
|
@@ -6117,25 +6121,25 @@ var Gs = (e, t) => {
|
|
|
6117
6121
|
retryAfterMs: null,
|
|
6118
6122
|
intentId: null
|
|
6119
6123
|
}
|
|
6120
|
-
},
|
|
6124
|
+
}, Sp = class extends Error {
|
|
6121
6125
|
workflowName;
|
|
6122
6126
|
retryAfterMs;
|
|
6123
6127
|
constructor(e, t) {
|
|
6124
6128
|
super(`workflow '${e}' is over its declared rateLimit; this start was DROPPED and will not run. The window reopens in ${t}ms. Use throttle instead of rateLimit if the excess should be queued rather than discarded.`), this.name = "WorkflowRateLimitedError", this.workflowName = e, this.retryAfterMs = t;
|
|
6125
6129
|
}
|
|
6126
|
-
},
|
|
6130
|
+
}, Cp = class extends Error {
|
|
6127
6131
|
workflowName;
|
|
6128
6132
|
executionId;
|
|
6129
6133
|
constructor(e, t) {
|
|
6130
6134
|
super(`workflow '${e}' holds its singleton key on run '${t}', and this workflow declares mode 'skip'. Nothing new was started. Wait on that run (ctx.workflows.wait('${e}', '${t}')) if its result is what you needed.`), this.name = "WorkflowSingletonHeldError", this.workflowName = e, this.executionId = t;
|
|
6131
6135
|
}
|
|
6132
|
-
},
|
|
6136
|
+
}, wp = { kind: "passthrough" }, Tp = bp, Ep = (t) => {
|
|
6133
6137
|
let n = e.failureOption(t), r = n._tag === "Some" ? n.value : e.squash(t);
|
|
6134
6138
|
return {
|
|
6135
6139
|
tag: r && typeof r == "object" && "_tag" in r ? String(r._tag) : null,
|
|
6136
6140
|
message: r?.message ?? String(r)
|
|
6137
6141
|
};
|
|
6138
|
-
},
|
|
6142
|
+
}, Dp = (t, n, r) => {
|
|
6139
6143
|
if (r === void 0) return {
|
|
6140
6144
|
id: n,
|
|
6141
6145
|
workflowName: t,
|
|
@@ -6161,7 +6165,7 @@ var Gs = (e, t) => {
|
|
|
6161
6165
|
workflowName: t,
|
|
6162
6166
|
executionId: n,
|
|
6163
6167
|
status: e.isInterruptedOnly(i.cause) ? "cancelled" : "failed",
|
|
6164
|
-
error:
|
|
6168
|
+
error: Ep(i.cause)
|
|
6165
6169
|
};
|
|
6166
6170
|
}
|
|
6167
6171
|
return {
|
|
@@ -6170,7 +6174,7 @@ var Gs = (e, t) => {
|
|
|
6170
6174
|
executionId: n,
|
|
6171
6175
|
status: "running"
|
|
6172
6176
|
};
|
|
6173
|
-
},
|
|
6177
|
+
}, Op = (e) => new Promise((t) => setTimeout(t, e)), kp = class extends Error {
|
|
6174
6178
|
workflowName;
|
|
6175
6179
|
missingFields;
|
|
6176
6180
|
detail;
|
|
@@ -6179,7 +6183,7 @@ var Gs = (e, t) => {
|
|
|
6179
6183
|
let r = t.length > 0 ? ` missing required field(s): ${t.join(", ")}.` : "";
|
|
6180
6184
|
super(`Workflow "${e}" was started with an invalid payload.${r} ${n}`), this.workflowName = e, this.missingFields = t, this.detail = n, this.name = "WorkflowPayloadError";
|
|
6181
6185
|
}
|
|
6182
|
-
},
|
|
6186
|
+
}, Ap = (e) => {
|
|
6183
6187
|
let t = e.ast;
|
|
6184
6188
|
if (!Array.isArray(t.propertySignatures)) return {
|
|
6185
6189
|
required: [],
|
|
@@ -6190,10 +6194,10 @@ var Gs = (e, t) => {
|
|
|
6190
6194
|
required: n.filter((e) => !e.isOptional).map((e) => String(e.name)),
|
|
6191
6195
|
optional: n.filter((e) => e.isOptional).map((e) => String(e.name))
|
|
6192
6196
|
};
|
|
6193
|
-
},
|
|
6197
|
+
}, jp = (e) => {
|
|
6194
6198
|
let t = e.ast;
|
|
6195
6199
|
return Array.isArray(t.propertySignatures) ? t.propertySignatures.filter((e) => !e.isOptional && typeof e.name == "string").map((e) => String(e.name)) : [];
|
|
6196
|
-
},
|
|
6200
|
+
}, Mp = (e) => {
|
|
6197
6201
|
let t = new Map(e.workflows.map((e) => [e.definition.name, e.definition])), n = (e) => {
|
|
6198
6202
|
let n = t.get(e);
|
|
6199
6203
|
if (!n) {
|
|
@@ -6204,14 +6208,14 @@ var Gs = (e, t) => {
|
|
|
6204
6208
|
}, r = (e, t, n = e.payloadSchema) => {
|
|
6205
6209
|
let r = x.validateEither(n)(t);
|
|
6206
6210
|
if (r._tag === "Right") return;
|
|
6207
|
-
let i = typeof t == "object" && t ? Object.keys(t) : [], a =
|
|
6208
|
-
throw new
|
|
6211
|
+
let i = typeof t == "object" && t ? Object.keys(t) : [], a = jp(n).filter((e) => !i.includes(e));
|
|
6212
|
+
throw new kp(e.name, a, Cr.formatErrorSync(r.left));
|
|
6209
6213
|
}, i = (t) => e.startPayloadSchema?.(t.name) ?? t.payloadSchema, a = (e, t, a = !1) => {
|
|
6210
6214
|
let o = n(e);
|
|
6211
6215
|
return r(o, t, a ? o.payloadSchema : i(o)), o;
|
|
6212
6216
|
}, o = async (t, r) => {
|
|
6213
6217
|
let i = n(t);
|
|
6214
|
-
return
|
|
6218
|
+
return Dp(t, r, await e.runEffect(i.poll(r)));
|
|
6215
6219
|
}, s = async () => e.runEffect(Vr()), l = async (t, n, r) => {
|
|
6216
6220
|
if (e.resolveQueuedStart === void 0) throw Error(`Workflow '${t}' remains queued under receipt '${n}'; no receipt resolver is configured`);
|
|
6217
6221
|
let i = await e.resolveQueuedStart({
|
|
@@ -6225,7 +6229,7 @@ var Gs = (e, t) => {
|
|
|
6225
6229
|
return i.executionId;
|
|
6226
6230
|
}
|
|
6227
6231
|
let a = i.kind === "terminal" ? i.outcome : void 0;
|
|
6228
|
-
throw new
|
|
6232
|
+
throw new mp({
|
|
6229
6233
|
workflowName: t,
|
|
6230
6234
|
handleId: n,
|
|
6231
6235
|
reason: a?.kind ?? "rejected",
|
|
@@ -6240,11 +6244,11 @@ var Gs = (e, t) => {
|
|
|
6240
6244
|
if (!("exit" in t) || !c.isExit(t.exit)) throw Error("Completed workflow observation has no valid Exit");
|
|
6241
6245
|
return e.runEffect(t.exit);
|
|
6242
6246
|
}
|
|
6243
|
-
await
|
|
6247
|
+
await Op(500);
|
|
6244
6248
|
}
|
|
6245
6249
|
}, d = async (e, t, n) => {
|
|
6246
6250
|
let r;
|
|
6247
|
-
for (; r === void 0;) r = await l(e, t, n), r === void 0 && await
|
|
6251
|
+
for (; r === void 0;) r = await l(e, t, n), r === void 0 && await Op(500);
|
|
6248
6252
|
return {
|
|
6249
6253
|
executionId: r,
|
|
6250
6254
|
value: await u(e, r)
|
|
@@ -6268,7 +6272,7 @@ var Gs = (e, t) => {
|
|
|
6268
6272
|
}
|
|
6269
6273
|
if (c !== void 0) throw Error("Workflow control requestId requires a resident control adapter");
|
|
6270
6274
|
let l = await o(r, i);
|
|
6271
|
-
if (
|
|
6275
|
+
if (vp.has(l.status)) return {
|
|
6272
6276
|
operation: t,
|
|
6273
6277
|
kind: "already-terminal",
|
|
6274
6278
|
requestId: null,
|
|
@@ -6284,7 +6288,7 @@ var Gs = (e, t) => {
|
|
|
6284
6288
|
snapshot: n
|
|
6285
6289
|
};
|
|
6286
6290
|
} catch (e) {
|
|
6287
|
-
return
|
|
6291
|
+
return hp.warn("workflow control outcome is unknown", {
|
|
6288
6292
|
workflowName: r,
|
|
6289
6293
|
executionId: i,
|
|
6290
6294
|
operation: t,
|
|
@@ -6330,9 +6334,9 @@ var Gs = (e, t) => {
|
|
|
6330
6334
|
try {
|
|
6331
6335
|
a = x.encodeUnknownSync(i(s))(n);
|
|
6332
6336
|
} catch {
|
|
6333
|
-
throw new
|
|
6337
|
+
throw new kp(t, [], "payload could not be encoded for the admission queue");
|
|
6334
6338
|
}
|
|
6335
|
-
return
|
|
6339
|
+
return xp(t, {
|
|
6336
6340
|
kind: "queued",
|
|
6337
6341
|
mode: "transaction",
|
|
6338
6342
|
...await r.enqueueStart({
|
|
@@ -6354,7 +6358,7 @@ var Gs = (e, t) => {
|
|
|
6354
6358
|
callerContext: r.callerContext,
|
|
6355
6359
|
at: i
|
|
6356
6360
|
});
|
|
6357
|
-
return r.wait === !0 ?
|
|
6361
|
+
return r.wait === !0 ? bp(t, (await d(t, a.receiptId, r.callerContext)).executionId, "succeeded") : {
|
|
6358
6362
|
id: a.receiptId,
|
|
6359
6363
|
workflowName: t,
|
|
6360
6364
|
executionId: null,
|
|
@@ -6368,21 +6372,21 @@ var Gs = (e, t) => {
|
|
|
6368
6372
|
};
|
|
6369
6373
|
}
|
|
6370
6374
|
}
|
|
6371
|
-
let c = r?.wait === !0, l = e.admitStart === void 0 || r?.admitted === !0 ?
|
|
6375
|
+
let c = r?.wait === !0, l = e.admitStart === void 0 || r?.admitted === !0 ? wp : await e.admitStart({
|
|
6372
6376
|
workflowName: t,
|
|
6373
6377
|
payload: n,
|
|
6374
6378
|
callerContext: r?.callerContext,
|
|
6375
6379
|
waiting: c
|
|
6376
6380
|
});
|
|
6377
|
-
if (l.kind === "queued" || l.kind === "dropped" || l.kind === "skipped") return c && l.kind === "queued" ?
|
|
6381
|
+
if (l.kind === "queued" || l.kind === "dropped" || l.kind === "skipped") return c && l.kind === "queued" ? bp(t, (await d(t, l.receiptId, r?.callerContext)).executionId, "succeeded") : xp(t, l);
|
|
6378
6382
|
if (l.kind === "start") {
|
|
6379
6383
|
let n = await l.accept();
|
|
6380
|
-
return e.onEnqueue?.(), c && await u(t, n),
|
|
6384
|
+
return e.onEnqueue?.(), c && await u(t, n), bp(t, n, c ? "succeeded" : "running");
|
|
6381
6385
|
}
|
|
6382
6386
|
let f = n;
|
|
6383
6387
|
if (e.listRuns !== void 0 && r?.admitted !== !0) {
|
|
6384
|
-
let n = await e.runEffect(s.executionId(f)), r = await
|
|
6385
|
-
if (r !== void 0) return
|
|
6388
|
+
let n = await e.runEffect(s.executionId(f)), r = await yp(e.listRuns, n);
|
|
6389
|
+
if (r !== void 0) return gp.has(n) || (gp.size >= _p && gp.clear(), gp.add(n), hp.warn("workflow start replayed — the idempotency key was already spent, nothing ran", {
|
|
6386
6390
|
workflow: t,
|
|
6387
6391
|
executionId: n,
|
|
6388
6392
|
runId: r.id,
|
|
@@ -6402,9 +6406,9 @@ var Gs = (e, t) => {
|
|
|
6402
6406
|
let p;
|
|
6403
6407
|
(e.rememberStartContext !== void 0 || r?.callerContext !== void 0) && (p = o ?? await e.runEffect(s.executionId(f)), await e.rememberStartContext?.(t, p, r?.callerContext ?? { subject: Zf }));
|
|
6404
6408
|
let m = o ?? (p !== void 0 && Hr(s) ? p : void 0);
|
|
6405
|
-
if (c) return m === void 0 ? await e.runEffect(s.execute(f)) : await e.runEffect(Br(s, f, m, { discard: !1 })), e.onEnqueue?.(),
|
|
6409
|
+
if (c) return m === void 0 ? await e.runEffect(s.execute(f)) : await e.runEffect(Br(s, f, m, { discard: !1 })), e.onEnqueue?.(), bp(t, m ?? await e.runEffect(s.executionId(f)), "succeeded");
|
|
6406
6410
|
let h = await e.runEffect(m === void 0 ? s.execute(f, { discard: !0 }) : Br(s, f, m));
|
|
6407
|
-
return e.onEnqueue?.(),
|
|
6411
|
+
return e.onEnqueue?.(), bp(t, h, "running");
|
|
6408
6412
|
};
|
|
6409
6413
|
return {
|
|
6410
6414
|
start: h,
|
|
@@ -6433,8 +6437,8 @@ var Gs = (e, t) => {
|
|
|
6433
6437
|
waiting: !0
|
|
6434
6438
|
});
|
|
6435
6439
|
if (i.kind === "queued") return (await d(t, i.receiptId, r?.callerContext)).value;
|
|
6436
|
-
if (i.kind === "dropped") throw new
|
|
6437
|
-
if (i.kind === "skipped") throw new
|
|
6440
|
+
if (i.kind === "dropped") throw new Sp(t, i.retryAfterMs);
|
|
6441
|
+
if (i.kind === "skipped") throw new Cp(t, i.executionId);
|
|
6438
6442
|
if (i.kind === "start") {
|
|
6439
6443
|
let n = await i.accept();
|
|
6440
6444
|
return e.onEnqueue?.(), await u(t, n);
|
|
@@ -6454,7 +6458,7 @@ var Gs = (e, t) => {
|
|
|
6454
6458
|
query: async (e, t) => o(e, t),
|
|
6455
6459
|
wait: (async (t, n, r) => {
|
|
6456
6460
|
let i = typeof t == "string" ? t : t.workflowName, a = typeof t == "string" ? n : t.executionId, s = typeof t == "string" ? r : n, c = Date.now(), u = s?.pollIntervalMs ?? 500, d = typeof t == "string" ? void 0 : t;
|
|
6457
|
-
if (d?.status === "dropped" || d?.status === "skipped") throw new
|
|
6461
|
+
if (d?.status === "dropped" || d?.status === "skipped") throw new mp({
|
|
6458
6462
|
workflowName: i,
|
|
6459
6463
|
handleId: d.id,
|
|
6460
6464
|
reason: d.status,
|
|
@@ -6466,14 +6470,14 @@ var Gs = (e, t) => {
|
|
|
6466
6470
|
if (d?.status !== "queued" || e.resolveQueuedStart === void 0) throw Error(`Workflow '${i}' has no execution or configured receipt resolver`);
|
|
6467
6471
|
if (a = await l(i, d.id, s?.callerContext), a === void 0) {
|
|
6468
6472
|
if (s?.timeoutMs !== void 0 && Date.now() - c >= s.timeoutMs) throw Error(`Timed out waiting for workflow '${i}' start receipt '${d.id}'`);
|
|
6469
|
-
await
|
|
6473
|
+
await Op(u);
|
|
6470
6474
|
continue;
|
|
6471
6475
|
}
|
|
6472
6476
|
}
|
|
6473
6477
|
let t = await o(i, a);
|
|
6474
6478
|
if (t.status === "succeeded" || t.status === "failed" || t.status === "cancelled") return t;
|
|
6475
6479
|
if (s?.timeoutMs !== void 0 && Date.now() - c >= s.timeoutMs) throw Error(`Timed out waiting for workflow '${i}' run '${a}'`);
|
|
6476
|
-
await
|
|
6480
|
+
await Op(u);
|
|
6477
6481
|
}
|
|
6478
6482
|
}),
|
|
6479
6483
|
cancel: (e, t, n) => p("cancel", e, t, n),
|
|
@@ -6548,7 +6552,7 @@ var Gs = (e, t) => {
|
|
|
6548
6552
|
return e.redrive(t);
|
|
6549
6553
|
}
|
|
6550
6554
|
};
|
|
6551
|
-
},
|
|
6555
|
+
}, Np = (e, t) => ({
|
|
6552
6556
|
...e,
|
|
6553
6557
|
startsDeferredUntilCommit: !0,
|
|
6554
6558
|
start: async (n, r, i) => {
|
|
@@ -6580,7 +6584,7 @@ var Gs = (e, t) => {
|
|
|
6580
6584
|
readStart: async () => {
|
|
6581
6585
|
throw Error("Observe a start after the mutation transaction commits; its receipt is provisional until then");
|
|
6582
6586
|
}
|
|
6583
|
-
}),
|
|
6587
|
+
}), Pp = (e, t) => ({
|
|
6584
6588
|
...e,
|
|
6585
6589
|
cancelQueued: (n, r) => e.cancelQueued(n, {
|
|
6586
6590
|
...r,
|
|
@@ -6613,7 +6617,7 @@ var Gs = (e, t) => {
|
|
|
6613
6617
|
...r,
|
|
6614
6618
|
callerContext: t
|
|
6615
6619
|
}))
|
|
6616
|
-
}),
|
|
6620
|
+
}), Fp = (e) => {
|
|
6617
6621
|
let t = () => {
|
|
6618
6622
|
let t = e();
|
|
6619
6623
|
if (!t) throw Error("Workflow runtime is not ready yet");
|
|
@@ -6639,11 +6643,11 @@ var Gs = (e, t) => {
|
|
|
6639
6643
|
retry: (e, n) => t().retry(e, n),
|
|
6640
6644
|
redrive: (e) => t().redrive(e)
|
|
6641
6645
|
};
|
|
6642
|
-
},
|
|
6646
|
+
}, Ip = (e, t) => {
|
|
6643
6647
|
let n = {};
|
|
6644
|
-
for (let r of e) n[r.definition.name] = (e) => (t ? o.promise(() => t.start(r.definition.name, e)) : r.definition.execute(e, { discard: !0 }).pipe(o.map((e) =>
|
|
6648
|
+
for (let r of e) n[r.definition.name] = (e) => (t ? o.promise(() => t.start(r.definition.name, e)) : r.definition.execute(e, { discard: !0 }).pipe(o.map((e) => bp(r.definition.name, e, "running")))).pipe(o.withSpan(`workflow.${r.definition.name}`, { attributes: { "framework.kind": "workflow" } }));
|
|
6645
6649
|
return n;
|
|
6646
|
-
},
|
|
6650
|
+
}, Lp = (t, n, r) => t.map((t) => t.definition.toLayer(((i, a) => {
|
|
6647
6651
|
let s = o.suspend(() => {
|
|
6648
6652
|
let e = n.resolveStartContext?.(t.definition.name, a);
|
|
6649
6653
|
return e === void 0 ? o.succeed(void 0) : o.promise(() => Promise.resolve(e));
|
|
@@ -6693,7 +6697,7 @@ var Gs = (e, t) => {
|
|
|
6693
6697
|
}), f = (r?.(t, d, l) ?? d)(i, a), p = u.succeed(on, l.subject);
|
|
6694
6698
|
return o.provide(f, p);
|
|
6695
6699
|
}));
|
|
6696
|
-
}))),
|
|
6700
|
+
}))), Rp = (e) => {
|
|
6697
6701
|
if ("on" in e) {
|
|
6698
6702
|
let { on: t, ...n } = e;
|
|
6699
6703
|
return {
|
|
@@ -6706,10 +6710,10 @@ var Gs = (e, t) => {
|
|
|
6706
6710
|
_tag: "workflowEventTrigger",
|
|
6707
6711
|
...e
|
|
6708
6712
|
};
|
|
6709
|
-
},
|
|
6713
|
+
}, zp = Rp, Bp = (e) => typeof e == "object" && !!e && e._tag === "workflowEventTrigger", Vp = () => {
|
|
6710
6714
|
let e = globalThis.crypto;
|
|
6711
6715
|
return typeof e?.randomUUID == "function" ? e.randomUUID() : `${Date.now().toString(36)}${Math.random().toString(36).slice(2)}`;
|
|
6712
|
-
},
|
|
6716
|
+
}, Hp = (e) => `${e}_${Vp()}`, Up = (e) => e.id ?? `${e.event}->${e.workflow}`, Wp = R("_voltro_workflow_events", {
|
|
6713
6717
|
id: I({ prefix: "wfe" }),
|
|
6714
6718
|
name: z(),
|
|
6715
6719
|
payload: je(),
|
|
@@ -6717,7 +6721,7 @@ var Gs = (e, t) => {
|
|
|
6717
6721
|
subject: je().nullable(),
|
|
6718
6722
|
traceId: z().nullable(),
|
|
6719
6723
|
occurredAt: B().default("now")
|
|
6720
|
-
}).index(["name"]).index(["source"]).index(["occurredAt"]),
|
|
6724
|
+
}).index(["name"]).index(["source"]).index(["occurredAt"]), Gp = R("_voltro_workflow_event_deliveries", {
|
|
6721
6725
|
id: I({ prefix: "wfed" }),
|
|
6722
6726
|
eventId: z(),
|
|
6723
6727
|
eventName: z(),
|
|
@@ -6735,8 +6739,8 @@ var Gs = (e, t) => {
|
|
|
6735
6739
|
errorMessage: z().nullable(),
|
|
6736
6740
|
createdAt: B().default("now"),
|
|
6737
6741
|
completedAt: B().nullable()
|
|
6738
|
-
}).index(["eventId"]).index(["eventName"]).index(["triggerId"]).index(["workflowName"]).index(["status"]),
|
|
6739
|
-
let t = e.makeId ??
|
|
6742
|
+
}).index(["eventId"]).index(["eventName"]).index(["triggerId"]).index(["workflowName"]).index(["status"]), Kp = (e) => {
|
|
6743
|
+
let t = e.makeId ?? Hp, n = /* @__PURE__ */ new Map();
|
|
6740
6744
|
for (let t of e.triggers) {
|
|
6741
6745
|
let e = n.get(t.event);
|
|
6742
6746
|
e ? e.push(t) : n.set(t.event, [t]);
|
|
@@ -6777,7 +6781,7 @@ var Gs = (e, t) => {
|
|
|
6777
6781
|
});
|
|
6778
6782
|
let f = o(n), p = [];
|
|
6779
6783
|
for (let o of f) {
|
|
6780
|
-
let s =
|
|
6784
|
+
let s = Up(o), l = o.workflow, u;
|
|
6781
6785
|
try {
|
|
6782
6786
|
let f = o.idempotencyKey?.(d) ?? `${c}:${s}`;
|
|
6783
6787
|
if (o.filter && !await o.filter(d)) {
|
|
@@ -6883,7 +6887,7 @@ var Gs = (e, t) => {
|
|
|
6883
6887
|
triggered: p
|
|
6884
6888
|
};
|
|
6885
6889
|
} };
|
|
6886
|
-
},
|
|
6890
|
+
}, qp = H({ scope: "voltro:events" }), Jp = 64, Yp = 3e5, Xp = 1e4, Zp = class {
|
|
6887
6891
|
routes = /* @__PURE__ */ new Map();
|
|
6888
6892
|
origin;
|
|
6889
6893
|
ringSize;
|
|
@@ -6895,7 +6899,7 @@ var Gs = (e, t) => {
|
|
|
6895
6899
|
interestListeners = /* @__PURE__ */ new Set();
|
|
6896
6900
|
now;
|
|
6897
6901
|
constructor(e) {
|
|
6898
|
-
this.origin = e.origin, this.ringSize = e.ringSize ??
|
|
6902
|
+
this.origin = e.origin, this.ringSize = e.ringSize ?? Jp, this.ringTtlMs = e.ringTtlMs ?? Yp, this.maxRoutes = e.maxRoutes ?? Xp, this.publishRemote = e.publishRemote, this.deliveryOf = e.deliveryOf, this.now = e.now ?? Date.now;
|
|
6899
6903
|
}
|
|
6900
6904
|
get instanceOrigin() {
|
|
6901
6905
|
return this.origin;
|
|
@@ -6915,7 +6919,7 @@ var Gs = (e, t) => {
|
|
|
6915
6919
|
for (let n of this.interestListeners) try {
|
|
6916
6920
|
n(e, t);
|
|
6917
6921
|
} catch (n) {
|
|
6918
|
-
|
|
6922
|
+
qp.warn("event interest listener threw", {
|
|
6919
6923
|
event: e,
|
|
6920
6924
|
active: t,
|
|
6921
6925
|
cause: n
|
|
@@ -6950,7 +6954,7 @@ var Gs = (e, t) => {
|
|
|
6950
6954
|
this.routes.delete(r), n += 1;
|
|
6951
6955
|
}
|
|
6952
6956
|
if (n === 0) {
|
|
6953
|
-
|
|
6957
|
+
qp.warn("event ring capacity reached with all routes live — replay buffers cleared", {
|
|
6954
6958
|
routes: this.routes.size,
|
|
6955
6959
|
maxRoutes: this.maxRoutes
|
|
6956
6960
|
});
|
|
@@ -6975,7 +6979,7 @@ var Gs = (e, t) => {
|
|
|
6975
6979
|
if (n.localNext += 1, this.accept(n, r), La(e.event), this.publishRemote !== void 0) try {
|
|
6976
6980
|
this.publishRemote(r);
|
|
6977
6981
|
} catch (t) {
|
|
6978
|
-
|
|
6982
|
+
qp.warn("event broadcast publish failed — local delivery unaffected", {
|
|
6979
6983
|
event: e.event,
|
|
6980
6984
|
cause: t
|
|
6981
6985
|
});
|
|
@@ -7004,7 +7008,7 @@ var Gs = (e, t) => {
|
|
|
7004
7008
|
for (let n of e.listeners) try {
|
|
7005
7009
|
n(i);
|
|
7006
7010
|
} catch (e) {
|
|
7007
|
-
|
|
7011
|
+
qp.warn("event listener threw — other subscribers unaffected", {
|
|
7008
7012
|
event: t.event,
|
|
7009
7013
|
cause: e
|
|
7010
7014
|
});
|
|
@@ -7088,13 +7092,13 @@ var Gs = (e, t) => {
|
|
|
7088
7092
|
clear() {
|
|
7089
7093
|
this.routes.clear();
|
|
7090
7094
|
}
|
|
7091
|
-
},
|
|
7095
|
+
}, Qp = (e) => e instanceof Error ? e.message : String(e), $p = (e, t, n, r) => o.gen(function* () {
|
|
7092
7096
|
let i = x.encode(t.key), a = x.encode(t.payload), s = yield* i(n).pipe(o.mapError((e) => new Wt({
|
|
7093
7097
|
event: t.name,
|
|
7094
|
-
message:
|
|
7098
|
+
message: Qp(e)
|
|
7095
7099
|
}))), c = yield* a(r).pipe(o.mapError((e) => new Gt({
|
|
7096
7100
|
event: t.name,
|
|
7097
|
-
message:
|
|
7101
|
+
message: Qp(e)
|
|
7098
7102
|
}))), l = Buffer.byteLength(JSON.stringify({
|
|
7099
7103
|
event: t.name,
|
|
7100
7104
|
key: s,
|
|
@@ -7123,10 +7127,10 @@ var Gs = (e, t) => {
|
|
|
7123
7127
|
n: -1,
|
|
7124
7128
|
deferred: !0
|
|
7125
7129
|
});
|
|
7126
|
-
}),
|
|
7130
|
+
}), em = (e) => {
|
|
7127
7131
|
let t;
|
|
7128
7132
|
return Object.assign(e, { then: (n, r) => (t ??= o.runPromise(e), t.then(n, r)) });
|
|
7129
|
-
},
|
|
7133
|
+
}, tm = (e) => ({ publish: (t, n, r) => em($p(e, t, n, r)) }), nm = 64, rm = 1, im = (e) => e.kind === "gap" ? {
|
|
7130
7134
|
_tag: "gap",
|
|
7131
7135
|
missed: e.missed,
|
|
7132
7136
|
reason: e.reason
|
|
@@ -7136,13 +7140,13 @@ var Gs = (e, t) => {
|
|
|
7136
7140
|
n: e.envelope.n,
|
|
7137
7141
|
emittedAt: e.envelope.emittedAt,
|
|
7138
7142
|
payload: e.envelope.payload
|
|
7139
|
-
},
|
|
7143
|
+
}, am = (e) => {
|
|
7140
7144
|
let t = new Map(e ?? []);
|
|
7141
7145
|
return (e, n = 0) => {
|
|
7142
7146
|
let r = t.get(e.origin) ?? 0;
|
|
7143
7147
|
return t.set(e.origin, Math.max(r, e.n)), r === 0 && n === 0 ? 0 : Math.max(0, e.n - r - 1);
|
|
7144
7148
|
};
|
|
7145
|
-
},
|
|
7149
|
+
}, om = (e) => S.unwrapScoped(o.gen(function* () {
|
|
7146
7150
|
let t = yield* on, n = yield* It, r = t.tenantId ?? null, i = e.guards === void 0 ? void 0 : e.guards.filter((e) => !Pn(e));
|
|
7147
7151
|
if (i !== void 0 && i.length > 0) {
|
|
7148
7152
|
let n = yield* Cn(t, i, e.key);
|
|
@@ -7170,13 +7174,13 @@ var Gs = (e, t) => {
|
|
|
7170
7174
|
e();
|
|
7171
7175
|
}));
|
|
7172
7176
|
}
|
|
7173
|
-
let u = a ? () => 0 :
|
|
7177
|
+
let u = a ? () => 0 : am(c), d = i === void 0 || i.length === 0 ? void 0 : () => Cn(t, i, e.key), f = S.fromQueue(s, { shutdown: !0 }).pipe(S.flatMap((e) => d === void 0 ? p(e) : S.unwrap(d().pipe(o.map((t) => t ? S.fail(t) : p(e))))));
|
|
7174
7178
|
function p(t) {
|
|
7175
7179
|
return S.suspend(() => {
|
|
7176
|
-
if (t.kind === "gap") return S.make(
|
|
7180
|
+
if (t.kind === "gap") return S.make(im(t));
|
|
7177
7181
|
let n = u(t.envelope, t.prior);
|
|
7178
7182
|
Ra(e.event);
|
|
7179
|
-
let r =
|
|
7183
|
+
let r = im(t);
|
|
7180
7184
|
if (n === 0) return S.make(r);
|
|
7181
7185
|
za(e.event, "buffer", n);
|
|
7182
7186
|
let i = {
|
|
@@ -7189,7 +7193,7 @@ var Gs = (e, t) => {
|
|
|
7189
7193
|
}
|
|
7190
7194
|
let m = { _tag: "attached" };
|
|
7191
7195
|
return Ql(S.concat(S.fromIterable([m]), f), n.credentialExpiresAt, S.fromIterable([m]));
|
|
7192
|
-
})),
|
|
7196
|
+
})), sm = H({ scope: "voltro:members" }), cm = 5e3, lm = class {
|
|
7193
7197
|
members = /* @__PURE__ */ new Map();
|
|
7194
7198
|
listeners = /* @__PURE__ */ new Set();
|
|
7195
7199
|
instanceId;
|
|
@@ -7201,7 +7205,7 @@ var Gs = (e, t) => {
|
|
|
7201
7205
|
now;
|
|
7202
7206
|
timer;
|
|
7203
7207
|
constructor(e) {
|
|
7204
|
-
this.instanceId = e.instanceId, this.now = e.now ?? Date.now, this.startedAt = e.startedAt ?? this.now(), this.meta = e.meta, this.heartbeatMs = e.heartbeatMs ??
|
|
7208
|
+
this.instanceId = e.instanceId, this.now = e.now ?? Date.now, this.startedAt = e.startedAt ?? this.now(), this.meta = e.meta, this.heartbeatMs = e.heartbeatMs ?? cm, this.downAfterMs = e.downAfterMs ?? this.heartbeatMs * 3, this.announce = e.announce, this.members.set(this.instanceId, {
|
|
7205
7209
|
startedAt: this.startedAt,
|
|
7206
7210
|
meta: this.meta,
|
|
7207
7211
|
lastHeardAt: this.now()
|
|
@@ -7227,7 +7231,7 @@ var Gs = (e, t) => {
|
|
|
7227
7231
|
...this.meta === void 0 ? {} : { meta: this.meta }
|
|
7228
7232
|
});
|
|
7229
7233
|
} catch (e) {
|
|
7230
|
-
|
|
7234
|
+
sm.warn("membership: announce failed", { cause: e });
|
|
7231
7235
|
}
|
|
7232
7236
|
}
|
|
7233
7237
|
receive(e) {
|
|
@@ -7281,16 +7285,16 @@ var Gs = (e, t) => {
|
|
|
7281
7285
|
for (let t of this.listeners) try {
|
|
7282
7286
|
t(e);
|
|
7283
7287
|
} catch (t) {
|
|
7284
|
-
|
|
7288
|
+
sm.warn("membership: listener threw", {
|
|
7285
7289
|
event: e.kind,
|
|
7286
7290
|
cause: t
|
|
7287
7291
|
});
|
|
7288
7292
|
}
|
|
7289
7293
|
}
|
|
7290
|
-
},
|
|
7294
|
+
}, um = H({ scope: "voltro:outbox" }), J = "_voltro_outbox", dm = {
|
|
7291
7295
|
kind: "typeid",
|
|
7292
7296
|
prefix: "obx"
|
|
7293
|
-
},
|
|
7297
|
+
}, fm = R(J, {
|
|
7294
7298
|
id: I({ prefix: "obx" }),
|
|
7295
7299
|
effect: z(),
|
|
7296
7300
|
payload: je(),
|
|
@@ -7311,10 +7315,10 @@ var Gs = (e, t) => {
|
|
|
7311
7315
|
resendCount: L(),
|
|
7312
7316
|
claimedBy: z().nullable(),
|
|
7313
7317
|
claimedAt: B().nullable()
|
|
7314
|
-
}),
|
|
7318
|
+
}), pm = "_voltro_outbox_attempts", mm = {
|
|
7315
7319
|
kind: "typeid",
|
|
7316
7320
|
prefix: "obxa"
|
|
7317
|
-
},
|
|
7321
|
+
}, hm = R(pm, {
|
|
7318
7322
|
id: I({ prefix: "obxa" }),
|
|
7319
7323
|
outboxId: z(),
|
|
7320
7324
|
effect: z(),
|
|
@@ -7335,11 +7339,11 @@ var Gs = (e, t) => {
|
|
|
7335
7339
|
subjectId: z().nullable(),
|
|
7336
7340
|
tenantId: z().nullable(),
|
|
7337
7341
|
traceId: z().nullable()
|
|
7338
|
-
}).index(["outboxId", "attempt"]).index(["startedAt"]).index(["outcome"]),
|
|
7342
|
+
}).index(["outboxId", "attempt"]).index(["startedAt"]).index(["outcome"]), gm = (e) => {
|
|
7339
7343
|
if (e.effect.trim() === "") throw Error("defineOutboxHandler: `effect` must be a non-empty name");
|
|
7340
7344
|
if (e.maxAttempts !== void 0 && e.maxAttempts < 1) throw Error(`defineOutboxHandler("${e.effect}"): maxAttempts must be >= 1`);
|
|
7341
7345
|
return e;
|
|
7342
|
-
},
|
|
7346
|
+
}, _m = 8, vm = (e) => ({
|
|
7343
7347
|
enqueue: async (t, n, r) => {
|
|
7344
7348
|
let i = (e.now ?? (() => /* @__PURE__ */ new Date()))(), a = r?.idempotencyKey;
|
|
7345
7349
|
if (a !== void 0) {
|
|
@@ -7354,12 +7358,12 @@ var Gs = (e, t) => {
|
|
|
7354
7358
|
if (t !== void 0) return t.id;
|
|
7355
7359
|
}
|
|
7356
7360
|
let o = {
|
|
7357
|
-
id: P(
|
|
7361
|
+
id: P(dm, J),
|
|
7358
7362
|
effect: t,
|
|
7359
7363
|
payload: n,
|
|
7360
7364
|
status: "pending",
|
|
7361
7365
|
attempts: 0,
|
|
7362
|
-
maxAttempts: r?.maxAttempts ??
|
|
7366
|
+
maxAttempts: r?.maxAttempts ?? _m,
|
|
7363
7367
|
nextAttemptAt: new Date(i.getTime() + (r?.delayMs ?? 0)),
|
|
7364
7368
|
idempotencyKey: a ?? null,
|
|
7365
7369
|
lastError: null,
|
|
@@ -7410,7 +7414,7 @@ var Gs = (e, t) => {
|
|
|
7410
7414
|
});
|
|
7411
7415
|
} else e.nudge?.();
|
|
7412
7416
|
}
|
|
7413
|
-
}),
|
|
7417
|
+
}), ym = (e) => Math.min(1e3 * 2 ** Math.max(0, e - 1), 3e5), bm = 3e5, xm = 50, Sm = (e, t) => e.length <= t ? e : `${e.slice(0, t)}… [clipped]`, Cm = (e) => {
|
|
7414
7418
|
if (e == null) return null;
|
|
7415
7419
|
let t = typeof e == "object" && !Array.isArray(e) ? e : { value: e }, n;
|
|
7416
7420
|
try {
|
|
@@ -7420,13 +7424,13 @@ var Gs = (e, t) => {
|
|
|
7420
7424
|
}
|
|
7421
7425
|
return n.length > 8192 ? {
|
|
7422
7426
|
truncated: !0,
|
|
7423
|
-
preview:
|
|
7427
|
+
preview: Sm(n, 8192)
|
|
7424
7428
|
} : t;
|
|
7425
|
-
},
|
|
7429
|
+
}, wm = async (e, t, n) => {
|
|
7426
7430
|
let r = t.outboxRow, i = r.id, a = r.resendRequestedBy ?? null;
|
|
7427
7431
|
try {
|
|
7428
|
-
await e.insert(
|
|
7429
|
-
id: P(
|
|
7432
|
+
await e.insert(pm, {
|
|
7433
|
+
id: P(mm, pm),
|
|
7430
7434
|
outboxId: i,
|
|
7431
7435
|
effect: r.effect,
|
|
7432
7436
|
attempt: t.attempt,
|
|
@@ -7437,14 +7441,14 @@ var Gs = (e, t) => {
|
|
|
7437
7441
|
startedAt: t.startedAt,
|
|
7438
7442
|
finishedAt: t.finishedAt,
|
|
7439
7443
|
durationMs: Math.max(0, t.finishedAt.getTime() - t.startedAt.getTime()),
|
|
7440
|
-
error: t.error === null ? null :
|
|
7441
|
-
response:
|
|
7444
|
+
error: t.error === null ? null : Sm(t.error, 4e3),
|
|
7445
|
+
response: Cm(t.response),
|
|
7442
7446
|
subjectId: r.subjectId ?? null,
|
|
7443
7447
|
tenantId: r.tenantId ?? null,
|
|
7444
7448
|
traceId: r.traceId ?? null
|
|
7445
7449
|
});
|
|
7446
7450
|
} catch (e) {
|
|
7447
|
-
|
|
7451
|
+
um.warn("outbox: could not record delivery attempt (delivery itself is unaffected)", {
|
|
7448
7452
|
outboxId: i,
|
|
7449
7453
|
attempt: t.attempt
|
|
7450
7454
|
}, e);
|
|
@@ -7452,7 +7456,7 @@ var Gs = (e, t) => {
|
|
|
7452
7456
|
}
|
|
7453
7457
|
if (!(t.attempt <= n)) try {
|
|
7454
7458
|
let t = await e.query({
|
|
7455
|
-
table:
|
|
7459
|
+
table: pm,
|
|
7456
7460
|
predicate: j("outboxId", i),
|
|
7457
7461
|
order: [{
|
|
7458
7462
|
column: "attempt",
|
|
@@ -7462,11 +7466,11 @@ var Gs = (e, t) => {
|
|
|
7462
7466
|
skip: void 0,
|
|
7463
7467
|
projection: ["id"]
|
|
7464
7468
|
});
|
|
7465
|
-
for (let r of t.slice(0, Math.max(0, t.length - n))) await e.delete(
|
|
7469
|
+
for (let r of t.slice(0, Math.max(0, t.length - n))) await e.delete(pm, r.id);
|
|
7466
7470
|
} catch (e) {
|
|
7467
|
-
|
|
7471
|
+
um.warn("outbox: attempt-log trim failed; the log may exceed its cap", { outboxId: i }, e);
|
|
7468
7472
|
}
|
|
7469
|
-
},
|
|
7473
|
+
}, Tm = async (e, t) => {
|
|
7470
7474
|
try {
|
|
7471
7475
|
await e.store.update(J, t, {
|
|
7472
7476
|
status: "pending",
|
|
@@ -7474,9 +7478,9 @@ var Gs = (e, t) => {
|
|
|
7474
7478
|
claimedAt: null
|
|
7475
7479
|
});
|
|
7476
7480
|
} catch (e) {
|
|
7477
|
-
|
|
7481
|
+
um.warn("outbox: could not release a claim; the lease will reclaim it", { id: t }, e);
|
|
7478
7482
|
}
|
|
7479
|
-
},
|
|
7483
|
+
}, Em = async (e) => {
|
|
7480
7484
|
let t = (e.now ?? (() => /* @__PURE__ */ new Date()))(), n = t.getTime(), r = e.claimLeaseMs ?? 3e5;
|
|
7481
7485
|
try {
|
|
7482
7486
|
let t = await e.store.updateMany(J, {
|
|
@@ -7484,12 +7488,12 @@ var Gs = (e, t) => {
|
|
|
7484
7488
|
claimedBy: null,
|
|
7485
7489
|
claimedAt: null
|
|
7486
7490
|
}, { where: T(j("status", "delivering"), Fe("claimedAt", new Date(n - r))) });
|
|
7487
|
-
t > 0 &&
|
|
7491
|
+
t > 0 && um.warn("outbox: reclaimed rows whose deliverer stopped responding — they will be retried, so a handler that had already reached the remote will be called again", {
|
|
7488
7492
|
reclaimed: t,
|
|
7489
7493
|
leaseMs: r
|
|
7490
7494
|
});
|
|
7491
7495
|
} catch (e) {
|
|
7492
|
-
|
|
7496
|
+
um.warn("outbox: stuck-claim reclaim failed", {}, e);
|
|
7493
7497
|
}
|
|
7494
7498
|
let i = await e.store.query({
|
|
7495
7499
|
table: J,
|
|
@@ -7540,10 +7544,10 @@ var Gs = (e, t) => {
|
|
|
7540
7544
|
for (let n of u) {
|
|
7541
7545
|
let r = n.id, i = n.effect, a = e.handlers.get(i);
|
|
7542
7546
|
if (a === void 0) {
|
|
7543
|
-
m++, await
|
|
7547
|
+
m++, await Tm(e, r);
|
|
7544
7548
|
continue;
|
|
7545
7549
|
}
|
|
7546
|
-
let s = n.attempts + 1, c = n.maxAttempts ??
|
|
7550
|
+
let s = n.attempts + 1, c = n.maxAttempts ?? _m, l = /* @__PURE__ */ new Date(), u = e.attemptLogCap ?? 50;
|
|
7547
7551
|
try {
|
|
7548
7552
|
let t = {
|
|
7549
7553
|
outboxId: r,
|
|
@@ -7554,7 +7558,7 @@ var Gs = (e, t) => {
|
|
|
7554
7558
|
tenantId: n.tenantId ?? null,
|
|
7555
7559
|
traceId: n.traceId ?? null
|
|
7556
7560
|
}, i = a.handler(t), c = o.isEffect(i) ? i : await i, f = o.isEffect(c) ? await (e.runEffect ? e.runEffect(c, t) : o.runPromise(c)) : c;
|
|
7557
|
-
await
|
|
7561
|
+
await wm(e.store, {
|
|
7558
7562
|
outboxRow: n,
|
|
7559
7563
|
attempt: s,
|
|
7560
7564
|
outcome: "delivered",
|
|
@@ -7575,7 +7579,7 @@ var Gs = (e, t) => {
|
|
|
7575
7579
|
}), d++;
|
|
7576
7580
|
} catch (a) {
|
|
7577
7581
|
let o = a instanceof Error ? a.message : String(a), d = s >= c;
|
|
7578
|
-
await
|
|
7582
|
+
await wm(e.store, {
|
|
7579
7583
|
outboxRow: n,
|
|
7580
7584
|
attempt: s,
|
|
7581
7585
|
outcome: d ? "dead" : "failed",
|
|
@@ -7587,23 +7591,23 @@ var Gs = (e, t) => {
|
|
|
7587
7591
|
status: d ? "dead" : "pending",
|
|
7588
7592
|
attempts: s,
|
|
7589
7593
|
lastError: o,
|
|
7590
|
-
nextAttemptAt: new Date(t.getTime() +
|
|
7594
|
+
nextAttemptAt: new Date(t.getTime() + ym(s)),
|
|
7591
7595
|
claimedBy: null,
|
|
7592
7596
|
claimedAt: null,
|
|
7593
7597
|
resendRequestedBy: null,
|
|
7594
7598
|
resendRequestedAt: null,
|
|
7595
7599
|
resendReason: null
|
|
7596
|
-
}), d ? (p++,
|
|
7600
|
+
}), d ? (p++, um.error("outbox effect dead-lettered after exhausting attempts", {
|
|
7597
7601
|
id: r,
|
|
7598
7602
|
effect: i,
|
|
7599
7603
|
attempts: s,
|
|
7600
7604
|
maxAttempts: c
|
|
7601
|
-
}, a)) : (f++,
|
|
7605
|
+
}, a)) : (f++, um.warn("outbox delivery failed; will retry", {
|
|
7602
7606
|
id: r,
|
|
7603
7607
|
effect: i,
|
|
7604
7608
|
attempt: s,
|
|
7605
7609
|
maxAttempts: c,
|
|
7606
|
-
retryInMs:
|
|
7610
|
+
retryInMs: ym(s)
|
|
7607
7611
|
}));
|
|
7608
7612
|
}
|
|
7609
7613
|
}
|
|
@@ -7615,10 +7619,10 @@ var Gs = (e, t) => {
|
|
|
7615
7619
|
scanned: i.length,
|
|
7616
7620
|
...l === void 0 ? {} : { nextAttemptAt: l }
|
|
7617
7621
|
};
|
|
7618
|
-
},
|
|
7622
|
+
}, Dm = H({ scope: "voltro:connections" }), Y = "_voltro_connections", Om = {
|
|
7619
7623
|
kind: "typeid",
|
|
7620
7624
|
prefix: "conn"
|
|
7621
|
-
},
|
|
7625
|
+
}, km = R(Y, {
|
|
7622
7626
|
id: I({ prefix: "conn" }),
|
|
7623
7627
|
connectionId: z(),
|
|
7624
7628
|
subjectId: z(),
|
|
@@ -7641,10 +7645,10 @@ var Gs = (e, t) => {
|
|
|
7641
7645
|
metadata: je().nullable(),
|
|
7642
7646
|
connectedAt: B(),
|
|
7643
7647
|
updatedAt: B()
|
|
7644
|
-
}).unique("byConnectionSubject", ["connectionId", "subjectId"]).index(["subjectId"]),
|
|
7648
|
+
}).unique("byConnectionSubject", ["connectionId", "subjectId"]).index(["subjectId"]), Am = "_voltro_connection_grants", jm = {
|
|
7645
7649
|
kind: "typeid",
|
|
7646
7650
|
prefix: "cgrant"
|
|
7647
|
-
},
|
|
7651
|
+
}, Mm = R(Am, {
|
|
7648
7652
|
id: I({ prefix: "cgrant" }),
|
|
7649
7653
|
state: z().unique(),
|
|
7650
7654
|
connectionId: z(),
|
|
@@ -7654,8 +7658,8 @@ var Gs = (e, t) => {
|
|
|
7654
7658
|
redirectTo: z(),
|
|
7655
7659
|
createdAt: B(),
|
|
7656
7660
|
expiresAt: B()
|
|
7657
|
-
}).index(["expiresAt"]),
|
|
7658
|
-
if (!
|
|
7661
|
+
}).index(["expiresAt"]), Nm = (e) => typeof e == "function" ? e() : e, Pm = /^[a-z][a-z0-9-]*$/, Fm = (e) => {
|
|
7662
|
+
if (!Pm.test(e.id)) throw Error(`defineConnection: id "${e.id}" must be lowercase kebab-case (it becomes a URL path segment).`);
|
|
7659
7663
|
if (e.kind === "oauth2") {
|
|
7660
7664
|
for (let t of ["authorizeUrl", "tokenUrl"]) if (typeof e[t] != "string" || e[t].length === 0) throw Error(`defineConnection("${e.id}"): \`${t}\` is required for kind 'oauth2'.`);
|
|
7661
7665
|
for (let t of ["clientId", "clientSecret"]) {
|
|
@@ -7664,9 +7668,9 @@ var Gs = (e, t) => {
|
|
|
7664
7668
|
}
|
|
7665
7669
|
}
|
|
7666
7670
|
return e;
|
|
7667
|
-
},
|
|
7671
|
+
}, Im = (e) => e.label ?? e.id, Lm = (e) => {
|
|
7668
7672
|
if (e.length !== 0 && Wc() === 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).`);
|
|
7669
|
-
},
|
|
7673
|
+
}, Rm = (e) => {
|
|
7670
7674
|
let t = /* @__PURE__ */ new Map();
|
|
7671
7675
|
for (let n of e) {
|
|
7672
7676
|
if (t.has(n.id)) throw Error(`connections: duplicate connection id "${n.id}" — each *.connection.ts must declare a distinct id.`);
|
|
@@ -7676,14 +7680,14 @@ var Gs = (e, t) => {
|
|
|
7676
7680
|
get: (e) => t.get(e),
|
|
7677
7681
|
list: () => [...t.values()]
|
|
7678
7682
|
};
|
|
7679
|
-
},
|
|
7683
|
+
}, zm = (e) => {
|
|
7680
7684
|
if (e == null) return null;
|
|
7681
7685
|
let t = e instanceof Date ? e : new Date(String(e));
|
|
7682
7686
|
return Number.isNaN(t.getTime()) ? null : t;
|
|
7683
|
-
},
|
|
7687
|
+
}, Bm = (e) => zm(e)?.toISOString() ?? null, Vm = (e) => String(e ?? "").split(" ").filter((e) => e.length > 0), Hm = (e, t) => t === void 0 ? {
|
|
7684
7688
|
connectionId: e.id,
|
|
7685
7689
|
kind: e.kind,
|
|
7686
|
-
label:
|
|
7690
|
+
label: Im(e),
|
|
7687
7691
|
status: "disconnected",
|
|
7688
7692
|
accountId: null,
|
|
7689
7693
|
accountLabel: null,
|
|
@@ -7694,22 +7698,22 @@ var Gs = (e, t) => {
|
|
|
7694
7698
|
} : {
|
|
7695
7699
|
connectionId: e.id,
|
|
7696
7700
|
kind: e.kind,
|
|
7697
|
-
label:
|
|
7701
|
+
label: Im(e),
|
|
7698
7702
|
status: String(t.status ?? "connected"),
|
|
7699
7703
|
accountId: t.accountId ?? null,
|
|
7700
7704
|
accountLabel: t.accountLabel ?? null,
|
|
7701
|
-
scopes:
|
|
7702
|
-
expiresAt:
|
|
7705
|
+
scopes: Vm(t.scopes),
|
|
7706
|
+
expiresAt: Bm(t.expiresAt),
|
|
7703
7707
|
lastError: t.lastError ?? null,
|
|
7704
|
-
connectedAt:
|
|
7705
|
-
},
|
|
7708
|
+
connectedAt: Bm(t.connectedAt)
|
|
7709
|
+
}, Um = async (e, t, n) => (await e.query({
|
|
7706
7710
|
table: Y,
|
|
7707
7711
|
predicate: T(j("connectionId", t), j("subjectId", n)),
|
|
7708
7712
|
order: [],
|
|
7709
7713
|
take: 1,
|
|
7710
7714
|
skip: void 0,
|
|
7711
7715
|
projection: void 0
|
|
7712
|
-
}))[0],
|
|
7716
|
+
}))[0], Wm = async (e) => {
|
|
7713
7717
|
let t = (e.now ?? (() => /* @__PURE__ */ new Date()))(), n = e.tokens.expiresAt === void 0 ? null : new Date(e.tokens.expiresAt), r = await e.store.query({
|
|
7714
7718
|
table: Y,
|
|
7715
7719
|
predicate: T(j("connectionId", e.definition.id), j("subjectId", e.subjectId)),
|
|
@@ -7717,7 +7721,7 @@ var Gs = (e, t) => {
|
|
|
7717
7721
|
take: 1,
|
|
7718
7722
|
skip: void 0,
|
|
7719
7723
|
projection: ["id"]
|
|
7720
|
-
}), i = typeof r[0]?.id == "string" ? r[0].id : P(
|
|
7724
|
+
}), i = typeof r[0]?.id == "string" ? r[0].id : P(Om, Y), a = {
|
|
7721
7725
|
id: i,
|
|
7722
7726
|
connectionId: e.definition.id,
|
|
7723
7727
|
subjectId: e.subjectId,
|
|
@@ -7736,8 +7740,8 @@ var Gs = (e, t) => {
|
|
|
7736
7740
|
connectedAt: t,
|
|
7737
7741
|
updatedAt: t
|
|
7738
7742
|
};
|
|
7739
|
-
return
|
|
7740
|
-
},
|
|
7743
|
+
return Gm(e.store, a);
|
|
7744
|
+
}, Gm = (e, t) => e.upsert(Y, t, {
|
|
7741
7745
|
conflictColumns: ["connectionId", "subjectId"],
|
|
7742
7746
|
update: [
|
|
7743
7747
|
"kind",
|
|
@@ -7753,10 +7757,10 @@ var Gs = (e, t) => {
|
|
|
7753
7757
|
"metadata",
|
|
7754
7758
|
"updatedAt"
|
|
7755
7759
|
]
|
|
7756
|
-
}),
|
|
7757
|
-
let r = await
|
|
7760
|
+
}), Km = async (e, t, n) => {
|
|
7761
|
+
let r = await Um(e, t, n);
|
|
7758
7762
|
return r !== void 0 && e.delete(Y, r.id);
|
|
7759
|
-
},
|
|
7763
|
+
}, qm = async (e, t, n) => {
|
|
7760
7764
|
let r = await e.query({
|
|
7761
7765
|
table: Y,
|
|
7762
7766
|
predicate: j("subjectId", n),
|
|
@@ -7765,9 +7769,9 @@ var Gs = (e, t) => {
|
|
|
7765
7769
|
skip: void 0,
|
|
7766
7770
|
projection: void 0
|
|
7767
7771
|
}), i = new Map(r.map((e) => [String(e.connectionId), e]));
|
|
7768
|
-
return t.list().map((e) =>
|
|
7769
|
-
},
|
|
7770
|
-
let r = e.fetchImpl ??
|
|
7772
|
+
return t.list().map((e) => Hm(e, i.get(e.id)));
|
|
7773
|
+
}, Jm = (e, t) => globalThis.fetch(e, t), Ym = async (e, t, n) => {
|
|
7774
|
+
let r = e.fetchImpl ?? Jm, i, a;
|
|
7771
7775
|
try {
|
|
7772
7776
|
let n = await r(e.tokenUrl, {
|
|
7773
7777
|
method: "POST",
|
|
@@ -7807,62 +7811,62 @@ var Gs = (e, t) => {
|
|
|
7807
7811
|
...Number.isFinite(o.expires_in) ? { expiresAt: n() + o.expires_in * 1e3 } : {},
|
|
7808
7812
|
scopes: (o.scope ?? e.scopes?.join(" ") ?? "").split(" ").filter(Boolean)
|
|
7809
7813
|
};
|
|
7810
|
-
},
|
|
7814
|
+
}, Xm = (e, t, n = Date.now) => Ym(e, {
|
|
7811
7815
|
grant_type: "authorization_code",
|
|
7812
|
-
client_id:
|
|
7813
|
-
client_secret:
|
|
7816
|
+
client_id: Nm(e.clientId),
|
|
7817
|
+
client_secret: Nm(e.clientSecret),
|
|
7814
7818
|
code: t.code,
|
|
7815
7819
|
redirect_uri: t.redirectUri,
|
|
7816
7820
|
...t.codeVerifier ? { code_verifier: t.codeVerifier } : {}
|
|
7817
|
-
}, n),
|
|
7821
|
+
}, n), Zm = (e, t, n = Date.now) => Ym(e, {
|
|
7818
7822
|
grant_type: "refresh_token",
|
|
7819
|
-
client_id:
|
|
7820
|
-
client_secret:
|
|
7823
|
+
client_id: Nm(e.clientId),
|
|
7824
|
+
client_secret: Nm(e.clientSecret),
|
|
7821
7825
|
refresh_token: t
|
|
7822
|
-
}, n),
|
|
7826
|
+
}, n), Qm = 6e4, $m = 3e4, eh = class extends Error {
|
|
7823
7827
|
connectionId;
|
|
7824
7828
|
subjectId;
|
|
7825
7829
|
_tag = "ConnectionNotConnected";
|
|
7826
7830
|
constructor(e, t) {
|
|
7827
7831
|
super(`connection "${e}" is not connected for this subject`), this.connectionId = e, this.subjectId = t, this.name = "ConnectionNotConnected";
|
|
7828
7832
|
}
|
|
7829
|
-
},
|
|
7833
|
+
}, th = (e) => new Promise((t) => {
|
|
7830
7834
|
setTimeout(t, e);
|
|
7831
|
-
}),
|
|
7832
|
-
|
|
7833
|
-
},
|
|
7835
|
+
}), nh = /* @__PURE__ */ new Map(), rh = (e, t) => `${e}\u0000${t}`, ih = () => {
|
|
7836
|
+
nh.clear();
|
|
7837
|
+
}, ah = (e, t) => ({
|
|
7834
7838
|
connectionId: e.id,
|
|
7835
7839
|
kind: e.kind,
|
|
7836
7840
|
accessToken: qc(String(t.accessToken), N(Y, "accessToken", t.id)),
|
|
7837
|
-
expiresAt:
|
|
7838
|
-
scopes:
|
|
7841
|
+
expiresAt: zm(t.expiresAt),
|
|
7842
|
+
scopes: Vm(t.scopes),
|
|
7839
7843
|
accountId: t.accountId ?? null,
|
|
7840
7844
|
accountLabel: t.accountLabel ?? null
|
|
7841
|
-
}),
|
|
7842
|
-
let r =
|
|
7845
|
+
}), oh = (e, t, n) => {
|
|
7846
|
+
let r = zm(e.expiresAt);
|
|
7843
7847
|
return r !== null && r.getTime() - n < t;
|
|
7844
|
-
},
|
|
7845
|
-
let t = e.now ?? Date.now, { store: n, definition: r, subjectId: i } = e, a = await
|
|
7846
|
-
if (a === void 0) throw new
|
|
7847
|
-
if (r.kind === "pat" || !
|
|
7848
|
-
let o =
|
|
7848
|
+
}, sh = async (e) => {
|
|
7849
|
+
let t = e.now ?? Date.now, { store: n, definition: r, subjectId: i } = e, a = await Um(n, r.id, i);
|
|
7850
|
+
if (a === void 0) throw new eh(r.id, i);
|
|
7851
|
+
if (r.kind === "pat" || !oh(a, r.refreshSkewMs ?? 6e4, t())) return ah(r, a);
|
|
7852
|
+
let o = rh(r.id, i), s = nh.get(o);
|
|
7849
7853
|
if (s !== void 0) return s;
|
|
7850
|
-
let c =
|
|
7854
|
+
let c = ch({
|
|
7851
7855
|
...e,
|
|
7852
7856
|
now: t,
|
|
7853
7857
|
row: a
|
|
7854
7858
|
}).finally(() => {
|
|
7855
|
-
|
|
7859
|
+
nh.delete(o);
|
|
7856
7860
|
});
|
|
7857
|
-
return
|
|
7858
|
-
},
|
|
7859
|
-
let { store: t, subjectId: n, now: r } = e, i = e.definition, a = e.sleep ??
|
|
7861
|
+
return nh.set(o, c), c;
|
|
7862
|
+
}, ch = async (e) => {
|
|
7863
|
+
let { store: t, subjectId: n, now: r } = e, i = e.definition, a = e.sleep ?? th, o = i.refreshSkewMs ?? 6e4, s = e.row.id;
|
|
7860
7864
|
if (await t.updateMany("_voltro_connections", { refreshLockedUntil: new Date(r() + 3e4) }, { where: T(j("id", s), Ie("refreshLockedUntil", new Date(r()))) }) === 0) {
|
|
7861
7865
|
for (let e = 0; e < 10; e++) {
|
|
7862
7866
|
await a(200);
|
|
7863
|
-
let e = await
|
|
7864
|
-
if (e === void 0) throw new
|
|
7865
|
-
if (!
|
|
7867
|
+
let e = await Um(t, i.id, n);
|
|
7868
|
+
if (e === void 0) throw new eh(i.id, n);
|
|
7869
|
+
if (!oh(e, o, r())) return ah(i, e);
|
|
7866
7870
|
}
|
|
7867
7871
|
throw new V({
|
|
7868
7872
|
connectionId: i.id,
|
|
@@ -7883,7 +7887,7 @@ var Gs = (e, t) => {
|
|
|
7883
7887
|
});
|
|
7884
7888
|
let l;
|
|
7885
7889
|
try {
|
|
7886
|
-
l = await
|
|
7890
|
+
l = await Zm(i, qc(String(c), N(Y, "refreshToken", s)), r);
|
|
7887
7891
|
} catch (e) {
|
|
7888
7892
|
let n = e instanceof V ? e : new V({
|
|
7889
7893
|
connectionId: i.id,
|
|
@@ -7900,7 +7904,7 @@ var Gs = (e, t) => {
|
|
|
7900
7904
|
refreshToken: null,
|
|
7901
7905
|
expiresAt: null
|
|
7902
7906
|
}
|
|
7903
|
-
}),
|
|
7907
|
+
}), Dm.warn("connection refresh failed", {
|
|
7904
7908
|
connectionId: i.id,
|
|
7905
7909
|
transient: n.transient,
|
|
7906
7910
|
reason: n.reason
|
|
@@ -7916,50 +7920,50 @@ var Gs = (e, t) => {
|
|
|
7916
7920
|
refreshLockedUntil: /* @__PURE__ */ new Date(0),
|
|
7917
7921
|
updatedAt: new Date(r())
|
|
7918
7922
|
};
|
|
7919
|
-
return
|
|
7923
|
+
return ah(i, await t.update(Y, s, u) ?? {
|
|
7920
7924
|
...e.row,
|
|
7921
7925
|
...u
|
|
7922
7926
|
});
|
|
7923
|
-
},
|
|
7927
|
+
}, lh = (e = 32) => {
|
|
7924
7928
|
let t = new Uint8Array(e);
|
|
7925
7929
|
return globalThis.crypto.getRandomValues(t), Array.from(t, (e) => e.toString(16).padStart(2, "0")).join("");
|
|
7926
|
-
},
|
|
7930
|
+
}, uh = (e) => {
|
|
7927
7931
|
let t = "";
|
|
7928
7932
|
for (let n of e) t += String.fromCharCode(n);
|
|
7929
7933
|
return btoa(t).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
7930
|
-
},
|
|
7934
|
+
}, dh = async (e) => {
|
|
7931
7935
|
let t = await globalThis.crypto.subtle.digest("SHA-256", new TextEncoder().encode(e));
|
|
7932
|
-
return
|
|
7933
|
-
},
|
|
7934
|
-
let t = (e.now ?? (() => /* @__PURE__ */ new Date()))(), { definition: n } = e, r =
|
|
7935
|
-
await e.store.insert(
|
|
7936
|
+
return uh(new Uint8Array(t));
|
|
7937
|
+
}, fh = 6e5, ph = (e) => `/_voltro/connections/${e}/callback`, mh = (e) => e === void 0 || e.length === 0 || !e.startsWith("/") || e.startsWith("//") || e.startsWith("/\\") ? "/" : e, hh = (e, t) => e.redirectUri ?? `${t.replace(/\/+$/, "")}${ph(e.id)}`, gh = async (e) => {
|
|
7938
|
+
let t = (e.now ?? (() => /* @__PURE__ */ new Date()))(), { definition: n } = e, r = lh(), i = n.pkce === !1 ? null : lh(48), a = hh(n, e.publicUrl), o = P(jm, Am);
|
|
7939
|
+
await e.store.insert(Am, {
|
|
7936
7940
|
id: o,
|
|
7937
7941
|
state: r,
|
|
7938
7942
|
connectionId: n.id,
|
|
7939
7943
|
subjectId: e.subjectId,
|
|
7940
7944
|
tenantId: e.tenantId,
|
|
7941
|
-
codeVerifier: i === null ? null : Kc(i, N(
|
|
7942
|
-
redirectTo:
|
|
7945
|
+
codeVerifier: i === null ? null : Kc(i, N(Am, "codeVerifier", o)),
|
|
7946
|
+
redirectTo: mh(e.redirectTo),
|
|
7943
7947
|
createdAt: t,
|
|
7944
|
-
expiresAt: new Date(t.getTime() +
|
|
7948
|
+
expiresAt: new Date(t.getTime() + fh)
|
|
7945
7949
|
});
|
|
7946
7950
|
let s = new URLSearchParams({
|
|
7947
7951
|
response_type: "code",
|
|
7948
|
-
client_id:
|
|
7952
|
+
client_id: Nm(n.clientId),
|
|
7949
7953
|
redirect_uri: a,
|
|
7950
7954
|
state: r,
|
|
7951
7955
|
...n.scopes && n.scopes.length > 0 ? { scope: n.scopes.join(" ") } : {},
|
|
7952
7956
|
...n.authorizeParams ?? {}
|
|
7953
7957
|
});
|
|
7954
|
-
i !== null && (s.set("code_challenge", await
|
|
7958
|
+
i !== null && (s.set("code_challenge", await dh(i)), s.set("code_challenge_method", "S256"));
|
|
7955
7959
|
let c = n.authorizeUrl.includes("?") ? "&" : "?";
|
|
7956
7960
|
return {
|
|
7957
7961
|
authorizeUrl: `${n.authorizeUrl}${c}${s.toString()}`,
|
|
7958
7962
|
state: r
|
|
7959
7963
|
};
|
|
7960
|
-
},
|
|
7964
|
+
}, _h = async (e) => {
|
|
7961
7965
|
let t = (e.now ?? (() => /* @__PURE__ */ new Date()))(), n = (await e.store.query({
|
|
7962
|
-
table:
|
|
7966
|
+
table: Am,
|
|
7963
7967
|
predicate: j("state", e.state),
|
|
7964
7968
|
order: [],
|
|
7965
7969
|
take: 1,
|
|
@@ -7971,8 +7975,8 @@ var Gs = (e, t) => {
|
|
|
7971
7975
|
reason: "unknown or already-used handshake state",
|
|
7972
7976
|
transient: !1
|
|
7973
7977
|
});
|
|
7974
|
-
await e.store.delete(
|
|
7975
|
-
let r = String(n.connectionId), i =
|
|
7978
|
+
await e.store.delete(Am, n.id);
|
|
7979
|
+
let r = String(n.connectionId), i = zm(n.expiresAt);
|
|
7976
7980
|
if (i !== null && i.getTime() < t.getTime()) throw new V({
|
|
7977
7981
|
connectionId: r,
|
|
7978
7982
|
reason: "handshake expired — start again",
|
|
@@ -7984,17 +7988,17 @@ var Gs = (e, t) => {
|
|
|
7984
7988
|
reason: "no oauth2 connection is declared under that id",
|
|
7985
7989
|
transient: !1
|
|
7986
7990
|
});
|
|
7987
|
-
let o = n.codeVerifier === null || n.codeVerifier === void 0 ? null : qc(String(n.codeVerifier), N(
|
|
7991
|
+
let o = n.codeVerifier === null || n.codeVerifier === void 0 ? null : qc(String(n.codeVerifier), N(Am, "codeVerifier", n.id)), s = await Xm(a, {
|
|
7988
7992
|
code: e.code,
|
|
7989
|
-
redirectUri:
|
|
7993
|
+
redirectUri: hh(a, e.publicUrl),
|
|
7990
7994
|
codeVerifier: o
|
|
7991
7995
|
}, () => t.getTime()), c = a.identify === void 0 ? void 0 : await a.identify(s).catch((e) => {
|
|
7992
|
-
|
|
7996
|
+
Dm.warn("connection identify failed; storing without account details", {
|
|
7993
7997
|
connectionId: r,
|
|
7994
7998
|
reason: String(e)
|
|
7995
7999
|
});
|
|
7996
8000
|
});
|
|
7997
|
-
return await
|
|
8001
|
+
return await Wm({
|
|
7998
8002
|
store: e.store,
|
|
7999
8003
|
definition: a,
|
|
8000
8004
|
subjectId: String(n.subjectId),
|
|
@@ -8004,11 +8008,11 @@ var Gs = (e, t) => {
|
|
|
8004
8008
|
now: () => t
|
|
8005
8009
|
}), {
|
|
8006
8010
|
connectionId: r,
|
|
8007
|
-
redirectTo:
|
|
8011
|
+
redirectTo: mh(String(n.redirectTo ?? "/"))
|
|
8008
8012
|
};
|
|
8009
|
-
},
|
|
8013
|
+
}, vh = async (e, t = /* @__PURE__ */ new Date()) => {
|
|
8010
8014
|
let n = await e.query({
|
|
8011
|
-
table:
|
|
8015
|
+
table: Am,
|
|
8012
8016
|
predicate: Ie("expiresAt", t),
|
|
8013
8017
|
order: [],
|
|
8014
8018
|
take: void 0,
|
|
@@ -8017,27 +8021,27 @@ var Gs = (e, t) => {
|
|
|
8017
8021
|
}), r = 0;
|
|
8018
8022
|
for (let t of n) await e.delete("_voltro_connection_grants", t.id) && r++;
|
|
8019
8023
|
return r;
|
|
8020
|
-
},
|
|
8021
|
-
|
|
8022
|
-
},
|
|
8023
|
-
let n =
|
|
8024
|
+
}, yh, bh = (e) => {
|
|
8025
|
+
yh = e;
|
|
8026
|
+
}, xh = () => yh, Sh = (e, t) => {
|
|
8027
|
+
let n = yh;
|
|
8024
8028
|
return n === void 0 ? Promise.reject(/* @__PURE__ */ Error(`resolveConnectionForSubject("${t}"): no connection vault is registered — the app declares no \`*.connection.ts\`, or this call ran before boot completed.`)) : n(e, t);
|
|
8025
|
-
},
|
|
8029
|
+
}, Ch = (e) => async (t, n) => {
|
|
8026
8030
|
let r = e.registry.get(n);
|
|
8027
8031
|
if (r === void 0) throw Error(`connection "${n}" is not declared. Declared: ${e.registry.list().map((e) => e.id).join(", ") || "(none)"}.`);
|
|
8028
8032
|
let i = t.id ?? null;
|
|
8029
|
-
if (i === null || i === "") throw new
|
|
8030
|
-
return
|
|
8033
|
+
if (i === null || i === "") throw new eh(n, "<anonymous>");
|
|
8034
|
+
return sh({
|
|
8031
8035
|
store: e.store,
|
|
8032
8036
|
definition: r,
|
|
8033
8037
|
subjectId: i
|
|
8034
8038
|
});
|
|
8035
|
-
},
|
|
8039
|
+
}, wh = (e) => {
|
|
8036
8040
|
let t = e.subject.id ?? null, n = async (n) => {
|
|
8037
8041
|
let r = e.registry.get(n);
|
|
8038
8042
|
if (r === void 0) throw Error(`ctx.connections.get("${n}"): no such connection is declared. Declared: ${e.registry.list().map((e) => e.id).join(", ") || "(none)"}.`);
|
|
8039
|
-
if (t === null || t === "") throw new
|
|
8040
|
-
return
|
|
8043
|
+
if (t === null || t === "") throw new eh(n, "<anonymous>");
|
|
8044
|
+
return sh({
|
|
8041
8045
|
store: e.store,
|
|
8042
8046
|
definition: r,
|
|
8043
8047
|
subjectId: t
|
|
@@ -8049,7 +8053,7 @@ var Gs = (e, t) => {
|
|
|
8049
8053
|
try {
|
|
8050
8054
|
return await n(e);
|
|
8051
8055
|
} catch (e) {
|
|
8052
|
-
if (e instanceof
|
|
8056
|
+
if (e instanceof eh) return null;
|
|
8053
8057
|
throw e;
|
|
8054
8058
|
}
|
|
8055
8059
|
},
|
|
@@ -8064,17 +8068,17 @@ var Gs = (e, t) => {
|
|
|
8064
8068
|
expiresAt: null,
|
|
8065
8069
|
lastError: null,
|
|
8066
8070
|
connectedAt: null
|
|
8067
|
-
})) :
|
|
8071
|
+
})) : qm(e.store, e.registry, t)
|
|
8068
8072
|
};
|
|
8069
|
-
},
|
|
8073
|
+
}, Th = (e, t) => {
|
|
8070
8074
|
let n = e.request?.subject?.id ?? null;
|
|
8071
8075
|
if (n === null || n === "") throw new Bt({ connectionId: t });
|
|
8072
8076
|
return n;
|
|
8073
|
-
},
|
|
8077
|
+
}, Eh = (e, t) => {
|
|
8074
8078
|
let n = e.registry.get(t);
|
|
8075
8079
|
if (n === void 0) throw new zt({ connectionId: t });
|
|
8076
8080
|
return n;
|
|
8077
|
-
},
|
|
8081
|
+
}, Dh = (e) => async (t, n) => {
|
|
8078
8082
|
let r = n.request?.subject?.id ?? null;
|
|
8079
8083
|
return r === null || r === "" ? e.registry.list().map((e) => ({
|
|
8080
8084
|
connectionId: e.id,
|
|
@@ -8087,15 +8091,15 @@ var Gs = (e, t) => {
|
|
|
8087
8091
|
expiresAt: null,
|
|
8088
8092
|
lastError: null,
|
|
8089
8093
|
connectedAt: null
|
|
8090
|
-
})) :
|
|
8091
|
-
},
|
|
8092
|
-
let r =
|
|
8094
|
+
})) : qm(n.store, e.registry, r);
|
|
8095
|
+
}, Oh = (e) => async (t, n) => {
|
|
8096
|
+
let r = Eh(e, t.connectionId), i = Th(n, t.connectionId);
|
|
8093
8097
|
if (r.kind !== "oauth2") throw new Rt({
|
|
8094
8098
|
connectionId: t.connectionId,
|
|
8095
8099
|
expected: "oauth2",
|
|
8096
8100
|
actual: r.kind
|
|
8097
8101
|
});
|
|
8098
|
-
return
|
|
8102
|
+
return gh({
|
|
8099
8103
|
store: n.store,
|
|
8100
8104
|
definition: r,
|
|
8101
8105
|
subjectId: i,
|
|
@@ -8103,8 +8107,8 @@ var Gs = (e, t) => {
|
|
|
8103
8107
|
publicUrl: e.publicUrl,
|
|
8104
8108
|
...t.redirectTo === void 0 ? {} : { redirectTo: t.redirectTo }
|
|
8105
8109
|
});
|
|
8106
|
-
},
|
|
8107
|
-
let r =
|
|
8110
|
+
}, kh = (e) => async (t, n) => {
|
|
8111
|
+
let r = Eh(e, t.connectionId), i = Th(n, t.connectionId);
|
|
8108
8112
|
if (r.kind !== "pat") throw new Rt({
|
|
8109
8113
|
connectionId: t.connectionId,
|
|
8110
8114
|
expected: "pat",
|
|
@@ -8126,7 +8130,7 @@ var Gs = (e, t) => {
|
|
|
8126
8130
|
transient: !1
|
|
8127
8131
|
});
|
|
8128
8132
|
}
|
|
8129
|
-
return await
|
|
8133
|
+
return await Wm({
|
|
8130
8134
|
store: n.store,
|
|
8131
8135
|
definition: r,
|
|
8132
8136
|
subjectId: i,
|
|
@@ -8137,20 +8141,20 @@ var Gs = (e, t) => {
|
|
|
8137
8141
|
},
|
|
8138
8142
|
...o === void 0 ? {} : { account: o }
|
|
8139
8143
|
}), { ok: !0 };
|
|
8140
|
-
},
|
|
8141
|
-
|
|
8142
|
-
let r =
|
|
8143
|
-
return { ok: await
|
|
8144
|
-
},
|
|
8144
|
+
}, Ah = (e) => async (t, n) => {
|
|
8145
|
+
Eh(e, t.connectionId);
|
|
8146
|
+
let r = Th(n, t.connectionId);
|
|
8147
|
+
return { ok: await Km(n.store, t.connectionId, r) };
|
|
8148
|
+
}, jh = "admin:full", Mh = class extends x.TaggedError()("AccessDenied", {
|
|
8145
8149
|
action: x.String,
|
|
8146
8150
|
resourceType: x.String,
|
|
8147
8151
|
resourceId: x.String
|
|
8148
|
-
}) {},
|
|
8152
|
+
}) {}, Nh = /* @__PURE__ */ new Map(), Ph = (e) => {
|
|
8149
8153
|
if (typeof e.resourceType != "string" || e.resourceType.length === 0) throw Error("defineResourcePolicy: a non-empty `resourceType` is required");
|
|
8150
8154
|
if (e.actions === void 0 || Object.keys(e.actions).length === 0) throw Error(`resource policy '${e.resourceType}': at least one action is required`);
|
|
8151
|
-
if (
|
|
8152
|
-
return
|
|
8153
|
-
},
|
|
8155
|
+
if (Nh.has(e.resourceType)) throw Error(`resource policy '${e.resourceType}' is already registered — types must be unique`);
|
|
8156
|
+
return Nh.set(e.resourceType, e), e;
|
|
8157
|
+
}, Fh = (e) => Nh.get(e), Ih = () => [...Nh.values()], Lh = () => Nh.clear(), Rh = () => Ih().map((e) => {
|
|
8154
8158
|
let t = /* @__PURE__ */ new Set();
|
|
8155
8159
|
for (let n of Object.values(e.actions)) for (let e of n) t.add(e);
|
|
8156
8160
|
for (let [n, r] of Object.entries(e.implies ?? {})) {
|
|
@@ -8163,7 +8167,7 @@ var Gs = (e, t) => {
|
|
|
8163
8167
|
relations: [...t],
|
|
8164
8168
|
implies: e.implies ?? {}
|
|
8165
8169
|
};
|
|
8166
|
-
}),
|
|
8170
|
+
}), zh = (e, t) => {
|
|
8167
8171
|
let n = new Set(e);
|
|
8168
8172
|
if (t === void 0) return n;
|
|
8169
8173
|
let r = [...e];
|
|
@@ -8172,39 +8176,39 @@ var Gs = (e, t) => {
|
|
|
8172
8176
|
for (let i of t[e] ?? []) n.has(i) || (n.add(i), r.push(i));
|
|
8173
8177
|
}
|
|
8174
8178
|
return n;
|
|
8175
|
-
},
|
|
8179
|
+
}, Bh = (e, t, n, r) => e.id === null ? /* @__PURE__ */ new Set() : zh(n.filter((n) => n.subjectId === e.id && n.resourceType === t.type && n.resourceId === t.id).map((e) => e.relation), r.implies), Vh = (e, t, n, r) => {
|
|
8176
8180
|
if (e.scopes?.includes("admin:full")) return !0;
|
|
8177
8181
|
if (e.id === null || n.tenantId != null && e.tenantId !== n.tenantId) return !1;
|
|
8178
8182
|
let i = r.policy.actions[t];
|
|
8179
8183
|
if (i === void 0 || i.length === 0) return !1;
|
|
8180
|
-
let a =
|
|
8184
|
+
let a = Bh(e, n, r.tuples, r.policy);
|
|
8181
8185
|
return i.some((e) => a.has(e));
|
|
8182
|
-
},
|
|
8183
|
-
if (!
|
|
8186
|
+
}, Hh = (e, t, n, r) => {
|
|
8187
|
+
if (!Vh(e, t, n, r)) throw new Mh({
|
|
8184
8188
|
action: t,
|
|
8185
8189
|
resourceType: n.type,
|
|
8186
8190
|
resourceId: n.id
|
|
8187
8191
|
});
|
|
8188
|
-
},
|
|
8192
|
+
}, Uh = (e, t, n, r, i) => r.filter((r) => Vh(e, t, {
|
|
8189
8193
|
type: n,
|
|
8190
8194
|
id: r.id,
|
|
8191
8195
|
...r.tenantId === void 0 ? {} : { tenantId: r.tenantId }
|
|
8192
|
-
}, i)),
|
|
8196
|
+
}, i)), Wh = (e, t) => {
|
|
8193
8197
|
let n = new Set(t.map((e) => e.id));
|
|
8194
8198
|
return e.filter((e) => !n.has(e.id)).map((e) => e.id);
|
|
8195
|
-
},
|
|
8196
|
-
|
|
8197
|
-
},
|
|
8198
|
-
|
|
8199
|
-
},
|
|
8199
|
+
}, Gh = new Qn(), Kh = (e) => {
|
|
8200
|
+
Gh.enterWith(e);
|
|
8201
|
+
}, qh = () => Gh.getStore(), Jh = (e, t) => Gh.run(e, t), Yh = H({ scope: "voltro:policy" }), Xh, Zh = (e) => {
|
|
8202
|
+
Xh = e;
|
|
8203
|
+
}, Qh = () => Xh, $h = (e) => Xh === void 0 && (Xh = e, !0), eg = () => {
|
|
8200
8204
|
Un((e) => o.gen(function* () {
|
|
8201
|
-
let t =
|
|
8202
|
-
if (t === void 0) return
|
|
8205
|
+
let t = Fh(e.resourceType);
|
|
8206
|
+
if (t === void 0) return Yh.warn("policy guard denied — no resource policy registered for this type", {
|
|
8203
8207
|
resourceType: e.resourceType,
|
|
8204
8208
|
action: e.action
|
|
8205
8209
|
}), !1;
|
|
8206
|
-
let n =
|
|
8207
|
-
if (n === void 0) return
|
|
8210
|
+
let n = Xh;
|
|
8211
|
+
if (n === void 0) return Yh.warn("policy guard denied — no tuple source registered (call setTupleSource at boot)", {
|
|
8208
8212
|
resourceType: e.resourceType,
|
|
8209
8213
|
action: e.action
|
|
8210
8214
|
}), !1;
|
|
@@ -8214,14 +8218,14 @@ var Gs = (e, t) => {
|
|
|
8214
8218
|
subject: e.subject,
|
|
8215
8219
|
resourceType: e.resourceType,
|
|
8216
8220
|
resourceId: e.resourceId,
|
|
8217
|
-
load:
|
|
8221
|
+
load: qh()
|
|
8218
8222
|
}),
|
|
8219
8223
|
catch: (e) => e
|
|
8220
|
-
}).pipe(o.catchAll((t) => (
|
|
8224
|
+
}).pipe(o.catchAll((t) => (Yh.error("policy guard denied — tuple source failed", {
|
|
8221
8225
|
resourceType: e.resourceType,
|
|
8222
8226
|
resourceId: e.resourceId
|
|
8223
8227
|
}, t), o.succeed([])))), i = e.subject;
|
|
8224
|
-
return
|
|
8228
|
+
return Vh({
|
|
8225
8229
|
id: e.subject.id,
|
|
8226
8230
|
tenantId: i.tenantId ?? null,
|
|
8227
8231
|
...i.scopes === void 0 ? {} : { scopes: i.scopes }
|
|
@@ -8234,10 +8238,10 @@ var Gs = (e, t) => {
|
|
|
8234
8238
|
tuples: r
|
|
8235
8239
|
});
|
|
8236
8240
|
}));
|
|
8237
|
-
},
|
|
8241
|
+
}, tg = (e) => {
|
|
8238
8242
|
Promise.resolve().then(e);
|
|
8239
|
-
},
|
|
8240
|
-
let t = e.schedule ??
|
|
8243
|
+
}, ng = (e) => {
|
|
8244
|
+
let t = e.schedule ?? tg, n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), i = (e, t) => `${e}\u0000${t}`, a = async (t) => {
|
|
8241
8245
|
let a = r.get(t);
|
|
8242
8246
|
if (a === void 0) return;
|
|
8243
8247
|
r.delete(t);
|
|
@@ -8283,23 +8287,23 @@ var Gs = (e, t) => {
|
|
|
8283
8287
|
load: async (e, t) => (await o(e, [t]))[0] ?? null,
|
|
8284
8288
|
loadMany: (e, t) => o(e, t)
|
|
8285
8289
|
};
|
|
8286
|
-
},
|
|
8290
|
+
}, rg = u.effect(ar.HttpClient, o.map(ar.HttpClient, (e) => e.pipe(ar.mapRequestEffect((e) => o.currentSpan.pipe(o.map((t) => e.headers.traceparent === void 0 ? sr.setHeader(e, "traceparent", Ac({
|
|
8287
8291
|
traceId: t.traceId,
|
|
8288
8292
|
spanId: t.spanId,
|
|
8289
8293
|
sampled: t.sampled
|
|
8290
|
-
})) : e), o.catchAll(() => o.succeed(e))))))),
|
|
8294
|
+
})) : e), o.catchAll(() => o.succeed(e))))))), ig = class extends Error {
|
|
8291
8295
|
url;
|
|
8292
8296
|
reason;
|
|
8293
8297
|
_tag = "SsrfBlockedError";
|
|
8294
8298
|
constructor(e, t) {
|
|
8295
8299
|
super(`SSRF: blocked outbound request to ${e} — ${t}. If this target is intentional, add its host to \`http.allowHosts\` in app.config.ts.`), this.url = e, this.reason = t, this.name = "SsrfBlockedError";
|
|
8296
8300
|
}
|
|
8297
|
-
},
|
|
8301
|
+
}, ag = (e, t) => e === 0 || e === 10 || e === 127 || e === 100 && t >= 64 && t <= 127 || e === 169 && t === 254 || e === 172 && t >= 16 && t <= 31 || e === 192 && t === 168 || e === 198 && (t === 18 || t === 19) || e >= 224, og = (e) => e === "::" || e === "::1" || e.startsWith("fc") || e.startsWith("fd") || e.startsWith("fe80") || e.startsWith("::ffff:"), sg = (e, t, n) => n.some((n) => {
|
|
8298
8302
|
let r = n.trim().toLowerCase();
|
|
8299
8303
|
if (r === "") return !1;
|
|
8300
8304
|
let i = t === "" ? e : `${e}:${t}`;
|
|
8301
8305
|
return r === e || r === i ? !0 : r.startsWith("*.") ? e.endsWith(r.slice(1)) : !1;
|
|
8302
|
-
}),
|
|
8306
|
+
}), cg = (e, t = {}) => {
|
|
8303
8307
|
let n;
|
|
8304
8308
|
try {
|
|
8305
8309
|
n = new URL(e);
|
|
@@ -8308,30 +8312,30 @@ var Gs = (e, t) => {
|
|
|
8308
8312
|
}
|
|
8309
8313
|
if (n.protocol !== "http:" && n.protocol !== "https:") return `blocked scheme "${n.protocol}"`;
|
|
8310
8314
|
let r = n.hostname.replace(/^\[|\]$/g, "").toLowerCase();
|
|
8311
|
-
if (
|
|
8315
|
+
if (sg(r, n.port, t.allowHosts ?? [])) return null;
|
|
8312
8316
|
if (r === "localhost" || r.endsWith(".localhost") || r.endsWith(".internal") || r.endsWith(".local")) return `blocked host "${r}"`;
|
|
8313
8317
|
let i = /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/.exec(r);
|
|
8314
8318
|
if (i) {
|
|
8315
8319
|
let e = Number(i[1]), t = Number(i[2]);
|
|
8316
|
-
return e > 255 || t > 255 || Number(i[3]) > 255 || Number(i[4]) > 255 ? "malformed ipv4 literal" :
|
|
8320
|
+
return e > 255 || t > 255 || Number(i[3]) > 255 || Number(i[4]) > 255 ? "malformed ipv4 literal" : ag(e, t) ? `blocked private/reserved address ${r}` : null;
|
|
8317
8321
|
}
|
|
8318
8322
|
if (r.includes(":")) {
|
|
8319
8323
|
let e = /^::ffff:(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$/.exec(r);
|
|
8320
|
-
return e ?
|
|
8324
|
+
return e ? cg(`${n.protocol}//${e[1]}`, t) : og(r) ? `blocked private/reserved address ${r}` : null;
|
|
8321
8325
|
}
|
|
8322
8326
|
return null;
|
|
8323
|
-
},
|
|
8327
|
+
}, lg = (e = {}) => u.effect(ar.HttpClient, o.map(ar.HttpClient, (t) => {
|
|
8324
8328
|
let n = ar.transform(t, (t, n) => o.suspend(() => {
|
|
8325
|
-
let r =
|
|
8329
|
+
let r = cg(n.url, e);
|
|
8326
8330
|
return r === null ? t : o.fail(new or.RequestError({
|
|
8327
8331
|
request: n,
|
|
8328
8332
|
reason: "Transport",
|
|
8329
|
-
cause: new
|
|
8333
|
+
cause: new ig(n.url, r),
|
|
8330
8334
|
description: `SSRF policy: ${r}`
|
|
8331
8335
|
}));
|
|
8332
8336
|
}));
|
|
8333
8337
|
return ar.followRedirects(n, e.maxRedirects ?? 5);
|
|
8334
|
-
})),
|
|
8338
|
+
})), ug = (e) => {
|
|
8335
8339
|
let t = e.now ?? Date.now, n = e.intervalMs ?? 3e4, r = e.maxPending ?? 500, i = /* @__PURE__ */ new Map(), a = !1, o = async () => {
|
|
8336
8340
|
if (i.size === 0) return;
|
|
8337
8341
|
let t = i;
|
|
@@ -8360,7 +8364,7 @@ var Gs = (e, t) => {
|
|
|
8360
8364
|
},
|
|
8361
8365
|
pending: () => i.size
|
|
8362
8366
|
};
|
|
8363
|
-
},
|
|
8367
|
+
}, dg = "voltro/audit", fg = "voltro/softDelete", pg = "voltro/expires", mg = "voltro/tenant", hg = "voltro/localFirst", gg = (e) => {
|
|
8364
8368
|
let t = /* @__PURE__ */ new Map();
|
|
8365
8369
|
for (let n of e) {
|
|
8366
8370
|
let e = /* @__PURE__ */ new Set();
|
|
@@ -8410,19 +8414,19 @@ var Gs = (e, t) => {
|
|
|
8410
8414
|
return !1;
|
|
8411
8415
|
},
|
|
8412
8416
|
idScheme: (e) => t.get(e)?.idScheme,
|
|
8413
|
-
declaredPrimaryKey: (e) => t.get(e)?.declaredPrimaryKey ??
|
|
8414
|
-
defaultFactories: (e) => t.get(e)?.defaultFactories ??
|
|
8415
|
-
computedFields: (e) => t.get(e)?.computedFields ??
|
|
8417
|
+
declaredPrimaryKey: (e) => t.get(e)?.declaredPrimaryKey ?? yg,
|
|
8418
|
+
defaultFactories: (e) => t.get(e)?.defaultFactories ?? _g,
|
|
8419
|
+
computedFields: (e) => t.get(e)?.computedFields ?? vg,
|
|
8416
8420
|
versionColumn: (e) => t.get(e)?.versionColumn,
|
|
8417
|
-
generatedColumns: (e) => t.get(e)?.generatedColumns ??
|
|
8418
|
-
crdtColumns: (e) => t.get(e)?.crdtColumns ??
|
|
8421
|
+
generatedColumns: (e) => t.get(e)?.generatedColumns ?? bg,
|
|
8422
|
+
crdtColumns: (e) => t.get(e)?.crdtColumns ?? xg,
|
|
8419
8423
|
insertSchema: (e) => t.get(e)?.insertSchema,
|
|
8420
8424
|
validatePatchSchema: (e) => t.get(e)?.validatePatchSchema
|
|
8421
8425
|
};
|
|
8422
|
-
},
|
|
8426
|
+
}, _g = /* @__PURE__ */ new Map(), vg = /* @__PURE__ */ new Map(), yg = [], bg = /* @__PURE__ */ new Set(), xg = /* @__PURE__ */ new Set(), Sg = gg([]), Cg = H({ scope: "store.fieldEncryption" }), wg = (e, t) => {
|
|
8423
8427
|
let n = t, r = process.env.VOLTRO_FIELD_DECRYPT_ON_ERROR === "null" ? "null" : "throw", i = /* @__PURE__ */ new Set(), a = (e) => {
|
|
8424
8428
|
let t = `${e.table}.${e.column}`;
|
|
8425
|
-
i.has(t) || (i.add(t),
|
|
8429
|
+
i.has(t) || (i.add(t), Cg.warn("encrypted column degraded to null — could not decrypt with the active key", {
|
|
8426
8430
|
table: e.table,
|
|
8427
8431
|
column: e.column,
|
|
8428
8432
|
reason: e.reason,
|
|
@@ -8447,7 +8451,7 @@ var Gs = (e, t) => {
|
|
|
8447
8451
|
e.injectExternalChange(t);
|
|
8448
8452
|
},
|
|
8449
8453
|
...e.changeScope === void 0 ? {} : { changeScope: e.changeScope },
|
|
8450
|
-
...e.withNamespace === void 0 ? {} : { withNamespace: (n) =>
|
|
8454
|
+
...e.withNamespace === void 0 ? {} : { withNamespace: (n) => wg(e.withNamespace(n), t) },
|
|
8451
8455
|
...e.raw === void 0 ? {} : { raw: ((...t) => e.raw(...t)) },
|
|
8452
8456
|
...e.close === void 0 ? {} : { close: (t) => e.close(t) },
|
|
8453
8457
|
...e.ping === void 0 ? {} : { ping: () => e.ping() },
|
|
@@ -8476,17 +8480,17 @@ var Gs = (e, t) => {
|
|
|
8476
8480
|
};
|
|
8477
8481
|
},
|
|
8478
8482
|
patchJson: async (t, n, r, i, a) => c(t, await e.patchJson(t, n, r, i, o(t, Me(n, r, a), n)), n),
|
|
8479
|
-
transactional: (n) => e.transactional((e) => n(
|
|
8483
|
+
transactional: (n) => e.transactional((e) => n(wg(e, t)))
|
|
8480
8484
|
};
|
|
8481
|
-
},
|
|
8485
|
+
}, Tg = (e, t) => {
|
|
8482
8486
|
if (t === void 0 || t.length === 0) return e;
|
|
8483
8487
|
let n = { ...e };
|
|
8484
8488
|
for (let e of t) delete n[e];
|
|
8485
8489
|
return n;
|
|
8486
|
-
},
|
|
8490
|
+
}, Eg = (e, t) => {
|
|
8487
8491
|
let n = F(e), r = n === void 0 ? [] : tt(n);
|
|
8488
8492
|
return r.length === 0 ? t ?? [] : t === void 0 ? r : [...t, ...r];
|
|
8489
|
-
},
|
|
8493
|
+
}, Dg = (e, t) => {
|
|
8490
8494
|
let n = F(e);
|
|
8491
8495
|
if (n === void 0) return;
|
|
8492
8496
|
let r = tt(n).filter((e) => t[e] !== void 0);
|
|
@@ -8494,14 +8498,14 @@ var Gs = (e, t) => {
|
|
|
8494
8498
|
table: e,
|
|
8495
8499
|
columns: r
|
|
8496
8500
|
});
|
|
8497
|
-
},
|
|
8501
|
+
}, Og = (e, t) => t.length === 0 ? e : e.map((e) => Tg(e, t)), kg = (e, t, n, r, i) => {
|
|
8498
8502
|
let a = {
|
|
8499
8503
|
...t?.(r) ?? {},
|
|
8500
8504
|
...n?.(i) ?? {}
|
|
8501
8505
|
}, o = e;
|
|
8502
8506
|
for (let [e, t] of Object.entries(a)) t !== void 0 && (o = o.where(e, t));
|
|
8503
8507
|
return o;
|
|
8504
|
-
},
|
|
8508
|
+
}, Ag = 1e3, jg = (e, t = Ag) => {
|
|
8505
8509
|
let n = (e) => typeof e == "number" && Number.isFinite(e) ? e : void 0, r = (e) => Math.max(1, Math.min(Math.floor(e), t)), i = n(e.page);
|
|
8506
8510
|
if (i !== void 0) {
|
|
8507
8511
|
let t = r(n(e.pageSize) ?? 100);
|
|
@@ -8514,37 +8518,37 @@ var Gs = (e, t) => {
|
|
|
8514
8518
|
limit: r(n(e.limit) ?? 100),
|
|
8515
8519
|
offset: Math.max(0, Math.floor(n(e.offset) ?? 0))
|
|
8516
8520
|
};
|
|
8517
|
-
},
|
|
8521
|
+
}, Mg = {
|
|
8518
8522
|
list: (e, t = {}) => async (n, r) => {
|
|
8519
8523
|
let i = n ?? {}, a = r.store.select(e);
|
|
8520
8524
|
if (t.columns !== void 0 && t.columns.length > 0) {
|
|
8521
|
-
let n = new Set(
|
|
8525
|
+
let n = new Set(Eg(e, void 0)), r = t.columns.filter((e) => !n.has(e));
|
|
8522
8526
|
r.length > 0 && (a = a.select(...r));
|
|
8523
8527
|
}
|
|
8524
|
-
t.include !== void 0 && (a = a.with(t.include)), a =
|
|
8528
|
+
t.include !== void 0 && (a = a.with(t.include)), a = kg(a, t.filter, t.scope, i, r);
|
|
8525
8529
|
for (let e of t.sort ?? []) a = a.orderBy(e.column, e.direction ?? "asc");
|
|
8526
8530
|
if (t.paginate === !0) {
|
|
8527
|
-
let { limit: e, offset: n } =
|
|
8531
|
+
let { limit: e, offset: n } = jg(i, t.maxPageSize);
|
|
8528
8532
|
a = a.limit(e).offset(n);
|
|
8529
8533
|
}
|
|
8530
|
-
return
|
|
8534
|
+
return Og(await a.all(), Eg(e, t.redact));
|
|
8531
8535
|
},
|
|
8532
8536
|
getById: (e, t = {}) => async (n, r) => {
|
|
8533
8537
|
let i = r.store.select(e).where("id", n.id);
|
|
8534
8538
|
t.include !== void 0 && (i = i.with(t.include));
|
|
8535
8539
|
let a = await i.first();
|
|
8536
|
-
return a === null ? null :
|
|
8540
|
+
return a === null ? null : Tg(a, Eg(e, t.redact));
|
|
8537
8541
|
},
|
|
8538
|
-
create: (e, t = {}) => async (n, r) => (
|
|
8542
|
+
create: (e, t = {}) => async (n, r) => (Dg(e, n), Tg(await r.store.insert(e, n), Eg(e, t.redact))),
|
|
8539
8543
|
update: (e, t = {}) => async (n, r) => {
|
|
8540
8544
|
let { id: i, ...a } = n;
|
|
8541
|
-
|
|
8545
|
+
Dg(e, a);
|
|
8542
8546
|
let o = await r.store.update(e, i, a);
|
|
8543
|
-
return o === null ? null :
|
|
8547
|
+
return o === null ? null : Tg(o, Eg(e, t.redact));
|
|
8544
8548
|
},
|
|
8545
|
-
count: (e, t = {}) => async (n, r) =>
|
|
8549
|
+
count: (e, t = {}) => async (n, r) => kg(r.store.select(e), t.filter, t.scope, n ?? {}, r).count(),
|
|
8546
8550
|
remove: (e) => async (t, n) => ({ deleted: await n.store.delete(e, t.id) })
|
|
8547
|
-
},
|
|
8551
|
+
}, Ng = (e) => {
|
|
8548
8552
|
let t = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set(), r = (e) => {
|
|
8549
8553
|
if (!n.has(e)) switch (n.add(e), e._tag) {
|
|
8550
8554
|
case "TypeLiteral":
|
|
@@ -8568,7 +8572,7 @@ var Gs = (e, t) => {
|
|
|
8568
8572
|
}
|
|
8569
8573
|
};
|
|
8570
8574
|
return r(e.ast), t;
|
|
8571
|
-
},
|
|
8575
|
+
}, Pg = (e) => {
|
|
8572
8576
|
let t = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set(), r = (e) => {
|
|
8573
8577
|
switch (e._tag) {
|
|
8574
8578
|
case "Literal": return e.literal === null;
|
|
@@ -8600,24 +8604,24 @@ var Gs = (e, t) => {
|
|
|
8600
8604
|
}
|
|
8601
8605
|
};
|
|
8602
8606
|
return i(e.ast), t;
|
|
8603
|
-
},
|
|
8607
|
+
}, Fg = (e, t) => {
|
|
8604
8608
|
let n = e.source === void 0 ? [] : Array.isArray(e.source) ? e.source : [e.source];
|
|
8605
8609
|
if (n.length === 0) return [];
|
|
8606
|
-
let r =
|
|
8610
|
+
let r = Ng(e.output), i = Pg(e.output), a = [];
|
|
8607
8611
|
for (let o of n) for (let n of t.get(o) ?? []) r.has(n) && !i.has(n) && a.push({
|
|
8608
8612
|
query: e.name,
|
|
8609
8613
|
table: o,
|
|
8610
8614
|
column: n
|
|
8611
8615
|
});
|
|
8612
8616
|
return a;
|
|
8613
|
-
},
|
|
8617
|
+
}, Ig = (e) => {
|
|
8614
8618
|
if (e.length !== 0) return `A wire-reachable query exposes a server-only column:\n${e.map((e) => ` • query '${e.query}' output declares '${e.column}' — a .serverOnly() column of '${e.table}'`).join("\n")}\nThree ways out, in order of preference:\n 1. Omit the column from the query's output schema. The crud.* read helpers strip these automatically.\n 2. Keep the KEY but type it \`Schema.Null\` — for a view that must stay wire-compatible (an importer that breaks if the key vanishes) while never sending a value. The audit accepts that, because the schema then PROVES no value can flow instead of promising it. Pair it with a \`hasX\` boolean.\n 3. Drop the .serverOnly() marker, if the column may in fact reach a client.\nNote the audit reads the DECLARED shape, not what your handler emits: a field typed \`string\` that you always set to null still fails, and should — the next edit to that handler is one line away from sending it.`;
|
|
8615
|
-
},
|
|
8619
|
+
}, Lg = (e, t) => e.cache?.scope === "global" ? (e.source === void 0 ? [] : Array.isArray(e.source) ? e.source : [e.source]).filter((e) => t.has(e)).map((t) => ({
|
|
8616
8620
|
query: e.name,
|
|
8617
8621
|
table: t
|
|
8618
|
-
})) : [],
|
|
8622
|
+
})) : [], Rg = (e) => {
|
|
8619
8623
|
if (e.length !== 0) return `A cached query shares one entry across tenants:\n${e.map((e) => ` • query '${e.query}' caches scope:'global' while reading '${e.table}', a tenant()-scoped table`).join("\n")}\n\nscope:'global' stores ONE entry for every caller. On a tenant-scoped table the\nrows depend on who asked, so the first caller's rows are served to the next one.\n\nUse scope:'tenant' — one entry per org, none shared across orgs. Use 'subject'\nif the result also depends on WHICH person is asking, and 'global' only for data\nthat depends on neither.`;
|
|
8620
|
-
},
|
|
8624
|
+
}, zg = (e, t) => {
|
|
8621
8625
|
let n, r = 0;
|
|
8622
8626
|
for (let i of t) {
|
|
8623
8627
|
let t = 0;
|
|
@@ -8628,7 +8632,7 @@ var Gs = (e, t) => {
|
|
|
8628
8632
|
o > r && o >= .6 && (r = o, n = i);
|
|
8629
8633
|
}
|
|
8630
8634
|
return n;
|
|
8631
|
-
},
|
|
8635
|
+
}, Bg = (e, t) => {
|
|
8632
8636
|
let n = wn(), r = [];
|
|
8633
8637
|
for (let i of e) for (let e of Wn(i.source)) {
|
|
8634
8638
|
if (In(e)) {
|
|
@@ -8644,12 +8648,12 @@ var Gs = (e, t) => {
|
|
|
8644
8648
|
t.size === 0 || t.has(e) || r.push({
|
|
8645
8649
|
procedure: i.name,
|
|
8646
8650
|
source: e,
|
|
8647
|
-
didYouMean:
|
|
8651
|
+
didYouMean: zg(e, t),
|
|
8648
8652
|
channel: !1
|
|
8649
8653
|
});
|
|
8650
8654
|
}
|
|
8651
8655
|
return r;
|
|
8652
|
-
},
|
|
8656
|
+
}, Vg = (e) => {
|
|
8653
8657
|
if (e.length === 0) return;
|
|
8654
8658
|
let t = e.map((e) => e.channel ? ` ${e.procedure}: source '${e.source}' names a reactivity channel nobody declared` : ` ${e.procedure}: source '${e.source}' matches no declared table` + (e.didYouMean === void 0 ? "" : ` — did you mean '${e.didYouMean}'?`)), n = e.some((e) => e.channel) ? "\nFor the `channel:` entries: declare it with `reactivityChannel(<name>)` and pass the\nCHANNEL as `source:`, not its key as a string. Authoring against the object is what\nmakes a channel source impossible to leave stale — you cannot import a declaration\nthat does not exist." : "";
|
|
8655
8659
|
return `${e.length} reactive source(s) name a table that does not exist:\n${t.join("\n")}\n
|
|
@@ -8658,13 +8662,13 @@ update again, which is indistinguishable from "nothing has changed" — so the
|
|
|
8658
8662
|
symptom is silence, and silence is what this surface exists to eliminate.
|
|
8659
8663
|
A \`source:\` is a STRING, so \`tsc\` cannot see a stale one and a rename leaves it
|
|
8660
8664
|
behind quietly.` + n;
|
|
8661
|
-
},
|
|
8662
|
-
let t =
|
|
8665
|
+
}, Hg = (e) => e.old ?? e.new ?? {}, Ug = (e) => String(Hg(e).id ?? ""), Wg = (e) => {
|
|
8666
|
+
let t = Hg(e).tenantId;
|
|
8663
8667
|
return typeof t == "string" ? t : null;
|
|
8664
|
-
},
|
|
8665
|
-
let n =
|
|
8668
|
+
}, Gg = (e) => e.op === "update" && (e.old?.deletedAt ?? null) === null && (e.new?.deletedAt ?? null) !== null, Kg = (e, t) => {
|
|
8669
|
+
let n = Gg(t);
|
|
8666
8670
|
return t.op !== "delete" && !n ? [] : e.filter((e) => e.targetTable === t.table && e.policy !== "keep" && (n ? e.onSoftDelete : e.onHardDelete !== !1));
|
|
8667
|
-
},
|
|
8671
|
+
}, qg = (e) => {
|
|
8668
8672
|
let t = [], n = [];
|
|
8669
8673
|
for (let r of e) for (let [e, i] of Object.entries(r.fields ?? {})) {
|
|
8670
8674
|
if (i.refOnSoftDelete === void 0 || i.type !== "reference" || i.references === void 0) continue;
|
|
@@ -8693,10 +8697,10 @@ behind quietly.` + n;
|
|
|
8693
8697
|
otherwise the runtime would hard-delete them, and restoring the parent would restore nothing.
|
|
8694
8698
|
Add the mixin, or use { onSoftDelete: 'setNull' } on a nullable column.`);
|
|
8695
8699
|
return t;
|
|
8696
|
-
},
|
|
8697
|
-
let r =
|
|
8700
|
+
}, Jg = async (e, t, n) => {
|
|
8701
|
+
let r = Kg(t, n);
|
|
8698
8702
|
if (r.length === 0) return [];
|
|
8699
|
-
let i =
|
|
8703
|
+
let i = Ug(n), a = Wg(n), o = [];
|
|
8700
8704
|
for (let t of r) {
|
|
8701
8705
|
let n = await e.query({
|
|
8702
8706
|
table: t.table,
|
|
@@ -8720,7 +8724,7 @@ behind quietly.` + n;
|
|
|
8720
8724
|
});
|
|
8721
8725
|
}
|
|
8722
8726
|
return o;
|
|
8723
|
-
},
|
|
8727
|
+
}, Yg = (e, t) => {
|
|
8724
8728
|
let n = [];
|
|
8725
8729
|
for (let r of e) for (let e of r.appliedPluginRefs ?? []) {
|
|
8726
8730
|
let i = e.column, a;
|
|
@@ -8739,9 +8743,9 @@ behind quietly.` + n;
|
|
|
8739
8743
|
});
|
|
8740
8744
|
}
|
|
8741
8745
|
return n.filter((e) => e.policy !== "keep");
|
|
8742
|
-
},
|
|
8743
|
-
|
|
8744
|
-
},
|
|
8746
|
+
}, Xg = H({ scope: "voltro:replica-observations" }), Zg = "_voltro_replica_observations", Qg = (e) => e instanceof Date ? e.getTime() : typeof e == "number" ? e : NaN, $g = /* @__PURE__ */ new Set(), e_ = () => {
|
|
8747
|
+
$g.clear();
|
|
8748
|
+
}, t_ = async (e, t, n) => {
|
|
8745
8749
|
let r = kr(), i = {
|
|
8746
8750
|
replicaId: r.replicaId,
|
|
8747
8751
|
startedAt: new Date(r.startedAt),
|
|
@@ -8751,7 +8755,7 @@ behind quietly.` + n;
|
|
|
8751
8755
|
reachableAt: r.reachable ? r.reachableAt ?? null : null
|
|
8752
8756
|
};
|
|
8753
8757
|
try {
|
|
8754
|
-
await e.upsert(
|
|
8758
|
+
await e.upsert(Zg, {
|
|
8755
8759
|
...i,
|
|
8756
8760
|
writtenAt: /* @__PURE__ */ new Date()
|
|
8757
8761
|
}, { conflictColumns: ["replicaId", "kind"] });
|
|
@@ -8760,12 +8764,12 @@ behind quietly.` + n;
|
|
|
8760
8764
|
kind: t,
|
|
8761
8765
|
error: String(e)
|
|
8762
8766
|
};
|
|
8763
|
-
|
|
8767
|
+
$g.has(t) ? Xg.debug("could not record this replica’s observation", n) : ($g.add(t), Xg.warn("could not record this replica’s observation — fleet views will report this replica as stale for as long as this keeps failing", n));
|
|
8764
8768
|
}
|
|
8765
|
-
},
|
|
8769
|
+
}, n_ = async (e, t, n = Date.now()) => {
|
|
8766
8770
|
try {
|
|
8767
8771
|
return (await e.query({
|
|
8768
|
-
table:
|
|
8772
|
+
table: Zg,
|
|
8769
8773
|
predicate: {
|
|
8770
8774
|
column: "kind",
|
|
8771
8775
|
op: "eq",
|
|
@@ -8776,42 +8780,42 @@ behind quietly.` + n;
|
|
|
8776
8780
|
skip: void 0,
|
|
8777
8781
|
projection: void 0
|
|
8778
8782
|
})).map((e) => {
|
|
8779
|
-
let r =
|
|
8783
|
+
let r = Qg(e.writtenAt);
|
|
8780
8784
|
return {
|
|
8781
8785
|
replicaId: String(e.replicaId ?? ""),
|
|
8782
|
-
startedAt:
|
|
8786
|
+
startedAt: Qg(e.startedAt),
|
|
8783
8787
|
version: e.version === null || e.version === void 0 ? void 0 : String(e.version),
|
|
8784
8788
|
kind: t,
|
|
8785
|
-
payload:
|
|
8789
|
+
payload: i_(e.payload),
|
|
8786
8790
|
reachableAt: e.reachableAt === null || e.reachableAt === void 0 ? void 0 : String(e.reachableAt),
|
|
8787
8791
|
writtenAt: r,
|
|
8788
8792
|
ageMs: Number.isNaN(r) ? NaN : Math.max(0, n - r)
|
|
8789
8793
|
};
|
|
8790
8794
|
});
|
|
8791
8795
|
} catch (e) {
|
|
8792
|
-
throw new
|
|
8796
|
+
throw new r_(String(e));
|
|
8793
8797
|
}
|
|
8794
|
-
},
|
|
8798
|
+
}, r_ = class extends Error {
|
|
8795
8799
|
detail;
|
|
8796
8800
|
_tag = "ObservationsUnavailable";
|
|
8797
8801
|
constructor(e) {
|
|
8798
8802
|
super("the replica-observation table could not be read"), this.detail = e;
|
|
8799
8803
|
}
|
|
8800
|
-
},
|
|
8804
|
+
}, i_ = (e) => {
|
|
8801
8805
|
if (typeof e == "string") try {
|
|
8802
8806
|
return JSON.parse(e);
|
|
8803
8807
|
} catch {
|
|
8804
8808
|
return;
|
|
8805
8809
|
}
|
|
8806
|
-
},
|
|
8810
|
+
}, a_ = async (e, t) => {
|
|
8807
8811
|
try {
|
|
8808
|
-
await e.deleteMany(
|
|
8812
|
+
await e.deleteMany(Zg, { where: {
|
|
8809
8813
|
column: "replicaId",
|
|
8810
8814
|
op: "eq",
|
|
8811
8815
|
value: t
|
|
8812
8816
|
} });
|
|
8813
8817
|
} catch {}
|
|
8814
|
-
},
|
|
8818
|
+
}, o_ = 12e4, s_ = (e, t, n = o_) => {
|
|
8815
8819
|
let r = /* @__PURE__ */ new Map();
|
|
8816
8820
|
for (let t of e) {
|
|
8817
8821
|
if (t.replicaId === "") continue;
|
|
@@ -8846,26 +8850,26 @@ behind quietly.` + n;
|
|
|
8846
8850
|
departed: l,
|
|
8847
8851
|
...m === void 0 ? { versions: void 0 } : { versions: m }
|
|
8848
8852
|
};
|
|
8849
|
-
},
|
|
8853
|
+
}, c_ = class extends x.TaggedError()("CircuitOpen", {
|
|
8850
8854
|
name: x.String,
|
|
8851
8855
|
retryAfterMs: x.Number
|
|
8852
|
-
}) {},
|
|
8856
|
+
}) {}, l_ = {
|
|
8853
8857
|
tag: "closed",
|
|
8854
8858
|
failureCount: 0,
|
|
8855
8859
|
halfOpenSuccesses: 0,
|
|
8856
8860
|
openedAt: 0
|
|
8857
|
-
},
|
|
8858
|
-
let r = n.name ?? "circuit", i = a.toMillis(a.decode(n.resetTimeout)), s = n.halfOpenSuccessThreshold ?? 1, c = n.isFailure ?? (() => !0), l = yield* v.make(
|
|
8861
|
+
}, u_ = { make: (n) => o.gen(function* () {
|
|
8862
|
+
let r = n.name ?? "circuit", i = a.toMillis(a.decode(n.resetTimeout)), s = n.halfOpenSuccessThreshold ?? 1, c = n.isFailure ?? (() => !0), l = yield* v.make(l_), u = o.gen(function* () {
|
|
8859
8863
|
let e = yield* v.get(l);
|
|
8860
8864
|
if (e.tag === "half-open") {
|
|
8861
8865
|
let t = e.halfOpenSuccesses + 1;
|
|
8862
|
-
yield* v.set(l, t >= s ?
|
|
8866
|
+
yield* v.set(l, t >= s ? l_ : {
|
|
8863
8867
|
...e,
|
|
8864
8868
|
halfOpenSuccesses: t
|
|
8865
8869
|
});
|
|
8866
8870
|
return;
|
|
8867
8871
|
}
|
|
8868
|
-
e.failureCount !== 0 && (yield* v.set(l,
|
|
8872
|
+
e.failureCount !== 0 && (yield* v.set(l, l_));
|
|
8869
8873
|
}), d = o.gen(function* () {
|
|
8870
8874
|
let e = yield* t.currentTimeMillis, r = yield* v.get(l);
|
|
8871
8875
|
if (r.tag === "half-open" || r.tag === "open") {
|
|
@@ -8903,7 +8907,7 @@ behind quietly.` + n;
|
|
|
8903
8907
|
if (e.isInterruptedOnly(t)) return o.void;
|
|
8904
8908
|
let n = e.failureOption(t), r = n._tag === "Some" ? n.value : void 0;
|
|
8905
8909
|
return c(r) ? d : o.void;
|
|
8906
|
-
})) : yield* o.fail(new
|
|
8910
|
+
})) : yield* o.fail(new c_({
|
|
8907
8911
|
name: r,
|
|
8908
8912
|
retryAfterMs: n
|
|
8909
8913
|
}));
|
|
@@ -8912,15 +8916,15 @@ behind quietly.` + n;
|
|
|
8912
8916
|
value: v.get(l).pipe(o.map((e) => e.tag)),
|
|
8913
8917
|
enumerable: !0
|
|
8914
8918
|
}), Object.defineProperty(m, "reset", {
|
|
8915
|
-
value: v.set(l,
|
|
8919
|
+
value: v.set(l, l_),
|
|
8916
8920
|
enumerable: !0
|
|
8917
8921
|
}), m;
|
|
8918
|
-
}) },
|
|
8919
|
-
|
|
8920
|
-
},
|
|
8921
|
-
|
|
8922
|
-
},
|
|
8923
|
-
let n = t.scopes === void 0 ? Kn(t.id ?? "system") : Kn(t.id ?? "system", t.scopes), r = t.store ??
|
|
8922
|
+
}) }, d_, f_ = (e) => {
|
|
8923
|
+
d_ = e;
|
|
8924
|
+
}, p_ = () => {
|
|
8925
|
+
d_ = void 0;
|
|
8926
|
+
}, m_ = () => d_, h_ = async (e, t = {}) => {
|
|
8927
|
+
let n = t.scopes === void 0 ? Kn(t.id ?? "system") : Kn(t.id ?? "system", t.scopes), r = t.store ?? d_?.dataStore, i = t.schemaRegistry ?? d_?.schemaRegistry, a = t.dialect ?? d_?.dialect;
|
|
8924
8928
|
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.");
|
|
8925
8929
|
return e({
|
|
8926
8930
|
subject: n,
|
|
@@ -8931,13 +8935,13 @@ behind quietly.` + n;
|
|
|
8931
8935
|
rowFilter: No
|
|
8932
8936
|
})
|
|
8933
8937
|
});
|
|
8934
|
-
},
|
|
8935
|
-
let n =
|
|
8938
|
+
}, g_ = Symbol.for("@voltro/runtime/connectionState"), __ = globalThis, v_ = __[g_] ??= /* @__PURE__ */ new WeakMap(), y_ = (e, t) => {
|
|
8939
|
+
let n = v_.get(e);
|
|
8936
8940
|
if (n === void 0 && !e.signal.aborted) {
|
|
8937
|
-
n = /* @__PURE__ */ new Map(),
|
|
8941
|
+
n = /* @__PURE__ */ new Map(), v_.set(e, n);
|
|
8938
8942
|
let t = n;
|
|
8939
8943
|
e.signal.addEventListener("abort", () => {
|
|
8940
|
-
t.clear(),
|
|
8944
|
+
t.clear(), v_.delete(e);
|
|
8941
8945
|
}, { once: !0 });
|
|
8942
8946
|
}
|
|
8943
8947
|
let r = n, i = (n) => {
|
|
@@ -8961,7 +8965,7 @@ behind quietly.` + n;
|
|
|
8961
8965
|
t.delete(e);
|
|
8962
8966
|
})
|
|
8963
8967
|
};
|
|
8964
|
-
},
|
|
8968
|
+
}, b_ = (e) => u.mergeAll(u.succeed(Pt, Pt.of(({ headers: t, clientId: n }) => o.promise(async () => {
|
|
8965
8969
|
let r = await e.resolveSubject({
|
|
8966
8970
|
headers: Ws(n, t),
|
|
8967
8971
|
clientId: n
|
|
@@ -8976,7 +8980,7 @@ behind quietly.` + n;
|
|
|
8976
8980
|
...o !== void 0 && Number.isSafeInteger(o) ? { resumeFrom: o } : {},
|
|
8977
8981
|
...a !== void 0 && /^[a-zA-Z0-9_-]{1,128}$/.test(a) ? { reconcile: a } : {}
|
|
8978
8982
|
};
|
|
8979
|
-
})))),
|
|
8983
|
+
})))), x_ = (e) => {
|
|
8980
8984
|
let { currentRegion: t, replicaRegions: n, inner: r } = e, i = (e) => {
|
|
8981
8985
|
if (t === void 0) return {
|
|
8982
8986
|
sameRegion: [],
|
|
@@ -9004,7 +9008,7 @@ behind quietly.` + n;
|
|
|
9004
9008
|
return r.loadSnapshot();
|
|
9005
9009
|
}
|
|
9006
9010
|
};
|
|
9007
|
-
},
|
|
9011
|
+
}, S_ = (e = process.env) => {
|
|
9008
9012
|
for (let t of [
|
|
9009
9013
|
"VOLTRO_REGION",
|
|
9010
9014
|
"AWS_REGION",
|
|
@@ -9016,7 +9020,7 @@ behind quietly.` + n;
|
|
|
9016
9020
|
let n = e[t];
|
|
9017
9021
|
if (typeof n == "string" && n.length > 0) return n;
|
|
9018
9022
|
}
|
|
9019
|
-
},
|
|
9023
|
+
}, C_ = () => {
|
|
9020
9024
|
let e = {
|
|
9021
9025
|
primary: 0,
|
|
9022
9026
|
lagByReplica: /* @__PURE__ */ new Map()
|
|
@@ -9041,7 +9045,7 @@ behind quietly.` + n;
|
|
|
9041
9045
|
e.lagByReplica.set(t, n);
|
|
9042
9046
|
}
|
|
9043
9047
|
};
|
|
9044
|
-
},
|
|
9048
|
+
}, w_ = Symbol.for("@voltro/ScheduleDefinition"), T_ = (e) => typeof e == "object" && !!e && w_ in e, E_ = 18e5, D_ = (e) => {
|
|
9045
9049
|
let t = r.parse(e.cron, e.timezone);
|
|
9046
9050
|
if (s.isLeft(t)) throw Error(`defineSchedule("${e.name}"): invalid cron expression "${e.cron}" (tz="${e.timezone}") — ${String(t.left)}`);
|
|
9047
9051
|
if (!e.timezone || e.timezone.trim() === "") throw Error(`defineSchedule("${e.name}"): timezone is required (e.g. "UTC", "Europe/Berlin").\nThe field is non-optional in \`ScheduleDefinition\`, so an ABSENT one is a tsc error and never reaches here. Arriving at this message means the value was present and EMPTY — almost always \`process.env.TZ ?? ''\` or a config lookup that missed. A reporter lost a crashloop to it, so the distinction is worth stating: this is not a check the type could have made for you.`);
|
|
@@ -9053,20 +9057,20 @@ Use a five-field expression, or leave this schedule on trigger: 'self' (the in-a
|
|
|
9053
9057
|
onOverlap: e.onOverlap ?? "skip",
|
|
9054
9058
|
backfill: e.backfill ?? "skip",
|
|
9055
9059
|
maxRuntimeMs: e.maxRuntimeMs ?? 18e5,
|
|
9056
|
-
[
|
|
9060
|
+
[w_]: !0
|
|
9057
9061
|
};
|
|
9058
|
-
},
|
|
9059
|
-
let a =
|
|
9062
|
+
}, O_ = (e) => r.unsafeParse(e.cron, e.timezone), k_ = (e, t = /* @__PURE__ */ new Date()) => r.next(O_(e), t), A_ = (e, t, n, i) => {
|
|
9063
|
+
let a = O_(e), o = [], s = r.next(a, t);
|
|
9060
9064
|
for (; s.getTime() <= n.getTime() && o.length <= i;) o.push(s), s = r.next(a, s);
|
|
9061
9065
|
return o;
|
|
9062
|
-
},
|
|
9066
|
+
}, j_ = (e, t, n) => {
|
|
9063
9067
|
if (t === void 0) return e;
|
|
9064
9068
|
if (t.trim() === "") throw Error("transaction tenantId must be non-empty");
|
|
9065
9069
|
if (t === e.tenantId) return e;
|
|
9066
9070
|
if (n) throw Error("transaction cannot change tenant inside an active transaction");
|
|
9067
9071
|
if (e.type !== "system") throw Error("only a system context can select another transaction tenant");
|
|
9068
9072
|
return qn(e, t);
|
|
9069
|
-
},
|
|
9073
|
+
}, M_ = 5e3, N_ = 3e4, P_ = "_voltro_schedule_backfill_requests", F_ = R(P_, {
|
|
9070
9074
|
id: I({ prefix: "schbackfill" }),
|
|
9071
9075
|
name: z(),
|
|
9072
9076
|
from: B(),
|
|
@@ -9085,34 +9089,34 @@ Use a five-field expression, or leave this schedule on trigger: 'self' (the in-a
|
|
|
9085
9089
|
activeIndex: L().nullable(),
|
|
9086
9090
|
results: je(),
|
|
9087
9091
|
error: z().nullable()
|
|
9088
|
-
}),
|
|
9089
|
-
runId:
|
|
9092
|
+
}), I_ = x.String.pipe(x.minLength(1), x.maxLength(256)), L_ = x.Struct({
|
|
9093
|
+
runId: I_,
|
|
9090
9094
|
status: x.Literal("succeeded", "failed", "skipped", "missed")
|
|
9091
|
-
}),
|
|
9092
|
-
id:
|
|
9093
|
-
name:
|
|
9095
|
+
}), R_ = x.Struct({
|
|
9096
|
+
id: I_,
|
|
9097
|
+
name: I_,
|
|
9094
9098
|
from: x.DateFromSelf,
|
|
9095
9099
|
to: x.DateFromSelf,
|
|
9096
9100
|
occurrences: x.Array(x.Number.pipe(x.finite())),
|
|
9097
9101
|
status: x.Literal("queued", "running", "completed", "interrupted"),
|
|
9098
|
-
owner: x.NullOr(
|
|
9102
|
+
owner: x.NullOr(I_),
|
|
9099
9103
|
createdAt: x.DateFromSelf,
|
|
9100
9104
|
updatedAt: x.DateFromSelf,
|
|
9101
9105
|
cursor: x.Number.pipe(x.int(), x.nonNegative()),
|
|
9102
9106
|
activeIndex: x.NullOr(x.Number.pipe(x.int(), x.nonNegative())),
|
|
9103
|
-
results: x.Array(
|
|
9107
|
+
results: x.Array(L_),
|
|
9104
9108
|
error: x.NullOr(x.String)
|
|
9105
|
-
}),
|
|
9109
|
+
}), z_ = async (e, t) => {
|
|
9106
9110
|
let n = await e.query({
|
|
9107
|
-
table:
|
|
9111
|
+
table: P_,
|
|
9108
9112
|
predicate: j("id", t),
|
|
9109
9113
|
order: [],
|
|
9110
9114
|
take: 1,
|
|
9111
9115
|
skip: void 0,
|
|
9112
9116
|
projection: void 0
|
|
9113
9117
|
});
|
|
9114
|
-
return n[0] === void 0 ? void 0 : x.decodeUnknownSync(
|
|
9115
|
-
},
|
|
9118
|
+
return n[0] === void 0 ? void 0 : x.decodeUnknownSync(R_)(n[0]);
|
|
9119
|
+
}, B_ = async (e, t) => {
|
|
9116
9120
|
let n = t.from.getTime(), r = t.to.getTime();
|
|
9117
9121
|
if (!Number.isFinite(n) || !Number.isFinite(r) || n >= r) throw Error("Invalid backfill range");
|
|
9118
9122
|
if (t.occurrences.length > 1e4) throw Error("Backfill occurrence limit exceeded");
|
|
@@ -9120,7 +9124,7 @@ Use a five-field expression, or leave this schedule on trigger: 'self' (the in-a
|
|
|
9120
9124
|
let t = e.getTime();
|
|
9121
9125
|
if (!Number.isFinite(t) || t <= i || t > r) throw Error("Backfill occurrences must be ordered within (from, to]");
|
|
9122
9126
|
return i = t, t;
|
|
9123
|
-
}), o = x.decodeUnknownSync(
|
|
9127
|
+
}), o = x.decodeUnknownSync(R_)({
|
|
9124
9128
|
...t,
|
|
9125
9129
|
occurrences: a,
|
|
9126
9130
|
status: "queued",
|
|
@@ -9131,19 +9135,19 @@ Use a five-field expression, or leave this schedule on trigger: 'self' (the in-a
|
|
|
9131
9135
|
activeIndex: null,
|
|
9132
9136
|
results: [],
|
|
9133
9137
|
error: null
|
|
9134
|
-
}), s = await e.insertIgnoreWithOutcome(
|
|
9138
|
+
}), s = await e.insertIgnoreWithOutcome(P_, o, { conflictColumns: ["id"] }), c = x.decodeUnknownSync(R_)(s.row);
|
|
9135
9139
|
if (c.name !== o.name || c.from.getTime() !== n || c.to.getTime() !== r) throw new Gr("Backfill request ID already belongs to a different schedule or range");
|
|
9136
9140
|
return {
|
|
9137
9141
|
request: c,
|
|
9138
9142
|
created: s.outcome === "inserted"
|
|
9139
9143
|
};
|
|
9140
|
-
},
|
|
9144
|
+
}, V_ = async (e, t, n) => (x.decodeUnknownSync(I_)(n), e.transactional(async (e) => await e.updateMany(P_, {
|
|
9141
9145
|
status: "running",
|
|
9142
9146
|
owner: n,
|
|
9143
9147
|
updatedAt: /* @__PURE__ */ new Date()
|
|
9144
|
-
}, { where: T(j("id", t), j("status", "queued")) }) === 1)),
|
|
9145
|
-
if (!await
|
|
9146
|
-
let i = await
|
|
9148
|
+
}, { where: T(j("id", t), j("status", "queued")) }) === 1)), H_ = async (e, t, n, r) => {
|
|
9149
|
+
if (!await V_(e, t, n)) return z_(e, t);
|
|
9150
|
+
let i = await z_(e, t);
|
|
9147
9151
|
if (!i) throw Error("Accepted backfill request disappeared");
|
|
9148
9152
|
let a = i, o = () => T(j("id", t), j("status", "running"), j("owner", n)), s, c, l = !1, u, d = () => {
|
|
9149
9153
|
s = setTimeout(() => {
|
|
@@ -9154,7 +9158,7 @@ Use a five-field expression, or leave this schedule on trigger: 'self' (the in-a
|
|
|
9154
9158
|
}, (e) => {
|
|
9155
9159
|
u = e;
|
|
9156
9160
|
});
|
|
9157
|
-
},
|
|
9161
|
+
}, M_), s.unref?.();
|
|
9158
9162
|
};
|
|
9159
9163
|
d();
|
|
9160
9164
|
try {
|
|
@@ -9163,14 +9167,14 @@ Use a five-field expression, or leave this schedule on trigger: 'self' (the in-a
|
|
|
9163
9167
|
if (await e.transactional(async (e) => e.updateMany("_voltro_schedule_backfill_requests", {
|
|
9164
9168
|
activeIndex: n,
|
|
9165
9169
|
updatedAt: /* @__PURE__ */ new Date()
|
|
9166
|
-
}, { where: T(o(), j("cursor", n), De("activeIndex")) })) !== 1) return
|
|
9167
|
-
let i = x.decodeUnknownSync(
|
|
9170
|
+
}, { where: T(o(), j("cursor", n), De("activeIndex")) })) !== 1) return z_(e, t);
|
|
9171
|
+
let i = x.decodeUnknownSync(L_)(await r(new Date(a.occurrences[n]))), s = [...a.results, i];
|
|
9168
9172
|
if (await e.transactional(async (e) => e.updateMany("_voltro_schedule_backfill_requests", {
|
|
9169
9173
|
cursor: n + 1,
|
|
9170
9174
|
activeIndex: null,
|
|
9171
9175
|
results: s,
|
|
9172
9176
|
updatedAt: /* @__PURE__ */ new Date()
|
|
9173
|
-
}, { where: T(o(), j("cursor", n), j("activeIndex", n)) })) !== 1) return
|
|
9177
|
+
}, { where: T(o(), j("cursor", n), j("activeIndex", n)) })) !== 1) return z_(e, t);
|
|
9174
9178
|
a = {
|
|
9175
9179
|
...a,
|
|
9176
9180
|
cursor: n + 1,
|
|
@@ -9178,12 +9182,12 @@ Use a five-field expression, or leave this schedule on trigger: 'self' (the in-a
|
|
|
9178
9182
|
results: s
|
|
9179
9183
|
};
|
|
9180
9184
|
}
|
|
9181
|
-
await e.transactional(async (e) => e.updateMany(
|
|
9185
|
+
await e.transactional(async (e) => e.updateMany(P_, {
|
|
9182
9186
|
status: "completed",
|
|
9183
9187
|
updatedAt: /* @__PURE__ */ new Date()
|
|
9184
9188
|
}, { where: T(o(), j("cursor", a.occurrences.length), De("activeIndex")) }));
|
|
9185
9189
|
} catch (t) {
|
|
9186
|
-
await e.transactional(async (e) => e.updateMany(
|
|
9190
|
+
await e.transactional(async (e) => e.updateMany(P_, {
|
|
9187
9191
|
status: "interrupted",
|
|
9188
9192
|
error: t instanceof Error ? t.message : String(t),
|
|
9189
9193
|
updatedAt: /* @__PURE__ */ new Date()
|
|
@@ -9191,24 +9195,24 @@ Use a five-field expression, or leave this schedule on trigger: 'self' (the in-a
|
|
|
9191
9195
|
} finally {
|
|
9192
9196
|
l = !0, clearTimeout(s), await c;
|
|
9193
9197
|
}
|
|
9194
|
-
return
|
|
9195
|
-
},
|
|
9198
|
+
return z_(e, t);
|
|
9199
|
+
}, U_ = (e, t = /* @__PURE__ */ new Date()) => e.transactional((e) => e.updateMany(P_, {
|
|
9196
9200
|
status: "interrupted",
|
|
9197
9201
|
error: "Backfill owner stopped reporting; check the active run before starting another range",
|
|
9198
9202
|
updatedAt: t
|
|
9199
|
-
}, { where: T(j("status", "running"), Fe("updatedAt", /* @__PURE__ */ new Date(t.getTime() -
|
|
9203
|
+
}, { where: T(j("status", "running"), Fe("updatedAt", /* @__PURE__ */ new Date(t.getTime() - N_))) })), W_ = (e, t) => e.transactional((e) => e.updateMany(P_, {
|
|
9200
9204
|
status: "interrupted",
|
|
9201
9205
|
error: "Scheduler stopped before the backfill settled",
|
|
9202
9206
|
updatedAt: /* @__PURE__ */ new Date()
|
|
9203
|
-
}, { where: T(j("status", "running"), j("owner", t)) })),
|
|
9207
|
+
}, { where: T(j("status", "running"), j("owner", t)) })), G_ = "_voltro_wakeups", K_ = (e) => `${e.tenantId}:${e.kind}:${e.refId}`, q_ = (e) => ({
|
|
9204
9208
|
tenantId: String(e.tenantId),
|
|
9205
9209
|
kind: String(e.kind),
|
|
9206
9210
|
refId: String(e.refId),
|
|
9207
9211
|
wakeAt: e.wakeAt instanceof Date ? e.wakeAt : new Date(String(e.wakeAt)),
|
|
9208
9212
|
status: e.status === "fired" ? "fired" : "pending"
|
|
9209
|
-
}),
|
|
9210
|
-
await e.upsert(
|
|
9211
|
-
id:
|
|
9213
|
+
}), J_ = async (e, t) => {
|
|
9214
|
+
await e.upsert(G_, {
|
|
9215
|
+
id: K_(t),
|
|
9212
9216
|
tenantId: t.tenantId,
|
|
9213
9217
|
kind: t.kind,
|
|
9214
9218
|
refId: t.refId,
|
|
@@ -9218,7 +9222,7 @@ Use a five-field expression, or leave this schedule on trigger: 'self' (the in-a
|
|
|
9218
9222
|
conflictColumns: ["id"],
|
|
9219
9223
|
update: ["wakeAt", "status"]
|
|
9220
9224
|
});
|
|
9221
|
-
},
|
|
9225
|
+
}, Y_ = async (e, t) => e.delete(G_, K_(t)), X_ = async (e, t) => await e.update(G_, K_(t), { status: "fired" }) !== null, Z_ = (e, t) => ({ and: [{
|
|
9222
9226
|
column: "id",
|
|
9223
9227
|
op: "eq",
|
|
9224
9228
|
value: e
|
|
@@ -9226,16 +9230,16 @@ Use a five-field expression, or leave this schedule on trigger: 'self' (the in-a
|
|
|
9226
9230
|
column: "status",
|
|
9227
9231
|
op: "eq",
|
|
9228
9232
|
value: t
|
|
9229
|
-
}] }),
|
|
9230
|
-
await e.updateMany(
|
|
9231
|
-
},
|
|
9233
|
+
}] }), Q_ = async (e, t) => await e.updateMany(G_, { status: "fired" }, { where: Z_(K_(t), "pending") }) > 0, $_ = async (e, t) => {
|
|
9234
|
+
await e.updateMany(G_, { status: "pending" }, { where: Z_(K_(t), "fired") });
|
|
9235
|
+
}, ev = {
|
|
9232
9236
|
column: "status",
|
|
9233
9237
|
op: "eq",
|
|
9234
9238
|
value: "pending"
|
|
9235
|
-
},
|
|
9239
|
+
}, tv = async (e, t) => {
|
|
9236
9240
|
let n = {
|
|
9237
|
-
table:
|
|
9238
|
-
predicate:
|
|
9241
|
+
table: G_,
|
|
9242
|
+
predicate: ev,
|
|
9239
9243
|
order: [{
|
|
9240
9244
|
column: "wakeAt",
|
|
9241
9245
|
direction: "asc"
|
|
@@ -9244,18 +9248,18 @@ Use a five-field expression, or leave this schedule on trigger: 'self' (the in-a
|
|
|
9244
9248
|
skip: void 0,
|
|
9245
9249
|
projection: void 0
|
|
9246
9250
|
};
|
|
9247
|
-
return (await e.query(n)).map(
|
|
9248
|
-
},
|
|
9249
|
-
let r = await
|
|
9251
|
+
return (await e.query(n)).map(q_);
|
|
9252
|
+
}, nv = async (e, t, n = 500) => {
|
|
9253
|
+
let r = await tv(e, n), i = t.getTime();
|
|
9250
9254
|
return r.filter((e) => e.wakeAt.getTime() <= i);
|
|
9251
|
-
},
|
|
9255
|
+
}, rv = async (e) => (await tv(e, 1))[0] ?? null, iv = {
|
|
9252
9256
|
column: "status",
|
|
9253
9257
|
op: "eq",
|
|
9254
9258
|
value: "fired"
|
|
9255
|
-
},
|
|
9259
|
+
}, av = async (e, t = {}) => {
|
|
9256
9260
|
let n = {
|
|
9257
|
-
table:
|
|
9258
|
-
predicate:
|
|
9261
|
+
table: G_,
|
|
9262
|
+
predicate: iv,
|
|
9259
9263
|
order: [{
|
|
9260
9264
|
column: "wakeAt",
|
|
9261
9265
|
direction: "asc"
|
|
@@ -9264,14 +9268,14 @@ Use a five-field expression, or leave this schedule on trigger: 'self' (the in-a
|
|
|
9264
9268
|
skip: void 0,
|
|
9265
9269
|
projection: void 0
|
|
9266
9270
|
}, r = await e.query(n), i = t.firedOlderThan?.getTime(), a = 0;
|
|
9267
|
-
for (let t of r) i !== void 0 && (t.wakeAt instanceof Date ? t.wakeAt : new Date(String(t.wakeAt))).getTime() >= i || await e.delete(
|
|
9271
|
+
for (let t of r) i !== void 0 && (t.wakeAt instanceof Date ? t.wakeAt : new Date(String(t.wakeAt))).getTime() >= i || await e.delete(G_, String(t.id)) && a++;
|
|
9268
9272
|
return a;
|
|
9269
|
-
},
|
|
9273
|
+
}, ov = Zf, sv = "default", cv = {
|
|
9270
9274
|
kind: "single",
|
|
9271
9275
|
tryClaim: async () => !0
|
|
9272
|
-
},
|
|
9276
|
+
}, lv = "_voltro_schedule_claims", uv = 6e4, dv = 64, fv = (e) => Math.max((e ?? 6e4) * 64, 6e4), pv = (e, t, n) => {
|
|
9273
9277
|
let r = async (t) => (await e.query({
|
|
9274
|
-
table:
|
|
9278
|
+
table: lv,
|
|
9275
9279
|
order: [],
|
|
9276
9280
|
predicate: j("id", t),
|
|
9277
9281
|
projection: ["id"],
|
|
@@ -9282,7 +9286,7 @@ Use a five-field expression, or leave this schedule on trigger: 'self' (the in-a
|
|
|
9282
9286
|
if (!(r - (i.get(t) ?? 0) < n)) {
|
|
9283
9287
|
i.set(t, r);
|
|
9284
9288
|
try {
|
|
9285
|
-
await e.deleteMany(
|
|
9289
|
+
await e.deleteMany(lv, { where: T(j("scheduleName", t), Fe("claimedAt", new Date(r - n))) });
|
|
9286
9290
|
} catch {}
|
|
9287
9291
|
}
|
|
9288
9292
|
};
|
|
@@ -9294,13 +9298,13 @@ Use a five-field expression, or leave this schedule on trigger: 'self' (the in-a
|
|
|
9294
9298
|
if (await r(u)) return !1;
|
|
9295
9299
|
} catch {}
|
|
9296
9300
|
try {
|
|
9297
|
-
return await e.insert(
|
|
9301
|
+
return await e.insert(lv, {
|
|
9298
9302
|
id: u,
|
|
9299
9303
|
scheduleName: i,
|
|
9300
9304
|
bucket: l,
|
|
9301
9305
|
claimedBy: t,
|
|
9302
9306
|
claimedAt: /* @__PURE__ */ new Date()
|
|
9303
|
-
}), await a(i,
|
|
9307
|
+
}), await a(i, fv(s)), !0;
|
|
9304
9308
|
} catch (e) {
|
|
9305
9309
|
try {
|
|
9306
9310
|
if (await r(u)) return !1;
|
|
@@ -9312,25 +9316,25 @@ Use a five-field expression, or leave this schedule on trigger: 'self' (the in-a
|
|
|
9312
9316
|
}
|
|
9313
9317
|
}
|
|
9314
9318
|
};
|
|
9315
|
-
},
|
|
9319
|
+
}, mv = 3e5, hv = 3e5, gv = 6e4, _v = 864e5, vv = 200, yv = /* @__PURE__ */ new Set([
|
|
9316
9320
|
"succeeded",
|
|
9317
9321
|
"failed",
|
|
9318
9322
|
"skipped",
|
|
9319
9323
|
"missed"
|
|
9320
|
-
]), X = "_voltro_schedule_runs",
|
|
9321
|
-
let r = n.heartbeatMs *
|
|
9324
|
+
]), X = "_voltro_schedule_runs", bv = 3e4, xv = 3, Sv = 1e3, Cv = (e, t) => Math.max(e * 2, t * xv * 2), wv = (e, t, n) => {
|
|
9325
|
+
let r = n.heartbeatMs * xv, i = e.heartbeatAt == null ? NaN : new Date(e.heartbeatAt).getTime();
|
|
9322
9326
|
if (Number.isFinite(i)) return t - i < r;
|
|
9323
9327
|
let a = e.firedAt == null ? NaN : new Date(e.firedAt).getTime();
|
|
9324
9328
|
return Number.isFinite(a) ? t - a < n.maxRuntimeMs + r : !1;
|
|
9325
|
-
},
|
|
9326
|
-
let { store: n, coordinator: i, buildContext: a, replicaId: s, log: c, onRunEvent: l, interceptFire: u } = t, d = t.runHeartbeatMs !== void 0 && t.runHeartbeatMs > 0 ? t.runHeartbeatMs :
|
|
9329
|
+
}, Tv = async (e, t) => {
|
|
9330
|
+
let { store: n, coordinator: i, buildContext: a, replicaId: s, log: c, onRunEvent: l, interceptFire: u } = t, d = t.runHeartbeatMs !== void 0 && t.runHeartbeatMs > 0 ? t.runHeartbeatMs : bv, f = t.queueAdoptionWindowMs !== void 0 && t.queueAdoptionWindowMs > 0 ? t.queueAdoptionWindowMs : void 0, p = t.dormancy === "sleep", m = t.dormancyTenantId ?? "default", h = /* @__PURE__ */ new Map(), g = /* @__PURE__ */ new Set(), _ = /* @__PURE__ */ new Map(), v = !1, y = `${s}:${yt()}`, b, x, S = !1, C = () => {
|
|
9327
9331
|
v || S || b !== void 0 || (b = setTimeout(() => {
|
|
9328
|
-
b = void 0, S = !0, x =
|
|
9332
|
+
b = void 0, S = !0, x = U_(n).then(() => {}, (e) => c.warn("schedule backfill recovery unavailable", { reason: Z(e) })).finally(() => {
|
|
9329
9333
|
S = !1, v || C();
|
|
9330
9334
|
});
|
|
9331
9335
|
}, 1e4), b.unref?.());
|
|
9332
9336
|
}, w = new Map(e.map((e) => [e.name, e])), ee = (e, t) => {
|
|
9333
|
-
l?.(e,
|
|
9337
|
+
l?.(e, Dv(t));
|
|
9334
9338
|
}, te = async (e, t, r, i, a, o) => {
|
|
9335
9339
|
try {
|
|
9336
9340
|
let c = `sr_${yt()}`, l = await n.insert(X, {
|
|
@@ -9399,7 +9403,7 @@ Use a five-field expression, or leave this schedule on trigger: 'self' (the in-a
|
|
|
9399
9403
|
}), r = Date.now(), i = {
|
|
9400
9404
|
heartbeatMs: d,
|
|
9401
9405
|
maxRuntimeMs: e.maxRuntimeMs ?? 18e5
|
|
9402
|
-
}, a = t.find((e) =>
|
|
9406
|
+
}, a = t.find((e) => wv(e, r, i));
|
|
9403
9407
|
if (a === void 0) return;
|
|
9404
9408
|
let o = a.heartbeatAt ?? a.firedAt;
|
|
9405
9409
|
return {
|
|
@@ -9438,7 +9442,7 @@ Use a five-field expression, or leave this schedule on trigger: 'self' (the in-a
|
|
|
9438
9442
|
replicaId: s
|
|
9439
9443
|
}, { where: T(j("id", e), j("status", "queued")) }) > 0, se = (e, t) => {
|
|
9440
9444
|
try {
|
|
9441
|
-
let n =
|
|
9445
|
+
let n = O_(e), i = r.next(n, t), a = r.next(n, i).getTime() - i.getTime();
|
|
9442
9446
|
return a > 0 ? a : d;
|
|
9443
9447
|
} catch {
|
|
9444
9448
|
return d;
|
|
@@ -9461,12 +9465,12 @@ Use a five-field expression, or leave this schedule on trigger: 'self' (the in-a
|
|
|
9461
9465
|
for (let n of a) {
|
|
9462
9466
|
if (n.id === i) continue;
|
|
9463
9467
|
let r = new Date(n.scheduledAt);
|
|
9464
|
-
if (
|
|
9468
|
+
if (wv(n, o, s)) return {
|
|
9465
9469
|
kind: "blocked",
|
|
9466
9470
|
behind: r
|
|
9467
9471
|
};
|
|
9468
9472
|
let a = n.heartbeatAt ?? n.firedAt ?? n.scheduledAt, c = o - new Date(a).getTime();
|
|
9469
|
-
if (c <= (f ??
|
|
9473
|
+
if (c <= (f ?? Cv(se(e, r), d))) return {
|
|
9470
9474
|
kind: "adopt",
|
|
9471
9475
|
runId: n.id,
|
|
9472
9476
|
scheduledAt: r,
|
|
@@ -9560,7 +9564,7 @@ Use a five-field expression, or leave this schedule on trigger: 'self' (the in-a
|
|
|
9560
9564
|
reason: Z(t)
|
|
9561
9565
|
});
|
|
9562
9566
|
}
|
|
9563
|
-
await ae(
|
|
9567
|
+
await ae(Sv);
|
|
9564
9568
|
}
|
|
9565
9569
|
} finally {
|
|
9566
9570
|
clearInterval(o);
|
|
@@ -9602,7 +9606,7 @@ Use a five-field expression, or leave this schedule on trigger: 'self' (the in-a
|
|
|
9602
9606
|
scheduleName: e.name,
|
|
9603
9607
|
trigger: r,
|
|
9604
9608
|
runId: p,
|
|
9605
|
-
subject:
|
|
9609
|
+
subject: ov
|
|
9606
9610
|
})
|
|
9607
9611
|
}, l = async () => {
|
|
9608
9612
|
if (e.workflow !== void 0) {
|
|
@@ -9636,7 +9640,7 @@ Use a five-field expression, or leave this schedule on trigger: 'self' (the in-a
|
|
|
9636
9640
|
let n = Z(t).includes("exceeded maxRuntimeMs"), r = ye(t).dbMessage, i = typeof r == "string" && r !== "" ? `${Z(t)} — ${r}` : Z(t);
|
|
9637
9641
|
p && await ne(p, {
|
|
9638
9642
|
status: "failed",
|
|
9639
|
-
errorTag: n ? "timeout" :
|
|
9643
|
+
errorTag: n ? "timeout" : Ev(t),
|
|
9640
9644
|
errorMessage: i,
|
|
9641
9645
|
completedAt: /* @__PURE__ */ new Date(),
|
|
9642
9646
|
durationMs: Date.now() - m
|
|
@@ -9707,8 +9711,8 @@ Use a five-field expression, or leave this schedule on trigger: 'self' (the in-a
|
|
|
9707
9711
|
}
|
|
9708
9712
|
}, me = async (e) => {
|
|
9709
9713
|
try {
|
|
9710
|
-
let t = r.next(
|
|
9711
|
-
await
|
|
9714
|
+
let t = r.next(O_(e), /* @__PURE__ */ new Date());
|
|
9715
|
+
await J_(n, {
|
|
9712
9716
|
tenantId: m,
|
|
9713
9717
|
kind: "schedule",
|
|
9714
9718
|
refId: e.name,
|
|
@@ -9722,7 +9726,7 @@ Use a five-field expression, or leave this schedule on trigger: 'self' (the in-a
|
|
|
9722
9726
|
}
|
|
9723
9727
|
}, he = 2147483647, ge = (e) => {
|
|
9724
9728
|
if (v) return;
|
|
9725
|
-
let n =
|
|
9729
|
+
let n = O_(e), i = r.next(n, /* @__PURE__ */ new Date()), a = () => {
|
|
9726
9730
|
if (v) return;
|
|
9727
9731
|
let n = i.getTime() - Date.now();
|
|
9728
9732
|
if (n > he) {
|
|
@@ -9753,10 +9757,10 @@ Use a five-field expression, or leave this schedule on trigger: 'self' (the in-a
|
|
|
9753
9757
|
projection: void 0
|
|
9754
9758
|
}), t = Date.now(), r = {
|
|
9755
9759
|
heartbeatMs: d,
|
|
9756
|
-
maxRuntimeMs:
|
|
9760
|
+
maxRuntimeMs: E_
|
|
9757
9761
|
};
|
|
9758
9762
|
for (let n of e) {
|
|
9759
|
-
if (w.has(n.name) ||
|
|
9763
|
+
if (w.has(n.name) || wv(n, t, r)) continue;
|
|
9760
9764
|
let e = n.heartbeatAt ?? n.firedAt ?? n.scheduledAt;
|
|
9761
9765
|
await le(n.id, n.name, new Date(n.scheduledAt), t - new Date(e).getTime(), "no schedule of this name is declared any more, so nothing can take this firing");
|
|
9762
9766
|
}
|
|
@@ -9787,7 +9791,7 @@ Use a five-field expression, or leave this schedule on trigger: 'self' (the in-a
|
|
|
9787
9791
|
return;
|
|
9788
9792
|
}
|
|
9789
9793
|
if (!a) return;
|
|
9790
|
-
let o =
|
|
9794
|
+
let o = O_(e), s = [], l = r.next(o, a), u = Date.now();
|
|
9791
9795
|
for (; l.getTime() < u && s.length < 1e3;) s.push(l), l = r.next(o, l);
|
|
9792
9796
|
if (s.length !== 0) {
|
|
9793
9797
|
if (c.info("schedule: backfill", {
|
|
@@ -9818,9 +9822,9 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
9818
9822
|
external: e.length - N.length,
|
|
9819
9823
|
coordinator: i.kind
|
|
9820
9824
|
}), await M();
|
|
9821
|
-
let P = t.externalTriggerSkewMs !== void 0 && t.externalTriggerSkewMs > 0 ? t.externalTriggerSkewMs :
|
|
9825
|
+
let P = t.externalTriggerSkewMs !== void 0 && t.externalTriggerSkewMs > 0 ? t.externalTriggerSkewMs : mv, be = i.kind === "advisoryLock" ? i : pv(n, s, c), F = (e, t, n) => {
|
|
9822
9826
|
try {
|
|
9823
|
-
let i =
|
|
9827
|
+
let i = O_(e), a = r.next(i, new Date(t.getTime() - n)), o, s = 0;
|
|
9824
9828
|
for (; a.getTime() <= t.getTime() && s++ < 1e3;) o = a, a = r.next(i, a);
|
|
9825
9829
|
return o;
|
|
9826
9830
|
} catch {
|
|
@@ -9860,7 +9864,7 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
9860
9864
|
errorTag: t.errorTag === null || t.errorTag === void 0 ? null : String(t.errorTag),
|
|
9861
9865
|
errorMessage: t.errorMessage === null || t.errorMessage === void 0 ? null : String(t.errorMessage)
|
|
9862
9866
|
};
|
|
9863
|
-
}, we = e.filter((e) => (e.trigger ?? t.defaultTrigger) === "external"), L = t.externalMissedPolicy ?? "record", Te = t.externalReconcileMs !== void 0 && t.externalReconcileMs > 0 ? t.externalReconcileMs :
|
|
9867
|
+
}, we = e.filter((e) => (e.trigger ?? t.defaultTrigger) === "external"), L = t.externalMissedPolicy ?? "record", Te = t.externalReconcileMs !== void 0 && t.externalReconcileMs > 0 ? t.externalReconcileMs : hv, Ee, De = async (e) => {
|
|
9864
9868
|
try {
|
|
9865
9869
|
let t = (await n.query({
|
|
9866
9870
|
table: X,
|
|
@@ -9880,17 +9884,17 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
9880
9884
|
}, Oe = async () => {
|
|
9881
9885
|
let e = Date.now();
|
|
9882
9886
|
for (let t of we) try {
|
|
9883
|
-
let n = new Date(e - xe(t, new Date(e))), r = await De(t.name) ?? /* @__PURE__ */ new Date(e -
|
|
9887
|
+
let n = new Date(e - xe(t, new Date(e))), r = await De(t.name) ?? /* @__PURE__ */ new Date(e - _v);
|
|
9884
9888
|
if (r.getTime() >= n.getTime()) continue;
|
|
9885
|
-
let i =
|
|
9889
|
+
let i = A_(t, r, n, vv);
|
|
9886
9890
|
if (i.length === 0) continue;
|
|
9887
|
-
i.length >
|
|
9891
|
+
i.length > vv && c.warn("schedule: more unfired occurrences than one reconciliation records", {
|
|
9888
9892
|
name: t.name,
|
|
9889
|
-
cap:
|
|
9893
|
+
cap: vv,
|
|
9890
9894
|
since: r.toISOString()
|
|
9891
9895
|
});
|
|
9892
9896
|
let a = 0;
|
|
9893
|
-
for (let e of i.slice(0,
|
|
9897
|
+
for (let e of i.slice(0, vv)) await be.tryClaim(t.name, e) && (L === "record-and-run" ? await A(t, e, "external", "external") : await te(t, e, null, "missed", "external", "external"), a += 1);
|
|
9894
9898
|
a > 0 && (Qa(t.name, a), c.warn("schedule: occurrences were never triggered by the external scheduler", {
|
|
9895
9899
|
name: t.name,
|
|
9896
9900
|
count: a,
|
|
@@ -9930,7 +9934,7 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
9930
9934
|
kind: "ahead",
|
|
9931
9935
|
arrivalAt: n,
|
|
9932
9936
|
now: a,
|
|
9933
|
-
toleranceMs:
|
|
9937
|
+
toleranceMs: gv
|
|
9934
9938
|
};
|
|
9935
9939
|
let o = xe(r, n), s = F(r, n, o);
|
|
9936
9940
|
if (s === void 0) return c.warn("schedule: external trigger matched no occurrence — the deployed cadence and the declared one disagree", {
|
|
@@ -10004,24 +10008,24 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
10004
10008
|
let n = await A(t, /* @__PURE__ */ new Date(), "self", "cluster");
|
|
10005
10009
|
return p && await me(t), n;
|
|
10006
10010
|
},
|
|
10007
|
-
backfillRequest: async (e) => (await
|
|
10011
|
+
backfillRequest: async (e) => (await U_(n), C(), z_(n, e)),
|
|
10008
10012
|
startBackfillRange: async (e, t, r, i) => {
|
|
10009
10013
|
if (v) throw Error("scheduler stopped");
|
|
10010
10014
|
let a = w.get(e);
|
|
10011
10015
|
if (!a) throw Error(`Unknown schedule "${e}"`);
|
|
10012
10016
|
if (!Number.isInteger(i.cap) || i.cap < 1 || i.cap > 1e4) throw Error("Invalid backfill cap");
|
|
10013
10017
|
if (!(t.getTime() < r.getTime())) throw Error("Invalid backfill range");
|
|
10014
|
-
let o =
|
|
10018
|
+
let o = A_(a, t, r, i.cap);
|
|
10015
10019
|
if (o.length > i.cap) throw Error("Backfill occurrence limit exceeded");
|
|
10016
|
-
await
|
|
10017
|
-
let s = await
|
|
10020
|
+
await U_(n), C();
|
|
10021
|
+
let s = await B_(n, {
|
|
10018
10022
|
id: i.requestId,
|
|
10019
10023
|
name: e,
|
|
10020
10024
|
from: t,
|
|
10021
10025
|
to: r,
|
|
10022
10026
|
occurrences: o
|
|
10023
10027
|
});
|
|
10024
|
-
return
|
|
10028
|
+
return H_(n, i.requestId, y, async (e) => {
|
|
10025
10029
|
if (v) throw Error("Scheduler stopped during backfill");
|
|
10026
10030
|
let t = await A(a, e, "manual");
|
|
10027
10031
|
if (!t) throw Error("Backfill firing has no recorded run ID");
|
|
@@ -10051,7 +10055,7 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
10051
10055
|
let i = w.get(e);
|
|
10052
10056
|
if (!i) throw Error(`scheduler.backfillRange: unknown schedule "${e}"`);
|
|
10053
10057
|
if (!(t.getTime() < n.getTime())) throw Error(`scheduler.backfillRange("${e}"): 'from' (${t.toISOString()}) must be before 'to' (${n.toISOString()})`);
|
|
10054
|
-
let a =
|
|
10058
|
+
let a = A_(i, t, n, r.cap);
|
|
10055
10059
|
if (a.length > r.cap) throw Error(`scheduler.backfillRange("${e}"): more than ${r.cap} occurrences in ${t.toISOString()}..${n.toISOString()} — narrow the range or raise the cap`);
|
|
10056
10060
|
let o = [];
|
|
10057
10061
|
for (let e of a) {
|
|
@@ -10067,18 +10071,18 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
10067
10071
|
shutdown: async () => {
|
|
10068
10072
|
v = !0;
|
|
10069
10073
|
let e = b !== void 0 || x !== void 0;
|
|
10070
|
-
clearTimeout(b), await x, e && await
|
|
10074
|
+
clearTimeout(b), await x, e && await W_(n, y), Ee && clearTimeout(Ee);
|
|
10071
10075
|
for (let e of h.values()) clearTimeout(e);
|
|
10072
10076
|
h.clear();
|
|
10073
10077
|
for (let e of [...D]) e();
|
|
10074
10078
|
D.clear(), O?.(), c.info("scheduler: stopped");
|
|
10075
10079
|
}
|
|
10076
10080
|
};
|
|
10077
|
-
}, Z = (e) => e?.message ?? String(e),
|
|
10081
|
+
}, Z = (e) => e?.message ?? String(e), Ev = (e) => e && typeof e == "object" && "_tag" in e ? String(e._tag) : null, Dv = (e) => {
|
|
10078
10082
|
let t = {};
|
|
10079
10083
|
for (let [n, r] of Object.entries(e)) t[n] = r instanceof Date ? r.toISOString() : r;
|
|
10080
10084
|
return t;
|
|
10081
|
-
},
|
|
10085
|
+
}, Ov = 6e4, kv = (e) => {
|
|
10082
10086
|
if (!Number.isFinite(e) || e < 6e4 || e % 6e4 != 0) return;
|
|
10083
10087
|
let t = e / 6e4;
|
|
10084
10088
|
if (t === 1) return "* * * * *";
|
|
@@ -10087,25 +10091,25 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
10087
10091
|
if (t % 60 != 0) return;
|
|
10088
10092
|
let n = t / 60;
|
|
10089
10093
|
return n < 24 ? 24 % n == 0 ? `0 */${n} * * *` : void 0 : n === 24 ? "0 0 * * *" : void 0;
|
|
10090
|
-
},
|
|
10094
|
+
}, Av = (e, t) => {
|
|
10091
10095
|
if (t < 6e4) return `"${e}" ticks every ${t} ms. No platform scheduler can express sub-minute cadence — and this is not a cron: its real trigger is an arrival, and the interval is only the ceiling for when reactivity is unavailable. It stays on its in-process timer.`;
|
|
10092
|
-
if (
|
|
10093
|
-
},
|
|
10094
|
-
let e = globalThis, t = e[
|
|
10096
|
+
if (kv(t) === void 0) return `"${e}" ticks every ${t} ms, which no five-field cron expression fires at — cron matches instants rather than measuring intervals, so only cadences that tile the hour or the day evenly can be expressed. Choose an interval that divides 60 minutes or 24 hours. It stays on its in-process timer.`;
|
|
10097
|
+
}, jv = Symbol.for("@voltro/externalizedCoordinatedTasks"), Mv = () => {
|
|
10098
|
+
let e = globalThis, t = e[jv];
|
|
10095
10099
|
if (t !== void 0) return t;
|
|
10096
10100
|
let n = /* @__PURE__ */ new Map();
|
|
10097
|
-
return e[
|
|
10098
|
-
},
|
|
10099
|
-
|
|
10100
|
-
},
|
|
10101
|
-
|
|
10102
|
-
},
|
|
10101
|
+
return e[jv] = n, n;
|
|
10102
|
+
}, Nv = (e) => {
|
|
10103
|
+
Mv().set(e.name, e);
|
|
10104
|
+
}, Pv = (e) => {
|
|
10105
|
+
Mv().delete(e);
|
|
10106
|
+
}, Fv = (e) => Mv().get(e), Iv = () => [...Mv().keys()].sort(), Lv = 3e4, Rv = (e = process.env) => {
|
|
10103
10107
|
let t = e.VOLTRO_POLL_CEILING_MS;
|
|
10104
|
-
if (t === void 0) return
|
|
10108
|
+
if (t === void 0) return Lv;
|
|
10105
10109
|
let n = Number(t);
|
|
10106
|
-
return Number.isFinite(n) && n > 0 ? n :
|
|
10107
|
-
},
|
|
10108
|
-
let i = Math.max(t, r.maxIdleIntervalMs ??
|
|
10110
|
+
return Number.isFinite(n) && n > 0 ? n : Lv;
|
|
10111
|
+
}, zv = (e, t, n, r) => {
|
|
10112
|
+
let i = Math.max(t, r.maxIdleIntervalMs ?? Rv()), a = !1, o, s = !1, c = t, l = !1, u = !1, d = 0, f = (e) => {
|
|
10109
10113
|
if (!a) {
|
|
10110
10114
|
if (o !== void 0 && clearTimeout(o), o = void 0, e === "disarm") {
|
|
10111
10115
|
s = !0;
|
|
@@ -10148,21 +10152,21 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
10148
10152
|
}), f(t);
|
|
10149
10153
|
return;
|
|
10150
10154
|
}
|
|
10151
|
-
f(
|
|
10155
|
+
f(Bv(s, t, c, i, r.disarmWhenIdle ?? !1));
|
|
10152
10156
|
} finally {
|
|
10153
10157
|
l = !1, u && !a && (u = !1, f(0));
|
|
10154
10158
|
}
|
|
10155
10159
|
}, m = async () => {
|
|
10156
10160
|
let i = new Date(Math.floor(Date.now() / t) * t);
|
|
10157
10161
|
return await (r.externalClaim ?? r.coordinator).tryClaim(e, i, t) ? (await n(), "ran") : "deduplicated";
|
|
10158
|
-
}, h = r.externalize === !0 ?
|
|
10162
|
+
}, h = r.externalize === !0 ? Av(e, t) : void 0, g = r.externalize === !0 && h === void 0;
|
|
10159
10163
|
return h !== void 0 && r.log?.warn(`coordinated schedule: REFUSING to externalise this task — ${h}`, {
|
|
10160
10164
|
task: e,
|
|
10161
10165
|
intervalMs: t
|
|
10162
|
-
}), g ? (
|
|
10166
|
+
}), g ? (Nv({
|
|
10163
10167
|
name: e,
|
|
10164
10168
|
intervalMs: t,
|
|
10165
|
-
cron:
|
|
10169
|
+
cron: kv(t),
|
|
10166
10170
|
run: m
|
|
10167
10171
|
}), r.log?.info("coordinated schedule: externalised — no in-process timer", {
|
|
10168
10172
|
task: e,
|
|
@@ -10183,19 +10187,19 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
10183
10187
|
}
|
|
10184
10188
|
},
|
|
10185
10189
|
stop: () => {
|
|
10186
|
-
a || (a = !0, o !== void 0 && clearTimeout(o), o = void 0, g &&
|
|
10190
|
+
a || (a = !0, o !== void 0 && clearTimeout(o), o = void 0, g && Pv(e));
|
|
10187
10191
|
}
|
|
10188
10192
|
};
|
|
10189
|
-
},
|
|
10193
|
+
}, Bv = (e, t, n, r, i = !1) => {
|
|
10190
10194
|
if (e === void 0 || !e.idle) return t;
|
|
10191
10195
|
if (e.nextDueInMs === void 0 && i) return "disarm";
|
|
10192
10196
|
let a = Math.min(Math.max(n, t) * 2, r);
|
|
10193
10197
|
return e.nextDueInMs === void 0 ? a : Math.max(t, Math.min(a, e.nextDueInMs));
|
|
10194
|
-
},
|
|
10198
|
+
}, Vv = (e) => (t, n, r, i) => zv(t, n, r, {
|
|
10195
10199
|
...e,
|
|
10196
10200
|
...e.externalizeTask === void 0 ? {} : { externalize: e.externalizeTask(t) },
|
|
10197
10201
|
...i?.disarmWhenIdle === void 0 ? {} : { disarmWhenIdle: i.disarmWhenIdle }
|
|
10198
|
-
}),
|
|
10202
|
+
}), Hv = R("_voltro_schedule_runs", {
|
|
10199
10203
|
id: I({ prefix: "schrun" }),
|
|
10200
10204
|
name: z(),
|
|
10201
10205
|
status: z().oneOf([
|
|
@@ -10227,19 +10231,19 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
10227
10231
|
replicaId: z().nullable(),
|
|
10228
10232
|
heartbeatAt: B().nullable(),
|
|
10229
10233
|
result: je().nullable()
|
|
10230
|
-
}).index(["name", "scheduledAt"]).index(["status"]),
|
|
10234
|
+
}).index(["name", "scheduledAt"]).index(["status"]), Uv = R("_voltro_schedule_claims", {
|
|
10231
10235
|
id: I({ prefix: "schclaim" }),
|
|
10232
10236
|
scheduleName: z(),
|
|
10233
10237
|
bucket: z(),
|
|
10234
10238
|
claimedBy: z(),
|
|
10235
10239
|
claimedAt: B()
|
|
10236
|
-
}).index(["scheduleName", "claimedAt"]).index(["claimedAt"]),
|
|
10240
|
+
}).index(["scheduleName", "claimedAt"]).index(["claimedAt"]), Wv = R("_voltro_change_claims", {
|
|
10237
10241
|
id: I({ prefix: "chclaim" }),
|
|
10238
10242
|
scope: z(),
|
|
10239
10243
|
key: z(),
|
|
10240
10244
|
claimedBy: z(),
|
|
10241
10245
|
claimedAt: B()
|
|
10242
|
-
}).unique(["scope", "key"]).index(["claimedAt"]),
|
|
10246
|
+
}).unique(["scope", "key"]).index(["claimedAt"]), Gv = R("_voltro_traces", {
|
|
10243
10247
|
id: I({ prefix: "span" }),
|
|
10244
10248
|
traceId: z(),
|
|
10245
10249
|
spanId: z(),
|
|
@@ -10263,7 +10267,7 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
10263
10267
|
durationMs: L(),
|
|
10264
10268
|
attributes: je().nullable(),
|
|
10265
10269
|
events: je().nullable()
|
|
10266
|
-
}).index(["traceId", "startedAt"]).index(["startedAt"]).index(["status"]),
|
|
10270
|
+
}).index(["traceId", "startedAt"]).index(["startedAt"]).index(["status"]), Kv = R("_voltro_undo_log", {
|
|
10267
10271
|
id: I({ prefix: "undo" }),
|
|
10268
10272
|
tag: z(),
|
|
10269
10273
|
label: z().nullable(),
|
|
@@ -10274,17 +10278,17 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
10274
10278
|
crossesAction: ae().default(!1),
|
|
10275
10279
|
undone: ae().default(!1),
|
|
10276
10280
|
createdAt: B().default("now")
|
|
10277
|
-
}).index(["subjectId", "createdAt"]),
|
|
10281
|
+
}).index(["subjectId", "createdAt"]), qv = (e = process.env) => {
|
|
10278
10282
|
let t = (e.VOLTRO_UNDO ?? "").toLowerCase();
|
|
10279
10283
|
return t === "on" || t === "1" || t === "true" ? !0 : t === "off" || t === "0" || t === "false" ? !1 : e.NODE_ENV !== "production";
|
|
10280
|
-
},
|
|
10284
|
+
}, Jv = (e = process.env) => {
|
|
10281
10285
|
let t = (e.VOLTRO_UNDO ?? "").toLowerCase();
|
|
10282
10286
|
return t !== "off" && t !== "0" && t !== "false";
|
|
10283
|
-
},
|
|
10287
|
+
}, Yv = (e) => e.startsWith("_voltro"), Xv = async (e, t, n) => (await e.query({
|
|
10284
10288
|
table: t,
|
|
10285
10289
|
predicate: j("id", n),
|
|
10286
10290
|
order: []
|
|
10287
|
-
}))[0] ?? null,
|
|
10291
|
+
}))[0] ?? null, Zv = (e, t, n = () => /* @__PURE__ */ new Set()) => new Proxy(e, { get(e, r, i) {
|
|
10288
10292
|
let a = (e, t) => {
|
|
10289
10293
|
if (t === null) return null;
|
|
10290
10294
|
let r = n(e);
|
|
@@ -10295,7 +10299,7 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
10295
10299
|
};
|
|
10296
10300
|
if (r === "insert") return async (n, r) => {
|
|
10297
10301
|
let i = await e.insert(n, r);
|
|
10298
|
-
return
|
|
10302
|
+
return Yv(n) || t({
|
|
10299
10303
|
table: n,
|
|
10300
10304
|
op: "insert",
|
|
10301
10305
|
next: i
|
|
@@ -10304,8 +10308,8 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
10304
10308
|
if (r === "update") return async (r, i, o) => {
|
|
10305
10309
|
let s = n(r), c = Object.keys(o);
|
|
10306
10310
|
if (s.size > 0 && c.length > 0 && c.every((e) => s.has(e))) return await e.update(r, i, o);
|
|
10307
|
-
let l =
|
|
10308
|
-
return
|
|
10311
|
+
let l = Yv(r) ? null : a(r, await Xv(e, r, i)), u = await e.update(r, i, o);
|
|
10312
|
+
return Yv(r) || t({
|
|
10309
10313
|
table: r,
|
|
10310
10314
|
op: "update",
|
|
10311
10315
|
id: i,
|
|
@@ -10314,8 +10318,8 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
10314
10318
|
}), u;
|
|
10315
10319
|
};
|
|
10316
10320
|
if (r === "delete") return async (n, r) => {
|
|
10317
|
-
let i =
|
|
10318
|
-
return !
|
|
10321
|
+
let i = Yv(n) ? null : await Xv(e, n, r), a = await e.delete(n, r);
|
|
10322
|
+
return !Yv(n) && a && t({
|
|
10319
10323
|
table: n,
|
|
10320
10324
|
op: "delete",
|
|
10321
10325
|
id: r,
|
|
@@ -10324,10 +10328,10 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
10324
10328
|
};
|
|
10325
10329
|
let o = Reflect.get(e, r, i);
|
|
10326
10330
|
return typeof o == "function" ? o.bind(e) : o;
|
|
10327
|
-
} }),
|
|
10331
|
+
} }), Qv = (e, t = () => /* @__PURE__ */ new Set()) => {
|
|
10328
10332
|
let n = [];
|
|
10329
10333
|
return {
|
|
10330
|
-
tx:
|
|
10334
|
+
tx: Zv(e, (e) => n.push(e), t),
|
|
10331
10335
|
persist: async (e, t) => {
|
|
10332
10336
|
if (n.length === 0 || t.tag.startsWith("__voltro")) return;
|
|
10333
10337
|
let r = t.subject;
|
|
@@ -10343,13 +10347,13 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
10343
10347
|
});
|
|
10344
10348
|
}
|
|
10345
10349
|
};
|
|
10346
|
-
},
|
|
10350
|
+
}, $v = (e) => e.startsWith("_voltro"), ey = (e) => {
|
|
10347
10351
|
let t = e?.id;
|
|
10348
10352
|
return typeof t == "string" ? t : void 0;
|
|
10349
|
-
},
|
|
10353
|
+
}, ty = (e) => {
|
|
10350
10354
|
let t = /* @__PURE__ */ new Map(), n = (e, n) => {
|
|
10351
|
-
if (n == null ||
|
|
10352
|
-
let r =
|
|
10355
|
+
if (n == null || $v(e)) return;
|
|
10356
|
+
let r = ey(n);
|
|
10353
10357
|
r !== void 0 && t.set(`${e}\u0000${r}`, {
|
|
10354
10358
|
table: e,
|
|
10355
10359
|
id: r,
|
|
@@ -10374,9 +10378,9 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
10374
10378
|
} }),
|
|
10375
10379
|
drain: () => [...t.values()]
|
|
10376
10380
|
};
|
|
10377
|
-
},
|
|
10381
|
+
}, ny = (e) => {
|
|
10378
10382
|
if (e !== !0 && e !== void 0) return e === !1 ? {} : e;
|
|
10379
|
-
},
|
|
10383
|
+
}, ry = async (e) => {
|
|
10380
10384
|
if (e.touched.length === 0) return;
|
|
10381
10385
|
let t = {
|
|
10382
10386
|
store: e.store,
|
|
@@ -10385,7 +10389,7 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
10385
10389
|
for (let { table: n, row: r } of e.touched) {
|
|
10386
10390
|
let e = F(n)?.appliedRules;
|
|
10387
10391
|
if (e !== void 0 && e.length !== 0) for (let i of e) {
|
|
10388
|
-
let e =
|
|
10392
|
+
let e = ny(await i.predicate(r, t));
|
|
10389
10393
|
if (e !== void 0) {
|
|
10390
10394
|
if (i.severity === "warning") {
|
|
10391
10395
|
Zn.warn("business rule violated (warning)", {
|
|
@@ -10406,14 +10410,14 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
10406
10410
|
}
|
|
10407
10411
|
}
|
|
10408
10412
|
}
|
|
10409
|
-
},
|
|
10413
|
+
}, iy = (e) => {
|
|
10410
10414
|
if (e.id !== void 0) return e.id;
|
|
10411
10415
|
let t = e.next?.id;
|
|
10412
10416
|
if (typeof t == "string") return t;
|
|
10413
10417
|
let n = e.prev?.id;
|
|
10414
10418
|
return typeof n == "string" ? n : void 0;
|
|
10415
|
-
},
|
|
10416
|
-
let t =
|
|
10419
|
+
}, ay = (e) => {
|
|
10420
|
+
let t = iy(e);
|
|
10417
10421
|
switch (e.op) {
|
|
10418
10422
|
case "insert": return t === void 0 ? null : {
|
|
10419
10423
|
table: e.table,
|
|
@@ -10437,28 +10441,28 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
10437
10441
|
row: e.prev
|
|
10438
10442
|
};
|
|
10439
10443
|
}
|
|
10440
|
-
},
|
|
10441
|
-
if (e.crossesAction) throw new
|
|
10444
|
+
}, oy = (e) => {
|
|
10445
|
+
if (e.crossesAction) throw new sy(e.invocationId, "action");
|
|
10442
10446
|
let t = [];
|
|
10443
10447
|
for (let n = e.changes.length - 1; n >= 0; --n) {
|
|
10444
|
-
let r =
|
|
10448
|
+
let r = ay(e.changes[n]);
|
|
10445
10449
|
r !== null && t.push(r);
|
|
10446
10450
|
}
|
|
10447
10451
|
return t;
|
|
10448
|
-
},
|
|
10452
|
+
}, sy = class extends Error {
|
|
10449
10453
|
invocationId;
|
|
10450
10454
|
boundary;
|
|
10451
10455
|
_tag = "UndoBoundaryError";
|
|
10452
10456
|
constructor(e, t) {
|
|
10453
10457
|
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";
|
|
10454
10458
|
}
|
|
10455
|
-
},
|
|
10459
|
+
}, cy = (e, t, n = ["updatedAt", "updatedBy"]) => {
|
|
10456
10460
|
if (t == null) return e == null;
|
|
10457
10461
|
if (e == null) return !1;
|
|
10458
10462
|
let r = new Set(n);
|
|
10459
10463
|
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;
|
|
10460
10464
|
return !0;
|
|
10461
|
-
},
|
|
10465
|
+
}, ly = class {
|
|
10462
10466
|
capacity;
|
|
10463
10467
|
done = [];
|
|
10464
10468
|
undone = [];
|
|
@@ -10494,7 +10498,7 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
10494
10498
|
redo: [...this.undone]
|
|
10495
10499
|
};
|
|
10496
10500
|
}
|
|
10497
|
-
},
|
|
10501
|
+
}, uy = (e, t = /* @__PURE__ */ new Set()) => e.op === "insert" ? {
|
|
10498
10502
|
table: e.table,
|
|
10499
10503
|
op: "insert",
|
|
10500
10504
|
next: e.new ?? null
|
|
@@ -10511,7 +10515,7 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
10511
10515
|
table: e.table,
|
|
10512
10516
|
op: "delete",
|
|
10513
10517
|
prev: e.old ?? null
|
|
10514
|
-
},
|
|
10518
|
+
}, dy = async (e, t) => {
|
|
10515
10519
|
switch (t.op) {
|
|
10516
10520
|
case "delete":
|
|
10517
10521
|
await e.delete(t.table, t.id);
|
|
@@ -10529,21 +10533,21 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
10529
10533
|
await e.insert(t.table, t.row);
|
|
10530
10534
|
return;
|
|
10531
10535
|
}
|
|
10532
|
-
},
|
|
10533
|
-
for (let n of t) await
|
|
10534
|
-
},
|
|
10536
|
+
}, fy = async (e, t) => {
|
|
10537
|
+
for (let n of t) await dy(e, n);
|
|
10538
|
+
}, py = (e) => e.request?.subject?.id ?? null, my = (e) => e === !0 || e === 1, hy = async (e, t, n) => (await e.query({
|
|
10535
10539
|
table: t,
|
|
10536
10540
|
predicate: j("id", n),
|
|
10537
10541
|
order: []
|
|
10538
|
-
}))[0] ?? null,
|
|
10542
|
+
}))[0] ?? null, gy = (e) => {
|
|
10539
10543
|
try {
|
|
10540
10544
|
let t = JSON.parse(String(e ?? "[]"));
|
|
10541
10545
|
return Array.isArray(t) ? t : [];
|
|
10542
10546
|
} catch {
|
|
10543
10547
|
return [];
|
|
10544
10548
|
}
|
|
10545
|
-
},
|
|
10546
|
-
let n =
|
|
10549
|
+
}, _y = (e) => e.id ?? e.next?.id ?? e.prev?.id, vy = async (e, t) => {
|
|
10550
|
+
let n = py(t);
|
|
10547
10551
|
return [...await t.store.query({
|
|
10548
10552
|
table: "_voltro_undo_log",
|
|
10549
10553
|
predicate: j("subjectId", n),
|
|
@@ -10552,46 +10556,46 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
10552
10556
|
id: String(e.id),
|
|
10553
10557
|
tag: String(e.tag ?? ""),
|
|
10554
10558
|
label: e.label ?? null,
|
|
10555
|
-
undone:
|
|
10556
|
-
crossesAction:
|
|
10559
|
+
undone: my(e.undone),
|
|
10560
|
+
crossesAction: my(e.crossesAction),
|
|
10557
10561
|
createdAt: String(e.createdAt ?? "")
|
|
10558
10562
|
}));
|
|
10559
|
-
},
|
|
10560
|
-
let n = await
|
|
10563
|
+
}, yy = async (e, t) => {
|
|
10564
|
+
let n = await hy(t.store, "_voltro_undo_log", e.invocationId);
|
|
10561
10565
|
if (!n) throw new gn({ invocationId: e.invocationId });
|
|
10562
|
-
if ((n.subjectId ?? null) !==
|
|
10566
|
+
if ((n.subjectId ?? null) !== py(t)) throw new hn({ invocationId: e.invocationId });
|
|
10563
10567
|
return n;
|
|
10564
|
-
},
|
|
10565
|
-
let n = await
|
|
10566
|
-
if (
|
|
10567
|
-
if (
|
|
10568
|
+
}, by = async (e, t) => {
|
|
10569
|
+
let n = await yy(e, t);
|
|
10570
|
+
if (my(n.undone)) return { ok: !0 };
|
|
10571
|
+
if (my(n.crossesAction)) throw new mn({
|
|
10568
10572
|
invocationId: e.invocationId,
|
|
10569
10573
|
reason: "action"
|
|
10570
10574
|
});
|
|
10571
|
-
let r =
|
|
10575
|
+
let r = gy(n.changes);
|
|
10572
10576
|
for (let n of r) {
|
|
10573
|
-
let r =
|
|
10574
|
-
if (r !== void 0 && !
|
|
10577
|
+
let r = _y(n);
|
|
10578
|
+
if (r !== void 0 && !cy(await hy(t.store, n.table, r), n.next ?? null)) throw new mn({
|
|
10575
10579
|
invocationId: e.invocationId,
|
|
10576
10580
|
reason: "conflict"
|
|
10577
10581
|
});
|
|
10578
10582
|
}
|
|
10579
10583
|
let i = {
|
|
10580
10584
|
invocationId: e.invocationId,
|
|
10581
|
-
subject:
|
|
10585
|
+
subject: py(t),
|
|
10582
10586
|
changes: r,
|
|
10583
10587
|
crossesAction: !1
|
|
10584
10588
|
};
|
|
10585
|
-
return await
|
|
10586
|
-
},
|
|
10587
|
-
let n = await
|
|
10588
|
-
if (!
|
|
10589
|
-
for (let e of
|
|
10590
|
-
let n =
|
|
10589
|
+
return await fy(t.store, oy(i)), await t.store.update("_voltro_undo_log", e.invocationId, { undone: !0 }), { ok: !0 };
|
|
10590
|
+
}, xy = async (e, t) => {
|
|
10591
|
+
let n = await yy(e, t);
|
|
10592
|
+
if (!my(n.undone)) return { ok: !0 };
|
|
10593
|
+
for (let e of gy(n.changes)) {
|
|
10594
|
+
let n = _y(e);
|
|
10591
10595
|
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);
|
|
10592
10596
|
}
|
|
10593
10597
|
return await t.store.update("_voltro_undo_log", e.invocationId, { undone: !1 }), { ok: !0 };
|
|
10594
|
-
},
|
|
10598
|
+
}, Sy = "_voltro_approvals", Cy = 864e5, wy = R(Sy, {
|
|
10595
10599
|
id: I({ prefix: "apv" }),
|
|
10596
10600
|
intentKey: z().maxLength(191),
|
|
10597
10601
|
procedure: z(),
|
|
@@ -10610,14 +10614,14 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
10610
10614
|
requestedAt: B().default("now"),
|
|
10611
10615
|
expiresAt: B(),
|
|
10612
10616
|
consumedAt: B().nullable()
|
|
10613
|
-
}).index(["status", "expiresAt"]).index(["requestedBy"]),
|
|
10617
|
+
}).index(["status", "expiresAt"]).index(["requestedBy"]), Ty = () => {
|
|
10614
10618
|
qe({
|
|
10615
10619
|
source: "framework",
|
|
10616
|
-
table:
|
|
10620
|
+
table: Sy,
|
|
10617
10621
|
timeColumn: "requestedAt",
|
|
10618
10622
|
ttlMs: Xe(process.env.VOLTRO_APPROVALS_TTL_HOURS, 720)
|
|
10619
10623
|
});
|
|
10620
|
-
},
|
|
10624
|
+
}, Ey = (e, t) => e.map((e) => Mn(e) ? { kind: "authenticated" } : Fn(e) ? {
|
|
10621
10625
|
kind: "policy",
|
|
10622
10626
|
action: Vn(e, t),
|
|
10623
10627
|
resourceType: e.resourceType,
|
|
@@ -10627,7 +10631,7 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
10627
10631
|
scope: typeof e.scope == "string" ? [e.scope] : [...e.scope],
|
|
10628
10632
|
mode: e.mode ?? "all",
|
|
10629
10633
|
resource: e.resource?.(t) ?? null
|
|
10630
|
-
}),
|
|
10634
|
+
}), Dy = (e) => e.map((e) => e.kind === "authenticated" ? { authenticated: !0 } : e.kind === "policy" ? {
|
|
10631
10635
|
action: e.action,
|
|
10632
10636
|
resourceType: e.resourceType,
|
|
10633
10637
|
resource: () => e.resource ?? void 0
|
|
@@ -10635,7 +10639,7 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
10635
10639
|
scope: e.scope,
|
|
10636
10640
|
mode: e.mode,
|
|
10637
10641
|
...e.resource === null ? {} : { resource: () => e.resource ?? void 0 }
|
|
10638
|
-
}),
|
|
10642
|
+
}), Oy = (e) => e.flatMap((e) => e.kind === "policy" ? [`${e.resourceType}:${e.action}`] : e.kind === "authenticated" ? ["authenticated"] : [...e.scope]), ky = (e) => {
|
|
10639
10643
|
let t = (e) => {
|
|
10640
10644
|
if (Array.isArray(e)) return e.map(t);
|
|
10641
10645
|
if (typeof e == "object" && e) {
|
|
@@ -10646,7 +10650,7 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
10646
10650
|
return e;
|
|
10647
10651
|
};
|
|
10648
10652
|
return JSON.stringify(t(e) ?? null);
|
|
10649
|
-
},
|
|
10653
|
+
}, Ay = (e) => {
|
|
10650
10654
|
let t = [
|
|
10651
10655
|
e.procedure,
|
|
10652
10656
|
e.requestedBy ?? "",
|
|
@@ -10655,48 +10659,48 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
10655
10659
|
e.nonce ?? ""
|
|
10656
10660
|
].map((e) => `${e.length}:${e}`).join("");
|
|
10657
10661
|
return _t("sha256").update(t, "utf8").digest("hex");
|
|
10658
|
-
},
|
|
10662
|
+
}, jy = (e) => e instanceof Date ? e.toISOString() : typeof e == "string" ? e : (/* @__PURE__ */ new Date(0)).toISOString(), My = (e) => e instanceof Date ? e.getTime() : typeof e == "string" ? Date.parse(e) : 0, Ny = (e) => {
|
|
10659
10663
|
try {
|
|
10660
10664
|
let t = JSON.parse(String(e ?? "[]"));
|
|
10661
10665
|
return Array.isArray(t) ? t : [];
|
|
10662
10666
|
} catch {
|
|
10663
10667
|
return [];
|
|
10664
10668
|
}
|
|
10665
|
-
},
|
|
10669
|
+
}, Py = async (e, t) => (await e.query({
|
|
10666
10670
|
table: "_voltro_approvals",
|
|
10667
10671
|
predicate: j("intentKey", t),
|
|
10668
10672
|
order: []
|
|
10669
|
-
}))[0] ?? null,
|
|
10673
|
+
}))[0] ?? null, Fy = async (e, t) => (await e.query({
|
|
10670
10674
|
table: "_voltro_approvals",
|
|
10671
10675
|
predicate: j("id", t),
|
|
10672
10676
|
order: []
|
|
10673
|
-
}))[0] ?? null,
|
|
10677
|
+
}))[0] ?? null, Iy = async (e, t, n) => {
|
|
10674
10678
|
let r = String(t.intentKey ?? ""), i = r.includes("#") ? r : `${r}#${String(t.id)}`;
|
|
10675
|
-
await e.update(
|
|
10679
|
+
await e.update(Sy, String(t.id), {
|
|
10676
10680
|
...n,
|
|
10677
10681
|
intentKey: i
|
|
10678
10682
|
});
|
|
10679
|
-
},
|
|
10683
|
+
}, Ly = (e) => {
|
|
10680
10684
|
let t = /^(\d+(?:\.\d+)?)\s*(ms|s|m|h|d)$/.exec(e.trim());
|
|
10681
10685
|
if (t === null) return null;
|
|
10682
10686
|
let n = Number(t[1]);
|
|
10683
10687
|
if (!(Number.isFinite(n) && n > 0)) return null;
|
|
10684
10688
|
let r = t[2];
|
|
10685
10689
|
return n * (r === "ms" ? 1 : r === "s" ? 1e3 : r === "m" ? 6e4 : r === "h" ? 36e5 : 864e5);
|
|
10686
|
-
},
|
|
10690
|
+
}, Ry = (e) => {
|
|
10687
10691
|
let t = e.store, n = e.now ?? Date.now, r = e.defaultExpiryMs ?? 864e5;
|
|
10688
|
-
|
|
10692
|
+
Ty();
|
|
10689
10693
|
let i = (e) => {
|
|
10690
10694
|
if (e.expiresIn === void 0) return r;
|
|
10691
|
-
let t =
|
|
10695
|
+
let t = Ly(e.expiresIn);
|
|
10692
10696
|
if (t === null) throw Error(`requiresApproval.expiresIn must be an interval like '4h' / '30m' (got ${JSON.stringify(e.expiresIn)})`);
|
|
10693
10697
|
return t;
|
|
10694
10698
|
}, a = async (e, r, a) => {
|
|
10695
|
-
let o =
|
|
10699
|
+
let o = Ey(e.policy.approvers, e.input), s = P({
|
|
10696
10700
|
kind: "typeid",
|
|
10697
10701
|
prefix: "apv"
|
|
10698
|
-
},
|
|
10699
|
-
await t.insertIgnore(
|
|
10702
|
+
}, Sy), c = n();
|
|
10703
|
+
await t.insertIgnore(Sy, {
|
|
10700
10704
|
id: s,
|
|
10701
10705
|
intentKey: r,
|
|
10702
10706
|
procedure: e.procedure,
|
|
@@ -10705,7 +10709,7 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
10705
10709
|
tenantId: e.subject?.tenantId ?? null,
|
|
10706
10710
|
payload: a,
|
|
10707
10711
|
approverGuards: JSON.stringify(o),
|
|
10708
|
-
approverScopes: JSON.stringify(
|
|
10712
|
+
approverScopes: JSON.stringify(Oy(o)),
|
|
10709
10713
|
reason: e.policy.reason ?? null,
|
|
10710
10714
|
status: "pending",
|
|
10711
10715
|
decidedBy: null,
|
|
@@ -10716,7 +10720,7 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
10716
10720
|
expiresAt: new Date(c + i(e.policy)),
|
|
10717
10721
|
consumedAt: null
|
|
10718
10722
|
}, { conflictColumns: ["intentKey"] });
|
|
10719
|
-
let l = await
|
|
10723
|
+
let l = await Py(t, r);
|
|
10720
10724
|
if (l === null) throw new Nt({
|
|
10721
10725
|
procedure: e.procedure,
|
|
10722
10726
|
message: "the approval intent was written and could not be read back"
|
|
@@ -10725,27 +10729,27 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
10725
10729
|
}, o = (e, t) => new jt({
|
|
10726
10730
|
approvalId: String(e.id),
|
|
10727
10731
|
procedure: String(e.procedure),
|
|
10728
|
-
expiresAt:
|
|
10729
|
-
requiredScopes:
|
|
10732
|
+
expiresAt: jy(e.expiresAt),
|
|
10733
|
+
requiredScopes: Oy(Ny(e.approverGuards)),
|
|
10730
10734
|
reason: e.reason ?? null,
|
|
10731
10735
|
created: t
|
|
10732
10736
|
});
|
|
10733
10737
|
return { admit: async (e) => {
|
|
10734
|
-
let r =
|
|
10738
|
+
let r = ky(e.input), i = Ay({
|
|
10735
10739
|
procedure: e.procedure,
|
|
10736
10740
|
requestedBy: e.subject?.id ?? null,
|
|
10737
10741
|
tenantId: e.subject?.tenantId ?? null,
|
|
10738
10742
|
payload: r,
|
|
10739
10743
|
nonce: e.nonce
|
|
10740
|
-
}), s = await
|
|
10744
|
+
}), s = await Py(t, i);
|
|
10741
10745
|
if (s === null) throw o(await a(e, i, r), !0);
|
|
10742
|
-
let c = String(s.status ?? "pending"), l =
|
|
10743
|
-
if ((c === "pending" || c === "approved") && n() > l) throw await
|
|
10746
|
+
let c = String(s.status ?? "pending"), l = My(s.expiresAt);
|
|
10747
|
+
if ((c === "pending" || c === "approved") && n() > l) throw await Iy(t, s, { status: "expired" }), new Et({
|
|
10744
10748
|
approvalId: String(s.id),
|
|
10745
|
-
expiredAt:
|
|
10749
|
+
expiredAt: jy(s.expiresAt)
|
|
10746
10750
|
});
|
|
10747
10751
|
if (c === "pending") throw o(s, !1);
|
|
10748
|
-
if (c === "rejected") throw await
|
|
10752
|
+
if (c === "rejected") throw await Iy(t, s, {}), new At({
|
|
10749
10753
|
approvalId: String(s.id),
|
|
10750
10754
|
decidedBy: s.decidedBy ?? null,
|
|
10751
10755
|
note: s.note ?? null
|
|
@@ -10756,17 +10760,17 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
10756
10760
|
consumedAt: new Date(n()),
|
|
10757
10761
|
intentKey: `${i}#${String(s.id)}`
|
|
10758
10762
|
}, { where: T(j("id", String(s.id)), j("status", "approved")) }) === 1) return;
|
|
10759
|
-
throw s = await
|
|
10763
|
+
throw s = await Py(t, i), s === null ? o(await a(e, i, r), !0) : o(s, !1);
|
|
10760
10764
|
}
|
|
10761
|
-
throw await
|
|
10765
|
+
throw await Iy(t, s, {}), o(await a(e, i, r), !0);
|
|
10762
10766
|
} };
|
|
10763
|
-
},
|
|
10764
|
-
|
|
10765
|
-
},
|
|
10766
|
-
|
|
10767
|
-
},
|
|
10767
|
+
}, zy, By = (e) => {
|
|
10768
|
+
zy = e;
|
|
10769
|
+
}, Vy = () => zy, Hy = () => {
|
|
10770
|
+
zy = void 0;
|
|
10771
|
+
}, Uy = async (e) => {
|
|
10768
10772
|
if (e.policy === void 0) return;
|
|
10769
|
-
let t =
|
|
10773
|
+
let t = Vy();
|
|
10770
10774
|
if (t === void 0) throw new Nt({
|
|
10771
10775
|
procedure: e.procedure,
|
|
10772
10776
|
message: `${e.procedure} declares \`requiresApproval\` and no approvals gate is installed on this boot path, so the framework cannot record the intent or verify a decision. Refusing the call rather than running it unapproved.`
|
|
@@ -10779,17 +10783,17 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
10779
10783
|
input: e.input,
|
|
10780
10784
|
...e.traceId === void 0 ? {} : { traceId: e.traceId }
|
|
10781
10785
|
});
|
|
10782
|
-
},
|
|
10783
|
-
let n = t.now ?? Date.now, r = await
|
|
10786
|
+
}, Wy = async (e, t) => {
|
|
10787
|
+
let n = t.now ?? Date.now, r = await Fy(e, t.approvalId);
|
|
10784
10788
|
if (r === null) throw new Ot({ approvalId: t.approvalId });
|
|
10785
10789
|
let i = String(r.status ?? "pending");
|
|
10786
10790
|
if (i !== "pending") throw new kt({
|
|
10787
10791
|
approvalId: t.approvalId,
|
|
10788
10792
|
status: i
|
|
10789
10793
|
});
|
|
10790
|
-
if (n() >
|
|
10794
|
+
if (n() > My(r.expiresAt)) throw await Iy(e, r, { status: "expired" }), new Et({
|
|
10791
10795
|
approvalId: t.approvalId,
|
|
10792
|
-
expiredAt:
|
|
10796
|
+
expiredAt: jy(r.expiresAt)
|
|
10793
10797
|
});
|
|
10794
10798
|
let a = t.approver?.id ?? null;
|
|
10795
10799
|
if (a === null) throw new Dt({
|
|
@@ -10801,7 +10805,7 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
10801
10805
|
approvalId: t.approvalId,
|
|
10802
10806
|
subjectId: a
|
|
10803
10807
|
});
|
|
10804
|
-
let s =
|
|
10808
|
+
let s = Dy(Ny(r.approverGuards)), c = await o.runPromise(Cn(t.approver, s, JSON.parse(String(r.payload ?? "null"))));
|
|
10805
10809
|
if (c) throw new Dt({
|
|
10806
10810
|
approvalId: t.approvalId,
|
|
10807
10811
|
required: "_tag" in c && c._tag === "ScopeError" ? c.required : null,
|
|
@@ -10814,7 +10818,7 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
10814
10818
|
decidedAt: new Date(n()),
|
|
10815
10819
|
note: t.note ?? null
|
|
10816
10820
|
}, { where: T(j("id", t.approvalId), j("status", "pending")) }) !== 1) {
|
|
10817
|
-
let n = await
|
|
10821
|
+
let n = await Fy(e, t.approvalId);
|
|
10818
10822
|
throw new kt({
|
|
10819
10823
|
approvalId: t.approvalId,
|
|
10820
10824
|
status: String(n?.status ?? "unknown")
|
|
@@ -10824,47 +10828,47 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
10824
10828
|
approvalId: t.approvalId,
|
|
10825
10829
|
status: l
|
|
10826
10830
|
};
|
|
10827
|
-
},
|
|
10831
|
+
}, Gy = async (e, t, n) => {
|
|
10828
10832
|
let r = t?.id ?? null;
|
|
10829
10833
|
if (r === null) return [];
|
|
10830
10834
|
let i = n?.now ?? Date.now, a = await e.query({
|
|
10831
|
-
table:
|
|
10835
|
+
table: Sy,
|
|
10832
10836
|
predicate: we("status", ["pending", "approved"]),
|
|
10833
10837
|
order: []
|
|
10834
10838
|
}), s = [];
|
|
10835
10839
|
for (let e of a) {
|
|
10836
|
-
if (i() >
|
|
10837
|
-
let n =
|
|
10838
|
-
a || await o.runPromise(Cn(t,
|
|
10840
|
+
if (i() > My(e.expiresAt)) continue;
|
|
10841
|
+
let n = Ny(e.approverGuards), a = (e.requestedBy ?? null) === r, c = a ? "requested" : null;
|
|
10842
|
+
a || await o.runPromise(Cn(t, Dy(n), JSON.parse(String(e.payload ?? "null")))) === null && String(e.status) === "pending" && (c = "to-decide"), c !== null && s.push({
|
|
10839
10843
|
id: String(e.id),
|
|
10840
10844
|
procedure: String(e.procedure),
|
|
10841
10845
|
kind: String(e.kind) === "action" ? "action" : "mutation",
|
|
10842
10846
|
requestedBy: e.requestedBy ?? null,
|
|
10843
10847
|
status: String(e.status ?? "pending"),
|
|
10844
10848
|
reason: e.reason ?? null,
|
|
10845
|
-
requiredScopes:
|
|
10846
|
-
requestedAt:
|
|
10847
|
-
expiresAt:
|
|
10849
|
+
requiredScopes: Oy(n),
|
|
10850
|
+
requestedAt: jy(e.requestedAt),
|
|
10851
|
+
expiresAt: jy(e.expiresAt),
|
|
10848
10852
|
decidedBy: e.decidedBy ?? null,
|
|
10849
|
-
decidedAt: e.decidedAt == null ? null :
|
|
10853
|
+
decidedAt: e.decidedAt == null ? null : jy(e.decidedAt),
|
|
10850
10854
|
note: e.note ?? null,
|
|
10851
10855
|
relation: c
|
|
10852
10856
|
});
|
|
10853
10857
|
}
|
|
10854
10858
|
return s.sort((e, t) => t.requestedAt.localeCompare(e.requestedAt)).slice(0, n?.limit ?? 50);
|
|
10855
|
-
},
|
|
10859
|
+
}, Ky = () => yt(), qy = (e) => e.request?.subject ?? null, Jy = async (e, t) => Gy(t.store, qy(t), { limit: e.limit ?? 50 }), Yy = async (e, t) => Wy(t.store, {
|
|
10856
10860
|
approvalId: e.approvalId,
|
|
10857
10861
|
decision: e.decision,
|
|
10858
|
-
approver:
|
|
10862
|
+
approver: qy(t),
|
|
10859
10863
|
...e.note === void 0 ? {} : { note: e.note }
|
|
10860
|
-
}),
|
|
10864
|
+
}), Xy = (e) => e.request?.subject ?? null, Zy = (e) => {
|
|
10861
10865
|
if (typeof e != "object" || !e) return null;
|
|
10862
10866
|
let t = e.tenantId;
|
|
10863
10867
|
return typeof t == "string" ? t : null;
|
|
10864
|
-
},
|
|
10865
|
-
let n =
|
|
10866
|
-
return t.filter((e) =>
|
|
10867
|
-
},
|
|
10868
|
+
}, Qy = (e, t) => e === null ? !1 : e.type === "system" || jn(e, St) ? !0 : e.type === "anonymous" || e.id == null ? !1 : Zy(t) === (e.tenantId ?? null), $y = (e, t) => {
|
|
10869
|
+
let n = Xy(e);
|
|
10870
|
+
return t.filter((e) => Qy(n, e.subject));
|
|
10871
|
+
}, eb = (e, t, n) => Number.isFinite(e) && e !== void 0 ? Math.min(Math.max(Math.floor(e), 1), n) : t, tb = (e, t) => ({
|
|
10868
10872
|
table: "_voltro_workflow_runs",
|
|
10869
10873
|
order: [{
|
|
10870
10874
|
column: "startedAt",
|
|
@@ -10874,16 +10878,16 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
10874
10878
|
take: t,
|
|
10875
10879
|
skip: void 0,
|
|
10876
10880
|
projection: void 0
|
|
10877
|
-
}),
|
|
10878
|
-
let n = (await e.store.query(
|
|
10879
|
-
return n !== void 0 &&
|
|
10880
|
-
},
|
|
10881
|
-
let n = await t.store.query(
|
|
10882
|
-
return
|
|
10883
|
-
},
|
|
10881
|
+
}), nb = async (e, t) => {
|
|
10882
|
+
let n = (await e.store.query(tb(j("id", t), 1)))[0];
|
|
10883
|
+
return n !== void 0 && Qy(Xy(e), n.subject) ? n : void 0;
|
|
10884
|
+
}, rb = async (e, t) => {
|
|
10885
|
+
let n = await t.store.query(tb(j("id", e.id), 1));
|
|
10886
|
+
return $y(t, n.length > 0 ? n : await t.store.query(tb(j("executionId", e.id), 1)));
|
|
10887
|
+
}, ib = async (e, t) => {
|
|
10884
10888
|
let n = [...e.tag === void 0 ? [] : [j("tag", e.tag)], ...e.status === void 0 ? [] : [j("status", e.status)]], r = n.length === 0 ? void 0 : n.length === 1 ? n[0] : T(...n);
|
|
10885
|
-
return
|
|
10886
|
-
},
|
|
10889
|
+
return $y(t, await t.store.query(tb(r, eb(e.limit, 100, 500))));
|
|
10890
|
+
}, ab = async (e, t) => await nb(t, e.runId) === void 0 ? [] : t.store.query({
|
|
10887
10891
|
table: "_voltro_workflow_run_steps",
|
|
10888
10892
|
order: [{
|
|
10889
10893
|
column: "startedAt",
|
|
@@ -10893,7 +10897,7 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
10893
10897
|
take: 1e3,
|
|
10894
10898
|
skip: void 0,
|
|
10895
10899
|
projection: void 0
|
|
10896
|
-
}),
|
|
10900
|
+
}), ob = async (e, t) => await nb(t, e.runId) === void 0 ? [] : t.store.query({
|
|
10897
10901
|
table: "_voltro_workflow_run_events",
|
|
10898
10902
|
order: [{
|
|
10899
10903
|
column: "occurredAt",
|
|
@@ -10903,7 +10907,7 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
10903
10907
|
take: 1e3,
|
|
10904
10908
|
skip: void 0,
|
|
10905
10909
|
projection: void 0
|
|
10906
|
-
}),
|
|
10910
|
+
}), sb = (e, t) => ({
|
|
10907
10911
|
table: "_voltro_workflow_events",
|
|
10908
10912
|
order: [{
|
|
10909
10913
|
column: "occurredAt",
|
|
@@ -10913,12 +10917,12 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
10913
10917
|
take: t,
|
|
10914
10918
|
skip: void 0,
|
|
10915
10919
|
projection: void 0
|
|
10916
|
-
}),
|
|
10920
|
+
}), cb = async (e, t) => {
|
|
10917
10921
|
let n = e.name === void 0 ? void 0 : j("name", e.name);
|
|
10918
|
-
return
|
|
10919
|
-
},
|
|
10920
|
-
let n = (await t.store.query(
|
|
10921
|
-
return n === void 0 || !
|
|
10922
|
+
return $y(t, await t.store.query(sb(n, eb(e.limit, 100, 500))));
|
|
10923
|
+
}, lb = async (e, t) => {
|
|
10924
|
+
let n = (await t.store.query(sb(j("id", e.eventId), 1)))[0];
|
|
10925
|
+
return n === void 0 || !Qy(Xy(t), n.subject) ? [] : t.store.query({
|
|
10922
10926
|
table: "_voltro_workflow_event_deliveries",
|
|
10923
10927
|
order: [{
|
|
10924
10928
|
column: "createdAt",
|
|
@@ -10929,29 +10933,29 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
10929
10933
|
skip: void 0,
|
|
10930
10934
|
projection: void 0
|
|
10931
10935
|
});
|
|
10932
|
-
},
|
|
10936
|
+
}, ub = (e = process.env) => {
|
|
10933
10937
|
let t = (e.VOLTRO_TIMELINE ?? "").toLowerCase();
|
|
10934
10938
|
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";
|
|
10935
|
-
},
|
|
10939
|
+
}, db = /pass(word)?|secret|token|api[_-]?key|authorization|cookie|ssn|credit[_-]?card|card[_-]?number|cvv|encrypted/i, fb = "«redacted»", pb = (e) => {
|
|
10936
10940
|
if (e == null) return null;
|
|
10937
10941
|
let t = {};
|
|
10938
|
-
for (let [n, r] of Object.entries(e)) t[n] =
|
|
10942
|
+
for (let [n, r] of Object.entries(e)) t[n] = db.test(n) ? fb : r;
|
|
10939
10943
|
return t;
|
|
10940
|
-
},
|
|
10944
|
+
}, mb = (e) => {
|
|
10941
10945
|
let t = e?.id;
|
|
10942
10946
|
return typeof t == "string" ? t : void 0;
|
|
10943
|
-
},
|
|
10947
|
+
}, hb = (e, t) => {
|
|
10944
10948
|
if (t.op === "insert") {
|
|
10945
|
-
let n =
|
|
10949
|
+
let n = mb(t.new);
|
|
10946
10950
|
return n === void 0 ? e : e.filter((e) => e.id !== n);
|
|
10947
10951
|
}
|
|
10948
10952
|
if (t.op === "update") {
|
|
10949
10953
|
if (t.old == null) return e;
|
|
10950
|
-
let n =
|
|
10954
|
+
let n = mb(t.new) ?? mb(t.old);
|
|
10951
10955
|
return e.map((e) => e.id === n ? t.old : e);
|
|
10952
10956
|
}
|
|
10953
10957
|
return t.old == null ? e : [...e, t.old];
|
|
10954
|
-
},
|
|
10958
|
+
}, gb = class {
|
|
10955
10959
|
mode;
|
|
10956
10960
|
capacity;
|
|
10957
10961
|
now;
|
|
@@ -10971,8 +10975,8 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
10971
10975
|
ts: this.now(),
|
|
10972
10976
|
table: e.table,
|
|
10973
10977
|
op: e.op,
|
|
10974
|
-
old:
|
|
10975
|
-
new:
|
|
10978
|
+
old: pb(e.old),
|
|
10979
|
+
new: pb(e.new),
|
|
10976
10980
|
tenantId: n
|
|
10977
10981
|
}), this.ring.length > this.capacity && this.ring.shift(), t;
|
|
10978
10982
|
}
|
|
@@ -10985,23 +10989,23 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
10985
10989
|
}
|
|
10986
10990
|
replay(e, t, n) {
|
|
10987
10991
|
let r = this.ring.filter((n) => n.table === e && n.seq > t).sort((e, t) => t.seq - e.seq), i = n;
|
|
10988
|
-
for (let e of r) i =
|
|
10992
|
+
for (let e of r) i = hb(i, e);
|
|
10989
10993
|
return i;
|
|
10990
10994
|
}
|
|
10991
|
-
},
|
|
10992
|
-
|
|
10993
|
-
},
|
|
10994
|
-
let t =
|
|
10995
|
+
}, _b, vb = () => (_b === void 0 && (_b = new gb(ub())), _b), yb = (e) => {
|
|
10996
|
+
_b = e;
|
|
10997
|
+
}, bb = (e) => {
|
|
10998
|
+
let t = vb();
|
|
10995
10999
|
if (t.enabled) try {
|
|
10996
11000
|
t.record(e);
|
|
10997
11001
|
} catch {}
|
|
10998
|
-
},
|
|
11002
|
+
}, xb = /* @__PURE__ */ new Set([
|
|
10999
11003
|
"count",
|
|
11000
11004
|
"sum",
|
|
11001
11005
|
"avg",
|
|
11002
11006
|
"min",
|
|
11003
11007
|
"max"
|
|
11004
|
-
]),
|
|
11008
|
+
]), Sb = (e) => {
|
|
11005
11009
|
if (e.joins !== void 0 && e.joins.length > 0) return {
|
|
11006
11010
|
maintainable: !1,
|
|
11007
11011
|
reason: "joins are not maintainable in v1"
|
|
@@ -11023,7 +11027,7 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
11023
11027
|
reason: "v1 maintains exactly one aggregation"
|
|
11024
11028
|
};
|
|
11025
11029
|
let t = e.aggregations[0];
|
|
11026
|
-
return
|
|
11030
|
+
return xb.has(t.op) ? t.op !== "count" && (t.column === void 0 || t.column.length === 0) ? {
|
|
11027
11031
|
maintainable: !1,
|
|
11028
11032
|
reason: `op '${t.op}' requires a column`
|
|
11029
11033
|
} : {
|
|
@@ -11037,7 +11041,7 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
11037
11041
|
maintainable: !1,
|
|
11038
11042
|
reason: `op '${t.op}' is not maintainable`
|
|
11039
11043
|
};
|
|
11040
|
-
},
|
|
11044
|
+
}, Cb = "\0", wb = (e, t) => t === void 0 || t.length === 0 ? "" : t.map((t) => JSON.stringify(e[t] ?? null)).join(Cb), Tb = (e, t) => t === void 0 ? 0 : Number(e[t] ?? 0), Eb = (e, t) => {
|
|
11041
11045
|
switch (e.op) {
|
|
11042
11046
|
case "count": return t.count;
|
|
11043
11047
|
case "sum": return t.sum ?? 0;
|
|
@@ -11045,10 +11049,10 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
11045
11049
|
case "min":
|
|
11046
11050
|
case "max": return t.count > 0 ? t.extreme ?? null : null;
|
|
11047
11051
|
}
|
|
11048
|
-
},
|
|
11052
|
+
}, Db = (e, t) => {
|
|
11049
11053
|
let n = /* @__PURE__ */ new Map();
|
|
11050
11054
|
for (let r of t) {
|
|
11051
|
-
let t =
|
|
11055
|
+
let t = wb(r, e.groupBy), i = n.get(t), a = Tb(r, e.column);
|
|
11052
11056
|
if (i === void 0) n.set(t, {
|
|
11053
11057
|
count: 1,
|
|
11054
11058
|
...e.op === "sum" || e.op === "avg" ? { sum: a } : {},
|
|
@@ -11064,19 +11068,19 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
11064
11068
|
}
|
|
11065
11069
|
}
|
|
11066
11070
|
return n;
|
|
11067
|
-
},
|
|
11071
|
+
}, Ob = (e, t) => [...t.entries()].map(([t, n]) => ({
|
|
11068
11072
|
groupKey: t,
|
|
11069
|
-
value:
|
|
11070
|
-
})),
|
|
11073
|
+
value: Eb(e, n)
|
|
11074
|
+
})), kb = (e, t, n) => {
|
|
11071
11075
|
let r = new Map(t), i = /* @__PURE__ */ new Set(), a = (t) => {
|
|
11072
|
-
let n =
|
|
11076
|
+
let n = wb(t, e.groupBy), a = r.get(n);
|
|
11073
11077
|
if (a === void 0) return;
|
|
11074
11078
|
let o = a.count - 1;
|
|
11075
11079
|
if (o <= 0) {
|
|
11076
11080
|
r.delete(n);
|
|
11077
11081
|
return;
|
|
11078
11082
|
}
|
|
11079
|
-
let s =
|
|
11083
|
+
let s = Tb(t, e.column);
|
|
11080
11084
|
e.op === "min" || e.op === "max" ? (a.extreme !== void 0 && s === a.extreme && i.add(n), r.set(n, {
|
|
11081
11085
|
count: o,
|
|
11082
11086
|
...a.extreme === void 0 ? {} : { extreme: a.extreme }
|
|
@@ -11085,7 +11089,7 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
11085
11089
|
...e.op === "sum" || e.op === "avg" ? { sum: (a.sum ?? 0) - s } : {}
|
|
11086
11090
|
});
|
|
11087
11091
|
}, o = (t) => {
|
|
11088
|
-
let n =
|
|
11092
|
+
let n = wb(t, e.groupBy), i = r.get(n), a = Tb(t, e.column);
|
|
11089
11093
|
if (i === void 0) {
|
|
11090
11094
|
r.set(n, {
|
|
11091
11095
|
count: 1,
|
|
@@ -11105,15 +11109,15 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
11105
11109
|
state: r,
|
|
11106
11110
|
rescanGroups: [...i]
|
|
11107
11111
|
};
|
|
11108
|
-
},
|
|
11112
|
+
}, Ab = (e, t, n, r) => {
|
|
11109
11113
|
if (n.length === 0) return t;
|
|
11110
|
-
let i = new Set(n), a =
|
|
11114
|
+
let i = new Set(n), a = Db(e, r.filter((t) => i.has(wb(t, e.groupBy)))), o = new Map(t);
|
|
11111
11115
|
for (let e of i) {
|
|
11112
11116
|
let t = a.get(e);
|
|
11113
11117
|
t === void 0 ? o.delete(e) : o.set(e, t);
|
|
11114
11118
|
}
|
|
11115
11119
|
return o;
|
|
11116
|
-
},
|
|
11120
|
+
}, jb = class {
|
|
11117
11121
|
shape;
|
|
11118
11122
|
state = /* @__PURE__ */ new Map();
|
|
11119
11123
|
groups = /* @__PURE__ */ new Map();
|
|
@@ -11121,35 +11125,35 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
11121
11125
|
this.shape = e;
|
|
11122
11126
|
}
|
|
11123
11127
|
seed(e) {
|
|
11124
|
-
this.state =
|
|
11128
|
+
this.state = Db(this.shape, e), this.groups.clear();
|
|
11125
11129
|
for (let t of e) {
|
|
11126
|
-
let e =
|
|
11130
|
+
let e = wb(t, this.shape.groupBy);
|
|
11127
11131
|
this.groups.has(e) || this.groups.set(e, this.groupValues(t));
|
|
11128
11132
|
}
|
|
11129
11133
|
}
|
|
11130
11134
|
applyChange(e) {
|
|
11131
11135
|
let t = e.new;
|
|
11132
11136
|
if (t) {
|
|
11133
|
-
let e =
|
|
11137
|
+
let e = wb(t, this.shape.groupBy);
|
|
11134
11138
|
this.groups.has(e) || this.groups.set(e, this.groupValues(t));
|
|
11135
11139
|
}
|
|
11136
|
-
let n =
|
|
11140
|
+
let n = kb(this.shape, this.state, e);
|
|
11137
11141
|
this.state = n.state;
|
|
11138
11142
|
for (let e of this.groups.keys()) this.state.has(e) || this.groups.delete(e);
|
|
11139
11143
|
return n.rescanGroups;
|
|
11140
11144
|
}
|
|
11141
11145
|
resolveRescan(e, t) {
|
|
11142
11146
|
if (e.length === 0) return;
|
|
11143
|
-
this.state =
|
|
11147
|
+
this.state = Ab(this.shape, this.state, e, t);
|
|
11144
11148
|
let n = new Set(e);
|
|
11145
11149
|
for (let e of t) {
|
|
11146
|
-
let t =
|
|
11150
|
+
let t = wb(e, this.shape.groupBy);
|
|
11147
11151
|
n.has(t) && this.state.has(t) && !this.groups.has(t) && this.groups.set(t, this.groupValues(e));
|
|
11148
11152
|
}
|
|
11149
11153
|
for (let e of n) this.state.has(e) || this.groups.delete(e);
|
|
11150
11154
|
}
|
|
11151
11155
|
materialize() {
|
|
11152
|
-
return
|
|
11156
|
+
return Ob(this.shape, this.state).map((e) => ({
|
|
11153
11157
|
groupKey: e.groupKey,
|
|
11154
11158
|
group: this.groups.get(e.groupKey) ?? {},
|
|
11155
11159
|
value: e.value
|
|
@@ -11162,7 +11166,7 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
11162
11166
|
for (let r of t) n[r] = e[r];
|
|
11163
11167
|
return n;
|
|
11164
11168
|
}
|
|
11165
|
-
},
|
|
11169
|
+
}, Mb = R("_voltro_rebac_tuples", {
|
|
11166
11170
|
id: I({ prefix: "rbct" }),
|
|
11167
11171
|
subjectId: z(),
|
|
11168
11172
|
relation: z(),
|
|
@@ -11174,7 +11178,7 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
11174
11178
|
"subjectId",
|
|
11175
11179
|
"resourceType",
|
|
11176
11180
|
"resourceId"
|
|
11177
|
-
]),
|
|
11181
|
+
]), Nb = async (e, t, n, r) => t === null ? [] : (await e.query({
|
|
11178
11182
|
table: "_voltro_rebac_tuples",
|
|
11179
11183
|
predicate: T(j("subjectId", t), j("resourceType", n), j("resourceId", r)),
|
|
11180
11184
|
order: [],
|
|
@@ -11186,16 +11190,16 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
11186
11190
|
relation: e.relation,
|
|
11187
11191
|
resourceType: e.resourceType,
|
|
11188
11192
|
resourceId: e.resourceId
|
|
11189
|
-
})),
|
|
11193
|
+
})), Pb = (e) => ({
|
|
11190
11194
|
id: e.id,
|
|
11191
11195
|
tenantId: e.tenantId,
|
|
11192
11196
|
...e.scopes === void 0 ? {} : { scopes: e.scopes }
|
|
11193
|
-
}),
|
|
11194
|
-
let n = t.getPolicy ??
|
|
11197
|
+
}), Fb = (e, t) => {
|
|
11198
|
+
let n = t.getPolicy ?? Fh;
|
|
11195
11199
|
return (r, i) => {
|
|
11196
11200
|
let a = e[i.tag];
|
|
11197
11201
|
if (a === void 0) return r;
|
|
11198
|
-
let s = n(a.resourceType), c = (e) => o.fail(new
|
|
11202
|
+
let s = n(a.resourceType), c = (e) => o.fail(new Mh({
|
|
11199
11203
|
action: a.action,
|
|
11200
11204
|
resourceType: a.resourceType,
|
|
11201
11205
|
resourceId: e
|
|
@@ -11203,17 +11207,17 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
11203
11207
|
if (s === void 0) return c("");
|
|
11204
11208
|
let l = a.resourceId(i.input);
|
|
11205
11209
|
if (l === null || l === "") return c("");
|
|
11206
|
-
let u =
|
|
11210
|
+
let u = Pb(i.subject), d = {
|
|
11207
11211
|
type: a.resourceType,
|
|
11208
11212
|
id: l,
|
|
11209
11213
|
tenantId: i.subject.tenantId
|
|
11210
11214
|
};
|
|
11211
|
-
return o.flatMap(o.promise(async () => t.loadTuples(u.id, a.resourceType, l)), (e) =>
|
|
11215
|
+
return o.flatMap(o.promise(async () => t.loadTuples(u.id, a.resourceType, l)), (e) => Vh(u, a.action, d, {
|
|
11212
11216
|
policy: s,
|
|
11213
11217
|
tuples: e
|
|
11214
11218
|
}) ? r : c(l));
|
|
11215
11219
|
};
|
|
11216
|
-
},
|
|
11220
|
+
}, Ib = async (e, t, n) => t === null ? [] : (await e.query({
|
|
11217
11221
|
table: "_voltro_rebac_tuples",
|
|
11218
11222
|
predicate: T(j("subjectId", t), j("resourceType", n)),
|
|
11219
11223
|
order: [],
|
|
@@ -11225,18 +11229,18 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
11225
11229
|
relation: e.relation,
|
|
11226
11230
|
resourceType: e.resourceType,
|
|
11227
11231
|
resourceId: e.resourceId
|
|
11228
|
-
})),
|
|
11229
|
-
let t = e.getPolicy ??
|
|
11232
|
+
})), Lb = (e) => {
|
|
11233
|
+
let t = e.getPolicy ?? Fh;
|
|
11230
11234
|
return async (n, r, i, a) => {
|
|
11231
11235
|
let o = t(r);
|
|
11232
11236
|
if (o === void 0) return [];
|
|
11233
|
-
let s =
|
|
11234
|
-
return
|
|
11237
|
+
let s = Pb(n);
|
|
11238
|
+
return Uh(s, i, r, a, {
|
|
11235
11239
|
policy: o,
|
|
11236
11240
|
tuples: await e.loadSubjectTuples(s.id, r)
|
|
11237
11241
|
});
|
|
11238
11242
|
};
|
|
11239
|
-
},
|
|
11243
|
+
}, Rb = (e) => {
|
|
11240
11244
|
if (typeof e.name != "string" || e.name.length === 0) throw Error("defineReaction: a non-empty `name` is required");
|
|
11241
11245
|
if (e.watch === void 0 || typeof e.watch.table != "string" || e.watch.table.length === 0) throw Error(`reaction '${e.name}': watch.table is required`);
|
|
11242
11246
|
if (e.act === void 0 || e.act.kind !== "agent" && e.act.kind !== "workflow") throw Error(`reaction '${e.name}': act must be { kind: 'agent' | 'workflow', … }`);
|
|
@@ -11244,14 +11248,14 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
11244
11248
|
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`);
|
|
11245
11249
|
if (e.guards.costBudgetUsd !== void 0 && e.guards.costBudgetUsd < 0) throw Error(`reaction '${e.name}': guards.costBudgetUsd must be >= 0`);
|
|
11246
11250
|
return e;
|
|
11247
|
-
},
|
|
11251
|
+
}, zb = (e, t) => e === void 0 ? !0 : Array.isArray(e) ? e.includes(t) : e === t, Bb = (e) => e.new?.tenantId ?? e.old?.tenantId ?? null, Vb = class {
|
|
11248
11252
|
hits = /* @__PURE__ */ new Map();
|
|
11249
11253
|
allow(e, t, n, r) {
|
|
11250
11254
|
let i = r - n, a = (this.hits.get(e) ?? []).filter((e) => e > i);
|
|
11251
11255
|
return a.length >= t ? (this.hits.set(e, a), !1) : (a.push(r), this.hits.set(e, a), !0);
|
|
11252
11256
|
}
|
|
11253
|
-
},
|
|
11254
|
-
if (t.table !== e.watch.table || !
|
|
11257
|
+
}, Hb = (e, t, n, r, i) => `${e}\u0000${t}\u0000${Math.floor(i / n)}\u0000${r}`, Ub = async (e, t, n) => {
|
|
11258
|
+
if (t.table !== e.watch.table || !zb(e.watch.on, t.op)) return "skipped-op";
|
|
11255
11259
|
if (e.when !== void 0 && !e.when(t)) return "skipped-when";
|
|
11256
11260
|
let r = `${e.name}:${e.guards.dedupeKey(t)}`;
|
|
11257
11261
|
if (!await n.dedupe.claim(r)) return "skipped-dedupe";
|
|
@@ -11260,23 +11264,23 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
11260
11264
|
let r = n.now?.() ?? Date.now(), a = i.key === void 0 ? "" : i.key(t);
|
|
11261
11265
|
if (n.claimRateSlot !== void 0) {
|
|
11262
11266
|
let t = !1;
|
|
11263
|
-
for (let o = 0; o < i.limit; o++) if (await n.claimRateSlot(
|
|
11267
|
+
for (let o = 0; o < i.limit; o++) if (await n.claimRateSlot(Hb(e.name, a, i.windowMs, o, r))) {
|
|
11264
11268
|
t = !0;
|
|
11265
11269
|
break;
|
|
11266
11270
|
}
|
|
11267
11271
|
if (!t) return "skipped-ratelimit";
|
|
11268
11272
|
} else if (n.rateLimiter !== void 0 && !n.rateLimiter.allow(`${e.name} ${a}`, i.limit, i.windowMs, r)) return "skipped-ratelimit";
|
|
11269
11273
|
}
|
|
11270
|
-
let a =
|
|
11274
|
+
let a = Bb(t);
|
|
11271
11275
|
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, {
|
|
11272
11276
|
id: a,
|
|
11273
11277
|
via: "agent"
|
|
11274
11278
|
}), "acted");
|
|
11275
|
-
},
|
|
11279
|
+
}, Wb = /* @__PURE__ */ new Set([
|
|
11276
11280
|
"info",
|
|
11277
11281
|
"warn",
|
|
11278
11282
|
"critical"
|
|
11279
|
-
]), Q = (e, t) => /* @__PURE__ */ Error(`defineExpectation(${JSON.stringify(e)}): ${t}`),
|
|
11283
|
+
]), Q = (e, t) => /* @__PURE__ */ Error(`defineExpectation(${JSON.stringify(e)}): ${t}`), Gb = (e) => {
|
|
11280
11284
|
let t = e.name;
|
|
11281
11285
|
if (typeof t != "string" || t.length === 0) throw Error("defineExpectation: a non-empty `name` is required");
|
|
11282
11286
|
if (e.on === void 0 || typeof e.on.table != "string" || e.on.table.length === 0) throw Q(t, "on.table is required — the table whose writes drive the expectation");
|
|
@@ -11305,7 +11309,7 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
11305
11309
|
default: throw Q(t, `unknown invariant kind ${JSON.stringify(n.kind)}`);
|
|
11306
11310
|
}
|
|
11307
11311
|
let r = e.severity ?? "warn";
|
|
11308
|
-
if (!
|
|
11312
|
+
if (!Wb.has(r)) throw Q(t, `severity must be one of info | warn | critical (got ${JSON.stringify(r)})`);
|
|
11309
11313
|
return {
|
|
11310
11314
|
_voltroExpectation: !0,
|
|
11311
11315
|
name: t,
|
|
@@ -11317,9 +11321,9 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
11317
11321
|
severity: r,
|
|
11318
11322
|
...e.description === void 0 ? {} : { description: e.description }
|
|
11319
11323
|
};
|
|
11320
|
-
},
|
|
11321
|
-
return (yield*
|
|
11322
|
-
}),
|
|
11324
|
+
}, Kb = (e) => typeof e == "object" && !!e && e._voltroExpectation === !0, qb = class extends n.Tag("@voltro/ExpectationRegistry")() {}, Jb = (e) => o.gen(function* () {
|
|
11325
|
+
return (yield* qb).get(e.name);
|
|
11326
|
+
}), Yb = (e) => {
|
|
11323
11327
|
if (e instanceof Date) return e.getTime();
|
|
11324
11328
|
if (typeof e == "number" && Number.isFinite(e)) return e;
|
|
11325
11329
|
if (typeof e == "string" && e.length > 0) {
|
|
@@ -11327,20 +11331,20 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
11327
11331
|
return Number.isNaN(t) ? null : t;
|
|
11328
11332
|
}
|
|
11329
11333
|
return null;
|
|
11330
|
-
},
|
|
11334
|
+
}, Xb = class {
|
|
11331
11335
|
maxAgeMs;
|
|
11332
11336
|
timeDependent = !0;
|
|
11333
11337
|
maintainer;
|
|
11334
11338
|
column;
|
|
11335
11339
|
constructor(e, t) {
|
|
11336
|
-
this.maxAgeMs = t, this.column = e, this.maintainer = new
|
|
11340
|
+
this.maxAgeMs = t, this.column = e, this.maintainer = new jb({
|
|
11337
11341
|
op: "max",
|
|
11338
11342
|
column: e
|
|
11339
11343
|
});
|
|
11340
11344
|
}
|
|
11341
11345
|
project(e) {
|
|
11342
11346
|
if (e == null) return null;
|
|
11343
|
-
let t =
|
|
11347
|
+
let t = Yb(e[this.column]);
|
|
11344
11348
|
return t === null ? null : {
|
|
11345
11349
|
...e,
|
|
11346
11350
|
[this.column]: t
|
|
@@ -11382,7 +11386,7 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
11382
11386
|
violated: n > this.maxAgeMs
|
|
11383
11387
|
};
|
|
11384
11388
|
}
|
|
11385
|
-
},
|
|
11389
|
+
}, Zb = class {
|
|
11386
11390
|
matches;
|
|
11387
11391
|
reduce;
|
|
11388
11392
|
timeDependent = !1;
|
|
@@ -11407,16 +11411,16 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
11407
11411
|
read() {
|
|
11408
11412
|
return this.reduce(this.total, this.matching);
|
|
11409
11413
|
}
|
|
11410
|
-
},
|
|
11411
|
-
if (
|
|
11414
|
+
}, Qb = (e) => e == null, $b = (e, t, n) => {
|
|
11415
|
+
if (Qb(e)) return !1;
|
|
11412
11416
|
let r = Number(e);
|
|
11413
11417
|
return Number.isNaN(r) ? !1 : t !== void 0 && r < t || n !== void 0 && r > n;
|
|
11414
|
-
},
|
|
11418
|
+
}, ex = (e) => {
|
|
11415
11419
|
switch (e.kind) {
|
|
11416
|
-
case "freshness": return new
|
|
11420
|
+
case "freshness": return new Xb(e.column, e.maxAgeMs);
|
|
11417
11421
|
case "nullRate": {
|
|
11418
11422
|
let t = e.column, n = e.maxRate;
|
|
11419
|
-
return new
|
|
11423
|
+
return new Zb((e) => Qb(e[t]), (e, t) => {
|
|
11420
11424
|
let r = e > 0 ? t / e : 0;
|
|
11421
11425
|
return {
|
|
11422
11426
|
metric: r,
|
|
@@ -11427,7 +11431,7 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
11427
11431
|
}
|
|
11428
11432
|
case "rowCount": {
|
|
11429
11433
|
let { min: t, max: n } = e;
|
|
11430
|
-
return new
|
|
11434
|
+
return new Zb(() => !1, (e) => ({
|
|
11431
11435
|
metric: e,
|
|
11432
11436
|
threshold: n ?? t ?? null,
|
|
11433
11437
|
violated: t !== void 0 && e < t || n !== void 0 && e > n
|
|
@@ -11435,7 +11439,7 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
11435
11439
|
}
|
|
11436
11440
|
case "valueBounds": {
|
|
11437
11441
|
let { column: t, min: n, max: r, maxViolationRate: i } = e;
|
|
11438
|
-
return new
|
|
11442
|
+
return new Zb((e) => $b(e[t], n, r), (e, t) => {
|
|
11439
11443
|
if (i !== void 0) {
|
|
11440
11444
|
let n = e > 0 ? t / e : 0;
|
|
11441
11445
|
return {
|
|
@@ -11452,13 +11456,13 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
11452
11456
|
});
|
|
11453
11457
|
}
|
|
11454
11458
|
}
|
|
11455
|
-
},
|
|
11459
|
+
}, tx = (e) => ({
|
|
11456
11460
|
table: e.table,
|
|
11457
11461
|
op: e.op,
|
|
11458
11462
|
traceId: e.traceId ?? null,
|
|
11459
11463
|
subjectId: e.subjectId ?? null,
|
|
11460
11464
|
procedure: e.procedure ?? null
|
|
11461
|
-
}),
|
|
11465
|
+
}), nx = (e, t) => !t || e.metric === null ? "unknown" : e.violated ? "violated" : "holding", rx = class {
|
|
11462
11466
|
def;
|
|
11463
11467
|
deps;
|
|
11464
11468
|
engine;
|
|
@@ -11471,7 +11475,7 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
11471
11475
|
lastEvaluatedAt = null;
|
|
11472
11476
|
lastCause = null;
|
|
11473
11477
|
constructor(e, t) {
|
|
11474
|
-
this.def = e, this.deps = t, this.engine =
|
|
11478
|
+
this.def = e, this.deps = t, this.engine = ex(e.invariant), this.now = t.now ?? Date.now, this.threshold = null;
|
|
11475
11479
|
}
|
|
11476
11480
|
get timeDependent() {
|
|
11477
11481
|
return this.engine.timeDependent;
|
|
@@ -11500,13 +11504,13 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
11500
11504
|
let e = (await this.deps.queryBase()).filter((e) => this.inScope(e));
|
|
11501
11505
|
this.engine.resolveRescan(i, e);
|
|
11502
11506
|
}
|
|
11503
|
-
return this.commitReading(this.engine.read(this.now()), !0,
|
|
11507
|
+
return this.commitReading(this.engine.read(this.now()), !0, tx(e));
|
|
11504
11508
|
}
|
|
11505
11509
|
tick() {
|
|
11506
11510
|
return this.seeded ? this.commitReading(this.engine.read(this.now()), !0, null) : null;
|
|
11507
11511
|
}
|
|
11508
11512
|
commitReading(e, t, n) {
|
|
11509
|
-
let r = this.status, i =
|
|
11513
|
+
let r = this.status, i = nx(e, this.seeded);
|
|
11510
11514
|
if (this.metric = e.metric, this.threshold = e.threshold, this.lastEvaluatedAt = new Date(this.now()), i !== r) {
|
|
11511
11515
|
if (this.status = i, this.since = this.lastEvaluatedAt, i === "violated" && (this.lastCause = n), t && i === "violated" && r !== "violated") return {
|
|
11512
11516
|
kind: "violated",
|
|
@@ -11536,7 +11540,7 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
11536
11540
|
...this.def.description === void 0 ? {} : { description: this.def.description }
|
|
11537
11541
|
};
|
|
11538
11542
|
}
|
|
11539
|
-
},
|
|
11543
|
+
}, ix = (e) => {
|
|
11540
11544
|
let t = e.now ?? Date.now, n = e.log, r = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Map(), a = (e) => {
|
|
11541
11545
|
for (let t of r) try {
|
|
11542
11546
|
t(e);
|
|
@@ -11553,7 +11557,7 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
11553
11557
|
}), s = /* @__PURE__ */ new Map(), c = !1;
|
|
11554
11558
|
for (let { definition: r } of e.discovered) {
|
|
11555
11559
|
if (i.has(r.name)) throw Error(`expectation: duplicate name '${r.name}' — names must be unique across all expectations`);
|
|
11556
|
-
let e = new
|
|
11560
|
+
let e = new rx(r, {
|
|
11557
11561
|
queryBase: o(r.on.table),
|
|
11558
11562
|
now: t,
|
|
11559
11563
|
...n === void 0 ? {} : { log: n }
|
|
@@ -11607,30 +11611,30 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
11607
11611
|
registered: [...i.keys()],
|
|
11608
11612
|
runTick: u
|
|
11609
11613
|
};
|
|
11610
|
-
},
|
|
11614
|
+
}, ax = /* @__PURE__ */ new Set([
|
|
11611
11615
|
"info",
|
|
11612
11616
|
"warn",
|
|
11613
11617
|
"critical"
|
|
11614
|
-
]),
|
|
11618
|
+
]), ox = /* @__PURE__ */ new Set(["observe", "suspend"]), sx = (e, t) => /* @__PURE__ */ Error(`defineCostBudget(${JSON.stringify(e)}): ${t}`), cx = (e) => {
|
|
11615
11619
|
let t = /^(\d+(?:\.\d+)?)\s*(ms|s|m|h|d)$/.exec(e.trim());
|
|
11616
11620
|
if (t === null) return null;
|
|
11617
11621
|
let n = Number(t[1]);
|
|
11618
11622
|
if (!(Number.isFinite(n) && n > 0)) return null;
|
|
11619
11623
|
let r = t[2];
|
|
11620
11624
|
return n * (r === "ms" ? 1 : r === "s" ? 1e3 : r === "m" ? 6e4 : r === "h" ? 36e5 : 864e5);
|
|
11621
|
-
},
|
|
11625
|
+
}, lx = (e) => {
|
|
11622
11626
|
let t = e.name;
|
|
11623
11627
|
if (typeof t != "string" || t.length === 0) throw Error("defineCostBudget: a non-empty `name` is required");
|
|
11624
|
-
if (!(typeof e.limit == "number" && Number.isFinite(e.limit) && e.limit > 0)) throw
|
|
11625
|
-
if (e.unit !== void 0 && (typeof e.unit != "string" || e.unit.length === 0)) throw
|
|
11628
|
+
if (!(typeof e.limit == "number" && Number.isFinite(e.limit) && e.limit > 0)) throw sx(t, "a positive, finite `limit` is required");
|
|
11629
|
+
if (e.unit !== void 0 && (typeof e.unit != "string" || e.unit.length === 0)) throw sx(t, "unit, when present, must be a non-empty string");
|
|
11626
11630
|
let n = e.warnAt ?? .8;
|
|
11627
|
-
if (!(typeof n == "number" && n >= 0 && n <= 1)) throw
|
|
11631
|
+
if (!(typeof n == "number" && n >= 0 && n <= 1)) throw sx(t, "warnAt, when present, must be in [0, 1]");
|
|
11628
11632
|
let r = null;
|
|
11629
|
-
if (e.window !== void 0 && (r =
|
|
11633
|
+
if (e.window !== void 0 && (r = cx(e.window), r === null)) throw sx(t, `window must be an interval like '1h' / '24h' (got ${JSON.stringify(e.window)})`);
|
|
11630
11634
|
let i = e.severity ?? "warn";
|
|
11631
|
-
if (
|
|
11635
|
+
if (!ax.has(i)) throw sx(t, `severity must be one of info | warn | critical (got ${JSON.stringify(i)})`);
|
|
11632
11636
|
let a = e.onExceeded ?? "observe";
|
|
11633
|
-
if (!
|
|
11637
|
+
if (!ox.has(a)) throw sx(t, `onExceeded must be observe | suspend (got ${JSON.stringify(e.onExceeded)})`);
|
|
11634
11638
|
return {
|
|
11635
11639
|
_voltroCostBudget: !0,
|
|
11636
11640
|
name: t,
|
|
@@ -11642,9 +11646,9 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
11642
11646
|
onExceeded: a,
|
|
11643
11647
|
...e.description === void 0 ? {} : { description: e.description }
|
|
11644
11648
|
};
|
|
11645
|
-
},
|
|
11646
|
-
return (yield*
|
|
11647
|
-
}),
|
|
11649
|
+
}, ux = (e) => typeof e == "object" && !!e && e._voltroCostBudget === !0, dx = class extends n.Tag("@voltro/CostRegistry")() {}, fx = (e, t) => o.gen(function* () {
|
|
11650
|
+
return (yield* dx).budget(e.name, t);
|
|
11651
|
+
}), px = class {
|
|
11648
11652
|
total = 0;
|
|
11649
11653
|
byUnit = /* @__PURE__ */ new Map();
|
|
11650
11654
|
bySubscription = /* @__PURE__ */ new Map();
|
|
@@ -11663,11 +11667,11 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
11663
11667
|
lastUpdatedAt: this.lastUpdatedAt
|
|
11664
11668
|
};
|
|
11665
11669
|
}
|
|
11666
|
-
},
|
|
11670
|
+
}, mx = {
|
|
11667
11671
|
ok: 0,
|
|
11668
11672
|
warn: 1,
|
|
11669
11673
|
exceeded: 2
|
|
11670
|
-
},
|
|
11674
|
+
}, hx = class {
|
|
11671
11675
|
def;
|
|
11672
11676
|
tenantId;
|
|
11673
11677
|
spent = 0;
|
|
@@ -11693,7 +11697,7 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
11693
11697
|
}
|
|
11694
11698
|
settle(e, t, n) {
|
|
11695
11699
|
let r = this.status;
|
|
11696
|
-
return e === r ? null : (this.status = e, this.since = t,
|
|
11700
|
+
return e === r ? null : (this.status = e, this.since = t, mx[e] > mx[r] ? (this.lastCause = n, {
|
|
11697
11701
|
kind: e === "exceeded" ? "exceeded" : "warn",
|
|
11698
11702
|
state: this.state(),
|
|
11699
11703
|
cause: n
|
|
@@ -11706,7 +11710,7 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
11706
11710
|
apply(e, t, n) {
|
|
11707
11711
|
let r = [], i = this.rollWindow(n);
|
|
11708
11712
|
i !== null && r.push(i), this.spent += t, this.lastUpdatedAt = e.at ?? n;
|
|
11709
|
-
let a = this.settle(this.statusOf(this.spent), n,
|
|
11713
|
+
let a = this.settle(this.statusOf(this.spent), n, gx(e));
|
|
11710
11714
|
return a !== null && r.push(a), r;
|
|
11711
11715
|
}
|
|
11712
11716
|
tick(e) {
|
|
@@ -11733,12 +11737,12 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
11733
11737
|
...this.def.description === void 0 ? {} : { description: this.def.description }
|
|
11734
11738
|
};
|
|
11735
11739
|
}
|
|
11736
|
-
},
|
|
11740
|
+
}, gx = (e) => ({
|
|
11737
11741
|
unit: e.unit,
|
|
11738
11742
|
subscriptionId: e.subscriptionId ?? null,
|
|
11739
11743
|
procedure: e.procedure ?? null,
|
|
11740
11744
|
traceId: e.traceId ?? null
|
|
11741
|
-
}),
|
|
11745
|
+
}), _x = (e) => Number.isFinite(e) && e > 0 ? e : 0, vx = class {
|
|
11742
11746
|
now;
|
|
11743
11747
|
attribution = /* @__PURE__ */ new Map();
|
|
11744
11748
|
counters = /* @__PURE__ */ new Map();
|
|
@@ -11758,13 +11762,13 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
11758
11762
|
}
|
|
11759
11763
|
counterFor(e, t) {
|
|
11760
11764
|
let n = this.counters.get(e.name), r = n.get(t);
|
|
11761
|
-
return r === void 0 && (r = new
|
|
11765
|
+
return r === void 0 && (r = new hx(e, t), n.set(t, r)), r;
|
|
11762
11766
|
}
|
|
11763
11767
|
record(e) {
|
|
11764
|
-
let t =
|
|
11768
|
+
let t = _x(e.amount);
|
|
11765
11769
|
if (t === 0) return [];
|
|
11766
11770
|
let n = e.at ?? this.now(), r = this.attribution.get(e.tenantId);
|
|
11767
|
-
r === void 0 && (r = new
|
|
11771
|
+
r === void 0 && (r = new px(), this.attribution.set(e.tenantId, r)), r.add(e, t, n);
|
|
11768
11772
|
let i = this.unitBudgets.get(e.unit);
|
|
11769
11773
|
if (this.totalBudgets.length === 0 && i === void 0) return [];
|
|
11770
11774
|
let a = [];
|
|
@@ -11817,8 +11821,8 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
11817
11821
|
breaches() {
|
|
11818
11822
|
return this.budgetStates().filter((e) => e.status !== "ok");
|
|
11819
11823
|
}
|
|
11820
|
-
},
|
|
11821
|
-
let t = e.now ?? Date.now, n = e.log, r = /* @__PURE__ */ new Set(), i = e.discovered.map((e) => e.definition), a = new
|
|
11824
|
+
}, yx = (e) => {
|
|
11825
|
+
let t = e.now ?? Date.now, n = e.log, r = /* @__PURE__ */ new Set(), i = e.discovered.map((e) => e.definition), a = new vx(i, {
|
|
11822
11826
|
now: t,
|
|
11823
11827
|
...n === void 0 ? {} : { log: n }
|
|
11824
11828
|
}), o = i.some((e) => e.windowMs !== null), s = (e) => {
|
|
@@ -11853,12 +11857,12 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
11853
11857
|
registered: i.map((e) => e.name),
|
|
11854
11858
|
runTick: l
|
|
11855
11859
|
};
|
|
11856
|
-
},
|
|
11860
|
+
}, bx = "holdout", $ = (e, t) => /* @__PURE__ */ Error(`defineExperiment(${JSON.stringify(e)}): ${t}`), xx = (e) => {
|
|
11857
11861
|
if (e == null) return null;
|
|
11858
11862
|
if (typeof e == "number") return Number.isFinite(e) ? String(e) : null;
|
|
11859
11863
|
let t = String(e);
|
|
11860
11864
|
return t.length > 0 ? t : null;
|
|
11861
|
-
},
|
|
11865
|
+
}, Sx = (e) => {
|
|
11862
11866
|
let t = e.name;
|
|
11863
11867
|
if (typeof t != "string" || t.length === 0) throw Error("defineExperiment: a non-empty `name` is required");
|
|
11864
11868
|
if (e.on === void 0 || typeof e.on.table != "string" || e.on.table.length === 0) throw $(t, "on.table is required — the table whose writes drive the experiment");
|
|
@@ -11870,18 +11874,18 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
11870
11874
|
if (typeof e.variantFrom == "string") {
|
|
11871
11875
|
if (e.variantFrom.length === 0) throw $(t, "variantFrom, when a column name, must be non-empty");
|
|
11872
11876
|
let n = e.variantFrom;
|
|
11873
|
-
a = (e) =>
|
|
11877
|
+
a = (e) => xx(e[n]);
|
|
11874
11878
|
} else if (typeof e.variantFrom == "function") {
|
|
11875
11879
|
let t = e.variantFrom;
|
|
11876
|
-
a = (e) =>
|
|
11880
|
+
a = (e) => xx(t(e));
|
|
11877
11881
|
} else throw $(t, "variantFrom must be a column name or a (row) => variantName function");
|
|
11878
11882
|
} else if (typeof e.subject == "string") {
|
|
11879
11883
|
if (e.subject.length === 0) throw $(t, "subject, when a column name, must be non-empty");
|
|
11880
11884
|
let n = e.subject;
|
|
11881
|
-
i = (e) =>
|
|
11885
|
+
i = (e) => xx(e[n]);
|
|
11882
11886
|
} else if (typeof e.subject == "function") {
|
|
11883
11887
|
let t = e.subject;
|
|
11884
|
-
i = (e) =>
|
|
11888
|
+
i = (e) => xx(t(e));
|
|
11885
11889
|
} else throw $(t, "subject is required — a column name or a (row) => key function (or use `variantFrom` to measure an arm something else assigned)");
|
|
11886
11890
|
if (!Array.isArray(e.variants) || e.variants.length < 2) throw $(t, "at least two variants are required (a control + one treatment)");
|
|
11887
11891
|
let o = /* @__PURE__ */ new Set(), s = [];
|
|
@@ -11898,9 +11902,9 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
11898
11902
|
}
|
|
11899
11903
|
let c = 0;
|
|
11900
11904
|
if (e.holdout !== void 0) {
|
|
11901
|
-
if (a !== null && e.holdout > 0) throw $(t, `holdout is meaningless with \`variantFrom\` — a holdout is carved out AT ASSIGNMENT, and this experiment does not assign. Declare the holdout arm on whatever does (a flag variant named "${
|
|
11905
|
+
if (a !== null && e.holdout > 0) throw $(t, `holdout is meaningless with \`variantFrom\` — a holdout is carved out AT ASSIGNMENT, and this experiment does not assign. Declare the holdout arm on whatever does (a flag variant named "${bx}", say) and list it in \`variants\`.`);
|
|
11902
11906
|
if (!(typeof e.holdout == "number" && e.holdout >= 0 && e.holdout < 1)) throw $(t, "holdout, when present, must be a fraction in [0, 1)");
|
|
11903
|
-
if (c = e.holdout, c > 0 && o.has("holdout")) throw $(t, `a variant may not be named ${JSON.stringify(
|
|
11907
|
+
if (c = e.holdout, c > 0 && o.has("holdout")) throw $(t, `a variant may not be named ${JSON.stringify(bx)} when holdout > 0 (reserved)`);
|
|
11904
11908
|
}
|
|
11905
11909
|
let l = e.metric;
|
|
11906
11910
|
if (l === void 0 || typeof l.kind != "string") throw $(t, "metric is required");
|
|
@@ -11932,23 +11936,23 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
11932
11936
|
baseline: u,
|
|
11933
11937
|
...e.description === void 0 ? {} : { description: e.description }
|
|
11934
11938
|
};
|
|
11935
|
-
},
|
|
11939
|
+
}, Cx = (e) => typeof e == "object" && !!e && e._voltroExperiment === !0, wx = (e) => {
|
|
11936
11940
|
let t = 2166136261;
|
|
11937
11941
|
for (let n = 0; n < e.length; n++) t ^= e.charCodeAt(n), t = Math.imul(t, 16777619);
|
|
11938
11942
|
return (t >>> 0) / 4294967296;
|
|
11939
|
-
},
|
|
11940
|
-
let n =
|
|
11941
|
-
if (e.holdout > 0 && n < e.holdout) return
|
|
11943
|
+
}, Tx = (e, t) => {
|
|
11944
|
+
let n = wx(`${e.name}\u0000${t}`);
|
|
11945
|
+
if (e.holdout > 0 && n < e.holdout) return bx;
|
|
11942
11946
|
let r = e.holdout > 0 ? (n - e.holdout) / (1 - e.holdout) : n, i = e.variants.reduce((e, t) => e + t.weight, 0), a = 0;
|
|
11943
11947
|
for (let t of e.variants) if (a += t.weight / i, r < a) return t.name;
|
|
11944
11948
|
return e.variants[e.variants.length - 1].name;
|
|
11945
|
-
},
|
|
11946
|
-
return (yield*
|
|
11947
|
-
}),
|
|
11949
|
+
}, Ex = (e) => e.holdout > 0 ? [...e.variants.map((e) => e.name), bx] : e.variants.map((e) => e.name), Dx = class extends n.Tag("@voltro/ExperimentRegistry")() {}, Ox = (e) => o.gen(function* () {
|
|
11950
|
+
return (yield* Dx).get(e.name);
|
|
11951
|
+
}), kx = "__voltro_variant", Ax = "__voltro_metric", jx = class {
|
|
11948
11952
|
project;
|
|
11949
11953
|
maintainer;
|
|
11950
11954
|
constructor(e, t) {
|
|
11951
|
-
this.project = t, this.maintainer = new
|
|
11955
|
+
this.project = t, this.maintainer = new jb(e);
|
|
11952
11956
|
}
|
|
11953
11957
|
seed(e) {
|
|
11954
11958
|
this.maintainer.seed(e.map((e) => this.project(e)).filter((e) => e !== null));
|
|
@@ -11972,56 +11976,56 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
11972
11976
|
byVariant() {
|
|
11973
11977
|
let e = /* @__PURE__ */ new Map();
|
|
11974
11978
|
for (let t of this.maintainer.materialize()) {
|
|
11975
|
-
let n = t.group[
|
|
11979
|
+
let n = t.group[kx];
|
|
11976
11980
|
typeof n == "string" && e.set(n, t.value);
|
|
11977
11981
|
}
|
|
11978
11982
|
return e;
|
|
11979
11983
|
}
|
|
11980
|
-
},
|
|
11981
|
-
if (
|
|
11984
|
+
}, Mx = (e) => typeof e == "number" && Number.isFinite(e), Nx = (e) => {
|
|
11985
|
+
if (Mx(e)) return e;
|
|
11982
11986
|
let t = Number(e);
|
|
11983
11987
|
return Number.isFinite(t) ? t : null;
|
|
11984
|
-
},
|
|
11988
|
+
}, Px = (e, t) => new jx(e.kind === "count" ? {
|
|
11985
11989
|
op: "count",
|
|
11986
|
-
groupBy: [
|
|
11990
|
+
groupBy: [kx]
|
|
11987
11991
|
} : {
|
|
11988
11992
|
op: e.kind === "sum" ? "sum" : "avg",
|
|
11989
|
-
column:
|
|
11990
|
-
groupBy: [
|
|
11993
|
+
column: Ax,
|
|
11994
|
+
groupBy: [kx]
|
|
11991
11995
|
}, (n) => {
|
|
11992
11996
|
let r = t(n);
|
|
11993
11997
|
if (r === null) return null;
|
|
11994
11998
|
switch (e.kind) {
|
|
11995
|
-
case "count": return { [
|
|
11999
|
+
case "count": return { [kx]: r };
|
|
11996
12000
|
case "sum":
|
|
11997
12001
|
case "avg": {
|
|
11998
|
-
let t =
|
|
12002
|
+
let t = Nx(n[e.column]);
|
|
11999
12003
|
return t === null ? null : {
|
|
12000
|
-
[
|
|
12001
|
-
[
|
|
12004
|
+
[kx]: r,
|
|
12005
|
+
[Ax]: t
|
|
12002
12006
|
};
|
|
12003
12007
|
}
|
|
12004
12008
|
case "conversionRate": {
|
|
12005
12009
|
let t = n[e.column], i = e.equals === void 0 ? !!t : t === e.equals;
|
|
12006
12010
|
return {
|
|
12007
|
-
[
|
|
12008
|
-
[
|
|
12011
|
+
[kx]: r,
|
|
12012
|
+
[Ax]: +!!i
|
|
12009
12013
|
};
|
|
12010
12014
|
}
|
|
12011
12015
|
}
|
|
12012
|
-
}),
|
|
12016
|
+
}), Fx = (e) => new jx({
|
|
12013
12017
|
op: "count",
|
|
12014
|
-
groupBy: [
|
|
12018
|
+
groupBy: [kx]
|
|
12015
12019
|
}, (t) => {
|
|
12016
12020
|
let n = e(t);
|
|
12017
|
-
return n === null ? null : { [
|
|
12018
|
-
}),
|
|
12021
|
+
return n === null ? null : { [kx]: n };
|
|
12022
|
+
}), Ix = (e) => ({
|
|
12019
12023
|
table: e.table,
|
|
12020
12024
|
op: e.op,
|
|
12021
12025
|
traceId: e.traceId ?? null,
|
|
12022
12026
|
subjectId: e.subjectId ?? null,
|
|
12023
12027
|
procedure: e.procedure ?? null
|
|
12024
|
-
}),
|
|
12028
|
+
}), Lx = class {
|
|
12025
12029
|
def;
|
|
12026
12030
|
deps;
|
|
12027
12031
|
exposure;
|
|
@@ -12032,9 +12036,9 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
12032
12036
|
lastUpdatedAt = null;
|
|
12033
12037
|
declaredVariants;
|
|
12034
12038
|
constructor(e, t) {
|
|
12035
|
-
this.def = e, this.deps = t, this.now = t.now ?? Date.now, this.declaredVariants = new Set(
|
|
12039
|
+
this.def = e, this.deps = t, this.now = t.now ?? Date.now, this.declaredVariants = new Set(Ex(e));
|
|
12036
12040
|
let n = (e) => this.variantOf(e);
|
|
12037
|
-
this.exposure =
|
|
12041
|
+
this.exposure = Fx(n), this.metricIsCount = e.metric.kind === "count", this.metric = this.metricIsCount ? this.exposure : Px(e.metric, n);
|
|
12038
12042
|
}
|
|
12039
12043
|
variantOf(e) {
|
|
12040
12044
|
if (e == null) return null;
|
|
@@ -12046,7 +12050,7 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
12046
12050
|
}
|
|
12047
12051
|
if (this.def.subject === null) return null;
|
|
12048
12052
|
let n = this.def.subject(e);
|
|
12049
|
-
return n === null ? null :
|
|
12053
|
+
return n === null ? null : Tx(this.def, n);
|
|
12050
12054
|
}
|
|
12051
12055
|
inScope(e) {
|
|
12052
12056
|
return this.variantOf(e) !== null;
|
|
@@ -12066,12 +12070,12 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
12066
12070
|
};
|
|
12067
12071
|
return this.exposure.apply(r), this.metricIsCount || this.metric.apply(r), this.lastUpdatedAt = new Date(this.now()), {
|
|
12068
12072
|
result: this.result(),
|
|
12069
|
-
cause:
|
|
12073
|
+
cause: Ix(e)
|
|
12070
12074
|
};
|
|
12071
12075
|
}
|
|
12072
12076
|
result() {
|
|
12073
12077
|
let e = this.exposure.byVariant(), t = this.metricIsCount ? e : this.metric.byVariant(), n = this.def.baseline, r = this.metricValueFor(n, t, e), i = 0, a = [];
|
|
12074
|
-
for (let o of
|
|
12078
|
+
for (let o of Ex(this.def)) {
|
|
12075
12079
|
let s = e.get(o) ?? 0;
|
|
12076
12080
|
i += s;
|
|
12077
12081
|
let c = this.metricValueFor(o, t, e), l = o === n, u = l || c === null || r === null ? null : c - r, d = l || c === null || r === null || r === 0 ? null : (c - r) / r;
|
|
@@ -12108,7 +12112,7 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
12108
12112
|
get isSeeded() {
|
|
12109
12113
|
return this.seeded;
|
|
12110
12114
|
}
|
|
12111
|
-
},
|
|
12115
|
+
}, Rx = (e) => {
|
|
12112
12116
|
let t = e.now ?? Date.now, n = e.log, r = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Map(), a = (e) => {
|
|
12113
12117
|
for (let t of r) try {
|
|
12114
12118
|
t(e);
|
|
@@ -12125,7 +12129,7 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
12125
12129
|
}), s = /* @__PURE__ */ new Map();
|
|
12126
12130
|
for (let { definition: r } of e.discovered) {
|
|
12127
12131
|
if (i.has(r.name)) throw Error(`experiment: duplicate name '${r.name}' — names must be unique across all experiments`);
|
|
12128
|
-
let e = new
|
|
12132
|
+
let e = new Lx(r, {
|
|
12129
12133
|
queryBase: o(r.on.table),
|
|
12130
12134
|
now: t,
|
|
12131
12135
|
...n === void 0 ? {} : { log: n }
|
|
@@ -12167,21 +12171,21 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
12167
12171
|
},
|
|
12168
12172
|
registered: [...i.keys()]
|
|
12169
12173
|
};
|
|
12170
|
-
},
|
|
12174
|
+
}, zx = R("_voltro_wakeups", {
|
|
12171
12175
|
id: I({ prefix: "wakeup" }),
|
|
12172
12176
|
tenantId: z(),
|
|
12173
12177
|
kind: z(),
|
|
12174
12178
|
refId: z(),
|
|
12175
12179
|
wakeAt: B(),
|
|
12176
12180
|
status: z()
|
|
12177
|
-
}).index(["status", "wakeAt"]).index(["tenantId"]),
|
|
12178
|
-
let t = e.now?.() ?? /* @__PURE__ */ new Date(), n = await
|
|
12181
|
+
}).index(["status", "wakeAt"]).index(["tenantId"]), Bx = async (e) => {
|
|
12182
|
+
let t = e.now?.() ?? /* @__PURE__ */ new Date(), n = await nv(e.store, t, e.batchLimit ?? 100);
|
|
12179
12183
|
if (n.length === 0) return 0;
|
|
12180
12184
|
let r = 0;
|
|
12181
|
-
for (let t of n) if (await
|
|
12185
|
+
for (let t of n) if (await Q_(e.store, t)) try {
|
|
12182
12186
|
await e.adapter.wake(t), r++;
|
|
12183
12187
|
} catch (n) {
|
|
12184
|
-
await
|
|
12188
|
+
await $_(e.store, t), e.log?.warn("wake: adapter failed — released for retry", {
|
|
12185
12189
|
tenantId: t.tenantId,
|
|
12186
12190
|
kind: t.kind,
|
|
12187
12191
|
refId: t.refId,
|
|
@@ -12189,11 +12193,11 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
12189
12193
|
});
|
|
12190
12194
|
}
|
|
12191
12195
|
return r > 0 && e.log?.info("wake: woke due deployments", { count: r }), r;
|
|
12192
|
-
},
|
|
12196
|
+
}, Vx = (e, t = 1e3) => {
|
|
12193
12197
|
let n = !1, r, i = async () => {
|
|
12194
12198
|
if (!n) {
|
|
12195
12199
|
try {
|
|
12196
|
-
await
|
|
12200
|
+
await Bx(e);
|
|
12197
12201
|
} catch (t) {
|
|
12198
12202
|
e.log?.warn("wake: tick failed", { reason: t instanceof Error ? t.message : String(t) });
|
|
12199
12203
|
}
|
|
@@ -12203,10 +12207,10 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
12203
12207
|
return i(), { stop: () => {
|
|
12204
12208
|
n = !0, r !== void 0 && clearTimeout(r);
|
|
12205
12209
|
} };
|
|
12206
|
-
},
|
|
12210
|
+
}, Hx = (e) => ({ wake: async () => {
|
|
12207
12211
|
await e.start();
|
|
12208
|
-
} }),
|
|
12209
|
-
let t = e.fetchImpl ?? fetch, n = e.now ?? Date.now, r = e.sleep ??
|
|
12212
|
+
} }), Ux = (e) => new Promise((t) => setTimeout(t, e)), Wx = (e) => {
|
|
12213
|
+
let t = e.fetchImpl ?? fetch, n = e.now ?? Date.now, r = e.sleep ?? Ux, i = e.spawnImpl ?? Kr, 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 () => {
|
|
12210
12214
|
try {
|
|
12211
12215
|
let n = await t(e.healthUrl);
|
|
12212
12216
|
return d(n);
|
|
@@ -12260,11 +12264,11 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
12260
12264
|
},
|
|
12261
12265
|
stop: m
|
|
12262
12266
|
};
|
|
12263
|
-
},
|
|
12267
|
+
}, Gx = async (e) => {
|
|
12264
12268
|
if (e.signals.connectedClients() > 0 || e.signals.inFlightRequests() > 0 || e.signals.activeWorkflowExecutions() > 0) return !1;
|
|
12265
|
-
let t = (e.now?.() ?? /* @__PURE__ */ new Date()).getTime() + (e.wakeLookaheadMs ?? 3e4), n = await
|
|
12269
|
+
let t = (e.now?.() ?? /* @__PURE__ */ new Date()).getTime() + (e.wakeLookaheadMs ?? 3e4), n = await rv(e.store);
|
|
12266
12270
|
return !(n !== null && n.wakeAt.getTime() <= t);
|
|
12267
|
-
},
|
|
12271
|
+
}, Kx = (e, t = Date.now) => {
|
|
12268
12272
|
let n;
|
|
12269
12273
|
return {
|
|
12270
12274
|
update: (r) => {
|
|
@@ -12276,7 +12280,7 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
12276
12280
|
n = void 0;
|
|
12277
12281
|
}
|
|
12278
12282
|
};
|
|
12279
|
-
},
|
|
12283
|
+
}, qx = () => {
|
|
12280
12284
|
let e = 0, t = 0;
|
|
12281
12285
|
return {
|
|
12282
12286
|
onRequestStart: () => {
|
|
@@ -12294,7 +12298,7 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
12294
12298
|
inFlightRequests: () => e,
|
|
12295
12299
|
openConnections: () => t
|
|
12296
12300
|
};
|
|
12297
|
-
},
|
|
12301
|
+
}, Jx = (e) => ({ run: async (t) => (e.onActivity?.(), await e.ensureAwake(), t()) }), Yx = (e, t, n, r) => new Promise((i, a) => {
|
|
12298
12302
|
let o = nr.request({
|
|
12299
12303
|
host: n,
|
|
12300
12304
|
port: r,
|
|
@@ -12305,7 +12309,7 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
12305
12309
|
t.writeHead(e.statusCode ?? 502, e.headers), e.pipe(t), e.on("end", i), e.on("error", a);
|
|
12306
12310
|
});
|
|
12307
12311
|
o.on("error", a), e.pipe(o);
|
|
12308
|
-
}),
|
|
12312
|
+
}), Xx = (e, t, n, r, i) => new Promise((a, o) => {
|
|
12309
12313
|
let s = nr.request({
|
|
12310
12314
|
host: r,
|
|
12311
12315
|
port: i,
|
|
@@ -12320,21 +12324,21 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
12320
12324
|
};
|
|
12321
12325
|
t.on("close", s), r.on("close", s), r.on("error", o);
|
|
12322
12326
|
}), s.on("error", o), s.end();
|
|
12323
|
-
}),
|
|
12324
|
-
let t =
|
|
12327
|
+
}), Zx = (e) => {
|
|
12328
|
+
let t = Jx({
|
|
12325
12329
|
ensureAwake: () => e.supervisor.start(),
|
|
12326
12330
|
...e.onActivity === void 0 ? {} : { onActivity: e.onActivity }
|
|
12327
12331
|
}), n = e.activity, r = nr.createServer((r, i) => {
|
|
12328
|
-
n?.onRequestStart(), i.on("close", () => n?.onRequestEnd()), t.run(() =>
|
|
12332
|
+
n?.onRequestStart(), i.on("close", () => n?.onRequestEnd()), t.run(() => Yx(r, i, e.targetHost, e.targetPort)).catch((t) => {
|
|
12329
12333
|
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");
|
|
12330
12334
|
});
|
|
12331
12335
|
});
|
|
12332
12336
|
return r.on("upgrade", (r, i, a) => {
|
|
12333
|
-
n?.onConnect(), i.on("close", () => n?.onDisconnect()), t.run(() =>
|
|
12337
|
+
n?.onConnect(), i.on("close", () => n?.onDisconnect()), t.run(() => Xx(r, i, a, e.targetHost, e.targetPort)).catch((t) => {
|
|
12334
12338
|
e.log?.warn("wake-router: upgrade proxy failed", { reason: t instanceof Error ? t.message : String(t) }), i.destroy();
|
|
12335
12339
|
});
|
|
12336
12340
|
}), r;
|
|
12337
|
-
},
|
|
12341
|
+
}, Qx = async (e) => {
|
|
12338
12342
|
try {
|
|
12339
12343
|
return (await e.query({
|
|
12340
12344
|
table: "_voltro_workflow_runs",
|
|
@@ -12351,15 +12355,15 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
12351
12355
|
} catch {
|
|
12352
12356
|
return 0;
|
|
12353
12357
|
}
|
|
12354
|
-
},
|
|
12355
|
-
let t =
|
|
12358
|
+
}, $x = async (e) => {
|
|
12359
|
+
let t = Hx(e.supervisor), n = await Bx({
|
|
12356
12360
|
store: e.store,
|
|
12357
12361
|
adapter: t,
|
|
12358
12362
|
...e.now === void 0 ? {} : { now: e.now },
|
|
12359
12363
|
...e.log === void 0 ? {} : { log: e.log }
|
|
12360
12364
|
});
|
|
12361
12365
|
n > 0 && e.idleGate.reset();
|
|
12362
|
-
let r = await
|
|
12366
|
+
let r = await Gx({
|
|
12363
12367
|
store: e.store,
|
|
12364
12368
|
signals: e.signals,
|
|
12365
12369
|
...e.wakeLookaheadMs === void 0 ? {} : { wakeLookaheadMs: e.wakeLookaheadMs },
|
|
@@ -12369,12 +12373,12 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
12369
12373
|
woke: n,
|
|
12370
12374
|
stopped: i
|
|
12371
12375
|
};
|
|
12372
|
-
},
|
|
12373
|
-
let t =
|
|
12376
|
+
}, eS = async (e) => {
|
|
12377
|
+
let t = Kx(e.idleGraceMs ?? 6e4), n = e.tickMs ?? 1e3, r = qx(), i = 0, a = e.signals === void 0, o = e.signals ?? {
|
|
12374
12378
|
connectedClients: () => r.openConnections(),
|
|
12375
12379
|
inFlightRequests: () => r.inFlightRequests(),
|
|
12376
12380
|
activeWorkflowExecutions: () => i
|
|
12377
|
-
}, s =
|
|
12381
|
+
}, s = Zx({
|
|
12378
12382
|
supervisor: e.supervisor,
|
|
12379
12383
|
targetHost: e.targetHost,
|
|
12380
12384
|
targetPort: e.targetPort,
|
|
@@ -12393,7 +12397,7 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
12393
12397
|
let l = !1, u, d = e.firedRetentionMs ?? 6e5, f = 0, p = async () => {
|
|
12394
12398
|
if (!l) {
|
|
12395
12399
|
try {
|
|
12396
|
-
if (a && (i = await
|
|
12400
|
+
if (a && (i = await Qx(e.store)), await $x({
|
|
12397
12401
|
store: e.store,
|
|
12398
12402
|
supervisor: e.supervisor,
|
|
12399
12403
|
signals: o,
|
|
@@ -12401,7 +12405,7 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
12401
12405
|
...e.wakeLookaheadMs === void 0 ? {} : { wakeLookaheadMs: e.wakeLookaheadMs },
|
|
12402
12406
|
...e.log === void 0 ? {} : { log: e.log }
|
|
12403
12407
|
}), f++ % 60 == 0) {
|
|
12404
|
-
let t = await
|
|
12408
|
+
let t = await av(e.store, { firedOlderThan: new Date(Date.now() - d) });
|
|
12405
12409
|
t > 0 && e.log?.info("orchestrator: pruned fired wakeups", { count: t });
|
|
12406
12410
|
}
|
|
12407
12411
|
} catch (t) {
|
|
@@ -12416,17 +12420,17 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
12416
12420
|
l = !0, u !== void 0 && clearTimeout(u), await new Promise((e) => s.close(() => e()));
|
|
12417
12421
|
}
|
|
12418
12422
|
};
|
|
12419
|
-
},
|
|
12423
|
+
}, tS = (e) => {
|
|
12420
12424
|
if (e.once !== void 0 && e.eachReplica === !0) throw Error("defineSubscriber: choose either `once` or `eachReplica: true`, not both");
|
|
12421
12425
|
return e;
|
|
12422
|
-
},
|
|
12426
|
+
}, nS = class extends x.TaggedError()("AnalyticsError", {
|
|
12423
12427
|
provider: x.String,
|
|
12424
12428
|
operation: x.String,
|
|
12425
12429
|
cause: x.String
|
|
12426
|
-
}) {},
|
|
12430
|
+
}) {}, rS = class extends x.TaggedError()("AnalyticsCapabilityNotSupported", {
|
|
12427
12431
|
provider: x.String,
|
|
12428
12432
|
capability: x.String
|
|
12429
|
-
}) {},
|
|
12433
|
+
}) {}, iS = class extends n.Tag("@voltro/AnalyticsSink")() {}, aS = (e, t) => ({
|
|
12430
12434
|
info: e.info,
|
|
12431
12435
|
track: (n) => e.track(n.tenantId === void 0 ? {
|
|
12432
12436
|
...n,
|
|
@@ -12445,20 +12449,20 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
12445
12449
|
tenantId: t
|
|
12446
12450
|
} : n),
|
|
12447
12451
|
...e.mirror === void 0 ? {} : { mirror: e.mirror }
|
|
12448
|
-
}),
|
|
12449
|
-
let e = yield*
|
|
12452
|
+
}), oS = () => o.gen(function* () {
|
|
12453
|
+
let e = yield* iS, t = yield* o.serviceOption(on), n = g.match(t, {
|
|
12450
12454
|
onNone: () => null,
|
|
12451
12455
|
onSome: (e) => e.tenantId ?? null
|
|
12452
12456
|
});
|
|
12453
|
-
return n === null ? e :
|
|
12454
|
-
}),
|
|
12455
|
-
let e = (e) => o.fail(new
|
|
12456
|
-
provider:
|
|
12457
|
+
return n === null ? e : aS(e, n);
|
|
12458
|
+
}), sS = "noop", cS = () => {
|
|
12459
|
+
let e = (e) => o.fail(new rS({
|
|
12460
|
+
provider: sS,
|
|
12457
12461
|
capability: e
|
|
12458
12462
|
}));
|
|
12459
12463
|
return {
|
|
12460
12464
|
info: {
|
|
12461
|
-
provider:
|
|
12465
|
+
provider: sS,
|
|
12462
12466
|
capabilities: {
|
|
12463
12467
|
track: !0,
|
|
12464
12468
|
aggregate: !1,
|
|
@@ -12472,8 +12476,8 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
12472
12476
|
timeseries: () => e("timeseries"),
|
|
12473
12477
|
topN: () => e("topN")
|
|
12474
12478
|
};
|
|
12475
|
-
},
|
|
12476
|
-
if (e.length === 0) return
|
|
12479
|
+
}, lS = (e) => {
|
|
12480
|
+
if (e.length === 0) return cS();
|
|
12477
12481
|
if (e.length === 1) return e[0];
|
|
12478
12482
|
let t = {
|
|
12479
12483
|
provider: "compose",
|
|
@@ -12490,7 +12494,7 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
12490
12494
|
discard: !0
|
|
12491
12495
|
}), r = (t, n) => {
|
|
12492
12496
|
let r = e.find((e) => e.info.capabilities[t]);
|
|
12493
|
-
return r === void 0 ? o.fail(new
|
|
12497
|
+
return r === void 0 ? o.fail(new rS({
|
|
12494
12498
|
provider: "compose",
|
|
12495
12499
|
capability: t
|
|
12496
12500
|
})) : n(r);
|
|
@@ -12517,11 +12521,11 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
12517
12521
|
topN: (e) => r("topN", (t) => t.topN(e)),
|
|
12518
12522
|
...a === void 0 ? {} : { mirror: a }
|
|
12519
12523
|
};
|
|
12520
|
-
},
|
|
12524
|
+
}, uS = (e) => {
|
|
12521
12525
|
let t = e.filter((e) => e.dispose !== void 0);
|
|
12522
12526
|
return {
|
|
12523
12527
|
kind: "compose",
|
|
12524
|
-
build: (t) =>
|
|
12528
|
+
build: (t) => lS(e.map((e) => e.build(t))),
|
|
12525
12529
|
tables: e.flatMap((e) => e.tables ?? []),
|
|
12526
12530
|
initialize: (t) => o.forEach(e, (e) => e.initialize ? e.initialize(t) : o.void, {
|
|
12527
12531
|
concurrency: 1,
|
|
@@ -12532,34 +12536,34 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
12532
12536
|
discard: !0
|
|
12533
12537
|
}) } : {}
|
|
12534
12538
|
};
|
|
12535
|
-
},
|
|
12539
|
+
}, dS = {
|
|
12536
12540
|
kind: "noop",
|
|
12537
|
-
build: () =>
|
|
12538
|
-
},
|
|
12541
|
+
build: () => cS()
|
|
12542
|
+
}, fS = p.counter("voltro_analytics_mirror_forwarded_total", { description: "Reactive-table changes successfully applied to the analytics mirror." }), pS = p.counter("voltro_analytics_mirror_retries_total", { description: "Analytics-mirror write attempts that failed (each is retried until the budget runs out)." }), mS = p.counter("voltro_analytics_mirror_repair_queued_total", { description: "Analytics-mirror changes whose retries were exhausted and were queued for repair." }), hS = p.counter("voltro_analytics_mirror_dropped_total", { description: "Analytics-mirror changes provably lost (repair queue overflow)." }), gS = (e) => {
|
|
12539
12543
|
o.runSync(p.increment(e));
|
|
12540
|
-
},
|
|
12544
|
+
}, _S = (t) => e.pretty(t), vS = {
|
|
12541
12545
|
retryAttempts: 5,
|
|
12542
12546
|
retryBaseDelayMs: 100,
|
|
12543
12547
|
retryMaxDelayMs: 3e4,
|
|
12544
12548
|
repairIntervalMs: 6e4,
|
|
12545
12549
|
repairQueueLimit: 1e4,
|
|
12546
12550
|
versionStateLimit: 1e5
|
|
12547
|
-
},
|
|
12551
|
+
}, yS = (e) => {
|
|
12548
12552
|
let t = process.env[e];
|
|
12549
12553
|
if (t === void 0 || t.trim() === "") return;
|
|
12550
12554
|
let n = Number(t);
|
|
12551
12555
|
return Number.isFinite(n) && n >= 0 ? n : void 0;
|
|
12552
|
-
},
|
|
12553
|
-
let t =
|
|
12556
|
+
}, bS = (e) => {
|
|
12557
|
+
let t = vS, n = e ?? {};
|
|
12554
12558
|
return {
|
|
12555
|
-
retryAttempts: Math.max(1, n.retryAttempts ??
|
|
12556
|
-
retryBaseDelayMs: n.retryBaseDelayMs ??
|
|
12557
|
-
retryMaxDelayMs: n.retryMaxDelayMs ??
|
|
12558
|
-
repairIntervalMs: n.repairIntervalMs ??
|
|
12559
|
-
repairQueueLimit: Math.max(1, n.repairQueueLimit ??
|
|
12560
|
-
versionStateLimit: Math.max(1, n.versionStateLimit ??
|
|
12561
|
-
};
|
|
12562
|
-
},
|
|
12559
|
+
retryAttempts: Math.max(1, n.retryAttempts ?? yS("VOLTRO_ANALYTICS_MIRROR_RETRY_ATTEMPTS") ?? t.retryAttempts),
|
|
12560
|
+
retryBaseDelayMs: n.retryBaseDelayMs ?? yS("VOLTRO_ANALYTICS_MIRROR_RETRY_BASE_MS") ?? t.retryBaseDelayMs,
|
|
12561
|
+
retryMaxDelayMs: n.retryMaxDelayMs ?? yS("VOLTRO_ANALYTICS_MIRROR_RETRY_MAX_MS") ?? t.retryMaxDelayMs,
|
|
12562
|
+
repairIntervalMs: n.repairIntervalMs ?? yS("VOLTRO_ANALYTICS_MIRROR_REPAIR_INTERVAL_MS") ?? t.repairIntervalMs,
|
|
12563
|
+
repairQueueLimit: Math.max(1, n.repairQueueLimit ?? yS("VOLTRO_ANALYTICS_MIRROR_REPAIR_QUEUE_LIMIT") ?? t.repairQueueLimit),
|
|
12564
|
+
versionStateLimit: Math.max(1, n.versionStateLimit ?? yS("VOLTRO_ANALYTICS_MIRROR_VERSION_STATE_LIMIT") ?? t.versionStateLimit)
|
|
12565
|
+
};
|
|
12566
|
+
}, xS = {
|
|
12563
12567
|
tables: [],
|
|
12564
12568
|
detach: () => {},
|
|
12565
12569
|
flush: () => Promise.resolve(),
|
|
@@ -12570,10 +12574,10 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
12570
12574
|
awaitingRepair: 0,
|
|
12571
12575
|
dropped: 0
|
|
12572
12576
|
})
|
|
12573
|
-
},
|
|
12577
|
+
}, SS = (e, t) => `${e}\u0000${String(t)}`, CS = (e) => {
|
|
12574
12578
|
let { store: t, sink: n, log: r } = e, i = n.mirror;
|
|
12575
|
-
if (i === void 0 || i.tables.length === 0) return
|
|
12576
|
-
let s =
|
|
12579
|
+
if (i === void 0 || i.tables.length === 0) return xS;
|
|
12580
|
+
let s = bS(e), c = e.run ?? ((e) => o.runPromise(e)), l = i.primaryKey ?? "id", u = new Set(i.tables), d = n.info.provider, f = t.changeScope === "fleet", p = 0, m = () => {
|
|
12577
12581
|
let e = Date.now() * 1e3;
|
|
12578
12582
|
return p = e > p ? e : p + 1, p;
|
|
12579
12583
|
}, h = /* @__PURE__ */ new Map(), g = /* @__PURE__ */ new Set(), _ = /* @__PURE__ */ new Map(), v = /* @__PURE__ */ new Set(), y = 0, x = 0, S = /* @__PURE__ */ new Map(), C = (e) => {
|
|
@@ -12593,7 +12597,7 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
12593
12597
|
primaryKeyValue: t.pk
|
|
12594
12598
|
}).pipe(o.map((e) => (n.baseline = e ?? 0, n.baseline))) : o.succeed(n.baseline);
|
|
12595
12599
|
}), ee = (e, t, n) => n.kind === "clock" ? o.succeed(n.version) : w(e, t).pipe(o.map((e) => e + n.ordinal)), te = b.exponential(a.millis(Math.max(1, s.retryBaseDelayMs)), 2).pipe(b.either(b.spaced(a.millis(Math.max(1, s.retryMaxDelayMs)))), b.intersect(b.recurs(s.retryAttempts - 1))), ne = (e, t) => o.gen(function* () {
|
|
12596
|
-
let n = yield* ee(
|
|
12600
|
+
let n = yield* ee(SS(e.table, e.pk), e, t.stamp);
|
|
12597
12601
|
yield* t.kind === "upsert" ? i.upsert({
|
|
12598
12602
|
table: e.table,
|
|
12599
12603
|
row: t.row,
|
|
@@ -12604,27 +12608,27 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
12604
12608
|
version: n
|
|
12605
12609
|
});
|
|
12606
12610
|
}), re = (e) => e instanceof Error ? `${e.name}: ${e.message}` : String(e), T = (e, t) => ne(e, t).pipe(o.tapErrorCause(() => o.sync(() => {
|
|
12607
|
-
|
|
12611
|
+
gS(pS);
|
|
12608
12612
|
})), o.retry(te), o.matchCauseEffect({
|
|
12609
12613
|
onSuccess: () => o.sync(() => {
|
|
12610
|
-
y += 1,
|
|
12614
|
+
y += 1, gS(fS);
|
|
12611
12615
|
}),
|
|
12612
12616
|
onFailure: (n) => o.sync(() => {
|
|
12613
|
-
ie(e, t,
|
|
12617
|
+
ie(e, t, _S(n));
|
|
12614
12618
|
})
|
|
12615
12619
|
})), ie = (e, t, n) => {
|
|
12616
|
-
let i =
|
|
12620
|
+
let i = SS(e.table, e.pk);
|
|
12617
12621
|
for (r.warn("analytics-mirror: change forward failed, queued for repair", {
|
|
12618
12622
|
provider: d,
|
|
12619
12623
|
table: e.table,
|
|
12620
12624
|
op: t.kind,
|
|
12621
12625
|
attempts: s.retryAttempts,
|
|
12622
12626
|
err: n
|
|
12623
|
-
}), _.set(i, e),
|
|
12627
|
+
}), _.set(i, e), gS(mS); _.size > s.repairQueueLimit;) {
|
|
12624
12628
|
let e = _.keys().next();
|
|
12625
12629
|
if (e.done === !0) break;
|
|
12626
12630
|
let t = _.get(e.value);
|
|
12627
|
-
_.delete(e.value), x += 1,
|
|
12631
|
+
_.delete(e.value), x += 1, gS(hS), r.error("analytics-mirror: repair queue full — change dropped, mirror is diverged", {
|
|
12628
12632
|
provider: d,
|
|
12629
12633
|
table: t?.table ?? "<unknown>",
|
|
12630
12634
|
limit: s.repairQueueLimit
|
|
@@ -12654,7 +12658,7 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
12654
12658
|
v.delete(t);
|
|
12655
12659
|
});
|
|
12656
12660
|
}, O = (e, t) => {
|
|
12657
|
-
let n =
|
|
12661
|
+
let n = SS(e.table, e.pk);
|
|
12658
12662
|
h.set(n, t), !g.has(n) && (g.add(n), ae(D(n, e)));
|
|
12659
12663
|
}, oe = (e) => o.tryPromise({
|
|
12660
12664
|
try: () => t.query({
|
|
@@ -12676,11 +12680,11 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
12676
12680
|
table: t.table,
|
|
12677
12681
|
row: r,
|
|
12678
12682
|
version: n
|
|
12679
|
-
}), _.delete(e), y += 1,
|
|
12683
|
+
}), _.delete(e), y += 1, gS(fS), !0;
|
|
12680
12684
|
}).pipe(o.catchAllCause((e) => o.sync(() => (r.warn("analytics-mirror: repair pass failed, key stays queued", {
|
|
12681
12685
|
provider: d,
|
|
12682
12686
|
table: t.table,
|
|
12683
|
-
err:
|
|
12687
|
+
err: _S(e)
|
|
12684
12688
|
}), !1)))), ce = () => o.gen(function* () {
|
|
12685
12689
|
let e = [..._.entries()];
|
|
12686
12690
|
if (e.length === 0) return 0;
|
|
@@ -12704,7 +12708,7 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
12704
12708
|
kind: "clock",
|
|
12705
12709
|
version: m()
|
|
12706
12710
|
};
|
|
12707
|
-
let t = C(
|
|
12711
|
+
let t = C(SS(e.table, e.pk));
|
|
12708
12712
|
return t.ordinal += 1, {
|
|
12709
12713
|
kind: "ordinal",
|
|
12710
12714
|
ordinal: t.ordinal
|
|
@@ -12760,11 +12764,11 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
12760
12764
|
dropped: x
|
|
12761
12765
|
})
|
|
12762
12766
|
};
|
|
12763
|
-
},
|
|
12767
|
+
}, wS = (e) => {
|
|
12764
12768
|
let t = typeof e.refresh == "string" ? { interval: e.refresh } : e.refresh, n = e.strategy ?? "replace";
|
|
12765
12769
|
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`);
|
|
12766
12770
|
if (e.incremental !== void 0) {
|
|
12767
|
-
let t =
|
|
12771
|
+
let t = Sb({
|
|
12768
12772
|
aggregations: [{
|
|
12769
12773
|
op: e.incremental.op,
|
|
12770
12774
|
...e.incremental.column === void 0 ? {} : { column: e.incremental.column }
|
|
@@ -12786,46 +12790,46 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
12786
12790
|
build: e.build,
|
|
12787
12791
|
...e.incremental === void 0 ? {} : { incremental: e.incremental }
|
|
12788
12792
|
};
|
|
12789
|
-
},
|
|
12793
|
+
}, TS = (e) => typeof e == "object" && !!e && e._voltroAggregate === !0, ES = class extends x.TaggedError()("AggregateStale", {
|
|
12790
12794
|
name: x.String,
|
|
12791
12795
|
ageMs: x.Number,
|
|
12792
12796
|
maxAgeMs: x.Number
|
|
12793
|
-
}) {},
|
|
12797
|
+
}) {}, DS = class extends x.TaggedError()("AggregateNotFound", { name: x.String }) {}, OS = class extends x.TaggedError()("AggregateError", {
|
|
12794
12798
|
name: x.String,
|
|
12795
12799
|
operation: x.String,
|
|
12796
12800
|
cause: x.String
|
|
12797
|
-
}) {},
|
|
12798
|
-
return (yield*
|
|
12799
|
-
}),
|
|
12801
|
+
}) {}, kS = class extends n.Tag("@voltro/AggregateRegistry")() {}, AS = (e) => o.gen(function* () {
|
|
12802
|
+
return (yield* kS).getHandle(e);
|
|
12803
|
+
}), jS = (e, t, n) => {
|
|
12800
12804
|
if (e.crossTenant || !t.has(e.table) || n == null) return e;
|
|
12801
12805
|
let r = j("tenantId", n);
|
|
12802
12806
|
return {
|
|
12803
12807
|
...e,
|
|
12804
12808
|
predicate: e.predicate ? T(e.predicate, r) : r
|
|
12805
12809
|
};
|
|
12806
|
-
},
|
|
12810
|
+
}, MS = (e, t, n) => n === "" && !e.crossTenant && t.has(e.table), NS = (e) => e?.type === "user" && e.tenantId === "", PS = (e, t) => {
|
|
12807
12811
|
if (e.includeDeleted || !t.has(e.table)) return e;
|
|
12808
12812
|
let n = De("deletedAt");
|
|
12809
12813
|
return {
|
|
12810
12814
|
...e,
|
|
12811
12815
|
predicate: e.predicate ? T(e.predicate, n) : n
|
|
12812
12816
|
};
|
|
12813
|
-
},
|
|
12817
|
+
}, FS = (e) => (t, n) => {
|
|
12814
12818
|
e.observe?.beforeScope?.({ ...t }, n);
|
|
12815
|
-
let r =
|
|
12819
|
+
let r = PS(jS(t, e.tenantScopedTables, n.tenantId), e.softDeleteScopedTables);
|
|
12816
12820
|
return e.observe?.afterScope?.({ ...r }), r;
|
|
12817
|
-
},
|
|
12821
|
+
}, IS = (e, t) => t, LS = (t) => o.runPromiseExit(t).then((t) => {
|
|
12818
12822
|
if (c.isSuccess(t)) return t.value;
|
|
12819
12823
|
let n = e.failureOption(t.cause);
|
|
12820
12824
|
throw g.isSome(n) ? n.value : e.squash(t.cause);
|
|
12821
|
-
}),
|
|
12825
|
+
}), RS = (e, t) => e.pipe(o.provideService(on, t)), zS = async (e, t, n, r) => {
|
|
12822
12826
|
let i = await o.runPromise(Cn(t, e.guards, n, {
|
|
12823
12827
|
defaultDeny: r === !0,
|
|
12824
12828
|
procedure: e.name
|
|
12825
12829
|
}));
|
|
12826
12830
|
if (i) throw i;
|
|
12827
|
-
},
|
|
12828
|
-
e.requiresApproval !== void 0 && await
|
|
12831
|
+
}, BS = async (e, t, n, r) => {
|
|
12832
|
+
e.requiresApproval !== void 0 && await Uy({
|
|
12829
12833
|
procedure: e.name,
|
|
12830
12834
|
kind: t,
|
|
12831
12835
|
policy: e.requiresApproval,
|
|
@@ -12833,19 +12837,19 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
12833
12837
|
input: r,
|
|
12834
12838
|
traceId: n.traceId
|
|
12835
12839
|
});
|
|
12836
|
-
},
|
|
12840
|
+
}, VS = H({ scope: "voltro:rpc" }), HS = async (e) => {
|
|
12837
12841
|
if (jo() === void 0) return e;
|
|
12838
|
-
let t = await
|
|
12839
|
-
|
|
12842
|
+
let t = await LS(zo(e.subject, (e) => {
|
|
12843
|
+
VS.error("row filter failed to load", {}, e instanceof Error ? e : Error(String(e)));
|
|
12840
12844
|
}));
|
|
12841
12845
|
return {
|
|
12842
12846
|
...e,
|
|
12843
12847
|
rowFilter: t
|
|
12844
12848
|
};
|
|
12845
|
-
},
|
|
12849
|
+
}, US = (e) => ({
|
|
12846
12850
|
...e.surface === void 0 ? {} : { surface: e.surface },
|
|
12847
12851
|
...e.publicApi === void 0 ? {} : { publicApi: e.publicApi }
|
|
12848
|
-
}),
|
|
12852
|
+
}), WS = (e) => {
|
|
12849
12853
|
let t = e.descriptor.target;
|
|
12850
12854
|
if (t == null) return [];
|
|
12851
12855
|
let n = Array.isArray(t) ? t : [t], r = /* @__PURE__ */ new Set();
|
|
@@ -12854,7 +12858,7 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
12854
12858
|
typeof t == "string" && t.length > 0 && r.add(t);
|
|
12855
12859
|
}
|
|
12856
12860
|
return [...r];
|
|
12857
|
-
},
|
|
12861
|
+
}, GS = async (e) => {
|
|
12858
12862
|
let { store: t, target: n, procedure: r, input: i, output: a } = e;
|
|
12859
12863
|
if (n == null) return;
|
|
12860
12864
|
let o = Array.isArray(n) ? n : [n];
|
|
@@ -12871,7 +12875,7 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
12871
12875
|
await u.set(c.map((e) => String(e)));
|
|
12872
12876
|
}
|
|
12873
12877
|
}
|
|
12874
|
-
},
|
|
12878
|
+
}, KS = async (t) => {
|
|
12875
12879
|
let n = `${t.kind}.${t.name}`, r = Date.now(), i = "ok";
|
|
12876
12880
|
try {
|
|
12877
12881
|
if (t.interceptor) {
|
|
@@ -12886,7 +12890,7 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
12886
12890
|
traceId: t.requestContext.traceId,
|
|
12887
12891
|
...t.requestContext.spanId === void 0 ? {} : { spanId: t.requestContext.spanId },
|
|
12888
12892
|
...t.target !== void 0 && t.target.length > 0 ? { target: t.target } : {},
|
|
12889
|
-
...
|
|
12893
|
+
...US(t.requestContext)
|
|
12890
12894
|
}), i = await o.runPromiseExit(r, t.requestContext.signal === void 0 ? void 0 : { signal: t.requestContext.signal });
|
|
12891
12895
|
if (c.isSuccess(i)) return i.value;
|
|
12892
12896
|
throw e.squash(i.cause);
|
|
@@ -12902,33 +12906,33 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
12902
12906
|
status: i
|
|
12903
12907
|
});
|
|
12904
12908
|
}
|
|
12905
|
-
},
|
|
12906
|
-
let n = t?.delay ?? ((e) =>
|
|
12909
|
+
}, qS = (e) => Ae(e) || kl(e), JS = 3, YS = (e) => new Promise((t) => setTimeout(t, e)), XS = async (e, t) => {
|
|
12910
|
+
let n = t?.delay ?? ((e) => YS(e * 20 + Math.floor(Math.random() * 30))), r = t?.attempts ?? 3;
|
|
12907
12911
|
for (let t = 1;; t++) try {
|
|
12908
12912
|
return await e();
|
|
12909
12913
|
} catch (e) {
|
|
12910
|
-
if (t >= r || !
|
|
12914
|
+
if (t >= r || !qS(e)) throw kl(e) ? e.conflict : e;
|
|
12911
12915
|
await n(t);
|
|
12912
12916
|
}
|
|
12913
|
-
},
|
|
12917
|
+
}, ZS = (e) => (t, n, r) => KS({
|
|
12914
12918
|
name: t.descriptor.name,
|
|
12915
12919
|
kind: "mutation",
|
|
12916
12920
|
input: n,
|
|
12917
12921
|
requestContext: r,
|
|
12918
|
-
target:
|
|
12922
|
+
target: WS(t),
|
|
12919
12923
|
...e.interceptor ? { interceptor: e.interceptor } : {},
|
|
12920
12924
|
...e.recordMetric ? { recordMetric: e.recordMetric } : {},
|
|
12921
12925
|
runExecutor: async () => {
|
|
12922
|
-
await
|
|
12923
|
-
let i = await
|
|
12926
|
+
await zS(t.descriptor, r.subject, n, e.defaultDeny), await BS(t.descriptor, "mutation", r, n);
|
|
12927
|
+
let i = await HS(r), a = e.resolveStore === void 0 ? e.store : await e.resolveStore(i), s = [], c = [], l = await XS(async () => a.transactional(async (l) => {
|
|
12924
12928
|
s.length = 0, c.length = 0, l[Symbol.for("@voltro/runtime:tx-fold-releases")] = c, l[Al] = /* @__PURE__ */ new Map();
|
|
12925
|
-
let u = e.undoCapture?.(l), d =
|
|
12929
|
+
let u = e.undoCapture?.(l), d = ty(u ? u.tx : l), f = e.buildContext(i, d.tx, {
|
|
12926
12930
|
committedStore: a,
|
|
12927
12931
|
afterCommit: (e) => {
|
|
12928
12932
|
s.push(e);
|
|
12929
12933
|
}
|
|
12930
|
-
}), p = t.executor(n, f), m = o.isEffect(p) ? await e.runEffect(
|
|
12931
|
-
return await
|
|
12934
|
+
}), p = t.executor(n, f), m = o.isEffect(p) ? await e.runEffect(RS(p, r.subject), f.store) : await p;
|
|
12935
|
+
return await GS({
|
|
12932
12936
|
store: f.store,
|
|
12933
12937
|
target: t.descriptor.target,
|
|
12934
12938
|
procedure: t.descriptor.name,
|
|
@@ -12938,7 +12942,7 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
12938
12942
|
tag: t.descriptor.name,
|
|
12939
12943
|
subject: r.subject,
|
|
12940
12944
|
traceId: r.traceId
|
|
12941
|
-
}), await
|
|
12945
|
+
}), await ry({
|
|
12942
12946
|
touched: d.drain(),
|
|
12943
12947
|
store: f.store,
|
|
12944
12948
|
subject: r.subject
|
|
@@ -12954,46 +12958,46 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
12954
12958
|
for (let e of s) await e();
|
|
12955
12959
|
return l;
|
|
12956
12960
|
}
|
|
12957
|
-
}),
|
|
12961
|
+
}), QS = (e) => (t, n, r, i) => KS({
|
|
12958
12962
|
name: t.name,
|
|
12959
12963
|
kind: "workflow",
|
|
12960
12964
|
input: n,
|
|
12961
12965
|
requestContext: r,
|
|
12962
12966
|
...e.interceptor ? { interceptor: e.interceptor } : {},
|
|
12963
12967
|
...e.recordMetric ? { recordMetric: e.recordMetric } : {},
|
|
12964
|
-
runExecutor: async () => (await
|
|
12965
|
-
}),
|
|
12968
|
+
runExecutor: async () => (await zS(t, r.subject, n, e.defaultDeny), i())
|
|
12969
|
+
}), $S = (e) => e && typeof e == "object" && "descriptor" in e ? e.descriptor : e, eC = (e) => typeof e == "object" && !!e && !Array.isArray(e) && "table" in e && "order" in e, tC = (e) => {
|
|
12966
12970
|
let t = e.descriptor.source;
|
|
12967
12971
|
return t == null ? [] : typeof t == "string" ? [t] : [...t];
|
|
12968
|
-
},
|
|
12972
|
+
}, nC = (e, t, n) => (r) => () => {
|
|
12969
12973
|
let i = e.descriptor.guards;
|
|
12970
12974
|
return (!i || i.length === 0) && n !== !0 ? Promise.resolve(null) : o.runPromise(Cn(r, i, t, {
|
|
12971
12975
|
defaultDeny: n === !0,
|
|
12972
12976
|
procedure: e.descriptor.name
|
|
12973
12977
|
}));
|
|
12974
|
-
},
|
|
12978
|
+
}, rC = (e, t) => e.rowFilter !== void 0 || jo() === void 0 ? t(e) : o.promise(() => HS(e)).pipe(o.flatMap((e) => {
|
|
12975
12979
|
let n = t(e);
|
|
12976
12980
|
return o.isEffect(n) ? n : o.succeed(n);
|
|
12977
|
-
})),
|
|
12978
|
-
if (r.rowFilter === void 0 && jo() !== void 0) return
|
|
12979
|
-
let i = e.buildContext(r), a =
|
|
12981
|
+
})), iC = (e) => (t, n) => (r) => {
|
|
12982
|
+
if (r.rowFilter === void 0 && jo() !== void 0) return rC(r, (r) => iC(e)(t, n)(r));
|
|
12983
|
+
let i = e.buildContext(r), a = nC(t, n, e.defaultDeny)(r.subject), s = async () => {
|
|
12980
12984
|
let i = await a();
|
|
12981
12985
|
if (i) throw i;
|
|
12982
|
-
let s = e.buildContext(await
|
|
12983
|
-
return o.isEffect(c) ? o.runPromise(e.provideEffect(
|
|
12986
|
+
let s = e.buildContext(await HS(r)), c = t.executor(n, s);
|
|
12987
|
+
return o.isEffect(c) ? o.runPromise(e.provideEffect(RS(c, r.subject), s.store), r.signal === void 0 ? void 0 : { signal: r.signal }) : $S(await Promise.resolve(c));
|
|
12984
12988
|
}, c = (n) => {
|
|
12985
|
-
let i =
|
|
12986
|
-
return
|
|
12989
|
+
let i = $S(n);
|
|
12990
|
+
return eC(i) ? e.finalize(i, r) : {
|
|
12987
12991
|
__voltroComputed: !0,
|
|
12988
12992
|
value: i,
|
|
12989
|
-
dependentTables:
|
|
12993
|
+
dependentTables: tC(t),
|
|
12990
12994
|
tenantId: r.subject?.tenantId ?? null,
|
|
12991
12995
|
recompute: s
|
|
12992
12996
|
};
|
|
12993
12997
|
}, l = () => {
|
|
12994
|
-
_o(t.descriptor.name,
|
|
12998
|
+
_o(t.descriptor.name, tC(t));
|
|
12995
12999
|
let a = t.executor(n, i);
|
|
12996
|
-
return o.isEffect(a) ? e.provideEffect(
|
|
13000
|
+
return o.isEffect(a) ? e.provideEffect(RS(a, r.subject), i.store).pipe(o.map(c)) : a instanceof Promise ? o.promise(() => a).pipe(o.map(c)) : c(a);
|
|
12997
13001
|
}, u = () => {
|
|
12998
13002
|
let i = t.descriptor.guards;
|
|
12999
13003
|
return (!i || i.length === 0) && e.defaultDeny !== !0 ? l() : Cn(r.subject, i, n, {
|
|
@@ -13017,18 +13021,18 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
13017
13021
|
subject: r.subject,
|
|
13018
13022
|
traceId: r.traceId,
|
|
13019
13023
|
...r.spanId === void 0 ? {} : { spanId: r.spanId },
|
|
13020
|
-
...
|
|
13024
|
+
...US(r)
|
|
13021
13025
|
});
|
|
13022
|
-
},
|
|
13023
|
-
let i = await
|
|
13026
|
+
}, aC = (e) => async (t, n, r) => {
|
|
13027
|
+
let i = await HS(r), a = iC(e)(t, n)(i), s = o.isEffect(a) ? await LS(a) : a;
|
|
13024
13028
|
if (ks(s)) return s.value;
|
|
13025
13029
|
let c = e.buildContext(i);
|
|
13026
13030
|
return e.queryRows(s, i, c.store);
|
|
13027
|
-
},
|
|
13031
|
+
}, oC = (e) => (t, n, r, i) => {
|
|
13028
13032
|
let a = !1, s;
|
|
13029
13033
|
return (async () => {
|
|
13030
13034
|
try {
|
|
13031
|
-
let c = await
|
|
13035
|
+
let c = await HS(r), l = iC(e)(t, n)(c), u = o.isEffect(l) ? await LS(l) : l, d = (e) => i(e), f = ks(u) ? await e.subscribeComputed(u, d, c) : await e.subscribeDescriptor(u, d, c, nC(t, n, e.defaultDeny)(c.subject), Go(c.subject));
|
|
13032
13036
|
a ? f() : s = f;
|
|
13033
13037
|
} catch (e) {
|
|
13034
13038
|
i({
|
|
@@ -13042,27 +13046,27 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
13042
13046
|
})(), () => {
|
|
13043
13047
|
a = !0, s?.();
|
|
13044
13048
|
};
|
|
13045
|
-
},
|
|
13049
|
+
}, sC = (e) => (t, n, r) => KS({
|
|
13046
13050
|
name: t.descriptor.name,
|
|
13047
13051
|
kind: "action",
|
|
13048
13052
|
input: n,
|
|
13049
13053
|
requestContext: r,
|
|
13050
|
-
target:
|
|
13054
|
+
target: WS(t),
|
|
13051
13055
|
...e.interceptor ? { interceptor: e.interceptor } : {},
|
|
13052
13056
|
...e.recordMetric ? { recordMetric: e.recordMetric } : {},
|
|
13053
13057
|
runExecutor: async () => {
|
|
13054
|
-
await
|
|
13055
|
-
let i = e.buildContext(await
|
|
13056
|
-
_o(t.descriptor.name,
|
|
13058
|
+
await zS(t.descriptor, r.subject, n, e.defaultDeny), await BS(t.descriptor, "action", r, n);
|
|
13059
|
+
let i = e.buildContext(await HS(r));
|
|
13060
|
+
_o(t.descriptor.name, tC(t));
|
|
13057
13061
|
let a = t.executor(n, i);
|
|
13058
|
-
return o.isEffect(a) ? e.runEffect(
|
|
13062
|
+
return o.isEffect(a) ? e.runEffect(RS(a, r.subject), i.store) : a;
|
|
13059
13063
|
}
|
|
13060
|
-
}),
|
|
13064
|
+
}), cC = (e) => e instanceof Date ? e.toISOString() : typeof e == "string" && e.length > 0 ? e : null, lC = (e) => typeof e == "string" && e.length > 0 ? e : null, uC = [
|
|
13061
13065
|
"updatedAt",
|
|
13062
13066
|
"createdAt",
|
|
13063
13067
|
"updatedBy",
|
|
13064
13068
|
"createdBy"
|
|
13065
|
-
],
|
|
13069
|
+
], dC = (e) => uC.some((t) => t in e), fC = (e, t, n) => {
|
|
13066
13070
|
let r = {
|
|
13067
13071
|
table: t.table,
|
|
13068
13072
|
id: t.id,
|
|
@@ -13077,14 +13081,14 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
13077
13081
|
found: !1
|
|
13078
13082
|
};
|
|
13079
13083
|
let i = t.column === void 0 ? void 0 : e[t.column];
|
|
13080
|
-
if (!
|
|
13084
|
+
if (!dC(e)) return {
|
|
13081
13085
|
...r,
|
|
13082
13086
|
value: i,
|
|
13083
13087
|
lastWrite: null,
|
|
13084
13088
|
attribution: "none",
|
|
13085
13089
|
found: !0
|
|
13086
13090
|
};
|
|
13087
|
-
let a =
|
|
13091
|
+
let a = lC(e.updatedBy) ?? lC(e.createdBy), o = cC(e.updatedAt) ?? cC(e.createdAt);
|
|
13088
13092
|
return {
|
|
13089
13093
|
...r,
|
|
13090
13094
|
value: i,
|
|
@@ -13096,12 +13100,12 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
13096
13100
|
attribution: "audit",
|
|
13097
13101
|
found: !0
|
|
13098
13102
|
};
|
|
13099
|
-
},
|
|
13103
|
+
}, pC = (e, t) => {
|
|
13100
13104
|
let n = e.map((e) => {
|
|
13101
13105
|
let n = e.newValue ?? e.value, r = t.column !== void 0 && n && typeof n == "object" ? n[t.column] : e.newValue ?? e.value;
|
|
13102
13106
|
return {
|
|
13103
|
-
actor: { id:
|
|
13104
|
-
at:
|
|
13107
|
+
actor: { id: lC(e.actor) ?? lC(e.changedBy) },
|
|
13108
|
+
at: cC(e.at) ?? cC(e.changedAt),
|
|
13105
13109
|
...e.traceId === void 0 ? {} : { traceId: e.traceId },
|
|
13106
13110
|
value: r
|
|
13107
13111
|
};
|
|
@@ -13116,12 +13120,12 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
13116
13120
|
history: n,
|
|
13117
13121
|
found: n.length > 0
|
|
13118
13122
|
};
|
|
13119
|
-
},
|
|
13123
|
+
}, mC = (e) => {
|
|
13120
13124
|
let t = e.new?.id;
|
|
13121
13125
|
if (typeof t == "string") return t;
|
|
13122
13126
|
let n = e.old?.id;
|
|
13123
13127
|
return typeof n == "string" ? n : void 0;
|
|
13124
|
-
},
|
|
13128
|
+
}, hC = (e) => {
|
|
13125
13129
|
let t = {};
|
|
13126
13130
|
if (e.op === "insert") for (let [n, r] of Object.entries(e.new ?? {})) t[n] = {
|
|
13127
13131
|
from: void 0,
|
|
@@ -13141,11 +13145,11 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
13141
13145
|
return {
|
|
13142
13146
|
table: e.table,
|
|
13143
13147
|
op: e.op,
|
|
13144
|
-
id:
|
|
13148
|
+
id: mC(e),
|
|
13145
13149
|
fields: t
|
|
13146
13150
|
};
|
|
13147
|
-
},
|
|
13148
|
-
let t = e.map(
|
|
13151
|
+
}, gC = (e) => {
|
|
13152
|
+
let t = e.map(hC);
|
|
13149
13153
|
return {
|
|
13150
13154
|
rows: t,
|
|
13151
13155
|
summary: {
|
|
@@ -13154,21 +13158,21 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
|
|
|
13154
13158
|
deletes: t.filter((e) => e.op === "delete").length
|
|
13155
13159
|
}
|
|
13156
13160
|
};
|
|
13157
|
-
},
|
|
13161
|
+
}, _C = class extends Error {
|
|
13158
13162
|
constructor() {
|
|
13159
13163
|
super("voltro:preview-rollback"), this.name = "PreviewRollback";
|
|
13160
13164
|
}
|
|
13161
|
-
},
|
|
13165
|
+
}, vC = async (e, t) => {
|
|
13162
13166
|
let n, r = !1;
|
|
13163
13167
|
try {
|
|
13164
13168
|
await e.transactional(async (e) => {
|
|
13165
|
-
throw n = await t(e), r = !0, new
|
|
13169
|
+
throw n = await t(e), r = !0, new _C();
|
|
13166
13170
|
});
|
|
13167
13171
|
} catch (e) {
|
|
13168
|
-
if (!(e instanceof
|
|
13172
|
+
if (!(e instanceof _C)) throw e;
|
|
13169
13173
|
}
|
|
13170
13174
|
if (!r) throw Error("preview: handler did not complete");
|
|
13171
13175
|
return n;
|
|
13172
|
-
},
|
|
13176
|
+
}, yC = "framework-runtime";
|
|
13173
13177
|
//#endregion
|
|
13174
|
-
export { mf as ACTORS_TABLE, Cu as API_CSP, pf as API_KEYS_TABLE, gy as APPROVALS_TABLE, Eh as AccessDenied, SS as AggregateError, Tb as AggregateMaintainer, xS as AggregateNotFound, CS as AggregateRegistry, bS as AggregateStale, Zx as AnalyticsCapabilityNotSupported, Xx as AnalyticsError, Qx as AnalyticsSink, av as CLAIM_RETENTION_BUCKETS, Y as CONNECTIONS_TABLE, wm as CONNECTION_GRANTS_TABLE, i_ as CircuitBreaker, n_ as CircuitOpen, Jm as ConnectionNotConnected, Vt as ConstraintViolation, fx as CostAccountant, ax as CostRegistry, fS as DEFAULT_ANALYTICS_MIRROR_TUNABLES, _y as DEFAULT_APPROVAL_EXPIRY_MS, iv as DEFAULT_CLAIM_BUCKET_MS, Nl as DEFAULT_COMPRESSION_MIN_BYTES, Ai as DEFAULT_CRDT_COMPACT_MAX_BYTES, bi as DEFAULT_DELIVERY_CONCURRENCY, lv as DEFAULT_EXTERNAL_RECONCILE_MS, cv as DEFAULT_EXTERNAL_TRIGGER_SKEW_MS, Tu as DEFAULT_HSTS, ws as DEFAULT_KEEP_ALIVE_MS, jv as DEFAULT_MAX_IDLE_INTERVAL_MS, gd as DEFAULT_MAX_RPC_BODY_BYTES, b_ as DEFAULT_MAX_RUNTIME_MS, HS as DEFAULT_MUTATION_REPLAY_ATTEMPTS, mm as DEFAULT_OUTBOX_CLAIM_LEASE_MS, xi as DEFAULT_RAW_READ_TRACKING_LIMIT, Km as DEFAULT_REFRESH_SKEW_MS, fc as DEFAULT_RESUME_MAX_DELTAS, dc as DEFAULT_RESUME_WINDOW_MS, Eo as DEFAULT_ROW_FILTER_RETRY, mv as DEFAULT_SCHEDULE_HEARTBEAT_MS, tc as DEFAULT_SOCKET_MAX_BUFFERED_BYTES, nc as DEFAULT_SOCKET_OVERRUN_AFTER_MS, rc as DEFAULT_SOCKET_OVERSIZED_EVENT_BYTES, ic as DEFAULT_SOCKET_STALL_WARN_AFTER_MS, e_ as DEFAULT_STALE_AFTER_MS, kf as DEVICES_TABLE, tv as DORMANCY_WAKEUP_TENANT, _l as DeleteBuilder, ms as Dispatcher, Xp as EVENT_CLIENT_QUEUE_SIZE, Zp as EVENT_LATEST_QUEUE_SIZE, uv as EXTERNAL_TRIGGER_AHEAD_TOLERANCE_MS, $f as EffectStore, Gp as EventBus, Zb as ExpectationEvaluator, Vb as ExpectationRegistry, jx as ExperimentEvaluator, xx as ExperimentRegistry, oh as GRANT_TTL_MS, Ts as HEADERS_TIMEOUT_MARGIN_MS, mx as HOLDOUT_VARIANT, wu as HTML_CSP, gi as InMemoryDataStore, ti as IndexedMatcher, rm as InstanceMembership, Jr as LinearScanMatcher, Sv as MIN_EXTERNALIZABLE_INTERVAL_MS, m as MetricBoundaries, tS as NOOP_ANALYTICS_PROVIDER, No as NO_ROW_FILTER, du as NO_TRUSTED_PROXIES, Qt as NoRowFound, Eu as ORIGIN_NULLING_REFERRER_POLICIES, sm as OUTBOX_ATTEMPTS_TABLE, hm as OUTBOX_ATTEMPT_LOG_CAP, J as OUTBOX_TABLE, dl as OptimisticLockError, Th as REBAC_ADMIN_SCOPE, qm as REFRESH_LEASE_MS, Gg as REPLICA_OBSERVATIONS_TABLE, pC as RUNTIME_NAME, Fb as ReactionRateLimiter, cs as ReplicatedDataStore, To as RowFilterDeclarationViolated, wo as RowFilterUnavailable, ev as SCHEDULE_SUBJECT, Zf as SYSTEM_SUBJECT, hl as SelectBuilder, tn as ServerOnlyColumnWrite, Qh as SsrfBlockedError, rn as StoreOperationFailed, ii as SubscriptionRegistry, ne as TENANT_SELECTIONS_TABLE, pv as TERMINAL_RUN_STATUSES, Dl as TRANSACTION_READ_CONFLICT_NAME, Al as TX_READ_VERSIONS_KEY, sn as TableValidationFailed, ln as TenantRowNotFound, dn as TenantScopeViolation, ub as TimelineRecorder, Ol as TransactionReadConflict, ty as UndoBoundaryError, ry as UndoStack, Fu as UnverifiedWebhookRoute, gl as UpdateBuilder, ag as VOLTRO_AUDIT_MIXIN_ID, sg as VOLTRO_EXPIRES_MIXIN_ID, lg as VOLTRO_LOCAL_FIRST_MIXIN_ID, og as VOLTRO_SOFT_DELETE_MIXIN_ID, cg as VOLTRO_TENANT_MIXIN_ID, Mu as WEBHOOK_VERIFICATION_PROPERTY, Cp as WorkflowPayloadError, gp as WorkflowRateLimitedError, _p as WorkflowSingletonHeldError, cp as WorkflowStartNotExecuted, qs as _connectionStreamCount, Js as _resetConnectionCredentialsForTest, vy as _voltroApprovalsTable, Rv as _voltroChangeClaimsTable, Em as _voltroConnectionGrantsTable, Cm as _voltroConnectionsTable, Eb as _voltroRebacTuplesTable, Lv as _voltroScheduleClaimsTable, Iv as _voltroScheduleRunsTable, zv as _voltroTracesTable, Bv as _voltroUndoLogTable, Nx as _voltroWakeupsTable, zp as _voltroWorkflowEventDeliveriesTable, Rp as _voltroWorkflowEventsTable, Tl as actingUserId, Dc as adoptDetached, Sc as answerResume, Xf as apiKeyManagementRoutes, yi as appValidation, Ws as applyConnectionCredential, zS as applyDeclaredRelations, Sl as applyDefined, Cb as applyDelta, ay as applyInverse, oy as applyInverses, Os as applyKeepAlive, Hg as applyPluginRefRules, Uo as applyRowFilter, Wo as applyRowFilterToDescriptor, OS as applySoftDeleteScope, TS as applyTenantScope, my as applyUndoInvocation, wy as approvalIntentKey, By as approvalNonce, Hy as approvalsPendingExecutor, Ih as assertCan, jm as assertConnectionCipherConfigured, Iu as assertWebhookRoutesDeclareVerification, yx as assignVariant, _S as attachAnalyticsMirror, Qb as attachExpectations, Mx as attachExperiments, px as attachFinops, Od as awaitServerListening, pm as backoffMs, uh as beginOAuthConnect, Zu as bindComputedUntyped, Bs as bindConnectionCredential, em as bindEvent, hd as bindMutation, ed as bindStream, Qu as bindSubscription, qu as bindSubscriptionUntyped, xb as buildIvmState, uC as buildPreview, kb as buildRebacInterceptor, jb as buildRebacReadFilter, ts as buildSubjectKey, Fd as buildTracingLayer, jg as cacheScopeLeaks, Xd as cachedBackend, Fh as can, U_ as cancelWakeup, _c as canonicalInputKey, Cy as canonicalJson, ni as canonicalize, ov as claimGraceMs, O as classifyConstraintViolation, uo as classifyRead, lu as classifyRequestOrigin, gb as classifyShape, Iy as clearApprovalGate, Qm as clearConnectionRefreshFlights, jh as clearResourcePolicies, se as clearRetentions, s_ as clearSystemStoreHandle, Of as clearTenantSelection, Ug as collectPluginRefRules, Vg as collectReferenceSoftDeleteRules, S_ as compileCron, dh as completeOAuthConnect, iS as composeAnalytics, rS as composeAnalyticsSinks, sh as connectionCallbackPath, Am as connectionLabel, Kx as countRunningWorkflows, eo as counter, Ni as crdtCompactMaxBytes, Cv as cronForInterval, w_ as cronOccurrences, Eg as crud, Di as currentRawReads, Vh as currentRequestLoader, ss as currentRoutingContext, Ic as currentTraceContext, Tf as dataStoreApiKeyStore, Uf as dataStoreDeviceStore, rf as dataStoreIdempotencyStore, uf as dataStoreKvStore, Ry as decideApproval, Uy as decideApprovalInvocation, qc as decryptField, dd as defectMessage, vS as defineAggregate, km as defineConnection, rx as defineCostBudget, Np as defineEventTrigger, AS as defineExecutor, zb as defineExpectation, gx as defineExperiment, um as defineOutboxHandler, Mb as defineReaction, Oh as defineResourcePolicy, x_ as defineSchedule, Yx as defineSubscriber, fs as deliveredRowCount, Rc as deriveKey, Ec as detachForResume, qf as deviceManagementRoutes, Mf as deviceTokenPrefixes, lC as diffChange, Ed as drainForShutdown, bm as drainOutbox, X_ as dueWakeups, Ph as effectiveRelations, gg as emptySchemaRegistry, $c as enableGraphObservation, Kc as encryptField, Ly as enforceApproval, _o as enterReadRecording, Bh as enterRequestLoader, Wd as envSecretsBackend, Zv as evaluateTouchedRules, Ia as eventMetricTagCacheSizeForTests, Wm as exchangeAuthorizationCode, Mc as externalSpanFromTraceparent, wv as externalizationRefusal, kv as externalizedTask, Av as externalizedTaskNames, ve as extractDbCause, ri as fingerprintFor, Yo as forbiddenColumnsForSubject, Bm as forgetCredential, $g as forgetReplicaObservations, Mg as formatCacheScopeLeaks, Ag as formatServerOnlyLeaks, Ac as formatTraceparent, Fg as formatUnresolvedSources, iy as forwardChangeFromCdc, Jf as frameworkApiKeyStrategy, Wf as frameworkDeviceStrategy, to as gauge, gf as generateApiKeyToken, Fy as getApprovalGate, Vs as getConnectionCredential, hh as getConnectionResolver, zs as getCredentialExpiry, Wc as getFieldCipher, kh as getResourcePolicy, jo as getRowFilter, Qs as getRpcConnection, c_ as getSystemStoreHandle, fb as getTimelineRecorder, Kh as getTupleSource, vb as groupKeyOf, vx as hashUnitInterval, no as histogramMetric, sC as historyProvenance, Zd as httpSecretsBackend, Ur as inspectWorkflow, Py as installApprovalGate, Jh as installPolicyGuardResolver, Ks as interruptConnectionStreams, $v as invertChange, hu as ipToBytes, yS as isAggregateDefinition, Fl as isCompressibleContentType, ix as isCostBudgetDefinition, ES as isEmptyTenantScopedRead, Bb as isExpectationDefinition, _x as isExperimentDefinition, Ee as isForeignKeyViolation, zx as isIdleNow, cd as isInfraError, el as isObservingGraph, DS as isOrglessUserSubject, Oe as isQueryTimeout, ny as isSafeToApply, y_ as isScheduleDefinition, zg as isSoftDelete, $l as isStateChangingMethod, kl as isTransactionReadConflict, yu as isTrustedProxy, Pp as isWorkflowEventTriggerDefinition, Ti as isolateRawReadScope, bb as ivmValue, oC as lastWriteProvenance, Vm as listConnectionStates, Ah as listResourcePolicies, Ne as listRetentionConflicts, Pe as listRetentions, Db as loadResourceTuples, Ab as loadSubjectTuples, h_ as localityAwareSelector, tC as makeActionRunner, sv as makeAdvisoryLockCoordinator, Bc as makeAesCipher, yf as makeApiKeyService, ig as makeApiKeyUsageBuffer, wf as makeApiKeyUsageFlusher, vi as makeAppAccess, My as makeApprovalGate, df as makeAsyncKv, m_ as makeAuthMiddlewareLayers, $p as makeBufferGapDetector, Ud as makeBufferingSpanProcessor, Mm as makeConnectionRegistry, _h as makeConnectionResolver, p_ as makeConnectionState, vh as makeConnectionsFacade, Fv as makeCoordinatedScheduler, Xh as makeDataLoader, Go as makeDefaultRefilter, Lf as makeDeviceService, wh as makeDisconnectConnectionExecutor, sp as makeEffectStoreLayer, Yp as makeEventPublisher, Bp as makeEventsFacade, Vc as makeFieldCipher, vl as makeFluentStore, Bx as makeIdleGate, kp as makeLazyWorkflowFacade, xh as makeListConnectionsExecutor, pd as makeMutationOutputCodec, GS as makeMutationRunner, $S as makeOneShotQueryRunner, nu as makeOriginGuardExemption, fm as makeOutboxFacade, Ix as makeProcessAdapter, QS as makeQueryDescriptorProducer, kS as makeQueryFinalizer, XS as makeQueryReauthorizer, eC as makeQuerySubscriber, Vx as makeRouterActivity, Yv as makeRuleCapture, ug as makeSchemaRegistry, Sh as makeStartConnectionExecutor, Ch as makeSubmitTokenExecutor, lc as makeSubscriptionOutbox, Dp as makeTransactionalWorkflowFacade, Kv as makeUndoCapture, Hx as makeWakeGate, Gx as makeWakeProxyServer, Ep as makeWorkflowFacade, Op as makeWorkflowFacadeWithCallerContext, Ap as makeWorkflowHandlers, jp as makeWorkflowLayers, yp as makeWorkflowRunHandle, KS as makeWorkflowStartRunner, W_ as markWakeupFired, Sb as materializeIvm, Rl as maybeCompress, bf as memoryApiKeyStore, Rf as memoryDeviceStore, __ as memoryReplicationAdapter, es as memoryRywPositionStore, Us as mergeCookieHeader, t_ as mergeFleetObservations, ul as missingRowError, Il as negotiateEncoding, Nc as newTraceId, Pv as nextDelay, C_ as nextFiring, Z_ as nextWakeup, Rx as nodeProcessSupervisor, nS as noopAnalytics, aS as noopAnalyticsSpec, ff as noopKv, fu as normalizeIp, iu as normalizeOrigin, xo as noteRead, Ul as noteResumeVerdict, Io as noteRowFilterResolved, Dm as oauthCredentialValue, al as observeStore, rl as observedGraph, xd as onProcessShutdown, Md as otelImportFailure, lm as outboxAttemptsTable, om as outboxTable, jy as parseApprovalInterval, jc as parseTraceparent, wp as payloadPropertyNames, vv as peerRunIsAlive, zy as pendingApprovalsFor, Cf as plantMissingApiKeyActors, Zo as powerOfTwoSelector, Du as preservesSameOriginHeader, fC as previewInRollback, Im as projectConnectionState, $_ as pruneWakeups, qp as publishEvent, Xl as publishServerTracerLayer, uc as pumpOutbox, ki as rawSqlPreview, sc as reactiveSocketTunables, Lc as readMaybeOne, Mv as readPollCeilingMs, go as readRecordingActive, Xg as readReplicaObservations, Mh as rebacPolicyGraph, $i as recordCoalesced, Rs as recordCredentialExpiry, Ra as recordEventDelivered, za as recordEventDropped, La as recordEventPublished, Ba as recordEventSubscribers, Qa as recordExternalMissed, Za as recordExternalTrigger, xc as recordForResume, ea as recordOverrun, ta as recordOversized, Ei as recordRawRead, vo as recordReads, Va as recordSample, Xa as recordScheduleQueueRecovery, Ya as recordScheduleQueueWait, Ja as recordScheduleQueued, Ka as recordScheduleRun, na as recordStalled, Ga as recordSubscriptionActive, Ua as recordSubscriptionDelivery, nl as recordTableAccess, mb as recordTimelineEvent, $a as recordWorkflowRun, So as recordingStore, Sg as redactColumns, sb as redactRow, ns as redisRywPositionStore, hy as redoUndoInvocation, Gm as refreshAccessToken, Gs as registerConnectionStream, qh as registerDefaultTupleSource, Dv as registerExternalizedTask, Ke as registerRetention, H_ as registerWakeup, xy as rehydrateGuards, q_ as releaseWakeup, Qo as replicaHealth, Yu as resetComputedQueryCacheWarnings, Oc as resetDetachedForTest, Fa as resetEventMetricTagCacheForTests, il as resetObservedGraph, Jg as resetReplicaObservationWarnings, Gl as resetResumeCensus, Cc as resetResumeRingsForTest, Ro as resetRowFilterResolvedArms, qd as resetSecretsBackend, oa as resetSubscriptionSocketMetrics, xu as resolveClientAddress, th as resolveConnection, gh as resolveConnectionForSubject, g_ as resolveCurrentRegion, Ri as resolveDependentTables, Ds as resolveKeepAlive, uu as resolveOriginGuardConfig, Ci as resolveReactiveConfig, lh as resolveRedirectUri, Su as resolveRequestIsHttps, wb as resolveRescan, zo as resolveRowFilterScope, Bo as resolveRowFilterScopeFor, Jd as resolveSecret, Yd as resolveSecretSync, Qd as resolveSecretsBackend, Au as resolveSecurityHeaders, ib as resolveTimelineMode, T_ as resolveTransactionSubject, bu as resolveTrustedProxies, yo as restrictingReads, bo as restrictingReadsEffect, bx as resultVariantNames, Wl as resumeCensus, gc as resumeKeyOf, hc as resumeTunables, Ye as retentionTtlMsFromEnv, xs as revalidatePath, Ss as revalidateTable, Cs as revalidateTag, lb as reverseEventOverRows, Rh as revokedIds, Ho as rowFilterMayNarrow, Mo as rowFilterRegistered, Lo as rowFilterResolvedArms, Bg as rulesFor, l_ as runAsSystem, qx as runOrchestratorTick, jS as runProvidedEffect, Lb as runReaction, Jx as runSingleNodeOrchestrator, Fx as runWakeLoop, WS as runWithDeadlockRetry, tl as runWithObservedProcedure, Oi as runWithRawReadScope, Hh as runWithRequestLoader, as as runWithRoutingContext, os as runWithRoutingContextEffect, Fc as runWithTraceContext, ch as sanitizeRedirectTo, k_ as scheduleBackfillRequestsTable, Nv as scheduleCoordinated, Dg as schemaPropertyNames, Sy as scopeStringsOf, ju as securityHeadersFor, Df as selectTenant, by as serializeGuards, Ko as serverOnlyColumnNames, kg as serverOnlyLeaks, Yl as serverTracer, Qi as setBufferedBytes, mh as setConnectionResolver, Mi as setCrdtCompactMaxBytes, Uc as setFieldCipher, oc as setReactiveSocketTunables, mc as setResumeTunables, ys as setRevalidationPublisher, Ao as setRowFilter, Kd as setSecretsBackend, Jl as setServerTracer, ho as setSourceGapSink, o_ as setSystemStoreHandle, pb as setTimelineRecorderForTest, Gh as setTupleSource, qr as settleHandlerBody, hf as sha256Hex, jf as sha256HexOf, Td as shutdownGraceMsFromEnv, nv as singleCoordinator, io as snapshotMetrics, ao as snapshotMetricsSync, Co as sourceGapReport, rg as ssrfGuardHttpClientLayer, ng as ssrfReason, _d as startRpcServer, yv as startScheduler, Rm as storeCredential, qo as stripColumnsFromRows, Xo as stripForbiddenForWire, Jo as stripServerOnlyForWire, aa as subscriptionSocketMetricSamples, ia as subscriptionSocketMetricsSnapshot, fh as sweepExpiredGrants, st as sweepRetention, ey as synthesizeInverse, ct as tenantSelectionId, Ef as tenantSelectionStore, Zh as tracingHttpClientLayer, Mp as triggerWorkflow, K_ as tryClaimWakeup, Hs as unbindConnection, Vv as undoCaptureEnabled, fy as undoLogExecutor, Hv as undoSurfaceEnabled, Ov as unregisterExternalizedTask, Pg as unresolvedSources, wS as useAggregate, eS as useAnalytics, ox as useCostBudget, Hb as useExpectation, Sx as useExperiment, Lh as visibleRows, Px as wakeDueOnce, Pu as webhookVerificationOf, IS as withRowFilter, ZS as withScopedRequest, Zl as withServerTracer, nb as workflowDomainEventsExecutor, rb as workflowEventDeliveriesExecutor, Ky as workflowRowVisibleTo, eb as workflowRunEventsExecutor, Zy as workflowRunExecutor, $y as workflowRunStepsExecutor, Qy as workflowRunsExecutor, Gv as wrapCaptureStore, vg as wrapStoreWithBootCodec, El as wrapStoreWithMixinBehaviour, Yg as writeReplicaObservation };
|
|
13178
|
+
export { mf as ACTORS_TABLE, Cu as API_CSP, pf as API_KEYS_TABLE, Sy as APPROVALS_TABLE, Mh as AccessDenied, OS as AggregateError, jb as AggregateMaintainer, DS as AggregateNotFound, kS as AggregateRegistry, ES as AggregateStale, rS as AnalyticsCapabilityNotSupported, nS as AnalyticsError, iS as AnalyticsSink, dv as CLAIM_RETENTION_BUCKETS, Y as CONNECTIONS_TABLE, Am as CONNECTION_GRANTS_TABLE, u_ as CircuitBreaker, c_ as CircuitOpen, eh as ConnectionNotConnected, Vt as ConstraintViolation, vx as CostAccountant, dx as CostRegistry, vS as DEFAULT_ANALYTICS_MIRROR_TUNABLES, Cy as DEFAULT_APPROVAL_EXPIRY_MS, uv as DEFAULT_CLAIM_BUCKET_MS, Nl as DEFAULT_COMPRESSION_MIN_BYTES, Ai as DEFAULT_CRDT_COMPACT_MAX_BYTES, bi as DEFAULT_DELIVERY_CONCURRENCY, hv as DEFAULT_EXTERNAL_RECONCILE_MS, mv as DEFAULT_EXTERNAL_TRIGGER_SKEW_MS, Tu as DEFAULT_HSTS, ws as DEFAULT_KEEP_ALIVE_MS, Lv as DEFAULT_MAX_IDLE_INTERVAL_MS, gd as DEFAULT_MAX_RPC_BODY_BYTES, E_ as DEFAULT_MAX_RUNTIME_MS, JS as DEFAULT_MUTATION_REPLAY_ATTEMPTS, bm as DEFAULT_OUTBOX_CLAIM_LEASE_MS, xi as DEFAULT_RAW_READ_TRACKING_LIMIT, Qm as DEFAULT_REFRESH_SKEW_MS, fc as DEFAULT_RESUME_MAX_DELTAS, dc as DEFAULT_RESUME_WINDOW_MS, Eo as DEFAULT_ROW_FILTER_RETRY, bv as DEFAULT_SCHEDULE_HEARTBEAT_MS, tc as DEFAULT_SOCKET_MAX_BUFFERED_BYTES, nc as DEFAULT_SOCKET_OVERRUN_AFTER_MS, rc as DEFAULT_SOCKET_OVERSIZED_EVENT_BYTES, ic as DEFAULT_SOCKET_STALL_WARN_AFTER_MS, o_ as DEFAULT_STALE_AFTER_MS, kf as DEVICES_TABLE, sv as DORMANCY_WAKEUP_TENANT, _l as DeleteBuilder, ms as Dispatcher, nm as EVENT_CLIENT_QUEUE_SIZE, rm as EVENT_LATEST_QUEUE_SIZE, gv as EXTERNAL_TRIGGER_AHEAD_TOLERANCE_MS, $f as EffectStore, Zp as EventBus, rx as ExpectationEvaluator, qb as ExpectationRegistry, Lx as ExperimentEvaluator, Dx as ExperimentRegistry, fh as GRANT_TTL_MS, Ts as HEADERS_TIMEOUT_MARGIN_MS, bx as HOLDOUT_VARIANT, wu as HTML_CSP, gi as InMemoryDataStore, ti as IndexedMatcher, lm as InstanceMembership, Jr as LinearScanMatcher, Ov as MIN_EXTERNALIZABLE_INTERVAL_MS, m as MetricBoundaries, sS as NOOP_ANALYTICS_PROVIDER, No as NO_ROW_FILTER, du as NO_TRUSTED_PROXIES, Qt as NoRowFound, Eu as ORIGIN_NULLING_REFERRER_POLICIES, pm as OUTBOX_ATTEMPTS_TABLE, xm as OUTBOX_ATTEMPT_LOG_CAP, J as OUTBOX_TABLE, dl as OptimisticLockError, jh as REBAC_ADMIN_SCOPE, $m as REFRESH_LEASE_MS, Zg as REPLICA_OBSERVATIONS_TABLE, yC as RUNTIME_NAME, Vb as ReactionRateLimiter, cs as ReplicatedDataStore, To as RowFilterDeclarationViolated, wo as RowFilterUnavailable, ov as SCHEDULE_SUBJECT, Zf as SYSTEM_SUBJECT, hl as SelectBuilder, tn as ServerOnlyColumnWrite, ig as SsrfBlockedError, rn as StoreOperationFailed, ii as SubscriptionRegistry, ne as TENANT_SELECTIONS_TABLE, yv as TERMINAL_RUN_STATUSES, Dl as TRANSACTION_READ_CONFLICT_NAME, Al as TX_READ_VERSIONS_KEY, sn as TableValidationFailed, ln as TenantRowNotFound, dn as TenantScopeViolation, gb as TimelineRecorder, Ol as TransactionReadConflict, sy as UndoBoundaryError, ly as UndoStack, Fu as UnverifiedWebhookRoute, gl as UpdateBuilder, dg as VOLTRO_AUDIT_MIXIN_ID, pg as VOLTRO_EXPIRES_MIXIN_ID, hg as VOLTRO_LOCAL_FIRST_MIXIN_ID, fg as VOLTRO_SOFT_DELETE_MIXIN_ID, mg as VOLTRO_TENANT_MIXIN_ID, Mu as WEBHOOK_VERIFICATION_PROPERTY, kp as WorkflowPayloadError, Sp as WorkflowRateLimitedError, Cp as WorkflowSingletonHeldError, mp as WorkflowStartNotExecuted, qs as _connectionStreamCount, Js as _resetConnectionCredentialsForTest, wy as _voltroApprovalsTable, Wv as _voltroChangeClaimsTable, Mm as _voltroConnectionGrantsTable, km as _voltroConnectionsTable, Mb as _voltroRebacTuplesTable, Uv as _voltroScheduleClaimsTable, Hv as _voltroScheduleRunsTable, Gv as _voltroTracesTable, Kv as _voltroUndoLogTable, zx as _voltroWakeupsTable, Gp as _voltroWorkflowEventDeliveriesTable, Wp as _voltroWorkflowEventsTable, Tl as actingUserId, Dc as adoptDetached, Sc as answerResume, Xf as apiKeyManagementRoutes, yi as appValidation, Ws as applyConnectionCredential, GS as applyDeclaredRelations, Sl as applyDefined, kb as applyDelta, dy as applyInverse, fy as applyInverses, Os as applyKeepAlive, Jg as applyPluginRefRules, Uo as applyRowFilter, Wo as applyRowFilterToDescriptor, PS as applySoftDeleteScope, jS as applyTenantScope, by as applyUndoInvocation, Ay as approvalIntentKey, Ky as approvalNonce, Jy as approvalsPendingExecutor, Hh as assertCan, Lm as assertConnectionCipherConfigured, Iu as assertWebhookRoutesDeclareVerification, Tx as assignVariant, CS as attachAnalyticsMirror, ix as attachExpectations, Rx as attachExperiments, yx as attachFinops, Od as awaitServerListening, ym as backoffMs, gh as beginOAuthConnect, Zu as bindComputedUntyped, Bs as bindConnectionCredential, om as bindEvent, hd as bindMutation, ed as bindStream, Qu as bindSubscription, qu as bindSubscriptionUntyped, Db as buildIvmState, gC as buildPreview, Fb as buildRebacInterceptor, Lb as buildRebacReadFilter, ts as buildSubjectKey, Fd as buildTracingLayer, Lg as cacheScopeLeaks, Xd as cachedBackend, Vh as can, Y_ as cancelWakeup, _c as canonicalInputKey, ky as canonicalJson, ni as canonicalize, fv as claimGraceMs, O as classifyConstraintViolation, uo as classifyRead, lu as classifyRequestOrigin, Sb as classifyShape, Hy as clearApprovalGate, ih as clearConnectionRefreshFlights, Lh as clearResourcePolicies, se as clearRetentions, p_ as clearSystemStoreHandle, Of as clearTenantSelection, Yg as collectPluginRefRules, qg as collectReferenceSoftDeleteRules, O_ as compileCron, _h as completeOAuthConnect, uS as composeAnalytics, lS as composeAnalyticsSinks, ph as connectionCallbackPath, Im as connectionLabel, Qx as countRunningWorkflows, eo as counter, Ni as crdtCompactMaxBytes, kv as cronForInterval, A_ as cronOccurrences, Mg as crud, Di as currentRawReads, qh as currentRequestLoader, ss as currentRoutingContext, Ic as currentTraceContext, Tf as dataStoreApiKeyStore, Uf as dataStoreDeviceStore, rf as dataStoreIdempotencyStore, uf as dataStoreKvStore, Wy as decideApproval, Yy as decideApprovalInvocation, qc as decryptField, dd as defectMessage, wS as defineAggregate, Fm as defineConnection, lx as defineCostBudget, zp as defineEventTrigger, IS as defineExecutor, Gb as defineExpectation, Sx as defineExperiment, gm as defineOutboxHandler, Rb as defineReaction, Ph as defineResourcePolicy, D_ as defineSchedule, tS as defineSubscriber, fs as deliveredRowCount, Rc as deriveKey, Ec as detachForResume, qf as deviceManagementRoutes, Mf as deviceTokenPrefixes, hC as diffChange, Ed as drainForShutdown, Em as drainOutbox, nv as dueWakeups, Bh as effectiveRelations, Sg as emptySchemaRegistry, $c as enableGraphObservation, Kc as encryptField, Uy as enforceApproval, _o as enterReadRecording, Kh as enterRequestLoader, Wd as envSecretsBackend, ry as evaluateTouchedRules, Ia as eventMetricTagCacheSizeForTests, Xm as exchangeAuthorizationCode, Mc as externalSpanFromTraceparent, Av as externalizationRefusal, Fv as externalizedTask, Iv as externalizedTaskNames, ve as extractDbCause, ri as fingerprintFor, Yo as forbiddenColumnsForSubject, Km as forgetCredential, a_ as forgetReplicaObservations, Rg as formatCacheScopeLeaks, Ig as formatServerOnlyLeaks, Ac as formatTraceparent, Vg as formatUnresolvedSources, uy as forwardChangeFromCdc, Jf as frameworkApiKeyStrategy, Wf as frameworkDeviceStrategy, to as gauge, gf as generateApiKeyToken, Vy as getApprovalGate, Vs as getConnectionCredential, xh as getConnectionResolver, zs as getCredentialExpiry, Wc as getFieldCipher, Fh as getResourcePolicy, jo as getRowFilter, Qs as getRpcConnection, m_ as getSystemStoreHandle, vb as getTimelineRecorder, Qh as getTupleSource, wb as groupKeyOf, wx as hashUnitInterval, no as histogramMetric, pC as historyProvenance, Zd as httpSecretsBackend, pp as insertIgnoreRowOutcomeEffect, up as insertManyRowsEffect, lp as insertRowEffect, Ur as inspectWorkflow, By as installApprovalGate, eg as installPolicyGuardResolver, Ks as interruptConnectionStreams, ay as invertChange, hu as ipToBytes, TS as isAggregateDefinition, Fl as isCompressibleContentType, ux as isCostBudgetDefinition, MS as isEmptyTenantScopedRead, Kb as isExpectationDefinition, Cx as isExperimentDefinition, Ee as isForeignKeyViolation, Gx as isIdleNow, cd as isInfraError, el as isObservingGraph, NS as isOrglessUserSubject, Oe as isQueryTimeout, cy as isSafeToApply, T_ as isScheduleDefinition, Gg as isSoftDelete, $l as isStateChangingMethod, kl as isTransactionReadConflict, yu as isTrustedProxy, Bp as isWorkflowEventTriggerDefinition, Ti as isolateRawReadScope, Eb as ivmValue, fC as lastWriteProvenance, qm as listConnectionStates, Ih as listResourcePolicies, Ne as listRetentionConflicts, Pe as listRetentions, Nb as loadResourceTuples, Ib as loadSubjectTuples, x_ as localityAwareSelector, sC as makeActionRunner, pv as makeAdvisoryLockCoordinator, Bc as makeAesCipher, yf as makeApiKeyService, ug as makeApiKeyUsageBuffer, wf as makeApiKeyUsageFlusher, vi as makeAppAccess, Ry as makeApprovalGate, df as makeAsyncKv, b_ as makeAuthMiddlewareLayers, am as makeBufferGapDetector, Ud as makeBufferingSpanProcessor, Rm as makeConnectionRegistry, Ch as makeConnectionResolver, y_ as makeConnectionState, wh as makeConnectionsFacade, Vv as makeCoordinatedScheduler, ng as makeDataLoader, Go as makeDefaultRefilter, Lf as makeDeviceService, Ah as makeDisconnectConnectionExecutor, sp as makeEffectStoreLayer, tm as makeEventPublisher, Kp as makeEventsFacade, Vc as makeFieldCipher, vl as makeFluentStore, Kx as makeIdleGate, Fp as makeLazyWorkflowFacade, Dh as makeListConnectionsExecutor, pd as makeMutationOutputCodec, ZS as makeMutationRunner, aC as makeOneShotQueryRunner, nu as makeOriginGuardExemption, vm as makeOutboxFacade, Hx as makeProcessAdapter, iC as makeQueryDescriptorProducer, FS as makeQueryFinalizer, nC as makeQueryReauthorizer, oC as makeQuerySubscriber, qx as makeRouterActivity, ty as makeRuleCapture, gg as makeSchemaRegistry, Oh as makeStartConnectionExecutor, kh as makeSubmitTokenExecutor, lc as makeSubscriptionOutbox, Np as makeTransactionalWorkflowFacade, Qv as makeUndoCapture, Jx as makeWakeGate, Zx as makeWakeProxyServer, Mp as makeWorkflowFacade, Pp as makeWorkflowFacadeWithCallerContext, Ip as makeWorkflowHandlers, Lp as makeWorkflowLayers, Tp as makeWorkflowRunHandle, QS as makeWorkflowStartRunner, X_ as markWakeupFired, Ob as materializeIvm, Rl as maybeCompress, bf as memoryApiKeyStore, Rf as memoryDeviceStore, C_ as memoryReplicationAdapter, es as memoryRywPositionStore, Us as mergeCookieHeader, s_ as mergeFleetObservations, ul as missingRowError, Il as negotiateEncoding, Nc as newTraceId, Bv as nextDelay, k_ as nextFiring, rv as nextWakeup, Wx as nodeProcessSupervisor, cS as noopAnalytics, dS as noopAnalyticsSpec, ff as noopKv, fu as normalizeIp, iu as normalizeOrigin, xo as noteRead, Ul as noteResumeVerdict, Io as noteRowFilterResolved, Nm as oauthCredentialValue, al as observeStore, rl as observedGraph, xd as onProcessShutdown, Md as otelImportFailure, hm as outboxAttemptsTable, fm as outboxTable, Ly as parseApprovalInterval, jc as parseTraceparent, Ap as payloadPropertyNames, wv as peerRunIsAlive, Gy as pendingApprovalsFor, Cf as plantMissingApiKeyActors, Zo as powerOfTwoSelector, Du as preservesSameOriginHeader, vC as previewInRollback, Hm as projectConnectionState, av as pruneWakeups, $p as publishEvent, Xl as publishServerTracerLayer, uc as pumpOutbox, ki as rawSqlPreview, sc as reactiveSocketTunables, Lc as readMaybeOne, Rv as readPollCeilingMs, go as readRecordingActive, n_ as readReplicaObservations, Rh as rebacPolicyGraph, $i as recordCoalesced, Rs as recordCredentialExpiry, Ra as recordEventDelivered, za as recordEventDropped, La as recordEventPublished, Ba as recordEventSubscribers, Qa as recordExternalMissed, Za as recordExternalTrigger, xc as recordForResume, ea as recordOverrun, ta as recordOversized, Ei as recordRawRead, vo as recordReads, Va as recordSample, Xa as recordScheduleQueueRecovery, Ya as recordScheduleQueueWait, Ja as recordScheduleQueued, Ka as recordScheduleRun, na as recordStalled, Ga as recordSubscriptionActive, Ua as recordSubscriptionDelivery, nl as recordTableAccess, bb as recordTimelineEvent, $a as recordWorkflowRun, So as recordingStore, Og as redactColumns, pb as redactRow, ns as redisRywPositionStore, xy as redoUndoInvocation, Zm as refreshAccessToken, Gs as registerConnectionStream, $h as registerDefaultTupleSource, Nv as registerExternalizedTask, Ke as registerRetention, J_ as registerWakeup, Dy as rehydrateGuards, $_ as releaseWakeup, Qo as replicaHealth, Yu as resetComputedQueryCacheWarnings, Oc as resetDetachedForTest, Fa as resetEventMetricTagCacheForTests, il as resetObservedGraph, e_ as resetReplicaObservationWarnings, Gl as resetResumeCensus, Cc as resetResumeRingsForTest, Ro as resetRowFilterResolvedArms, qd as resetSecretsBackend, oa as resetSubscriptionSocketMetrics, xu as resolveClientAddress, sh as resolveConnection, Sh as resolveConnectionForSubject, S_ as resolveCurrentRegion, Ri as resolveDependentTables, Ds as resolveKeepAlive, uu as resolveOriginGuardConfig, Ci as resolveReactiveConfig, hh as resolveRedirectUri, Su as resolveRequestIsHttps, Ab as resolveRescan, zo as resolveRowFilterScope, Bo as resolveRowFilterScopeFor, Jd as resolveSecret, Yd as resolveSecretSync, Qd as resolveSecretsBackend, Au as resolveSecurityHeaders, ub as resolveTimelineMode, j_ as resolveTransactionSubject, bu as resolveTrustedProxies, yo as restrictingReads, bo as restrictingReadsEffect, Ex as resultVariantNames, Wl as resumeCensus, gc as resumeKeyOf, hc as resumeTunables, Ye as retentionTtlMsFromEnv, xs as revalidatePath, Ss as revalidateTable, Cs as revalidateTag, hb as reverseEventOverRows, Wh as revokedIds, Ho as rowFilterMayNarrow, Mo as rowFilterRegistered, Lo as rowFilterResolvedArms, Kg as rulesFor, h_ as runAsSystem, $x as runOrchestratorTick, LS as runProvidedEffect, Ub as runReaction, eS as runSingleNodeOrchestrator, Vx as runWakeLoop, XS as runWithDeadlockRetry, tl as runWithObservedProcedure, Oi as runWithRawReadScope, Jh as runWithRequestLoader, as as runWithRoutingContext, os as runWithRoutingContextEffect, Fc as runWithTraceContext, mh as sanitizeRedirectTo, F_ as scheduleBackfillRequestsTable, zv as scheduleCoordinated, Ng as schemaPropertyNames, Oy as scopeStringsOf, ju as securityHeadersFor, Df as selectTenant, Ey as serializeGuards, Ko as serverOnlyColumnNames, Fg as serverOnlyLeaks, Yl as serverTracer, Qi as setBufferedBytes, bh as setConnectionResolver, Mi as setCrdtCompactMaxBytes, Uc as setFieldCipher, oc as setReactiveSocketTunables, mc as setResumeTunables, ys as setRevalidationPublisher, Ao as setRowFilter, Kd as setSecretsBackend, Jl as setServerTracer, ho as setSourceGapSink, f_ as setSystemStoreHandle, yb as setTimelineRecorderForTest, Zh as setTupleSource, qr as settleHandlerBody, hf as sha256Hex, jf as sha256HexOf, Td as shutdownGraceMsFromEnv, cv as singleCoordinator, io as snapshotMetrics, ao as snapshotMetricsSync, Co as sourceGapReport, lg as ssrfGuardHttpClientLayer, cg as ssrfReason, _d as startRpcServer, Tv as startScheduler, Wm as storeCredential, qo as stripColumnsFromRows, Xo as stripForbiddenForWire, Jo as stripServerOnlyForWire, aa as subscriptionSocketMetricSamples, ia as subscriptionSocketMetricsSnapshot, vh as sweepExpiredGrants, st as sweepRetention, oy as synthesizeInverse, ct as tenantSelectionId, Ef as tenantSelectionStore, rg as tracingHttpClientLayer, Rp as triggerWorkflow, Q_ as tryClaimWakeup, Hs as unbindConnection, qv as undoCaptureEnabled, vy as undoLogExecutor, Jv as undoSurfaceEnabled, Pv as unregisterExternalizedTask, Bg as unresolvedSources, dp as upsertRowEffect, fp as upsertRowOutcomeEffect, AS as useAggregate, oS as useAnalytics, fx as useCostBudget, Jb as useExpectation, Ox as useExperiment, Uh as visibleRows, Bx as wakeDueOnce, Pu as webhookVerificationOf, HS as withRowFilter, rC as withScopedRequest, Zl as withServerTracer, cb as workflowDomainEventsExecutor, lb as workflowEventDeliveriesExecutor, Qy as workflowRowVisibleTo, ob as workflowRunEventsExecutor, rb as workflowRunExecutor, ab as workflowRunStepsExecutor, ib as workflowRunsExecutor, Zv as wrapCaptureStore, wg as wrapStoreWithBootCodec, El as wrapStoreWithMixinBehaviour, t_ as writeReplicaObservation };
|