@voltro/cli 0.55.0 → 0.57.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +691 -0
- package/bin/voltro.mjs +24 -0
- package/dist/apiBuild-B83Cb2Rv.js +2 -0
- package/dist/{apiBuild-CMvLJM_K.js → apiBuild-DDr2aNFd.js} +119 -88
- package/dist/bin.js +1 -1
- package/dist/{build-S0QOzqPT.js → build-QKP6Bm0J.js} +308 -279
- package/dist/buildReport-52gHKgfO.js +64 -0
- package/dist/{checkCommand-DNkY5kwF.js → checkCommand-BISqx1OJ.js} +1 -1
- package/dist/{checkCommand-fbj9GDjN.js → checkCommand-DUtMWjcR.js} +6 -6
- package/dist/{clusterCmd-DrVFCzSj.js → clusterCmd-CdLB1GkT.js} +1 -1
- package/dist/{codegen-SIepQtUl.js → codegen-Bth5lUTU.js} +2 -1
- package/dist/codegen-DbH7NbCR.js +2 -0
- package/dist/{codegenCommand-3TDJezom.js → codegenCommand-DnVuDxwT.js} +11 -11
- package/dist/{codemodRunner-C2zxZUIw.js → codemodRunner-BlQPfjzA.js} +222 -0
- package/dist/{commands-BBYJ7Q3B.js → commands-CRbxgxv0.js} +35 -35
- package/dist/{dashboardCommand-D2kmyCLL.js → dashboardCommand-Bf_-Ne3P.js} +5 -5
- package/dist/{dataCommand-BEPPQiTl.js → dataCommand-BoBJJ-Gb.js} +3 -3
- package/dist/{dbCommand-DZTmOFT4.js → dbCommand-CMAIz-Bf.js} +457 -441
- package/dist/dbCommand-DHi_RuDl.js +2 -0
- package/dist/dev-Bl9HqtV7.js +3 -0
- package/dist/{dev-Ca_A_S9v.js → dev-DOEJXicj.js} +2623 -2485
- package/dist/{doctorCommand-CGZJK_4o.js → doctorCommand-BrWu67JZ.js} +524 -280
- package/dist/doctorCommand-DrQv9SL3.js +2 -0
- package/dist/{dormancyCommand-DY2rYpTa.js → dormancyCommand-xn2y-pJm.js} +1 -1
- package/dist/{embeddingsCommand-BoCqZsgp.js → embeddingsCommand-Cn5MbRDM.js} +1 -1
- package/dist/emptyResultHeadline-Csa5fZOF.js +18 -0
- package/dist/{envCommand-Bxy2fOjc.js → envCommand-UJmJIbs9.js} +8 -8
- package/dist/{evolveCommand-BsbZ-XDg.js → evolveCommand-Db30twUy.js} +2 -2
- package/dist/frameworkTableAssembly-B96WCNJA.js +2 -0
- package/dist/{frameworkTableAssembly-Do-cf6RJ.js → frameworkTableAssembly-vfkzuzEo.js} +131 -104
- package/dist/index.js +1 -1
- package/dist/{infoCommand-EmM3jPKD.js → infoCommand-BjVXpMlP.js} +1 -1
- package/dist/inspect-B0hL41s0.js +2 -0
- package/dist/inspect-DZnan87F.js +1500 -0
- package/dist/{inspectCmd-niF97fAq.js → inspectCmd-CP-G0sVK.js} +1 -1
- package/dist/{inspectFetch-EMuhTG_9.js → inspectFetch-BU1NyzxV.js} +36 -24
- package/dist/{inspectMetrics-CGF94puw.js → inspectMetrics-BY0Sjb2F.js} +19 -19
- package/dist/{logsCmd-B6oNsfaZ.js → logsCmd-C5y9HyrG.js} +59 -54
- package/dist/{manifestBuild-DjX5MoXy.js → manifestBuild-DnbFKF6w.js} +1 -1
- package/dist/manifestBuild-UXrnUcXP.js +2 -0
- package/dist/{migrate-CGFZS-1a.js → migrate-DtC3lu7H.js} +4 -4
- package/dist/precompressAssets-YhTi1aWp.js +40 -0
- package/dist/{probeCommand-Bs3iVBSL.js → probeCommand-C5fuN6Z2.js} +2 -2
- package/dist/{runtimeTrace-C1BTpHGQ.js → runtimeTrace-BQL_lfz6.js} +1 -1
- package/dist/{scheduleCmd-DQRu6BZC.js → scheduleCmd-DYBUfo_T.js} +1 -1
- package/dist/{sdkgen-CXMwLg9n.js → sdkgen-CMUPrDjH.js} +1 -1
- package/dist/{seedRunner-Dgsiwk_e.js → seedRunner-DISBKow-.js} +16 -16
- package/dist/serveCommand-B_w-Mpb_.js +2544 -0
- package/dist/serveCommand-Dtb48ffg.js +2 -0
- package/dist/serveEntry.js +1 -1
- package/dist/{start-EOV7s1NZ.js → start-YaUehtDV.js} +580 -558
- package/dist/{start-DH7cat4-.js → start-s25GAIgn.js} +1 -1
- package/dist/startEntry.js +1 -1
- package/dist/staticCachePolicy-CIyj6DbS.js +15 -0
- package/dist/{test-DO27-x2P.js → test-jipIQ5Mx.js} +1 -1
- package/dist/{tracesCmd-DgtgOUdi.js → tracesCmd-C1qKa94g.js} +69 -64
- package/dist/{updateCommand-C_jN1w18.js → updateCommand-C9n_Z_oG.js} +8 -2
- package/dist/updateCommand-DsXEAHbd.js +2 -0
- package/dist/webDev-B6ZMX42w.js +2 -0
- package/dist/{webDev-B7vNj4Bq.js → webDev-BgdkyjP6.js} +1379 -1303
- package/dist/{webhooksCommand-B1LVcyO3.js → webhooksCommand-CYXTNvXq.js} +2 -2
- package/dist/{workflowsCmd-BGF-mRZ5.js → workflowsCmd-g-DNpaUc.js} +1 -1
- package/package.json +55 -19
- package/templates/AGENTS.core.md +20 -1
- package/templates/AGENTS.md +21 -2
- package/templates/agent-docs/_index.md +1 -1
- package/templates/agent-docs/_manifest.json +2 -2
- package/templates/agent-docs/ai.md +1 -1
- package/templates/agent-docs/authentication.md +34 -19
- package/templates/agent-docs/cli.md +170 -0
- package/templates/agent-docs/configuration.md +29 -4
- package/templates/agent-docs/data.md +145 -5
- package/templates/agent-docs/database/scaling.md +50 -2
- package/templates/agent-docs/deployment.md +75 -1
- package/templates/agent-docs/internationalization.md +32 -0
- package/templates/agent-docs/local-first-mobile.md +9 -2
- package/templates/agent-docs/observability.md +227 -0
- package/templates/agent-docs/plugins/audit.md +21 -5
- package/templates/agent-docs/plugins/billing.md +17 -0
- package/templates/agent-docs/plugins/broadcast.md +2 -1
- package/templates/agent-docs/plugins/ratelimit.md +6 -1
- package/templates/agent-docs/plugins/row-history.md +11 -0
- package/templates/agent-docs/plugins.md +19 -0
- package/templates/agent-docs/reference.md +1 -0
- package/templates/agent-docs/scheduling.md +23 -0
- package/templates/agent-docs/schema-driven-ui.md +81 -0
- package/templates/agent-docs/templates/appshells.md +3 -3
- package/templates/agent-docs/whats-new.md +133 -77
- package/templates/apps/api-ai/package.json +6 -6
- package/templates/apps/api-auth/package.json +8 -8
- package/templates/apps/api-backend/package.json +7 -7
- package/templates/apps/api-backend-deactivation/package.json +7 -7
- package/templates/apps/api-backend-mail/package.json +8 -8
- package/templates/apps/api-backend-mariadb/package.json +9 -9
- package/templates/apps/api-backend-sqlite/package.json +8 -8
- package/templates/apps/api-backend-storage/package.json +8 -8
- package/templates/apps/api-cms/package.json +9 -9
- package/templates/apps/api-collab/package.json +8 -8
- package/templates/apps/api-data-advanced/package.json +8 -8
- package/templates/apps/api-durable/package.json +8 -8
- package/templates/apps/api-feature-flags/package.json +9 -9
- package/templates/apps/api-governance/package.json +8 -8
- package/templates/apps/api-kv/package.json +8 -8
- package/templates/apps/api-moderation/package.json +8 -8
- package/templates/apps/api-observability/package.json +8 -8
- package/templates/apps/api-ratelimit/package.json +8 -8
- package/templates/apps/api-rbac/package.json +8 -8
- package/templates/apps/api-rest/package.json +7 -7
- package/templates/apps/api-row-history/package.json +8 -8
- package/templates/apps/api-saas/package.json +11 -11
- package/templates/apps/api-saas-starter/package.json +10 -10
- package/templates/apps/api-search/package.json +8 -8
- package/templates/apps/api-status/package.json +8 -8
- package/templates/apps/api-webhooks/package.json +9 -9
- package/templates/apps/changelog/package.json +7 -7
- package/templates/apps/changelog/src/pages/[locale]/page.tsx +7 -1
- package/templates/apps/edge-functions/package.json +2 -2
- package/templates/apps/frontend-admin/package.json +7 -8
- package/templates/apps/frontend-admin/src/pages/(marketing)/layout.tsx +1 -2
- package/templates/apps/frontend-admin/src/pages/admin/layout.tsx +1 -2
- package/templates/apps/frontend-app/package.json +8 -9
- package/templates/apps/frontend-app/src/pages/layout.tsx +1 -2
- package/templates/apps/frontend-auth/package.json +7 -8
- package/templates/apps/frontend-auth/src/components/AuthShell.tsx +1 -2
- package/templates/apps/frontend-blank/package.json +6 -7
- package/templates/apps/frontend-blank/src/pages/layout.tsx +1 -2
- package/templates/apps/frontend-cms/package.json +8 -9
- package/templates/apps/frontend-cms/src/pages/(app)/layout.tsx +1 -2
- package/templates/apps/frontend-collab/README.md +7 -2
- package/templates/apps/frontend-collab/package.json +9 -10
- package/templates/apps/frontend-collab/src/pages/layout.tsx +1 -2
- package/templates/apps/frontend-collab/src/pages/page.test.tsx +8 -4
- package/templates/apps/frontend-collab/src/pages/page.tsx +10 -5
- package/templates/apps/frontend-contact/package.json +7 -7
- package/templates/apps/frontend-contact/src/components/ContactForm.island.tsx +1 -1
- package/templates/apps/frontend-dashboard/package.json +6 -7
- package/templates/apps/frontend-dashboard/src/pages/(marketing)/layout.tsx +1 -2
- package/templates/apps/frontend-dashboard/src/pages/dashboard/layout.tsx +1 -2
- package/templates/apps/frontend-docs/package.json +8 -8
- package/templates/apps/frontend-i18n/package.json +6 -6
- package/templates/apps/frontend-landing/package.json +7 -7
- package/templates/apps/frontend-portal/package.json +7 -8
- package/templates/apps/frontend-portal/src/pages/(portal)/layout.tsx +1 -2
- package/templates/apps/frontend-saas/package.json +7 -8
- package/templates/apps/frontend-saas/src/pages/(marketing)/layout.tsx +1 -2
- package/templates/apps/frontend-saas/src/pages/dashboard/layout.tsx +1 -2
- package/templates/apps/frontend-spa/package.json +6 -7
- package/templates/apps/frontend-spa/src/pages/layout.tsx +1 -2
- package/templates/apps/frontend-ssr/package.json +6 -7
- package/templates/apps/frontend-ssr/src/pages/layout.tsx +1 -2
- package/templates/apps/frontend-ssr-api/package.json +7 -8
- package/templates/apps/frontend-ssr-api/src/pages/layout.tsx +1 -2
- package/templates/apps/frontend-static-blog/package.json +8 -8
- package/templates/apps/frontend-static-blog/src/components/ReadingProgress.island.tsx +1 -1
- package/templates/apps/frontend-static-blog/src/pages/[locale]/page.tsx +7 -1
- package/templates/apps/frontend-status/package.json +7 -8
- package/templates/apps/frontend-status/src/pages/layout.tsx +1 -2
- package/templates/apps/mobile-app/package.json +4 -4
- package/templates/baselines/compose/docker/api.Dockerfile +61 -5
- package/templates/baselines/compose/docker/web.Dockerfile +55 -10
- package/templates/baselines/compose-mariadb/docker/api.Dockerfile +61 -5
- package/templates/baselines/compose-mariadb/docker/web.Dockerfile +55 -10
- package/dist/apiBuild-Cl0IDx8c.js +0 -2
- package/dist/codegen-CN6vMM4J.js +0 -2
- package/dist/dbCommand-BTyBGhIA.js +0 -2
- package/dist/dev-DfVZaoys.js +0 -3
- package/dist/doctorCommand-djmqEcDC.js +0 -2
- package/dist/frameworkTableAssembly-Df2Ymp2f.js +0 -2
- package/dist/inspect-DCqILJ1G.js +0 -1197
- package/dist/inspect-DGJwpOAb.js +0 -2
- package/dist/manifestBuild-CJ2zvPvT.js +0 -2
- package/dist/serveCommand-C7IrCD58.js +0 -2445
- package/dist/serveCommand-Cjt5S9hD.js +0 -2
- package/dist/updateCommand-nnFjDbl4.js +0 -2
- package/dist/webDev-1XpVnYkW.js +0 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as e } from "./cliOutput-D1tSBoRM.js";
|
|
2
|
-
import { n as t, o as n, r, t as i } from "./inspectFetch-
|
|
2
|
+
import { n as t, o as n, r, t as i } from "./inspectFetch-BU1NyzxV.js";
|
|
3
3
|
import { ansi as a } from "@voltro/logger";
|
|
4
4
|
//#region src/inspectCmd.ts
|
|
5
5
|
var o = {
|
|
@@ -1,43 +1,55 @@
|
|
|
1
1
|
import { n as e } from "./runtimeRegistry-DMeKfTHP.js";
|
|
2
2
|
//#region src/inspectFetch.ts
|
|
3
|
-
var t = (e
|
|
3
|
+
var t = (e) => {
|
|
4
|
+
if (typeof e != "object" || !e) return { data: e };
|
|
5
|
+
let t = e;
|
|
6
|
+
return !("data" in t) || !("scope" in t) || !("completeness" in t) ? { data: e } : {
|
|
7
|
+
data: t.data,
|
|
8
|
+
observation: {
|
|
9
|
+
...t.scope === void 0 ? {} : { scope: t.scope },
|
|
10
|
+
...t.origin === void 0 ? {} : { origin: t.origin },
|
|
11
|
+
...t.completeness === void 0 ? {} : { completeness: t.completeness }
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
}, n = (e, t, n = !1) => {
|
|
4
15
|
let r = { ...e ?? {} }, i = t ?? process.env.VOLTRO_INSPECT_TOKEN;
|
|
5
16
|
if (i !== void 0 && i !== "" && (r.authorization = `Bearer ${i}`), n) {
|
|
6
17
|
let e = process.env.VOLTRO_INSPECT_WRITE_TOKEN;
|
|
7
18
|
e !== void 0 && e !== "" && (r["x-voltro-inspect-write"] = e);
|
|
8
19
|
}
|
|
9
20
|
return r;
|
|
10
|
-
},
|
|
21
|
+
}, r = /* @__PURE__ */ new Set([
|
|
11
22
|
"POST",
|
|
12
23
|
"PUT",
|
|
13
24
|
"PATCH",
|
|
14
25
|
"DELETE"
|
|
15
|
-
]),
|
|
16
|
-
let
|
|
26
|
+
]), i = async (e, i, a) => {
|
|
27
|
+
let o = `${e.url.replace(/\/+$/, "")}${i.startsWith("/") ? i : `/${i}`}`, s = a?.method ?? "GET", c = a?.body !== void 0;
|
|
17
28
|
try {
|
|
18
|
-
let
|
|
19
|
-
method:
|
|
20
|
-
headers:
|
|
21
|
-
...
|
|
22
|
-
}),
|
|
23
|
-
if (
|
|
24
|
-
|
|
29
|
+
let i = await fetch(o, {
|
|
30
|
+
method: s,
|
|
31
|
+
headers: a?.anonymous === !0 ? c ? { "content-type": "application/json" } : {} : n(c ? { "content-type": "application/json" } : void 0, e.inspectToken, r.has(s)),
|
|
32
|
+
...c ? { body: JSON.stringify(a.body) } : {}
|
|
33
|
+
}), l = await i.text(), u;
|
|
34
|
+
if (l.length > 0) try {
|
|
35
|
+
u = JSON.parse(l);
|
|
25
36
|
} catch {
|
|
26
|
-
|
|
37
|
+
u = l;
|
|
27
38
|
}
|
|
28
|
-
if (!
|
|
29
|
-
let t =
|
|
39
|
+
if (!i.ok) {
|
|
40
|
+
let t = u, n = typeof t == "object" && t ? String(t.message ?? t.reason ?? t.error ?? `HTTP ${i.status}`) : `HTTP ${i.status}`, a = r.has(s) && (process.env.VOLTRO_INSPECT_WRITE_TOKEN ?? "") === "" && /write/i.test(n);
|
|
30
41
|
return {
|
|
31
42
|
kind: "err",
|
|
32
43
|
name: e.name,
|
|
33
|
-
error: a ? `${
|
|
44
|
+
error: a ? `${n}\n VOLTRO_INSPECT_WRITE_TOKEN is not set in this shell. \`voltro dev\` mints it into the project's \`.env.local\`; export it (or run from a shell that loaded it).` : n
|
|
34
45
|
};
|
|
35
46
|
}
|
|
47
|
+
let d = t(u);
|
|
36
48
|
return {
|
|
37
49
|
kind: "ok",
|
|
38
50
|
name: e.name,
|
|
39
|
-
status:
|
|
40
|
-
|
|
51
|
+
status: i.status,
|
|
52
|
+
...d
|
|
41
53
|
};
|
|
42
54
|
} catch (t) {
|
|
43
55
|
return {
|
|
@@ -46,7 +58,7 @@ var t = (e, t, n = !1) => {
|
|
|
46
58
|
error: t.message || String(t)
|
|
47
59
|
};
|
|
48
60
|
}
|
|
49
|
-
},
|
|
61
|
+
}, a = (e, t = process.env) => {
|
|
50
62
|
let n = [], r, i;
|
|
51
63
|
for (let t = 0; t < e.length; t++) {
|
|
52
64
|
let a = e[t];
|
|
@@ -91,7 +103,7 @@ var t = (e, t, n = !1) => {
|
|
|
91
103
|
},
|
|
92
104
|
rest: n
|
|
93
105
|
};
|
|
94
|
-
},
|
|
106
|
+
}, o = (e) => ({
|
|
95
107
|
id: `remote:${e.url}`,
|
|
96
108
|
name: e.name,
|
|
97
109
|
kind: "api",
|
|
@@ -102,7 +114,7 @@ var t = (e, t, n = !1) => {
|
|
|
102
114
|
status: "live",
|
|
103
115
|
logFile: "",
|
|
104
116
|
...e.token === void 0 ? {} : { inspectToken: e.token }
|
|
105
|
-
}),
|
|
117
|
+
}), s = async (t, n) => n === void 0 ? (await e()).apps.filter((e) => e.kind === "api" && e.status === "live" && e.url.length > 0 && (t === void 0 || e.name === t)) : [o(n)], c = (e) => {
|
|
106
118
|
let t = "pretty", n = [];
|
|
107
119
|
for (let r = 0; r < e.length; r++) {
|
|
108
120
|
let i = e[r];
|
|
@@ -126,8 +138,8 @@ var t = (e, t, n = !1) => {
|
|
|
126
138
|
format: t,
|
|
127
139
|
rest: n
|
|
128
140
|
};
|
|
129
|
-
},
|
|
130
|
-
let { target: n, rest: r, error:
|
|
141
|
+
}, l = (e, t = process.env) => {
|
|
142
|
+
let { target: n, rest: r, error: i } = a(e, t), o, s = [];
|
|
131
143
|
for (let e = 0; e < r.length; e++) {
|
|
132
144
|
let t = r[e];
|
|
133
145
|
if (t === "--process") {
|
|
@@ -144,8 +156,8 @@ var t = (e, t, n = !1) => {
|
|
|
144
156
|
process: o,
|
|
145
157
|
target: n,
|
|
146
158
|
rest: s,
|
|
147
|
-
...
|
|
159
|
+
...i === void 0 ? {} : { error: i }
|
|
148
160
|
};
|
|
149
161
|
};
|
|
150
162
|
//#endregion
|
|
151
|
-
export { a, i,
|
|
163
|
+
export { o as a, a as i, c as n, s as o, l as r, i as t };
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { o as e, t } from "./connectionConfig-Bk9IC7D0.js";
|
|
2
2
|
import { createLogger as n } from "@voltro/logger";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { recordSample as r, setRevalidationPublisher as i } from "@voltro/runtime";
|
|
4
|
+
import { Effect as a } from "effect";
|
|
5
5
|
import { channelFor as o, resolveBroadcastNamespace as s, resolveBroadcastProvider as c } from "@voltro/plugin-broadcast";
|
|
6
6
|
//#region src/revalidationWiring.ts
|
|
7
|
-
var l = "voltro_revalidate", u = (e) => o(s({ env: e.VOLTRO_BROADCAST_NAMESPACE }), "revalidate"), d = (
|
|
8
|
-
let o =
|
|
9
|
-
if (
|
|
7
|
+
var l = "voltro_revalidate", u = (e) => o(s({ env: e.VOLTRO_BROADCAST_NAMESPACE }), "revalidate"), d = (r) => {
|
|
8
|
+
let o = r.logger ?? n({ scope: "voltro:revalidate" });
|
|
9
|
+
if (r.mode === "dev") return i((e) => (o.debug(`revalidate ${e.kind} '${e.value}' — no-op under voltro dev (no ISR cache)`), Promise.resolve())), {
|
|
10
10
|
transports: [],
|
|
11
|
-
stop: () => (
|
|
11
|
+
stop: () => (i(null), Promise.resolve())
|
|
12
12
|
};
|
|
13
|
-
let s = [], d =
|
|
13
|
+
let s = [], d = r.dialect === "postgres" && t(), f = null, m = null, h = () => m || (m = (async () => {
|
|
14
14
|
try {
|
|
15
15
|
let t = new (await (import("pg"))).default.Client(e());
|
|
16
16
|
return await t.connect(), f = t, t;
|
|
@@ -20,13 +20,13 @@ var l = "voltro_revalidate", u = (e) => o(s({ env: e.VOLTRO_BROADCAST_NAMESPACE
|
|
|
20
20
|
})(), m);
|
|
21
21
|
d && s.push("pg-notify");
|
|
22
22
|
let g = null, _ = !1;
|
|
23
|
-
if (
|
|
24
|
-
else if (
|
|
23
|
+
if (r.provider !== void 0 && r.provider.name !== "memory") g = r.provider;
|
|
24
|
+
else if (r.provider === void 0) {
|
|
25
25
|
let e = c({}, process.env);
|
|
26
26
|
e.crossReplica && (g = e.provider, _ = !0);
|
|
27
27
|
}
|
|
28
28
|
let v = u(process.env);
|
|
29
|
-
return g && s.push("broker"),
|
|
29
|
+
return g && s.push("broker"), i(async (e) => {
|
|
30
30
|
let t = JSON.stringify(e), n = !1;
|
|
31
31
|
if (d) {
|
|
32
32
|
let r = await h();
|
|
@@ -37,7 +37,7 @@ var l = "voltro_revalidate", u = (e) => o(s({ env: e.VOLTRO_BROADCAST_NAMESPACE
|
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
if (g) try {
|
|
40
|
-
await
|
|
40
|
+
await a.runPromise(g.publish(v, t)), n = !0;
|
|
41
41
|
} catch (t) {
|
|
42
42
|
o.warn(`revalidate ${e.kind} '${e.value}': broker publish failed`, {}, t);
|
|
43
43
|
}
|
|
@@ -48,14 +48,14 @@ var l = "voltro_revalidate", u = (e) => o(s({ env: e.VOLTRO_BROADCAST_NAMESPACE
|
|
|
48
48
|
}), {
|
|
49
49
|
transports: s,
|
|
50
50
|
stop: async () => {
|
|
51
|
-
if (
|
|
51
|
+
if (i(null), f) {
|
|
52
52
|
try {
|
|
53
53
|
await f.end();
|
|
54
54
|
} catch {}
|
|
55
55
|
f = null;
|
|
56
56
|
}
|
|
57
57
|
if (g && _) try {
|
|
58
|
-
await
|
|
58
|
+
await a.runPromise(g.close());
|
|
59
59
|
} catch {}
|
|
60
60
|
g = null;
|
|
61
61
|
}
|
|
@@ -98,17 +98,17 @@ var l = "voltro_revalidate", u = (e) => o(s({ env: e.VOLTRO_BROADCAST_NAMESPACE
|
|
|
98
98
|
max: t[t.length - 1]
|
|
99
99
|
};
|
|
100
100
|
}, y = (e = {}) => {
|
|
101
|
-
let t = e.maxSamples ?? h, n = e.defaultWindowMs ?? g,
|
|
101
|
+
let t = e.maxSamples ?? h, n = e.defaultWindowMs ?? g, i = [];
|
|
102
102
|
return {
|
|
103
103
|
record(e) {
|
|
104
|
-
|
|
104
|
+
r(e), i.push({
|
|
105
105
|
...e,
|
|
106
106
|
ts: Date.now()
|
|
107
|
-
}),
|
|
107
|
+
}), i.length > t && i.shift();
|
|
108
108
|
},
|
|
109
109
|
snapshot(e) {
|
|
110
|
-
let t = e ?? n,
|
|
111
|
-
for (let e of
|
|
110
|
+
let t = e ?? n, r = Date.now(), a = r - t, o = /* @__PURE__ */ new Map(), s = 0;
|
|
111
|
+
for (let e of i) {
|
|
112
112
|
if (e.ts < a) continue;
|
|
113
113
|
s++;
|
|
114
114
|
let t = `${e.kind}\u0000${e.tag}`, n = o.get(t);
|
|
@@ -132,7 +132,7 @@ var l = "voltro_revalidate", u = (e) => o(s({ env: e.VOLTRO_BROADCAST_NAMESPACE
|
|
|
132
132
|
}
|
|
133
133
|
return c.sort((e, t) => t.count - e.count), {
|
|
134
134
|
windowMs: t,
|
|
135
|
-
capturedAt:
|
|
135
|
+
capturedAt: r,
|
|
136
136
|
totalSamples: s,
|
|
137
137
|
buckets: c
|
|
138
138
|
};
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { n as e } from "./runtimeRegistry-DMeKfTHP.js";
|
|
2
2
|
import { r as t, t as n } from "./logFileSink-B4uP8pvf.js";
|
|
3
3
|
import { n as r } from "./cliOutput-D1tSBoRM.js";
|
|
4
|
-
import { a as i, i as a } from "./inspectFetch-
|
|
5
|
-
import {
|
|
4
|
+
import { a as i, i as a } from "./inspectFetch-BU1NyzxV.js";
|
|
5
|
+
import { n as o, t as s } from "./emptyResultHeadline-Csa5fZOF.js";
|
|
6
|
+
import { ansi as c } from "@voltro/logger";
|
|
6
7
|
//#region src/logsCmd.ts
|
|
7
|
-
var
|
|
8
|
+
var l = (e) => {
|
|
8
9
|
let t = a(e);
|
|
9
10
|
if (t.error !== void 0) return { error: t.error };
|
|
10
11
|
let n = t.target, r = t.rest, i = {
|
|
@@ -31,7 +32,7 @@ var s = (e) => {
|
|
|
31
32
|
case "--since": {
|
|
32
33
|
let e = n();
|
|
33
34
|
if (e === void 0) return { error: "--since expects a value" };
|
|
34
|
-
let t =
|
|
35
|
+
let t = u(e);
|
|
35
36
|
if (t === null) return { error: `--since: unrecognised '${e}' (try '30s', '5m', '1h', or unix-ms)` };
|
|
36
37
|
i.since = t;
|
|
37
38
|
break;
|
|
@@ -89,7 +90,7 @@ var s = (e) => {
|
|
|
89
90
|
...i,
|
|
90
91
|
target: n
|
|
91
92
|
};
|
|
92
|
-
},
|
|
93
|
+
}, u = (e) => {
|
|
93
94
|
let t = /^(\d+)([smh])$/.exec(e);
|
|
94
95
|
if (t) {
|
|
95
96
|
let e = Number(t[1]), n = t[2], r = n === "s" ? 1e3 : n === "m" ? 6e4 : 36e5;
|
|
@@ -97,15 +98,15 @@ var s = (e) => {
|
|
|
97
98
|
}
|
|
98
99
|
let n = Number(e);
|
|
99
100
|
return Number.isFinite(n) && n > 0 ? n : null;
|
|
100
|
-
},
|
|
101
|
+
}, d = () => {
|
|
101
102
|
console.log("voltro logs — recent log records from every running voltro process"), console.log(""), console.log("Usage:"), console.log(" voltro logs [--tail N] [--since SPEC] [--level L] [--scope S]"), console.log(" [--source server|client] [--filter PAT] [--trace ID]"), console.log(" [--process NAME] [--format pretty|json|text] [--no-color]"), console.log(""), console.log("Examples:"), console.log(" voltro logs --tail 50"), console.log(" voltro logs --since 30s --level error"), console.log(" voltro logs --filter 'channels.create'"), console.log(" voltro logs --trace <traceId> --format json # whole chain for one request"), console.log(" voltro logs --format json | jq '.[] | select(.level == \"error\")'");
|
|
102
|
-
},
|
|
103
|
-
let a =
|
|
104
|
-
if ("error" in a) return a.error !== "help" && console.error(`voltro logs: ${a.error}`),
|
|
105
|
-
let
|
|
103
|
+
}, f = async (t) => {
|
|
104
|
+
let a = l(t);
|
|
105
|
+
if ("error" in a) return a.error !== "help" && console.error(`voltro logs: ${a.error}`), d(), a.error === "help" ? 0 : 2;
|
|
106
|
+
let s = a.target === void 0 ? await e() : {
|
|
106
107
|
version: 1,
|
|
107
108
|
apps: [i(a.target)]
|
|
108
|
-
}, u = a.process === void 0 ?
|
|
109
|
+
}, u = a.process === void 0 ? s.apps : s.apps.filter((e) => e.name === a.process);
|
|
109
110
|
if (u.length === 0 && a.process !== void 0) {
|
|
110
111
|
let e = n(a.process);
|
|
111
112
|
e !== void 0 && (u = [{
|
|
@@ -123,37 +124,41 @@ var s = (e) => {
|
|
|
123
124
|
if (u.length === 0) {
|
|
124
125
|
if (a.process !== void 0) {
|
|
125
126
|
console.error(`voltro logs: no running process named '${a.process}' and no orphan log file found`), console.error(" active processes:");
|
|
126
|
-
for (let e of
|
|
127
|
+
for (let e of s.apps) console.error(` - ${e.name} (${e.kind} @ ${e.url})`);
|
|
127
128
|
return 1;
|
|
128
129
|
}
|
|
129
130
|
return console.error("voltro logs: no running voltro process found"), console.error(" start one with 'voltro dev' (or 'voltro start') and try again."), 1;
|
|
130
131
|
}
|
|
131
|
-
let f = u.map((e) =>
|
|
132
|
-
for (let e of
|
|
132
|
+
let f = u.map((e) => p(e, a)), m = await Promise.all(f), h = [], g = [];
|
|
133
|
+
for (let e of m) e.kind === "ok" ? h.push(...e.records) : g.push({
|
|
133
134
|
name: e.name,
|
|
134
135
|
error: e.error
|
|
135
136
|
});
|
|
136
|
-
if (
|
|
137
|
-
let e =
|
|
138
|
-
records:
|
|
139
|
-
fetchErrors:
|
|
140
|
-
} : { records:
|
|
141
|
-
return r(e, { pretty: !1 }), +(
|
|
137
|
+
if (h.sort((e, t) => e.ts - t.ts), a.format === "json") {
|
|
138
|
+
let e = g.length > 0 ? {
|
|
139
|
+
records: h,
|
|
140
|
+
fetchErrors: g
|
|
141
|
+
} : { records: h };
|
|
142
|
+
return r(e, { pretty: !1 }), +(g.length === u.length);
|
|
142
143
|
}
|
|
143
144
|
if (a.format === "text") {
|
|
144
|
-
for (let e of
|
|
145
|
-
for (let e of
|
|
146
|
-
return +(
|
|
145
|
+
for (let e of h) console.log(_(e));
|
|
146
|
+
for (let e of g) console.error(`# fetch failed: ${e.name}: ${e.error}`);
|
|
147
|
+
return +(g.length === u.length);
|
|
147
148
|
}
|
|
148
|
-
for (let e of
|
|
149
|
-
|
|
150
|
-
|
|
149
|
+
for (let e of h) console.log(v(e, a.color));
|
|
150
|
+
h.length === 0 && console.error(o({
|
|
151
|
+
noun: "logs",
|
|
152
|
+
targets: u.length,
|
|
153
|
+
failures: g
|
|
154
|
+
}) ?? "voltro logs: no records matched the given filters.");
|
|
155
|
+
for (let e of g) {
|
|
151
156
|
let t = `# fetch failed: ${e.name}: ${e.error}`;
|
|
152
|
-
console.error(a.color ?
|
|
157
|
+
console.error(a.color ? c.dim(t) : t);
|
|
153
158
|
}
|
|
154
|
-
return +(
|
|
155
|
-
},
|
|
156
|
-
if (e.status === "booting") return
|
|
159
|
+
return +(g.length === u.length);
|
|
160
|
+
}, p = async (e, t) => {
|
|
161
|
+
if (e.status === "booting") return m(e, t, "process still booting");
|
|
157
162
|
let n = new URLSearchParams();
|
|
158
163
|
n.set("max", String(t.tail)), n.set("format", "json"), t.since !== void 0 && n.set("since", String(t.since)), t.level !== void 0 && n.set("level", t.level), t.scope !== void 0 && n.set("scope", t.scope), t.source !== void 0 && n.set("source", t.source), t.filter !== void 0 && n.set("filter", t.filter), t.traceId !== void 0 && n.set("trace", t.traceId);
|
|
159
164
|
let r = `${e.url.replace(/\/+$/, "")}/_voltro/inspect/logs?${n.toString()}`;
|
|
@@ -161,7 +166,7 @@ var s = (e) => {
|
|
|
161
166
|
let n = {};
|
|
162
167
|
process.env.VOLTRO_INSPECT_TOKEN !== void 0 && (n.authorization = `Bearer ${process.env.VOLTRO_INSPECT_TOKEN}`);
|
|
163
168
|
let i = await fetch(r, { headers: n });
|
|
164
|
-
if (!i.ok) return
|
|
169
|
+
if (!i.ok) return m(e, t, await s(i));
|
|
165
170
|
let a = await i.json(), o = Array.isArray(a.records) ? a.records : [];
|
|
166
171
|
return {
|
|
167
172
|
kind: "ok",
|
|
@@ -172,9 +177,9 @@ var s = (e) => {
|
|
|
172
177
|
}))
|
|
173
178
|
};
|
|
174
179
|
} catch (n) {
|
|
175
|
-
return
|
|
180
|
+
return m(e, t, n.message || String(n));
|
|
176
181
|
}
|
|
177
|
-
},
|
|
182
|
+
}, m = async (e, n, r) => {
|
|
178
183
|
if (!e.logFile) return {
|
|
179
184
|
kind: "err",
|
|
180
185
|
name: e.name,
|
|
@@ -215,49 +220,49 @@ var s = (e) => {
|
|
|
215
220
|
error: `${r}; file read failed: ${t.message || String(t)}`
|
|
216
221
|
};
|
|
217
222
|
}
|
|
218
|
-
},
|
|
219
|
-
trace:
|
|
220
|
-
debug:
|
|
221
|
-
info:
|
|
222
|
-
warn:
|
|
223
|
-
error:
|
|
224
|
-
fatal: (e) =>
|
|
225
|
-
},
|
|
223
|
+
}, h = {
|
|
224
|
+
trace: c.dim,
|
|
225
|
+
debug: c.cyan,
|
|
226
|
+
info: c.green,
|
|
227
|
+
warn: c.yellow,
|
|
228
|
+
error: c.red,
|
|
229
|
+
fatal: (e) => c.bgRed(c.white(e))
|
|
230
|
+
}, g = {
|
|
226
231
|
trace: "TRACE",
|
|
227
232
|
debug: "DEBUG",
|
|
228
233
|
info: "INFO ",
|
|
229
234
|
warn: "WARN ",
|
|
230
235
|
error: "ERROR",
|
|
231
236
|
fatal: "FATAL"
|
|
232
|
-
}, h = (e) => {
|
|
233
|
-
let t = _(e.ts), n = e.scope ?? "?", r = y(e.fields);
|
|
234
|
-
return `${t} ${m[e.level]} [${n}/${e.source}@${e.process}] ${e.message}${r}`;
|
|
235
|
-
}, g = (e, t) => {
|
|
236
|
-
if (!t) return h(e);
|
|
237
|
-
let n = o.dim(_(e.ts)), r = e.scope ?? "?", i = p[e.level](m[e.level]), a = o.dim(`[${r}/${e.source}@${e.process}]`), s = e.level === "error" || e.level === "fatal" ? o.red(e.message) : e.message, c = y(e.fields);
|
|
238
|
-
return `${n} ${i} ${a} ${s}${c ? o.dim(c) : ""}`;
|
|
239
237
|
}, _ = (e) => {
|
|
238
|
+
let t = y(e.ts), n = e.scope ?? "?", r = x(e.fields);
|
|
239
|
+
return `${t} ${g[e.level]} [${n}/${e.source}@${e.process}] ${e.message}${r}`;
|
|
240
|
+
}, v = (e, t) => {
|
|
241
|
+
if (!t) return _(e);
|
|
242
|
+
let n = c.dim(y(e.ts)), r = e.scope ?? "?", i = h[e.level](g[e.level]), a = c.dim(`[${r}/${e.source}@${e.process}]`), o = e.level === "error" || e.level === "fatal" ? c.red(e.message) : e.message, s = x(e.fields);
|
|
243
|
+
return `${n} ${i} ${a} ${o}${s ? c.dim(s) : ""}`;
|
|
244
|
+
}, y = (e) => {
|
|
240
245
|
let t = new Date(e);
|
|
241
246
|
return `${String(t.getHours()).padStart(2, "0")}:${String(t.getMinutes()).padStart(2, "0")}:${String(t.getSeconds()).padStart(2, "0")}.${String(t.getMilliseconds()).padStart(3, "0")}`;
|
|
242
|
-
},
|
|
247
|
+
}, b = 80, x = (e) => {
|
|
243
248
|
let t = Object.entries(e);
|
|
244
249
|
if (t.length === 0) return "";
|
|
245
250
|
let n = [];
|
|
246
|
-
for (let [e, r] of t) r !== void 0 && n.push(`${e}=${
|
|
251
|
+
for (let [e, r] of t) r !== void 0 && n.push(`${e}=${S(r)}`);
|
|
247
252
|
return n.length > 0 ? " " + n.join(" ") : "";
|
|
248
|
-
},
|
|
253
|
+
}, S = (e) => {
|
|
249
254
|
if (typeof e == "string") {
|
|
250
|
-
let t = e.length >
|
|
255
|
+
let t = e.length > b ? e.slice(0, b) + "…" : e;
|
|
251
256
|
return /[\s=]/.test(t) ? `"${t.replace(/"/g, "\\\"")}"` : t;
|
|
252
257
|
}
|
|
253
258
|
if (e === null) return "null";
|
|
254
259
|
if (typeof e == "number" || typeof e == "boolean") return String(e);
|
|
255
260
|
try {
|
|
256
261
|
let t = JSON.stringify(e);
|
|
257
|
-
return t.length >
|
|
262
|
+
return t.length > b ? t.slice(0, b) + "…" : t;
|
|
258
263
|
} catch {
|
|
259
264
|
return "[unserialisable]";
|
|
260
265
|
}
|
|
261
266
|
};
|
|
262
267
|
//#endregion
|
|
263
|
-
export {
|
|
268
|
+
export { f as runLogsCommand };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as e } from "./cliError-BmdYnghb.js";
|
|
2
2
|
import { r as t } from "./dialectDriver-czCHYpeH.js";
|
|
3
3
|
import { a as n, r } from "./connectionConfig-Bk9IC7D0.js";
|
|
4
|
-
import {
|
|
4
|
+
import { _ as i, c as a, n as o } from "./frameworkTableAssembly-vfkzuzEo.js";
|
|
5
5
|
import { t as s } from "./cliRuntime-Dh7UDinH.js";
|
|
6
6
|
import { join as c, relative as l, resolve as u } from "node:path";
|
|
7
7
|
import { pathToFileURL as d } from "node:url";
|
|
@@ -43,7 +43,7 @@ var _ = /* @__PURE__ */ new Set([
|
|
|
43
43
|
root: e
|
|
44
44
|
}), 1;
|
|
45
45
|
yield* m.logInfo(`discovered ${t.length} schema file(s)`, { files: t.map((t) => l(e, t)) });
|
|
46
|
-
let n = yield* x(t), r = yield* m.promise(() =>
|
|
46
|
+
let n = yield* x(t), r = yield* m.promise(() => o({ root: e })), s = [...n, ...r];
|
|
47
47
|
if (yield* m.logInfo(`tables to apply: ${s.length}`, {
|
|
48
48
|
user: n.map((e) => e.tableName),
|
|
49
49
|
framework: r.map((e) => e.tableName)
|
|
@@ -56,7 +56,7 @@ var _ = /* @__PURE__ */ new Set([
|
|
|
56
56
|
});
|
|
57
57
|
let g = yield* m.promise(() => w()), _ = g.makeSqlLayer(C());
|
|
58
58
|
yield* m.promise(() => h(s, _, g.id, { retryFilter: g.retryFilter }));
|
|
59
|
-
let v = yield* m.promise(() =>
|
|
59
|
+
let v = yield* m.promise(() => a(e)), b = [], S = yield* i(v, (e, t) => {
|
|
60
60
|
b.push({
|
|
61
61
|
message: e,
|
|
62
62
|
fields: t ?? {}
|
|
@@ -79,7 +79,7 @@ var _ = /* @__PURE__ */ new Set([
|
|
|
79
79
|
let t = u(e.find((e) => !e.startsWith("-")) ?? process.cwd());
|
|
80
80
|
return s(S(t), { scope: "voltro:migrate" });
|
|
81
81
|
}
|
|
82
|
-
let { runDbCommand: t } = await import("./dbCommand-
|
|
82
|
+
let { runDbCommand: t } = await import("./dbCommand-DHi_RuDl.js");
|
|
83
83
|
return t(["apply", ...e]);
|
|
84
84
|
};
|
|
85
85
|
//#endregion
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { i as e } from "./staticCachePolicy-CIyj6DbS.js";
|
|
2
|
+
import { join as t } from "node:path";
|
|
3
|
+
import { promises as n } from "node:fs";
|
|
4
|
+
import { brotliCompress as r, constants as i, gzip as a } from "node:zlib";
|
|
5
|
+
import { promisify as o } from "node:util";
|
|
6
|
+
//#region src/precompressAssets.ts
|
|
7
|
+
var s = o(r), c = o(a), l = /\.(js|mjs|css|svg|json|map|txt|xml|wasm)$/i, u = async (r) => {
|
|
8
|
+
let a = t(r, "assets"), o;
|
|
9
|
+
try {
|
|
10
|
+
o = await n.readdir(a);
|
|
11
|
+
} catch {
|
|
12
|
+
return {
|
|
13
|
+
files: 0,
|
|
14
|
+
originalBytes: 0,
|
|
15
|
+
brotliBytes: 0,
|
|
16
|
+
gzipBytes: 0
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
let u = 0, d = 0, f = 0, p = 0;
|
|
20
|
+
return await Promise.all(o.map(async (r) => {
|
|
21
|
+
if (r.endsWith(".br") || r.endsWith(".gz") || !l.test(r) || !e(`/assets/${r}`)) return;
|
|
22
|
+
let o = t(a, r);
|
|
23
|
+
try {
|
|
24
|
+
let e = await n.readFile(o);
|
|
25
|
+
if (e.length < 1024) return;
|
|
26
|
+
let [t, r] = await Promise.all([s(e, { params: {
|
|
27
|
+
[i.BROTLI_PARAM_QUALITY]: 11,
|
|
28
|
+
[i.BROTLI_PARAM_SIZE_HINT]: e.length
|
|
29
|
+
} }), c(e, { level: 9 })]);
|
|
30
|
+
t.length < e.length && (await n.writeFile(`${o}.br`, t), f += t.length), r.length < e.length && (await n.writeFile(`${o}.gz`, r), p += r.length), u += 1, d += e.length;
|
|
31
|
+
} catch {}
|
|
32
|
+
})), {
|
|
33
|
+
files: u,
|
|
34
|
+
originalBytes: d,
|
|
35
|
+
brotliBytes: f,
|
|
36
|
+
gzipBytes: p
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
//#endregion
|
|
40
|
+
export { u as precompressAssets };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { r as e, t } from "./inspectGateHint-4LxkNtrz.js";
|
|
2
2
|
import { n } from "./cliOutput-D1tSBoRM.js";
|
|
3
|
-
import { n as r, o as i, r as a, t as o } from "./inspectFetch-
|
|
3
|
+
import { n as r, o as i, r as a, t as o } from "./inspectFetch-BU1NyzxV.js";
|
|
4
4
|
import { ansi as s } from "@voltro/logger";
|
|
5
5
|
//#region src/probeCommand.ts
|
|
6
6
|
var c = () => {
|
|
@@ -108,7 +108,7 @@ server and in this shell.`);
|
|
|
108
108
|
}, m = async (e) => {
|
|
109
109
|
let t = /* @__PURE__ */ new Map();
|
|
110
110
|
try {
|
|
111
|
-
let { walk: n, loadDiscovered: r } = await import("./dev-
|
|
111
|
+
let { walk: n, loadDiscovered: r } = await import("./dev-Bl9HqtV7.js"), i = await r(await n(e), { root: e }), a = [
|
|
112
112
|
...i.queries,
|
|
113
113
|
...i.mutations,
|
|
114
114
|
...i.actions,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as e } from "./apiBuild-
|
|
1
|
+
import { n as e } from "./apiBuild-DDr2aNFd.js";
|
|
2
2
|
import { join as t, resolve as n, sep as r } from "node:path";
|
|
3
3
|
import { existsSync as i, promises as a } from "node:fs";
|
|
4
4
|
import { createLogger as o } from "@voltro/logger";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as e } from "./cliArgs-D4p8n7EE.js";
|
|
2
2
|
import { n as t } from "./cliOutput-D1tSBoRM.js";
|
|
3
|
-
import { n, o as r, r as i, t as a } from "./inspectFetch-
|
|
3
|
+
import { n, o as r, r as i, t as a } from "./inspectFetch-BU1NyzxV.js";
|
|
4
4
|
import { ansi as o } from "@voltro/logger";
|
|
5
5
|
//#region src/scheduleCmd.ts
|
|
6
6
|
var s = () => {
|
|
@@ -422,7 +422,7 @@ let package = Package(
|
|
|
422
422
|
await l.mkdir(o(e), { recursive: !0 }), await l.writeFile(e, n.content, "utf8");
|
|
423
423
|
}
|
|
424
424
|
}, X = async (e) => {
|
|
425
|
-
let { offlineManifest: t } = await import("./checkCommand-
|
|
425
|
+
let { offlineManifest: t } = await import("./checkCommand-BISqx1OJ.js"), { manifest: n } = await t(e);
|
|
426
426
|
return n;
|
|
427
427
|
}, Z = async (e) => {
|
|
428
428
|
let t = J(await (e.manifestProvider ?? X)(e.root), {
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
import { n as e } from "./appModuleLoader-C9r9mxZt.js";
|
|
2
2
|
import { promises as t } from "node:fs";
|
|
3
3
|
import { _voltroSeedsTable as n, and as r, eq as i, generateId as a, isSeedDefinition as o, setSchemaChangeSeedHook as s, setTenantCreateSeedHook as c } from "@voltro/database";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
4
|
+
import { defineSchedule as l } from "@voltro/runtime";
|
|
5
|
+
import { Cause as u, Effect as d } from "effect";
|
|
6
|
+
import { SqlClient as f } from "@effect/sql";
|
|
7
|
+
import { DEFAULT_CDC_CHANNEL as p, detectReactiveTriggerDrift as m, migrationLockKeyForSchema as h, reactiveTriggerRepairSql as g, resolveMigrationLockSchema as _ } from "@voltro/database/sql";
|
|
8
8
|
import { createHash as v } from "node:crypto";
|
|
9
9
|
//#region src/reactiveTriggerBoot.ts
|
|
10
10
|
var y = (e, t = process.env) => {
|
|
11
11
|
let n = (t.VOLTRO_REACTIVE_TRIGGERS ?? "").trim().toLowerCase(), r = n === "repair" || n === "report" || n === "off" ? n : e ?? "repair";
|
|
12
12
|
return r === "repair" && t.VOLTRO_AUTO_MIGRATE === "0" ? "report" : r;
|
|
13
|
-
}, b = (e, t, n =
|
|
13
|
+
}, b = (e, t, n = p) => d.map(m(e, t, n), (e) => ({
|
|
14
14
|
drift: e,
|
|
15
|
-
statements:
|
|
15
|
+
statements: g({
|
|
16
16
|
tables: t,
|
|
17
17
|
dialect: "postgres",
|
|
18
18
|
channel: n,
|
|
19
19
|
...e
|
|
20
20
|
})
|
|
21
|
-
})), x = (e, t) =>
|
|
22
|
-
let n = yield*
|
|
21
|
+
})), x = (e, t) => d.gen(function* () {
|
|
22
|
+
let n = yield* f.SqlClient, { drift: r, statements: i } = yield* b(n, e, t.channel ?? p), a = {
|
|
23
23
|
missing: r.missing.length,
|
|
24
24
|
stale: r.stale.length,
|
|
25
25
|
statements: i.length
|
|
@@ -32,24 +32,24 @@ var y = (e, t = process.env) => {
|
|
|
32
32
|
kind: "reported",
|
|
33
33
|
...a
|
|
34
34
|
};
|
|
35
|
-
let o =
|
|
35
|
+
let o = h(_({ schema: t.lockSchema }));
|
|
36
36
|
return (yield* n`
|
|
37
|
-
SELECT pg_try_advisory_lock(${o.toString()}::bigint) AS got`)[0]?.got === !0 ? yield*
|
|
37
|
+
SELECT pg_try_advisory_lock(${o.toString()}::bigint) AS got`)[0]?.got === !0 ? yield* d.gen(function* () {
|
|
38
38
|
for (let e of i) yield* n.unsafe(e);
|
|
39
39
|
return {
|
|
40
40
|
kind: "repaired",
|
|
41
41
|
...a
|
|
42
42
|
};
|
|
43
|
-
}).pipe(
|
|
43
|
+
}).pipe(d.ensuring(n`SELECT pg_advisory_unlock(${o.toString()}::bigint)`.pipe(d.catchAll(() => d.void)))) : {
|
|
44
44
|
kind: "lock-held",
|
|
45
45
|
...a
|
|
46
46
|
};
|
|
47
|
-
}).pipe(
|
|
47
|
+
}).pipe(d.catchAllCause((e) => d.succeed({
|
|
48
48
|
kind: "failed",
|
|
49
49
|
missing: 0,
|
|
50
50
|
stale: 0,
|
|
51
51
|
statements: 0,
|
|
52
|
-
detail:
|
|
52
|
+
detail: u.pretty(e)
|
|
53
53
|
}))), S = async (e) => {
|
|
54
54
|
let t = {
|
|
55
55
|
kind: "skipped",
|
|
@@ -58,11 +58,11 @@ var y = (e, t = process.env) => {
|
|
|
58
58
|
statements: 0
|
|
59
59
|
};
|
|
60
60
|
if (e.dialectId !== "postgres" || e.mode === "off" || e.tables.length === 0) return t;
|
|
61
|
-
let n = await e.makeLayer(), r = await
|
|
61
|
+
let n = await e.makeLayer(), r = await d.runPromise(x(e.tables, {
|
|
62
62
|
mode: e.mode,
|
|
63
63
|
...e.channel === void 0 ? {} : { channel: e.channel },
|
|
64
64
|
...e.lockSchema === void 0 ? {} : { lockSchema: e.lockSchema }
|
|
65
|
-
}).pipe(
|
|
65
|
+
}).pipe(d.provide(n))).catch((e) => ({
|
|
66
66
|
kind: "failed",
|
|
67
67
|
missing: 0,
|
|
68
68
|
stale: 0,
|
|
@@ -317,7 +317,7 @@ var y = (e, t = process.env) => {
|
|
|
317
317
|
await I(e, r.changedTables, t, n);
|
|
318
318
|
}), () => {
|
|
319
319
|
c(null), s(null);
|
|
320
|
-
}), R = "seed:", z = (e, t, n) => e.filter((e) => e.definition.lifecycle === "cron").map((r) =>
|
|
320
|
+
}), R = "seed:", z = (e, t, n) => e.filter((e) => e.definition.lifecycle === "cron").map((r) => l({
|
|
321
321
|
name: `${R}${r.definition.id}`,
|
|
322
322
|
cron: r.definition.cron ?? "",
|
|
323
323
|
timezone: r.definition.timezone ?? "UTC",
|