@prisma/orm-toolchain 8.0.0-rc.1-dev.39 → 8.0.0-rc.1-dev.40

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 (152) hide show
  1. package/dist/bin__prisma-next.mjs +24 -24
  2. package/dist/bin__prisma-next.mjs.map +1 -1
  3. package/dist/{caught-errors-DLPzfzIW-CQ9BoXD-.mjs → caught-errors-BZo7zcRc-C-pIEasG.mjs} +3 -3
  4. package/dist/{caught-errors-DLPzfzIW-CQ9BoXD-.mjs.map → caught-errors-BZo7zcRc-C-pIEasG.mjs.map} +1 -1
  5. package/dist/{cli-errors-BG6bItjG-DwdKIeGz.mjs → cli-errors-B4zTLaqQ-CXgjO9t4.mjs} +20 -3
  6. package/dist/cli-errors-B4zTLaqQ-CXgjO9t4.mjs.map +1 -0
  7. package/dist/{cli-errors-BiKBrOXc-JPxQqO58.d.mts → cli-errors-iquUoY6O-BFboxglv.d.mts} +17 -9
  8. package/dist/cli-errors-iquUoY6O-BFboxglv.d.mts.map +1 -0
  9. package/dist/cli.mjs +1057 -32
  10. package/dist/cli.mjs.map +1 -1
  11. package/dist/cli__commands__contract-emit.mjs +1 -1
  12. package/dist/cli__commands__contract-infer.mjs +1 -1
  13. package/dist/cli__commands__db-init.mjs +1 -1
  14. package/dist/cli__commands__db-schema.mjs +1 -1
  15. package/dist/cli__commands__db-sign.mjs +1 -1
  16. package/dist/cli__commands__db-update.mjs +1 -1
  17. package/dist/cli__commands__db-verify.mjs +1 -1
  18. package/dist/cli__commands__migrate.d.mts +2 -2
  19. package/dist/cli__commands__migrate.mjs +1 -1
  20. package/dist/cli__commands__migration-check.mjs +1 -1
  21. package/dist/cli__commands__migration-graph.d.mts +1 -1
  22. package/dist/cli__commands__migration-graph.mjs +1 -1
  23. package/dist/cli__commands__migration-list.d.mts +1 -1
  24. package/dist/cli__commands__migration-list.mjs +1 -1
  25. package/dist/cli__commands__migration-log.d.mts +1 -1
  26. package/dist/cli__commands__migration-log.mjs +1 -1
  27. package/dist/cli__commands__migration-new.mjs +1 -1
  28. package/dist/cli__commands__migration-plan.d.mts +1 -1
  29. package/dist/cli__commands__migration-plan.mjs +1 -1
  30. package/dist/cli__commands__migration-show.mjs +1 -1
  31. package/dist/cli__commands__migration-status.d.mts +1 -1
  32. package/dist/cli__commands__migration-status.mjs +1 -1
  33. package/dist/cli__commands__ref.mjs +1 -1
  34. package/dist/cli__commands__telemetry.mjs +1 -1
  35. package/dist/cli__control-api.d.mts +3 -3
  36. package/dist/cli__control-api.mjs +15 -15
  37. package/dist/cli__control-api__testing.d.mts +1 -1
  38. package/dist/cli__control-api__testing.mjs +2 -1
  39. package/dist/cli__control-api__testing.mjs.map +1 -1
  40. package/dist/{client-DU9qtBxW-BjVHiKzE.mjs → client-C6Qp5ujC-Dxb7r79B.mjs} +12 -15
  41. package/dist/client-C6Qp5ujC-Dxb7r79B.mjs.map +1 -0
  42. package/dist/{code-templates-CSLH8721-CWRA4Lru.mjs → code-templates-D73q329L-CSx0Jg-6.mjs} +3 -3
  43. package/dist/{code-templates-CSLH8721-CWRA4Lru.mjs.map → code-templates-D73q329L-CSx0Jg-6.mjs.map} +1 -1
  44. package/dist/combine-verify-results-B87B_pMc-D4l22OqY.mjs +65 -0
  45. package/dist/combine-verify-results-B87B_pMc-D4l22OqY.mjs.map +1 -0
  46. package/dist/{command-helpers-CwLvFwMB-BWwUQhlT.mjs → command-helpers-BCgwcqTe-lNCtppzM.mjs} +3 -3
  47. package/dist/{command-helpers-CwLvFwMB-BWwUQhlT.mjs.map → command-helpers-BCgwcqTe-lNCtppzM.mjs.map} +1 -1
  48. package/dist/{contract-at-errors-Dptf8RE_-B5gr04Sc.mjs → contract-at-errors-BSoDI0Hw-BXeUNE3s.mjs} +3 -3
  49. package/dist/{contract-at-errors-Dptf8RE_-B5gr04Sc.mjs.map → contract-at-errors-BSoDI0Hw-BXeUNE3s.mjs.map} +1 -1
  50. package/dist/contract-emit-DDWBBvF1-BeGZCRrb.mjs +2 -0
  51. package/dist/{contract-emit-CZQZ1i4z-p9LSGmmQ.mjs → contract-emit-DFScp9D6-6H-UJMFv.mjs} +5 -5
  52. package/dist/{contract-emit-CZQZ1i4z-p9LSGmmQ.mjs.map → contract-emit-DFScp9D6-6H-UJMFv.mjs.map} +1 -1
  53. package/dist/{contract-emit-BQFpcb2A-BwT9iVdb.mjs → contract-emit-DsvAx-dY-DQzoDO34.mjs} +5 -5
  54. package/dist/{contract-emit-BQFpcb2A-BwT9iVdb.mjs.map → contract-emit-DsvAx-dY-DQzoDO34.mjs.map} +1 -1
  55. package/dist/{contract-infer-C6cYOihE-CIUCgmw0.mjs → contract-infer-BwIDGl7v-CZrdWXAr.mjs} +4 -4
  56. package/dist/{contract-infer-C6cYOihE-CIUCgmw0.mjs.map → contract-infer-BwIDGl7v-CZrdWXAr.mjs.map} +1 -1
  57. package/dist/{contract-snapshot-resolution-DvZvbNcZ-DHFCWe_k.mjs → contract-snapshot-resolution-De2VvOJn-DqIAV9cr.mjs} +4 -4
  58. package/dist/{contract-snapshot-resolution-DvZvbNcZ-DHFCWe_k.mjs.map → contract-snapshot-resolution-De2VvOJn-DqIAV9cr.mjs.map} +1 -1
  59. package/dist/{contract-space-aggregate-loader-CoLTf3Ce-pQDru2w0.mjs → contract-space-aggregate-loader-fa04OIaL-B7LXHle3.mjs} +4 -4
  60. package/dist/{contract-space-aggregate-loader-CoLTf3Ce-pQDru2w0.mjs.map → contract-space-aggregate-loader-fa04OIaL-B7LXHle3.mjs.map} +1 -1
  61. package/dist/{db-init-DypCy1e3-CBrYfhHF.mjs → db-init-BolXrKAI-CwG-zEDW.mjs} +6 -6
  62. package/dist/{db-init-DypCy1e3-CBrYfhHF.mjs.map → db-init-BolXrKAI-CwG-zEDW.mjs.map} +1 -1
  63. package/dist/{db-init-failure-BmCcHUfc-BqDxyrJE.mjs → db-init-failure-B5cQML4A-5zr-99Ek.mjs} +3 -3
  64. package/dist/{db-init-failure-BmCcHUfc-BqDxyrJE.mjs.map → db-init-failure-B5cQML4A-5zr-99Ek.mjs.map} +1 -1
  65. package/dist/{db-schema-DHfPM-5V-JeCjrQ55.mjs → db-schema-DvdLBdEY-Dl6e1d_Y.mjs} +4 -4
  66. package/dist/{db-schema-DHfPM-5V-JeCjrQ55.mjs.map → db-schema-DvdLBdEY-Dl6e1d_Y.mjs.map} +1 -1
  67. package/dist/{db-sign-DbAxRcZh-C-nT9kcG.mjs → db-sign-DCp4c8CA-B3tun-kh.mjs} +6 -6
  68. package/dist/{db-sign-DbAxRcZh-C-nT9kcG.mjs.map → db-sign-DCp4c8CA-B3tun-kh.mjs.map} +1 -1
  69. package/dist/{db-update-J59yROwL-DCP-_z2W.mjs → db-update-CfayE8WE-CPhQyDaZ.mjs} +6 -6
  70. package/dist/{db-update-J59yROwL-DCP-_z2W.mjs.map → db-update-CfayE8WE-CPhQyDaZ.mjs.map} +1 -1
  71. package/dist/{db-verify-0TpDMziA-CJDKutMN.mjs → db-verify-BN7IrOAL-kEzRNJUl.mjs} +7 -65
  72. package/dist/db-verify-BN7IrOAL-kEzRNJUl.mjs.map +1 -0
  73. package/dist/{exports-DaxzMVtq.mjs → exports-B3xY_FHp.mjs} +304 -18
  74. package/dist/exports-B3xY_FHp.mjs.map +1 -0
  75. package/dist/{format-cbJY7l6v-CjMUDTAs.mjs → format-Ca7dUE6B-BMFqrc6D.mjs} +5 -5
  76. package/dist/{format-cbJY7l6v-CjMUDTAs.mjs.map → format-Ca7dUE6B-BMFqrc6D.mjs.map} +1 -1
  77. package/dist/{framework-components-C3K7SBeC-Bj5gx85-.mjs → framework-components-Bau7o1-J-DTp6AUoq.mjs} +3 -3
  78. package/dist/{framework-components-C3K7SBeC-Bj5gx85-.mjs.map → framework-components-Bau7o1-J-DTp6AUoq.mjs.map} +1 -1
  79. package/dist/{init-CcJxAIeS-CITTa8YU.mjs → init-DJrxDasP-DoQftaPY.mjs} +6 -6
  80. package/dist/{init-CcJxAIeS-CITTa8YU.mjs.map → init-DJrxDasP-DoQftaPY.mjs.map} +1 -1
  81. package/dist/{inspect-live-schema-Cf77j9Vd-i5fzNW4T.mjs → inspect-live-schema-BPHXdvqW-DrzL2ZkQ.mjs} +5 -5
  82. package/dist/{inspect-live-schema-Cf77j9Vd-i5fzNW4T.mjs.map → inspect-live-schema-BPHXdvqW-DrzL2ZkQ.mjs.map} +1 -1
  83. package/dist/integrity-violation-to-check-failure-BmWMLAae-DqiC4_3p.mjs +115 -0
  84. package/dist/integrity-violation-to-check-failure-BmWMLAae-DqiC4_3p.mjs.map +1 -0
  85. package/dist/{invariants-1zL5-9Mc-BCeOLxd_.mjs → invariants-Bltd8DyA-Cg_1Lu0q.mjs} +4 -4
  86. package/dist/{invariants-1zL5-9Mc-BCeOLxd_.mjs.map → invariants-Bltd8DyA-Cg_1Lu0q.mjs.map} +1 -1
  87. package/dist/{legend-BQcPKTLe-bn9e4_ZU.mjs → legend-DGv9e2_0-BtetgRz4.mjs} +3 -3
  88. package/dist/{legend-BQcPKTLe-bn9e4_ZU.mjs.map → legend-DGv9e2_0-BtetgRz4.mjs.map} +1 -1
  89. package/dist/{migrate-BVEyoBor-CN_EOCzx.mjs → migrate-BXATUjYE-Do79Imf-.mjs} +12 -12
  90. package/dist/{migrate-BVEyoBor-CN_EOCzx.mjs.map → migrate-BXATUjYE-Do79Imf-.mjs.map} +1 -1
  91. package/dist/{migrate-failure-CKMEnA_x-ByHkYjn5.mjs → migrate-failure-D4NvkoCk-0bttmQs2.mjs} +4 -4
  92. package/dist/{migrate-failure-CKMEnA_x-ByHkYjn5.mjs.map → migrate-failure-D4NvkoCk-0bttmQs2.mjs.map} +1 -1
  93. package/dist/{migrate-show-Dlo-YzOk-BXo-DmwI.d.mts → migrate-show-B8UJ9dmb-C4RTPbDk.d.mts} +3 -3
  94. package/dist/{migrate-show-Dlo-YzOk-BXo-DmwI.d.mts.map → migrate-show-B8UJ9dmb-C4RTPbDk.d.mts.map} +1 -1
  95. package/dist/{migrate-show-kVUG1xdo-bVTW8tu4.mjs → migrate-show-C_9xR4Qt-B-Y0PGKw.mjs} +6 -6
  96. package/dist/{migrate-show-kVUG1xdo-bVTW8tu4.mjs.map → migrate-show-C_9xR4Qt-B-Y0PGKw.mjs.map} +1 -1
  97. package/dist/{migration-check-CBMoMDX2-DhSEOGNg.mjs → migration-check-Bbdw7t-r-C2VTMK61.mjs} +6 -6
  98. package/dist/{migration-check-CBMoMDX2-DhSEOGNg.mjs.map → migration-check-Bbdw7t-r-C2VTMK61.mjs.map} +1 -1
  99. package/dist/migration-check-DbHgYK7F-7mtYNVFu.mjs +163 -0
  100. package/dist/migration-check-DbHgYK7F-7mtYNVFu.mjs.map +1 -0
  101. package/dist/{migration-command-scaffold-B1BiWKLI-Bskk5UKX.mjs → migration-command-scaffold-SzjR2naH-Yi3-rNfX.mjs} +5 -5
  102. package/dist/{migration-command-scaffold-B1BiWKLI-Bskk5UKX.mjs.map → migration-command-scaffold-SzjR2naH-Yi3-rNfX.mjs.map} +1 -1
  103. package/dist/{migration-graph-B30X5398-BH3zB9Mn.mjs → migration-graph-B8WxW_tm-qGNf7jQh.mjs} +3 -3
  104. package/dist/{migration-graph-B30X5398-BH3zB9Mn.mjs.map → migration-graph-B8WxW_tm-qGNf7jQh.mjs.map} +1 -1
  105. package/dist/{migration-graph-D4sgTiXa-BLtiLIk7.mjs → migration-graph-BOwu76mF-kOTWFvfV.mjs} +8 -8
  106. package/dist/{migration-graph-D4sgTiXa-BLtiLIk7.mjs.map → migration-graph-BOwu76mF-kOTWFvfV.mjs.map} +1 -1
  107. package/dist/{migration-graph-sections-B8WSWSkJ-CyaRo0T6.mjs → migration-graph-sections-BBHPOFN--COKyUKQ4.mjs} +3 -3
  108. package/dist/{migration-graph-sections-B8WSWSkJ-CyaRo0T6.mjs.map → migration-graph-sections-BBHPOFN--COKyUKQ4.mjs.map} +1 -1
  109. package/dist/{migration-list-BIL-re1m-CZY4m3d0.mjs → migration-list-CKuYcMQq-CubZzE9i.mjs} +6 -6
  110. package/dist/{migration-list-BIL-re1m-CZY4m3d0.mjs.map → migration-list-CKuYcMQq-CubZzE9i.mjs.map} +1 -1
  111. package/dist/{migration-list-BQTfSGbT-DoNqbNsu.mjs → migration-list-CY08bD8I-PoXuv94c.mjs} +3 -3
  112. package/dist/{migration-list-BQTfSGbT-DoNqbNsu.mjs.map → migration-list-CY08bD8I-PoXuv94c.mjs.map} +1 -1
  113. package/dist/{migration-log-BdBKYAUW-DTPxKZtD.mjs → migration-log-CUbGla-9-BLIrWjwN.mjs} +6 -6
  114. package/dist/{migration-log-BdBKYAUW-DTPxKZtD.mjs.map → migration-log-CUbGla-9-BLIrWjwN.mjs.map} +1 -1
  115. package/dist/{migration-new-CXLgOLXz-2C5s_q7n.mjs → migration-new-ChvZjf5X-BFhEM0BF.mjs} +4 -4
  116. package/dist/{migration-new-CXLgOLXz-2C5s_q7n.mjs.map → migration-new-ChvZjf5X-BFhEM0BF.mjs.map} +1 -1
  117. package/dist/{migration-new-Bp5dPKnF-D-Fb6vEp.mjs → migration-new-DXMvJdbB-BkrpDfcr.mjs} +7 -7
  118. package/dist/{migration-new-Bp5dPKnF-D-Fb6vEp.mjs.map → migration-new-DXMvJdbB-BkrpDfcr.mjs.map} +1 -1
  119. package/dist/{migration-path-target-BNTSTPAc-D7dQ4K7x.mjs → migration-path-target-JDWqF9kj-B7zoMq6X.mjs} +3 -3
  120. package/dist/{migration-path-target-BNTSTPAc-D7dQ4K7x.mjs.map → migration-path-target-JDWqF9kj-B7zoMq6X.mjs.map} +1 -1
  121. package/dist/{migration-plan-CharRhoN-BIB3WL65.d.mts → migration-plan-BV9f5Xjq-DiyscOMc.d.mts} +3 -3
  122. package/dist/{migration-plan-CharRhoN-BIB3WL65.d.mts.map → migration-plan-BV9f5Xjq-DiyscOMc.d.mts.map} +1 -1
  123. package/dist/{migration-plan-BxfF1Hdo-BKn0xMlY.mjs → migration-plan-Bz1hOTHF-CFCtPuOv.mjs} +4 -4
  124. package/dist/{migration-plan-BxfF1Hdo-BKn0xMlY.mjs.map → migration-plan-Bz1hOTHF-CFCtPuOv.mjs.map} +1 -1
  125. package/dist/{migration-plan-C6KrFHJT-CRkTsE7L.mjs → migration-plan-Cfz0efEL-DMNFq5b2.mjs} +8 -8
  126. package/dist/{migration-plan-C6KrFHJT-CRkTsE7L.mjs.map → migration-plan-Cfz0efEL-DMNFq5b2.mjs.map} +1 -1
  127. package/dist/{migration-show-Dhnlx_GU-DhWLLt3Z.mjs → migration-show-BGdR1xnT-Cg3M0FPh.mjs} +8 -8
  128. package/dist/{migration-show-Dhnlx_GU-DhWLLt3Z.mjs.map → migration-show-BGdR1xnT-Cg3M0FPh.mjs.map} +1 -1
  129. package/dist/{migration-status-DzPVkkB3-BA7jjITd.mjs → migration-status-BIrAJ5af-D-_mMBUA.mjs} +10 -10
  130. package/dist/{migration-status-DzPVkkB3-BA7jjITd.mjs.map → migration-status-BIrAJ5af-D-_mMBUA.mjs.map} +1 -1
  131. package/dist/{project-import-root-nwdoPWap--5vXe4zp.mjs → project-import-root-B4nM-VWX-D__g0hTb.mjs} +3 -3
  132. package/dist/{project-import-root-nwdoPWap--5vXe4zp.mjs.map → project-import-root-B4nM-VWX-D__g0hTb.mjs.map} +1 -1
  133. package/dist/{redact-secrets-kQ0KKV1u-MnVSKe-u.mjs → redact-secrets-Cvia6eTB-BE_Pg3k9.mjs} +4 -4
  134. package/dist/{redact-secrets-kQ0KKV1u-MnVSKe-u.mjs.map → redact-secrets-Cvia6eTB-BE_Pg3k9.mjs.map} +1 -1
  135. package/dist/{ref-gZQjdz8I-CW6n9Fc0.mjs → ref-4x6BGSsd-ClaoZIQh.mjs} +4 -4
  136. package/dist/{ref-gZQjdz8I-CW6n9Fc0.mjs.map → ref-4x6BGSsd-ClaoZIQh.mjs.map} +1 -1
  137. package/dist/{ref-C8oaaeky-ColNkWpr.mjs → ref-WXLIR9Xm-12IUtoBU.mjs} +5 -5
  138. package/dist/{ref-C8oaaeky-ColNkWpr.mjs.map → ref-WXLIR9Xm-12IUtoBU.mjs.map} +1 -1
  139. package/dist/{ref-resolution-DAK4OK3x-B-8ZZc0f.mjs → ref-resolution-BSN1amKm-C6-TTM2N.mjs} +3 -3
  140. package/dist/{ref-resolution-DAK4OK3x-B-8ZZc0f.mjs.map → ref-resolution-BSN1amKm-C6-TTM2N.mjs.map} +1 -1
  141. package/dist/{telemetry-DPXFYAsz-CPW2USxs.mjs → telemetry-BD52LETE-Cqeb7ebh.mjs} +3 -3
  142. package/dist/{telemetry-DPXFYAsz-CPW2USxs.mjs.map → telemetry-BD52LETE-Cqeb7ebh.mjs.map} +1 -1
  143. package/dist/vite-plugin-contract-emit.mjs +1 -1
  144. package/package.json +12 -12
  145. package/dist/cli-errors-BG6bItjG-DwdKIeGz.mjs.map +0 -1
  146. package/dist/cli-errors-BiKBrOXc-JPxQqO58.d.mts.map +0 -1
  147. package/dist/client-DU9qtBxW-BjVHiKzE.mjs.map +0 -1
  148. package/dist/contract-emit-Bzt11N4v-BQ2Pr8KG.mjs +0 -2
  149. package/dist/db-verify-0TpDMziA-CJDKutMN.mjs.map +0 -1
  150. package/dist/exports-DaxzMVtq.mjs.map +0 -1
  151. package/dist/migration-check-BVK9vfan-Dfg8lbeB.mjs +0 -272
  152. package/dist/migration-check-BVK9vfan-Dfg8lbeB.mjs.map +0 -1
