@voltro/runtime 0.86.0 → 0.88.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 +5484 -0
- package/README.md +43 -0
- package/THIRD-PARTY-NOTICES.md +1511 -276
- package/dist/aggregate.js +1 -2
- package/dist/aggregateExtrema.js +1 -2
- package/dist/aggregateIvm.js +1 -2
- package/dist/analyticsMirror.js +1 -2
- package/dist/analyticsSink.js +9 -16
- package/dist/apiKeyUsage.js +1 -2
- package/dist/apiKeys.js +83 -80
- package/dist/apiKeysWiring.js +1 -2
- package/dist/apiRoleBucketSampler.js +63 -0
- package/dist/apiRoleWorkloadHistory.js +55 -0
- package/dist/apiRoleWorkloadMetrics.js +77 -0
- package/dist/apiRoleWorkloadStorage.js +94 -0
- package/dist/approvalBuiltins.js +1 -2
- package/dist/approvals.js +68 -76
- package/dist/authMiddlewareLayer.js +8 -8
- package/dist/bindEvent.js +49 -30
- package/dist/boot-refusal.d.ts +10 -0
- package/dist/{bootRefusal.js → boot-refusal.js} +1 -2
- package/dist/bootListener.js +203 -47
- package/dist/bootStoreCodec.js +39 -39
- package/dist/businessRules.js +1 -2
- package/dist/changeClaimsTable.js +1 -2
- package/dist/circuitBreaker.js +1 -72
- package/dist/columnOnUpdate.js +1 -2
- package/dist/composeAnalytics.js +32 -12
- package/dist/computedQuery.js +1 -2
- package/dist/computedQueryCache.js +289 -0
- package/dist/connectionBuiltins.js +1 -2
- package/dist/connectionCredentials.js +1 -2
- package/dist/connectionState.js +1 -2
- package/dist/connectionVault.js +1 -2
- package/dist/connectionsFacade.js +33 -32
- package/dist/coordinatedSchedule.js +85 -80
- package/dist/crdtHistory.js +1 -2
- package/dist/crdtMerge.js +1 -2
- package/dist/crdtVersionsTable.js +1 -2
- package/dist/credentialBound.js +1 -2
- package/dist/crud.js +1 -2
- package/dist/dataStore.js +155 -123
- package/dist/dataloader.js +1 -2
- package/dist/declaredTablesGuard.js +3 -3
- package/dist/defineExecutor.js +1 -2
- package/dist/dependencyGraph.js +1 -2
- package/dist/devices.js +1 -2
- package/dist/devicesWiring.js +1 -2
- package/dist/dialectReplicationAdapter.js +1 -2
- package/dist/dispatcher.js +404 -330
- package/dist/effectStore.js +3 -4
- package/dist/engineClients.js +23 -0
- package/dist/eventBus.js +1 -2
- package/dist/eventPublish.js +1 -2
- package/dist/events.js +1 -2
- package/dist/expectation.js +1 -2
- package/dist/expectationEvaluator.js +2 -3
- package/dist/experiment.js +1 -2
- package/dist/experimentEvaluator.js +1 -2
- package/dist/externalizedTasks.js +20 -8
- package/dist/fieldCipher.js +110 -42
- package/dist/fieldKeyRegistry.js +294 -0
- package/dist/fieldKeyRekey.js +285 -0
- package/dist/fieldKeyScan.js +135 -0
- package/dist/fieldKeyring.js +76 -0
- package/dist/fingerprint.js +1 -2
- package/dist/finops.js +1 -2
- package/dist/finopsAccountant.js +1 -2
- package/dist/handlerBody.js +1 -2
- package/dist/healthProbes.js +1 -2
- package/dist/hot.d.ts +56 -0
- package/dist/hot.js +3 -0
- package/dist/hotDataStore.js +147 -0
- package/dist/hotDataStoreSnapshot.js +97 -0
- package/dist/hotDataStoreTables.js +17 -0
- package/dist/http-range.d.ts +53 -0
- package/dist/http-range.js +51 -0
- package/dist/httpClientSsrf.js +13 -39
- package/dist/httpClientTracing.js +13 -11
- package/dist/httpCompression.js +18 -19
- package/dist/httpInputStream.js +81 -0
- package/dist/httpKeepAlive.js +1 -2
- package/dist/httpRouteMounts.js +2 -2
- package/dist/idempotencyStore.js +93 -54
- package/dist/idleDetector.js +1 -2
- package/dist/index.d.ts +1185 -452
- package/dist/index.js +144 -134
- package/dist/insertRequiredColumns.js +1 -2
- package/dist/instanceMembership.js +1 -2
- package/dist/ivm.js +1 -2
- package/dist/kvDataStore.js +1 -2
- package/dist/kvFacade.js +24 -19
- package/dist/matcher.js +1 -2
- package/dist/memoryColumnDefaults.js +1 -2
- package/dist/memoryQueryJoins.js +17 -18
- package/dist/memorySetOperations.js +42 -0
- package/dist/metrics.js +39 -26
- package/dist/observability.js +2 -3
- package/dist/observedGraph.js +1 -2
- package/dist/originGuard.js +1 -2
- package/dist/outbox.js +2 -3
- package/dist/pluginRefRules.js +1 -2
- package/dist/policyGuardResolver.js +1 -2
- package/dist/preview.js +1 -2
- package/dist/projectedRows.js +1 -2
- package/dist/provenance.js +1 -2
- package/dist/rangeIndex.js +1 -2
- package/dist/rawReadScope.js +2 -3
- package/dist/reaction.js +1 -2
- package/dist/reactiveConfig.js +1 -2
- package/dist/readClassification.js +1 -2
- package/dist/readRecorder.js +36 -36
- package/dist/readScopePredicate.js +11 -0
- package/dist/rebac.js +1 -2
- package/dist/rebacInterceptor.js +1 -2
- package/dist/registry.js +1 -2
- package/dist/relevantFields.js +1 -2
- package/dist/replicaHealth.js +1 -2
- package/dist/replicaLocality.js +1 -2
- package/dist/replicaObservations.js +1 -2
- package/dist/replicaSelection.js +1 -2
- package/dist/replicatedDataStore.js +23 -6
- package/dist/requestLoader.js +1 -2
- package/dist/resumeCensus.js +1 -2
- package/dist/revalidation.js +1 -2
- package/dist/rowFilter.js +57 -41
- package/dist/rowStateBytes.js +1 -2
- package/dist/rpcBodyCap.js +1 -2
- package/dist/rpcConnections.js +9 -10
- package/dist/rpcDefectDiagnostics.js +1 -2
- package/dist/rpcServer.js +523 -451
- package/dist/rpcWorkloadAdmission.js +49 -0
- package/dist/runAsSystem.js +1 -2
- package/dist/rywPositionStore.js +83 -49
- package/dist/schedule.js +1 -2
- package/dist/scheduleBackfillRequests.js +1 -2
- package/dist/scheduleClaimsTable.js +1 -2
- package/dist/scheduleRunsTable.js +1 -2
- package/dist/scheduler.js +7 -3
- package/dist/schemaRegistry.js +1 -2
- package/dist/secretsResolver.js +1 -2
- package/dist/securityHeaders.js +1 -2
- package/dist/servePipeline.js +238 -154
- package/dist/serverOnlyAudit.js +1 -2
- package/dist/serverTracer.js +1 -2
- package/dist/serviceCredentials.js +1 -2
- package/dist/setReadScopes.js +27 -0
- package/dist/singleNodeOrchestrator.js +1 -2
- package/dist/snapshotValueCodec.js +45 -0
- package/dist/sourceResolution.js +35 -26
- package/dist/storeMiddleware.js +213 -212
- package/dist/storeQuery.js +1 -2
- package/dist/storeRead.js +1 -2
- package/dist/subscriber.js +2 -2
- package/dist/subscriptionOutbox.js +1 -2
- package/dist/subscriptionRegistry.js +1 -2
- package/dist/subscriptionResume.js +1 -2
- package/dist/subscriptionSocketMetrics.js +1 -2
- package/dist/systemSubject.js +1 -2
- package/dist/tenantScope.js +9 -22
- package/dist/tenantSelection.js +1 -2
- package/dist/timeline.js +1 -2
- package/dist/traceContext.js +1 -2
- package/dist/traceSink.js +1 -2
- package/dist/traceSpansTable.js +1 -2
- package/dist/traceparent.js +9 -21
- package/dist/transactionSubject.js +1 -2
- package/dist/trustedProxy.js +2 -3
- package/dist/undo.js +1 -2
- package/dist/undoBuiltins.js +1 -2
- package/dist/undoCapture.js +1 -2
- package/dist/undoLogTable.js +1 -2
- package/dist/upsertBinding.js +1 -2
- package/dist/wakeOrchestrator.js +1 -2
- package/dist/wakeRegistry.js +1 -2
- package/dist/wakeRouter.js +1 -2
- package/dist/wakeSupervisor.js +1 -2
- package/dist/wakeupsTable.js +1 -2
- package/dist/webSocketGatewayRuntime.js +112 -73
- package/dist/webhookVerification.js +1 -2
- package/dist/wireColumnStrip.js +1 -2
- package/dist/workflowReadBuiltins.js +1 -2
- package/dist/workflowRuntime.js +10 -11
- package/package.json +36 -17
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
import { canonicalize as e } from "./fingerprint.js";
|
|
2
|
+
import { currentRawReads as t, runWithRawReadScope as n } from "./rawReadScope.js";
|
|
3
|
+
import { classifyRead as r } from "./readClassification.js";
|
|
4
|
+
import { buildSubjectKey as i } from "./rywPositionStore.js";
|
|
5
|
+
import { runWithRoutingContext as a } from "./replicatedDataStore.js";
|
|
6
|
+
import { Effect as o, Option as s, Schema as c } from "effect";
|
|
7
|
+
import { createHash as l } from "node:crypto";
|
|
8
|
+
import { Unauthenticated as u, currentSubjectAuthority as d, effectiveScopes as f, parseRevalidateMs as p, schemaShape as m, setEffectiveScopes as h, shapeDigest as g } from "@voltro/protocol";
|
|
9
|
+
import { AsyncLocalStorage as _ } from "node:async_hooks";
|
|
10
|
+
// src/computedQueryCache.ts
|
|
11
|
+
var v = Symbol.for("@voltro/runtime:computed-query-cache-capture"), y = () => {
|
|
12
|
+
let e = globalThis, t = e[v];
|
|
13
|
+
return t === void 0 && (t = {
|
|
14
|
+
storage: new _(),
|
|
15
|
+
installed: !1
|
|
16
|
+
}, e[v] = t), t;
|
|
17
|
+
}, b = () => {
|
|
18
|
+
y().installed = !0;
|
|
19
|
+
}, x = () => y().installed, S = () => {
|
|
20
|
+
y().installed = !1;
|
|
21
|
+
}, C = (e) => {
|
|
22
|
+
let t = y().storage.getStore();
|
|
23
|
+
if (t === void 0) return;
|
|
24
|
+
let { composed: n, restricting: i } = r(e, !1);
|
|
25
|
+
for (let e of n) t.tables.add(e);
|
|
26
|
+
for (let e of i) t.tables.add(e);
|
|
27
|
+
}, w = Symbol.for("@voltro/runtime:query-dependencies"), T = () => {
|
|
28
|
+
let e = globalThis, t = e[w];
|
|
29
|
+
return t === void 0 && (t = { storage: new _() }, e[w] = t), t;
|
|
30
|
+
}, E = () => {
|
|
31
|
+
T().storage.enterWith(/* @__PURE__ */ new Set());
|
|
32
|
+
}, D = () => [...T().storage.getStore() ?? []], O = (e) => {
|
|
33
|
+
T().storage.getStore()?.add(e), y().storage.getStore()?.tables.add(e);
|
|
34
|
+
}, k = (e) => {
|
|
35
|
+
y().storage.getStore()?.volatile.add(e);
|
|
36
|
+
}, A = (e, t) => y().storage.run(e, t), j = () => ({
|
|
37
|
+
tables: /* @__PURE__ */ new Set(),
|
|
38
|
+
caller: /* @__PURE__ */ new Set(),
|
|
39
|
+
volatile: /* @__PURE__ */ new Set()
|
|
40
|
+
}), M = /* @__PURE__ */ new Set([
|
|
41
|
+
"connections",
|
|
42
|
+
"apis",
|
|
43
|
+
"kv",
|
|
44
|
+
"cache",
|
|
45
|
+
"webhooks",
|
|
46
|
+
"workflows",
|
|
47
|
+
"events",
|
|
48
|
+
"outbox",
|
|
49
|
+
"transaction",
|
|
50
|
+
"storeForTenant"
|
|
51
|
+
]), N = /* @__PURE__ */ new Set(["access", "connectionState"]), P = (e, t, n) => new Proxy(e, { get(e, r) {
|
|
52
|
+
return typeof r == "string" && !t.has(r) && n.caller.add(`subject.${r}`), Reflect.get(e, r, e);
|
|
53
|
+
} }), F = (e, t, n, r = !1) => {
|
|
54
|
+
let i = e.request, a = i === void 0 ? void 0 : new Proxy(i, { get(e, r) {
|
|
55
|
+
return r === "subject" ? t : (typeof r == "string" && n.caller.add(`request.${r}`), Reflect.get(e, r, e));
|
|
56
|
+
} });
|
|
57
|
+
return new Proxy(e, { get(e, t) {
|
|
58
|
+
if (t === "request" && a !== void 0) return a;
|
|
59
|
+
typeof t == "string" && (M.has(t) && n.volatile.add(`ctx.${t}`), N.has(t) && !(r && t === "access") && n.caller.add(`ctx.${t}`));
|
|
60
|
+
let i = Reflect.get(e, t, e);
|
|
61
|
+
return typeof i == "function" ? i.bind(e) : i;
|
|
62
|
+
} });
|
|
63
|
+
}, I = (e) => {
|
|
64
|
+
let t = /* @__PURE__ */ new Set(), n = (e, r) => {
|
|
65
|
+
if (r > 64) throw Error("subject claims too deep");
|
|
66
|
+
if (e === void 0) return ["undefined"];
|
|
67
|
+
if (e === null || typeof e == "string" || typeof e == "boolean") return e;
|
|
68
|
+
if (typeof e == "number" && Number.isFinite(e)) return ["number", Object.is(e, -0) ? "-0" : e];
|
|
69
|
+
if (typeof e != "object" || !e || t.has(e)) throw Error("non-data subject claim");
|
|
70
|
+
let i = Object.getPrototypeOf(e);
|
|
71
|
+
if (!Array.isArray(e) && i !== Object.prototype && i !== null) throw Error("non-data subject claim");
|
|
72
|
+
if (Object.getOwnPropertySymbols(e).length > 0) throw Error("symbol subject claim");
|
|
73
|
+
t.add(e);
|
|
74
|
+
try {
|
|
75
|
+
if (Array.isArray(e)) {
|
|
76
|
+
if (i !== Array.prototype || Object.keys(e).length !== e.length || Object.getOwnPropertyNames(e).length !== e.length + 1) throw Error("non-data subject array");
|
|
77
|
+
return ["array", Array.from({ length: e.length }, (t, i) => {
|
|
78
|
+
let a = Object.getOwnPropertyDescriptor(e, String(i));
|
|
79
|
+
if (a === void 0 || !("value" in a)) throw Error("non-data subject array");
|
|
80
|
+
return n(a.value, r + 1);
|
|
81
|
+
})];
|
|
82
|
+
}
|
|
83
|
+
if (Object.getOwnPropertyNames(e).length !== Object.keys(e).length) throw Error("hidden subject claim");
|
|
84
|
+
return ["object", Object.keys(e).sort().map((t) => {
|
|
85
|
+
let i = Object.getOwnPropertyDescriptor(e, t);
|
|
86
|
+
if (i === void 0 || !("value" in i)) throw Error("accessor subject claim");
|
|
87
|
+
return [t, n(i.value, r + 1)];
|
|
88
|
+
})];
|
|
89
|
+
} finally {
|
|
90
|
+
t.delete(e);
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
try {
|
|
94
|
+
n(e, 0);
|
|
95
|
+
let t = e, r = "scopes" in t && t.scopes !== void 0 ? { scopes: [...new Set(t.scopes)].sort() } : {}, i = n({
|
|
96
|
+
subject: {
|
|
97
|
+
...e,
|
|
98
|
+
...r
|
|
99
|
+
},
|
|
100
|
+
effective: [...new Set(f(t))].sort()
|
|
101
|
+
}, 0);
|
|
102
|
+
return l("sha256").update(JSON.stringify(i)).digest("base64url");
|
|
103
|
+
} catch {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
}, L = /* @__PURE__ */ new WeakMap(), R = (e) => {
|
|
107
|
+
let t = L.get(e);
|
|
108
|
+
return t === void 0 && (t = c.toCodecJson(e), L.set(e, t)), t;
|
|
109
|
+
}, z = /* @__PURE__ */ new WeakMap(), B = (e) => {
|
|
110
|
+
if (e === void 0) return "none";
|
|
111
|
+
let t = z.get(e);
|
|
112
|
+
return t === void 0 && (t = g(m(e.ast)), z.set(e, t)), t;
|
|
113
|
+
}, V = (t) => {
|
|
114
|
+
let n = t.input === void 0 ? s.some(t.decodedInput) : c.encodeUnknownOption(R(t.input))(t.decodedInput);
|
|
115
|
+
if (s.isNone(n)) return { bypass: "input-not-encodable" };
|
|
116
|
+
let r;
|
|
117
|
+
if (t.scope === "global") r = "g";
|
|
118
|
+
else if (t.scope === "tenant") {
|
|
119
|
+
if (t.subject.tenantId == null) return { bypass: "no-tenant" };
|
|
120
|
+
r = `t:${t.subject.tenantId}`;
|
|
121
|
+
} else {
|
|
122
|
+
if (t.subject.type === "anonymous" || t.subject.id == null || t.subject.id === "") return { bypass: "anonymous-subject" };
|
|
123
|
+
let e = I(t.subject);
|
|
124
|
+
if (e === void 0) return { bypass: "subject-not-encodable" };
|
|
125
|
+
r = `s:${e}`;
|
|
126
|
+
}
|
|
127
|
+
let i = t.rowFilter === void 0 ? [] : [...t.declaredSources].sort().map((n) => [n, e(t.rowFilter(n) ?? null)]), a;
|
|
128
|
+
try {
|
|
129
|
+
a = JSON.stringify([
|
|
130
|
+
t.codeIdentity,
|
|
131
|
+
B(t.output),
|
|
132
|
+
e(n.value),
|
|
133
|
+
i
|
|
134
|
+
]);
|
|
135
|
+
} catch {
|
|
136
|
+
return { bypass: "input-not-encodable" };
|
|
137
|
+
}
|
|
138
|
+
let o = l("sha256").update(a).digest("base64url");
|
|
139
|
+
return { key: `cq:${t.name}:${o}:${r}` };
|
|
140
|
+
}, H = (e) => {
|
|
141
|
+
if (e.aborted) return { refused: {
|
|
142
|
+
reason: "aborted",
|
|
143
|
+
detail: []
|
|
144
|
+
} };
|
|
145
|
+
if (!e.volatileAllowed && e.scope.volatile.size > 0) return { refused: {
|
|
146
|
+
reason: "volatile",
|
|
147
|
+
detail: [...e.scope.volatile].sort()
|
|
148
|
+
} };
|
|
149
|
+
let t = e.rawReads.filter((e) => e.dependsOn.length === 0).map((e) => e.sql);
|
|
150
|
+
if (t.length > 0) return { refused: {
|
|
151
|
+
reason: "undeclared-raw-read",
|
|
152
|
+
detail: t
|
|
153
|
+
} };
|
|
154
|
+
let n = new Set(e.declaredSources);
|
|
155
|
+
for (let t of e.scope.tables) n.add(t);
|
|
156
|
+
for (let t of e.rawReads) for (let e of t.dependsOn) n.add(e);
|
|
157
|
+
if (e.rowFilter !== void 0) {
|
|
158
|
+
let t = new Set(e.declaredSources), r = [...n].filter((n) => !t.has(n) && e.rowFilter(n) !== void 0).sort();
|
|
159
|
+
if (r.length > 0) return { refused: {
|
|
160
|
+
reason: "row-filter-outside-source",
|
|
161
|
+
detail: r
|
|
162
|
+
} };
|
|
163
|
+
}
|
|
164
|
+
let r = e.output === void 0 ? s.some(e.value) : c.encodeUnknownOption(R(e.output))(e.value);
|
|
165
|
+
if (s.isNone(r)) return { refused: {
|
|
166
|
+
reason: "output-not-encodable",
|
|
167
|
+
detail: []
|
|
168
|
+
} };
|
|
169
|
+
let i;
|
|
170
|
+
try {
|
|
171
|
+
i = Buffer.byteLength(JSON.stringify(r.value) ?? "", "utf8");
|
|
172
|
+
} catch {
|
|
173
|
+
return { refused: {
|
|
174
|
+
reason: "output-not-encodable",
|
|
175
|
+
detail: []
|
|
176
|
+
} };
|
|
177
|
+
}
|
|
178
|
+
return e.scope.caller.size > 0 ? { refused: {
|
|
179
|
+
reason: "caller",
|
|
180
|
+
detail: [...e.scope.caller].sort()
|
|
181
|
+
} } : i > e.maxEntryBytes ? { refused: {
|
|
182
|
+
reason: "oversized",
|
|
183
|
+
detail: [`${i} bytes`]
|
|
184
|
+
} } : { store: {
|
|
185
|
+
stored: r.value,
|
|
186
|
+
tags: [...n].sort()
|
|
187
|
+
} };
|
|
188
|
+
}, U = (e, t) => e === void 0 ? s.some(t) : c.decodeUnknownOption(R(e))(t), W = (e, t) => {
|
|
189
|
+
let n = t.detail.join(", ");
|
|
190
|
+
switch (t.reason) {
|
|
191
|
+
case "caller": return `${e}: \`cache:\` result NOT kept — the handler read ${n}, which its cache scope does not key on. Use \`scope: 'subject'\` for subject claims and effective scopes, or declare access in \`guards:\`. Connection state, client ids and cookie headers are never keyed; keep those reads outside cached queries. Membership rows read through ctx.store become invalidation dependencies.`;
|
|
192
|
+
case "volatile": return `${e}: \`cache:\` result NOT kept — the handler used ${n}, which no table write invalidates. Declare \`cache: { …, volatile: true }\` to accept the ttl as the bound on that staleness, or drop \`cache:\`.`;
|
|
193
|
+
case "undeclared-raw-read": return `${e}: \`cache:\` result NOT kept — a raw read declares no tables, so no write could invalidate it: ${n}. Declare them: ctx.store.raw(fragment, { dependsOn: ['…'] }).`;
|
|
194
|
+
case "row-filter-outside-source": return `${e}: \`cache:\` result NOT kept — the registered row filter restricts ${n}, which the query reads but does not declare in \`source:\`. Add it to \`source:\` so the entry is keyed by what this caller may see there.`;
|
|
195
|
+
case "output-not-encodable": return `${e}: \`cache:\` result NOT kept — the value does not encode through the query's \`output\` schema.`;
|
|
196
|
+
case "oversized": return `${e}: \`cache:\` result NOT kept — ${n} exceeds the cache's maxEntryBytes.`;
|
|
197
|
+
case "aborted": return `${e}: \`cache:\` result NOT kept — the subscription closed while it was computed.`;
|
|
198
|
+
}
|
|
199
|
+
}, G = () => new u({ reason: "request authority changed while reading a cached query; authenticate again" }), K = (e) => {
|
|
200
|
+
let r = I(e.subject), s = o.suspend(() => {
|
|
201
|
+
let s = j(), c = e.policy.scope === "subject", l = new Set(c ? [
|
|
202
|
+
...Object.keys(e.subject),
|
|
203
|
+
"id",
|
|
204
|
+
"type",
|
|
205
|
+
"tenantId",
|
|
206
|
+
"scopes",
|
|
207
|
+
"metadata",
|
|
208
|
+
"kind",
|
|
209
|
+
"service",
|
|
210
|
+
"auditActorId"
|
|
211
|
+
] : e.policy.scope === "tenant" ? ["tenantId"] : []), u = P(e.subject, l, s), p = f(e.subject);
|
|
212
|
+
h(u, c ? p : new Proxy(p, { get(e, t, n) {
|
|
213
|
+
return s.caller.add("subject.scopes"), Reflect.get(e, t, n);
|
|
214
|
+
} }));
|
|
215
|
+
let m = F(e.ctx, u, s, c), g = [], _ = e.subject.id ?? "anonymous", v = {
|
|
216
|
+
subjectKey: i(_, void 0),
|
|
217
|
+
forcePrimary: !0
|
|
218
|
+
};
|
|
219
|
+
return o.tryPromise({
|
|
220
|
+
try: () => A(s, () => a(v, () => n(async () => {
|
|
221
|
+
let n = await e.execute(m, u);
|
|
222
|
+
if (r !== I(d(e.subject))) throw G();
|
|
223
|
+
return g = t(), n;
|
|
224
|
+
}))),
|
|
225
|
+
catch: (e) => e
|
|
226
|
+
}).pipe(o.map((t) => {
|
|
227
|
+
let n = new Set(e.sources), r = (e) => [...new Set(e)].filter((e) => !n.has(e)).sort();
|
|
228
|
+
if (e.isDescriptor(t)) return e.onDescriptor(), {
|
|
229
|
+
value: {
|
|
230
|
+
value: t,
|
|
231
|
+
dependencies: []
|
|
232
|
+
},
|
|
233
|
+
notApplicable: !0
|
|
234
|
+
};
|
|
235
|
+
let i = H({
|
|
236
|
+
scope: s,
|
|
237
|
+
cacheScope: e.policy.scope,
|
|
238
|
+
volatileAllowed: e.policy.volatile,
|
|
239
|
+
rawReads: g,
|
|
240
|
+
declaredSources: e.sources,
|
|
241
|
+
rowFilter: e.rowFilter,
|
|
242
|
+
output: e.output,
|
|
243
|
+
value: e.unwrap(t),
|
|
244
|
+
maxEntryBytes: e.cache.maxEntryBytes,
|
|
245
|
+
aborted: e.signal?.aborted === !0
|
|
246
|
+
});
|
|
247
|
+
if ("refused" in i) return i.refused.reason !== "aborted" && e.cache.notice(e.name, i.refused.reason, W(e.name, i.refused)), { value: {
|
|
248
|
+
value: t,
|
|
249
|
+
dependencies: r(s.tables)
|
|
250
|
+
} };
|
|
251
|
+
let a = r(i.store.tags);
|
|
252
|
+
return {
|
|
253
|
+
value: {
|
|
254
|
+
value: t,
|
|
255
|
+
dependencies: a
|
|
256
|
+
},
|
|
257
|
+
store: {
|
|
258
|
+
stored: {
|
|
259
|
+
v: i.store.stored,
|
|
260
|
+
d: a
|
|
261
|
+
},
|
|
262
|
+
tags: i.store.tags
|
|
263
|
+
}
|
|
264
|
+
};
|
|
265
|
+
}), o.flatMap((t) => r === I(d(e.subject)) ? o.succeed(t) : o.fail(G())));
|
|
266
|
+
});
|
|
267
|
+
return e.cache.wrapDynamic(e.key, {
|
|
268
|
+
ttlMs: e.policy.ttlMs,
|
|
269
|
+
...e.policy.swrMs === void 0 ? {} : { swrMs: e.policy.swrMs },
|
|
270
|
+
...e.cache.leaseMs === void 0 ? {} : { leaseMs: e.cache.leaseMs },
|
|
271
|
+
label: e.name
|
|
272
|
+
}, s, (t) => o.succeed(q(e.output, t))).pipe(o.map(({ value: e }) => e));
|
|
273
|
+
}, q = (e, t) => {
|
|
274
|
+
if (typeof t != "object" || !t || !("v" in t) || !("d" in t)) return s.none();
|
|
275
|
+
let n = t;
|
|
276
|
+
return !Array.isArray(n.d) || !n.d.every((e) => typeof e == "string") ? s.none() : s.map(U(e, n.v), (e) => ({
|
|
277
|
+
value: e,
|
|
278
|
+
dependencies: n.d
|
|
279
|
+
}));
|
|
280
|
+
}, J = (e) => {
|
|
281
|
+
let t = p(e.ttl);
|
|
282
|
+
if (t !== null) return {
|
|
283
|
+
ttlMs: t,
|
|
284
|
+
swrMs: e.swr === void 0 ? void 0 : p(e.swr) ?? void 0,
|
|
285
|
+
scope: e.scope,
|
|
286
|
+
volatile: e.volatile === !0
|
|
287
|
+
};
|
|
288
|
+
};
|
|
289
|
+
export { K as cachedComputedCall, G as computedAuthorityRefusal, V as computedCacheKey, x as computedQueryCacheCaptureInstalled, I as computedSubjectIdentity, D as currentQueryDependencies, H as decideComputedStore, U as decodeComputedStored, W as describeComputedRefusal, E as enterQueryDependencies, b as installComputedQueryCacheCapture, j as newComputedCaptureScope, C as noteCacheRead, k as noteCacheVolatile, O as noteDependency, F as observedContext, P as observedSubject, J as queryCachePolicy, S as resetComputedQueryCacheCaptureForTests, A as runWithComputedCapture };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { beginOAuthConnect as e, forgetCredential as t, listConnectionStates as n, storeCredential as r } from "./connectionVault.js";
|
|
2
2
|
import { ConnectionHandshakeFailed as i, ConnectionKindMismatch as a, ConnectionNotDeclared as o, ConnectionSubjectRequired as s } from "@voltro/protocol";
|
|
3
|
-
|
|
3
|
+
// src/connectionBuiltins.ts
|
|
4
4
|
var c = (e, t) => {
|
|
5
5
|
let n = e.request?.subject?.id ?? null;
|
|
6
6
|
if (n === null || n === "") throw new s({ connectionId: t });
|
|
@@ -77,5 +77,4 @@ var c = (e, t) => {
|
|
|
77
77
|
let i = c(r, n.connectionId);
|
|
78
78
|
return { ok: await t(r.store, n.connectionId, i) };
|
|
79
79
|
};
|
|
80
|
-
//#endregion
|
|
81
80
|
export { p as makeDisconnectConnectionExecutor, u as makeListConnectionsExecutor, d as makeStartConnectionExecutor, f as makeSubmitTokenExecutor };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/connectionCredentials.ts
|
|
2
2
|
var e = 36e5, t = Symbol.for("@voltro/runtime/connectionCredentials"), n = globalThis, r = n[t] ??= {
|
|
3
3
|
overrides: /* @__PURE__ */ new Map(),
|
|
4
4
|
credentialExpiry: /* @__PURE__ */ new Map(),
|
|
@@ -62,5 +62,4 @@ var m = (e, t) => {
|
|
|
62
62
|
}, g = (e) => o.get(e)?.size ?? 0, _ = () => {
|
|
63
63
|
i.clear(), a.clear(), o.clear();
|
|
64
64
|
};
|
|
65
|
-
//#endregion
|
|
66
65
|
export { g as _connectionStreamCount, _ as _resetConnectionCredentialsForTest, p as applyConnectionCredential, l as bindConnectionCredential, u as getConnectionCredential, c as getCredentialExpiry, h as interruptConnectionStreams, f as mergeCookieHeader, s as recordCredentialExpiry, m as registerConnectionStream, d as unbindConnection };
|
package/dist/connectionState.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/connectionState.ts
|
|
2
2
|
var e = Symbol.for("@voltro/runtime/connectionState"), t = globalThis, n = t[e] ??= /* @__PURE__ */ new WeakMap(), r = (e, t) => {
|
|
3
3
|
let r = n.get(e);
|
|
4
4
|
if (r === void 0 && !e.signal.aborted) {
|
|
@@ -30,5 +30,4 @@ var e = Symbol.for("@voltro/runtime/connectionState"), t = globalThis, n = t[e]
|
|
|
30
30
|
})
|
|
31
31
|
};
|
|
32
32
|
};
|
|
33
|
-
//#endregion
|
|
34
33
|
export { r as makeConnectionState };
|
package/dist/connectionVault.js
CHANGED
|
@@ -2,7 +2,7 @@ import { decryptField as e, encryptField as t, getFieldCipher as n } from "./fie
|
|
|
2
2
|
import { and as r, eq as i, fieldBinding as a, generateId as o, id as s, json as c, lte as l, table as u, text as d, timestamp as f } from "@voltro/database";
|
|
3
3
|
import { ConnectionHandshakeFailed as p } from "@voltro/protocol";
|
|
4
4
|
import { createLogger as m } from "@voltro/logger";
|
|
5
|
-
|
|
5
|
+
// src/connectionVault.ts
|
|
6
6
|
var h = m({ scope: "voltro:connections" }), g = "_voltro_connections", _ = {
|
|
7
7
|
kind: "typeid",
|
|
8
8
|
prefix: "conn"
|
|
@@ -406,5 +406,4 @@ var h = m({ scope: "voltro:connections" }), g = "_voltro_connections", _ = {
|
|
|
406
406
|
for (let t of n) await e.delete("_voltro_connection_grants", t.id) && r++;
|
|
407
407
|
return r;
|
|
408
408
|
};
|
|
409
|
-
//#endregion
|
|
410
409
|
export { g as CONNECTIONS_TABLE, y as CONNECTION_GRANTS_TABLE, z as ConnectionNotConnected, L as DEFAULT_REFRESH_SKEW_MS, X as GRANT_TTL_MS, R as REFRESH_LEASE_MS, b as _voltroConnectionGrantsTable, v as _voltroConnectionsTable, C as assertConnectionCipherConfigured, ae as beginOAuthConnect, U as clearConnectionRefreshFlights, oe as completeOAuthConnect, Z as connectionCallbackPath, S as connectionLabel, ne as defineConnection, F as exchangeAuthorizationCode, j as forgetCredential, M as listConnectionStates, w as makeConnectionRegistry, x as oauthCredentialValue, O as projectConnectionState, I as refreshAccessToken, K as resolveConnection, $ as resolveRedirectUri, Q as sanitizeRedirectTo, A as storeCredential, se as sweepExpiredGrants };
|
|
@@ -1,42 +1,44 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { noteCacheVolatile as e } from "./computedQueryCache.js";
|
|
2
|
+
import { ConnectionNotConnected as t, listConnectionStates as n, resolveConnection as r } from "./connectionVault.js";
|
|
3
|
+
// src/connectionsFacade.ts
|
|
4
|
+
var i, a = (e) => {
|
|
5
|
+
i = e;
|
|
6
|
+
}, o = () => i, s = (e, t) => {
|
|
7
|
+
let n = i;
|
|
7
8
|
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);
|
|
8
|
-
},
|
|
9
|
-
let a =
|
|
10
|
-
if (a === void 0) throw Error(`connection "${i}" is not declared. Declared: ${
|
|
11
|
-
let o =
|
|
12
|
-
if (o === null || o === "") throw new
|
|
13
|
-
return
|
|
14
|
-
store:
|
|
9
|
+
}, c = (e) => async (n, i) => {
|
|
10
|
+
let a = e.registry.get(i);
|
|
11
|
+
if (a === void 0) throw Error(`connection "${i}" is not declared. Declared: ${e.registry.list().map((e) => e.id).join(", ") || "(none)"}.`);
|
|
12
|
+
let o = n.id ?? null;
|
|
13
|
+
if (o === null || o === "") throw new t(i, "<anonymous>");
|
|
14
|
+
return r({
|
|
15
|
+
store: e.store,
|
|
15
16
|
definition: a,
|
|
16
17
|
subjectId: o
|
|
17
18
|
});
|
|
18
|
-
},
|
|
19
|
-
let
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
if (
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
19
|
+
}, l = (i) => {
|
|
20
|
+
let a = i.subject.id ?? null, o = async (n) => {
|
|
21
|
+
e("ctx.connections");
|
|
22
|
+
let o = i.registry.get(n);
|
|
23
|
+
if (o === void 0) throw Error(`ctx.connections.get("${n}"): no such connection is declared. Declared: ${i.registry.list().map((e) => e.id).join(", ") || "(none)"}.`);
|
|
24
|
+
if (a === null || a === "") throw new t(n, "<anonymous>");
|
|
25
|
+
return r({
|
|
26
|
+
store: i.store,
|
|
27
|
+
definition: o,
|
|
28
|
+
subjectId: a
|
|
27
29
|
});
|
|
28
30
|
};
|
|
29
31
|
return {
|
|
30
|
-
get:
|
|
31
|
-
tryGet: async (
|
|
32
|
+
get: o,
|
|
33
|
+
tryGet: async (e) => {
|
|
32
34
|
try {
|
|
33
|
-
return await
|
|
34
|
-
} catch (
|
|
35
|
-
if (
|
|
36
|
-
throw
|
|
35
|
+
return await o(e);
|
|
36
|
+
} catch (e) {
|
|
37
|
+
if (e instanceof t) return null;
|
|
38
|
+
throw e;
|
|
37
39
|
}
|
|
38
40
|
},
|
|
39
|
-
list: async () =>
|
|
41
|
+
list: async () => a === null || a === "" ? i.registry.list().map((e) => ({
|
|
40
42
|
connectionId: e.id,
|
|
41
43
|
kind: e.kind,
|
|
42
44
|
label: e.label ?? e.id,
|
|
@@ -47,8 +49,7 @@ var r, i = (e) => {
|
|
|
47
49
|
expiresAt: null,
|
|
48
50
|
lastError: null,
|
|
49
51
|
connectedAt: null
|
|
50
|
-
})) :
|
|
52
|
+
})) : n(i.store, i.registry, a)
|
|
51
53
|
};
|
|
52
54
|
};
|
|
53
|
-
|
|
54
|
-
export { a as getConnectionResolver, s as makeConnectionResolver, c as makeConnectionsFacade, o as resolveConnectionForSubject, i as setConnectionResolver };
|
|
55
|
+
export { o as getConnectionResolver, c as makeConnectionResolver, l as makeConnectionsFacade, s as resolveConnectionForSubject, a as setConnectionResolver };
|
|
@@ -1,19 +1,22 @@
|
|
|
1
|
-
import { cronForInterval as e, externalizationRefusal as t, registerExternalizedTask as n
|
|
2
|
-
|
|
3
|
-
var
|
|
1
|
+
import { cronForInterval as e, externalizationRefusal as t, registerExternalizedTask as n } from "./externalizedTasks.js";
|
|
2
|
+
// src/coordinatedSchedule.ts
|
|
3
|
+
var r = (e) => {
|
|
4
4
|
if (e === void 0) return null;
|
|
5
5
|
let t = e.nextDueInMs;
|
|
6
6
|
return {
|
|
7
7
|
idle: e.idle === !0,
|
|
8
8
|
...t === null ? { nextDueInMs: null } : typeof t == "number" && Number.isFinite(t) ? { nextDueInMs: t } : {}
|
|
9
9
|
};
|
|
10
|
-
},
|
|
10
|
+
}, i = /* @__PURE__ */ new WeakMap(), a = (e) => i.get(e)?.() ?? null, o = 3e4, s = (e = process.env) => {
|
|
11
11
|
let t = e.VOLTRO_POLL_CEILING_MS;
|
|
12
|
-
if (t === void 0) return
|
|
12
|
+
if (t === void 0) return o;
|
|
13
13
|
let n = Number(t);
|
|
14
|
-
return Number.isFinite(n) && n > 0 ? n :
|
|
15
|
-
},
|
|
16
|
-
let
|
|
14
|
+
return Number.isFinite(n) && n > 0 ? n : o;
|
|
15
|
+
}, c = (a, o, c, u) => {
|
|
16
|
+
let d = Math.max(o, u.maxIdleIntervalMs ?? s()), f = !1, p, m = /* @__PURE__ */ new Set(), h = (e) => {
|
|
17
|
+
let t = Promise.resolve().then(e);
|
|
18
|
+
return m.add(t), t.then(() => m.delete(t), () => m.delete(t)), t;
|
|
19
|
+
}, g, _ = !1, v = o, y = !1, b = !1, x = 0, S = null, C = {
|
|
17
20
|
ticks: 0,
|
|
18
21
|
claimWins: 0,
|
|
19
22
|
claimLosses: 0,
|
|
@@ -25,115 +28,117 @@ var i = (e) => {
|
|
|
25
28
|
lastWakeAt: null,
|
|
26
29
|
lastDecision: "starting",
|
|
27
30
|
lastOutcome: null
|
|
28
|
-
},
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
},
|
|
32
|
-
},
|
|
33
|
-
if (
|
|
34
|
-
if (
|
|
35
|
-
|
|
31
|
+
}, w = (e) => {
|
|
32
|
+
f || (g !== void 0 && clearTimeout(g), g = void 0, S = null, e === "disarm" ? _ = !0 : (_ = !1, v = Math.max(0, Math.min(e, d)), S = Date.now() + v, g = setTimeout(() => {
|
|
33
|
+
E();
|
|
34
|
+
}, v), typeof g.unref == "function" && g.unref()));
|
|
35
|
+
}, T = async () => {
|
|
36
|
+
if (f) return;
|
|
37
|
+
if (y) {
|
|
38
|
+
b = !0;
|
|
36
39
|
return;
|
|
37
40
|
}
|
|
38
|
-
|
|
39
|
-
let e = new Date(Math.floor(Date.now() /
|
|
41
|
+
C.ticks++, C.lastTickAt = Date.now(), C.lastOutcome = null, S = null, y = !0;
|
|
42
|
+
let e = new Date(Math.floor(Date.now() / o) * o);
|
|
40
43
|
try {
|
|
41
44
|
let t = !1;
|
|
42
45
|
try {
|
|
43
|
-
t = await
|
|
46
|
+
t = await u.coordinator.tryClaim(a, e, o);
|
|
44
47
|
} catch (e) {
|
|
45
|
-
|
|
46
|
-
task:
|
|
48
|
+
C.claimFailures++, C.lastDecision = "claim-failed", u.log?.warn("coordinated schedule: claim check failed — skipping this tick", {
|
|
49
|
+
task: a,
|
|
47
50
|
reason: e?.message ?? String(e)
|
|
48
|
-
}),
|
|
51
|
+
}), w(o);
|
|
49
52
|
return;
|
|
50
53
|
}
|
|
51
54
|
if (!t) {
|
|
52
|
-
|
|
55
|
+
C.claimLosses++, C.lastDecision = "claim-lost", w(o);
|
|
53
56
|
return;
|
|
54
57
|
}
|
|
58
|
+
if (f) return;
|
|
55
59
|
let n;
|
|
56
|
-
|
|
60
|
+
C.claimWins++;
|
|
57
61
|
try {
|
|
58
|
-
n = await
|
|
62
|
+
n = await c();
|
|
59
63
|
} catch (e) {
|
|
60
|
-
|
|
61
|
-
task:
|
|
64
|
+
C.taskFailures++, C.lastDecision = "task-failed", u.log?.warn("coordinated schedule: task threw", {
|
|
65
|
+
task: a,
|
|
62
66
|
reason: e?.message ?? String(e)
|
|
63
|
-
}),
|
|
67
|
+
}), w(o);
|
|
64
68
|
return;
|
|
65
69
|
}
|
|
66
|
-
|
|
67
|
-
let
|
|
68
|
-
|
|
70
|
+
C.lastOutcome = r(n);
|
|
71
|
+
let i = l(C.lastOutcome ?? void 0, o, v, d, u.disarmWhenIdle ?? !1);
|
|
72
|
+
C.lastDecision = i === "disarm" ? "idle-disarmed" : n?.idle ? "idle-backoff" : "active", w(i);
|
|
69
73
|
} finally {
|
|
70
|
-
|
|
74
|
+
y = !1, b && !f && (b = !1, w(0));
|
|
71
75
|
}
|
|
72
|
-
},
|
|
73
|
-
|
|
74
|
-
|
|
76
|
+
}, E = () => f ? Promise.resolve() : h(T), D = async () => {
|
|
77
|
+
if (f) throw Error("Coordinated schedule is stopped");
|
|
78
|
+
C.ticks++, C.lastTickAt = Date.now(), C.lastOutcome = null;
|
|
79
|
+
let e = new Date(Math.floor(Date.now() / o) * o), t;
|
|
75
80
|
try {
|
|
76
|
-
t = await (
|
|
81
|
+
t = await (u.externalClaim ?? u.coordinator).tryClaim(a, e, o);
|
|
77
82
|
} catch (e) {
|
|
78
|
-
throw
|
|
83
|
+
throw C.claimFailures++, C.lastDecision = "claim-failed", e;
|
|
79
84
|
}
|
|
80
|
-
if (!t) return
|
|
81
|
-
|
|
85
|
+
if (!t) return C.claimLosses++, C.lastDecision = "claim-lost", "deduplicated";
|
|
86
|
+
if (f) throw Error("Coordinated schedule is stopped");
|
|
87
|
+
C.claimWins++;
|
|
82
88
|
try {
|
|
83
|
-
let e = await
|
|
84
|
-
|
|
89
|
+
let e = await c();
|
|
90
|
+
C.lastOutcome = r(e), C.lastDecision = "active";
|
|
85
91
|
} catch (e) {
|
|
86
|
-
throw
|
|
92
|
+
throw C.taskFailures++, C.lastDecision = "task-failed", e;
|
|
87
93
|
}
|
|
88
94
|
return "ran";
|
|
89
|
-
},
|
|
90
|
-
|
|
91
|
-
task:
|
|
92
|
-
intervalMs:
|
|
93
|
-
})
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
95
|
+
}, O = () => f ? Promise.reject(/* @__PURE__ */ Error("Coordinated schedule is stopped")) : h(D), k = u.externalize === !0 ? t(a, o) : void 0, A = u.externalize === !0 && k === void 0;
|
|
96
|
+
k !== void 0 && u.log?.warn(`coordinated schedule: REFUSING to externalise this task — ${k}`, {
|
|
97
|
+
task: a,
|
|
98
|
+
intervalMs: o
|
|
99
|
+
});
|
|
100
|
+
let j;
|
|
101
|
+
A ? (j = (u.externalTasks?.register ?? n)({
|
|
102
|
+
name: a,
|
|
103
|
+
intervalMs: o,
|
|
104
|
+
cron: e(o),
|
|
105
|
+
run: O
|
|
106
|
+
}), u.log?.info("coordinated schedule: externalised — no in-process timer", {
|
|
107
|
+
task: a,
|
|
108
|
+
intervalMs: o
|
|
109
|
+
})) : w(o);
|
|
110
|
+
let M = {
|
|
111
|
+
name: a,
|
|
112
|
+
currentIntervalMs: () => v,
|
|
113
|
+
isArmed: () => !f && !_ && !A,
|
|
106
114
|
wake: () => {
|
|
107
|
-
if (
|
|
108
|
-
|
|
115
|
+
if (f) return;
|
|
116
|
+
C.wakes++, C.lastWakeAt = Date.now();
|
|
109
117
|
let e = Date.now();
|
|
110
|
-
!
|
|
118
|
+
!_ && e - x < o ? C.coalescedWakes++ : (C.lastDecision = "wake", x = e, y ? b = !0 : w(0));
|
|
111
119
|
},
|
|
112
|
-
stop: () => {
|
|
113
|
-
p || (p = !0, m !== void 0 && clearTimeout(m), m = void 0, b = null, E && r(o));
|
|
114
|
-
}
|
|
120
|
+
stop: () => (p === void 0 && (f = !0, g !== void 0 && clearTimeout(g), g = void 0, S = null, j?.(), p = Promise.allSettled([...m]).then(() => {})), p)
|
|
115
121
|
};
|
|
116
|
-
return
|
|
117
|
-
...
|
|
118
|
-
lastOutcome:
|
|
119
|
-
task:
|
|
120
|
-
state:
|
|
121
|
-
baseIntervalMs:
|
|
122
|
-
currentIntervalMs:
|
|
123
|
-
maxIdleIntervalMs:
|
|
124
|
-
nextTickAt:
|
|
125
|
-
disarmWhenIdle:
|
|
126
|
-
})),
|
|
127
|
-
},
|
|
122
|
+
return i.set(M, () => ({
|
|
123
|
+
...C,
|
|
124
|
+
lastOutcome: C.lastOutcome === null ? null : { ...C.lastOutcome },
|
|
125
|
+
task: a,
|
|
126
|
+
state: f ? "stopped" : A ? "externalized" : y ? "running" : _ ? "disarmed" : "armed",
|
|
127
|
+
baseIntervalMs: o,
|
|
128
|
+
currentIntervalMs: v,
|
|
129
|
+
maxIdleIntervalMs: d,
|
|
130
|
+
nextTickAt: S,
|
|
131
|
+
disarmWhenIdle: u.disarmWhenIdle ?? !1
|
|
132
|
+
})), M;
|
|
133
|
+
}, l = (e, t, n, r, i = !1) => {
|
|
128
134
|
if (e === void 0 || !e.idle) return t;
|
|
129
135
|
let a = typeof e.nextDueInMs == "number" && Number.isFinite(e.nextDueInMs) ? e.nextDueInMs : void 0;
|
|
130
136
|
if (a === void 0 && e.nextDueInMs === null && i) return "disarm";
|
|
131
137
|
let o = Math.min(Math.max(n, t) * 2, r);
|
|
132
138
|
return a === void 0 ? o : Math.max(t, i ? a : Math.min(o, a));
|
|
133
|
-
},
|
|
139
|
+
}, u = (e) => (t, n, r, i) => c(t, n, r, {
|
|
134
140
|
...e,
|
|
135
141
|
...e.externalizeTask === void 0 ? {} : { externalize: e.externalizeTask(t) },
|
|
136
142
|
...i?.disarmWhenIdle === void 0 ? {} : { disarmWhenIdle: i.disarmWhenIdle }
|
|
137
143
|
});
|
|
138
|
-
|
|
139
|
-
export { s as DEFAULT_MAX_IDLE_INTERVAL_MS, o as inspectCoordinatedSchedule, d as makeCoordinatedScheduler, u as nextDelay, c as readPollCeilingMs, l as scheduleCoordinated };
|
|
144
|
+
export { o as DEFAULT_MAX_IDLE_INTERVAL_MS, a as inspectCoordinatedSchedule, u as makeCoordinatedScheduler, l as nextDelay, s as readPollCeilingMs, c as scheduleCoordinated };
|