@voltro/cli 0.23.0 → 0.24.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 (64) hide show
  1. package/CHANGELOG.md +111 -0
  2. package/bin/voltro.mjs +39 -4
  3. package/dist/{apiBuild-JQtIhZPy.js → apiBuild-B2m4XK_8.js} +44 -22
  4. package/dist/apiBuild-UEM3QBke.js +2 -0
  5. package/dist/bin.js +2 -2
  6. package/dist/{commands-Bsu9Buln.js → commands-CaIhTsC2.js} +2565 -2444
  7. package/dist/{dbCommand-GI7-BVZt.js → dbCommand-CC61CsAc.js} +248 -218
  8. package/dist/dbCommand-Cr__4ATv.js +2 -0
  9. package/dist/{dev-DRxF_qOB.js → dev-DPkQVUTP.js} +1 -1
  10. package/dist/{dev-jM07kq_D.js → dev-NCuEhNxs.js} +1039 -1021
  11. package/dist/index.js +1 -1
  12. package/dist/{serveCommand-Cl8sicD5.js → serveCommand-C4gzDZzc.js} +349 -336
  13. package/dist/serveEntry.js +1 -1
  14. package/package.json +17 -17
  15. package/templates/agent-docs/authentication.md +21 -0
  16. package/templates/agent-docs/cli.md +17 -0
  17. package/templates/agent-docs/data.md +185 -165
  18. package/templates/agent-docs/database/migrations.md +92 -63
  19. package/templates/agent-docs/database/seedsdialects.md +12 -0
  20. package/templates/agent-docs/deployment.md +66 -1
  21. package/templates/agent-docs/workflows.md +30 -0
  22. package/templates/apps/api-ai/package.json +8 -7
  23. package/templates/apps/api-auth/package.json +9 -8
  24. package/templates/apps/api-backend/package.json +8 -7
  25. package/templates/apps/api-backend-deactivation/package.json +8 -7
  26. package/templates/apps/api-backend-mail/package.json +9 -8
  27. package/templates/apps/api-backend-mariadb/package.json +10 -9
  28. package/templates/apps/api-backend-storage/package.json +9 -8
  29. package/templates/apps/api-data-advanced/package.json +9 -8
  30. package/templates/apps/api-durable/package.json +9 -8
  31. package/templates/apps/api-feature-flags/package.json +10 -9
  32. package/templates/apps/api-governance/package.json +9 -8
  33. package/templates/apps/api-kv/package.json +9 -8
  34. package/templates/apps/api-moderation/package.json +9 -8
  35. package/templates/apps/api-observability/package.json +9 -8
  36. package/templates/apps/api-ratelimit/package.json +9 -8
  37. package/templates/apps/api-rbac/package.json +9 -8
  38. package/templates/apps/api-rest/package.json +8 -7
  39. package/templates/apps/api-saas/package.json +12 -11
  40. package/templates/apps/api-search/package.json +9 -8
  41. package/templates/apps/api-versioning/package.json +9 -8
  42. package/templates/apps/api-webhooks/package.json +10 -9
  43. package/templates/apps/changelog/package.json +7 -6
  44. package/templates/apps/edge-functions/package.json +3 -2
  45. package/templates/apps/frontend-admin/package.json +9 -8
  46. package/templates/apps/frontend-app/package.json +9 -8
  47. package/templates/apps/frontend-blank/package.json +8 -7
  48. package/templates/apps/frontend-contact/package.json +8 -7
  49. package/templates/apps/frontend-contact/src/globals.d.ts +6 -0
  50. package/templates/apps/frontend-dashboard/package.json +8 -7
  51. package/templates/apps/frontend-docs/package.json +8 -7
  52. package/templates/apps/frontend-docs/src/globals.d.ts +6 -0
  53. package/templates/apps/frontend-i18n/package.json +7 -6
  54. package/templates/apps/frontend-landing/package.json +8 -7
  55. package/templates/apps/frontend-landing/src/globals.d.ts +6 -0
  56. package/templates/apps/frontend-spa/package.json +8 -7
  57. package/templates/apps/frontend-spa/src/globals.d.ts +6 -0
  58. package/templates/apps/frontend-ssr/package.json +8 -7
  59. package/templates/apps/frontend-ssr/src/globals.d.ts +6 -0
  60. package/templates/apps/frontend-ssr-api/package.json +9 -8
  61. package/templates/apps/frontend-static-blog/package.json +7 -6
  62. package/templates/apps/frontend-static-blog/src/globals.d.ts +6 -0
  63. package/dist/apiBuild-CD-4JLLA.js +0 -2
  64. package/dist/dbCommand-CSguuUQn.js +0 -2
@@ -4,8 +4,8 @@ import { r, t as i } from "./appModuleLoader-C9r9mxZt.js";
4
4
  import { f as a, m as o, n as s, p as c, u as l } from "./frameworkTableAssembly-sg41s14F.js";
5
5
  import { l as u } from "./fileConventions-CBNPZVOV.js";
6
6
  import { p as d } from "./inspect-_ldwsAwH.js";
7
- import { $ as ee, A as f, B as p, C as te, D as m, E as ne, F as re, G as ie, H as ae, I as h, K as oe, L as g, M as _, N as se, O as v, P as y, R as ce, S as le, T as ue, V as de, W as fe, _ as b, at as pe, b as me, c as he, et as ge, h as _e, i as x, it as S, j as ve, k as ye, lt as be, m as C, nt as w, o as T, ot as xe, q as Se, r as Ce, rt as we, st as E, t as Te, tt as Ee, u as De, ut as Oe, v as ke, w as Ae, x as D, y as je, z as Me } from "./dev-jM07kq_D.js";
8
- import { l as O, r as k } from "./apiBuild-JQtIhZPy.js";
7
+ import { A as f, B as p, C as ee, D as m, E as te, F as ne, G as re, H as h, I as g, J as ie, K as ae, L as _, M as oe, N as v, O as y, P as b, R as se, S as ce, T as le, U as ue, V as de, at as x, b as fe, c as pe, ct as me, dt as he, et as S, g as ge, h as C, i as _e, it as ve, j as ye, k as w, nt as T, o as E, ot as be, q as xe, r as Se, rt as D, st as Ce, t as we, tt as Te, u as Ee, ut as De, v as Oe, w as ke, x as Ae, y as je, z as O } from "./dev-NCuEhNxs.js";
8
+ import { r as Me, u as k } from "./apiBuild-B2m4XK_8.js";
9
9
  import { t as A } from "./bootTiming-BdyP9nYw.js";
10
10
  import { n as Ne } from "./cliArgs-qdZSElM3.js";
11
11
  import { join as Pe } from "node:path";
@@ -13,42 +13,42 @@ import { pathToFileURL as Fe } from "node:url";
13
13
  import { Cause as Ie, Effect as j, Layer as M, ManagedRuntime as Le } from "effect";
14
14
  import { createLogger as N } from "@voltro/logger";
15
15
  import { existsSync as Re } from "node:fs";
16
- import { AggregateRegistry as P, Dispatcher as ze, apiKeyManagementRoutes as Be, applySoftDeleteScope as Ve, applyTenantScope as He, attachAnalyticsMirror as Ue, awaitServerListening as We, bindMutation as F, bindStream as Ge, bindSubscription as I, buildTracingLayer as Ke, cancelWakeup as qe, compileCron as L, dataStoreApiKeyStore as Je, dataStoreIdempotencyStore as Ye, formatServerOnlyLeaks as Xe, frameworkApiKeyStrategy as Ze, installPolicyGuardResolver as Qe, loadResourceTuples as $e, makeActionRunner as R, makeAdvisoryLockCoordinator as et, makeApiKeyService as tt, makeApiKeyUsageBuffer as nt, makeApiKeyUsageFlusher as rt, makeAsyncKv as it, makeCoordinatedScheduler as at, makeEffectStoreLayer as ot, makeLazyWorkflowFacade as st, makeMutationRunner as ct, makeOneShotQueryRunner as lt, makeQueryDescriptorProducer as ut, makeQueryReauthorizer as dt, makeQuerySubscriber as ft, makeSchemaRegistry as pt, makeWorkflowFacade as mt, makeWorkflowFacadeWithCallerContext as ht, makeWorkflowLayers as gt, noopKv as z, onProcessShutdown as _t, recordSubscriptionDelivery as vt, registerWakeup as yt, resolveSecretsBackend as bt, runProvidedEffect as xt, setSecretsBackend as St, setSystemStoreHandle as Ct, setTupleSource as wt, singleCoordinator as Tt, startRpcServer as Et, startScheduler as Dt, workflowToRpc as B, wrapStoreWithBootCodec as Ot } from "@voltro/runtime";
16
+ import { AggregateRegistry as P, Dispatcher as ze, apiKeyManagementRoutes as Be, applySoftDeleteScope as Ve, applyTenantScope as He, attachAnalyticsMirror as Ue, awaitServerListening as We, bindMutation as F, bindStream as Ge, bindSubscription as I, buildTracingLayer as Ke, cancelWakeup as qe, compileCron as L, dataStoreApiKeyStore as Je, dataStoreIdempotencyStore as Ye, formatServerOnlyLeaks as Xe, frameworkApiKeyStrategy as Ze, installPolicyGuardResolver as Qe, loadResourceTuples as $e, makeActionRunner as R, makeAdvisoryLockCoordinator as et, makeApiKeyService as tt, makeApiKeyUsageBuffer as nt, makeApiKeyUsageFlusher as rt, makeAsyncKv as it, makeCoordinatedScheduler as at, makeEffectStoreLayer as ot, makeLazyWorkflowFacade as st, makeMutationOutputCodec as ct, makeMutationRunner as lt, makeOneShotQueryRunner as ut, makeQueryDescriptorProducer as dt, makeQueryReauthorizer as ft, makeQuerySubscriber as pt, makeSchemaRegistry as mt, makeWorkflowFacade as ht, makeWorkflowFacadeWithCallerContext as gt, makeWorkflowLayers as z, noopKv as _t, onProcessShutdown as vt, recordSubscriptionDelivery as yt, registerWakeup as bt, resolveSecretsBackend as xt, runProvidedEffect as St, setSecretsBackend as Ct, setSystemStoreHandle as wt, setTupleSource as Tt, singleCoordinator as Et, startRpcServer as Dt, startScheduler as B, workflowToRpc as V, wrapStoreWithBootCodec as Ot } from "@voltro/runtime";
17
17
  import { RpcGroup as kt } from "@effect/rpc";
18
18
  import { SqlClient as At } from "@effect/sql";