package/dist/cli.mjs CHANGED
@@ -1,55 +1,58 @@
1
1
  import { i as loadConfig } from "./exports-BZLNbtkY.mjs";
2
- import { I as requireLiveDatabase, L as runCommandAction, M as errorTargetMigrationNotSupported, O as errorRunnerFailed, P as errorUnexpected, a as errorConfigValidation$1, b as errorMigrationPlanningFailed, c as errorContractValidationFailed, d as errorDriverRequired, f as errorFileNotFound, g as errorLegendHumanOnly, k as errorRuntime$1, l as errorDatabaseConnectionRequired, o as errorConsentPlanMismatch, r as chooseAction, t as CliStructuredError$1$1, u as errorDestructiveChanges, x as errorNoMigrations, y as errorMigrationPackageNotFound } from "./cli-errors-BG6bItjG-DwdKIeGz.mjs";
2
+ import { A as errorRuntime$1, F as errorUnexpected, L as requireLiveDatabase, N as errorTargetMigrationNotSupported, P as errorTargetMismatch, R as runCommandAction, S as errorNoMigrations, _ as errorLegendHumanOnly, a as errorConfigValidation$1, b as errorMigrationPackageNotFound, d as errorDestructiveChanges, f as errorDriverRequired, k as errorRunnerFailed, l as errorContractValidationFailed, m as errorHashMismatch, o as errorConsentPlanMismatch, p as errorFileNotFound, r as chooseAction, s as errorContractArgConflict, t as CliStructuredError$1$1, u as errorDatabaseConnectionRequired, x as errorMigrationPlanningFailed, y as errorMarkerMissing } from "./cli-errors-B4zTLaqQ-CXgjO9t4.mjs";
3
3
  import { r as getEmittedArtifactPaths } from "./exports-BCLg4CiV-05kuwcb0.mjs";
