@prisma/orm-toolchain 8.0.0-rc.1-dev.6 → 8.0.0-rc.1-dev.7

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 (200) hide show
  1. package/dist/{aggregate-i-rfetSO.mjs → aggregate-D53gnb7v.mjs} +8 -8
  2. package/dist/{aggregate-i-rfetSO.mjs.map → aggregate-D53gnb7v.mjs.map} +1 -1
  3. package/dist/bin__prisma-next.mjs +22 -22
  4. package/dist/bin__prisma-next.mjs.map +1 -1
  5. package/dist/caught-errors-D7Qznyrm-BzYooF6H.mjs +14 -0
  6. package/dist/caught-errors-D7Qznyrm-BzYooF6H.mjs.map +1 -0
  7. package/dist/{types-2n_H3DQ9-Bks8UPEO.d.mts → cli-errors-CDr3WcJP-NFry5GHb.d.mts} +2 -2
  8. package/dist/cli-errors-CDr3WcJP-NFry5GHb.d.mts.map +1 -0
  9. package/dist/cli.mjs +2 -2
  10. package/dist/cli__commands__contract-emit.mjs +1 -1
  11. package/dist/cli__commands__contract-infer.mjs +1 -1
  12. package/dist/cli__commands__db-init.mjs +1 -1
  13. package/dist/cli__commands__db-schema.mjs +1 -1
  14. package/dist/cli__commands__db-sign.mjs +1 -1
  15. package/dist/cli__commands__db-update.mjs +1 -1
  16. package/dist/cli__commands__db-verify.mjs +1 -1
  17. package/dist/cli__commands__migrate.d.mts +3 -12
  18. package/dist/cli__commands__migrate.d.mts.map +1 -1
  19. package/dist/cli__commands__migrate.mjs +1 -1
  20. package/dist/cli__commands__migration-check.d.mts +1 -57
  21. package/dist/cli__commands__migration-check.d.mts.map +1 -1
  22. package/dist/cli__commands__migration-check.mjs +2 -2
  23. package/dist/cli__commands__migration-graph.d.mts +1 -1
  24. package/dist/cli__commands__migration-graph.mjs +1 -1
  25. package/dist/cli__commands__migration-list.d.mts +4 -44
  26. package/dist/cli__commands__migration-list.d.mts.map +1 -1
  27. package/dist/cli__commands__migration-list.mjs +2 -2
  28. package/dist/cli__commands__migration-log.d.mts +1 -1
  29. package/dist/cli__commands__migration-log.mjs +1 -1
  30. package/dist/cli__commands__migration-new.mjs +1 -1
  31. package/dist/cli__commands__migration-plan.d.mts +2 -47
  32. package/dist/cli__commands__migration-plan.d.mts.map +1 -1
  33. package/dist/cli__commands__migration-plan.mjs +1 -1
  34. package/dist/cli__commands__migration-show.mjs +1 -1
  35. package/dist/cli__commands__migration-status.d.mts +1 -1
  36. package/dist/cli__commands__migration-status.mjs +1 -1
  37. package/dist/cli__commands__ref.d.mts +1 -28
  38. package/dist/cli__commands__ref.d.mts.map +1 -1
  39. package/dist/cli__commands__ref.mjs +2 -2
  40. package/dist/cli__commands__telemetry.mjs +1 -1
  41. package/dist/cli__control-api.d.mts +502 -2
  42. package/dist/cli__control-api.d.mts.map +1 -1
  43. package/dist/cli__control-api.mjs +18 -3
  44. package/dist/cli__migration-cli.mjs +2 -2
  45. package/dist/{client-7aUYC7ci-Bh9mLxkl.mjs → client-Y6qbDk7X-BzKLmBZo.mjs} +8 -8
  46. package/dist/{client-7aUYC7ci-Bh9mLxkl.mjs.map → client-Y6qbDk7X-BzKLmBZo.mjs.map} +1 -1
  47. package/dist/{command-helpers-C4WpR-QE-CK2gkj6l.mjs → command-helpers-C4WpR-QE-DE494TSG.mjs} +2 -2
  48. package/dist/{command-helpers-C4WpR-QE-CK2gkj6l.mjs.map → command-helpers-C4WpR-QE-DE494TSG.mjs.map} +1 -1
  49. package/dist/config-loader.d.mts +2 -18
  50. package/dist/{contract-at-errors-YdCQ5OOk-okxG7Eaj.mjs → contract-at-errors-Dv1mxKYO-C29YB4RC.mjs} +4 -4
  51. package/dist/contract-at-errors-Dv1mxKYO-C29YB4RC.mjs.map +1 -0
  52. package/dist/{contract-emit-CTm2zfuG-8mtkxW8M.mjs → contract-emit-CTm2zfuG-7PV9SBY6.mjs} +4 -4
  53. package/dist/{contract-emit-CTm2zfuG-8mtkxW8M.mjs.map → contract-emit-CTm2zfuG-7PV9SBY6.mjs.map} +1 -1
  54. package/dist/{contract-emit-D8IXP9Qp-CecAQio1.mjs → contract-emit-D8IXP9Qp-Df6NwXn8.mjs} +3 -3
  55. package/dist/{contract-emit-D8IXP9Qp-CecAQio1.mjs.map → contract-emit-D8IXP9Qp-Df6NwXn8.mjs.map} +1 -1
  56. package/dist/{contract-infer-C8-RqHeK-D_dm3onP.mjs → contract-infer-BwT7ngoo-Dx6aAwIN.mjs} +4 -4
  57. package/dist/{contract-infer-C8-RqHeK-D_dm3onP.mjs.map → contract-infer-BwT7ngoo-Dx6aAwIN.mjs.map} +1 -1
  58. package/dist/contract-snapshot-resolution-SATuw0JW-CsYq7g_n.mjs +82 -0
  59. package/dist/contract-snapshot-resolution-SATuw0JW-CsYq7g_n.mjs.map +1 -0
  60. package/dist/{contract-snapshot-store-DNTOE6fB-BDpjbdCJ.mjs → contract-snapshot-store-C9-J6OBn-ByElY0EC.mjs} +3 -3
  61. package/dist/{contract-snapshot-store-DNTOE6fB-BDpjbdCJ.mjs.map → contract-snapshot-store-C9-J6OBn-ByElY0EC.mjs.map} +1 -1
  62. package/dist/{contract-space-aggregate-loader-CziO_ZRW-DIoQOL0P.mjs → contract-space-aggregate-loader-C5r12INu-Db_pa3rX.mjs} +6 -6
  63. package/dist/contract-space-aggregate-loader-C5r12INu-Db_pa3rX.mjs.map +1 -0
  64. package/dist/{db-init-CXMcvoIA.mjs → db-init-CBj_EWg3.mjs} +15 -26
  65. package/dist/db-init-CBj_EWg3.mjs.map +1 -0
  66. package/dist/{db-schema-j8DERh4t.mjs → db-schema-BWpeh0Q_.mjs} +4 -4
  67. package/dist/{db-schema-j8DERh4t.mjs.map → db-schema-BWpeh0Q_.mjs.map} +1 -1
  68. package/dist/{db-sign-xV_rpoIc.mjs → db-sign-DCb_DKtv.mjs} +13 -29
  69. package/dist/db-sign-DCb_DKtv.mjs.map +1 -0
  70. package/dist/{db-update-DXa2DIvu.mjs → db-update-WX0KitcX.mjs} +27 -50
  71. package/dist/db-update-WX0KitcX.mjs.map +1 -0
  72. package/dist/{db-verify-YWHjuKC7-DidK1gx1.mjs → db-verify-B8ax2Y_x-Bp4s5Ra6.mjs} +5 -5
  73. package/dist/{db-verify-YWHjuKC7-DidK1gx1.mjs.map → db-verify-B8ax2Y_x-Bp4s5Ra6.mjs.map} +1 -1
  74. package/dist/{errors-BwusfLIN-BXM7K-ww.mjs → errors-Co-8oaiB-CB-6Uqki.mjs} +5 -4
  75. package/dist/{errors-BwusfLIN-BXM7K-ww.mjs.map → errors-Co-8oaiB-CB-6Uqki.mjs.map} +1 -1
  76. package/dist/{errors-AkMBj-YP.d.mts → errors-NRmFpwR1.d.mts} +6 -2
  77. package/dist/errors-NRmFpwR1.d.mts.map +1 -0
  78. package/dist/{format-Bw3LVJ1v-D10inUT9.mjs → format-Bw3LVJ1v-BJ6lVFMA.mjs} +2 -2
  79. package/dist/{format-Bw3LVJ1v-D10inUT9.mjs.map → format-Bw3LVJ1v-BJ6lVFMA.mjs.map} +1 -1
  80. package/dist/{framework-components-3DdB31mk-BPGSuOyZ.mjs → framework-components-3DdB31mk-BHyX-OlJ.mjs} +2 -2
  81. package/dist/{framework-components-3DdB31mk-BPGSuOyZ.mjs.map → framework-components-3DdB31mk-BHyX-OlJ.mjs.map} +1 -1
  82. package/dist/{graph-membership-h9ejuZla-ewjYM5wz.mjs → graph-membership-BEmNEMtP-rz61CLM5.mjs} +3 -3
  83. package/dist/{graph-membership-h9ejuZla-ewjYM5wz.mjs.map → graph-membership-BEmNEMtP-rz61CLM5.mjs.map} +1 -1
  84. package/dist/index-Df9igRvP.d.mts +18 -0
  85. package/dist/index-Df9igRvP.d.mts.map +1 -0
  86. package/dist/{init-CPB89WK2-Di4kgP6B.mjs → init-CPB89WK2-DPZRZ9Ee.mjs} +3 -3
  87. package/dist/{init-CPB89WK2-Di4kgP6B.mjs.map → init-CPB89WK2-DPZRZ9Ee.mjs.map} +1 -1
  88. package/dist/{inspect-live-schema-DEYE4EHW-DmSfKdpv.mjs → inspect-live-schema-Da76TWOs-CAFqkhGb.mjs} +4 -4
  89. package/dist/{inspect-live-schema-DEYE4EHW-DmSfKdpv.mjs.map → inspect-live-schema-Da76TWOs-CAFqkhGb.mjs.map} +1 -1
  90. package/dist/invariants-BzYfO9IL-BXTvx0z9.mjs +52 -0
  91. package/dist/invariants-BzYfO9IL-BXTvx0z9.mjs.map +1 -0
  92. package/dist/{invariants-CMcQxRas-CXX9uhQW.mjs → invariants-C1WVUAH7-DlOBTTkM.mjs} +3 -3
  93. package/dist/{invariants-CMcQxRas-CXX9uhQW.mjs.map → invariants-C1WVUAH7-DlOBTTkM.mjs.map} +1 -1
  94. package/dist/{io-CL3hSv42-DGZtTs89.mjs → io-CHUUeHh0-CoCBe9eN.mjs} +5 -5
  95. package/dist/{io-CL3hSv42-DGZtTs89.mjs.map → io-CHUUeHh0-CoCBe9eN.mjs.map} +1 -1
  96. package/dist/legend-5iwwlLU2-CB8bdQKJ.mjs +22 -0
  97. package/dist/legend-5iwwlLU2-CB8bdQKJ.mjs.map +1 -0
  98. package/dist/{migrate-COusRrm7.mjs → migrate-B-NAuO90.mjs} +87 -230
  99. package/dist/migrate-B-NAuO90.mjs.map +1 -0
  100. package/dist/migrate-show-60NNqVia-oGqMaVA9.d.mts +56 -0
  101. package/dist/migrate-show-60NNqVia-oGqMaVA9.d.mts.map +1 -0
  102. package/dist/migrate-show-B2LkXkoB-D1ZNl84C.mjs +202 -0
  103. package/dist/migrate-show-B2LkXkoB-D1ZNl84C.mjs.map +1 -0
  104. package/dist/{migration-diUAhNaa.mjs → migration-DAJY-NmR.mjs} +3 -3
  105. package/dist/{migration-diUAhNaa.mjs.map → migration-DAJY-NmR.mjs.map} +1 -1
  106. package/dist/migration-check-BDjtAn7x-B0nEBR0k.mjs +254 -0
  107. package/dist/migration-check-BDjtAn7x-B0nEBR0k.mjs.map +1 -0
  108. package/dist/{migration-check-CueEJelQ-J81XR_ns.mjs → migration-check-DONPyXff-CGTUpLv-.mjs} +12 -254
  109. package/dist/migration-check-DONPyXff-CGTUpLv-.mjs.map +1 -0
  110. package/dist/{migration-command-scaffold-DNRo4exb-9JCezdoT.mjs → migration-command-scaffold-BPqXPCFV-Bls2Wwg7.mjs} +4 -4
  111. package/dist/{migration-command-scaffold-DNRo4exb-9JCezdoT.mjs.map → migration-command-scaffold-BPqXPCFV-Bls2Wwg7.mjs.map} +1 -1
  112. package/dist/{migration-graph-D6bN-mX0-DwMWY8DA.mjs → migration-graph-DDaOHo10-yJFAbKCu.mjs} +3 -3
  113. package/dist/{migration-graph-D6bN-mX0-DwMWY8DA.mjs.map → migration-graph-DDaOHo10-yJFAbKCu.mjs.map} +1 -1
  114. package/dist/{migration-graph-BL6vfLcE.mjs → migration-graph-Dn469b0l.mjs} +10 -19
  115. package/dist/migration-graph-Dn469b0l.mjs.map +1 -0
  116. package/dist/migration-graph-HKch1Xk4-DyWhXtjZ.mjs +35 -0
  117. package/dist/migration-graph-HKch1Xk4-DyWhXtjZ.mjs.map +1 -0
  118. package/dist/migration-list-C9OPCMt--C28yBgVr.mjs +102 -0
  119. package/dist/migration-list-C9OPCMt--C28yBgVr.mjs.map +1 -0
  120. package/dist/migration-list-jk4iCtmO.mjs +120 -0
  121. package/dist/migration-list-jk4iCtmO.mjs.map +1 -0
  122. package/dist/{migration-log-BXbz6-Lj-CKHbat5f.mjs → migration-log-DQzUBrm8-D3m9wcuf.mjs} +7 -5
  123. package/dist/migration-log-DQzUBrm8-D3m9wcuf.mjs.map +1 -0
  124. package/dist/migration-new-BkSY6m0t.mjs +50 -0
  125. package/dist/migration-new-BkSY6m0t.mjs.map +1 -0
  126. package/dist/{migration-new-szZFsA3C.mjs → migration-new-g98oB3nC-BcrkxAAt.mjs} +12 -52
  127. package/dist/migration-new-g98oB3nC-BcrkxAAt.mjs.map +1 -0
  128. package/dist/{migration-path-target-BPYp3LNc-qRQlG_Yn.mjs → migration-path-target-BPYp3LNc-DsDdLU0J.mjs} +2 -2
  129. package/dist/{migration-path-target-BPYp3LNc-qRQlG_Yn.mjs.map → migration-path-target-BPYp3LNc-DsDdLU0J.mjs.map} +1 -1
  130. package/dist/migration-plan-BsOYRogP-CC1UFAbu.d.mts +159 -0
  131. package/dist/migration-plan-BsOYRogP-CC1UFAbu.d.mts.map +1 -0
  132. package/dist/migration-plan-CjIYMJZy.mjs +172 -0
  133. package/dist/migration-plan-CjIYMJZy.mjs.map +1 -0
  134. package/dist/{migration-plan-CxXAXYc8-Dnp-v8Nl.mjs → migration-plan-CwuZLXVE-DAJ-JUQT.mjs} +45 -183
  135. package/dist/migration-plan-CwuZLXVE-DAJ-JUQT.mjs.map +1 -0
  136. package/dist/{migration-show-BKsIh7Uz.mjs → migration-show-CW6EKtfw.mjs} +13 -9
  137. package/dist/migration-show-CW6EKtfw.mjs.map +1 -0
  138. package/dist/{migration-status-CNnRInne--cvmx56T.mjs → migration-status-DSQcBhiN.mjs} +37 -68
  139. package/dist/migration-status-DSQcBhiN.mjs.map +1 -0
  140. package/dist/migration-tools.d.mts +4 -4
  141. package/dist/migration-tools.mjs +13 -13
  142. package/dist/migration-tools__aggregate.mjs +1 -1
  143. package/dist/migration-tools__contract-snapshot-store.mjs +1 -1
  144. package/dist/migration-tools__errors.d.mts +2 -2
  145. package/dist/migration-tools__errors.mjs +2 -2
  146. package/dist/migration-tools__invariants.mjs +1 -1
  147. package/dist/migration-tools__io.mjs +1 -1
  148. package/dist/migration-tools__migration-graph.mjs +2 -2
  149. package/dist/migration-tools__migration.mjs +1 -1
  150. package/dist/migration-tools__ref-resolution.mjs +1 -1
  151. package/dist/migration-tools__refs.mjs +1 -1
  152. package/dist/migration-tools__spaces.mjs +2 -2
  153. package/dist/{project-import-root-C_bd0ooL-CLXW-gp6.mjs → project-import-root-C_bd0ooL-WkbJLnAA.mjs} +2 -2
  154. package/dist/{project-import-root-C_bd0ooL-CLXW-gp6.mjs.map → project-import-root-C_bd0ooL-WkbJLnAA.mjs.map} +1 -1
  155. package/dist/ref-DSAZime8.mjs +72 -0
  156. package/dist/ref-DSAZime8.mjs.map +1 -0
  157. package/dist/ref-advancement-DaZBzm7m-BZQtedYC.mjs +96 -0
  158. package/dist/ref-advancement-DaZBzm7m-BZQtedYC.mjs.map +1 -0
  159. package/dist/ref-eJjxzYTh-CNiyDL4p.mjs +109 -0
  160. package/dist/ref-eJjxzYTh-CNiyDL4p.mjs.map +1 -0
  161. package/dist/{ref-resolution-BsdziDFA.mjs → ref-resolution-Ct2GMcNB.mjs} +2 -2
  162. package/dist/{ref-resolution-BsdziDFA.mjs.map → ref-resolution-Ct2GMcNB.mjs.map} +1 -1
  163. package/dist/ref-resolution-_S4xTT2L-BE5zgO2W.mjs +16 -0
  164. package/dist/ref-resolution-_S4xTT2L-BE5zgO2W.mjs.map +1 -0
  165. package/dist/{refs-DtoeUivZ-qay0UMSP.mjs → refs-B2BL8z3i-DGGFB7Mj.mjs} +3 -3
  166. package/dist/{refs-DtoeUivZ-qay0UMSP.mjs.map → refs-B2BL8z3i-DGGFB7Mj.mjs.map} +1 -1
  167. package/dist/refs-fQLFcMoq-UTlvnijY.mjs +47 -0
  168. package/dist/refs-fQLFcMoq-UTlvnijY.mjs.map +1 -0
  169. package/dist/{spaces-BNd2Tlk0.mjs → spaces-DxuvClN9.mjs} +6 -6
  170. package/dist/{spaces-BNd2Tlk0.mjs.map → spaces-DxuvClN9.mjs.map} +1 -1
  171. package/dist/{telemetry-DVBHDQd6-BEdoMii0.mjs → telemetry-DVBHDQd6-Ckn5oClN.mjs} +2 -2
  172. package/dist/{telemetry-DVBHDQd6-BEdoMii0.mjs.map → telemetry-DVBHDQd6-Ckn5oClN.mjs.map} +1 -1
  173. package/dist/{verify-C6L_hiJU-CN3eEe3Y.mjs → verify-C6L_hiJU-B4V3bqvG.mjs} +2 -2
  174. package/dist/{verify-C6L_hiJU-CN3eEe3Y.mjs.map → verify-C6L_hiJU-B4V3bqvG.mjs.map} +1 -1
  175. package/dist/{verify-contract-spaces-Ak73-zQK-y4qVyu-y.mjs → verify-contract-spaces-WvjSiWcB-zGhaCnfs.mjs} +4 -4
  176. package/dist/{verify-contract-spaces-Ak73-zQK-y4qVyu-y.mjs.map → verify-contract-spaces-WvjSiWcB-zGhaCnfs.mjs.map} +1 -1
  177. package/dist/vite-plugin-contract-emit.mjs +1 -1
  178. package/package.json +12 -12
  179. package/dist/config-loader.d.mts.map +0 -1
  180. package/dist/contract-at-errors-YdCQ5OOk-okxG7Eaj.mjs.map +0 -1
  181. package/dist/contract-space-aggregate-loader-CziO_ZRW-DIoQOL0P.mjs.map +0 -1
  182. package/dist/db-init-CXMcvoIA.mjs.map +0 -1
  183. package/dist/db-sign-xV_rpoIc.mjs.map +0 -1
  184. package/dist/db-update-DXa2DIvu.mjs.map +0 -1
  185. package/dist/errors-AkMBj-YP.d.mts.map +0 -1
  186. package/dist/migrate-COusRrm7.mjs.map +0 -1
  187. package/dist/migration-check-CueEJelQ-J81XR_ns.mjs.map +0 -1
  188. package/dist/migration-graph-BL6vfLcE.mjs.map +0 -1
  189. package/dist/migration-list-D2_JdzWC-MRHYYVQE.mjs +0 -228
  190. package/dist/migration-list-D2_JdzWC-MRHYYVQE.mjs.map +0 -1
  191. package/dist/migration-log-BXbz6-Lj-CKHbat5f.mjs.map +0 -1
  192. package/dist/migration-new-szZFsA3C.mjs.map +0 -1
  193. package/dist/migration-plan-CxXAXYc8-Dnp-v8Nl.mjs.map +0 -1
  194. package/dist/migration-show-BKsIh7Uz.mjs.map +0 -1
  195. package/dist/migration-status-CNnRInne--cvmx56T.mjs.map +0 -1
  196. package/dist/ref-DjZ5Y8ju.mjs +0 -171
  197. package/dist/ref-DjZ5Y8ju.mjs.map +0 -1
  198. package/dist/ref-advancement-CSPMoQs3-CPkL3IFF.mjs +0 -57
  199. package/dist/ref-advancement-CSPMoQs3-CPkL3IFF.mjs.map +0 -1
  200. package/dist/types-2n_H3DQ9-Bks8UPEO.d.mts.map +0 -1
