@voltro/runtime 0.86.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 +5321 -0
- package/README.md +43 -0
- package/THIRD-PARTY-NOTICES.md +860 -221
- package/dist/analyticsSink.js +8 -14
- package/dist/apiKeys.js +82 -78
- 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/approvals.js +67 -74
- package/dist/authMiddlewareLayer.js +7 -6
- package/dist/bindEvent.js +48 -28
- package/dist/bootListener.js +106 -39
- package/dist/bootStoreCodec.js +38 -37
- package/dist/circuitBreaker.js +1 -72
- package/dist/composeAnalytics.js +31 -10
- package/dist/computedQueryCache.js +231 -0
- package/dist/connectionsFacade.js +32 -30
- package/dist/coordinatedSchedule.js +84 -78
- package/dist/dataStore.js +154 -121
- package/dist/declaredTablesGuard.js +2 -1
- package/dist/dispatcher.js +403 -328
- package/dist/effectStore.js +2 -2
- package/dist/engineClients.js +24 -0
- package/dist/externalizedTasks.js +19 -6
- package/dist/fieldCipher.js +109 -40
- 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/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 +12 -37
- package/dist/httpClientTracing.js +12 -9
- package/dist/httpCompression.js +17 -17
- package/dist/httpInputStream.js +82 -0
- package/dist/httpRouteMounts.js +1 -0
- package/dist/idempotencyStore.js +92 -52
- package/dist/index.d.ts +1164 -451
- package/dist/index.js +143 -132
- package/dist/kvFacade.js +23 -17
- package/dist/memoryQueryJoins.js +16 -16
- package/dist/memorySetOperations.js +43 -0
- package/dist/metrics.js +38 -24
- package/dist/outbox.js +1 -1
- package/dist/readRecorder.js +35 -34
- package/dist/readScopePredicate.js +12 -0
- package/dist/replicatedDataStore.js +22 -4
- package/dist/rowFilter.js +56 -39
- package/dist/rpcConnections.js +8 -8
- package/dist/rpcServer.js +522 -449
- package/dist/rpcWorkloadAdmission.js +50 -0
- package/dist/rywPositionStore.js +82 -47
- package/dist/scheduler.js +6 -1
- package/dist/servePipeline.js +215 -146
- package/dist/setReadScopes.js +28 -0
- package/dist/snapshotValueCodec.js +46 -0
- package/dist/sourceResolution.js +34 -24
- package/dist/storeMiddleware.js +211 -209
- package/dist/subscriber.js +1 -0
- package/dist/tenantScope.js +8 -20
- package/dist/traceparent.js +8 -19
- package/dist/webSocketGatewayRuntime.js +111 -71
- package/dist/workflowRuntime.js +9 -9
- package/package.json +19 -7
package/dist/idempotencyStore.js
CHANGED
|
@@ -1,70 +1,110 @@
|
|
|
1
1
|
import { and as e, eq as t, generateId as n, lte as r } from "@voltro/database";
|
|
2
|
-
import { freshFor as i
|
|
2
|
+
import { freshFor as i } from "@voltro/protocol";
|
|
3
3
|
//#region src/idempotencyStore.ts
|
|
4
|
-
var
|
|
5
|
-
if (e
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
4
|
+
var a = "_voltro_idempotency", o = () => /* @__PURE__ */ Error("Stored idempotency receipt is invalid"), s = (e) => {
|
|
5
|
+
if (e === null) return null;
|
|
6
|
+
try {
|
|
7
|
+
let t = typeof e == "string" ? JSON.parse(e) : e;
|
|
8
|
+
if (t === null) return null;
|
|
9
|
+
if (typeof t != "object") throw o();
|
|
10
|
+
let n = Object.getPrototypeOf(t);
|
|
11
|
+
if (n !== Object.prototype && n !== null) throw o();
|
|
12
|
+
let r = Object.getOwnPropertyDescriptor(t, "status"), i = r && "value" in r ? r.value : void 0;
|
|
13
|
+
if (typeof i != "number" || !Number.isInteger(i) || i < 100 || i > 999) throw o();
|
|
14
|
+
let a = Object.getOwnPropertyDescriptor(t, "body");
|
|
15
|
+
if (a && !("value" in a)) throw o();
|
|
16
|
+
let s = a?.value, c = Object.getOwnPropertyDescriptor(t, "rest");
|
|
17
|
+
if (c && !("value" in c)) throw o();
|
|
18
|
+
return {
|
|
19
|
+
status: i,
|
|
20
|
+
body: s,
|
|
21
|
+
...c ? { rest: c.value } : {}
|
|
22
|
+
};
|
|
23
|
+
} catch {
|
|
24
|
+
throw o();
|
|
25
|
+
}
|
|
26
|
+
}, c = (e) => {
|
|
27
|
+
try {
|
|
28
|
+
let t = e instanceof Date ? Date.prototype.getTime.call(e) : typeof e == "number" || typeof e == "string" ? new Date(e).getTime() : NaN;
|
|
29
|
+
if (!Number.isFinite(t) || typeof e == "number" && t !== e) throw o();
|
|
30
|
+
return t;
|
|
31
|
+
} catch {
|
|
32
|
+
throw o();
|
|
33
|
+
}
|
|
34
|
+
}, l = (e) => {
|
|
35
|
+
if (typeof e.id != "string" || e.id.length === 0 || typeof e.scope != "string" || typeof e.key != "string" || e.status !== "in_flight" && e.status !== "completed" || e.inputHash != null && (typeof e.inputHash != "string" || !/^[0-9a-f]{64}$/.test(e.inputHash))) throw o();
|
|
36
|
+
let t = c(e.createdAt), n = s(e.response);
|
|
37
|
+
if (e.status === "in_flight" != (n === null)) throw o();
|
|
38
|
+
return {
|
|
39
|
+
scope: e.scope,
|
|
40
|
+
key: e.key,
|
|
41
|
+
inputHash: e.inputHash ?? null,
|
|
42
|
+
status: e.status,
|
|
43
|
+
response: n,
|
|
44
|
+
createdAt: t
|
|
45
|
+
};
|
|
46
|
+
}, u = async (n, r, i) => (await n.query({
|
|
47
|
+
table: a,
|
|
16
48
|
predicate: e(t("scope", r), t("key", i)),
|
|
17
49
|
order: [],
|
|
18
50
|
take: 1,
|
|
19
51
|
skip: void 0,
|
|
20
52
|
projection: void 0
|
|
21
|
-
}))[0] ?? null,
|
|
53
|
+
}))[0] ?? null, d = (n) => e(t("id", n.id), t("scope", n.scope), t("key", n.key), t("inputHash", n.inputHash), t("status", "in_flight")), f = (o) => ({
|
|
22
54
|
get: async (e, t) => {
|
|
23
|
-
let n = await
|
|
24
|
-
return n ?
|
|
55
|
+
let n = await u(o, e, t);
|
|
56
|
+
return n ? l(n) : null;
|
|
25
57
|
},
|
|
26
|
-
claim: async (s,
|
|
27
|
-
for (let
|
|
28
|
-
let
|
|
58
|
+
claim: async (s, c, d, f, p, m) => {
|
|
59
|
+
for (let u = 0; u < 2; u++) {
|
|
60
|
+
let u = n({
|
|
29
61
|
kind: "typeid",
|
|
30
62
|
prefix: "idem"
|
|
31
|
-
},
|
|
32
|
-
id:
|
|
63
|
+
}, a), h = await o.insertIgnore(a, {
|
|
64
|
+
id: u,
|
|
33
65
|
scope: s,
|
|
34
|
-
key:
|
|
66
|
+
key: c,
|
|
67
|
+
inputHash: d,
|
|
35
68
|
status: "in_flight",
|
|
36
69
|
response: null,
|
|
37
|
-
createdAt: new Date(
|
|
38
|
-
}, { conflictColumns: ["scope", "key"] });
|
|
39
|
-
if (
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
70
|
+
createdAt: new Date(f)
|
|
71
|
+
}, { conflictColumns: ["scope", "key"] }), g = l(h);
|
|
72
|
+
if (h.id === u) {
|
|
73
|
+
if (g.scope !== s || g.key !== c || g.inputHash !== d || g.status !== "in_flight" || g.response !== null) throw Error("Idempotency acquisition did not retain the expected input witness");
|
|
74
|
+
return {
|
|
75
|
+
kind: "claimed",
|
|
76
|
+
claim: Object.freeze({
|
|
77
|
+
scope: s,
|
|
78
|
+
key: c,
|
|
79
|
+
id: u,
|
|
80
|
+
inputHash: d
|
|
81
|
+
})
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
if (g.inputHash !== d) return {
|
|
85
|
+
kind: "existing",
|
|
86
|
+
record: g
|
|
87
|
+
};
|
|
88
|
+
let _ = i(g.status, p, m);
|
|
89
|
+
if (f - g.createdAt < _) return {
|
|
90
|
+
kind: "existing",
|
|
91
|
+
record: g
|
|
92
|
+
};
|
|
93
|
+
await o.deleteMany(a, { where: e(t("id", h.id), t("scope", s), t("key", c), t("inputHash", d), t("status", h.status), r("createdAt", new Date(f - _))) });
|
|
43
94
|
}
|
|
44
|
-
let
|
|
45
|
-
return
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
response: null,
|
|
50
|
-
createdAt: d
|
|
51
|
-
};
|
|
95
|
+
let h = await u(o, s, c);
|
|
96
|
+
return h ? {
|
|
97
|
+
kind: "existing",
|
|
98
|
+
record: l(h)
|
|
99
|
+
} : { kind: "conflict" };
|
|
52
100
|
},
|
|
53
|
-
complete: async (e, t, n
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
renew: async (e, t, n) => {
|
|
61
|
-
let r = await l(a, e, t);
|
|
62
|
-
r !== null && r.status === "in_flight" && await a.update(o, r.id, { createdAt: new Date(n) });
|
|
63
|
-
},
|
|
64
|
-
release: async (e, t) => {
|
|
65
|
-
let n = await l(a, e, t);
|
|
66
|
-
n && await a.delete(o, n.id);
|
|
67
|
-
}
|
|
101
|
+
complete: async (e, t, n) => await o.updateMany(a, {
|
|
102
|
+
status: "completed",
|
|
103
|
+
response: t,
|
|
104
|
+
createdAt: new Date(n)
|
|
105
|
+
}, { where: d(e) }) === 1,
|
|
106
|
+
renew: async (e, t) => await o.updateMany(a, { createdAt: new Date(t) }, { where: d(e) }) === 1,
|
|
107
|
+
release: async (e) => await o.deleteMany(a, { where: d(e) }) === 1
|
|
68
108
|
});
|
|
69
109
|
//#endregion
|
|
70
|
-
export {
|
|
110
|
+
export { f as dataStoreIdempotencyStore };
|