@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.
- package/CHANGELOG.md +111 -0
- package/bin/voltro.mjs +39 -4
- package/dist/{apiBuild-JQtIhZPy.js → apiBuild-B2m4XK_8.js} +44 -22
- package/dist/apiBuild-UEM3QBke.js +2 -0
- package/dist/bin.js +2 -2
- package/dist/{commands-Bsu9Buln.js → commands-CaIhTsC2.js} +2565 -2444
- package/dist/{dbCommand-GI7-BVZt.js → dbCommand-CC61CsAc.js} +248 -218
- package/dist/dbCommand-Cr__4ATv.js +2 -0
- package/dist/{dev-DRxF_qOB.js → dev-DPkQVUTP.js} +1 -1
- package/dist/{dev-jM07kq_D.js → dev-NCuEhNxs.js} +1039 -1021
- package/dist/index.js +1 -1
- package/dist/{serveCommand-Cl8sicD5.js → serveCommand-C4gzDZzc.js} +349 -336
- package/dist/serveEntry.js +1 -1
- package/package.json +17 -17
- package/templates/agent-docs/authentication.md +21 -0
- package/templates/agent-docs/cli.md +17 -0
- package/templates/agent-docs/data.md +185 -165
- package/templates/agent-docs/database/migrations.md +92 -63
- package/templates/agent-docs/database/seedsdialects.md +12 -0
- package/templates/agent-docs/deployment.md +66 -1
- package/templates/agent-docs/workflows.md +30 -0
- package/templates/apps/api-ai/package.json +8 -7
- package/templates/apps/api-auth/package.json +9 -8
- package/templates/apps/api-backend/package.json +8 -7
- package/templates/apps/api-backend-deactivation/package.json +8 -7
- package/templates/apps/api-backend-mail/package.json +9 -8
- package/templates/apps/api-backend-mariadb/package.json +10 -9
- package/templates/apps/api-backend-storage/package.json +9 -8
- package/templates/apps/api-data-advanced/package.json +9 -8
- package/templates/apps/api-durable/package.json +9 -8
- package/templates/apps/api-feature-flags/package.json +10 -9
- package/templates/apps/api-governance/package.json +9 -8
- package/templates/apps/api-kv/package.json +9 -8
- package/templates/apps/api-moderation/package.json +9 -8
- package/templates/apps/api-observability/package.json +9 -8
- package/templates/apps/api-ratelimit/package.json +9 -8
- package/templates/apps/api-rbac/package.json +9 -8
- package/templates/apps/api-rest/package.json +8 -7
- package/templates/apps/api-saas/package.json +12 -11
- package/templates/apps/api-search/package.json +9 -8
- package/templates/apps/api-versioning/package.json +9 -8
- package/templates/apps/api-webhooks/package.json +10 -9
- package/templates/apps/changelog/package.json +7 -6
- package/templates/apps/edge-functions/package.json +3 -2
- package/templates/apps/frontend-admin/package.json +9 -8
- package/templates/apps/frontend-app/package.json +9 -8
- package/templates/apps/frontend-blank/package.json +8 -7
- package/templates/apps/frontend-contact/package.json +8 -7
- package/templates/apps/frontend-contact/src/globals.d.ts +6 -0
- package/templates/apps/frontend-dashboard/package.json +8 -7
- package/templates/apps/frontend-docs/package.json +8 -7
- package/templates/apps/frontend-docs/src/globals.d.ts +6 -0
- package/templates/apps/frontend-i18n/package.json +7 -6
- package/templates/apps/frontend-landing/package.json +8 -7
- package/templates/apps/frontend-landing/src/globals.d.ts +6 -0
- package/templates/apps/frontend-spa/package.json +8 -7
- package/templates/apps/frontend-spa/src/globals.d.ts +6 -0
- package/templates/apps/frontend-ssr/package.json +8 -7
- package/templates/apps/frontend-ssr/src/globals.d.ts +6 -0
- package/templates/apps/frontend-ssr-api/package.json +9 -8
- package/templates/apps/frontend-static-blog/package.json +7 -6
- package/templates/apps/frontend-static-blog/src/globals.d.ts +6 -0
- package/dist/apiBuild-CD-4JLLA.js +0 -2
- 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 {
|
|
8
|
-
import {
|
|
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,
|
|
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
|
|
20
|
-
import { appStorageProvider as
|
|
21
|
-
import { AuthMiddleware as
|
|
22
|
-
import { assertProductionSessionSecret as
|
|
23
|
-
import { createHash as
|
|
24
|
-
import { declaredSnapshot as
|
|
25
|
-
import { getAuthSessionStrategy as
|
|
26
|
-
import { collectPublicApiRoutes as
|
|
27
|
-
import { buildDeliverWebhookExecute as
|
|
28
|
-
import { packBundle as
|
|
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
|
|
30
|
+
var gn = "VoltroBootRefusal", _n = (e) => {
|
|
31
31
|
let t = Error(e);
|
|
32
|
-
return t.name =
|
|
33
|
-
},
|
|
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
|
-
}),
|
|
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
|
-
},
|
|
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 =
|
|
44
|
-
return !n || !
|
|
45
|
-
},
|
|
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
|
-
},
|
|
48
|
-
let n =
|
|
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") ===
|
|
51
|
-
if (s) c =
|
|
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"),
|
|
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
|
|
66
|
-
dir:
|
|
65
|
+
e.assetSink ? await mn(c, {
|
|
66
|
+
dir: p,
|
|
67
67
|
blobs: e.assetSink
|
|
68
|
-
}) : await
|
|
69
|
-
let t = await j.runPromiseExit(
|
|
68
|
+
}) : await hn(c, p);
|
|
69
|
+
let t = await j.runPromiseExit(dn({
|
|
70
70
|
store: e.store,
|
|
71
|
-
bundleDir:
|
|
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) =>
|
|
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
|
|
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
|
|
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
|
|
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(
|
|
119
|
+
await d.rm(p, {
|
|
120
120
|
recursive: !0,
|
|
121
121
|
force: !0
|
|
122
122
|
});
|
|
123
123
|
}
|
|
124
|
-
},
|
|
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
|
-
},
|
|
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" },
|
|
135
|
-
let n =
|
|
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 ??
|
|
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(
|
|
157
|
+
let t = await j.runPromise(un({
|
|
158
158
|
store: e.store,
|
|
159
159
|
snapshot: e.snapshot,
|
|
160
160
|
dialect: e.dialect,
|
|
161
|
-
outDir:
|
|
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, () =>
|
|
174
|
-
dir:
|
|
173
|
+
return await e.putArchive(i, () => ln({
|
|
174
|
+
dir: p,
|
|
175
175
|
...l
|
|
176
|
-
})),
|
|
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
|
|
191
|
-
dir:
|
|
190
|
+
let d = await On(ln({
|
|
191
|
+
dir: p,
|
|
192
192
|
...l
|
|
193
193
|
}));
|
|
194
|
-
return
|
|
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
|
|
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(
|
|
216
|
+
await d.rm(p, {
|
|
217
217
|
recursive: !0,
|
|
218
218
|
force: !0
|
|
219
219
|
});
|
|
220
220
|
}
|
|
221
|
-
},
|
|
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
|
-
},
|
|
233
|
-
let r = await
|
|
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
|
-
})(),
|
|
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
|
-
},
|
|
252
|
-
|
|
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) =>
|
|
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 ??
|
|
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:
|
|
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:
|
|
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,
|
|
322
|
-
if (
|
|
323
|
-
let t = e.workflowEngineLayer, i =
|
|
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 =
|
|
329
|
-
|
|
330
|
-
let n =
|
|
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
|
-
|
|
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
|
|
340
|
-
if (
|
|
341
|
-
let t = e.descriptor.path ??
|
|
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 :
|
|
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 ?
|
|
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
|
-
|
|
358
|
+
ie.set(t, { handle: r });
|
|
359
359
|
}
|
|
360
|
-
Qe(),
|
|
361
|
-
let
|
|
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,
|
|
365
|
+
}) : void 0, _ = O({
|
|
366
366
|
definitions: (e.discovered.connections ?? []).map((e) => e.definition),
|
|
367
367
|
store: e.store,
|
|
368
|
-
publicUrl:
|
|
368
|
+
publicUrl: se(e.port ?? 4e3),
|
|
369
369
|
log: (e.log ?? N({ scope: "voltro:serve" })).child("connections")
|
|
370
|
-
}),
|
|
370
|
+
}), b = ve({
|
|
371
371
|
store: e.store,
|
|
372
372
|
schemaRegistry: e.schemaRegistry,
|
|
373
373
|
cache: n,
|
|
374
374
|
kv: r,
|
|
375
|
-
...
|
|
375
|
+
...re === void 0 ? {} : { webhooksService: re },
|
|
376
376
|
...d === void 0 ? {} : { workflowsProxy: d },
|
|
377
377
|
eventTriggers: e.discovered.eventTriggers ?? [],
|
|
378
|
-
namespaceIsolationOn:
|
|
379
|
-
...
|
|
380
|
-
...
|
|
381
|
-
}),
|
|
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(
|
|
384
|
-
},
|
|
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) =>
|
|
387
|
-
runEffect:
|
|
388
|
-
undoCapture:
|
|
389
|
-
}),
|
|
390
|
-
buildContext: (e) =>
|
|
391
|
-
runEffect:
|
|
392
|
-
}),
|
|
393
|
-
buildContext: (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:
|
|
396
|
-
},
|
|
397
|
-
...
|
|
395
|
+
provideEffect: ue
|
|
396
|
+
}, C = dt(ge), _e = ut({
|
|
397
|
+
...ge,
|
|
398
398
|
queryRows: (t) => e.store.query(t)
|
|
399
|
-
}),
|
|
400
|
-
...
|
|
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
|
-
}),
|
|
403
|
+
}), w = (e) => e.filter((e) => zt(e.descriptor)), T = {};
|
|
404
404
|
for (let n of [
|
|
405
|
-
...
|
|
406
|
-
...
|
|
407
|
-
...
|
|
408
|
-
]) T[n.descriptor.name] = (e) => I(
|
|
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
|
-
...
|
|
411
|
-
...
|
|
412
|
-
...
|
|
413
|
-
])
|
|
414
|
-
|
|
415
|
-
|
|
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) =>
|
|
424
|
+
invoke: (t, n) => _e(e, t, {
|
|
419
425
|
subject: n.subject,
|
|
420
|
-
traceId:
|
|
426
|
+
traceId: E()
|
|
421
427
|
}),
|
|
422
|
-
subscribe: (t, n, r) =>
|
|
428
|
+
subscribe: (t, n, r) => ye(e, t, {
|
|
423
429
|
subject: n.subject,
|
|
424
|
-
traceId:
|
|
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) =>
|
|
435
|
+
invoke: (t, n) => pe(e, t, {
|
|
430
436
|
subject: n.subject,
|
|
431
|
-
traceId:
|
|
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) =>
|
|
442
|
+
invoke: (t, n) => he(e, t, {
|
|
437
443
|
subject: n.subject,
|
|
438
|
-
traceId:
|
|
444
|
+
traceId: E()
|
|
439
445
|
})
|
|
440
446
|
}))
|
|
441
|
-
],
|
|
447
|
+
], xe = be.length > 0 ? nn(tn(be), {
|
|
442
448
|
store: e.store,
|
|
443
449
|
resolveSubject: (t) => e.resolveSubject(t, -1)
|
|
444
|
-
}) : [],
|
|
450
|
+
}) : [], Se = e.dataTransferSecret ?? process.env.VOLTRO_DATA_TRANSFER_SECRET, Ce = Se && Se.length >= 16 ? [{
|
|
445
451
|
method: "POST",
|
|
446
|
-
path:
|
|
447
|
-
handle:
|
|
448
|
-
secret:
|
|
452
|
+
path: vn,
|
|
453
|
+
handle: En({
|
|
454
|
+
secret: Se,
|
|
449
455
|
store: e.store,
|
|
450
456
|
...e.dataTransferSnapshot ? { snapshot: e.dataTransferSnapshot } : {},
|
|
451
|
-
assetSink:
|
|
452
|
-
openArchive: (e) =>
|
|
457
|
+
assetSink: fn(U()),
|
|
458
|
+
openArchive: (e) => Mn(U(), e)
|
|
453
459
|
})
|
|
454
460
|
}, {
|
|
455
461
|
method: "POST",
|
|
456
|
-
path:
|
|
457
|
-
handle:
|
|
458
|
-
secret:
|
|
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:
|
|
464
|
-
assetSource:
|
|
469
|
+
loadProfile: jn,
|
|
470
|
+
assetSource: pn(U(), e.store),
|
|
465
471
|
putArchive: async (e, t) => {
|
|
466
|
-
let { Readable: n } = await import("node:stream"), r =
|
|
467
|
-
await j.runPromise(
|
|
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
|
-
}] : [],
|
|
476
|
+
}] : [], we = [
|
|
471
477
|
...e.httpRoutes ?? [],
|
|
478
|
+
...xe,
|
|
472
479
|
...Ce,
|
|
473
|
-
...
|
|
474
|
-
...v.httpRoutes
|
|
480
|
+
..._.httpRoutes
|
|
475
481
|
];
|
|
476
|
-
for (let t of
|
|
477
|
-
let 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(
|
|
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
|
|
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[
|
|
493
|
-
descriptor:
|
|
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(
|
|
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.${
|
|
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 ? [] : [
|
|
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[
|
|
525
|
-
descriptor:
|
|
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:
|
|
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.${
|
|
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:
|
|
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[
|
|
557
|
-
descriptor:
|
|
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 :
|
|
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.${
|
|
573
|
-
descriptor:
|
|
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:
|
|
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.${
|
|
594
|
+
}, e), t, `subscription.${J.name}`), T[Ht.name] = (t) => F(async (t, n) => {
|
|
589
595
|
let r = t;
|
|
590
|
-
return await
|
|
591
|
-
}, t, `action.${Ht.name}`), T[
|
|
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
|
|
594
|
-
}, t, `action.${
|
|
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
|
|
597
|
-
}, t, `action.${
|
|
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
|
|
600
|
-
}, t, `action.${
|
|
601
|
-
let
|
|
602
|
-
...
|
|
603
|
-
...
|
|
604
|
-
...
|
|
605
|
-
...
|
|
606
|
-
...
|
|
607
|
-
...
|
|
608
|
-
...
|
|
609
|
-
...
|
|
610
|
-
...
|
|
611
|
-
...(e.discovered.workflows ?? []).map((e) =>
|
|
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
|
-
|
|
614
|
-
|
|
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(
|
|
617
|
-
K(
|
|
618
|
-
K(Ut),
|
|
619
|
-
G(Ht),
|
|
620
|
-
G(J),
|
|
621
|
-
G(Gt),
|
|
622
|
-
G(Kt)
|
|
627
|
+
K(Kt),
|
|
628
|
+
K(qt)
|
|
623
629
|
] : []
|
|
624
|
-
],
|
|
625
|
-
|
|
626
|
-
|
|
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 ??
|
|
641
|
+
tenantId: n ?? Ae,
|
|
633
642
|
kind: "workflow",
|
|
634
643
|
refId: t
|
|
635
644
|
}).then(() => {})
|
|
636
|
-
} : void 0, k =
|
|
645
|
+
} : void 0, k = p ? await import("@voltro/workflow") : void 0, A = k?.makeWorkflowRunRecorder({
|
|
637
646
|
store: e.store,
|
|
638
|
-
...
|
|
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:
|
|
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 = [...
|
|
681
|
-
buildContext: (t, n) => e.buildContextForWorkflow?.(t, n) ??
|
|
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 ?
|
|
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) =>
|
|
733
|
-
retry: (t, n) =>
|
|
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(
|
|
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 } =
|
|
746
|
-
group:
|
|
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
|
-
...
|
|
766
|
+
...we.length > 0 ? { httpRoutes: we } : {},
|
|
758
767
|
...e.getStore === void 0 ? {} : { getStore: e.getStore },
|
|
759
|
-
...
|
|
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}`) :
|
|
764
|
-
o = await
|
|
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 }) =>
|
|
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 =
|
|
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 =
|
|
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
|
|
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
|
|
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(
|
|
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
|
|
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
|
-
}),
|
|
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" }),
|
|
847
|
-
let t =
|
|
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
|
|
859
|
-
},
|
|
860
|
-
let
|
|
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
|
-
|
|
872
|
+
Jt();
|
|
864
873
|
} catch (e) {
|
|
865
|
-
throw
|
|
874
|
+
throw _n(e instanceof Error ? e.message : String(e));
|
|
866
875
|
}
|
|
867
|
-
let
|
|
868
|
-
|
|
869
|
-
rawEnv:
|
|
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:
|
|
880
|
+
root: h,
|
|
872
881
|
log: $,
|
|
873
882
|
generateTypes: !1
|
|
874
|
-
}),
|
|
875
|
-
let
|
|
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(
|
|
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
|
|
895
|
+
let x = await C(h), S = await Ee(x, { cdc: se && ce !== void 0 });
|
|
887
896
|
{
|
|
888
|
-
let e =
|
|
889
|
-
if (e.action === "fail") throw
|
|
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 =
|
|
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:
|
|
895
|
-
cdc:
|
|
896
|
-
...
|
|
897
|
-
}),
|
|
898
|
-
spec:
|
|
899
|
-
sqlLayer:
|
|
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
|
-
}),
|
|
910
|
+
}), k = (() => {
|
|
902
911
|
let e = new Set(S.tables.map((e) => e.tableName)), t = [...S.tables];
|
|
903
|
-
for (let n of [...
|
|
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
|
|
915
|
+
for (let e of k) Mt(e);
|
|
907
916
|
let Ne = (process.env.NODE_ENV ?? "").toLowerCase();
|
|
908
|
-
if (
|
|
909
|
-
let e = (await n(
|
|
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(
|
|
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 =
|
|
917
|
-
|
|
918
|
-
let P = await
|
|
919
|
-
for (let e of
|
|
920
|
-
dialect: String(
|
|
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
|
-
|
|
933
|
-
let { service: Ve, invalidationBus: He, snapshotCache: We, cache: F, backend: Ge, dispose: I } = await
|
|
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
|
-
}),
|
|
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
|
-
|
|
947
|
+
m.mark("store");
|
|
939
948
|
let Qe = Ue({
|
|
940
949
|
store: P,
|
|
941
|
-
sink:
|
|
950
|
+
sink: O.sink,
|
|
942
951
|
log: $
|
|
943
|
-
}), $e =
|
|
952
|
+
}), $e = be({
|
|
944
953
|
store: P,
|
|
945
|
-
dialect:
|
|
946
|
-
}), R =
|
|
947
|
-
|
|
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(
|
|
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 =
|
|
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
|
|
982
|
+
let pt = Ae({
|
|
974
983
|
plugins: R,
|
|
975
|
-
appName:
|
|
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
|
|
981
|
-
let ht = await
|
|
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 =
|
|
986
|
-
|
|
987
|
-
let
|
|
988
|
-
prefix:
|
|
989
|
-
...
|
|
990
|
-
}) : void 0, wt =
|
|
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,
|
|
1003
|
+
} : void 0, kt = Dt.length > 0 ? nn(Dt, {
|
|
995
1004
|
store: P,
|
|
996
|
-
resolveSubject: (e) =>
|
|
1005
|
+
resolveSubject: (e) => Tt({
|
|
997
1006
|
headers: e,
|
|
998
1007
|
clientId: -1
|
|
999
1008
|
}),
|
|
1000
|
-
...
|
|
1001
|
-
}) : [],
|
|
1002
|
-
analyticsLayer:
|
|
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:
|
|
1006
|
-
userLayers:
|
|
1007
|
-
}),
|
|
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
|
-
]),
|
|
1013
|
-
|
|
1014
|
-
let
|
|
1015
|
-
if (
|
|
1016
|
-
if (
|
|
1017
|
-
let e = await
|
|
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 =
|
|
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
|
|
1033
|
+
await G?.fireFromCluster(e.name);
|
|
1025
1034
|
}
|
|
1026
1035
|
})) : [];
|
|
1027
|
-
|
|
1028
|
-
let e = await n(
|
|
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(
|
|
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
|
|
1039
|
-
if (
|
|
1040
|
-
|
|
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
|
|
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 =
|
|
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
|
|
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
|
-
|
|
1057
|
-
let
|
|
1058
|
-
bootTiming:
|
|
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, ...
|
|
1073
|
+
queries: [...S.queries, ...Z],
|
|
1061
1074
|
mutations: S.mutations,
|
|
1062
|
-
actions: [...S.actions, ...
|
|
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:
|
|
1081
|
+
subscribers: Bt,
|
|
1069
1082
|
outboxHandlers: Ut,
|
|
1070
1083
|
connections: S.connections,
|
|
1071
|
-
reactions:
|
|
1072
|
-
aggregates:
|
|
1073
|
-
...
|
|
1084
|
+
reactions: Vt,
|
|
1085
|
+
aggregates: Wt,
|
|
1086
|
+
...D === void 0 ? {} : { webhooks: D }
|
|
1074
1087
|
},
|
|
1075
1088
|
log: $,
|
|
1076
|
-
analytics:
|
|
1077
|
-
aggregateStorage:
|
|
1078
|
-
aggregateCoordinator:
|
|
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:
|
|
1087
|
-
dataTransferDialect:
|
|
1088
|
-
tenantIsolation: (process.env.VOLTRO_TENANT_ISOLATION ??
|
|
1089
|
-
resolveSubject: (e, t) =>
|
|
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 ?? []), ...
|
|
1106
|
+
httpRoutes: [...R.flatMap((e) => e.httpRoutes ?? []), ...kt],
|
|
1094
1107
|
getStore: () => ze,
|
|
1095
|
-
...
|
|
1096
|
-
...
|
|
1097
|
-
scheduleDefaultTrigger:
|
|
1098
|
-
scheduleCoordination:
|
|
1099
|
-
scheduleArmSelf: !
|
|
1100
|
-
dormancy: process.env.VOLTRO_DORMANCY === "sleep" || process.env.VOLTRO_DORMANCY === "always-on" ? process.env.VOLTRO_DORMANCY :
|
|
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
|
-
...
|
|
1115
|
+
...Rt === void 0 ? {} : { scheduleFireInterceptor: Rt },
|
|
1103
1116
|
onSchedulerReady: (e) => {
|
|
1104
|
-
|
|
1117
|
+
G = e;
|
|
1105
1118
|
},
|
|
1106
1119
|
inspectRoute: { handle: (e, t, n, r) => d(e, {
|
|
1107
1120
|
kind: "api",
|
|
1108
1121
|
meta: {
|
|
1109
|
-
name:
|
|
1110
|
-
voltroVersion:
|
|
1111
|
-
port:
|
|
1122
|
+
name: v?.name ?? "voltro-api",
|
|
1123
|
+
voltroVersion: we,
|
|
1124
|
+
port: oe,
|
|
1112
1125
|
mode: "start",
|
|
1113
|
-
store:
|
|
1114
|
-
cdc:
|
|
1126
|
+
store: y,
|
|
1127
|
+
cdc: se ? "on" : "off"
|
|
1115
1128
|
},
|
|
1116
|
-
rpc:
|
|
1117
|
-
workflows:
|
|
1129
|
+
rpc: De(S, h),
|
|
1130
|
+
workflows: he(S, h),
|
|
1118
1131
|
inspectFireSchedule: async ({ name: e, trigger: t }) => {
|
|
1119
|
-
if (!
|
|
1120
|
-
return { runId: await
|
|
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:
|
|
1132
|
-
...
|
|
1144
|
+
port: oe,
|
|
1145
|
+
...v?.transport?.wsPath ? { path: v.transport.wsPath } : {}
|
|
1133
1146
|
});
|
|
1134
|
-
return
|
|
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 :${
|
|
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:
|
|
1151
|
-
}),
|
|
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
|
|
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 {
|
|
1175
|
+
export { Ln as n, jn as r, Rn as t };
|