@voltro/cli 0.21.0 → 0.22.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 +249 -0
- package/dist/{apiBuild-BHOtsQkp.js → apiBuild-2zRxj2hJ.js} +2 -2
- package/dist/apiBuild-sqNmWmY5.js +2 -0
- package/dist/bin.js +3 -3
- package/dist/{commands-BZoimvvS.js → commands-DGaeTn2f.js} +1539 -1243
- package/dist/dbCommand-CO3eSAZR.js +2 -0
- package/dist/{dbCommand-CDBbZ-Ac.js → dbCommand-DVASmZj2.js} +295 -253
- package/dist/{dev-CZQ73Yoh.js → dev-BEYBSGJ7.js} +1 -1
- package/dist/{dev-DKb92NYX.js → dev-DeHVUxQx.js} +1738 -1702
- package/dist/index.js +1 -1
- package/dist/inspect-BA67TF6v.js +2 -0
- package/dist/inspect-_ldwsAwH.js +945 -0
- package/dist/{inspectMetrics-DMjWBQif.js → inspectMetrics-4AVPn6IS.js} +8 -4
- package/dist/{manifestBuild-P9yuCY2d.js → manifestBuild-Bs1Uw22_.js} +1 -1
- package/dist/manifestBuild-i-fRHg_H.js +2 -0
- package/dist/{serveCommand-qHJCs0cX.js → serveCommand-DEVTtnLy.js} +285 -286
- package/dist/serveEntry.js +2 -2
- package/dist/{start-B1x6Z60h.js → start-BjGUIIvj.js} +3 -3
- package/dist/startEntry.js +2 -2
- package/package.json +17 -17
- package/templates/AGENTS.md +1 -1
- package/templates/agent-docs/_index.md +1 -1
- package/templates/agent-docs/cli.md +118 -5
- package/templates/agent-docs/data.md +58 -0
- package/templates/agent-docs/database/migrations.md +142 -20
- package/templates/agent-docs/plugins.md +1 -1
- package/templates/agent-docs/schema-driven-ui.md +2 -2
- package/templates/agent-docs/templates/apibackends.md +1 -1
- package/templates/agent-docs/whats-new.md +174 -74
- package/templates/apps/api-ai/package.json +7 -7
- package/templates/apps/api-auth/package.json +8 -8
- package/templates/apps/api-backend/package.json +7 -7
- package/templates/apps/api-backend-deactivation/package.json +7 -7
- package/templates/apps/api-backend-mail/package.json +8 -8
- package/templates/apps/api-backend-mariadb/package.json +9 -9
- package/templates/apps/api-backend-storage/package.json +8 -8
- package/templates/apps/api-data-advanced/package.json +8 -8
- package/templates/apps/api-durable/package.json +8 -8
- package/templates/apps/api-feature-flags/package.json +9 -9
- package/templates/apps/api-governance/package.json +8 -8
- package/templates/apps/api-kv/package.json +8 -8
- package/templates/apps/api-moderation/package.json +8 -8
- package/templates/apps/api-observability/package.json +8 -8
- package/templates/apps/api-ratelimit/package.json +8 -8
- package/templates/apps/api-rbac/package.json +8 -8
- package/templates/apps/api-rest/package.json +7 -7
- package/templates/apps/api-saas/package.json +11 -11
- package/templates/apps/api-search/package.json +8 -8
- package/templates/apps/api-versioning/package.json +8 -8
- package/templates/apps/api-webhooks/package.json +9 -9
- package/templates/apps/changelog/package.json +6 -6
- package/templates/apps/edge-functions/package.json +2 -2
- package/templates/apps/frontend-admin/package.json +8 -8
- package/templates/apps/frontend-app/package.json +8 -8
- package/templates/apps/frontend-blank/package.json +7 -7
- package/templates/apps/frontend-contact/package.json +7 -7
- package/templates/apps/frontend-dashboard/package.json +7 -7
- package/templates/apps/frontend-docs/package.json +7 -7
- package/templates/apps/frontend-i18n/package.json +6 -6
- package/templates/apps/frontend-landing/package.json +7 -7
- package/templates/apps/frontend-spa/package.json +7 -7
- package/templates/apps/frontend-ssr/package.json +7 -7
- package/templates/apps/frontend-ssr-api/package.json +8 -8
- package/templates/apps/frontend-static-blog/package.json +6 -6
- package/dist/apiBuild-K7M6Rt0U.js +0 -2
- package/dist/dbCommand-oADAj6ez.js +0 -2
- package/dist/inspect-DcZ04OME.js +0 -2
- package/dist/inspect-Dwx0_tUj.js +0 -921
- package/dist/manifestBuild-D1MzJAiQ.js +0 -2
|
@@ -1,54 +1,54 @@
|
|
|
1
|
-
import { at as e, t } from "./inspectMetrics-
|
|
1
|
+
import { at as e, t } from "./inspectMetrics-4AVPn6IS.js";
|
|
2
2
|
import { s as n } from "./seedRunner-D6eu-u5U.js";
|
|
3
3
|
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
|
-
import { p as d } from "./inspect-
|
|
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 x, i as _e, it as S, j as ve, k as ye, lt as C, m as be, nt as w, o as T, ot as xe, q as
|
|
8
|
-
import { l as O, r as
|
|
9
|
-
import { t as
|
|
10
|
-
import { n as
|
|
11
|
-
import { join as
|
|
12
|
-
import { pathToFileURL as
|
|
13
|
-
import { Cause as
|
|
14
|
-
import { createLogger as
|
|
15
|
-
import { existsSync as
|
|
16
|
-
import { AggregateRegistry as
|
|
17
|
-
import { RpcGroup as
|
|
18
|
-
import { SqlClient as
|
|
19
|
-
import { and as
|
|
20
|
-
import { appStorageProvider as H, fromNodeReadable 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
|
|
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 x, i as _e, it as S, j as ve, k as ye, lt as C, m as be, nt as w, o as T, ot as xe, q as E, r as Se, rt as Ce, st as we, 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-DeHVUxQx.js";
|
|
8
|
+
import { l as O, r as k } from "./apiBuild-2zRxj2hJ.js";
|
|
9
|
+
import { t as Ne } from "./bootTiming-BdyP9nYw.js";
|
|
10
|
+
import { n as Pe } from "./cliArgs-qdZSElM3.js";
|
|
11
|
+
import { join as Fe } from "node:path";
|
|
12
|
+
import { pathToFileURL as Ie } from "node:url";
|
|
13
|
+
import { Cause as Le, Effect as A, Layer as j, ManagedRuntime as Re } from "effect";
|
|
14
|
+
import { createLogger as M } from "@voltro/logger";
|
|
15
|
+
import { existsSync as ze } from "node:fs";
|
|
16
|
+
import { AggregateRegistry as N, Dispatcher as Be, apiKeyManagementRoutes as Ve, applySoftDeleteScope as He, applyTenantScope as Ue, attachAnalyticsMirror as P, awaitServerListening as We, bindMutation as F, bindStream as Ge, bindSubscription as I, buildTracingLayer as Ke, cancelWakeup as qe, compileCron as Je, dataStoreApiKeyStore as Ye, dataStoreIdempotencyStore as Xe, formatServerOnlyLeaks as Ze, frameworkApiKeyStrategy as Qe, installPolicyGuardResolver as $e, loadResourceTuples as et, makeActionRunner as L, makeAdvisoryLockCoordinator as tt, makeApiKeyService as nt, makeApiKeyUsageBuffer as rt, makeApiKeyUsageFlusher as it, makeAsyncKv as at, makeCoordinatedScheduler as ot, makeEffectStoreLayer as st, makeLazyWorkflowFacade 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 _t, noopKv as R, onProcessShutdown as vt, recordSubscriptionDelivery as yt, registerWakeup as bt, resolveSecretsBackend as xt, runProvidedEffect as St, setSecretsBackend as Ct, setSystemStoreHandle as z, setTupleSource as wt, singleCoordinator as Tt, startRpcServer as Et, startScheduler as Dt, workflowToRpc as B, wrapStoreWithBootCodec as Ot } from "@voltro/runtime";
|
|
17
|
+
import { RpcGroup as kt } from "@effect/rpc";
|
|
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 W, ConnectionInfoMiddleware as G, actionToRpc as K, anonymousSubject as Lt, isWireReachable as Rt, mutationToRpc as zt, queryToRpc as q, streamToRpc as Bt, workflowCancelDescriptor as Vt, workflowDomainEventsQueryDescriptor as J, workflowEventDeliveriesQueryDescriptor as Ht, workflowResumeDescriptor as Ut, 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";
|
|
29
29
|
//#region src/bootRefusal.ts
|
|
30
|
-
var
|
|
30
|
+
var hn = "VoltroBootRefusal", gn = (e) => {
|
|
31
31
|
let t = Error(e);
|
|
32
|
-
return t.name =
|
|
33
|
-
},
|
|
32
|
+
return t.name = hn, t;
|
|
33
|
+
}, _n = "/_voltro/admin/import", vn = "/_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
|
+
}), yn = (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
|
+
}, bn = (e, t) => Yt(Jt("sha256").update(e).digest(), Jt("sha256").update(t).digest()), xn = (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 = yn(e.headers);
|
|
44
|
+
return !n || !bn(n, t) ? Q(401, { error: "unauthorized" }) : null;
|
|
45
|
+
}, Sn = M({ scope: "voltro:admin-import" }), Cn = "VBUNDLE2", wn = async function* (e) {
|
|
46
46
|
yield e;
|
|
47
|
-
},
|
|
48
|
-
let n =
|
|
47
|
+
}, Tn = (e) => async (t) => {
|
|
48
|
+
let n = xn(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") === Cn, c, l;
|
|
51
|
+
if (s) c = wn(t.rawBody), l = "upload";
|
|
52
52
|
else {
|
|
53
53
|
let n;
|
|
54
54
|
try {
|
|
@@ -62,11 +62,11 @@ var pn = "VoltroBootRefusal", mn = (e) => {
|
|
|
62
62
|
}
|
|
63
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-"));
|
|
64
64
|
try {
|
|
65
|
-
e.assetSink ? await
|
|
65
|
+
e.assetSink ? await pn(c, {
|
|
66
66
|
dir: f,
|
|
67
67
|
blobs: e.assetSink
|
|
68
|
-
}) : await
|
|
69
|
-
let t = await
|
|
68
|
+
}) : await mn(c, f);
|
|
69
|
+
let t = await A.runPromiseExit(un({
|
|
70
70
|
store: e.store,
|
|
71
71
|
bundleDir: f,
|
|
72
72
|
...r ? { mode: r } : {},
|
|
@@ -74,14 +74,14 @@ var pn = "VoltroBootRefusal", mn = (e) => {
|
|
|
74
74
|
...a ? { atomic: a } : {},
|
|
75
75
|
...e.snapshot ? { targetSnapshot: e.snapshot } : {},
|
|
76
76
|
force: o,
|
|
77
|
-
onWarn: (e) =>
|
|
77
|
+
onWarn: (e) => Sn.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 Sn.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 pn = "VoltroBootRefusal", mn = (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 Sn.info("admin.import", {
|
|
100
100
|
transport: l,
|
|
101
101
|
tables: n.tables.length,
|
|
102
102
|
rows: s,
|
|
@@ -108,7 +108,7 @@ var pn = "VoltroBootRefusal", mn = (e) => {
|
|
|
108
108
|
transport: l
|
|
109
109
|
});
|
|
110
110
|
} catch (e) {
|
|
111
|
-
return
|
|
111
|
+
return Sn.warn("admin.import failed", {
|
|
112
112
|
transport: l,
|
|
113
113
|
error: e?.message ?? String(e)
|
|
114
114
|
}), Q(500, {
|
|
@@ -121,18 +121,18 @@ var pn = "VoltroBootRefusal", mn = (e) => {
|
|
|
121
121
|
force: !0
|
|
122
122
|
});
|
|
123
123
|
}
|
|
124
|
-
},
|
|
124
|
+
}, En = M({ scope: "voltro:admin-export" }), Dn = 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
|
+
}, On = (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" }, kn = (e) => async (t) => {
|
|
135
|
+
let n = xn(t, e.secret);
|
|
136
136
|
if (n) return n;
|
|
137
137
|
let r;
|
|
138
138
|
try {
|
|
@@ -152,9 +152,9 @@ var pn = "VoltroBootRefusal", mn = (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 ?? 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-"));
|
|
156
156
|
try {
|
|
157
|
-
let t = await
|
|
157
|
+
let t = await A.runPromise(ln({
|
|
158
158
|
store: e.store,
|
|
159
159
|
snapshot: e.snapshot,
|
|
160
160
|
dialect: e.dialect,
|
|
@@ -170,10 +170,10 @@ var pn = "VoltroBootRefusal", mn = (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, () =>
|
|
173
|
+
return await e.putArchive(i, () => cn({
|
|
174
174
|
dir: f,
|
|
175
175
|
...l
|
|
176
|
-
})),
|
|
176
|
+
})), En.info("admin.export", {
|
|
177
177
|
transport: "storage",
|
|
178
178
|
tables: t.tables.length,
|
|
179
179
|
rows: n,
|
|
@@ -187,11 +187,11 @@ var pn = "VoltroBootRefusal", mn = (e) => {
|
|
|
187
187
|
transport: "storage"
|
|
188
188
|
});
|
|
189
189
|
}
|
|
190
|
-
let d = await
|
|
190
|
+
let d = await Dn(cn({
|
|
191
191
|
dir: f,
|
|
192
192
|
...l
|
|
193
193
|
}));
|
|
194
|
-
return
|
|
194
|
+
return En.info("admin.export", {
|
|
195
195
|
transport: "download",
|
|
196
196
|
tables: t.tables.length,
|
|
197
197
|
rows: n,
|
|
@@ -208,7 +208,7 @@ var pn = "VoltroBootRefusal", mn = (e) => {
|
|
|
208
208
|
}
|
|
209
209
|
};
|
|
210
210
|
} catch (e) {
|
|
211
|
-
return
|
|
211
|
+
return En.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
|
});
|
|
@@ -218,7 +218,7 @@ var pn = "VoltroBootRefusal", mn = (e) => {
|
|
|
218
218
|
force: !0
|
|
219
219
|
});
|
|
220
220
|
}
|
|
221
|
-
},
|
|
221
|
+
}, An = 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 pn = "VoltroBootRefusal", mn = (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
|
+
}, jn = (e, t, n = {}) => (async function* () {
|
|
233
|
+
let r = await U((await A.runPromise(Ft(e, t).pipe(A.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 pn = "VoltroBootRefusal", mn = (e) => {
|
|
|
239
239
|
} finally {
|
|
240
240
|
a && clearTimeout(a), r.destroy();
|
|
241
241
|
}
|
|
242
|
-
})(),
|
|
242
|
+
})(), Mn = {
|
|
243
243
|
get: async () => void 0,
|
|
244
244
|
set: async () => {},
|
|
245
245
|
setWithTags: async () => {},
|
|
@@ -248,21 +248,21 @@ var pn = "VoltroBootRefusal", mn = (e) => {
|
|
|
248
248
|
clear: async () => {},
|
|
249
249
|
invalidateTag: async () => 0,
|
|
250
250
|
wrap: async (e, t, n) => n()
|
|
251
|
-
},
|
|
252
|
-
|
|
251
|
+
}, Nn = async (e) => {
|
|
252
|
+
z({
|
|
253
253
|
dataStore: e.store,
|
|
254
254
|
schemaRegistry: e.schemaRegistry
|
|
255
255
|
});
|
|
256
|
-
let t = new
|
|
256
|
+
let t = new Be({
|
|
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 ?? Mn, r = e.kv ?? R, 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}`
|
|
@@ -318,7 +318,7 @@ var pn = "VoltroBootRefusal", mn = (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 ? ct(() => 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 ??
|
|
321
|
+
}, d = (e.discovered.workflows?.length ?? 0) > 0 ? ct(() => 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 ?? M({ scope: "voltro:serve" })).child("webhooks"), ae, h = e.discovered.webhooks;
|
|
322
322
|
if (h && h.outgoing.length > 0 && e.workflowEngineLayer !== void 0) {
|
|
323
323
|
let t = e.workflowEngineLayer, i = S({
|
|
324
324
|
store: e.store,
|
|
@@ -326,9 +326,9 @@ var pn = "VoltroBootRefusal", mn = (e) => {
|
|
|
326
326
|
cache: n,
|
|
327
327
|
kv: r
|
|
328
328
|
}), a = h.outgoing.map((e) => e.descriptor);
|
|
329
|
-
ae =
|
|
330
|
-
let n =
|
|
331
|
-
|
|
329
|
+
ae = rn(i, async (e) => {
|
|
330
|
+
let n = on.execute(e).pipe(A.provide(on.toLayer(nn(i, { events: a })).pipe(j.provideMerge(t))));
|
|
331
|
+
A.runPromise(n).catch((t) => {
|
|
332
332
|
ie.error("deliverWebhook workflow crashed", {
|
|
333
333
|
deliveryId: e.deliveryId,
|
|
334
334
|
targetId: e.targetId
|
|
@@ -338,7 +338,7 @@ var pn = "VoltroBootRefusal", mn = (e) => {
|
|
|
338
338
|
}
|
|
339
339
|
let oe = /* @__PURE__ */ new Map();
|
|
340
340
|
if (h) for (let e of h.incoming) {
|
|
341
|
-
let t = e.descriptor.path ??
|
|
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, {
|
|
342
342
|
resolveSecret: async () => process.env[n] ?? null,
|
|
343
343
|
resolveWorkflows: () => d === void 0 ? void 0 : gt(d, {
|
|
344
344
|
traceId: `incoming:${e.descriptor.id}`,
|
|
@@ -357,17 +357,17 @@ var pn = "VoltroBootRefusal", mn = (e) => {
|
|
|
357
357
|
});
|
|
358
358
|
oe.set(t, { handle: r });
|
|
359
359
|
}
|
|
360
|
-
|
|
360
|
+
$e(), wt((t) => et(e.store, t.subjectId, t.resourceType, t.resourceId));
|
|
361
361
|
let se = (e.discovered.outboxHandlers?.length ?? 0) > 0 ? p({
|
|
362
362
|
handlers: e.discovered.outboxHandlers ?? [],
|
|
363
363
|
store: e.store,
|
|
364
|
-
log: (e.log ??
|
|
364
|
+
log: (e.log ?? M({ scope: "voltro:serve" })).child("outbox")
|
|
365
365
|
}) : void 0, v = ce({
|
|
366
366
|
definitions: (e.discovered.connections ?? []).map((e) => e.definition),
|
|
367
367
|
store: e.store,
|
|
368
368
|
publicUrl: g(e.port ?? 4e3),
|
|
369
|
-
log: (e.log ??
|
|
370
|
-
}), y =
|
|
369
|
+
log: (e.log ?? M({ scope: "voltro:serve" })).child("connections")
|
|
370
|
+
}), y = Ce({
|
|
371
371
|
store: e.store,
|
|
372
372
|
schemaRegistry: e.schemaRegistry,
|
|
373
373
|
cache: n,
|
|
@@ -378,21 +378,21 @@ var pn = "VoltroBootRefusal", mn = (e) => {
|
|
|
378
378
|
namespaceIsolationOn: re,
|
|
379
379
|
...se === void 0 ? {} : { outbox: { nudge: se.nudge } },
|
|
380
380
|
...v.active ? { connections: { registry: v.registry } } : {}
|
|
381
|
-
}), ue =
|
|
382
|
-
let r = t.pipe(
|
|
383
|
-
return
|
|
381
|
+
}), ue = j.succeed(N, m), fe = (t, n) => {
|
|
382
|
+
let r = t.pipe(A.provide(st(n)));
|
|
383
|
+
return St((e.baseLayer ? r.pipe(A.provide(e.baseLayer)) : r).pipe(A.provide(ue)));
|
|
384
384
|
}, pe = lt({
|
|
385
385
|
store: e.store,
|
|
386
386
|
buildContext: (e, t, n) => y(e, t, n),
|
|
387
387
|
runEffect: fe,
|
|
388
388
|
undoCapture: le()
|
|
389
|
-
}), me =
|
|
389
|
+
}), me = D(), he = L({
|
|
390
390
|
buildContext: (e) => y(e),
|
|
391
391
|
runEffect: fe
|
|
392
392
|
}), ge = {
|
|
393
393
|
buildContext: (e) => y(e),
|
|
394
394
|
finalize: (t, n) => He(Ue(t, e.tenantScopedTables, n.subject.tenantId), e.softDeleteScopedTables),
|
|
395
|
-
provideEffect: (e, t) => e.pipe(
|
|
395
|
+
provideEffect: (e, t) => e.pipe(A.provide(st(t)))
|
|
396
396
|
}, x = dt(ge), _e = ut({
|
|
397
397
|
...ge,
|
|
398
398
|
queryRows: (t) => e.store.query(t)
|
|
@@ -405,13 +405,13 @@ var pn = "VoltroBootRefusal", mn = (e) => {
|
|
|
405
405
|
...e.discovered.queries,
|
|
406
406
|
...me.queries,
|
|
407
407
|
...v.queries
|
|
408
|
-
]) C[n.descriptor.name] = (e) =>
|
|
408
|
+
]) C[n.descriptor.name] = (e) => I(x(n, e), t, `subscription.${n.descriptor.name}`, void 0, void 0, ft(n, e));
|
|
409
409
|
for (let t of [
|
|
410
410
|
...e.discovered.mutations,
|
|
411
411
|
...me.mutations,
|
|
412
412
|
...v.mutations
|
|
413
|
-
]) C[t.descriptor.name] = (e) =>
|
|
414
|
-
for (let t of [...e.discovered.actions, ...v.actions]) C[t.descriptor.name] = (e) =>
|
|
413
|
+
]) C[t.descriptor.name] = (e) => F(async (e, n) => pe(t, e, n), e, `mutation.${t.descriptor.name}`);
|
|
414
|
+
for (let t of [...e.discovered.actions, ...v.actions]) C[t.descriptor.name] = (e) => F(async (e, n) => he(t, e, n), e, `action.${t.descriptor.name}`);
|
|
415
415
|
let be = () => `public-${Math.random().toString(36).slice(2, 10)}`, T = [
|
|
416
416
|
...e.discovered.queries.filter((e) => e.descriptor.publicApi !== void 0).map((e) => ({
|
|
417
417
|
descriptor: e.descriptor,
|
|
@@ -438,50 +438,50 @@ var pn = "VoltroBootRefusal", mn = (e) => {
|
|
|
438
438
|
traceId: be()
|
|
439
439
|
})
|
|
440
440
|
}))
|
|
441
|
-
], xe = T.length > 0 ?
|
|
441
|
+
], xe = T.length > 0 ? tn(en(T), {
|
|
442
442
|
store: e.store,
|
|
443
443
|
resolveSubject: (t) => e.resolveSubject(t, -1)
|
|
444
|
-
}) : [],
|
|
444
|
+
}) : [], E = e.dataTransferSecret ?? process.env.VOLTRO_DATA_TRANSFER_SECRET, Se = E && E.length >= 16 ? [{
|
|
445
445
|
method: "POST",
|
|
446
|
-
path:
|
|
447
|
-
handle:
|
|
448
|
-
secret:
|
|
446
|
+
path: _n,
|
|
447
|
+
handle: Tn({
|
|
448
|
+
secret: E,
|
|
449
449
|
store: e.store,
|
|
450
450
|
...e.dataTransferSnapshot ? { snapshot: e.dataTransferSnapshot } : {},
|
|
451
|
-
assetSink:
|
|
452
|
-
openArchive: (e) =>
|
|
451
|
+
assetSink: dn(H()),
|
|
452
|
+
openArchive: (e) => jn(H(), e)
|
|
453
453
|
})
|
|
454
454
|
}, {
|
|
455
455
|
method: "POST",
|
|
456
|
-
path:
|
|
457
|
-
handle:
|
|
458
|
-
secret:
|
|
456
|
+
path: vn,
|
|
457
|
+
handle: kn({
|
|
458
|
+
secret: E,
|
|
459
459
|
store: e.store,
|
|
460
460
|
snapshot: e.dataTransferSnapshot ?? { tables: [] },
|
|
461
461
|
dialect: e.dataTransferDialect ?? "memory",
|
|
462
462
|
tenantTables: [...e.tenantScopedTables],
|
|
463
|
-
loadProfile:
|
|
464
|
-
assetSource:
|
|
463
|
+
loadProfile: An,
|
|
464
|
+
assetSource: fn(H(), e.store),
|
|
465
465
|
putArchive: async (e, t) => {
|
|
466
|
-
let { Readable: n } = await import("node:stream"), r = H(), i =
|
|
467
|
-
await
|
|
466
|
+
let { Readable: n } = await import("node:stream"), r = H(), i = Pt("storage", () => n.from(t()));
|
|
467
|
+
await A.runPromise(It(r, e, i, { contentType: "application/octet-stream" }));
|
|
468
468
|
}
|
|
469
469
|
})
|
|
470
|
-
}] : [],
|
|
470
|
+
}] : [], we = [
|
|
471
471
|
...e.httpRoutes ?? [],
|
|
472
472
|
...xe,
|
|
473
|
-
...
|
|
473
|
+
...Se,
|
|
474
474
|
...v.httpRoutes
|
|
475
475
|
];
|
|
476
|
-
for (let t of e.discovered.streams ?? []) C[t.descriptor.name] = (n) =>
|
|
476
|
+
for (let t of e.discovered.streams ?? []) C[t.descriptor.name] = (n) => Ge((r) => {
|
|
477
477
|
let i = y(r), a = t.executor(n, i);
|
|
478
|
-
if (
|
|
479
|
-
let t = a.pipe(
|
|
480
|
-
return (e.baseLayer ? t.pipe(
|
|
478
|
+
if (A.isEffect(a)) {
|
|
479
|
+
let t = a.pipe(A.provide(st(i.store)));
|
|
480
|
+
return (e.baseLayer ? t.pipe(A.provide(e.baseLayer)) : t).pipe(A.provide(ue));
|
|
481
481
|
}
|
|
482
|
-
return typeof a == "object" && a && typeof a.then == "function" ?
|
|
482
|
+
return typeof a == "object" && a && typeof a.then == "function" ? A.promise(() => a) : a;
|
|
483
483
|
}, `stream.${t.descriptor.name}`);
|
|
484
|
-
for (let t of e.discovered.workflows ?? []) C[t.definition.name] = (e) =>
|
|
484
|
+
for (let t of e.discovered.workflows ?? []) C[t.definition.name] = (e) => F(async (e, n) => {
|
|
485
485
|
let r = n;
|
|
486
486
|
return gt(d, {
|
|
487
487
|
subject: r.subject,
|
|
@@ -489,7 +489,7 @@ var pn = "VoltroBootRefusal", mn = (e) => {
|
|
|
489
489
|
source: "workflow-rpc"
|
|
490
490
|
}).start(t.definition.name, e);
|
|
491
491
|
}, e, `workflow.${t.definition.name}`);
|
|
492
|
-
f && (C[X.name] = (e) =>
|
|
492
|
+
f && (C[X.name] = (e) => I(x({
|
|
493
493
|
descriptor: X,
|
|
494
494
|
executor: (e) => {
|
|
495
495
|
let t = e.id;
|
|
@@ -499,14 +499,14 @@ var pn = "VoltroBootRefusal", mn = (e) => {
|
|
|
499
499
|
column: "startedAt",
|
|
500
500
|
direction: "desc"
|
|
501
501
|
}],
|
|
502
|
-
predicate:
|
|
502
|
+
predicate: Nt(V("id", t), V("executionId", t)),
|
|
503
503
|
take: 1,
|
|
504
504
|
skip: void 0,
|
|
505
505
|
projection: void 0
|
|
506
506
|
};
|
|
507
507
|
}
|
|
508
|
-
}, e), t, `subscription.${X.name}`), C[
|
|
509
|
-
descriptor:
|
|
508
|
+
}, e), t, `subscription.${X.name}`), C[Z.name] = (e) => I(x({
|
|
509
|
+
descriptor: Z,
|
|
510
510
|
executor: (e) => {
|
|
511
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;
|
|
512
512
|
return {
|
|
@@ -515,14 +515,14 @@ var pn = "VoltroBootRefusal", mn = (e) => {
|
|
|
515
515
|
column: "startedAt",
|
|
516
516
|
direction: "desc"
|
|
517
517
|
}],
|
|
518
|
-
predicate: n.length === 0 ? void 0 : n.length === 1 ? n[0] :
|
|
518
|
+
predicate: n.length === 0 ? void 0 : n.length === 1 ? n[0] : jt(...n),
|
|
519
519
|
take: r,
|
|
520
520
|
skip: void 0,
|
|
521
521
|
projection: void 0
|
|
522
522
|
};
|
|
523
523
|
}
|
|
524
|
-
}, e), t, `subscription.${
|
|
525
|
-
descriptor:
|
|
524
|
+
}, e), t, `subscription.${Z.name}`), C[Wt.name] = (e) => I(x({
|
|
525
|
+
descriptor: Wt,
|
|
526
526
|
executor: (e) => {
|
|
527
527
|
let t = e.runId;
|
|
528
528
|
return {
|
|
@@ -537,7 +537,7 @@ var pn = "VoltroBootRefusal", mn = (e) => {
|
|
|
537
537
|
projection: void 0
|
|
538
538
|
};
|
|
539
539
|
}
|
|
540
|
-
}, e), t, `subscription.${
|
|
540
|
+
}, e), t, `subscription.${Wt.name}`), C[Y.name] = (e) => I(x({
|
|
541
541
|
descriptor: Y,
|
|
542
542
|
executor: (e) => {
|
|
543
543
|
let t = e.runId;
|
|
@@ -553,8 +553,8 @@ var pn = "VoltroBootRefusal", mn = (e) => {
|
|
|
553
553
|
projection: void 0
|
|
554
554
|
};
|
|
555
555
|
}
|
|
556
|
-
}, e), t, `subscription.${Y.name}`), C[
|
|
557
|
-
descriptor:
|
|
556
|
+
}, e), t, `subscription.${Y.name}`), C[J.name] = (e) => I(x({
|
|
557
|
+
descriptor: J,
|
|
558
558
|
executor: (e) => {
|
|
559
559
|
let t = e;
|
|
560
560
|
return {
|
|
@@ -569,8 +569,8 @@ var pn = "VoltroBootRefusal", mn = (e) => {
|
|
|
569
569
|
projection: void 0
|
|
570
570
|
};
|
|
571
571
|
}
|
|
572
|
-
}, e), t, `subscription.${
|
|
573
|
-
descriptor:
|
|
572
|
+
}, e), t, `subscription.${J.name}`), C[Ht.name] = (e) => I(x({
|
|
573
|
+
descriptor: Ht,
|
|
574
574
|
executor: (e) => {
|
|
575
575
|
let t = e.eventId;
|
|
576
576
|
return {
|
|
@@ -585,63 +585,63 @@ var pn = "VoltroBootRefusal", mn = (e) => {
|
|
|
585
585
|
projection: void 0
|
|
586
586
|
};
|
|
587
587
|
}
|
|
588
|
-
}, e), t, `subscription.${
|
|
588
|
+
}, e), t, `subscription.${Ht.name}`), C[Vt.name] = (t) => F(async (t, n) => {
|
|
589
589
|
let r = t;
|
|
590
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.${
|
|
591
|
+
}, t, `action.${Vt.name}`), C[Ut.name] = (t) => F(async (t, n) => {
|
|
592
592
|
let r = t;
|
|
593
593
|
return await w(e.store, n.subject, { executionId: r.executionId }), await d.resume(r.workflowName, r.executionId), { ok: !0 };
|
|
594
|
-
}, t, `action.${
|
|
594
|
+
}, t, `action.${Ut.name}`), C[Gt.name] = (t) => F(async (t, n) => {
|
|
595
595
|
let r = t;
|
|
596
596
|
return await w(e.store, n.subject, { id: r.id }), d.signal({ id: r.id }, r.signalName, r.payload);
|
|
597
|
-
}, t, `action.${
|
|
597
|
+
}, t, `action.${Gt.name}`), C[Kt.name] = (t) => F(async (t, n) => {
|
|
598
598
|
let r = t;
|
|
599
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.${
|
|
601
|
-
let Ee = [
|
|
602
|
-
...e.discovered.queries.map((e) => q(e.descriptor)),
|
|
603
|
-
...e.discovered.mutations.map((e) =>
|
|
604
|
-
...e.discovered.actions.map((e) => K(e.descriptor)),
|
|
600
|
+
}, t, `action.${Kt.name}`));
|
|
601
|
+
let Te = (e) => e.filter((e) => Rt(e.descriptor)), Ee = [
|
|
602
|
+
...Te(e.discovered.queries).map((e) => q(e.descriptor)),
|
|
603
|
+
...Te(e.discovered.mutations).map((e) => zt(e.descriptor)),
|
|
604
|
+
...Te(e.discovered.actions).map((e) => K(e.descriptor)),
|
|
605
605
|
...me.queries.map((e) => q(e.descriptor)),
|
|
606
|
-
...me.mutations.map((e) =>
|
|
606
|
+
...me.mutations.map((e) => zt(e.descriptor)),
|
|
607
607
|
...v.queries.map((e) => q(e.descriptor)),
|
|
608
|
-
...v.mutations.map((e) =>
|
|
608
|
+
...v.mutations.map((e) => zt(e.descriptor)),
|
|
609
609
|
...v.actions.map((e) => K(e.descriptor)),
|
|
610
|
-
...(e.discovered.streams ?? []).map((e) =>
|
|
610
|
+
...(e.discovered.streams ?? []).map((e) => Bt(e.descriptor)),
|
|
611
611
|
...(e.discovered.workflows ?? []).map((e) => B(e.definition)),
|
|
612
612
|
...f ? [
|
|
613
613
|
q(X),
|
|
614
|
-
q(Ht),
|
|
615
614
|
q(Z),
|
|
615
|
+
q(Wt),
|
|
616
616
|
q(Y),
|
|
617
|
-
q(Bt),
|
|
618
617
|
q(J),
|
|
619
|
-
|
|
618
|
+
q(Ht),
|
|
620
619
|
K(Vt),
|
|
621
620
|
K(Ut),
|
|
622
|
-
K(
|
|
621
|
+
K(Gt),
|
|
622
|
+
K(Kt)
|
|
623
623
|
] : []
|
|
624
|
-
], De =
|
|
625
|
-
register: (t, n, r) =>
|
|
624
|
+
], De = kt.make(...Ee).middleware(W).middleware(G), Oe = j.succeed(W, W.of(({ headers: t, clientId: n }) => A.promise(() => e.resolveSubject(t, n)))), Ae = j.succeed(G, G.of(({ clientId: e }) => A.succeed({ clientId: e }))), je = e.dormancyTenantId ?? "default", Me = e.dormancy === "sleep" ? {
|
|
625
|
+
register: (t, n, r) => bt(e.store, {
|
|
626
626
|
tenantId: r ?? je,
|
|
627
627
|
kind: "workflow",
|
|
628
628
|
refId: t,
|
|
629
629
|
wakeAt: n
|
|
630
630
|
}),
|
|
631
|
-
cancel: (t, n) =>
|
|
631
|
+
cancel: (t, n) => qe(e.store, {
|
|
632
632
|
tenantId: n ?? je,
|
|
633
633
|
kind: "workflow",
|
|
634
634
|
refId: t
|
|
635
635
|
}).then(() => {})
|
|
636
|
-
} : void 0,
|
|
636
|
+
} : void 0, O = te ? await import("@voltro/workflow") : void 0, k = O?.makeWorkflowRunRecorder({
|
|
637
637
|
store: e.store,
|
|
638
638
|
...Me === void 0 ? {} : { wakeups: Me }
|
|
639
639
|
}), Ne = async (t, n) => {
|
|
640
|
-
await
|
|
640
|
+
await O.closeWorkflowChildrenForParent({
|
|
641
641
|
store: e.store,
|
|
642
642
|
parentExecutionId: t,
|
|
643
643
|
parentStatus: n,
|
|
644
|
-
recorder:
|
|
644
|
+
recorder: k,
|
|
645
645
|
log: { warn: (e, t) => {
|
|
646
646
|
process.stderr.write(`[workflow] ${e} ${t ? JSON.stringify(t) : ""}\n`);
|
|
647
647
|
} },
|
|
@@ -667,7 +667,7 @@ var pn = "VoltroBootRefusal", mn = (e) => {
|
|
|
667
667
|
cancelled: !0,
|
|
668
668
|
completedAt: /* @__PURE__ */ new Date()
|
|
669
669
|
}), o = i.subject?.tenantId ?? void 0;
|
|
670
|
-
a && await
|
|
670
|
+
a && await k.recordEvent({
|
|
671
671
|
runId: i.id,
|
|
672
672
|
eventType: "run-cancelled",
|
|
673
673
|
payload: {
|
|
@@ -684,8 +684,8 @@ var pn = "VoltroBootRefusal", mn = (e) => {
|
|
|
684
684
|
}, e.store, void 0, `workflow:${n.workflowName}`, { parentExecutionId: n.executionId }),
|
|
685
685
|
resolveStartContext: u
|
|
686
686
|
}, (t, n, r) => {
|
|
687
|
-
let i =
|
|
688
|
-
return
|
|
687
|
+
let i = O.getWorkflowVersionMetadata(t.definition);
|
|
688
|
+
return O.wrapWorkflowExecuteWithRunRecording({
|
|
689
689
|
name: t.definition.name,
|
|
690
690
|
store: e.store,
|
|
691
691
|
subject: r.subject,
|
|
@@ -697,70 +697,70 @@ var pn = "VoltroBootRefusal", mn = (e) => {
|
|
|
697
697
|
parentExecutionId: r?.parentExecutionId ?? null,
|
|
698
698
|
parentClosePolicy: r?.parentClosePolicy ?? null,
|
|
699
699
|
onParentClose: ({ executionId: e, status: t }) => Ne(e, t),
|
|
700
|
-
recorder:
|
|
700
|
+
recorder: k
|
|
701
701
|
}, n);
|
|
702
|
-
}), ...e.discovered.workflowWorkers ?? []], Ie = Fe.length > 0 ?
|
|
702
|
+
}), ...e.discovered.workflowWorkers ?? []], Ie = Fe.length > 0 ? j.mergeAll(...Fe) : j.empty;
|
|
703
703
|
if (((e.discovered.workflows?.length ?? 0) > 0 || (e.discovered.workflowWorkers?.length ?? 0) > 0 || e.scheduleCoordination === "cluster") && e.workflowEngineLayer !== void 0) {
|
|
704
|
-
let t = Ie.pipe(
|
|
705
|
-
a =
|
|
704
|
+
let t = Ie.pipe(j.provideMerge(e.workflowEngineLayer));
|
|
705
|
+
a = Re.make(e.baseLayer === void 0 ? t : t.pipe(j.provideMerge(e.baseLayer))), await a.runPromise(A.void), i = (e.discovered.workflows?.length ?? 0) > 0 ? ht({
|
|
706
706
|
workflows: e.discovered.workflows ?? [],
|
|
707
707
|
runEffect: (e) => a.runPromise(e),
|
|
708
708
|
rememberStartContext: l,
|
|
709
709
|
signal: async (t, n, r) => {
|
|
710
|
-
let i = await
|
|
710
|
+
let i = await O.sendWorkflowSignal({
|
|
711
711
|
store: e.store,
|
|
712
|
-
recorder:
|
|
712
|
+
recorder: k,
|
|
713
713
|
target: t,
|
|
714
714
|
signalName: n,
|
|
715
715
|
payload: r
|
|
716
716
|
});
|
|
717
|
-
return await a.runPromise(
|
|
717
|
+
return await a.runPromise(O.completeSuspendingSignal({
|
|
718
718
|
store: e.store,
|
|
719
719
|
target: t,
|
|
720
720
|
signalName: n,
|
|
721
721
|
payload: r
|
|
722
722
|
})).catch(() => {}), i;
|
|
723
723
|
},
|
|
724
|
-
update: (t, n, r, i) =>
|
|
724
|
+
update: (t, n, r, i) => O.sendWorkflowUpdate({
|
|
725
725
|
store: e.store,
|
|
726
|
-
recorder:
|
|
726
|
+
recorder: k,
|
|
727
727
|
target: t,
|
|
728
728
|
updateName: n,
|
|
729
729
|
payload: r,
|
|
730
730
|
...i === void 0 ? {} : { options: i }
|
|
731
731
|
}),
|
|
732
732
|
listRuns: (t) => b(e.store, t),
|
|
733
|
-
retry: (t, n) =>
|
|
733
|
+
retry: (t, n) => ke({
|
|
734
734
|
store: e.store,
|
|
735
735
|
workflows: e.discovered.workflows ?? [],
|
|
736
736
|
runPromise: (e) => a.runPromise(e)
|
|
737
737
|
}, t, n)
|
|
738
738
|
}) : void 0;
|
|
739
739
|
}
|
|
740
|
-
let Le =
|
|
741
|
-
...
|
|
742
|
-
...
|
|
743
|
-
...
|
|
744
|
-
...
|
|
745
|
-
}), Ye = !1, Xe = e.store.ping ? () => e.store.ping().then(() => !0).catch(() => !1) : void 0, { server: Ze, shutdown: Qe } =
|
|
740
|
+
let Le = j.mergeAll(De.toLayer(C), Oe, Ae), ze = ee(C, e.discovered.queries.map((e) => e.descriptor.name), f), Ve = j.mergeAll(De.toLayer(ze), Oe, Ae), P = e.observability, Je = await Ke({
|
|
741
|
+
...P && P.spanProcessors.length > 0 ? { extraSpanProcessors: P.spanProcessors } : {},
|
|
742
|
+
...P && P.metricReaders.length > 0 ? { extraMetricReaders: P.metricReaders } : {},
|
|
743
|
+
...P && Object.keys(P.resourceAttributes).length > 0 ? { resourceAttributes: P.resourceAttributes } : {},
|
|
744
|
+
...P && P.sampler !== void 0 ? { sampler: P.sampler } : {}
|
|
745
|
+
}), Ye = !1, Xe = e.store.ping ? () => e.store.ping().then(() => !0).catch(() => !1) : void 0, { server: Ze, shutdown: Qe } = Et({
|
|
746
746
|
group: De,
|
|
747
747
|
handlersLayer: Le,
|
|
748
|
-
httpHandlersLayer:
|
|
748
|
+
httpHandlersLayer: Ve,
|
|
749
749
|
port: e.port ?? 4e3,
|
|
750
750
|
path: e.path ?? "/ws",
|
|
751
|
-
tracerLayer:
|
|
751
|
+
tracerLayer: Je.layer,
|
|
752
752
|
healthCheck: {
|
|
753
753
|
isReady: () => Ye,
|
|
754
754
|
...Xe ? { ping: Xe } : {}
|
|
755
755
|
},
|
|
756
|
-
...
|
|
756
|
+
...we.length > 0 ? { httpRoutes: we } : {},
|
|
757
757
|
...e.getStore === void 0 ? {} : { getStore: e.getStore },
|
|
758
758
|
...oe.size > 0 ? { webhookRoutes: oe } : {},
|
|
759
759
|
...e.inspectRoute === void 0 ? {} : { inspectRoute: e.inspectRoute }
|
|
760
760
|
});
|
|
761
|
-
if (await
|
|
762
|
-
let t = (e.scheduleCoordination ?? "single") === "advisoryLock" ?
|
|
763
|
-
o = await
|
|
761
|
+
if (await We(Ze), (e.discovered.schedules?.length ?? 0) > 0) {
|
|
762
|
+
let t = (e.scheduleCoordination ?? "single") === "advisoryLock" ? tt(e.store, e.scheduleReplicaId ?? `pid-${process.pid}`) : Tt;
|
|
763
|
+
o = await Dt(e.discovered.schedules ?? [], {
|
|
764
764
|
store: e.store,
|
|
765
765
|
coordinator: t,
|
|
766
766
|
defaultTrigger: e.scheduleDefaultTrigger ?? "self",
|
|
@@ -788,9 +788,9 @@ var pn = "VoltroBootRefusal", mn = (e) => {
|
|
|
788
788
|
...e.onScheduleRunEvent === void 0 ? {} : { onRunEvent: e.onScheduleRunEvent }
|
|
789
789
|
}), e.onSchedulerReady?.(o);
|
|
790
790
|
}
|
|
791
|
-
let
|
|
792
|
-
if ((e.discovered.subscribers?.length ?? 0) > 0 && (rt = de(e.discovered.subscribers ?? [], e.store,
|
|
793
|
-
let t =
|
|
791
|
+
let nt = e.log ?? M({ scope: "voltro:serve" }), rt, it;
|
|
792
|
+
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) {
|
|
793
|
+
let t = nt.child("reaction");
|
|
794
794
|
it = ve(e.discovered.reactions ?? [], e.store, {
|
|
795
795
|
runAct: async (n, r) => {
|
|
796
796
|
if (n.kind === "workflow") {
|
|
@@ -808,7 +808,7 @@ var pn = "VoltroBootRefusal", mn = (e) => {
|
|
|
808
808
|
await _(n.agent, r, {
|
|
809
809
|
findAgentSend: (t) => e.discovered.actions.find((e) => e.descriptor.name === `${t}.send`),
|
|
810
810
|
runAction: (e, t, n) => Promise.resolve(he(e, t, n)),
|
|
811
|
-
makeSubject: (e) =>
|
|
811
|
+
makeSubject: (e) => Lt(e),
|
|
812
812
|
now: () => Date.now(),
|
|
813
813
|
log: t
|
|
814
814
|
});
|
|
@@ -816,7 +816,7 @@ var pn = "VoltroBootRefusal", mn = (e) => {
|
|
|
816
816
|
checkBudget: async (n, r) => {
|
|
817
817
|
try {
|
|
818
818
|
let { requireAiBudget: t } = await import("@voltro/ai");
|
|
819
|
-
return (await
|
|
819
|
+
return (await A.runPromise(A.either(t(e.store, {
|
|
820
820
|
tenantId: n,
|
|
821
821
|
limitUsd: r
|
|
822
822
|
}))))._tag === "Right";
|
|
@@ -830,11 +830,11 @@ var pn = "VoltroBootRefusal", mn = (e) => {
|
|
|
830
830
|
return (e.discovered.aggregates?.length ?? 0) > 0 && (at = await ne({
|
|
831
831
|
discovered: e.discovered.aggregates ?? [],
|
|
832
832
|
store: e.store,
|
|
833
|
-
log:
|
|
833
|
+
log: nt.child("aggregate"),
|
|
834
834
|
...e.analytics === void 0 ? {} : { analytics: e.analytics },
|
|
835
835
|
...e.aggregateStorage === void 0 ? {} : { storage: e.aggregateStorage },
|
|
836
836
|
...e.aggregateCoordinator === void 0 ? {} : { coordinator: e.aggregateCoordinator }
|
|
837
|
-
}), ue =
|
|
837
|
+
}), ue = j.succeed(N, at.registry)), Ye = !0, e.bootTiming?.mark("ready"), {
|
|
838
838
|
dispatcher: t,
|
|
839
839
|
server: Ze,
|
|
840
840
|
scheduler: o,
|
|
@@ -842,80 +842,80 @@ var pn = "VoltroBootRefusal", mn = (e) => {
|
|
|
842
842
|
Ye = !1, at?.detach(), it?.(), rt?.(), await o?.shutdown(), t.close(), await a?.dispose(), await new Promise((e) => Ze.close(() => e())), await Qe();
|
|
843
843
|
}
|
|
844
844
|
};
|
|
845
|
-
}, $ =
|
|
845
|
+
}, $ = M({ scope: "voltro:serve" }), Pn = (e, t, n) => (e === "production" || e === "staging") && t !== "memory" && n !== "0", Fn = Pe, In = async (e) => {
|
|
846
846
|
let t = O(process.cwd());
|
|
847
|
-
if (
|
|
847
|
+
if (ze(t)) {
|
|
848
848
|
let n;
|
|
849
849
|
try {
|
|
850
|
-
let e = await import(
|
|
850
|
+
let e = await import(Ie(t).href);
|
|
851
851
|
typeof e.runServe == "function" ? n = e.runServe : $.warn("serve bundle has no runServe export — using the standard serve path");
|
|
852
852
|
} catch (e) {
|
|
853
853
|
$.warn("serve bundle failed to load — using the standard serve path", {}, e);
|
|
854
854
|
}
|
|
855
855
|
if (n) return $.info("serve: booting from the precompiled serve bundle"), n(e);
|
|
856
856
|
}
|
|
857
|
-
return
|
|
858
|
-
},
|
|
859
|
-
let p =
|
|
857
|
+
return Ln(e);
|
|
858
|
+
}, Ln = async (ee) => {
|
|
859
|
+
let p = Ne();
|
|
860
860
|
process.env.NODE_ENV || (process.env.NODE_ENV = "production");
|
|
861
861
|
try {
|
|
862
|
-
|
|
862
|
+
qt();
|
|
863
863
|
} catch (e) {
|
|
864
|
-
throw
|
|
864
|
+
throw gn(e instanceof Error ? e.message : String(e));
|
|
865
865
|
}
|
|
866
|
-
let m = process.cwd(), ne = Number(process.env.PORT ??
|
|
867
|
-
xt(
|
|
866
|
+
let m = process.cwd(), ne = Number(process.env.PORT ?? Fn(ee, "--port") ?? 4e3), g = await he(m);
|
|
867
|
+
Ct(xt(g?.secrets)), await e({
|
|
868
868
|
rawEnv: g?.env,
|
|
869
869
|
appType: "api",
|
|
870
870
|
root: m,
|
|
871
871
|
log: $,
|
|
872
872
|
generateTypes: !1
|
|
873
873
|
}), p.mark("config");
|
|
874
|
-
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 =
|
|
875
|
-
if (!i() &&
|
|
876
|
-
let e = await import(
|
|
874
|
+
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);
|
|
875
|
+
if (!i() && ze(de)) try {
|
|
876
|
+
let e = await import(Ie(de).href);
|
|
877
877
|
if (e.modules) {
|
|
878
878
|
let t = {};
|
|
879
|
-
for (let [n, r] of Object.entries(e.modules)) t[
|
|
879
|
+
for (let [n, r] of Object.entries(e.modules)) t[Fe(m, n)] = r;
|
|
880
880
|
r(t), $.info("precompiled api bundle loaded", { modules: Object.keys(t).length });
|
|
881
881
|
}
|
|
882
882
|
} catch (e) {
|
|
883
883
|
$.warn("precompiled api bundle failed to load — falling back to source", {}, e);
|
|
884
884
|
}
|
|
885
|
-
let b = await be(m), S = await
|
|
885
|
+
let b = await be(m), S = await De(b, { cdc: ce && le !== void 0 });
|
|
886
886
|
{
|
|
887
|
-
let e = h(S.serverOnlyLeaks, re(process.env, "strict"),
|
|
888
|
-
if (e.action === "fail") throw
|
|
887
|
+
let e = h(S.serverOnlyLeaks, re(process.env, "strict"), Ze, "`voltro serve`");
|
|
888
|
+
if (e.action === "fail") throw gn(e.message ?? "");
|
|
889
889
|
e.action === "warn" && $.warn(e.message ?? "");
|
|
890
890
|
}
|
|
891
|
-
let ve = b.filter((e) =>
|
|
891
|
+
let ve = b.filter((e) => Ae.test(e)), w = ve.length > 0 ? await ue(ve, $.child("webhooks")) : void 0, Ce = s({
|
|
892
892
|
mix: S.featureMix,
|
|
893
893
|
plugins: g?.plugins ?? [],
|
|
894
894
|
cdc: ce && le !== void 0,
|
|
895
895
|
...le ? { cdcDialect: le } : {}
|
|
896
|
-
}),
|
|
896
|
+
}), ke = g?.analytics !== void 0 && g.analytics.kind !== "noop" && _ !== "memory" ? (await n(_)).makeSqlLayer(T()) : void 0, D = await ie({
|
|
897
897
|
spec: g?.analytics,
|
|
898
|
-
sqlLayer:
|
|
898
|
+
sqlLayer: ke,
|
|
899
899
|
log: $
|
|
900
900
|
}), O = (() => {
|
|
901
901
|
let e = new Set(S.tables.map((e) => e.tableName)), t = [...S.tables];
|
|
902
|
-
for (let n of [...
|
|
902
|
+
for (let n of [...Ce, ...D.tables]) e.has(n.tableName) || (e.add(n.tableName), t.push(n));
|
|
903
903
|
return t;
|
|
904
904
|
})();
|
|
905
|
-
for (let e of O)
|
|
906
|
-
let
|
|
907
|
-
if (
|
|
908
|
-
let e = (await n(_)).makeSqlLayer(T()), t = await
|
|
909
|
-
appliedBy: `serve:${
|
|
905
|
+
for (let e of O) Mt(e);
|
|
906
|
+
let Pe = (process.env.NODE_ENV ?? "").toLowerCase();
|
|
907
|
+
if (Pn(Pe, _, process.env.VOLTRO_AUTO_MIGRATE)) {
|
|
908
|
+
let e = (await n(_)).makeSqlLayer(T()), t = await A.runPromise(At.SqlClient.pipe(A.flatMap((e) => Qt(e, O, {
|
|
909
|
+
appliedBy: `serve:${Pe}`,
|
|
910
910
|
environment: "prod",
|
|
911
911
|
dialectId: _
|
|
912
|
-
})),
|
|
913
|
-
t.kind === "prod-mismatch" && ($.error(
|
|
912
|
+
})), A.provide(e)));
|
|
913
|
+
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, _));
|
|
914
914
|
}
|
|
915
|
-
let
|
|
915
|
+
let M = mt(O);
|
|
916
916
|
p.mark("discover");
|
|
917
|
-
let
|
|
918
|
-
for (let e of
|
|
917
|
+
let N = await _e(g, void 0), Be = Ot(N, _);
|
|
918
|
+
for (let e of we({
|
|
919
919
|
dialect: String(g?.store ?? process.env.DB_DIALECT ?? "postgres"),
|
|
920
920
|
changeStrategy: (process.env.CDC ?? "1") === "0" ? "inline" : "cdc",
|
|
921
921
|
dbUrl: process.env.DB_URL,
|
|
@@ -929,29 +929,29 @@ var pn = "VoltroBootRefusal", mn = (e) => {
|
|
|
929
929
|
})
|
|
930
930
|
})) e.level === "warn" ? $.warn(e.message) : $.info(e.message);
|
|
931
931
|
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);
|
|
932
|
-
let { service: He, invalidationBus: Ue, snapshotCache:
|
|
933
|
-
$.info(`cache backend resolved: ${
|
|
934
|
-
|
|
932
|
+
let { service: He, invalidationBus: Ue, snapshotCache: We, cache: F, backend: Ge, dispose: I } = await xe({ env: process.env });
|
|
933
|
+
$.info(`cache backend resolved: ${Ge}` + (Ge === "redis" ? ` (driver ${process.env.CACHE_REDIS_DRIVER ?? "resp"})` : " — in-process, not cross-instance")), N.onChange((e) => {
|
|
934
|
+
A.runFork(Ue.publish(e.table));
|
|
935
935
|
}), 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);
|
|
936
|
-
let { kv:
|
|
936
|
+
let { kv: Ke, service: qe } = await at({ store: N });
|
|
937
937
|
p.mark("store");
|
|
938
|
-
let
|
|
939
|
-
store:
|
|
940
|
-
sink:
|
|
938
|
+
let $e = P({
|
|
939
|
+
store: N,
|
|
940
|
+
sink: D.sink,
|
|
941
941
|
log: $
|
|
942
|
-
}),
|
|
943
|
-
store:
|
|
942
|
+
}), et = pe({
|
|
943
|
+
store: N,
|
|
944
944
|
dialect: _
|
|
945
|
-
}),
|
|
946
|
-
_ !== "memory" && (ct =
|
|
947
|
-
let ut =
|
|
945
|
+
}), L = g?.plugins ?? [], st = process.env.POD_NAME ?? process.env.HOSTNAME ?? `serve-${process.pid}`, ct, lt;
|
|
946
|
+
_ !== "memory" && (ct = Re.make((await n(_)).makeSqlLayer(T())), lt = await ct.runPromise(At.SqlClient));
|
|
947
|
+
let ut = ot({
|
|
948
948
|
coordinator: [
|
|
949
949
|
"postgres",
|
|
950
950
|
"mariadb",
|
|
951
951
|
"mysql",
|
|
952
952
|
"mssql"
|
|
953
|
-
].includes(_) ?
|
|
954
|
-
replicaId:
|
|
953
|
+
].includes(_) ? tt(N, st, $) : Tt,
|
|
954
|
+
replicaId: st,
|
|
955
955
|
log: $
|
|
956
956
|
}), dt = [], ft = {
|
|
957
957
|
...lt ? { sql: lt } : {},
|
|
@@ -960,72 +960,70 @@ var pn = "VoltroBootRefusal", mn = (e) => {
|
|
|
960
960
|
return dt.push(r), r;
|
|
961
961
|
}
|
|
962
962
|
};
|
|
963
|
-
for (let e of
|
|
964
|
-
let pt =
|
|
963
|
+
for (let e of L) e.bindDataStore?.(N, ft);
|
|
964
|
+
let pt = L.filter((e) => typeof e.onChangeEvent == "function");
|
|
965
965
|
if (pt.length > 0) {
|
|
966
|
-
let e =
|
|
967
|
-
|
|
966
|
+
let e = N.changeScope ?? "local";
|
|
967
|
+
N.onChange((t) => {
|
|
968
968
|
let n = y(t, e);
|
|
969
|
-
for (let e of pt)
|
|
969
|
+
for (let e of pt) A.runFork(e.onChangeEvent(n).pipe(A.catchAllCause((t) => A.sync(() => $.warn(`plugin ${e.name} onChangeEvent failed`, { error: Le.pretty(t) })))));
|
|
970
970
|
});
|
|
971
971
|
}
|
|
972
972
|
let ht = me({
|
|
973
|
-
plugins:
|
|
973
|
+
plugins: L,
|
|
974
974
|
appName: g?.name ?? "voltro-api",
|
|
975
975
|
appType: "api",
|
|
976
976
|
voltroVersion: process.env.npm_package_version ?? "0.0.0",
|
|
977
977
|
log: $
|
|
978
978
|
});
|
|
979
|
-
|
|
980
|
-
let gt = await ht.gatherObservability(), _t = await x(
|
|
979
|
+
L.length && await ht.activate(), p.mark("plugins");
|
|
980
|
+
let gt = await ht.gatherObservability(), _t = await x(N, g, _, {
|
|
981
981
|
info: (e, t) => process.stdout.write(`[broadcast] ${e} ${t ? JSON.stringify(t) : ""}\n`),
|
|
982
982
|
warn: (e, t) => process.stderr.write(`[broadcast] ${e} ${t ? JSON.stringify(t) : ""}\n`),
|
|
983
983
|
debug: () => {}
|
|
984
|
-
}), R = g?.apiKeys,
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
}) : void 0, Ct = St ? [$e(St, { prefix: vt })] : [], Tt = Ce([...g?.auth?.strategies ?? [], ...Ct], Zt(g?.plugins ?? []), g?.auth?.anonymousTenantRequired ?? !1, g?.auth?.resolveScopes, () => Ve), Et = [...g?.restRoutes ?? [], ...St ? N(St, (typeof R == "object" ? R.managementPath : void 0) ?? "/v1/api-keys") : []], B = g?.idempotency, Ot = B ? {
|
|
992
|
-
store: Ze(M),
|
|
984
|
+
}), R = g?.apiKeys, yt = (typeof R == "object" ? R.prefix : void 0) ?? "voltro_", bt = R ? Ye(N) : void 0, St = bt ? rt({ flush: it(bt) }) : void 0;
|
|
985
|
+
St && vt(() => St.shutdown());
|
|
986
|
+
let z = bt ? nt(bt, {
|
|
987
|
+
prefix: yt,
|
|
988
|
+
...St ? { usage: St } : {}
|
|
989
|
+
}) : void 0, wt = z ? [Qe(z, { prefix: yt })] : [], Et = Se([...g?.auth?.strategies ?? [], ...wt], $t(g?.plugins ?? []), g?.auth?.anonymousTenantRequired ?? !1, g?.auth?.resolveScopes, () => Be), Dt = [...g?.restRoutes ?? [], ...z ? Ve(z, (typeof R == "object" ? R.managementPath : void 0) ?? "/v1/api-keys") : []], B = g?.idempotency, kt = B ? {
|
|
990
|
+
store: Xe(N),
|
|
993
991
|
header: (typeof B == "object" ? B.header : void 0) ?? "Idempotency-Key",
|
|
994
992
|
ttlMs: (typeof B == "object" ? B.ttlMs : void 0) ?? 864e5
|
|
995
|
-
} : void 0,
|
|
996
|
-
store:
|
|
997
|
-
resolveSubject: (e) =>
|
|
993
|
+
} : void 0, jt = Dt.length > 0 ? tn(Dt, {
|
|
994
|
+
store: N,
|
|
995
|
+
resolveSubject: (e) => Et({
|
|
998
996
|
headers: e,
|
|
999
997
|
clientId: -1
|
|
1000
998
|
}),
|
|
1001
|
-
...
|
|
1002
|
-
}) : [], V =
|
|
1003
|
-
analyticsLayer:
|
|
999
|
+
...kt ? { idempotency: kt } : {}
|
|
1000
|
+
}) : [], V = L.map((e) => e.services).filter((e) => e !== void 0), Nt = j.mergeAll(Ee({
|
|
1001
|
+
analyticsLayer: D.layer,
|
|
1004
1002
|
cacheService: He,
|
|
1005
|
-
kvService:
|
|
1003
|
+
kvService: qe,
|
|
1006
1004
|
pluginServices: V,
|
|
1007
1005
|
userLayers: g?.layers ?? []
|
|
1008
|
-
}), ge(g?.http ?? {})), H = g?.scheduling ?? {},
|
|
1006
|
+
}), ge(g?.http ?? {})), H = g?.scheduling ?? {}, Pt = H.trigger ?? "self", Ft = /* @__PURE__ */ new Set([
|
|
1009
1007
|
"postgres",
|
|
1010
1008
|
"mysql",
|
|
1011
1009
|
"mariadb",
|
|
1012
1010
|
"mssql"
|
|
1013
|
-
]),
|
|
1014
|
-
|
|
1015
|
-
let G, K = S.workflows.length > 0 || S.workflowWorkers.length > 0 || S.eventTriggers.length > 0 || (w?.outgoing.length ?? 0) > 0 ||
|
|
1011
|
+
]), It = H.coordination ?? (Ft.has(_) ? "advisoryLock" : "single"), U = It === "cluster" && Ft.has(_), W = U ? "cluster" : It === "advisoryLock" && Ft.has(_) ? "advisoryLock" : "single";
|
|
1012
|
+
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");
|
|
1013
|
+
let G, K = S.workflows.length > 0 || S.workflowWorkers.length > 0 || S.eventTriggers.length > 0 || (w?.outgoing.length ?? 0) > 0 || U, Lt;
|
|
1016
1014
|
if (K) {
|
|
1017
1015
|
if (_ === "mssql") {
|
|
1018
1016
|
let e = await fe(process.cwd());
|
|
1019
1017
|
e && $.warn(e);
|
|
1020
1018
|
}
|
|
1021
|
-
let [{ WorkflowEngine: e }, { makeClusterCronLayer: t, workflowEngineLayer: r, resolveRunnerStorage: i }] = await Promise.all([import("@effect/workflow"), import("@voltro/workflow/cluster")]), a =
|
|
1019
|
+
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({
|
|
1022
1020
|
name: e.name,
|
|
1023
|
-
cron:
|
|
1021
|
+
cron: Je(e),
|
|
1024
1022
|
execute: async () => {
|
|
1025
1023
|
await G?.fireFromCluster(e.name);
|
|
1026
1024
|
}
|
|
1027
1025
|
})) : [];
|
|
1028
|
-
|
|
1026
|
+
Lt = _ === "memory" ? e.layerMemory : await (async () => {
|
|
1029
1027
|
let e = await n(_), t = i({ sqliteFamily: e.id === "sqlite" || e.id === "turso" });
|
|
1030
1028
|
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({
|
|
1031
1029
|
sqlClientLayer: e.makeSqlLayer(T()),
|
|
@@ -1036,18 +1034,18 @@ var pn = "VoltroBootRefusal", mn = (e) => {
|
|
|
1036
1034
|
});
|
|
1037
1035
|
})();
|
|
1038
1036
|
}
|
|
1039
|
-
let
|
|
1040
|
-
if (
|
|
1041
|
-
|
|
1037
|
+
let Rt = je(L, t()), zt = b.filter((e) => /\.subscribe\.tsx?$/.test(e)), q = zt.length > 0 ? await ae(zt, $) : [], Bt = b.filter((e) => /\.reaction\.tsx?$/.test(e)), Vt = Bt.length > 0 ? await se(Bt, $) : [], J = b.filter((e) => u.test(e)), Ht = J.length > 0 ? await Me(J, $) : [], Ut = b.filter((e) => /\.aggregate\.tsx?$/.test(e)), Y = Ut.length > 0 ? await v(Ut, $) : [], X = ye();
|
|
1038
|
+
if (Y.length > 0 && _ !== "memory") try {
|
|
1039
|
+
X = f((await n(_)).makeSqlLayer(T()));
|
|
1042
1040
|
} catch (e) {
|
|
1043
1041
|
$.warn("aggregate: SQL storage init failed — falling back to in-process", { err: String(e) });
|
|
1044
1042
|
}
|
|
1045
|
-
let
|
|
1043
|
+
let Wt = _ === "memory" ? Tt : tt(N, `aggregate@${process.pid}`, $), Z = [], Gt = [], Kt = b.filter((e) => l.test(e));
|
|
1046
1044
|
if (Kt.length > 0) {
|
|
1047
1045
|
let e = $.child("agent"), t = b.filter((e) => a.test(e));
|
|
1048
1046
|
t.length > 0 && await o(t, e);
|
|
1049
1047
|
let n = await c(Kt, e);
|
|
1050
|
-
for (let e of n.agents) for (let t of te(e)) (t.kind === "action" ?
|
|
1048
|
+
for (let e of n.agents) for (let t of te(e)) (t.kind === "action" ? Z : Gt).push({
|
|
1051
1049
|
file: t.file,
|
|
1052
1050
|
descriptor: t.descriptor,
|
|
1053
1051
|
executor: t.executor
|
|
@@ -1055,52 +1053,52 @@ var pn = "VoltroBootRefusal", mn = (e) => {
|
|
|
1055
1053
|
n.agents.length > 0 && e.info("synthesized agent routes", { agents: n.agents.map((e) => e.descriptor.name) });
|
|
1056
1054
|
}
|
|
1057
1055
|
p.mark("workflow");
|
|
1058
|
-
let
|
|
1056
|
+
let Jt = await Nn({
|
|
1059
1057
|
bootTiming: p,
|
|
1060
1058
|
discovered: {
|
|
1061
|
-
queries: [...S.queries, ...
|
|
1059
|
+
queries: [...S.queries, ...Gt],
|
|
1062
1060
|
mutations: S.mutations,
|
|
1063
|
-
actions: [...S.actions, ...
|
|
1061
|
+
actions: [...S.actions, ...Z],
|
|
1064
1062
|
streams: S.streams,
|
|
1065
1063
|
workflows: S.workflows,
|
|
1066
1064
|
workflowWorkers: S.workflowWorkers,
|
|
1067
1065
|
eventTriggers: S.eventTriggers,
|
|
1068
1066
|
schedules: S.schedules,
|
|
1069
|
-
subscribers:
|
|
1070
|
-
outboxHandlers:
|
|
1067
|
+
subscribers: q,
|
|
1068
|
+
outboxHandlers: Ht,
|
|
1071
1069
|
connections: S.connections,
|
|
1072
|
-
reactions:
|
|
1073
|
-
aggregates:
|
|
1070
|
+
reactions: Vt,
|
|
1071
|
+
aggregates: Y,
|
|
1074
1072
|
...w === void 0 ? {} : { webhooks: w }
|
|
1075
1073
|
},
|
|
1076
1074
|
log: $,
|
|
1077
|
-
analytics:
|
|
1078
|
-
aggregateStorage:
|
|
1079
|
-
aggregateCoordinator:
|
|
1080
|
-
store:
|
|
1081
|
-
kv:
|
|
1082
|
-
cache:
|
|
1083
|
-
snapshotCache:
|
|
1084
|
-
schemaRegistry:
|
|
1075
|
+
analytics: D.sink,
|
|
1076
|
+
aggregateStorage: X,
|
|
1077
|
+
aggregateCoordinator: Wt,
|
|
1078
|
+
store: N,
|
|
1079
|
+
kv: Ke,
|
|
1080
|
+
cache: F,
|
|
1081
|
+
snapshotCache: We,
|
|
1082
|
+
schemaRegistry: M,
|
|
1085
1083
|
tenantScopedTables: S.tenantScopedTables,
|
|
1086
1084
|
softDeleteScopedTables: S.softDeleteScopedTables,
|
|
1087
|
-
dataTransferSnapshot:
|
|
1085
|
+
dataTransferSnapshot: Xt(O),
|
|
1088
1086
|
dataTransferDialect: _,
|
|
1089
1087
|
tenantIsolation: (process.env.VOLTRO_TENANT_ISOLATION ?? g?.tenancy?.isolation) === "namespace" ? "namespace" : "shared-schema",
|
|
1090
|
-
resolveSubject: (e, t) =>
|
|
1088
|
+
resolveSubject: (e, t) => Et({
|
|
1091
1089
|
headers: e,
|
|
1092
1090
|
clientId: t
|
|
1093
1091
|
}),
|
|
1094
|
-
httpRoutes: [...
|
|
1095
|
-
getStore: () =>
|
|
1096
|
-
...
|
|
1097
|
-
...
|
|
1098
|
-
scheduleDefaultTrigger:
|
|
1099
|
-
scheduleCoordination:
|
|
1100
|
-
scheduleArmSelf: !
|
|
1092
|
+
httpRoutes: [...L.flatMap((e) => e.httpRoutes ?? []), ...jt],
|
|
1093
|
+
getStore: () => Be,
|
|
1094
|
+
...Nt ? { baseLayer: Nt } : {},
|
|
1095
|
+
...Lt === void 0 ? {} : { workflowEngineLayer: Lt },
|
|
1096
|
+
scheduleDefaultTrigger: Pt,
|
|
1097
|
+
scheduleCoordination: W,
|
|
1098
|
+
scheduleArmSelf: !U,
|
|
1101
1099
|
dormancy: process.env.VOLTRO_DORMANCY === "sleep" || process.env.VOLTRO_DORMANCY === "always-on" ? process.env.VOLTRO_DORMANCY : g?.dormancy ?? "always-on",
|
|
1102
1100
|
scheduleReplicaId: process.env.HOSTNAME ?? `pid-${process.pid}`,
|
|
1103
|
-
...
|
|
1101
|
+
...Rt === void 0 ? {} : { scheduleFireInterceptor: Rt },
|
|
1104
1102
|
onSchedulerReady: (e) => {
|
|
1105
1103
|
G = e;
|
|
1106
1104
|
},
|
|
@@ -1108,14 +1106,14 @@ var pn = "VoltroBootRefusal", mn = (e) => {
|
|
|
1108
1106
|
kind: "api",
|
|
1109
1107
|
meta: {
|
|
1110
1108
|
name: g?.name ?? "voltro-api",
|
|
1111
|
-
voltroVersion:
|
|
1109
|
+
voltroVersion: Te,
|
|
1112
1110
|
port: ne,
|
|
1113
1111
|
mode: "start",
|
|
1114
1112
|
store: _,
|
|
1115
1113
|
cdc: ce ? "on" : "off"
|
|
1116
1114
|
},
|
|
1117
1115
|
rpc: C(S, m),
|
|
1118
|
-
workflows:
|
|
1116
|
+
workflows: Oe(S, m),
|
|
1119
1117
|
inspectFireSchedule: async ({ name: e, trigger: t }) => {
|
|
1120
1118
|
if (!G) throw Error("scheduler not started — this app registers no self-triggered schedules (all schedules are trigger:'external', or there are none).");
|
|
1121
1119
|
return { runId: await G.fireNow(e, t) ?? null };
|
|
@@ -1132,7 +1130,7 @@ var pn = "VoltroBootRefusal", mn = (e) => {
|
|
|
1132
1130
|
port: ne,
|
|
1133
1131
|
...g?.transport?.wsPath ? { path: g.transport.wsPath } : {}
|
|
1134
1132
|
});
|
|
1135
|
-
|
|
1133
|
+
return E(oe([
|
|
1136
1134
|
S.queries,
|
|
1137
1135
|
S.mutations,
|
|
1138
1136
|
S.actions,
|
|
@@ -1148,15 +1146,16 @@ var pn = "VoltroBootRefusal", mn = (e) => {
|
|
|
1148
1146
|
workflows: S.workflows.length,
|
|
1149
1147
|
workflowWorkers: S.workflowWorkers.length,
|
|
1150
1148
|
schedules: S.schedules.length,
|
|
1151
|
-
scheduleCoordination:
|
|
1152
|
-
}), p.finish($)
|
|
1153
|
-
let Qt = () => {
|
|
1149
|
+
scheduleCoordination: W
|
|
1150
|
+
}), p.finish($), vt(async () => {
|
|
1154
1151
|
for (let e of dt) e.stop();
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1152
|
+
$e.detach(), et.stop(), I(), ct?.dispose();
|
|
1153
|
+
try {
|
|
1154
|
+
await ht.deactivate(), await _t?.close(), await D.dispose(), await Jt.close(), await N.close?.();
|
|
1155
|
+
} catch (e) {
|
|
1156
|
+
console.error("serve: shutdown step failed, exiting anyway:", e);
|
|
1157
|
+
}
|
|
1158
|
+
}), await new Promise(() => {}), 0;
|
|
1160
1159
|
};
|
|
1161
1160
|
//#endregion
|
|
1162
|
-
export {
|
|
1161
|
+
export { In as n, An as r, Ln as t };
|