@voltro/cli 0.35.0 → 0.36.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 +68 -0
- package/dist/{apiBuild-DYD_ONLD.js → apiBuild-DiE9zcj6.js} +1 -1
- package/dist/apiBuild-ZEZnCXn2.js +2 -0
- package/dist/bin.js +1 -1
- package/dist/{build-CD8K4XOr.js → build-DBe6c7qC.js} +6 -6
- package/dist/{checkCommand-DKpDLlqu.js → checkCommand-BTA6P3Yr.js} +1 -1
- package/dist/{checkCommand-Ct9xkTrS.js → checkCommand-BhG0gmUD.js} +2 -2
- package/dist/{codegenCommand-C4YoQIc2.js → codegenCommand-DH-8ZXzR.js} +1 -1
- package/dist/{codemodRunner-BnFq3Fgu.js → codemodRunner-DjQGrdmg.js} +64 -47
- package/dist/{commands-BE8E7zF3.js → commands-Bp7utV-7.js} +18 -18
- package/dist/{dashboardCommand-D7SgZGaN.js → dashboardCommand-D5Jwjmr1.js} +1 -1
- package/dist/{dataCommand-BhYwDgg-.js → dataCommand-DnCm0B2C.js} +1 -1
- package/dist/{dev-D2BikO7a.js → dev-BSFTgCQ5.js} +1 -1
- package/dist/{dev-C7sFZq3m.js → dev-Dc4cpmRl.js} +2000 -2000
- package/dist/doctorCommand-BYffQc0s.js +2 -0
- package/dist/{doctorCommand-DnimF5IM.js → doctorCommand-CNFtt3nR.js} +9 -9
- package/dist/{dormancyCommand-QewYug_s.js → dormancyCommand-6F6NsJKf.js} +1 -1
- package/dist/{embeddingsCommand-BfiLS_QI.js → embeddingsCommand-DRRdneJD.js} +1 -1
- package/dist/{envCommand-CCGPRQY1.js → envCommand-TZzcyqZ-.js} +1 -1
- package/dist/{evolveCommand-CHsLCtDf.js → evolveCommand-iU35TPjT.js} +2 -2
- package/dist/index.js +1 -1
- package/dist/{infoCommand-DwOgK1t6.js → infoCommand-unqisJGp.js} +1 -1
- package/dist/{runtimeTrace-CH3eUiMw.js → runtimeTrace-D5LJ_N55.js} +1 -1
- package/dist/{sdkgen-BLkvGRfX.js → sdkgen-82xVuvbt.js} +1 -1
- package/dist/serveCommand-CEBVP36A.js +2 -0
- package/dist/{serveCommand-iwlUBNS1.js → serveCommand-VVGcIMIw.js} +487 -487
- package/dist/serveEntry.js +1 -1
- package/dist/updateCommand-CSBXVsYq.js +2 -0
- package/dist/{updateCommand-x0pI_x-B.js → updateCommand-CwnUK_mf.js} +1 -1
- package/dist/{webhooksCommand-DlAgS2Iw.js → webhooksCommand-di1CJVzu.js} +1 -1
- package/package.json +23 -17
- package/templates/AGENTS.md +1 -1
- package/templates/agent-docs/_index.md +1 -1
- package/templates/agent-docs/cli.md +22 -0
- package/templates/agent-docs/database/misc.md +33 -0
- package/templates/agent-docs/whats-new.md +31 -130
- 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 +3 -3
- package/dist/apiBuild-B8aoJvuw.js +0 -2
- package/dist/doctorCommand-CM4Ch9C7.js +0 -2
- package/dist/serveCommand-CbDHU6l-.js +0 -2
- package/dist/updateCommand-BlMZhWgO.js +0 -2
|
@@ -2,54 +2,54 @@ import { t as e } from "./nodeEnvironment-cGFAj1J8.js";
|
|
|
2
2
|
import { t } from "./frameworkInspectState-CX2250XB.js";
|
|
3
3
|
import { r as n, t as r } from "./appModuleLoader-C9r9mxZt.js";
|
|
4
4
|
import { n as i, t as a } from "./startupRunner-DPGFchOa.js";
|
|
5
|
-
import { $ as o, $t as s, A as c, At as l, B as u, C as d, Ct as ee, D as f, Dt as p, E as te, Et as ne, F as re, Ft as m, G as ie, Gt as ae, H as oe, Ht as se, I as h, It as ce, J as le, Jt as g, K as ue, Kt as de, L as fe, Lt as pe, M as me, Mt as he, N as ge, Nt as _e, O as _, Ot as ve, P as ye, Pt as be, Q as xe, Qt as Se, R as Ce, S as we, St as Te, T as v, Tt as Ee, U as De, Ut as Oe, V as ke, Vt as Ae, W as je, Wt as y, X as Me, Xt as Ne, Y as Pe, Yt as Fe, Z as b, Zt as Ie, _ as Le, _n as x, _t as Re, an as ze, at as Be, b as Ve, bt as He, c as Ue, cn as We, ct as Ge, dn as S, dt as Ke, en as qe, et as
|
|
6
|
-
import { n as
|
|
7
|
-
import { r as
|
|
8
|
-
import { at as
|
|
9
|
-
import { r as
|
|
10
|
-
import { i as
|
|
11
|
-
import { c as
|
|
12
|
-
import { C as
|
|
13
|
-
import { S as
|
|
14
|
-
import { h as
|
|
15
|
-
import { n as
|
|
16
|
-
import { i as
|
|
17
|
-
import { t as
|
|
18
|
-
import { r as
|
|
19
|
-
import { t as
|
|
20
|
-
import { t as
|
|
21
|
-
import { basename as
|
|
22
|
-
import { existsSync as
|
|
23
|
-
import { pathToFileURL as
|
|
24
|
-
import { createLogger as
|
|
25
|
-
import { AuthMiddleware as
|
|
26
|
-
import { Cause as
|
|
27
|
-
import { SqlClient as
|
|
28
|
-
import { declaredSnapshot as
|
|
29
|
-
import { RpcGroup as
|
|
30
|
-
import { allRegisteredTables as
|
|
31
|
-
import { AggregateRegistry as
|
|
32
|
-
import { appStorageProvider as
|
|
33
|
-
import { isEnvContract as
|
|
34
|
-
import { assertProductionSessionSecret as
|
|
35
|
-
import { createHash as
|
|
36
|
-
import { buildDeliverWebhookExecute as
|
|
37
|
-
import { getAuthSessionStrategy as
|
|
38
|
-
import { registerEmailTemplates as
|
|
39
|
-
import { channelFor as
|
|
40
|
-
import { packBundle as
|
|
5
|
+
import { $ as o, $t as s, A as c, At as l, B as u, C as d, Ct as ee, D as f, Dt as p, E as te, Et as ne, F as re, Ft as m, G as ie, Gt as ae, H as oe, Ht as se, I as h, It as ce, J as le, Jt as g, K as ue, Kt as de, L as fe, Lt as pe, M as me, Mt as he, N as ge, Nt as _e, O as _, Ot as ve, P as ye, Pt as be, Q as xe, Qt as Se, R as Ce, S as we, St as Te, T as v, Tt as Ee, U as De, Ut as Oe, V as ke, Vt as Ae, W as je, Wt as y, X as Me, Xt as Ne, Y as Pe, Yt as Fe, Z as b, Zt as Ie, _ as Le, _n as x, _t as Re, an as ze, at as Be, b as Ve, bt as He, c as Ue, cn as We, ct as Ge, dn as S, dt as Ke, en as qe, et as Je, f as Ye, fn as Xe, ft as Ze, g as Qe, gn as $e, gt as et, h as tt, hn as nt, ht as rt, i as C, in as it, it as at, j as ot, jt as st, k as ct, kt as lt, ln as ut, lt as dt, m as ft, mn as pt, mt, nn as ht, nt as gt, o as w, on as _t, ot as T, p as vt, pt as yt, q as bt, qt as E, r as D, rn as xt, rt as St, sn as Ct, st as wt, t as Tt, tn as O, tt as Et, u as Dt, un as Ot, ut as kt, v as At, vn as jt, vt as Mt, w as Nt, wt as Pt, x as Ft, xt as It, y as k, yt as Lt, zt as A } from "./dev-Dc4cpmRl.js";
|
|
6
|
+
import { n as Rt } from "./cliArgs-D4p8n7EE.js";
|
|
7
|
+
import { r as zt } from "./appPort-B_HpJ_ck.js";
|
|
8
|
+
import { at as Bt, nt as Vt, st as Ht } from "./webDev-Dybxew86.js";
|
|
9
|
+
import { r as j } from "./dialectDriver-CgXnDfec.js";
|
|
10
|
+
import { i as Ut, n as Wt } from "./connectionConfig-UFlIEiys.js";
|
|
11
|
+
import { c as M, n as Gt, o as Kt } from "./seedRunner-ZmLSqNe2.js";
|
|
12
|
+
import { C as qt, S as Jt, _ as Yt, d as Xt, g as N, l as Zt, m as Qt, r as $t, u as en, v as tn } from "./frameworkTableAssembly-oMPBKqlE.js";
|
|
13
|
+
import { S as nn, c as rn, n as an, p as on, s as sn, x as cn } from "./fileConventions-Cof68_BL.js";
|
|
14
|
+
import { h as ln, o as un } from "./inspect-CjTYzAs_.js";
|
|
15
|
+
import { n as dn } from "./mssqlClusterPatch-_4cE_nun.js";
|
|
16
|
+
import { i as fn, n as pn, r as mn, t as hn } from "./webhookDiscovery-D7VaeMlz.js";
|
|
17
|
+
import { t as gn } from "./inspectMetrics-CfdKLh6t.js";
|
|
18
|
+
import { r as _n, u as vn } from "./apiBuild-DiE9zcj6.js";
|
|
19
|
+
import { t as yn } from "./bootTiming-BdyP9nYw.js";
|
|
20
|
+
import { t as bn } from "./dataProfile-dW-PsfLB.js";
|
|
21
|
+
import { basename as xn, join as Sn } from "node:path";
|
|
22
|
+
import { existsSync as Cn } from "node:fs";
|
|
23
|
+
import { pathToFileURL as wn } from "node:url";
|
|
24
|
+
import { createLogger as P } from "@voltro/logger";
|
|
25
|
+
import { AuthMiddleware as Tn, ConnectionInfoMiddleware as En, actionToRpc as F, anonymousSubject as Dn, isWireReachable as On, mutationToRpc as I, queryToRpc as L, streamToRpc as kn, workflowCancelDescriptor as An, workflowDomainEventsQueryDescriptor as jn, workflowEventDeliveriesQueryDescriptor as R, workflowResumeDescriptor as Mn, workflowRunEventsQueryDescriptor as z, workflowRunQueryDescriptor as B, workflowRunStepsQueryDescriptor as V, workflowRunsQueryDescriptor as Nn, workflowSignalDescriptor as Pn, workflowUpdateDescriptor as Fn } from "@voltro/protocol";
|
|
26
|
+
import { Cause as In, Effect as H, Layer as U, ManagedRuntime as Ln } from "effect";
|
|
27
|
+
import { SqlClient as Rn } from "@effect/sql";
|
|
28
|
+
import { declaredSnapshot as zn, describeOutcome as Bn, pendingFileMigrationIds as Vn, runPlannedMigrations as Hn } from "@voltro/database/sql";
|
|
29
|
+
import { RpcGroup as Un } from "@effect/rpc";
|
|
30
|
+
import { allRegisteredTables as Wn, and as Gn, connectionIdentity as Kn, ensureTableRegistered as qn, eq as W, or as G } from "@voltro/database";
|
|
31
|
+
import { AggregateRegistry as Jn, CostRegistry as Yn, DORMANCY_WAKEUP_TENANT as Xn, Dispatcher as Zn, ExpectationRegistry as K, ExperimentRegistry as q, apiKeyManagementRoutes as Qn, attachAnalyticsMirror as $n, attachExpectations as er, attachExperiments as tr, attachFinops as nr, awaitServerListening as rr, bindMutation as J, bindStream as ir, bindSubscription as Y, buildTracingLayer as ar, cancelWakeup as or, compileCron as sr, dataStoreApiKeyStore as cr, formatServerOnlyLeaks as lr, formatUnresolvedSources as ur, frameworkApiKeyStrategy as dr, installPolicyGuardResolver as fr, loadResourceTuples as pr, makeActionRunner as mr, makeAdvisoryLockCoordinator as hr, makeApiKeyService as gr, makeApiKeyUsageBuffer as _r, makeApiKeyUsageFlusher as vr, makeAsyncKv as yr, makeAuthMiddlewareLayers as br, makeCoordinatedScheduler as xr, makeEffectStoreLayer as Sr, makeLazyWorkflowFacade as Cr, makeMutationOutputCodec as wr, makeMutationRunner as Tr, makeOneShotQueryRunner as Er, makeQueryDescriptorProducer as Dr, makeQueryFinalizer as Or, makeQueryReauthorizer as kr, makeQuerySubscriber as Ar, makeSchemaRegistry as jr, makeWorkflowFacade as Mr, makeWorkflowFacadeWithCallerContext as Nr, makeWorkflowLayers as X, noopKv as Pr, onProcessShutdown as Fr, recordSubscriptionDelivery as Ir, recordWorkflowRun as Lr, registerWakeup as Rr, resolveSecretsBackend as zr, runProvidedEffect as Br, setSecretsBackend as Vr, setSystemStoreHandle as Hr, setTupleSource as Ur, shutdownGraceMsFromEnv as Z, singleCoordinator as Wr, startRpcServer as Gr, startScheduler as Kr, stripForbiddenForWire as qr, undoCaptureEnabled as Jr, unresolvedSources as Yr, withScopedRequest as Xr, workflowToRpc as Zr, wrapStoreWithBootCodec as Qr } from "@voltro/runtime";
|
|
32
|
+
import { appStorageProvider as $r, fromNodeReadable as ei, getObjectStream as ti, putObjectStream as ni, toNodeReadable as ri } from "@voltro/plugin-storage";
|
|
33
|
+
import { isEnvContract as ii } from "@voltro/env";
|
|
34
|
+
import { assertProductionSessionSecret as ai } from "@voltro/protocol/session";
|
|
35
|
+
import { createHash as oi, timingSafeEqual as si } from "node:crypto";
|
|
36
|
+
import { buildDeliverWebhookExecute as ci, buildWebhooksService as li, defaultIncomingPath as ui, deliverWebhookWorkflow as di, makeDeferredEmitHandler as fi, mountIncomingWebhook as pi } from "@voltro/plugin-webhooks";
|
|
37
|
+
import { getAuthSessionStrategy as mi } from "@voltro/plugin-auth";
|
|
38
|
+
import { registerEmailTemplates as hi } from "@voltro/plugin-mail";
|
|
39
|
+
import { channelFor as gi, getBroadcastPlugin as _i } from "@voltro/plugin-broadcast";
|
|
40
|
+
import { packBundle as vi, runExport as yi, runImport as bi, storageBlobSink as xi, storageRefsBlobSource as Si, unpackBundle as Ci, unpackBundleToDir as wi } from "@voltro/data-transfer";
|
|
41
41
|
//#region src/dbPoolReport.ts
|
|
42
|
-
var
|
|
42
|
+
var Ti = (e, t, n = [], r = 0) => {
|
|
43
43
|
let i = n.length, a = 1 + Math.max(0, r), o = e === void 0 ? void 0 : e * a + i, s = o !== void 0 && t !== void 0 ? o * t : void 0, c = i === 0 ? " No connections outside the pool in this process." : ` PLUS ${i} outside the pool (${n.map((e) => e.reason).join("; ")}) — those do not come out of the pool budget, they come out of the DATABASE's.`, l = r > 0 ? ` This process opens ${a} pools of that size — 1 primary + ${r} read replica(s) (DB_REPLICA_URLS), each with its own DB_MAX_CONNECTIONS.` : "";
|
|
44
|
-
if (e === void 0) return "db pool: max per replica UNSET (DB_MAX_CONNECTIONS) — each replica opens the driver's default pool, so the fleet total is that default × replicas. Set DB_MAX_CONNECTIONS so the total stays under your database's connection limit; the pool scales with replicaCount and the database does not." + l + c +
|
|
44
|
+
if (e === void 0) return "db pool: max per replica UNSET (DB_MAX_CONNECTIONS) — each replica opens the driver's default pool, so the fleet total is that default × replicas. Set DB_MAX_CONNECTIONS so the total stays under your database's connection limit; the pool scales with replicaCount and the database does not." + l + c + Ei;
|
|
45
45
|
let u = (r > 0 ? `max × ${a}` : "max") + (i === 0 ? "" : ` + ${i}`), d = r === 0 ? i === 0 ? "" : ` + ${i} = ${o}` : ` → ${u} = ${o} per pod`, ee = r === 0 && i === 0 ? "max" : `(${u})`;
|
|
46
|
-
return `db pool: max=${e} per replica (DB_MAX_CONNECTIONS)` + d + (s === void 0 ? ` — the fleet opens up to ${ee} × replicas connections. Check that against your database's limit before raising replicaCount.` : ` × ${t} replicas = up to ${s} connections. Check that against your database's limit.`) + l + c +
|
|
47
|
-
},
|
|
46
|
+
return `db pool: max=${e} per replica (DB_MAX_CONNECTIONS)` + d + (s === void 0 ? ` — the fleet opens up to ${ee} × replicas connections. Check that against your database's limit before raising replicaCount.` : ` × ${t} replicas = up to ${s} connections. Check that against your database's limit.`) + l + c + Ei;
|
|
47
|
+
}, Ei = " A rolling update runs BOTH generations at once, so budget for (replicas + surge), not replicas — a surge pod that cannot get a connection crashloops, and a rollout that never completes cannot free the connections it is waiting for.", Di = (e = process.env) => {
|
|
48
48
|
let t = e.REPLICA_COUNT;
|
|
49
49
|
if (t === void 0 || t === "") return;
|
|
50
50
|
let n = Number(t);
|
|
51
51
|
return Number.isInteger(n) && n > 0 ? n : void 0;
|
|
52
|
-
},
|
|
52
|
+
}, Oi = () => Math.max(500, Math.floor(Z() * .6)), ki = (e) => new Promise((t) => setTimeout(t, e)), Ai = (e) => {
|
|
53
53
|
let t = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set(), r = 0;
|
|
54
54
|
e.on("connection", (e) => {
|
|
55
55
|
t.add(e), e.once("close", () => {
|
|
@@ -63,14 +63,14 @@ var wi = (e, t, n = [], r = 0) => {
|
|
|
63
63
|
});
|
|
64
64
|
});
|
|
65
65
|
let i, a = async (t = {}) => {
|
|
66
|
-
let n = t.budgetMs ??
|
|
66
|
+
let n = t.budgetMs ?? Oi();
|
|
67
67
|
i ??= new Promise((t) => {
|
|
68
68
|
e.close(() => {
|
|
69
69
|
t();
|
|
70
70
|
});
|
|
71
71
|
}), e.closeIdleConnections();
|
|
72
72
|
let a = Date.now() + n;
|
|
73
|
-
for (; r > 0 && Date.now() < a;) await
|
|
73
|
+
for (; r > 0 && Date.now() < a;) await ki(25), e.closeIdleConnections();
|
|
74
74
|
e.closeIdleConnections();
|
|
75
75
|
}, o = async () => {
|
|
76
76
|
i ??= new Promise((t) => {
|
|
@@ -87,7 +87,7 @@ var wi = (e, t, n = [], r = 0) => {
|
|
|
87
87
|
]));
|
|
88
88
|
} catch {}
|
|
89
89
|
else e.destroy();
|
|
90
|
-
for (let e = 0; t.size > 0 && e < 250; e += 25) await
|
|
90
|
+
for (let e = 0; t.size > 0 && e < 250; e += 25) await ki(25);
|
|
91
91
|
for (let e of t) e.destroy();
|
|
92
92
|
await i;
|
|
93
93
|
};
|
|
@@ -99,25 +99,25 @@ var wi = (e, t, n = [], r = 0) => {
|
|
|
99
99
|
await a(e), await o();
|
|
100
100
|
}
|
|
101
101
|
};
|
|
102
|
-
},
|
|
102
|
+
}, ji = "/_voltro/admin/import", Mi = "/_voltro/admin/export", Q = (e, t) => ({
|
|
103
103
|
status: e,
|
|
104
104
|
contentType: "application/json; charset=utf-8",
|
|
105
105
|
body: JSON.stringify(t)
|
|
106
|
-
}),
|
|
106
|
+
}), Ni = (e) => {
|
|
107
107
|
let t = e.authorization ?? e.Authorization, n = t ? /^Bearer\s+(.+)$/i.exec(t) : null;
|
|
108
108
|
return n ? n[1] : null;
|
|
109
|
-
},
|
|
109
|
+
}, Pi = (e, t) => si(oi("sha256").update(e).digest(), oi("sha256").update(t).digest()), Fi = (e, t) => {
|
|
110
110
|
if (e.method.toUpperCase() !== "POST") return Q(405, { error: "method not allowed" });
|
|
111
111
|
if (!t || t.length < 16) return Q(503, { error: "data transfer misconfigured (no/weak secret)" });
|
|
112
|
-
let n =
|
|
113
|
-
return !n || !
|
|
114
|
-
},
|
|
112
|
+
let n = Ni(e.headers);
|
|
113
|
+
return !n || !Pi(n, t) ? Q(401, { error: "unauthorized" }) : null;
|
|
114
|
+
}, Ii = P({ scope: "voltro:admin-import" }), Li = "VBUNDLE2", Ri = async function* (e) {
|
|
115
115
|
yield e;
|
|
116
|
-
},
|
|
117
|
-
let n =
|
|
116
|
+
}, zi = (e) => async (t) => {
|
|
117
|
+
let n = Fi(t, e.secret);
|
|
118
118
|
if (n) return n;
|
|
119
|
-
let r = t.headers["x-import-mode"], i = t.headers["x-import-on-conflict"], a = t.headers["x-import-atomic"] === "1" || t.headers["x-import-atomic"] === "true", o = t.headers["x-import-force"] === "1" || t.headers["x-import-force"] === "true", s = t.rawBody.byteLength >= 8 && Buffer.from(t.rawBody.subarray(0, 8)).toString("latin1") ===
|
|
120
|
-
if (s) c =
|
|
119
|
+
let r = t.headers["x-import-mode"], i = t.headers["x-import-on-conflict"], a = t.headers["x-import-atomic"] === "1" || t.headers["x-import-atomic"] === "true", o = t.headers["x-import-force"] === "1" || t.headers["x-import-force"] === "true", s = t.rawBody.byteLength >= 8 && Buffer.from(t.rawBody.subarray(0, 8)).toString("latin1") === Li, c, l;
|
|
120
|
+
if (s) c = Ri(t.rawBody), l = "upload";
|
|
121
121
|
else {
|
|
122
122
|
let n;
|
|
123
123
|
try {
|
|
@@ -131,11 +131,11 @@ var wi = (e, t, n = [], r = 0) => {
|
|
|
131
131
|
}
|
|
132
132
|
let u = await import("node:os"), d = await import("node:fs/promises"), ee = await import("node:path"), f = await d.mkdtemp(ee.join(u.tmpdir(), "voltro-admin-import-"));
|
|
133
133
|
try {
|
|
134
|
-
e.assetSink ? await
|
|
134
|
+
e.assetSink ? await Ci(c, {
|
|
135
135
|
dir: f,
|
|
136
136
|
blobs: e.assetSink
|
|
137
|
-
}) : await
|
|
138
|
-
let t = await
|
|
137
|
+
}) : await wi(c, f);
|
|
138
|
+
let t = await H.runPromiseExit(bi({
|
|
139
139
|
store: e.store,
|
|
140
140
|
bundleDir: f,
|
|
141
141
|
...r ? { mode: r } : {},
|
|
@@ -143,14 +143,14 @@ var wi = (e, t, n = [], r = 0) => {
|
|
|
143
143
|
...a ? { atomic: a } : {},
|
|
144
144
|
...e.snapshot ? { targetSnapshot: e.snapshot } : {},
|
|
145
145
|
force: o,
|
|
146
|
-
onWarn: (e) =>
|
|
146
|
+
onWarn: (e) => Ii.warn("admin.import", { message: e }),
|
|
147
147
|
...e.assetSink ? { assetsAlreadyRestored: !0 } : {}
|
|
148
148
|
}));
|
|
149
149
|
if (t._tag === "Failure") {
|
|
150
150
|
let e = t.cause._tag === "Fail" ? t.cause.error : void 0;
|
|
151
151
|
if (e && e._tag === "SchemaDriftError") {
|
|
152
152
|
let t = e;
|
|
153
|
-
return
|
|
153
|
+
return Ii.warn("admin.import refused (schema drift)", {
|
|
154
154
|
transport: l,
|
|
155
155
|
bundle: t.bundleFingerprint.slice(0, 16),
|
|
156
156
|
target: t.targetFingerprint.slice(0, 16)
|
|
@@ -165,7 +165,7 @@ var wi = (e, t, n = [], r = 0) => {
|
|
|
165
165
|
throw Error(String(e?.message ?? e ?? "import failed"));
|
|
166
166
|
}
|
|
167
167
|
let n = t.value, s = n.tables.reduce((e, t) => e + t.rowCount, 0);
|
|
168
|
-
return
|
|
168
|
+
return Ii.info("admin.import", {
|
|
169
169
|
transport: l,
|
|
170
170
|
tables: n.tables.length,
|
|
171
171
|
rows: s,
|
|
@@ -177,7 +177,7 @@ var wi = (e, t, n = [], r = 0) => {
|
|
|
177
177
|
transport: l
|
|
178
178
|
});
|
|
179
179
|
} catch (e) {
|
|
180
|
-
return
|
|
180
|
+
return Ii.warn("admin.import failed", {
|
|
181
181
|
transport: l,
|
|
182
182
|
error: e?.message ?? String(e)
|
|
183
183
|
}), Q(500, {
|
|
@@ -190,18 +190,18 @@ var wi = (e, t, n = [], r = 0) => {
|
|
|
190
190
|
force: !0
|
|
191
191
|
});
|
|
192
192
|
}
|
|
193
|
-
},
|
|
193
|
+
}, Bi = P({ scope: "voltro:admin-export" }), Vi = async (e) => {
|
|
194
194
|
let t = [];
|
|
195
195
|
for await (let n of e) t.push(Buffer.from(n));
|
|
196
196
|
return new Uint8Array(Buffer.concat(t));
|
|
197
|
-
},
|
|
197
|
+
}, Hi = (e) => typeof e.tenant == "string" && e.tenant ? {
|
|
198
198
|
kind: "tenant",
|
|
199
199
|
tenantId: e.tenant
|
|
200
200
|
} : Array.isArray(e.tables) && e.tables.length ? {
|
|
201
201
|
kind: "tables",
|
|
202
202
|
tables: e.tables.filter((e) => typeof e == "string")
|
|
203
|
-
} : { kind: "all" },
|
|
204
|
-
let n =
|
|
203
|
+
} : { kind: "all" }, Ui = (e) => async (t) => {
|
|
204
|
+
let n = Fi(t, e.secret);
|
|
205
205
|
if (n) return n;
|
|
206
206
|
let r;
|
|
207
207
|
try {
|
|
@@ -221,9 +221,9 @@ var wi = (e, t, n = [], r = 0) => {
|
|
|
221
221
|
});
|
|
222
222
|
}
|
|
223
223
|
}
|
|
224
|
-
let a = r.consistency === "snapshot" ? "snapshot" : i.consistency ?? "live", o = (typeof r.compression == "string" ? r.compression : void 0) ?? i.compression, s = i.scope ??
|
|
224
|
+
let a = r.consistency === "snapshot" ? "snapshot" : i.consistency ?? "live", o = (typeof r.compression == "string" ? r.compression : void 0) ?? i.compression, s = i.scope ?? Hi(r), c = typeof r.bundleKey == "string" && r.bundleKey.length > 0, l = r.assets === !0 && e.assetSource ? { blobs: e.assetSource } : {}, u = await import("node:os"), d = await import("node:fs/promises"), ee = await import("node:path"), f = await d.mkdtemp(ee.join(u.tmpdir(), "voltro-admin-export-"));
|
|
225
225
|
try {
|
|
226
|
-
let t = await
|
|
226
|
+
let t = await H.runPromise(yi({
|
|
227
227
|
store: e.store,
|
|
228
228
|
snapshot: e.snapshot,
|
|
229
229
|
dialect: e.dialect,
|
|
@@ -239,10 +239,10 @@ var wi = (e, t, n = [], r = 0) => {
|
|
|
239
239
|
if (c) {
|
|
240
240
|
if (!e.putArchive) return Q(501, { error: "storage transport not configured on this instance" });
|
|
241
241
|
let i = r.bundleKey;
|
|
242
|
-
return await e.putArchive(i, () =>
|
|
242
|
+
return await e.putArchive(i, () => vi({
|
|
243
243
|
dir: f,
|
|
244
244
|
...l
|
|
245
|
-
})),
|
|
245
|
+
})), Bi.info("admin.export", {
|
|
246
246
|
transport: "storage",
|
|
247
247
|
tables: t.tables.length,
|
|
248
248
|
rows: n,
|
|
@@ -256,11 +256,11 @@ var wi = (e, t, n = [], r = 0) => {
|
|
|
256
256
|
transport: "storage"
|
|
257
257
|
});
|
|
258
258
|
}
|
|
259
|
-
let d = await
|
|
259
|
+
let d = await Vi(vi({
|
|
260
260
|
dir: f,
|
|
261
261
|
...l
|
|
262
262
|
}));
|
|
263
|
-
return
|
|
263
|
+
return Bi.info("admin.export", {
|
|
264
264
|
transport: "download",
|
|
265
265
|
tables: t.tables.length,
|
|
266
266
|
rows: n,
|
|
@@ -277,7 +277,7 @@ var wi = (e, t, n = [], r = 0) => {
|
|
|
277
277
|
}
|
|
278
278
|
};
|
|
279
279
|
} catch (e) {
|
|
280
|
-
return
|
|
280
|
+
return Bi.warn("admin.export failed", { error: e?.message ?? String(e) }), Q(500, {
|
|
281
281
|
error: "export failed",
|
|
282
282
|
message: e?.message ?? String(e)
|
|
283
283
|
});
|
|
@@ -287,8 +287,8 @@ var wi = (e, t, n = [], r = 0) => {
|
|
|
287
287
|
force: !0
|
|
288
288
|
});
|
|
289
289
|
}
|
|
290
|
-
},
|
|
291
|
-
let r = await
|
|
290
|
+
}, Wi = (e, t, n = {}) => (async function* () {
|
|
291
|
+
let r = await ri((await H.runPromise(ti(e, t).pipe(H.timeout(n.openTimeout ?? "30 seconds")))).stream), i = n.stallMs ?? 12e4, a, o = () => {
|
|
292
292
|
a && clearTimeout(a), a = setTimeout(() => r.destroy(/* @__PURE__ */ Error(`storage read stalled for ${i}ms reading '${t}'`)), i);
|
|
293
293
|
};
|
|
294
294
|
try {
|
|
@@ -297,7 +297,7 @@ var wi = (e, t, n = [], r = 0) => {
|
|
|
297
297
|
} finally {
|
|
298
298
|
a && clearTimeout(a), r.destroy();
|
|
299
299
|
}
|
|
300
|
-
})(),
|
|
300
|
+
})(), Gi = {
|
|
301
301
|
get: async () => void 0,
|
|
302
302
|
set: async () => {},
|
|
303
303
|
setWithTags: async () => {},
|
|
@@ -306,7 +306,7 @@ var wi = (e, t, n = [], r = 0) => {
|
|
|
306
306
|
clear: async () => {},
|
|
307
307
|
invalidateTag: async () => 0,
|
|
308
308
|
wrap: async (e, t, n) => n()
|
|
309
|
-
},
|
|
309
|
+
}, Ki = async (e) => {
|
|
310
310
|
pe(e.appProcedures ?? e.discovered, {
|
|
311
311
|
defaultDeny: e.security?.defaultDeny ?? !0,
|
|
312
312
|
commandHint: "`voltro serve`"
|
|
@@ -314,7 +314,7 @@ var wi = (e, t, n = [], r = 0) => {
|
|
|
314
314
|
dataStore: e.store,
|
|
315
315
|
schemaRegistry: e.schemaRegistry
|
|
316
316
|
});
|
|
317
|
-
let t = (e.discovered.budgets?.length ?? 0) > 0, n, r = new
|
|
317
|
+
let t = (e.discovered.budgets?.length ?? 0) > 0, n, r = new Zn({
|
|
318
318
|
store: e.store,
|
|
319
319
|
...e.snapshotCache ? { cache: e.snapshotCache } : {},
|
|
320
320
|
...e.reactive === void 0 ? {} : { reactive: e.reactive },
|
|
@@ -325,7 +325,7 @@ var wi = (e, t, n = [], r = 0) => {
|
|
|
325
325
|
durationMs: e.durationMs,
|
|
326
326
|
rowCount: e.rowCount
|
|
327
327
|
})
|
|
328
|
-
}), i = e.cache ??
|
|
328
|
+
}), i = e.cache ?? Gi, a = e.kv ?? Pr, c, d = () => void 0, ee, f, p, te, se, ce, le, ue = Oe({
|
|
329
329
|
store: e.store,
|
|
330
330
|
warn: (e, t) => {
|
|
331
331
|
process.stderr.write(`[workflow] ${e} ${JSON.stringify(t)}\n`);
|
|
@@ -333,16 +333,16 @@ var wi = (e, t, n = [], r = 0) => {
|
|
|
333
333
|
}), fe = ue.remember, he = ue.resolve, _e = y({
|
|
334
334
|
authority: e.authority,
|
|
335
335
|
getStore: () => e.store
|
|
336
|
-
}), _ = (e.discovered.workflows?.length ?? 0) > 0 ? Cr(() => c) : void 0, ve = (e.discovered.workflows?.length ?? 0) > 0 || (e.discovered.eventTriggers?.length ?? 0) > 0, ye = ve || (e.discovered.workflowWorkers?.length ?? 0) > 0 || e.scheduleCoordination === "cluster", Se = e.tenantIsolation === "namespace", Ce = (e.log ??
|
|
336
|
+
}), _ = (e.discovered.workflows?.length ?? 0) > 0 ? Cr(() => c) : void 0, ve = (e.discovered.workflows?.length ?? 0) > 0 || (e.discovered.eventTriggers?.length ?? 0) > 0, ye = ve || (e.discovered.workflowWorkers?.length ?? 0) > 0 || e.scheduleCoordination === "cluster", Se = e.tenantIsolation === "namespace", Ce = (e.log ?? P({ scope: "voltro:serve" })).child("webhooks"), we, Te, v = e.discovered.webhooks;
|
|
337
337
|
if (v && v.outgoing.length > 0 && e.workflowEngineLayer !== void 0) {
|
|
338
338
|
e.workflowEngineLayer;
|
|
339
|
-
let t =
|
|
339
|
+
let t = _t({
|
|
340
340
|
store: e.store,
|
|
341
341
|
schemaRegistry: e.schemaRegistry,
|
|
342
342
|
cache: i,
|
|
343
343
|
kv: a
|
|
344
344
|
}), n = v.outgoing.map((e) => e.descriptor);
|
|
345
|
-
Te =
|
|
345
|
+
Te = di.toLayer(ci(t, { events: n })), we = li(t, async (e) => {
|
|
346
346
|
let t = p;
|
|
347
347
|
if (t === void 0) {
|
|
348
348
|
Ce.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.", {
|
|
@@ -351,7 +351,7 @@ var wi = (e, t, n = [], r = 0) => {
|
|
|
351
351
|
});
|
|
352
352
|
return;
|
|
353
353
|
}
|
|
354
|
-
t.runPromise(
|
|
354
|
+
t.runPromise(di.execute(e)).catch((t) => {
|
|
355
355
|
Ce.error("deliverWebhook workflow crashed", {
|
|
356
356
|
deliveryId: e.deliveryId,
|
|
357
357
|
targetId: e.targetId
|
|
@@ -361,7 +361,7 @@ var wi = (e, t, n = [], r = 0) => {
|
|
|
361
361
|
}
|
|
362
362
|
let Ae = /* @__PURE__ */ new Map();
|
|
363
363
|
if (v) for (let e of v.incoming) {
|
|
364
|
-
let t = e.descriptor.path ??
|
|
364
|
+
let t = e.descriptor.path ?? ui(e.descriptor.id), n = `VOLTRO_WEBHOOK_SECRET_${e.descriptor.id.toUpperCase().replace(/[^A-Z0-9]/g, "_")}`, r = pi(e.descriptor, {
|
|
365
365
|
resolveSecret: async () => process.env[n] ?? null,
|
|
366
366
|
resolveWorkflows: () => _ === void 0 ? void 0 : Nr(_, {
|
|
367
367
|
traceId: `incoming:${e.descriptor.id}`,
|
|
@@ -381,14 +381,14 @@ var wi = (e, t, n = [], r = 0) => {
|
|
|
381
381
|
Ae.set(t, { handle: r });
|
|
382
382
|
}
|
|
383
383
|
fr(), Ur((t) => pr(e.store, t.subjectId, t.resourceType, t.resourceId));
|
|
384
|
-
let Ne = [], Pe = [...e.discovered.outboxHandlers ?? [], ...
|
|
384
|
+
let Ne = [], Pe = [...e.discovered.outboxHandlers ?? [], ...pn((v?.outgoing.length ?? 0) + (v?.incoming.length ?? 0) + (v?.providers.length ?? 0), []) ? [{
|
|
385
385
|
file: "<framework>/webhooks",
|
|
386
386
|
id: "voltro-webhook-emit",
|
|
387
|
-
definition:
|
|
387
|
+
definition: fi(() => we)
|
|
388
388
|
}] : []], Ie = Pe.length > 0 ? g({
|
|
389
389
|
handlers: Pe,
|
|
390
390
|
store: e.store,
|
|
391
|
-
log: (e.log ??
|
|
391
|
+
log: (e.log ?? P({ scope: "voltro:serve" })).child("outbox"),
|
|
392
392
|
onChange: (t) => e.store.onChange((e) => t({
|
|
393
393
|
table: e.table,
|
|
394
394
|
op: e.op
|
|
@@ -400,9 +400,9 @@ var wi = (e, t, n = [], r = 0) => {
|
|
|
400
400
|
definitions: (e.discovered.connections ?? []).map((e) => e.definition),
|
|
401
401
|
store: e.store,
|
|
402
402
|
publicUrl: ae(e.port ?? 4e3),
|
|
403
|
-
log: (e.log ??
|
|
403
|
+
log: (e.log ?? P({ scope: "voltro:serve" })).child("connections")
|
|
404
404
|
});
|
|
405
|
-
|
|
405
|
+
ot({
|
|
406
406
|
events: e.discovered.events ?? [],
|
|
407
407
|
rpcTags: [
|
|
408
408
|
...e.discovered.queries.map((e) => e.descriptor.name),
|
|
@@ -411,7 +411,7 @@ var wi = (e, t, n = [], r = 0) => {
|
|
|
411
411
|
...(e.discovered.streams ?? []).map((e) => e.descriptor.name)
|
|
412
412
|
]
|
|
413
413
|
});
|
|
414
|
-
let Re = (e.log ??
|
|
414
|
+
let Re = (e.log ?? P({ scope: "voltro:serve" })).child("events"), Be = e.broadcastNamespace ?? Qe(e.plugins, void 0), Ve = Le(e.plugins, Be, Re), Ue = e.membership?.instanceId ?? process.env.POD_NAME ?? process.env.HOSTNAME ?? `serve-${process.pid}`, We = e.membership ?? At(e.plugins, {
|
|
415
415
|
instanceId: Ue,
|
|
416
416
|
namespace: Be,
|
|
417
417
|
meta: { mode: "serve" },
|
|
@@ -420,7 +420,7 @@ var wi = (e, t, n = [], r = 0) => {
|
|
|
420
420
|
events: e.discovered.events ?? [],
|
|
421
421
|
origin: Ue,
|
|
422
422
|
...Ve.publishRemote === void 0 ? {} : { publishRemote: Ve.publishRemote }
|
|
423
|
-
}), qe = (e.discovered.events ?? []).length > 0 ? await Ve.attach(S.bus) : null,
|
|
423
|
+
}), qe = (e.discovered.events ?? []).length > 0 ? await Ve.attach(S.bus) : null, Je = ze({
|
|
424
424
|
store: e.store,
|
|
425
425
|
schemaRegistry: e.schemaRegistry,
|
|
426
426
|
cache: i,
|
|
@@ -434,163 +434,163 @@ var wi = (e, t, n = [], r = 0) => {
|
|
|
434
434
|
...Ie === void 0 ? {} : { outbox: { nudge: Ie.nudge } },
|
|
435
435
|
...x.active ? { connections: { registry: x.registry } } : {},
|
|
436
436
|
eventBus: S.bus
|
|
437
|
-
}),
|
|
438
|
-
let r = t.pipe(
|
|
439
|
-
return (e.baseLayer ? r.pipe(
|
|
440
|
-
},
|
|
437
|
+
}), Ye = U.succeed(Jn, ne), Xe = U.succeed(K, He), Ze = U.succeed(Yn, Lt), et = U.succeed(q, It), tt = (t, n) => {
|
|
438
|
+
let r = t.pipe(H.provide(Sr(n)));
|
|
439
|
+
return (e.baseLayer ? r.pipe(H.provide(e.baseLayer)) : r).pipe(H.provide(Ye)).pipe(H.provide(Xe)).pipe(H.provide(Ze)).pipe(H.provide(et));
|
|
440
|
+
}, nt = (e, t) => Br(tt(e, t)), C = gn(), at = bt(e.plugins ?? [], C), ct = u({
|
|
441
441
|
plugins: e.plugins ?? [],
|
|
442
|
-
metrics:
|
|
443
|
-
log: e.log ??
|
|
444
|
-
}),
|
|
442
|
+
metrics: C,
|
|
443
|
+
log: e.log ?? P({ scope: "voltro:serve" })
|
|
444
|
+
}), lt = ie(e.plugins ?? [], C), ut = e.security?.defaultDeny ?? !0, ft = Tr({
|
|
445
445
|
store: e.store,
|
|
446
|
-
defaultDeny:
|
|
446
|
+
defaultDeny: ut,
|
|
447
447
|
recordMetric: (e) => {
|
|
448
|
-
|
|
448
|
+
C.record(e);
|
|
449
449
|
},
|
|
450
|
-
...
|
|
451
|
-
buildContext: (e, t, n) =>
|
|
452
|
-
runEffect:
|
|
450
|
+
...at.mutation === void 0 ? {} : { interceptor: at.mutation },
|
|
451
|
+
buildContext: (e, t, n) => Je(e, t, n),
|
|
452
|
+
runEffect: nt,
|
|
453
453
|
undoCapture: xe()
|
|
454
|
-
}),
|
|
454
|
+
}), pt = b();
|
|
455
455
|
{
|
|
456
456
|
let t = o();
|
|
457
|
-
t !== void 0 && (e.log ??
|
|
457
|
+
t !== void 0 && (e.log ?? P({ scope: "voltro:serve" })).info(t);
|
|
458
458
|
}
|
|
459
|
-
let
|
|
459
|
+
let mt = Me({
|
|
460
460
|
store: e.store,
|
|
461
461
|
...e.approvals === void 0 ? {} : { defaultExpiryMs: e.approvals.defaultExpiryMs }
|
|
462
|
-
}),
|
|
463
|
-
defaultDeny:
|
|
464
|
-
buildContext: (e) =>
|
|
465
|
-
runEffect:
|
|
462
|
+
}), ht = mr({
|
|
463
|
+
defaultDeny: ut,
|
|
464
|
+
buildContext: (e) => Je(e),
|
|
465
|
+
runEffect: nt,
|
|
466
466
|
recordMetric: (e) => {
|
|
467
|
-
|
|
467
|
+
C.record(e);
|
|
468
468
|
},
|
|
469
|
-
...
|
|
470
|
-
}),
|
|
469
|
+
...at.action === void 0 ? {} : { interceptor: at.action }
|
|
470
|
+
}), gt = Or({
|
|
471
471
|
tenantScopedTables: e.tenantScopedTables,
|
|
472
472
|
softDeleteScopedTables: e.softDeleteScopedTables
|
|
473
|
-
}),
|
|
474
|
-
defaultDeny:
|
|
475
|
-
buildContext: (e) =>
|
|
476
|
-
finalize: (e, t) =>
|
|
477
|
-
provideEffect:
|
|
478
|
-
...
|
|
479
|
-
},
|
|
480
|
-
...
|
|
473
|
+
}), w = {
|
|
474
|
+
defaultDeny: ut,
|
|
475
|
+
buildContext: (e) => Je(e),
|
|
476
|
+
finalize: (e, t) => gt(e, t.subject),
|
|
477
|
+
provideEffect: tt,
|
|
478
|
+
...at.query === void 0 ? {} : { interceptor: at.query }
|
|
479
|
+
}, T = Dr(w), vt = Er({
|
|
480
|
+
...w,
|
|
481
481
|
queryRows: (t, n) => e.store.query(t).then((e) => qr(t.table, e, n.subject))
|
|
482
|
-
}),
|
|
483
|
-
...
|
|
482
|
+
}), yt = Ar({
|
|
483
|
+
...w,
|
|
484
484
|
subscribeDescriptor: (e, t, n) => r.subscribe(e, t, n),
|
|
485
485
|
subscribeComputed: (e, t, n) => r.subscribeComputed(e, t, n)
|
|
486
|
-
}),
|
|
486
|
+
}), E = (e) => e.filter((e) => On(e.descriptor)), D = {};
|
|
487
487
|
for (let t of [
|
|
488
|
-
...
|
|
489
|
-
...ft.queries,
|
|
488
|
+
...E(e.discovered.queries),
|
|
490
489
|
...pt.queries,
|
|
490
|
+
...mt.queries,
|
|
491
491
|
...x.queries
|
|
492
|
-
])
|
|
492
|
+
]) D[t.descriptor.name] = (e) => Y(T(t, e), r, `subscription.${t.descriptor.name}`, void 0, void 0, kr(t, e));
|
|
493
493
|
for (let t of [
|
|
494
|
-
...
|
|
495
|
-
...ft.mutations,
|
|
494
|
+
...E(e.discovered.mutations),
|
|
496
495
|
...pt.mutations,
|
|
496
|
+
...mt.mutations,
|
|
497
497
|
...x.mutations
|
|
498
498
|
]) {
|
|
499
499
|
let n = wr(t.descriptor.output);
|
|
500
|
-
|
|
500
|
+
D[t.descriptor.name] = (r) => J(async (e, n) => ft(t, e, n), r, `mutation.${t.descriptor.name}`, n, e.idempotency, t.descriptor.error);
|
|
501
501
|
}
|
|
502
|
-
for (let t of [...
|
|
502
|
+
for (let t of [...E(e.discovered.actions), ...x.actions]) {
|
|
503
503
|
let n = wr(t.descriptor.output);
|
|
504
|
-
|
|
504
|
+
D[t.descriptor.name] = (r) => J(async (e, n) => ht(t, e, n), r, `action.${t.descriptor.name}`, n, e.idempotency, t.descriptor.error);
|
|
505
505
|
}
|
|
506
|
-
let
|
|
506
|
+
let xt = () => `public-${Math.random().toString(36).slice(2, 10)}`, St = [
|
|
507
507
|
...e.discovered.queries.filter((e) => e.descriptor.publicApi !== void 0).map((e) => ({
|
|
508
508
|
descriptor: e.descriptor,
|
|
509
|
-
invoke: (t, n) =>
|
|
509
|
+
invoke: (t, n) => vt(e, t, {
|
|
510
510
|
subject: n.subject,
|
|
511
|
-
traceId:
|
|
511
|
+
traceId: xt()
|
|
512
512
|
}),
|
|
513
|
-
subscribe: (t, n, r) =>
|
|
513
|
+
subscribe: (t, n, r) => yt(e, t, {
|
|
514
514
|
subject: n.subject,
|
|
515
|
-
traceId:
|
|
515
|
+
traceId: xt()
|
|
516
516
|
}, r)
|
|
517
517
|
})),
|
|
518
518
|
...e.discovered.mutations.filter((e) => e.descriptor.publicApi !== void 0).map((e) => ({
|
|
519
519
|
descriptor: e.descriptor,
|
|
520
|
-
invoke: (t, n) =>
|
|
520
|
+
invoke: (t, n) => ft(e, t, {
|
|
521
521
|
subject: n.subject,
|
|
522
|
-
traceId:
|
|
522
|
+
traceId: xt()
|
|
523
523
|
})
|
|
524
524
|
})),
|
|
525
525
|
...e.discovered.actions.filter((e) => e.descriptor.publicApi !== void 0).map((e) => ({
|
|
526
526
|
descriptor: e.descriptor,
|
|
527
|
-
invoke: (t, n) =>
|
|
527
|
+
invoke: (t, n) => ht(e, t, {
|
|
528
528
|
subject: n.subject,
|
|
529
|
-
traceId:
|
|
529
|
+
traceId: xt()
|
|
530
530
|
})
|
|
531
531
|
}))
|
|
532
|
-
],
|
|
532
|
+
], Ct = {
|
|
533
533
|
candidates: m({
|
|
534
534
|
queries: e.discovered.queries,
|
|
535
535
|
mutations: e.discovered.mutations,
|
|
536
536
|
actions: e.discovered.actions,
|
|
537
537
|
descriptorOf: (e) => e.descriptor,
|
|
538
|
-
runQuery: (e, t, n) => Promise.resolve(
|
|
539
|
-
runMutation: (e, t, n) => Promise.resolve(
|
|
540
|
-
runAction: (e, t, n) => Promise.resolve(
|
|
538
|
+
runQuery: (e, t, n) => Promise.resolve(vt(e, t, n)),
|
|
539
|
+
runMutation: (e, t, n) => Promise.resolve(ft(e, t, n)),
|
|
540
|
+
runAction: (e, t, n) => Promise.resolve(ht(e, t, n))
|
|
541
541
|
}),
|
|
542
542
|
policy: e.agents?.tools ?? {},
|
|
543
543
|
mcpEnabled: e.agents?.mcp === !0,
|
|
544
544
|
resolveSubject: (t) => e.resolveSubject(t, -1).then((e) => e.subject)
|
|
545
|
-
},
|
|
545
|
+
}, Tt = s({
|
|
546
546
|
...e.restRoutes === void 0 ? {} : { restRoutes: e.restRoutes },
|
|
547
|
-
publicApiEntries:
|
|
547
|
+
publicApiEntries: St,
|
|
548
548
|
store: e.store,
|
|
549
549
|
resolveSubject: (t) => e.resolveSubject(t, -1).then((e) => e.subject),
|
|
550
550
|
...e.idempotency === void 0 ? {} : { idempotency: e.idempotency },
|
|
551
|
-
log: e.log ??
|
|
552
|
-
}),
|
|
551
|
+
log: e.log ?? P({ scope: "voltro:serve" })
|
|
552
|
+
}), Et = e.dataTransferSecret ?? process.env.VOLTRO_DATA_TRANSFER_SECRET, Dt = Et && Et.length >= 16 ? [{
|
|
553
553
|
method: "POST",
|
|
554
|
-
path:
|
|
555
|
-
handle:
|
|
556
|
-
secret:
|
|
554
|
+
path: ji,
|
|
555
|
+
handle: zi({
|
|
556
|
+
secret: Et,
|
|
557
557
|
store: e.store,
|
|
558
558
|
...e.dataTransferSnapshot ? { snapshot: e.dataTransferSnapshot } : {},
|
|
559
|
-
assetSink:
|
|
560
|
-
openArchive: (e) =>
|
|
559
|
+
assetSink: xi($r()),
|
|
560
|
+
openArchive: (e) => Wi($r(), e)
|
|
561
561
|
})
|
|
562
562
|
}, {
|
|
563
563
|
method: "POST",
|
|
564
|
-
path:
|
|
565
|
-
handle:
|
|
566
|
-
secret:
|
|
564
|
+
path: Mi,
|
|
565
|
+
handle: Ui({
|
|
566
|
+
secret: Et,
|
|
567
567
|
store: e.store,
|
|
568
568
|
snapshot: e.dataTransferSnapshot ?? { tables: [] },
|
|
569
569
|
dialect: e.dataTransferDialect ?? "memory",
|
|
570
570
|
tenantTables: [...e.tenantScopedTables],
|
|
571
|
-
loadProfile:
|
|
572
|
-
assetSource:
|
|
571
|
+
loadProfile: bn,
|
|
572
|
+
assetSource: Si($r(), e.store),
|
|
573
573
|
putArchive: async (e, t) => {
|
|
574
|
-
let { Readable: n } = await import("node:stream"), r =
|
|
575
|
-
await
|
|
574
|
+
let { Readable: n } = await import("node:stream"), r = $r(), i = ei("storage", () => n.from(t()));
|
|
575
|
+
await H.runPromise(ni(r, e, i, { contentType: "application/octet-stream" }));
|
|
576
576
|
}
|
|
577
577
|
})
|
|
578
|
-
}] : [],
|
|
578
|
+
}] : [], Ot = [
|
|
579
579
|
...e.httpRoutes ?? [],
|
|
580
|
-
...
|
|
581
|
-
...
|
|
580
|
+
...Tt.httpRoutes,
|
|
581
|
+
...Dt,
|
|
582
582
|
...x.httpRoutes
|
|
583
583
|
];
|
|
584
|
-
Object.assign(
|
|
585
|
-
for (let t of
|
|
586
|
-
let i =
|
|
587
|
-
if (
|
|
588
|
-
let t = a.pipe(
|
|
589
|
-
return (e.baseLayer ? t.pipe(
|
|
584
|
+
Object.assign(D, S.handlers);
|
|
585
|
+
for (let t of E(e.discovered.streams ?? [])) D[t.descriptor.name] = (n) => ir((r) => Xr(r, (r) => {
|
|
586
|
+
let i = Je(r), a = t.executor(n, i);
|
|
587
|
+
if (H.isEffect(a)) {
|
|
588
|
+
let t = a.pipe(H.provide(Sr(i.store)));
|
|
589
|
+
return (e.baseLayer ? t.pipe(H.provide(e.baseLayer)) : t).pipe(H.provide(Ye)).pipe(H.provide(Xe)).pipe(H.provide(Ze)).pipe(H.provide(et));
|
|
590
590
|
}
|
|
591
|
-
return typeof a == "object" && a && typeof a.then == "function" ?
|
|
592
|
-
}, `stream.${t.descriptor.name}`);
|
|
593
|
-
for (let t of e.discovered.workflows ?? [])
|
|
591
|
+
return typeof a == "object" && a && typeof a.then == "function" ? H.promise(() => a) : a;
|
|
592
|
+
}), `stream.${t.descriptor.name}`);
|
|
593
|
+
for (let t of e.discovered.workflows ?? []) D[t.definition.name] = (e) => J(async (e, n) => {
|
|
594
594
|
let r = n;
|
|
595
595
|
return Nr(_, {
|
|
596
596
|
subject: r.subject,
|
|
@@ -598,8 +598,8 @@ var wi = (e, t, n = [], r = 0) => {
|
|
|
598
598
|
source: "workflow-rpc"
|
|
599
599
|
}).start(t.definition.name, e);
|
|
600
600
|
}, e, `workflow.${t.definition.name}`);
|
|
601
|
-
ve && (
|
|
602
|
-
descriptor:
|
|
601
|
+
ve && (D[B.name] = (e) => Y(T({
|
|
602
|
+
descriptor: B,
|
|
603
603
|
executor: (e) => {
|
|
604
604
|
let t = e.id;
|
|
605
605
|
return {
|
|
@@ -608,30 +608,30 @@ var wi = (e, t, n = [], r = 0) => {
|
|
|
608
608
|
column: "startedAt",
|
|
609
609
|
direction: "desc"
|
|
610
610
|
}],
|
|
611
|
-
predicate:
|
|
611
|
+
predicate: G(W("id", t), W("executionId", t)),
|
|
612
612
|
take: 1,
|
|
613
613
|
skip: void 0,
|
|
614
614
|
projection: void 0
|
|
615
615
|
};
|
|
616
616
|
}
|
|
617
|
-
}, e), r, `subscription.${
|
|
618
|
-
descriptor:
|
|
617
|
+
}, e), r, `subscription.${B.name}`), D[Nn.name] = (e) => Y(T({
|
|
618
|
+
descriptor: Nn,
|
|
619
619
|
executor: (e) => {
|
|
620
|
-
let t = e, n = [...t.tag === void 0 ? [] : [
|
|
620
|
+
let t = e, n = [...t.tag === void 0 ? [] : [W("tag", t.tag)], ...t.status === void 0 ? [] : [W("status", t.status)]], r = Number.isFinite(t.limit) && t.limit !== void 0 ? Math.min(Math.max(Math.floor(t.limit), 1), 500) : 100;
|
|
621
621
|
return {
|
|
622
622
|
table: "_voltro_workflow_runs",
|
|
623
623
|
order: [{
|
|
624
624
|
column: "startedAt",
|
|
625
625
|
direction: "desc"
|
|
626
626
|
}],
|
|
627
|
-
predicate: n.length === 0 ? void 0 : n.length === 1 ? n[0] :
|
|
627
|
+
predicate: n.length === 0 ? void 0 : n.length === 1 ? n[0] : Gn(...n),
|
|
628
628
|
take: r,
|
|
629
629
|
skip: void 0,
|
|
630
630
|
projection: void 0
|
|
631
631
|
};
|
|
632
632
|
}
|
|
633
|
-
}, e), r, `subscription.${
|
|
634
|
-
descriptor:
|
|
633
|
+
}, e), r, `subscription.${Nn.name}`), D[V.name] = (e) => Y(T({
|
|
634
|
+
descriptor: V,
|
|
635
635
|
executor: (e) => {
|
|
636
636
|
let t = e.runId;
|
|
637
637
|
return {
|
|
@@ -640,14 +640,14 @@ var wi = (e, t, n = [], r = 0) => {
|
|
|
640
640
|
column: "startedAt",
|
|
641
641
|
direction: "asc"
|
|
642
642
|
}],
|
|
643
|
-
predicate:
|
|
643
|
+
predicate: W("runId", t),
|
|
644
644
|
take: 1e3,
|
|
645
645
|
skip: void 0,
|
|
646
646
|
projection: void 0
|
|
647
647
|
};
|
|
648
648
|
}
|
|
649
|
-
}, e), r, `subscription.${
|
|
650
|
-
descriptor:
|
|
649
|
+
}, e), r, `subscription.${V.name}`), D[z.name] = (e) => Y(T({
|
|
650
|
+
descriptor: z,
|
|
651
651
|
executor: (e) => {
|
|
652
652
|
let t = e.runId;
|
|
653
653
|
return {
|
|
@@ -656,14 +656,14 @@ var wi = (e, t, n = [], r = 0) => {
|
|
|
656
656
|
column: "occurredAt",
|
|
657
657
|
direction: "asc"
|
|
658
658
|
}],
|
|
659
|
-
predicate:
|
|
659
|
+
predicate: W("runId", t),
|
|
660
660
|
take: 1e3,
|
|
661
661
|
skip: void 0,
|
|
662
662
|
projection: void 0
|
|
663
663
|
};
|
|
664
664
|
}
|
|
665
|
-
}, e), r, `subscription.${
|
|
666
|
-
descriptor:
|
|
665
|
+
}, e), r, `subscription.${z.name}`), D[jn.name] = (e) => Y(T({
|
|
666
|
+
descriptor: jn,
|
|
667
667
|
executor: (e) => {
|
|
668
668
|
let t = e;
|
|
669
669
|
return {
|
|
@@ -672,14 +672,14 @@ var wi = (e, t, n = [], r = 0) => {
|
|
|
672
672
|
column: "occurredAt",
|
|
673
673
|
direction: "desc"
|
|
674
674
|
}],
|
|
675
|
-
predicate: t.name === void 0 ? void 0 :
|
|
675
|
+
predicate: t.name === void 0 ? void 0 : W("name", t.name),
|
|
676
676
|
take: Math.max(1, Math.min(500, t.limit ?? 100)),
|
|
677
677
|
skip: void 0,
|
|
678
678
|
projection: void 0
|
|
679
679
|
};
|
|
680
680
|
}
|
|
681
|
-
}, e), r, `subscription.${
|
|
682
|
-
descriptor:
|
|
681
|
+
}, e), r, `subscription.${jn.name}`), D[R.name] = (e) => Y(T({
|
|
682
|
+
descriptor: R,
|
|
683
683
|
executor: (e) => {
|
|
684
684
|
let t = e.eventId;
|
|
685
685
|
return {
|
|
@@ -688,73 +688,73 @@ var wi = (e, t, n = [], r = 0) => {
|
|
|
688
688
|
column: "createdAt",
|
|
689
689
|
direction: "asc"
|
|
690
690
|
}],
|
|
691
|
-
predicate:
|
|
691
|
+
predicate: W("eventId", t),
|
|
692
692
|
take: 500,
|
|
693
693
|
skip: void 0,
|
|
694
694
|
projection: void 0
|
|
695
695
|
};
|
|
696
696
|
}
|
|
697
|
-
}, e), r, `subscription.${
|
|
697
|
+
}, e), r, `subscription.${R.name}`), D[An.name] = (t) => J(async (t, n) => {
|
|
698
698
|
let r = t;
|
|
699
|
-
return await
|
|
700
|
-
}, t, `action.${
|
|
699
|
+
return await it(e.store, n.subject, { executionId: r.executionId }), await _.cancel(r.workflowName, r.executionId), await zt(r.workflowName, r.executionId, "workflow.cancel"), { ok: !0 };
|
|
700
|
+
}, t, `action.${An.name}`), D[Mn.name] = (t) => J(async (t, n) => {
|
|
701
701
|
let r = t;
|
|
702
|
-
return await
|
|
703
|
-
}, t, `action.${
|
|
702
|
+
return await it(e.store, n.subject, { executionId: r.executionId }), await _.resume(r.workflowName, r.executionId), { ok: !0 };
|
|
703
|
+
}, t, `action.${Mn.name}`), D[Pn.name] = (t) => J(async (t, n) => {
|
|
704
704
|
let r = t;
|
|
705
|
-
return await
|
|
706
|
-
}, t, `action.${
|
|
705
|
+
return await it(e.store, n.subject, { id: r.id }), _.signal({ id: r.id }, r.signalName, r.payload);
|
|
706
|
+
}, t, `action.${Pn.name}`), D[Fn.name] = (t) => J(async (t, n) => {
|
|
707
707
|
let r = t;
|
|
708
|
-
return await
|
|
709
|
-
}, t, `action.${
|
|
710
|
-
let
|
|
711
|
-
...
|
|
712
|
-
...
|
|
713
|
-
...
|
|
714
|
-
...
|
|
715
|
-
...
|
|
716
|
-
...
|
|
717
|
-
...
|
|
718
|
-
...x.queries.map((e) =>
|
|
719
|
-
...x.mutations.map((e) =>
|
|
720
|
-
...x.actions.map((e) =>
|
|
721
|
-
...
|
|
708
|
+
return await it(e.store, n.subject, { id: r.id }), _.update({ id: r.id }, r.updateName, r.payload, r.timeoutMs === void 0 ? void 0 : { timeoutMs: r.timeoutMs });
|
|
709
|
+
}, t, `action.${Fn.name}`));
|
|
710
|
+
let jt = [
|
|
711
|
+
...E(e.discovered.queries).map((e) => L(e.descriptor)),
|
|
712
|
+
...E(e.discovered.mutations).map((e) => I(e.descriptor)),
|
|
713
|
+
...E(e.discovered.actions).map((e) => F(e.descriptor)),
|
|
714
|
+
...pt.queries.map((e) => L(e.descriptor)),
|
|
715
|
+
...pt.mutations.map((e) => I(e.descriptor)),
|
|
716
|
+
...mt.queries.map((e) => L(e.descriptor)),
|
|
717
|
+
...mt.mutations.map((e) => I(e.descriptor)),
|
|
718
|
+
...x.queries.map((e) => L(e.descriptor)),
|
|
719
|
+
...x.mutations.map((e) => I(e.descriptor)),
|
|
720
|
+
...x.actions.map((e) => F(e.descriptor)),
|
|
721
|
+
...E(e.discovered.streams ?? []).map((e) => kn(e.descriptor)),
|
|
722
722
|
...S.rpcs,
|
|
723
|
-
...(e.discovered.workflows ?? []).map((e) =>
|
|
723
|
+
...(e.discovered.workflows ?? []).map((e) => Zr(e.definition)),
|
|
724
724
|
...ve ? [
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
R
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
725
|
+
L(B),
|
|
726
|
+
L(Nn),
|
|
727
|
+
L(V),
|
|
728
|
+
L(z),
|
|
729
|
+
L(jn),
|
|
730
|
+
L(R),
|
|
731
|
+
F(An),
|
|
732
|
+
F(Mn),
|
|
733
|
+
F(Pn),
|
|
734
|
+
F(Fn)
|
|
735
735
|
] : []
|
|
736
|
-
],
|
|
736
|
+
], Mt = Un.make(...jt).middleware(Tn).middleware(En), Nt = br({ resolveSubject: ({ headers: t, clientId: n }) => e.resolveSubject(t, n) }), Pt = e.dormancyTenantId ?? Xn, Ft = e.dormancy === "sleep" ? {
|
|
737
737
|
register: (t, n, r) => Rr(e.store, {
|
|
738
|
-
tenantId: r ??
|
|
738
|
+
tenantId: r ?? Pt,
|
|
739
739
|
kind: "workflow",
|
|
740
740
|
refId: t,
|
|
741
741
|
wakeAt: n
|
|
742
742
|
}),
|
|
743
743
|
cancel: (t, n) => or(e.store, {
|
|
744
|
-
tenantId: n ??
|
|
744
|
+
tenantId: n ?? Pt,
|
|
745
745
|
kind: "workflow",
|
|
746
746
|
refId: t
|
|
747
747
|
}).then(() => {})
|
|
748
|
-
} : void 0,
|
|
748
|
+
} : void 0, k = ye ? await import("@voltro/workflow") : void 0, A = k?.makeWorkflowRunRecorder({
|
|
749
749
|
store: e.store,
|
|
750
750
|
...e.workflowRecording === void 0 ? {} : { recording: e.workflowRecording },
|
|
751
|
-
...
|
|
752
|
-
}),
|
|
753
|
-
await
|
|
751
|
+
...Ft === void 0 ? {} : { wakeups: Ft }
|
|
752
|
+
}), Rt = async (t, n) => {
|
|
753
|
+
await k.closeWorkflowChildrenForParent({
|
|
754
754
|
store: e.store,
|
|
755
755
|
parentExecutionId: t,
|
|
756
756
|
parentStatus: n,
|
|
757
|
-
recorder:
|
|
757
|
+
recorder: A,
|
|
758
758
|
log: { warn: (e, t) => {
|
|
759
759
|
process.stderr.write(`[workflow] ${e} ${t ? JSON.stringify(t) : ""}\n`);
|
|
760
760
|
} },
|
|
@@ -765,11 +765,11 @@ var wi = (e, t, n = [], r = 0) => {
|
|
|
765
765
|
await p.runPromise(r.definition.interrupt(n));
|
|
766
766
|
}
|
|
767
767
|
});
|
|
768
|
-
},
|
|
768
|
+
}, zt = async (t, n, r) => {
|
|
769
769
|
let i = (await e.store.query({
|
|
770
770
|
table: "_voltro_workflow_runs",
|
|
771
771
|
order: [],
|
|
772
|
-
predicate:
|
|
772
|
+
predicate: W("executionId", n),
|
|
773
773
|
projection: void 0,
|
|
774
774
|
skip: void 0,
|
|
775
775
|
take: 1
|
|
@@ -780,7 +780,7 @@ var wi = (e, t, n = [], r = 0) => {
|
|
|
780
780
|
cancelled: !0,
|
|
781
781
|
completedAt: /* @__PURE__ */ new Date()
|
|
782
782
|
}), o = i.subject?.tenantId ?? void 0;
|
|
783
|
-
a && await
|
|
783
|
+
a && await A.recordEvent({
|
|
784
784
|
runId: i.id,
|
|
785
785
|
eventType: "run-cancelled",
|
|
786
786
|
payload: {
|
|
@@ -789,18 +789,18 @@ var wi = (e, t, n = [], r = 0) => {
|
|
|
789
789
|
executionId: n,
|
|
790
790
|
...o == null ? {} : { tenantId: o }
|
|
791
791
|
}
|
|
792
|
-
}), a && await
|
|
793
|
-
},
|
|
792
|
+
}), a && await Rt(n, "cancelled");
|
|
793
|
+
}, Bt = [
|
|
794
794
|
...X(e.discovered.workflows ?? [], {
|
|
795
|
-
buildContext: (t, n) => e.buildContextForWorkflow?.(t, n) ??
|
|
795
|
+
buildContext: (t, n) => e.buildContextForWorkflow?.(t, n) ?? Je({
|
|
796
796
|
subject: t.subject,
|
|
797
797
|
traceId: t.traceId
|
|
798
798
|
}, e.store, void 0, `workflow:${n.workflowName}`, { parentExecutionId: n.executionId }),
|
|
799
799
|
resolveStartContext: he,
|
|
800
800
|
..._e === void 0 ? {} : { resolveAuthority: _e }
|
|
801
801
|
}, (t, n, r) => {
|
|
802
|
-
let i =
|
|
803
|
-
return
|
|
802
|
+
let i = k.getWorkflowVersionMetadata(t.definition);
|
|
803
|
+
return k.wrapWorkflowExecuteWithRunRecording({
|
|
804
804
|
name: t.definition.name,
|
|
805
805
|
store: e.store,
|
|
806
806
|
subject: r.subject,
|
|
@@ -811,26 +811,26 @@ var wi = (e, t, n = [], r = 0) => {
|
|
|
811
811
|
workflowPatches: i.patches,
|
|
812
812
|
parentExecutionId: r?.parentExecutionId ?? null,
|
|
813
813
|
parentClosePolicy: r?.parentClosePolicy ?? null,
|
|
814
|
-
onParentClose: ({ executionId: e, status: t }) =>
|
|
814
|
+
onParentClose: ({ executionId: e, status: t }) => Rt(e, t),
|
|
815
815
|
...Ge(t.definition),
|
|
816
816
|
onTerminal: async ({ executionId: e }) => {
|
|
817
817
|
await f?.gate.release(e);
|
|
818
818
|
},
|
|
819
|
-
recorder:
|
|
820
|
-
pluginWorkflowStepLayer:
|
|
819
|
+
recorder: A,
|
|
820
|
+
pluginWorkflowStepLayer: lt,
|
|
821
821
|
recordRun: Lr
|
|
822
822
|
}, n);
|
|
823
823
|
}),
|
|
824
824
|
...e.discovered.workflowWorkers ?? [],
|
|
825
825
|
...Te === void 0 ? [] : [Te]
|
|
826
|
-
],
|
|
826
|
+
], Vt = [...(e.discovered.workflows ?? []).map((e) => e.definition.name).filter(Boolean), ...Te === void 0 ? [] : ["voltro.deliverWebhook"]], Ht = Bt.length > 0 ? U.mergeAll(...Bt) : U.empty;
|
|
827
827
|
if (((e.discovered.workflows?.length ?? 0) > 0 || (e.discovered.workflowWorkers?.length ?? 0) > 0 || e.scheduleCoordination === "cluster" || Te !== void 0) && e.workflowEngineLayer !== void 0) {
|
|
828
|
-
let t =
|
|
829
|
-
p =
|
|
828
|
+
let t = Ht.pipe(U.provideMerge(e.workflowEngineLayer));
|
|
829
|
+
p = Ln.make(e.baseLayer === void 0 ? t : t.pipe(U.provideMerge(e.baseLayer))), await p.runPromise(H.void), (e.log ?? P({ scope: "voltro:serve" })).child("workflow").info(`workflow runtime ready — ${Vt.length} entity type(s) registered`, { entities: Vt });
|
|
830
830
|
let n = await import("@voltro/workflow/cluster"), r = (e) => p.runPromise(n.redriveFailedRun(e)), i = (e) => p.runPromise(n.resumeRunFromStep(e));
|
|
831
|
-
ce = await
|
|
832
|
-
provider:
|
|
833
|
-
crossReplica:
|
|
831
|
+
ce = await $e({
|
|
832
|
+
provider: _i(e.plugins ?? [])?.broadcast?.provider,
|
|
833
|
+
crossReplica: _i(e.plugins ?? [])?.broadcast?.crossReplica ?? !1,
|
|
834
834
|
namespace: Be,
|
|
835
835
|
replicaId: crypto.randomUUID(),
|
|
836
836
|
pollStorage: () => p.runPromise(n.pollWorkflowStorage),
|
|
@@ -839,14 +839,14 @@ var wi = (e, t, n = [], r = 0) => {
|
|
|
839
839
|
op: e.op,
|
|
840
840
|
...e.origin === void 0 ? {} : { origin: e.origin }
|
|
841
841
|
})),
|
|
842
|
-
log: (e.log ??
|
|
842
|
+
log: (e.log ?? P({ scope: "voltro:serve" })).child("workflow")
|
|
843
843
|
}), te = async (t) => {
|
|
844
844
|
let n = await oe({
|
|
845
845
|
store: e.store,
|
|
846
846
|
workflows: e.discovered.workflows ?? [],
|
|
847
847
|
runRedrive: r
|
|
848
848
|
}, t.runId);
|
|
849
|
-
return n.statusReset && await
|
|
849
|
+
return n.statusReset && await A.recordEvent({
|
|
850
850
|
runId: t.runId,
|
|
851
851
|
eventType: "run-redriven",
|
|
852
852
|
payload: {
|
|
@@ -864,7 +864,7 @@ var wi = (e, t, n = [], r = 0) => {
|
|
|
864
864
|
workflows: e.discovered.workflows ?? [],
|
|
865
865
|
runResume: i
|
|
866
866
|
}, t.runId, t.step);
|
|
867
|
-
return n.statusReset && await
|
|
867
|
+
return n.statusReset && await A.recordEvent({
|
|
868
868
|
runId: t.runId,
|
|
869
869
|
eventType: "run-redriven",
|
|
870
870
|
payload: {
|
|
@@ -894,17 +894,17 @@ var wi = (e, t, n = [], r = 0) => {
|
|
|
894
894
|
}
|
|
895
895
|
}, s, l = () => {
|
|
896
896
|
if (s !== void 0) return s;
|
|
897
|
-
if (!(c === void 0 ||
|
|
897
|
+
if (!(c === void 0 || A === void 0)) return s = re({
|
|
898
898
|
store: e.store,
|
|
899
|
-
log:
|
|
899
|
+
log: N,
|
|
900
900
|
workflows: e.discovered.workflows ?? [],
|
|
901
901
|
workflowsProxy: c,
|
|
902
902
|
workflowRuntime: p,
|
|
903
|
-
workflowRunRecorder:
|
|
904
|
-
closeChildrenForParent:
|
|
903
|
+
workflowRunRecorder: A,
|
|
904
|
+
closeChildrenForParent: Rt
|
|
905
905
|
}), s;
|
|
906
906
|
};
|
|
907
|
-
d = l, f =
|
|
907
|
+
d = l, f = rt({
|
|
908
908
|
store: e.store,
|
|
909
909
|
onChange: (t) => e.store.onChange((e) => t({
|
|
910
910
|
table: e.table,
|
|
@@ -919,12 +919,12 @@ var wi = (e, t, n = [], r = 0) => {
|
|
|
919
919
|
workflows: e.discovered.workflows ?? [],
|
|
920
920
|
facade: () => c,
|
|
921
921
|
cancelRunWithReason: l,
|
|
922
|
-
recordRunEvent: () =>
|
|
922
|
+
recordRunEvent: () => A?.recordEvent,
|
|
923
923
|
...e.workflowStaleness === void 0 ? {} : { staleness: e.workflowStaleness },
|
|
924
924
|
...e.workflowSuspendSignalHintMs === void 0 ? {} : { suspendSignalHintMs: e.workflowSuspendSignalHintMs },
|
|
925
925
|
scheduleCoordinated: a,
|
|
926
926
|
onAbandoned: async (t) => {
|
|
927
|
-
await
|
|
927
|
+
await wt({
|
|
928
928
|
workflows: e.discovered.workflows ?? [],
|
|
929
929
|
facade: () => c,
|
|
930
930
|
log: o,
|
|
@@ -945,10 +945,10 @@ var wi = (e, t, n = [], r = 0) => {
|
|
|
945
945
|
tickIntervalMs: e.scheduling.inferenceTickMs
|
|
946
946
|
},
|
|
947
947
|
enabled: (e.discovered.workflows?.length ?? 0) > 0,
|
|
948
|
-
resumeSignal: () => p === void 0 ||
|
|
949
|
-
await p.runPromise(
|
|
948
|
+
resumeSignal: () => p === void 0 || k === void 0 ? void 0 : async ({ executionId: t, workflowName: n, signalName: r, payload: i }) => {
|
|
949
|
+
await p.runPromise(k.completeSuspendingSignal({
|
|
950
950
|
store: e.store,
|
|
951
|
-
target:
|
|
951
|
+
target: kt(t, n),
|
|
952
952
|
signalName: r,
|
|
953
953
|
payload: i
|
|
954
954
|
}));
|
|
@@ -969,23 +969,23 @@ var wi = (e, t, n = [], r = 0) => {
|
|
|
969
969
|
},
|
|
970
970
|
rememberStartContext: fe,
|
|
971
971
|
signal: async (t, n, r) => {
|
|
972
|
-
let i = await
|
|
972
|
+
let i = await k.sendWorkflowSignal({
|
|
973
973
|
store: e.store,
|
|
974
|
-
recorder:
|
|
974
|
+
recorder: A,
|
|
975
975
|
target: t,
|
|
976
976
|
signalName: n,
|
|
977
977
|
payload: r
|
|
978
978
|
});
|
|
979
|
-
return await p.runPromise(
|
|
979
|
+
return await p.runPromise(k.completeSuspendingSignal({
|
|
980
980
|
store: e.store,
|
|
981
981
|
target: t,
|
|
982
982
|
signalName: n,
|
|
983
983
|
payload: r
|
|
984
984
|
})).catch(() => {}), i;
|
|
985
985
|
},
|
|
986
|
-
update: (t, n, r, i) =>
|
|
986
|
+
update: (t, n, r, i) => k.sendWorkflowUpdate({
|
|
987
987
|
store: e.store,
|
|
988
|
-
recorder:
|
|
988
|
+
recorder: A,
|
|
989
989
|
target: t,
|
|
990
990
|
updateName: n,
|
|
991
991
|
payload: r,
|
|
@@ -1004,32 +1004,32 @@ var wi = (e, t, n = [], r = 0) => {
|
|
|
1004
1004
|
}, t).then((e) => e.outcome)
|
|
1005
1005
|
}) : void 0;
|
|
1006
1006
|
}
|
|
1007
|
-
let
|
|
1007
|
+
let j = U.mergeAll(Mt.toLayer(D), Nt), Ut = O(D, e.discovered.queries.map((e) => e.descriptor.name), ve), Wt = U.mergeAll(Mt.toLayer(Ut), Nt), M = e.observability, Gt = await ar({
|
|
1008
1008
|
...e.appName === void 0 ? {} : { serviceName: e.appName },
|
|
1009
|
-
...
|
|
1010
|
-
...
|
|
1011
|
-
...
|
|
1012
|
-
...
|
|
1013
|
-
}),
|
|
1014
|
-
group:
|
|
1015
|
-
handlersLayer:
|
|
1016
|
-
httpHandlersLayer:
|
|
1009
|
+
...M && M.spanProcessors.length > 0 ? { extraSpanProcessors: M.spanProcessors } : {},
|
|
1010
|
+
...M && M.metricReaders.length > 0 ? { extraMetricReaders: M.metricReaders } : {},
|
|
1011
|
+
...M && Object.keys(M.resourceAttributes).length > 0 ? { resourceAttributes: M.resourceAttributes } : {},
|
|
1012
|
+
...M && M.sampler !== void 0 ? { sampler: M.sampler } : {}
|
|
1013
|
+
}), Kt = !1, qt = e.store.ping ? () => e.store.ping().then(() => !0).catch(() => !1) : void 0, { server: Jt, shutdown: Yt } = Gr({
|
|
1014
|
+
group: Mt,
|
|
1015
|
+
handlersLayer: j,
|
|
1016
|
+
httpHandlersLayer: Wt,
|
|
1017
1017
|
port: e.port ?? 4e3,
|
|
1018
1018
|
...e.host === void 0 ? {} : { host: e.host },
|
|
1019
1019
|
path: e.path ?? "/ws",
|
|
1020
|
-
tracerLayer:
|
|
1020
|
+
tracerLayer: Gt.layer,
|
|
1021
1021
|
security: be(e),
|
|
1022
|
-
...
|
|
1022
|
+
...ct,
|
|
1023
1023
|
healthCheck: {
|
|
1024
|
-
isReady: () =>
|
|
1025
|
-
...
|
|
1024
|
+
isReady: () => Kt,
|
|
1025
|
+
...qt ? { ping: qt } : {}
|
|
1026
1026
|
},
|
|
1027
|
-
...
|
|
1027
|
+
...Ot.length > 0 ? { httpRoutes: Ot } : {},
|
|
1028
1028
|
...e.getStore === void 0 ? {} : { getStore: e.getStore },
|
|
1029
1029
|
...Ae.size > 0 ? { webhookRoutes: Ae } : {},
|
|
1030
1030
|
...e.inspectRoute === void 0 ? {} : { inspectRoute: e.inspectRoute }
|
|
1031
|
-
}),
|
|
1032
|
-
if (await rr(
|
|
1031
|
+
}), Xt = Ai(Jt);
|
|
1032
|
+
if (await rr(Jt), (e.discovered.schedules?.length ?? 0) > 0) {
|
|
1033
1033
|
let t = (e.scheduleCoordination ?? "single") === "advisoryLock" ? hr(e.store, e.scheduleReplicaId ?? `pid-${process.pid}`) : Wr;
|
|
1034
1034
|
le = await Kr(e.discovered.schedules ?? [], {
|
|
1035
1035
|
store: e.store,
|
|
@@ -1039,7 +1039,7 @@ var wi = (e, t, n = [], r = 0) => {
|
|
|
1039
1039
|
armSelf: e.scheduleArmSelf ?? !0,
|
|
1040
1040
|
dormancy: e.dormancy ?? "always-on",
|
|
1041
1041
|
...e.dormancyTenantId === void 0 ? {} : { dormancyTenantId: e.dormancyTenantId },
|
|
1042
|
-
buildContext: ({ traceId: t, scheduleName: n, subject: r }) =>
|
|
1042
|
+
buildContext: ({ traceId: t, scheduleName: n, subject: r }) => Je({
|
|
1043
1043
|
subject: r,
|
|
1044
1044
|
traceId: t
|
|
1045
1045
|
}, e.store, void 0, `schedule:${n}`),
|
|
@@ -1059,9 +1059,9 @@ var wi = (e, t, n = [], r = 0) => {
|
|
|
1059
1059
|
...e.onScheduleRunEvent === void 0 ? {} : { onRunEvent: e.onScheduleRunEvent }
|
|
1060
1060
|
}), e.onSchedulerReady?.(le);
|
|
1061
1061
|
}
|
|
1062
|
-
let
|
|
1063
|
-
if ((e.discovered.subscribers?.length ?? 0) > 0 && (
|
|
1064
|
-
let t =
|
|
1062
|
+
let N = e.log ?? P({ scope: "voltro:serve" }), Zt, Qt;
|
|
1063
|
+
if ((e.discovered.subscribers?.length ?? 0) > 0 && (Zt = Fe(e.discovered.subscribers ?? [], e.store, N.child("subscribe"), e.schemaRegistry, S.bus)), (e.discovered.reactions?.length ?? 0) > 0) {
|
|
1064
|
+
let t = N.child("reaction"), n = async (n, r) => {
|
|
1065
1065
|
if (n.kind === "workflow") {
|
|
1066
1066
|
if (_ === void 0) {
|
|
1067
1067
|
t.warn("reaction workflow act skipped — no workflow engine in this app", { workflow: n.workflow });
|
|
@@ -1074,178 +1074,178 @@ var wi = (e, t, n = [], r = 0) => {
|
|
|
1074
1074
|
}).start(n.workflow, e);
|
|
1075
1075
|
return;
|
|
1076
1076
|
}
|
|
1077
|
-
await
|
|
1077
|
+
await st(n.agent, r, {
|
|
1078
1078
|
findAgentSend: (t) => e.discovered.actions.find((e) => e.descriptor.name === `${t}.send`),
|
|
1079
|
-
runAction: (e, t, n) => Promise.resolve(
|
|
1080
|
-
makeSubject: (e) =>
|
|
1079
|
+
runAction: (e, t, n) => Promise.resolve(ht(e, t, n)),
|
|
1080
|
+
makeSubject: (e) => Dn(e),
|
|
1081
1081
|
now: () => Date.now(),
|
|
1082
1082
|
log: t
|
|
1083
1083
|
});
|
|
1084
1084
|
}, r = async (n, r) => {
|
|
1085
1085
|
try {
|
|
1086
1086
|
let { requireAiBudget: t } = await import("@voltro/ai");
|
|
1087
|
-
return (await
|
|
1087
|
+
return (await H.runPromise(H.either(t(e.store, {
|
|
1088
1088
|
tenantId: n,
|
|
1089
1089
|
limitUsd: r
|
|
1090
1090
|
}))))._tag === "Right";
|
|
1091
1091
|
} catch (e) {
|
|
1092
1092
|
return t.warn("reaction budget check failed — refusing the act", { tenantId: n }, e), !1;
|
|
1093
1093
|
}
|
|
1094
|
-
}, i =
|
|
1095
|
-
|
|
1094
|
+
}, i = dt(e.store, { onError: (e) => t.warn("reaction: rate-slot claim failed; refusing the act", { cause: String(e) }) });
|
|
1095
|
+
Qt = l(e.discovered.reactions ?? [], e.store, {
|
|
1096
1096
|
runAct: n,
|
|
1097
1097
|
checkBudget: r,
|
|
1098
1098
|
claimRateSlot: (e) => i.claim(e)
|
|
1099
1099
|
}, t);
|
|
1100
1100
|
}
|
|
1101
|
-
let
|
|
1102
|
-
(e.discovered.aggregates?.length ?? 0) > 0 && (
|
|
1101
|
+
let $t;
|
|
1102
|
+
(e.discovered.aggregates?.length ?? 0) > 0 && ($t = await Ee({
|
|
1103
1103
|
discovered: e.discovered.aggregates ?? [],
|
|
1104
1104
|
store: e.store,
|
|
1105
|
-
log:
|
|
1105
|
+
log: N.child("aggregate"),
|
|
1106
1106
|
...e.analytics === void 0 ? {} : { analytics: e.analytics },
|
|
1107
1107
|
...e.aggregateStorage === void 0 ? {} : { storage: e.aggregateStorage },
|
|
1108
1108
|
...e.aggregateCoordinator === void 0 ? {} : { coordinator: e.aggregateCoordinator }
|
|
1109
|
-
}),
|
|
1110
|
-
let
|
|
1111
|
-
(e.discovered.expectations?.length ?? 0) > 0 && (
|
|
1109
|
+
}), Ye = U.succeed(Jn, $t.registry));
|
|
1110
|
+
let en;
|
|
1111
|
+
(e.discovered.expectations?.length ?? 0) > 0 && (en = er({
|
|
1112
1112
|
discovered: e.discovered.expectations ?? [],
|
|
1113
1113
|
store: e.store,
|
|
1114
|
-
log:
|
|
1115
|
-
}),
|
|
1114
|
+
log: N.child("expectation")
|
|
1115
|
+
}), Xe = U.succeed(K, en.registry)), (e.discovered.budgets?.length ?? 0) > 0 && (n = nr({
|
|
1116
1116
|
discovered: e.discovered.budgets ?? [],
|
|
1117
|
-
log:
|
|
1118
|
-
}),
|
|
1119
|
-
let
|
|
1120
|
-
return (e.discovered.experiments?.length ?? 0) > 0 && (
|
|
1117
|
+
log: N.child("finops")
|
|
1118
|
+
}), Ze = U.succeed(Yn, n.registry));
|
|
1119
|
+
let tn;
|
|
1120
|
+
return (e.discovered.experiments?.length ?? 0) > 0 && (tn = tr({
|
|
1121
1121
|
discovered: e.discovered.experiments ?? [],
|
|
1122
1122
|
store: e.store,
|
|
1123
|
-
log:
|
|
1124
|
-
}),
|
|
1123
|
+
log: N.child("experiment")
|
|
1124
|
+
}), et = U.succeed(q, tn.registry)), Kt = !0, e.bootTiming?.mark("ready"), {
|
|
1125
1125
|
dispatcher: r,
|
|
1126
|
-
server:
|
|
1126
|
+
server: Jt,
|
|
1127
1127
|
scheduler: le,
|
|
1128
1128
|
eventsSnapshot: ge(S.bus, S.declared),
|
|
1129
1129
|
membersSnapshot: () => ({
|
|
1130
1130
|
members: We.membership.list(),
|
|
1131
1131
|
capturedAt: Date.now()
|
|
1132
1132
|
}),
|
|
1133
|
-
agentTools: () =>
|
|
1134
|
-
rpcMetrics: () =>
|
|
1133
|
+
agentTools: () => Ct,
|
|
1134
|
+
rpcMetrics: () => C,
|
|
1135
1135
|
webhooksService: () => we,
|
|
1136
1136
|
runCanceller: () => d(),
|
|
1137
1137
|
flowControlHealth: () => f?.cancelHealth(),
|
|
1138
1138
|
inferenceHealth: () => ee?.health(),
|
|
1139
|
-
workflowWriteActions: () => _ === void 0 ||
|
|
1139
|
+
workflowWriteActions: () => _ === void 0 || A === void 0 ? void 0 : h({
|
|
1140
1140
|
store: e.store,
|
|
1141
|
-
log:
|
|
1141
|
+
log: N,
|
|
1142
1142
|
workflows: e.discovered.workflows ?? [],
|
|
1143
1143
|
workflowsProxy: c,
|
|
1144
1144
|
workflowRuntime: p,
|
|
1145
|
-
workflowRunRecorder:
|
|
1146
|
-
closeChildrenForParent:
|
|
1145
|
+
workflowRunRecorder: A,
|
|
1146
|
+
closeChildrenForParent: Rt
|
|
1147
1147
|
}),
|
|
1148
1148
|
redriveWorkflowRun: (e) => te ? te(e) : Promise.reject(/* @__PURE__ */ Error("redrive: this app registers no workflows")),
|
|
1149
1149
|
resumeWorkflowRunFromStep: (e) => se ? se(e) : Promise.reject(/* @__PURE__ */ Error("resume-from-step: this app registers no workflows")),
|
|
1150
1150
|
close: async () => {
|
|
1151
|
-
|
|
1151
|
+
Kt = !1, await Xt.drainRequests();
|
|
1152
1152
|
for (let e of Ne) try {
|
|
1153
1153
|
await e();
|
|
1154
1154
|
} catch (e) {
|
|
1155
|
-
|
|
1155
|
+
N.warn("serve: teardown step failed", {}, e);
|
|
1156
1156
|
}
|
|
1157
|
-
await qe?.detach(), await We.detach(),
|
|
1157
|
+
await qe?.detach(), await We.detach(), $t?.detach(), en?.detach(), n?.detach(), tn?.detach(), Qt?.(), Zt?.(), await le?.shutdown(), r.close(), await ce?.detach(), await p?.dispose(), await Yt(), await Xt.finish();
|
|
1158
1158
|
}
|
|
1159
1159
|
};
|
|
1160
|
-
}, $ =
|
|
1161
|
-
let t =
|
|
1162
|
-
if (
|
|
1160
|
+
}, $ = P({ scope: "voltro:serve" }), qi = (e, t, n) => (e === "production" || e === "staging") && t !== "memory" && n !== "0", Ji = Rt, Yi = async (e) => {
|
|
1161
|
+
let t = vn(process.cwd());
|
|
1162
|
+
if (Cn(t)) {
|
|
1163
1163
|
let n;
|
|
1164
1164
|
try {
|
|
1165
|
-
let e = await import(
|
|
1165
|
+
let e = await import(wn(t).href);
|
|
1166
1166
|
typeof e.runServe == "function" ? n = e.runServe : $.warn("serve bundle has no runServe export — using the standard serve path");
|
|
1167
1167
|
} catch (e) {
|
|
1168
1168
|
$.warn("serve bundle failed to load — using the standard serve path", {}, e);
|
|
1169
1169
|
}
|
|
1170
1170
|
if (n) return $.info("serve: booting from the precompiled serve bundle"), n(e);
|
|
1171
1171
|
}
|
|
1172
|
-
return
|
|
1173
|
-
},
|
|
1174
|
-
let s =
|
|
1172
|
+
return Xi(e);
|
|
1173
|
+
}, Xi = async (o) => {
|
|
1174
|
+
let s = yn();
|
|
1175
1175
|
e("serve");
|
|
1176
1176
|
try {
|
|
1177
|
-
|
|
1177
|
+
ai();
|
|
1178
1178
|
} catch (e) {
|
|
1179
|
-
throw
|
|
1179
|
+
throw Vt(e instanceof Error ? e.message : String(e));
|
|
1180
1180
|
}
|
|
1181
|
-
let l = process.cwd(), u = await Ue(l), ne =
|
|
1181
|
+
let l = process.cwd(), u = await Ue(l), ne = zt({
|
|
1182
1182
|
kind: "api",
|
|
1183
1183
|
configPort: u?.port,
|
|
1184
1184
|
env: process.env,
|
|
1185
|
-
flagPort:
|
|
1185
|
+
flagPort: Ji(o, "--port")
|
|
1186
1186
|
});
|
|
1187
1187
|
for (let e of ne.warnings) $.warn(e);
|
|
1188
1188
|
let re = ne.port;
|
|
1189
|
-
Vr(zr(u?.secrets)), await
|
|
1189
|
+
Vr(zr(u?.secrets)), await Ht({
|
|
1190
1190
|
rawEnv: u?.env,
|
|
1191
1191
|
appType: "api",
|
|
1192
1192
|
root: l,
|
|
1193
1193
|
log: $,
|
|
1194
1194
|
generateTypes: !1
|
|
1195
1195
|
}), s.mark("config");
|
|
1196
|
-
let m = (process.env.DB_DIALECT ?? u?.store ?? "memory").toLowerCase(), ie = (m === "mariadb" || m === "postgres" || m === "mssql") && (process.env.CDC ?? "1") !== "0", ae = m === "mariadb" ? "mariadb" : m === "mssql" ? "mssql" : void 0, oe =
|
|
1197
|
-
if (!r() &&
|
|
1198
|
-
let e = await import(
|
|
1196
|
+
let m = (process.env.DB_DIALECT ?? u?.store ?? "memory").toLowerCase(), ie = (m === "mariadb" || m === "postgres" || m === "mssql") && (process.env.CDC ?? "1") !== "0", ae = m === "mariadb" ? "mariadb" : m === "mssql" ? "mssql" : void 0, oe = _n(l);
|
|
1197
|
+
if (!r() && Cn(oe)) try {
|
|
1198
|
+
let e = await import(wn(oe).href);
|
|
1199
1199
|
if (e.modules) {
|
|
1200
1200
|
let t = {};
|
|
1201
|
-
for (let [n, r] of Object.entries(e.modules)) t[
|
|
1201
|
+
for (let [n, r] of Object.entries(e.modules)) t[Sn(l, n)] = r;
|
|
1202
1202
|
n(t), $.info("precompiled api bundle loaded", { modules: Object.keys(t).length });
|
|
1203
1203
|
}
|
|
1204
1204
|
} catch (e) {
|
|
1205
1205
|
$.warn("precompiled api bundle failed to load — falling back to source", {}, e);
|
|
1206
1206
|
}
|
|
1207
|
-
let h = await
|
|
1207
|
+
let h = await Ye(l), g = await Dt(h, { cdc: ie && ae !== void 0 }), de = ce(g);
|
|
1208
1208
|
{
|
|
1209
1209
|
let e = /* @__PURE__ */ new Set([
|
|
1210
1210
|
...g.queries.filter((e) => e.descriptor.overridesPlugin === !0).map((e) => e.descriptor.name),
|
|
1211
1211
|
...g.mutations.filter((e) => e.descriptor.overridesPlugin === !0).map((e) => e.descriptor.name),
|
|
1212
1212
|
...g.actions.filter((e) => e.descriptor.overridesPlugin === !0).map((e) => e.descriptor.name)
|
|
1213
1213
|
]);
|
|
1214
|
-
qt(
|
|
1214
|
+
Jt(qt(u?.plugins ?? []), [
|
|
1215
1215
|
...g.queries.map((e) => e.descriptor.name),
|
|
1216
1216
|
...g.mutations.map((e) => e.descriptor.name),
|
|
1217
1217
|
...g.actions.map((e) => e.descriptor.name),
|
|
1218
1218
|
...g.streams.map((e) => e.descriptor.name)
|
|
1219
1219
|
], e);
|
|
1220
1220
|
let t = se(g.serverOnlyLeaks, Ae(process.env, "strict"), lr, "`voltro serve`");
|
|
1221
|
-
if (t.action === "fail") throw
|
|
1221
|
+
if (t.action === "fail") throw Vt(t.message ?? "");
|
|
1222
1222
|
t.action === "warn" && $.warn(t.message ?? "");
|
|
1223
1223
|
}
|
|
1224
|
-
let pe = h.filter((e) =>
|
|
1224
|
+
let pe = h.filter((e) => hn.test(e)), me = pe.length > 0 ? await mn(pe, $.child("webhooks")) : {
|
|
1225
1225
|
outgoing: [],
|
|
1226
1226
|
incoming: [],
|
|
1227
1227
|
providers: []
|
|
1228
|
-
}, ge =
|
|
1228
|
+
}, ge = fn(g.events), xe = me.outgoing.length + me.incoming.length + me.providers.length + ge.length === 0 ? void 0 : {
|
|
1229
1229
|
...me,
|
|
1230
1230
|
outgoing: [...me.outgoing, ...ge]
|
|
1231
|
-
}, Ee =
|
|
1231
|
+
}, Ee = en({
|
|
1232
1232
|
nodeEnv: process.env.NODE_ENV,
|
|
1233
1233
|
cdcDialect: ae,
|
|
1234
1234
|
declared: u?.schema
|
|
1235
|
-
}), De =
|
|
1235
|
+
}), De = Xt({
|
|
1236
1236
|
gates: Ee,
|
|
1237
1237
|
runtime: {
|
|
1238
1238
|
traces: ye(),
|
|
1239
1239
|
undo: Jr()
|
|
1240
1240
|
}
|
|
1241
1241
|
});
|
|
1242
|
-
if (De !== void 0) throw
|
|
1243
|
-
let Oe =
|
|
1242
|
+
if (De !== void 0) throw Vt(`serve: ${De}`);
|
|
1243
|
+
let Oe = $t({
|
|
1244
1244
|
mix: g.featureMix,
|
|
1245
1245
|
plugins: u?.plugins ?? [],
|
|
1246
1246
|
gates: Ee,
|
|
1247
1247
|
...ae ? { cdcDialect: ae } : {}
|
|
1248
|
-
}), ke = u?.analytics !== void 0 && u.analytics.kind !== "noop" && m !== "memory" ? (await
|
|
1248
|
+
}), ke = u?.analytics !== void 0 && u.analytics.kind !== "noop" && m !== "memory" ? (await j(m)).makeSqlLayer(w()) : void 0, je = await Ie({
|
|
1249
1249
|
spec: u?.analytics,
|
|
1250
1250
|
sqlLayer: ke,
|
|
1251
1251
|
log: $
|
|
@@ -1254,7 +1254,7 @@ var wi = (e, t, n = [], r = 0) => {
|
|
|
1254
1254
|
for (let n of [...Oe, ...je.tables]) e.has(n.tableName) || (e.add(n.tableName), t.push(n));
|
|
1255
1255
|
return t;
|
|
1256
1256
|
})();
|
|
1257
|
-
for (let e of y)
|
|
1257
|
+
for (let e of y) qn(e);
|
|
1258
1258
|
{
|
|
1259
1259
|
let e = ur(Yr(g.queries.map((e) => ({
|
|
1260
1260
|
name: e.descriptor.name,
|
|
@@ -1266,27 +1266,27 @@ var wi = (e, t, n = [], r = 0) => {
|
|
|
1266
1266
|
e !== void 0 && $.warn(e);
|
|
1267
1267
|
}
|
|
1268
1268
|
let Me = (process.env.NODE_ENV ?? "").toLowerCase();
|
|
1269
|
-
if (
|
|
1270
|
-
let e = (await
|
|
1269
|
+
if (qi(Me, m, process.env.VOLTRO_AUTO_MIGRATE)) {
|
|
1270
|
+
let e = (await j(m)).makeSqlLayer(w()), t = await H.runPromise(Rn.SqlClient.pipe(H.flatMap((e) => Vn(e, l)), H.provide(e), H.catchAll(() => H.succeed([]))));
|
|
1271
1271
|
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));
|
|
1272
|
-
let n = await
|
|
1272
|
+
let n = await H.runPromise(Rn.SqlClient.pipe(H.flatMap((e) => Hn(e, y, {
|
|
1273
1273
|
appliedBy: `serve:${Me}`,
|
|
1274
1274
|
environment: "prod",
|
|
1275
1275
|
dialectId: m
|
|
1276
|
-
})),
|
|
1277
|
-
n.kind === "prod-mismatch" && ($.error(
|
|
1276
|
+
})), H.provide(e)));
|
|
1277
|
+
n.kind === "prod-mismatch" && ($.error(Bn(n, m)), $.error(Zt({
|
|
1278
1278
|
gates: Ee,
|
|
1279
1279
|
nodeEnv: process.env.NODE_ENV,
|
|
1280
1280
|
cdcDialect: ae,
|
|
1281
1281
|
declared: u?.schema
|
|
1282
|
-
})), $.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(
|
|
1282
|
+
})), $.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(Bn(n, m));
|
|
1283
1283
|
}
|
|
1284
|
-
await
|
|
1284
|
+
await Kt({
|
|
1285
1285
|
dialectId: m,
|
|
1286
1286
|
tables: y,
|
|
1287
|
-
mode:
|
|
1288
|
-
lockSchema:
|
|
1289
|
-
makeLayer: async () => (await
|
|
1287
|
+
mode: M(u?.reactiveTriggers),
|
|
1288
|
+
lockSchema: w().schema,
|
|
1289
|
+
makeLayer: async () => (await j(m)).makeSqlLayer(w()),
|
|
1290
1290
|
log: {
|
|
1291
1291
|
info: (e, t) => $.info(e, t ?? {}),
|
|
1292
1292
|
warn: (e, t) => $.warn(e, t ?? {})
|
|
@@ -1294,12 +1294,12 @@ var wi = (e, t, n = [], r = 0) => {
|
|
|
1294
1294
|
});
|
|
1295
1295
|
let Fe = jr(y);
|
|
1296
1296
|
s.mark("discover");
|
|
1297
|
-
let b = await
|
|
1298
|
-
for (let e of
|
|
1297
|
+
let b = await C(u, void 0), Le = Qr(b, m);
|
|
1298
|
+
for (let e of Xe({
|
|
1299
1299
|
dialect: String(u?.store ?? process.env.DB_DIALECT ?? "postgres"),
|
|
1300
1300
|
changeStrategy: (process.env.CDC ?? "1") === "0" ? "inline" : "cdc",
|
|
1301
1301
|
dbUrl: process.env.DB_URL,
|
|
1302
|
-
crossReplicaBus:
|
|
1302
|
+
crossReplicaBus: _i(u?.plugins ?? [])?.broadcast.crossReplica === !0,
|
|
1303
1303
|
tables: g.tables.map((e) => ({
|
|
1304
1304
|
tableName: e.tableName,
|
|
1305
1305
|
isReactive: e.isReactive === !0
|
|
@@ -1310,8 +1310,8 @@ var wi = (e, t, n = [], r = 0) => {
|
|
|
1310
1310
|
})
|
|
1311
1311
|
})) e.level === "warn" ? $.warn(e.message) : $.info(e.message);
|
|
1312
1312
|
{
|
|
1313
|
-
let e = S(
|
|
1314
|
-
tables:
|
|
1313
|
+
let e = S(Ot({
|
|
1314
|
+
tables: Wn().map((e) => ({ tableName: e.tableName })),
|
|
1315
1315
|
queries: g.queries.map((e) => ({
|
|
1316
1316
|
name: e.descriptor.name,
|
|
1317
1317
|
source: e.descriptor.source
|
|
@@ -1320,146 +1320,146 @@ var wi = (e, t, n = [], r = 0) => {
|
|
|
1320
1320
|
e !== void 0 && $.warn(e);
|
|
1321
1321
|
}
|
|
1322
1322
|
u?.cache && !process.env.CACHE_BACKEND && (process.env.CACHE_BACKEND = u.cache), u?.cacheRedisUrl && !process.env.CACHE_REDIS_URL && (process.env.CACHE_REDIS_URL = u.cacheRedisUrl), u?.cacheRedisDriver && !process.env.CACHE_REDIS_DRIVER && (process.env.CACHE_REDIS_DRIVER = u.cacheRedisDriver), u?.cacheKeyPrefix && !process.env.CACHE_KEY_PREFIX && (process.env.CACHE_KEY_PREFIX = u.cacheKeyPrefix);
|
|
1323
|
-
let { service: ze, invalidationBus: He, snapshotCache: Ge, cache: Ke, semantic:
|
|
1323
|
+
let { service: ze, invalidationBus: He, snapshotCache: Ge, cache: Ke, semantic: $e, evictSource: rt, backend: it, stats: ot, dispose: st } = await ut({
|
|
1324
1324
|
env: process.env,
|
|
1325
1325
|
semantic: u?.cacheSemantic ?? !1
|
|
1326
1326
|
});
|
|
1327
|
-
|
|
1328
|
-
if (
|
|
1327
|
+
$e !== void 0 && $.info("semantic cache enabled — reactive eviction on live writes"), $.info(`cache backend resolved: ${it}` + (it === "redis" ? ` (driver ${process.env.CACHE_REDIS_DRIVER ?? "resp"})` : " — in-process, not cross-instance")), b.onChange((e) => {
|
|
1328
|
+
if (H.runFork(He.publish(e.table)), rt !== void 0) {
|
|
1329
1329
|
let t = (e.new ?? e.old)?.id;
|
|
1330
|
-
|
|
1330
|
+
rt({
|
|
1331
1331
|
table: e.table,
|
|
1332
1332
|
op: e.op,
|
|
1333
1333
|
...t === void 0 ? {} : { id: t }
|
|
1334
1334
|
});
|
|
1335
1335
|
}
|
|
1336
1336
|
}), u?.kv && !process.env.KV_BACKEND && (process.env.KV_BACKEND = u.kv), u?.kvRedisUrl && !process.env.KV_REDIS_URL && (process.env.KV_REDIS_URL = u.kvRedisUrl), u?.kvKeyPrefix && !process.env.KV_KEY_PREFIX && (process.env.KV_KEY_PREFIX = u.kvKeyPrefix);
|
|
1337
|
-
let { kv:
|
|
1338
|
-
$.info(
|
|
1339
|
-
let
|
|
1337
|
+
let { kv: dt, service: _t } = await yr({ store: b });
|
|
1338
|
+
$.info(Ti(Wt(), Di(), m === "postgres" && (process.env.CDC ?? "1") !== "0" ? [{ reason: "CDC LISTEN consumer" }] : [], t.replicationSnapshot()?.replicaCount ?? 0)), s.mark("store");
|
|
1339
|
+
let bt = $n({
|
|
1340
1340
|
store: b,
|
|
1341
1341
|
sink: je.sink,
|
|
1342
1342
|
log: $
|
|
1343
|
-
}),
|
|
1343
|
+
}), wt = We({
|
|
1344
1344
|
store: b,
|
|
1345
1345
|
dialect: m,
|
|
1346
1346
|
log: { info: (e) => $.info(e) }
|
|
1347
|
-
}),
|
|
1348
|
-
m !== "memory" && (
|
|
1349
|
-
let
|
|
1347
|
+
}), O = u?.plugins ?? [], kt = process.env.POD_NAME ?? process.env.HOSTNAME ?? `serve-${process.pid}`, It, Lt;
|
|
1348
|
+
m !== "memory" && (It = Ln.make((await j(m)).makeSqlLayer(w())), Lt = await It.runPromise(Rn.SqlClient));
|
|
1349
|
+
let Rt = [
|
|
1350
1350
|
"postgres",
|
|
1351
1351
|
"mariadb",
|
|
1352
1352
|
"mysql",
|
|
1353
1353
|
"mssql"
|
|
1354
|
-
].includes(m) ? hr(b,
|
|
1355
|
-
maxIdleIntervalMs:
|
|
1356
|
-
coordinator:
|
|
1357
|
-
replicaId:
|
|
1354
|
+
].includes(m) ? hr(b, kt, $) : Wr, pn = Re(u?.scheduling), vn = xr({
|
|
1355
|
+
maxIdleIntervalMs: pn.pollCeilingMs,
|
|
1356
|
+
coordinator: Rt,
|
|
1357
|
+
replicaId: kt,
|
|
1358
1358
|
log: $
|
|
1359
|
-
}),
|
|
1359
|
+
}), bn = [], P = process.env.POD_NAME ?? process.env.HOSTNAME ?? `serve-${process.pid}`, Tn = _i(u?.plugins ?? [])?.broadcast?.provider, En = Qe(u?.plugins, u?.name ?? xn(l));
|
|
1360
1360
|
{
|
|
1361
|
-
let e =
|
|
1361
|
+
let e = tt(u?.plugins, u?.name ?? xn(l));
|
|
1362
1362
|
e !== void 0 && $.warn(e);
|
|
1363
1363
|
}
|
|
1364
|
-
let
|
|
1365
|
-
instanceId:
|
|
1366
|
-
namespace:
|
|
1364
|
+
let F = At(u?.plugins, {
|
|
1365
|
+
instanceId: P,
|
|
1366
|
+
namespace: En,
|
|
1367
1367
|
meta: { mode: "serve" },
|
|
1368
1368
|
logger: $
|
|
1369
|
-
}),
|
|
1370
|
-
...
|
|
1371
|
-
instanceId:
|
|
1372
|
-
membership:
|
|
1373
|
-
...
|
|
1374
|
-
broadcastChannels: { presence:
|
|
1369
|
+
}), Dn = {
|
|
1370
|
+
...Lt ? { sql: Lt } : {},
|
|
1371
|
+
instanceId: P,
|
|
1372
|
+
membership: F.membership,
|
|
1373
|
+
...Tn === void 0 ? {} : { broadcast: Tn },
|
|
1374
|
+
broadcastChannels: { presence: gi(En, "presence") },
|
|
1375
1375
|
scheduleCoordinated: (e, t, n) => {
|
|
1376
|
-
let r =
|
|
1377
|
-
return
|
|
1376
|
+
let r = vn(e, t, n);
|
|
1377
|
+
return bn.push(r), r;
|
|
1378
1378
|
}
|
|
1379
1379
|
};
|
|
1380
|
-
for (let e of
|
|
1380
|
+
for (let e of O) e.bindDataStore?.(Le, Dn);
|
|
1381
1381
|
c({
|
|
1382
1382
|
store: b,
|
|
1383
|
-
...
|
|
1383
|
+
...ct(),
|
|
1384
1384
|
log: $
|
|
1385
1385
|
});
|
|
1386
|
-
let
|
|
1387
|
-
if (
|
|
1386
|
+
let On = O.filter((e) => typeof e.onChangeEvent == "function");
|
|
1387
|
+
if (On.length > 0) {
|
|
1388
1388
|
let e = b.changeScope ?? "local";
|
|
1389
1389
|
b.onChange((t) => {
|
|
1390
1390
|
let n = _e(t, e);
|
|
1391
|
-
for (let e of
|
|
1391
|
+
for (let e of On) H.runFork(e.onChangeEvent(n).pipe(H.catchAllCause((t) => H.sync(() => $.warn(`plugin ${e.name} onChangeEvent failed`, { error: In.pretty(t) })))));
|
|
1392
1392
|
});
|
|
1393
1393
|
}
|
|
1394
|
-
let
|
|
1395
|
-
plugins:
|
|
1394
|
+
let I = le({
|
|
1395
|
+
plugins: O,
|
|
1396
1396
|
appName: u?.name ?? "voltro-api",
|
|
1397
1397
|
appType: "api",
|
|
1398
1398
|
voltroVersion: process.env.npm_package_version ?? "0.0.0",
|
|
1399
1399
|
log: $
|
|
1400
1400
|
});
|
|
1401
|
-
|
|
1402
|
-
let
|
|
1401
|
+
O.length && await I.activate(), s.mark("plugins");
|
|
1402
|
+
let L = await I.gatherObservability(), kn = {
|
|
1403
1403
|
info: (e, t) => process.stdout.write(`[broadcast] ${e} ${t ? JSON.stringify(t) : ""}\n`),
|
|
1404
1404
|
warn: (e, t) => process.stderr.write(`[broadcast] ${e} ${t ? JSON.stringify(t) : ""}\n`),
|
|
1405
1405
|
debug: () => {}
|
|
1406
|
-
},
|
|
1407
|
-
|
|
1408
|
-
}),
|
|
1409
|
-
|
|
1410
|
-
let
|
|
1411
|
-
prefix:
|
|
1412
|
-
...
|
|
1413
|
-
}) : void 0,
|
|
1406
|
+
}, An, jn = await vt(b, u, m, En, kn, (e, t) => {
|
|
1407
|
+
An?.refreshAll(`broadcast gap: missed ${t} change(s) from ${e}`);
|
|
1408
|
+
}), R = u?.apiKeys, Mn = (typeof R == "object" ? R.prefix : void 0) ?? "voltro_", z = R ? cr(b) : void 0, B = z ? _r({ flush: vr(z) }) : void 0;
|
|
1409
|
+
B && Fr(() => B.shutdown());
|
|
1410
|
+
let V = z ? gr(z, {
|
|
1411
|
+
prefix: Mn,
|
|
1412
|
+
...B ? { usage: B } : {}
|
|
1413
|
+
}) : void 0, Nn = V ? [dr(V, { prefix: Mn })] : [], Pn = D([...u?.auth?.strategies ?? [], ...Nn], mi(u?.plugins ?? []), u?.auth?.anonymousTenantRequired ?? !1, u?.auth, () => Le), Fn = [...u?.restRoutes ?? [], ...V ? Qn(V, (typeof R == "object" ? R.managementPath : void 0) ?? "/v1/api-keys") : []], Un = qe(u?.idempotency, b), Gn = O.map((e) => e.services).filter((e) => e !== void 0), W = U.mergeAll(xt({
|
|
1414
1414
|
analyticsLayer: je.layer,
|
|
1415
1415
|
cacheService: ze,
|
|
1416
|
-
kvService:
|
|
1417
|
-
|
|
1418
|
-
pluginServices:
|
|
1416
|
+
kvService: _t,
|
|
1417
|
+
...$e === void 0 ? {} : { semanticCache: $e },
|
|
1418
|
+
pluginServices: Gn,
|
|
1419
1419
|
userLayers: u?.layers ?? []
|
|
1420
|
-
}),
|
|
1420
|
+
}), ht(u?.http ?? {})), G = await at({
|
|
1421
1421
|
files: h,
|
|
1422
1422
|
store: b,
|
|
1423
1423
|
log: $,
|
|
1424
1424
|
seedPolicy: "report",
|
|
1425
|
-
seedPattern:
|
|
1426
|
-
loadSeedFiles:
|
|
1427
|
-
startupPattern:
|
|
1425
|
+
seedPattern: cn,
|
|
1426
|
+
loadSeedFiles: Gt,
|
|
1427
|
+
startupPattern: nn,
|
|
1428
1428
|
loadStartupFiles: a,
|
|
1429
1429
|
runStartups: i,
|
|
1430
1430
|
emailPattern: Be,
|
|
1431
|
-
loadEmailFiles:
|
|
1432
|
-
registerEmailTemplates:
|
|
1431
|
+
loadEmailFiles: T,
|
|
1432
|
+
registerEmailTemplates: hi
|
|
1433
1433
|
});
|
|
1434
|
-
(
|
|
1435
|
-
startups:
|
|
1436
|
-
emailTemplates:
|
|
1437
|
-
}),
|
|
1438
|
-
await
|
|
1434
|
+
(G.startupCount > 0 || G.emailCount > 0) && $.info("boot lifecycle", {
|
|
1435
|
+
startups: G.startupCount,
|
|
1436
|
+
emailTemplates: G.emailCount
|
|
1437
|
+
}), G.startups !== void 0 && Fr(async () => {
|
|
1438
|
+
await G.startups.stop();
|
|
1439
1439
|
});
|
|
1440
|
-
let
|
|
1441
|
-
schedules:
|
|
1440
|
+
let Jn = gt({
|
|
1441
|
+
schedules: St({
|
|
1442
1442
|
schedules: g.schedules,
|
|
1443
|
-
seeds:
|
|
1443
|
+
seeds: G.seeds,
|
|
1444
1444
|
store: b,
|
|
1445
1445
|
log: $.child("seeds")
|
|
1446
1446
|
}),
|
|
1447
1447
|
workflows: g.workflows ?? [],
|
|
1448
1448
|
log: $.child("workflow-schedules")
|
|
1449
|
-
}),
|
|
1449
|
+
}), Yn = u?.scheduling ?? {}, Xn = Yn.trigger ?? "self", Zn = /* @__PURE__ */ new Set([
|
|
1450
1450
|
"postgres",
|
|
1451
1451
|
"mysql",
|
|
1452
1452
|
"mariadb",
|
|
1453
1453
|
"mssql"
|
|
1454
|
-
]),
|
|
1455
|
-
|
|
1454
|
+
]), K = Yn.coordination ?? (Zn.has(m) ? "advisoryLock" : "single"), q = K === "cluster" && Zn.has(m), er = q ? "cluster" : K === "advisoryLock" && Zn.has(m) ? "advisoryLock" : "single";
|
|
1455
|
+
K === "cluster" && !q && $.warn("scheduling.coordination=cluster needs a sql-backed store except sqlite — falling back to single"), K === "advisoryLock" && !Zn.has(m) && $.warn("scheduling.coordination=advisoryLock needs a SQL store (the claim-row gate) — falling back to single");
|
|
1456
1456
|
let tr, nr = g.workflows.length > 0 || g.workflowWorkers.length > 0 || g.eventTriggers.length > 0 || (xe?.outgoing.length ?? 0) > 0 || q, rr;
|
|
1457
1457
|
if (nr) {
|
|
1458
1458
|
if (m === "mssql") {
|
|
1459
|
-
let e = await
|
|
1459
|
+
let e = await dn(process.cwd());
|
|
1460
1460
|
e && $.warn(e);
|
|
1461
1461
|
}
|
|
1462
|
-
let [{ WorkflowEngine: e }, { makeClusterCronLayer: t, workflowEngineLayer: n, resolveRunnerStorage: r, resolveFailoverTuning: i }] = await Promise.all([import("@effect/workflow"), import("@voltro/workflow/cluster")]), a = q ?
|
|
1462
|
+
let [{ WorkflowEngine: e }, { makeClusterCronLayer: t, workflowEngineLayer: n, resolveRunnerStorage: r, resolveFailoverTuning: i }] = await Promise.all([import("@effect/workflow"), import("@voltro/workflow/cluster")]), a = q ? Jn.filter((e) => (e.trigger ?? Xn) === "self").map((e) => t({
|
|
1463
1463
|
name: e.name,
|
|
1464
1464
|
cron: sr(e),
|
|
1465
1465
|
execute: async () => {
|
|
@@ -1467,9 +1467,9 @@ var wi = (e, t, n = [], r = 0) => {
|
|
|
1467
1467
|
}
|
|
1468
1468
|
})) : [];
|
|
1469
1469
|
rr = m === "memory" ? e.layerMemory : await (async () => {
|
|
1470
|
-
let e = await
|
|
1470
|
+
let e = await j(m), t = r({ sqliteFamily: e.id === "sqlite" || e.id === "turso" });
|
|
1471
1471
|
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({
|
|
1472
|
-
sqlClientLayer: e.makeSqlLayer(
|
|
1472
|
+
sqlClientLayer: e.makeSqlLayer(w()),
|
|
1473
1473
|
runnerStorage: t,
|
|
1474
1474
|
dialectId: e.id,
|
|
1475
1475
|
...process.env.VOLTRO_WORKFLOW_RUNNER_PORT ? { runnerListenPort: Number(process.env.VOLTRO_WORKFLOW_RUNNER_PORT) } : {},
|
|
@@ -1478,18 +1478,18 @@ var wi = (e, t, n = [], r = 0) => {
|
|
|
1478
1478
|
});
|
|
1479
1479
|
})();
|
|
1480
1480
|
}
|
|
1481
|
-
let J = ue(
|
|
1481
|
+
let J = ue(O, gn()), ir = h.filter((e) => /\.subscribe\.tsx?$/.test(e)), Y = ir.length > 0 ? await Ne(ir, $) : [], ar = h.filter((e) => /\.reaction\.tsx?$/.test(e)), or = ar.length > 0 ? await he(ar, $) : [], fr = h.filter((e) => on.test(e)), pr = fr.length > 0 ? await E(fr, $) : [], mr = h.filter((e) => /\.aggregate\.tsx?$/.test(e)), br = mr.length > 0 ? await p(mr, $) : [], Sr = ve();
|
|
1482
1482
|
if (br.length > 0 && m !== "memory") try {
|
|
1483
|
-
Sr =
|
|
1483
|
+
Sr = lt((await j(m)).makeSqlLayer(w()));
|
|
1484
1484
|
} catch (e) {
|
|
1485
1485
|
$.warn("aggregate: SQL storage init failed — falling back to in-process", { err: String(e) });
|
|
1486
1486
|
}
|
|
1487
|
-
let Cr = m === "memory" ? Wr : hr(b, `aggregate@${process.pid}`, $), wr = h.filter((e) =>
|
|
1487
|
+
let Cr = m === "memory" ? Wr : hr(b, `aggregate@${process.pid}`, $), wr = h.filter((e) => sn.test(e)), Tr = wr.length > 0 ? await ee(wr, $) : [], Er = h.filter((e) => an.test(e)), Dr = Er.length > 0 ? await Te(Er, $) : [], Or = h.filter((e) => rn.test(e)), kr = Or.length > 0 ? await Pt(Or, $) : [], Ar = [], Mr = [], Nr = h.filter((e) => Qt.test(e));
|
|
1488
1488
|
if (Nr.length > 0) {
|
|
1489
|
-
let e = $.child("agent"), t = h.filter((e) =>
|
|
1490
|
-
t.length > 0 && await
|
|
1491
|
-
let n = await
|
|
1492
|
-
for (let e of n.agents) for (let t of
|
|
1489
|
+
let e = $.child("agent"), t = h.filter((e) => N.test(e));
|
|
1490
|
+
t.length > 0 && await tn(t, e);
|
|
1491
|
+
let n = await Yt(Nr, e);
|
|
1492
|
+
for (let e of n.agents) for (let t of Je(e)) (t.kind === "action" ? Ar : Mr).push({
|
|
1493
1493
|
file: t.file,
|
|
1494
1494
|
descriptor: t.descriptor,
|
|
1495
1495
|
executor: t.executor
|
|
@@ -1501,10 +1501,10 @@ var wi = (e, t, n = [], r = 0) => {
|
|
|
1501
1501
|
let e = Z.workflowWriteActions();
|
|
1502
1502
|
if (e === void 0) throw Error("workflow actions: this app registers no workflows");
|
|
1503
1503
|
return e;
|
|
1504
|
-
}, Pr =
|
|
1504
|
+
}, Pr = Kn({
|
|
1505
1505
|
dialect: m,
|
|
1506
|
-
...
|
|
1507
|
-
}), Ir = m === "memory" ? void 0 : (await
|
|
1506
|
+
...w()
|
|
1507
|
+
}), Ir = m === "memory" ? void 0 : (await j(m)).makeSqlLayer(w()), Lr = async () => Et({
|
|
1508
1508
|
sqlLayer: Ir,
|
|
1509
1509
|
declared: y,
|
|
1510
1510
|
log: $
|
|
@@ -1512,15 +1512,15 @@ var wi = (e, t, n = [], r = 0) => {
|
|
|
1512
1512
|
kind: "api",
|
|
1513
1513
|
meta: {
|
|
1514
1514
|
name: u?.name ?? "voltro-api",
|
|
1515
|
-
voltroVersion:
|
|
1515
|
+
voltroVersion: Tt,
|
|
1516
1516
|
port: re,
|
|
1517
1517
|
mode: "start",
|
|
1518
1518
|
store: m,
|
|
1519
1519
|
cdc: ie ? "on" : "off",
|
|
1520
1520
|
...Pr === void 0 ? {} : { databaseId: Pr }
|
|
1521
1521
|
},
|
|
1522
|
-
rpc:
|
|
1523
|
-
workflows:
|
|
1522
|
+
rpc: pt(g, l),
|
|
1523
|
+
workflows: nt(g, l),
|
|
1524
1524
|
migrations: Lr,
|
|
1525
1525
|
events: () => Z.eventsSnapshot(),
|
|
1526
1526
|
agentTools: () => Z.agentTools(),
|
|
@@ -1538,25 +1538,25 @@ var wi = (e, t, n = [], r = 0) => {
|
|
|
1538
1538
|
},
|
|
1539
1539
|
inspectBackfillSchedule: te({
|
|
1540
1540
|
getHandle: () => tr,
|
|
1541
|
-
getSchedules: () =>
|
|
1541
|
+
getSchedules: () => Jn
|
|
1542
1542
|
}),
|
|
1543
1543
|
...xe === void 0 ? {} : { webhooks: () => _({
|
|
1544
1544
|
store: b,
|
|
1545
1545
|
discoveredWebhooks: xe
|
|
1546
1546
|
}) },
|
|
1547
1547
|
plugins: () => ({
|
|
1548
|
-
plugins:
|
|
1548
|
+
plugins: I.snapshot(),
|
|
1549
1549
|
capturedAt: Date.now()
|
|
1550
1550
|
}),
|
|
1551
|
-
env: () =>
|
|
1552
|
-
...u?.env !== void 0 &&
|
|
1551
|
+
env: () => Bt(u?.name ?? xn(l), {
|
|
1552
|
+
...u?.env !== void 0 && ii(u.env) ? { contract: u.env } : {},
|
|
1553
1553
|
plugins: u?.plugins ?? []
|
|
1554
1554
|
}),
|
|
1555
1555
|
dataCache: () => Ve({
|
|
1556
|
-
stats:
|
|
1557
|
-
backendKind:
|
|
1556
|
+
stats: ot,
|
|
1557
|
+
backendKind: it
|
|
1558
1558
|
}),
|
|
1559
|
-
subscriptions: () =>
|
|
1559
|
+
subscriptions: () => Ft(() => An),
|
|
1560
1560
|
inspectTables: () => fe(g.tables),
|
|
1561
1561
|
inspectRows: Ce({
|
|
1562
1562
|
store: b,
|
|
@@ -1564,20 +1564,20 @@ var wi = (e, t, n = [], r = 0) => {
|
|
|
1564
1564
|
mask: !0
|
|
1565
1565
|
}),
|
|
1566
1566
|
metrics: (e) => Z.rpcMetrics().snapshot(e),
|
|
1567
|
-
cluster: () =>
|
|
1567
|
+
cluster: () => k({
|
|
1568
1568
|
store: b,
|
|
1569
1569
|
dialect: m,
|
|
1570
1570
|
useClusterCron: q,
|
|
1571
|
-
scheduleCoordChoice:
|
|
1571
|
+
scheduleCoordChoice: K
|
|
1572
1572
|
}),
|
|
1573
1573
|
inspectSchedules: () => v({
|
|
1574
|
-
schedules:
|
|
1575
|
-
defaultTrigger:
|
|
1574
|
+
schedules: Jn,
|
|
1575
|
+
defaultTrigger: Xn,
|
|
1576
1576
|
coordination: er
|
|
1577
1577
|
}),
|
|
1578
|
-
inspectScheduleRuns: (e) =>
|
|
1578
|
+
inspectScheduleRuns: (e) => Nt(b, e),
|
|
1579
1579
|
...d(b, {
|
|
1580
|
-
controls:
|
|
1580
|
+
controls: mt(g.workflows ?? []),
|
|
1581
1581
|
active: (g.workflows?.length ?? 0) > 0,
|
|
1582
1582
|
cancellation: () => Z.flowControlHealth()
|
|
1583
1583
|
}),
|
|
@@ -1590,12 +1590,12 @@ var wi = (e, t, n = [], r = 0) => {
|
|
|
1590
1590
|
inspectRetryWorkflowRun: (e) => X().inspectRetryWorkflowRun(e),
|
|
1591
1591
|
inspectSignalWorkflowRun: (e) => X().inspectSignalWorkflowRun(e),
|
|
1592
1592
|
inspectUpdateWorkflowRun: (e) => X().inspectUpdateWorkflowRun(e),
|
|
1593
|
-
inspectInferences: (e) =>
|
|
1593
|
+
inspectInferences: (e) => Ze({
|
|
1594
1594
|
store: b,
|
|
1595
1595
|
active: (g.workflows?.length ?? 0) > 0,
|
|
1596
1596
|
dispatcher: () => Z.inferenceHealth()
|
|
1597
1597
|
}, e.limit === void 0 ? {} : { limit: e.limit }),
|
|
1598
|
-
...
|
|
1598
|
+
...yt({
|
|
1599
1599
|
store: b,
|
|
1600
1600
|
cancelRun: async (e) => await Z.runCanceller()?.(e) ?? !1,
|
|
1601
1601
|
retryRun: async (e) => X().inspectRetryWorkflowRun({ runId: e }),
|
|
@@ -1605,10 +1605,10 @@ var wi = (e, t, n = [], r = 0) => {
|
|
|
1605
1605
|
inspectRedriveWorkflowRun: (e) => Z.redriveWorkflowRun(e),
|
|
1606
1606
|
inspectResumeWorkflowRunFromStep: (e) => Z.resumeWorkflowRunFromStep(e)
|
|
1607
1607
|
}, Br = (process.env.VOLTRO_TENANT_ISOLATION ?? u?.tenancy?.isolation) === "namespace", Hr = Br && m !== "memory" ? await (async () => {
|
|
1608
|
-
let e = await
|
|
1609
|
-
return
|
|
1608
|
+
let e = await j(m);
|
|
1609
|
+
return Ct({
|
|
1610
1610
|
tables: y,
|
|
1611
|
-
sqlLayer: e.makeSqlLayer(
|
|
1611
|
+
sqlLayer: e.makeSqlLayer(w()),
|
|
1612
1612
|
dialect: m,
|
|
1613
1613
|
options: { retryFilter: e.retryFilter },
|
|
1614
1614
|
log: {
|
|
@@ -1616,10 +1616,10 @@ var wi = (e, t, n = [], r = 0) => {
|
|
|
1616
1616
|
error: (e, t, n) => $.error(e, t ?? {}, n)
|
|
1617
1617
|
}
|
|
1618
1618
|
});
|
|
1619
|
-
})() : void 0, Ur = await
|
|
1619
|
+
})() : void 0, Ur = await ft({
|
|
1620
1620
|
input: u?.tenancy?.residency,
|
|
1621
1621
|
namespaceIsolationOn: Br,
|
|
1622
|
-
makeStoreForUrl: (e, t) =>
|
|
1622
|
+
makeStoreForUrl: (e, t) => C(u, void 0, Ut(w(), t)),
|
|
1623
1623
|
log: {
|
|
1624
1624
|
info: (e, t) => $.info(e, t),
|
|
1625
1625
|
warn: (e, t) => $.warn(e, t)
|
|
@@ -1628,37 +1628,37 @@ var wi = (e, t, n = [], r = 0) => {
|
|
|
1628
1628
|
Ur !== void 0 && Fr(async () => {
|
|
1629
1629
|
await Ur.close();
|
|
1630
1630
|
});
|
|
1631
|
-
let Z = await
|
|
1631
|
+
let Z = await Ki({
|
|
1632
1632
|
bootTiming: s,
|
|
1633
|
-
broadcastNamespace:
|
|
1633
|
+
broadcastNamespace: En,
|
|
1634
1634
|
scheduling: (() => {
|
|
1635
|
-
let e =
|
|
1635
|
+
let e = pn;
|
|
1636
1636
|
return {
|
|
1637
1637
|
admissionDrainMs: e.admissionDrainMs,
|
|
1638
1638
|
inferenceTickMs: e.inferenceTickMs,
|
|
1639
1639
|
cancelSweepMs: e.cancelSweepMs,
|
|
1640
1640
|
stalenessSweepMs: e.stalenessSweepMs,
|
|
1641
|
-
disarmWhenIdle:
|
|
1641
|
+
disarmWhenIdle: et({
|
|
1642
1642
|
changeScope: b.changeScope,
|
|
1643
|
-
broadcastAttached:
|
|
1643
|
+
broadcastAttached: jn !== void 0
|
|
1644
1644
|
})
|
|
1645
1645
|
};
|
|
1646
1646
|
})(),
|
|
1647
1647
|
...u?.workflows?.staleness === void 0 ? {} : { workflowStaleness: u.workflows.staleness },
|
|
1648
1648
|
...u?.workflows?.suspendSignalHintMs === void 0 ? {} : { workflowSuspendSignalHintMs: u.workflows.suspendSignalHintMs },
|
|
1649
|
-
workflowRecording:
|
|
1649
|
+
workflowRecording: Mt(u?.workflows?.recording),
|
|
1650
1650
|
membership: {
|
|
1651
|
-
...
|
|
1652
|
-
instanceId:
|
|
1651
|
+
...F,
|
|
1652
|
+
instanceId: P
|
|
1653
1653
|
},
|
|
1654
1654
|
security: {
|
|
1655
|
-
defaultDeny:
|
|
1655
|
+
defaultDeny: A(u),
|
|
1656
1656
|
...be(u)
|
|
1657
1657
|
},
|
|
1658
1658
|
approvals: { defaultExpiryMs: Pe(u) },
|
|
1659
1659
|
...u?.plugins === void 0 ? {} : { plugins: u.plugins },
|
|
1660
|
-
...
|
|
1661
|
-
restRoutes:
|
|
1660
|
+
...Un ? { idempotency: Un } : {},
|
|
1661
|
+
restRoutes: Fn,
|
|
1662
1662
|
appProcedures: de,
|
|
1663
1663
|
discovered: {
|
|
1664
1664
|
queries: [...g.queries, ...Mr],
|
|
@@ -1669,7 +1669,7 @@ var wi = (e, t, n = [], r = 0) => {
|
|
|
1669
1669
|
workflows: g.workflows,
|
|
1670
1670
|
workflowWorkers: g.workflowWorkers,
|
|
1671
1671
|
eventTriggers: g.eventTriggers,
|
|
1672
|
-
schedules:
|
|
1672
|
+
schedules: Jn,
|
|
1673
1673
|
subscribers: Y,
|
|
1674
1674
|
outboxHandlers: pr,
|
|
1675
1675
|
connections: g.connections,
|
|
@@ -1685,29 +1685,29 @@ var wi = (e, t, n = [], r = 0) => {
|
|
|
1685
1685
|
aggregateStorage: Sr,
|
|
1686
1686
|
aggregateCoordinator: Cr,
|
|
1687
1687
|
store: b,
|
|
1688
|
-
kv:
|
|
1688
|
+
kv: dt,
|
|
1689
1689
|
cache: Ke,
|
|
1690
1690
|
snapshotCache: Ge,
|
|
1691
1691
|
...u?.reactive === void 0 ? {} : { reactive: u.reactive },
|
|
1692
1692
|
schemaRegistry: Fe,
|
|
1693
1693
|
tenantScopedTables: g.tenantScopedTables,
|
|
1694
1694
|
softDeleteScopedTables: g.softDeleteScopedTables,
|
|
1695
|
-
dataTransferSnapshot:
|
|
1695
|
+
dataTransferSnapshot: zn(y),
|
|
1696
1696
|
dataTransferDialect: m,
|
|
1697
1697
|
...Hr === void 0 ? {} : { ensureTenantProvisioned: Hr.ensure },
|
|
1698
1698
|
...Ur === void 0 ? {} : { resolveResidentStore: Ur.resolveStore },
|
|
1699
1699
|
tenantIsolation: (process.env.VOLTRO_TENANT_ISOLATION ?? u?.tenancy?.isolation) === "namespace" ? "namespace" : "shared-schema",
|
|
1700
|
-
resolveSubject: (e, t) =>
|
|
1700
|
+
resolveSubject: (e, t) => Pn({
|
|
1701
1701
|
headers: e,
|
|
1702
1702
|
clientId: t
|
|
1703
1703
|
}),
|
|
1704
1704
|
...u?.auth === void 0 ? {} : { authority: u.auth },
|
|
1705
1705
|
...u?.agents === void 0 ? {} : { agents: u.agents },
|
|
1706
|
-
httpRoutes:
|
|
1706
|
+
httpRoutes: O.flatMap((e) => e.httpRoutes ?? []),
|
|
1707
1707
|
getStore: () => Le,
|
|
1708
|
-
...
|
|
1708
|
+
...W ? { baseLayer: W } : {},
|
|
1709
1709
|
...rr === void 0 ? {} : { workflowEngineLayer: rr },
|
|
1710
|
-
scheduleDefaultTrigger:
|
|
1710
|
+
scheduleDefaultTrigger: Xn,
|
|
1711
1711
|
scheduleCoordination: er,
|
|
1712
1712
|
scheduleArmSelf: !q,
|
|
1713
1713
|
dormancy: process.env.VOLTRO_DORMANCY === "sleep" || process.env.VOLTRO_DORMANCY === "always-on" ? process.env.VOLTRO_DORMANCY : u?.dormancy ?? "always-on",
|
|
@@ -1719,7 +1719,7 @@ var wi = (e, t, n = [], r = 0) => {
|
|
|
1719
1719
|
inspectRoute: { handle: async (e, t, n, r) => await f(e, Rr, t, {
|
|
1720
1720
|
method: n,
|
|
1721
1721
|
...r === void 0 ? {} : { body: r }
|
|
1722
|
-
}) || ((n === "GET" ? await
|
|
1722
|
+
}) || ((n === "GET" ? await un(e, Rr, t, { method: n }) : null) ?? ln(e, Rr, t, {
|
|
1723
1723
|
method: n,
|
|
1724
1724
|
...r === void 0 ? {} : { body: r }
|
|
1725
1725
|
}) ?? {
|
|
@@ -1728,11 +1728,11 @@ var wi = (e, t, n = [], r = 0) => {
|
|
|
1728
1728
|
body: JSON.stringify({ error: "not an inspect route" })
|
|
1729
1729
|
}) },
|
|
1730
1730
|
...u?.name === void 0 ? {} : { appName: u.name },
|
|
1731
|
-
observability:
|
|
1731
|
+
observability: L,
|
|
1732
1732
|
port: re,
|
|
1733
1733
|
...u?.transport?.wsPath ? { path: u.transport.wsPath } : {}
|
|
1734
1734
|
});
|
|
1735
|
-
return
|
|
1735
|
+
return An = Z.dispatcher, jt(x([
|
|
1736
1736
|
g.queries,
|
|
1737
1737
|
g.mutations,
|
|
1738
1738
|
g.actions,
|
|
@@ -1747,14 +1747,14 @@ var wi = (e, t, n = [], r = 0) => {
|
|
|
1747
1747
|
streams: g.streams.length,
|
|
1748
1748
|
workflows: g.workflows.length,
|
|
1749
1749
|
workflowWorkers: g.workflowWorkers.length,
|
|
1750
|
-
schedules:
|
|
1750
|
+
schedules: Jn.length,
|
|
1751
1751
|
scheduleCoordination: er
|
|
1752
1752
|
}), s.finish($), Fr(async () => {
|
|
1753
|
-
for (let e of
|
|
1754
|
-
|
|
1753
|
+
for (let e of bn) e.stop();
|
|
1754
|
+
wt.stop();
|
|
1755
1755
|
try {
|
|
1756
|
-
await Z.close(),
|
|
1757
|
-
mirror:
|
|
1756
|
+
await Z.close(), st(), It?.dispose(), await I.deactivate(), await jn?.close(), await Se({
|
|
1757
|
+
mirror: bt,
|
|
1758
1758
|
log: $
|
|
1759
1759
|
}), await je.dispose(), await b.close?.();
|
|
1760
1760
|
} catch (e) {
|
|
@@ -1763,4 +1763,4 @@ var wi = (e, t, n = [], r = 0) => {
|
|
|
1763
1763
|
}), await new Promise(() => {}), 0;
|
|
1764
1764
|
};
|
|
1765
1765
|
//#endregion
|
|
1766
|
-
export {
|
|
1766
|
+
export { Yi as n, qi as r, Xi as t };
|