@voltro/cli 0.10.0 → 0.11.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 +134 -0
- package/THIRD-PARTY-NOTICES.md +1047 -22
- package/bin/voltro.mjs +16 -7
- package/dist/apiBuild-BGd-BnHq.js +2 -0
- package/dist/{apiBuild-DTLPSlt9.js → apiBuild-D_kEJTxc.js} +10 -10
- package/dist/bin.js +2 -2
- package/dist/bootTiming-BdyP9nYw.js +38 -0
- package/dist/{commands-B0QT8dUY.js → commands-BiQsbV50.js} +2191 -2039
- package/dist/dev-DH13Ysgs.js +2 -0
- package/dist/{dev-CK9fbuAM.js → dev-zJGsTTNb.js} +2317 -2282
- package/dist/index.js +1 -1
- package/dist/{inspectMetrics-BeMjgt8x.js → inspectMetrics-BuBwg1yW.js} +1169 -1137
- package/dist/{serveCommand-YR3mKjvf.js → serveCommand-BU454-ay.js} +272 -296
- package/dist/serveEntry.js +3 -3
- package/dist/{start-C_M4fGS2.js → start-ChN6PO-c.js} +338 -323
- package/dist/startEntry.js +2 -2
- package/package.json +23 -17
- package/templates/agent-docs/data.md +107 -0
- package/templates/agent-docs/database/seedsdialects.md +21 -1
- package/templates/agent-docs/deployment.md +49 -0
- package/templates/agent-docs/internationalization.md +36 -0
- package/templates/agent-docs/multi-tenancy.md +33 -0
- package/templates/apps/api-ai/package.json +7 -7
- package/templates/apps/api-auth/package.json +8 -8
- package/templates/apps/api-backend/package.json +7 -7
- package/templates/apps/api-backend-deactivation/package.json +7 -7
- package/templates/apps/api-backend-mail/package.json +8 -8
- package/templates/apps/api-backend-mariadb/package.json +9 -9
- package/templates/apps/api-backend-storage/package.json +8 -8
- package/templates/apps/api-data-advanced/package.json +8 -8
- package/templates/apps/api-durable/package.json +8 -8
- package/templates/apps/api-feature-flags/package.json +9 -9
- package/templates/apps/api-governance/package.json +8 -8
- package/templates/apps/api-kv/package.json +8 -8
- package/templates/apps/api-moderation/package.json +8 -8
- package/templates/apps/api-observability/package.json +8 -8
- package/templates/apps/api-ratelimit/package.json +8 -8
- package/templates/apps/api-rbac/package.json +8 -8
- package/templates/apps/api-rest/package.json +7 -7
- package/templates/apps/api-saas/package.json +11 -11
- package/templates/apps/api-search/package.json +8 -8
- package/templates/apps/api-versioning/package.json +8 -8
- package/templates/apps/api-webhooks/package.json +8 -8
- package/templates/apps/changelog/package.json +6 -6
- package/templates/apps/edge-functions/package.json +2 -2
- package/templates/apps/frontend-admin/package.json +8 -8
- package/templates/apps/frontend-app/package.json +8 -8
- package/templates/apps/frontend-blank/package.json +7 -7
- package/templates/apps/frontend-contact/package.json +7 -7
- package/templates/apps/frontend-dashboard/package.json +7 -7
- package/templates/apps/frontend-docs/package.json +7 -7
- package/templates/apps/frontend-i18n/package.json +6 -6
- package/templates/apps/frontend-landing/package.json +7 -7
- package/templates/apps/frontend-spa/package.json +7 -7
- package/templates/apps/frontend-ssr/package.json +7 -7
- package/templates/apps/frontend-ssr-api/package.json +8 -8
- package/templates/apps/frontend-static-blog/package.json +6 -6
- package/dist/apiBuild-BbR1nYcE.js +0 -2
- package/dist/dev-BJvbwjSz.js +0 -2
|
@@ -6,18 +6,18 @@ import { Cause as d, Effect as f, Layer as p } from "effect";
|
|
|
6
6
|
import { LoggerLayer as m, addSink as h, createLogger as g, printReadyBlock as _ } from "@voltro/logger";
|
|
7
7
|
import { closeSync as v, existsSync as y, mkdirSync as b, openSync as x, promises as S, readFileSync as C, readdirSync as w, statSync as T, unlinkSync as E, unwatchFile as ee, watchFile as D, writeSync as te } from "node:fs";
|
|
8
8
|
import { currentTraceContext as O, lastWriteProvenance as k, recordSample as A, resolveSecret as j } from "@voltro/runtime";
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
9
|
+
import { createRequire as ne } from "node:module";
|
|
10
|
+
import { homedir as re } from "node:os";
|
|
11
|
+
import { FRAMEWORK_ENV_CATALOG as M, appEnvEntries as ie, checkEnvNaming as N, formatEnvErrors as ae, installEnvSnapshot as P, isEnvContract as oe, pluginEnvEntries as se, renderDotEnvExample as F, resolveEnv as ce } from "@voltro/env";
|
|
11
12
|
import { __installPublicEnv as le } from "@voltro/env/public";
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import { timingSafeStringEqual as
|
|
15
|
-
import {
|
|
16
|
-
import { createConnection as
|
|
17
|
-
import {
|
|
18
|
-
import { PassThrough as he } from "node:stream";
|
|
13
|
+
import { mkdir as ue, readFile as de, writeFile as I } from "node:fs/promises";
|
|
14
|
+
import { createHash as fe } from "node:crypto";
|
|
15
|
+
import { timingSafeStringEqual as pe } from "@voltro/protocol/session";
|
|
16
|
+
import { spawn as me } from "node:child_process";
|
|
17
|
+
import { createConnection as he } from "node:net";
|
|
18
|
+
import { PassThrough as ge } from "node:stream";
|
|
19
19
|
//#region src/cliRuntime.ts
|
|
20
|
-
var
|
|
20
|
+
var _e = [
|
|
21
21
|
"severity",
|
|
22
22
|
"code",
|
|
23
23
|
"detail",
|
|
@@ -34,14 +34,14 @@ var ge = [
|
|
|
34
34
|
"file",
|
|
35
35
|
"line",
|
|
36
36
|
"routine"
|
|
37
|
-
],
|
|
37
|
+
], L = (e, t = 0, n = /* @__PURE__ */ new WeakSet()) => {
|
|
38
38
|
if (t > 10 || typeof e != "object" || !e || n.has(e)) return null;
|
|
39
39
|
n.add(e);
|
|
40
40
|
let r = e, i = r.message;
|
|
41
41
|
if (typeof i == "string" && i.length > 0 && i !== "Failed to execute statement") {
|
|
42
42
|
let e = { message: i };
|
|
43
43
|
typeof r.stack == "string" && (e.stack = r.stack);
|
|
44
|
-
for (let t of
|
|
44
|
+
for (let t of _e) r[t] !== void 0 && (e[t] = r[t]);
|
|
45
45
|
return e;
|
|
46
46
|
}
|
|
47
47
|
for (let e of [
|
|
@@ -54,20 +54,20 @@ var ge = [
|
|
|
54
54
|
]) {
|
|
55
55
|
let i = r[e];
|
|
56
56
|
if (i !== void 0) {
|
|
57
|
-
let e =
|
|
57
|
+
let e = L(i, t + 1, n);
|
|
58
58
|
if (e) return e;
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
if (Array.isArray(r.failures)) for (let e of r.failures) {
|
|
62
|
-
let r =
|
|
62
|
+
let r = L(e, t + 1, n);
|
|
63
63
|
if (r) return r;
|
|
64
64
|
}
|
|
65
65
|
return null;
|
|
66
|
-
},
|
|
66
|
+
}, ve = (e = {}) => p.merge(l.layer, m({
|
|
67
67
|
...e.scope ? { defaultScope: e.scope } : {},
|
|
68
68
|
...e.logger
|
|
69
|
-
})),
|
|
70
|
-
let n = e.pipe(f.provide(
|
|
69
|
+
})), ye = async (e, t = {}) => {
|
|
70
|
+
let n = e.pipe(f.provide(ve(t)));
|
|
71
71
|
return await f.runPromise(f.matchCauseEffect(n, {
|
|
72
72
|
onSuccess: (e) => f.succeed(e),
|
|
73
73
|
onFailure: (e) => {
|
|
@@ -83,7 +83,7 @@ var ge = [
|
|
|
83
83
|
}
|
|
84
84
|
let n = null;
|
|
85
85
|
for (let e of t) {
|
|
86
|
-
let t =
|
|
86
|
+
let t = L(e);
|
|
87
87
|
if (t) {
|
|
88
88
|
n = t;
|
|
89
89
|
break;
|
|
@@ -103,41 +103,41 @@ var ge = [
|
|
|
103
103
|
return f.zipRight(f.logError("cli command failed", r), f.succeed(1));
|
|
104
104
|
}
|
|
105
105
|
}).pipe(f.provide(m(t.logger ?? {}))));
|
|
106
|
-
},
|
|
107
|
-
let n = e.pipe(f.provide(
|
|
106
|
+
}, be = (e, t = {}) => {
|
|
107
|
+
let n = e.pipe(f.provide(ve(t)));
|
|
108
108
|
u.runMain(n, { disableErrorReporting: !1 });
|
|
109
|
-
},
|
|
109
|
+
}, R = t(o(import.meta.url)), xe = [a(R, "..", "templates"), a(R, "..", "..", "templates")], Se = (e) => ({
|
|
110
110
|
_tag: "TemplateNotFoundError",
|
|
111
111
|
searched: e
|
|
112
|
-
}),
|
|
112
|
+
}), Ce = ["AGENTS.md", "CLAUDE.md"], we = "voltro:agents-md:keep", Te = 2048, Ee = "<!-- VOLTRO:INDEX -->", z = (e, t) => e.exists(t).pipe(f.orElseSucceed(() => !1)), B = (e, t) => e.readFileString(t).pipe(f.orElseSucceed(() => "")), De = (e, t) => e.readFileString(t).pipe(f.map((e) => {
|
|
113
113
|
try {
|
|
114
114
|
return JSON.parse(e).workspaces !== void 0;
|
|
115
115
|
} catch {
|
|
116
116
|
return !1;
|
|
117
117
|
}
|
|
118
|
-
}), f.orElseSucceed(() => !1)),
|
|
118
|
+
}), f.orElseSucceed(() => !1)), Oe = (e) => f.gen(function* () {
|
|
119
119
|
let n = yield* c.FileSystem, i = a(e);
|
|
120
120
|
for (;;) {
|
|
121
|
-
if ((yield*
|
|
121
|
+
if ((yield* z(n, r(i, ".git"))) || (yield* z(n, r(i, "pnpm-workspace.yaml"))) || (yield* De(n, r(i, "package.json")))) return i;
|
|
122
122
|
let o = t(i);
|
|
123
123
|
if (o === i) return a(e);
|
|
124
124
|
i = o;
|
|
125
125
|
}
|
|
126
|
-
}),
|
|
126
|
+
}), ke = (e, t, n) => f.gen(function* () {
|
|
127
127
|
yield* e.makeDirectory(n, { recursive: !0 }).pipe(f.orElseSucceed(() => void 0));
|
|
128
128
|
let i = yield* e.readDirectory(t).pipe(f.orElseSucceed(() => []));
|
|
129
129
|
for (let a of i) {
|
|
130
130
|
let i = r(t, a), o = r(n, a);
|
|
131
|
-
(yield* e.stat(i).pipe(f.orElseSucceed(() => null)))?.type === "Directory" ? yield*
|
|
131
|
+
(yield* e.stat(i).pipe(f.orElseSucceed(() => null)))?.type === "Directory" ? yield* ke(e, i, o) : yield* e.copyFile(i, o).pipe(f.orElseSucceed(() => void 0));
|
|
132
132
|
}
|
|
133
|
-
}),
|
|
133
|
+
}), Ae = (e) => typeof e?.name == "string" && e.name.length > 0 ? e.name.split("#")[0] : null, je = (e, t) => f.gen(function* () {
|
|
134
134
|
let n = r(t, "app.config.ts");
|
|
135
|
-
if (!(yield*
|
|
135
|
+
if (!(yield* z(e, n))) return null;
|
|
136
136
|
let i = (yield* f.tryPromise(() => import(s(n).href)).pipe(f.orElseSucceed(() => null)))?.default;
|
|
137
|
-
return !i || i.type && i.type !== "api" ? i?.type === "web" ? [] : null : (i.plugins ?? []).map(
|
|
138
|
-
}),
|
|
137
|
+
return !i || i.type && i.type !== "api" ? i?.type === "web" ? [] : null : (i.plugins ?? []).map(Ae).filter((e) => e !== null);
|
|
138
|
+
}), Me = (e, t) => f.gen(function* () {
|
|
139
139
|
let n = [], i = [], a = r(t, "apps");
|
|
140
|
-
if (!(yield*
|
|
140
|
+
if (!(yield* z(e, a))) return {
|
|
141
141
|
apis: n,
|
|
142
142
|
webs: i
|
|
143
143
|
};
|
|
@@ -145,8 +145,8 @@ var ge = [
|
|
|
145
145
|
let o = r(a, t);
|
|
146
146
|
if ((yield* e.stat(o).pipe(f.orElseSucceed(() => null)))?.type === "Directory") for (let t of yield* e.readDirectory(o).pipe(f.orElseSucceed(() => []))) {
|
|
147
147
|
let a = r(o, t), s = r(a, "app.config.ts");
|
|
148
|
-
if (!(yield*
|
|
149
|
-
let c = yield*
|
|
148
|
+
if (!(yield* z(e, s))) continue;
|
|
149
|
+
let c = yield* B(e, s);
|
|
150
150
|
/type:\s*['"]web['"]/.test(c) ? i.push(a) : n.push(a);
|
|
151
151
|
}
|
|
152
152
|
}
|
|
@@ -154,7 +154,7 @@ var ge = [
|
|
|
154
154
|
apis: n,
|
|
155
155
|
webs: i
|
|
156
156
|
};
|
|
157
|
-
}),
|
|
157
|
+
}), Ne = (e) => e.replace(/\|/g, "\\|").replace(/\n/g, " ").trim(), Pe = (e, t, n) => {
|
|
158
158
|
let r = [
|
|
159
159
|
"<!-- voltro agent-docs index — regenerated at seed time -->",
|
|
160
160
|
"## Deep reference (read on demand)",
|
|
@@ -166,17 +166,17 @@ var ge = [
|
|
|
166
166
|
"",
|
|
167
167
|
"| Topic | Open | Summary |",
|
|
168
168
|
"|---|---|---|",
|
|
169
|
-
...e.modules.map((e) => `| ${e.title} | \`${n}${e.path}\` | ${
|
|
169
|
+
...e.modules.map((e) => `| ${e.title} | \`${n}${e.path}\` | ${Ne(e.description)} |`),
|
|
170
170
|
""
|
|
171
|
-
], i = new Map(e.plugins.map((e) => [e.pkg, e])), a = t === null ? e.plugins.map((e) => `| ${e.slug} | \`node_modules/${e.pkg}/README.md\` | ${
|
|
171
|
+
], i = new Map(e.plugins.map((e) => [e.pkg, e])), a = t === null ? e.plugins.map((e) => `| ${e.slug} | \`node_modules/${e.pkg}/README.md\` | ${Ne(e.description)} |`) : t.map((e) => {
|
|
172
172
|
let t = i.get(e);
|
|
173
|
-
return t ? `| ${t.slug} | \`node_modules/${e}/README.md\` | ${
|
|
173
|
+
return t ? `| ${t.slug} | \`node_modules/${e}/README.md\` | ${Ne(t.description)} |` : `| ${e.replace(/^@[^/]+\//, "")} | \`node_modules/${e}/README.md\` | (see plugin README) |`;
|
|
174
174
|
});
|
|
175
175
|
return r.push(`### Plugins${t === null ? "" : " (installed)"}`, "", "| Plugin | Open | Summary |", "|---|---|---|"), r.push(a.length ? a.join("\n") : "| _(none installed)_ | | |", ""), r.join("\n");
|
|
176
|
-
},
|
|
176
|
+
}, Fe = (e, t, n) => {
|
|
177
177
|
let r = t.templates?.[e] ?? t.templates?.[e.replace(/^frontend-/, "")];
|
|
178
178
|
return `\nScaffolded from the \`${e}\` template — see \`${r ? `${n}${r}` : `${n}agent-docs/templates/overview.md`}\`.\n`;
|
|
179
|
-
},
|
|
179
|
+
}, Ie = {
|
|
180
180
|
api: (e, t, n = "") => `# api — agent notes
|
|
181
181
|
|
|
182
182
|
You are in a Voltro **api** app. Server primitives live here: \`queries/\`,
|
|
@@ -216,7 +216,7 @@ You are in a Voltro **web** app. File-based routing under \`src/pages/**\`.
|
|
|
216
216
|
Deep reference (paths from the repo root): \`${e}agent-docs/routing.md\`,
|
|
217
217
|
\`${e}agent-docs/schema-driven-ui.md\`, \`${e}agent-docs/internationalization.md\`.
|
|
218
218
|
${t}`
|
|
219
|
-
},
|
|
219
|
+
}, Le = [
|
|
220
220
|
{
|
|
221
221
|
name: "voltro-schema",
|
|
222
222
|
description: "Define or change a Voltro database table/schema (columns, mixins, indexes, relations).",
|
|
@@ -247,7 +247,7 @@ ${t}`
|
|
|
247
247
|
description: "Export/import + backup/restore Voltro data & assets, and copy prod→dev/stage SAFELY with fail-closed masking/anonymization (.sensitive()/.safe()) + referential subsetting. Use for data takeout, seeding lower envs, backups, or cross-dialect moves.",
|
|
248
248
|
module: "cli.md"
|
|
249
249
|
}
|
|
250
|
-
],
|
|
250
|
+
], Re = (e, t) => `---
|
|
251
251
|
name: ${e.name}
|
|
252
252
|
description: ${e.description}
|
|
253
253
|
---
|
|
@@ -258,10 +258,10 @@ Open the full reference and follow the patterns there:
|
|
|
258
258
|
|
|
259
259
|
Also read the repo-root \`AGENTS.md\` for the always-true rules (browser/server
|
|
260
260
|
boundary, naming, anti-patterns) before editing.
|
|
261
|
-
`,
|
|
262
|
-
let a = yield*
|
|
261
|
+
`, ze = (e, n, r, i) => f.gen(function* () {
|
|
262
|
+
let a = yield* z(e, n);
|
|
263
263
|
if (a) {
|
|
264
|
-
if ((yield*
|
|
264
|
+
if ((yield* B(e, n)).slice(0, Te).includes("voltro:agents-md:keep")) return {
|
|
265
265
|
path: n,
|
|
266
266
|
action: "protected"
|
|
267
267
|
};
|
|
@@ -274,64 +274,64 @@ boundary, naming, anti-patterns) before editing.
|
|
|
274
274
|
path: n,
|
|
275
275
|
action: a ? "overwritten" : "created"
|
|
276
276
|
};
|
|
277
|
-
}),
|
|
278
|
-
let n = yield* c.FileSystem, i = yield*
|
|
279
|
-
for (let e of
|
|
277
|
+
}), Be = (e, t = {}) => f.gen(function* () {
|
|
278
|
+
let n = yield* c.FileSystem, i = yield* Oe(e), o = null;
|
|
279
|
+
for (let e of xe) if (yield* z(n, r(e, "AGENTS.core.md"))) {
|
|
280
280
|
o = e;
|
|
281
281
|
break;
|
|
282
282
|
}
|
|
283
283
|
if (o === null) {
|
|
284
|
-
for (let e of
|
|
285
|
-
let a = yield*
|
|
286
|
-
for (let e of
|
|
284
|
+
for (let e of xe) if (yield* z(n, r(e, "AGENTS.md"))) {
|
|
285
|
+
let a = yield* B(n, r(e, "AGENTS.md")), o = [];
|
|
286
|
+
for (let e of Ce) o.push(yield* ze(n, r(i, e), a, t.force ?? !1));
|
|
287
287
|
return { files: o };
|
|
288
288
|
}
|
|
289
|
-
return yield* f.fail(xe
|
|
289
|
+
return yield* f.fail(Se(xe.map((e) => r(e, "AGENTS.core.md"))));
|
|
290
290
|
}
|
|
291
|
-
let s = yield*
|
|
291
|
+
let s = yield* B(n, r(o, "AGENTS.core.md")), l = yield* B(n, r(o, "agent-docs", "_manifest.json")), u = l ? JSON.parse(l) : {
|
|
292
292
|
modules: [],
|
|
293
293
|
plugins: []
|
|
294
|
-
}, d = (t.preferPointer ?? !1) || (yield*
|
|
295
|
-
if ((yield* f.forEach(h, (e) =>
|
|
294
|
+
}, d = (t.preferPointer ?? !1) || (yield* z(n, r(i, "node_modules/@voltro/cli/templates/agent-docs", "_manifest.json"))), p = d ? "node_modules/@voltro/cli/templates/" : "", m = t.force ?? !1, h = Ce.map((e) => r(i, e));
|
|
295
|
+
if ((yield* f.forEach(h, (e) => B(n, e).pipe(f.map((e) => e.slice(0, Te))))).every((e) => e.includes("voltro:agents-md:keep"))) return { files: h.map((e) => ({
|
|
296
296
|
path: e,
|
|
297
297
|
action: "protected"
|
|
298
298
|
})) };
|
|
299
|
-
let { apis: g, webs: _ } = yield*
|
|
299
|
+
let { apis: g, webs: _ } = yield* Me(n, i), v = /* @__PURE__ */ new Map(), y = /* @__PURE__ */ new Set(), b = !1;
|
|
300
300
|
for (let e of g) {
|
|
301
|
-
let t = yield*
|
|
301
|
+
let t = yield* je(n, e);
|
|
302
302
|
if (v.set(e, t), t !== null) {
|
|
303
303
|
b = !0;
|
|
304
304
|
for (let e of t) y.add(e);
|
|
305
305
|
}
|
|
306
306
|
}
|
|
307
|
-
let x = t.plugins ? t.plugins.map(
|
|
308
|
-
for (let e of h) C.push(yield*
|
|
309
|
-
d || (yield*
|
|
307
|
+
let x = t.plugins ? t.plugins.map(Ae).filter((e) => e !== null) : b ? [...y] : null, S = s.includes(Ee) ? s.replace(Ee, Pe(u, x, p)) : s, C = [];
|
|
308
|
+
for (let e of h) C.push(yield* ze(n, e, S, m));
|
|
309
|
+
d || (yield* ke(n, r(o, "agent-docs"), r(i, "agent-docs")));
|
|
310
310
|
let w = new Map((t.appTemplates ?? []).map((e) => [a(e.dir), e.template])), T = (e) => {
|
|
311
311
|
let t = w.get(a(e));
|
|
312
|
-
return t ?
|
|
313
|
-
}, E = (e, t) => f.forEach(
|
|
314
|
-
for (let e of g) C.push(...yield* E(e,
|
|
315
|
-
for (let e of _) C.push(...yield* E(e,
|
|
316
|
-
for (let e of
|
|
312
|
+
return t ? Fe(t, u, p) : "";
|
|
313
|
+
}, E = (e, t) => f.forEach(Ce, (i) => ze(n, r(e, i), t, m));
|
|
314
|
+
for (let e of g) C.push(...yield* E(e, Ie.api(p, v.get(e) ?? null, T(e)))), (yield* z(n, r(e, "database"))) && C.push(...yield* E(r(e, "database"), Ie.database(p)));
|
|
315
|
+
for (let e of _) C.push(...yield* E(e, Ie.web(p, T(e))));
|
|
316
|
+
for (let e of Le) C.push(yield* ze(n, r(i, ".claude", "skills", e.name, "SKILL.md"), Re(e, p), m));
|
|
317
317
|
return { files: C };
|
|
318
|
-
}),
|
|
318
|
+
}), Ve = (e, t = {}) => f.runPromise(Be(e, t).pipe(f.provide(l.layer))), He = async (e) => {
|
|
319
319
|
let t = e.includes("--force"), n = e.find((e) => !e.startsWith("-")) ?? process.cwd();
|
|
320
|
-
return
|
|
321
|
-
let e = yield*
|
|
320
|
+
return ye(f.gen(function* () {
|
|
321
|
+
let e = yield* Be(n, { force: t });
|
|
322
322
|
for (let t of e.files) {
|
|
323
|
-
let e = t.action === "created" ? "wrote" : t.action === "overwritten" ? "overwrote" : t.action === "protected" ? `protected (hand-maintained — has "${
|
|
323
|
+
let e = t.action === "created" ? "wrote" : t.action === "overwritten" ? "overwrote" : t.action === "protected" ? `protected (hand-maintained — has "${we}")` : "present (use --force to overwrite)";
|
|
324
324
|
yield* f.logInfo(`${t.path.split("/").slice(-2).join("/")} ${e}`, { action: t.action });
|
|
325
325
|
}
|
|
326
326
|
return 0;
|
|
327
327
|
}).pipe(f.catchTag("TemplateNotFoundError", (e) => f.gen(function* () {
|
|
328
328
|
return yield* f.logError("AGENTS.md template not found", { searched: e.searched }), 1;
|
|
329
329
|
}))), { scope: "voltro:agents-md" });
|
|
330
|
-
},
|
|
330
|
+
}, Ue = (e) => e.replace(/\\"|"(?:[^"\\]|\\.)*"|(\/\/[^\n]*|\/\*[\s\S]*?\*\/)/g, (e, t) => t ? "" : e), We = (e) => {
|
|
331
331
|
try {
|
|
332
332
|
let t = r(e, "tsconfig.json");
|
|
333
333
|
if (!y(t)) return [];
|
|
334
|
-
let n = JSON.parse(
|
|
334
|
+
let n = JSON.parse(Ue(C(t, "utf8"))).compilerOptions ?? {}, i = n.paths ?? {}, o = a(e, n.baseUrl ?? "."), s = [];
|
|
335
335
|
for (let [e, t] of Object.entries(i)) {
|
|
336
336
|
let n = t[0];
|
|
337
337
|
if (!n) continue;
|
|
@@ -351,84 +351,17 @@ boundary, naming, anti-patterns) before editing.
|
|
|
351
351
|
} catch {
|
|
352
352
|
return [];
|
|
353
353
|
}
|
|
354
|
-
},
|
|
354
|
+
}, Ge = (e) => {
|
|
355
355
|
let t = e;
|
|
356
356
|
return t?.code === "ERR_MODULE_NOT_FOUND" || /Cannot find (package|module)/.test(String(t?.message ?? ""));
|
|
357
|
-
},
|
|
357
|
+
}, Ke = async (e, t) => {
|
|
358
358
|
try {
|
|
359
359
|
return await t();
|
|
360
360
|
} catch (t) {
|
|
361
|
-
throw
|
|
361
|
+
throw Ge(t) ? Error(`voltro: the build tool '${e}' is not installed.\n\nIt's an OPTIONAL dependency of @voltro/cli — needed by 'voltro dev' and 'voltro build', but excluded from a serve-only production install (that's how prod images stay lean). If you are building, reinstall WITHOUT '--no-optional' (e.g. 'pnpm install'). A production SERVE container does not need '${e}' — it boots from the precompiled bundle.`) : t;
|
|
362
362
|
}
|
|
363
|
-
},
|
|
364
|
-
let
|
|
365
|
-
return {
|
|
366
|
-
get(t) {
|
|
367
|
-
return e.get(t);
|
|
368
|
-
},
|
|
369
|
-
set(t, n) {
|
|
370
|
-
e.set(t, n);
|
|
371
|
-
},
|
|
372
|
-
invalidate(t) {
|
|
373
|
-
e.delete(t);
|
|
374
|
-
},
|
|
375
|
-
invalidateBy(t) {
|
|
376
|
-
let n = 0;
|
|
377
|
-
for (let r of e.keys()) t(r) && (e.delete(r), n++);
|
|
378
|
-
return n;
|
|
379
|
-
},
|
|
380
|
-
clear() {
|
|
381
|
-
e.clear();
|
|
382
|
-
},
|
|
383
|
-
size() {
|
|
384
|
-
return e.size;
|
|
385
|
-
},
|
|
386
|
-
snapshot() {
|
|
387
|
-
return Array.from(e.entries());
|
|
388
|
-
}
|
|
389
|
-
};
|
|
390
|
-
}, qe = (e) => {
|
|
391
|
-
if (typeof e == "number" && Number.isFinite(e) && e > 0) return e * 1e3;
|
|
392
|
-
if (typeof e != "string") return null;
|
|
393
|
-
let t = /^\s*(\d+)\s*(s|seconds?|m|minutes?|h|hours?|d|days?)\s*$/i.exec(e);
|
|
394
|
-
if (!t) return null;
|
|
395
|
-
let n = parseInt(t[1], 10);
|
|
396
|
-
if (!Number.isFinite(n) || n <= 0) return null;
|
|
397
|
-
let r = t[2].toLowerCase();
|
|
398
|
-
return r === "s" || r.startsWith("second") ? n * 1e3 : r === "m" || r.startsWith("minute") ? n * 6e4 : r === "h" || r.startsWith("hour") ? n * 36e5 : r === "d" || r.startsWith("day") ? n * 864e5 : null;
|
|
399
|
-
}, Je = (e, t = {}) => {
|
|
400
|
-
let n = [e];
|
|
401
|
-
return t.tenant !== void 0 && t.tenant !== "" && n.push(`tenant=${t.tenant}`), t.locale !== void 0 && t.locale !== "" && n.push(`lang=${t.locale}`), n.join("|");
|
|
402
|
-
}, Ye = (e, t) => e.expiresAt > t, Xe = (e, t) => e.expiresAt <= t && e.servableUntil > t, Ze = [
|
|
403
|
-
"static",
|
|
404
|
-
"spa",
|
|
405
|
-
"ssr",
|
|
406
|
-
"isr"
|
|
407
|
-
], Qe = (e) => typeof e == "string" && Ze.includes(e), $e = Ze.map((e) => `'${e}'`).join(" | "), et = (e, t) => `[voltro] ${e}: unknown renderMode '${t}'.\n Valid values: ${$e}.${t === "client" || t === "csr" || t === "browser" ? "\n A page that renders only in the browser is 'spa': it is skipped by the prerender and mounts on the client. If its route has a layout, that layout still renders server-side as an SSR shell." : t === "server" || t === "dynamic" ? "\n A page rendered per request is 'ssr'." : t === "ssg" || t === "prerender" ? "\n A page rendered once at build time is 'static' (the default)." : ""}`, tt = class extends Error {
|
|
408
|
-
page;
|
|
409
|
-
value;
|
|
410
|
-
name = "InvalidRenderModeError";
|
|
411
|
-
constructor(e, t) {
|
|
412
|
-
super(et(e, t)), this.page = e, this.value = t;
|
|
413
|
-
}
|
|
414
|
-
}, nt = (e, t = "<page>") => {
|
|
415
|
-
if (e.renderMode !== void 0 && e.renderMode !== null) {
|
|
416
|
-
if (!Qe(e.renderMode)) throw new tt(t, String(e.renderMode));
|
|
417
|
-
return e.renderMode;
|
|
418
|
-
}
|
|
419
|
-
return e.dynamic === "force-dynamic" ? "ssr" : (e.dynamic, "static");
|
|
420
|
-
}, rt = (e, t = "<page>") => ({
|
|
421
|
-
renderMode: nt(e, t),
|
|
422
|
-
tenantAware: e.tenantAware === !0,
|
|
423
|
-
revalidateMs: qe(e.revalidate),
|
|
424
|
-
staleWhileRevalidateMs: qe(e.staleWhileRevalidate) ?? 0,
|
|
425
|
-
cacheInvalidatesOn: Array.isArray(e.cacheInvalidatesOn) ? e.cacheInvalidatesOn : [],
|
|
426
|
-
interactive: e.interactive ?? "full",
|
|
427
|
-
hasLoader: typeof e.loader == "function",
|
|
428
|
-
hasMeta: e.meta != null,
|
|
429
|
-
hasGetStaticPaths: typeof e.getStaticPaths == "function"
|
|
430
|
-
}), it = "// AUTO-GENERATED by Voltro — DO NOT EDIT.\n// Source: app.config.ts `env` (defineEnv). Regenerated on every `voltro dev` boot.\n", at = (e, t) => t ? `${e} | undefined` : e, ot = (e, t) => Object.entries(e.vars).filter(([, e]) => t(e.access)).map(([e, t]) => `${t.description ? ` /** ${t.description} */\n` : ""} readonly ${e}: ${at(t.tsType, t.optional)}`).join("\n"), st = async (e, t) => {
|
|
431
|
-
let n = ot(t, () => !0), i = `${it}
|
|
363
|
+
}, qe = "// AUTO-GENERATED by Voltro — DO NOT EDIT.\n// Source: app.config.ts `env` (defineEnv). Regenerated on every `voltro dev` boot.\n", Je = (e, t) => t ? `${e} | undefined` : e, Ye = (e, t) => Object.entries(e.vars).filter(([, e]) => t(e.access)).map(([e, t]) => `${t.description ? ` /** ${t.description} */\n` : ""} readonly ${e}: ${Je(t.tsType, t.optional)}`).join("\n"), Xe = async (e, t) => {
|
|
364
|
+
let n = Ye(t, () => !0), i = `${qe}
|
|
432
365
|
import '@voltro/env/server'
|
|
433
366
|
|
|
434
367
|
declare module '@voltro/env/server' {
|
|
@@ -437,9 +370,9 @@ ${n.length > 0 ? n : " // (no variables declared)"}
|
|
|
437
370
|
}
|
|
438
371
|
}
|
|
439
372
|
`;
|
|
440
|
-
await
|
|
441
|
-
},
|
|
442
|
-
let n =
|
|
373
|
+
await I(r(e, "env.generated.d.ts"), i, "utf8");
|
|
374
|
+
}, Ze = async (e, t) => {
|
|
375
|
+
let n = Ye(t, (e) => e === "public"), i = `${qe}
|
|
443
376
|
import '@voltro/env/public'
|
|
444
377
|
|
|
445
378
|
declare module '@voltro/env/public' {
|
|
@@ -448,9 +381,9 @@ ${n.length > 0 ? n : " // (no public variables declared)"}
|
|
|
448
381
|
}
|
|
449
382
|
}
|
|
450
383
|
`, a = r(e, "src");
|
|
451
|
-
await
|
|
452
|
-
},
|
|
453
|
-
let n = `${
|
|
384
|
+
await ue(a, { recursive: !0 }), await I(r(a, "voltro-env.d.ts"), i, "utf8");
|
|
385
|
+
}, Qe = async (e, t) => {
|
|
386
|
+
let n = `${qe}
|
|
454
387
|
import { __installPublicEnv } from '@voltro/env/public'
|
|
455
388
|
|
|
456
389
|
export const publicEnvValues = ${JSON.stringify(t, null, 2)} as const
|
|
@@ -458,14 +391,14 @@ export const publicEnvValues = ${JSON.stringify(t, null, 2)} as const
|
|
|
458
391
|
// Set the browser/SSR-shared global the \`publicEnv\` accessor reads.
|
|
459
392
|
__installPublicEnv(publicEnvValues)
|
|
460
393
|
`;
|
|
461
|
-
await
|
|
462
|
-
},
|
|
394
|
+
await ue(e, { recursive: !0 }), await I(r(e, "env.public.ts"), n, "utf8");
|
|
395
|
+
}, $e = async (e) => {
|
|
463
396
|
let t = oe(e.rawEnv) ? e.rawEnv : void 0, n = await ce({
|
|
464
397
|
contract: t,
|
|
465
398
|
resolveSecret: j
|
|
466
|
-
}), r = [...n.errors, ...
|
|
467
|
-
if (r.length > 0) throw Error(
|
|
468
|
-
|
|
399
|
+
}), r = [...n.errors, ...N(t, e.appType)];
|
|
400
|
+
if (r.length > 0) throw Error(ae(r));
|
|
401
|
+
P(n.values), e.appType === "web" && le(n.publicValues);
|
|
469
402
|
let i = t ? Object.keys(t.vars).length : 0;
|
|
470
403
|
if (i > 0) {
|
|
471
404
|
let r = Object.keys(n.publicValues).length;
|
|
@@ -477,214 +410,20 @@ __installPublicEnv(publicEnvValues)
|
|
|
477
410
|
n.length > 0 && e.log.warn(`env: ${n.length} secret var(s) declared on a web app — secrets are reachable only from server-side render code and are NEVER bundled. Prefer declaring secrets on the api.`, { keys: n });
|
|
478
411
|
}
|
|
479
412
|
}
|
|
480
|
-
return e.generateTypes && t && (e.appType === "api" ? await
|
|
413
|
+
return e.generateTypes && t && (e.appType === "api" ? await Xe(e.root, t) : await Ze(e.root, t)), {
|
|
481
414
|
resolved: n,
|
|
482
415
|
contract: t
|
|
483
416
|
};
|
|
484
|
-
},
|
|
485
|
-
|
|
486
|
-
"ECONNRESET",
|
|
487
|
-
"ECONNABORTED",
|
|
488
|
-
"EPIPE",
|
|
489
|
-
"ETIMEDOUT"
|
|
490
|
-
], _t = (e, t = 0) => {
|
|
491
|
-
if (e == null || t > 5) return !1;
|
|
492
|
-
let n = e;
|
|
493
|
-
return typeof n.code == "string" && gt.includes(n.code) || typeof n.message == "string" && gt.some((e) => n.message.includes(e)) || Array.isArray(n.errors) && n.errors.some((e) => _t(e, t + 1)) ? !0 : _t(n.cause, t + 1);
|
|
494
|
-
}, vt = 4e3, yt = () => {
|
|
495
|
-
let e = /* @__PURE__ */ new Set(), t = 0, n = {
|
|
496
|
-
hasWarned: !1,
|
|
497
|
-
info: (e) => {
|
|
498
|
-
let t = mt(e);
|
|
499
|
-
t.length !== 0 && dt.info(t);
|
|
500
|
-
},
|
|
501
|
-
warn: (e) => {
|
|
502
|
-
n.hasWarned = !0;
|
|
503
|
-
let t = mt(e);
|
|
504
|
-
t.length !== 0 && dt.warn(t);
|
|
505
|
-
},
|
|
506
|
-
warnOnce: (t) => {
|
|
507
|
-
let r = mt(t);
|
|
508
|
-
e.has(r) || (e.add(r), n.hasWarned = !0, r.length !== 0 && dt.warn(r));
|
|
509
|
-
},
|
|
510
|
-
error: (e, n) => {
|
|
511
|
-
let r = mt(e), i = n?.error;
|
|
512
|
-
if (r.length !== 0) {
|
|
513
|
-
if (ht.test(r) && _t(i)) {
|
|
514
|
-
let e = Date.now();
|
|
515
|
-
e - t > vt && (t = e, dt.info("waiting for api — proxy upstream not accepting connections yet (still starting?)"));
|
|
516
|
-
return;
|
|
517
|
-
}
|
|
518
|
-
dt.error(r, {}, i);
|
|
519
|
-
}
|
|
520
|
-
},
|
|
521
|
-
clearScreen: () => {},
|
|
522
|
-
hasErrorLogged: (e) => !1
|
|
523
|
-
};
|
|
524
|
-
return n;
|
|
525
|
-
}, bt = (e = process.env) => {
|
|
526
|
-
let t = e.VOLTRO_DEV_SSR_COMPILE_CONCURRENCY;
|
|
527
|
-
if (t === void 0 || t.trim() === "") return 4;
|
|
528
|
-
let n = Number(t);
|
|
529
|
-
return Number.isFinite(n) && n >= 1 ? Math.floor(n) : 4;
|
|
530
|
-
}, xt = (e) => {
|
|
531
|
-
let t = Math.max(1, Math.floor(e)), n = 0, r = [], i = () => n < t ? (n++, Promise.resolve()) : new Promise((e) => r.push(e)), a = () => {
|
|
532
|
-
let e = r.shift();
|
|
533
|
-
e ? e() : n--;
|
|
534
|
-
};
|
|
535
|
-
return {
|
|
536
|
-
withPermit: async (e) => {
|
|
537
|
-
await i();
|
|
538
|
-
try {
|
|
539
|
-
return await e();
|
|
540
|
-
} finally {
|
|
541
|
-
a();
|
|
542
|
-
}
|
|
543
|
-
},
|
|
544
|
-
get active() {
|
|
545
|
-
return n;
|
|
546
|
-
}
|
|
547
|
-
};
|
|
548
|
-
}, St = (e) => {
|
|
549
|
-
let t = xt(e.limit), n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Set();
|
|
550
|
-
return {
|
|
551
|
-
load: (i, a) => {
|
|
552
|
-
if (r.has(i)) return a();
|
|
553
|
-
let o = n.get(i);
|
|
554
|
-
if (o) return o;
|
|
555
|
-
let s = t.withPermit(async () => {
|
|
556
|
-
e.onColdStart?.(i);
|
|
557
|
-
try {
|
|
558
|
-
return await a();
|
|
559
|
-
} finally {
|
|
560
|
-
e.onColdEnd?.(i);
|
|
561
|
-
}
|
|
562
|
-
}).then((e) => (r.add(i), e)).finally(() => {
|
|
563
|
-
n.delete(i);
|
|
564
|
-
});
|
|
565
|
-
return n.set(i, s), s;
|
|
566
|
-
},
|
|
567
|
-
get inFlightCount() {
|
|
568
|
-
return n.size;
|
|
569
|
-
},
|
|
570
|
-
get warmCount() {
|
|
571
|
-
return r.size;
|
|
572
|
-
}
|
|
573
|
-
};
|
|
574
|
-
}, Ct = (e) => {
|
|
575
|
-
let t = [];
|
|
576
|
-
for (let n of e.split("/").filter(Boolean)) n.startsWith("[[...") && n.endsWith("]]") ? t.push({
|
|
577
|
-
name: n.slice(5, -2),
|
|
578
|
-
catchAll: !0,
|
|
579
|
-
optional: !0
|
|
580
|
-
}) : n.startsWith("[...") && n.endsWith("]") ? t.push({
|
|
581
|
-
name: n.slice(4, -1),
|
|
582
|
-
catchAll: !0,
|
|
583
|
-
optional: !1
|
|
584
|
-
}) : n.startsWith("[") && n.endsWith("]") && t.push({
|
|
585
|
-
name: n.slice(1, -1),
|
|
586
|
-
catchAll: !1,
|
|
587
|
-
optional: !1
|
|
588
|
-
});
|
|
589
|
-
return t;
|
|
590
|
-
}, wt = (e) => e.replace(/-([a-z0-9])/g, (e, t) => t.toUpperCase()), Tt = async (e) => {
|
|
591
|
-
let n = a(e);
|
|
592
|
-
for (let e = 0; e < 4; e++) {
|
|
593
|
-
let e = r(n, "project.json");
|
|
594
|
-
if (y(e)) try {
|
|
595
|
-
let t = await S.readFile(e, "utf8");
|
|
596
|
-
return {
|
|
597
|
-
projectDir: n,
|
|
598
|
-
manifest: JSON.parse(t)
|
|
599
|
-
};
|
|
600
|
-
} catch {
|
|
601
|
-
return null;
|
|
602
|
-
}
|
|
603
|
-
let i = t(n);
|
|
604
|
-
if (i === n) break;
|
|
605
|
-
n = i;
|
|
606
|
-
}
|
|
607
|
-
return null;
|
|
608
|
-
}, Et = async (t) => {
|
|
609
|
-
let n = await Tt(t);
|
|
610
|
-
if (!n) return [];
|
|
611
|
-
let { projectDir: i, manifest: a } = n, o = e(t), s = a.apps ?? {}, c = [];
|
|
612
|
-
for (let [e, t] of Object.entries(s)) {
|
|
613
|
-
if (e === o || t.kind !== "web" || typeof t.port != "number") continue;
|
|
614
|
-
let n = r(r(i, t.path ?? e), "src", "pages");
|
|
615
|
-
if (!y(n)) continue;
|
|
616
|
-
let a;
|
|
617
|
-
try {
|
|
618
|
-
let { pages: e } = await gi(n);
|
|
619
|
-
a = e.map((e) => ({
|
|
620
|
-
pattern: e.pattern,
|
|
621
|
-
params: Ct(e.pattern)
|
|
622
|
-
}));
|
|
623
|
-
} catch {
|
|
624
|
-
continue;
|
|
625
|
-
}
|
|
626
|
-
c.push({
|
|
627
|
-
key: wt(e),
|
|
628
|
-
origin: `http://localhost:${t.port}`,
|
|
629
|
-
...typeof t.origin == "string" && t.origin.length > 0 ? { prodOrigin: t.origin } : {},
|
|
630
|
-
routes: a
|
|
631
|
-
});
|
|
632
|
-
}
|
|
633
|
-
return c;
|
|
634
|
-
}, Dt = (e) => {
|
|
635
|
-
if (e.params.length === 0) return `'${e.pattern}'`;
|
|
636
|
-
let t = e.pattern;
|
|
637
|
-
for (let n of e.params) {
|
|
638
|
-
let e = n.optional ? `[[...${n.name}]]` : n.catchAll ? `[...${n.name}]` : `[${n.name}]`, r = n.optional ? "${" + n.name + " === undefined ? \"\" : encodeURI(" + n.name + ")}" : n.catchAll ? "${encodeURI(" + n.name + ")}" : "${encodeURIComponent(" + n.name + ")}";
|
|
639
|
-
t = t.replace(e, r);
|
|
640
|
-
}
|
|
641
|
-
return "`" + t + "`";
|
|
642
|
-
}, Ot = (e) => e.params.length === 0 ? "EmptyParams" : `{ ${e.params.map((e) => {
|
|
643
|
-
let t = "string";
|
|
644
|
-
return e.optional ? `readonly ${e.name}?: ${t}` : `readonly ${e.name}: ${t}`;
|
|
645
|
-
}).join("; ")} }`, kt = (e, t, n) => {
|
|
646
|
-
let r = Ot(e), i = Dt(e), a = t ? "VoltroExternalUrl" : "VoltroRouteUrl", o = t && n ? `${n} + ` : "";
|
|
647
|
-
return e.params.length === 0 ? `() => (${o}${i}) as ${a}` : `({ ${e.params.map((e) => e.name).join(", ")} }: ${r}) => (${o}${i}) as ${a}`;
|
|
648
|
-
}, At = (e) => `{\n${[...e].sort((e, t) => e.pattern.localeCompare(t.pattern)).map((e) => ` ${JSON.stringify(e.pattern)}: ${kt(e, !1)},`).join("\n")}\n}`, jt = (e, t) => {
|
|
649
|
-
if (e.routes.length === 0) return ` ${e.key}: {} as Record<string, never>,`;
|
|
650
|
-
let n = [...e.routes].sort((e, t) => e.pattern.localeCompare(t.pattern)), r = t === "prod" && e.prodOrigin ? e.prodOrigin : e.origin, i = JSON.stringify(r), a = n.map((e) => ` ${JSON.stringify(e.pattern)}: ${kt(e, !0, i)},`);
|
|
651
|
-
return ` ${e.key}: {\n${a.join("\n")}\n },`;
|
|
652
|
-
}, Mt = async (e) => {
|
|
653
|
-
let n = e.pages.map((e) => ({
|
|
654
|
-
pattern: e.pattern,
|
|
655
|
-
params: Ct(e.pattern)
|
|
656
|
-
})), i = await Et(e.appRoot), a = [
|
|
657
|
-
"// THIS FILE IS GENERATED — DO NOT EDIT BY HAND.",
|
|
658
|
-
"// Re-emitted by `voltro dev` whenever `src/pages/**` changes.",
|
|
659
|
-
"// Type-safe route builders consumed by <Link to={...}>.",
|
|
660
|
-
"",
|
|
661
|
-
"import type { VoltroRouteUrl, VoltroExternalUrl } from '@voltro/web'",
|
|
662
|
-
"",
|
|
663
|
-
"type EmptyParams = Record<string, never>",
|
|
664
|
-
""
|
|
665
|
-
].join("\n"), o = e.mode ?? "dev", s = `${a}\n${`export const routes = ${At(n)} as const\n`}\n${i.length === 0 ? "export const siblingApps = {} as Record<string, never>\n" : `export const siblingApps = {\n${i.map((e) => jt(e, o)).join("\n")}\n} as const\n`}`, c = r(e.appRoot, ".framework", "routes.generated.ts");
|
|
666
|
-
await S.mkdir(t(c), { recursive: !0 });
|
|
667
|
-
let l = null;
|
|
668
|
-
try {
|
|
669
|
-
l = await S.readFile(c, "utf8");
|
|
670
|
-
} catch {}
|
|
671
|
-
return l === s ? {
|
|
672
|
-
path: c,
|
|
673
|
-
wrote: !1
|
|
674
|
-
} : (await S.writeFile(c, s, "utf8"), {
|
|
675
|
-
path: c,
|
|
676
|
-
wrote: !0
|
|
677
|
-
});
|
|
678
|
-
}, Nt = (e) => {
|
|
679
|
-
let t = P(e.contract), n = (e.plugins ?? []).flatMap((e) => I(e.name, e.declaredEnv)), r = e.includeFramework === !1 ? [] : re, i = /* @__PURE__ */ new Set(), a = [];
|
|
417
|
+
}, et = (e) => {
|
|
418
|
+
let t = ie(e.contract), n = (e.plugins ?? []).flatMap((e) => se(e.name, e.declaredEnv)), r = e.includeFramework === !1 ? [] : M, i = /* @__PURE__ */ new Set(), a = [];
|
|
680
419
|
for (let e of [
|
|
681
420
|
...t,
|
|
682
421
|
...n,
|
|
683
422
|
...r
|
|
684
423
|
]) i.has(e.key) || (i.add(e.key), a.push(e));
|
|
685
424
|
return a;
|
|
686
|
-
},
|
|
687
|
-
let r =
|
|
425
|
+
}, tt = (e, t, n = (e) => process.env[e]) => {
|
|
426
|
+
let r = et(t).map((e) => {
|
|
688
427
|
let t = n(e.key) !== void 0;
|
|
689
428
|
return {
|
|
690
429
|
...e,
|
|
@@ -701,17 +440,111 @@ __installPublicEnv(publicEnvValues)
|
|
|
701
440
|
missingRequired: r.filter((e) => e.required && !e.isSet && e.default === void 0).length
|
|
702
441
|
}
|
|
703
442
|
};
|
|
704
|
-
},
|
|
443
|
+
}, nt = (e, t) => F(et({
|
|
705
444
|
...e,
|
|
706
445
|
includeFramework: !1
|
|
707
446
|
}), {
|
|
708
447
|
includeFramework: e.includeFramework !== !1,
|
|
709
448
|
...t ? { header: t } : {}
|
|
710
|
-
}),
|
|
449
|
+
}), rt = () => {
|
|
450
|
+
let e = /* @__PURE__ */ new Map();
|
|
451
|
+
return {
|
|
452
|
+
get(t) {
|
|
453
|
+
return e.get(t);
|
|
454
|
+
},
|
|
455
|
+
set(t, n) {
|
|
456
|
+
e.set(t, n);
|
|
457
|
+
},
|
|
458
|
+
invalidate(t) {
|
|
459
|
+
e.delete(t);
|
|
460
|
+
},
|
|
461
|
+
invalidateBy(t) {
|
|
462
|
+
let n = 0;
|
|
463
|
+
for (let r of e.keys()) t(r) && (e.delete(r), n++);
|
|
464
|
+
return n;
|
|
465
|
+
},
|
|
466
|
+
clear() {
|
|
467
|
+
e.clear();
|
|
468
|
+
},
|
|
469
|
+
size() {
|
|
470
|
+
return e.size;
|
|
471
|
+
},
|
|
472
|
+
snapshot() {
|
|
473
|
+
return Array.from(e.entries());
|
|
474
|
+
}
|
|
475
|
+
};
|
|
476
|
+
}, it = (e) => {
|
|
477
|
+
if (typeof e == "number" && Number.isFinite(e) && e > 0) return e * 1e3;
|
|
478
|
+
if (typeof e != "string") return null;
|
|
479
|
+
let t = /^\s*(\d+)\s*(s|seconds?|m|minutes?|h|hours?|d|days?)\s*$/i.exec(e);
|
|
480
|
+
if (!t) return null;
|
|
481
|
+
let n = parseInt(t[1], 10);
|
|
482
|
+
if (!Number.isFinite(n) || n <= 0) return null;
|
|
483
|
+
let r = t[2].toLowerCase();
|
|
484
|
+
return r === "s" || r.startsWith("second") ? n * 1e3 : r === "m" || r.startsWith("minute") ? n * 6e4 : r === "h" || r.startsWith("hour") ? n * 36e5 : r === "d" || r.startsWith("day") ? n * 864e5 : null;
|
|
485
|
+
}, at = (e, t = {}) => {
|
|
486
|
+
let n = [e];
|
|
487
|
+
return t.tenant !== void 0 && t.tenant !== "" && n.push(`tenant=${t.tenant}`), t.locale !== void 0 && t.locale !== "" && n.push(`lang=${t.locale}`), n.join("|");
|
|
488
|
+
}, ot = (e, t) => e.expiresAt > t, st = (e, t) => e.expiresAt <= t && e.servableUntil > t, ct = g({ scope: "voltro:cli" }), lt = [], ut = (e) => {
|
|
489
|
+
lt.length = 0;
|
|
490
|
+
let r = e[1] && !e[1].startsWith("-") ? e[1] : void 0, i = r ? n(r) ? r : a(process.cwd(), r) : process.cwd(), o = [], s = i;
|
|
491
|
+
for (;;) {
|
|
492
|
+
o.push(s);
|
|
493
|
+
let e = t(s);
|
|
494
|
+
if (e === s) break;
|
|
495
|
+
s = e;
|
|
496
|
+
}
|
|
497
|
+
for (let e of o) for (let t of [".env.local", ".env"]) {
|
|
498
|
+
let n = a(e, t);
|
|
499
|
+
if (y(n)) {
|
|
500
|
+
lt.push(n);
|
|
501
|
+
try {
|
|
502
|
+
let e = C(n, "utf8");
|
|
503
|
+
for (let t of e.split(/\r?\n/)) {
|
|
504
|
+
let e = t.trim();
|
|
505
|
+
if (e === "" || e.startsWith("#")) continue;
|
|
506
|
+
let n = e.indexOf("=");
|
|
507
|
+
if (n < 1) continue;
|
|
508
|
+
let r = e.slice(0, n).trim(), i = e.slice(n + 1).trim();
|
|
509
|
+
(i.startsWith("\"") && i.endsWith("\"") || i.startsWith("'") && i.endsWith("'")) && (i = i.slice(1, -1)), process.env[r] === void 0 && (process.env[r] = i);
|
|
510
|
+
}
|
|
511
|
+
} catch (e) {
|
|
512
|
+
ct.warn("failed to load env file (continuing)", { path: n }, e);
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
}, dt = 500, ft = (e, t, n = {}) => {
|
|
517
|
+
if (e.length === 0) return () => {};
|
|
518
|
+
let r = (e) => n.root ? i(n.root, e) : e, a = !1, o = (e) => {
|
|
519
|
+
a || (a = !0, t.warn(`.env changed (${r(e)}) — hard-restarting: process.env is read once at boot, a reload would keep stale values`, { file: r(e) }), Promise.resolve().then(() => n.onBeforeRestart?.()).catch((e) => t.warn(".env restart: onBeforeRestart failed (continuing)", {}, e)).finally(() => {
|
|
520
|
+
let e = me(process.execPath, [...process.execArgv, ...process.argv.slice(1)], {
|
|
521
|
+
stdio: "inherit",
|
|
522
|
+
env: process.env,
|
|
523
|
+
cwd: n.cwd ?? process.cwd()
|
|
524
|
+
}), r = (t) => {
|
|
525
|
+
e.kill(t);
|
|
526
|
+
}, i = () => r("SIGINT"), a = () => r("SIGTERM");
|
|
527
|
+
process.on("SIGINT", i), process.on("SIGTERM", a), e.on("exit", (e, t) => {
|
|
528
|
+
process.off("SIGINT", i), process.off("SIGTERM", a), t ? process.kill(process.pid, t) : process.exit(e ?? 0);
|
|
529
|
+
}), e.on("error", (e) => {
|
|
530
|
+
t.error(".env restart: spawn failed", {}, e), process.exit(1);
|
|
531
|
+
});
|
|
532
|
+
}));
|
|
533
|
+
};
|
|
534
|
+
for (let t of e) D(t, { interval: dt }, (e, n) => {
|
|
535
|
+
e.mtimeMs !== n.mtimeMs && o(t);
|
|
536
|
+
});
|
|
537
|
+
return t.info("watching .env files for changes", {
|
|
538
|
+
files: e.map(r),
|
|
539
|
+
intervalMs: dt
|
|
540
|
+
}), () => {
|
|
541
|
+
for (let t of e) ee(t);
|
|
542
|
+
};
|
|
543
|
+
}, V = "/_voltro/inspect", H = () => process.env.VOLTRO_INSPECT === "off", U = (e) => {
|
|
711
544
|
let t = process.env.VOLTRO_INSPECT_TOKEN;
|
|
712
545
|
if (!t || t.length === 0) return { ok: !0 };
|
|
713
546
|
let n = e.authorization ?? e.Authorization;
|
|
714
|
-
return n ? n.startsWith("Bearer ") ?
|
|
547
|
+
return n ? n.startsWith("Bearer ") ? pe(n.slice(7).trim(), t) ? { ok: !0 } : {
|
|
715
548
|
ok: !1,
|
|
716
549
|
reason: "token mismatch"
|
|
717
550
|
} : {
|
|
@@ -721,7 +554,7 @@ __installPublicEnv(publicEnvValues)
|
|
|
721
554
|
ok: !1,
|
|
722
555
|
reason: "missing Authorization header"
|
|
723
556
|
};
|
|
724
|
-
},
|
|
557
|
+
}, pt = (e) => {
|
|
725
558
|
if (!Array.isArray(e) || e.length === 0) return;
|
|
726
559
|
let t = [];
|
|
727
560
|
for (let n of e) {
|
|
@@ -743,25 +576,25 @@ __installPublicEnv(publicEnvValues)
|
|
|
743
576
|
});
|
|
744
577
|
}
|
|
745
578
|
return t.length > 0 ? t : void 0;
|
|
746
|
-
},
|
|
579
|
+
}, W = (e, t, n = {}) => ({
|
|
747
580
|
status: e,
|
|
748
581
|
contentType: "application/json; charset=utf-8",
|
|
749
582
|
body: JSON.stringify(t),
|
|
750
583
|
headers: n
|
|
751
|
-
}),
|
|
584
|
+
}), G = (e) => !e || e.length === 0 ? {} : {
|
|
752
585
|
"access-control-allow-origin": e,
|
|
753
586
|
"access-control-allow-credentials": "true",
|
|
754
587
|
"access-control-allow-methods": "GET, POST, OPTIONS",
|
|
755
588
|
"access-control-allow-headers": "authorization, content-type, accept",
|
|
756
589
|
"access-control-expose-headers": "content-type, content-length",
|
|
757
590
|
vary: "Origin"
|
|
758
|
-
},
|
|
591
|
+
}, K = (e) => {
|
|
759
592
|
let t = e.indexOf("?");
|
|
760
593
|
return t === -1 ? e : e.slice(0, t);
|
|
761
|
-
},
|
|
594
|
+
}, mt = (e) => {
|
|
762
595
|
let t = e.indexOf("?");
|
|
763
596
|
return t === -1 ? new URLSearchParams() : new URLSearchParams(e.slice(t + 1));
|
|
764
|
-
},
|
|
597
|
+
}, ht = (e) => e === "/_voltro/inspect" || e.startsWith("/_voltro/inspect/"), gt = [
|
|
765
598
|
"text",
|
|
766
599
|
"textarea",
|
|
767
600
|
"number",
|
|
@@ -777,7 +610,7 @@ __installPublicEnv(publicEnvValues)
|
|
|
777
610
|
"file",
|
|
778
611
|
"hidden",
|
|
779
612
|
"custom"
|
|
780
|
-
],
|
|
613
|
+
], _t = (e, t, n = []) => ({
|
|
781
614
|
version: 2,
|
|
782
615
|
procedures: [...e].sort((e, t) => e.tag.localeCompare(t.tag)).map((e) => ({
|
|
783
616
|
tag: e.tag,
|
|
@@ -791,7 +624,7 @@ __installPublicEnv(publicEnvValues)
|
|
|
791
624
|
...e.exposeAsTool === void 0 ? {} : { exposeAsTool: e.exposeAsTool }
|
|
792
625
|
})),
|
|
793
626
|
workflows: [...t].sort((e, t) => e.tag.localeCompare(t.tag)).map((e) => ({ name: e.tag })),
|
|
794
|
-
widgets:
|
|
627
|
+
widgets: gt,
|
|
795
628
|
tables: [...n].filter((e) => !e.isFrameworkTable).sort((e, t) => e.name.localeCompare(t.name)).map((e) => ({
|
|
796
629
|
name: e.name,
|
|
797
630
|
reactive: e.isReactive,
|
|
@@ -804,58 +637,58 @@ __installPublicEnv(publicEnvValues)
|
|
|
804
637
|
...e.oneOf === void 0 ? {} : { enum: e.oneOf }
|
|
805
638
|
}))
|
|
806
639
|
}))
|
|
807
|
-
}),
|
|
808
|
-
let i =
|
|
809
|
-
if (!
|
|
810
|
-
let a =
|
|
640
|
+
}), vt = (e, t, n = {}, r = {}) => {
|
|
641
|
+
let i = K(e);
|
|
642
|
+
if (!ht(i)) return null;
|
|
643
|
+
let a = G(n.origin ?? n.Origin);
|
|
811
644
|
if ((r.method ?? "GET").toUpperCase() === "OPTIONS") return {
|
|
812
645
|
status: 204,
|
|
813
646
|
contentType: "text/plain",
|
|
814
647
|
body: "",
|
|
815
648
|
headers: a
|
|
816
649
|
};
|
|
817
|
-
if (
|
|
818
|
-
let o = (r.authResolver ??
|
|
819
|
-
if (!o.ok) return
|
|
650
|
+
if (H()) return W(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, a);
|
|
651
|
+
let o = (r.authResolver ?? U)(n);
|
|
652
|
+
if (!o.ok) return W(401, {
|
|
820
653
|
error: "unauthorized",
|
|
821
654
|
reason: o.reason
|
|
822
655
|
}, a);
|
|
823
|
-
if (i === "/_voltro/inspect" || i === "/_voltro/inspect/" || i === "/_voltro/inspect/app") return
|
|
656
|
+
if (i === "/_voltro/inspect" || i === "/_voltro/inspect/" || i === "/_voltro/inspect/app") return W(200, {
|
|
824
657
|
kind: t.kind,
|
|
825
658
|
...t.meta
|
|
826
659
|
}, a);
|
|
827
|
-
if (i === "/_voltro/inspect/routes") return t.kind === "web" ?
|
|
660
|
+
if (i === "/_voltro/inspect/routes") return t.kind === "web" ? W(200, {
|
|
828
661
|
pages: t.routes,
|
|
829
662
|
dirs: t.dirs
|
|
830
|
-
}, a) :
|
|
831
|
-
if (i === "/_voltro/inspect/cache") return t.kind === "web" ?
|
|
832
|
-
if (i === "/_voltro/inspect/rpc") return t.kind === "api" ?
|
|
663
|
+
}, a) : W(404, { error: "routes endpoint is web-only" }, a);
|
|
664
|
+
if (i === "/_voltro/inspect/cache") return t.kind === "web" ? W(200, t.cache(), a) : W(404, { error: "cache endpoint is web-only" }, a);
|
|
665
|
+
if (i === "/_voltro/inspect/rpc") return t.kind === "api" ? W(200, {
|
|
833
666
|
procedures: t.rpc,
|
|
834
667
|
workflows: t.workflows
|
|
835
|
-
}, a) :
|
|
668
|
+
}, a) : W(404, { error: "rpc endpoint is api-only" }, a);
|
|
836
669
|
if (i === "/_voltro/inspect/manifest") {
|
|
837
|
-
if (t.kind !== "api") return
|
|
670
|
+
if (t.kind !== "api") return W(404, { error: "manifest endpoint is api-only" }, a);
|
|
838
671
|
let e = t.inspectTables?.().tables ?? [];
|
|
839
|
-
return
|
|
672
|
+
return W(200, _t(t.rpc, t.workflows, e), a);
|
|
840
673
|
}
|
|
841
|
-
return i === "/_voltro/inspect/metrics" ? t.metrics === void 0 ?
|
|
674
|
+
return i === "/_voltro/inspect/metrics" ? t.metrics === void 0 ? W(200, [], a) : W(200, t.metrics(), a) : i === "/_voltro/inspect/subscriptions" ? t.kind === "api" ? t.subscriptions === void 0 ? W(200, {
|
|
842
675
|
subscriptions: [],
|
|
843
676
|
matcherStats: [],
|
|
844
677
|
capturedAt: Date.now()
|
|
845
|
-
}, a) :
|
|
678
|
+
}, a) : W(200, t.subscriptions(), a) : W(404, { error: "subscriptions endpoint is api-only" }, a) : i === "/_voltro/inspect/data-cache" ? t.kind === "api" ? t.dataCache === void 0 ? W(200, {
|
|
846
679
|
backend: "memory",
|
|
847
680
|
engine: "memory",
|
|
848
681
|
driver: "resp",
|
|
849
682
|
hits: 0,
|
|
850
683
|
misses: 0,
|
|
851
684
|
hitRate: 0
|
|
852
|
-
}, a) :
|
|
685
|
+
}, a) : W(200, t.dataCache(), a) : W(404, { error: "data-cache endpoint is api-only" }, a) : i === "/_voltro/inspect/database" ? t.kind === "api" ? t.database === void 0 ? W(200, {
|
|
853
686
|
migrations: [],
|
|
854
687
|
seeds: []
|
|
855
|
-
}, a) :
|
|
688
|
+
}, a) : W(200, t.database(), a) : W(404, { error: "database endpoint is api-only" }, a) : i === "/_voltro/inspect/plugins" ? t.kind === "api" ? t.plugins === void 0 ? W(200, {
|
|
856
689
|
plugins: [],
|
|
857
690
|
capturedAt: Date.now()
|
|
858
|
-
}, a) :
|
|
691
|
+
}, a) : W(200, t.plugins(), a) : W(404, { error: "plugins endpoint is api-only" }, a) : i === "/_voltro/inspect/env" ? t.env === void 0 ? W(200, {
|
|
859
692
|
app: t.meta.name ?? "app",
|
|
860
693
|
entries: [],
|
|
861
694
|
summary: {
|
|
@@ -863,34 +696,34 @@ __installPublicEnv(publicEnvValues)
|
|
|
863
696
|
set: 0,
|
|
864
697
|
missingRequired: 0
|
|
865
698
|
}
|
|
866
|
-
}, a) :
|
|
699
|
+
}, a) : W(200, t.env(), a) : i === "/_voltro/inspect/data/tables" ? t.kind === "api" ? t.inspectTables === void 0 ? W(200, { tables: [] }, a) : W(200, t.inspectTables(), a) : W(404, { error: "data viewer is api-only" }, a) : i === "/_voltro/inspect/invoke" ? W(404, { error: "invoke not enabled here — use POST handler" }, a) : W(404, {
|
|
867
700
|
error: "unknown inspect endpoint",
|
|
868
701
|
path: i
|
|
869
702
|
}, a);
|
|
870
|
-
},
|
|
871
|
-
let i =
|
|
872
|
-
if (
|
|
873
|
-
if ((r.method ?? "POST").toUpperCase() !== "POST") return
|
|
703
|
+
}, yt = async (e, t, n, r = {}) => {
|
|
704
|
+
let i = G(t.origin ?? t.Origin);
|
|
705
|
+
if (H()) return W(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, i);
|
|
706
|
+
if ((r.method ?? "POST").toUpperCase() !== "POST") return W(405, {
|
|
874
707
|
error: "method not allowed",
|
|
875
708
|
expected: "POST"
|
|
876
709
|
}, i);
|
|
877
|
-
let a = (r.authResolver ??
|
|
878
|
-
if (!a.ok) return
|
|
710
|
+
let a = (r.authResolver ?? U)(t);
|
|
711
|
+
if (!a.ok) return W(401, {
|
|
879
712
|
error: "unauthorized",
|
|
880
713
|
reason: a.reason
|
|
881
714
|
}, i);
|
|
882
|
-
if (e.kind !== "api") return
|
|
883
|
-
if (!e.invokers || e.invokers.size === 0) return
|
|
715
|
+
if (e.kind !== "api") return W(404, { error: "invoke endpoint is api-only" }, i);
|
|
716
|
+
if (!e.invokers || e.invokers.size === 0) return W(404, { error: "invoke not configured" }, i);
|
|
884
717
|
let o;
|
|
885
718
|
try {
|
|
886
719
|
o = JSON.parse(n || "{}");
|
|
887
720
|
} catch {
|
|
888
|
-
return
|
|
721
|
+
return W(400, { error: "body must be JSON" }, i);
|
|
889
722
|
}
|
|
890
723
|
let s = o;
|
|
891
|
-
if (typeof s.tag != "string") return
|
|
724
|
+
if (typeof s.tag != "string") return W(400, { error: "body.tag must be a string" }, i);
|
|
892
725
|
let c = e.invokers.get(s.tag);
|
|
893
|
-
if (!c) return
|
|
726
|
+
if (!c) return W(404, {
|
|
894
727
|
error: "unknown tag",
|
|
895
728
|
tag: s.tag
|
|
896
729
|
}, i);
|
|
@@ -900,167 +733,167 @@ __installPublicEnv(publicEnvValues)
|
|
|
900
733
|
let n = e.toLowerCase();
|
|
901
734
|
n !== "cookie" && (u[n] = t);
|
|
902
735
|
}
|
|
903
|
-
return
|
|
904
|
-
},
|
|
905
|
-
let a =
|
|
906
|
-
if (!
|
|
907
|
-
let o =
|
|
736
|
+
return W(200, await c(s.input, u), i);
|
|
737
|
+
}, bt = async (e, t, n, r, i = {}) => {
|
|
738
|
+
let a = K(e);
|
|
739
|
+
if (!ht(a) || !a.startsWith("/_voltro/inspect/webhooks/")) return null;
|
|
740
|
+
let o = G(n.origin ?? n.Origin);
|
|
908
741
|
if ((i.method ?? "POST").toUpperCase() !== "POST") return null;
|
|
909
|
-
if (
|
|
910
|
-
let s = (i.authResolver ??
|
|
911
|
-
if (!s.ok) return
|
|
742
|
+
if (H()) return W(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, o);
|
|
743
|
+
let s = (i.authResolver ?? U)(n);
|
|
744
|
+
if (!s.ok) return W(401, {
|
|
912
745
|
error: "unauthorized",
|
|
913
746
|
reason: s.reason
|
|
914
747
|
}, o);
|
|
915
|
-
if (t.kind !== "api") return
|
|
916
|
-
if (!t.webhookActions) return
|
|
748
|
+
if (t.kind !== "api") return W(404, { error: "webhook actions are api-only" }, o);
|
|
749
|
+
if (!t.webhookActions) return W(404, { error: "webhook actions not configured — is @voltro/plugin-webhooks active?" }, o);
|
|
917
750
|
let c;
|
|
918
751
|
try {
|
|
919
752
|
c = JSON.parse(r || "{}");
|
|
920
753
|
} catch {
|
|
921
|
-
return
|
|
754
|
+
return W(400, { error: "body must be JSON" }, o);
|
|
922
755
|
}
|
|
923
|
-
let l = a.slice(`${
|
|
756
|
+
let l = a.slice(`${V}/webhooks/`.length);
|
|
924
757
|
try {
|
|
925
758
|
switch (l) {
|
|
926
759
|
case "subscribe": {
|
|
927
760
|
let e = c;
|
|
928
|
-
return typeof e.event != "string" || e.event.length === 0 ?
|
|
761
|
+
return typeof e.event != "string" || e.event.length === 0 ? W(400, { error: "event required" }, o) : typeof e.url != "string" || e.url.length === 0 ? W(400, { error: "url required" }, o) : W(200, await t.webhookActions.subscribe(e), o);
|
|
929
762
|
}
|
|
930
763
|
case "pause": {
|
|
931
764
|
let e = c.targetId;
|
|
932
|
-
return typeof e != "string" || e.length === 0 ?
|
|
765
|
+
return typeof e != "string" || e.length === 0 ? W(400, { error: "targetId required" }, o) : (await t.webhookActions.pause(e), W(200, { ok: !0 }, o));
|
|
933
766
|
}
|
|
934
767
|
case "resume": {
|
|
935
768
|
let e = c.targetId;
|
|
936
|
-
return typeof e != "string" || e.length === 0 ?
|
|
769
|
+
return typeof e != "string" || e.length === 0 ? W(400, { error: "targetId required" }, o) : (await t.webhookActions.resume(e), W(200, { ok: !0 }, o));
|
|
937
770
|
}
|
|
938
771
|
case "delete": {
|
|
939
772
|
let e = c.targetId;
|
|
940
|
-
return typeof e != "string" || e.length === 0 ?
|
|
773
|
+
return typeof e != "string" || e.length === 0 ? W(400, { error: "targetId required" }, o) : (await t.webhookActions.delete(e), W(200, { ok: !0 }, o));
|
|
941
774
|
}
|
|
942
775
|
case "rotateSecret": {
|
|
943
776
|
let e = c.targetId;
|
|
944
|
-
return typeof e != "string" || e.length === 0 ?
|
|
777
|
+
return typeof e != "string" || e.length === 0 ? W(400, { error: "targetId required" }, o) : W(200, await t.webhookActions.rotateSecret(e), o);
|
|
945
778
|
}
|
|
946
779
|
case "replay": {
|
|
947
780
|
let e = c.deliveryId;
|
|
948
|
-
return typeof e != "string" || e.length === 0 ?
|
|
781
|
+
return typeof e != "string" || e.length === 0 ? W(400, { error: "deliveryId required" }, o) : (await t.webhookActions.replay(e), W(200, { ok: !0 }, o));
|
|
949
782
|
}
|
|
950
783
|
case "repinVersion": {
|
|
951
784
|
let e = c.targetId, n = c.version;
|
|
952
|
-
return typeof e != "string" || e.length === 0 ?
|
|
785
|
+
return typeof e != "string" || e.length === 0 ? W(400, { error: "targetId required" }, o) : typeof n != "number" || !Number.isInteger(n) || n < 1 ? W(400, { error: "version must be a positive integer" }, o) : (await t.webhookActions.updateTargetPayloadVersion(e, n), W(200, { ok: !0 }, o));
|
|
953
786
|
}
|
|
954
|
-
default: return
|
|
787
|
+
default: return W(404, { error: `unknown webhook action: ${l}` }, o);
|
|
955
788
|
}
|
|
956
789
|
} catch (e) {
|
|
957
|
-
return
|
|
790
|
+
return W(500, {
|
|
958
791
|
error: "webhook action failed",
|
|
959
792
|
message: e?.message ?? String(e)
|
|
960
793
|
}, o);
|
|
961
794
|
}
|
|
962
|
-
},
|
|
963
|
-
let a =
|
|
964
|
-
if (!
|
|
965
|
-
let o =
|
|
795
|
+
}, xt = async (e, t, n, r, i = {}) => {
|
|
796
|
+
let a = K(e);
|
|
797
|
+
if (!ht(a)) return null;
|
|
798
|
+
let o = G(n.origin ?? n.Origin);
|
|
966
799
|
if ((i.method ?? "POST").toUpperCase() !== "POST") return null;
|
|
967
|
-
if (
|
|
968
|
-
let s = (i.authResolver ??
|
|
969
|
-
if (!s.ok) return
|
|
800
|
+
if (H()) return W(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, o);
|
|
801
|
+
let s = (i.authResolver ?? U)(n);
|
|
802
|
+
if (!s.ok) return W(401, {
|
|
970
803
|
error: "unauthorized",
|
|
971
804
|
reason: s.reason
|
|
972
805
|
}, o);
|
|
973
|
-
if (t.kind !== "api") return
|
|
974
|
-
let c = `${
|
|
806
|
+
if (t.kind !== "api") return W(404, { error: "framework-action endpoints are api-only" }, o);
|
|
807
|
+
let c = `${V}/seeds/run`, l = `${V}/migrations/rollback`, u = `${V}/migrations/squash`, d = `${V}/migrations/restore-snapshot`;
|
|
975
808
|
if (a !== c && a !== l && a !== u && a !== d && a !== "/_voltro/inspect/migrations/compare-env") return null;
|
|
976
809
|
let f;
|
|
977
810
|
try {
|
|
978
811
|
f = JSON.parse(r || "{}");
|
|
979
812
|
} catch {
|
|
980
|
-
return
|
|
813
|
+
return W(400, { error: "body must be JSON" }, o);
|
|
981
814
|
}
|
|
982
815
|
try {
|
|
983
|
-
if (a === c) return typeof f.id != "string" || f.id.length === 0 ?
|
|
984
|
-
if (a === l) return typeof f.id != "string" || f.id.length === 0 ?
|
|
816
|
+
if (a === c) return typeof f.id != "string" || f.id.length === 0 ? W(400, { error: "body.id must be a non-empty string" }, o) : t.runSeed ? W(200, await t.runSeed(f.id), o) : W(404, { error: "runSeed not configured" }, o);
|
|
817
|
+
if (a === l) return typeof f.id != "string" || f.id.length === 0 ? W(400, { error: "body.id must be a non-empty string" }, o) : t.rollbackMigration ? W(200, await t.rollbackMigration(f.id), o) : W(404, { error: "rollbackMigration not configured" }, o);
|
|
985
818
|
if (a === u) {
|
|
986
|
-
if (typeof f.before != "string" || f.before.length === 0) return
|
|
987
|
-
if (!t.squashMigrationHistory) return
|
|
819
|
+
if (typeof f.before != "string" || f.before.length === 0) return W(400, { error: "body.before must be a non-empty ISO date string" }, o);
|
|
820
|
+
if (!t.squashMigrationHistory) return W(404, { error: "squashMigrationHistory not configured" }, o);
|
|
988
821
|
let e = typeof f.note == "string" ? f.note : void 0;
|
|
989
|
-
return
|
|
822
|
+
return W(200, await t.squashMigrationHistory({
|
|
990
823
|
before: f.before,
|
|
991
824
|
note: e
|
|
992
825
|
}), o);
|
|
993
826
|
}
|
|
994
|
-
return a === d ? typeof f.planId != "string" || f.planId.length === 0 ?
|
|
827
|
+
return a === d ? typeof f.planId != "string" || f.planId.length === 0 ? W(400, { error: "body.planId must be a non-empty string" }, o) : t.restoreSnapshot ? W(200, await t.restoreSnapshot({ planId: f.planId }), o) : W(404, { error: "restoreSnapshot not configured" }, o) : typeof f.url != "string" || f.url.length === 0 ? W(400, { error: "body.url must be a non-empty URL string" }, o) : t.compareCrossEnv ? (await t.compareCrossEnv({
|
|
995
828
|
url: f.url,
|
|
996
829
|
label: typeof f.label == "string" ? f.label : void 0,
|
|
997
830
|
token: typeof f.token == "string" ? f.token : void 0
|
|
998
|
-
}),
|
|
831
|
+
}), W(200, { ok: !0 }, o)) : W(404, { error: "compareCrossEnv not configured" }, o);
|
|
999
832
|
} catch (e) {
|
|
1000
|
-
return
|
|
833
|
+
return W(500, {
|
|
1001
834
|
error: "framework action failed",
|
|
1002
835
|
message: e?.message ?? String(e)
|
|
1003
836
|
}, o);
|
|
1004
837
|
}
|
|
1005
|
-
},
|
|
1006
|
-
if (
|
|
1007
|
-
let i =
|
|
1008
|
-
if ((r.method ?? "GET").toUpperCase() !== "GET") return
|
|
838
|
+
}, St = async (e, t, n, r = {}) => {
|
|
839
|
+
if (K(e) !== "/_voltro/inspect/data/rows") return null;
|
|
840
|
+
let i = G(n.origin ?? n.Origin);
|
|
841
|
+
if ((r.method ?? "GET").toUpperCase() !== "GET") return W(405, {
|
|
1009
842
|
error: "method not allowed",
|
|
1010
843
|
expected: "GET"
|
|
1011
844
|
}, i);
|
|
1012
|
-
if (
|
|
1013
|
-
let a = (r.authResolver ??
|
|
1014
|
-
if (!a.ok) return
|
|
845
|
+
if (H()) return W(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, i);
|
|
846
|
+
let a = (r.authResolver ?? U)(n);
|
|
847
|
+
if (!a.ok) return W(401, {
|
|
1015
848
|
error: "unauthorized",
|
|
1016
849
|
reason: a.reason
|
|
1017
850
|
}, i);
|
|
1018
|
-
if (t.kind !== "api") return
|
|
1019
|
-
if (t.inspectRows === void 0) return
|
|
1020
|
-
let o =
|
|
1021
|
-
if (!s) return
|
|
1022
|
-
let c =
|
|
851
|
+
if (t.kind !== "api") return W(404, { error: "data viewer is api-only" }, i);
|
|
852
|
+
if (t.inspectRows === void 0) return W(404, { error: "inspectRows not configured" }, i);
|
|
853
|
+
let o = q(e), s = o.get("table");
|
|
854
|
+
if (!s) return W(400, { error: "query.table is required" }, i);
|
|
855
|
+
let c = J(o.get("offset")) ?? 0, l = J(o.get("limit")) ?? 50, u = {}, d = o.get("q");
|
|
1023
856
|
if (d) {
|
|
1024
|
-
if (d.length > 8192) return
|
|
857
|
+
if (d.length > 8192) return W(400, { error: "query.q too large" }, i);
|
|
1025
858
|
try {
|
|
1026
859
|
u = JSON.parse(Buffer.from(d, "base64url").toString("utf8"));
|
|
1027
860
|
} catch {
|
|
1028
|
-
return
|
|
861
|
+
return W(400, { error: "query.q is not valid base64url JSON" }, i);
|
|
1029
862
|
}
|
|
1030
863
|
}
|
|
1031
864
|
try {
|
|
1032
|
-
return
|
|
865
|
+
return W(200, await t.inspectRows({
|
|
1033
866
|
table: s,
|
|
1034
867
|
offset: c,
|
|
1035
868
|
limit: l,
|
|
1036
869
|
...u
|
|
1037
870
|
}), i);
|
|
1038
871
|
} catch (e) {
|
|
1039
|
-
return e?.name === "InspectQueryError" ?
|
|
872
|
+
return e?.name === "InspectQueryError" ? W(400, {
|
|
1040
873
|
error: "invalid query",
|
|
1041
874
|
message: e.message
|
|
1042
|
-
}, i) :
|
|
875
|
+
}, i) : W(500, {
|
|
1043
876
|
error: "data-rows query failed",
|
|
1044
877
|
message: e?.message ?? String(e)
|
|
1045
878
|
}, i);
|
|
1046
879
|
}
|
|
1047
|
-
},
|
|
1048
|
-
if (
|
|
1049
|
-
let i =
|
|
1050
|
-
if ((r.method ?? "GET").toUpperCase() !== "GET") return
|
|
880
|
+
}, Ct = async (e, t, n, r = {}) => {
|
|
881
|
+
if (K(e) !== "/_voltro/inspect/provenance") return null;
|
|
882
|
+
let i = G(n.origin ?? n.Origin);
|
|
883
|
+
if ((r.method ?? "GET").toUpperCase() !== "GET") return W(405, {
|
|
1051
884
|
error: "method not allowed",
|
|
1052
885
|
expected: "GET"
|
|
1053
886
|
}, i);
|
|
1054
|
-
if (
|
|
1055
|
-
let a = (r.authResolver ??
|
|
1056
|
-
if (!a.ok) return
|
|
887
|
+
if (H()) return W(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, i);
|
|
888
|
+
let a = (r.authResolver ?? U)(n);
|
|
889
|
+
if (!a.ok) return W(401, {
|
|
1057
890
|
error: "unauthorized",
|
|
1058
891
|
reason: a.reason
|
|
1059
892
|
}, i);
|
|
1060
|
-
if (t.kind !== "api") return
|
|
1061
|
-
if (t.inspectRows === void 0) return
|
|
1062
|
-
let o =
|
|
1063
|
-
if (!s || !c) return
|
|
893
|
+
if (t.kind !== "api") return W(404, { error: "provenance is api-only" }, i);
|
|
894
|
+
if (t.inspectRows === void 0) return W(404, { error: "inspectRows not configured" }, i);
|
|
895
|
+
let o = q(e), s = o.get("table"), c = o.get("id"), l = o.get("column") ?? void 0;
|
|
896
|
+
if (!s || !c) return W(400, { error: "query.table and query.id are required" }, i);
|
|
1064
897
|
try {
|
|
1065
898
|
let e = (await t.inspectRows({
|
|
1066
899
|
table: s,
|
|
@@ -1072,175 +905,175 @@ __installPublicEnv(publicEnvValues)
|
|
|
1072
905
|
value: c
|
|
1073
906
|
}
|
|
1074
907
|
})).rows[0];
|
|
1075
|
-
return
|
|
908
|
+
return W(200, k(e, {
|
|
1076
909
|
table: s,
|
|
1077
910
|
id: c,
|
|
1078
911
|
...l === void 0 ? {} : { column: l }
|
|
1079
912
|
}), i);
|
|
1080
913
|
} catch (e) {
|
|
1081
|
-
return e?.name === "InspectQueryError" ?
|
|
914
|
+
return e?.name === "InspectQueryError" ? W(400, {
|
|
1082
915
|
error: "invalid query",
|
|
1083
916
|
message: e.message
|
|
1084
|
-
}, i) :
|
|
917
|
+
}, i) : W(500, {
|
|
1085
918
|
error: "provenance query failed",
|
|
1086
919
|
message: e?.message ?? String(e)
|
|
1087
920
|
}, i);
|
|
1088
921
|
}
|
|
1089
|
-
},
|
|
922
|
+
}, q = (e) => {
|
|
1090
923
|
let t = e.indexOf("?");
|
|
1091
924
|
return t < 0 ? new URLSearchParams() : new URLSearchParams(e.slice(t + 1));
|
|
1092
|
-
},
|
|
925
|
+
}, J = (e) => {
|
|
1093
926
|
if (e === null || e === "") return;
|
|
1094
927
|
let t = Number(e);
|
|
1095
928
|
return Number.isFinite(t) && t >= 0 ? Math.floor(t) : void 0;
|
|
1096
|
-
},
|
|
1097
|
-
if (
|
|
1098
|
-
let i =
|
|
1099
|
-
if ((r.method ?? "GET").toUpperCase() !== "GET") return
|
|
929
|
+
}, wt = async (e, t, n, r = {}) => {
|
|
930
|
+
if (K(e) !== "/_voltro/inspect/workflows/runs") return null;
|
|
931
|
+
let i = G(n.origin ?? n.Origin);
|
|
932
|
+
if ((r.method ?? "GET").toUpperCase() !== "GET") return W(405, {
|
|
1100
933
|
error: "method not allowed",
|
|
1101
934
|
expected: "GET"
|
|
1102
935
|
}, i);
|
|
1103
|
-
if (
|
|
1104
|
-
let a = (r.authResolver ??
|
|
1105
|
-
if (!a.ok) return
|
|
936
|
+
if (H()) return W(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, i);
|
|
937
|
+
let a = (r.authResolver ?? U)(n);
|
|
938
|
+
if (!a.ok) return W(401, {
|
|
1106
939
|
error: "unauthorized",
|
|
1107
940
|
reason: a.reason
|
|
1108
941
|
}, i);
|
|
1109
|
-
if (t.kind !== "api") return
|
|
1110
|
-
if (t.inspectWorkflowRuns === void 0) return
|
|
942
|
+
if (t.kind !== "api") return W(404, { error: "workflows endpoint is api-only" }, i);
|
|
943
|
+
if (t.inspectWorkflowRuns === void 0) return W(200, {
|
|
1111
944
|
runs: [],
|
|
1112
945
|
total: 0,
|
|
1113
946
|
offset: 0,
|
|
1114
947
|
limit: 50
|
|
1115
948
|
}, i);
|
|
1116
|
-
let o =
|
|
949
|
+
let o = q(e);
|
|
1117
950
|
try {
|
|
1118
|
-
return
|
|
951
|
+
return W(200, await t.inspectWorkflowRuns({
|
|
1119
952
|
...o.get("tag") === null ? {} : { tag: o.get("tag") },
|
|
1120
953
|
...o.get("status") === null ? {} : { status: o.get("status") },
|
|
1121
|
-
offset:
|
|
1122
|
-
limit:
|
|
954
|
+
offset: J(o.get("offset")) ?? 0,
|
|
955
|
+
limit: J(o.get("limit")) ?? 50
|
|
1123
956
|
}), i);
|
|
1124
957
|
} catch (e) {
|
|
1125
|
-
return
|
|
958
|
+
return W(500, {
|
|
1126
959
|
error: "workflow-runs query failed",
|
|
1127
960
|
message: e?.message ?? String(e)
|
|
1128
961
|
}, i);
|
|
1129
962
|
}
|
|
1130
|
-
},
|
|
1131
|
-
let a =
|
|
963
|
+
}, Tt = async (e, t, n, r, i = {}) => {
|
|
964
|
+
let a = K(e).match(/^\/_voltro\/inspect\/workflows\/start\/([^/]+)$/);
|
|
1132
965
|
if (!a) return null;
|
|
1133
|
-
let o = decodeURIComponent(a[1] ?? ""), s =
|
|
1134
|
-
if ((i.method ?? "POST").toUpperCase() !== "POST") return
|
|
966
|
+
let o = decodeURIComponent(a[1] ?? ""), s = G(n.origin ?? n.Origin);
|
|
967
|
+
if ((i.method ?? "POST").toUpperCase() !== "POST") return W(405, {
|
|
1135
968
|
error: "method not allowed",
|
|
1136
969
|
expected: "POST"
|
|
1137
970
|
}, s);
|
|
1138
|
-
if (
|
|
1139
|
-
let c = (i.authResolver ??
|
|
1140
|
-
if (!c.ok) return
|
|
971
|
+
if (H()) return W(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, s);
|
|
972
|
+
let c = (i.authResolver ?? U)(n);
|
|
973
|
+
if (!c.ok) return W(401, {
|
|
1141
974
|
error: "unauthorized",
|
|
1142
975
|
reason: c.reason
|
|
1143
976
|
}, s);
|
|
1144
|
-
if (t.kind !== "api") return
|
|
1145
|
-
if (t.inspectStartWorkflow === void 0) return
|
|
977
|
+
if (t.kind !== "api") return W(404, { error: "workflow start is api-only" }, s);
|
|
978
|
+
if (t.inspectStartWorkflow === void 0) return W(404, { error: "inspectStartWorkflow not configured" }, s);
|
|
1146
979
|
let l = {};
|
|
1147
980
|
if (r.length > 0) try {
|
|
1148
981
|
l = JSON.parse(r).payload ?? {};
|
|
1149
982
|
} catch {
|
|
1150
|
-
return
|
|
983
|
+
return W(400, { error: "start requires JSON body `{ payload?: unknown }`" }, s);
|
|
1151
984
|
}
|
|
1152
985
|
try {
|
|
1153
|
-
return
|
|
986
|
+
return W(200, await t.inspectStartWorkflow({
|
|
1154
987
|
name: o,
|
|
1155
988
|
payload: l
|
|
1156
989
|
}), s);
|
|
1157
990
|
} catch (e) {
|
|
1158
|
-
return
|
|
991
|
+
return W(500, {
|
|
1159
992
|
error: "workflow start failed",
|
|
1160
993
|
message: e?.message ?? String(e)
|
|
1161
994
|
}, s);
|
|
1162
995
|
}
|
|
1163
|
-
},
|
|
1164
|
-
let i =
|
|
996
|
+
}, Et = async (e, t, n, r = {}) => {
|
|
997
|
+
let i = K(e);
|
|
1165
998
|
if (!i.startsWith("/_voltro/inspect/schedules")) return null;
|
|
1166
|
-
let a =
|
|
1167
|
-
if (
|
|
1168
|
-
let o = (r.authResolver ??
|
|
1169
|
-
if (!o.ok) return
|
|
999
|
+
let a = G(n.origin ?? n.Origin);
|
|
1000
|
+
if (H()) return W(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, a);
|
|
1001
|
+
let o = (r.authResolver ?? U)(n);
|
|
1002
|
+
if (!o.ok) return W(401, {
|
|
1170
1003
|
error: "unauthorized",
|
|
1171
1004
|
reason: o.reason
|
|
1172
1005
|
}, a);
|
|
1173
|
-
if (t.kind !== "api") return
|
|
1006
|
+
if (t.kind !== "api") return W(404, { error: "schedules are api-only" }, a);
|
|
1174
1007
|
let s = (r.method ?? "GET").toUpperCase(), c = i.match(/^\/_voltro\/inspect\/schedules\/([^/]+)\/fire$/);
|
|
1175
1008
|
if (c) {
|
|
1176
|
-
if (s !== "POST") return
|
|
1009
|
+
if (s !== "POST") return W(405, {
|
|
1177
1010
|
error: "method not allowed",
|
|
1178
1011
|
expected: "POST"
|
|
1179
1012
|
}, a);
|
|
1180
|
-
if (!t.inspectFireSchedule) return
|
|
1181
|
-
let n = decodeURIComponent(c[1] ?? ""), r =
|
|
1013
|
+
if (!t.inspectFireSchedule) return W(404, { error: "inspectFireSchedule not configured" }, a);
|
|
1014
|
+
let n = decodeURIComponent(c[1] ?? ""), r = q(e).get("trigger") === "external" ? "external" : "manual";
|
|
1182
1015
|
try {
|
|
1183
|
-
return
|
|
1016
|
+
return W(200, await t.inspectFireSchedule({
|
|
1184
1017
|
name: n,
|
|
1185
1018
|
trigger: r
|
|
1186
1019
|
}), a);
|
|
1187
1020
|
} catch (e) {
|
|
1188
|
-
return
|
|
1021
|
+
return W(500, {
|
|
1189
1022
|
error: "fire failed",
|
|
1190
1023
|
message: e?.message ?? String(e)
|
|
1191
1024
|
}, a);
|
|
1192
1025
|
}
|
|
1193
1026
|
}
|
|
1194
1027
|
if (i === "/_voltro/inspect/schedules/runs") {
|
|
1195
|
-
if (s !== "GET") return
|
|
1028
|
+
if (s !== "GET") return W(405, {
|
|
1196
1029
|
error: "method not allowed",
|
|
1197
1030
|
expected: "GET"
|
|
1198
1031
|
}, a);
|
|
1199
|
-
if (!t.inspectScheduleRuns) return
|
|
1032
|
+
if (!t.inspectScheduleRuns) return W(200, {
|
|
1200
1033
|
runs: [],
|
|
1201
1034
|
total: 0,
|
|
1202
1035
|
offset: 0,
|
|
1203
1036
|
limit: 50
|
|
1204
1037
|
}, a);
|
|
1205
|
-
let n =
|
|
1038
|
+
let n = q(e);
|
|
1206
1039
|
try {
|
|
1207
|
-
return
|
|
1040
|
+
return W(200, await t.inspectScheduleRuns({
|
|
1208
1041
|
...n.get("name") === null ? {} : { name: n.get("name") },
|
|
1209
|
-
offset:
|
|
1210
|
-
limit:
|
|
1042
|
+
offset: J(n.get("offset")) ?? 0,
|
|
1043
|
+
limit: J(n.get("limit")) ?? 50
|
|
1211
1044
|
}), a);
|
|
1212
1045
|
} catch (e) {
|
|
1213
|
-
return
|
|
1046
|
+
return W(500, {
|
|
1214
1047
|
error: "schedule-runs query failed",
|
|
1215
1048
|
message: e?.message ?? String(e)
|
|
1216
1049
|
}, a);
|
|
1217
1050
|
}
|
|
1218
1051
|
}
|
|
1219
|
-
return i === "/_voltro/inspect/schedules" ? s === "GET" ? t.inspectSchedules ?
|
|
1052
|
+
return i === "/_voltro/inspect/schedules" ? s === "GET" ? t.inspectSchedules ? W(200, t.inspectSchedules(), a) : W(200, {
|
|
1220
1053
|
schedules: [],
|
|
1221
1054
|
coordination: "single"
|
|
1222
|
-
}, a) :
|
|
1055
|
+
}, a) : W(405, {
|
|
1223
1056
|
error: "method not allowed",
|
|
1224
1057
|
expected: "GET"
|
|
1225
|
-
}, a) :
|
|
1058
|
+
}, a) : W(404, {
|
|
1226
1059
|
error: "unknown schedules endpoint",
|
|
1227
1060
|
path: i
|
|
1228
1061
|
}, a);
|
|
1229
|
-
},
|
|
1230
|
-
if (
|
|
1231
|
-
let i =
|
|
1232
|
-
if (
|
|
1233
|
-
let a = (r.authResolver ??
|
|
1234
|
-
if (!a.ok) return
|
|
1062
|
+
}, Dt = async (e, t, n, r = {}) => {
|
|
1063
|
+
if (K(e) !== "/_voltro/inspect/cluster") return null;
|
|
1064
|
+
let i = G(n.origin ?? n.Origin);
|
|
1065
|
+
if (H()) return W(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, i);
|
|
1066
|
+
let a = (r.authResolver ?? U)(n);
|
|
1067
|
+
if (!a.ok) return W(401, {
|
|
1235
1068
|
error: "unauthorized",
|
|
1236
1069
|
reason: a.reason
|
|
1237
1070
|
}, i);
|
|
1238
|
-
if (t.kind !== "api") return
|
|
1239
|
-
if ((r.method ?? "GET").toUpperCase() !== "GET") return
|
|
1071
|
+
if (t.kind !== "api") return W(404, { error: "cluster is api-only" }, i);
|
|
1072
|
+
if ((r.method ?? "GET").toUpperCase() !== "GET") return W(405, {
|
|
1240
1073
|
error: "method not allowed",
|
|
1241
1074
|
expected: "GET"
|
|
1242
1075
|
}, i);
|
|
1243
|
-
if (!t.cluster) return
|
|
1076
|
+
if (!t.cluster) return W(200, {
|
|
1244
1077
|
instance: {
|
|
1245
1078
|
replicaId: process.env.POD_NAME ?? process.env.HOSTNAME ?? `dev-${process.pid}`,
|
|
1246
1079
|
dialect: "memory",
|
|
@@ -1265,163 +1098,163 @@ __installPublicEnv(publicEnvValues)
|
|
|
1265
1098
|
capturedAt: Date.now()
|
|
1266
1099
|
}, i);
|
|
1267
1100
|
try {
|
|
1268
|
-
return
|
|
1101
|
+
return W(200, await t.cluster(), i);
|
|
1269
1102
|
} catch (e) {
|
|
1270
|
-
return
|
|
1103
|
+
return W(500, {
|
|
1271
1104
|
error: "cluster snapshot failed",
|
|
1272
1105
|
message: e?.message ?? String(e)
|
|
1273
1106
|
}, i);
|
|
1274
1107
|
}
|
|
1275
|
-
},
|
|
1276
|
-
let i =
|
|
1108
|
+
}, Ot = async (e, t, n, r = {}) => {
|
|
1109
|
+
let i = K(e).match(/^\/_voltro\/inspect\/workflows\/runs\/([^/]+)\/steps$/);
|
|
1277
1110
|
if (!i) return null;
|
|
1278
|
-
let a = decodeURIComponent(i[1] ?? ""), o =
|
|
1279
|
-
if ((r.method ?? "GET").toUpperCase() !== "GET") return
|
|
1111
|
+
let a = decodeURIComponent(i[1] ?? ""), o = G(n.origin ?? n.Origin);
|
|
1112
|
+
if ((r.method ?? "GET").toUpperCase() !== "GET") return W(405, {
|
|
1280
1113
|
error: "method not allowed",
|
|
1281
1114
|
expected: "GET"
|
|
1282
1115
|
}, o);
|
|
1283
|
-
if (
|
|
1284
|
-
let s = (r.authResolver ??
|
|
1285
|
-
if (!s.ok) return
|
|
1116
|
+
if (H()) return W(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, o);
|
|
1117
|
+
let s = (r.authResolver ?? U)(n);
|
|
1118
|
+
if (!s.ok) return W(401, {
|
|
1286
1119
|
error: "unauthorized",
|
|
1287
1120
|
reason: s.reason
|
|
1288
1121
|
}, o);
|
|
1289
|
-
if (t.kind !== "api") return
|
|
1290
|
-
if (t.inspectWorkflowRunSteps === void 0) return
|
|
1122
|
+
if (t.kind !== "api") return W(404, { error: "workflow steps are api-only" }, o);
|
|
1123
|
+
if (t.inspectWorkflowRunSteps === void 0) return W(200, { steps: [] }, o);
|
|
1291
1124
|
try {
|
|
1292
|
-
return
|
|
1125
|
+
return W(200, await t.inspectWorkflowRunSteps({ runId: a }), o);
|
|
1293
1126
|
} catch (e) {
|
|
1294
|
-
return
|
|
1127
|
+
return W(500, {
|
|
1295
1128
|
error: "steps query failed",
|
|
1296
1129
|
message: e?.message ?? String(e)
|
|
1297
1130
|
}, o);
|
|
1298
1131
|
}
|
|
1299
|
-
},
|
|
1300
|
-
let i =
|
|
1132
|
+
}, kt = async (e, t, n, r = {}) => {
|
|
1133
|
+
let i = K(e).match(/^\/_voltro\/inspect\/workflows\/runs\/([^/]+)\/events$/);
|
|
1301
1134
|
if (!i) return null;
|
|
1302
|
-
let a = decodeURIComponent(i[1] ?? ""), o =
|
|
1303
|
-
if ((r.method ?? "GET").toUpperCase() !== "GET") return
|
|
1135
|
+
let a = decodeURIComponent(i[1] ?? ""), o = G(n.origin ?? n.Origin);
|
|
1136
|
+
if ((r.method ?? "GET").toUpperCase() !== "GET") return W(405, {
|
|
1304
1137
|
error: "method not allowed",
|
|
1305
1138
|
expected: "GET"
|
|
1306
1139
|
}, o);
|
|
1307
|
-
if (
|
|
1308
|
-
let s = (r.authResolver ??
|
|
1309
|
-
if (!s.ok) return
|
|
1140
|
+
if (H()) return W(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, o);
|
|
1141
|
+
let s = (r.authResolver ?? U)(n);
|
|
1142
|
+
if (!s.ok) return W(401, {
|
|
1310
1143
|
error: "unauthorized",
|
|
1311
1144
|
reason: s.reason
|
|
1312
1145
|
}, o);
|
|
1313
|
-
if (t.kind !== "api") return
|
|
1314
|
-
if (t.inspectWorkflowRunEvents === void 0) return
|
|
1146
|
+
if (t.kind !== "api") return W(404, { error: "workflow events are api-only" }, o);
|
|
1147
|
+
if (t.inspectWorkflowRunEvents === void 0) return W(200, { events: [] }, o);
|
|
1315
1148
|
try {
|
|
1316
|
-
return
|
|
1149
|
+
return W(200, await t.inspectWorkflowRunEvents({ runId: a }), o);
|
|
1317
1150
|
} catch (e) {
|
|
1318
|
-
return
|
|
1151
|
+
return W(500, {
|
|
1319
1152
|
error: "events query failed",
|
|
1320
1153
|
message: e?.message ?? String(e)
|
|
1321
1154
|
}, o);
|
|
1322
1155
|
}
|
|
1323
|
-
},
|
|
1324
|
-
if (
|
|
1325
|
-
let i =
|
|
1326
|
-
if ((r.method ?? "GET").toUpperCase() !== "GET") return
|
|
1156
|
+
}, At = async (e, t, n, r = {}) => {
|
|
1157
|
+
if (K(t) !== "/_voltro/inspect/workflows/events") return null;
|
|
1158
|
+
let i = G(n.origin ?? n.Origin);
|
|
1159
|
+
if ((r.method ?? "GET").toUpperCase() !== "GET") return W(405, {
|
|
1327
1160
|
error: "method not allowed",
|
|
1328
1161
|
expected: "GET"
|
|
1329
1162
|
}, i);
|
|
1330
|
-
if (
|
|
1331
|
-
let a = (r.authResolver ??
|
|
1332
|
-
if (!a.ok) return
|
|
1163
|
+
if (H()) return W(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, i);
|
|
1164
|
+
let a = (r.authResolver ?? U)(n);
|
|
1165
|
+
if (!a.ok) return W(401, {
|
|
1333
1166
|
error: "unauthorized",
|
|
1334
1167
|
reason: a.reason
|
|
1335
1168
|
}, i);
|
|
1336
|
-
if (e.kind !== "api") return
|
|
1337
|
-
if (e.inspectWorkflowDomainEvents === void 0) return
|
|
1169
|
+
if (e.kind !== "api") return W(404, { error: "workflow domain events are api-only" }, i);
|
|
1170
|
+
if (e.inspectWorkflowDomainEvents === void 0) return W(200, {
|
|
1338
1171
|
events: [],
|
|
1339
1172
|
total: 0,
|
|
1340
1173
|
offset: 0,
|
|
1341
1174
|
limit: 100
|
|
1342
1175
|
}, i);
|
|
1343
|
-
let o =
|
|
1176
|
+
let o = mt(t), s = o.get("name") ?? void 0, c = Number(o.get("offset") ?? "0"), l = Number(o.get("limit") ?? "100");
|
|
1344
1177
|
try {
|
|
1345
|
-
return
|
|
1178
|
+
return W(200, await e.inspectWorkflowDomainEvents({
|
|
1346
1179
|
...s !== void 0 && s !== "" ? { name: s } : {},
|
|
1347
1180
|
offset: Number.isFinite(c) ? c : 0,
|
|
1348
1181
|
limit: Number.isFinite(l) ? l : 100
|
|
1349
1182
|
}), i);
|
|
1350
1183
|
} catch (e) {
|
|
1351
|
-
return
|
|
1184
|
+
return W(500, {
|
|
1352
1185
|
error: "workflow domain events query failed",
|
|
1353
1186
|
message: e?.message ?? String(e)
|
|
1354
1187
|
}, i);
|
|
1355
1188
|
}
|
|
1356
|
-
},
|
|
1357
|
-
let i =
|
|
1189
|
+
}, jt = async (e, t, n, r = {}) => {
|
|
1190
|
+
let i = K(t).match(/^\/_voltro\/inspect\/workflows\/events\/([^/]+)\/deliveries$/);
|
|
1358
1191
|
if (!i) return null;
|
|
1359
|
-
let a = decodeURIComponent(i[1] ?? ""), o =
|
|
1360
|
-
if ((r.method ?? "GET").toUpperCase() !== "GET") return
|
|
1192
|
+
let a = decodeURIComponent(i[1] ?? ""), o = G(n.origin ?? n.Origin);
|
|
1193
|
+
if ((r.method ?? "GET").toUpperCase() !== "GET") return W(405, {
|
|
1361
1194
|
error: "method not allowed",
|
|
1362
1195
|
expected: "GET"
|
|
1363
1196
|
}, o);
|
|
1364
|
-
if (
|
|
1365
|
-
let s = (r.authResolver ??
|
|
1366
|
-
if (!s.ok) return
|
|
1197
|
+
if (H()) return W(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, o);
|
|
1198
|
+
let s = (r.authResolver ?? U)(n);
|
|
1199
|
+
if (!s.ok) return W(401, {
|
|
1367
1200
|
error: "unauthorized",
|
|
1368
1201
|
reason: s.reason
|
|
1369
1202
|
}, o);
|
|
1370
|
-
if (e.kind !== "api") return
|
|
1371
|
-
if (e.inspectWorkflowEventDeliveries === void 0) return
|
|
1203
|
+
if (e.kind !== "api") return W(404, { error: "workflow event deliveries are api-only" }, o);
|
|
1204
|
+
if (e.inspectWorkflowEventDeliveries === void 0) return W(200, { deliveries: [] }, o);
|
|
1372
1205
|
try {
|
|
1373
|
-
return
|
|
1206
|
+
return W(200, await e.inspectWorkflowEventDeliveries({ eventId: a }), o);
|
|
1374
1207
|
} catch (e) {
|
|
1375
|
-
return
|
|
1208
|
+
return W(500, {
|
|
1376
1209
|
error: "workflow event deliveries query failed",
|
|
1377
1210
|
message: e?.message ?? String(e)
|
|
1378
1211
|
}, o);
|
|
1379
1212
|
}
|
|
1380
|
-
},
|
|
1381
|
-
if (
|
|
1382
|
-
let i =
|
|
1383
|
-
if ((r.method ?? "GET").toUpperCase() !== "GET") return
|
|
1213
|
+
}, Mt = async (e, t, n, r = {}) => {
|
|
1214
|
+
if (K(e) !== "/_voltro/inspect/workflows/children") return null;
|
|
1215
|
+
let i = G(n.origin ?? n.Origin);
|
|
1216
|
+
if ((r.method ?? "GET").toUpperCase() !== "GET") return W(405, {
|
|
1384
1217
|
error: "method not allowed",
|
|
1385
1218
|
expected: "GET"
|
|
1386
1219
|
}, i);
|
|
1387
|
-
if (
|
|
1388
|
-
let a = (r.authResolver ??
|
|
1389
|
-
if (!a.ok) return
|
|
1220
|
+
if (H()) return W(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, i);
|
|
1221
|
+
let a = (r.authResolver ?? U)(n);
|
|
1222
|
+
if (!a.ok) return W(401, {
|
|
1390
1223
|
error: "unauthorized",
|
|
1391
1224
|
reason: a.reason
|
|
1392
1225
|
}, i);
|
|
1393
|
-
if (t.kind !== "api") return
|
|
1394
|
-
let o =
|
|
1395
|
-
if (o === null || o === "") return
|
|
1396
|
-
if (t.inspectWorkflowChildren === void 0) return
|
|
1226
|
+
if (t.kind !== "api") return W(404, { error: "workflow children are api-only" }, i);
|
|
1227
|
+
let o = q(e).get("parentExecutionId");
|
|
1228
|
+
if (o === null || o === "") return W(400, { error: "parentExecutionId query param required" }, i);
|
|
1229
|
+
if (t.inspectWorkflowChildren === void 0) return W(200, {
|
|
1397
1230
|
runs: [],
|
|
1398
1231
|
total: 0,
|
|
1399
1232
|
offset: 0,
|
|
1400
1233
|
limit: 200
|
|
1401
1234
|
}, i);
|
|
1402
1235
|
try {
|
|
1403
|
-
return
|
|
1236
|
+
return W(200, await t.inspectWorkflowChildren({ parentExecutionId: o }), i);
|
|
1404
1237
|
} catch (e) {
|
|
1405
|
-
return
|
|
1238
|
+
return W(500, {
|
|
1406
1239
|
error: "children query failed",
|
|
1407
1240
|
message: e?.message ?? String(e)
|
|
1408
1241
|
}, i);
|
|
1409
1242
|
}
|
|
1410
|
-
},
|
|
1411
|
-
let a =
|
|
1243
|
+
}, Nt = async (e, t, n, r, i = {}) => {
|
|
1244
|
+
let a = K(e).match(/^\/_voltro\/inspect\/workflows\/runs\/([^/]+)\/(cancel|retry|suspend|resume|signal|update)$/);
|
|
1412
1245
|
if (!a) return null;
|
|
1413
|
-
let o = decodeURIComponent(a[1] ?? ""), s = a[2], c =
|
|
1414
|
-
if ((i.method ?? "POST").toUpperCase() !== "POST") return
|
|
1246
|
+
let o = decodeURIComponent(a[1] ?? ""), s = a[2], c = G(n.origin ?? n.Origin);
|
|
1247
|
+
if ((i.method ?? "POST").toUpperCase() !== "POST") return W(405, {
|
|
1415
1248
|
error: "method not allowed",
|
|
1416
1249
|
expected: "POST"
|
|
1417
1250
|
}, c);
|
|
1418
|
-
if (
|
|
1419
|
-
let l = (i.authResolver ??
|
|
1420
|
-
if (!l.ok) return
|
|
1251
|
+
if (H()) return W(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, c);
|
|
1252
|
+
let l = (i.authResolver ?? U)(n);
|
|
1253
|
+
if (!l.ok) return W(401, {
|
|
1421
1254
|
error: "unauthorized",
|
|
1422
1255
|
reason: l.reason
|
|
1423
1256
|
}, c);
|
|
1424
|
-
if (t.kind !== "api") return
|
|
1257
|
+
if (t.kind !== "api") return W(404, { error: "workflow actions are api-only" }, c);
|
|
1425
1258
|
let u = {
|
|
1426
1259
|
cancel: t.inspectCancelWorkflowRun,
|
|
1427
1260
|
retry: t.inspectRetryWorkflowRun,
|
|
@@ -1430,16 +1263,16 @@ __installPublicEnv(publicEnvValues)
|
|
|
1430
1263
|
signal: t.inspectSignalWorkflowRun,
|
|
1431
1264
|
update: t.inspectUpdateWorkflowRun
|
|
1432
1265
|
}[s];
|
|
1433
|
-
if (!u) return
|
|
1266
|
+
if (!u) return W(404, { error: `inspect${s[0]?.toUpperCase() ?? ""}${s.slice(1)}WorkflowRun not configured` }, c);
|
|
1434
1267
|
let d, f, p, m, h, g;
|
|
1435
1268
|
if (r.length > 0) try {
|
|
1436
1269
|
let e = JSON.parse(r);
|
|
1437
1270
|
s === "retry" && (d = e.payloadOverride), s === "signal" && (typeof e.signalName == "string" && e.signalName.length > 0 && (f = e.signalName), p = e.payload), s === "update" && (typeof e.updateName == "string" && e.updateName.length > 0 && (m = e.updateName), h = e.payload, typeof e.timeoutMs == "number" && Number.isFinite(e.timeoutMs) && (g = e.timeoutMs));
|
|
1438
1271
|
} catch {}
|
|
1439
|
-
if (s === "signal" && f === void 0) return
|
|
1440
|
-
if (s === "update" && m === void 0) return
|
|
1272
|
+
if (s === "signal" && f === void 0) return W(400, { error: "signal requires JSON body `{ signalName: string, payload?: unknown }`" }, c);
|
|
1273
|
+
if (s === "update" && m === void 0) return W(400, { error: "update requires JSON body `{ updateName: string, payload?: unknown, timeoutMs?: number }`" }, c);
|
|
1441
1274
|
try {
|
|
1442
|
-
return
|
|
1275
|
+
return W(200, s === "retry" && d !== void 0 ? await u({
|
|
1443
1276
|
runId: o,
|
|
1444
1277
|
payloadOverride: d
|
|
1445
1278
|
}) : s === "signal" ? await u({
|
|
@@ -1453,123 +1286,317 @@ __installPublicEnv(publicEnvValues)
|
|
|
1453
1286
|
...g === void 0 ? {} : { timeoutMs: g }
|
|
1454
1287
|
}) : await u({ runId: o }), c);
|
|
1455
1288
|
} catch (e) {
|
|
1456
|
-
return
|
|
1289
|
+
return W(500, {
|
|
1457
1290
|
error: `${s} failed`,
|
|
1458
1291
|
message: e?.message ?? String(e)
|
|
1459
1292
|
}, c);
|
|
1460
1293
|
}
|
|
1461
|
-
},
|
|
1462
|
-
if (
|
|
1463
|
-
let a =
|
|
1464
|
-
if (
|
|
1465
|
-
let o = (i.authResolver ??
|
|
1466
|
-
if (!o.ok) return
|
|
1294
|
+
}, Pt = async (e, t, n, r, i = {}) => {
|
|
1295
|
+
if (K(e) !== "/_voltro/inspect/data/import" || (i.method ?? "POST").toUpperCase() !== "POST") return null;
|
|
1296
|
+
let a = G(n.origin ?? n.Origin);
|
|
1297
|
+
if (H()) return W(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, a);
|
|
1298
|
+
let o = (i.authResolver ?? U)(n);
|
|
1299
|
+
if (!o.ok) return W(401, {
|
|
1467
1300
|
error: "unauthorized",
|
|
1468
1301
|
reason: o.reason
|
|
1469
1302
|
}, a);
|
|
1470
|
-
if (t.kind !== "api") return
|
|
1471
|
-
if (!t.inspectImport) return
|
|
1303
|
+
if (t.kind !== "api") return W(404, { error: "data import is api-only" }, a);
|
|
1304
|
+
if (!t.inspectImport) return W(404, { error: "inspectImport not configured" }, a);
|
|
1472
1305
|
let s;
|
|
1473
1306
|
try {
|
|
1474
1307
|
s = JSON.parse(r || "{}");
|
|
1475
1308
|
} catch {
|
|
1476
|
-
return
|
|
1309
|
+
return W(400, { error: "body must be JSON" }, a);
|
|
1477
1310
|
}
|
|
1478
|
-
if (typeof s.bundleDir != "string" || !s.bundleDir) return
|
|
1311
|
+
if (typeof s.bundleDir != "string" || !s.bundleDir) return W(400, { error: "body.bundleDir (string) is required" }, a);
|
|
1479
1312
|
try {
|
|
1480
|
-
return
|
|
1313
|
+
return W(200, await t.inspectImport({
|
|
1481
1314
|
bundleDir: s.bundleDir,
|
|
1482
1315
|
...s.mode === "upsert" || s.mode === "append" || s.mode === "replace" ? { mode: s.mode } : {},
|
|
1483
1316
|
...s.onConflict === "skip" || s.onConflict === "fail" ? { onConflict: s.onConflict } : {},
|
|
1484
1317
|
...typeof s.atomic == "boolean" ? { atomic: s.atomic } : {}
|
|
1485
1318
|
}), a);
|
|
1486
1319
|
} catch (e) {
|
|
1487
|
-
return
|
|
1320
|
+
return W(500, {
|
|
1488
1321
|
error: "import failed",
|
|
1489
1322
|
message: e?.message ?? String(e)
|
|
1490
1323
|
}, a);
|
|
1491
1324
|
}
|
|
1492
|
-
},
|
|
1493
|
-
let a =
|
|
1325
|
+
}, Ft = async (e, t, n, r, i = {}) => {
|
|
1326
|
+
let a = K(e);
|
|
1494
1327
|
if (!a.startsWith("/_voltro/inspect/data/rows")) return null;
|
|
1495
1328
|
let o = (i.method ?? "POST").toUpperCase();
|
|
1496
1329
|
if (o === "GET" && a === "/_voltro/inspect/data/rows") return null;
|
|
1497
|
-
let s =
|
|
1498
|
-
if (
|
|
1499
|
-
let c = (i.authResolver ??
|
|
1500
|
-
if (!c.ok) return
|
|
1330
|
+
let s = G(n.origin ?? n.Origin);
|
|
1331
|
+
if (H()) return W(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, s);
|
|
1332
|
+
let c = (i.authResolver ?? U)(n);
|
|
1333
|
+
if (!c.ok) return W(401, {
|
|
1501
1334
|
error: "unauthorized",
|
|
1502
1335
|
reason: c.reason
|
|
1503
1336
|
}, s);
|
|
1504
|
-
if (t.kind !== "api") return
|
|
1337
|
+
if (t.kind !== "api") return W(404, { error: "data viewer is api-only" }, s);
|
|
1505
1338
|
if (o === "POST" && a === "/_voltro/inspect/data/rows") {
|
|
1506
|
-
if (!t.inspectInsertRow) return
|
|
1339
|
+
if (!t.inspectInsertRow) return W(404, { error: "inspectInsertRow not configured" }, s);
|
|
1340
|
+
let e;
|
|
1341
|
+
try {
|
|
1342
|
+
e = JSON.parse(r || "{}");
|
|
1343
|
+
} catch {
|
|
1344
|
+
return W(400, { error: "body must be JSON" }, s);
|
|
1345
|
+
}
|
|
1346
|
+
if (typeof e.table != "string" || !e.row || typeof e.row != "object") return W(400, { error: "body must be { table: string, row: object }" }, s);
|
|
1347
|
+
try {
|
|
1348
|
+
return W(200, await t.inspectInsertRow({
|
|
1349
|
+
table: e.table,
|
|
1350
|
+
row: e.row
|
|
1351
|
+
}), s);
|
|
1352
|
+
} catch (e) {
|
|
1353
|
+
return W(500, {
|
|
1354
|
+
error: "insert failed",
|
|
1355
|
+
message: e?.message ?? String(e)
|
|
1356
|
+
}, s);
|
|
1357
|
+
}
|
|
1358
|
+
}
|
|
1359
|
+
let l = a.match(/^\/_voltro\/inspect\/data\/rows\/([^/]+)$/);
|
|
1360
|
+
if (!l) return null;
|
|
1361
|
+
let u = decodeURIComponent(l[1] ?? "");
|
|
1362
|
+
if (!u) return W(400, { error: "row id is required in URL" }, s);
|
|
1363
|
+
let d = q(e).get("table") ?? "";
|
|
1364
|
+
if (!d) return W(400, { error: "query.table is required" }, s);
|
|
1365
|
+
if (o === "PATCH") {
|
|
1366
|
+
if (!t.inspectUpdateRow) return W(404, { error: "inspectUpdateRow not configured" }, s);
|
|
1507
1367
|
let e;
|
|
1508
1368
|
try {
|
|
1509
1369
|
e = JSON.parse(r || "{}");
|
|
1510
1370
|
} catch {
|
|
1511
|
-
return
|
|
1371
|
+
return W(400, { error: "body must be JSON" }, s);
|
|
1372
|
+
}
|
|
1373
|
+
if (!e.patch || typeof e.patch != "object") return W(400, { error: "body.patch must be an object" }, s);
|
|
1374
|
+
try {
|
|
1375
|
+
return W(200, await t.inspectUpdateRow({
|
|
1376
|
+
table: d,
|
|
1377
|
+
id: u,
|
|
1378
|
+
patch: e.patch
|
|
1379
|
+
}), s);
|
|
1380
|
+
} catch (e) {
|
|
1381
|
+
return W(500, {
|
|
1382
|
+
error: "update failed",
|
|
1383
|
+
message: e?.message ?? String(e)
|
|
1384
|
+
}, s);
|
|
1385
|
+
}
|
|
1386
|
+
}
|
|
1387
|
+
if (o === "DELETE") {
|
|
1388
|
+
if (!t.inspectDeleteRow) return W(404, { error: "inspectDeleteRow not configured" }, s);
|
|
1389
|
+
try {
|
|
1390
|
+
return W(200, await t.inspectDeleteRow({
|
|
1391
|
+
table: d,
|
|
1392
|
+
id: u
|
|
1393
|
+
}), s);
|
|
1394
|
+
} catch (e) {
|
|
1395
|
+
return W(500, {
|
|
1396
|
+
error: "delete failed",
|
|
1397
|
+
message: e?.message ?? String(e)
|
|
1398
|
+
}, s);
|
|
1399
|
+
}
|
|
1400
|
+
}
|
|
1401
|
+
return W(405, {
|
|
1402
|
+
error: "method not allowed",
|
|
1403
|
+
expected: "POST | PATCH | DELETE"
|
|
1404
|
+
}, s);
|
|
1405
|
+
}, It = g({ scope: "vite" }), Lt = /\x1b\[[0-9;]*m/g, Rt = /^\s*\[?vite\]?\s*(\([a-z-]+\)\s*)?/, zt = (e) => e.replace(Lt, "").replace(Rt, "").trim(), Bt = /proxy error/i, Vt = [
|
|
1406
|
+
"ECONNREFUSED",
|
|
1407
|
+
"ECONNRESET",
|
|
1408
|
+
"ECONNABORTED",
|
|
1409
|
+
"EPIPE",
|
|
1410
|
+
"ETIMEDOUT"
|
|
1411
|
+
], Ht = (e, t = 0) => {
|
|
1412
|
+
if (e == null || t > 5) return !1;
|
|
1413
|
+
let n = e;
|
|
1414
|
+
return typeof n.code == "string" && Vt.includes(n.code) || typeof n.message == "string" && Vt.some((e) => n.message.includes(e)) || Array.isArray(n.errors) && n.errors.some((e) => Ht(e, t + 1)) ? !0 : Ht(n.cause, t + 1);
|
|
1415
|
+
}, Ut = 4e3, Wt = () => {
|
|
1416
|
+
let e = /* @__PURE__ */ new Set(), t = 0, n = {
|
|
1417
|
+
hasWarned: !1,
|
|
1418
|
+
info: (e) => {
|
|
1419
|
+
let t = zt(e);
|
|
1420
|
+
t.length !== 0 && It.info(t);
|
|
1421
|
+
},
|
|
1422
|
+
warn: (e) => {
|
|
1423
|
+
n.hasWarned = !0;
|
|
1424
|
+
let t = zt(e);
|
|
1425
|
+
t.length !== 0 && It.warn(t);
|
|
1426
|
+
},
|
|
1427
|
+
warnOnce: (t) => {
|
|
1428
|
+
let r = zt(t);
|
|
1429
|
+
e.has(r) || (e.add(r), n.hasWarned = !0, r.length !== 0 && It.warn(r));
|
|
1430
|
+
},
|
|
1431
|
+
error: (e, n) => {
|
|
1432
|
+
let r = zt(e), i = n?.error;
|
|
1433
|
+
if (r.length !== 0) {
|
|
1434
|
+
if (Bt.test(r) && Ht(i)) {
|
|
1435
|
+
let e = Date.now();
|
|
1436
|
+
e - t > Ut && (t = e, It.info("waiting for api — proxy upstream not accepting connections yet (still starting?)"));
|
|
1437
|
+
return;
|
|
1438
|
+
}
|
|
1439
|
+
It.error(r, {}, i);
|
|
1440
|
+
}
|
|
1441
|
+
},
|
|
1442
|
+
clearScreen: () => {},
|
|
1443
|
+
hasErrorLogged: (e) => !1
|
|
1444
|
+
};
|
|
1445
|
+
return n;
|
|
1446
|
+
}, Gt = (e = process.env) => {
|
|
1447
|
+
let t = e.VOLTRO_DEV_SSR_COMPILE_CONCURRENCY;
|
|
1448
|
+
if (t === void 0 || t.trim() === "") return 4;
|
|
1449
|
+
let n = Number(t);
|
|
1450
|
+
return Number.isFinite(n) && n >= 1 ? Math.floor(n) : 4;
|
|
1451
|
+
}, Kt = (e) => {
|
|
1452
|
+
let t = Math.max(1, Math.floor(e)), n = 0, r = [], i = () => n < t ? (n++, Promise.resolve()) : new Promise((e) => r.push(e)), a = () => {
|
|
1453
|
+
let e = r.shift();
|
|
1454
|
+
e ? e() : n--;
|
|
1455
|
+
};
|
|
1456
|
+
return {
|
|
1457
|
+
withPermit: async (e) => {
|
|
1458
|
+
await i();
|
|
1459
|
+
try {
|
|
1460
|
+
return await e();
|
|
1461
|
+
} finally {
|
|
1462
|
+
a();
|
|
1463
|
+
}
|
|
1464
|
+
},
|
|
1465
|
+
get active() {
|
|
1466
|
+
return n;
|
|
1512
1467
|
}
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1468
|
+
};
|
|
1469
|
+
}, qt = (e) => {
|
|
1470
|
+
let t = Kt(e.limit), n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Set();
|
|
1471
|
+
return {
|
|
1472
|
+
load: (i, a) => {
|
|
1473
|
+
if (r.has(i)) return a();
|
|
1474
|
+
let o = n.get(i);
|
|
1475
|
+
if (o) return o;
|
|
1476
|
+
let s = t.withPermit(async () => {
|
|
1477
|
+
e.onColdStart?.(i);
|
|
1478
|
+
try {
|
|
1479
|
+
return await a();
|
|
1480
|
+
} finally {
|
|
1481
|
+
e.onColdEnd?.(i);
|
|
1482
|
+
}
|
|
1483
|
+
}).then((e) => (r.add(i), e)).finally(() => {
|
|
1484
|
+
n.delete(i);
|
|
1485
|
+
});
|
|
1486
|
+
return n.set(i, s), s;
|
|
1487
|
+
},
|
|
1488
|
+
get inFlightCount() {
|
|
1489
|
+
return n.size;
|
|
1490
|
+
},
|
|
1491
|
+
get warmCount() {
|
|
1492
|
+
return r.size;
|
|
1524
1493
|
}
|
|
1525
|
-
}
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
let
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1494
|
+
};
|
|
1495
|
+
}, Jt = (e) => {
|
|
1496
|
+
let t = [];
|
|
1497
|
+
for (let n of e.split("/").filter(Boolean)) n.startsWith("[[...") && n.endsWith("]]") ? t.push({
|
|
1498
|
+
name: n.slice(5, -2),
|
|
1499
|
+
catchAll: !0,
|
|
1500
|
+
optional: !0
|
|
1501
|
+
}) : n.startsWith("[...") && n.endsWith("]") ? t.push({
|
|
1502
|
+
name: n.slice(4, -1),
|
|
1503
|
+
catchAll: !0,
|
|
1504
|
+
optional: !1
|
|
1505
|
+
}) : n.startsWith("[") && n.endsWith("]") && t.push({
|
|
1506
|
+
name: n.slice(1, -1),
|
|
1507
|
+
catchAll: !1,
|
|
1508
|
+
optional: !1
|
|
1509
|
+
});
|
|
1510
|
+
return t;
|
|
1511
|
+
}, Yt = (e) => e.replace(/-([a-z0-9])/g, (e, t) => t.toUpperCase()), Xt = async (e) => {
|
|
1512
|
+
let n = a(e);
|
|
1513
|
+
for (let e = 0; e < 4; e++) {
|
|
1514
|
+
let e = r(n, "project.json");
|
|
1515
|
+
if (y(e)) try {
|
|
1516
|
+
let t = await S.readFile(e, "utf8");
|
|
1517
|
+
return {
|
|
1518
|
+
projectDir: n,
|
|
1519
|
+
manifest: JSON.parse(t)
|
|
1520
|
+
};
|
|
1537
1521
|
} catch {
|
|
1538
|
-
return
|
|
1539
|
-
}
|
|
1540
|
-
if (!e.patch || typeof e.patch != "object") return G(400, { error: "body.patch must be an object" }, s);
|
|
1541
|
-
try {
|
|
1542
|
-
return G(200, await t.inspectUpdateRow({
|
|
1543
|
-
table: d,
|
|
1544
|
-
id: u,
|
|
1545
|
-
patch: e.patch
|
|
1546
|
-
}), s);
|
|
1547
|
-
} catch (e) {
|
|
1548
|
-
return G(500, {
|
|
1549
|
-
error: "update failed",
|
|
1550
|
-
message: e?.message ?? String(e)
|
|
1551
|
-
}, s);
|
|
1522
|
+
return null;
|
|
1552
1523
|
}
|
|
1524
|
+
let i = t(n);
|
|
1525
|
+
if (i === n) break;
|
|
1526
|
+
n = i;
|
|
1553
1527
|
}
|
|
1554
|
-
|
|
1555
|
-
|
|
1528
|
+
return null;
|
|
1529
|
+
}, Zt = async (t) => {
|
|
1530
|
+
let n = await Xt(t);
|
|
1531
|
+
if (!n) return [];
|
|
1532
|
+
let { projectDir: i, manifest: a } = n, o = e(t), s = a.apps ?? {}, c = [];
|
|
1533
|
+
for (let [e, t] of Object.entries(s)) {
|
|
1534
|
+
if (e === o || t.kind !== "web" || typeof t.port != "number") continue;
|
|
1535
|
+
let n = r(r(i, t.path ?? e), "src", "pages");
|
|
1536
|
+
if (!y(n)) continue;
|
|
1537
|
+
let a;
|
|
1556
1538
|
try {
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
message: e?.message ?? String(e)
|
|
1565
|
-
}, s);
|
|
1539
|
+
let { pages: e } = await $(n);
|
|
1540
|
+
a = e.map((e) => ({
|
|
1541
|
+
pattern: e.pattern,
|
|
1542
|
+
params: Jt(e.pattern)
|
|
1543
|
+
}));
|
|
1544
|
+
} catch {
|
|
1545
|
+
continue;
|
|
1566
1546
|
}
|
|
1547
|
+
c.push({
|
|
1548
|
+
key: Yt(e),
|
|
1549
|
+
origin: `http://localhost:${t.port}`,
|
|
1550
|
+
...typeof t.origin == "string" && t.origin.length > 0 ? { prodOrigin: t.origin } : {},
|
|
1551
|
+
routes: a
|
|
1552
|
+
});
|
|
1567
1553
|
}
|
|
1568
|
-
return
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1554
|
+
return c;
|
|
1555
|
+
}, Qt = (e) => {
|
|
1556
|
+
if (e.params.length === 0) return `'${e.pattern}'`;
|
|
1557
|
+
let t = e.pattern;
|
|
1558
|
+
for (let n of e.params) {
|
|
1559
|
+
let e = n.optional ? `[[...${n.name}]]` : n.catchAll ? `[...${n.name}]` : `[${n.name}]`, r = n.optional ? "${" + n.name + " === undefined ? \"\" : encodeURI(" + n.name + ")}" : n.catchAll ? "${encodeURI(" + n.name + ")}" : "${encodeURIComponent(" + n.name + ")}";
|
|
1560
|
+
t = t.replace(e, r);
|
|
1561
|
+
}
|
|
1562
|
+
return "`" + t + "`";
|
|
1563
|
+
}, $t = (e) => e.params.length === 0 ? "EmptyParams" : `{ ${e.params.map((e) => {
|
|
1564
|
+
let t = "string";
|
|
1565
|
+
return e.optional ? `readonly ${e.name}?: ${t}` : `readonly ${e.name}: ${t}`;
|
|
1566
|
+
}).join("; ")} }`, en = (e, t, n) => {
|
|
1567
|
+
let r = $t(e), i = Qt(e), a = t ? "VoltroExternalUrl" : "VoltroRouteUrl", o = t && n ? `${n} + ` : "";
|
|
1568
|
+
return e.params.length === 0 ? `() => (${o}${i}) as ${a}` : `({ ${e.params.map((e) => e.name).join(", ")} }: ${r}) => (${o}${i}) as ${a}`;
|
|
1569
|
+
}, tn = (e) => `{\n${[...e].sort((e, t) => e.pattern.localeCompare(t.pattern)).map((e) => ` ${JSON.stringify(e.pattern)}: ${en(e, !1)},`).join("\n")}\n}`, nn = (e, t) => {
|
|
1570
|
+
if (e.routes.length === 0) return ` ${e.key}: {} as Record<string, never>,`;
|
|
1571
|
+
let n = [...e.routes].sort((e, t) => e.pattern.localeCompare(t.pattern)), r = t === "prod" && e.prodOrigin ? e.prodOrigin : e.origin, i = JSON.stringify(r), a = n.map((e) => ` ${JSON.stringify(e.pattern)}: ${en(e, !0, i)},`);
|
|
1572
|
+
return ` ${e.key}: {\n${a.join("\n")}\n },`;
|
|
1573
|
+
}, rn = async (e) => {
|
|
1574
|
+
let n = e.pages.map((e) => ({
|
|
1575
|
+
pattern: e.pattern,
|
|
1576
|
+
params: Jt(e.pattern)
|
|
1577
|
+
})), i = await Zt(e.appRoot), a = [
|
|
1578
|
+
"// THIS FILE IS GENERATED — DO NOT EDIT BY HAND.",
|
|
1579
|
+
"// Re-emitted by `voltro dev` whenever `src/pages/**` changes.",
|
|
1580
|
+
"// Type-safe route builders consumed by <Link to={...}>.",
|
|
1581
|
+
"",
|
|
1582
|
+
"import type { VoltroRouteUrl, VoltroExternalUrl } from '@voltro/web'",
|
|
1583
|
+
"",
|
|
1584
|
+
"type EmptyParams = Record<string, never>",
|
|
1585
|
+
""
|
|
1586
|
+
].join("\n"), o = e.mode ?? "dev", s = `${a}\n${`export const routes = ${tn(n)} as const\n`}\n${i.length === 0 ? "export const siblingApps = {} as Record<string, never>\n" : `export const siblingApps = {\n${i.map((e) => nn(e, o)).join("\n")}\n} as const\n`}`, c = r(e.appRoot, ".framework", "routes.generated.ts");
|
|
1587
|
+
await S.mkdir(t(c), { recursive: !0 });
|
|
1588
|
+
let l = null;
|
|
1589
|
+
try {
|
|
1590
|
+
l = await S.readFile(c, "utf8");
|
|
1591
|
+
} catch {}
|
|
1592
|
+
return l === s ? {
|
|
1593
|
+
path: c,
|
|
1594
|
+
wrote: !1
|
|
1595
|
+
} : (await S.writeFile(c, s, "utf8"), {
|
|
1596
|
+
path: c,
|
|
1597
|
+
wrote: !0
|
|
1598
|
+
});
|
|
1599
|
+
}, an = 256, on = (e = an) => {
|
|
1573
1600
|
let t = [], n = /* @__PURE__ */ new Set();
|
|
1574
1601
|
return {
|
|
1575
1602
|
emit(r, i) {
|
|
@@ -1592,27 +1619,27 @@ __installPublicEnv(publicEnvValues)
|
|
|
1592
1619
|
return t.slice();
|
|
1593
1620
|
}
|
|
1594
1621
|
};
|
|
1595
|
-
},
|
|
1622
|
+
}, sn = (e) => `event: ${e.channel}\ndata: ${JSON.stringify(e)}\n\n`, cn = () => `: keep-alive ${Date.now()}\n\n`, ln = {
|
|
1596
1623
|
trace: 0,
|
|
1597
1624
|
debug: 1,
|
|
1598
1625
|
info: 2,
|
|
1599
1626
|
warn: 3,
|
|
1600
1627
|
error: 4,
|
|
1601
1628
|
fatal: 5
|
|
1602
|
-
},
|
|
1629
|
+
}, un = 2e3, dn = 200, fn = class {
|
|
1603
1630
|
capacity;
|
|
1604
1631
|
buffer = [];
|
|
1605
|
-
constructor(e =
|
|
1632
|
+
constructor(e = un) {
|
|
1606
1633
|
this.capacity = e;
|
|
1607
1634
|
}
|
|
1608
1635
|
append(e) {
|
|
1609
1636
|
this.buffer.push(e), this.buffer.length > this.capacity && this.buffer.shift();
|
|
1610
1637
|
}
|
|
1611
1638
|
query(e = {}) {
|
|
1612
|
-
let t = e.since ?? 0, n = e.until ?? Date.now(), r = Math.min(e.max ??
|
|
1639
|
+
let t = e.since ?? 0, n = e.until ?? Date.now(), r = Math.min(e.max ?? dn, this.capacity), i = e.minLevel === void 0 ? ln.trace : ln[e.minLevel], a = e.scope?.toLowerCase(), o = e.source, s = e.filter?.toLowerCase(), c = e.traceId, l = [];
|
|
1613
1640
|
for (let e = this.buffer.length - 1; e >= 0 && l.length < r; e--) {
|
|
1614
1641
|
let r = this.buffer[e];
|
|
1615
|
-
r.ts < t || r.ts > n ||
|
|
1642
|
+
r.ts < t || r.ts > n || ln[r.level] < i || o !== void 0 && r.source !== o || a !== void 0 && (r.scope === void 0 || !r.scope.toLowerCase().includes(a)) || s !== void 0 && !r.message.toLowerCase().includes(s) || c !== void 0 && r.fields.traceId !== c || l.push(r);
|
|
1616
1643
|
}
|
|
1617
1644
|
return l.reverse();
|
|
1618
1645
|
}
|
|
@@ -1625,7 +1652,7 @@ __installPublicEnv(publicEnvValues)
|
|
|
1625
1652
|
clear() {
|
|
1626
1653
|
this.buffer = [];
|
|
1627
1654
|
}
|
|
1628
|
-
},
|
|
1655
|
+
}, pn = null, mn = () => (pn === null && (pn = new fn()), pn), hn = (e) => {
|
|
1629
1656
|
if (typeof e == "string") return e;
|
|
1630
1657
|
if (e instanceof Error) return e.message;
|
|
1631
1658
|
try {
|
|
@@ -1633,18 +1660,18 @@ __installPublicEnv(publicEnvValues)
|
|
|
1633
1660
|
} catch {
|
|
1634
1661
|
return String(e);
|
|
1635
1662
|
}
|
|
1636
|
-
},
|
|
1663
|
+
}, gn = (e) => {
|
|
1637
1664
|
let t = {
|
|
1638
1665
|
log: console.log.bind(console),
|
|
1639
1666
|
info: console.info.bind(console),
|
|
1640
1667
|
warn: console.warn.bind(console),
|
|
1641
1668
|
error: console.error.bind(console),
|
|
1642
1669
|
debug: console.debug.bind(console)
|
|
1643
|
-
}, n =
|
|
1670
|
+
}, n = mn(), r = !1, i = (i) => (...a) => {
|
|
1644
1671
|
if (t[i](...a), !r) {
|
|
1645
1672
|
r = !0;
|
|
1646
1673
|
try {
|
|
1647
|
-
let t = a.length > 0 ?
|
|
1674
|
+
let t = a.length > 0 ? hn(a[0]) : "", r = t.length > 500 ? t.slice(0, 500) + "…" : t, o = O();
|
|
1648
1675
|
e.emit("log", {
|
|
1649
1676
|
level: i,
|
|
1650
1677
|
message: r,
|
|
@@ -1702,24 +1729,24 @@ __installPublicEnv(publicEnvValues)
|
|
|
1702
1729
|
return () => {
|
|
1703
1730
|
console.log = t.log, console.info = t.info, console.warn = t.warn, console.error = t.error, console.debug = t.debug, a();
|
|
1704
1731
|
};
|
|
1705
|
-
},
|
|
1732
|
+
}, _n = 2e3, vn = 8, yn = 1e3, bn = 200, Y = (e, t) => e.length > t ? `${e.slice(0, t)}…` : e, xn = (e) => {
|
|
1706
1733
|
switch (e) {
|
|
1707
1734
|
case "error": return "error";
|
|
1708
1735
|
case "warn": return "warn";
|
|
1709
1736
|
case "debug": return "debug";
|
|
1710
1737
|
default: return "info";
|
|
1711
1738
|
}
|
|
1712
|
-
},
|
|
1739
|
+
}, Sn = g({ scope: "client" }), Cn = (e, t) => {
|
|
1713
1740
|
let n;
|
|
1714
1741
|
try {
|
|
1715
1742
|
n = JSON.parse(e);
|
|
1716
1743
|
} catch {
|
|
1717
|
-
return
|
|
1744
|
+
return wn(400, { error: "invalid JSON body" });
|
|
1718
1745
|
}
|
|
1719
|
-
if (typeof n != "object" || !n) return
|
|
1746
|
+
if (typeof n != "object" || !n) return wn(400, { error: "body must be a JSON object" });
|
|
1720
1747
|
let r = n;
|
|
1721
|
-
if (!Array.isArray(r.entries)) return
|
|
1722
|
-
let i = typeof r.app == "string" ?
|
|
1748
|
+
if (!Array.isArray(r.entries)) return wn(400, { error: "entries must be an array" });
|
|
1749
|
+
let i = typeof r.app == "string" ? Y(r.app, 120) : void 0, a = typeof r.page == "string" ? Y(r.page, 200) : void 0, o = typeof r.ua == "string" ? Y(r.ua, 200) : void 0, s = r.entries.slice(0, bn), c = 0;
|
|
1723
1750
|
for (let e of s) {
|
|
1724
1751
|
if (typeof e != "object" || !e) continue;
|
|
1725
1752
|
let n = e;
|
|
@@ -1730,7 +1757,7 @@ __installPublicEnv(publicEnvValues)
|
|
|
1730
1757
|
"warn",
|
|
1731
1758
|
"error",
|
|
1732
1759
|
"debug"
|
|
1733
|
-
].includes(n.level) ? n.level : "log", s = typeof n.ts == "number" && Number.isFinite(n.ts) ? n.ts : Date.now(), l =
|
|
1760
|
+
].includes(n.level) ? n.level : "log", s = typeof n.ts == "number" && Number.isFinite(n.ts) ? n.ts : Date.now(), l = Y(n.message, _n), u = Array.isArray(n.args) ? n.args.slice(0, vn).filter((e) => typeof e == "string").map((e) => Y(e, yn)) : void 0, d = typeof n.stack == "string" ? Y(n.stack, _n) : void 0;
|
|
1734
1761
|
t.emit("clientLog", {
|
|
1735
1762
|
ts: s,
|
|
1736
1763
|
level: r,
|
|
@@ -1745,160 +1772,119 @@ __installPublicEnv(publicEnvValues)
|
|
|
1745
1772
|
...i === void 0 ? {} : { app: i },
|
|
1746
1773
|
...a === void 0 ? {} : { page: a },
|
|
1747
1774
|
...u !== void 0 && u.length > 0 ? { args: u } : {}
|
|
1748
|
-
}, p =
|
|
1749
|
-
(p === "error" || p === "warn") && d !== void 0 ?
|
|
1775
|
+
}, p = xn(r);
|
|
1776
|
+
(p === "error" || p === "warn") && d !== void 0 ? Sn[p](l, f, { stack: d }) : Sn[p](l, {
|
|
1750
1777
|
...f,
|
|
1751
1778
|
...d === void 0 ? {} : { stack: d }
|
|
1752
1779
|
}), c++;
|
|
1753
1780
|
}
|
|
1754
|
-
return
|
|
1781
|
+
return wn(202, {
|
|
1755
1782
|
accepted: c,
|
|
1756
1783
|
dropped: r.entries.length - c
|
|
1757
1784
|
});
|
|
1758
|
-
},
|
|
1785
|
+
}, wn = (e, t) => ({
|
|
1759
1786
|
status: e,
|
|
1760
1787
|
contentType: "application/json; charset=utf-8",
|
|
1761
1788
|
body: JSON.stringify(t)
|
|
1762
|
-
}),
|
|
1789
|
+
}), Tn = "/_voltro/inspect/clientLog", En = [
|
|
1763
1790
|
"trace",
|
|
1764
1791
|
"debug",
|
|
1765
1792
|
"info",
|
|
1766
1793
|
"warn",
|
|
1767
1794
|
"error",
|
|
1768
1795
|
"fatal"
|
|
1769
|
-
],
|
|
1796
|
+
], Dn = {
|
|
1770
1797
|
trace: "TRACE",
|
|
1771
1798
|
debug: "DEBUG",
|
|
1772
1799
|
info: "INFO ",
|
|
1773
1800
|
warn: "WARN ",
|
|
1774
1801
|
error: "ERROR",
|
|
1775
1802
|
fatal: "FATAL"
|
|
1776
|
-
},
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
}
|
|
1782
|
-
let
|
|
1783
|
-
if (
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1803
|
+
}, On = (e) => En.includes(e), kn = (e, t, n = {}) => {
|
|
1804
|
+
if (H()) return {
|
|
1805
|
+
status: 503,
|
|
1806
|
+
contentType: "application/json",
|
|
1807
|
+
body: JSON.stringify({ error: "inspect disabled (VOLTRO_INSPECT=off)" })
|
|
1808
|
+
};
|
|
1809
|
+
let r = U(n);
|
|
1810
|
+
if (!r.ok) return {
|
|
1811
|
+
status: 401,
|
|
1812
|
+
contentType: "application/json",
|
|
1813
|
+
body: JSON.stringify({
|
|
1814
|
+
error: "unauthorized",
|
|
1815
|
+
reason: r.reason
|
|
1816
|
+
})
|
|
1817
|
+
};
|
|
1818
|
+
let i = e.indexOf("?"), a = i === -1 ? new URLSearchParams() : new URLSearchParams(e.slice(i + 1)), o = {}, s = a.get("since");
|
|
1788
1819
|
if (s !== null) {
|
|
1789
1820
|
let e = Number(s);
|
|
1790
|
-
Number.isFinite(e) &&
|
|
1821
|
+
Number.isFinite(e) && (o.since = e);
|
|
1791
1822
|
}
|
|
1792
|
-
let c =
|
|
1793
|
-
c !== null
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
let
|
|
1803
|
-
|
|
1823
|
+
let c = a.get("until");
|
|
1824
|
+
if (c !== null) {
|
|
1825
|
+
let e = Number(c);
|
|
1826
|
+
Number.isFinite(e) && (o.until = e);
|
|
1827
|
+
}
|
|
1828
|
+
let l = a.get("max");
|
|
1829
|
+
if (l !== null) {
|
|
1830
|
+
let e = Number(l);
|
|
1831
|
+
Number.isFinite(e) && e > 0 && (o.max = Math.floor(e));
|
|
1832
|
+
}
|
|
1833
|
+
let u = a.get("level");
|
|
1834
|
+
u !== null && On(u) && (o.minLevel = u);
|
|
1835
|
+
let d = a.get("source");
|
|
1836
|
+
(d === "server" || d === "client") && (o.source = d);
|
|
1837
|
+
let f = a.get("scope");
|
|
1838
|
+
f !== null && f.length > 0 && (o.scope = f);
|
|
1839
|
+
let p = a.get("filter");
|
|
1840
|
+
p !== null && p.length > 0 && (o.filter = p);
|
|
1841
|
+
let m = a.get("trace");
|
|
1842
|
+
m !== null && m.length > 0 && (o.traceId = m);
|
|
1843
|
+
let h = t.query(o);
|
|
1844
|
+
if ((a.get("format") ?? "json") === "text") return {
|
|
1804
1845
|
status: 200,
|
|
1805
1846
|
contentType: "text/plain; charset=utf-8",
|
|
1806
|
-
body:
|
|
1847
|
+
body: h.map(An).join("\n") + (h.length > 0 ? "\n" : "")
|
|
1807
1848
|
};
|
|
1808
|
-
let
|
|
1849
|
+
let g = {
|
|
1809
1850
|
capturedAt: Date.now(),
|
|
1810
1851
|
bufferCapacity: t.capacityHint(),
|
|
1811
1852
|
bufferSize: t.size(),
|
|
1812
|
-
returned:
|
|
1813
|
-
records:
|
|
1853
|
+
returned: h.length,
|
|
1854
|
+
records: h
|
|
1814
1855
|
};
|
|
1815
1856
|
return {
|
|
1816
1857
|
status: 200,
|
|
1817
1858
|
contentType: "application/json; charset=utf-8",
|
|
1818
|
-
body: JSON.stringify(
|
|
1859
|
+
body: JSON.stringify(g)
|
|
1819
1860
|
};
|
|
1820
|
-
},
|
|
1821
|
-
let t = new Date(e.ts), n = String(t.getHours()).padStart(2, "0"), r = String(t.getMinutes()).padStart(2, "0"), i = String(t.getSeconds()).padStart(2, "0"), a = String(t.getMilliseconds()).padStart(3, "0"), o = `[${e.scope ?? "?"}/${e.source}]`, s =
|
|
1822
|
-
return `${n}:${r}:${i}.${a} ${
|
|
1823
|
-
},
|
|
1861
|
+
}, An = (e) => {
|
|
1862
|
+
let t = new Date(e.ts), n = String(t.getHours()).padStart(2, "0"), r = String(t.getMinutes()).padStart(2, "0"), i = String(t.getSeconds()).padStart(2, "0"), a = String(t.getMilliseconds()).padStart(3, "0"), o = `[${e.scope ?? "?"}/${e.source}]`, s = Mn(e.fields);
|
|
1863
|
+
return `${n}:${r}:${i}.${a} ${Dn[e.level]} ${o} ${e.message}${s}`;
|
|
1864
|
+
}, jn = 80, Mn = (e) => {
|
|
1824
1865
|
let t = Object.entries(e);
|
|
1825
1866
|
if (t.length === 0) return "";
|
|
1826
1867
|
let n = [];
|
|
1827
1868
|
for (let [e, r] of t) {
|
|
1828
1869
|
if (r === void 0) continue;
|
|
1829
|
-
let t =
|
|
1870
|
+
let t = Nn(r);
|
|
1830
1871
|
n.push(`${e}=${t}`);
|
|
1831
1872
|
}
|
|
1832
1873
|
return n.length > 0 ? " " + n.join(" ") : "";
|
|
1833
|
-
},
|
|
1874
|
+
}, Nn = (e) => {
|
|
1834
1875
|
if (typeof e == "string") {
|
|
1835
|
-
let t = e.length >
|
|
1876
|
+
let t = e.length > jn ? e.slice(0, jn) + "…" : e;
|
|
1836
1877
|
return /[\s=]/.test(t) ? `"${t.replace(/"/g, "\\\"")}"` : t;
|
|
1837
1878
|
}
|
|
1838
1879
|
if (e === null) return "null";
|
|
1839
1880
|
if (typeof e == "number" || typeof e == "boolean") return String(e);
|
|
1840
1881
|
try {
|
|
1841
1882
|
let t = JSON.stringify(e);
|
|
1842
|
-
return t.length >
|
|
1883
|
+
return t.length > jn ? t.slice(0, jn) + "…" : t;
|
|
1843
1884
|
} catch {
|
|
1844
1885
|
return "[unserialisable]";
|
|
1845
1886
|
}
|
|
1846
|
-
},
|
|
1847
|
-
Ln.length = 0;
|
|
1848
|
-
let r = e[1] && !e[1].startsWith("-") ? e[1] : void 0, i = r ? n(r) ? r : a(process.cwd(), r) : process.cwd(), o = [], s = i;
|
|
1849
|
-
for (;;) {
|
|
1850
|
-
o.push(s);
|
|
1851
|
-
let e = t(s);
|
|
1852
|
-
if (e === s) break;
|
|
1853
|
-
s = e;
|
|
1854
|
-
}
|
|
1855
|
-
for (let e of o) for (let t of [".env.local", ".env"]) {
|
|
1856
|
-
let n = a(e, t);
|
|
1857
|
-
if (y(n)) {
|
|
1858
|
-
Ln.push(n);
|
|
1859
|
-
try {
|
|
1860
|
-
let e = C(n, "utf8");
|
|
1861
|
-
for (let t of e.split(/\r?\n/)) {
|
|
1862
|
-
let e = t.trim();
|
|
1863
|
-
if (e === "" || e.startsWith("#")) continue;
|
|
1864
|
-
let n = e.indexOf("=");
|
|
1865
|
-
if (n < 1) continue;
|
|
1866
|
-
let r = e.slice(0, n).trim(), i = e.slice(n + 1).trim();
|
|
1867
|
-
(i.startsWith("\"") && i.endsWith("\"") || i.startsWith("'") && i.endsWith("'")) && (i = i.slice(1, -1)), process.env[r] === void 0 && (process.env[r] = i);
|
|
1868
|
-
}
|
|
1869
|
-
} catch (e) {
|
|
1870
|
-
In.warn("failed to load env file (continuing)", { path: n }, e);
|
|
1871
|
-
}
|
|
1872
|
-
}
|
|
1873
|
-
}
|
|
1874
|
-
}, zn = 500, Bn = (e, t, n = {}) => {
|
|
1875
|
-
if (e.length === 0) return () => {};
|
|
1876
|
-
let r = (e) => n.root ? i(n.root, e) : e, a = !1, o = (e) => {
|
|
1877
|
-
a || (a = !0, t.warn(`.env changed (${r(e)}) — hard-restarting: process.env is read once at boot, a reload would keep stale values`, { file: r(e) }), Promise.resolve().then(() => n.onBeforeRestart?.()).catch((e) => t.warn(".env restart: onBeforeRestart failed (continuing)", {}, e)).finally(() => {
|
|
1878
|
-
let e = de(process.execPath, [...process.execArgv, ...process.argv.slice(1)], {
|
|
1879
|
-
stdio: "inherit",
|
|
1880
|
-
env: process.env,
|
|
1881
|
-
cwd: n.cwd ?? process.cwd()
|
|
1882
|
-
}), r = (t) => {
|
|
1883
|
-
e.kill(t);
|
|
1884
|
-
}, i = () => r("SIGINT"), a = () => r("SIGTERM");
|
|
1885
|
-
process.on("SIGINT", i), process.on("SIGTERM", a), e.on("exit", (e, t) => {
|
|
1886
|
-
process.off("SIGINT", i), process.off("SIGTERM", a), t ? process.kill(process.pid, t) : process.exit(e ?? 0);
|
|
1887
|
-
}), e.on("error", (e) => {
|
|
1888
|
-
t.error(".env restart: spawn failed", {}, e), process.exit(1);
|
|
1889
|
-
});
|
|
1890
|
-
}));
|
|
1891
|
-
};
|
|
1892
|
-
for (let t of e) D(t, { interval: zn }, (e, n) => {
|
|
1893
|
-
e.mtimeMs !== n.mtimeMs && o(t);
|
|
1894
|
-
});
|
|
1895
|
-
return t.info("watching .env files for changes", {
|
|
1896
|
-
files: e.map(r),
|
|
1897
|
-
intervalMs: zn
|
|
1898
|
-
}), () => {
|
|
1899
|
-
for (let t of e) ee(t);
|
|
1900
|
-
};
|
|
1901
|
-
}, Vn = [{
|
|
1887
|
+
}, Pn = "/_voltro/inspect/logs", Fn = [{
|
|
1902
1888
|
match: (e) => typeof e == "string" && e.startsWith("[BABEL] Note: The code generator has deoptimised"),
|
|
1903
1889
|
handle: (e, t) => {
|
|
1904
1890
|
let n = e[0], r = n.match(/deoptimised the styling of (.+?) as it exceeds the max of (\d+\w*B)\.?/);
|
|
@@ -1910,13 +1896,13 @@ __installPublicEnv(publicEnvValues)
|
|
|
1910
1896
|
});
|
|
1911
1897
|
} else t.info(n);
|
|
1912
1898
|
}
|
|
1913
|
-
}],
|
|
1899
|
+
}], In = () => {
|
|
1914
1900
|
let e = {
|
|
1915
1901
|
warn: console.warn.bind(console),
|
|
1916
1902
|
error: console.error.bind(console)
|
|
1917
1903
|
}, t = g({ scope: "babel" }), n = !1, r = (r) => (...i) => {
|
|
1918
1904
|
if (!n) {
|
|
1919
|
-
for (let e of
|
|
1905
|
+
for (let e of Fn) if (e.match(i[0])) {
|
|
1920
1906
|
n = !0;
|
|
1921
1907
|
try {
|
|
1922
1908
|
e.handle(i, t);
|
|
@@ -1931,7 +1917,7 @@ __installPublicEnv(publicEnvValues)
|
|
|
1931
1917
|
return console.warn = r("warn"), console.error = r("error"), () => {
|
|
1932
1918
|
console.warn = e.warn, console.error = e.error;
|
|
1933
1919
|
};
|
|
1934
|
-
},
|
|
1920
|
+
}, Ln = {
|
|
1935
1921
|
loader: "it runs on the server, and the router caches its result per route + params",
|
|
1936
1922
|
renderMode: "it picks the server render strategy",
|
|
1937
1923
|
dynamic: "it picks the server render strategy",
|
|
@@ -1942,7 +1928,7 @@ __installPublicEnv(publicEnvValues)
|
|
|
1942
1928
|
cacheInvalidatesOn: "it wires this page into the ISR cache invalidator",
|
|
1943
1929
|
interactive: "it decides how much client JS the server ships",
|
|
1944
1930
|
tenantAware: "it is part of the server-side cache key"
|
|
1945
|
-
},
|
|
1931
|
+
}, Rn = Object.keys(Ln), zn = "virtual:voltro-route-refresh", Bn = `\0${zn}`, Vn = /(?:^|&)(raw|url|inline|worker|sharedworker|direct)(?:&|=|$)/, Hn = () => `
|
|
1946
1932
|
// GENERATED by @voltro/cli — the \`voltro dev\` route Fast Refresh runtime.
|
|
1947
1933
|
|
|
1948
1934
|
/** Mirrors react-refresh's own \`isLikelyComponentType\` closely enough for the
|
|
@@ -1971,11 +1957,11 @@ const stableForm = (value) => {
|
|
|
1971
1957
|
* readers (\`build.ts\` prerender, \`webDev.ts\` dev SSR, \`start.ts\`). A change to
|
|
1972
1958
|
* one of THESE cannot be hot-applied: the server already ran with the old
|
|
1973
1959
|
* value. Everything else a page exports is plain client-side data. */
|
|
1974
|
-
const serverRelevantExports = ${JSON.stringify(
|
|
1960
|
+
const serverRelevantExports = ${JSON.stringify(Rn)}
|
|
1975
1961
|
|
|
1976
1962
|
/** Name → the server step that already consumed it, so the reload message can
|
|
1977
1963
|
* say WHY rather than just WHAT. Injected from the same single source. */
|
|
1978
|
-
const serverExportEffect = ${JSON.stringify(
|
|
1964
|
+
const serverExportEffect = ${JSON.stringify(Ln)}
|
|
1979
1965
|
|
|
1980
1966
|
/** The reason \`name\` forces a reload, for the console line. */
|
|
1981
1967
|
export const serverEffectOf = (name) =>
|
|
@@ -2018,7 +2004,7 @@ export const routeUpdateNeedsReload = (prevExports, nextExports) => {
|
|
|
2018
2004
|
const previousHook = globalThis.__getReactRefreshIgnoredExports
|
|
2019
2005
|
globalThis.__getReactRefreshIgnoredExports = (args) =>
|
|
2020
2006
|
ignoredExports.get(args.id) ?? previousHook?.(args) ?? []
|
|
2021
|
-
`,
|
|
2007
|
+
`, Un = (e) => `
|
|
2022
2008
|
if (import.meta.hot) {
|
|
2023
2009
|
// Self-import to read our OWN exports, the same technique the react plugin
|
|
2024
2010
|
// uses; the namespace is only complete after evaluation, hence the promise.
|
|
@@ -2045,48 +2031,76 @@ import {
|
|
|
2045
2031
|
registerRouteModule as __voltro_registerRouteModule,
|
|
2046
2032
|
routeUpdateNeedsReload as __voltro_routeUpdateNeedsReload,
|
|
2047
2033
|
serverEffectOf as __voltro_serverEffect,
|
|
2048
|
-
} from '${
|
|
2049
|
-
`,
|
|
2050
|
-
let [n = "", r] =
|
|
2051
|
-
if (!n.endsWith(".tsx") || r !== void 0 &&
|
|
2052
|
-
let i =
|
|
2034
|
+
} from '${zn}'
|
|
2035
|
+
`, Wn = (e) => e.replace(/\\/g, "/"), Gn = (e, t) => {
|
|
2036
|
+
let [n = "", r] = Wn(e).split("?");
|
|
2037
|
+
if (!n.endsWith(".tsx") || r !== void 0 && Vn.test(r)) return !1;
|
|
2038
|
+
let i = Wn(t).replace(/\/$/, "");
|
|
2053
2039
|
return n.startsWith(`${i}/`);
|
|
2054
|
-
},
|
|
2040
|
+
}, Kn = (e, t, n) => Gn(t, n) ? `${e}${Un(Wn(t).split("?")[0] ?? t)}` : null, qn = (e) => ({
|
|
2055
2041
|
name: "voltro:route-fast-refresh",
|
|
2056
2042
|
enforce: "pre",
|
|
2057
|
-
resolveId: (e) => e === "virtual:voltro-route-refresh" ?
|
|
2058
|
-
load: (e) => e ===
|
|
2043
|
+
resolveId: (e) => e === "virtual:voltro-route-refresh" ? Bn : void 0,
|
|
2044
|
+
load: (e) => e === Bn ? Hn() : void 0,
|
|
2059
2045
|
transform: (t, n, r) => {
|
|
2060
2046
|
if (r?.ssr === !0) return null;
|
|
2061
|
-
let i =
|
|
2047
|
+
let i = Kn(t, n, e);
|
|
2062
2048
|
return i === null ? null : {
|
|
2063
2049
|
code: i,
|
|
2064
2050
|
map: null
|
|
2065
2051
|
};
|
|
2066
2052
|
}
|
|
2067
|
-
}),
|
|
2053
|
+
}), Jn = [
|
|
2054
|
+
"static",
|
|
2055
|
+
"spa",
|
|
2056
|
+
"ssr",
|
|
2057
|
+
"isr"
|
|
2058
|
+
], Yn = (e) => typeof e == "string" && Jn.includes(e), Xn = Jn.map((e) => `'${e}'`).join(" | "), Zn = (e, t) => `[voltro] ${e}: unknown renderMode '${t}'.\n Valid values: ${Xn}.${t === "client" || t === "csr" || t === "browser" ? "\n A page that renders only in the browser is 'spa': it is skipped by the prerender and mounts on the client. If its route has a layout, that layout still renders server-side as an SSR shell." : t === "server" || t === "dynamic" ? "\n A page rendered per request is 'ssr'." : t === "ssg" || t === "prerender" ? "\n A page rendered once at build time is 'static' (the default)." : ""}`, Qn = class extends Error {
|
|
2059
|
+
page;
|
|
2060
|
+
value;
|
|
2061
|
+
name = "InvalidRenderModeError";
|
|
2062
|
+
constructor(e, t) {
|
|
2063
|
+
super(Zn(e, t)), this.page = e, this.value = t;
|
|
2064
|
+
}
|
|
2065
|
+
}, $n = (e, t = "<page>") => {
|
|
2066
|
+
if (e.renderMode !== void 0 && e.renderMode !== null) {
|
|
2067
|
+
if (!Yn(e.renderMode)) throw new Qn(t, String(e.renderMode));
|
|
2068
|
+
return e.renderMode;
|
|
2069
|
+
}
|
|
2070
|
+
return e.dynamic === "force-dynamic" ? "ssr" : (e.dynamic, "static");
|
|
2071
|
+
}, er = (e, t = "<page>") => ({
|
|
2072
|
+
renderMode: $n(e, t),
|
|
2073
|
+
tenantAware: e.tenantAware === !0,
|
|
2074
|
+
revalidateMs: it(e.revalidate),
|
|
2075
|
+
staleWhileRevalidateMs: it(e.staleWhileRevalidate) ?? 0,
|
|
2076
|
+
cacheInvalidatesOn: Array.isArray(e.cacheInvalidatesOn) ? e.cacheInvalidatesOn : [],
|
|
2077
|
+
interactive: e.interactive ?? "full",
|
|
2078
|
+
hasLoader: typeof e.loader == "function",
|
|
2079
|
+
hasMeta: e.meta != null,
|
|
2080
|
+
hasGetStaticPaths: typeof e.getStaticPaths == "function"
|
|
2081
|
+
}), tr = /export\s+const\s+renderMode\s*(?::[^=]+)?=\s*['"]([^'"]*)['"]/, nr = (e) => tr.exec(e)?.[1] ?? null, rr = async (e, t) => {
|
|
2068
2082
|
let n = (await Promise.all(t.map(async (t) => {
|
|
2069
2083
|
let n;
|
|
2070
2084
|
try {
|
|
2071
|
-
n = await
|
|
2085
|
+
n = await de(r(e, t.file), "utf8");
|
|
2072
2086
|
} catch {
|
|
2073
2087
|
return null;
|
|
2074
2088
|
}
|
|
2075
|
-
let i =
|
|
2076
|
-
return i === null ||
|
|
2089
|
+
let i = nr(n);
|
|
2090
|
+
return i === null || Yn(i) ? null : {
|
|
2077
2091
|
file: t.file,
|
|
2078
2092
|
value: i
|
|
2079
2093
|
};
|
|
2080
2094
|
}))).filter((e) => e !== null);
|
|
2081
|
-
if (n.length !== 0) throw Error(n.map((e) =>
|
|
2082
|
-
},
|
|
2095
|
+
if (n.length !== 0) throw Error(n.map((e) => Zn(r("src", "pages", e.file), e.value)).join("\n\n"));
|
|
2096
|
+
}, ir = r(re(), ".voltro"), ar = r(ir, "runtime-registry.json"), or = 3e4, sr = () => {
|
|
2083
2097
|
let e = Math.random().toString(36).slice(2, 10);
|
|
2084
|
-
return `${
|
|
2085
|
-
}, sr = async () => {
|
|
2086
|
-
await S.mkdir(rr, { recursive: !0 });
|
|
2098
|
+
return `${ar}.${process.pid}.${Date.now()}.${e}.tmp`;
|
|
2087
2099
|
}, cr = async () => {
|
|
2100
|
+
await S.mkdir(ir, { recursive: !0 });
|
|
2101
|
+
}, lr = async () => {
|
|
2088
2102
|
try {
|
|
2089
|
-
let e = await S.readFile(
|
|
2103
|
+
let e = await S.readFile(ar, "utf8"), t = JSON.parse(e);
|
|
2090
2104
|
return t.version !== 1 || !Array.isArray(t.apps) ? {
|
|
2091
2105
|
version: 1,
|
|
2092
2106
|
apps: []
|
|
@@ -2097,31 +2111,31 @@ import {
|
|
|
2097
2111
|
apps: []
|
|
2098
2112
|
};
|
|
2099
2113
|
}
|
|
2100
|
-
},
|
|
2101
|
-
await
|
|
2102
|
-
let t =
|
|
2114
|
+
}, ur = async (e) => {
|
|
2115
|
+
await cr();
|
|
2116
|
+
let t = sr();
|
|
2103
2117
|
try {
|
|
2104
|
-
await S.writeFile(t, JSON.stringify(e, null, 2), "utf8"), await S.rename(t,
|
|
2118
|
+
await S.writeFile(t, JSON.stringify(e, null, 2), "utf8"), await S.rename(t, ar);
|
|
2105
2119
|
} catch (e) {
|
|
2106
2120
|
try {
|
|
2107
2121
|
await S.unlink(t);
|
|
2108
2122
|
} catch {}
|
|
2109
2123
|
throw e;
|
|
2110
2124
|
}
|
|
2111
|
-
},
|
|
2125
|
+
}, dr = (e) => {
|
|
2112
2126
|
try {
|
|
2113
2127
|
return process.kill(e, 0), !0;
|
|
2114
2128
|
} catch {
|
|
2115
2129
|
return !1;
|
|
2116
2130
|
}
|
|
2117
|
-
},
|
|
2131
|
+
}, fr = (e) => {
|
|
2118
2132
|
let t = Date.now();
|
|
2119
|
-
return e.filter((e) =>
|
|
2120
|
-
},
|
|
2121
|
-
let e = await
|
|
2133
|
+
return e.filter((e) => dr(e.pid) ? t - new Date(e.heartbeatAt).getTime() < or : !1);
|
|
2134
|
+
}, pr = async () => {
|
|
2135
|
+
let e = await lr(), t = fr(e.apps);
|
|
2122
2136
|
if (t.length === e.apps.length) return e;
|
|
2123
2137
|
try {
|
|
2124
|
-
await
|
|
2138
|
+
await ur({
|
|
2125
2139
|
version: 1,
|
|
2126
2140
|
apps: t
|
|
2127
2141
|
});
|
|
@@ -2130,48 +2144,48 @@ import {
|
|
|
2130
2144
|
version: 1,
|
|
2131
2145
|
apps: t
|
|
2132
2146
|
};
|
|
2133
|
-
},
|
|
2134
|
-
let t = await
|
|
2147
|
+
}, mr = async (e) => {
|
|
2148
|
+
let t = await lr(), n = (/* @__PURE__ */ new Date()).toISOString(), r = t.apps.findIndex((t) => t.id === e.id), i = {
|
|
2135
2149
|
...e,
|
|
2136
2150
|
registeredAt: r >= 0 ? t.apps[r].registeredAt : n,
|
|
2137
2151
|
heartbeatAt: n
|
|
2138
2152
|
};
|
|
2139
|
-
await
|
|
2153
|
+
await ur({
|
|
2140
2154
|
version: 1,
|
|
2141
2155
|
apps: r >= 0 ? t.apps.map((e, t) => t === r ? i : e) : [...t.apps, i]
|
|
2142
2156
|
});
|
|
2143
|
-
},
|
|
2157
|
+
}, hr = async (e) => {
|
|
2144
2158
|
try {
|
|
2145
|
-
let t = await
|
|
2159
|
+
let t = await lr(), n = t.apps.filter((t) => t.id !== e);
|
|
2146
2160
|
if (n.length === t.apps.length) return;
|
|
2147
|
-
await
|
|
2161
|
+
await ur({
|
|
2148
2162
|
version: 1,
|
|
2149
2163
|
apps: n
|
|
2150
2164
|
});
|
|
2151
2165
|
} catch {}
|
|
2152
|
-
},
|
|
2166
|
+
}, gr = (e, t, n) => `${e}:${t}:${n}`, X = r(re(), ".voltro", "logs"), _r = () => {
|
|
2153
2167
|
let e = Number(process.env.VOLTRO_LOG_FILE_TTL_MS);
|
|
2154
2168
|
return Number.isFinite(e) && e > 0 ? e : 3600 * 1e3;
|
|
2155
|
-
},
|
|
2156
|
-
if (
|
|
2157
|
-
|
|
2158
|
-
let e = Date.now() -
|
|
2169
|
+
}, vr = !1, yr = () => {
|
|
2170
|
+
if (vr) return;
|
|
2171
|
+
vr = !0;
|
|
2172
|
+
let e = Date.now() - _r(), t = [];
|
|
2159
2173
|
try {
|
|
2160
|
-
t = w(
|
|
2174
|
+
t = w(X);
|
|
2161
2175
|
} catch {
|
|
2162
2176
|
return;
|
|
2163
2177
|
}
|
|
2164
2178
|
for (let n of t) {
|
|
2165
2179
|
if (!n.endsWith(".log")) continue;
|
|
2166
|
-
let t = r(
|
|
2180
|
+
let t = r(X, n);
|
|
2167
2181
|
try {
|
|
2168
2182
|
T(t).mtimeMs < e && E(t);
|
|
2169
2183
|
} catch {}
|
|
2170
2184
|
}
|
|
2171
|
-
},
|
|
2172
|
-
let t =
|
|
2185
|
+
}, br = (e) => e.replace(/[^a-zA-Z0-9._-]/g, "_").slice(0, 80), xr = (e, t) => r(X, `${br(e)}-${t}.log`), Sr = (e) => {
|
|
2186
|
+
let t = br(e), n = [];
|
|
2173
2187
|
try {
|
|
2174
|
-
n = w(
|
|
2188
|
+
n = w(X);
|
|
2175
2189
|
} catch {
|
|
2176
2190
|
return;
|
|
2177
2191
|
}
|
|
@@ -2179,19 +2193,19 @@ import {
|
|
|
2179
2193
|
if (i.length === 0) return;
|
|
2180
2194
|
let a, o = -1;
|
|
2181
2195
|
for (let e of i) {
|
|
2182
|
-
let t = r(
|
|
2196
|
+
let t = r(X, e);
|
|
2183
2197
|
try {
|
|
2184
2198
|
let e = T(t);
|
|
2185
2199
|
e.mtimeMs > o && (o = e.mtimeMs, a = t);
|
|
2186
2200
|
} catch {}
|
|
2187
2201
|
}
|
|
2188
2202
|
return a;
|
|
2189
|
-
},
|
|
2203
|
+
}, Cr = (e) => {
|
|
2190
2204
|
try {
|
|
2191
|
-
b(
|
|
2205
|
+
b(X, { recursive: !0 });
|
|
2192
2206
|
} catch {}
|
|
2193
|
-
|
|
2194
|
-
let t =
|
|
2207
|
+
yr();
|
|
2208
|
+
let t = xr(e, process.pid), n = x(t, "w"), r = (e) => {
|
|
2195
2209
|
let t = {
|
|
2196
2210
|
ts: e.ts.getTime(),
|
|
2197
2211
|
level: e.level,
|
|
@@ -2232,7 +2246,7 @@ import {
|
|
|
2232
2246
|
a(), o(), process.off("exit", o), process.off("uncaughtException", s), process.off("unhandledRejection", s);
|
|
2233
2247
|
}
|
|
2234
2248
|
};
|
|
2235
|
-
},
|
|
2249
|
+
}, wr = async (e, t) => {
|
|
2236
2250
|
let n;
|
|
2237
2251
|
try {
|
|
2238
2252
|
n = await S.readFile(e, "utf8");
|
|
@@ -2246,11 +2260,11 @@ import {
|
|
|
2246
2260
|
i.push(t);
|
|
2247
2261
|
} catch {}
|
|
2248
2262
|
return t?.max !== void 0 && i.length > t.max ? i.slice(i.length - t.max) : i;
|
|
2249
|
-
},
|
|
2263
|
+
}, Tr = g({ scope: "voltro:dashboard" }), Er = ne(import.meta.url), Dr = 5179, Or = (e) => {
|
|
2250
2264
|
let n = process.env.VOLTRO_DASHBOARD_PATH;
|
|
2251
2265
|
if (n && y(r(a(n), "app.config.ts"))) return a(n);
|
|
2252
2266
|
try {
|
|
2253
|
-
let e = t(
|
|
2267
|
+
let e = t(Er.resolve("@voltro/dashboard/package.json"));
|
|
2254
2268
|
if (y(r(e, "app.config.ts"))) return e;
|
|
2255
2269
|
} catch {}
|
|
2256
2270
|
let i = r("voltro-devtools", "apps", "dashboard"), o = a(e);
|
|
@@ -2262,53 +2276,53 @@ import {
|
|
|
2262
2276
|
o = n;
|
|
2263
2277
|
}
|
|
2264
2278
|
return null;
|
|
2265
|
-
},
|
|
2266
|
-
let i =
|
|
2279
|
+
}, kr = "VOLTRO_IS_DASHBOARD", Ar = (e, t = "127.0.0.1", n = 250) => new Promise((r) => {
|
|
2280
|
+
let i = he({
|
|
2267
2281
|
port: e,
|
|
2268
2282
|
host: t
|
|
2269
2283
|
}), a = !1, o = (e) => {
|
|
2270
2284
|
a || (a = !0, i.destroy(), r(e));
|
|
2271
2285
|
};
|
|
2272
2286
|
i.once("connect", () => o(!0)), i.once("error", () => o(!1)), setTimeout(() => o(!1), n);
|
|
2273
|
-
}),
|
|
2287
|
+
}), jr = () => !!(process.env.VOLTRO_DASHBOARD === "off" || process.argv.includes("--disable-dashboard")), Mr = () => process.env[kr] === "1", Nr = () => process.stdout.isTTY === !0, Pr = r(re(), ".voltro", "dashboard-launch.lock"), Fr = 1e4, Ir = async () => {
|
|
2274
2288
|
try {
|
|
2275
|
-
await S.mkdir(t(
|
|
2276
|
-
let e = await S.open(
|
|
2289
|
+
await S.mkdir(t(Pr), { recursive: !0 });
|
|
2290
|
+
let e = await S.open(Pr, "wx");
|
|
2277
2291
|
return await e.write(`${process.pid}\n${Date.now()}\n`), await e.close(), !0;
|
|
2278
2292
|
} catch {
|
|
2279
2293
|
try {
|
|
2280
|
-
let e = await S.stat(
|
|
2281
|
-
if (Date.now() - e.mtimeMs >
|
|
2294
|
+
let e = await S.stat(Pr);
|
|
2295
|
+
if (Date.now() - e.mtimeMs > Fr) return await S.unlink(Pr).catch(() => void 0), Ir();
|
|
2282
2296
|
} catch {}
|
|
2283
2297
|
return !1;
|
|
2284
2298
|
}
|
|
2285
|
-
},
|
|
2299
|
+
}, Lr = async () => {
|
|
2286
2300
|
try {
|
|
2287
|
-
await S.unlink(
|
|
2301
|
+
await S.unlink(Pr);
|
|
2288
2302
|
} catch {}
|
|
2289
|
-
},
|
|
2303
|
+
}, Rr = async (e) => {
|
|
2290
2304
|
let n = e.port ?? 5179;
|
|
2291
|
-
if (
|
|
2305
|
+
if (jr()) return {
|
|
2292
2306
|
status: "skipped",
|
|
2293
2307
|
reason: "disabled by flag/env",
|
|
2294
2308
|
port: n
|
|
2295
2309
|
};
|
|
2296
|
-
if (
|
|
2310
|
+
if (Mr()) return {
|
|
2297
2311
|
status: "skipped",
|
|
2298
2312
|
reason: "this process IS the dashboard",
|
|
2299
2313
|
port: n
|
|
2300
2314
|
};
|
|
2301
|
-
if (!
|
|
2315
|
+
if (!Nr()) return {
|
|
2302
2316
|
status: "skipped",
|
|
2303
2317
|
reason: "stdout is not a TTY (CI/smoke)",
|
|
2304
2318
|
port: n
|
|
2305
2319
|
};
|
|
2306
|
-
if (!await
|
|
2320
|
+
if (!await Ir()) return {
|
|
2307
2321
|
status: "skipped",
|
|
2308
2322
|
reason: "another voltro process is currently launching the dashboard",
|
|
2309
2323
|
port: n
|
|
2310
2324
|
};
|
|
2311
|
-
if (await
|
|
2325
|
+
if (await Ar(n)) return await Lr(), {
|
|
2312
2326
|
status: "already-running",
|
|
2313
2327
|
port: n
|
|
2314
2328
|
};
|
|
@@ -2317,7 +2331,7 @@ import {
|
|
|
2317
2331
|
let e = process.argv[1];
|
|
2318
2332
|
i = e && e.endsWith("/src/bin.ts") ? r(t(e), "..", "bin", "voltro.mjs") : e ?? "voltro";
|
|
2319
2333
|
}
|
|
2320
|
-
let a = y(r(e.dashboardAppPath, ".framework", "dist", "index.html")), o = a ? "start" : "dev", s =
|
|
2334
|
+
let a = y(r(e.dashboardAppPath, ".framework", "dist", "index.html")), o = a ? "start" : "dev", s = me(process.execPath, [
|
|
2321
2335
|
i,
|
|
2322
2336
|
o,
|
|
2323
2337
|
e.dashboardAppPath
|
|
@@ -2325,7 +2339,7 @@ import {
|
|
|
2325
2339
|
stdio: "ignore",
|
|
2326
2340
|
env: {
|
|
2327
2341
|
...process.env,
|
|
2328
|
-
[
|
|
2342
|
+
[kr]: "1",
|
|
2329
2343
|
VOLTRO_DASHBOARD_PORT: String(n)
|
|
2330
2344
|
}
|
|
2331
2345
|
});
|
|
@@ -2333,22 +2347,22 @@ import {
|
|
|
2333
2347
|
if (s.exitCode === null && s.signalCode === null) try {
|
|
2334
2348
|
s.kill("SIGTERM");
|
|
2335
2349
|
} catch {}
|
|
2336
|
-
}),
|
|
2350
|
+
}), Tr.info(`auto-launching dashboard at http://localhost:${n}`, {
|
|
2337
2351
|
port: n,
|
|
2338
2352
|
mode: o,
|
|
2339
2353
|
prebuilt: a
|
|
2340
|
-
}), a ||
|
|
2341
|
-
|
|
2354
|
+
}), a || Tr.debug("no pre-built dashboard — running `voltro dev`. Build with `cd voltro-devtools && pnpm build` for a fast prod boot."), Tr.debug("disable via --disable-dashboard or VOLTRO_DASHBOARD=off"), setTimeout(() => {
|
|
2355
|
+
Lr();
|
|
2342
2356
|
}, 4e3).unref(), {
|
|
2343
2357
|
status: "launched",
|
|
2344
2358
|
port: n
|
|
2345
2359
|
};
|
|
2346
|
-
},
|
|
2360
|
+
}, zr = class extends Error {
|
|
2347
2361
|
_voltroDeferral = !0;
|
|
2348
2362
|
constructor(e) {
|
|
2349
2363
|
super(e), this.name = "DeferralNotSupportedError";
|
|
2350
2364
|
}
|
|
2351
|
-
},
|
|
2365
|
+
}, Br = (e) => typeof e == "object" && !!e && e._voltroDeferral === !0, Vr = (e) => {
|
|
2352
2366
|
let { helpers: t } = e, n = t.prepareDeferredLoaderData(e.loaderData, "page"), r = {}, i = {}, a = {};
|
|
2353
2367
|
for (let [n, o] of Object.entries(e.segmentLoaderData)) {
|
|
2354
2368
|
let e = Number(n), s = t.prepareDeferredLoaderData(o, e);
|
|
@@ -2363,7 +2377,7 @@ import {
|
|
|
2363
2377
|
...e.layoutShell ? { layoutShell: e.layoutShell } : {}
|
|
2364
2378
|
});
|
|
2365
2379
|
} catch (e) {
|
|
2366
|
-
throw new
|
|
2380
|
+
throw new zr(e instanceof Error ? e.message : String(e));
|
|
2367
2381
|
}
|
|
2368
2382
|
return {
|
|
2369
2383
|
loaderData: n.renderData,
|
|
@@ -2379,8 +2393,8 @@ import {
|
|
|
2379
2393
|
...Object.keys(a).length > 0 ? { deferredSegmentIds: a } : {}
|
|
2380
2394
|
}
|
|
2381
2395
|
};
|
|
2382
|
-
},
|
|
2383
|
-
let { helpers: t, renderInput: n } = e, r =
|
|
2396
|
+
}, Hr = (e) => {
|
|
2397
|
+
let { helpers: t, renderInput: n } = e, r = Vr({
|
|
2384
2398
|
helpers: t,
|
|
2385
2399
|
page: e.page,
|
|
2386
2400
|
pathname: n.pathname,
|
|
@@ -2401,42 +2415,42 @@ import {
|
|
|
2401
2415
|
stateScript: t.renderRouterStateScript(r.stateInput),
|
|
2402
2416
|
hasDeferred: r.hasDeferred
|
|
2403
2417
|
};
|
|
2404
|
-
},
|
|
2418
|
+
}, Ur = (e) => {
|
|
2405
2419
|
let { html: t, meta: n } = e.helpers.renderPageToHtml(e.prepared.renderInput);
|
|
2406
2420
|
return {
|
|
2407
2421
|
body: t,
|
|
2408
2422
|
meta: n
|
|
2409
2423
|
};
|
|
2410
|
-
},
|
|
2424
|
+
}, Wr = (e) => [
|
|
2411
2425
|
...e.extra ?? [],
|
|
2412
2426
|
e.helpers.renderMetaToHtml(e.meta),
|
|
2413
2427
|
`<meta name="voltro-interactive" content="${e.interactive}" />`,
|
|
2414
2428
|
...e.prepared.hasDeferred ? [e.helpers.renderDeferredRegistryScript()] : [],
|
|
2415
2429
|
e.prepared.stateScript
|
|
2416
|
-
].filter((e) => e.length > 0).join("\n "),
|
|
2417
|
-
let t = e.keepScriptInHead ?? ((e) => e.startsWith("/@")), n = [], r = e.shell.replace(
|
|
2418
|
-
let r =
|
|
2430
|
+
].filter((e) => e.length > 0).join("\n "), Gr = "<div id=\"root\"></div>", Kr = "<div id=\"root\">", qr = "</div>", Jr = /<script\b[^>]*\btype=["']module["'][^>]*><\/script>[ \t]*\n?/gi, Yr = /\bsrc=["']([^"']+)["']/i, Xr = /<script(?![^>]*\basync\b)([^>]*\btype=["']module["'][^>]*)>/gi, Zr = (e) => {
|
|
2431
|
+
let t = e.keepScriptInHead ?? ((e) => e.startsWith("/@")), n = [], r = e.shell.replace(Jr, (e) => {
|
|
2432
|
+
let r = Yr.exec(e)?.[1];
|
|
2419
2433
|
return r === void 0 || t(r) ? e : (n.push(r), "");
|
|
2420
2434
|
});
|
|
2421
|
-
e.inlineModuleScriptsAsync && (r = r.replace(
|
|
2422
|
-
let i = r.indexOf(
|
|
2423
|
-
if (i === -1) throw Error(`[voltro] the generated shell has no \`${
|
|
2435
|
+
e.inlineModuleScriptsAsync && (r = r.replace(Xr, "<script async$1>"));
|
|
2436
|
+
let i = r.indexOf(Gr);
|
|
2437
|
+
if (i === -1) throw Error(`[voltro] the generated shell has no \`${Gr}\` element, so a streamed response cannot be split around the page body. This is a framework bug unless the app overrode \`.framework/index.html\` by hand.`);
|
|
2424
2438
|
return {
|
|
2425
|
-
head: `${r.slice(0, i)}${
|
|
2426
|
-
tail: `${
|
|
2439
|
+
head: `${r.slice(0, i)}${Kr}`,
|
|
2440
|
+
tail: `${qr}${r.slice(i + 21)}`,
|
|
2427
2441
|
bootstrapModules: n
|
|
2428
2442
|
};
|
|
2429
|
-
},
|
|
2443
|
+
}, Qr = (e) => e.head.replace("</head>", ` ${e.headInjection}\n </head>`).replace(/<html(\s+lang="[^"]*")?/i, `<html lang="${e.htmlLang}"`), $r = (e) => {
|
|
2430
2444
|
let { res: t, shell: n, htmlLang: r, headInjection: i } = e, a = null, o = !1, s = !1, c = () => {
|
|
2431
2445
|
if (s || !o || a === null) return;
|
|
2432
2446
|
s = !0, t.statusCode = e.statusCode ?? 200;
|
|
2433
2447
|
for (let [n, r] of Object.entries(e.headers ?? {})) t.setHeader(n, r);
|
|
2434
|
-
t.flushHeaders?.(), t.write(
|
|
2448
|
+
t.flushHeaders?.(), t.write(Qr({
|
|
2435
2449
|
head: n.head,
|
|
2436
2450
|
headInjection: i(a.meta),
|
|
2437
2451
|
htmlLang: r
|
|
2438
2452
|
}));
|
|
2439
|
-
let c = new
|
|
2453
|
+
let c = new ge();
|
|
2440
2454
|
c.pipe(t, { end: !1 }), c.on("end", () => {
|
|
2441
2455
|
t.end(n.tail);
|
|
2442
2456
|
}), a.stream.pipe(c);
|
|
@@ -2461,14 +2475,14 @@ import {
|
|
|
2461
2475
|
return;
|
|
2462
2476
|
}
|
|
2463
2477
|
c();
|
|
2464
|
-
},
|
|
2478
|
+
}, Z = g({ scope: "voltro:dev:web" }), ei = g({ scope: "vite" }), ti = await (async () => {
|
|
2465
2479
|
try {
|
|
2466
2480
|
let e = r(t(o(import.meta.url)), "..", "package.json"), n = await S.readFile(e, "utf8");
|
|
2467
2481
|
return JSON.parse(n).version ?? "0.0.0";
|
|
2468
2482
|
} catch {
|
|
2469
2483
|
return "0.0.0";
|
|
2470
2484
|
}
|
|
2471
|
-
})(),
|
|
2485
|
+
})(), ni = async () => {
|
|
2472
2486
|
try {
|
|
2473
2487
|
let e = t(o(import.meta.url)), n = a(e, "..", "..", "devtools");
|
|
2474
2488
|
if (y(r(n, "package.json"))) return n;
|
|
@@ -2477,7 +2491,7 @@ import {
|
|
|
2477
2491
|
} catch {
|
|
2478
2492
|
return null;
|
|
2479
2493
|
}
|
|
2480
|
-
},
|
|
2494
|
+
}, ri = (e, t) => e.disableDevtools || !t ? [] : [
|
|
2481
2495
|
"",
|
|
2482
2496
|
"// Dev-only in-page devtools overlay. The `import.meta.env.DEV` guard is a",
|
|
2483
2497
|
"// compile-time constant, so prod builds strip this whole `if` block — the",
|
|
@@ -2487,12 +2501,12 @@ import {
|
|
|
2487
2501
|
" await import('@voltro/devtools/styles.css')",
|
|
2488
2502
|
" Devtools = (await import('@voltro/devtools')).VoltroDevtools",
|
|
2489
2503
|
"}"
|
|
2490
|
-
],
|
|
2504
|
+
], ii = (e, t) => e.disableDevtools || !t ? [] : [" ...(Devtools ? { Devtools } : {}),"], ai = (e) => e.sentry ? ["import { initSentryBrowser } from '@voltro/plugin-sentry/web'"] : [], oi = (e) => e.sentry ? [
|
|
2491
2505
|
"",
|
|
2492
2506
|
"// Browser-side Sentry (frontend half of the deep integration). Errors +",
|
|
2493
2507
|
"// browser rpc spans flow to Sentry, sharing the server transactions' trace.",
|
|
2494
2508
|
`await initSentryBrowser(${JSON.stringify(e.sentry)})`
|
|
2495
|
-
] : [],
|
|
2509
|
+
] : [], si = (e) => e.env ? ["import './env.public'"] : [], ci = (e) => {
|
|
2496
2510
|
let n = [], i = a(e);
|
|
2497
2511
|
for (;;) {
|
|
2498
2512
|
y(r(i, "pnpm-workspace.yaml")) && n.push(i);
|
|
@@ -2501,19 +2515,19 @@ import {
|
|
|
2501
2515
|
i = e;
|
|
2502
2516
|
}
|
|
2503
2517
|
return n;
|
|
2504
|
-
},
|
|
2518
|
+
}, li = /* @__PURE__ */ new Set([
|
|
2505
2519
|
"layout.tsx",
|
|
2506
2520
|
"error.tsx",
|
|
2507
2521
|
"loading.tsx",
|
|
2508
2522
|
"not-found.tsx"
|
|
2509
|
-
]),
|
|
2523
|
+
]), ui = (e) => /\.(test|spec)\.tsx$/.test(e), di = (e) => {
|
|
2510
2524
|
if (/\/node_modules\/(?:\.pnpm\/[^/]+\/node_modules\/)?(?:react|react-dom|scheduler)\//.test(e)) return "react";
|
|
2511
2525
|
let t = /\/([^/]+)\.island\.tsx?$/.exec(e);
|
|
2512
2526
|
if (t) return `island-${t[1]}`;
|
|
2513
|
-
},
|
|
2514
|
-
let t = e.replace(/\.tsx$/, "").split("/").filter(Boolean).filter((e) => !
|
|
2527
|
+
}, fi = /export\s+(?:async\s+)?(?:const|function|let|var)\s+loader\b/, pi = (e) => e.startsWith("(") && e.endsWith(")"), mi = (e) => e.filter((e) => !pi(e)), hi = (e) => {
|
|
2528
|
+
let t = e.replace(/\.tsx$/, "").split("/").filter(Boolean).filter((e) => !pi(e)), n = t.length > 0 && t[t.length - 1] === "index" ? t.slice(0, -1) : t;
|
|
2515
2529
|
return n.length === 0 ? "/" : "/" + n.join("/");
|
|
2516
|
-
},
|
|
2530
|
+
}, gi = (e) => `${e.replace(/\.tsx$/, "").split("/").filter(Boolean).map((e) => e.replace(/[()]/g, "").replace(/\[\.\.\./g, "_rest_").replace(/[[\]]/g, "_")).map((e) => e.charAt(0).toUpperCase() + e.slice(1)).join("").replace(/[^A-Za-z0-9_]/g, "_") || "Index"}Page`, Q = (e, t) => e === "" ? `Root${t}` : `${e.split("/").filter(Boolean).map((e) => e.replace(/[()]/g, "").replace(/\[\.\.\./g, "_rest_").replace(/[[\]]/g, "_")).map((e) => e.charAt(0).toUpperCase() + e.slice(1)).join("").replace(/[^A-Za-z0-9_]/g, "_") || "Root"}${t}`, $ = async (e) => {
|
|
2517
2531
|
let t = [], n = [], i = async (e, a) => {
|
|
2518
2532
|
let o = [];
|
|
2519
2533
|
try {
|
|
@@ -2521,17 +2535,17 @@ import {
|
|
|
2521
2535
|
} catch {
|
|
2522
2536
|
return;
|
|
2523
2537
|
}
|
|
2524
|
-
let s = o.filter((e) => e.isDirectory()).map((e) => e.name).sort(), c = o.filter((e) => e.isFile() && e.name.endsWith(".tsx") && !
|
|
2525
|
-
if (c.some((e) =>
|
|
2538
|
+
let s = o.filter((e) => e.isDirectory()).map((e) => e.name).sort(), c = o.filter((e) => e.isFile() && e.name.endsWith(".tsx") && !ui(e.name)).map((e) => e.name).sort(), l = new Set(c), u = a.join("/");
|
|
2539
|
+
if (c.some((e) => li.has(e))) {
|
|
2526
2540
|
let t = l.has("layout.tsx"), i = !1;
|
|
2527
2541
|
if (t) try {
|
|
2528
2542
|
let t = await S.readFile(r(e, "layout.tsx"), "utf8");
|
|
2529
|
-
i =
|
|
2543
|
+
i = fi.test(t);
|
|
2530
2544
|
} catch {}
|
|
2531
2545
|
n.push({
|
|
2532
2546
|
dir: u,
|
|
2533
2547
|
chain: a,
|
|
2534
|
-
contributesToUrl: a.length === 0 || !
|
|
2548
|
+
contributesToUrl: a.length === 0 || !pi(a[a.length - 1]),
|
|
2535
2549
|
hasLayout: t,
|
|
2536
2550
|
hasLayoutLoader: i,
|
|
2537
2551
|
hasError: l.has("error.tsx"),
|
|
@@ -2540,12 +2554,12 @@ import {
|
|
|
2540
2554
|
});
|
|
2541
2555
|
}
|
|
2542
2556
|
for (let e of c) {
|
|
2543
|
-
if (
|
|
2557
|
+
if (li.has(e)) continue;
|
|
2544
2558
|
let n = u ? `${u}/${e}` : e;
|
|
2545
2559
|
t.push({
|
|
2546
2560
|
file: n,
|
|
2547
|
-
pattern:
|
|
2548
|
-
ident:
|
|
2561
|
+
pattern: hi(n),
|
|
2562
|
+
ident: gi(n),
|
|
2549
2563
|
dirChain: a
|
|
2550
2564
|
});
|
|
2551
2565
|
}
|
|
@@ -2585,7 +2599,7 @@ import {
|
|
|
2585
2599
|
segmentLoaderData: o
|
|
2586
2600
|
};
|
|
2587
2601
|
}, yi = (e) => {
|
|
2588
|
-
let t =
|
|
2602
|
+
let t = mi(e);
|
|
2589
2603
|
return t.length === 0 ? "" : "/" + t.join("/");
|
|
2590
2604
|
}, bi = [
|
|
2591
2605
|
"// Hot-reload bridge: keep SSR-injected <link rel=\"stylesheet\"> tags",
|
|
@@ -2739,6 +2753,7 @@ import {
|
|
|
2739
2753
|
pkg: t.package,
|
|
2740
2754
|
browserWsUrl: t.url,
|
|
2741
2755
|
proxyTarget: void 0,
|
|
2756
|
+
...t.serverUrl ? { serverOrigin: t.serverUrl } : {},
|
|
2742
2757
|
...t.headers ? { headers: t.headers } : {}
|
|
2743
2758
|
}), Di = (e, t, n) => {
|
|
2744
2759
|
let r = t.transport?.wsPath ?? n.wsPath;
|
|
@@ -2748,6 +2763,7 @@ import {
|
|
|
2748
2763
|
browserWsUrl: r ?? `/ws/${e}`,
|
|
2749
2764
|
proxyTarget: `ws://localhost:${n.port}`,
|
|
2750
2765
|
...r ? { wsPath: r } : {},
|
|
2766
|
+
...t.serverUrl ? { serverOrigin: t.serverUrl } : {},
|
|
2751
2767
|
...t.headers ? { headers: t.headers } : {}
|
|
2752
2768
|
};
|
|
2753
2769
|
}, Oi = (e) => {
|
|
@@ -2771,48 +2787,71 @@ import {
|
|
|
2771
2787
|
}
|
|
2772
2788
|
return Oi(r), r;
|
|
2773
2789
|
}, Ai = (e) => {
|
|
2774
|
-
if (!e)
|
|
2775
|
-
|
|
2776
|
-
|
|
2777
|
-
let e = new URL(t);
|
|
2778
|
-
return e.protocol = e.protocol === "wss:" || e.protocol === "https:" ? "https:" : "http:", `${e.protocol}//${e.host}`;
|
|
2790
|
+
if (!(!/^wss?:\/\//.test(e) && !/^https?:\/\//.test(e))) try {
|
|
2791
|
+
let t = new URL(e);
|
|
2792
|
+
return t.protocol = t.protocol === "wss:" || t.protocol === "https:" ? "https:" : "http:", `${t.protocol}//${t.host}`;
|
|
2779
2793
|
} catch {
|
|
2780
2794
|
return;
|
|
2781
2795
|
}
|
|
2782
|
-
}, ji = (e, t) => {
|
|
2783
|
-
if (e) return
|
|
2784
|
-
|
|
2796
|
+
}, ji = (e) => `VOLTRO_API_ORIGIN_${e.toUpperCase().replace(/[^A-Z0-9]/g, "_")}`, Mi = (e) => process.env[ji(e)] ?? process.env.VOLTRO_API_ORIGIN, Ni = (e, t) => {
|
|
2797
|
+
if (!e) return;
|
|
2798
|
+
let n = Mi(e.name) ?? e.serverOrigin;
|
|
2799
|
+
if (n) {
|
|
2800
|
+
let e = Ai(n);
|
|
2801
|
+
if (e) return e;
|
|
2802
|
+
}
|
|
2803
|
+
if (t?.allowDevProxy && e.proxyTarget) {
|
|
2804
|
+
let t = Ai(e.proxyTarget);
|
|
2805
|
+
if (t) return t;
|
|
2806
|
+
}
|
|
2807
|
+
if (!e.proxyTarget && /^wss?:\/\//.test(e.browserWsUrl)) return Ai(e.browserWsUrl);
|
|
2808
|
+
}, Pi = (e, t, n) => {
|
|
2809
|
+
if (!e) {
|
|
2810
|
+
if (n?.apiName === void 0) return;
|
|
2811
|
+
let e = n.apiName;
|
|
2812
|
+
return async () => {
|
|
2813
|
+
throw Error(`[loader.query] api '${e}' has no server-side origin for SSR. In a split web/api deployment the web pod reaches the api by internal DNS, not the browser's relative wsPath — set ${ji(e)} (or VOLTRO_API_ORIGIN, or apis.${e}.serverUrl in app.config.ts) to the api's internal origin, e.g. http://api.<namespace>.svc.cluster.local. The browser transport is unaffected.`);
|
|
2814
|
+
};
|
|
2815
|
+
}
|
|
2816
|
+
return async (r, i) => {
|
|
2817
|
+
let a = {
|
|
2785
2818
|
_tag: "Request",
|
|
2786
2819
|
id: "0",
|
|
2787
|
-
tag:
|
|
2788
|
-
payload:
|
|
2820
|
+
tag: r,
|
|
2821
|
+
payload: i ?? {},
|
|
2789
2822
|
headers: []
|
|
2790
|
-
},
|
|
2791
|
-
|
|
2792
|
-
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
|
|
2803
|
-
|
|
2823
|
+
}, o;
|
|
2824
|
+
try {
|
|
2825
|
+
o = await fetch(`${e}/rpc`, {
|
|
2826
|
+
method: "POST",
|
|
2827
|
+
headers: {
|
|
2828
|
+
"content-type": "application/json",
|
|
2829
|
+
...t ? { cookie: t } : {}
|
|
2830
|
+
},
|
|
2831
|
+
body: JSON.stringify(a)
|
|
2832
|
+
});
|
|
2833
|
+
} catch (t) {
|
|
2834
|
+
let i = t?.cause?.code ?? String(t?.message ?? t);
|
|
2835
|
+
throw Error(`[loader.query] ${r}: could not reach the api at ${e}/rpc (${i}). ${n?.apiName ? `Set ${ji(n.apiName)} / VOLTRO_API_ORIGIN` : "Set the api server origin"} to the api's SSR-reachable origin (internal cluster DNS in a split deployment).`, { cause: t });
|
|
2836
|
+
}
|
|
2837
|
+
if (!o.ok) throw Error(`[loader.query] ${r}: HTTP ${o.status} ${await o.text()}`);
|
|
2838
|
+
let s = await o.json();
|
|
2839
|
+
if (!Array.isArray(s)) throw Error(`[loader.query] ${r}: unexpected non-array rpc response`);
|
|
2840
|
+
let c = (e) => e && typeof e == "object" && "_tag" in e && "data" in e && e._tag === "snapshot" ? e.data : e, l, u = !1;
|
|
2841
|
+
for (let e of s) {
|
|
2842
|
+
if (e._tag === "ClientProtocolError") throw Error(`[loader.query] ${r}: protocol error ${JSON.stringify(e.error)}`);
|
|
2804
2843
|
if (!(e.requestId !== void 0 && String(e.requestId) !== "0")) {
|
|
2805
|
-
if (e._tag === "Chunk" && e.values && e.values.length > 0 && !
|
|
2844
|
+
if (e._tag === "Chunk" && e.values && e.values.length > 0 && !u && (l = c(e.values[0]), u = !0), e._tag === "Defect") throw Error(`[loader.query] ${r}: defect ${JSON.stringify(e)}`);
|
|
2806
2845
|
if (e._tag === "Exit" && e.exit) {
|
|
2807
|
-
if (e.exit._tag === "Failure") throw Error(`[loader.query] ${
|
|
2808
|
-
!
|
|
2846
|
+
if (e.exit._tag === "Failure") throw Error(`[loader.query] ${r}: rpc failed ${JSON.stringify(e.exit.cause ?? e.exit)}`);
|
|
2847
|
+
!u && e.exit._tag === "Success" && e.exit.value !== void 0 && (l = c(e.exit.value), u = !0);
|
|
2809
2848
|
}
|
|
2810
2849
|
}
|
|
2811
2850
|
}
|
|
2812
|
-
if (
|
|
2851
|
+
if (u) return l;
|
|
2813
2852
|
};
|
|
2814
|
-
},
|
|
2815
|
-
let a = t.title ?? t.name ?? "app", o = t.theme === "dark" ? " class=\"dark\"" : t.theme === "light" ? " class=\"light\"" : "", s = y(r(e, "node_modules", "@voltro", "devtools", "package.json")) || await
|
|
2853
|
+
}, Fi = async (e, t, n, i = {}) => {
|
|
2854
|
+
let a = t.title ?? t.name ?? "app", o = t.theme === "dark" ? " class=\"dark\"" : t.theme === "light" ? " class=\"light\"" : "", s = y(r(e, "node_modules", "@voltro", "devtools", "package.json")) || await ni() !== null, c = t.theme === "system" ? [
|
|
2816
2855
|
" <script>",
|
|
2817
2856
|
" (function () {",
|
|
2818
2857
|
" var root = document.documentElement",
|
|
@@ -2850,8 +2889,8 @@ import {
|
|
|
2850
2889
|
" </body>",
|
|
2851
2890
|
"</html>",
|
|
2852
2891
|
""
|
|
2853
|
-
].join("\n"), u = r(e, "src", "pages"), { pages: d, dirs: f } = await
|
|
2854
|
-
await
|
|
2892
|
+
].join("\n"), u = r(e, "src", "pages"), { pages: d, dirs: f } = await $(u);
|
|
2893
|
+
await rr(u, d);
|
|
2855
2894
|
let p = (e) => `${e.replace(/[^a-zA-Z0-9]/g, "_")}AppGroup`, m = (e) => `${e.replace(/[^a-zA-Z0-9]/g, "_")}AppDescriptors`, h = n.map((e) => `import { appGroup as ${p(e.name)}, appDescriptors as ${m(e.name)} } from '${e.pkg}/rpcGroup'`), g = n.map((e) => {
|
|
2856
2895
|
let t = [`group: ${p(e.name)}`];
|
|
2857
2896
|
return t.push(`descriptors: ${m(e.name)}`), t.push(`wsUrl: ${JSON.stringify(e.browserWsUrl)}`), e.headers && t.push(`headers: ${JSON.stringify(e.headers)}`), ` ${JSON.stringify(e.name)}: { ${t.join(", ")} },`;
|
|
@@ -2860,7 +2899,7 @@ import {
|
|
|
2860
2899
|
let e = d.map((e) => ` ${JSON.stringify(e.pattern)}: () => import('../src/pages/${e.file}'),`), n = [];
|
|
2861
2900
|
for (let e of f) {
|
|
2862
2901
|
let t = e.dir === "" ? "../src/pages" : `../src/pages/${e.dir}`;
|
|
2863
|
-
e.hasLayout && e.hasLayoutLoader ? n.push(`import * as ${
|
|
2902
|
+
e.hasLayout && e.hasLayoutLoader ? n.push(`import * as ${Q(e.dir, "Layout")}Mod from '${t}/layout.tsx'`) : e.hasLayout && n.push(`import ${Q(e.dir, "Layout")} from '${t}/layout.tsx'`), e.hasError && n.push(`import ${Q(e.dir, "Error")} from '${t}/error.tsx'`), e.hasPending && n.push(`import ${Q(e.dir, "Pending")} from '${t}/loading.tsx'`), e.hasNotFound && n.push(`import ${Q(e.dir, "NotFound")} from '${t}/not-found.tsx'`);
|
|
2864
2903
|
}
|
|
2865
2904
|
let r = d.map((e) => {
|
|
2866
2905
|
let t = _i(f, e.dirChain).map((e) => {
|
|
@@ -2877,23 +2916,23 @@ import {
|
|
|
2877
2916
|
}), a = [], o = [], c = [], l = [], u = [], p = [];
|
|
2878
2917
|
for (let e of f) {
|
|
2879
2918
|
let t = e.dir === "" ? "../src/pages/layout.tsx" : `../src/pages/${e.dir}/layout.tsx`, n = e.dir === "" ? "../src/pages/error.tsx" : `../src/pages/${e.dir}/error.tsx`, r = e.dir === "" ? "../src/pages/loading.tsx" : `../src/pages/${e.dir}/loading.tsx`, i = e.dir === "" ? "../src/pages/not-found.tsx" : `../src/pages/${e.dir}/not-found.tsx`, s = JSON.stringify(e.dir);
|
|
2880
|
-
e.hasLayout && e.hasLayoutLoader ? (o.push(` ${s}: ${
|
|
2919
|
+
e.hasLayout && e.hasLayoutLoader ? (o.push(` ${s}: ${Q(e.dir, "Layout")}Mod.default,`), c.push(` ${s}: ${Q(e.dir, "Layout")}Mod.loader,`), a.push({
|
|
2881
2920
|
relPath: t,
|
|
2882
2921
|
kind: "layout",
|
|
2883
2922
|
slotKey: e.dir
|
|
2884
|
-
})) : e.hasLayout && (o.push(` ${s}: ${
|
|
2923
|
+
})) : e.hasLayout && (o.push(` ${s}: ${Q(e.dir, "Layout")},`), a.push({
|
|
2885
2924
|
relPath: t,
|
|
2886
2925
|
kind: "layout",
|
|
2887
2926
|
slotKey: e.dir
|
|
2888
|
-
})), e.hasError && (l.push(` ${s}: ${
|
|
2927
|
+
})), e.hasError && (l.push(` ${s}: ${Q(e.dir, "Error")},`), a.push({
|
|
2889
2928
|
relPath: n,
|
|
2890
2929
|
kind: "error",
|
|
2891
2930
|
slotKey: e.dir
|
|
2892
|
-
})), e.hasPending && (u.push(` ${s}: ${
|
|
2931
|
+
})), e.hasPending && (u.push(` ${s}: ${Q(e.dir, "Pending")},`), a.push({
|
|
2893
2932
|
relPath: r,
|
|
2894
2933
|
kind: "pending",
|
|
2895
2934
|
slotKey: e.dir
|
|
2896
|
-
})), e.hasNotFound && (p.push(` ${s}: ${
|
|
2935
|
+
})), e.hasNotFound && (p.push(` ${s}: ${Q(e.dir, "NotFound")},`), a.push({
|
|
2897
2936
|
relPath: i,
|
|
2898
2937
|
kind: "notFound",
|
|
2899
2938
|
slotKey: e.dir
|
|
@@ -3108,14 +3147,14 @@ import {
|
|
|
3108
3147
|
"// resolved apis map. Side-effect only — no local component definitions —",
|
|
3109
3148
|
"// so downstream invalidations (user page edits) terminate at app.tsx.",
|
|
3110
3149
|
"",
|
|
3111
|
-
...
|
|
3150
|
+
...si(t),
|
|
3112
3151
|
"import { mount } from '@voltro/web'",
|
|
3113
3152
|
...h,
|
|
3114
3153
|
"import { App } from './app'",
|
|
3115
3154
|
"import { preloadCurrentRoute } from './routeTable'",
|
|
3116
|
-
...ii(t),
|
|
3117
|
-
...ni(t, s),
|
|
3118
3155
|
...ai(t),
|
|
3156
|
+
...ri(t, s),
|
|
3157
|
+
...oi(t),
|
|
3119
3158
|
"",
|
|
3120
3159
|
"// Preload the current route's page chunk BEFORE hydration so the first",
|
|
3121
3160
|
"// client render matches the SSG/SSR-prerendered HTML. Without it, a lazy",
|
|
@@ -3132,7 +3171,7 @@ import {
|
|
|
3132
3171
|
" apis: {",
|
|
3133
3172
|
...g,
|
|
3134
3173
|
" },",
|
|
3135
|
-
...
|
|
3174
|
+
...ii(t, s),
|
|
3136
3175
|
"})",
|
|
3137
3176
|
"",
|
|
3138
3177
|
bi
|
|
@@ -3143,25 +3182,25 @@ import {
|
|
|
3143
3182
|
"// and calls mount(). Side-effect only, no component definitions, so the",
|
|
3144
3183
|
"// user's component file remains the Fast Refresh boundary.",
|
|
3145
3184
|
"",
|
|
3146
|
-
...
|
|
3185
|
+
...si(t),
|
|
3147
3186
|
"import { mount } from '@voltro/web'",
|
|
3148
3187
|
...h,
|
|
3149
3188
|
"import App from '../src/App'",
|
|
3150
|
-
...ii(t),
|
|
3151
|
-
...ni(t, s),
|
|
3152
3189
|
...ai(t),
|
|
3190
|
+
...ri(t, s),
|
|
3191
|
+
...oi(t),
|
|
3153
3192
|
"",
|
|
3154
3193
|
"mount(App, {",
|
|
3155
3194
|
" apis: {",
|
|
3156
3195
|
...g,
|
|
3157
3196
|
" },",
|
|
3158
|
-
...
|
|
3197
|
+
...ii(t, s),
|
|
3159
3198
|
"})",
|
|
3160
3199
|
"",
|
|
3161
3200
|
bi
|
|
3162
3201
|
].join("\n");
|
|
3163
3202
|
let x = r(e, ".framework");
|
|
3164
|
-
await S.mkdir(x, { recursive: !0 }), t.env ? await
|
|
3203
|
+
await S.mkdir(x, { recursive: !0 }), t.env ? await Qe(x, i) : await S.rm(r(x, "env.public.ts"), { force: !0 }), await S.writeFile(r(x, "index.html"), l, "utf8"), await S.writeFile(r(x, "main.tsx"), b, "utf8"), _ ? (await S.writeFile(r(x, "app.tsx"), _, "utf8"), await S.writeFile(r(x, "routeTable.ts"), v, "utf8")) : (await S.rm(r(x, "app.tsx"), { force: !0 }), await S.rm(r(x, "routeTable.ts"), { force: !0 }));
|
|
3165
3204
|
let C = r(e, ".gitignore"), w = "";
|
|
3166
3205
|
try {
|
|
3167
3206
|
w = await S.readFile(C, "utf8");
|
|
@@ -3169,62 +3208,62 @@ import {
|
|
|
3169
3208
|
let T = ["/.framework/"], E = w.split("\n").filter((e) => e.trim() !== "");
|
|
3170
3209
|
for (let e of T) E.includes(e) || E.push(e);
|
|
3171
3210
|
await S.writeFile(C, E.join("\n") + "\n", "utf8");
|
|
3172
|
-
},
|
|
3211
|
+
}, Ii = async (e, n) => {
|
|
3173
3212
|
try {
|
|
3174
3213
|
let i = r(t(e), "project.json");
|
|
3175
3214
|
if (!y(i)) return;
|
|
3176
3215
|
let a = await S.readFile(i, "utf8"), o = JSON.parse(a).apps ?? {}, s = e.split("/").filter(Boolean).pop() ?? "", c = [];
|
|
3177
3216
|
for (let [e, t] of Object.entries(o)) e !== s && t.port === n && c.push(e);
|
|
3178
3217
|
if (c.length === 0) return;
|
|
3179
|
-
|
|
3218
|
+
Z.warn("sibling app(s) claim the same port — only one boots", {
|
|
3180
3219
|
port: n,
|
|
3181
3220
|
conflicts: c,
|
|
3182
3221
|
projectJson: i
|
|
3183
3222
|
});
|
|
3184
3223
|
} catch {}
|
|
3185
|
-
},
|
|
3186
|
-
let t =
|
|
3224
|
+
}, Li = (e) => r(e, ".framework", "dist", "server", "appConfig.js"), Ri = async (e) => {
|
|
3225
|
+
let t = Li(e), n = y(t) ? t : r(e, "app.config.ts");
|
|
3187
3226
|
try {
|
|
3188
3227
|
let e = (await import(s(n).href)).default;
|
|
3189
3228
|
return typeof e == "object" && e && "type" in e && e.type === "web" ? e : null;
|
|
3190
3229
|
} catch {
|
|
3191
3230
|
return null;
|
|
3192
3231
|
}
|
|
3193
|
-
},
|
|
3194
|
-
let n = await
|
|
3232
|
+
}, zi = async (t) => {
|
|
3233
|
+
let n = await Ri(t);
|
|
3195
3234
|
if (!n) return {
|
|
3196
3235
|
ran: !1,
|
|
3197
3236
|
exitCode: 0
|
|
3198
3237
|
};
|
|
3199
|
-
|
|
3200
|
-
let o =
|
|
3201
|
-
|
|
3238
|
+
In();
|
|
3239
|
+
let o = on();
|
|
3240
|
+
gn(o), Z.info("booting voltro dev (web)", { app: n.name ?? "(unnamed)" });
|
|
3202
3241
|
let s = await ki(t, n);
|
|
3203
|
-
for (let e of s)
|
|
3242
|
+
for (let e of s) Z.info("api wired", {
|
|
3204
3243
|
name: e.name,
|
|
3205
3244
|
pkg: e.pkg,
|
|
3206
3245
|
...e.proxyTarget ? { proxyTo: e.proxyTarget } : { directWs: e.browserWsUrl }
|
|
3207
3246
|
});
|
|
3208
|
-
|
|
3247
|
+
Ve(t).then((e) => {
|
|
3209
3248
|
for (let t of e.files) if (t.action === "created") {
|
|
3210
3249
|
let e = t.path.split("/").pop() ?? t.path;
|
|
3211
|
-
|
|
3250
|
+
Z.info(`${e} seeded`, { path: t.path });
|
|
3212
3251
|
}
|
|
3213
3252
|
}).catch(() => {});
|
|
3214
|
-
let { resolved: c } = await
|
|
3253
|
+
let { resolved: c } = await $e({
|
|
3215
3254
|
rawEnv: n.env,
|
|
3216
3255
|
appType: "web",
|
|
3217
3256
|
root: t,
|
|
3218
|
-
log:
|
|
3257
|
+
log: Z,
|
|
3219
3258
|
generateTypes: !0
|
|
3220
3259
|
}), l = c.publicValues;
|
|
3221
|
-
await
|
|
3260
|
+
await Fi(t, n, s, l), Z.debug("generated framework entry files", { files: [
|
|
3222
3261
|
"index.html",
|
|
3223
3262
|
".framework/main.tsx",
|
|
3224
3263
|
...n.env ? [".framework/env.public.ts"] : []
|
|
3225
3264
|
] });
|
|
3226
|
-
let u = process.env.VOLTRO_IS_DASHBOARD === "1" && process.env.VOLTRO_DASHBOARD_PORT ? Number(process.env.VOLTRO_DASHBOARD_PORT) : n.port ?? 5173, d = n.name ?? "unnamed", f =
|
|
3227
|
-
await
|
|
3265
|
+
let u = process.env.VOLTRO_IS_DASHBOARD === "1" && process.env.VOLTRO_DASHBOARD_PORT ? Number(process.env.VOLTRO_DASHBOARD_PORT) : n.port ?? 5173, d = n.name ?? "unnamed", f = gr("web", d, u), p = Cr(d);
|
|
3266
|
+
await mr({
|
|
3228
3267
|
id: f,
|
|
3229
3268
|
name: d,
|
|
3230
3269
|
kind: "web",
|
|
@@ -3232,19 +3271,19 @@ import {
|
|
|
3232
3271
|
pid: process.pid,
|
|
3233
3272
|
status: "booting",
|
|
3234
3273
|
logFile: p.path
|
|
3235
|
-
}).catch(() => {}), await
|
|
3236
|
-
let { pages: m, dirs: h } = await
|
|
3274
|
+
}).catch(() => {}), await Ii(t, u);
|
|
3275
|
+
let { pages: m, dirs: h } = await $(r(t, "src", "pages")), g = h.map((e) => ({
|
|
3237
3276
|
dir: e.dir,
|
|
3238
3277
|
hasLayout: e.hasLayout,
|
|
3239
3278
|
hasError: e.hasError,
|
|
3240
3279
|
hasPending: e.hasPending,
|
|
3241
3280
|
hasNotFound: e.hasNotFound
|
|
3242
|
-
})), v = await
|
|
3281
|
+
})), v = await rn({
|
|
3243
3282
|
appRoot: t,
|
|
3244
3283
|
pages: m
|
|
3245
3284
|
});
|
|
3246
|
-
v.wrote &&
|
|
3247
|
-
let b = await
|
|
3285
|
+
v.wrote && Z.debug("routes codegen wrote", { path: i(t, v.path) });
|
|
3286
|
+
let b = await Ke("vite", () => import("vite")), x = (await import("@vitejs/plugin-react")).default, C = (await import("@tailwindcss/vite")).default, w = r(t, ".framework"), T = r(t, "src"), E = /* @__PURE__ */ new Set([
|
|
3248
3287
|
".framework",
|
|
3249
3288
|
"node_modules",
|
|
3250
3289
|
"dist",
|
|
@@ -3280,17 +3319,17 @@ import {
|
|
|
3280
3319
|
}, D = r(t, "src", "pages"), te = (e) => e.endsWith(".tsx") && (e === D || e.startsWith(D + "/")), O = (e) => e === D || e.startsWith(D + "/"), k = async (e) => {
|
|
3281
3320
|
try {
|
|
3282
3321
|
let r = Date.now();
|
|
3283
|
-
await
|
|
3284
|
-
let { pages: i } = await
|
|
3285
|
-
await
|
|
3322
|
+
await Fi(t, n, s, l);
|
|
3323
|
+
let { pages: i } = await $(D);
|
|
3324
|
+
await rn({
|
|
3286
3325
|
appRoot: t,
|
|
3287
3326
|
pages: i
|
|
3288
|
-
}),
|
|
3327
|
+
}), Z.info("page tree regenerated", {
|
|
3289
3328
|
reason: e,
|
|
3290
3329
|
ms: Date.now() - r
|
|
3291
3330
|
});
|
|
3292
3331
|
} catch (t) {
|
|
3293
|
-
|
|
3332
|
+
Z.error("page tree regen failed", { reason: e }, t);
|
|
3294
3333
|
}
|
|
3295
3334
|
}, A = {
|
|
3296
3335
|
name: "framework:regenerate-on-page-tree-change",
|
|
@@ -3312,17 +3351,17 @@ import {
|
|
|
3312
3351
|
O(e) && a(`unlinkDir ${i(t, e)}`);
|
|
3313
3352
|
});
|
|
3314
3353
|
}
|
|
3315
|
-
}, j = r(t, "app.config.ts"),
|
|
3354
|
+
}, j = r(t, "app.config.ts"), ne = (e) => {
|
|
3316
3355
|
if (!oe(e.env)) return "";
|
|
3317
3356
|
let t = Object.entries(e.env.vars).map(([e, t]) => `${e}:${t.access}`).sort();
|
|
3318
3357
|
return `${String(e.env.publicPrefix)}|${t.join(",")}`;
|
|
3319
|
-
},
|
|
3358
|
+
}, re = (e, t) => {
|
|
3320
3359
|
let n = [];
|
|
3321
|
-
return e.port !== t.port && n.push(`port ${e.port ?? "(default)"} → ${t.port ?? "(default)"}`), JSON.stringify(e.proxies) !== JSON.stringify(t.proxies) && n.push("proxies"), JSON.stringify(e.allowedHosts) !== JSON.stringify(t.allowedHosts) && n.push("allowedHosts"), JSON.stringify(e.apis) !== JSON.stringify(t.apis) && n.push("apis"),
|
|
3322
|
-
},
|
|
3360
|
+
return e.port !== t.port && n.push(`port ${e.port ?? "(default)"} → ${t.port ?? "(default)"}`), JSON.stringify(e.proxies) !== JSON.stringify(t.proxies) && n.push("proxies"), JSON.stringify(e.allowedHosts) !== JSON.stringify(t.allowedHosts) && n.push("allowedHosts"), JSON.stringify(e.apis) !== JSON.stringify(t.apis) && n.push("apis"), ne(e) !== ne(t) && n.push("env"), n;
|
|
3361
|
+
}, M = n, ie = a(j), N = {
|
|
3323
3362
|
name: "framework:watch-app-config",
|
|
3324
3363
|
async configureServer(n) {
|
|
3325
|
-
n.watcher.add(j),
|
|
3364
|
+
n.watcher.add(j), Z.info("watching app.config.ts for changes", { path: i(t, j) });
|
|
3326
3365
|
let r = async () => {
|
|
3327
3366
|
try {
|
|
3328
3367
|
try {
|
|
@@ -3330,9 +3369,9 @@ import {
|
|
|
3330
3369
|
e && n.moduleGraph.invalidateModule(e);
|
|
3331
3370
|
} catch {}
|
|
3332
3371
|
let e = (await n.ssrLoadModule(j, { fixStacktrace: !0 })).default;
|
|
3333
|
-
return typeof e == "object" && e && "type" in e && e.type === "web" ? e : (
|
|
3372
|
+
return typeof e == "object" && e && "type" in e && e.type === "web" ? e : (Z.warn("app.config.ts re-load returned wrong shape", { hasDefault: e !== void 0 }), null);
|
|
3334
3373
|
} catch (e) {
|
|
3335
|
-
return
|
|
3374
|
+
return Z.warn("app.config.ts re-load failed — ignoring this change", {}, e), null;
|
|
3336
3375
|
}
|
|
3337
3376
|
}, o = null, s = () => {
|
|
3338
3377
|
o && clearTimeout(o), o = setTimeout(() => {
|
|
@@ -3341,24 +3380,24 @@ import {
|
|
|
3341
3380
|
}, c = async () => {
|
|
3342
3381
|
let e = await r();
|
|
3343
3382
|
if (!e) {
|
|
3344
|
-
|
|
3383
|
+
Z.info("app.config.ts onConfigChange: load returned null — skipping");
|
|
3345
3384
|
return;
|
|
3346
3385
|
}
|
|
3347
|
-
if (
|
|
3386
|
+
if (Z.info("app.config.ts onConfigChange: loaded", {
|
|
3348
3387
|
theme: e.theme,
|
|
3349
3388
|
port: e.port,
|
|
3350
3389
|
name: e.name
|
|
3351
|
-
}), JSON.stringify(e) === JSON.stringify(
|
|
3352
|
-
|
|
3390
|
+
}), JSON.stringify(e) === JSON.stringify(M)) {
|
|
3391
|
+
Z.info("app.config.ts onConfigChange: parsed config unchanged — skipping (no-op edit?)");
|
|
3353
3392
|
return;
|
|
3354
3393
|
}
|
|
3355
|
-
let i =
|
|
3394
|
+
let i = re(M, e);
|
|
3356
3395
|
if (i.length > 0) {
|
|
3357
|
-
|
|
3396
|
+
Z.warn("app.config.ts changed — hard restart required", { fields: i });
|
|
3358
3397
|
try {
|
|
3359
3398
|
await n.close();
|
|
3360
3399
|
} catch {}
|
|
3361
|
-
let e =
|
|
3400
|
+
let e = me(process.execPath, [...process.execArgv, ...process.argv.slice(1)], {
|
|
3362
3401
|
stdio: "inherit",
|
|
3363
3402
|
env: process.env,
|
|
3364
3403
|
cwd: process.cwd()
|
|
@@ -3368,47 +3407,47 @@ import {
|
|
|
3368
3407
|
process.on("SIGINT", r), process.on("SIGTERM", a), e.on("exit", (e, t) => {
|
|
3369
3408
|
process.off("SIGINT", r), process.off("SIGTERM", a), t ? process.kill(process.pid, t) : process.exit(e ?? 0);
|
|
3370
3409
|
}), e.on("error", (e) => {
|
|
3371
|
-
|
|
3410
|
+
Z.error("restart spawn failed", {}, e), process.exit(1);
|
|
3372
3411
|
});
|
|
3373
3412
|
return;
|
|
3374
3413
|
}
|
|
3375
3414
|
try {
|
|
3376
3415
|
let r = Date.now();
|
|
3377
|
-
await
|
|
3416
|
+
await Fi(t, e, await ki(t, e)), M = e, n.ws && n.ws.send({
|
|
3378
3417
|
type: "full-reload",
|
|
3379
3418
|
path: "*"
|
|
3380
|
-
}),
|
|
3419
|
+
}), Z.info("app.config.ts soft-regen", {
|
|
3381
3420
|
ms: Date.now() - r,
|
|
3382
3421
|
reload: "full"
|
|
3383
3422
|
});
|
|
3384
3423
|
} catch (e) {
|
|
3385
|
-
|
|
3424
|
+
Z.error("app.config.ts soft-regen failed", {}, e);
|
|
3386
3425
|
}
|
|
3387
|
-
}, l = (t) => e(t) === "app.config.ts" ? t === j || a(t) ===
|
|
3426
|
+
}, l = (t) => e(t) === "app.config.ts" ? t === j || a(t) === ie : !1;
|
|
3388
3427
|
n.watcher.on("change", (e) => {
|
|
3389
|
-
l(e) && (
|
|
3428
|
+
l(e) && (Z.info("app.config.ts change event (chokidar)", { file: e }), s());
|
|
3390
3429
|
}), n.watcher.on("add", (e) => {
|
|
3391
|
-
l(e) && (
|
|
3430
|
+
l(e) && (Z.info("app.config.ts add event (chokidar)", { file: e }), s());
|
|
3392
3431
|
});
|
|
3393
3432
|
try {
|
|
3394
3433
|
let { watchFile: e } = await import("node:fs");
|
|
3395
3434
|
e(j, { interval: 500 }, (e, t) => {
|
|
3396
|
-
e.mtimeMs !== t.mtimeMs && (
|
|
3397
|
-
}),
|
|
3435
|
+
e.mtimeMs !== t.mtimeMs && (Z.info("app.config.ts change event (poll)", { mtime: e.mtimeMs }), s());
|
|
3436
|
+
}), Z.info("app.config.ts polling watcher attached", { intervalMs: 500 });
|
|
3398
3437
|
} catch (e) {
|
|
3399
|
-
|
|
3438
|
+
Z.warn("app.config.ts polling watcher could not attach", {}, e);
|
|
3400
3439
|
}
|
|
3401
|
-
|
|
3440
|
+
ft(lt, Z, {
|
|
3402
3441
|
root: t,
|
|
3403
3442
|
onBeforeRestart: () => n.close()
|
|
3404
3443
|
});
|
|
3405
3444
|
}
|
|
3406
|
-
},
|
|
3445
|
+
}, ae = /\/apps\/[^/]+\/.*\.(route|mutation|workflow|schema)\.tsx?$/, P = {
|
|
3407
3446
|
name: "framework:suppress-api-hmr",
|
|
3408
3447
|
handleHotUpdate(e) {
|
|
3409
|
-
if (
|
|
3448
|
+
if (ae.test(e.file)) return [];
|
|
3410
3449
|
}
|
|
3411
|
-
},
|
|
3450
|
+
}, se = {
|
|
3412
3451
|
name: "framework:reoptimize-on-rpcgroup-change",
|
|
3413
3452
|
async configureServer(e) {
|
|
3414
3453
|
let n = /* @__PURE__ */ new Map();
|
|
@@ -3440,14 +3479,14 @@ import {
|
|
|
3440
3479
|
r !== t && (n.set(e, r), a = e);
|
|
3441
3480
|
}
|
|
3442
3481
|
if (a !== null) {
|
|
3443
|
-
c = !0,
|
|
3482
|
+
c = !0, Z.info(`rpcGroup changed (${i(t, a)}) — re-bundling the api client + reloading (descriptor edits propagate automatically; no manual restart needed)`);
|
|
3444
3483
|
try {
|
|
3445
3484
|
await S.rm(r(w, ".vite", "deps"), {
|
|
3446
3485
|
recursive: !0,
|
|
3447
3486
|
force: !0
|
|
3448
3487
|
}), await e.restart(!0);
|
|
3449
3488
|
} catch (e) {
|
|
3450
|
-
c = !1,
|
|
3489
|
+
c = !1, Z.error("rpcGroup re-optimize failed", {}, e);
|
|
3451
3490
|
}
|
|
3452
3491
|
}
|
|
3453
3492
|
}, u = (e) => {
|
|
@@ -3457,38 +3496,38 @@ import {
|
|
|
3457
3496
|
};
|
|
3458
3497
|
e.watcher.on("change", u), e.watcher.on("add", u);
|
|
3459
3498
|
}
|
|
3460
|
-
},
|
|
3499
|
+
}, F = {};
|
|
3461
3500
|
for (let e of s) {
|
|
3462
3501
|
if (!e.proxyTarget) continue;
|
|
3463
|
-
|
|
3502
|
+
F[e.browserWsUrl] = {
|
|
3464
3503
|
target: e.proxyTarget,
|
|
3465
3504
|
ws: !0,
|
|
3466
3505
|
changeOrigin: !0,
|
|
3467
3506
|
...e.wsPath ? {} : { rewrite: () => "/ws" }
|
|
3468
3507
|
};
|
|
3469
3508
|
let t = e.proxyTarget.replace(/^ws/, "http");
|
|
3470
|
-
|
|
3509
|
+
F[`/_voltro/api/${e.name}`] = {
|
|
3471
3510
|
target: t,
|
|
3472
3511
|
changeOrigin: !0,
|
|
3473
3512
|
rewrite: (t) => t.replace(RegExp(`^/_voltro/api/${e.name}`), "")
|
|
3474
3513
|
};
|
|
3475
3514
|
}
|
|
3476
3515
|
for (let [e, t] of Object.entries(n.proxies ?? {})) {
|
|
3477
|
-
if (
|
|
3478
|
-
|
|
3516
|
+
if (F[e]) {
|
|
3517
|
+
Z.warn("user proxy ignored — prefix already claimed by an api ws proxy", { prefix: e });
|
|
3479
3518
|
continue;
|
|
3480
3519
|
}
|
|
3481
|
-
|
|
3520
|
+
F[e] = {
|
|
3482
3521
|
target: t.target,
|
|
3483
3522
|
changeOrigin: t.changeOrigin ?? !0,
|
|
3484
3523
|
...t.rewrite === void 0 ? {} : { rewrite: (n) => n.replace(RegExp(`^${e}`), t.rewrite) }
|
|
3485
|
-
},
|
|
3524
|
+
}, Z.info(`proxy ${e} → ${t.target}`, {
|
|
3486
3525
|
prefix: e,
|
|
3487
3526
|
target: t.target,
|
|
3488
3527
|
...t.rewrite === void 0 ? {} : { rewrite: t.rewrite }
|
|
3489
3528
|
});
|
|
3490
3529
|
}
|
|
3491
|
-
let
|
|
3530
|
+
let ce = {
|
|
3492
3531
|
name: "framework:inspect",
|
|
3493
3532
|
configureServer(e) {
|
|
3494
3533
|
let i = null, a = async () => {
|
|
@@ -3500,18 +3539,18 @@ import {
|
|
|
3500
3539
|
pattern: i.pattern,
|
|
3501
3540
|
file: i.file,
|
|
3502
3541
|
dirChain: i.dirChain,
|
|
3503
|
-
renderMode:
|
|
3542
|
+
renderMode: $n(a, r("src", "pages", i.file)),
|
|
3504
3543
|
interactive: a.interactive ?? "full",
|
|
3505
3544
|
tenantAware: a.tenantAware === !0,
|
|
3506
|
-
revalidateMs:
|
|
3507
|
-
staleWhileRevalidateMs:
|
|
3545
|
+
revalidateMs: it(a.revalidate),
|
|
3546
|
+
staleWhileRevalidateMs: it(a.staleWhileRevalidate) ?? 0,
|
|
3508
3547
|
cacheInvalidatesOn: Array.isArray(a.cacheInvalidatesOn) ? a.cacheInvalidatesOn : [],
|
|
3509
3548
|
hasLoader: typeof a.loader == "function",
|
|
3510
3549
|
hasMeta: a.meta != null,
|
|
3511
3550
|
hasGetStaticPaths: typeof a.getStaticPaths == "function"
|
|
3512
3551
|
});
|
|
3513
3552
|
} catch (e) {
|
|
3514
|
-
|
|
3553
|
+
Z.warn("inspect: failed to load page metadata", { pattern: i.pattern }, e);
|
|
3515
3554
|
}
|
|
3516
3555
|
return i = n, n;
|
|
3517
3556
|
};
|
|
@@ -3609,22 +3648,15 @@ import {
|
|
|
3609
3648
|
for (let [t, n] of Object.entries(e.headers ?? {})) n !== void 0 && (s[String(t).toLowerCase()] = Array.isArray(n) ? n.join(", ") : String(n));
|
|
3610
3649
|
let c = i.split("?")[0];
|
|
3611
3650
|
if (e.method === "GET" && (c === "/_voltro/inspect/logs" || i.startsWith("/_voltro/inspect/logs?"))) {
|
|
3612
|
-
let e =
|
|
3613
|
-
if (U()) {
|
|
3614
|
-
t.statusCode = 503, t.setHeader("content-type", "application/json");
|
|
3615
|
-
for (let [n, r] of Object.entries(e)) t.setHeader(n, r);
|
|
3616
|
-
t.end(JSON.stringify({ error: "inspect disabled (VOLTRO_INSPECT=off)" }));
|
|
3617
|
-
return;
|
|
3618
|
-
}
|
|
3619
|
-
let n = An(i, hn());
|
|
3651
|
+
let e = G(s.origin), n = kn(i, mn(), s);
|
|
3620
3652
|
t.statusCode = n.status, t.setHeader("content-type", n.contentType);
|
|
3621
3653
|
for (let [n, r] of Object.entries(e)) t.setHeader(n, r);
|
|
3622
3654
|
t.end(n.body);
|
|
3623
3655
|
return;
|
|
3624
3656
|
}
|
|
3625
3657
|
if (e.method === "POST" && c === "/_voltro/inspect/clientLog") {
|
|
3626
|
-
let n =
|
|
3627
|
-
if (
|
|
3658
|
+
let n = G(s.origin);
|
|
3659
|
+
if (H()) {
|
|
3628
3660
|
t.statusCode = 503, t.setHeader("content-type", "application/json");
|
|
3629
3661
|
for (let [e, r] of Object.entries(n)) t.setHeader(e, r);
|
|
3630
3662
|
t.end(JSON.stringify({ error: "inspect disabled (VOLTRO_INSPECT=off)" }));
|
|
@@ -3634,7 +3666,7 @@ import {
|
|
|
3634
3666
|
e.setEncoding("utf-8"), e.on("data", (e) => {
|
|
3635
3667
|
r += e;
|
|
3636
3668
|
}), e.on("end", () => {
|
|
3637
|
-
let e =
|
|
3669
|
+
let e = Cn(r, o);
|
|
3638
3670
|
t.statusCode = e.status, t.setHeader("content-type", e.contentType);
|
|
3639
3671
|
for (let [e, r] of Object.entries(n)) t.setHeader(e, r);
|
|
3640
3672
|
t.end(e.body);
|
|
@@ -3644,14 +3676,14 @@ import {
|
|
|
3644
3676
|
return;
|
|
3645
3677
|
}
|
|
3646
3678
|
if (c === "/_voltro/inspect/stream") {
|
|
3647
|
-
let n =
|
|
3648
|
-
if (
|
|
3679
|
+
let n = G(s.origin);
|
|
3680
|
+
if (H()) {
|
|
3649
3681
|
t.statusCode = 503, t.setHeader("content-type", "application/json");
|
|
3650
3682
|
for (let [e, r] of Object.entries(n)) t.setHeader(e, r);
|
|
3651
3683
|
t.end(JSON.stringify({ error: "inspect disabled (VOLTRO_INSPECT=off)" }));
|
|
3652
3684
|
return;
|
|
3653
3685
|
}
|
|
3654
|
-
let r =
|
|
3686
|
+
let r = U(s);
|
|
3655
3687
|
if (!r.ok) {
|
|
3656
3688
|
t.statusCode = 401, t.setHeader("content-type", "application/json");
|
|
3657
3689
|
for (let [e, r] of Object.entries(n)) t.setHeader(e, r);
|
|
@@ -3665,14 +3697,14 @@ import {
|
|
|
3665
3697
|
for (let [e, r] of Object.entries(n)) t.setHeader(e, r);
|
|
3666
3698
|
t.flushHeaders?.(), t.write("retry: 5000\n\n");
|
|
3667
3699
|
let a = i.indexOf("?");
|
|
3668
|
-
if (!(a !== -1 && new URLSearchParams(i.slice(a + 1)).get("live") === "1")) for (let e of o.buffered()) t.write(
|
|
3700
|
+
if (!(a !== -1 && new URLSearchParams(i.slice(a + 1)).get("live") === "1")) for (let e of o.buffered()) t.write(sn(e));
|
|
3669
3701
|
let c = o.subscribe((e) => {
|
|
3670
3702
|
try {
|
|
3671
|
-
t.write(
|
|
3703
|
+
t.write(sn(e));
|
|
3672
3704
|
} catch {}
|
|
3673
3705
|
}), l = setInterval(() => {
|
|
3674
3706
|
try {
|
|
3675
|
-
t.write(
|
|
3707
|
+
t.write(cn());
|
|
3676
3708
|
} catch {}
|
|
3677
3709
|
}, 15e3), u = () => {
|
|
3678
3710
|
clearInterval(l), c();
|
|
@@ -3681,11 +3713,11 @@ import {
|
|
|
3681
3713
|
return;
|
|
3682
3714
|
}
|
|
3683
3715
|
try {
|
|
3684
|
-
let o =
|
|
3716
|
+
let o = vt(i, {
|
|
3685
3717
|
kind: "web",
|
|
3686
3718
|
meta: {
|
|
3687
3719
|
name: n.name ?? "(unnamed)",
|
|
3688
|
-
voltroVersion:
|
|
3720
|
+
voltroVersion: ti,
|
|
3689
3721
|
port: u,
|
|
3690
3722
|
mode: "dev",
|
|
3691
3723
|
apis: Object.entries(n.apis ?? {}).map(([e, t]) => {
|
|
@@ -3703,7 +3735,7 @@ import {
|
|
|
3703
3735
|
size: 0,
|
|
3704
3736
|
entries: []
|
|
3705
3737
|
}),
|
|
3706
|
-
env: () =>
|
|
3738
|
+
env: () => tt(n.name ?? "app", { contract: oe(n.env) ? n.env : void 0 })
|
|
3707
3739
|
}, s, { method: e.method ?? "GET" });
|
|
3708
3740
|
if (o === null) return r();
|
|
3709
3741
|
t.statusCode = o.status, t.setHeader("content-type", o.contentType);
|
|
@@ -3714,26 +3746,26 @@ import {
|
|
|
3714
3746
|
}
|
|
3715
3747
|
});
|
|
3716
3748
|
}
|
|
3717
|
-
},
|
|
3749
|
+
}, le = n.name === "voltroDashboard" ? {
|
|
3718
3750
|
name: "framework:dashboard-registry",
|
|
3719
3751
|
configureServer(e) {
|
|
3720
3752
|
e.middlewares.use(async (e, t, n) => {
|
|
3721
3753
|
if (!(e.url ?? "").startsWith("/api/dashboard/registry")) return n();
|
|
3722
3754
|
try {
|
|
3723
|
-
let e = await
|
|
3755
|
+
let e = await pr();
|
|
3724
3756
|
t.statusCode = 200, t.setHeader("content-type", "application/json; charset=utf-8"), t.end(JSON.stringify(e));
|
|
3725
3757
|
} catch (e) {
|
|
3726
3758
|
t.statusCode = 500, t.setHeader("content-type", "text/plain"), t.end(`registry read error: ${e.message}`);
|
|
3727
3759
|
}
|
|
3728
3760
|
});
|
|
3729
3761
|
}
|
|
3730
|
-
} : null,
|
|
3731
|
-
limit:
|
|
3732
|
-
onColdStart: (e) =>
|
|
3733
|
-
onColdEnd: (e) =>
|
|
3762
|
+
} : null, ue = Si(m), de = /* @__PURE__ */ new Set(), I = Gt(), pe = qt({
|
|
3763
|
+
limit: I,
|
|
3764
|
+
onColdStart: (e) => Z.debug("ssr cold-compile start", { id: e }),
|
|
3765
|
+
onColdEnd: (e) => Z.debug("ssr cold-compile end", { id: e })
|
|
3734
3766
|
});
|
|
3735
|
-
|
|
3736
|
-
let
|
|
3767
|
+
Z.debug(`ssr cold-compile concurrency ${I}`, { concurrency: I });
|
|
3768
|
+
let he = null, ge = async () => (he === null && (he = await S.readFile(r(t, ".framework", "index.html"), "utf8")), he), _e = {
|
|
3737
3769
|
name: "framework:ssr",
|
|
3738
3770
|
configureServer(e) {
|
|
3739
3771
|
let n = (t) => pe.load(t, async () => await e.ssrLoadModule(t));
|
|
@@ -3741,10 +3773,10 @@ import {
|
|
|
3741
3773
|
if (i.method !== "GET" && i.method !== "HEAD") return o();
|
|
3742
3774
|
let c = i.url ?? "/", l = c.indexOf("?"), u = (l === -1 ? c : c.slice(0, l)) || "/";
|
|
3743
3775
|
if (u.startsWith("/@") || u.startsWith("/node_modules/") || u.startsWith("/.framework/") || u.startsWith("/_voltro/") || u === "/main.tsx" || u === "/index.html" || u === "/sw.js" || u === "/favicon.ico" || u === "/robots.txt" || /\.[a-z0-9]+$/i.test(u)) return o();
|
|
3744
|
-
let d = Ci(u,
|
|
3776
|
+
let d = Ci(u, ue);
|
|
3745
3777
|
if (!d) return o();
|
|
3746
|
-
let f = !
|
|
3747
|
-
f &&
|
|
3778
|
+
let f = !de.has(d.route.pattern), p = Date.now();
|
|
3779
|
+
f && Z.info(`ssr compiling ${d.route.pattern}`, {
|
|
3748
3780
|
pattern: d.route.pattern,
|
|
3749
3781
|
pathname: u
|
|
3750
3782
|
});
|
|
@@ -3763,11 +3795,11 @@ import {
|
|
|
3763
3795
|
}
|
|
3764
3796
|
};
|
|
3765
3797
|
try {
|
|
3766
|
-
let l = await g("loadPage", async () => await n(r(t, "src", "pages", d.route.file))), v =
|
|
3798
|
+
let l = await g("loadPage", async () => await n(r(t, "src", "pages", d.route.file))), v = $n(l, r("src", "pages", d.route.file)), y = _i(h, d.route.dirChain), b = v === "spa" && y.some((e) => e.hasLayout);
|
|
3767
3799
|
if (v !== "ssr" && v !== "isr" && !b) return o();
|
|
3768
3800
|
let x = {};
|
|
3769
3801
|
for (let [e, t] of Object.entries(i.headers ?? {})) typeof t == "string" ? x[e] = t : Array.isArray(t) && (x[e] = t.join(", "));
|
|
3770
|
-
let S =
|
|
3802
|
+
let S = Pi(Ni(s[0], { allowDevProxy: !0 }), x.cookie, { apiName: s[0]?.name }), C = new AbortController(), w = () => C.abort();
|
|
3771
3803
|
a.once("close", w);
|
|
3772
3804
|
let T = null, E = [], ee = {};
|
|
3773
3805
|
try {
|
|
@@ -3808,7 +3840,7 @@ import {
|
|
|
3808
3840
|
cookies: D.parseCookieHeader(x.cookie),
|
|
3809
3841
|
headers: x,
|
|
3810
3842
|
url: c
|
|
3811
|
-
}, k = l.interactive ?? "full", A = b ?
|
|
3843
|
+
}, k = l.interactive ?? "full", A = b ? Hr({
|
|
3812
3844
|
helpers: D,
|
|
3813
3845
|
page: `src/pages/${d.route.file}`,
|
|
3814
3846
|
interactive: k,
|
|
@@ -3820,7 +3852,7 @@ import {
|
|
|
3820
3852
|
segmentLoaderData: ee,
|
|
3821
3853
|
requestContext: O
|
|
3822
3854
|
}
|
|
3823
|
-
}) : null, j = b ? null :
|
|
3855
|
+
}) : null, j = b ? null : Vr({
|
|
3824
3856
|
helpers: D,
|
|
3825
3857
|
page: `src/pages/${d.route.file}`,
|
|
3826
3858
|
pathname: u,
|
|
@@ -3829,7 +3861,7 @@ import {
|
|
|
3829
3861
|
loaderData: T,
|
|
3830
3862
|
segmentLoaderData: ee,
|
|
3831
3863
|
pageLoaderRan: typeof l.loader == "function"
|
|
3832
|
-
}),
|
|
3864
|
+
}), ne = [];
|
|
3833
3865
|
await g("collectCss", async () => {
|
|
3834
3866
|
let e = /* @__PURE__ */ new Set(), n = [
|
|
3835
3867
|
r(t, "src", "pages", d.route.file),
|
|
@@ -3840,24 +3872,24 @@ import {
|
|
|
3840
3872
|
]),
|
|
3841
3873
|
r(t, ".framework", "main.tsx")
|
|
3842
3874
|
];
|
|
3843
|
-
for (let t of n) await _(t, e,
|
|
3875
|
+
for (let t of n) await _(t, e, ne);
|
|
3844
3876
|
});
|
|
3845
|
-
let
|
|
3877
|
+
let re = await g("readShell", ge), M = await g("transformShell", () => e.transformIndexHtml(c, re)), ie = ne.map((e) => `<link rel="stylesheet" href="${e}?direct" />`).join("\n "), N = O.cookies["voltro:locale"] ?? "en", ae = Date.now();
|
|
3846
3878
|
if (A) {
|
|
3847
|
-
let e = (e) =>
|
|
3879
|
+
let e = (e) => Wr({
|
|
3848
3880
|
helpers: D,
|
|
3849
3881
|
prepared: A,
|
|
3850
3882
|
meta: e,
|
|
3851
3883
|
interactive: k,
|
|
3852
|
-
extra: [
|
|
3884
|
+
extra: [ie]
|
|
3853
3885
|
});
|
|
3854
|
-
if (A.hasDeferred)
|
|
3886
|
+
if (A.hasDeferred) $r({
|
|
3855
3887
|
res: a,
|
|
3856
|
-
shell:
|
|
3857
|
-
shell:
|
|
3888
|
+
shell: Zr({
|
|
3889
|
+
shell: M,
|
|
3858
3890
|
inlineModuleScriptsAsync: !0
|
|
3859
3891
|
}),
|
|
3860
|
-
htmlLang:
|
|
3892
|
+
htmlLang: N,
|
|
3861
3893
|
headers: {
|
|
3862
3894
|
"content-type": "text/html; charset=utf-8",
|
|
3863
3895
|
"x-voltro-rendered-by": "spa-shell-dev"
|
|
@@ -3868,22 +3900,22 @@ import {
|
|
|
3868
3900
|
...e
|
|
3869
3901
|
}),
|
|
3870
3902
|
onShellError: (e) => {
|
|
3871
|
-
|
|
3903
|
+
Z.warn("spa-shell-dev shell render failed; falling back to SPA shell", {
|
|
3872
3904
|
pathname: u,
|
|
3873
3905
|
pattern: d.route.pattern
|
|
3874
3906
|
}, e), o();
|
|
3875
3907
|
}
|
|
3876
3908
|
});
|
|
3877
3909
|
else {
|
|
3878
|
-
let t =
|
|
3910
|
+
let t = Ur({
|
|
3879
3911
|
helpers: D,
|
|
3880
3912
|
prepared: A
|
|
3881
|
-
}), n =
|
|
3913
|
+
}), n = M.replace("<div id=\"root\"></div>", `<div id="root">${t.body}</div>`).replace("</head>", ` ${e(t.meta)}\n </head>`).replace(/<html(\s+lang="[^"]*")?/i, `<html lang="${N}"`);
|
|
3882
3914
|
a.statusCode = 200, a.setHeader("content-type", "text/html; charset=utf-8"), a.setHeader("x-voltro-rendered-by", "spa-shell-dev"), a.end(n);
|
|
3883
3915
|
}
|
|
3884
3916
|
} else if (j) {
|
|
3885
3917
|
let e = (e) => [
|
|
3886
|
-
|
|
3918
|
+
ie,
|
|
3887
3919
|
D.renderMetaToHtml(e),
|
|
3888
3920
|
`<meta name="voltro-interactive" content="${k}" />`,
|
|
3889
3921
|
...j.hasDeferred ? [D.renderDeferredRegistryScript()] : [],
|
|
@@ -3896,13 +3928,13 @@ import {
|
|
|
3896
3928
|
segmentLoaderData: j.segmentLoaderData,
|
|
3897
3929
|
requestContext: O
|
|
3898
3930
|
};
|
|
3899
|
-
if (v === "ssr" && k === "full")
|
|
3931
|
+
if (v === "ssr" && k === "full") $r({
|
|
3900
3932
|
res: a,
|
|
3901
|
-
shell:
|
|
3902
|
-
shell:
|
|
3933
|
+
shell: Zr({
|
|
3934
|
+
shell: M,
|
|
3903
3935
|
inlineModuleScriptsAsync: !0
|
|
3904
3936
|
}),
|
|
3905
|
-
htmlLang:
|
|
3937
|
+
htmlLang: N,
|
|
3906
3938
|
headers: {
|
|
3907
3939
|
"content-type": "text/html; charset=utf-8",
|
|
3908
3940
|
"x-voltro-rendered-by": "ssr-dev"
|
|
@@ -3913,48 +3945,48 @@ import {
|
|
|
3913
3945
|
...e
|
|
3914
3946
|
}),
|
|
3915
3947
|
onShellError: (e) => {
|
|
3916
|
-
|
|
3948
|
+
Z.warn("ssr-dev shell render failed; falling back to SPA shell", {
|
|
3917
3949
|
pathname: u,
|
|
3918
3950
|
pattern: d.route.pattern
|
|
3919
3951
|
}, e), o();
|
|
3920
3952
|
}
|
|
3921
3953
|
});
|
|
3922
3954
|
else {
|
|
3923
|
-
let { html: n, meta: r } = D.renderPageToHtml(t), i =
|
|
3955
|
+
let { html: n, meta: r } = D.renderPageToHtml(t), i = M.replace("<div id=\"root\"></div>", `<div id="root">${n}</div>`).replace("</head>", ` ${e(r)}\n </head>`).replace(/<html(\s+lang="[^"]*")?/i, `<html lang="${N}"`);
|
|
3924
3956
|
a.statusCode = 200, a.setHeader("content-type", "text/html; charset=utf-8"), a.setHeader("x-voltro-rendered-by", "ssr-dev"), a.end(i);
|
|
3925
3957
|
}
|
|
3926
3958
|
}
|
|
3927
|
-
m.render = Date.now() -
|
|
3928
|
-
let
|
|
3929
|
-
f ? (
|
|
3959
|
+
m.render = Date.now() - ae;
|
|
3960
|
+
let P = Date.now() - p;
|
|
3961
|
+
f ? (de.add(d.route.pattern), Z.info(`ssr compiled ${d.route.pattern} in ${P}ms`, {
|
|
3930
3962
|
pattern: d.route.pattern,
|
|
3931
3963
|
pathname: u,
|
|
3932
|
-
elapsedMs:
|
|
3964
|
+
elapsedMs: P,
|
|
3933
3965
|
cold: !0,
|
|
3934
3966
|
phases: m
|
|
3935
|
-
})) :
|
|
3967
|
+
})) : P > 200 && Z.info(`ssr rendered ${u} in ${P}ms`, {
|
|
3936
3968
|
pattern: d.route.pattern,
|
|
3937
3969
|
pathname: u,
|
|
3938
|
-
elapsedMs:
|
|
3970
|
+
elapsedMs: P,
|
|
3939
3971
|
cold: !1,
|
|
3940
3972
|
phases: m
|
|
3941
3973
|
});
|
|
3942
3974
|
} catch (e) {
|
|
3943
|
-
if (
|
|
3944
|
-
|
|
3975
|
+
if (Br(e)) {
|
|
3976
|
+
Z.error("ssr-dev render refused", {
|
|
3945
3977
|
pathname: u,
|
|
3946
3978
|
pattern: d.route.pattern
|
|
3947
3979
|
}, e), a.statusCode = 500, a.setHeader("content-type", "text/plain; charset=utf-8"), a.end(e.message);
|
|
3948
3980
|
return;
|
|
3949
3981
|
}
|
|
3950
|
-
|
|
3982
|
+
Z.warn("ssr-dev render failed; falling back to SPA shell", {
|
|
3951
3983
|
pathname: u,
|
|
3952
3984
|
pattern: d.route.pattern
|
|
3953
3985
|
}, e), o();
|
|
3954
3986
|
}
|
|
3955
3987
|
});
|
|
3956
3988
|
}
|
|
3957
|
-
},
|
|
3989
|
+
}, L = Date.now(), ve = b.version ?? "?", ye = await ni(), be = r(t, "node_modules", "@voltro", "ui-shadcn"), R = y(r(be, "package.json")) ? be : null, xe = [], Se = await (async () => {
|
|
3958
3990
|
let e = [];
|
|
3959
3991
|
for (let n of s) {
|
|
3960
3992
|
if (!n.proxyTarget) continue;
|
|
@@ -3964,7 +3996,7 @@ import {
|
|
|
3964
3996
|
} catch {}
|
|
3965
3997
|
}
|
|
3966
3998
|
if (e.length === 0) return !1;
|
|
3967
|
-
let n =
|
|
3999
|
+
let n = fe("sha1").update(e.join("\0")).digest("hex"), i = r(w, ".voltro-rpcgroup-optimize"), a = "";
|
|
3968
4000
|
try {
|
|
3969
4001
|
a = (await S.readFile(i, "utf8")).trim();
|
|
3970
4002
|
} catch {}
|
|
@@ -3974,83 +4006,83 @@ import {
|
|
|
3974
4006
|
} catch {}
|
|
3975
4007
|
return !0;
|
|
3976
4008
|
})();
|
|
3977
|
-
|
|
4009
|
+
Se && Z.info("rpcGroup changed since last boot — forcing a dep re-optimize so the browser loads the current api client"), await (await b.createServer({
|
|
3978
4010
|
root: w,
|
|
3979
4011
|
envPrefix: "__VOLTRO_VITE_ENV_DISABLED__",
|
|
3980
4012
|
ssr: { noExternal: ["react-intl"] },
|
|
3981
4013
|
resolve: {
|
|
3982
4014
|
dedupe: ["react", "react-dom"],
|
|
3983
4015
|
alias: [
|
|
3984
|
-
...
|
|
4016
|
+
...ye ? [{
|
|
3985
4017
|
find: "@voltro/devtools/styles.css",
|
|
3986
|
-
replacement: r(
|
|
4018
|
+
replacement: r(ye, "src/styles.css")
|
|
3987
4019
|
}, {
|
|
3988
4020
|
find: "@voltro/devtools",
|
|
3989
|
-
replacement: r(
|
|
4021
|
+
replacement: r(ye, "src/index.ts")
|
|
3990
4022
|
}] : [],
|
|
3991
|
-
...
|
|
4023
|
+
...R ? [
|
|
3992
4024
|
{
|
|
3993
4025
|
find: "@voltro/ui-shadcn/tokens.css",
|
|
3994
|
-
replacement: r(
|
|
4026
|
+
replacement: r(R, "src/tokens.css")
|
|
3995
4027
|
},
|
|
3996
4028
|
{
|
|
3997
4029
|
find: "@voltro/ui-shadcn/cn",
|
|
3998
|
-
replacement: r(
|
|
4030
|
+
replacement: r(R, "src/cn.ts")
|
|
3999
4031
|
},
|
|
4000
4032
|
{
|
|
4001
4033
|
find: "@voltro/ui-shadcn/brand",
|
|
4002
|
-
replacement: r(
|
|
4034
|
+
replacement: r(R, "src/brand/voltroLogo.tsx")
|
|
4003
4035
|
},
|
|
4004
4036
|
{
|
|
4005
4037
|
find: "@voltro/ui-shadcn",
|
|
4006
|
-
replacement: r(
|
|
4038
|
+
replacement: r(R, "src/index.ts")
|
|
4007
4039
|
}
|
|
4008
4040
|
] : [],
|
|
4009
|
-
...
|
|
4041
|
+
...We(t)
|
|
4010
4042
|
]
|
|
4011
4043
|
},
|
|
4012
4044
|
optimizeDeps: {
|
|
4013
|
-
include: [...s.map((e) => `${e.pkg}/rpcGroup`), ...
|
|
4014
|
-
force:
|
|
4045
|
+
include: [...s.map((e) => `${e.pkg}/rpcGroup`), ...xe],
|
|
4046
|
+
force: Se
|
|
4015
4047
|
},
|
|
4016
|
-
customLogger:
|
|
4048
|
+
customLogger: Wt(),
|
|
4017
4049
|
plugins: [
|
|
4018
|
-
|
|
4050
|
+
qn(r(t, "src", "pages")),
|
|
4019
4051
|
x(),
|
|
4020
4052
|
C(),
|
|
4021
4053
|
ee,
|
|
4022
4054
|
A,
|
|
4055
|
+
N,
|
|
4023
4056
|
P,
|
|
4024
|
-
F,
|
|
4025
|
-
ae,
|
|
4026
4057
|
se,
|
|
4027
|
-
|
|
4028
|
-
|
|
4058
|
+
ce,
|
|
4059
|
+
_e,
|
|
4060
|
+
...le ? [le] : []
|
|
4029
4061
|
],
|
|
4030
4062
|
server: {
|
|
4031
4063
|
port: u,
|
|
4032
4064
|
strictPort: !0,
|
|
4033
4065
|
host: !0,
|
|
4034
4066
|
allowedHosts: n.allowedHosts === !0 || [...n.allowedHosts ?? []],
|
|
4035
|
-
proxy:
|
|
4036
|
-
fs: { allow: [t, ...
|
|
4067
|
+
proxy: F,
|
|
4068
|
+
fs: { allow: [t, ...ci(t)] }
|
|
4037
4069
|
},
|
|
4038
4070
|
appType: "spa",
|
|
4039
4071
|
cacheDir: r(w, ".vite"),
|
|
4040
4072
|
publicDir: r(t, "public")
|
|
4041
|
-
})).listen(),
|
|
4042
|
-
version:
|
|
4043
|
-
bootMs: Date.now() -
|
|
4044
|
-
}),
|
|
4073
|
+
})).listen(), ei.info(`v${ve} ready in ${Date.now() - L}ms`, {
|
|
4074
|
+
version: ve,
|
|
4075
|
+
bootMs: Date.now() - L
|
|
4076
|
+
}), Z.info(`listening on http://localhost:${u}`, {
|
|
4045
4077
|
port: u,
|
|
4046
4078
|
app: n.name ?? "(unnamed)"
|
|
4047
4079
|
});
|
|
4048
|
-
for (let e of s) e.proxyTarget && (
|
|
4080
|
+
for (let e of s) e.proxyTarget && (Z.info(`proxy /ws/${e.name} → ${e.proxyTarget}`, {
|
|
4049
4081
|
api: e.name,
|
|
4050
4082
|
target: e.proxyTarget
|
|
4051
|
-
}),
|
|
4083
|
+
}), Z.info(`proxy /_voltro/api/${e.name} → ${e.proxyTarget.replace(/^ws/, "http")}/_voltro/inspect`, { api: e.name }));
|
|
4052
4084
|
try {
|
|
4053
|
-
await
|
|
4085
|
+
await mr({
|
|
4054
4086
|
id: f,
|
|
4055
4087
|
name: d,
|
|
4056
4088
|
kind: "web",
|
|
@@ -4059,13 +4091,13 @@ import {
|
|
|
4059
4091
|
status: "live",
|
|
4060
4092
|
logFile: p.path
|
|
4061
4093
|
});
|
|
4062
|
-
let e =
|
|
4094
|
+
let e = Or(t);
|
|
4063
4095
|
if (e) {
|
|
4064
|
-
let t = await
|
|
4065
|
-
t.status === "launched" ?
|
|
4096
|
+
let t = await Rr({ dashboardAppPath: e });
|
|
4097
|
+
t.status === "launched" ? Z.info(`dashboard launched at http://localhost:${t.port}`, { port: t.port }) : t.status === "already-running" && Z.debug(`dashboard already running on :${t.port}`, { port: t.port });
|
|
4066
4098
|
}
|
|
4067
4099
|
setInterval(() => {
|
|
4068
|
-
|
|
4100
|
+
mr({
|
|
4069
4101
|
id: f,
|
|
4070
4102
|
name: d,
|
|
4071
4103
|
kind: "web",
|
|
@@ -4076,50 +4108,50 @@ import {
|
|
|
4076
4108
|
}).catch(() => {});
|
|
4077
4109
|
}, 1e4).unref();
|
|
4078
4110
|
let n = () => {
|
|
4079
|
-
|
|
4111
|
+
hr(f), p.dispose();
|
|
4080
4112
|
};
|
|
4081
4113
|
process.on("SIGINT", n), process.on("SIGTERM", n);
|
|
4082
4114
|
} catch (e) {
|
|
4083
|
-
|
|
4115
|
+
Z.warn("runtime-registry write failed", {}, e);
|
|
4084
4116
|
}
|
|
4085
4117
|
return _({
|
|
4086
4118
|
app: n.name ?? "unnamed",
|
|
4087
4119
|
kind: "web",
|
|
4088
4120
|
url: `http://localhost:${u}`,
|
|
4089
|
-
bootMs: Date.now() -
|
|
4121
|
+
bootMs: Date.now() - L
|
|
4090
4122
|
}), new Promise(() => {});
|
|
4091
|
-
},
|
|
4123
|
+
}, Bi = async (e) => {
|
|
4092
4124
|
process.env.NODE_ENV || (process.env.NODE_ENV = "production");
|
|
4093
|
-
let t = await
|
|
4125
|
+
let t = await Ri(e);
|
|
4094
4126
|
if (!t) return {
|
|
4095
4127
|
ran: !1,
|
|
4096
4128
|
exitCode: 0
|
|
4097
4129
|
};
|
|
4098
|
-
let n = Date.now(), i =
|
|
4130
|
+
let n = Date.now(), i = Z.child("serve");
|
|
4099
4131
|
i.info("booting voltro serve (preview)", { app: t.name ?? "(unnamed)" });
|
|
4100
4132
|
let a = await ki(e, t);
|
|
4101
4133
|
for (let e of a) i.info("api wired", {
|
|
4102
4134
|
name: e.name,
|
|
4103
4135
|
pkg: e.pkg
|
|
4104
4136
|
});
|
|
4105
|
-
await
|
|
4137
|
+
await Fi(e, t, a);
|
|
4106
4138
|
{
|
|
4107
|
-
let { pages: t } = await
|
|
4108
|
-
await
|
|
4139
|
+
let { pages: t } = await $(r(e, "src", "pages"));
|
|
4140
|
+
await rn({
|
|
4109
4141
|
appRoot: e,
|
|
4110
4142
|
pages: t
|
|
4111
4143
|
});
|
|
4112
4144
|
}
|
|
4113
|
-
let o = t.port ?? 5173, s = await
|
|
4114
|
-
|
|
4145
|
+
let o = t.port ?? 5173, s = await Ke("vite", () => import("vite")), c = (await import("@vitejs/plugin-react")).default, l = r(e, ".framework");
|
|
4146
|
+
Z.info("running production build"), await s.build({
|
|
4115
4147
|
root: l,
|
|
4116
4148
|
envPrefix: "__VOLTRO_VITE_ENV_DISABLED__",
|
|
4117
4149
|
plugins: [c()],
|
|
4118
|
-
customLogger:
|
|
4150
|
+
customLogger: Wt(),
|
|
4119
4151
|
resolve: { dedupe: ["react", "react-dom"] },
|
|
4120
4152
|
build: {
|
|
4121
4153
|
outDir: "dist",
|
|
4122
|
-
rollupOptions: { output: { manualChunks:
|
|
4154
|
+
rollupOptions: { output: { manualChunks: di } }
|
|
4123
4155
|
},
|
|
4124
4156
|
publicDir: r(e, "public")
|
|
4125
4157
|
});
|
|
@@ -4139,14 +4171,14 @@ import {
|
|
|
4139
4171
|
extras: f,
|
|
4140
4172
|
bootMs: Date.now() - n
|
|
4141
4173
|
}), new Promise(() => {});
|
|
4142
|
-
},
|
|
4174
|
+
}, Vi = 5e3, Hi = 6e4, Ui = (e, t) => {
|
|
4143
4175
|
if (e.length === 0) return 0;
|
|
4144
4176
|
if (e.length === 1) return e[0];
|
|
4145
4177
|
let n = t * (e.length - 1), r = Math.floor(n), i = Math.ceil(n);
|
|
4146
4178
|
if (r === i) return e[r];
|
|
4147
4179
|
let a = n - r;
|
|
4148
4180
|
return e[r] * (1 - a) + e[i] * a;
|
|
4149
|
-
},
|
|
4181
|
+
}, Wi = (e) => {
|
|
4150
4182
|
if (e.length === 0) return {
|
|
4151
4183
|
p50: 0,
|
|
4152
4184
|
p95: 0,
|
|
@@ -4158,15 +4190,15 @@ import {
|
|
|
4158
4190
|
let t = e.slice().sort((e, t) => e - t), n = 0;
|
|
4159
4191
|
for (let e of t) n += e;
|
|
4160
4192
|
return {
|
|
4161
|
-
p50:
|
|
4162
|
-
p95:
|
|
4163
|
-
p99:
|
|
4193
|
+
p50: Ui(t, .5),
|
|
4194
|
+
p95: Ui(t, .95),
|
|
4195
|
+
p99: Ui(t, .99),
|
|
4164
4196
|
mean: n / t.length,
|
|
4165
4197
|
min: t[0],
|
|
4166
4198
|
max: t[t.length - 1]
|
|
4167
4199
|
};
|
|
4168
|
-
},
|
|
4169
|
-
let t = e.maxSamples ??
|
|
4200
|
+
}, Gi = (e = {}) => {
|
|
4201
|
+
let t = e.maxSamples ?? Vi, n = e.defaultWindowMs ?? Hi, r = [];
|
|
4170
4202
|
return {
|
|
4171
4203
|
record(e) {
|
|
4172
4204
|
A(e), r.push({
|
|
@@ -4195,7 +4227,7 @@ import {
|
|
|
4195
4227
|
tag: e.tag,
|
|
4196
4228
|
count: e.samples.length,
|
|
4197
4229
|
errorCount: n,
|
|
4198
|
-
latencyMs:
|
|
4230
|
+
latencyMs: Wi(t)
|
|
4199
4231
|
});
|
|
4200
4232
|
}
|
|
4201
4233
|
return c.sort((e, t) => t.count - e.count), {
|
|
@@ -4208,4 +4240,4 @@ import {
|
|
|
4208
4240
|
};
|
|
4209
4241
|
};
|
|
4210
4242
|
//#endregion
|
|
4211
|
-
export {
|
|
4243
|
+
export { Pt as $, hr as A, Ze as At, Cn as B, Rr as C, ot as Ct, wr as D, tt as Dt, Cr as E, it as Et, Zn as F, He as Ft, cn as G, mn as H, $n as I, ye as It, Gt as J, rn as K, Pn as L, be as Lt, Jn as M, Ke as Mt, er as N, We as Nt, gr as O, nt as Ot, Yn as P, Ve as Pt, Dt as Q, kn as R, Dr as S, at as St, Sr as T, rt as Tt, sn as U, gn as V, on as W, _t as X, V as Y, U as Z, Vr as _, H as _t, vi as a, vt as at, Wr as b, ut as bt, ki as c, Nt as ct, di as d, jt as dt, St as et, $ as f, kt as ft, Br as g, G as gt, $r as h, Tt as ht, Pi as i, Ct as it, mr as j, Xe as jt, pr as k, $e as kt, zi as l, Mt as lt, Zr as m, wt as mt, fi as n, xt as nt, _i as o, Et as ot, Fi as p, Ot as pt, qt as q, Ni as r, yt as rt, Ri as s, bt as st, Gi as t, Ft as tt, Bi as u, At as ut, Hr as v, pt as vt, Or as w, st as wt, kr as x, lt as xt, Ur as y, ft as yt, Tn as z };
|