@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
@@ -2,7 +2,7 @@ import { NO_ROW_FILTER as e } from "./rowFilter.js";
2
2
  import { Schema as t } from "effect";
3
3
  import { and as n, contains as r, eq as i, getTable as a, gt as o, gte as s, inSet as c, isNull as l, lt as u, lte as d, neq as f, queryFor as p, startsWith as m } from "@voltro/database";
4
4
  import { NoRowFound as h, NoRowFound as g } from "@voltro/protocol";
5
- //#region src/storeQuery.ts
5
+ // src/storeQuery.ts
6
6
  var _ = (e, t) => t === void 0 ? new h(e) : t(e), v = class extends t.TaggedError()("OptimisticLockError", {
7
7
  table: t.String,
8
8
  expected: t.Number
@@ -200,5 +200,4 @@ var _ = (e, t) => t === void 0 ? new h(e) : t(e), v = class extends t.TaggedErro
200
200
  updateWhere: (n) => new C(e, t, n),
201
201
  deleteWhere: (n) => new w(e, t, n)
202
202
  });
203
- //#endregion
204
203
  export { w as DeleteBuilder, g as NoRowFound, v as OptimisticLockError, S as SelectBuilder, C as UpdateBuilder, T as makeFluentStore, _ as missingRowError };
package/dist/storeRead.js CHANGED
@@ -1,4 +1,4 @@
1
- //#region src/storeRead.ts
1
+ // src/storeRead.ts
2
2
  var e = async (e, t) => {
3
3
  let n = "descriptor" in t ? t.descriptor : t;
4
4
  return (await e.query({
@@ -6,5 +6,4 @@ var e = async (e, t) => {
6
6
  take: 1
7
7
  }))[0] ?? null;
8
8
  };
9
- //#endregion
10
9
  export { e as readMaybeOne };
@@ -1,7 +1,7 @@
1
- //#region src/subscriber.ts
1
+ // src/subscriber.ts
2
2
  var e = (e) => {
3
+ if (e.eventTenant !== void 0 && typeof e.eventTenant != "function") throw Error("defineSubscriber: `eventTenant` must be a function");
3
4
  if (e.once !== void 0 && e.eachReplica === !0) throw Error("defineSubscriber: choose either `once` or `eachReplica: true`, not both");
4
5
  return e;
5
6
  };
6
- //#endregion
7
7
  export { e as defineSubscriber };
@@ -3,7 +3,7 @@ import { createRowStateByteEstimator as a } from "./rowStateBytes.js";
3
3
  import { MutableList as o } from "effect";
4
4
  import { createRowPatchApplier as s, diffRows as c, isIdKeyed as l } from "@voltro/protocol";
5
5
  import { createLogger as u } from "@voltro/logger";
6
- //#region src/subscriptionOutbox.ts
6
+ // src/subscriptionOutbox.ts
7
7
  var d = u({ scope: "voltro:subscription" }), f = 1048576, p = 1e4, m = 262144, h = 5e3, g = Symbol.for("@voltro/runtime/reactiveSocketTunables"), _ = (e) => {
8
8
  let t = globalThis;
9
9
  t[g] = e;
@@ -135,5 +135,4 @@ var d = u({ scope: "voltro:subscription" }), f = 1048576, p = 1e4, m = 262144, h
135
135
  }
136
136
  }
137
137
  };
138
- //#endregion
139
138
  export { f as DEFAULT_SOCKET_MAX_BUFFERED_BYTES, p as DEFAULT_SOCKET_OVERRUN_AFTER_MS, m as DEFAULT_SOCKET_OVERSIZED_EVENT_BYTES, h as DEFAULT_SOCKET_STALL_WARN_AFTER_MS, b as makeSubscriptionOutbox, x as pumpOutbox, v as reactiveSocketTunables, _ as setReactiveSocketTunables };
@@ -1,5 +1,5 @@
1
1
  import { fingerprintFor as e } from "./fingerprint.js";
2
- //#region src/subscriptionRegistry.ts
2
+ // src/subscriptionRegistry.ts
3
3
  var t = class {
4
4
  matcher;
5
5
  byFingerprint = /* @__PURE__ */ new Map();
@@ -78,5 +78,4 @@ var t = class {
78
78
  return e;
79
79
  }
80
80
  };
