@prisma-next/cli 0.15.0 → 0.16.0-dev.10

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 (177) hide show
  1. package/README.md +3 -4
  2. package/dist/cli.d.mts +1 -1
  3. package/dist/cli.mjs +13 -13
  4. package/dist/{client-DigVI8zX.mjs → client-2kwLMBSf.mjs} +67 -36
  5. package/dist/client-2kwLMBSf.mjs.map +1 -0
  6. package/dist/{command-helpers-CUoKYTlG.mjs → command-helpers-CVn3U9Uz.mjs} +32 -8
  7. package/dist/command-helpers-CVn3U9Uz.mjs.map +1 -0
  8. package/dist/commands/contract-emit.d.mts +0 -1
  9. package/dist/commands/contract-emit.d.mts.map +1 -1
  10. package/dist/commands/contract-emit.mjs +1 -1
  11. package/dist/commands/contract-infer.d.mts +0 -1
  12. package/dist/commands/contract-infer.d.mts.map +1 -1
  13. package/dist/commands/contract-infer.mjs +1 -1
  14. package/dist/commands/db-init.d.mts +0 -1
  15. package/dist/commands/db-init.d.mts.map +1 -1
  16. package/dist/commands/db-init.mjs +8 -7
  17. package/dist/commands/db-init.mjs.map +1 -1
  18. package/dist/commands/db-schema.d.mts +0 -1
  19. package/dist/commands/db-schema.d.mts.map +1 -1
  20. package/dist/commands/db-schema.mjs +3 -3
  21. package/dist/commands/db-sign.d.mts +0 -1
  22. package/dist/commands/db-sign.d.mts.map +1 -1
  23. package/dist/commands/db-sign.mjs +8 -10
  24. package/dist/commands/db-sign.mjs.map +1 -1
  25. package/dist/commands/db-update.d.mts +0 -1
  26. package/dist/commands/db-update.d.mts.map +1 -1
  27. package/dist/commands/db-update.mjs +12 -14
  28. package/dist/commands/db-update.mjs.map +1 -1
  29. package/dist/commands/db-verify.d.mts +0 -1
  30. package/dist/commands/db-verify.d.mts.map +1 -1
  31. package/dist/commands/db-verify.mjs +1 -1
  32. package/dist/commands/migrate.d.mts +1 -2
  33. package/dist/commands/migrate.d.mts.map +1 -1
  34. package/dist/commands/migrate.mjs +7 -7
  35. package/dist/commands/migrate.mjs.map +1 -1
  36. package/dist/commands/migration-check.d.mts +4 -3
  37. package/dist/commands/migration-check.d.mts.map +1 -1
  38. package/dist/commands/migration-check.mjs +1 -1
  39. package/dist/commands/migration-graph.d.mts +2 -3
  40. package/dist/commands/migration-graph.d.mts.map +1 -1
  41. package/dist/commands/migration-graph.mjs +3 -3
  42. package/dist/commands/migration-list.d.mts +2 -3
  43. package/dist/commands/migration-list.d.mts.map +1 -1
  44. package/dist/commands/migration-list.mjs +1 -1
  45. package/dist/commands/migration-log.d.mts +2 -3
  46. package/dist/commands/migration-log.d.mts.map +1 -1
  47. package/dist/commands/migration-log.mjs +1 -1
  48. package/dist/commands/migration-new.d.mts +0 -1
  49. package/dist/commands/migration-new.d.mts.map +1 -1
  50. package/dist/commands/migration-new.mjs +14 -38
  51. package/dist/commands/migration-new.mjs.map +1 -1
  52. package/dist/commands/migration-plan.d.mts +0 -1
  53. package/dist/commands/migration-plan.d.mts.map +1 -1
  54. package/dist/commands/migration-plan.mjs +1 -1
  55. package/dist/commands/migration-show.d.mts +0 -1
  56. package/dist/commands/migration-show.d.mts.map +1 -1
  57. package/dist/commands/migration-show.mjs +3 -3
  58. package/dist/commands/migration-status.d.mts +2 -3
  59. package/dist/commands/migration-status.d.mts.map +1 -1
  60. package/dist/commands/migration-status.mjs +1 -1
  61. package/dist/commands/ref.d.mts +1 -2
  62. package/dist/commands/ref.d.mts.map +1 -1
  63. package/dist/commands/ref.mjs +13 -18
  64. package/dist/commands/ref.mjs.map +1 -1
  65. package/dist/commands/telemetry/index.d.mts +0 -1
  66. package/dist/commands/telemetry/index.d.mts.map +1 -1
  67. package/dist/commands/telemetry/index.mjs +1 -1
  68. package/dist/contract-at-errors-C-l4-JEY.mjs +36 -0
  69. package/dist/contract-at-errors-C-l4-JEY.mjs.map +1 -0
  70. package/dist/{contract-emit-wgqrOXUI.mjs → contract-emit-DzOkTs11.mjs} +3 -3
  71. package/dist/{contract-emit-wgqrOXUI.mjs.map → contract-emit-DzOkTs11.mjs.map} +1 -1
  72. package/dist/{contract-emit-sYrqzsdN.mjs → contract-emit-iSMJVs26.mjs} +3 -3
  73. package/dist/{contract-emit-sYrqzsdN.mjs.map → contract-emit-iSMJVs26.mjs.map} +1 -1
  74. package/dist/{contract-infer-6SQnnVj7.mjs → contract-infer-BVqworBB.mjs} +3 -3
  75. package/dist/{contract-infer-6SQnnVj7.mjs.map → contract-infer-BVqworBB.mjs.map} +1 -1
  76. package/dist/{contract-space-aggregate-loader-DpB4x97a.mjs → contract-space-aggregate-loader-hPVymNLw.mjs} +14 -15
  77. package/dist/contract-space-aggregate-loader-hPVymNLw.mjs.map +1 -0
  78. package/dist/{db-verify-CEsG5Gek.mjs → db-verify-BpwCMyWJ.mjs} +6 -7
  79. package/dist/db-verify-BpwCMyWJ.mjs.map +1 -0
  80. package/dist/exports/control-api.d.mts +1 -2
  81. package/dist/exports/control-api.d.mts.map +1 -1
  82. package/dist/exports/control-api.mjs +2 -2
  83. package/dist/exports/index.d.mts +0 -1
  84. package/dist/exports/index.d.mts.map +1 -1
  85. package/dist/exports/index.mjs +2 -2
  86. package/dist/exports/init-output.d.mts +1 -0
  87. package/dist/exports/init-output.d.mts.map +1 -1
  88. package/dist/exports/init-output.mjs +1 -1
  89. package/dist/{format-CjongNb1.mjs → format-CFLZv_zU.mjs} +6 -5
  90. package/dist/format-CFLZv_zU.mjs.map +1 -0
  91. package/dist/{framework-components-BbnM1RYm.mjs → framework-components-VMQJbAwl.mjs} +2 -2
  92. package/dist/{framework-components-BbnM1RYm.mjs.map → framework-components-VMQJbAwl.mjs.map} +1 -1
  93. package/dist/global-flags-BpoOYtNZ.d.mts.map +1 -1
  94. package/dist/{init-D8YFfaD6.mjs → init-BSgPxVXA.mjs} +85 -90
  95. package/dist/init-BSgPxVXA.mjs.map +1 -0
  96. package/dist/{inspect-live-schema-CEt_ztBJ.mjs → inspect-live-schema-DxsD_a4d.mjs} +3 -3
  97. package/dist/{inspect-live-schema-CEt_ztBJ.mjs.map → inspect-live-schema-DxsD_a4d.mjs.map} +1 -1
  98. package/dist/{migration-check-ByeQHOhK.mjs → migration-check-DMxPzbHl.mjs} +70 -44
  99. package/dist/migration-check-DMxPzbHl.mjs.map +1 -0
  100. package/dist/migration-cli.d.mts +0 -1
  101. package/dist/migration-cli.d.mts.map +1 -1
  102. package/dist/migration-cli.mjs +3 -3
  103. package/dist/migration-cli.mjs.map +1 -1
  104. package/dist/{migration-command-scaffold-CJO3tjiR.mjs → migration-command-scaffold-DB_i9nBC.mjs} +3 -3
  105. package/dist/{migration-command-scaffold-CJO3tjiR.mjs.map → migration-command-scaffold-DB_i9nBC.mjs.map} +1 -1
  106. package/dist/{migration-list-DTYM8xvm.mjs → migration-list-cnSKilYH.mjs} +5 -5
  107. package/dist/migration-list-cnSKilYH.mjs.map +1 -0
  108. package/dist/{migration-log-qZ8LpQIl.mjs → migration-log-CEqFiez9.mjs} +3 -3
  109. package/dist/{migration-log-qZ8LpQIl.mjs.map → migration-log-CEqFiez9.mjs.map} +1 -1
  110. package/dist/{migration-path-target-DmNwsDgs.mjs → migration-path-target-C0TQuV5n.mjs} +2 -2
  111. package/dist/{migration-path-target-DmNwsDgs.mjs.map → migration-path-target-C0TQuV5n.mjs.map} +1 -1
  112. package/dist/{migration-plan-CfPrB80t.mjs → migration-plan-BJHulFZC.mjs} +54 -62
  113. package/dist/migration-plan-BJHulFZC.mjs.map +1 -0
  114. package/dist/{migration-status-DRuS-rP5.mjs → migration-status-ugWwGk1V.mjs} +5 -5
  115. package/dist/{migration-status-DRuS-rP5.mjs.map → migration-status-ugWwGk1V.mjs.map} +1 -1
  116. package/dist/{output-mEQ74_nd.mjs → output-DWNYqZGc.mjs} +5 -6
  117. package/dist/output-DWNYqZGc.mjs.map +1 -0
  118. package/dist/{ref-advancement-BkXlikCA.mjs → ref-advancement-BCz7X7qJ.mjs} +13 -6
  119. package/dist/ref-advancement-BCz7X7qJ.mjs.map +1 -0
  120. package/dist/schemas-CeGMYFYX.d.mts.map +1 -1
  121. package/dist/{telemetry-DHBBq5wT.mjs → telemetry-BEyNMfco.mjs} +2 -2
  122. package/dist/{telemetry-DHBBq5wT.mjs.map → telemetry-BEyNMfco.mjs.map} +1 -1
  123. package/dist/{terminal-ui-DGRNFWna.d.mts → terminal-ui-BN4QOsm5.d.mts} +1 -2
  124. package/dist/terminal-ui-BN4QOsm5.d.mts.map +1 -0
  125. package/dist/{types-DFoqNIcQ.d.mts → types-D4r_HI9-.d.mts} +8 -4
  126. package/dist/types-D4r_HI9-.d.mts.map +1 -0
  127. package/dist/{verify-DDCb0R2r.mjs → verify-C4RazDE1.mjs} +9 -8
  128. package/dist/verify-C4RazDE1.mjs.map +1 -0
  129. package/package.json +25 -25
  130. package/src/commands/db-init.ts +4 -3
  131. package/src/commands/db-sign.ts +6 -4
  132. package/src/commands/db-update.ts +15 -7
  133. package/src/commands/db-verify.ts +2 -3
  134. package/src/commands/init/errors.ts +62 -58
  135. package/src/commands/init/hygiene-gitattributes.ts +37 -21
  136. package/src/commands/init/init.ts +35 -32
  137. package/src/commands/init/output.ts +4 -5
  138. package/src/commands/init/reinit-cleanup.ts +16 -17
  139. package/src/commands/migrate.ts +1 -0
  140. package/src/commands/migration-check.ts +75 -38
  141. package/src/commands/migration-list.ts +1 -5
  142. package/src/commands/migration-new.ts +15 -39
  143. package/src/commands/migration-plan.ts +56 -78
  144. package/src/commands/ref.ts +19 -14
  145. package/src/control-api/operations/db-run.ts +4 -4
  146. package/src/control-api/operations/db-verify.ts +12 -9
  147. package/src/control-api/operations/format.ts +4 -3
  148. package/src/control-api/operations/migrate.ts +70 -26
  149. package/src/control-api/types.ts +4 -1
  150. package/src/migration-cli.ts +5 -5
  151. package/src/utils/cli-errors.ts +28 -7
  152. package/src/utils/combine-verify-results.ts +1 -1
  153. package/src/utils/contract-at-errors.ts +13 -22
  154. package/src/utils/contract-space-aggregate-loader.ts +12 -13
  155. package/src/utils/contract-space-seed-phase.ts +8 -6
  156. package/src/utils/formatters/errors.ts +24 -3
  157. package/src/utils/formatters/verify.ts +7 -6
  158. package/src/utils/integrity-violation-to-check-failure.ts +14 -14
  159. package/src/utils/plan-resolution.ts +6 -9
  160. package/src/utils/ref-advancement.ts +22 -3
  161. package/src/utils/result-handler.ts +4 -2
  162. package/dist/client-DigVI8zX.mjs.map +0 -1
  163. package/dist/command-helpers-CUoKYTlG.mjs.map +0 -1
  164. package/dist/contract-at-errors-D8CNDD7g.mjs +0 -42
  165. package/dist/contract-at-errors-D8CNDD7g.mjs.map +0 -1
  166. package/dist/contract-space-aggregate-loader-DpB4x97a.mjs.map +0 -1
  167. package/dist/db-verify-CEsG5Gek.mjs.map +0 -1
  168. package/dist/format-CjongNb1.mjs.map +0 -1
  169. package/dist/init-D8YFfaD6.mjs.map +0 -1
  170. package/dist/migration-check-ByeQHOhK.mjs.map +0 -1
  171. package/dist/migration-list-DTYM8xvm.mjs.map +0 -1
  172. package/dist/migration-plan-CfPrB80t.mjs.map +0 -1
  173. package/dist/output-mEQ74_nd.mjs.map +0 -1
  174. package/dist/ref-advancement-BkXlikCA.mjs.map +0 -1
  175. package/dist/terminal-ui-DGRNFWna.d.mts.map +0 -1
  176. package/dist/types-DFoqNIcQ.d.mts.map +0 -1
  177. package/dist/verify-DDCb0R2r.mjs.map +0 -1
