@voltro/cli 0.38.0 → 0.39.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +276 -0
- package/THIRD-PARTY-NOTICES.md +80 -45
- package/dist/{addCommand-BNeoeSxe.js → addCommand-C05L9tZh.js} +2 -2
- package/dist/addCommand-C3MdJG-a.js +2 -0
- package/dist/{agentsMd-mhQMF1bx.js → agentsMd-7zI2h5l9.js} +3 -3
- package/dist/agentsMd-BFCXh2gl.js +2 -0
- package/dist/apiBuild-BmR_bIxN.js +2 -0
- package/dist/{apiBuild-CvacV4zA.js → apiBuild-D9FB13_2.js} +3 -3
- package/dist/baselineCommand-CXv680Dc.js +2 -0
- package/dist/{baselineCommand-C6NMt-oa.js → baselineCommand-Ck2Xm8M7.js} +18 -18
- package/dist/bin.js +1 -1
- package/dist/{build-_LoTC1s0.js → build-DORV5mLM.js} +107 -100
- package/dist/{capabilitiesCommand-nq_pz5xd.js → capabilitiesCommand-D5gucwYa.js} +8 -8
- package/dist/{checkCommand-Pjk5sBl2.js → checkCommand-Bf6oMao4.js} +35 -35
- package/dist/{checkCommand-wibtQx-N.js → checkCommand-D9qK_gtA.js} +1 -1
- package/dist/{cloudCmd-NQSwe_Qk.js → cloudCmd-C42gaO8s.js} +16 -16
- package/dist/{clusterCmd-D5wsCmA_.js → clusterCmd-DrVFCzSj.js} +8 -4
- package/dist/{codegen-GYYcdpCg.js → codegen-CbpGCWLG.js} +1 -1
- package/dist/codegen-i8QGcHsi.js +2 -0
- package/dist/codegenCommand-CxOyKmc1.js +129 -0
- package/dist/{codemodRunner-CXgQ-ecJ.js → codemodRunner-D-jTyvWo.js} +622 -551
- package/dist/{commands-DaZVi9wi.js → commands-D6aW_6AR.js} +48 -48
- package/dist/{connectionConfig-UFlIEiys.js → connectionConfig-Bk9IC7D0.js} +1 -1
- package/dist/{dashboardCommand-Dxy_kmoW.js → dashboardCommand-CwTZh-XZ.js} +3 -3
- package/dist/{dataCommand-D6-Ha2lf.js → dataCommand-Cc9RiLQZ.js} +14 -11
- package/dist/{dbCommand-C4UW8cVN.js → dbCommand-DSwGv9wS.js} +50 -49
- package/dist/dbCommand-DcqEyxju.js +2 -0
- package/dist/{dev-E7Eo5GHc.js → dev-3mgc8c-H.js} +2260 -2184
- package/dist/dev-CjJAasDs.js +3 -0
- package/dist/{dialectDriver-CgXnDfec.js → dialectDriver-czCHYpeH.js} +2 -1
- package/dist/doctorCommand-Cghssndo.js +2 -0
- package/dist/{doctorCommand-gmDyALFL.js → doctorCommand-oLuzc-aC.js} +261 -244
- package/dist/{dormancyCommand-CE6wG8lj.js → dormancyCommand-Bxe4WtHU.js} +1 -1
- package/dist/{e2eCmd-BRabZww-.js → e2eCmd-uFHig1hV.js} +8 -2
- package/dist/{embeddingsCommand-C3uAuf6N.js → embeddingsCommand-CyNQkFIc.js} +6 -6
- package/dist/{envCommand-DzuWh8ya.js → envCommand-CAkSgBbh.js} +19 -19
- package/dist/{evolveCommand-DPLqcYb2.js → evolveCommand-CWhBoe_P.js} +6 -8
- package/dist/frameworkTableAssembly-DgylYh9_.js +2 -0
- package/dist/{generateCommand-DbgcUpGw.js → generateCommand-CcyvH2ve.js} +1 -1
- package/dist/index.js +1 -1
- package/dist/{infoCommand-CmczGj_l.js → infoCommand-CTo8Jnhq.js} +7 -7
- package/dist/inspect-B7U7Cl_Z.js +1192 -0
- package/dist/inspect-DUze25t0.js +2 -0
- package/dist/{inspectCmd-EHFZ9yYu.js → inspectCmd-niF97fAq.js} +5 -5
- package/dist/inspectGateHint-BjnFubmH.js +7 -0
- package/dist/{logFileSink-C_D2wRN1.js → logFileSink-B4uP8pvf.js} +1 -1
- package/dist/{logsCmd-D36xK7Zu.js → logsCmd-B6oNsfaZ.js} +10 -7
- package/dist/{manifestBuild-hpPLaGxV.js → manifestBuild-BK42hu0k.js} +1 -1
- package/dist/manifestBuild-j0n109tt.js +2 -0
- package/dist/{metaCommands-CIoQNlaQ.js → metaCommands-DUYR--Ts.js} +1 -1
- package/dist/{migrate-RwgUWXfc.js → migrate-BnPw2zC8.js} +7 -4
- package/dist/{packageCommand-Cug_3Ogl.js → packageCommand-9SVyvsSo.js} +3 -2
- package/dist/{probeCommand-BPEpwT32.js → probeCommand-C9gazU0H.js} +35 -24
- package/dist/{projectScaffold-CxgtJvlb.js → projectScaffold-BEhhHjPr.js} +1 -1
- package/dist/{projectScaffold-DDgWbNLe.js → projectScaffold-BvhLOrLq.js} +17 -15
- package/dist/{runtimeTrace-6jfznSzr.js → runtimeTrace-gNXeLf6H.js} +1 -1
- package/dist/{scheduleManifestCmd-D2x0CTTY.js → scheduleManifestCmd-kmWzrO_w.js} +6 -9
- package/dist/{sdkgen-CEJZZQUA.js → sdkgen-C8zz10-X.js} +4 -4
- package/dist/{seedRunner-ZmLSqNe2.js → seedRunner-IdHEprqf.js} +1 -4
- package/dist/serveCommand-BpK8-m1N.js +1770 -0
- package/dist/serveCommand-CW-goXvh.js +2 -0
- package/dist/serveEntry.js +2 -2
- package/dist/{serverlessCommand-CfJZy6dS.js → serverlessCommand-DbJ7Plg9.js} +3 -3
- package/dist/{start-CidwCcjl.js → start-BNuTWdRd.js} +1 -1
- package/dist/{start-RCh6qKFe.js → start-ft_KzFTd.js} +257 -254
- package/dist/startEntry.js +1 -1
- package/dist/{test-DIQ0jlkQ.js → test-CLYXrZ2F.js} +1 -1
- package/dist/{tracesCmd-DStmCJPi.js → tracesCmd-DgtgOUdi.js} +7 -4
- package/dist/{typecheckCommand-BlsWiCNq.js → typecheckCommand-BuCtT92o.js} +7 -7
- package/dist/updateCommand-6FMU2klq.js +2 -0
- package/dist/{updateCommand-CmksX7m_.js → updateCommand-CHBmCB17.js} +5 -3
- package/dist/{webDev-BKdD7c_a.js → webDev-CTpSY-e_.js} +813 -775
- package/dist/webDev-id3I5PvG.js +2 -0
- package/dist/{webhookDiscovery-D7VaeMlz.js → webhookDiscovery-CphsQe59.js} +4 -6
- package/dist/{webhookDiscovery-CrGAfhIG.js → webhookDiscovery-il9ti-HE.js} +1 -1
- package/dist/{webhooksCommand-BHeaF1ZJ.js → webhooksCommand-EccPZQZ4.js} +1 -1
- package/package.json +27 -21
- package/templates/AGENTS.md +2 -2
- package/templates/agent-docs/_index.md +2 -2
- package/templates/agent-docs/_manifest.json +2 -2
- package/templates/agent-docs/authentication.md +43 -4
- package/templates/agent-docs/cli.md +17 -13
- package/templates/agent-docs/data.md +44 -1
- package/templates/agent-docs/database/migrations.md +2 -2
- package/templates/agent-docs/database/seedsdialects.md +2 -2
- package/templates/agent-docs/deployment.md +21 -7
- package/templates/agent-docs/internationalization.md +10 -3
- package/templates/agent-docs/local-first-mobile.md +141 -20
- package/templates/agent-docs/plugins/mail.md +1 -1
- package/templates/agent-docs/plugins/ratelimit.md +1 -1
- package/templates/agent-docs/plugins.md +3 -1
- package/templates/agent-docs/releases.md +130 -1
- package/templates/agent-docs/routing.md +34 -2
- package/templates/agent-docs/templates/apibackends.md +1 -1
- package/templates/agent-docs/templates/mobile.md +1 -1
- package/templates/agent-docs/whats-new.md +26 -66
- package/templates/apps/api-ai/package.json +7 -7
- package/templates/apps/api-auth/package.json +8 -8
- package/templates/apps/api-backend/package.json +7 -7
- package/templates/apps/api-backend-deactivation/package.json +7 -7
- package/templates/apps/api-backend-mail/package.json +8 -8
- package/templates/apps/api-backend-mariadb/package.json +9 -9
- package/templates/apps/api-backend-sqlite/package.json +8 -8
- package/templates/apps/api-backend-storage/package.json +8 -8
- package/templates/apps/api-cms/package.json +10 -10
- package/templates/apps/api-collab/package.json +8 -8
- package/templates/apps/api-data-advanced/package.json +8 -8
- package/templates/apps/api-durable/package.json +8 -8
- package/templates/apps/api-durable/startup/warm.startup.tsx +16 -2
- package/templates/apps/api-feature-flags/package.json +9 -9
- package/templates/apps/api-governance/package.json +8 -8
- package/templates/apps/api-kv/package.json +8 -8
- package/templates/apps/api-moderation/package.json +8 -8
- package/templates/apps/api-observability/package.json +8 -8
- package/templates/apps/api-ratelimit/package.json +8 -8
- package/templates/apps/api-rbac/authz.ts +16 -1
- package/templates/apps/api-rbac/package.json +8 -8
- package/templates/apps/api-rest/package.json +7 -7
- package/templates/apps/api-saas/package.json +11 -11
- package/templates/apps/api-saas-starter/package.json +10 -10
- package/templates/apps/api-search/package.json +8 -8
- package/templates/apps/api-status/package.json +8 -8
- package/templates/apps/api-versioning/package.json +8 -8
- package/templates/apps/api-webhooks/package.json +9 -9
- package/templates/apps/changelog/package.json +6 -6
- package/templates/apps/edge-functions/package.json +2 -2
- package/templates/apps/frontend-admin/package.json +8 -8
- package/templates/apps/frontend-app/package.json +9 -9
- package/templates/apps/frontend-auth/package.json +8 -8
- package/templates/apps/frontend-blank/package.json +7 -7
- package/templates/apps/frontend-cms/package.json +9 -9
- package/templates/apps/frontend-collab/package.json +10 -10
- package/templates/apps/frontend-contact/package.json +7 -7
- package/templates/apps/frontend-dashboard/package.json +7 -7
- package/templates/apps/frontend-docs/package.json +7 -7
- package/templates/apps/frontend-i18n/package.json +6 -6
- package/templates/apps/frontend-landing/package.json +7 -7
- package/templates/apps/frontend-portal/package.json +8 -8
- package/templates/apps/frontend-saas/package.json +8 -8
- package/templates/apps/frontend-spa/package.json +7 -7
- package/templates/apps/frontend-ssr/package.json +7 -7
- package/templates/apps/frontend-ssr-api/package.json +8 -8
- package/templates/apps/frontend-static-blog/package.json +6 -6
- package/templates/apps/frontend-status/package.json +8 -8
- package/templates/apps/mobile-app/README.md +41 -17
- package/templates/apps/mobile-app/app.config.ts +1 -1
- package/templates/apps/mobile-app/package.json +15 -11
- package/templates/apps/mobile-app/src/app/_layout.tsx +44 -13
- package/templates/apps/mobile-app/src/app/index.tsx +1 -1
- package/templates/apps/mobile-app/src/app/settings.tsx +4 -1
- package/templates/apps/mobile-app/src/client.ts +74 -57
- package/templates/apps/mobile-app/src/lib/api.ts +4 -4
- package/templates/apps/mobile-app/src/lib/deeplinks.ts +6 -6
- package/templates/apps/mobile-app/src/persistence.ts +24 -3
- package/templates/apps/mobile-app/tsconfig.json +17 -3
- package/dist/addCommand-aXSQveak.js +0 -2
- package/dist/agentsMd-BTchIZku.js +0 -2
- package/dist/apiBuild-ttSDDOGp.js +0 -2
- package/dist/baselineCommand-Cfw2Afwm.js +0 -2
- package/dist/codegen-uYrrDzQv.js +0 -2
- package/dist/codegenCommand-C60m_LCp.js +0 -30
- package/dist/dbCommand-CC-qNzpz.js +0 -2
- package/dist/dev-CAOoXOkc.js +0 -3
- package/dist/doctorCommand-Cjl8Yii8.js +0 -2
- package/dist/frameworkTableAssembly-YyVe32Cb.js +0 -2
- package/dist/inspect-CjTYzAs_.js +0 -1190
- package/dist/inspect-P4pxoMaV.js +0 -2
- package/dist/inspectGateHint-BF6608UT.js +0 -4
- package/dist/manifestBuild-COkJoyAr.js +0 -2
- package/dist/serveCommand-DNRF2nDI.js +0 -2
- package/dist/serveCommand-DnY4VS3D.js +0 -1767
- package/dist/updateCommand-B0J_T9Vs.js +0 -2
- package/dist/webDev-CcJfdSjl2.js +0 -2
|
@@ -0,0 +1,1192 @@
|
|
|
1
|
+
import { n as e } from "./inspectGateHint-BjnFubmH.js";
|
|
2
|
+
import { lastWriteProvenance as t } from "@voltro/runtime";
|
|
3
|
+
import { timingSafeStringEqual as n } from "@voltro/protocol/session";
|
|
4
|
+
//#region src/inspect.ts
|
|
5
|
+
var r = "/_voltro/inspect", i = () => process.env.VOLTRO_INSPECT === "off", a = /* @__PURE__ */ new Set([
|
|
6
|
+
"GET",
|
|
7
|
+
"HEAD",
|
|
8
|
+
"OPTIONS"
|
|
9
|
+
]), o = (t, r) => {
|
|
10
|
+
let i = process.env.VOLTRO_INSPECT_TOKEN;
|
|
11
|
+
if (!i || i.length === 0) return {
|
|
12
|
+
ok: !1,
|
|
13
|
+
reason: "inspect is closed: no VOLTRO_INSPECT_TOKEN configured. `voltro dev` mints one per project; for serve/start set it explicitly (it is never minted outside dev)."
|
|
14
|
+
};
|
|
15
|
+
let o = t.authorization ?? t.Authorization;
|
|
16
|
+
if (!o) return {
|
|
17
|
+
ok: !1,
|
|
18
|
+
reason: "missing Authorization header"
|
|
19
|
+
};
|
|
20
|
+
if (!o.startsWith("Bearer ")) return {
|
|
21
|
+
ok: !1,
|
|
22
|
+
reason: "expected \"Bearer <token>\" auth scheme"
|
|
23
|
+
};
|
|
24
|
+
let s = o.slice(7).trim();
|
|
25
|
+
if (!n(s, i)) return {
|
|
26
|
+
ok: !1,
|
|
27
|
+
reason: "token mismatch"
|
|
28
|
+
};
|
|
29
|
+
if (!a.has(r.toUpperCase())) {
|
|
30
|
+
let i = process.env.VOLTRO_INSPECT_WRITE_TOKEN;
|
|
31
|
+
if (!i || i.length === 0) return {
|
|
32
|
+
ok: !1,
|
|
33
|
+
reason: e("unset", r)
|
|
34
|
+
};
|
|
35
|
+
let a = (t["x-voltro-inspect-write"] ?? t["X-Voltro-Inspect-Write"] ?? "").trim();
|
|
36
|
+
if (a.length === 0) return {
|
|
37
|
+
ok: !1,
|
|
38
|
+
reason: e("absent", r)
|
|
39
|
+
};
|
|
40
|
+
if (!n(a, i)) return {
|
|
41
|
+
ok: !1,
|
|
42
|
+
reason: e("mismatch", r)
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
return { ok: !0 };
|
|
46
|
+
}, s = (e) => {
|
|
47
|
+
if (!Array.isArray(e) || e.length === 0) return;
|
|
48
|
+
let t = [];
|
|
49
|
+
for (let n of e) {
|
|
50
|
+
if (typeof n != "object" || !n) continue;
|
|
51
|
+
if (typeof n.open == "string") {
|
|
52
|
+
t.push({
|
|
53
|
+
kind: "open",
|
|
54
|
+
reason: n.open
|
|
55
|
+
});
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
if (typeof n.action == "string" && typeof n.resourceType == "string") {
|
|
59
|
+
t.push({
|
|
60
|
+
kind: "policy",
|
|
61
|
+
action: n.action,
|
|
62
|
+
resourceType: n.resourceType
|
|
63
|
+
});
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
let e = n.scope;
|
|
67
|
+
typeof e != "string" && !Array.isArray(e) || t.push({
|
|
68
|
+
kind: "scope",
|
|
69
|
+
scope: typeof e == "string" ? [e] : e.filter((e) => typeof e == "string"),
|
|
70
|
+
mode: n.mode === "any" ? "any" : "all",
|
|
71
|
+
resourceScoped: typeof n.resource == "function"
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
return t.length > 0 ? t : void 0;
|
|
75
|
+
}, c = (e, t, n = {}) => ({
|
|
76
|
+
status: e,
|
|
77
|
+
contentType: "application/json; charset=utf-8",
|
|
78
|
+
body: JSON.stringify(t),
|
|
79
|
+
headers: n
|
|
80
|
+
}), l = (e) => {
|
|
81
|
+
let t;
|
|
82
|
+
try {
|
|
83
|
+
t = new URL(e).hostname;
|
|
84
|
+
} catch {
|
|
85
|
+
return !1;
|
|
86
|
+
}
|
|
87
|
+
return t = t.replace(/^\[|\]$/g, ""), t === "localhost" || t.endsWith(".localhost") || t === "::1" ? !0 : /^127(?:\.\d{1,3}){3}$/.test(t);
|
|
88
|
+
}, u = (e) => !e || e.length === 0 ? {} : l(e) ? {
|
|
89
|
+
"access-control-allow-origin": e,
|
|
90
|
+
"access-control-allow-credentials": "true",
|
|
91
|
+
"access-control-allow-methods": "GET, POST, OPTIONS",
|
|
92
|
+
"access-control-allow-headers": "authorization, content-type, accept",
|
|
93
|
+
"access-control-expose-headers": "content-type, content-length",
|
|
94
|
+
vary: "Origin"
|
|
95
|
+
} : { vary: "Origin" }, d = (e, t = process.env.VOLTRO_DASHBOARD_APPS) => {
|
|
96
|
+
if (l(e)) return !0;
|
|
97
|
+
let n;
|
|
98
|
+
try {
|
|
99
|
+
n = new URL(e).origin;
|
|
100
|
+
} catch {
|
|
101
|
+
return !1;
|
|
102
|
+
}
|
|
103
|
+
if (!t || t.trim() === "") return !1;
|
|
104
|
+
try {
|
|
105
|
+
let e = JSON.parse(t);
|
|
106
|
+
return Array.isArray(e) ? e.some((e) => {
|
|
107
|
+
let t = e?.url;
|
|
108
|
+
if (typeof t != "string") return !1;
|
|
109
|
+
try {
|
|
110
|
+
return new URL(t).origin === n;
|
|
111
|
+
} catch {
|
|
112
|
+
return !1;
|
|
113
|
+
}
|
|
114
|
+
}) : !1;
|
|
115
|
+
} catch {
|
|
116
|
+
return !1;
|
|
117
|
+
}
|
|
118
|
+
}, f = (e, t, n = {}) => {
|
|
119
|
+
let r = (e ?? "GET").toUpperCase();
|
|
120
|
+
if (r === "GET" || r === "HEAD" || r === "OPTIONS") return null;
|
|
121
|
+
let i = t.origin ?? t.Origin;
|
|
122
|
+
return i === void 0 || i === "" || l(i) ? null : c(403, {
|
|
123
|
+
error: "cross-site write rejected",
|
|
124
|
+
reason: `a state-changing inspect request may not come from origin "${i}" — only same-machine (loopback) origins may write`
|
|
125
|
+
}, n);
|
|
126
|
+
}, p = (e = process.env.VOLTRO_INSPECT_ALLOWED_HOSTS) => (e ?? "").split(/[,\s]+/).map((e) => e.trim().toLowerCase()).filter((e) => e.length > 0), m = (e) => {
|
|
127
|
+
if (e === void 0) return "";
|
|
128
|
+
let t = e.trim();
|
|
129
|
+
if (t === "") return "";
|
|
130
|
+
if (t.startsWith("[")) {
|
|
131
|
+
let e = t.indexOf("]");
|
|
132
|
+
return (e === -1 ? t.slice(1) : t.slice(1, e)).toLowerCase();
|
|
133
|
+
}
|
|
134
|
+
let n = t.indexOf(":");
|
|
135
|
+
return (n === -1 ? t : t.slice(0, n)).toLowerCase();
|
|
136
|
+
}, h = (e) => /^\d{1,3}(?:\.\d{1,3}){3}$/.test(e) || e.includes(":"), g = (e, t = p()) => {
|
|
137
|
+
let n = m(e);
|
|
138
|
+
return n === "" || n === "localhost" || n.endsWith(".localhost") || h(n) ? !0 : t.includes(n);
|
|
139
|
+
}, _ = (e, t = {}, n) => g(e, n) ? null : c(403, {
|
|
140
|
+
error: "forbidden host",
|
|
141
|
+
reason: `the dev inspect surface refuses a request with Host "${e ?? ""}" — a DNS-rebinding guard. Only loopback names, IP literals, and hosts listed in VOLTRO_INSPECT_ALLOWED_HOSTS may reach it.`
|
|
142
|
+
}, t), v = (e) => {
|
|
143
|
+
let t = e.indexOf("?");
|
|
144
|
+
return t === -1 ? e : e.slice(0, t);
|
|
145
|
+
}, y = (e) => {
|
|
146
|
+
let t = e.indexOf("?");
|
|
147
|
+
return t === -1 ? new URLSearchParams() : new URLSearchParams(e.slice(t + 1));
|
|
148
|
+
}, b = (e) => e === "/_voltro/inspect" || e.startsWith("/_voltro/inspect/"), x = [
|
|
149
|
+
"text",
|
|
150
|
+
"textarea",
|
|
151
|
+
"number",
|
|
152
|
+
"checkbox",
|
|
153
|
+
"switch",
|
|
154
|
+
"select",
|
|
155
|
+
"radio",
|
|
156
|
+
"async-select",
|
|
157
|
+
"multi-select",
|
|
158
|
+
"date",
|
|
159
|
+
"datetime",
|
|
160
|
+
"daterange",
|
|
161
|
+
"file",
|
|
162
|
+
"hidden",
|
|
163
|
+
"custom"
|
|
164
|
+
], S = (e, t, n = [], r = []) => ({
|
|
165
|
+
version: 2,
|
|
166
|
+
scopes: [...new Set(r.flatMap((e) => e.declaredScopes ?? []))].sort(),
|
|
167
|
+
procedures: [...e].sort((e, t) => e.tag.localeCompare(t.tag)).map((e) => ({
|
|
168
|
+
tag: e.tag,
|
|
169
|
+
kind: e.kind,
|
|
170
|
+
...e.inputSchema === void 0 ? {} : { input: e.inputSchema },
|
|
171
|
+
...e.outputSchema === void 0 ? {} : { output: e.outputSchema },
|
|
172
|
+
...e.source === void 0 ? {} : { source: e.source },
|
|
173
|
+
...e.targets === void 0 ? {} : { targets: e.targets },
|
|
174
|
+
...e.guards === void 0 ? {} : { guards: e.guards },
|
|
175
|
+
...e.publicApi === void 0 ? {} : { publicApi: e.publicApi },
|
|
176
|
+
...e.exposeAsTool === void 0 ? {} : { exposeAsTool: e.exposeAsTool }
|
|
177
|
+
})),
|
|
178
|
+
workflows: [...t].sort((e, t) => e.tag.localeCompare(t.tag)).map((e) => ({ name: e.tag })),
|
|
179
|
+
widgets: x,
|
|
180
|
+
tables: [...n].filter((e) => !e.isFrameworkTable).sort((e, t) => e.name.localeCompare(t.name)).map((e) => ({
|
|
181
|
+
name: e.name,
|
|
182
|
+
reactive: e.isReactive,
|
|
183
|
+
framework: e.isFrameworkTable,
|
|
184
|
+
editable: e.editable ?? !0,
|
|
185
|
+
...e.pkColumn === void 0 ? {} : { pkColumn: e.pkColumn },
|
|
186
|
+
columns: e.columns.map((e) => ({
|
|
187
|
+
name: e.name,
|
|
188
|
+
type: String(e.type),
|
|
189
|
+
nullable: e.nullable,
|
|
190
|
+
...e.referencesTable === void 0 ? {} : { refersTo: e.referencesTable },
|
|
191
|
+
...e.oneOf === void 0 ? {} : { enum: e.oneOf },
|
|
192
|
+
...e.serverOnly === !0 ? { serverOnly: !0 } : {},
|
|
193
|
+
...e.encrypted === !0 ? { encrypted: !0 } : {},
|
|
194
|
+
...e.sensitive === void 0 ? {} : { sensitive: e.sensitive }
|
|
195
|
+
}))
|
|
196
|
+
}))
|
|
197
|
+
}), C = (e, t, n = {}, r = {}) => {
|
|
198
|
+
let a = v(e);
|
|
199
|
+
if (!b(a)) return null;
|
|
200
|
+
let s = u(n.origin ?? n.Origin), l = (r.method ?? "GET").toUpperCase();
|
|
201
|
+
if (l === "OPTIONS") return {
|
|
202
|
+
status: 204,
|
|
203
|
+
contentType: "text/plain",
|
|
204
|
+
body: "",
|
|
205
|
+
headers: s
|
|
206
|
+
};
|
|
207
|
+
if (i()) return c(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, s);
|
|
208
|
+
let d = (r.authResolver ?? o)(n, l);
|
|
209
|
+
if (!d.ok) return c(401, {
|
|
210
|
+
error: "unauthorized",
|
|
211
|
+
reason: d.reason
|
|
212
|
+
}, s);
|
|
213
|
+
if (a === "/_voltro/inspect" || a === "/_voltro/inspect/" || a === "/_voltro/inspect/app") return c(200, {
|
|
214
|
+
kind: t.kind,
|
|
215
|
+
...t.meta
|
|
216
|
+
}, s);
|
|
217
|
+
if (a === "/_voltro/inspect/routes") return t.kind === "web" ? c(200, {
|
|
218
|
+
pages: t.routes,
|
|
219
|
+
dirs: t.dirs
|
|
220
|
+
}, s) : c(404, { error: "routes endpoint is web-only" }, s);
|
|
221
|
+
if (a === "/_voltro/inspect/cache") return t.kind === "web" ? c(200, t.cache(), s) : c(404, { error: "cache endpoint is web-only" }, s);
|
|
222
|
+
if (a === "/_voltro/inspect/rpc") return t.kind === "api" ? c(200, {
|
|
223
|
+
procedures: t.rpc,
|
|
224
|
+
workflows: t.workflows
|
|
225
|
+
}, s) : c(404, { error: "rpc endpoint is api-only" }, s);
|
|
226
|
+
if (a === "/_voltro/inspect/manifest") {
|
|
227
|
+
if (t.kind !== "api") return c(404, { error: "manifest endpoint is api-only" }, s);
|
|
228
|
+
let e = t.inspectTables?.().tables ?? [];
|
|
229
|
+
return c(200, S(t.rpc, t.workflows, e, t.plugins?.().plugins ?? []), s);
|
|
230
|
+
}
|
|
231
|
+
return a === "/_voltro/inspect/metrics" ? t.metrics === void 0 ? c(200, [], s) : c(200, t.metrics(), s) : a === "/_voltro/inspect/subscriptions" ? t.kind === "api" ? t.subscriptions === void 0 ? c(200, {
|
|
232
|
+
subscriptions: [],
|
|
233
|
+
matcherStats: [],
|
|
234
|
+
capturedAt: Date.now()
|
|
235
|
+
}, s) : c(200, t.subscriptions(), s) : c(404, { error: "subscriptions endpoint is api-only" }, s) : a === "/_voltro/inspect/members" ? t.kind === "api" ? t.members === void 0 ? c(200, {
|
|
236
|
+
members: [],
|
|
237
|
+
capturedAt: Date.now()
|
|
238
|
+
}, s) : c(200, t.members(), s) : c(404, { error: "members endpoint is api-only" }, s) : a === "/_voltro/inspect/events" ? t.kind === "api" ? t.events === void 0 ? c(200, {
|
|
239
|
+
declared: [],
|
|
240
|
+
routes: [],
|
|
241
|
+
origin: "",
|
|
242
|
+
capturedAt: Date.now(),
|
|
243
|
+
totals: {
|
|
244
|
+
routes: 0,
|
|
245
|
+
subscribers: 0,
|
|
246
|
+
buffered: 0
|
|
247
|
+
}
|
|
248
|
+
}, s) : c(200, t.events(), s) : c(404, { error: "events endpoint is api-only" }, s) : a === "/_voltro/inspect/data-cache" ? t.kind === "api" ? t.dataCache === void 0 ? c(200, {
|
|
249
|
+
backend: "memory",
|
|
250
|
+
engine: "memory",
|
|
251
|
+
driver: "resp",
|
|
252
|
+
hits: 0,
|
|
253
|
+
misses: 0,
|
|
254
|
+
hitRate: 0
|
|
255
|
+
}, s) : c(200, t.dataCache(), s) : c(404, { error: "data-cache endpoint is api-only" }, s) : a === "/_voltro/inspect/database" ? t.kind === "api" ? t.database === void 0 ? c(200, {
|
|
256
|
+
migrations: [],
|
|
257
|
+
seeds: []
|
|
258
|
+
}, s) : c(200, t.database(), s) : c(404, { error: "database endpoint is api-only" }, s) : a === "/_voltro/inspect/plugins" ? t.kind === "api" ? t.plugins === void 0 ? c(200, {
|
|
259
|
+
plugins: [],
|
|
260
|
+
capturedAt: Date.now()
|
|
261
|
+
}, s) : c(200, t.plugins(), s) : c(404, { error: "plugins endpoint is api-only" }, s) : a === "/_voltro/inspect/env" ? t.env === void 0 ? c(200, {
|
|
262
|
+
app: t.meta.name ?? "app",
|
|
263
|
+
entries: [],
|
|
264
|
+
summary: {
|
|
265
|
+
total: 0,
|
|
266
|
+
set: 0,
|
|
267
|
+
missingRequired: 0
|
|
268
|
+
}
|
|
269
|
+
}, s) : c(200, t.env(), s) : a === "/_voltro/inspect/data/tables" ? t.kind === "api" ? t.inspectTables === void 0 ? c(200, { tables: [] }, s) : c(200, t.inspectTables(), s) : c(404, { error: "data viewer is api-only" }, s) : a === "/_voltro/inspect/invoke" ? c(404, { error: "invoke not enabled here — use POST handler" }, s) : w.has(a) ? c(404, {
|
|
270
|
+
error: "endpoint not mounted on this instance",
|
|
271
|
+
path: a,
|
|
272
|
+
reason: "This inspect endpoint is served by `voltro dev`. A production `voltro serve` does not mount it — the data behind it (the in-memory log ring, the span buffer, the dev route table) is not collected there. This is not a missing token: the same request with no token would be 401."
|
|
273
|
+
}, s) : c(404, {
|
|
274
|
+
error: "unknown inspect endpoint",
|
|
275
|
+
path: a
|
|
276
|
+
}, s);
|
|
277
|
+
}, w = /* @__PURE__ */ new Set([
|
|
278
|
+
`${r}/logs`,
|
|
279
|
+
`${r}/traces`,
|
|
280
|
+
`${r}/workflows`,
|
|
281
|
+
`${r}/storage`,
|
|
282
|
+
`${r}/aggregates`,
|
|
283
|
+
`${r}/flags`
|
|
284
|
+
]), T = async (e, t, n, r = {}) => {
|
|
285
|
+
let a = u(t.origin ?? t.Origin);
|
|
286
|
+
if (i()) return c(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, a);
|
|
287
|
+
let s = (r.method ?? "POST").toUpperCase();
|
|
288
|
+
if (s !== "POST") return c(405, {
|
|
289
|
+
error: "method not allowed",
|
|
290
|
+
expected: "POST"
|
|
291
|
+
}, a);
|
|
292
|
+
let l = (r.authResolver ?? o)(t, s);
|
|
293
|
+
if (!l.ok) return c(401, {
|
|
294
|
+
error: "unauthorized",
|
|
295
|
+
reason: l.reason
|
|
296
|
+
}, a);
|
|
297
|
+
if (e.kind !== "api") return c(404, { error: "invoke endpoint is api-only" }, a);
|
|
298
|
+
if (!e.invokers || e.invokers.size === 0) return c(404, { error: "invoke not configured" }, a);
|
|
299
|
+
let d;
|
|
300
|
+
try {
|
|
301
|
+
d = JSON.parse(n || "{}");
|
|
302
|
+
} catch {
|
|
303
|
+
return c(400, { error: "body must be JSON" }, a);
|
|
304
|
+
}
|
|
305
|
+
let f = d;
|
|
306
|
+
if (typeof f.tag != "string") return c(400, { error: "body.tag must be a string" }, a);
|
|
307
|
+
let p = e.invokers.get(f.tag);
|
|
308
|
+
if (!p) return c(404, {
|
|
309
|
+
error: "unknown tag",
|
|
310
|
+
tag: f.tag
|
|
311
|
+
}, a);
|
|
312
|
+
let m = typeof f.headers == "object" && f.headers !== null ? f.headers : {}, h = {};
|
|
313
|
+
for (let [e, n] of Object.entries(t)) h[e.toLowerCase()] = n;
|
|
314
|
+
for (let [e, t] of Object.entries(m)) {
|
|
315
|
+
let n = e.toLowerCase();
|
|
316
|
+
n !== "cookie" && (h[n] = t);
|
|
317
|
+
}
|
|
318
|
+
return c(200, await p(f.input, h), a);
|
|
319
|
+
}, E = async (e, t, n, r = {}) => {
|
|
320
|
+
let a = v(e);
|
|
321
|
+
if (!b(a) || a !== "/_voltro/inspect/migrations" || (r.method ?? "GET").toUpperCase() !== "GET") return null;
|
|
322
|
+
let s = u(n.origin ?? n.Origin);
|
|
323
|
+
if (i()) return c(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, s);
|
|
324
|
+
let l = (r.authResolver ?? o)(n, "GET");
|
|
325
|
+
return l.ok ? t.kind === "api" ? t.migrations === void 0 ? c(200, {
|
|
326
|
+
drift: {
|
|
327
|
+
isDrifted: !1,
|
|
328
|
+
liveFingerprint: "",
|
|
329
|
+
liveSnapshot: { tables: [] }
|
|
330
|
+
},
|
|
331
|
+
pending: null,
|
|
332
|
+
history: [],
|
|
333
|
+
softDropSnapshots: []
|
|
334
|
+
}, s) : c(200, await t.migrations(), s) : c(404, { error: "migrations endpoint is api-only" }, s) : c(401, {
|
|
335
|
+
error: "unauthorized",
|
|
336
|
+
reason: l.reason
|
|
337
|
+
}, s);
|
|
338
|
+
}, D = async (e, t, n, a, s = {}) => {
|
|
339
|
+
let l = v(e);
|
|
340
|
+
if (!b(l) || !l.startsWith("/_voltro/inspect/webhooks/")) return null;
|
|
341
|
+
let d = u(n.origin ?? n.Origin);
|
|
342
|
+
if ((s.method ?? "POST").toUpperCase() !== "POST") return null;
|
|
343
|
+
if (i()) return c(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, d);
|
|
344
|
+
let p = (s.authResolver ?? o)(n, s.method ?? "POST");
|
|
345
|
+
if (!p.ok) return c(401, {
|
|
346
|
+
error: "unauthorized",
|
|
347
|
+
reason: p.reason
|
|
348
|
+
}, d);
|
|
349
|
+
let m = f(s.method, n, d);
|
|
350
|
+
if (m) return m;
|
|
351
|
+
if (t.kind !== "api") return c(404, { error: "webhook actions are api-only" }, d);
|
|
352
|
+
if (!t.webhookActions) return c(404, { error: "webhook actions not configured — is @voltro/plugin-webhooks active?" }, d);
|
|
353
|
+
let h;
|
|
354
|
+
try {
|
|
355
|
+
h = JSON.parse(a || "{}");
|
|
356
|
+
} catch {
|
|
357
|
+
return c(400, { error: "body must be JSON" }, d);
|
|
358
|
+
}
|
|
359
|
+
let g = l.slice(`${r}/webhooks/`.length);
|
|
360
|
+
try {
|
|
361
|
+
switch (g) {
|
|
362
|
+
case "subscribe": {
|
|
363
|
+
let e = h;
|
|
364
|
+
return typeof e.event != "string" || e.event.length === 0 ? c(400, { error: "event required" }, d) : typeof e.url != "string" || e.url.length === 0 ? c(400, { error: "url required" }, d) : c(200, await t.webhookActions.subscribe(e), d);
|
|
365
|
+
}
|
|
366
|
+
case "pause": {
|
|
367
|
+
let e = h.targetId;
|
|
368
|
+
return typeof e != "string" || e.length === 0 ? c(400, { error: "targetId required" }, d) : (await t.webhookActions.pause(e), c(200, { ok: !0 }, d));
|
|
369
|
+
}
|
|
370
|
+
case "resume": {
|
|
371
|
+
let e = h.targetId;
|
|
372
|
+
return typeof e != "string" || e.length === 0 ? c(400, { error: "targetId required" }, d) : (await t.webhookActions.resume(e), c(200, { ok: !0 }, d));
|
|
373
|
+
}
|
|
374
|
+
case "delete": {
|
|
375
|
+
let e = h.targetId;
|
|
376
|
+
return typeof e != "string" || e.length === 0 ? c(400, { error: "targetId required" }, d) : (await t.webhookActions.delete(e), c(200, { ok: !0 }, d));
|
|
377
|
+
}
|
|
378
|
+
case "rotateSecret": {
|
|
379
|
+
let e = h.targetId;
|
|
380
|
+
return typeof e != "string" || e.length === 0 ? c(400, { error: "targetId required" }, d) : c(200, await t.webhookActions.rotateSecret(e), d);
|
|
381
|
+
}
|
|
382
|
+
case "replay": {
|
|
383
|
+
let e = h.deliveryId;
|
|
384
|
+
return typeof e != "string" || e.length === 0 ? c(400, { error: "deliveryId required" }, d) : (await t.webhookActions.replay(e), c(200, { ok: !0 }, d));
|
|
385
|
+
}
|
|
386
|
+
case "repinVersion": {
|
|
387
|
+
let e = h.targetId, n = h.version;
|
|
388
|
+
return typeof e != "string" || e.length === 0 ? c(400, { error: "targetId required" }, d) : typeof n != "number" || !Number.isInteger(n) || n < 1 ? c(400, { error: "version must be a positive integer" }, d) : (await t.webhookActions.updateTargetPayloadVersion(e, n), c(200, { ok: !0 }, d));
|
|
389
|
+
}
|
|
390
|
+
default: return c(404, { error: `unknown webhook action: ${g}` }, d);
|
|
391
|
+
}
|
|
392
|
+
} catch (e) {
|
|
393
|
+
return c(500, {
|
|
394
|
+
error: "webhook action failed",
|
|
395
|
+
message: e?.message ?? String(e)
|
|
396
|
+
}, d);
|
|
397
|
+
}
|
|
398
|
+
}, O = async (e, t, n, a, s = {}) => {
|
|
399
|
+
let l = v(e);
|
|
400
|
+
if (!b(l)) return null;
|
|
401
|
+
let d = u(n.origin ?? n.Origin), f = (s.method ?? "POST").toUpperCase();
|
|
402
|
+
if (f !== "POST") return null;
|
|
403
|
+
if (i()) return c(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, d);
|
|
404
|
+
let p = (s.authResolver ?? o)(n, f);
|
|
405
|
+
if (!p.ok) return c(401, {
|
|
406
|
+
error: "unauthorized",
|
|
407
|
+
reason: p.reason
|
|
408
|
+
}, d);
|
|
409
|
+
if (t.kind !== "api") return c(404, { error: "framework-action endpoints are api-only" }, d);
|
|
410
|
+
let m = `${r}/seeds/run`, h = `${r}/migrations/rollback`, g = `${r}/migrations/squash`, _ = `${r}/migrations/restore-snapshot`;
|
|
411
|
+
if (l !== m && l !== h && l !== g && l !== _ && l !== "/_voltro/inspect/migrations/compare-env") return null;
|
|
412
|
+
let y;
|
|
413
|
+
try {
|
|
414
|
+
y = JSON.parse(a || "{}");
|
|
415
|
+
} catch {
|
|
416
|
+
return c(400, { error: "body must be JSON" }, d);
|
|
417
|
+
}
|
|
418
|
+
try {
|
|
419
|
+
if (l === m) return typeof y.id != "string" || y.id.length === 0 ? c(400, { error: "body.id must be a non-empty string" }, d) : t.runSeed ? c(200, await t.runSeed(y.id), d) : c(404, { error: "runSeed not configured" }, d);
|
|
420
|
+
if (l === h) return typeof y.id != "string" || y.id.length === 0 ? c(400, { error: "body.id must be a non-empty string" }, d) : t.rollbackMigration ? c(200, await t.rollbackMigration(y.id), d) : c(404, { error: "rollbackMigration not configured" }, d);
|
|
421
|
+
if (l === g) {
|
|
422
|
+
if (typeof y.before != "string" || y.before.length === 0) return c(400, { error: "body.before must be a non-empty ISO date string" }, d);
|
|
423
|
+
if (!t.squashMigrationHistory) return c(404, { error: "squashMigrationHistory not configured" }, d);
|
|
424
|
+
let e = typeof y.note == "string" ? y.note : void 0;
|
|
425
|
+
return c(200, await t.squashMigrationHistory({
|
|
426
|
+
before: y.before,
|
|
427
|
+
note: e
|
|
428
|
+
}), d);
|
|
429
|
+
}
|
|
430
|
+
return l === _ ? typeof y.planId != "string" || y.planId.length === 0 ? c(400, { error: "body.planId must be a non-empty string" }, d) : t.restoreSnapshot ? c(200, await t.restoreSnapshot({ planId: y.planId }), d) : c(404, { error: "restoreSnapshot not configured" }, d) : typeof y.url != "string" || y.url.length === 0 ? c(400, { error: "body.url must be a non-empty URL string" }, d) : t.compareCrossEnv ? (await t.compareCrossEnv({
|
|
431
|
+
url: y.url,
|
|
432
|
+
label: typeof y.label == "string" ? y.label : void 0,
|
|
433
|
+
token: typeof y.token == "string" ? y.token : void 0
|
|
434
|
+
}), c(200, { ok: !0 }, d)) : c(404, { error: "compareCrossEnv not configured" }, d);
|
|
435
|
+
} catch (e) {
|
|
436
|
+
return c(500, {
|
|
437
|
+
error: "framework action failed",
|
|
438
|
+
message: e?.message ?? String(e)
|
|
439
|
+
}, d);
|
|
440
|
+
}
|
|
441
|
+
}, k = async (e, t, n, r = {}) => {
|
|
442
|
+
if (v(e) !== "/_voltro/inspect/data/rows") return null;
|
|
443
|
+
let a = u(n.origin ?? n.Origin), s = (r.method ?? "GET").toUpperCase();
|
|
444
|
+
if (s !== "GET") return c(405, {
|
|
445
|
+
error: "method not allowed",
|
|
446
|
+
expected: "GET"
|
|
447
|
+
}, a);
|
|
448
|
+
if (i()) return c(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, a);
|
|
449
|
+
let l = (r.authResolver ?? o)(n, s);
|
|
450
|
+
if (!l.ok) return c(401, {
|
|
451
|
+
error: "unauthorized",
|
|
452
|
+
reason: l.reason
|
|
453
|
+
}, a);
|
|
454
|
+
if (t.kind !== "api") return c(404, { error: "data viewer is api-only" }, a);
|
|
455
|
+
if (t.inspectRows === void 0) return c(404, { error: "inspectRows not configured" }, a);
|
|
456
|
+
let d = j(e), f = d.get("table");
|
|
457
|
+
if (!f) return c(400, { error: "query.table is required" }, a);
|
|
458
|
+
let p = M(d.get("offset")) ?? 0, m = M(d.get("limit")) ?? 50, h = {}, g = d.get("q");
|
|
459
|
+
if (g) {
|
|
460
|
+
if (g.length > 8192) return c(400, { error: "query.q too large" }, a);
|
|
461
|
+
try {
|
|
462
|
+
h = JSON.parse(Buffer.from(g, "base64url").toString("utf8"));
|
|
463
|
+
} catch {
|
|
464
|
+
return c(400, { error: "query.q is not valid base64url JSON" }, a);
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
try {
|
|
468
|
+
return c(200, await t.inspectRows({
|
|
469
|
+
table: f,
|
|
470
|
+
offset: p,
|
|
471
|
+
limit: m,
|
|
472
|
+
...h
|
|
473
|
+
}), a);
|
|
474
|
+
} catch (e) {
|
|
475
|
+
return e?.name === "InspectQueryError" ? c(400, {
|
|
476
|
+
error: "invalid query",
|
|
477
|
+
message: e.message
|
|
478
|
+
}, a) : c(500, {
|
|
479
|
+
error: "data-rows query failed",
|
|
480
|
+
message: e?.message ?? String(e)
|
|
481
|
+
}, a);
|
|
482
|
+
}
|
|
483
|
+
}, A = async (e, n, r, a = {}) => {
|
|
484
|
+
if (v(e) !== "/_voltro/inspect/provenance") return null;
|
|
485
|
+
let s = u(r.origin ?? r.Origin), l = (a.method ?? "GET").toUpperCase();
|
|
486
|
+
if (l !== "GET") return c(405, {
|
|
487
|
+
error: "method not allowed",
|
|
488
|
+
expected: "GET"
|
|
489
|
+
}, s);
|
|
490
|
+
if (i()) return c(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, s);
|
|
491
|
+
let d = (a.authResolver ?? o)(r, l);
|
|
492
|
+
if (!d.ok) return c(401, {
|
|
493
|
+
error: "unauthorized",
|
|
494
|
+
reason: d.reason
|
|
495
|
+
}, s);
|
|
496
|
+
let p = f(a.method, r, s);
|
|
497
|
+
if (p) return p;
|
|
498
|
+
if (n.kind !== "api") return c(404, { error: "provenance is api-only" }, s);
|
|
499
|
+
if (n.inspectRows === void 0) return c(404, { error: "inspectRows not configured" }, s);
|
|
500
|
+
let m = j(e), h = m.get("table"), g = m.get("id"), _ = m.get("column") ?? void 0;
|
|
501
|
+
if (!h || !g) return c(400, { error: "query.table and query.id are required" }, s);
|
|
502
|
+
try {
|
|
503
|
+
let e = (await n.inspectRows({
|
|
504
|
+
table: h,
|
|
505
|
+
limit: 1,
|
|
506
|
+
filter: {
|
|
507
|
+
kind: "leaf",
|
|
508
|
+
column: "id",
|
|
509
|
+
op: "eq",
|
|
510
|
+
value: g
|
|
511
|
+
}
|
|
512
|
+
})).rows[0];
|
|
513
|
+
return c(200, t(e, {
|
|
514
|
+
table: h,
|
|
515
|
+
id: g,
|
|
516
|
+
..._ === void 0 ? {} : { column: _ }
|
|
517
|
+
}), s);
|
|
518
|
+
} catch (e) {
|
|
519
|
+
return e?.name === "InspectQueryError" ? c(400, {
|
|
520
|
+
error: "invalid query",
|
|
521
|
+
message: e.message
|
|
522
|
+
}, s) : c(500, {
|
|
523
|
+
error: "provenance query failed",
|
|
524
|
+
message: e?.message ?? String(e)
|
|
525
|
+
}, s);
|
|
526
|
+
}
|
|
527
|
+
}, j = (e) => {
|
|
528
|
+
let t = e.indexOf("?");
|
|
529
|
+
return t < 0 ? new URLSearchParams() : new URLSearchParams(e.slice(t + 1));
|
|
530
|
+
}, M = (e) => {
|
|
531
|
+
if (e === null || e === "") return;
|
|
532
|
+
let t = Number(e);
|
|
533
|
+
return Number.isFinite(t) && t >= 0 ? Math.floor(t) : void 0;
|
|
534
|
+
}, N = async (e, t, n, r = {}) => {
|
|
535
|
+
if (v(e) !== "/_voltro/inspect/workflows/runs") return null;
|
|
536
|
+
let a = u(n.origin ?? n.Origin), s = (r.method ?? "GET").toUpperCase();
|
|
537
|
+
if (s !== "GET") return c(405, {
|
|
538
|
+
error: "method not allowed",
|
|
539
|
+
expected: "GET"
|
|
540
|
+
}, a);
|
|
541
|
+
if (i()) return c(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, a);
|
|
542
|
+
let l = (r.authResolver ?? o)(n, s);
|
|
543
|
+
if (!l.ok) return c(401, {
|
|
544
|
+
error: "unauthorized",
|
|
545
|
+
reason: l.reason
|
|
546
|
+
}, a);
|
|
547
|
+
if (t.kind !== "api") return c(404, { error: "workflows endpoint is api-only" }, a);
|
|
548
|
+
if (t.inspectWorkflowRuns === void 0) return c(200, {
|
|
549
|
+
runs: [],
|
|
550
|
+
total: 0,
|
|
551
|
+
offset: 0,
|
|
552
|
+
limit: 50
|
|
553
|
+
}, a);
|
|
554
|
+
let d = j(e);
|
|
555
|
+
try {
|
|
556
|
+
let e = d.get("deadLettered") === "1" || d.get("deadLettered") === "true", n = (d.get("statuses") ?? "").split(",").map((e) => e.trim()).filter((e) => e !== "");
|
|
557
|
+
return c(200, await t.inspectWorkflowRuns({
|
|
558
|
+
...d.get("tag") === null ? {} : { tag: d.get("tag") },
|
|
559
|
+
...e ? { deadLettered: !0 } : d.get("status") === null ? n.length > 0 ? { statuses: n } : {} : { status: d.get("status") },
|
|
560
|
+
...d.get("q") === null ? {} : { tagContains: d.get("q") },
|
|
561
|
+
...d.get("source") === null ? {} : { source: d.get("source") },
|
|
562
|
+
...d.get("idPrefix") === null ? {} : { idPrefix: d.get("idPrefix") },
|
|
563
|
+
...d.get("from") === null ? {} : { startedAfter: d.get("from") },
|
|
564
|
+
...d.get("to") === null ? {} : { startedBefore: d.get("to") },
|
|
565
|
+
offset: M(d.get("offset")) ?? 0,
|
|
566
|
+
limit: M(d.get("limit")) ?? 50
|
|
567
|
+
}), a);
|
|
568
|
+
} catch (e) {
|
|
569
|
+
return c(500, {
|
|
570
|
+
error: "workflow-runs query failed",
|
|
571
|
+
message: e?.message ?? String(e)
|
|
572
|
+
}, a);
|
|
573
|
+
}
|
|
574
|
+
}, P = async (e, t, n, r = {}) => {
|
|
575
|
+
if (v(e) !== "/_voltro/inspect/workflows/stats") return null;
|
|
576
|
+
let a = u(n.origin ?? n.Origin), s = (r.method ?? "GET").toUpperCase();
|
|
577
|
+
if (s !== "GET") return c(405, {
|
|
578
|
+
error: "method not allowed",
|
|
579
|
+
expected: "GET"
|
|
580
|
+
}, a);
|
|
581
|
+
if (i()) return c(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, a);
|
|
582
|
+
let l = (r.authResolver ?? o)(n, s);
|
|
583
|
+
if (!l.ok) return c(401, {
|
|
584
|
+
error: "unauthorized",
|
|
585
|
+
reason: l.reason
|
|
586
|
+
}, a);
|
|
587
|
+
if (t.kind !== "api") return c(404, { error: "workflows endpoint is api-only" }, a);
|
|
588
|
+
if (t.inspectWorkflowRunStats === void 0) return c(200, {
|
|
589
|
+
windowHours: 24,
|
|
590
|
+
bucketMinutes: 30,
|
|
591
|
+
buckets: [],
|
|
592
|
+
byTag: [],
|
|
593
|
+
total: 0,
|
|
594
|
+
truncated: !1
|
|
595
|
+
}, a);
|
|
596
|
+
let d = j(e);
|
|
597
|
+
try {
|
|
598
|
+
return c(200, await t.inspectWorkflowRunStats({
|
|
599
|
+
...d.get("tag") === null ? {} : { tag: d.get("tag") },
|
|
600
|
+
...M(d.get("hours")) === void 0 ? {} : { hours: M(d.get("hours")) }
|
|
601
|
+
}), a);
|
|
602
|
+
} catch (e) {
|
|
603
|
+
return c(500, {
|
|
604
|
+
error: "workflow-stats query failed",
|
|
605
|
+
message: e?.message ?? String(e)
|
|
606
|
+
}, a);
|
|
607
|
+
}
|
|
608
|
+
}, F = async (e, t, n, r, a = {}) => {
|
|
609
|
+
let s = v(e).match(/^\/_voltro\/inspect\/workflows\/start\/([^/]+)$/);
|
|
610
|
+
if (!s) return null;
|
|
611
|
+
let l = decodeURIComponent(s[1] ?? ""), d = u(n.origin ?? n.Origin), f = (a.method ?? "POST").toUpperCase();
|
|
612
|
+
if (f !== "POST") return c(405, {
|
|
613
|
+
error: "method not allowed",
|
|
614
|
+
expected: "POST"
|
|
615
|
+
}, d);
|
|
616
|
+
if (i()) return c(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, d);
|
|
617
|
+
let p = (a.authResolver ?? o)(n, f);
|
|
618
|
+
if (!p.ok) return c(401, {
|
|
619
|
+
error: "unauthorized",
|
|
620
|
+
reason: p.reason
|
|
621
|
+
}, d);
|
|
622
|
+
if (t.kind !== "api") return c(404, { error: "workflow start is api-only" }, d);
|
|
623
|
+
if (t.inspectStartWorkflow === void 0) return c(404, { error: "inspectStartWorkflow not configured" }, d);
|
|
624
|
+
let m = {};
|
|
625
|
+
if (r.length > 0) try {
|
|
626
|
+
m = JSON.parse(r).payload ?? {};
|
|
627
|
+
} catch {
|
|
628
|
+
return c(400, { error: "start requires JSON body `{ payload?: unknown }`" }, d);
|
|
629
|
+
}
|
|
630
|
+
try {
|
|
631
|
+
return c(200, await t.inspectStartWorkflow({
|
|
632
|
+
name: l,
|
|
633
|
+
payload: m
|
|
634
|
+
}), d);
|
|
635
|
+
} catch (e) {
|
|
636
|
+
return c(500, {
|
|
637
|
+
error: "workflow start failed",
|
|
638
|
+
message: e?.message ?? String(e)
|
|
639
|
+
}, d);
|
|
640
|
+
}
|
|
641
|
+
}, I = async (e, t, n, r = {}) => {
|
|
642
|
+
let a = v(e);
|
|
643
|
+
if (!a.startsWith("/_voltro/inspect/schedules")) return null;
|
|
644
|
+
let s = u(n.origin ?? n.Origin);
|
|
645
|
+
if (i()) return c(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, s);
|
|
646
|
+
let l = (r.authResolver ?? o)(n, r.method ?? "POST");
|
|
647
|
+
if (!l.ok) return c(401, {
|
|
648
|
+
error: "unauthorized",
|
|
649
|
+
reason: l.reason
|
|
650
|
+
}, s);
|
|
651
|
+
let d = f(r.method, n, s);
|
|
652
|
+
if (d) return d;
|
|
653
|
+
if (t.kind !== "api") return c(404, { error: "schedules are api-only" }, s);
|
|
654
|
+
let p = (r.method ?? "GET").toUpperCase(), m = a.match(/^\/_voltro\/inspect\/schedules\/([^/]+)\/backfill$/);
|
|
655
|
+
if (m) {
|
|
656
|
+
if (p !== "POST") return c(405, {
|
|
657
|
+
error: "method not allowed",
|
|
658
|
+
expected: "POST"
|
|
659
|
+
}, s);
|
|
660
|
+
if (!t.inspectBackfillSchedule) return c(404, { error: "inspectBackfillSchedule not configured" }, s);
|
|
661
|
+
let e = decodeURIComponent(m[1] ?? ""), n;
|
|
662
|
+
try {
|
|
663
|
+
n = JSON.parse(r.body ?? "{}");
|
|
664
|
+
} catch {
|
|
665
|
+
return c(400, { error: "invalid JSON body — expected { from, to, confirm?, limit? }" }, s);
|
|
666
|
+
}
|
|
667
|
+
if (typeof n.from != "string" || typeof n.to != "string") return c(400, { error: "body must carry ISO 'from' and 'to' instants" }, s);
|
|
668
|
+
try {
|
|
669
|
+
let r = await t.inspectBackfillSchedule({
|
|
670
|
+
name: e,
|
|
671
|
+
from: n.from,
|
|
672
|
+
to: n.to,
|
|
673
|
+
confirm: n.confirm === !0,
|
|
674
|
+
...typeof n.limit == "number" ? { limit: n.limit } : {}
|
|
675
|
+
});
|
|
676
|
+
return c(r.kind === "refused" ? 409 : 200, r, s);
|
|
677
|
+
} catch (e) {
|
|
678
|
+
return c(500, {
|
|
679
|
+
error: "backfill failed",
|
|
680
|
+
message: e?.message ?? String(e)
|
|
681
|
+
}, s);
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
let h = a.match(/^\/_voltro\/inspect\/schedules\/([^/]+)\/fire$/);
|
|
685
|
+
if (h) {
|
|
686
|
+
if (p !== "POST") return c(405, {
|
|
687
|
+
error: "method not allowed",
|
|
688
|
+
expected: "POST"
|
|
689
|
+
}, s);
|
|
690
|
+
if (!t.inspectFireSchedule) return c(404, { error: "inspectFireSchedule not configured" }, s);
|
|
691
|
+
let n = decodeURIComponent(h[1] ?? ""), r = j(e).get("trigger") === "external" ? "external" : "manual";
|
|
692
|
+
try {
|
|
693
|
+
return c(200, await t.inspectFireSchedule({
|
|
694
|
+
name: n,
|
|
695
|
+
trigger: r
|
|
696
|
+
}), s);
|
|
697
|
+
} catch (e) {
|
|
698
|
+
return c(500, {
|
|
699
|
+
error: "fire failed",
|
|
700
|
+
message: e?.message ?? String(e)
|
|
701
|
+
}, s);
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
if (a === "/_voltro/inspect/schedules/runs") {
|
|
705
|
+
if (p !== "GET") return c(405, {
|
|
706
|
+
error: "method not allowed",
|
|
707
|
+
expected: "GET"
|
|
708
|
+
}, s);
|
|
709
|
+
if (!t.inspectScheduleRuns) return c(200, {
|
|
710
|
+
runs: [],
|
|
711
|
+
total: 0,
|
|
712
|
+
offset: 0,
|
|
713
|
+
limit: 50
|
|
714
|
+
}, s);
|
|
715
|
+
let n = j(e);
|
|
716
|
+
try {
|
|
717
|
+
return c(200, await t.inspectScheduleRuns({
|
|
718
|
+
...n.get("name") === null ? {} : { name: n.get("name") },
|
|
719
|
+
offset: M(n.get("offset")) ?? 0,
|
|
720
|
+
limit: M(n.get("limit")) ?? 50
|
|
721
|
+
}), s);
|
|
722
|
+
} catch (e) {
|
|
723
|
+
return c(500, {
|
|
724
|
+
error: "schedule-runs query failed",
|
|
725
|
+
message: e?.message ?? String(e)
|
|
726
|
+
}, s);
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
return a === "/_voltro/inspect/schedules" ? p === "GET" ? t.inspectSchedules ? c(200, t.inspectSchedules(), s) : c(200, {
|
|
730
|
+
schedules: [],
|
|
731
|
+
coordination: "single"
|
|
732
|
+
}, s) : c(405, {
|
|
733
|
+
error: "method not allowed",
|
|
734
|
+
expected: "GET"
|
|
735
|
+
}, s) : c(404, {
|
|
736
|
+
error: "unknown schedules endpoint",
|
|
737
|
+
path: a
|
|
738
|
+
}, s);
|
|
739
|
+
}, L = async (e, t, n, r = {}) => {
|
|
740
|
+
if (v(e) !== "/_voltro/inspect/cluster") return null;
|
|
741
|
+
let a = u(n.origin ?? n.Origin);
|
|
742
|
+
if (i()) return c(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, a);
|
|
743
|
+
let s = (r.authResolver ?? o)(n, r.method ?? "POST");
|
|
744
|
+
if (!s.ok) return c(401, {
|
|
745
|
+
error: "unauthorized",
|
|
746
|
+
reason: s.reason
|
|
747
|
+
}, a);
|
|
748
|
+
let l = f(r.method, n, a);
|
|
749
|
+
if (l) return l;
|
|
750
|
+
if (t.kind !== "api") return c(404, { error: "cluster is api-only" }, a);
|
|
751
|
+
if ((r.method ?? "GET").toUpperCase() !== "GET") return c(405, {
|
|
752
|
+
error: "method not allowed",
|
|
753
|
+
expected: "GET"
|
|
754
|
+
}, a);
|
|
755
|
+
if (!t.cluster) return c(200, {
|
|
756
|
+
instance: {
|
|
757
|
+
replicaId: process.env.POD_NAME ?? process.env.HOSTNAME ?? `dev-${process.pid}`,
|
|
758
|
+
dialect: "memory",
|
|
759
|
+
runnerHost: "localhost",
|
|
760
|
+
runnerPort: 0,
|
|
761
|
+
runnerStorage: "none",
|
|
762
|
+
shardLock: "none",
|
|
763
|
+
coordination: "single",
|
|
764
|
+
cdc: {
|
|
765
|
+
enabled: !1,
|
|
766
|
+
flavor: "none (single-process)"
|
|
767
|
+
},
|
|
768
|
+
tier: "none",
|
|
769
|
+
localhostRisk: !1
|
|
770
|
+
},
|
|
771
|
+
coordinationState: {
|
|
772
|
+
recentReplicaIds: [],
|
|
773
|
+
scheduleClaims: [],
|
|
774
|
+
runningScheduleRuns: 0,
|
|
775
|
+
runningWorkflowRuns: 0
|
|
776
|
+
},
|
|
777
|
+
capturedAt: Date.now()
|
|
778
|
+
}, a);
|
|
779
|
+
try {
|
|
780
|
+
return c(200, await t.cluster(), a);
|
|
781
|
+
} catch (e) {
|
|
782
|
+
return c(500, {
|
|
783
|
+
error: "cluster snapshot failed",
|
|
784
|
+
message: e?.message ?? String(e)
|
|
785
|
+
}, a);
|
|
786
|
+
}
|
|
787
|
+
}, R = async (e, t, n, r = {}) => {
|
|
788
|
+
let a = v(e).match(/^\/_voltro\/inspect\/workflows\/runs\/([^/]+)\/steps$/);
|
|
789
|
+
if (!a) return null;
|
|
790
|
+
let s = decodeURIComponent(a[1] ?? ""), l = u(n.origin ?? n.Origin), d = (r.method ?? "GET").toUpperCase();
|
|
791
|
+
if (d !== "GET") return c(405, {
|
|
792
|
+
error: "method not allowed",
|
|
793
|
+
expected: "GET"
|
|
794
|
+
}, l);
|
|
795
|
+
if (i()) return c(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, l);
|
|
796
|
+
let f = (r.authResolver ?? o)(n, d);
|
|
797
|
+
if (!f.ok) return c(401, {
|
|
798
|
+
error: "unauthorized",
|
|
799
|
+
reason: f.reason
|
|
800
|
+
}, l);
|
|
801
|
+
if (t.kind !== "api") return c(404, { error: "workflow steps are api-only" }, l);
|
|
802
|
+
if (t.inspectWorkflowRunSteps === void 0) return c(200, { steps: [] }, l);
|
|
803
|
+
try {
|
|
804
|
+
return c(200, await t.inspectWorkflowRunSteps({ runId: s }), l);
|
|
805
|
+
} catch (e) {
|
|
806
|
+
return c(500, {
|
|
807
|
+
error: "steps query failed",
|
|
808
|
+
message: e?.message ?? String(e)
|
|
809
|
+
}, l);
|
|
810
|
+
}
|
|
811
|
+
}, z = async (e, t, n, r = {}) => {
|
|
812
|
+
let a = v(e).match(/^\/_voltro\/inspect\/workflows\/runs\/([^/]+)\/events$/);
|
|
813
|
+
if (!a) return null;
|
|
814
|
+
let s = decodeURIComponent(a[1] ?? ""), l = u(n.origin ?? n.Origin), d = (r.method ?? "GET").toUpperCase();
|
|
815
|
+
if (d !== "GET") return c(405, {
|
|
816
|
+
error: "method not allowed",
|
|
817
|
+
expected: "GET"
|
|
818
|
+
}, l);
|
|
819
|
+
if (i()) return c(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, l);
|
|
820
|
+
let f = (r.authResolver ?? o)(n, d);
|
|
821
|
+
if (!f.ok) return c(401, {
|
|
822
|
+
error: "unauthorized",
|
|
823
|
+
reason: f.reason
|
|
824
|
+
}, l);
|
|
825
|
+
if (t.kind !== "api") return c(404, { error: "workflow events are api-only" }, l);
|
|
826
|
+
if (t.inspectWorkflowRunEvents === void 0) return c(200, { events: [] }, l);
|
|
827
|
+
try {
|
|
828
|
+
return c(200, await t.inspectWorkflowRunEvents({ runId: s }), l);
|
|
829
|
+
} catch (e) {
|
|
830
|
+
return c(500, {
|
|
831
|
+
error: "events query failed",
|
|
832
|
+
message: e?.message ?? String(e)
|
|
833
|
+
}, l);
|
|
834
|
+
}
|
|
835
|
+
}, B = async (e, t, n, r = {}) => {
|
|
836
|
+
if (v(t) !== "/_voltro/inspect/workflows/events") return null;
|
|
837
|
+
let a = u(n.origin ?? n.Origin), s = (r.method ?? "GET").toUpperCase();
|
|
838
|
+
if (s !== "GET") return c(405, {
|
|
839
|
+
error: "method not allowed",
|
|
840
|
+
expected: "GET"
|
|
841
|
+
}, a);
|
|
842
|
+
if (i()) return c(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, a);
|
|
843
|
+
let l = (r.authResolver ?? o)(n, s);
|
|
844
|
+
if (!l.ok) return c(401, {
|
|
845
|
+
error: "unauthorized",
|
|
846
|
+
reason: l.reason
|
|
847
|
+
}, a);
|
|
848
|
+
if (e.kind !== "api") return c(404, { error: "workflow domain events are api-only" }, a);
|
|
849
|
+
if (e.inspectWorkflowDomainEvents === void 0) return c(200, {
|
|
850
|
+
events: [],
|
|
851
|
+
total: 0,
|
|
852
|
+
offset: 0,
|
|
853
|
+
limit: 100
|
|
854
|
+
}, a);
|
|
855
|
+
let d = y(t), f = d.get("name") ?? void 0, p = Number(d.get("offset") ?? "0"), m = Number(d.get("limit") ?? "100");
|
|
856
|
+
try {
|
|
857
|
+
return c(200, await e.inspectWorkflowDomainEvents({
|
|
858
|
+
...f !== void 0 && f !== "" ? { name: f } : {},
|
|
859
|
+
offset: Number.isFinite(p) ? p : 0,
|
|
860
|
+
limit: Number.isFinite(m) ? m : 100
|
|
861
|
+
}), a);
|
|
862
|
+
} catch (e) {
|
|
863
|
+
return c(500, {
|
|
864
|
+
error: "workflow domain events query failed",
|
|
865
|
+
message: e?.message ?? String(e)
|
|
866
|
+
}, a);
|
|
867
|
+
}
|
|
868
|
+
}, V = async (e, t, n, r = {}) => {
|
|
869
|
+
let a = v(t).match(/^\/_voltro\/inspect\/workflows\/events\/([^/]+)\/deliveries$/);
|
|
870
|
+
if (!a) return null;
|
|
871
|
+
let s = decodeURIComponent(a[1] ?? ""), l = u(n.origin ?? n.Origin), d = (r.method ?? "GET").toUpperCase();
|
|
872
|
+
if (d !== "GET") return c(405, {
|
|
873
|
+
error: "method not allowed",
|
|
874
|
+
expected: "GET"
|
|
875
|
+
}, l);
|
|
876
|
+
if (i()) return c(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, l);
|
|
877
|
+
let f = (r.authResolver ?? o)(n, d);
|
|
878
|
+
if (!f.ok) return c(401, {
|
|
879
|
+
error: "unauthorized",
|
|
880
|
+
reason: f.reason
|
|
881
|
+
}, l);
|
|
882
|
+
if (e.kind !== "api") return c(404, { error: "workflow event deliveries are api-only" }, l);
|
|
883
|
+
if (e.inspectWorkflowEventDeliveries === void 0) return c(200, { deliveries: [] }, l);
|
|
884
|
+
try {
|
|
885
|
+
return c(200, await e.inspectWorkflowEventDeliveries({ eventId: s }), l);
|
|
886
|
+
} catch (e) {
|
|
887
|
+
return c(500, {
|
|
888
|
+
error: "workflow event deliveries query failed",
|
|
889
|
+
message: e?.message ?? String(e)
|
|
890
|
+
}, l);
|
|
891
|
+
}
|
|
892
|
+
}, H = async (e, t, n, r = {}) => {
|
|
893
|
+
if (v(e) !== "/_voltro/inspect/workflows/children") return null;
|
|
894
|
+
let a = u(n.origin ?? n.Origin), s = (r.method ?? "GET").toUpperCase();
|
|
895
|
+
if (s !== "GET") return c(405, {
|
|
896
|
+
error: "method not allowed",
|
|
897
|
+
expected: "GET"
|
|
898
|
+
}, a);
|
|
899
|
+
if (i()) return c(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, a);
|
|
900
|
+
let l = (r.authResolver ?? o)(n, s);
|
|
901
|
+
if (!l.ok) return c(401, {
|
|
902
|
+
error: "unauthorized",
|
|
903
|
+
reason: l.reason
|
|
904
|
+
}, a);
|
|
905
|
+
if (t.kind !== "api") return c(404, { error: "workflow children are api-only" }, a);
|
|
906
|
+
let d = j(e).get("parentExecutionId");
|
|
907
|
+
if (d === null || d === "") return c(400, { error: "parentExecutionId query param required" }, a);
|
|
908
|
+
if (t.inspectWorkflowChildren === void 0) return c(200, {
|
|
909
|
+
runs: [],
|
|
910
|
+
total: 0,
|
|
911
|
+
offset: 0,
|
|
912
|
+
limit: 200
|
|
913
|
+
}, a);
|
|
914
|
+
try {
|
|
915
|
+
return c(200, await t.inspectWorkflowChildren({ parentExecutionId: d }), a);
|
|
916
|
+
} catch (e) {
|
|
917
|
+
return c(500, {
|
|
918
|
+
error: "children query failed",
|
|
919
|
+
message: e?.message ?? String(e)
|
|
920
|
+
}, a);
|
|
921
|
+
}
|
|
922
|
+
}, U = async (e, t, n, r, a = {}) => {
|
|
923
|
+
let s = v(e).match(/^\/_voltro\/inspect\/workflows\/runs\/([^/]+)\/(cancel|retry|suspend|resume-from-step|resume|signal|update|discard|redrive)$/);
|
|
924
|
+
if (!s) return null;
|
|
925
|
+
let l = decodeURIComponent(s[1] ?? ""), d = s[2], f = u(n.origin ?? n.Origin), p = (a.method ?? "POST").toUpperCase();
|
|
926
|
+
if (p !== "POST") return c(405, {
|
|
927
|
+
error: "method not allowed",
|
|
928
|
+
expected: "POST"
|
|
929
|
+
}, f);
|
|
930
|
+
if (i()) return c(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, f);
|
|
931
|
+
let m = (a.authResolver ?? o)(n, p);
|
|
932
|
+
if (!m.ok) return c(401, {
|
|
933
|
+
error: "unauthorized",
|
|
934
|
+
reason: m.reason
|
|
935
|
+
}, f);
|
|
936
|
+
if (t.kind !== "api") return c(404, { error: "workflow actions are api-only" }, f);
|
|
937
|
+
let h = {
|
|
938
|
+
cancel: t.inspectCancelWorkflowRun,
|
|
939
|
+
retry: t.inspectRetryWorkflowRun,
|
|
940
|
+
suspend: t.inspectSuspendWorkflowRun,
|
|
941
|
+
resume: t.inspectResumeWorkflowRun,
|
|
942
|
+
signal: t.inspectSignalWorkflowRun,
|
|
943
|
+
update: t.inspectUpdateWorkflowRun,
|
|
944
|
+
discard: t.inspectDiscardWorkflowRun,
|
|
945
|
+
redrive: t.inspectRedriveWorkflowRun,
|
|
946
|
+
"resume-from-step": t.inspectResumeWorkflowRunFromStep
|
|
947
|
+
}[d];
|
|
948
|
+
if (!h) return c(404, { error: d === "resume-from-step" ? "inspectResumeWorkflowRunFromStep not configured" : `inspect${d[0]?.toUpperCase() ?? ""}${d.slice(1)}WorkflowRun not configured` }, f);
|
|
949
|
+
let g, _, y, b, x, S, C;
|
|
950
|
+
if (r.length > 0) try {
|
|
951
|
+
let e = JSON.parse(r);
|
|
952
|
+
d === "retry" && (g = e.payloadOverride), d === "resume-from-step" && typeof e.step == "string" && e.step.length > 0 && (C = e.step), d === "signal" && (typeof e.signalName == "string" && e.signalName.length > 0 && (_ = e.signalName), y = e.payload), d === "update" && (typeof e.updateName == "string" && e.updateName.length > 0 && (b = e.updateName), x = e.payload, typeof e.timeoutMs == "number" && Number.isFinite(e.timeoutMs) && (S = e.timeoutMs));
|
|
953
|
+
} catch {}
|
|
954
|
+
if (d === "signal" && _ === void 0) return c(400, { error: "signal requires JSON body `{ signalName: string, payload?: unknown }`" }, f);
|
|
955
|
+
if (d === "update" && b === void 0) return c(400, { error: "update requires JSON body `{ updateName: string, payload?: unknown, timeoutMs?: number }`" }, f);
|
|
956
|
+
if (d === "resume-from-step" && C === void 0) return c(400, { error: "resume-from-step requires JSON body `{ step: string }` (the step name to rewind to)" }, f);
|
|
957
|
+
try {
|
|
958
|
+
return c(200, d === "retry" && g !== void 0 ? await h({
|
|
959
|
+
runId: l,
|
|
960
|
+
payloadOverride: g
|
|
961
|
+
}) : d === "signal" ? await h({
|
|
962
|
+
runId: l,
|
|
963
|
+
signalName: _,
|
|
964
|
+
payload: y
|
|
965
|
+
}) : d === "update" ? await h({
|
|
966
|
+
runId: l,
|
|
967
|
+
updateName: b,
|
|
968
|
+
payload: x,
|
|
969
|
+
...S === void 0 ? {} : { timeoutMs: S }
|
|
970
|
+
}) : d === "resume-from-step" ? await h({
|
|
971
|
+
runId: l,
|
|
972
|
+
step: C
|
|
973
|
+
}) : await h({ runId: l }), f);
|
|
974
|
+
} catch (e) {
|
|
975
|
+
return c(500, {
|
|
976
|
+
error: `${d} failed`,
|
|
977
|
+
message: e?.message ?? String(e)
|
|
978
|
+
}, f);
|
|
979
|
+
}
|
|
980
|
+
}, W = async (e, t, n, r, a = {}) => {
|
|
981
|
+
if (v(e) !== "/_voltro/inspect/data/import" || (a.method ?? "POST").toUpperCase() !== "POST") return null;
|
|
982
|
+
let s = u(n.origin ?? n.Origin);
|
|
983
|
+
if (i()) return c(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, s);
|
|
984
|
+
let l = (a.authResolver ?? o)(n, "POST");
|
|
985
|
+
if (!l.ok) return c(401, {
|
|
986
|
+
error: "unauthorized",
|
|
987
|
+
reason: l.reason
|
|
988
|
+
}, s);
|
|
989
|
+
let d = f(a.method, n, s);
|
|
990
|
+
if (d) return d;
|
|
991
|
+
if (t.kind !== "api") return c(404, { error: "data import is api-only" }, s);
|
|
992
|
+
if (!t.inspectImport) return c(404, { error: "inspectImport not configured" }, s);
|
|
993
|
+
let p;
|
|
994
|
+
try {
|
|
995
|
+
p = JSON.parse(r || "{}");
|
|
996
|
+
} catch {
|
|
997
|
+
return c(400, { error: "body must be JSON" }, s);
|
|
998
|
+
}
|
|
999
|
+
if (typeof p.bundleDir != "string" || !p.bundleDir) return c(400, { error: "body.bundleDir (string) is required" }, s);
|
|
1000
|
+
try {
|
|
1001
|
+
return c(200, await t.inspectImport({
|
|
1002
|
+
bundleDir: p.bundleDir,
|
|
1003
|
+
...p.mode === "upsert" || p.mode === "append" || p.mode === "replace" ? { mode: p.mode } : {},
|
|
1004
|
+
...p.onConflict === "skip" || p.onConflict === "fail" ? { onConflict: p.onConflict } : {},
|
|
1005
|
+
...typeof p.atomic == "boolean" ? { atomic: p.atomic } : {}
|
|
1006
|
+
}), s);
|
|
1007
|
+
} catch (e) {
|
|
1008
|
+
return c(500, {
|
|
1009
|
+
error: "import failed",
|
|
1010
|
+
message: e?.message ?? String(e)
|
|
1011
|
+
}, s);
|
|
1012
|
+
}
|
|
1013
|
+
}, G = async (e, t, n, r, a = {}) => {
|
|
1014
|
+
let s = v(e);
|
|
1015
|
+
if (!s.startsWith("/_voltro/inspect/data/rows")) return null;
|
|
1016
|
+
let l = (a.method ?? "POST").toUpperCase();
|
|
1017
|
+
if (l === "GET" && s === "/_voltro/inspect/data/rows") return null;
|
|
1018
|
+
let d = u(n.origin ?? n.Origin);
|
|
1019
|
+
if (i()) return c(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, d);
|
|
1020
|
+
let f = (a.authResolver ?? o)(n, l);
|
|
1021
|
+
if (!f.ok) return c(401, {
|
|
1022
|
+
error: "unauthorized",
|
|
1023
|
+
reason: f.reason
|
|
1024
|
+
}, d);
|
|
1025
|
+
if (t.kind !== "api") return c(404, { error: "data viewer is api-only" }, d);
|
|
1026
|
+
if (l === "POST" && s === "/_voltro/inspect/data/rows") {
|
|
1027
|
+
if (!t.inspectInsertRow) return c(404, { error: "inspectInsertRow not configured" }, d);
|
|
1028
|
+
let e;
|
|
1029
|
+
try {
|
|
1030
|
+
e = JSON.parse(r || "{}");
|
|
1031
|
+
} catch {
|
|
1032
|
+
return c(400, { error: "body must be JSON" }, d);
|
|
1033
|
+
}
|
|
1034
|
+
if (typeof e.table != "string" || !e.row || typeof e.row != "object") return c(400, { error: "body must be { table: string, row: object }" }, d);
|
|
1035
|
+
try {
|
|
1036
|
+
return c(200, await t.inspectInsertRow({
|
|
1037
|
+
table: e.table,
|
|
1038
|
+
row: e.row
|
|
1039
|
+
}), d);
|
|
1040
|
+
} catch (e) {
|
|
1041
|
+
return c(500, {
|
|
1042
|
+
error: "insert failed",
|
|
1043
|
+
message: e?.message ?? String(e)
|
|
1044
|
+
}, d);
|
|
1045
|
+
}
|
|
1046
|
+
}
|
|
1047
|
+
let p = s.match(/^\/_voltro\/inspect\/data\/rows\/([^/]+)$/);
|
|
1048
|
+
if (!p) return null;
|
|
1049
|
+
let m = decodeURIComponent(p[1] ?? "");
|
|
1050
|
+
if (!m) return c(400, { error: "row id is required in URL" }, d);
|
|
1051
|
+
let h = j(e).get("table") ?? "";
|
|
1052
|
+
if (!h) return c(400, { error: "query.table is required" }, d);
|
|
1053
|
+
if (l === "PATCH") {
|
|
1054
|
+
if (!t.inspectUpdateRow) return c(404, { error: "inspectUpdateRow not configured" }, d);
|
|
1055
|
+
let e;
|
|
1056
|
+
try {
|
|
1057
|
+
e = JSON.parse(r || "{}");
|
|
1058
|
+
} catch {
|
|
1059
|
+
return c(400, { error: "body must be JSON" }, d);
|
|
1060
|
+
}
|
|
1061
|
+
if (!e.patch || typeof e.patch != "object") return c(400, { error: "body.patch must be an object" }, d);
|
|
1062
|
+
try {
|
|
1063
|
+
return c(200, await t.inspectUpdateRow({
|
|
1064
|
+
table: h,
|
|
1065
|
+
id: m,
|
|
1066
|
+
patch: e.patch
|
|
1067
|
+
}), d);
|
|
1068
|
+
} catch (e) {
|
|
1069
|
+
return c(500, {
|
|
1070
|
+
error: "update failed",
|
|
1071
|
+
message: e?.message ?? String(e)
|
|
1072
|
+
}, d);
|
|
1073
|
+
}
|
|
1074
|
+
}
|
|
1075
|
+
if (l === "DELETE") {
|
|
1076
|
+
if (!t.inspectDeleteRow) return c(404, { error: "inspectDeleteRow not configured" }, d);
|
|
1077
|
+
try {
|
|
1078
|
+
return c(200, await t.inspectDeleteRow({
|
|
1079
|
+
table: h,
|
|
1080
|
+
id: m
|
|
1081
|
+
}), d);
|
|
1082
|
+
} catch (e) {
|
|
1083
|
+
return c(500, {
|
|
1084
|
+
error: "delete failed",
|
|
1085
|
+
message: e?.message ?? String(e)
|
|
1086
|
+
}, d);
|
|
1087
|
+
}
|
|
1088
|
+
}
|
|
1089
|
+
return c(405, {
|
|
1090
|
+
error: "method not allowed",
|
|
1091
|
+
expected: "POST | PATCH | DELETE"
|
|
1092
|
+
}, d);
|
|
1093
|
+
}, K = async (e, t, n, a, s = {}) => {
|
|
1094
|
+
let l = v(e), d = `${r}/workflows/flow-control`;
|
|
1095
|
+
if (l !== d && !l.startsWith(`${d}/`)) return null;
|
|
1096
|
+
let f = u(n.origin ?? n.Origin), p = (s.method ?? "GET").toUpperCase();
|
|
1097
|
+
if (i()) return c(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, f);
|
|
1098
|
+
let m = (s.authResolver ?? o)(n, p);
|
|
1099
|
+
if (!m.ok) return c(401, {
|
|
1100
|
+
error: "unauthorized",
|
|
1101
|
+
reason: m.reason
|
|
1102
|
+
}, f);
|
|
1103
|
+
if (t.kind !== "api") return c(404, { error: "flow control is api-only" }, f);
|
|
1104
|
+
if (l === `${d}/inferences`) {
|
|
1105
|
+
if (p !== "GET") return c(405, {
|
|
1106
|
+
error: "method not allowed",
|
|
1107
|
+
expected: "GET"
|
|
1108
|
+
}, f);
|
|
1109
|
+
if (t.inspectInferences === void 0) return c(404, { error: "inspectInferences not configured" }, f);
|
|
1110
|
+
let n = j(e).get("limit"), r = n === null ? void 0 : Number(n);
|
|
1111
|
+
try {
|
|
1112
|
+
return c(200, await t.inspectInferences(r !== void 0 && Number.isFinite(r) ? { limit: r } : {}), f);
|
|
1113
|
+
} catch (e) {
|
|
1114
|
+
return c(500, {
|
|
1115
|
+
error: "inference queue read failed",
|
|
1116
|
+
message: e?.message ?? String(e)
|
|
1117
|
+
}, f);
|
|
1118
|
+
}
|
|
1119
|
+
}
|
|
1120
|
+
if (l === d) {
|
|
1121
|
+
if (p !== "GET") return c(405, {
|
|
1122
|
+
error: "method not allowed",
|
|
1123
|
+
expected: "GET"
|
|
1124
|
+
}, f);
|
|
1125
|
+
if (t.inspectFlowControl === void 0) return c(404, { error: "inspectFlowControl not configured" }, f);
|
|
1126
|
+
let n = j(e).get("limit"), r = n === null ? void 0 : Number(n);
|
|
1127
|
+
try {
|
|
1128
|
+
return c(200, await t.inspectFlowControl(r !== void 0 && Number.isFinite(r) ? { limit: r } : {}), f);
|
|
1129
|
+
} catch (e) {
|
|
1130
|
+
return c(500, {
|
|
1131
|
+
error: "flow control read failed",
|
|
1132
|
+
message: e?.message ?? String(e)
|
|
1133
|
+
}, f);
|
|
1134
|
+
}
|
|
1135
|
+
}
|
|
1136
|
+
if (p !== "POST") return c(405, {
|
|
1137
|
+
error: "method not allowed",
|
|
1138
|
+
expected: "POST"
|
|
1139
|
+
}, f);
|
|
1140
|
+
let h = {};
|
|
1141
|
+
if (a.length > 0) try {
|
|
1142
|
+
h = JSON.parse(a);
|
|
1143
|
+
} catch {
|
|
1144
|
+
return c(400, { error: "expected a JSON body" }, f);
|
|
1145
|
+
}
|
|
1146
|
+
let g = l.slice(d.length + 1);
|
|
1147
|
+
try {
|
|
1148
|
+
if (g === "pause") return t.inspectPauseWorkflow === void 0 ? c(404, { error: "inspectPauseWorkflow not configured" }, f) : h.workflow ? c(200, await t.inspectPauseWorkflow({
|
|
1149
|
+
workflow: h.workflow,
|
|
1150
|
+
...h.reason === void 0 ? {} : { reason: h.reason }
|
|
1151
|
+
}), f) : c(400, { error: "body.workflow is required" }, f);
|
|
1152
|
+
if (g === "resume") return t.inspectResumeWorkflow === void 0 ? c(404, { error: "inspectResumeWorkflow not configured" }, f) : h.workflow ? c(200, await t.inspectResumeWorkflow({ workflow: h.workflow }), f) : c(400, { error: "body.workflow is required" }, f);
|
|
1153
|
+
if (g === "discard") return t.inspectDiscardIntent === void 0 ? c(404, { error: "inspectDiscardIntent not configured" }, f) : h.intentId ? c(200, await t.inspectDiscardIntent({ intentId: h.intentId }), f) : c(400, { error: "body.intentId is required" }, f);
|
|
1154
|
+
if (g === "bulk") {
|
|
1155
|
+
if (t.inspectBulkWorkflowRuns === void 0) return c(404, { error: "inspectBulkWorkflowRuns not configured" }, f);
|
|
1156
|
+
if (h.op !== "cancel" && h.op !== "replay") return c(400, { error: "body.op must be 'cancel' or 'replay'" }, f);
|
|
1157
|
+
if (typeof h.limit != "number") return c(400, { error: "body.limit is required — a bulk operation has no unbounded form, the cap IS the blast radius. The response reports `truncated` when more matched." }, f);
|
|
1158
|
+
try {
|
|
1159
|
+
return c(200, await t.inspectBulkWorkflowRuns({
|
|
1160
|
+
op: h.op,
|
|
1161
|
+
limit: h.limit,
|
|
1162
|
+
...h.reason === void 0 ? {} : { reason: h.reason },
|
|
1163
|
+
...h.mode === void 0 ? {} : { mode: h.mode },
|
|
1164
|
+
...h.dryRun === void 0 ? {} : { dryRun: h.dryRun },
|
|
1165
|
+
...h.workflow === void 0 ? {} : { workflow: h.workflow },
|
|
1166
|
+
...h.status === void 0 ? {} : { status: h.status },
|
|
1167
|
+
...h.startedAfter === void 0 ? {} : { startedAfter: h.startedAfter },
|
|
1168
|
+
...h.startedBefore === void 0 ? {} : { startedBefore: h.startedBefore }
|
|
1169
|
+
}), f);
|
|
1170
|
+
} catch (e) {
|
|
1171
|
+
if (e?.name === "BulkRequestError") return c(400, { error: e.message }, f);
|
|
1172
|
+
throw e;
|
|
1173
|
+
}
|
|
1174
|
+
}
|
|
1175
|
+
} catch (e) {
|
|
1176
|
+
return c(500, {
|
|
1177
|
+
error: "flow control action failed",
|
|
1178
|
+
message: e?.message ?? String(e)
|
|
1179
|
+
}, f);
|
|
1180
|
+
}
|
|
1181
|
+
return c(404, {
|
|
1182
|
+
error: `unknown flow-control action '${g}'`,
|
|
1183
|
+
expected: [
|
|
1184
|
+
"pause",
|
|
1185
|
+
"resume",
|
|
1186
|
+
"discard",
|
|
1187
|
+
"bulk"
|
|
1188
|
+
]
|
|
1189
|
+
}, f);
|
|
1190
|
+
};
|
|
1191
|
+
//#endregion
|
|
1192
|
+
export { i as A, P as C, u as D, F as E, p as M, _ as N, g as O, s as P, z as S, N as T, D as _, o as a, B as b, W as c, K as d, O as f, I as g, C as h, f as i, l as j, d as k, k as l, A as m, x as n, E as o, T as p, S as r, L as s, r as t, G as u, U as v, R as w, V as x, H as y };
|