@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.
Files changed (184) hide show
  1. package/CHANGELOG.md +5484 -0
  2. package/README.md +43 -0
  3. package/THIRD-PARTY-NOTICES.md +1511 -276
  4. package/dist/aggregate.js +1 -2
  5. package/dist/aggregateExtrema.js +1 -2
  6. package/dist/aggregateIvm.js +1 -2
  7. package/dist/analyticsMirror.js +1 -2
  8. package/dist/analyticsSink.js +9 -16
  9. package/dist/apiKeyUsage.js +1 -2
  10. package/dist/apiKeys.js +83 -80
  11. package/dist/apiKeysWiring.js +1 -2
  12. package/dist/apiRoleBucketSampler.js +63 -0
  13. package/dist/apiRoleWorkloadHistory.js +55 -0
  14. package/dist/apiRoleWorkloadMetrics.js +77 -0
  15. package/dist/apiRoleWorkloadStorage.js +94 -0
  16. package/dist/approvalBuiltins.js +1 -2
  17. package/dist/approvals.js +68 -76
  18. package/dist/authMiddlewareLayer.js +8 -8
  19. package/dist/bindEvent.js +49 -30
  20. package/dist/boot-refusal.d.ts +10 -0
  21. package/dist/{bootRefusal.js → boot-refusal.js} +1 -2
  22. package/dist/bootListener.js +203 -47
  23. package/dist/bootStoreCodec.js +39 -39
  24. package/dist/businessRules.js +1 -2
  25. package/dist/changeClaimsTable.js +1 -2
  26. package/dist/circuitBreaker.js +1 -72
  27. package/dist/columnOnUpdate.js +1 -2
  28. package/dist/composeAnalytics.js +32 -12
  29. package/dist/computedQuery.js +1 -2
  30. package/dist/computedQueryCache.js +289 -0
  31. package/dist/connectionBuiltins.js +1 -2
  32. package/dist/connectionCredentials.js +1 -2
  33. package/dist/connectionState.js +1 -2
  34. package/dist/connectionVault.js +1 -2
  35. package/dist/connectionsFacade.js +33 -32
  36. package/dist/coordinatedSchedule.js +85 -80
  37. package/dist/crdtHistory.js +1 -2
  38. package/dist/crdtMerge.js +1 -2
  39. package/dist/crdtVersionsTable.js +1 -2
  40. package/dist/credentialBound.js +1 -2
  41. package/dist/crud.js +1 -2
  42. package/dist/dataStore.js +155 -123
  43. package/dist/dataloader.js +1 -2
  44. package/dist/declaredTablesGuard.js +3 -3
  45. package/dist/defineExecutor.js +1 -2
  46. package/dist/dependencyGraph.js +1 -2
  47. package/dist/devices.js +1 -2
  48. package/dist/devicesWiring.js +1 -2
  49. package/dist/dialectReplicationAdapter.js +1 -2
  50. package/dist/dispatcher.js +404 -330
  51. package/dist/effectStore.js +3 -4
  52. package/dist/engineClients.js +23 -0
  53. package/dist/eventBus.js +1 -2
  54. package/dist/eventPublish.js +1 -2
  55. package/dist/events.js +1 -2
  56. package/dist/expectation.js +1 -2
  57. package/dist/expectationEvaluator.js +2 -3
  58. package/dist/experiment.js +1 -2
  59. package/dist/experimentEvaluator.js +1 -2
  60. package/dist/externalizedTasks.js +20 -8
  61. package/dist/fieldCipher.js +110 -42
  62. package/dist/fieldKeyRegistry.js +294 -0
  63. package/dist/fieldKeyRekey.js +285 -0
  64. package/dist/fieldKeyScan.js +135 -0
  65. package/dist/fieldKeyring.js +76 -0
  66. package/dist/fingerprint.js +1 -2
  67. package/dist/finops.js +1 -2
  68. package/dist/finopsAccountant.js +1 -2
  69. package/dist/handlerBody.js +1 -2
  70. package/dist/healthProbes.js +1 -2
  71. package/dist/hot.d.ts +56 -0
  72. package/dist/hot.js +3 -0
  73. package/dist/hotDataStore.js +147 -0
  74. package/dist/hotDataStoreSnapshot.js +97 -0
  75. package/dist/hotDataStoreTables.js +17 -0
  76. package/dist/http-range.d.ts +53 -0
  77. package/dist/http-range.js +51 -0
  78. package/dist/httpClientSsrf.js +13 -39
  79. package/dist/httpClientTracing.js +13 -11
  80. package/dist/httpCompression.js +18 -19
  81. package/dist/httpInputStream.js +81 -0
  82. package/dist/httpKeepAlive.js +1 -2
  83. package/dist/httpRouteMounts.js +2 -2
  84. package/dist/idempotencyStore.js +93 -54
  85. package/dist/idleDetector.js +1 -2
  86. package/dist/index.d.ts +1185 -452
  87. package/dist/index.js +144 -134
  88. package/dist/insertRequiredColumns.js +1 -2
  89. package/dist/instanceMembership.js +1 -2
  90. package/dist/ivm.js +1 -2
  91. package/dist/kvDataStore.js +1 -2
  92. package/dist/kvFacade.js +24 -19
  93. package/dist/matcher.js +1 -2
  94. package/dist/memoryColumnDefaults.js +1 -2
  95. package/dist/memoryQueryJoins.js +17 -18
  96. package/dist/memorySetOperations.js +42 -0
  97. package/dist/metrics.js +39 -26
  98. package/dist/observability.js +2 -3
  99. package/dist/observedGraph.js +1 -2
  100. package/dist/originGuard.js +1 -2
  101. package/dist/outbox.js +2 -3
  102. package/dist/pluginRefRules.js +1 -2
  103. package/dist/policyGuardResolver.js +1 -2
  104. package/dist/preview.js +1 -2
  105. package/dist/projectedRows.js +1 -2
  106. package/dist/provenance.js +1 -2
  107. package/dist/rangeIndex.js +1 -2
  108. package/dist/rawReadScope.js +2 -3
  109. package/dist/reaction.js +1 -2
  110. package/dist/reactiveConfig.js +1 -2
  111. package/dist/readClassification.js +1 -2
  112. package/dist/readRecorder.js +36 -36
  113. package/dist/readScopePredicate.js +11 -0
  114. package/dist/rebac.js +1 -2
  115. package/dist/rebacInterceptor.js +1 -2
  116. package/dist/registry.js +1 -2
  117. package/dist/relevantFields.js +1 -2
  118. package/dist/replicaHealth.js +1 -2
  119. package/dist/replicaLocality.js +1 -2
  120. package/dist/replicaObservations.js +1 -2
  121. package/dist/replicaSelection.js +1 -2
  122. package/dist/replicatedDataStore.js +23 -6
  123. package/dist/requestLoader.js +1 -2
  124. package/dist/resumeCensus.js +1 -2
  125. package/dist/revalidation.js +1 -2
  126. package/dist/rowFilter.js +57 -41
  127. package/dist/rowStateBytes.js +1 -2
  128. package/dist/rpcBodyCap.js +1 -2
  129. package/dist/rpcConnections.js +9 -10
  130. package/dist/rpcDefectDiagnostics.js +1 -2
  131. package/dist/rpcServer.js +523 -451
  132. package/dist/rpcWorkloadAdmission.js +49 -0
  133. package/dist/runAsSystem.js +1 -2
  134. package/dist/rywPositionStore.js +83 -49
  135. package/dist/schedule.js +1 -2
  136. package/dist/scheduleBackfillRequests.js +1 -2
  137. package/dist/scheduleClaimsTable.js +1 -2
  138. package/dist/scheduleRunsTable.js +1 -2
  139. package/dist/scheduler.js +7 -3
  140. package/dist/schemaRegistry.js +1 -2
  141. package/dist/secretsResolver.js +1 -2
  142. package/dist/securityHeaders.js +1 -2
  143. package/dist/servePipeline.js +238 -154
  144. package/dist/serverOnlyAudit.js +1 -2
  145. package/dist/serverTracer.js +1 -2
  146. package/dist/serviceCredentials.js +1 -2
  147. package/dist/setReadScopes.js +27 -0
  148. package/dist/singleNodeOrchestrator.js +1 -2
  149. package/dist/snapshotValueCodec.js +45 -0
  150. package/dist/sourceResolution.js +35 -26
  151. package/dist/storeMiddleware.js +213 -212
  152. package/dist/storeQuery.js +1 -2
  153. package/dist/storeRead.js +1 -2
  154. package/dist/subscriber.js +2 -2
  155. package/dist/subscriptionOutbox.js +1 -2
  156. package/dist/subscriptionRegistry.js +1 -2
  157. package/dist/subscriptionResume.js +1 -2
  158. package/dist/subscriptionSocketMetrics.js +1 -2
  159. package/dist/systemSubject.js +1 -2
  160. package/dist/tenantScope.js +9 -22
  161. package/dist/tenantSelection.js +1 -2
  162. package/dist/timeline.js +1 -2
  163. package/dist/traceContext.js +1 -2
  164. package/dist/traceSink.js +1 -2
  165. package/dist/traceSpansTable.js +1 -2
  166. package/dist/traceparent.js +9 -21
  167. package/dist/transactionSubject.js +1 -2
  168. package/dist/trustedProxy.js +2 -3
  169. package/dist/undo.js +1 -2
  170. package/dist/undoBuiltins.js +1 -2
  171. package/dist/undoCapture.js +1 -2
  172. package/dist/undoLogTable.js +1 -2
  173. package/dist/upsertBinding.js +1 -2
  174. package/dist/wakeOrchestrator.js +1 -2
  175. package/dist/wakeRegistry.js +1 -2
  176. package/dist/wakeRouter.js +1 -2
  177. package/dist/wakeSupervisor.js +1 -2
  178. package/dist/wakeupsTable.js +1 -2
  179. package/dist/webSocketGatewayRuntime.js +112 -73
  180. package/dist/webhookVerification.js +1 -2
  181. package/dist/wireColumnStrip.js +1 -2
  182. package/dist/workflowReadBuiltins.js +1 -2
  183. package/dist/workflowRuntime.js +10 -11
  184. package/package.json +36 -17