4
- import { n as executeContractEmit } from "./contract-emit-CZQZ1i4z-p9LSGmmQ.mjs";
4
+ import { n as executeContractEmit } from "./contract-emit-DFScp9D6-6H-UJMFv.mjs";
5
5
  import { h as renderPreviewStatement, m as previewBlockHeader } from "./terminal-ui-Cqz4LVL7-B0mcVdLy.mjs";
6
6
  import { c as spaceMigrationDirectory } from "./verify-contract-spaces-DhJTb0zM-_oh6W6lp.mjs";
7
- import { S as targetSupportsMigrations, f as maskConnectionUrl, h as readContractEnvelope, n as closeQuietly, v as sanitizeErrorMessage } from "./command-helpers-CwLvFwMB-BWwUQhlT.mjs";
8
- import { t as createContractEmitCommand } from "./contract-emit-BQFpcb2A-BwT9iVdb.mjs";
9
- import { n as executeFormat, t as createFormatCommand } from "./format-cbJY7l6v-CjMUDTAs.mjs";
10
- import { c as targetLabel, i as scaffoldSpecifierResolverFor, l as targetPackageName, n as dbFile, o as starterSchema, r as defaultSchemaPath, t as configFile } from "./code-templates-CSLH8721-CWRA4Lru.mjs";
11
- import { a as loadContractSpaceAggregateForCli, i as loadContractRawSafely, l as refusePackageCorruptionOnAggregate, r as buildReadAggregate, s as refuseContractSpaceIntegrity, u as toDeclaredExtensionsFromRaw } from "./contract-space-aggregate-loader-CoLTf3Ce-pQDru2w0.mjs";
12
- import { t as createControlClient } from "./client-DU9qtBxW-BjVHiKzE.mjs";
7
+ import { S as targetSupportsMigrations, f as maskConnectionUrl, h as readContractEnvelope, n as closeQuietly, v as sanitizeErrorMessage } from "./command-helpers-BCgwcqTe-lNCtppzM.mjs";
8
+ import { t as createContractEmitCommand } from "./contract-emit-DsvAx-dY-DQzoDO34.mjs";
9
+ import { n as executeFormat, t as createFormatCommand } from "./format-Ca7dUE6B-BMFqrc6D.mjs";
10
+ import { c as targetLabel, i as scaffoldSpecifierResolverFor, l as targetPackageName, n as dbFile, o as starterSchema, r as defaultSchemaPath, t as configFile } from "./code-templates-D73q329L-CSx0Jg-6.mjs";
11
+ import { a as loadContractSpaceAggregateForCli, i as loadContractRawSafely, l as refusePackageCorruptionOnAggregate, r as buildReadAggregate, s as refuseContractSpaceIntegrity, u as toDeclaredExtensionsFromRaw } from "./contract-space-aggregate-loader-fa04OIaL-B7LXHle3.mjs";
12
+ import { t as createControlClient } from "./client-C6Qp5ujC-Dxb7r79B.mjs";
13
13
  import { a as readContractIR, o as resolveRefAdvancementFields, t as advanceRefSafely } from "./ref-advancement-DaZBzm7m-WoqnFAyr.mjs";
14
- import { t as mapDbInitFailure } from "./db-init-failure-BmCcHUfc-BqDxyrJE.mjs";
15
- import { t as resolveContractRefToSnapshot } from "./contract-snapshot-resolution-DvZvbNcZ-DHFCWe_k.mjs";
16
- import { t as mapCaughtMigrationError } from "./caught-errors-DLPzfzIW-CQ9BoXD-.mjs";
17
- import { t as mapContractAtError } from "./contract-at-errors-Dptf8RE_-B5gr04Sc.mjs";
18
- import { i as refuseUnknownInvariants, n as refuseMarkerOutsideGraph, r as refuseMissingInvariantPath, t as hasMigrationPath } from "./invariants-1zL5-9Mc-BCeOLxd_.mjs";
19
- import { t as executeMigrateShowPlan } from "./migrate-show-kVUG1xdo-bVTW8tu4.mjs";
20
- import { n as resolveMigrationRef, t as resolveContractRef } from "./ref-resolution-DAK4OK3x-B-8ZZc0f.mjs";
21
- import { n as migrationSpaceListEntriesFromAggregate, r as runMigrationList, t as listRefsByContractHash } from "./migration-list-BQTfSGbT-DoNqbNsu.mjs";
14
+ import { t as mapDbInitFailure } from "./db-init-failure-B5cQML4A-5zr-99Ek.mjs";
15
+ import { t as resolveContractRefToSnapshot } from "./contract-snapshot-resolution-De2VvOJn-DqIAV9cr.mjs";
16
+ import { t as combineVerifyResults } from "./combine-verify-results-B87B_pMc-D4l22OqY.mjs";
17
+ import { t as mapCaughtMigrationError } from "./caught-errors-BZo7zcRc-C-pIEasG.mjs";
18
+ import { t as mapContractAtError } from "./contract-at-errors-BSoDI0Hw-BXeUNE3s.mjs";
19
+ import { i as refuseUnknownInvariants, n as refuseMarkerOutsideGraph, r as refuseMissingInvariantPath, t as hasMigrationPath } from "./invariants-Bltd8DyA-Cg_1Lu0q.mjs";
20
+ import { t as executeMigrateShowPlan } from "./migrate-show-C_9xR4Qt-B-Y0PGKw.mjs";
21
+ import { n as resolveMigrationRef, t as resolveContractRef } from "./ref-resolution-BSN1amKm-C6-TTM2N.mjs";
22
+ import { n as migrationSpaceListEntriesFromAggregate, r as runMigrationList, t as listRefsByContractHash } from "./migration-list-CY08bD8I-PoXuv94c.mjs";
22
23
  import { C as toneSpans, S as toneDrawing, b as renderMigrationGraphSpaceTrees, d as createToneMigrationListStyler, m as indentMigrationGraphTreeBlock, n as TONE_MIGRATION_GRAPH_PALETTE, v as renderMigrationGraphLegend, x as renderMigrationListWithStyle } from "./migration-graph-command-render-h0VdTkSM-C3rPZEw1.mjs";
23
- import { n as migrateShowRunListRows, r as renderMigrateShowGraph, t as mapMigrateFailure } from "./migrate-failure-CKMEnA_x-ByHkYjn5.mjs";
24
- import { n as looksLikePath, r as resolveAppTargetPath, t as findPackageByDirPath } from "./migration-path-target-BNTSTPAc-D7dQ4K7x.mjs";
25
- import { t as buildMigrationSpaceGraphEntries } from "./migration-graph-B30X5398-BH3zB9Mn.mjs";
26
- import { n as renderMigrationGraphDot, r as renderMigrationGraphSections, t as buildMigrationGraphTreeSections } from "./migration-graph-sections-B8WSWSkJ-CyaRo0T6.mjs";
24
+ import { n as migrateShowRunListRows, r as renderMigrateShowGraph, t as mapMigrateFailure } from "./migrate-failure-D4NvkoCk-0bttmQs2.mjs";
25
+ import { n as looksLikePath, r as resolveAppTargetPath, t as findPackageByDirPath } from "./migration-path-target-JDWqF9kj-B7zoMq6X.mjs";
26
+ import { i as runMigrationCheck, n as enumerateCheckSpaces, r as loadAggregateIntegrityViolations, t as checkSingleTarget } from "./migration-check-Bbdw7t-r-C2VTMK61.mjs";
27
+ import { t as integrityViolationToCheckFailure } from "./integrity-violation-to-check-failure-BmWMLAae-DqiC4_3p.mjs";
28
+ import { t as buildMigrationSpaceGraphEntries } from "./migration-graph-B8WxW_tm-qGNf7jQh.mjs";
29
+ import { n as renderMigrationGraphDot, r as renderMigrationGraphSections, t as buildMigrationGraphTreeSections } from "./migration-graph-sections-BBHPOFN--COKyUKQ4.mjs";
27
30
  import { a as sortLedgerEntries, i as serializeLedgerEntriesForJson, n as formatLedgerAppliedAt, o as styleHashTransition, t as MIGRATION_LOG_EMPTY_MESSAGE } from "./migration-log-table-eES9lPjv-BCFm8qJr.mjs";
28
- import { t as executeMigrationNewCommand } from "./migration-new-Bp5dPKnF-D-Fb6vEp.mjs";
29
- import { t as executeMigrationPlanCommand } from "./migration-plan-C6KrFHJT-CRkTsE7L.mjs";
31
+ import { t as executeMigrationNewCommand } from "./migration-new-DXMvJdbB-BkrpDfcr.mjs";
32
+ import { t as executeMigrationPlanCommand } from "./migration-plan-Cfz0efEL-DMNFq5b2.mjs";
30
33
  import { a as statusForMigrationHash, i as readMigrationRefs, n as deriveStatusEdgeAnnotations, r as originHashForStatus, t as appliedHashesFromLedger } from "./refs-fQLFcMoq-aTBeUU9H.mjs";
