@voltro/cli 0.7.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +40 -0
- package/THIRD-PARTY-NOTICES.md +2 -2
- package/dist/apiBuild-Ba4njm9m.js +2 -0
- package/dist/{apiBuild-deIjJKJm.js → apiBuild-eInHm_bJ.js} +2 -2
- package/dist/bin.js +2 -2
- package/dist/{commands-BHdc71DG.js → commands-Cxs97AFp.js} +1897 -1664
- package/dist/{dev-Bqyq62Ak.js → dev-63Ehpw2p.js} +475 -475
- package/dist/dev-CXsR8Zgo.js +2 -0
- package/dist/index.js +1 -1
- package/dist/{inspectMetrics-BLUBAWLb.js → inspectMetrics-DVCKKSPk.js} +819 -510
- package/dist/{serveCommand-Dn6--0Bv.js → serveCommand-Cq7BhtpB.js} +3 -3
- package/dist/serveEntry.js +3 -3
- package/dist/{start-CWZW_4Et.js → start-CYe-7ueh.js} +371 -306
- package/dist/startEntry.js +2 -2
- package/package.json +18 -17
- package/templates/AGENTS.core.md +15 -4
- package/templates/AGENTS.md +15 -4
- package/templates/agent-docs/authentication.md +7 -4
- package/templates/agent-docs/cli.md +84 -5
- package/templates/agent-docs/data.md +94 -70
- package/templates/agent-docs/database/schema.md +1 -1
- package/templates/agent-docs/reference.md +20 -0
- package/templates/agent-docs/routing.md +183 -25
- package/templates/agent-docs/testing.md +24 -0
- package/templates/apps/api-ai/package.json +7 -7
- package/templates/apps/api-auth/package.json +8 -8
- package/templates/apps/api-backend/package.json +7 -7
- package/templates/apps/api-backend-deactivation/package.json +7 -7
- package/templates/apps/api-backend-mail/package.json +8 -8
- package/templates/apps/api-backend-mariadb/package.json +9 -9
- package/templates/apps/api-backend-storage/package.json +8 -8
- package/templates/apps/api-data-advanced/package.json +8 -8
- package/templates/apps/api-durable/package.json +8 -8
- package/templates/apps/api-feature-flags/package.json +9 -9
- package/templates/apps/api-governance/package.json +8 -8
- package/templates/apps/api-kv/package.json +8 -8
- package/templates/apps/api-moderation/package.json +8 -8
- package/templates/apps/api-observability/package.json +8 -8
- package/templates/apps/api-ratelimit/package.json +8 -8
- package/templates/apps/api-rbac/package.json +8 -8
- package/templates/apps/api-rest/package.json +7 -7
- package/templates/apps/api-saas/package.json +11 -11
- package/templates/apps/api-search/package.json +8 -8
- package/templates/apps/api-versioning/package.json +8 -8
- package/templates/apps/api-webhooks/package.json +8 -8
- package/templates/apps/changelog/package.json +6 -6
- package/templates/apps/edge-functions/package.json +2 -2
- package/templates/apps/frontend-admin/package.json +8 -8
- package/templates/apps/frontend-app/package.json +8 -8
- package/templates/apps/frontend-blank/package.json +7 -7
- package/templates/apps/frontend-contact/package.json +7 -7
- package/templates/apps/frontend-dashboard/package.json +7 -7
- package/templates/apps/frontend-docs/package.json +7 -7
- package/templates/apps/frontend-i18n/package.json +6 -6
- package/templates/apps/frontend-landing/package.json +7 -7
- package/templates/apps/frontend-spa/package.json +7 -7
- package/templates/apps/frontend-ssr/package.json +7 -7
- package/templates/apps/frontend-ssr-api/package.json +8 -8
- package/templates/apps/frontend-static-blog/package.json +6 -6
- package/dist/apiBuild-CSM74oEZ.js +0 -2
- package/dist/dev-BYfrYwrT.js +0 -2
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { $ as e,
|
|
2
|
-
import { i as
|
|
3
|
-
import { r as
|
|
4
|
-
import { t as
|
|
5
|
-
import { basename as
|
|
6
|
-
import { fileURLToPath as
|
|
7
|
-
import { FetchHttpClient as
|
|
8
|
-
import { Cause as
|
|
9
|
-
import { createLogger as
|
|
10
|
-
import { appendFileSync as
|
|
11
|
-
import { AggregateError as
|
|
1
|
+
import { $ as e, At as t, Dt as n, E as r, F as i, G as a, H as o, J as s, K as c, L as l, O as u, P as d, Q as f, S as p, St as m, U as h, V as g, W as _, X as ee, Y as te, Z as ne, _t as re, at as ie, ct as ae, dt as v, et as oe, ft as se, gt as ce, ht as le, it as ue, k as de, l as y, lt as fe, mt as b, nt as pe, ot as me, pt as he, q as ge, rt as _e, st as ve, t as ye, tt as be, ut as xe, w as Se, x as Ce, z as we } from "./inspectMetrics-DVCKKSPk.js";
|
|
2
|
+
import { i as x, n as Te, t as Ee } from "./startupRunner-DhlX9nqd.js";
|
|
3
|
+
import { r as De } from "./devActivity-1WtIVyHc.js";
|
|
4
|
+
import { t as S } from "./frameworkInspectState-CX2250XB.js";
|
|
5
|
+
import { basename as C, dirname as w, join as T, relative as E, resolve as D } from "node:path";
|
|
6
|
+
import { fileURLToPath as Oe, pathToFileURL as O } from "node:url";
|
|
7
|
+
import { FetchHttpClient as ke } from "@effect/platform";
|
|
8
|
+
import { Cause as Ae, Cron as je, Duration as Me, Effect as k, Fiber as Ne, JSONSchema as Pe, Layer as A, ManagedRuntime as Fe, Option as j, Ref as Ie, Schema as Le, Stream as Re } from "effect";
|
|
9
|
+
import { createLogger as ze, printAppSurface as Be, printReadyBlock as Ve } from "@voltro/logger";
|
|
10
|
+
import { appendFileSync as He, existsSync as M, promises as N, readFileSync as Ue, writeFileSync as P } from "node:fs";
|
|
11
|
+
import { AggregateError as F, AggregateMaintainer as I, AggregateNotFound as We, AggregateRegistry as Ge, AggregateStale as L, AnalyticsSink as Ke, Dispatcher as qe, InMemoryDataStore as Je, ReactionRateLimiter as Ye, ReplicatedDataStore as Xe, _voltroConnectionGrantsTable as Ze, _voltroConnectionsTable as Qe, _voltroScheduleClaimsTable as $e, _voltroScheduleRunsTable as et, _voltroTracesTable as tt, _voltroUndoLogTable as R, _voltroWakeupsTable as nt, _voltroWorkflowEventDeliveriesTable as rt, _voltroWorkflowEventsTable as it, apiKeyManagementRoutes as at, applySoftDeleteScope as ot, applyTenantScope as st, applyUndoInvocation as ct, assertConnectionCipherConfigured as lt, attachAnalyticsMirror as ut, awaitServerListening as dt, bindMutation as ft, bindStream as pt, bindSubscription as mt, buildTracingLayer as ht, cancelWakeup as gt, compileCron as _t, completeOAuthConnect as vt, dataStoreApiKeyStore as yt, dataStoreIdempotencyStore as bt, drainOutbox as xt, extractDbCause as St, frameworkApiKeyStrategy as Ct, getConnectionSubject as wt, getTimelineRecorder as Tt, installPolicyGuardResolver as Et, isAggregateDefinition as z, isScheduleDefinition as Dt, isWorkflowEventTriggerDefinition as Ot, listRetentions as kt, loadResourceTuples as At, localityAwareSelector as jt, makeActionRunner as Mt, makeAdvisoryLockCoordinator as Nt, makeApiKeyService as Pt, makeAppAccess as Ft, makeAsyncKv as It, makeBufferingSpanProcessor as Lt, makeConnectionRegistry as Rt, makeConnectionResolver as zt, makeConnectionsFacade as Bt, makeCoordinatedScheduler as Vt, makeDataLoader as Ht, makeDisconnectConnectionExecutor as Ut, makeEffectStoreLayer as Wt, makeEventsFacade as Gt, makeLazyWorkflowFacade as Kt, makeListConnectionsExecutor as qt, makeMutationRunner as Jt, makeOutboxFacade as Yt, makePostCommitWorkflowFacade as Xt, makeQueryDescriptorProducer as Zt, makeQueryReauthorizer as Qt, makeSchemaRegistry as $t, makeStartConnectionExecutor as en, makeSubmitTokenExecutor as tn, makeUndoCapture as nn, makeWorkflowFacade as rn, makeWorkflowFacadeWithCallerContext as an, makeWorkflowLayers as on, memoryRywPositionStore as sn, nextFiring as cn, noopAnalytics as ln, noopAnalyticsSpec as un, outboxAttemptsTable as dn, outboxTable as fn, powerOfTwoSelector as pn, recordSubscriptionDelivery as mn, recordTimelineEvent as hn, redisRywPositionStore as gn, redoUndoInvocation as _n, registerRetention as vn, registerWakeup as yn, resolveCurrentRegion as bn, resolveSecretsBackend as xn, retentionTtlMsFromEnv as Sn, runProvidedEffect as Cn, runReaction as wn, sanitizeRedirectTo as Tn, setConnectionResolver as En, setSecretsBackend as Dn, setTupleSource as On, singleCoordinator as kn, snapshotMetricsSync as An, startRpcServer as jn, startScheduler as Mn, sweepRetention as Nn, tracingHttpClientLayer as B, undoCaptureEnabled as Pn, undoLogExecutor as Fn, wrapStoreWithMixinBehaviour as In } from "@voltro/runtime";
|
|
12
12
|
import { isEnvContract as Ln } from "@voltro/env";
|
|
13
13
|
import { createHash as Rn, randomBytes as zn } from "node:crypto";
|
|
14
14
|
import { spawn as Bn } from "node:child_process";
|
|
@@ -38,7 +38,7 @@ import { isEmailTemplate as K, registerEmailTemplates as na } from "@voltro/plug
|
|
|
38
38
|
import { attachBroadcastBus as ra, getBroadcastPlugin as ia } from "@voltro/plugin-broadcast";
|
|
39
39
|
import { runImport as aa } from "@voltro/data-transfer";
|
|
40
40
|
//#region src/browserSafetyGuard.ts
|
|
41
|
-
var oa = /* @__PURE__ */ new Set(/* @__PURE__ */ "crypto.fs.path.os.net.http.https.http2.tls.dns.dgram.stream.zlib.child_process.worker_threads.cluster.readline.vm.module.perf_hooks.async_hooks.inspector.v8.process.tty.repl.constants.sys.string_decoder".split(".")), sa = (e) => e.startsWith("node:") || oa.has(e) || e === "@voltro/workflow"
|
|
41
|
+
var oa = /* @__PURE__ */ new Set(/* @__PURE__ */ "crypto.fs.path.os.net.http.https.http2.tls.dns.dgram.stream.zlib.child_process.worker_threads.cluster.readline.vm.module.perf_hooks.async_hooks.inspector.v8.process.tty.repl.constants.sys.string_decoder".split(".")), sa = (e) => e.startsWith("node:") || oa.has(e) || e === "@voltro/workflow" ? !0 : e === "@voltro/database/wire" ? !1 : e === "@voltro/database" || e.startsWith("@voltro/database/") || e === "@voltro/runtime" || e.startsWith("@voltro/runtime/") ? !0 : e === "@voltro/ai/agent" || e === "@voltro/ai/events" ? !1 : !!(e === "@voltro/ai" || e.startsWith("@voltro/ai/") || [
|
|
42
42
|
"@voltro/protocol/session",
|
|
43
43
|
"@voltro/protocol/jwt",
|
|
44
44
|
"@voltro/protocol/apikey"
|
|
@@ -78,21 +78,21 @@ var oa = /* @__PURE__ */ new Set(/* @__PURE__ */ "crypto.fs.path.os.net.http.htt
|
|
|
78
78
|
let t = ua(e) ? [e] : [
|
|
79
79
|
`${e}.ts`,
|
|
80
80
|
`${e}.tsx`,
|
|
81
|
-
|
|
82
|
-
|
|
81
|
+
T(e, "index.ts"),
|
|
82
|
+
T(e, "index.tsx")
|
|
83
83
|
];
|
|
84
84
|
for (let e of t) try {
|
|
85
|
-
if ((await
|
|
85
|
+
if ((await N.stat(e)).isFile()) return e;
|
|
86
86
|
} catch {}
|
|
87
87
|
return null;
|
|
88
88
|
}, fa = async (e, t) => {
|
|
89
89
|
let n = t;
|
|
90
90
|
for (;;) {
|
|
91
|
-
let t =
|
|
91
|
+
let t = T(n, "node_modules", e);
|
|
92
92
|
try {
|
|
93
|
-
if ((await
|
|
93
|
+
if ((await N.stat(t)).isDirectory()) return t;
|
|
94
94
|
} catch {}
|
|
95
|
-
let r =
|
|
95
|
+
let r = w(n);
|
|
96
96
|
if (r === n) return null;
|
|
97
97
|
n = r;
|
|
98
98
|
}
|
|
@@ -111,12 +111,12 @@ var oa = /* @__PURE__ */ new Set(/* @__PURE__ */ "crypto.fs.path.os.net.http.htt
|
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
113
|
}, ma = async (e, t) => {
|
|
114
|
-
if (e.startsWith(".")) return da(
|
|
115
|
-
let n = e.split("/"), r = e.startsWith("@"), i = r ? `${n[0]}/${n[1]}` : n[0], a = r ? n.slice(2) : n.slice(1), o = a.length > 0 ? `./${a.join("/")}` : ".", s = await fa(i,
|
|
114
|
+
if (e.startsWith(".")) return da(D(w(t), e));
|
|
115
|
+
let n = e.split("/"), r = e.startsWith("@"), i = r ? `${n[0]}/${n[1]}` : n[0], a = r ? n.slice(2) : n.slice(1), o = a.length > 0 ? `./${a.join("/")}` : ".", s = await fa(i, w(t));
|
|
116
116
|
if (!s) return null;
|
|
117
117
|
try {
|
|
118
|
-
let e = JSON.parse(await
|
|
119
|
-
if (typeof t == "string") return da(
|
|
118
|
+
let e = JSON.parse(await N.readFile(T(s, "package.json"), "utf8")), t = pa(e.exports?.[o]) ?? (o === "." ? e.module ?? e.main : void 0);
|
|
119
|
+
if (typeof t == "string") return da(D(s, t));
|
|
120
120
|
} catch {}
|
|
121
121
|
return null;
|
|
122
122
|
}, ha = (e, t) => e.startsWith(t) ? e.slice(t.length).replace(/^[/\\]/, "") : e, ga = async (e, t) => {
|
|
@@ -130,7 +130,7 @@ var oa = /* @__PURE__ */ new Set(/* @__PURE__ */ "crypto.fs.path.os.net.http.htt
|
|
|
130
130
|
n.add(e);
|
|
131
131
|
let a;
|
|
132
132
|
try {
|
|
133
|
-
a = await
|
|
133
|
+
a = await N.readFile(e, "utf8");
|
|
134
134
|
} catch {
|
|
135
135
|
continue;
|
|
136
136
|
}
|
|
@@ -149,7 +149,7 @@ var oa = /* @__PURE__ */ new Set(/* @__PURE__ */ "crypto.fs.path.os.net.http.htt
|
|
|
149
149
|
return null;
|
|
150
150
|
}, _a = async (e) => {
|
|
151
151
|
if (process.env.VOLTRO_BROWSER_SAFETY === "off") return;
|
|
152
|
-
let t = await ga(e,
|
|
152
|
+
let t = await ga(e, w(e));
|
|
153
153
|
if (!t) return;
|
|
154
154
|
let n = t.chain.join("\n → ");
|
|
155
155
|
throw Error(`browser-safety violation — the generated rpcGroup pulls a SERVER-ONLY module into the client bundle.\n\n '${t.specifier}' is server-only (node:* / database / ai / cluster / protocol session / db driver),\n and the web client loads rpcGroup VALUE-LEVEL — this crashes the browser with\n "Module …node:crypto… has been externalized for browser compatibility", or bloats the\n bundle with the whole server graph.\n\n import chain:\n → ${n}\n\n Fix: keep the descriptor (*.query/.mutation/.action.ts), the workflow descriptor\n (*.workflow.tsx, import from @voltro/workflow/define), AND any plugin error schema\n browser-safe. Move DB-backed / node: code behind a *.server.ts file or a browser-safe\n subpath (e.g. a plugin's '/errors' export). Escape hatch (not recommended):\n VOLTRO_BROWSER_SAFETY=off.`);
|
|
@@ -163,10 +163,10 @@ var oa = /* @__PURE__ */ new Set(/* @__PURE__ */ "crypto.fs.path.os.net.http.htt
|
|
|
163
163
|
".git"
|
|
164
164
|
]), Ca = async (e) => {
|
|
165
165
|
let t = async (e) => {
|
|
166
|
-
let n = await
|
|
166
|
+
let n = await N.readdir(e, { withFileTypes: !0 }).catch(() => []);
|
|
167
167
|
for (let r of n) if (!Sa.has(r.name)) {
|
|
168
168
|
if (r.isDirectory()) {
|
|
169
|
-
if (await t(
|
|
169
|
+
if (await t(T(e, r.name))) return !0;
|
|
170
170
|
} else if (r.isFile() && xa.test(r.name)) return !0;
|
|
171
171
|
}
|
|
172
172
|
return !1;
|
|
@@ -174,10 +174,10 @@ var oa = /* @__PURE__ */ new Set(/* @__PURE__ */ "crypto.fs.path.os.net.http.htt
|
|
|
174
174
|
return t(e);
|
|
175
175
|
}, J = async (e) => {
|
|
176
176
|
let t = [], n = async (e) => {
|
|
177
|
-
let r = await
|
|
177
|
+
let r = await N.readdir(e, { withFileTypes: !0 });
|
|
178
178
|
for (let i of r) {
|
|
179
179
|
if (Sa.has(i.name)) continue;
|
|
180
|
-
let r =
|
|
180
|
+
let r = T(e, i.name);
|
|
181
181
|
i.isDirectory() ? await n(r) : i.isFile() && (va.test(i.name) && !ya.test(i.name) || ba.test(i.name) || q.test(i.name)) && t.push(r);
|
|
182
182
|
}
|
|
183
183
|
};
|
|
@@ -185,7 +185,7 @@ var oa = /* @__PURE__ */ new Set(/* @__PURE__ */ "crypto.fs.path.os.net.http.htt
|
|
|
185
185
|
}, wa = (e) => typeof e == "object" && !!e && "kind" in e && "name" in e && (e.kind === "query" || e.kind === "mutation" || e.kind === "action" || e.kind === "stream"), Ta = Symbol.for("@effect/workflow/Workflow"), Ea = (e) => typeof e == "object" && !!e && Ta in e && "name" in e && typeof e.name == "string", Da = async (e) => {
|
|
186
186
|
let t = [];
|
|
187
187
|
for (let n of e) {
|
|
188
|
-
let e = await import(
|
|
188
|
+
let e = await import(O(n).href);
|
|
189
189
|
for (let [r, i] of Object.entries(e)) wa(i) ? t.push({
|
|
190
190
|
file: n,
|
|
191
191
|
exportName: r,
|
|
@@ -203,7 +203,7 @@ var oa = /* @__PURE__ */ new Set(/* @__PURE__ */ "crypto.fs.path.os.net.http.htt
|
|
|
203
203
|
let t = [];
|
|
204
204
|
for (let n of e) {
|
|
205
205
|
if (!q.test(n)) continue;
|
|
206
|
-
let e = await import(
|
|
206
|
+
let e = await import(O(n).href);
|
|
207
207
|
for (let [r, i] of Object.entries(e)) nr(i) && t.push({
|
|
208
208
|
file: n,
|
|
209
209
|
exportName: r,
|
|
@@ -215,7 +215,7 @@ var oa = /* @__PURE__ */ new Set(/* @__PURE__ */ "crypto.fs.path.os.net.http.htt
|
|
|
215
215
|
let t = (e, t) => e.split(/[^a-zA-Z0-9]+/).filter(Boolean).map((e, n) => (n === 0 && !t ? e.charAt(0).toLowerCase() : e.charAt(0).toUpperCase()) + e.slice(1)).join(""), n = e.split(".");
|
|
216
216
|
return `${t(n[0] ?? "rpc", !1)}${n.slice(1).map((e) => t(e, !0)).join("")}Rpc`;
|
|
217
217
|
}, ka = /^[A-Za-z][A-Za-z0-9]*([._-][A-Za-z0-9]+)*$/, Aa = (e, t) => {
|
|
218
|
-
let n = (e) =>
|
|
218
|
+
let n = (e) => E(t, e.file).replace(/\\/g, "/"), r = e.filter((e) => !ka.test(e.rpcTag));
|
|
219
219
|
if (r.length > 0) throw Error(`invalid rpc tag — a procedure/workflow \`name\` must start with a letter and
|
|
220
220
|
use only letters, digits, and \`.\` \`-\` \`_\` separators (the tag becomes a JS
|
|
221
221
|
identifier in the generated rpcGroup):
|
|
@@ -243,7 +243,7 @@ ${a.map((e) => ` ${Y(e[0].rpcTag)}:\n` + e.map((e) => ` - "${e.rpcTag}" (${
|
|
|
243
243
|
}, Ma = (e, t) => {
|
|
244
244
|
let n = /* @__PURE__ */ new Map();
|
|
245
245
|
for (let t of e) n.has(t.rpcTag) || n.set(t.rpcTag, t);
|
|
246
|
-
let r = [...n.keys()], i = (e) =>
|
|
246
|
+
let r = [...n.keys()], i = (e) => E(t, n.get(e).file).replace(/\\/g, "/"), a = [];
|
|
247
247
|
for (let e of r) {
|
|
248
248
|
let t = r.filter((t) => t.startsWith(`${e}.`)).sort();
|
|
249
249
|
if (t.length === 0) continue;
|
|
@@ -281,8 +281,8 @@ ${a.join("\n\n")}\n`);
|
|
|
281
281
|
...l,
|
|
282
282
|
...d
|
|
283
283
|
], e);
|
|
284
|
-
let f = (e) => e.replace(/[^a-zA-Z0-9_$]/g, "_"), p = (e) => `__src_agent_${f(e.name)}`, m = (e) => `__agentRoutes_${f(e.name)}`, h = r.length > 0, g = r.map((e, t) => `import { ${e.name} as __pe${t} } from '${e.module}'`), _ = h ? ", __voltroPluginErrors" : "", ee = u.length > 0, te = u.map((e, t) => `import { ${e.name} as __prpc${t} } from '${e.module}'`), ne = (e) => e === "query" ? "queryToRpc" : e === "mutation" ? "mutationToRpc" : "actionToRpc", re = u.map((e, t) => `export const ${Y(e.tag)} = ${ne(e.kind)}(__prpc${t}${_})`), ie = u.map((e) => ` ${Y(e.tag)},`), ae = u.map((e, t) => ` ${JSON.stringify(e.tag)}: normalizeDescriptor(__prpc${t}),`), v = [...n].sort((e, t) => e.kind === t.kind ? e.rpcTag < t.rpcTag ? -1 : 1 : ja(e.kind) - ja(t.kind)), oe =
|
|
285
|
-
let t = `./${
|
|
284
|
+
let f = (e) => e.replace(/[^a-zA-Z0-9_$]/g, "_"), p = (e) => `__src_agent_${f(e.name)}`, m = (e) => `__agentRoutes_${f(e.name)}`, h = r.length > 0, g = r.map((e, t) => `import { ${e.name} as __pe${t} } from '${e.module}'`), _ = h ? ", __voltroPluginErrors" : "", ee = u.length > 0, te = u.map((e, t) => `import { ${e.name} as __prpc${t} } from '${e.module}'`), ne = (e) => e === "query" ? "queryToRpc" : e === "mutation" ? "mutationToRpc" : "actionToRpc", re = u.map((e, t) => `export const ${Y(e.tag)} = ${ne(e.kind)}(__prpc${t}${_})`), ie = u.map((e) => ` ${Y(e.tag)},`), ae = u.map((e, t) => ` ${JSON.stringify(e.tag)}: normalizeDescriptor(__prpc${t}),`), v = [...n].sort((e, t) => e.kind === t.kind ? e.rpcTag < t.rpcTag ? -1 : 1 : ja(e.kind) - ja(t.kind)), oe = w(t), se = (e) => `__src_${Y(e.rpcTag)}`, ce = (e) => {
|
|
285
|
+
let t = `./${E(oe, e.file).replace(/\\/g, "/").replace(/\.tsx?$/, "")}`;
|
|
286
286
|
return `import { ${e.exportName} as ${se(e)} } from '${t}'`;
|
|
287
287
|
}, le = (e) => {
|
|
288
288
|
let t = Y(e.rpcTag), n = se(e);
|
|
@@ -293,7 +293,7 @@ ${a.join("\n\n")}\n`);
|
|
|
293
293
|
` error: ${n}.errorSchema,`,
|
|
294
294
|
"})"
|
|
295
295
|
].join("\n");
|
|
296
|
-
}, ue = [...v.filter((e) => e.kind === "query" || e.kind === "mutation" || e.kind === "action" || e.kind === "stream").map((e) => ` | __AppErrorOf<typeof ${se(e)}>`), ...h ? [" | Schema.Schema.Type<(typeof __voltroPluginErrors)[number]>"] : []], de = ue.length > 0,
|
|
296
|
+
}, ue = [...v.filter((e) => e.kind === "query" || e.kind === "mutation" || e.kind === "action" || e.kind === "stream").map((e) => ` | __AppErrorOf<typeof ${se(e)}>`), ...h ? [" | Schema.Schema.Type<(typeof __voltroPluginErrors)[number]>"] : []], de = ue.length > 0, y = v.some((e) => e.kind === "workflow"), fe = y ? [
|
|
297
297
|
"__voltroWorkflowRun",
|
|
298
298
|
"__voltroWorkflowRuns",
|
|
299
299
|
"__voltroWorkflowRunSteps",
|
|
@@ -304,25 +304,25 @@ ${a.join("\n\n")}\n`);
|
|
|
304
304
|
"__voltroWorkflowResume",
|
|
305
305
|
"__voltroWorkflowSignal",
|
|
306
306
|
"__voltroWorkflowUpdate"
|
|
307
|
-
] : [],
|
|
307
|
+
] : [], b = a ? [
|
|
308
308
|
"__voltroUndoLog",
|
|
309
309
|
"__voltroUndoApply",
|
|
310
310
|
"__voltroUndoRedo"
|
|
311
|
-
] : [],
|
|
311
|
+
] : [], pe = o ? [
|
|
312
312
|
"__voltroConnectionsList",
|
|
313
313
|
"__voltroConnectionStart",
|
|
314
314
|
"__voltroConnectionSubmitToken",
|
|
315
315
|
"__voltroConnectionDisconnect"
|
|
316
|
-
] : [],
|
|
316
|
+
] : [], me = [
|
|
317
317
|
...v.map((e) => ` ${Y(e.rpcTag)},`),
|
|
318
318
|
...i.flatMap((e) => [` ${Y(`${e.name}.send`)},`, ` ${Y(`${e.name}.messages`)},`]),
|
|
319
|
+
...fe.map((e) => ` ${e},`),
|
|
320
|
+
...b.map((e) => ` ${e},`),
|
|
319
321
|
...pe.map((e) => ` ${e},`),
|
|
320
|
-
...me.map((e) => ` ${e},`),
|
|
321
|
-
...he.map((e) => ` ${e},`),
|
|
322
322
|
...ie
|
|
323
|
-
].join("\n"),
|
|
324
|
-
(v.some((e) => e.kind === "mutation") || u.some((e) => e.kind === "mutation")) &&
|
|
325
|
-
let
|
|
323
|
+
].join("\n"), he = ["queryToRpc"];
|
|
324
|
+
(v.some((e) => e.kind === "mutation") || u.some((e) => e.kind === "mutation")) && he.push("mutationToRpc"), (v.some((e) => e.kind === "action") || y || c || u.some((e) => e.kind === "action")) && he.push("actionToRpc"), v.some((e) => e.kind === "stream") && he.push("streamToRpc"), y && he.push("WorkflowRunHandleSchema", "workflowCancelDescriptor", "workflowDomainEventsQueryDescriptor", "workflowEventDeliveriesQueryDescriptor", "workflowResumeDescriptor", "workflowRunEventsQueryDescriptor", "workflowRunQueryDescriptor", "workflowRunsQueryDescriptor", "workflowRunStepsQueryDescriptor", "workflowSignalDescriptor", "workflowUpdateDescriptor"), a && he.push("mutationToRpc", "undoLogQueryDescriptor", "undoApplyDescriptor", "undoRedoDescriptor"), o && he.push("mutationToRpc", "actionToRpc", "connectionsListQueryDescriptor", "connectionStartDescriptor", "connectionSubmitTokenDescriptor", "connectionDisconnectDescriptor"), (v.some((e) => e.kind === "query" || e.kind === "mutation" || e.kind === "action" || e.kind === "stream") || c || y || a || o || ee) && he.push("normalizeDescriptor");
|
|
325
|
+
let ge = [...new Set(he)].sort(), _e = v.filter((e) => e.kind === "query" || e.kind === "mutation" || e.kind === "action" || e.kind === "stream").map((e) => ` ${JSON.stringify(e.rpcTag)}: normalizeDescriptor(${se(e)}),`), ve = i.flatMap((e) => [` ${JSON.stringify(`${e.name}.send`)}: normalizeDescriptor(${m(e)}.send),`, ` ${JSON.stringify(`${e.name}.messages`)}: normalizeDescriptor(${m(e)}.messages),`]), ye = y ? [
|
|
326
326
|
" \"__voltro.workflow.run\": normalizeDescriptor(workflowRunQueryDescriptor),",
|
|
327
327
|
" \"__voltro.workflow.runs\": normalizeDescriptor(workflowRunsQueryDescriptor),",
|
|
328
328
|
" \"__voltro.workflow.run.steps\": normalizeDescriptor(workflowRunStepsQueryDescriptor),",
|
|
@@ -333,16 +333,16 @@ ${a.join("\n\n")}\n`);
|
|
|
333
333
|
" \"__voltro.workflow.resume\": normalizeDescriptor(workflowResumeDescriptor),",
|
|
334
334
|
" \"__voltro.workflow.signal\": normalizeDescriptor(workflowSignalDescriptor),",
|
|
335
335
|
" \"__voltro.workflow.update\": normalizeDescriptor(workflowUpdateDescriptor),"
|
|
336
|
-
] : [],
|
|
336
|
+
] : [], be = a ? [
|
|
337
337
|
" \"__voltro.undo.log\": normalizeDescriptor(undoLogQueryDescriptor),",
|
|
338
338
|
" \"__voltro.undo.apply\": normalizeDescriptor(undoApplyDescriptor),",
|
|
339
339
|
" \"__voltro.undo.redo\": normalizeDescriptor(undoRedoDescriptor),"
|
|
340
|
-
] : [],
|
|
340
|
+
] : [], xe = o ? [
|
|
341
341
|
" \"__voltro.connections.list\": normalizeDescriptor(connectionsListQueryDescriptor),",
|
|
342
342
|
" \"__voltro.connections.start\": normalizeDescriptor(connectionStartDescriptor),",
|
|
343
343
|
" \"__voltro.connections.submitToken\": normalizeDescriptor(connectionSubmitTokenDescriptor),",
|
|
344
344
|
" \"__voltro.connections.disconnect\": normalizeDescriptor(connectionDisconnectDescriptor),"
|
|
345
|
-
] : [],
|
|
345
|
+
] : [], Se = v.filter((e) => e.kind === "workflow").map((e) => ` ${JSON.stringify(e.rpcTag)}: { kind: 'workflow' },`), Ce = v.filter((e) => e.kind === "workflow").map((e) => {
|
|
346
346
|
let t = se(e);
|
|
347
347
|
return [
|
|
348
348
|
` ${JSON.stringify(e.rpcTag)}: {`,
|
|
@@ -355,31 +355,31 @@ ${a.join("\n\n")}\n`);
|
|
|
355
355
|
` queries: __voltroWorkflowMessages(${t}).queries,`,
|
|
356
356
|
" },"
|
|
357
357
|
].join("\n");
|
|
358
|
-
}),
|
|
358
|
+
}), we = [...v, ...i.map((e) => ({
|
|
359
359
|
rpcTag: `agent:${e.name}`,
|
|
360
360
|
file: e.file
|
|
361
361
|
}))];
|
|
362
362
|
return [
|
|
363
363
|
"// THIS FILE IS GENERATED — DO NOT EDIT BY HAND.",
|
|
364
364
|
"// Re-emitted by `voltro dev` whenever query/mutation/action/stream/workflow files change.",
|
|
365
|
-
`// descriptor-fingerprint: ${Rn("sha1").update(
|
|
365
|
+
`// descriptor-fingerprint: ${Rn("sha1").update(we.map((e) => {
|
|
366
366
|
let t = "";
|
|
367
367
|
try {
|
|
368
|
-
t =
|
|
368
|
+
t = Ue(e.file, "utf8");
|
|
369
369
|
} catch {}
|
|
370
370
|
return `${e.rpcTag}${t}`;
|
|
371
371
|
}).join("")).digest("hex").slice(0, 16)}`,
|
|
372
372
|
"// Source files:",
|
|
373
|
-
...v.map((t) => `// - ${
|
|
374
|
-
...i.map((t) => `// - ${
|
|
373
|
+
...v.map((t) => `// - ${E(e, t.file).replace(/\\/g, "/")}`),
|
|
374
|
+
...i.map((t) => `// - ${E(e, t.file).replace(/\\/g, "/")} (agent)`),
|
|
375
375
|
"",
|
|
376
|
-
|
|
377
|
-
...
|
|
378
|
-
`import { ${
|
|
376
|
+
y ? "import { Rpc, RpcGroup } from '@effect/rpc'" : "import { RpcGroup } from '@effect/rpc'",
|
|
377
|
+
...y || de ? ["import { Schema } from 'effect'"] : [],
|
|
378
|
+
`import { ${ge.join(", ")} } from '@voltro/protocol'`,
|
|
379
379
|
...c ? ["import { agentRouteDescriptors as __voltroAgentRoutes } from '@voltro/ai/agent'"] : [],
|
|
380
380
|
"",
|
|
381
381
|
...v.map(ce),
|
|
382
|
-
...i.map((e) => `import { ${e.exportName} as ${p(e)} } from './${
|
|
382
|
+
...i.map((e) => `import { ${e.exportName} as ${p(e)} } from './${E(oe, e.file).replace(/\\/g, "/").replace(/\.tsx?$/, "")}'`),
|
|
383
383
|
...h ? ["", ...g] : [],
|
|
384
384
|
...ee ? ["", ...te] : [],
|
|
385
385
|
"",
|
|
@@ -391,7 +391,7 @@ ${a.join("\n\n")}\n`);
|
|
|
391
391
|
`const __voltroPluginErrors = [${r.map((e, t) => `__pe${t}`).join(", ")}] as const`,
|
|
392
392
|
""
|
|
393
393
|
] : [],
|
|
394
|
-
...
|
|
394
|
+
...y ? [
|
|
395
395
|
"const __voltroEmptyWorkflowMessages = { signals: {}, updates: {}, queries: {} } as const",
|
|
396
396
|
"const __voltroWorkflowMessages = <const M extends {",
|
|
397
397
|
" readonly signals: Readonly<Record<string, Schema.Schema.Any>>",
|
|
@@ -401,7 +401,7 @@ ${a.join("\n\n")}\n`);
|
|
|
401
401
|
" definition.__voltroWorkflowMessages ?? __voltroEmptyWorkflowMessages",
|
|
402
402
|
"",
|
|
403
403
|
"export const workflowDescriptors = {",
|
|
404
|
-
...
|
|
404
|
+
...Ce,
|
|
405
405
|
"} as const",
|
|
406
406
|
"",
|
|
407
407
|
"export type WorkflowDescriptors = typeof workflowDescriptors",
|
|
@@ -427,7 +427,7 @@ ${a.join("\n\n")}\n`);
|
|
|
427
427
|
] : [],
|
|
428
428
|
...v.map(le),
|
|
429
429
|
...i.flatMap((e) => [`export const ${Y(`${e.name}.send`)} = actionToRpc(${m(e)}.send${_})`, `export const ${Y(`${e.name}.messages`)} = queryToRpc(${m(e)}.messages${_})`]),
|
|
430
|
-
...
|
|
430
|
+
...y ? [
|
|
431
431
|
"export const __voltroWorkflowRun = queryToRpc(workflowRunQueryDescriptor)",
|
|
432
432
|
"export const __voltroWorkflowRuns = queryToRpc(workflowRunsQueryDescriptor)",
|
|
433
433
|
"export const __voltroWorkflowRunSteps = queryToRpc(workflowRunStepsQueryDescriptor)",
|
|
@@ -453,19 +453,19 @@ ${a.join("\n\n")}\n`);
|
|
|
453
453
|
...re,
|
|
454
454
|
"",
|
|
455
455
|
"export const appGroup = RpcGroup.make(",
|
|
456
|
-
|
|
456
|
+
me,
|
|
457
457
|
")",
|
|
458
458
|
"",
|
|
459
459
|
"/** Per-rpc-tag metadata for the client. Drives auto-optimistic etc.",
|
|
460
460
|
" * Function fields (target.shape, target.identify) survive because",
|
|
461
461
|
" * the descriptors themselves are imported by reference. */",
|
|
462
462
|
"export const appDescriptors = {",
|
|
463
|
+
..._e,
|
|
463
464
|
...ve,
|
|
465
|
+
...Se,
|
|
464
466
|
...ye,
|
|
465
|
-
...Ce,
|
|
466
467
|
...be,
|
|
467
468
|
...xe,
|
|
468
|
-
...Se,
|
|
469
469
|
...ae,
|
|
470
470
|
"} as const",
|
|
471
471
|
"",
|
|
@@ -502,7 +502,7 @@ ${a.join("\n\n")}\n`);
|
|
|
502
502
|
] : []
|
|
503
503
|
].join("\n");
|
|
504
504
|
}, Pa = async (e) => {
|
|
505
|
-
let t =
|
|
505
|
+
let t = D(e.root), n = await J(t), r = await Da(n), i = await Oa(n), a = await Ca(t);
|
|
506
506
|
if (r.length === 0 && i.length === 0 && !a && (e.pluginRpcImports?.length ?? 0) === 0) return;
|
|
507
507
|
let o = ((e) => {
|
|
508
508
|
if (e.length === 0) return t;
|
|
@@ -521,7 +521,7 @@ ${a.join("\n\n")}\n`);
|
|
|
521
521
|
"workflows"
|
|
522
522
|
]), c = (e) => e.slice(e.lastIndexOf("/") + 1), l = o;
|
|
523
523
|
for (; l !== t && s.has(c(l));) l = l.slice(0, l.lastIndexOf("/")) || "/";
|
|
524
|
-
let u =
|
|
524
|
+
let u = D(e.outputFile ?? T(l, "rpcGroup.generated.ts")), d = [...new Map((e.pluginErrorImports ?? []).map((e) => [`${e.module}#${e.name}`, e])).values()], f = [...new Map((e.pluginRpcImports ?? []).map((e) => [e.tag, e])).values()], p = Na(t, u, r, d, i, Pn(), a, f), m = [];
|
|
525
525
|
for (let t of e.pluginContributions ?? []) {
|
|
526
526
|
let e = null;
|
|
527
527
|
try {
|
|
@@ -538,9 +538,9 @@ ${a.join("\n\n")}\n`);
|
|
|
538
538
|
}
|
|
539
539
|
let h = m.length === 0 ? p : `${p}\n\n// ---- plugin codegen ----\n\n${m.join("\n")}`, g = null;
|
|
540
540
|
try {
|
|
541
|
-
g = await
|
|
541
|
+
g = await N.readFile(u, "utf8");
|
|
542
542
|
} catch {}
|
|
543
|
-
return g !== h && await
|
|
543
|
+
return g !== h && await N.writeFile(u, h, "utf8"), await _a(u), u;
|
|
544
544
|
}, Fa = {
|
|
545
545
|
postgres: "@voltro/sql-postgres",
|
|
546
546
|
sqlite: "@voltro/sql-sqlite",
|
|
@@ -561,7 +561,7 @@ ${a.join("\n\n")}\n`);
|
|
|
561
561
|
let t = Ra.get(e);
|
|
562
562
|
if (t) return t;
|
|
563
563
|
try {
|
|
564
|
-
return await import(
|
|
564
|
+
return await import(O(Wn(T(process.cwd(), "package.json")).resolve(e)).href);
|
|
565
565
|
} catch {
|
|
566
566
|
try {
|
|
567
567
|
return await import(e);
|
|
@@ -713,7 +713,7 @@ ${a.join("\n\n")}\n`);
|
|
|
713
713
|
...n.error === void 0 ? {} : { error: n.error }
|
|
714
714
|
});
|
|
715
715
|
}
|
|
716
|
-
}, qa = (e) => (t, n) =>
|
|
716
|
+
}, qa = (e) => (t, n) => k.suspend(() => {
|
|
717
717
|
let r = { request: {
|
|
718
718
|
subject: n.request.subject,
|
|
719
719
|
traceId: n.request.traceId
|
|
@@ -746,7 +746,7 @@ ${a.join("\n\n")}\n`);
|
|
|
746
746
|
if (r !== void 0) throw Error(`plugin route tag collision: "${e}" declared by plugin "${t.plugin.name}" but already claimed by ${r === "user-route" ? "a user-authored route" : `plugin "${r}"`}`);
|
|
747
747
|
n.set(e, t.plugin.name);
|
|
748
748
|
}
|
|
749
|
-
}, Xa = "_voltro_plugin_migrations", Za = () =>
|
|
749
|
+
}, Xa = "_voltro_plugin_migrations", Za = () => k.gen(function* () {
|
|
750
750
|
yield* (yield* V.SqlClient).unsafe(`
|
|
751
751
|
CREATE TABLE IF NOT EXISTS ${Xa} (
|
|
752
752
|
id TEXT PRIMARY KEY,
|
|
@@ -755,17 +755,17 @@ ${a.join("\n\n")}\n`);
|
|
|
755
755
|
description TEXT,
|
|
756
756
|
applied_at TEXT NOT NULL
|
|
757
757
|
);
|
|
758
|
-
`).pipe(
|
|
759
|
-
}), Qa = (e, t) => `${Wa(e)}__${t}`, $a = () =>
|
|
760
|
-
let e = yield* V.SqlClient, t = yield* e`SELECT id FROM ${e(Xa)}`.pipe(
|
|
758
|
+
`).pipe(k.orDie);
|
|
759
|
+
}), Qa = (e, t) => `${Wa(e)}__${t}`, $a = () => k.gen(function* () {
|
|
760
|
+
let e = yield* V.SqlClient, t = yield* e`SELECT id FROM ${e(Xa)}`.pipe(k.orDie);
|
|
761
761
|
return new Set(t.map((e) => e.id));
|
|
762
|
-
}), eo = (e) =>
|
|
762
|
+
}), eo = (e) => k.gen(function* () {
|
|
763
763
|
let t = yield* V.SqlClient, n = (/* @__PURE__ */ new Date()).toISOString();
|
|
764
764
|
yield* t`
|
|
765
765
|
INSERT INTO ${t(Xa)} (id, plugin_name, migration_id, description, applied_at)
|
|
766
766
|
VALUES (${e.key}, ${e.pluginName}, ${e.migration.id}, ${e.migration.description ?? null}, ${n})
|
|
767
|
-
`.pipe(
|
|
768
|
-
}), to = (e) =>
|
|
767
|
+
`.pipe(k.orDie);
|
|
768
|
+
}), to = (e) => k.gen(function* () {
|
|
769
769
|
let t = e.flatMap((e) => (e.extendSchema?.migrations ?? []).map((t) => ({
|
|
770
770
|
plugin: e,
|
|
771
771
|
migration: t
|
|
@@ -786,7 +786,7 @@ ${a.join("\n\n")}\n`);
|
|
|
786
786
|
}
|
|
787
787
|
let o = yield* V.SqlClient;
|
|
788
788
|
try {
|
|
789
|
-
yield* i.up(o).pipe(
|
|
789
|
+
yield* i.up(o).pipe(k.mapError((e) => e)), yield* eo({
|
|
790
790
|
key: t,
|
|
791
791
|
pluginName: e.name,
|
|
792
792
|
migration: i
|
|
@@ -803,7 +803,7 @@ ${a.join("\n\n")}\n`);
|
|
|
803
803
|
status: "failed",
|
|
804
804
|
durationMs: Date.now() - a,
|
|
805
805
|
error: t
|
|
806
|
-
}), yield*
|
|
806
|
+
}), yield* k.fail(/* @__PURE__ */ Error(`Plugin migration failed: ${e.name} ${i.id} — ${t instanceof Error ? t.message : String(t)}`));
|
|
807
807
|
}
|
|
808
808
|
}
|
|
809
809
|
return r;
|
|
@@ -815,7 +815,7 @@ ${a.join("\n\n")}\n`);
|
|
|
815
815
|
})), ro = (e) => e.flatMap((e) => e.extendSchema?.tables ?? []), io = /(?<!\.server)\.agent\.tsx?$/, Z = /\.agent\.server\.tsx?$/, ao = /\.tool\.tsx?$/, oo = async (e, t) => {
|
|
816
816
|
let n = 0;
|
|
817
817
|
for (let r of e) if (ao.test(r)) try {
|
|
818
|
-
let e = await
|
|
818
|
+
let e = await x(r);
|
|
819
819
|
n += Qn(e);
|
|
820
820
|
} catch (e) {
|
|
821
821
|
t.warn("tool: failed to import — handler not wired", { file: r }, e);
|
|
@@ -827,7 +827,7 @@ ${a.join("\n\n")}\n`);
|
|
|
827
827
|
if (!io.test(i)) continue;
|
|
828
828
|
let e;
|
|
829
829
|
try {
|
|
830
|
-
e = await
|
|
830
|
+
e = await x(i);
|
|
831
831
|
} catch (e) {
|
|
832
832
|
t.warn("agent: failed to import descriptor", { file: i }, e);
|
|
833
833
|
continue;
|
|
@@ -846,7 +846,7 @@ ${a.join("\n\n")}\n`);
|
|
|
846
846
|
}
|
|
847
847
|
let o = so(i), s;
|
|
848
848
|
try {
|
|
849
|
-
s = await
|
|
849
|
+
s = await x(o);
|
|
850
850
|
} catch (e) {
|
|
851
851
|
t.warn("agent: no executor — expected a `*.agent.server.tsx` default-exporting defineAgentExecutor()", {
|
|
852
852
|
descriptor: i,
|
|
@@ -876,7 +876,7 @@ ${a.join("\n\n")}\n`);
|
|
|
876
876
|
for (let i of e) {
|
|
877
877
|
let e;
|
|
878
878
|
try {
|
|
879
|
-
e = await
|
|
879
|
+
e = await x(i);
|
|
880
880
|
} catch (e) {
|
|
881
881
|
t.warn("connections: failed to import", { file: i }, e);
|
|
882
882
|
continue;
|
|
@@ -914,7 +914,7 @@ ${a.join("\n\n")}\n`);
|
|
|
914
914
|
}
|
|
915
915
|
return n.length > 0 && t.info("discovered connections", {
|
|
916
916
|
connections: n.map((e) => `${e.definition.id} (${e.definition.kind})`),
|
|
917
|
-
files: n.map((e) => uo(
|
|
917
|
+
files: n.map((e) => uo(C(e.file)))
|
|
918
918
|
}), n;
|
|
919
919
|
}, po = (e) => typeof e.attributes["framework.kind"] == "string" && e.attributes["framework.kind"].startsWith("subscription."), mo = (e) => {
|
|
920
920
|
if (e.name.includes("_voltro_traces")) return !0;
|
|
@@ -1107,10 +1107,10 @@ ${a.join("\n\n")}\n`);
|
|
|
1107
1107
|
};
|
|
1108
1108
|
}, Mo = /\.outbox\.tsx?$/, No = /\.workflow\.tsx?$/, Po = /\.trigger\.tsx?$/, Fo = /\.cron\.tsx?$/, Io = /\.webhook\.tsx?$/, Lo = async (e) => {
|
|
1109
1109
|
let t = !1, n = !1, r = !1, i = !1, a = !1, o = !1, s = async (e) => {
|
|
1110
|
-
let c = await
|
|
1110
|
+
let c = await N.readdir(e, { withFileTypes: !0 }).catch(() => []);
|
|
1111
1111
|
for (let l of c) if (l.isDirectory()) {
|
|
1112
1112
|
if (l.name === "node_modules" || l.name === "dist" || l.name === ".framework" || l.name.startsWith(".")) continue;
|
|
1113
|
-
await s(
|
|
1113
|
+
await s(T(e, l.name));
|
|
1114
1114
|
} else {
|
|
1115
1115
|
let e = l.name;
|
|
1116
1116
|
(No.test(e) || Po.test(e)) && (t = !0), Fo.test(e) && (n = !0), Io.test(e) && (r = !0), io.test(e) && (i = !0), Mo.test(e) && (a = !0), lo.test(e) && (o = !0);
|
|
@@ -1126,7 +1126,7 @@ ${a.join("\n\n")}\n`);
|
|
|
1126
1126
|
};
|
|
1127
1127
|
}, Ro = async (e) => {
|
|
1128
1128
|
try {
|
|
1129
|
-
return (await import(
|
|
1129
|
+
return (await import(O(T(e, "app.config.ts")).href)).default?.plugins ?? [];
|
|
1130
1130
|
} catch {
|
|
1131
1131
|
return [];
|
|
1132
1132
|
}
|
|
@@ -1157,15 +1157,15 @@ ${a.join("\n\n")}\n`);
|
|
|
1157
1157
|
...i ? { cdcDialect: i } : {}
|
|
1158
1158
|
});
|
|
1159
1159
|
}, Vo = ".env.local", Ho = (e) => {
|
|
1160
|
-
let t =
|
|
1160
|
+
let t = T(e, ".gitignore"), n = "";
|
|
1161
1161
|
try {
|
|
1162
|
-
|
|
1162
|
+
M(t) && (n = Ue(t, "utf8"));
|
|
1163
1163
|
} catch {
|
|
1164
1164
|
return !1;
|
|
1165
1165
|
}
|
|
1166
1166
|
if (n.split(/\r?\n/).map((e) => e.trim()).some((e) => e === Vo || e === `/${Vo}` || e === ".env*" || e === ".env.*" || e === ".env.local*")) return !0;
|
|
1167
1167
|
try {
|
|
1168
|
-
return
|
|
1168
|
+
return He(t, `${n === "" || n.endsWith("\n") ? "" : "\n"}\n# Local secrets minted by \`voltro dev\` — machine-specific, never commit.\n${Vo}\n`, "utf8"), !0;
|
|
1169
1169
|
} catch {
|
|
1170
1170
|
return !1;
|
|
1171
1171
|
}
|
|
@@ -1182,13 +1182,13 @@ ${a.join("\n\n")}\n`);
|
|
|
1182
1182
|
});
|
|
1183
1183
|
}
|
|
1184
1184
|
if (r.length === 0) return { minted: [] };
|
|
1185
|
-
if (!Ho(t)) throw Error(`cannot mint ${r.map((e) => e.key).join(", ")}: failed to add "${Vo}" to ${
|
|
1186
|
-
let i =
|
|
1185
|
+
if (!Ho(t)) throw Error(`cannot mint ${r.map((e) => e.key).join(", ")}: failed to add "${Vo}" to ${T(t, ".gitignore")}. Refusing to write a secret to a path that might be committed — add the entry by hand, or set the variable(s) yourself (\`voltro secret generate\`).`);
|
|
1186
|
+
let i = T(t, Vo), a = r.map((e) => `${e.description ? `# ${e.description}\n` : ""}${e.key}=${e.value}`).join("\n");
|
|
1187
1187
|
try {
|
|
1188
|
-
if (
|
|
1189
|
-
let e =
|
|
1190
|
-
|
|
1191
|
-
} else
|
|
1188
|
+
if (M(i)) {
|
|
1189
|
+
let e = Ue(i, "utf8");
|
|
1190
|
+
He(i, `${e === "" || e.endsWith("\n") ? "" : "\n"}\n${a}\n`, "utf8");
|
|
1191
|
+
} else P(i, `# Minted by \`voltro dev\` — unique to this project and this machine.
|
|
1192
1192
|
# Not committed (see .gitignore). Your deployment needs its OWN values:
|
|
1193
1193
|
# voltro secret generate
|
|
1194
1194
|
\n${a}\n`, "utf8");
|
|
@@ -1201,7 +1201,7 @@ ${a.join("\n\n")}\n`);
|
|
|
1201
1201
|
file: i
|
|
1202
1202
|
};
|
|
1203
1203
|
}, Go = async ({ env: e = process.env } = {}) => {
|
|
1204
|
-
let t =
|
|
1204
|
+
let t = Fe.make(A.mergeAll(Hi.layer, Ui.Default)), n = await t.runPromise(Vi), r = await t.runPromise(Ui), i = (e.CACHE_BACKEND ?? "memory").toLowerCase();
|
|
1205
1205
|
return await t.runPromise(r.addSink((e) => n.invalidateTag(e))), {
|
|
1206
1206
|
service: n,
|
|
1207
1207
|
invalidationBus: r,
|
|
@@ -1210,7 +1210,7 @@ ${a.join("\n\n")}\n`);
|
|
|
1210
1210
|
ttlMs: e.ttlMs,
|
|
1211
1211
|
...e.swrMs === void 0 ? {} : { swrMs: e.swrMs },
|
|
1212
1212
|
tags: r
|
|
1213
|
-
},
|
|
1213
|
+
}, k.promise(i))),
|
|
1214
1214
|
put: (e, r, i) => {
|
|
1215
1215
|
t.runFork(n.put(e.key, {
|
|
1216
1216
|
ttlMs: e.ttlMs,
|
|
@@ -1220,14 +1220,14 @@ ${a.join("\n\n")}\n`);
|
|
|
1220
1220
|
}
|
|
1221
1221
|
},
|
|
1222
1222
|
cache: {
|
|
1223
|
-
get: (e) => t.runPromise(n.get(e)).then((e) =>
|
|
1223
|
+
get: (e) => t.runPromise(n.get(e)).then((e) => j.getOrUndefined(e)),
|
|
1224
1224
|
set: (e, r, i) => t.runPromise(n.set(e, r, i)),
|
|
1225
1225
|
setWithTags: (e, r, i) => t.runPromise(n.setWithTags(e, r, i)),
|
|
1226
1226
|
remove: (e) => t.runPromise(n.remove(e)),
|
|
1227
1227
|
has: (e) => t.runPromise(n.has(e)),
|
|
1228
1228
|
clear: () => t.runPromise(n.clear()),
|
|
1229
1229
|
invalidateTag: (e) => t.runPromise(n.invalidateTag(e)),
|
|
1230
|
-
wrap: (e, r, i) => t.runPromise(n.wrap(e, r,
|
|
1230
|
+
wrap: (e, r, i) => t.runPromise(n.wrap(e, r, k.promise(i)))
|
|
1231
1231
|
},
|
|
1232
1232
|
backend: i,
|
|
1233
1233
|
stats: () => t.runSync(n.stats()),
|
|
@@ -1354,15 +1354,15 @@ ${a.join("\n\n")}\n`);
|
|
|
1354
1354
|
take: 1
|
|
1355
1355
|
}))[0], a = i?.subject?.tenantId ?? null, o = t.tenantId ?? null;
|
|
1356
1356
|
if (i === void 0 || a !== o) throw new ni({ reason: "not authorized for this workflow run" });
|
|
1357
|
-
}, Yo = B.pipe(
|
|
1358
|
-
let t =
|
|
1357
|
+
}, Yo = B.pipe(A.provide(ke.layer)), Xo = (e) => {
|
|
1358
|
+
let t = A.succeed(Vi, e.cacheService), n = A.succeed(Wi, e.kvService), r = [
|
|
1359
1359
|
e.analyticsLayer,
|
|
1360
1360
|
t,
|
|
1361
1361
|
n,
|
|
1362
1362
|
...e.pluginServices,
|
|
1363
1363
|
...e.userLayers
|
|
1364
1364
|
];
|
|
1365
|
-
return
|
|
1365
|
+
return A.mergeAll(...r);
|
|
1366
1366
|
}, Zo = [
|
|
1367
1367
|
Oi,
|
|
1368
1368
|
Ai,
|
|
@@ -1374,13 +1374,13 @@ ${a.join("\n\n")}\n`);
|
|
|
1374
1374
|
let r = new Set(t);
|
|
1375
1375
|
if (n) for (let e of Zo) r.add(e.name);
|
|
1376
1376
|
let i = {};
|
|
1377
|
-
for (let [t, n] of Object.entries(e)) i[t] = r.has(t) ? (e) => n(e).pipe(
|
|
1377
|
+
for (let [t, n] of Object.entries(e)) i[t] = r.has(t) ? (e) => n(e).pipe(Re.take(1)) : n;
|
|
1378
1378
|
return i;
|
|
1379
|
-
}, $o =
|
|
1380
|
-
let t =
|
|
1379
|
+
}, $o = ze({ scope: "voltro:dev:supervisor" }), es = /\.generated\./, ts = /\.([cm]?[jt]sx?|json)$/, ns = (e) => {
|
|
1380
|
+
let t = C(e);
|
|
1381
1381
|
return !es.test(t) && ts.test(t);
|
|
1382
|
-
}, rs = (e) => e.startsWith("node_modules") || e.startsWith(".framework") || e.startsWith(".turbo") || e.startsWith(".vite") || e.startsWith("dist") || e.startsWith(".git"), is = process.env.WATCH_POLL === "1" || process.env.CHOKIDAR_USEPOLLING === "1", as = 1e3, os = (e) =>
|
|
1383
|
-
let n =
|
|
1382
|
+
}, rs = (e) => e.startsWith("node_modules") || e.startsWith(".framework") || e.startsWith(".turbo") || e.startsWith(".vite") || e.startsWith("dist") || e.startsWith(".git"), is = process.env.WATCH_POLL === "1" || process.env.CHOKIDAR_USEPOLLING === "1", as = 1e3, os = (e) => Re.async((t) => {
|
|
1383
|
+
let n = D(e), r = (e) => E(n, e), i = Ji(n, {
|
|
1384
1384
|
persistent: !0,
|
|
1385
1385
|
ignoreInitial: !0,
|
|
1386
1386
|
atomic: !0,
|
|
@@ -1389,7 +1389,7 @@ ${a.join("\n\n")}\n`);
|
|
|
1389
1389
|
binaryInterval: as,
|
|
1390
1390
|
ignored: (e) => {
|
|
1391
1391
|
let t = r(e);
|
|
1392
|
-
return t === "" ? !1 : rs(t) || es.test(
|
|
1392
|
+
return t === "" ? !1 : rs(t) || es.test(C(e));
|
|
1393
1393
|
}
|
|
1394
1394
|
});
|
|
1395
1395
|
return i.on("all", (e, n) => {
|
|
@@ -1400,10 +1400,10 @@ ${a.join("\n\n")}\n`);
|
|
|
1400
1400
|
}), !rs(i) && ns(i) && t.single({ file: i });
|
|
1401
1401
|
}), i.on("error", (e) => {
|
|
1402
1402
|
$o.error("watcher error", { hint: is ? void 0 : "on a bind-mount (k8s hostPath / Docker volume) set WATCH_POLL=1" }, e);
|
|
1403
|
-
}),
|
|
1403
|
+
}), k.sync(() => {
|
|
1404
1404
|
i.close();
|
|
1405
1405
|
});
|
|
1406
|
-
}), ss = (e) =>
|
|
1406
|
+
}), ss = (e) => k.acquireUseRelease(k.sync(() => {
|
|
1407
1407
|
let t = process.argv[1] ?? "";
|
|
1408
1408
|
return Bn(process.execPath, [
|
|
1409
1409
|
"--import",
|
|
@@ -1418,9 +1418,9 @@ ${a.join("\n\n")}\n`);
|
|
|
1418
1418
|
FRAMEWORK_DEV_INNER: "1"
|
|
1419
1419
|
}
|
|
1420
1420
|
});
|
|
1421
|
-
}), () =>
|
|
1421
|
+
}), () => k.never, (e) => k.async((t) => {
|
|
1422
1422
|
if (e.exitCode !== null || e.killed) {
|
|
1423
|
-
t(
|
|
1423
|
+
t(k.void);
|
|
1424
1424
|
return;
|
|
1425
1425
|
}
|
|
1426
1426
|
e.kill("SIGTERM");
|
|
@@ -1428,29 +1428,29 @@ ${a.join("\n\n")}\n`);
|
|
|
1428
1428
|
e.exitCode === null && !e.killed && e.kill("SIGKILL");
|
|
1429
1429
|
}, 1500);
|
|
1430
1430
|
e.once("exit", () => {
|
|
1431
|
-
clearTimeout(n), t(
|
|
1431
|
+
clearTimeout(n), t(k.void);
|
|
1432
1432
|
});
|
|
1433
|
-
})), cs = (e) =>
|
|
1433
|
+
})), cs = (e) => k.gen(function* () {
|
|
1434
1434
|
$o.info("supervisor active — watching project root", {
|
|
1435
1435
|
root: e.root,
|
|
1436
1436
|
patterns: ["**/*.{ts,tsx,mts,cts,js,jsx,mjs,cjs,json} (excl. *.generated.*)"],
|
|
1437
1437
|
watcher: is ? "chokidar (polling)" : "chokidar (native)",
|
|
1438
1438
|
hint: "WATCH=0 disables, WATCH_DEBUG=1 traces every event, WATCH_POLL=1 for bind-mounts (k8s/Docker)"
|
|
1439
1439
|
});
|
|
1440
|
-
let t = yield*
|
|
1441
|
-
let n = yield*
|
|
1442
|
-
yield*
|
|
1443
|
-
}), r =
|
|
1444
|
-
let e = yield*
|
|
1445
|
-
yield*
|
|
1446
|
-
onNone: () =>
|
|
1447
|
-
onSome: (e) =>
|
|
1448
|
-
}), yield*
|
|
1440
|
+
let t = yield* Ie.make(j.none()), n = k.gen(function* () {
|
|
1441
|
+
let n = yield* k.fork(ss(e.root));
|
|
1442
|
+
yield* Ie.set(t, j.some(n));
|
|
1443
|
+
}), r = k.gen(function* () {
|
|
1444
|
+
let e = yield* Ie.get(t);
|
|
1445
|
+
yield* j.match(e, {
|
|
1446
|
+
onNone: () => k.void,
|
|
1447
|
+
onSome: (e) => Ne.interrupt(e)
|
|
1448
|
+
}), yield* Ie.set(t, j.none());
|
|
1449
1449
|
});
|
|
1450
|
-
return yield* n, yield* os(e.root).pipe(
|
|
1450
|
+
return yield* n, yield* os(e.root).pipe(Re.debounce(Me.millis(80)), Re.runForEach((e) => k.gen(function* () {
|
|
1451
1451
|
let t = Date.now();
|
|
1452
1452
|
$o.info("file changed — restarting", { file: e.file }), yield* r, yield* n, $o.info("restart complete", { ms: Date.now() - t });
|
|
1453
|
-
}))), yield*
|
|
1453
|
+
}))), yield* k.never;
|
|
1454
1454
|
}), ls = (e) => {
|
|
1455
1455
|
let t = [];
|
|
1456
1456
|
for (let n of e) for (let e of n) {
|
|
@@ -1468,37 +1468,37 @@ ${a.join("\n\n")}\n`);
|
|
|
1468
1468
|
return n.length === 0 ? 0 : (t(ai(n)), n.length);
|
|
1469
1469
|
}, ds = async (e) => {
|
|
1470
1470
|
let t = e.spec ?? un, n;
|
|
1471
|
-
return t.kind !== "noop" && e.sqlLayer !== void 0 ? n = await
|
|
1471
|
+
return t.kind !== "noop" && e.sqlLayer !== void 0 ? n = await k.runPromise(k.gen(function* () {
|
|
1472
1472
|
let n = yield* V.SqlClient, r = t.build(n);
|
|
1473
|
-
return t.initialize && (yield* t.initialize(r).pipe(
|
|
1473
|
+
return t.initialize && (yield* t.initialize(r).pipe(k.catchAll((t) => k.sync(() => e.log.warn("analytics sink initialize failed", {
|
|
1474
1474
|
provider: r.info.provider,
|
|
1475
1475
|
err: String(t)
|
|
1476
1476
|
}))))), r;
|
|
1477
|
-
}).pipe(
|
|
1477
|
+
}).pipe(k.provide(e.sqlLayer))) : (t.kind !== "noop" && e.sqlLayer === void 0 && e.log.warn(`analytics sink '${t.kind}' requires a real SQL store — falling back to noop`), n = ln()), e.log.info("analytics sink", {
|
|
1478
1478
|
provider: n.info.provider,
|
|
1479
1479
|
capabilities: n.info.capabilities,
|
|
1480
1480
|
...n.info.detail ?? {}
|
|
1481
1481
|
}), {
|
|
1482
1482
|
spec: t,
|
|
1483
1483
|
sink: n,
|
|
1484
|
-
layer:
|
|
1484
|
+
layer: A.succeed(Ke, n),
|
|
1485
1485
|
tables: t.tables ?? [],
|
|
1486
1486
|
dispose: async () => {
|
|
1487
|
-
t.dispose && await
|
|
1487
|
+
t.dispose && await k.runPromise(t.dispose(n).pipe(k.timeout("1200 millis"), k.ignore));
|
|
1488
1488
|
}
|
|
1489
1489
|
};
|
|
1490
|
-
}, fs = "@effect/cluster@0.59.0", ps = "@effect__cluster@0.59.0.patch", ms = `patches/${ps}`, hs =
|
|
1491
|
-
for (let e of gs) if (
|
|
1490
|
+
}, fs = "@effect/cluster@0.59.0", ps = "@effect__cluster@0.59.0.patch", ms = `patches/${ps}`, hs = w(Oe(import.meta.url)), gs = [D(hs, "..", "templates", "patches", ps), D(hs, "..", "..", "templates", "patches", ps)], _s = async () => {
|
|
1491
|
+
for (let e of gs) if (M(e)) return N.readFile(e, "utf8");
|
|
1492
1492
|
throw Error(`@effect/cluster patch asset not found (looked in: ${gs.join(", ")}). This is a packaging bug — the CLI should ship it under templates/patches/.`);
|
|
1493
1493
|
}, vs = (e) => RegExp(`['"]?${fs.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}['"]?\\s*:`).test(e), ys = (e) => {
|
|
1494
1494
|
if (vs(e)) return null;
|
|
1495
1495
|
let t = ` '${fs}': ${ms}`, n = /^patchedDependencies:[ \t]*\n/m;
|
|
1496
1496
|
return n.test(e) ? e.replace(n, (e) => `${e}${t}\n`) : `${e}${e.endsWith("\n") ? "" : "\n"}\npatchedDependencies:\n${t}\n`;
|
|
1497
1497
|
}, bs = (e) => {
|
|
1498
|
-
let t =
|
|
1498
|
+
let t = D(e);
|
|
1499
1499
|
for (let e = 0; e < 12; e++) {
|
|
1500
|
-
if (
|
|
1501
|
-
let e =
|
|
1500
|
+
if (M(T(t, "pnpm-workspace.yaml"))) return t;
|
|
1501
|
+
let e = w(t);
|
|
1502
1502
|
if (e === t) break;
|
|
1503
1503
|
t = e;
|
|
1504
1504
|
}
|
|
@@ -1509,19 +1509,19 @@ ${a.join("\n\n")}\n`);
|
|
|
1509
1509
|
let n = await Ss(t);
|
|
1510
1510
|
return n.fullyWired ? null : `mssql + durable cluster workflows need the @effect/cluster patch, which a plain install cannot carry. Run \`voltro add mssql\` then \`pnpm install\` to wire it (missing: ${[n.patchFilePresent ? null : ms, n.pnpmEntryPresent ? null : "patchedDependencies in pnpm-workspace.yaml"].filter(Boolean).join(" + ")}). Without it, workflow message/runner storage misbehaves on SQL Server.`;
|
|
1511
1511
|
}, Ss = async (e) => {
|
|
1512
|
-
let t =
|
|
1512
|
+
let t = M(T(e, ms)), n = T(e, "pnpm-workspace.yaml"), r = M(n) && vs(await N.readFile(n, "utf8"));
|
|
1513
1513
|
return {
|
|
1514
1514
|
patchFilePresent: t,
|
|
1515
1515
|
pnpmEntryPresent: r,
|
|
1516
1516
|
fullyWired: t && r
|
|
1517
1517
|
};
|
|
1518
1518
|
}, Cs = async (e) => {
|
|
1519
|
-
let t = [], n =
|
|
1520
|
-
(
|
|
1521
|
-
let i =
|
|
1522
|
-
if (
|
|
1523
|
-
let e = ys(await
|
|
1524
|
-
e !== null && (await
|
|
1519
|
+
let t = [], n = T(e, ms), r = await _s();
|
|
1520
|
+
(M(n) ? await N.readFile(n, "utf8") : null) !== r && (await N.mkdir(w(n), { recursive: !0 }), await N.writeFile(n, r, "utf8"), t.push(`patch file → ${ms}`));
|
|
1521
|
+
let i = T(e, "pnpm-workspace.yaml");
|
|
1522
|
+
if (M(i)) {
|
|
1523
|
+
let e = ys(await N.readFile(i, "utf8"));
|
|
1524
|
+
e !== null && (await N.writeFile(i, e, "utf8"), t.push(`patchedDependencies['${fs}'] → pnpm-workspace.yaml`));
|
|
1525
1525
|
}
|
|
1526
1526
|
return t;
|
|
1527
1527
|
}, ws = async (e, t) => {
|
|
@@ -1529,7 +1529,7 @@ ${a.join("\n\n")}\n`);
|
|
|
1529
1529
|
for (let r of e) {
|
|
1530
1530
|
let e;
|
|
1531
1531
|
try {
|
|
1532
|
-
e = await import(
|
|
1532
|
+
e = await import(O(r).href);
|
|
1533
1533
|
} catch (e) {
|
|
1534
1534
|
t.warn("seed: failed to import", { file: r }, e);
|
|
1535
1535
|
continue;
|
|
@@ -1539,7 +1539,7 @@ ${a.join("\n\n")}\n`);
|
|
|
1539
1539
|
t.warn("seed: no defineSeed export", { file: r });
|
|
1540
1540
|
continue;
|
|
1541
1541
|
}
|
|
1542
|
-
let a = await
|
|
1542
|
+
let a = await N.readFile(r, "utf8").catch(() => ""), o = i.fingerprint ? i.fingerprint({ src: a }) : Rn("sha256").update(a).digest("hex").slice(0, 16);
|
|
1543
1543
|
n.push({
|
|
1544
1544
|
file: r,
|
|
1545
1545
|
definition: i,
|
|
@@ -1641,7 +1641,7 @@ ${a.join("\n\n")}\n`);
|
|
|
1641
1641
|
for (let r of e) {
|
|
1642
1642
|
let e;
|
|
1643
1643
|
try {
|
|
1644
|
-
e = await
|
|
1644
|
+
e = await x(r);
|
|
1645
1645
|
} catch (e) {
|
|
1646
1646
|
t.warn("subscriber: failed to import", { file: r }, e);
|
|
1647
1647
|
continue;
|
|
@@ -1662,7 +1662,7 @@ ${a.join("\n\n")}\n`);
|
|
|
1662
1662
|
}
|
|
1663
1663
|
n.push({
|
|
1664
1664
|
file: r,
|
|
1665
|
-
id: Ms(
|
|
1665
|
+
id: Ms(C(r)),
|
|
1666
1666
|
definition: a
|
|
1667
1667
|
});
|
|
1668
1668
|
}
|
|
@@ -1723,7 +1723,7 @@ ${a.join("\n\n")}\n`);
|
|
|
1723
1723
|
for (let i of e) {
|
|
1724
1724
|
let e;
|
|
1725
1725
|
try {
|
|
1726
|
-
e = await
|
|
1726
|
+
e = await x(i);
|
|
1727
1727
|
} catch (e) {
|
|
1728
1728
|
t.warn("outbox: failed to import", { file: i }, e);
|
|
1729
1729
|
continue;
|
|
@@ -1753,7 +1753,7 @@ ${a.join("\n\n")}\n`);
|
|
|
1753
1753
|
}
|
|
1754
1754
|
r.set(o.effect, i), n.push({
|
|
1755
1755
|
file: i,
|
|
1756
|
-
id: Fs(
|
|
1756
|
+
id: Fs(C(i)),
|
|
1757
1757
|
definition: o
|
|
1758
1758
|
});
|
|
1759
1759
|
}
|
|
@@ -1891,7 +1891,7 @@ ${a.join("\n\n")}\n`);
|
|
|
1891
1891
|
for (let r of e) {
|
|
1892
1892
|
let e;
|
|
1893
1893
|
try {
|
|
1894
|
-
e = await
|
|
1894
|
+
e = await x(r);
|
|
1895
1895
|
} catch (e) {
|
|
1896
1896
|
t.warn("reaction: failed to import (check defineReaction validation)", { file: r }, e);
|
|
1897
1897
|
continue;
|
|
@@ -1920,7 +1920,7 @@ ${a.join("\n\n")}\n`);
|
|
|
1920
1920
|
}
|
|
1921
1921
|
n.push({
|
|
1922
1922
|
file: r,
|
|
1923
|
-
id: Us(
|
|
1923
|
+
id: Us(C(r)),
|
|
1924
1924
|
definition: a
|
|
1925
1925
|
});
|
|
1926
1926
|
}
|
|
@@ -2069,11 +2069,11 @@ ${a.join("\n\n")}\n`);
|
|
|
2069
2069
|
durationMs: 0,
|
|
2070
2070
|
lastError: null,
|
|
2071
2071
|
nextRefreshAt: null
|
|
2072
|
-
}, r = (t) =>
|
|
2072
|
+
}, r = (t) => k.runPromise(t.pipe(k.provide(e))), i = () => k.gen(function* () {
|
|
2073
2073
|
let e = yield* V.SqlClient;
|
|
2074
|
-
yield* e.unsafe(Xs).pipe(
|
|
2075
|
-
}), a = () =>
|
|
2076
|
-
let e = yield* V.SqlClient, n = yield* e`SELECT * FROM ${e(qs)}`.pipe(
|
|
2074
|
+
yield* e.unsafe(Xs).pipe(k.orDie), yield* e.unsafe(Zs).pipe(k.orDie), yield* e.unsafe(Qs).pipe(k.orDie);
|
|
2075
|
+
}), a = () => k.gen(function* () {
|
|
2076
|
+
let e = yield* V.SqlClient, n = yield* e`SELECT * FROM ${e(qs)}`.pipe(k.orElseSucceed(() => []));
|
|
2077
2077
|
for (let r of n) {
|
|
2078
2078
|
let n = yield* e`
|
|
2079
2079
|
SELECT ${e("row_index")} AS row_index, ${e("row_data")} AS row_data
|
|
@@ -2081,7 +2081,7 @@ ${a.join("\n\n")}\n`);
|
|
|
2081
2081
|
WHERE ${e("aggregate_name")} = ${r.name}
|
|
2082
2082
|
AND ${e("generation")} = ${r.generation}
|
|
2083
2083
|
ORDER BY ${e("row_index")} ASC
|
|
2084
|
-
`.pipe(
|
|
2084
|
+
`.pipe(k.orElseSucceed(() => [])), i = [];
|
|
2085
2085
|
for (let e of n) try {
|
|
2086
2086
|
i.push(JSON.parse(e.row_data));
|
|
2087
2087
|
} catch {}
|
|
@@ -2090,12 +2090,12 @@ ${a.join("\n\n")}\n`);
|
|
|
2090
2090
|
meta: $s(r)
|
|
2091
2091
|
});
|
|
2092
2092
|
}
|
|
2093
|
-
}), o = (e, t) =>
|
|
2093
|
+
}), o = (e, t) => k.gen(function* () {
|
|
2094
2094
|
let n = yield* V.SqlClient, r = (yield* n`
|
|
2095
2095
|
SELECT ${n("generation")} AS generation
|
|
2096
2096
|
FROM ${n(qs)}
|
|
2097
2097
|
WHERE ${n("name")} = ${e}
|
|
2098
|
-
`.pipe(
|
|
2098
|
+
`.pipe(k.orElseSucceed(() => [])))[0]?.generation ?? 0, i = r + 1;
|
|
2099
2099
|
yield* n`
|
|
2100
2100
|
UPDATE ${n(qs)} SET
|
|
2101
2101
|
${n("generation")} = ${i},
|
|
@@ -2105,7 +2105,7 @@ ${a.join("\n\n")}\n`);
|
|
|
2105
2105
|
${n("last_error")} = ${t.meta.lastError},
|
|
2106
2106
|
${n("next_refresh_at")} = ${t.meta.nextRefreshAt ? t.meta.nextRefreshAt.toISOString() : null}
|
|
2107
2107
|
WHERE ${n("name")} = ${e}
|
|
2108
|
-
`.pipe(
|
|
2108
|
+
`.pipe(k.orDie), r === 0 && (yield* n`
|
|
2109
2109
|
INSERT INTO ${n(qs)}
|
|
2110
2110
|
(${n("name")}, ${n("generation")}, ${n("refreshed_at")},
|
|
2111
2111
|
${n("duration_ms")}, ${n("row_count")}, ${n("last_error")}, ${n("next_refresh_at")})
|
|
@@ -2113,7 +2113,7 @@ ${a.join("\n\n")}\n`);
|
|
|
2113
2113
|
(${e}, ${i}, ${t.meta.refreshedAt ? t.meta.refreshedAt.toISOString() : null},
|
|
2114
2114
|
${t.meta.durationMs}, ${t.meta.rowCount}, ${t.meta.lastError},
|
|
2115
2115
|
${t.meta.nextRefreshAt ? t.meta.nextRefreshAt.toISOString() : null})
|
|
2116
|
-
`.pipe(
|
|
2116
|
+
`.pipe(k.orElseSucceed(() => void 0)));
|
|
2117
2117
|
for (let r = 0; r < t.rows.length; r++) {
|
|
2118
2118
|
let a = JSON.stringify(t.rows[r]);
|
|
2119
2119
|
yield* n`
|
|
@@ -2121,14 +2121,14 @@ ${a.join("\n\n")}\n`);
|
|
|
2121
2121
|
(${n("aggregate_name")}, ${n("generation")}, ${n("row_index")}, ${n("row_data")})
|
|
2122
2122
|
VALUES
|
|
2123
2123
|
(${e}, ${i}, ${r}, ${a})
|
|
2124
|
-
`.pipe(
|
|
2124
|
+
`.pipe(k.orDie);
|
|
2125
2125
|
}
|
|
2126
2126
|
r > 0 && (yield* n`
|
|
2127
2127
|
DELETE FROM ${n(Js)}
|
|
2128
2128
|
WHERE ${n("aggregate_name")} = ${e}
|
|
2129
2129
|
AND ${n("generation")} < ${i}
|
|
2130
|
-
`.pipe(
|
|
2131
|
-
}), s = (e, t) =>
|
|
2130
|
+
`.pipe(k.orDie));
|
|
2131
|
+
}), s = (e, t) => k.gen(function* () {
|
|
2132
2132
|
let n = yield* V.SqlClient;
|
|
2133
2133
|
yield* n`
|
|
2134
2134
|
UPDATE ${n(qs)} SET
|
|
@@ -2138,10 +2138,10 @@ ${a.join("\n\n")}\n`);
|
|
|
2138
2138
|
${n("last_error")} = ${t.lastError},
|
|
2139
2139
|
${n("next_refresh_at")} = ${t.nextRefreshAt ? t.nextRefreshAt.toISOString() : null}
|
|
2140
2140
|
WHERE ${n("name")} = ${e}
|
|
2141
|
-
`.pipe(
|
|
2141
|
+
`.pipe(k.orDie), (yield* n`
|
|
2142
2142
|
SELECT ${n("name")} FROM ${n(qs)}
|
|
2143
2143
|
WHERE ${n("name")} = ${e}
|
|
2144
|
-
`.pipe(
|
|
2144
|
+
`.pipe(k.orElseSucceed(() => []))).length === 0 && (yield* n`
|
|
2145
2145
|
INSERT INTO ${n(qs)}
|
|
2146
2146
|
(${n("name")}, ${n("generation")}, ${n("refreshed_at")},
|
|
2147
2147
|
${n("duration_ms")}, ${n("row_count")}, ${n("last_error")}, ${n("next_refresh_at")})
|
|
@@ -2149,7 +2149,7 @@ ${a.join("\n\n")}\n`);
|
|
|
2149
2149
|
(${e}, 0, ${t.refreshedAt ? t.refreshedAt.toISOString() : null},
|
|
2150
2150
|
${t.durationMs}, ${t.rowCount}, ${t.lastError},
|
|
2151
2151
|
${t.nextRefreshAt ? t.nextRefreshAt.toISOString() : null})
|
|
2152
|
-
`.pipe(
|
|
2152
|
+
`.pipe(k.orDie));
|
|
2153
2153
|
});
|
|
2154
2154
|
return {
|
|
2155
2155
|
initialize: async () => {
|
|
@@ -2189,11 +2189,11 @@ ${a.join("\n\n")}\n`);
|
|
|
2189
2189
|
};
|
|
2190
2190
|
},
|
|
2191
2191
|
refreshMirror: async (e) => {
|
|
2192
|
-
await r(
|
|
2192
|
+
await r(k.gen(function* () {
|
|
2193
2193
|
let n = yield* V.SqlClient, r = (yield* n`
|
|
2194
2194
|
SELECT * FROM ${n(qs)}
|
|
2195
2195
|
WHERE ${n("name")} = ${e}
|
|
2196
|
-
`.pipe(
|
|
2196
|
+
`.pipe(k.orElseSucceed(() => [])))[0];
|
|
2197
2197
|
if (!r) return;
|
|
2198
2198
|
let i = yield* n`
|
|
2199
2199
|
SELECT ${n("row_index")} AS row_index, ${n("row_data")} AS row_data
|
|
@@ -2201,7 +2201,7 @@ ${a.join("\n\n")}\n`);
|
|
|
2201
2201
|
WHERE ${n("aggregate_name")} = ${e}
|
|
2202
2202
|
AND ${n("generation")} = ${r.generation}
|
|
2203
2203
|
ORDER BY ${n("row_index")} ASC
|
|
2204
|
-
`.pipe(
|
|
2204
|
+
`.pipe(k.orElseSucceed(() => [])), a = [];
|
|
2205
2205
|
for (let e of i) try {
|
|
2206
2206
|
a.push(JSON.parse(e.row_data));
|
|
2207
2207
|
} catch {}
|
|
@@ -2217,7 +2217,7 @@ ${a.join("\n\n")}\n`);
|
|
|
2217
2217
|
for (let i of e) {
|
|
2218
2218
|
let e;
|
|
2219
2219
|
try {
|
|
2220
|
-
e = await
|
|
2220
|
+
e = await x(i);
|
|
2221
2221
|
} catch (e) {
|
|
2222
2222
|
t.warn("aggregate: failed to import", { file: i }, e);
|
|
2223
2223
|
continue;
|
|
@@ -2231,7 +2231,7 @@ ${a.join("\n\n")}\n`);
|
|
|
2231
2231
|
r.add(a.name), n.push({
|
|
2232
2232
|
file: i,
|
|
2233
2233
|
definition: a
|
|
2234
|
-
}), tc(
|
|
2234
|
+
}), tc(C(i));
|
|
2235
2235
|
}
|
|
2236
2236
|
return n;
|
|
2237
2237
|
}, rc = /^(\d+)(ms|s|m|h|d)$/, ic = (e) => {
|
|
@@ -2271,7 +2271,7 @@ ${a.join("\n\n")}\n`);
|
|
|
2271
2271
|
let r = n ?? 0, i = t === void 0 ? e.length : r + t;
|
|
2272
2272
|
return e.slice(r, i);
|
|
2273
2273
|
}, cc = (e, t) => {
|
|
2274
|
-
let n =
|
|
2274
|
+
let n = Le.decodeUnknownEither(e.output), r = [];
|
|
2275
2275
|
for (let e = 0; e < t.length; e++) {
|
|
2276
2276
|
let i = n(t[e]);
|
|
2277
2277
|
if (i._tag === "Left") {
|
|
@@ -2290,10 +2290,10 @@ ${a.join("\n\n")}\n`);
|
|
|
2290
2290
|
}, lc = (e, t) => {
|
|
2291
2291
|
let n = e.refresh;
|
|
2292
2292
|
if (n.cron) {
|
|
2293
|
-
let e = n.timezone ?? "UTC", r =
|
|
2293
|
+
let e = n.timezone ?? "UTC", r = je.unsafeParse(n.cron, e);
|
|
2294
2294
|
return {
|
|
2295
2295
|
intervalMs: null,
|
|
2296
|
-
nextAt:
|
|
2296
|
+
nextAt: je.next(r, t),
|
|
2297
2297
|
kind: "cron"
|
|
2298
2298
|
};
|
|
2299
2299
|
}
|
|
@@ -2337,7 +2337,7 @@ ${a.join("\n\n")}\n`);
|
|
|
2337
2337
|
analytics: r,
|
|
2338
2338
|
log: l,
|
|
2339
2339
|
id: t.name
|
|
2340
|
-
}), o = cc(t, e instanceof Promise ? await e : await
|
|
2340
|
+
}), o = cc(t, e instanceof Promise ? await e : await k.runPromise(e));
|
|
2341
2341
|
if (!o.ok) throw Error(`output schema mismatch: ${o.reason}`);
|
|
2342
2342
|
let s = o.rows;
|
|
2343
2343
|
if (t.strategy === "merge") {
|
|
@@ -2431,7 +2431,7 @@ ${a.join("\n\n")}\n`);
|
|
|
2431
2431
|
}, pc = (e) => {
|
|
2432
2432
|
let { definition: t, store: n, storage: r, log: i, schedule: a } = e, o = t.incremental;
|
|
2433
2433
|
if (o === void 0) return;
|
|
2434
|
-
let s = i.child(`aggregate:${t.name}`), c = new
|
|
2434
|
+
let s = i.child(`aggregate:${t.name}`), c = new I({
|
|
2435
2435
|
op: o.op,
|
|
2436
2436
|
...o.column === void 0 ? {} : { column: o.column },
|
|
2437
2437
|
...o.groupBy === void 0 ? {} : { groupBy: o.groupBy }
|
|
@@ -2573,13 +2573,13 @@ ${a.join("\n\n")}\n`);
|
|
|
2573
2573
|
return {
|
|
2574
2574
|
registry: {
|
|
2575
2575
|
getHandle: (a) => {
|
|
2576
|
-
let l = s.has(a.name), u = () =>
|
|
2576
|
+
let l = s.has(a.name), u = () => k.fail(new We({ name: a.name }));
|
|
2577
2577
|
return l ? {
|
|
2578
|
-
read: (e) =>
|
|
2578
|
+
read: (e) => k.gen(function* () {
|
|
2579
2579
|
let n = t.get(a.name);
|
|
2580
2580
|
if (e?.maxAgeMs !== void 0) {
|
|
2581
2581
|
let t = n.meta.refreshedAt, r = t === null ? Infinity : Date.now() - t.getTime();
|
|
2582
|
-
if (r > e.maxAgeMs) return yield*
|
|
2582
|
+
if (r > e.maxAgeMs) return yield* k.fail(new L({
|
|
2583
2583
|
name: a.name,
|
|
2584
2584
|
ageMs: Number.isFinite(r) ? r : -1,
|
|
2585
2585
|
maxAgeMs: e.maxAgeMs
|
|
@@ -2587,8 +2587,8 @@ ${a.join("\n\n")}\n`);
|
|
|
2587
2587
|
}
|
|
2588
2588
|
return sc(oc(ac(n.rows, e?.where), e?.orderBy, e?.direction), e?.limit, e?.offset);
|
|
2589
2589
|
}),
|
|
2590
|
-
meta: () =>
|
|
2591
|
-
refresh: () =>
|
|
2590
|
+
meta: () => k.succeed(t.get(a.name).meta),
|
|
2591
|
+
refresh: () => k.tryPromise({
|
|
2592
2592
|
try: () => uc({
|
|
2593
2593
|
definition: s.get(a.name),
|
|
2594
2594
|
store: e.store,
|
|
@@ -2599,7 +2599,7 @@ ${a.join("\n\n")}\n`);
|
|
|
2599
2599
|
refreshState: o.get(a.name),
|
|
2600
2600
|
scheduledAt: /* @__PURE__ */ new Date()
|
|
2601
2601
|
}),
|
|
2602
|
-
catch: (e) => new
|
|
2602
|
+
catch: (e) => new F({
|
|
2603
2603
|
name: a.name,
|
|
2604
2604
|
operation: "refresh",
|
|
2605
2605
|
cause: e instanceof Error ? `${e.name}: ${e.message}` : String(e)
|
|
@@ -2607,7 +2607,7 @@ ${a.join("\n\n")}\n`);
|
|
|
2607
2607
|
})
|
|
2608
2608
|
} : {
|
|
2609
2609
|
read: () => u(),
|
|
2610
|
-
meta: () =>
|
|
2610
|
+
meta: () => k.succeed(c),
|
|
2611
2611
|
refresh: () => u()
|
|
2612
2612
|
};
|
|
2613
2613
|
},
|
|
@@ -2641,15 +2641,15 @@ ${a.join("\n\n")}\n`);
|
|
|
2641
2641
|
};
|
|
2642
2642
|
}, hc = {
|
|
2643
2643
|
getHandle: (e) => ({
|
|
2644
|
-
read: () =>
|
|
2645
|
-
meta: () =>
|
|
2644
|
+
read: () => k.fail(new We({ name: e.name })),
|
|
2645
|
+
meta: () => k.succeed({
|
|
2646
2646
|
refreshedAt: null,
|
|
2647
2647
|
rowCount: 0,
|
|
2648
2648
|
durationMs: 0,
|
|
2649
2649
|
lastError: null,
|
|
2650
2650
|
nextRefreshAt: null
|
|
2651
2651
|
}),
|
|
2652
|
-
refresh: () =>
|
|
2652
|
+
refresh: () => k.fail(new We({ name: e.name }))
|
|
2653
2653
|
}),
|
|
2654
2654
|
snapshot: () => [],
|
|
2655
2655
|
refreshByName: async () => !1
|
|
@@ -2797,7 +2797,7 @@ ${a.join("\n\n")}\n`);
|
|
|
2797
2797
|
for (let a of e) {
|
|
2798
2798
|
let e;
|
|
2799
2799
|
try {
|
|
2800
|
-
e = await
|
|
2800
|
+
e = await x(a);
|
|
2801
2801
|
} catch (e) {
|
|
2802
2802
|
t.warn("webhook: failed to import", { file: a }, e);
|
|
2803
2803
|
continue;
|
|
@@ -2838,7 +2838,7 @@ ${a.join("\n\n")}\n`);
|
|
|
2838
2838
|
for (let r of e) {
|
|
2839
2839
|
let e;
|
|
2840
2840
|
try {
|
|
2841
|
-
e = await import(
|
|
2841
|
+
e = await import(O(r).href);
|
|
2842
2842
|
} catch (e) {
|
|
2843
2843
|
t.warn("email: failed to import", { file: r }, e);
|
|
2844
2844
|
continue;
|
|
@@ -2854,7 +2854,7 @@ ${a.join("\n\n")}\n`);
|
|
|
2854
2854
|
});
|
|
2855
2855
|
}
|
|
2856
2856
|
return { templates: n };
|
|
2857
|
-
}, Fc = (e) =>
|
|
2857
|
+
}, Fc = (e) => k.map(e, (e) => ({ text: e })), Ic = (e) => {
|
|
2858
2858
|
let { descriptor: t, executor: n, file: r } = e, { send: i, messages: a } = tr(t);
|
|
2859
2859
|
return [{
|
|
2860
2860
|
kind: "action",
|
|
@@ -2958,8 +2958,8 @@ ${a.join("\n\n")}\n`);
|
|
|
2958
2958
|
}
|
|
2959
2959
|
}, Jc = async (e) => {
|
|
2960
2960
|
if (e !== void 0) {
|
|
2961
|
-
if (typeof e == "object" && e &&
|
|
2962
|
-
await
|
|
2961
|
+
if (typeof e == "object" && e && k.isEffect(e)) {
|
|
2962
|
+
await k.runPromise(e);
|
|
2963
2963
|
return;
|
|
2964
2964
|
}
|
|
2965
2965
|
await Promise.resolve(e);
|
|
@@ -2973,7 +2973,7 @@ ${a.join("\n\n")}\n`);
|
|
|
2973
2973
|
}
|
|
2974
2974
|
let n = e.pluginConfigs?.[t.name];
|
|
2975
2975
|
try {
|
|
2976
|
-
let e =
|
|
2976
|
+
let e = Le.decodeUnknownSync(t.configSchema)(n);
|
|
2977
2977
|
a.set(t.name, e);
|
|
2978
2978
|
} catch (e) {
|
|
2979
2979
|
throw Error(`plugin "${t.name}" config failed validation: ${e.message ?? String(e)}`);
|
|
@@ -2985,7 +2985,7 @@ ${a.join("\n\n")}\n`);
|
|
|
2985
2985
|
type: e.appType,
|
|
2986
2986
|
voltroVersion: e.voltroVersion
|
|
2987
2987
|
},
|
|
2988
|
-
logger:
|
|
2988
|
+
logger: ze({ scope: t.name }),
|
|
2989
2989
|
env: process.env,
|
|
2990
2990
|
config: a.get(t.name)
|
|
2991
2991
|
});
|
|
@@ -3134,21 +3134,21 @@ ${a.join("\n\n")}\n`);
|
|
|
3134
3134
|
action: "intercept-action"
|
|
3135
3135
|
}, $c = (e, t, n, r) => {
|
|
3136
3136
|
let i = Qc[t], a = `plugin.${e}.${i}`, o = a;
|
|
3137
|
-
return (t, s) =>
|
|
3137
|
+
return (t, s) => k.suspend(() => {
|
|
3138
3138
|
let c = Date.now();
|
|
3139
|
-
return n(t, s).pipe(
|
|
3139
|
+
return n(t, s).pipe(k.withSpan(a, { attributes: {
|
|
3140
3140
|
"plugin.name": e,
|
|
3141
3141
|
"plugin.hook": i,
|
|
3142
3142
|
"rpc.tag": s.tag,
|
|
3143
3143
|
"rpc.kind": s.kind
|
|
3144
|
-
} }),
|
|
3144
|
+
} }), k.tap(() => k.sync(() => {
|
|
3145
3145
|
r.record({
|
|
3146
3146
|
kind: "plugin",
|
|
3147
3147
|
tag: o,
|
|
3148
3148
|
durationMs: Date.now() - c,
|
|
3149
3149
|
status: "ok"
|
|
3150
3150
|
});
|
|
3151
|
-
})),
|
|
3151
|
+
})), k.tapErrorCause(() => k.sync(() => {
|
|
3152
3152
|
r.record({
|
|
3153
3153
|
kind: "plugin",
|
|
3154
3154
|
tag: o,
|
|
@@ -3164,7 +3164,7 @@ ${a.join("\n\n")}\n`);
|
|
|
3164
3164
|
typeof e == "function" && i.push($c(a.name, t, e, n));
|
|
3165
3165
|
}
|
|
3166
3166
|
return i;
|
|
3167
|
-
}, tl = `${
|
|
3167
|
+
}, tl = `${ge}/plugins/`, nl = (e) => e.startsWith("/") ? e : `/${e}`, rl = (e) => {
|
|
3168
3168
|
let t = e.indexOf("?");
|
|
3169
3169
|
return t >= 0 ? e.slice(0, t) : e;
|
|
3170
3170
|
}, il = (e, t) => e.kind === "json" ? {
|
|
@@ -3196,50 +3196,50 @@ ${a.join("\n\n")}\n`);
|
|
|
3196
3196
|
return {
|
|
3197
3197
|
endpoints: n,
|
|
3198
3198
|
async dispatch(e, t, r, i, a) {
|
|
3199
|
-
let
|
|
3200
|
-
if (!
|
|
3201
|
-
let
|
|
3202
|
-
if (
|
|
3199
|
+
let o = rl(e);
|
|
3200
|
+
if (!o.startsWith(tl)) return null;
|
|
3201
|
+
let s = b(r.origin ?? r.Origin), c = t.toUpperCase();
|
|
3202
|
+
if (c === "OPTIONS") return {
|
|
3203
3203
|
status: 204,
|
|
3204
3204
|
contentType: "text/plain",
|
|
3205
3205
|
body: "",
|
|
3206
|
-
headers:
|
|
3206
|
+
headers: s
|
|
3207
3207
|
};
|
|
3208
|
-
if (
|
|
3208
|
+
if (le()) return {
|
|
3209
3209
|
status: 503,
|
|
3210
3210
|
contentType: "application/json; charset=utf-8",
|
|
3211
3211
|
body: JSON.stringify({ error: "inspect disabled (VOLTRO_INSPECT=off)" }),
|
|
3212
|
-
headers:
|
|
3212
|
+
headers: s
|
|
3213
3213
|
};
|
|
3214
|
-
let
|
|
3215
|
-
if (!
|
|
3214
|
+
let l = (a?.authResolver ?? te)(r);
|
|
3215
|
+
if (!l.ok) return {
|
|
3216
3216
|
status: 401,
|
|
3217
3217
|
contentType: "application/json; charset=utf-8",
|
|
3218
3218
|
body: JSON.stringify({
|
|
3219
3219
|
error: "unauthorized",
|
|
3220
|
-
reason:
|
|
3220
|
+
reason: l.reason
|
|
3221
3221
|
}),
|
|
3222
|
-
headers:
|
|
3222
|
+
headers: s
|
|
3223
3223
|
};
|
|
3224
|
-
let
|
|
3225
|
-
if (!
|
|
3224
|
+
let u = n.find((e) => e.method === c && e.path === o);
|
|
3225
|
+
if (!u) return null;
|
|
3226
3226
|
try {
|
|
3227
|
-
return il(await
|
|
3228
|
-
method:
|
|
3227
|
+
return il(await k.runPromise(u.handler({
|
|
3228
|
+
method: c,
|
|
3229
3229
|
url: e,
|
|
3230
3230
|
headers: r,
|
|
3231
3231
|
body: i
|
|
3232
|
-
})),
|
|
3232
|
+
})), s);
|
|
3233
3233
|
} catch (e) {
|
|
3234
3234
|
return {
|
|
3235
3235
|
status: 500,
|
|
3236
3236
|
contentType: "application/json; charset=utf-8",
|
|
3237
3237
|
body: JSON.stringify({
|
|
3238
3238
|
error: "plugin inspect handler failed",
|
|
3239
|
-
plugin:
|
|
3239
|
+
plugin: u.pluginName,
|
|
3240
3240
|
message: e?.message ?? String(e)
|
|
3241
3241
|
}),
|
|
3242
|
-
headers:
|
|
3242
|
+
headers: s
|
|
3243
3243
|
};
|
|
3244
3244
|
}
|
|
3245
3245
|
}
|
|
@@ -3249,10 +3249,10 @@ ${a.join("\n\n")}\n`);
|
|
|
3249
3249
|
return async (i, a) => {
|
|
3250
3250
|
let o = Date.now();
|
|
3251
3251
|
try {
|
|
3252
|
-
await
|
|
3252
|
+
await k.runPromise(k.tryPromise({
|
|
3253
3253
|
try: () => t(i, a),
|
|
3254
3254
|
catch: (e) => e
|
|
3255
|
-
}).pipe(
|
|
3255
|
+
}).pipe(k.withSpan(`plugin.${e}.schedule-fire`, { attributes: {
|
|
3256
3256
|
"plugin.name": e,
|
|
3257
3257
|
"plugin.hook": "schedule-fire",
|
|
3258
3258
|
"schedule.name": a.name,
|
|
@@ -3285,20 +3285,20 @@ ${a.join("\n\n")}\n`);
|
|
|
3285
3285
|
};
|
|
3286
3286
|
}, cl = (e, t, n) => ((r, i) => {
|
|
3287
3287
|
let a = `plugin.${e}.workflow-step`, o = a, s = Date.now();
|
|
3288
|
-
return t(r, i).pipe(
|
|
3288
|
+
return t(r, i).pipe(k.withSpan(a, { attributes: {
|
|
3289
3289
|
"plugin.name": e,
|
|
3290
3290
|
"plugin.hook": "workflow-step",
|
|
3291
3291
|
"workflow.step": i.stepName,
|
|
3292
3292
|
"workflow.runId": i.runId,
|
|
3293
3293
|
"workflow.attempt": i.attempt
|
|
3294
|
-
} }),
|
|
3294
|
+
} }), k.tap(() => k.sync(() => {
|
|
3295
3295
|
n.record({
|
|
3296
3296
|
kind: "plugin",
|
|
3297
3297
|
tag: o,
|
|
3298
3298
|
durationMs: Date.now() - s,
|
|
3299
3299
|
status: "ok"
|
|
3300
3300
|
});
|
|
3301
|
-
})),
|
|
3301
|
+
})), k.tapErrorCause(() => k.sync(() => {
|
|
3302
3302
|
n.record({
|
|
3303
3303
|
kind: "plugin",
|
|
3304
3304
|
tag: o,
|
|
@@ -3309,7 +3309,7 @@ ${a.join("\n\n")}\n`);
|
|
|
3309
3309
|
}), ll = (e, t) => {
|
|
3310
3310
|
let n = [];
|
|
3311
3311
|
for (let r of e) typeof r.onWorkflowStep == "function" && n.push(cl(r.name, r.onWorkflowStep, t));
|
|
3312
|
-
return n.length === 0 ?
|
|
3312
|
+
return n.length === 0 ? A.succeed(or, { interceptor: ((e) => e) }) : A.succeed(or, { interceptor: ((e, t) => n.reduceRight((e, n) => n(e, t), e)) });
|
|
3313
3313
|
}, ul = (e) => {
|
|
3314
3314
|
if (!e) return;
|
|
3315
3315
|
let t = e.workflowName ?? e.tag, n = [];
|
|
@@ -3428,13 +3428,13 @@ ${a.join("\n\n")}\n`);
|
|
|
3428
3428
|
let t = [], n = async (e) => {
|
|
3429
3429
|
let r;
|
|
3430
3430
|
try {
|
|
3431
|
-
r = await
|
|
3431
|
+
r = await N.readdir(e, { withFileTypes: !0 });
|
|
3432
3432
|
} catch {
|
|
3433
3433
|
return;
|
|
3434
3434
|
}
|
|
3435
3435
|
for (let i of r) {
|
|
3436
3436
|
if (bl.has(i.name)) continue;
|
|
3437
|
-
let r =
|
|
3437
|
+
let r = T(e, i.name);
|
|
3438
3438
|
i.isDirectory() ? await n(r) : i.isFile() && (_l.test(i.name) && !vl.test(i.name) || yl.test(i.name)) && t.push(r);
|
|
3439
3439
|
}
|
|
3440
3440
|
};
|
|
@@ -3442,7 +3442,7 @@ ${a.join("\n\n")}\n`);
|
|
|
3442
3442
|
}, Sl = async (e) => {
|
|
3443
3443
|
let t = await xl(e), n = [];
|
|
3444
3444
|
for (let e of t) try {
|
|
3445
|
-
let t = await import(
|
|
3445
|
+
let t = await import(O(e).href);
|
|
3446
3446
|
for (let r of Object.values(t)) {
|
|
3447
3447
|
if (r && typeof r == "object" && "kind" in r && "name" in r) {
|
|
3448
3448
|
let e = r;
|
|
@@ -3730,9 +3730,9 @@ ${a.join("\n\n")}\n`);
|
|
|
3730
3730
|
r.removeListener("error", n), r.unref(), e.log?.info("dev health server listening", { port: e.port }), t(i(!0));
|
|
3731
3731
|
});
|
|
3732
3732
|
});
|
|
3733
|
-
}, Gl = Yo, $ =
|
|
3733
|
+
}, Gl = Yo, $ = ze({ scope: "voltro:dev" }), Kl = await (async () => {
|
|
3734
3734
|
try {
|
|
3735
|
-
let e = w(
|
|
3735
|
+
let e = T(w(Oe(import.meta.url)), "..", "package.json"), t = await N.readFile(e, "utf8");
|
|
3736
3736
|
return JSON.parse(t).version ?? "0.0.0";
|
|
3737
3737
|
} catch {
|
|
3738
3738
|
return "0.0.0";
|
|
@@ -3760,25 +3760,25 @@ ${a.join("\n\n")}\n`);
|
|
|
3760
3760
|
onStrategyFailed: ({ strategyId: e, reason: t }) => {
|
|
3761
3761
|
$.warn(`auth strategy "${e}" rejected request: ${t}`);
|
|
3762
3762
|
}
|
|
3763
|
-
}), Zl = (e) =>
|
|
3763
|
+
}), Zl = (e) => A.succeed(ei, ei.of(({ headers: t, clientId: n }) => k.promise(async () => wt(n) || e({
|
|
3764
3764
|
headers: t,
|
|
3765
3765
|
clientId: n
|
|
3766
|
-
})))), Ql =
|
|
3767
|
-
if (
|
|
3766
|
+
})))), Ql = A.succeed(ti, ti.of(({ clientId: e }) => k.succeed({ clientId: e }))), $l = (e) => {
|
|
3767
|
+
if (Ae.isCause(e)) return e;
|
|
3768
3768
|
if (typeof e != "object" || !e) return;
|
|
3769
3769
|
for (let t of Object.getOwnPropertySymbols(e)) if (t.description === "effect/Runtime/FiberFailure/Cause") {
|
|
3770
3770
|
let n = e[t];
|
|
3771
|
-
if (
|
|
3771
|
+
if (Ae.isCause(n)) return n;
|
|
3772
3772
|
}
|
|
3773
3773
|
let t = e.cause;
|
|
3774
|
-
return
|
|
3774
|
+
return Ae.isCause(t) ? t : void 0;
|
|
3775
3775
|
}, eu = (e) => {
|
|
3776
3776
|
let t = $l(e);
|
|
3777
3777
|
if (t === void 0) return;
|
|
3778
|
-
let n =
|
|
3779
|
-
if (
|
|
3780
|
-
let r =
|
|
3781
|
-
if (
|
|
3778
|
+
let n = Ae.failureOption(t);
|
|
3779
|
+
if (j.isSome(n)) return n.value;
|
|
3780
|
+
let r = Ae.dieOption(t);
|
|
3781
|
+
if (j.isSome(r)) return r.value;
|
|
3782
3782
|
}, tu = (e) => {
|
|
3783
3783
|
if (e == null) return { message: "unknown error" };
|
|
3784
3784
|
let t = eu(e);
|
|
@@ -3809,10 +3809,10 @@ ${a.join("\n\n")}\n`);
|
|
|
3809
3809
|
".git"
|
|
3810
3810
|
]), vu = async (e) => {
|
|
3811
3811
|
let t = [], n = async (e) => {
|
|
3812
|
-
let r = await
|
|
3812
|
+
let r = await N.readdir(e, { withFileTypes: !0 });
|
|
3813
3813
|
for (let i of r) {
|
|
3814
3814
|
if (_u.has(i.name)) continue;
|
|
3815
|
-
let r =
|
|
3815
|
+
let r = T(e, i.name);
|
|
3816
3816
|
i.isDirectory() ? await n(r) : i.isFile() && (nu.test(i.name) && !ru.test(i.name) || ru.test(i.name) || iu.test(i.name) || au.test(i.name) || ou.test(i.name) || hu.test(i.name) || gu.test(i.name) || su.test(i.name) || cu.test(i.name) || lu.test(i.name) || uu.test(i.name) || Nc.test(i.name) || io.test(i.name) || Z.test(i.name) || du.test(i.name) || fu.test(i.name) || pu.test(i.name) || mu.test(i.name)) && t.push(r);
|
|
3817
3817
|
}
|
|
3818
3818
|
};
|
|
@@ -3896,26 +3896,26 @@ ${a.join("\n\n")}\n`);
|
|
|
3896
3896
|
}, Iu = async (e, t) => {
|
|
3897
3897
|
let n = [], r = [], i = [], a = [], o = [], s = [], c = [], l = [], u = /* @__PURE__ */ new Set(), d = /* @__PURE__ */ new Set(), f = /* @__PURE__ */ new Map(), p = [], m = /* @__PURE__ */ new Map();
|
|
3898
3898
|
for (let t of e) {
|
|
3899
|
-
let e =
|
|
3899
|
+
let e = C(t);
|
|
3900
3900
|
if (hu.test(e)) {
|
|
3901
|
-
let e = await
|
|
3901
|
+
let e = await x(t);
|
|
3902
3902
|
for (let t of Object.values(e)) Ou(t) && (f.set(t.tableName, t), ju(t) && u.add(t.tableName), Nu(t) && d.add(t.tableName));
|
|
3903
3903
|
Gr(e);
|
|
3904
3904
|
continue;
|
|
3905
3905
|
}
|
|
3906
3906
|
if (gu.test(e)) {
|
|
3907
|
-
Gr(await
|
|
3907
|
+
Gr(await x(t)) === 0 && $.warn("skipping relations file — no relations(...) export found", { file: t });
|
|
3908
3908
|
continue;
|
|
3909
3909
|
}
|
|
3910
3910
|
if (iu.test(e)) {
|
|
3911
|
-
let e = await
|
|
3911
|
+
let e = await x(t), n = Object.values(e).find(wu);
|
|
3912
3912
|
if (!n) {
|
|
3913
3913
|
$.warn("skipping workflow — no workflow(...) export", { file: t });
|
|
3914
3914
|
continue;
|
|
3915
3915
|
}
|
|
3916
3916
|
let r = t.replace(/\.workflow\.tsx$/, ".workflow.server.tsx"), i;
|
|
3917
3917
|
try {
|
|
3918
|
-
i = await
|
|
3918
|
+
i = await x(r);
|
|
3919
3919
|
} catch {
|
|
3920
3920
|
$.warn("skipping workflow — missing paired executor", {
|
|
3921
3921
|
file: t,
|
|
@@ -3937,7 +3937,7 @@ ${a.join("\n\n")}\n`);
|
|
|
3937
3937
|
continue;
|
|
3938
3938
|
}
|
|
3939
3939
|
if (ou.test(e)) {
|
|
3940
|
-
let n = await
|
|
3940
|
+
let n = await x(t), r = n.default ?? Object.values(n).find(Ot);
|
|
3941
3941
|
if (!Ot(r)) {
|
|
3942
3942
|
$.warn("skipping trigger — default export is not triggerWorkflow(...)", { file: t });
|
|
3943
3943
|
continue;
|
|
@@ -3954,7 +3954,7 @@ ${a.join("\n\n")}\n`);
|
|
|
3954
3954
|
continue;
|
|
3955
3955
|
}
|
|
3956
3956
|
if (lu.test(e)) {
|
|
3957
|
-
let e = (await
|
|
3957
|
+
let e = (await x(t)).default;
|
|
3958
3958
|
if (!Dt(e)) {
|
|
3959
3959
|
$.warn("skipping cron — default export is not defineSchedule(...)", { file: t });
|
|
3960
3960
|
continue;
|
|
@@ -3980,7 +3980,7 @@ ${a.join("\n\n")}\n`);
|
|
|
3980
3980
|
}
|
|
3981
3981
|
}
|
|
3982
3982
|
for (let e of p) {
|
|
3983
|
-
let t = await
|
|
3983
|
+
let t = await x(e), o = Object.values(t).find(yu) ?? Object.values(t).find(bu) ?? Object.values(t).find(xu) ?? Object.values(t).find(Su);
|
|
3984
3984
|
if (!o) {
|
|
3985
3985
|
$.warn("skipping procedure descriptor — no defineQuery / defineMutation / defineAction / defineStream export", { file: e });
|
|
3986
3986
|
continue;
|
|
@@ -3993,7 +3993,7 @@ ${a.join("\n\n")}\n`);
|
|
|
3993
3993
|
});
|
|
3994
3994
|
continue;
|
|
3995
3995
|
}
|
|
3996
|
-
let c = (await
|
|
3996
|
+
let c = (await x(s)).default;
|
|
3997
3997
|
if (typeof c != "function") {
|
|
3998
3998
|
$.warn("skipping procedure server executor — missing default export", { file: s });
|
|
3999
3999
|
continue;
|
|
@@ -4022,12 +4022,12 @@ ${a.join("\n\n")}\n`);
|
|
|
4022
4022
|
...h === void 0 ? {} : { actors: () => h },
|
|
4023
4023
|
...g === void 0 ? {} : { tenants: () => g }
|
|
4024
4024
|
});
|
|
4025
|
-
let _ = e.filter((e) => lo.test(
|
|
4025
|
+
let _ = e.filter((e) => lo.test(C(e))), ee = _.length > 0 ? await fo(_, $.child("connections")) : [], te = {
|
|
4026
4026
|
workflows: o.length > 0 || c.length > 0,
|
|
4027
4027
|
schedules: l.length > 0,
|
|
4028
|
-
webhooks: e.some((e) => uu.test(
|
|
4029
|
-
agents: e.some((e) => io.test(
|
|
4030
|
-
outbox: e.some((e) => fu.test(
|
|
4028
|
+
webhooks: e.some((e) => uu.test(C(e))),
|
|
4029
|
+
agents: e.some((e) => io.test(C(e))),
|
|
4030
|
+
outbox: e.some((e) => fu.test(C(e))),
|
|
4031
4031
|
connections: _.length > 0
|
|
4032
4032
|
};
|
|
4033
4033
|
return qr(), {
|
|
@@ -4046,9 +4046,9 @@ ${a.join("\n\n")}\n`);
|
|
|
4046
4046
|
softDeleteScopedTables: d
|
|
4047
4047
|
};
|
|
4048
4048
|
}, Lu = async (e) => {
|
|
4049
|
-
let t =
|
|
4049
|
+
let t = T(e, "app.config.ts");
|
|
4050
4050
|
try {
|
|
4051
|
-
let e = (await
|
|
4051
|
+
let e = (await x(t)).default;
|
|
4052
4052
|
return typeof e == "object" && e ? e : null;
|
|
4053
4053
|
} catch {
|
|
4054
4054
|
return null;
|
|
@@ -4152,14 +4152,14 @@ ${a.join("\n\n")}\n`);
|
|
|
4152
4152
|
changeStrategy: r ? "cdc" : "inline",
|
|
4153
4153
|
...u ? { cdcConfig: u } : {}
|
|
4154
4154
|
}), f = Hu();
|
|
4155
|
-
if (f.length === 0) return $.info("read replicas: none configured (DB_REPLICA_URLS unset) — all queries → primary"),
|
|
4155
|
+
if (f.length === 0) return $.info("read replicas: none configured (DB_REPLICA_URLS unset) — all queries → primary"), S.recordReplication({
|
|
4156
4156
|
replicaCount: 0,
|
|
4157
4157
|
rywPolicy: "off",
|
|
4158
4158
|
rywStore: "memory",
|
|
4159
4159
|
region: null,
|
|
4160
4160
|
localityEnabled: !1
|
|
4161
4161
|
}), d;
|
|
4162
|
-
if (Vr(i.id)) return $.warn(`read replicas: not applicable (${i.id} is single-process); ignoring DB_REPLICA_URLS`),
|
|
4162
|
+
if (Vr(i.id)) return $.warn(`read replicas: not applicable (${i.id} is single-process); ignoring DB_REPLICA_URLS`), S.recordReplication({
|
|
4163
4163
|
replicaCount: 0,
|
|
4164
4164
|
rywPolicy: "off",
|
|
4165
4165
|
rywStore: "memory",
|
|
@@ -4167,7 +4167,7 @@ ${a.join("\n\n")}\n`);
|
|
|
4167
4167
|
localityEnabled: !1
|
|
4168
4168
|
}), d;
|
|
4169
4169
|
let p = await Xu(i.id);
|
|
4170
|
-
if (p === null) return $.warn(`read replicas: no replication adapter for dialect ${i.id}; falling back to primary-only routing`),
|
|
4170
|
+
if (p === null) return $.warn(`read replicas: no replication adapter for dialect ${i.id}; falling back to primary-only routing`), S.recordReplication({
|
|
4171
4171
|
replicaCount: 0,
|
|
4172
4172
|
rywPolicy: "off",
|
|
4173
4173
|
rywStore: "memory",
|
|
@@ -4203,7 +4203,7 @@ ${a.join("\n\n")}\n`);
|
|
|
4203
4203
|
replicaRegions: Yu(m, te),
|
|
4204
4204
|
inner: pn()
|
|
4205
4205
|
}) : pn();
|
|
4206
|
-
return $.info(`read replicas: ${m.length} configured, ryw policy '${h}', dialect=${i.id}, region=${ne ?? "unknown"}` + (te.length > 0 ? ", replica-locality=on" : "")),
|
|
4206
|
+
return $.info(`read replicas: ${m.length} configured, ryw policy '${h}', dialect=${i.id}, region=${ne ?? "unknown"}` + (te.length > 0 ? ", replica-locality=on" : "")), S.recordReplication({
|
|
4207
4207
|
replicaCount: m.length,
|
|
4208
4208
|
rywPolicy: h,
|
|
4209
4209
|
rywStore: ee,
|
|
@@ -4252,40 +4252,40 @@ ${a.join("\n\n")}\n`);
|
|
|
4252
4252
|
default: return null;
|
|
4253
4253
|
}
|
|
4254
4254
|
}, Zu = async (e) => {
|
|
4255
|
-
let
|
|
4256
|
-
return
|
|
4257
|
-
}, Qu = async (
|
|
4258
|
-
let
|
|
4259
|
-
await
|
|
4260
|
-
id:
|
|
4261
|
-
name:
|
|
4255
|
+
let n = D(e.find((e) => !e.startsWith("-")) ?? process.cwd()), r = await y(n);
|
|
4256
|
+
return r.ran ? r.exitCode : process.env.FRAMEWORK_DEV_INNER !== "1" && process.env.WATCH !== "0" ? (t(cs({ root: n }), { scope: "voltro:dev" }), new Promise(() => {})) : Qu(n);
|
|
4257
|
+
}, Qu = async (t) => {
|
|
4258
|
+
let y = Date.now(), ge = await Lu(t), x = Number(process.env.PORT ?? ge?.port ?? 4e3), w = ge?.name ?? C(t), D = r("api", w, x), Oe = Se(w);
|
|
4259
|
+
await de({
|
|
4260
|
+
id: D,
|
|
4261
|
+
name: w,
|
|
4262
4262
|
kind: "api",
|
|
4263
|
-
url: `http://localhost:${
|
|
4263
|
+
url: `http://localhost:${x}`,
|
|
4264
4264
|
pid: process.pid,
|
|
4265
4265
|
status: "booting",
|
|
4266
|
-
logFile:
|
|
4266
|
+
logFile: Oe.path
|
|
4267
4267
|
}).catch(() => {});
|
|
4268
|
-
let
|
|
4269
|
-
|
|
4270
|
-
root:
|
|
4268
|
+
let O = a();
|
|
4269
|
+
o(O), $.info("booting voltro dev", {
|
|
4270
|
+
root: t,
|
|
4271
4271
|
version: Kl,
|
|
4272
|
-
logFile:
|
|
4272
|
+
logFile: Oe.path
|
|
4273
4273
|
});
|
|
4274
|
-
let
|
|
4275
|
-
project:
|
|
4274
|
+
let ke = await De({
|
|
4275
|
+
project: C(t),
|
|
4276
4276
|
cliVersion: Kl
|
|
4277
4277
|
});
|
|
4278
|
-
if (
|
|
4279
|
-
${
|
|
4280
|
-
|
|
4281
|
-
let
|
|
4282
|
-
|
|
4283
|
-
port:
|
|
4278
|
+
if (ke.kind === "not-personal") return $.error(`voltro dev needs a personal login — the stored credential belongs to no user.
|
|
4279
|
+
${ke.message}`), 1;
|
|
4280
|
+
ke.kind === "reported" && ke.seat === "claimed" && $.info("cloud: this machine now counts toward your organisation's seats (voltro cloud whoami)");
|
|
4281
|
+
let je = process.env.VOLTRO_DEV_HEALTH_PORT, Me = je === void 0 ? x + 1 : Number(je), Ne;
|
|
4282
|
+
Me > 0 && Number.isFinite(Me) && (Ne = await Wl({
|
|
4283
|
+
port: Me,
|
|
4284
4284
|
log: {
|
|
4285
4285
|
info: (e, t) => $.debug(e, t),
|
|
4286
4286
|
warn: (e, t) => $.warn(e, t)
|
|
4287
4287
|
}
|
|
4288
|
-
})),
|
|
4288
|
+
})), n(t).then((e) => {
|
|
4289
4289
|
for (let t of e.files) if (t.action === "created") {
|
|
4290
4290
|
let e = t.path.split("/").slice(-2).join("/");
|
|
4291
4291
|
$.info(`${e} seeded`, { path: t.path });
|
|
@@ -4293,34 +4293,34 @@ ${a.join("\n\n")}\n`);
|
|
|
4293
4293
|
}).catch((e) => {
|
|
4294
4294
|
$.warn("agent-instructions seed failed (non-fatal)", {}, e);
|
|
4295
4295
|
});
|
|
4296
|
-
let
|
|
4297
|
-
$.info(`discovered ${
|
|
4298
|
-
let { pluginContributions:
|
|
4299
|
-
root:
|
|
4300
|
-
...
|
|
4301
|
-
...
|
|
4302
|
-
...
|
|
4303
|
-
...
|
|
4296
|
+
let j = await vu(t);
|
|
4297
|
+
$.info(`discovered ${j.length} files`, { count: j.length });
|
|
4298
|
+
let { pluginContributions: Ie, pluginErrorImports: Le, pluginRpcImports: Re } = await wl(ge?.plugins ?? [], ge?.name ?? C(t), t), ze = await Pa({
|
|
4299
|
+
root: t,
|
|
4300
|
+
...Ie.length > 0 ? { pluginContributions: Ie } : {},
|
|
4301
|
+
...Le.length > 0 ? { pluginErrorImports: Le } : {},
|
|
4302
|
+
...Re.length > 0 ? { pluginRpcImports: Re } : {},
|
|
4303
|
+
...ge?.name === void 0 ? {} : { apiName: ge.name }
|
|
4304
4304
|
});
|
|
4305
|
-
|
|
4306
|
-
let
|
|
4305
|
+
ze ? ($.info("codegen wrote rpcGroup", { path: E(t, ze) }), await _a(ze)) : $.debug("codegen skipped — no descriptors discovered");
|
|
4306
|
+
let He = Wu(ge ?? null), M = He === "mariadb" ? "mariadb" : He === "mssql" ? "mssql" : void 0, Ue = M !== void 0 && (process.env.CDC ?? "1") !== "0", { queries: P, mutations: F, actions: I, streams: We, workflows: L, workflowWorkers: Ke, eventTriggers: Je, schedules: Ye, connections: Xe, tables: Ze, featureMix: Qe, tenantScopedTables: $e, softDeleteScopedTables: et } = await Iu(j, { cdc: Ue }), tt = L.length > 0 || Je.length > 0, R = await Lu(t);
|
|
4307
4307
|
Dn(xn(R?.secrets));
|
|
4308
|
-
let nt = Wo(Ln(R?.env) ? R.env : void 0,
|
|
4309
|
-
nt.minted.length > 0 && nt.file !== void 0 && ($.warn(`minted ${nt.minted.length} project secret(s) into ${
|
|
4308
|
+
let nt = Wo(Ln(R?.env) ? R.env : void 0, t);
|
|
4309
|
+
nt.minted.length > 0 && nt.file !== void 0 && ($.warn(`minted ${nt.minted.length} project secret(s) into ${E(t, nt.file)} — unique to this project, gitignored. Your DEPLOYMENT needs its own values (\`voltro secret generate\`).`, {
|
|
4310
4310
|
keys: nt.minted,
|
|
4311
|
-
file:
|
|
4312
|
-
}),
|
|
4311
|
+
file: E(t, nt.file)
|
|
4312
|
+
}), l.includes(nt.file) || l.unshift(nt.file)), await m({
|
|
4313
4313
|
rawEnv: R?.env,
|
|
4314
4314
|
appType: "api",
|
|
4315
|
-
root:
|
|
4315
|
+
root: t,
|
|
4316
4316
|
log: $,
|
|
4317
4317
|
generateTypes: !0
|
|
4318
4318
|
});
|
|
4319
4319
|
let rt = R?.apiKeys, it = (typeof rt == "object" ? rt.prefix : void 0) ?? "voltro_", ct, lt = rt ? [Ct({ resolveByHash: (e, t) => ct ? ct.resolveByHash(e, t) : Promise.resolve(null) }, { prefix: it })] : [], vt = Xl([...R?.auth?.strategies ?? [], ...lt], Gi(R?.plugins ?? []), R?.auth?.anonymousTenantRequired ?? !1), xt = Zl(vt), St = zo({
|
|
4320
4320
|
mix: Qe,
|
|
4321
4321
|
plugins: R?.plugins ?? [],
|
|
4322
|
-
cdc:
|
|
4323
|
-
...
|
|
4322
|
+
cdc: Ue,
|
|
4323
|
+
...M ? { cdcDialect: M } : {}
|
|
4324
4324
|
}), wt = R?.analytics?.tables ?? [], z = (() => {
|
|
4325
4325
|
let e = new Set(Ze.map((e) => e.tableName)), t = [...Ze];
|
|
4326
4326
|
for (let n of [...St, ...wt]) {
|
|
@@ -4332,7 +4332,7 @@ ${a.join("\n\n")}\n`);
|
|
|
4332
4332
|
for (let e of z) Rr(e);
|
|
4333
4333
|
let Dt = Zc({
|
|
4334
4334
|
plugins: R?.plugins ?? [],
|
|
4335
|
-
appName: R?.name ??
|
|
4335
|
+
appName: R?.name ?? C(t),
|
|
4336
4336
|
appType: "api",
|
|
4337
4337
|
voltroVersion: process.env.npm_package_version ?? "0.0.0",
|
|
4338
4338
|
log: $
|
|
@@ -4353,20 +4353,20 @@ ${a.join("\n\n")}\n`);
|
|
|
4353
4353
|
let zt = Ja(R?.plugins ?? []);
|
|
4354
4354
|
if (zt.length > 0) {
|
|
4355
4355
|
Ya(zt, [
|
|
4356
|
-
...N.map((e) => e.descriptor.name),
|
|
4357
4356
|
...P.map((e) => e.descriptor.name),
|
|
4358
4357
|
...F.map((e) => e.descriptor.name),
|
|
4359
|
-
...I.map((e) => e.descriptor.name)
|
|
4358
|
+
...I.map((e) => e.descriptor.name),
|
|
4359
|
+
...We.map((e) => e.descriptor.name)
|
|
4360
4360
|
]);
|
|
4361
|
-
for (let e of zt) e.kind === "query" ?
|
|
4361
|
+
for (let e of zt) e.kind === "query" ? P.push({
|
|
4362
4362
|
file: e.file,
|
|
4363
4363
|
descriptor: e.descriptor,
|
|
4364
4364
|
executor: e.executor
|
|
4365
|
-
}) : e.kind === "mutation" ?
|
|
4365
|
+
}) : e.kind === "mutation" ? F.push({
|
|
4366
4366
|
file: e.file,
|
|
4367
4367
|
descriptor: e.descriptor,
|
|
4368
4368
|
executor: e.executor
|
|
4369
|
-
}) :
|
|
4369
|
+
}) : I.push({
|
|
4370
4370
|
file: e.file,
|
|
4371
4371
|
descriptor: e.descriptor,
|
|
4372
4372
|
executor: e.executor
|
|
@@ -4376,20 +4376,20 @@ ${a.join("\n\n")}\n`);
|
|
|
4376
4376
|
routes: zt.map((e) => `${e.plugin.name}:${e.descriptor.name} (${e.kind})`)
|
|
4377
4377
|
});
|
|
4378
4378
|
}
|
|
4379
|
-
let Bt = $.child("agent"), Ut =
|
|
4379
|
+
let Bt = $.child("agent"), Ut = j.filter((e) => ao.test(C(e)));
|
|
4380
4380
|
if (Ut.length > 0) {
|
|
4381
4381
|
let e = await oo(Ut, Bt);
|
|
4382
4382
|
e > 0 && Bt.info("wired tool handlers", { tools: e });
|
|
4383
4383
|
}
|
|
4384
|
-
let Gt =
|
|
4384
|
+
let Gt = j.filter((e) => io.test(C(e))), qt = [];
|
|
4385
4385
|
if (Gt.length > 0) {
|
|
4386
4386
|
let e = await co(Gt, Bt);
|
|
4387
4387
|
qt = e.agents.map((e) => e.descriptor.name);
|
|
4388
|
-
for (let t of e.agents) for (let e of Ic(t)) e.kind === "action" ?
|
|
4388
|
+
for (let t of e.agents) for (let e of Ic(t)) e.kind === "action" ? I.push({
|
|
4389
4389
|
file: e.file,
|
|
4390
4390
|
descriptor: e.descriptor,
|
|
4391
4391
|
executor: e.executor
|
|
4392
|
-
}) :
|
|
4392
|
+
}) : P.push({
|
|
4393
4393
|
file: e.file,
|
|
4394
4394
|
descriptor: e.descriptor,
|
|
4395
4395
|
executor: e.executor
|
|
@@ -4400,26 +4400,26 @@ ${a.join("\n\n")}\n`);
|
|
|
4400
4400
|
});
|
|
4401
4401
|
}
|
|
4402
4402
|
let Yt = Rc();
|
|
4403
|
-
(Yt.queries.length > 0 || Yt.mutations.length > 0) && (
|
|
4403
|
+
(Yt.queries.length > 0 || Yt.mutations.length > 0) && (P.push(...Yt.queries), F.push(...Yt.mutations), $.info("undo built-ins registered", { routes: [
|
|
4404
4404
|
"__voltro.undo.log",
|
|
4405
4405
|
"__voltro.undo.apply",
|
|
4406
4406
|
"__voltro.undo.redo"
|
|
4407
4407
|
] }));
|
|
4408
|
-
let Xt = $.child("aggregate"), en =
|
|
4408
|
+
let Xt = $.child("aggregate"), en = j.filter((e) => mu.test(e)), tn = en.length > 0 ? await nc(en, Xt) : [], nn = tn.map((e) => e.definition.name);
|
|
4409
4409
|
for (let e of Lr()) $.warn(`identifier length · ${e}`);
|
|
4410
|
-
let sn = R?.restRoutes ?? [], ln =
|
|
4410
|
+
let sn = R?.restRoutes ?? [], ln = j.filter((e) => du.test(e)).length, un = j.filter((e) => cu.test(e)).length, dn = j.filter((e) => /\.seed\.ts$/.test(e)).length, fn = j.filter((e) => uu.test(e)).length, pn = j.filter((e) => Nc.test(e)).length;
|
|
4411
4411
|
us(ls([
|
|
4412
|
-
N,
|
|
4413
4412
|
P,
|
|
4414
4413
|
F,
|
|
4415
|
-
I
|
|
4414
|
+
I,
|
|
4415
|
+
We
|
|
4416
4416
|
]), (e) => {
|
|
4417
4417
|
$.warn(e);
|
|
4418
4418
|
}), $.info("app surface", {
|
|
4419
|
-
queryCount:
|
|
4420
|
-
mutationCount:
|
|
4421
|
-
actionCount:
|
|
4422
|
-
streamCount:
|
|
4419
|
+
queryCount: P.length,
|
|
4420
|
+
mutationCount: F.length,
|
|
4421
|
+
actionCount: I.length,
|
|
4422
|
+
streamCount: We.length,
|
|
4423
4423
|
restRouteCount: sn.length,
|
|
4424
4424
|
workflowCount: L.length,
|
|
4425
4425
|
workflowWorkerCount: Ke.length,
|
|
@@ -4433,12 +4433,12 @@ ${a.join("\n\n")}\n`);
|
|
|
4433
4433
|
webhookCount: fn,
|
|
4434
4434
|
emailCount: pn,
|
|
4435
4435
|
tenantTables: [...$e]
|
|
4436
|
-
}),
|
|
4437
|
-
appName: R?.name ??
|
|
4438
|
-
queries:
|
|
4439
|
-
mutations:
|
|
4440
|
-
actions:
|
|
4441
|
-
streams:
|
|
4436
|
+
}), Be({
|
|
4437
|
+
appName: R?.name ?? C(t),
|
|
4438
|
+
queries: P.map((e) => e.descriptor.name),
|
|
4439
|
+
mutations: F.map((e) => e.descriptor.name),
|
|
4440
|
+
actions: I.map((e) => e.descriptor.name),
|
|
4441
|
+
streams: We.map((e) => e.descriptor.name),
|
|
4442
4442
|
restRoutes: sn.map((e) => `${e.method} ${e.path}`),
|
|
4443
4443
|
workflows: L.map((e) => e.definition.name),
|
|
4444
4444
|
triggers: Je.map((e) => `${e.event}→${e.workflow}`),
|
|
@@ -4459,7 +4459,7 @@ ${a.join("\n\n")}\n`);
|
|
|
4459
4459
|
let t = e.attributes, n = String(t["url.path"] ?? t["http.route"] ?? t["http.target"] ?? "");
|
|
4460
4460
|
return n.startsWith("/_voltro/") || n === "/ws" || n.startsWith("/ws/") || n.startsWith("/ws?");
|
|
4461
4461
|
}, wn = (e) => {
|
|
4462
|
-
Sn(e) || mo(e) || e.name.startsWith("RpcServer.") || (gn.append(e), (vn || e.status === "error") &&
|
|
4462
|
+
Sn(e) || mo(e) || e.name.startsWith("RpcServer.") || (gn.append(e), (vn || e.status === "error") && O.emit("trace", e), bn(e));
|
|
4463
4463
|
}, Tn = _n ? void 0 : Lt(wn), En = await ht({
|
|
4464
4464
|
serviceName: process.env.OTEL_SERVICE_NAME ?? R?.name ?? "voltro-api",
|
|
4465
4465
|
...Tn ? { traceSink: Tn } : {},
|
|
@@ -4474,14 +4474,14 @@ ${a.join("\n\n")}\n`);
|
|
|
4474
4474
|
let Pn = Bs({
|
|
4475
4475
|
definitions: Xe.map((e) => e.definition),
|
|
4476
4476
|
store: B,
|
|
4477
|
-
publicUrl: Hs(
|
|
4477
|
+
publicUrl: Hs(x),
|
|
4478
4478
|
log: $.child("connections")
|
|
4479
4479
|
});
|
|
4480
|
-
|
|
4480
|
+
P.push(...Pn.queries), F.push(...Pn.mutations), I.push(...Pn.actions);
|
|
4481
4481
|
let Fn = Wu(R), Rn = process.env.POD_NAME ?? process.env.HOSTNAME ?? `dev-${process.pid}`, zn, Bn;
|
|
4482
4482
|
if (Fn !== "memory") {
|
|
4483
4483
|
let e = await Va(Fn);
|
|
4484
|
-
zn =
|
|
4484
|
+
zn = Fe.make(e.makeSqlLayer(Ru())), Bn = await zn.runPromise(V.SqlClient);
|
|
4485
4485
|
}
|
|
4486
4486
|
let Vn = Vt({
|
|
4487
4487
|
coordinator: [
|
|
@@ -4525,33 +4525,33 @@ ${a.join("\n\n")}\n`);
|
|
|
4525
4525
|
});
|
|
4526
4526
|
let lr = or.dispose, ur = Wu(R), mr;
|
|
4527
4527
|
if (ur !== "memory" && process.env.VOLTRO_AUTO_MIGRATE !== "0") {
|
|
4528
|
-
let e = Date.now(),
|
|
4528
|
+
let e = Date.now(), n = (process.env.NODE_ENV ?? "").toLowerCase() === "production" ? "prod" : (process.env.NODE_ENV ?? "").toLowerCase() === "staging" ? "staging" : "dev";
|
|
4529
4529
|
$.info("auto-migrate: planning schema", {
|
|
4530
4530
|
dialect: ur,
|
|
4531
|
-
env:
|
|
4531
|
+
env: n,
|
|
4532
4532
|
tables: z.length
|
|
4533
|
-
}),
|
|
4533
|
+
}), Ne?.set({
|
|
4534
4534
|
phase: "migrating",
|
|
4535
4535
|
tablesTotal: z.length
|
|
4536
4536
|
});
|
|
4537
4537
|
try {
|
|
4538
4538
|
let r = await Va(ur), i = r.makeSqlLayer(Ru());
|
|
4539
4539
|
mr = i, await zi(ku(z.filter((e) => e.tableName.startsWith("_voltro_") || e.tableName === "voltro_isr_cache"), z), i, r.id);
|
|
4540
|
-
let a = await
|
|
4541
|
-
projectRoot:
|
|
4542
|
-
env:
|
|
4543
|
-
appliedBy: `boot:${
|
|
4544
|
-
})),
|
|
4540
|
+
let a = await k.runPromise(V.SqlClient.pipe(k.flatMap((e) => Ri(e, {
|
|
4541
|
+
projectRoot: t,
|
|
4542
|
+
env: n,
|
|
4543
|
+
appliedBy: `boot:${n}`
|
|
4544
|
+
})), k.provide(i)));
|
|
4545
4545
|
a.applied.length > 0 && $.info(`file-based migrations: applied ${a.applied.length}`, { applied: a.applied.map((e) => `${e.id} (${e.durationMs}ms)`) });
|
|
4546
|
-
let o = await
|
|
4547
|
-
appliedBy: `boot:${
|
|
4548
|
-
environment:
|
|
4546
|
+
let o = await k.runPromise(V.SqlClient.pipe(k.flatMap((e) => Bi(e, z, {
|
|
4547
|
+
appliedBy: `boot:${n}`,
|
|
4548
|
+
environment: n,
|
|
4549
4549
|
dialectId: r.id
|
|
4550
|
-
})),
|
|
4550
|
+
})), k.provide(i)));
|
|
4551
4551
|
if (o.kind === "refused-blocked" || o.kind === "prod-mismatch") throw $.error(Pi(o, r.id)), Error("auto-migrate refused — see error above");
|
|
4552
4552
|
$.info(Pi(o, r.id), { durationMs: Date.now() - e });
|
|
4553
4553
|
} catch (e) {
|
|
4554
|
-
throw $.error("auto-migrate failed — aborting boot", { err: e }),
|
|
4554
|
+
throw $.error("auto-migrate failed — aborting boot", { err: e }), Ne?.set({
|
|
4555
4555
|
phase: "error",
|
|
4556
4556
|
error: e instanceof Error ? e.message : String(e)
|
|
4557
4557
|
}), e;
|
|
@@ -4561,7 +4561,7 @@ ${a.join("\n\n")}\n`);
|
|
|
4561
4561
|
if ((R?.plugins ?? []).some((e) => (e.extendSchema?.migrations?.length ?? 0) > 0) && Tr !== "memory") {
|
|
4562
4562
|
let e = (await Va(Tr)).makeSqlLayer(Ru());
|
|
4563
4563
|
try {
|
|
4564
|
-
let t = await
|
|
4564
|
+
let t = await k.runPromise(to(R.plugins).pipe(k.provide(e))), n = t.filter((e) => e.status === "applied"), r = t.filter((e) => e.status === "skipped");
|
|
4565
4565
|
$.info("plugin migrations complete", {
|
|
4566
4566
|
applied: n.map((e) => `${e.pluginName}:${e.migrationId} (${e.durationMs}ms)`),
|
|
4567
4567
|
skippedCount: r.length
|
|
@@ -4570,28 +4570,28 @@ ${a.join("\n\n")}\n`);
|
|
|
4570
4570
|
throw $.error("plugin migrations failed — aborting boot", { err: e }), e;
|
|
4571
4571
|
}
|
|
4572
4572
|
}
|
|
4573
|
-
let Er = Bl(B,
|
|
4573
|
+
let Er = Bl(B, O);
|
|
4574
4574
|
process.on("beforeExit", () => {
|
|
4575
4575
|
Er();
|
|
4576
4576
|
});
|
|
4577
|
-
let Dr = $.child("seeds"), Or =
|
|
4577
|
+
let Dr = $.child("seeds"), Or = j.filter((e) => /\.seed\.ts$/.test(e)), kr = Or.length > 0 ? await ws(Or, Dr) : [];
|
|
4578
4578
|
if (kr.length > 0) {
|
|
4579
4579
|
Dr.info("discovered seeds", { ids: kr.map((e) => e.definition.id) });
|
|
4580
|
-
for (let e of kr)
|
|
4580
|
+
for (let e of kr) S.registerSeed(e);
|
|
4581
4581
|
let e = await ks(kr, B, Dr);
|
|
4582
|
-
for (let t of e)
|
|
4582
|
+
for (let t of e) S.recordSeedResult(t);
|
|
4583
4583
|
let t = e.filter((e) => e.status === "failed");
|
|
4584
4584
|
t.length > 0 && Dr.warn("one or more seeds failed (server continues)", { failedIds: t.map((e) => e.seedId) });
|
|
4585
4585
|
}
|
|
4586
|
-
let Ar = $.child("startup"), jr =
|
|
4587
|
-
Mr.length > 0 && (Ar.info("discovered startups", { ids: Mr.map((e) => e.id) }), Nr = await
|
|
4586
|
+
let Ar = $.child("startup"), jr = j.filter((e) => cu.test(e)), Mr = jr.length > 0 ? await Ee(jr, Ar) : [], Nr;
|
|
4587
|
+
Mr.length > 0 && (Ar.info("discovered startups", { ids: Mr.map((e) => e.id) }), Nr = await Te(Mr, B, Ar)), Nr && process.on("beforeExit", () => {
|
|
4588
4588
|
Nr.shutdown();
|
|
4589
4589
|
});
|
|
4590
|
-
let Pr = $.child("subscribe"), Br =
|
|
4590
|
+
let Pr = $.child("subscribe"), Br = j.filter((e) => du.test(e)), Hr = Br.length > 0 ? await Ns(Br, Pr) : [], Wr;
|
|
4591
4591
|
Hr.length > 0 && (Pr.info("discovered subscribers", { subscribers: Hr.map((e) => `${e.id}@${e.definition.table}`) }), Wr = Ps(Hr, B, Pr)), Wr && process.on("beforeExit", () => {
|
|
4592
4592
|
Wr();
|
|
4593
4593
|
}), Et(), On((e) => At(B, e.subjectId, e.resourceType, e.resourceId));
|
|
4594
|
-
let Gr = $.child("outbox"), Kr =
|
|
4594
|
+
let Gr = $.child("outbox"), Kr = j.filter((e) => fu.test(e)), qr = Kr.length > 0 ? await Is(Kr, Gr) : [], Yr = qr.length > 0 ? Ls({
|
|
4595
4595
|
handlers: qr,
|
|
4596
4596
|
store: B,
|
|
4597
4597
|
log: Gr
|
|
@@ -4725,7 +4725,7 @@ ${a.join("\n\n")}\n`);
|
|
|
4725
4725
|
});
|
|
4726
4726
|
return;
|
|
4727
4727
|
}
|
|
4728
|
-
}, W = L.length > 0 ? Kt(() => pi) : void 0, xi = $.child("webhooks"), Si =
|
|
4728
|
+
}, W = L.length > 0 ? Kt(() => pi) : void 0, xi = $.child("webhooks"), Si = j.filter((e) => uu.test(e)), G = Si.length > 0 ? await Mc(Si, xi) : {
|
|
4729
4729
|
outgoing: [],
|
|
4730
4730
|
incoming: [],
|
|
4731
4731
|
providers: []
|
|
@@ -4735,7 +4735,7 @@ ${a.join("\n\n")}\n`);
|
|
|
4735
4735
|
incoming: G.incoming.map((e) => e.descriptor.id),
|
|
4736
4736
|
providers: G.providers.map((e) => e.descriptor.id)
|
|
4737
4737
|
});
|
|
4738
|
-
let Vi =
|
|
4738
|
+
let Vi = j.filter((e) => Nc.test(e));
|
|
4739
4739
|
if (Vi.length > 0) {
|
|
4740
4740
|
let e = $.child("mail"), t = await Pc(Vi, e);
|
|
4741
4741
|
t.templates.length > 0 && (na(t.templates.map((e) => e.template)), e.info("discovered email templates", { templates: t.templates.map((e) => e.template.name) }));
|
|
@@ -4765,7 +4765,7 @@ ${a.join("\n\n")}\n`);
|
|
|
4765
4765
|
secretEnvKey: n
|
|
4766
4766
|
});
|
|
4767
4767
|
}
|
|
4768
|
-
let Ui = $.child("reaction"), Wi =
|
|
4768
|
+
let Ui = $.child("reaction"), Wi = j.filter((e) => pu.test(e)), Ji = Wi.length > 0 ? await Ws(Wi, Ui) : [], Yi;
|
|
4769
4769
|
Ji.length > 0 && (Ui.info("discovered reactions", { reactions: Ji.map((e) => `${e.definition.name}@${e.definition.watch.table}`) }), Yi = Ks(Ji, B, {
|
|
4770
4770
|
runAct: async (e, t) => {
|
|
4771
4771
|
if (e.kind === "workflow") {
|
|
@@ -4781,7 +4781,7 @@ ${a.join("\n\n")}\n`);
|
|
|
4781
4781
|
return;
|
|
4782
4782
|
}
|
|
4783
4783
|
await Gs(e.agent, t, {
|
|
4784
|
-
findAgentSend: (e) =>
|
|
4784
|
+
findAgentSend: (e) => I.find((t) => t.descriptor.name === `${e}.send`),
|
|
4785
4785
|
runAction: (e, t, n) => Promise.resolve(Ia(e, t, n)),
|
|
4786
4786
|
makeSubject: (e) => oi(e),
|
|
4787
4787
|
now: () => Date.now(),
|
|
@@ -4791,7 +4791,7 @@ ${a.join("\n\n")}\n`);
|
|
|
4791
4791
|
checkBudget: async (e, t) => {
|
|
4792
4792
|
try {
|
|
4793
4793
|
let { requireAiBudget: n } = await import("@voltro/ai");
|
|
4794
|
-
return (await
|
|
4794
|
+
return (await k.runPromise(k.either(n(B, {
|
|
4795
4795
|
tenantId: e,
|
|
4796
4796
|
limitUsd: t
|
|
4797
4797
|
}))))._tag === "Right";
|
|
@@ -4840,7 +4840,7 @@ ${a.join("\n\n")}\n`);
|
|
|
4840
4840
|
...e.usingIndex === void 0 ? {} : { usingIndex: e.usingIndex }
|
|
4841
4841
|
};
|
|
4842
4842
|
});
|
|
4843
|
-
|
|
4843
|
+
O.emit("subscriptions", {
|
|
4844
4844
|
subscriptions: n,
|
|
4845
4845
|
matcherStats: t.perTable,
|
|
4846
4846
|
capturedAt: Date.now()
|
|
@@ -4857,7 +4857,7 @@ ${a.join("\n\n")}\n`);
|
|
|
4857
4857
|
op: e.op,
|
|
4858
4858
|
old: e.old ?? null,
|
|
4859
4859
|
new: e.new ?? null
|
|
4860
|
-
}),
|
|
4860
|
+
}), k.runFork(Kn.publish(e.table)), oa.length > 0) {
|
|
4861
4861
|
let t = {
|
|
4862
4862
|
table: e.table,
|
|
4863
4863
|
op: e.op,
|
|
@@ -4868,10 +4868,10 @@ ${a.join("\n\n")}\n`);
|
|
|
4868
4868
|
};
|
|
4869
4869
|
for (let n of oa) {
|
|
4870
4870
|
let r = ia.child(`plugin:${n.name}`);
|
|
4871
|
-
|
|
4871
|
+
k.runFork(n.onChangeEvent(t).pipe(k.catchAllCause((t) => k.sync(() => r.warn("onChangeEvent failed", {
|
|
4872
4872
|
table: e.table,
|
|
4873
4873
|
op: e.op
|
|
4874
|
-
}, Error(
|
|
4874
|
+
}, Error(Ae.pretty(t)))))));
|
|
4875
4875
|
}
|
|
4876
4876
|
}
|
|
4877
4877
|
});
|
|
@@ -4891,13 +4891,13 @@ ${a.join("\n\n")}\n`);
|
|
|
4891
4891
|
ii(ji),
|
|
4892
4892
|
ii(Mi)
|
|
4893
4893
|
] : [], ua = (R?.plugins ?? []).flatMap((e) => (e.errorSchemas ?? []).map((e) => e.schema)), da = ua.length > 0 ? ua : void 0, fa = [
|
|
4894
|
-
...
|
|
4895
|
-
...
|
|
4896
|
-
...
|
|
4897
|
-
...
|
|
4894
|
+
...P.map((e) => yi(e.descriptor, da)),
|
|
4895
|
+
...F.map((e) => vi(e.descriptor, da)),
|
|
4896
|
+
...I.map((e) => ii(e.descriptor, da)),
|
|
4897
|
+
...We.map((e) => bi(e.descriptor, da)),
|
|
4898
4898
|
...ca,
|
|
4899
4899
|
...la
|
|
4900
|
-
], pa = ir.make(...fa).middleware(ei).middleware(ti), ma = R?.layers ?? [], ha = (R?.plugins ?? []).map((e) => e.services).filter((e) => e !== void 0), ga =
|
|
4900
|
+
], pa = ir.make(...fa).middleware(ei).middleware(ti), ma = R?.layers ?? [], ha = (R?.plugins ?? []).map((e) => e.services).filter((e) => e !== void 0), ga = A.succeed(Ge, $r.registry), va = A.mergeAll(Xo({
|
|
4901
4901
|
analyticsLayer: or.layer,
|
|
4902
4902
|
cacheService: Gn,
|
|
4903
4903
|
kvService: $n,
|
|
@@ -4908,7 +4908,7 @@ ${a.join("\n\n")}\n`);
|
|
|
4908
4908
|
userLayers: ma.length,
|
|
4909
4909
|
pluginLayers: ha.length
|
|
4910
4910
|
});
|
|
4911
|
-
let ya = (e, t) => Cn(e.pipe(
|
|
4911
|
+
let ya = (e, t) => Cn(e.pipe(k.provide(Wt(t)), k.provide(va), k.provide(Gl))), ba = $t(z);
|
|
4912
4912
|
if ((process.env.VOLTRO_INDEX_AUDIT ?? "on") !== "off") {
|
|
4913
4913
|
let e = Ir(z), t = process.stdout.isTTY === !0 && (process.env.NO_COLOR ?? "") === "";
|
|
4914
4914
|
for (let n of e) $.warn("\n" + zr(n, {
|
|
@@ -4939,8 +4939,8 @@ ${a.join("\n\n")}\n`);
|
|
|
4939
4939
|
kv: Qn
|
|
4940
4940
|
}, t = G.outgoing.map((e) => e.descriptor);
|
|
4941
4941
|
q = Zi(e, async (n) => {
|
|
4942
|
-
let r = $i.execute(n).pipe(
|
|
4943
|
-
|
|
4942
|
+
let r = $i.execute(n).pipe(k.provide($i.toLayer(Xi(e, { events: t })).pipe(A.provideMerge(fi))));
|
|
4943
|
+
k.runPromise(r).catch((e) => {
|
|
4944
4944
|
xi.error("deliverWebhook workflow crashed", {
|
|
4945
4945
|
deliveryId: n.deliveryId,
|
|
4946
4946
|
targetId: n.targetId
|
|
@@ -4959,7 +4959,7 @@ ${a.join("\n\n")}\n`);
|
|
|
4959
4959
|
...W === void 0 ? {} : { workflowsProxy: W },
|
|
4960
4960
|
eventTriggers: Je,
|
|
4961
4961
|
namespaceIsolationOn: xa,
|
|
4962
|
-
onEventEmit: (e, t) =>
|
|
4962
|
+
onEventEmit: (e, t) => O.emit(e, t),
|
|
4963
4963
|
...Yr === void 0 ? {} : { outbox: { nudge: Yr.nudge } },
|
|
4964
4964
|
...Pn.active ? { connections: { registry: Pn.registry } } : {}
|
|
4965
4965
|
}), Ca = async () => {
|
|
@@ -4987,7 +4987,7 @@ ${a.join("\n\n")}\n`);
|
|
|
4987
4987
|
warn: (e, t) => $.warn(e, t ?? {}),
|
|
4988
4988
|
debug: (e, t) => $.debug(e, t ?? {})
|
|
4989
4989
|
},
|
|
4990
|
-
onRunEvent: (e, t) =>
|
|
4990
|
+
onRunEvent: (e, t) => O.emit("scheduleRuns", {
|
|
4991
4991
|
op: e,
|
|
4992
4992
|
row: t
|
|
4993
4993
|
}),
|
|
@@ -5022,14 +5022,14 @@ ${a.join("\n\n")}\n`);
|
|
|
5022
5022
|
}, Oa = (e) => JSON.stringify(e, (e, t) => typeof t == "object" && t && !Array.isArray(t) ? Object.fromEntries(Object.entries(t).sort(([e], [t]) => e.localeCompare(t))) : t), Y = (e, t) => {
|
|
5023
5023
|
let n = e.cache;
|
|
5024
5024
|
if (n === void 0) return;
|
|
5025
|
-
let
|
|
5026
|
-
if (
|
|
5027
|
-
ttlMs:
|
|
5028
|
-
swrMs: n.swr === void 0 ? void 0 :
|
|
5025
|
+
let r = d(n.ttl);
|
|
5026
|
+
if (r !== null) return {
|
|
5027
|
+
ttlMs: r,
|
|
5028
|
+
swrMs: n.swr === void 0 ? void 0 : d(n.swr) ?? void 0,
|
|
5029
5029
|
scope: n.scope,
|
|
5030
5030
|
baseKey: `q:${e.name}:${Oa(t)}`
|
|
5031
5031
|
};
|
|
5032
|
-
}, ka =
|
|
5032
|
+
}, ka = ye(), Aa = R?.plugins ?? [], ja = li(el(Aa, "mutation", ka)), Ma = li(el(Aa, "action", ka)), Na = li(el(Aa, "query", ka)), Fa = Jt({
|
|
5033
5033
|
store: B,
|
|
5034
5034
|
buildContext: (e, t, n) => Sa(e, t, n),
|
|
5035
5035
|
runEffect: (e, t) => ya(e, t),
|
|
@@ -5047,23 +5047,23 @@ ${a.join("\n\n")}\n`);
|
|
|
5047
5047
|
let n = wa(e, t);
|
|
5048
5048
|
return Ea(n), n;
|
|
5049
5049
|
},
|
|
5050
|
-
provideEffect: (e, t) => e.pipe(
|
|
5050
|
+
provideEffect: (e, t) => e.pipe(k.provide(Wt(t)), k.provide(Gl)),
|
|
5051
5051
|
...Na ? { interceptor: Na } : {}
|
|
5052
5052
|
});
|
|
5053
|
-
for (let e of
|
|
5054
|
-
for (let e of
|
|
5053
|
+
for (let e of P) J[e.descriptor.name] = (t) => mt(La(e, t), K, `subscription.${e.descriptor.name}`, Da, Y(e.descriptor, t), Qt(e, t));
|
|
5054
|
+
for (let e of F) {
|
|
5055
5055
|
let t = `mutation.${e.descriptor.name}`;
|
|
5056
5056
|
J[e.descriptor.name] = (n) => ft(async (t, n) => Fa(e, t, n), n, t);
|
|
5057
5057
|
}
|
|
5058
|
-
for (let e of
|
|
5058
|
+
for (let e of I) {
|
|
5059
5059
|
let t = `action.${e.descriptor.name}`;
|
|
5060
5060
|
J[e.descriptor.name] = (n) => ft(async (t, n) => Ia(e, t, n), n, t);
|
|
5061
5061
|
}
|
|
5062
|
-
for (let e of
|
|
5062
|
+
for (let e of We) {
|
|
5063
5063
|
let t = `stream.${e.descriptor.name}`;
|
|
5064
5064
|
J[e.descriptor.name] = (n) => pt((t) => {
|
|
5065
5065
|
let r = Sa(t), i = e.executor(n, r);
|
|
5066
|
-
return
|
|
5066
|
+
return k.isEffect(i) ? i.pipe(k.provide(Wt(r.store)), k.provide(va), k.provide(Gl)) : typeof i == "object" && i && typeof i.then == "function" ? k.promise(() => i) : i;
|
|
5067
5067
|
}, t);
|
|
5068
5068
|
}
|
|
5069
5069
|
tt && (J[Oi.name] = (e) => mt(La({
|
|
@@ -5186,7 +5186,7 @@ ${a.join("\n\n")}\n`);
|
|
|
5186
5186
|
let Ra = oi(ql), za = (e, t) => Sa({
|
|
5187
5187
|
subject: e?.subject ?? Ra,
|
|
5188
5188
|
traceId: e?.traceId ?? "workflow-bootstrap"
|
|
5189
|
-
}, B, void 0, `workflow:${t.workflowName}`, { parentExecutionId: t.executionId }), Ba = ll(R?.plugins ?? [], ka), Ha = vr, Ua = (e, t) =>
|
|
5189
|
+
}, B, void 0, `workflow:${t.workflowName}`, { parentExecutionId: t.executionId }), Ba = ll(R?.plugins ?? [], ka), Ha = vr, Ua = (e, t) => O.emit(e, t), Wa = R?.dormancy === "sleep" ? {
|
|
5190
5190
|
register: (e, t, n) => yn(B, {
|
|
5191
5191
|
tenantId: n ?? ql,
|
|
5192
5192
|
kind: "workflow",
|
|
@@ -5237,7 +5237,7 @@ ${a.join("\n\n")}\n`);
|
|
|
5237
5237
|
cancelled: !0,
|
|
5238
5238
|
completedAt: /* @__PURE__ */ new Date()
|
|
5239
5239
|
});
|
|
5240
|
-
i &&
|
|
5240
|
+
i && O.emit("workflowRuns", {
|
|
5241
5241
|
op: "update",
|
|
5242
5242
|
row: Ha(i)
|
|
5243
5243
|
});
|
|
@@ -5274,7 +5274,7 @@ ${a.join("\n\n")}\n`);
|
|
|
5274
5274
|
}, Xa = [...on(L, {
|
|
5275
5275
|
buildContext: za,
|
|
5276
5276
|
resolveStartContext: _i
|
|
5277
|
-
}, (e, t, n) => qa(e.definition.name, e.definition, t, n)), ...Ke], Za = Xa.length > 0 ?
|
|
5277
|
+
}, (e, t, n) => qa(e.definition.name, e.definition, t, n)), ...Ke], Za = Xa.length > 0 ? A.mergeAll(...Xa) : A.empty, Qa = Fe.make(Za.pipe(A.provideMerge(fi)));
|
|
5278
5278
|
process.on("beforeExit", () => {
|
|
5279
5279
|
Qa.dispose();
|
|
5280
5280
|
}), pi = L.length > 0 ? rn({
|
|
@@ -5311,7 +5311,7 @@ ${a.join("\n\n")}\n`);
|
|
|
5311
5311
|
runPromise: (e) => Qa.runPromise(e)
|
|
5312
5312
|
}, e, t)
|
|
5313
5313
|
}) : void 0;
|
|
5314
|
-
let $a =
|
|
5314
|
+
let $a = A.mergeAll(pa.toLayer(J), xt, Ql), eo = Qo(J, P.map((e) => e.descriptor.name), tt), ro = A.mergeAll(pa.toLayer(eo), xt, Ql), Z = U, so = (Z === "postgres" || Z === "mysql" || Z === "mariadb" || Z === "mssql") && (process.env.CDC ?? "1") !== "0";
|
|
5315
5315
|
if (Z === "postgres" && Eo()) {
|
|
5316
5316
|
let e = jo({
|
|
5317
5317
|
store: B,
|
|
@@ -5328,7 +5328,7 @@ ${a.join("\n\n")}\n`);
|
|
|
5328
5328
|
});
|
|
5329
5329
|
let uo = (e) => {
|
|
5330
5330
|
try {
|
|
5331
|
-
return
|
|
5331
|
+
return Pe.make(e);
|
|
5332
5332
|
} catch {
|
|
5333
5333
|
return;
|
|
5334
5334
|
}
|
|
@@ -5356,34 +5356,34 @@ ${a.join("\n\n")}\n`);
|
|
|
5356
5356
|
}));
|
|
5357
5357
|
e.length > 0 && (i.targets = e);
|
|
5358
5358
|
}
|
|
5359
|
-
let c =
|
|
5359
|
+
let c = ce(e.guards);
|
|
5360
5360
|
c !== void 0 && (i.guards = c), e.publicApi != null && typeof e.publicApi == "object" && (i.publicApi = e.publicApi);
|
|
5361
5361
|
let l = e.exposeAsTool;
|
|
5362
5362
|
return l === !0 ? i.exposeAsTool = { enabled: !0 } : typeof l == "object" && l && (i.exposeAsTool = l), i;
|
|
5363
5363
|
}, ho = [
|
|
5364
|
-
...
|
|
5365
|
-
...
|
|
5366
|
-
...
|
|
5367
|
-
...
|
|
5364
|
+
...P.map((e) => po(e.descriptor, "query", E(t, e.file))),
|
|
5365
|
+
...F.map((e) => po(e.descriptor, "mutation", E(t, e.file))),
|
|
5366
|
+
...I.map((e) => po(e.descriptor, "action", E(t, e.file))),
|
|
5367
|
+
...We.map((e) => po({
|
|
5368
5368
|
name: e.descriptor.name,
|
|
5369
5369
|
input: e.descriptor.input,
|
|
5370
5370
|
output: e.descriptor.element,
|
|
5371
5371
|
error: e.descriptor.error
|
|
5372
|
-
}, "stream",
|
|
5372
|
+
}, "stream", E(t, e.file)))
|
|
5373
5373
|
], go = L.map((e) => ({
|
|
5374
5374
|
tag: e.definition.name,
|
|
5375
|
-
file:
|
|
5375
|
+
file: E(t, e.file)
|
|
5376
5376
|
}));
|
|
5377
|
-
|
|
5378
|
-
let e =
|
|
5377
|
+
N.writeFile(T(t, "app.manifest.generated.json"), `${JSON.stringify(s(ho, go), null, 2)}\n`, "utf8").catch(() => {}), (async () => {
|
|
5378
|
+
let e = T(t, ".gitignore"), n = "";
|
|
5379
5379
|
try {
|
|
5380
|
-
|
|
5380
|
+
n = await N.readFile(e, "utf8");
|
|
5381
5381
|
} catch {}
|
|
5382
|
-
let r =
|
|
5383
|
-
r.includes("app.manifest.generated.json") || (r.push("app.manifest.generated.json"), await
|
|
5382
|
+
let r = n.split("\n").filter((e) => e.trim() !== "");
|
|
5383
|
+
r.includes("app.manifest.generated.json") || (r.push("app.manifest.generated.json"), await N.writeFile(e, `${r.join("\n")}\n`, "utf8"));
|
|
5384
5384
|
})().catch(() => {});
|
|
5385
5385
|
let _o = /* @__PURE__ */ new Map();
|
|
5386
|
-
for (let e of
|
|
5386
|
+
for (let e of F) _o.set(e.descriptor.name, async (t, n) => {
|
|
5387
5387
|
let r = {
|
|
5388
5388
|
subject: await vt({
|
|
5389
5389
|
headers: n,
|
|
@@ -5407,7 +5407,7 @@ ${a.join("\n\n")}\n`);
|
|
|
5407
5407
|
};
|
|
5408
5408
|
}
|
|
5409
5409
|
});
|
|
5410
|
-
for (let e of
|
|
5410
|
+
for (let e of I) _o.set(e.descriptor.name, async (t, n) => {
|
|
5411
5411
|
let r = {
|
|
5412
5412
|
subject: await vt({
|
|
5413
5413
|
headers: n,
|
|
@@ -5433,14 +5433,14 @@ ${a.join("\n\n")}\n`);
|
|
|
5433
5433
|
});
|
|
5434
5434
|
let vo = () => ({
|
|
5435
5435
|
dialect: U,
|
|
5436
|
-
replication:
|
|
5436
|
+
replication: S.replicationSnapshot() ?? {
|
|
5437
5437
|
replicaCount: 0,
|
|
5438
5438
|
rywPolicy: "off",
|
|
5439
5439
|
rywStore: "memory",
|
|
5440
5440
|
region: null,
|
|
5441
5441
|
localityEnabled: !1
|
|
5442
5442
|
},
|
|
5443
|
-
migrations:
|
|
5443
|
+
migrations: S.migrationsSnapshot().map((e) => ({
|
|
5444
5444
|
id: e.id,
|
|
5445
5445
|
name: e.name,
|
|
5446
5446
|
hash: e.hash,
|
|
@@ -5450,7 +5450,7 @@ ${a.join("\n\n")}\n`);
|
|
|
5450
5450
|
...e.durationMs ? { durationMs: e.durationMs } : {},
|
|
5451
5451
|
...e.lastError ? { lastError: e.lastError } : {}
|
|
5452
5452
|
})),
|
|
5453
|
-
seeds:
|
|
5453
|
+
seeds: S.seedsSnapshot().map((e) => ({
|
|
5454
5454
|
id: e.id,
|
|
5455
5455
|
name: e.name,
|
|
5456
5456
|
lifecycle: e.lifecycle,
|
|
@@ -5475,7 +5475,7 @@ ${a.join("\n\n")}\n`);
|
|
|
5475
5475
|
softDropSnapshots: []
|
|
5476
5476
|
};
|
|
5477
5477
|
if (!mr) return e;
|
|
5478
|
-
let t =
|
|
5478
|
+
let t = k.gen(function* () {
|
|
5479
5479
|
let e = yield* V.SqlClient, t = yield* e`
|
|
5480
5480
|
SELECT ${e("id")}, ${e("fingerprint")},
|
|
5481
5481
|
${e("appliedAt")}::text AS ${e("appliedAt")},
|
|
@@ -5485,7 +5485,7 @@ ${a.join("\n\n")}\n`);
|
|
|
5485
5485
|
FROM ${e("_voltro_migration_plans")}
|
|
5486
5486
|
ORDER BY ${e("appliedAt")} DESC
|
|
5487
5487
|
LIMIT 20
|
|
5488
|
-
`.pipe(
|
|
5488
|
+
`.pipe(k.orElseSucceed(() => [])), n = yield* Ii(e), r = Fi({ tables: n.tables.filter((e) => !e.name.startsWith("_voltro_")) }), i = t[0], a = {
|
|
5489
5489
|
isDrifted: i ? i.fingerprint !== r : !1,
|
|
5490
5490
|
liveFingerprint: r,
|
|
5491
5491
|
liveSnapshot: n
|
|
@@ -5534,16 +5534,16 @@ ${a.join("\n\n")}\n`);
|
|
|
5534
5534
|
};
|
|
5535
5535
|
});
|
|
5536
5536
|
try {
|
|
5537
|
-
return await
|
|
5537
|
+
return await k.runPromise(t.pipe(k.provide(mr)));
|
|
5538
5538
|
} catch (t) {
|
|
5539
5539
|
return $.warn("inspect.migrations: snapshot build failed", { err: String(t) }), e;
|
|
5540
5540
|
}
|
|
5541
5541
|
}, Q = {
|
|
5542
5542
|
kind: "api",
|
|
5543
5543
|
meta: {
|
|
5544
|
-
name: R?.name ??
|
|
5544
|
+
name: R?.name ?? C(t),
|
|
5545
5545
|
voltroVersion: Kl,
|
|
5546
|
-
port:
|
|
5546
|
+
port: x,
|
|
5547
5547
|
mode: "dev",
|
|
5548
5548
|
store: Z,
|
|
5549
5549
|
cdc: so ? "on" : "off"
|
|
@@ -5567,7 +5567,7 @@ ${a.join("\n\n")}\n`);
|
|
|
5567
5567
|
plugins: Dt.snapshot(),
|
|
5568
5568
|
capturedAt: Date.now()
|
|
5569
5569
|
}),
|
|
5570
|
-
env: () =>
|
|
5570
|
+
env: () => re(R?.name ?? C(t), {
|
|
5571
5571
|
contract: Ln(R?.env) ? R.env : void 0,
|
|
5572
5572
|
plugins: R?.plugins ?? []
|
|
5573
5573
|
}),
|
|
@@ -5663,7 +5663,7 @@ ${a.join("\n\n")}\n`);
|
|
|
5663
5663
|
}), { deleted: t };
|
|
5664
5664
|
},
|
|
5665
5665
|
inspectImport: async (e) => {
|
|
5666
|
-
let t = await
|
|
5666
|
+
let t = await k.runPromise(aa({
|
|
5667
5667
|
store: B,
|
|
5668
5668
|
bundleDir: e.bundleDir,
|
|
5669
5669
|
...e.mode ? { mode: e.mode } : {},
|
|
@@ -5749,7 +5749,7 @@ ${a.join("\n\n")}\n`);
|
|
|
5749
5749
|
cancelled: !0,
|
|
5750
5750
|
completedAt: /* @__PURE__ */ new Date()
|
|
5751
5751
|
});
|
|
5752
|
-
r &&
|
|
5752
|
+
r && O.emit("workflowRuns", {
|
|
5753
5753
|
op: "update",
|
|
5754
5754
|
row: Ha(r)
|
|
5755
5755
|
});
|
|
@@ -5930,7 +5930,7 @@ ${a.join("\n\n")}\n`);
|
|
|
5930
5930
|
status: "suspended",
|
|
5931
5931
|
completedAt: /* @__PURE__ */ new Date()
|
|
5932
5932
|
});
|
|
5933
|
-
return r &&
|
|
5933
|
+
return r && O.emit("workflowRuns", {
|
|
5934
5934
|
op: "update",
|
|
5935
5935
|
row: Ha(r)
|
|
5936
5936
|
}), r && await X.recordEvent({
|
|
@@ -5962,7 +5962,7 @@ ${a.join("\n\n")}\n`);
|
|
|
5962
5962
|
status: "running",
|
|
5963
5963
|
completedAt: null
|
|
5964
5964
|
});
|
|
5965
|
-
return r &&
|
|
5965
|
+
return r && O.emit("workflowRuns", {
|
|
5966
5966
|
op: "update",
|
|
5967
5967
|
row: Ha(r)
|
|
5968
5968
|
}), r && await X.recordEvent({
|
|
@@ -6149,7 +6149,7 @@ ${a.join("\n\n")}\n`);
|
|
|
6149
6149
|
},
|
|
6150
6150
|
runSeed: async (e) => {
|
|
6151
6151
|
let t = await As(kr, e, B, Dr);
|
|
6152
|
-
return
|
|
6152
|
+
return S.recordSeedResult(t), vo();
|
|
6153
6153
|
},
|
|
6154
6154
|
rollbackMigration: async (e) => (Dr.warn("rollbackMigration called but only memory store is wired — no-op"), vo()),
|
|
6155
6155
|
webhooks: async () => {
|
|
@@ -6220,13 +6220,13 @@ ${a.join("\n\n")}\n`);
|
|
|
6220
6220
|
} }
|
|
6221
6221
|
}, xo = hl(R?.plugins ?? [], ka);
|
|
6222
6222
|
xo !== void 0 && $.info("plugin http-request interceptor active", { plugins: (R?.plugins ?? []).filter((e) => typeof e.onHttpRequest == "function").map((e) => e.name) });
|
|
6223
|
-
let So = (R?.plugins ?? []).flatMap((e) => e.httpRoutes ?? []), Co = typeof rt == "object" ? rt.managementPath : void 0, wo = () => `public-${Math.random().toString(36).slice(2, 10)}`, To = Ki([...
|
|
6223
|
+
let So = (R?.plugins ?? []).flatMap((e) => e.httpRoutes ?? []), Co = typeof rt == "object" ? rt.managementPath : void 0, wo = () => `public-${Math.random().toString(36).slice(2, 10)}`, To = Ki([...F.filter((e) => e.descriptor.publicApi !== void 0).map((e) => ({
|
|
6224
6224
|
descriptor: e.descriptor,
|
|
6225
6225
|
invoke: (t, n) => Fa(e, t, {
|
|
6226
6226
|
subject: n.subject,
|
|
6227
6227
|
traceId: wo()
|
|
6228
6228
|
})
|
|
6229
|
-
})), ...
|
|
6229
|
+
})), ...I.filter((e) => e.descriptor.publicApi !== void 0).map((e) => ({
|
|
6230
6230
|
descriptor: e.descriptor,
|
|
6231
6231
|
invoke: (t, n) => Ia(e, t, {
|
|
6232
6232
|
subject: n.subject,
|
|
@@ -6262,7 +6262,7 @@ ${a.join("\n\n")}\n`);
|
|
|
6262
6262
|
group: pa,
|
|
6263
6263
|
handlersLayer: $a,
|
|
6264
6264
|
httpHandlersLayer: ro,
|
|
6265
|
-
port:
|
|
6265
|
+
port: x,
|
|
6266
6266
|
path: R?.transport?.wsPath ?? "/ws",
|
|
6267
6267
|
...xo ? { pluginHttpInterceptor: xo } : {},
|
|
6268
6268
|
...Mo.length > 0 ? { httpRoutes: Mo } : {},
|
|
@@ -6274,67 +6274,67 @@ ${a.join("\n\n")}\n`);
|
|
|
6274
6274
|
mounts: jt,
|
|
6275
6275
|
capturedAt: Date.now()
|
|
6276
6276
|
}),
|
|
6277
|
-
headers:
|
|
6277
|
+
headers: b(n.origin)
|
|
6278
6278
|
};
|
|
6279
|
-
if (r === "POST" && (t === "/_voltro/inspect/invoke" || t.startsWith("/_voltro/inspect/invoke?"))) return
|
|
6280
|
-
if (r === "POST" && t.startsWith("/_voltro/inspect/webhooks/")) return
|
|
6279
|
+
if (r === "POST" && (t === "/_voltro/inspect/invoke" || t.startsWith("/_voltro/inspect/invoke?"))) return be(Q, n, i ?? "", { method: r });
|
|
6280
|
+
if (r === "POST" && t.startsWith("/_voltro/inspect/webhooks/")) return ie(t, Q, n, i ?? "", { method: r }).then((e) => e ?? {
|
|
6281
6281
|
status: 404,
|
|
6282
6282
|
contentType: "application/json; charset=utf-8",
|
|
6283
6283
|
body: JSON.stringify({ error: "unknown webhook URL" })
|
|
6284
6284
|
});
|
|
6285
6285
|
if (r === "POST" && t.startsWith("/_voltro/inspect/")) {
|
|
6286
|
-
let e =
|
|
6286
|
+
let e = oe(t, Q, n, i ?? "", { method: r });
|
|
6287
6287
|
if (t === "/_voltro/inspect/seeds/run" || t === "/_voltro/inspect/migrations/rollback") return e;
|
|
6288
6288
|
}
|
|
6289
6289
|
if (r === "POST" && t === "/_voltro/inspect/clientLog") return {
|
|
6290
|
-
...
|
|
6291
|
-
headers:
|
|
6290
|
+
...g(i ?? "", O),
|
|
6291
|
+
headers: b(n.origin)
|
|
6292
6292
|
};
|
|
6293
6293
|
if (r === "GET" && (t === "/_voltro/inspect/logs" || t.startsWith("/_voltro/inspect/logs?"))) return {
|
|
6294
|
-
...
|
|
6295
|
-
headers:
|
|
6294
|
+
...we(t, h()),
|
|
6295
|
+
headers: b(n.origin)
|
|
6296
6296
|
};
|
|
6297
6297
|
if (r === "GET" && (t === "/_voltro/inspect/traces" || t.startsWith("/_voltro/inspect/traces?"))) {
|
|
6298
6298
|
let e = bo();
|
|
6299
6299
|
return {
|
|
6300
6300
|
...Hl(t, Z === "postgres" && Eo() ? await Fu(t, e, B) : e),
|
|
6301
|
-
headers:
|
|
6301
|
+
headers: b(n.origin)
|
|
6302
6302
|
};
|
|
6303
6303
|
}
|
|
6304
6304
|
if (r === "GET" && (t === "/_voltro/inspect/data/rows" || t.startsWith("/_voltro/inspect/data/rows?"))) {
|
|
6305
|
-
let e = await
|
|
6305
|
+
let e = await f(t, Q, n, { method: r });
|
|
6306
6306
|
if (e) return e;
|
|
6307
6307
|
}
|
|
6308
6308
|
if (r === "GET" && t.startsWith("/_voltro/inspect/provenance")) {
|
|
6309
|
-
let e = await
|
|
6309
|
+
let e = await pe(t, Q, n, { method: r });
|
|
6310
6310
|
if (e) return e;
|
|
6311
6311
|
}
|
|
6312
6312
|
if ((r === "POST" || r === "PATCH" || r === "DELETE") && t.startsWith("/_voltro/inspect/data/rows")) {
|
|
6313
|
-
let
|
|
6314
|
-
if (
|
|
6313
|
+
let a = await e(t, Q, n, i ?? "", { method: r });
|
|
6314
|
+
if (a) return a;
|
|
6315
6315
|
}
|
|
6316
6316
|
if (r === "POST" && t.startsWith("/_voltro/inspect/data/import")) {
|
|
6317
|
-
let e = await
|
|
6317
|
+
let e = await ne(t, Q, n, i ?? "", { method: r });
|
|
6318
6318
|
if (e) return e;
|
|
6319
6319
|
}
|
|
6320
6320
|
if (r === "GET" && (t === "/_voltro/inspect/workflows/runs" || t.startsWith("/_voltro/inspect/workflows/runs?"))) {
|
|
6321
|
-
let e = await
|
|
6321
|
+
let e = await se(t, Q, n, { method: r });
|
|
6322
6322
|
if (e) return e;
|
|
6323
6323
|
}
|
|
6324
6324
|
if (r === "POST" && t.startsWith("/_voltro/inspect/workflows/start/")) {
|
|
6325
|
-
let e = await
|
|
6325
|
+
let e = await he(t, Q, n, i ?? "", { method: r });
|
|
6326
6326
|
if (e) return e;
|
|
6327
6327
|
}
|
|
6328
6328
|
if (r === "GET" && t.startsWith("/_voltro/inspect/workflows/runs/") && t.endsWith("/steps")) {
|
|
6329
|
-
let e = await
|
|
6329
|
+
let e = await v(t, Q, n, { method: r });
|
|
6330
6330
|
if (e) return e;
|
|
6331
6331
|
}
|
|
6332
6332
|
if (r === "GET" && t.startsWith("/_voltro/inspect/workflows/runs/") && t.endsWith("/events")) {
|
|
6333
|
-
let e = await
|
|
6333
|
+
let e = await xe(t, Q, n, { method: r });
|
|
6334
6334
|
if (e) return e;
|
|
6335
6335
|
}
|
|
6336
6336
|
if (r === "GET" && (t === "/_voltro/inspect/workflows/events" || t.startsWith("/_voltro/inspect/workflows/events?"))) {
|
|
6337
|
-
let e = await
|
|
6337
|
+
let e = await ae(Q, t, n, { method: r });
|
|
6338
6338
|
if (e) return e;
|
|
6339
6339
|
}
|
|
6340
6340
|
if (r === "GET" && t.startsWith("/_voltro/inspect/workflows/events/") && t.endsWith("/deliveries")) {
|
|
@@ -6342,23 +6342,23 @@ ${a.join("\n\n")}\n`);
|
|
|
6342
6342
|
if (e) return e;
|
|
6343
6343
|
}
|
|
6344
6344
|
if (r === "GET" && (t === "/_voltro/inspect/workflows/children" || t.startsWith("/_voltro/inspect/workflows/children?"))) {
|
|
6345
|
-
let e = await
|
|
6345
|
+
let e = await ve(t, Q, n, { method: r });
|
|
6346
6346
|
if (e) return e;
|
|
6347
6347
|
}
|
|
6348
6348
|
if (r === "POST" && t.startsWith("/_voltro/inspect/workflows/runs/") && (t.endsWith("/cancel") || t.endsWith("/retry") || t.endsWith("/suspend") || t.endsWith("/resume") || t.endsWith("/signal"))) {
|
|
6349
|
-
let
|
|
6350
|
-
if (
|
|
6349
|
+
let e = await me(t, Q, n, i ?? "", { method: r });
|
|
6350
|
+
if (e) return e;
|
|
6351
6351
|
}
|
|
6352
6352
|
if (t.startsWith("/_voltro/inspect/schedules")) {
|
|
6353
|
-
let e = await
|
|
6353
|
+
let e = await ue(t, Q, n, { method: r });
|
|
6354
6354
|
if (e) return e;
|
|
6355
6355
|
}
|
|
6356
6356
|
if (t === "/_voltro/inspect/cluster" || t.startsWith("/_voltro/inspect/cluster?")) {
|
|
6357
|
-
let e = await
|
|
6357
|
+
let e = await ee(t, Q, n, { method: r });
|
|
6358
6358
|
if (e) return e;
|
|
6359
6359
|
}
|
|
6360
6360
|
if (t.startsWith("/_voltro/inspect/aggregates")) {
|
|
6361
|
-
let e = await bc(t, r, $r.registry,
|
|
6361
|
+
let e = await bc(t, r, $r.registry, b(n.origin));
|
|
6362
6362
|
if (e) return e;
|
|
6363
6363
|
}
|
|
6364
6364
|
if (t.startsWith("/_voltro/inspect/timeline")) {
|
|
@@ -6370,14 +6370,14 @@ ${a.join("\n\n")}\n`);
|
|
|
6370
6370
|
limit: 500,
|
|
6371
6371
|
count: "none"
|
|
6372
6372
|
})).rows
|
|
6373
|
-
},
|
|
6373
|
+
}, b(n.origin));
|
|
6374
6374
|
if (e) return e;
|
|
6375
6375
|
}
|
|
6376
6376
|
if (t.startsWith("/_voltro/inspect/analytics")) {
|
|
6377
6377
|
let e = wc(t, r, {
|
|
6378
6378
|
sink: sr,
|
|
6379
6379
|
metricsCollector: ka
|
|
6380
|
-
},
|
|
6380
|
+
}, b(n.origin));
|
|
6381
6381
|
if (e) return e;
|
|
6382
6382
|
}
|
|
6383
6383
|
if (r === "GET" && (t === "/_voltro/inspect/webhooks" || t.startsWith("/_voltro/inspect/webhooks?"))) return Q.webhooks === void 0 ? {
|
|
@@ -6389,26 +6389,26 @@ ${a.join("\n\n")}\n`);
|
|
|
6389
6389
|
targets: [],
|
|
6390
6390
|
deliveries: []
|
|
6391
6391
|
}),
|
|
6392
|
-
headers:
|
|
6392
|
+
headers: b(n.origin)
|
|
6393
6393
|
} : Q.webhooks().then((e) => ({
|
|
6394
6394
|
status: 200,
|
|
6395
6395
|
contentType: "application/json; charset=utf-8",
|
|
6396
6396
|
body: JSON.stringify(e),
|
|
6397
|
-
headers:
|
|
6397
|
+
headers: b(n.origin)
|
|
6398
6398
|
}));
|
|
6399
6399
|
if (t.startsWith("/_voltro/inspect/plugins/")) {
|
|
6400
6400
|
let e = await kt.dispatch(t, r, n, i ?? "");
|
|
6401
6401
|
if (e) return e;
|
|
6402
6402
|
}
|
|
6403
|
-
return
|
|
6403
|
+
return _e(t, Q, n, { method: r });
|
|
6404
6404
|
} },
|
|
6405
6405
|
inspectStream: {
|
|
6406
|
-
authorize: (e) =>
|
|
6407
|
-
isDisabled: () =>
|
|
6408
|
-
replay: () =>
|
|
6409
|
-
subscribe: (e) =>
|
|
6410
|
-
corsHeaders: (e) =>
|
|
6411
|
-
keepAlive: () =>
|
|
6406
|
+
authorize: (e) => te(e),
|
|
6407
|
+
isDisabled: () => le(),
|
|
6408
|
+
replay: () => O.buffered().map(_),
|
|
6409
|
+
subscribe: (e) => O.subscribe((t) => e(_(t))),
|
|
6410
|
+
corsHeaders: (e) => b(e),
|
|
6411
|
+
keepAlive: () => c()
|
|
6412
6412
|
},
|
|
6413
6413
|
webhookRoutes: new Map(Array.from(Hi.entries()).map(([e, t]) => [e, { handle: t }])),
|
|
6414
6414
|
...Nn ? { tracerLayer: Nn } : {}
|
|
@@ -6416,76 +6416,76 @@ ${a.join("\n\n")}\n`);
|
|
|
6416
6416
|
try {
|
|
6417
6417
|
await dt(No);
|
|
6418
6418
|
} catch (e) {
|
|
6419
|
-
$.error(`rpc server failed to bind on port ${
|
|
6419
|
+
$.error(`rpc server failed to bind on port ${x} — aborting boot`, { port: x }, e), process.exit(1);
|
|
6420
6420
|
}
|
|
6421
|
-
$.info(`listening on http://localhost:${
|
|
6422
|
-
port:
|
|
6423
|
-
ws: `ws://localhost:${
|
|
6421
|
+
$.info(`listening on http://localhost:${x}`, {
|
|
6422
|
+
port: x,
|
|
6423
|
+
ws: `ws://localhost:${x}/ws`,
|
|
6424
6424
|
store: Z
|
|
6425
|
-
}),
|
|
6425
|
+
}), Ne?.set({ phase: "ready" }), Z === "postgres" && $.info("postgres change-data-capture", { enabled: (process.env.CDC ?? "1") !== "0" }), await Ca();
|
|
6426
6426
|
try {
|
|
6427
|
-
await
|
|
6428
|
-
id:
|
|
6429
|
-
name:
|
|
6427
|
+
await de({
|
|
6428
|
+
id: D,
|
|
6429
|
+
name: w,
|
|
6430
6430
|
kind: "api",
|
|
6431
|
-
url: `http://localhost:${
|
|
6431
|
+
url: `http://localhost:${x}`,
|
|
6432
6432
|
pid: process.pid,
|
|
6433
6433
|
status: "live",
|
|
6434
|
-
logFile:
|
|
6434
|
+
logFile: Oe.path
|
|
6435
6435
|
});
|
|
6436
|
-
let e =
|
|
6436
|
+
let e = p(t);
|
|
6437
6437
|
if (e) {
|
|
6438
|
-
let t = await
|
|
6438
|
+
let t = await Ce({ dashboardAppPath: e });
|
|
6439
6439
|
t.status === "launched" ? $.info(`dashboard launched at http://localhost:${t.port}`, { port: t.port }) : t.status === "already-running" && $.debug(`dashboard already running on :${t.port}`, { port: t.port });
|
|
6440
6440
|
}
|
|
6441
6441
|
setInterval(() => {
|
|
6442
|
-
|
|
6443
|
-
id:
|
|
6444
|
-
name:
|
|
6442
|
+
de({
|
|
6443
|
+
id: D,
|
|
6444
|
+
name: w,
|
|
6445
6445
|
kind: "api",
|
|
6446
|
-
url: `http://localhost:${
|
|
6446
|
+
url: `http://localhost:${x}`,
|
|
6447
6447
|
pid: process.pid,
|
|
6448
6448
|
status: "live",
|
|
6449
|
-
logFile:
|
|
6449
|
+
logFile: Oe.path
|
|
6450
6450
|
}).catch(() => {});
|
|
6451
6451
|
}, 1e4).unref();
|
|
6452
|
-
let
|
|
6452
|
+
let n = async () => {
|
|
6453
6453
|
Dt.deactivate();
|
|
6454
6454
|
for (let e of Hn) e.stop();
|
|
6455
|
-
zn?.dispose(),
|
|
6455
|
+
zn?.dispose(), u(D), Oe.dispose(), Zn(), Wn?.close(), await lr();
|
|
6456
6456
|
};
|
|
6457
6457
|
process.on("SIGINT", () => {
|
|
6458
|
-
|
|
6458
|
+
n();
|
|
6459
6459
|
}), process.on("SIGTERM", () => {
|
|
6460
|
-
|
|
6460
|
+
n();
|
|
6461
6461
|
});
|
|
6462
6462
|
let r = process.ppid;
|
|
6463
6463
|
if (r > 1) {
|
|
6464
6464
|
let e = setInterval(() => {
|
|
6465
|
-
(process.ppid !== r || process.ppid === 1) && (clearInterval(e),
|
|
6465
|
+
(process.ppid !== r || process.ppid === 1) && (clearInterval(e), n().finally(() => process.exit(0)));
|
|
6466
6466
|
}, 2e3);
|
|
6467
6467
|
e.unref();
|
|
6468
6468
|
}
|
|
6469
6469
|
} catch (e) {
|
|
6470
6470
|
$.warn("runtime-registry write failed", {}, e);
|
|
6471
6471
|
}
|
|
6472
|
-
return
|
|
6473
|
-
root:
|
|
6472
|
+
return i(l, $, {
|
|
6473
|
+
root: t,
|
|
6474
6474
|
onBeforeRestart: () => {
|
|
6475
6475
|
try {
|
|
6476
6476
|
No.closeAllConnections?.();
|
|
6477
6477
|
} catch {}
|
|
6478
6478
|
No.close();
|
|
6479
6479
|
}
|
|
6480
|
-
}),
|
|
6481
|
-
app:
|
|
6480
|
+
}), Ve({
|
|
6481
|
+
app: w,
|
|
6482
6482
|
kind: "api",
|
|
6483
|
-
url: `http://localhost:${
|
|
6483
|
+
url: `http://localhost:${x}`,
|
|
6484
6484
|
extras: [{
|
|
6485
6485
|
label: "WS",
|
|
6486
|
-
url: `ws://localhost:${
|
|
6486
|
+
url: `ws://localhost:${x}/ws`
|
|
6487
6487
|
}],
|
|
6488
|
-
bootMs: Date.now() -
|
|
6488
|
+
bootMs: Date.now() - y
|
|
6489
6489
|
}), new Promise(() => {});
|
|
6490
6490
|
};
|
|
6491
6491
|
//#endregion
|