@voltro/cli 0.45.0 → 0.47.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 +206 -0
- package/dist/apiBuild-BsooZpw2.js +2 -0
- package/dist/{apiBuild-CDQBNRDx.js → apiBuild-FpHCWiv6.js} +2 -2
- package/dist/bin.d.ts +8 -0
- package/dist/bin.js +1 -1
- package/dist/{build-yvsLG77U.js → build-zVygXxGB.js} +8 -8
- package/dist/{checkCommand-lrzwOzV1.js → checkCommand-B2Fw73lu.js} +1 -1
- package/dist/{checkCommand-Boxov8lr.js → checkCommand-D0dAKciE.js} +4 -4
- package/dist/{codegen-sbN1Y8PB.js → codegen-CrMXs4hb.js} +176 -162
- package/dist/codegen-DiMn2KkZ.js +2 -0
- package/dist/{codegenCommand-CQOLytL-.js → codegenCommand-BTtsnRus.js} +16 -16
- package/dist/{codemodRunner-5ZhDH3rB.js → codemodRunner-DSZjgyCL.js} +8 -0
- package/dist/{commands-CEkVoFM5.js → commands-BrFKxnYW.js} +24 -24
- package/dist/{dashboardCommand-0ahyp-zA.js → dashboardCommand-D9SjDc8E.js} +3 -3
- package/dist/{dataCommand-D4IlZcih.js → dataCommand-Dl11q14e.js} +271 -230
- package/dist/dbCommand-BUD4Fd8v.js +2 -0
- package/dist/{dbCommand-B237qI-j.js → dbCommand-jbrmzwW_.js} +110 -110
- package/dist/{dev-P4HyeY9W.js → dev-CaIfZnw5.js} +1 -1
- package/dist/{dev-DAM5CnAa.js → dev-RjB7eE_B.js} +2081 -2058
- package/dist/devActivity.d.ts +8 -0
- package/dist/doctorCommand-5zv6PN-G.js +2 -0
- package/dist/{doctorCommand-DW2cwAvC.js → doctorCommand-D7X29cw6.js} +16 -16
- package/dist/{doctorSourceRelations-CPjSwYuZ.js → doctorSourceRelations-Dd48LPvO.js} +15 -10
- package/dist/{dormancyCommand-BqQz7lbM.js → dormancyCommand-BGOP27fz.js} +1 -1
- package/dist/{embeddingsCommand-DJyArpU4.js → embeddingsCommand-D72E22bw.js} +1 -1
- package/dist/{envCommand-CviRZx1L.js → envCommand-BHSxz6wC.js} +2 -2
- package/dist/{evalCommand-6RUfPen4.js → evalCommand-Db01Kbng.js} +24 -24
- package/dist/{evolveCommand-qdlP-R9G.js → evolveCommand-C2ofGGlz.js} +2 -2
- package/dist/{frameworkTableAssembly-oMPBKqlE.js → frameworkTableAssembly-BvZ0Lil_.js} +97 -89
- package/dist/frameworkTableAssembly-DDKtwsy2.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-odCPGHPq.js} +27 -27
- package/dist/{runtimeTrace-BDZSt9W_.js → runtimeTrace-C_OKr0jY.js} +1 -1
- package/dist/{sdkgen-sNaD3oZB.js → sdkgen-D9trW7sl.js} +1 -1
- package/dist/{seedRunner-IdHEprqf.js → seedRunner-Dgsiwk_e.js} +59 -59
- package/dist/serveCommand-BU0wfV6V.js +1931 -0
- package/dist/serveCommand-Bwrn_9Fn.js +2 -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/{test-CHb7UwvE.js → test-rXFq4S76.js} +1 -1
- 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-BqcWcbuW.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 +166 -2
- package/templates/agent-docs/data.md +70 -4
- package/templates/agent-docs/whats-new.md +14 -87
- 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/codegen-DcE2li1i.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,13 +1,13 @@
|
|
|
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 { n as i, s as a, y as o } from "./frameworkTableAssembly-
|
|
4
|
+
import { n as i, s as a, y as o } from "./frameworkTableAssembly-BvZ0Lil_.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";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
8
|
+
import { actorsTable as f, registerCoreTables as p } from "@voltro/database";
|
|
9
|
+
import { Effect as m } from "effect";
|
|
10
|
+
import { runMigrate as h } from "@voltro/database/sql";
|
|
11
11
|
import { FileSystem as g } from "@effect/platform";
|
|
12
12
|
//#region src/migrate.ts
|
|
13
13
|
var _ = /* @__PURE__ */ new Set([
|
|
@@ -18,58 +18,58 @@ var _ = /* @__PURE__ */ new Set([
|
|
|
18
18
|
".vite",
|
|
19
19
|
".next",
|
|
20
20
|
".git"
|
|
21
|
-
]), v = /\.entity\.ts$|\.schema\.ts$|^schema\.ts$/, y = (e) =>
|
|
22
|
-
let t = yield* g.FileSystem, n = [], r = (e) =>
|
|
23
|
-
let i = yield* t.readDirectory(e).pipe(
|
|
21
|
+
]), v = /\.entity\.ts$|\.schema\.ts$|^schema\.ts$/, y = (e) => m.gen(function* () {
|
|
22
|
+
let t = yield* g.FileSystem, n = [], r = (e) => m.gen(function* () {
|
|
23
|
+
let i = yield* t.readDirectory(e).pipe(m.orElseSucceed(() => []));
|
|
24
24
|
for (let a of i) {
|
|
25
25
|
if (_.has(a)) continue;
|
|
26
|
-
let i = c(e, a), o = yield* t.stat(i).pipe(
|
|
26
|
+
let i = c(e, a), o = yield* t.stat(i).pipe(m.orElseSucceed(() => null));
|
|
27
27
|
o && (o.type === "Directory" ? yield* r(i) : o.type === "File" && v.test(a) && n.push(i));
|
|
28
28
|
}
|
|
29
29
|
});
|
|
30
30
|
return yield* r(e), n;
|
|
31
|
-
}), b = (e) => typeof e == "object" && !!e && "tableName" in e && "fields" in e && "isReactive" in e && typeof e.tableName == "string", x = (e) =>
|
|
31
|
+
}), b = (e) => typeof e == "object" && !!e && "tableName" in e && "fields" in e && "isReactive" in e && typeof e.tableName == "string", x = (e) => m.gen(function* () {
|
|
32
32
|
let t = [];
|
|
33
33
|
for (let n of e) {
|
|
34
|
-
let e = yield*
|
|
34
|
+
let e = yield* m.promise(() => import(d(n).href));
|
|
35
35
|
for (let n of Object.values(e)) b(n) && t.push(n);
|
|
36
36
|
}
|
|
37
37
|
return t;
|
|
38
|
-
}), S = (e) =>
|
|
39
|
-
yield*
|
|
38
|
+
}), S = (e) => m.gen(function* () {
|
|
39
|
+
yield* m.logInfo("starting migration", { root: e });
|
|
40
40
|
let t = yield* y(e);
|
|
41
|
-
if (t.length === 0) return yield*
|
|
41
|
+
if (t.length === 0) return yield* m.logError("no schema files found", {
|
|
42
42
|
hint: "looked for *.entity.ts / *.schema.ts / schema.ts under the project root",
|
|
43
43
|
root: e
|
|
44
44
|
}), 1;
|
|
45
|
-
yield*
|
|
46
|
-
let n = yield* x(t), r = yield*
|
|
47
|
-
if (yield*
|
|
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(() => i({ root: e })), s = [...n, ...r];
|
|
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)
|
|
50
|
-
}), s.length === 0) return yield*
|
|
51
|
-
s.some((e) => e.tableName === "actors") || (s = [
|
|
50
|
+
}), s.length === 0) return yield* m.logWarning("no table descriptors discovered, nothing to apply"), 0;
|
|
51
|
+
s.some((e) => e.tableName === "actors") || (s = [f, ...s]);
|
|
52
52
|
let c = new Map(s.map((e) => [e.tableName, e])), u = c.get("actors"), d = c.get("tenants");
|
|
53
|
-
(u !== void 0 || d !== void 0) &&
|
|
53
|
+
(u !== void 0 || d !== void 0) && p({
|
|
54
54
|
...u === void 0 ? {} : { actors: () => u },
|
|
55
55
|
...d === void 0 ? {} : { tenants: () => d }
|
|
56
56
|
});
|
|
57
|
-
let g = yield*
|
|
58
|
-
yield*
|
|
59
|
-
let v = yield*
|
|
57
|
+
let g = yield* m.promise(() => w()), _ = g.makeSqlLayer(C());
|
|
58
|
+
yield* m.promise(() => h(s, _, g.id, { retryFilter: g.retryFilter }));
|
|
59
|
+
let v = yield* m.promise(() => a(e)), b = [], S = yield* o(v, (e, t) => {
|
|
60
60
|
b.push({
|
|
61
61
|
message: e,
|
|
62
62
|
fields: t ?? {}
|
|
63
63
|
});
|
|
64
|
-
}).pipe(
|
|
64
|
+
}).pipe(m.provide(_), m.match({
|
|
65
65
|
onFailure: (e) => e,
|
|
66
66
|
onSuccess: () => void 0
|
|
67
67
|
}));
|
|
68
|
-
for (let e of b) yield*
|
|
69
|
-
return S === void 0 ? (yield*
|
|
68
|
+
for (let e of b) yield* m.logInfo(e.message, e.fields);
|
|
69
|
+
return S === void 0 ? (yield* m.logInfo(`applied ${s.length} table(s) to ${g.id}`, {
|
|
70
70
|
count: s.length,
|
|
71
71
|
dialect: g.id
|
|
72
|
-
}), 0) : (yield*
|
|
72
|
+
}), 0) : (yield* m.logError("a plugin migration FAILED — the tables were created, the plugin steps were not", { error: S instanceof Error ? S.message : String(S) }), 1);
|
|
73
73
|
}), C = () => (r() && console.warn("voltro migrate: no DB_URL/DB_HOST set — defaulting to postgres://app@localhost:5432/app"), n("migration")), w = async () => {
|
|
74
74
|
let n = (process.env.DB_DIALECT ?? "postgres").toLowerCase();
|
|
75
75
|
if (n === "memory") throw new e("voltro migrate: cannot migrate against an in-memory store. Set DB_DIALECT to one of: postgres, sqlite, mysql, mariadb, mssql, turso.");
|
|
@@ -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-BUD4Fd8v.js");
|
|
83
83
|
return t(["apply", ...e]);
|
|
84
84
|
};
|
|
85
85
|
//#endregion
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as e } from "./apiBuild-
|
|
1
|
+
import { n as e } from "./apiBuild-FpHCWiv6.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";
|
|
@@ -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-B2Fw73lu.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,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 ?? "",
|