@@ -0,0 +1,49 @@
1
+ import { Context as e, Option as t } from "effect";
2
+ import { EventRpcWorkload as n } from "@voltro/protocol";
3
+ import { RpcGroup as r, RpcSchema as i } from "effect/rpc";
4
+ // src/rpcWorkloadAdmission.ts
5
+ var a = (e) => {
6
+ if (e === void 0) return;
7
+ if (!e || typeof e != "object" || Array.isArray(e) || ![Object.prototype, null].includes(Object.getPrototypeOf(e))) throw Error("Invalid RPC workload admission");
8
+ let t = /* @__PURE__ */ new Map();
9
+ for (let n of Reflect.ownKeys(e)) {
10
+ let r = Object.getOwnPropertyDescriptor(e, n);
11
+ if (typeof n != "string" || ![
12
+ "rpc",
13
+ "subscriptions",
14
+ "events",
15
+ "routes"
16
+ ].includes(n) || !r.enumerable || !("value" in r)) throw Error("RPC workload admission requires own data");
17
+ t.set(n, r.value);
18
+ }
19
+ let n = t.get("rpc"), r = t.get("subscriptions"), i = t.get("routes");
20
+ if (typeof n != "boolean" || typeof r != "boolean") throw Error("RPC workload admission requires explicit modes");
21
+ let a = t.get("events");
22
+ if (a !== void 0 && typeof a != "boolean") throw Error("Invalid event workload admission");
23
+ let o;
24
+ if (i !== void 0) {
25
+ if (!Array.isArray(i) || i.length > 4096 || Reflect.ownKeys(i).length !== i.length + 1) throw Error("Invalid RPC workload route filters");
26
+ let e = [];
27
+ for (let t = 0; t < i.length; t++) {
28
+ let n = Object.getOwnPropertyDescriptor(i, String(t));
29
+ if (!n?.enumerable || !("value" in n) || typeof n.value != "string" || n.value.length > 191 || !/^(?:[A-Za-z][A-Za-z0-9_-]*\.)*[A-Za-z][A-Za-z0-9_-]*(?:\.\*)?$/.test(n.value)) throw Error("Invalid RPC workload tag filter");
30
+ e.push(n.value);
31
+ }
32
+ if (new Set(e).size !== e.length) throw Error("Duplicate RPC workload tag filter");
33
+ o = Object.freeze(e);
34
+ }
35
+ return Object.freeze({
36
+ rpc: n,
37
+ subscriptions: r,
38
+ ...a === void 0 ? {} : { events: a },
39
+ ...o === void 0 ? {} : { routes: o }
40
+ });
41
+ }, o = (a, o, s) => {
42
+ if (!o) return a;
43
+ let c = [...a.requests.values()].filter((r) => {
44
+ let a = r, c = t.isSome(e.getOption(a.annotations, n)), l = o.events ?? o.subscriptions;
45
+ return (c ? l && (s === "websocket" || o.rpc) : s === "http" ? o.rpc : i.isStreamSchema(a.successSchema) ? o.subscriptions : o.rpc) && (o.routes === void 0 || o.routes.some((e) => e.endsWith(".*") ? r._tag.startsWith(e.slice(0, -1)) : r._tag === e));
46
+ });
47
+ return r.make(...c).annotateMerge(a.annotations);
48
+ };
49
+ export { a as captureRpcWorkloadAdmission, o as selectRpcWorkloadGroup };
@@ -1,7 +1,7 @@
1
1
  import { NO_ROW_FILTER as e } from "./rowFilter.js";