81
- //#endregion
82
81
  export { t as SubscriptionRegistry };
@@ -1,5 +1,5 @@
1
1
  import { BoundedRing as e } from "@voltro/protocol";
2
- //#region src/subscriptionResume.ts
2
+ // src/subscriptionResume.ts
3
3
  var t = 6e4, n = 256, r = Symbol.for("@voltro/runtime:resume-tunables"), i = (e) => {
4
4
  let t = globalThis;
5
5
  t[r] = e;
@@ -128,5 +128,4 @@ var t = 6e4, n = 256, r = Symbol.for("@voltro/runtime:resume-tunables"), i = (e)
128
128
  for (let e of b().values()) clearTimeout(e.timer), e.unsubscribe();
129
129
  b().clear();
130
130
  };
131
- //#endregion
132
131
  export { n as DEFAULT_RESUME_MAX_DELTAS, t as DEFAULT_RESUME_WINDOW_MS, S as adoptDetached, _ as answerResume, s as canonicalInputKey, x as detachForResume, g as recordForResume, C as resetDetachedForTest, v as resetResumeRingsForTest, o as resumeKeyOf, a as resumeTunables, i as setResumeTunables };
@@ -1,4 +1,4 @@
1
- //#region src/subscriptionSocketMetrics.ts
1
+ // src/subscriptionSocketMetrics.ts
2
2
  var e = Symbol.for("@voltro/runtime/subscriptionSocketMetrics"), t = () => {
3
3
  let t = globalThis;
4
4
  return t[e] ??= {
@@ -61,5 +61,4 @@ var e = Symbol.for("@voltro/runtime/subscriptionSocketMetrics"), t = () => {
61
61
  let e = t();
62
62
  e.bufferOwners = /* @__PURE__ */ new WeakMap(), e.bufferedBytes.clear(), e.coalescedTotal.clear(), e.overrunTotal.clear(), e.oversizedTotal.clear(), e.stalledTotal.clear();
63
63
  };
64
- //#endregion
65
64
  export { i as createSubscriptionBufferMetric, a as recordCoalesced, o as recordOverrun, s as recordOversized, c as recordStalled, f as resetSubscriptionSocketMetrics, r as setBufferedBytes, d as subscriptionSocketMetricSamples, u as subscriptionSocketMetricsSnapshot };
@@ -1,5 +1,4 @@
1
1
  import { systemSubject as e } from "@voltro/protocol";
2
- //#region src/systemSubject.ts
2
+ // src/systemSubject.ts
3
3
  var t = e("system");
4
- //#endregion
5
4
  export { t as SYSTEM_SUBJECT };
@@ -1,23 +1,10 @@
1
- import { and as e, eq as t, isNull as n } from "@voltro/database";
2
- //#region src/tenantScope.ts
3
- var r = (n, r, i) => {
4
- if (n.crossTenant || !r.has(n.table) || i == null) return n;
5
- let a = t("tenantId", i);
6
- return {
7
- ...n,
8
- predicate: n.predicate ? e(n.predicate, a) : a
9
- };
10
- }, i = (e, t, n) => n === "" && !e.crossTenant && t.has(e.table), a = (e) => e?.type === "user" && e.tenantId === "", o = (t, r) => {
11
- if (t.includeDeleted || !r.has(t.table)) return t;
12
- let i = n("deletedAt");
13
- return {
14
- ...t,
15
- predicate: t.predicate ? e(t.predicate, i) : i
16
- };
17
- }, s = (e) => (t, n) => {
18
- e.observe?.beforeScope?.({ ...t }, n);
19
- let i = o(r(t, e.tenantScopedTables, n.tenantId), e.softDeleteScopedTables);
20
- return e.observe?.afterScope?.({ ...i }), i;
1
+ import { mapSetReadScopes as e } from "./setReadScopes.js";
2
+ import { addReadScopePredicate as t } from "./readScopePredicate.js";
3
+ import { eq as n, gt as r, isNull as i, or as a } from "@voltro/database";
4
+ // src/tenantScope.ts
5
+ var o = (r, i, a) => e(r, (e) => e.crossTenant || !i.has(e.table) || a == null ? e : t(e, (e) => n(e("tenantId"), a))), s = (e, t, n) => n === "" && !e.crossTenant && t.has(e.table), c = (e) => e?.type === "user" && e.tenantId === "", l = (n, r) => e(n, (e) => e.includeDeleted || !r.has(e.table) ? e : t(e, (e) => i(e("deletedAt")))), u = (n) => (s, c) => {
6
+ n.observe?.beforeScope?.({ ...s }, c);
7
+ let u = l(o(s, n.tenantScopedTables, c.tenantId), n.softDeleteScopedTables), d = /* @__PURE__ */ new Date(), f = n.expiresScopedTables, p = f === void 0 ? u : e(u, (e) => e.includeExpired || !f.has(e.table) ? e : t(e, (e) => a(i(e("expiresAt")), r(e("expiresAt"), d))));
8
+ return n.observe?.afterScope?.({ ...p }), p;
21
9
  };
22
- //#endregion
23
- export { o as applySoftDeleteScope, r as applyTenantScope, i as isEmptyTenantScopedRead, a as isOrglessUserSubject, s as makeQueryFinalizer };
10
+ export { l as applySoftDeleteScope, o as applyTenantScope, s as isEmptyTenantScopedRead, c as isOrglessUserSubject, u as makeQueryFinalizer };
@@ -1,6 +1,6 @@
1
1
  import { TENANT_SELECTIONS_TABLE as e, deleteTenantSelection as t, readTenantSelection as n, tenantSelectionId as r, writeTenantSelection as i } from "@voltro/database";
2
2
  import { isTenantSelectable as a, selectSubjectTenant as o } from "@voltro/protocol";
3
- //#region src/tenantSelection.ts
3
+ // src/tenantSelection.ts
4
4
  var s = (e) => {
5
5
  let r = () => {
6
6
  let t = e();
@@ -23,5 +23,4 @@ var s = (e) => {
23
23
  id: n.id
24
24
  });
25
25
  };
26
- //#endregion
27
26
  export { e as TENANT_SELECTIONS_TABLE, l as clearTenantSelection, c as selectTenant, r as tenantSelectionId, s as tenantSelectionStore };
package/dist/timeline.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { randomUUID as e } from "node:crypto";
2
2
  import { BoundedRing as t } from "@voltro/protocol";
3
- //#region src/timeline.ts
3
+ // src/timeline.ts
4
4
  var n = (e = process.env) => {
5
5
  let t = (e.VOLTRO_TIMELINE ?? "").toLowerCase();
6
6
  return t === "off" || t === "0" || t === "false" ? "off" : t === "all" ? "all" : t === "interesting" || t === "on" || t === "1" || t === "true" ? "interesting" : e.NODE_ENV === "production" ? "off" : "interesting";
@@ -101,5 +101,4 @@ var n = (e = process.env) => {
101
101
  t.invalidate();
102
102
  }
103
103
  };
104
- //#endregion
105
104
  export { u as TimelineRecorder, f as getTimelineRecorder, m as recordTimelineEvent, a as redactRow, n as resolveTimelineMode, c as reverseEventOverRows, p as setTimelineRecorderForTest };
@@ -1,5 +1,4 @@
1
1
  import { AsyncLocalStorage as e } from "node:async_hooks";
2
- //#region src/traceContext.ts
2
+ // src/traceContext.ts
3
3
  var t = new e(), n = (e, n) => t.run(e, n), r = () => t.getStore();
4
- //#endregion
5
4
  export { r as currentTraceContext, n as runWithTraceContext };
package/dist/traceSink.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { SpanKind as e, SpanStatusCode as t } from "@opentelemetry/api";
2
- //#region src/traceSink.ts
2
+ // src/traceSink.ts
3
3
  var n = {
4
4
  [e.INTERNAL]: "internal",
5
5
  [e.SERVER]: "server",
@@ -59,5 +59,4 @@ var n = {
59
59
  forceFlush: () => Promise.resolve(),
60
60
  shutdown: () => Promise.resolve()
61
61
  });
62
- //#endregion
63
62
  export { l as makeBufferingSpanProcessor };
@@ -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/traceSpansTable.ts
2
+ // src/traceSpansTable.ts
3
3
  var o = r("_voltro_traces", {
4
4
  id: e({ prefix: "span" }),
5
5
  traceId: i(),
@@ -25,5 +25,4 @@ var o = r("_voltro_traces", {
25
25
  attributes: n().nullable(),
26
26
  events: n().nullable()
27
27
  }).index(["traceId", "startedAt"]).index(["startedAt"]).index(["status"]);
28
- //#endregion
29
28
  export { o as _voltroTracesTable };
@@ -1,34 +1,22 @@
1
1
  import { Tracer as e } from "effect";
2
- //#region src/traceparent.ts
3
- var t = /^00-([0-9a-f]{32})-([0-9a-f]{16})-([0-9a-f]{2})$/, n = (e) => `00-${e.traceId}-${e.spanId}-${e.sampled ? "01" : "00"}`, r = (e) => {
2
+ import { newTraceId as t } from "@voltro/shared";
3
+ // src/traceparent.ts
4
+ var n = /^00-([0-9a-f]{32})-([0-9a-f]{16})-([0-9a-f]{2})$/, r = (e) => `00-${e.traceId}-${e.spanId}-${e.sampled ? "01" : "00"}`, i = (e) => {
4
5
  if (typeof e != "string") return null;
5
- let n = t.exec(e.trim().toLowerCase());
6
- if (n === null) return null;
7
- let [, r, i, a] = n;
6
+ let t = n.exec(e.trim().toLowerCase());
7
+ if (t === null) return null;
8
+ let [, r, i, a] = t;
8
9
  return r === "0".repeat(32) || i === "0".repeat(16) ? null : {
9
10
  traceId: r,
10
11
  spanId: i,
11
12
  sampled: (parseInt(a, 16) & 1) == 1
12
13
  };
13
- }, i = (t) => {
14
- let n = r(t);
14
+ }, a = (t) => {
15
+ let n = i(t);
15
16
  if (n !== null) return e.externalSpan({
16
17
  traceId: n.traceId,
17
18
  spanId: n.spanId,
18
19
  sampled: n.sampled
19
20
  });
20
- }, a = () => {
21
- let e = globalThis.crypto, t = /* @__PURE__ */ new Uint8Array(16);
22
- if (e?.getRandomValues !== void 0) e.getRandomValues(t);
23
- else {
24
- let e = `${Date.now().toString(16)}${Math.random().toString(16).slice(2)}`;
25
- for (let n = 0; n < t.length; n += 1) {
26
- let r = e.slice(n * 2 % e.length, n * 2 % e.length + 2);
27
- t[n] = (parseInt(r, 16) || n + 1) ^ (Math.random() * 256 | 0);
28
- }
29
- }
30
- let n = Array.from(t, (e) => e.toString(16).padStart(2, "0")).join("");
31
- return n === "0".repeat(32) ? `${"0".repeat(31)}1` : n;
32
21
  };
33
- //#endregion
34
- export { i as externalSpanFromTraceparent, n as formatTraceparent, a as newTraceId, r as parseTraceparent };
22
+ export { a as externalSpanFromTraceparent, r as formatTraceparent, t as newTraceId, i as parseTraceparent };
@@ -1,5 +1,5 @@
1
1
  import { isMachineSubject as e, tenantScopedSubject as t } from "@voltro/protocol";
2
- //#region src/transactionSubject.ts
2
+ // src/transactionSubject.ts
3
3
  var n = (n, r, i) => {
4
4
  if (r === void 0) return n;
5
5
  if (r.trim() === "") throw Error("transaction tenantId must be non-empty");
@@ -8,5 +8,4 @@ var n = (n, r, i) => {
8
8
  if (!e(n)) throw Error("only a system context — the framework itself, or another app calling a `service:` procedure — can select another transaction tenant");
9
9
  return t(n, r);
10
10
  };
11
- //#endregion
12
11
  export { n as resolveTransactionSubject };
@@ -1,5 +1,5 @@
1
- import { bootRefusal as e } from "./bootRefusal.js";
2
- //#region src/trustedProxy.ts
1
+ import { bootRefusal as e } from "./boot-refusal.js";
2
+ // src/trustedProxy.ts
3
3
  var t = {
4
4
  entries: [],
5
5
  trustAll: !1
@@ -151,5 +151,4 @@ var t = {
151
151
  let t = e.xForwardedProto;
152
152
  return t === void 0 || t.trim() === "" || !(e.config.trustAll || e.config.hops !== void 0 || l(e.socketAddress, e.config)) ? !1 : t.split(",")[0].trim().toLowerCase() === "https";
153
153
  };
154
- //#endregion
155
154
  export { t as NO_TRUSTED_PROXIES, a as ipToBytes, l as isTrustedProxy, n as normalizeIp, f as resolveClientAddress, m as resolveRequestClientAddress, h as resolveRequestIsHttps, u as resolveTrustedProxies };
package/dist/undo.js CHANGED
@@ -1,4 +1,4 @@
1
- //#region src/undo.ts
1
+ // src/undo.ts
2
2
  var e = (e) => {
3
3
  if (e.id !== void 0) return e.id;
4
4
  let t = e.next?.id;
@@ -125,5 +125,4 @@ var e = (e) => {
125
125
  }, c = async (e, t) => {
126
126
  for (let n of t) await s(e, n);
127
127
  };
128
- //#endregion
129
128
  export { r as UndoBoundaryError, a as UndoStack, s as applyInverse, c as applyInverses, o as forwardChangeFromCdc, t as invertChange, i as isSafeToApply, n as synthesizeInverse };
@@ -1,7 +1,7 @@
1
1
  import { applyInverses as e, isSafeToApply as t, synthesizeInverse as n } from "./undo.js";
2
2
  import { eq as r } from "@voltro/database";
3
3
  import { UndoConflict as i, UndoForbidden as a, UndoNotFound as o } from "@voltro/protocol";
4
- //#region src/undoBuiltins.ts
4
+ // src/undoBuiltins.ts
5
5
  var s = (e) => e.request?.subject?.id ?? null, c = (e) => e === !0 || e === 1, l = async (e, t, n) => (await e.query({
6
6
  table: t,
7
7
  predicate: r("id", n),
@@ -65,5 +65,4 @@ var s = (e) => e.request?.subject?.id ?? null, c = (e) => e === !0 || e === 1, l
65
65
  }
66
66
  return await t.store.update("_voltro_undo_log", e.invocationId, { undone: !1 }), { ok: !0 };
67
67
  };
68
- //#endregion
69
68
  export { m as applyUndoInvocation, h as redoUndoInvocation, f as undoLogExecutor };
@@ -1,5 +1,5 @@
1
1
  import { eq as e } from "@voltro/database";
2
- //#region src/undoCapture.ts
2
+ // src/undoCapture.ts
3
3
  var t = (e = process.env) => {
4
4
  let t = (e.VOLTRO_UNDO ?? "").toLowerCase();
5
5
  return t === "on" || t === "1" || t === "true" ? !0 : t === "off" || t === "0" || t === "false" ? !1 : e.NODE_ENV !== "production";
@@ -70,5 +70,4 @@ var t = (e = process.env) => {
70
70
  }
71
71
  };
72
72
  };
73
- //#endregion
74
73
  export { o as makeUndoCapture, t as undoCaptureEnabled, n as undoSurfaceEnabled, a as wrapCaptureStore };
@@ -1,5 +1,5 @@
1
1
  import { boolean as e, id as t, table as n, text as r, timestamp as i } from "@voltro/database";
2
- //#region src/undoLogTable.ts
2
+ // src/undoLogTable.ts
3
3
  var a = n("_voltro_undo_log", {
4
4
  id: t({ prefix: "undo" }),
5
5
  tag: r(),
@@ -12,5 +12,4 @@ var a = n("_voltro_undo_log", {
12
12
  undone: e().default(!1),
13
13
  createdAt: i().default("now")
14
14
  }).index(["subjectId", "createdAt"]);
15
- //#endregion
16
15
  export { a as _voltroUndoLogTable };
@@ -1,5 +1,5 @@
1
1
  import { and as e, eq as t } from "@voltro/database";
2
- //#region src/upsertBinding.ts
2
+ // src/upsertBinding.ts
3
3
  var n = "id", r = async (r, i, a, o) => {
4
4
  let s = o.map((e) => t(e, a[e]));
5
5
  if (s.length === 0) return;
@@ -16,5 +16,4 @@ var n = "id", r = async (r, i, a, o) => {
16
16
  let o = await r(e, t, i, a);
17
17
  return o === void 0 ? i[n] : o;
18
18
  };
19
- //#endregion
20
19
  export { r as upsertConflictId, i as upsertDestinationId };
@@ -1,5 +1,5 @@
1
1
  import { dueWakeups as e, releaseWakeup as t, tryClaimWakeup as n } from "./wakeRegistry.js";
2
- //#region src/wakeOrchestrator.ts
2
+ // src/wakeOrchestrator.ts
3
3
  var r = async (r) => {
4
4
  let i = r.now?.() ?? /* @__PURE__ */ new Date(), a = await e(r.store, i, r.batchLimit ?? 100);
5
5
  if (a.length === 0) return 0;
@@ -30,5 +30,4 @@ var r = async (r) => {
30
30
  n = !0, i !== void 0 && clearTimeout(i);
31
31
  } };
32
32
  };
33
- //#endregion
34
33
  export { i as runWakeLoop, r as wakeDueOnce };
@@ -1,4 +1,4 @@
1
- //#region src/wakeRegistry.ts
1
+ // src/wakeRegistry.ts
2
2
  var e = "_voltro_wakeups", t = (e) => `${e.tenantId}:${e.kind}:${e.refId}`, n = (e) => ({
3
3
  tenantId: String(e.tenantId),
4
4
  kind: String(e.kind),
@@ -67,5 +67,4 @@ var e = "_voltro_wakeups", t = (e) => `${e.tenantId}:${e.kind}:${e.refId}`, n =
67
67
  for (let n of i) a !== void 0 && (n.wakeAt instanceof Date ? n.wakeAt : new Date(String(n.wakeAt))).getTime() >= a || await t.delete(e, String(n.id)) && o++;
68
68
  return o;
69
69
  };
70
- //#endregion
71
70
  export { i as cancelWakeup, d as dueWakeups, a as markWakeupFired, f as nextWakeup, m as pruneWakeups, r as registerWakeup, c as releaseWakeup, s as tryClaimWakeup };
@@ -1,5 +1,5 @@
1
1
  import * as e from "node:http";
2
- //#region src/wakeRouter.ts
2
+ // src/wakeRouter.ts
3
3
  var t = () => {
4
4
  let e = 0, t = 0;
5
5
  return {
@@ -59,5 +59,4 @@ var t = () => {
59
59
  });
60
60
  }), s;
61
61
  };
62
- //#endregion
63
62
  export { t as makeRouterActivity, n as makeWakeGate, a as makeWakeProxyServer };
@@ -1,5 +1,5 @@
1
1
  import { spawn as e } from "node:child_process";
2
- //#region src/wakeSupervisor.ts
2
+ // src/wakeSupervisor.ts
3
3
  var t = (e) => ({ wake: async () => {
4
4
  await e.start();
5
5
  } }), n = (e) => new Promise((t) => setTimeout(t, e)), r = (t) => {
@@ -58,5 +58,4 @@ var t = (e) => ({ wake: async () => {
58
58
  stop: g
59
59
  };
60
60
  };
61
- //#endregion
62
61
  export { t as makeProcessAdapter, r as nodeProcessSupervisor };
@@ -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/wakeupsTable.ts
2
+ // src/wakeupsTable.ts
3
3
  var i = t("_voltro_wakeups", {
4
4
  id: e({ prefix: "wakeup" }),
5
5
  tenantId: n(),
@@ -8,5 +8,4 @@ var i = t("_voltro_wakeups", {
8
8
  wakeAt: r(),
9
9
  status: n()
10
10
  }).index(["status", "wakeAt"]).index(["tenantId"]);
11
- //#endregion
12
11
  export { i as _voltroWakeupsTable };