19
- import { and as jt, ensureTableRegistered as Mt, eq as V, or as Nt } from "@voltro/database";
20
- import { appStorageProvider as H, fromNodeReadable as Pt, getObjectStream as Ft, putObjectStream as It, toNodeReadable as U } from "@voltro/plugin-storage";
21
- import { AuthMiddleware as Lt, ConnectionInfoMiddleware as W, actionToRpc as G, anonymousSubject as Rt, isWireReachable as zt, mutationToRpc as Bt, queryToRpc as K, streamToRpc as Vt, workflowCancelDescriptor as Ht, workflowDomainEventsQueryDescriptor as q, workflowEventDeliveriesQueryDescriptor as Ut, workflowResumeDescriptor as J, workflowRunEventsQueryDescriptor as Y, workflowRunQueryDescriptor as X, workflowRunStepsQueryDescriptor as Wt, workflowRunsQueryDescriptor as Z, workflowSignalDescriptor as Gt, workflowUpdateDescriptor as Kt } from "@voltro/protocol";
22
- import { assertProductionSessionSecret as qt } from "@voltro/protocol/session";
23
- import { createHash as Jt, timingSafeEqual as Yt } from "node:crypto";
24
- import { declaredSnapshot as Xt, describeOutcome as Zt, runPlannedMigrations as Qt } from "@voltro/database/sql";
25
- import { getAuthSessionStrategy as $t } from "@voltro/plugin-auth";
26
- import { collectPublicApiRoutes as en, restRoutesToHttpRoutes as tn } from "@voltro/protocol/rest";
27
- import { buildDeliverWebhookExecute as nn, buildWebhooksService as rn, defaultIncomingPath as an, deliverWebhookWorkflow as on, mountIncomingWebhook as sn } from "@voltro/plugin-webhooks";
28
- import { packBundle as cn, runExport as ln, runImport as un, storageBlobSink as dn, storageRefsBlobSource as fn, unpackBundle as pn, unpackBundleToDir as mn } from "@voltro/data-transfer";
19
+ import { and as jt, ensureTableRegistered as Mt, eq as H, or as Nt } from "@voltro/database";
20
+ import { appStorageProvider as U, fromNodeReadable as Pt, getObjectStream as Ft, putObjectStream as W, toNodeReadable as It } from "@voltro/plugin-storage";
21
+ import { AuthMiddleware as G, ConnectionInfoMiddleware as Lt, actionToRpc as K, anonymousSubject as Rt, isWireReachable as zt, mutationToRpc as Bt, queryToRpc as q, streamToRpc as Vt, workflowCancelDescriptor as Ht, workflowDomainEventsQueryDescriptor as Ut, workflowEventDeliveriesQueryDescriptor as J, workflowResumeDescriptor as Wt, workflowRunEventsQueryDescriptor as Y, workflowRunQueryDescriptor as Gt, workflowRunStepsQueryDescriptor as X, workflowRunsQueryDescriptor as Z, workflowSignalDescriptor as Kt, workflowUpdateDescriptor as qt } from "@voltro/protocol";
22
+ import { assertProductionSessionSecret as Jt } from "@voltro/protocol/session";
23
+ import { createHash as Yt, timingSafeEqual as Xt } from "node:crypto";
24
+ import { declaredSnapshot as Zt, describeOutcome as Qt, runPlannedMigrations as $t } from "@voltro/database/sql";
25
+ import { getAuthSessionStrategy as en } from "@voltro/plugin-auth";
26
+ import { collectPublicApiRoutes as tn, restRoutesToHttpRoutes as nn } from "@voltro/protocol/rest";
27
+ import { buildDeliverWebhookExecute as rn, buildWebhooksService as an, defaultIncomingPath as on, deliverWebhookWorkflow as sn, mountIncomingWebhook as cn } from "@voltro/plugin-webhooks";
28
+ import { packBundle as ln, runExport as un, runImport as dn, storageBlobSink as fn, storageRefsBlobSource as pn, unpackBundle as mn, unpackBundleToDir as hn } from "@voltro/data-transfer";
29
29
  //#region src/bootRefusal.ts