@@ -1,130 +1,23 @@
1
- import { t as MigrationToolsError } from "./errors-BwusfLIN-BXM7K-ww.mjs";
2
- import { r as readContractSnapshotJson, t as contractSnapshotDir } from "./contract-snapshot-store-DNTOE6fB-BDpjbdCJ.mjs";
1
+ import { t as MigrationToolsError } from "./errors-Co-8oaiB-CB-6Uqki.mjs";
2
+ import { r as readContractSnapshotJson, t as contractSnapshotDir } from "./contract-snapshot-store-C9-J6OBn-ByElY0EC.mjs";
3
3
  import { n as verifyMigrationHash } from "./hash-DH8hl5Rq-BpM2t3Nu.mjs";
4
4
  import "./constants-CM-w38DQ-Cz_EXbOc.mjs";
5
- import { a as isValidSpaceId, c as spaceMigrationDirectory, l as spaceRefsDirectory, o as listContractSpaceDirectories } from "./verify-contract-spaces-Ak73-zQK-y4qVyu-y.mjs";
6
- import { A as errorSpaceNotFound, I as formatErrorJson, L as formatErrorOutput, W as formatStyledHeader, Z as mapRefResolutionError, _ as errorInvalidSpaceId, c as errorAmbiguousMigrationRef, ct as setCommandSeeAlso, et as parseGlobalFlagsOrExit, it as resolveMigrationPaths, o as createTerminalUI, ot as setCommandDescriptions, r as addGlobalOptions, rt as resolveContractPath, st as setCommandExamples } from "./command-helpers-C4WpR-QE-CK2gkj6l.mjs";
7
- import { r as loadConfig } from "./exports-CDX9kZuw.mjs";
8
- import { s as loadContractSpaceAggregate } from "./aggregate-i-rfetSO.mjs";
9
- import { n as buildReadAggregate, s as toDeclaredExtensionsFromRaw } from "./contract-space-aggregate-loader-CziO_ZRW-DIoQOL0P.mjs";
10
- import { r as parseMigrationRef } from "./ref-resolution-BsdziDFA.mjs";
11
- import { i as resolveTargetPathAcrossSpaces, n as looksLikePath, r as resolveAppTargetPath, t as findPackageByDirPath } from "./migration-path-target-BPYp3LNc-qRQlG_Yn.mjs";
5
+ import { a as isValidSpaceId, c as spaceMigrationDirectory, l as spaceRefsDirectory, o as listContractSpaceDirectories } from "./verify-contract-spaces-WvjSiWcB-zGhaCnfs.mjs";
6
+ import { A as errorSpaceNotFound, Z as mapRefResolutionError, _ as errorInvalidSpaceId, c as errorAmbiguousMigrationRef, rt as resolveContractPath } from "./command-helpers-C4WpR-QE-DE494TSG.mjs";
7
+ import { s as loadContractSpaceAggregate } from "./aggregate-D53gnb7v.mjs";
8
+ import { u as toDeclaredExtensionsFromRaw } from "./contract-space-aggregate-loader-C5r12INu-Db_pa3rX.mjs";
9
+ import { r as parseMigrationRef } from "./ref-resolution-Ct2GMcNB.mjs";
10
+ import { i as resolveTargetPathAcrossSpaces, n as looksLikePath, r as resolveAppTargetPath, t as findPackageByDirPath } from "./migration-path-target-BPYp3LNc-DsDdLU0J.mjs";
12
11
  import { ifDefined } from "@prisma/orm-framework/utils/defined";
13
12
  import { notOk, ok } from "@prisma/orm-framework/utils/result";
14
13
  import { join, relative } from "pathe";
15
14
  import { readFile } from "node:fs/promises";
16
15
  import { createControlStack } from "@prisma/orm-framework/components/control";
17
16
  import { existsSync, readdirSync, statSync } from "node:fs";
18
- import { Command } from "commander";
19
- //#region ../../../1-framework/3-tooling/cli/dist/migration-check-CueEJelQ.mjs
20
- function migrationPathRelative$1(dirPath) {
21
- return relative(process.cwd(), dirPath);
22
- }
23
- function migrationFileRelative$1(dirPath, fileName) {
24
- return join(migrationPathRelative$1(dirPath), fileName);
25
- }
17
+ //#region ../../../1-framework/3-tooling/cli/dist/migration-check-DONPyXff.mjs
26
18
  /**
27
- * Map one {@link IntegrityViolation} onto a `migration check` failure row.
28
- * Sole catalogue mapping from integrity violations to `MIGRATION.CHECK_*` codes.
19
+ * Policy core of `migration check`: per-space explicit graph checks, aggregate-integrity loading, and single-target resolution.
29
20
  */
30
- function integrityViolationToCheckFailure(violation, migrationsDir) {
31
- const spaceRelative = (spaceId) => migrationPathRelative$1(join(migrationsDir, spaceId));
32
- const packageRelative = (spaceId, dirName) => migrationPathRelative$1(join(migrationsDir, spaceId, dirName));
33
- const refRelative = (spaceId, refName) => migrationPathRelative$1(join(migrationsDir, spaceId, "refs", `${refName}.json`));
34
- switch (violation.kind) {
35
- case "hashMismatch": return {
36
- space: violation.spaceId,
37
- code: "MIGRATION.CHECK_HASH_MISMATCH",
38
- where: migrationFileRelative$1(join(migrationsDir, violation.spaceId, violation.dirName), "migration.json"),
39
- why: `Stored hash ${violation.stored} does not match recomputed hash ${violation.computed}`,
40
- fix: "Re-emit the migration package or restore from version control."
41
- };
42
- case "providedInvariantsMismatch": return {
43
- space: violation.spaceId,
44
- code: "MIGRATION.CHECK_PROVIDED_INVARIANTS_MISMATCH",
45
- where: packageRelative(violation.spaceId, violation.dirName),
46
- why: `Migration "${violation.dirName}" providedInvariants in migration.json disagrees with ops.json.`,
47
- fix: "Re-emit the migration package so migration.json and ops.json agree."
48
- };
49
- case "packageUnloadable": return {
50
- space: violation.spaceId,
51
- code: "MIGRATION.CHECK_PACKAGE_UNLOADABLE",
52
- where: packageRelative(violation.spaceId, violation.dirName),
53
- why: `Migration "${violation.dirName}" could not be loaded: ${violation.detail}`,
54
- fix: "Re-emit the migration package or restore from version control."
55
- };
56
- case "sameSourceAndTarget": return {
57
- space: violation.spaceId,
58
- code: "MIGRATION.CHECK_NOOP_SELF_EDGE",
59
- where: packageRelative(violation.spaceId, violation.dirName),
60
- why: `Migration "${violation.dirName}" in space "${violation.spaceId}" has source equal to target (${violation.hash}) with no data invariant — a true no-op self-edge.`,
61
- fix: "Add a data operation if this self-edge was meant to carry a data invariant, or delete the migration if it is a true no-op."
62
- };
63
- case "orphanSpaceDir": return {
64
- space: violation.spaceId,
65
- code: "MIGRATION.CHECK_ORPHAN_SPACE_DIR",
66
- where: spaceRelative(violation.spaceId),
67
- why: `Contract-space directory "${violation.spaceId}" exists on disk but no extension declares it.`,
68
- fix: "Remove the orphan directory, or declare the extension in `extensions`."
69
- };
70
- case "declaredButUnmigrated": return {
71
- space: violation.spaceId,
72
- code: "MIGRATION.CHECK_DECLARED_BUT_UNMIGRATED",
73
- where: spaceRelative(violation.spaceId),
74
- why: `Extension "${violation.spaceId}" is declared in \`extensions\` but has no on-disk migrations directory.`,
75
- fix: "Re-emit the extension contract-space artefacts with `prisma-next contract emit` and migration planning, or remove the extension from `extensions` if it is unused."
76
- };
77
- case "headRefMissing": return {
78
- space: violation.spaceId,
79
- code: "MIGRATION.CHECK_HEAD_REF_MISSING",
80
- where: refRelative(violation.spaceId, "head"),
81
- why: `Head ref \`refs/head.json\` is missing for contract space "${violation.spaceId}".`,
82
- fix: "Re-emit the contract-space migrations and head ref artefacts, or restore `refs/head.json` from version control."
83
- };
84
- case "headRefNotInGraph": return {
85
- space: violation.spaceId,
86
- code: "MIGRATION.CHECK_HEAD_REF_NOT_IN_GRAPH",
87
- where: refRelative(violation.spaceId, "head"),
88
- why: `Head ref ${violation.hash} for contract space "${violation.spaceId}" is not present in its migration graph.`,
89
- fix: "Re-emit the contract space migrations, or restore the missing migration package."
90
- };
91
- case "refUnreadable": return {
92
- space: violation.spaceId,
93
- code: "MIGRATION.CHECK_REF_UNREADABLE",
94
- where: refRelative(violation.spaceId, violation.refName),
95
- why: `Ref "${violation.refName}" for contract space "${violation.spaceId}" is unreadable: ${violation.detail}`,
96
- fix: "Repair or remove the corrupt ref file."
97
- };
98
- case "targetMismatch": return {
99
- space: violation.spaceId,
100
- code: "MIGRATION.CHECK_TARGET_MISMATCH",
101
- where: spaceRelative(violation.spaceId),
102
- why: `Contract space "${violation.spaceId}" targets "${violation.actual}" but the project targets "${violation.expected}".`,
103
- fix: "Update the extension to target the configured database, or change the project target."
104
- };
105
- case "disjointness": return {
106
- space: "app",
107
- code: "MIGRATION.CHECK_SPACE_DISJOINTNESS_VIOLATION",
108
- where: migrationPathRelative$1(migrationsDir),
109
- why: `Storage element "${violation.element}" is claimed by multiple contract spaces: ${violation.claimedBy.join(", ")}.`,
110
- fix: "Update the contracts so each storage element is owned by exactly one contract space."
111
- };
112
- case "contractUnreadable": return {
113
- space: violation.spaceId,
114
- code: "MIGRATION.CHECK_CONTRACT_UNREADABLE",
115
- where: migrationFileRelative$1(join(migrationsDir, violation.spaceId), "contract.json"),
116
- why: `Contract for space "${violation.spaceId}" is unreadable: ${violation.detail}`,
117
- fix: "Re-emit the extension contract artefacts, or fix the descriptor producing the invalid contract."
118
- };
119
- case "duplicateMigrationHash": return {
120
- space: violation.spaceId,
121
- code: "MIGRATION.CHECK_DUPLICATE_MIGRATION_HASH",
122
- where: spaceRelative(violation.spaceId),
123
- why: `Multiple migrations in space "${violation.spaceId}" share migrationHash "${violation.migrationHash}" (${violation.dirNames.join(", ")}).`,
124
- fix: "Re-emit one of the conflicting packages so each migrationHash is unique."
125
- };
126
- }
127
- }
128
21
  function migrationPathRelative(dirPath) {
129
22
  return relative(process.cwd(), dirPath);
130
23
  }
