@voltro/cli 0.9.0 → 0.11.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 +394 -7
- package/dist/apiBuild-BCv3bekE.js +2 -0
- package/dist/{apiBuild-eInHm_bJ.js → apiBuild-BUbgGz73.js} +8 -8
- package/dist/bin.js +2 -2
- package/dist/{commands-Cxs97AFp.js → commands-C1qBfIBI.js} +1977 -1599
- package/dist/dev-DKASElZP.js +2 -0
- package/dist/{dev-63Ehpw2p.js → dev-ITlO-epO.js} +1600 -1512
- package/dist/index.js +1 -1
- package/dist/{inspectMetrics-DVCKKSPk.js → inspectMetrics-BeMjgt8x.js} +1018 -827
- package/dist/inspectState.d.ts +6 -2
- package/dist/{serveCommand-Cq7BhtpB.js → serveCommand-mpsE3vLY.js} +407 -420
- package/dist/serveEntry.js +3 -3
- package/dist/{start-CYe-7ueh.js → start-C_M4fGS2.js} +331 -309
- package/dist/startEntry.js +2 -2
- package/package.json +17 -17
- package/templates/agent-docs/cli.md +45 -17
- package/templates/agent-docs/data.md +145 -1
- package/templates/agent-docs/database/seedsdialects.md +40 -4
- package/templates/agent-docs/routing.md +52 -13
- package/templates/agent-docs/scheduling.md +32 -0
- 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-durable/schedules/nightlyReport.cron.tsx +5 -0
- package/templates/apps/api-durable/subscribers/orderChanges.subscribe.ts +8 -2
- 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 +8 -8
- 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-Ba4njm9m.js +0 -2
- package/dist/dev-CXsR8Zgo.js +0 -2
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { a as
|
|
4
|
-
import { a as O, t as
|
|
5
|
-
import { join as
|
|
6
|
-
import { pathToFileURL as
|
|
7
|
-
import { Cause as
|
|
1
|
+
import { t as e, yt as t } from "./inspectMetrics-BeMjgt8x.js";
|
|
2
|
+
import { $ as n, A as r, C as i, D as a, E as o, F as s, G as c, H as l, I as u, J as d, K as f, M as p, N as ee, O as m, P as h, Q as g, S as te, T as ne, U as re, W as ie, X as ae, Y as _, Z as oe, _ as se, at as v, b as ce, d as le, f as y, g as b, h as x, i as S, it as ue, j as C, k as de, lt as w, m as fe, n as pe, o as me, ot as T, q as E, rt as he, s as ge, t as _e, tt as ve, v as ye, w as be, x as xe, y as D } from "./dev-ITlO-epO.js";
|
|
3
|
+
import { a as Se, r as Ce } from "./startupRunner-DhlX9nqd.js";
|
|
4
|
+
import { a as O, t as we } from "./apiBuild-BUbgGz73.js";
|
|
5
|
+
import { join as Te } from "node:path";
|
|
6
|
+
import { pathToFileURL as Ee } from "node:url";
|
|
7
|
+
import { Cause as De, Effect as k, Layer as A, ManagedRuntime as Oe } from "effect";
|
|
8
8
|
import { createLogger as j } from "@voltro/logger";
|
|
9
9
|
import { existsSync as M } from "node:fs";
|
|
10
|
-
import { AggregateRegistry as
|
|
11
|
-
import { createHash as V, timingSafeEqual as
|
|
12
|
-
import { assertProductionSessionSecret as
|
|
13
|
-
import { RpcGroup as
|
|
14
|
-
import { SqlClient as
|
|
15
|
-
import { and as
|
|
16
|
-
import { fromNodeReadable as
|
|
17
|
-
import { AuthMiddleware as
|
|
18
|
-
import { declaredSnapshot as
|
|
19
|
-
import { getAuthSessionStrategy as
|
|
20
|
-
import { collectPublicApiRoutes as
|
|
21
|
-
import { buildDeliverWebhookExecute as
|
|
22
|
-
import { packBundle as
|
|
10
|
+
import { AggregateRegistry as ke, Dispatcher as N, apiKeyManagementRoutes as P, applySoftDeleteScope as Ae, applyTenantScope as je, attachAnalyticsMirror as Me, awaitServerListening as Ne, bindMutation as F, bindStream as Pe, bindSubscription as I, buildTracingLayer as Fe, cancelWakeup as Ie, compileCron as Le, dataStoreApiKeyStore as Re, dataStoreIdempotencyStore as ze, frameworkApiKeyStrategy as Be, installPolicyGuardResolver as Ve, loadResourceTuples as He, makeActionRunner as L, makeAdvisoryLockCoordinator as Ue, makeApiKeyService as We, makeAsyncKv as Ge, makeCoordinatedScheduler as R, makeEffectStoreLayer as Ke, makeLazyWorkflowFacade as qe, makeMutationRunner as Je, makeQueryDescriptorProducer as Ye, makeQueryReauthorizer as Xe, makeSchemaRegistry as Ze, makeWorkflowFacade as Qe, makeWorkflowFacadeWithCallerContext as $e, makeWorkflowLayers as et, noopKv as tt, recordSubscriptionDelivery as nt, registerWakeup as z, resolveSecretsBackend as rt, runProvidedEffect as it, setSecretsBackend as at, setSystemStoreHandle as ot, setTupleSource as st, singleCoordinator as ct, startRpcServer as lt, startScheduler as ut, workflowToRpc as B } from "@voltro/runtime";
|
|
11
|
+
import { createHash as V, timingSafeEqual as dt } from "node:crypto";
|
|
12
|
+
import { assertProductionSessionSecret as ft } from "@voltro/protocol/session";
|
|
13
|
+
import { RpcGroup as pt } from "@effect/rpc";
|
|
14
|
+
import { SqlClient as mt } from "@effect/sql";
|
|
15
|
+
import { and as ht, ensureTableRegistered as gt, eq as H, or as _t } from "@voltro/database";
|
|
16
|
+
import { fromNodeReadable as vt, getObjectStream as yt, putObjectStream as U, resolveStorageProvider as W, toNodeReadable as bt } from "@voltro/plugin-storage";
|
|
17
|
+
import { AuthMiddleware as xt, ConnectionInfoMiddleware as G, actionToRpc as K, anonymousSubject as St, mutationToRpc as Ct, queryToRpc as q, streamToRpc as wt, workflowCancelDescriptor as Tt, workflowDomainEventsQueryDescriptor as Et, workflowEventDeliveriesQueryDescriptor as J, workflowResumeDescriptor as Dt, workflowRunEventsQueryDescriptor as Y, workflowRunQueryDescriptor as Ot, workflowRunStepsQueryDescriptor as X, workflowRunsQueryDescriptor as Z, workflowSignalDescriptor as kt, workflowUpdateDescriptor as At } from "@voltro/protocol";
|
|
18
|
+
import { declaredSnapshot as jt, describeOutcome as Mt, runPlannedMigrations as Nt } from "@voltro/database/sql";
|
|
19
|
+
import { getAuthSessionStrategy as Pt } from "@voltro/plugin-auth";
|
|
20
|
+
import { collectPublicApiRoutes as Ft, restRoutesToHttpRoutes as It } from "@voltro/protocol/rest";
|
|
21
|
+
import { buildDeliverWebhookExecute as Lt, buildWebhooksService as Rt, defaultIncomingPath as zt, deliverWebhookWorkflow as Bt, mountIncomingWebhook as Vt } from "@voltro/plugin-webhooks";
|
|
22
|
+
import { packBundle as Ht, runExport as Ut, runImport as Wt, storageBlobSink as Gt, storageRefsBlobSource as Kt, unpackBundle as qt, unpackBundleToDir as Jt } from "@voltro/data-transfer";
|
|
23
23
|
//#region src/bootTiming.ts
|
|
24
|
-
var
|
|
24
|
+
var Yt = () => {
|
|
25
25
|
let e = process.env.VOLTRO_BOOT_TIMING;
|
|
26
26
|
return e === "1" || e === "true";
|
|
27
|
-
},
|
|
27
|
+
}, Xt = () => {
|
|
28
28
|
let e = [{
|
|
29
29
|
name: "modules",
|
|
30
30
|
at: performance.now()
|
|
@@ -38,7 +38,7 @@ var Jt = () => {
|
|
|
38
38
|
},
|
|
39
39
|
finish: (t) => {
|
|
40
40
|
let n = Math.round(e[e.length - 1].at);
|
|
41
|
-
if (!
|
|
41
|
+
if (!Yt()) {
|
|
42
42
|
t.info(`serve: ready in ${n}ms`);
|
|
43
43
|
return;
|
|
44
44
|
}
|
|
@@ -50,25 +50,25 @@ var Jt = () => {
|
|
|
50
50
|
});
|
|
51
51
|
}
|
|
52
52
|
};
|
|
53
|
-
},
|
|
53
|
+
}, Zt = "/_voltro/admin/import", Qt = "/_voltro/admin/export", Q = (e, t) => ({
|
|
54
54
|
status: e,
|
|
55
55
|
contentType: "application/json; charset=utf-8",
|
|
56
56
|
body: JSON.stringify(t)
|
|
57
|
-
}),
|
|
57
|
+
}), $t = (e) => {
|
|
58
58
|
let t = e.authorization ?? e.Authorization, n = t ? /^Bearer\s+(.+)$/i.exec(t) : null;
|
|
59
59
|
return n ? n[1] : null;
|
|
60
|
-
},
|
|
60
|
+
}, en = (e, t) => dt(V("sha256").update(e).digest(), V("sha256").update(t).digest()), tn = (e, t) => {
|
|
61
61
|
if (e.method.toUpperCase() !== "POST") return Q(405, { error: "method not allowed" });
|
|
62
62
|
if (!t || t.length < 16) return Q(503, { error: "data transfer misconfigured (no/weak secret)" });
|
|
63
|
-
let n =
|
|
64
|
-
return !n ||
|
|
65
|
-
},
|
|
63
|
+
let n = $t(e.headers);
|
|
64
|
+
return !n || !en(n, t) ? Q(401, { error: "unauthorized" }) : null;
|
|
65
|
+
}, nn = j({ scope: "voltro:admin-import" }), rn = "VBUNDLE2", an = async function* (e) {
|
|
66
66
|
yield e;
|
|
67
|
-
},
|
|
68
|
-
let n =
|
|
67
|
+
}, on = (e) => async (t) => {
|
|
68
|
+
let n = tn(t, e.secret);
|
|
69
69
|
if (n) return n;
|
|
70
|
-
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") ===
|
|
71
|
-
if (s) c =
|
|
70
|
+
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") === rn, c, l;
|
|
71
|
+
if (s) c = an(t.rawBody), l = "upload";
|
|
72
72
|
else {
|
|
73
73
|
let n;
|
|
74
74
|
try {
|
|
@@ -80,28 +80,28 @@ var Jt = () => {
|
|
|
80
80
|
if (!e.openArchive) return Q(501, { error: "storage transport not configured on this instance" });
|
|
81
81
|
c = e.openArchive(n.bundleKey), l = "storage";
|
|
82
82
|
}
|
|
83
|
-
let u = await import("node:os"), d = await import("node:fs/promises"),
|
|
83
|
+
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-"));
|
|
84
84
|
try {
|
|
85
|
-
e.assetSink ? await
|
|
86
|
-
dir:
|
|
85
|
+
e.assetSink ? await qt(c, {
|
|
86
|
+
dir: p,
|
|
87
87
|
blobs: e.assetSink
|
|
88
|
-
}) : await
|
|
89
|
-
let t = await k.runPromiseExit(
|
|
88
|
+
}) : await Jt(c, p);
|
|
89
|
+
let t = await k.runPromiseExit(Wt({
|
|
90
90
|
store: e.store,
|
|
91
|
-
bundleDir:
|
|
91
|
+
bundleDir: p,
|
|
92
92
|
...r ? { mode: r } : {},
|
|
93
93
|
...i ? { onConflict: i } : {},
|
|
94
94
|
...a ? { atomic: a } : {},
|
|
95
95
|
...e.snapshot ? { targetSnapshot: e.snapshot } : {},
|
|
96
96
|
force: o,
|
|
97
|
-
onWarn: (e) =>
|
|
97
|
+
onWarn: (e) => nn.warn("admin.import", { message: e }),
|
|
98
98
|
...e.assetSink ? { assetsAlreadyRestored: !0 } : {}
|
|
99
99
|
}));
|
|
100
100
|
if (t._tag === "Failure") {
|
|
101
101
|
let e = t.cause._tag === "Fail" ? t.cause.error : void 0;
|
|
102
102
|
if (e && e._tag === "SchemaDriftError") {
|
|
103
103
|
let t = e;
|
|
104
|
-
return
|
|
104
|
+
return nn.warn("admin.import refused (schema drift)", {
|
|
105
105
|
transport: l,
|
|
106
106
|
bundle: t.bundleFingerprint.slice(0, 16),
|
|
107
107
|
target: t.targetFingerprint.slice(0, 16)
|
|
@@ -116,7 +116,7 @@ var Jt = () => {
|
|
|
116
116
|
throw Error(String(e?.message ?? e ?? "import failed"));
|
|
117
117
|
}
|
|
118
118
|
let n = t.value, s = n.tables.reduce((e, t) => e + t.rowCount, 0);
|
|
119
|
-
return
|
|
119
|
+
return nn.info("admin.import", {
|
|
120
120
|
transport: l,
|
|
121
121
|
tables: n.tables.length,
|
|
122
122
|
rows: s,
|
|
@@ -128,7 +128,7 @@ var Jt = () => {
|
|
|
128
128
|
transport: l
|
|
129
129
|
});
|
|
130
130
|
} catch (e) {
|
|
131
|
-
return
|
|
131
|
+
return nn.warn("admin.import failed", {
|
|
132
132
|
transport: l,
|
|
133
133
|
error: e?.message ?? String(e)
|
|
134
134
|
}), Q(500, {
|
|
@@ -136,23 +136,23 @@ var Jt = () => {
|
|
|
136
136
|
message: e?.message ?? String(e)
|
|
137
137
|
});
|
|
138
138
|
} finally {
|
|
139
|
-
await d.rm(
|
|
139
|
+
await d.rm(p, {
|
|
140
140
|
recursive: !0,
|
|
141
141
|
force: !0
|
|
142
142
|
});
|
|
143
143
|
}
|
|
144
|
-
},
|
|
144
|
+
}, sn = j({ scope: "voltro:admin-export" }), cn = async (e) => {
|
|
145
145
|
let t = [];
|
|
146
146
|
for await (let n of e) t.push(Buffer.from(n));
|
|
147
147
|
return new Uint8Array(Buffer.concat(t));
|
|
148
|
-
},
|
|
148
|
+
}, ln = (e) => typeof e.tenant == "string" && e.tenant ? {
|
|
149
149
|
kind: "tenant",
|
|
150
150
|
tenantId: e.tenant
|
|
151
151
|
} : Array.isArray(e.tables) && e.tables.length ? {
|
|
152
152
|
kind: "tables",
|
|
153
153
|
tables: e.tables.filter((e) => typeof e == "string")
|
|
154
|
-
} : { kind: "all" },
|
|
155
|
-
let n =
|
|
154
|
+
} : { kind: "all" }, un = (e) => async (t) => {
|
|
155
|
+
let n = tn(t, e.secret);
|
|
156
156
|
if (n) return n;
|
|
157
157
|
let r;
|
|
158
158
|
try {
|
|
@@ -172,13 +172,13 @@ var Jt = () => {
|
|
|
172
172
|
});
|
|
173
173
|
}
|
|
174
174
|
}
|
|
175
|
-
let a = r.consistency === "snapshot" ? "snapshot" : i.consistency ?? "live", o = (typeof r.compression == "string" ? r.compression : void 0) ?? i.compression, s = i.scope ??
|
|
175
|
+
let a = r.consistency === "snapshot" ? "snapshot" : i.consistency ?? "live", o = (typeof r.compression == "string" ? r.compression : void 0) ?? i.compression, s = i.scope ?? ln(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-"));
|
|
176
176
|
try {
|
|
177
|
-
let t = await k.runPromise(
|
|
177
|
+
let t = await k.runPromise(Ut({
|
|
178
178
|
store: e.store,
|
|
179
179
|
snapshot: e.snapshot,
|
|
180
180
|
dialect: e.dialect,
|
|
181
|
-
outDir:
|
|
181
|
+
outDir: p,
|
|
182
182
|
...i.subset ? { subset: i.subset } : {
|
|
183
183
|
scope: s,
|
|
184
184
|
...e.tenantTables && e.tenantTables.length > 0 ? { tenantTables: e.tenantTables } : {}
|
|
@@ -190,10 +190,10 @@ var Jt = () => {
|
|
|
190
190
|
if (c) {
|
|
191
191
|
if (!e.putArchive) return Q(501, { error: "storage transport not configured on this instance" });
|
|
192
192
|
let i = r.bundleKey;
|
|
193
|
-
return await e.putArchive(i, () =>
|
|
194
|
-
dir:
|
|
193
|
+
return await e.putArchive(i, () => Ht({
|
|
194
|
+
dir: p,
|
|
195
195
|
...l
|
|
196
|
-
})),
|
|
196
|
+
})), sn.info("admin.export", {
|
|
197
197
|
transport: "storage",
|
|
198
198
|
tables: t.tables.length,
|
|
199
199
|
rows: n,
|
|
@@ -207,11 +207,11 @@ var Jt = () => {
|
|
|
207
207
|
transport: "storage"
|
|
208
208
|
});
|
|
209
209
|
}
|
|
210
|
-
let d = await
|
|
211
|
-
dir:
|
|
210
|
+
let d = await cn(Ht({
|
|
211
|
+
dir: p,
|
|
212
212
|
...l
|
|
213
213
|
}));
|
|
214
|
-
return
|
|
214
|
+
return sn.info("admin.export", {
|
|
215
215
|
transport: "download",
|
|
216
216
|
tables: t.tables.length,
|
|
217
217
|
rows: n,
|
|
@@ -228,17 +228,17 @@ var Jt = () => {
|
|
|
228
228
|
}
|
|
229
229
|
};
|
|
230
230
|
} catch (e) {
|
|
231
|
-
return
|
|
231
|
+
return sn.warn("admin.export failed", { error: e?.message ?? String(e) }), Q(500, {
|
|
232
232
|
error: "export failed",
|
|
233
233
|
message: e?.message ?? String(e)
|
|
234
234
|
});
|
|
235
235
|
} finally {
|
|
236
|
-
await d.rm(
|
|
236
|
+
await d.rm(p, {
|
|
237
237
|
recursive: !0,
|
|
238
238
|
force: !0
|
|
239
239
|
});
|
|
240
240
|
}
|
|
241
|
-
},
|
|
241
|
+
}, dn = async (e) => {
|
|
242
242
|
let { resolve: t } = await import("node:path"), { existsSync: n } = await import("node:fs"), r = [
|
|
243
243
|
e,
|
|
244
244
|
`${e}.profile.ts`,
|
|
@@ -249,7 +249,7 @@ var Jt = () => {
|
|
|
249
249
|
let a = await import(i), o = a.default ?? a.profile;
|
|
250
250
|
if (!o) throw Error(`data profile '${i}' has no default export`);
|
|
251
251
|
return o;
|
|
252
|
-
},
|
|
252
|
+
}, fn = {
|
|
253
253
|
get: async () => void 0,
|
|
254
254
|
set: async () => {},
|
|
255
255
|
setWithTags: async () => {},
|
|
@@ -258,17 +258,21 @@ var Jt = () => {
|
|
|
258
258
|
clear: async () => {},
|
|
259
259
|
invalidateTag: async () => 0,
|
|
260
260
|
wrap: async (e, t, n) => n()
|
|
261
|
-
},
|
|
262
|
-
|
|
261
|
+
}, pn = async (e) => {
|
|
262
|
+
ot({
|
|
263
|
+
dataStore: e.store,
|
|
264
|
+
schemaRegistry: e.schemaRegistry
|
|
265
|
+
});
|
|
266
|
+
let t = new N({
|
|
263
267
|
store: e.store,
|
|
264
268
|
...e.snapshotCache ? { cache: e.snapshotCache } : {},
|
|
265
|
-
recordDelivery: (e) =>
|
|
269
|
+
recordDelivery: (e) => nt({
|
|
266
270
|
label: e.label,
|
|
267
271
|
kind: e.kind,
|
|
268
272
|
durationMs: e.durationMs,
|
|
269
273
|
rowCount: e.rowCount
|
|
270
274
|
})
|
|
271
|
-
}), n = e.cache ??
|
|
275
|
+
}), n = e.cache ?? fn, r = e.kv ?? tt, a, o, c, l = /* @__PURE__ */ new Map(), u = () => `wfctx_${globalThis.crypto?.randomUUID?.() ?? `${Date.now().toString(36)}${Math.random().toString(36).slice(2)}`}`, d = async (t, n, r) => {
|
|
272
276
|
let i = {
|
|
273
277
|
...r,
|
|
274
278
|
source: r.source ?? `workflow:${t}`
|
|
@@ -278,7 +282,7 @@ var Jt = () => {
|
|
|
278
282
|
let r = await e.store.query({
|
|
279
283
|
table: "_voltro_workflow_start_contexts",
|
|
280
284
|
order: [],
|
|
281
|
-
predicate:
|
|
285
|
+
predicate: H("executionId", n),
|
|
282
286
|
projection: ["id"],
|
|
283
287
|
skip: void 0,
|
|
284
288
|
take: 1
|
|
@@ -299,14 +303,14 @@ var Jt = () => {
|
|
|
299
303
|
} catch (e) {
|
|
300
304
|
process.stderr.write(`[workflow] failed to persist start context for ${t}/${n}: ${e?.message ?? String(e)}\n`);
|
|
301
305
|
}
|
|
302
|
-
},
|
|
306
|
+
}, ee = async (t, n) => {
|
|
303
307
|
let r = l.get(n);
|
|
304
308
|
if (r !== void 0) return r;
|
|
305
309
|
try {
|
|
306
310
|
let t = (await e.store.query({
|
|
307
311
|
table: "_voltro_workflow_start_contexts",
|
|
308
312
|
order: [],
|
|
309
|
-
predicate:
|
|
313
|
+
predicate: H("executionId", n),
|
|
310
314
|
projection: void 0,
|
|
311
315
|
skip: void 0,
|
|
312
316
|
take: 1
|
|
@@ -324,35 +328,29 @@ var Jt = () => {
|
|
|
324
328
|
process.stderr.write(`[workflow] failed to load start context for ${n}: ${e?.message ?? String(e)}\n`);
|
|
325
329
|
return;
|
|
326
330
|
}
|
|
327
|
-
},
|
|
331
|
+
}, g = (e.discovered.workflows?.length ?? 0) > 0 ? qe(() => a) : void 0, te = (e.discovered.workflows?.length ?? 0) > 0 || (e.discovered.eventTriggers?.length ?? 0) > 0, ne = te || (e.discovered.workflowWorkers?.length ?? 0) > 0 || e.scheduleCoordination === "cluster", re = e.tenantIsolation === "namespace", ie = (e.log ?? j({ scope: "voltro:serve" })).child("webhooks"), se, v = e.discovered.webhooks;
|
|
328
332
|
if (v && v.outgoing.length > 0 && e.workflowEngineLayer !== void 0) {
|
|
329
|
-
let t = e.workflowEngineLayer,
|
|
330
|
-
store:
|
|
331
|
-
|
|
332
|
-
schemaRegistry: e.schemaRegistry
|
|
333
|
-
}),
|
|
334
|
-
request: {
|
|
335
|
-
subject: St(null),
|
|
336
|
-
traceId: "webhooks:trigger"
|
|
337
|
-
},
|
|
333
|
+
let t = e.workflowEngineLayer, i = oe({
|
|
334
|
+
store: e.store,
|
|
335
|
+
schemaRegistry: e.schemaRegistry,
|
|
338
336
|
cache: n,
|
|
339
|
-
kv:
|
|
340
|
-
}, a = v.outgoing.map((e) => e.descriptor);
|
|
341
|
-
|
|
342
|
-
let n =
|
|
337
|
+
kv: r
|
|
338
|
+
}), a = v.outgoing.map((e) => e.descriptor);
|
|
339
|
+
se = Rt(i, async (e) => {
|
|
340
|
+
let n = Bt.execute(e).pipe(k.provide(Bt.toLayer(Lt(i, { events: a })).pipe(A.provideMerge(t))));
|
|
343
341
|
k.runPromise(n).catch((t) => {
|
|
344
|
-
|
|
342
|
+
ie.error("deliverWebhook workflow crashed", {
|
|
345
343
|
deliveryId: e.deliveryId,
|
|
346
344
|
targetId: e.targetId
|
|
347
345
|
}, t);
|
|
348
346
|
});
|
|
349
347
|
}, { events: a });
|
|
350
348
|
}
|
|
351
|
-
let
|
|
349
|
+
let ce = /* @__PURE__ */ new Map();
|
|
352
350
|
if (v) for (let e of v.incoming) {
|
|
353
|
-
let t = e.descriptor.path ??
|
|
351
|
+
let t = e.descriptor.path ?? zt(e.descriptor.id), n = `VOLTRO_WEBHOOK_SECRET_${e.descriptor.id.toUpperCase().replace(/[^A-Z0-9]/g, "_")}`, r = Vt(e.descriptor, {
|
|
354
352
|
resolveSecret: async () => process.env[n] ?? null,
|
|
355
|
-
resolveWorkflows: () =>
|
|
353
|
+
resolveWorkflows: () => g === void 0 ? void 0 : $e(g, {
|
|
356
354
|
traceId: `incoming:${e.descriptor.id}`,
|
|
357
355
|
source: `incoming:${e.descriptor.id}`
|
|
358
356
|
}),
|
|
@@ -364,127 +362,127 @@ var Jt = () => {
|
|
|
364
362
|
idempotency: e.idempotency,
|
|
365
363
|
durationMs: e.durationMs
|
|
366
364
|
};
|
|
367
|
-
e.status >= 500 ?
|
|
365
|
+
e.status >= 500 ? ie.error("incoming delivery failed", t) : e.status >= 400 ? ie.warn("incoming delivery rejected", t) : ie.info("incoming delivery handled", t);
|
|
368
366
|
}
|
|
369
367
|
});
|
|
370
|
-
|
|
368
|
+
ce.set(t, { handle: r });
|
|
371
369
|
}
|
|
372
|
-
|
|
373
|
-
let
|
|
370
|
+
Ve(), st((t) => He(e.store, t.subjectId, t.resourceType, t.resourceId));
|
|
371
|
+
let le = (e.discovered.outboxHandlers?.length ?? 0) > 0 ? h({
|
|
374
372
|
handlers: e.discovered.outboxHandlers ?? [],
|
|
375
373
|
store: e.store,
|
|
376
374
|
log: (e.log ?? j({ scope: "voltro:serve" })).child("outbox")
|
|
377
|
-
}) : void 0,
|
|
375
|
+
}) : void 0, y = p({
|
|
378
376
|
definitions: (e.discovered.connections ?? []).map((e) => e.definition),
|
|
379
377
|
store: e.store,
|
|
380
378
|
publicUrl: C(e.port ?? 4e3),
|
|
381
379
|
log: (e.log ?? j({ scope: "voltro:serve" })).child("connections")
|
|
382
|
-
}),
|
|
380
|
+
}), b = ae({
|
|
383
381
|
store: e.store,
|
|
384
382
|
schemaRegistry: e.schemaRegistry,
|
|
385
383
|
cache: n,
|
|
386
|
-
kv:
|
|
387
|
-
...
|
|
388
|
-
...
|
|
384
|
+
kv: r,
|
|
385
|
+
...se === void 0 ? {} : { webhooksService: se },
|
|
386
|
+
...g === void 0 ? {} : { workflowsProxy: g },
|
|
389
387
|
eventTriggers: e.discovered.eventTriggers ?? [],
|
|
390
388
|
namespaceIsolationOn: re,
|
|
391
|
-
...
|
|
392
|
-
...
|
|
393
|
-
}),
|
|
394
|
-
let r = t.pipe(k.provide(
|
|
395
|
-
return
|
|
396
|
-
},
|
|
389
|
+
...le === void 0 ? {} : { outbox: { nudge: le.nudge } },
|
|
390
|
+
...y.active ? { connections: { registry: y.registry } } : {}
|
|
391
|
+
}), S = A.succeed(ke, be), ue = (t, n) => {
|
|
392
|
+
let r = t.pipe(k.provide(Ke(n)));
|
|
393
|
+
return it((e.baseLayer ? r.pipe(k.provide(e.baseLayer)) : r).pipe(k.provide(S)));
|
|
394
|
+
}, w = Je({
|
|
397
395
|
store: e.store,
|
|
398
|
-
buildContext: (e, t, n) =>
|
|
399
|
-
runEffect:
|
|
400
|
-
undoCapture:
|
|
401
|
-
}),
|
|
402
|
-
buildContext: (e) =>
|
|
403
|
-
runEffect:
|
|
404
|
-
}), T =
|
|
405
|
-
buildContext: (e) =>
|
|
406
|
-
finalize: (t, n) =>
|
|
407
|
-
provideEffect: (e, t) => e.pipe(k.provide(
|
|
396
|
+
buildContext: (e, t, n) => b(e, t, n),
|
|
397
|
+
runEffect: ue,
|
|
398
|
+
undoCapture: D()
|
|
399
|
+
}), pe = ye(), me = L({
|
|
400
|
+
buildContext: (e) => b(e),
|
|
401
|
+
runEffect: ue
|
|
402
|
+
}), T = Ye({
|
|
403
|
+
buildContext: (e) => b(e),
|
|
404
|
+
finalize: (t, n) => Ae(je(t, e.tenantScopedTables, n.subject.tenantId), e.softDeleteScopedTables),
|
|
405
|
+
provideEffect: (e, t) => e.pipe(k.provide(Ke(t)))
|
|
408
406
|
}), E = {};
|
|
409
407
|
for (let n of [
|
|
410
408
|
...e.discovered.queries,
|
|
411
|
-
...
|
|
412
|
-
...
|
|
413
|
-
]) E[n.descriptor.name] = (e) => I(T(n, e), t, `subscription.${n.descriptor.name}`, void 0, void 0,
|
|
409
|
+
...pe.queries,
|
|
410
|
+
...y.queries
|
|
411
|
+
]) E[n.descriptor.name] = (e) => I(T(n, e), t, `subscription.${n.descriptor.name}`, void 0, void 0, Xe(n, e));
|
|
414
412
|
for (let t of [
|
|
415
413
|
...e.discovered.mutations,
|
|
416
|
-
...
|
|
417
|
-
...
|
|
418
|
-
]) E[t.descriptor.name] = (e) => F(async (e, n) =>
|
|
419
|
-
for (let t of [...e.discovered.actions, ...
|
|
420
|
-
let
|
|
414
|
+
...pe.mutations,
|
|
415
|
+
...y.mutations
|
|
416
|
+
]) E[t.descriptor.name] = (e) => F(async (e, n) => w(t, e, n), e, `mutation.${t.descriptor.name}`);
|
|
417
|
+
for (let t of [...e.discovered.actions, ...y.actions]) E[t.descriptor.name] = (e) => F(async (e, n) => me(t, e, n), e, `action.${t.descriptor.name}`);
|
|
418
|
+
let he = () => `public-${Math.random().toString(36).slice(2, 10)}`, ge = [...e.discovered.mutations.filter((e) => e.descriptor.publicApi !== void 0).map((e) => ({
|
|
421
419
|
descriptor: e.descriptor,
|
|
422
|
-
invoke: (t, n) =>
|
|
420
|
+
invoke: (t, n) => w(e, t, {
|
|
423
421
|
subject: n.subject,
|
|
424
|
-
traceId:
|
|
422
|
+
traceId: he()
|
|
425
423
|
})
|
|
426
424
|
})), ...e.discovered.actions.filter((e) => e.descriptor.publicApi !== void 0).map((e) => ({
|
|
427
425
|
descriptor: e.descriptor,
|
|
428
|
-
invoke: (t, n) =>
|
|
426
|
+
invoke: (t, n) => me(e, t, {
|
|
429
427
|
subject: n.subject,
|
|
430
|
-
traceId:
|
|
428
|
+
traceId: he()
|
|
431
429
|
})
|
|
432
|
-
}))],
|
|
430
|
+
}))], _e = ge.length > 0 ? It(Ft(ge), {
|
|
433
431
|
store: e.store,
|
|
434
432
|
resolveSubject: (t) => e.resolveSubject(t, -1)
|
|
435
|
-
}) : [],
|
|
433
|
+
}) : [], ve = e.dataTransferSecret ?? process.env.VOLTRO_DATA_TRANSFER_SECRET, xe = ve && ve.length >= 16 ? [{
|
|
436
434
|
method: "POST",
|
|
437
|
-
path:
|
|
438
|
-
handle:
|
|
439
|
-
secret:
|
|
435
|
+
path: Zt,
|
|
436
|
+
handle: on({
|
|
437
|
+
secret: ve,
|
|
440
438
|
store: e.store,
|
|
441
439
|
...e.dataTransferSnapshot ? { snapshot: e.dataTransferSnapshot } : {},
|
|
442
|
-
assetSink:
|
|
440
|
+
assetSink: Gt(W({})),
|
|
443
441
|
openArchive: (e) => (async function* () {
|
|
444
|
-
let t = W({}), n = await
|
|
442
|
+
let t = W({}), n = await bt((await k.runPromise(yt(t, e))).stream);
|
|
445
443
|
for await (let e of n) yield e instanceof Uint8Array ? e : new Uint8Array(e);
|
|
446
444
|
})()
|
|
447
445
|
})
|
|
448
446
|
}, {
|
|
449
447
|
method: "POST",
|
|
450
|
-
path:
|
|
451
|
-
handle:
|
|
452
|
-
secret:
|
|
448
|
+
path: Qt,
|
|
449
|
+
handle: un({
|
|
450
|
+
secret: ve,
|
|
453
451
|
store: e.store,
|
|
454
452
|
snapshot: e.dataTransferSnapshot ?? { tables: [] },
|
|
455
453
|
dialect: e.dataTransferDialect ?? "memory",
|
|
456
454
|
tenantTables: [...e.tenantScopedTables],
|
|
457
|
-
loadProfile:
|
|
458
|
-
assetSource:
|
|
455
|
+
loadProfile: dn,
|
|
456
|
+
assetSource: Kt(W({}), e.store),
|
|
459
457
|
putArchive: async (e, t) => {
|
|
460
|
-
let { Readable: n } = await import("node:stream"), r = W({}), i =
|
|
461
|
-
await k.runPromise(
|
|
458
|
+
let { Readable: n } = await import("node:stream"), r = W({}), i = vt("storage", () => n.from(t()));
|
|
459
|
+
await k.runPromise(U(r, e, i, { contentType: "application/octet-stream" }));
|
|
462
460
|
}
|
|
463
461
|
})
|
|
464
|
-
}] : [],
|
|
462
|
+
}] : [], Se = [
|
|
465
463
|
...e.httpRoutes ?? [],
|
|
466
|
-
...
|
|
467
|
-
...
|
|
468
|
-
...
|
|
464
|
+
..._e,
|
|
465
|
+
...xe,
|
|
466
|
+
...y.httpRoutes
|
|
469
467
|
];
|
|
470
|
-
for (let t of e.discovered.streams ?? []) E[t.descriptor.name] = (n) =>
|
|
471
|
-
let i =
|
|
468
|
+
for (let t of e.discovered.streams ?? []) E[t.descriptor.name] = (n) => Pe((r) => {
|
|
469
|
+
let i = b(r), a = t.executor(n, i);
|
|
472
470
|
if (k.isEffect(a)) {
|
|
473
|
-
let t = a.pipe(k.provide(
|
|
474
|
-
return (e.baseLayer ? t.pipe(k.provide(e.baseLayer)) : t).pipe(k.provide(
|
|
471
|
+
let t = a.pipe(k.provide(Ke(i.store)));
|
|
472
|
+
return (e.baseLayer ? t.pipe(k.provide(e.baseLayer)) : t).pipe(k.provide(S));
|
|
475
473
|
}
|
|
476
474
|
return typeof a == "object" && a && typeof a.then == "function" ? k.promise(() => a) : a;
|
|
477
475
|
}, `stream.${t.descriptor.name}`);
|
|
478
476
|
for (let t of e.discovered.workflows ?? []) E[t.definition.name] = (e) => F(async (e, n) => {
|
|
479
477
|
let r = n;
|
|
480
|
-
return
|
|
478
|
+
return $e(g, {
|
|
481
479
|
subject: r.subject,
|
|
482
480
|
traceId: r.traceId,
|
|
483
481
|
source: "workflow-rpc"
|
|
484
482
|
}).start(t.definition.name, e);
|
|
485
483
|
}, e, `workflow.${t.definition.name}`);
|
|
486
|
-
|
|
487
|
-
descriptor:
|
|
484
|
+
te && (E[Ot.name] = (e) => I(T({
|
|
485
|
+
descriptor: Ot,
|
|
488
486
|
executor: (e) => {
|
|
489
487
|
let t = e.id;
|
|
490
488
|
return {
|
|
@@ -493,30 +491,30 @@ var Jt = () => {
|
|
|
493
491
|
column: "startedAt",
|
|
494
492
|
direction: "desc"
|
|
495
493
|
}],
|
|
496
|
-
predicate:
|
|
494
|
+
predicate: _t(H("id", t), H("executionId", t)),
|
|
497
495
|
take: 1,
|
|
498
496
|
skip: void 0,
|
|
499
497
|
projection: void 0
|
|
500
498
|
};
|
|
501
499
|
}
|
|
502
|
-
}, e), t, `subscription.${
|
|
503
|
-
descriptor:
|
|
500
|
+
}, e), t, `subscription.${Ot.name}`), E[Z.name] = (e) => I(T({
|
|
501
|
+
descriptor: Z,
|
|
504
502
|
executor: (e) => {
|
|
505
|
-
let t = e, n = [...t.tag === void 0 ? [] : [
|
|
503
|
+
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;
|
|
506
504
|
return {
|
|
507
505
|
table: "_voltro_workflow_runs",
|
|
508
506
|
order: [{
|
|
509
507
|
column: "startedAt",
|
|
510
508
|
direction: "desc"
|
|
511
509
|
}],
|
|
512
|
-
predicate: n.length === 0 ? void 0 : n.length === 1 ? n[0] :
|
|
510
|
+
predicate: n.length === 0 ? void 0 : n.length === 1 ? n[0] : ht(...n),
|
|
513
511
|
take: r,
|
|
514
512
|
skip: void 0,
|
|
515
513
|
projection: void 0
|
|
516
514
|
};
|
|
517
515
|
}
|
|
518
|
-
}, e), t, `subscription.${
|
|
519
|
-
descriptor:
|
|
516
|
+
}, e), t, `subscription.${Z.name}`), E[X.name] = (e) => I(T({
|
|
517
|
+
descriptor: X,
|
|
520
518
|
executor: (e) => {
|
|
521
519
|
let t = e.runId;
|
|
522
520
|
return {
|
|
@@ -525,14 +523,14 @@ var Jt = () => {
|
|
|
525
523
|
column: "startedAt",
|
|
526
524
|
direction: "asc"
|
|
527
525
|
}],
|
|
528
|
-
predicate:
|
|
526
|
+
predicate: H("runId", t),
|
|
529
527
|
take: 1e3,
|
|
530
528
|
skip: void 0,
|
|
531
529
|
projection: void 0
|
|
532
530
|
};
|
|
533
531
|
}
|
|
534
|
-
}, e), t, `subscription.${
|
|
535
|
-
descriptor:
|
|
532
|
+
}, e), t, `subscription.${X.name}`), E[Y.name] = (e) => I(T({
|
|
533
|
+
descriptor: Y,
|
|
536
534
|
executor: (e) => {
|
|
537
535
|
let t = e.runId;
|
|
538
536
|
return {
|
|
@@ -541,14 +539,14 @@ var Jt = () => {
|
|
|
541
539
|
column: "occurredAt",
|
|
542
540
|
direction: "asc"
|
|
543
541
|
}],
|
|
544
|
-
predicate:
|
|
542
|
+
predicate: H("runId", t),
|
|
545
543
|
take: 1e3,
|
|
546
544
|
skip: void 0,
|
|
547
545
|
projection: void 0
|
|
548
546
|
};
|
|
549
547
|
}
|
|
550
|
-
}, e), t, `subscription.${
|
|
551
|
-
descriptor:
|
|
548
|
+
}, e), t, `subscription.${Y.name}`), E[Et.name] = (e) => I(T({
|
|
549
|
+
descriptor: Et,
|
|
552
550
|
executor: (e) => {
|
|
553
551
|
let t = e;
|
|
554
552
|
return {
|
|
@@ -557,14 +555,14 @@ var Jt = () => {
|
|
|
557
555
|
column: "occurredAt",
|
|
558
556
|
direction: "desc"
|
|
559
557
|
}],
|
|
560
|
-
predicate: t.name === void 0 ? void 0 :
|
|
558
|
+
predicate: t.name === void 0 ? void 0 : H("name", t.name),
|
|
561
559
|
take: Math.max(1, Math.min(500, t.limit ?? 100)),
|
|
562
560
|
skip: void 0,
|
|
563
561
|
projection: void 0
|
|
564
562
|
};
|
|
565
563
|
}
|
|
566
|
-
}, e), t, `subscription.${
|
|
567
|
-
descriptor:
|
|
564
|
+
}, e), t, `subscription.${Et.name}`), E[J.name] = (e) => I(T({
|
|
565
|
+
descriptor: J,
|
|
568
566
|
executor: (e) => {
|
|
569
567
|
let t = e.eventId;
|
|
570
568
|
return {
|
|
@@ -573,84 +571,84 @@ var Jt = () => {
|
|
|
573
571
|
column: "createdAt",
|
|
574
572
|
direction: "asc"
|
|
575
573
|
}],
|
|
576
|
-
predicate:
|
|
574
|
+
predicate: H("eventId", t),
|
|
577
575
|
take: 500,
|
|
578
576
|
skip: void 0,
|
|
579
577
|
projection: void 0
|
|
580
578
|
};
|
|
581
579
|
}
|
|
582
|
-
}, e), t, `subscription.${
|
|
580
|
+
}, e), t, `subscription.${J.name}`), E[Tt.name] = (t) => F(async (t, n) => {
|
|
583
581
|
let r = t;
|
|
584
|
-
return await _(e.store, n.subject, { executionId: r.executionId }), await
|
|
582
|
+
return await _(e.store, n.subject, { executionId: r.executionId }), await g.cancel(r.workflowName, r.executionId), await Le(r.workflowName, r.executionId, "workflow.cancel"), { ok: !0 };
|
|
585
583
|
}, t, `action.${Tt.name}`), E[Dt.name] = (t) => F(async (t, n) => {
|
|
586
584
|
let r = t;
|
|
587
|
-
return await _(e.store, n.subject, { executionId: r.executionId }), await
|
|
588
|
-
}, t, `action.${Dt.name}`), E[
|
|
585
|
+
return await _(e.store, n.subject, { executionId: r.executionId }), await g.resume(r.workflowName, r.executionId), { ok: !0 };
|
|
586
|
+
}, t, `action.${Dt.name}`), E[kt.name] = (t) => F(async (t, n) => {
|
|
589
587
|
let r = t;
|
|
590
|
-
return await _(e.store, n.subject, { id: r.id }),
|
|
591
|
-
}, t, `action.${
|
|
588
|
+
return await _(e.store, n.subject, { id: r.id }), g.signal({ id: r.id }, r.signalName, r.payload);
|
|
589
|
+
}, t, `action.${kt.name}`), E[At.name] = (t) => F(async (t, n) => {
|
|
592
590
|
let r = t;
|
|
593
|
-
return await _(e.store, n.subject, { id: r.id }),
|
|
594
|
-
}, t, `action.${
|
|
595
|
-
let
|
|
596
|
-
...e.discovered.queries.map((e) =>
|
|
591
|
+
return await _(e.store, n.subject, { id: r.id }), g.update({ id: r.id }, r.updateName, r.payload, r.timeoutMs === void 0 ? void 0 : { timeoutMs: r.timeoutMs });
|
|
592
|
+
}, t, `action.${At.name}`));
|
|
593
|
+
let Ce = [
|
|
594
|
+
...e.discovered.queries.map((e) => q(e.descriptor)),
|
|
597
595
|
...e.discovered.mutations.map((e) => Ct(e.descriptor)),
|
|
598
|
-
...e.discovered.actions.map((e) =>
|
|
599
|
-
...
|
|
600
|
-
...
|
|
601
|
-
...
|
|
602
|
-
...
|
|
603
|
-
...
|
|
596
|
+
...e.discovered.actions.map((e) => K(e.descriptor)),
|
|
597
|
+
...pe.queries.map((e) => q(e.descriptor)),
|
|
598
|
+
...pe.mutations.map((e) => Ct(e.descriptor)),
|
|
599
|
+
...y.queries.map((e) => q(e.descriptor)),
|
|
600
|
+
...y.mutations.map((e) => Ct(e.descriptor)),
|
|
601
|
+
...y.actions.map((e) => K(e.descriptor)),
|
|
604
602
|
...(e.discovered.streams ?? []).map((e) => wt(e.descriptor)),
|
|
605
|
-
...(e.discovered.workflows ?? []).map((e) =>
|
|
606
|
-
...
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
603
|
+
...(e.discovered.workflows ?? []).map((e) => B(e.definition)),
|
|
604
|
+
...te ? [
|
|
605
|
+
q(Ot),
|
|
606
|
+
q(Z),
|
|
607
|
+
q(X),
|
|
608
|
+
q(Y),
|
|
609
|
+
q(Et),
|
|
610
|
+
q(J),
|
|
611
|
+
K(Tt),
|
|
612
|
+
K(Dt),
|
|
613
|
+
K(kt),
|
|
614
|
+
K(At)
|
|
617
615
|
] : []
|
|
618
|
-
], O =
|
|
619
|
-
register: (t, n, r) =>
|
|
620
|
-
tenantId: r ??
|
|
616
|
+
], O = pt.make(...Ce).middleware(xt).middleware(G), we = A.succeed(xt, xt.of(({ headers: t, clientId: n }) => k.promise(() => e.resolveSubject(t, n)))), Te = A.succeed(G, G.of(({ clientId: e }) => k.succeed({ clientId: e }))), Ee = e.dormancyTenantId ?? "default", De = e.dormancy === "sleep" ? {
|
|
617
|
+
register: (t, n, r) => z(e.store, {
|
|
618
|
+
tenantId: r ?? Ee,
|
|
621
619
|
kind: "workflow",
|
|
622
620
|
refId: t,
|
|
623
621
|
wakeAt: n
|
|
624
622
|
}),
|
|
625
|
-
cancel: (t, n) =>
|
|
626
|
-
tenantId: n ??
|
|
623
|
+
cancel: (t, n) => Ie(e.store, {
|
|
624
|
+
tenantId: n ?? Ee,
|
|
627
625
|
kind: "workflow",
|
|
628
626
|
refId: t
|
|
629
627
|
}).then(() => {})
|
|
630
|
-
} : void 0, M = ne ? await import("@voltro/workflow") : void 0,
|
|
628
|
+
} : void 0, M = ne ? await import("@voltro/workflow") : void 0, P = M?.makeWorkflowRunRecorder({
|
|
631
629
|
store: e.store,
|
|
632
|
-
...
|
|
633
|
-
}),
|
|
630
|
+
...De === void 0 ? {} : { wakeups: De }
|
|
631
|
+
}), Me = async (t, n) => {
|
|
634
632
|
await M.closeWorkflowChildrenForParent({
|
|
635
633
|
store: e.store,
|
|
636
634
|
parentExecutionId: t,
|
|
637
635
|
parentStatus: n,
|
|
638
|
-
recorder:
|
|
636
|
+
recorder: P,
|
|
639
637
|
log: { warn: (e, t) => {
|
|
640
638
|
process.stderr.write(`[workflow] ${e} ${t ? JSON.stringify(t) : ""}\n`);
|
|
641
639
|
} },
|
|
642
640
|
interruptChild: async (t, n) => {
|
|
643
641
|
let r = (e.discovered.workflows ?? []).find((e) => e.definition.name === t);
|
|
644
642
|
if (!r) throw Error(`Unknown child workflow: ${t}`);
|
|
645
|
-
if (!
|
|
646
|
-
await
|
|
643
|
+
if (!o) throw Error("Workflow runtime is not ready");
|
|
644
|
+
await o.runPromise(r.definition.interrupt(n));
|
|
647
645
|
}
|
|
648
646
|
});
|
|
649
|
-
},
|
|
647
|
+
}, Le = async (t, n, r) => {
|
|
650
648
|
let i = (await e.store.query({
|
|
651
649
|
table: "_voltro_workflow_runs",
|
|
652
650
|
order: [],
|
|
653
|
-
predicate:
|
|
651
|
+
predicate: H("executionId", n),
|
|
654
652
|
projection: void 0,
|
|
655
653
|
skip: void 0,
|
|
656
654
|
take: 1
|
|
@@ -661,7 +659,7 @@ var Jt = () => {
|
|
|
661
659
|
cancelled: !0,
|
|
662
660
|
completedAt: /* @__PURE__ */ new Date()
|
|
663
661
|
}), o = i.subject?.tenantId ?? void 0;
|
|
664
|
-
a && await
|
|
662
|
+
a && await P.recordEvent({
|
|
665
663
|
runId: i.id,
|
|
666
664
|
eventType: "run-cancelled",
|
|
667
665
|
payload: {
|
|
@@ -670,50 +668,43 @@ var Jt = () => {
|
|
|
670
668
|
executionId: n,
|
|
671
669
|
...o == null ? {} : { tenantId: o }
|
|
672
670
|
}
|
|
673
|
-
}), a && await
|
|
674
|
-
},
|
|
675
|
-
buildContext: (t, n) => {
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
};
|
|
681
|
-
return e.buildContextForWorkflow?.(t, n) ?? x({
|
|
682
|
-
subject: r,
|
|
683
|
-
traceId: t?.traceId ?? "workflow-bootstrap"
|
|
684
|
-
}, e.store, void 0, `workflow:${n.workflowName}`, { parentExecutionId: n.executionId });
|
|
685
|
-
},
|
|
686
|
-
resolveStartContext: te
|
|
671
|
+
}), a && await Me(n, "cancelled");
|
|
672
|
+
}, Re = [...et(e.discovered.workflows ?? [], {
|
|
673
|
+
buildContext: (t, n) => e.buildContextForWorkflow?.(t, n) ?? b({
|
|
674
|
+
subject: t.subject,
|
|
675
|
+
traceId: t.traceId
|
|
676
|
+
}, e.store, void 0, `workflow:${n.workflowName}`, { parentExecutionId: n.executionId }),
|
|
677
|
+
resolveStartContext: ee
|
|
687
678
|
}, (t, n, r) => {
|
|
688
679
|
let i = M.getWorkflowVersionMetadata(t.definition);
|
|
689
680
|
return M.wrapWorkflowExecuteWithRunRecording({
|
|
690
681
|
name: t.definition.name,
|
|
691
682
|
store: e.store,
|
|
692
|
-
subject: r
|
|
693
|
-
source: r
|
|
694
|
-
traceId: r
|
|
683
|
+
subject: r.subject,
|
|
684
|
+
source: r.source ?? null,
|
|
685
|
+
traceId: r.traceId,
|
|
695
686
|
workflowVersion: i.version,
|
|
696
687
|
workflowCompatibleVersions: i.compatibleWith,
|
|
697
688
|
workflowPatches: i.patches,
|
|
698
689
|
parentExecutionId: r?.parentExecutionId ?? null,
|
|
699
690
|
parentClosePolicy: r?.parentClosePolicy ?? null,
|
|
700
|
-
onParentClose: ({ executionId: e, status: t }) =>
|
|
701
|
-
recorder:
|
|
691
|
+
onParentClose: ({ executionId: e, status: t }) => Me(e, t),
|
|
692
|
+
recorder: P
|
|
702
693
|
}, n);
|
|
703
|
-
}), ...e.discovered.workflowWorkers ?? []],
|
|
704
|
-
((e.discovered.workflows?.length ?? 0) > 0 || (e.discovered.workflowWorkers?.length ?? 0) > 0 || e.scheduleCoordination === "cluster") && e.workflowEngineLayer !== void 0 && (
|
|
694
|
+
}), ...e.discovered.workflowWorkers ?? []], ze = Re.length > 0 ? A.mergeAll(...Re) : A.empty;
|
|
695
|
+
((e.discovered.workflows?.length ?? 0) > 0 || (e.discovered.workflowWorkers?.length ?? 0) > 0 || e.scheduleCoordination === "cluster") && e.workflowEngineLayer !== void 0 && (o = Oe.make(ze.pipe(A.provideMerge(e.workflowEngineLayer))), await o.runPromise(k.void), a = (e.discovered.workflows?.length ?? 0) > 0 ? Qe({
|
|
705
696
|
workflows: e.discovered.workflows ?? [],
|
|
706
|
-
runEffect: (e) =>
|
|
707
|
-
rememberStartContext:
|
|
697
|
+
runEffect: (e) => o.runPromise(e),
|
|
698
|
+
rememberStartContext: d,
|
|
708
699
|
signal: async (t, n, r) => {
|
|
709
700
|
let i = await M.sendWorkflowSignal({
|
|
710
701
|
store: e.store,
|
|
711
|
-
recorder:
|
|
702
|
+
recorder: P,
|
|
712
703
|
target: t,
|
|
713
704
|
signalName: n,
|
|
714
705
|
payload: r
|
|
715
706
|
});
|
|
716
|
-
return await
|
|
707
|
+
return await o.runPromise(M.completeSuspendingSignal({
|
|
717
708
|
store: e.store,
|
|
718
709
|
target: t,
|
|
719
710
|
signalName: n,
|
|
@@ -722,54 +713,50 @@ var Jt = () => {
|
|
|
722
713
|
},
|
|
723
714
|
update: (t, n, r, i) => M.sendWorkflowUpdate({
|
|
724
715
|
store: e.store,
|
|
725
|
-
recorder:
|
|
716
|
+
recorder: P,
|
|
726
717
|
target: t,
|
|
727
718
|
updateName: n,
|
|
728
719
|
payload: r,
|
|
729
720
|
...i === void 0 ? {} : { options: i }
|
|
730
721
|
}),
|
|
731
722
|
listRuns: (t) => fe(e.store, t),
|
|
732
|
-
retry: (t, n) =>
|
|
723
|
+
retry: (t, n) => x({
|
|
733
724
|
store: e.store,
|
|
734
725
|
workflows: e.discovered.workflows ?? [],
|
|
735
|
-
runPromise: (e) =>
|
|
726
|
+
runPromise: (e) => o.runPromise(e)
|
|
736
727
|
}, t, n)
|
|
737
728
|
}) : void 0);
|
|
738
|
-
let
|
|
739
|
-
...
|
|
740
|
-
...
|
|
741
|
-
...
|
|
742
|
-
...
|
|
743
|
-
}), rt = !1,
|
|
729
|
+
let Be = A.mergeAll(O.toLayer(E), we, Te), We = f(E, e.discovered.queries.map((e) => e.descriptor.name), te), Ge = A.mergeAll(O.toLayer(We), we, Te), R = e.observability, Ze = await Fe({
|
|
730
|
+
...R && R.spanProcessors.length > 0 ? { extraSpanProcessors: R.spanProcessors } : {},
|
|
731
|
+
...R && R.metricReaders.length > 0 ? { extraMetricReaders: R.metricReaders } : {},
|
|
732
|
+
...R && Object.keys(R.resourceAttributes).length > 0 ? { resourceAttributes: R.resourceAttributes } : {},
|
|
733
|
+
...R && R.sampler !== void 0 ? { sampler: R.sampler } : {}
|
|
734
|
+
}), rt = !1, at = e.store.ping ? () => e.store.ping().then(() => !0).catch(() => !1) : void 0, V = lt({
|
|
744
735
|
group: O,
|
|
745
|
-
handlersLayer:
|
|
736
|
+
handlersLayer: Be,
|
|
746
737
|
httpHandlersLayer: Ge,
|
|
747
738
|
port: e.port ?? 4e3,
|
|
748
739
|
path: e.path ?? "/ws",
|
|
749
|
-
tracerLayer:
|
|
740
|
+
tracerLayer: Ze.layer,
|
|
750
741
|
healthCheck: {
|
|
751
742
|
isReady: () => rt,
|
|
752
|
-
...
|
|
743
|
+
...at ? { ping: at } : {}
|
|
753
744
|
},
|
|
754
|
-
...
|
|
755
|
-
...
|
|
745
|
+
...Se.length > 0 ? { httpRoutes: Se } : {},
|
|
746
|
+
...ce.size > 0 ? { webhookRoutes: ce } : {}
|
|
756
747
|
});
|
|
757
|
-
if (await
|
|
758
|
-
let t = (e.scheduleCoordination ?? "single") === "advisoryLock" ? Ue(e.store, e.scheduleReplicaId ?? `pid-${process.pid}`) :
|
|
759
|
-
c = await
|
|
748
|
+
if (await Ne(V), (e.discovered.schedules?.length ?? 0) > 0) {
|
|
749
|
+
let t = (e.scheduleCoordination ?? "single") === "advisoryLock" ? Ue(e.store, e.scheduleReplicaId ?? `pid-${process.pid}`) : ct;
|
|
750
|
+
c = await ut(e.discovered.schedules ?? [], {
|
|
760
751
|
store: e.store,
|
|
761
752
|
coordinator: t,
|
|
762
753
|
defaultTrigger: e.scheduleDefaultTrigger ?? "self",
|
|
763
754
|
replicaId: e.scheduleReplicaId ?? `pid-${process.pid}`,
|
|
764
755
|
armSelf: e.scheduleArmSelf ?? !0,
|
|
765
756
|
dormancy: e.dormancy ?? "always-on",
|
|
766
|
-
dormancyTenantId: e.dormancyTenantId
|
|
767
|
-
buildContext: ({ traceId: t, scheduleName: n }) =>
|
|
768
|
-
subject:
|
|
769
|
-
type: "anonymous",
|
|
770
|
-
id: null,
|
|
771
|
-
tenantId: null
|
|
772
|
-
},
|
|
757
|
+
...e.dormancyTenantId === void 0 ? {} : { dormancyTenantId: e.dormancyTenantId },
|
|
758
|
+
buildContext: ({ traceId: t, scheduleName: n, subject: r }) => b({
|
|
759
|
+
subject: r,
|
|
773
760
|
traceId: t
|
|
774
761
|
}, e.store, void 0, `schedule:${n}`),
|
|
775
762
|
log: {
|
|
@@ -785,26 +772,26 @@ var Jt = () => {
|
|
|
785
772
|
...e.onScheduleRunEvent === void 0 ? {} : { onRunEvent: e.onScheduleRunEvent }
|
|
786
773
|
}), e.onSchedulerReady?.(c);
|
|
787
774
|
}
|
|
788
|
-
let
|
|
789
|
-
if ((e.discovered.subscribers?.length ?? 0) > 0 && (
|
|
790
|
-
let t =
|
|
791
|
-
|
|
775
|
+
let dt = e.log ?? j({ scope: "voltro:serve" }), ft, mt;
|
|
776
|
+
if ((e.discovered.subscribers?.length ?? 0) > 0 && (ft = s(e.discovered.subscribers ?? [], e.store, dt.child("subscribe"), e.schemaRegistry)), (e.discovered.reactions?.length ?? 0) > 0) {
|
|
777
|
+
let t = dt.child("reaction");
|
|
778
|
+
mt = m(e.discovered.reactions ?? [], e.store, {
|
|
792
779
|
runAct: async (n, r) => {
|
|
793
780
|
if (n.kind === "workflow") {
|
|
794
|
-
if (
|
|
781
|
+
if (g === void 0) {
|
|
795
782
|
t.warn("reaction workflow act skipped — no workflow engine in this app", { workflow: n.workflow });
|
|
796
783
|
return;
|
|
797
784
|
}
|
|
798
785
|
let e = r.new ?? r.old ?? {};
|
|
799
|
-
await
|
|
786
|
+
await $e(g, {
|
|
800
787
|
traceId: `reaction:${n.workflow}`,
|
|
801
788
|
source: `reaction:${n.workflow}`
|
|
802
789
|
}).start(n.workflow, e);
|
|
803
790
|
return;
|
|
804
791
|
}
|
|
805
|
-
await
|
|
792
|
+
await de(n.agent, r, {
|
|
806
793
|
findAgentSend: (t) => e.discovered.actions.find((e) => e.descriptor.name === `${t}.send`),
|
|
807
|
-
runAction: (e, t, n) => Promise.resolve(
|
|
794
|
+
runAction: (e, t, n) => Promise.resolve(me(e, t, n)),
|
|
808
795
|
makeSubject: (e) => St(e),
|
|
809
796
|
now: () => Date.now(),
|
|
810
797
|
log: t
|
|
@@ -823,124 +810,124 @@ var Jt = () => {
|
|
|
823
810
|
}
|
|
824
811
|
}, t);
|
|
825
812
|
}
|
|
826
|
-
let
|
|
827
|
-
return (e.discovered.aggregates?.length ?? 0) > 0 && (
|
|
813
|
+
let gt;
|
|
814
|
+
return (e.discovered.aggregates?.length ?? 0) > 0 && (gt = await i({
|
|
828
815
|
discovered: e.discovered.aggregates ?? [],
|
|
829
816
|
store: e.store,
|
|
830
|
-
log:
|
|
817
|
+
log: dt.child("aggregate"),
|
|
831
818
|
...e.analytics === void 0 ? {} : { analytics: e.analytics },
|
|
832
819
|
...e.aggregateStorage === void 0 ? {} : { storage: e.aggregateStorage },
|
|
833
820
|
...e.aggregateCoordinator === void 0 ? {} : { coordinator: e.aggregateCoordinator }
|
|
834
|
-
}),
|
|
821
|
+
}), S = A.succeed(ke, gt.registry)), rt = !0, e.bootTiming?.mark("ready"), {
|
|
835
822
|
dispatcher: t,
|
|
836
823
|
server: V,
|
|
837
824
|
scheduler: c,
|
|
838
825
|
close: async () => {
|
|
839
|
-
rt = !1,
|
|
826
|
+
rt = !1, gt?.detach(), mt?.(), ft?.(), await c?.shutdown(), t.close(), await o?.dispose(), await new Promise((e) => V.close(() => e()));
|
|
840
827
|
}
|
|
841
828
|
};
|
|
842
|
-
}, $ = j({ scope: "voltro:serve" }),
|
|
829
|
+
}, $ = j({ scope: "voltro:serve" }), mn = (e, t, n) => (e === "production" || e === "staging") && t !== "memory" && n !== "0", hn = (e, t) => {
|
|
843
830
|
let n = e.indexOf(t);
|
|
844
831
|
return n >= 0 ? e[n + 1] : void 0;
|
|
845
|
-
},
|
|
832
|
+
}, gn = async (e) => {
|
|
846
833
|
let t = O(process.cwd());
|
|
847
834
|
if (M(t)) {
|
|
848
835
|
let n;
|
|
849
836
|
try {
|
|
850
|
-
let e = await import(
|
|
837
|
+
let e = await import(Ee(t).href);
|
|
851
838
|
typeof e.runServe == "function" ? n = e.runServe : $.warn("serve bundle has no runServe export — using the standard serve path");
|
|
852
839
|
} catch (e) {
|
|
853
840
|
$.warn("serve bundle failed to load — using the standard serve path", {}, e);
|
|
854
841
|
}
|
|
855
842
|
if (n) return $.info("serve: booting from the precompiled serve bundle"), n(e);
|
|
856
843
|
}
|
|
857
|
-
return
|
|
858
|
-
},
|
|
859
|
-
let
|
|
860
|
-
process.env.NODE_ENV || (process.env.NODE_ENV = "production"),
|
|
861
|
-
let
|
|
862
|
-
|
|
863
|
-
rawEnv:
|
|
844
|
+
return _n(e);
|
|
845
|
+
}, _n = async (i) => {
|
|
846
|
+
let s = Xt();
|
|
847
|
+
process.env.NODE_ENV || (process.env.NODE_ENV = "production"), ft();
|
|
848
|
+
let f = process.cwd(), p = Number(process.env.PORT ?? hn(i, "--port") ?? 4e3), m = await me(f);
|
|
849
|
+
at(rt(m?.secrets)), await t({
|
|
850
|
+
rawEnv: m?.env,
|
|
864
851
|
appType: "api",
|
|
865
|
-
root:
|
|
852
|
+
root: f,
|
|
866
853
|
log: $,
|
|
867
854
|
generateTypes: !1
|
|
868
|
-
}),
|
|
869
|
-
let
|
|
870
|
-
if (!
|
|
871
|
-
let e = await import(
|
|
855
|
+
}), s.mark("config");
|
|
856
|
+
let h = (process.env.DB_DIALECT ?? m?.store ?? "memory").toLowerCase(), ae = (h === "mariadb" || h === "postgres" || h === "mssql") && (process.env.CDC ?? "1") !== "0", _ = h === "mariadb" ? "mariadb" : h === "mssql" ? "mssql" : void 0, oe = we(f);
|
|
857
|
+
if (!Ce() && M(oe)) try {
|
|
858
|
+
let e = await import(Ee(oe).href);
|
|
872
859
|
if (e.modules) {
|
|
873
860
|
let t = {};
|
|
874
|
-
for (let [n, r] of Object.entries(e.modules)) t[
|
|
875
|
-
|
|
861
|
+
for (let [n, r] of Object.entries(e.modules)) t[Te(f, n)] = r;
|
|
862
|
+
Se(t), $.info("precompiled api bundle loaded", { modules: Object.keys(t).length });
|
|
876
863
|
}
|
|
877
864
|
} catch (e) {
|
|
878
865
|
$.warn("precompiled api bundle failed to load — falling back to source", {}, e);
|
|
879
866
|
}
|
|
880
|
-
let
|
|
881
|
-
mix:
|
|
882
|
-
plugins:
|
|
883
|
-
cdc:
|
|
867
|
+
let x = await le(f), C = await ge(x, { cdc: ae && _ !== void 0 }), de = x.filter((e) => xe.test(e)), fe = de.length > 0 ? await te(de, $.child("webhooks")) : void 0, ye = ve({
|
|
868
|
+
mix: C.featureMix,
|
|
869
|
+
plugins: m?.plugins ?? [],
|
|
870
|
+
cdc: ae && _ !== void 0,
|
|
884
871
|
..._ ? { cdcDialect: _ } : {}
|
|
885
|
-
}), be =
|
|
886
|
-
spec:
|
|
872
|
+
}), be = m?.analytics !== void 0 && m.analytics.kind !== "noop" && h !== "memory" ? (await w(h)).makeSqlLayer(S()) : void 0, D = await re({
|
|
873
|
+
spec: m?.analytics,
|
|
887
874
|
sqlLayer: be,
|
|
888
875
|
log: $
|
|
889
|
-
}),
|
|
890
|
-
let e = new Set(
|
|
891
|
-
for (let n of [...
|
|
876
|
+
}), O = (() => {
|
|
877
|
+
let e = new Set(C.tables.map((e) => e.tableName)), t = [...C.tables];
|
|
878
|
+
for (let n of [...ye, ...D.tables]) e.has(n.tableName) || (e.add(n.tableName), t.push(n));
|
|
892
879
|
return t;
|
|
893
880
|
})();
|
|
894
|
-
for (let e of
|
|
895
|
-
let
|
|
896
|
-
if (
|
|
897
|
-
let e = (await
|
|
898
|
-
appliedBy: `serve:${
|
|
881
|
+
for (let e of O) gt(e);
|
|
882
|
+
let j = (process.env.NODE_ENV ?? "").toLowerCase();
|
|
883
|
+
if (mn(j, h, process.env.VOLTRO_AUTO_MIGRATE)) {
|
|
884
|
+
let e = (await w(h)).makeSqlLayer(S()), t = await k.runPromise(mt.SqlClient.pipe(k.flatMap((e) => Nt(e, O, {
|
|
885
|
+
appliedBy: `serve:${j}`,
|
|
899
886
|
environment: "prod",
|
|
900
|
-
dialectId:
|
|
887
|
+
dialectId: h
|
|
901
888
|
})), k.provide(e)));
|
|
902
|
-
t.kind === "prod-mismatch" && ($.error(
|
|
889
|
+
t.kind === "prod-mismatch" && ($.error(Mt(t, h)), $.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(Mt(t, h));
|
|
903
890
|
}
|
|
904
|
-
let ke =
|
|
905
|
-
|
|
906
|
-
let
|
|
907
|
-
|
|
908
|
-
let { service: Ae, invalidationBus:
|
|
909
|
-
$.info(`cache backend resolved: ${
|
|
910
|
-
k.runFork(
|
|
911
|
-
}),
|
|
912
|
-
let { kv: Fe, service:
|
|
913
|
-
|
|
914
|
-
let Ve =
|
|
915
|
-
store:
|
|
916
|
-
sink:
|
|
891
|
+
let ke = Ze(O);
|
|
892
|
+
s.mark("discover");
|
|
893
|
+
let N = await pe(m, void 0);
|
|
894
|
+
m?.cache && !process.env.CACHE_BACKEND && (process.env.CACHE_BACKEND = m.cache), m?.cacheRedisUrl && !process.env.CACHE_REDIS_URL && (process.env.CACHE_REDIS_URL = m.cacheRedisUrl), m?.cacheRedisDriver && !process.env.CACHE_REDIS_DRIVER && (process.env.CACHE_REDIS_DRIVER = m.cacheRedisDriver), m?.cacheKeyPrefix && !process.env.CACHE_KEY_PREFIX && (process.env.CACHE_KEY_PREFIX = m.cacheKeyPrefix);
|
|
895
|
+
let { service: Ae, invalidationBus: je, snapshotCache: Ne, cache: F, backend: Pe, dispose: I } = await n({ env: process.env });
|
|
896
|
+
$.info(`cache backend resolved: ${Pe}` + (Pe === "redis" ? ` (driver ${process.env.CACHE_REDIS_DRIVER ?? "resp"})` : " — in-process, not cross-instance")), N.onChange((e) => {
|
|
897
|
+
k.runFork(je.publish(e.table));
|
|
898
|
+
}), m?.kv && !process.env.KV_BACKEND && (process.env.KV_BACKEND = m.kv), m?.kvRedisUrl && !process.env.KV_REDIS_URL && (process.env.KV_REDIS_URL = m.kvRedisUrl), m?.kvKeyPrefix && !process.env.KV_KEY_PREFIX && (process.env.KV_KEY_PREFIX = m.kvKeyPrefix);
|
|
899
|
+
let { kv: Fe, service: Ie } = await Ge({ store: N });
|
|
900
|
+
s.mark("store");
|
|
901
|
+
let Ve = Me({
|
|
902
|
+
store: N,
|
|
903
|
+
sink: D.sink,
|
|
917
904
|
log: $
|
|
918
|
-
}), He =
|
|
919
|
-
store:
|
|
920
|
-
dialect:
|
|
921
|
-
}),
|
|
922
|
-
|
|
923
|
-
let Ye =
|
|
905
|
+
}), He = g({
|
|
906
|
+
store: N,
|
|
907
|
+
dialect: h
|
|
908
|
+
}), L = m?.plugins ?? [], Ke = process.env.POD_NAME ?? process.env.HOSTNAME ?? `serve-${process.pid}`, qe, Je;
|
|
909
|
+
h !== "memory" && (qe = Oe.make((await w(h)).makeSqlLayer(S())), Je = await qe.runPromise(mt.SqlClient));
|
|
910
|
+
let Ye = R({
|
|
924
911
|
coordinator: [
|
|
925
912
|
"postgres",
|
|
926
913
|
"mariadb",
|
|
927
914
|
"mysql",
|
|
928
915
|
"mssql"
|
|
929
|
-
].includes(
|
|
916
|
+
].includes(h) ? Ue(N, Ke, $) : ct,
|
|
930
917
|
replicaId: Ke,
|
|
931
918
|
log: $
|
|
932
|
-
}),
|
|
919
|
+
}), Xe = [], Qe = {
|
|
933
920
|
...Je ? { sql: Je } : {},
|
|
934
921
|
scheduleCoordinated: (e, t, n) => {
|
|
935
922
|
let r = Ye(e, t, n);
|
|
936
|
-
return
|
|
923
|
+
return Xe.push(r), r;
|
|
937
924
|
}
|
|
938
925
|
};
|
|
939
|
-
for (let e of
|
|
940
|
-
let $e =
|
|
926
|
+
for (let e of L) e.bindDataStore?.(N, Qe);
|
|
927
|
+
let $e = L.filter((e) => typeof e.onChangeEvent == "function");
|
|
941
928
|
if ($e.length > 0) {
|
|
942
|
-
let e =
|
|
943
|
-
|
|
929
|
+
let e = N.changeScope ?? "local";
|
|
930
|
+
N.onChange((t) => {
|
|
944
931
|
let n = {
|
|
945
932
|
table: t.table,
|
|
946
933
|
op: t.op,
|
|
@@ -949,60 +936,60 @@ var Jt = () => {
|
|
|
949
936
|
...t.origin === void 0 ? {} : { origin: t.origin },
|
|
950
937
|
changeScope: e
|
|
951
938
|
};
|
|
952
|
-
for (let e of $e) k.runFork(e.onChangeEvent(n).pipe(k.catchAllCause((t) => k.sync(() => $.warn(`plugin ${e.name} onChangeEvent failed`, { error:
|
|
939
|
+
for (let e of $e) k.runFork(e.onChangeEvent(n).pipe(k.catchAllCause((t) => k.sync(() => $.warn(`plugin ${e.name} onChangeEvent failed`, { error: De.pretty(t) })))));
|
|
953
940
|
});
|
|
954
941
|
}
|
|
955
|
-
let et =
|
|
956
|
-
plugins:
|
|
957
|
-
appName:
|
|
942
|
+
let et = se({
|
|
943
|
+
plugins: L,
|
|
944
|
+
appName: m?.name ?? "voltro-api",
|
|
958
945
|
appType: "api",
|
|
959
946
|
voltroVersion: process.env.npm_package_version ?? "0.0.0",
|
|
960
947
|
log: $
|
|
961
948
|
});
|
|
962
|
-
|
|
963
|
-
let tt = await et.gatherObservability(), nt = await
|
|
949
|
+
L.length && await et.activate(), s.mark("plugins");
|
|
950
|
+
let tt = await et.gatherObservability(), nt = await y(N, m, h, {
|
|
964
951
|
info: (e, t) => process.stdout.write(`[broadcast] ${e} ${t ? JSON.stringify(t) : ""}\n`),
|
|
965
952
|
warn: (e, t) => process.stderr.write(`[broadcast] ${e} ${t ? JSON.stringify(t) : ""}\n`),
|
|
966
953
|
debug: () => {}
|
|
967
|
-
}), z =
|
|
968
|
-
store:
|
|
969
|
-
header: (typeof
|
|
970
|
-
ttlMs: (typeof
|
|
971
|
-
} : void 0, dt =
|
|
972
|
-
store:
|
|
973
|
-
resolveSubject: (e) =>
|
|
954
|
+
}), z = m?.apiKeys, it = (typeof z == "object" ? z.prefix : void 0) ?? "voltro_", ot = z ? We(Re(N), { prefix: it }) : void 0, st = ot ? [Be(ot, { prefix: it })] : [], lt = _e([...m?.auth?.strategies ?? [], ...st], Pt(m?.plugins ?? []), m?.auth?.anonymousTenantRequired ?? !1), ut = [...m?.restRoutes ?? [], ...ot ? P(ot, (typeof z == "object" ? z.managementPath : void 0) ?? "/v1/api-keys") : []], B = m?.idempotency, V = B ? {
|
|
955
|
+
store: ze(N),
|
|
956
|
+
header: (typeof B == "object" ? B.header : void 0) ?? "Idempotency-Key",
|
|
957
|
+
ttlMs: (typeof B == "object" ? B.ttlMs : void 0) ?? 864e5
|
|
958
|
+
} : void 0, dt = ut.length > 0 ? It(ut, {
|
|
959
|
+
store: N,
|
|
960
|
+
resolveSubject: (e) => lt({
|
|
974
961
|
headers: e,
|
|
975
962
|
clientId: -1
|
|
976
963
|
}),
|
|
977
|
-
...
|
|
978
|
-
}) : [], pt =
|
|
979
|
-
analyticsLayer:
|
|
964
|
+
...V ? { idempotency: V } : {}
|
|
965
|
+
}) : [], pt = L.map((e) => e.services).filter((e) => e !== void 0), ht = A.mergeAll(d({
|
|
966
|
+
analyticsLayer: D.layer,
|
|
980
967
|
cacheService: Ae,
|
|
981
|
-
kvService:
|
|
968
|
+
kvService: Ie,
|
|
982
969
|
pluginServices: pt,
|
|
983
|
-
userLayers:
|
|
984
|
-
}),
|
|
970
|
+
userLayers: m?.layers ?? []
|
|
971
|
+
}), E), H = m?.scheduling ?? {}, _t = H.trigger ?? "self", vt = /* @__PURE__ */ new Set([
|
|
985
972
|
"postgres",
|
|
986
973
|
"mysql",
|
|
987
974
|
"mariadb",
|
|
988
975
|
"mssql"
|
|
989
|
-
]),
|
|
990
|
-
|
|
991
|
-
let bt, xt =
|
|
976
|
+
]), yt = H.coordination ?? (vt.has(h) ? "advisoryLock" : "single"), U = yt === "cluster" && vt.has(h), W = U ? "cluster" : yt === "advisoryLock" && vt.has(h) ? "advisoryLock" : "single";
|
|
977
|
+
yt === "cluster" && !U && $.warn("scheduling.coordination=cluster needs a sql-backed store except sqlite — falling back to single"), yt === "advisoryLock" && !vt.has(h) && $.warn("scheduling.coordination=advisoryLock needs a SQL store (the claim-row gate) — falling back to single");
|
|
978
|
+
let bt, xt = C.workflows.length > 0 || C.workflowWorkers.length > 0 || C.eventTriggers.length > 0 || (fe?.outgoing.length ?? 0) > 0 || U, G;
|
|
992
979
|
if (xt) {
|
|
993
|
-
if (
|
|
994
|
-
let e = await
|
|
980
|
+
if (h === "mssql") {
|
|
981
|
+
let e = await l(process.cwd());
|
|
995
982
|
e && $.warn(e);
|
|
996
983
|
}
|
|
997
|
-
let [{ WorkflowEngine: e }, { makeClusterCronLayer: t, workflowEngineLayer: n, resolveRunnerStorage: r }] = await Promise.all([import("@effect/workflow"), import("@voltro/workflow/cluster")]), i =
|
|
984
|
+
let [{ WorkflowEngine: e }, { makeClusterCronLayer: t, workflowEngineLayer: n, resolveRunnerStorage: r }] = await Promise.all([import("@effect/workflow"), import("@voltro/workflow/cluster")]), i = U ? C.schedules.filter((e) => (e.trigger ?? _t) === "self").map((e) => t({
|
|
998
985
|
name: e.name,
|
|
999
|
-
cron:
|
|
986
|
+
cron: Le(e),
|
|
1000
987
|
execute: async () => {
|
|
1001
988
|
await bt?.fireFromCluster(e.name);
|
|
1002
989
|
}
|
|
1003
990
|
})) : [];
|
|
1004
|
-
G =
|
|
1005
|
-
let e = await
|
|
991
|
+
G = h === "memory" ? e.layerMemory : await (async () => {
|
|
992
|
+
let e = await w(h), t = r({ sqliteFamily: e.id === "sqlite" || e.id === "turso" });
|
|
1006
993
|
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)" : "") : "")), n({
|
|
1007
994
|
sqlClientLayer: e.makeSqlLayer(S()),
|
|
1008
995
|
runnerStorage: t,
|
|
@@ -1012,100 +999,100 @@ var Jt = () => {
|
|
|
1012
999
|
});
|
|
1013
1000
|
})();
|
|
1014
1001
|
}
|
|
1015
|
-
let
|
|
1016
|
-
if (
|
|
1017
|
-
Y =
|
|
1002
|
+
let K = b(L, e()), St = x.filter((e) => /\.subscribe\.tsx?$/.test(e)), Ct = St.length > 0 ? await u(St, $) : [], q = x.filter((e) => /\.reaction\.tsx?$/.test(e)), wt = q.length > 0 ? await r(q, $) : [], Tt = x.filter((e) => /\.outbox\.tsx?$/.test(e)), Et = Tt.length > 0 ? await ee(Tt, $) : [], J = x.filter((e) => /\.aggregate\.tsx?$/.test(e)), Dt = J.length > 0 ? await ne(J, $) : [], Y = o();
|
|
1003
|
+
if (Dt.length > 0 && h !== "memory") try {
|
|
1004
|
+
Y = a((await w(h)).makeSqlLayer(S()));
|
|
1018
1005
|
} catch (e) {
|
|
1019
1006
|
$.warn("aggregate: SQL storage init failed — falling back to in-process", { err: String(e) });
|
|
1020
1007
|
}
|
|
1021
|
-
let Ot =
|
|
1008
|
+
let Ot = h === "memory" ? ct : Ue(N, `aggregate@${process.pid}`, $), X = [], Z = [], kt = x.filter((e) => he.test(e));
|
|
1022
1009
|
if (kt.length > 0) {
|
|
1023
|
-
let e = $.child("agent"), t =
|
|
1024
|
-
t.length > 0 && await
|
|
1025
|
-
let n = await
|
|
1026
|
-
for (let e of n.agents) for (let t of
|
|
1010
|
+
let e = $.child("agent"), t = x.filter((e) => ue.test(e));
|
|
1011
|
+
t.length > 0 && await T(t, e);
|
|
1012
|
+
let n = await v(kt, e);
|
|
1013
|
+
for (let e of n.agents) for (let t of ce(e)) (t.kind === "action" ? X : Z).push({
|
|
1027
1014
|
file: t.file,
|
|
1028
1015
|
descriptor: t.descriptor,
|
|
1029
1016
|
executor: t.executor
|
|
1030
1017
|
});
|
|
1031
1018
|
n.agents.length > 0 && e.info("synthesized agent routes", { agents: n.agents.map((e) => e.descriptor.name) });
|
|
1032
1019
|
}
|
|
1033
|
-
|
|
1034
|
-
let
|
|
1035
|
-
bootTiming:
|
|
1020
|
+
s.mark("workflow");
|
|
1021
|
+
let At = await pn({
|
|
1022
|
+
bootTiming: s,
|
|
1036
1023
|
discovered: {
|
|
1037
|
-
queries: [...
|
|
1038
|
-
mutations:
|
|
1039
|
-
actions: [...
|
|
1040
|
-
streams:
|
|
1041
|
-
workflows:
|
|
1042
|
-
workflowWorkers:
|
|
1043
|
-
eventTriggers:
|
|
1044
|
-
schedules:
|
|
1045
|
-
subscribers:
|
|
1024
|
+
queries: [...C.queries, ...Z],
|
|
1025
|
+
mutations: C.mutations,
|
|
1026
|
+
actions: [...C.actions, ...X],
|
|
1027
|
+
streams: C.streams,
|
|
1028
|
+
workflows: C.workflows,
|
|
1029
|
+
workflowWorkers: C.workflowWorkers,
|
|
1030
|
+
eventTriggers: C.eventTriggers,
|
|
1031
|
+
schedules: C.schedules,
|
|
1032
|
+
subscribers: Ct,
|
|
1046
1033
|
outboxHandlers: Et,
|
|
1047
|
-
connections:
|
|
1048
|
-
reactions:
|
|
1049
|
-
aggregates:
|
|
1050
|
-
...
|
|
1034
|
+
connections: C.connections,
|
|
1035
|
+
reactions: wt,
|
|
1036
|
+
aggregates: Dt,
|
|
1037
|
+
...fe === void 0 ? {} : { webhooks: fe }
|
|
1051
1038
|
},
|
|
1052
1039
|
log: $,
|
|
1053
|
-
analytics:
|
|
1040
|
+
analytics: D.sink,
|
|
1054
1041
|
aggregateStorage: Y,
|
|
1055
1042
|
aggregateCoordinator: Ot,
|
|
1056
|
-
store:
|
|
1043
|
+
store: N,
|
|
1057
1044
|
kv: Fe,
|
|
1058
|
-
cache:
|
|
1059
|
-
snapshotCache:
|
|
1045
|
+
cache: F,
|
|
1046
|
+
snapshotCache: Ne,
|
|
1060
1047
|
schemaRegistry: ke,
|
|
1061
|
-
tenantScopedTables:
|
|
1062
|
-
softDeleteScopedTables:
|
|
1063
|
-
dataTransferSnapshot:
|
|
1064
|
-
dataTransferDialect:
|
|
1065
|
-
tenantIsolation: (process.env.VOLTRO_TENANT_ISOLATION ??
|
|
1066
|
-
resolveSubject: (e, t) =>
|
|
1048
|
+
tenantScopedTables: C.tenantScopedTables,
|
|
1049
|
+
softDeleteScopedTables: C.softDeleteScopedTables,
|
|
1050
|
+
dataTransferSnapshot: jt(O),
|
|
1051
|
+
dataTransferDialect: h,
|
|
1052
|
+
tenantIsolation: (process.env.VOLTRO_TENANT_ISOLATION ?? m?.tenancy?.isolation) === "namespace" ? "namespace" : "shared-schema",
|
|
1053
|
+
resolveSubject: (e, t) => lt({
|
|
1067
1054
|
headers: e,
|
|
1068
1055
|
clientId: t
|
|
1069
1056
|
}),
|
|
1070
|
-
httpRoutes: [...
|
|
1071
|
-
...
|
|
1057
|
+
httpRoutes: [...L.flatMap((e) => e.httpRoutes ?? []), ...dt],
|
|
1058
|
+
...ht ? { baseLayer: ht } : {},
|
|
1072
1059
|
...G === void 0 ? {} : { workflowEngineLayer: G },
|
|
1073
|
-
scheduleDefaultTrigger:
|
|
1074
|
-
scheduleCoordination:
|
|
1075
|
-
scheduleArmSelf: !
|
|
1076
|
-
dormancy: process.env.VOLTRO_DORMANCY === "sleep" || process.env.VOLTRO_DORMANCY === "always-on" ? process.env.VOLTRO_DORMANCY :
|
|
1060
|
+
scheduleDefaultTrigger: _t,
|
|
1061
|
+
scheduleCoordination: W,
|
|
1062
|
+
scheduleArmSelf: !U,
|
|
1063
|
+
dormancy: process.env.VOLTRO_DORMANCY === "sleep" || process.env.VOLTRO_DORMANCY === "always-on" ? process.env.VOLTRO_DORMANCY : m?.dormancy ?? "always-on",
|
|
1077
1064
|
scheduleReplicaId: process.env.HOSTNAME ?? `pid-${process.pid}`,
|
|
1078
|
-
...
|
|
1065
|
+
...K === void 0 ? {} : { scheduleFireInterceptor: K },
|
|
1079
1066
|
onSchedulerReady: (e) => {
|
|
1080
1067
|
bt = e;
|
|
1081
1068
|
},
|
|
1082
1069
|
observability: tt,
|
|
1083
|
-
port:
|
|
1084
|
-
...
|
|
1070
|
+
port: p,
|
|
1071
|
+
...m?.transport?.wsPath ? { path: m.transport.wsPath } : {}
|
|
1085
1072
|
});
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1073
|
+
c(ie([
|
|
1074
|
+
C.queries,
|
|
1075
|
+
C.mutations,
|
|
1076
|
+
C.actions,
|
|
1077
|
+
C.streams
|
|
1091
1078
|
]), (e) => {
|
|
1092
1079
|
$.warn(e);
|
|
1093
|
-
}), $.info(`API listening on :${
|
|
1094
|
-
dialect:
|
|
1095
|
-
queries:
|
|
1096
|
-
mutations:
|
|
1097
|
-
actions:
|
|
1098
|
-
streams:
|
|
1099
|
-
workflows:
|
|
1100
|
-
workflowWorkers:
|
|
1101
|
-
schedules:
|
|
1102
|
-
scheduleCoordination:
|
|
1103
|
-
}),
|
|
1104
|
-
let
|
|
1105
|
-
for (let e of
|
|
1106
|
-
Ve.detach(), He.stop(),
|
|
1080
|
+
}), $.info(`API listening on :${p}`, {
|
|
1081
|
+
dialect: h,
|
|
1082
|
+
queries: C.queries.length,
|
|
1083
|
+
mutations: C.mutations.length,
|
|
1084
|
+
actions: C.actions.length,
|
|
1085
|
+
streams: C.streams.length,
|
|
1086
|
+
workflows: C.workflows.length,
|
|
1087
|
+
workflowWorkers: C.workflowWorkers.length,
|
|
1088
|
+
schedules: C.schedules.length,
|
|
1089
|
+
scheduleCoordination: W
|
|
1090
|
+
}), s.finish($);
|
|
1091
|
+
let Ft = () => {
|
|
1092
|
+
for (let e of Xe) e.stop();
|
|
1093
|
+
Ve.detach(), He.stop(), I(), qe?.dispose(), Promise.resolve(et.deactivate()).then(() => nt?.close()).then(() => D.dispose()).then(() => At.close()).then(() => N.close?.()).then(() => process.exit(0));
|
|
1107
1094
|
};
|
|
1108
|
-
return process.on("SIGINT",
|
|
1095
|
+
return process.on("SIGINT", Ft), process.on("SIGTERM", Ft), await new Promise(() => {}), 0;
|
|
1109
1096
|
};
|
|
1110
1097
|
//#endregion
|
|
1111
|
-
export {
|
|
1098
|
+
export { gn as n, dn as r, _n as t };
|