@voltro/cli 0.47.0 → 0.48.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 +80 -0
- package/dist/apiBuild-DOnvi2zm.js +2 -0
- package/dist/{apiBuild-FpHCWiv6.js → apiBuild-Dz8TJSxp.js} +1 -1
- package/dist/bin.js +1 -1
- package/dist/{build-zVygXxGB.js → build-DLme2ppa.js} +6 -6
- package/dist/{checkCommand-B2Fw73lu.js → checkCommand-BUBqPBlI.js} +1 -1
- package/dist/{checkCommand-D0dAKciE.js → checkCommand-Dals7g-I.js} +3 -3
- package/dist/{codegenCommand-BTtsnRus.js → codegenCommand-L6vacVRW.js} +3 -2
- package/dist/{commands-BrFKxnYW.js → commands-CAxFLqG4.js} +17 -17
- package/dist/{dashboardCommand-D9SjDc8E.js → dashboardCommand-CJC8Kg-s.js} +1 -1
- package/dist/{dataCommand-Dl11q14e.js → dataCommand-hIaq2iKY.js} +266 -189
- package/dist/dbCommand-D1Q33ktl.js +2 -0
- package/dist/{dbCommand-jbrmzwW_.js → dbCommand-ZGNItjoJ.js} +4 -4
- package/dist/declaredSchemaGates-BlcwObhb.js +25 -0
- package/dist/{dev-CaIfZnw5.js → dev-cGGsLNn6.js} +1 -1
- package/dist/{dev-RjB7eE_B.js → dev-lvnVq5RD.js} +31 -30
- package/dist/{doctorCommand-D7X29cw6.js → doctorCommand-BK0qu7eD.js} +32 -14
- package/dist/doctorCommand-CWgUPye-.js +2 -0
- package/dist/doctorDecidedSchema-BlbWgCD_.js +23 -0
- package/dist/{dormancyCommand-BGOP27fz.js → dormancyCommand-CyIk-zq4.js} +1 -1
- package/dist/{embeddingsCommand-D72E22bw.js → embeddingsCommand-D7TLklps.js} +1 -1
- package/dist/{envCommand-BHSxz6wC.js → envCommand-BHxKkGXq.js} +1 -1
- package/dist/{evolveCommand-C2ofGGlz.js → evolveCommand-CQh6dw21.js} +1 -1
- package/dist/{frameworkTableAssembly-BvZ0Lil_.js → frameworkTableAssembly-BNod_DKN.js} +97 -120
- package/dist/frameworkTableAssembly-Rft-DPUg.js +2 -0
- package/dist/index.js +1 -1
- package/dist/{migrate-odCPGHPq.js → migrate-CL5Ed01M.js} +4 -4
- package/dist/{runtimeTrace-C_OKr0jY.js → runtimeTrace-C0SlIoQY.js} +1 -1
- package/dist/{sdkgen-D9trW7sl.js → sdkgen-BXm7zx7F.js} +1 -1
- package/dist/{serveCommand-BU0wfV6V.js → serveCommand-CV3YO9L3.js} +469 -365
- package/dist/serveCommand-ZP_Cb-yz.js +2 -0
- package/dist/serveEntry.js +1 -1
- package/dist/{webhooksCommand-BqcWcbuW.js → webhooksCommand-QlAk_tED.js} +1 -1
- 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 +58 -3
- package/templates/agent-docs/database/migrations.md +19 -5
- package/templates/agent-docs/whats-new.md +63 -13
- 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-sqlite/package.json +8 -8
- package/templates/apps/api-backend-storage/package.json +8 -8
- package/templates/apps/api-cms/package.json +10 -10
- package/templates/apps/api-collab/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-saas-starter/package.json +10 -10
- package/templates/apps/api-search/package.json +8 -8
- package/templates/apps/api-status/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 +9 -9
- package/templates/apps/frontend-auth/package.json +8 -8
- package/templates/apps/frontend-blank/package.json +7 -7
- package/templates/apps/frontend-cms/package.json +9 -9
- package/templates/apps/frontend-collab/package.json +10 -10
- 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-portal/package.json +8 -8
- package/templates/apps/frontend-saas/package.json +8 -8
- 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/templates/apps/frontend-status/package.json +8 -8
- package/templates/apps/mobile-app/package.json +4 -4
- package/dist/apiBuild-BsooZpw2.js +0 -2
- package/dist/dbCommand-BUD4Fd8v.js +0 -2
- package/dist/doctorCommand-5zv6PN-G.js +0 -2
- package/dist/frameworkTableAssembly-DDKtwsy2.js +0 -2
- package/dist/serveCommand-Bwrn_9Fn.js +0 -2
|
@@ -4,20 +4,21 @@ import { r as n, t as r } from "./appModuleLoader-C9r9mxZt.js";
|
|
|
4
4
|
import { t as i } from "./bootRefusal-pgvDxlrU.js";
|
|
5
5
|
import { n as a, r as o } from "./startupRunner-CEqQq7ax.js";
|
|
6
6
|
import { t as ee } from "./interruptedReplace-C1ZI84xi.js";
|
|
7
|
-
import { $ as s, $t as c, A as l, At as u, Bt as d, C as f, Cn as p, Ct as m, D as h, Dt as g, E as _, En as te, Et as v, F as ne, Ft as re, G as ie, Gt as ae, H as y, Ht as oe, I as se, It as ce, J as le, Jt as b, K as x, Kt as ue, L as S, Lt as de, M as fe, Mt as pe, N as me, Nt as he, O as ge, Ot as _e, P as ve, Pt as ye, Q as be, Qt as xe, R as C, Rt as Se, S as Ce, St as we, T as Te, Tn as Ee, Tt as w, U as De, V as Oe, W as ke, Wt as Ae, X as je, Xt as Me, Y as Ne, Yt as T, Z as Pe, Zt as Fe, _ as E, _n as Ie, _t as
|
|
7
|
+
import { $ as s, $t as c, A as l, At as u, Bt as d, C as f, Cn as p, Ct as m, D as h, Dt as g, E as _, En as te, Et as v, F as ne, Ft as re, G as ie, Gt as ae, H as y, Ht as oe, I as se, It as ce, J as le, Jt as b, K as x, Kt as ue, L as S, Lt as de, M as fe, Mt as pe, N as me, Nt as he, O as ge, Ot as _e, P as ve, Pt as ye, Q as be, Qt as xe, R as C, Rt as Se, S as Ce, St as we, T as Te, Tn as Ee, Tt as w, U as De, V as Oe, W as ke, Wt as Ae, X as je, Xt as Me, Y as Ne, Yt as T, Z as Pe, Zt as Fe, _ as E, _n as Ie, _t as Le, an as Re, at as ze, b as Be, bn as Ve, bt as He, c as Ue, cn as We, ct as Ge, dn as Ke, dt as qe, en as Je, et as Ye, f as Xe, fn as Ze, ft as Qe, g as $e, gt as et, h as tt, hn as nt, ht as rt, i as it, in as at, it as ot, j as st, jt as ct, k as lt, kt as ut, ln as dt, lt as ft, m as pt, mn as mt, mt as ht, nn as gt, nt as D, o as O, on as _t, ot as k, p as A, pn as vt, pt as yt, q as bt, qt as xt, r as St, rn as Ct, rt as wt, sn as j, st as Tt, t as Et, tn as Dt, tt as Ot, u as kt, un as At, ut as jt, v as Mt, vn as Nt, vt as M, w as N, wn as Pt, wt as Ft, x as It, xn as Lt, xt as Rt, y as zt, yn as Bt, yt as Vt, zt as Ht } from "./dev-lvnVq5RD.js";
|
|
8
8
|
import { n as Ut } from "./cliArgs-D4p8n7EE.js";
|
|
9
9
|
import { r as P } from "./appPort-B_HpJ_ck.js";
|
|
10
10
|
import { ht as Wt, pt as Gt } from "./webDev-B4IEMB0n.js";
|
|
11
11
|
import { r as F } from "./dialectDriver-czCHYpeH.js";
|
|
12
12
|
import { i as Kt, n as qt } from "./connectionConfig-Bk9IC7D0.js";
|
|
13
13
|
import { c as Jt, n as I, o as Yt } from "./seedRunner-Dgsiwk_e.js";
|
|
14
|
-
import {
|
|
14
|
+
import { b as Xt, d as Zt, h as Qt, m as $t, p as en, r as tn, y as nn } from "./frameworkTableAssembly-BNod_DKN.js";
|
|
15
|
+
import { n as rn, r as an, t as on } from "./declaredSchemaGates-BlcwObhb.js";
|
|
15
16
|
import { S as sn, c as cn, n as ln, p as un, s as dn, x as fn } from "./fileConventions-Cof68_BL.js";
|
|
16
17
|
import { h as pn, o as mn } from "./inspect-B7U7Cl_Z.js";
|
|
17
18
|
import { n as hn } from "./mssqlClusterPatch-_4cE_nun.js";
|
|
18
19
|
import { i as gn, n as _n, r as vn, t as yn } from "./webhookDiscovery-CphsQe59.js";
|
|
19
20
|
import { t as bn } from "./inspectMetrics-CfdKLh6t.js";
|
|
20
|
-
import { r as xn, u as Sn } from "./apiBuild-
|
|
21
|
+
import { r as xn, u as Sn } from "./apiBuild-Dz8TJSxp.js";
|
|
21
22
|
import { t as Cn } from "./bootTiming-BdyP9nYw.js";
|
|
22
23
|
import { t as wn } from "./dataProfile-Cm0YVKSy.js";
|
|
23
24
|
import Tn, { basename as En, join as Dn } from "node:path";
|
|
@@ -25,25 +26,25 @@ import { createWriteStream as On, existsSync as kn } from "node:fs";
|
|
|
25
26
|
import { pathToFileURL as An } from "node:url";
|
|
26
27
|
import { createLogger as L } from "@voltro/logger";
|
|
27
28
|
import { AuthMiddleware as jn, ConnectionInfoMiddleware as Mn, actionToRpc as R, anonymousSubject as Nn, isWireReachable as Pn, mutationToRpc as Fn, queryToRpc as z, streamToRpc as In, wireErrorUnion as Ln, workflowCancelDescriptor as Rn, workflowDomainEventsQueryDescriptor as B, workflowEventDeliveriesQueryDescriptor as V, workflowResumeDescriptor as zn, workflowRunEventsQueryDescriptor as Bn, workflowRunQueryDescriptor as Vn, workflowRunStepsQueryDescriptor as Hn, workflowRunsQueryDescriptor as Un, workflowSignalDescriptor as Wn, workflowUpdateDescriptor as Gn } from "@voltro/protocol";
|
|
28
|
-
import { allRegisteredTables as Kn, and as
|
|
29
|
-
import { Cause as
|
|
30
|
-
import { SqlClient as
|
|
31
|
-
import { declaredSnapshot as
|
|
32
|
-
import { AggregateRegistry as
|
|
33
|
-
import
|
|
34
|
-
import { RpcGroup as
|
|
35
|
-
import { appStorageProvider as
|
|
36
|
-
import { isEnvContract as
|
|
37
|
-
import { assertProductionSessionSecret as
|
|
29
|
+
import { IMPORT_RUNS_TABLE as H, allRegisteredTables as Kn, and as qn, connectionIdentity as Jn, describeImportRun as Yn, ensureTableRegistered as Xn, eq as U, or as Zn } from "@voltro/database";
|
|
30
|
+
import { Cause as Qn, Effect as W, Layer as G, ManagedRuntime as $n } from "effect";
|
|
31
|
+
import { SqlClient as er } from "@effect/sql";
|
|
32
|
+
import { declaredSnapshot as tr, describeOutcome as nr, pendingFileMigrationIds as rr, runPlannedMigrations as ir } from "@voltro/database/sql";
|
|
33
|
+
import { AggregateRegistry as ar, CostRegistry as K, DORMANCY_WAKEUP_TENANT as or, Dispatcher as sr, ExpectationRegistry as cr, ExperimentRegistry as lr, apiKeyManagementRoutes as ur, attachAnalyticsMirror as dr, attachExpectations as fr, attachExperiments as pr, attachFinops as mr, awaitServerListening as hr, bindMutation as q, bindStream as gr, bindSubscription as _r, buildTracingLayer as vr, cancelWakeup as yr, compileCron as br, dataStoreApiKeyStore as xr, formatServerOnlyLeaks as Sr, formatUnresolvedSources as Cr, frameworkApiKeyStrategy as wr, getResourcePolicy as Tr, installPolicyGuardResolver as Er, loadResourceTuples as Dr, makeActionRunner as Or, makeAdvisoryLockCoordinator as kr, makeApiKeyService as Ar, makeApiKeyUsageBuffer as jr, makeApiKeyUsageFlusher as Mr, makeAsyncKv as Nr, makeAuthMiddlewareLayers as Pr, makeCoordinatedScheduler as Fr, makeEffectStoreLayer as Ir, makeLazyWorkflowFacade as Lr, makeMutationOutputCodec as Rr, makeMutationRunner as zr, makeOneShotQueryRunner as Br, makeQueryDescriptorProducer as Vr, makeQueryFinalizer as Hr, makeQueryReauthorizer as J, makeQuerySubscriber as Ur, makeSchemaRegistry as Wr, makeWorkflowFacade as Gr, makeWorkflowFacadeWithCallerContext as Kr, makeWorkflowLayers as qr, noopKv as Jr, onProcessShutdown as Yr, recordSubscriptionDelivery as Xr, recordWorkflowRun as Zr, registerDefaultTupleSource as Y, registerWakeup as Qr, resolveSecretsBackend as $r, runProvidedEffect as ei, setSecretsBackend as ti, setSystemStoreHandle as ni, shutdownGraceMsFromEnv as ri, singleCoordinator as ii, startRpcServer as ai, startScheduler as oi, stripForbiddenForWire as si, undoCaptureEnabled as ci, unresolvedSources as li, withScopedRequest as ui, workflowToRpc as di, wrapStoreWithBootCodec as fi } from "@voltro/runtime";
|
|
34
|
+
import pi, { tmpdir as mi } from "node:os";
|
|
35
|
+
import { RpcGroup as hi } from "@effect/rpc";
|
|
36
|
+
import { appStorageProvider as gi, durabilityNotice as _i, fromNodeReadable as vi, getObjectStream as yi, putObjectStream as bi, toNodeReadable as xi } from "@voltro/plugin-storage";
|
|
37
|
+
import { isEnvContract as Si } from "@voltro/env";
|
|
38
|
+
import { assertProductionSessionSecret as Ci } from "@voltro/protocol/session";
|
|
38
39
|
import X from "node:fs/promises";
|
|
39
|
-
import { createHash as
|
|
40
|
-
import { buildDeliverWebhookExecute as
|
|
41
|
-
import { getAuthSessionStrategy as
|
|
42
|
-
import { registerEmailTemplates as
|
|
43
|
-
import { channelFor as
|
|
44
|
-
import { packBundle as
|
|
40
|
+
import { createHash as wi, timingSafeEqual as Ti } from "node:crypto";
|
|
41
|
+
import { buildDeliverWebhookExecute as Ei, buildWebhooksService as Di, defaultIncomingPath as Oi, deliverWebhookWorkflow as ki, makeDeferredEmitHandler as Ai, mountIncomingWebhook as ji } from "@voltro/plugin-webhooks";
|
|
42
|
+
import { getAuthSessionStrategy as Mi } from "@voltro/plugin-auth";
|
|
43
|
+
import { registerEmailTemplates as Ni } from "@voltro/plugin-mail";
|
|
44
|
+
import { channelFor as Pi, getBroadcastPlugin as Fi } from "@voltro/plugin-broadcast";
|
|
45
|
+
import { decideStaging as Ii, isEnvironmentLocal as Li, packBundle as Ri, peekBundle as zi, runExport as Bi, runImport as Vi, storageBlobSink as Hi, storageRefsBlobSource as Ui, unpackBundle as Wi, unpackBundleToDir as Gi } from "@voltro/data-transfer";
|
|
45
46
|
//#region src/serveDrain.ts
|
|
46
|
-
var
|
|
47
|
+
var Ki = () => Math.max(500, Math.floor(ri() * .6)), qi = (e) => new Promise((t) => setTimeout(t, e)), Ji = (e) => {
|
|
47
48
|
let t = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set(), r = 0;
|
|
48
49
|
e.on("connection", (e) => {
|
|
49
50
|
t.add(e), e.once("close", () => {
|
|
@@ -57,14 +58,14 @@ var Vi = () => Math.max(500, Math.floor(ti() * .6)), Hi = (e) => new Promise((t)
|
|
|
57
58
|
});
|
|
58
59
|
});
|
|
59
60
|
let i, a = async (t = {}) => {
|
|
60
|
-
let n = t.budgetMs ??
|
|
61
|
+
let n = t.budgetMs ?? Ki();
|
|
61
62
|
i ??= new Promise((t) => {
|
|
62
63
|
e.close(() => {
|
|
63
64
|
t();
|
|
64
65
|
});
|
|
65
66
|
}), e.closeIdleConnections();
|
|
66
67
|
let a = Date.now() + n;
|
|
67
|
-
for (; r > 0 && Date.now() < a;) await
|
|
68
|
+
for (; r > 0 && Date.now() < a;) await qi(25), e.closeIdleConnections();
|
|
68
69
|
e.closeIdleConnections();
|
|
69
70
|
}, o = async () => {
|
|
70
71
|
i ??= new Promise((t) => {
|
|
@@ -81,7 +82,7 @@ var Vi = () => Math.max(500, Math.floor(ti() * .6)), Hi = (e) => new Promise((t)
|
|
|
81
82
|
]));
|
|
82
83
|
} catch {}
|
|
83
84
|
else e.destroy();
|
|
84
|
-
for (let e = 0; t.size > 0 && e < 250; e += 25) await
|
|
85
|
+
for (let e = 0; t.size > 0 && e < 250; e += 25) await qi(25);
|
|
85
86
|
for (let e of t) e.destroy();
|
|
86
87
|
await i;
|
|
87
88
|
};
|
|
@@ -93,77 +94,77 @@ var Vi = () => Math.max(500, Math.floor(ti() * .6)), Hi = (e) => new Promise((t)
|
|
|
93
94
|
await a(e), await o();
|
|
94
95
|
}
|
|
95
96
|
};
|
|
96
|
-
},
|
|
97
|
+
}, Yi = "/_voltro/admin/import", Xi = "/_voltro/admin/export", Zi = "/_voltro/admin/imports", Z = (e, t) => ({
|
|
97
98
|
status: e,
|
|
98
99
|
contentType: "application/json; charset=utf-8",
|
|
99
100
|
body: JSON.stringify(t)
|
|
100
|
-
}),
|
|
101
|
+
}), Qi = (e) => {
|
|
101
102
|
let t = e.authorization ?? e.Authorization, n = t ? /^Bearer\s+(.+)$/i.exec(t) : null;
|
|
102
103
|
return n ? n[1] : null;
|
|
103
|
-
},
|
|
104
|
-
if (e.method.toUpperCase() !==
|
|
104
|
+
}, $i = (e, t) => Ti(wi("sha256").update(e).digest(), wi("sha256").update(t).digest()), ea = (e, t, n = "POST") => {
|
|
105
|
+
if (e.method.toUpperCase() !== n) return Z(405, { error: "method not allowed" });
|
|
105
106
|
if (!t || t.length < 16) return Z(503, { error: "data transfer misconfigured (no/weak secret)" });
|
|
106
|
-
let
|
|
107
|
-
return !
|
|
108
|
-
},
|
|
107
|
+
let r = Qi(e.headers);
|
|
108
|
+
return !r || !$i(r, t) ? Z(401, { error: "unauthorized" }) : null;
|
|
109
|
+
}, ta = /^[A-Za-z0-9_-]{8,64}$/, na = (e) => ta.test(e), ra = () => Tn.join(pi.tmpdir(), "voltro-import-uploads"), ia = (e) => Tn.join(ra(), e), aa = (e) => Tn.join(ia(e), "archive.bin"), oa = (e) => Tn.join(ia(e), "meta.json"), sa = async (e = Date.now()) => {
|
|
109
110
|
let t = 0;
|
|
110
111
|
try {
|
|
111
|
-
for (let n of await X.readdir(
|
|
112
|
-
let r = await X.stat(
|
|
113
|
-
r !== null && (e - r.mtimeMs <= 864e5 || (await X.rm(
|
|
112
|
+
for (let n of await X.readdir(ra())) {
|
|
113
|
+
let r = await X.stat(ia(n)).catch(() => null);
|
|
114
|
+
r !== null && (e - r.mtimeMs <= 864e5 || (await X.rm(ia(n), {
|
|
114
115
|
recursive: !0,
|
|
115
116
|
force: !0
|
|
116
117
|
}).catch(() => void 0), t++));
|
|
117
118
|
}
|
|
118
119
|
} catch {}
|
|
119
120
|
return t;
|
|
120
|
-
},
|
|
121
|
-
if (!
|
|
121
|
+
}, ca = async (e) => {
|
|
122
|
+
if (!na(e)) return {
|
|
122
123
|
bytes: 0,
|
|
123
124
|
key: null
|
|
124
125
|
};
|
|
125
|
-
let t = await X.stat(
|
|
126
|
+
let t = await X.stat(aa(e)).catch(() => null);
|
|
126
127
|
if (t === null) return {
|
|
127
128
|
bytes: 0,
|
|
128
129
|
key: null
|
|
129
130
|
};
|
|
130
|
-
let n = await X.readFile(
|
|
131
|
+
let n = await X.readFile(oa(e), "utf8").then((e) => JSON.parse(e), () => ({}));
|
|
131
132
|
return {
|
|
132
133
|
bytes: t.size,
|
|
133
134
|
key: n.key ?? null
|
|
134
135
|
};
|
|
135
|
-
},
|
|
136
|
-
if (!
|
|
136
|
+
}, la = async (e) => {
|
|
137
|
+
if (!na(e.id)) return {
|
|
137
138
|
reason: "bad-id",
|
|
138
|
-
message: `upload id must match ${String(
|
|
139
|
+
message: `upload id must match ${String(ta)}`
|
|
139
140
|
};
|
|
140
|
-
let t = await
|
|
141
|
+
let t = await ca(e.id);
|
|
141
142
|
return t.key !== null && t.key !== e.key ? {
|
|
142
143
|
reason: "key-mismatch",
|
|
143
144
|
message: "this upload id already holds a different bundle. Use a new upload id, or delete the partial upload."
|
|
144
|
-
} : e.offset === t.bytes ? (await X.mkdir(
|
|
145
|
+
} : e.offset === t.bytes ? (await X.mkdir(ia(e.id), { recursive: !0 }), t.key === null && await X.writeFile(oa(e.id), JSON.stringify({
|
|
145
146
|
key: e.key,
|
|
146
147
|
startedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
147
148
|
})), await new Promise((t, n) => {
|
|
148
|
-
let r = On(
|
|
149
|
+
let r = On(aa(e.id), { flags: "a" });
|
|
149
150
|
r.on("error", n), r.on("finish", () => t()), r.end(Buffer.from(e.bytes));
|
|
150
151
|
}), { total: t.bytes + e.bytes.byteLength }) : {
|
|
151
152
|
reason: "offset-mismatch",
|
|
152
153
|
message: `chunk starts at ${e.offset} but the server holds ${t.bytes} byte(s)`,
|
|
153
154
|
expectedOffset: t.bytes
|
|
154
155
|
};
|
|
155
|
-
},
|
|
156
|
-
let t = await X.stat(
|
|
156
|
+
}, ua = async (e) => {
|
|
157
|
+
let t = await X.stat(aa(e));
|
|
157
158
|
return {
|
|
158
|
-
path:
|
|
159
|
+
path: aa(e),
|
|
159
160
|
bytes: t.size
|
|
160
161
|
};
|
|
161
|
-
},
|
|
162
|
-
|
|
162
|
+
}, da = async (e) => {
|
|
163
|
+
na(e) && await X.rm(ia(e), {
|
|
163
164
|
recursive: !0,
|
|
164
165
|
force: !0
|
|
165
166
|
}).catch(() => void 0);
|
|
166
|
-
}, Q = L({ scope: "voltro:admin-import" }),
|
|
167
|
+
}, Q = L({ scope: "voltro:admin-import" }), fa = "VBUNDLE2", pa = (e) => {
|
|
167
168
|
let t = e.req.headers["x-import-rollback-key"];
|
|
168
169
|
if (e.mode !== "replace") return { options: {} };
|
|
169
170
|
if (typeof t != "string" || t.length === 0) return Q.warn("admin.import: no rollback capture — this run empties the target first, and nothing was asked to be kept. Send `x-import-rollback-key: <storage key>` (voltro data import --rollback-key <key>) to have the instance store the target's current rows before deleting them."), { options: {} };
|
|
@@ -174,37 +175,78 @@ var Vi = () => Math.max(500, Math.floor(ti() * .6)), Hi = (e) => new Promise((t)
|
|
|
174
175
|
hint: "A capture written to the pod would not survive the failure it exists for. Configure storage (the same one the storage-push export uses), or re-send without `x-import-rollback-key` to accept that a run which does not finish can leave the target emptied. Note that CONFIGURED is not the same question as SURVIVES: a `filesystem` provider pointed at a container directory with no volume behind it passes this check and dies with the pod. The run says so when it can observe it — the capture path being on the same filesystem as `/`."
|
|
175
176
|
})
|
|
176
177
|
};
|
|
177
|
-
let n = Dn(
|
|
178
|
+
let n = Dn(mi(), `voltro-rollback-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`), r = e.deps.putArchive;
|
|
178
179
|
return {
|
|
179
180
|
key: t,
|
|
180
181
|
options: {
|
|
181
182
|
rollbackDir: n,
|
|
182
183
|
onRollbackCaptured: async () => {
|
|
183
|
-
let e =
|
|
184
|
-
e !== void 0 && Q.warn(`admin.import: ${e}`), await r(t, () =>
|
|
184
|
+
let e = _i(n);
|
|
185
|
+
e !== void 0 && Q.warn(`admin.import: ${e}`), await r(t, () => Ri({ dir: n })), Q.info("admin.import: rollback capture stored", { bundleKey: t });
|
|
185
186
|
}
|
|
186
187
|
}
|
|
187
188
|
};
|
|
188
|
-
},
|
|
189
|
+
}, ma = async function* (e) {
|
|
189
190
|
yield e;
|
|
190
|
-
},
|
|
191
|
-
let n =
|
|
191
|
+
}, ha = (e) => async (t) => {
|
|
192
|
+
let n = ea(t, e.secret);
|
|
192
193
|
if (n) return n;
|
|
193
|
-
let r = t.headers["x-import-mode"], i = t.headers["x-import-on-conflict"], a = t.headers["x-import-atomic"], o = a === "0" || a === "false" ? !1 : a === "1" || a === "true" || r === "replace", ee = t.headers["x-import-force"] === "1" || t.headers["x-import-force"] === "true", s =
|
|
194
|
+
let r = t.headers["x-import-mode"], i = t.headers["x-import-on-conflict"], a = t.headers["x-import-atomic"], o = a === "0" || a === "false" ? !1 : a === "1" || a === "true" || r === "replace", ee = t.headers["x-import-force"] === "1" || t.headers["x-import-force"] === "true", s = pa({
|
|
194
195
|
req: t,
|
|
195
196
|
mode: r,
|
|
196
197
|
deps: e
|
|
197
198
|
});
|
|
198
199
|
if (s.refusal !== void 0) return s.refusal;
|
|
199
|
-
let c = t.headers["x-import-dry-run"] === "1" || t.headers["x-import-dry-run"] === "true", l = (t.headers["x-import-tables"] ?? "").split(",").map((e) => e.trim()).filter(Boolean)
|
|
200
|
+
let c = t.headers["x-import-dry-run"] === "1" || t.headers["x-import-dry-run"] === "true", l = (t.headers["x-import-tables"] ?? "").split(",").map((e) => e.trim()).filter(Boolean);
|
|
201
|
+
if (t.headers["x-import-preflight"] === "1" || t.headers["x-import-preflight"] === "true") {
|
|
202
|
+
let n;
|
|
203
|
+
try {
|
|
204
|
+
n = JSON.parse(Buffer.from(t.rawBody).toString("utf8") || "{}");
|
|
205
|
+
} catch {
|
|
206
|
+
return Z(400, { error: "a preflight body must be JSON: { tables: string[] } or { bundleKey: string }" });
|
|
207
|
+
}
|
|
208
|
+
let i = Array.isArray(n.tables) ? n.tables.filter((e) => typeof e == "string") : [];
|
|
209
|
+
if (i.length === 0 && typeof n.bundleKey == "string" && n.bundleKey !== "" && e.openArchive) {
|
|
210
|
+
let t = await zi(e.openArchive(n.bundleKey), ["manifest.json"]).then((e) => e.get("manifest.json"), () => void 0);
|
|
211
|
+
if (t !== void 0) try {
|
|
212
|
+
i = (JSON.parse(Buffer.from(t).toString("utf8")).tables ?? []).map((e) => e.name).filter((e) => typeof e == "string");
|
|
213
|
+
} catch {}
|
|
214
|
+
}
|
|
215
|
+
if (i.length === 0) return Z(400, {
|
|
216
|
+
error: "a preflight needs { tables: string[] } — the bundle's table names, so the staging decision can be made against them",
|
|
217
|
+
hint: "or { bundleKey } on an instance with storage configured, where this endpoint reads the table list out of the archive itself"
|
|
218
|
+
});
|
|
219
|
+
let a = Ii({
|
|
220
|
+
mode: r ?? "upsert",
|
|
221
|
+
...e.dialect === void 0 ? {} : { targetDialect: e.dialect },
|
|
222
|
+
...e.snapshot === void 0 ? {} : { targetSnapshot: e.snapshot },
|
|
223
|
+
bundleTables: i,
|
|
224
|
+
isSkipped: Li,
|
|
225
|
+
canRunSql: !0
|
|
226
|
+
});
|
|
227
|
+
return Z(200, {
|
|
228
|
+
preflight: !0,
|
|
229
|
+
mode: r ?? "upsert",
|
|
230
|
+
atomic: o,
|
|
231
|
+
staged: a.active,
|
|
232
|
+
...a.blocker === void 0 ? {} : { reason: a.blocker },
|
|
233
|
+
stagedTables: a.tables.length,
|
|
234
|
+
rollback: s.key === void 0 ? { taken: !1 } : {
|
|
235
|
+
taken: !0,
|
|
236
|
+
key: s.key
|
|
237
|
+
},
|
|
238
|
+
dialect: e.dialect ?? null
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
let u = t.headers["x-import-upload-id"], d;
|
|
200
242
|
if (u !== void 0 && u !== "") {
|
|
201
|
-
if (
|
|
243
|
+
if (sa(), t.headers["x-import-probe"] === "1") return Z(200, {
|
|
202
244
|
uploadId: u,
|
|
203
|
-
bytes: (await
|
|
245
|
+
bytes: (await ca(u)).bytes
|
|
204
246
|
});
|
|
205
247
|
let e = t.headers["x-import-upload-key"] ?? "", n = Number(t.headers["x-import-chunk-offset"] ?? "0");
|
|
206
248
|
if (e === "" || !Number.isFinite(n) || n < 0) return Z(400, { error: "a chunked upload needs x-import-upload-key and a numeric x-import-chunk-offset" });
|
|
207
|
-
let r = await
|
|
249
|
+
let r = await la({
|
|
208
250
|
id: u,
|
|
209
251
|
key: e,
|
|
210
252
|
offset: n,
|
|
@@ -223,13 +265,13 @@ var Vi = () => Math.max(500, Math.floor(ti() * .6)), Hi = (e) => new Promise((t)
|
|
|
223
265
|
uploadId: u,
|
|
224
266
|
bytes: r.total
|
|
225
267
|
});
|
|
226
|
-
d = (await
|
|
268
|
+
d = (await ua(u)).path;
|
|
227
269
|
}
|
|
228
|
-
let f = t.rawBody.byteLength >= 8 && Buffer.from(t.rawBody.subarray(0, 8)).toString("latin1") ===
|
|
270
|
+
let f = t.rawBody.byteLength >= 8 && Buffer.from(t.rawBody.subarray(0, 8)).toString("latin1") === fa, p, m;
|
|
229
271
|
if (d !== void 0) {
|
|
230
272
|
let { createReadStream: e } = await import("node:fs");
|
|
231
273
|
p = e(d), m = "chunked";
|
|
232
|
-
} else if (f) p =
|
|
274
|
+
} else if (f) p = ma(t.rawBody), m = "upload";
|
|
233
275
|
else {
|
|
234
276
|
let n;
|
|
235
277
|
try {
|
|
@@ -243,11 +285,11 @@ var Vi = () => Math.max(500, Math.floor(ti() * .6)), Hi = (e) => new Promise((t)
|
|
|
243
285
|
}
|
|
244
286
|
let h = await import("node:os"), g = await import("node:fs/promises"), _ = await import("node:path"), te = await g.mkdtemp(_.join(h.tmpdir(), "voltro-admin-import-"));
|
|
245
287
|
try {
|
|
246
|
-
e.assetSink ? await
|
|
288
|
+
e.assetSink ? await Wi(p, {
|
|
247
289
|
dir: te,
|
|
248
290
|
blobs: e.assetSink
|
|
249
|
-
}) : await
|
|
250
|
-
let t = await W.runPromiseExit(
|
|
291
|
+
}) : await Gi(p, te);
|
|
292
|
+
let t = await W.runPromiseExit(Vi({
|
|
251
293
|
store: e.store,
|
|
252
294
|
bundleDir: te,
|
|
253
295
|
...r ? { mode: r } : {},
|
|
@@ -330,20 +372,28 @@ var Vi = () => Math.max(500, Math.floor(ti() * .6)), Hi = (e) => new Promise((t)
|
|
|
330
372
|
await g.rm(te, {
|
|
331
373
|
recursive: !0,
|
|
332
374
|
force: !0
|
|
333
|
-
}), u !== void 0 && u !== "" && d !== void 0 && await
|
|
375
|
+
}), u !== void 0 && u !== "" && d !== void 0 && await da(u);
|
|
334
376
|
}
|
|
335
|
-
},
|
|
377
|
+
}, ga = L({ scope: "voltro:admin-export" }), _a = async (e) => {
|
|
336
378
|
let t = [];
|
|
337
379
|
for await (let n of e) t.push(Buffer.from(n));
|
|
338
380
|
return new Uint8Array(Buffer.concat(t));
|
|
339
|
-
},
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
381
|
+
}, va = (e) => Array.isArray(e) ? e.filter((e) => typeof e == "string") : [], ya = (e) => {
|
|
382
|
+
if (typeof e.tenant == "string" && e.tenant) return {
|
|
383
|
+
kind: "tenant",
|
|
384
|
+
tenantId: e.tenant
|
|
385
|
+
};
|
|
386
|
+
if (Array.isArray(e.tables) && e.tables.length) return {
|
|
387
|
+
kind: "tables",
|
|
388
|
+
tables: va(e.tables)
|
|
389
|
+
};
|
|
390
|
+
let t = va(e.exclude);
|
|
391
|
+
return t.length > 0 ? {
|
|
392
|
+
kind: "all",
|
|
393
|
+
exclude: t
|
|
394
|
+
} : { kind: "all" };
|
|
395
|
+
}, ba = (e) => async (t) => {
|
|
396
|
+
let n = ea(t, e.secret);
|
|
347
397
|
if (n) return n;
|
|
348
398
|
let r;
|
|
349
399
|
try {
|
|
@@ -363,9 +413,9 @@ var Vi = () => Math.max(500, Math.floor(ti() * .6)), Hi = (e) => new Promise((t)
|
|
|
363
413
|
});
|
|
364
414
|
}
|
|
365
415
|
}
|
|
366
|
-
let a = r.consistency === "snapshot" ? "snapshot" : i.consistency ?? "live", o = (typeof r.compression == "string" ? r.compression : void 0) ?? i.compression, ee = i.scope ??
|
|
416
|
+
let a = r.consistency === "snapshot" ? "snapshot" : i.consistency ?? "live", o = (typeof r.compression == "string" ? r.compression : void 0) ?? i.compression, ee = i.scope ?? ya(r), s = typeof r.bundleKey == "string" && r.bundleKey.length > 0, c = r.assets === !0 && e.assetSource ? { blobs: e.assetSource } : {}, l = await import("node:os"), u = await import("node:fs/promises"), d = await import("node:path"), f = await u.mkdtemp(d.join(l.tmpdir(), "voltro-admin-export-"));
|
|
367
417
|
try {
|
|
368
|
-
let t = await W.runPromise(
|
|
418
|
+
let t = await W.runPromise(Bi({
|
|
369
419
|
store: e.store,
|
|
370
420
|
snapshot: e.snapshot,
|
|
371
421
|
dialect: e.dialect,
|
|
@@ -381,10 +431,10 @@ var Vi = () => Math.max(500, Math.floor(ti() * .6)), Hi = (e) => new Promise((t)
|
|
|
381
431
|
if (s) {
|
|
382
432
|
if (!e.putArchive) return Z(501, { error: "storage transport not configured on this instance" });
|
|
383
433
|
let i = r.bundleKey;
|
|
384
|
-
return await e.putArchive(i, () =>
|
|
434
|
+
return await e.putArchive(i, () => Ri({
|
|
385
435
|
dir: f,
|
|
386
436
|
...c
|
|
387
|
-
})),
|
|
437
|
+
})), ga.info("admin.export", {
|
|
388
438
|
transport: "storage",
|
|
389
439
|
tables: t.tables.length,
|
|
390
440
|
rows: n,
|
|
@@ -398,11 +448,11 @@ var Vi = () => Math.max(500, Math.floor(ti() * .6)), Hi = (e) => new Promise((t)
|
|
|
398
448
|
transport: "storage"
|
|
399
449
|
});
|
|
400
450
|
}
|
|
401
|
-
let u = await
|
|
451
|
+
let u = await _a(Ri({
|
|
402
452
|
dir: f,
|
|
403
453
|
...c
|
|
404
454
|
}));
|
|
405
|
-
return
|
|
455
|
+
return ga.info("admin.export", {
|
|
406
456
|
transport: "download",
|
|
407
457
|
tables: t.tables.length,
|
|
408
458
|
rows: n,
|
|
@@ -419,7 +469,7 @@ var Vi = () => Math.max(500, Math.floor(ti() * .6)), Hi = (e) => new Promise((t)
|
|
|
419
469
|
}
|
|
420
470
|
};
|
|
421
471
|
} catch (e) {
|
|
422
|
-
return
|
|
472
|
+
return ga.warn("admin.export failed", { error: e?.message ?? String(e) }), Z(500, {
|
|
423
473
|
error: "export failed",
|
|
424
474
|
message: e?.message ?? String(e)
|
|
425
475
|
});
|
|
@@ -429,8 +479,51 @@ var Vi = () => Math.max(500, Math.floor(ti() * .6)), Hi = (e) => new Promise((t)
|
|
|
429
479
|
force: !0
|
|
430
480
|
});
|
|
431
481
|
}
|
|
432
|
-
},
|
|
433
|
-
|
|
482
|
+
}, xa = async (e, t) => await e.query({
|
|
483
|
+
table: H,
|
|
484
|
+
order: [{
|
|
485
|
+
column: "startedAt",
|
|
486
|
+
direction: "desc"
|
|
487
|
+
}],
|
|
488
|
+
predicate: void 0,
|
|
489
|
+
projection: void 0,
|
|
490
|
+
skip: 0,
|
|
491
|
+
take: t
|
|
492
|
+
}), Sa = (e) => ({
|
|
493
|
+
...e,
|
|
494
|
+
startedAt: new Date(e.startedAt),
|
|
495
|
+
finishedAt: e.finishedAt === null ? null : new Date(e.finishedAt)
|
|
496
|
+
}), Ca = (e) => async (t) => {
|
|
497
|
+
let n = ea(t, e.secret, "GET");
|
|
498
|
+
if (n) return n;
|
|
499
|
+
let r = Number(new URLSearchParams(t.query ?? "").get("limit") ?? "20"), i = Number.isFinite(r) ? Math.max(1, Math.min(200, Math.trunc(r))) : 20, a;
|
|
500
|
+
try {
|
|
501
|
+
a = (await xa(e.store, i)).map(Sa);
|
|
502
|
+
} catch (e) {
|
|
503
|
+
return Z(409, {
|
|
504
|
+
error: "no import history",
|
|
505
|
+
message: `this instance has no \`${H}\` table, so no import has been recorded. Run \`voltro db apply\` against it; imports themselves are unaffected.`,
|
|
506
|
+
detail: e?.message ?? String(e)
|
|
507
|
+
});
|
|
508
|
+
}
|
|
509
|
+
return Z(200, {
|
|
510
|
+
running: a.filter((e) => e.finishedAt === null && e.failure === null).length,
|
|
511
|
+
runs: a.map((e) => ({
|
|
512
|
+
id: e.id,
|
|
513
|
+
startedAt: e.startedAt.toISOString(),
|
|
514
|
+
finishedAt: e.finishedAt === null ? null : e.finishedAt.toISOString(),
|
|
515
|
+
mode: e.mode,
|
|
516
|
+
via: e.via,
|
|
517
|
+
bundle: e.bundle,
|
|
518
|
+
sourceFingerprint: e.sourceFingerprint,
|
|
519
|
+
tablesWritten: e.tablesWritten,
|
|
520
|
+
rowsWritten: e.rowsWritten,
|
|
521
|
+
failure: e.failure,
|
|
522
|
+
line: Yn(e)
|
|
523
|
+
}))
|
|
524
|
+
});
|
|
525
|
+
}, wa = (e, t, n = {}) => (async function* () {
|
|
526
|
+
let r = await W.runPromise(yi(e, t).pipe(W.timeout(n.openTimeout ?? "30 seconds"))), i = await xi(r.stream), a = n.stallMs ?? 12e4, o, ee = () => {
|
|
434
527
|
o && clearTimeout(o), o = setTimeout(() => i.destroy(/* @__PURE__ */ Error(`storage read stalled for ${a}ms reading '${t}'`)), a);
|
|
435
528
|
};
|
|
436
529
|
try {
|
|
@@ -439,7 +532,7 @@ var Vi = () => Math.max(500, Math.floor(ti() * .6)), Hi = (e) => new Promise((t)
|
|
|
439
532
|
} finally {
|
|
440
533
|
o && clearTimeout(o), i.destroy();
|
|
441
534
|
}
|
|
442
|
-
})(),
|
|
535
|
+
})(), Ta = {
|
|
443
536
|
get: async () => void 0,
|
|
444
537
|
set: async () => {},
|
|
445
538
|
setWithTags: async () => {},
|
|
@@ -448,26 +541,26 @@ var Vi = () => Math.max(500, Math.floor(ti() * .6)), Hi = (e) => new Promise((t)
|
|
|
448
541
|
clear: async () => {},
|
|
449
542
|
invalidateTag: async () => 0,
|
|
450
543
|
wrap: async (e, t, n) => n()
|
|
451
|
-
},
|
|
544
|
+
}, Ea = async (e) => {
|
|
452
545
|
d(e.appProcedures ?? e.discovered, {
|
|
453
546
|
defaultDeny: e.security?.defaultDeny ?? !0,
|
|
454
547
|
commandHint: "`voltro serve`"
|
|
455
|
-
}),
|
|
548
|
+
}), ni({
|
|
456
549
|
dataStore: e.store,
|
|
457
550
|
schemaRegistry: e.schemaRegistry
|
|
458
551
|
});
|
|
459
|
-
let t = (e.discovered.budgets?.length ?? 0) > 0, n, r = new
|
|
552
|
+
let t = (e.discovered.budgets?.length ?? 0) > 0, n, r = new sr({
|
|
460
553
|
store: e.store,
|
|
461
554
|
...e.snapshotCache ? { cache: e.snapshotCache } : {},
|
|
462
555
|
...e.reactive === void 0 ? {} : { reactive: e.reactive },
|
|
463
556
|
...t ? { recordCost: (e) => n?.record(e) } : {},
|
|
464
|
-
recordDelivery: (e) =>
|
|
557
|
+
recordDelivery: (e) => Xr({
|
|
465
558
|
label: e.label,
|
|
466
559
|
kind: e.kind,
|
|
467
560
|
durationMs: e.durationMs,
|
|
468
561
|
rowCount: e.rowCount
|
|
469
562
|
})
|
|
470
|
-
}), i = e.cache ??
|
|
563
|
+
}), i = e.cache ?? Ta, a = e.kv ?? Jr, o, ee = () => void 0, c, l, u, f, p, m, h, _ = ue({
|
|
471
564
|
store: e.store,
|
|
472
565
|
warn: (e, t) => {
|
|
473
566
|
process.stderr.write(`[workflow] ${e} ${JSON.stringify(t)}\n`);
|
|
@@ -475,16 +568,16 @@ var Vi = () => Math.max(500, Math.floor(ti() * .6)), Hi = (e) => new Promise((t)
|
|
|
475
568
|
}), te = _.remember, ae = _.resolve, oe = xt({
|
|
476
569
|
authority: e.authority,
|
|
477
570
|
getStore: () => e.store
|
|
478
|
-
}), S = (e.discovered.workflows?.length ?? 0) > 0 ?
|
|
571
|
+
}), S = (e.discovered.workflows?.length ?? 0) > 0 ? Lr(() => o) : void 0, de = (e.discovered.workflows?.length ?? 0) > 0 || (e.discovered.eventTriggers?.length ?? 0) > 0, he = de || (e.discovered.workflowWorkers?.length ?? 0) > 0 || e.scheduleCoordination === "cluster", ge = e.tenantIsolation === "namespace", _e = (e.log ?? L({ scope: "voltro:serve" })).child("webhooks"), ve, ye, C = e.discovered.webhooks;
|
|
479
572
|
if (C && C.outgoing.length > 0 && e.workflowEngineLayer !== void 0) {
|
|
480
573
|
e.workflowEngineLayer;
|
|
481
|
-
let t =
|
|
574
|
+
let t = dt({
|
|
482
575
|
store: e.store,
|
|
483
576
|
schemaRegistry: e.schemaRegistry,
|
|
484
577
|
cache: i,
|
|
485
578
|
kv: a
|
|
486
579
|
}), n = C.outgoing.map((e) => e.descriptor);
|
|
487
|
-
ye =
|
|
580
|
+
ye = ki.toLayer(Ei(t, { events: n })), ve = Di(t, async (e) => {
|
|
488
581
|
let t = u;
|
|
489
582
|
if (t === void 0) {
|
|
490
583
|
_e.error("webhook delivery skipped — the workflow runtime was never built. This is a framework defect, not a configuration problem: report it with your engine setting. Deliveries are NOT queued and will not be retried.", {
|
|
@@ -493,7 +586,7 @@ var Vi = () => Math.max(500, Math.floor(ti() * .6)), Hi = (e) => new Promise((t)
|
|
|
493
586
|
});
|
|
494
587
|
return;
|
|
495
588
|
}
|
|
496
|
-
t.runPromise(
|
|
589
|
+
t.runPromise(ki.execute(e)).catch((t) => {
|
|
497
590
|
_e.error("deliverWebhook workflow crashed", {
|
|
498
591
|
deliveryId: e.deliveryId,
|
|
499
592
|
targetId: e.targetId
|
|
@@ -503,9 +596,9 @@ var Vi = () => Math.max(500, Math.floor(ti() * .6)), Hi = (e) => new Promise((t)
|
|
|
503
596
|
}
|
|
504
597
|
let Se = /* @__PURE__ */ new Map();
|
|
505
598
|
if (C) for (let e of C.incoming) {
|
|
506
|
-
let t = e.descriptor.path ??
|
|
599
|
+
let t = e.descriptor.path ?? Oi(e.descriptor.id), n = `VOLTRO_WEBHOOK_SECRET_${e.descriptor.id.toUpperCase().replace(/[^A-Z0-9]/g, "_")}`, r = ji(e.descriptor, {
|
|
507
600
|
resolveSecret: async () => process.env[n] ?? null,
|
|
508
|
-
resolveWorkflows: () => S === void 0 ? void 0 :
|
|
601
|
+
resolveWorkflows: () => S === void 0 ? void 0 : Kr(S, {
|
|
509
602
|
traceId: `incoming:${e.descriptor.id}`,
|
|
510
603
|
source: `incoming:${e.descriptor.id}`
|
|
511
604
|
}),
|
|
@@ -522,11 +615,11 @@ var Vi = () => Math.max(500, Math.floor(ti() * .6)), Hi = (e) => new Promise((t)
|
|
|
522
615
|
});
|
|
523
616
|
Se.set(t, { handle: r });
|
|
524
617
|
}
|
|
525
|
-
|
|
618
|
+
Er(), Y((t) => Dr(e.store, t.subjectId, t.resourceType, t.resourceId)) || L({ scope: "voltro:serve" }).info("policy guards: using the app-registered tuple source");
|
|
526
619
|
let Ce = [], Te = [...e.discovered.outboxHandlers ?? [], ..._n((C?.outgoing.length ?? 0) + (C?.incoming.length ?? 0) + (C?.providers.length ?? 0), []) ? [{
|
|
527
620
|
file: "<framework>/webhooks",
|
|
528
621
|
id: "voltro-webhook-emit",
|
|
529
|
-
definition:
|
|
622
|
+
definition: Ai(() => ve)
|
|
530
623
|
}] : []], Ee = Te.length > 0 ? Fe({
|
|
531
624
|
handlers: Te,
|
|
532
625
|
store: e.store,
|
|
@@ -544,7 +637,7 @@ var Vi = () => Math.max(500, Math.floor(ti() * .6)), Hi = (e) => new Promise((t)
|
|
|
544
637
|
publicUrl: b(e.port ?? 4e3),
|
|
545
638
|
log: (e.log ?? L({ scope: "voltro:serve" })).child("connections")
|
|
546
639
|
});
|
|
547
|
-
|
|
640
|
+
st({
|
|
548
641
|
events: e.discovered.events ?? [],
|
|
549
642
|
rpcTags: [
|
|
550
643
|
...e.discovered.queries.map((e) => e.descriptor.name),
|
|
@@ -553,16 +646,16 @@ var Vi = () => Math.max(500, Math.floor(ti() * .6)), Hi = (e) => new Promise((t)
|
|
|
553
646
|
...(e.discovered.streams ?? []).map((e) => e.descriptor.name)
|
|
554
647
|
]
|
|
555
648
|
});
|
|
556
|
-
let Ae = (e.log ?? L({ scope: "voltro:serve" })).child("events"), je = e.broadcastNamespace ??
|
|
649
|
+
let Ae = (e.log ?? L({ scope: "voltro:serve" })).child("events"), je = e.broadcastNamespace ?? $e(e.plugins, void 0), Me = E(e.plugins, je, Ae), Ne = e.membership?.instanceId ?? process.env.POD_NAME ?? process.env.HOSTNAME ?? `serve-${process.pid}`, Ie = e.membership ?? Mt(e.plugins, {
|
|
557
650
|
instanceId: Ne,
|
|
558
651
|
namespace: je,
|
|
559
652
|
meta: { mode: "serve" },
|
|
560
653
|
logger: Ae
|
|
561
|
-
}),
|
|
654
|
+
}), Le = fe({
|
|
562
655
|
events: e.discovered.events ?? [],
|
|
563
656
|
origin: Ne,
|
|
564
657
|
...Me.publishRemote === void 0 ? {} : { publishRemote: Me.publishRemote }
|
|
565
|
-
}),
|
|
658
|
+
}), Re = (e.discovered.events ?? []).length > 0 ? await Me.attach(Le.bus) : null, ze = We({
|
|
566
659
|
store: e.store,
|
|
567
660
|
schemaRegistry: e.schemaRegistry,
|
|
568
661
|
cache: i,
|
|
@@ -575,78 +668,78 @@ var Vi = () => Math.max(500, Math.floor(ti() * .6)), Hi = (e) => new Promise((t)
|
|
|
575
668
|
...e.resolveResidentStore === void 0 ? {} : { resolveResidentStore: e.resolveResidentStore },
|
|
576
669
|
...Ee === void 0 ? {} : { outbox: { nudge: Ee.nudge } },
|
|
577
670
|
...w.active ? { connections: { registry: w.registry } } : {},
|
|
578
|
-
eventBus:
|
|
579
|
-
}),
|
|
580
|
-
let r = t.pipe(W.provide(
|
|
581
|
-
return (e.baseLayer ? r.pipe(W.provide(e.baseLayer)) : r).pipe(W.provide(
|
|
582
|
-
},
|
|
583
|
-
let n =
|
|
584
|
-
return
|
|
585
|
-
},
|
|
671
|
+
eventBus: Le.bus
|
|
672
|
+
}), Be = G.succeed(ar, g), Ve = G.succeed(cr, Rt), Ue = G.succeed(K, He), Ke = G.succeed(lr, we), Je = (t, n) => {
|
|
673
|
+
let r = t.pipe(W.provide(Ir(n)));
|
|
674
|
+
return (e.baseLayer ? r.pipe(W.provide(e.baseLayer)) : r).pipe(W.provide(Be)).pipe(W.provide(Ve)).pipe(W.provide(Ue)).pipe(W.provide(Ke));
|
|
675
|
+
}, Xe = (e, t) => {
|
|
676
|
+
let n = Je(e, t);
|
|
677
|
+
return ei(n);
|
|
678
|
+
}, Ze = bn(), tt = le(e.plugins ?? [], Ze), nt = Oe({
|
|
586
679
|
plugins: e.plugins ?? [],
|
|
587
|
-
metrics:
|
|
680
|
+
metrics: Ze,
|
|
588
681
|
log: e.log ?? L({ scope: "voltro:serve" })
|
|
589
|
-
}),
|
|
682
|
+
}), rt = x(e.plugins ?? [], Ze), it = e.security?.defaultDeny ?? !0, ot = zr({
|
|
590
683
|
store: e.store,
|
|
591
|
-
defaultDeny:
|
|
684
|
+
defaultDeny: it,
|
|
592
685
|
recordMetric: (e) => {
|
|
593
|
-
|
|
686
|
+
Ze.record(e);
|
|
594
687
|
},
|
|
595
|
-
...
|
|
596
|
-
buildContext: (e, t, n) =>
|
|
597
|
-
runEffect:
|
|
688
|
+
...tt.mutation === void 0 ? {} : { interceptor: tt.mutation },
|
|
689
|
+
buildContext: (e, t, n) => ze(e, t, n),
|
|
690
|
+
runEffect: Xe,
|
|
598
691
|
undoCapture: s()
|
|
599
|
-
}),
|
|
692
|
+
}), lt = be();
|
|
600
693
|
{
|
|
601
|
-
let t =
|
|
694
|
+
let t = Ye();
|
|
602
695
|
t !== void 0 && (e.log ?? L({ scope: "voltro:serve" })).info(t);
|
|
603
696
|
}
|
|
604
|
-
let
|
|
697
|
+
let ut = Pe({
|
|
605
698
|
store: e.store,
|
|
606
699
|
...e.approvals === void 0 ? {} : { defaultExpiryMs: e.approvals.defaultExpiryMs }
|
|
607
|
-
}),
|
|
608
|
-
defaultDeny:
|
|
609
|
-
buildContext: (e) =>
|
|
610
|
-
runEffect:
|
|
700
|
+
}), pt = Or({
|
|
701
|
+
defaultDeny: it,
|
|
702
|
+
buildContext: (e) => ze(e),
|
|
703
|
+
runEffect: Xe,
|
|
611
704
|
recordMetric: (e) => {
|
|
612
|
-
|
|
705
|
+
Ze.record(e);
|
|
613
706
|
},
|
|
614
|
-
...
|
|
615
|
-
}),
|
|
707
|
+
...tt.action === void 0 ? {} : { interceptor: tt.action }
|
|
708
|
+
}), mt = Hr({
|
|
616
709
|
tenantScopedTables: e.tenantScopedTables,
|
|
617
710
|
softDeleteScopedTables: e.softDeleteScopedTables
|
|
618
|
-
}),
|
|
619
|
-
defaultDeny:
|
|
620
|
-
buildContext: (e) =>
|
|
621
|
-
finalize: (e, t) =>
|
|
622
|
-
provideEffect:
|
|
623
|
-
...
|
|
624
|
-
},
|
|
625
|
-
...
|
|
626
|
-
queryRows: (t, n) => e.store.query(t).then((e) =>
|
|
627
|
-
}), _t =
|
|
628
|
-
...
|
|
711
|
+
}), ht = {
|
|
712
|
+
defaultDeny: it,
|
|
713
|
+
buildContext: (e) => ze(e),
|
|
714
|
+
finalize: (e, t) => mt(e, t.subject),
|
|
715
|
+
provideEffect: Je,
|
|
716
|
+
...tt.query === void 0 ? {} : { interceptor: tt.query }
|
|
717
|
+
}, D = Vr(ht), O = Br({
|
|
718
|
+
...ht,
|
|
719
|
+
queryRows: (t, n) => e.store.query(t).then((e) => si(t.table, e, n.subject))
|
|
720
|
+
}), _t = Ur({
|
|
721
|
+
...ht,
|
|
629
722
|
subscribeDescriptor: (e, t, n) => r.subscribe(e, t, n),
|
|
630
723
|
subscribeComputed: (e, t, n) => r.subscribeComputed(e, t, n)
|
|
631
724
|
}), k = (e) => e.filter((e) => Pn(e.descriptor)), A = {};
|
|
632
725
|
for (let t of [
|
|
633
726
|
...k(e.discovered.queries),
|
|
634
|
-
...ct.queries,
|
|
635
727
|
...lt.queries,
|
|
728
|
+
...ut.queries,
|
|
636
729
|
...w.queries
|
|
637
|
-
]) A[t.descriptor.name] = (e) =>
|
|
730
|
+
]) A[t.descriptor.name] = (e) => _r(D(t, e), r, `subscription.${t.descriptor.name}`, void 0, void 0, J(t, e));
|
|
638
731
|
for (let t of [
|
|
639
732
|
...k(e.discovered.mutations),
|
|
640
|
-
...ct.mutations,
|
|
641
733
|
...lt.mutations,
|
|
734
|
+
...ut.mutations,
|
|
642
735
|
...w.mutations
|
|
643
736
|
]) {
|
|
644
|
-
let n =
|
|
645
|
-
A[t.descriptor.name] = (r) =>
|
|
737
|
+
let n = Rr(t.descriptor.output);
|
|
738
|
+
A[t.descriptor.name] = (r) => q(async (e, n) => ot(t, e, n), r, `mutation.${t.descriptor.name}`, n, e.idempotency, Ln(t.descriptor, "mutation"));
|
|
646
739
|
}
|
|
647
740
|
for (let t of [...k(e.discovered.actions), ...w.actions]) {
|
|
648
|
-
let n =
|
|
649
|
-
A[t.descriptor.name] = (r) =>
|
|
741
|
+
let n = Rr(t.descriptor.output);
|
|
742
|
+
A[t.descriptor.name] = (r) => q(async (e, n) => pt(t, e, n), r, `action.${t.descriptor.name}`, n, e.idempotency, Ln(t.descriptor, "action"));
|
|
650
743
|
}
|
|
651
744
|
let vt = () => `public-${Math.random().toString(36).slice(2, 10)}`, yt = [
|
|
652
745
|
...e.discovered.queries.filter((e) => e.descriptor.publicApi !== void 0).map((e) => ({
|
|
@@ -662,14 +755,14 @@ var Vi = () => Math.max(500, Math.floor(ti() * .6)), Hi = (e) => new Promise((t)
|
|
|
662
755
|
})),
|
|
663
756
|
...e.discovered.mutations.filter((e) => e.descriptor.publicApi !== void 0).map((e) => ({
|
|
664
757
|
descriptor: e.descriptor,
|
|
665
|
-
invoke: (t, n) =>
|
|
758
|
+
invoke: (t, n) => ot(e, t, {
|
|
666
759
|
subject: n.subject,
|
|
667
760
|
traceId: vt()
|
|
668
761
|
})
|
|
669
762
|
})),
|
|
670
763
|
...e.discovered.actions.filter((e) => e.descriptor.publicApi !== void 0).map((e) => ({
|
|
671
764
|
descriptor: e.descriptor,
|
|
672
|
-
invoke: (t, n) =>
|
|
765
|
+
invoke: (t, n) => pt(e, t, {
|
|
673
766
|
subject: n.subject,
|
|
674
767
|
traceId: vt()
|
|
675
768
|
})
|
|
@@ -681,13 +774,13 @@ var Vi = () => Math.max(500, Math.floor(ti() * .6)), Hi = (e) => new Promise((t)
|
|
|
681
774
|
actions: e.discovered.actions,
|
|
682
775
|
descriptorOf: (e) => e.descriptor,
|
|
683
776
|
runQuery: (e, t, n) => Promise.resolve(O(e, t, n)),
|
|
684
|
-
runMutation: (e, t, n) => Promise.resolve(
|
|
685
|
-
runAction: (e, t, n) => Promise.resolve(
|
|
777
|
+
runMutation: (e, t, n) => Promise.resolve(ot(e, t, n)),
|
|
778
|
+
runAction: (e, t, n) => Promise.resolve(pt(e, t, n))
|
|
686
779
|
}),
|
|
687
780
|
policy: e.agents?.tools ?? {},
|
|
688
781
|
mcpEnabled: e.agents?.mcp === !0,
|
|
689
782
|
resolveSubject: (t) => e.resolveSubject(t, -1).then((e) => e.subject)
|
|
690
|
-
}, St =
|
|
783
|
+
}, St = gt({
|
|
691
784
|
...e.restRoutes === void 0 ? {} : { restRoutes: e.restRoutes },
|
|
692
785
|
publicApiEntries: yt,
|
|
693
786
|
store: e.store,
|
|
@@ -695,61 +788,72 @@ var Vi = () => Math.max(500, Math.floor(ti() * .6)), Hi = (e) => new Promise((t)
|
|
|
695
788
|
...e.idempotency === void 0 ? {} : { idempotency: e.idempotency },
|
|
696
789
|
log: e.log ?? L({ scope: "voltro:serve" })
|
|
697
790
|
}), Ct = e.dataTransferSecret ?? process.env.VOLTRO_DATA_TRANSFER_SECRET, wt = async (e, t) => {
|
|
698
|
-
let { Readable: n } = await import("node:stream"), r =
|
|
699
|
-
await W.runPromise(
|
|
700
|
-
}, Tt = Ct && Ct.length >= 16 ? [
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
791
|
+
let { Readable: n } = await import("node:stream"), r = gi(), i = vi("storage", () => n.from(t()));
|
|
792
|
+
await W.runPromise(bi(r, e, i, { contentType: "application/octet-stream" }));
|
|
793
|
+
}, Tt = Ct && Ct.length >= 16 ? [
|
|
794
|
+
{
|
|
795
|
+
method: "POST",
|
|
796
|
+
path: Yi,
|
|
797
|
+
handle: ha({
|
|
798
|
+
secret: Ct,
|
|
799
|
+
store: e.store,
|
|
800
|
+
...e.dataTransferSnapshot ? { snapshot: e.dataTransferSnapshot } : {},
|
|
801
|
+
...e.dataTransferDialect ? { dialect: e.dataTransferDialect } : {},
|
|
802
|
+
assetSink: Hi(gi()),
|
|
803
|
+
openArchive: (e) => wa(gi(), e),
|
|
804
|
+
refreshSubscriptions: (e) => {
|
|
805
|
+
r.refreshAll(e);
|
|
806
|
+
},
|
|
807
|
+
putArchive: wt,
|
|
808
|
+
...e.dataTransferDialect ? { dialect: e.dataTransferDialect } : {}
|
|
809
|
+
})
|
|
810
|
+
},
|
|
811
|
+
{
|
|
812
|
+
method: "GET",
|
|
813
|
+
path: Zi,
|
|
814
|
+
handle: Ca({
|
|
815
|
+
secret: Ct,
|
|
816
|
+
store: e.store
|
|
817
|
+
})
|
|
818
|
+
},
|
|
819
|
+
{
|
|
820
|
+
method: "POST",
|
|
821
|
+
path: Xi,
|
|
822
|
+
handle: ba({
|
|
823
|
+
secret: Ct,
|
|
824
|
+
store: e.store,
|
|
825
|
+
snapshot: e.dataTransferSnapshot ?? { tables: [] },
|
|
826
|
+
dialect: e.dataTransferDialect ?? "memory",
|
|
827
|
+
tenantTables: [...e.tenantScopedTables],
|
|
828
|
+
loadProfile: wn,
|
|
829
|
+
assetSource: Ui(gi(), e.store),
|
|
830
|
+
putArchive: wt
|
|
831
|
+
})
|
|
832
|
+
}
|
|
833
|
+
] : [], Et = [
|
|
730
834
|
...e.httpRoutes ?? [],
|
|
731
835
|
...St.httpRoutes,
|
|
732
836
|
...Tt,
|
|
733
837
|
...w.httpRoutes
|
|
734
838
|
];
|
|
735
|
-
Object.assign(A,
|
|
736
|
-
for (let t of k(e.discovered.streams ?? [])) A[t.descriptor.name] = (n) =>
|
|
737
|
-
let i =
|
|
839
|
+
Object.assign(A, Le.handlers);
|
|
840
|
+
for (let t of k(e.discovered.streams ?? [])) A[t.descriptor.name] = (n) => gr((r) => ui(r, (r) => {
|
|
841
|
+
let i = ze(r), a = t.executor(n, i);
|
|
738
842
|
if (W.isEffect(a)) {
|
|
739
|
-
let t = a.pipe(W.provide(
|
|
740
|
-
return (e.baseLayer ? t.pipe(W.provide(e.baseLayer)) : t).pipe(W.provide(
|
|
843
|
+
let t = a.pipe(W.provide(Ir(i.store)));
|
|
844
|
+
return (e.baseLayer ? t.pipe(W.provide(e.baseLayer)) : t).pipe(W.provide(Be)).pipe(W.provide(Ve)).pipe(W.provide(Ue)).pipe(W.provide(Ke));
|
|
741
845
|
}
|
|
742
846
|
return typeof a == "object" && a && typeof a.then == "function" ? W.promise(() => a) : a;
|
|
743
847
|
}), `stream.${t.descriptor.name}`);
|
|
744
|
-
for (let t of e.discovered.workflows ?? []) A[t.definition.name] = (e) =>
|
|
848
|
+
for (let t of e.discovered.workflows ?? []) A[t.definition.name] = (e) => q(async (e, n) => {
|
|
745
849
|
let r = n;
|
|
746
|
-
return
|
|
850
|
+
return Kr(S, {
|
|
747
851
|
subject: r.subject,
|
|
748
852
|
traceId: r.traceId,
|
|
749
853
|
source: "workflow-rpc"
|
|
750
854
|
}).start(t.definition.name, e);
|
|
751
855
|
}, e, `workflow.${t.definition.name}`);
|
|
752
|
-
de && (A[Vn.name] = (e) =>
|
|
856
|
+
de && (A[Vn.name] = (e) => _r(D({
|
|
753
857
|
descriptor: Vn,
|
|
754
858
|
executor: (e) => {
|
|
755
859
|
let t = e.id;
|
|
@@ -759,13 +863,13 @@ var Vi = () => Math.max(500, Math.floor(ti() * .6)), Hi = (e) => new Promise((t)
|
|
|
759
863
|
column: "startedAt",
|
|
760
864
|
direction: "desc"
|
|
761
865
|
}],
|
|
762
|
-
predicate:
|
|
866
|
+
predicate: Zn(U("id", t), U("executionId", t)),
|
|
763
867
|
take: 1,
|
|
764
868
|
skip: void 0,
|
|
765
869
|
projection: void 0
|
|
766
870
|
};
|
|
767
871
|
}
|
|
768
|
-
}, e), r, `subscription.${Vn.name}`), A[Un.name] = (e) =>
|
|
872
|
+
}, e), r, `subscription.${Vn.name}`), A[Un.name] = (e) => _r(D({
|
|
769
873
|
descriptor: Un,
|
|
770
874
|
executor: (e) => {
|
|
771
875
|
let t = e, n = [...t.tag === void 0 ? [] : [U("tag", t.tag)], ...t.status === void 0 ? [] : [U("status", t.status)]], r = Number.isFinite(t.limit) && t.limit !== void 0 ? Math.min(Math.max(Math.floor(t.limit), 1), 500) : 100;
|
|
@@ -775,13 +879,13 @@ var Vi = () => Math.max(500, Math.floor(ti() * .6)), Hi = (e) => new Promise((t)
|
|
|
775
879
|
column: "startedAt",
|
|
776
880
|
direction: "desc"
|
|
777
881
|
}],
|
|
778
|
-
predicate: n.length === 0 ? void 0 : n.length === 1 ? n[0] :
|
|
882
|
+
predicate: n.length === 0 ? void 0 : n.length === 1 ? n[0] : qn(...n),
|
|
779
883
|
take: r,
|
|
780
884
|
skip: void 0,
|
|
781
885
|
projection: void 0
|
|
782
886
|
};
|
|
783
887
|
}
|
|
784
|
-
}, e), r, `subscription.${Un.name}`), A[Hn.name] = (e) =>
|
|
888
|
+
}, e), r, `subscription.${Un.name}`), A[Hn.name] = (e) => _r(D({
|
|
785
889
|
descriptor: Hn,
|
|
786
890
|
executor: (e) => {
|
|
787
891
|
let t = e.runId;
|
|
@@ -797,7 +901,7 @@ var Vi = () => Math.max(500, Math.floor(ti() * .6)), Hi = (e) => new Promise((t)
|
|
|
797
901
|
projection: void 0
|
|
798
902
|
};
|
|
799
903
|
}
|
|
800
|
-
}, e), r, `subscription.${Hn.name}`), A[Bn.name] = (e) =>
|
|
904
|
+
}, e), r, `subscription.${Hn.name}`), A[Bn.name] = (e) => _r(D({
|
|
801
905
|
descriptor: Bn,
|
|
802
906
|
executor: (e) => {
|
|
803
907
|
let t = e.runId;
|
|
@@ -813,7 +917,7 @@ var Vi = () => Math.max(500, Math.floor(ti() * .6)), Hi = (e) => new Promise((t)
|
|
|
813
917
|
projection: void 0
|
|
814
918
|
};
|
|
815
919
|
}
|
|
816
|
-
}, e), r, `subscription.${Bn.name}`), A[B.name] = (e) =>
|
|
920
|
+
}, e), r, `subscription.${Bn.name}`), A[B.name] = (e) => _r(D({
|
|
817
921
|
descriptor: B,
|
|
818
922
|
executor: (e) => {
|
|
819
923
|
let t = e;
|
|
@@ -829,7 +933,7 @@ var Vi = () => Math.max(500, Math.floor(ti() * .6)), Hi = (e) => new Promise((t)
|
|
|
829
933
|
projection: void 0
|
|
830
934
|
};
|
|
831
935
|
}
|
|
832
|
-
}, e), r, `subscription.${B.name}`), A[V.name] = (e) =>
|
|
936
|
+
}, e), r, `subscription.${B.name}`), A[V.name] = (e) => _r(D({
|
|
833
937
|
descriptor: V,
|
|
834
938
|
executor: (e) => {
|
|
835
939
|
let t = e.eventId;
|
|
@@ -845,16 +949,16 @@ var Vi = () => Math.max(500, Math.floor(ti() * .6)), Hi = (e) => new Promise((t)
|
|
|
845
949
|
projection: void 0
|
|
846
950
|
};
|
|
847
951
|
}
|
|
848
|
-
}, e), r, `subscription.${V.name}`), A[Rn.name] = (t) =>
|
|
952
|
+
}, e), r, `subscription.${V.name}`), A[Rn.name] = (t) => q(async (t, n) => {
|
|
849
953
|
let r = t;
|
|
850
954
|
return await j(e.store, n.subject, { executionId: r.executionId }), await S.cancel(r.workflowName, r.executionId), await Ft(r.workflowName, r.executionId, "workflow.cancel"), { ok: !0 };
|
|
851
|
-
}, t, `action.${Rn.name}`), A[zn.name] = (t) =>
|
|
955
|
+
}, t, `action.${Rn.name}`), A[zn.name] = (t) => q(async (t, n) => {
|
|
852
956
|
let r = t;
|
|
853
957
|
return await j(e.store, n.subject, { executionId: r.executionId }), await S.resume(r.workflowName, r.executionId), { ok: !0 };
|
|
854
|
-
}, t, `action.${zn.name}`), A[Wn.name] = (t) =>
|
|
958
|
+
}, t, `action.${zn.name}`), A[Wn.name] = (t) => q(async (t, n) => {
|
|
855
959
|
let r = t;
|
|
856
960
|
return await j(e.store, n.subject, { id: r.id }), S.signal({ id: r.id }, r.signalName, r.payload);
|
|
857
|
-
}, t, `action.${Wn.name}`), A[Gn.name] = (t) =>
|
|
961
|
+
}, t, `action.${Wn.name}`), A[Gn.name] = (t) => q(async (t, n) => {
|
|
858
962
|
let r = t;
|
|
859
963
|
return await j(e.store, n.subject, { id: r.id }), S.update({ id: r.id }, r.updateName, r.payload, r.timeoutMs === void 0 ? void 0 : { timeoutMs: r.timeoutMs });
|
|
860
964
|
}, t, `action.${Gn.name}`));
|
|
@@ -862,16 +966,16 @@ var Vi = () => Math.max(500, Math.floor(ti() * .6)), Hi = (e) => new Promise((t)
|
|
|
862
966
|
...k(e.discovered.queries).map((e) => z(e.descriptor)),
|
|
863
967
|
...k(e.discovered.mutations).map((e) => Fn(e.descriptor)),
|
|
864
968
|
...k(e.discovered.actions).map((e) => R(e.descriptor)),
|
|
865
|
-
...ct.queries.map((e) => z(e.descriptor)),
|
|
866
|
-
...ct.mutations.map((e) => Fn(e.descriptor)),
|
|
867
969
|
...lt.queries.map((e) => z(e.descriptor)),
|
|
868
970
|
...lt.mutations.map((e) => Fn(e.descriptor)),
|
|
971
|
+
...ut.queries.map((e) => z(e.descriptor)),
|
|
972
|
+
...ut.mutations.map((e) => Fn(e.descriptor)),
|
|
869
973
|
...w.queries.map((e) => z(e.descriptor)),
|
|
870
974
|
...w.mutations.map((e) => Fn(e.descriptor)),
|
|
871
975
|
...w.actions.map((e) => R(e.descriptor)),
|
|
872
976
|
...k(e.discovered.streams ?? []).map((e) => In(e.descriptor)),
|
|
873
|
-
...
|
|
874
|
-
...(e.discovered.workflows ?? []).map((e) =>
|
|
977
|
+
...Le.rpcs,
|
|
978
|
+
...(e.discovered.workflows ?? []).map((e) => di(e.definition)),
|
|
875
979
|
...de ? [
|
|
876
980
|
z(Vn),
|
|
877
981
|
z(Un),
|
|
@@ -884,14 +988,14 @@ var Vi = () => Math.max(500, Math.floor(ti() * .6)), Hi = (e) => new Promise((t)
|
|
|
884
988
|
R(Wn),
|
|
885
989
|
R(Gn)
|
|
886
990
|
] : []
|
|
887
|
-
], Ot =
|
|
888
|
-
register: (t, n, r) =>
|
|
991
|
+
], Ot = hi.make(...Dt).middleware(jn).middleware(Mn), kt = Pr({ resolveSubject: ({ headers: t, clientId: n }) => e.resolveSubject(t, n) }), At = e.dormancyTenantId ?? or, Nt = e.dormancy === "sleep" ? {
|
|
992
|
+
register: (t, n, r) => Qr(e.store, {
|
|
889
993
|
tenantId: r ?? At,
|
|
890
994
|
kind: "workflow",
|
|
891
995
|
refId: t,
|
|
892
996
|
wakeAt: n
|
|
893
997
|
}),
|
|
894
|
-
cancel: (t, n) =>
|
|
998
|
+
cancel: (t, n) => yr(e.store, {
|
|
895
999
|
tenantId: n ?? At,
|
|
896
1000
|
kind: "workflow",
|
|
897
1001
|
refId: t
|
|
@@ -942,8 +1046,8 @@ var Vi = () => Math.max(500, Math.floor(ti() * .6)), Hi = (e) => new Promise((t)
|
|
|
942
1046
|
}
|
|
943
1047
|
}), a && await Pt(n, "cancelled");
|
|
944
1048
|
}, It = [
|
|
945
|
-
...
|
|
946
|
-
buildContext: (t, n) => e.buildContextForWorkflow?.(t, n) ??
|
|
1049
|
+
...qr(e.discovered.workflows ?? [], {
|
|
1050
|
+
buildContext: (t, n) => e.buildContextForWorkflow?.(t, n) ?? ze({
|
|
947
1051
|
subject: t.subject,
|
|
948
1052
|
traceId: t.traceId
|
|
949
1053
|
}, e.store, void 0, `workflow:${n.workflowName}`, { parentExecutionId: n.executionId }),
|
|
@@ -963,13 +1067,13 @@ var Vi = () => Math.max(500, Math.floor(ti() * .6)), Hi = (e) => new Promise((t)
|
|
|
963
1067
|
parentExecutionId: r?.parentExecutionId ?? null,
|
|
964
1068
|
parentClosePolicy: r?.parentClosePolicy ?? null,
|
|
965
1069
|
onParentClose: ({ executionId: e, status: t }) => Pt(e, t),
|
|
966
|
-
...
|
|
1070
|
+
...ft(t.definition),
|
|
967
1071
|
onTerminal: async ({ executionId: e }) => {
|
|
968
1072
|
await l?.gate.release(e);
|
|
969
1073
|
},
|
|
970
1074
|
recorder: N,
|
|
971
|
-
pluginWorkflowStepLayer:
|
|
972
|
-
recordRun:
|
|
1075
|
+
pluginWorkflowStepLayer: rt,
|
|
1076
|
+
recordRun: Zr
|
|
973
1077
|
}, n);
|
|
974
1078
|
}),
|
|
975
1079
|
...e.discovered.workflowWorkers ?? [],
|
|
@@ -977,11 +1081,11 @@ var Vi = () => Math.max(500, Math.floor(ti() * .6)), Hi = (e) => new Promise((t)
|
|
|
977
1081
|
], Lt = [...(e.discovered.workflows ?? []).map((e) => e.definition.name).filter(Boolean), ...ye === void 0 ? [] : ["voltro.deliverWebhook"]], zt = It.length > 0 ? G.mergeAll(...It) : G.empty;
|
|
978
1082
|
if (((e.discovered.workflows?.length ?? 0) > 0 || (e.discovered.workflowWorkers?.length ?? 0) > 0 || e.scheduleCoordination === "cluster" || ye !== void 0) && e.workflowEngineLayer !== void 0) {
|
|
979
1083
|
let t = zt.pipe(G.provideMerge(e.workflowEngineLayer));
|
|
980
|
-
u =
|
|
1084
|
+
u = $n.make(e.baseLayer === void 0 ? t : t.pipe(G.provideMerge(e.baseLayer))), await u.runPromise(W.void), (e.log ?? L({ scope: "voltro:serve" })).child("workflow").info(`workflow runtime ready — ${Lt.length} entity type(s) registered`, { entities: Lt });
|
|
981
1085
|
let n = await import("@voltro/workflow/cluster"), r = (e) => u.runPromise(n.redriveFailedRun(e)), i = (e) => u.runPromise(n.resumeRunFromStep(e));
|
|
982
1086
|
m = await Bt({
|
|
983
|
-
provider:
|
|
984
|
-
crossReplica:
|
|
1087
|
+
provider: Fi(e.plugins ?? [])?.broadcast?.provider,
|
|
1088
|
+
crossReplica: Fi(e.plugins ?? [])?.broadcast?.crossReplica ?? !1,
|
|
985
1089
|
namespace: je,
|
|
986
1090
|
replicaId: crypto.randomUUID(),
|
|
987
1091
|
pollStorage: () => u.runPromise(n.pollWorkflowStorage),
|
|
@@ -1030,7 +1134,7 @@ var Vi = () => Math.max(500, Math.floor(ti() * .6)), Hi = (e) => new Promise((t)
|
|
|
1030
1134
|
reason: n.outcome.reason
|
|
1031
1135
|
};
|
|
1032
1136
|
};
|
|
1033
|
-
let a = (e.scheduleCoordination ?? "single") === "advisoryLock" ?
|
|
1137
|
+
let a = (e.scheduleCoordination ?? "single") === "advisoryLock" ? kr(e.store, e.scheduleReplicaId ?? `pid-${process.pid}`) : ii, s = Fr({
|
|
1034
1138
|
coordinator: a,
|
|
1035
1139
|
replicaId: e.scheduleReplicaId ?? `pid-${process.pid}`
|
|
1036
1140
|
}), d = {
|
|
@@ -1055,7 +1159,7 @@ var Vi = () => Math.max(500, Math.floor(ti() * .6)), Hi = (e) => new Promise((t)
|
|
|
1055
1159
|
closeChildrenForParent: Pt
|
|
1056
1160
|
}), h;
|
|
1057
1161
|
};
|
|
1058
|
-
ee = g, l =
|
|
1162
|
+
ee = g, l = et({
|
|
1059
1163
|
store: e.store,
|
|
1060
1164
|
onChange: (t) => e.store.onChange((e) => t({
|
|
1061
1165
|
table: e.table,
|
|
@@ -1075,7 +1179,7 @@ var Vi = () => Math.max(500, Math.floor(ti() * .6)), Hi = (e) => new Promise((t)
|
|
|
1075
1179
|
...e.workflowSuspendSignalHintMs === void 0 ? {} : { suspendSignalHintMs: e.workflowSuspendSignalHintMs },
|
|
1076
1180
|
scheduleCoordinated: s,
|
|
1077
1181
|
onAbandoned: async (t) => {
|
|
1078
|
-
await
|
|
1182
|
+
await Ge({
|
|
1079
1183
|
workflows: e.discovered.workflows ?? [],
|
|
1080
1184
|
facade: () => o,
|
|
1081
1185
|
log: d,
|
|
@@ -1085,7 +1189,7 @@ var Vi = () => Math.max(500, Math.floor(ti() * .6)), Hi = (e) => new Promise((t)
|
|
|
1085
1189
|
log: d
|
|
1086
1190
|
});
|
|
1087
1191
|
let _ = l;
|
|
1088
|
-
_ !== void 0 &&
|
|
1192
|
+
_ !== void 0 && Yr(() => _.stop()), c = Qe({
|
|
1089
1193
|
store: e.store,
|
|
1090
1194
|
onChange: (t) => e.store.onChange((e) => t({
|
|
1091
1195
|
table: e.table,
|
|
@@ -1099,7 +1203,7 @@ var Vi = () => Math.max(500, Math.floor(ti() * .6)), Hi = (e) => new Promise((t)
|
|
|
1099
1203
|
resumeSignal: () => u === void 0 || M === void 0 ? void 0 : async ({ executionId: t, workflowName: n, signalName: r, payload: i }) => {
|
|
1100
1204
|
await u.runPromise(M.completeSuspendingSignal({
|
|
1101
1205
|
store: e.store,
|
|
1102
|
-
target:
|
|
1206
|
+
target: qe(t, n),
|
|
1103
1207
|
signalName: r,
|
|
1104
1208
|
payload: i
|
|
1105
1209
|
}));
|
|
@@ -1109,7 +1213,7 @@ var Vi = () => Math.max(500, Math.floor(ti() * .6)), Hi = (e) => new Promise((t)
|
|
|
1109
1213
|
log: d
|
|
1110
1214
|
});
|
|
1111
1215
|
let v = c;
|
|
1112
|
-
v !== void 0 &&
|
|
1216
|
+
v !== void 0 && Yr(() => v.stop()), o = (e.discovered.workflows?.length ?? 0) > 0 ? Gr({
|
|
1113
1217
|
workflows: e.discovered.workflows ?? [],
|
|
1114
1218
|
runEffect: (e) => u.runPromise(e),
|
|
1115
1219
|
onEnqueue: () => m?.publishWake(),
|
|
@@ -1155,13 +1259,13 @@ var Vi = () => Math.max(500, Math.floor(ti() * .6)), Hi = (e) => new Promise((t)
|
|
|
1155
1259
|
}, t).then((e) => e.outcome)
|
|
1156
1260
|
}) : void 0;
|
|
1157
1261
|
}
|
|
1158
|
-
let Vt = G.mergeAll(Ot.toLayer(A), kt), Ht =
|
|
1262
|
+
let Vt = G.mergeAll(Ot.toLayer(A), kt), Ht = at(A, e.discovered.queries.map((e) => e.descriptor.name), de), Ut = G.mergeAll(Ot.toLayer(Ht), kt), P = e.observability, Wt = await vr({
|
|
1159
1263
|
...e.appName === void 0 ? {} : { serviceName: e.appName },
|
|
1160
1264
|
...P && P.spanProcessors.length > 0 ? { extraSpanProcessors: P.spanProcessors } : {},
|
|
1161
1265
|
...P && P.metricReaders.length > 0 ? { extraMetricReaders: P.metricReaders } : {},
|
|
1162
1266
|
...P && Object.keys(P.resourceAttributes).length > 0 ? { resourceAttributes: P.resourceAttributes } : {},
|
|
1163
1267
|
...P && P.sampler !== void 0 ? { sampler: P.sampler } : {}
|
|
1164
|
-
}), Gt = !1, F = e.store.ping ? () => e.store.ping().then(() => !0).catch(() => !1) : void 0, { server: Kt, shutdown: qt } =
|
|
1268
|
+
}), Gt = !1, F = e.store.ping ? () => e.store.ping().then(() => !0).catch(() => !1) : void 0, { server: Kt, shutdown: qt } = ai({
|
|
1165
1269
|
group: Ot,
|
|
1166
1270
|
handlersLayer: Vt,
|
|
1167
1271
|
httpHandlersLayer: Ut,
|
|
@@ -1170,7 +1274,7 @@ var Vi = () => Math.max(500, Math.floor(ti() * .6)), Hi = (e) => new Promise((t)
|
|
|
1170
1274
|
path: e.path ?? "/ws",
|
|
1171
1275
|
tracerLayer: Wt.layer,
|
|
1172
1276
|
security: re(e),
|
|
1173
|
-
...
|
|
1277
|
+
...nt,
|
|
1174
1278
|
healthCheck: {
|
|
1175
1279
|
isReady: () => Gt,
|
|
1176
1280
|
...F ? { ping: F } : {}
|
|
@@ -1179,10 +1283,10 @@ var Vi = () => Math.max(500, Math.floor(ti() * .6)), Hi = (e) => new Promise((t)
|
|
|
1179
1283
|
...e.getStore === void 0 ? {} : { getStore: e.getStore },
|
|
1180
1284
|
...Se.size > 0 ? { webhookRoutes: Se } : {},
|
|
1181
1285
|
...e.inspectRoute === void 0 ? {} : { inspectRoute: e.inspectRoute }
|
|
1182
|
-
}), Jt =
|
|
1183
|
-
if (await
|
|
1184
|
-
let t = (e.scheduleCoordination ?? "single") === "advisoryLock" ?
|
|
1185
|
-
h = await
|
|
1286
|
+
}), Jt = Ji(Kt);
|
|
1287
|
+
if (await hr(Kt), (e.discovered.schedules?.length ?? 0) > 0) {
|
|
1288
|
+
let t = (e.scheduleCoordination ?? "single") === "advisoryLock" ? kr(e.store, e.scheduleReplicaId ?? `pid-${process.pid}`) : ii;
|
|
1289
|
+
h = await oi(e.discovered.schedules ?? [], {
|
|
1186
1290
|
store: e.store,
|
|
1187
1291
|
coordinator: t,
|
|
1188
1292
|
defaultTrigger: e.scheduleDefaultTrigger ?? "self",
|
|
@@ -1190,7 +1294,7 @@ var Vi = () => Math.max(500, Math.floor(ti() * .6)), Hi = (e) => new Promise((t)
|
|
|
1190
1294
|
armSelf: e.scheduleArmSelf ?? !0,
|
|
1191
1295
|
dormancy: e.dormancy ?? "always-on",
|
|
1192
1296
|
...e.dormancyTenantId === void 0 ? {} : { dormancyTenantId: e.dormancyTenantId },
|
|
1193
|
-
buildContext: ({ traceId: t, scheduleName: n, subject: r }) =>
|
|
1297
|
+
buildContext: ({ traceId: t, scheduleName: n, subject: r }) => ze({
|
|
1194
1298
|
subject: r,
|
|
1195
1299
|
traceId: t
|
|
1196
1300
|
}, e.store, void 0, `schedule:${n}`),
|
|
@@ -1211,7 +1315,7 @@ var Vi = () => Math.max(500, Math.floor(ti() * .6)), Hi = (e) => new Promise((t)
|
|
|
1211
1315
|
}), e.onSchedulerReady?.(h);
|
|
1212
1316
|
}
|
|
1213
1317
|
let I = e.log ?? L({ scope: "voltro:serve" }), Yt, Xt;
|
|
1214
|
-
if ((e.discovered.subscribers?.length ?? 0) > 0 && (Yt = xe(e.discovered.subscribers ?? [], e.store, I.child("subscribe"), e.schemaRegistry,
|
|
1318
|
+
if ((e.discovered.subscribers?.length ?? 0) > 0 && (Yt = xe(e.discovered.subscribers ?? [], e.store, I.child("subscribe"), e.schemaRegistry, Le.bus)), (e.discovered.reactions?.length ?? 0) > 0) {
|
|
1215
1319
|
let t = I.child("reaction"), n = async (n, r) => {
|
|
1216
1320
|
if (n.kind === "workflow") {
|
|
1217
1321
|
if (S === void 0) {
|
|
@@ -1219,7 +1323,7 @@ var Vi = () => Math.max(500, Math.floor(ti() * .6)), Hi = (e) => new Promise((t)
|
|
|
1219
1323
|
return;
|
|
1220
1324
|
}
|
|
1221
1325
|
let e = n.payload === void 0 ? r.new ?? r.old ?? {} : n.payload(r);
|
|
1222
|
-
await
|
|
1326
|
+
await Kr(S, {
|
|
1223
1327
|
traceId: `reaction:${n.workflow}`,
|
|
1224
1328
|
source: `reaction:${n.workflow}`
|
|
1225
1329
|
}).start(n.workflow, e);
|
|
@@ -1227,7 +1331,7 @@ var Vi = () => Math.max(500, Math.floor(ti() * .6)), Hi = (e) => new Promise((t)
|
|
|
1227
1331
|
}
|
|
1228
1332
|
await pe(n.agent, r, {
|
|
1229
1333
|
findAgentSend: (t) => e.discovered.actions.find((e) => e.descriptor.name === `${t}.send`),
|
|
1230
|
-
runAction: (e, t, n) => Promise.resolve(
|
|
1334
|
+
runAction: (e, t, n) => Promise.resolve(pt(e, t, n)),
|
|
1231
1335
|
makeSubject: (e) => Nn(e),
|
|
1232
1336
|
now: () => Date.now(),
|
|
1233
1337
|
log: t
|
|
@@ -1243,7 +1347,7 @@ var Vi = () => Math.max(500, Math.floor(ti() * .6)), Hi = (e) => new Promise((t)
|
|
|
1243
1347
|
return t.warn("reaction budget check failed — refusing the act", { tenantId: n }, e), !1;
|
|
1244
1348
|
}
|
|
1245
1349
|
}, i = jt(e.store, { onError: (e) => t.warn("reaction: rate-slot claim failed; refusing the act", { cause: String(e) }) });
|
|
1246
|
-
Xt =
|
|
1350
|
+
Xt = ct(e.discovered.reactions ?? [], e.store, {
|
|
1247
1351
|
runAct: n,
|
|
1248
1352
|
checkBudget: r,
|
|
1249
1353
|
claimRateSlot: (e) => i.claim(e)
|
|
@@ -1257,32 +1361,32 @@ var Vi = () => Math.max(500, Math.floor(ti() * .6)), Hi = (e) => new Promise((t)
|
|
|
1257
1361
|
...e.analytics === void 0 ? {} : { analytics: e.analytics },
|
|
1258
1362
|
...e.aggregateStorage === void 0 ? {} : { storage: e.aggregateStorage },
|
|
1259
1363
|
...e.aggregateCoordinator === void 0 ? {} : { coordinator: e.aggregateCoordinator }
|
|
1260
|
-
}),
|
|
1364
|
+
}), Be = G.succeed(ar, Zt.registry));
|
|
1261
1365
|
let Qt;
|
|
1262
|
-
(e.discovered.expectations?.length ?? 0) > 0 && (Qt =
|
|
1366
|
+
(e.discovered.expectations?.length ?? 0) > 0 && (Qt = fr({
|
|
1263
1367
|
discovered: e.discovered.expectations ?? [],
|
|
1264
1368
|
store: e.store,
|
|
1265
1369
|
log: I.child("expectation")
|
|
1266
|
-
}),
|
|
1370
|
+
}), Ve = G.succeed(cr, Qt.registry)), (e.discovered.budgets?.length ?? 0) > 0 && (n = mr({
|
|
1267
1371
|
discovered: e.discovered.budgets ?? [],
|
|
1268
1372
|
log: I.child("finops")
|
|
1269
|
-
}),
|
|
1373
|
+
}), Ue = G.succeed(K, n.registry));
|
|
1270
1374
|
let $t;
|
|
1271
|
-
return (e.discovered.experiments?.length ?? 0) > 0 && ($t =
|
|
1375
|
+
return (e.discovered.experiments?.length ?? 0) > 0 && ($t = pr({
|
|
1272
1376
|
discovered: e.discovered.experiments ?? [],
|
|
1273
1377
|
store: e.store,
|
|
1274
1378
|
log: I.child("experiment")
|
|
1275
|
-
}),
|
|
1379
|
+
}), Ke = G.succeed(lr, $t.registry)), Gt = !0, e.bootTiming?.mark("ready"), {
|
|
1276
1380
|
dispatcher: r,
|
|
1277
1381
|
server: Kt,
|
|
1278
1382
|
scheduler: h,
|
|
1279
|
-
eventsSnapshot: me(
|
|
1383
|
+
eventsSnapshot: me(Le.bus, Le.declared),
|
|
1280
1384
|
membersSnapshot: () => ({
|
|
1281
1385
|
members: Ie.membership.list(),
|
|
1282
1386
|
capturedAt: Date.now()
|
|
1283
1387
|
}),
|
|
1284
1388
|
agentTools: () => bt,
|
|
1285
|
-
rpcMetrics: () =>
|
|
1389
|
+
rpcMetrics: () => Ze,
|
|
1286
1390
|
webhooksService: () => ve,
|
|
1287
1391
|
runCanceller: () => ee(),
|
|
1288
1392
|
flowControlHealth: () => l?.cancelHealth(),
|
|
@@ -1305,10 +1409,10 @@ var Vi = () => Math.max(500, Math.floor(ti() * .6)), Hi = (e) => new Promise((t)
|
|
|
1305
1409
|
} catch (e) {
|
|
1306
1410
|
I.warn("serve: teardown step failed", {}, e);
|
|
1307
1411
|
}
|
|
1308
|
-
await
|
|
1412
|
+
await Re?.detach(), await Ie.detach(), Zt?.detach(), Qt?.detach(), n?.detach(), $t?.detach(), Xt?.(), Yt?.(), await h?.shutdown(), r.close(), await m?.detach(), await u?.dispose(), await qt(), await Jt.finish();
|
|
1309
1413
|
}
|
|
1310
1414
|
};
|
|
1311
|
-
}, $ = L({ scope: "voltro:serve" }),
|
|
1415
|
+
}, $ = L({ scope: "voltro:serve" }), Da = (e, t, n) => (e === "production" || e === "staging") && t !== "memory" && n !== "0", Oa = Ut, ka = async (e) => {
|
|
1312
1416
|
let t = Sn(process.cwd());
|
|
1313
1417
|
if (kn(t)) {
|
|
1314
1418
|
let n;
|
|
@@ -1320,24 +1424,24 @@ var Vi = () => Math.max(500, Math.floor(ti() * .6)), Hi = (e) => new Promise((t)
|
|
|
1320
1424
|
}
|
|
1321
1425
|
if (n) return $.info("serve: booting from the precompiled serve bundle"), n(e);
|
|
1322
1426
|
}
|
|
1323
|
-
return
|
|
1324
|
-
},
|
|
1427
|
+
return Aa(e);
|
|
1428
|
+
}, Aa = async (s) => {
|
|
1325
1429
|
let d = Cn();
|
|
1326
1430
|
e("serve");
|
|
1327
1431
|
try {
|
|
1328
|
-
|
|
1432
|
+
Ci();
|
|
1329
1433
|
} catch (e) {
|
|
1330
1434
|
throw i(e instanceof Error ? e.message : String(e));
|
|
1331
1435
|
}
|
|
1332
|
-
let g = process.cwd(), v = await
|
|
1436
|
+
let g = process.cwd(), v = await Ue(g), ne = P({
|
|
1333
1437
|
kind: "api",
|
|
1334
1438
|
configPort: v?.port,
|
|
1335
1439
|
env: process.env,
|
|
1336
|
-
flagPort:
|
|
1440
|
+
flagPort: Oa(s, "--port")
|
|
1337
1441
|
});
|
|
1338
1442
|
for (let e of ne.warnings) $.warn(e);
|
|
1339
1443
|
let ie = ne.port;
|
|
1340
|
-
$r(
|
|
1444
|
+
ti($r(v?.secrets)), await Wt({
|
|
1341
1445
|
rawEnv: v?.env,
|
|
1342
1446
|
appType: "api",
|
|
1343
1447
|
root: g,
|
|
@@ -1355,20 +1459,20 @@ var Vi = () => Math.max(500, Math.floor(ti() * .6)), Hi = (e) => new Promise((t)
|
|
|
1355
1459
|
} catch (e) {
|
|
1356
1460
|
$.warn("precompiled api bundle failed to load — falling back to source", {}, e);
|
|
1357
1461
|
}
|
|
1358
|
-
let b = await
|
|
1462
|
+
let b = await Xe(g), x = await kt(b, { cdc: se && ce !== void 0 }), ue = Ht(x);
|
|
1359
1463
|
{
|
|
1360
1464
|
let e = /* @__PURE__ */ new Set([
|
|
1361
1465
|
...x.queries.filter((e) => e.descriptor.overridesPlugin === !0).map((e) => e.descriptor.name),
|
|
1362
1466
|
...x.mutations.filter((e) => e.descriptor.overridesPlugin === !0).map((e) => e.descriptor.name),
|
|
1363
1467
|
...x.actions.filter((e) => e.descriptor.overridesPlugin === !0).map((e) => e.descriptor.name)
|
|
1364
1468
|
]);
|
|
1365
|
-
|
|
1469
|
+
nn(Xt(v?.plugins ?? []), [
|
|
1366
1470
|
...x.queries.map((e) => e.descriptor.name),
|
|
1367
1471
|
...x.mutations.map((e) => e.descriptor.name),
|
|
1368
1472
|
...x.actions.map((e) => e.descriptor.name),
|
|
1369
1473
|
...x.streams.map((e) => e.descriptor.name)
|
|
1370
1474
|
], e);
|
|
1371
|
-
let t = ae(x.serverOnlyLeaks, Ae(process.env, "strict"),
|
|
1475
|
+
let t = ae(x.serverOnlyLeaks, Ae(process.env, "strict"), Sr, "`voltro serve`");
|
|
1372
1476
|
if (t.action === "fail") throw i(t.message ?? "");
|
|
1373
1477
|
t.action === "warn" && $.warn(t.message ?? "");
|
|
1374
1478
|
}
|
|
@@ -1379,24 +1483,24 @@ var Vi = () => Math.max(500, Math.floor(ti() * .6)), Hi = (e) => new Promise((t)
|
|
|
1379
1483
|
}, me = gn(x.events), be = pe.outgoing.length + pe.incoming.length + pe.providers.length + me.length === 0 ? void 0 : {
|
|
1380
1484
|
...pe,
|
|
1381
1485
|
outgoing: [...pe.outgoing, ...me]
|
|
1382
|
-
}, xe =
|
|
1486
|
+
}, xe = rn({
|
|
1383
1487
|
nodeEnv: process.env.NODE_ENV,
|
|
1384
1488
|
cdcDialect: ce,
|
|
1385
1489
|
declared: v?.schema
|
|
1386
|
-
}), we =
|
|
1490
|
+
}), we = an({
|
|
1387
1491
|
gates: xe,
|
|
1388
1492
|
runtime: {
|
|
1389
1493
|
traces: ve(),
|
|
1390
|
-
undo:
|
|
1494
|
+
undo: ci()
|
|
1391
1495
|
}
|
|
1392
1496
|
});
|
|
1393
1497
|
if (we !== void 0) throw i(`serve: ${we}`);
|
|
1394
|
-
let De =
|
|
1498
|
+
let De = tn({
|
|
1395
1499
|
mix: x.featureMix,
|
|
1396
1500
|
plugins: v?.plugins ?? [],
|
|
1397
1501
|
gates: xe,
|
|
1398
1502
|
...ce ? { cdcDialect: ce } : {}
|
|
1399
|
-
}), Oe = v?.analytics !== void 0 && v.analytics.kind !== "noop" && y !== "memory" ? (await F(y)).makeSqlLayer(O()) : void 0, ke = await
|
|
1503
|
+
}), Oe = v?.analytics !== void 0 && v.analytics.kind !== "noop" && y !== "memory" ? (await F(y)).makeSqlLayer(O()) : void 0, ke = await Je({
|
|
1400
1504
|
spec: v?.analytics,
|
|
1401
1505
|
sqlLayer: Oe,
|
|
1402
1506
|
log: $
|
|
@@ -1405,26 +1509,26 @@ var Vi = () => Math.max(500, Math.floor(ti() * .6)), Hi = (e) => new Promise((t)
|
|
|
1405
1509
|
for (let n of [...De, ...ke.tables]) e.has(n.tableName) || (e.add(n.tableName), t.push(n));
|
|
1406
1510
|
return t;
|
|
1407
1511
|
})();
|
|
1408
|
-
for (let e of T)
|
|
1512
|
+
for (let e of T) Xn(e);
|
|
1409
1513
|
{
|
|
1410
|
-
let e =
|
|
1514
|
+
let e = Cr(li(Ve(x), Lt(T)));
|
|
1411
1515
|
e !== void 0 && $.warn(e);
|
|
1412
1516
|
}
|
|
1413
1517
|
let Pe = (process.env.NODE_ENV ?? "").toLowerCase();
|
|
1414
|
-
if (
|
|
1415
|
-
let e = (await F(y)).makeSqlLayer(O()), t = await W.runPromise(
|
|
1518
|
+
if (Da(Pe, y, process.env.VOLTRO_AUTO_MIGRATE)) {
|
|
1519
|
+
let e = (await F(y)).makeSqlLayer(O()), t = await W.runPromise(er.SqlClient.pipe(W.flatMap((e) => rr(e, g)), W.provide(e), W.catchAll(() => W.succeed([]))));
|
|
1416
1520
|
t.length > 0 && ($.error(`serve: refusing to boot — ${t.length} pending file-based migration(s) have never run against this database. They perform the changes a schema diff cannot infer (data moves, backfills, table splits), so the declarative fingerprint check below cannot see them and would have let this process serve un-migrated data.`, { pending: t }), $.error("Run them from your pre-deploy job — `voltro db migrate .` (schema + files) or `voltro db files .` (files alone) — or set VOLTRO_AUTO_MIGRATE=0 to bypass every boot schema check. `voltro serve` never applies them itself: a rolling deploy would start N replicas and each would try."), process.exit(1));
|
|
1417
|
-
let n = await W.runPromise(
|
|
1521
|
+
let n = await W.runPromise(er.SqlClient.pipe(W.flatMap((e) => ir(e, T, {
|
|
1418
1522
|
appliedBy: `serve:${Pe}`,
|
|
1419
1523
|
environment: "prod",
|
|
1420
1524
|
dialectId: y
|
|
1421
1525
|
})), W.provide(e)));
|
|
1422
|
-
n.kind === "prod-mismatch" && ($.error(
|
|
1526
|
+
n.kind === "prod-mismatch" && ($.error(nr(n, y)), $.error(on({
|
|
1423
1527
|
gates: xe,
|
|
1424
1528
|
nodeEnv: process.env.NODE_ENV,
|
|
1425
1529
|
cdcDialect: ce,
|
|
1426
1530
|
declared: v?.schema
|
|
1427
|
-
})), $.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(
|
|
1531
|
+
})), $.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(nr(n, y));
|
|
1428
1532
|
}
|
|
1429
1533
|
await Yt({
|
|
1430
1534
|
dialectId: y,
|
|
@@ -1437,19 +1541,19 @@ var Vi = () => Math.max(500, Math.floor(ti() * .6)), Hi = (e) => new Promise((t)
|
|
|
1437
1541
|
warn: (e, t) => $.warn(e, t ?? {})
|
|
1438
1542
|
}
|
|
1439
1543
|
});
|
|
1440
|
-
let Fe =
|
|
1544
|
+
let Fe = Wr(T);
|
|
1441
1545
|
d.mark("discover");
|
|
1442
|
-
let E = await
|
|
1546
|
+
let E = await it(v, void 0);
|
|
1443
1547
|
{
|
|
1444
1548
|
let e = await ee(E);
|
|
1445
1549
|
if (e !== void 0) throw i(`serve: ${e}`);
|
|
1446
1550
|
}
|
|
1447
|
-
let
|
|
1448
|
-
for (let e of
|
|
1551
|
+
let He = fi(E, y);
|
|
1552
|
+
for (let e of nt({
|
|
1449
1553
|
dialect: String(v?.store ?? process.env.DB_DIALECT ?? "postgres"),
|
|
1450
1554
|
changeStrategy: (process.env.CDC ?? "1") === "0" ? "inline" : "cdc",
|
|
1451
1555
|
dbUrl: process.env.DB_URL,
|
|
1452
|
-
crossReplicaBus:
|
|
1556
|
+
crossReplicaBus: Fi(v?.plugins ?? [])?.broadcast.crossReplica === !0,
|
|
1453
1557
|
tables: x.tables.map((e) => ({
|
|
1454
1558
|
tableName: e.tableName,
|
|
1455
1559
|
isReactive: e.isReactive === !0
|
|
@@ -1466,25 +1570,25 @@ var Vi = () => Math.max(500, Math.floor(ti() * .6)), Hi = (e) => new Promise((t)
|
|
|
1466
1570
|
name: e.descriptor.name,
|
|
1467
1571
|
source: e.descriptor.source
|
|
1468
1572
|
}))
|
|
1469
|
-
}), t =
|
|
1573
|
+
}), t = mt(e);
|
|
1470
1574
|
t !== void 0 && $.warn(t);
|
|
1471
1575
|
}
|
|
1472
1576
|
v?.cache && !process.env.CACHE_BACKEND && (process.env.CACHE_BACKEND = v.cache), v?.cacheRedisUrl && !process.env.CACHE_REDIS_URL && (process.env.CACHE_REDIS_URL = v.cacheRedisUrl), v?.cacheRedisDriver && !process.env.CACHE_REDIS_DRIVER && (process.env.CACHE_REDIS_DRIVER = v.cacheRedisDriver), v?.cacheKeyPrefix && !process.env.CACHE_KEY_PREFIX && (process.env.CACHE_KEY_PREFIX = v.cacheKeyPrefix);
|
|
1473
|
-
let { service:
|
|
1577
|
+
let { service: We, invalidationBus: Ge, snapshotCache: qe, cache: Ye, semantic: Qe, evictSource: et, backend: at, stats: st, dispose: ct } = await Ze({
|
|
1474
1578
|
env: process.env,
|
|
1475
1579
|
semantic: v?.cacheSemantic ?? !1
|
|
1476
1580
|
});
|
|
1477
|
-
|
|
1478
|
-
if (W.runFork(
|
|
1581
|
+
Qe !== void 0 && $.info("semantic cache enabled — reactive eviction on live writes"), $.info(`cache backend resolved: ${at}` + (at === "redis" ? ` (driver ${process.env.CACHE_REDIS_DRIVER ?? "resp"})` : " — in-process, not cross-instance")), E.onChange((e) => {
|
|
1582
|
+
if (W.runFork(Ge.publish(e.table)), et !== void 0) {
|
|
1479
1583
|
let t = (e.new ?? e.old)?.id;
|
|
1480
|
-
|
|
1584
|
+
et({
|
|
1481
1585
|
table: e.table,
|
|
1482
1586
|
op: e.op,
|
|
1483
1587
|
...t === void 0 ? {} : { id: t }
|
|
1484
1588
|
});
|
|
1485
1589
|
}
|
|
1486
1590
|
}), v?.kv && !process.env.KV_BACKEND && (process.env.KV_BACKEND = v.kv), v?.kvRedisUrl && !process.env.KV_REDIS_URL && (process.env.KV_REDIS_URL = v.kvRedisUrl), v?.kvKeyPrefix && !process.env.KV_KEY_PREFIX && (process.env.KV_KEY_PREFIX = v.kvKeyPrefix);
|
|
1487
|
-
let { kv:
|
|
1591
|
+
let { kv: dt, service: ft } = await Nr({ store: E });
|
|
1488
1592
|
Pt({
|
|
1489
1593
|
log: $,
|
|
1490
1594
|
max: qt(),
|
|
@@ -1492,29 +1596,29 @@ var Vi = () => Math.max(500, Math.floor(ti() * .6)), Hi = (e) => new Promise((t)
|
|
|
1492
1596
|
readPools: t.replicationSnapshot()?.replicaCount ?? 0,
|
|
1493
1597
|
always: !0
|
|
1494
1598
|
}), d.mark("store");
|
|
1495
|
-
let
|
|
1599
|
+
let gt = dr({
|
|
1496
1600
|
store: E,
|
|
1497
1601
|
sink: ke.sink,
|
|
1498
1602
|
log: $
|
|
1499
|
-
}), xt =
|
|
1603
|
+
}), xt = Ke({
|
|
1500
1604
|
store: E,
|
|
1501
1605
|
dialect: y,
|
|
1502
1606
|
log: { info: (e) => $.info(e) }
|
|
1503
1607
|
}), j = v?.plugins ?? [], jt = process.env.POD_NAME ?? process.env.HOSTNAME ?? `serve-${process.pid}`, Rt, Bt;
|
|
1504
|
-
y !== "memory" && (Rt =
|
|
1608
|
+
y !== "memory" && (Rt = $n.make((await F(y)).makeSqlLayer(O())), Bt = await Rt.runPromise(er.SqlClient));
|
|
1505
1609
|
let Ut = [
|
|
1506
1610
|
"postgres",
|
|
1507
1611
|
"mariadb",
|
|
1508
1612
|
"mysql",
|
|
1509
1613
|
"mssql"
|
|
1510
|
-
].includes(y) ?
|
|
1614
|
+
].includes(y) ? kr(E, jt, $) : ii, _n = M(v?.scheduling), Sn = Fr({
|
|
1511
1615
|
maxIdleIntervalMs: _n.pollCeilingMs,
|
|
1512
1616
|
coordinator: Ut,
|
|
1513
1617
|
replicaId: jt,
|
|
1514
1618
|
log: $
|
|
1515
|
-
}), wn = [], Tn = process.env.POD_NAME ?? process.env.HOSTNAME ?? `serve-${process.pid}`, On =
|
|
1619
|
+
}), wn = [], Tn = process.env.POD_NAME ?? process.env.HOSTNAME ?? `serve-${process.pid}`, On = Fi(v?.plugins ?? [])?.broadcast?.provider, L = $e(v?.plugins, v?.name ?? En(g));
|
|
1516
1620
|
{
|
|
1517
|
-
let e =
|
|
1621
|
+
let e = tt(v?.plugins, v?.name ?? En(g));
|
|
1518
1622
|
e !== void 0 && $.warn(e);
|
|
1519
1623
|
}
|
|
1520
1624
|
let jn = Mt(v?.plugins, {
|
|
@@ -1527,16 +1631,16 @@ var Vi = () => Math.max(500, Math.floor(ti() * .6)), Hi = (e) => new Promise((t)
|
|
|
1527
1631
|
instanceId: Tn,
|
|
1528
1632
|
membership: jn.membership,
|
|
1529
1633
|
...On === void 0 ? {} : { broadcast: On },
|
|
1530
|
-
broadcastChannels: { presence:
|
|
1634
|
+
broadcastChannels: { presence: Pi(L, "presence") },
|
|
1531
1635
|
scheduleCoordinated: (e, t, n) => {
|
|
1532
1636
|
let r = Sn(e, t, n);
|
|
1533
1637
|
return wn.push(r), r;
|
|
1534
1638
|
}
|
|
1535
1639
|
};
|
|
1536
|
-
for (let e of j) e.bindDataStore?.(
|
|
1640
|
+
for (let e of j) e.bindDataStore?.(He, Mn);
|
|
1537
1641
|
l({
|
|
1538
1642
|
store: E,
|
|
1539
|
-
...
|
|
1643
|
+
...lt(),
|
|
1540
1644
|
log: $
|
|
1541
1645
|
});
|
|
1542
1646
|
let R = j.filter((e) => typeof e.onChangeEvent == "function");
|
|
@@ -1544,7 +1648,7 @@ var Vi = () => Math.max(500, Math.floor(ti() * .6)), Hi = (e) => new Promise((t)
|
|
|
1544
1648
|
let e = E.changeScope ?? "local";
|
|
1545
1649
|
E.onChange((t) => {
|
|
1546
1650
|
let n = ye(t, e);
|
|
1547
|
-
for (let e of R) W.runFork(e.onChangeEvent(n).pipe(W.catchAllCause((t) => W.sync(() => $.warn(`plugin ${e.name} onChangeEvent failed`, { error:
|
|
1651
|
+
for (let e of R) W.runFork(e.onChangeEvent(n).pipe(W.catchAllCause((t) => W.sync(() => $.warn(`plugin ${e.name} onChangeEvent failed`, { error: Qn.pretty(t) })))));
|
|
1548
1652
|
});
|
|
1549
1653
|
}
|
|
1550
1654
|
let Nn = Ne({
|
|
@@ -1561,19 +1665,19 @@ var Vi = () => Math.max(500, Math.floor(ti() * .6)), Hi = (e) => new Promise((t)
|
|
|
1561
1665
|
debug: () => {}
|
|
1562
1666
|
}, z, In = await A(E, v, y, L, Fn, (e, t) => {
|
|
1563
1667
|
z?.refreshAll(`broadcast gap: missed ${t} change(s) from ${e}`);
|
|
1564
|
-
}), Ln = v?.apiKeys, Rn = (typeof Ln == "object" ? Ln.prefix : void 0) ?? "voltro_", B = Ln ?
|
|
1565
|
-
V &&
|
|
1566
|
-
let zn = B ?
|
|
1668
|
+
}), Ln = v?.apiKeys, Rn = (typeof Ln == "object" ? Ln.prefix : void 0) ?? "voltro_", B = Ln ? xr(E) : void 0, V = B ? jr({ flush: Mr(B) }) : void 0;
|
|
1669
|
+
V && Yr(() => V.shutdown());
|
|
1670
|
+
let zn = B ? Ar(B, {
|
|
1567
1671
|
prefix: Rn,
|
|
1568
1672
|
...V ? { usage: V } : {}
|
|
1569
|
-
}) : void 0, Bn = zn ? [
|
|
1673
|
+
}) : void 0, Bn = zn ? [wr(zn, { prefix: Rn })] : [], Vn = St([...v?.auth?.strategies ?? [], ...Bn], Mi(v?.plugins ?? []), v?.auth?.anonymousTenantRequired ?? !1, v?.auth, () => He), Hn = [...v?.restRoutes ?? [], ...zn ? ur(zn, (typeof Ln == "object" ? Ln.managementPath : void 0) ?? "/v1/api-keys") : []], Un = Ct(v?.idempotency, E), Wn = j.map((e) => e.services).filter((e) => e !== void 0), Gn = G.mergeAll(_t({
|
|
1570
1674
|
analyticsLayer: ke.layer,
|
|
1571
|
-
cacheService:
|
|
1572
|
-
kvService:
|
|
1573
|
-
...
|
|
1675
|
+
cacheService: We,
|
|
1676
|
+
kvService: ft,
|
|
1677
|
+
...Qe === void 0 ? {} : { semanticCache: Qe },
|
|
1574
1678
|
pluginServices: Wn,
|
|
1575
1679
|
userLayers: v?.layers ?? []
|
|
1576
|
-
}),
|
|
1680
|
+
}), Re(v?.http ?? {})), H = await ze({
|
|
1577
1681
|
files: b,
|
|
1578
1682
|
store: E,
|
|
1579
1683
|
log: $,
|
|
@@ -1585,19 +1689,19 @@ var Vi = () => Math.max(500, Math.floor(ti() * .6)), Hi = (e) => new Promise((t)
|
|
|
1585
1689
|
runStartups: o,
|
|
1586
1690
|
emailPattern: k,
|
|
1587
1691
|
loadEmailFiles: Tt,
|
|
1588
|
-
registerEmailTemplates:
|
|
1692
|
+
registerEmailTemplates: Ni
|
|
1589
1693
|
});
|
|
1590
1694
|
(H.startupCount > 0 || H.emailCount > 0) && $.info("boot lifecycle", {
|
|
1591
1695
|
startups: H.startupCount,
|
|
1592
1696
|
emailTemplates: H.emailCount
|
|
1593
|
-
}), H.startups !== void 0 &&
|
|
1697
|
+
}), H.startups !== void 0 && Yr(async () => {
|
|
1594
1698
|
await H.startups.stop();
|
|
1595
1699
|
}), de({
|
|
1596
1700
|
demands: Se(ue),
|
|
1597
|
-
isRegistered: (e) =>
|
|
1701
|
+
isRegistered: (e) => Tr(e) !== void 0
|
|
1598
1702
|
});
|
|
1599
|
-
let
|
|
1600
|
-
schedules:
|
|
1703
|
+
let qn = wt({
|
|
1704
|
+
schedules: ot({
|
|
1601
1705
|
schedules: x.schedules,
|
|
1602
1706
|
seeds: H.seeds,
|
|
1603
1707
|
store: E,
|
|
@@ -1605,27 +1709,27 @@ var Vi = () => Math.max(500, Math.floor(ti() * .6)), Hi = (e) => new Promise((t)
|
|
|
1605
1709
|
}),
|
|
1606
1710
|
workflows: x.workflows ?? [],
|
|
1607
1711
|
log: $.child("workflow-schedules")
|
|
1608
|
-
}), Yn = v?.scheduling ?? {},
|
|
1712
|
+
}), Yn = v?.scheduling ?? {}, U = Yn.trigger ?? "self", Zn = /* @__PURE__ */ new Set([
|
|
1609
1713
|
"postgres",
|
|
1610
1714
|
"mysql",
|
|
1611
1715
|
"mariadb",
|
|
1612
1716
|
"mssql"
|
|
1613
|
-
]), ar = Yn.coordination ?? (
|
|
1614
|
-
ar === "cluster" && !
|
|
1615
|
-
let
|
|
1616
|
-
if (
|
|
1717
|
+
]), ar = Yn.coordination ?? (Zn.has(y) ? "advisoryLock" : "single"), K = ar === "cluster" && Zn.has(y), or = K ? "cluster" : ar === "advisoryLock" && Zn.has(y) ? "advisoryLock" : "single";
|
|
1718
|
+
ar === "cluster" && !K && $.warn("scheduling.coordination=cluster needs a sql-backed store except sqlite — falling back to single"), ar === "advisoryLock" && !Zn.has(y) && $.warn("scheduling.coordination=advisoryLock needs a SQL store (the claim-row gate) — falling back to single");
|
|
1719
|
+
let sr, cr = x.workflows.length > 0 || x.workflowWorkers.length > 0 || x.eventTriggers.length > 0 || (be?.outgoing.length ?? 0) > 0 || K, lr;
|
|
1720
|
+
if (cr) {
|
|
1617
1721
|
if (y === "mssql") {
|
|
1618
1722
|
let e = await hn(process.cwd());
|
|
1619
1723
|
e && $.warn(e);
|
|
1620
1724
|
}
|
|
1621
|
-
let [{ WorkflowEngine: e }, { makeClusterCronLayer: t, workflowEngineLayer: n, resolveRunnerStorage: r, resolveFailoverTuning: i }] = await Promise.all([import("@effect/workflow"), import("@voltro/workflow/cluster")]), a =
|
|
1725
|
+
let [{ WorkflowEngine: e }, { makeClusterCronLayer: t, workflowEngineLayer: n, resolveRunnerStorage: r, resolveFailoverTuning: i }] = await Promise.all([import("@effect/workflow"), import("@voltro/workflow/cluster")]), a = K ? qn.filter((e) => (e.trigger ?? U) === "self").map((e) => t({
|
|
1622
1726
|
name: e.name,
|
|
1623
|
-
cron:
|
|
1727
|
+
cron: br(e),
|
|
1624
1728
|
execute: async () => {
|
|
1625
|
-
await
|
|
1729
|
+
await sr?.fireFromCluster(e.name);
|
|
1626
1730
|
}
|
|
1627
1731
|
})) : [];
|
|
1628
|
-
|
|
1732
|
+
lr = y === "memory" ? e.layerMemory : await (async () => {
|
|
1629
1733
|
let e = await F(y), t = r({ sqliteFamily: e.id === "sqlite" || e.id === "turso" });
|
|
1630
1734
|
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({
|
|
1631
1735
|
sqlClientLayer: e.makeSqlLayer(O()),
|
|
@@ -1637,23 +1741,23 @@ var Vi = () => Math.max(500, Math.floor(ti() * .6)), Hi = (e) => new Promise((t)
|
|
|
1637
1741
|
});
|
|
1638
1742
|
})();
|
|
1639
1743
|
}
|
|
1640
|
-
let
|
|
1744
|
+
let fr = bt(j, bn()), pr = b.filter((e) => /\.subscribe\.tsx?$/.test(e)), mr = pr.length > 0 ? await c(pr, $) : [], hr = b.filter((e) => /\.reaction\.tsx?$/.test(e)), q = hr.length > 0 ? await he(hr, $) : [], gr = b.filter((e) => un.test(e)), _r = gr.length > 0 ? await Me(gr, $) : [], vr = b.filter((e) => /\.aggregate\.tsx?$/.test(e)), yr = vr.length > 0 ? await _e(vr, $) : [];
|
|
1641
1745
|
{
|
|
1642
|
-
let e =
|
|
1746
|
+
let e = Cr(li(Ve({ aggregates: yr.map((e) => e.definition) }), Lt(T)));
|
|
1643
1747
|
e !== void 0 && $.warn(e);
|
|
1644
1748
|
}
|
|
1645
|
-
let Er =
|
|
1646
|
-
if (
|
|
1749
|
+
let Er = ut();
|
|
1750
|
+
if (yr.length > 0 && y !== "memory") try {
|
|
1647
1751
|
let e = (await F(y)).makeSqlLayer(O());
|
|
1648
1752
|
Er = u(e);
|
|
1649
1753
|
} catch (e) {
|
|
1650
1754
|
$.warn("aggregate: SQL storage init failed — falling back to in-process", { err: String(e) });
|
|
1651
1755
|
}
|
|
1652
|
-
let
|
|
1756
|
+
let Dr = y === "memory" ? ii : kr(E, `aggregate@${process.pid}`, $), Or = b.filter((e) => dn.test(e)), Pr = Or.length > 0 ? await Ft(Or, $) : [], Ir = b.filter((e) => ln.test(e)), Lr = Ir.length > 0 ? await m(Ir, $) : [], Rr = b.filter((e) => cn.test(e)), zr = Rr.length > 0 ? await w(Rr, $) : [], Br = [], Vr = [], Hr = b.filter((e) => Zt.test(e));
|
|
1653
1757
|
if (Hr.length > 0) {
|
|
1654
1758
|
let e = $.child("agent"), t = b.filter((e) => en.test(e));
|
|
1655
|
-
t.length > 0 && await
|
|
1656
|
-
let n = await
|
|
1759
|
+
t.length > 0 && await Qt(t, e);
|
|
1760
|
+
let n = await $t(Hr, e);
|
|
1657
1761
|
for (let e of n.agents) for (let t of Ot(e)) (t.kind === "action" ? Br : Vr).push({
|
|
1658
1762
|
file: t.file,
|
|
1659
1763
|
descriptor: t.descriptor,
|
|
@@ -1666,14 +1770,14 @@ var Vi = () => Math.max(500, Math.floor(ti() * .6)), Hi = (e) => new Promise((t)
|
|
|
1666
1770
|
let e = Y.workflowWriteActions();
|
|
1667
1771
|
if (e === void 0) throw Error("workflow actions: this app registers no workflows");
|
|
1668
1772
|
return e;
|
|
1669
|
-
},
|
|
1773
|
+
}, Ur = Jn({
|
|
1670
1774
|
dialect: y,
|
|
1671
1775
|
...O()
|
|
1672
|
-
}), Gr = y === "memory" ? void 0 : (await F(y)).makeSqlLayer(O()), Kr = async () =>
|
|
1776
|
+
}), Gr = y === "memory" ? void 0 : (await F(y)).makeSqlLayer(O()), Kr = async () => D({
|
|
1673
1777
|
sqlLayer: Gr,
|
|
1674
1778
|
declared: T,
|
|
1675
1779
|
log: $
|
|
1676
|
-
}),
|
|
1780
|
+
}), qr = {
|
|
1677
1781
|
kind: "api",
|
|
1678
1782
|
meta: {
|
|
1679
1783
|
name: v?.name ?? "voltro-api",
|
|
@@ -1682,7 +1786,7 @@ var Vi = () => Math.max(500, Math.floor(ti() * .6)), Hi = (e) => new Promise((t)
|
|
|
1682
1786
|
mode: "start",
|
|
1683
1787
|
store: y,
|
|
1684
1788
|
cdc: se ? "on" : "off",
|
|
1685
|
-
...
|
|
1789
|
+
...Ur === void 0 ? {} : { databaseId: Ur }
|
|
1686
1790
|
},
|
|
1687
1791
|
rpc: Ie(x, g),
|
|
1688
1792
|
workflows: Nt(x, g),
|
|
@@ -1698,12 +1802,12 @@ var Vi = () => Math.max(500, Math.floor(ti() * .6)), Hi = (e) => new Promise((t)
|
|
|
1698
1802
|
}),
|
|
1699
1803
|
members: () => Y.membersSnapshot(),
|
|
1700
1804
|
inspectFireSchedule: async ({ name: e, trigger: t }) => {
|
|
1701
|
-
if (!
|
|
1702
|
-
return { runId: await
|
|
1805
|
+
if (!sr) throw Error("scheduler not started — this app registers no self-triggered schedules (all schedules are trigger:'external', or there are none).");
|
|
1806
|
+
return { runId: await sr.fireNow(e, t) ?? null };
|
|
1703
1807
|
},
|
|
1704
1808
|
inspectBackfillSchedule: _({
|
|
1705
|
-
getHandle: () =>
|
|
1706
|
-
getSchedules: () =>
|
|
1809
|
+
getHandle: () => sr,
|
|
1810
|
+
getSchedules: () => qn
|
|
1707
1811
|
}),
|
|
1708
1812
|
...be === void 0 ? {} : { webhooks: () => ge({
|
|
1709
1813
|
store: E,
|
|
@@ -1714,12 +1818,12 @@ var Vi = () => Math.max(500, Math.floor(ti() * .6)), Hi = (e) => new Promise((t)
|
|
|
1714
1818
|
capturedAt: Date.now()
|
|
1715
1819
|
}),
|
|
1716
1820
|
env: () => Gt(v?.name ?? En(g), {
|
|
1717
|
-
...v?.env !== void 0 &&
|
|
1821
|
+
...v?.env !== void 0 && Si(v.env) ? { contract: v.env } : {},
|
|
1718
1822
|
plugins: v?.plugins ?? []
|
|
1719
1823
|
}),
|
|
1720
|
-
dataCache: () =>
|
|
1721
|
-
stats:
|
|
1722
|
-
backendKind:
|
|
1824
|
+
dataCache: () => Be({
|
|
1825
|
+
stats: st,
|
|
1826
|
+
backendKind: at
|
|
1723
1827
|
}),
|
|
1724
1828
|
subscriptions: () => It(() => z),
|
|
1725
1829
|
inspectTables: () => S(x.tables),
|
|
@@ -1732,17 +1836,17 @@ var Vi = () => Math.max(500, Math.floor(ti() * .6)), Hi = (e) => new Promise((t)
|
|
|
1732
1836
|
cluster: () => zt({
|
|
1733
1837
|
store: E,
|
|
1734
1838
|
dialect: y,
|
|
1735
|
-
useClusterCron:
|
|
1839
|
+
useClusterCron: K,
|
|
1736
1840
|
scheduleCoordChoice: ar
|
|
1737
1841
|
}),
|
|
1738
1842
|
inspectSchedules: () => Te({
|
|
1739
|
-
schedules:
|
|
1740
|
-
defaultTrigger:
|
|
1741
|
-
coordination:
|
|
1843
|
+
schedules: qn,
|
|
1844
|
+
defaultTrigger: U,
|
|
1845
|
+
coordination: or
|
|
1742
1846
|
}),
|
|
1743
1847
|
inspectScheduleRuns: (e) => N(E, e),
|
|
1744
1848
|
...f(E, {
|
|
1745
|
-
controls:
|
|
1849
|
+
controls: rt(x.workflows ?? []),
|
|
1746
1850
|
active: (x.workflows?.length ?? 0) > 0,
|
|
1747
1851
|
cancellation: () => Y.flowControlHealth()
|
|
1748
1852
|
}),
|
|
@@ -1760,7 +1864,7 @@ var Vi = () => Math.max(500, Math.floor(ti() * .6)), Hi = (e) => new Promise((t)
|
|
|
1760
1864
|
active: (x.workflows?.length ?? 0) > 0,
|
|
1761
1865
|
dispatcher: () => Y.inferenceHealth()
|
|
1762
1866
|
}, e.limit === void 0 ? {} : { limit: e.limit }),
|
|
1763
|
-
...
|
|
1867
|
+
...ht({
|
|
1764
1868
|
store: E,
|
|
1765
1869
|
cancelRun: async (e) => await Y.runCanceller()?.(e) ?? !1,
|
|
1766
1870
|
retryRun: async (e) => J().inspectRetryWorkflowRun({ runId: e }),
|
|
@@ -1769,7 +1873,7 @@ var Vi = () => Math.max(500, Math.floor(ti() * .6)), Hi = (e) => new Promise((t)
|
|
|
1769
1873
|
}),
|
|
1770
1874
|
inspectRedriveWorkflowRun: (e) => Y.redriveWorkflowRun(e),
|
|
1771
1875
|
inspectResumeWorkflowRunFromStep: (e) => Y.resumeWorkflowRunFromStep(e)
|
|
1772
|
-
},
|
|
1876
|
+
}, Jr = (process.env.VOLTRO_TENANT_ISOLATION ?? v?.tenancy?.isolation) === "namespace", Xr = Jr && y !== "memory" ? await (async () => {
|
|
1773
1877
|
let e = await F(y);
|
|
1774
1878
|
return At({
|
|
1775
1879
|
tables: T,
|
|
@@ -1781,19 +1885,19 @@ var Vi = () => Math.max(500, Math.floor(ti() * .6)), Hi = (e) => new Promise((t)
|
|
|
1781
1885
|
error: (e, t, n) => $.error(e, t ?? {}, n)
|
|
1782
1886
|
}
|
|
1783
1887
|
});
|
|
1784
|
-
})() : void 0, Zr = await
|
|
1888
|
+
})() : void 0, Zr = await pt({
|
|
1785
1889
|
input: v?.tenancy?.residency,
|
|
1786
|
-
namespaceIsolationOn:
|
|
1787
|
-
makeStoreForUrl: (e, t) =>
|
|
1890
|
+
namespaceIsolationOn: Jr,
|
|
1891
|
+
makeStoreForUrl: (e, t) => it(v, void 0, Kt(O(), t)),
|
|
1788
1892
|
log: {
|
|
1789
1893
|
info: (e, t) => $.info(e, t),
|
|
1790
1894
|
warn: (e, t) => $.warn(e, t)
|
|
1791
1895
|
}
|
|
1792
1896
|
});
|
|
1793
|
-
Zr !== void 0 &&
|
|
1897
|
+
Zr !== void 0 && Yr(async () => {
|
|
1794
1898
|
await Zr.close();
|
|
1795
1899
|
});
|
|
1796
|
-
let Y = await
|
|
1900
|
+
let Y = await Ea({
|
|
1797
1901
|
bootTiming: d,
|
|
1798
1902
|
broadcastNamespace: L,
|
|
1799
1903
|
scheduling: (() => {
|
|
@@ -1803,7 +1907,7 @@ var Vi = () => Math.max(500, Math.floor(ti() * .6)), Hi = (e) => new Promise((t)
|
|
|
1803
1907
|
inferenceTickMs: e.inferenceTickMs,
|
|
1804
1908
|
cancelSweepMs: e.cancelSweepMs,
|
|
1805
1909
|
stalenessSweepMs: e.stalenessSweepMs,
|
|
1806
|
-
disarmWhenIdle:
|
|
1910
|
+
disarmWhenIdle: Le({
|
|
1807
1911
|
changeScope: E.changeScope,
|
|
1808
1912
|
broadcastAttached: In !== void 0
|
|
1809
1913
|
})
|
|
@@ -1834,13 +1938,13 @@ var Vi = () => Math.max(500, Math.floor(ti() * .6)), Hi = (e) => new Promise((t)
|
|
|
1834
1938
|
workflows: x.workflows,
|
|
1835
1939
|
workflowWorkers: x.workflowWorkers,
|
|
1836
1940
|
eventTriggers: x.eventTriggers,
|
|
1837
|
-
schedules:
|
|
1838
|
-
subscribers:
|
|
1941
|
+
schedules: qn,
|
|
1942
|
+
subscribers: mr,
|
|
1839
1943
|
outboxHandlers: _r,
|
|
1840
1944
|
connections: x.connections,
|
|
1841
1945
|
reactions: q,
|
|
1842
|
-
aggregates:
|
|
1843
|
-
expectations:
|
|
1946
|
+
aggregates: yr,
|
|
1947
|
+
expectations: Pr,
|
|
1844
1948
|
budgets: Lr,
|
|
1845
1949
|
experiments: zr,
|
|
1846
1950
|
...be === void 0 ? {} : { webhooks: be }
|
|
@@ -1848,16 +1952,16 @@ var Vi = () => Math.max(500, Math.floor(ti() * .6)), Hi = (e) => new Promise((t)
|
|
|
1848
1952
|
log: $,
|
|
1849
1953
|
analytics: ke.sink,
|
|
1850
1954
|
aggregateStorage: Er,
|
|
1851
|
-
aggregateCoordinator:
|
|
1955
|
+
aggregateCoordinator: Dr,
|
|
1852
1956
|
store: E,
|
|
1853
|
-
kv:
|
|
1854
|
-
cache:
|
|
1855
|
-
snapshotCache:
|
|
1957
|
+
kv: dt,
|
|
1958
|
+
cache: Ye,
|
|
1959
|
+
snapshotCache: qe,
|
|
1856
1960
|
...v?.reactive === void 0 ? {} : { reactive: v.reactive },
|
|
1857
1961
|
schemaRegistry: Fe,
|
|
1858
1962
|
tenantScopedTables: x.tenantScopedTables,
|
|
1859
1963
|
softDeleteScopedTables: x.softDeleteScopedTables,
|
|
1860
|
-
dataTransferSnapshot:
|
|
1964
|
+
dataTransferSnapshot: tr(T, y),
|
|
1861
1965
|
dataTransferDialect: y,
|
|
1862
1966
|
...Xr === void 0 ? {} : { ensureTenantProvisioned: Xr.ensure },
|
|
1863
1967
|
...Zr === void 0 ? {} : { resolveResidentStore: Zr.resolveStore },
|
|
@@ -1869,22 +1973,22 @@ var Vi = () => Math.max(500, Math.floor(ti() * .6)), Hi = (e) => new Promise((t)
|
|
|
1869
1973
|
...v?.auth === void 0 ? {} : { authority: v.auth },
|
|
1870
1974
|
...v?.agents === void 0 ? {} : { agents: v.agents },
|
|
1871
1975
|
httpRoutes: j.flatMap((e) => e.httpRoutes ?? []),
|
|
1872
|
-
getStore: () =>
|
|
1976
|
+
getStore: () => He,
|
|
1873
1977
|
...Gn ? { baseLayer: Gn } : {},
|
|
1874
|
-
...
|
|
1875
|
-
scheduleDefaultTrigger:
|
|
1876
|
-
scheduleCoordination:
|
|
1877
|
-
scheduleArmSelf: !
|
|
1978
|
+
...lr === void 0 ? {} : { workflowEngineLayer: lr },
|
|
1979
|
+
scheduleDefaultTrigger: U,
|
|
1980
|
+
scheduleCoordination: or,
|
|
1981
|
+
scheduleArmSelf: !K,
|
|
1878
1982
|
dormancy: process.env.VOLTRO_DORMANCY === "sleep" || process.env.VOLTRO_DORMANCY === "always-on" ? process.env.VOLTRO_DORMANCY : v?.dormancy ?? "always-on",
|
|
1879
1983
|
scheduleReplicaId: process.env.HOSTNAME ?? `pid-${process.pid}`,
|
|
1880
|
-
...
|
|
1984
|
+
...fr === void 0 ? {} : { scheduleFireInterceptor: fr },
|
|
1881
1985
|
onSchedulerReady: (e) => {
|
|
1882
|
-
|
|
1986
|
+
sr = e;
|
|
1883
1987
|
},
|
|
1884
|
-
inspectRoute: { handle: async (e, t, n, r) => await h(e,
|
|
1988
|
+
inspectRoute: { handle: async (e, t, n, r) => await h(e, qr, t, {
|
|
1885
1989
|
method: n,
|
|
1886
1990
|
...r === void 0 ? {} : { body: r }
|
|
1887
|
-
}) || ((n === "GET" ? await mn(e,
|
|
1991
|
+
}) || ((n === "GET" ? await mn(e, qr, t, { method: n }) : null) ?? pn(e, qr, t, {
|
|
1888
1992
|
method: n,
|
|
1889
1993
|
...r === void 0 ? {} : { body: r }
|
|
1890
1994
|
}) ?? {
|
|
@@ -1912,14 +2016,14 @@ var Vi = () => Math.max(500, Math.floor(ti() * .6)), Hi = (e) => new Promise((t)
|
|
|
1912
2016
|
streams: x.streams.length,
|
|
1913
2017
|
workflows: x.workflows.length,
|
|
1914
2018
|
workflowWorkers: x.workflowWorkers.length,
|
|
1915
|
-
schedules:
|
|
1916
|
-
scheduleCoordination:
|
|
1917
|
-
}), d.finish($),
|
|
2019
|
+
schedules: qn.length,
|
|
2020
|
+
scheduleCoordination: or
|
|
2021
|
+
}), d.finish($), Yr(async () => {
|
|
1918
2022
|
for (let e of wn) e.stop();
|
|
1919
2023
|
xt.stop();
|
|
1920
2024
|
try {
|
|
1921
|
-
await Y.close(),
|
|
1922
|
-
mirror:
|
|
2025
|
+
await Y.close(), ct(), Rt?.dispose(), await Nn.deactivate(), await In?.close(), await Dt({
|
|
2026
|
+
mirror: gt,
|
|
1923
2027
|
log: $
|
|
1924
2028
|
}), await ke.dispose(), await E.close?.();
|
|
1925
2029
|
} catch (e) {
|
|
@@ -1928,4 +2032,4 @@ var Vi = () => Math.max(500, Math.floor(ti() * .6)), Hi = (e) => new Promise((t)
|
|
|
1928
2032
|
}), await new Promise(() => {}), 0;
|
|
1929
2033
|
};
|
|
1930
2034
|
//#endregion
|
|
1931
|
-
export {
|
|
2035
|
+
export { ka as n, Da as r, Aa as t };
|