@prisma/orm-toolchain 8.0.0-rc.1-dev.45 → 8.0.0-rc.1-dev.46

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 (303) hide show
  1. package/README.md +3 -3
  2. package/dist/{aggregate-BBsCbXgJ.mjs → aggregate-CPZB020V.mjs} +9 -9
  3. package/dist/{aggregate-BBsCbXgJ.mjs.map → aggregate-CPZB020V.mjs.map} +1 -1
  4. package/dist/{aggregate-CA6bJ8UO.d.mts → aggregate-DLUJLq5Y.d.mts} +3 -3
  5. package/dist/{aggregate-CA6bJ8UO.d.mts.map → aggregate-DLUJLq5Y.d.mts.map} +1 -1
  6. package/dist/cli-telemetry.d.mts +19 -5
  7. package/dist/cli-telemetry.d.mts.map +1 -1
  8. package/dist/cli-telemetry.mjs +287 -8
  9. package/dist/cli-telemetry.mjs.map +1 -1
  10. package/dist/cli.d.mts +11 -13
  11. package/dist/cli.d.mts.map +1 -1
  12. package/dist/cli.mjs +5382 -1095
  13. package/dist/cli.mjs.map +1 -1
  14. package/dist/cli__control-api.d.mts +298 -27
  15. package/dist/cli__control-api.d.mts.map +1 -1
  16. package/dist/cli__control-api.mjs +2 -19
  17. package/dist/cli__control-api__testing.d.mts +1 -1
  18. package/dist/cli__control-api__testing.mjs.map +1 -1
  19. package/dist/cli__init-output.d.mts +0 -1
  20. package/dist/cli__init-output.d.mts.map +1 -1
  21. package/dist/cli__init-output.mjs +1 -1
  22. package/dist/cli__migration-cli.mjs +9 -9
  23. package/dist/cli__migration-cli.mjs.map +1 -1
  24. package/dist/config-loader.d.mts +1 -1
  25. package/dist/config-loader.mjs +1 -1
  26. package/dist/{contract-snapshot-store-B0G1Fw_F-C4JjmWEA.mjs → contract-snapshot-store-B0G1Fw_F-CHc4QfKb.mjs} +4 -4
  27. package/dist/{contract-snapshot-store-B0G1Fw_F-C4JjmWEA.mjs.map → contract-snapshot-store-B0G1Fw_F-CHc4QfKb.mjs.map} +1 -1
  28. package/dist/{cli-errors-iquUoY6O-BFboxglv.d.mts → db-verify-BwgNK50T-DGvKgFCK.d.mts} +81 -81
  29. package/dist/db-verify-BwgNK50T-DGvKgFCK.d.mts.map +1 -0
  30. package/dist/emitter.d.mts +1 -1
  31. package/dist/{errors-CXbGUWGu-BQi6YS-H.mjs → errors-CXbGUWGu-CstQHPh6.mjs} +2 -2
  32. package/dist/{errors-CXbGUWGu-BQi6YS-H.mjs.map → errors-CXbGUWGu-CstQHPh6.mjs.map} +1 -1
  33. package/dist/{errors-KWM8yBAL.d.mts → errors-D59OCpoI.d.mts} +2 -2
  34. package/dist/{errors-KWM8yBAL.d.mts.map → errors-D59OCpoI.d.mts.map} +1 -1
  35. package/dist/{exports-B3xY_FHp.mjs → exports-8ZUN43ve.mjs} +6 -6
  36. package/dist/exports-8ZUN43ve.mjs.map +1 -0
  37. package/dist/{exports-BZLNbtkY.mjs → exports-BZaG8_w_.mjs} +64 -36
  38. package/dist/exports-BZaG8_w_.mjs.map +1 -0
  39. package/dist/{graph-membership-BViWUMpP-Cgu4Z2ox.mjs → graph-membership-BViWUMpP-C4lYYJdU.mjs} +2 -2
  40. package/dist/{graph-membership-BViWUMpP-Cgu4Z2ox.mjs.map → graph-membership-BViWUMpP-C4lYYJdU.mjs.map} +1 -1
  41. package/dist/{import-roots-NDOIEDVj.mjs → import-roots-CNFBPAT1.mjs} +10 -3
  42. package/dist/{import-roots-NDOIEDVj.mjs.map → import-roots-CNFBPAT1.mjs.map} +1 -1
  43. package/dist/{import-roots-B6CtsWXb.d.mts → import-roots-CfoYgejL.d.mts} +2 -2
  44. package/dist/{import-roots-B6CtsWXb.d.mts.map → import-roots-CfoYgejL.d.mts.map} +1 -1
  45. package/dist/{index-mCsi_ND5.d.mts → index-DRs7L6N0.d.mts} +11 -3
  46. package/dist/index-DRs7L6N0.d.mts.map +1 -0
  47. package/dist/{index-CnOyYxmv.d.mts → index-Dgwl8Tzs.d.mts} +2 -2
  48. package/dist/{index-CnOyYxmv.d.mts.map → index-Dgwl8Tzs.d.mts.map} +1 -1
  49. package/dist/{invariants-CTHy88OP-DJ-i5yTz.mjs → invariants-CTHy88OP-CYI2a8IO.mjs} +2 -2
  50. package/dist/{invariants-CTHy88OP-DJ-i5yTz.mjs.map → invariants-CTHy88OP-CYI2a8IO.mjs.map} +1 -1
  51. package/dist/{io-635GlNx1-D94PxRc-.mjs → io-635GlNx1-D3zrw2qu.mjs} +4 -4
  52. package/dist/{io-635GlNx1-D94PxRc-.mjs.map → io-635GlNx1-D3zrw2qu.mjs.map} +1 -1
  53. package/dist/{migration-graph-_SJImD5V-D5RCc651.mjs → migration-graph-_SJImD5V-BURyY1KM.mjs} +2 -2
  54. package/dist/{migration-graph-_SJImD5V-D5RCc651.mjs.map → migration-graph-_SJImD5V-BURyY1KM.mjs.map} +1 -1
  55. package/dist/{migration-gubSSeMk.mjs → migration-hspPIEeV.mjs} +4 -4
  56. package/dist/{migration-gubSSeMk.mjs.map → migration-hspPIEeV.mjs.map} +1 -1
  57. package/dist/migration-tools.d.mts +4 -4
  58. package/dist/migration-tools.mjs +13 -13
  59. package/dist/migration-tools__aggregate.d.mts +1 -1
  60. package/dist/migration-tools__aggregate.mjs +1 -1
  61. package/dist/migration-tools__contract-snapshot-store.mjs +1 -1
  62. package/dist/migration-tools__errors.d.mts +1 -1
  63. package/dist/migration-tools__errors.mjs +1 -1
  64. package/dist/migration-tools__invariants.mjs +1 -1
  65. package/dist/migration-tools__io.mjs +1 -1
  66. package/dist/migration-tools__migration-graph.mjs +2 -2
  67. package/dist/migration-tools__migration-ts.mjs +1 -1
  68. package/dist/migration-tools__migration.mjs +1 -1
  69. package/dist/migration-tools__ref-resolution.mjs +1 -1
  70. package/dist/migration-tools__refs.mjs +1 -1
  71. package/dist/migration-tools__spaces.d.mts +2 -2
  72. package/dist/migration-tools__spaces.mjs +2 -2
  73. package/dist/{migration-ts-BoHxxGvi.mjs → migration-ts-DdVm0rws.mjs} +2 -2
  74. package/dist/{migration-ts-BoHxxGvi.mjs.map → migration-ts-DdVm0rws.mjs.map} +1 -1
  75. package/dist/{output-DP3woAjV-BxCr9nHA.mjs → output-CovTDY14-CUoAqLML.mjs} +3 -45
  76. package/dist/output-CovTDY14-CUoAqLML.mjs.map +1 -0
  77. package/dist/publish-surface.d.mts +2 -2
  78. package/dist/publish-surface.mjs +2 -2
  79. package/dist/publish-surface__import-roots.d.mts +1 -1
  80. package/dist/publish-surface__import-roots.mjs +1 -1
  81. package/dist/publish-surface__shells.d.mts +1 -1
  82. package/dist/publish-surface__shells.mjs +1 -1
  83. package/dist/quick-reference-mongo.md +12 -9
  84. package/dist/quick-reference-postgres.md +12 -9
  85. package/dist/readme-mongo.md +2 -2
  86. package/dist/readme-postgres.md +2 -2
  87. package/dist/ref-h6InR6dO-rGfl18Jv.mjs +4686 -0
  88. package/dist/ref-h6InR6dO-rGfl18Jv.mjs.map +1 -0
  89. package/dist/{ref-resolution-sGcINe7o.mjs → ref-resolution-HeNBXW53.mjs} +2 -2
  90. package/dist/{ref-resolution-sGcINe7o.mjs.map → ref-resolution-HeNBXW53.mjs.map} +1 -1
  91. package/dist/{refs-WK86uYYp-B6EZkmmT.mjs → refs-WK86uYYp-gM8tvWQP.mjs} +2 -2
  92. package/dist/{refs-WK86uYYp-B6EZkmmT.mjs.map → refs-WK86uYYp-gM8tvWQP.mjs.map} +1 -1
  93. package/dist/{shells-BenrJHp2.mjs → shells-C4HbRAr5.mjs} +13 -14
  94. package/dist/shells-C4HbRAr5.mjs.map +1 -0
  95. package/dist/{shells-COHV_Ozf.d.mts → shells-CIUmT4u4.d.mts} +14 -20
  96. package/dist/shells-CIUmT4u4.d.mts.map +1 -0
  97. package/dist/{spaces-BG2w0P8d.mjs → spaces-4qMOAYE9.mjs} +7 -7
  98. package/dist/{spaces-BG2w0P8d.mjs.map → spaces-4qMOAYE9.mjs.map} +1 -1
  99. package/dist/{spaces-tWQi7CUv.d.mts → spaces-Dj65JrwZ.d.mts} +2 -2
  100. package/dist/{spaces-tWQi7CUv.d.mts.map → spaces-Dj65JrwZ.d.mts.map} +1 -1
  101. package/dist/{verify-contract-spaces-Cc1u_wJo-BilPJS2S.d.mts → verify-contract-spaces-C3PiFBk3-DfomYyOE.d.mts} +3 -3
  102. package/dist/{verify-contract-spaces-Cc1u_wJo-BilPJS2S.d.mts.map → verify-contract-spaces-C3PiFBk3-DfomYyOE.d.mts.map} +1 -1
  103. package/dist/{verify-contract-spaces-DhJTb0zM-_oh6W6lp.mjs → verify-contract-spaces-DhJTb0zM-B62maCfE.mjs} +4 -4
  104. package/dist/{verify-contract-spaces-DhJTb0zM-_oh6W6lp.mjs.map → verify-contract-spaces-DhJTb0zM-B62maCfE.mjs.map} +1 -1
  105. package/dist/vite-plugin-contract-emit.d.mts +2 -2
  106. package/dist/vite-plugin-contract-emit.mjs +5 -5
  107. package/dist/vite-plugin-contract-emit.mjs.map +1 -1
  108. package/package.json +14 -38
  109. package/dist/bin__prisma-next.mjs +0 -512
  110. package/dist/bin__prisma-next.mjs.map +0 -1
  111. package/dist/caught-errors-BZo7zcRc-C-pIEasG.mjs +0 -14
  112. package/dist/caught-errors-BZo7zcRc-C-pIEasG.mjs.map +0 -1
  113. package/dist/cli-errors-B4zTLaqQ-CXgjO9t4.mjs +0 -347
  114. package/dist/cli-errors-B4zTLaqQ-CXgjO9t4.mjs.map +0 -1
  115. package/dist/cli-errors-iquUoY6O-BFboxglv.d.mts.map +0 -1
  116. package/dist/cli__commands__contract-emit.d.mts +0 -2
  117. package/dist/cli__commands__contract-emit.mjs +0 -2
  118. package/dist/cli__commands__contract-infer.d.mts +0 -7
  119. package/dist/cli__commands__contract-infer.d.mts.map +0 -1
  120. package/dist/cli__commands__contract-infer.mjs +0 -2
  121. package/dist/cli__commands__db-init.d.mts +0 -7
  122. package/dist/cli__commands__db-init.d.mts.map +0 -1
  123. package/dist/cli__commands__db-init.mjs +0 -2
  124. package/dist/cli__commands__db-schema.d.mts +0 -7
  125. package/dist/cli__commands__db-schema.d.mts.map +0 -1
  126. package/dist/cli__commands__db-schema.mjs +0 -2
  127. package/dist/cli__commands__db-sign.d.mts +0 -7
  128. package/dist/cli__commands__db-sign.d.mts.map +0 -1
  129. package/dist/cli__commands__db-sign.mjs +0 -2
  130. package/dist/cli__commands__db-update.d.mts +0 -7
  131. package/dist/cli__commands__db-update.d.mts.map +0 -1
  132. package/dist/cli__commands__db-update.mjs +0 -2
  133. package/dist/cli__commands__db-verify.d.mts +0 -7
  134. package/dist/cli__commands__db-verify.d.mts.map +0 -1
  135. package/dist/cli__commands__db-verify.mjs +0 -2
  136. package/dist/cli__commands__migrate.d.mts +0 -57
  137. package/dist/cli__commands__migrate.d.mts.map +0 -1
  138. package/dist/cli__commands__migrate.mjs +0 -2
  139. package/dist/cli__commands__migration-check.d.mts +0 -8
  140. package/dist/cli__commands__migration-check.d.mts.map +0 -1
  141. package/dist/cli__commands__migration-check.mjs +0 -3
  142. package/dist/cli__commands__migration-graph.d.mts +0 -38
  143. package/dist/cli__commands__migration-graph.d.mts.map +0 -1
  144. package/dist/cli__commands__migration-graph.mjs +0 -2
  145. package/dist/cli__commands__migration-list.d.mts +0 -39
  146. package/dist/cli__commands__migration-list.d.mts.map +0 -1
  147. package/dist/cli__commands__migration-list.mjs +0 -2
  148. package/dist/cli__commands__migration-log.d.mts +0 -20
  149. package/dist/cli__commands__migration-log.d.mts.map +0 -1
  150. package/dist/cli__commands__migration-log.mjs +0 -2
  151. package/dist/cli__commands__migration-new.d.mts +0 -7
  152. package/dist/cli__commands__migration-new.d.mts.map +0 -1
  153. package/dist/cli__commands__migration-new.mjs +0 -2
  154. package/dist/cli__commands__migration-plan.d.mts +0 -34
  155. package/dist/cli__commands__migration-plan.d.mts.map +0 -1
  156. package/dist/cli__commands__migration-plan.mjs +0 -2
  157. package/dist/cli__commands__migration-show.d.mts +0 -27
  158. package/dist/cli__commands__migration-show.d.mts.map +0 -1
  159. package/dist/cli__commands__migration-show.mjs +0 -2
  160. package/dist/cli__commands__migration-status.d.mts +0 -55
  161. package/dist/cli__commands__migration-status.d.mts.map +0 -1
  162. package/dist/cli__commands__migration-status.mjs +0 -3
  163. package/dist/cli__commands__ref.d.mts +0 -7
  164. package/dist/cli__commands__ref.d.mts.map +0 -1
  165. package/dist/cli__commands__ref.mjs +0 -2
  166. package/dist/cli__commands__telemetry.d.mts +0 -7
  167. package/dist/cli__commands__telemetry.d.mts.map +0 -1
  168. package/dist/cli__commands__telemetry.mjs +0 -2
  169. package/dist/client-C6Qp5ujC-Dxb7r79B.mjs +0 -1653
  170. package/dist/client-C6Qp5ujC-Dxb7r79B.mjs.map +0 -1
  171. package/dist/code-templates-C-jirr19-DDQB0WGo.mjs +0 -295
  172. package/dist/code-templates-C-jirr19-DDQB0WGo.mjs.map +0 -1
  173. package/dist/combine-verify-results-B87B_pMc-D4l22OqY.mjs +0 -65
  174. package/dist/combine-verify-results-B87B_pMc-D4l22OqY.mjs.map +0 -1
  175. package/dist/command-helpers-BCgwcqTe-lNCtppzM.mjs +0 -776
  176. package/dist/command-helpers-BCgwcqTe-lNCtppzM.mjs.map +0 -1
  177. package/dist/contract-at-errors-BSoDI0Hw-BXeUNE3s.mjs +0 -44
  178. package/dist/contract-at-errors-BSoDI0Hw-BXeUNE3s.mjs.map +0 -1
  179. package/dist/contract-emit-BG7KL4zk-_a0J310Z.mjs +0 -331
  180. package/dist/contract-emit-BG7KL4zk-_a0J310Z.mjs.map +0 -1
  181. package/dist/contract-emit-BkEj3siG-C8M-IyvS.mjs +0 -2
  182. package/dist/contract-emit-CvwNE4R1-DEn1V1Zo.d.mts +0 -7
  183. package/dist/contract-emit-CvwNE4R1-DEn1V1Zo.d.mts.map +0 -1
  184. package/dist/contract-emit-GknCmgn_-BSWdFprC.mjs +0 -154
  185. package/dist/contract-emit-GknCmgn_-BSWdFprC.mjs.map +0 -1
  186. package/dist/contract-enrichment-DrMvvY2A-DxNGeF4d.mjs +0 -56
  187. package/dist/contract-enrichment-DrMvvY2A-DxNGeF4d.mjs.map +0 -1
  188. package/dist/contract-infer-BwIDGl7v-CZrdWXAr.mjs +0 -74
  189. package/dist/contract-infer-BwIDGl7v-CZrdWXAr.mjs.map +0 -1
  190. package/dist/contract-snapshot-resolution-De2VvOJn-DqIAV9cr.mjs +0 -82
  191. package/dist/contract-snapshot-resolution-De2VvOJn-DqIAV9cr.mjs.map +0 -1
  192. package/dist/contract-space-aggregate-loader-fa04OIaL-B7LXHle3.mjs +0 -303
  193. package/dist/contract-space-aggregate-loader-fa04OIaL-B7LXHle3.mjs.map +0 -1
  194. package/dist/db-init-BolXrKAI-CwG-zEDW.mjs +0 -109
  195. package/dist/db-init-BolXrKAI-CwG-zEDW.mjs.map +0 -1
  196. package/dist/db-init-failure-B5cQML4A-5zr-99Ek.mjs +0 -44
  197. package/dist/db-init-failure-B5cQML4A-5zr-99Ek.mjs.map +0 -1
  198. package/dist/db-schema-DvdLBdEY-Dl6e1d_Y.mjs +0 -48
  199. package/dist/db-schema-DvdLBdEY-Dl6e1d_Y.mjs.map +0 -1
  200. package/dist/db-sign-DCp4c8CA-B3tun-kh.mjs +0 -172
  201. package/dist/db-sign-DCp4c8CA-B3tun-kh.mjs.map +0 -1
  202. package/dist/db-update-CfayE8WE-CPhQyDaZ.mjs +0 -171
  203. package/dist/db-update-CfayE8WE-CPhQyDaZ.mjs.map +0 -1
  204. package/dist/db-verify-BN7IrOAL-kEzRNJUl.mjs +0 -358
  205. package/dist/db-verify-BN7IrOAL-kEzRNJUl.mjs.map +0 -1
  206. package/dist/exports-B3xY_FHp.mjs.map +0 -1
  207. package/dist/exports-BZLNbtkY.mjs.map +0 -1
  208. package/dist/exports-CqNUihkI.mjs +0 -276
  209. package/dist/exports-CqNUihkI.mjs.map +0 -1
  210. package/dist/format-Ca7dUE6B-BMFqrc6D.mjs +0 -110
  211. package/dist/format-Ca7dUE6B-BMFqrc6D.mjs.map +0 -1
  212. package/dist/framework-components-Bau7o1-J-DTp6AUoq.mjs +0 -60
  213. package/dist/framework-components-Bau7o1-J-DTp6AUoq.mjs.map +0 -1
  214. package/dist/global-flags-BpoOYtNZ-CHZD3fud.d.mts +0 -35
  215. package/dist/global-flags-BpoOYtNZ-CHZD3fud.d.mts.map +0 -1
  216. package/dist/index-mCsi_ND5.d.mts.map +0 -1
  217. package/dist/init-DC7zPKka-BSiUrPw3.mjs +0 -800
  218. package/dist/init-DC7zPKka-BSiUrPw3.mjs.map +0 -1
  219. package/dist/inspect-live-schema-BPHXdvqW-DrzL2ZkQ.mjs +0 -95
  220. package/dist/inspect-live-schema-BPHXdvqW-DrzL2ZkQ.mjs.map +0 -1
  221. package/dist/integrity-violation-to-check-failure-BmWMLAae-DqiC4_3p.mjs +0 -115
  222. package/dist/integrity-violation-to-check-failure-BmWMLAae-DqiC4_3p.mjs.map +0 -1
  223. package/dist/invariants-Bltd8DyA-Cg_1Lu0q.mjs +0 -53
  224. package/dist/invariants-Bltd8DyA-Cg_1Lu0q.mjs.map +0 -1
  225. package/dist/legend-DGv9e2_0-BtetgRz4.mjs +0 -22
  226. package/dist/legend-DGv9e2_0-BtetgRz4.mjs.map +0 -1
  227. package/dist/migrate-BXATUjYE-Do79Imf-.mjs +0 -343
  228. package/dist/migrate-BXATUjYE-Do79Imf-.mjs.map +0 -1
  229. package/dist/migrate-failure-D4NvkoCk-0bttmQs2.mjs +0 -96
  230. package/dist/migrate-failure-D4NvkoCk-0bttmQs2.mjs.map +0 -1
  231. package/dist/migrate-show-B8UJ9dmb-C4RTPbDk.d.mts +0 -63
  232. package/dist/migrate-show-B8UJ9dmb-C4RTPbDk.d.mts.map +0 -1
  233. package/dist/migrate-show-C_9xR4Qt-B-Y0PGKw.mjs +0 -199
  234. package/dist/migrate-show-C_9xR4Qt-B-Y0PGKw.mjs.map +0 -1
  235. package/dist/migration-check-Bbdw7t-r-C2VTMK61.mjs +0 -358
  236. package/dist/migration-check-Bbdw7t-r-C2VTMK61.mjs.map +0 -1
  237. package/dist/migration-check-DbHgYK7F-7mtYNVFu.mjs +0 -163
  238. package/dist/migration-check-DbHgYK7F-7mtYNVFu.mjs.map +0 -1
  239. package/dist/migration-command-scaffold-SzjR2naH-Yi3-rNfX.mjs +0 -121
  240. package/dist/migration-command-scaffold-SzjR2naH-Yi3-rNfX.mjs.map +0 -1
  241. package/dist/migration-graph-B8WxW_tm-qGNf7jQh.mjs +0 -35
  242. package/dist/migration-graph-B8WxW_tm-qGNf7jQh.mjs.map +0 -1
  243. package/dist/migration-graph-BOwu76mF-kOTWFvfV.mjs +0 -144
  244. package/dist/migration-graph-BOwu76mF-kOTWFvfV.mjs.map +0 -1
  245. package/dist/migration-graph-command-render-h0VdTkSM-C3rPZEw1.mjs +0 -2127
  246. package/dist/migration-graph-command-render-h0VdTkSM-C3rPZEw1.mjs.map +0 -1
  247. package/dist/migration-graph-sections-BBHPOFN--COKyUKQ4.mjs +0 -69
  248. package/dist/migration-graph-sections-BBHPOFN--COKyUKQ4.mjs.map +0 -1
  249. package/dist/migration-list-CKuYcMQq-CubZzE9i.mjs +0 -130
  250. package/dist/migration-list-CKuYcMQq-CubZzE9i.mjs.map +0 -1
  251. package/dist/migration-list-CY08bD8I-PoXuv94c.mjs +0 -102
  252. package/dist/migration-list-CY08bD8I-PoXuv94c.mjs.map +0 -1
  253. package/dist/migration-log-CUbGla-9-BLIrWjwN.mjs +0 -123
  254. package/dist/migration-log-CUbGla-9-BLIrWjwN.mjs.map +0 -1
  255. package/dist/migration-log-table-eES9lPjv-BCFm8qJr.mjs +0 -116
  256. package/dist/migration-log-table-eES9lPjv-BCFm8qJr.mjs.map +0 -1
  257. package/dist/migration-new-ChvZjf5X-BFhEM0BF.mjs +0 -70
  258. package/dist/migration-new-ChvZjf5X-BFhEM0BF.mjs.map +0 -1
  259. package/dist/migration-new-DXMvJdbB-BkrpDfcr.mjs +0 -130
  260. package/dist/migration-new-DXMvJdbB-BkrpDfcr.mjs.map +0 -1
  261. package/dist/migration-path-target-JDWqF9kj-B7zoMq6X.mjs +0 -38
  262. package/dist/migration-path-target-JDWqF9kj-B7zoMq6X.mjs.map +0 -1
  263. package/dist/migration-plan-BV9f5Xjq-DiyscOMc.d.mts +0 -164
  264. package/dist/migration-plan-BV9f5Xjq-DiyscOMc.d.mts.map +0 -1
  265. package/dist/migration-plan-Bz1hOTHF-CFCtPuOv.mjs +0 -192
  266. package/dist/migration-plan-Bz1hOTHF-CFCtPuOv.mjs.map +0 -1
  267. package/dist/migration-plan-Cfz0efEL-DMNFq5b2.mjs +0 -621
  268. package/dist/migration-plan-Cfz0efEL-DMNFq5b2.mjs.map +0 -1
  269. package/dist/migration-show-BGdR1xnT-Cg3M0FPh.mjs +0 -178
  270. package/dist/migration-show-BGdR1xnT-Cg3M0FPh.mjs.map +0 -1
  271. package/dist/migration-status-BIrAJ5af-D-_mMBUA.mjs +0 -427
  272. package/dist/migration-status-BIrAJ5af-D-_mMBUA.mjs.map +0 -1
  273. package/dist/output-DP3woAjV-BxCr9nHA.mjs.map +0 -1
  274. package/dist/progress-adapter-CjAeTxY_-BXYSd1eY.mjs +0 -43
  275. package/dist/progress-adapter-CjAeTxY_-BXYSd1eY.mjs.map +0 -1
  276. package/dist/project-import-root-B4nM-VWX-D__g0hTb.mjs +0 -101
  277. package/dist/project-import-root-B4nM-VWX-D__g0hTb.mjs.map +0 -1
  278. package/dist/redact-secrets-DuKoiMax-Cfe2XVhc.mjs +0 -1476
  279. package/dist/redact-secrets-DuKoiMax-Cfe2XVhc.mjs.map +0 -1
  280. package/dist/ref-4x6BGSsd-ClaoZIQh.mjs +0 -95
  281. package/dist/ref-4x6BGSsd-ClaoZIQh.mjs.map +0 -1
  282. package/dist/ref-WXLIR9Xm-12IUtoBU.mjs +0 -104
  283. package/dist/ref-WXLIR9Xm-12IUtoBU.mjs.map +0 -1
  284. package/dist/ref-advancement-DaZBzm7m-WoqnFAyr.mjs +0 -96
  285. package/dist/ref-advancement-DaZBzm7m-WoqnFAyr.mjs.map +0 -1
  286. package/dist/ref-resolution-BSN1amKm-C6-TTM2N.mjs +0 -16
  287. package/dist/ref-resolution-BSN1amKm-C6-TTM2N.mjs.map +0 -1
  288. package/dist/refs-fQLFcMoq-aTBeUU9H.mjs +0 -47
  289. package/dist/refs-fQLFcMoq-aTBeUU9H.mjs.map +0 -1
  290. package/dist/schemas-BGgjiKV0-Rh8RlMCl.d.mts +0 -206
  291. package/dist/schemas-BGgjiKV0-Rh8RlMCl.d.mts.map +0 -1
  292. package/dist/schemas-CYSD83Cu-Bff4PPoi.mjs +0 -119
  293. package/dist/schemas-CYSD83Cu-Bff4PPoi.mjs.map +0 -1
  294. package/dist/shells-BenrJHp2.mjs.map +0 -1
  295. package/dist/shells-COHV_Ozf.d.mts.map +0 -1
  296. package/dist/telemetry-BD52LETE-Cqeb7ebh.mjs +0 -121
  297. package/dist/telemetry-BD52LETE-Cqeb7ebh.mjs.map +0 -1
  298. package/dist/terminal-ui-BN4QOsm5-Bf3pim46.d.mts +0 -133
  299. package/dist/terminal-ui-BN4QOsm5-Bf3pim46.d.mts.map +0 -1
  300. package/dist/terminal-ui-Cqz4LVL7-B0mcVdLy.mjs +0 -676
  301. package/dist/terminal-ui-Cqz4LVL7-B0mcVdLy.mjs.map +0 -1
  302. package/dist/verify-Cogr_Fj9-D3lCWA6t.mjs +0 -283
  303. package/dist/verify-Cogr_Fj9-D3lCWA6t.mjs.map +0 -1
