@prisma/orm-toolchain 8.0.0-rc.1-dev.38 → 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 (171) hide show
  1. package/dist/bin__prisma-next.mjs +25 -318
  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 +2895 -182
  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.d.mts +1 -1
  21. package/dist/cli__commands__migration-check.mjs +2 -2
  22. package/dist/cli__commands__migration-graph.d.mts +2 -2
  23. package/dist/cli__commands__migration-graph.mjs +1 -1
  24. package/dist/cli__commands__migration-list.d.mts +2 -2
  25. package/dist/cli__commands__migration-list.mjs +1 -1
  26. package/dist/cli__commands__migration-log.d.mts +2 -2
  27. package/dist/cli__commands__migration-log.mjs +1 -1
  28. package/dist/cli__commands__migration-new.mjs +1 -1
  29. package/dist/cli__commands__migration-plan.d.mts +1 -1
  30. package/dist/cli__commands__migration-plan.mjs +1 -1
  31. package/dist/cli__commands__migration-show.d.mts +1 -1
  32. package/dist/cli__commands__migration-show.mjs +1 -1
  33. package/dist/cli__commands__migration-status.d.mts +2 -2
  34. package/dist/cli__commands__migration-status.mjs +2 -2
  35. package/dist/cli__commands__ref.mjs +1 -1
  36. package/dist/cli__commands__telemetry.mjs +1 -1
  37. package/dist/cli__control-api.d.mts +4 -4
  38. package/dist/cli__control-api.mjs +15 -15
  39. package/dist/cli__control-api__testing.d.mts +1 -1
  40. package/dist/cli__control-api__testing.mjs +2 -1
  41. package/dist/cli__control-api__testing.mjs.map +1 -1
  42. package/dist/cli__init-output.d.mts +1 -1
  43. package/dist/cli__init-output.mjs +1 -1
  44. package/dist/{client-DU9qtBxW-BjVHiKzE.mjs → client-C6Qp5ujC-Dxb7r79B.mjs} +12 -15
  45. package/dist/client-C6Qp5ujC-Dxb7r79B.mjs.map +1 -0
  46. package/dist/code-templates-D73q329L-CSx0Jg-6.mjs +295 -0
  47. package/dist/code-templates-D73q329L-CSx0Jg-6.mjs.map +1 -0
  48. package/dist/combine-verify-results-B87B_pMc-D4l22OqY.mjs +65 -0
  49. package/dist/combine-verify-results-B87B_pMc-D4l22OqY.mjs.map +1 -0
  50. package/dist/{command-helpers-CwLvFwMB-BWwUQhlT.mjs → command-helpers-BCgwcqTe-lNCtppzM.mjs} +3 -3
  51. package/dist/{command-helpers-CwLvFwMB-BWwUQhlT.mjs.map → command-helpers-BCgwcqTe-lNCtppzM.mjs.map} +1 -1
  52. package/dist/{contract-at-errors-Dptf8RE_-B5gr04Sc.mjs → contract-at-errors-BSoDI0Hw-BXeUNE3s.mjs} +3 -3
  53. package/dist/{contract-at-errors-Dptf8RE_-B5gr04Sc.mjs.map → contract-at-errors-BSoDI0Hw-BXeUNE3s.mjs.map} +1 -1
  54. package/dist/contract-emit-DDWBBvF1-BeGZCRrb.mjs +2 -0
  55. package/dist/{contract-emit-CZQZ1i4z-p9LSGmmQ.mjs → contract-emit-DFScp9D6-6H-UJMFv.mjs} +5 -5
  56. package/dist/{contract-emit-CZQZ1i4z-p9LSGmmQ.mjs.map → contract-emit-DFScp9D6-6H-UJMFv.mjs.map} +1 -1
  57. package/dist/{contract-emit-BQFpcb2A-BwT9iVdb.mjs → contract-emit-DsvAx-dY-DQzoDO34.mjs} +5 -5
  58. package/dist/{contract-emit-BQFpcb2A-BwT9iVdb.mjs.map → contract-emit-DsvAx-dY-DQzoDO34.mjs.map} +1 -1
  59. package/dist/{contract-infer-C6cYOihE-CIUCgmw0.mjs → contract-infer-BwIDGl7v-CZrdWXAr.mjs} +4 -4
  60. package/dist/{contract-infer-C6cYOihE-CIUCgmw0.mjs.map → contract-infer-BwIDGl7v-CZrdWXAr.mjs.map} +1 -1
  61. package/dist/{contract-snapshot-resolution-DvZvbNcZ-DHFCWe_k.mjs → contract-snapshot-resolution-De2VvOJn-DqIAV9cr.mjs} +4 -4
  62. package/dist/{contract-snapshot-resolution-DvZvbNcZ-DHFCWe_k.mjs.map → contract-snapshot-resolution-De2VvOJn-DqIAV9cr.mjs.map} +1 -1
  63. package/dist/{contract-space-aggregate-loader-CoLTf3Ce-pQDru2w0.mjs → contract-space-aggregate-loader-fa04OIaL-B7LXHle3.mjs} +4 -4
  64. package/dist/{contract-space-aggregate-loader-CoLTf3Ce-pQDru2w0.mjs.map → contract-space-aggregate-loader-fa04OIaL-B7LXHle3.mjs.map} +1 -1
  65. package/dist/{db-init-DypCy1e3-CBrYfhHF.mjs → db-init-BolXrKAI-CwG-zEDW.mjs} +6 -6
  66. package/dist/{db-init-DypCy1e3-CBrYfhHF.mjs.map → db-init-BolXrKAI-CwG-zEDW.mjs.map} +1 -1
  67. package/dist/{db-init-failure-BmCcHUfc-BqDxyrJE.mjs → db-init-failure-B5cQML4A-5zr-99Ek.mjs} +3 -3
  68. package/dist/{db-init-failure-BmCcHUfc-BqDxyrJE.mjs.map → db-init-failure-B5cQML4A-5zr-99Ek.mjs.map} +1 -1
  69. package/dist/{db-schema-DHfPM-5V-JeCjrQ55.mjs → db-schema-DvdLBdEY-Dl6e1d_Y.mjs} +4 -4
  70. package/dist/{db-schema-DHfPM-5V-JeCjrQ55.mjs.map → db-schema-DvdLBdEY-Dl6e1d_Y.mjs.map} +1 -1
  71. package/dist/{db-sign-DbAxRcZh-C-nT9kcG.mjs → db-sign-DCp4c8CA-B3tun-kh.mjs} +6 -6
  72. package/dist/{db-sign-DbAxRcZh-C-nT9kcG.mjs.map → db-sign-DCp4c8CA-B3tun-kh.mjs.map} +1 -1
  73. package/dist/{db-update-J59yROwL-DCP-_z2W.mjs → db-update-CfayE8WE-CPhQyDaZ.mjs} +6 -6
  74. package/dist/{db-update-J59yROwL-DCP-_z2W.mjs.map → db-update-CfayE8WE-CPhQyDaZ.mjs.map} +1 -1
  75. package/dist/{db-verify-0TpDMziA-CJDKutMN.mjs → db-verify-BN7IrOAL-kEzRNJUl.mjs} +7 -65
  76. package/dist/db-verify-BN7IrOAL-kEzRNJUl.mjs.map +1 -0
  77. package/dist/{exports-DaxzMVtq.mjs → exports-B3xY_FHp.mjs} +304 -18
  78. package/dist/exports-B3xY_FHp.mjs.map +1 -0
  79. package/dist/{format-cbJY7l6v-CjMUDTAs.mjs → format-Ca7dUE6B-BMFqrc6D.mjs} +5 -5
  80. package/dist/{format-cbJY7l6v-CjMUDTAs.mjs.map → format-Ca7dUE6B-BMFqrc6D.mjs.map} +1 -1
  81. package/dist/{framework-components-C3K7SBeC-Bj5gx85-.mjs → framework-components-Bau7o1-J-DTp6AUoq.mjs} +3 -3
  82. package/dist/{framework-components-C3K7SBeC-Bj5gx85-.mjs.map → framework-components-Bau7o1-J-DTp6AUoq.mjs.map} +1 -1
  83. package/dist/init-DJrxDasP-DoQftaPY.mjs +800 -0
  84. package/dist/init-DJrxDasP-DoQftaPY.mjs.map +1 -0
  85. package/dist/{inspect-live-schema-Cf77j9Vd-i5fzNW4T.mjs → inspect-live-schema-BPHXdvqW-DrzL2ZkQ.mjs} +5 -5
  86. package/dist/{inspect-live-schema-Cf77j9Vd-i5fzNW4T.mjs.map → inspect-live-schema-BPHXdvqW-DrzL2ZkQ.mjs.map} +1 -1
  87. package/dist/integrity-violation-to-check-failure-BmWMLAae-DqiC4_3p.mjs +115 -0
  88. package/dist/integrity-violation-to-check-failure-BmWMLAae-DqiC4_3p.mjs.map +1 -0
  89. package/dist/{invariants-1zL5-9Mc-BCeOLxd_.mjs → invariants-Bltd8DyA-Cg_1Lu0q.mjs} +4 -4
  90. package/dist/{invariants-1zL5-9Mc-BCeOLxd_.mjs.map → invariants-Bltd8DyA-Cg_1Lu0q.mjs.map} +1 -1
  91. package/dist/{legend-BQcPKTLe-bn9e4_ZU.mjs → legend-DGv9e2_0-BtetgRz4.mjs} +3 -3
  92. package/dist/{legend-BQcPKTLe-bn9e4_ZU.mjs.map → legend-DGv9e2_0-BtetgRz4.mjs.map} +1 -1
  93. package/dist/{migrate-CgSnzAUm-aGstaO5N.mjs → migrate-BXATUjYE-Do79Imf-.mjs} +12 -12
  94. package/dist/{migrate-CgSnzAUm-aGstaO5N.mjs.map → migrate-BXATUjYE-Do79Imf-.mjs.map} +1 -1
  95. package/dist/{migrate-failure-CnoUcDms-taa9pfd7.mjs → migrate-failure-D4NvkoCk-0bttmQs2.mjs} +5 -5
  96. package/dist/{migrate-failure-CnoUcDms-taa9pfd7.mjs.map → migrate-failure-D4NvkoCk-0bttmQs2.mjs.map} +1 -1
  97. package/dist/{migrate-show-Dlo-YzOk-BXo-DmwI.d.mts → migrate-show-B8UJ9dmb-C4RTPbDk.d.mts} +3 -3
  98. package/dist/{migrate-show-Dlo-YzOk-BXo-DmwI.d.mts.map → migrate-show-B8UJ9dmb-C4RTPbDk.d.mts.map} +1 -1
  99. package/dist/{migrate-show-kVUG1xdo-bVTW8tu4.mjs → migrate-show-C_9xR4Qt-B-Y0PGKw.mjs} +6 -6
  100. package/dist/{migrate-show-kVUG1xdo-bVTW8tu4.mjs.map → migrate-show-C_9xR4Qt-B-Y0PGKw.mjs.map} +1 -1
  101. package/dist/{migration-check-CBMoMDX2-DhSEOGNg.mjs → migration-check-Bbdw7t-r-C2VTMK61.mjs} +6 -6
  102. package/dist/{migration-check-CBMoMDX2-DhSEOGNg.mjs.map → migration-check-Bbdw7t-r-C2VTMK61.mjs.map} +1 -1
  103. package/dist/migration-check-DbHgYK7F-7mtYNVFu.mjs +163 -0
  104. package/dist/migration-check-DbHgYK7F-7mtYNVFu.mjs.map +1 -0
  105. package/dist/{migration-command-scaffold-B1BiWKLI-Bskk5UKX.mjs → migration-command-scaffold-SzjR2naH-Yi3-rNfX.mjs} +5 -5
  106. package/dist/{migration-command-scaffold-B1BiWKLI-Bskk5UKX.mjs.map → migration-command-scaffold-SzjR2naH-Yi3-rNfX.mjs.map} +1 -1
  107. package/dist/{migration-graph-B30X5398-BH3zB9Mn.mjs → migration-graph-B8WxW_tm-qGNf7jQh.mjs} +3 -3
  108. package/dist/{migration-graph-B30X5398-BH3zB9Mn.mjs.map → migration-graph-B8WxW_tm-qGNf7jQh.mjs.map} +1 -1
  109. package/dist/{migration-graph-D2dbLCkl-CCHL0aDA.mjs → migration-graph-BOwu76mF-kOTWFvfV.mjs} +9 -9
  110. package/dist/{migration-graph-D2dbLCkl-CCHL0aDA.mjs.map → migration-graph-BOwu76mF-kOTWFvfV.mjs.map} +1 -1
  111. package/dist/{migration-graph-command-render-BeuEyf2B-BNH9oUB_.mjs → migration-graph-command-render-h0VdTkSM-C3rPZEw1.mjs} +17 -3
  112. package/dist/migration-graph-command-render-h0VdTkSM-C3rPZEw1.mjs.map +1 -0
  113. package/dist/{migration-graph-sections-0lKA5l1b-CTHQquu7.mjs → migration-graph-sections-BBHPOFN--COKyUKQ4.mjs} +4 -4
  114. package/dist/{migration-graph-sections-0lKA5l1b-CTHQquu7.mjs.map → migration-graph-sections-BBHPOFN--COKyUKQ4.mjs.map} +1 -1
  115. package/dist/{migration-list-DCx0KOFp-B3MiGnpa.mjs → migration-list-CKuYcMQq-CubZzE9i.mjs} +7 -7
  116. package/dist/{migration-list-DCx0KOFp-B3MiGnpa.mjs.map → migration-list-CKuYcMQq-CubZzE9i.mjs.map} +1 -1
  117. package/dist/{migration-list-BQTfSGbT-DoNqbNsu.mjs → migration-list-CY08bD8I-PoXuv94c.mjs} +3 -3
  118. package/dist/{migration-list-BQTfSGbT-DoNqbNsu.mjs.map → migration-list-CY08bD8I-PoXuv94c.mjs.map} +1 -1
  119. package/dist/{migration-log-CJ6_9_uj-uWyc3vlC.mjs → migration-log-CUbGla-9-BLIrWjwN.mjs} +8 -8
  120. package/dist/{migration-log-CJ6_9_uj-uWyc3vlC.mjs.map → migration-log-CUbGla-9-BLIrWjwN.mjs.map} +1 -1
  121. package/dist/{migration-log-table-DRiOnvzf-zTQBThqe.mjs → migration-log-table-eES9lPjv-BCFm8qJr.mjs} +3 -3
  122. package/dist/{migration-log-table-DRiOnvzf-zTQBThqe.mjs.map → migration-log-table-eES9lPjv-BCFm8qJr.mjs.map} +1 -1
  123. package/dist/{migration-new-CXLgOLXz-2C5s_q7n.mjs → migration-new-ChvZjf5X-BFhEM0BF.mjs} +4 -4
  124. package/dist/{migration-new-CXLgOLXz-2C5s_q7n.mjs.map → migration-new-ChvZjf5X-BFhEM0BF.mjs.map} +1 -1
  125. package/dist/{migration-new-Bp5dPKnF-D-Fb6vEp.mjs → migration-new-DXMvJdbB-BkrpDfcr.mjs} +7 -7
  126. package/dist/{migration-new-Bp5dPKnF-D-Fb6vEp.mjs.map → migration-new-DXMvJdbB-BkrpDfcr.mjs.map} +1 -1
  127. package/dist/{migration-path-target-BNTSTPAc-D7dQ4K7x.mjs → migration-path-target-JDWqF9kj-B7zoMq6X.mjs} +3 -3
  128. package/dist/{migration-path-target-BNTSTPAc-D7dQ4K7x.mjs.map → migration-path-target-JDWqF9kj-B7zoMq6X.mjs.map} +1 -1
  129. package/dist/{migration-plan-CharRhoN-BIB3WL65.d.mts → migration-plan-BV9f5Xjq-DiyscOMc.d.mts} +3 -3
  130. package/dist/{migration-plan-CharRhoN-BIB3WL65.d.mts.map → migration-plan-BV9f5Xjq-DiyscOMc.d.mts.map} +1 -1
  131. package/dist/{migration-plan-BxfF1Hdo-BKn0xMlY.mjs → migration-plan-Bz1hOTHF-CFCtPuOv.mjs} +4 -4
  132. package/dist/{migration-plan-BxfF1Hdo-BKn0xMlY.mjs.map → migration-plan-Bz1hOTHF-CFCtPuOv.mjs.map} +1 -1
  133. package/dist/{migration-plan-C6KrFHJT-CRkTsE7L.mjs → migration-plan-Cfz0efEL-DMNFq5b2.mjs} +8 -8
  134. package/dist/{migration-plan-C6KrFHJT-CRkTsE7L.mjs.map → migration-plan-Cfz0efEL-DMNFq5b2.mjs.map} +1 -1
  135. package/dist/{migration-show-Dhnlx_GU-DhWLLt3Z.mjs → migration-show-BGdR1xnT-Cg3M0FPh.mjs} +8 -8
  136. package/dist/{migration-show-Dhnlx_GU-DhWLLt3Z.mjs.map → migration-show-BGdR1xnT-Cg3M0FPh.mjs.map} +1 -1
  137. package/dist/{migration-status-S88DjM8c-DLHnCKfW.mjs → migration-status-BIrAJ5af-D-_mMBUA.mjs} +12 -11
  138. package/dist/{migration-status-S88DjM8c-DLHnCKfW.mjs.map → migration-status-BIrAJ5af-D-_mMBUA.mjs.map} +1 -1
  139. package/dist/{output-DWNYqZGc-D2sRgLAm.mjs → output-DP3woAjV-BxCr9nHA.mjs} +21 -11
  140. package/dist/output-DP3woAjV-BxCr9nHA.mjs.map +1 -0
  141. package/dist/{project-import-root-nwdoPWap--5vXe4zp.mjs → project-import-root-B4nM-VWX-D__g0hTb.mjs} +3 -3
  142. package/dist/{project-import-root-nwdoPWap--5vXe4zp.mjs.map → project-import-root-B4nM-VWX-D__g0hTb.mjs.map} +1 -1
  143. package/dist/{init-Bco4QkKJ-DqUZVrBU.mjs → redact-secrets-Cvia6eTB-BE_Pg3k9.mjs} +741 -1517
  144. package/dist/redact-secrets-Cvia6eTB-BE_Pg3k9.mjs.map +1 -0
  145. package/dist/{ref-gZQjdz8I-CW6n9Fc0.mjs → ref-4x6BGSsd-ClaoZIQh.mjs} +4 -4
  146. package/dist/{ref-gZQjdz8I-CW6n9Fc0.mjs.map → ref-4x6BGSsd-ClaoZIQh.mjs.map} +1 -1
  147. package/dist/{ref-C8oaaeky-ColNkWpr.mjs → ref-WXLIR9Xm-12IUtoBU.mjs} +5 -5
  148. package/dist/{ref-C8oaaeky-ColNkWpr.mjs.map → ref-WXLIR9Xm-12IUtoBU.mjs.map} +1 -1
  149. package/dist/{ref-resolution-DAK4OK3x-B-8ZZc0f.mjs → ref-resolution-BSN1amKm-C6-TTM2N.mjs} +3 -3
  150. package/dist/{ref-resolution-DAK4OK3x-B-8ZZc0f.mjs.map → ref-resolution-BSN1amKm-C6-TTM2N.mjs.map} +1 -1
  151. package/dist/{schemas-Bm2e3Hk1-qLKF0B36.d.mts → schemas-BGgjiKV0-Rh8RlMCl.d.mts} +4 -2
  152. package/dist/schemas-BGgjiKV0-Rh8RlMCl.d.mts.map +1 -0
  153. package/dist/{schemas-BMkqaqvM-CLaqlat4.mjs → schemas-CYSD83Cu-Bff4PPoi.mjs} +3 -2
  154. package/dist/schemas-CYSD83Cu-Bff4PPoi.mjs.map +1 -0
  155. package/dist/{telemetry-DPXFYAsz-CPW2USxs.mjs → telemetry-BD52LETE-Cqeb7ebh.mjs} +3 -3
  156. package/dist/{telemetry-DPXFYAsz-CPW2USxs.mjs.map → telemetry-BD52LETE-Cqeb7ebh.mjs.map} +1 -1
  157. package/dist/vite-plugin-contract-emit.mjs +1 -1
  158. package/package.json +13 -13
  159. package/dist/cli-errors-BG6bItjG-DwdKIeGz.mjs.map +0 -1
  160. package/dist/cli-errors-BiKBrOXc-JPxQqO58.d.mts.map +0 -1
  161. package/dist/client-DU9qtBxW-BjVHiKzE.mjs.map +0 -1
  162. package/dist/contract-emit-Bzt11N4v-BQ2Pr8KG.mjs +0 -2
  163. package/dist/db-verify-0TpDMziA-CJDKutMN.mjs.map +0 -1
  164. package/dist/exports-DaxzMVtq.mjs.map +0 -1
  165. package/dist/init-Bco4QkKJ-DqUZVrBU.mjs.map +0 -1
  166. package/dist/migration-check-BVK9vfan-Dfg8lbeB.mjs +0 -272
  167. package/dist/migration-check-BVK9vfan-Dfg8lbeB.mjs.map +0 -1
  168. package/dist/migration-graph-command-render-BeuEyf2B-BNH9oUB_.mjs.map +0 -1
  169. package/dist/output-DWNYqZGc-D2sRgLAm.mjs.map +0 -1
  170. package/dist/schemas-BMkqaqvM-CLaqlat4.mjs.map +0 -1
  171. package/dist/schemas-Bm2e3Hk1-qLKF0B36.d.mts.map +0 -1
@@ -1,13 +1,13 @@
1
- import { F as mapRefResolutionError, P as errorUnexpected, f as errorFileNotFound, k as errorRuntime$1, t as CliStructuredError$1 } from "./cli-errors-BG6bItjG-DwdKIeGz.mjs";
1
+ import { A as errorRuntime$1, F as errorUnexpected, I as mapRefResolutionError, p as errorFileNotFound, t as CliStructuredError$1 } from "./cli-errors-B4zTLaqQ-CXgjO9t4.mjs";
2
2
  import { i as errorContractDeserializationFailed, t as MigrationToolsError } from "./errors-CXbGUWGu-BQi6YS-H.mjs";
3
3
  import { r as readContractSnapshotJson, t as contractSnapshotDir } from "./contract-snapshot-store-B0G1Fw_F-C4JjmWEA.mjs";