31
- import { n as executeRefListCommand, r as executeRefSetCommand, t as executeRefDeleteCommand } from "./ref-C8oaaeky-ColNkWpr.mjs";
32
- import { A as isRecognisedPnpmResolutionError, B as removeDependency, C as findStaleArtifacts, E as formatRunCommand, F as mergeTsConfig, G as validateSchemaPath, H as resolveAuthoring, I as minimalProjectReadmeMd, L as probeServerVersion, M as mergeGitattributes, N as mergeGitignore, O as formatSkillSourceUrl, P as mergePackageScripts, R as quickReferenceMd, S as errorInitWriteFailed, U as resolveProjectSkillInstallCommands, V as requiredGitattributesLines, W as resolveTarget, _ as errorInitProbeFailed, a as TsConfigParseError, b as errorInitStrictProbeWithoutProbe, d as envFileContent, g as errorInitMissingFlags, h as errorInitInvalidTsconfig, i as REQUIRED_SCRIPTS, j as legacySkillDirs, l as ensureEsmModuleType, m as errorInitInvalidManifest, n as DEFAULT_SKILL_SOURCES, o as buildCatalogWarnings, r as MIN_SERVER_VERSION, s as defaultTsConfig, t as DEFAULT_SKILL_AGENTS, u as envExampleContent, x as errorInitUserAborted, z as redactSecrets } from "./redact-secrets-kQ0KKV1u-MnVSKe-u.mjs";
34
+ import { n as executeRefListCommand, r as executeRefSetCommand, t as executeRefDeleteCommand } from "./ref-WXLIR9Xm-12IUtoBU.mjs";
35
+ import { A as isRecognisedPnpmResolutionError, B as removeDependency, C as findStaleArtifacts, E as formatRunCommand, F as mergeTsConfig, G as validateSchemaPath, H as resolveAuthoring, I as minimalProjectReadmeMd, L as probeServerVersion, M as mergeGitattributes, N as mergeGitignore, O as formatSkillSourceUrl, P as mergePackageScripts, R as quickReferenceMd, S as errorInitWriteFailed, U as resolveProjectSkillInstallCommands, V as requiredGitattributesLines, W as resolveTarget, _ as errorInitProbeFailed, a as TsConfigParseError, b as errorInitStrictProbeWithoutProbe, d as envFileContent, g as errorInitMissingFlags, h as errorInitInvalidTsconfig, i as REQUIRED_SCRIPTS, j as legacySkillDirs, l as ensureEsmModuleType, m as errorInitInvalidManifest, n as DEFAULT_SKILL_SOURCES, o as buildCatalogWarnings, r as MIN_SERVER_VERSION, s as defaultTsConfig, t as DEFAULT_SKILL_AGENTS, u as envExampleContent, x as errorInitUserAborted, z as redactSecrets } from "./redact-secrets-Cvia6eTB-BE_Pg3k9.mjs";
33
36
  import { n as buildNextSteps, t as InitOutputSchema } from "./output-DP3woAjV-BxCr9nHA.mjs";
34
37
  import { CliStructuredError } from "@prisma/orm-framework/errors/control";
35
38
  import { ifDefined } from "@prisma/orm-framework/utils/defined";
36
39
  import { basename, dirname, isAbsolute, join, normalize, relative, resolve } from "pathe";
37
40
  import { existsSync, mkdirSync, readFileSync, rmSync, unlinkSync, writeFileSync } from "node:fs";
38
- import { DOCS_BASE, docsUrlFor, isStructuredError } from "@prisma/orm-framework/utils/structured-error";
41
+ import { DOCS_BASE, docsUrlFor, isStructuredError, isStructuredErrorCode } from "@prisma/orm-framework/utils/structured-error";
39
42
  import { blindCast, castAs } from "@prisma/orm-framework/utils/casts";
40
- import { InternalError, assertNever } from "@prisma/orm-framework/utils/internal-error";
43
+ import { InternalError, assertNever, isInternalError } from "@prisma/orm-framework/utils/internal-error";
41
44
  import { mkdir, readFile, rename, rm, writeFile } from "node:fs/promises";
42
- import { APP_SPACE_ID, createControlStack } from "@prisma/orm-framework/components/control";
45
+ import { APP_SPACE_ID, VERIFY_CODE_HASH_MISMATCH, VERIFY_CODE_MARKER_MISSING, VERIFY_CODE_TARGET_MISMATCH, createControlStack, issueOutcome } from "@prisma/orm-framework/components/control";
43
46
  import { type } from "arktype";
44
47
  import { collectConfigIssues } from "@prisma/orm-framework/config/config-validation";
45
48
  import { tmpdir } from "node:os";
46
49
  import { detect } from "package-manager-detector/detect";
47
50
  import { printPsl } from "@prisma/orm-framework/psl-printer";
48
- import { defineCommand, defineCommandFamily, defineConfigSection, flag, positional } from "@prisma/cli-engine";
51
+ import { defineCommand, defineCommandFamily, defineConfigSection, defineServerCommand, flag, positional } from "@prisma/cli-engine";
49
52
  import { CliStructuredError as CliStructuredError$1, notOk, ok } from "@prisma/cli-engine/protocol";
50
53
  import { pathToFileURL } from "node:url";
51
54
  import { build } from "esbuild";
