@voltro/cli 0.55.0 → 0.57.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 +691 -0
- package/bin/voltro.mjs +24 -0
- package/dist/apiBuild-B83Cb2Rv.js +2 -0
- package/dist/{apiBuild-CMvLJM_K.js → apiBuild-DDr2aNFd.js} +119 -88
- package/dist/bin.js +1 -1
- package/dist/{build-S0QOzqPT.js → build-QKP6Bm0J.js} +308 -279
- package/dist/buildReport-52gHKgfO.js +64 -0
- package/dist/{checkCommand-DNkY5kwF.js → checkCommand-BISqx1OJ.js} +1 -1
- package/dist/{checkCommand-fbj9GDjN.js → checkCommand-DUtMWjcR.js} +6 -6
- package/dist/{clusterCmd-DrVFCzSj.js → clusterCmd-CdLB1GkT.js} +1 -1
- package/dist/{codegen-SIepQtUl.js → codegen-Bth5lUTU.js} +2 -1
- package/dist/codegen-DbH7NbCR.js +2 -0
- package/dist/{codegenCommand-3TDJezom.js → codegenCommand-DnVuDxwT.js} +11 -11
- package/dist/{codemodRunner-C2zxZUIw.js → codemodRunner-BlQPfjzA.js} +222 -0
- package/dist/{commands-BBYJ7Q3B.js → commands-CRbxgxv0.js} +35 -35
- package/dist/{dashboardCommand-D2kmyCLL.js → dashboardCommand-Bf_-Ne3P.js} +5 -5
- package/dist/{dataCommand-BEPPQiTl.js → dataCommand-BoBJJ-Gb.js} +3 -3
- package/dist/{dbCommand-DZTmOFT4.js → dbCommand-CMAIz-Bf.js} +457 -441
- package/dist/dbCommand-DHi_RuDl.js +2 -0
- package/dist/dev-Bl9HqtV7.js +3 -0
- package/dist/{dev-Ca_A_S9v.js → dev-DOEJXicj.js} +2623 -2485
- package/dist/{doctorCommand-CGZJK_4o.js → doctorCommand-BrWu67JZ.js} +524 -280
- package/dist/doctorCommand-DrQv9SL3.js +2 -0
- package/dist/{dormancyCommand-DY2rYpTa.js → dormancyCommand-xn2y-pJm.js} +1 -1
- package/dist/{embeddingsCommand-BoCqZsgp.js → embeddingsCommand-Cn5MbRDM.js} +1 -1
- package/dist/emptyResultHeadline-Csa5fZOF.js +18 -0
- package/dist/{envCommand-Bxy2fOjc.js → envCommand-UJmJIbs9.js} +8 -8
- package/dist/{evolveCommand-BsbZ-XDg.js → evolveCommand-Db30twUy.js} +2 -2
- package/dist/frameworkTableAssembly-B96WCNJA.js +2 -0
- package/dist/{frameworkTableAssembly-Do-cf6RJ.js → frameworkTableAssembly-vfkzuzEo.js} +131 -104
- package/dist/index.js +1 -1
- package/dist/{infoCommand-EmM3jPKD.js → infoCommand-BjVXpMlP.js} +1 -1
- package/dist/inspect-B0hL41s0.js +2 -0
- package/dist/inspect-DZnan87F.js +1500 -0
- package/dist/{inspectCmd-niF97fAq.js → inspectCmd-CP-G0sVK.js} +1 -1
- package/dist/{inspectFetch-EMuhTG_9.js → inspectFetch-BU1NyzxV.js} +36 -24
- package/dist/{inspectMetrics-CGF94puw.js → inspectMetrics-BY0Sjb2F.js} +19 -19
- package/dist/{logsCmd-B6oNsfaZ.js → logsCmd-C5y9HyrG.js} +59 -54
- package/dist/{manifestBuild-DjX5MoXy.js → manifestBuild-DnbFKF6w.js} +1 -1
- package/dist/manifestBuild-UXrnUcXP.js +2 -0
- package/dist/{migrate-CGFZS-1a.js → migrate-DtC3lu7H.js} +4 -4
- package/dist/precompressAssets-YhTi1aWp.js +40 -0
- package/dist/{probeCommand-Bs3iVBSL.js → probeCommand-C5fuN6Z2.js} +2 -2
- package/dist/{runtimeTrace-C1BTpHGQ.js → runtimeTrace-BQL_lfz6.js} +1 -1
- package/dist/{scheduleCmd-DQRu6BZC.js → scheduleCmd-DYBUfo_T.js} +1 -1
- package/dist/{sdkgen-CXMwLg9n.js → sdkgen-CMUPrDjH.js} +1 -1
- package/dist/{seedRunner-Dgsiwk_e.js → seedRunner-DISBKow-.js} +16 -16
- package/dist/serveCommand-B_w-Mpb_.js +2544 -0
- package/dist/serveCommand-Dtb48ffg.js +2 -0
- package/dist/serveEntry.js +1 -1
- package/dist/{start-EOV7s1NZ.js → start-YaUehtDV.js} +580 -558
- package/dist/{start-DH7cat4-.js → start-s25GAIgn.js} +1 -1
- package/dist/startEntry.js +1 -1
- package/dist/staticCachePolicy-CIyj6DbS.js +15 -0
- package/dist/{test-DO27-x2P.js → test-jipIQ5Mx.js} +1 -1
- package/dist/{tracesCmd-DgtgOUdi.js → tracesCmd-C1qKa94g.js} +69 -64
- package/dist/{updateCommand-C_jN1w18.js → updateCommand-C9n_Z_oG.js} +8 -2
- package/dist/updateCommand-DsXEAHbd.js +2 -0
- package/dist/webDev-B6ZMX42w.js +2 -0
- package/dist/{webDev-B7vNj4Bq.js → webDev-BgdkyjP6.js} +1379 -1303
- package/dist/{webhooksCommand-B1LVcyO3.js → webhooksCommand-CYXTNvXq.js} +2 -2
- package/dist/{workflowsCmd-BGF-mRZ5.js → workflowsCmd-g-DNpaUc.js} +1 -1
- package/package.json +55 -19
- package/templates/AGENTS.core.md +20 -1
- package/templates/AGENTS.md +21 -2
- package/templates/agent-docs/_index.md +1 -1
- package/templates/agent-docs/_manifest.json +2 -2
- package/templates/agent-docs/ai.md +1 -1
- package/templates/agent-docs/authentication.md +34 -19
- package/templates/agent-docs/cli.md +170 -0
- package/templates/agent-docs/configuration.md +29 -4
- package/templates/agent-docs/data.md +145 -5
- package/templates/agent-docs/database/scaling.md +50 -2
- package/templates/agent-docs/deployment.md +75 -1
- package/templates/agent-docs/internationalization.md +32 -0
- package/templates/agent-docs/local-first-mobile.md +9 -2
- package/templates/agent-docs/observability.md +227 -0
- package/templates/agent-docs/plugins/audit.md +21 -5
- package/templates/agent-docs/plugins/billing.md +17 -0
- package/templates/agent-docs/plugins/broadcast.md +2 -1
- package/templates/agent-docs/plugins/ratelimit.md +6 -1
- package/templates/agent-docs/plugins/row-history.md +11 -0
- package/templates/agent-docs/plugins.md +19 -0
- package/templates/agent-docs/reference.md +1 -0
- package/templates/agent-docs/scheduling.md +23 -0
- package/templates/agent-docs/schema-driven-ui.md +81 -0
- package/templates/agent-docs/templates/appshells.md +3 -3
- package/templates/agent-docs/whats-new.md +133 -77
- package/templates/apps/api-ai/package.json +6 -6
- 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 +9 -9
- package/templates/apps/api-collab/package.json +8 -8
- package/templates/apps/api-data-advanced/package.json +8 -8
- package/templates/apps/api-durable/package.json +8 -8
- package/templates/apps/api-feature-flags/package.json +9 -9
- package/templates/apps/api-governance/package.json +8 -8
- package/templates/apps/api-kv/package.json +8 -8
- package/templates/apps/api-moderation/package.json +8 -8
- package/templates/apps/api-observability/package.json +8 -8
- package/templates/apps/api-ratelimit/package.json +8 -8
- package/templates/apps/api-rbac/package.json +8 -8
- package/templates/apps/api-rest/package.json +7 -7
- package/templates/apps/api-row-history/package.json +8 -8
- 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-webhooks/package.json +9 -9
- package/templates/apps/changelog/package.json +7 -7
- package/templates/apps/changelog/src/pages/[locale]/page.tsx +7 -1
- package/templates/apps/edge-functions/package.json +2 -2
- package/templates/apps/frontend-admin/package.json +7 -8
- package/templates/apps/frontend-admin/src/pages/(marketing)/layout.tsx +1 -2
- package/templates/apps/frontend-admin/src/pages/admin/layout.tsx +1 -2
- package/templates/apps/frontend-app/package.json +8 -9
- package/templates/apps/frontend-app/src/pages/layout.tsx +1 -2
- package/templates/apps/frontend-auth/package.json +7 -8
- package/templates/apps/frontend-auth/src/components/AuthShell.tsx +1 -2
- package/templates/apps/frontend-blank/package.json +6 -7
- package/templates/apps/frontend-blank/src/pages/layout.tsx +1 -2
- package/templates/apps/frontend-cms/package.json +8 -9
- package/templates/apps/frontend-cms/src/pages/(app)/layout.tsx +1 -2
- package/templates/apps/frontend-collab/README.md +7 -2
- package/templates/apps/frontend-collab/package.json +9 -10
- package/templates/apps/frontend-collab/src/pages/layout.tsx +1 -2
- package/templates/apps/frontend-collab/src/pages/page.test.tsx +8 -4
- package/templates/apps/frontend-collab/src/pages/page.tsx +10 -5
- package/templates/apps/frontend-contact/package.json +7 -7
- package/templates/apps/frontend-contact/src/components/ContactForm.island.tsx +1 -1
- package/templates/apps/frontend-dashboard/package.json +6 -7
- package/templates/apps/frontend-dashboard/src/pages/(marketing)/layout.tsx +1 -2
- package/templates/apps/frontend-dashboard/src/pages/dashboard/layout.tsx +1 -2
- package/templates/apps/frontend-docs/package.json +8 -8
- 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 +7 -8
- package/templates/apps/frontend-portal/src/pages/(portal)/layout.tsx +1 -2
- package/templates/apps/frontend-saas/package.json +7 -8
- package/templates/apps/frontend-saas/src/pages/(marketing)/layout.tsx +1 -2
- package/templates/apps/frontend-saas/src/pages/dashboard/layout.tsx +1 -2
- package/templates/apps/frontend-spa/package.json +6 -7
- package/templates/apps/frontend-spa/src/pages/layout.tsx +1 -2
- package/templates/apps/frontend-ssr/package.json +6 -7
- package/templates/apps/frontend-ssr/src/pages/layout.tsx +1 -2
- package/templates/apps/frontend-ssr-api/package.json +7 -8
- package/templates/apps/frontend-ssr-api/src/pages/layout.tsx +1 -2
- package/templates/apps/frontend-static-blog/package.json +8 -8
- package/templates/apps/frontend-static-blog/src/components/ReadingProgress.island.tsx +1 -1
- package/templates/apps/frontend-static-blog/src/pages/[locale]/page.tsx +7 -1
- package/templates/apps/frontend-status/package.json +7 -8
- package/templates/apps/frontend-status/src/pages/layout.tsx +1 -2
- package/templates/apps/mobile-app/package.json +4 -4
- package/templates/baselines/compose/docker/api.Dockerfile +61 -5
- package/templates/baselines/compose/docker/web.Dockerfile +55 -10
- package/templates/baselines/compose-mariadb/docker/api.Dockerfile +61 -5
- package/templates/baselines/compose-mariadb/docker/web.Dockerfile +55 -10
- package/dist/apiBuild-Cl0IDx8c.js +0 -2
- package/dist/codegen-CN6vMM4J.js +0 -2
- package/dist/dbCommand-BTyBGhIA.js +0 -2
- package/dist/dev-DfVZaoys.js +0 -3
- package/dist/doctorCommand-djmqEcDC.js +0 -2
- package/dist/frameworkTableAssembly-Df2Ymp2f.js +0 -2
- package/dist/inspect-DCqILJ1G.js +0 -1197
- package/dist/inspect-DGJwpOAb.js +0 -2
- package/dist/manifestBuild-CJ2zvPvT.js +0 -2
- package/dist/serveCommand-C7IrCD58.js +0 -2445
- package/dist/serveCommand-Cjt5S9hD.js +0 -2
- package/dist/updateCommand-nnFjDbl4.js +0 -2
- package/dist/webDev-1XpVnYkW.js +0 -2
package/dist/inspect-DCqILJ1G.js
DELETED
|
@@ -1,1197 +0,0 @@
|
|
|
1
|
-
import { n as e } from "./inspectGateHint-4LxkNtrz.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
|
-
"rich-text",
|
|
152
|
-
"number",
|
|
153
|
-
"checkbox",
|
|
154
|
-
"switch",
|
|
155
|
-
"select",
|
|
156
|
-
"radio",
|
|
157
|
-
"async-select",
|
|
158
|
-
"multi-select",
|
|
159
|
-
"date",
|
|
160
|
-
"datetime",
|
|
161
|
-
"daterange",
|
|
162
|
-
"file",
|
|
163
|
-
"hidden",
|
|
164
|
-
"array",
|
|
165
|
-
"reference",
|
|
166
|
-
"custom"
|
|
167
|
-
], S = (e, t, n = [], r = []) => ({
|
|
168
|
-
version: 2,
|
|
169
|
-
scopes: [...new Set(r.flatMap((e) => e.declaredScopes ?? []))].sort(),
|
|
170
|
-
procedures: [...e].sort((e, t) => e.tag.localeCompare(t.tag)).map((e) => ({
|
|
171
|
-
tag: e.tag,
|
|
172
|
-
kind: e.kind,
|
|
173
|
-
...e.inputSchema === void 0 ? {} : { input: e.inputSchema },
|
|
174
|
-
...e.outputSchema === void 0 ? {} : { output: e.outputSchema },
|
|
175
|
-
...e.source === void 0 ? {} : { source: e.source },
|
|
176
|
-
...e.targets === void 0 ? {} : { targets: e.targets },
|
|
177
|
-
...e.guards === void 0 ? {} : { guards: e.guards },
|
|
178
|
-
...e.internal === !0 ? { internal: !0 } : {},
|
|
179
|
-
...e.publicApi === void 0 ? {} : { publicApi: e.publicApi },
|
|
180
|
-
...e.exposeAsTool === void 0 ? {} : { exposeAsTool: e.exposeAsTool }
|
|
181
|
-
})),
|
|
182
|
-
workflows: [...t].sort((e, t) => e.tag.localeCompare(t.tag)).map((e) => ({ name: e.tag })),
|
|
183
|
-
widgets: x,
|
|
184
|
-
tables: [...n].filter((e) => !e.isFrameworkTable).sort((e, t) => e.name.localeCompare(t.name)).map((e) => ({
|
|
185
|
-
name: e.name,
|
|
186
|
-
reactive: e.isReactive,
|
|
187
|
-
framework: e.isFrameworkTable,
|
|
188
|
-
editable: e.editable ?? !0,
|
|
189
|
-
...e.pkColumn === void 0 ? {} : { pkColumn: e.pkColumn },
|
|
190
|
-
columns: e.columns.map((e) => ({
|
|
191
|
-
name: e.name,
|
|
192
|
-
type: String(e.type),
|
|
193
|
-
nullable: e.nullable,
|
|
194
|
-
...e.referencesTable === void 0 ? {} : { refersTo: e.referencesTable },
|
|
195
|
-
...e.oneOf === void 0 ? {} : { enum: e.oneOf },
|
|
196
|
-
...e.serverOnly === !0 ? { serverOnly: !0 } : {},
|
|
197
|
-
...e.encrypted === !0 ? { encrypted: !0 } : {},
|
|
198
|
-
...e.sensitive === void 0 ? {} : { sensitive: e.sensitive }
|
|
199
|
-
}))
|
|
200
|
-
}))
|
|
201
|
-
}), C = (e, t, n = {}, r = {}) => {
|
|
202
|
-
let a = v(e);
|
|
203
|
-
if (!b(a)) return null;
|
|
204
|
-
let s = u(n.origin ?? n.Origin), l = (r.method ?? "GET").toUpperCase();
|
|
205
|
-
if (l === "OPTIONS") return {
|
|
206
|
-
status: 204,
|
|
207
|
-
contentType: "text/plain",
|
|
208
|
-
body: "",
|
|
209
|
-
headers: s
|
|
210
|
-
};
|
|
211
|
-
if (i()) return c(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, s);
|
|
212
|
-
let d = (r.authResolver ?? o)(n, l);
|
|
213
|
-
if (!d.ok) return c(401, {
|
|
214
|
-
error: "unauthorized",
|
|
215
|
-
reason: d.reason
|
|
216
|
-
}, s);
|
|
217
|
-
if (a === "/_voltro/inspect" || a === "/_voltro/inspect/" || a === "/_voltro/inspect/app") return c(200, {
|
|
218
|
-
kind: t.kind,
|
|
219
|
-
...t.meta
|
|
220
|
-
}, s);
|
|
221
|
-
if (a === "/_voltro/inspect/routes") return t.kind === "web" ? c(200, {
|
|
222
|
-
pages: t.routes,
|
|
223
|
-
dirs: t.dirs
|
|
224
|
-
}, s) : c(404, { error: "routes endpoint is web-only" }, s);
|
|
225
|
-
if (a === "/_voltro/inspect/cache") return t.kind === "web" ? c(200, t.cache(), s) : c(404, { error: "cache endpoint is web-only" }, s);
|
|
226
|
-
if (a === "/_voltro/inspect/rpc") return t.kind === "api" ? c(200, {
|
|
227
|
-
procedures: t.rpc,
|
|
228
|
-
workflows: t.workflows
|
|
229
|
-
}, s) : c(404, { error: "rpc endpoint is api-only" }, s);
|
|
230
|
-
if (a === "/_voltro/inspect/manifest") {
|
|
231
|
-
if (t.kind !== "api") return c(404, { error: "manifest endpoint is api-only" }, s);
|
|
232
|
-
let e = t.inspectTables?.().tables ?? [];
|
|
233
|
-
return c(200, S(t.rpc, t.workflows, e, t.plugins?.().plugins ?? []), s);
|
|
234
|
-
}
|
|
235
|
-
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, {
|
|
236
|
-
subscriptions: [],
|
|
237
|
-
matcherStats: [],
|
|
238
|
-
resume: [],
|
|
239
|
-
capturedAt: Date.now()
|
|
240
|
-
}, 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, {
|
|
241
|
-
members: [],
|
|
242
|
-
capturedAt: Date.now()
|
|
243
|
-
}, 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, {
|
|
244
|
-
declared: [],
|
|
245
|
-
routes: [],
|
|
246
|
-
origin: "",
|
|
247
|
-
capturedAt: Date.now(),
|
|
248
|
-
totals: {
|
|
249
|
-
routes: 0,
|
|
250
|
-
subscribers: 0,
|
|
251
|
-
buffered: 0
|
|
252
|
-
}
|
|
253
|
-
}, 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, {
|
|
254
|
-
backend: "memory",
|
|
255
|
-
engine: "memory",
|
|
256
|
-
driver: "resp",
|
|
257
|
-
hits: 0,
|
|
258
|
-
misses: 0,
|
|
259
|
-
hitRate: 0
|
|
260
|
-
}, 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, {
|
|
261
|
-
migrations: [],
|
|
262
|
-
seeds: []
|
|
263
|
-
}, 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, {
|
|
264
|
-
plugins: [],
|
|
265
|
-
capturedAt: Date.now()
|
|
266
|
-
}, 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, {
|
|
267
|
-
app: t.meta.name ?? "app",
|
|
268
|
-
entries: [],
|
|
269
|
-
summary: {
|
|
270
|
-
total: 0,
|
|
271
|
-
set: 0,
|
|
272
|
-
missingRequired: 0
|
|
273
|
-
}
|
|
274
|
-
}, 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, {
|
|
275
|
-
error: "endpoint not mounted on this instance",
|
|
276
|
-
path: a,
|
|
277
|
-
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."
|
|
278
|
-
}, s) : c(404, {
|
|
279
|
-
error: "unknown inspect endpoint",
|
|
280
|
-
path: a
|
|
281
|
-
}, s);
|
|
282
|
-
}, w = /* @__PURE__ */ new Set([
|
|
283
|
-
`${r}/logs`,
|
|
284
|
-
`${r}/traces`,
|
|
285
|
-
`${r}/workflows`,
|
|
286
|
-
`${r}/storage`,
|
|
287
|
-
`${r}/aggregates`,
|
|
288
|
-
`${r}/flags`
|
|
289
|
-
]), T = async (e, t, n, r = {}) => {
|
|
290
|
-
let a = u(t.origin ?? t.Origin);
|
|
291
|
-
if (i()) return c(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, a);
|
|
292
|
-
let s = (r.method ?? "POST").toUpperCase();
|
|
293
|
-
if (s !== "POST") return c(405, {
|
|
294
|
-
error: "method not allowed",
|
|
295
|
-
expected: "POST"
|
|
296
|
-
}, a);
|
|
297
|
-
let l = (r.authResolver ?? o)(t, s);
|
|
298
|
-
if (!l.ok) return c(401, {
|
|
299
|
-
error: "unauthorized",
|
|
300
|
-
reason: l.reason
|
|
301
|
-
}, a);
|
|
302
|
-
if (e.kind !== "api") return c(404, { error: "invoke endpoint is api-only" }, a);
|
|
303
|
-
if (!e.invokers || e.invokers.size === 0) return c(404, { error: "invoke not configured" }, a);
|
|
304
|
-
let d;
|
|
305
|
-
try {
|
|
306
|
-
d = JSON.parse(n || "{}");
|
|
307
|
-
} catch {
|
|
308
|
-
return c(400, { error: "body must be JSON" }, a);
|
|
309
|
-
}
|
|
310
|
-
let f = d;
|
|
311
|
-
if (typeof f.tag != "string") return c(400, { error: "body.tag must be a string" }, a);
|
|
312
|
-
let p = e.invokers.get(f.tag);
|
|
313
|
-
if (!p) return c(404, {
|
|
314
|
-
error: "unknown tag",
|
|
315
|
-
tag: f.tag
|
|
316
|
-
}, a);
|
|
317
|
-
let m = typeof f.headers == "object" && f.headers !== null ? f.headers : {}, h = {};
|
|
318
|
-
for (let [e, n] of Object.entries(t)) h[e.toLowerCase()] = n;
|
|
319
|
-
for (let [e, t] of Object.entries(m)) {
|
|
320
|
-
let n = e.toLowerCase();
|
|
321
|
-
n !== "cookie" && (h[n] = t);
|
|
322
|
-
}
|
|
323
|
-
return c(200, await p(f.input, h), a);
|
|
324
|
-
}, E = async (e, t, n, r = {}) => {
|
|
325
|
-
let a = v(e);
|
|
326
|
-
if (!b(a) || a !== "/_voltro/inspect/migrations" || (r.method ?? "GET").toUpperCase() !== "GET") return null;
|
|
327
|
-
let s = u(n.origin ?? n.Origin);
|
|
328
|
-
if (i()) return c(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, s);
|
|
329
|
-
let l = (r.authResolver ?? o)(n, "GET");
|
|
330
|
-
return l.ok ? t.kind === "api" ? t.migrations === void 0 ? c(200, {
|
|
331
|
-
drift: {
|
|
332
|
-
isDrifted: !1,
|
|
333
|
-
liveFingerprint: "",
|
|
334
|
-
liveSnapshot: { tables: [] }
|
|
335
|
-
},
|
|
336
|
-
pending: null,
|
|
337
|
-
history: [],
|
|
338
|
-
softDropSnapshots: []
|
|
339
|
-
}, s) : c(200, await t.migrations(), s) : c(404, { error: "migrations endpoint is api-only" }, s) : c(401, {
|
|
340
|
-
error: "unauthorized",
|
|
341
|
-
reason: l.reason
|
|
342
|
-
}, s);
|
|
343
|
-
}, D = async (e, t, n, a, s = {}) => {
|
|
344
|
-
let l = v(e);
|
|
345
|
-
if (!b(l) || !l.startsWith("/_voltro/inspect/webhooks/")) return null;
|
|
346
|
-
let d = u(n.origin ?? n.Origin);
|
|
347
|
-
if ((s.method ?? "POST").toUpperCase() !== "POST") return null;
|
|
348
|
-
if (i()) return c(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, d);
|
|
349
|
-
let p = (s.authResolver ?? o)(n, s.method ?? "POST");
|
|
350
|
-
if (!p.ok) return c(401, {
|
|
351
|
-
error: "unauthorized",
|
|
352
|
-
reason: p.reason
|
|
353
|
-
}, d);
|
|
354
|
-
let m = f(s.method, n, d);
|
|
355
|
-
if (m) return m;
|
|
356
|
-
if (t.kind !== "api") return c(404, { error: "webhook actions are api-only" }, d);
|
|
357
|
-
if (!t.webhookActions) return c(404, { error: "webhook actions not configured — is @voltro/plugin-webhooks active?" }, d);
|
|
358
|
-
let h;
|
|
359
|
-
try {
|
|
360
|
-
h = JSON.parse(a || "{}");
|
|
361
|
-
} catch {
|
|
362
|
-
return c(400, { error: "body must be JSON" }, d);
|
|
363
|
-
}
|
|
364
|
-
let g = l.slice(`${r}/webhooks/`.length);
|
|
365
|
-
try {
|
|
366
|
-
switch (g) {
|
|
367
|
-
case "subscribe": {
|
|
368
|
-
let e = h;
|
|
369
|
-
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);
|
|
370
|
-
}
|
|
371
|
-
case "pause": {
|
|
372
|
-
let e = h.targetId;
|
|
373
|
-
return typeof e != "string" || e.length === 0 ? c(400, { error: "targetId required" }, d) : (await t.webhookActions.pause(e), c(200, { ok: !0 }, d));
|
|
374
|
-
}
|
|
375
|
-
case "resume": {
|
|
376
|
-
let e = h.targetId;
|
|
377
|
-
return typeof e != "string" || e.length === 0 ? c(400, { error: "targetId required" }, d) : (await t.webhookActions.resume(e), c(200, { ok: !0 }, d));
|
|
378
|
-
}
|
|
379
|
-
case "delete": {
|
|
380
|
-
let e = h.targetId;
|
|
381
|
-
return typeof e != "string" || e.length === 0 ? c(400, { error: "targetId required" }, d) : (await t.webhookActions.delete(e), c(200, { ok: !0 }, d));
|
|
382
|
-
}
|
|
383
|
-
case "rotateSecret": {
|
|
384
|
-
let e = h.targetId;
|
|
385
|
-
return typeof e != "string" || e.length === 0 ? c(400, { error: "targetId required" }, d) : c(200, await t.webhookActions.rotateSecret(e), d);
|
|
386
|
-
}
|
|
387
|
-
case "replay": {
|
|
388
|
-
let e = h.deliveryId;
|
|
389
|
-
return typeof e != "string" || e.length === 0 ? c(400, { error: "deliveryId required" }, d) : (await t.webhookActions.replay(e), c(200, { ok: !0 }, d));
|
|
390
|
-
}
|
|
391
|
-
case "repinVersion": {
|
|
392
|
-
let e = h.targetId, n = h.version;
|
|
393
|
-
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));
|
|
394
|
-
}
|
|
395
|
-
default: return c(404, { error: `unknown webhook action: ${g}` }, d);
|
|
396
|
-
}
|
|
397
|
-
} catch (e) {
|
|
398
|
-
return c(500, {
|
|
399
|
-
error: "webhook action failed",
|
|
400
|
-
message: e?.message ?? String(e)
|
|
401
|
-
}, d);
|
|
402
|
-
}
|
|
403
|
-
}, O = async (e, t, n, a, s = {}) => {
|
|
404
|
-
let l = v(e);
|
|
405
|
-
if (!b(l)) return null;
|
|
406
|
-
let d = u(n.origin ?? n.Origin), f = (s.method ?? "POST").toUpperCase();
|
|
407
|
-
if (f !== "POST") return null;
|
|
408
|
-
if (i()) return c(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, d);
|
|
409
|
-
let p = (s.authResolver ?? o)(n, f);
|
|
410
|
-
if (!p.ok) return c(401, {
|
|
411
|
-
error: "unauthorized",
|
|
412
|
-
reason: p.reason
|
|
413
|
-
}, d);
|
|
414
|
-
if (t.kind !== "api") return c(404, { error: "framework-action endpoints are api-only" }, d);
|
|
415
|
-
let m = `${r}/seeds/run`, h = `${r}/migrations/rollback`, g = `${r}/migrations/squash`, _ = `${r}/migrations/restore-snapshot`;
|
|
416
|
-
if (l !== m && l !== h && l !== g && l !== _ && l !== "/_voltro/inspect/migrations/compare-env") return null;
|
|
417
|
-
let y;
|
|
418
|
-
try {
|
|
419
|
-
y = JSON.parse(a || "{}");
|
|
420
|
-
} catch {
|
|
421
|
-
return c(400, { error: "body must be JSON" }, d);
|
|
422
|
-
}
|
|
423
|
-
try {
|
|
424
|
-
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);
|
|
425
|
-
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);
|
|
426
|
-
if (l === g) {
|
|
427
|
-
if (typeof y.before != "string" || y.before.length === 0) return c(400, { error: "body.before must be a non-empty ISO date string" }, d);
|
|
428
|
-
if (!t.squashMigrationHistory) return c(404, { error: "squashMigrationHistory not configured" }, d);
|
|
429
|
-
let e = typeof y.note == "string" ? y.note : void 0;
|
|
430
|
-
return c(200, await t.squashMigrationHistory({
|
|
431
|
-
before: y.before,
|
|
432
|
-
note: e
|
|
433
|
-
}), d);
|
|
434
|
-
}
|
|
435
|
-
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({
|
|
436
|
-
url: y.url,
|
|
437
|
-
label: typeof y.label == "string" ? y.label : void 0,
|
|
438
|
-
token: typeof y.token == "string" ? y.token : void 0
|
|
439
|
-
}), c(200, { ok: !0 }, d)) : c(404, { error: "compareCrossEnv not configured" }, d);
|
|
440
|
-
} catch (e) {
|
|
441
|
-
return c(500, {
|
|
442
|
-
error: "framework action failed",
|
|
443
|
-
message: e?.message ?? String(e)
|
|
444
|
-
}, d);
|
|
445
|
-
}
|
|
446
|
-
}, k = async (e, t, n, r = {}) => {
|
|
447
|
-
if (v(e) !== "/_voltro/inspect/data/rows") return null;
|
|
448
|
-
let a = u(n.origin ?? n.Origin), s = (r.method ?? "GET").toUpperCase();
|
|
449
|
-
if (s !== "GET") return c(405, {
|
|
450
|
-
error: "method not allowed",
|
|
451
|
-
expected: "GET"
|
|
452
|
-
}, a);
|
|
453
|
-
if (i()) return c(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, a);
|
|
454
|
-
let l = (r.authResolver ?? o)(n, s);
|
|
455
|
-
if (!l.ok) return c(401, {
|
|
456
|
-
error: "unauthorized",
|
|
457
|
-
reason: l.reason
|
|
458
|
-
}, a);
|
|
459
|
-
if (t.kind !== "api") return c(404, { error: "data viewer is api-only" }, a);
|
|
460
|
-
if (t.inspectRows === void 0) return c(404, { error: "inspectRows not configured" }, a);
|
|
461
|
-
let d = j(e), f = d.get("table");
|
|
462
|
-
if (!f) return c(400, { error: "query.table is required" }, a);
|
|
463
|
-
let p = M(d.get("offset")) ?? 0, m = M(d.get("limit")) ?? 50, h = {}, g = d.get("q");
|
|
464
|
-
if (g) {
|
|
465
|
-
if (g.length > 8192) return c(400, { error: "query.q too large" }, a);
|
|
466
|
-
try {
|
|
467
|
-
h = JSON.parse(Buffer.from(g, "base64url").toString("utf8"));
|
|
468
|
-
} catch {
|
|
469
|
-
return c(400, { error: "query.q is not valid base64url JSON" }, a);
|
|
470
|
-
}
|
|
471
|
-
}
|
|
472
|
-
try {
|
|
473
|
-
return c(200, await t.inspectRows({
|
|
474
|
-
table: f,
|
|
475
|
-
offset: p,
|
|
476
|
-
limit: m,
|
|
477
|
-
...h
|
|
478
|
-
}), a);
|
|
479
|
-
} catch (e) {
|
|
480
|
-
return e?.name === "InspectQueryError" ? c(400, {
|
|
481
|
-
error: "invalid query",
|
|
482
|
-
message: e.message
|
|
483
|
-
}, a) : c(500, {
|
|
484
|
-
error: "data-rows query failed",
|
|
485
|
-
message: e?.message ?? String(e)
|
|
486
|
-
}, a);
|
|
487
|
-
}
|
|
488
|
-
}, A = async (e, n, r, a = {}) => {
|
|
489
|
-
if (v(e) !== "/_voltro/inspect/provenance") return null;
|
|
490
|
-
let s = u(r.origin ?? r.Origin), l = (a.method ?? "GET").toUpperCase();
|
|
491
|
-
if (l !== "GET") return c(405, {
|
|
492
|
-
error: "method not allowed",
|
|
493
|
-
expected: "GET"
|
|
494
|
-
}, s);
|
|
495
|
-
if (i()) return c(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, s);
|
|
496
|
-
let d = (a.authResolver ?? o)(r, l);
|
|
497
|
-
if (!d.ok) return c(401, {
|
|
498
|
-
error: "unauthorized",
|
|
499
|
-
reason: d.reason
|
|
500
|
-
}, s);
|
|
501
|
-
let p = f(a.method, r, s);
|
|
502
|
-
if (p) return p;
|
|
503
|
-
if (n.kind !== "api") return c(404, { error: "provenance is api-only" }, s);
|
|
504
|
-
if (n.inspectRows === void 0) return c(404, { error: "inspectRows not configured" }, s);
|
|
505
|
-
let m = j(e), h = m.get("table"), g = m.get("id"), _ = m.get("column") ?? void 0;
|
|
506
|
-
if (!h || !g) return c(400, { error: "query.table and query.id are required" }, s);
|
|
507
|
-
try {
|
|
508
|
-
let e = (await n.inspectRows({
|
|
509
|
-
table: h,
|
|
510
|
-
limit: 1,
|
|
511
|
-
filter: {
|
|
512
|
-
kind: "leaf",
|
|
513
|
-
column: "id",
|
|
514
|
-
op: "eq",
|
|
515
|
-
value: g
|
|
516
|
-
}
|
|
517
|
-
})).rows[0];
|
|
518
|
-
return c(200, t(e, {
|
|
519
|
-
table: h,
|
|
520
|
-
id: g,
|
|
521
|
-
..._ === void 0 ? {} : { column: _ }
|
|
522
|
-
}), s);
|
|
523
|
-
} catch (e) {
|
|
524
|
-
return e?.name === "InspectQueryError" ? c(400, {
|
|
525
|
-
error: "invalid query",
|
|
526
|
-
message: e.message
|
|
527
|
-
}, s) : c(500, {
|
|
528
|
-
error: "provenance query failed",
|
|
529
|
-
message: e?.message ?? String(e)
|
|
530
|
-
}, s);
|
|
531
|
-
}
|
|
532
|
-
}, j = (e) => {
|
|
533
|
-
let t = e.indexOf("?");
|
|
534
|
-
return t < 0 ? new URLSearchParams() : new URLSearchParams(e.slice(t + 1));
|
|
535
|
-
}, M = (e) => {
|
|
536
|
-
if (e === null || e === "") return;
|
|
537
|
-
let t = Number(e);
|
|
538
|
-
return Number.isFinite(t) && t >= 0 ? Math.floor(t) : void 0;
|
|
539
|
-
}, N = async (e, t, n, r = {}) => {
|
|
540
|
-
if (v(e) !== "/_voltro/inspect/workflows/runs") return null;
|
|
541
|
-
let a = u(n.origin ?? n.Origin), s = (r.method ?? "GET").toUpperCase();
|
|
542
|
-
if (s !== "GET") return c(405, {
|
|
543
|
-
error: "method not allowed",
|
|
544
|
-
expected: "GET"
|
|
545
|
-
}, a);
|
|
546
|
-
if (i()) return c(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, a);
|
|
547
|
-
let l = (r.authResolver ?? o)(n, s);
|
|
548
|
-
if (!l.ok) return c(401, {
|
|
549
|
-
error: "unauthorized",
|
|
550
|
-
reason: l.reason
|
|
551
|
-
}, a);
|
|
552
|
-
if (t.kind !== "api") return c(404, { error: "workflows endpoint is api-only" }, a);
|
|
553
|
-
if (t.inspectWorkflowRuns === void 0) return c(200, {
|
|
554
|
-
runs: [],
|
|
555
|
-
total: 0,
|
|
556
|
-
offset: 0,
|
|
557
|
-
limit: 50
|
|
558
|
-
}, a);
|
|
559
|
-
let d = j(e);
|
|
560
|
-
try {
|
|
561
|
-
let e = d.get("deadLettered") === "1" || d.get("deadLettered") === "true", n = (d.get("statuses") ?? "").split(",").map((e) => e.trim()).filter((e) => e !== "");
|
|
562
|
-
return c(200, await t.inspectWorkflowRuns({
|
|
563
|
-
...d.get("tag") === null ? {} : { tag: d.get("tag") },
|
|
564
|
-
...e ? { deadLettered: !0 } : d.get("status") === null ? n.length > 0 ? { statuses: n } : {} : { status: d.get("status") },
|
|
565
|
-
...d.get("q") === null ? {} : { tagContains: d.get("q") },
|
|
566
|
-
...d.get("source") === null ? {} : { source: d.get("source") },
|
|
567
|
-
...d.get("idPrefix") === null ? {} : { idPrefix: d.get("idPrefix") },
|
|
568
|
-
...d.get("from") === null ? {} : { startedAfter: d.get("from") },
|
|
569
|
-
...d.get("to") === null ? {} : { startedBefore: d.get("to") },
|
|
570
|
-
offset: M(d.get("offset")) ?? 0,
|
|
571
|
-
limit: M(d.get("limit")) ?? 50
|
|
572
|
-
}), a);
|
|
573
|
-
} catch (e) {
|
|
574
|
-
return c(500, {
|
|
575
|
-
error: "workflow-runs query failed",
|
|
576
|
-
message: e?.message ?? String(e)
|
|
577
|
-
}, a);
|
|
578
|
-
}
|
|
579
|
-
}, P = async (e, t, n, r = {}) => {
|
|
580
|
-
if (v(e) !== "/_voltro/inspect/workflows/stats") return null;
|
|
581
|
-
let a = u(n.origin ?? n.Origin), s = (r.method ?? "GET").toUpperCase();
|
|
582
|
-
if (s !== "GET") return c(405, {
|
|
583
|
-
error: "method not allowed",
|
|
584
|
-
expected: "GET"
|
|
585
|
-
}, a);
|
|
586
|
-
if (i()) return c(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, a);
|
|
587
|
-
let l = (r.authResolver ?? o)(n, s);
|
|
588
|
-
if (!l.ok) return c(401, {
|
|
589
|
-
error: "unauthorized",
|
|
590
|
-
reason: l.reason
|
|
591
|
-
}, a);
|
|
592
|
-
if (t.kind !== "api") return c(404, { error: "workflows endpoint is api-only" }, a);
|
|
593
|
-
if (t.inspectWorkflowRunStats === void 0) return c(200, {
|
|
594
|
-
windowHours: 24,
|
|
595
|
-
bucketMinutes: 30,
|
|
596
|
-
buckets: [],
|
|
597
|
-
byTag: [],
|
|
598
|
-
total: 0,
|
|
599
|
-
truncated: !1
|
|
600
|
-
}, a);
|
|
601
|
-
let d = j(e);
|
|
602
|
-
try {
|
|
603
|
-
return c(200, await t.inspectWorkflowRunStats({
|
|
604
|
-
...d.get("tag") === null ? {} : { tag: d.get("tag") },
|
|
605
|
-
...M(d.get("hours")) === void 0 ? {} : { hours: M(d.get("hours")) }
|
|
606
|
-
}), a);
|
|
607
|
-
} catch (e) {
|
|
608
|
-
return c(500, {
|
|
609
|
-
error: "workflow-stats query failed",
|
|
610
|
-
message: e?.message ?? String(e)
|
|
611
|
-
}, a);
|
|
612
|
-
}
|
|
613
|
-
}, F = async (e, t, n, r, a = {}) => {
|
|
614
|
-
let s = v(e).match(/^\/_voltro\/inspect\/workflows\/start\/([^/]+)$/);
|
|
615
|
-
if (!s) return null;
|
|
616
|
-
let l = decodeURIComponent(s[1] ?? ""), d = u(n.origin ?? n.Origin), f = (a.method ?? "POST").toUpperCase();
|
|
617
|
-
if (f !== "POST") return c(405, {
|
|
618
|
-
error: "method not allowed",
|
|
619
|
-
expected: "POST"
|
|
620
|
-
}, d);
|
|
621
|
-
if (i()) return c(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, d);
|
|
622
|
-
let p = (a.authResolver ?? o)(n, f);
|
|
623
|
-
if (!p.ok) return c(401, {
|
|
624
|
-
error: "unauthorized",
|
|
625
|
-
reason: p.reason
|
|
626
|
-
}, d);
|
|
627
|
-
if (t.kind !== "api") return c(404, { error: "workflow start is api-only" }, d);
|
|
628
|
-
if (t.inspectStartWorkflow === void 0) return c(404, { error: "inspectStartWorkflow not configured" }, d);
|
|
629
|
-
let m = {};
|
|
630
|
-
if (r.length > 0) try {
|
|
631
|
-
m = JSON.parse(r).payload ?? {};
|
|
632
|
-
} catch {
|
|
633
|
-
return c(400, { error: "start requires JSON body `{ payload?: unknown }`" }, d);
|
|
634
|
-
}
|
|
635
|
-
try {
|
|
636
|
-
return c(200, await t.inspectStartWorkflow({
|
|
637
|
-
name: l,
|
|
638
|
-
payload: m
|
|
639
|
-
}), d);
|
|
640
|
-
} catch (e) {
|
|
641
|
-
return c(500, {
|
|
642
|
-
error: "workflow start failed",
|
|
643
|
-
message: e?.message ?? String(e)
|
|
644
|
-
}, d);
|
|
645
|
-
}
|
|
646
|
-
}, I = async (e, t, n, r = {}) => {
|
|
647
|
-
let a = v(e);
|
|
648
|
-
if (!a.startsWith("/_voltro/inspect/schedules")) return null;
|
|
649
|
-
let s = u(n.origin ?? n.Origin);
|
|
650
|
-
if (i()) return c(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, s);
|
|
651
|
-
let l = (r.authResolver ?? o)(n, r.method ?? "POST");
|
|
652
|
-
if (!l.ok) return c(401, {
|
|
653
|
-
error: "unauthorized",
|
|
654
|
-
reason: l.reason
|
|
655
|
-
}, s);
|
|
656
|
-
let d = f(r.method, n, s);
|
|
657
|
-
if (d) return d;
|
|
658
|
-
if (t.kind !== "api") return c(404, { error: "schedules are api-only" }, s);
|
|
659
|
-
let p = (r.method ?? "GET").toUpperCase(), m = a.match(/^\/_voltro\/inspect\/schedules\/([^/]+)\/backfill$/);
|
|
660
|
-
if (m) {
|
|
661
|
-
if (p !== "POST") return c(405, {
|
|
662
|
-
error: "method not allowed",
|
|
663
|
-
expected: "POST"
|
|
664
|
-
}, s);
|
|
665
|
-
if (!t.inspectBackfillSchedule) return c(404, { error: "inspectBackfillSchedule not configured" }, s);
|
|
666
|
-
let e = decodeURIComponent(m[1] ?? ""), n;
|
|
667
|
-
try {
|
|
668
|
-
n = JSON.parse(r.body ?? "{}");
|
|
669
|
-
} catch {
|
|
670
|
-
return c(400, { error: "invalid JSON body — expected { from, to, confirm?, limit? }" }, s);
|
|
671
|
-
}
|
|
672
|
-
if (typeof n.from != "string" || typeof n.to != "string") return c(400, { error: "body must carry ISO 'from' and 'to' instants" }, s);
|
|
673
|
-
try {
|
|
674
|
-
let r = await t.inspectBackfillSchedule({
|
|
675
|
-
name: e,
|
|
676
|
-
from: n.from,
|
|
677
|
-
to: n.to,
|
|
678
|
-
confirm: n.confirm === !0,
|
|
679
|
-
...typeof n.limit == "number" ? { limit: n.limit } : {}
|
|
680
|
-
});
|
|
681
|
-
return c(r.kind === "refused" ? 409 : 200, r, s);
|
|
682
|
-
} catch (e) {
|
|
683
|
-
return c(500, {
|
|
684
|
-
error: "backfill failed",
|
|
685
|
-
message: e?.message ?? String(e)
|
|
686
|
-
}, s);
|
|
687
|
-
}
|
|
688
|
-
}
|
|
689
|
-
let h = a.match(/^\/_voltro\/inspect\/schedules\/([^/]+)\/fire$/);
|
|
690
|
-
if (h) {
|
|
691
|
-
if (p !== "POST") return c(405, {
|
|
692
|
-
error: "method not allowed",
|
|
693
|
-
expected: "POST"
|
|
694
|
-
}, s);
|
|
695
|
-
if (!t.inspectFireSchedule) return c(404, { error: "inspectFireSchedule not configured" }, s);
|
|
696
|
-
let n = decodeURIComponent(h[1] ?? ""), r = j(e).get("trigger") === "external" ? "external" : "manual";
|
|
697
|
-
try {
|
|
698
|
-
return c(200, await t.inspectFireSchedule({
|
|
699
|
-
name: n,
|
|
700
|
-
trigger: r
|
|
701
|
-
}), s);
|
|
702
|
-
} catch (e) {
|
|
703
|
-
return c(500, {
|
|
704
|
-
error: "fire failed",
|
|
705
|
-
message: e?.message ?? String(e)
|
|
706
|
-
}, s);
|
|
707
|
-
}
|
|
708
|
-
}
|
|
709
|
-
if (a === "/_voltro/inspect/schedules/runs") {
|
|
710
|
-
if (p !== "GET") return c(405, {
|
|
711
|
-
error: "method not allowed",
|
|
712
|
-
expected: "GET"
|
|
713
|
-
}, s);
|
|
714
|
-
if (!t.inspectScheduleRuns) return c(200, {
|
|
715
|
-
runs: [],
|
|
716
|
-
total: 0,
|
|
717
|
-
offset: 0,
|
|
718
|
-
limit: 50
|
|
719
|
-
}, s);
|
|
720
|
-
let n = j(e);
|
|
721
|
-
try {
|
|
722
|
-
return c(200, await t.inspectScheduleRuns({
|
|
723
|
-
...n.get("name") === null ? {} : { name: n.get("name") },
|
|
724
|
-
offset: M(n.get("offset")) ?? 0,
|
|
725
|
-
limit: M(n.get("limit")) ?? 50
|
|
726
|
-
}), s);
|
|
727
|
-
} catch (e) {
|
|
728
|
-
return c(500, {
|
|
729
|
-
error: "schedule-runs query failed",
|
|
730
|
-
message: e?.message ?? String(e)
|
|
731
|
-
}, s);
|
|
732
|
-
}
|
|
733
|
-
}
|
|
734
|
-
return a === "/_voltro/inspect/schedules" ? p === "GET" ? t.inspectSchedules ? c(200, t.inspectSchedules(), s) : c(200, {
|
|
735
|
-
schedules: [],
|
|
736
|
-
coordination: "single"
|
|
737
|
-
}, s) : c(405, {
|
|
738
|
-
error: "method not allowed",
|
|
739
|
-
expected: "GET"
|
|
740
|
-
}, s) : c(404, {
|
|
741
|
-
error: "unknown schedules endpoint",
|
|
742
|
-
path: a
|
|
743
|
-
}, s);
|
|
744
|
-
}, L = async (e, t, n, r = {}) => {
|
|
745
|
-
if (v(e) !== "/_voltro/inspect/cluster") return null;
|
|
746
|
-
let a = u(n.origin ?? n.Origin);
|
|
747
|
-
if (i()) return c(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, a);
|
|
748
|
-
let s = (r.authResolver ?? o)(n, r.method ?? "POST");
|
|
749
|
-
if (!s.ok) return c(401, {
|
|
750
|
-
error: "unauthorized",
|
|
751
|
-
reason: s.reason
|
|
752
|
-
}, a);
|
|
753
|
-
let l = f(r.method, n, a);
|
|
754
|
-
if (l) return l;
|
|
755
|
-
if (t.kind !== "api") return c(404, { error: "cluster is api-only" }, a);
|
|
756
|
-
if ((r.method ?? "GET").toUpperCase() !== "GET") return c(405, {
|
|
757
|
-
error: "method not allowed",
|
|
758
|
-
expected: "GET"
|
|
759
|
-
}, a);
|
|
760
|
-
if (!t.cluster) return c(200, {
|
|
761
|
-
instance: {
|
|
762
|
-
replicaId: process.env.POD_NAME ?? process.env.HOSTNAME ?? `dev-${process.pid}`,
|
|
763
|
-
dialect: "memory",
|
|
764
|
-
runnerHost: "localhost",
|
|
765
|
-
runnerPort: 0,
|
|
766
|
-
runnerStorage: "none",
|
|
767
|
-
shardLock: "none",
|
|
768
|
-
coordination: "single",
|
|
769
|
-
cdc: {
|
|
770
|
-
enabled: !1,
|
|
771
|
-
flavor: "none (single-process)"
|
|
772
|
-
},
|
|
773
|
-
tier: "none",
|
|
774
|
-
localhostRisk: !1
|
|
775
|
-
},
|
|
776
|
-
coordinationState: {
|
|
777
|
-
recentReplicaIds: [],
|
|
778
|
-
scheduleClaims: [],
|
|
779
|
-
runningScheduleRuns: 0,
|
|
780
|
-
runningWorkflowRuns: 0
|
|
781
|
-
},
|
|
782
|
-
capturedAt: Date.now()
|
|
783
|
-
}, a);
|
|
784
|
-
try {
|
|
785
|
-
return c(200, await t.cluster(), a);
|
|
786
|
-
} catch (e) {
|
|
787
|
-
return c(500, {
|
|
788
|
-
error: "cluster snapshot failed",
|
|
789
|
-
message: e?.message ?? String(e)
|
|
790
|
-
}, a);
|
|
791
|
-
}
|
|
792
|
-
}, R = async (e, t, n, r = {}) => {
|
|
793
|
-
let a = v(e).match(/^\/_voltro\/inspect\/workflows\/runs\/([^/]+)\/steps$/);
|
|
794
|
-
if (!a) return null;
|
|
795
|
-
let s = decodeURIComponent(a[1] ?? ""), l = u(n.origin ?? n.Origin), d = (r.method ?? "GET").toUpperCase();
|
|
796
|
-
if (d !== "GET") return c(405, {
|
|
797
|
-
error: "method not allowed",
|
|
798
|
-
expected: "GET"
|
|
799
|
-
}, l);
|
|
800
|
-
if (i()) return c(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, l);
|
|
801
|
-
let f = (r.authResolver ?? o)(n, d);
|
|
802
|
-
if (!f.ok) return c(401, {
|
|
803
|
-
error: "unauthorized",
|
|
804
|
-
reason: f.reason
|
|
805
|
-
}, l);
|
|
806
|
-
if (t.kind !== "api") return c(404, { error: "workflow steps are api-only" }, l);
|
|
807
|
-
if (t.inspectWorkflowRunSteps === void 0) return c(200, { steps: [] }, l);
|
|
808
|
-
try {
|
|
809
|
-
return c(200, await t.inspectWorkflowRunSteps({ runId: s }), l);
|
|
810
|
-
} catch (e) {
|
|
811
|
-
return c(500, {
|
|
812
|
-
error: "steps query failed",
|
|
813
|
-
message: e?.message ?? String(e)
|
|
814
|
-
}, l);
|
|
815
|
-
}
|
|
816
|
-
}, z = async (e, t, n, r = {}) => {
|
|
817
|
-
let a = v(e).match(/^\/_voltro\/inspect\/workflows\/runs\/([^/]+)\/events$/);
|
|
818
|
-
if (!a) return null;
|
|
819
|
-
let s = decodeURIComponent(a[1] ?? ""), l = u(n.origin ?? n.Origin), d = (r.method ?? "GET").toUpperCase();
|
|
820
|
-
if (d !== "GET") return c(405, {
|
|
821
|
-
error: "method not allowed",
|
|
822
|
-
expected: "GET"
|
|
823
|
-
}, l);
|
|
824
|
-
if (i()) return c(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, l);
|
|
825
|
-
let f = (r.authResolver ?? o)(n, d);
|
|
826
|
-
if (!f.ok) return c(401, {
|
|
827
|
-
error: "unauthorized",
|
|
828
|
-
reason: f.reason
|
|
829
|
-
}, l);
|
|
830
|
-
if (t.kind !== "api") return c(404, { error: "workflow events are api-only" }, l);
|
|
831
|
-
if (t.inspectWorkflowRunEvents === void 0) return c(200, { events: [] }, l);
|
|
832
|
-
try {
|
|
833
|
-
return c(200, await t.inspectWorkflowRunEvents({ runId: s }), l);
|
|
834
|
-
} catch (e) {
|
|
835
|
-
return c(500, {
|
|
836
|
-
error: "events query failed",
|
|
837
|
-
message: e?.message ?? String(e)
|
|
838
|
-
}, l);
|
|
839
|
-
}
|
|
840
|
-
}, B = async (e, t, n, r = {}) => {
|
|
841
|
-
if (v(t) !== "/_voltro/inspect/workflows/events") return null;
|
|
842
|
-
let a = u(n.origin ?? n.Origin), s = (r.method ?? "GET").toUpperCase();
|
|
843
|
-
if (s !== "GET") return c(405, {
|
|
844
|
-
error: "method not allowed",
|
|
845
|
-
expected: "GET"
|
|
846
|
-
}, a);
|
|
847
|
-
if (i()) return c(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, a);
|
|
848
|
-
let l = (r.authResolver ?? o)(n, s);
|
|
849
|
-
if (!l.ok) return c(401, {
|
|
850
|
-
error: "unauthorized",
|
|
851
|
-
reason: l.reason
|
|
852
|
-
}, a);
|
|
853
|
-
if (e.kind !== "api") return c(404, { error: "workflow domain events are api-only" }, a);
|
|
854
|
-
if (e.inspectWorkflowDomainEvents === void 0) return c(200, {
|
|
855
|
-
events: [],
|
|
856
|
-
total: 0,
|
|
857
|
-
offset: 0,
|
|
858
|
-
limit: 100
|
|
859
|
-
}, a);
|
|
860
|
-
let d = y(t), f = d.get("name") ?? void 0, p = Number(d.get("offset") ?? "0"), m = Number(d.get("limit") ?? "100");
|
|
861
|
-
try {
|
|
862
|
-
return c(200, await e.inspectWorkflowDomainEvents({
|
|
863
|
-
...f !== void 0 && f !== "" ? { name: f } : {},
|
|
864
|
-
offset: Number.isFinite(p) ? p : 0,
|
|
865
|
-
limit: Number.isFinite(m) ? m : 100
|
|
866
|
-
}), a);
|
|
867
|
-
} catch (e) {
|
|
868
|
-
return c(500, {
|
|
869
|
-
error: "workflow domain events query failed",
|
|
870
|
-
message: e?.message ?? String(e)
|
|
871
|
-
}, a);
|
|
872
|
-
}
|
|
873
|
-
}, V = async (e, t, n, r = {}) => {
|
|
874
|
-
let a = v(t).match(/^\/_voltro\/inspect\/workflows\/events\/([^/]+)\/deliveries$/);
|
|
875
|
-
if (!a) return null;
|
|
876
|
-
let s = decodeURIComponent(a[1] ?? ""), l = u(n.origin ?? n.Origin), d = (r.method ?? "GET").toUpperCase();
|
|
877
|
-
if (d !== "GET") return c(405, {
|
|
878
|
-
error: "method not allowed",
|
|
879
|
-
expected: "GET"
|
|
880
|
-
}, l);
|
|
881
|
-
if (i()) return c(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, l);
|
|
882
|
-
let f = (r.authResolver ?? o)(n, d);
|
|
883
|
-
if (!f.ok) return c(401, {
|
|
884
|
-
error: "unauthorized",
|
|
885
|
-
reason: f.reason
|
|
886
|
-
}, l);
|
|
887
|
-
if (e.kind !== "api") return c(404, { error: "workflow event deliveries are api-only" }, l);
|
|
888
|
-
if (e.inspectWorkflowEventDeliveries === void 0) return c(200, { deliveries: [] }, l);
|
|
889
|
-
try {
|
|
890
|
-
return c(200, await e.inspectWorkflowEventDeliveries({ eventId: s }), l);
|
|
891
|
-
} catch (e) {
|
|
892
|
-
return c(500, {
|
|
893
|
-
error: "workflow event deliveries query failed",
|
|
894
|
-
message: e?.message ?? String(e)
|
|
895
|
-
}, l);
|
|
896
|
-
}
|
|
897
|
-
}, H = async (e, t, n, r = {}) => {
|
|
898
|
-
if (v(e) !== "/_voltro/inspect/workflows/children") return null;
|
|
899
|
-
let a = u(n.origin ?? n.Origin), s = (r.method ?? "GET").toUpperCase();
|
|
900
|
-
if (s !== "GET") return c(405, {
|
|
901
|
-
error: "method not allowed",
|
|
902
|
-
expected: "GET"
|
|
903
|
-
}, a);
|
|
904
|
-
if (i()) return c(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, a);
|
|
905
|
-
let l = (r.authResolver ?? o)(n, s);
|
|
906
|
-
if (!l.ok) return c(401, {
|
|
907
|
-
error: "unauthorized",
|
|
908
|
-
reason: l.reason
|
|
909
|
-
}, a);
|
|
910
|
-
if (t.kind !== "api") return c(404, { error: "workflow children are api-only" }, a);
|
|
911
|
-
let d = j(e).get("parentExecutionId");
|
|
912
|
-
if (d === null || d === "") return c(400, { error: "parentExecutionId query param required" }, a);
|
|
913
|
-
if (t.inspectWorkflowChildren === void 0) return c(200, {
|
|
914
|
-
runs: [],
|
|
915
|
-
total: 0,
|
|
916
|
-
offset: 0,
|
|
917
|
-
limit: 200
|
|
918
|
-
}, a);
|
|
919
|
-
try {
|
|
920
|
-
return c(200, await t.inspectWorkflowChildren({ parentExecutionId: d }), a);
|
|
921
|
-
} catch (e) {
|
|
922
|
-
return c(500, {
|
|
923
|
-
error: "children query failed",
|
|
924
|
-
message: e?.message ?? String(e)
|
|
925
|
-
}, a);
|
|
926
|
-
}
|
|
927
|
-
}, U = async (e, t, n, r, a = {}) => {
|
|
928
|
-
let s = v(e).match(/^\/_voltro\/inspect\/workflows\/runs\/([^/]+)\/(cancel|retry|suspend|resume-from-step|resume|signal|update|discard|redrive)$/);
|
|
929
|
-
if (!s) return null;
|
|
930
|
-
let l = decodeURIComponent(s[1] ?? ""), d = s[2], f = u(n.origin ?? n.Origin), p = (a.method ?? "POST").toUpperCase();
|
|
931
|
-
if (p !== "POST") return c(405, {
|
|
932
|
-
error: "method not allowed",
|
|
933
|
-
expected: "POST"
|
|
934
|
-
}, f);
|
|
935
|
-
if (i()) return c(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, f);
|
|
936
|
-
let m = (a.authResolver ?? o)(n, p);
|
|
937
|
-
if (!m.ok) return c(401, {
|
|
938
|
-
error: "unauthorized",
|
|
939
|
-
reason: m.reason
|
|
940
|
-
}, f);
|
|
941
|
-
if (t.kind !== "api") return c(404, { error: "workflow actions are api-only" }, f);
|
|
942
|
-
let h = {
|
|
943
|
-
cancel: t.inspectCancelWorkflowRun,
|
|
944
|
-
retry: t.inspectRetryWorkflowRun,
|
|
945
|
-
suspend: t.inspectSuspendWorkflowRun,
|
|
946
|
-
resume: t.inspectResumeWorkflowRun,
|
|
947
|
-
signal: t.inspectSignalWorkflowRun,
|
|
948
|
-
update: t.inspectUpdateWorkflowRun,
|
|
949
|
-
discard: t.inspectDiscardWorkflowRun,
|
|
950
|
-
redrive: t.inspectRedriveWorkflowRun,
|
|
951
|
-
"resume-from-step": t.inspectResumeWorkflowRunFromStep
|
|
952
|
-
}[d];
|
|
953
|
-
if (!h) return c(404, { error: d === "resume-from-step" ? "inspectResumeWorkflowRunFromStep not configured" : `inspect${d[0]?.toUpperCase() ?? ""}${d.slice(1)}WorkflowRun not configured` }, f);
|
|
954
|
-
let g, _, y, b, x, S, C;
|
|
955
|
-
if (r.length > 0) try {
|
|
956
|
-
let e = JSON.parse(r);
|
|
957
|
-
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));
|
|
958
|
-
} catch {}
|
|
959
|
-
if (d === "signal" && _ === void 0) return c(400, { error: "signal requires JSON body `{ signalName: string, payload?: unknown }`" }, f);
|
|
960
|
-
if (d === "update" && b === void 0) return c(400, { error: "update requires JSON body `{ updateName: string, payload?: unknown, timeoutMs?: number }`" }, f);
|
|
961
|
-
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);
|
|
962
|
-
try {
|
|
963
|
-
return c(200, d === "retry" && g !== void 0 ? await h({
|
|
964
|
-
runId: l,
|
|
965
|
-
payloadOverride: g
|
|
966
|
-
}) : d === "signal" ? await h({
|
|
967
|
-
runId: l,
|
|
968
|
-
signalName: _,
|
|
969
|
-
payload: y
|
|
970
|
-
}) : d === "update" ? await h({
|
|
971
|
-
runId: l,
|
|
972
|
-
updateName: b,
|
|
973
|
-
payload: x,
|
|
974
|
-
...S === void 0 ? {} : { timeoutMs: S }
|
|
975
|
-
}) : d === "resume-from-step" ? await h({
|
|
976
|
-
runId: l,
|
|
977
|
-
step: C
|
|
978
|
-
}) : await h({ runId: l }), f);
|
|
979
|
-
} catch (e) {
|
|
980
|
-
return c(500, {
|
|
981
|
-
error: `${d} failed`,
|
|
982
|
-
message: e?.message ?? String(e)
|
|
983
|
-
}, f);
|
|
984
|
-
}
|
|
985
|
-
}, W = async (e, t, n, r, a = {}) => {
|
|
986
|
-
if (v(e) !== "/_voltro/inspect/data/import" || (a.method ?? "POST").toUpperCase() !== "POST") return null;
|
|
987
|
-
let s = u(n.origin ?? n.Origin);
|
|
988
|
-
if (i()) return c(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, s);
|
|
989
|
-
let l = (a.authResolver ?? o)(n, "POST");
|
|
990
|
-
if (!l.ok) return c(401, {
|
|
991
|
-
error: "unauthorized",
|
|
992
|
-
reason: l.reason
|
|
993
|
-
}, s);
|
|
994
|
-
let d = f(a.method, n, s);
|
|
995
|
-
if (d) return d;
|
|
996
|
-
if (t.kind !== "api") return c(404, { error: "data import is api-only" }, s);
|
|
997
|
-
if (!t.inspectImport) return c(404, { error: "inspectImport not configured" }, s);
|
|
998
|
-
let p;
|
|
999
|
-
try {
|
|
1000
|
-
p = JSON.parse(r || "{}");
|
|
1001
|
-
} catch {
|
|
1002
|
-
return c(400, { error: "body must be JSON" }, s);
|
|
1003
|
-
}
|
|
1004
|
-
if (typeof p.bundleDir != "string" || !p.bundleDir) return c(400, { error: "body.bundleDir (string) is required" }, s);
|
|
1005
|
-
try {
|
|
1006
|
-
return c(200, await t.inspectImport({
|
|
1007
|
-
bundleDir: p.bundleDir,
|
|
1008
|
-
...p.mode === "upsert" || p.mode === "append" || p.mode === "replace" ? { mode: p.mode } : {},
|
|
1009
|
-
...p.onConflict === "skip" || p.onConflict === "fail" ? { onConflict: p.onConflict } : {},
|
|
1010
|
-
...typeof p.atomic == "boolean" ? { atomic: p.atomic } : {}
|
|
1011
|
-
}), s);
|
|
1012
|
-
} catch (e) {
|
|
1013
|
-
return c(500, {
|
|
1014
|
-
error: "import failed",
|
|
1015
|
-
message: e?.message ?? String(e)
|
|
1016
|
-
}, s);
|
|
1017
|
-
}
|
|
1018
|
-
}, G = async (e, t, n, r, a = {}) => {
|
|
1019
|
-
let s = v(e);
|
|
1020
|
-
if (!s.startsWith("/_voltro/inspect/data/rows")) return null;
|
|
1021
|
-
let l = (a.method ?? "POST").toUpperCase();
|
|
1022
|
-
if (l === "GET" && s === "/_voltro/inspect/data/rows") return null;
|
|
1023
|
-
let d = u(n.origin ?? n.Origin);
|
|
1024
|
-
if (i()) return c(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, d);
|
|
1025
|
-
let f = (a.authResolver ?? o)(n, l);
|
|
1026
|
-
if (!f.ok) return c(401, {
|
|
1027
|
-
error: "unauthorized",
|
|
1028
|
-
reason: f.reason
|
|
1029
|
-
}, d);
|
|
1030
|
-
if (t.kind !== "api") return c(404, { error: "data viewer is api-only" }, d);
|
|
1031
|
-
if (l === "POST" && s === "/_voltro/inspect/data/rows") {
|
|
1032
|
-
if (!t.inspectInsertRow) return c(404, { error: "inspectInsertRow not configured" }, d);
|
|
1033
|
-
let e;
|
|
1034
|
-
try {
|
|
1035
|
-
e = JSON.parse(r || "{}");
|
|
1036
|
-
} catch {
|
|
1037
|
-
return c(400, { error: "body must be JSON" }, d);
|
|
1038
|
-
}
|
|
1039
|
-
if (typeof e.table != "string" || !e.row || typeof e.row != "object") return c(400, { error: "body must be { table: string, row: object }" }, d);
|
|
1040
|
-
try {
|
|
1041
|
-
return c(200, await t.inspectInsertRow({
|
|
1042
|
-
table: e.table,
|
|
1043
|
-
row: e.row
|
|
1044
|
-
}), d);
|
|
1045
|
-
} catch (e) {
|
|
1046
|
-
return c(500, {
|
|
1047
|
-
error: "insert failed",
|
|
1048
|
-
message: e?.message ?? String(e)
|
|
1049
|
-
}, d);
|
|
1050
|
-
}
|
|
1051
|
-
}
|
|
1052
|
-
let p = s.match(/^\/_voltro\/inspect\/data\/rows\/([^/]+)$/);
|
|
1053
|
-
if (!p) return null;
|
|
1054
|
-
let m = decodeURIComponent(p[1] ?? "");
|
|
1055
|
-
if (!m) return c(400, { error: "row id is required in URL" }, d);
|
|
1056
|
-
let h = j(e).get("table") ?? "";
|
|
1057
|
-
if (!h) return c(400, { error: "query.table is required" }, d);
|
|
1058
|
-
if (l === "PATCH") {
|
|
1059
|
-
if (!t.inspectUpdateRow) return c(404, { error: "inspectUpdateRow not configured" }, d);
|
|
1060
|
-
let e;
|
|
1061
|
-
try {
|
|
1062
|
-
e = JSON.parse(r || "{}");
|
|
1063
|
-
} catch {
|
|
1064
|
-
return c(400, { error: "body must be JSON" }, d);
|
|
1065
|
-
}
|
|
1066
|
-
if (!e.patch || typeof e.patch != "object") return c(400, { error: "body.patch must be an object" }, d);
|
|
1067
|
-
try {
|
|
1068
|
-
return c(200, await t.inspectUpdateRow({
|
|
1069
|
-
table: h,
|
|
1070
|
-
id: m,
|
|
1071
|
-
patch: e.patch
|
|
1072
|
-
}), d);
|
|
1073
|
-
} catch (e) {
|
|
1074
|
-
return c(500, {
|
|
1075
|
-
error: "update failed",
|
|
1076
|
-
message: e?.message ?? String(e)
|
|
1077
|
-
}, d);
|
|
1078
|
-
}
|
|
1079
|
-
}
|
|
1080
|
-
if (l === "DELETE") {
|
|
1081
|
-
if (!t.inspectDeleteRow) return c(404, { error: "inspectDeleteRow not configured" }, d);
|
|
1082
|
-
try {
|
|
1083
|
-
return c(200, await t.inspectDeleteRow({
|
|
1084
|
-
table: h,
|
|
1085
|
-
id: m
|
|
1086
|
-
}), d);
|
|
1087
|
-
} catch (e) {
|
|
1088
|
-
return c(500, {
|
|
1089
|
-
error: "delete failed",
|
|
1090
|
-
message: e?.message ?? String(e)
|
|
1091
|
-
}, d);
|
|
1092
|
-
}
|
|
1093
|
-
}
|
|
1094
|
-
return c(405, {
|
|
1095
|
-
error: "method not allowed",
|
|
1096
|
-
expected: "POST | PATCH | DELETE"
|
|
1097
|
-
}, d);
|
|
1098
|
-
}, K = async (e, t, n, a, s = {}) => {
|
|
1099
|
-
let l = v(e), d = `${r}/workflows/flow-control`;
|
|
1100
|
-
if (l !== d && !l.startsWith(`${d}/`)) return null;
|
|
1101
|
-
let f = u(n.origin ?? n.Origin), p = (s.method ?? "GET").toUpperCase();
|
|
1102
|
-
if (i()) return c(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, f);
|
|
1103
|
-
let m = (s.authResolver ?? o)(n, p);
|
|
1104
|
-
if (!m.ok) return c(401, {
|
|
1105
|
-
error: "unauthorized",
|
|
1106
|
-
reason: m.reason
|
|
1107
|
-
}, f);
|
|
1108
|
-
if (t.kind !== "api") return c(404, { error: "flow control is api-only" }, f);
|
|
1109
|
-
if (l === `${d}/inferences`) {
|
|
1110
|
-
if (p !== "GET") return c(405, {
|
|
1111
|
-
error: "method not allowed",
|
|
1112
|
-
expected: "GET"
|
|
1113
|
-
}, f);
|
|
1114
|
-
if (t.inspectInferences === void 0) return c(404, { error: "inspectInferences not configured" }, f);
|
|
1115
|
-
let n = j(e).get("limit"), r = n === null ? void 0 : Number(n);
|
|
1116
|
-
try {
|
|
1117
|
-
return c(200, await t.inspectInferences(r !== void 0 && Number.isFinite(r) ? { limit: r } : {}), f);
|
|
1118
|
-
} catch (e) {
|
|
1119
|
-
return c(500, {
|
|
1120
|
-
error: "inference queue read failed",
|
|
1121
|
-
message: e?.message ?? String(e)
|
|
1122
|
-
}, f);
|
|
1123
|
-
}
|
|
1124
|
-
}
|
|
1125
|
-
if (l === d) {
|
|
1126
|
-
if (p !== "GET") return c(405, {
|
|
1127
|
-
error: "method not allowed",
|
|
1128
|
-
expected: "GET"
|
|
1129
|
-
}, f);
|
|
1130
|
-
if (t.inspectFlowControl === void 0) return c(404, { error: "inspectFlowControl not configured" }, f);
|
|
1131
|
-
let n = j(e).get("limit"), r = n === null ? void 0 : Number(n);
|
|
1132
|
-
try {
|
|
1133
|
-
return c(200, await t.inspectFlowControl(r !== void 0 && Number.isFinite(r) ? { limit: r } : {}), f);
|
|
1134
|
-
} catch (e) {
|
|
1135
|
-
return c(500, {
|
|
1136
|
-
error: "flow control read failed",
|
|
1137
|
-
message: e?.message ?? String(e)
|
|
1138
|
-
}, f);
|
|
1139
|
-
}
|
|
1140
|
-
}
|
|
1141
|
-
if (p !== "POST") return c(405, {
|
|
1142
|
-
error: "method not allowed",
|
|
1143
|
-
expected: "POST"
|
|
1144
|
-
}, f);
|
|
1145
|
-
let h = {};
|
|
1146
|
-
if (a.length > 0) try {
|
|
1147
|
-
h = JSON.parse(a);
|
|
1148
|
-
} catch {
|
|
1149
|
-
return c(400, { error: "expected a JSON body" }, f);
|
|
1150
|
-
}
|
|
1151
|
-
let g = l.slice(d.length + 1);
|
|
1152
|
-
try {
|
|
1153
|
-
if (g === "pause") return t.inspectPauseWorkflow === void 0 ? c(404, { error: "inspectPauseWorkflow not configured" }, f) : h.workflow ? c(200, await t.inspectPauseWorkflow({
|
|
1154
|
-
workflow: h.workflow,
|
|
1155
|
-
...h.reason === void 0 ? {} : { reason: h.reason }
|
|
1156
|
-
}), f) : c(400, { error: "body.workflow is required" }, f);
|
|
1157
|
-
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);
|
|
1158
|
-
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);
|
|
1159
|
-
if (g === "bulk") {
|
|
1160
|
-
if (t.inspectBulkWorkflowRuns === void 0) return c(404, { error: "inspectBulkWorkflowRuns not configured" }, f);
|
|
1161
|
-
if (h.op !== "cancel" && h.op !== "replay") return c(400, { error: "body.op must be 'cancel' or 'replay'" }, f);
|
|
1162
|
-
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);
|
|
1163
|
-
try {
|
|
1164
|
-
return c(200, await t.inspectBulkWorkflowRuns({
|
|
1165
|
-
op: h.op,
|
|
1166
|
-
limit: h.limit,
|
|
1167
|
-
...h.reason === void 0 ? {} : { reason: h.reason },
|
|
1168
|
-
...h.mode === void 0 ? {} : { mode: h.mode },
|
|
1169
|
-
...h.dryRun === void 0 ? {} : { dryRun: h.dryRun },
|
|
1170
|
-
...h.workflow === void 0 ? {} : { workflow: h.workflow },
|
|
1171
|
-
...h.status === void 0 ? {} : { status: h.status },
|
|
1172
|
-
...h.startedAfter === void 0 ? {} : { startedAfter: h.startedAfter },
|
|
1173
|
-
...h.startedBefore === void 0 ? {} : { startedBefore: h.startedBefore }
|
|
1174
|
-
}), f);
|
|
1175
|
-
} catch (e) {
|
|
1176
|
-
if (e?.name === "BulkRequestError") return c(400, { error: e.message }, f);
|
|
1177
|
-
throw e;
|
|
1178
|
-
}
|
|
1179
|
-
}
|
|
1180
|
-
} catch (e) {
|
|
1181
|
-
return c(500, {
|
|
1182
|
-
error: "flow control action failed",
|
|
1183
|
-
message: e?.message ?? String(e)
|
|
1184
|
-
}, f);
|
|
1185
|
-
}
|
|
1186
|
-
return c(404, {
|
|
1187
|
-
error: `unknown flow-control action '${g}'`,
|
|
1188
|
-
expected: [
|
|
1189
|
-
"pause",
|
|
1190
|
-
"resume",
|
|
1191
|
-
"discard",
|
|
1192
|
-
"bulk"
|
|
1193
|
-
]
|
|
1194
|
-
}, f);
|
|
1195
|
-
};
|
|
1196
|
-
//#endregion
|
|
1197
|
-
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 };
|