4
- import { r as buildReadAggregate } from "./contract-space-aggregate-loader-CoLTf3Ce-pQDru2w0.mjs";
4
+ import { r as buildReadAggregate } from "./contract-space-aggregate-loader-fa04OIaL-B7LXHle3.mjs";
5
5
  import { n as parseContractRef } from "./ref-resolution-sGcINe7o.mjs";
6
6
  import { join } from "pathe";
7
7
  import { blindCast, castAs } from "@prisma/orm-framework/utils/casts";
8
8
  import { readFile } from "node:fs/promises";
9
9
  import { notOk, ok } from "@prisma/orm-framework/utils/result";
10
- //#region ../../../1-framework/3-tooling/cli/dist/contract-snapshot-resolution-DvZvbNcZ.mjs
10
+ //#region ../../../1-framework/3-tooling/cli/dist/contract-snapshot-resolution-De2VvOJn.mjs
11
11
  /**
12
12
  * Resolves a user-supplied contract reference to an on-disk contract JSON (snapshot store or emitted contract), shared by db sign and db update --to.
13
13
  */
@@ -79,4 +79,4 @@ async function resolveContractRefToSnapshot(options) {
79
79
  //#endregion
80
80
  export { resolveContractRefToSnapshot as t };
81
81
 
82
- //# sourceMappingURL=contract-snapshot-resolution-DvZvbNcZ-DHFCWe_k.mjs.map
82
+ //# sourceMappingURL=contract-snapshot-resolution-De2VvOJn-DqIAV9cr.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"contract-snapshot-resolution-DvZvbNcZ-DHFCWe_k.mjs","names":["errorRuntime","CliStructuredError"],"sources":["../../../../1-framework/3-tooling/cli/dist/contract-snapshot-resolution-DvZvbNcZ.mjs"],"sourcesContent":["import { N as errorUnexpected, O as errorRuntime, P as mapRefResolutionError, d as errorFileNotFound, t as CliStructuredError } from \"./cli-errors-BG6bItjG.mjs\";\nimport { r as buildReadAggregate } from \"./contract-space-aggregate-loader-CoLTf3Ce.mjs\";\nimport { notOk, ok } from \"@internal/utils/result\";\nimport { join } from \"pathe\";\nimport { readFile } from \"node:fs/promises\";\nimport { blindCast, castAs } from \"@internal/utils/casts\";\nimport { MigrationToolsError, errorContractDeserializationFailed } from \"@internal/migration-tools/errors\";\nimport { contractSnapshotDir, readContractSnapshotJson } from \"@internal/migration-tools/contract-snapshot-store\";\nimport { parseContractRef } from \"@internal/migration-tools/ref-resolution\";\n//#region src/control-api/operations/contract-snapshot-resolution.ts\n/**\n* Resolves a user-supplied contract reference to an on-disk contract JSON (snapshot store or emitted contract), shared by db sign and db update --to.\n*/\nfunction isEnoent(error) {\n\treturn error instanceof Error && \"code\" in error && error.code === \"ENOENT\";\n}\nasync function resolveContractRefToSnapshot(options) {\n\ttry {\n\t\tconst loaded = await buildReadAggregate(options.config, { migrationsDir: options.migrationsDir });\n\t\tif (!loaded.ok) return notOk(loaded.failure);\n\t\tconst graph = loaded.value.aggregate.app.graph();\n\t\tconst bundles = loaded.value.aggregate.app.packages;\n\t\tconst refs = loaded.value.aggregate.app.refs;\n\t\tconst refResult = parseContractRef(options.refInput, {\n\t\t\tgraph,\n\t\t\trefs\n\t\t});\n\t\tif (!refResult.ok) return notOk(mapRefResolutionError(refResult.failure));\n\t\tconst targetHash = refResult.value.hash;\n\t\tif (bundles.find((p) => p.metadata.to === targetHash)) return ok({\n\t\t\thash: targetHash,\n\t\t\tcontractJson: blindCast(await readContractSnapshotJson(options.migrationsDir, targetHash)),\n\t\t\tcontractJsonPath: join(contractSnapshotDir(options.migrationsDir, targetHash), \"contract.json\"),\n\t\t\tsource: \"snapshot\"\n\t\t});\n\t\tif (!options.fallbackToEmitted) return notOk(errorUnexpected(`No migration bundle found for ${options.missingBundleFlag} \"${options.refInput}\" (resolved hash: ${targetHash})`, {\n\t\t\twhy: `The ref resolved successfully but no on-disk migration package has a destination (\\`to\\`) hash matching ${targetHash}.`,\n\t\t\tfix: \"Provide a ref or hash that corresponds to an existing migration package, or run `migration list` to see available migrations.\"\n\t\t}));\n\t\tlet defaultRaw;\n\t\ttry {\n\t\t\tdefaultRaw = await readFile(options.contractPathAbsolute, \"utf-8\");\n\t\t} catch (error) {\n\t\t\tif (isEnoent(error)) return notOk(errorFileNotFound(options.contractPathAbsolute, {\n\t\t\t\twhy: `Contract file not found at ${options.contractPathAbsolute}`,\n\t\t\t\tfix: \"Run `prisma-next contract emit` first to generate the contract\",\n\t\t\t\tcause: error\n\t\t\t}));\n\t\t\treturn notOk(errorUnexpected(error instanceof Error ? error.message : String(error), {\n\t\t\t\twhy: `Failed to read contract file: ${error instanceof Error ? error.message : String(error)}`,\n\t\t\t\tcause: error\n\t\t\t}));\n\t\t}\n\t\tlet parsed;\n\t\ttry {\n\t\t\tparsed = castAs(JSON.parse(defaultRaw));\n\t\t} catch (error) {\n\t\t\treturn notOk(errorContractDeserializationFailed(options.contractPathAbsolute, error instanceof Error ? error.message : String(error), { cause: error }));\n\t\t}\n\t\tif (parsed === null || typeof parsed !== \"object\" || Array.isArray(parsed)) return notOk(errorContractDeserializationFailed(options.contractPathAbsolute, `expected a JSON object, got ${parsed === null ? \"null\" : Array.isArray(parsed) ? \"an array\" : `a ${typeof parsed}`}`));\n\t\tconst defaultContract = blindCast(parsed);\n\t\tconst storage = defaultContract[\"storage\"];\n\t\tif ((storage !== null && typeof storage === \"object\" ? blindCast(storage)[\"storageHash\"] : void 0) === targetHash) return ok({\n\t\t\thash: targetHash,\n\t\t\tcontractJson: defaultContract,\n\t\t\tcontractJsonPath: options.contractPathAbsolute,\n\t\t\tsource: \"emitted\"\n\t\t});\n\t\treturn notOk(errorRuntime(\"MIGRATION.SNAPSHOT_MISSING\", `No contract file found for hash \"${targetHash}\"`, {\n\t\t\twhy: `Resolved contract reference \"${options.refInput}\" to hash \"${targetHash}\" but no migration produces that hash and the emitted contract does not match.`,\n\t\t\tfix: \"Ensure the target contract exists on disk — either as a migration endpoint or as the emitted contract.json.\"\n\t\t}));\n\t} catch (error) {\n\t\tif (MigrationToolsError.is(error)) return notOk(error);\n\t\tif (CliStructuredError.is(error)) return notOk(error);\n\t\tthrow error;\n\t}\n}\n//#endregion\nexport { resolveContractRefToSnapshot as t };\n\n//# sourceMappingURL=contract-snapshot-resolution-DvZvbNcZ.mjs.map"],"mappings":";;;;;;;;;;;;;AAaA,SAAS,SAAS,OAAO;CACxB,OAAO,iBAAiB,SAAS,UAAU,SAAS,MAAM,SAAS;AACpE;AACA,eAAe,6BAA6B,SAAS;CACpD,IAAI;EACH,MAAM,SAAS,MAAM,mBAAmB,QAAQ,QAAQ,EAAE,eAAe,QAAQ,cAAc,CAAC;EAChG,IAAI,CAAC,OAAO,IAAI,OAAO,MAAM,OAAO,OAAO;EAC3C,MAAM,QAAQ,OAAO,MAAM,UAAU,IAAI,MAAM;EAC/C,MAAM,UAAU,OA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,QAAQ,OAAO,WAAW,YAAY,MAAM,QAAQ,MAAM,GAAG,OAAO,MAAM,mCAAmC,QAAQ,sBAAsB,+BAA+B,WAAW,OAAO,SAAS,MAAM,QAAQ,MAAM,IAAI,aAAa,KAAK,OAAO,UAAU,CAAC;EAChR,MAAM,kBAAkB,UAAU,MAAM;EACxC,MAAM,UAAU,gBAAgB;EAChC,KAAK,YAAY,QAAQ,OAAO,YAAY,WAAW,UAAU,OAAO,CAAC,CAAC,iBAAiB,KAAK,OAAO,YAAY,OAAO,GAAG;GAC5H,MAAM;GACN,cAAc;GACd,kBAAkB,QAAQ;GAC1B,QAAQ;EACT,CAAC;EACD,OAAO,MAAMA,eAAa,8BAA8B,oCAAoC,WAAW,IAAI;GAC1G,KAAK,gCAAgC,QAAQ,SAAS,aAAa,WAAW;GAC9E,KAAK;EACN,CAAC,CAAC;CACH,SAAS,OAAO;EACf,IAAI,oBAAoB,GAAG,KAAK,GAAG,OAAO,MAAM,KAAK;EACrD,IAAIC,qBAAmB,GAAG,KAAK,GAAG,OAAO,MAAM,KAAK;EACpD,MAAM;CACP;AACD"}
1
+ {"version":3,"file":"contract-snapshot-resolution-De2VvOJn-DqIAV9cr.mjs","names":["errorRuntime","CliStructuredError"],"sources":["../../../../1-framework/3-tooling/cli/dist/contract-snapshot-resolution-De2VvOJn.mjs"],"sourcesContent":["import { F as mapRefResolutionError, P as errorUnexpected, f as errorFileNotFound, k as errorRuntime, t as CliStructuredError } from \"./cli-errors-B4zTLaqQ.mjs\";\nimport { r as buildReadAggregate } from \"./contract-space-aggregate-loader-fa04OIaL.mjs\";\nimport { notOk, ok } from \"@internal/utils/result\";\nimport { join } from \"pathe\";\nimport { readFile } from \"node:fs/promises\";\nimport { blindCast, castAs } from \"@internal/utils/casts\";\nimport { MigrationToolsError, errorContractDeserializationFailed } from \"@internal/migration-tools/errors\";\nimport { contractSnapshotDir, readContractSnapshotJson } from \"@internal/migration-tools/contract-snapshot-store\";\nimport { parseContractRef } from \"@internal/migration-tools/ref-resolution\";\n//#region src/control-api/operations/contract-snapshot-resolution.ts\n/**\n* Resolves a user-supplied contract reference to an on-disk contract JSON (snapshot store or emitted contract), shared by db sign and db update --to.\n*/\nfunction isEnoent(error) {\n\treturn error instanceof Error && \"code\" in error && error.code === \"ENOENT\";\n}\nasync function resolveContractRefToSnapshot(options) {\n\ttry {\n\t\tconst loaded = await buildReadAggregate(options.config, { migrationsDir: options.migrationsDir });\n\t\tif (!loaded.ok) return notOk(loaded.failure);\n\t\tconst graph = loaded.value.aggregate.app.graph();\n\t\tconst bundles = loaded.value.aggregate.app.packages;\n\t\tconst refs = loaded.value.aggregate.app.refs;\n\t\tconst refResult = parseContractRef(options.refInput, {\n\t\t\tgraph,\n\t\t\trefs\n\t\t});\n\t\tif (!refResult.ok) return notOk(mapRefResolutionError(refResult.failure));\n\t\tconst targetHash = refResult.value.hash;\n\t\tif (bundles.find((p) => p.metadata.to === targetHash)) return ok({\n\t\t\thash: targetHash,\n\t\t\tcontractJson: blindCast(await readContractSnapshotJson(options.migrationsDir, targetHash)),\n\t\t\tcontractJsonPath: join(contractSnapshotDir(options.migrationsDir, targetHash), \"contract.json\"),\n\t\t\tsource: \"snapshot\"\n\t\t});\n\t\tif (!options.fallbackToEmitted) return notOk(errorUnexpected(`No migration bundle found for ${options.missingBundleFlag} \"${options.refInput}\" (resolved hash: ${targetHash})`, {\n\t\t\twhy: `The ref resolved successfully but no on-disk migration package has a destination (\\`to\\`) hash matching ${targetHash}.`,\n\t\t\tfix: \"Provide a ref or hash that corresponds to an existing migration package, or run `migration list` to see available migrations.\"\n\t\t}));\n\t\tlet defaultRaw;\n\t\ttry {\n\t\t\tdefaultRaw = await readFile(options.contractPathAbsolute, \"utf-8\");\n\t\t} catch (error) {\n\t\t\tif (isEnoent(error)) return notOk(errorFileNotFound(options.contractPathAbsolute, {\n\t\t\t\twhy: `Contract file not found at ${options.contractPathAbsolute}`,\n\t\t\t\tfix: \"Run `prisma-next contract emit` first to generate the contract\",\n\t\t\t\tcause: error\n\t\t\t}));\n\t\t\treturn notOk(errorUnexpected(error instanceof Error ? error.message : String(error), {\n\t\t\t\twhy: `Failed to read contract file: ${error instanceof Error ? error.message : String(error)}`,\n\t\t\t\tcause: error\n\t\t\t}));\n\t\t}\n\t\tlet parsed;\n\t\ttry {\n\t\t\tparsed = castAs(JSON.parse(defaultRaw));\n\t\t} catch (error) {\n\t\t\treturn notOk(errorContractDeserializationFailed(options.contractPathAbsolute, error instanceof Error ? error.message : String(error), { cause: error }));\n\t\t}\n\t\tif (parsed === null || typeof parsed !== \"object\" || Array.isArray(parsed)) return notOk(errorContractDeserializationFailed(options.contractPathAbsolute, `expected a JSON object, got ${parsed === null ? \"null\" : Array.isArray(parsed) ? \"an array\" : `a ${typeof parsed}`}`));\n\t\tconst defaultContract = blindCast(parsed);\n\t\tconst storage = defaultContract[\"storage\"];\n\t\tif ((storage !== null && typeof storage === \"object\" ? blindCast(storage)[\"storageHash\"] : void 0) === targetHash) return ok({\n\t\t\thash: targetHash,\n\t\t\tcontractJson: defaultContract,\n\t\t\tcontractJsonPath: options.contractPathAbsolute,\n\t\t\tsource: \"emitted\"\n\t\t});\n\t\treturn notOk(errorRuntime(\"MIGRATION.SNAPSHOT_MISSING\", `No contract file found for hash \"${targetHash}\"`, {\n\t\t\twhy: `Resolved contract reference \"${options.refInput}\" to hash \"${targetHash}\" but no migration produces that hash and the emitted contract does not match.`,\n\t\t\tfix: \"Ensure the target contract exists on disk — either as a migration endpoint or as the emitted contract.json.\"\n\t\t}));\n\t} catch (error) {\n\t\tif (MigrationToolsError.is(error)) return notOk(error);\n\t\tif (CliStructuredError.is(error)) return notOk(error);\n\t\tthrow error;\n\t}\n}\n//#endregion\nexport { resolveContractRefToSnapshot as t };\n\n//# sourceMappingURL=contract-snapshot-resolution-De2VvOJn.mjs.map"],"mappings":";;;;;;;;;;;;;AAaA,SAAS,SAAS,OAAO;CACxB,OAAO,iBAAiB,SAAS,UAAU,SAAS,MAAM,SA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,OAAO;GACR,CAAC,CAAC;EACH;EACA,IAAI;EACJ,IAAI;GACH,SAAS,OAAO,KAAK,MAAM,UAAU,CAAC;EACvC,SAAS,OAAO;GACf,OAAO,MAAM,mCAAmC,QAAQ,sBAAsB,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,GAAG,EAAE,OAAO,MAAM,CAAC,CAAC;EACxJ;EACA,IAAI,WAAW,QAAQ,OAAO,WAAW,YAAY,MAAM,QAAQ,MAAM,GAAG,OAAO,MAAM,mCAAmC,QAAQ,sBAAsB,+BAA+B,WAAW,OAAO,SAAS,MAAM,QAAQ,MAAM,IAAI,aAAa,KAAK,OAAO,UAAU,CAAC;EAChR,MAAM,kBAAkB,UAAU,MAAM;EACxC,MAAM,UAAU,gBAAgB;EAChC,KAAK,YAAY,QAAQ,OAAO,YAAY,WAAW,UAAU,OAAO,CAAC,CAAC,iBAAiB,KAAK,OAAO,YAAY,OAAO,GAAG;GAC5H,MAAM;GACN,cAAc;GACd,kBAAkB,QAAQ;GAC1B,QAAQ;EACT,CAAC;EACD,OAAO,MAAMA,eAAa,8BAA8B,oCAAoC,WAAW,IAAI;GAC1G,KAAK,gCAAgC,QAAQ,SAAS,aAAa,WAAW;GAC9E,KAAK;EACN,CAAC,CAAC;CACH,SAAS,OAAO;EACf,IAAI,oBAAoB,GAAG,KAAK,GAAG,OAAO,MAAM,KAAK;EACrD,IAAIC,qBAAmB,GAAG,KAAK,GAAG,OAAO,MAAM,KAAK;EACpD,MAAM;CACP;AACD"}
@@ -1,13 +1,13 @@
1
- import { P as errorUnexpected, t as CliStructuredError$1 } from "./cli-errors-BG6bItjG-DwdKIeGz.mjs";
1
+ import { F as errorUnexpected, t as CliStructuredError$1 } from "./cli-errors-B4zTLaqQ-CXgjO9t4.mjs";
2
2
  import { t as MigrationToolsError } from "./errors-CXbGUWGu-BQi6YS-H.mjs";
3
3
  import { t as EMPTY_CONTRACT_HASH } from "./constants-CM-w38DQ-Cz_EXbOc.mjs";
4
- import { g as resolveContractPath, h as readContractEnvelope } from "./command-helpers-CwLvFwMB-BWwUQhlT.mjs";
4
+ import { g as resolveContractPath, h as readContractEnvelope } from "./command-helpers-BCgwcqTe-lNCtppzM.mjs";
5
5
  import { s as loadContractSpaceAggregate } from "./aggregate-BBsCbXgJ.mjs";
6
6
  import { blindCast } from "@prisma/orm-framework/utils/casts";
7
7
  import { readFile } from "node:fs/promises";
8
8
  import { createControlStack } from "@prisma/orm-framework/components/control";
9
9
  import { notOk, ok } from "@prisma/orm-framework/utils/result";
10
- //#region ../../../1-framework/3-tooling/cli/dist/contract-space-aggregate-loader-CoLTf3Ce.mjs
10
+ //#region ../../../1-framework/3-tooling/cli/dist/contract-space-aggregate-loader-fa04OIaL.mjs
11
11
  /**
12
12
  * Project the CLI's `Config.extensions` array into the canonical
13
13
  * {@link ExtensionPackInput} shape. The single `as ExtensionPackLike`
@@ -300,4 +300,4 @@ async function buildReadAggregate(config, options) {
300
300
  //#endregion
301
301
  export { loadContractSpaceAggregateForCli as a, refuseDeclaredExtensionTargetMismatch as c, toExtensionInputs as d, loadContractRawSafely as i, refusePackageCorruptionOnAggregate as l, buildContractSpaceAggregate as n, mapIntegrityViolations as o, buildReadAggregate as r, refuseContractSpaceIntegrity as s, appContractStandInFromIdentity as t, toDeclaredExtensionsFromRaw as u };
302
302
 
303
- //# sourceMappingURL=contract-space-aggregate-loader-CoLTf3Ce-pQDru2w0.mjs.map
303
+ //# sourceMappingURL=contract-space-aggregate-loader-fa04OIaL-B7LXHle3.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"contract-space-aggregate-loader-CoLTf3Ce-pQDru2w0.mjs","names":["CliStructuredError"],"sources":["../../../../1-framework/3-tooling/cli/dist/contract-space-aggregate-loader-CoLTf3Ce.mjs"],"sourcesContent":["import { N as errorUnexpected, t as CliStructuredError } from \"./cli-errors-BG6bItjG.mjs\";\nimport { o as readContractEnvelope, s as resolveContractPath } from \"./command-helpers-CwLvFwMB.mjs\";\nimport { notOk, ok } from \"@internal/utils/result\";\nimport { readFile } from \"node:fs/promises\";\nimport { createControlStack } from \"@internal/framework-components/control\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { loadContractSpaceAggregate } from \"@internal/migration-tools/aggregate\";\nimport { EMPTY_CONTRACT_HASH } from \"@internal/migration-tools/constants\";\nimport { MigrationToolsError } from \"@internal/migration-tools/errors\";\n//#region src/utils/extension-pack-inputs.ts\n/**\n* Project the CLI's `Config.extensions` array into the canonical\n* {@link ExtensionPackInput} shape. The single `as ExtensionPackLike`\n* structural cast in the CLI lives inside this function.\n*/\nfunction toExtensionInputs(extensions) {\n\treturn extensions.map((raw) => {\n\t\tconst pack = raw;\n\t\tif (pack.contractSpace === void 0) return {\n\t\t\tid: pack.id,\n\t\t\ttargetId: pack.targetId\n\t\t};\n\t\treturn {\n\t\t\tid: pack.id,\n\t\t\ttargetId: pack.targetId,\n\t\t\tcontractSpace: {\n\t\t\t\tcontractJson: pack.contractSpace.contractJson,\n\t\t\t\theadRef: pack.contractSpace.headRef,\n\t\t\t\tmigrations: pack.contractSpace.migrations ?? []\n\t\t\t}\n\t\t};\n\t});\n}\n/**\n* Minimal aggregate-loader projection that extracts `id` + `targetId`\n* from raw extension pack descriptors **without invoking any\n* `contractSpace` accessor**. Inspects the own-property descriptor so\n* that getter-backed `contractSpace` declarations are detected but\n* never called.\n*\n* Inclusion semantics match {@link toDeclaredExtensions}: a data\n* property whose value is explicitly `undefined` is treated as \"no\n* contract-space declaration\" and skipped, mirroring the\n* `pack.contractSpace === undefined` check used on canonicalised\n* inputs. Prototype-chain `contractSpace` properties (no own\n* descriptor) are also skipped.\n*\n* This variant must be used by `buildContractSpaceAggregate` so that\n* the aggregate path (including `db verify`) never reads\n* `contractSpace.contractJson` from extension descriptors — the loader\n* always reads the contract from on-disk artefacts instead.\n*/\nfunction toDeclaredExtensionsFromRaw(extensions) {\n\tconst entries = [];\n\tfor (const raw of extensions) {\n\t\tif (typeof raw !== \"object\" || raw === null) continue;\n\t\tconst descriptor = Object.getOwnPropertyDescriptor(raw, \"contractSpace\");\n\t\tif (descriptor === void 0) continue;\n\t\tif (\"value\" in descriptor && descriptor.value === void 0) continue;\n\t\tconst pack = raw;\n\t\tentries.push({\n\t\t\tid: pack.id,\n\t\t\ttargetId: pack.targetId\n\t\t});\n\t}\n\treturn entries;\n}\n//#endregion\n//#region src/control-api/operations/contract-space-aggregate-loader.ts\nconst CONTRACT_SPACES_DOCS_URL = \"https://pris.ly/contract-spaces\";\nfunction contractSpaceViolationError(summary, options) {\n\treturn new CliStructuredError(\"MIGRATION.CONTRACT_SPACE_VIOLATION\", summary, {\n\t\twhy: options.why,\n\t\tfix: options.fix,\n\t\tdocsUrl: CONTRACT_SPACES_DOCS_URL,\n\t\tmeta: { violations: options.violations }\n\t});\n}\n/**\n* Build the `MIGRATION.CONTRACT_SPACE_VIOLATION` structured-error envelope for a contract-space\n* target mismatch. Shared between the declared-extension precheck (the\n* descriptor's configured target disagrees with the project target) and\n* the on-disk-contract check surfaced by `checkIntegrity`.\n*/\nfunction targetMismatchError(spaceId, expected, actual) {\n\treturn contractSpaceViolationError(`Contract-space target mismatch for \"${spaceId}\"`, {\n\t\twhy: `Space \"${spaceId}\" targets \"${actual}\" but the project's adapter targets \"${expected}\".`,\n\t\tfix: \"Update the extension descriptor to target the configured database, or change the project adapter.\",\n\t\tviolations: [{\n\t\t\tkind: \"targetMismatch\",\n\t\t\tspaceId,\n\t\t\texpected,\n\t\t\tactual\n\t\t}]\n\t});\n}\n/**\n* Human-readable detail for an integrity violation, used as the `why`\n* of the `integrityFailure` envelope. Mirrors the messages the prior\n* throw-on-load loader produced so downstream consumers see the same\n* text for the same on-disk state.\n*/\nfunction describeIntegrityViolation(violation) {\n\tswitch (violation.kind) {\n\t\tcase \"hashMismatch\": return `Migration \"${violation.dirName}\" stored hash \"${violation.stored}\" does not match computed hash \"${violation.computed}\".`;\n\t\tcase \"providedInvariantsMismatch\": return `Migration \"${violation.dirName}\" providedInvariants in migration.json disagrees with ops.json.`;\n\t\tcase \"packageUnloadable\": return `Migration \"${violation.dirName}\" could not be loaded: ${violation.detail}`;\n\t\tcase \"sameSourceAndTarget\": return `Migration \"${violation.dirName}\" has source equal to target (${violation.hash}) with no data invariant — a true no-op self-edge.`;\n\t\tcase \"headRefMissing\": return `Head ref \\`refs/head.json\\` is missing for contract space \"${violation.spaceId}\".`;\n\t\tcase \"headRefNotInGraph\": return `Head ref ${violation.hash} for contract space \"${violation.spaceId}\" is not present in the migration graph.`;\n\t\tcase \"refUnreadable\": return `Ref \"${violation.refName}\" for contract space \"${violation.spaceId}\" is unreadable: ${violation.detail}`;\n\t\tcase \"duplicateMigrationHash\": return `Multiple migrations in space \"${violation.spaceId}\" share migrationHash \"${violation.migrationHash}\" (${violation.dirNames.join(\", \")}).`;\n\t\tdefault: {\n\t\t\tconst spaceId = \"spaceId\" in violation ? violation.spaceId : \"*\";\n\t\t\treturn `Integrity violation \"${violation.kind}\" for contract space \"${spaceId}\".`;\n\t\t}\n\t}\n}\n/**\n* Map the integrity violations `checkIntegrity` reports into a single\n* CLI structured-error envelope, preserving the error codes the prior\n* throw-on-load loader emitted: `MIGRATION.CONTRACT_SPACE_LAYOUT_VIOLATION`\n* (layout drift, bundled) and `MIGRATION.CONTRACT_SPACE_VIOLATION` (target /\n* disjointness / contract-validation / structural integrity). Returns\n* `null` when there is nothing to refuse on.\n*\n* Precedence reproduces the prior loader's first-failure ordering:\n* layout drift first (every offence bundled into one envelope), then\n* target mismatch, then disjointness, then a contract-validation\n* failure, then any remaining structural integrity violation.\n*/\nfunction mapIntegrityViolations(violations) {\n\tif (violations.length === 0) return null;\n\tconst layout = violations.filter((v) => v.kind === \"orphanSpaceDir\" || v.kind === \"declaredButUnmigrated\");\n\tif (layout.length > 0) {\n\t\tconst lines = layout.map((v) => `- [${v.kind}] ${v.spaceId}`);\n\t\treturn new CliStructuredError(\"MIGRATION.CONTRACT_SPACE_LAYOUT_VIOLATION\", layout.length === 1 ? \"Contract-space layout violation detected\" : `Contract-space layout violations detected (${layout.length})`, {\n\t\t\twhy: `The on-disk \\`migrations/\\` directory and your \\`extensions\\` declaration are not in agreement.\\n${lines.join(\"\\n\")}`,\n\t\t\tfix: \"Declare the extension in `extensions` and re-emit its contract-space artefacts, or remove the orphan `migrations/<space>` directory.\",\n\t\t\tdocsUrl: CONTRACT_SPACES_DOCS_URL,\n\t\t\tmeta: { violations: layout }\n\t\t});\n\t}\n\tconst targetMismatch = violations.find((v) => v.kind === \"targetMismatch\");\n\tif (targetMismatch && targetMismatch.kind === \"targetMismatch\") return targetMismatchError(targetMismatch.spaceId, targetMismatch.expected, targetMismatch.actual);\n\tconst disjointness = violations.find((v) => v.kind === \"disjointness\");\n\tif (disjointness && disjointness.kind === \"disjointness\") return contractSpaceViolationError(`Contract-space disjointness violation: storage element \"${disjointness.element}\" claimed by multiple spaces`, {\n\t\twhy: `Spaces ${disjointness.claimedBy.map((s) => `\"${s}\"`).join(\", \")} all claim the storage element \"${disjointness.element}\". Each storage element must be owned by exactly one contract space.`,\n\t\tfix: \"Update the conflicting contracts so each storage element is claimed by exactly one space.\",\n\t\tviolations: [disjointness]\n\t});\n\tconst contractUnreadable = violations.find((v) => v.kind === \"contractUnreadable\");\n\tif (contractUnreadable && contractUnreadable.kind === \"contractUnreadable\") return contractSpaceViolationError(`Contract-space contract validation failed for \"${contractUnreadable.spaceId}\"`, {\n\t\twhy: contractUnreadable.detail,\n\t\tfix: \"Re-emit the extension contract with `prisma-next contract emit`, or fix the extension pack descriptor producing the invalid contract.\",\n\t\tviolations: [contractUnreadable]\n\t});\n\tconst structural = violations[0];\n\treturn contractSpaceViolationError(`Contract-space integrity failure for \"${\"spaceId\" in structural ? structural.spaceId : \"*\"}\"`, {\n\t\twhy: describeIntegrityViolation(structural),\n\t\tfix: \"Re-emit the affected migration package(s) or restore the on-disk `migrations/` directory from version control.\",\n\t\tviolations: [structural]\n\t});\n}\nfunction declaredExtensionsFromInputs(extensions) {\n\treturn toDeclaredExtensionsFromRaw(extensions);\n}\n/**\n* Reject extension descriptors whose configured target disagrees with\n* the project target before any on-disk read.\n*/\nfunction refuseDeclaredExtensionTargetMismatch(inputs) {\n\tfor (const declared of declaredExtensionsFromInputs(inputs.extensions)) if (declared.targetId !== inputs.targetId) return targetMismatchError(declared.id, inputs.targetId, declared.targetId);\n\treturn null;\n}\n/**\n* Load the tolerant {@link ContractSpaceAggregate} once at the CLI\n* surface. Construction never throws on disk content; callers query\n* {@link ContractSpaceAggregate.app} / extension facets instead of\n* re-reading `migrations/`.\n*/\nasync function loadContractSpaceAggregateForCli(inputs) {\n\tconst targetFailure = refuseDeclaredExtensionTargetMismatch(inputs);\n\tif (targetFailure) return notOk(targetFailure);\n\treturn ok(await loadContractSpaceAggregate({\n\t\tmigrationsDir: inputs.migrationsDir,\n\t\tdeserializeContract: inputs.deserializeContract,\n\t\tappContract: inputs.appContract\n\t}));\n}\n/**\n* Run `checkIntegrity` on a loaded aggregate and map violations into\n* the contract-space refusal envelope, or return `null` when the model\n* is acceptable for the requested check scope.\n*/\nfunction refuseContractSpaceIntegrity(aggregate, options) {\n\treturn mapIntegrityViolations(aggregate.checkIntegrity(options));\n}\nconst PACKAGE_CORRUPTION_KINDS = /* @__PURE__ */ new Set([\n\t\"hashMismatch\",\n\t\"providedInvariantsMismatch\",\n\t\"packageUnloadable\"\n]);\n/**\n* Reader-subset integrity refusal for `migration status`: package\n* corruptions only (`hashMismatch`, `providedInvariantsMismatch`,\n* `packageUnloadable`).\n*/\nfunction refusePackageCorruptionOnAggregate(aggregate) {\n\treturn mapIntegrityViolations(aggregate.checkIntegrity().filter((v) => PACKAGE_CORRUPTION_KINDS.has(v.kind)));\n}\n/**\n* Construct the tolerant {@link ContractSpaceAggregate} at the CLI\n* surface and apply the explicit integrity refusal.\n*\n* App-space migration packages are read from `migrations/<app>/` by the\n* loader itself; callers no longer thread them through.\n*/\nasync function buildContractSpaceAggregate(inputs) {\n\tconst declaredExtensions = declaredExtensionsFromInputs(inputs.extensions);\n\tconst loaded = await loadContractSpaceAggregateForCli(inputs);\n\tif (!loaded.ok) return loaded;\n\tconst failure = refuseContractSpaceIntegrity(loaded.value, {\n\t\tdeclaredExtensions,\n\t\tcheckContracts: true\n\t});\n\tif (failure) return notOk(failure);\n\treturn ok(loaded.value);\n}\n/**\n* Build a minimal app {@link Contract} carrying only the project's\n* contract-identity (`storage.storageHash` + `target` / `targetFamily`)\n* when the real `contract.json` is absent or undeserializable.\n*\n* `loadContractSpaceAggregate` requires an `appContract` to synthesise the\n* app space's head ref from its storage hash. Read commands query only that\n* hash and the target — never `models` — so an empty-`models` stand-in is\n* sufficient for them. It is *not* a valid contract for any consumer that\n* reads schema, which is why this is confined to the read-aggregate path.\n*/\nfunction appContractStandInFromIdentity(args) {\n\treturn blindCast({\n\t\tstorage: { storageHash: args.contractHash },\n\t\tschemaVersion: \"0.0.0\",\n\t\ttarget: args.targetId,\n\t\ttargetFamily: args.targetFamily,\n\t\tmodels: {},\n\t\tprofileHash: EMPTY_CONTRACT_HASH\n\t});\n}\nasync function loadContractRawSafely(config) {\n\ttry {\n\t\tconst raw = await readFile(resolveContractPath(config), \"utf-8\");\n\t\treturn JSON.parse(raw);\n\t} catch {\n\t\treturn null;\n\t}\n}\n/**\n* Tolerant {@link ContractSpaceAggregate} assembly for read-only CLI\n* commands. No integrity gate — callers query `aggregate.app` (or other\n* facets) without re-reading `migrations/`. When `contract.json` is absent\n* or undeserializable, the app contract falls back to an identity-only\n* stand-in ({@link appContractStandInFromIdentity}), so these commands\n* load without requiring a readable contract.\n*/\nasync function buildReadAggregate(config, options) {\n\tlet contractHash = EMPTY_CONTRACT_HASH;\n\ttry {\n\t\tcontractHash = (await readContractEnvelope(config)).storageHash;\n\t} catch {}\n\ttry {\n\t\tconst contractRawForAggregate = await loadContractRawSafely(config);\n\t\tconst stack = createControlStack(config);\n\t\tconst familyInstance = config.family.create(stack);\n\t\tconst deserializeContract = (json) => familyInstance.deserializeContract(json);\n\t\tlet appContractForLoad = appContractStandInFromIdentity({\n\t\t\tcontractHash,\n\t\t\ttargetId: config.target.id,\n\t\t\ttargetFamily: config.target.familyId\n\t\t});\n\t\tif (contractRawForAggregate !== null) try {\n\t\t\tappContractForLoad = deserializeContract(contractRawForAggregate);\n\t\t} catch {}\n\t\tconst loaded = await loadContractSpaceAggregateForCli({\n\t\t\ttargetId: config.target.id,\n\t\t\tmigrationsDir: options.migrationsDir,\n\t\t\tappContract: appContractForLoad,\n\t\t\textensions: config.extensions ?? [],\n\t\t\tdeserializeContract\n\t\t});\n\t\tif (!loaded.ok) return loaded;\n\t\treturn ok({\n\t\t\taggregate: loaded.value,\n\t\t\tcontractHash\n\t\t});\n\t} catch (error) {\n\t\tif (MigrationToolsError.is(error)) return notOk(error);\n\t\treturn notOk(errorUnexpected(error instanceof Error ? error.message : String(error), { why: `Failed to read migrations directory: ${error instanceof Error ? error.message : String(error)}` }));\n\t}\n}\n//#endregion\nexport { loadContractSpaceAggregateForCli as a, refuseDeclaredExtensionTargetMismatch as c, toExtensionInputs as d, loadContractRawSafely as i, refusePackageCorruptionOnAggregate as l, buildContractSpaceAggregate as n, mapIntegrityViolations as o, buildReadAggregate as r, refuseContractSpaceIntegrity as s, appContractStandInFromIdentity as t, toDeclaredExtensionsFromRaw as u };\n\n//# sourceMappingURL=contract-space-aggregate-loader-CoLTf3Ce.mjs.map"],"mappings":";;;;;;;;;;;;;;;AAeA,SAAS,kBAAkB,YAAY;CACtC,OAAO,WAAW,KAAK,QAAQ;EAC9B,MAAM,OAAO;EACb,IAAI,KAAK,kBAAkB,KAAK,GAAG,OAAO;GACzC,IAAI,KAAK;GACT,UAAU,KAAK;EAChB;EACA,OAAO;GACN,IAAI,KAAK;GACT,UAAU,KAAK;GACf,eAAe;IACd,cAAc,KAAK,cAAc;IACjC,SAAS,KAAK,cAAc;IAC5B,YAAY,KAAK,cAAc,cAAc,CAAC;GAC/C;EACD;CACD,CAAC;AACF;;;;;;;;;;;;;;;;;;;;AA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,OAAO;EACf,IAAI,oBAAoB,GAAG,KAAK,GAAG,OAAO,MAAM,KAAK;EACrD,OAAO,MAAM,gBAAgB,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,GAAG,EAAE,KAAK,wCAAwC,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,IAAI,CAAC,CAAC;CAChM;AACD"}
1
+ {"version":3,"file":"contract-space-aggregate-loader-fa04OIaL-B7LXHle3.mjs","names":["CliStructuredError"],"sources":["../../../../1-framework/3-tooling/cli/dist/contract-space-aggregate-loader-fa04OIaL.mjs"],"sourcesContent":["import { P as errorUnexpected, t as CliStructuredError } from \"./cli-errors-B4zTLaqQ.mjs\";\nimport { o as readContractEnvelope, s as resolveContractPath } from \"./command-helpers-BCgwcqTe.mjs\";\nimport { notOk, ok } from \"@internal/utils/result\";\nimport { readFile } from \"node:fs/promises\";\nimport { createControlStack } from \"@internal/framework-components/control\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { loadContractSpaceAggregate } from \"@internal/migration-tools/aggregate\";\nimport { EMPTY_CONTRACT_HASH } from \"@internal/migration-tools/constants\";\nimport { MigrationToolsError } from \"@internal/migration-tools/errors\";\n//#region src/utils/extension-pack-inputs.ts\n/**\n* Project the CLI's `Config.extensions` array into the canonical\n* {@link ExtensionPackInput} shape. The single `as ExtensionPackLike`\n* structural cast in the CLI lives inside this function.\n*/\nfunction toExtensionInputs(extensions) {\n\treturn extensions.map((raw) => {\n\t\tconst pack = raw;\n\t\tif (pack.contractSpace === void 0) return {\n\t\t\tid: pack.id,\n\t\t\ttargetId: pack.targetId\n\t\t};\n\t\treturn {\n\t\t\tid: pack.id,\n\t\t\ttargetId: pack.targetId,\n\t\t\tcontractSpace: {\n\t\t\t\tcontractJson: pack.contractSpace.contractJson,\n\t\t\t\theadRef: pack.contractSpace.headRef,\n\t\t\t\tmigrations: pack.contractSpace.migrations ?? []\n\t\t\t}\n\t\t};\n\t});\n}\n/**\n* Minimal aggregate-loader projection that extracts `id` + `targetId`\n* from raw extension pack descriptors **without invoking any\n* `contractSpace` accessor**. Inspects the own-property descriptor so\n* that getter-backed `contractSpace` declarations are detected but\n* never called.\n*\n* Inclusion semantics match {@link toDeclaredExtensions}: a data\n* property whose value is explicitly `undefined` is treated as \"no\n* contract-space declaration\" and skipped, mirroring the\n* `pack.contractSpace === undefined` check used on canonicalised\n* inputs. Prototype-chain `contractSpace` properties (no own\n* descriptor) are also skipped.\n*\n* This variant must be used by `buildContractSpaceAggregate` so that\n* the aggregate path (including `db verify`) never reads\n* `contractSpace.contractJson` from extension descriptors — the loader\n* always reads the contract from on-disk artefacts instead.\n*/\nfunction toDeclaredExtensionsFromRaw(extensions) {\n\tconst entries = [];\n\tfor (const raw of extensions) {\n\t\tif (typeof raw !== \"object\" || raw === null) continue;\n\t\tconst descriptor = Object.getOwnPropertyDescriptor(raw, \"contractSpace\");\n\t\tif (descriptor === void 0) continue;\n\t\tif (\"value\" in descriptor && descriptor.value === void 0) continue;\n\t\tconst pack = raw;\n\t\tentries.push({\n\t\t\tid: pack.id,\n\t\t\ttargetId: pack.targetId\n\t\t});\n\t}\n\treturn entries;\n}\n//#endregion\n//#region src/control-api/operations/contract-space-aggregate-loader.ts\nconst CONTRACT_SPACES_DOCS_URL = \"https://pris.ly/contract-spaces\";\nfunction contractSpaceViolationError(summary, options) {\n\treturn new CliStructuredError(\"MIGRATION.CONTRACT_SPACE_VIOLATION\", summary, {\n\t\twhy: options.why,\n\t\tfix: options.fix,\n\t\tdocsUrl: CONTRACT_SPACES_DOCS_URL,\n\t\tmeta: { violations: options.violations }\n\t});\n}\n/**\n* Build the `MIGRATION.CONTRACT_SPACE_VIOLATION` structured-error envelope for a contract-space\n* target mismatch. Shared between the declared-extension precheck (the\n* descriptor's configured target disagrees with the project target) and\n* the on-disk-contract check surfaced by `checkIntegrity`.\n*/\nfunction targetMismatchError(spaceId, expected, actual) {\n\treturn contractSpaceViolationError(`Contract-space target mismatch for \"${spaceId}\"`, {\n\t\twhy: `Space \"${spaceId}\" targets \"${actual}\" but the project's adapter targets \"${expected}\".`,\n\t\tfix: \"Update the extension descriptor to target the configured database, or change the project adapter.\",\n\t\tviolations: [{\n\t\t\tkind: \"targetMismatch\",\n\t\t\tspaceId,\n\t\t\texpected,\n\t\t\tactual\n\t\t}]\n\t});\n}\n/**\n* Human-readable detail for an integrity violation, used as the `why`\n* of the `integrityFailure` envelope. Mirrors the messages the prior\n* throw-on-load loader produced so downstream consumers see the same\n* text for the same on-disk state.\n*/\nfunction describeIntegrityViolation(violation) {\n\tswitch (violation.kind) {\n\t\tcase \"hashMismatch\": return `Migration \"${violation.dirName}\" stored hash \"${violation.stored}\" does not match computed hash \"${violation.computed}\".`;\n\t\tcase \"providedInvariantsMismatch\": return `Migration \"${violation.dirName}\" providedInvariants in migration.json disagrees with ops.json.`;\n\t\tcase \"packageUnloadable\": return `Migration \"${violation.dirName}\" could not be loaded: ${violation.detail}`;\n\t\tcase \"sameSourceAndTarget\": return `Migration \"${violation.dirName}\" has source equal to target (${violation.hash}) with no data invariant — a true no-op self-edge.`;\n\t\tcase \"headRefMissing\": return `Head ref \\`refs/head.json\\` is missing for contract space \"${violation.spaceId}\".`;\n\t\tcase \"headRefNotInGraph\": return `Head ref ${violation.hash} for contract space \"${violation.spaceId}\" is not present in the migration graph.`;\n\t\tcase \"refUnreadable\": return `Ref \"${violation.refName}\" for contract space \"${violation.spaceId}\" is unreadable: ${violation.detail}`;\n\t\tcase \"duplicateMigrationHash\": return `Multiple migrations in space \"${violation.spaceId}\" share migrationHash \"${violation.migrationHash}\" (${violation.dirNames.join(\", \")}).`;\n\t\tdefault: {\n\t\t\tconst spaceId = \"spaceId\" in violation ? violation.spaceId : \"*\";\n\t\t\treturn `Integrity violation \"${violation.kind}\" for contract space \"${spaceId}\".`;\n\t\t}\n\t}\n}\n/**\n* Map the integrity violations `checkIntegrity` reports into a single\n* CLI structured-error envelope, preserving the error codes the prior\n* throw-on-load loader emitted: `MIGRATION.CONTRACT_SPACE_LAYOUT_VIOLATION`\n* (layout drift, bundled) and `MIGRATION.CONTRACT_SPACE_VIOLATION` (target /\n* disjointness / contract-validation / structural integrity). Returns\n* `null` when there is nothing to refuse on.\n*\n* Precedence reproduces the prior loader's first-failure ordering:\n* layout drift first (every offence bundled into one envelope), then\n* target mismatch, then disjointness, then a contract-validation\n* failure, then any remaining structural integrity violation.\n*/\nfunction mapIntegrityViolations(violations) {\n\tif (violations.length === 0) return null;\n\tconst layout = violations.filter((v) => v.kind === \"orphanSpaceDir\" || v.kind === \"declaredButUnmigrated\");\n\tif (layout.length > 0) {\n\t\tconst lines = layout.map((v) => `- [${v.kind}] ${v.spaceId}`);\n\t\treturn new CliStructuredError(\"MIGRATION.CONTRACT_SPACE_LAYOUT_VIOLATION\", layout.length === 1 ? \"Contract-space layout violation detected\" : `Contract-space layout violations detected (${layout.length})`, {\n\t\t\twhy: `The on-disk \\`migrations/\\` directory and your \\`extensions\\` declaration are not in agreement.\\n${lines.join(\"\\n\")}`,\n\t\t\tfix: \"Declare the extension in `extensions` and re-emit its contract-space artefacts, or remove the orphan `migrations/<space>` directory.\",\n\t\t\tdocsUrl: CONTRACT_SPACES_DOCS_URL,\n\t\t\tmeta: { violations: layout }\n\t\t});\n\t}\n\tconst targetMismatch = violations.find((v) => v.kind === \"targetMismatch\");\n\tif (targetMismatch && targetMismatch.kind === \"targetMismatch\") return targetMismatchError(targetMismatch.spaceId, targetMismatch.expected, targetMismatch.actual);\n\tconst disjointness = violations.find((v) => v.kind === \"disjointness\");\n\tif (disjointness && disjointness.kind === \"disjointness\") return contractSpaceViolationError(`Contract-space disjointness violation: storage element \"${disjointness.element}\" claimed by multiple spaces`, {\n\t\twhy: `Spaces ${disjointness.claimedBy.map((s) => `\"${s}\"`).join(\", \")} all claim the storage element \"${disjointness.element}\". Each storage element must be owned by exactly one contract space.`,\n\t\tfix: \"Update the conflicting contracts so each storage element is claimed by exactly one space.\",\n\t\tviolations: [disjointness]\n\t});\n\tconst contractUnreadable = violations.find((v) => v.kind === \"contractUnreadable\");\n\tif (contractUnreadable && contractUnreadable.kind === \"contractUnreadable\") return contractSpaceViolationError(`Contract-space contract validation failed for \"${contractUnreadable.spaceId}\"`, {\n\t\twhy: contractUnreadable.detail,\n\t\tfix: \"Re-emit the extension contract with `prisma-next contract emit`, or fix the extension pack descriptor producing the invalid contract.\",\n\t\tviolations: [contractUnreadable]\n\t});\n\tconst structural = violations[0];\n\treturn contractSpaceViolationError(`Contract-space integrity failure for \"${\"spaceId\" in structural ? structural.spaceId : \"*\"}\"`, {\n\t\twhy: describeIntegrityViolation(structural),\n\t\tfix: \"Re-emit the affected migration package(s) or restore the on-disk `migrations/` directory from version control.\",\n\t\tviolations: [structural]\n\t});\n}\nfunction declaredExtensionsFromInputs(extensions) {\n\treturn toDeclaredExtensionsFromRaw(extensions);\n}\n/**\n* Reject extension descriptors whose configured target disagrees with\n* the project target before any on-disk read.\n*/\nfunction refuseDeclaredExtensionTargetMismatch(inputs) {\n\tfor (const declared of declaredExtensionsFromInputs(inputs.extensions)) if (declared.targetId !== inputs.targetId) return targetMismatchError(declared.id, inputs.targetId, declared.targetId);\n\treturn null;\n}\n/**\n* Load the tolerant {@link ContractSpaceAggregate} once at the CLI\n* surface. Construction never throws on disk content; callers query\n* {@link ContractSpaceAggregate.app} / extension facets instead of\n* re-reading `migrations/`.\n*/\nasync function loadContractSpaceAggregateForCli(inputs) {\n\tconst targetFailure = refuseDeclaredExtensionTargetMismatch(inputs);\n\tif (targetFailure) return notOk(targetFailure);\n\treturn ok(await loadContractSpaceAggregate({\n\t\tmigrationsDir: inputs.migrationsDir,\n\t\tdeserializeContract: inputs.deserializeContract,\n\t\tappContract: inputs.appContract\n\t}));\n}\n/**\n* Run `checkIntegrity` on a loaded aggregate and map violations into\n* the contract-space refusal envelope, or return `null` when the model\n* is acceptable for the requested check scope.\n*/\nfunction refuseContractSpaceIntegrity(aggregate, options) {\n\treturn mapIntegrityViolations(aggregate.checkIntegrity(options));\n}\nconst PACKAGE_CORRUPTION_KINDS = /* @__PURE__ */ new Set([\n\t\"hashMismatch\",\n\t\"providedInvariantsMismatch\",\n\t\"packageUnloadable\"\n]);\n/**\n* Reader-subset integrity refusal for `migration status`: package\n* corruptions only (`hashMismatch`, `providedInvariantsMismatch`,\n* `packageUnloadable`).\n*/\nfunction refusePackageCorruptionOnAggregate(aggregate) {\n\treturn mapIntegrityViolations(aggregate.checkIntegrity().filter((v) => PACKAGE_CORRUPTION_KINDS.has(v.kind)));\n}\n/**\n* Construct the tolerant {@link ContractSpaceAggregate} at the CLI\n* surface and apply the explicit integrity refusal.\n*\n* App-space migration packages are read from `migrations/<app>/` by the\n* loader itself; callers no longer thread them through.\n*/\nasync function buildContractSpaceAggregate(inputs) {\n\tconst declaredExtensions = declaredExtensionsFromInputs(inputs.extensions);\n\tconst loaded = await loadContractSpaceAggregateForCli(inputs);\n\tif (!loaded.ok) return loaded;\n\tconst failure = refuseContractSpaceIntegrity(loaded.value, {\n\t\tdeclaredExtensions,\n\t\tcheckContracts: true\n\t});\n\tif (failure) return notOk(failure);\n\treturn ok(loaded.value);\n}\n/**\n* Build a minimal app {@link Contract} carrying only the project's\n* contract-identity (`storage.storageHash` + `target` / `targetFamily`)\n* when the real `contract.json` is absent or undeserializable.\n*\n* `loadContractSpaceAggregate` requires an `appContract` to synthesise the\n* app space's head ref from its storage hash. Read commands query only that\n* hash and the target — never `models` — so an empty-`models` stand-in is\n* sufficient for them. It is *not* a valid contract for any consumer that\n* reads schema, which is why this is confined to the read-aggregate path.\n*/\nfunction appContractStandInFromIdentity(args) {\n\treturn blindCast({\n\t\tstorage: { storageHash: args.contractHash },\n\t\tschemaVersion: \"0.0.0\",\n\t\ttarget: args.targetId,\n\t\ttargetFamily: args.targetFamily,\n\t\tmodels: {},\n\t\tprofileHash: EMPTY_CONTRACT_HASH\n\t});\n}\nasync function loadContractRawSafely(config) {\n\ttry {\n\t\tconst raw = await readFile(resolveContractPath(config), \"utf-8\");\n\t\treturn JSON.parse(raw);\n\t} catch {\n\t\treturn null;\n\t}\n}\n/**\n* Tolerant {@link ContractSpaceAggregate} assembly for read-only CLI\n* commands. No integrity gate — callers query `aggregate.app` (or other\n* facets) without re-reading `migrations/`. When `contract.json` is absent\n* or undeserializable, the app contract falls back to an identity-only\n* stand-in ({@link appContractStandInFromIdentity}), so these commands\n* load without requiring a readable contract.\n*/\nasync function buildReadAggregate(config, options) {\n\tlet contractHash = EMPTY_CONTRACT_HASH;\n\ttry {\n\t\tcontractHash = (await readContractEnvelope(config)).storageHash;\n\t} catch {}\n\ttry {\n\t\tconst contractRawForAggregate = await loadContractRawSafely(config);\n\t\tconst stack = createControlStack(config);\n\t\tconst familyInstance = config.family.create(stack);\n\t\tconst deserializeContract = (json) => familyInstance.deserializeContract(json);\n\t\tlet appContractForLoad = appContractStandInFromIdentity({\n\t\t\tcontractHash,\n\t\t\ttargetId: config.target.id,\n\t\t\ttargetFamily: config.target.familyId\n\t\t});\n\t\tif (contractRawForAggregate !== null) try {\n\t\t\tappContractForLoad = deserializeContract(contractRawForAggregate);\n\t\t} catch {}\n\t\tconst loaded = await loadContractSpaceAggregateForCli({\n\t\t\ttargetId: config.target.id,\n\t\t\tmigrationsDir: options.migrationsDir,\n\t\t\tappContract: appContractForLoad,\n\t\t\textensions: config.extensions ?? [],\n\t\t\tdeserializeContract\n\t\t});\n\t\tif (!loaded.ok) return loaded;\n\t\treturn ok({\n\t\t\taggregate: loaded.value,\n\t\t\tcontractHash\n\t\t});\n\t} catch (error) {\n\t\tif (MigrationToolsError.is(error)) return notOk(error);\n\t\treturn notOk(errorUnexpected(error instanceof Error ? error.message : String(error), { why: `Failed to read migrations directory: ${error instanceof Error ? error.message : String(error)}` }));\n\t}\n}\n//#endregion\nexport { loadContractSpaceAggregateForCli as a, refuseDeclaredExtensionTargetMismatch as c, toExtensionInputs as d, loadContractRawSafely as i, refusePackageCorruptionOnAggregate as l, buildContractSpaceAggregate as n, mapIntegrityViolations as o, buildReadAggregate as r, refuseContractSpaceIntegrity as s, appContractStandInFromIdentity as t, toDeclaredExtensionsFromRaw as u };\n\n//# sourceMappingURL=contract-space-aggregate-loader-fa04OIaL.mjs.map"],"mappings":";;;;;;;;;;;;;;;AAeA,SAAS,kBAAkB,YAAY;CACtC,OAAO,WAAW,KAAK,QAAQ;EAC9B,MAAM,OAAO;EACb,IAAI,KAAK,kBAAkB,KAAK,GAAG,OAAO;GACzC,IAAI,KAAK;GACT,UAAU,KAAK;EAChB;EACA,OAAO;GACN,IAAI,KAAK;GACT,UAAU,KAAK;GACf,eAAe;IACd,cAAc,KAAK,cAAc;IACjC,SAAS,KAAK,cAAc;IAC5B,YAAY,KAAK,cAAc,cAAc,CAAC;GAC/C;EACD;CACD,CAAC;AACF;;;;;;;;;;;;;;;;;;;;AAoBA,SAAS,4BAA4B,YAAY;CAChD,MAAM,UAAU,CAAC;CACjB,KAAK,MAAM,OAAO,YAAY;EAC7B,IAAI,OAAO,QAAQ,YAAY,QAAQ,MAAM;EAC7C,MAAM,aAAa,OAAO,yBAAyB,KAAK,eAAe;EACvE,IAAI,eAAe,KAAK,GAAG;EAC3B,IAAI,WAAW,cAAc,WAAW,UAAU,KAAK,GAAG;EAC1D,MAAM,OAAO;EACb,QAAQ,KAAK;GACZ,IAAI,KAAK;GACT,UAAU,KAAK;EAChB,CAAC;CACF;CACA,OAAO;AACR;AAGA,MAAM,2BAA2B;AACjC,SAAS,4BAA4B,SAAS,SAAS;CACtD,OAAO,IAAIA,qBAAmB,sCAAsC,SAAS;EAC5E,KAAK,QAAQ;EACb,KAAK,QAAQ;EACb,SAAS;EACT,MAAM,EAAE,YAAY,QAAQ,WAAW;CACxC,CAAC;AACF;;;;;;;AAOA,SAAS,oBAAoB,SAAS,UAAU,QAAQ;CACvD,OAAO,4BAA4B,uCAAuC,QAAQ,IAAI;EACrF,KAAK,UAAU,QAAQ,aAAa,OAAO,uCAAuC,SAAS;EAC3F,KAAK;EACL,YAAY,CAAC;GACZ,MAAM;GAC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C,MAAM,iBAAiB,OAAO,OAAO,OAAO,KAAK;EACjD,MAAM,uBAAuB,SAAS,eAAe,oBAAoB,IAAI;EAC7E,IAAI,qBAAqB,+BAA+B;GACvD;GACA,UAAU,OAAO,OAAO;GACxB,cAAc,OAAO,OAAO;EAC7B,CAAC;EACD,IAAI,4BAA4B,MAAM,IAAI;GACzC,qBAAqB,oBAAoB,uBAAuB;EACjE,QAAQ,CAAC;EACT,MAAM,SAAS,MAAM,iCAAiC;GACrD,UAAU,OAAO,OAAO;GACxB,eAAe,QAAQ;GACvB,aAAa;GACb,YAAY,OAAO,cAAc,CAAC;GAClC;EACD,CAAC;EACD,IAAI,CAAC,OAAO,IAAI,OAAO;EACvB,OAAO,GAAG;GACT,WAAW,OAAO;GAClB;EACD,CAAC;CACF,SAAS,OAAO;EACf,IAAI,oBAAoB,GAAG,KAAK,GAAG,OAAO,MAAM,KAAK;EACrD,OAAO,MAAM,gBAAgB,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,GAAG,EAAE,KAAK,wCAAwC,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,IAAI,CAAC,CAAC;CAChM;AACD"}
@@ -1,14 +1,14 @@
1
- import { P as errorUnexpected, c as errorContractValidationFailed, t as CliStructuredError$1 } from "./cli-errors-BG6bItjG-DwdKIeGz.mjs";
1
+ import { F as errorUnexpected, l as errorContractValidationFailed, t as CliStructuredError$1 } from "./cli-errors-B4zTLaqQ-CXgjO9t4.mjs";
2
2
  import { c as formatMigrationApplyOutput, l as formatMigrationJson, r as createTerminalUI, u as formatMigrationPlanOutput } from "./terminal-ui-Cqz4LVL7-B0mcVdLy.mjs";
3
- import { _ as resolveMigrationPaths, b as setCommandExamples, m as parseGlobalFlagsOrExit, n as closeQuietly, u as handleResult, v as sanitizeErrorMessage, y as setCommandDescriptions } from "./command-helpers-CwLvFwMB-BWwUQhlT.mjs";
3
+ import { _ as resolveMigrationPaths, b as setCommandExamples, m as parseGlobalFlagsOrExit, n as closeQuietly, u as handleResult, v as sanitizeErrorMessage, y as setCommandDescriptions } from "./command-helpers-BCgwcqTe-lNCtppzM.mjs";
4
4
  import { o as resolveRefAdvancementFields } from "./ref-advancement-DaZBzm7m-WoqnFAyr.mjs";
5
- import { t as mapDbInitFailure } from "./db-init-failure-BmCcHUfc-BqDxyrJE.mjs";
6
- import { n as prepareMigrationContext, t as addMigrationCommandOptions } from "./migration-command-scaffold-B1BiWKLI-Bskk5UKX.mjs";
5
+ import { t as mapDbInitFailure } from "./db-init-failure-B5cQML4A-5zr-99Ek.mjs";
6
+ import { n as prepareMigrationContext, t as addMigrationCommandOptions } from "./migration-command-scaffold-SzjR2naH-Yi3-rNfX.mjs";
7
7
  import { ifDefined } from "@prisma/orm-framework/utils/defined";
8
8
  import { isStructuredError } from "@prisma/orm-framework/utils/structured-error";
9
9
  import { notOk, ok } from "@prisma/orm-framework/utils/result";
10
10
  import { Command } from "commander";
11
- //#region ../../../1-framework/3-tooling/cli/dist/db-init-DypCy1e3.mjs
11
+ //#region ../../../1-framework/3-tooling/cli/dist/db-init-BolXrKAI.mjs
12
12
  /**
13
13
  * Executes the db init command and returns a structured Result.
14
14
  */
@@ -106,4 +106,4 @@ function createDbInitCommand() {
106
106
  //#endregion
107
107
  export { createDbInitCommand as t };
108
108
 
109
- //# sourceMappingURL=db-init-DypCy1e3-CBrYfhHF.mjs.map
109
+ //# sourceMappingURL=db-init-BolXrKAI-CwG-zEDW.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"db-init-DypCy1e3-CBrYfhHF.mjs","names":["CliStructuredError"],"sources":["../../../../1-framework/3-tooling/cli/dist/db-init-DypCy1e3.mjs"],"sourcesContent":["import { N as errorUnexpected, s as errorContractValidationFailed, t as CliStructuredError } from \"./cli-errors-BG6bItjG.mjs\";\nimport { c as formatMigrationPlanOutput, o as formatMigrationApplyOutput, s as formatMigrationJson, t as createTerminalUI } from \"./terminal-ui-Cqz4LVL7.mjs\";\nimport { _ as parseGlobalFlagsOrExit, c as resolveMigrationPaths, d as setCommandExamples, l as sanitizeErrorMessage, n as closeQuietly, u as setCommandDescriptions, v as handleResult } from \"./command-helpers-CwLvFwMB.mjs\";\nimport { o as resolveRefAdvancementFields } from \"./ref-advancement-DaZBzm7m.mjs\";\nimport { t as mapDbInitFailure } from \"./db-init-failure-BmCcHUfc.mjs\";\nimport { n as prepareMigrationContext, t as addMigrationCommandOptions } from \"./migration-command-scaffold-B1BiWKLI.mjs\";\nimport { Command } from \"commander\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { notOk, ok } from \"@internal/utils/result\";\nimport { isStructuredError } from \"@internal/utils/structured-error\";\n//#region src/commands/db-init.ts\n/**\n* Executes the db init command and returns a structured Result.\n*/\nasync function executeDbInitCommand(options, flags, ui, startTime) {\n\tconst ctxResult = await prepareMigrationContext(options, flags, ui, {\n\t\tcommandName: \"db init\",\n\t\tdescription: \"Bootstrap a database to match the current contract\",\n\t\turl: \"https://pris.ly/db-init\"\n\t});\n\tif (!ctxResult.ok) return ctxResult;\n\tconst { client, config, contractJson, dbConnection, onProgress, contractPathAbsolute } = ctxResult.value;\n\tconst { migrationsDir, refsDir } = resolveMigrationPaths(options.config, config, process.cwd());\n\ttry {\n\t\tawait client.connect(dbConnection);\n\t\tconst result = await client.dbInit({\n\t\t\tcontract: contractJson,\n\t\t\tmode: options.dryRun ? \"plan\" : \"apply\",\n\t\t\tmigrationsDir,\n\t\t\tonProgress\n\t\t});\n\t\tif (!result.ok) return notOk(mapDbInitFailure(result.failure));\n\t\tconst advancementHash = result.value.mode === \"apply\" ? result.value.marker?.storageHash ?? result.value.destination.storageHash : result.value.destination.storageHash;\n\t\tconst advancement = await resolveRefAdvancementFields({\n\t\t\t...ifDefined(\"advanceRef\", options.advanceRef),\n\t\t\t...ifDefined(\"db\", options.db),\n\t\t\trefsDir,\n\t\t\tmigrationsDir,\n\t\t\tcontractJson,\n\t\t\tcontractJsonPath: contractPathAbsolute,\n\t\t\tmode: result.value.mode,\n\t\t\thash: advancementHash\n\t\t});\n\t\tif (!advancement.ok) return notOk(advancement.failure);\n\t\tconst refAdvancementFields = advancement.value;\n\t\treturn ok({\n\t\t\tok: true,\n\t\t\tmode: result.value.mode,\n\t\t\tplan: {\n\t\t\t\ttargetId: ctxResult.value.config.target.targetId,\n\t\t\t\tdestination: {\n\t\t\t\t\tstorageHash: result.value.destination.storageHash,\n\t\t\t\t\t...ifDefined(\"profileHash\", result.value.destination.profileHash)\n\t\t\t\t},\n\t\t\t\toperations: result.value.plan.operations.map((op) => ({\n\t\t\t\t\tid: op.id,\n\t\t\t\t\tlabel: op.label,\n\t\t\t\t\toperationClass: op.operationClass\n\t\t\t\t})),\n\t\t\t\t...ifDefined(\"preview\", result.value.plan.preview)\n\t\t\t},\n\t\t\t...result.value.execution ? { execution: {\n\t\t\t\toperationsPlanned: result.value.execution.operationsPlanned,\n\t\t\t\toperationsExecuted: result.value.execution.operationsExecuted\n\t\t\t} } : {},\n\t\t\t...result.value.marker ? { marker: {\n\t\t\t\tstorageHash: result.value.marker.storageHash,\n\t\t\t\t...ifDefined(\"profileHash\", result.value.marker.profileHash)\n\t\t\t} } : {},\n\t\t\t...ifDefined(\"perSpace\", result.value.perSpace),\n\t\t\tadvancedRef: refAdvancementFields.advancedRef,\n\t\t\tplannedAdvanceRef: refAdvancementFields.plannedAdvanceRef,\n\t\t\tsummary: result.value.summary,\n\t\t\ttimings: { total: Date.now() - startTime }\n\t\t});\n\t} catch (error) {\n\t\tif (CliStructuredError.is(error)) return notOk(error);\n\t\tif (isStructuredError(error) && error.code === \"CONTRACT.VALIDATION_FAILED\") return notOk(errorContractValidationFailed(`Contract validation failed: ${error.message}`, { where: { path: contractPathAbsolute } }));\n\t\tconst safeMessage = sanitizeErrorMessage(error instanceof Error ? error.message : String(error), typeof dbConnection === \"string\" ? dbConnection : void 0);\n\t\treturn notOk(errorUnexpected(safeMessage, { why: `Unexpected error during db init: ${safeMessage}` }));\n\t} finally {\n\t\tawait closeQuietly(client);\n\t}\n}\nfunction createDbInitCommand() {\n\tconst command = new Command(\"init\");\n\tsetCommandDescriptions(command, \"Bootstrap a database to match the current contract and sign it\", \"Initializes a database to match your emitted contract using additive-only operations.\\nCreates any missing tables, columns, indexes, and constraints defined in your contract.\\nLeaves existing compatible structures in place, surfaces conflicts when destructive changes\\nwould be required, and signs the database to track contract state. Use --dry-run to\\npreview changes without applying.\");\n\tsetCommandExamples(command, [\"prisma-next db init --db $DATABASE_URL\", \"prisma-next db init --db $DATABASE_URL --dry-run\"]);\n\taddMigrationCommandOptions(command);\n\tcommand.option(\"--advance-ref <name>\", \"Ref to advance to the post-command contract hash\");\n\tcommand.action(async (options) => {\n\t\tconst flags = parseGlobalFlagsOrExit(options);\n\t\tconst startTime = Date.now();\n\t\tconst ui = createTerminalUI(flags);\n\t\tconst exitCode = handleResult(await executeDbInitCommand(options, flags, ui, startTime), flags, ui, (dbInitResult) => {\n\t\t\tif (flags.json) ui.output(formatMigrationJson(dbInitResult));\n\t\t\telse {\n\t\t\t\tconst output = dbInitResult.mode === \"plan\" ? formatMigrationPlanOutput(dbInitResult, flags) : formatMigrationApplyOutput(dbInitResult, flags);\n\t\t\t\tif (output) ui.log(output);\n\t\t\t}\n\t\t});\n\t\tprocess.exit(exitCode);\n\t});\n\treturn command;\n}\n//#endregion\nexport { createDbInitCommand as t };\n\n//# sourceMappingURL=db-init-DypCy1e3.mjs.map"],"mappings":";;;;;;;;;;;;;;AAcA,eAAe,qBAAqB,SAAS,OAAO,IAAI,WAAW;CAClE,MAAM,YAAY,MAAM,wBAAwB,SAAS,OAAO,IAAI;EACnE,aAAa;EACb,aAAa;EACb,KAAK;CACN,CAAC;CACD,IAAI,CAAC,UAAU,IAAI,OAAO;CAC1B,MAAM,EAAE,QAAQ,QAAQ,cAAc,cAAc,YAAY,yBAAyB,UAAU;CACnG,MAAM,EAAE,eAAe,YAAY,sBAAsB,QAAQ,QAAQ,QAAQ,QAAQ,IAAI,CAAC;CAC9F,IAAI;EACH,M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,KAAK,QAAQ;CACtB,CAAC;CACD,OAAO;AACR"}
1
+ {"version":3,"file":"db-init-BolXrKAI-CwG-zEDW.mjs","names":["CliStructuredError"],"sources":["../../../../1-framework/3-tooling/cli/dist/db-init-BolXrKAI.mjs"],"sourcesContent":["import { P as errorUnexpected, c as errorContractValidationFailed, t as CliStructuredError } from \"./cli-errors-B4zTLaqQ.mjs\";\nimport { c as formatMigrationPlanOutput, o as formatMigrationApplyOutput, s as formatMigrationJson, t as createTerminalUI } from \"./terminal-ui-Cqz4LVL7.mjs\";\nimport { _ as parseGlobalFlagsOrExit, c as resolveMigrationPaths, d as setCommandExamples, l as sanitizeErrorMessage, n as closeQuietly, u as setCommandDescriptions, v as handleResult } from \"./command-helpers-BCgwcqTe.mjs\";\nimport { o as resolveRefAdvancementFields } from \"./ref-advancement-DaZBzm7m.mjs\";\nimport { t as mapDbInitFailure } from \"./db-init-failure-B5cQML4A.mjs\";\nimport { n as prepareMigrationContext, t as addMigrationCommandOptions } from \"./migration-command-scaffold-SzjR2naH.mjs\";\nimport { Command } from \"commander\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { notOk, ok } from \"@internal/utils/result\";\nimport { isStructuredError } from \"@internal/utils/structured-error\";\n//#region src/commands/db-init.ts\n/**\n* Executes the db init command and returns a structured Result.\n*/\nasync function executeDbInitCommand(options, flags, ui, startTime) {\n\tconst ctxResult = await prepareMigrationContext(options, flags, ui, {\n\t\tcommandName: \"db init\",\n\t\tdescription: \"Bootstrap a database to match the current contract\",\n\t\turl: \"https://pris.ly/db-init\"\n\t});\n\tif (!ctxResult.ok) return ctxResult;\n\tconst { client, config, contractJson, dbConnection, onProgress, contractPathAbsolute } = ctxResult.value;\n\tconst { migrationsDir, refsDir } = resolveMigrationPaths(options.config, config, process.cwd());\n\ttry {\n\t\tawait client.connect(dbConnection);\n\t\tconst result = await client.dbInit({\n\t\t\tcontract: contractJson,\n\t\t\tmode: options.dryRun ? \"plan\" : \"apply\",\n\t\t\tmigrationsDir,\n\t\t\tonProgress\n\t\t});\n\t\tif (!result.ok) return notOk(mapDbInitFailure(result.failure));\n\t\tconst advancementHash = result.value.mode === \"apply\" ? result.value.marker?.storageHash ?? result.value.destination.storageHash : result.value.destination.storageHash;\n\t\tconst advancement = await resolveRefAdvancementFields({\n\t\t\t...ifDefined(\"advanceRef\", options.advanceRef),\n\t\t\t...ifDefined(\"db\", options.db),\n\t\t\trefsDir,\n\t\t\tmigrationsDir,\n\t\t\tcontractJson,\n\t\t\tcontractJsonPath: contractPathAbsolute,\n\t\t\tmode: result.value.mode,\n\t\t\thash: advancementHash\n\t\t});\n\t\tif (!advancement.ok) return notOk(advancement.failure);\n\t\tconst refAdvancementFields = advancement.value;\n\t\treturn ok({\n\t\t\tok: true,\n\t\t\tmode: result.value.mode,\n\t\t\tplan: {\n\t\t\t\ttargetId: ctxResult.value.config.target.targetId,\n\t\t\t\tdestination: {\n\t\t\t\t\tstorageHash: result.value.destination.storageHash,\n\t\t\t\t\t...ifDefined(\"profileHash\", result.value.destination.profileHash)\n\t\t\t\t},\n\t\t\t\toperations: result.value.plan.operations.map((op) => ({\n\t\t\t\t\tid: op.id,\n\t\t\t\t\tlabel: op.label,\n\t\t\t\t\toperationClass: op.operationClass\n\t\t\t\t})),\n\t\t\t\t...ifDefined(\"preview\", result.value.plan.preview)\n\t\t\t},\n\t\t\t...result.value.execution ? { execution: {\n\t\t\t\toperationsPlanned: result.value.execution.operationsPlanned,\n\t\t\t\toperationsExecuted: result.value.execution.operationsExecuted\n\t\t\t} } : {},\n\t\t\t...result.value.marker ? { marker: {\n\t\t\t\tstorageHash: result.value.marker.storageHash,\n\t\t\t\t...ifDefined(\"profileHash\", result.value.marker.profileHash)\n\t\t\t} } : {},\n\t\t\t...ifDefined(\"perSpace\", result.value.perSpace),\n\t\t\tadvancedRef: refAdvancementFields.advancedRef,\n\t\t\tplannedAdvanceRef: refAdvancementFields.plannedAdvanceRef,\n\t\t\tsummary: result.value.summary,\n\t\t\ttimings: { total: Date.now() - startTime }\n\t\t});\n\t} catch (error) {\n\t\tif (CliStructuredError.is(error)) return notOk(error);\n\t\tif (isStructuredError(error) && error.code === \"CONTRACT.VALIDATION_FAILED\") return notOk(errorContractValidationFailed(`Contract validation failed: ${error.message}`, { where: { path: contractPathAbsolute } }));\n\t\tconst safeMessage = sanitizeErrorMessage(error instanceof Error ? error.message : String(error), typeof dbConnection === \"string\" ? dbConnection : void 0);\n\t\treturn notOk(errorUnexpected(safeMessage, { why: `Unexpected error during db init: ${safeMessage}` }));\n\t} finally {\n\t\tawait closeQuietly(client);\n\t}\n}\nfunction createDbInitCommand() {\n\tconst command = new Command(\"init\");\n\tsetCommandDescriptions(command, \"Bootstrap a database to match the current contract and sign it\", \"Initializes a database to match your emitted contract using additive-only operations.\\nCreates any missing tables, columns, indexes, and constraints defined in your contract.\\nLeaves existing compatible structures in place, surfaces conflicts when destructive changes\\nwould be required, and signs the database to track contract state. Use --dry-run to\\npreview changes without applying.\");\n\tsetCommandExamples(command, [\"prisma-next db init --db $DATABASE_URL\", \"prisma-next db init --db $DATABASE_URL --dry-run\"]);\n\taddMigrationCommandOptions(command);\n\tcommand.option(\"--advance-ref <name>\", \"Ref to advance to the post-command contract hash\");\n\tcommand.action(async (options) => {\n\t\tconst flags = parseGlobalFlagsOrExit(options);\n\t\tconst startTime = Date.now();\n\t\tconst ui = createTerminalUI(flags);\n\t\tconst exitCode = handleResult(await executeDbInitCommand(options, flags, ui, startTime), flags, ui, (dbInitResult) => {\n\t\t\tif (flags.json) ui.output(formatMigrationJson(dbInitResult));\n\t\t\telse {\n\t\t\t\tconst output = dbInitResult.mode === \"plan\" ? formatMigrationPlanOutput(dbInitResult, flags) : formatMigrationApplyOutput(dbInitResult, flags);\n\t\t\t\tif (output) ui.log(output);\n\t\t\t}\n\t\t});\n\t\tprocess.exit(exitCode);\n\t});\n\treturn command;\n}\n//#endregion\nexport { createDbInitCommand as t };\n\n//# sourceMappingURL=db-init-BolXrKAI.mjs.map"],"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,MAAM,YAAY,KAAK,IAAI;EAC3B,MAAM,KAAK,iBAAiB,KAAK;EACjC,MAAM,WAAW,aAAa,MAAM,qBAAqB,SAAS,OAAO,IAAI,SAAS,GAAG,OAAO,KAAK,iBAAiB;GACrH,IAAI,MAAM,MAAM,GAAG,OAAO,oBAAoB,YAAY,CAAC;QACtD;IACJ,MAAM,SAAS,aAAa,SAAS,SAAS,0BAA0B,cAAc,KAAK,IAAI,2BAA2B,cAAc,KAAK;IAC7I,IAAI,QAAQ,GAAG,IAAI,MAAM;GAC1B;EACD,CAAC;EACD,QAAQ,KAAK,QAAQ;CACtB,CAAC;CACD,OAAO;AACR"}
@@ -1,7 +1,7 @@
1
- import { O as errorRunnerFailed, b as errorMigrationPlanningFailed, k as errorRuntime$1 } from "./cli-errors-BG6bItjG-DwdKIeGz.mjs";
1
+ import { A as errorRuntime$1, k as errorRunnerFailed, x as errorMigrationPlanningFailed } from "./cli-errors-B4zTLaqQ-CXgjO9t4.mjs";
2
2
  import { ifDefined } from "@prisma/orm-framework/utils/defined";
3
3
  import { assertNever } from "@prisma/orm-framework/utils/internal-error";
4
- //#region ../../../1-framework/3-tooling/cli/dist/db-init-failure-BmCcHUfc.mjs
4
+ //#region ../../../1-framework/3-tooling/cli/dist/db-init-failure-B5cQML4A.mjs
5
5
  function markerMismatchDetail(failure) {
6
6
  const parts = [];
7
7
  if (failure.marker?.storageHash !== failure.destination?.storageHash && failure.marker?.storageHash && failure.destination?.storageHash) parts.push(`storageHash (marker: ${failure.marker.storageHash}, destination: ${failure.destination.storageHash})`);
@@ -41,4 +41,4 @@ function mapDbInitFailure(failure) {
41
41
  //#endregion
42
42
  export { mapDbInitFailure as t };
43
43
 
44
- //# sourceMappingURL=db-init-failure-BmCcHUfc-BqDxyrJE.mjs.map
44
+ //# sourceMappingURL=db-init-failure-B5cQML4A-5zr-99Ek.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"db-init-failure-BmCcHUfc-BqDxyrJE.mjs","names":["errorRuntime"],"sources":["../../../../1-framework/3-tooling/cli/dist/db-init-failure-BmCcHUfc.mjs"],"sourcesContent":["import { D as errorRunnerFailed, O as errorRuntime, y as errorMigrationPlanningFailed } from \"./cli-errors-BG6bItjG.mjs\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { assertNever } from \"@internal/utils/internal-error\";\n//#region src/utils/db-init-failure.ts\nfunction markerMismatchDetail(failure) {\n\tconst parts = [];\n\tif (failure.marker?.storageHash !== failure.destination?.storageHash && failure.marker?.storageHash && failure.destination?.storageHash) parts.push(`storageHash (marker: ${failure.marker.storageHash}, destination: ${failure.destination.storageHash})`);\n\tif (failure.marker?.profileHash !== failure.destination?.profileHash && failure.marker?.profileHash && failure.destination?.profileHash) parts.push(`profileHash (marker: ${failure.marker.profileHash}, destination: ${failure.destination.profileHash})`);\n\treturn parts.length > 0 ? ` Mismatch in ${parts.join(\" and \")}.` : \"\";\n}\n/**\n* A `db init` failure as the CLI's structured error.\n*\n* The `assertNever` is deliberate: a control-API failure code this does not\n* handle must stop the command rather than degrade into a generic message.\n*/\nfunction mapDbInitFailure(failure) {\n\tif (failure.code === \"PLANNING_FAILED\") return errorMigrationPlanningFailed({ conflicts: failure.conflicts ?? [] });\n\tif (failure.code === \"MIGRATION.MARKER_ORIGIN_MISMATCH\") return errorRuntime(\"MIGRATION.MARKER_ORIGIN_MISMATCH\", `Existing database signature does not match plan destination.${markerMismatchDetail(failure)}`, {\n\t\twhy: \"Database has an existing signature (marker) that does not match the target contract\",\n\t\tfix: \"If bootstrapping, drop/reset the database then re-run `prisma-next db init`; otherwise reconcile schema/marker using your migration workflow\",\n\t\tmeta: {\n\t\t\t...ifDefined(\"markerStorageHash\", failure.marker?.storageHash),\n\t\t\t...ifDefined(\"destinationStorageHash\", failure.destination?.storageHash),\n\t\t\t...ifDefined(\"markerProfileHash\", failure.marker?.profileHash),\n\t\t\t...ifDefined(\"destinationProfileHash\", failure.destination?.profileHash)\n\t\t}\n\t});\n\tif (failure.code === \"RUNNER_FAILED\") {\n\t\tconst fix = (typeof failure.meta?.[\"runnerErrorCode\"] === \"string\" ? failure.meta[\"runnerErrorCode\"] : void 0) === \"MIGRATION.LEGACY_MARKER_SHAPE\" ? \"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.\" : \"Fix the schema mismatch (db init is additive-only), or drop/reset the database and re-run `prisma-next db init`\";\n\t\treturn errorRunnerFailed(failure.summary, {\n\t\t\twhy: failure.why ?? \"Migration runner failed\",\n\t\t\tfix,\n\t\t\t...ifDefined(\"meta\", failure.meta),\n\t\t\t...ifDefined(\"cause\", failure.cause)\n\t\t});\n\t}\n\tconst exhaustive = failure.code;\n\treturn assertNever(exhaustive, `Unhandled DbInitFailure code: ${String(exhaustive)}`);\n}\n//#endregion\nexport { mapDbInitFailure as t };\n\n//# sourceMappingURL=db-init-failure-BmCcHUfc.mjs.map"],"mappings":";;;;AAIA,SAAS,qBAAqB,SAAS;CACtC,MAAM,QAAQ,CAAC;CACf,IAAI,QAAQ,QAAQ,gBAAgB,QAAQ,aAAa,eAAe,QAAQ,QAAQ,eAAe,QAAQ,aAAa,aAAa,MAAM,KAAK,wBAAwB,QAAQ,OAAO,YAAY,iBAAiB,QAAQ,YAAY,YAAY,EAAE;CAC1P,IAAI,QAAQ,QAAQ,gBAAgB,QAAQ,aAAa,eAAe,QAAQ,QAAQ,eAAe,QAAQ,aAAa,aAAa,MAAM,KAAK,wBAAwB,QAAQ,OAAO,YAAY,iBAAiB,QAAQ,YAAY,YAAY,EAAE;CAC1P,OAAO,MAAM,SAAS,IAAI,gBAAgB,MAAM,KAAK,OAAO,EAAE,KAAK;AACpE;;;;;;;AAOA,SAAS,iBAAiB,SAAS;CAClC,IAAI,QAAQ,SAAS,mBAAmB,OAAO,6BAA6B,EAAE,WAAW,QAAQ,aAAa,CAAC,EAAE,CAAC;CAClH,IAAI,QAAQ,SAAS,oCAAoC,OAAOA,eAAa,oCAAoC,+DAA+D,qBAAqB,OAAO,KAAK;EAChN,KAAK;EACL,KAAK;EACL,MAAM;GACL,GAAG,UAAU,qBAAqB,QAAQ,QAAQ,WAAW;GAC7D,GAAG,UAAU,0BAA0B,QAAQ,aAAa,WAAW;GACvE,GAAG,UAAU,qBAAqB,QAAQ,QAAQ,WAAW;GAC7D,GAAG,UAAU,0BAA0B,QAAQ,aAAa,WAAW;EACxE;CACD,CAAC;CACD,IAAI,QAAQ,SAAS,iBAAiB;EACrC,MAAM,OAAO,OAAO,QAAQ,OAAO,uBAAuB,WAAW,QAAQ,KAAK,qBAAqB,KAAK,OAAO,kCAAkC,iMAAiM;EACtV,OAAO,kBAAkB,QAAQ,SAAS;GACzC,KAAK,QAAQ,OAAO;GACpB;GACA,GAAG,UAAU,QAAQ,QAAQ,IAAI;GACjC,GAAG,UAAU,SAAS,QAAQ,KAAK;EACpC,CAAC;CACF;CACA,MAAM,aAAa,QAAQ;CAC3B,OAAO,YAAY,YAAY,iCAAiC,OAAO,UAAU,GAAG;AACrF"}
1
+ {"version":3,"file":"db-init-failure-B5cQML4A-5zr-99Ek.mjs","names":["errorRuntime"],"sources":["../../../../1-framework/3-tooling/cli/dist/db-init-failure-B5cQML4A.mjs"],"sourcesContent":["import { O as errorRunnerFailed, b as errorMigrationPlanningFailed, k as errorRuntime } from \"./cli-errors-B4zTLaqQ.mjs\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { assertNever } from \"@internal/utils/internal-error\";\n//#region src/utils/db-init-failure.ts\nfunction markerMismatchDetail(failure) {\n\tconst parts = [];\n\tif (failure.marker?.storageHash !== failure.destination?.storageHash && failure.marker?.storageHash && failure.destination?.storageHash) parts.push(`storageHash (marker: ${failure.marker.storageHash}, destination: ${failure.destination.storageHash})`);\n\tif (failure.marker?.profileHash !== failure.destination?.profileHash && failure.marker?.profileHash && failure.destination?.profileHash) parts.push(`profileHash (marker: ${failure.marker.profileHash}, destination: ${failure.destination.profileHash})`);\n\treturn parts.length > 0 ? ` Mismatch in ${parts.join(\" and \")}.` : \"\";\n}\n/**\n* A `db init` failure as the CLI's structured error.\n*\n* The `assertNever` is deliberate: a control-API failure code this does not\n* handle must stop the command rather than degrade into a generic message.\n*/\nfunction mapDbInitFailure(failure) {\n\tif (failure.code === \"PLANNING_FAILED\") return errorMigrationPlanningFailed({ conflicts: failure.conflicts ?? [] });\n\tif (failure.code === \"MIGRATION.MARKER_ORIGIN_MISMATCH\") return errorRuntime(\"MIGRATION.MARKER_ORIGIN_MISMATCH\", `Existing database signature does not match plan destination.${markerMismatchDetail(failure)}`, {\n\t\twhy: \"Database has an existing signature (marker) that does not match the target contract\",\n\t\tfix: \"If bootstrapping, drop/reset the database then re-run `prisma-next db init`; otherwise reconcile schema/marker using your migration workflow\",\n\t\tmeta: {\n\t\t\t...ifDefined(\"markerStorageHash\", failure.marker?.storageHash),\n\t\t\t...ifDefined(\"destinationStorageHash\", failure.destination?.storageHash),\n\t\t\t...ifDefined(\"markerProfileHash\", failure.marker?.profileHash),\n\t\t\t...ifDefined(\"destinationProfileHash\", failure.destination?.profileHash)\n\t\t}\n\t});\n\tif (failure.code === \"RUNNER_FAILED\") {\n\t\tconst fix = (typeof failure.meta?.[\"runnerErrorCode\"] === \"string\" ? failure.meta[\"runnerErrorCode\"] : void 0) === \"MIGRATION.LEGACY_MARKER_SHAPE\" ? \"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.\" : \"Fix the schema mismatch (db init is additive-only), or drop/reset the database and re-run `prisma-next db init`\";\n\t\treturn errorRunnerFailed(failure.summary, {\n\t\t\twhy: failure.why ?? \"Migration runner failed\",\n\t\t\tfix,\n\t\t\t...ifDefined(\"meta\", failure.meta),\n\t\t\t...ifDefined(\"cause\", failure.cause)\n\t\t});\n\t}\n\tconst exhaustive = failure.code;\n\treturn assertNever(exhaustive, `Unhandled DbInitFailure code: ${String(exhaustive)}`);\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GACjC,GAAG,UAAU,SAAS,QAAQ,KAAK;EACpC,CAAC;CACF;CACA,MAAM,aAAa,QAAQ;CAC3B,OAAO,YAAY,YAAY,iCAAiC,OAAO,UAAU,GAAG;AACrF"}
@@ -1,9 +1,9 @@
1
1
  import { r as createTerminalUI } from "./terminal-ui-Cqz4LVL7-B0mcVdLy.mjs";
2
- import { b as setCommandExamples, m as parseGlobalFlagsOrExit, t as addGlobalOptions, u as handleResult, y as setCommandDescriptions } from "./command-helpers-CwLvFwMB-BWwUQhlT.mjs";
3
- import { t as inspectLiveSchema } from "./inspect-live-schema-Cf77j9Vd-i5fzNW4T.mjs";
2
+ import { b as setCommandExamples, m as parseGlobalFlagsOrExit, t as addGlobalOptions, u as handleResult, y as setCommandDescriptions } from "./command-helpers-BCgwcqTe-lNCtppzM.mjs";
3
+ import { t as inspectLiveSchema } from "./inspect-live-schema-BPHXdvqW-DrzL2ZkQ.mjs";
4
4
  import { n as formatIntrospectOutput, t as formatIntrospectJson } from "./verify-Cogr_Fj9-D3lCWA6t.mjs";
5
5
  import { Command } from "commander";
6
- //#region ../../../1-framework/3-tooling/cli/dist/db-schema-DHfPM-5V.mjs
6
+ //#region ../../../1-framework/3-tooling/cli/dist/db-schema-DvdLBdEY.mjs
7
7
  function toIntrospectSchemaResult(result) {
8
8
  return {
9
9
  ok: true,
@@ -45,4 +45,4 @@ function createDbSchemaCommand() {
45
45
  //#endregion
46
46
  export { createDbSchemaCommand as t };
47
47
 
48
- //# sourceMappingURL=db-schema-DHfPM-5V-JeCjrQ55.mjs.map
48
+ //# sourceMappingURL=db-schema-DvdLBdEY-Dl6e1d_Y.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"db-schema-DHfPM-5V-JeCjrQ55.mjs","names":[],"sources":["../../../../1-framework/3-tooling/cli/dist/db-schema-DHfPM-5V.mjs"],"sourcesContent":["import { t as createTerminalUI } from \"./terminal-ui-Cqz4LVL7.mjs\";\nimport { _ as parseGlobalFlagsOrExit, d as setCommandExamples, t as addGlobalOptions, u as setCommandDescriptions, v as handleResult } from \"./command-helpers-CwLvFwMB.mjs\";\nimport { t as inspectLiveSchema } from \"./inspect-live-schema-Cf77j9Vd.mjs\";\nimport { n as formatIntrospectOutput, t as formatIntrospectJson } from \"./verify-Cogr_Fj9.mjs\";\nimport { Command } from \"commander\";\n//#region src/commands/db-schema.ts\nfunction toIntrospectSchemaResult(result) {\n\treturn {\n\t\tok: true,\n\t\tsummary: \"Schema read successfully\",\n\t\ttarget: result.target,\n\t\tschema: result.schema,\n\t\tmeta: result.meta,\n\t\ttimings: result.timings\n\t};\n}\nfunction createDbSchemaCommand() {\n\tconst command = new Command(\"schema\");\n\tsetCommandDescriptions(command, \"Inspect the live database schema\", \"Reads the live database schema and prints it as a tree by default or as JSON with\\n--json. This command is always read-only and never writes files. To save machine-\\nreadable output, use shell redirection, for example `prisma-next db schema --json > schema.json`.\");\n\tsetCommandExamples(command, [\n\t\t\"prisma-next db schema --db $DATABASE_URL\",\n\t\t\"prisma-next db schema --db $DATABASE_URL --json\",\n\t\t\"prisma-next db schema --db $DATABASE_URL --json > schema.json\"\n\t]);\n\taddGlobalOptions(command).option(\"--db <url>\", \"Database connection string\").option(\"--config <path>\", \"Path to prisma-next.config.ts\").action(async (options) => {\n\t\tconst flags = parseGlobalFlagsOrExit(options);\n\t\tconst ui = createTerminalUI(flags);\n\t\tconst exitCode = handleResult(await inspectLiveSchema(options, flags, ui, Date.now(), {\n\t\t\tcommandName: \"db schema\",\n\t\t\tdescription: \"Inspect the live database schema\",\n\t\t\turl: \"https://pris.ly/db-schema\"\n\t\t}), flags, ui, (value) => {\n\t\t\tconst introspectResult = toIntrospectSchemaResult(value);\n\t\t\tif (flags.json) {\n\t\t\t\tui.output(formatIntrospectJson(introspectResult));\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst output = formatIntrospectOutput(introspectResult, value.schemaView, flags);\n\t\t\tif (output) ui.log(output);\n\t\t});\n\t\tprocess.exit(exitCode);\n\t});\n\treturn command;\n}\n//#endregion\nexport { createDbSchemaCommand as t };\n\n//# sourceMappingURL=db-schema-DHfPM-5V.mjs.map"],"mappings":";;;;;;AAMA,SAAS,yBAAyB,QAAQ;CACzC,OAAO;EACN,IAAI;EACJ,SAAS;EACT,QAAQ,OAAO;EACf,QAAQ,OAAO;EACf,MAAM,OAAO;EACb,SAAS,OAAO;CACjB;AACD;AACA,SAAS,wBAAwB;CAChC,MAAM,UAAU,IAAI,QAAQ,QAAQ;CACpC,uBAAuB,SAAS,oCAAoC,yQAAyQ;CAC7U,mBAAmB,SAAS;EAC3B;EACA;EACA;CACD,CAAC;CACD,iBAAiB,OAAO,CAAC,CAAC,OAAO,cAAc,4BAA4B,CAAC,CAAC,OAAO,mBAAmB,+BAA+B,CAAC,CAAC,OAAO,OAAO,YAAY;EACjK,MAAM,QAAQ,uBAAuB,OAAO;EAC5C,MAAM,KAAK,iBAAiB,KAAK;EACjC,MAAM,WAAW,aAAa,MAAM,kBAAkB,SAAS,OAAO,IAAI,KAAK,IAAI,GAAG;GACrF,aAAa;GACb,aAAa;GACb,KAAK;EACN,CAAC,GAAG,OAAO,KAAK,UAAU;GACzB,MAAM,mBAAmB,yBAAyB,KAAK;GACvD,IAAI,MAAM,MAAM;IACf,GAAG,OAAO,qBAAqB,gBAAgB,CAAC;IAChD;GACD;GACA,MAAM,SAAS,uBAAuB,kBAAkB,MAAM,YAAY,KAAK;GAC/E,IAAI,QAAQ,GAAG,IAAI,MAAM;EAC1B,CAAC;EACD,QAAQ,KAAK,QAAQ;CACtB,CAAC;CACD,OAAO;AACR"}
1
+ {"version":3,"file":"db-schema-DvdLBdEY-Dl6e1d_Y.mjs","names":[],"sources":["../../../../1-framework/3-tooling/cli/dist/db-schema-DvdLBdEY.mjs"],"sourcesContent":["import { t as createTerminalUI } from \"./terminal-ui-Cqz4LVL7.mjs\";\nimport { _ as parseGlobalFlagsOrExit, d as setCommandExamples, t as addGlobalOptions, u as setCommandDescriptions, v as handleResult } from \"./command-helpers-BCgwcqTe.mjs\";\nimport { t as inspectLiveSchema } from \"./inspect-live-schema-BPHXdvqW.mjs\";\nimport { n as formatIntrospectOutput, t as formatIntrospectJson } from \"./verify-Cogr_Fj9.mjs\";\nimport { Command } from \"commander\";\n//#region src/commands/db-schema.ts\nfunction toIntrospectSchemaResult(result) {\n\treturn {\n\t\tok: true,\n\t\tsummary: \"Schema read successfully\",\n\t\ttarget: result.target,\n\t\tschema: result.schema,\n\t\tmeta: result.meta,\n\t\ttimings: result.timings\n\t};\n}\nfunction createDbSchemaCommand() {\n\tconst command = new Command(\"schema\");\n\tsetCommandDescriptions(command, \"Inspect the live database schema\", \"Reads the live database schema and prints it as a tree by default or as JSON with\\n--json. This command is always read-only and never writes files. To save machine-\\nreadable output, use shell redirection, for example `prisma-next db schema --json > schema.json`.\");\n\tsetCommandExamples(command, [\n\t\t\"prisma-next db schema --db $DATABASE_URL\",\n\t\t\"prisma-next db schema --db $DATABASE_URL --json\",\n\t\t\"prisma-next db schema --db $DATABASE_URL --json > schema.json\"\n\t]);\n\taddGlobalOptions(command).option(\"--db <url>\", \"Database connection string\").option(\"--config <path>\", \"Path to prisma-next.config.ts\").action(async (options) => {\n\t\tconst flags = parseGlobalFlagsOrExit(options);\n\t\tconst ui = createTerminalUI(flags);\n\t\tconst exitCode = handleResult(await inspectLiveSchema(options, flags, ui, Date.now(), {\n\t\t\tcommandName: \"db schema\",\n\t\t\tdescription: \"Inspect the live database schema\",\n\t\t\turl: \"https://pris.ly/db-schema\"\n\t\t}), flags, ui, (value) => {\n\t\t\tconst introspectResult = toIntrospectSchemaResult(value);\n\t\t\tif (flags.json) {\n\t\t\t\tui.output(formatIntrospectJson(introspectResult));\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst output = formatIntrospectOutput(introspectResult, value.schemaView, flags);\n\t\t\tif (output) ui.log(output);\n\t\t});\n\t\tprocess.exit(exitCode);\n\t});\n\treturn command;\n}\n//#endregion\nexport { createDbSchemaCommand as t };\n\n//# sourceMappingURL=db-schema-DvdLBdEY.mjs.map"],"mappings":";;;;;;AAMA,SAAS,yBAAyB,QAAQ;CACzC,OAAO;EACN,IAAI;EACJ,SAAS;EACT,QAAQ,OAAO;EACf,QAAQ,OAAO;EACf,MAAM,OAAO;EACb,SAAS,OAAO;CACjB;AACD;AACA,SAAS,wBAAwB;CAChC,MAAM,UAAU,IAAI,QAAQ,QAAQ;CACpC,uBAAuB,SAAS,oCAAoC,yQAAyQ;CAC7U,mBAAmB,SAAS;EAC3B;EACA;EACA;CACD,CAAC;CACD,iBAAiB,OAAO,CAAC,CAAC,OAAO,cAAc,4BAA4B,CAAC,CAAC,OAAO,mBAAmB,+BAA+B,CAAC,CAAC,OAAO,OAAO,YAAY;EACjK,MAAM,QAAQ,uBAAuB,OAAO;EAC5C,MAAM,KAAK,iBAAiB,KAAK;EACjC,MAAM,WAAW,aAAa,MAAM,kBAAkB,SAAS,OAAO,IAAI,KAAK,IAAI,GAAG;GACrF,aAAa;GACb,aAAa;GACb,KAAK;EACN,CAAC,GAAG,OAAO,KAAK,UAAU;GACzB,MAAM,mBAAmB,yBAAyB,KAAK;GACvD,IAAI,MAAM,MAAM;IACf,GAAG,OAAO,qBAAqB,gBAAgB,CAAC;IAChD;GACD;GACA,MAAM,SAAS,uBAAuB,kBAAkB,MAAM,YAAY,KAAK;GAC/E,IAAI,QAAQ,GAAG,IAAI,MAAM;EAC1B,CAAC;EACD,QAAQ,KAAK,QAAQ;CACtB,CAAC;CACD,OAAO;AACR"}
@@ -1,17 +1,17 @@
1
1
  import { o as loadConfigForSections } from "./exports-BZLNbtkY.mjs";
2
- import { P as errorUnexpected, c as errorContractValidationFailed, d as errorDriverRequired, f as errorFileNotFound, l as errorDatabaseConnectionRequired, t as CliStructuredError$1 } from "./cli-errors-BG6bItjG-DwdKIeGz.mjs";
2
+ import { F as errorUnexpected, f as errorDriverRequired, l as errorContractValidationFailed, p as errorFileNotFound, t as CliStructuredError$1, u as errorDatabaseConnectionRequired } from "./cli-errors-B4zTLaqQ-CXgjO9t4.mjs";
3
3
  import { r as createTerminalUI } from "./terminal-ui-Cqz4LVL7-B0mcVdLy.mjs";
4
- import { _ as resolveMigrationPaths, b as setCommandExamples, f as maskConnectionUrl, g as resolveContractPath, m as parseGlobalFlagsOrExit, n as closeQuietly, s as formatStyledHeader, t as addGlobalOptions, u as handleResult, y as setCommandDescriptions } from "./command-helpers-CwLvFwMB-BWwUQhlT.mjs";
4
+ import { _ as resolveMigrationPaths, b as setCommandExamples, f as maskConnectionUrl, g as resolveContractPath, m as parseGlobalFlagsOrExit, n as closeQuietly, s as formatStyledHeader, t as addGlobalOptions, u as handleResult, y as setCommandDescriptions } from "./command-helpers-BCgwcqTe-lNCtppzM.mjs";
5
5
  import { t as createProgressAdapter } from "./progress-adapter-CjAeTxY_-BXYSd1eY.mjs";
6
- import { t as createControlClient } from "./client-DU9qtBxW-BjVHiKzE.mjs";
7
- import { t as resolveContractRefToSnapshot } from "./contract-snapshot-resolution-DvZvbNcZ-DHFCWe_k.mjs";
6
+ import { t as createControlClient } from "./client-C6Qp5ujC-Dxb7r79B.mjs";
7
+ import { t as resolveContractRefToSnapshot } from "./contract-snapshot-resolution-De2VvOJn-DqIAV9cr.mjs";
8
8
  import { a as formatSignJson, i as formatSchemaVerifyOutput, o as formatSignOutput, r as formatSchemaVerifyJson } from "./verify-Cogr_Fj9-D3lCWA6t.mjs";
9
9
  import { relative, resolve } from "pathe";
10
10
  import { isStructuredError } from "@prisma/orm-framework/utils/structured-error";
11
11
  import { readFile } from "node:fs/promises";
12
12
  import { notOk, ok } from "@prisma/orm-framework/utils/result";
13
13
  import { Command } from "commander";
14
- //#region ../../../1-framework/3-tooling/cli/dist/db-sign-DbAxRcZh.mjs
14
+ //#region ../../../1-framework/3-tooling/cli/dist/db-sign-DCp4c8CA.mjs
15
15
  /**
16
16
  * Executes the db sign command and returns a structured Result.
17
17
  * Success: SignDatabaseResult (sign happened)
@@ -169,4 +169,4 @@ function createDbSignCommand() {
169
169
  //#endregion
170
170
  export { createDbSignCommand as t };
171
171
 
172
- //# sourceMappingURL=db-sign-DbAxRcZh-C-nT9kcG.mjs.map
172
+ //# sourceMappingURL=db-sign-DCp4c8CA-B3tun-kh.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"db-sign-DbAxRcZh-C-nT9kcG.mjs","names":["CliStructuredError"],"sources":["../../../../1-framework/3-tooling/cli/dist/db-sign-DbAxRcZh.mjs"],"sourcesContent":["import { N as errorUnexpected, c as errorDatabaseConnectionRequired, d as errorFileNotFound, s as errorContractValidationFailed, t as CliStructuredError, u as errorDriverRequired } from \"./cli-errors-BG6bItjG.mjs\";\nimport { t as createTerminalUI } from \"./terminal-ui-Cqz4LVL7.mjs\";\nimport { S as formatStyledHeader, _ as parseGlobalFlagsOrExit, a as maskConnectionUrl, c as resolveMigrationPaths, d as setCommandExamples, n as closeQuietly, s as resolveContractPath, t as addGlobalOptions, u as setCommandDescriptions, v as handleResult } from \"./command-helpers-CwLvFwMB.mjs\";\nimport { t as createProgressAdapter } from \"./progress-adapter-CjAeTxY_.mjs\";\nimport { t as createControlClient } from \"./client-DU9qtBxW.mjs\";\nimport { a as formatSignJson, i as formatSchemaVerifyOutput, o as formatSignOutput, r as formatSchemaVerifyJson } from \"./verify-Cogr_Fj9.mjs\";\nimport { t as resolveContractRefToSnapshot } from \"./contract-snapshot-resolution-DvZvbNcZ.mjs\";\nimport { Command } from \"commander\";\nimport { loadConfigForSections } from \"@internal/config-loader\";\nimport { notOk, ok } from \"@internal/utils/result\";\nimport { relative, resolve } from \"pathe\";\nimport { readFile } from \"node:fs/promises\";\nimport { isStructuredError } from \"@internal/utils/structured-error\";\n//#region src/commands/db-sign.ts\n/**\n* Executes the db sign command and returns a structured Result.\n* Success: SignDatabaseResult (sign happened)\n* Failure: CliStructuredError (infra error) or VerifyDatabaseSchemaResult (schema mismatch)\n*/\nasync function executeDbSignCommand(contractArg, options, flags, ui) {\n\tconst configResult = await loadConfigForSections(options.config, [\n\t\t\"family\",\n\t\t\"target\",\n\t\t\"adapter\",\n\t\t\"driver\",\n\t\t\"extensions\",\n\t\t\"db\",\n\t\t\"migrations\",\n\t\t\"contract\"\n\t]);\n\tif (!configResult.ok) return configResult;\n\tconst config = configResult.value;\n\tconst configPath = options.config ? relative(process.cwd(), resolve(options.config)) : \"prisma-next.config.ts\";\n\tconst contractPathAbsolute = resolveContractPath(config);\n\tconst contractPath = relative(process.cwd(), contractPathAbsolute);\n\tconst effectiveContractArg = contractArg ?? options.contract;\n\tif (!flags.json && !flags.quiet) {\n\t\tconst details = [{\n\t\t\tlabel: \"config\",\n\t\t\tvalue: configPath\n\t\t}, {\n\t\t\tlabel: \"contract\",\n\t\t\tvalue: effectiveContractArg ?? contractPath\n\t\t}];\n\t\tif (options.db) details.push({\n\t\t\tlabel: \"database\",\n\t\t\tvalue: maskConnectionUrl(options.db)\n\t\t});\n\t\tconst header = formatStyledHeader({\n\t\t\tcommand: \"db sign\",\n\t\t\tdescription: \"Sign the database with your contract so you can safely run queries\",\n\t\t\turl: \"https://pris.ly/db-sign\",\n\t\t\tdetails,\n\t\t\tflags\n\t\t});\n\t\tui.stderr(header);\n\t}\n\tlet contractJson;\n\tif (effectiveContractArg) try {\n\t\tconst { migrationsDir } = resolveMigrationPaths(options.config, config, process.cwd());\n\t\tconst resolved = await resolveContractRefToSnapshot({\n\t\t\tconfig,\n\t\t\tmigrationsDir,\n\t\t\trefInput: effectiveContractArg,\n\t\t\tcontractPathAbsolute,\n\t\t\tfallbackToEmitted: true\n\t\t});\n\t\tif (!resolved.ok) return notOk(resolved.failure);\n\t\tcontractJson = resolved.value.contractJson;\n\t} catch (error) {\n\t\tif (error instanceof CliStructuredError) return notOk(error);\n\t\treturn notOk(errorUnexpected(error instanceof Error ? error.message : String(error), { why: `Failed to resolve contract reference: ${error instanceof Error ? error.message : String(error)}` }));\n\t}\n\telse {\n\t\tlet contractJsonContent;\n\t\ttry {\n\t\t\tcontractJsonContent = await readFile(contractPathAbsolute, \"utf-8\");\n\t\t} catch (error) {\n\t\t\tif (error instanceof Error && error.code === \"ENOENT\") return notOk(errorFileNotFound(contractPathAbsolute, {\n\t\t\t\twhy: `Contract file not found at ${contractPathAbsolute}`,\n\t\t\t\tfix: `Run \\`prisma-next contract emit\\` to generate ${contractPath}, or update \\`config.contract.output\\` in ${configPath}`\n\t\t\t}));\n\t\t\treturn notOk(errorUnexpected(error instanceof Error ? error.message : String(error), { why: `Failed to read contract file: ${error instanceof Error ? error.message : String(error)}` }));\n\t\t}\n\t\ttry {\n\t\t\tcontractJson = JSON.parse(contractJsonContent);\n\t\t} catch (error) {\n\t\t\treturn notOk(errorContractValidationFailed(`Contract JSON is invalid: ${error instanceof Error ? error.message : String(error)}`, { where: { path: contractPathAbsolute } }));\n\t\t}\n\t}\n\tconst dbConnection = options.db ?? config.db?.connection;\n\tif (!dbConnection) return notOk(errorDatabaseConnectionRequired({\n\t\twhy: `Database connection is required for db sign (set db.connection in ${configPath}, or pass --db <url>)`,\n\t\tcommandName: \"db sign\"\n\t}));\n\tif (!config.driver) return notOk(errorDriverRequired({ why: \"Config.driver is required for db sign\" }));\n\tconst client = createControlClient({\n\t\tfamily: config.family,\n\t\ttarget: config.target,\n\t\tadapter: config.adapter,\n\t\tdriver: config.driver,\n\t\textensions: config.extensions ?? []\n\t});\n\tconst onProgress = createProgressAdapter({\n\t\tui,\n\t\tflags\n\t});\n\ttry {\n\t\tconst schemaVerifyResult = await client.schemaVerify({\n\t\t\tcontract: contractJson,\n\t\t\tstrict: false,\n\t\t\tconnection: dbConnection,\n\t\t\tonProgress\n\t\t});\n\t\tif (!schemaVerifyResult.ok) return notOk(schemaVerifyResult);\n\t\treturn ok(await client.sign({\n\t\t\tcontract: contractJson,\n\t\t\tcontractPath,\n\t\t\tconfigPath,\n\t\t\tonProgress\n\t\t}));\n\t} catch (error) {\n\t\tif (error instanceof CliStructuredError) return notOk(error);\n\t\tif (isStructuredError(error) && error.code === \"CONTRACT.VALIDATION_FAILED\") return notOk(errorContractValidationFailed(`Contract validation failed: ${error.message}`, { where: { path: contractPathAbsolute } }));\n\t\treturn notOk(errorUnexpected(error instanceof Error ? error.message : String(error), { why: `Unexpected error during db sign: ${error instanceof Error ? error.message : String(error)}` }));\n\t} finally {\n\t\tawait closeQuietly(client);\n\t}\n}\nfunction createDbSignCommand() {\n\tconst command = new Command(\"sign\");\n\tsetCommandDescriptions(command, \"Sign the database with your contract so you can safely run queries\", \"Verifies that your database schema satisfies the emitted contract, and if so, writes or\\nupdates the database signature. This command is idempotent and safe to run\\nin CI/deployment pipelines. The signature records that this database instance is aligned\\nwith a specific contract version.\");\n\tsetCommandExamples(command, [\n\t\t\"prisma-next db sign --db $DATABASE_URL\",\n\t\t\"prisma-next db sign production --db $DATABASE_URL\",\n\t\t\"prisma-next db sign --contract production --db $DATABASE_URL\"\n\t]);\n\taddGlobalOptions(command).argument(\"[contract]\", \"Contract reference (hash, prefix, ref name, or migration dir name)\").option(\"--db <url>\", \"Database connection string\").option(\"--config <path>\", \"Path to prisma-next.config.ts\").option(\"--contract <contract>\", \"Contract reference (hash, prefix, ref name, migration dir name, <dir>^, or ./path)\").action(async (positionalContract, options) => {\n\t\tconst flags = parseGlobalFlagsOrExit(options);\n\t\tif (positionalContract && options.contract) {\n\t\t\tprocess.stderr.write(\"Cannot specify both a positional contract argument and --contract flag.\\n\");\n\t\t\tprocess.exit(2);\n\t\t\treturn;\n\t\t}\n\t\tconst ui = createTerminalUI(flags);\n\t\tconst result = await executeDbSignCommand(positionalContract, options, flags, ui);\n\t\tif (result.ok) {\n\t\t\tif (flags.json) ui.output(formatSignJson(result.value));\n\t\t\telse {\n\t\t\t\tconst output = formatSignOutput(result.value, flags);\n\t\t\t\tif (output) ui.log(output);\n\t\t\t}\n\t\t\tprocess.exit(0);\n\t\t}\n\t\tconst failure = result.failure;\n\t\tif (failure instanceof CliStructuredError) {\n\t\t\tconst exitCode = handleResult(result, flags, ui);\n\t\t\tprocess.exit(exitCode);\n\t\t}\n\t\tif (flags.json) ui.output(formatSchemaVerifyJson(failure));\n\t\telse {\n\t\t\tconst output = formatSchemaVerifyOutput(failure, flags);\n\t\t\tif (output) ui.log(output);\n\t\t}\n\t\tprocess.exit(1);\n\t});\n\treturn command;\n}\n//#endregion\nexport { createDbSignCommand as t };\n\n//# sourceMappingURL=db-sign-DbAxRcZh.mjs.map"],"mappings":";;;;;;;;;;;;;;;;;;;AAmBA,eAAe,qBAAqB,aAAa,SAAS,OAAO,IAAI;CACpE,MAAM,eAAe,MAAM,sBAAsB,QAAQ,QAAQ;EAChE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACD,CAAC;CACD,IAAI,CAAC,aAAa,IAAI,OAAO;CAC7B,MAAM,SAAS,aAAa;CAC5B,MAAM,aAAa,QAAQ,SAAS,SAAS,QAAQ,IAAI,GAAG,QAAQ,QAAQ,MAAM,CAAC,IAAI;CACvF,MAAM,uBAAuB,oBAAoB,MAAM;CACvD,MAAM,eAAe,SAAS,QAAQ,IAAI,GAAG,oBAAoB;CACjE,MAAM,uBAAuB,eAAe,QAAQ;CACpD,IAAI,CAAC,MAAM,QAAQ,CAAC,MAAM,OAAO;EAChC,MAAM,UAAU,CAAC;GAChB,OAAO;GACP,OAAO;EACR,GAAG;GACF,OAAO;GACP,OAAO,wBAAwB;EAChC,CAAC;EACD,IAAI,QAAQ,IAAI,QAAQ,KAAK;GAC5B,OAAO;GACP,OAAO,kBAAkB,QAAQ,EAAE;EACpC,CAAC;EACD,MAAM,SAAS,mBAAmB;GACjC,SAAS;GACT,aAAa;GACb,KAAK;GACL;GACA;EACD,CAAC;EACD,GAAG,OAAO,MAAM;CACjB;CACA,IAAI;CACJ,IAAI,sBAAsB,IAAI;EAC7B,MAAM,EAAE,kBAAkB,sBAAsB,QAAQ,QAAQ,QAAQ,QAAQ,IAAI,CAAC;EACrF,MAAM,WAAW,MAAM,6BAA6B;GACnD;GACA;GACA,UAAU;GACV;GACA,mBAAmB;EACpB,CAAC;EACD,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AAS,MAAM,qBAAqB,oBAAoB,SAAS,OAAO,EAAE;EAChF,IAAI,OAAO,IAAI;GACd,IAAI,MAAM,MAAM,GAAG,OAAO,eAAe,OAAO,KAAK,CAAC;QACjD;IACJ,MAAM,SAAS,iBAAiB,OAAO,OAAO,KAAK;IACnD,IAAI,QAAQ,GAAG,IAAI,MAAM;GAC1B;GACA,QAAQ,KAAK,CAAC;EACf;EACA,MAAM,UAAU,OAAO;EACvB,IAAI,mBAAmBA,sBAAoB;GAC1C,MAAM,WAAW,aAAa,QAAQ,OAAO,EAAE;GAC/C,QAAQ,KAAK,QAAQ;EACtB;EACA,IAAI,MAAM,MAAM,GAAG,OAAO,uBAAuB,OAAO,CAAC;OACpD;GACJ,MAAM,SAAS,yBAAyB,SAAS,KAAK;GACtD,IAAI,QAAQ,GAAG,IAAI,MAAM;EAC1B;EACA,QAAQ,KAAK,CAAC;CACf,CAAC;CACD,OAAO;AACR"}
1
+ {"version":3,"file":"db-sign-DCp4c8CA-B3tun-kh.mjs","names":["CliStructuredError"],"sources":["../../../../1-framework/3-tooling/cli/dist/db-sign-DCp4c8CA.mjs"],"sourcesContent":["import { P as errorUnexpected, c as errorContractValidationFailed, d as errorDriverRequired, f as errorFileNotFound, l as errorDatabaseConnectionRequired, t as CliStructuredError } from \"./cli-errors-B4zTLaqQ.mjs\";\nimport { t as createTerminalUI } from \"./terminal-ui-Cqz4LVL7.mjs\";\nimport { S as formatStyledHeader, _ as parseGlobalFlagsOrExit, a as maskConnectionUrl, c as resolveMigrationPaths, d as setCommandExamples, n as closeQuietly, s as resolveContractPath, t as addGlobalOptions, u as setCommandDescriptions, v as handleResult } from \"./command-helpers-BCgwcqTe.mjs\";\nimport { t as createProgressAdapter } from \"./progress-adapter-CjAeTxY_.mjs\";\nimport { t as createControlClient } from \"./client-C6Qp5ujC.mjs\";\nimport { a as formatSignJson, i as formatSchemaVerifyOutput, o as formatSignOutput, r as formatSchemaVerifyJson } from \"./verify-Cogr_Fj9.mjs\";\nimport { t as resolveContractRefToSnapshot } from \"./contract-snapshot-resolution-De2VvOJn.mjs\";\nimport { Command } from \"commander\";\nimport { loadConfigForSections } from \"@internal/config-loader\";\nimport { notOk, ok } from \"@internal/utils/result\";\nimport { relative, resolve } from \"pathe\";\nimport { readFile } from \"node:fs/promises\";\nimport { isStructuredError } from \"@internal/utils/structured-error\";\n//#region src/commands/db-sign.ts\n/**\n* Executes the db sign command and returns a structured Result.\n* Success: SignDatabaseResult (sign happened)\n* Failure: CliStructuredError (infra error) or VerifyDatabaseSchemaResult (schema mismatch)\n*/\nasync function executeDbSignCommand(contractArg, options, flags, ui) {\n\tconst configResult = await loadConfigForSections(options.config, [\n\t\t\"family\",\n\t\t\"target\",\n\t\t\"adapter\",\n\t\t\"driver\",\n\t\t\"extensions\",\n\t\t\"db\",\n\t\t\"migrations\",\n\t\t\"contract\"\n\t]);\n\tif (!configResult.ok) return configResult;\n\tconst config = configResult.value;\n\tconst configPath = options.config ? relative(process.cwd(), resolve(options.config)) : \"prisma-next.config.ts\";\n\tconst contractPathAbsolute = resolveContractPath(config);\n\tconst contractPath = relative(process.cwd(), contractPathAbsolute);\n\tconst effectiveContractArg = contractArg ?? options.contract;\n\tif (!flags.json && !flags.quiet) {\n\t\tconst details = [{\n\t\t\tlabel: \"config\",\n\t\t\tvalue: configPath\n\t\t}, {\n\t\t\tlabel: \"contract\",\n\t\t\tvalue: effectiveContractArg ?? contractPath\n\t\t}];\n\t\tif (options.db) details.push({\n\t\t\tlabel: \"database\",\n\t\t\tvalue: maskConnectionUrl(options.db)\n\t\t});\n\t\tconst header = formatStyledHeader({\n\t\t\tcommand: \"db sign\",\n\t\t\tdescription: \"Sign the database with your contract so you can safely run queries\",\n\t\t\turl: \"https://pris.ly/db-sign\",\n\t\t\tdetails,\n\t\t\tflags\n\t\t});\n\t\tui.stderr(header);\n\t}\n\tlet contractJson;\n\tif (effectiveContractArg) try {\n\t\tconst { migrationsDir } = resolveMigrationPaths(options.config, config, process.cwd());\n\t\tconst resolved = await resolveContractRefToSnapshot({\n\t\t\tconfig,\n\t\t\tmigrationsDir,\n\t\t\trefInput: effectiveContractArg,\n\t\t\tcontractPathAbsolute,\n\t\t\tfallbackToEmitted: true\n\t\t});\n\t\tif (!resolved.ok) return notOk(resolved.failure);\n\t\tcontractJson = resolved.value.contractJson;\n\t} catch (error) {\n\t\tif (error instanceof CliStructuredError) return notOk(error);\n\t\treturn notOk(errorUnexpected(error instanceof Error ? error.message : String(error), { why: `Failed to resolve contract reference: ${error instanceof Error ? error.message : String(error)}` }));\n\t}\n\telse {\n\t\tlet contractJsonContent;\n\t\ttry {\n\t\t\tcontractJsonContent = await readFile(contractPathAbsolute, \"utf-8\");\n\t\t} catch (error) {\n\t\t\tif (error instanceof Error && error.code === \"ENOENT\") return notOk(errorFileNotFound(contractPathAbsolute, {\n\t\t\t\twhy: `Contract file not found at ${contractPathAbsolute}`,\n\t\t\t\tfix: `Run \\`prisma-next contract emit\\` to generate ${contractPath}, or update \\`config.contract.output\\` in ${configPath}`\n\t\t\t}));\n\t\t\treturn notOk(errorUnexpected(error instanceof Error ? error.message : String(error), { why: `Failed to read contract file: ${error instanceof Error ? error.message : String(error)}` }));\n\t\t}\n\t\ttry {\n\t\t\tcontractJson = JSON.parse(contractJsonContent);\n\t\t} catch (error) {\n\t\t\treturn notOk(errorContractValidationFailed(`Contract JSON is invalid: ${error instanceof Error ? error.message : String(error)}`, { where: { path: contractPathAbsolute } }));\n\t\t}\n\t}\n\tconst dbConnection = options.db ?? config.db?.connection;\n\tif (!dbConnection) return notOk(errorDatabaseConnectionRequired({\n\t\twhy: `Database connection is required for db sign (set db.connection in ${configPath}, or pass --db <url>)`,\n\t\tcommandName: \"db sign\"\n\t}));\n\tif (!config.driver) return notOk(errorDriverRequired({ why: \"Config.driver is required for db sign\" }));\n\tconst client = createControlClient({\n\t\tfamily: config.family,\n\t\ttarget: config.target,\n\t\tadapter: config.adapter,\n\t\tdriver: config.driver,\n\t\textensions: config.extensions ?? []\n\t});\n\tconst onProgress = createProgressAdapter({\n\t\tui,\n\t\tflags\n\t});\n\ttry {\n\t\tconst schemaVerifyResult = await client.schemaVerify({\n\t\t\tcontract: contractJson,\n\t\t\tstrict: false,\n\t\t\tconnection: dbConnection,\n\t\t\tonProgress\n\t\t});\n\t\tif (!schemaVerifyResult.ok) return notOk(schemaVerifyResult);\n\t\treturn ok(await client.sign({\n\t\t\tcontract: contractJson,\n\t\t\tcontractPath,\n\t\t\tconfigPath,\n\t\t\tonProgress\n\t\t}));\n\t} catch (error) {\n\t\tif (error instanceof CliStructuredError) return notOk(error);\n\t\tif (isStructuredError(error) && error.code === \"CONTRACT.VALIDATION_FAILED\") return notOk(errorContractValidationFailed(`Contract validation failed: ${error.message}`, { where: { path: contractPathAbsolute } }));\n\t\treturn notOk(errorUnexpected(error instanceof Error ? error.message : String(error), { why: `Unexpected error during db sign: ${error instanceof Error ? error.message : String(error)}` }));\n\t} finally {\n\t\tawait closeQuietly(client);\n\t}\n}\nfunction createDbSignCommand() {\n\tconst command = new Command(\"sign\");\n\tsetCommandDescriptions(command, \"Sign the database with your contract so you can safely run queries\", \"Verifies that your database schema satisfies the emitted contract, and if so, writes or\\nupdates the database signature. This command is idempotent and safe to run\\nin CI/deployment pipelines. The signature records that this database instance is aligned\\nwith a specific contract version.\");\n\tsetCommandExamples(command, [\n\t\t\"prisma-next db sign --db $DATABASE_URL\",\n\t\t\"prisma-next db sign production --db $DATABASE_URL\",\n\t\t\"prisma-next db sign --contract production --db $DATABASE_URL\"\n\t]);\n\taddGlobalOptions(command).argument(\"[contract]\", \"Contract reference (hash, prefix, ref name, or migration dir name)\").option(\"--db <url>\", \"Database connection string\").option(\"--config <path>\", \"Path to prisma-next.config.ts\").option(\"--contract <contract>\", \"Contract reference (hash, prefix, ref name, migration dir name, <dir>^, or ./path)\").action(async (positionalContract, options) => {\n\t\tconst flags = parseGlobalFlagsOrExit(options);\n\t\tif (positionalContract && options.contract) {\n\t\t\tprocess.stderr.write(\"Cannot specify both a positional contract argument and --contract flag.\\n\");\n\t\t\tprocess.exit(2);\n\t\t\treturn;\n\t\t}\n\t\tconst ui = createTerminalUI(flags);\n\t\tconst result = await executeDbSignCommand(positionalContract, options, flags, ui);\n\t\tif (result.ok) {\n\t\t\tif (flags.json) ui.output(formatSignJson(result.value));\n\t\t\telse {\n\t\t\t\tconst output = formatSignOutput(result.value, flags);\n\t\t\t\tif (output) ui.log(output);\n\t\t\t}\n\t\t\tprocess.exit(0);\n\t\t}\n\t\tconst failure = result.failure;\n\t\tif (failure instanceof CliStructuredError) {\n\t\t\tconst exitCode = handleResult(result, flags, ui);\n\t\t\tprocess.exit(exitCode);\n\t\t}\n\t\tif (flags.json) ui.output(formatSchemaVerifyJson(failure));\n\t\telse {\n\t\t\tconst output = formatSchemaVerifyOutput(failure, flags);\n\t\t\tif (output) ui.log(output);\n\t\t}\n\t\tprocess.exit(1);\n\t});\n\treturn command;\n}\n//#endregion\nexport { createDbSignCommand as t };\n\n//# sourceMappingURL=db-sign-DCp4c8CA.mjs.map"],"mappings":";;;;;;;;;;;;;;;;;;;AAmBA,eAAe,qBAAqB,aAAa,SAAS,OAAO,IAAI;CACpE,MAAM,eAAe,MAAM,sBAAsB,QAAQ,QAAQ;EAChE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACD,CAAC;CACD,IAAI,CAAC,aAAa,IAAI,OAAO;CAC7B,MAAM,SAAS,aAAa;CAC5B,MAAM,aAAa,QAAQ,SAAS,SAAS,QAAQ,IAAI,GAAG,QAAQ,QAAQ,MAAM,CAAC,IAAI;CACvF,MAAM,uBAAuB,oBAAoB,MAAM;CACvD,MAAM,eAAe,SAAS,QAAQ,IAAI,GAAG,oBAAoB;CACjE,MAAM,uBAAuB,eAAe,QAAQ;CACpD,IAAI,CAAC,MAAM,QAAQ,CAAC,MAAM,OAAO;EAChC,MAAM,UAAU,CAAC;GAChB,OAAO;GACP,OAAO;EACR,GAAG;GACF,OAAO;GACP,OAAO,wBAAwB;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,mBAAmB,SAAS;EAC3B;EACA;EACA;CACD,CAAC;CACD,iBAAiB,OAAO,CAAC,CAAC,SAAS,cAAc,oEAAoE,CAAC,CAAC,OAAO,cAAc,4BAA4B,CAAC,CAAC,OAAO,mBAAmB,+BAA+B,CAAC,CAAC,OAAO,yBAAyB,oFAAoF,CAAC,CAAC,OAAO,OAAO,oBAAoB,YAAY;EACxY,MAAM,QAAQ,uBAAuB,OAAO;EAC5C,IAAI,sBAAsB,QAAQ,UAAU;GAC3C,QAAQ,OAAO,MAAM,2EAA2E;GAChG,QAAQ,KAAK,CAAC;GACd;EACD;EACA,MAAM,KAAK,iBAAiB,KAAK;EACjC,MAAM,SAAS,MAAM,qBAAqB,oBAAoB,SAAS,OAAO,EAAE;EAChF,IAAI,OAAO,IAAI;GACd,IAAI,MAAM,MAAM,GAAG,OAAO,eAAe,OAAO,KAAK,CAAC;QACjD;IACJ,MAAM,SAAS,iBAAiB,OAAO,OAAO,KAAK;IACnD,IAAI,QAAQ,GAAG,IAAI,MAAM;GAC1B;GACA,QAAQ,KAAK,CAAC;EACf;EACA,MAAM,UAAU,OAAO;EACvB,IAAI,mBAAmBA,sBAAoB;GAC1C,MAAM,WAAW,aAAa,QAAQ,OAAO,EAAE;GAC/C,QAAQ,KAAK,QAAQ;EACtB;EACA,IAAI,MAAM,MAAM,GAAG,OAAO,uBAAuB,OAAO,CAAC;OACpD;GACJ,MAAM,SAAS,yBAAyB,SAAS,KAAK;GACtD,IAAI,QAAQ,GAAG,IAAI,MAAM;EAC1B;EACA,QAAQ,KAAK,CAAC;CACf,CAAC;CACD,OAAO;AACR"}
@@ -1,15 +1,15 @@
1
- import { O as errorRunnerFailed, P as errorUnexpected, b as errorMigrationPlanningFailed, c as errorContractValidationFailed, n as ERROR_CODE_DESTRUCTIVE_CHANGES, o as errorConsentPlanMismatch, t as CliStructuredError$1, u as errorDestructiveChanges } from "./cli-errors-BG6bItjG-DwdKIeGz.mjs";
1
+ import { F as errorUnexpected, d as errorDestructiveChanges, k as errorRunnerFailed, l as errorContractValidationFailed, n as ERROR_CODE_DESTRUCTIVE_CHANGES, o as errorConsentPlanMismatch, t as CliStructuredError$1, x as errorMigrationPlanningFailed } from "./cli-errors-B4zTLaqQ-CXgjO9t4.mjs";
2
2
  import { c as formatMigrationApplyOutput, l as formatMigrationJson, r as createTerminalUI, u as formatMigrationPlanOutput } from "./terminal-ui-Cqz4LVL7-B0mcVdLy.mjs";
3
- import { _ as resolveMigrationPaths, b as setCommandExamples, m as parseGlobalFlagsOrExit, n as closeQuietly, u as handleResult, v as sanitizeErrorMessage, y as setCommandDescriptions } from "./command-helpers-CwLvFwMB-BWwUQhlT.mjs";
3
+ import { _ as resolveMigrationPaths, b as setCommandExamples, m as parseGlobalFlagsOrExit, n as closeQuietly, u as handleResult, v as sanitizeErrorMessage, y as setCommandDescriptions } from "./command-helpers-BCgwcqTe-lNCtppzM.mjs";
4
4
  import { o as resolveRefAdvancementFields } from "./ref-advancement-DaZBzm7m-WoqnFAyr.mjs";
5
- import { t as resolveContractRefToSnapshot } from "./contract-snapshot-resolution-DvZvbNcZ-DHFCWe_k.mjs";
6
- import { n as prepareMigrationContext, t as addMigrationCommandOptions } from "./migration-command-scaffold-B1BiWKLI-Bskk5UKX.mjs";
5
+ import { t as resolveContractRefToSnapshot } from "./contract-snapshot-resolution-De2VvOJn-DqIAV9cr.mjs";
6
+ import { n as prepareMigrationContext, t as addMigrationCommandOptions } from "./migration-command-scaffold-SzjR2naH-Yi3-rNfX.mjs";
7
7
  import { ifDefined } from "@prisma/orm-framework/utils/defined";
8
8
  import { isStructuredError } from "@prisma/orm-framework/utils/structured-error";
9
9
  import { assertNever } from "@prisma/orm-framework/utils/internal-error";
10
10
  import { notOk, ok } from "@prisma/orm-framework/utils/result";
11
11
  import { Command } from "commander";
12
- //#region ../../../1-framework/3-tooling/cli/dist/db-update-J59yROwL.mjs
12
+ //#region ../../../1-framework/3-tooling/cli/dist/db-update-CfayE8WE.mjs
13
13
  /**
14
14
  * Maps a DbUpdateFailure to a CliStructuredError for consistent error handling.
15
15
  */
@@ -168,4 +168,4 @@ function createDbUpdateCommand() {
168
168
  //#endregion
169
169
  export { createDbUpdateCommand as t };
170
170
 
171
- //# sourceMappingURL=db-update-J59yROwL-DCP-_z2W.mjs.map
171
+ //# sourceMappingURL=db-update-CfayE8WE-CPhQyDaZ.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"db-update-J59yROwL-DCP-_z2W.mjs","names":["CliStructuredError"],"sources":["../../../../1-framework/3-tooling/cli/dist/db-update-J59yROwL.mjs"],"sourcesContent":["import { D as errorRunnerFailed, N as errorUnexpected, a as errorConsentPlanMismatch, l as errorDestructiveChanges, n as ERROR_CODE_DESTRUCTIVE_CHANGES, s as errorContractValidationFailed, t as CliStructuredError, y as errorMigrationPlanningFailed } from \"./cli-errors-BG6bItjG.mjs\";\nimport { c as formatMigrationPlanOutput, o as formatMigrationApplyOutput, s as formatMigrationJson, t as createTerminalUI } from \"./terminal-ui-Cqz4LVL7.mjs\";\nimport { _ as parseGlobalFlagsOrExit, c as resolveMigrationPaths, d as setCommandExamples, l as sanitizeErrorMessage, n as closeQuietly, u as setCommandDescriptions, v as handleResult } from \"./command-helpers-CwLvFwMB.mjs\";\nimport { o as resolveRefAdvancementFields } from \"./ref-advancement-DaZBzm7m.mjs\";\nimport { n as prepareMigrationContext, t as addMigrationCommandOptions } from \"./migration-command-scaffold-B1BiWKLI.mjs\";\nimport { t as resolveContractRefToSnapshot } from \"./contract-snapshot-resolution-DvZvbNcZ.mjs\";\nimport { Command } from \"commander\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { notOk, ok } from \"@internal/utils/result\";\nimport { assertNever } from \"@internal/utils/internal-error\";\nimport { isStructuredError } from \"@internal/utils/structured-error\";\n//#region src/commands/db-update.ts\n/**\n* Maps a DbUpdateFailure to a CliStructuredError for consistent error handling.\n*/\nfunction mapDbUpdateFailure(failure) {\n\tif (failure.code === \"PLANNING_FAILED\") return errorMigrationPlanningFailed({ conflicts: failure.conflicts ?? [] });\n\tif (failure.code === \"RUNNER_FAILED\") {\n\t\tconst fix = (typeof failure.meta?.[\"runnerErrorCode\"] === \"string\" ? failure.meta[\"runnerErrorCode\"] : void 0) === \"MIGRATION.LEGACY_MARKER_SHAPE\" ? \"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.\" : \"Inspect the reported conflict, reconcile schema drift if needed, then re-run `prisma-next db update`\";\n\t\treturn errorRunnerFailed(failure.summary, {\n\t\t\twhy: failure.why ?? \"Migration runner failed\",\n\t\t\tfix,\n\t\t\tmeta: {\n\t\t\t\t...failure.meta,\n\t\t\t\t...failure.warnings && failure.warnings.length > 0 ? { plannerWarnings: failure.warnings } : {}\n\t\t\t},\n\t\t\t...ifDefined(\"cause\", failure.cause)\n\t\t});\n\t}\n\tif (failure.code === \"DESTRUCTIVE_CHANGES\") return errorDestructiveChanges(failure.summary, {\n\t\t...ifDefined(\"why\", failure.why),\n\t\tfix: \"Re-run with `-y` to apply destructive changes, or use `--dry-run` to preview first\",\n\t\t...failure.destructiveChanges ? { meta: {\n\t\t\tdestructiveOperations: failure.destructiveChanges.destructiveOperations,\n\t\t\tdatabaseName: failure.destructiveChanges.databaseName,\n\t\t\tplanHash: failure.destructiveChanges.planHash\n\t\t} } : {}\n\t});\n\tif (failure.code === \"CONSENT_PLAN_MISMATCH\") return errorConsentPlanMismatch({\n\t\tconsentedPlanHash: failure.consentPlanMismatch?.consentedPlanHash ?? \"\",\n\t\tplanHash: failure.consentPlanMismatch?.planHash ?? \"\",\n\t\t...ifDefined(\"why\", failure.why)\n\t});\n\tconst exhaustive = failure.code;\n\treturn assertNever(exhaustive, `Unhandled DbUpdateFailure code: ${String(exhaustive)}`);\n}\n/**\n* Executes the db update command and returns a structured Result.\n*/\nasync function executeDbUpdateCommand(options, flags, ui, startTime) {\n\tconst ctxResult = await prepareMigrationContext(options, flags, ui, {\n\t\tcommandName: \"db update\",\n\t\tdescription: \"Update your database schema to match your contract\",\n\t\turl: \"https://pris.ly/db-update\"\n\t});\n\tif (!ctxResult.ok) return ctxResult;\n\tconst { client, config, dbConnection, onProgress, contractPathAbsolute } = ctxResult.value;\n\tlet { contractJson } = ctxResult.value;\n\tlet contractJsonPathForSnapshot = contractPathAbsolute;\n\tconst { migrationsDir, refsDir } = resolveMigrationPaths(options.config, config, process.cwd());\n\tif (options.to) {\n\t\tconst resolved = await resolveContractRefToSnapshot({\n\t\t\tconfig,\n\t\t\tmigrationsDir,\n\t\t\trefInput: options.to,\n\t\t\tcontractPathAbsolute,\n\t\t\tfallbackToEmitted: false,\n\t\t\tmissingBundleFlag: \"--to\"\n\t\t});\n\t\tif (!resolved.ok) return notOk(resolved.failure);\n\t\tcontractJson = resolved.value.contractJson;\n\t\tcontractJsonPathForSnapshot = resolved.value.contractJsonPath;\n\t}\n\ttry {\n\t\tawait client.connect(dbConnection);\n\t\tconst result = await client.dbUpdate({\n\t\t\tcontract: contractJson,\n\t\t\tmode: options.dryRun ? \"plan\" : \"apply\",\n\t\t\tmigrationsDir,\n\t\t\t...flags.yes ? { acceptDataLoss: true } : {},\n\t\t\tonProgress\n\t\t});\n\t\tif (!result.ok) return notOk(mapDbUpdateFailure(result.failure));\n\t\tconst advancementHash = result.value.mode === \"apply\" ? result.value.marker?.storageHash ?? result.value.destination.storageHash : result.value.destination.storageHash;\n\t\tconst advancement = await resolveRefAdvancementFields({\n\t\t\t...ifDefined(\"advanceRef\", options.advanceRef),\n\t\t\t...ifDefined(\"db\", options.db),\n\t\t\trefsDir,\n\t\t\tmigrationsDir,\n\t\t\tcontractJson,\n\t\t\tcontractJsonPath: contractJsonPathForSnapshot,\n\t\t\tmode: result.value.mode,\n\t\t\thash: advancementHash\n\t\t});\n\t\tif (!advancement.ok) return notOk(advancement.failure);\n\t\tconst refAdvancementFields = advancement.value;\n\t\treturn ok({\n\t\t\tok: true,\n\t\t\tmode: result.value.mode,\n\t\t\tplan: {\n\t\t\t\ttargetId: ctxResult.value.config.target.targetId,\n\t\t\t\tdestination: {\n\t\t\t\t\tstorageHash: result.value.destination.storageHash,\n\t\t\t\t\t...ifDefined(\"profileHash\", result.value.destination.profileHash)\n\t\t\t\t},\n\t\t\t\toperations: result.value.plan.operations.map((op) => ({\n\t\t\t\t\tid: op.id,\n\t\t\t\t\tlabel: op.label,\n\t\t\t\t\toperationClass: op.operationClass\n\t\t\t\t})),\n\t\t\t\t...ifDefined(\"preview\", result.value.plan.preview)\n\t\t\t},\n\t\t\t...ifDefined(\"execution\", result.value.execution ? {\n\t\t\t\toperationsPlanned: result.value.execution.operationsPlanned,\n\t\t\t\toperationsExecuted: result.value.execution.operationsExecuted\n\t\t\t} : void 0),\n\t\t\t...ifDefined(\"marker\", result.value.marker ? {\n\t\t\t\tstorageHash: result.value.marker.storageHash,\n\t\t\t\t...ifDefined(\"profileHash\", result.value.marker.profileHash)\n\t\t\t} : void 0),\n\t\t\t...ifDefined(\"perSpace\", result.value.perSpace),\n\t\t\t...ifDefined(\"warnings\", result.value.warnings),\n\t\t\tadvancedRef: refAdvancementFields.advancedRef,\n\t\t\tplannedAdvanceRef: refAdvancementFields.plannedAdvanceRef,\n\t\t\tsummary: result.value.summary,\n\t\t\ttimings: { total: Date.now() - startTime }\n\t\t});\n\t} catch (error) {\n\t\tif (CliStructuredError.is(error)) return notOk(error);\n\t\tif (isStructuredError(error) && error.code === \"CONTRACT.VALIDATION_FAILED\") return notOk(errorContractValidationFailed(`Contract validation failed: ${error.message}`, { where: { path: contractPathAbsolute } }));\n\t\tconst safeMessage = sanitizeErrorMessage(error instanceof Error ? error.message : String(error), typeof dbConnection === \"string\" ? dbConnection : void 0);\n\t\treturn notOk(errorUnexpected(safeMessage, { why: `Unexpected error during db update: ${safeMessage}` }));\n\t} finally {\n\t\tawait closeQuietly(client);\n\t}\n}\nfunction createDbUpdateCommand() {\n\tconst command = new Command(\"update\");\n\tsetCommandDescriptions(command, \"Update your database schema to match your contract\", \"Compares your database schema to the emitted contract and applies the necessary\\nchanges. Works on any database, whether or not it has been initialized with `db init`.\\nDestructive operations prompt for confirmation in interactive mode. Use -y to\\nauto-accept or --dry-run to preview first.\");\n\tsetCommandExamples(command, [\"prisma-next db update --db $DATABASE_URL\", \"prisma-next db update --db $DATABASE_URL --dry-run\"]);\n\taddMigrationCommandOptions(command);\n\tcommand.option(\"--to <contract>\", \"Target contract reference (hash, prefix, ref name, migration dir name, <dir>^, or ./path)\");\n\tcommand.option(\"--advance-ref <name>\", \"Ref to advance to the post-command contract hash\");\n\tcommand.action(async (options) => {\n\t\tconst flags = parseGlobalFlagsOrExit(options);\n\t\tconst startTime = Date.now();\n\t\tconst ui = createTerminalUI(flags);\n\t\tlet result = await executeDbUpdateCommand(options, flags, ui, startTime);\n\t\tif (!result.ok && result.failure.code === ERROR_CODE_DESTRUCTIVE_CHANGES && flags.interactive && !flags.json && !flags.yes) {\n\t\t\tconst destructiveOps = result.failure.meta?.destructiveOperations ?? [];\n\t\t\tif (destructiveOps.length > 0) ui.warn(`${destructiveOps.length} destructive operation(s) that may cause data loss:\\n${destructiveOps.map((op) => ` ${ui.yellow(\"▸\")} ${op.label}`).join(\"\\n\")}`);\n\t\t\tif (await ui.confirm(\"Apply destructive changes? This cannot be undone.\")) result = await executeDbUpdateCommand(options, {\n\t\t\t\t...flags,\n\t\t\t\tyes: true\n\t\t\t}, ui, Date.now());\n\t\t}\n\t\tconst exitCode = handleResult(result, flags, ui, (dbUpdateResult) => {\n\t\t\tif (flags.json) ui.output(formatMigrationJson(dbUpdateResult));\n\t\t\telse {\n\t\t\t\tconst output = dbUpdateResult.mode === \"plan\" ? formatMigrationPlanOutput(dbUpdateResult, flags) : formatMigrationApplyOutput(dbUpdateResult, flags);\n\t\t\t\tif (output) ui.log(output);\n\t\t\t}\n\t\t});\n\t\tprocess.exit(exitCode);\n\t});\n\treturn command;\n}\n//#endregion\nexport { createDbUpdateCommand as t };\n\n//# s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ling/cli/dist/db-update-CfayE8WE.mjs"],"sourcesContent":["import { O as errorRunnerFailed, P as errorUnexpected, a as errorConsentPlanMismatch, b as errorMigrationPlanningFailed, c as errorContractValidationFailed, n as ERROR_CODE_DESTRUCTIVE_CHANGES, t as CliStructuredError, u as errorDestructiveChanges } from \"./cli-errors-B4zTLaqQ.mjs\";\nimport { c as formatMigrationPlanOutput, o as formatMigrationApplyOutput, s as formatMigrationJson, t as createTerminalUI } from \"./terminal-ui-Cqz4LVL7.mjs\";\nimport { _ as parseGlobalFlagsOrExit, c as resolveMigrationPaths, d as setCommandExamples, l as sanitizeErrorMessage, n as closeQuietly, u as setCommandDescriptions, v as handleResult } from \"./command-helpers-BCgwcqTe.mjs\";\nimport { o as resolveRefAdvancementFields } from \"./ref-advancement-DaZBzm7m.mjs\";\nimport { n as prepareMigrationContext, t as addMigrationCommandOptions } from \"./migration-command-scaffold-SzjR2naH.mjs\";\nimport { t as resolveContractRefToSnapshot } from \"./contract-snapshot-resolution-De2VvOJn.mjs\";\nimport { Command } from \"commander\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { notOk, ok } from \"@internal/utils/result\";\nimport { assertNever } from \"@internal/utils/internal-error\";\nimport { isStructuredError } from \"@internal/utils/structured-error\";\n//#region src/commands/db-update.ts\n/**\n* Maps a DbUpdateFailure to a CliStructuredError for consistent error handling.\n*/\nfunction mapDbUpdateFailure(failure) {\n\tif (failure.code === \"PLANNING_FAILED\") return errorMigrationPlanningFailed({ conflicts: failure.conflicts ?? [] });\n\tif (failure.code === \"RUNNER_FAILED\") {\n\t\tconst fix = (typeof failure.meta?.[\"runnerErrorCode\"] === \"string\" ? failure.meta[\"runnerErrorCode\"] : void 0) === \"MIGRATION.LEGACY_MARKER_SHAPE\" ? \"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.\" : \"Inspect the reported conflict, reconcile schema drift if needed, then re-run `prisma-next db update`\";\n\t\treturn errorRunnerFailed(failure.summary, {\n\t\t\twhy: failure.why ?? \"Migration runner failed\",\n\t\t\tfix,\n\t\t\tmeta: {\n\t\t\t\t...failure.meta,\n\t\t\t\t...failure.warnings && failure.warnings.length > 0 ? { plannerWarnings: failure.warnings } : {}\n\t\t\t},\n\t\t\t...ifDefined(\"cause\", failure.cause)\n\t\t});\n\t}\n\tif (failure.code === \"DESTRUCTIVE_CHANGES\") return errorDestructiveChanges(failure.summary, {\n\t\t...ifDefined(\"why\", failure.why),\n\t\tfix: \"Re-run with `-y` to apply destructive changes, or use `--dry-run` to preview first\",\n\t\t...failure.destructiveChanges ? { meta: {\n\t\t\tdestructiveOperations: failure.destructiveChanges.destructiveOperations,\n\t\t\tdatabaseName: failure.destructiveChanges.databaseName,\n\t\t\tplanHash: failure.destructiveChanges.planHash\n\t\t} } : {}\n\t});\n\tif (failure.code === \"CONSENT_PLAN_MISMATCH\") return errorConsentPlanMismatch({\n\t\tconsentedPlanHash: failure.consentPlanMismatch?.consentedPlanHash ?? \"\",\n\t\tplanHash: failure.consentPlanMismatch?.planHash ?? \"\",\n\t\t...ifDefined(\"why\", failure.why)\n\t});\n\tconst exhaustive = failure.code;\n\treturn assertNever(exhaustive, `Unhandled DbUpdateFailure code: ${String(exhaustive)}`);\n}\n/**\n* Executes the db update command and returns a structured Result.\n*/\nasync function executeDbUpdateCommand(options, flags, ui, startTime) {\n\tconst ctxResult = await prepareMigrationContext(options, flags, ui, {\n\t\tcommandName: \"db update\",\n\t\tdescription: \"Update your database schema to match your contract\",\n\t\turl: \"https://pris.ly/db-update\"\n\t});\n\tif (!ctxResult.ok) return ctxResult;\n\tconst { client, config, dbConnection, onProgress, contractPathAbsolute } = ctxResult.value;\n\tlet { contractJson } = ctxResult.value;\n\tlet contractJsonPathForSnapshot = contractPathAbsolute;\n\tconst { migrationsDir, refsDir } = resolveMigrationPaths(options.config, config, process.cwd());\n\tif (options.to) {\n\t\tconst resolved = await resolveContractRefToSnapshot({\n\t\t\tconfig,\n\t\t\tmigrationsDir,\n\t\t\trefInput: options.to,\n\t\t\tcontractPathAbsolute,\n\t\t\tfallbackToEmitted: false,\n\t\t\tmissingBundleFlag: \"--to\"\n\t\t});\n\t\tif (!resolved.ok) return notOk(resolved.failure);\n\t\tcontractJson = resolved.value.contractJson;\n\t\tcontractJsonPathForSnapshot = resolved.value.contractJsonPath;\n\t}\n\ttry {\n\t\tawait client.connect(dbConnection);\n\t\tconst result = await client.dbUpdate({\n\t\t\tcontract: contractJson,\n\t\t\tmode: options.dryRun ? \"plan\" : \"apply\",\n\t\t\tmigrationsDir,\n\t\t\t...flags.yes ? { acceptDataLoss: true } : {},\n\t\t\tonProgress\n\t\t});\n\t\tif (!result.ok) return notOk(mapDbUpdateFailure(result.failure));\n\t\tconst advancementHash = result.value.mode === \"apply\" ? result.value.marker?.storageHash ?? result.value.destination.storageHash : result.value.destination.storageHash;\n\t\tconst advancement = await resolveRefAdvancementFields({\n\t\t\t...ifDefined(\"advanceRef\", options.advanceRef),\n\t\t\t...ifDefined(\"db\", options.db),\n\t\t\trefsDir,\n\t\t\tmigrationsDir,\n\t\t\tcontractJson,\n\t\t\tcontractJsonPath: contractJsonPathForSnapshot,\n\t\t\tmode: result.value.mode,\n\t\t\thash: advancementHash\n\t\t});\n\t\tif (!advancement.ok) return notOk(advancement.failure);\n\t\tconst refAdvancementFields = advancement.value;\n\t\treturn ok({\n\t\t\tok: true,\n\t\t\tmode: result.value.mode,\n\t\t\tplan: {\n\t\t\t\ttargetId: ctxResult.value.config.target.targetId,\n\t\t\t\tdestination: {\n\t\t\t\t\tstorageHash: result.value.destination.storageHash,\n\t\t\t\t\t...ifDefined(\"profileHash\", result.value.destination.profileHash)\n\t\t\t\t},\n\t\t\t\toperations: result.value.plan.operations.map((op) => ({\n\t\t\t\t\tid: op.id,\n\t\t\t\t\tlabel: op.label,\n\t\t\t\t\toperationClass: op.operationClass\n\t\t\t\t})),\n\t\t\t\t...ifDefined(\"preview\", result.value.plan.preview)\n\t\t\t},\n\t\t\t...ifDefined(\"execution\", result.value.execution ? {\n\t\t\t\toperationsPlanned: result.value.execution.operationsPlanned,\n\t\t\t\toperationsExecuted: result.value.execution.operationsExecuted\n\t\t\t} : void 0),\n\t\t\t...ifDefined(\"marker\", result.value.marker ? {\n\t\t\t\tstorageHash: result.value.marker.storageHash,\n\t\t\t\t...ifDefined(\"profileHash\", result.value.marker.profileHash)\n\t\t\t} : void 0),\n\t\t\t...ifDefined(\"perSpace\", result.value.perSpace),\n\t\t\t...ifDefined(\"warnings\", result.value.warnings),\n\t\t\tadvancedRef: refAdvancementFields.advancedRef,\n\t\t\tplannedAdvanceRef: refAdvancementFields.plannedAdvanceRef,\n\t\t\tsummary: result.value.summary,\n\t\t\ttimings: { total: Date.now() - startTime }\n\t\t});\n\t} catch (error) {\n\t\tif (CliStructuredError.is(error)) return notOk(error);\n\t\tif (isStructuredError(error) && error.code === \"CONTRACT.VALIDATION_FAILED\") return notOk(errorContractValidationFailed(`Contract validation failed: ${error.message}`, { where: { path: contractPathAbsolute } }));\n\t\tconst safeMessage = sanitizeErrorMessage(error instanceof Error ? error.message : String(error), typeof dbConnection === \"string\" ? dbConnection : void 0);\n\t\treturn notOk(errorUnexpected(safeMessage, { why: `Unexpected error during db update: ${safeMessage}` }));\n\t} finally {\n\t\tawait closeQuietly(client);\n\t}\n}\nfunction createDbUpdateCommand() {\n\tconst command = new Command(\"update\");\n\tsetCommandDescriptions(command, \"Update your database schema to match your contract\", \"Compares your database schema to the emitted contract and applies the necessary\\nchanges. Works on any database, whether or not it has been initialized with `db init`.\\nDestructive operations prompt for confirmation in interactive mode. Use -y to\\nauto-accept or --dry-run to preview first.\");\n\tsetCommandExamples(command, [\"prisma-next db update --db $DATABASE_URL\", \"prisma-next db update --db $DATABASE_URL --dry-run\"]);\n\taddMigrationCommandOptions(command);\n\tcommand.option(\"--to <contract>\", \"Target contract reference (hash, prefix, ref name, migration dir name, <dir>^, or ./path)\");\n\tcommand.option(\"--advance-ref <name>\", \"Ref to advance to the post-command contract hash\");\n\tcommand.action(async (options) => {\n\t\tconst flags = parseGlobalFlagsOrExit(options);\n\t\tconst startTime = Date.now();\n\t\tconst ui = createTerminalUI(flags);\n\t\tlet result = await executeDbUpdateCommand(options, flags, ui, startTime);\n\t\tif (!result.ok && result.failure.code === ERROR_CODE_DESTRUCTIVE_CHANGES && flags.interactive && !flags.json && !flags.yes) {\n\t\t\tconst destructiveOps = result.failure.meta?.destructiveOperations ?? [];\n\t\t\tif (destructiveOps.length > 0) ui.warn(`${destructiveOps.length} destructive operation(s) that may cause data loss:\\n${destructiveOps.map((op) => ` ${ui.yellow(\"▸\")} ${op.label}`).join(\"\\n\")}`);\n\t\t\tif (await ui.confirm(\"Apply destructive changes? This cannot be undone.\")) result = await executeDbUpdateCommand(options, {\n\t\t\t\t...flags,\n\t\t\t\tyes: true\n\t\t\t}, ui, Date.now());\n\t\t}\n\t\tconst exitCode = handleResult(result, flags, ui, (dbUpdateResult) => {\n\t\t\tif (flags.json) ui.output(formatMigrationJson(dbUpdateResult));\n\t\t\telse {\n\t\t\t\tconst output = dbUpdateResult.mode === \"plan\" ? formatMigrationPlanOutput(dbUpdateResult, flags) : formatMigrationApplyOutput(dbUpdateResult, flags);\n\t\t\t\tif (output) ui.log(output);\n\t\t\t}\n\t\t});\n\t\tprocess.exit(exitCode);\n\t});\n\treturn command;\n}\n//#endregion\nexport { createDbUpdateCommand as t };\n\n//# sourceMappingURL=db-update-CfayE8WE.mjs.map"],"mappings":";;;;;;;;;;;;;;;AAeA,SAAS,mBAAmB,SAAS;CACpC,IAAI,QAAQ,SAAS,mBAAmB,OAAO,6BAA6B,EAAE,WAAW,QAAQ,aAAa,CAAC,EAAE,CAAC;CAClH,IAAI,QAAQ,SAAS,iBAAiB;EACrC,MAAM,OAAO,OAAO,QAAQ,OAAO,uBAAuB,WAAW,QAAQ,KAAK,qBAAqB,KAAK,OAAO,kCAAkC,iMAAiM;EACtV,OAAO,kBAAk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