@@ -318,70 +211,6 @@ async function loadAggregateIntegrityViolations(config, migrationsDir) {
318
211
  return [];
319
212
  }
320
213
  }
321
- async function executeMigrationCheckCommand(target, options, flags, ui) {
322
- const config = await loadConfig(options.config);
323
- const { configPath, migrationsDir, appMigrationsDir, appMigrationsRelative } = resolveMigrationPaths(options.config, config);
324
- if (!flags.json && !flags.quiet) {
325
- const details = [{
326
- label: "config",
327
- value: configPath
328
- }, {
329
- label: "migrations",
330
- value: appMigrationsRelative
331
- }];
332
- if (target) details.push({
333
- label: "target",
334
- value: target
335
- });
336
- const header = formatStyledHeader({
337
- command: "migration check",
338
- description: "Verify artifact and graph integrity",
339
- details,
340
- flags
341
- });
342
- ui.stderr(header);
343
- }
344
- const loadedAggregate = await buildReadAggregate(config, { migrationsDir });
345
- if (!loadedAggregate.ok) return {
346
- error: loadedAggregate.failure,
347
- exitCode: 2
348
- };
349
- const spaces = await enumerateCheckSpaces(loadedAggregate.value.aggregate, migrationsDir);
350
- if (target) return await checkSingleTarget(target, {
351
- spaces,
352
- ...options.space !== void 0 ? { spaceFilter: options.space } : {},
353
- appMigrationsDir,
354
- appMigrationsRelative
355
- });
356
- const checkResult = await runMigrationCheck({
357
- spaces,
358
- ...options.space !== void 0 ? { spaceFilter: options.space } : {}
359
- });
360
- if (!checkResult.ok) return {
361
- error: checkResult.failure,
362
- exitCode: 2
363
- };
364
- const failures = [...checkResult.value.failures];
365
- const allViolations = await loadAggregateIntegrityViolations(config, migrationsDir);
366
- const scopedViolations = options.space === void 0 ? allViolations : allViolations.filter((v) => v.kind !== "disjointness" && v.spaceId === options.space);
367
- for (const violation of scopedViolations) failures.push(integrityViolationToCheckFailure(violation, migrationsDir));
368
- if (failures.length === 0) return {
369
- result: {
370
- ok: true,
371
- failures: [],
372
- summary: "All checks passed"
373
- },
374
- exitCode: 0
375
- };
376
- return {
377
- result: {
378
- ok: false,
379
- failures,
380
- summary: `${failures.length} integrity failure(s)`
381
- },
382
- exitCode: 4
383
- };
384
- }
385
214
  /**
386
215
  * Ranks ref-resolution failure kinds by how informative they are, so a
387
216
  * single-target check surfaces the most useful failure across spaces instead of
@@ -520,78 +349,7 @@ async function checkSingleTarget(target, inputs) {
520
349
  ...ifDefined("resolvedSpaceId", resolvedSpaceId)
521
350
  };
522
351
  }
523
- function createMigrationCheckCommand() {
524
- const command = new Command("check");
525
- setCommandDescriptions(command, "Verify artifact and graph integrity", "Validates that on-disk migration packages are internally consistent\n(hashes match, manifests are complete) and that the graph is well-formed\n(edges connect, refs point at valid nodes). The whole-graph check spans\nevery contract space by default; pass --space <id> to narrow to one. A\nmigration reference checks a single package, resolved across all contract\nspaces (narrow with --space; an ambiguous reference is a precondition failure).\nOffline — does not consult the database.\nExit codes: 0 = all checks passed, 2 = precondition failed\n(unresolved target or unknown --space), 4 = integrity failure(s) found.");
526
- setCommandExamples(command, [
527
- "prisma-next migration check",
528
- "prisma-next migration check --space app",
529
- "prisma-next migration check 20260101-add-users",
530
- "prisma-next migration check 20260101-add-users --space app",
531
- "prisma-next migration check --json"
532
- ]);
533
- setCommandSeeAlso(command, [
534
- {
535
- verb: "migration status",
536
- oneLiner: "Show migration path and pending status"
537
- },
538
- {
539
- verb: "migration list",
540
- oneLiner: "List on-disk migrations"
541
- },
542
- {
543
- verb: "migration graph",
544
- oneLiner: "Show the migration graph topology"
545
- },
546
- {
547
- verb: "migration show",
548
- oneLiner: "Display migration package contents"
549
- }
550
- ]);
551
- command.exitOverride();
552
- addGlobalOptions(command).argument("[target]", "Migration reference: directory name, hash/prefix, ref, or path").option("--config <path>", "Path to prisma-next.config.ts").option("--space <id>", "Narrow output to a single contract space").action(async (target, options) => {
553
- const flags = parseGlobalFlagsOrExit(options);
554
- const ui = createTerminalUI(flags);
555
- let outcome;
556
- try {
557
- outcome = await executeMigrationCheckCommand(target, options, flags, ui);
558
- } catch (error) {
559
- outcome = {
560
- result: {
561
- ok: false,
562
- failures: [],
563
- summary: error instanceof Error ? error.message : String(error)
564
- },
565
- exitCode: 2
566
- };
567
- }
568
- if (outcome.error) {
569
- const envelope = outcome.error.toEnvelope();
570
- if (flags.json) ui.output(formatErrorJson(envelope));
571
- else if (!flags.quiet) ui.error(formatErrorOutput(envelope, flags));
572
- process.exit(outcome.exitCode);
573
- }
574
- const result = outcome.result ?? {
575
- ok: false,
576
- failures: [],
577
- summary: "No check result produced"
578
- };
579
- if (flags.json) ui.output(JSON.stringify(result, null, 2));
580
- else if (!flags.quiet) if (result.ok) {
581
- const spaceSuffix = outcome.resolvedSpaceId !== void 0 ? ` (space: ${outcome.resolvedSpaceId})` : "";
582
- ui.log(`✔ ${result.summary}${spaceSuffix}`);
583
- } else {
584
- for (const f of result.failures) {
585
- ui.log(`✗ [${f.code}] ${f.where}: ${f.why}`);
586
- ui.log(` fix: ${f.fix}`);
587
- }
588
- ui.log(`\n${result.summary}`);
589
- }
590
- process.exit(outcome.exitCode);
591
- });
592
- return command;
593
- }
594
352
  //#endregion
595
- export { enumerateCheckSpaces as n, runMigrationCheck as r, createMigrationCheckCommand as t };
353
+ export { runMigrationCheck as i, enumerateCheckSpaces as n, loadAggregateIntegrityViolations as r, checkSingleTarget as t };
596
354
 
597
- //# sourceMappingURL=migration-check-CueEJelQ-J81XR_ns.mjs.map
355
+ //# sourceMappingURL=migration-check-DONPyXff-CGTUpLv-.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migration-check-DONPyXff-CGTUpLv-.mjs","names":[],"sources":["../../../../1-framework/3-tooling/cli/dist/migration-check-DONPyXff.mjs"],"sourcesContent":["import { K as errorInvalidSpaceId, L as errorAmbiguousMigrationRef, at as errorSpaceNotFound, lt as mapRefResolutionError, o as resolveContractPath } from \"./command-helpers-C4WpR-QE.mjs\";\nimport { u as toDeclaredExtensionsFromRaw } from \"./contract-space-aggregate-loader-C5r12INu.mjs\";\nimport { i as resolveTargetPathAcrossSpaces, n as looksLikePath, r as resolveAppTargetPath, t as findPackageByDirPath } from \"./migration-path-target-BPYp3LNc.mjs\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { notOk, ok } from \"@internal/utils/result\";\nimport { join, relative } from \"pathe\";\nimport { readFile } from \"node:fs/promises\";\nimport { createControlStack } from \"@internal/framework-components/control\";\nimport { existsSync, readdirSync, statSync } from \"node:fs\";\nimport { isValidSpaceId, listContractSpaceDirectories, spaceMigrationDirectory, spaceRefsDirectory } from \"@internal/migration-tools/spaces\";\nimport { loadContractSpaceAggregate } from \"@internal/migration-tools/aggregate\";\nimport { EMPTY_CONTRACT_HASH } from \"@internal/migration-tools/constants\";\nimport { MigrationToolsError } from \"@internal/migration-tools/errors\";\nimport { contractSnapshotDir, readContractSnapshotJson } from \"@internal/migration-tools/contract-snapshot-store\";\nimport { parseMigrationRef } from \"@internal/migration-tools/ref-resolution\";\nimport { verifyMigrationHash } from \"@internal/migration-tools/hash\";\n//#region src/control-api/operations/migration-check.ts\n/**\n* Policy core of `migration check`: per-space explicit graph checks, aggregate-integrity loading, and single-target resolution.\n*/\nfunction migrationPathRelative(dirPath) {\n\treturn relative(process.cwd(), dirPath);\n}\nfunction migrationFileRelative(dirPath, fileName) {\n\treturn join(migrationPathRelative(dirPath), fileName);\n}\nfunction checkFileExists(spaceId, dirPath, dirName, fileName) {\n\tif (!existsSync(join(dirPath, fileName))) return {\n\t\tspace: spaceId,\n\t\tcode: \"MIGRATION.CHECK_FILE_MISSING\",\n\t\twhere: migrationFileRelative(dirPath, fileName),\n\t\twhy: `${fileName} is missing from ${dirName}`,\n\t\tfix: \"Re-emit the migration package or restore from version control.\"\n\t};\n\treturn null;\n}\n/**\n* Snapshot-store consistency check for one migration package (D6.5):\n* absent store entry is not an issue (runner independence, ADR 199 — a\n* package dir with only `migration.json` + `ops.json` is legitimate); a\n* present entry whose inner `storage.storageHash` disagrees with\n* `pkg.metadata.to` is `MIGRATION.CHECK_SNAPSHOT_HASH_MISMATCH`; an unparseable store\n* entry (or a malformed `to`) is `MIGRATION.CHECK_SNAPSHOT_UNPARSEABLE`.\n*/\nasync function checkSnapshotConsistency(spaceId, pkg, migrationsDir) {\n\tlet snapshotDir;\n\ttry {\n\t\tsnapshotDir = contractSnapshotDir(migrationsDir, pkg.metadata.to);\n\t} catch {\n\t\treturn {\n\t\t\tspace: spaceId,\n\t\t\tcode: \"MIGRATION.CHECK_SNAPSHOT_UNPARSEABLE\",\n\t\t\twhere: migrationPathRelative(pkg.dirPath),\n\t\t\twhy: `Migration \"${pkg.dirName}\" declares to=\"${pkg.metadata.to}\", which is not a well-formed contract snapshot hash.`,\n\t\t\tfix: \"Re-emit the migration package so migration.json declares a valid 64-hex to-hash.\"\n\t\t};\n\t}\n\tlet raw;\n\ttry {\n\t\traw = await readContractSnapshotJson(migrationsDir, pkg.metadata.to);\n\t} catch (error) {\n\t\tif (MigrationToolsError.is(error) && error.code === \"MIGRATION.CONTRACT_SNAPSHOT_MISSING\") return null;\n\t\treturn {\n\t\t\tspace: spaceId,\n\t\t\tcode: \"MIGRATION.CHECK_SNAPSHOT_UNPARSEABLE\",\n\t\t\twhere: migrationPathRelative(pkg.dirPath),\n\t\t\twhy: `Migration \"${pkg.dirName}\" has an unparseable contract snapshot at ${snapshotDir}/contract.json.`,\n\t\t\tfix: \"Restore migrations/snapshots/ from version control, or re-run the command that produced this migration to regenerate its snapshot.\"\n\t\t};\n\t}\n\tconst snapshotHash = (raw !== null && typeof raw === \"object\" ? raw : {})[\"storage\"]?.[\"storageHash\"];\n\tif (typeof snapshotHash === \"string\" && snapshotHash !== pkg.metadata.to) return {\n\t\tspace: spaceId,\n\t\tcode: \"MIGRATION.CHECK_SNAPSHOT_HASH_MISMATCH\",\n\t\twhere: migrationPathRelative(pkg.dirPath),\n\t\twhy: `Migration \"${pkg.dirName}\" declares to=${pkg.metadata.to} but its contract snapshot has storageHash=${snapshotHash}`,\n\t\tfix: \"Re-emit the migration package so migration.json and its contract snapshot agree.\"\n\t};\n\treturn null;\n}\n/**\n* Project the loaded {@link ContractSpaceAggregate} into the\n* {@link CheckSpace} rows the multi-space check iterates — one per on-disk\n* contract-space directory, in the aggregate's `app`-first ordering. Mirrors\n* `migration list`'s `migrationSpaceListEntriesFromAggregate`: space\n* membership matches the on-disk directories, package / ref / graph data come\n* from `aggregate.space(id)`.\n*/\nasync function enumerateCheckSpaces(aggregate, projectMigrationsDir) {\n\tconst candidateDirs = await listContractSpaceDirectories(projectMigrationsDir);\n\tconst onDiskSpaceIds = new Set(candidateDirs.filter(isValidSpaceId));\n\tconst spaces = [];\n\tfor (const space of aggregate.spaces()) {\n\t\tconst spaceId = space.spaceId;\n\t\tif (!isValidSpaceId(spaceId)) continue;\n\t\tif (!onDiskSpaceIds.has(spaceId)) continue;\n\t\tconst migrationsDir = spaceMigrationDirectory(projectMigrationsDir, spaceId);\n\t\tspaces.push({\n\t\t\tspaceId,\n\t\t\tpackages: space.packages,\n\t\t\trefs: space.refs,\n\t\t\tgraph: space.graph(),\n\t\t\tmigrationsDir,\n\t\t\trefsDir: spaceRefsDirectory(migrationsDir),\n\t\t\tprojectMigrationsDir\n\t\t});\n\t}\n\treturn spaces;\n}\nfunction checkManifestFilesPresent(space) {\n\tif (!existsSync(space.migrationsDir)) return [];\n\tconst loadedDirNames = new Set(space.packages.map((p) => p.dirName));\n\tconst failures = [];\n\tlet entries;\n\ttry {\n\t\tentries = readdirSync(space.migrationsDir);\n\t} catch {\n\t\treturn failures;\n\t}\n\tfor (const entry of entries) {\n\t\tif (entry.startsWith(\".\") || entry.startsWith(\"_\") || entry === \"refs\") continue;\n\t\tconst entryPath = join(space.migrationsDir, entry);\n\t\ttry {\n\t\t\tif (!statSync(entryPath).isDirectory()) continue;\n\t\t} catch {\n\t\t\tcontinue;\n\t\t}\n\t\tif (!loadedDirNames.has(entry)) for (const f of [\"migration.json\", \"ops.json\"]) {\n\t\t\tconst fail = checkFileExists(space.spaceId, entryPath, entry, f);\n\t\t\tif (fail) failures.push(fail);\n\t\t}\n\t}\n\treturn failures;\n}\nfunction checkReachability(space) {\n\tconst allToHashes = new Set(space.packages.map((p) => p.metadata.to));\n\tconst failures = [];\n\tfor (const pkg of space.packages) if (!(pkg.metadata.from === null || allToHashes.has(pkg.metadata.from) || pkg.metadata.from === EMPTY_CONTRACT_HASH)) failures.push({\n\t\tspace: space.spaceId,\n\t\tcode: \"MIGRATION.CHECK_UNREACHABLE_MIGRATION\",\n\t\twhere: migrationPathRelative(pkg.dirPath),\n\t\twhy: `Migration \"${pkg.dirName}\" starts from ${pkg.metadata.from} which no other migration produces`,\n\t\tfix: \"This migration is unreachable in the graph. Delete it or re-emit a connecting migration.\"\n\t});\n\treturn failures;\n}\nfunction checkDanglingRefs(space) {\n\tconst failures = [];\n\tfor (const [name, entry] of Object.entries(space.refs)) if (!space.graph.nodes.has(entry.hash)) failures.push({\n\t\tspace: space.spaceId,\n\t\tcode: \"MIGRATION.CHECK_DANGLING_REF\",\n\t\twhere: relative(process.cwd(), join(space.refsDir, `${name}.json`)),\n\t\twhy: `Ref \"${name}\" points at ${entry.hash} which does not exist in the migration graph`,\n\t\tfix: `Update the ref with \\`prisma-next ref set ${name} <valid-hash>\\` or delete it.`\n\t});\n\treturn failures;\n}\nasync function checkSpace(space) {\n\tconst snapshotFailures = await Promise.all(space.packages.map((pkg) => checkSnapshotConsistency(space.spaceId, pkg, space.projectMigrationsDir)));\n\treturn [\n\t\t...checkManifestFilesPresent(space),\n\t\t...snapshotFailures.filter((f) => f !== null),\n\t\t...checkReachability(space),\n\t\t...checkDanglingRefs(space)\n\t];\n}\n/**\n* Policy core of the holistic `migration check`: validates `--space`,\n* narrows the pre-enumerated spaces, and runs the per-space explicit graph\n* checks (file-existence, snapshot consistency, reachability, dangling\n* refs), aggregating every failure into one {@link MigrationCheckResult}.\n*\n* `--space` validation mirrors `migration list`: an invalid id →\n* {@link errorInvalidSpaceId}; an id with no on-disk space →\n* {@link errorSpaceNotFound}. Both map to exit `PRECONDITION` at the shell.\n* Aggregate-integrity violations (which already span every space) are folded\n* in by the caller, not here.\n*/\nasync function runMigrationCheck(inputs) {\n\tconst { spaces, spaceFilter } = inputs;\n\tif (spaceFilter !== void 0 && !isValidSpaceId(spaceFilter)) return notOk(errorInvalidSpaceId(spaceFilter));\n\tif (spaceFilter !== void 0 && !spaces.some((s) => s.spaceId === spaceFilter)) return notOk(errorSpaceNotFound(spaceFilter, spaces.map((s) => s.spaceId).sort()));\n\tconst scopedSpaces = spaceFilter !== void 0 ? spaces.filter((s) => s.spaceId === spaceFilter) : spaces;\n\tconst failures = (await Promise.all(scopedSpaces.map(checkSpace))).flat();\n\tif (failures.length === 0) return ok({\n\t\tok: true,\n\t\tfailures: [],\n\t\tsummary: \"All checks passed\"\n\t});\n\treturn ok({\n\t\tok: false,\n\t\tfailures,\n\t\tsummary: `${failures.length} integrity failure(s)`\n\t});\n}\nasync function loadAggregateIntegrityViolations(config, migrationsDir) {\n\ttry {\n\t\tconst contractJsonContent = await readFile(resolveContractPath(config), \"utf-8\");\n\t\tconst familyInstance = config.family.create(createControlStack(config));\n\t\tconst declaredExtensions = toDeclaredExtensionsFromRaw(config.extensions ?? []);\n\t\tconst parsedAppContract = JSON.parse(contractJsonContent);\n\t\treturn (await loadContractSpaceAggregate({\n\t\t\tmigrationsDir,\n\t\t\tdeserializeContract: (json) => familyInstance.deserializeContract(json),\n\t\t\tappContract: familyInstance.deserializeContract(parsedAppContract)\n\t\t})).checkIntegrity({\n\t\t\tdeclaredExtensions,\n\t\t\tcheckContracts: true\n\t\t});\n\t} catch {\n\t\treturn [];\n\t}\n}\n/**\n* Ranks ref-resolution failure kinds by how informative they are, so a\n* single-target check surfaces the most useful failure across spaces instead of\n* whichever space failed first. `not-found` (the input matched nothing here)\n* says the least; a malformed input, a wrong grammar, or an in-space ambiguity\n* all say more.\n*/\nfunction refFailureSpecificity(error) {\n\tswitch (error.kind) {\n\t\tcase \"wrong-grammar\": return 3;\n\t\tcase \"ambiguous\": return 2;\n\t\tcase \"invalid-format\": return 1;\n\t\tcase \"not-found\": return 0;\n\t}\n}\n/**\n* Single-target (`check <ref/path>`) mode — resolves a migration reference\n* across all contract spaces (or the one space narrowed by `--space <id>`).\n*\n* Resolution:\n* - filesystem path → find the owning space by checking which space's\n* `migrationsDir` contains the resolved path; falls back to app-relative\n* validation when the path is outside every space dir.\n* - ref → `parseMigrationRef` against each in-scope space; collect every\n* (space, package) hit; 0 hits = not-found, 1 = check it, >1 = ambiguity\n* error (qualify with `--space`).\n*\n* `--space <id>` is validated the same way the holistic path does it:\n* invalid id → `errorInvalidSpaceId`; no on-disk space → `errorSpaceNotFound`.\n*/\nasync function checkSingleTarget(target, inputs) {\n\tconst { spaces, spaceFilter, appMigrationsDir, appMigrationsRelative } = inputs;\n\tif (spaceFilter !== void 0 && !isValidSpaceId(spaceFilter)) return {\n\t\terror: errorInvalidSpaceId(spaceFilter),\n\t\texitCode: 2\n\t};\n\tif (spaceFilter !== void 0 && !spaces.some((s) => s.spaceId === spaceFilter)) return {\n\t\terror: errorSpaceNotFound(spaceFilter, spaces.map((s) => s.spaceId).sort()),\n\t\texitCode: 2\n\t};\n\tconst scopedSpaces = spaceFilter !== void 0 ? spaces.filter((s) => s.spaceId === spaceFilter) : spaces;\n\tlet matchedSpace;\n\tlet matchedPkg;\n\tif (looksLikePath(target)) {\n\t\tconst resolvedPath = resolveTargetPathAcrossSpaces(target, scopedSpaces);\n\t\tif (resolvedPath !== null) for (const space of scopedSpaces) {\n\t\t\tconst found = findPackageByDirPath(space.packages, resolvedPath);\n\t\t\tif (found) {\n\t\t\t\tmatchedSpace = space;\n\t\t\t\tmatchedPkg = found;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\tconst resolved = resolveAppTargetPath(target, appMigrationsDir, appMigrationsRelative);\n\t\t\tif (!resolved.ok) return {\n\t\t\t\terror: resolved.failure,\n\t\t\t\texitCode: 2\n\t\t\t};\n\t\t\tconst appSpace = scopedSpaces.find((s) => s.spaceId === \"app\");\n\t\t\tif (appSpace) {\n\t\t\t\tmatchedSpace = appSpace;\n\t\t\t\tmatchedPkg = findPackageByDirPath(appSpace.packages, resolved.value);\n\t\t\t}\n\t\t}\n\t} else {\n\t\tconst hits = [];\n\t\tlet bestParseFailure;\n\t\tfor (const space of scopedSpaces) {\n\t\t\tconst migResult = parseMigrationRef(target, {\n\t\t\t\tgraph: space.graph,\n\t\t\t\trefs: space.refs\n\t\t\t});\n\t\t\tif (!migResult.ok) {\n\t\t\t\tif (bestParseFailure === void 0 || refFailureSpecificity(migResult.failure) > refFailureSpecificity(bestParseFailure)) bestParseFailure = migResult.failure;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst pkg = space.packages.find((p) => p.metadata.migrationHash === migResult.value.migrationHash);\n\t\t\tif (pkg) hits.push({\n\t\t\t\tspace,\n\t\t\t\tpkg\n\t\t\t});\n\t\t}\n\t\tif (hits.length > 1) return {\n\t\t\terror: errorAmbiguousMigrationRef(target, hits.map((h) => h.space.spaceId)),\n\t\t\texitCode: 2\n\t\t};\n\t\tif (hits.length === 1) {\n\t\t\tmatchedSpace = hits[0].space;\n\t\t\tmatchedPkg = hits[0].pkg;\n\t\t} else if (bestParseFailure !== void 0) return {\n\t\t\terror: mapRefResolutionError(bestParseFailure),\n\t\t\texitCode: 2\n\t\t};\n\t}\n\tif (!matchedPkg || !matchedSpace) return {\n\t\tresult: {\n\t\t\tok: false,\n\t\t\tfailures: [],\n\t\t\tsummary: `Migration package for \"${target}\" not found on disk`\n\t\t},\n\t\texitCode: 2\n\t};\n\tconst failures = [...checkManifestFilesPresent(matchedSpace)];\n\tfor (const f of [\"migration.json\", \"ops.json\"]) {\n\t\tconst fail = checkFileExists(matchedSpace.spaceId, matchedPkg.dirPath, matchedPkg.dirName, f);\n\t\tif (fail) failures.push(fail);\n\t}\n\tconst verification = verifyMigrationHash(matchedPkg);\n\tif (!verification.ok) failures.push({\n\t\tspace: matchedSpace.spaceId,\n\t\tcode: \"MIGRATION.CHECK_HASH_MISMATCH\",\n\t\twhere: migrationFileRelative(matchedPkg.dirPath, \"migration.json\"),\n\t\twhy: `Stored hash ${verification.storedHash} does not match recomputed hash ${verification.computedHash}`,\n\t\tfix: \"Re-emit the migration package or restore from version control.\"\n\t});\n\tconst snapshotFailure = await checkSnapshotConsistency(matchedSpace.spaceId, matchedPkg, matchedSpace.projectMigrationsDir);\n\tif (snapshotFailure) failures.push(snapshotFailure);\n\tconst resolvedSpaceId = matchedSpace.spaceId !== \"app\" ? matchedSpace.spaceId : void 0;\n\tif (failures.length === 0) return {\n\t\tresult: {\n\t\t\tok: true,\n\t\t\tfailures: [],\n\t\t\tsummary: \"All checks passed\"\n\t\t},\n\t\texitCode: 0,\n\t\t...ifDefined(\"resolvedSpaceId\", resolvedSpaceId)\n\t};\n\treturn {\n\t\tresult: {\n\t\t\tok: false,\n\t\t\tfailures,\n\t\t\tsummary: `${failures.length} integrity failure(s)`\n\t\t},\n\t\texitCode: 4,\n\t\t...ifDefined(\"resolvedSpaceId\", resolvedSpaceId)\n\t};\n}\n//#endregion\nexport { runMigrationCheck as i, enumerateCheckSpaces as n, loadAggregateIntegrityViolations as r, checkSingleTarget as t };\n\n//# sourceMappingURL=migration-check-DONPyXff.mjs.map"],"mappings":";;;;;;;;;;;;;;;;;;;;AAoBA,SAAS,sBAAsB,SAAS;CACvC,OAAO,SAAS,QAAQ,IAAI,GAAG,OAAO;AACvC;AACA,SAAS,sBAAsB,SAAS,UAAU;CACjD,OAAO,KAAK,sBAAsB,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AG,SAAS,OAAO;EAC7B;EACA,UAAU;EACV,GAAG,UAAU,mBAAmB,eAAe;CAChD;AACD"}
@@ -1,12 +1,12 @@
1
- import { N as errorUnexpected, Q as maskConnectionUrl, W as formatStyledHeader, d as errorContractValidationFailed, f as errorDatabaseConnectionRequired, h as errorFileNotFound, j as errorTargetMigrationNotSupported, m as errorDriverRequired, r as addGlobalOptions, rt as resolveContractPath } from "./command-helpers-C4WpR-QE-CK2gkj6l.mjs";
1
+ import { N as errorUnexpected, Q as maskConnectionUrl, W as formatStyledHeader, d as errorContractValidationFailed, f as errorDatabaseConnectionRequired, h as errorFileNotFound, j as errorTargetMigrationNotSupported, m as errorDriverRequired, r as addGlobalOptions, rt as resolveContractPath } from "./command-helpers-C4WpR-QE-DE494TSG.mjs";
2
2
  import { r as loadConfig } from "./exports-CDX9kZuw.mjs";