2
2
  import { wrapStoreWithMixinBehaviour as t } from "./storeMiddleware.js";
3
3
  import { systemSubject as n } from "@voltro/protocol";
4
- //#region src/runAsSystem.ts
4
+ // src/runAsSystem.ts
5
5
  var r, i = (e) => {
6
6
  r = e;
7
7
  }, a = () => {
@@ -19,5 +19,4 @@ var r, i = (e) => {
19
19
  })
20
20
  });
21
21
  };
22
- //#endregion
23
22
  export { a as clearSystemStoreHandle, o as getSystemStoreHandle, s as runAsSystem, i as setSystemStoreHandle };
@@ -1,6 +1,7 @@
1
- import { createLogger as e } from "@voltro/logger";
2
- //#region src/rywPositionStore.ts
3
- var t = e({ scope: "voltro:ryw" }), n = (e = {}) => {
1
+ import { Effect as e } from "effect";
2
+ import { createLogger as t } from "@voltro/logger";
3
+ // src/rywPositionStore.ts
4
+ var n = t({ scope: "voltro:ryw" }), r = (e = {}) => {
4
5
  let t = e.now ?? Date.now, n = /* @__PURE__ */ new Map();
5
6
  return {
6
7
  get(e) {
@@ -20,65 +21,98 @@ var t = e({ scope: "voltro:ryw" }), n = (e = {}) => {
20
21
  return n.size;
21
22
  }
22
23
  };
23
- }, r = (e, t) => e === null ? t === void 0 ? "anon:bg" : `anon:${t}` : `subject:${e}`, i = (e) => {
24
- let n = e.now ?? Date.now, r = e.keyPrefix ?? "voltro:ryw", i = e.channel ?? `${r}:bus`, a = e.onError ?? ((e, n) => {
25
- t.warn("redis operation failed", {
26
- op: n,
27
- error: String(e)
28
- });
29
- }), o = `${process.pid ?? 0}:${Math.random() * 1e9 | 0}:${n()}`, s = /* @__PURE__ */ new Map(), c = (e) => {
30
- if (e.senderId !== o) {
31
- if (e.op === "set") {
32
- if (e.position === void 0 || e.expiresAt === void 0) return;
33
- s.set(e.subjectKey, {
34
- position: e.position,
35
- expiresAt: e.expiresAt
36
- });
37
- } else s.delete(e.subjectKey);
24
+ }, i = (e, t) => e === null ? t === void 0 ? "anon:bg" : `anon:${t}` : `subject:${e}`, a = (t) => e.gen(function* () {
25
+ let r = yield* e.context(), i = e.runPromiseWith(r), a = t.now ?? Date.now, s = t.keyPrefix.trim();
26
+ if (s.length === 0) throw Error("RYW keyPrefix must name an application/environment namespace");
27
+ let c = t.channel ?? `${s}:bus`;
28
+ if (c.trim().length === 0) throw Error("RYW channel must not be empty");
29
+ let l = t.onError ?? ((e, t) => {
30
+ n.warn("redis operation failed", { op: t });
31
+ }), u = (e, t) => {
32
+ try {
33
+ l(e, t);
34
+ } catch {
35
+ n.warn("redis error observer failed", { op: t });
38
36
  }
39
- };
40
- e.subscriber.on("message", (e, t) => {
41
- if (e === i) try {
42
- let e = JSON.parse(t);
43
- c(e);
37
+ }, d = `${process.pid}:${Math.random()}:${a()}`, f = /* @__PURE__ */ new Map(), p = !1, m = Promise.resolve(), h, g = yield* t.pubsub.subscribe(c, (e) => {
38
+ if (!p) try {
39
+ let t = o(e);
40
+ if (t.senderId === d) return;
41
+ t.op === "delete" ? f.delete(t.subjectKey) : t.expiresAt > a() ? f.set(t.subjectKey, {
42
+ position: t.position,
43
+ expiresAt: t.expiresAt
44
+ }) : f.delete(t.subjectKey);
44
45
  } catch (e) {
45
- a(e, "parse");
46
+ u(e, "parse");
46
47
  }
47
- }), e.subscriber.subscribe(i).catch((e) => a(e, "subscribe"));
48
- let l = (t) => {
49
- let n = JSON.stringify(t);
50
- e.client.publish(i, n).catch((e) => a(e, t.op));
51
- }, u = (e) => `${r}:${e}`;
48
+ }).pipe(e.onError(() => t.pubsub.close)), _ = (e, n) => {
49
+ m = m.then(async () => {
50
+ try {
51
+ await n(), await i(t.pubsub.publish(c, JSON.stringify(e)));
52
+ } catch (t) {
53
+ u(t, e.op);
54
+ }
55
+ });
56
+ }, v = () => {
57
+ if (p) throw Error("RYW consumer is closed");
58
+ };
52
59
  return {
53
60
  get(e) {
54
- let t = s.get(e);
61
+ let t = f.get(e);
55
62
  if (t !== void 0) {
56
- if (t.expiresAt <= n()) s.delete(e);
63
+ if (t.expiresAt <= a()) f.delete(e);
57
64
  else return t;
58
65
  }
59
66
  },
60
- set(t, r) {
61
- s.set(t, r);
62
- let i = r.expiresAt - n();
63
- i > 0 && e.client.psetex(u(t), i, JSON.stringify(r)).catch((e) => a(e, "set")), l({
64
- senderId: o,
67
+ set(e, n) {
68
+ v();
69
+ let r = { ...n };
70
+ f.set(e, r), _({
71
+ senderId: d,
65
72
  op: "set",
66
- subjectKey: t,
67
- position: r.position,
68
- expiresAt: r.expiresAt
73
+ subjectKey: e,
74
+ ...r
75
+ }, () => {
76
+ let n = r.expiresAt - a();
77
+ return n > 0 ? t.client.psetex(`${s}:${e}`, n, JSON.stringify(r)) : t.client.del([`${s}:${e}`]);
69
78
  });
70
79
  },
71
- delete(t) {
72
- s.delete(t), e.client.del(u(t)).catch((e) => a(e, "delete")), l({
73
- senderId: o,
80
+ delete(e) {
81
+ v(), f.delete(e), _({
82
+ senderId: d,
74
83
  op: "delete",
75
- subjectKey: t
76
- });
84
+ subjectKey: e
85
+ }, () => t.client.del([`${s}:${e}`]));
77
86
  },
78
- size() {
79
- return s.size;
80
- }
87
+ size: () => f.size,
88
+ close: () => h ??= (async () => {
89
+ p = !0, await m;
90
+ try {
91
+ await i(g);
92
+ } finally {
93
+ try {
94
+ await i(t.pubsub.close);
95
+ } finally {
96
+ f.clear();
97
+ }
98
+ }
99
+ })()
100
+ };
101
+ }), o = (e) => {
102
+ let t = JSON.parse(e);
103
+ if (typeof t != "object" || !t || !("senderId" in t) || typeof t.senderId != "string" || !("subjectKey" in t) || typeof t.subjectKey != "string" || !("op" in t) || t.op !== "set" && t.op !== "delete") throw Error("Invalid RYW message");
104
+ if (t.op === "delete") return {
105
+ senderId: t.senderId,
106
+ subjectKey: t.subjectKey,
107
+ op: "delete"
108
+ };
109
+ if (!("position" in t) || typeof t.position != "string" || !("expiresAt" in t) || typeof t.expiresAt != "number" || !Number.isFinite(t.expiresAt)) throw Error("Invalid RYW position");
110
+ return {
111
+ senderId: t.senderId,
112
+ subjectKey: t.subjectKey,
113
+ op: "set",
114
+ position: t.position,
115
+ expiresAt: t.expiresAt
81
116
  };
82
117
  };
83
- //#endregion
84
- export { r as buildSubjectKey, n as memoryRywPositionStore, i as redisRywPositionStore };
118
+ export { i as buildSubjectKey, r as memoryRywPositionStore, a as redisRywPositionStore };
package/dist/schedule.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Cron as e, Result as t } from "effect";
2
- //#region src/schedule.ts
2
+ // src/schedule.ts
3
3
  var n = Symbol.for("@voltro/ScheduleDefinition"), r = (e) => typeof e == "object" && !!e && n in e, i = 18e5, a = (r) => {
4
4
  let i = e.parse(r.cron, r.timezone);
5
5
  if (t.isFailure(i)) throw Error(`defineSchedule("${r.name}"): invalid cron expression "${r.cron}" (tz="${r.timezone}") — ${String(i.failure)}`);
@@ -19,5 +19,4 @@ Use a five-field expression, or leave this schedule on trigger: 'self' (the in-a
19
19
  for (; c.getTime() <= r.getTime() && s.length <= i;) s.push(c), c = e.next(a, c);
20
20
  return s;
21
21
  };
22
- //#endregion
23
22
  export { i as DEFAULT_MAX_RUNTIME_MS, o as compileCron, c as cronOccurrences, a as defineSchedule, r as isScheduleDefinition, s as nextFiring };
@@ -1,7 +1,7 @@
1
1
  import { Schema as e } from "effect";
2
2
  import { and as t, eq as n, id as r, integer as i, isNull as a, json as o, lt as s, table as c, text as l, timestamp as u } from "@voltro/database";
3
3
  import { ScheduleBackfillRequestConflict as d } from "@voltro/protocol/inspect";
4
- //#region src/scheduleBackfillRequests.ts
4
+ // src/scheduleBackfillRequests.ts
5
5
  var f = 5e3, p = 3e4, m = "_voltro_schedule_backfill_requests", h = c(m, {
6
6
  id: r({ prefix: "schbackfill" }),
7
7
  name: l(),
@@ -147,5 +147,4 @@ var f = 5e3, p = 3e4, m = "_voltro_schedule_backfill_requests", h = c(m, {
147
147
  error: "Scheduler stopped before the backfill settled",
148
148
  updatedAt: /* @__PURE__ */ new Date()
149
149
  }, { where: t(n("status", "running"), n("owner", r)) }));
150
- //#endregion
151
150
  export { f as SCHEDULE_BACKFILL_HEARTBEAT_MS, m as SCHEDULE_BACKFILL_REQUESTS_TABLE, p as SCHEDULE_BACKFILL_STALE_MS, b as acceptScheduleBackfillRequest, x as claimScheduleBackfillRequest, S as executeScheduleBackfillRequest, w as interruptOwnedScheduleBackfills, C as interruptStaleScheduleBackfills, y as readScheduleBackfillRequest, h as scheduleBackfillRequestsTable };
@@ -1,5 +1,5 @@
1
1
  import { id as e, table as t, text as n, timestamp as r } from "@voltro/database";
2
- //#region src/scheduleClaimsTable.ts
2
+ // src/scheduleClaimsTable.ts
3
3
  var i = t("_voltro_schedule_claims", {
4
4
  id: e({ prefix: "schclaim" }),
5
5
  scheduleName: n(),
@@ -7,5 +7,4 @@ var i = t("_voltro_schedule_claims", {
7
7
  claimedBy: n(),
8
8
  claimedAt: r()
9
9
  }).index(["scheduleName", "claimedAt"]).index(["claimedAt"]);
10
- //#endregion
11
10
  export { i as _voltroScheduleClaimsTable };
@@ -1,5 +1,5 @@
1
1
  import { id as e, integer as t, json as n, table as r, text as i, timestamp as a } from "@voltro/database";
2
- //#region src/scheduleRunsTable.ts
2
+ // src/scheduleRunsTable.ts
3
3
  var o = r("_voltro_schedule_runs", {
4
4
  id: e({ prefix: "schrun" }),
5
5
  name: i(),
@@ -33,5 +33,4 @@ var o = r("_voltro_schedule_runs", {
33
33
  heartbeatAt: a().nullable(),
34
34
  result: n().nullable()
35
35
  }).index(["name", "scheduledAt"]).index(["status"]);
36
- //#endregion
37
36
  export { o as _voltroScheduleRunsTable };
package/dist/scheduler.js CHANGED
@@ -9,7 +9,7 @@ import { Cron as g, Effect as ne } from "effect";
9
9
  import { and as _, eq as v, extractDbCause as y, lt as re } from "@voltro/database";
10
10
  import { randomUUID as ie } from "node:crypto";
11
11
  import { publishServerError as ae } from "@voltro/protocol";
12
- //#region src/scheduler.ts
12
+ // src/scheduler.ts
13
13
  var b = c, x = "default", S = {
14
14
  kind: "single",
15
15
  tryClaim: async () => !0
@@ -363,7 +363,10 @@ var b = c, x = "default", S = {
363
363
  let n = typeof t.workflow.payload == "function" ? await t.workflow.payload(a) : t.workflow.payload ?? {};
364
364
  await e.start(t.workflow.name, n);
365
365
  }
366
- t.handler !== void 0 && await e(t.handler(a), (e) => x.runEffect ? x.runEffect(e, m.signal) : ne.runPromise(e, { signal: m.signal }));
366
+ if (t.handler !== void 0) {
367
+ let n = t.handler, r = x.measureSync ? x.measureSync(() => n(a)) : n(a);
368
+ await e(r, (e) => x.runEffect ? x.runEffect(e, m.signal) : ne.runPromise(e, { signal: m.signal }));
369
+ }
367
370
  }, h = k ? k(c, {
368
371
  name: t.name,
369
372
  scheduledAt: n,
@@ -662,6 +665,7 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
662
665
  };
663
666
  Ge.length > 0 && Q !== "off" && Ye();
664
667
  let Xe = async (e, t) => {
668
+ if (I) throw Error("scheduler stopped");
665
669
  let n = V.get(e);
666
670
  if (!n) return {
667
671
  kind: "unknownSchedule",
@@ -730,6 +734,7 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
730
734
  for (let e of X) Fe(e);
731
735
  }
732
736
  return {
737
+ isRunning: () => !I,
733
738
  triggerExternal: async (e, t) => {
734
739
  let r = await Xe(e, t);
735
740
  return n(e, r.kind), r;
@@ -831,5 +836,4 @@ Give each a five-field expression, or set trigger: 'self' on it.`);
831
836
  for (let [n, r] of Object.entries(e)) t[n] = r instanceof Date ? r.toISOString() : r;
832
837
  return t;
833
838
  };
834
- //#endregion
835
839
  export { w as CLAIM_RETENTION_BUCKETS, oe as DEFAULT_CLAIM_BUCKET_MS, ce as DEFAULT_EXTERNAL_RECONCILE_MS, se as DEFAULT_EXTERNAL_TRIGGER_SKEW_MS, fe as DEFAULT_SCHEDULE_HEARTBEAT_MS, x as DORMANCY_WAKEUP_TENANT, le as EXTERNAL_TRIGGER_AHEAD_TOLERANCE_MS, b as SCHEDULE_SUBJECT, de as TERMINAL_RUN_STATUSES, T as claimGraceMs, E as makeAdvisoryLockCoordinator, A as peerRunIsAlive, S as singleCoordinator, j as startScheduler };
@@ -1,4 +1,4 @@
1
- //#region src/schemaRegistry.ts
1
+ // src/schemaRegistry.ts
2
2
  var e = "voltro/audit", t = "voltro/softDelete", n = "voltro/expires", r = "voltro/tenant", i = "voltro/localFirst", a = (e) => {
3
3
  let t = /* @__PURE__ */ new Map();
4
4
  for (let n of e) {
@@ -61,5 +61,4 @@ var e = "voltro/audit", t = "voltro/softDelete", n = "voltro/expires", r = "volt
61
61
  validatePatchSchema: (e) => t.get(e)?.validatePatchSchema
62
62
  };
63
63
  }, o = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), c = [], l = /* @__PURE__ */ new Set(), u = /* @__PURE__ */ new Set(), d = a([]);
64
- //#endregion
65
64
  export { e as VOLTRO_AUDIT_MIXIN_ID, n as VOLTRO_EXPIRES_MIXIN_ID, i as VOLTRO_LOCAL_FIRST_MIXIN_ID, t as VOLTRO_SOFT_DELETE_MIXIN_ID, r as VOLTRO_TENANT_MIXIN_ID, d as emptySchemaRegistry, a as makeSchemaRegistry };
@@ -1,4 +1,4 @@
1
- //#region src/secretsResolver.ts
1
+ // src/secretsResolver.ts
2
2
  var e = { get: (e) => Promise.resolve(process.env[e]) }, t = e, n = (e) => {
3
3
  t = e;
4
4
  }, r = () => {
@@ -31,5 +31,4 @@ var e = { get: (e) => Promise.resolve(process.env[e]) }, t = e, n = (e) => {
31
31
  return typeof t == "string" ? t : void 0;
32
32
  } };
33
33
  }, c = (t) => t === void 0 || t === "env" || typeof t == "object" && t.kind === "env" ? e : t.kind === "custom" ? t.backend : t.kind === "http" ? s(t) : e;
34
- //#endregion
35
34
  export { o as cachedBackend, e as envSecretsBackend, s as httpSecretsBackend, r as resetSecretsBackend, i as resolveSecret, a as resolveSecretSync, c as resolveSecretsBackend, n as setSecretsBackend };
@@ -1,4 +1,4 @@
1
- //#region src/securityHeaders.ts
1
+ // src/securityHeaders.ts
2
2
  var e = "default-src 'none'; frame-ancestors 'none'; base-uri 'none'; form-action 'none'", t = "frame-ancestors 'none'; base-uri 'none'; object-src 'none'", n = "max-age=15552000; includeSubDomains", r = /* @__PURE__ */ new Set(["no-referrer"]), i = (e) => {
3
3
  if (e === !1) return !0;
4
4
  let t = e.split(",").map((e) => e.trim().toLowerCase()).filter((e) => e !== ""), n = t[t.length - 1];
@@ -29,5 +29,4 @@ var e = "default-src 'none'; frame-ancestors 'none'; base-uri 'none'; form-actio
29
29
  for (let [t, n] of Object.entries(e.extra)) r[t.toLowerCase()] = n;
30
30
  return r;
31
31
  };
32
- //#endregion
33
32
  export { e as API_CSP, n as DEFAULT_HSTS, t as HTML_CSP, r as ORIGIN_NULLING_REFERRER_POLICIES, i as preservesSameOriginHeader, s as resolveSecurityHeaders, c as securityHeadersFor };