@@ -1,14 +1,16 @@
1
1
  import { CliStructuredError as CliStructuredError$1 } from "@prisma-next/errors/control";
2
2
  import { Result } from "@prisma-next/utils/result";
3
3
  import { ControlAdapterDescriptor, ControlDriverDescriptor, ControlDriverInstance, ControlExtensionDescriptor, ControlFamilyDescriptor, ControlFamilyInstance, ControlTargetDescriptor, CoreSchemaView, MigrationPlanOperation, MigrationPlannerConflict, OperationPreview, SignDatabaseResult, VerifyDatabaseResult, VerifyDatabaseSchemaResult } from "@prisma-next/framework-components/control";
4
+ import "@prisma-next/errors/execution";
5
+ import "@prisma-next/errors/migration";
4
6
  import { TargetBoundComponentDescriptor } from "@prisma-next/framework-components/components";
5
7
  import { AggregateContractSpace } from "@prisma-next/migration-tools/aggregate";
6
8
  import { MigrationToolsError } from "@prisma-next/migration-tools/errors";
7
9
  import { ContractSourceDiagnostics, ContractSourceProvider } from "@prisma-next/config/config-types";
10
+ import "@prisma-next/migration-tools/ref-resolution";
8
11
  import { Contract, ContractMarkerRecord, LedgerEntryRecord } from "@prisma-next/contract/types";
9
12
  import { AuthoringPslBlockDescriptorNamespace } from "@prisma-next/framework-components/authoring";
10
13
  import { PslDocumentAst } from "@prisma-next/framework-components/psl-ast";
11
-
12
14
  //#region src/control-api/operations/db-verify.d.ts
13
15
  /**
14
16
  * Inputs for the aggregate `db verify` operation.
@@ -404,7 +406,7 @@ interface DbInitSuccess {
404
406
  /**
405
407
  * Failure codes for dbInit operation.
406
408
  */
407
- type DbInitFailureCode = 'PLANNING_FAILED' | 'MARKER_ORIGIN_MISMATCH' | 'RUNNER_FAILED';
409
+ type DbInitFailureCode = 'PLANNING_FAILED' | 'MIGRATION.MARKER_ORIGIN_MISMATCH' | 'RUNNER_FAILED';
408
410
  /**
409
411
  * Failure details for dbInit operation.
410
412
  */
