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

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 (170) hide show
  1. package/dist/{aggregate-B4mhR4Sk.mjs → aggregate-i-rfetSO.mjs} +8 -8
  2. package/dist/{aggregate-B4mhR4Sk.mjs.map → aggregate-i-rfetSO.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/cli.mjs +2 -2
  6. package/dist/cli.mjs.map +1 -1
  7. package/dist/cli__commands__contract-emit.mjs +1 -1
  8. package/dist/cli__commands__contract-infer.mjs +1 -1
  9. package/dist/cli__commands__db-init.mjs +1 -1
  10. package/dist/cli__commands__db-schema.mjs +1 -1
  11. package/dist/cli__commands__db-sign.mjs +1 -1
  12. package/dist/cli__commands__db-update.mjs +1 -1
  13. package/dist/cli__commands__db-verify.mjs +1 -1
  14. package/dist/cli__commands__migrate.d.mts +1 -1
  15. package/dist/cli__commands__migrate.mjs +1 -1
  16. package/dist/cli__commands__migration-check.d.mts +1 -1
  17. package/dist/cli__commands__migration-check.mjs +1 -1
  18. package/dist/cli__commands__migration-graph.d.mts +1 -1
  19. package/dist/cli__commands__migration-graph.mjs +1 -1
  20. package/dist/cli__commands__migration-list.d.mts +1 -1
  21. package/dist/cli__commands__migration-list.mjs +1 -1
  22. package/dist/cli__commands__migration-log.d.mts +1 -1
  23. package/dist/cli__commands__migration-log.mjs +1 -1
  24. package/dist/cli__commands__migration-new.mjs +1 -1
  25. package/dist/cli__commands__migration-plan.mjs +1 -1
  26. package/dist/cli__commands__migration-show.mjs +1 -1
  27. package/dist/cli__commands__migration-status.d.mts +1 -1
  28. package/dist/cli__commands__migration-status.mjs +1 -1
  29. package/dist/cli__commands__ref.d.mts +1 -1
  30. package/dist/cli__commands__ref.mjs +1 -1
  31. package/dist/cli__commands__telemetry.mjs +1 -1
  32. package/dist/cli__control-api.d.mts +1 -1
  33. package/dist/cli__control-api.mjs +2 -2
  34. package/dist/cli__migration-cli.mjs +3 -6
  35. package/dist/cli__migration-cli.mjs.map +1 -1
  36. package/dist/{client-75qrAPqf-7l0C0H_b.mjs → client-7aUYC7ci-Bh9mLxkl.mjs} +16 -12
  37. package/dist/client-7aUYC7ci-Bh9mLxkl.mjs.map +1 -0
  38. package/dist/{command-helpers-CAoXqAY9-DWUBcTXM.mjs → command-helpers-C4WpR-QE-CK2gkj6l.mjs} +30 -74
  39. package/dist/command-helpers-C4WpR-QE-CK2gkj6l.mjs.map +1 -0
  40. package/dist/contract-at-errors-YdCQ5OOk-okxG7Eaj.mjs +44 -0
  41. package/dist/contract-at-errors-YdCQ5OOk-okxG7Eaj.mjs.map +1 -0
  42. package/dist/{contract-emit-B6odMoem-C87PBvmo.mjs → contract-emit-CTm2zfuG-8mtkxW8M.mjs} +12 -11
  43. package/dist/contract-emit-CTm2zfuG-8mtkxW8M.mjs.map +1 -0
  44. package/dist/{contract-emit-0hSjbuxp-BJLC-VgC.mjs → contract-emit-D8IXP9Qp-CecAQio1.mjs} +4 -4
  45. package/dist/{contract-emit-0hSjbuxp-BJLC-VgC.mjs.map → contract-emit-D8IXP9Qp-CecAQio1.mjs.map} +1 -1
  46. package/dist/{contract-infer-BnkqpftN-DwBzasOu.mjs → contract-infer-C8-RqHeK-D_dm3onP.mjs} +5 -5
  47. package/dist/contract-infer-C8-RqHeK-D_dm3onP.mjs.map +1 -0
  48. package/dist/{contract-snapshot-store-sf5nP4mb-MLpG-ihh.mjs → contract-snapshot-store-DNTOE6fB-BDpjbdCJ.mjs} +3 -3
  49. package/dist/{contract-snapshot-store-sf5nP4mb-MLpG-ihh.mjs.map → contract-snapshot-store-DNTOE6fB-BDpjbdCJ.mjs.map} +1 -1
  50. package/dist/{contract-space-aggregate-loader-CFH-336b-BhAyRQEL.mjs → contract-space-aggregate-loader-CziO_ZRW-DIoQOL0P.mjs} +6 -6
  51. package/dist/contract-space-aggregate-loader-CziO_ZRW-DIoQOL0P.mjs.map +1 -0
  52. package/dist/{db-init-bd0_x2Q8.mjs → db-init-CXMcvoIA.mjs} +9 -12
  53. package/dist/db-init-CXMcvoIA.mjs.map +1 -0
  54. package/dist/{db-schema-CwgAWTqG.mjs → db-schema-j8DERh4t.mjs} +4 -4
  55. package/dist/{db-schema-CwgAWTqG.mjs.map → db-schema-j8DERh4t.mjs.map} +1 -1
  56. package/dist/{db-sign-vqiYfpjI.mjs → db-sign-xV_rpoIc.mjs} +10 -10
  57. package/dist/db-sign-xV_rpoIc.mjs.map +1 -0
  58. package/dist/{db-update-Br0diOCo.mjs → db-update-DXa2DIvu.mjs} +11 -11
  59. package/dist/db-update-DXa2DIvu.mjs.map +1 -0
  60. package/dist/{db-verify-CKPsRFrj-T7nSt7yT.mjs → db-verify-YWHjuKC7-DidK1gx1.mjs} +9 -6
  61. package/dist/db-verify-YWHjuKC7-DidK1gx1.mjs.map +1 -0
  62. package/dist/{errors--qsXZUtL.d.mts → errors-AkMBj-YP.d.mts} +8 -8
  63. package/dist/errors-AkMBj-YP.d.mts.map +1 -0
  64. package/dist/{errors-IpZm1Skp-BH495dRd.mjs → errors-BwusfLIN-BXM7K-ww.mjs} +42 -51
  65. package/dist/errors-BwusfLIN-BXM7K-ww.mjs.map +1 -0
  66. package/dist/{format-ByDm2goZ-BIRlFoo6.mjs → format-Bw3LVJ1v-D10inUT9.mjs} +12 -9
  67. package/dist/format-Bw3LVJ1v-D10inUT9.mjs.map +1 -0
  68. package/dist/{framework-components-CjshQKHA-Dlp6Leo5.mjs → framework-components-3DdB31mk-BPGSuOyZ.mjs} +3 -3
  69. package/dist/{framework-components-CjshQKHA-Dlp6Leo5.mjs.map → framework-components-3DdB31mk-BPGSuOyZ.mjs.map} +1 -1
  70. package/dist/{graph-membership-DW6nnbyQ-Bp2KcVwR.mjs → graph-membership-h9ejuZla-ewjYM5wz.mjs} +3 -3
  71. package/dist/{graph-membership-DW6nnbyQ-Bp2KcVwR.mjs.map → graph-membership-h9ejuZla-ewjYM5wz.mjs.map} +1 -1
  72. package/dist/{init-BGm77aWc-jHVUn63W.mjs → init-CPB89WK2-Di4kgP6B.mjs} +4 -4
  73. package/dist/{init-BGm77aWc-jHVUn63W.mjs.map → init-CPB89WK2-Di4kgP6B.mjs.map} +1 -1
  74. package/dist/{inspect-live-schema-CnwYTRZ0-P-6asJFl.mjs → inspect-live-schema-DEYE4EHW-DmSfKdpv.mjs} +4 -4
  75. package/dist/{inspect-live-schema-CnwYTRZ0-P-6asJFl.mjs.map → inspect-live-schema-DEYE4EHW-DmSfKdpv.mjs.map} +1 -1
  76. package/dist/{invariants-lXzy6txi-DAoP4nTE.mjs → invariants-CMcQxRas-CXX9uhQW.mjs} +3 -3
  77. package/dist/{invariants-lXzy6txi-DAoP4nTE.mjs.map → invariants-CMcQxRas-CXX9uhQW.mjs.map} +1 -1
  78. package/dist/{io-C8TdyBKt-DloEBi70.mjs → io-CL3hSv42-DGZtTs89.mjs} +8 -8
  79. package/dist/{io-C8TdyBKt-DloEBi70.mjs.map → io-CL3hSv42-DGZtTs89.mjs.map} +1 -1
  80. package/dist/{migrate-BdVFDKF2.mjs → migrate-COusRrm7.mjs} +28 -22
  81. package/dist/migrate-COusRrm7.mjs.map +1 -0
  82. package/dist/{migration-check-CcG-fB8r-qpu6xdbA.mjs → migration-check-CueEJelQ-J81XR_ns.mjs} +10 -10
  83. package/dist/migration-check-CueEJelQ-J81XR_ns.mjs.map +1 -0
  84. package/dist/{migration-command-scaffold-BCuoeAki-DMy_5ztW.mjs → migration-command-scaffold-DNRo4exb-9JCezdoT.mjs} +4 -4
  85. package/dist/{migration-command-scaffold-BCuoeAki-DMy_5ztW.mjs.map → migration-command-scaffold-DNRo4exb-9JCezdoT.mjs.map} +1 -1
  86. package/dist/{migration-BuUmO7It.mjs → migration-diUAhNaa.mjs} +3 -3
  87. package/dist/{migration-BuUmO7It.mjs.map → migration-diUAhNaa.mjs.map} +1 -1
  88. package/dist/{migration-graph-vmgkL3k4.mjs → migration-graph-BL6vfLcE.mjs} +4 -4
  89. package/dist/{migration-graph-vmgkL3k4.mjs.map → migration-graph-BL6vfLcE.mjs.map} +1 -1
  90. package/dist/{migration-graph-CBf9ORe7-B4xAF8GN.mjs → migration-graph-D6bN-mX0-DwMWY8DA.mjs} +3 -3
  91. package/dist/{migration-graph-CBf9ORe7-B4xAF8GN.mjs.map → migration-graph-D6bN-mX0-DwMWY8DA.mjs.map} +1 -1
  92. package/dist/{migration-list-BFBeo1_X-ckYMhETH.mjs → migration-list-D2_JdzWC-MRHYYVQE.mjs} +6 -6
  93. package/dist/{migration-list-BFBeo1_X-ckYMhETH.mjs.map → migration-list-D2_JdzWC-MRHYYVQE.mjs.map} +1 -1
  94. package/dist/{migration-log-CS5IWcNq-DI7FTHCA.mjs → migration-log-BXbz6-Lj-CKHbat5f.mjs} +4 -6
  95. package/dist/migration-log-BXbz6-Lj-CKHbat5f.mjs.map +1 -0
  96. package/dist/{migration-new-GmW2anVb.mjs → migration-new-szZFsA3C.mjs} +16 -15
  97. package/dist/migration-new-szZFsA3C.mjs.map +1 -0
  98. package/dist/{migration-path-target-D3Sj55PI-BICblCuk.mjs → migration-path-target-BPYp3LNc-qRQlG_Yn.mjs} +4 -4
  99. package/dist/migration-path-target-BPYp3LNc-qRQlG_Yn.mjs.map +1 -0
  100. package/dist/{migration-plan-q_L84PN1-ClkGgtVz.mjs → migration-plan-CxXAXYc8-Dnp-v8Nl.mjs} +17 -18
  101. package/dist/migration-plan-CxXAXYc8-Dnp-v8Nl.mjs.map +1 -0
  102. package/dist/{migration-show--pW4XhKs.mjs → migration-show-BKsIh7Uz.mjs} +9 -9
  103. package/dist/migration-show-BKsIh7Uz.mjs.map +1 -0
  104. package/dist/{migration-status-CFlzlRmu-QHUxHm_l.mjs → migration-status-CNnRInne--cvmx56T.mjs} +15 -15
  105. package/dist/migration-status-CNnRInne--cvmx56T.mjs.map +1 -0
  106. package/dist/migration-tools.d.mts +2 -2
  107. package/dist/migration-tools.mjs +12 -12
  108. package/dist/migration-tools__aggregate.mjs +1 -1
  109. package/dist/migration-tools__contract-snapshot-store.mjs +1 -1
  110. package/dist/migration-tools__errors.d.mts +1 -1
  111. package/dist/migration-tools__errors.mjs +1 -1
  112. package/dist/migration-tools__invariants.mjs +1 -1
  113. package/dist/migration-tools__io.mjs +1 -1
  114. package/dist/migration-tools__migration-graph.mjs +2 -2
  115. package/dist/migration-tools__migration.mjs +1 -1
  116. package/dist/migration-tools__ref-resolution.mjs +1 -1
  117. package/dist/migration-tools__refs.mjs +1 -1
  118. package/dist/migration-tools__spaces.d.mts +1 -1
  119. package/dist/migration-tools__spaces.mjs +2 -2
  120. package/dist/{project-import-root-CpwLCDLY-DkVwAnWj.mjs → project-import-root-C_bd0ooL-CLXW-gp6.mjs} +10 -8
  121. package/dist/project-import-root-C_bd0ooL-CLXW-gp6.mjs.map +1 -0
  122. package/dist/{ref-sHE8zOcm.mjs → ref-DjZ5Y8ju.mjs} +11 -11
  123. package/dist/ref-DjZ5Y8ju.mjs.map +1 -0
  124. package/dist/{ref-advancement-CSPMoQs3-fEipZrdu.mjs → ref-advancement-CSPMoQs3-CPkL3IFF.mjs} +4 -4
  125. package/dist/{ref-advancement-CSPMoQs3-fEipZrdu.mjs.map → ref-advancement-CSPMoQs3-CPkL3IFF.mjs.map} +1 -1
  126. package/dist/{ref-resolution-BjJBWPjX.mjs → ref-resolution-BsdziDFA.mjs} +2 -2
  127. package/dist/{ref-resolution-BjJBWPjX.mjs.map → ref-resolution-BsdziDFA.mjs.map} +1 -1
  128. package/dist/{refs-BDbB9BRB-D6Za3Q49.mjs → refs-DtoeUivZ-qay0UMSP.mjs} +6 -6
  129. package/dist/refs-DtoeUivZ-qay0UMSP.mjs.map +1 -0
  130. package/dist/{spaces-C27bA-xc.mjs → spaces-BNd2Tlk0.mjs} +7 -7
  131. package/dist/spaces-BNd2Tlk0.mjs.map +1 -0
  132. package/dist/{spaces-DxFj5y8l.d.mts → spaces-D5qtTlhj.d.mts} +2 -2
  133. package/dist/{spaces-DxFj5y8l.d.mts.map → spaces-D5qtTlhj.d.mts.map} +1 -1
  134. package/dist/{telemetry-CmbCa3Ld-CmE5zcIG.mjs → telemetry-DVBHDQd6-BEdoMii0.mjs} +3 -3
  135. package/dist/{telemetry-CmbCa3Ld-CmE5zcIG.mjs.map → telemetry-DVBHDQd6-BEdoMii0.mjs.map} +1 -1
  136. package/dist/{types-DZWEs4si-D8UlyJI0.d.mts → types-2n_H3DQ9-Bks8UPEO.d.mts} +8 -2
  137. package/dist/types-2n_H3DQ9-Bks8UPEO.d.mts.map +1 -0
  138. package/dist/{verify-DnVNjc5C-BGdsblBK.mjs → verify-C6L_hiJU-CN3eEe3Y.mjs} +3 -3
  139. package/dist/{verify-DnVNjc5C-BGdsblBK.mjs.map → verify-C6L_hiJU-CN3eEe3Y.mjs.map} +1 -1
  140. package/dist/{verify-contract-spaces-BZDcJsuA-De8v4Z4T.mjs → verify-contract-spaces-Ak73-zQK-y4qVyu-y.mjs} +4 -4
  141. package/dist/{verify-contract-spaces-BZDcJsuA-De8v4Z4T.mjs.map → verify-contract-spaces-Ak73-zQK-y4qVyu-y.mjs.map} +1 -1
  142. package/dist/vite-plugin-contract-emit.mjs +1 -1
  143. package/package.json +12 -12
  144. package/dist/client-75qrAPqf-7l0C0H_b.mjs.map +0 -1
  145. package/dist/command-helpers-CAoXqAY9-DWUBcTXM.mjs.map +0 -1
  146. package/dist/contract-at-errors-BX7w-p19-SxA8eaV2.mjs +0 -36
  147. package/dist/contract-at-errors-BX7w-p19-SxA8eaV2.mjs.map +0 -1
  148. package/dist/contract-emit-B6odMoem-C87PBvmo.mjs.map +0 -1
  149. package/dist/contract-infer-BnkqpftN-DwBzasOu.mjs.map +0 -1
  150. package/dist/contract-space-aggregate-loader-CFH-336b-BhAyRQEL.mjs.map +0 -1
  151. package/dist/db-init-bd0_x2Q8.mjs.map +0 -1
  152. package/dist/db-sign-vqiYfpjI.mjs.map +0 -1
  153. package/dist/db-update-Br0diOCo.mjs.map +0 -1
  154. package/dist/db-verify-CKPsRFrj-T7nSt7yT.mjs.map +0 -1
  155. package/dist/errors--qsXZUtL.d.mts.map +0 -1
  156. package/dist/errors-IpZm1Skp-BH495dRd.mjs.map +0 -1
  157. package/dist/format-ByDm2goZ-BIRlFoo6.mjs.map +0 -1
  158. package/dist/migrate-BdVFDKF2.mjs.map +0 -1
  159. package/dist/migration-check-CcG-fB8r-qpu6xdbA.mjs.map +0 -1
  160. package/dist/migration-log-CS5IWcNq-DI7FTHCA.mjs.map +0 -1
  161. package/dist/migration-new-GmW2anVb.mjs.map +0 -1
  162. package/dist/migration-path-target-D3Sj55PI-BICblCuk.mjs.map +0 -1
  163. package/dist/migration-plan-q_L84PN1-ClkGgtVz.mjs.map +0 -1
  164. package/dist/migration-show--pW4XhKs.mjs.map +0 -1
  165. package/dist/migration-status-CFlzlRmu-QHUxHm_l.mjs.map +0 -1
  166. package/dist/project-import-root-CpwLCDLY-DkVwAnWj.mjs.map +0 -1
  167. package/dist/ref-sHE8zOcm.mjs.map +0 -1
  168. package/dist/refs-BDbB9BRB-D6Za3Q49.mjs.map +0 -1
  169. package/dist/spaces-C27bA-xc.mjs.map +0 -1
  170. package/dist/types-DZWEs4si-D8UlyJI0.d.mts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"migration-command-scaffold-BCuoeAki-DMy_5ztW.mjs","names":[],"sources":["../../../../1-framework/3-tooling/cli/dist/migration-command-scaffold-BCuoeAki.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-CAoXqAY9.mjs\";\nimport { t as createProgressAdapter } from \"./progress-adapter-CjAeTxY_.mjs\";\nimport { t as createControlClient } from \"./client-75qrAPqf.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-BCuoeAki.mjs.map"],"mappings":";;;;;;;;;;;;;;;;;AAiBA,eAAe,wBAAwB,SAAS,OAAO,IAAI,YAAY;CACtE,MAAM,SAAS,MAAM,WAAW,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AAe,QAAQ,MAAM,OAAO,IAAI;CAC9C,IAAI,CAAC,cAAc,OAAO,MAAM,gCAAgC;EAC/D,KAAK,uCAAuC,WAAW,YAAY,yBAAyB,WAAW;EACvG,aAAa,WAAW;CACzB,CAAC,CAAC;CACF,IAAI,CAAC,OAAO,QAAQ,OAAO,MAAM,oBAAoB,EAAE,KAAK,iCAAiC,WAAW,cAAc,CAAC,CAAC;CACxH,IAAI,CAAC,cAAc,OAAO,MAAM,GAAG,OAAO,MAAM,iCAAiC,EAAE,KAAK,WAAW,OAAO,OAAO,GAAG,+BAA+B,CAAC,CAAC;CACrJ,MAAM,SAAS,oBAAoB;EAClC,QAAQ,OAAO;EACf,QAAQ,OAAO;EACf,SAAS,OAAO;EAChB,QAAQ,OAAO;EACf,YAAY,OAAO,cAAc,CAAC;CACnC,CAAC;CACD,MAAM,aAAa,sBAAsB;EACxC;EACA;CACD,CAAC;CACD,OAAO,GAAG;EACT;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACD,CAAC;AACF;;;;AAIA,SAAS,2BAA2B,SAAS;CAC5C,iBAAiB,OAAO;CACxB,OAAO,QAAQ,OAAO,cAAc,4BAA4B,CAAC,CAAC,OAAO,mBAAmB,+BAA+B,CAAC,CAAC,OAAO,aAAa,+CAA+C,KAAK;AACtM"}
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,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AC,cAAc,OAAO,MAAM,gCAAgC;EAC/D,KAAK,uCAAuC,WAAW,YAAY,yBAAyB,WAAW;EACvG,aAAa,WAAW;CACzB,CAAC,CAAC;CACF,IAAI,CAAC,OAAO,QAAQ,OAAO,MAAM,oBAAoB,EAAE,KAAK,iCAAiC,WAAW,cAAc,CAAC,CAAC;CACxH,IAAI,CAAC,cAAc,OAAO,MAAM,GAAG,OAAO,MAAM,iCAAiC,EAAE,KAAK,WAAW,OAAO,OAAO,GAAG,+BAA+B,CAAC,CAAC;CACrJ,MAAM,SAAS,oBAAoB;EAClC,QAAQ,OAAO;EACf,QAAQ,OAAO;EACf,SAAS,OAAO;EAChB,QAAQ,OAAO;EACf,YAAY,OAAO,cAAc,CAAC;CACnC,CAAC;CACD,MAAM,aAAa,sBAAsB;EACxC;EACA;CACD,CAAC;CACD,OAAO,GAAG;EACT;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACD,CAAC;AACF;;;;AAIA,SAAS,2BAA2B,SAAS;CAC5C,iBAAiB,OAAO;CACxB,OAAO,QAAQ,OAAO,cAAc,4BAA4B,CAAC,CAAC,OAAO,mBAAmB,+BAA+B,CAAC,CAAC,OAAO,aAAa,+CAA+C,KAAK;AACtM"}
@@ -1,6 +1,6 @@
1
- import { A as errorOperationsNotArray, c as errorDescribeMissingEndContract, s as errorDescribeInvalidMetadata, v as errorInvalidOperationEntry, w as errorMigrationContractViewMissing } from "./errors-IpZm1Skp-BH495dRd.mjs";
1
+ import { A as errorOperationsNotArray, c as errorDescribeMissingEndContract, s as errorDescribeInvalidMetadata, v as errorInvalidOperationEntry, w as errorMigrationContractViewMissing } from "./errors-BwusfLIN-BXM7K-ww.mjs";
2
2
  import { t as computeMigrationHash } from "./hash-DH8hl5Rq-BpM2t3Nu.mjs";