52
- //#region ../../../1-framework/3-tooling/cli/dist/load-config-DWFCZvpn.mjs
55
+ //#region ../../../1-framework/3-tooling/cli/dist/load-config-CVli79Ro.mjs
53
56
  const MISSING_CONFIG_ACTION = {
54
57
  kind: "run-command",
55
58
  label: "Create a config file",
@@ -259,6 +262,11 @@ function normalizeError(error) {
259
262
  * prisma/prisma's `CliStructuredError` — both classes carry that name — and then settles it
260
263
  * through fields the engine's own class has and this one does not. The envelope that results is
261
264
  * off-protocol. Catching here means every handler settles through the single conversion instead.
265
+ *
266
+ * An `InternalError` is the one thing this boundary does not convert. Its own contract says never
267
+ * to catch it outside the outermost boundary: it means an invariant broke, which is a bug in
268
+ * Prisma Next rather than something the user did. Re-throwing lets the engine settle it as a bug
269
+ * at exit 1, where converting it would report the same number as a bad connection string.
262
270
  */
263
271
  function defineOrmCommand(def) {
264
272
  return defineCommand({
@@ -267,6 +275,7 @@ function defineOrmCommand(def) {
267
275
  try {
268
276
  return await def.handler(args, ctx);
269
277
  } catch (error) {
278
+ if (isInternalError(error)) throw error;
270
279
  return notOk(normalizeError(error));
271
280
  }
272
281
  }
@@ -1108,7 +1117,7 @@ function treeNode(node) {
1108
1117
  ...ifDefined("children", node.children === void 0 || node.children.length === 0 ? void 0 : node.children.map(treeNode))
1109
1118
  };
1110
1119
  }
1111
- function schemaPresentations(inputs) {
1120
+ function schemaPresentations$1(inputs) {
1112
1121
  const { document, schemaView, database } = inputs;
1113
1122
  return {
1114
1123
  human: () => [...database === void 0 ? [] : [{
@@ -1185,7 +1194,7 @@ function createDbSchemaCommand(createClient) {
1185
1194
  meta: { ...ifDefined("dbUrl", database) },
1186
1195
  timings: { total: Date.now() - startedAt }
1187
1196
  };
1188
- return ok(ctx.present({ data: document }, schemaPresentations({
1197
+ return ok(ctx.present({ data: document }, schemaPresentations$1({
1189
1198
  document,
1190
1199
  schemaView,
1191
1200
  database
@@ -1195,6 +1204,372 @@ function createDbSchemaCommand(createClient) {
1195
1204
  }
1196
1205
  const dbSchemaCommand = createDbSchemaCommand(createControlClient);
1197
1206
  /**
1207
+ * Reads the emitted contract and hydrates it through the family's
1208
+ * `deserializeContract` seam, which is where every other on-disk contract read
1209
+ * in this CLI crosses into family types.
1210
+ */
1211
+ async function readEmittedContract(inputs) {
1212
+ const path = contractPathFor(inputs.config, inputs.cwd);
1213
+ if (path === void 0) return notOk(normalizeError(errorConfigValidation$1("contract.output", {
1214
+ why: `${inputs.commandName} reads the emitted contract from config.contract.output; the config has no value to read.`,
1215
+ section: "contract"
1216
+ })));
1217
+ const relativePath = displayPath(path, inputs.cwd);
1218
+ let content;
1219
+ try {
1220
+ content = await readFile(path, "utf-8");
1221
+ } catch (error) {
1222
+ return notOk(normalizeError(Reflect.get(Object(error), "code") === "ENOENT" ? errorFileNotFound(path, {
1223
+ why: `Contract file not found at ${path}`,
1224
+ fix: `Run \`prisma-next contract emit\` to generate ${relativePath}, or update \`contract.output\` in prisma-next.config.ts`
1225
+ }) : errorUnexpected(error instanceof Error ? error.message : String(error), { why: `Failed to read contract file: ${error instanceof Error ? error.message : String(error)}` })));
1226
+ }
1227
+ const familyInstance = inputs.config.family.create(createControlStack(inputs.config));
1228
+ try {
1229
+ return ok({
1230
+ contract: familyInstance.deserializeContract(castAs(JSON.parse(content))),
1231
+ path,
1232
+ displayPath: relativePath
1233
+ });
1234
+ } catch (error) {
1235
+ return notOk(normalizeError(errorContractValidationFailed(`Contract JSON is invalid: ${error instanceof Error ? error.message : String(error)}`, { where: { path } })));
1236
+ }
1237
+ }
1238
+ /**
1239
+ * The connection and driver both verification commands need. Returns the
1240
+ * resolved connection or the precondition failure that stopped the run.
1241
+ */
1242
+ function requireVerifyConnection(inputs) {
1243
+ const dbConnection = inputs.db ?? inputs.config.db?.connection;
1244
+ if (typeof dbConnection !== "string" || dbConnection.length === 0) return notOk(normalizeError(errorDatabaseConnectionRequired({
1245
+ why: `Database connection is required for ${inputs.invocation} (set db.connection in prisma-next.config.ts, or pass --db <url>)`,
1246
+ missingFlags: ["--db"],
1247
+ retryCommand: `prisma-next ${inputs.invocation} --db <url>`
1248
+ })));
1249
+ if (inputs.config.driver === void 0) return notOk(normalizeError(errorDriverRequired({ why: `Config.driver is required for ${inputs.invocation}` })));
1250
+ return ok(dbConnection);
1251
+ }
1252
+ /**
1253
+ * A failure the verification could not recover from — a dropped connection, a
1254
+ * driver throw — as a settlement the user can act on. Connection strings are
1255
+ * stripped from the prose whichever path the value took. A driver error
1256
+ * carrying `ECONNREFUSED`, `ENOTFOUND` or a SQLSTATE has a `code` and takes
1257
+ * the first path, and its message is exactly the one likely to quote the URL.
1258
+ */
1259
+ function verificationThrow(inputs) {
1260
+ const { error } = inputs;
1261
+ const message = error instanceof Error ? error.message : String(error);
1262
+ return withoutConnectionString(typeof error === "object" && error !== null && "code" in error ? normalizeError(error) : normalizeError(errorUnexpected(message, { why: `Unexpected error during ${inputs.invocation}: ${message}` })), inputs.connection);
1263
+ }
1264
+ /**
1265
+ * The same envelope with the connection string stripped from every field the
1266
+ * settlement serializes: the prose, each next action's strings, and every
1267
+ * string reachable through `meta`. A driver error quotes the URL wherever it
1268
+ * pleases, so nothing user-facing passes through unstripped.
1269
+ */
1270
+ function withoutConnectionString(error, connection) {
1271
+ const clean = (text) => sanitizeErrorMessage(text, connection);
1272
+ return new CliStructuredError$1(error.code, clean(error.message), {
1273
+ severity: error.severity,
1274
+ nextActions: error.nextActions.map((action) => cleanNextAction(action, clean)),
1275
+ ...ifDefined("why", error.why === void 0 ? void 0 : clean(error.why)),
1276
+ ...ifDefined("where", error.where),
1277
+ ...ifDefined("meta", error.meta === void 0 ? void 0 : cleanMetaRecord(error.meta, clean)),
1278
+ ...ifDefined("docsUrl", error.docsUrl),
1279
+ cause: error.cause
1280
+ });
1281
+ }
1282
+ function cleanNextAction(action, clean) {
1283
+ return {
1284
+ kind: action.kind,
1285
+ label: clean(action.label),
1286
+ ...ifDefined("command", action.command === void 0 ? void 0 : clean(action.command)),
1287
+ ...ifDefined("commands", action.commands?.map(clean)),
1288
+ ...ifDefined("url", action.url === void 0 ? void 0 : clean(action.url)),
1289
+ ...ifDefined("reason", action.reason === void 0 ? void 0 : clean(action.reason))
1290
+ };
1291
+ }
1292
+ function cleanMetaValue(value, clean) {
1293
+ if (typeof value === "string") return clean(value);
1294
+ if (Array.isArray(value)) return value.map((entry) => cleanMetaValue(entry, clean));
1295
+ if (typeof value === "object" && value !== null) return Object.fromEntries(Object.entries(value).map(([key, entry]) => [key, cleanMetaValue(entry, clean)]));
1296
+ return value;
1297
+ }
1298
+ function cleanMetaRecord(meta, clean) {
1299
+ return Object.fromEntries(Object.entries(meta).map(([key, value]) => [key, cleanMetaValue(value, clean)]));
1300
+ }
1301
+ const OUTCOME_LABEL = {
1302
+ "not-found": "missing",
1303
+ "not-expected": "extra",
1304
+ "not-equal": "mismatch"
1305
+ };
1306
+ /** What a diff issue says, in the words the commander shell used. */
1307
+ function issueLabel(issue) {
1308
+ return `${OUTCOME_LABEL[issueOutcome(issue)]}: ${issue.path.join("/")}`;
1309
+ }
1310
+ function issueNodes(issues, status) {
1311
+ return issues.map((issue) => ({
1312
+ label: issueLabel(issue),
1313
+ status
1314
+ }));
1315
+ }
1316
+ /**
1317
+ * The drift, laid out as a tree the engine draws: one root per finding family,
1318
+ * one child per element. The engine owns the connectors and the status glyphs,
1319
+ * so nothing here carries an escape sequence.
1320
+ */
1321
+ function schemaFindingBlocks(inputs) {
1322
+ const roots = [];
1323
+ const issues = inputs.result.schema.issues;
1324
+ if (issues.length > 0) roots.push({
1325
+ label: "Schema issues",
1326
+ status: "error",
1327
+ children: issueNodes(issues, "error")
1328
+ });
1329
+ const warnings = inputs.result.schema.warnings?.issues ?? [];
1330
+ if (warnings.length > 0) roots.push({
1331
+ label: "Schema warnings",
1332
+ status: "warn",
1333
+ children: issueNodes(warnings, "warn")
1334
+ });
1335
+ if (inputs.unclaimed.length > 0) {
1336
+ const status = inputs.strict ? "error" : "warn";
1337
+ roots.push({
1338
+ label: "Unclaimed elements (declared by no contract)",
1339
+ status,
1340
+ children: inputs.unclaimed.map((name) => ({
1341
+ label: name,
1342
+ status
1343
+ }))
1344
+ });
1345
+ }
1346
+ return roots.length === 0 ? [] : [{
1347
+ kind: "tree",
1348
+ roots
1349
+ }];
1350
+ }
1351
+ /**
1352
+ * A failed schema-verification verdict as one envelope diagnostic. `error` is
1353
+ * the honest severity: the database does not satisfy the contract. It is legal
1354
+ * because both commands settle at exit 4 — the engine refuses a
1355
+ * severity-`error` diagnostic only on a run that exits 0.
1356
+ */
1357
+ function schemaVerdictDiagnostic(inputs) {
1358
+ const code = inputs.result.code;
1359
+ const dotted = code !== void 0 && isStructuredErrorCode(code);
1360
+ const issues = inputs.result.schema.issues.map(issueLabel);
1361
+ return {
1362
+ code: dotted ? code : "CONTRACT.VERIFY_FAILED",
1363
+ severity: "error",
1364
+ summary: inputs.result.summary,
1365
+ ...issues.length === 0 ? {} : { why: `The live schema differs: ${issues.join("; ")}.` },
1366
+ nextActions: inputs.nextActions,
1367
+ meta: {
1368
+ ...inputs.space === void 0 ? {} : { space: inputs.space },
1369
+ issues,
1370
+ ...dotted || code === void 0 ? {} : { code }
1371
+ }
1372
+ };
1373
+ }
1374
+ /**
1375
+ * Verification ran and refused the signature. The command completed — it
1376
+ * answered the question "may this database be signed?" — so the refusal is a
1377
+ * diagnostic on a completed envelope rather than an error.
1378
+ */
1379
+ const FINDINGS_EXIT_CODE$2 = 4;
1380
+ /** The config file this bin reads; the handler is not told which one was loaded. */
1381
+ const CONFIG_DISPLAY_PATH = "prisma-next.config.ts";
1382
+ function headerBlock$1(inputs) {
1383
+ return {
1384
+ kind: "fields",
1385
+ rail: true,
1386
+ rows: [{
1387
+ label: "contract",
1388
+ value: inputs.contract
1389
+ }, {
1390
+ label: "database",
1391
+ value: inputs.database
1392
+ }]
1393
+ };
1394
+ }
1395
+ function signPresentations(inputs) {
1396
+ const marker = inputs.document.marker;
1397
+ return {
1398
+ human: () => [
1399
+ inputs.header,
1400
+ {
1401
+ kind: "summary",
1402
+ status: "ok",
1403
+ text: "Database signed"
1404
+ },
1405
+ {
1406
+ kind: "fields",
1407
+ rows: [{
1408
+ label: "from",
1409
+ value: marker.previous?.storageHash === void 0 ? [{
1410
+ text: "none",
1411
+ tone: "muted"
1412
+ }] : [{
1413
+ text: marker.previous.storageHash,
1414
+ tone: "identifier"
1415
+ }]
1416
+ }, {
1417
+ label: "to",
1418
+ value: [{
1419
+ text: inputs.document.contract.storageHash,
1420
+ tone: "identifier"
1421
+ }]
1422
+ }]
1423
+ }
1424
+ ],
1425
+ json: () => inputs.document
1426
+ };
1427
+ }
1428
+ function refusedPresentations(inputs) {
1429
+ return {
1430
+ human: () => [
1431
+ inputs.header,
1432
+ ...schemaFindingBlocks({
1433
+ result: inputs.document,
1434
+ unclaimed: [],
1435
+ strict: false
1436
+ }),
1437
+ {
1438
+ kind: "summary",
1439
+ status: "error",
1440
+ text: inputs.document.summary
1441
+ }
1442
+ ],
1443
+ json: () => inputs.document
1444
+ };
1445
+ }
1446
+ /**
1447
+ * Builds the command with its control-client factory injected, so tests mount
1448
+ * the same tree over a fake client instead of mocking the client module.
1449
+ */
1450
+ function createDbSignCommand(createClient = createControlClient) {
1451
+ return defineOrmCommand({
1452
+ help: {
1453
+ summary: "Sign the database with your contract so you can safely run queries",
1454
+ description: "Verifies that your database schema satisfies the emitted contract, and if\nso, writes or updates the database signature. Idempotent and safe to run\nin CI or a deployment pipeline. The signature records that this database\ninstance is aligned with a specific contract version.\nExit codes: 0 = signed, 2 = the command could not run (unresolvable\ncontract reference, no emitted contract, unreachable database),\n4 = schema verification failed and no signature was written.",
1455
+ examples: [
1456
+ "db sign",
1457
+ "db sign --db $DATABASE_URL",
1458
+ "db sign production --db $DATABASE_URL",
1459
+ "db sign --contract production --db $DATABASE_URL"
1460
+ ]
1461
+ },
1462
+ args: {
1463
+ positionals: { contract: positional.optionalString({
1464
+ brief: "Contract reference (hash, prefix, ref name, or migration dir name)",
1465
+ placeholder: "contract"
1466
+ }) },
1467
+ flags: {
1468
+ db: dbFlag,
1469
+ contract: flag.string({
1470
+ brief: "Contract reference (hash, prefix, ref name, migration dir name, <dir>^, or ./path)",
1471
+ placeholder: "contract"
1472
+ })
1473
+ }
1474
+ },
1475
+ needs: { config: ormConfigSection },
1476
+ exitCodes: { 4: "schema verification failed; no signature was written" },
1477
+ handler: async (args, ctx) => {
1478
+ const positionalContract = args.positionals.contract;
1479
+ const flagContract = args.flags.contract;
1480
+ if (positionalContract !== void 0 && flagContract !== void 0) return notOk(normalizeError(errorContractArgConflict({
1481
+ positional: positionalContract,
1482
+ flag: flagContract
1483
+ })));
1484
+ const contractRef = positionalContract ?? flagContract;
1485
+ const emitted = await readEmittedContract({
1486
+ config: ctx.config,
1487
+ cwd: ctx.cwd,
1488
+ commandName: "db sign"
1489
+ });
1490
+ if (!emitted.ok) return notOk(emitted.failure);
1491
+ let contractInput = emitted.value.contract;
1492
+ if (contractRef !== void 0) {
1493
+ const resolvedRef = await resolveContractRefToSnapshot({
1494
+ config: ctx.config,
1495
+ migrationsDir: migrationsDirFor(ctx.config, ctx.cwd),
1496
+ refInput: contractRef,
1497
+ contractPathAbsolute: emitted.value.path,
1498
+ fallbackToEmitted: true
1499
+ });
1500
+ if (!resolvedRef.ok) return notOk(normalizeError(resolvedRef.failure));
1501
+ contractInput = resolvedRef.value.contractJson;
1502
+ }
1503
+ const connection = requireVerifyConnection({
1504
+ config: ctx.config,
1505
+ db: args.flags.db,
1506
+ invocation: "db sign"
1507
+ });
1508
+ if (!connection.ok) return notOk(connection.failure);
1509
+ const dbConnection = connection.value;
1510
+ const header = headerBlock$1({
1511
+ contract: contractRef ?? emitted.value.displayPath,
1512
+ database: maskConnectionUrl(dbConnection)
1513
+ });
1514
+ const client = createClient({
1515
+ family: ctx.config.family,
1516
+ target: ctx.config.target,
1517
+ adapter: ctx.config.adapter,
1518
+ ...ifDefined("driver", ctx.config.driver),
1519
+ extensions: ctx.config.extensions ?? []
1520
+ });
1521
+ const onProgress = controlProgressReporter(ctx.report);
1522
+ try {
1523
+ const verified = await client.schemaVerify({
1524
+ contract: contractInput,
1525
+ strict: false,
1526
+ connection: dbConnection,
1527
+ onProgress
1528
+ });
1529
+ if (!verified.ok) {
1530
+ const document = verified;
1531
+ return ok(ctx.present({
1532
+ data: document,
1533
+ exitCode: FINDINGS_EXIT_CODE$2,
1534
+ diagnostics: [schemaVerdictDiagnostic({
1535
+ result: verified,
1536
+ space: void 0,
1537
+ nextActions: [runCommandAction("Bring the database up to the contract, then sign again", "prisma-next db update")]
1538
+ })]
1539
+ }, refusedPresentations({
1540
+ document,
1541
+ header
1542
+ })));
1543
+ }
1544
+ const signed = await client.sign({
1545
+ contract: contractInput,
1546
+ contractPath: displayPath(emitted.value.path, ctx.cwd),
1547
+ configPath: CONFIG_DISPLAY_PATH,
1548
+ onProgress
1549
+ });
1550
+ if (!signed.ok) throw new InternalError(`The family returned a sign result that did not sign: ${signed.summary}`);
1551
+ return ok(ctx.present({
1552
+ data: signed,
1553
+ exitCode: 0
1554
+ }, signPresentations({
1555
+ document: signed,
1556
+ header
1557
+ })));
1558
+ } catch (error) {
1559
+ if (isInternalError(error)) throw error;
1560
+ return notOk(verificationThrow({
1561
+ error,
1562
+ invocation: "db sign",
1563
+ connection: dbConnection
1564
+ }));
1565
+ } finally {
1566
+ await closeQuietly(client);
1567
+ }
1568
+ }
1569
+ });
1570
+ }
1571
+ const dbSignCommand = createDbSignCommand();
1572
+ /**
1198
1573
  * A `db update` failure as the CLI's structured error.
1199
1574
  *
1200
1575
  * `DESTRUCTIVE_CHANGES` is handled by the command, which asks for consent and
@@ -1458,6 +1833,447 @@ function createDbUpdateCommand(createClient) {
1458
1833
  });
1459
1834
  }
1460
1835
  const dbUpdateCommand = createDbUpdateCommand(createControlClient);
1836
+ /**
1837
+ * Verification ran and the database does not match the contract. The run did
1838
+ * the job it was asked to do, so this is a completed settlement carrying
1839
+ * diagnostics rather than an error.
1840
+ */
1841
+ const FINDINGS_EXIT_CODE$1 = 4;
1842
+ const PUSH_THE_CONTRACT = runCommandAction("Push the contract to the database", "prisma-next db update");
1843
+ const RECONCILE_BY_HAND = {
1844
+ kind: "user-choice",
1845
+ label: "Or reconcile the differences by hand and verify again"
1846
+ };
1847
+ function errorInvalidVerifyMode(options) {
1848
+ return new CliStructuredError$1("CLI.INVALID_VERIFY_MODE", "Invalid verify mode", {
1849
+ why: options.why,
1850
+ nextActions: [{
1851
+ kind: "user-choice",
1852
+ label: options.choose
1853
+ }],
1854
+ docsUrl: "https://pris.ly/db-verify"
1855
+ });
1856
+ }
1857
+ function resolveMode(flags) {
1858
+ if (flags.markerOnly && flags.schemaOnly) return notOk(errorInvalidVerifyMode({
1859
+ why: "`--marker-only` and `--schema-only` cannot be used together",
1860
+ choose: "Choose one mode: omit both to check the marker and schema, use `--marker-only` to check only the marker, or use `--schema-only` to check only the live schema."
1861
+ }));
1862
+ if (flags.markerOnly && flags.strict) return notOk(errorInvalidVerifyMode({
1863
+ why: "`--strict` requires schema verification, but `--marker-only` skips it",
1864
+ choose: "Remove `--strict`, or use `db verify` / `db verify --schema-only` when you want to check the live schema in strict mode."
1865
+ }));
1866
+ if (flags.schemaOnly) return ok("schema-only");
1867
+ return ok(flags.markerOnly ? "marker-only" : "full");
1868
+ }
1869
+ function modeLabel(mode, strict) {
1870
+ if (mode === "marker-only") return "marker only";
1871
+ const strictness = strict ? "strict" : "tolerant";
1872
+ return mode === "schema-only" ? `schema only (${strictness})` : `full (marker + schema, ${strictness})`;
1873
+ }
1874
+ function invocation(mode, strict) {
1875
+ return [
1876
+ "db verify",
1877
+ ...mode === "marker-only" ? ["--marker-only"] : [],
1878
+ ...mode === "schema-only" ? ["--schema-only"] : [],
1879
+ ...strict ? ["--strict"] : []
1880
+ ].join(" ");
1881
+ }
1882
+ /** The marker verdict as a finding, keeping the code the commander raised. */
1883
+ function markerFindingDiagnostic(result) {
1884
+ const { ok: _ok, ...diagnostic } = normalizeError(markerFindingError(result)).toEnvelope();
1885
+ return diagnostic;
1886
+ }
1887
+ /**
1888
+ * The aggregate verifier's per-space marker drift as a finding on a completed
1889
+ * run, keeping the `MIGRATION.CONTRACT_SPACE_VIOLATION` envelope it was
1890
+ * raised with.
1891
+ */
1892
+ function markerDriftDiagnostic(drift) {
1893
+ const { ok: _ok, ...diagnostic } = normalizeError(drift).toEnvelope();
1894
+ return diagnostic;
1895
+ }
1896
+ function markerFindingError(result) {
1897
+ if (result.code === VERIFY_CODE_MARKER_MISSING) return errorMarkerMissing();
1898
+ if (result.code === VERIFY_CODE_HASH_MISMATCH) {
1899
+ if (!(result.marker?.storageHash === result.contract.storageHash)) return errorHashMismatch({
1900
+ why: "Contract storageHash does not match database marker",
1901
+ expected: result.contract.storageHash,
1902
+ ...ifDefined("actual", result.marker?.storageHash)
1903
+ });
1904
+ return errorHashMismatch({
1905
+ why: !result.contract.profileHash || result.marker?.profileHash === result.contract.profileHash ? "Contract hash does not match database marker" : "Contract profileHash does not match database marker",
1906
+ ...ifDefined("expected", result.contract.profileHash),
1907
+ ...ifDefined("actual", result.marker?.profileHash)
1908
+ });
1909
+ }
1910
+ if (result.code === VERIFY_CODE_TARGET_MISMATCH) return errorTargetMismatch(result.target.expected, result.target.actual ?? "unknown");
1911
+ return errorRuntime$1("CONTRACT.VERIFY_FAILED", result.summary, {
1912
+ why: "Verification failed",
1913
+ fix: "Check contract and database state"
1914
+ });
1915
+ }
1916
+ function verifyDocument(inputs) {
1917
+ return {
1918
+ ok: inputs.ok,
1919
+ summary: inputs.summary,
1920
+ mode: inputs.mode,
1921
+ contract: inputs.verified.contract,
1922
+ ...ifDefined("marker", inputs.verified.marker),
1923
+ target: inputs.verified.target,
1924
+ ...ifDefined("missingCodecs", inputs.verified.missingCodecs),
1925
+ ...ifDefined("codecCoverageSkipped", inputs.verified.codecCoverageSkipped),
1926
+ ...ifDefined("schema", inputs.schema),
1927
+ ...ifDefined("unclaimed", inputs.unclaimed),
1928
+ ...ifDefined("warning", inputs.warning),
1929
+ meta: {
1930
+ ...inputs.verified.meta ?? {},
1931
+ schemaVerification: inputs.schemaVerification
1932
+ },
1933
+ timings: { total: inputs.elapsed }
1934
+ };
1935
+ }
1936
+ function schemaSummary(combined) {
1937
+ return {
1938
+ summary: combined.result.summary,
1939
+ strict: combined.result.meta?.strict ?? false,
1940
+ warnings: (combined.result.schema.warnings?.issues ?? []).map((issue) => issue.path.join("/"))
1941
+ };
1942
+ }
1943
+ function headerBlock(inputs) {
1944
+ return {
1945
+ kind: "fields",
1946
+ rail: true,
1947
+ rows: [
1948
+ {
1949
+ label: "contract",
1950
+ value: inputs.contractPath
1951
+ },
1952
+ {
1953
+ label: "mode",
1954
+ value: modeLabel(inputs.mode, inputs.strict)
1955
+ },
1956
+ {
1957
+ label: "database",
1958
+ value: inputs.database
1959
+ }
1960
+ ]
1961
+ };
1962
+ }
1963
+ function verifyPresentations(inputs) {
1964
+ const document = inputs.document;
1965
+ const warnings = document.schema?.warnings ?? [];
1966
+ const unclaimed = document.unclaimed ?? [];
1967
+ return {
1968
+ human: () => [
1969
+ inputs.header,
1970
+ {
1971
+ kind: "summary",
1972
+ status: document.ok ? "ok" : "error",
1973
+ text: document.summary
1974
+ },
1975
+ ...document.ok ? [{
1976
+ kind: "fields",
1977
+ rows: [{
1978
+ label: "storageHash",
1979
+ value: document.contract.storageHash
1980
+ }, ...document.contract.profileHash === void 0 ? [] : [{
1981
+ label: "profileHash",
1982
+ value: document.contract.profileHash
1983
+ }]]
1984
+ }] : [],
1985
+ ...warnings.length === 0 && unclaimed.length === 0 ? [] : [{
1986
+ kind: "tree",
1987
+ roots: [...warnings.length === 0 ? [] : [{
1988
+ label: "Schema warnings",
1989
+ status: "warn",
1990
+ children: warnings.map((message) => ({
1991
+ label: message,
1992
+ status: "warn"
1993
+ }))
1994
+ }], ...unclaimed.length === 0 ? [] : [{
1995
+ label: "Unclaimed elements (declared by no contract)",
1996
+ status: "warn",
1997
+ children: unclaimed.map((name) => ({
1998
+ label: name,
1999
+ status: "warn"
2000
+ }))
2001
+ }]]
2002
+ }],
2003
+ ...document.warning === void 0 ? [] : [{
2004
+ kind: "summary",
2005
+ status: "warn",
2006
+ text: document.warning
2007
+ }]
2008
+ ],
2009
+ json: () => document
2010
+ };
2011
+ }
2012
+ function schemaPresentations(inputs) {
2013
+ return {
2014
+ human: () => [
2015
+ inputs.header,
2016
+ ...schemaFindingBlocks({
2017
+ result: inputs.document,
2018
+ unclaimed: inputs.document.unclaimed,
2019
+ strict: inputs.strict
2020
+ }),
2021
+ {
2022
+ kind: "summary",
2023
+ status: inputs.document.ok ? "ok" : "error",
2024
+ text: inputs.document.summary
2025
+ }
2026
+ ],
2027
+ json: () => inputs.document
2028
+ };
2029
+ }
2030
+ /**
2031
+ * One diagnostic per contract space whose live schema does not satisfy its
2032
+ * contract, plus the combined verdict when only the unclaimed list failed it.
2033
+ */
2034
+ function driftDiagnostics(inputs) {
2035
+ const perSpace = [...inputs.perSpace].filter(([, result]) => !result.ok).map(([space, result]) => schemaVerdictDiagnostic({
2036
+ result,
2037
+ space,
2038
+ nextActions: [PUSH_THE_CONTRACT, RECONCILE_BY_HAND]
2039
+ }));
2040
+ if (perSpace.length > 0) return perSpace;
2041
+ return [schemaVerdictDiagnostic({
2042
+ result: inputs.combined.result,
2043
+ space: void 0,
2044
+ nextActions: [{
2045
+ kind: "user-choice",
2046
+ label: "Declare the unclaimed elements in a contract, or drop them from the database"
2047
+ }]
2048
+ })];
2049
+ }
2050
+ /**
2051
+ * Builds the command with its control-client factory injected, so tests mount
2052
+ * the same tree over a fake client instead of mocking the client module.
2053
+ */
2054
+ function createDbVerifyCommand(createClient = createControlClient) {
2055
+ return defineOrmCommand({
2056
+ help: {
2057
+ summary: "Check whether the database marker and live schema match your contract",
2058
+ description: "Verifies the database marker first, then checks the database schema\nmatches your contract. Use `--marker-only` for marker-only verification,\n`--schema-only` to skip marker checks and inspect only the live schema,\nand `--strict` to fail if the database includes elements not present in\nthe contract.\nExit codes: 0 = the database matches the contract, 2 = the check could\nnot run (conflicting mode flags, no emitted contract, unreachable\ndatabase), 4 = drift or a marker finding.",
2059
+ examples: [
2060
+ "db verify",
2061
+ "db verify --db $DATABASE_URL",
2062
+ "db verify --strict",
2063
+ "db verify --schema-only",
2064
+ "db verify --marker-only",
2065
+ "db verify --json"
2066
+ ]
2067
+ },
2068
+ args: { flags: {
2069
+ db: dbFlag,
2070
+ markerOnly: flag.boolean({ brief: "Skip schema verification and only check the database marker" }),
2071
+ schemaOnly: flag.boolean({ brief: "Skip marker verification and only check whether the live schema satisfies the contract" }),
2072
+ strict: flag.boolean({ brief: "Treat schema elements not present in the contract as an error" })
2073
+ } },
2074
+ needs: { config: ormConfigSection },
2075
+ exitCodes: { 4: "verification found drift or marker findings" },
2076
+ handler: async (args, ctx) => {
2077
+ const strict = args.flags.strict;
2078
+ const resolved = resolveMode({
2079
+ markerOnly: args.flags.markerOnly,
2080
+ schemaOnly: args.flags.schemaOnly,
2081
+ strict
2082
+ });
2083
+ if (!resolved.ok) return notOk(resolved.failure);
2084
+ const mode = resolved.value;
2085
+ const commandInvocation = invocation(mode, strict);
2086
+ const emitted = await readEmittedContract({
2087
+ config: ctx.config,
2088
+ cwd: ctx.cwd,
2089
+ commandName: commandInvocation
2090
+ });
2091
+ if (!emitted.ok) return notOk(emitted.failure);
2092
+ const connection = requireVerifyConnection({
2093
+ config: ctx.config,
2094
+ db: args.flags.db,
2095
+ invocation: commandInvocation
2096
+ });
2097
+ if (!connection.ok) return notOk(connection.failure);
2098
+ const dbConnection = connection.value;
2099
+ const header = headerBlock({
2100
+ contractPath: emitted.value.displayPath,
2101
+ mode,
2102
+ strict,
2103
+ database: maskConnectionUrl(dbConnection)
2104
+ });
2105
+ const migrationsDir = migrationsDirFor(ctx.config, ctx.cwd);
2106
+ const client = createClient({
2107
+ family: ctx.config.family,
2108
+ target: ctx.config.target,
2109
+ adapter: ctx.config.adapter,
2110
+ ...ifDefined("driver", ctx.config.driver),
2111
+ extensions: ctx.config.extensions ?? []
2112
+ });
2113
+ const onProgress = controlProgressReporter(ctx.report);
2114
+ const startedAt = Date.now();
2115
+ try {
2116
+ if (mode === "schema-only") {
2117
+ await client.connect(dbConnection);
2118
+ const aggregate = await client.dbVerify({
2119
+ contract: emitted.value.contract,
2120
+ migrationsDir,
2121
+ strict,
2122
+ skipSchema: false,
2123
+ skipMarker: true,
2124
+ onProgress
2125
+ });
2126
+ if (!aggregate.ok) return notOk(normalizeError(aggregate.failure));
2127
+ const combined = combineVerifyResults(aggregate.value.schemaResults, aggregate.value.appSpaceId, strict, aggregate.value.unclaimed);
2128
+ const document = {
2129
+ ...combined.result,
2130
+ unclaimed: combined.unclaimed
2131
+ };
2132
+ return ok(ctx.present({
2133
+ data: document,
2134
+ exitCode: combined.result.ok ? 0 : FINDINGS_EXIT_CODE$1,
2135
+ diagnostics: combined.result.ok ? [] : driftDiagnostics({
2136
+ perSpace: aggregate.value.schemaResults,
2137
+ combined
2138
+ })
2139
+ }, schemaPresentations({
2140
+ document,
2141
+ header,
2142
+ strict
2143
+ })));
2144
+ }
2145
+ const verified = await client.verify({
2146
+ contract: emitted.value.contract,
2147
+ connection: dbConnection,
2148
+ onProgress
2149
+ });
2150
+ if (!verified.ok) {
2151
+ const document = verifyDocument({
2152
+ ok: false,
2153
+ mode,
2154
+ summary: verified.summary,
2155
+ verified,
2156
+ schema: void 0,
2157
+ schemaVerification: "skipped",
2158
+ unclaimed: void 0,
2159
+ warning: void 0,
2160
+ elapsed: Date.now() - startedAt
2161
+ });
2162
+ return ok(ctx.present({
2163
+ data: document,
2164
+ exitCode: FINDINGS_EXIT_CODE$1,
2165
+ diagnostics: [markerFindingDiagnostic(verified)]
2166
+ }, verifyPresentations({
2167
+ document,
2168
+ header
2169
+ })));
2170
+ }
2171
+ const aggregate = await client.dbVerify({
2172
+ contract: emitted.value.contract,
2173
+ migrationsDir,
2174
+ strict,
2175
+ skipSchema: mode === "marker-only",
2176
+ skipMarker: false,
2177
+ onProgress
2178
+ });
2179
+ if (!aggregate.ok) return notOk(normalizeError(aggregate.failure));
2180
+ const drift = aggregate.value.markerDrift;
2181
+ if (drift !== null) {
2182
+ const driftCombined = mode === "marker-only" ? void 0 : combineVerifyResults(aggregate.value.schemaResults, aggregate.value.appSpaceId, strict, aggregate.value.unclaimed);
2183
+ const document = verifyDocument({
2184
+ ok: false,
2185
+ mode,
2186
+ summary: normalizeError(drift).message,
2187
+ verified,
2188
+ schema: driftCombined === void 0 ? void 0 : schemaSummary(driftCombined),
2189
+ schemaVerification: driftCombined === void 0 ? "skipped" : "performed",
2190
+ unclaimed: driftCombined?.unclaimed,
2191
+ warning: void 0,
2192
+ elapsed: Date.now() - startedAt
2193
+ });
2194
+ return ok(ctx.present({
2195
+ data: document,
2196
+ exitCode: FINDINGS_EXIT_CODE$1,
2197
+ diagnostics: [markerDriftDiagnostic(drift), ...driftCombined !== void 0 && !driftCombined.result.ok ? driftDiagnostics({
2198
+ perSpace: aggregate.value.schemaResults,
2199
+ combined: driftCombined
2200
+ }) : []]
2201
+ }, verifyPresentations({
2202
+ document,
2203
+ header
2204
+ })));
2205
+ }
2206
+ if (mode === "marker-only") {
2207
+ const document = verifyDocument({
2208
+ ok: true,
2209
+ mode,
2210
+ summary: "Database marker matches contract",
2211
+ verified,
2212
+ schema: void 0,
2213
+ schemaVerification: "skipped",
2214
+ unclaimed: void 0,
2215
+ warning: "Schema verification skipped because --marker-only was provided",
2216
+ elapsed: Date.now() - startedAt
2217
+ });
2218
+ return ok(ctx.present({
2219
+ data: document,
2220
+ exitCode: 0
2221
+ }, verifyPresentations({
2222
+ document,
2223
+ header
2224
+ })));
2225
+ }
2226
+ const combined = combineVerifyResults(aggregate.value.schemaResults, aggregate.value.appSpaceId, strict, aggregate.value.unclaimed);
2227
+ if (!combined.result.ok) {
2228
+ const document = {
2229
+ ...combined.result,
2230
+ unclaimed: combined.unclaimed
2231
+ };
2232
+ return ok(ctx.present({
2233
+ data: document,
2234
+ exitCode: FINDINGS_EXIT_CODE$1,
2235
+ diagnostics: driftDiagnostics({
2236
+ perSpace: aggregate.value.schemaResults,
2237
+ combined
2238
+ })
2239
+ }, schemaPresentations({
2240
+ document,
2241
+ header,
2242
+ strict
2243
+ })));
2244
+ }
2245
+ const document = verifyDocument({
2246
+ ok: true,
2247
+ mode,
2248
+ summary: "Database marker and schema match contract",
2249
+ verified,
2250
+ schema: schemaSummary(combined),
2251
+ schemaVerification: "performed",
2252
+ unclaimed: combined.unclaimed,
2253
+ warning: void 0,
2254
+ elapsed: Date.now() - startedAt
2255
+ });
2256
+ return ok(ctx.present({
2257
+ data: document,
2258
+ exitCode: 0
2259
+ }, verifyPresentations({
2260
+ document,
2261
+ header
2262
+ })));
2263
+ } catch (error) {
2264
+ if (isInternalError(error)) throw error;
2265
+ return notOk(verificationThrow({
2266
+ error,
2267
+ invocation: commandInvocation,
2268
+ connection: dbConnection
2269
+ }));
2270
+ } finally {
2271
+ await closeQuietly(client);
2272
+ }
2273
+ }
2274
+ });
2275
+ }
2276
+ const dbVerifyCommand = createDbVerifyCommand();
1461
2277
  const NOTHING_TO_FORMAT = "Nothing to format (contract source is not PSL).";
1462
2278
  function formatPresentations(document, cwd) {
1463
2279
  const path = document.path;
@@ -1657,7 +2473,7 @@ function initPresentations(inputs) {
1657
2473
  * therefore skips the emit — never pays for either.
1658
2474
  */
1659
2475
  async function emitScaffoldedContract(ctx) {
1660
- const { executeContractEmit } = await import("./contract-emit-Bzt11N4v-BQ2Pr8KG.mjs");
2476
+ const { executeContractEmit } = await import("./contract-emit-DDWBBvF1-BeGZCRrb.mjs");
1661
2477
  const { loadConfigForSections } = await import("./exports-BZLNbtkY.mjs").then((n) => n.t);
1662
2478
  const configPath = join(ctx.cwd, "prisma-next.config.ts");
1663
2479
  const loaded = await loadConfigForSections(configPath, [
@@ -2408,6 +3224,71 @@ const createInitCommand = (injected) => defineOrmCommand({
2408
3224
  }
2409
3225
  });
2410
3226
  const initCommand = createInitCommand({ emitScaffoldedContract });
3227
+ /**
3228
+ * R-S5-12 asks every command to end at 143 for SIGTERM and 130 otherwise, and
3229
+ * a server command is the one kind the engine leaves to do it: it settles the
3230
+ * handler's code verbatim, on the reasoning that a protocol conclusion was
3231
+ * never the CLI's to author. The two readings are in tension — this one wins
3232
+ * here, and the tension is recorded for the engine's owners, because it means
3233
+ * a SIGTERM landing after a clean `shutdown` reports 143 for a conversation
3234
+ * that ended correctly at 0.
3235
+ */
3236
+ function signalExitCode(reason) {
3237
+ return reason === "SIGTERM" ? 143 : 130;
3238
+ }
3239
+ const lspCommand = defineServerCommand({
3240
+ help: {
3241
+ summary: "Start the Prisma Next language server",
3242
+ description: "Launches a Language Server Protocol server that publishes PSL parse diagnostics\nand handles whole-document PSL formatting for the schema inputs declared in\nyour config (contract.source.inputs). Formatting uses the Prisma Next PSL\nformatter and the formatter block from the project config.\nCommunicates over stdio; intended to be spawned by an\neditor, not run interactively. The server keeps running until the editor client\ndisconnects.",
3243
+ examples: ["lsp"]
3244
+ },
3245
+ args: { flags: {
3246
+ stdio: flag.boolean({ brief: "Communicate with the editor over stdio (the default and only transport)" }),
3247
+ clientProcessId: flag.number({
3248
+ brief: "Process id of the editor that spawned the server; the server ends when it dies",
3249
+ placeholder: "pid"
3250
+ })
3251
+ } },
3252
+ handler: async (args, io) => {
3253
+ const exitCode = await withoutClientProcessIdInArgv(async () => {
3254
+ const { startServer } = await import("./exports-B3xY_FHp.mjs");
3255
+ return startServer({
3256
+ stdin: io.stdin,
3257
+ stdout: io.stdout,
3258
+ stderr: io.stderr,
3259
+ signal: io.signal,
3260
+ ...ifDefined("clientProcessId", args.flags.clientProcessId)
3261
+ });
3262
+ });
3263
+ return io.signal.aborted ? signalExitCode(io.signal.reason) : exitCode;
3264
+ }
3265
+ });
3266
+ /**
3267
+ * Importing `vscode-languageserver/node` reads `--clientProcessId` off
3268
+ * `process.argv` and arms a parent-watch interval that is never unref'd, so a
3269
+ * settled run would leave the process hanging. The server watches the client
3270
+ * process itself (from the parsed flag), so the argument is hidden for the
3271
+ * import and restored after.
3272
+ */
3273
+ async function withoutClientProcessIdInArgv(run) {
3274
+ const original = process.argv;
3275
+ const scrubbed = [];
3276
+ for (let index = 0; index < original.length; index += 1) {
3277
+ const token = original[index];
3278
+ if (token === "--clientProcessId") {
3279
+ index += 1;
3280
+ continue;
3281
+ }
3282
+ if (token === void 0 || token.startsWith("--clientProcessId=")) continue;
3283
+ scrubbed.push(token);
3284
+ }
3285
+ process.argv = scrubbed;
3286
+ try {
3287
+ return await run();
3288
+ } finally {
3289
+ process.argv = original;
3290
+ }
3291
+ }
2411
3292
  const STATUS_ACTION = runCommandAction("Check every space against the database", "prisma-next migration status");
2412
3293
  /**
2413
3294
  * The route the migration will take. The graph is a drawing — the engine cannot
@@ -2729,6 +3610,146 @@ function createMigrateCommand(createClient) {
2729
3610
  }
2730
3611
  const migrateCommand = createMigrateCommand(createControlClient);
2731
3612
  /**
3613
+ * The check completed and the artifacts it read are not internally consistent.
3614
+ * The findings ride the envelope as diagnostics; the run itself did its job,
3615
+ * which is why this is not an errored settlement.
3616
+ */
3617
+ const FINDINGS_EXIT_CODE = 4;
3618
+ /**
3619
+ * One integrity failure as an envelope diagnostic. `error` is the honest
3620
+ * severity: nothing about the artifacts is merely worth a look, and exit 4
3621
+ * makes it legal — the engine refuses a severity-`error` diagnostic only on a
3622
+ * run that exits 0.
3623
+ *
3624
+ * The summary leads with the path because the engine's diagnostic renderer
3625
+ * prints `code`, `summary`, `why` and the next actions and never prints
3626
+ * `where`. Several failure texts name no package on their own — a hash
3627
+ * mismatch reads "Stored hash X does not match recomputed hash Y" — so
3628
+ * without the path a project with fifty migrations cannot be told which one
3629
+ * is broken. `where` still carries the path on its own for a `--json`
3630
+ * consumer.
3631
+ */
3632
+ function failureDiagnostic(failure) {
3633
+ if (!isStructuredErrorCode(failure.code)) throw new InternalError(`migration check produced the failure code "${failure.code}", which is not a dotted NAMESPACE.SUBCODE.`);
3634
+ return {
3635
+ code: failure.code,
3636
+ severity: "error",
3637
+ summary: `${failure.where}: ${failure.why}`,
3638
+ nextActions: failure.nextActions,
3639
+ where: { path: failure.where },
3640
+ meta: { space: failure.space }
3641
+ };
3642
+ }
3643
+ function checkPresentations(inputs) {
3644
+ const summary = inputs.resolvedSpaceId === void 0 ? inputs.document.summary : `${inputs.document.summary} (space: ${inputs.resolvedSpaceId})`;
3645
+ return {
3646
+ human: () => [{
3647
+ kind: "fields",
3648
+ rail: true,
3649
+ rows: [
3650
+ {
3651
+ label: "migrations",
3652
+ value: inputs.migrationsRelative
3653
+ },
3654
+ ...inputs.target === void 0 ? [] : [{
3655
+ label: "target",
3656
+ value: inputs.target
3657
+ }],
3658
+ ...inputs.space === void 0 ? [] : [{
3659
+ label: "space",
3660
+ value: inputs.space
3661
+ }]
3662
+ ]
3663
+ }, {
3664
+ kind: "summary",
3665
+ status: inputs.document.ok ? "ok" : "error",
3666
+ text: summary
3667
+ }],
3668
+ json: () => inputs.document
3669
+ };
3670
+ }
3671
+ const migrationCheckCommand = defineOrmCommand({
3672
+ help: {
3673
+ summary: "Verify artifact and graph integrity",
3674
+ description: "Validates that on-disk migration packages are internally consistent\n(hashes match, manifests are complete) and that the graph is well-formed\n(edges connect, refs point at valid nodes). The whole-graph check spans\nevery contract space by default; pass --space <id> to narrow to one. A\nmigration reference checks a single package, resolved across all contract\nspaces (narrow with --space; an ambiguous reference cannot be checked).\nOffline — does not consult the database.\nExit codes: 0 = all checks passed, 2 = precondition failed (unresolved\ntarget or unknown --space), 4 = integrity failure(s) found.",
3675
+ examples: [
3676
+ "migration check",
3677
+ "migration check --space app",
3678
+ "migration check 20260101-add-users",
3679
+ "migration check 20260101-add-users --space app",
3680
+ "migration check --json"
3681
+ ]
3682
+ },
3683
+ args: {
3684
+ positionals: { target: positional.optionalString({
3685
+ brief: "Migration reference: directory name, hash/prefix, ref, or path",
3686
+ placeholder: "target"
3687
+ }) },
3688
+ flags: { space: flag.string({
3689
+ brief: "Narrow output to a single contract space",
3690
+ placeholder: "id"
3691
+ }) }
3692
+ },
3693
+ needs: { config: ormConfigSection },
3694
+ exitCodes: { 4: "integrity check found failures" },
3695
+ handler: async (args, ctx) => {
3696
+ const { target } = args.positionals;
3697
+ const spaceFilter = args.flags.space;
3698
+ const migrationsDir = migrationsDirFor(ctx.config, ctx.cwd);
3699
+ const appMigrationsDir = appMigrationsDirFor(ctx.config, ctx.cwd);
3700
+ const appMigrationsRelative = displayPath(appMigrationsDir, ctx.cwd);
3701
+ const loaded = await buildReadAggregate(ctx.config, { migrationsDir });
3702
+ if (!loaded.ok) return notOk(normalizeError(loaded.failure));
3703
+ const spaces = await enumerateCheckSpaces(loaded.value.aggregate, migrationsDir, ctx.cwd);
3704
+ let document;
3705
+ let resolvedSpaceId;
3706
+ if (target !== void 0) {
3707
+ const outcome = await checkSingleTarget(target, {
3708
+ spaces,
3709
+ ...ifDefined("spaceFilter", spaceFilter),
3710
+ appMigrationsDir,
3711
+ appMigrationsRelative,
3712
+ cwd: ctx.cwd
3713
+ });
3714
+ if (outcome.error !== void 0) return notOk(normalizeError(outcome.error));
3715
+ const result = outcome.result;
3716
+ if (result === void 0 || outcome.exitCode === 2) return notOk(normalizeError(errorMigrationPackageNotFound(result?.summary ?? `Migration package for "${target}" not found on disk`)));
3717
+ document = result;
3718
+ resolvedSpaceId = outcome.resolvedSpaceId;
3719
+ } else {
3720
+ const checked = await runMigrationCheck({
3721
+ spaces,
3722
+ ...ifDefined("spaceFilter", spaceFilter)
3723
+ });
3724
+ if (!checked.ok) return notOk(normalizeError(checked.failure));
3725
+ const violations = await loadAggregateIntegrityViolations(ctx.config, migrationsDir);
3726
+ const scoped = spaceFilter === void 0 ? violations : violations.filter((violation) => violation.kind !== "disjointness" && violation.spaceId === spaceFilter);
3727
+ const failures = [...checked.value.failures, ...scoped.map((violation) => integrityViolationToCheckFailure(violation, migrationsDir))];
3728
+ document = failures.length === 0 ? {
3729
+ ok: true,
3730
+ failures: [],
3731
+ summary: "All checks passed"
3732
+ } : {
3733
+ ok: false,
3734
+ failures: [...failures],
3735
+ summary: `${failures.length} integrity failure(s)`
3736
+ };
3737
+ }
3738
+ const diagnostics = document.failures.map(failureDiagnostic);
3739
+ return ok(ctx.present({
3740
+ data: document,
3741
+ exitCode: diagnostics.length === 0 ? 0 : FINDINGS_EXIT_CODE,
3742
+ diagnostics
3743
+ }, checkPresentations({
3744
+ document,
3745
+ migrationsRelative: appMigrationsRelative,
3746
+ target,
3747
+ space: spaceFilter,
3748
+ resolvedSpaceId
3749
+ })));
3750
+ }
3751
+ });
3752
+ /**
2732
3753
  * The tree is a drawing for a reader; the DOT document is a graph description
2733
3754
  * for another program, so it is the one thing here that belongs on stdout.
2734
3755
  */
@@ -4164,10 +5185,14 @@ const ormCommandFamily = defineCommandFamily({
4164
5185
  "contract infer": contractInferCommand,
4165
5186
  "db init": dbInitCommand,
4166
5187
  "db schema": dbSchemaCommand,
5188
+ "db sign": dbSignCommand,
4167
5189
  "db update": dbUpdateCommand,
5190
+ "db verify": dbVerifyCommand,
4168
5191
  format: formatCommand,
4169
5192
  init: initCommand,
5193
+ lsp: lspCommand,
4170
5194
  migrate: migrateCommand,
5195
+ "migration check": migrationCheckCommand,
4171
5196
  "migration graph": migrationGraphCommand,
4172
5197
  "migration list": migrationListCommand,
4173
5198
  "migration log": migrationLogCommand,