@voltro/cli 0.45.0 → 0.46.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 +176 -0
- package/dist/{apiBuild-CDQBNRDx.js → apiBuild-BKdd0I1Z.js} +2 -2
- package/dist/apiBuild-P2gewrfQ.js +2 -0
- package/dist/bin.d.ts +8 -0
- package/dist/bin.js +1 -1
- package/dist/{build-yvsLG77U.js → build-co6yadYz.js} +7 -7
- package/dist/{checkCommand-Boxov8lr.js → checkCommand-B-eiW-G_.js} +3 -3
- package/dist/{checkCommand-lrzwOzV1.js → checkCommand-CXAXTjZL.js} +1 -1
- package/dist/{codegenCommand-CQOLytL-.js → codegenCommand-CB6_3sX0.js} +15 -15
- package/dist/{codemodRunner-5ZhDH3rB.js → codemodRunner-DSZjgyCL.js} +8 -0
- package/dist/{commands-CEkVoFM5.js → commands-C-hxgAGr.js} +23 -23
- package/dist/{dashboardCommand-0ahyp-zA.js → dashboardCommand-CEVO0GWF.js} +3 -3
- package/dist/{dataCommand-D4IlZcih.js → dataCommand-k0ezbQWa.js} +271 -230
- package/dist/{dbCommand-B237qI-j.js → dbCommand-BwkyNxn-.js} +110 -110
- package/dist/dbCommand-C2XK63Dd.js +2 -0
- package/dist/{dev-DAM5CnAa.js → dev-8hTEnN6s.js} +2080 -2057
- package/dist/{dev-P4HyeY9W.js → dev-DyoYst4j.js} +1 -1
- package/dist/devActivity.d.ts +8 -0
- package/dist/{doctorCommand-DW2cwAvC.js → doctorCommand-B6D7HH1-.js} +14 -14
- package/dist/doctorCommand-Btl2Jz1a.js +2 -0
- package/dist/{dormancyCommand-BqQz7lbM.js → dormancyCommand-CrPAwOgo.js} +1 -1
- package/dist/{embeddingsCommand-DJyArpU4.js → embeddingsCommand-DsSxsn_b.js} +1 -1
- package/dist/{envCommand-CviRZx1L.js → envCommand-B_NPVGUf.js} +2 -2
- package/dist/{evalCommand-6RUfPen4.js → evalCommand-Db01Kbng.js} +24 -24
- package/dist/{evolveCommand-qdlP-R9G.js → evolveCommand-DUuaCIyn.js} +2 -2
- package/dist/{frameworkTableAssembly-oMPBKqlE.js → frameworkTableAssembly-BPlPfU07.js} +82 -78
- package/dist/frameworkTableAssembly-Bob3vj9R.js +2 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +1 -1
- package/dist/{infoCommand-CNWPSUcW.js → infoCommand-CuNl9cbh.js} +1 -1
- package/dist/inspectState.d.ts +8 -0
- package/dist/interruptedReplace-C1ZI84xi.js +27 -0
- package/dist/interruptedReplace-DNJ7MKph.js +2 -0
- package/dist/{migrate-DN47p2PG.js → migrate-CM1qwalu.js} +27 -27
- package/dist/{runtimeTrace-BDZSt9W_.js → runtimeTrace-BRNM06vK.js} +1 -1
- package/dist/{sdkgen-sNaD3oZB.js → sdkgen-CRCw_XcR.js} +1 -1
- package/dist/{seedRunner-IdHEprqf.js → seedRunner-Dgsiwk_e.js} +59 -59
- package/dist/serveCommand-BNHMVXyp.js +2 -0
- package/dist/serveCommand-CHOr74WM.js +1928 -0
- package/dist/serveEntry.d.ts +8 -0
- package/dist/serveEntry.js +1 -1
- package/dist/{start-Ds3xyn8R.js → start-7HcSIKEp.js} +1 -1
- package/dist/{start-BAlGcjF5.js → start-DvlYDyAr.js} +1 -1
- package/dist/startEntry.d.ts +8 -0
- package/dist/startEntry.js +1 -1
- package/dist/startup.d.ts +8 -0
- package/dist/{updateCommand-rCnhaj84.js → updateCommand-BlyXavoG.js} +1 -1
- package/dist/updateCommand-CT5AvVg7.js +2 -0
- package/dist/{webDev-101csg6Q.js → webDev-B4IEMB0n.js} +6 -6
- package/dist/webDev-B79ji8M5.js +2 -0
- package/dist/{webhooksCommand-C0iZZfaI.js → webhooksCommand-BRrG_sGf.js} +1 -1
- package/package.json +23 -17
- package/templates/AGENTS.md +1 -1
- package/templates/agent-docs/_index.md +1 -1
- package/templates/agent-docs/cli.md +138 -2
- package/templates/agent-docs/data.md +70 -4
- package/templates/agent-docs/whats-new.md +127 -54
- package/templates/apps/api-ai/package.json +7 -7
- package/templates/apps/api-auth/package.json +8 -8
- package/templates/apps/api-backend/package.json +7 -7
- package/templates/apps/api-backend-deactivation/package.json +7 -7
- package/templates/apps/api-backend-mail/package.json +8 -8
- package/templates/apps/api-backend-mariadb/package.json +9 -9
- package/templates/apps/api-backend-sqlite/package.json +8 -8
- package/templates/apps/api-backend-storage/package.json +8 -8
- package/templates/apps/api-cms/package.json +10 -10
- package/templates/apps/api-collab/package.json +8 -8
- package/templates/apps/api-data-advanced/package.json +8 -8
- package/templates/apps/api-durable/package.json +8 -8
- package/templates/apps/api-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-saas-starter/package.json +10 -10
- package/templates/apps/api-search/package.json +8 -8
- package/templates/apps/api-status/package.json +8 -8
- package/templates/apps/api-versioning/package.json +8 -8
- package/templates/apps/api-webhooks/package.json +9 -9
- package/templates/apps/changelog/package.json +6 -6
- package/templates/apps/edge-functions/package.json +2 -2
- package/templates/apps/frontend-admin/package.json +8 -8
- package/templates/apps/frontend-app/package.json +9 -9
- package/templates/apps/frontend-auth/package.json +8 -8
- package/templates/apps/frontend-blank/package.json +7 -7
- package/templates/apps/frontend-cms/package.json +9 -9
- package/templates/apps/frontend-collab/package.json +10 -10
- package/templates/apps/frontend-contact/package.json +7 -7
- package/templates/apps/frontend-dashboard/package.json +7 -7
- package/templates/apps/frontend-docs/package.json +7 -7
- package/templates/apps/frontend-i18n/package.json +6 -6
- package/templates/apps/frontend-landing/package.json +7 -7
- package/templates/apps/frontend-portal/package.json +8 -8
- package/templates/apps/frontend-saas/package.json +8 -8
- package/templates/apps/frontend-spa/package.json +7 -7
- package/templates/apps/frontend-ssr/package.json +7 -7
- package/templates/apps/frontend-ssr-api/package.json +8 -8
- package/templates/apps/frontend-static-blog/package.json +6 -6
- package/templates/apps/frontend-status/package.json +8 -8
- package/templates/apps/mobile-app/package.json +4 -4
- package/dist/apiBuild-yJCqJYQ8.js +0 -2
- package/dist/dbCommand-BvQeKQOb.js +0 -2
- package/dist/doctorCommand-2K1dIzYk.js +0 -2
- package/dist/frameworkTableAssembly-DgylYh9_.js +0 -2
- package/dist/serveCommand-BBhT2U94.js +0 -1885
- package/dist/serveCommand-DY2jLy0o.js +0 -2
- package/dist/updateCommand-BH6EGuCc.js +0 -2
- package/dist/webDev-BLKBO34K.js +0 -2
|
@@ -1,55 +1,55 @@
|
|
|
1
1
|
import { n as e } from "./appModuleLoader-C9r9mxZt.js";
|
|
2
2
|
import { promises as t } from "node:fs";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
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 { Cause as l, Effect as u } from "effect";
|
|
5
|
+
import { SqlClient as d } from "@effect/sql";
|
|
6
|
+
import { DEFAULT_CDC_CHANNEL as f, detectReactiveTriggerDrift as p, migrationLockKeyForSchema as m, reactiveTriggerRepairSql as h, resolveMigrationLockSchema as g } from "@voltro/database/sql";
|
|
7
7
|
import { defineSchedule as _ } from "@voltro/runtime";
|
|
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 = f) => u.map(p(e, t, n), (e) => ({
|
|
14
14
|
drift: e,
|
|
15
|
-
statements:
|
|
15
|
+
statements: h({
|
|
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*
|
|
23
|
-
missing:
|
|
24
|
-
stale:
|
|
25
|
-
statements:
|
|
21
|
+
})), x = (e, t) => u.gen(function* () {
|
|
22
|
+
let n = yield* d.SqlClient, { drift: r, statements: i } = yield* b(n, e, t.channel ?? f), a = {
|
|
23
|
+
missing: r.missing.length,
|
|
24
|
+
stale: r.stale.length,
|
|
25
|
+
statements: i.length
|
|
26
26
|
};
|
|
27
|
-
if (
|
|
27
|
+
if (i.length === 0) return {
|
|
28
28
|
kind: "clean",
|
|
29
|
-
...
|
|
29
|
+
...a
|
|
30
30
|
};
|
|
31
31
|
if (t.mode === "report") return {
|
|
32
32
|
kind: "reported",
|
|
33
|
-
...
|
|
33
|
+
...a
|
|
34
34
|
};
|
|
35
|
-
let
|
|
35
|
+
let o = m(g({ schema: t.lockSchema }));
|
|
36
36
|
return (yield* n`
|
|
37
|
-
SELECT pg_try_advisory_lock(${
|
|
38
|
-
for (let e of
|
|
37
|
+
SELECT pg_try_advisory_lock(${o.toString()}::bigint) AS got`)[0]?.got === !0 ? yield* u.gen(function* () {
|
|
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(u.ensuring(n`SELECT pg_advisory_unlock(${o.toString()}::bigint)`.pipe(u.catchAll(() => u.void)))) : {
|
|
44
44
|
kind: "lock-held",
|
|
45
|
-
...
|
|
45
|
+
...a
|
|
46
46
|
};
|
|
47
|
-
}).pipe(
|
|
47
|
+
}).pipe(u.catchAllCause((e) => u.succeed({
|
|
48
48
|
kind: "failed",
|
|
49
49
|
missing: 0,
|
|
50
50
|
stale: 0,
|
|
51
51
|
statements: 0,
|
|
52
|
-
detail:
|
|
52
|
+
detail: l.pretty(e)
|
|
53
53
|
}))), S = async (e) => {
|
|
54
54
|
let t = {
|
|
55
55
|
kind: "skipped",
|
|
@@ -58,39 +58,39 @@ 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(),
|
|
61
|
+
let n = await e.makeLayer(), r = await u.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(u.provide(n))).catch((e) => ({
|
|
66
66
|
kind: "failed",
|
|
67
67
|
missing: 0,
|
|
68
68
|
stale: 0,
|
|
69
69
|
statements: 0,
|
|
70
70
|
detail: e instanceof Error ? e.message : String(e)
|
|
71
71
|
}));
|
|
72
|
-
switch (
|
|
72
|
+
switch (r.kind) {
|
|
73
73
|
case "repaired":
|
|
74
|
-
e.log.info(`reactive triggers: converged at boot — installed ${
|
|
75
|
-
missing:
|
|
76
|
-
stale:
|
|
74
|
+
e.log.info(`reactive triggers: converged at boot — installed ${r.missing}, removed ${r.stale} (${r.statements} statement(s))`, {
|
|
75
|
+
missing: r.missing,
|
|
76
|
+
stale: r.stale
|
|
77
77
|
});
|
|
78
78
|
break;
|
|
79
79
|
case "reported":
|
|
80
|
-
e.log.warn(`reactive triggers: ${
|
|
81
|
-
missing:
|
|
82
|
-
stale:
|
|
80
|
+
e.log.warn(`reactive triggers: ${r.missing} table(s) have NO change trigger and ${r.stale} carry a stale one. Writes to them do not reach another instance's subscribers — invisible on a single instance, which is why this surfaces only once you scale out. This boot is in report-only mode (VOLTRO_REACTIVE_TRIGGERS=report, or VOLTRO_AUTO_MIGRATE=0); run \`voltro db apply\` to close it.`, {
|
|
81
|
+
missing: r.missing,
|
|
82
|
+
stale: r.stale
|
|
83
83
|
});
|
|
84
84
|
break;
|
|
85
85
|
case "lock-held":
|
|
86
86
|
e.log.info("reactive triggers: drift found; another instance (or a `voltro db apply`) holds the migration lock and is converging it. Not waiting — a boot that queues on a lock is worse than a boot that re-checks on the next start.", {
|
|
87
|
-
missing:
|
|
88
|
-
stale:
|
|
87
|
+
missing: r.missing,
|
|
88
|
+
stale: r.stale
|
|
89
89
|
});
|
|
90
90
|
break;
|
|
91
|
-
case "failed": e.log.warn("reactive triggers: the boot check could not run — reactivity may be silently degraded. Run `voltro db apply` to converge them explicitly.", { error:
|
|
91
|
+
case "failed": e.log.warn("reactive triggers: the boot check could not run — reactivity may be silently degraded. Run `voltro db apply` to converge them explicitly.", { error: r.detail });
|
|
92
92
|
}
|
|
93
|
-
return
|
|
93
|
+
return r;
|
|
94
94
|
}, C = async (n, r) => {
|
|
95
95
|
let i = [];
|
|
96
96
|
for (let a of n) {
|
|
@@ -101,16 +101,16 @@ var y = (e, t = process.env) => {
|
|
|
101
101
|
r.warn("seed: failed to import", { file: a }, e);
|
|
102
102
|
continue;
|
|
103
103
|
}
|
|
104
|
-
let
|
|
105
|
-
if (!
|
|
104
|
+
let s = (n.default && o(n.default) ? n.default : void 0) ?? Object.values(n).find(o);
|
|
105
|
+
if (!s) {
|
|
106
106
|
r.warn("seed: no defineSeed export", { file: a });
|
|
107
107
|
continue;
|
|
108
108
|
}
|
|
109
|
-
let
|
|
109
|
+
let c = await t.readFile(a, "utf8").catch(() => ""), l = s.fingerprint ? s.fingerprint({ src: c }) : v("sha256").update(c).digest("hex").slice(0, 16);
|
|
110
110
|
i.push({
|
|
111
111
|
file: a,
|
|
112
|
-
definition:
|
|
113
|
-
fingerprint:
|
|
112
|
+
definition: s,
|
|
113
|
+
fingerprint: l
|
|
114
114
|
});
|
|
115
115
|
}
|
|
116
116
|
return i;
|
|
@@ -127,28 +127,28 @@ var y = (e, t = process.env) => {
|
|
|
127
127
|
insertIgnore: (t, n, r) => e.insertIgnore(t, n, r),
|
|
128
128
|
update: (t, n, r) => e.update(t, n, r),
|
|
129
129
|
delete: (t, n) => e.delete(t, n)
|
|
130
|
-
}), T = (e) => async (t, n,
|
|
131
|
-
let
|
|
132
|
-
if (
|
|
133
|
-
let
|
|
134
|
-
if (
|
|
135
|
-
let e =
|
|
136
|
-
|
|
137
|
-
} else
|
|
138
|
-
let
|
|
130
|
+
}), T = (e) => async (t, n, a) => {
|
|
131
|
+
let o = Object.keys(n);
|
|
132
|
+
if (o.length === 0) throw Error("upsertByUnique: matchFields must have at least one key");
|
|
133
|
+
let s;
|
|
134
|
+
if (o.length === 1) {
|
|
135
|
+
let e = o[0];
|
|
136
|
+
s = i(e, n[e]);
|
|
137
|
+
} else s = r(...o.map((e) => i(e, n[e])));
|
|
138
|
+
let c = (await e.query({
|
|
139
139
|
table: t,
|
|
140
140
|
order: [],
|
|
141
|
-
predicate:
|
|
141
|
+
predicate: s
|
|
142
142
|
}))[0];
|
|
143
|
-
if (
|
|
144
|
-
let n =
|
|
143
|
+
if (c) {
|
|
144
|
+
let n = c.id;
|
|
145
145
|
return {
|
|
146
|
-
row: await e.update(t, n,
|
|
146
|
+
row: await e.update(t, n, a) ?? c,
|
|
147
147
|
created: !1
|
|
148
148
|
};
|
|
149
149
|
}
|
|
150
150
|
return {
|
|
151
|
-
row: await e.insert(t,
|
|
151
|
+
row: await e.insert(t, a),
|
|
152
152
|
created: !0
|
|
153
153
|
};
|
|
154
154
|
}, E = (e, t) => {
|
|
@@ -162,8 +162,8 @@ var y = (e, t = process.env) => {
|
|
|
162
162
|
})
|
|
163
163
|
};
|
|
164
164
|
}, D = "_voltro_seeds", O = () => {
|
|
165
|
-
let e =
|
|
166
|
-
return (e ?
|
|
165
|
+
let e = n.fields.id?.idScheme;
|
|
166
|
+
return (e ? a(e, D) : null) ?? a({
|
|
167
167
|
kind: "typeid",
|
|
168
168
|
prefix: "seed"
|
|
169
169
|
}, D);
|
|
@@ -311,12 +311,12 @@ var y = (e, t = process.env) => {
|
|
|
311
311
|
}
|
|
312
312
|
let c = s.filter((e) => e.status === "failed");
|
|
313
313
|
return c.length > 0 && r.warn("one or more onSchemaChange seeds failed (the schema apply itself succeeded)", { failedIds: c.map((e) => e.seedId) }), s;
|
|
314
|
-
}, L = (e, t, n) => (
|
|
314
|
+
}, L = (e, t, n) => (c(async (r) => {
|
|
315
315
|
await F(e, r.namespace, t, n);
|
|
316
|
-
}),
|
|
316
|
+
}), s(async (r) => {
|
|
317
317
|
await I(e, r.changedTables, t, n);
|
|
318
318
|
}), () => {
|
|
319
|
-
|
|
319
|
+
c(null), s(null);
|
|
320
320
|
}), R = "seed:", z = (e, t, n) => e.filter((e) => e.definition.lifecycle === "cron").map((r) => _({
|
|
321
321
|
name: `${R}${r.definition.id}`,
|
|
322
322
|
cron: r.definition.cron ?? "",
|