30
- var hn = "VoltroBootRefusal", gn = (e) => {
30
+ var gn = "VoltroBootRefusal", _n = (e) => {
31
31
  let t = Error(e);
32
- return t.name = hn, t;
33
- }, _n = "/_voltro/admin/import", vn = "/_voltro/admin/export", Q = (e, t) => ({
32
+ return t.name = gn, t;
33
+ }, vn = "/_voltro/admin/import", yn = "/_voltro/admin/export", Q = (e, t) => ({
34
34
  status: e,
35
35
  contentType: "application/json; charset=utf-8",
36
36
  body: JSON.stringify(t)
37
- }), yn = (e) => {
37
+ }), bn = (e) => {
38
38
  let t = e.authorization ?? e.Authorization, n = t ? /^Bearer\s+(.+)$/i.exec(t) : null;
39
39
  return n ? n[1] : null;
40
- }, bn = (e, t) => Yt(Jt("sha256").update(e).digest(), Jt("sha256").update(t).digest()), xn = (e, t) => {
40
+ }, xn = (e, t) => Xt(Yt("sha256").update(e).digest(), Yt("sha256").update(t).digest()), Sn = (e, t) => {
41
41
  if (e.method.toUpperCase() !== "POST") return Q(405, { error: "method not allowed" });
42
42
  if (!t || t.length < 16) return Q(503, { error: "data transfer misconfigured (no/weak secret)" });
43
- let n = yn(e.headers);
44
- return !n || !bn(n, t) ? Q(401, { error: "unauthorized" }) : null;
45
- }, Sn = N({ scope: "voltro:admin-import" }), Cn = "VBUNDLE2", wn = async function* (e) {
43
+ let n = bn(e.headers);
44
+ return !n || !xn(n, t) ? Q(401, { error: "unauthorized" }) : null;
45
+ }, Cn = N({ scope: "voltro:admin-import" }), wn = "VBUNDLE2", Tn = async function* (e) {
46
46
  yield e;
47
- }, Tn = (e) => async (t) => {
48
- let n = xn(t, e.secret);
47
+ }, En = (e) => async (t) => {
48
+ let n = Sn(t, e.secret);
49
49
  if (n) return n;
50
- let r = t.headers["x-import-mode"], i = t.headers["x-import-on-conflict"], a = t.headers["x-import-atomic"] === "1" || t.headers["x-import-atomic"] === "true", o = t.headers["x-import-force"] === "1" || t.headers["x-import-force"] === "true", s = t.rawBody.byteLength >= 8 && Buffer.from(t.rawBody.subarray(0, 8)).toString("latin1") === Cn, c, l;
51
- if (s) c = wn(t.rawBody), l = "upload";
50
+ let r = t.headers["x-import-mode"], i = t.headers["x-import-on-conflict"], a = t.headers["x-import-atomic"] === "1" || t.headers["x-import-atomic"] === "true", o = t.headers["x-import-force"] === "1" || t.headers["x-import-force"] === "true", s = t.rawBody.byteLength >= 8 && Buffer.from(t.rawBody.subarray(0, 8)).toString("latin1") === wn, c, l;
51
+ if (s) c = Tn(t.rawBody), l = "upload";
52
52
  else {
53
53
  let n;
54
54
  try {
@@ -60,28 +60,28 @@ var hn = "VoltroBootRefusal", gn = (e) => {
60
60
  if (!e.openArchive) return Q(501, { error: "storage transport not configured on this instance" });
61
61
  c = e.openArchive(n.bundleKey), l = "storage";
62
62
  }
63
- let u = await import("node:os"), d = await import("node:fs/promises"), ee = await import("node:path"), f = await d.mkdtemp(ee.join(u.tmpdir(), "voltro-admin-import-"));
63
+ let u = await import("node:os"), d = await import("node:fs/promises"), f = await import("node:path"), p = await d.mkdtemp(f.join(u.tmpdir(), "voltro-admin-import-"));
64
64
  try {
65
- e.assetSink ? await pn(c, {
66
- dir: f,
65
+ e.assetSink ? await mn(c, {
66
+ dir: p,
67
67
  blobs: e.assetSink
68
- }) : await mn(c, f);
69
- let t = await j.runPromiseExit(un({
68
+ }) : await hn(c, p);
69
+ let t = await j.runPromiseExit(dn({
70
70
  store: e.store,
71
- bundleDir: f,
71
+ bundleDir: p,
72
72
  ...r ? { mode: r } : {},
73
73
  ...i ? { onConflict: i } : {},
74
74
  ...a ? { atomic: a } : {},
75
75
  ...e.snapshot ? { targetSnapshot: e.snapshot } : {},
76
76
  force: o,
77
- onWarn: (e) => Sn.warn("admin.import", { message: e }),
77
+ onWarn: (e) => Cn.warn("admin.import", { message: e }),
78
78
  ...e.assetSink ? { assetsAlreadyRestored: !0 } : {}
79
79
  }));
80
80
  if (t._tag === "Failure") {
81
81
  let e = t.cause._tag === "Fail" ? t.cause.error : void 0;
82
82
  if (e && e._tag === "SchemaDriftError") {
83
83
  let t = e;
84
- return Sn.warn("admin.import refused (schema drift)", {
84
+ return Cn.warn("admin.import refused (schema drift)", {
85
85
  transport: l,
86
86
  bundle: t.bundleFingerprint.slice(0, 16),
87
87
  target: t.targetFingerprint.slice(0, 16)
@@ -96,7 +96,7 @@ var hn = "VoltroBootRefusal", gn = (e) => {
96
96
  throw Error(String(e?.message ?? e ?? "import failed"));
97
97
  }
98
98
  let n = t.value, s = n.tables.reduce((e, t) => e + t.rowCount, 0);
99
- return Sn.info("admin.import", {
99
+ return Cn.info("admin.import", {
100
100
  transport: l,
101
101
  tables: n.tables.length,
102
102
  rows: s,
@@ -108,7 +108,7 @@ var hn = "VoltroBootRefusal", gn = (e) => {
108
108
  transport: l
109
109
  });
110
110
  } catch (e) {
111
- return Sn.warn("admin.import failed", {
111
+ return Cn.warn("admin.import failed", {
112
112
  transport: l,
113
113
  error: e?.message ?? String(e)
114
114
  }), Q(500, {
@@ -116,23 +116,23 @@ var hn = "VoltroBootRefusal", gn = (e) => {
116
116
  message: e?.message ?? String(e)
117
117
  });
118
118
  } finally {
119
- await d.rm(f, {
119
+ await d.rm(p, {
120
120
  recursive: !0,
121
121
  force: !0
122
122
  });
123
123
  }
124
- }, En = N({ scope: "voltro:admin-export" }), Dn = async (e) => {
124
+ }, Dn = N({ scope: "voltro:admin-export" }), On = async (e) => {
125
125
  let t = [];
126
126
  for await (let n of e) t.push(Buffer.from(n));
127
127
  return new Uint8Array(Buffer.concat(t));
128
- }, On = (e) => typeof e.tenant == "string" && e.tenant ? {
128
+ }, kn = (e) => typeof e.tenant == "string" && e.tenant ? {
129
129
  kind: "tenant",
130
130
  tenantId: e.tenant
131
131
  } : Array.isArray(e.tables) && e.tables.length ? {
132
132
  kind: "tables",
133
133
  tables: e.tables.filter((e) => typeof e == "string")
134
- } : { kind: "all" }, kn = (e) => async (t) => {
135
- let n = xn(t, e.secret);
134
+ } : { kind: "all" }, An = (e) => async (t) => {
135
+ let n = Sn(t, e.secret);
136
136
  if (n) return n;
137
137
  let r;
138
138
  try {
@@ -152,13 +152,13 @@ var hn = "VoltroBootRefusal", gn = (e) => {
152
152
  });
153
153
  }
154
154
  }
155
- let a = r.consistency === "snapshot" ? "snapshot" : i.consistency ?? "live", o = (typeof r.compression == "string" ? r.compression : void 0) ?? i.compression, s = i.scope ?? On(r), c = typeof r.bundleKey == "string" && r.bundleKey.length > 0, l = r.assets === !0 && e.assetSource ? { blobs: e.assetSource } : {}, u = await import("node:os"), d = await import("node:fs/promises"), ee = await import("node:path"), f = await d.mkdtemp(ee.join(u.tmpdir(), "voltro-admin-export-"));
155
+ let a = r.consistency === "snapshot" ? "snapshot" : i.consistency ?? "live", o = (typeof r.compression == "string" ? r.compression : void 0) ?? i.compression, s = i.scope ?? kn(r), c = typeof r.bundleKey == "string" && r.bundleKey.length > 0, l = r.assets === !0 && e.assetSource ? { blobs: e.assetSource } : {}, u = await import("node:os"), d = await import("node:fs/promises"), f = await import("node:path"), p = await d.mkdtemp(f.join(u.tmpdir(), "voltro-admin-export-"));
156
156
  try {
157
- let t = await j.runPromise(ln({
157
+ let t = await j.runPromise(un({
158
158
  store: e.store,
159
159
  snapshot: e.snapshot,
160
160
  dialect: e.dialect,
161
- outDir: f,
161
+ outDir: p,
162
162
  ...i.subset ? { subset: i.subset } : {
163
163
  scope: s,
164
164
  ...e.tenantTables && e.tenantTables.length > 0 ? { tenantTables: e.tenantTables } : {}
@@ -170,10 +170,10 @@ var hn = "VoltroBootRefusal", gn = (e) => {
170
170
  if (c) {
171
171
  if (!e.putArchive) return Q(501, { error: "storage transport not configured on this instance" });
172
172
  let i = r.bundleKey;
173
- return await e.putArchive(i, () => cn({
174
- dir: f,
173
+ return await e.putArchive(i, () => ln({
174
+ dir: p,
175
175
  ...l
176
- })), En.info("admin.export", {
176
+ })), Dn.info("admin.export", {
177
177
  transport: "storage",
178
178
  tables: t.tables.length,
179
179
  rows: n,
@@ -187,11 +187,11 @@ var hn = "VoltroBootRefusal", gn = (e) => {
187
187
  transport: "storage"
188
188
  });
189
189
  }
190
- let d = await Dn(cn({
191
- dir: f,
190
+ let d = await On(ln({
191
+ dir: p,
192
192
  ...l
193
193
  }));
194
- return En.info("admin.export", {
194
+ return Dn.info("admin.export", {
195
195
  transport: "download",
196
196
  tables: t.tables.length,
197
197
  rows: n,
@@ -208,17 +208,17 @@ var hn = "VoltroBootRefusal", gn = (e) => {
208
208
  }
209
209
  };
210
210
  } catch (e) {
211
- return En.warn("admin.export failed", { error: e?.message ?? String(e) }), Q(500, {
211
+ return Dn.warn("admin.export failed", { error: e?.message ?? String(e) }), Q(500, {
212
212
  error: "export failed",
213
213
  message: e?.message ?? String(e)
214
214
  });
215
215
  } finally {
216
- await d.rm(f, {
216
+ await d.rm(p, {
217
217
  recursive: !0,
218
218
  force: !0
219
219
  });
220
220
  }
221
- }, An = async (e) => {
221
+ }, jn = async (e) => {
222
222
  let { resolve: t } = await import("node:path"), { existsSync: n } = await import("node:fs"), r = [
223
223
  e,
224
224
  `${e}.profile.ts`,
@@ -229,8 +229,8 @@ var hn = "VoltroBootRefusal", gn = (e) => {
229
229
  let a = await import(i), o = a.default ?? a.profile;
230
230
  if (!o) throw Error(`data profile '${i}' has no default export`);
231
231
  return o;
232
- }, jn = (e, t, n = {}) => (async function* () {
233
- let r = await U((await j.runPromise(Ft(e, t).pipe(j.timeout(n.openTimeout ?? "30 seconds")))).stream), i = n.stallMs ?? 12e4, a, o = () => {
232
+ }, Mn = (e, t, n = {}) => (async function* () {
233
+ let r = await It((await j.runPromise(Ft(e, t).pipe(j.timeout(n.openTimeout ?? "30 seconds")))).stream), i = n.stallMs ?? 12e4, a, o = () => {
234
234
  a && clearTimeout(a), a = setTimeout(() => r.destroy(/* @__PURE__ */ Error(`storage read stalled for ${i}ms reading '${t}'`)), i);
235
235
  };
236
236
  try {
@@ -239,7 +239,7 @@ var hn = "VoltroBootRefusal", gn = (e) => {
239
239
  } finally {
240
240
  a && clearTimeout(a), r.destroy();
241
241
  }
242
- })(), Mn = {
242
+ })(), Nn = {
243
243
  get: async () => void 0,
244
244
  set: async () => {},
245
245
  setWithTags: async () => {},
@@ -248,21 +248,21 @@ var hn = "VoltroBootRefusal", gn = (e) => {
248
248
  clear: async () => {},
249
249
  invalidateTag: async () => 0,
250
250
  wrap: async (e, t, n) => n()
251
- }, Nn = async (e) => {
252
- Ct({
251
+ }, Pn = async (e) => {
252
+ wt({
253
253
  dataStore: e.store,
254
254
  schemaRegistry: e.schemaRegistry
255
255
  });
256
256
  let t = new ze({
257
257
  store: e.store,
258
258
  ...e.snapshotCache ? { cache: e.snapshotCache } : {},
259
- recordDelivery: (e) => vt({
259
+ recordDelivery: (e) => yt({
260
260
  label: e.label,
261
261
  kind: e.kind,
262
262
  durationMs: e.durationMs,
263
263
  rowCount: e.rowCount
264
264
  })
265
- }), n = e.cache ?? Mn, r = e.kv ?? z, i, a, o, s = /* @__PURE__ */ new Map(), c = () => `wfctx_${globalThis.crypto?.randomUUID?.() ?? `${Date.now().toString(36)}${Math.random().toString(36).slice(2)}`}`, l = async (t, n, r) => {
265
+ }), n = e.cache ?? Nn, r = e.kv ?? _t, i, a, o, s = /* @__PURE__ */ new Map(), c = () => `wfctx_${globalThis.crypto?.randomUUID?.() ?? `${Date.now().toString(36)}${Math.random().toString(36).slice(2)}`}`, l = async (t, n, r) => {
266
266
  let i = {
267
267
  ...r,
268
268
  source: r.source ?? `workflow:${t}`
@@ -272,7 +272,7 @@ var hn = "VoltroBootRefusal", gn = (e) => {
272
272
  let r = await e.store.query({
273
273
  table: "_voltro_workflow_start_contexts",
274
274
  order: [],
275
- predicate: V("executionId", n),
275
+ predicate: H("executionId", n),
276
276
  projection: ["id"],
277
277
  skip: void 0,
278
278
  take: 1
@@ -300,7 +300,7 @@ var hn = "VoltroBootRefusal", gn = (e) => {
300
300
  let t = (await e.store.query({
301
301
  table: "_voltro_workflow_start_contexts",
302
302
  order: [],
303
- predicate: V("executionId", n),
303
+ predicate: H("executionId", n),
304
304
  projection: void 0,
305
305
  skip: void 0,
306
306
  take: 1
@@ -318,29 +318,29 @@ var hn = "VoltroBootRefusal", gn = (e) => {
318
318
  process.stderr.write(`[workflow] failed to load start context for ${n}: ${e?.message ?? String(e)}\n`);
319
319
  return;
320
320
  }
321
- }, d = (e.discovered.workflows?.length ?? 0) > 0 ? st(() => i) : void 0, f = (e.discovered.workflows?.length ?? 0) > 0 || (e.discovered.eventTriggers?.length ?? 0) > 0, te = f || (e.discovered.workflowWorkers?.length ?? 0) > 0 || e.scheduleCoordination === "cluster", re = e.tenantIsolation === "namespace", ie = (e.log ?? N({ scope: "voltro:serve" })).child("webhooks"), ae, h = e.discovered.webhooks;
322
- if (h && h.outgoing.length > 0 && e.workflowEngineLayer !== void 0) {
323
- let t = e.workflowEngineLayer, i = S({
321
+ }, d = (e.discovered.workflows?.length ?? 0) > 0 ? st(() => i) : void 0, f = (e.discovered.workflows?.length ?? 0) > 0 || (e.discovered.eventTriggers?.length ?? 0) > 0, p = f || (e.discovered.workflowWorkers?.length ?? 0) > 0 || e.scheduleCoordination === "cluster", te = e.tenantIsolation === "namespace", ne = (e.log ?? N({ scope: "voltro:serve" })).child("webhooks"), re, g = e.discovered.webhooks;
322
+ if (g && g.outgoing.length > 0 && e.workflowEngineLayer !== void 0) {
323
+ let t = e.workflowEngineLayer, i = x({
324
324
  store: e.store,
325
325
  schemaRegistry: e.schemaRegistry,
326
326
  cache: n,
327
327
  kv: r
328
- }), a = h.outgoing.map((e) => e.descriptor);
329
- ae = rn(i, async (e) => {
330
- let n = on.execute(e).pipe(j.provide(on.toLayer(nn(i, { events: a })).pipe(M.provideMerge(t))));
328
+ }), a = g.outgoing.map((e) => e.descriptor);
329
+ re = an(i, async (e) => {
330
+ let n = sn.execute(e).pipe(j.provide(sn.toLayer(rn(i, { events: a })).pipe(M.provideMerge(t))));
331
331
  j.runPromise(n).catch((t) => {
332
- ie.error("deliverWebhook workflow crashed", {
332
+ ne.error("deliverWebhook workflow crashed", {
333
333
  deliveryId: e.deliveryId,
334
334
  targetId: e.targetId
335
335
  }, t);
336
336
  });
337
337
  }, { events: a });
338
338
  }
339
- let oe = /* @__PURE__ */ new Map();
340
- if (h) for (let e of h.incoming) {
341
- let t = e.descriptor.path ?? an(e.descriptor.id), n = `VOLTRO_WEBHOOK_SECRET_${e.descriptor.id.toUpperCase().replace(/[^A-Z0-9]/g, "_")}`, r = sn(e.descriptor, {
339
+ let ie = /* @__PURE__ */ new Map();
340
+ if (g) for (let e of g.incoming) {
341
+ let t = e.descriptor.path ?? on(e.descriptor.id), n = `VOLTRO_WEBHOOK_SECRET_${e.descriptor.id.toUpperCase().replace(/[^A-Z0-9]/g, "_")}`, r = cn(e.descriptor, {
342
342
  resolveSecret: async () => process.env[n] ?? null,
343
- resolveWorkflows: () => d === void 0 ? void 0 : ht(d, {
343
+ resolveWorkflows: () => d === void 0 ? void 0 : gt(d, {
344
344
  traceId: `incoming:${e.descriptor.id}`,
345
345
  source: `incoming:${e.descriptor.id}`
346
346
  }),
@@ -352,145 +352,151 @@ var hn = "VoltroBootRefusal", gn = (e) => {
352
352
  idempotency: e.idempotency,
353
353
  durationMs: e.durationMs
354
354
  };
355
- e.status >= 500 ? ie.error("incoming delivery failed", t) : e.status >= 400 ? ie.warn("incoming delivery rejected", t) : ie.info("incoming delivery handled", t);
355
+ e.status >= 500 ? ne.error("incoming delivery failed", t) : e.status >= 400 ? ne.warn("incoming delivery rejected", t) : ne.info("incoming delivery handled", t);
356
356
  }
357
357
  });
358
- oe.set(t, { handle: r });
358
+ ie.set(t, { handle: r });
359
359
  }
360
- Qe(), wt((t) => $e(e.store, t.subjectId, t.resourceType, t.resourceId));
361
- let se = (e.discovered.outboxHandlers?.length ?? 0) > 0 ? p({
360
+ Qe(), Tt((t) => $e(e.store, t.subjectId, t.resourceType, t.resourceId));
361
+ let ae = (e.discovered.outboxHandlers?.length ?? 0) > 0 ? de({
362
362
  handlers: e.discovered.outboxHandlers ?? [],
363
363
  store: e.store,
364
364
  log: (e.log ?? N({ scope: "voltro:serve" })).child("outbox")
365
- }) : void 0, v = ce({
365
+ }) : void 0, _ = O({
366
366
  definitions: (e.discovered.connections ?? []).map((e) => e.definition),
367
367
  store: e.store,
368
- publicUrl: g(e.port ?? 4e3),
368
+ publicUrl: se(e.port ?? 4e3),
369
369
  log: (e.log ?? N({ scope: "voltro:serve" })).child("connections")
370
- }), y = we({
370
+ }), b = ve({
371
371
  store: e.store,
372
372
  schemaRegistry: e.schemaRegistry,
373
373
  cache: n,
374
374
  kv: r,
375
- ...ae === void 0 ? {} : { webhooksService: ae },
375
+ ...re === void 0 ? {} : { webhooksService: re },
376
376
  ...d === void 0 ? {} : { workflowsProxy: d },
377
377
  eventTriggers: e.discovered.eventTriggers ?? [],
378
- namespaceIsolationOn: re,
379
- ...se === void 0 ? {} : { outbox: { nudge: se.nudge } },
380
- ...v.active ? { connections: { registry: v.registry } } : {}
381
- }), ue = M.succeed(P, m), fe = (t, n) => {
378
+ namespaceIsolationOn: te,
379
+ ...ae === void 0 ? {} : { outbox: { nudge: ae.nudge } },
380
+ ..._.active ? { connections: { registry: _.registry } } : {}
381
+ }), le = M.succeed(P, y), ue = (t, n) => {
382
382
  let r = t.pipe(j.provide(ot(n)));
383
- return (e.baseLayer ? r.pipe(j.provide(e.baseLayer)) : r).pipe(j.provide(ue));
384
- }, pe = (e, t) => xt(fe(e, t)), me = ct({
383
+ return (e.baseLayer ? r.pipe(j.provide(e.baseLayer)) : r).pipe(j.provide(le));
384
+ }, fe = (e, t) => St(ue(e, t)), pe = lt({
385
385
  store: e.store,
386
- buildContext: (e, t, n) => y(e, t, n),
387
- runEffect: pe,
388
- undoCapture: le()
389
- }), he = D(), ge = R({
390
- buildContext: (e) => y(e),
391
- runEffect: pe
392
- }), _e = {
393
- buildContext: (e) => y(e),
386
+ buildContext: (e, t, n) => b(e, t, n),
387
+ runEffect: fe,
388
+ undoCapture: ee()
389
+ }), me = ce(), he = R({
390
+ buildContext: (e) => b(e),
391
+ runEffect: fe
392
+ }), ge = {
393
+ buildContext: (e) => b(e),
394
394
  finalize: (t, n) => Ve(He(t, e.tenantScopedTables, n.subject.tenantId), e.softDeleteScopedTables),
395
- provideEffect: fe
396
- }, x = ut(_e), ye = lt({
397
- ..._e,
395
+ provideEffect: ue
396
+ }, C = dt(ge), _e = ut({
397
+ ...ge,
398
398
  queryRows: (t) => e.store.query(t)
399
- }), be = ft({
400
- ..._e,
399
+ }), ye = pt({
400
+ ...ge,
401
401
  subscribeDescriptor: (e, n, r) => t.subscribe(e, n, r),
402
402
  subscribeComputed: (e, n, r) => t.subscribeComputed(e, n, r)
403
- }), C = (e) => e.filter((e) => zt(e.descriptor)), T = {};
403
+ }), w = (e) => e.filter((e) => zt(e.descriptor)), T = {};
404
404
  for (let n of [
405
- ...C(e.discovered.queries),
406
- ...he.queries,
407
- ...v.queries
408
- ]) T[n.descriptor.name] = (e) => I(x(n, e), t, `subscription.${n.descriptor.name}`, void 0, void 0, dt(n, e));
405
+ ...w(e.discovered.queries),
406
+ ...me.queries,
407
+ ..._.queries
408
+ ]) T[n.descriptor.name] = (e) => I(C(n, e), t, `subscription.${n.descriptor.name}`, void 0, void 0, ft(n, e));
409
409
  for (let t of [
410
- ...C(e.discovered.mutations),
411
- ...he.mutations,
412
- ...v.mutations
413
- ]) T[t.descriptor.name] = (e) => F(async (e, n) => me(t, e, n), e, `mutation.${t.descriptor.name}`);
414
- for (let t of [...C(e.discovered.actions), ...v.actions]) T[t.descriptor.name] = (e) => F(async (e, n) => ge(t, e, n), e, `action.${t.descriptor.name}`);
415
- let xe = () => `public-${Math.random().toString(36).slice(2, 10)}`, Se = [
410
+ ...w(e.discovered.mutations),
411
+ ...me.mutations,
412
+ ..._.mutations
413
+ ]) {
414
+ let n = ct(t.descriptor.output);
415
+ T[t.descriptor.name] = (r) => F(async (e, n) => pe(t, e, n), r, `mutation.${t.descriptor.name}`, n, e.idempotency);
416
+ }
417
+ for (let t of [...w(e.discovered.actions), ..._.actions]) {
418
+ let n = ct(t.descriptor.output);
419
+ T[t.descriptor.name] = (r) => F(async (e, n) => he(t, e, n), r, `action.${t.descriptor.name}`, n, e.idempotency);
420
+ }
421
+ let E = () => `public-${Math.random().toString(36).slice(2, 10)}`, be = [
416
422
  ...e.discovered.queries.filter((e) => e.descriptor.publicApi !== void 0).map((e) => ({
417
423
  descriptor: e.descriptor,
418
- invoke: (t, n) => ye(e, t, {
424
+ invoke: (t, n) => _e(e, t, {
419
425
  subject: n.subject,
420
- traceId: xe()
426
+ traceId: E()
421
427
  }),
422
- subscribe: (t, n, r) => be(e, t, {
428
+ subscribe: (t, n, r) => ye(e, t, {
423
429
  subject: n.subject,
424
- traceId: xe()
430
+ traceId: E()
425
431
  }, r)
426
432
  })),
427
433
  ...e.discovered.mutations.filter((e) => e.descriptor.publicApi !== void 0).map((e) => ({
428
434
  descriptor: e.descriptor,
429
- invoke: (t, n) => me(e, t, {
435
+ invoke: (t, n) => pe(e, t, {
430
436
  subject: n.subject,
431
- traceId: xe()
437
+ traceId: E()
432
438
  })
433
439
  })),
434
440
  ...e.discovered.actions.filter((e) => e.descriptor.publicApi !== void 0).map((e) => ({
435
441
  descriptor: e.descriptor,
436
- invoke: (t, n) => ge(e, t, {
442
+ invoke: (t, n) => he(e, t, {
437
443
  subject: n.subject,
438
- traceId: xe()
444
+ traceId: E()
439
445
  })
440
446
  }))
441
- ], Ce = Se.length > 0 ? tn(en(Se), {
447
+ ], xe = be.length > 0 ? nn(tn(be), {
442
448
  store: e.store,
443
449
  resolveSubject: (t) => e.resolveSubject(t, -1)
444
- }) : [], E = e.dataTransferSecret ?? process.env.VOLTRO_DATA_TRANSFER_SECRET, Te = E && E.length >= 16 ? [{
450
+ }) : [], Se = e.dataTransferSecret ?? process.env.VOLTRO_DATA_TRANSFER_SECRET, Ce = Se && Se.length >= 16 ? [{
445
451
  method: "POST",
446
- path: _n,
447
- handle: Tn({
448
- secret: E,
452
+ path: vn,
453
+ handle: En({
454
+ secret: Se,
449
455
  store: e.store,
450
456
  ...e.dataTransferSnapshot ? { snapshot: e.dataTransferSnapshot } : {},
451
- assetSink: dn(H()),
452
- openArchive: (e) => jn(H(), e)
457
+ assetSink: fn(U()),
458
+ openArchive: (e) => Mn(U(), e)
453
459
  })
454
460
  }, {
455
461
  method: "POST",
456
- path: vn,
457
- handle: kn({
458
- secret: E,
462
+ path: yn,
463
+ handle: An({
464
+ secret: Se,
459
465
  store: e.store,
460
466
  snapshot: e.dataTransferSnapshot ?? { tables: [] },
461
467
  dialect: e.dataTransferDialect ?? "memory",
462
468
  tenantTables: [...e.tenantScopedTables],
463
- loadProfile: An,
464
- assetSource: fn(H(), e.store),
469
+ loadProfile: jn,
470
+ assetSource: pn(U(), e.store),
465
471
  putArchive: async (e, t) => {
466
- let { Readable: n } = await import("node:stream"), r = H(), i = Pt("storage", () => n.from(t()));
467
- await j.runPromise(It(r, e, i, { contentType: "application/octet-stream" }));
472
+ let { Readable: n } = await import("node:stream"), r = U(), i = Pt("storage", () => n.from(t()));
473
+ await j.runPromise(W(r, e, i, { contentType: "application/octet-stream" }));
468
474
  }
469
475
  })
470
- }] : [], Ee = [
476
+ }] : [], we = [
471
477
  ...e.httpRoutes ?? [],
478
+ ...xe,
472
479
  ...Ce,
473
- ...Te,
474
- ...v.httpRoutes
480
+ ..._.httpRoutes
475
481
  ];
476
- for (let t of C(e.discovered.streams ?? [])) T[t.descriptor.name] = (n) => Ge((r) => {
477
- let i = y(r), a = t.executor(n, i);
482
+ for (let t of w(e.discovered.streams ?? [])) T[t.descriptor.name] = (n) => Ge((r) => {
483
+ let i = b(r), a = t.executor(n, i);
478
484
  if (j.isEffect(a)) {
479
485
  let t = a.pipe(j.provide(ot(i.store)));
480
- return (e.baseLayer ? t.pipe(j.provide(e.baseLayer)) : t).pipe(j.provide(ue));
486
+ return (e.baseLayer ? t.pipe(j.provide(e.baseLayer)) : t).pipe(j.provide(le));
481
487
  }
482
488
  return typeof a == "object" && a && typeof a.then == "function" ? j.promise(() => a) : a;
483
489
  }, `stream.${t.descriptor.name}`);
484
490
  for (let t of e.discovered.workflows ?? []) T[t.definition.name] = (e) => F(async (e, n) => {
485
491
  let r = n;
486
- return ht(d, {
492
+ return gt(d, {
487
493
  subject: r.subject,
488
494
  traceId: r.traceId,
489
495
  source: "workflow-rpc"
490
496
  }).start(t.definition.name, e);
491
497
  }, e, `workflow.${t.definition.name}`);
492
- f && (T[X.name] = (e) => I(x({
493
- descriptor: X,
498
+ f && (T[Gt.name] = (e) => I(C({
499
+ descriptor: Gt,
494
500
  executor: (e) => {
495
501
  let t = e.id;
496
502
  return {
@@ -499,16 +505,16 @@ var hn = "VoltroBootRefusal", gn = (e) => {
499
505
  column: "startedAt",
500
506
  direction: "desc"
501
507
  }],
502
- predicate: Nt(V("id", t), V("executionId", t)),
508
+ predicate: Nt(H("id", t), H("executionId", t)),
503
509
  take: 1,
504
510
  skip: void 0,
505
511
  projection: void 0
506
512
  };
507
513
  }
508
- }, e), t, `subscription.${X.name}`), T[Z.name] = (e) => I(x({
514
+ }, e), t, `subscription.${Gt.name}`), T[Z.name] = (e) => I(C({
509
515
  descriptor: Z,
510
516
  executor: (e) => {
511
- let t = e, n = [...t.tag === void 0 ? [] : [V("tag", t.tag)], ...t.status === void 0 ? [] : [V("status", t.status)]], r = Number.isFinite(t.limit) && t.limit !== void 0 ? Math.min(Math.max(Math.floor(t.limit), 1), 500) : 100;
517
+ let t = e, n = [...t.tag === void 0 ? [] : [H("tag", t.tag)], ...t.status === void 0 ? [] : [H("status", t.status)]], r = Number.isFinite(t.limit) && t.limit !== void 0 ? Math.min(Math.max(Math.floor(t.limit), 1), 500) : 100;
512
518
  return {
513
519
  table: "_voltro_workflow_runs",
514
520
  order: [{
@@ -521,8 +527,8 @@ var hn = "VoltroBootRefusal", gn = (e) => {
521
527
  projection: void 0
522
528
  };
523
529
  }
524
- }, e), t, `subscription.${Z.name}`), T[Wt.name] = (e) => I(x({
525
- descriptor: Wt,
530
+ }, e), t, `subscription.${Z.name}`), T[X.name] = (e) => I(C({
531
+ descriptor: X,
526
532
  executor: (e) => {
527
533
  let t = e.runId;
528
534
  return {
@@ -531,13 +537,13 @@ var hn = "VoltroBootRefusal", gn = (e) => {
531
537
  column: "startedAt",
532
538
  direction: "asc"
533
539
  }],
534
- predicate: V("runId", t),
540
+ predicate: H("runId", t),
535
541
  take: 1e3,
536
542
  skip: void 0,
537
543
  projection: void 0
538
544
  };
539
545
  }
540
- }, e), t, `subscription.${Wt.name}`), T[Y.name] = (e) => I(x({
546
+ }, e), t, `subscription.${X.name}`), T[Y.name] = (e) => I(C({
541
547
  descriptor: Y,
542
548
  executor: (e) => {
543
549
  let t = e.runId;
@@ -547,14 +553,14 @@ var hn = "VoltroBootRefusal", gn = (e) => {
547
553
  column: "occurredAt",
548
554
  direction: "asc"
549
555
  }],
550
- predicate: V("runId", t),
556
+ predicate: H("runId", t),
551
557
  take: 1e3,
552
558
  skip: void 0,
553
559
  projection: void 0
554
560
  };
555
561
  }
556
- }, e), t, `subscription.${Y.name}`), T[q.name] = (e) => I(x({
557
- descriptor: q,
562
+ }, e), t, `subscription.${Y.name}`), T[Ut.name] = (e) => I(C({
563
+ descriptor: Ut,
558
564
  executor: (e) => {
559
565
  let t = e;
560
566
  return {
@@ -563,14 +569,14 @@ var hn = "VoltroBootRefusal", gn = (e) => {
563
569
  column: "occurredAt",
564
570
  direction: "desc"
565
571
  }],
566
- predicate: t.name === void 0 ? void 0 : V("name", t.name),
572
+ predicate: t.name === void 0 ? void 0 : H("name", t.name),
567
573
  take: Math.max(1, Math.min(500, t.limit ?? 100)),
568
574
  skip: void 0,
569
575
  projection: void 0
570
576
  };
571
577
  }
572
- }, e), t, `subscription.${q.name}`), T[Ut.name] = (e) => I(x({
573
- descriptor: Ut,
578
+ }, e), t, `subscription.${Ut.name}`), T[J.name] = (e) => I(C({
579
+ descriptor: J,
574
580
  executor: (e) => {
575
581
  let t = e.eventId;
576
582
  return {
@@ -579,63 +585,66 @@ var hn = "VoltroBootRefusal", gn = (e) => {
579
585
  column: "createdAt",
580
586
  direction: "asc"
581
587
  }],
582
- predicate: V("eventId", t),
588
+ predicate: H("eventId", t),
583
589
  take: 500,
584
590
  skip: void 0,
585
591
  projection: void 0
586
592
  };
587
593
  }
588
- }, e), t, `subscription.${Ut.name}`), T[Ht.name] = (t) => F(async (t, n) => {
594
+ }, e), t, `subscription.${J.name}`), T[Ht.name] = (t) => F(async (t, n) => {
589
595
  let r = t;
590
- return await w(e.store, n.subject, { executionId: r.executionId }), await d.cancel(r.workflowName, r.executionId), await Pe(r.workflowName, r.executionId, "workflow.cancel"), { ok: !0 };
591
- }, t, `action.${Ht.name}`), T[J.name] = (t) => F(async (t, n) => {
596
+ return await D(e.store, n.subject, { executionId: r.executionId }), await d.cancel(r.workflowName, r.executionId), await Pe(r.workflowName, r.executionId, "workflow.cancel"), { ok: !0 };
597
+ }, t, `action.${Ht.name}`), T[Wt.name] = (t) => F(async (t, n) => {
592
598
  let r = t;
593
- return await w(e.store, n.subject, { executionId: r.executionId }), await d.resume(r.workflowName, r.executionId), { ok: !0 };
594
- }, t, `action.${J.name}`), T[Gt.name] = (t) => F(async (t, n) => {
599
+ return await D(e.store, n.subject, { executionId: r.executionId }), await d.resume(r.workflowName, r.executionId), { ok: !0 };
600
+ }, t, `action.${Wt.name}`), T[Kt.name] = (t) => F(async (t, n) => {
595
601
  let r = t;
596
- return await w(e.store, n.subject, { id: r.id }), d.signal({ id: r.id }, r.signalName, r.payload);
597
- }, t, `action.${Gt.name}`), T[Kt.name] = (t) => F(async (t, n) => {
602
+ return await D(e.store, n.subject, { id: r.id }), d.signal({ id: r.id }, r.signalName, r.payload);
603
+ }, t, `action.${Kt.name}`), T[qt.name] = (t) => F(async (t, n) => {
598
604
  let r = t;
599
- return await w(e.store, n.subject, { id: r.id }), d.update({ id: r.id }, r.updateName, r.payload, r.timeoutMs === void 0 ? void 0 : { timeoutMs: r.timeoutMs });
600
- }, t, `action.${Kt.name}`));
601
- let De = [
602
- ...C(e.discovered.queries).map((e) => K(e.descriptor)),
603
- ...C(e.discovered.mutations).map((e) => Bt(e.descriptor)),
604
- ...C(e.discovered.actions).map((e) => G(e.descriptor)),
605
- ...he.queries.map((e) => K(e.descriptor)),
606
- ...he.mutations.map((e) => Bt(e.descriptor)),
607
- ...v.queries.map((e) => K(e.descriptor)),
608
- ...v.mutations.map((e) => Bt(e.descriptor)),
609
- ...v.actions.map((e) => G(e.descriptor)),
610
- ...C(e.discovered.streams ?? []).map((e) => Vt(e.descriptor)),
611
- ...(e.discovered.workflows ?? []).map((e) => B(e.definition)),
605
+ return await D(e.store, n.subject, { id: r.id }), d.update({ id: r.id }, r.updateName, r.payload, r.timeoutMs === void 0 ? void 0 : { timeoutMs: r.timeoutMs });
606
+ }, t, `action.${qt.name}`));
607
+ let Te = [
608
+ ...w(e.discovered.queries).map((e) => q(e.descriptor)),
609
+ ...w(e.discovered.mutations).map((e) => Bt(e.descriptor)),
610
+ ...w(e.discovered.actions).map((e) => K(e.descriptor)),
611
+ ...me.queries.map((e) => q(e.descriptor)),
612
+ ...me.mutations.map((e) => Bt(e.descriptor)),
613
+ ..._.queries.map((e) => q(e.descriptor)),
614
+ ..._.mutations.map((e) => Bt(e.descriptor)),
615
+ ..._.actions.map((e) => K(e.descriptor)),
616
+ ...w(e.discovered.streams ?? []).map((e) => Vt(e.descriptor)),
617
+ ...(e.discovered.workflows ?? []).map((e) => V(e.definition)),
612
618
  ...f ? [
613
- K(X),
614
- K(Z),
619
+ q(Gt),
620
+ q(Z),
621
+ q(X),
622
+ q(Y),
623
+ q(Ut),
624
+ q(J),
625
+ K(Ht),
615
626
  K(Wt),
616
- K(Y),
617
- K(q),
618
- K(Ut),
619
- G(Ht),
620
- G(J),
621
- G(Gt),
622
- G(Kt)
627
+ K(Kt),
628
+ K(qt)
623
629
  ] : []
624
- ], Oe = kt.make(...De).middleware(Lt).middleware(W), Ae = M.succeed(Lt, Lt.of(({ headers: t, clientId: n }) => j.promise(() => e.resolveSubject(t, n)))), je = M.succeed(W, W.of(({ clientId: e }) => j.succeed({ clientId: e }))), Me = e.dormancyTenantId ?? "default", O = e.dormancy === "sleep" ? {
625
- register: (t, n, r) => yt(e.store, {
626
- tenantId: r ?? Me,
630
+ ], Ee = kt.make(...Te).middleware(G).middleware(Lt), De = M.succeed(G, G.of(({ headers: t, clientId: n }) => j.promise(() => e.resolveSubject(t, n)))), ke = M.succeed(Lt, Lt.of(({ headers: e, clientId: t }) => j.succeed({
631
+ clientId: t,
632
+ ...e["idempotency-key"] ? { idempotencyKey: e["idempotency-key"] } : {}
633
+ }))), Ae = e.dormancyTenantId ?? "default", Me = e.dormancy === "sleep" ? {
634
+ register: (t, n, r) => bt(e.store, {
635
+ tenantId: r ?? Ae,
627
636
  kind: "workflow",
628
637
  refId: t,
629
638
  wakeAt: n
630
639
  }),
631
640
  cancel: (t, n) => qe(e.store, {
632
- tenantId: n ?? Me,
641
+ tenantId: n ?? Ae,
633
642
  kind: "workflow",
634
643
  refId: t
635
644
  }).then(() => {})
636
- } : void 0, k = te ? await import("@voltro/workflow") : void 0, A = k?.makeWorkflowRunRecorder({
645
+ } : void 0, k = p ? await import("@voltro/workflow") : void 0, A = k?.makeWorkflowRunRecorder({
637
646
  store: e.store,
638
- ...O === void 0 ? {} : { wakeups: O }
647
+ ...Me === void 0 ? {} : { wakeups: Me }
639
648
  }), Ne = async (t, n) => {
640
649
  await k.closeWorkflowChildrenForParent({
641
650
  store: e.store,
@@ -656,7 +665,7 @@ var hn = "VoltroBootRefusal", gn = (e) => {
656
665
  let i = (await e.store.query({
657
666
  table: "_voltro_workflow_runs",
658
667
  order: [],
659
- predicate: V("executionId", n),
668
+ predicate: H("executionId", n),
660
669
  projection: void 0,
661
670
  skip: void 0,
662
671
  take: 1
@@ -677,8 +686,8 @@ var hn = "VoltroBootRefusal", gn = (e) => {
677
686
  ...o == null ? {} : { tenantId: o }
678
687
  }
679
688
  }), a && await Ne(n, "cancelled");
680
- }, Fe = [...gt(e.discovered.workflows ?? [], {
681
- buildContext: (t, n) => e.buildContextForWorkflow?.(t, n) ?? y({
689
+ }, Fe = [...z(e.discovered.workflows ?? [], {
690
+ buildContext: (t, n) => e.buildContextForWorkflow?.(t, n) ?? b({
682
691
  subject: t.subject,
683
692
  traceId: t.traceId
684
693
  }, e.store, void 0, `workflow:${n.workflowName}`, { parentExecutionId: n.executionId }),
@@ -702,7 +711,7 @@ var hn = "VoltroBootRefusal", gn = (e) => {
702
711
  }), ...e.discovered.workflowWorkers ?? []], Ie = Fe.length > 0 ? M.mergeAll(...Fe) : M.empty;
703
712
  if (((e.discovered.workflows?.length ?? 0) > 0 || (e.discovered.workflowWorkers?.length ?? 0) > 0 || e.scheduleCoordination === "cluster") && e.workflowEngineLayer !== void 0) {
704
713
  let t = Ie.pipe(M.provideMerge(e.workflowEngineLayer));
705
- a = Le.make(e.baseLayer === void 0 ? t : t.pipe(M.provideMerge(e.baseLayer))), await a.runPromise(j.void), i = (e.discovered.workflows?.length ?? 0) > 0 ? mt({
714
+ a = Le.make(e.baseLayer === void 0 ? t : t.pipe(M.provideMerge(e.baseLayer))), await a.runPromise(j.void), i = (e.discovered.workflows?.length ?? 0) > 0 ? ht({
706
715
  workflows: e.discovered.workflows ?? [],
707
716
  runEffect: (e) => a.runPromise(e),
708
717
  rememberStartContext: l,
@@ -729,21 +738,21 @@ var hn = "VoltroBootRefusal", gn = (e) => {
729
738
  payload: r,
730
739
  ...i === void 0 ? {} : { options: i }
731
740
  }),
732
- listRuns: (t) => b(e.store, t),
733
- retry: (t, n) => ke({
741
+ listRuns: (t) => Oe(e.store, t),
742
+ retry: (t, n) => je({
734
743
  store: e.store,
735
744
  workflows: e.discovered.workflows ?? [],
736
745
  runPromise: (e) => a.runPromise(e)
737
746
  }, t, n)
738
747
  }) : void 0;
739
748
  }
740
- let Re = M.mergeAll(Oe.toLayer(T), Ae, je), Be = ee(T, e.discovered.queries.map((e) => e.descriptor.name), f), Ue = M.mergeAll(Oe.toLayer(Be), Ae, je), L = e.observability, Je = await Ke({
749
+ let Re = M.mergeAll(Ee.toLayer(T), De, ke), Be = S(T, e.discovered.queries.map((e) => e.descriptor.name), f), Ue = M.mergeAll(Ee.toLayer(Be), De, ke), L = e.observability, Je = await Ke({
741
750
  ...L && L.spanProcessors.length > 0 ? { extraSpanProcessors: L.spanProcessors } : {},
742
751
  ...L && L.metricReaders.length > 0 ? { extraMetricReaders: L.metricReaders } : {},
743
752
  ...L && Object.keys(L.resourceAttributes).length > 0 ? { resourceAttributes: L.resourceAttributes } : {},
744
753
  ...L && L.sampler !== void 0 ? { sampler: L.sampler } : {}
745
- }), Ye = !1, Xe = e.store.ping ? () => e.store.ping().then(() => !0).catch(() => !1) : void 0, { server: Ze, shutdown: tt } = Et({
746
- group: Oe,
754
+ }), Ye = !1, Xe = e.store.ping ? () => e.store.ping().then(() => !0).catch(() => !1) : void 0, { server: Ze, shutdown: tt } = Dt({
755
+ group: Ee,
747
756
  handlersLayer: Re,
748
757
  httpHandlersLayer: Ue,
749
758
  port: e.port ?? 4e3,
@@ -754,14 +763,14 @@ var hn = "VoltroBootRefusal", gn = (e) => {
754
763
  isReady: () => Ye,
755
764
  ...Xe ? { ping: Xe } : {}
756
765
  },
757
- ...Ee.length > 0 ? { httpRoutes: Ee } : {},
766
+ ...we.length > 0 ? { httpRoutes: we } : {},
758
767
  ...e.getStore === void 0 ? {} : { getStore: e.getStore },
759
- ...oe.size > 0 ? { webhookRoutes: oe } : {},
768
+ ...ie.size > 0 ? { webhookRoutes: ie } : {},
760
769
  ...e.inspectRoute === void 0 ? {} : { inspectRoute: e.inspectRoute }
761
770
  });
762
771
  if (await We(Ze), (e.discovered.schedules?.length ?? 0) > 0) {
763
- let t = (e.scheduleCoordination ?? "single") === "advisoryLock" ? et(e.store, e.scheduleReplicaId ?? `pid-${process.pid}`) : Tt;
764
- o = await Dt(e.discovered.schedules ?? [], {
772
+ let t = (e.scheduleCoordination ?? "single") === "advisoryLock" ? et(e.store, e.scheduleReplicaId ?? `pid-${process.pid}`) : Et;
773
+ o = await B(e.discovered.schedules ?? [], {
765
774
  store: e.store,
766
775
  coordinator: t,
767
776
  defaultTrigger: e.scheduleDefaultTrigger ?? "self",
@@ -769,7 +778,7 @@ var hn = "VoltroBootRefusal", gn = (e) => {
769
778
  armSelf: e.scheduleArmSelf ?? !0,
770
779
  dormancy: e.dormancy ?? "always-on",
771
780
  ...e.dormancyTenantId === void 0 ? {} : { dormancyTenantId: e.dormancyTenantId },
772
- buildContext: ({ traceId: t, scheduleName: n, subject: r }) => y({
781
+ buildContext: ({ traceId: t, scheduleName: n, subject: r }) => b({
773
782
  subject: r,
774
783
  traceId: t
775
784
  }, e.store, void 0, `schedule:${n}`),
@@ -790,9 +799,9 @@ var hn = "VoltroBootRefusal", gn = (e) => {
790
799
  }), e.onSchedulerReady?.(o);
791
800
  }
792
801
  let nt = e.log ?? N({ scope: "voltro:serve" }), rt, it;
793
- if ((e.discovered.subscribers?.length ?? 0) > 0 && (rt = de(e.discovered.subscribers ?? [], e.store, nt.child("subscribe"), e.schemaRegistry)), (e.discovered.reactions?.length ?? 0) > 0) {
802
+ if ((e.discovered.subscribers?.length ?? 0) > 0 && (rt = h(e.discovered.subscribers ?? [], e.store, nt.child("subscribe"), e.schemaRegistry)), (e.discovered.reactions?.length ?? 0) > 0) {
794
803
  let t = nt.child("reaction");
795
- it = ve(e.discovered.reactions ?? [], e.store, {
804
+ it = oe(e.discovered.reactions ?? [], e.store, {
796
805
  runAct: async (n, r) => {
797
806
  if (n.kind === "workflow") {
798
807
  if (d === void 0) {
@@ -800,15 +809,15 @@ var hn = "VoltroBootRefusal", gn = (e) => {
800
809
  return;
801
810
  }
802
811
  let e = r.new ?? r.old ?? {};
803
- await ht(d, {
812
+ await gt(d, {
804
813
  traceId: `reaction:${n.workflow}`,
805
814
  source: `reaction:${n.workflow}`
806
815
  }).start(n.workflow, e);
807
816
  return;
808
817
  }
809
- await _(n.agent, r, {
818
+ await v(n.agent, r, {
810
819
  findAgentSend: (t) => e.discovered.actions.find((e) => e.descriptor.name === `${t}.send`),
811
- runAction: (e, t, n) => Promise.resolve(ge(e, t, n)),
820
+ runAction: (e, t, n) => Promise.resolve(he(e, t, n)),
812
821
  makeSubject: (e) => Rt(e),
813
822
  now: () => Date.now(),
814
823
  log: t
@@ -828,14 +837,14 @@ var hn = "VoltroBootRefusal", gn = (e) => {
828
837
  }, t);
829
838
  }
830
839
  let at;
831
- return (e.discovered.aggregates?.length ?? 0) > 0 && (at = await ne({
840
+ return (e.discovered.aggregates?.length ?? 0) > 0 && (at = await m({
832
841
  discovered: e.discovered.aggregates ?? [],
833
842
  store: e.store,
834
843
  log: nt.child("aggregate"),
835
844
  ...e.analytics === void 0 ? {} : { analytics: e.analytics },
836
845
  ...e.aggregateStorage === void 0 ? {} : { storage: e.aggregateStorage },
837
846
  ...e.aggregateCoordinator === void 0 ? {} : { coordinator: e.aggregateCoordinator }
838
- }), ue = M.succeed(P, at.registry)), Ye = !0, e.bootTiming?.mark("ready"), {
847
+ }), le = M.succeed(P, at.registry)), Ye = !0, e.bootTiming?.mark("ready"), {
839
848
  dispatcher: t,
840
849
  server: Ze,
841
850
  scheduler: o,
@@ -843,8 +852,8 @@ var hn = "VoltroBootRefusal", gn = (e) => {
843
852
  Ye = !1, at?.detach(), it?.(), rt?.(), await o?.shutdown(), t.close(), await a?.dispose(), await new Promise((e) => Ze.close(() => e())), await tt();
844
853
  }
845
854
  };
846
- }, $ = N({ scope: "voltro:serve" }), Pn = (e, t, n) => (e === "production" || e === "staging") && t !== "memory" && n !== "0", Fn = Ne, In = async (e) => {
847
- let t = O(process.cwd());
855
+ }, $ = N({ scope: "voltro:serve" }), Fn = (e, t, n) => (e === "production" || e === "staging") && t !== "memory" && n !== "0", In = Ne, Ln = async (e) => {
856
+ let t = k(process.cwd());
848
857
  if (Re(t)) {
849
858
  let n;
850
859
  try {
@@ -855,69 +864,69 @@ var hn = "VoltroBootRefusal", gn = (e) => {
855
864
  }
856
865
  if (n) return $.info("serve: booting from the precompiled serve bundle"), n(e);
857
866
  }
858
- return Ln(e);
859
- }, Ln = async (ee) => {
860
- let p = A();
867
+ return Rn(e);
868
+ }, Rn = async (ee) => {
869
+ let m = A();
861
870
  process.env.NODE_ENV || (process.env.NODE_ENV = "production");
862
871
  try {
863
- qt();
872
+ Jt();
864
873
  } catch (e) {
865
- throw gn(e instanceof Error ? e.message : String(e));
874
+ throw _n(e instanceof Error ? e.message : String(e));
866
875
  }
867
- let m = process.cwd(), ne = Number(process.env.PORT ?? Fn(ee, "--port") ?? 4e3), g = await he(m);
868
- St(bt(g?.secrets)), await e({
869
- rawEnv: g?.env,
876
+ let h = process.cwd(), oe = Number(process.env.PORT ?? In(ee, "--port") ?? 4e3), v = await pe(h);
877
+ Ct(xt(v?.secrets)), await e({
878
+ rawEnv: v?.env,
870
879
  appType: "api",
871
- root: m,
880
+ root: h,
872
881
  log: $,
873
882
  generateTypes: !1
874
- }), p.mark("config");
875
- let _ = (process.env.DB_DIALECT ?? g?.store ?? "memory").toLowerCase(), ce = (_ === "mariadb" || _ === "postgres" || _ === "mssql") && (process.env.CDC ?? "1") !== "0", le = _ === "mariadb" ? "mariadb" : _ === "mssql" ? "mssql" : void 0, de = k(m);
883
+ }), m.mark("config");
884
+ let y = (process.env.DB_DIALECT ?? v?.store ?? "memory").toLowerCase(), se = (y === "mariadb" || y === "postgres" || y === "mssql") && (process.env.CDC ?? "1") !== "0", ce = y === "mariadb" ? "mariadb" : y === "mssql" ? "mssql" : void 0, de = Me(h);
876
885
  if (!i() && Re(de)) try {
877
886
  let e = await import(Fe(de).href);
878
887
  if (e.modules) {
879
888
  let t = {};
880
- for (let [n, r] of Object.entries(e.modules)) t[Pe(m, n)] = r;
889
+ for (let [n, r] of Object.entries(e.modules)) t[Pe(h, n)] = r;
881
890
  r(t), $.info("precompiled api bundle loaded", { modules: Object.keys(t).length });
882
891
  }
883
892
  } catch (e) {
884
893
  $.warn("precompiled api bundle failed to load — falling back to source", {}, e);
885
894
  }
886
- let b = await C(m), S = await De(b, { cdc: ce && le !== void 0 });
895
+ let x = await C(h), S = await Ee(x, { cdc: se && ce !== void 0 });
887
896
  {
888
- let e = h(S.serverOnlyLeaks, re(process.env, "strict"), Xe, "`voltro serve`");
889
- if (e.action === "fail") throw gn(e.message ?? "");
897
+ let e = _(S.serverOnlyLeaks, g(process.env, "strict"), Xe, "`voltro serve`");
898
+ if (e.action === "fail") throw _n(e.message ?? "");
890
899
  e.action === "warn" && $.warn(e.message ?? "");
891
900
  }
892
- let ve = b.filter((e) => Ae.test(e)), w = ve.length > 0 ? await ue(ve, $.child("webhooks")) : void 0, we = s({
901
+ let ve = x.filter((e) => le.test(e)), D = ve.length > 0 ? await te(ve, $.child("webhooks")) : void 0, Oe = s({
893
902
  mix: S.featureMix,
894
- plugins: g?.plugins ?? [],
895
- cdc: ce && le !== void 0,
896
- ...le ? { cdcDialect: le } : {}
897
- }), ke = g?.analytics !== void 0 && g.analytics.kind !== "noop" && _ !== "memory" ? (await n(_)).makeSqlLayer(T()) : void 0, D = await ie({
898
- spec: g?.analytics,
899
- sqlLayer: ke,
903
+ plugins: v?.plugins ?? [],
904
+ cdc: se && ce !== void 0,
905
+ ...ce ? { cdcDialect: ce } : {}
906
+ }), je = v?.analytics !== void 0 && v.analytics.kind !== "noop" && y !== "memory" ? (await n(y)).makeSqlLayer(E()) : void 0, O = await ae({
907
+ spec: v?.analytics,
908
+ sqlLayer: je,
900
909
  log: $
901
- }), O = (() => {
910
+ }), k = (() => {
902
911
  let e = new Set(S.tables.map((e) => e.tableName)), t = [...S.tables];
903
- for (let n of [...we, ...D.tables]) e.has(n.tableName) || (e.add(n.tableName), t.push(n));
912
+ for (let n of [...Oe, ...O.tables]) e.has(n.tableName) || (e.add(n.tableName), t.push(n));
904
913
  return t;
905
914
  })();
906
- for (let e of O) Mt(e);
915
+ for (let e of k) Mt(e);
907
916
  let Ne = (process.env.NODE_ENV ?? "").toLowerCase();
908
- if (Pn(Ne, _, process.env.VOLTRO_AUTO_MIGRATE)) {
909
- let e = (await n(_)).makeSqlLayer(T()), t = await j.runPromise(At.SqlClient.pipe(j.flatMap((e) => Qt(e, O, {
917
+ if (Fn(Ne, y, process.env.VOLTRO_AUTO_MIGRATE)) {
918
+ let e = (await n(y)).makeSqlLayer(E()), t = await j.runPromise(At.SqlClient.pipe(j.flatMap((e) => $t(e, k, {
910
919
  appliedBy: `serve:${Ne}`,
911
920
  environment: "prod",
912
- dialectId: _
921
+ dialectId: y
913
922
  })), j.provide(e)));
914
- t.kind === "prod-mismatch" && ($.error(Zt(t, _)), $.error("serve: refusing to boot — apply the schema first (voltro db apply in a pre-deploy step), or set VOLTRO_AUTO_MIGRATE=0 to bypass this check."), process.exit(1)), $.info(Zt(t, _));
923
+ t.kind === "prod-mismatch" && ($.error(Qt(t, y)), $.error("serve: refusing to boot — apply the schema first (voltro db apply in a pre-deploy step), or set VOLTRO_AUTO_MIGRATE=0 to bypass this check."), process.exit(1)), $.info(Qt(t, y));
915
924
  }
916
- let N = pt(O);
917
- p.mark("discover");
918
- let P = await x(g, void 0), ze = Ot(P, _);
919
- for (let e of E({
920
- dialect: String(g?.store ?? process.env.DB_DIALECT ?? "postgres"),
925
+ let N = mt(k);
926
+ m.mark("discover");
927
+ let P = await _e(v, void 0), ze = Ot(P, y);
928
+ for (let e of me({
929
+ dialect: String(v?.store ?? process.env.DB_DIALECT ?? "postgres"),
921
930
  changeStrategy: (process.env.CDC ?? "1") === "0" ? "inline" : "cdc",
922
931
  dbUrl: process.env.DB_URL,
923
932
  tables: S.tables.map((e) => ({
@@ -929,29 +938,29 @@ var hn = "VoltroBootRefusal", gn = (e) => {
929
938
  return t === void 0 ? [] : typeof t == "string" ? [t] : [...t];
930
939
  })
931
940
  })) e.level === "warn" ? $.warn(e.message) : $.info(e.message);
932
- g?.cache && !process.env.CACHE_BACKEND && (process.env.CACHE_BACKEND = g.cache), g?.cacheRedisUrl && !process.env.CACHE_REDIS_URL && (process.env.CACHE_REDIS_URL = g.cacheRedisUrl), g?.cacheRedisDriver && !process.env.CACHE_REDIS_DRIVER && (process.env.CACHE_REDIS_DRIVER = g.cacheRedisDriver), g?.cacheKeyPrefix && !process.env.CACHE_KEY_PREFIX && (process.env.CACHE_KEY_PREFIX = g.cacheKeyPrefix);
933
- let { service: Ve, invalidationBus: He, snapshotCache: We, cache: F, backend: Ge, dispose: I } = await xe({ env: process.env });
941
+ v?.cache && !process.env.CACHE_BACKEND && (process.env.CACHE_BACKEND = v.cache), v?.cacheRedisUrl && !process.env.CACHE_REDIS_URL && (process.env.CACHE_REDIS_URL = v.cacheRedisUrl), v?.cacheRedisDriver && !process.env.CACHE_REDIS_DRIVER && (process.env.CACHE_REDIS_DRIVER = v.cacheRedisDriver), v?.cacheKeyPrefix && !process.env.CACHE_KEY_PREFIX && (process.env.CACHE_KEY_PREFIX = v.cacheKeyPrefix);
942
+ let { service: Ve, invalidationBus: He, snapshotCache: We, cache: F, backend: Ge, dispose: I } = await Ce({ env: process.env });
934
943
  $.info(`cache backend resolved: ${Ge}` + (Ge === "redis" ? ` (driver ${process.env.CACHE_REDIS_DRIVER ?? "resp"})` : " — in-process, not cross-instance")), P.onChange((e) => {
935
944
  j.runFork(He.publish(e.table));
936
- }), g?.kv && !process.env.KV_BACKEND && (process.env.KV_BACKEND = g.kv), g?.kvRedisUrl && !process.env.KV_REDIS_URL && (process.env.KV_REDIS_URL = g.kvRedisUrl), g?.kvKeyPrefix && !process.env.KV_KEY_PREFIX && (process.env.KV_KEY_PREFIX = g.kvKeyPrefix);
945
+ }), v?.kv && !process.env.KV_BACKEND && (process.env.KV_BACKEND = v.kv), v?.kvRedisUrl && !process.env.KV_REDIS_URL && (process.env.KV_REDIS_URL = v.kvRedisUrl), v?.kvKeyPrefix && !process.env.KV_KEY_PREFIX && (process.env.KV_KEY_PREFIX = v.kvKeyPrefix);
937
946
  let { kv: Ke, service: qe } = await it({ store: P });
938
- p.mark("store");
947
+ m.mark("store");
939
948
  let Qe = Ue({
940
949
  store: P,
941
- sink: D.sink,
950
+ sink: O.sink,
942
951
  log: $
943
- }), $e = pe({
952
+ }), $e = be({
944
953
  store: P,
945
- dialect: _
946
- }), R = g?.plugins ?? [], ot = process.env.POD_NAME ?? process.env.HOSTNAME ?? `serve-${process.pid}`, st, ct;
947
- _ !== "memory" && (st = Le.make((await n(_)).makeSqlLayer(T())), ct = await st.runPromise(At.SqlClient));
954
+ dialect: y
955
+ }), R = v?.plugins ?? [], ot = process.env.POD_NAME ?? process.env.HOSTNAME ?? `serve-${process.pid}`, st, ct;
956
+ y !== "memory" && (st = Le.make((await n(y)).makeSqlLayer(E())), ct = await st.runPromise(At.SqlClient));
948
957
  let lt = at({
949
958
  coordinator: [
950
959
  "postgres",
951
960
  "mariadb",
952
961
  "mysql",
953
962
  "mssql"
954
- ].includes(_) ? et(P, ot, $) : Tt,
963
+ ].includes(y) ? et(P, ot, $) : Et,
955
964
  replicaId: ot,
956
965
  log: $
957
966
  }), ut = [], dt = {
@@ -966,68 +975,68 @@ var hn = "VoltroBootRefusal", gn = (e) => {
966
975
  if (ft.length > 0) {
967
976
  let e = P.changeScope ?? "local";
968
977
  P.onChange((t) => {
969
- let n = y(t, e);
978
+ let n = ne(t, e);
970
979
  for (let e of ft) j.runFork(e.onChangeEvent(n).pipe(j.catchAllCause((t) => j.sync(() => $.warn(`plugin ${e.name} onChangeEvent failed`, { error: Ie.pretty(t) })))));
971
980
  });
972
981
  }
973
- let mt = me({
982
+ let pt = Ae({
974
983
  plugins: R,
975
- appName: g?.name ?? "voltro-api",
984
+ appName: v?.name ?? "voltro-api",
976
985
  appType: "api",
977
986
  voltroVersion: process.env.npm_package_version ?? "0.0.0",
978
987
  log: $
979
988
  });
980
- R.length && await mt.activate(), p.mark("plugins");
981
- let ht = await mt.gatherObservability(), gt = await _e(P, g, _, {
989
+ R.length && await pt.activate(), m.mark("plugins");
990
+ let ht = await pt.gatherObservability(), gt = await ge(P, v, y, {
982
991
  info: (e, t) => process.stdout.write(`[broadcast] ${e} ${t ? JSON.stringify(t) : ""}\n`),
983
992
  warn: (e, t) => process.stderr.write(`[broadcast] ${e} ${t ? JSON.stringify(t) : ""}\n`),
984
993
  debug: () => {}
985
- }), z = g?.apiKeys, vt = (typeof z == "object" ? z.prefix : void 0) ?? "voltro_", yt = z ? Je(P) : void 0, xt = yt ? nt({ flush: rt(yt) }) : void 0;
986
- xt && _t(() => xt.shutdown());
987
- let Ct = yt ? tt(yt, {
988
- prefix: vt,
989
- ...xt ? { usage: xt } : {}
990
- }) : void 0, wt = Ct ? [Ze(Ct, { prefix: vt })] : [], Et = Ce([...g?.auth?.strategies ?? [], ...wt], $t(g?.plugins ?? []), g?.auth?.anonymousTenantRequired ?? !1, g?.auth?.resolveScopes, () => ze), Dt = [...g?.restRoutes ?? [], ...Ct ? Be(Ct, (typeof z == "object" ? z.managementPath : void 0) ?? "/v1/api-keys") : []], B = g?.idempotency, kt = B ? {
994
+ }), z = v?.apiKeys, _t = (typeof z == "object" ? z.prefix : void 0) ?? "voltro_", yt = z ? Je(P) : void 0, bt = yt ? nt({ flush: rt(yt) }) : void 0;
995
+ bt && vt(() => bt.shutdown());
996
+ let St = yt ? tt(yt, {
997
+ prefix: _t,
998
+ ...bt ? { usage: bt } : {}
999
+ }) : void 0, wt = St ? [Ze(St, { prefix: _t })] : [], Tt = Se([...v?.auth?.strategies ?? [], ...wt], en(v?.plugins ?? []), v?.auth?.anonymousTenantRequired ?? !1, v?.auth?.resolveScopes, () => ze), Dt = [...v?.restRoutes ?? [], ...St ? Be(St, (typeof z == "object" ? z.managementPath : void 0) ?? "/v1/api-keys") : []], B = v?.idempotency, V = B ? {
991
1000
  store: Ye(P),
992
1001
  header: (typeof B == "object" ? B.header : void 0) ?? "Idempotency-Key",
993
1002
  ttlMs: (typeof B == "object" ? B.ttlMs : void 0) ?? 864e5
994
- } : void 0, jt = Dt.length > 0 ? tn(Dt, {
1003
+ } : void 0, kt = Dt.length > 0 ? nn(Dt, {
995
1004
  store: P,
996
- resolveSubject: (e) => Et({
1005
+ resolveSubject: (e) => Tt({
997
1006
  headers: e,
998
1007
  clientId: -1
999
1008
  }),
1000
- ...kt ? { idempotency: kt } : {}
1001
- }) : [], V = R.map((e) => e.services).filter((e) => e !== void 0), Nt = M.mergeAll(Ee({
1002
- analyticsLayer: D.layer,
1009
+ ...V ? { idempotency: V } : {}
1010
+ }) : [], jt = R.map((e) => e.services).filter((e) => e !== void 0), H = M.mergeAll(T({
1011
+ analyticsLayer: O.layer,
1003
1012
  cacheService: Ve,
1004
1013
  kvService: qe,
1005
- pluginServices: V,
1006
- userLayers: g?.layers ?? []
1007
- }), ge(g?.http ?? {})), H = g?.scheduling ?? {}, Pt = H.trigger ?? "self", Ft = /* @__PURE__ */ new Set([
1014
+ pluginServices: jt,
1015
+ userLayers: v?.layers ?? []
1016
+ }), Te(v?.http ?? {})), Nt = v?.scheduling ?? {}, U = Nt.trigger ?? "self", Pt = /* @__PURE__ */ new Set([
1008
1017
  "postgres",
1009
1018
  "mysql",
1010
1019
  "mariadb",
1011
1020
  "mssql"
1012
- ]), It = H.coordination ?? (Ft.has(_) ? "advisoryLock" : "single"), U = It === "cluster" && Ft.has(_), Lt = U ? "cluster" : It === "advisoryLock" && Ft.has(_) ? "advisoryLock" : "single";
1013
- It === "cluster" && !U && $.warn("scheduling.coordination=cluster needs a sql-backed store except sqlite — falling back to single"), It === "advisoryLock" && !Ft.has(_) && $.warn("scheduling.coordination=advisoryLock needs a SQL store (the claim-row gate) — falling back to single");
1014
- let W, G = S.workflows.length > 0 || S.workflowWorkers.length > 0 || S.eventTriggers.length > 0 || (w?.outgoing.length ?? 0) > 0 || U, Rt;
1015
- if (G) {
1016
- if (_ === "mssql") {
1017
- let e = await fe(process.cwd());
1021
+ ]), Ft = Nt.coordination ?? (Pt.has(y) ? "advisoryLock" : "single"), W = Ft === "cluster" && Pt.has(y), It = W ? "cluster" : Ft === "advisoryLock" && Pt.has(y) ? "advisoryLock" : "single";
1022
+ Ft === "cluster" && !W && $.warn("scheduling.coordination=cluster needs a sql-backed store except sqlite — falling back to single"), Ft === "advisoryLock" && !Pt.has(y) && $.warn("scheduling.coordination=advisoryLock needs a SQL store (the claim-row gate) — falling back to single");
1023
+ let G, Lt = S.workflows.length > 0 || S.workflowWorkers.length > 0 || S.eventTriggers.length > 0 || (D?.outgoing.length ?? 0) > 0 || W, K;
1024
+ if (Lt) {
1025
+ if (y === "mssql") {
1026
+ let e = await re(process.cwd());
1018
1027
  e && $.warn(e);
1019
1028
  }
1020
- let [{ WorkflowEngine: e }, { makeClusterCronLayer: t, workflowEngineLayer: r, resolveRunnerStorage: i }] = await Promise.all([import("@effect/workflow"), import("@voltro/workflow/cluster")]), a = U ? S.schedules.filter((e) => (e.trigger ?? Pt) === "self").map((e) => t({
1029
+ let [{ WorkflowEngine: e }, { makeClusterCronLayer: t, workflowEngineLayer: r, resolveRunnerStorage: i }] = await Promise.all([import("@effect/workflow"), import("@voltro/workflow/cluster")]), a = W ? S.schedules.filter((e) => (e.trigger ?? U) === "self").map((e) => t({
1021
1030
  name: e.name,
1022
1031
  cron: L(e),
1023
1032
  execute: async () => {
1024
- await W?.fireFromCluster(e.name);
1033
+ await G?.fireFromCluster(e.name);
1025
1034
  }
1026
1035
  })) : [];
1027
- Rt = _ === "memory" ? e.layerMemory : await (async () => {
1028
- let e = await n(_), t = i({ sqliteFamily: e.id === "sqlite" || e.id === "turso" });
1036
+ K = y === "memory" ? e.layerMemory : await (async () => {
1037
+ let e = await n(y), t = i({ sqliteFamily: e.id === "sqlite" || e.id === "turso" });
1029
1038
  return $.info(`workflow engine: cluster-${t}, dialect=${e.id}` + (t === "memory" ? " — single-process durable replay, no cross-pod shard handoff" + (e.id !== "sqlite" && e.id !== "turso" ? " (VOLTRO_WORKFLOW_RUNNER_STORAGE=memory: SqlRunnerStorage/cluster_runners + GET_LOCK skipped)" : "") : "")), r({
1030
- sqlClientLayer: e.makeSqlLayer(T()),
1039
+ sqlClientLayer: e.makeSqlLayer(E()),
1031
1040
  runnerStorage: t,
1032
1041
  dialectId: e.id,
1033
1042
  ...process.env.VOLTRO_WORKFLOW_RUNNER_PORT ? { runnerListenPort: Number(process.env.VOLTRO_WORKFLOW_RUNNER_PORT) } : {},
@@ -1035,47 +1044,51 @@ var hn = "VoltroBootRefusal", gn = (e) => {
1035
1044
  });
1036
1045
  })();
1037
1046
  }
1038
- let zt = je(R, t()), Bt = b.filter((e) => /\.subscribe\.tsx?$/.test(e)), K = Bt.length > 0 ? await ae(Bt, $) : [], Vt = b.filter((e) => /\.reaction\.tsx?$/.test(e)), Ht = Vt.length > 0 ? await se(Vt, $) : [], q = b.filter((e) => u.test(e)), Ut = q.length > 0 ? await Me(q, $) : [], J = b.filter((e) => /\.aggregate\.tsx?$/.test(e)), Y = J.length > 0 ? await v(J, $) : [], X = ye();
1039
- if (Y.length > 0 && _ !== "memory") try {
1040
- X = f((await n(_)).makeSqlLayer(T()));
1047
+ let Rt = fe(R, t()), zt = x.filter((e) => /\.subscribe\.tsx?$/.test(e)), Bt = zt.length > 0 ? await ue(zt, $) : [], q = x.filter((e) => /\.reaction\.tsx?$/.test(e)), Vt = q.length > 0 ? await b(q, $) : [], Ht = x.filter((e) => u.test(e)), Ut = Ht.length > 0 ? await p(Ht, $) : [], J = x.filter((e) => /\.aggregate\.tsx?$/.test(e)), Wt = J.length > 0 ? await w(J, $) : [], Y = f();
1048
+ if (Wt.length > 0 && y !== "memory") try {
1049
+ Y = ye((await n(y)).makeSqlLayer(E()));
1041
1050
  } catch (e) {
1042
1051
  $.warn("aggregate: SQL storage init failed — falling back to in-process", { err: String(e) });
1043
1052
  }
1044
- let Wt = _ === "memory" ? Tt : et(P, `aggregate@${process.pid}`, $), Z = [], Gt = [], Kt = b.filter((e) => l.test(e));
1053
+ let Gt = y === "memory" ? Et : et(P, `aggregate@${process.pid}`, $), X = [], Z = [], Kt = x.filter((e) => l.test(e));
1045
1054
  if (Kt.length > 0) {
1046
- let e = $.child("agent"), t = b.filter((e) => a.test(e));
1055
+ let e = $.child("agent"), t = x.filter((e) => a.test(e));
1047
1056
  t.length > 0 && await o(t, e);
1048
1057
  let n = await c(Kt, e);
1049
- for (let e of n.agents) for (let t of te(e)) (t.kind === "action" ? Z : Gt).push({
1058
+ for (let e of n.agents) for (let t of ke(e)) (t.kind === "action" ? X : Z).push({
1050
1059
  file: t.file,
1051
1060
  descriptor: t.descriptor,
1052
1061
  executor: t.executor
1053
1062
  });
1054
1063
  n.agents.length > 0 && e.info("synthesized agent routes", { agents: n.agents.map((e) => e.descriptor.name) });
1055
1064
  }
1056
- p.mark("workflow");
1057
- let Jt = await Nn({
1058
- bootTiming: p,
1065
+ m.mark("workflow");
1066
+ let qt = await Pn({
1067
+ bootTiming: m,
1068
+ ...V ? { idempotency: {
1069
+ store: V.store,
1070
+ ttlMs: V.ttlMs
1071
+ } } : {},
1059
1072
  discovered: {
1060
- queries: [...S.queries, ...Gt],
1073
+ queries: [...S.queries, ...Z],
1061
1074
  mutations: S.mutations,
1062
- actions: [...S.actions, ...Z],
1075
+ actions: [...S.actions, ...X],
1063
1076
  streams: S.streams,
1064
1077
  workflows: S.workflows,
1065
1078
  workflowWorkers: S.workflowWorkers,
1066
1079
  eventTriggers: S.eventTriggers,
1067
1080
  schedules: S.schedules,
1068
- subscribers: K,
1081
+ subscribers: Bt,
1069
1082
  outboxHandlers: Ut,
1070
1083
  connections: S.connections,
1071
- reactions: Ht,
1072
- aggregates: Y,
1073
- ...w === void 0 ? {} : { webhooks: w }
1084
+ reactions: Vt,
1085
+ aggregates: Wt,
1086
+ ...D === void 0 ? {} : { webhooks: D }
1074
1087
  },
1075
1088
  log: $,
1076
- analytics: D.sink,
1077
- aggregateStorage: X,
1078
- aggregateCoordinator: Wt,
1089
+ analytics: O.sink,
1090
+ aggregateStorage: Y,
1091
+ aggregateCoordinator: Gt,
1079
1092
  store: P,
1080
1093
  kv: Ke,
1081
1094
  cache: F,
@@ -1083,41 +1096,41 @@ var hn = "VoltroBootRefusal", gn = (e) => {
1083
1096
  schemaRegistry: N,
1084
1097
  tenantScopedTables: S.tenantScopedTables,
1085
1098
  softDeleteScopedTables: S.softDeleteScopedTables,
1086
- dataTransferSnapshot: Xt(O),
1087
- dataTransferDialect: _,
1088
- tenantIsolation: (process.env.VOLTRO_TENANT_ISOLATION ?? g?.tenancy?.isolation) === "namespace" ? "namespace" : "shared-schema",
1089
- resolveSubject: (e, t) => Et({
1099
+ dataTransferSnapshot: Zt(k),
1100
+ dataTransferDialect: y,
1101
+ tenantIsolation: (process.env.VOLTRO_TENANT_ISOLATION ?? v?.tenancy?.isolation) === "namespace" ? "namespace" : "shared-schema",
1102
+ resolveSubject: (e, t) => Tt({
1090
1103
  headers: e,
1091
1104
  clientId: t
1092
1105
  }),
1093
- httpRoutes: [...R.flatMap((e) => e.httpRoutes ?? []), ...jt],
1106
+ httpRoutes: [...R.flatMap((e) => e.httpRoutes ?? []), ...kt],
1094
1107
  getStore: () => ze,
1095
- ...Nt ? { baseLayer: Nt } : {},
1096
- ...Rt === void 0 ? {} : { workflowEngineLayer: Rt },
1097
- scheduleDefaultTrigger: Pt,
1098
- scheduleCoordination: Lt,
1099
- scheduleArmSelf: !U,
1100
- dormancy: process.env.VOLTRO_DORMANCY === "sleep" || process.env.VOLTRO_DORMANCY === "always-on" ? process.env.VOLTRO_DORMANCY : g?.dormancy ?? "always-on",
1108
+ ...H ? { baseLayer: H } : {},
1109
+ ...K === void 0 ? {} : { workflowEngineLayer: K },
1110
+ scheduleDefaultTrigger: U,
1111
+ scheduleCoordination: It,
1112
+ scheduleArmSelf: !W,
1113
+ dormancy: process.env.VOLTRO_DORMANCY === "sleep" || process.env.VOLTRO_DORMANCY === "always-on" ? process.env.VOLTRO_DORMANCY : v?.dormancy ?? "always-on",
1101
1114
  scheduleReplicaId: process.env.HOSTNAME ?? `pid-${process.pid}`,
1102
- ...zt === void 0 ? {} : { scheduleFireInterceptor: zt },
1115
+ ...Rt === void 0 ? {} : { scheduleFireInterceptor: Rt },
1103
1116
  onSchedulerReady: (e) => {
1104
- W = e;
1117
+ G = e;
1105
1118
  },
1106
1119
  inspectRoute: { handle: (e, t, n, r) => d(e, {
1107
1120
  kind: "api",
1108
1121
  meta: {
1109
- name: g?.name ?? "voltro-api",
1110
- voltroVersion: Te,
1111
- port: ne,
1122
+ name: v?.name ?? "voltro-api",
1123
+ voltroVersion: we,
1124
+ port: oe,
1112
1125
  mode: "start",
1113
- store: _,
1114
- cdc: ce ? "on" : "off"
1126
+ store: y,
1127
+ cdc: se ? "on" : "off"
1115
1128
  },
1116
- rpc: be(S, m),
1117
- workflows: Oe(S, m),
1129
+ rpc: De(S, h),
1130
+ workflows: he(S, h),
1118
1131
  inspectFireSchedule: async ({ name: e, trigger: t }) => {
1119
- if (!W) throw Error("scheduler not started — this app registers no self-triggered schedules (all schedules are trigger:'external', or there are none).");
1120
- return { runId: await W.fireNow(e, t) ?? null };
1132
+ if (!G) throw Error("scheduler not started — this app registers no self-triggered schedules (all schedules are trigger:'external', or there are none).");
1133
+ return { runId: await G.fireNow(e, t) ?? null };
1121
1134
  }
1122
1135
  }, t, {
1123
1136
  method: n,
@@ -1128,18 +1141,18 @@ var hn = "VoltroBootRefusal", gn = (e) => {
1128
1141
  body: JSON.stringify({ error: "not an inspect route" })
1129
1142
  } },
1130
1143
  observability: ht,
1131
- port: ne,
1132
- ...g?.transport?.wsPath ? { path: g.transport.wsPath } : {}
1144
+ port: oe,
1145
+ ...v?.transport?.wsPath ? { path: v.transport.wsPath } : {}
1133
1146
  });
1134
- return Se(oe([
1147
+ return ie(xe([
1135
1148
  S.queries,
1136
1149
  S.mutations,
1137
1150
  S.actions,
1138
1151
  S.streams
1139
1152
  ]), (e) => {
1140
1153
  $.warn(e);
1141
- }), $.info(`API listening on :${ne}`, {
1142
- dialect: _,
1154
+ }), $.info(`API listening on :${oe}`, {
1155
+ dialect: y,
1143
1156
  queries: S.queries.length,
1144
1157
  mutations: S.mutations.length,
1145
1158
  actions: S.actions.length,
@@ -1147,16 +1160,16 @@ var hn = "VoltroBootRefusal", gn = (e) => {
1147
1160
  workflows: S.workflows.length,
1148
1161
  workflowWorkers: S.workflowWorkers.length,
1149
1162
  schedules: S.schedules.length,
1150
- scheduleCoordination: Lt
1151
- }), p.finish($), _t(async () => {
1163
+ scheduleCoordination: It
1164
+ }), m.finish($), vt(async () => {
1152
1165
  for (let e of ut) e.stop();
1153
1166
  Qe.detach(), $e.stop(), I(), st?.dispose();
1154
1167
  try {
1155
- await mt.deactivate(), await gt?.close(), await D.dispose(), await Jt.close(), await P.close?.();
1168
+ await pt.deactivate(), await gt?.close(), await O.dispose(), await qt.close(), await P.close?.();
1156
1169
  } catch (e) {
1157
1170
  console.error("serve: shutdown step failed, exiting anyway:", e);
1158
1171
  }
1159
1172
  }), await new Promise(() => {}), 0;
1160
1173
  };
1161
1174
  //#endregion
1162
- export { In as n, An as r, Ln as t };
1175
+ export { Ln as n, jn as r, Rn as t };