3
3
  import { t as createProgressAdapter } from "./progress-adapter-CjAeTxY_-BXYSd1eY.mjs";
4
- import { t as createControlClient } from "./client-7aUYC7ci-Bh9mLxkl.mjs";
4
+ import { t as createControlClient } from "./client-Y6qbDk7X-BzKLmBZo.mjs";
5
5
  import { notOk, ok } from "@prisma/orm-framework/utils/result";
6
6
  import { readFile } from "node:fs/promises";
7
7
  import { hasMigrations } from "@prisma/orm-framework/components/control";
8
8
  import { relative, resolve } from "node:path";
9
- //#region ../../../1-framework/3-tooling/cli/dist/migration-command-scaffold-DNRo4exb.mjs
9
+ //#region ../../../1-framework/3-tooling/cli/dist/migration-command-scaffold-BPqXPCFV.mjs
10
10
  /**
11
11
  * Prepares the shared context for migration commands (db init, db update).
12
12
  *
@@ -100,4 +100,4 @@ function addMigrationCommandOptions(command) {
100
100
  //#endregion
101
101
  export { prepareMigrationContext as n, addMigrationCommandOptions as t };
102
102
 
103
- //# sourceMappingURL=migration-command-scaffold-DNRo4exb-9JCezdoT.mjs.map
103
+ //# sourceMappingURL=migration-command-scaffold-BPqXPCFV-Bls2Wwg7.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"migration-command-scaffold-DNRo4exb-9JCezdoT.mjs","names":[],"sources":["../../../../1-framework/3-tooling/cli/dist/migration-command-scaffold-DNRo4exb.mjs"],"sourcesContent":["import { A as formatStyledHeader, B as errorContractValidationFailed, U as errorDriverRequired, V as errorDatabaseConnectionRequired, W as errorFileNotFound, ct as errorUnexpected, i as maskConnectionUrl, o as resolveContractPath, ot as errorTargetMigrationNotSupported, t as addGlobalOptions } from \"./command-helpers-C4WpR-QE.mjs\";\nimport { t as createProgressAdapter } from \"./progress-adapter-CjAeTxY_.mjs\";\nimport { t as createControlClient } from \"./client-7aUYC7ci.mjs\";\nimport { loadConfig } from \"@internal/config-loader\";\nimport { notOk, ok } from \"@internal/utils/result\";\nimport { readFile } from \"node:fs/promises\";\nimport { hasMigrations } from \"@internal/framework-components/control\";\nimport { relative, resolve } from \"node:path\";\n//#region src/utils/migration-command-scaffold.ts\n/**\n* Prepares the shared context for migration commands (db init, db update).\n*\n* Handles: config loading, contract file reading, JSON parsing, connection resolution,\n* driver/migration-support validation, client creation, and header output.\n*\n* Returns a Result with either the resolved context or a structured error.\n*/\nasync function prepareMigrationContext(options, flags, ui, descriptor) {\n\tconst config = await loadConfig(options.config);\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\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: 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\tif (options.dryRun) details.push({\n\t\t\tlabel: \"mode\",\n\t\t\tvalue: \"dry run\"\n\t\t});\n\t\tconst header = formatStyledHeader({\n\t\t\tcommand: descriptor.commandName,\n\t\t\tdescription: descriptor.description,\n\t\t\turl: descriptor.url,\n\t\t\tdetails,\n\t\t\tflags\n\t\t});\n\t\tui.stderr(header);\n\t}\n\tlet contractJsonContent;\n\ttry {\n\t\tcontractJsonContent = await readFile(contractPathAbsolute, \"utf-8\");\n\t} catch (error) {\n\t\tif (error instanceof Error && error.code === \"ENOENT\") return notOk(errorFileNotFound(contractPathAbsolute, {\n\t\t\twhy: `Contract file not found at ${contractPathAbsolute}`,\n\t\t\tfix: `Run \\`prisma-next contract emit\\` to generate ${contractPath}, or update \\`config.contract.output\\` in ${configPath}`\n\t\t}));\n\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}\n\tlet contractJson;\n\ttry {\n\t\tcontractJson = JSON.parse(contractJsonContent);\n\t} catch (error) {\n\t\treturn notOk(errorContractValidationFailed(`Contract JSON is invalid: ${error instanceof Error ? error.message : String(error)}`, { where: { path: contractPathAbsolute } }));\n\t}\n\tconst dbConnection = options.db ?? config.db?.connection;\n\tif (!dbConnection) return notOk(errorDatabaseConnectionRequired({\n\t\twhy: `Database connection is required for ${descriptor.commandName} (set db.connection in ${configPath}, or pass --db <url>)`,\n\t\tcommandName: descriptor.commandName\n\t}));\n\tif (!config.driver) return notOk(errorDriverRequired({ why: `Config.driver is required for ${descriptor.commandName}` }));\n\tif (!hasMigrations(config.target)) return notOk(errorTargetMigrationNotSupported({ why: `Target \"${config.target.id}\" does not support migrations` }));\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\treturn ok({\n\t\tclient,\n\t\tcontractJson,\n\t\tdbConnection,\n\t\tonProgress,\n\t\tconfigPath,\n\t\tcontractPath,\n\t\tcontractPathAbsolute,\n\t\tconfig\n\t});\n}\n/**\n* Registers the shared CLI options for migration commands (db init, db update).\n*/\nfunction addMigrationCommandOptions(command) {\n\taddGlobalOptions(command);\n\treturn command.option(\"--db <url>\", \"Database connection string\").option(\"--config <path>\", \"Path to prisma-next.config.ts\").option(\"--dry-run\", \"Preview planned operations without applying\", false);\n}\n//#endregion\nexport { prepareMigrationContext as n, addMigrationCommandOptions as t };\n\n//# sourceMappingURL=migration-command-scaffold-DNRo4exb.mjs.map"],"mappings":";;;;;;;;;;;;;;;;;AAiBA,eAAe,wBAAwB,SAAS,OAAO,IAAI,YAAY;CACtE,MAAM,SAAS,MAAM,WAAW,QAAQ,MAAM;CAC9C,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,IAAI,CAAC,MAAM,QAAQ,CAAC,MAAM,OAAO;EAChC,MAAM,UAAU,CAAC;GAChB,OAAO;GACP,OAAO;EACR,GAAG;GACF,OAAO;GACP,OAAO;EACR,CAAC;EACD,IAAI,QAAQ,IAAI,QAAQ,KAAK;GAC5B,OAAO;GACP,OAAO,kBAAkB,QAAQ,EAAE;EACpC,CAAC;EACD,IAAI,QAAQ,QAAQ,QAAQ,KAAK;GAChC,OAAO;GACP,OAAO;EACR,CAAC;EACD,MAAM,SAAS,mBAAmB;GACjC,SAAS,WAAW;GACpB,aAAa,WAAW;GACxB,KAAK,WAAW;GAChB;GACA;EACD,CAAC;EACD,GAAG,OAAO,MAAM;CACjB;CACA,IAAI;CACJ,IAAI;EACH,sBAAsB,MAAM,SAAS,sBAAsB,OAAO;CACnE,SAAS,OAAO;EACf,IAAI,iBAAiB,SAAS,MAAM,SAAS,UAAU,OAAO,MAAM,kBAAkB,sBAAsB;GAC3G,KAAK,8BAA8B;GACnC,KAAK,iDAAiD,aAAa,4CAA4C;EAChH,CAAC,CAAC;EACF,OAA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","names":[],"sources":["../../../../1-framework/3-tooling/cli/dist/migration-command-scaffold-BPqXPCFV.mjs"],"sourcesContent":["import { A as formatStyledHeader, B as errorContractValidationFailed, U as errorDriverRequired, V as errorDatabaseConnectionRequired, W as errorFileNotFound, ct as errorUnexpected, i as maskConnectionUrl, o as resolveContractPath, ot as errorTargetMigrationNotSupported, t as addGlobalOptions } from \"./command-helpers-C4WpR-QE.mjs\";\nimport { t as createProgressAdapter } from \"./progress-adapter-CjAeTxY_.mjs\";\nimport { t as createControlClient } from \"./client-Y6qbDk7X.mjs\";\nimport { loadConfig } from \"@internal/config-loader\";\nimport { notOk, ok } from \"@internal/utils/result\";\nimport { readFile } from \"node:fs/promises\";\nimport { hasMigrations } from \"@internal/framework-components/control\";\nimport { relative, resolve } from \"node:path\";\n//#region src/utils/migration-command-scaffold.ts\n/**\n* Prepares the shared context for migration commands (db init, db update).\n*\n* Handles: config loading, contract file reading, JSON parsing, connection resolution,\n* driver/migration-support validation, client creation, and header output.\n*\n* Returns a Result with either the resolved context or a structured error.\n*/\nasync function prepareMigrationContext(options, flags, ui, descriptor) {\n\tconst config = await loadConfig(options.config);\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\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: 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\tif (options.dryRun) details.push({\n\t\t\tlabel: \"mode\",\n\t\t\tvalue: \"dry run\"\n\t\t});\n\t\tconst header = formatStyledHeader({\n\t\t\tcommand: descriptor.commandName,\n\t\t\tdescription: descriptor.description,\n\t\t\turl: descriptor.url,\n\t\t\tdetails,\n\t\t\tflags\n\t\t});\n\t\tui.stderr(header);\n\t}\n\tlet contractJsonContent;\n\ttry {\n\t\tcontractJsonContent = await readFile(contractPathAbsolute, \"utf-8\");\n\t} catch (error) {\n\t\tif (error instanceof Error && error.code === \"ENOENT\") return notOk(errorFileNotFound(contractPathAbsolute, {\n\t\t\twhy: `Contract file not found at ${contractPathAbsolute}`,\n\t\t\tfix: `Run \\`prisma-next contract emit\\` to generate ${contractPath}, or update \\`config.contract.output\\` in ${configPath}`\n\t\t}));\n\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}\n\tlet contractJson;\n\ttry {\n\t\tcontractJson = JSON.parse(contractJsonContent);\n\t} catch (error) {\n\t\treturn notOk(errorContractValidationFailed(`Contract JSON is invalid: ${error instanceof Error ? error.message : String(error)}`, { where: { path: contractPathAbsolute } }));\n\t}\n\tconst dbConnection = options.db ?? config.db?.connection;\n\tif (!dbConnection) return notOk(errorDatabaseConnectionRequired({\n\t\twhy: `Database connection is required for ${descriptor.commandName} (set db.connection in ${configPath}, or pass --db <url>)`,\n\t\tcommandName: descriptor.commandName\n\t}));\n\tif (!config.driver) return notOk(errorDriverRequired({ why: `Config.driver is required for ${descriptor.commandName}` }));\n\tif (!hasMigrations(config.target)) return notOk(errorTargetMigrationNotSupported({ why: `Target \"${config.target.id}\" does not support migrations` }));\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\treturn ok({\n\t\tclient,\n\t\tcontractJson,\n\t\tdbConnection,\n\t\tonProgress,\n\t\tconfigPath,\n\t\tcontractPath,\n\t\tcontractPathAbsolute,\n\t\tconfig\n\t});\n}\n/**\n* Registers the shared CLI options for migration commands (db init, db update).\n*/\nfunction addMigrationCommandOptions(command) {\n\taddGlobalOptions(command);\n\treturn command.option(\"--db <url>\", \"Database connection string\").option(\"--config <path>\", \"Path to prisma-next.config.ts\").option(\"--dry-run\", \"Preview planned operations without applying\", false);\n}\n//#endregion\nexport { prepareMigrationContext as n, addMigrationCommandOptions as t };\n\n//# sourceMappingURL=migration-command-scaffold-BPqXPCFV.mjs.map"],"mappings":";;;;;;;;;;;;;;;;;AAiBA,eAAe,wBAAwB,SAAS,OAAO,IAAI,YAAY;CACtE,MAAM,SAAS,MAAM,WAAW,QAAQ,MAAM;CAC9C,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,IAAI,CAAC,MAAM,QAAQ,CAAC,MAAM,OAAO;EAChC,MAAM,UAAU,CAAC;GAChB,OAAO;GACP,OAAO;EACR,GAAG;GACF,OAAO;GACP,OAAO;EACR,CAAC;EACD,IAAI,QAAQ,IAAI,QAAQ,KAAK;GAC5B,OAAO;GACP,OAAO,kBAAkB,QAAQ,EAAE;EACpC,CAAC;EACD,IAAI,QAAQ,QAAQ,QAAQ,KAAK;GAChC,OAAO;GACP,OAAO;EACR,CAAC;EACD,MAAM,SAAS,mBAAmB;GACjC,SAAS,WAAW;GACpB,aAAa,WAAW;GACxB,KAAK,WAAW;GAChB;GACA;EACD,CAAC;EACD,GAAG,OAAO,MAAM;CACjB;CACA,IAAI;CACJ,IAAI;EACH,sBAAsB,MAAM,SAAS,sBAAsB,OAAO;CACnE,SAAS,OAAO;EACf,IAAI,iBAAiB,SAAS,MAAM,SAAS,UAAU,OAAO,MAAM,kBAAkB,sBAAsB;GAC3G,KAAK,8BAA8B;GACnC,KAAK,iDAAiD,aAAa,4CAA4C;EAChH,CAAC,CAAC;EACF,OAAO,MAAM,gBAAgB,iBAAiB,QAAQ,MAAM,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ww.mjs";
1
+ import { D as errorNoInitialMigration, k as errorNoTarget, n as errorAmbiguousTarget } from "./errors-Co-8oaiB-CB-6Uqki.mjs";
2
2
  import { t as EMPTY_CONTRACT_HASH } from "./constants-CM-w38DQ-Cz_EXbOc.mjs";
3
3
  import { ifDefined } from "@prisma/orm-framework/utils/defined";
4
4
  import { InternalError } from "@prisma/orm-framework/utils/internal-error";
5
- //#region ../../../1-framework/3-tooling/migration/dist/migration-graph-D6bN-mX0.mjs
5
+ //#region ../../../1-framework/3-tooling/migration/dist/migration-graph-DDaOHo10.mjs
6
6
  /**
7
7
  * FIFO queue with amortised O(1) push and shift.
8
8
  *
@@ -497,4 +497,4 @@ function detectOrphans(graph) {
497
497
  //#endregion
498
498
  export { findPath as a, findReachableLeaves as c, findLeaf as i, reconstructGraph as l, detectOrphans as n, findPathWithDecision as o, findLatestMigration as r, findPathWithInvariants as s, detectCycles as t };
499
499
 
500
- //# sourceMappingURL=migration-graph-D6bN-mX0-DwMWY8DA.mjs.map
500
+ //# sourceMappingURL=migration-graph-DDaOHo10-yJFAbKCu.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"migration-graph-D6bN-mX0-DwMWY8DA.mjs","names":[],"sources":["../../../../1-framework/3-tooling/migration/dist/migration-graph-D6bN-mX0.mjs"],"sourcesContent":["import { D as errorNoInitialMigration, k as errorNoTarget, n as errorAmbiguousTarget } from \"./errors-BwusfLIN.mjs\";\nimport { t as EMPTY_CONTRACT_HASH } from \"./constants-CM-w38DQ.mjs\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { InternalError } from \"@internal/utils/internal-error\";\n//#region src/queue.ts\n/**\n* FIFO queue with amortised O(1) push and shift.\n*\n* Uses a head-index cursor over a backing array rather than\n* `Array.prototype.shift()`, which is O(n) on V8. Intended for BFS-shaped\n* traversals where the queue is drained in a single pass — it does not\n* reclaim memory for already-shifted items, so it is not suitable for\n* long-lived queues with many push/shift cycles.\n*/\nvar Queue = class {\n\titems;\n\thead = 0;\n\tconstructor(initial = []) {\n\t\tthis.items = [...initial];\n\t}\n\tpush(item) {\n\t\tthis.items.push(item);\n\t}\n\t/**\n\t* Remove and return the next item. Caller must check `isEmpty` first —\n\t* shifting an empty queue throws.\n\t*/\n\tshift() {\n\t\tif (this.head >= this.items.length) throw new InternalError(\"Queue.shift called on empty queue\");\n\t\treturn this.items[this.head++];\n\t}\n\tget isEmpty() {\n\t\treturn this.head >= this.items.length;\n\t}\n};\n//#endregion\n//#region src/graph-ops.ts\nfunction* bfs(starts, neighbours, key = (state) => state) {\n\tconst visited = /* @__PURE__ */ new Set();\n\tconst parentMap = /* @__PURE__ */ new Map();\n\tconst queue = new Queue();\n\tfor (const start of starts) {\n\t\tconst k = key(start);\n\t\tif (!visited.has(k)) {\n\t\t\tvisited.add(k);\n\t\t\tqueue.push({\n\t\t\t\tstate: start,\n\t\t\t\tkey: k\n\t\t\t});\n\t\t}\n\t}\n\twhile (!queue.isEmpty) {\n\t\tconst { state: current, key: curKey } = queue.shift();\n\t\tconst parentInfo = parentMap.get(curKey);\n\t\tyield {\n\t\t\tstate: current,\n\t\t\tparent: parentInfo?.parent ?? null,\n\t\t\tincomingEdge: parentInfo?.edge ?? null\n\t\t};\n\t\tfor (const { next, edge } of neighbours(current)) {\n\t\t\tconst k = key(next);\n\t\t\tif (!visited.has(k)) {\n\t\t\t\tvisited.add(k);\n\t\t\t\tparentMap.set(k, {\n\t\t\t\t\tparent: current,\n\t\t\t\t\tedge\n\t\t\t\t});\n\t\t\t\tqueue.push({\n\t\t\t\t\tstate: next,\n\t\t\t\t\tkey: k\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n}\n//#endregion\n//#region src/migration-graph.ts\n/** Forward-edge neighbours: edge `e` from `n` visits `e.to` next. */\nfunction forwardNeighbours(graph, node) {\n\treturn (graph.forwardChain.get(node) ?? []).map((edge) => ({\n\t\tnext: edge.to,\n\t\tedge\n\t}));\n}\n/**\n* Forward-edge neighbours, sorted by the deterministic tie-break.\n* Used by path-finding so the resulting shortest path is stable across runs.\n*/\nfunction sortedForwardNeighbours(graph, node) {\n\treturn [...graph.forwardChain.get(node) ?? []].sort(compareTieBreak).map((edge) => ({\n\t\tnext: edge.to,\n\t\tedge\n\t}));\n}\n/** Reverse-edge neighbours: edge `e` from `n` visits `e.from` next. */\nfunction reverseNeighbours(graph, node) {\n\treturn (graph.reverseChain.get(node) ?? []).map((edge) => ({\n\t\tnext: edge.from,\n\t\tedge\n\t}));\n}\nfunction appendEdge(map, key, entry) {\n\tconst bucket = map.get(key);\n\tif (bucket) bucket.push(entry);\n\telse map.set(key, [entry]);\n}\nfunction reconstructGraph(packages) {\n\tconst nodes = /* @__PURE__ */ new Set();\n\tconst forwardChain = /* @__PURE__ */ new Map();\n\tconst reverseChain = /* @__PURE__ */ new Map();\n\tconst migrationByHash = /* @__PURE__ */ new Map();\n\tfor (const pkg of packages) {\n\t\tconst from = pkg.metadata.from ?? \"empty\";\n\t\tconst { to } = pkg.metadata;\n\t\tnodes.add(from);\n\t\tnodes.add(to);\n\t\tconst migration = {\n\t\t\tfrom,\n\t\t\tto,\n\t\t\tmigrationHash: pkg.metadata.migrationHash,\n\t\t\tdirName: pkg.dirName,\n\t\t\tcreatedAt: pkg.metadata.createdAt,\n\t\t\tinvariants: pkg.metadata.providedInvariants\n\t\t};\n\t\tif (!migrationByHash.has(migration.migrationHash)) migrationByHash.set(migration.migrationHash, migration);\n\t\tappendEdge(forwardChain, from, migration);\n\t\tappendEdge(reverseChain, to, migration);\n\t}\n\treturn {\n\t\tnodes,\n\t\tforwardChain,\n\t\treverseChain,\n\t\tmigrationByHash\n\t};\n}\nfunction compareTieBreak(a, b) {\n\tconst ca = a.createdAt.localeCompare(b.createdAt);\n\tif (ca !== 0) return ca;\n\tconst tc = a.to.localeCompare(b.to);\n\tif (tc !== 0) return tc;\n\treturn a.migrationHash.localeCompare(b.migrationHash);\n}\nfunction sortedNeighbors(edges) {\n\treturn [...edges].sort(compareTieBreak);\n}\n/**\n* Find the shortest path from `fromHash` to `toHash` using BFS over the\n* contract-hash graph. Returns the ordered list of edges, or null if no path\n* exists. Returns an empty array when `fromHash === toHash` (no-op).\n*\n* Neighbor ordering is deterministic via the tie-break sort key:\n* createdAt → to → migrationHash.\n*/\nfunction findPath(graph, fromHash, toHash) {\n\tif (fromHash === toHash) return [];\n\tconst parents = /* @__PURE__ */ new Map();\n\tfor (const step of bfs([fromHash], (n) => sortedForwardNeighbours(graph, n))) {\n\t\tif (step.parent !== null && step.incomingEdge !== null) parents.set(step.state, {\n\t\t\tparent: step.parent,\n\t\t\tedge: step.incomingEdge\n\t\t});\n\t\tif (step.state === toHash) {\n\t\t\tconst path = [];\n\t\t\tlet cur = toHash;\n\t\t\tlet p = parents.get(cur);\n\t\t\twhile (p) {\n\t\t\t\tpath.push(p.edge);\n\t\t\t\tcur = p.parent;\n\t\t\t\tp = parents.get(cur);\n\t\t\t}\n\t\t\tpath.reverse();\n\t\t\treturn path;\n\t\t}\n\t}\n\treturn null;\n}\n/**\n* Find the shortest path from `fromHash` to `toHash` whose edges collectively\n* cover every invariant in `required`. Returns `null` when no such path exists\n* (either `fromHash`→`toHash` is structurally unreachable, or every reachable\n* path leaves at least one required invariant uncovered). When `required` is\n* empty, delegates to `findPath` so the result is byte-identical for that case.\n*\n* Algorithm: BFS over `(node, coveredSubset)` states with state-level dedup.\n* The covered subset is a `Set<string>` of invariant ids; the state's dedup\n* key is `${node}\\0${[...covered].sort().join('\\0')}`. State keys distinguish\n* distinct `(node, covered)` tuples regardless of node-name length because\n* `\\0` cannot appear in any invariant id (validation rejects whitespace and\n* control chars at authoring time).\n*\n* Neighbour ordering when `required ≠ ∅`: edges covering ≥1 still-needed\n* invariant come first, with `createdAt → to → migrationHash` as the\n* secondary key. The heuristic steers BFS toward the satisfying path;\n* correctness (shortest, deterministic) does not depend on it.\n*/\nfunction findPathWithInvariants(graph, fromHash, toHash, required) {\n\tif (required.size === 0) return findPath(graph, fromHash, toHash);\n\tconst stateKey = (s) => {\n\t\tif (s.covered.size === 0) return `${s.node}\\0`;\n\t\treturn `${s.node}\\0${[...s.covered].sort().join(\"\\0\")}`;\n\t};\n\tconst neighbours = (s) => {\n\t\tconst outgoing = graph.forwardChain.get(s.node) ?? [];\n\t\tif (outgoing.length === 0) return [];\n\t\treturn [...outgoing].map((edge) => {\n\t\t\tlet useful = false;\n\t\t\tlet next = null;\n\t\t\tfor (const inv of edge.invariants) if (required.has(inv) && !s.covered.has(inv)) {\n\t\t\t\tif (next === null) next = new Set(s.covered);\n\t\t\t\tnext.add(inv);\n\t\t\t\tuseful = true;\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tedge,\n\t\t\t\tuseful,\n\t\t\t\tnextCovered: next ?? s.covered\n\t\t\t};\n\t\t}).sort((a, b) => {\n\t\t\tif (a.useful !== b.useful) return a.useful ? -1 : 1;\n\t\t\treturn compareTieBreak(a.edge, b.edge);\n\t\t}).map(({ edge, nextCovered }) => ({\n\t\t\tnext: {\n\t\t\t\tnode: edge.to,\n\t\t\t\tcovered: nextCovered\n\t\t\t},\n\t\t\tedge\n\t\t}));\n\t};\n\tconst parents = /* @__PURE__ */ new Map();\n\tfor (const step of bfs([{\n\t\tnode: fromHash,\n\t\tcovered: /* @__PURE__ */ new Set()\n\t}], neighbours, stateKey)) {\n\t\tconst curKey = stateKey(step.state);\n\t\tif (step.parent !== null && step.incomingEdge !== null) parents.set(curKey, {\n\t\t\tparentKey: stateKey(step.parent),\n\t\t\tedge: step.incomingEdge\n\t\t});\n\t\tif (step.state.node === toHash && step.state.covered.size === required.size) {\n\t\t\tconst path = [];\n\t\t\tlet cur = curKey;\n\t\t\twhile (cur !== void 0) {\n\t\t\t\tconst p = parents.get(cur);\n\t\t\t\tif (!p) break;\n\t\t\t\tpath.push(p.edge);\n\t\t\t\tcur = p.parentKey;\n\t\t\t}\n\t\t\tpath.reverse();\n\t\t\treturn path;\n\t\t}\n\t}\n\treturn null;\n}\n/**\n* Reverse-BFS from `toHash` over `reverseChain` to collect every node from\n* which `toHash` is reachable (inclusive of `toHash` itself).\n*/\nfunction collectNodesReachingTarget(graph, toHash) {\n\tconst reached = /* @__PURE__ */ new Set();\n\tfor (const step of bfs([toHash], (n) => reverseNeighbours(graph, n))) reached.add(step.state);\n\treturn reached;\n}\n/**\n* Find the shortest path from `fromHash` to `toHash` and return structured\n* path-decision metadata for machine-readable output. When `required` is\n* non-empty, the returned path is the shortest one whose edges collectively\n* cover every required invariant.\n*\n* The discriminated return type tells the caller *why* a path could not be\n* found, so the CLI can pick the right structured error without re-running\n* a structural BFS.\n*/\nfunction findPathWithDecision(graph, fromHash, toHash, options = {}) {\n\tconst { refName, required = /* @__PURE__ */ new Set() } = options;\n\tconst requiredInvariants = [...required].sort();\n\tif (fromHash === toHash && required.size === 0) return {\n\t\tkind: \"ok\",\n\t\tdecision: {\n\t\t\tselectedPath: [],\n\t\t\tfromHash,\n\t\t\ttoHash,\n\t\t\talternativeCount: 0,\n\t\t\ttieBreakReasons: [],\n\t\t\trequiredInvariants,\n\t\t\tsatisfiedInvariants: [],\n\t\t\t...ifDefined(\"refName\", refName)\n\t\t}\n\t};\n\tconst path = findPathWithInvariants(graph, fromHash, toHash, required);\n\tif (!path) {\n\t\tif (required.size === 0) return { kind: \"unreachable\" };\n\t\tconst structural = findPath(graph, fromHash, toHash);\n\t\tif (structural === null) return { kind: \"unreachable\" };\n\t\tconst coveredByStructural = /* @__PURE__ */ new Set();\n\t\tfor (const edge of structural) for (const inv of edge.invariants) if (required.has(inv)) coveredByStructural.add(inv);\n\t\treturn {\n\t\t\tkind: \"unsatisfiable\",\n\t\t\tstructuralPath: structural,\n\t\t\tmissing: requiredInvariants.filter((id) => !coveredByStructural.has(id))\n\t\t};\n\t}\n\tconst satisfiedInvariants = computeSatisfiedInvariants(required, path);\n\tconst reachesTarget = collectNodesReachingTarget(graph, toHash);\n\tconst coveragePrefixes = requiredCoveragePrefixes(required, path);\n\tconst tieBreakReasons = [];\n\tlet alternativeCount = 0;\n\tfor (const [i, edge] of path.entries()) {\n\t\tconst outgoing = graph.forwardChain.get(edge.from);\n\t\tif (!outgoing || outgoing.length <= 1) continue;\n\t\tconst reachable = outgoing.filter((e) => reachesTarget.has(e.to));\n\t\tif (reachable.length <= 1) continue;\n\t\tlet comparisonPool = reachable;\n\t\tif (required.size > 0) {\n\t\t\tconst prefixSet = coveragePrefixes[i];\n\t\t\tif (prefixSet === void 0) continue;\n\t\t\tcomparisonPool = invariantViableAlternativesAtStep(required, prefixSet, reachable);\n\t\t}\n\t\talternativeCount += reachable.length - 1;\n\t\tif (sortedNeighbors(reachable)[0]?.migrationHash !== edge.migrationHash) continue;\n\t\tif (!reachable.some((e) => e.migrationHash !== edge.migrationHash)) continue;\n\t\tconst sortedViable = sortedNeighbors(comparisonPool);\n\t\tif (sortedViable.length > 1 && sortedViable[0]?.migrationHash === edge.migrationHash && sortedViable.some((e) => e.migrationHash !== edge.migrationHash)) tieBreakReasons.push(`at ${edge.from}: ${comparisonPool.length} candidates, selected by tie-break`);\n\t}\n\treturn {\n\t\tkind: \"ok\",\n\t\tdecision: {\n\t\t\tselectedPath: path,\n\t\t\tfromHash,\n\t\t\ttoHash,\n\t\t\talternativeCount,\n\t\t\ttieBreakReasons,\n\t\t\trequiredInvariants,\n\t\t\tsatisfiedInvariants,\n\t\t\t...ifDefined(\"refName\", refName)\n\t\t}\n\t};\n}\nfunction computeSatisfiedInvariants(required, path) {\n\tif (required.size === 0) return [];\n\tconst covered = /* @__PURE__ */ new Set();\n\tfor (const edge of path) for (const inv of edge.invariants) if (required.has(inv)) covered.add(inv);\n\treturn [...covered].sort();\n}\n/**\n* For each edge on path, invariant coverage accumulated from earlier edges only —\n* `(required ∩ ∪_{j<i} path[j].invariants)` represented as cumulative set along `required`,\n* keyed as \"full set of required ids satisfied before taking path[i]\".\n*/\nfunction requiredCoveragePrefixes(required, path) {\n\tconst prefixes = [];\n\tconst acc = /* @__PURE__ */ new Set();\n\tfor (const edge of path) {\n\t\tprefixes.push(new Set(acc));\n\t\tfor (const inv of edge.invariants) if (required.has(inv)) acc.add(inv);\n\t}\n\treturn prefixes;\n}\nfunction invariantViableAlternativesAtStep(required, coverageBeforeTakingEdge, outgoing) {\n\tif (required.size === 0) return [...outgoing];\n\treturn outgoing.filter((e) => [...required].every((id) => coverageBeforeTakingEdge.has(id) || e.invariants.includes(id)));\n}\n/**\n* Walk ancestors of each branch tip back to find the last node\n* that appears on all paths. Returns `fromHash` if no shared ancestor is found.\n*/\nfunction findDivergencePoint(graph, fromHash, leaves) {\n\tconst ancestorSets = leaves.map((leaf) => {\n\t\tconst ancestors = /* @__PURE__ */ new Set();\n\t\tfor (const step of bfs([leaf], (n) => reverseNeighbours(graph, n))) ancestors.add(step.state);\n\t\treturn ancestors;\n\t});\n\tconst commonAncestors = [...ancestorSets[0] ?? []].filter((node) => ancestorSets.every((s) => s.has(node)));\n\tlet deepest = fromHash;\n\tlet deepestDepth = -1;\n\tfor (const ancestor of commonAncestors) {\n\t\tconst path = findPath(graph, fromHash, ancestor);\n\t\tconst depth = path ? path.length : 0;\n\t\tif (depth > deepestDepth) {\n\t\t\tdeepestDepth = depth;\n\t\t\tdeepest = ancestor;\n\t\t}\n\t}\n\treturn deepest;\n}\n/**\n* Find all branch tips (nodes with no outgoing edges) reachable from\n* `fromHash` via forward edges.\n*/\nfunction findReachableLeaves(graph, fromHash) {\n\tconst leaves = [];\n\tfor (const step of bfs([fromHash], (n) => forwardNeighbours(graph, n))) if (!graph.forwardChain.get(step.state)?.length) leaves.push(step.state);\n\treturn leaves;\n}\n/**\n* Find the target contract hash of the migration graph reachable from\n* EMPTY_CONTRACT_HASH. Returns `null` for a graph that has no target\n* state (either empty, or containing only the root with no outgoing\n* edges). Throws NO_INITIAL_MIGRATION if the graph has nodes but none\n* originate from the empty hash, and AMBIGUOUS_TARGET if multiple\n* branch tips exist.\n*/\nfunction findLeaf(graph) {\n\tif (graph.nodes.size === 0) return null;\n\tif (!graph.nodes.has(\"empty\")) throw errorNoInitialMigration([...graph.nodes]);\n\tconst leaves = findReachableLeaves(graph, EMPTY_CONTRACT_HASH);\n\tif (leaves.length === 0) {\n\t\tconst reachable = [...graph.nodes].filter((n) => n !== EMPTY_CONTRACT_HASH);\n\t\tif (reachable.length > 0) throw errorNoTarget(reachable);\n\t\treturn null;\n\t}\n\tif (leaves.length > 1) {\n\t\tconst divergencePoint = findDivergencePoint(graph, EMPTY_CONTRACT_HASH, leaves);\n\t\tthrow errorAmbiguousTarget(leaves, {\n\t\t\tdivergencePoint,\n\t\t\tbranches: leaves.map((tip) => {\n\t\t\t\treturn {\n\t\t\t\t\ttip,\n\t\t\t\t\tedges: (findPath(graph, divergencePoint, tip) ?? []).map((e) => ({\n\t\t\t\t\t\tdirName: e.dirName,\n\t\t\t\t\t\tfrom: e.from,\n\t\t\t\t\t\tto: e.to\n\t\t\t\t\t}))\n\t\t\t\t};\n\t\t\t})\n\t\t});\n\t}\n\treturn leaves[0];\n}\n/**\n* Find the latest migration entry by traversing from EMPTY_CONTRACT_HASH\n* to the single target. Returns null for an empty graph.\n* Throws AMBIGUOUS_TARGET if the graph has multiple branch tips.\n*/\nfunction findLatestMigration(graph) {\n\tconst leafHash = findLeaf(graph);\n\tif (leafHash === null) return null;\n\treturn findPath(graph, \"empty\", leafHash)?.at(-1) ?? null;\n}\nfunction detectCycles(graph) {\n\tconst WHITE = 0;\n\tconst GRAY = 1;\n\tconst BLACK = 2;\n\tconst color = /* @__PURE__ */ new Map();\n\tconst parentMap = /* @__PURE__ */ new Map();\n\tconst cycles = [];\n\tfor (const node of graph.nodes) color.set(node, WHITE);\n\tconst stack = [];\n\tfunction pushFrame(u) {\n\t\tcolor.set(u, GRAY);\n\t\tstack.push({\n\t\t\tnode: u,\n\t\t\toutgoing: graph.forwardChain.get(u) ?? [],\n\t\t\tindex: 0\n\t\t});\n\t}\n\tfor (const root of graph.nodes) {\n\t\tif (color.get(root) !== WHITE) continue;\n\t\tparentMap.set(root, null);\n\t\tpushFrame(root);\n\t\twhile (stack.length > 0) {\n\t\t\tconst frame = stack[stack.length - 1];\n\t\t\tif (frame.index >= frame.outgoing.length) {\n\t\t\t\tcolor.set(frame.node, BLACK);\n\t\t\t\tstack.pop();\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst v = frame.outgoing[frame.index++].to;\n\t\t\tconst vColor = color.get(v);\n\t\t\tif (vColor === GRAY) {\n\t\t\t\tconst cycle = [v];\n\t\t\t\tlet cur = frame.node;\n\t\t\t\twhile (cur !== v) {\n\t\t\t\t\tcycle.push(cur);\n\t\t\t\t\tcur = parentMap.get(cur) ?? v;\n\t\t\t\t}\n\t\t\t\tcycle.reverse();\n\t\t\t\tcycles.push(cycle);\n\t\t\t} else if (vColor === WHITE) {\n\t\t\t\tparentMap.set(v, frame.node);\n\t\t\t\tpushFrame(v);\n\t\t\t}\n\t\t}\n\t}\n\treturn cycles;\n}\nfunction detectOrphans(graph) {\n\tif (graph.nodes.size === 0) return [];\n\tconst reachable = /* @__PURE__ */ new Set();\n\tconst startNodes = [];\n\tif (graph.forwardChain.has(\"empty\")) startNodes.push(EMPTY_CONTRACT_HASH);\n\telse {\n\t\tconst allTargets = /* @__PURE__ */ new Set();\n\t\tfor (const edges of graph.forwardChain.values()) for (const edge of edges) allTargets.add(edge.to);\n\t\tfor (const node of graph.nodes) if (!allTargets.has(node)) startNodes.push(node);\n\t}\n\tfor (const step of bfs(startNodes, (n) => forwardNeighbours(graph, n))) reachable.add(step.state);\n\tconst orphans = [];\n\tfor (const [from, migrations] of graph.forwardChain) if (!reachable.has(from)) orphans.push(...migrations);\n\treturn orphans;\n}\n//#endregion\nexport { findPath as a, findReachableLeaves as c, findLeaf as i, reconstructGraph as l, detectOrphans as n, findPathWithDecision as o, findLatestMigration as r, findPathWithInvariants as s, detectCycles as t };\n\n//# sourceMappingURL=migration-graph-D6bN-mX0.mjs.map"],"mappings":";;;;;;;;;;;;;;AAcA,IAAI,QAAQ,MAAM;CACjB;CACA,OAAO;CACP,YAA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W,IAAI,KAAK,EAAE;EACjG,KAAK,MAAM,QAAQ,MAAM,OAAO,IAAI,CAAC,WAAW,IAAI,IAAI,GAAG,WAAW,KAAK,IAAI;CAChF;CACA,KAAK,MAAM,QAAQ,IAAI,aAAa,MAAM,kBAAkB,OAAO,CAAC,CAAC,GAAG,UAAU,IAAI,KAAK,KAAK;CAChG,MAAM,UAAU,CAAC;CACjB,KAAK,MAAM,CAAC,MAAM,eAAe,MAAM,cAAc,IAAI,CAAC,UAAU,IAAI,IAAI,GAAG,QAAQ,KAAK,GAAG,UAAU;CACzG,OAAO;AACR"}
1
+ {"version":3,"file":"migration-graph-DDaOHo10-yJFAbKCu.mjs","names":[],"sources":["../../../../1-framework/3-tooling/migration/dist/migration-graph-DDaOHo10.mjs"],"sourcesContent":["import { D as errorNoInitialMigration, k as errorNoTarget, n as errorAmbiguousTarget } from \"./errors-Co-8oaiB.mjs\";\nimport { t as EMPTY_CONTRACT_HASH } from \"./constants-CM-w38DQ.mjs\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { InternalError } from \"@internal/utils/internal-error\";\n//#region src/queue.ts\n/**\n* FIFO queue with amortised O(1) push and shift.\n*\n* Uses a head-index cursor over a backing array rather than\n* `Array.prototype.shift()`, which is O(n) on V8. Intended for BFS-shaped\n* traversals where the queue is drained in a single pass — it does not\n* reclaim memory for already-shifted items, so it is not suitable for\n* long-lived queues with many push/shift cycles.\n*/\nvar Queue = class {\n\titems;\n\thead = 0;\n\tconstructor(initial = []) {\n\t\tthis.items = [...initial];\n\t}\n\tpush(item) {\n\t\tthis.items.push(item);\n\t}\n\t/**\n\t* Remove and return the next item. Caller must check `isEmpty` first —\n\t* shifting an empty queue throws.\n\t*/\n\tshift() {\n\t\tif (this.head >= this.items.length) throw new InternalError(\"Queue.shift called on empty queue\");\n\t\treturn this.items[this.head++];\n\t}\n\tget isEmpty() {\n\t\treturn this.head >= this.items.length;\n\t}\n};\n//#endregion\n//#region src/graph-ops.ts\nfunction* bfs(starts, neighbours, key = (state) => state) {\n\tconst visited = /* @__PURE__ */ new Set();\n\tconst parentMap = /* @__PURE__ */ new Map();\n\tconst queue = new Queue();\n\tfor (const start of starts) {\n\t\tconst k = key(start);\n\t\tif (!visited.has(k)) {\n\t\t\tvisited.add(k);\n\t\t\tqueue.push({\n\t\t\t\tstate: start,\n\t\t\t\tkey: k\n\t\t\t});\n\t\t}\n\t}\n\twhile (!queue.isEmpty) {\n\t\tconst { state: current, key: curKey } = queue.shift();\n\t\tconst parentInfo = parentMap.get(curKey);\n\t\tyield {\n\t\t\tstate: current,\n\t\t\tparent: parentInfo?.parent ?? null,\n\t\t\tincomingEdge: parentInfo?.edge ?? null\n\t\t};\n\t\tfor (const { next, edge } of neighbours(current)) {\n\t\t\tconst k = key(next);\n\t\t\tif (!visited.has(k)) {\n\t\t\t\tvisited.add(k);\n\t\t\t\tparentMap.set(k, {\n\t\t\t\t\tparent: current,\n\t\t\t\t\tedge\n\t\t\t\t});\n\t\t\t\tqueue.push({\n\t\t\t\t\tstate: next,\n\t\t\t\t\tkey: k\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n}\n//#endregion\n//#region src/migration-graph.ts\n/** Forward-edge neighbours: edge `e` from `n` visits `e.to` next. */\nfunction forwardNeighbours(graph, node) {\n\treturn (graph.forwardChain.get(node) ?? []).map((edge) => ({\n\t\tnext: edge.to,\n\t\tedge\n\t}));\n}\n/**\n* Forward-edge neighbours, sorted by the deterministic tie-break.\n* Used by path-finding so the resulting shortest path is stable across runs.\n*/\nfunction sortedForwardNeighbours(graph, node) {\n\treturn [...graph.forwardChain.get(node) ?? []].sort(compareTieBreak).map((edge) => ({\n\t\tnext: edge.to,\n\t\tedge\n\t}));\n}\n/** Reverse-edge neighbours: edge `e` from `n` visits `e.from` next. */\nfunction reverseNeighbours(graph, node) {\n\treturn (graph.reverseChain.get(node) ?? []).map((edge) => ({\n\t\tnext: edge.from,\n\t\tedge\n\t}));\n}\nfunction appendEdge(map, key, entry) {\n\tconst bucket = map.get(key);\n\tif (bucket) bucket.push(entry);\n\telse map.set(key, [entry]);\n}\nfunction reconstructGraph(packages) {\n\tconst nodes = /* @__PURE__ */ new Set();\n\tconst forwardChain = /* @__PURE__ */ new Map();\n\tconst reverseChain = /* @__PURE__ */ new Map();\n\tconst migrationByHash = /* @__PURE__ */ new Map();\n\tfor (const pkg of packages) {\n\t\tconst from = pkg.metadata.from ?? \"empty\";\n\t\tconst { to } = pkg.metadata;\n\t\tnodes.add(from);\n\t\tnodes.add(to);\n\t\tconst migration = {\n\t\t\tfrom,\n\t\t\tto,\n\t\t\tmigrationHash: pkg.metadata.migrationHash,\n\t\t\tdirName: pkg.dirName,\n\t\t\tcreatedAt: pkg.metadata.createdAt,\n\t\t\tinvariants: pkg.metadata.providedInvariants\n\t\t};\n\t\tif (!migrationByHash.has(migration.migrationHash)) migrationByHash.set(migration.migrationHash, migration);\n\t\tappendEdge(forwardChain, from, migration);\n\t\tappendEdge(reverseChain, to, migration);\n\t}\n\treturn {\n\t\tnodes,\n\t\tforwardChain,\n\t\treverseChain,\n\t\tmigrationByHash\n\t};\n}\nfunction compareTieBreak(a, b) {\n\tconst ca = a.createdAt.localeCompare(b.createdAt);\n\tif (ca !== 0) return ca;\n\tconst tc = a.to.localeCompare(b.to);\n\tif (tc !== 0) return tc;\n\treturn a.migrationHash.localeCompare(b.migrationHash);\n}\nfunction sortedNeighbors(edges) {\n\treturn [...edges].sort(compareTieBreak);\n}\n/**\n* Find the shortest path from `fromHash` to `toHash` using BFS over the\n* contract-hash graph. Returns the ordered list of edges, or null if no path\n* exists. Returns an empty array when `fromHash === toHash` (no-op).\n*\n* Neighbor ordering is deterministic via the tie-break sort key:\n* createdAt → to → migrationHash.\n*/\nfunction findPath(graph, fromHash, toHash) {\n\tif (fromHash === toHash) return [];\n\tconst parents = /* @__PURE__ */ new Map();\n\tfor (const step of bfs([fromHash], (n) => sortedForwardNeighbours(graph, n))) {\n\t\tif (step.parent !== null && step.incomingEdge !== null) parents.set(step.state, {\n\t\t\tparent: step.parent,\n\t\t\tedge: step.incomingEdge\n\t\t});\n\t\tif (step.state === toHash) {\n\t\t\tconst path = [];\n\t\t\tlet cur = toHash;\n\t\t\tlet p = parents.get(cur);\n\t\t\twhile (p) {\n\t\t\t\tpath.push(p.edge);\n\t\t\t\tcur = p.parent;\n\t\t\t\tp = parents.get(cur);\n\t\t\t}\n\t\t\tpath.reverse();\n\t\t\treturn path;\n\t\t}\n\t}\n\treturn null;\n}\n/**\n* Find the shortest path from `fromHash` to `toHash` whose edges collectively\n* cover every invariant in `required`. Returns `null` when no such path exists\n* (either `fromHash`→`toHash` is structurally unreachable, or every reachable\n* path leaves at least one required invariant uncovered). When `required` is\n* empty, delegates to `findPath` so the result is byte-identical for that case.\n*\n* Algorithm: BFS over `(node, coveredSubset)` states with state-level dedup.\n* The covered subset is a `Set<string>` of invariant ids; the state's dedup\n* key is `${node}\\0${[...covered].sort().join('\\0')}`. State keys distinguish\n* distinct `(node, covered)` tuples regardless of node-name length because\n* `\\0` cannot appear in any invariant id (validation rejects whitespace and\n* control chars at authoring time).\n*\n* Neighbour ordering when `required ≠ ∅`: edges covering ≥1 still-needed\n* invariant come first, with `createdAt → to → migrationHash` as the\n* secondary key. The heuristic steers BFS toward the satisfying path;\n* correctness (shortest, deterministic) does not depend on it.\n*/\nfunction findPathWithInvariants(graph, fromHash, toHash, required) {\n\tif (required.size === 0) return findPath(graph, fromHash, toHash);\n\tconst stateKey = (s) => {\n\t\tif (s.covered.size === 0) return `${s.node}\\0`;\n\t\treturn `${s.node}\\0${[...s.covered].sort().join(\"\\0\")}`;\n\t};\n\tconst neighbours = (s) => {\n\t\tconst outgoing = graph.forwardChain.get(s.node) ?? [];\n\t\tif (outgoing.length === 0) return [];\n\t\treturn [...outgoing].map((edge) => {\n\t\t\tlet useful = false;\n\t\t\tlet next = null;\n\t\t\tfor (const inv of edge.invariants) if (required.has(inv) && !s.covered.has(inv)) {\n\t\t\t\tif (next === null) next = new Set(s.covered);\n\t\t\t\tnext.add(inv);\n\t\t\t\tuseful = true;\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tedge,\n\t\t\t\tuseful,\n\t\t\t\tnextCovered: next ?? s.covered\n\t\t\t};\n\t\t}).sort((a, b) => {\n\t\t\tif (a.useful !== b.useful) return a.useful ? -1 : 1;\n\t\t\treturn compareTieBreak(a.edge, b.edge);\n\t\t}).map(({ edge, nextCovered }) => ({\n\t\t\tnext: {\n\t\t\t\tnode: edge.to,\n\t\t\t\tcovered: nextCovered\n\t\t\t},\n\t\t\tedge\n\t\t}));\n\t};\n\tconst parents = /* @__PURE__ */ new Map();\n\tfor (const step of bfs([{\n\t\tnode: fromHash,\n\t\tcovered: /* @__PURE__ */ new Set()\n\t}], neighbours, stateKey)) {\n\t\tconst curKey = stateKey(step.state);\n\t\tif (step.parent !== null && step.incomingEdge !== null) parents.set(curKey, {\n\t\t\tparentKey: stateKey(step.parent),\n\t\t\tedge: step.incomingEdge\n\t\t});\n\t\tif (step.state.node === toHash && step.state.covered.size === required.size) {\n\t\t\tconst path = [];\n\t\t\tlet cur = curKey;\n\t\t\twhile (cur !== void 0) {\n\t\t\t\tconst p = parents.get(cur);\n\t\t\t\tif (!p) break;\n\t\t\t\tpath.push(p.edge);\n\t\t\t\tcur = p.parentKey;\n\t\t\t}\n\t\t\tpath.reverse();\n\t\t\treturn path;\n\t\t}\n\t}\n\treturn null;\n}\n/**\n* Reverse-BFS from `toHash` over `reverseChain` to collect every node from\n* which `toHash` is reachable (inclusive of `toHash` itself).\n*/\nfunction collectNodesReachingTarget(graph, toHash) {\n\tconst reached = /* @__PURE__ */ new Set();\n\tfor (const step of bfs([toHash], (n) => reverseNeighbours(graph, n))) reached.add(step.state);\n\treturn reached;\n}\n/**\n* Find the shortest path from `fromHash` to `toHash` and return structured\n* path-decision metadata for machine-readable output. When `required` is\n* non-empty, the returned path is the shortest one whose edges collectively\n* cover every required invariant.\n*\n* The discriminated return type tells the caller *why* a path could not be\n* found, so the CLI can pick the right structured error without re-running\n* a structural BFS.\n*/\nfunction findPathWithDecision(graph, fromHash, toHash, options = {}) {\n\tconst { refName, required = /* @__PURE__ */ new Set() } = options;\n\tconst requiredInvariants = [...required].sort();\n\tif (fromHash === toHash && required.size === 0) return {\n\t\tkind: \"ok\",\n\t\tdecision: {\n\t\t\tselectedPath: [],\n\t\t\tfromHash,\n\t\t\ttoHash,\n\t\t\talternativeCount: 0,\n\t\t\ttieBreakReasons: [],\n\t\t\trequiredInvariants,\n\t\t\tsatisfiedInvariants: [],\n\t\t\t...ifDefined(\"refName\", refName)\n\t\t}\n\t};\n\tconst path = findPathWithInvariants(graph, fromHash, toHash, required);\n\tif (!path) {\n\t\tif (required.size === 0) return { kind: \"unreachable\" };\n\t\tconst structural = findPath(graph, fromHash, toHash);\n\t\tif (structural === null) return { kind: \"unreachable\" };\n\t\tconst coveredByStructural = /* @__PURE__ */ new Set();\n\t\tfor (const edge of structural) for (const inv of edge.invariants) if (required.has(inv)) coveredByStructural.add(inv);\n\t\treturn {\n\t\t\tkind: \"unsatisfiable\",\n\t\t\tstructuralPath: structural,\n\t\t\tmissing: requiredInvariants.filter((id) => !coveredByStructural.has(id))\n\t\t};\n\t}\n\tconst satisfiedInvariants = computeSatisfiedInvariants(required, path);\n\tconst reachesTarget = collectNodesReachingTarget(graph, toHash);\n\tconst coveragePrefixes = requiredCoveragePrefixes(required, path);\n\tconst tieBreakReasons = [];\n\tlet alternativeCount = 0;\n\tfor (const [i, edge] of path.entries()) {\n\t\tconst outgoing = graph.forwardChain.get(edge.from);\n\t\tif (!outgoing || outgoing.length <= 1) continue;\n\t\tconst reachable = outgoing.filter((e) => reachesTarget.has(e.to));\n\t\tif (reachable.length <= 1) continue;\n\t\tlet comparisonPool = reachable;\n\t\tif (required.size > 0) {\n\t\t\tconst prefixSet = coveragePrefixes[i];\n\t\t\tif (prefixSet === void 0) continue;\n\t\t\tcomparisonPool = invariantViableAlternativesAtStep(required, prefixSet, reachable);\n\t\t}\n\t\talternativeCount += reachable.length - 1;\n\t\tif (sortedNeighbors(reachable)[0]?.migrationHash !== edge.migrationHash) continue;\n\t\tif (!reachable.some((e) => e.migrationHash !== edge.migrationHash)) continue;\n\t\tconst sortedViable = sortedNeighbors(comparisonPool);\n\t\tif (sortedViable.length > 1 && sortedViable[0]?.migrationHash === edge.migrationHash && sortedViable.some((e) => e.migrationHash !== edge.migrationHash)) tieBreakReasons.push(`at ${edge.from}: ${comparisonPool.length} candidates, selected by tie-break`);\n\t}\n\treturn {\n\t\tkind: \"ok\",\n\t\tdecision: {\n\t\t\tselectedPath: path,\n\t\t\tfromHash,\n\t\t\ttoHash,\n\t\t\talternativeCount,\n\t\t\ttieBreakReasons,\n\t\t\trequiredInvariants,\n\t\t\tsatisfiedInvariants,\n\t\t\t...ifDefined(\"refName\", refName)\n\t\t}\n\t};\n}\nfunction computeSatisfiedInvariants(required, path) {\n\tif (required.size === 0) return [];\n\tconst covered = /* @__PURE__ */ new Set();\n\tfor (const edge of path) for (const inv of edge.invariants) if (required.has(inv)) covered.add(inv);\n\treturn [...covered].sort();\n}\n/**\n* For each edge on path, invariant coverage accumulated from earlier edges only —\n* `(required ∩ ∪_{j<i} path[j].invariants)` represented as cumulative set along `required`,\n* keyed as \"full set of required ids satisfied before taking path[i]\".\n*/\nfunction requiredCoveragePrefixes(required, path) {\n\tconst prefixes = [];\n\tconst acc = /* @__PURE__ */ new Set();\n\tfor (const edge of path) {\n\t\tprefixes.push(new Set(acc));\n\t\tfor (const inv of edge.invariants) if (required.has(inv)) acc.add(inv);\n\t}\n\treturn prefixes;\n}\nfunction invariantViableAlternativesAtStep(required, coverageBeforeTakingEdge, outgoing) {\n\tif (required.size === 0) return [...outgoing];\n\treturn outgoing.filter((e) => [...required].every((id) => coverageBeforeTakingEdge.has(id) || e.invariants.includes(id)));\n}\n/**\n* Walk ancestors of each branch tip back to find the last node\n* that appears on all paths. Returns `fromHash` if no shared ancestor is found.\n*/\nfunction findDivergencePoint(graph, fromHash, leaves) {\n\tconst ancestorSets = leaves.map((leaf) => {\n\t\tconst ancestors = /* @__PURE__ */ new Set();\n\t\tfor (const step of bfs([leaf], (n) => reverseNeighbours(graph, n))) ancestors.add(step.state);\n\t\treturn ancestors;\n\t});\n\tconst commonAncestors = [...ancestorSets[0] ?? []].filter((node) => ancestorSets.every((s) => s.has(node)));\n\tlet deepest = fromHash;\n\tlet deepestDepth = -1;\n\tfor (const ancestor of commonAncestors) {\n\t\tconst path = findPath(graph, fromHash, ancestor);\n\t\tconst depth = path ? path.length : 0;\n\t\tif (depth > deepestDepth) {\n\t\t\tdeepestDepth = depth;\n\t\t\tdeepest = ancestor;\n\t\t}\n\t}\n\treturn deepest;\n}\n/**\n* Find all branch tips (nodes with no outgoing edges) reachable from\n* `fromHash` via forward edges.\n*/\nfunction findReachableLeaves(graph, fromHash) {\n\tconst leaves = [];\n\tfor (const step of bfs([fromHash], (n) => forwardNeighbours(graph, n))) if (!graph.forwardChain.get(step.state)?.length) leaves.push(step.state);\n\treturn leaves;\n}\n/**\n* Find the target contract hash of the migration graph reachable from\n* EMPTY_CONTRACT_HASH. Returns `null` for a graph that has no target\n* state (either empty, or containing only the root with no outgoing\n* edges). Throws NO_INITIAL_MIGRATION if the graph has nodes but none\n* originate from the empty hash, and AMBIGUOUS_TARGET if multiple\n* branch tips exist.\n*/\nfunction findLeaf(graph) {\n\tif (graph.nodes.size === 0) return null;\n\tif (!graph.nodes.has(\"empty\")) throw errorNoInitialMigration([...graph.nodes]);\n\tconst leaves = findReachableLeaves(graph, EMPTY_CONTRACT_HASH);\n\tif (leaves.length === 0) {\n\t\tconst reachable = [...graph.nodes].filter((n) => n !== EMPTY_CONTRACT_HASH);\n\t\tif (reachable.length > 0) throw errorNoTarget(reachable);\n\t\treturn null;\n\t}\n\tif (leaves.length > 1) {\n\t\tconst divergencePoint = findDivergencePoint(graph, EMPTY_CONTRACT_HASH, leaves);\n\t\tthrow errorAmbiguousTarget(leaves, {\n\t\t\tdivergencePoint,\n\t\t\tbranches: leaves.map((tip) => {\n\t\t\t\treturn {\n\t\t\t\t\ttip,\n\t\t\t\t\tedges: (findPath(graph, divergencePoint, tip) ?? []).map((e) => ({\n\t\t\t\t\t\tdirName: e.dirName,\n\t\t\t\t\t\tfrom: e.from,\n\t\t\t\t\t\tto: e.to\n\t\t\t\t\t}))\n\t\t\t\t};\n\t\t\t})\n\t\t});\n\t}\n\treturn leaves[0];\n}\n/**\n* Find the latest migration entry by traversing from EMPTY_CONTRACT_HASH\n* to the single target. Returns null for an empty graph.\n* Throws AMBIGUOUS_TARGET if the graph has multiple branch tips.\n*/\nfunction findLatestMigration(graph) {\n\tconst leafHash = findLeaf(graph);\n\tif (leafHash === null) return null;\n\treturn findPath(graph, \"empty\", leafHash)?.at(-1) ?? null;\n}\nfunction detectCycles(graph) {\n\tconst WHITE = 0;\n\tconst GRAY = 1;\n\tconst BLACK = 2;\n\tconst color = /* @__PURE__ */ new Map();\n\tconst parentMap = /* @__PURE__ */ new Map();\n\tconst cycles = [];\n\tfor (const node of graph.nodes) color.set(node, WHITE);\n\tconst stack = [];\n\tfunction pushFrame(u) {\n\t\tcolor.set(u, GRAY);\n\t\tstack.push({\n\t\t\tnode: u,\n\t\t\toutgoing: graph.forwardChain.get(u) ?? [],\n\t\t\tindex: 0\n\t\t});\n\t}\n\tfor (const root of graph.nodes) {\n\t\tif (color.get(root) !== WHITE) continue;\n\t\tparentMap.set(root, null);\n\t\tpushFrame(root);\n\t\twhile (stack.length > 0) {\n\t\t\tconst frame = stack[stack.length - 1];\n\t\t\tif (frame.index >= frame.outgoing.length) {\n\t\t\t\tcolor.set(frame.node, BLACK);\n\t\t\t\tstack.pop();\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst v = frame.outgoing[frame.index++].to;\n\t\t\tconst vColor = color.get(v);\n\t\t\tif (vColor === GRAY) {\n\t\t\t\tconst cycle = [v];\n\t\t\t\tlet cur = frame.node;\n\t\t\t\twhile (cur !== v) {\n\t\t\t\t\tcycle.push(cur);\n\t\t\t\t\tcur = parentMap.get(cur) ?? v;\n\t\t\t\t}\n\t\t\t\tcycle.reverse();\n\t\t\t\tcycles.push(cycle);\n\t\t\t} else if (vColor === WHITE) {\n\t\t\t\tparentMap.set(v, frame.node);\n\t\t\t\tpushFrame(v);\n\t\t\t}\n\t\t}\n\t}\n\treturn cycles;\n}\nfunction detectOrphans(graph) {\n\tif (graph.nodes.size === 0) return [];\n\tconst reachable = /* @__PURE__ */ new Set();\n\tconst startNodes = [];\n\tif (graph.forwardChain.has(\"empty\")) startNodes.push(EMPTY_CONTRACT_HASH);\n\telse {\n\t\tconst allTargets = /* @__PURE__ */ new Set();\n\t\tfor (const edges of graph.forwardChain.values()) for (const edge of edges) allTargets.add(edge.to);\n\t\tfor (const node of graph.nodes) if (!allTargets.has(node)) startNodes.push(node);\n\t}\n\tfor (const step of bfs(startNodes, (n) => forwardNeighbours(graph, n))) reachable.add(step.state);\n\tconst orphans = [];\n\tfor (const [from, migrations] of graph.forwardChain) if (!reachable.has(from)) orphans.push(...migrations);\n\treturn orphans;\n}\n//#endregion\nexport { findPath as a, findReachableLeaves as c, findLeaf as i, reconstructGraph as l, detectOrphans as n, findPathWithDecision as o, findLatestMigration as r, findPathWithInvariants as s, detectCycles as t };\n\n//# sourceMappingURL=migration-graph-DDaOHo10.mjs.map"],"mappings":";;;;;;;;;;;;;;AAcA,IAAI,QAAQ,MAAM;CACjB;CACA,OAAO;CACP,YAAY,UAAU,CAAC,GAAG;EACzB,KAAK,QAAQ,CAAC,GAAG,OAAO;CACzB;CACA,KAAK,MAAM;EACV,KAAK,MAAM,KAAK,IAAI;CACrB;;;;;CAKA,QAAQ;EACP,IAAI,KAAK,QAAQ,KAAK,MAAM,QAAQ,MAAM,IAAI,cAAc,mCAAmC;EAC/F,OAAO,KAAK,MAAM,KAAK;CACxB;CACA,IAAI,UAAU;EACb,OAAO,KAAK,QAAQ,KAAK,MAAM;CAChC;AACD;AAGA,UAAU,IAAI,Q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,QAAQ,KAAK,GAAG,UAAU;CACzG,OAAO;AACR"}
@@ -1,9 +1,10 @@
1
- import "./constants-CM-w38DQ-Cz_EXbOc.mjs";
2
- import { W as formatStyledHeader, ct as setCommandSeeAlso, et as parseGlobalFlagsOrExit, it as resolveMigrationPaths, o as createTerminalUI, ot as setCommandDescriptions, q as handleResult, r as addGlobalOptions, st as setCommandExamples } from "./command-helpers-C4WpR-QE-CK2gkj6l.mjs";
1
+ import { W as formatStyledHeader, ct as setCommandSeeAlso, et as parseGlobalFlagsOrExit, it as resolveMigrationPaths, o as createTerminalUI, ot as setCommandDescriptions, q as handleResult, r as addGlobalOptions, st as setCommandExamples } from "./command-helpers-C4WpR-QE-DE494TSG.mjs";
3
2
  import { r as loadConfig } from "./exports-CDX9kZuw.mjs";
4
- import { n as buildReadAggregate } from "./contract-space-aggregate-loader-CziO_ZRW-DIoQOL0P.mjs";
3
+ import { r as buildReadAggregate } from "./contract-space-aggregate-loader-C5r12INu-Db_pa3rX.mjs";
4
+ import { n as migrationSpaceListEntriesFromAggregate, r as runMigrationList, t as listRefsByContractHash } from "./migration-list-C9OPCMt--C28yBgVr.mjs";
5
5
  import { _ as renderMigrationGraphSpaceTree, a as computeGlobalMaxDirNameWidth, f as indentMigrationGraphTreeBlock, g as renderMigrationGraphLegend, o as computeGlobalMaxEdgeTreePrefixWidth } from "./migration-graph-command-render-BKrg6BPv-BP8Pfj4J.mjs";
6
- import { c as validateLegendOptions, i as migrationSpaceListEntriesFromAggregate, o as runMigrationList, r as listRefsByContractHash, s as shouldShowLegend } from "./migration-list-D2_JdzWC-MRHYYVQE.mjs";
6
+ import { n as validateLegendOptions, t as shouldShowLegend } from "./legend-5iwwlLU2-CB8bdQKJ.mjs";
7
+ import { t as buildMigrationSpaceGraphEntries } from "./migration-graph-HKch1Xk4-DyWhXtjZ.mjs";
7
8
  import { ifDefined } from "@prisma/orm-framework/utils/defined";
8
9
  import { ok } from "@prisma/orm-framework/utils/result";
9
10
  import { Command } from "commander";
@@ -76,7 +77,6 @@ async function executeMigrationGraphCommand(options, flags, ui) {
76
77
  const globalMaxEdgeTreePrefixWidth = globalLayoutInputs.length > 0 ? computeGlobalMaxEdgeTreePrefixWidth(globalLayoutInputs) : void 0;
77
78
  const globalMaxDirNameWidth = globalLayoutInputs.length > 0 ? computeGlobalMaxDirNameWidth(globalLayoutInputs) : void 0;
78
79
  const treeSections = [];
79
- const spaces = [];
80
80
  for (const spaceEntry of scopedSpaces) {
81
81
  const space = aggregate.space(spaceEntry.space);
82
82
  if (space === void 0) continue;
@@ -100,20 +100,11 @@ async function executeMigrationGraphCommand(options, flags, ui) {
100
100
  tree: displayTree,
101
101
  showHeading: showSpaceHeadings
102
102
  });
103
- spaces.push({
104
- space: spaceEntry.space,
105
- contracts: [...graph.nodes].map((hash) => ({
106
- hash,
107
- refs: [...refsByHash.get(hash) ?? []]
108
- })),
109
- migrations: [...graph.migrationByHash.values()].map((edge) => ({
110
- name: edge.dirName,
111
- hash: edge.migrationHash,
112
- fromContract: edge.from === "empty" ? null : edge.from,
113
- toContract: edge.to
114
- }))
115
- });
116
103
  }
104
+ const spaces = [...buildMigrationSpaceGraphEntries({
105
+ aggregate,
106
+ scopedSpaces
107
+ })];
117
108
  return ok({
118
109
  ok: true,
119
110
  graph: appGraph,
@@ -182,4 +173,4 @@ function createMigrationGraphCommand() {
182
173
  //#endregion
183
174
  export { executeMigrationGraphCommand as n, formatMigrationGraphHumanOutput as r, createMigrationGraphCommand as t };
184
175
 
185
- //# sourceMappingURL=migration-graph-BL6vfLcE.mjs.map
176
+ //# sourceMappingURL=migration-graph-Dn469b0l.mjs.map