@voltro/cli 0.20.2 → 0.21.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.
Files changed (64) hide show
  1. package/CHANGELOG.md +149 -0
  2. package/THIRD-PARTY-NOTICES.md +61 -61
  3. package/dist/{apiBuild-qZBEu59d.js → apiBuild-BHOtsQkp.js} +93 -80
  4. package/dist/apiBuild-K7M6Rt0U.js +2 -0
  5. package/dist/bin.js +41 -20
  6. package/dist/{commands-kYbfVoPO.js → commands-BZoimvvS.js} +2752 -2633
  7. package/dist/{dbCommand-BPp9R0Wc.js → dbCommand-CDBbZ-Ac.js} +27 -13
  8. package/dist/dbCommand-oADAj6ez.js +2 -0
  9. package/dist/dev-CZQ73Yoh.js +3 -0
  10. package/dist/{dev-OHLsAq4K.js → dev-DKb92NYX.js} +1537 -1527
  11. package/dist/index.js +1 -1
  12. package/dist/{inspectMetrics-DvPNXmGA.js → inspectMetrics-DMjWBQif.js} +576 -567
  13. package/dist/serveCommand-qHJCs0cX.js +1162 -0
  14. package/dist/serveEntry.js +2 -2
  15. package/dist/{start-CXQ7WL1W.js → start-B1x6Z60h.js} +389 -389
  16. package/dist/startEntry.js +2 -2
  17. package/package.json +27 -27
  18. package/templates/AGENTS.md +1 -1
  19. package/templates/agent-docs/_index.md +1 -1
  20. package/templates/agent-docs/cli.md +63 -0
  21. package/templates/agent-docs/database/migrations.md +33 -11
  22. package/templates/agent-docs/database/schema.md +7 -0
  23. package/templates/agent-docs/database/seedsdialects.md +3 -3
  24. package/templates/agent-docs/whats-new.md +136 -9
  25. package/templates/apps/api-ai/package.json +12 -12
  26. package/templates/apps/api-auth/package.json +13 -13
  27. package/templates/apps/api-backend/package.json +12 -12
  28. package/templates/apps/api-backend-deactivation/package.json +12 -12
  29. package/templates/apps/api-backend-mail/package.json +11 -11
  30. package/templates/apps/api-backend-mariadb/package.json +14 -14
  31. package/templates/apps/api-backend-storage/package.json +11 -11
  32. package/templates/apps/api-data-advanced/package.json +13 -13
  33. package/templates/apps/api-durable/package.json +13 -13
  34. package/templates/apps/api-feature-flags/package.json +14 -14
  35. package/templates/apps/api-governance/package.json +13 -13
  36. package/templates/apps/api-kv/package.json +13 -13
  37. package/templates/apps/api-moderation/package.json +13 -13
  38. package/templates/apps/api-observability/package.json +13 -13
  39. package/templates/apps/api-ratelimit/package.json +13 -13
  40. package/templates/apps/api-rbac/package.json +13 -13
  41. package/templates/apps/api-rest/package.json +12 -12
  42. package/templates/apps/api-saas/package.json +16 -16
  43. package/templates/apps/api-search/package.json +13 -13
  44. package/templates/apps/api-versioning/package.json +13 -13
  45. package/templates/apps/api-webhooks/package.json +14 -14
  46. package/templates/apps/changelog/package.json +8 -8
  47. package/templates/apps/edge-functions/package.json +5 -5
  48. package/templates/apps/frontend-admin/package.json +10 -10
  49. package/templates/apps/frontend-app/package.json +10 -10
  50. package/templates/apps/frontend-blank/package.json +9 -9
  51. package/templates/apps/frontend-contact/package.json +11 -11
  52. package/templates/apps/frontend-dashboard/package.json +9 -9
  53. package/templates/apps/frontend-docs/package.json +9 -9
  54. package/templates/apps/frontend-i18n/package.json +8 -8
  55. package/templates/apps/frontend-landing/package.json +9 -9
  56. package/templates/apps/frontend-spa/package.json +9 -9
  57. package/templates/apps/frontend-ssr/package.json +9 -9
  58. package/templates/apps/frontend-ssr-api/package.json +10 -10
  59. package/templates/apps/frontend-static-blog/package.json +8 -8
  60. package/dist/apiBuild-C9aHz4Yh.js +0 -2
  61. package/dist/dbCommand-DtUe-0dM.js +0 -2
  62. package/dist/dev-2AvdzDg2.js +0 -3
  63. package/dist/serveCommand-BKqTKWTX.js +0 -1136
  64. /package/templates/patches/{@effect__cluster@0.59.0.patch → @effect__cluster@0.60.0.patch} +0 -0