3
- import { t as deriveProvidedInvariants } from "./invariants-lXzy6txi-DAoP4nTE.mjs";
3
+ import { t as deriveProvidedInvariants } from "./invariants-CMcQxRas-CXX9uhQW.mjs";
4
4
  import { t as MigrationOpSchema } from "./op-schema-BSVHzEQN-DIWt28D8.mjs";
5
5
  import { type } from "arktype";
6
6
  import { realpathSync } from "node:fs";
@@ -206,4 +206,4 @@ async function buildMigrationArtifacts(instance, existing) {
206
206
  //#endregion
207
207
  export { isDirectEntrypoint as i, MigrationContractViews as n, buildMigrationArtifacts as r, Migration as t };
208
208
 
209
- //# sourceMappingURL=migration-BuUmO7It.mjs.map
209
+ //# sourceMappingURL=migration-diUAhNaa.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"migration-BuUmO7It.mjs","names":["#endView","#startView"],"sources":["../../../../1-framework/3-tooling/migration/dist/exports/migration.mjs"],"sourcesContent":["import { A as errorOperationsNotArray, c as errorDescribeMissingEndContract, s as errorDescribeInvalidMetadata, v as errorInvalidOperationEntry, w as errorMigrationContractViewMissing } from \"../errors-IpZm1Skp.mjs\";\nimport { t as computeMigrationHash } from \"../hash-DH8hl5Rq.mjs\";\nimport { t as deriveProvidedInvariants } from \"../invariants-lXzy6txi.mjs\";\nimport { t as MigrationOpSchema } from \"../op-schema-BSVHzEQN.mjs\";\nimport { type } from \"arktype\";\nimport { realpathSync } from \"node:fs\";\nimport { fileURLToPath } from \"node:url\";\n//#region src/migration-base.ts\nconst MigrationMetaSchema = type({\n\tfrom: \"string > 0 | null\",\n\tto: \"string\"\n});\n/**\n* Base class for migrations.\n*\n* A `Migration` subclass is itself a `MigrationPlan`: CLI commands and the\n* runner can consume it directly via `targetId`, `operations`, `origin`, and\n* `destination`.\n*\n* The from/to identities come from `describe()`. A migration provides them in\n* one of two ways:\n* - **Contract-derived (default):** assign the `contract.json` imports from\n* the snapshot store (`migrations/snapshots/<hex>/contract.json`) to\n* `startContractJson` / `endContractJson`; the concrete `describe()` below\n* derives `to`/`from` from their\n* `storage.storageHash`. The family bases additionally expose typed view\n* getters (`startContract` / `endContract`) over the same JSON.\n* - **Override (e.g. extension migrations that carry no contract):** override\n* `describe()` directly; the override wins and the JSON fields are unused.\n*\n* The `Start` / `End` generics carry each migration's precise contract types so\n* the family-base view getters resolve to fully-typed views.\n*/\nvar Migration = class {\n\t/**\n\t* The migration's end-state contract JSON (the `contract.json` import from\n\t* the snapshot store). When set, the derived `describe()` reads `to` from its\n\t* `storage.storageHash`. Family bases build the typed `endContract` view from\n\t* it. Optional so `describe()`-overriding migrations (no contract) compile.\n\t*\n\t* Typed with a plain `storageHash: string`, not the branded\n\t* `StorageHashBase`, so a raw `contract.json` import — whose `storageHash`\n\t* is an untyped string literal — is assignable without a cast. The full\n\t* `Start`/`End` contract typing is applied downstream in the family bases'\n\t* view getters (via `<Family>ContractView.fromJson<…>`).\n\t*/\n\tendContractJson;\n\t/**\n\t* The migration's start-state contract JSON (the `contract.json` import\n\t* from the snapshot store). Absent for a baseline migration (`from`\n\t* derives to `null`). Family bases build the typed `startContract` view from\n\t* it.\n\t*/\n\tstartContractJson;\n\t/**\n\t* Assembled `ControlStack` injected by the orchestrator (`runMigration`).\n\t*\n\t* Subclasses (e.g. `PostgresMigration`) read the stack to materialize their\n\t* adapter once per instance. Optional at the abstract level so unit tests can\n\t* construct `Migration` instances purely for `operations` / `describe`\n\t* assertions without needing a real stack; concrete subclasses that need the\n\t* stack at runtime should narrow the parameter to required.\n\t*/\n\tstack;\n\tconstructor(stack) {\n\t\tthis.stack = stack;\n\t}\n\t/**\n\t* Metadata inputs used to build `migration.json` and to derive the plan's\n\t* origin/destination identities.\n\t*\n\t* Default derivation: `to = endContractJson.storage.storageHash`,\n\t* `from = startContractJson?.storage.storageHash ?? null`. A migration that\n\t* carries no contract JSON (e.g. an extension migration) must override this;\n\t* otherwise it throws, since `migration.json` requires a `to` identity.\n\t*/\n\tdescribe() {\n\t\tconst end = this.endContractJson;\n\t\tif (end === void 0) throw errorDescribeMissingEndContract();\n\t\treturn {\n\t\t\tfrom: this.startContractJson?.storage.storageHash ?? null,\n\t\t\tto: end.storage.storageHash\n\t\t};\n\t}\n\tget origin() {\n\t\tconst from = this.describe().from;\n\t\treturn from === null ? null : { storageHash: from };\n\t}\n\tget destination() {\n\t\treturn { storageHash: this.describe().to };\n\t}\n};\n/**\n* Lazy-memoized `endContract` / `startContract` view accessors, one instance\n* held per migration. Each target base (`MongoMigration`, `SqliteMigration`,\n* `PostgresMigration`) creates one `MigrationContractViews` field from\n* `this` — passing its own `<Family>ContractView.fromJson<…>` as `fromJson`\n* and a name for error messages — and forwards its\n* `endContract`/`startContract` getters to it.\n*\n* `endContract` throws `MIGRATION.CONTRACT_VIEW_MISSING` when the migration\n* has no `endContractJson` (mirrors `describe()`'s own requirement).\n* `startContract` returns `null` for a baseline migration (no\n* `startContractJson`) instead of throwing.\n*/\nvar MigrationContractViews = class {\n\tmigration;\n\tclassName;\n\tfromJson;\n\t#endView;\n\t#startView;\n\tconstructor(migration, className, fromJson) {\n\t\tthis.migration = migration;\n\t\tthis.className = className;\n\t\tthis.fromJson = fromJson;\n\t}\n\tget endContract() {\n\t\tif (this.#endView === void 0) {\n\t\t\tconst json = this.migration.endContractJson;\n\t\t\tif (json === void 0) throw errorMigrationContractViewMissing(this.className, \"endContract\", \"endContractJson\");\n\t\t\tthis.#endView = this.fromJson(json);\n\t\t}\n\t\treturn this.#endView;\n\t}\n\tget startContract() {\n\t\tif (this.#startView === void 0) {\n\t\t\tconst json = this.migration.startContractJson;\n\t\t\tthis.#startView = json === void 0 ? null : this.fromJson(json);\n\t\t}\n\t\treturn this.#startView;\n\t}\n};\n/**\n* Returns true when `import.meta.url` resolves to the same file that was\n* invoked as the node entrypoint (`process.argv[1]`). Used by\n* `MigrationCLI.run` (in `@internal/cli/migration-cli`) to no-op when\n* the migration module is being imported (e.g. by another script) rather\n* than executed directly.\n*/\nfunction isDirectEntrypoint(importMetaUrl) {\n\tconst metaFilename = fileURLToPath(importMetaUrl);\n\tconst argv1 = process.argv[1];\n\tif (!argv1) return false;\n\ttry {\n\t\treturn realpathSync(metaFilename) === realpathSync(argv1);\n\t} catch {\n\t\treturn false;\n\t}\n}\n/**\n* Build the attested metadata from `describe()`-derived metadata, the\n* operations list, and the previously-scaffolded metadata (if any).\n*\n* When a `migration.json` already exists for this package (the common\n* case: it was scaffolded by `migration plan`), preserve `createdAt`\n* set there — that field is owned by the CLI scaffolder, not the authored\n* class. Only the `describe()`-derived fields (`from`, `to`) and the\n* operations change as the author iterates. When no metadata exists yet\n* (a bare `migration.ts` run from scratch), synthesize a minimal but\n* schema-conformant record so the resulting package can still be read,\n* verified, and applied.\n*\n* The `migrationHash` is recomputed against the current metadata + ops so\n* the on-disk artifacts are always fully attested.\n*/\nfunction buildAttestedMetadata(meta, ops, existing) {\n\tconst baseMetadata = {\n\t\tfrom: meta.from,\n\t\tto: meta.to,\n\t\tprovidedInvariants: deriveProvidedInvariants(ops),\n\t\tcreatedAt: existing?.createdAt ?? (/* @__PURE__ */ new Date()).toISOString()\n\t};\n\tconst migrationHash = computeMigrationHash(baseMetadata, ops);\n\treturn {\n\t\t...baseMetadata,\n\t\tmigrationHash\n\t};\n}\n/**\n* Pure conversion from a `Migration` instance (plus the previously\n* scaffolded metadata, when one exists on disk) to the in-memory\n* artifacts that downstream tooling persists. Owns metadata validation,\n* metadata synthesis/preservation, and the content-addressed\n* `migrationHash` computation, but performs no file I/O — callers handle\n* reads (to source `existing`) and writes (to persist `opsJson` /\n* `metadataJson`).\n*/\nasync function buildMigrationArtifacts(instance, existing) {\n\tconst rawOps = instance.operations;\n\tif (!Array.isArray(rawOps)) throw errorOperationsNotArray();\n\tconst ops = await Promise.all(rawOps);\n\tfor (let index = 0; index < ops.length; index++) {\n\t\tconst result = MigrationOpSchema(ops[index]);\n\t\tif (result instanceof type.errors) throw errorInvalidOperationEntry(index, result.summary);\n\t}\n\tconst rawMeta = instance.describe();\n\tconst parsed = MigrationMetaSchema(rawMeta);\n\tif (parsed instanceof type.errors) throw errorDescribeInvalidMetadata(parsed.summary);\n\tconst metadata = buildAttestedMetadata(parsed, ops, existing);\n\treturn {\n\t\topsJson: JSON.stringify(ops, null, 2),\n\t\tmetadata,\n\t\tmetadataJson: JSON.stringify(metadata, null, 2)\n\t};\n}\n//#endregion\nexport { Migration, MigrationContractViews, buildMigrationArtifacts, isDirectEntrypoint };\n\n//# sourceMappingURL=migration.mjs.map"],"mappings":";;;;;;;;AAQA,MAAM,sBAAsB,KAAK;CAChC,MAAM;CACN,IAAI;AACL,CAAC;;;;;;;;;;;;;;;;;;;;;;AAsBD,IAAI,YAAY,MAAM;;;;;;;;;;;;;CAarB;;;;;;;CAOA;;;;;;;;;;CAUA;CACA,YAAY,OAAO;EAClB,KAAK,QAAQ;CACd;;;;;;;;;;CAUA,WAAW;EACV,MAAM,MAAM,KAAK;EACjB,IAAI,QAAQ,KAAK,GAAG,MAAM,gCAAgC;EAC1D,OAAO;GACN,MAAM,KAAK,mBAAmB,QAAQ,eAAe;GACrD,IAAI,IAAI,QAAQ;EACjB;CACD;CACA,IAAI,SAAS;EACZ,MAAM,OAAO,KAAK,SAAS,CAAC,CAAC;EAC7B,OAAO,SAAS,OAAO,OAAO,EAAE,aAAa,KAAK;CACnD;CACA,IAAI,cAAc;EACjB,OAAO,EAAE,aAAa,KAAK,SAAS,CAAC,CAAC,GAAG;CAC1C;AACD;;;;;;;;;;;;;;AAcA,IAAI,yBAAyB,MAAM;CAClC;CACA;CACA;CACA;CACA;CACA,YAAY,WAAW,WAAW,UAAU;EAC3C,KAAK,YAAY;EACjB,KAAK,YAAY;EACjB,KAAK,WAAW;CACjB;CACA,IAAI,cAAc;EACjB,IAAI,KAAKA,aAAa,KAAK,GAAG;GAC7B,MAAM,OAAO,KAAK,UAAU;GAC5B,IAAI,SAAS,KAAK,GAAG,MAAM,kCAAkC,KAAK,WAAW,eAAe,iBAAiB;GAC7G,KAAKA,WAAW,KAAK,SAAS,IAAI;EACnC;EACA,OAAO,KAAKA;CACb;CACA,IAAI,gBAAgB;EACnB,IAAI,KAAKC,eAAe,KAAK,GAAG;GAC/B,MAAM,OAAO,KAAK,UAAU;GAC5B,KAAKA,aAAa,SAAS,KAAK,IAAI,OA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sources":["../../../../1-framework/3-tooling/migration/dist/exports/migration.mjs"],"sourcesContent":["import { A as errorOperationsNotArray, c as errorDescribeMissingEndContract, s as errorDescribeInvalidMetadata, v as errorInvalidOperationEntry, w as errorMigrationContractViewMissing } from \"../errors-BwusfLIN.mjs\";\nimport { t as computeMigrationHash } from \"../hash-DH8hl5Rq.mjs\";\nimport { t as deriveProvidedInvariants } from \"../invariants-CMcQxRas.mjs\";\nimport { t as MigrationOpSchema } from \"../op-schema-BSVHzEQN.mjs\";\nimport { type } from \"arktype\";\nimport { realpathSync } from \"node:fs\";\nimport { fileURLToPath } from \"node:url\";\n//#region src/migration-base.ts\nconst MigrationMetaSchema = type({\n\tfrom: \"string > 0 | null\",\n\tto: \"string\"\n});\n/**\n* Base class for migrations.\n*\n* A `Migration` subclass is itself a `MigrationPlan`: CLI commands and the\n* runner can consume it directly via `targetId`, `operations`, `origin`, and\n* `destination`.\n*\n* The from/to identities come from `describe()`. A migration provides them in\n* one of two ways:\n* - **Contract-derived (default):** assign the `contract.json` imports from\n* the snapshot store (`migrations/snapshots/<hex>/contract.json`) to\n* `startContractJson` / `endContractJson`; the concrete `describe()` below\n* derives `to`/`from` from their\n* `storage.storageHash`. The family bases additionally expose typed view\n* getters (`startContract` / `endContract`) over the same JSON.\n* - **Override (e.g. extension migrations that carry no contract):** override\n* `describe()` directly; the override wins and the JSON fields are unused.\n*\n* The `Start` / `End` generics carry each migration's precise contract types so\n* the family-base view getters resolve to fully-typed views.\n*/\nvar Migration = class {\n\t/**\n\t* The migration's end-state contract JSON (the `contract.json` import from\n\t* the snapshot store). When set, the derived `describe()` reads `to` from its\n\t* `storage.storageHash`. Family bases build the typed `endContract` view from\n\t* it. Optional so `describe()`-overriding migrations (no contract) compile.\n\t*\n\t* Typed with a plain `storageHash: string`, not the branded\n\t* `StorageHashBase`, so a raw `contract.json` import — whose `storageHash`\n\t* is an untyped string literal — is assignable without a cast. The full\n\t* `Start`/`End` contract typing is applied downstream in the family bases'\n\t* view getters (via `<Family>ContractView.fromJson<…>`).\n\t*/\n\tendContractJson;\n\t/**\n\t* The migration's start-state contract JSON (the `contract.json` import\n\t* from the snapshot store). Absent for a baseline migration (`from`\n\t* derives to `null`). Family bases build the typed `startContract` view from\n\t* it.\n\t*/\n\tstartContractJson;\n\t/**\n\t* Assembled `ControlStack` injected by the orchestrator (`runMigration`).\n\t*\n\t* Subclasses (e.g. `PostgresMigration`) read the stack to materialize their\n\t* adapter once per instance. Optional at the abstract level so unit tests can\n\t* construct `Migration` instances purely for `operations` / `describe`\n\t* assertions without needing a real stack; concrete subclasses that need the\n\t* stack at runtime should narrow the parameter to required.\n\t*/\n\tstack;\n\tconstructor(stack) {\n\t\tthis.stack = stack;\n\t}\n\t/**\n\t* Metadata inputs used to build `migration.json` and to derive the plan's\n\t* origin/destination identities.\n\t*\n\t* Default derivation: `to = endContractJson.storage.storageHash`,\n\t* `from = startContractJson?.storage.storageHash ?? null`. A migration that\n\t* carries no contract JSON (e.g. an extension migration) must override this;\n\t* otherwise it throws, since `migration.json` requires a `to` identity.\n\t*/\n\tdescribe() {\n\t\tconst end = this.endContractJson;\n\t\tif (end === void 0) throw errorDescribeMissingEndContract();\n\t\treturn {\n\t\t\tfrom: this.startContractJson?.storage.storageHash ?? null,\n\t\t\tto: end.storage.storageHash\n\t\t};\n\t}\n\tget origin() {\n\t\tconst from = this.describe().from;\n\t\treturn from === null ? null : { storageHash: from };\n\t}\n\tget destination() {\n\t\treturn { storageHash: this.describe().to };\n\t}\n};\n/**\n* Lazy-memoized `endContract` / `startContract` view accessors, one instance\n* held per migration. Each target base (`MongoMigration`, `SqliteMigration`,\n* `PostgresMigration`) creates one `MigrationContractViews` field from\n* `this` — passing its own `<Family>ContractView.fromJson<…>` as `fromJson`\n* and a name for error messages — and forwards its\n* `endContract`/`startContract` getters to it.\n*\n* `endContract` throws `MIGRATION.CONTRACT_VIEW_MISSING` when the migration\n* has no `endContractJson` (mirrors `describe()`'s own requirement).\n* `startContract` returns `null` for a baseline migration (no\n* `startContractJson`) instead of throwing.\n*/\nvar MigrationContractViews = class {\n\tmigration;\n\tclassName;\n\tfromJson;\n\t#endView;\n\t#startView;\n\tconstructor(migration, className, fromJson) {\n\t\tthis.migration = migration;\n\t\tthis.className = className;\n\t\tthis.fromJson = fromJson;\n\t}\n\tget endContract() {\n\t\tif (this.#endView === void 0) {\n\t\t\tconst json = this.migration.endContractJson;\n\t\t\tif (json === void 0) throw errorMigrationContractViewMissing(this.className, \"endContract\", \"endContractJson\");\n\t\t\tthis.#endView = this.fromJson(json);\n\t\t}\n\t\treturn this.#endView;\n\t}\n\tget startContract() {\n\t\tif (this.#startView === void 0) {\n\t\t\tconst json = this.migration.startContractJson;\n\t\t\tthis.#startView = json === void 0 ? null : this.fromJson(json);\n\t\t}\n\t\treturn this.#startView;\n\t}\n};\n/**\n* Returns true when `import.meta.url` resolves to the same file that was\n* invoked as the node entrypoint (`process.argv[1]`). Used by\n* `MigrationCLI.run` (in `@internal/cli/migration-cli`) to no-op when\n* the migration module is being imported (e.g. by another script) rather\n* than executed directly.\n*/\nfunction isDirectEntrypoint(importMetaUrl) {\n\tconst metaFilename = fileURLToPath(importMetaUrl);\n\tconst argv1 = process.argv[1];\n\tif (!argv1) return false;\n\ttry {\n\t\treturn realpathSync(metaFilename) === realpathSync(argv1);\n\t} catch {\n\t\treturn false;\n\t}\n}\n/**\n* Build the attested metadata from `describe()`-derived metadata, the\n* operations list, and the previously-scaffolded metadata (if any).\n*\n* When a `migration.json` already exists for this package (the common\n* case: it was scaffolded by `migration plan`), preserve `createdAt`\n* set there — that field is owned by the CLI scaffolder, not the authored\n* class. Only the `describe()`-derived fields (`from`, `to`) and the\n* operations change as the author iterates. When no metadata exists yet\n* (a bare `migration.ts` run from scratch), synthesize a minimal but\n* schema-conformant record so the resulting package can still be read,\n* verified, and applied.\n*\n* The `migrationHash` is recomputed against the current metadata + ops so\n* the on-disk artifacts are always fully attested.\n*/\nfunction buildAttestedMetadata(meta, ops, existing) {\n\tconst baseMetadata = {\n\t\tfrom: meta.from,\n\t\tto: meta.to,\n\t\tprovidedInvariants: deriveProvidedInvariants(ops),\n\t\tcreatedAt: existing?.createdAt ?? (/* @__PURE__ */ new Date()).toISOString()\n\t};\n\tconst migrationHash = computeMigrationHash(baseMetadata, ops);\n\treturn {\n\t\t...baseMetadata,\n\t\tmigrationHash\n\t};\n}\n/**\n* Pure conversion from a `Migration` instance (plus the previously\n* scaffolded metadata, when one exists on disk) to the in-memory\n* artifacts that downstream tooling persists. Owns metadata validation,\n* metadata synthesis/preservation, and the content-addressed\n* `migrationHash` computation, but performs no file I/O — callers handle\n* reads (to source `existing`) and writes (to persist `opsJson` /\n* `metadataJson`).\n*/\nasync function buildMigrationArtifacts(instance, existing) {\n\tconst rawOps = instance.operations;\n\tif (!Array.isArray(rawOps)) throw errorOperationsNotArray();\n\tconst ops = await Promise.all(rawOps);\n\tfor (let index = 0; index < ops.length; index++) {\n\t\tconst result = MigrationOpSchema(ops[index]);\n\t\tif (result instanceof type.errors) throw errorInvalidOperationEntry(index, result.summary);\n\t}\n\tconst rawMeta = instance.describe();\n\tconst parsed = MigrationMetaSchema(rawMeta);\n\tif (parsed instanceof type.errors) throw errorDescribeInvalidMetadata(parsed.summary);\n\tconst metadata = buildAttestedMetadata(parsed, ops, existing);\n\treturn {\n\t\topsJson: JSON.stringify(ops, null, 2),\n\t\tmetadata,\n\t\tmetadataJson: JSON.stringify(metadata, null, 2)\n\t};\n}\n//#endregion\nexport { Migration, MigrationContractViews, buildMigrationArtifacts, isDirectEntrypoint };\n\n//# sourceMappingURL=migration.mjs.map"],"mappings":";;;;;;;;AAQA,MAAM,sBAAsB,KAAK;CAChC,MAAM;CACN,IAAI;AACL,CAAC;;;;;;;;;;;;;;;;;;;;;;AAsBD,IAAI,YAAY,MAAM;;;;;;;;;;;;;CAarB;;;;;;;CAOA;;;;;;;;;;CAUA;CACA,YAAY,OAAO;EAClB,KAAK,QAAQ;CACd;;;;;;;;;;CAUA,W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KAAK;EACX,IAAI,KAAK;EACT,oBAAoB,yBAAyB,GAAG;EAChD,WAAW,UAAU,8BAA8B,IAAI,KAAK,EAAA,CAAG,YAAY;CAC5E;CACA,MAAM,gBAAgB,qBAAqB,cAAc,GAAG;CAC5D,OAAO;EACN,GAAG;EACH;CACD;AACD;;;;;;;;;;AAUA,eAAe,wBAAwB,UAAU,UAAU;CAC1D,MAAM,SAAS,SAAS;CACxB,IAAI,CAAC,MAAM,QAAQ,MAAM,GAAG,MAAM,wBAAwB;CAC1D,MAAM,MAAM,MAAM,QAAQ,IAAI,MAAM;CACpC,KAAK,IAAI,QAAQ,GAAG,QAAQ,IAAI,QAAQ,SAAS;EAChD,MAAM,SAAS,kBAAkB,IAAI,MAAM;EAC3C,IAAI,kBAAkB,KAAK,QAAQ,MAAM,2BAA2B,OAAO,OAAO,OAAO;CAC1F;CACA,MAAM,UAAU,SAAS,SAAS;CAClC,MAAM,SAAS,oBAAoB,OAAO;CAC1C,IAAI,kBAAkB,KAAK,QAAQ,MAAM,6BAA6B,OAAO,OAAO;CACpF,MAAM,WAAW,sBAAsB,QAAQ,KAAK,QAAQ;CAC5D,OAAO;EACN,SAAS,KAAK,UAAU,KAAK,MAAM,CAAC;EACpC;EACA,cAAc,KAAK,UAAU,UAAU,MAAM,CAAC;CAC/C;AACD"}
@@ -1,9 +1,9 @@
1
1
  import "./constants-CM-w38DQ-Cz_EXbOc.mjs";
2
- import { W as formatStyledHeader, at as resolveMigrationPaths, ct as setCommandExamples, lt as setCommandSeeAlso, o as createTerminalUI, q as handleResult, r as addGlobalOptions, st as setCommandDescriptions, tt as parseGlobalFlagsOrExit } from "./command-helpers-CAoXqAY9-DWUBcTXM.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";
3
3
  import { r as loadConfig } from "./exports-CDX9kZuw.mjs";
4
- import { n as buildReadAggregate } from "./contract-space-aggregate-loader-CFH-336b-BhAyRQEL.mjs";
4
+ import { n as buildReadAggregate } from "./contract-space-aggregate-loader-CziO_ZRW-DIoQOL0P.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-BFBeo1_X-ckYMhETH.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";
7
7
  import { ifDefined } from "@prisma/orm-framework/utils/defined";
8
8
  import { ok } from "@prisma/orm-framework/utils/result";
9
9
  import { Command } from "commander";
@@ -182,4 +182,4 @@ function createMigrationGraphCommand() {
182
182
  //#endregion
183
183
  export { executeMigrationGraphCommand as n, formatMigrationGraphHumanOutput as r, createMigrationGraphCommand as t };
184
184
 
185
- //# sourceMappingURL=migration-graph-vmgkL3k4.mjs.map
185
+ //# sourceMappingURL=migration-graph-BL6vfLcE.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"migration-graph-vmgkL3k4.mjs","names":[],"sources":["../../../../1-framework/3-tooling/cli/dist/commands/migration-graph.mjs"],"sourcesContent":["import { A as formatStyledHeader, _ as createTerminalUI, d as setCommandSeeAlso, g as parseGlobalFlagsOrExit, l as setCommandDescriptions, s as resolveMigrationPaths, t as addGlobalOptions, u as setCommandExamples, y as handleResult } from \"../command-helpers-CAoXqAY9.mjs\";\nimport { n as buildReadAggregate } from \"../contract-space-aggregate-loader-CFH-336b.mjs\";\nimport { a as renderMigrationGraphLegend, f as indentMigrationGraphTreeBlock, l as computeGlobalMaxDirNameWidth, p as renderMigrationGraphSpaceTree, u as computeGlobalMaxEdgeTreePrefixWidth } from \"../migration-graph-command-render-BKrg6BPv.mjs\";\nimport { c as validateLegendOptions, i as migrationSpaceListEntriesFromAggregate, o as runMigrationList, r as listRefsByContractHash, s as shouldShowLegend } from \"../migration-list-BFBeo1_X.mjs\";\nimport { Command } from \"commander\";\nimport { loadConfig } from \"@internal/config-loader\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { ok } from \"@internal/utils/result\";\nimport { EMPTY_CONTRACT_HASH } from \"@internal/migration-tools/constants\";\n//#region src/commands/migration-graph.ts\nfunction computeGraphSummary(spaces) {\n\tconst contractCount = spaces.reduce((count, space) => count + space.contracts.length, 0);\n\tconst migrationCount = spaces.reduce((count, space) => count + space.migrations.length, 0);\n\treturn `${spaces.length} space(s), ${contractCount} contract(s), ${migrationCount} migration(s)`;\n}\nfunction formatMigrationGraphHumanOutput(result) {\n\tconst sections = [];\n\tfor (const section of result.treeSections) {\n\t\tif (section.showHeading) sections.push(`${section.space}:`);\n\t\tif (section.tree.length > 0) sections.push(section.tree);\n\t\telse sections.push(\"(no migrations)\");\n\t\tsections.push(\"\");\n\t}\n\tsections.push(result.summary);\n\treturn sections.join(\"\\n\").trimEnd();\n}\nasync function executeMigrationGraphCommand(options, flags, ui) {\n\tconst config = await loadConfig(options.config);\n\tconst { configPath, migrationsRelative, migrationsDir } = resolveMigrationPaths(options.config, config);\n\tif (!flags.json && !flags.quiet) {\n\t\tconst header = formatStyledHeader({\n\t\t\tcommand: \"migration graph\",\n\t\t\tdescription: \"Show the migration graph topology\",\n\t\t\tdetails: [\n\t\t\t\t{\n\t\t\t\t\tlabel: \"config\",\n\t\t\t\t\tvalue: configPath\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tlabel: \"migrations\",\n\t\t\t\t\tvalue: migrationsRelative\n\t\t\t\t},\n\t\t\t\t...options.space !== void 0 ? [{\n\t\t\t\t\tlabel: \"space\",\n\t\t\t\t\tvalue: options.space\n\t\t\t\t}] : []\n\t\t\t],\n\t\t\tflags\n\t\t});\n\t\tui.stderr(header);\n\t\tif (shouldShowLegend(options, flags)) {\n\t\t\tui.stderr(renderMigrationGraphLegend({\n\t\t\t\tcolorize: flags.color !== false,\n\t\t\t\tglyphMode: ui.resolveGlyphMode(options.ascii === true)\n\t\t\t}));\n\t\t\tui.stderr(\"\");\n\t\t}\n\t}\n\tconst loaded = await buildReadAggregate(config, { migrationsDir });\n\tif (!loaded.ok) return loaded;\n\tconst { aggregate, contractHash: liveContractHash } = loaded.value;\n\tconst appGraph = aggregate.app.graph();\n\tconst listResult = runMigrationList({\n\t\tspaces: await migrationSpaceListEntriesFromAggregate(aggregate, migrationsDir),\n\t\t...ifDefined(\"spaceFilter\", options.space)\n\t});\n\tif (!listResult.ok) return listResult;\n\tconst scopedSpaces = listResult.value.spaces;\n\tconst showSpaceHeadings = scopedSpaces.length > 1;\n\tconst glyphMode = ui.resolveGlyphMode(options.ascii === true);\n\tconst colorize = flags.color !== false;\n\tconst globalLayoutInputs = showSpaceHeadings ? scopedSpaces.filter((spaceEntry) => spaceEntry.migrations.length > 0).map((spaceEntry) => ({\n\t\tgraph: aggregate.space(spaceEntry.space).graph(),\n\t\tliveContractHash\n\t})) : [];\n\tconst globalMaxEdgeTreePrefixWidth = globalLayoutInputs.length > 0 ? computeGlobalMaxEdgeTreePrefixWidth(globalLayoutInputs) : void 0;\n\tconst globalMaxDirNameWidth = globalLayoutInputs.length > 0 ? computeGlobalMaxDirNameWidth(globalLayoutInputs) : void 0;\n\tconst treeSections = [];\n\tconst spaces = [];\n\tfor (const spaceEntry of scopedSpaces) {\n\t\tconst space = aggregate.space(spaceEntry.space);\n\t\tif (space === void 0) continue;\n\t\tconst graph = space.graph();\n\t\tconst isAppSpace = spaceEntry.space === aggregate.app.spaceId;\n\t\tconst refsByHash = listRefsByContractHash(space);\n\t\tconst tree = spaceEntry.migrations.length === 0 ? \"\" : renderMigrationGraphSpaceTree({\n\t\t\tgraph,\n\t\t\tmigrations: spaceEntry.migrations,\n\t\t\tliveContractHash,\n\t\t\tglyphMode,\n\t\t\tcolorize,\n\t\t\tisAppSpace,\n\t\t\trefsByHash,\n\t\t\t...globalMaxEdgeTreePrefixWidth !== void 0 ? { globalMaxEdgeTreePrefixWidth } : {},\n\t\t\t...globalMaxDirNameWidth !== void 0 ? { globalMaxDirNameWidth } : {}\n\t\t});\n\t\tconst displayTree = showSpaceHeadings && tree.length > 0 ? indentMigrationGraphTreeBlock(tree, \" \") : tree;\n\t\ttreeSections.push({\n\t\t\tspace: spaceEntry.space,\n\t\t\ttree: displayTree,\n\t\t\tshowHeading: showSpaceHeadings\n\t\t});\n\t\tspaces.push({\n\t\t\tspace: spaceEntry.space,\n\t\t\tcontracts: [...graph.nodes].map((hash) => ({\n\t\t\t\thash,\n\t\t\t\trefs: [...refsByHash.get(hash) ?? []]\n\t\t\t})),\n\t\t\tmigrations: [...graph.migrationByHash.values()].map((edge) => ({\n\t\t\t\tname: edge.dirName,\n\t\t\t\thash: edge.migrationHash,\n\t\t\t\tfromContract: edge.from === EMPTY_CONTRACT_HASH ? null : edge.from,\n\t\t\t\ttoContract: edge.to\n\t\t\t}))\n\t\t});\n\t}\n\treturn ok({\n\t\tok: true,\n\t\tgraph: appGraph,\n\t\tspaces,\n\t\ttreeSections,\n\t\tsummary: computeGraphSummary(spaces)\n\t});\n}\nfunction createMigrationGraphCommand() {\n\tconst command = new Command(\"graph\");\n\tsetCommandDescriptions(command, \"Show the migration graph topology\", \"Renders the migration graph topology.\\nOffline — does not consult the database.\\n--ascii swaps box-drawing for pipe-friendly ASCII glyphs.\\nUse --json for machine-readable output, or --dot for Graphviz DOT\\nformat.\");\n\tsetCommandExamples(command, [\n\t\t\"prisma-next migration graph\",\n\t\t\"prisma-next migration graph --json\",\n\t\t\"prisma-next migration graph --dot\",\n\t\t\"prisma-next migration graph --ascii\",\n\t\t\"prisma-next migration graph --legend\",\n\t\t\"prisma-next migration graph --space app\"\n\t]);\n\tsetCommandSeeAlso(command, [\n\t\t{\n\t\t\tverb: \"migration status\",\n\t\t\toneLiner: \"Show migration path and pending status\"\n\t\t},\n\t\t{\n\t\t\tverb: \"migration log\",\n\t\t\toneLiner: \"Show executed migration history\"\n\t\t},\n\t\t{\n\t\t\tverb: \"migration list\",\n\t\t\toneLiner: \"List on-disk migrations\"\n\t\t},\n\t\t{\n\t\t\tverb: \"migration show\",\n\t\t\toneLiner: \"Display migration package contents\"\n\t\t}\n\t]);\n\taddGlobalOptions(command).option(\"--config <path>\", \"Path to prisma-next.config.ts\").option(\"--space <id>\", \"Narrow output to a single contract space\").option(\"--dot\", \"Output in Graphviz DOT format\").option(\"--ascii\", \"Use ASCII glyphs (pipe-friendly)\").option(\"--legend\", \"Print a key for the tree glyphs and lane colors\").action(async (options) => {\n\t\tconst flags = parseGlobalFlagsOrExit(options);\n\t\tconst ui = createTerminalUI(flags);\n\t\tconst legendValidation = validateLegendOptions(options, flags);\n\t\tif (!legendValidation.ok) process.exit(handleResult(legendValidation, flags, ui));\n\t\tconst exitCode = handleResult(await executeMigrationGraphCommand(options, flags, ui), flags, ui, (graphResult) => {\n\t\t\tif (options.dot) {\n\t\t\t\tconst lines = [\"digraph migrations {\"];\n\t\t\t\tfor (const edge of graphResult.graph.migrationByHash.values()) {\n\t\t\t\t\tconst from = edge.from.slice(0, 12);\n\t\t\t\t\tconst to = edge.to.slice(0, 12);\n\t\t\t\t\tlines.push(` \"${from}\" -> \"${to}\" [label=\"${edge.dirName}\"];`);\n\t\t\t\t}\n\t\t\t\tlines.push(\"}\");\n\t\t\t\tui.output(lines.join(\"\\n\"));\n\t\t\t} else if (flags.json) {\n\t\t\t\tconst jsonResult = {\n\t\t\t\t\tok: true,\n\t\t\t\t\tspaces: [...graphResult.spaces],\n\t\t\t\t\tsummary: graphResult.summary\n\t\t\t\t};\n\t\t\t\tui.output(JSON.stringify(jsonResult, null, 2));\n\t\t\t} else if (!flags.quiet) ui.output(formatMigrationGraphHumanOutput(graphResult));\n\t\t});\n\t\tprocess.exit(exitCode);\n\t});\n\treturn command;\n}\n//#endregion\nexport { createMigrationGraphCommand, executeMigrationGraphCommand, formatMigrationGraphHumanOutput };\n\n//# sourceMappingURL=migration-graph.mjs.map"],"mappings":";;;;;;;;;;AAUA,SAAS,oBAAoB,QAAQ;CACpC,MAAM,gBAAgB,OAAO,QAAQ,OAAO,UAAU,QAAQ,MAAM,UAAU,QAAQ,CAAC;CACvF,MAAM,iBAAiB,OAAO,QAAQ,OAAO,UAAU,QAAQ,MAAM,WAAW,QAAQ,CAAC;CACzF,OAAO,GAAG,OAAO,OAAO,aAAa,cAAc,gBAAgB,eAAe;AACnF;AACA,SAAS,gCAAgC,QAAQ;CAChD,MAAM,WAAW,CAAC;CAClB,KAAK,MAAM,WAAW,OAAO,cAAc;EAC1C,IAAI,QAAQ,aAAa,SAAS,KAAK,GAAG,QAAQ,MAAM,EAAE;EAC1D,IAAI,QAAQ,KAAK,SAAS,GAAG,SAAS,KAAK,QAAQ,IAAI;OAClD,SAAS,KAAK,iBAAiB;EACpC,SAAS,KAAK,EAAE;CACjB;CACA,SAAS,KAAK,OAAO,OAAO;CAC5B,OAAO,SAAS,KAAK,IAAI,CAAC,CAAC,QAAQ;AACpC;AACA,eAAe,6BAA6B,SAAS,OAAO,IAAI;CAC/D,MAAM,SAAS,MAAM,WAAW,QAAQ,MAAM;CAC9C,MAAM,EAAE,YAAY,oBAAoB,kBAAkB,sBAAsB,QAAQ,QAAQ,MAAM;CACtG,IAAI,CAAC,MAAM,QAAQ,CAAC,MAAM,OAAO;EAChC,MAAM,SAAS,mBAAmB;GACjC,SAAS;GACT,aAAa;GACb,SAAS;IACR;KACC,OAAO;KACP,OAAO;IACR;IACA;KACC,OAAO;KACP,OAAO;IACR;IACA,GAAG,QAAQ,UAAU,KAAK,IAAI,CAAC;KAC9B,OAAO;KACP,OAAO,QAAQ;IAChB,CAAC,IAAI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ourcesContent":["import { A as formatStyledHeader, _ as createTerminalUI, d as setCommandSeeAlso, g as parseGlobalFlagsOrExit, l as setCommandDescriptions, s as resolveMigrationPaths, t as addGlobalOptions, u as setCommandExamples, y as handleResult } from \"../command-helpers-C4WpR-QE.mjs\";\nimport { n as buildReadAggregate } from \"../contract-space-aggregate-loader-CziO_ZRW.mjs\";\nimport { a as renderMigrationGraphLegend, f as indentMigrationGraphTreeBlock, l as computeGlobalMaxDirNameWidth, p as renderMigrationGraphSpaceTree, u as computeGlobalMaxEdgeTreePrefixWidth } from \"../migration-graph-command-render-BKrg6BPv.mjs\";\nimport { c as validateLegendOptions, i as migrationSpaceListEntriesFromAggregate, o as runMigrationList, r as listRefsByContractHash, s as shouldShowLegend } from \"../migration-list-D2_JdzWC.mjs\";\nimport { Command } from \"commander\";\nimport { loadConfig } from \"@internal/config-loader\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { ok } from \"@internal/utils/result\";\nimport { EMPTY_CONTRACT_HASH } from \"@internal/migration-tools/constants\";\n//#region src/commands/migration-graph.ts\nfunction computeGraphSummary(spaces) {\n\tconst contractCount = spaces.reduce((count, space) => count + space.contracts.length, 0);\n\tconst migrationCount = spaces.reduce((count, space) => count + space.migrations.length, 0);\n\treturn `${spaces.length} space(s), ${contractCount} contract(s), ${migrationCount} migration(s)`;\n}\nfunction formatMigrationGraphHumanOutput(result) {\n\tconst sections = [];\n\tfor (const section of result.treeSections) {\n\t\tif (section.showHeading) sections.push(`${section.space}:`);\n\t\tif (section.tree.length > 0) sections.push(section.tree);\n\t\telse sections.push(\"(no migrations)\");\n\t\tsections.push(\"\");\n\t}\n\tsections.push(result.summary);\n\treturn sections.join(\"\\n\").trimEnd();\n}\nasync function executeMigrationGraphCommand(options, flags, ui) {\n\tconst config = await loadConfig(options.config);\n\tconst { configPath, migrationsRelative, migrationsDir } = resolveMigrationPaths(options.config, config);\n\tif (!flags.json && !flags.quiet) {\n\t\tconst header = formatStyledHeader({\n\t\t\tcommand: \"migration graph\",\n\t\t\tdescription: \"Show the migration graph topology\",\n\t\t\tdetails: [\n\t\t\t\t{\n\t\t\t\t\tlabel: \"config\",\n\t\t\t\t\tvalue: configPath\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tlabel: \"migrations\",\n\t\t\t\t\tvalue: migrationsRelative\n\t\t\t\t},\n\t\t\t\t...options.space !== void 0 ? [{\n\t\t\t\t\tlabel: \"space\",\n\t\t\t\t\tvalue: options.space\n\t\t\t\t}] : []\n\t\t\t],\n\t\t\tflags\n\t\t});\n\t\tui.stderr(header);\n\t\tif (shouldShowLegend(options, flags)) {\n\t\t\tui.stderr(renderMigrationGraphLegend({\n\t\t\t\tcolorize: flags.color !== false,\n\t\t\t\tglyphMode: ui.resolveGlyphMode(options.ascii === true)\n\t\t\t}));\n\t\t\tui.stderr(\"\");\n\t\t}\n\t}\n\tconst loaded = await buildReadAggregate(config, { migrationsDir });\n\tif (!loaded.ok) return loaded;\n\tconst { aggregate, contractHash: liveContractHash } = loaded.value;\n\tconst appGraph = aggregate.app.graph();\n\tconst listResult = runMigrationList({\n\t\tspaces: await migrationSpaceListEntriesFromAggregate(aggregate, migrationsDir),\n\t\t...ifDefined(\"spaceFilter\", options.space)\n\t});\n\tif (!listResult.ok) return listResult;\n\tconst scopedSpaces = listResult.value.spaces;\n\tconst showSpaceHeadings = scopedSpaces.length > 1;\n\tconst glyphMode = ui.resolveGlyphMode(options.ascii === true);\n\tconst colorize = flags.color !== false;\n\tconst globalLayoutInputs = showSpaceHeadings ? scopedSpaces.filter((spaceEntry) => spaceEntry.migrations.length > 0).map((spaceEntry) => ({\n\t\tgraph: aggregate.space(spaceEntry.space).graph(),\n\t\tliveContractHash\n\t})) : [];\n\tconst globalMaxEdgeTreePrefixWidth = globalLayoutInputs.length > 0 ? computeGlobalMaxEdgeTreePrefixWidth(globalLayoutInputs) : void 0;\n\tconst globalMaxDirNameWidth = globalLayoutInputs.length > 0 ? computeGlobalMaxDirNameWidth(globalLayoutInputs) : void 0;\n\tconst treeSections = [];\n\tconst spaces = [];\n\tfor (const spaceEntry of scopedSpaces) {\n\t\tconst space = aggregate.space(spaceEntry.space);\n\t\tif (space === void 0) continue;\n\t\tconst graph = space.graph();\n\t\tconst isAppSpace = spaceEntry.space === aggregate.app.spaceId;\n\t\tconst refsByHash = listRefsByContractHash(space);\n\t\tconst tree = spaceEntry.migrations.length === 0 ? \"\" : renderMigrationGraphSpaceTree({\n\t\t\tgraph,\n\t\t\tmigrations: spaceEntry.migrations,\n\t\t\tliveContractHash,\n\t\t\tglyphMode,\n\t\t\tcolorize,\n\t\t\tisAppSpace,\n\t\t\trefsByHash,\n\t\t\t...globalMaxEdgeTreePrefixWidth !== void 0 ? { globalMaxEdgeTreePrefixWidth } : {},\n\t\t\t...globalMaxDirNameWidth !== void 0 ? { globalMaxDirNameWidth } : {}\n\t\t});\n\t\tconst displayTree = showSpaceHeadings && tree.length > 0 ? indentMigrationGraphTreeBlock(tree, \" \") : tree;\n\t\ttreeSections.push({\n\t\t\tspace: spaceEntry.space,\n\t\t\ttree: displayTree,\n\t\t\tshowHeading: showSpaceHeadings\n\t\t});\n\t\tspaces.push({\n\t\t\tspace: spaceEntry.space,\n\t\t\tcontracts: [...graph.nodes].map((hash) => ({\n\t\t\t\thash,\n\t\t\t\trefs: [...refsByHash.get(hash) ?? []]\n\t\t\t})),\n\t\t\tmigrations: [...graph.migrationByHash.values()].map((edge) => ({\n\t\t\t\tname: edge.dirName,\n\t\t\t\thash: edge.migrationHash,\n\t\t\t\tfromContract: edge.from === EMPTY_CONTRACT_HASH ? null : edge.from,\n\t\t\t\ttoContract: edge.to\n\t\t\t}))\n\t\t});\n\t}\n\treturn ok({\n\t\tok: true,\n\t\tgraph: appGraph,\n\t\tspaces,\n\t\ttreeSections,\n\t\tsummary: computeGraphSummary(spaces)\n\t});\n}\nfunction createMigrationGraphCommand() {\n\tconst command = new Command(\"graph\");\n\tsetCommandDescriptions(command, \"Show the migration graph topology\", \"Renders the migration graph topology.\\nOffline — does not consult the database.\\n--ascii swaps box-drawing for pipe-friendly ASCII glyphs.\\nUse --json for machine-readable output, or --dot for Graphviz DOT\\nformat.\");\n\tsetCommandExamples(command, [\n\t\t\"prisma-next migration graph\",\n\t\t\"prisma-next migration graph --json\",\n\t\t\"prisma-next migration graph --dot\",\n\t\t\"prisma-next migration graph --ascii\",\n\t\t\"prisma-next migration graph --legend\",\n\t\t\"prisma-next migration graph --space app\"\n\t]);\n\tsetCommandSeeAlso(command, [\n\t\t{\n\t\t\tverb: \"migration status\",\n\t\t\toneLiner: \"Show migration path and pending status\"\n\t\t},\n\t\t{\n\t\t\tverb: \"migration log\",\n\t\t\toneLiner: \"Show executed migration history\"\n\t\t},\n\t\t{\n\t\t\tverb: \"migration list\",\n\t\t\toneLiner: \"List on-disk migrations\"\n\t\t},\n\t\t{\n\t\t\tverb: \"migration show\",\n\t\t\toneLiner: \"Display migration package contents\"\n\t\t}\n\t]);\n\taddGlobalOptions(command).option(\"--config <path>\", \"Path to prisma-next.config.ts\").option(\"--space <id>\", \"Narrow output to a single contract space\").option(\"--dot\", \"Output in Graphviz DOT format\").option(\"--ascii\", \"Use ASCII glyphs (pipe-friendly)\").option(\"--legend\", \"Print a key for the tree glyphs and lane colors\").action(async (options) => {\n\t\tconst flags = parseGlobalFlagsOrExit(options);\n\t\tconst ui = createTerminalUI(flags);\n\t\tconst legendValidation = validateLegendOptions(options, flags);\n\t\tif (!legendValidation.ok) process.exit(handleResult(legendValidation, flags, ui));\n\t\tconst exitCode = handleResult(await executeMigrationGraphCommand(options, flags, ui), flags, ui, (graphResult) => {\n\t\t\tif (options.dot) {\n\t\t\t\tconst lines = [\"digraph migrations {\"];\n\t\t\t\tfor (const edge of graphResult.graph.migrationByHash.values()) {\n\t\t\t\t\tconst from = edge.from.slice(0, 12);\n\t\t\t\t\tconst to = edge.to.slice(0, 12);\n\t\t\t\t\tlines.push(` \"${from}\" -> \"${to}\" [label=\"${edge.dirName}\"];`);\n\t\t\t\t}\n\t\t\t\tlines.push(\"}\");\n\t\t\t\tui.output(lines.join(\"\\n\"));\n\t\t\t} else if (flags.json) {\n\t\t\t\tconst jsonResult = {\n\t\t\t\t\tok: true,\n\t\t\t\t\tspaces: [...graphResult.spaces],\n\t\t\t\t\tsummary: graphResult.summary\n\t\t\t\t};\n\t\t\t\tui.output(JSON.stringify(jsonResult, null, 2));\n\t\t\t} else if (!flags.quiet) ui.output(formatMigrationGraphHumanOutput(graphResult));\n\t\t});\n\t\tprocess.exit(exitCode);\n\t});\n\treturn command;\n}\n//#endregion\nexport { createMigrationGraphCommand, executeMigrationGraphCommand, formatMigrationGraphHumanOutput };\n\n//# sourceMappingURL=migration-graph.mjs.map"],"mappings":";;;;;;;;;;AAUA,SAAS,oBAAoB,QAAQ;CACpC,MAAM,gBAAgB,OAAO,QAAQ,OAAO,UAAU,QAAQ,MAAM,UAAU,QAAQ,CAAC;CACvF,MAAM,iBAAiB,OAAO,QAAQ,OAAO,UAAU,QAAQ,MAAM,WAAW,QAAQ,CAAC;CACzF,OAAO,GAAG,OAAO,OAAO,aAAa,cAAc,gBAAgB,eAAe;AACnF;AACA,SAAS,gCAAgC,QAAQ;CAChD,MAAM,WAAW,CAAC;CAClB,KAAK,MAAM,WAAW,OAAO,cAAc;EAC1C,IAAI,QAAQ,aAAa,SAAS,KAAK,GAAG,QAAQ,MAAM,EAAE;EAC1D,IAAI,QAAQ,KAAK,SAAS,GAAG,SAAS,KAAK,QAAQ,IAAI;OAClD,SAAS,KAAK,iBAAiB;EACpC,SAAS,KAAK,EAAE;CACjB;CACA,SAAS,KAAK,OAAO,OAAO;CAC5B,OAAO,SAAS,KAAK,IAAI,CAAC,CAAC,QAAQ;AACpC;AACA,eAAe,6BAA6B,SAAS,OAAO,IAAI;CAC/D,MAAM,SAAS,MAAM,WAAW,QAAQ,MAAM;CAC9C,MAAM,EAAE,YAAY,oBAAoB,kBAAkB,sBAAsB,QAAQ,QAAQ,MAAM;CACtG,IAAI,CAAC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,CAAC,CAAC;GAC9C,OAAO,IAAI,CAAC,MAAM,OAAO,GAAG,OAAO,gCAAgC,WAAW,CAAC;EAChF,CAAC;EACD,QAAQ,KAAK,QAAQ;CACtB,CAAC;CACD,OAAO;AACR"}
@@ -1,8 +1,8 @@
1
- import { D as errorNoInitialMigration, k as errorNoTarget, n as errorAmbiguousTarget } from "./errors-IpZm1Skp-BH495dRd.mjs";
1
+ import { D as errorNoInitialMigration, k as errorNoTarget, n as errorAmbiguousTarget } from "./errors-BwusfLIN-BXM7K-ww.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-CBf9ORe7.mjs
5
+ //#region ../../../1-framework/3-tooling/migration/dist/migration-graph-D6bN-mX0.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-CBf9ORe7-B4xAF8GN.mjs.map
500
+ //# sourceMappingURL=migration-graph-D6bN-mX0-DwMWY8DA.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"migration-graph-CBf9ORe7-B4xAF8GN.mjs","names":[],"sources":["../../../../1-framework/3-tooling/migration/dist/migration-graph-CBf9ORe7.mjs"],"sourcesContent":["import { D as errorNoInitialMigration, k as errorNoTarget, n as errorAmbiguousTarget } from \"./errors-IpZm1Skp.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-CBf9ORe7.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,QAAQ,YAAY,OAAO,UAAU,OAAO;CACzD,MAAM,0BAA0B,IAAI,IAAI;CACxC,MAAM,4BAA4B,IAAI,IAAI;CAC1C,MAAM,QAAQ,IAAI,MAAM;CACxB,KAAK,MAAM,SAAS,QAAQ;EAC3B,MAAM,IAAI,IAAI,KAAK;EACnB,IAAI,CAAC,QAAQ,IAAI,CAAC,GAAG;GACpB,QAAQ,IAAI,CAAC;GACb,MAAM,KAAK;IACV,OAAO;IACP,KAAK;GACN,CAAC;EACF;CACD;CACA,OAAO,CAAC,MAAM,SAAS;EACtB,MAAM,EAAE,OAAO,SAAS,KAAK,WAAW,MAAM,MAAM;EACpD,MAAM,aAAa,UAAU,IAAI,MAAM;EACvC,MAAM;GACL,OAAO;GACP,QAAQ,YAAY,UAAU;GAC9B,cAAc,YAAY,QAAQ;EACnC;EACA,KAAK,MAAM,EAAE,MAAM,UAAU,WAAW,OAAO,GAAG;GACjD,MAAM,IAAI,IAAI,IAAI;GAClB,IAAI,CAAC,QAAQ,IAAI,CAAC,GAAG;IACpB,QAAQ,IAAI,C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O,CAAC;CACpC,MAAM,4BAA4B,IAAI,IAAI;CAC1C,MAAM,aAAa,CAAC;CACpB,IAAI,MAAM,aAAa,IAAI,OAAO,GAAG,WAAW,KAAK,mBAAmB;MACnE;EACJ,MAAM,6BAA6B,IAAI,IAAI;EAC3C,KAAK,MAAM,SAAS,MAAM,aAAa,OAAO,GAAG,KAAK,MAAM,QAAQ,OAAO,WAAW,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-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,YAAY,UAAU,CAAC,GAAG;EACzB,KAAK,QAAQ,CAAC,GAAG,OAAO;CACzB;CACA,KAAK,M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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,13 +1,13 @@
1
- import { a as isValidSpaceId, o as listContractSpaceDirectories, t as APP_SPACE_ID } from "./verify-contract-spaces-BZDcJsuA-De8v4Z4T.mjs";
2
- import { A as errorSpaceNotFound, W as formatStyledHeader, _ as errorInvalidSpaceId, at as resolveMigrationPaths, ct as setCommandExamples, lt as setCommandSeeAlso, o as createTerminalUI, q as handleResult, r as addGlobalOptions, st as setCommandDescriptions, tt as parseGlobalFlagsOrExit, v as errorLegendHumanOnly } from "./command-helpers-CAoXqAY9-DWUBcTXM.mjs";
1
+ import { a as isValidSpaceId, o as listContractSpaceDirectories, t as APP_SPACE_ID } from "./verify-contract-spaces-Ak73-zQK-y4qVyu-y.mjs";
2
+ import { A as errorSpaceNotFound, W as formatStyledHeader, _ as errorInvalidSpaceId, ct as setCommandSeeAlso, et as parseGlobalFlagsOrExit, it as resolveMigrationPaths, o as createTerminalUI, ot as setCommandDescriptions, q as handleResult, r as addGlobalOptions, st as setCommandExamples, v as errorLegendHumanOnly } from "./command-helpers-C4WpR-QE-CK2gkj6l.mjs";
3
3
  import { r as loadConfig } from "./exports-CDX9kZuw.mjs";
4
- import { o as refsByContractHash, t as HEAD_REF_NAME } from "./refs-BDbB9BRB-D6Za3Q49.mjs";
5
- import { n as buildReadAggregate } from "./contract-space-aggregate-loader-CFH-336b-BhAyRQEL.mjs";
4
+ import { o as refsByContractHash, t as HEAD_REF_NAME } from "./refs-DtoeUivZ-qay0UMSP.mjs";
5
+ import { n as buildReadAggregate } from "./contract-space-aggregate-loader-CziO_ZRW-DIoQOL0P.mjs";
6
6
  import { g as renderMigrationGraphLegend, l as createAnsiMigrationListStyler, v as renderMigrationListWithStyle } from "./migration-graph-command-render-BKrg6BPv-BP8Pfj4J.mjs";
7
7
  import { ifDefined } from "@prisma/orm-framework/utils/defined";
8
8
  import { notOk, ok } from "@prisma/orm-framework/utils/result";
9
9
  import { Command } from "commander";
10
- //#region ../../../1-framework/3-tooling/cli/dist/migration-list-BFBeo1_X.mjs
10
+ //#region ../../../1-framework/3-tooling/cli/dist/migration-list-D2_JdzWC.mjs
11
11
  /**
12
12
  * The legend is decoration printed alongside the command header on stderr, so
13
13
  * it is suppressed for the machine-readable / silent paths (`--json`, `--dot`,
@@ -225,4 +225,4 @@ function createMigrationListCommand() {
225
225
  //#endregion
226
226
  export { renderMigrationListHumanOutput as a, validateLegendOptions as c, migrationSpaceListEntriesFromAggregate as i, executeMigrationListCommand as n, runMigrationList as o, listRefsByContractHash as r, shouldShowLegend as s, createMigrationListCommand as t };
227
227
 
228
- //# sourceMappingURL=migration-list-BFBeo1_X-ckYMhETH.mjs.map
228
+ //# sourceMappingURL=migration-list-D2_JdzWC-MRHYYVQE.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"migration-list-BFBeo1_X-ckYMhETH.mjs","names":[],"sources":["../../../../1-framework/3-tooling/cli/dist/migration-list-BFBeo1_X.mjs"],"sourcesContent":["import { A as formatStyledHeader, K as errorInvalidSpaceId, _ as createTerminalUI, at as errorSpaceNotFound, d as setCommandSeeAlso, g as parseGlobalFlagsOrExit, l as setCommandDescriptions, q as errorLegendHumanOnly, s as resolveMigrationPaths, t as addGlobalOptions, u as setCommandExamples, y as handleResult } from \"./command-helpers-CAoXqAY9.mjs\";\nimport { n as buildReadAggregate } from \"./contract-space-aggregate-loader-CFH-336b.mjs\";\nimport { a as renderMigrationGraphLegend, c as renderMigrationListWithStyle, o as createAnsiMigrationListStyler } from \"./migration-graph-command-render-BKrg6BPv.mjs\";\nimport { Command } from \"commander\";\nimport { loadConfig } from \"@internal/config-loader\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { notOk, ok } from \"@internal/utils/result\";\nimport { APP_SPACE_ID, isValidSpaceId, listContractSpaceDirectories } from \"@internal/migration-tools/spaces\";\nimport { HEAD_REF_NAME, refsByContractHash } from \"@internal/migration-tools/refs\";\n//#region src/utils/legend.ts\n/**\n* The legend is decoration printed alongside the command header on stderr, so\n* it is suppressed for the machine-readable / silent paths (`--json`, `--dot`,\n* `--quiet`) exactly as the header is.\n*/\nfunction shouldShowLegend(options, flags) {\n\treturn options.legend === true && options.dot !== true && flags.json !== true && flags.quiet !== true;\n}\nfunction validateLegendOptions(options, flags) {\n\tif (options.legend !== true) return ok(void 0);\n\tif (flags.json === true) return notOk(errorLegendHumanOnly(\"--json\"));\n\tif (flags.quiet === true) return notOk(errorLegendHumanOnly(\"--quiet\"));\n\tif (options.dot === true) return notOk(errorLegendHumanOnly(\"--dot\"));\n\treturn ok(void 0);\n}\n//#endregion\n//#region src/commands/migration-list.ts\nfunction compareSpaceIds(a, b) {\n\tif (a === APP_SPACE_ID) return b === APP_SPACE_ID ? 0 : -1;\n\tif (b === APP_SPACE_ID) return 1;\n\tif (a < b) return -1;\n\tif (a > b) return 1;\n\treturn 0;\n}\nfunction compareDirNamesDescending(a, b) {\n\tif (a.name < b.name) return 1;\n\tif (a.name > b.name) return -1;\n\treturn 0;\n}\n/**\n* Ref names decorating a space's destination contract hashes. The\n* tolerant `space.refs` deliberately omits the structural `head.json`;\n* for extension spaces the old enumerator surfaced it as a `head`\n* decoration on the tip migration, so fold `space.headRef` back in to\n* keep that output. The app space synthesises its head, so it carries\n* no on-disk `head` ref to restore.\n*/\nfunction listRefsByContractHash(space) {\n\tconst byHash = new Map(refsByContractHash(space.refs));\n\tif (space.spaceId !== APP_SPACE_ID && space.headRef !== null) {\n\t\tconst hash = space.headRef.hash;\n\t\tconst bucket = byHash.get(hash) ?? [];\n\t\tif (!bucket.includes(HEAD_REF_NAME)) byHash.set(hash, [...bucket, HEAD_REF_NAME].sort());\n\t}\n\treturn byHash;\n}\nasync function orderedOnDiskSpaceIds(projectMigrationsDir) {\n\treturn (await listContractSpaceDirectories(projectMigrationsDir)).filter(isValidSpaceId).sort(compareSpaceIds);\n}\n/**\n* Project the loaded {@link ContractSpaceAggregate} into the render-ready\n* {@link MigrationSpaceListEntry} rows `migration list` displays.\n*\n* Space membership matches the on-disk contract-space directories (not the\n* aggregate's always-present synthesized app space when `migrations/app/`\n* is absent); package and ref data come from `aggregate.space(id)`.\n*/\nasync function migrationSpaceListEntriesFromAggregate(aggregate, projectMigrationsDir) {\n\tconst spaceIds = await orderedOnDiskSpaceIds(projectMigrationsDir);\n\tconst spaces = [];\n\tfor (const spaceId of spaceIds) {\n\t\tconst space = aggregate.space(spaceId);\n\t\tif (space === void 0) continue;\n\t\tconst refsByHash = listRefsByContractHash(space);\n\t\tconst migrations = space.packages.map((pkg) => ({\n\t\t\tname: pkg.dirName,\n\t\t\thash: pkg.metadata.migrationHash,\n\t\t\tfromContract: pkg.metadata.from,\n\t\t\ttoContract: pkg.metadata.to,\n\t\t\toperationCount: pkg.ops.length,\n\t\t\tcreatedAt: pkg.metadata.createdAt,\n\t\t\trefs: [...refsByHash.get(pkg.metadata.to) ?? []],\n\t\t\tprovidedInvariants: [...pkg.metadata.providedInvariants]\n\t\t})).sort(compareDirNamesDescending);\n\t\tspaces.push({\n\t\t\tspace: spaceId,\n\t\t\tmigrations\n\t\t});\n\t}\n\treturn spaces;\n}\nfunction renderMigrationListHumanOutput(result, options) {\n\treturn renderMigrationListWithStyle(result, createAnsiMigrationListStyler({ useColor: options.useColor }), options.glyphMode, {\n\t\tcolorize: options.useColor,\n\t\tliveContractHash: options.liveContractHash,\n\t\tgraphForSpace: options.graphForSpace,\n\t\t...options.appSpaceId !== void 0 ? { appSpaceId: options.appSpaceId } : {}\n\t});\n}\nfunction computeSummary(spaces) {\n\tconst totalMigrations = spaces.reduce((count, space) => count + space.migrations.length, 0);\n\tif (spaces.length <= 1) return `${totalMigrations} migration(s) on disk`;\n\treturn `${totalMigrations} migration(s) across ${spaces.length} contract space(s)`;\n}\n/**\n* Policy core of `migration list`: validates `--space`, narrows the\n* pre-enumerated spaces, and assembles a {@link MigrationListResult}.\n*\n* - `migrations/` missing or contains no valid space directories →\n* caller passes `spaces: []`; this synthesizes `[{ spaceId: APP_SPACE_ID, migrations: [] }]`.\n* - `--space <id>` on an existing-but-empty space → `{ spaceId, migrations: [] }` in the input.\n* - `--space <id>` on a non-existent (or reserved) space → `SPACE_NOT_FOUND`.\n*/\nfunction runMigrationList(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.space === spaceFilter)) return notOk(errorSpaceNotFound(spaceFilter, spaces.map((s) => s.space).sort()));\n\tconst scopedSpaces = spaceFilter !== void 0 ? spaces.filter((s) => s.space === spaceFilter) : spaces;\n\tconst resultSpaces = scopedSpaces.length === 0 ? [{\n\t\tspace: APP_SPACE_ID,\n\t\tmigrations: []\n\t}] : scopedSpaces;\n\treturn ok({\n\t\tok: true,\n\t\tspaces: [...resultSpaces],\n\t\tsummary: computeSummary(resultSpaces)\n\t});\n}\n/**\n* CLI shell: loads config, resolves paths, prints the styled header on\n* stderr (interactive mode only), and delegates to {@link runMigrationList}.\n* Kept intentionally thin so the unit-testable surface lives in the core.\n*/\nasync function executeMigrationListCommand(options, flags, ui) {\n\tconst config = await loadConfig(options.config);\n\tconst { configPath, migrationsDir, migrationsRelative } = resolveMigrationPaths(options.config, config);\n\tif (!flags.json && !flags.quiet) {\n\t\tconst header = formatStyledHeader({\n\t\t\tcommand: \"migration list\",\n\t\t\tdescription: \"List on-disk migrations per contract space\",\n\t\t\tdetails: [\n\t\t\t\t{\n\t\t\t\t\tlabel: \"config\",\n\t\t\t\t\tvalue: configPath\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tlabel: \"migrations\",\n\t\t\t\t\tvalue: migrationsRelative\n\t\t\t\t},\n\t\t\t\t...options.space !== void 0 ? [{\n\t\t\t\t\tlabel: \"space\",\n\t\t\t\t\tvalue: options.space\n\t\t\t\t}] : []\n\t\t\t],\n\t\t\tflags\n\t\t});\n\t\tui.stderr(header);\n\t\tif (shouldShowLegend(options, flags)) {\n\t\t\tui.stderr(renderMigrationGraphLegend({\n\t\t\t\tcolorize: flags.color !== false,\n\t\t\t\tglyphMode: ui.resolveGlyphMode(options.ascii === true)\n\t\t\t}));\n\t\t\tui.stderr(\"\");\n\t\t}\n\t}\n\tconst loaded = await buildReadAggregate(config, { migrationsDir });\n\tif (!loaded.ok) return notOk(loaded.failure);\n\tconst { aggregate, contractHash: liveContractHash } = loaded.value;\n\tconst listResult = runMigrationList({\n\t\tspaces: await migrationSpaceListEntriesFromAggregate(aggregate, migrationsDir),\n\t\t...ifDefined(\"spaceFilter\", options.space)\n\t});\n\tif (!listResult.ok) return listResult;\n\treturn ok({\n\t\tlist: listResult.value,\n\t\tliveContractHash,\n\t\taggregate\n\t});\n}\nfunction createMigrationListCommand() {\n\tconst command = new Command(\"list\");\n\tsetCommandDescriptions(command, \"List on-disk migrations per contract space\", \"Enumerates every on-disk migration under migrations/<space>/ for every\\ncontract space found on disk. Offline — does not consult the database.\\nHuman output draws the shared migration graph tree with operation counts,\\ninvariants on each migration row, and refs on destination contract nodes.\\nPass --space <id> to narrow to one contract space. --ascii forces ASCII\\ntree glyphs (orthogonal to --no-color).\");\n\tsetCommandExamples(command, [\n\t\t\"prisma-next migration list\",\n\t\t\"prisma-next migration list --space app\",\n\t\t\"prisma-next migration list --ascii\",\n\t\t\"prisma-next migration list --legend\",\n\t\t\"prisma-next migration list --json\"\n\t]);\n\tsetCommandSeeAlso(command, [\n\t\t{\n\t\t\tverb: \"migration status\",\n\t\t\toneLiner: \"Show migration path and pending status\"\n\t\t},\n\t\t{\n\t\t\tverb: \"migration log\",\n\t\t\toneLiner: \"Show executed migration history\"\n\t\t},\n\t\t{\n\t\t\tverb: \"migration graph\",\n\t\t\toneLiner: \"Show the migration graph topology\"\n\t\t},\n\t\t{\n\t\t\tverb: \"migration show\",\n\t\t\toneLiner: \"Display migration package contents\"\n\t\t}\n\t]);\n\taddGlobalOptions(command).option(\"--config <path>\", \"Path to prisma-next.config.ts\").option(\"--space <id>\", \"Narrow output to a single contract space\").option(\"--ascii\", \"Use ASCII kind glyphs (pipe-friendly)\").option(\"--legend\", \"Print a key for the tree glyphs and lane colors\").action(async (options) => {\n\t\tconst flags = parseGlobalFlagsOrExit(options);\n\t\tconst ui = createTerminalUI(flags);\n\t\tconst legendValidation = validateLegendOptions(options, flags);\n\t\tif (!legendValidation.ok) process.exit(handleResult(legendValidation, flags, ui));\n\t\tconst exitCode = handleResult(await executeMigrationListCommand(options, flags, ui), flags, ui, ({ list, liveContractHash, aggregate }) => {\n\t\t\tif (flags.json) ui.output(JSON.stringify(list, null, 2));\n\t\t\telse if (!flags.quiet) ui.output(renderMigrationListHumanOutput(list, {\n\t\t\t\tglyphMode: ui.resolveGlyphMode(options.ascii === true),\n\t\t\t\tuseColor: ui.useColor,\n\t\t\t\tliveContractHash,\n\t\t\t\tgraphForSpace: (spaceId) => aggregate.space(spaceId)?.graph(),\n\t\t\t\tappSpaceId: aggregate.app.spaceId\n\t\t\t}));\n\t\t});\n\t\tprocess.exit(exitCode);\n\t});\n\treturn command;\n}\n//#endregion\nexport { renderMigrationListHumanOutput as a, validateLegendOptions as c, migrationSpaceListEntriesFromAggregate as i, executeMigrationListCommand as n, runMigrationList as o, listRefsByContractHash as r, shouldShowLegend as s, createMigrationListCommand as t };\n\n//# sourceMappingURL=migration-list-BFBeo1_X.mjs.map"],"mappings":";;;;;;;;;;;;;;;AAeA,SAAS,iBAAiB,SAAS,OAAO;CACzC,OAAO,QAAQ,WAAW,QAAQ,QAAQ,QAAQ,QAAQ,MAAM,SAAS,QAAQ,MA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AAM;IAC5D,YAAY,UAAU,IAAI;GAC3B,CAAC,CAAC;EACH,CAAC;EACD,QAAQ,KAAK,QAAQ;CACtB,CAAC;CACD,OAAO;AACR"}
1
+ {"version":3,"file":"migration-list-D2_JdzWC-MRHYYVQE.mjs","names":[],"sources":["../../../../1-framework/3-tooling/cli/dist/migration-list-D2_JdzWC.mjs"],"sourcesContent":["import { A as formatStyledHeader, K as errorInvalidSpaceId, _ as createTerminalUI, at as errorSpaceNotFound, d as setCommandSeeAlso, g as parseGlobalFlagsOrExit, l as setCommandDescriptions, q as errorLegendHumanOnly, s as resolveMigrationPaths, t as addGlobalOptions, u as setCommandExamples, y as handleResult } from \"./command-helpers-C4WpR-QE.mjs\";\nimport { n as buildReadAggregate } from \"./contract-space-aggregate-loader-CziO_ZRW.mjs\";\nimport { a as renderMigrationGraphLegend, c as renderMigrationListWithStyle, o as createAnsiMigrationListStyler } from \"./migration-graph-command-render-BKrg6BPv.mjs\";\nimport { Command } from \"commander\";\nimport { loadConfig } from \"@internal/config-loader\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { notOk, ok } from \"@internal/utils/result\";\nimport { APP_SPACE_ID, isValidSpaceId, listContractSpaceDirectories } from \"@internal/migration-tools/spaces\";\nimport { HEAD_REF_NAME, refsByContractHash } from \"@internal/migration-tools/refs\";\n//#region src/utils/legend.ts\n/**\n* The legend is decoration printed alongside the command header on stderr, so\n* it is suppressed for the machine-readable / silent paths (`--json`, `--dot`,\n* `--quiet`) exactly as the header is.\n*/\nfunction shouldShowLegend(options, flags) {\n\treturn options.legend === true && options.dot !== true && flags.json !== true && flags.quiet !== true;\n}\nfunction validateLegendOptions(options, flags) {\n\tif (options.legend !== true) return ok(void 0);\n\tif (flags.json === true) return notOk(errorLegendHumanOnly(\"--json\"));\n\tif (flags.quiet === true) return notOk(errorLegendHumanOnly(\"--quiet\"));\n\tif (options.dot === true) return notOk(errorLegendHumanOnly(\"--dot\"));\n\treturn ok(void 0);\n}\n//#endregion\n//#region src/commands/migration-list.ts\nfunction compareSpaceIds(a, b) {\n\tif (a === APP_SPACE_ID) return b === APP_SPACE_ID ? 0 : -1;\n\tif (b === APP_SPACE_ID) return 1;\n\tif (a < b) return -1;\n\tif (a > b) return 1;\n\treturn 0;\n}\nfunction compareDirNamesDescending(a, b) {\n\tif (a.name < b.name) return 1;\n\tif (a.name > b.name) return -1;\n\treturn 0;\n}\n/**\n* Ref names decorating a space's destination contract hashes. The\n* tolerant `space.refs` deliberately omits the structural `head.json`;\n* for extension spaces the old enumerator surfaced it as a `head`\n* decoration on the tip migration, so fold `space.headRef` back in to\n* keep that output. The app space synthesises its head, so it carries\n* no on-disk `head` ref to restore.\n*/\nfunction listRefsByContractHash(space) {\n\tconst byHash = new Map(refsByContractHash(space.refs));\n\tif (space.spaceId !== APP_SPACE_ID && space.headRef !== null) {\n\t\tconst hash = space.headRef.hash;\n\t\tconst bucket = byHash.get(hash) ?? [];\n\t\tif (!bucket.includes(HEAD_REF_NAME)) byHash.set(hash, [...bucket, HEAD_REF_NAME].sort());\n\t}\n\treturn byHash;\n}\nasync function orderedOnDiskSpaceIds(projectMigrationsDir) {\n\treturn (await listContractSpaceDirectories(projectMigrationsDir)).filter(isValidSpaceId).sort(compareSpaceIds);\n}\n/**\n* Project the loaded {@link ContractSpaceAggregate} into the render-ready\n* {@link MigrationSpaceListEntry} rows `migration list` displays.\n*\n* Space membership matches the on-disk contract-space directories (not the\n* aggregate's always-present synthesized app space when `migrations/app/`\n* is absent); package and ref data come from `aggregate.space(id)`.\n*/\nasync function migrationSpaceListEntriesFromAggregate(aggregate, projectMigrationsDir) {\n\tconst spaceIds = await orderedOnDiskSpaceIds(projectMigrationsDir);\n\tconst spaces = [];\n\tfor (const spaceId of spaceIds) {\n\t\tconst space = aggregate.space(spaceId);\n\t\tif (space === void 0) continue;\n\t\tconst refsByHash = listRefsByContractHash(space);\n\t\tconst migrations = space.packages.map((pkg) => ({\n\t\t\tname: pkg.dirName,\n\t\t\thash: pkg.metadata.migrationHash,\n\t\t\tfromContract: pkg.metadata.from,\n\t\t\ttoContract: pkg.metadata.to,\n\t\t\toperationCount: pkg.ops.length,\n\t\t\tcreatedAt: pkg.metadata.createdAt,\n\t\t\trefs: [...refsByHash.get(pkg.metadata.to) ?? []],\n\t\t\tprovidedInvariants: [...pkg.metadata.providedInvariants]\n\t\t})).sort(compareDirNamesDescending);\n\t\tspaces.push({\n\t\t\tspace: spaceId,\n\t\t\tmigrations\n\t\t});\n\t}\n\treturn spaces;\n}\nfunction renderMigrationListHumanOutput(result, options) {\n\treturn renderMigrationListWithStyle(result, createAnsiMigrationListStyler({ useColor: options.useColor }), options.glyphMode, {\n\t\tcolorize: options.useColor,\n\t\tliveContractHash: options.liveContractHash,\n\t\tgraphForSpace: options.graphForSpace,\n\t\t...options.appSpaceId !== void 0 ? { appSpaceId: options.appSpaceId } : {}\n\t});\n}\nfunction computeSummary(spaces) {\n\tconst totalMigrations = spaces.reduce((count, space) => count + space.migrations.length, 0);\n\tif (spaces.length <= 1) return `${totalMigrations} migration(s) on disk`;\n\treturn `${totalMigrations} migration(s) across ${spaces.length} contract space(s)`;\n}\n/**\n* Policy core of `migration list`: validates `--space`, narrows the\n* pre-enumerated spaces, and assembles a {@link MigrationListResult}.\n*\n* - `migrations/` missing or contains no valid space directories →\n* caller passes `spaces: []`; this synthesizes `[{ spaceId: APP_SPACE_ID, migrations: [] }]`.\n* - `--space <id>` on an existing-but-empty space → `{ spaceId, migrations: [] }` in the input.\n* - `--space <id>` on a non-existent (or reserved) space → `SPACE_NOT_FOUND`.\n*/\nfunction runMigrationList(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.space === spaceFilter)) return notOk(errorSpaceNotFound(spaceFilter, spaces.map((s) => s.space).sort()));\n\tconst scopedSpaces = spaceFilter !== void 0 ? spaces.filter((s) => s.space === spaceFilter) : spaces;\n\tconst resultSpaces = scopedSpaces.length === 0 ? [{\n\t\tspace: APP_SPACE_ID,\n\t\tmigrations: []\n\t}] : scopedSpaces;\n\treturn ok({\n\t\tok: true,\n\t\tspaces: [...resultSpaces],\n\t\tsummary: computeSummary(resultSpaces)\n\t});\n}\n/**\n* CLI shell: loads config, resolves paths, prints the styled header on\n* stderr (interactive mode only), and delegates to {@link runMigrationList}.\n* Kept intentionally thin so the unit-testable surface lives in the core.\n*/\nasync function executeMigrationListCommand(options, flags, ui) {\n\tconst config = await loadConfig(options.config);\n\tconst { configPath, migrationsDir, migrationsRelative } = resolveMigrationPaths(options.config, config);\n\tif (!flags.json && !flags.quiet) {\n\t\tconst header = formatStyledHeader({\n\t\t\tcommand: \"migration list\",\n\t\t\tdescription: \"List on-disk migrations per contract space\",\n\t\t\tdetails: [\n\t\t\t\t{\n\t\t\t\t\tlabel: \"config\",\n\t\t\t\t\tvalue: configPath\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tlabel: \"migrations\",\n\t\t\t\t\tvalue: migrationsRelative\n\t\t\t\t},\n\t\t\t\t...options.space !== void 0 ? [{\n\t\t\t\t\tlabel: \"space\",\n\t\t\t\t\tvalue: options.space\n\t\t\t\t}] : []\n\t\t\t],\n\t\t\tflags\n\t\t});\n\t\tui.stderr(header);\n\t\tif (shouldShowLegend(options, flags)) {\n\t\t\tui.stderr(renderMigrationGraphLegend({\n\t\t\t\tcolorize: flags.color !== false,\n\t\t\t\tglyphMode: ui.resolveGlyphMode(options.ascii === true)\n\t\t\t}));\n\t\t\tui.stderr(\"\");\n\t\t}\n\t}\n\tconst loaded = await buildReadAggregate(config, { migrationsDir });\n\tif (!loaded.ok) return notOk(loaded.failure);\n\tconst { aggregate, contractHash: liveContractHash } = loaded.value;\n\tconst listResult = runMigrationList({\n\t\tspaces: await migrationSpaceListEntriesFromAggregate(aggregate, migrationsDir),\n\t\t...ifDefined(\"spaceFilter\", options.space)\n\t});\n\tif (!listResult.ok) return listResult;\n\treturn ok({\n\t\tlist: listResult.value,\n\t\tliveContractHash,\n\t\taggregate\n\t});\n}\nfunction createMigrationListCommand() {\n\tconst command = new Command(\"list\");\n\tsetCommandDescriptions(command, \"List on-disk migrations per contract space\", \"Enumerates every on-disk migration under migrations/<space>/ for every\\ncontract space found on disk. Offline — does not consult the database.\\nHuman output draws the shared migration graph tree with operation counts,\\ninvariants on each migration row, and refs on destination contract nodes.\\nPass --space <id> to narrow to one contract space. --ascii forces ASCII\\ntree glyphs (orthogonal to --no-color).\");\n\tsetCommandExamples(command, [\n\t\t\"prisma-next migration list\",\n\t\t\"prisma-next migration list --space app\",\n\t\t\"prisma-next migration list --ascii\",\n\t\t\"prisma-next migration list --legend\",\n\t\t\"prisma-next migration list --json\"\n\t]);\n\tsetCommandSeeAlso(command, [\n\t\t{\n\t\t\tverb: \"migration status\",\n\t\t\toneLiner: \"Show migration path and pending status\"\n\t\t},\n\t\t{\n\t\t\tverb: \"migration log\",\n\t\t\toneLiner: \"Show executed migration history\"\n\t\t},\n\t\t{\n\t\t\tverb: \"migration graph\",\n\t\t\toneLiner: \"Show the migration graph topology\"\n\t\t},\n\t\t{\n\t\t\tverb: \"migration show\",\n\t\t\toneLiner: \"Display migration package contents\"\n\t\t}\n\t]);\n\taddGlobalOptions(command).option(\"--config <path>\", \"Path to prisma-next.config.ts\").option(\"--space <id>\", \"Narrow output to a single contract space\").option(\"--ascii\", \"Use ASCII kind glyphs (pipe-friendly)\").option(\"--legend\", \"Print a key for the tree glyphs and lane colors\").action(async (options) => {\n\t\tconst flags = parseGlobalFlagsOrExit(options);\n\t\tconst ui = createTerminalUI(flags);\n\t\tconst legendValidation = validateLegendOptions(options, flags);\n\t\tif (!legendValidation.ok) process.exit(handleResult(legendValidation, flags, ui));\n\t\tconst exitCode = handleResult(await executeMigrationListCommand(options, flags, ui), flags, ui, ({ list, liveContractHash, aggregate }) => {\n\t\t\tif (flags.json) ui.output(JSON.stringify(list, null, 2));\n\t\t\telse if (!flags.quiet) ui.output(renderMigrationListHumanOutput(list, {\n\t\t\t\tglyphMode: ui.resolveGlyphMode(options.ascii === true),\n\t\t\t\tuseColor: ui.useColor,\n\t\t\t\tliveContractHash,\n\t\t\t\tgraphForSpace: (spaceId) => aggregate.space(spaceId)?.graph(),\n\t\t\t\tappSpaceId: aggregate.app.spaceId\n\t\t\t}));\n\t\t});\n\t\tprocess.exit(exitCode);\n\t});\n\treturn command;\n}\n//#endregion\nexport { renderMigrationListHumanOutput as a, validateLegendOptions as c, migrationSpaceListEntriesFromAggregate as i, executeMigrationListCommand as n, runMigrationList as o, listRefsByContractHash as r, shouldShowLegend as s, createMigrationListCommand as t };\n\n//# sourceMappingURL=migration-list-D2_JdzWC.mjs.map"],"mappings":";;;;;;;;;;;;;;;AAeA,SAAS,iBAAiB,SAAS,OAAO;CACzC,OAAO,QAAQ,WAAW,QAAQ,QAAQ,QAAQ,QAAQ,MAAM,SAAS,QAAQ,MAAM,UAAU;AAClG;AACA,SAAS,sBAAsB,SAAS,OAAO;CAC9C,IAAI,QAAQ,WAAW,MAAM,OAAO,GAAG,KAAK,CAAC;CAC7C,IAAI,MAAM,SAAS,MAAM,OAAO,MAAM,qBAAqB,QAAQ,CAAC;CACpE,IAAI,MAAM,UAAU,MAAM,OAAO,MAAM,qBAAqB,SAAS,CAAC;CACtE,IAAI,QAAQ,QAAQ,MAAM,OAAO,MAAM,qBAAqB,OAAO,CAAC;CACpE,OAAO,GAAG,KAAK,CAAC;AACjB;AAGA,SAAS,gBAAgB,GAAG,GAAG;CAC9B,IAAI,MAAM,cAAc,OAAO,MAAM,eAAe,IAAI;CACxD,IAAI,MAAM,cAAc,OAAO;CAC/B,IAAI,IAAI,GAAG,OAAO;CAClB,IAAI,IAAI,GAAG,OAAO;CAClB,OAAO;AACR;AACA,SAAS,0BAA0B,GAAG,GAAG;CACxC,IAAI,EAAE,OAAO,EAAE,MAAM,OAAO;CAC5B,IAAI,EAAE,OAAO,EAAE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uC,CAAC,CAAC,OAAO,YAAY,iDAAiD,CAAC,CAAC,OAAO,OAAO,YAAY;EAClT,MAAM,QAAQ,uBAAuB,OAAO;EAC5C,MAAM,KAAK,iBAAiB,KAAK;EACjC,MAAM,mBAAmB,sBAAsB,SAAS,KAAK;EAC7D,IAAI,CAAC,iBAAiB,IAAI,QAAQ,KAAK,aAAa,kBAAkB,OAAO,EAAE,CAAC;EAChF,MAAM,WAAW,aAAa,MAAM,4BAA4B,SAAS,OAAO,EAAE,GAAG,OAAO,KAAK,EAAE,MAAM,kBAAkB,gBAAgB;GAC1I,IAAI,MAAM,MAAM,GAAG,OAAO,KAAK,UAAU,MAAM,MAAM,CAAC,CAAC;QAClD,IAAI,CAAC,MAAM,OAAO,GAAG,OAAO,+BAA+B,MAAM;IACrE,WAAW,GAAG,iBAAiB,QAAQ,UAAU,IAAI;IACrD,UAAU,GAAG;IACb;IACA,gBAAgB,YAAY,UAAU,MAAM,OAAO,CAAC,EAAE,MAAM;IAC5D,YAAY,UAAU,IAAI;GAC3B,CAAC,CAAC;EACH,CAAC;EACD,QAAQ,KAAK,QAAQ;CACtB,CAAC;CACD,OAAO;AACR"}
@@ -1,13 +1,12 @@
1
- import { t as MigrationToolsError } from "./errors-IpZm1Skp-BH495dRd.mjs";
2
- import { $ as maskConnectionUrl, N as errorUnexpected, W as formatStyledHeader, Z as mapMigrationToolsError, at as resolveMigrationPaths, ct as setCommandExamples, lt as setCommandSeeAlso, o as createTerminalUI, q as handleResult, r as addGlobalOptions, rt as requireLiveDatabase, st as setCommandDescriptions, t as CliStructuredError$1, tt as parseGlobalFlagsOrExit, ut as targetSupportsMigrations } from "./command-helpers-CAoXqAY9-DWUBcTXM.mjs";
1
+ import { N as errorUnexpected, Q as maskConnectionUrl, W as formatStyledHeader, ct as setCommandSeeAlso, et as parseGlobalFlagsOrExit, it as resolveMigrationPaths, lt as targetSupportsMigrations, nt as requireLiveDatabase, o as createTerminalUI, ot as setCommandDescriptions, q as handleResult, r as addGlobalOptions, st as setCommandExamples, t as CliStructuredError$1 } from "./command-helpers-C4WpR-QE-CK2gkj6l.mjs";
3
2
  import { r as loadConfig } from "./exports-CDX9kZuw.mjs";
4
- import { t as createControlClient } from "./client-75qrAPqf-7l0C0H_b.mjs";
3
+ import { t as createControlClient } from "./client-7aUYC7ci-Bh9mLxkl.mjs";
5
4
  import { l as createAnsiMigrationListStyler, m as migrationListForwardArrow, n as abbreviateContractHash, p as migrationListEmptySource, t as IDENTITY_MIGRATION_LIST_STYLER } from "./migration-graph-command-render-BKrg6BPv-BP8Pfj4J.mjs";
6
5
  import { ifDefined } from "@prisma/orm-framework/utils/defined";
7
6
  import { notOk, ok } from "@prisma/orm-framework/utils/result";
8
7
  import stringWidth from "string-width";
9
8
  import { Command } from "commander";
10
- //#region ../../../1-framework/3-tooling/cli/dist/migration-log-CS5IWcNq.mjs
9
+ //#region ../../../1-framework/3-tooling/cli/dist/migration-log-BXbz6-Lj.mjs
11
10
  const HEADING_APPLIED_AT = "Applied at";
12
11
  const HEADING_SPACE = "Space";
13
12
  const HEADING_MIGRATION = "Migration";
@@ -156,7 +155,6 @@ async function executeMigrationLogCommand(options, flags, ui) {
156
155
  return ok(await client.readLedger());
157
156
  } catch (error) {
158
157
  if (CliStructuredError$1.is(error)) return notOk(error);
159
- if (MigrationToolsError.is(error)) return notOk(mapMigrationToolsError(error));
160
158
  return notOk(errorUnexpected(error instanceof Error ? error.message : String(error), { why: `Failed to read migration log: ${error instanceof Error ? error.message : String(error)}` }));
161
159
  } finally {
162
160
  await client.close();
@@ -217,4 +215,4 @@ function createMigrationLogCommand() {
217
215
  //#endregion
218
216
  export { executeMigrationLogCommand as n, createMigrationLogCommand as t };
219
217
 
220
- //# sourceMappingURL=migration-log-CS5IWcNq-DI7FTHCA.mjs.map
218
+ //# sourceMappingURL=migration-log-BXbz6-Lj-CKHbat5f.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migration-log-BXbz6-Lj-CKHbat5f.mjs","names":["CliStructuredError"],"sources":["../../../../1-framework/3-tooling/cli/dist/migration-log-BXbz6-Lj.mjs"],"sourcesContent":["import { A as formatStyledHeader, F as CliStructuredError, _ as createTerminalUI, ct as errorUnexpected, d as setCommandSeeAlso, f as targetSupportsMigrations, g as parseGlobalFlagsOrExit, i as maskConnectionUrl, l as setCommandDescriptions, s as resolveMigrationPaths, t as addGlobalOptions, u as setCommandExamples, ut as requireLiveDatabase, y as handleResult } from \"./command-helpers-C4WpR-QE.mjs\";\nimport { t as createControlClient } from \"./client-7aUYC7ci.mjs\";\nimport { _ as migrationListEmptySource, g as abbreviateContractHash, o as createAnsiMigrationListStyler, s as IDENTITY_MIGRATION_LIST_STYLER, v as migrationListForwardArrow } from \"./migration-graph-command-render-BKrg6BPv.mjs\";\nimport { Command } from \"commander\";\nimport { loadConfig } from \"@internal/config-loader\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { notOk, ok } from \"@internal/utils/result\";\nimport stringWidth from \"string-width\";\n//#region src/utils/formatters/migration-log-table.ts\nconst HEADING_APPLIED_AT = \"Applied at\";\nconst HEADING_SPACE = \"Space\";\nconst HEADING_MIGRATION = \"Migration\";\nconst HEADING_CHANGE = \"Change\";\nconst HEADING_OPS = \"Ops\";\nconst COLUMN_SEPARATOR = \" \";\nconst DIVIDER_CHAR = \"─\";\nconst ASCII_DIVIDER_CHAR = \"-\";\nfunction sortLedgerEntries(entries) {\n\treturn [...entries].sort((left, right) => {\n\t\tconst timeDiff = left.appliedAt.getTime() - right.appliedAt.getTime();\n\t\tif (timeDiff !== 0) return timeDiff;\n\t\tconst spaceDiff = left.space.localeCompare(right.space);\n\t\tif (spaceDiff !== 0) return spaceDiff;\n\t\treturn left.migrationName.localeCompare(right.migrationName);\n\t});\n}\nfunction pad2(value) {\n\treturn String(value).padStart(2, \"0\");\n}\nfunction formatLedgerAppliedAt(date, mode) {\n\tif (mode === \"iso\") return date.toISOString();\n\tif (mode === \"utc\") return `${date.getUTCFullYear()}-${pad2(date.getUTCMonth() + 1)}-${pad2(date.getUTCDate())} ${pad2(date.getUTCHours())}:${pad2(date.getUTCMinutes())}:${pad2(date.getUTCSeconds())}Z`;\n\tconst offsetMinutes = -date.getTimezoneOffset();\n\tconst sign = offsetMinutes >= 0 ? \"+\" : \"-\";\n\tconst absoluteOffset = Math.abs(offsetMinutes);\n\tconst offsetHours = pad2(Math.floor(absoluteOffset / 60));\n\tconst offsetMins = pad2(absoluteOffset % 60);\n\treturn `${date.getFullYear()}-${pad2(date.getMonth() + 1)}-${pad2(date.getDate())} ${pad2(date.getHours())}:${pad2(date.getMinutes())}:${pad2(date.getSeconds())} ${sign}${offsetHours}:${offsetMins}`;\n}\nfunction formatHashEndpoint(hash, glyphMode = \"unicode\") {\n\tif (hash === null) return migrationListEmptySource(glyphMode);\n\treturn abbreviateContractHash(hash);\n}\nfunction formatHashTransition(from, to, glyphMode = \"unicode\") {\n\treturn `${formatHashEndpoint(from, glyphMode)} ${migrationListForwardArrow(glyphMode)} ${abbreviateContractHash(to)}`;\n}\nfunction styleHashTransition(from, to, styler, glyphMode = \"unicode\") {\n\treturn `${from === null ? styler.glyph(migrationListEmptySource(glyphMode)) : styler.sourceHash(abbreviateContractHash(from))} ${styler.glyph(migrationListForwardArrow(glyphMode))} ${styler.destHash(abbreviateContractHash(to))}`;\n}\nfunction padVisible(text, targetWidth) {\n\tconst padding = Math.max(0, targetWidth - stringWidth(text));\n\treturn text + \" \".repeat(padding);\n}\nfunction columnWidth(values) {\n\treturn values.reduce((max, value) => Math.max(max, stringWidth(value)), 0);\n}\nfunction padDividerCell(valueWidth, dividerChar) {\n\treturn dividerChar.repeat(valueWidth + 2);\n}\nfunction padTextCell(value, valueWidth) {\n\treturn ` ${padVisible(value, valueWidth)} `;\n}\nfunction padOpsCell(value, valueWidth) {\n\tconst padding = Math.max(0, valueWidth - stringWidth(value));\n\treturn ` ${\" \".repeat(padding)}${value} `;\n}\nfunction renderMigrationLogTable(entries, options = {}) {\n\tconst sorted = sortLedgerEntries(entries);\n\tif (sorted.length === 0) return \"\";\n\tconst styler = options.styler ?? IDENTITY_MIGRATION_LIST_STYLER;\n\tconst glyphMode = options.glyphMode ?? \"unicode\";\n\tconst dividerChar = glyphMode === \"ascii\" ? ASCII_DIVIDER_CHAR : DIVIDER_CHAR;\n\tconst showSpace = new Set(sorted.map((entry) => entry.space)).size > 1;\n\tconst timestampMode = options.utc ? \"utc\" : \"local\";\n\tconst rows = sorted.map((entry) => ({\n\t\tappliedAt: formatLedgerAppliedAt(entry.appliedAt, timestampMode),\n\t\tspace: entry.space,\n\t\tmigrationName: entry.migrationName,\n\t\ttransition: formatHashTransition(entry.from, entry.to, glyphMode),\n\t\tops: `${entry.operationCount} ops`,\n\t\tfrom: entry.from,\n\t\tto: entry.to\n\t}));\n\tconst appliedAtWidth = columnWidth([HEADING_APPLIED_AT, ...rows.map((row) => row.appliedAt)]);\n\tconst spaceWidth = showSpace ? columnWidth([HEADING_SPACE, ...rows.map((row) => row.space)]) : 0;\n\tconst nameWidth = columnWidth([HEADING_MIGRATION, ...rows.map((row) => row.migrationName)]);\n\tconst transitionWidth = columnWidth([HEADING_CHANGE, ...rows.map((row) => row.transition)]);\n\tconst opsWidth = columnWidth([HEADING_OPS, ...rows.map((row) => row.ops)]);\n\tconst headingParts = [padTextCell(HEADING_APPLIED_AT, appliedAtWidth)];\n\tif (showSpace) headingParts.push(padTextCell(HEADING_SPACE, spaceWidth));\n\theadingParts.push(padTextCell(HEADING_MIGRATION, nameWidth), padTextCell(HEADING_CHANGE, transitionWidth), padOpsCell(HEADING_OPS, opsWidth));\n\tconst heading = headingParts.join(COLUMN_SEPARATOR);\n\tconst dividerParts = [padDividerCell(appliedAtWidth, dividerChar)];\n\tif (showSpace) dividerParts.push(padDividerCell(spaceWidth, dividerChar));\n\tdividerParts.push(padDividerCell(nameWidth, dividerChar), padDividerCell(transitionWidth, dividerChar), padDividerCell(opsWidth, dividerChar));\n\treturn [\n\t\theading,\n\t\tdividerParts.map((cell) => styler.summary(cell)).join(COLUMN_SEPARATOR),\n\t\t...rows.map((row) => {\n\t\t\tconst parts = [padTextCell(row.appliedAt, appliedAtWidth)];\n\t\t\tif (showSpace) parts.push(padTextCell(row.space, spaceWidth));\n\t\t\tparts.push(padTextCell(styler.dirName(row.migrationName), nameWidth), padTextCell(styleHashTransition(row.from, row.to, styler, glyphMode), transitionWidth), padOpsCell(row.ops, opsWidth));\n\t\t\treturn parts.join(COLUMN_SEPARATOR);\n\t\t})\n\t].join(\"\\n\");\n}\nfunction serializeLedgerEntriesForJson(entries) {\n\treturn sortLedgerEntries(entries).map((entry) => ({\n\t\tspace: entry.space,\n\t\tname: entry.migrationName,\n\t\thash: entry.migrationHash,\n\t\tfromContract: entry.from,\n\t\ttoContract: entry.to,\n\t\tappliedAt: formatLedgerAppliedAt(entry.appliedAt, \"iso\"),\n\t\toperationCount: entry.operationCount\n\t}));\n}\nconst MIGRATION_LOG_EMPTY_MESSAGE = \"No migrations have been applied to this database.\";\n//#endregion\n//#region src/commands/migration-log.ts\nasync function executeMigrationLogCommand(options, flags, ui) {\n\tconst config = await loadConfig(options.config);\n\tconst { configPath } = resolveMigrationPaths(options.config, config);\n\tconst dbConnection = options.db ?? config.db?.connection;\n\tconst missingDb = requireLiveDatabase({\n\t\tdbConnection,\n\t\thasDriver: !!config.driver,\n\t\twhy: `migration log needs a database connection and driver to read the ledger (set db.connection in ${configPath}, or pass --db <url>)`,\n\t\tcommandName: \"migration log\"\n\t});\n\tif (missingDb) return notOk(missingDb);\n\tif (!targetSupportsMigrations(config.target)) return notOk(errorUnexpected(\"Target does not support migrations\"));\n\tif (!flags.json && !flags.quiet) {\n\t\tconst header = formatStyledHeader({\n\t\t\tcommand: \"migration log\",\n\t\t\tdescription: \"Show executed migration history from the database ledger\",\n\t\t\tdetails: [{\n\t\t\t\tlabel: \"config\",\n\t\t\t\tvalue: configPath\n\t\t\t}, ...typeof dbConnection === \"string\" ? [{\n\t\t\t\tlabel: \"database\",\n\t\t\t\tvalue: maskConnectionUrl(dbConnection)\n\t\t\t}] : []],\n\t\t\tflags\n\t\t});\n\t\tui.stderr(header);\n\t}\n\tconst client = createControlClient({\n\t\tfamily: config.family,\n\t\ttarget: config.target,\n\t\tadapter: config.adapter,\n\t\t...ifDefined(\"driver\", config.driver),\n\t\textensions: config.extensions ?? []\n\t});\n\ttry {\n\t\tawait client.connect(dbConnection);\n\t\treturn ok(await client.readLedger());\n\t} catch (error) {\n\t\tif (CliStructuredError.is(error)) return notOk(error);\n\t\treturn notOk(errorUnexpected(error instanceof Error ? error.message : String(error), { why: `Failed to read migration log: ${error instanceof Error ? error.message : String(error)}` }));\n\t} finally {\n\t\tawait client.close();\n\t}\n}\nfunction createMigrationLogCommand() {\n\tconst command = new Command(\"log\");\n\tsetCommandDescriptions(command, \"Show executed migration history\", \"Reads the database ledger and displays every applied migration edge\\nin chronological order, including rollbacks and re-applies, merged\\nacross all contract spaces. Requires a database connection.\");\n\tsetCommandExamples(command, [\n\t\t\"prisma-next migration log --db $DATABASE_URL\",\n\t\t\"prisma-next migration log --utc --db $DATABASE_URL\",\n\t\t\"prisma-next migration log --json --db $DATABASE_URL\"\n\t]);\n\tsetCommandSeeAlso(command, [\n\t\t{\n\t\t\tverb: \"migration status\",\n\t\t\toneLiner: \"Show migration path and pending status\"\n\t\t},\n\t\t{\n\t\t\tverb: \"migration list\",\n\t\t\toneLiner: \"List on-disk migrations\"\n\t\t},\n\t\t{\n\t\t\tverb: \"migration graph\",\n\t\t\toneLiner: \"Show the migration graph topology\"\n\t\t},\n\t\t{\n\t\t\tverb: \"migration show\",\n\t\t\toneLiner: \"Display migration package contents\"\n\t\t}\n\t]);\n\taddGlobalOptions(command).option(\"--db <url>\", \"Database connection string\").option(\"--config <path>\", \"Path to prisma-next.config.ts\").option(\"--utc\", \"Render human timestamps in UTC instead of local time\").option(\"--ascii\", \"Use ASCII glyphs (pipe-friendly)\").action(async (options) => {\n\t\tconst flags = parseGlobalFlagsOrExit(options);\n\t\tconst ui = createTerminalUI(flags);\n\t\tconst exitCode = handleResult(await executeMigrationLogCommand(options, flags, ui), flags, ui, (entries) => {\n\t\t\tif (flags.json) {\n\t\t\t\tconst records = serializeLedgerEntriesForJson(entries);\n\t\t\t\tconst result = {\n\t\t\t\t\tok: true,\n\t\t\t\t\trecords,\n\t\t\t\t\tsummary: `${records.length} migration(s) applied`\n\t\t\t\t};\n\t\t\t\tui.output(JSON.stringify(result, null, 2));\n\t\t\t} else if (!flags.quiet) if (entries.length === 0) ui.output(MIGRATION_LOG_EMPTY_MESSAGE);\n\t\t\telse {\n\t\t\t\tconst styler = createAnsiMigrationListStyler({ useColor: ui.useColor });\n\t\t\t\tui.output(renderMigrationLogTable(entries, {\n\t\t\t\t\tutc: options.utc === true,\n\t\t\t\t\tstyler,\n\t\t\t\t\tglyphMode: ui.resolveGlyphMode(options.ascii === true)\n\t\t\t\t}));\n\t\t\t}\n\t\t});\n\t\tprocess.exit(exitCode);\n\t});\n\treturn command;\n}\n//#endregion\nexport { executeMigrationLogCommand as n, createMigrationLogCommand as t };\n\n//# sourceMappingURL=migration-log-BXbz6-Lj.mjs.map"],"mappings":";;;;;;;;;AASA,MAAM,qBAAqB;AAC3B,MAAM,gBAAgB;AACtB,MAAM,oBAAoB;AAC1B,MAAM,iBAAiB;AACvB,MAAM,cAAc;AACpB,MAAM,mBAAmB;AACzB,MAAM,eAAe;AACrB,MAAM,qBAAqB;AAC3B,SAAS,kBAAkB,SAAS;CACnC,OAAO,CAAC,GAAG,OAAO,CAAC,CAAC,MAAM,MAAM,UAAU;EACzC,MAAM,WAAW,KAAK,UAAU,QAAQ,IAAI,MAAM,UAAU,QAAQ;EACpE,IAAI,aAAa,GAAG,OAAO;EAC3B,MAAM,YAAY,KAAK,MAAM,cAAc,MAAM,KAAK;EACtD,IAAI,cAAc,GAAG,OAAO;EAC5B,OAAO,KAAK,cAAc,cAAc,MAAM,aAAa;CAC5D,CAAC;AACF;AACA,SAAS,KAAK,OAAO;CACpB,O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