@voltro/runtime 0.85.0 → 0.87.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 +5987 -0
- package/README.md +43 -0
- package/THIRD-PARTY-NOTICES.md +864 -253
- package/dist/aggregate.js +42 -0
- package/dist/aggregateExtrema.js +80 -0
- package/dist/aggregateIvm.js +115 -0
- package/dist/analyticsMirror.js +228 -0
- package/dist/analyticsSink.js +32 -0
- package/dist/apiKeyUsage.js +33 -0
- package/dist/apiKeys.js +227 -0
- package/dist/apiKeysWiring.js +114 -0
- package/dist/apiRoleBucketSampler.js +64 -0
- package/dist/apiRoleWorkloadHistory.js +56 -0
- package/dist/apiRoleWorkloadMetrics.js +78 -0
- package/dist/apiRoleWorkloadStorage.js +95 -0
- package/dist/approvalBuiltins.js +10 -0
- package/dist/approvals.js +262 -0
- package/dist/authMiddlewareLayer.js +48 -0
- package/dist/bindEvent.js +92 -0
- package/dist/bootListener.js +143 -0
- package/dist/bootRefusal.js +7 -0
- package/dist/bootStoreCodec.js +71 -0
- package/dist/businessRules.js +67 -0
- package/dist/changeClaimsTable.js +12 -0
- package/dist/circuitBreaker.js +1 -0
- package/dist/columnOnUpdate.js +23 -0
- package/dist/composeAnalytics.js +129 -0
- package/dist/computedQuery.js +4 -0
- package/dist/computedQueryCache.js +231 -0
- package/dist/connectionBuiltins.js +81 -0
- package/dist/connectionCredentials.js +66 -0
- package/dist/connectionState.js +34 -0
- package/dist/connectionVault.js +410 -0
- package/dist/connectionsFacade.js +56 -0
- package/dist/coordinatedSchedule.js +145 -0
- package/dist/crdtHistory.js +138 -0
- package/dist/crdtMerge.js +179 -0
- package/dist/crdtVersionsTable.js +25 -0
- package/dist/credentialBound.js +12 -0
- package/dist/crud.js +72 -0
- package/dist/dataStore.js +712 -0
- package/dist/dataloader.js +61 -0
- package/dist/declaredTablesGuard.js +49 -0
- package/dist/defineExecutor.js +4 -0
- package/dist/dependencyGraph.js +32 -0
- package/dist/devices.js +228 -0
- package/dist/devicesWiring.js +168 -0
- package/dist/dialectReplicationAdapter.js +29 -0
- package/dist/dispatcher.js +522 -0
- package/dist/effectStore.js +71 -0
- package/dist/engineClients.js +24 -0
- package/dist/eventBus.js +260 -0
- package/dist/eventPublish.js +49 -0
- package/dist/events.js +193 -0
- package/dist/expectation.js +52 -0
- package/dist/expectationEvaluator.js +308 -0
- package/dist/experiment.js +96 -0
- package/dist/experimentEvaluator.js +245 -0
- package/dist/externalizedTasks.js +38 -0
- package/dist/fieldCipher.js +130 -0
- package/dist/fieldKeyRegistry.js +295 -0
- package/dist/fieldKeyRekey.js +286 -0
- package/dist/fieldKeyScan.js +136 -0
- package/dist/fieldKeyring.js +77 -0
- package/dist/fingerprint.js +21 -0
- package/dist/finops.js +42 -0
- package/dist/finopsAccountant.js +216 -0
- package/dist/handlerBody.js +8 -0
- package/dist/healthProbes.js +55 -0
- package/dist/hot.d.ts +56 -0
- package/dist/hot.js +3 -0
- package/dist/hotDataStore.js +148 -0
- package/dist/hotDataStoreSnapshot.js +98 -0
- package/dist/hotDataStoreTables.js +18 -0
- package/dist/http-range.d.ts +53 -0
- package/dist/http-range.js +52 -0
- package/dist/httpClientSsrf.js +24 -0
- package/dist/httpClientTracing.js +14 -0
- package/dist/httpCompression.js +76 -0
- package/dist/httpInputStream.js +82 -0
- package/dist/httpKeepAlive.js +12 -0
- package/dist/httpRouteMounts.js +48 -0
- package/dist/idempotencyStore.js +110 -0
- package/dist/idleDetector.js +21 -0
- package/dist/index.d.ts +1249 -517
- package/dist/index.js +155 -15292
- package/dist/insertRequiredColumns.js +19 -0
- package/dist/inspectWorkflow.js +1 -0
- package/dist/instanceMembership.js +98 -0
- package/dist/ivm.js +125 -0
- package/dist/kvDataStore.js +86 -0
- package/dist/kvFacade.js +38 -0
- package/dist/matcher.js +304 -0
- package/dist/memoryColumnDefaults.js +11 -0
- package/dist/memoryQueryJoins.js +114 -0
- package/dist/memorySetOperations.js +43 -0
- package/dist/metrics.js +175 -0
- package/dist/observability.js +123 -0
- package/dist/observedGraph.js +52 -0
- package/dist/originGuard.js +116 -0
- package/dist/outbox.js +352 -0
- package/dist/pluginRefRules.js +65 -0
- package/dist/policyGuardResolver.js +55 -0
- package/dist/preview.js +62 -0
- package/dist/projectedRows.js +12 -0
- package/dist/provenance.js +63 -0
- package/dist/rangeIndex.js +89 -0
- package/dist/rawReadScope.js +17 -0
- package/dist/reaction.js +85 -0
- package/dist/reactiveConfig.js +11 -0
- package/dist/readClassification.js +57 -0
- package/dist/readRecorder.js +67 -0
- package/dist/readScopePredicate.js +12 -0
- package/dist/rebac.js +104 -0
- package/dist/rebacInterceptor.js +81 -0
- package/dist/registry.js +29 -0
- package/dist/relevantFields.js +65 -0
- package/dist/replicaHealth.js +42 -0
- package/dist/replicaLocality.js +44 -0
- package/dist/replicaObservations.js +121 -0
- package/dist/replicaSelection.js +32 -0
- package/dist/replicatedDataStore.js +257 -0
- package/dist/requestLoader.js +7 -0
- package/dist/resumeCensus.js +28 -0
- package/dist/revalidation.js +22 -0
- package/dist/rowFilter.js +82 -0
- package/dist/rowStateBytes.js +45 -0
- package/dist/rpcBodyCap.js +63 -0
- package/dist/rpcConnections.js +83 -0
- package/dist/rpcDefectDiagnostics.js +15 -0
- package/dist/rpcServer.js +1065 -0
- package/dist/rpcWorkloadAdmission.js +50 -0
- package/dist/runAsSystem.js +23 -0
- package/dist/rywPositionStore.js +119 -0
- package/dist/schedule.js +23 -0
- package/dist/scheduleBackfillRequests.js +151 -0
- package/dist/scheduleClaimsTable.js +11 -0
- package/dist/scheduleRunsTable.js +37 -0
- package/dist/scheduler.js +840 -0
- package/dist/schemaRegistry.js +65 -0
- package/dist/secretsResolver.js +35 -0
- package/dist/securityHeaders.js +33 -0
- package/dist/servePipeline.js +374 -0
- package/dist/serverOnlyAudit.js +66 -0
- package/dist/serverTracer.js +15 -0
- package/dist/serviceCredentials.js +40 -0
- package/dist/setReadScopes.js +28 -0
- package/dist/singleNodeOrchestrator.js +91 -0
- package/dist/snapshotValueCodec.js +46 -0
- package/dist/sourceResolution.js +52 -0
- package/dist/storeMiddleware.js +882 -0
- package/dist/storeQuery.js +204 -0
- package/dist/storeRead.js +10 -0
- package/dist/subscriber.js +8 -0
- package/dist/subscriptionOutbox.js +139 -0
- package/dist/subscriptionRegistry.js +82 -0
- package/dist/subscriptionResume.js +132 -0
- package/dist/subscriptionSocketMetrics.js +65 -0
- package/dist/systemSubject.js +5 -0
- package/dist/tenantScope.js +11 -0
- package/dist/tenantSelection.js +27 -0
- package/dist/timeline.js +105 -0
- package/dist/traceContext.js +5 -0
- package/dist/traceSink.js +63 -0
- package/dist/traceSpansTable.js +29 -0
- package/dist/traceparent.js +23 -0
- package/dist/transactionSubject.js +12 -0
- package/dist/trustedProxy.js +155 -0
- package/dist/undo.js +129 -0
- package/dist/undoBuiltins.js +69 -0
- package/dist/undoCapture.js +74 -0
- package/dist/undoLogTable.js +16 -0
- package/dist/upsertBinding.js +20 -0
- package/dist/wakeOrchestrator.js +34 -0
- package/dist/wakeRegistry.js +71 -0
- package/dist/wakeRouter.js +63 -0
- package/dist/wakeSupervisor.js +62 -0
- package/dist/wakeupsTable.js +12 -0
- package/dist/webSocketGatewayRuntime.js +154 -0
- package/dist/webhookVerification.js +18 -0
- package/dist/wireColumnStrip.js +84 -0
- package/dist/workflowReadBuiltins.js +87 -0
- package/dist/workflowRuntime.js +708 -0
- package/package.json +19 -7
package/dist/outbox.js
ADDED
|
@@ -0,0 +1,352 @@
|
|
|
1
|
+
import { Effect as e } from "effect";
|
|
2
|
+
import { and as t, eq as n, generateId as r, id as i, inSet as a, integer as o, json as s, lt as c, table as l, text as u, timestamp as d } from "@voltro/database";
|
|
3
|
+
import { validateOutboxHandlerDefinition as f } from "@voltro/protocol";
|
|
4
|
+
import { createLogger as p } from "@voltro/logger";
|
|
5
|
+
//#region src/outbox.ts
|
|
6
|
+
var m = p({ scope: "voltro:outbox" }), h = "_voltro_outbox", g = {
|
|
7
|
+
kind: "typeid",
|
|
8
|
+
prefix: "obx"
|
|
9
|
+
}, _ = l(h, {
|
|
10
|
+
id: i({ prefix: "obx" }),
|
|
11
|
+
effect: u(),
|
|
12
|
+
payload: s(),
|
|
13
|
+
status: u(),
|
|
14
|
+
attempts: o(),
|
|
15
|
+
maxAttempts: o(),
|
|
16
|
+
nextAttemptAt: d(),
|
|
17
|
+
idempotencyKey: u().nullable(),
|
|
18
|
+
lastError: u().nullable(),
|
|
19
|
+
subjectId: u().nullable(),
|
|
20
|
+
tenantId: u().nullable(),
|
|
21
|
+
traceId: u().nullable(),
|
|
22
|
+
createdAt: d(),
|
|
23
|
+
deliveredAt: d().nullable(),
|
|
24
|
+
resendRequestedBy: u().nullable(),
|
|
25
|
+
resendRequestedAt: d().nullable(),
|
|
26
|
+
resendReason: u().nullable(),
|
|
27
|
+
resendCount: o(),
|
|
28
|
+
claimedBy: u().nullable(),
|
|
29
|
+
claimedAt: d().nullable()
|
|
30
|
+
}), v = "_voltro_outbox_attempts", y = {
|
|
31
|
+
kind: "typeid",
|
|
32
|
+
prefix: "obxa"
|
|
33
|
+
}, b = l(v, {
|
|
34
|
+
id: i({ prefix: "obxa" }),
|
|
35
|
+
outboxId: u(),
|
|
36
|
+
effect: u(),
|
|
37
|
+
attempt: o(),
|
|
38
|
+
trigger: u().oneOf(["automatic", "manual"]),
|
|
39
|
+
triggeredBy: u().nullable(),
|
|
40
|
+
reason: u().nullable(),
|
|
41
|
+
outcome: u().oneOf([
|
|
42
|
+
"delivered",
|
|
43
|
+
"failed",
|
|
44
|
+
"dead"
|
|
45
|
+
]),
|
|
46
|
+
startedAt: d(),
|
|
47
|
+
finishedAt: d(),
|
|
48
|
+
durationMs: o(),
|
|
49
|
+
error: u().nullable(),
|
|
50
|
+
response: s().nullable(),
|
|
51
|
+
subjectId: u().nullable(),
|
|
52
|
+
tenantId: u().nullable(),
|
|
53
|
+
traceId: u().nullable()
|
|
54
|
+
}).index(["outboxId", "attempt"]).index(["startedAt"]).index(["outcome"]), x = (e) => (f(e, e.effect), e), S = 8, C = (e) => ({
|
|
55
|
+
enqueue: async (i, a, o) => {
|
|
56
|
+
let s = (e.now ?? (() => /* @__PURE__ */ new Date()))(), c = o?.idempotencyKey;
|
|
57
|
+
if (c !== void 0) {
|
|
58
|
+
let r = (await e.store.query({
|
|
59
|
+
table: h,
|
|
60
|
+
predicate: t(n("idempotencyKey", c), n("status", "pending")),
|
|
61
|
+
order: [],
|
|
62
|
+
take: 1,
|
|
63
|
+
skip: void 0,
|
|
64
|
+
projection: void 0
|
|
65
|
+
}))[0];
|
|
66
|
+
if (r !== void 0) return r.id;
|
|
67
|
+
}
|
|
68
|
+
let l = {
|
|
69
|
+
id: r(g, h),
|
|
70
|
+
effect: i,
|
|
71
|
+
payload: a,
|
|
72
|
+
status: "pending",
|
|
73
|
+
attempts: 0,
|
|
74
|
+
maxAttempts: o?.maxAttempts ?? e.maxAttemptsOf?.(i) ?? S,
|
|
75
|
+
nextAttemptAt: new Date(s.getTime() + (o?.delayMs ?? 0)),
|
|
76
|
+
idempotencyKey: c ?? null,
|
|
77
|
+
lastError: null,
|
|
78
|
+
subjectId: e.subject.id ?? null,
|
|
79
|
+
tenantId: e.subject.tenantId ?? null,
|
|
80
|
+
traceId: e.traceId,
|
|
81
|
+
createdAt: s,
|
|
82
|
+
deliveredAt: null,
|
|
83
|
+
resendRequestedBy: null,
|
|
84
|
+
resendRequestedAt: null,
|
|
85
|
+
resendReason: null,
|
|
86
|
+
resendCount: 0
|
|
87
|
+
}, u = await e.store.insert(h, l);
|
|
88
|
+
if (e.afterCommit !== void 0 && e.nudge !== void 0) {
|
|
89
|
+
let t = e.nudge;
|
|
90
|
+
e.afterCommit(async () => {
|
|
91
|
+
t();
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
return u.id ?? l.id;
|
|
95
|
+
},
|
|
96
|
+
resend: async (r, i) => {
|
|
97
|
+
let a = (e.now ?? (() => /* @__PURE__ */ new Date()))(), o = (await e.store.query({
|
|
98
|
+
table: h,
|
|
99
|
+
predicate: n("id", r),
|
|
100
|
+
order: [],
|
|
101
|
+
take: 1,
|
|
102
|
+
skip: void 0,
|
|
103
|
+
projection: void 0
|
|
104
|
+
}))[0];
|
|
105
|
+
if (o === void 0) throw Error(`outbox.resend: no entry "${r}"`);
|
|
106
|
+
let s = o.status;
|
|
107
|
+
if (s === "delivering") throw Error(`outbox.resend("${r}"): an attempt is in flight — retry once it settles`);
|
|
108
|
+
let c = o.attempts ?? 0, l = Math.max(1, Math.floor(i?.attempts ?? 1));
|
|
109
|
+
if (await e.store.updateMany("_voltro_outbox", {
|
|
110
|
+
status: "pending",
|
|
111
|
+
nextAttemptAt: a,
|
|
112
|
+
maxAttempts: c + l,
|
|
113
|
+
resendRequestedBy: e.subject.id ?? null,
|
|
114
|
+
resendRequestedAt: a,
|
|
115
|
+
resendReason: i?.reason ?? null,
|
|
116
|
+
resendCount: (o.resendCount ?? 0) + 1
|
|
117
|
+
}, { where: t(n("id", r), n("status", s), n("attempts", c), n("resendCount", o.resendCount ?? 0)) }) !== 1) throw Error(`outbox.resend("${r}"): entry changed while requesting another attempt; refresh its status`);
|
|
118
|
+
if (e.afterCommit !== void 0 && e.nudge !== void 0) {
|
|
119
|
+
let t = e.nudge;
|
|
120
|
+
e.afterCommit(async () => {
|
|
121
|
+
t();
|
|
122
|
+
});
|
|
123
|
+
} else e.nudge?.();
|
|
124
|
+
}
|
|
125
|
+
}), w = (e) => Math.min(1e3 * 2 ** Math.max(0, e - 1), 3e5), T = 3e5, E = 50, D = (e, t) => e.length <= t ? e : `${e.slice(0, t)}… [clipped]`, O = (e) => {
|
|
126
|
+
if (e == null) return null;
|
|
127
|
+
let t = typeof e == "object" && !Array.isArray(e) ? e : { value: e }, n;
|
|
128
|
+
try {
|
|
129
|
+
n = JSON.stringify(t) ?? "";
|
|
130
|
+
} catch {
|
|
131
|
+
return { unserializable: !0 };
|
|
132
|
+
}
|
|
133
|
+
return n.length > 8192 ? {
|
|
134
|
+
truncated: !0,
|
|
135
|
+
preview: D(n, 8192)
|
|
136
|
+
} : t;
|
|
137
|
+
}, k = async (e, t, i) => {
|
|
138
|
+
let a = t.outboxRow, o = a.id, s = a.resendRequestedBy ?? null;
|
|
139
|
+
try {
|
|
140
|
+
await e.insert(v, {
|
|
141
|
+
id: r(y, v),
|
|
142
|
+
outboxId: o,
|
|
143
|
+
effect: a.effect,
|
|
144
|
+
attempt: t.attempt,
|
|
145
|
+
trigger: a.resendRequestedAt == null ? "automatic" : "manual",
|
|
146
|
+
triggeredBy: s,
|
|
147
|
+
reason: a.resendReason ?? null,
|
|
148
|
+
outcome: t.outcome,
|
|
149
|
+
startedAt: t.startedAt,
|
|
150
|
+
finishedAt: t.finishedAt,
|
|
151
|
+
durationMs: Math.max(0, t.finishedAt.getTime() - t.startedAt.getTime()),
|
|
152
|
+
error: t.error === null ? null : D(t.error, 4e3),
|
|
153
|
+
response: O(t.response),
|
|
154
|
+
subjectId: a.subjectId ?? null,
|
|
155
|
+
tenantId: a.tenantId ?? null,
|
|
156
|
+
traceId: a.traceId ?? null
|
|
157
|
+
});
|
|
158
|
+
} catch (e) {
|
|
159
|
+
m.warn("outbox: could not record delivery attempt (delivery itself is unaffected)", {
|
|
160
|
+
outboxId: o,
|
|
161
|
+
attempt: t.attempt
|
|
162
|
+
}, e);
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
if (!(t.attempt <= i)) try {
|
|
166
|
+
let t = await e.query({
|
|
167
|
+
table: v,
|
|
168
|
+
predicate: n("outboxId", o),
|
|
169
|
+
order: [{
|
|
170
|
+
column: "attempt",
|
|
171
|
+
direction: "asc"
|
|
172
|
+
}],
|
|
173
|
+
take: void 0,
|
|
174
|
+
skip: void 0,
|
|
175
|
+
projection: ["id"]
|
|
176
|
+
});
|
|
177
|
+
for (let n of t.slice(0, Math.max(0, t.length - i))) await e.delete(v, n.id);
|
|
178
|
+
} catch (e) {
|
|
179
|
+
m.warn("outbox: attempt-log trim failed; the log may exceed its cap", { outboxId: o }, e);
|
|
180
|
+
}
|
|
181
|
+
}, A = async (e, t) => {
|
|
182
|
+
try {
|
|
183
|
+
let [r] = await e.query({
|
|
184
|
+
table: h,
|
|
185
|
+
predicate: n("status", "delivering"),
|
|
186
|
+
order: [{
|
|
187
|
+
column: "claimedAt",
|
|
188
|
+
direction: "asc"
|
|
189
|
+
}],
|
|
190
|
+
take: 1,
|
|
191
|
+
skip: void 0,
|
|
192
|
+
projection: void 0
|
|
193
|
+
}), i = r?.claimedAt, a = i instanceof Date ? i.getTime() : typeof i == "string" || typeof i == "number" ? new Date(i).getTime() : NaN;
|
|
194
|
+
return Number.isFinite(a) ? a + t + 1 : void 0;
|
|
195
|
+
} catch (e) {
|
|
196
|
+
m.warn("outbox: could not read the oldest claim; a lost deliverer waits for the next pass", {}, e);
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
}, j = async (e, t) => {
|
|
200
|
+
try {
|
|
201
|
+
await e.store.update(h, t, {
|
|
202
|
+
status: "pending",
|
|
203
|
+
claimedBy: null,
|
|
204
|
+
claimedAt: null
|
|
205
|
+
});
|
|
206
|
+
} catch (e) {
|
|
207
|
+
m.warn("outbox: could not release a claim; the lease will reclaim it", { id: t }, e);
|
|
208
|
+
}
|
|
209
|
+
}, M = async (r) => {
|
|
210
|
+
let i = (r.now ?? (() => /* @__PURE__ */ new Date()))(), o = i.getTime(), s = r.claimLeaseMs ?? 3e5;
|
|
211
|
+
try {
|
|
212
|
+
let e = await r.store.updateMany(h, {
|
|
213
|
+
status: "pending",
|
|
214
|
+
claimedBy: null,
|
|
215
|
+
claimedAt: null
|
|
216
|
+
}, { where: t(n("status", "delivering"), c("claimedAt", new Date(o - s))) });
|
|
217
|
+
e > 0 && m.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", {
|
|
218
|
+
reclaimed: e,
|
|
219
|
+
leaseMs: s
|
|
220
|
+
});
|
|
221
|
+
} catch (e) {
|
|
222
|
+
m.warn("outbox: stuck-claim reclaim failed", {}, e);
|
|
223
|
+
}
|
|
224
|
+
let l = await r.store.query({
|
|
225
|
+
table: h,
|
|
226
|
+
predicate: t(n("status", "pending"), a("effect", [...r.handlers.keys()])),
|
|
227
|
+
order: [{
|
|
228
|
+
column: "nextAttemptAt",
|
|
229
|
+
direction: "asc"
|
|
230
|
+
}],
|
|
231
|
+
take: r.batchSize ?? 50,
|
|
232
|
+
skip: void 0,
|
|
233
|
+
projection: void 0
|
|
234
|
+
}), u = i.getTime(), d = (e) => {
|
|
235
|
+
let t = e.nextAttemptAt;
|
|
236
|
+
return t instanceof Date ? t.getTime() : new Date(t).getTime();
|
|
237
|
+
}, f = l.filter((e) => d(e) <= u), p;
|
|
238
|
+
for (let e of l) {
|
|
239
|
+
let t = d(e);
|
|
240
|
+
t <= u || Number.isNaN(t) || (p === void 0 || t < p) && (p = t);
|
|
241
|
+
}
|
|
242
|
+
let g = await A(r.store, s);
|
|
243
|
+
g !== void 0 && g > u && (p === void 0 || g < p) && (p = g);
|
|
244
|
+
let _ = [];
|
|
245
|
+
if (f.length > 0) {
|
|
246
|
+
let e = f.map((e) => e.id), i = new Date(o);
|
|
247
|
+
if (await r.store.updateMany("_voltro_outbox", {
|
|
248
|
+
status: "delivering",
|
|
249
|
+
claimedBy: r.claimedBy,
|
|
250
|
+
claimedAt: i
|
|
251
|
+
}, { where: t(n("status", "pending"), a("id", e)) }) === 0) return {
|
|
252
|
+
delivered: 0,
|
|
253
|
+
failed: 0,
|
|
254
|
+
dead: 0,
|
|
255
|
+
skipped: 0,
|
|
256
|
+
scanned: l.length,
|
|
257
|
+
...p === void 0 ? {} : { nextAttemptAt: p }
|
|
258
|
+
};
|
|
259
|
+
_ = await r.store.query({
|
|
260
|
+
table: h,
|
|
261
|
+
predicate: t(n("status", "delivering"), n("claimedBy", r.claimedBy), a("id", e)),
|
|
262
|
+
order: [{
|
|
263
|
+
column: "nextAttemptAt",
|
|
264
|
+
direction: "asc"
|
|
265
|
+
}],
|
|
266
|
+
take: void 0,
|
|
267
|
+
skip: void 0,
|
|
268
|
+
projection: void 0
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
let v = 0, y = 0, b = 0, x = 0;
|
|
272
|
+
for (let t of _) {
|
|
273
|
+
let n = t.id, a = t.effect, o = r.handlers.get(a);
|
|
274
|
+
if (o === void 0) {
|
|
275
|
+
x++, await j(r, n);
|
|
276
|
+
continue;
|
|
277
|
+
}
|
|
278
|
+
let s = t.attempts + 1, c = t.maxAttempts ?? S, l = /* @__PURE__ */ new Date(), u = r.attemptLogCap ?? 50;
|
|
279
|
+
try {
|
|
280
|
+
let i = {
|
|
281
|
+
outboxId: n,
|
|
282
|
+
idempotencyKey: t.idempotencyKey ?? null,
|
|
283
|
+
payload: t.payload ?? {},
|
|
284
|
+
attempt: s,
|
|
285
|
+
subjectId: t.subjectId ?? null,
|
|
286
|
+
tenantId: t.tenantId ?? null,
|
|
287
|
+
traceId: t.traceId ?? null
|
|
288
|
+
}, a = r.measureSync ? r.measureSync(() => o.handler(i)) : o.handler(i), c = e.isEffect(a) ? a : await a, d = e.isEffect(c) ? await (r.runEffect ? r.runEffect(c, i) : e.runPromise(c)) : c;
|
|
289
|
+
await k(r.store, {
|
|
290
|
+
outboxRow: t,
|
|
291
|
+
attempt: s,
|
|
292
|
+
outcome: "delivered",
|
|
293
|
+
startedAt: l,
|
|
294
|
+
finishedAt: /* @__PURE__ */ new Date(),
|
|
295
|
+
error: null,
|
|
296
|
+
response: d
|
|
297
|
+
}, u), await r.store.update(h, n, {
|
|
298
|
+
status: "delivered",
|
|
299
|
+
attempts: s,
|
|
300
|
+
deliveredAt: /* @__PURE__ */ new Date(),
|
|
301
|
+
lastError: null,
|
|
302
|
+
claimedBy: null,
|
|
303
|
+
claimedAt: null,
|
|
304
|
+
resendRequestedBy: null,
|
|
305
|
+
resendRequestedAt: null,
|
|
306
|
+
resendReason: null
|
|
307
|
+
}), v++;
|
|
308
|
+
} catch (e) {
|
|
309
|
+
let o = e instanceof Error ? e.message : String(e), d = s >= c;
|
|
310
|
+
await k(r.store, {
|
|
311
|
+
outboxRow: t,
|
|
312
|
+
attempt: s,
|
|
313
|
+
outcome: d ? "dead" : "failed",
|
|
314
|
+
startedAt: l,
|
|
315
|
+
finishedAt: /* @__PURE__ */ new Date(),
|
|
316
|
+
error: o,
|
|
317
|
+
response: null
|
|
318
|
+
}, u), await r.store.update(h, n, {
|
|
319
|
+
status: d ? "dead" : "pending",
|
|
320
|
+
attempts: s,
|
|
321
|
+
lastError: o,
|
|
322
|
+
nextAttemptAt: new Date(i.getTime() + w(s)),
|
|
323
|
+
claimedBy: null,
|
|
324
|
+
claimedAt: null,
|
|
325
|
+
resendRequestedBy: null,
|
|
326
|
+
resendRequestedAt: null,
|
|
327
|
+
resendReason: null
|
|
328
|
+
}), d ? (b++, m.error("outbox effect dead-lettered after exhausting attempts", {
|
|
329
|
+
id: n,
|
|
330
|
+
effect: a,
|
|
331
|
+
attempts: s,
|
|
332
|
+
maxAttempts: c
|
|
333
|
+
}, e)) : (y++, m.warn("outbox delivery failed; will retry", {
|
|
334
|
+
id: n,
|
|
335
|
+
effect: a,
|
|
336
|
+
attempt: s,
|
|
337
|
+
maxAttempts: c,
|
|
338
|
+
retryInMs: w(s)
|
|
339
|
+
}));
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
return {
|
|
343
|
+
delivered: v,
|
|
344
|
+
failed: y,
|
|
345
|
+
dead: b,
|
|
346
|
+
skipped: x,
|
|
347
|
+
scanned: l.length,
|
|
348
|
+
...p === void 0 ? {} : { nextAttemptAt: p }
|
|
349
|
+
};
|
|
350
|
+
};
|
|
351
|
+
//#endregion
|
|
352
|
+
export { T as DEFAULT_OUTBOX_CLAIM_LEASE_MS, v as OUTBOX_ATTEMPTS_TABLE, E as OUTBOX_ATTEMPT_LOG_CAP, h as OUTBOX_TABLE, w as backoffMs, x as defineOutboxHandler, M as drainOutbox, C as makeOutboxFacade, b as outboxAttemptsTable, _ as outboxTable };
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { and as e, eq as t } from "@voltro/database";
|
|
2
|
+
//#region src/pluginRefRules.ts
|
|
3
|
+
var n = (e) => e.old ?? e.new ?? {}, r = (e) => String(n(e).id ?? ""), i = (e) => {
|
|
4
|
+
let t = n(e).tenantId;
|
|
5
|
+
return typeof t == "string" ? t : null;
|
|
6
|
+
}, a = (e) => e.op === "update" && (e.old?.deletedAt ?? null) === null && (e.new?.deletedAt ?? null) !== null, o = (e, t) => {
|
|
7
|
+
let n = a(t);
|
|
8
|
+
return t.op !== "delete" && !n ? [] : e.filter((e) => e.targetTable === t.table && e.policy !== "keep" && (n ? e.onSoftDelete : e.onHardDelete !== !1));
|
|
9
|
+
}, s = (e) => {
|
|
10
|
+
let t = [], n = [];
|
|
11
|
+
for (let r of e) for (let [e, i] of Object.entries(r.fields ?? {})) {
|
|
12
|
+
if (i.refOnSoftDelete === void 0 || i.type !== "reference" || i.references === void 0) continue;
|
|
13
|
+
let a;
|
|
14
|
+
try {
|
|
15
|
+
a = i.references()?.tableName;
|
|
16
|
+
} catch {
|
|
17
|
+
a = void 0;
|
|
18
|
+
}
|
|
19
|
+
a !== void 0 && (i.refOnSoftDelete === "cascade" && r.softDeletable !== !0 ? n.push(`${r.name}.${e} → ${a}`) : t.push({
|
|
20
|
+
table: r.name,
|
|
21
|
+
column: e,
|
|
22
|
+
targetTable: a,
|
|
23
|
+
policy: i.refOnSoftDelete === "cascade" ? "delete" : "null",
|
|
24
|
+
onSoftDelete: !0,
|
|
25
|
+
onHardDelete: !1
|
|
26
|
+
}));
|
|
27
|
+
}
|
|
28
|
+
if (n.length > 0) throw Error(`reference(…, { onSoftDelete: 'cascade' }) on a table without softDelete(): ${n.join(", ")}.\n A cascade on a SOFT delete must soft-delete the children, so their table needs \`.with(softDelete())\` —
|
|
29
|
+
otherwise the runtime would hard-delete them, and restoring the parent would restore nothing.
|
|
30
|
+
Add the mixin, or use { onSoftDelete: 'setNull' } on a nullable column.`);
|
|
31
|
+
return t;
|
|
32
|
+
}, c = async (n, a, s) => {
|
|
33
|
+
let c = o(a, s);
|
|
34
|
+
if (c.length === 0) return [];
|
|
35
|
+
let l = r(s), u = i(s), d = [];
|
|
36
|
+
for (let r of c) {
|
|
37
|
+
let i = u === null ? t(r.column, l) : e(t(r.column, l), t("tenantId", u)), a = r.policy === "delete" ? await n.deleteMany(r.table, { where: i }) : await n.updateMany(r.table, { [r.column]: null }, { where: i });
|
|
38
|
+
d.push({
|
|
39
|
+
rule: r,
|
|
40
|
+
affected: a
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
return d;
|
|
44
|
+
}, l = (e, t) => {
|
|
45
|
+
let n = [];
|
|
46
|
+
for (let r of e) for (let e of r.appliedPluginRefs ?? []) {
|
|
47
|
+
let i = e.column, a;
|
|
48
|
+
try {
|
|
49
|
+
a = e.target()?.tableName;
|
|
50
|
+
} catch {
|
|
51
|
+
a = void 0;
|
|
52
|
+
}
|
|
53
|
+
if (a === void 0 || !t.has(a)) throw Error(`pluginRef: ${r.name}.${i} points at ${a ?? "an unresolvable table"}, which no installed plugin registers. A declared orphan rule against an absent table would look enforced and never fire — install the plugin that owns it, or drop the column.`);
|
|
54
|
+
n.push({
|
|
55
|
+
table: r.name,
|
|
56
|
+
column: i,
|
|
57
|
+
targetTable: a,
|
|
58
|
+
policy: e.orphanPolicy,
|
|
59
|
+
onSoftDelete: e.onSoftDelete
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
return n.filter((e) => e.policy !== "keep");
|
|
63
|
+
};
|
|
64
|
+
//#endregion
|
|
65
|
+
export { c as applyPluginRefRules, l as collectPluginRefRules, s as collectReferenceSoftDeleteRules, a as isSoftDelete, o as rulesFor };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { can as e, getResourcePolicy as t } from "./rebac.js";
|
|
2
|
+
import { currentRequestLoader as n } from "./requestLoader.js";
|
|
3
|
+
import { Effect as r } from "effect";
|
|
4
|
+
import { setPolicyGuardResolver as i } from "@voltro/protocol";
|
|
5
|
+
import { createLogger as a } from "@voltro/logger";
|
|
6
|
+
//#region src/policyGuardResolver.ts
|
|
7
|
+
var o = a({ scope: "voltro:policy" }), s, c = (e) => {
|
|
8
|
+
s = e;
|
|
9
|
+
}, l = () => s, u = (e) => s === void 0 && (s = e, !0), d = () => {
|
|
10
|
+
i((i) => r.gen(function* () {
|
|
11
|
+
let a = t(i.resourceType);
|
|
12
|
+
if (a === void 0) return o.warn("policy guard denied — no resource policy registered for this type", {
|
|
13
|
+
resourceType: i.resourceType,
|
|
14
|
+
action: i.action
|
|
15
|
+
}), !1;
|
|
16
|
+
let c = s;
|
|
17
|
+
if (c === void 0) return o.warn("policy guard denied — no tuple source registered (call setTupleSource at boot)", {
|
|
18
|
+
resourceType: i.resourceType,
|
|
19
|
+
action: i.action
|
|
20
|
+
}), !1;
|
|
21
|
+
let l = yield* r.tryPromise({
|
|
22
|
+
try: async () => c({
|
|
23
|
+
subjectId: i.subject.id,
|
|
24
|
+
subject: i.subject,
|
|
25
|
+
resourceType: i.resourceType,
|
|
26
|
+
resourceId: i.resourceId,
|
|
27
|
+
load: n()
|
|
28
|
+
}),
|
|
29
|
+
catch: (e) => e
|
|
30
|
+
}).pipe(r.catch((e) => (o.error("policy guard denied — tuple source failed", {
|
|
31
|
+
resourceType: i.resourceType,
|
|
32
|
+
resourceId: i.resourceId
|
|
33
|
+
}, e), r.succeed([]))));
|
|
34
|
+
if (l === "missing") return "missing";
|
|
35
|
+
if (!Array.isArray(l)) return o.error("policy guard denied — tuple source returned neither tuples nor 'missing'", {
|
|
36
|
+
resourceType: i.resourceType,
|
|
37
|
+
resourceId: i.resourceId
|
|
38
|
+
}), !1;
|
|
39
|
+
let u = i.subject;
|
|
40
|
+
return e({
|
|
41
|
+
id: i.subject.id,
|
|
42
|
+
tenantId: u.tenantId ?? null,
|
|
43
|
+
...u.scopes === void 0 ? {} : { scopes: u.scopes }
|
|
44
|
+
}, i.action, {
|
|
45
|
+
type: i.resourceType,
|
|
46
|
+
id: i.resourceId,
|
|
47
|
+
tenantId: u.tenantId ?? null
|
|
48
|
+
}, {
|
|
49
|
+
policy: a,
|
|
50
|
+
tuples: l
|
|
51
|
+
});
|
|
52
|
+
}));
|
|
53
|
+
};
|
|
54
|
+
//#endregion
|
|
55
|
+
export { l as getTupleSource, d as installPolicyGuardResolver, u as registerDefaultTupleSource, c as setTupleSource };
|
package/dist/preview.js
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
//#region src/preview.ts
|
|
2
|
+
var e = (e) => {
|
|
3
|
+
let t = e.new?.id;
|
|
4
|
+
if (typeof t == "string") return t;
|
|
5
|
+
let n = e.old?.id;
|
|
6
|
+
return typeof n == "string" ? n : void 0;
|
|
7
|
+
}, t = (t) => {
|
|
8
|
+
let n = {};
|
|
9
|
+
if (t.op === "insert") for (let [e, r] of Object.entries(t.new ?? {})) n[e] = {
|
|
10
|
+
from: void 0,
|
|
11
|
+
to: r
|
|
12
|
+
};
|
|
13
|
+
else if (t.op === "delete") for (let [e, r] of Object.entries(t.old ?? {})) n[e] = {
|
|
14
|
+
from: r,
|
|
15
|
+
to: void 0
|
|
16
|
+
};
|
|
17
|
+
else {
|
|
18
|
+
let e = t.old ?? {}, r = t.new ?? {};
|
|
19
|
+
for (let t of /* @__PURE__ */ new Set([...Object.keys(e), ...Object.keys(r)])) Object.is(e[t], r[t]) || (n[t] = {
|
|
20
|
+
from: e[t],
|
|
21
|
+
to: r[t]
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
return {
|
|
25
|
+
table: t.table,
|
|
26
|
+
op: t.op,
|
|
27
|
+
id: e(t),
|
|
28
|
+
fields: n
|
|
29
|
+
};
|
|
30
|
+
}, n = (e) => {
|
|
31
|
+
let n = e.map(t), r = {
|
|
32
|
+
inserts: 0,
|
|
33
|
+
updates: 0,
|
|
34
|
+
deletes: 0
|
|
35
|
+
};
|
|
36
|
+
for (let e = 0; e < n.length; e++) {
|
|
37
|
+
if (!(e in n)) continue;
|
|
38
|
+
let t = n[e];
|
|
39
|
+
t.op === "insert" ? r.inserts += 1 : t.op === "update" ? r.updates += 1 : t.op === "delete" && (r.deletes += 1);
|
|
40
|
+
}
|
|
41
|
+
return {
|
|
42
|
+
rows: n,
|
|
43
|
+
summary: r
|
|
44
|
+
};
|
|
45
|
+
}, r = class extends Error {
|
|
46
|
+
constructor() {
|
|
47
|
+
super("voltro:preview-rollback"), this.name = "PreviewRollback";
|
|
48
|
+
}
|
|
49
|
+
}, i = async (e, t) => {
|
|
50
|
+
let n, i = !1;
|
|
51
|
+
try {
|
|
52
|
+
await e.transactional(async (e) => {
|
|
53
|
+
throw n = await t(e), i = !0, new r();
|
|
54
|
+
});
|
|
55
|
+
} catch (e) {
|
|
56
|
+
if (!(e instanceof r)) throw e;
|
|
57
|
+
}
|
|
58
|
+
if (!i) throw Error("preview: handler did not complete");
|
|
59
|
+
return n;
|
|
60
|
+
};
|
|
61
|
+
//#endregion
|
|
62
|
+
export { n as buildPreview, t as diffChange, i as previewInRollback };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//#region src/projectedRows.ts
|
|
2
|
+
var e = (e, t) => {
|
|
3
|
+
let n = [], r = e.length;
|
|
4
|
+
for (let i = 0; i < r; i += 1) {
|
|
5
|
+
if (!(i in e)) continue;
|
|
6
|
+
let r = t(e[i]);
|
|
7
|
+
r !== null && n.push(r);
|
|
8
|
+
}
|
|
9
|
+
return n;
|
|
10
|
+
};
|
|
11
|
+
//#endregion
|
|
12
|
+
export { e as collectProjectedRows };
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
//#region src/provenance.ts
|
|
2
|
+
var e = (e) => e instanceof Date ? e.toISOString() : typeof e == "string" && e.length > 0 ? e : null, t = (e) => typeof e == "string" && e.length > 0 ? e : null, n = [
|
|
3
|
+
"updatedAt",
|
|
4
|
+
"createdAt",
|
|
5
|
+
"updatedBy",
|
|
6
|
+
"createdBy"
|
|
7
|
+
], r = (e) => n.some((t) => t in e), i = (n, i, a) => {
|
|
8
|
+
let o = {
|
|
9
|
+
table: i.table,
|
|
10
|
+
id: i.id,
|
|
11
|
+
...i.column === void 0 ? {} : { column: i.column },
|
|
12
|
+
...a?.derived ? { derived: !0 } : {}
|
|
13
|
+
};
|
|
14
|
+
if (!n) return {
|
|
15
|
+
...o,
|
|
16
|
+
value: void 0,
|
|
17
|
+
lastWrite: null,
|
|
18
|
+
attribution: "none",
|
|
19
|
+
found: !1
|
|
20
|
+
};
|
|
21
|
+
let s = i.column === void 0 ? void 0 : n[i.column];
|
|
22
|
+
if (!r(n)) return {
|
|
23
|
+
...o,
|
|
24
|
+
value: s,
|
|
25
|
+
lastWrite: null,
|
|
26
|
+
attribution: "none",
|
|
27
|
+
found: !0
|
|
28
|
+
};
|
|
29
|
+
let c = t(n.updatedBy) ?? t(n.createdBy), l = e(n.updatedAt) ?? e(n.createdAt);
|
|
30
|
+
return {
|
|
31
|
+
...o,
|
|
32
|
+
value: s,
|
|
33
|
+
lastWrite: {
|
|
34
|
+
actor: { id: c },
|
|
35
|
+
at: l,
|
|
36
|
+
...a?.traceId === void 0 ? {} : { traceId: a.traceId }
|
|
37
|
+
},
|
|
38
|
+
attribution: "audit",
|
|
39
|
+
found: !0
|
|
40
|
+
};
|
|
41
|
+
}, a = (n, r) => {
|
|
42
|
+
let i = n.map((n) => {
|
|
43
|
+
let i = n.newValue ?? n.value, a = r.column !== void 0 && i && typeof i == "object" ? i[r.column] : n.newValue ?? n.value;
|
|
44
|
+
return {
|
|
45
|
+
actor: { id: t(n.actor) ?? t(n.changedBy) },
|
|
46
|
+
at: e(n.at) ?? e(n.changedAt),
|
|
47
|
+
...n.traceId === void 0 ? {} : { traceId: n.traceId },
|
|
48
|
+
value: a
|
|
49
|
+
};
|
|
50
|
+
}), a = i.length > 0 ? i[i.length - 1] : null;
|
|
51
|
+
return {
|
|
52
|
+
table: r.table,
|
|
53
|
+
id: r.id,
|
|
54
|
+
...r.column === void 0 ? {} : { column: r.column },
|
|
55
|
+
value: a?.value,
|
|
56
|
+
lastWrite: a,
|
|
57
|
+
attribution: a ? "audit" : "none",
|
|
58
|
+
history: i,
|
|
59
|
+
found: i.length > 0
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
//#endregion
|
|
63
|
+
export { a as historyProvenance, i as lastWriteProvenance };
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
//#region src/rangeIndex.ts
|
|
2
|
+
var e = (e) => e?.height ?? 0, t = (t) => (t.height = 1 + Math.max(e(t.left), e(t.right)), t), n = (e) => {
|
|
3
|
+
let n = e.left;
|
|
4
|
+
return e.left = n.right, n.right = t(e), t(n);
|
|
5
|
+
}, r = (e) => {
|
|
6
|
+
let n = e.right;
|
|
7
|
+
return e.right = n.left, n.left = t(e), t(n);
|
|
8
|
+
}, i = (i) => (t(i), e(i.left) - e(i.right) > 1 ? (e(i.left.left) < e(i.left.right) && (i.left = r(i.left)), n(i)) : e(i.right) - e(i.left) > 1 ? (e(i.right.right) < e(i.right.left) && (i.right = n(i.right)), r(i)) : i), a = (e) => typeof e == "string" || typeof e == "boolean" || typeof e == "number" && !Number.isNaN(e), o = (e, t) => e < t, s = (e, t, n) => e ? (t === e.value ? e.members.add(n) : o(t, e.value) ? e.left = s(e.left, t, n) : e.right = s(e.right, t, n), i(e)) : {
|
|
9
|
+
value: t,
|
|
10
|
+
members: /* @__PURE__ */ new Set([n]),
|
|
11
|
+
height: 1,
|
|
12
|
+
left: void 0,
|
|
13
|
+
right: void 0
|
|
14
|
+
}, c = (e, t, n) => {
|
|
15
|
+
if (e) {
|
|
16
|
+
if (t === e.value) {
|
|
17
|
+
if (n !== void 0 && e.members.delete(n), n !== void 0 && e.members.size > 0) return e;
|
|
18
|
+
if (!e.left) return e.right;
|
|
19
|
+
if (!e.right) return e.left;
|
|
20
|
+
let t = e.right;
|
|
21
|
+
for (; t.left;) t = t.left;
|
|
22
|
+
e.value = t.value, e.members = t.members, e.right = c(e.right, t.value, void 0);
|
|
23
|
+
} else o(t, e.value) ? e.left = c(e.left, t, n) : e.right = c(e.right, t, n);
|
|
24
|
+
return i(e);
|
|
25
|
+
}
|
|
26
|
+
}, l = class {
|
|
27
|
+
members = /* @__PURE__ */ new Map();
|
|
28
|
+
roots = /* @__PURE__ */ new Map();
|
|
29
|
+
fallback = /* @__PURE__ */ new Map();
|
|
30
|
+
get size() {
|
|
31
|
+
return this.members.size;
|
|
32
|
+
}
|
|
33
|
+
keys() {
|
|
34
|
+
return this.members.keys();
|
|
35
|
+
}
|
|
36
|
+
add(e, t) {
|
|
37
|
+
let n = this.members.get(e);
|
|
38
|
+
if (n ? n.push(t) : this.members.set(e, [t]), a(t)) this.roots.set(typeof t, s(this.roots.get(typeof t), t, e));
|
|
39
|
+
else {
|
|
40
|
+
let n = this.fallback.get(e);
|
|
41
|
+
n ? n.push(t) : this.fallback.set(e, [t]);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
delete(e) {
|
|
45
|
+
for (let t of this.members.get(e) ?? []) {
|
|
46
|
+
if (!a(t)) continue;
|
|
47
|
+
let n = c(this.roots.get(typeof t), t, e);
|
|
48
|
+
n ? this.roots.set(typeof t, n) : this.roots.delete(typeof t);
|
|
49
|
+
}
|
|
50
|
+
this.members.delete(e), this.fallback.delete(e);
|
|
51
|
+
}
|
|
52
|
+
numericExtreme(e) {
|
|
53
|
+
let t = this.roots.get("number");
|
|
54
|
+
if (t === void 0) return;
|
|
55
|
+
let n = t;
|
|
56
|
+
for (;;) {
|
|
57
|
+
let t = e === "min" ? n.left : n.right;
|
|
58
|
+
if (t === void 0) return n.value;
|
|
59
|
+
n = t;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
candidates(e, t, n) {
|
|
63
|
+
let r = /* @__PURE__ */ new Set();
|
|
64
|
+
if (!a(e)) {
|
|
65
|
+
for (let [e, t] of this.members) t.some(n) && r.add(e);
|
|
66
|
+
return r;
|
|
67
|
+
}
|
|
68
|
+
let i = (e) => {
|
|
69
|
+
if (e) {
|
|
70
|
+
i(e.left);
|
|
71
|
+
for (let t of e.members) r.add(t);
|
|
72
|
+
i(e.right);
|
|
73
|
+
}
|
|
74
|
+
}, s = t === "gt" || t === "gte", c = t === "gte" || t === "lte", l = (t) => {
|
|
75
|
+
if (t) {
|
|
76
|
+
if ((s ? o(t.value, e) : o(e, t.value)) || c && e === t.value) {
|
|
77
|
+
i(s ? t.left : t.right);
|
|
78
|
+
for (let e of t.members) r.add(e);
|
|
79
|
+
l(s ? t.right : t.left);
|
|
80
|
+
} else l(s ? t.left : t.right);
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
l(this.roots.get(typeof e));
|
|
84
|
+
for (let [e, t] of this.fallback) t.some(n) && r.add(e);
|
|
85
|
+
return r;
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
//#endregion
|
|
89
|
+
export { l as RangeIndex };
|