@@ -698,7 +700,9 @@ interface ContractEmitResult {
698
700
  readonly profileHash: string;
699
701
  /** Paths to the emitted files */
700
702
  readonly files: {
701
- /** Path to the emitted contract.json file */readonly json: string; /** Path to the emitted contract.d.ts file */
703
+ /** Path to the emitted contract.json file */
704
+ readonly json: string;
705
+ /** Path to the emitted contract.d.ts file */
702
706
  readonly dts: string;
703
707
  };
704
708
  /**
@@ -887,4 +891,4 @@ interface ControlClient {
887
891
  }
888
892
  //#endregion
889
893
  export { ExecuteDbVerifyOptions as A, IntrospectOptions as C, SchemaVerifyOptions as D, PerSpaceExecutionEntry as E, executeDbVerify as M, CliStructuredError$1 as N, SignOptions as O, EmitSuccess as S, OnControlProgress as T, EmitContractConfig as _, ControlClientOptions as a, EmitOptions as b, DbInitFailureCode as c, DbInitSuccess as d, DbUpdateFailure as f, DbUpdateSuccess as g, DbUpdateResult as h, ControlClient as i, ExecuteDbVerifyResult as j, VerifyOptions as k, DbInitOptions as l, DbUpdateOptions as m, ContractEmitResult as n, ControlProgressEvent as o, DbUpdateFailureCode as p, ControlActionName as r, DbInitFailure as s, ContractEmitOptions as t, DbInitResult as u, EmitFailure as v, MigratePathDecision as w, EmitResult as x, EmitFailureCode as y };
890
- //# sourceMappingURL=types-DFoqNIcQ.d.mts.map
894
+ //# sourceMappingURL=types-D4r_HI9-.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types-D4r_HI9-.d.mts","names":[],"sources":["../src/control-api/operations/db-verify.ts","../src/control-api/types.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;UA8CiB,uBAAuB,0BAA0B;WACvD,QAAQ,sBAAsB,WAAW;WACzC,gBAAgB,sBAAsB;WACtC,UAAU;WACV;WACA,UAAU;WACV,gBAAgB,cAAc,2BAA2B,WAAW;WACpE,qBAAqB,cAAc,+BAA+B,WAAW;WAC7E;WACA;WACA;WACA,aAAa;;;;;;;;;;;;;;UAeP;WACN,eAAe,oBAAoB;;;;;;WAMnC;WACA;WACA;;KAGC,wBAAwB,OAAO,wBAAwB;;;;;;;;;;;;;;;;;iBAkB7C,gBAAgB,0BAA0B,0BAC9D,SAAS,uBAAuB,WAAW,aAC1C,QAAQ;;;;;;;;;;;;;;UC7DM;WAEN,QAAQ;WAER,QAAQ;WAER,SAAS;;WAGT,SAAS;WAET,iBAAiB,cAAc;;;;;;WAM/B;;;;;KAUC;;;;;;;;;;;;;;KAwBA;WAEG,QAAQ;WACR;WACA;WACA;WACA;;WAGA,QAAQ;WACR;WACA;WACA;;;;;;;KAQH,qBAAqB,OAAO;;;;UASvB;;WAEN;;;;;;WAMA;;WAEA,aAAa;;;;;UAMP;;WAEN;;;;;;WAMA;;;;;;WAMA;;WAEA,aAAa;;;;;UAMP;;WAEN;;;;WAIA;;;;WAIA;;;;;;WAMA;;WAEA,aAAa;;;;;UAMP;;WAEN;;;;;;WAMA;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ose } from "./command-helpers-CUoKYTlG.mjs";
1
+ import { M as createColorFormatter, N as formatDim, P as isVerbose } from "./command-helpers-CVn3U9Uz.mjs";
2
2
  import { ifDefined } from "@prisma-next/utils/defined";
3
+ import { issueOutcome } from "@prisma-next/framework-components/control";
3
4
  import { bold, cyan, dim, green, magenta, red, yellow } from "colorette";
4
5
  //#region src/utils/formatters/verify.ts
5
- /** Human-readable label for each failure reason, prefixed onto an issue's message for display. */
6
- const REASON_LABEL = {
6
+ /** Human-readable label for each outcome, prefixed onto an issue's message for display. */
7
+ const OUTCOME_LABEL = {
7
8
  "not-found": "missing",
8
9
  "not-expected": "extra",
9
10
  "not-equal": "mismatch"
10
11
  };
11
12
  /**
12
13
  * The issue's display text: its own path, prefixed with a human label for
13
- * why it's flagged. Turning `reason` (and the path) into prose is this
14
- * formatter's job, not the differ's — the differ's issue is data (`path` +
15
- * `reason` + nodes), not prose.
14
+ * why it's flagged. Turning the presence-derived outcome (and the path) into
15
+ * prose is this formatter's job, not the differ's — the differ's issue is
16
+ * data (`path` + nodes), not prose.
16
17
  */
17
18
  function formatIssueMessage(issue) {
18
- return `${REASON_LABEL[issue.reason]}: ${issue.path.join("/")}`;
19
+ return `${OUTCOME_LABEL[issueOutcome(issue)]}: ${issue.path.join("/")}`;
19
20
  }
20
21
  /**
21
22
  * Formats human-readable output for database verify.
@@ -279,4 +280,4 @@ function formatSignJson(result) {
279
280
  //#endregion
280
281
  export { formatSignJson as a, formatVerifyOutput as c, formatSchemaVerifyOutput as i, formatIntrospectOutput as n, formatSignOutput as o, formatSchemaVerifyJson as r, formatVerifyJson as s, formatIntrospectJson as t };
281
282
 
282
- //# sourceMappingURL=verify-DDCb0R2r.mjs.map
283
+ //# sourceMappingURL=verify-C4RazDE1.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verify-C4RazDE1.mjs","names":[],"sources":["../src/utils/formatters/verify.ts"],"sourcesContent":["import type {\n CoreSchemaView,\n ExpectationFailureReason,\n IntrospectSchemaResult,\n SchemaDiffIssue,\n SchemaTreeNode,\n SignDatabaseResult,\n VerifyDatabaseResult,\n VerifyDatabaseSchemaResult,\n} from '@prisma-next/framework-components/control';\nimport { issueOutcome } from '@prisma-next/framework-components/control';\nimport { ifDefined } from '@prisma-next/utils/defined';\nimport { bold, cyan, dim, green, magenta, red, yellow } from 'colorette';\nimport type { GlobalFlags } from '../global-flags';\nimport { createColorFormatter, formatDim, isVerbose } from './helpers';\n\n/** Human-readable label for each outcome, prefixed onto an issue's message for display. */\nconst OUTCOME_LABEL: Record<ExpectationFailureReason, string> = {\n 'not-found': 'missing',\n 'not-expected': 'extra',\n 'not-equal': 'mismatch',\n};\n\n/**\n * The issue's display text: its own path, prefixed with a human label for\n * why it's flagged. Turning the presence-derived outcome (and the path) into\n * prose is this formatter's job, not the differ's — the differ's issue is\n * data (`path` + nodes), not prose.\n */\nfunction formatIssueMessage(issue: SchemaDiffIssue): string {\n return `${OUTCOME_LABEL[issueOutcome(issue)]}: ${issue.path.join('/')}`;\n}\n\n// ============================================================================\n// Verify Output Formatters\n// ============================================================================\n\nexport interface DbVerifyCommandSuccessResult {\n readonly ok: true;\n readonly mode: 'full' | 'marker-only';\n readonly summary: string;\n readonly contract: VerifyDatabaseResult['contract'];\n readonly marker?: VerifyDatabaseResult['marker'];\n readonly target: VerifyDatabaseResult['target'];\n readonly missingCodecs?: VerifyDatabaseResult['missingCodecs'];\n readonly codecCoverageSkipped?: VerifyDatabaseResult['codecCoverageSkipped'];\n readonly schema?: {\n readonly summary: string;\n readonly strict: boolean;\n /**\n * Warn-graded finding messages (observed-policy drift). Informational —\n * present on a passing verify; the full-mode result summarizes them as a\n * flat message list.\n */\n readonly warnings?: readonly string[];\n };\n /**\n * Live element names no contract space declares. In full success this is\n * only ever non-empty in lenient mode — strict mode fails on it — and is\n * rendered informationally.\n */\n readonly unclaimed?: readonly string[];\n readonly warning?: string;\n readonly meta?:\n | (NonNullable<VerifyDatabaseResult['meta']> & {\n readonly schemaVerification: 'performed' | 'skipped';\n })\n | {\n readonly schemaVerification: 'performed' | 'skipped';\n };\n readonly timings: {\n readonly total: number;\n };\n}\n\n/**\n * Formats human-readable output for database verify.\n */\nexport function formatVerifyOutput(\n result: DbVerifyCommandSuccessResult,\n flags: GlobalFlags,\n): string {\n if (flags.quiet) {\n return '';\n }\n\n const lines: string[] = [];\n\n const useColor = flags.color !== false;\n const formatGreen = createColorFormatter(useColor, green);\n const formatYellow = createColorFormatter(useColor, yellow);\n const formatDimText = (text: string) => formatDim(useColor, text);\n const verificationMode =\n result.mode === 'full'\n ? `marker + schema${result.schema?.strict ? ' (strict)' : ' (tolerant)'}`\n : 'marker only (--marker-only)';\n\n lines.push(`${formatGreen('✔')} ${result.summary}`);\n lines.push(`${formatDimText(` verification: ${verificationMode}`)}`);\n lines.push(`${formatDimText(` storageHash: ${result.contract.storageHash}`)}`);\n if (result.contract.profileHash) {\n lines.push(`${formatDimText(` profileHash: ${result.contract.profileHash}`)}`);\n }\n if (result.schema?.warnings && result.schema.warnings.length > 0) {\n lines.push('');\n lines.push(formatYellow('Schema warnings:'));\n for (const message of result.schema.warnings) {\n lines.push(` ${formatYellow('⚠')} ${message}`);\n }\n }\n\n if (result.unclaimed && result.unclaimed.length > 0) {\n lines.push('');\n lines.push(formatYellow('Unclaimed elements (declared by no contract):'));\n for (const name of result.unclaimed) {\n lines.push(` ${formatYellow('⚠')} ${name}`);\n }\n }\n\n if (result.warning) {\n lines.push('');\n lines.push(`${formatYellow('⚠')} ${result.warning}`);\n }\n\n if (isVerbose(flags, 1)) {\n if (result.codecCoverageSkipped) {\n lines.push(\n `${formatDimText(' Codec coverage check skipped (helper returned no supported types)')}`,\n );\n }\n lines.push(`${formatDimText(` Total time: ${result.timings.total}ms`)}`);\n }\n\n return lines.join('\\n');\n}\n\n/**\n * Formats JSON output for database verify.\n */\nexport function formatVerifyJson(result: DbVerifyCommandSuccessResult): string {\n const output = {\n ok: result.ok,\n summary: result.summary,\n mode: result.mode,\n contract: result.contract,\n ...ifDefined('marker', result.marker),\n target: result.target,\n ...ifDefined('missingCodecs', result.missingCodecs),\n ...ifDefined('codecCoverageSkipped', result.codecCoverageSkipped),\n ...ifDefined('schema', result.schema),\n unclaimed: result.unclaimed ?? [],\n ...ifDefined('warning', result.warning),\n ...ifDefined('meta', result.meta),\n timings: result.timings,\n };\n\n return JSON.stringify(output, null, 2);\n}\n\n/**\n * Formats JSON output for database introspection.\n */\nexport function formatIntrospectJson(result: IntrospectSchemaResult<unknown>): string {\n return JSON.stringify(result, null, 2);\n}\n\n/**\n * Renders a schema tree structure from CoreSchemaView.\n * Status-glyph tree styling shared with the retired verification-tree renderer.\n */\nfunction renderSchemaTree(\n node: SchemaTreeNode,\n flags: GlobalFlags,\n options: {\n readonly isLast: boolean;\n readonly prefix: string;\n readonly useColor: boolean;\n readonly formatDimText: (text: string) => string;\n readonly isRoot?: boolean;\n },\n): string[] {\n const { isLast, prefix, useColor, formatDimText, isRoot = false } = options;\n const lines: string[] = [];\n\n // Format node label with color based on kind (matching schema-verify style)\n let formattedLabel: string = node.label;\n\n if (useColor) {\n switch (node.kind) {\n case 'root':\n formattedLabel = bold(node.label);\n break;\n case 'entity': {\n // Parse \"table tableName\" format - color \"table\" dim, tableName cyan\n const tableMatch = node.label.match(/^table\\s+(.+)$/);\n if (tableMatch?.[1]) {\n const tableName = tableMatch[1];\n formattedLabel = `${dim('table')} ${cyan(tableName)}`;\n } else {\n // Fallback: color entire label with cyan\n formattedLabel = cyan(node.label);\n }\n break;\n }\n case 'collection': {\n // \"columns\" grouping node - dim the label\n formattedLabel = dim(node.label);\n break;\n }\n case 'field': {\n // Parse column name format: \"columnName: typeDisplay (nullability)\"\n // Color code: column name (cyan), type (default), nullability (dim)\n const columnMatch = node.label.match(/^([^:]+):\\s*(.+)$/);\n if (columnMatch?.[1] && columnMatch[2]) {\n const columnName = columnMatch[1];\n const rest = columnMatch[2];\n // Parse rest: \"typeDisplay (nullability)\"\n const typeMatch = rest.match(/^([^\\s(]+)\\s*(\\([^)]+\\))$/);\n if (typeMatch?.[1] && typeMatch[2]) {\n const typeDisplay = typeMatch[1];\n const nullability = typeMatch[2];\n formattedLabel = `${cyan(columnName)}: ${typeDisplay} ${dim(nullability)}`;\n } else {\n // Fallback if format doesn't match\n formattedLabel = `${cyan(columnName)}: ${rest}`;\n }\n } else {\n formattedLabel = node.label;\n }\n break;\n }\n case 'index': {\n // Parse index/unique constraint/primary key formats\n // \"primary key: columnName\" -> dim \"primary key\", cyan columnName\n const pkMatch = node.label.match(/^primary key:\\s*(.+)$/);\n if (pkMatch?.[1]) {\n const columnNames = pkMatch[1];\n formattedLabel = `${dim('primary key')}: ${cyan(columnNames)}`;\n } else {\n // \"unique name\" -> dim \"unique\", cyan \"name\"\n const uniqueMatch = node.label.match(/^unique\\s+(.+)$/);\n if (uniqueMatch?.[1]) {\n const name = uniqueMatch[1];\n formattedLabel = `${dim('unique')} ${cyan(name)}`;\n } else {\n // \"index name\" or \"unique index name\" -> dim label prefix, cyan name\n const indexMatch = node.label.match(/^(unique\\s+)?index\\s+(.+)$/);\n if (indexMatch?.[2]) {\n const indexPrefix = indexMatch[1] ? `${dim('unique')} ` : '';\n const name = indexMatch[2];\n formattedLabel = `${indexPrefix}${dim('index')} ${cyan(name)}`;\n } else {\n formattedLabel = dim(node.label);\n }\n }\n }\n break;\n }\n case 'dependency': {\n // Parse extension message formats similar to schema-verify\n // \"extensionName extension is enabled\" -> cyan extensionName, dim rest\n const extMatch = node.label.match(/^([^\\s]+)\\s+(extension is enabled)$/);\n if (extMatch?.[1] && extMatch[2]) {\n const extName = extMatch[1];\n const rest = extMatch[2];\n formattedLabel = `${cyan(extName)} ${dim(rest)}`;\n } else {\n // Fallback: color entire label with magenta\n formattedLabel = magenta(node.label);\n }\n break;\n }\n default:\n formattedLabel = node.label;\n break;\n }\n }\n\n // Root node renders without tree characters or prefix\n if (isRoot) {\n lines.push(formattedLabel);\n } else {\n const treeChar = isLast ? '└' : '├';\n const treePrefix = `${formatDimText(treeChar)}─ `;\n lines.push(`${prefix}${treePrefix}${formattedLabel}`);\n }\n\n // Render children if present\n if (node.children && node.children.length > 0) {\n const childPrefix = isRoot ? '' : `${prefix}${isLast ? ' ' : `${formatDimText('│')} `}`;\n for (let i = 0; i < node.children.length; i++) {\n const child = node.children[i];\n if (!child) continue;\n const isLastChild = i === node.children.length - 1;\n const childLines = renderSchemaTree(child, flags, {\n isLast: isLastChild,\n prefix: childPrefix,\n useColor,\n formatDimText,\n isRoot: false,\n });\n lines.push(...childLines);\n }\n }\n\n return lines;\n}\n\n/**\n * Formats human-readable output for database introspection.\n */\nexport function formatIntrospectOutput(\n result: IntrospectSchemaResult<unknown>,\n schemaView: CoreSchemaView | undefined,\n flags: GlobalFlags,\n): string {\n if (flags.quiet) {\n return '';\n }\n\n const lines: string[] = [];\n\n const useColor = flags.color !== false;\n const formatDimText = (text: string) => formatDim(useColor, text);\n\n if (schemaView) {\n // Render tree structure - root node is special (no tree characters)\n const treeLines = renderSchemaTree(schemaView.root, flags, {\n isLast: true,\n prefix: '',\n useColor,\n formatDimText,\n isRoot: true,\n });\n lines.push(...treeLines);\n } else {\n // Fallback: print summary when toSchemaView is not available\n lines.push(`✔ ${result.summary}`);\n if (isVerbose(flags, 1)) {\n lines.push(` Target: ${result.target.familyId}/${result.target.id}`);\n if (result.meta?.dbUrl) {\n lines.push(` Database: ${result.meta.dbUrl}`);\n }\n }\n }\n\n // Add timings in verbose mode\n if (isVerbose(flags, 1)) {\n lines.push(`${formatDimText(` Total time: ${result.timings.total}ms`)}`);\n }\n\n return lines.join('\\n');\n}\n\n/**\n * Formats human-readable output for database schema verification.\n */\nexport function formatSchemaVerifyOutput(\n result: VerifyDatabaseSchemaResult,\n flags: GlobalFlags,\n unclaimed: readonly string[] = [],\n): string {\n if (flags.quiet) {\n return '';\n }\n\n const lines: string[] = [];\n\n const useColor = flags.color !== false;\n const formatGreen = createColorFormatter(useColor, green);\n const formatRed = createColorFormatter(useColor, red);\n const formatYellow = createColorFormatter(useColor, yellow);\n const formatDimText = (text: string) => formatDim(useColor, text);\n\n const issueMessages = result.schema.issues.map(formatIssueMessage);\n if (issueMessages.length > 0) {\n lines.push(formatRed('Schema issues:'));\n for (const message of issueMessages) {\n lines.push(` ${formatRed('✖')} ${message}`);\n }\n }\n\n const warningMessages = (result.schema.warnings?.issues ?? []).map(formatIssueMessage);\n if (warningMessages.length > 0) {\n if (lines.length > 0) lines.push('');\n lines.push(formatYellow('Schema warnings:'));\n for (const message of warningMessages) {\n lines.push(` ${formatYellow('⚠')} ${message}`);\n }\n }\n\n if (unclaimed.length > 0) {\n const strict = result.meta?.strict ?? false;\n if (lines.length > 0) lines.push('');\n lines.push(\n (strict ? formatRed : formatYellow)('Unclaimed elements (declared by no contract):'),\n );\n for (const name of unclaimed) {\n lines.push(` ${(strict ? formatRed : formatYellow)(strict ? '✖' : '⚠')} ${name}`);\n }\n }\n\n if (isVerbose(flags, 1)) {\n lines.push(`${formatDimText(` Total time: ${result.timings.total}ms`)}`);\n }\n\n // Blank line before summary\n if (lines.length > 0) lines.push('');\n\n // Summary line at the end: verdict with status glyph\n if (result.ok) {\n lines.push(`${formatGreen('✔')} ${result.summary}`);\n } else {\n const codeText = result.code ? ` (${result.code})` : '';\n lines.push(`${formatRed('✖')} ${result.summary}${codeText}`);\n }\n\n return lines.join('\\n');\n}\n\n/**\n * Formats JSON output for database schema verification. The unclaimed-elements\n * list is a top-level field alongside the combined result, reported once for\n * the whole database.\n */\nexport function formatSchemaVerifyJson(\n result: VerifyDatabaseSchemaResult,\n unclaimed: readonly string[] = [],\n): string {\n return JSON.stringify({ ...result, unclaimed }, null, 2);\n}\n\n// ============================================================================\n// Sign Output Formatters\n// ============================================================================\n\n/**\n * Formats human-readable output for database sign.\n */\nexport function formatSignOutput(result: SignDatabaseResult, flags: GlobalFlags): string {\n if (flags.quiet) {\n return '';\n }\n\n const lines: string[] = [];\n\n const useColor = flags.color !== false;\n const formatGreen = createColorFormatter(useColor, green);\n const formatDimText = (text: string) => formatDim(useColor, text);\n\n if (result.ok) {\n // Main success message in white (not dimmed)\n lines.push(`${formatGreen('✔')} Database signed`);\n\n // Show from -> to hashes with clear labels\n const previousHash = result.marker.previous?.storageHash ?? 'none';\n const currentHash = result.contract.storageHash;\n\n lines.push(`${formatDimText(` from: ${previousHash}`)}`);\n lines.push(`${formatDimText(` to: ${currentHash}`)}`);\n\n if (isVerbose(flags, 1)) {\n if (result.contract.profileHash) {\n lines.push(`${formatDimText(` profileHash: ${result.contract.profileHash}`)}`);\n }\n if (result.marker.previous?.profileHash) {\n lines.push(\n `${formatDimText(` previous profileHash: ${result.marker.previous.profileHash}`)}`,\n );\n }\n lines.push(`${formatDimText(` Total time: ${result.timings.total}ms`)}`);\n }\n }\n\n return lines.join('\\n');\n}\n\n/**\n * Formats JSON output for database sign.\n */\nexport function formatSignJson(result: SignDatabaseResult): string {\n return JSON.stringify(result, null, 2);\n}\n"],"mappings":";;;;;;AAiBA,MAAM,gBAA0D;CAC9D,aAAa;CACb,gBAAgB;CAChB,aAAa;AACf;;;;;;;AAQA,SAAS,mBAAmB,OAAgC;CAC1D,OAAO,GAAG,cAAc,aAAa,KAAK,GAAG,IAAI,MAAM,KAAK,KAAK,GAAG;AACtE;;;;AA+CA,SAAgB,mBACd,QACA,OACQ;CACR,IAAI,MAAM,OACR,OAAO;CAGT,MAAM,QAAkB,CAAC;CAEzB,MAAM,WAAW,MAAM,UAAU;CACjC,MAAM,cAAc,qBAAqB,UAAU,KAAK;CACxD,MAAM,eAAe,qBAAqB,UAAU,MAAM;CAC1D,MAAM,iBAAiB,SAAiB,UAAU,UAAU,IAAI;CAChE,MAAM,mBACJ,OAAO,SAAS,SACZ,kBAAkB,OAAO,QAAQ,SAAS,cAAc,kBACxD;CAEN,MAAM,KAAK,GAAG,YAAY,GAAG,EAAE,GAAG,OAAO,SAAS;CAClD,MAAM,KAAK,GAAG,cAAc,mBAAmB,kBAAkB,GAAG;CACpE,MAAM,KAAK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A4B;CACvF,IAAI,MAAM,OACR,OAAO;CAGT,MAAM,QAAkB,CAAC;CAEzB,MAAM,WAAW,MAAM,UAAU;CACjC,MAAM,cAAc,qBAAqB,UAAU,KAAK;CACxD,MAAM,iBAAiB,SAAiB,UAAU,UAAU,IAAI;CAEhE,IAAI,OAAO,IAAI;EAEb,MAAM,KAAK,GAAG,YAAY,GAAG,EAAE,iBAAiB;EAGhD,MAAM,eAAe,OAAO,OAAO,UAAU,eAAe;EAC5D,MAAM,cAAc,OAAO,SAAS;EAEpC,MAAM,KAAK,GAAG,cAAc,WAAW,cAAc,GAAG;EACxD,MAAM,KAAK,GAAG,cAAc,WAAW,aAAa,GAAG;EAEvD,IAAI,UAAU,OAAO,CAAC,GAAG;GACvB,IAAI,OAAO,SAAS,aAClB,MAAM,KAAK,GAAG,cAAc,kBAAkB,OAAO,SAAS,aAAa,GAAG;GAEhF,IAAI,OAAO,OAAO,UAAU,aAC1B,MAAM,KACJ,GAAG,cAAc,2BAA2B,OAAO,OAAO,SAAS,aAAa,GAClF;GAEF,MAAM,KAAK,GAAG,cAAc,iBAAiB,OAAO,QAAQ,MAAM,GAAG,GAAG;EAC1E;CACF;CAEA,OAAO,MAAM,KAAK,IAAI;AACxB;;;;AAKA,SAAgB,eAAe,QAAoC;CACjE,OAAO,KAAK,UAAU,QAAQ,MAAM,CAAC;AACvC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prisma-next/cli",
3
- "version": "0.15.0",
3
+ "version": "0.16.0-dev.10",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -8,44 +8,44 @@
8
8
  "prisma-next": "./dist/cli.js"
9
9
  },
10
10
  "dependencies": {
11
- "@clack/prompts": "^1.6.0",
12
- "@prisma-next/config": "0.15.0",
13
- "@prisma-next/config-loader": "0.15.0",
14
- "@prisma-next/contract": "0.15.0",
15
- "@prisma-next/emitter": "0.15.0",
16
- "@prisma-next/errors": "0.15.0",
17
- "@prisma-next/framework-components": "0.15.0",
18
- "@prisma-next/language-server": "0.15.0",
19
- "@prisma-next/migration-tools": "0.15.0",
20
- "@prisma-next/psl-parser": "0.15.0",
21
- "@prisma-next/psl-printer": "0.15.0",
22
- "@prisma-next/cli-telemetry": "0.15.0",
23
- "@prisma-next/utils": "0.15.0",
11
+ "@clack/prompts": "^1.7.0",
12
+ "@prisma-next/config": "0.16.0-dev.10",
13
+ "@prisma-next/config-loader": "0.16.0-dev.10",
14
+ "@prisma-next/contract": "0.16.0-dev.10",
15
+ "@prisma-next/emitter": "0.16.0-dev.10",
16
+ "@prisma-next/errors": "0.16.0-dev.10",
17
+ "@prisma-next/framework-components": "0.16.0-dev.10",
18
+ "@prisma-next/language-server": "0.16.0-dev.10",
19
+ "@prisma-next/migration-tools": "0.16.0-dev.10",
20
+ "@prisma-next/psl-parser": "0.16.0-dev.10",
21
+ "@prisma-next/psl-printer": "0.16.0-dev.10",
22
+ "@prisma-next/cli-telemetry": "0.16.0-dev.10",
23
+ "@prisma-next/utils": "0.16.0-dev.10",
24
24
  "arktype": "^2.2.2",
25
25
  "ci-info": "^4.3.1",
26
26
  "clipanion": "4.0.0-rc.4",
27
27
  "closest-match": "^1.3.3",
28
28
  "colorette": "^2.0.20",
29
- "commander": "^14.0.3",
29
+ "commander": "^15.0.0",
30
30
  "esbuild": "^0.28.1",
31
31
  "jsonc-parser": "^3.3.1",
32
32
  "package-manager-detector": "^1.7.0",
33
33
  "pathe": "^2.0.3",
34
- "string-width": "^8.2.1",
34
+ "string-width": "^8.2.2",
35
35
  "strip-ansi": "^7.2.0",
36
36
  "wrap-ansi": "^10.0.0"
37
37
  },
38
38
  "devDependencies": {
39
- "@prisma-next/sql-contract": "0.15.0",
40
- "@prisma-next/sql-contract-emitter": "0.15.0",
41
- "@prisma-next/sql-contract-ts": "0.15.0",
42
- "@prisma-next/sql-operations": "0.15.0",
43
- "@prisma-next/sql-runtime": "0.15.0",
44
- "@prisma-next/test-utils": "0.15.0",
45
- "@prisma-next/tsconfig": "0.15.0",
46
- "@prisma-next/tsdown": "0.15.0",
39
+ "@prisma-next/sql-contract": "0.16.0-dev.10",
40
+ "@prisma-next/sql-contract-emitter": "0.16.0-dev.10",
41
+ "@prisma-next/sql-contract-ts": "0.16.0-dev.10",
42
+ "@prisma-next/sql-operations": "0.16.0-dev.10",
43
+ "@prisma-next/sql-runtime": "0.16.0-dev.10",
44
+ "@prisma-next/test-utils": "0.16.0-dev.10",
45
+ "@prisma-next/tsconfig": "0.16.0-dev.10",
46
+ "@prisma-next/tsdown": "0.16.0-dev.10",
47
47
  "@types/node": "25.9.4",
48
- "tsdown": "0.22.3",
48
+ "tsdown": "0.22.8",
49
49
  "typescript": "5.9.3",
50
50
  "vitest": "4.1.10"
51
51
  },
@@ -52,7 +52,7 @@ function mapDbInitFailure(failure: DbInitFailure): CliStructuredError {
52
52
  return errorMigrationPlanningFailed({ conflicts: failure.conflicts ?? [] });
53
53
  }
54
54
 
55
- if (failure.code === 'MARKER_ORIGIN_MISMATCH') {
55
+ if (failure.code === 'MIGRATION.MARKER_ORIGIN_MISMATCH') {
56
56
  const mismatchParts: string[] = [];
57
57
  if (
58
58
  failure.marker?.storageHash !== failure.destination?.storageHash &&
@@ -79,7 +79,7 @@ function mapDbInitFailure(failure: DbInitFailure): CliStructuredError {
79
79
  why: 'Database has an existing signature (marker) that does not match the target contract',
80
80
  fix: 'If bootstrapping, drop/reset the database then re-run `prisma-next db init`; otherwise reconcile schema/marker using your migration workflow',
81
81
  meta: {
82
- code: 'MARKER_ORIGIN_MISMATCH',
82
+ code: 'MIGRATION.MARKER_ORIGIN_MISMATCH',
83
83
  ...ifDefined('markerStorageHash', failure.marker?.storageHash),
84
84
  ...ifDefined('destinationStorageHash', failure.destination?.storageHash),
85
85
  ...ifDefined('markerProfileHash', failure.marker?.profileHash),
@@ -95,7 +95,7 @@ function mapDbInitFailure(failure: DbInitFailure): CliStructuredError {
95
95
  ? failure.meta['runnerErrorCode']
96
96
  : undefined;
97
97
  const fix =
98
- runnerCode === 'LEGACY_MARKER_SHAPE'
98
+ runnerCode === 'MIGRATION.LEGACY_MARKER_SHAPE'
99
99
  ? 'Legacy marker-table shape detected. Drop `prisma_contract.marker` (Postgres) or `_prisma_marker` (SQLite) and re-run `prisma-next db init` to recreate it with the current per-space schema.'
100
100
  : 'Fix the schema mismatch (db init is additive-only), or drop/reset the database and re-run `prisma-next db init`';
101
101
  return errorRunnerFailed(failure.summary, {
@@ -176,6 +176,7 @@ async function executeDbInitCommand(
176
176
  ...ifDefined('advanceRef', options.advanceRef),
177
177
  ...ifDefined('db', options.db),
178
178
  refsDir,
179
+ migrationsDir,
179
180
  contractIR,
180
181
  mode: result.value.mode,
181
182
  hash: advancementHash,
@@ -4,11 +4,12 @@ import type {
4
4
  SignDatabaseResult,
5
5
  VerifyDatabaseSchemaResult,
6
6
  } from '@prisma-next/framework-components/control';
7
+ import { readContractSnapshotJson } from '@prisma-next/migration-tools/contract-snapshot-store';
7
8
  import { MigrationToolsError } from '@prisma-next/migration-tools/errors';
8
9
  import { parseContractRef } from '@prisma-next/migration-tools/ref-resolution';
9
10
  import { notOk, ok, type Result } from '@prisma-next/utils/result';
10
11
  import { Command } from 'commander';
11
- import { join, relative, resolve } from 'pathe';
12
+ import { relative, resolve } from 'pathe';
12
13
  import { createControlClient } from '../control-api/client';
13
14
  import { ContractValidationError } from '../control-api/errors';
14
15
  import {
@@ -113,9 +114,10 @@ async function executeDbSignCommand(
113
114
  const targetHash = refResult.value.hash;
114
115
  const matchingBundle = bundles.find((p) => p.metadata.to === targetHash);
115
116
  if (matchingBundle) {
116
- const endContractPath = join(matchingBundle.dirPath, 'end-contract.json');
117
- const raw = await readFile(endContractPath, 'utf-8');
118
- contractJson = JSON.parse(raw) as Record<string, unknown>;
117
+ contractJson = (await readContractSnapshotJson(migrationsDir, targetHash)) as Record<
118
+ string,
119
+ unknown
120
+ >;
119
121
  } else {
120
122
  const defaultRaw = await readFile(contractPathAbsolute, 'utf-8');
121
123
  const defaultContract = JSON.parse(defaultRaw) as Record<string, unknown>;
@@ -1,4 +1,7 @@
1
- import { readFile } from 'node:fs/promises';
1
+ import {
2
+ contractSnapshotDir,
3
+ readContractSnapshotJson,
4
+ } from '@prisma-next/migration-tools/contract-snapshot-store';
2
5
  import { MigrationToolsError } from '@prisma-next/migration-tools/errors';
3
6
  import { parseContractRef } from '@prisma-next/migration-tools/ref-resolution';
4
7
  import { ifDefined } from '@prisma-next/utils/defined';
@@ -65,7 +68,7 @@ function mapDbUpdateFailure(failure: DbUpdateFailure): CliStructuredError {
65
68
  ? failure.meta['runnerErrorCode']
66
69
  : undefined;
67
70
  const fix =
68
- runnerCode === 'LEGACY_MARKER_SHAPE'
71
+ runnerCode === 'MIGRATION.LEGACY_MARKER_SHAPE'
69
72
  ? 'Legacy marker-table shape detected. Drop `prisma_contract.marker` (Postgres) or `_prisma_marker` (SQLite) and re-run `prisma-next db init` to recreate it with the current per-space schema.'
70
73
  : 'Inspect the reported conflict, reconcile schema drift if needed, then re-run `prisma-next db update`';
71
74
  return errorRunnerFailed(failure.summary, {
@@ -135,16 +138,20 @@ async function executeDbUpdateCommand(
135
138
  errorUnexpected(
136
139
  `No migration bundle found for --to "${options.to}" (resolved hash: ${targetHash})`,
137
140
  {
138
- why: `The ref resolved successfully but no on-disk migration package has an end-contract hash matching ${targetHash}.`,
141
+ why: `The ref resolved successfully but no on-disk migration package has a destination (\`to\`) hash matching ${targetHash}.`,
139
142
  fix: 'Provide a ref or hash that corresponds to an existing migration package, or run `migration list` to see available migrations.',
140
143
  },
141
144
  ),
142
145
  );
143
146
  }
144
- const endContractPath = join(matchingBundle.dirPath, 'end-contract.json');
145
- const raw = await readFile(endContractPath, 'utf-8');
146
- contractJson = JSON.parse(raw) as Record<string, unknown>;
147
- contractJsonPathForSnapshot = endContractPath;
147
+ contractJson = (await readContractSnapshotJson(migrationsDir, targetHash)) as Record<
148
+ string,
149
+ unknown
150
+ >;
151
+ contractJsonPathForSnapshot = join(
152
+ contractSnapshotDir(migrationsDir, targetHash),
153
+ 'contract.json',
154
+ );
148
155
  } catch (error) {
149
156
  if (MigrationToolsError.is(error)) {
150
157
  return notOk(mapMigrationToolsError(error));
@@ -193,6 +200,7 @@ async function executeDbUpdateCommand(
193
200
  ...ifDefined('advanceRef', options.advanceRef),
194
201
  ...ifDefined('db', options.db),
195
202
  refsDir,
203
+ migrationsDir,
196
204
  contractIR,
197
205
  mode: result.value.mode,
198
206
  hash: advancementHash,
@@ -106,8 +106,7 @@ function errorInvalidVerifyMode(options: {
106
106
  readonly why: string;
107
107
  readonly fix: string;
108
108
  }): CliStructuredError {
109
- return new CliStructuredError('4012', 'Invalid verify mode', {
110
- domain: 'CLI',
109
+ return new CliStructuredError('CLI.INVALID_VERIFY_MODE', 'Invalid verify mode', {
111
110
  why: options.why,
112
111
  fix: options.fix,
113
112
  docsUrl: 'https://pris.ly/db-verify',
@@ -368,7 +367,7 @@ async function executeDbVerifyCommand(
368
367
 
369
368
  try {
370
369
  // Single-contract marker verification preserved for the existing
371
- // marker / target / hash failure surface (`PN-RUN-3001/3002/3003`).
370
+ // marker / target / hash failure surface (`CONTRACT.MARKER_MISSING/CONTRACT.MARKER_MISMATCH/CONTRACT.TARGET_MISMATCH`).
372
371
  // The aggregate verifier (run below for the per-space marker /
373
372
  // schema checks) does not duplicate this: it concerns itself with
374
373
  // marker-vs-on-disk and orphan-marker drift, not the
@@ -6,8 +6,7 @@ import { CliStructuredError } from '../../utils/cli-errors';
6
6
  * the user was never given the choice — `--force` is the contract.
7
7
  */
8
8
  export function errorInitReinitNeedsForce(): CliStructuredError {
9
- return new CliStructuredError('5002', 'Project is already initialized', {
10
- domain: 'CLI',
9
+ return new CliStructuredError('CLI.INIT_REINIT_NEEDS_FORCE', 'Project is already initialized', {
11
10
  why: 'A `prisma-next.config.ts` already exists in this directory. Re-running `init` would overwrite the scaffolded files; in non-interactive mode `init` will not do that without `--force`.',
12
11
  fix: 'Pass `--force` to overwrite the existing scaffold, or run `init` interactively to confirm.',
13
12
  docsUrl: 'https://prisma-next.dev/docs/cli/init',
@@ -42,8 +41,7 @@ export function errorInitMissingFlags(options: {
42
41
  }
43
42
  })
44
43
  .join(' ');
45
- return new CliStructuredError('5003', 'Missing required flags', {
46
- domain: 'CLI',
44
+ return new CliStructuredError('CLI.INIT_MISSING_FLAGS', 'Missing required flags', {
47
45
  why: `${options.why} Missing required flag(s): ${flagList}.`,
48
46
  fix: `Re-run with the missing flag(s) supplied, e.g. \`prisma-next init --yes ${fixList}\`. Use \`prisma-next init --help\` to see every flag.`,
49
47
  docsUrl: 'https://prisma-next.dev/docs/cli/init',
@@ -60,13 +58,16 @@ export function errorInitInvalidFlagValue(options: {
60
58
  readonly value: string;
61
59
  readonly allowed: readonly string[];
62
60
  }): CliStructuredError {
63
- return new CliStructuredError('5004', `Invalid value for --${options.flag}`, {
64
- domain: 'CLI',
65
- why: `\`--${options.flag} ${options.value}\` is not one of: ${options.allowed.join(', ')}.`,
66
- fix: `Use one of: ${options.allowed.map((v) => `--${options.flag} ${v}`).join(', ')}.`,
67
- docsUrl: 'https://prisma-next.dev/docs/cli/init',
68
- meta: { flag: options.flag, value: options.value, allowed: options.allowed },
69
- });
61
+ return new CliStructuredError(
62
+ 'CLI.INIT_INVALID_FLAG_VALUE',
63
+ `Invalid value for --${options.flag}`,
64
+ {
65
+ why: `\`--${options.flag} ${options.value}\` is not one of: ${options.allowed.join(', ')}.`,
66
+ fix: `Use one of: ${options.allowed.map((v) => `--${options.flag} ${v}`).join(', ')}.`,
67
+ docsUrl: 'https://prisma-next.dev/docs/cli/init',
68
+ meta: { flag: options.flag, value: options.value, allowed: options.allowed },
69
+ },
70
+ );
70
71
  }
71
72
 
72
73
  /**
@@ -81,23 +82,26 @@ export function errorInitAuthoringSchemaPathMismatch(options: {
81
82
  readonly expectedExtension: string;
82
83
  }): CliStructuredError {
83
84
  const expectedAuthoring = options.expectedExtension === '.ts' ? 'typescript' : 'psl';
84
- return new CliStructuredError('5014', 'Authoring and schema path do not match', {
85
- domain: 'CLI',
86
- why:
87
- `\`--authoring ${options.authoring}\` requires a schema file ending in ${options.expectedExtension}, ` +
88
- `but \`--schema-path ${options.schemaPath}\` ends in ${options.actualExtension}.`,
89
- fix:
90
- `Use a matching pair, for example \`--authoring ${expectedAuthoring} --schema-path <path>${options.expectedExtension}\`, ` +
91
- 'or change `--authoring` to match the path you supplied. ' +
92
- 'You can also omit `--schema-path` to use the default for the chosen authoring.',
93
- docsUrl: 'https://prisma-next.dev/docs/cli/init',
94
- meta: {
95
- authoring: options.authoring,
96
- schemaPath: options.schemaPath,
97
- actualExtension: options.actualExtension,
98
- expectedExtension: options.expectedExtension,
85
+ return new CliStructuredError(
86
+ 'CLI.INIT_AUTHORING_SCHEMA_PATH_MISMATCH',
87
+ 'Authoring and schema path do not match',
88
+ {
89
+ why:
90
+ `\`--authoring ${options.authoring}\` requires a schema file ending in ${options.expectedExtension}, ` +
91
+ `but \`--schema-path ${options.schemaPath}\` ends in ${options.actualExtension}.`,
92
+ fix:
93
+ `Use a matching pair, for example \`--authoring ${expectedAuthoring} --schema-path <path>${options.expectedExtension}\`, ` +
94
+ 'or change `--authoring` to match the path you supplied. ' +
95
+ 'You can also omit `--schema-path` to use the default for the chosen authoring.',
96
+ docsUrl: 'https://prisma-next.dev/docs/cli/init',
97
+ meta: {
98
+ authoring: options.authoring,
99
+ schemaPath: options.schemaPath,
100
+ actualExtension: options.actualExtension,
101
+ expectedExtension: options.expectedExtension,
102
+ },
99
103
  },
100
- });
104
+ );
101
105
  }
102
106
 
103
107
  /**
@@ -108,8 +112,7 @@ export function errorInitAuthoringSchemaPathMismatch(options: {
108
112
  * 3 (USER_ABORTED).
109
113
  */
110
114
  export function errorInitUserAborted(): CliStructuredError {
111
- return new CliStructuredError('5006', 'Init cancelled', {
112
- domain: 'CLI',
115
+ return new CliStructuredError('CLI.INIT_USER_ABORTED', 'Init cancelled', {
113
116
  why: 'The interactive prompt was cancelled before all required inputs were supplied. No files were modified.',
114
117
  fix: 'Re-run `prisma-next init` and complete the prompts, or pass the required inputs as flags (see `--help`) for a non-interactive run.',
115
118
  severity: 'info',
@@ -125,12 +128,15 @@ export function errorInitUserAborted(): CliStructuredError {
125
128
  * mode is supposed to prevent.
126
129
  */
127
130
  export function errorInitStrictProbeWithoutProbe(): CliStructuredError {
128
- return new CliStructuredError('5005', '`--strict-probe` requires `--probe-db`', {
129
- domain: 'CLI',
130
- why: '`--strict-probe` only changes how a *failed* probe is reported; without `--probe-db` no probe is attempted in the first place. (`init` is offline-by-default — it never opens a connection to your database without explicit consent.)',
131
- fix: 'Add `--probe-db` to opt in to the probe, or drop `--strict-probe` if you do not need the version check.',
132
- docsUrl: 'https://prisma-next.dev/docs/cli/init',
133
- });
131
+ return new CliStructuredError(
132
+ 'CLI.INIT_STRICT_PROBE_WITHOUT_PROBE',
133
+ '`--strict-probe` requires `--probe-db`',
134
+ {
135
+ why: '`--strict-probe` only changes how a *failed* probe is reported; without `--probe-db` no probe is attempted in the first place. (`init` is offline-by-default — it never opens a connection to your database without explicit consent.)',
136
+ fix: 'Add `--probe-db` to opt in to the probe, or drop `--strict-probe` if you do not need the version check.',
137
+ docsUrl: 'https://prisma-next.dev/docs/cli/init',
138
+ },
139
+ );
134
140
  }
135
141
 
136
142
  /**
@@ -152,8 +158,7 @@ export function errorInitInstallFailed(options: {
152
158
  trimmed.length === 0
153
159
  ? 'The package manager exited with an error and no recoverable fallback applied.'
154
160
  : `The package manager exited with: ${trimmed[0]}`;
155
- return new CliStructuredError('5007', 'Failed to install dependencies', {
156
- domain: 'CLI',
161
+ return new CliStructuredError('CLI.INIT_INSTALL_FAILED', 'Failed to install dependencies', {
157
162
  why,
158
163
  fix: `Install manually:\n ${options.addCommand}\n ${options.addDevCommand}\nThen run \`${options.emitCommand}\` to emit the contract.`,
159
164
  docsUrl: 'https://prisma-next.dev/docs/cli/init',
@@ -179,8 +184,7 @@ export function errorInitInvalidManifest(options: {
179
184
  readonly path: string;
180
185
  readonly cause: string;
181
186
  }): CliStructuredError {
182
- return new CliStructuredError('5010', `Failed to parse ${options.path}`, {
183
- domain: 'CLI',
187
+ return new CliStructuredError('CLI.INIT_INVALID_MANIFEST', `Failed to parse ${options.path}`, {
184
188
  why: `\`${options.path}\` is not valid JSON: ${options.cause}`,
185
189
  fix: `Fix the JSON syntax in \`${options.path}\` (a missing comma or unbalanced brace is the most common cause), then re-run \`prisma-next init\`.`,
186
190
  docsUrl: 'https://prisma-next.dev/docs/cli/init',
@@ -206,8 +210,7 @@ export function errorInitInvalidTsconfig(options: {
206
210
  readonly path: string;
207
211
  readonly cause: string;
208
212
  }): CliStructuredError {
209
- return new CliStructuredError('5011', `Failed to parse ${options.path}`, {
210
- domain: 'CLI',
213
+ return new CliStructuredError('CLI.INIT_INVALID_TSCONFIG', `Failed to parse ${options.path}`, {
211
214
  why: `\`${options.path}\` is not valid JSON or JSONC: ${options.cause}`,
212
215
  fix: `Fix the syntax in \`${options.path}\` and re-run \`prisma-next init\`. \`init\` accepts JSONC (comments and trailing commas) but cannot recover from unbalanced braces or missing commas.`,
213
216
  docsUrl: 'https://prisma-next.dev/docs/cli/init',
@@ -233,8 +236,7 @@ export function errorInitProbeFailed(options: {
233
236
  readonly cause: string;
234
237
  readonly filesWritten: readonly string[];
235
238
  }): CliStructuredError {
236
- return new CliStructuredError('5012', 'Database probe failed', {
237
- domain: 'CLI',
239
+ return new CliStructuredError('CLI.INIT_PROBE_FAILED', 'Database probe failed', {
238
240
  why: `\`--probe-db\` could not complete and \`--strict-probe\` was set: ${options.cause}`,
239
241
  fix: 'Confirm `DATABASE_URL` points at a reachable server, or drop `--strict-probe` to treat probe failures as warnings.',
240
242
  docsUrl: 'https://prisma-next.dev/docs/cli/init',
@@ -256,8 +258,7 @@ export function errorInitEmitFailed(options: {
256
258
  readonly filesWritten: readonly string[];
257
259
  readonly cause: string;
258
260
  }): CliStructuredError {
259
- return new CliStructuredError('5008', 'Failed to emit contract', {
260
- domain: 'CLI',
261
+ return new CliStructuredError('CLI.INIT_EMIT_FAILED', 'Failed to emit contract', {
261
262
  why: `\`prisma-next contract emit\` failed: ${options.cause}`,
262
263
  fix: `Inspect your contract file, fix the underlying issue, then re-run \`${options.emitCommand}\`. Pass \`-v\` for the full error envelope.`,
263
264
  docsUrl: 'https://prisma-next.dev/docs/cli/contract-emit',
@@ -284,18 +285,21 @@ export function errorInitSkillInstallFailed(options: {
284
285
  readonly filesWritten: readonly string[];
285
286
  readonly cause: string;
286
287
  }): CliStructuredError {
287
- return new CliStructuredError('5013', 'Failed to install Prisma Next skills', {
288
- domain: 'CLI',
289
- why: `\`${options.skillInstallCommand}\` exited with an error: ${options.cause}`,
290
- fix:
291
- 'Either:\n' +
292
- ` - Re-run \`prisma-next init --no-skill${options.filesWritten.length > 0 ? ' --force' : ''}\` to skip the skill install for this run, or\n` +
293
- ` - Fix the underlying issue (network, npm registry, \`npx skills\` on PATH) and install manually:\n ${options.skillInstallCommand}`,
294
- docsUrl: 'https://prisma-next.dev/docs/cli/init#skills',
295
- meta: {
296
- filesWritten: options.filesWritten,
297
- skillInstallCommand: options.skillInstallCommand,
298
- cause: options.cause,
288
+ return new CliStructuredError(
289
+ 'CLI.INIT_SKILL_INSTALL_FAILED',
290
+ 'Failed to install Prisma Next skills',
291
+ {
292
+ why: `\`${options.skillInstallCommand}\` exited with an error: ${options.cause}`,
293
+ fix:
294
+ 'Either:\n' +
295
+ ` - Re-run \`prisma-next init --no-skill${options.filesWritten.length > 0 ? ' --force' : ''}\` to skip the skill install for this run, or\n` +
296
+ ` - Fix the underlying issue (network, npm registry, \`npx skills\` on PATH) and install manually:\n ${options.skillInstallCommand}`,
297
+ docsUrl: 'https://prisma-next.dev/docs/cli/init#skills',
298
+ meta: {
299
+ filesWritten: options.filesWritten,
300
+ skillInstallCommand: options.skillInstallCommand,
301
+ cause: options.cause,
302
+ },
299
303
  },
300
- });
304
+ );
301
305
  }