@@ -1,1653 +0,0 @@
1
- import { t as CliStructuredError$1 } from "./cli-errors-B4zTLaqQ-CXgjO9t4.mjs";
2
- import { t as assertFrameworkComponentsCompatible } from "./framework-components-Bau7o1-J-DTp6AUoq.mjs";
3
- import { t as enrichContract } from "./contract-enrichment-DrMvvY2A-DxNGeF4d.mjs";
4
- import { t as emit } from "./exports-BCLg4CiV-05kuwcb0.mjs";
5
- import { O as errorNoInvariantPath } from "./errors-CXbGUWGu-BQi6YS-H.mjs";
6
- import "./constants-CM-w38DQ-Cz_EXbOc.mjs";
7
- import { o as findPathWithDecision } from "./migration-graph-_SJImD5V-D5RCc651.mjs";
8
- import { d as resolveRecordedPath, f as verifyMigration, l as planMigration, n as buildFabricatedMigrationEdge, r as collectAggregateNamespaces, t as allStorageElementsExternal, u as requireHeadRef } from "./aggregate-BBsCbXgJ.mjs";
9
- import { n as buildContractSpaceAggregate } from "./contract-space-aggregate-loader-fa04OIaL-B7LXHle3.mjs";
10
- import { CliStructuredError } from "@prisma/orm-framework/errors/control";
11
- import { ifDefined } from "@prisma/orm-framework/utils/defined";
12
- import { structuredError } from "@prisma/orm-framework/utils/structured-error";
13
- import { blindCast, castAs } from "@prisma/orm-framework/utils/casts";
14
- import { InternalError } from "@prisma/orm-framework/utils/internal-error";
15
- import { APP_SPACE_ID, createControlStack, hasMigrations, hasOperationPreview, hasPslContractInfer, hasSchemaSubjectClassifier, hasSchemaView } from "@prisma/orm-framework/components/control";
16
- import { notOk, ok } from "@prisma/orm-framework/utils/result";
17
- import { createHash } from "node:crypto";
18
- import { canonicalizeJson } from "@prisma/orm-framework/components/utils";
19
- //#region ../../../1-framework/3-tooling/cli/dist/client-C6Qp5ujC.mjs
20
- /**
21
- * Strips operation objects to their public shape (id, label, operationClass).
22
- * Used at the API boundary to avoid leaking internal fields (precheck, execute, postcheck, etc.).
23
- */
24
- function stripOperations(operations) {
25
- return operations.map((op) => ({
26
- id: op.id,
27
- label: op.label,
28
- operationClass: op.operationClass
29
- }));
30
- }
31
- /**
32
- * Content identity of a `db update` plan: what it does (the ordered display
33
- * operations) and where it lands (the destination storage hash). A
34
- * `DESTRUCTIVE_CHANGES` refusal names the refused plan by this hash, and the
35
- * apply that carries the consent back recomputes it to prove it is still
36
- * applying the plan that was consented to.
37
- */
38
- function computePlanHash(plan) {
39
- const canonical = canonicalizeJson({
40
- operations: plan.operations,
41
- destination: { storageHash: plan.destination.storageHash }
42
- });
43
- return createHash("sha256").update(canonical).digest("hex");
44
- }
45
- /**
46
- * Span id emitted via `onProgress` for the run phase. Stable
47
- * identifier consumed by the structured-output renderer and by tests.
48
- */
49
- const RUN_SPAN_ID = "apply";
50
- /**
51
- * Runner-driving tail shared by every run caller — `db init`,
52
- * `db update`, and `migrate`. Consumes already-resolved per-space
53
- * plans (the planner-vs-replay distinction is owned by the caller) and
54
- * dispatches them to the runner in canonical order.
55
- *
56
- * Marker advancement is part of the runner's per-space transaction
57
- * (the SQL family runner writes the marker as the last step of each
58
- * space's transaction), so this primitive does not advance markers
59
- * separately — by the time `execute` returns ok, every
60
- * space's marker has been advanced to its plan's destination.
61
- *
62
- * Span emission (`spanStart 'apply'` / `spanEnd 'apply'`) is owned here
63
- * so callers don't have to duplicate it; the `action` field on each
64
- * progress event is taken from the caller's `action` argument.
65
- */
66
- async function runMigration(inputs) {
67
- const { aggregate, perSpacePlans, applyOrder, driver, familyInstance, migrations, frameworkComponents, policy, action, onProgress } = inputs;
68
- const orderedResolutions = collectOrdered(applyOrder, perSpacePlans);
69
- const runner = migrations.createRunner(familyInstance);
70
- onProgress?.({
71
- action,
72
- kind: "spanStart",
73
- spanId: RUN_SPAN_ID,
74
- label: progressLabelForAction(action)
75
- });
76
- const perSpaceOptions = orderedResolutions.map((r) => ({
77
- space: r.spaceId,
78
- plan: r.entry.plan,
79
- driver,
80
- destinationContract: r.entry.destinationContract,
81
- policy,
82
- frameworkComponents,
83
- migrationEdges: r.entry.migrationEdges,
84
- strictVerification: false
85
- }));
86
- const runnerResult = await runner.execute({
87
- driver,
88
- perSpaceOptions
89
- });
90
- if (!runnerResult.ok) {
91
- onProgress?.({
92
- action,
93
- kind: "spanEnd",
94
- spanId: RUN_SPAN_ID,
95
- outcome: "error"
96
- });
97
- return notOk({
98
- summary: runnerResult.failure.summary,
99
- ...ifDefined("why", runnerResult.failure.why),
100
- meta: {
101
- ...runnerResult.failure.meta ?? {},
102
- failingSpace: runnerResult.failure.failingSpace,
103
- runnerErrorCode: runnerResult.failure.code
104
- },
105
- cause: runnerResult.failure
106
- });
107
- }
108
- onProgress?.({
109
- action,
110
- kind: "spanEnd",
111
- spanId: RUN_SPAN_ID,
112
- outcome: "ok"
113
- });
114
- return ok({
115
- orderedResolutions,
116
- totalOpsPlanned: runnerResult.value.perSpaceResults.reduce((sum, r) => sum + r.value.operationsPlanned, 0),
117
- totalOpsExecuted: runnerResult.value.perSpaceResults.reduce((sum, r) => sum + r.value.operationsExecuted, 0),
118
- perSpace: buildPerSpaceBreakdown(orderedResolutions, aggregate.app.spaceId, { includeMarkers: true })
119
- });
120
- }
121
- /**
122
- * Project the planner's per-space resolutions into the
123
- * `PerSpaceExecutionEntry[]` shape the CLI surfaces.
124
- *
125
- * `includeMarkers` is `true` for apply-mode (each space's marker is
126
- * the `destination.storageHash` of its plan, which the runner
127
- * advances as the last step of each space's transaction) and `false`
128
- * for plan-mode (no marker has been written yet).
129
- *
130
- * Exported alongside {@link runMigration} so plan-mode callers can
131
- * assemble the same per-space block without going through the runner.
132
- */
133
- function buildPerSpaceBreakdown(orderedResolutions, appSpaceId, options) {
134
- return orderedResolutions.map((r) => {
135
- const operations = r.entry.displayOps.map((op) => ({
136
- id: op.id,
137
- label: op.label,
138
- operationClass: op.operationClass
139
- }));
140
- const base = {
141
- spaceId: r.spaceId,
142
- kind: r.spaceId === appSpaceId ? "app" : "extension",
143
- operations
144
- };
145
- if (!options.includeMarkers) return base;
146
- return {
147
- ...base,
148
- marker: { storageHash: r.entry.plan.destination.storageHash }
149
- };
150
- });
151
- }
152
- /**
153
- * Materialise the `applyOrder` ordering into resolved per-space
154
- * entries. Throws if the planner output is missing a contract space listed
155
- * in `applyOrder` — a wiring bug that should never reach runtime.
156
- *
157
- * Exported so callers building their own success envelopes after a
158
- * plan-mode dispatch can replay the same ordering.
159
- */
160
- function collectOrdered(applyOrder, perSpace) {
161
- return applyOrder.map((spaceId) => {
162
- const entry = perSpace.get(spaceId);
163
- if (!entry) throw new InternalError(`planner output missing per-space plan for "${spaceId}"`);
164
- return {
165
- spaceId,
166
- entry
167
- };
168
- });
169
- }
170
- /**
171
- * Action-appropriate label for the `spanStart` event the run
172
- * primitive emits. `runMigration` is shared by `db init`, `db update`,
173
- * and `migrate`; the span label tracks the user-visible action
174
- * so structured-progress output reads naturally for each surface.
175
- */
176
- function progressLabelForAction(action) {
177
- switch (action) {
178
- case "dbInit": return "Initialising database across spaces";
179
- case "dbUpdate": return "Updating database across spaces";
180
- case "migrate": return "Running migration plan across spaces";
181
- }
182
- }
183
- /**
184
- * Span IDs emitted via `onProgress` during the run flow.
185
- * Stable identifiers consumed by the structured-output renderer and by
186
- * tests asserting on span ids. The `apply` span itself is owned by
187
- * the {@link runMigration} primitive — only the introspect / plan
188
- * spans are emitted directly here.
189
- */
190
- const SPAN_IDS$1 = {
191
- introspect: "introspect",
192
- plan: "plan"
193
- };
194
- /**
195
- * Loader → planner → runner pipeline shared by `db init` and `db update`.
196
- *
197
- * The pipeline:
198
- *
199
- * 1. **Load**: build a {@link ContractSpaceAggregate} from the descriptor
200
- * set + on-disk on-disk artefacts. Any layout / drift / disjointness /
201
- * integrity violation short-circuits with a structured error.
202
- * 2. **Read DB state**: marker rows (`familyInstance.readAllMarkers`)
203
- * + introspected schema (`familyInstance.introspect`).
204
- * 3. **Plan**: {@link planMigration} chooses `resolveRecordedPath` vs
205
- * `planFromDiff` per space according to `callerPolicy.ignoreGraphFor`.
206
- * The app space is forced through `planFromDiff` (today's daily-driver
207
- * behaviour); every extension space walks its on-disk graph via
208
- * `resolveRecordedPath`.
209
- * 4. **Apply** (when `mode === 'apply'`): every per-space `MigrationPlan`
210
- * feeds into the runner's `execute` — one outer
211
- * transaction across every space; failure on any space rolls back
212
- * every space's writes.
213
- */
214
- async function executeRun(options) {
215
- const { driver, adapter, familyInstance, contract, mode, migrations, frameworkComponents, migrationsDir, extensions, targetId, policy, action, onProgress } = options;
216
- const loaded = await buildContractSpaceAggregate({
217
- targetId,
218
- migrationsDir,
219
- appContract: contract,
220
- extensions,
221
- deserializeContract: (json) => familyInstance.deserializeContract(json)
222
- });
223
- if (!loaded.ok) throw loaded.failure;
224
- const aggregate = loaded.value;
225
- const markerRows = await familyInstance.readAllMarkers({ driver });
226
- if (mode === "apply") {
227
- const orphanMarkerError = detectOrphanMarkers(aggregate, markerRows);
228
- if (orphanMarkerError !== null) throw orphanMarkerError;
229
- }
230
- onProgress?.({
231
- action,
232
- kind: "spanStart",
233
- spanId: SPAN_IDS$1.introspect,
234
- label: "Introspecting database schema"
235
- });
236
- const schemaIR = await familyInstance.introspect({
237
- driver,
238
- contract: collectAggregateNamespaces(aggregate)
239
- });
240
- onProgress?.({
241
- action,
242
- kind: "spanEnd",
243
- spanId: SPAN_IDS$1.introspect,
244
- outcome: "ok"
245
- });
246
- onProgress?.({
247
- action,
248
- kind: "spanStart",
249
- spanId: SPAN_IDS$1.plan,
250
- label: "Planning migration"
251
- });
252
- const planResult = await planMigration({
253
- aggregate,
254
- currentDBState: {
255
- markersBySpaceId: markerRows,
256
- schemaIntrospection: schemaIR
257
- },
258
- adapter,
259
- migrations,
260
- frameworkComponents,
261
- callerPolicy: { ignoreGraphFor: /* @__PURE__ */ new Set([aggregate.app.spaceId]) },
262
- operationPolicy: policy
263
- });
264
- if (!planResult.ok) {
265
- onProgress?.({
266
- action,
267
- kind: "spanEnd",
268
- spanId: SPAN_IDS$1.plan,
269
- outcome: "error"
270
- });
271
- return mapPlannerError(planResult.failure);
272
- }
273
- onProgress?.({
274
- action,
275
- kind: "spanEnd",
276
- spanId: SPAN_IDS$1.plan,
277
- outcome: "ok"
278
- });
279
- const orderedResolutions = collectOrdered(planResult.value.applyOrder, planResult.value.perSpace);
280
- const plannerWarnings = aggregatePlannerWarnings(orderedResolutions);
281
- const appResolution = orderedResolutions.find((r) => r.spaceId === aggregate.app.spaceId);
282
- if (!appResolution) throw new InternalError("Aggregate planner returned no plan for the app space — the planner is supposed to always emit one.");
283
- const appPlan = appResolution.entry.plan;
284
- if (mode === "plan") {
285
- const aggregateOps = orderedResolutions.flatMap((r) => r.entry.displayOps);
286
- const preview = hasOperationPreview(familyInstance) ? familyInstance.toOperationPreview(aggregateOps) : void 0;
287
- const perSpace = buildPerSpaceBreakdown(orderedResolutions, aggregate.app.spaceId, { includeMarkers: false });
288
- const summary = `Planned ${aggregateOps.length} operation(s) across ${orderedResolutions.length} space(s)`;
289
- return wrapPlanResult({
290
- operations: aggregateOps,
291
- destination: appPlan.destination,
292
- preview,
293
- perSpace,
294
- summary,
295
- ...ifDefined("warnings", plannerWarnings)
296
- });
297
- }
298
- if (options.consentedPlanHash !== void 0) {
299
- const planHash = computePlanHash({
300
- operations: stripOperations(orderedResolutions.flatMap((r) => r.entry.displayOps)),
301
- destination: appPlan.destination
302
- });
303
- if (planHash !== options.consentedPlanHash) return notOk({
304
- code: "CONSENT_PLAN_MISMATCH",
305
- summary: "The plan changed between consent and apply",
306
- why: "The plan recomputed for the consented apply is not the plan that was consented to, so applying it could destroy something nobody agreed to.",
307
- conflicts: void 0,
308
- meta: void 0,
309
- consentPlanMismatch: {
310
- consentedPlanHash: options.consentedPlanHash,
311
- planHash
312
- },
313
- ...ifDefined("warnings", plannerWarnings)
314
- });
315
- }
316
- const applied = await runMigration({
317
- aggregate,
318
- perSpacePlans: planResult.value.perSpace,
319
- applyOrder: planResult.value.applyOrder,
320
- driver,
321
- familyInstance,
322
- migrations,
323
- frameworkComponents,
324
- policy,
325
- action,
326
- ...ifDefined("onProgress", onProgress)
327
- });
328
- if (!applied.ok) return buildRunnerFailure({
329
- summary: applied.failure.summary,
330
- ...ifDefined("why", applied.failure.why),
331
- meta: applied.failure.meta,
332
- ...ifDefined("warnings", plannerWarnings),
333
- ...ifDefined("cause", applied.failure.cause)
334
- });
335
- const aggregateOps = applied.value.orderedResolutions.flatMap((r) => r.entry.displayOps);
336
- const summary = action === "dbInit" ? `Applied ${applied.value.totalOpsExecuted} operation(s) across ${applied.value.orderedResolutions.length} space(s), database signed` : applied.value.totalOpsExecuted === 0 ? `Database already matches contract across ${applied.value.orderedResolutions.length} space(s), signature updated` : `Applied ${applied.value.totalOpsExecuted} operation(s) across ${applied.value.orderedResolutions.length} space(s), signature updated`;
337
- return wrapApplyResult({
338
- operations: aggregateOps,
339
- destination: appPlan.destination,
340
- operationsPlanned: applied.value.totalOpsPlanned,
341
- operationsExecuted: applied.value.totalOpsExecuted,
342
- perSpace: applied.value.perSpace,
343
- summary,
344
- ...ifDefined("warnings", plannerWarnings)
345
- });
346
- }
347
- function aggregatePlannerWarnings(orderedResolutions) {
348
- const warnings = orderedResolutions.flatMap((r) => r.entry.warnings ?? []);
349
- return warnings.length > 0 ? warnings : void 0;
350
- }
351
- /**
352
- * Compare the live `_prisma_marker` rows against the aggregate's
353
- * declared contract spaces. Any marker row whose `space` is not a space of
354
- * the aggregate is an "orphan" — typically a marker left behind by
355
- * an extension that was removed from `extensions` without first
356
- * cleaning up its on-disk migrations / database tables.
357
- *
358
- * Returns a {@link CliStructuredError} envelope (code
359
- * `MIGRATION.CONTRACT_SPACE_VIOLATION`, `kind: 'orphanMarker'`) for the
360
- * first orphan it finds, or `null`
361
- * when every marker row maps to a declared contract space. Mirrors the M2
362
- * `runContractSpaceVerifierMarkerCheck` envelope so downstream
363
- * tooling (integration tests, JSON consumers) keeps asserting on the
364
- * same shape.
365
- */
366
- function detectOrphanMarkers(aggregate, markerRows) {
367
- const aggregateSpaceIds = /* @__PURE__ */ new Set([aggregate.app.spaceId, ...aggregate.extensions.map((m) => m.spaceId)]);
368
- const orphans = [];
369
- for (const [spaceId, row] of markerRows) if (row !== null && row !== void 0 && !aggregateSpaceIds.has(spaceId)) orphans.push(spaceId);
370
- if (orphans.length === 0) return null;
371
- orphans.sort((a, b) => a.localeCompare(b));
372
- return new CliStructuredError$1("MIGRATION.CONTRACT_SPACE_VIOLATION", orphans.length === 1 ? `Orphan contract-space marker detected for "${orphans[0]}"` : `Orphan contract-space markers detected for ${orphans.length} spaces`, {
373
- why: `The database has \`_prisma_marker\` rows for spaces (${orphans.map((s) => `"${s}"`).join(", ")}) that are not declared in the project's \`extensions\`. The aggregate pipeline refuses to advance markers it cannot account for.`,
374
- fix: "Either re-declare the missing extension(s) in `extensions` (so the aggregate owns them again), or remove the orphan marker row(s) from `_prisma_marker` once you have confirmed the corresponding tables can be safely retired.",
375
- docsUrl: "https://pris.ly/contract-spaces",
376
- meta: { violations: orphans.map((spaceId) => ({
377
- kind: "orphanMarker",
378
- spaceId
379
- })) }
380
- });
381
- }
382
- function mapPlannerError(error) {
383
- if (error.kind === "planFromDiffFailed") return blindCast(notOk({
384
- code: "PLANNING_FAILED",
385
- summary: "Migration planning failed due to conflicts",
386
- conflicts: error.conflicts,
387
- why: void 0,
388
- meta: void 0
389
- }));
390
- if (error.kind === "extensionPathUnreachable") return buildRunnerFailure({
391
- summary: `Cannot resolve apply path for extension space "${error.spaceId}"`,
392
- why: `No path in the on-disk migration graph for extension space "${error.spaceId}" reaches the on-disk head ref hash "${error.target}".`,
393
- meta: {
394
- spaceId: error.spaceId,
395
- target: error.target
396
- }
397
- });
398
- if (error.kind === "extensionPathUnsatisfiable") return buildRunnerFailure({
399
- summary: `Cannot resolve apply path for extension space "${error.spaceId}"`,
400
- why: `On-disk migration graph for extension space "${error.spaceId}" reaches the on-disk head ref but does not cover required invariants: ${error.missingInvariants.join(", ")}.`,
401
- meta: {
402
- spaceId: error.spaceId,
403
- missingInvariants: error.missingInvariants
404
- }
405
- });
406
- return buildRunnerFailure({
407
- summary: `Aggregate planner policy conflict for space "${error.spaceId}"`,
408
- why: error.detail,
409
- meta: { spaceId: error.spaceId }
410
- });
411
- }
412
- function wrapPlanResult(args) {
413
- return ok({
414
- mode: "plan",
415
- plan: {
416
- operations: stripOperations(args.operations),
417
- ...ifDefined("preview", args.preview)
418
- },
419
- destination: {
420
- storageHash: args.destination.storageHash,
421
- ...ifDefined("profileHash", args.destination.profileHash)
422
- },
423
- perSpace: args.perSpace,
424
- summary: args.summary,
425
- ...ifDefined("warnings", args.warnings)
426
- });
427
- }
428
- function wrapApplyResult(args) {
429
- return ok({
430
- mode: "apply",
431
- plan: { operations: stripOperations(args.operations) },
432
- destination: {
433
- storageHash: args.destination.storageHash,
434
- ...ifDefined("profileHash", args.destination.profileHash)
435
- },
436
- execution: {
437
- operationsPlanned: args.operationsPlanned,
438
- operationsExecuted: args.operationsExecuted
439
- },
440
- marker: args.destination.profileHash ? {
441
- storageHash: args.destination.storageHash,
442
- profileHash: args.destination.profileHash
443
- } : { storageHash: args.destination.storageHash },
444
- perSpace: args.perSpace,
445
- summary: args.summary,
446
- ...ifDefined("warnings", args.warnings)
447
- });
448
- }
449
- function buildRunnerFailure(args) {
450
- return blindCast(notOk({
451
- code: "RUNNER_FAILED",
452
- summary: args.summary,
453
- why: args.why,
454
- meta: args.meta,
455
- conflicts: void 0,
456
- ...ifDefined("warnings", args.warnings),
457
- ...ifDefined("cause", args.cause)
458
- }));
459
- }
460
- /**
461
- * Execute `db init` against the configured contract.
462
- *
463
- * Routes through the loader → planner → runner pipeline (sub-spec
464
- * "Commit-by-commit § Commit 4"). Always additive-only; destructive
465
- * changes belong to `db update`.
466
- */
467
- async function executeDbInit(options) {
468
- return await executeRun({
469
- driver: options.driver,
470
- adapter: options.adapter,
471
- familyInstance: options.familyInstance,
472
- contract: options.contract,
473
- mode: options.mode,
474
- migrations: options.migrations,
475
- frameworkComponents: options.frameworkComponents,
476
- migrationsDir: options.migrationsDir,
477
- targetId: options.targetId,
478
- extensions: options.extensions ?? [],
479
- policy: { allowedOperationClasses: ["additive"] },
480
- action: "dbInit",
481
- ...ifDefined("onProgress", options.onProgress)
482
- });
483
- }
484
- const DB_UPDATE_POLICY = { allowedOperationClasses: [
485
- "additive",
486
- "widening",
487
- "destructive"
488
- ] };
489
- /**
490
- * Execute `db update` against the configured contract.
491
- *
492
- * Routes through the loader → planner → runner pipeline. Destructive
493
- * operations require either `acceptDataLoss: true` or a prior
494
- * `mode: 'plan'` invocation that surfaces the destructive ops; the
495
- * confirmation gate is implemented here so the lower-level applier
496
- * remains policy-agnostic.
497
- */
498
- async function executeDbUpdate(options) {
499
- const sharedInputs = {
500
- driver: options.driver,
501
- adapter: options.adapter,
502
- familyInstance: options.familyInstance,
503
- contract: options.contract,
504
- migrations: options.migrations,
505
- frameworkComponents: options.frameworkComponents,
506
- migrationsDir: options.migrationsDir,
507
- targetId: options.targetId,
508
- extensions: options.extensions ?? [],
509
- policy: DB_UPDATE_POLICY,
510
- action: "dbUpdate",
511
- ...ifDefined("onProgress", options.onProgress)
512
- };
513
- if (options.mode === "apply" && !options.acceptDataLoss && options.consent === void 0) {
514
- const refusal = await guardDestructiveChanges(sharedInputs);
515
- if (refusal !== null) return refusal;
516
- }
517
- return await executeRun({
518
- ...sharedInputs,
519
- mode: options.mode,
520
- ...ifDefined("consentedPlanHash", options.consent?.planHash)
521
- });
522
- }
523
- /**
524
- * Pre-plan once when running `db update apply` without `acceptDataLoss`.
525
- * Surfaces destructive operations across every space; if any are
526
- * planned, returns a `DESTRUCTIVE_CHANGES` failure that the CLI shows
527
- * as a confirmation prompt. Returns `null` when the apply is safe to
528
- * run.
529
- */
530
- async function guardDestructiveChanges(sharedInputs) {
531
- const planResult = await executeRun({
532
- ...sharedInputs,
533
- mode: "plan"
534
- });
535
- if (!planResult.ok) return planResult;
536
- const destructiveOps = planResult.value.plan.operations.filter((op) => op.operationClass === "destructive").map((op) => ({
537
- id: op.id,
538
- label: op.label
539
- }));
540
- if (destructiveOps.length === 0) return null;
541
- const databaseName = await sharedInputs.driver.databaseName?.();
542
- return notOk({
543
- code: "DESTRUCTIVE_CHANGES",
544
- summary: `Planned ${destructiveOps.length} destructive operation(s) that require confirmation`,
545
- why: "Destructive operations require explicit consent, which the caller has not given",
546
- conflicts: void 0,
547
- meta: void 0,
548
- destructiveChanges: {
549
- destructiveOperations: destructiveOps,
550
- databaseName,
551
- planHash: computePlanHash({
552
- operations: planResult.value.plan.operations,
553
- destination: planResult.value.destination
554
- })
555
- },
556
- ...ifDefined("warnings", planResult.value.warnings)
557
- });
558
- }
559
- /**
560
- * Span IDs emitted via `onProgress` during the aggregate verify flow.
561
- * Mirrors the span identifiers used by the legacy precheck / marker-check
562
- * helpers so structured-output renderers and progress tests keep working.
563
- */
564
- const SPAN_IDS = {
565
- introspect: "introspect",
566
- verify: "verify"
567
- };
568
- /**
569
- * Loader → verifier pipeline shared by `db verify` modes (`full`,
570
- * `marker-only`, `schema-only`).
571
- *
572
- * 1. **Load**: build a {@link import('@internal/migration-tools/aggregate').ContractSpaceAggregate}
573
- * from descriptors + on-disk on-disk artefacts. Layout / drift /
574
- * integrity / disjointness violations short-circuit with a
575
- * structured CLI error.
576
- * 2. **Read DB state**: marker rows + (when `skipSchema` is `false`)
577
- * schema introspection.
578
- * 3. **Verify**: {@link verifyMigration} returns per-space `markerCheck` +
579
- * per-space `schemaCheck` (each contract space verified against the full schema,
580
- * then scoped to its own contract space). Marker drift is returned as the
581
- * success value's `markerDrift` envelope for callers to settle as a
582
- * finding. Verify results are returned to the caller verbatim.
583
- */
584
- async function executeDbVerify(options) {
585
- const { driver, familyInstance, onProgress, skipSchema, skipMarker } = options;
586
- const loaded = await buildContractSpaceAggregate(buildLoadInputs(options));
587
- if (!loaded.ok) return notOk(loaded.failure);
588
- const aggregate = loaded.value;
589
- const markersBySpaceId = await familyInstance.readAllMarkers({ driver });
590
- const schemaIntrospection = skipSchema ? null : await runIntrospection({
591
- driver,
592
- familyInstance,
593
- onProgress,
594
- contract: collectAggregateNamespaces(aggregate)
595
- });
596
- const classifySubjectGranularity = hasSchemaSubjectClassifier(familyInstance) ? (issue) => familyInstance.classifySubjectGranularity(issue) : void 0;
597
- const classifyEntityKind = hasSchemaSubjectClassifier(familyInstance) ? (issue) => familyInstance.classifyEntityKind(issue) : void 0;
598
- emitVerifySpan(onProgress, "spanStart");
599
- return finaliseVerifyResult({
600
- verifyResult: verifyMigration({
601
- aggregate,
602
- markersBySpaceId,
603
- schemaIntrospection,
604
- mode: options.mode,
605
- verifySchemaForSpace: createPerSpaceVerifier(options),
606
- ...ifDefined("classifySubjectGranularity", classifySubjectGranularity),
607
- ...ifDefined("classifyEntityKind", classifyEntityKind)
608
- }),
609
- aggregate,
610
- skipMarker,
611
- onProgress
612
- });
613
- }
614
- function buildLoadInputs(options) {
615
- return {
616
- targetId: options.targetId,
617
- migrationsDir: options.migrationsDir,
618
- appContract: options.contract,
619
- extensions: options.extensions,
620
- deserializeContract: (json) => options.familyInstance.deserializeContract(json)
621
- };
622
- }
623
- async function runIntrospection(args) {
624
- const { driver, familyInstance, onProgress, contract } = args;
625
- onProgress?.({
626
- action: "dbVerify",
627
- kind: "spanStart",
628
- spanId: SPAN_IDS.introspect,
629
- label: "Introspecting database schema"
630
- });
631
- try {
632
- const result = await familyInstance.introspect({
633
- driver,
634
- contract
635
- });
636
- onProgress?.({
637
- action: "dbVerify",
638
- kind: "spanEnd",
639
- spanId: SPAN_IDS.introspect,
640
- outcome: "ok"
641
- });
642
- return result;
643
- } catch (error) {
644
- onProgress?.({
645
- action: "dbVerify",
646
- kind: "spanEnd",
647
- spanId: SPAN_IDS.introspect,
648
- outcome: "error"
649
- });
650
- throw error;
651
- }
652
- }
653
- /**
654
- * Build the per-space schema callback handed to the aggregate verifier.
655
- * When `skipSchema` is true the callback short-circuits with a synthetic
656
- * `ok` result so the verifier still runs the (cheap) schemaCheck loop
657
- * without invoking the family's verification path.
658
- */
659
- function createPerSpaceVerifier(options) {
660
- const { skipSchema, familyInstance, frameworkComponents } = options;
661
- return (schema, space, verifyMode) => {
662
- if (skipSchema) return buildSkippedSchemaResult(space);
663
- return familyInstance.verifySchema({
664
- contract: space.contract(),
665
- schema,
666
- strict: verifyMode === "strict",
667
- frameworkComponents
668
- });
669
- };
670
- }
671
- function emitVerifySpan(onProgress, kind) {
672
- if (kind === "spanStart") {
673
- onProgress?.({
674
- action: "dbVerify",
675
- kind: "spanStart",
676
- spanId: SPAN_IDS.verify,
677
- label: "Verifying contract spaces"
678
- });
679
- return;
680
- }
681
- onProgress?.({
682
- action: "dbVerify",
683
- kind: "spanEnd",
684
- spanId: SPAN_IDS.verify,
685
- outcome: kind === "spanEndOk" ? "ok" : "error"
686
- });
687
- }
688
- /**
689
- * Map an {@link VerifierOutput} to the operation's
690
- * {@link ExecuteDbVerifyResult}, applying the `skipMarker` policy used
691
- * by the CLI's `--schema-only` mode.
692
- */
693
- function finaliseVerifyResult(args) {
694
- const { verifyResult, aggregate, skipMarker, onProgress } = args;
695
- if (!verifyResult.ok) {
696
- emitVerifySpan(onProgress, "spanEndError");
697
- return notOk(new CliStructuredError$1("MIGRATION.CONTRACT_SPACE_VIOLATION", "Aggregate verifier introspection failed", {
698
- why: verifyResult.failure.detail,
699
- fix: "Check database connectivity and the introspection tooling.",
700
- docsUrl: "https://pris.ly/contract-spaces"
701
- }));
702
- }
703
- const markerDrift = skipMarker ? null : mapMarkerCheckFailures(aggregate.app.spaceId, verifyResult.value.markerCheck);
704
- emitVerifySpan(onProgress, markerDrift === null ? "spanEndOk" : "spanEndError");
705
- return ok({
706
- schemaResults: verifyResult.value.schemaCheck.perSpace,
707
- unclaimed: verifyResult.value.schemaCheck.unclaimed,
708
- spaceOrder: [aggregate.app.spaceId, ...aggregate.extensions.map((e) => e.spaceId)],
709
- appSpaceId: aggregate.app.spaceId,
710
- markerDrift
711
- });
712
- }
713
- function buildSkippedSchemaResult(space) {
714
- const contract = space.contract();
715
- const headRef = requireHeadRef(space);
716
- const profileHash = castAs(contract).profileHash;
717
- return {
718
- ok: true,
719
- summary: "Schema verification skipped",
720
- contract: {
721
- storageHash: headRef.hash,
722
- ...profileHash ? { profileHash } : {}
723
- },
724
- target: { expected: contract.target },
725
- schema: { issues: [] },
726
- timings: { total: 0 }
727
- };
728
- }
729
- /**
730
- * Translate per-space marker check failures and orphan markers into a
731
- * single CLI structured error envelope. Preserves the legacy code
732
- * `MIGRATION.CONTRACT_SPACE_VIOLATION` (was emitted by
733
- * `runContractSpaceVerifierMarkerCheck`).
734
- */
735
- function mapMarkerCheckFailures(appSpaceId, section) {
736
- const violations = [];
737
- for (const [spaceId, result] of section.perSpace) {
738
- if (result.kind === "ok" || result.kind === "absent") continue;
739
- if (result.kind === "hashMismatch") {
740
- violations.push({
741
- kind: "hashMismatch",
742
- spaceId,
743
- remediation: spaceId === appSpaceId ? "Run `prisma-next db update` to advance the marker, or roll the database back to the recorded hash." : `Apply on-disk migrations under \`migrations/${spaceId}/\` to advance the marker, or remove the conflicting marker row.`
744
- });
745
- continue;
746
- }
747
- if (result.kind === "missingInvariants") violations.push({
748
- kind: "invariantsMismatch",
749
- spaceId,
750
- remediation: `Re-apply the migrations under \`migrations/${spaceId}/\` so the marker carries invariants: ${result.missing.join(", ")}.`
751
- });
752
- }
753
- for (const orphan of section.orphanMarkers) violations.push({
754
- kind: "orphanMarker",
755
- spaceId: orphan.spaceId,
756
- remediation: `Add the corresponding extension to \`extensions\` in \`prisma-next.config.ts\`, or delete the orphan marker row for "${orphan.spaceId}".`
757
- });
758
- if (violations.length === 0) return null;
759
- const lines = violations.map((v) => `- [${v.kind}] ${v.spaceId}: ${v.remediation}`);
760
- return new CliStructuredError$1("MIGRATION.CONTRACT_SPACE_VIOLATION", violations.length === 1 ? "Contract-space verifier found a violation" : `Contract-space verifier found violations (${violations.length})`, {
761
- why: `The on-disk \`migrations/\` directory, the \`extensions\` declaration, and the live database marker rows are not in agreement.\n${lines.join("\n")}`,
762
- fix: violations[0]?.remediation ?? "Review and reconcile the violations listed above.",
763
- docsUrl: "https://pris.ly/contract-spaces",
764
- meta: { violations }
765
- });
766
- }
767
- /**
768
- * Apply pending migrations across every contract space (app +
769
- * extensions). Replay-only: graph-walk against the on-disk graph for
770
- * every contract space; no synth, no introspection.
771
- *
772
- * Pipeline:
773
- *
774
- * 1. Load aggregate from disk (loader hydrates extension graphs;
775
- * caller provides app-space packages).
776
- * 2. Read live marker rows per space (`familyInstance.readAllMarkers`).
777
- * 3. Per space: `resolveRecordedPath` plots the path from the live
778
- * marker to `space.headRef.hash` (or `refHash` for the app
779
- * space when provided). An empty-graph space whose elements are ALL
780
- * externally managed resolves declaratively (marker to head, zero
781
- * ops), mirroring the db-init aggregate planner: such a space ships
782
- * no DDL and has nothing to author. Every other empty-graph space
783
- * fails loudly — "never planned" is a user-error condition for
784
- * replay.
785
- * 4. Hand off to {@link runMigration} (the runner-driving tail
786
- * shared with `db init` / `db update`). Marker advancement is
787
- * inside the per-space transaction.
788
- *
789
- * Encodes the replay-only contract: the app contract space must have an
790
- * authored migration graph on disk before this operation can advance it.
791
- */
792
- async function executeMigrate(options) {
793
- const { driver, familyInstance, contract, migrations, frameworkComponents, migrationsDir, extensions, targetId, refHash, refInvariants, refName, onProgress } = options;
794
- const loaded = await buildContractSpaceAggregate({
795
- targetId,
796
- migrationsDir,
797
- appContract: contract,
798
- extensions,
799
- deserializeContract: (json) => familyInstance.deserializeContract(json)
800
- });
801
- if (!loaded.ok) throw loaded.failure;
802
- const aggregate = loaded.value;
803
- const markerRows = await familyInstance.readAllMarkers({ driver });
804
- const allSpaces = [aggregate.app, ...aggregate.extensions];
805
- const perSpacePlans = /* @__PURE__ */ new Map();
806
- const atHeadResolutions = /* @__PURE__ */ new Map();
807
- for (const space of allSpaces) {
808
- const isAppSpace = space.spaceId === aggregate.app.spaceId;
809
- const headRef = requireHeadRef(space);
810
- const spaceTargetHash = isAppSpace && refHash !== void 0 ? refHash : headRef.hash;
811
- const outcome = planSpacePath({
812
- space,
813
- aggregate,
814
- targetHash: spaceTargetHash,
815
- refInvariants: isAppSpace && refHash !== void 0 ? refInvariants : void 0,
816
- liveMarker: markerRows.get(space.spaceId) ?? null,
817
- ...isAppSpace ? { refName } : {}
818
- });
819
- if (outcome.kind === "at-head") {
820
- atHeadResolutions.set(space.spaceId, outcome.plan);
821
- continue;
822
- }
823
- if (outcome.kind === "never-planned") return notOk(buildNeverPlannedFailure(outcome.spaceId, outcome.targetHash));
824
- if (outcome.kind === "unreachable") return notOk(buildPathNotFoundFailure(outcome.spaceId, outcome.liveMarker, outcome.targetHash));
825
- if (outcome.kind === "unsatisfiable") {
826
- const structural = findPathWithDecision(outcome.targetSpace.graph(), outcome.liveHash, spaceTargetHash, { required: /* @__PURE__ */ new Set() });
827
- const structuralPath = structural.kind === "ok" ? structural.decision.selectedPath.map((edge) => ({
828
- dirName: edge.dirName,
829
- migrationHash: edge.migrationHash,
830
- from: edge.from,
831
- to: edge.to,
832
- invariants: edge.invariants
833
- })) : [];
834
- throw errorNoInvariantPath({
835
- ...outcome.refName !== void 0 ? { refName: outcome.refName } : {},
836
- required: outcome.targetInvariants,
837
- missing: outcome.missing,
838
- structuralPath
839
- });
840
- }
841
- perSpacePlans.set(space.spaceId, outcome.plan);
842
- }
843
- const canonicalOrder = [...aggregate.extensions.map((m) => m.spaceId), aggregate.app.spaceId];
844
- const applyOrder = canonicalOrder.filter((spaceId) => perSpacePlans.has(spaceId));
845
- if (!applyOrder.some((spaceId) => {
846
- const entry = perSpacePlans.get(spaceId);
847
- return entry !== void 0 && planRequiresExecution(entry);
848
- })) {
849
- const ordered = canonicalOrder.filter((spaceId) => perSpacePlans.has(spaceId) || atHeadResolutions.has(spaceId)).map((spaceId) => {
850
- const entry = perSpacePlans.get(spaceId) ?? atHeadResolutions.get(spaceId);
851
- if (entry === void 0) throw new InternalError(`Unreachable: missing per-space plan for "${spaceId}"`);
852
- return {
853
- spaceId,
854
- entry
855
- };
856
- });
857
- const perSpace = buildPerSpaceBreakdown(ordered, aggregate.app.spaceId, { includeMarkers: true });
858
- const totalSpaces = ordered.length;
859
- return ok(buildSuccess({
860
- aggregate,
861
- orderedResolutions: ordered,
862
- perSpace,
863
- totalOpsExecuted: 0,
864
- summary: totalSpaces === 0 ? "Already up to date — no contract spaces are loaded" : totalSpaces === 1 ? "Already up to date" : `Already up to date across ${totalSpaces} space(s)`
865
- }));
866
- }
867
- const applied = await runMigration({
868
- aggregate,
869
- perSpacePlans,
870
- applyOrder,
871
- driver,
872
- familyInstance,
873
- migrations,
874
- frameworkComponents,
875
- policy: { allowedOperationClasses: [
876
- "additive",
877
- "widening",
878
- "destructive",
879
- "data"
880
- ] },
881
- action: "migrate",
882
- ...ifDefined("onProgress", onProgress)
883
- });
884
- if (!applied.ok) return notOk({
885
- code: "RUNNER_FAILED",
886
- summary: applied.failure.summary,
887
- why: applied.failure.why,
888
- meta: applied.failure.meta,
889
- ...ifDefined("cause", applied.failure.cause)
890
- });
891
- const orderedAll = canonicalOrder.filter((spaceId) => perSpacePlans.has(spaceId) || atHeadResolutions.has(spaceId)).map((spaceId) => {
892
- if (perSpacePlans.has(spaceId)) {
893
- const fromRunner = applied.value.orderedResolutions.find((r) => r.spaceId === spaceId);
894
- if (fromRunner !== void 0) return fromRunner;
895
- }
896
- const entry = atHeadResolutions.get(spaceId);
897
- if (entry === void 0) throw new InternalError(`Unreachable: missing per-space plan for "${spaceId}"`);
898
- return {
899
- spaceId,
900
- entry
901
- };
902
- });
903
- const perSpaceAll = buildPerSpaceBreakdown(orderedAll, aggregate.app.spaceId, { includeMarkers: true });
904
- const summary = `Applied ${applied.value.orderedResolutions.reduce((sum, r) => sum + r.entry.migrationEdges.length, 0)} migration(s) (${applied.value.totalOpsExecuted} operation(s)) across ${orderedAll.length} contract space(s)`;
905
- return ok(buildSuccess({
906
- aggregate,
907
- orderedResolutions: orderedAll,
908
- perSpace: perSpaceAll,
909
- totalOpsExecuted: applied.value.totalOpsExecuted,
910
- summary
911
- }));
912
- }
913
- /**
914
- * Compute the graph-walk path for one contract space.
915
- *
916
- * Encapsulates the invariant-correct input assembly that both
917
- * `executeMigrate` and `executeMigrateShowCommand` must use:
918
- * - `currentMarker` carries the full live marker including `invariants`
919
- * (not a stripped `{ storageHash, invariants: [] }` shell).
920
- * - `targetInvariants` uses the caller-supplied `refInvariants` when a
921
- * `--to` ref was resolved (not always the file head ref's invariants).
922
- *
923
- * Both callers map the returned `SpacePathOutcome` to their own error
924
- * representation; the path-compute logic is shared and identical.
925
- *
926
- * @internal Exported for `executeMigrateShowCommand`.
927
- */
928
- function planSpacePath({ space, aggregate, targetHash, refInvariants, liveMarker, refName }) {
929
- const isAppSpace = space.spaceId === aggregate.app.spaceId;
930
- const headRef = requireHeadRef(space);
931
- if (space.graph().nodes.size === 0) {
932
- const liveHash = liveMarker?.storageHash;
933
- if (targetHash === liveHash || liveHash === void 0 && targetHash === "empty") return {
934
- kind: "at-head",
935
- plan: buildAtHeadResolution({
936
- aggregateTargetId: aggregate.targetId,
937
- space,
938
- targetHash,
939
- liveMarker
940
- })
941
- };
942
- if (!isAppSpace && allStorageElementsExternal(space.contract())) {
943
- if (headRef.invariants.length > 0) return {
944
- kind: "unsatisfiable",
945
- spaceId: space.spaceId,
946
- isAppSpace,
947
- missing: [...headRef.invariants].sort(),
948
- targetInvariants: headRef.invariants,
949
- targetSpace: space,
950
- liveHash: liveHash ?? "empty",
951
- refName: void 0
952
- };
953
- return {
954
- kind: "ok",
955
- plan: buildAtHeadResolution({
956
- aggregateTargetId: aggregate.targetId,
957
- space,
958
- targetHash,
959
- liveMarker
960
- })
961
- };
962
- }
963
- return {
964
- kind: "never-planned",
965
- spaceId: space.spaceId,
966
- targetHash
967
- };
968
- }
969
- const targetInvariants = isAppSpace && refInvariants !== void 0 ? refInvariants : headRef.invariants;
970
- const targetSpace = targetHash === headRef.hash && targetInvariants === headRef.invariants ? space : {
971
- ...space,
972
- headRef: {
973
- hash: targetHash,
974
- invariants: targetInvariants
975
- }
976
- };
977
- const walked = resolveRecordedPath({
978
- aggregateTargetId: aggregate.targetId,
979
- space: targetSpace,
980
- currentMarker: liveMarker,
981
- ...isAppSpace && refName !== void 0 ? { refName } : {}
982
- });
983
- if (walked.kind === "unreachable") return {
984
- kind: "unreachable",
985
- spaceId: space.spaceId,
986
- liveMarker,
987
- targetHash
988
- };
989
- if (walked.kind === "unsatisfiable") {
990
- const liveHash = liveMarker?.storageHash ?? "empty";
991
- return {
992
- kind: "unsatisfiable",
993
- spaceId: space.spaceId,
994
- isAppSpace,
995
- missing: walked.missing,
996
- targetInvariants,
997
- targetSpace,
998
- liveHash,
999
- refName
1000
- };
1001
- }
1002
- return {
1003
- kind: "ok",
1004
- plan: walked.result
1005
- };
1006
- }
1007
- /**
1008
- * Build a zero-op {@link PerSpacePlan} for an empty-graph space —
1009
- * either one whose live marker already matches the target (at-head), or
1010
- * an all-external extension space whose marker must advance to the head
1011
- * ref with no DDL (declared-state). Lets the apply pipeline thread the
1012
- * space through `perSpacePlans` -> `applyOrder` -> the success
1013
- * envelope's `perSpace[]` block so the result reflects every loaded
1014
- * space, even when there is nothing to execute.
1015
- */
1016
- function buildAtHeadResolution(args) {
1017
- const { aggregateTargetId, space, targetHash, liveMarker } = args;
1018
- return {
1019
- plan: {
1020
- targetId: aggregateTargetId,
1021
- spaceId: space.spaceId,
1022
- origin: liveMarker === null ? null : { storageHash: liveMarker.storageHash },
1023
- destination: { storageHash: targetHash },
1024
- operations: [],
1025
- providedInvariants: []
1026
- },
1027
- displayOps: [],
1028
- destinationContract: space.contract(),
1029
- strategy: "declared-state",
1030
- migrationEdges: [buildFabricatedMigrationEdge({
1031
- currentMarkerStorageHash: liveMarker?.storageHash,
1032
- destinationStorageHash: targetHash,
1033
- operationCount: 0
1034
- })]
1035
- };
1036
- }
1037
- /**
1038
- * A plan needs the runner when it executes operations or advances the
1039
- * space's marker (a declared-state resolution has zero operations but a
1040
- * destination hash the live marker doesn't carry yet).
1041
- */
1042
- function planRequiresExecution(entry) {
1043
- if (entry.plan.operations.length > 0) return true;
1044
- return entry.plan.origin?.storageHash !== entry.plan.destination.storageHash;
1045
- }
1046
- function buildSuccess(args) {
1047
- const appResolution = args.orderedResolutions.find((r) => r.spaceId === args.aggregate.app.spaceId);
1048
- const appMarkerHash = appResolution?.entry.plan.destination.storageHash ?? requireHeadRef(args.aggregate.app).hash;
1049
- const applied = args.orderedResolutions.flatMap((r) => {
1050
- return r.entry.migrationEdges.map((edge) => ({
1051
- spaceId: r.spaceId,
1052
- dirName: edge.dirName,
1053
- migrationHash: edge.migrationHash,
1054
- from: edge.from,
1055
- to: edge.to,
1056
- operationsExecuted: edge.operationCount
1057
- }));
1058
- });
1059
- const appPlan = appResolution?.entry;
1060
- const pathDecision = appPlan?.pathDecision ? {
1061
- fromHash: appPlan.pathDecision.fromHash,
1062
- toHash: appPlan.pathDecision.toHash,
1063
- alternativeCount: appPlan.pathDecision.alternativeCount,
1064
- tieBreakReasons: appPlan.pathDecision.tieBreakReasons,
1065
- ...appPlan.pathDecision.refName !== void 0 ? { refName: appPlan.pathDecision.refName } : {},
1066
- requiredInvariants: appPlan.pathDecision.requiredInvariants ?? [],
1067
- satisfiedInvariants: appPlan.pathDecision.satisfiedInvariants ?? [],
1068
- selectedPath: appPlan.pathDecision.selectedPath.map((entry) => ({
1069
- dirName: entry.dirName,
1070
- migrationHash: entry.migrationHash,
1071
- from: entry.from,
1072
- to: entry.to,
1073
- invariants: entry.invariants
1074
- }))
1075
- } : void 0;
1076
- return {
1077
- migrationsApplied: applied.length,
1078
- markerHash: appMarkerHash,
1079
- applied,
1080
- summary: args.summary,
1081
- perSpace: args.perSpace,
1082
- ...pathDecision !== void 0 ? { pathDecision } : {}
1083
- };
1084
- }
1085
- /**
1086
- * Build the `neverPlanned` failure raised when a contract space that
1087
- * declares managed storage elements has no on-disk migration graph but
1088
- * migrate was asked to reach a target hash. All-external spaces never reach
1089
- * this: they resolve declaratively (marker advances to the head ref with
1090
- * zero operations). The `why` states only the condition; the recovery
1091
- * sequence is composed by `errorPathUnreachable`'s `fix`.
1092
- *
1093
- * @internal Exported for testing only.
1094
- */
1095
- function buildNeverPlannedFailure(spaceId, targetHash) {
1096
- return {
1097
- code: "MIGRATION_PATH_NOT_FOUND",
1098
- summary: `No on-disk migrations for contract space "${spaceId}"`,
1099
- why: `migrate is replay-only: a contract space that declares managed storage elements must have an authored migration graph on disk. Space "${spaceId}" has no migrations under \`migrations/${spaceId}/\` but its head ref targets "${targetHash}".`,
1100
- meta: {
1101
- spaceId,
1102
- target: targetHash,
1103
- kind: "neverPlanned"
1104
- }
1105
- };
1106
- }
1107
- /**
1108
- * Build the `pathUnreachable` failure raised when an emitted contract has no
1109
- * on-disk migration edge from the current marker to the target. The `why`
1110
- * states only the condition (no edge between the two named states, and migrate
1111
- * replays edges rather than inventing them); the recovery sequence — plan the
1112
- * edge, then re-apply — is composed by `errorPathUnreachable`'s `fix`, so the
1113
- * two read as one non-redundant plan-then-apply story.
1114
- *
1115
- * @internal Exported for testing only.
1116
- */
1117
- function buildPathNotFoundFailure(spaceId, marker, targetHash) {
1118
- const fromHash = marker?.storageHash ?? "<empty>";
1119
- return {
1120
- code: "MIGRATION_PATH_NOT_FOUND",
1121
- summary: spaceId === "app" ? "Current contract has no planned migration path" : `Current contract has no planned migration path for contract space "${spaceId}"`,
1122
- why: `No migration edge connects the current state "${fromHash}" to the target "${targetHash}" in contract space "${spaceId}". The on-disk migration graph does not join the two, and migrate replays existing edges — it never invents one.`,
1123
- meta: {
1124
- spaceId,
1125
- fromHash,
1126
- targetHash,
1127
- kind: "pathUnreachable"
1128
- }
1129
- };
1130
- }
1131
- /**
1132
- * Creates a programmatic control client for Prisma Next operations.
1133
- *
1134
- * The client accepts framework component descriptors at creation time,
1135
- * manages driver lifecycle via connect()/close(), and exposes domain
1136
- * operations that delegate to the existing family instance methods.
1137
- *
1138
- * @see {@link ControlClient} for the client interface
1139
- * @see README.md "Programmatic Control API" section for usage examples
1140
- */
1141
- function createControlClient(options) {
1142
- return new ControlClientImpl(options);
1143
- }
1144
- /**
1145
- * Implementation of ControlClient.
1146
- * Manages initialization and connection state, delegates operations to family instance.
1147
- */
1148
- var ControlClientImpl = class {
1149
- options;
1150
- stack = null;
1151
- driver = null;
1152
- familyInstance = null;
1153
- frameworkComponents = null;
1154
- initialized = false;
1155
- defaultConnection;
1156
- constructor(options) {
1157
- this.options = options;
1158
- this.defaultConnection = options.connection;
1159
- }
1160
- init() {
1161
- if (this.initialized) return;
1162
- this.stack = createControlStack({
1163
- family: this.options.family,
1164
- target: this.options.target,
1165
- adapter: this.options.adapter,
1166
- driver: this.options.driver,
1167
- extensions: this.options.extensions
1168
- });
1169
- this.familyInstance = this.options.family.create(this.stack);
1170
- const rawComponents = [
1171
- this.options.target,
1172
- this.options.adapter,
1173
- ...this.options.extensions ?? []
1174
- ];
1175
- this.frameworkComponents = assertFrameworkComponentsCompatible(this.options.family.familyId, this.options.target.targetId, rawComponents);
1176
- this.initialized = true;
1177
- }
1178
- async connect(connection) {
1179
- this.init();
1180
- if (this.driver) throw new CliStructuredError("DRIVER.ALREADY_CONNECTED", "Already connected. Call close() before reconnecting.");
1181
- const resolvedConnection = connection ?? this.defaultConnection;
1182
- if (resolvedConnection === void 0) throw new CliStructuredError("CONFIG.DB_CONNECTION_REQUIRED", "No connection provided. Pass a connection to connect() or provide a default connection when creating the client.");
1183
- if (!this.stack?.driver) throw new CliStructuredError("CONFIG.DRIVER_REQUIRED", "Driver is not configured. Pass a driver descriptor when creating the control client to enable database operations.");
1184
- this.driver = await this.stack.driver.create(resolvedConnection);
1185
- }
1186
- async close() {
1187
- if (this.driver) {
1188
- await this.driver.close();
1189
- this.driver = null;
1190
- }
1191
- }
1192
- /**
1193
- * Construct the control adapter once for a migration operation and return
1194
- * it, mirroring how the runtime plane builds the execution adapter once in
1195
- * `createExecutionStack`. Only `dbInit` / `dbUpdate` need it (it lowers the
1196
- * planner's DDL); read-only operations never build it. The descriptor is
1197
- * optional on the stack — targets without migrations omit it.
1198
- */
1199
- buildControlAdapter() {
1200
- this.init();
1201
- if (!this.stack?.adapter) throw new CliStructuredError("MIGRATION.TARGET_UNSUPPORTED", `Target "${this.options.target.targetId}" requires an adapter for migrations`);
1202
- return this.stack.adapter.create(this.stack);
1203
- }
1204
- async ensureConnected() {
1205
- this.init();
1206
- if (!this.driver && this.defaultConnection !== void 0) await this.connect(this.defaultConnection);
1207
- if (!this.driver || !this.familyInstance || !this.frameworkComponents) throw new CliStructuredError("DRIVER.NOT_CONNECTED", "Not connected. Call connect(connection) first.");
1208
- return {
1209
- driver: this.driver,
1210
- familyInstance: this.familyInstance,
1211
- frameworkComponents: this.frameworkComponents
1212
- };
1213
- }
1214
- async connectWithProgress(connection, action, onProgress) {
1215
- if (connection === void 0) return;
1216
- onProgress?.({
1217
- action,
1218
- kind: "spanStart",
1219
- spanId: "connect",
1220
- label: "Connecting to database..."
1221
- });
1222
- try {
1223
- await this.connect(connection);
1224
- onProgress?.({
1225
- action,
1226
- kind: "spanEnd",
1227
- spanId: "connect",
1228
- outcome: "ok"
1229
- });
1230
- } catch (error) {
1231
- onProgress?.({
1232
- action,
1233
- kind: "spanEnd",
1234
- spanId: "connect",
1235
- outcome: "error"
1236
- });
1237
- throw error;
1238
- }
1239
- }
1240
- async verify(options) {
1241
- const { onProgress } = options;
1242
- await this.connectWithProgress(options.connection, "verify", onProgress);
1243
- const { driver, familyInstance } = await this.ensureConnected();
1244
- let contract;
1245
- try {
1246
- contract = familyInstance.deserializeContract(options.contract);
1247
- } catch (error) {
1248
- throw structuredError("CONTRACT.VALIDATION_FAILED", error instanceof Error ? error.message : String(error), { cause: error });
1249
- }
1250
- onProgress?.({
1251
- action: "verify",
1252
- kind: "spanStart",
1253
- spanId: "verify",
1254
- label: "Verifying database marker..."
1255
- });
1256
- try {
1257
- const result = await familyInstance.verify({
1258
- driver,
1259
- contract,
1260
- expectedTargetId: this.options.target.targetId,
1261
- contractPath: ""
1262
- });
1263
- onProgress?.({
1264
- action: "verify",
1265
- kind: "spanEnd",
1266
- spanId: "verify",
1267
- outcome: result.ok ? "ok" : "error"
1268
- });
1269
- return result;
1270
- } catch (error) {
1271
- onProgress?.({
1272
- action: "verify",
1273
- kind: "spanEnd",
1274
- spanId: "verify",
1275
- outcome: "error"
1276
- });
1277
- throw error;
1278
- }
1279
- }
1280
- async schemaVerify(options) {
1281
- const { onProgress } = options;
1282
- await this.connectWithProgress(options.connection, "schemaVerify", onProgress);
1283
- const { driver, familyInstance, frameworkComponents } = await this.ensureConnected();
1284
- let contract;
1285
- try {
1286
- contract = familyInstance.deserializeContract(options.contract);
1287
- } catch (error) {
1288
- throw structuredError("CONTRACT.VALIDATION_FAILED", error instanceof Error ? error.message : String(error), { cause: error });
1289
- }
1290
- onProgress?.({
1291
- action: "schemaVerify",
1292
- kind: "spanStart",
1293
- spanId: "schemaVerify",
1294
- label: "Verifying database schema..."
1295
- });
1296
- try {
1297
- const schema = await familyInstance.introspect({
1298
- driver,
1299
- contract
1300
- });
1301
- const result = familyInstance.verifySchema({
1302
- contract,
1303
- schema,
1304
- strict: options.strict ?? false,
1305
- frameworkComponents
1306
- });
1307
- onProgress?.({
1308
- action: "schemaVerify",
1309
- kind: "spanEnd",
1310
- spanId: "schemaVerify",
1311
- outcome: result.ok ? "ok" : "error"
1312
- });
1313
- return result;
1314
- } catch (error) {
1315
- onProgress?.({
1316
- action: "schemaVerify",
1317
- kind: "spanEnd",
1318
- spanId: "schemaVerify",
1319
- outcome: "error"
1320
- });
1321
- throw error;
1322
- }
1323
- }
1324
- async sign(options) {
1325
- const { onProgress } = options;
1326
- await this.connectWithProgress(options.connection, "sign", onProgress);
1327
- const { driver, familyInstance } = await this.ensureConnected();
1328
- let contract;
1329
- try {
1330
- contract = familyInstance.deserializeContract(options.contract);
1331
- } catch (error) {
1332
- throw structuredError("CONTRACT.VALIDATION_FAILED", error instanceof Error ? error.message : String(error), { cause: error });
1333
- }
1334
- onProgress?.({
1335
- action: "sign",
1336
- kind: "spanStart",
1337
- spanId: "sign",
1338
- label: "Signing database..."
1339
- });
1340
- try {
1341
- const result = await familyInstance.sign({
1342
- driver,
1343
- contract,
1344
- contractPath: options.contractPath ?? "",
1345
- ...ifDefined("configPath", options.configPath)
1346
- });
1347
- onProgress?.({
1348
- action: "sign",
1349
- kind: "spanEnd",
1350
- spanId: "sign",
1351
- outcome: "ok"
1352
- });
1353
- return result;
1354
- } catch (error) {
1355
- onProgress?.({
1356
- action: "sign",
1357
- kind: "spanEnd",
1358
- spanId: "sign",
1359
- outcome: "error"
1360
- });
1361
- throw error;
1362
- }
1363
- }
1364
- async dbInit(options) {
1365
- const { onProgress } = options;
1366
- await this.connectWithProgress(options.connection, "dbInit", onProgress);
1367
- const { driver, familyInstance, frameworkComponents } = await this.ensureConnected();
1368
- if (!hasMigrations(this.options.target)) throw new CliStructuredError("MIGRATION.TARGET_UNSUPPORTED", `Target "${this.options.target.targetId}" does not support migrations`);
1369
- const adapter = this.buildControlAdapter();
1370
- let contract;
1371
- try {
1372
- contract = familyInstance.deserializeContract(options.contract);
1373
- } catch (error) {
1374
- throw structuredError("CONTRACT.VALIDATION_FAILED", error instanceof Error ? error.message : String(error), { cause: error });
1375
- }
1376
- return executeDbInit({
1377
- driver,
1378
- adapter,
1379
- familyInstance,
1380
- contract,
1381
- mode: options.mode,
1382
- migrations: this.options.target.migrations,
1383
- frameworkComponents,
1384
- migrationsDir: options.migrationsDir,
1385
- targetId: this.options.target.targetId,
1386
- extensions: this.options.extensions ?? [],
1387
- ...ifDefined("onProgress", onProgress)
1388
- });
1389
- }
1390
- async dbUpdate(options) {
1391
- const { onProgress } = options;
1392
- await this.connectWithProgress(options.connection, "dbUpdate", onProgress);
1393
- const { driver, familyInstance, frameworkComponents } = await this.ensureConnected();
1394
- if (!hasMigrations(this.options.target)) throw new CliStructuredError("MIGRATION.TARGET_UNSUPPORTED", `Target "${this.options.target.targetId}" does not support migrations`);
1395
- const adapter = this.buildControlAdapter();
1396
- let contract;
1397
- try {
1398
- contract = familyInstance.deserializeContract(options.contract);
1399
- } catch (error) {
1400
- throw structuredError("CONTRACT.VALIDATION_FAILED", error instanceof Error ? error.message : String(error), { cause: error });
1401
- }
1402
- return executeDbUpdate({
1403
- driver,
1404
- adapter,
1405
- familyInstance,
1406
- contract,
1407
- mode: options.mode,
1408
- migrations: this.options.target.migrations,
1409
- frameworkComponents,
1410
- migrationsDir: options.migrationsDir,
1411
- targetId: this.options.target.targetId,
1412
- extensions: this.options.extensions ?? [],
1413
- ...ifDefined("acceptDataLoss", options.acceptDataLoss),
1414
- ...ifDefined("consent", options.consent),
1415
- ...ifDefined("onProgress", onProgress)
1416
- });
1417
- }
1418
- async dbVerify(options) {
1419
- const { onProgress } = options;
1420
- await this.connectWithProgress(options.connection, "dbVerify", onProgress);
1421
- const { driver, familyInstance, frameworkComponents } = await this.ensureConnected();
1422
- return executeDbVerify({
1423
- driver,
1424
- familyInstance,
1425
- contract: options.contract,
1426
- migrationsDir: options.migrationsDir,
1427
- targetId: this.options.target.targetId,
1428
- extensions: this.options.extensions ?? [],
1429
- frameworkComponents,
1430
- mode: options.strict ? "strict" : "lenient",
1431
- skipSchema: options.skipSchema,
1432
- skipMarker: options.skipMarker,
1433
- ...ifDefined("onProgress", onProgress)
1434
- });
1435
- }
1436
- async readMarker() {
1437
- const { driver, familyInstance } = await this.ensureConnected();
1438
- return familyInstance.readMarker({
1439
- driver,
1440
- space: APP_SPACE_ID
1441
- });
1442
- }
1443
- async readAllMarkers() {
1444
- const { driver, familyInstance } = await this.ensureConnected();
1445
- return familyInstance.readAllMarkers({ driver });
1446
- }
1447
- /** Reads the per-migration journal; omit `space` to return every space. */
1448
- async readLedger(space) {
1449
- const { driver, familyInstance } = await this.ensureConnected();
1450
- return familyInstance.readLedger({
1451
- driver,
1452
- ...ifDefined("space", space)
1453
- });
1454
- }
1455
- async migrate(options) {
1456
- const { onProgress } = options;
1457
- await this.connectWithProgress(options.connection, "migrate", onProgress);
1458
- const { driver, familyInstance, frameworkComponents } = await this.ensureConnected();
1459
- if (!hasMigrations(this.options.target)) throw new CliStructuredError("MIGRATION.TARGET_UNSUPPORTED", `Target "${this.options.target.targetId}" does not support migrations`);
1460
- let contract;
1461
- try {
1462
- contract = familyInstance.deserializeContract(options.contract);
1463
- } catch (error) {
1464
- throw structuredError("CONTRACT.VALIDATION_FAILED", error instanceof Error ? error.message : String(error), { cause: error });
1465
- }
1466
- return executeMigrate({
1467
- driver,
1468
- familyInstance,
1469
- contract,
1470
- migrations: this.options.target.migrations,
1471
- frameworkComponents,
1472
- migrationsDir: options.migrationsDir,
1473
- extensions: this.options.extensions ?? [],
1474
- targetId: this.options.target.targetId,
1475
- ...ifDefined("refHash", options.refHash),
1476
- ...ifDefined("refInvariants", options.refInvariants),
1477
- ...ifDefined("refName", options.refName),
1478
- ...ifDefined("onProgress", onProgress)
1479
- });
1480
- }
1481
- async introspect(options) {
1482
- const onProgress = options?.onProgress;
1483
- await this.connectWithProgress(options?.connection, "introspect", onProgress);
1484
- const { driver, familyInstance } = await this.ensureConnected();
1485
- options?.schema;
1486
- onProgress?.({
1487
- action: "introspect",
1488
- kind: "spanStart",
1489
- spanId: "introspect",
1490
- label: "Introspecting database schema..."
1491
- });
1492
- try {
1493
- const result = await familyInstance.introspect({ driver });
1494
- onProgress?.({
1495
- action: "introspect",
1496
- kind: "spanEnd",
1497
- spanId: "introspect",
1498
- outcome: "ok"
1499
- });
1500
- return result;
1501
- } catch (error) {
1502
- onProgress?.({
1503
- action: "introspect",
1504
- kind: "spanEnd",
1505
- spanId: "introspect",
1506
- outcome: "error"
1507
- });
1508
- throw error;
1509
- }
1510
- }
1511
- toSchemaView(schemaIR) {
1512
- this.init();
1513
- if (this.familyInstance && hasSchemaView(this.familyInstance)) return this.familyInstance.toSchemaView(schemaIR);
1514
- }
1515
- inferPslContract(schemaIR) {
1516
- this.init();
1517
- if (this.familyInstance && hasPslContractInfer(this.familyInstance)) return this.familyInstance.inferPslContract(schemaIR);
1518
- }
1519
- getPslBlockDescriptors() {
1520
- this.init();
1521
- return this.stack.authoringContributions.pslBlockDescriptors;
1522
- }
1523
- toOperationPreview(operations) {
1524
- this.init();
1525
- if (this.familyInstance && hasOperationPreview(this.familyInstance)) return this.familyInstance.toOperationPreview(operations);
1526
- }
1527
- async emit(options) {
1528
- const { onProgress, contractConfig } = options;
1529
- this.init();
1530
- if (!this.familyInstance) throw new InternalError("Family instance was not initialized. This is a bug.");
1531
- let contractRaw;
1532
- onProgress?.({
1533
- action: "emit",
1534
- kind: "spanStart",
1535
- spanId: "resolveSource",
1536
- label: "Resolving contract source..."
1537
- });
1538
- try {
1539
- const stack = this.stack;
1540
- const sourceContext = {
1541
- composedExtensions: stack.extensions.map((p) => p.id),
1542
- composedExtensionContracts: stack.extensionContracts,
1543
- authoringContributions: stack.authoringContributions,
1544
- codecLookup: stack.codecLookup,
1545
- controlMutationDefaults: stack.controlMutationDefaults,
1546
- resolvedInputs: contractConfig.source.inputs ?? [],
1547
- capabilities: stack.capabilities
1548
- };
1549
- const providerResult = await contractConfig.source.load(sourceContext);
1550
- if (!providerResult.ok) {
1551
- onProgress?.({
1552
- action: "emit",
1553
- kind: "spanEnd",
1554
- spanId: "resolveSource",
1555
- outcome: "error"
1556
- });
1557
- return notOk({
1558
- code: "CONTRACT_SOURCE_INVALID",
1559
- summary: providerResult.failure.summary,
1560
- why: providerResult.failure.summary,
1561
- meta: providerResult.failure.meta,
1562
- diagnostics: providerResult.failure
1563
- });
1564
- }
1565
- contractRaw = providerResult.value;
1566
- onProgress?.({
1567
- action: "emit",
1568
- kind: "spanEnd",
1569
- spanId: "resolveSource",
1570
- outcome: "ok"
1571
- });
1572
- } catch (error) {
1573
- onProgress?.({
1574
- action: "emit",
1575
- kind: "spanEnd",
1576
- spanId: "resolveSource",
1577
- outcome: "error"
1578
- });
1579
- const message = error instanceof Error ? error.message : String(error);
1580
- return notOk({
1581
- code: "CONTRACT_SOURCE_INVALID",
1582
- summary: "Failed to resolve contract source",
1583
- why: message,
1584
- diagnostics: {
1585
- summary: "Contract source provider threw an exception",
1586
- diagnostics: [{
1587
- code: "PROVIDER_THROW",
1588
- message
1589
- }]
1590
- },
1591
- meta: void 0
1592
- });
1593
- }
1594
- onProgress?.({
1595
- action: "emit",
1596
- kind: "spanStart",
1597
- spanId: "emit",
1598
- label: "Emitting contract..."
1599
- });
1600
- try {
1601
- const enrichedIR = enrichContract(contractRaw, this.frameworkComponents ?? []);
1602
- const rawContractJson = this.options.target.contractSerializer.serializeContract(enrichedIR);
1603
- let deserializedContract;
1604
- try {
1605
- deserializedContract = this.familyInstance.deserializeContract(rawContractJson);
1606
- } catch (error) {
1607
- onProgress?.({
1608
- action: "emit",
1609
- kind: "spanEnd",
1610
- spanId: "emit",
1611
- outcome: "error"
1612
- });
1613
- return notOk({
1614
- code: "CONTRACT_VALIDATION_FAILED",
1615
- summary: "Contract validation failed",
1616
- why: error instanceof Error ? error.message : String(error),
1617
- meta: void 0
1618
- });
1619
- }
1620
- const result = await emit(deserializedContract, this.stack, this.options.family.emission, { serializeContract: (contract) => this.options.target.contractSerializer.serializeContract(contract) });
1621
- onProgress?.({
1622
- action: "emit",
1623
- kind: "spanEnd",
1624
- spanId: "emit",
1625
- outcome: "ok"
1626
- });
1627
- return ok({
1628
- storageHash: result.storageHash,
1629
- ...ifDefined("executionHash", result.executionHash),
1630
- profileHash: result.profileHash,
1631
- contractJson: result.contractJson,
1632
- contractDts: result.contractDts
1633
- });
1634
- } catch (error) {
1635
- onProgress?.({
1636
- action: "emit",
1637
- kind: "spanEnd",
1638
- spanId: "emit",
1639
- outcome: "error"
1640
- });
1641
- return notOk({
1642
- code: "EMIT_FAILED",
1643
- summary: "Failed to emit contract",
1644
- why: error instanceof Error ? error.message : String(error),
1645
- meta: void 0
1646
- });
1647
- }
1648
- }
1649
- };
1650
- //#endregion
1651
- export { planSpacePath as a, executeDbVerify as i, executeDbInit as n, executeDbUpdate as r, createControlClient as t };
1652
-
1653
- //# sourceMappingURL=client-C6Qp5ujC-Dxb7r79B.mjs.map