@voltro/cli 0.38.0 → 0.39.1
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 +276 -0
- package/THIRD-PARTY-NOTICES.md +80 -45
- package/dist/{addCommand-BNeoeSxe.js → addCommand-C05L9tZh.js} +2 -2
- package/dist/addCommand-C3MdJG-a.js +2 -0
- package/dist/{agentsMd-mhQMF1bx.js → agentsMd-7zI2h5l9.js} +3 -3
- package/dist/agentsMd-BFCXh2gl.js +2 -0
- package/dist/apiBuild-BmR_bIxN.js +2 -0
- package/dist/{apiBuild-CvacV4zA.js → apiBuild-D9FB13_2.js} +3 -3
- package/dist/baselineCommand-CXv680Dc.js +2 -0
- package/dist/{baselineCommand-C6NMt-oa.js → baselineCommand-Ck2Xm8M7.js} +18 -18
- package/dist/bin.js +1 -1
- package/dist/{build-_LoTC1s0.js → build-DORV5mLM.js} +107 -100
- package/dist/{capabilitiesCommand-nq_pz5xd.js → capabilitiesCommand-D5gucwYa.js} +8 -8
- package/dist/{checkCommand-Pjk5sBl2.js → checkCommand-Bf6oMao4.js} +35 -35
- package/dist/{checkCommand-wibtQx-N.js → checkCommand-D9qK_gtA.js} +1 -1
- package/dist/{cloudCmd-NQSwe_Qk.js → cloudCmd-C42gaO8s.js} +16 -16
- package/dist/{clusterCmd-D5wsCmA_.js → clusterCmd-DrVFCzSj.js} +8 -4
- package/dist/{codegen-GYYcdpCg.js → codegen-CbpGCWLG.js} +1 -1
- package/dist/codegen-i8QGcHsi.js +2 -0
- package/dist/codegenCommand-CxOyKmc1.js +129 -0
- package/dist/{codemodRunner-CXgQ-ecJ.js → codemodRunner-D-jTyvWo.js} +622 -551
- package/dist/{commands-DaZVi9wi.js → commands-D6aW_6AR.js} +48 -48
- package/dist/{connectionConfig-UFlIEiys.js → connectionConfig-Bk9IC7D0.js} +1 -1
- package/dist/{dashboardCommand-Dxy_kmoW.js → dashboardCommand-CwTZh-XZ.js} +3 -3
- package/dist/{dataCommand-D6-Ha2lf.js → dataCommand-Cc9RiLQZ.js} +14 -11
- package/dist/{dbCommand-C4UW8cVN.js → dbCommand-DSwGv9wS.js} +50 -49
- package/dist/dbCommand-DcqEyxju.js +2 -0
- package/dist/{dev-E7Eo5GHc.js → dev-3mgc8c-H.js} +2260 -2184
- package/dist/dev-CjJAasDs.js +3 -0
- package/dist/{dialectDriver-CgXnDfec.js → dialectDriver-czCHYpeH.js} +2 -1
- package/dist/doctorCommand-Cghssndo.js +2 -0
- package/dist/{doctorCommand-gmDyALFL.js → doctorCommand-oLuzc-aC.js} +261 -244
- package/dist/{dormancyCommand-CE6wG8lj.js → dormancyCommand-Bxe4WtHU.js} +1 -1
- package/dist/{e2eCmd-BRabZww-.js → e2eCmd-uFHig1hV.js} +8 -2
- package/dist/{embeddingsCommand-C3uAuf6N.js → embeddingsCommand-CyNQkFIc.js} +6 -6
- package/dist/{envCommand-DzuWh8ya.js → envCommand-CAkSgBbh.js} +19 -19
- package/dist/{evolveCommand-DPLqcYb2.js → evolveCommand-CWhBoe_P.js} +6 -8
- package/dist/frameworkTableAssembly-DgylYh9_.js +2 -0
- package/dist/{generateCommand-DbgcUpGw.js → generateCommand-CcyvH2ve.js} +1 -1
- package/dist/index.js +1 -1
- package/dist/{infoCommand-CmczGj_l.js → infoCommand-CTo8Jnhq.js} +7 -7
- package/dist/inspect-B7U7Cl_Z.js +1192 -0
- package/dist/inspect-DUze25t0.js +2 -0
- package/dist/{inspectCmd-EHFZ9yYu.js → inspectCmd-niF97fAq.js} +5 -5
- package/dist/inspectGateHint-BjnFubmH.js +7 -0
- package/dist/{logFileSink-C_D2wRN1.js → logFileSink-B4uP8pvf.js} +1 -1
- package/dist/{logsCmd-D36xK7Zu.js → logsCmd-B6oNsfaZ.js} +10 -7
- package/dist/{manifestBuild-hpPLaGxV.js → manifestBuild-BK42hu0k.js} +1 -1
- package/dist/manifestBuild-j0n109tt.js +2 -0
- package/dist/{metaCommands-CIoQNlaQ.js → metaCommands-DUYR--Ts.js} +1 -1
- package/dist/{migrate-RwgUWXfc.js → migrate-BnPw2zC8.js} +7 -4
- package/dist/{packageCommand-Cug_3Ogl.js → packageCommand-9SVyvsSo.js} +3 -2
- package/dist/{probeCommand-BPEpwT32.js → probeCommand-C9gazU0H.js} +35 -24
- package/dist/{projectScaffold-CxgtJvlb.js → projectScaffold-BEhhHjPr.js} +1 -1
- package/dist/{projectScaffold-DDgWbNLe.js → projectScaffold-BvhLOrLq.js} +17 -15
- package/dist/{runtimeTrace-6jfznSzr.js → runtimeTrace-gNXeLf6H.js} +1 -1
- package/dist/{scheduleManifestCmd-D2x0CTTY.js → scheduleManifestCmd-kmWzrO_w.js} +6 -9
- package/dist/{sdkgen-CEJZZQUA.js → sdkgen-C8zz10-X.js} +4 -4
- package/dist/{seedRunner-ZmLSqNe2.js → seedRunner-IdHEprqf.js} +1 -4
- package/dist/serveCommand-BpK8-m1N.js +1770 -0
- package/dist/serveCommand-CW-goXvh.js +2 -0
- package/dist/serveEntry.js +2 -2
- package/dist/{serverlessCommand-CfJZy6dS.js → serverlessCommand-DbJ7Plg9.js} +3 -3
- package/dist/{start-CidwCcjl.js → start-BNuTWdRd.js} +1 -1
- package/dist/{start-RCh6qKFe.js → start-ft_KzFTd.js} +257 -254
- package/dist/startEntry.js +1 -1
- package/dist/{test-DIQ0jlkQ.js → test-CLYXrZ2F.js} +1 -1
- package/dist/{tracesCmd-DStmCJPi.js → tracesCmd-DgtgOUdi.js} +7 -4
- package/dist/{typecheckCommand-BlsWiCNq.js → typecheckCommand-BuCtT92o.js} +7 -7
- package/dist/updateCommand-6FMU2klq.js +2 -0
- package/dist/{updateCommand-CmksX7m_.js → updateCommand-CHBmCB17.js} +5 -3
- package/dist/{webDev-BKdD7c_a.js → webDev-CTpSY-e_.js} +813 -775
- package/dist/webDev-id3I5PvG.js +2 -0
- package/dist/{webhookDiscovery-D7VaeMlz.js → webhookDiscovery-CphsQe59.js} +4 -6
- package/dist/{webhookDiscovery-CrGAfhIG.js → webhookDiscovery-il9ti-HE.js} +1 -1
- package/dist/{webhooksCommand-BHeaF1ZJ.js → webhooksCommand-EccPZQZ4.js} +1 -1
- package/package.json +27 -21
- package/templates/AGENTS.md +2 -2
- package/templates/agent-docs/_index.md +2 -2
- package/templates/agent-docs/_manifest.json +2 -2
- package/templates/agent-docs/authentication.md +43 -4
- package/templates/agent-docs/cli.md +17 -13
- package/templates/agent-docs/data.md +44 -1
- package/templates/agent-docs/database/migrations.md +2 -2
- package/templates/agent-docs/database/seedsdialects.md +2 -2
- package/templates/agent-docs/deployment.md +21 -7
- package/templates/agent-docs/internationalization.md +10 -3
- package/templates/agent-docs/local-first-mobile.md +141 -20
- package/templates/agent-docs/plugins/mail.md +1 -1
- package/templates/agent-docs/plugins/ratelimit.md +1 -1
- package/templates/agent-docs/plugins.md +3 -1
- package/templates/agent-docs/releases.md +130 -1
- package/templates/agent-docs/routing.md +34 -2
- package/templates/agent-docs/templates/apibackends.md +1 -1
- package/templates/agent-docs/templates/mobile.md +1 -1
- package/templates/agent-docs/whats-new.md +26 -66
- 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-durable/startup/warm.startup.tsx +16 -2
- package/templates/apps/api-feature-flags/package.json +9 -9
- package/templates/apps/api-governance/package.json +8 -8
- package/templates/apps/api-kv/package.json +8 -8
- package/templates/apps/api-moderation/package.json +8 -8
- package/templates/apps/api-observability/package.json +8 -8
- package/templates/apps/api-ratelimit/package.json +8 -8
- package/templates/apps/api-rbac/authz.ts +16 -1
- 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/README.md +41 -17
- package/templates/apps/mobile-app/app.config.ts +1 -1
- package/templates/apps/mobile-app/package.json +15 -11
- package/templates/apps/mobile-app/src/app/_layout.tsx +44 -13
- package/templates/apps/mobile-app/src/app/index.tsx +1 -1
- package/templates/apps/mobile-app/src/app/settings.tsx +4 -1
- package/templates/apps/mobile-app/src/client.ts +74 -57
- package/templates/apps/mobile-app/src/lib/api.ts +4 -4
- package/templates/apps/mobile-app/src/lib/deeplinks.ts +6 -6
- package/templates/apps/mobile-app/src/persistence.ts +24 -3
- package/templates/apps/mobile-app/tsconfig.json +17 -3
- package/dist/addCommand-aXSQveak.js +0 -2
- package/dist/agentsMd-BTchIZku.js +0 -2
- package/dist/apiBuild-ttSDDOGp.js +0 -2
- package/dist/baselineCommand-Cfw2Afwm.js +0 -2
- package/dist/codegen-uYrrDzQv.js +0 -2
- package/dist/codegenCommand-C60m_LCp.js +0 -30
- package/dist/dbCommand-CC-qNzpz.js +0 -2
- package/dist/dev-CAOoXOkc.js +0 -3
- package/dist/doctorCommand-Cjl8Yii8.js +0 -2
- package/dist/frameworkTableAssembly-YyVe32Cb.js +0 -2
- package/dist/inspect-CjTYzAs_.js +0 -1190
- package/dist/inspect-P4pxoMaV.js +0 -2
- package/dist/inspectGateHint-BF6608UT.js +0 -4
- package/dist/manifestBuild-COkJoyAr.js +0 -2
- package/dist/serveCommand-DNRF2nDI.js +0 -2
- package/dist/serveCommand-DnY4VS3D.js +0 -1767
- package/dist/updateCommand-B0J_T9Vs.js +0 -2
- package/dist/webDev-CcJfdSjl2.js +0 -2
|
@@ -1,1767 +0,0 @@
|
|
|
1
|
-
import { t as e } from "./nodeEnvironment-cGFAj1J8.js";
|
|
2
|
-
import { t } from "./frameworkInspectState-CX2250XB.js";
|
|
3
|
-
import { r as n, t as r } from "./appModuleLoader-C9r9mxZt.js";
|
|
4
|
-
import { t as i } from "./bootRefusal-pgvDxlrU.js";
|
|
5
|
-
import { n as a, r as o } from "./startupRunner-CEqQq7ax.js";
|
|
6
|
-
import { $ as s, $t as c, A as l, At as u, B as d, C as ee, Ct as f, D as p, Dt as te, E as ne, Et as re, F as ie, Ft as m, G as ae, Gt as oe, H as se, Ht as ce, I as h, It as le, J as ue, Jt as g, K as de, Kt as fe, L as pe, Lt as me, M as he, Mt as ge, N as _e, Nt as _, O as ve, Ot as ye, P as be, Pt as xe, Q as Se, Qt as Ce, R as we, S as Te, St as v, T as Ee, Tt as De, U as Oe, Ut as ke, V as Ae, Vt as je, W as Me, Wt as y, X as Ne, Xt as Pe, Y as Fe, Yt as Ie, Z as b, Zt as x, _ as Le, _n as Re, _t as ze, an as Be, at as Ve, b as He, bt as Ue, c as We, cn as S, ct as Ge, dn as Ke, dt as qe, en as C, 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 w, ht as nt, i as T, in as rt, it, j as at, jt as ot, k as st, kt as ct, ln as lt, lt as ut, m as dt, mn as ft, mt as pt, nn as mt, nt as ht, o as E, on as gt, ot as _t, p as vt, pt as D, q as yt, qt as O, r as bt, rn as xt, rt as St, sn as Ct, st as wt, t as Tt, tn as k, 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 A, xt as Ft, y as j, yt as It, zt as Lt } from "./dev-E7Eo5GHc.js";
|
|
7
|
-
import { n as Rt } from "./cliArgs-D4p8n7EE.js";
|
|
8
|
-
import { r as zt } from "./appPort-B_HpJ_ck.js";
|
|
9
|
-
import { it as Bt, ot as Vt } from "./webDev-BKdD7c_a.js";
|
|
10
|
-
import { r as M } from "./dialectDriver-CgXnDfec.js";
|
|
11
|
-
import { i as Ht, n as Ut } from "./connectionConfig-UFlIEiys.js";
|
|
12
|
-
import { c as N, n as Wt, o as Gt } from "./seedRunner-ZmLSqNe2.js";
|
|
13
|
-
import { C as Kt, S as qt, _ as Jt, d as Yt, g as P, l as Xt, m as Zt, r as Qt, u as $t, v as en } from "./frameworkTableAssembly-oMPBKqlE.js";
|
|
14
|
-
import { S as tn, c as nn, n as rn, p as an, s as on, x as sn } from "./fileConventions-Cof68_BL.js";
|
|
15
|
-
import { h as cn, o as ln } from "./inspect-CjTYzAs_.js";
|
|
16
|
-
import { n as un } from "./mssqlClusterPatch-_4cE_nun.js";
|
|
17
|
-
import { i as dn, n as fn, r as pn, t as mn } from "./webhookDiscovery-D7VaeMlz.js";
|
|
18
|
-
import { t as hn } from "./inspectMetrics-CfdKLh6t.js";
|
|
19
|
-
import { r as gn, u as _n } from "./apiBuild-CvacV4zA.js";
|
|
20
|
-
import { t as vn } from "./bootTiming-BdyP9nYw.js";
|
|
21
|
-
import { t as yn } from "./dataProfile-dW-PsfLB.js";
|
|
22
|
-
import { basename as bn, join as xn } from "node:path";
|
|
23
|
-
import { existsSync as Sn } from "node:fs";
|
|
24
|
-
import { pathToFileURL as Cn } from "node:url";
|
|
25
|
-
import { createLogger as F } from "@voltro/logger";
|
|
26
|
-
import { AuthMiddleware as wn, ConnectionInfoMiddleware as Tn, actionToRpc as I, anonymousSubject as En, isWireReachable as Dn, mutationToRpc as L, queryToRpc as R, streamToRpc as On, workflowCancelDescriptor as kn, workflowDomainEventsQueryDescriptor as An, workflowEventDeliveriesQueryDescriptor as z, workflowResumeDescriptor as jn, workflowRunEventsQueryDescriptor as B, workflowRunQueryDescriptor as V, workflowRunStepsQueryDescriptor as H, workflowRunsQueryDescriptor as Mn, workflowSignalDescriptor as Nn, workflowUpdateDescriptor as Pn } from "@voltro/protocol";
|
|
27
|
-
import { Cause as Fn, Effect as U, Layer as W, ManagedRuntime as In } from "effect";
|
|
28
|
-
import { SqlClient as Ln } from "@effect/sql";
|
|
29
|
-
import { declaredSnapshot as Rn, describeOutcome as zn, pendingFileMigrationIds as Bn, runPlannedMigrations as Vn } from "@voltro/database/sql";
|
|
30
|
-
import { RpcGroup as Hn } from "@effect/rpc";
|
|
31
|
-
import { allRegisteredTables as Un, and as Wn, connectionIdentity as Gn, ensureTableRegistered as Kn, eq as G, or as K } from "@voltro/database";
|
|
32
|
-
import { AggregateRegistry as qn, CostRegistry as Jn, DORMANCY_WAKEUP_TENANT as Yn, Dispatcher as Xn, ExpectationRegistry as Zn, 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";
|
|
33
|
-
import { appStorageProvider as $r, fromNodeReadable as ei, getObjectStream as ti, putObjectStream as ni, toNodeReadable as ri } from "@voltro/plugin-storage";
|
|
34
|
-
import { isEnvContract as ii } from "@voltro/env";
|
|
35
|
-
import { assertProductionSessionSecret as ai } from "@voltro/protocol/session";
|
|
36
|
-
import { createHash as oi, timingSafeEqual as si } from "node:crypto";
|
|
37
|
-
import { buildDeliverWebhookExecute as ci, buildWebhooksService as li, defaultIncomingPath as ui, deliverWebhookWorkflow as di, makeDeferredEmitHandler as fi, mountIncomingWebhook as pi } from "@voltro/plugin-webhooks";
|
|
38
|
-
import { getAuthSessionStrategy as mi } from "@voltro/plugin-auth";
|
|
39
|
-
import { registerEmailTemplates as hi } from "@voltro/plugin-mail";
|
|
40
|
-
import { channelFor as gi, getBroadcastPlugin as _i } from "@voltro/plugin-broadcast";
|
|
41
|
-
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";
|
|
42
|
-
//#region src/dbPoolReport.ts
|
|
43
|
-
var Ti = (e, t, n = [], r = 0) => {
|
|
44
|
-
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.` : "";
|
|
45
|
-
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;
|
|
46
|
-
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})`;
|
|
47
|
-
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;
|
|
48
|
-
}, 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) => {
|
|
49
|
-
let t = e.REPLICA_COUNT;
|
|
50
|
-
if (t === void 0 || t === "") return;
|
|
51
|
-
let n = Number(t);
|
|
52
|
-
return Number.isInteger(n) && n > 0 ? n : void 0;
|
|
53
|
-
}, Oi = () => Math.max(500, Math.floor(Z() * .6)), ki = (e) => new Promise((t) => setTimeout(t, e)), Ai = (e) => {
|
|
54
|
-
let t = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set(), r = 0;
|
|
55
|
-
e.on("connection", (e) => {
|
|
56
|
-
t.add(e), e.once("close", () => {
|
|
57
|
-
t.delete(e), n.delete(e);
|
|
58
|
-
});
|
|
59
|
-
}), e.on("upgrade", (e, t) => {
|
|
60
|
-
n.add(t);
|
|
61
|
-
}), e.on("request", (e, t) => {
|
|
62
|
-
r += 1, t.once("close", () => {
|
|
63
|
-
--r;
|
|
64
|
-
});
|
|
65
|
-
});
|
|
66
|
-
let i, a = async (t = {}) => {
|
|
67
|
-
let n = t.budgetMs ?? Oi();
|
|
68
|
-
i ??= new Promise((t) => {
|
|
69
|
-
e.close(() => {
|
|
70
|
-
t();
|
|
71
|
-
});
|
|
72
|
-
}), e.closeIdleConnections();
|
|
73
|
-
let a = Date.now() + n;
|
|
74
|
-
for (; r > 0 && Date.now() < a;) await ki(25), e.closeIdleConnections();
|
|
75
|
-
e.closeIdleConnections();
|
|
76
|
-
}, o = async () => {
|
|
77
|
-
i ??= new Promise((t) => {
|
|
78
|
-
e.close(() => {
|
|
79
|
-
t();
|
|
80
|
-
});
|
|
81
|
-
});
|
|
82
|
-
for (let e of t) if (n.has(e)) try {
|
|
83
|
-
e.write(Buffer.from([
|
|
84
|
-
136,
|
|
85
|
-
2,
|
|
86
|
-
3,
|
|
87
|
-
233
|
|
88
|
-
]));
|
|
89
|
-
} catch {}
|
|
90
|
-
else e.destroy();
|
|
91
|
-
for (let e = 0; t.size > 0 && e < 250; e += 25) await ki(25);
|
|
92
|
-
for (let e of t) e.destroy();
|
|
93
|
-
await i;
|
|
94
|
-
};
|
|
95
|
-
return {
|
|
96
|
-
activeRequests: () => r,
|
|
97
|
-
drainRequests: a,
|
|
98
|
-
finish: o,
|
|
99
|
-
drain: async (e = {}) => {
|
|
100
|
-
await a(e), await o();
|
|
101
|
-
}
|
|
102
|
-
};
|
|
103
|
-
}, ji = "/_voltro/admin/import", Mi = "/_voltro/admin/export", Q = (e, t) => ({
|
|
104
|
-
status: e,
|
|
105
|
-
contentType: "application/json; charset=utf-8",
|
|
106
|
-
body: JSON.stringify(t)
|
|
107
|
-
}), Ni = (e) => {
|
|
108
|
-
let t = e.authorization ?? e.Authorization, n = t ? /^Bearer\s+(.+)$/i.exec(t) : null;
|
|
109
|
-
return n ? n[1] : null;
|
|
110
|
-
}, Pi = (e, t) => si(oi("sha256").update(e).digest(), oi("sha256").update(t).digest()), Fi = (e, t) => {
|
|
111
|
-
if (e.method.toUpperCase() !== "POST") return Q(405, { error: "method not allowed" });
|
|
112
|
-
if (!t || t.length < 16) return Q(503, { error: "data transfer misconfigured (no/weak secret)" });
|
|
113
|
-
let n = Ni(e.headers);
|
|
114
|
-
return !n || !Pi(n, t) ? Q(401, { error: "unauthorized" }) : null;
|
|
115
|
-
}, Ii = F({ scope: "voltro:admin-import" }), Li = "VBUNDLE2", Ri = async function* (e) {
|
|
116
|
-
yield e;
|
|
117
|
-
}, zi = (e) => async (t) => {
|
|
118
|
-
let n = Fi(t, e.secret);
|
|
119
|
-
if (n) return n;
|
|
120
|
-
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;
|
|
121
|
-
if (s) c = Ri(t.rawBody), l = "upload";
|
|
122
|
-
else {
|
|
123
|
-
let n;
|
|
124
|
-
try {
|
|
125
|
-
n = JSON.parse(Buffer.from(t.rawBody).toString("utf8") || "{}");
|
|
126
|
-
} catch {
|
|
127
|
-
return Q(400, { error: "body must be a packed bundle archive or { bundleKey } JSON" });
|
|
128
|
-
}
|
|
129
|
-
if (typeof n.bundleKey != "string" || !n.bundleKey) return Q(400, { error: "body.bundleKey (string) is required for the storage transport" });
|
|
130
|
-
if (!e.openArchive) return Q(501, { error: "storage transport not configured on this instance" });
|
|
131
|
-
c = e.openArchive(n.bundleKey), l = "storage";
|
|
132
|
-
}
|
|
133
|
-
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-"));
|
|
134
|
-
try {
|
|
135
|
-
e.assetSink ? await Ci(c, {
|
|
136
|
-
dir: f,
|
|
137
|
-
blobs: e.assetSink
|
|
138
|
-
}) : await wi(c, f);
|
|
139
|
-
let t = await U.runPromiseExit(bi({
|
|
140
|
-
store: e.store,
|
|
141
|
-
bundleDir: f,
|
|
142
|
-
...r ? { mode: r } : {},
|
|
143
|
-
...i ? { onConflict: i } : {},
|
|
144
|
-
...a ? { atomic: a } : {},
|
|
145
|
-
...e.snapshot ? { targetSnapshot: e.snapshot } : {},
|
|
146
|
-
force: o,
|
|
147
|
-
onWarn: (e) => Ii.warn("admin.import", { message: e }),
|
|
148
|
-
...e.assetSink ? { assetsAlreadyRestored: !0 } : {}
|
|
149
|
-
}));
|
|
150
|
-
if (t._tag === "Failure") {
|
|
151
|
-
let e = t.cause._tag === "Fail" ? t.cause.error : void 0;
|
|
152
|
-
if (e && e._tag === "SchemaDriftError") {
|
|
153
|
-
let t = e;
|
|
154
|
-
return Ii.warn("admin.import refused (schema drift)", {
|
|
155
|
-
transport: l,
|
|
156
|
-
bundle: t.bundleFingerprint.slice(0, 16),
|
|
157
|
-
target: t.targetFingerprint.slice(0, 16)
|
|
158
|
-
}), Q(409, {
|
|
159
|
-
error: "schema drift",
|
|
160
|
-
bundleFingerprint: t.bundleFingerprint,
|
|
161
|
-
targetFingerprint: t.targetFingerprint,
|
|
162
|
-
diff: t.diff,
|
|
163
|
-
hint: "re-export against the current schema, or resend with x-import-force: 1"
|
|
164
|
-
});
|
|
165
|
-
}
|
|
166
|
-
throw Error(String(e?.message ?? e ?? "import failed"));
|
|
167
|
-
}
|
|
168
|
-
let n = t.value, s = n.tables.reduce((e, t) => e + t.rowCount, 0);
|
|
169
|
-
return Ii.info("admin.import", {
|
|
170
|
-
transport: l,
|
|
171
|
-
tables: n.tables.length,
|
|
172
|
-
rows: s,
|
|
173
|
-
mode: r ?? "upsert",
|
|
174
|
-
atomic: a
|
|
175
|
-
}), Q(200, {
|
|
176
|
-
tables: n.tables.length,
|
|
177
|
-
rows: s,
|
|
178
|
-
transport: l
|
|
179
|
-
});
|
|
180
|
-
} catch (e) {
|
|
181
|
-
return Ii.warn("admin.import failed", {
|
|
182
|
-
transport: l,
|
|
183
|
-
error: e?.message ?? String(e)
|
|
184
|
-
}), Q(500, {
|
|
185
|
-
error: "import failed",
|
|
186
|
-
message: e?.message ?? String(e)
|
|
187
|
-
});
|
|
188
|
-
} finally {
|
|
189
|
-
await d.rm(f, {
|
|
190
|
-
recursive: !0,
|
|
191
|
-
force: !0
|
|
192
|
-
});
|
|
193
|
-
}
|
|
194
|
-
}, Bi = F({ scope: "voltro:admin-export" }), Vi = async (e) => {
|
|
195
|
-
let t = [];
|
|
196
|
-
for await (let n of e) t.push(Buffer.from(n));
|
|
197
|
-
return new Uint8Array(Buffer.concat(t));
|
|
198
|
-
}, Hi = (e) => typeof e.tenant == "string" && e.tenant ? {
|
|
199
|
-
kind: "tenant",
|
|
200
|
-
tenantId: e.tenant
|
|
201
|
-
} : Array.isArray(e.tables) && e.tables.length ? {
|
|
202
|
-
kind: "tables",
|
|
203
|
-
tables: e.tables.filter((e) => typeof e == "string")
|
|
204
|
-
} : { kind: "all" }, Ui = (e) => async (t) => {
|
|
205
|
-
let n = Fi(t, e.secret);
|
|
206
|
-
if (n) return n;
|
|
207
|
-
let r;
|
|
208
|
-
try {
|
|
209
|
-
r = JSON.parse(Buffer.from(t.rawBody).toString("utf8") || "{}");
|
|
210
|
-
} catch {
|
|
211
|
-
return Q(400, { error: "body must be JSON: { profile?, tenant?, tables?, consistency?, compression?, bundleKey? }" });
|
|
212
|
-
}
|
|
213
|
-
let i = {};
|
|
214
|
-
if (typeof r.profile == "string" && r.profile) {
|
|
215
|
-
if (!e.loadProfile) return Q(501, { error: "server-side profiles not configured on this instance" });
|
|
216
|
-
try {
|
|
217
|
-
i = await e.loadProfile(r.profile);
|
|
218
|
-
} catch (e) {
|
|
219
|
-
return Q(400, {
|
|
220
|
-
error: `profile '${r.profile}' could not be loaded`,
|
|
221
|
-
message: e?.message ?? String(e)
|
|
222
|
-
});
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
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-"));
|
|
226
|
-
try {
|
|
227
|
-
let t = await U.runPromise(yi({
|
|
228
|
-
store: e.store,
|
|
229
|
-
snapshot: e.snapshot,
|
|
230
|
-
dialect: e.dialect,
|
|
231
|
-
outDir: f,
|
|
232
|
-
...i.subset ? { subset: i.subset } : {
|
|
233
|
-
scope: s,
|
|
234
|
-
...e.tenantTables && e.tenantTables.length > 0 ? { tenantTables: e.tenantTables } : {}
|
|
235
|
-
},
|
|
236
|
-
consistency: a,
|
|
237
|
-
...o ? { compression: o } : {},
|
|
238
|
-
...i.masking ? { masking: i.masking } : {}
|
|
239
|
-
})), n = t.tables.reduce((e, t) => e + t.rowCount, 0), u = t.masking?.transformed.length ?? 0;
|
|
240
|
-
if (c) {
|
|
241
|
-
if (!e.putArchive) return Q(501, { error: "storage transport not configured on this instance" });
|
|
242
|
-
let i = r.bundleKey;
|
|
243
|
-
return await e.putArchive(i, () => vi({
|
|
244
|
-
dir: f,
|
|
245
|
-
...l
|
|
246
|
-
})), Bi.info("admin.export", {
|
|
247
|
-
transport: "storage",
|
|
248
|
-
tables: t.tables.length,
|
|
249
|
-
rows: n,
|
|
250
|
-
masked: u,
|
|
251
|
-
bundleKey: i
|
|
252
|
-
}), Q(200, {
|
|
253
|
-
bundleKey: i,
|
|
254
|
-
tables: t.tables.length,
|
|
255
|
-
rows: n,
|
|
256
|
-
masked: u,
|
|
257
|
-
transport: "storage"
|
|
258
|
-
});
|
|
259
|
-
}
|
|
260
|
-
let d = await Vi(vi({
|
|
261
|
-
dir: f,
|
|
262
|
-
...l
|
|
263
|
-
}));
|
|
264
|
-
return Bi.info("admin.export", {
|
|
265
|
-
transport: "download",
|
|
266
|
-
tables: t.tables.length,
|
|
267
|
-
rows: n,
|
|
268
|
-
masked: u,
|
|
269
|
-
bytes: d.byteLength
|
|
270
|
-
}), {
|
|
271
|
-
status: 200,
|
|
272
|
-
contentType: "application/octet-stream",
|
|
273
|
-
body: d,
|
|
274
|
-
headers: {
|
|
275
|
-
"x-export-tables": String(t.tables.length),
|
|
276
|
-
"x-export-rows": String(n),
|
|
277
|
-
"x-export-masked": String(u)
|
|
278
|
-
}
|
|
279
|
-
};
|
|
280
|
-
} catch (e) {
|
|
281
|
-
return Bi.warn("admin.export failed", { error: e?.message ?? String(e) }), Q(500, {
|
|
282
|
-
error: "export failed",
|
|
283
|
-
message: e?.message ?? String(e)
|
|
284
|
-
});
|
|
285
|
-
} finally {
|
|
286
|
-
await d.rm(f, {
|
|
287
|
-
recursive: !0,
|
|
288
|
-
force: !0
|
|
289
|
-
});
|
|
290
|
-
}
|
|
291
|
-
}, Wi = (e, t, n = {}) => (async function* () {
|
|
292
|
-
let r = await ri((await U.runPromise(ti(e, t).pipe(U.timeout(n.openTimeout ?? "30 seconds")))).stream), i = n.stallMs ?? 12e4, a, o = () => {
|
|
293
|
-
a && clearTimeout(a), a = setTimeout(() => r.destroy(/* @__PURE__ */ Error(`storage read stalled for ${i}ms reading '${t}'`)), i);
|
|
294
|
-
};
|
|
295
|
-
try {
|
|
296
|
-
o();
|
|
297
|
-
for await (let e of r) o(), yield e instanceof Uint8Array ? e : new Uint8Array(e);
|
|
298
|
-
} finally {
|
|
299
|
-
a && clearTimeout(a), r.destroy();
|
|
300
|
-
}
|
|
301
|
-
})(), Gi = {
|
|
302
|
-
get: async () => void 0,
|
|
303
|
-
set: async () => {},
|
|
304
|
-
setWithTags: async () => {},
|
|
305
|
-
remove: async () => !1,
|
|
306
|
-
has: async () => !1,
|
|
307
|
-
clear: async () => {},
|
|
308
|
-
invalidateTag: async () => 0,
|
|
309
|
-
wrap: async (e, t, n) => n()
|
|
310
|
-
}, Ki = async (e) => {
|
|
311
|
-
me(e.appProcedures ?? e.discovered, {
|
|
312
|
-
defaultDeny: e.security?.defaultDeny ?? !0,
|
|
313
|
-
commandHint: "`voltro serve`"
|
|
314
|
-
}), Hr({
|
|
315
|
-
dataStore: e.store,
|
|
316
|
-
schemaRegistry: e.schemaRegistry
|
|
317
|
-
});
|
|
318
|
-
let t = (e.discovered.budgets?.length ?? 0) > 0, n, r = new Xn({
|
|
319
|
-
store: e.store,
|
|
320
|
-
...e.snapshotCache ? { cache: e.snapshotCache } : {},
|
|
321
|
-
...e.reactive === void 0 ? {} : { reactive: e.reactive },
|
|
322
|
-
...t ? { recordCost: (e) => n?.record(e) } : {},
|
|
323
|
-
recordDelivery: (e) => Ir({
|
|
324
|
-
label: e.label,
|
|
325
|
-
kind: e.kind,
|
|
326
|
-
durationMs: e.durationMs,
|
|
327
|
-
rowCount: e.rowCount
|
|
328
|
-
})
|
|
329
|
-
}), i = e.cache ?? Gi, a = e.kv ?? Pr, o, l = () => void 0, ee, f, p, te, ne, ce, le, ue = ke({
|
|
330
|
-
store: e.store,
|
|
331
|
-
warn: (e, t) => {
|
|
332
|
-
process.stderr.write(`[workflow] ${e} ${JSON.stringify(t)}\n`);
|
|
333
|
-
}
|
|
334
|
-
}), de = ue.remember, pe = ue.resolve, ge = y({
|
|
335
|
-
authority: e.authority,
|
|
336
|
-
getStore: () => e.store
|
|
337
|
-
}), _ = (e.discovered.workflows?.length ?? 0) > 0 ? Cr(() => o) : 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", be = e.tenantIsolation === "namespace", Ce = (e.log ?? F({ scope: "voltro:serve" })).child("webhooks"), we, Te, v = e.discovered.webhooks;
|
|
338
|
-
if (v && v.outgoing.length > 0 && e.workflowEngineLayer !== void 0) {
|
|
339
|
-
e.workflowEngineLayer;
|
|
340
|
-
let t = gt({
|
|
341
|
-
store: e.store,
|
|
342
|
-
schemaRegistry: e.schemaRegistry,
|
|
343
|
-
cache: i,
|
|
344
|
-
kv: a
|
|
345
|
-
}), n = v.outgoing.map((e) => e.descriptor);
|
|
346
|
-
Te = di.toLayer(ci(t, { events: n })), we = li(t, async (e) => {
|
|
347
|
-
let t = p;
|
|
348
|
-
if (t === void 0) {
|
|
349
|
-
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.", {
|
|
350
|
-
deliveryId: e.deliveryId,
|
|
351
|
-
targetId: e.targetId
|
|
352
|
-
});
|
|
353
|
-
return;
|
|
354
|
-
}
|
|
355
|
-
t.runPromise(di.execute(e)).catch((t) => {
|
|
356
|
-
Ce.error("deliverWebhook workflow crashed", {
|
|
357
|
-
deliveryId: e.deliveryId,
|
|
358
|
-
targetId: e.targetId
|
|
359
|
-
}, t);
|
|
360
|
-
});
|
|
361
|
-
}, { events: n });
|
|
362
|
-
}
|
|
363
|
-
let Ee = /* @__PURE__ */ new Map();
|
|
364
|
-
if (v) for (let e of v.incoming) {
|
|
365
|
-
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, {
|
|
366
|
-
resolveSecret: async () => process.env[n] ?? null,
|
|
367
|
-
resolveWorkflows: () => _ === void 0 ? void 0 : Nr(_, {
|
|
368
|
-
traceId: `incoming:${e.descriptor.id}`,
|
|
369
|
-
source: `incoming:${e.descriptor.id}`
|
|
370
|
-
}),
|
|
371
|
-
log: (e) => {
|
|
372
|
-
let t = {
|
|
373
|
-
webhookId: e.webhookId,
|
|
374
|
-
status: e.status,
|
|
375
|
-
signatureOk: String(e.signatureOk),
|
|
376
|
-
idempotency: e.idempotency,
|
|
377
|
-
durationMs: e.durationMs
|
|
378
|
-
};
|
|
379
|
-
e.status >= 500 ? Ce.error("incoming delivery failed", t) : e.status >= 400 ? Ce.warn("incoming delivery rejected", t) : Ce.info("incoming delivery handled", t);
|
|
380
|
-
}
|
|
381
|
-
});
|
|
382
|
-
Ee.set(t, { handle: r });
|
|
383
|
-
}
|
|
384
|
-
fr(), Ur((t) => pr(e.store, t.subjectId, t.resourceType, t.resourceId));
|
|
385
|
-
let je = [], Pe = [...e.discovered.outboxHandlers ?? [], ...fn((v?.outgoing.length ?? 0) + (v?.incoming.length ?? 0) + (v?.providers.length ?? 0), []) ? [{
|
|
386
|
-
file: "<framework>/webhooks",
|
|
387
|
-
id: "voltro-webhook-emit",
|
|
388
|
-
definition: fi(() => we)
|
|
389
|
-
}] : []], Fe = Pe.length > 0 ? g({
|
|
390
|
-
handlers: Pe,
|
|
391
|
-
store: e.store,
|
|
392
|
-
log: (e.log ?? F({ scope: "voltro:serve" })).child("outbox"),
|
|
393
|
-
onChange: (t) => e.store.onChange((e) => t({
|
|
394
|
-
table: e.table,
|
|
395
|
-
op: e.op
|
|
396
|
-
})),
|
|
397
|
-
onShutdown: (e) => {
|
|
398
|
-
je.push(e);
|
|
399
|
-
}
|
|
400
|
-
}) : void 0, x = fe({
|
|
401
|
-
definitions: (e.discovered.connections ?? []).map((e) => e.definition),
|
|
402
|
-
store: e.store,
|
|
403
|
-
publicUrl: oe(e.port ?? 4e3),
|
|
404
|
-
log: (e.log ?? F({ scope: "voltro:serve" })).child("connections")
|
|
405
|
-
});
|
|
406
|
-
at({
|
|
407
|
-
events: e.discovered.events ?? [],
|
|
408
|
-
rpcTags: [
|
|
409
|
-
...e.discovered.queries.map((e) => e.descriptor.name),
|
|
410
|
-
...e.discovered.mutations.map((e) => e.descriptor.name),
|
|
411
|
-
...e.discovered.actions.map((e) => e.descriptor.name),
|
|
412
|
-
...(e.discovered.streams ?? []).map((e) => e.descriptor.name)
|
|
413
|
-
]
|
|
414
|
-
});
|
|
415
|
-
let Re = (e.log ?? F({ scope: "voltro:serve" })).child("events"), ze = e.broadcastNamespace ?? Qe(e.plugins, void 0), Ve = Le(e.plugins, ze, Re), He = e.membership?.instanceId ?? process.env.POD_NAME ?? process.env.HOSTNAME ?? `serve-${process.pid}`, We = e.membership ?? At(e.plugins, {
|
|
416
|
-
instanceId: He,
|
|
417
|
-
namespace: ze,
|
|
418
|
-
meta: { mode: "serve" },
|
|
419
|
-
logger: Re
|
|
420
|
-
}), S = he({
|
|
421
|
-
events: e.discovered.events ?? [],
|
|
422
|
-
origin: He,
|
|
423
|
-
...Ve.publishRemote === void 0 ? {} : { publishRemote: Ve.publishRemote }
|
|
424
|
-
}), Ke = (e.discovered.events ?? []).length > 0 ? await Ve.attach(S.bus) : null, C = Be({
|
|
425
|
-
store: e.store,
|
|
426
|
-
schemaRegistry: e.schemaRegistry,
|
|
427
|
-
cache: i,
|
|
428
|
-
kv: a,
|
|
429
|
-
...we === void 0 ? {} : { webhooksService: we },
|
|
430
|
-
..._ === void 0 ? {} : { workflowsProxy: _ },
|
|
431
|
-
eventTriggers: e.discovered.eventTriggers ?? [],
|
|
432
|
-
namespaceIsolationOn: be,
|
|
433
|
-
...e.ensureTenantProvisioned === void 0 ? {} : { ensureTenantProvisioned: e.ensureTenantProvisioned },
|
|
434
|
-
...e.resolveResidentStore === void 0 ? {} : { resolveResidentStore: e.resolveResidentStore },
|
|
435
|
-
...Fe === void 0 ? {} : { outbox: { nudge: Fe.nudge } },
|
|
436
|
-
...x.active ? { connections: { registry: x.registry } } : {},
|
|
437
|
-
eventBus: S.bus
|
|
438
|
-
}), Je = W.succeed(qn, re), Ye = W.succeed(Zn, Ue), Xe = W.succeed(Jn, It), Ze = W.succeed(q, Ft), et = (t, n) => {
|
|
439
|
-
let r = t.pipe(U.provide(Sr(n)));
|
|
440
|
-
return (e.baseLayer ? r.pipe(U.provide(e.baseLayer)) : r).pipe(U.provide(Je)).pipe(U.provide(Ye)).pipe(U.provide(Xe)).pipe(U.provide(Ze));
|
|
441
|
-
}, tt = (e, t) => Br(et(e, t)), w = hn(), T = yt(e.plugins ?? [], w), it = d({
|
|
442
|
-
plugins: e.plugins ?? [],
|
|
443
|
-
metrics: w,
|
|
444
|
-
log: e.log ?? F({ scope: "voltro:serve" })
|
|
445
|
-
}), st = ae(e.plugins ?? [], w), ct = e.security?.defaultDeny ?? !0, lt = Tr({
|
|
446
|
-
store: e.store,
|
|
447
|
-
defaultDeny: ct,
|
|
448
|
-
recordMetric: (e) => {
|
|
449
|
-
w.record(e);
|
|
450
|
-
},
|
|
451
|
-
...T.mutation === void 0 ? {} : { interceptor: T.mutation },
|
|
452
|
-
buildContext: (e, t, n) => C(e, t, n),
|
|
453
|
-
runEffect: tt,
|
|
454
|
-
undoCapture: Se()
|
|
455
|
-
}), dt = b();
|
|
456
|
-
{
|
|
457
|
-
let t = s();
|
|
458
|
-
t !== void 0 && (e.log ?? F({ scope: "voltro:serve" })).info(t);
|
|
459
|
-
}
|
|
460
|
-
let ft = Ne({
|
|
461
|
-
store: e.store,
|
|
462
|
-
...e.approvals === void 0 ? {} : { defaultExpiryMs: e.approvals.defaultExpiryMs }
|
|
463
|
-
}), pt = mr({
|
|
464
|
-
defaultDeny: ct,
|
|
465
|
-
buildContext: (e) => C(e),
|
|
466
|
-
runEffect: tt,
|
|
467
|
-
recordMetric: (e) => {
|
|
468
|
-
w.record(e);
|
|
469
|
-
},
|
|
470
|
-
...T.action === void 0 ? {} : { interceptor: T.action }
|
|
471
|
-
}), mt = Or({
|
|
472
|
-
tenantScopedTables: e.tenantScopedTables,
|
|
473
|
-
softDeleteScopedTables: e.softDeleteScopedTables
|
|
474
|
-
}), ht = {
|
|
475
|
-
defaultDeny: ct,
|
|
476
|
-
buildContext: (e) => C(e),
|
|
477
|
-
finalize: (e, t) => mt(e, t.subject),
|
|
478
|
-
provideEffect: et,
|
|
479
|
-
...T.query === void 0 ? {} : { interceptor: T.query }
|
|
480
|
-
}, E = Dr(ht), _t = Er({
|
|
481
|
-
...ht,
|
|
482
|
-
queryRows: (t, n) => e.store.query(t).then((e) => qr(t.table, e, n.subject))
|
|
483
|
-
}), vt = Ar({
|
|
484
|
-
...ht,
|
|
485
|
-
subscribeDescriptor: (e, t, n) => r.subscribe(e, t, n),
|
|
486
|
-
subscribeComputed: (e, t, n) => r.subscribeComputed(e, t, n)
|
|
487
|
-
}), D = (e) => e.filter((e) => Dn(e.descriptor)), O = {};
|
|
488
|
-
for (let t of [
|
|
489
|
-
...D(e.discovered.queries),
|
|
490
|
-
...dt.queries,
|
|
491
|
-
...ft.queries,
|
|
492
|
-
...x.queries
|
|
493
|
-
]) O[t.descriptor.name] = (e) => Y(E(t, e), r, `subscription.${t.descriptor.name}`, void 0, void 0, kr(t, e));
|
|
494
|
-
for (let t of [
|
|
495
|
-
...D(e.discovered.mutations),
|
|
496
|
-
...dt.mutations,
|
|
497
|
-
...ft.mutations,
|
|
498
|
-
...x.mutations
|
|
499
|
-
]) {
|
|
500
|
-
let n = wr(t.descriptor.output);
|
|
501
|
-
O[t.descriptor.name] = (r) => J(async (e, n) => lt(t, e, n), r, `mutation.${t.descriptor.name}`, n, e.idempotency, t.descriptor.error);
|
|
502
|
-
}
|
|
503
|
-
for (let t of [...D(e.discovered.actions), ...x.actions]) {
|
|
504
|
-
let n = wr(t.descriptor.output);
|
|
505
|
-
O[t.descriptor.name] = (r) => J(async (e, n) => pt(t, e, n), r, `action.${t.descriptor.name}`, n, e.idempotency, t.descriptor.error);
|
|
506
|
-
}
|
|
507
|
-
let bt = () => `public-${Math.random().toString(36).slice(2, 10)}`, xt = [
|
|
508
|
-
...e.discovered.queries.filter((e) => e.descriptor.publicApi !== void 0).map((e) => ({
|
|
509
|
-
descriptor: e.descriptor,
|
|
510
|
-
invoke: (t, n) => _t(e, t, {
|
|
511
|
-
subject: n.subject,
|
|
512
|
-
traceId: bt()
|
|
513
|
-
}),
|
|
514
|
-
subscribe: (t, n, r) => vt(e, t, {
|
|
515
|
-
subject: n.subject,
|
|
516
|
-
traceId: bt()
|
|
517
|
-
}, r)
|
|
518
|
-
})),
|
|
519
|
-
...e.discovered.mutations.filter((e) => e.descriptor.publicApi !== void 0).map((e) => ({
|
|
520
|
-
descriptor: e.descriptor,
|
|
521
|
-
invoke: (t, n) => lt(e, t, {
|
|
522
|
-
subject: n.subject,
|
|
523
|
-
traceId: bt()
|
|
524
|
-
})
|
|
525
|
-
})),
|
|
526
|
-
...e.discovered.actions.filter((e) => e.descriptor.publicApi !== void 0).map((e) => ({
|
|
527
|
-
descriptor: e.descriptor,
|
|
528
|
-
invoke: (t, n) => pt(e, t, {
|
|
529
|
-
subject: n.subject,
|
|
530
|
-
traceId: bt()
|
|
531
|
-
})
|
|
532
|
-
}))
|
|
533
|
-
], St = {
|
|
534
|
-
candidates: m({
|
|
535
|
-
queries: e.discovered.queries,
|
|
536
|
-
mutations: e.discovered.mutations,
|
|
537
|
-
actions: e.discovered.actions,
|
|
538
|
-
descriptorOf: (e) => e.descriptor,
|
|
539
|
-
runQuery: (e, t, n) => Promise.resolve(_t(e, t, n)),
|
|
540
|
-
runMutation: (e, t, n) => Promise.resolve(lt(e, t, n)),
|
|
541
|
-
runAction: (e, t, n) => Promise.resolve(pt(e, t, n))
|
|
542
|
-
}),
|
|
543
|
-
policy: e.agents?.tools ?? {},
|
|
544
|
-
mcpEnabled: e.agents?.mcp === !0,
|
|
545
|
-
resolveSubject: (t) => e.resolveSubject(t, -1).then((e) => e.subject)
|
|
546
|
-
}, Ct = c({
|
|
547
|
-
...e.restRoutes === void 0 ? {} : { restRoutes: e.restRoutes },
|
|
548
|
-
publicApiEntries: xt,
|
|
549
|
-
store: e.store,
|
|
550
|
-
resolveSubject: (t) => e.resolveSubject(t, -1).then((e) => e.subject),
|
|
551
|
-
...e.idempotency === void 0 ? {} : { idempotency: e.idempotency },
|
|
552
|
-
log: e.log ?? F({ scope: "voltro:serve" })
|
|
553
|
-
}), Tt = e.dataTransferSecret ?? process.env.VOLTRO_DATA_TRANSFER_SECRET, Et = Tt && Tt.length >= 16 ? [{
|
|
554
|
-
method: "POST",
|
|
555
|
-
path: ji,
|
|
556
|
-
handle: zi({
|
|
557
|
-
secret: Tt,
|
|
558
|
-
store: e.store,
|
|
559
|
-
...e.dataTransferSnapshot ? { snapshot: e.dataTransferSnapshot } : {},
|
|
560
|
-
assetSink: xi($r()),
|
|
561
|
-
openArchive: (e) => Wi($r(), e)
|
|
562
|
-
})
|
|
563
|
-
}, {
|
|
564
|
-
method: "POST",
|
|
565
|
-
path: Mi,
|
|
566
|
-
handle: Ui({
|
|
567
|
-
secret: Tt,
|
|
568
|
-
store: e.store,
|
|
569
|
-
snapshot: e.dataTransferSnapshot ?? { tables: [] },
|
|
570
|
-
dialect: e.dataTransferDialect ?? "memory",
|
|
571
|
-
tenantTables: [...e.tenantScopedTables],
|
|
572
|
-
loadProfile: yn,
|
|
573
|
-
assetSource: Si($r(), e.store),
|
|
574
|
-
putArchive: async (e, t) => {
|
|
575
|
-
let { Readable: n } = await import("node:stream"), r = $r(), i = ei("storage", () => n.from(t()));
|
|
576
|
-
await U.runPromise(ni(r, e, i, { contentType: "application/octet-stream" }));
|
|
577
|
-
}
|
|
578
|
-
})
|
|
579
|
-
}] : [], Dt = [
|
|
580
|
-
...e.httpRoutes ?? [],
|
|
581
|
-
...Ct.httpRoutes,
|
|
582
|
-
...Et,
|
|
583
|
-
...x.httpRoutes
|
|
584
|
-
];
|
|
585
|
-
Object.assign(O, S.handlers);
|
|
586
|
-
for (let t of D(e.discovered.streams ?? [])) O[t.descriptor.name] = (n) => ir((r) => Xr(r, (r) => {
|
|
587
|
-
let i = C(r), a = t.executor(n, i);
|
|
588
|
-
if (U.isEffect(a)) {
|
|
589
|
-
let t = a.pipe(U.provide(Sr(i.store)));
|
|
590
|
-
return (e.baseLayer ? t.pipe(U.provide(e.baseLayer)) : t).pipe(U.provide(Je)).pipe(U.provide(Ye)).pipe(U.provide(Xe)).pipe(U.provide(Ze));
|
|
591
|
-
}
|
|
592
|
-
return typeof a == "object" && a && typeof a.then == "function" ? U.promise(() => a) : a;
|
|
593
|
-
}), `stream.${t.descriptor.name}`);
|
|
594
|
-
for (let t of e.discovered.workflows ?? []) O[t.definition.name] = (e) => J(async (e, n) => {
|
|
595
|
-
let r = n;
|
|
596
|
-
return Nr(_, {
|
|
597
|
-
subject: r.subject,
|
|
598
|
-
traceId: r.traceId,
|
|
599
|
-
source: "workflow-rpc"
|
|
600
|
-
}).start(t.definition.name, e);
|
|
601
|
-
}, e, `workflow.${t.definition.name}`);
|
|
602
|
-
ve && (O[V.name] = (e) => Y(E({
|
|
603
|
-
descriptor: V,
|
|
604
|
-
executor: (e) => {
|
|
605
|
-
let t = e.id;
|
|
606
|
-
return {
|
|
607
|
-
table: "_voltro_workflow_runs",
|
|
608
|
-
order: [{
|
|
609
|
-
column: "startedAt",
|
|
610
|
-
direction: "desc"
|
|
611
|
-
}],
|
|
612
|
-
predicate: K(G("id", t), G("executionId", t)),
|
|
613
|
-
take: 1,
|
|
614
|
-
skip: void 0,
|
|
615
|
-
projection: void 0
|
|
616
|
-
};
|
|
617
|
-
}
|
|
618
|
-
}, e), r, `subscription.${V.name}`), O[Mn.name] = (e) => Y(E({
|
|
619
|
-
descriptor: Mn,
|
|
620
|
-
executor: (e) => {
|
|
621
|
-
let t = e, n = [...t.tag === void 0 ? [] : [G("tag", t.tag)], ...t.status === void 0 ? [] : [G("status", t.status)]], r = Number.isFinite(t.limit) && t.limit !== void 0 ? Math.min(Math.max(Math.floor(t.limit), 1), 500) : 100;
|
|
622
|
-
return {
|
|
623
|
-
table: "_voltro_workflow_runs",
|
|
624
|
-
order: [{
|
|
625
|
-
column: "startedAt",
|
|
626
|
-
direction: "desc"
|
|
627
|
-
}],
|
|
628
|
-
predicate: n.length === 0 ? void 0 : n.length === 1 ? n[0] : Wn(...n),
|
|
629
|
-
take: r,
|
|
630
|
-
skip: void 0,
|
|
631
|
-
projection: void 0
|
|
632
|
-
};
|
|
633
|
-
}
|
|
634
|
-
}, e), r, `subscription.${Mn.name}`), O[H.name] = (e) => Y(E({
|
|
635
|
-
descriptor: H,
|
|
636
|
-
executor: (e) => {
|
|
637
|
-
let t = e.runId;
|
|
638
|
-
return {
|
|
639
|
-
table: "_voltro_workflow_run_steps",
|
|
640
|
-
order: [{
|
|
641
|
-
column: "startedAt",
|
|
642
|
-
direction: "asc"
|
|
643
|
-
}],
|
|
644
|
-
predicate: G("runId", t),
|
|
645
|
-
take: 1e3,
|
|
646
|
-
skip: void 0,
|
|
647
|
-
projection: void 0
|
|
648
|
-
};
|
|
649
|
-
}
|
|
650
|
-
}, e), r, `subscription.${H.name}`), O[B.name] = (e) => Y(E({
|
|
651
|
-
descriptor: B,
|
|
652
|
-
executor: (e) => {
|
|
653
|
-
let t = e.runId;
|
|
654
|
-
return {
|
|
655
|
-
table: "_voltro_workflow_run_events",
|
|
656
|
-
order: [{
|
|
657
|
-
column: "occurredAt",
|
|
658
|
-
direction: "asc"
|
|
659
|
-
}],
|
|
660
|
-
predicate: G("runId", t),
|
|
661
|
-
take: 1e3,
|
|
662
|
-
skip: void 0,
|
|
663
|
-
projection: void 0
|
|
664
|
-
};
|
|
665
|
-
}
|
|
666
|
-
}, e), r, `subscription.${B.name}`), O[An.name] = (e) => Y(E({
|
|
667
|
-
descriptor: An,
|
|
668
|
-
executor: (e) => {
|
|
669
|
-
let t = e;
|
|
670
|
-
return {
|
|
671
|
-
table: "_voltro_workflow_events",
|
|
672
|
-
order: [{
|
|
673
|
-
column: "occurredAt",
|
|
674
|
-
direction: "desc"
|
|
675
|
-
}],
|
|
676
|
-
predicate: t.name === void 0 ? void 0 : G("name", t.name),
|
|
677
|
-
take: Math.max(1, Math.min(500, t.limit ?? 100)),
|
|
678
|
-
skip: void 0,
|
|
679
|
-
projection: void 0
|
|
680
|
-
};
|
|
681
|
-
}
|
|
682
|
-
}, e), r, `subscription.${An.name}`), O[z.name] = (e) => Y(E({
|
|
683
|
-
descriptor: z,
|
|
684
|
-
executor: (e) => {
|
|
685
|
-
let t = e.eventId;
|
|
686
|
-
return {
|
|
687
|
-
table: "_voltro_workflow_event_deliveries",
|
|
688
|
-
order: [{
|
|
689
|
-
column: "createdAt",
|
|
690
|
-
direction: "asc"
|
|
691
|
-
}],
|
|
692
|
-
predicate: G("eventId", t),
|
|
693
|
-
take: 500,
|
|
694
|
-
skip: void 0,
|
|
695
|
-
projection: void 0
|
|
696
|
-
};
|
|
697
|
-
}
|
|
698
|
-
}, e), r, `subscription.${z.name}`), O[kn.name] = (t) => J(async (t, n) => {
|
|
699
|
-
let r = t;
|
|
700
|
-
return await rt(e.store, n.subject, { executionId: r.executionId }), await _.cancel(r.workflowName, r.executionId), await Rt(r.workflowName, r.executionId, "workflow.cancel"), { ok: !0 };
|
|
701
|
-
}, t, `action.${kn.name}`), O[jn.name] = (t) => J(async (t, n) => {
|
|
702
|
-
let r = t;
|
|
703
|
-
return await rt(e.store, n.subject, { executionId: r.executionId }), await _.resume(r.workflowName, r.executionId), { ok: !0 };
|
|
704
|
-
}, t, `action.${jn.name}`), O[Nn.name] = (t) => J(async (t, n) => {
|
|
705
|
-
let r = t;
|
|
706
|
-
return await rt(e.store, n.subject, { id: r.id }), _.signal({ id: r.id }, r.signalName, r.payload);
|
|
707
|
-
}, t, `action.${Nn.name}`), O[Pn.name] = (t) => J(async (t, n) => {
|
|
708
|
-
let r = t;
|
|
709
|
-
return await rt(e.store, n.subject, { id: r.id }), _.update({ id: r.id }, r.updateName, r.payload, r.timeoutMs === void 0 ? void 0 : { timeoutMs: r.timeoutMs });
|
|
710
|
-
}, t, `action.${Pn.name}`));
|
|
711
|
-
let Ot = [
|
|
712
|
-
...D(e.discovered.queries).map((e) => R(e.descriptor)),
|
|
713
|
-
...D(e.discovered.mutations).map((e) => L(e.descriptor)),
|
|
714
|
-
...D(e.discovered.actions).map((e) => I(e.descriptor)),
|
|
715
|
-
...dt.queries.map((e) => R(e.descriptor)),
|
|
716
|
-
...dt.mutations.map((e) => L(e.descriptor)),
|
|
717
|
-
...ft.queries.map((e) => R(e.descriptor)),
|
|
718
|
-
...ft.mutations.map((e) => L(e.descriptor)),
|
|
719
|
-
...x.queries.map((e) => R(e.descriptor)),
|
|
720
|
-
...x.mutations.map((e) => L(e.descriptor)),
|
|
721
|
-
...x.actions.map((e) => I(e.descriptor)),
|
|
722
|
-
...D(e.discovered.streams ?? []).map((e) => On(e.descriptor)),
|
|
723
|
-
...S.rpcs,
|
|
724
|
-
...(e.discovered.workflows ?? []).map((e) => Zr(e.definition)),
|
|
725
|
-
...ve ? [
|
|
726
|
-
R(V),
|
|
727
|
-
R(Mn),
|
|
728
|
-
R(H),
|
|
729
|
-
R(B),
|
|
730
|
-
R(An),
|
|
731
|
-
R(z),
|
|
732
|
-
I(kn),
|
|
733
|
-
I(jn),
|
|
734
|
-
I(Nn),
|
|
735
|
-
I(Pn)
|
|
736
|
-
] : []
|
|
737
|
-
], jt = Hn.make(...Ot).middleware(wn).middleware(Tn), Mt = br({ resolveSubject: ({ headers: t, clientId: n }) => e.resolveSubject(t, n) }), Nt = e.dormancyTenantId ?? Yn, Pt = e.dormancy === "sleep" ? {
|
|
738
|
-
register: (t, n, r) => Rr(e.store, {
|
|
739
|
-
tenantId: r ?? Nt,
|
|
740
|
-
kind: "workflow",
|
|
741
|
-
refId: t,
|
|
742
|
-
wakeAt: n
|
|
743
|
-
}),
|
|
744
|
-
cancel: (t, n) => or(e.store, {
|
|
745
|
-
tenantId: n ?? Nt,
|
|
746
|
-
kind: "workflow",
|
|
747
|
-
refId: t
|
|
748
|
-
}).then(() => {})
|
|
749
|
-
} : void 0, A = ye ? await import("@voltro/workflow") : void 0, j = A?.makeWorkflowRunRecorder({
|
|
750
|
-
store: e.store,
|
|
751
|
-
...e.workflowRecording === void 0 ? {} : { recording: e.workflowRecording },
|
|
752
|
-
...Pt === void 0 ? {} : { wakeups: Pt }
|
|
753
|
-
}), Lt = async (t, n) => {
|
|
754
|
-
await A.closeWorkflowChildrenForParent({
|
|
755
|
-
store: e.store,
|
|
756
|
-
parentExecutionId: t,
|
|
757
|
-
parentStatus: n,
|
|
758
|
-
recorder: j,
|
|
759
|
-
log: { warn: (e, t) => {
|
|
760
|
-
process.stderr.write(`[workflow] ${e} ${t ? JSON.stringify(t) : ""}\n`);
|
|
761
|
-
} },
|
|
762
|
-
interruptChild: async (t, n) => {
|
|
763
|
-
let r = (e.discovered.workflows ?? []).find((e) => e.definition.name === t);
|
|
764
|
-
if (!r) throw Error(`Unknown child workflow: ${t}`);
|
|
765
|
-
if (!p) throw Error("Workflow runtime is not ready");
|
|
766
|
-
await p.runPromise(r.definition.interrupt(n));
|
|
767
|
-
}
|
|
768
|
-
});
|
|
769
|
-
}, Rt = async (t, n, r) => {
|
|
770
|
-
let i = (await e.store.query({
|
|
771
|
-
table: "_voltro_workflow_runs",
|
|
772
|
-
order: [],
|
|
773
|
-
predicate: G("executionId", n),
|
|
774
|
-
projection: void 0,
|
|
775
|
-
skip: void 0,
|
|
776
|
-
take: 1
|
|
777
|
-
}))[0];
|
|
778
|
-
if (i === void 0) return;
|
|
779
|
-
let a = await e.store.update("_voltro_workflow_runs", i.id, {
|
|
780
|
-
status: "cancelled",
|
|
781
|
-
cancelled: !0,
|
|
782
|
-
completedAt: /* @__PURE__ */ new Date()
|
|
783
|
-
}), o = i.subject?.tenantId ?? void 0;
|
|
784
|
-
a && await j.recordEvent({
|
|
785
|
-
runId: i.id,
|
|
786
|
-
eventType: "run-cancelled",
|
|
787
|
-
payload: {
|
|
788
|
-
reason: r,
|
|
789
|
-
workflowName: t,
|
|
790
|
-
executionId: n,
|
|
791
|
-
...o == null ? {} : { tenantId: o }
|
|
792
|
-
}
|
|
793
|
-
}), a && await Lt(n, "cancelled");
|
|
794
|
-
}, zt = [
|
|
795
|
-
...X(e.discovered.workflows ?? [], {
|
|
796
|
-
buildContext: (t, n) => e.buildContextForWorkflow?.(t, n) ?? C({
|
|
797
|
-
subject: t.subject,
|
|
798
|
-
traceId: t.traceId
|
|
799
|
-
}, e.store, void 0, `workflow:${n.workflowName}`, { parentExecutionId: n.executionId }),
|
|
800
|
-
resolveStartContext: pe,
|
|
801
|
-
...ge === void 0 ? {} : { resolveAuthority: ge }
|
|
802
|
-
}, (t, n, r) => {
|
|
803
|
-
let i = A.getWorkflowVersionMetadata(t.definition);
|
|
804
|
-
return A.wrapWorkflowExecuteWithRunRecording({
|
|
805
|
-
name: t.definition.name,
|
|
806
|
-
store: e.store,
|
|
807
|
-
subject: r.subject,
|
|
808
|
-
source: r.source ?? null,
|
|
809
|
-
traceId: r.traceId,
|
|
810
|
-
workflowVersion: i.version,
|
|
811
|
-
workflowCompatibleVersions: i.compatibleWith,
|
|
812
|
-
workflowPatches: i.patches,
|
|
813
|
-
parentExecutionId: r?.parentExecutionId ?? null,
|
|
814
|
-
parentClosePolicy: r?.parentClosePolicy ?? null,
|
|
815
|
-
onParentClose: ({ executionId: e, status: t }) => Lt(e, t),
|
|
816
|
-
...Ge(t.definition),
|
|
817
|
-
onTerminal: async ({ executionId: e }) => {
|
|
818
|
-
await f?.gate.release(e);
|
|
819
|
-
},
|
|
820
|
-
recorder: j,
|
|
821
|
-
pluginWorkflowStepLayer: st,
|
|
822
|
-
recordRun: Lr
|
|
823
|
-
}, n);
|
|
824
|
-
}),
|
|
825
|
-
...e.discovered.workflowWorkers ?? [],
|
|
826
|
-
...Te === void 0 ? [] : [Te]
|
|
827
|
-
], Bt = [...(e.discovered.workflows ?? []).map((e) => e.definition.name).filter(Boolean), ...Te === void 0 ? [] : ["voltro.deliverWebhook"]], Vt = zt.length > 0 ? W.mergeAll(...zt) : W.empty;
|
|
828
|
-
if (((e.discovered.workflows?.length ?? 0) > 0 || (e.discovered.workflowWorkers?.length ?? 0) > 0 || e.scheduleCoordination === "cluster" || Te !== void 0) && e.workflowEngineLayer !== void 0) {
|
|
829
|
-
let t = Vt.pipe(W.provideMerge(e.workflowEngineLayer));
|
|
830
|
-
p = In.make(e.baseLayer === void 0 ? t : t.pipe(W.provideMerge(e.baseLayer))), await p.runPromise(U.void), (e.log ?? F({ scope: "voltro:serve" })).child("workflow").info(`workflow runtime ready — ${Bt.length} entity type(s) registered`, { entities: Bt });
|
|
831
|
-
let n = await import("@voltro/workflow/cluster"), r = (e) => p.runPromise(n.redriveFailedRun(e)), i = (e) => p.runPromise(n.resumeRunFromStep(e));
|
|
832
|
-
ce = await $e({
|
|
833
|
-
provider: _i(e.plugins ?? [])?.broadcast?.provider,
|
|
834
|
-
crossReplica: _i(e.plugins ?? [])?.broadcast?.crossReplica ?? !1,
|
|
835
|
-
namespace: ze,
|
|
836
|
-
replicaId: crypto.randomUUID(),
|
|
837
|
-
pollStorage: () => p.runPromise(n.pollWorkflowStorage),
|
|
838
|
-
onChange: (t) => e.store.onChange((e) => t({
|
|
839
|
-
table: e.table,
|
|
840
|
-
op: e.op,
|
|
841
|
-
...e.origin === void 0 ? {} : { origin: e.origin }
|
|
842
|
-
})),
|
|
843
|
-
log: (e.log ?? F({ scope: "voltro:serve" })).child("workflow")
|
|
844
|
-
}), te = async (t) => {
|
|
845
|
-
let n = await se({
|
|
846
|
-
store: e.store,
|
|
847
|
-
workflows: e.discovered.workflows ?? [],
|
|
848
|
-
runRedrive: r
|
|
849
|
-
}, t.runId);
|
|
850
|
-
return n.statusReset && await j.recordEvent({
|
|
851
|
-
runId: t.runId,
|
|
852
|
-
eventType: "run-redriven",
|
|
853
|
-
payload: {
|
|
854
|
-
reason: "inspect.redrive",
|
|
855
|
-
activitiesReset: n.outcome.activitiesReset
|
|
856
|
-
}
|
|
857
|
-
}), {
|
|
858
|
-
redriven: n.outcome.redriven,
|
|
859
|
-
activitiesReset: n.outcome.activitiesReset,
|
|
860
|
-
reason: n.outcome.reason
|
|
861
|
-
};
|
|
862
|
-
}, ne = async (t) => {
|
|
863
|
-
let n = await Oe({
|
|
864
|
-
store: e.store,
|
|
865
|
-
workflows: e.discovered.workflows ?? [],
|
|
866
|
-
runResume: i
|
|
867
|
-
}, t.runId, t.step);
|
|
868
|
-
return n.statusReset && await j.recordEvent({
|
|
869
|
-
runId: t.runId,
|
|
870
|
-
eventType: "run-redriven",
|
|
871
|
-
payload: {
|
|
872
|
-
reason: "inspect.resume-from-step",
|
|
873
|
-
step: n.stepName,
|
|
874
|
-
activitiesReset: n.outcome.activitiesReset
|
|
875
|
-
}
|
|
876
|
-
}), {
|
|
877
|
-
redriven: n.outcome.redriven,
|
|
878
|
-
stepName: n.stepName,
|
|
879
|
-
activitiesReset: n.outcome.activitiesReset,
|
|
880
|
-
reason: n.outcome.reason
|
|
881
|
-
};
|
|
882
|
-
};
|
|
883
|
-
let a = xr({
|
|
884
|
-
coordinator: (e.scheduleCoordination ?? "single") === "advisoryLock" ? hr(e.store, e.scheduleReplicaId ?? `pid-${process.pid}`) : Wr,
|
|
885
|
-
replicaId: e.scheduleReplicaId ?? `pid-${process.pid}`
|
|
886
|
-
}), s = {
|
|
887
|
-
info: (e, t) => {
|
|
888
|
-
process.stdout.write(`[flow-control] ${e} ${t ? JSON.stringify(t) : ""}\n`);
|
|
889
|
-
},
|
|
890
|
-
warn: (e, t) => {
|
|
891
|
-
process.stderr.write(`[flow-control] ${e} ${t ? JSON.stringify(t) : ""}\n`);
|
|
892
|
-
},
|
|
893
|
-
error: (e, t) => {
|
|
894
|
-
process.stderr.write(`[flow-control] ERROR ${e} ${t ? JSON.stringify(t) : ""}\n`);
|
|
895
|
-
}
|
|
896
|
-
}, c, u = () => {
|
|
897
|
-
if (c !== void 0) return c;
|
|
898
|
-
if (!(o === void 0 || j === void 0)) return c = ie({
|
|
899
|
-
store: e.store,
|
|
900
|
-
log: P,
|
|
901
|
-
workflows: e.discovered.workflows ?? [],
|
|
902
|
-
workflowsProxy: o,
|
|
903
|
-
workflowRuntime: p,
|
|
904
|
-
workflowRunRecorder: j,
|
|
905
|
-
closeChildrenForParent: Lt
|
|
906
|
-
}), c;
|
|
907
|
-
};
|
|
908
|
-
l = u, f = nt({
|
|
909
|
-
store: e.store,
|
|
910
|
-
onChange: (t) => e.store.onChange((e) => t({
|
|
911
|
-
table: e.table,
|
|
912
|
-
op: e.op
|
|
913
|
-
})),
|
|
914
|
-
...e.scheduling === void 0 ? {} : {
|
|
915
|
-
disarmWhenIdle: e.scheduling.disarmWhenIdle,
|
|
916
|
-
drainIntervalMs: e.scheduling.admissionDrainMs,
|
|
917
|
-
cancelSweepIntervalMs: e.scheduling.cancelSweepMs,
|
|
918
|
-
stalenessSweepIntervalMs: e.scheduling.stalenessSweepMs
|
|
919
|
-
},
|
|
920
|
-
workflows: e.discovered.workflows ?? [],
|
|
921
|
-
facade: () => o,
|
|
922
|
-
cancelRunWithReason: u,
|
|
923
|
-
recordRunEvent: () => j?.recordEvent,
|
|
924
|
-
...e.workflowStaleness === void 0 ? {} : { staleness: e.workflowStaleness },
|
|
925
|
-
...e.workflowSuspendSignalHintMs === void 0 ? {} : { suspendSignalHintMs: e.workflowSuspendSignalHintMs },
|
|
926
|
-
scheduleCoordinated: a,
|
|
927
|
-
onAbandoned: async (t) => {
|
|
928
|
-
await wt({
|
|
929
|
-
workflows: e.discovered.workflows ?? [],
|
|
930
|
-
facade: () => o,
|
|
931
|
-
log: s,
|
|
932
|
-
...t
|
|
933
|
-
});
|
|
934
|
-
},
|
|
935
|
-
log: s
|
|
936
|
-
});
|
|
937
|
-
let d = f;
|
|
938
|
-
d !== void 0 && Fr(() => d.stop()), ee = qe({
|
|
939
|
-
store: e.store,
|
|
940
|
-
onChange: (t) => e.store.onChange((e) => t({
|
|
941
|
-
table: e.table,
|
|
942
|
-
op: e.op
|
|
943
|
-
})),
|
|
944
|
-
...e.scheduling === void 0 ? {} : {
|
|
945
|
-
disarmWhenIdle: e.scheduling.disarmWhenIdle,
|
|
946
|
-
tickIntervalMs: e.scheduling.inferenceTickMs
|
|
947
|
-
},
|
|
948
|
-
enabled: (e.discovered.workflows?.length ?? 0) > 0,
|
|
949
|
-
resumeSignal: () => p === void 0 || A === void 0 ? void 0 : async ({ executionId: t, workflowName: n, signalName: r, payload: i }) => {
|
|
950
|
-
await p.runPromise(A.completeSuspendingSignal({
|
|
951
|
-
store: e.store,
|
|
952
|
-
target: kt(t, n),
|
|
953
|
-
signalName: r,
|
|
954
|
-
payload: i
|
|
955
|
-
}));
|
|
956
|
-
},
|
|
957
|
-
runEffect: (e) => p.runPromise(e),
|
|
958
|
-
scheduleCoordinated: a,
|
|
959
|
-
log: s
|
|
960
|
-
});
|
|
961
|
-
let re = ee;
|
|
962
|
-
re !== void 0 && Fr(() => re.stop()), o = (e.discovered.workflows?.length ?? 0) > 0 ? Mr({
|
|
963
|
-
workflows: e.discovered.workflows ?? [],
|
|
964
|
-
runEffect: (e) => p.runPromise(e),
|
|
965
|
-
onEnqueue: () => ce?.publishWake(),
|
|
966
|
-
...d === void 0 ? {} : {
|
|
967
|
-
admitStart: d.gate.admitStart,
|
|
968
|
-
startPayloadSchema: d.gate.startPayloadSchema,
|
|
969
|
-
parkDelayedStart: d.gate.parkDelayed
|
|
970
|
-
},
|
|
971
|
-
rememberStartContext: de,
|
|
972
|
-
signal: async (t, n, r) => {
|
|
973
|
-
let i = await A.sendWorkflowSignal({
|
|
974
|
-
store: e.store,
|
|
975
|
-
recorder: j,
|
|
976
|
-
target: t,
|
|
977
|
-
signalName: n,
|
|
978
|
-
payload: r
|
|
979
|
-
});
|
|
980
|
-
return await p.runPromise(A.completeSuspendingSignal({
|
|
981
|
-
store: e.store,
|
|
982
|
-
target: t,
|
|
983
|
-
signalName: n,
|
|
984
|
-
payload: r
|
|
985
|
-
})).catch(() => {}), i;
|
|
986
|
-
},
|
|
987
|
-
update: (t, n, r, i) => A.sendWorkflowUpdate({
|
|
988
|
-
store: e.store,
|
|
989
|
-
recorder: j,
|
|
990
|
-
target: t,
|
|
991
|
-
updateName: n,
|
|
992
|
-
payload: r,
|
|
993
|
-
...i === void 0 ? {} : { options: i }
|
|
994
|
-
}),
|
|
995
|
-
listRuns: (t) => Ae(e.store, t),
|
|
996
|
-
retry: (t, n) => Me({
|
|
997
|
-
store: e.store,
|
|
998
|
-
workflows: e.discovered.workflows ?? [],
|
|
999
|
-
runPromise: (e) => p.runPromise(e)
|
|
1000
|
-
}, t, n),
|
|
1001
|
-
redrive: (t) => se({
|
|
1002
|
-
store: e.store,
|
|
1003
|
-
workflows: e.discovered.workflows ?? [],
|
|
1004
|
-
runRedrive: r
|
|
1005
|
-
}, t).then((e) => e.outcome)
|
|
1006
|
-
}) : void 0;
|
|
1007
|
-
}
|
|
1008
|
-
let M = W.mergeAll(jt.toLayer(O), Mt), Ht = k(O, e.discovered.queries.map((e) => e.descriptor.name), ve), Ut = W.mergeAll(jt.toLayer(Ht), Mt), N = e.observability, Wt = await ar({
|
|
1009
|
-
...e.appName === void 0 ? {} : { serviceName: e.appName },
|
|
1010
|
-
...N && N.spanProcessors.length > 0 ? { extraSpanProcessors: N.spanProcessors } : {},
|
|
1011
|
-
...N && N.metricReaders.length > 0 ? { extraMetricReaders: N.metricReaders } : {},
|
|
1012
|
-
...N && Object.keys(N.resourceAttributes).length > 0 ? { resourceAttributes: N.resourceAttributes } : {},
|
|
1013
|
-
...N && N.sampler !== void 0 ? { sampler: N.sampler } : {}
|
|
1014
|
-
}), Gt = !1, Kt = e.store.ping ? () => e.store.ping().then(() => !0).catch(() => !1) : void 0, { server: qt, shutdown: Jt } = Gr({
|
|
1015
|
-
group: jt,
|
|
1016
|
-
handlersLayer: M,
|
|
1017
|
-
httpHandlersLayer: Ut,
|
|
1018
|
-
port: e.port ?? 4e3,
|
|
1019
|
-
...e.host === void 0 ? {} : { host: e.host },
|
|
1020
|
-
path: e.path ?? "/ws",
|
|
1021
|
-
tracerLayer: Wt.layer,
|
|
1022
|
-
security: xe(e),
|
|
1023
|
-
...it,
|
|
1024
|
-
healthCheck: {
|
|
1025
|
-
isReady: () => Gt,
|
|
1026
|
-
...Kt ? { ping: Kt } : {}
|
|
1027
|
-
},
|
|
1028
|
-
...Dt.length > 0 ? { httpRoutes: Dt } : {},
|
|
1029
|
-
...e.getStore === void 0 ? {} : { getStore: e.getStore },
|
|
1030
|
-
...Ee.size > 0 ? { webhookRoutes: Ee } : {},
|
|
1031
|
-
...e.inspectRoute === void 0 ? {} : { inspectRoute: e.inspectRoute }
|
|
1032
|
-
}), Yt = Ai(qt);
|
|
1033
|
-
if (await rr(qt), (e.discovered.schedules?.length ?? 0) > 0) {
|
|
1034
|
-
let t = (e.scheduleCoordination ?? "single") === "advisoryLock" ? hr(e.store, e.scheduleReplicaId ?? `pid-${process.pid}`) : Wr;
|
|
1035
|
-
le = await Kr(e.discovered.schedules ?? [], {
|
|
1036
|
-
store: e.store,
|
|
1037
|
-
coordinator: t,
|
|
1038
|
-
defaultTrigger: e.scheduleDefaultTrigger ?? "self",
|
|
1039
|
-
replicaId: e.scheduleReplicaId ?? `pid-${process.pid}`,
|
|
1040
|
-
armSelf: e.scheduleArmSelf ?? !0,
|
|
1041
|
-
dormancy: e.dormancy ?? "always-on",
|
|
1042
|
-
...e.dormancyTenantId === void 0 ? {} : { dormancyTenantId: e.dormancyTenantId },
|
|
1043
|
-
buildContext: ({ traceId: t, scheduleName: n, subject: r }) => C({
|
|
1044
|
-
subject: r,
|
|
1045
|
-
traceId: t
|
|
1046
|
-
}, e.store, void 0, `schedule:${n}`),
|
|
1047
|
-
log: {
|
|
1048
|
-
info: (e, t) => {
|
|
1049
|
-
process.stdout.write(`[schedule] ${e} ${t ? JSON.stringify(t) : ""}\n`);
|
|
1050
|
-
},
|
|
1051
|
-
warn: (e, t) => {
|
|
1052
|
-
process.stderr.write(`[schedule] ${e} ${t ? JSON.stringify(t) : ""}\n`);
|
|
1053
|
-
},
|
|
1054
|
-
error: (e, t) => {
|
|
1055
|
-
process.stderr.write(`[schedule] ERROR ${e} ${t ? JSON.stringify(t) : ""}\n`);
|
|
1056
|
-
},
|
|
1057
|
-
debug: () => {}
|
|
1058
|
-
},
|
|
1059
|
-
...e.scheduleFireInterceptor === void 0 ? {} : { interceptFire: e.scheduleFireInterceptor },
|
|
1060
|
-
...e.onScheduleRunEvent === void 0 ? {} : { onRunEvent: e.onScheduleRunEvent }
|
|
1061
|
-
}), e.onSchedulerReady?.(le);
|
|
1062
|
-
}
|
|
1063
|
-
let P = e.log ?? F({ scope: "voltro:serve" }), Xt, Zt;
|
|
1064
|
-
if ((e.discovered.subscribers?.length ?? 0) > 0 && (Xt = Ie(e.discovered.subscribers ?? [], e.store, P.child("subscribe"), e.schemaRegistry, S.bus)), (e.discovered.reactions?.length ?? 0) > 0) {
|
|
1065
|
-
let t = P.child("reaction"), n = async (n, r) => {
|
|
1066
|
-
if (n.kind === "workflow") {
|
|
1067
|
-
if (_ === void 0) {
|
|
1068
|
-
t.warn("reaction workflow act skipped — no workflow engine in this app", { workflow: n.workflow });
|
|
1069
|
-
return;
|
|
1070
|
-
}
|
|
1071
|
-
let e = n.payload === void 0 ? r.new ?? r.old ?? {} : n.payload(r);
|
|
1072
|
-
await Nr(_, {
|
|
1073
|
-
traceId: `reaction:${n.workflow}`,
|
|
1074
|
-
source: `reaction:${n.workflow}`
|
|
1075
|
-
}).start(n.workflow, e);
|
|
1076
|
-
return;
|
|
1077
|
-
}
|
|
1078
|
-
await ot(n.agent, r, {
|
|
1079
|
-
findAgentSend: (t) => e.discovered.actions.find((e) => e.descriptor.name === `${t}.send`),
|
|
1080
|
-
runAction: (e, t, n) => Promise.resolve(pt(e, t, n)),
|
|
1081
|
-
makeSubject: (e) => En(e),
|
|
1082
|
-
now: () => Date.now(),
|
|
1083
|
-
log: t
|
|
1084
|
-
});
|
|
1085
|
-
}, r = async (n, r) => {
|
|
1086
|
-
try {
|
|
1087
|
-
let { requireAiBudget: t } = await import("@voltro/ai");
|
|
1088
|
-
return (await U.runPromise(U.either(t(e.store, {
|
|
1089
|
-
tenantId: n,
|
|
1090
|
-
limitUsd: r
|
|
1091
|
-
}))))._tag === "Right";
|
|
1092
|
-
} catch (e) {
|
|
1093
|
-
return t.warn("reaction budget check failed — refusing the act", { tenantId: n }, e), !1;
|
|
1094
|
-
}
|
|
1095
|
-
}, i = ut(e.store, { onError: (e) => t.warn("reaction: rate-slot claim failed; refusing the act", { cause: String(e) }) });
|
|
1096
|
-
Zt = u(e.discovered.reactions ?? [], e.store, {
|
|
1097
|
-
runAct: n,
|
|
1098
|
-
checkBudget: r,
|
|
1099
|
-
claimRateSlot: (e) => i.claim(e)
|
|
1100
|
-
}, t);
|
|
1101
|
-
}
|
|
1102
|
-
let Qt;
|
|
1103
|
-
(e.discovered.aggregates?.length ?? 0) > 0 && (Qt = await De({
|
|
1104
|
-
discovered: e.discovered.aggregates ?? [],
|
|
1105
|
-
store: e.store,
|
|
1106
|
-
log: P.child("aggregate"),
|
|
1107
|
-
...e.analytics === void 0 ? {} : { analytics: e.analytics },
|
|
1108
|
-
...e.aggregateStorage === void 0 ? {} : { storage: e.aggregateStorage },
|
|
1109
|
-
...e.aggregateCoordinator === void 0 ? {} : { coordinator: e.aggregateCoordinator }
|
|
1110
|
-
}), Je = W.succeed(qn, Qt.registry));
|
|
1111
|
-
let $t;
|
|
1112
|
-
(e.discovered.expectations?.length ?? 0) > 0 && ($t = er({
|
|
1113
|
-
discovered: e.discovered.expectations ?? [],
|
|
1114
|
-
store: e.store,
|
|
1115
|
-
log: P.child("expectation")
|
|
1116
|
-
}), Ye = W.succeed(Zn, $t.registry)), (e.discovered.budgets?.length ?? 0) > 0 && (n = nr({
|
|
1117
|
-
discovered: e.discovered.budgets ?? [],
|
|
1118
|
-
log: P.child("finops")
|
|
1119
|
-
}), Xe = W.succeed(Jn, n.registry));
|
|
1120
|
-
let en;
|
|
1121
|
-
return (e.discovered.experiments?.length ?? 0) > 0 && (en = tr({
|
|
1122
|
-
discovered: e.discovered.experiments ?? [],
|
|
1123
|
-
store: e.store,
|
|
1124
|
-
log: P.child("experiment")
|
|
1125
|
-
}), Ze = W.succeed(q, en.registry)), Gt = !0, e.bootTiming?.mark("ready"), {
|
|
1126
|
-
dispatcher: r,
|
|
1127
|
-
server: qt,
|
|
1128
|
-
scheduler: le,
|
|
1129
|
-
eventsSnapshot: _e(S.bus, S.declared),
|
|
1130
|
-
membersSnapshot: () => ({
|
|
1131
|
-
members: We.membership.list(),
|
|
1132
|
-
capturedAt: Date.now()
|
|
1133
|
-
}),
|
|
1134
|
-
agentTools: () => St,
|
|
1135
|
-
rpcMetrics: () => w,
|
|
1136
|
-
webhooksService: () => we,
|
|
1137
|
-
runCanceller: () => l(),
|
|
1138
|
-
flowControlHealth: () => f?.cancelHealth(),
|
|
1139
|
-
inferenceHealth: () => ee?.health(),
|
|
1140
|
-
workflowWriteActions: () => _ === void 0 || j === void 0 ? void 0 : h({
|
|
1141
|
-
store: e.store,
|
|
1142
|
-
log: P,
|
|
1143
|
-
workflows: e.discovered.workflows ?? [],
|
|
1144
|
-
workflowsProxy: o,
|
|
1145
|
-
workflowRuntime: p,
|
|
1146
|
-
workflowRunRecorder: j,
|
|
1147
|
-
closeChildrenForParent: Lt
|
|
1148
|
-
}),
|
|
1149
|
-
redriveWorkflowRun: (e) => te ? te(e) : Promise.reject(/* @__PURE__ */ Error("redrive: this app registers no workflows")),
|
|
1150
|
-
resumeWorkflowRunFromStep: (e) => ne ? ne(e) : Promise.reject(/* @__PURE__ */ Error("resume-from-step: this app registers no workflows")),
|
|
1151
|
-
close: async () => {
|
|
1152
|
-
Gt = !1, await Yt.drainRequests();
|
|
1153
|
-
for (let e of je) try {
|
|
1154
|
-
await e();
|
|
1155
|
-
} catch (e) {
|
|
1156
|
-
P.warn("serve: teardown step failed", {}, e);
|
|
1157
|
-
}
|
|
1158
|
-
await Ke?.detach(), await We.detach(), Qt?.detach(), $t?.detach(), n?.detach(), en?.detach(), Zt?.(), Xt?.(), await le?.shutdown(), r.close(), await ce?.detach(), await p?.dispose(), await Jt(), await Yt.finish();
|
|
1159
|
-
}
|
|
1160
|
-
};
|
|
1161
|
-
}, $ = F({ scope: "voltro:serve" }), qi = (e, t, n) => (e === "production" || e === "staging") && t !== "memory" && n !== "0", Ji = Rt, Yi = async (e) => {
|
|
1162
|
-
let t = _n(process.cwd());
|
|
1163
|
-
if (Sn(t)) {
|
|
1164
|
-
let n;
|
|
1165
|
-
try {
|
|
1166
|
-
let e = await import(Cn(t).href);
|
|
1167
|
-
typeof e.runServe == "function" ? n = e.runServe : $.warn("serve bundle has no runServe export — using the standard serve path");
|
|
1168
|
-
} catch (e) {
|
|
1169
|
-
$.warn("serve bundle failed to load — using the standard serve path", {}, e);
|
|
1170
|
-
}
|
|
1171
|
-
if (n) return $.info("serve: booting from the precompiled serve bundle"), n(e);
|
|
1172
|
-
}
|
|
1173
|
-
return Xi(e);
|
|
1174
|
-
}, Xi = async (s) => {
|
|
1175
|
-
let c = vn();
|
|
1176
|
-
e("serve");
|
|
1177
|
-
try {
|
|
1178
|
-
ai();
|
|
1179
|
-
} catch (e) {
|
|
1180
|
-
throw i(e instanceof Error ? e.message : String(e));
|
|
1181
|
-
}
|
|
1182
|
-
let u = process.cwd(), d = await We(u), re = zt({
|
|
1183
|
-
kind: "api",
|
|
1184
|
-
configPort: d?.port,
|
|
1185
|
-
env: process.env,
|
|
1186
|
-
flagPort: Ji(s, "--port")
|
|
1187
|
-
});
|
|
1188
|
-
for (let e of re.warnings) $.warn(e);
|
|
1189
|
-
let ie = re.port;
|
|
1190
|
-
Vr(zr(d?.secrets)), await Vt({
|
|
1191
|
-
rawEnv: d?.env,
|
|
1192
|
-
appType: "api",
|
|
1193
|
-
root: u,
|
|
1194
|
-
log: $,
|
|
1195
|
-
generateTypes: !1
|
|
1196
|
-
}), c.mark("config");
|
|
1197
|
-
let m = (process.env.DB_DIALECT ?? d?.store ?? "memory").toLowerCase(), ae = (m === "mariadb" || m === "postgres" || m === "mssql") && (process.env.CDC ?? "1") !== "0", oe = m === "mariadb" ? "mariadb" : m === "mssql" ? "mssql" : void 0, se = gn(u);
|
|
1198
|
-
if (!r() && Sn(se)) try {
|
|
1199
|
-
let e = await import(Cn(se).href);
|
|
1200
|
-
if (e.modules) {
|
|
1201
|
-
let t = {};
|
|
1202
|
-
for (let [n, r] of Object.entries(e.modules)) t[xn(u, n)] = r;
|
|
1203
|
-
n(t), $.info("precompiled api bundle loaded", { modules: Object.keys(t).length });
|
|
1204
|
-
}
|
|
1205
|
-
} catch (e) {
|
|
1206
|
-
$.warn("precompiled api bundle failed to load — falling back to source", {}, e);
|
|
1207
|
-
}
|
|
1208
|
-
let h = await Ye(u), g = await Dt(h, { cdc: ae && oe !== void 0 }), fe = le(g);
|
|
1209
|
-
{
|
|
1210
|
-
let e = /* @__PURE__ */ new Set([
|
|
1211
|
-
...g.queries.filter((e) => e.descriptor.overridesPlugin === !0).map((e) => e.descriptor.name),
|
|
1212
|
-
...g.mutations.filter((e) => e.descriptor.overridesPlugin === !0).map((e) => e.descriptor.name),
|
|
1213
|
-
...g.actions.filter((e) => e.descriptor.overridesPlugin === !0).map((e) => e.descriptor.name)
|
|
1214
|
-
]);
|
|
1215
|
-
qt(Kt(d?.plugins ?? []), [
|
|
1216
|
-
...g.queries.map((e) => e.descriptor.name),
|
|
1217
|
-
...g.mutations.map((e) => e.descriptor.name),
|
|
1218
|
-
...g.actions.map((e) => e.descriptor.name),
|
|
1219
|
-
...g.streams.map((e) => e.descriptor.name)
|
|
1220
|
-
], e);
|
|
1221
|
-
let t = ce(g.serverOnlyLeaks, je(process.env, "strict"), lr, "`voltro serve`");
|
|
1222
|
-
if (t.action === "fail") throw i(t.message ?? "");
|
|
1223
|
-
t.action === "warn" && $.warn(t.message ?? "");
|
|
1224
|
-
}
|
|
1225
|
-
let me = h.filter((e) => mn.test(e)), he = me.length > 0 ? await pn(me, $.child("webhooks")) : {
|
|
1226
|
-
outgoing: [],
|
|
1227
|
-
incoming: [],
|
|
1228
|
-
providers: []
|
|
1229
|
-
}, _e = dn(g.events), Se = he.outgoing.length + he.incoming.length + he.providers.length + _e.length === 0 ? void 0 : {
|
|
1230
|
-
...he,
|
|
1231
|
-
outgoing: [...he.outgoing, ..._e]
|
|
1232
|
-
}, De = $t({
|
|
1233
|
-
nodeEnv: process.env.NODE_ENV,
|
|
1234
|
-
cdcDialect: oe,
|
|
1235
|
-
declared: d?.schema
|
|
1236
|
-
}), Oe = Yt({
|
|
1237
|
-
gates: De,
|
|
1238
|
-
runtime: {
|
|
1239
|
-
traces: be(),
|
|
1240
|
-
undo: Jr()
|
|
1241
|
-
}
|
|
1242
|
-
});
|
|
1243
|
-
if (Oe !== void 0) throw i(`serve: ${Oe}`);
|
|
1244
|
-
let ke = Qt({
|
|
1245
|
-
mix: g.featureMix,
|
|
1246
|
-
plugins: d?.plugins ?? [],
|
|
1247
|
-
gates: De,
|
|
1248
|
-
...oe ? { cdcDialect: oe } : {}
|
|
1249
|
-
}), Ae = d?.analytics !== void 0 && d.analytics.kind !== "noop" && m !== "memory" ? (await M(m)).makeSqlLayer(E()) : void 0, Me = await x({
|
|
1250
|
-
spec: d?.analytics,
|
|
1251
|
-
sqlLayer: Ae,
|
|
1252
|
-
log: $
|
|
1253
|
-
}), y = (() => {
|
|
1254
|
-
let e = new Set(g.tables.map((e) => e.tableName)), t = [...g.tables];
|
|
1255
|
-
for (let n of [...ke, ...Me.tables]) e.has(n.tableName) || (e.add(n.tableName), t.push(n));
|
|
1256
|
-
return t;
|
|
1257
|
-
})();
|
|
1258
|
-
for (let e of y) Kn(e);
|
|
1259
|
-
{
|
|
1260
|
-
let e = ur(Yr(g.queries.map((e) => ({
|
|
1261
|
-
name: e.descriptor.name,
|
|
1262
|
-
source: e.descriptor.source
|
|
1263
|
-
})), new Set(y.flatMap((e) => {
|
|
1264
|
-
let t = e.tableName;
|
|
1265
|
-
return t === void 0 ? [] : [t];
|
|
1266
|
-
}))));
|
|
1267
|
-
e !== void 0 && $.warn(e);
|
|
1268
|
-
}
|
|
1269
|
-
let Ne = (process.env.NODE_ENV ?? "").toLowerCase();
|
|
1270
|
-
if (qi(Ne, m, process.env.VOLTRO_AUTO_MIGRATE)) {
|
|
1271
|
-
let e = (await M(m)).makeSqlLayer(E()), t = await U.runPromise(Ln.SqlClient.pipe(U.flatMap((e) => Bn(e, u)), U.provide(e), U.catchAll(() => U.succeed([]))));
|
|
1272
|
-
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));
|
|
1273
|
-
let n = await U.runPromise(Ln.SqlClient.pipe(U.flatMap((e) => Vn(e, y, {
|
|
1274
|
-
appliedBy: `serve:${Ne}`,
|
|
1275
|
-
environment: "prod",
|
|
1276
|
-
dialectId: m
|
|
1277
|
-
})), U.provide(e)));
|
|
1278
|
-
n.kind === "prod-mismatch" && ($.error(zn(n, m)), $.error(Xt({
|
|
1279
|
-
gates: De,
|
|
1280
|
-
nodeEnv: process.env.NODE_ENV,
|
|
1281
|
-
cdcDialect: oe,
|
|
1282
|
-
declared: d?.schema
|
|
1283
|
-
})), $.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(zn(n, m));
|
|
1284
|
-
}
|
|
1285
|
-
await Gt({
|
|
1286
|
-
dialectId: m,
|
|
1287
|
-
tables: y,
|
|
1288
|
-
mode: N(d?.reactiveTriggers),
|
|
1289
|
-
lockSchema: E().schema,
|
|
1290
|
-
makeLayer: async () => (await M(m)).makeSqlLayer(E()),
|
|
1291
|
-
log: {
|
|
1292
|
-
info: (e, t) => $.info(e, t ?? {}),
|
|
1293
|
-
warn: (e, t) => $.warn(e, t ?? {})
|
|
1294
|
-
}
|
|
1295
|
-
});
|
|
1296
|
-
let Ie = jr(y);
|
|
1297
|
-
c.mark("discover");
|
|
1298
|
-
let b = await T(d, void 0), Le = Qr(b, m);
|
|
1299
|
-
for (let e of Xe({
|
|
1300
|
-
dialect: String(d?.store ?? process.env.DB_DIALECT ?? "postgres"),
|
|
1301
|
-
changeStrategy: (process.env.CDC ?? "1") === "0" ? "inline" : "cdc",
|
|
1302
|
-
dbUrl: process.env.DB_URL,
|
|
1303
|
-
crossReplicaBus: _i(d?.plugins ?? [])?.broadcast.crossReplica === !0,
|
|
1304
|
-
tables: g.tables.map((e) => ({
|
|
1305
|
-
tableName: e.tableName,
|
|
1306
|
-
isReactive: e.isReactive === !0
|
|
1307
|
-
})),
|
|
1308
|
-
querySources: g.queries.flatMap((e) => {
|
|
1309
|
-
let t = e.descriptor.source;
|
|
1310
|
-
return t === void 0 ? [] : typeof t == "string" ? [t] : [...t];
|
|
1311
|
-
})
|
|
1312
|
-
})) e.level === "warn" ? $.warn(e.message) : $.info(e.message);
|
|
1313
|
-
{
|
|
1314
|
-
let e = Ke(Ot({
|
|
1315
|
-
tables: Un().map((e) => ({ tableName: e.tableName })),
|
|
1316
|
-
queries: g.queries.map((e) => ({
|
|
1317
|
-
name: e.descriptor.name,
|
|
1318
|
-
source: e.descriptor.source
|
|
1319
|
-
}))
|
|
1320
|
-
}));
|
|
1321
|
-
e !== void 0 && $.warn(e);
|
|
1322
|
-
}
|
|
1323
|
-
d?.cache && !process.env.CACHE_BACKEND && (process.env.CACHE_BACKEND = d.cache), d?.cacheRedisUrl && !process.env.CACHE_REDIS_URL && (process.env.CACHE_REDIS_URL = d.cacheRedisUrl), d?.cacheRedisDriver && !process.env.CACHE_REDIS_DRIVER && (process.env.CACHE_REDIS_DRIVER = d.cacheRedisDriver), d?.cacheKeyPrefix && !process.env.CACHE_KEY_PREFIX && (process.env.CACHE_KEY_PREFIX = d.cacheKeyPrefix);
|
|
1324
|
-
let { service: Be, invalidationBus: Ue, snapshotCache: Ge, cache: qe, semantic: $e, evictSource: nt, backend: rt, stats: at, dispose: ot } = await lt({
|
|
1325
|
-
env: process.env,
|
|
1326
|
-
semantic: d?.cacheSemantic ?? !1
|
|
1327
|
-
});
|
|
1328
|
-
$e !== void 0 && $.info("semantic cache enabled — reactive eviction on live writes"), $.info(`cache backend resolved: ${rt}` + (rt === "redis" ? ` (driver ${process.env.CACHE_REDIS_DRIVER ?? "resp"})` : " — in-process, not cross-instance")), b.onChange((e) => {
|
|
1329
|
-
if (U.runFork(Ue.publish(e.table)), nt !== void 0) {
|
|
1330
|
-
let t = (e.new ?? e.old)?.id;
|
|
1331
|
-
nt({
|
|
1332
|
-
table: e.table,
|
|
1333
|
-
op: e.op,
|
|
1334
|
-
...t === void 0 ? {} : { id: t }
|
|
1335
|
-
});
|
|
1336
|
-
}
|
|
1337
|
-
}), d?.kv && !process.env.KV_BACKEND && (process.env.KV_BACKEND = d.kv), d?.kvRedisUrl && !process.env.KV_REDIS_URL && (process.env.KV_REDIS_URL = d.kvRedisUrl), d?.kvKeyPrefix && !process.env.KV_KEY_PREFIX && (process.env.KV_KEY_PREFIX = d.kvKeyPrefix);
|
|
1338
|
-
let { kv: ut, service: gt } = await yr({ store: b });
|
|
1339
|
-
$.info(Ti(Ut(), Di(), m === "postgres" && (process.env.CDC ?? "1") !== "0" ? [{ reason: "CDC LISTEN consumer" }] : [], t.replicationSnapshot()?.replicaCount ?? 0)), c.mark("store");
|
|
1340
|
-
let yt = $n({
|
|
1341
|
-
store: b,
|
|
1342
|
-
sink: Me.sink,
|
|
1343
|
-
log: $
|
|
1344
|
-
}), wt = S({
|
|
1345
|
-
store: b,
|
|
1346
|
-
dialect: m,
|
|
1347
|
-
log: { info: (e) => $.info(e) }
|
|
1348
|
-
}), k = d?.plugins ?? [], kt = process.env.POD_NAME ?? process.env.HOSTNAME ?? `serve-${process.pid}`, Ft, It;
|
|
1349
|
-
m !== "memory" && (Ft = In.make((await M(m)).makeSqlLayer(E())), It = await Ft.runPromise(Ln.SqlClient));
|
|
1350
|
-
let Rt = [
|
|
1351
|
-
"postgres",
|
|
1352
|
-
"mariadb",
|
|
1353
|
-
"mysql",
|
|
1354
|
-
"mssql"
|
|
1355
|
-
].includes(m) ? hr(b, kt, $) : Wr, fn = ze(d?.scheduling), _n = xr({
|
|
1356
|
-
maxIdleIntervalMs: fn.pollCeilingMs,
|
|
1357
|
-
coordinator: Rt,
|
|
1358
|
-
replicaId: kt,
|
|
1359
|
-
log: $
|
|
1360
|
-
}), yn = [], F = process.env.POD_NAME ?? process.env.HOSTNAME ?? `serve-${process.pid}`, wn = _i(d?.plugins ?? [])?.broadcast?.provider, Tn = Qe(d?.plugins, d?.name ?? bn(u));
|
|
1361
|
-
{
|
|
1362
|
-
let e = tt(d?.plugins, d?.name ?? bn(u));
|
|
1363
|
-
e !== void 0 && $.warn(e);
|
|
1364
|
-
}
|
|
1365
|
-
let I = At(d?.plugins, {
|
|
1366
|
-
instanceId: F,
|
|
1367
|
-
namespace: Tn,
|
|
1368
|
-
meta: { mode: "serve" },
|
|
1369
|
-
logger: $
|
|
1370
|
-
}), En = {
|
|
1371
|
-
...It ? { sql: It } : {},
|
|
1372
|
-
instanceId: F,
|
|
1373
|
-
membership: I.membership,
|
|
1374
|
-
...wn === void 0 ? {} : { broadcast: wn },
|
|
1375
|
-
broadcastChannels: { presence: gi(Tn, "presence") },
|
|
1376
|
-
scheduleCoordinated: (e, t, n) => {
|
|
1377
|
-
let r = _n(e, t, n);
|
|
1378
|
-
return yn.push(r), r;
|
|
1379
|
-
}
|
|
1380
|
-
};
|
|
1381
|
-
for (let e of k) e.bindDataStore?.(Le, En);
|
|
1382
|
-
l({
|
|
1383
|
-
store: b,
|
|
1384
|
-
...st(),
|
|
1385
|
-
log: $
|
|
1386
|
-
});
|
|
1387
|
-
let Dn = k.filter((e) => typeof e.onChangeEvent == "function");
|
|
1388
|
-
if (Dn.length > 0) {
|
|
1389
|
-
let e = b.changeScope ?? "local";
|
|
1390
|
-
b.onChange((t) => {
|
|
1391
|
-
let n = _(t, e);
|
|
1392
|
-
for (let e of Dn) U.runFork(e.onChangeEvent(n).pipe(U.catchAllCause((t) => U.sync(() => $.warn(`plugin ${e.name} onChangeEvent failed`, { error: Fn.pretty(t) })))));
|
|
1393
|
-
});
|
|
1394
|
-
}
|
|
1395
|
-
let L = ue({
|
|
1396
|
-
plugins: k,
|
|
1397
|
-
appName: d?.name ?? "voltro-api",
|
|
1398
|
-
appType: "api",
|
|
1399
|
-
voltroVersion: process.env.npm_package_version ?? "0.0.0",
|
|
1400
|
-
log: $
|
|
1401
|
-
});
|
|
1402
|
-
k.length && await L.activate(), c.mark("plugins");
|
|
1403
|
-
let R = await L.gatherObservability(), On = {
|
|
1404
|
-
info: (e, t) => process.stdout.write(`[broadcast] ${e} ${t ? JSON.stringify(t) : ""}\n`),
|
|
1405
|
-
warn: (e, t) => process.stderr.write(`[broadcast] ${e} ${t ? JSON.stringify(t) : ""}\n`),
|
|
1406
|
-
debug: () => {}
|
|
1407
|
-
}, kn, An = await vt(b, d, m, Tn, On, (e, t) => {
|
|
1408
|
-
kn?.refreshAll(`broadcast gap: missed ${t} change(s) from ${e}`);
|
|
1409
|
-
}), z = d?.apiKeys, jn = (typeof z == "object" ? z.prefix : void 0) ?? "voltro_", B = z ? cr(b) : void 0, V = B ? _r({ flush: vr(B) }) : void 0;
|
|
1410
|
-
V && Fr(() => V.shutdown());
|
|
1411
|
-
let H = B ? gr(B, {
|
|
1412
|
-
prefix: jn,
|
|
1413
|
-
...V ? { usage: V } : {}
|
|
1414
|
-
}) : void 0, Mn = H ? [dr(H, { prefix: jn })] : [], Nn = bt([...d?.auth?.strategies ?? [], ...Mn], mi(d?.plugins ?? []), d?.auth?.anonymousTenantRequired ?? !1, d?.auth, () => Le), Pn = [...d?.restRoutes ?? [], ...H ? Qn(H, (typeof z == "object" ? z.managementPath : void 0) ?? "/v1/api-keys") : []], Hn = C(d?.idempotency, b), Wn = k.map((e) => e.services).filter((e) => e !== void 0), G = W.mergeAll(xt({
|
|
1415
|
-
analyticsLayer: Me.layer,
|
|
1416
|
-
cacheService: Be,
|
|
1417
|
-
kvService: gt,
|
|
1418
|
-
...$e === void 0 ? {} : { semanticCache: $e },
|
|
1419
|
-
pluginServices: Wn,
|
|
1420
|
-
userLayers: d?.layers ?? []
|
|
1421
|
-
}), mt(d?.http ?? {})), K = await it({
|
|
1422
|
-
files: h,
|
|
1423
|
-
store: b,
|
|
1424
|
-
log: $,
|
|
1425
|
-
seedPolicy: "report",
|
|
1426
|
-
seedPattern: sn,
|
|
1427
|
-
loadSeedFiles: Wt,
|
|
1428
|
-
startupPattern: tn,
|
|
1429
|
-
loadStartupFiles: a,
|
|
1430
|
-
runStartups: o,
|
|
1431
|
-
emailPattern: Ve,
|
|
1432
|
-
loadEmailFiles: _t,
|
|
1433
|
-
registerEmailTemplates: hi
|
|
1434
|
-
});
|
|
1435
|
-
(K.startupCount > 0 || K.emailCount > 0) && $.info("boot lifecycle", {
|
|
1436
|
-
startups: K.startupCount,
|
|
1437
|
-
emailTemplates: K.emailCount
|
|
1438
|
-
}), K.startups !== void 0 && Fr(async () => {
|
|
1439
|
-
await K.startups.stop();
|
|
1440
|
-
});
|
|
1441
|
-
let qn = ht({
|
|
1442
|
-
schedules: St({
|
|
1443
|
-
schedules: g.schedules,
|
|
1444
|
-
seeds: K.seeds,
|
|
1445
|
-
store: b,
|
|
1446
|
-
log: $.child("seeds")
|
|
1447
|
-
}),
|
|
1448
|
-
workflows: g.workflows ?? [],
|
|
1449
|
-
log: $.child("workflow-schedules")
|
|
1450
|
-
}), Jn = d?.scheduling ?? {}, Yn = Jn.trigger ?? "self", Xn = /* @__PURE__ */ new Set([
|
|
1451
|
-
"postgres",
|
|
1452
|
-
"mysql",
|
|
1453
|
-
"mariadb",
|
|
1454
|
-
"mssql"
|
|
1455
|
-
]), Zn = Jn.coordination ?? (Xn.has(m) ? "advisoryLock" : "single"), q = Zn === "cluster" && Xn.has(m), er = q ? "cluster" : Zn === "advisoryLock" && Xn.has(m) ? "advisoryLock" : "single";
|
|
1456
|
-
Zn === "cluster" && !q && $.warn("scheduling.coordination=cluster needs a sql-backed store except sqlite — falling back to single"), Zn === "advisoryLock" && !Xn.has(m) && $.warn("scheduling.coordination=advisoryLock needs a SQL store (the claim-row gate) — falling back to single");
|
|
1457
|
-
let tr, nr = g.workflows.length > 0 || g.workflowWorkers.length > 0 || g.eventTriggers.length > 0 || (Se?.outgoing.length ?? 0) > 0 || q, rr;
|
|
1458
|
-
if (nr) {
|
|
1459
|
-
if (m === "mssql") {
|
|
1460
|
-
let e = await un(process.cwd());
|
|
1461
|
-
e && $.warn(e);
|
|
1462
|
-
}
|
|
1463
|
-
let [{ WorkflowEngine: e }, { makeClusterCronLayer: t, workflowEngineLayer: n, resolveRunnerStorage: r, resolveFailoverTuning: i }] = await Promise.all([import("@effect/workflow"), import("@voltro/workflow/cluster")]), a = q ? qn.filter((e) => (e.trigger ?? Yn) === "self").map((e) => t({
|
|
1464
|
-
name: e.name,
|
|
1465
|
-
cron: sr(e),
|
|
1466
|
-
execute: async () => {
|
|
1467
|
-
await tr?.fireFromCluster(e.name);
|
|
1468
|
-
}
|
|
1469
|
-
})) : [];
|
|
1470
|
-
rr = m === "memory" ? e.layerMemory : await (async () => {
|
|
1471
|
-
let e = await M(m), t = r({ sqliteFamily: e.id === "sqlite" || e.id === "turso" });
|
|
1472
|
-
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({
|
|
1473
|
-
sqlClientLayer: e.makeSqlLayer(E()),
|
|
1474
|
-
runnerStorage: t,
|
|
1475
|
-
dialectId: e.id,
|
|
1476
|
-
...process.env.VOLTRO_WORKFLOW_RUNNER_PORT ? { runnerListenPort: Number(process.env.VOLTRO_WORKFLOW_RUNNER_PORT) } : {},
|
|
1477
|
-
...i(),
|
|
1478
|
-
...a.length > 0 ? { extraShardingLayers: a } : {}
|
|
1479
|
-
});
|
|
1480
|
-
})();
|
|
1481
|
-
}
|
|
1482
|
-
let J = de(k, hn()), ir = h.filter((e) => /\.subscribe\.tsx?$/.test(e)), Y = ir.length > 0 ? await Pe(ir, $) : [], ar = h.filter((e) => /\.reaction\.tsx?$/.test(e)), or = ar.length > 0 ? await ge(ar, $) : [], fr = h.filter((e) => an.test(e)), pr = fr.length > 0 ? await O(fr, $) : [], mr = h.filter((e) => /\.aggregate\.tsx?$/.test(e)), br = mr.length > 0 ? await te(mr, $) : [], Sr = ye();
|
|
1483
|
-
if (br.length > 0 && m !== "memory") try {
|
|
1484
|
-
Sr = ct((await M(m)).makeSqlLayer(E()));
|
|
1485
|
-
} catch (e) {
|
|
1486
|
-
$.warn("aggregate: SQL storage init failed — falling back to in-process", { err: String(e) });
|
|
1487
|
-
}
|
|
1488
|
-
let Cr = m === "memory" ? Wr : hr(b, `aggregate@${process.pid}`, $), wr = h.filter((e) => on.test(e)), Tr = wr.length > 0 ? await f(wr, $) : [], Er = h.filter((e) => rn.test(e)), Dr = Er.length > 0 ? await v(Er, $) : [], Or = h.filter((e) => nn.test(e)), kr = Or.length > 0 ? await Pt(Or, $) : [], Ar = [], Mr = [], Nr = h.filter((e) => Zt.test(e));
|
|
1489
|
-
if (Nr.length > 0) {
|
|
1490
|
-
let e = $.child("agent"), t = h.filter((e) => P.test(e));
|
|
1491
|
-
t.length > 0 && await en(t, e);
|
|
1492
|
-
let n = await Jt(Nr, e);
|
|
1493
|
-
for (let e of n.agents) for (let t of Je(e)) (t.kind === "action" ? Ar : Mr).push({
|
|
1494
|
-
file: t.file,
|
|
1495
|
-
descriptor: t.descriptor,
|
|
1496
|
-
executor: t.executor
|
|
1497
|
-
});
|
|
1498
|
-
n.agents.length > 0 && e.info("synthesized agent routes", { agents: n.agents.map((e) => e.descriptor.name) });
|
|
1499
|
-
}
|
|
1500
|
-
c.mark("workflow");
|
|
1501
|
-
let X = () => {
|
|
1502
|
-
let e = Z.workflowWriteActions();
|
|
1503
|
-
if (e === void 0) throw Error("workflow actions: this app registers no workflows");
|
|
1504
|
-
return e;
|
|
1505
|
-
}, Pr = Gn({
|
|
1506
|
-
dialect: m,
|
|
1507
|
-
...E()
|
|
1508
|
-
}), Ir = m === "memory" ? void 0 : (await M(m)).makeSqlLayer(E()), Lr = async () => Et({
|
|
1509
|
-
sqlLayer: Ir,
|
|
1510
|
-
declared: y,
|
|
1511
|
-
log: $
|
|
1512
|
-
}), Rr = {
|
|
1513
|
-
kind: "api",
|
|
1514
|
-
meta: {
|
|
1515
|
-
name: d?.name ?? "voltro-api",
|
|
1516
|
-
voltroVersion: Tt,
|
|
1517
|
-
port: ie,
|
|
1518
|
-
mode: "start",
|
|
1519
|
-
store: m,
|
|
1520
|
-
cdc: ae ? "on" : "off",
|
|
1521
|
-
...Pr === void 0 ? {} : { databaseId: Pr }
|
|
1522
|
-
},
|
|
1523
|
-
rpc: ft(g, u),
|
|
1524
|
-
workflows: w(g, u),
|
|
1525
|
-
migrations: Lr,
|
|
1526
|
-
events: () => Z.eventsSnapshot(),
|
|
1527
|
-
agentTools: () => Z.agentTools(),
|
|
1528
|
-
invariantChecks: () => ({
|
|
1529
|
-
mode: "serve",
|
|
1530
|
-
accessGate: fe,
|
|
1531
|
-
config: d,
|
|
1532
|
-
serverOnlyLeaks: g.serverOnlyLeaks,
|
|
1533
|
-
migrations: Lr
|
|
1534
|
-
}),
|
|
1535
|
-
members: () => Z.membersSnapshot(),
|
|
1536
|
-
inspectFireSchedule: async ({ name: e, trigger: t }) => {
|
|
1537
|
-
if (!tr) throw Error("scheduler not started — this app registers no self-triggered schedules (all schedules are trigger:'external', or there are none).");
|
|
1538
|
-
return { runId: await tr.fireNow(e, t) ?? null };
|
|
1539
|
-
},
|
|
1540
|
-
inspectBackfillSchedule: ne({
|
|
1541
|
-
getHandle: () => tr,
|
|
1542
|
-
getSchedules: () => qn
|
|
1543
|
-
}),
|
|
1544
|
-
...Se === void 0 ? {} : { webhooks: () => ve({
|
|
1545
|
-
store: b,
|
|
1546
|
-
discoveredWebhooks: Se
|
|
1547
|
-
}) },
|
|
1548
|
-
plugins: () => ({
|
|
1549
|
-
plugins: L.snapshot(),
|
|
1550
|
-
capturedAt: Date.now()
|
|
1551
|
-
}),
|
|
1552
|
-
env: () => Bt(d?.name ?? bn(u), {
|
|
1553
|
-
...d?.env !== void 0 && ii(d.env) ? { contract: d.env } : {},
|
|
1554
|
-
plugins: d?.plugins ?? []
|
|
1555
|
-
}),
|
|
1556
|
-
dataCache: () => He({
|
|
1557
|
-
stats: at,
|
|
1558
|
-
backendKind: rt
|
|
1559
|
-
}),
|
|
1560
|
-
subscriptions: () => A(() => kn),
|
|
1561
|
-
inspectTables: () => pe(g.tables),
|
|
1562
|
-
inspectRows: we({
|
|
1563
|
-
store: b,
|
|
1564
|
-
tables: g.tables,
|
|
1565
|
-
mask: !0
|
|
1566
|
-
}),
|
|
1567
|
-
metrics: (e) => Z.rpcMetrics().snapshot(e),
|
|
1568
|
-
cluster: () => j({
|
|
1569
|
-
store: b,
|
|
1570
|
-
dialect: m,
|
|
1571
|
-
useClusterCron: q,
|
|
1572
|
-
scheduleCoordChoice: Zn
|
|
1573
|
-
}),
|
|
1574
|
-
inspectSchedules: () => Ee({
|
|
1575
|
-
schedules: qn,
|
|
1576
|
-
defaultTrigger: Yn,
|
|
1577
|
-
coordination: er
|
|
1578
|
-
}),
|
|
1579
|
-
inspectScheduleRuns: (e) => Nt(b, e),
|
|
1580
|
-
...ee(b, {
|
|
1581
|
-
controls: pt(g.workflows ?? []),
|
|
1582
|
-
active: (g.workflows?.length ?? 0) > 0,
|
|
1583
|
-
cancellation: () => Z.flowControlHealth()
|
|
1584
|
-
}),
|
|
1585
|
-
webhookActions: Te(() => Z.webhooksService()),
|
|
1586
|
-
inspectStartWorkflow: (e) => X().inspectStartWorkflow(e),
|
|
1587
|
-
inspectCancelWorkflowRun: (e) => X().inspectCancelWorkflowRun(e),
|
|
1588
|
-
inspectSuspendWorkflowRun: (e) => X().inspectSuspendWorkflowRun(e),
|
|
1589
|
-
inspectResumeWorkflowRun: (e) => X().inspectResumeWorkflowRun(e),
|
|
1590
|
-
inspectDiscardWorkflowRun: (e) => X().inspectDiscardWorkflowRun(e),
|
|
1591
|
-
inspectRetryWorkflowRun: (e) => X().inspectRetryWorkflowRun(e),
|
|
1592
|
-
inspectSignalWorkflowRun: (e) => X().inspectSignalWorkflowRun(e),
|
|
1593
|
-
inspectUpdateWorkflowRun: (e) => X().inspectUpdateWorkflowRun(e),
|
|
1594
|
-
inspectInferences: (e) => Ze({
|
|
1595
|
-
store: b,
|
|
1596
|
-
active: (g.workflows?.length ?? 0) > 0,
|
|
1597
|
-
dispatcher: () => Z.inferenceHealth()
|
|
1598
|
-
}, e.limit === void 0 ? {} : { limit: e.limit }),
|
|
1599
|
-
...D({
|
|
1600
|
-
store: b,
|
|
1601
|
-
cancelRun: async (e) => await Z.runCanceller()?.(e) ?? !1,
|
|
1602
|
-
retryRun: async (e) => X().inspectRetryWorkflowRun({ runId: e }),
|
|
1603
|
-
redriveRun: async (e) => Z.redriveWorkflowRun({ runId: e }),
|
|
1604
|
-
log: $
|
|
1605
|
-
}),
|
|
1606
|
-
inspectRedriveWorkflowRun: (e) => Z.redriveWorkflowRun(e),
|
|
1607
|
-
inspectResumeWorkflowRunFromStep: (e) => Z.resumeWorkflowRunFromStep(e)
|
|
1608
|
-
}, Br = (process.env.VOLTRO_TENANT_ISOLATION ?? d?.tenancy?.isolation) === "namespace", Hr = Br && m !== "memory" ? await (async () => {
|
|
1609
|
-
let e = await M(m);
|
|
1610
|
-
return Ct({
|
|
1611
|
-
tables: y,
|
|
1612
|
-
sqlLayer: e.makeSqlLayer(E()),
|
|
1613
|
-
dialect: m,
|
|
1614
|
-
options: { retryFilter: e.retryFilter },
|
|
1615
|
-
log: {
|
|
1616
|
-
info: (e, t) => $.info(e, t),
|
|
1617
|
-
error: (e, t, n) => $.error(e, t ?? {}, n)
|
|
1618
|
-
}
|
|
1619
|
-
});
|
|
1620
|
-
})() : void 0, Ur = await dt({
|
|
1621
|
-
input: d?.tenancy?.residency,
|
|
1622
|
-
namespaceIsolationOn: Br,
|
|
1623
|
-
makeStoreForUrl: (e, t) => T(d, void 0, Ht(E(), t)),
|
|
1624
|
-
log: {
|
|
1625
|
-
info: (e, t) => $.info(e, t),
|
|
1626
|
-
warn: (e, t) => $.warn(e, t)
|
|
1627
|
-
}
|
|
1628
|
-
});
|
|
1629
|
-
Ur !== void 0 && Fr(async () => {
|
|
1630
|
-
await Ur.close();
|
|
1631
|
-
});
|
|
1632
|
-
let Z = await Ki({
|
|
1633
|
-
bootTiming: c,
|
|
1634
|
-
broadcastNamespace: Tn,
|
|
1635
|
-
scheduling: (() => {
|
|
1636
|
-
let e = fn;
|
|
1637
|
-
return {
|
|
1638
|
-
admissionDrainMs: e.admissionDrainMs,
|
|
1639
|
-
inferenceTickMs: e.inferenceTickMs,
|
|
1640
|
-
cancelSweepMs: e.cancelSweepMs,
|
|
1641
|
-
stalenessSweepMs: e.stalenessSweepMs,
|
|
1642
|
-
disarmWhenIdle: et({
|
|
1643
|
-
changeScope: b.changeScope,
|
|
1644
|
-
broadcastAttached: An !== void 0
|
|
1645
|
-
})
|
|
1646
|
-
};
|
|
1647
|
-
})(),
|
|
1648
|
-
...d?.workflows?.staleness === void 0 ? {} : { workflowStaleness: d.workflows.staleness },
|
|
1649
|
-
...d?.workflows?.suspendSignalHintMs === void 0 ? {} : { workflowSuspendSignalHintMs: d.workflows.suspendSignalHintMs },
|
|
1650
|
-
workflowRecording: Mt(d?.workflows?.recording),
|
|
1651
|
-
membership: {
|
|
1652
|
-
...I,
|
|
1653
|
-
instanceId: F
|
|
1654
|
-
},
|
|
1655
|
-
security: {
|
|
1656
|
-
defaultDeny: Lt(d),
|
|
1657
|
-
...xe(d)
|
|
1658
|
-
},
|
|
1659
|
-
approvals: { defaultExpiryMs: Fe(d) },
|
|
1660
|
-
...d?.plugins === void 0 ? {} : { plugins: d.plugins },
|
|
1661
|
-
...Hn ? { idempotency: Hn } : {},
|
|
1662
|
-
restRoutes: Pn,
|
|
1663
|
-
appProcedures: fe,
|
|
1664
|
-
discovered: {
|
|
1665
|
-
queries: [...g.queries, ...Mr],
|
|
1666
|
-
mutations: g.mutations,
|
|
1667
|
-
actions: [...g.actions, ...Ar],
|
|
1668
|
-
streams: g.streams,
|
|
1669
|
-
events: g.events,
|
|
1670
|
-
workflows: g.workflows,
|
|
1671
|
-
workflowWorkers: g.workflowWorkers,
|
|
1672
|
-
eventTriggers: g.eventTriggers,
|
|
1673
|
-
schedules: qn,
|
|
1674
|
-
subscribers: Y,
|
|
1675
|
-
outboxHandlers: pr,
|
|
1676
|
-
connections: g.connections,
|
|
1677
|
-
reactions: or,
|
|
1678
|
-
aggregates: br,
|
|
1679
|
-
expectations: Tr,
|
|
1680
|
-
budgets: Dr,
|
|
1681
|
-
experiments: kr,
|
|
1682
|
-
...Se === void 0 ? {} : { webhooks: Se }
|
|
1683
|
-
},
|
|
1684
|
-
log: $,
|
|
1685
|
-
analytics: Me.sink,
|
|
1686
|
-
aggregateStorage: Sr,
|
|
1687
|
-
aggregateCoordinator: Cr,
|
|
1688
|
-
store: b,
|
|
1689
|
-
kv: ut,
|
|
1690
|
-
cache: qe,
|
|
1691
|
-
snapshotCache: Ge,
|
|
1692
|
-
...d?.reactive === void 0 ? {} : { reactive: d.reactive },
|
|
1693
|
-
schemaRegistry: Ie,
|
|
1694
|
-
tenantScopedTables: g.tenantScopedTables,
|
|
1695
|
-
softDeleteScopedTables: g.softDeleteScopedTables,
|
|
1696
|
-
dataTransferSnapshot: Rn(y),
|
|
1697
|
-
dataTransferDialect: m,
|
|
1698
|
-
...Hr === void 0 ? {} : { ensureTenantProvisioned: Hr.ensure },
|
|
1699
|
-
...Ur === void 0 ? {} : { resolveResidentStore: Ur.resolveStore },
|
|
1700
|
-
tenantIsolation: (process.env.VOLTRO_TENANT_ISOLATION ?? d?.tenancy?.isolation) === "namespace" ? "namespace" : "shared-schema",
|
|
1701
|
-
resolveSubject: (e, t) => Nn({
|
|
1702
|
-
headers: e,
|
|
1703
|
-
clientId: t
|
|
1704
|
-
}),
|
|
1705
|
-
...d?.auth === void 0 ? {} : { authority: d.auth },
|
|
1706
|
-
...d?.agents === void 0 ? {} : { agents: d.agents },
|
|
1707
|
-
httpRoutes: k.flatMap((e) => e.httpRoutes ?? []),
|
|
1708
|
-
getStore: () => Le,
|
|
1709
|
-
...G ? { baseLayer: G } : {},
|
|
1710
|
-
...rr === void 0 ? {} : { workflowEngineLayer: rr },
|
|
1711
|
-
scheduleDefaultTrigger: Yn,
|
|
1712
|
-
scheduleCoordination: er,
|
|
1713
|
-
scheduleArmSelf: !q,
|
|
1714
|
-
dormancy: process.env.VOLTRO_DORMANCY === "sleep" || process.env.VOLTRO_DORMANCY === "always-on" ? process.env.VOLTRO_DORMANCY : d?.dormancy ?? "always-on",
|
|
1715
|
-
scheduleReplicaId: process.env.HOSTNAME ?? `pid-${process.pid}`,
|
|
1716
|
-
...J === void 0 ? {} : { scheduleFireInterceptor: J },
|
|
1717
|
-
onSchedulerReady: (e) => {
|
|
1718
|
-
tr = e;
|
|
1719
|
-
},
|
|
1720
|
-
inspectRoute: { handle: async (e, t, n, r) => await p(e, Rr, t, {
|
|
1721
|
-
method: n,
|
|
1722
|
-
...r === void 0 ? {} : { body: r }
|
|
1723
|
-
}) || ((n === "GET" ? await ln(e, Rr, t, { method: n }) : null) ?? cn(e, Rr, t, {
|
|
1724
|
-
method: n,
|
|
1725
|
-
...r === void 0 ? {} : { body: r }
|
|
1726
|
-
}) ?? {
|
|
1727
|
-
status: 404,
|
|
1728
|
-
contentType: "application/json",
|
|
1729
|
-
body: JSON.stringify({ error: "not an inspect route" })
|
|
1730
|
-
}) },
|
|
1731
|
-
...d?.name === void 0 ? {} : { appName: d.name },
|
|
1732
|
-
observability: R,
|
|
1733
|
-
port: ie,
|
|
1734
|
-
...d?.transport?.wsPath ? { path: d.transport.wsPath } : {}
|
|
1735
|
-
});
|
|
1736
|
-
return kn = Z.dispatcher, jt(Re([
|
|
1737
|
-
g.queries,
|
|
1738
|
-
g.mutations,
|
|
1739
|
-
g.actions,
|
|
1740
|
-
g.streams
|
|
1741
|
-
]), (e) => {
|
|
1742
|
-
$.warn(e);
|
|
1743
|
-
}), $.info(`API listening on :${ie}`, {
|
|
1744
|
-
dialect: m,
|
|
1745
|
-
queries: g.queries.length,
|
|
1746
|
-
mutations: g.mutations.length,
|
|
1747
|
-
actions: g.actions.length,
|
|
1748
|
-
streams: g.streams.length,
|
|
1749
|
-
workflows: g.workflows.length,
|
|
1750
|
-
workflowWorkers: g.workflowWorkers.length,
|
|
1751
|
-
schedules: qn.length,
|
|
1752
|
-
scheduleCoordination: er
|
|
1753
|
-
}), c.finish($), Fr(async () => {
|
|
1754
|
-
for (let e of yn) e.stop();
|
|
1755
|
-
wt.stop();
|
|
1756
|
-
try {
|
|
1757
|
-
await Z.close(), ot(), Ft?.dispose(), await L.deactivate(), await An?.close(), await Ce({
|
|
1758
|
-
mirror: yt,
|
|
1759
|
-
log: $
|
|
1760
|
-
}), await Me.dispose(), await b.close?.();
|
|
1761
|
-
} catch (e) {
|
|
1762
|
-
console.error("serve: shutdown step failed, exiting anyway:", e);
|
|
1763
|
-
}
|
|
1764
|
-
}), await new Promise(() => {}), 0;
|
|
1765
|
-
};
|
|
1766
|
-
//#endregion
|
|
1767
|
-
export { Yi as n, qi as r, Xi as t };
|