@@ -638,7 +638,7 @@ var O = class extends Error {
638
638
  X(u);
639
639
  let d = q(u), f = d.plan;
640
640
  if (f.summary.blocked > 0 && !d.acknowledged) return I.error(`db apply: refusing — ${f.summary.blocked} blocked operation(s). See the fix hints above.`), process.env.VOLTRO_DESTRUCTIVE_OK !== void 0 && (I.error(" VOLTRO_DESTRUCTIVE_OK is set but did not cover this plan — it only relaxes"), I.error(" `lossy` operations, and only the tables it names. Anything else stays refused.")), 2;
641
- if (d.acknowledged && I.warn(`db apply: proceeding with ${u.summary.blocked} acknowledged lossy operation(s) (VOLTRO_DESTRUCTIVE_OK)`), f.operations.length === 0) return I.info("db apply: schema is up to date — nothing to apply"), 0;
641
+ if (d.acknowledged && I.warn(`db apply: proceeding with ${u.summary.blocked} acknowledged lossy operation(s) (VOLTRO_DESTRUCTIVE_OK)`), f.operations.length === 0) return I.info("db apply: schema is up to date — nothing to apply"), await Ae(l), 0;
642
642
  let p = c(e, "--note"), m = await J(l, y.SqlClient.pipe(h.flatMap((e) => S(e, f, {
643
643
  declared: s,
644
644
  appliedBy: process.env.USER ? `cli:${process.env.USER}` : "cli:user",
@@ -671,9 +671,9 @@ var O = class extends Error {
671
671
  for (let e of n) {
672
672
  let t = 0;
673
673
  try {
674
- t = JSON.parse(Ae(e.operations)).length;
674
+ t = JSON.parse(Q(e.operations)).length;
675
675
  } catch {}
676
- console.log(` ${e.id} fp=${D(e.fingerprint)} env=${e.environment} src=${e.source} ${t} op(s) ${e.durationMs}ms ${Q(e.appliedAt)} by=${e.appliedBy}`), e.notes && console.log(` [2mnote: ${e.notes}[0m`);
676
+ console.log(` ${e.id} fp=${D(e.fingerprint)} env=${e.environment} src=${e.source} ${t} op(s) ${e.durationMs}ms ${$(e.appliedAt)} by=${e.appliedBy}`), e.notes && console.log(` [2mnote: ${e.notes}[0m`);
677
677
  }
678
678
  return console.log(), 0;
679
679
  }, De = async (e) => {
@@ -684,7 +684,7 @@ var O = class extends Error {
684
684
  if (r.length === 0) return console.error(`restore-snapshot: plan '${t}' not found`), 1;
685
685
  let i;
686
686
  try {
687
- i = JSON.parse(Ae(r[0].operations));
687
+ i = JSON.parse(Q(r[0].operations));
688
688
  } catch {
689
689
  return console.error(`restore-snapshot: plan '${t}' has corrupted operations JSON`), 1;
690
690
  }
@@ -776,16 +776,30 @@ var O = class extends Error {
776
776
  } catch (e) {
777
777
  return console.error(`squash refused: ${e.message}`), 1;
778
778
  }
779
- }, Ae = (e) => typeof e == "string" ? e : e == null ? "" : JSON.stringify(e), Q = (e) => e instanceof Date ? e.toISOString() : String(e ?? ""), je = async (e) => {
779
+ }, Ae = async (e) => {
780
+ try {
781
+ let t = w(await Y(e));
782
+ await J(e, y.SqlClient.pipe(h.flatMap((e) => e`
783
+ UPDATE ${e("_voltro_migration_plans")}
784
+ SET ${e("liveFingerprint")} = ${t}
785
+ WHERE ${e("id")} = (
786
+ SELECT ${e("id")} FROM (
787
+ SELECT ${e("id")} FROM ${e("_voltro_migration_plans")}
788
+ ORDER BY ${e("appliedAt")} DESC LIMIT 1
789
+ ) AS ${e("newest")}
790
+ )
791
+ AND ${e("liveFingerprint")} IS NULL
792
+ `)));
793
+ } catch {}
794
+ }, Q = (e) => typeof e == "string" ? e : e == null ? "" : JSON.stringify(e), $ = (e) => e instanceof Date ? e.toISOString() : String(e ?? ""), je = async (e) => {
780
795
  let t = await U(), n = await J(t, y.SqlClient.pipe(h.flatMap((e) => e`
781
- SELECT ${e("id")}, ${e("fingerprint")}, ${e("liveFingerprint")}, ${e("appliedAt")}
782
- FROM ${e("_voltro_migration_plans")}
796
+ SELECT * FROM ${e("_voltro_migration_plans")}
783
797
  ORDER BY ${e("appliedAt")} DESC
784
798
  LIMIT 1
785
799
  `))), r = w(await Y(t));
786
800
  if (n.length === 0) return I.info("db drift: no _voltro_migration_plans rows yet"), console.log(`live user-schema fingerprint: ${D(r)}`), console.log("No baseline to compare against. Run `voltro db apply` to lock in the current state."), 0;
787
801
  let i = n[0];
788
- return i.liveFingerprint === null || i.liveFingerprint === void 0 ? (I.warn("db drift: no drift baseline recorded yet — cannot compare"), console.log(), console.log(` last applied: ${i.id} at ${Q(i.appliedAt)}`), console.log(` live now: ${D(r)}`), console.log(), console.log("That row was written before the framework recorded a live-schema baseline,"), console.log("and the value it does carry is the DECLARED snapshot's hash — not comparable"), console.log("with a live one. Run `voltro db apply` once to establish the baseline; use"), console.log("`voltro db plan` in the meantime, which compares declared against live directly."), 0) : i.liveFingerprint === r ? (I.info(`db drift: live matches last applied (${D(r)})`), 0) : (I.error("db drift: live schema DIVERGED from last applied state"), console.log(), console.log(` baseline: ${D(i.liveFingerprint)} at ${Q(i.appliedAt)} (${i.id})`), console.log(` live now: ${D(r)}`), console.log(), console.log("Something changed the live schema after the last apply. This command can see"), console.log("THAT it changed, not what or who — the fingerprints are hashes, not a diff."), console.log(), console.log("Run `voltro db plan` for the actual difference against your declared schema."), console.log("If it reports 0 operations, the change is in a table your code does not declare"), console.log("(a framework table after an upgrade, or something created outside the framework)."), 4);
802
+ return i.liveFingerprint === null || i.liveFingerprint === void 0 ? (I.warn("db drift: no drift baseline recorded yet — cannot compare"), console.log(), console.log(` last applied: ${i.id} at ${$(i.appliedAt)}`), console.log(` live now: ${D(r)}`), console.log(), console.log("That row was written before the framework recorded a live-schema baseline,"), console.log("and the value it does carry is the DECLARED snapshot's hash — not comparable"), console.log("with a live one. Run `voltro db apply` once to establish the baseline (a no-op"), console.log("apply backfills it too); use `voltro db plan` meanwhile, which compares declared"), console.log("against live directly."), console.log(), console.log("Exit code 3 — NOT 0. \"Did not compare\" is not \"clean\", and a gate on the exit"), console.log("code has to be able to tell them apart."), 3) : i.liveFingerprint === r ? (I.info(`db drift: live matches last applied (${D(r)})`), 0) : (I.error("db drift: live schema DIVERGED from last applied state"), console.log(), console.log(` baseline: ${D(i.liveFingerprint)} at ${$(i.appliedAt)} (${i.id})`), console.log(` live now: ${D(r)}`), console.log(), console.log("Something changed the live schema after the last apply. This command can see"), console.log("THAT it changed, not what or who — the fingerprints are hashes, not a diff."), console.log(), console.log("Run `voltro db plan` for the actual difference against your declared schema."), console.log("If it reports 0 operations, the change is in a table your code does not declare"), console.log("(a framework table after an upgrade, or something created outside the framework)."), 4);
789
803
  }, Me = async (e) => {
790
804
  let t = R(e), n = await U(), r = (process.env.NODE_ENV ?? "").toLowerCase() === "production" ? "prod" : (process.env.NODE_ENV ?? "").toLowerCase() === "staging" ? "staging" : "dev";
791
805
  await J(n, C(b, H()));
@@ -849,7 +863,7 @@ export default defineMigration({
849
863
  }),
850
864
  ],
851
865
  })
852
- `, $ = {
866
+ `, Le = {
853
867
  plan: Ce,
854
868
  apply: Te,
855
869
  plans: Ee,
@@ -867,14 +881,14 @@ export default defineMigration({
867
881
  squash: ke,
868
882
  "restore-snapshot": De,
869
883
  "gc-snapshots": Oe
870
- }, Le = async (e) => {
884
+ }, Re = async (e) => {
871
885
  let [t, ...n] = e;
872
886
  if (!t) {
873
887
  console.error("voltro db <subcommand> [args]"), console.error("subcommands:");
874
- for (let e of Object.keys($)) console.error(` ${e}`);
888
+ for (let e of Object.keys(Le)) console.error(` ${e}`);
875
889
  return 1;
876
890
  }
877
- let r = $[t];
891
+ let r = Le[t];
878
892
  if (!r) return console.error(`voltro db: unknown subcommand '${t}'`), 2;
879
893
  (process.env.DB_DIRECT_URL !== void 0 || process.env.DB_MIGRATE_URL !== void 0) && I.info("using a DIRECT (non-pooler) connection for the db-command path (DB_DIRECT_URL/DB_MIGRATE_URL set)");
880
894
  let i = (e) => {
@@ -888,4 +902,4 @@ export default defineMigration({
888
902
  }
889
903
  };
890
904
  //#endregion
891
- export { B as a, de as c, G as i, z as n, Le as o, W as r, O as s, V as t };
905
+ export { B as a, de as c, G as i, z as n, Re as o, W as r, O as s, V as t };
@@ -0,0 +1,2 @@
1
+ import { o as e } from "./dbCommand-CDBbZ-Ac.js";
2
+ export { e as runDbCommand };
@@ -0,0 +1,3 @@
1
+ import "./seedRunner-D6eu-u5U.js";
2
+ import { c as e, m as t, u as n } from "./dev-DKb92NYX.js";
3
+ export { e as loadApiConfig, n as loadDiscovered, t as walk };