@prisma/orm-toolchain 8.0.0-rc.1-dev.6 → 8.0.0-rc.1-dev.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{aggregate-i-rfetSO.mjs → aggregate-D53gnb7v.mjs} +8 -8
- package/dist/{aggregate-i-rfetSO.mjs.map → aggregate-D53gnb7v.mjs.map} +1 -1
- package/dist/bin__prisma-next.mjs +22 -22
- package/dist/bin__prisma-next.mjs.map +1 -1
- package/dist/caught-errors-D7Qznyrm-BzYooF6H.mjs +14 -0
- package/dist/caught-errors-D7Qznyrm-BzYooF6H.mjs.map +1 -0
- package/dist/{types-2n_H3DQ9-Bks8UPEO.d.mts → cli-errors-CDr3WcJP-NFry5GHb.d.mts} +2 -2
- package/dist/cli-errors-CDr3WcJP-NFry5GHb.d.mts.map +1 -0
- package/dist/cli.mjs +2 -2
- package/dist/cli__commands__contract-emit.mjs +1 -1
- package/dist/cli__commands__contract-infer.mjs +1 -1
- package/dist/cli__commands__db-init.mjs +1 -1
- package/dist/cli__commands__db-schema.mjs +1 -1
- package/dist/cli__commands__db-sign.mjs +1 -1
- package/dist/cli__commands__db-update.mjs +1 -1
- package/dist/cli__commands__db-verify.mjs +1 -1
- package/dist/cli__commands__migrate.d.mts +3 -12
- package/dist/cli__commands__migrate.d.mts.map +1 -1
- package/dist/cli__commands__migrate.mjs +1 -1
- package/dist/cli__commands__migration-check.d.mts +1 -57
- package/dist/cli__commands__migration-check.d.mts.map +1 -1
- package/dist/cli__commands__migration-check.mjs +2 -2
- package/dist/cli__commands__migration-graph.d.mts +1 -1
- package/dist/cli__commands__migration-graph.mjs +1 -1
- package/dist/cli__commands__migration-list.d.mts +4 -44
- package/dist/cli__commands__migration-list.d.mts.map +1 -1
- package/dist/cli__commands__migration-list.mjs +2 -2
- package/dist/cli__commands__migration-log.d.mts +1 -1
- package/dist/cli__commands__migration-log.mjs +1 -1
- package/dist/cli__commands__migration-new.mjs +1 -1
- package/dist/cli__commands__migration-plan.d.mts +2 -47
- package/dist/cli__commands__migration-plan.d.mts.map +1 -1
- package/dist/cli__commands__migration-plan.mjs +1 -1
- package/dist/cli__commands__migration-show.mjs +1 -1
- package/dist/cli__commands__migration-status.d.mts +1 -1
- package/dist/cli__commands__migration-status.mjs +1 -1
- package/dist/cli__commands__ref.d.mts +1 -28
- package/dist/cli__commands__ref.d.mts.map +1 -1
- package/dist/cli__commands__ref.mjs +2 -2
- package/dist/cli__commands__telemetry.mjs +1 -1
- package/dist/cli__control-api.d.mts +502 -2
- package/dist/cli__control-api.d.mts.map +1 -1
- package/dist/cli__control-api.mjs +18 -3
- package/dist/cli__migration-cli.mjs +2 -2
- package/dist/{client-7aUYC7ci-Bh9mLxkl.mjs → client-Y6qbDk7X-BzKLmBZo.mjs} +8 -8
- package/dist/{client-7aUYC7ci-Bh9mLxkl.mjs.map → client-Y6qbDk7X-BzKLmBZo.mjs.map} +1 -1
- package/dist/{command-helpers-C4WpR-QE-CK2gkj6l.mjs → command-helpers-C4WpR-QE-DE494TSG.mjs} +2 -2
- package/dist/{command-helpers-C4WpR-QE-CK2gkj6l.mjs.map → command-helpers-C4WpR-QE-DE494TSG.mjs.map} +1 -1
- package/dist/config-loader.d.mts +2 -18
- package/dist/{contract-at-errors-YdCQ5OOk-okxG7Eaj.mjs → contract-at-errors-Dv1mxKYO-C29YB4RC.mjs} +4 -4
- package/dist/contract-at-errors-Dv1mxKYO-C29YB4RC.mjs.map +1 -0
- package/dist/{contract-emit-CTm2zfuG-8mtkxW8M.mjs → contract-emit-CTm2zfuG-7PV9SBY6.mjs} +4 -4
- package/dist/{contract-emit-CTm2zfuG-8mtkxW8M.mjs.map → contract-emit-CTm2zfuG-7PV9SBY6.mjs.map} +1 -1
- package/dist/{contract-emit-D8IXP9Qp-CecAQio1.mjs → contract-emit-D8IXP9Qp-Df6NwXn8.mjs} +3 -3
- package/dist/{contract-emit-D8IXP9Qp-CecAQio1.mjs.map → contract-emit-D8IXP9Qp-Df6NwXn8.mjs.map} +1 -1
- package/dist/{contract-infer-C8-RqHeK-D_dm3onP.mjs → contract-infer-BwT7ngoo-Dx6aAwIN.mjs} +4 -4
- package/dist/{contract-infer-C8-RqHeK-D_dm3onP.mjs.map → contract-infer-BwT7ngoo-Dx6aAwIN.mjs.map} +1 -1
- package/dist/contract-snapshot-resolution-SATuw0JW-CsYq7g_n.mjs +82 -0
- package/dist/contract-snapshot-resolution-SATuw0JW-CsYq7g_n.mjs.map +1 -0
- package/dist/{contract-snapshot-store-DNTOE6fB-BDpjbdCJ.mjs → contract-snapshot-store-C9-J6OBn-ByElY0EC.mjs} +3 -3
- package/dist/{contract-snapshot-store-DNTOE6fB-BDpjbdCJ.mjs.map → contract-snapshot-store-C9-J6OBn-ByElY0EC.mjs.map} +1 -1
- package/dist/{contract-space-aggregate-loader-CziO_ZRW-DIoQOL0P.mjs → contract-space-aggregate-loader-C5r12INu-Db_pa3rX.mjs} +6 -6
- package/dist/contract-space-aggregate-loader-C5r12INu-Db_pa3rX.mjs.map +1 -0
- package/dist/{db-init-CXMcvoIA.mjs → db-init-CBj_EWg3.mjs} +15 -26
- package/dist/db-init-CBj_EWg3.mjs.map +1 -0
- package/dist/{db-schema-j8DERh4t.mjs → db-schema-BWpeh0Q_.mjs} +4 -4
- package/dist/{db-schema-j8DERh4t.mjs.map → db-schema-BWpeh0Q_.mjs.map} +1 -1
- package/dist/{db-sign-xV_rpoIc.mjs → db-sign-DCb_DKtv.mjs} +13 -29
- package/dist/db-sign-DCb_DKtv.mjs.map +1 -0
- package/dist/{db-update-DXa2DIvu.mjs → db-update-WX0KitcX.mjs} +27 -50
- package/dist/db-update-WX0KitcX.mjs.map +1 -0
- package/dist/{db-verify-YWHjuKC7-DidK1gx1.mjs → db-verify-B8ax2Y_x-Bp4s5Ra6.mjs} +5 -5
- package/dist/{db-verify-YWHjuKC7-DidK1gx1.mjs.map → db-verify-B8ax2Y_x-Bp4s5Ra6.mjs.map} +1 -1
- package/dist/{errors-BwusfLIN-BXM7K-ww.mjs → errors-Co-8oaiB-CB-6Uqki.mjs} +5 -4
- package/dist/{errors-BwusfLIN-BXM7K-ww.mjs.map → errors-Co-8oaiB-CB-6Uqki.mjs.map} +1 -1
- package/dist/{errors-AkMBj-YP.d.mts → errors-NRmFpwR1.d.mts} +6 -2
- package/dist/errors-NRmFpwR1.d.mts.map +1 -0
- package/dist/{format-Bw3LVJ1v-D10inUT9.mjs → format-Bw3LVJ1v-BJ6lVFMA.mjs} +2 -2
- package/dist/{format-Bw3LVJ1v-D10inUT9.mjs.map → format-Bw3LVJ1v-BJ6lVFMA.mjs.map} +1 -1
- package/dist/{framework-components-3DdB31mk-BPGSuOyZ.mjs → framework-components-3DdB31mk-BHyX-OlJ.mjs} +2 -2
- package/dist/{framework-components-3DdB31mk-BPGSuOyZ.mjs.map → framework-components-3DdB31mk-BHyX-OlJ.mjs.map} +1 -1
- package/dist/{graph-membership-h9ejuZla-ewjYM5wz.mjs → graph-membership-BEmNEMtP-rz61CLM5.mjs} +3 -3
- package/dist/{graph-membership-h9ejuZla-ewjYM5wz.mjs.map → graph-membership-BEmNEMtP-rz61CLM5.mjs.map} +1 -1
- package/dist/index-Df9igRvP.d.mts +18 -0
- package/dist/index-Df9igRvP.d.mts.map +1 -0
- package/dist/{init-CPB89WK2-Di4kgP6B.mjs → init-CPB89WK2-DPZRZ9Ee.mjs} +3 -3
- package/dist/{init-CPB89WK2-Di4kgP6B.mjs.map → init-CPB89WK2-DPZRZ9Ee.mjs.map} +1 -1
- package/dist/{inspect-live-schema-DEYE4EHW-DmSfKdpv.mjs → inspect-live-schema-Da76TWOs-CAFqkhGb.mjs} +4 -4
- package/dist/{inspect-live-schema-DEYE4EHW-DmSfKdpv.mjs.map → inspect-live-schema-Da76TWOs-CAFqkhGb.mjs.map} +1 -1
- package/dist/invariants-BzYfO9IL-BXTvx0z9.mjs +52 -0
- package/dist/invariants-BzYfO9IL-BXTvx0z9.mjs.map +1 -0
- package/dist/{invariants-CMcQxRas-CXX9uhQW.mjs → invariants-C1WVUAH7-DlOBTTkM.mjs} +3 -3
- package/dist/{invariants-CMcQxRas-CXX9uhQW.mjs.map → invariants-C1WVUAH7-DlOBTTkM.mjs.map} +1 -1
- package/dist/{io-CL3hSv42-DGZtTs89.mjs → io-CHUUeHh0-CoCBe9eN.mjs} +5 -5
- package/dist/{io-CL3hSv42-DGZtTs89.mjs.map → io-CHUUeHh0-CoCBe9eN.mjs.map} +1 -1
- package/dist/legend-5iwwlLU2-CB8bdQKJ.mjs +22 -0
- package/dist/legend-5iwwlLU2-CB8bdQKJ.mjs.map +1 -0
- package/dist/{migrate-COusRrm7.mjs → migrate-B-NAuO90.mjs} +87 -230
- package/dist/migrate-B-NAuO90.mjs.map +1 -0
- package/dist/migrate-show-60NNqVia-oGqMaVA9.d.mts +56 -0
- package/dist/migrate-show-60NNqVia-oGqMaVA9.d.mts.map +1 -0
- package/dist/migrate-show-B2LkXkoB-D1ZNl84C.mjs +202 -0
- package/dist/migrate-show-B2LkXkoB-D1ZNl84C.mjs.map +1 -0
- package/dist/{migration-diUAhNaa.mjs → migration-DAJY-NmR.mjs} +3 -3
- package/dist/{migration-diUAhNaa.mjs.map → migration-DAJY-NmR.mjs.map} +1 -1
- package/dist/migration-check-BDjtAn7x-B0nEBR0k.mjs +254 -0
- package/dist/migration-check-BDjtAn7x-B0nEBR0k.mjs.map +1 -0
- package/dist/{migration-check-CueEJelQ-J81XR_ns.mjs → migration-check-DONPyXff-CGTUpLv-.mjs} +12 -254
- package/dist/migration-check-DONPyXff-CGTUpLv-.mjs.map +1 -0
- package/dist/{migration-command-scaffold-DNRo4exb-9JCezdoT.mjs → migration-command-scaffold-BPqXPCFV-Bls2Wwg7.mjs} +4 -4
- package/dist/{migration-command-scaffold-DNRo4exb-9JCezdoT.mjs.map → migration-command-scaffold-BPqXPCFV-Bls2Wwg7.mjs.map} +1 -1
- package/dist/{migration-graph-D6bN-mX0-DwMWY8DA.mjs → migration-graph-DDaOHo10-yJFAbKCu.mjs} +3 -3
- package/dist/{migration-graph-D6bN-mX0-DwMWY8DA.mjs.map → migration-graph-DDaOHo10-yJFAbKCu.mjs.map} +1 -1
- package/dist/{migration-graph-BL6vfLcE.mjs → migration-graph-Dn469b0l.mjs} +10 -19
- package/dist/migration-graph-Dn469b0l.mjs.map +1 -0
- package/dist/migration-graph-HKch1Xk4-DyWhXtjZ.mjs +35 -0
- package/dist/migration-graph-HKch1Xk4-DyWhXtjZ.mjs.map +1 -0
- package/dist/migration-list-C9OPCMt--C28yBgVr.mjs +102 -0
- package/dist/migration-list-C9OPCMt--C28yBgVr.mjs.map +1 -0
- package/dist/migration-list-jk4iCtmO.mjs +120 -0
- package/dist/migration-list-jk4iCtmO.mjs.map +1 -0
- package/dist/{migration-log-BXbz6-Lj-CKHbat5f.mjs → migration-log-DQzUBrm8-D3m9wcuf.mjs} +7 -5
- package/dist/migration-log-DQzUBrm8-D3m9wcuf.mjs.map +1 -0
- package/dist/migration-new-BkSY6m0t.mjs +50 -0
- package/dist/migration-new-BkSY6m0t.mjs.map +1 -0
- package/dist/{migration-new-szZFsA3C.mjs → migration-new-g98oB3nC-BcrkxAAt.mjs} +12 -52
- package/dist/migration-new-g98oB3nC-BcrkxAAt.mjs.map +1 -0
- package/dist/{migration-path-target-BPYp3LNc-qRQlG_Yn.mjs → migration-path-target-BPYp3LNc-DsDdLU0J.mjs} +2 -2
- package/dist/{migration-path-target-BPYp3LNc-qRQlG_Yn.mjs.map → migration-path-target-BPYp3LNc-DsDdLU0J.mjs.map} +1 -1
- package/dist/migration-plan-BsOYRogP-CC1UFAbu.d.mts +159 -0
- package/dist/migration-plan-BsOYRogP-CC1UFAbu.d.mts.map +1 -0
- package/dist/migration-plan-CjIYMJZy.mjs +172 -0
- package/dist/migration-plan-CjIYMJZy.mjs.map +1 -0
- package/dist/{migration-plan-CxXAXYc8-Dnp-v8Nl.mjs → migration-plan-CwuZLXVE-DAJ-JUQT.mjs} +45 -183
- package/dist/migration-plan-CwuZLXVE-DAJ-JUQT.mjs.map +1 -0
- package/dist/{migration-show-BKsIh7Uz.mjs → migration-show-CW6EKtfw.mjs} +13 -9
- package/dist/migration-show-CW6EKtfw.mjs.map +1 -0
- package/dist/{migration-status-CNnRInne--cvmx56T.mjs → migration-status-DSQcBhiN.mjs} +37 -68
- package/dist/migration-status-DSQcBhiN.mjs.map +1 -0
- package/dist/migration-tools.d.mts +4 -4
- package/dist/migration-tools.mjs +13 -13
- package/dist/migration-tools__aggregate.mjs +1 -1
- package/dist/migration-tools__contract-snapshot-store.mjs +1 -1
- package/dist/migration-tools__errors.d.mts +2 -2
- package/dist/migration-tools__errors.mjs +2 -2
- package/dist/migration-tools__invariants.mjs +1 -1
- package/dist/migration-tools__io.mjs +1 -1
- package/dist/migration-tools__migration-graph.mjs +2 -2
- package/dist/migration-tools__migration.mjs +1 -1
- package/dist/migration-tools__ref-resolution.mjs +1 -1
- package/dist/migration-tools__refs.mjs +1 -1
- package/dist/migration-tools__spaces.mjs +2 -2
- package/dist/{project-import-root-C_bd0ooL-CLXW-gp6.mjs → project-import-root-C_bd0ooL-WkbJLnAA.mjs} +2 -2
- package/dist/{project-import-root-C_bd0ooL-CLXW-gp6.mjs.map → project-import-root-C_bd0ooL-WkbJLnAA.mjs.map} +1 -1
- package/dist/ref-DSAZime8.mjs +72 -0
- package/dist/ref-DSAZime8.mjs.map +1 -0
- package/dist/ref-advancement-DaZBzm7m-BZQtedYC.mjs +96 -0
- package/dist/ref-advancement-DaZBzm7m-BZQtedYC.mjs.map +1 -0
- package/dist/ref-eJjxzYTh-CNiyDL4p.mjs +109 -0
- package/dist/ref-eJjxzYTh-CNiyDL4p.mjs.map +1 -0
- package/dist/{ref-resolution-BsdziDFA.mjs → ref-resolution-Ct2GMcNB.mjs} +2 -2
- package/dist/{ref-resolution-BsdziDFA.mjs.map → ref-resolution-Ct2GMcNB.mjs.map} +1 -1
- package/dist/ref-resolution-_S4xTT2L-BE5zgO2W.mjs +16 -0
- package/dist/ref-resolution-_S4xTT2L-BE5zgO2W.mjs.map +1 -0
- package/dist/{refs-DtoeUivZ-qay0UMSP.mjs → refs-B2BL8z3i-DGGFB7Mj.mjs} +3 -3
- package/dist/{refs-DtoeUivZ-qay0UMSP.mjs.map → refs-B2BL8z3i-DGGFB7Mj.mjs.map} +1 -1
- package/dist/refs-fQLFcMoq-UTlvnijY.mjs +47 -0
- package/dist/refs-fQLFcMoq-UTlvnijY.mjs.map +1 -0
- package/dist/{spaces-BNd2Tlk0.mjs → spaces-DxuvClN9.mjs} +6 -6
- package/dist/{spaces-BNd2Tlk0.mjs.map → spaces-DxuvClN9.mjs.map} +1 -1
- package/dist/{telemetry-DVBHDQd6-BEdoMii0.mjs → telemetry-DVBHDQd6-Ckn5oClN.mjs} +2 -2
- package/dist/{telemetry-DVBHDQd6-BEdoMii0.mjs.map → telemetry-DVBHDQd6-Ckn5oClN.mjs.map} +1 -1
- package/dist/{verify-C6L_hiJU-CN3eEe3Y.mjs → verify-C6L_hiJU-B4V3bqvG.mjs} +2 -2
- package/dist/{verify-C6L_hiJU-CN3eEe3Y.mjs.map → verify-C6L_hiJU-B4V3bqvG.mjs.map} +1 -1
- package/dist/{verify-contract-spaces-Ak73-zQK-y4qVyu-y.mjs → verify-contract-spaces-WvjSiWcB-zGhaCnfs.mjs} +4 -4
- package/dist/{verify-contract-spaces-Ak73-zQK-y4qVyu-y.mjs.map → verify-contract-spaces-WvjSiWcB-zGhaCnfs.mjs.map} +1 -1
- package/dist/vite-plugin-contract-emit.mjs +1 -1
- package/package.json +12 -12
- package/dist/config-loader.d.mts.map +0 -1
- package/dist/contract-at-errors-YdCQ5OOk-okxG7Eaj.mjs.map +0 -1
- package/dist/contract-space-aggregate-loader-CziO_ZRW-DIoQOL0P.mjs.map +0 -1
- package/dist/db-init-CXMcvoIA.mjs.map +0 -1
- package/dist/db-sign-xV_rpoIc.mjs.map +0 -1
- package/dist/db-update-DXa2DIvu.mjs.map +0 -1
- package/dist/errors-AkMBj-YP.d.mts.map +0 -1
- package/dist/migrate-COusRrm7.mjs.map +0 -1
- package/dist/migration-check-CueEJelQ-J81XR_ns.mjs.map +0 -1
- package/dist/migration-graph-BL6vfLcE.mjs.map +0 -1
- package/dist/migration-list-D2_JdzWC-MRHYYVQE.mjs +0 -228
- package/dist/migration-list-D2_JdzWC-MRHYYVQE.mjs.map +0 -1
- package/dist/migration-log-BXbz6-Lj-CKHbat5f.mjs.map +0 -1
- package/dist/migration-new-szZFsA3C.mjs.map +0 -1
- package/dist/migration-plan-CxXAXYc8-Dnp-v8Nl.mjs.map +0 -1
- package/dist/migration-show-BKsIh7Uz.mjs.map +0 -1
- package/dist/migration-status-CNnRInne--cvmx56T.mjs.map +0 -1
- package/dist/ref-DjZ5Y8ju.mjs +0 -171
- package/dist/ref-DjZ5Y8ju.mjs.map +0 -1
- package/dist/ref-advancement-CSPMoQs3-CPkL3IFF.mjs +0 -57
- package/dist/ref-advancement-CSPMoQs3-CPkL3IFF.mjs.map +0 -1
- package/dist/types-2n_H3DQ9-Bks8UPEO.d.mts.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"migration-check-CueEJelQ-J81XR_ns.mjs","names":[],"sources":["../../../../1-framework/3-tooling/cli/dist/migration-check-CueEJelQ.mjs"],"sourcesContent":["import { A as formatStyledHeader, K as errorInvalidSpaceId, L as errorAmbiguousMigrationRef, _ as createTerminalUI, at as errorSpaceNotFound, b as formatErrorJson, d as setCommandSeeAlso, g as parseGlobalFlagsOrExit, l as setCommandDescriptions, lt as mapRefResolutionError, o as resolveContractPath, s as resolveMigrationPaths, t as addGlobalOptions, u as setCommandExamples, x as formatErrorOutput } from \"./command-helpers-C4WpR-QE.mjs\";\nimport { n as buildReadAggregate, s as toDeclaredExtensionsFromRaw } from \"./contract-space-aggregate-loader-CziO_ZRW.mjs\";\nimport { i as resolveTargetPathAcrossSpaces, n as looksLikePath, r as resolveAppTargetPath, t as findPackageByDirPath } from \"./migration-path-target-BPYp3LNc.mjs\";\nimport \"./schemas-KhXMzNA_.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 { join, relative } from \"pathe\";\nimport { readFile } from \"node:fs/promises\";\nimport { createControlStack } from \"@internal/framework-components/control\";\nimport { existsSync, readdirSync, statSync } from \"node:fs\";\nimport { isValidSpaceId, listContractSpaceDirectories, spaceMigrationDirectory, spaceRefsDirectory } from \"@internal/migration-tools/spaces\";\nimport { loadContractSpaceAggregate } from \"@internal/migration-tools/aggregate\";\nimport { EMPTY_CONTRACT_HASH } from \"@internal/migration-tools/constants\";\nimport { MigrationToolsError } from \"@internal/migration-tools/errors\";\nimport { contractSnapshotDir, readContractSnapshotJson } from \"@internal/migration-tools/contract-snapshot-store\";\nimport { parseMigrationRef } from \"@internal/migration-tools/ref-resolution\";\nimport { verifyMigrationHash } from \"@internal/migration-tools/hash\";\n//#region src/utils/integrity-violation-to-check-failure.ts\nfunction migrationPathRelative$1(dirPath) {\n\treturn relative(process.cwd(), dirPath);\n}\nfunction migrationFileRelative$1(dirPath, fileName) {\n\treturn join(migrationPathRelative$1(dirPath), fileName);\n}\n/**\n* Map one {@link IntegrityViolation} onto a `migration check` failure row.\n* Sole catalogue mapping from integrity violations to `MIGRATION.CHECK_*` codes.\n*/\nfunction integrityViolationToCheckFailure(violation, migrationsDir) {\n\tconst spaceRelative = (spaceId) => migrationPathRelative$1(join(migrationsDir, spaceId));\n\tconst packageRelative = (spaceId, dirName) => migrationPathRelative$1(join(migrationsDir, spaceId, dirName));\n\tconst refRelative = (spaceId, refName) => migrationPathRelative$1(join(migrationsDir, spaceId, \"refs\", `${refName}.json`));\n\tswitch (violation.kind) {\n\t\tcase \"hashMismatch\": return {\n\t\t\tspace: violation.spaceId,\n\t\t\tcode: \"MIGRATION.CHECK_HASH_MISMATCH\",\n\t\t\twhere: migrationFileRelative$1(join(migrationsDir, violation.spaceId, violation.dirName), \"migration.json\"),\n\t\t\twhy: `Stored hash ${violation.stored} does not match recomputed hash ${violation.computed}`,\n\t\t\tfix: \"Re-emit the migration package or restore from version control.\"\n\t\t};\n\t\tcase \"providedInvariantsMismatch\": return {\n\t\t\tspace: violation.spaceId,\n\t\t\tcode: \"MIGRATION.CHECK_PROVIDED_INVARIANTS_MISMATCH\",\n\t\t\twhere: packageRelative(violation.spaceId, violation.dirName),\n\t\t\twhy: `Migration \"${violation.dirName}\" providedInvariants in migration.json disagrees with ops.json.`,\n\t\t\tfix: \"Re-emit the migration package so migration.json and ops.json agree.\"\n\t\t};\n\t\tcase \"packageUnloadable\": return {\n\t\t\tspace: violation.spaceId,\n\t\t\tcode: \"MIGRATION.CHECK_PACKAGE_UNLOADABLE\",\n\t\t\twhere: packageRelative(violation.spaceId, violation.dirName),\n\t\t\twhy: `Migration \"${violation.dirName}\" could not be loaded: ${violation.detail}`,\n\t\t\tfix: \"Re-emit the migration package or restore from version control.\"\n\t\t};\n\t\tcase \"sameSourceAndTarget\": return {\n\t\t\tspace: violation.spaceId,\n\t\t\tcode: \"MIGRATION.CHECK_NOOP_SELF_EDGE\",\n\t\t\twhere: packageRelative(violation.spaceId, violation.dirName),\n\t\t\twhy: `Migration \"${violation.dirName}\" in space \"${violation.spaceId}\" has source equal to target (${violation.hash}) with no data invariant — a true no-op self-edge.`,\n\t\t\tfix: \"Add a data operation if this self-edge was meant to carry a data invariant, or delete the migration if it is a true no-op.\"\n\t\t};\n\t\tcase \"orphanSpaceDir\": return {\n\t\t\tspace: violation.spaceId,\n\t\t\tcode: \"MIGRATION.CHECK_ORPHAN_SPACE_DIR\",\n\t\t\twhere: spaceRelative(violation.spaceId),\n\t\t\twhy: `Contract-space directory \"${violation.spaceId}\" exists on disk but no extension declares it.`,\n\t\t\tfix: \"Remove the orphan directory, or declare the extension in `extensions`.\"\n\t\t};\n\t\tcase \"declaredButUnmigrated\": return {\n\t\t\tspace: violation.spaceId,\n\t\t\tcode: \"MIGRATION.CHECK_DECLARED_BUT_UNMIGRATED\",\n\t\t\twhere: spaceRelative(violation.spaceId),\n\t\t\twhy: `Extension \"${violation.spaceId}\" is declared in \\`extensions\\` but has no on-disk migrations directory.`,\n\t\t\tfix: \"Re-emit the extension contract-space artefacts with `prisma-next contract emit` and migration planning, or remove the extension from `extensions` if it is unused.\"\n\t\t};\n\t\tcase \"headRefMissing\": return {\n\t\t\tspace: violation.spaceId,\n\t\t\tcode: \"MIGRATION.CHECK_HEAD_REF_MISSING\",\n\t\t\twhere: refRelative(violation.spaceId, \"head\"),\n\t\t\twhy: `Head ref \\`refs/head.json\\` is missing for contract space \"${violation.spaceId}\".`,\n\t\t\tfix: \"Re-emit the contract-space migrations and head ref artefacts, or restore `refs/head.json` from version control.\"\n\t\t};\n\t\tcase \"headRefNotInGraph\": return {\n\t\t\tspace: violation.spaceId,\n\t\t\tcode: \"MIGRATION.CHECK_HEAD_REF_NOT_IN_GRAPH\",\n\t\t\twhere: refRelative(violation.spaceId, \"head\"),\n\t\t\twhy: `Head ref ${violation.hash} for contract space \"${violation.spaceId}\" is not present in its migration graph.`,\n\t\t\tfix: \"Re-emit the contract space migrations, or restore the missing migration package.\"\n\t\t};\n\t\tcase \"refUnreadable\": return {\n\t\t\tspace: violation.spaceId,\n\t\t\tcode: \"MIGRATION.CHECK_REF_UNREADABLE\",\n\t\t\twhere: refRelative(violation.spaceId, violation.refName),\n\t\t\twhy: `Ref \"${violation.refName}\" for contract space \"${violation.spaceId}\" is unreadable: ${violation.detail}`,\n\t\t\tfix: \"Repair or remove the corrupt ref file.\"\n\t\t};\n\t\tcase \"targetMismatch\": return {\n\t\t\tspace: violation.spaceId,\n\t\t\tcode: \"MIGRATION.CHECK_TARGET_MISMATCH\",\n\t\t\twhere: spaceRelative(violation.spaceId),\n\t\t\twhy: `Contract space \"${violation.spaceId}\" targets \"${violation.actual}\" but the project targets \"${violation.expected}\".`,\n\t\t\tfix: \"Update the extension to target the configured database, or change the project target.\"\n\t\t};\n\t\tcase \"disjointness\": return {\n\t\t\tspace: \"app\",\n\t\t\tcode: \"MIGRATION.CHECK_SPACE_DISJOINTNESS_VIOLATION\",\n\t\t\twhere: migrationPathRelative$1(migrationsDir),\n\t\t\twhy: `Storage element \"${violation.element}\" is claimed by multiple contract spaces: ${violation.claimedBy.join(\", \")}.`,\n\t\t\tfix: \"Update the contracts so each storage element is owned by exactly one contract space.\"\n\t\t};\n\t\tcase \"contractUnreadable\": return {\n\t\t\tspace: violation.spaceId,\n\t\t\tcode: \"MIGRATION.CHECK_CONTRACT_UNREADABLE\",\n\t\t\twhere: migrationFileRelative$1(join(migrationsDir, violation.spaceId), \"contract.json\"),\n\t\t\twhy: `Contract for space \"${violation.spaceId}\" is unreadable: ${violation.detail}`,\n\t\t\tfix: \"Re-emit the extension contract artefacts, or fix the descriptor producing the invalid contract.\"\n\t\t};\n\t\tcase \"duplicateMigrationHash\": return {\n\t\t\tspace: violation.spaceId,\n\t\t\tcode: \"MIGRATION.CHECK_DUPLICATE_MIGRATION_HASH\",\n\t\t\twhere: spaceRelative(violation.spaceId),\n\t\t\twhy: `Multiple migrations in space \"${violation.spaceId}\" share migrationHash \"${violation.migrationHash}\" (${violation.dirNames.join(\", \")}).`,\n\t\t\tfix: \"Re-emit one of the conflicting packages so each migrationHash is unique.\"\n\t\t};\n\t}\n}\n//#endregion\n//#region src/commands/migration-check.ts\nfunction migrationPathRelative(dirPath) {\n\treturn relative(process.cwd(), dirPath);\n}\nfunction migrationFileRelative(dirPath, fileName) {\n\treturn join(migrationPathRelative(dirPath), fileName);\n}\nfunction checkFileExists(spaceId, dirPath, dirName, fileName) {\n\tif (!existsSync(join(dirPath, fileName))) return {\n\t\tspace: spaceId,\n\t\tcode: \"MIGRATION.CHECK_FILE_MISSING\",\n\t\twhere: migrationFileRelative(dirPath, fileName),\n\t\twhy: `${fileName} is missing from ${dirName}`,\n\t\tfix: \"Re-emit the migration package or restore from version control.\"\n\t};\n\treturn null;\n}\n/**\n* Snapshot-store consistency check for one migration package (D6.5):\n* absent store entry is not an issue (runner independence, ADR 199 — a\n* package dir with only `migration.json` + `ops.json` is legitimate); a\n* present entry whose inner `storage.storageHash` disagrees with\n* `pkg.metadata.to` is `MIGRATION.CHECK_SNAPSHOT_HASH_MISMATCH`; an unparseable store\n* entry (or a malformed `to`) is `MIGRATION.CHECK_SNAPSHOT_UNPARSEABLE`.\n*/\nasync function checkSnapshotConsistency(spaceId, pkg, migrationsDir) {\n\tlet snapshotDir;\n\ttry {\n\t\tsnapshotDir = contractSnapshotDir(migrationsDir, pkg.metadata.to);\n\t} catch {\n\t\treturn {\n\t\t\tspace: spaceId,\n\t\t\tcode: \"MIGRATION.CHECK_SNAPSHOT_UNPARSEABLE\",\n\t\t\twhere: migrationPathRelative(pkg.dirPath),\n\t\t\twhy: `Migration \"${pkg.dirName}\" declares to=\"${pkg.metadata.to}\", which is not a well-formed contract snapshot hash.`,\n\t\t\tfix: \"Re-emit the migration package so migration.json declares a valid 64-hex to-hash.\"\n\t\t};\n\t}\n\tlet raw;\n\ttry {\n\t\traw = await readContractSnapshotJson(migrationsDir, pkg.metadata.to);\n\t} catch (error) {\n\t\tif (MigrationToolsError.is(error) && error.code === \"MIGRATION.CONTRACT_SNAPSHOT_MISSING\") return null;\n\t\treturn {\n\t\t\tspace: spaceId,\n\t\t\tcode: \"MIGRATION.CHECK_SNAPSHOT_UNPARSEABLE\",\n\t\t\twhere: migrationPathRelative(pkg.dirPath),\n\t\t\twhy: `Migration \"${pkg.dirName}\" has an unparseable contract snapshot at ${snapshotDir}/contract.json.`,\n\t\t\tfix: \"Restore migrations/snapshots/ from version control, or re-run the command that produced this migration to regenerate its snapshot.\"\n\t\t};\n\t}\n\tconst snapshotHash = (raw !== null && typeof raw === \"object\" ? raw : {})[\"storage\"]?.[\"storageHash\"];\n\tif (typeof snapshotHash === \"string\" && snapshotHash !== pkg.metadata.to) return {\n\t\tspace: spaceId,\n\t\tcode: \"MIGRATION.CHECK_SNAPSHOT_HASH_MISMATCH\",\n\t\twhere: migrationPathRelative(pkg.dirPath),\n\t\twhy: `Migration \"${pkg.dirName}\" declares to=${pkg.metadata.to} but its contract snapshot has storageHash=${snapshotHash}`,\n\t\tfix: \"Re-emit the migration package so migration.json and its contract snapshot agree.\"\n\t};\n\treturn null;\n}\n/**\n* Project the loaded {@link ContractSpaceAggregate} into the\n* {@link CheckSpace} rows the multi-space check iterates — one per on-disk\n* contract-space directory, in the aggregate's `app`-first ordering. Mirrors\n* `migration list`'s `migrationSpaceListEntriesFromAggregate`: space\n* membership matches the on-disk directories, package / ref / graph data come\n* from `aggregate.space(id)`.\n*/\nasync function enumerateCheckSpaces(aggregate, projectMigrationsDir) {\n\tconst candidateDirs = await listContractSpaceDirectories(projectMigrationsDir);\n\tconst onDiskSpaceIds = new Set(candidateDirs.filter(isValidSpaceId));\n\tconst spaces = [];\n\tfor (const space of aggregate.spaces()) {\n\t\tconst spaceId = space.spaceId;\n\t\tif (!isValidSpaceId(spaceId)) continue;\n\t\tif (!onDiskSpaceIds.has(spaceId)) continue;\n\t\tconst migrationsDir = spaceMigrationDirectory(projectMigrationsDir, spaceId);\n\t\tspaces.push({\n\t\t\tspaceId,\n\t\t\tpackages: space.packages,\n\t\t\trefs: space.refs,\n\t\t\tgraph: space.graph(),\n\t\t\tmigrationsDir,\n\t\t\trefsDir: spaceRefsDirectory(migrationsDir),\n\t\t\tprojectMigrationsDir\n\t\t});\n\t}\n\treturn spaces;\n}\nfunction checkManifestFilesPresent(space) {\n\tif (!existsSync(space.migrationsDir)) return [];\n\tconst loadedDirNames = new Set(space.packages.map((p) => p.dirName));\n\tconst failures = [];\n\tlet entries;\n\ttry {\n\t\tentries = readdirSync(space.migrationsDir);\n\t} catch {\n\t\treturn failures;\n\t}\n\tfor (const entry of entries) {\n\t\tif (entry.startsWith(\".\") || entry.startsWith(\"_\") || entry === \"refs\") continue;\n\t\tconst entryPath = join(space.migrationsDir, entry);\n\t\ttry {\n\t\t\tif (!statSync(entryPath).isDirectory()) continue;\n\t\t} catch {\n\t\t\tcontinue;\n\t\t}\n\t\tif (!loadedDirNames.has(entry)) for (const f of [\"migration.json\", \"ops.json\"]) {\n\t\t\tconst fail = checkFileExists(space.spaceId, entryPath, entry, f);\n\t\t\tif (fail) failures.push(fail);\n\t\t}\n\t}\n\treturn failures;\n}\nfunction checkReachability(space) {\n\tconst allToHashes = new Set(space.packages.map((p) => p.metadata.to));\n\tconst failures = [];\n\tfor (const pkg of space.packages) if (!(pkg.metadata.from === null || allToHashes.has(pkg.metadata.from) || pkg.metadata.from === EMPTY_CONTRACT_HASH)) failures.push({\n\t\tspace: space.spaceId,\n\t\tcode: \"MIGRATION.CHECK_UNREACHABLE_MIGRATION\",\n\t\twhere: migrationPathRelative(pkg.dirPath),\n\t\twhy: `Migration \"${pkg.dirName}\" starts from ${pkg.metadata.from} which no other migration produces`,\n\t\tfix: \"This migration is unreachable in the graph. Delete it or re-emit a connecting migration.\"\n\t});\n\treturn failures;\n}\nfunction checkDanglingRefs(space) {\n\tconst failures = [];\n\tfor (const [name, entry] of Object.entries(space.refs)) if (!space.graph.nodes.has(entry.hash)) failures.push({\n\t\tspace: space.spaceId,\n\t\tcode: \"MIGRATION.CHECK_DANGLING_REF\",\n\t\twhere: relative(process.cwd(), join(space.refsDir, `${name}.json`)),\n\t\twhy: `Ref \"${name}\" points at ${entry.hash} which does not exist in the migration graph`,\n\t\tfix: `Update the ref with \\`prisma-next ref set ${name} <valid-hash>\\` or delete it.`\n\t});\n\treturn failures;\n}\nasync function checkSpace(space) {\n\tconst snapshotFailures = await Promise.all(space.packages.map((pkg) => checkSnapshotConsistency(space.spaceId, pkg, space.projectMigrationsDir)));\n\treturn [\n\t\t...checkManifestFilesPresent(space),\n\t\t...snapshotFailures.filter((f) => f !== null),\n\t\t...checkReachability(space),\n\t\t...checkDanglingRefs(space)\n\t];\n}\n/**\n* Policy core of the holistic `migration check`: validates `--space`,\n* narrows the pre-enumerated spaces, and runs the per-space explicit graph\n* checks (file-existence, snapshot consistency, reachability, dangling\n* refs), aggregating every failure into one {@link MigrationCheckResult}.\n*\n* `--space` validation mirrors `migration list`: an invalid id →\n* {@link errorInvalidSpaceId}; an id with no on-disk space →\n* {@link errorSpaceNotFound}. Both map to exit `PRECONDITION` at the shell.\n* Aggregate-integrity violations (which already span every space) are folded\n* in by the caller, not here.\n*/\nasync function runMigrationCheck(inputs) {\n\tconst { spaces, spaceFilter } = inputs;\n\tif (spaceFilter !== void 0 && !isValidSpaceId(spaceFilter)) return notOk(errorInvalidSpaceId(spaceFilter));\n\tif (spaceFilter !== void 0 && !spaces.some((s) => s.spaceId === spaceFilter)) return notOk(errorSpaceNotFound(spaceFilter, spaces.map((s) => s.spaceId).sort()));\n\tconst scopedSpaces = spaceFilter !== void 0 ? spaces.filter((s) => s.spaceId === spaceFilter) : spaces;\n\tconst failures = (await Promise.all(scopedSpaces.map(checkSpace))).flat();\n\tif (failures.length === 0) return ok({\n\t\tok: true,\n\t\tfailures: [],\n\t\tsummary: \"All checks passed\"\n\t});\n\treturn ok({\n\t\tok: false,\n\t\tfailures,\n\t\tsummary: `${failures.length} integrity failure(s)`\n\t});\n}\nasync function loadAggregateIntegrityViolations(config, migrationsDir) {\n\ttry {\n\t\tconst contractJsonContent = await readFile(resolveContractPath(config), \"utf-8\");\n\t\tconst familyInstance = config.family.create(createControlStack(config));\n\t\tconst declaredExtensions = toDeclaredExtensionsFromRaw(config.extensions ?? []);\n\t\tconst parsedAppContract = JSON.parse(contractJsonContent);\n\t\treturn (await loadContractSpaceAggregate({\n\t\t\tmigrationsDir,\n\t\t\tdeserializeContract: (json) => familyInstance.deserializeContract(json),\n\t\t\tappContract: familyInstance.deserializeContract(parsedAppContract)\n\t\t})).checkIntegrity({\n\t\t\tdeclaredExtensions,\n\t\t\tcheckContracts: true\n\t\t});\n\t} catch {\n\t\treturn [];\n\t}\n}\nasync function executeMigrationCheckCommand(target, options, flags, ui) {\n\tconst config = await loadConfig(options.config);\n\tconst { configPath, migrationsDir, appMigrationsDir, appMigrationsRelative } = resolveMigrationPaths(options.config, config);\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: \"migrations\",\n\t\t\tvalue: appMigrationsRelative\n\t\t}];\n\t\tif (target) details.push({\n\t\t\tlabel: \"target\",\n\t\t\tvalue: target\n\t\t});\n\t\tconst header = formatStyledHeader({\n\t\t\tcommand: \"migration check\",\n\t\t\tdescription: \"Verify artifact and graph integrity\",\n\t\t\tdetails,\n\t\t\tflags\n\t\t});\n\t\tui.stderr(header);\n\t}\n\tconst loadedAggregate = await buildReadAggregate(config, { migrationsDir });\n\tif (!loadedAggregate.ok) return {\n\t\terror: loadedAggregate.failure,\n\t\texitCode: 2\n\t};\n\tconst spaces = await enumerateCheckSpaces(loadedAggregate.value.aggregate, migrationsDir);\n\tif (target) return await checkSingleTarget(target, {\n\t\tspaces,\n\t\t...options.space !== void 0 ? { spaceFilter: options.space } : {},\n\t\tappMigrationsDir,\n\t\tappMigrationsRelative\n\t});\n\tconst checkResult = await runMigrationCheck({\n\t\tspaces,\n\t\t...options.space !== void 0 ? { spaceFilter: options.space } : {}\n\t});\n\tif (!checkResult.ok) return {\n\t\terror: checkResult.failure,\n\t\texitCode: 2\n\t};\n\tconst failures = [...checkResult.value.failures];\n\tconst allViolations = await loadAggregateIntegrityViolations(config, migrationsDir);\n\tconst scopedViolations = options.space === void 0 ? allViolations : allViolations.filter((v) => v.kind !== \"disjointness\" && v.spaceId === options.space);\n\tfor (const violation of scopedViolations) failures.push(integrityViolationToCheckFailure(violation, migrationsDir));\n\tif (failures.length === 0) return {\n\t\tresult: {\n\t\t\tok: true,\n\t\t\tfailures: [],\n\t\t\tsummary: \"All checks passed\"\n\t\t},\n\t\texitCode: 0\n\t};\n\treturn {\n\t\tresult: {\n\t\t\tok: false,\n\t\t\tfailures,\n\t\t\tsummary: `${failures.length} integrity failure(s)`\n\t\t},\n\t\texitCode: 4\n\t};\n}\n/**\n* Ranks ref-resolution failure kinds by how informative they are, so a\n* single-target check surfaces the most useful failure across spaces instead of\n* whichever space failed first. `not-found` (the input matched nothing here)\n* says the least; a malformed input, a wrong grammar, or an in-space ambiguity\n* all say more.\n*/\nfunction refFailureSpecificity(error) {\n\tswitch (error.kind) {\n\t\tcase \"wrong-grammar\": return 3;\n\t\tcase \"ambiguous\": return 2;\n\t\tcase \"invalid-format\": return 1;\n\t\tcase \"not-found\": return 0;\n\t}\n}\n/**\n* Single-target (`check <ref/path>`) mode — resolves a migration reference\n* across all contract spaces (or the one space narrowed by `--space <id>`).\n*\n* Resolution:\n* - filesystem path → find the owning space by checking which space's\n* `migrationsDir` contains the resolved path; falls back to app-relative\n* validation when the path is outside every space dir.\n* - ref → `parseMigrationRef` against each in-scope space; collect every\n* (space, package) hit; 0 hits = not-found, 1 = check it, >1 = ambiguity\n* error (qualify with `--space`).\n*\n* `--space <id>` is validated the same way the holistic path does it:\n* invalid id → `errorInvalidSpaceId`; no on-disk space → `errorSpaceNotFound`.\n*/\nasync function checkSingleTarget(target, inputs) {\n\tconst { spaces, spaceFilter, appMigrationsDir, appMigrationsRelative } = inputs;\n\tif (spaceFilter !== void 0 && !isValidSpaceId(spaceFilter)) return {\n\t\terror: errorInvalidSpaceId(spaceFilter),\n\t\texitCode: 2\n\t};\n\tif (spaceFilter !== void 0 && !spaces.some((s) => s.spaceId === spaceFilter)) return {\n\t\terror: errorSpaceNotFound(spaceFilter, spaces.map((s) => s.spaceId).sort()),\n\t\texitCode: 2\n\t};\n\tconst scopedSpaces = spaceFilter !== void 0 ? spaces.filter((s) => s.spaceId === spaceFilter) : spaces;\n\tlet matchedSpace;\n\tlet matchedPkg;\n\tif (looksLikePath(target)) {\n\t\tconst resolvedPath = resolveTargetPathAcrossSpaces(target, scopedSpaces);\n\t\tif (resolvedPath !== null) for (const space of scopedSpaces) {\n\t\t\tconst found = findPackageByDirPath(space.packages, resolvedPath);\n\t\t\tif (found) {\n\t\t\t\tmatchedSpace = space;\n\t\t\t\tmatchedPkg = found;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\tconst resolved = resolveAppTargetPath(target, appMigrationsDir, appMigrationsRelative);\n\t\t\tif (!resolved.ok) return {\n\t\t\t\terror: resolved.failure,\n\t\t\t\texitCode: 2\n\t\t\t};\n\t\t\tconst appSpace = scopedSpaces.find((s) => s.spaceId === \"app\");\n\t\t\tif (appSpace) {\n\t\t\t\tmatchedSpace = appSpace;\n\t\t\t\tmatchedPkg = findPackageByDirPath(appSpace.packages, resolved.value);\n\t\t\t}\n\t\t}\n\t} else {\n\t\tconst hits = [];\n\t\tlet bestParseFailure;\n\t\tfor (const space of scopedSpaces) {\n\t\t\tconst migResult = parseMigrationRef(target, {\n\t\t\t\tgraph: space.graph,\n\t\t\t\trefs: space.refs\n\t\t\t});\n\t\t\tif (!migResult.ok) {\n\t\t\t\tif (bestParseFailure === void 0 || refFailureSpecificity(migResult.failure) > refFailureSpecificity(bestParseFailure)) bestParseFailure = migResult.failure;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst pkg = space.packages.find((p) => p.metadata.migrationHash === migResult.value.migrationHash);\n\t\t\tif (pkg) hits.push({\n\t\t\t\tspace,\n\t\t\t\tpkg\n\t\t\t});\n\t\t}\n\t\tif (hits.length > 1) return {\n\t\t\terror: errorAmbiguousMigrationRef(target, hits.map((h) => h.space.spaceId)),\n\t\t\texitCode: 2\n\t\t};\n\t\tif (hits.length === 1) {\n\t\t\tmatchedSpace = hits[0].space;\n\t\t\tmatchedPkg = hits[0].pkg;\n\t\t} else if (bestParseFailure !== void 0) return {\n\t\t\terror: mapRefResolutionError(bestParseFailure),\n\t\t\texitCode: 2\n\t\t};\n\t}\n\tif (!matchedPkg || !matchedSpace) return {\n\t\tresult: {\n\t\t\tok: false,\n\t\t\tfailures: [],\n\t\t\tsummary: `Migration package for \"${target}\" not found on disk`\n\t\t},\n\t\texitCode: 2\n\t};\n\tconst failures = [...checkManifestFilesPresent(matchedSpace)];\n\tfor (const f of [\"migration.json\", \"ops.json\"]) {\n\t\tconst fail = checkFileExists(matchedSpace.spaceId, matchedPkg.dirPath, matchedPkg.dirName, f);\n\t\tif (fail) failures.push(fail);\n\t}\n\tconst verification = verifyMigrationHash(matchedPkg);\n\tif (!verification.ok) failures.push({\n\t\tspace: matchedSpace.spaceId,\n\t\tcode: \"MIGRATION.CHECK_HASH_MISMATCH\",\n\t\twhere: migrationFileRelative(matchedPkg.dirPath, \"migration.json\"),\n\t\twhy: `Stored hash ${verification.storedHash} does not match recomputed hash ${verification.computedHash}`,\n\t\tfix: \"Re-emit the migration package or restore from version control.\"\n\t});\n\tconst snapshotFailure = await checkSnapshotConsistency(matchedSpace.spaceId, matchedPkg, matchedSpace.projectMigrationsDir);\n\tif (snapshotFailure) failures.push(snapshotFailure);\n\tconst resolvedSpaceId = matchedSpace.spaceId !== \"app\" ? matchedSpace.spaceId : void 0;\n\tif (failures.length === 0) return {\n\t\tresult: {\n\t\t\tok: true,\n\t\t\tfailures: [],\n\t\t\tsummary: \"All checks passed\"\n\t\t},\n\t\texitCode: 0,\n\t\t...ifDefined(\"resolvedSpaceId\", resolvedSpaceId)\n\t};\n\treturn {\n\t\tresult: {\n\t\t\tok: false,\n\t\t\tfailures,\n\t\t\tsummary: `${failures.length} integrity failure(s)`\n\t\t},\n\t\texitCode: 4,\n\t\t...ifDefined(\"resolvedSpaceId\", resolvedSpaceId)\n\t};\n}\nfunction createMigrationCheckCommand() {\n\tconst command = new Command(\"check\");\n\tsetCommandDescriptions(command, \"Verify artifact and graph integrity\", \"Validates that on-disk migration packages are internally consistent\\n(hashes match, manifests are complete) and that the graph is well-formed\\n(edges connect, refs point at valid nodes). The whole-graph check spans\\nevery contract space by default; pass --space <id> to narrow to one. A\\nmigration reference checks a single package, resolved across all contract\\nspaces (narrow with --space; an ambiguous reference is a precondition failure).\\nOffline — does not consult the database.\\nExit codes: 0 = all checks passed, 2 = precondition failed\\n(unresolved target or unknown --space), 4 = integrity failure(s) found.\");\n\tsetCommandExamples(command, [\n\t\t\"prisma-next migration check\",\n\t\t\"prisma-next migration check --space app\",\n\t\t\"prisma-next migration check 20260101-add-users\",\n\t\t\"prisma-next migration check 20260101-add-users --space app\",\n\t\t\"prisma-next migration check --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 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\tcommand.exitOverride();\n\taddGlobalOptions(command).argument(\"[target]\", \"Migration reference: directory name, hash/prefix, ref, or path\").option(\"--config <path>\", \"Path to prisma-next.config.ts\").option(\"--space <id>\", \"Narrow output to a single contract space\").action(async (target, options) => {\n\t\tconst flags = parseGlobalFlagsOrExit(options);\n\t\tconst ui = createTerminalUI(flags);\n\t\tlet outcome;\n\t\ttry {\n\t\t\toutcome = await executeMigrationCheckCommand(target, options, flags, ui);\n\t\t} catch (error) {\n\t\t\toutcome = {\n\t\t\t\tresult: {\n\t\t\t\t\tok: false,\n\t\t\t\t\tfailures: [],\n\t\t\t\t\tsummary: error instanceof Error ? error.message : String(error)\n\t\t\t\t},\n\t\t\t\texitCode: 2\n\t\t\t};\n\t\t}\n\t\tif (outcome.error) {\n\t\t\tconst envelope = outcome.error.toEnvelope();\n\t\t\tif (flags.json) ui.output(formatErrorJson(envelope));\n\t\t\telse if (!flags.quiet) ui.error(formatErrorOutput(envelope, flags));\n\t\t\tprocess.exit(outcome.exitCode);\n\t\t}\n\t\tconst result = outcome.result ?? {\n\t\t\tok: false,\n\t\t\tfailures: [],\n\t\t\tsummary: \"No check result produced\"\n\t\t};\n\t\tif (flags.json) ui.output(JSON.stringify(result, null, 2));\n\t\telse if (!flags.quiet) if (result.ok) {\n\t\t\tconst spaceSuffix = outcome.resolvedSpaceId !== void 0 ? ` (space: ${outcome.resolvedSpaceId})` : \"\";\n\t\t\tui.log(`✔ ${result.summary}${spaceSuffix}`);\n\t\t} else {\n\t\t\tfor (const f of result.failures) {\n\t\t\t\tui.log(`✗ [${f.code}] ${f.where}: ${f.why}`);\n\t\t\t\tui.log(` fix: ${f.fix}`);\n\t\t\t}\n\t\t\tui.log(`\\n${result.summary}`);\n\t\t}\n\t\tprocess.exit(outcome.exitCode);\n\t});\n\treturn command;\n}\n//#endregion\nexport { enumerateCheckSpaces as n, runMigrationCheck as r, createMigrationCheckCommand as t };\n\n//# sourceMappingURL=migration-check-CueEJelQ.mjs.map"],"mappings":";;;;;;;;;;;;;;;;;;;AAoBA,SAAS,wBAAwB,SAAS;CACzC,OAAO,SAAS,QAAQ,IAAI,GAAG,OAAO;AACvC;AACA,SAAS,wBAAwB,SAAS,UAAU;CACnD,OAAO,KAAK,wBAAwB,OAAO,GAAG,QAAQ;AACvD;;;;;AAKA,SAAS,iCAAiC,WAAW,eAAe;CACnE,MAAM,iBAAiB,YAAY,wBAAwB,KAAK,eAAe,OAAO,CAAC;CACvF,MAAM,mBAAmB,SAAS,YAAY,wBAAwB,KAAK,eAAe,SAAS,OAAO,CAAC;CAC3G,MAAM,eAAe,SAAS,YAAY,wBAAwB,KAAK,eAAe,SAAS,QAAQ,GAAG,QAAQ,MAAM,CAAC;CACzH,QAAQ,UAAU,MAAlB;EACC,KAAK,gBAAgB,OAAO;GAC3B,OAAO,UAAU;GACjB,MAAM;GACN,OAAO,wBAAwB,KAAK,eAAe,UAAU,SAAS,UAAU,OAAO,GAAG,gBAAgB;GAC1G,KAAK,eAAe,UAAU,OAAO,kCAAkC,UAAU;GACjF,KAAK;EACN;EACA,KAAK,8BAA8B,OAAO;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B,KAAK;GACnG,GAAG,IAAI,KAAK,OAAO,UAAU,aAAa;EAC3C,OAAO;GACN,KAAK,MAAM,KAAK,OAAO,UAAU;IAChC,GAAG,IAAI,MAAM,EAAE,KAAK,IAAI,EAAE,MAAM,IAAI,EAAE,KAAK;IAC3C,GAAG,IAAI,UAAU,EAAE,KAAK;GACzB;GACA,GAAG,IAAI,KAAK,OAAO,SAAS;EAC7B;EACA,QAAQ,KAAK,QAAQ,QAAQ;CAC9B,CAAC;CACD,OAAO;AACR"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"migration-graph-BL6vfLcE.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-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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AAM,QAAQ,YAAY,MAAM,gBAAgB,OAAO,GAAG;KAC9D,MAAM,OAAO,KAAK,KAAK,MAAM,GAAG,EAAE;KAClC,MAAM,KAAK,KAAK,GAAG,MAAM,GAAG,EAAE;KAC9B,MAAM,KAAK,MAAM,KAAK,QAAQ,GAAG,YAAY,KAAK,QAAQ,IAAI;IAC/D;IACA,MAAM,KAAK,GAAG;IACd,GAAG,OAAO,MAAM,KAAK,IAAI,CAAC;GAC3B,OAAO,IAAI,MAAM,MAAM;IACtB,MAAM,aAAa;KAClB,IAAI;KACJ,QAAQ,CAAC,GAAG,YAAY,MAAM;KAC9B,SAAS,YAAY;IACtB;IACA,GAAG,OAAO,KAAK,UAAU,YAAY,MAAM,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,228 +0,0 @@
|
|
|
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
|
-
import { r as loadConfig } from "./exports-CDX9kZuw.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
|
-
import { g as renderMigrationGraphLegend, l as createAnsiMigrationListStyler, v as renderMigrationListWithStyle } from "./migration-graph-command-render-BKrg6BPv-BP8Pfj4J.mjs";
|
|
7
|
-
import { ifDefined } from "@prisma/orm-framework/utils/defined";
|
|
8
|
-
import { notOk, ok } from "@prisma/orm-framework/utils/result";
|
|
9
|
-
import { Command } from "commander";
|
|
10
|
-
//#region ../../../1-framework/3-tooling/cli/dist/migration-list-D2_JdzWC.mjs
|
|
11
|
-
/**
|
|
12
|
-
* The legend is decoration printed alongside the command header on stderr, so
|
|
13
|
-
* it is suppressed for the machine-readable / silent paths (`--json`, `--dot`,
|
|
14
|
-
* `--quiet`) exactly as the header is.
|
|
15
|
-
*/
|
|
16
|
-
function shouldShowLegend(options, flags) {
|
|
17
|
-
return options.legend === true && options.dot !== true && flags.json !== true && flags.quiet !== true;
|
|
18
|
-
}
|
|
19
|
-
function validateLegendOptions(options, flags) {
|
|
20
|
-
if (options.legend !== true) return ok(void 0);
|
|
21
|
-
if (flags.json === true) return notOk(errorLegendHumanOnly("--json"));
|
|
22
|
-
if (flags.quiet === true) return notOk(errorLegendHumanOnly("--quiet"));
|
|
23
|
-
if (options.dot === true) return notOk(errorLegendHumanOnly("--dot"));
|
|
24
|
-
return ok(void 0);
|
|
25
|
-
}
|
|
26
|
-
function compareSpaceIds(a, b) {
|
|
27
|
-
if (a === APP_SPACE_ID) return b === APP_SPACE_ID ? 0 : -1;
|
|
28
|
-
if (b === APP_SPACE_ID) return 1;
|
|
29
|
-
if (a < b) return -1;
|
|
30
|
-
if (a > b) return 1;
|
|
31
|
-
return 0;
|
|
32
|
-
}
|
|
33
|
-
function compareDirNamesDescending(a, b) {
|
|
34
|
-
if (a.name < b.name) return 1;
|
|
35
|
-
if (a.name > b.name) return -1;
|
|
36
|
-
return 0;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Ref names decorating a space's destination contract hashes. The
|
|
40
|
-
* tolerant `space.refs` deliberately omits the structural `head.json`;
|
|
41
|
-
* for extension spaces the old enumerator surfaced it as a `head`
|
|
42
|
-
* decoration on the tip migration, so fold `space.headRef` back in to
|
|
43
|
-
* keep that output. The app space synthesises its head, so it carries
|
|
44
|
-
* no on-disk `head` ref to restore.
|
|
45
|
-
*/
|
|
46
|
-
function listRefsByContractHash(space) {
|
|
47
|
-
const byHash = new Map(refsByContractHash(space.refs));
|
|
48
|
-
if (space.spaceId !== APP_SPACE_ID && space.headRef !== null) {
|
|
49
|
-
const hash = space.headRef.hash;
|
|
50
|
-
const bucket = byHash.get(hash) ?? [];
|
|
51
|
-
if (!bucket.includes("head")) byHash.set(hash, [...bucket, HEAD_REF_NAME].sort());
|
|
52
|
-
}
|
|
53
|
-
return byHash;
|
|
54
|
-
}
|
|
55
|
-
async function orderedOnDiskSpaceIds(projectMigrationsDir) {
|
|
56
|
-
return (await listContractSpaceDirectories(projectMigrationsDir)).filter(isValidSpaceId).sort(compareSpaceIds);
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Project the loaded {@link ContractSpaceAggregate} into the render-ready
|
|
60
|
-
* {@link MigrationSpaceListEntry} rows `migration list` displays.
|
|
61
|
-
*
|
|
62
|
-
* Space membership matches the on-disk contract-space directories (not the
|
|
63
|
-
* aggregate's always-present synthesized app space when `migrations/app/`
|
|
64
|
-
* is absent); package and ref data come from `aggregate.space(id)`.
|
|
65
|
-
*/
|
|
66
|
-
async function migrationSpaceListEntriesFromAggregate(aggregate, projectMigrationsDir) {
|
|
67
|
-
const spaceIds = await orderedOnDiskSpaceIds(projectMigrationsDir);
|
|
68
|
-
const spaces = [];
|
|
69
|
-
for (const spaceId of spaceIds) {
|
|
70
|
-
const space = aggregate.space(spaceId);
|
|
71
|
-
if (space === void 0) continue;
|
|
72
|
-
const refsByHash = listRefsByContractHash(space);
|
|
73
|
-
const migrations = space.packages.map((pkg) => ({
|
|
74
|
-
name: pkg.dirName,
|
|
75
|
-
hash: pkg.metadata.migrationHash,
|
|
76
|
-
fromContract: pkg.metadata.from,
|
|
77
|
-
toContract: pkg.metadata.to,
|
|
78
|
-
operationCount: pkg.ops.length,
|
|
79
|
-
createdAt: pkg.metadata.createdAt,
|
|
80
|
-
refs: [...refsByHash.get(pkg.metadata.to) ?? []],
|
|
81
|
-
providedInvariants: [...pkg.metadata.providedInvariants]
|
|
82
|
-
})).sort(compareDirNamesDescending);
|
|
83
|
-
spaces.push({
|
|
84
|
-
space: spaceId,
|
|
85
|
-
migrations
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
return spaces;
|
|
89
|
-
}
|
|
90
|
-
function renderMigrationListHumanOutput(result, options) {
|
|
91
|
-
return renderMigrationListWithStyle(result, createAnsiMigrationListStyler({ useColor: options.useColor }), options.glyphMode, {
|
|
92
|
-
colorize: options.useColor,
|
|
93
|
-
liveContractHash: options.liveContractHash,
|
|
94
|
-
graphForSpace: options.graphForSpace,
|
|
95
|
-
...options.appSpaceId !== void 0 ? { appSpaceId: options.appSpaceId } : {}
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
function computeSummary(spaces) {
|
|
99
|
-
const totalMigrations = spaces.reduce((count, space) => count + space.migrations.length, 0);
|
|
100
|
-
if (spaces.length <= 1) return `${totalMigrations} migration(s) on disk`;
|
|
101
|
-
return `${totalMigrations} migration(s) across ${spaces.length} contract space(s)`;
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* Policy core of `migration list`: validates `--space`, narrows the
|
|
105
|
-
* pre-enumerated spaces, and assembles a {@link MigrationListResult}.
|
|
106
|
-
*
|
|
107
|
-
* - `migrations/` missing or contains no valid space directories →
|
|
108
|
-
* caller passes `spaces: []`; this synthesizes `[{ spaceId: APP_SPACE_ID, migrations: [] }]`.
|
|
109
|
-
* - `--space <id>` on an existing-but-empty space → `{ spaceId, migrations: [] }` in the input.
|
|
110
|
-
* - `--space <id>` on a non-existent (or reserved) space → `SPACE_NOT_FOUND`.
|
|
111
|
-
*/
|
|
112
|
-
function runMigrationList(inputs) {
|
|
113
|
-
const { spaces, spaceFilter } = inputs;
|
|
114
|
-
if (spaceFilter !== void 0 && !isValidSpaceId(spaceFilter)) return notOk(errorInvalidSpaceId(spaceFilter));
|
|
115
|
-
if (spaceFilter !== void 0 && !spaces.some((s) => s.space === spaceFilter)) return notOk(errorSpaceNotFound(spaceFilter, spaces.map((s) => s.space).sort()));
|
|
116
|
-
const scopedSpaces = spaceFilter !== void 0 ? spaces.filter((s) => s.space === spaceFilter) : spaces;
|
|
117
|
-
const resultSpaces = scopedSpaces.length === 0 ? [{
|
|
118
|
-
space: APP_SPACE_ID,
|
|
119
|
-
migrations: []
|
|
120
|
-
}] : scopedSpaces;
|
|
121
|
-
return ok({
|
|
122
|
-
ok: true,
|
|
123
|
-
spaces: [...resultSpaces],
|
|
124
|
-
summary: computeSummary(resultSpaces)
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
/**
|
|
128
|
-
* CLI shell: loads config, resolves paths, prints the styled header on
|
|
129
|
-
* stderr (interactive mode only), and delegates to {@link runMigrationList}.
|
|
130
|
-
* Kept intentionally thin so the unit-testable surface lives in the core.
|
|
131
|
-
*/
|
|
132
|
-
async function executeMigrationListCommand(options, flags, ui) {
|
|
133
|
-
const config = await loadConfig(options.config);
|
|
134
|
-
const { configPath, migrationsDir, migrationsRelative } = resolveMigrationPaths(options.config, config);
|
|
135
|
-
if (!flags.json && !flags.quiet) {
|
|
136
|
-
const header = formatStyledHeader({
|
|
137
|
-
command: "migration list",
|
|
138
|
-
description: "List on-disk migrations per contract space",
|
|
139
|
-
details: [
|
|
140
|
-
{
|
|
141
|
-
label: "config",
|
|
142
|
-
value: configPath
|
|
143
|
-
},
|
|
144
|
-
{
|
|
145
|
-
label: "migrations",
|
|
146
|
-
value: migrationsRelative
|
|
147
|
-
},
|
|
148
|
-
...options.space !== void 0 ? [{
|
|
149
|
-
label: "space",
|
|
150
|
-
value: options.space
|
|
151
|
-
}] : []
|
|
152
|
-
],
|
|
153
|
-
flags
|
|
154
|
-
});
|
|
155
|
-
ui.stderr(header);
|
|
156
|
-
if (shouldShowLegend(options, flags)) {
|
|
157
|
-
ui.stderr(renderMigrationGraphLegend({
|
|
158
|
-
colorize: flags.color !== false,
|
|
159
|
-
glyphMode: ui.resolveGlyphMode(options.ascii === true)
|
|
160
|
-
}));
|
|
161
|
-
ui.stderr("");
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
const loaded = await buildReadAggregate(config, { migrationsDir });
|
|
165
|
-
if (!loaded.ok) return notOk(loaded.failure);
|
|
166
|
-
const { aggregate, contractHash: liveContractHash } = loaded.value;
|
|
167
|
-
const listResult = runMigrationList({
|
|
168
|
-
spaces: await migrationSpaceListEntriesFromAggregate(aggregate, migrationsDir),
|
|
169
|
-
...ifDefined("spaceFilter", options.space)
|
|
170
|
-
});
|
|
171
|
-
if (!listResult.ok) return listResult;
|
|
172
|
-
return ok({
|
|
173
|
-
list: listResult.value,
|
|
174
|
-
liveContractHash,
|
|
175
|
-
aggregate
|
|
176
|
-
});
|
|
177
|
-
}
|
|
178
|
-
function createMigrationListCommand() {
|
|
179
|
-
const command = new Command("list");
|
|
180
|
-
setCommandDescriptions(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).");
|
|
181
|
-
setCommandExamples(command, [
|
|
182
|
-
"prisma-next migration list",
|
|
183
|
-
"prisma-next migration list --space app",
|
|
184
|
-
"prisma-next migration list --ascii",
|
|
185
|
-
"prisma-next migration list --legend",
|
|
186
|
-
"prisma-next migration list --json"
|
|
187
|
-
]);
|
|
188
|
-
setCommandSeeAlso(command, [
|
|
189
|
-
{
|
|
190
|
-
verb: "migration status",
|
|
191
|
-
oneLiner: "Show migration path and pending status"
|
|
192
|
-
},
|
|
193
|
-
{
|
|
194
|
-
verb: "migration log",
|
|
195
|
-
oneLiner: "Show executed migration history"
|
|
196
|
-
},
|
|
197
|
-
{
|
|
198
|
-
verb: "migration graph",
|
|
199
|
-
oneLiner: "Show the migration graph topology"
|
|
200
|
-
},
|
|
201
|
-
{
|
|
202
|
-
verb: "migration show",
|
|
203
|
-
oneLiner: "Display migration package contents"
|
|
204
|
-
}
|
|
205
|
-
]);
|
|
206
|
-
addGlobalOptions(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) => {
|
|
207
|
-
const flags = parseGlobalFlagsOrExit(options);
|
|
208
|
-
const ui = createTerminalUI(flags);
|
|
209
|
-
const legendValidation = validateLegendOptions(options, flags);
|
|
210
|
-
if (!legendValidation.ok) process.exit(handleResult(legendValidation, flags, ui));
|
|
211
|
-
const exitCode = handleResult(await executeMigrationListCommand(options, flags, ui), flags, ui, ({ list, liveContractHash, aggregate }) => {
|
|
212
|
-
if (flags.json) ui.output(JSON.stringify(list, null, 2));
|
|
213
|
-
else if (!flags.quiet) ui.output(renderMigrationListHumanOutput(list, {
|
|
214
|
-
glyphMode: ui.resolveGlyphMode(options.ascii === true),
|
|
215
|
-
useColor: ui.useColor,
|
|
216
|
-
liveContractHash,
|
|
217
|
-
graphForSpace: (spaceId) => aggregate.space(spaceId)?.graph(),
|
|
218
|
-
appSpaceId: aggregate.app.spaceId
|
|
219
|
-
}));
|
|
220
|
-
});
|
|
221
|
-
process.exit(exitCode);
|
|
222
|
-
});
|
|
223
|
-
return command;
|
|
224
|
-
}
|
|
225
|
-
//#endregion
|
|
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
|
-
|
|
228
|
-
//# sourceMappingURL=migration-list-D2_JdzWC-MRHYYVQE.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
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,MAAM,OAAO;CAC5B,OAAO;AACR;;;;;;;;;AASA,SAAS,uBAAuB,OAAO;CACtC,MAAM,SAAS,IAAI,IAAI,mBAAmB,MAAM,IAAI,C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,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 +0,0 @@
|
|
|
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,OAAO,OAAO,KAAK,CAAC,CAAC,SAAS,GAAG,GAAG;AACrC;AACA,SAAS,sBAAsB,MAAM,MAAM;CAC1C,IAAI,SAAS,OAAO,OAAO,KAAK,YAAY;CAC5C,IAAI,SAAS,OAAO,OAAO,GAAG,KAAK,eAAe,EAAE,GAAG,KAAK,KAAK,YAAY,IAAI,CAAC,EAAE,GAAG,KAAK,KAAK,WAAW,CAAC,EAAE,GAAG,KAAK,KAAK,YAAY,CAAC,EAAE,GAAG,KAAK,KAAK,cAAc,CAAC,EAAE,GAAG,KAAK,KAAK,cAAc,CAAC,EAAE;CACvM,MAAM,gBAAgB,CAAC,KAAK,kBAAkB;CAC9C,MAAM,OAAO,iBAAiB,IAAI,MAAM;CACxC,MAAM,iBAAiB,KAAK,IAAI,aAAa;CAC7C,MAAM,cAAc,KAAK,KAAK,MAAM,iBAAiB,EAAE,CAAC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AAkB,SAAS;EAC1B;GACC,MAAM;GACN,UAAU;EACX;EACA;GACC,MAAM;GACN,UAAU;EACX;EACA;GACC,MAAM;GACN,UAAU;EACX;EACA;GACC,MAAM;GACN,UAAU;EACX;CACD,CAAC;CACD,iBAAiB,OAAO,CAAC,CAAC,OAAO,cAAc,4BAA4B,CAAC,CAAC,OAAO,mBAAmB,+BAA+B,CAAC,CAAC,OAAO,SAAS,sDAAsD,CAAC,CAAC,OAAO,WAAW,kCAAkC,CAAC,CAAC,OAAO,OAAO,YAAY;EAC/R,MAAM,QAAQ,uBAAuB,OAAO;EAC5C,MAAM,KAAK,iBAAiB,KAAK;EACjC,MAAM,WAAW,aAAa,MAAM,2BAA2B,SAAS,OAAO,EAAE,GAAG,OAAO,KAAK,YAAY;GAC3G,IAAI,MAAM,MAAM;IACf,MAAM,UAAU,8BAA8B,OAAO;IACrD,MAAM,SAAS;KACd,IAAI;KACJ;KACA,SAAS,GAAG,QAAQ,OAAO;IAC5B;IACA,GAAG,OAAO,KAAK,UAAU,QAAQ,MAAM,CAAC,CAAC;GAC1C,OAAO,IAAI,CAAC,MAAM,OAAO,IAAI,QAAQ,WAAW,GAAG,GAAG,OAAO,2BAA2B;QACnF;IACJ,MAAM,SAAS,8BAA8B,EAAE,UAAU,GAAG,SAAS,CAAC;IACtE,GAAG,OAAO,wBAAwB,SAAS;KAC1C,KAAK,QAAQ,QAAQ;KACrB;KACA,WAAW,GAAG,iBAAiB,QAAQ,UAAU,IAAI;IACtD,CAAC,CAAC;GACH;EACD,CAAC;EACD,QAAQ,KAAK,QAAQ;CACtB,CAAC;CACD,OAAO;AACR"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"migration-new-szZFsA3C.mjs","names":["errorRuntime","CliStructuredError"],"sources":["../../../../1-framework/3-tooling/cli/dist/commands/migration-new.mjs"],"sourcesContent":["import { A as formatStyledHeader, F as CliStructuredError, _ as createTerminalUI, ct as errorUnexpected, g as parseGlobalFlagsOrExit, l as setCommandDescriptions, o as resolveContractPath, ot as errorTargetMigrationNotSupported, r as getTargetMigrations, rt as errorRuntime, s as resolveMigrationPaths, t as addGlobalOptions, u as setCommandExamples, y as handleResult } from \"../command-helpers-C4WpR-QE.mjs\";\nimport { t as assertFrameworkComponentsCompatible } from \"../framework-components-3DdB31mk.mjs\";\nimport { t as createProjectSpecifierResolver } from \"../project-import-root-C_bd0ooL.mjs\";\nimport { o as refusePackageCorruptionOnAggregate } from \"../contract-space-aggregate-loader-CziO_ZRW.mjs\";\nimport { Command } from \"commander\";\nimport { loadConfig } from \"@internal/config-loader\";\nimport { getEmittedArtifactPaths } from \"@internal/emitter\";\nimport { notOk, ok } from \"@internal/utils/result\";\nimport { join, relative } from \"pathe\";\nimport { readFile } from \"node:fs/promises\";\nimport { APP_SPACE_ID, createControlStack } from \"@internal/framework-components/control\";\nimport { loadContractSpaceAggregate } from \"@internal/migration-tools/aggregate\";\nimport { findLatestMigration } from \"@internal/migration-tools/migration-graph\";\nimport { contractSnapshotDir, snapshotsImportPathFrom, writeContractSnapshot } from \"@internal/migration-tools/contract-snapshot-store\";\nimport { computeMigrationHash } from \"@internal/migration-tools/hash\";\nimport { formatMigrationDirName, writeMigrationPackage } from \"@internal/migration-tools/io\";\nimport { writeMigrationTs } from \"@internal/migration-tools/migration-ts\";\n//#region src/commands/migration-new.ts\n/**\n* `migration new` — scaffolds a migration package with a `migration.ts` file\n* for manual authoring.\n*\n* The planner's `emptyMigration(context)` returns a\n* `MigrationPlanWithAuthoringSurface`, whose `renderTypeScript(resolver)`\n* produces the target-appropriate empty stub. The CLI writes the returned\n* source verbatim.\n*\n* The resolver is the one this project's own manifest implies, so the\n* scaffold names packages the project can resolve — the same resolver\n* `contract emit` hands to the emitter (ADR 242).\n*/\nasync function executeMigrationNewCommand(options) {\n\tconst config = await loadConfig(options.config);\n\tconst { migrationsDir, appMigrationsDir, appMigrationsRelative } = resolveMigrationPaths(options.config, config);\n\tconst stack = createControlStack(config);\n\tconst familyInstance = config.family.create(stack);\n\tconst controlAdapter = config.adapter.create(stack);\n\tconst contractPathAbsolute = resolveContractPath(config);\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(errorRuntime(\"CLI.FILE_NOT_FOUND\", `Contract file not found at ${contractPathAbsolute}`, {\n\t\t\twhy: `Contract file not found at ${contractPathAbsolute}`,\n\t\t\tfix: \"Run `prisma-next contract emit` first to generate the contract\"\n\t\t}));\n\t\tthrow error;\n\t}\n\tlet toContract;\n\ttry {\n\t\tconst parsedContract = JSON.parse(contractJsonContent);\n\t\ttoContract = familyInstance.deserializeContract(parsedContract);\n\t} catch (error) {\n\t\treturn notOk(errorRuntime(\"MIGRATION.CONTRACT_DESERIALIZATION_FAILED\", \"Contract JSON is invalid\", {\n\t\t\twhy: `Failed to deserialize ${contractPathAbsolute}: ${error instanceof Error ? error.message : String(error)}`,\n\t\t\tfix: \"Run `prisma-next contract emit` to regenerate the contract\",\n\t\t\tcause: error\n\t\t}));\n\t}\n\tconst toStorageHash = toContract.storage?.storageHash;\n\tif (typeof toStorageHash !== \"string\") return notOk(errorRuntime(\"CONTRACT.VALIDATION_FAILED\", \"Contract is missing storageHash\", {\n\t\twhy: `Contract at ${contractPathAbsolute} has no storageHash`,\n\t\tfix: \"Run `prisma-next contract emit` to regenerate the contract\"\n\t}));\n\tconst aggregate = await loadContractSpaceAggregate({\n\t\tmigrationsDir,\n\t\tdeserializeContract: (json) => familyInstance.deserializeContract(json),\n\t\tappContract: toContract\n\t});\n\tconst packageCorruptionFailure = refusePackageCorruptionOnAggregate(aggregate);\n\tif (packageCorruptionFailure) return notOk(packageCorruptionFailure);\n\tconst packages = aggregate.app.packages;\n\tconst graph = aggregate.app.graph();\n\tlet fromHash = null;\n\tif (packages.length > 0) if (options.from) {\n\t\tconst match = packages.find((p) => p.metadata.to.startsWith(options.from));\n\t\tif (!match) return notOk(errorRuntime(\"MIGRATION.HASH_NOT_IN_GRAPH\", \"Starting contract not found\", {\n\t\t\twhy: `No migration with to hash matching \"${options.from}\" exists in ${appMigrationsRelative}`,\n\t\t\tfix: \"Check that the --from hash matches a known migration target hash.\"\n\t\t}));\n\t\tfromHash = match.metadata.to;\n\t} else {\n\t\tconst latestMigration = findLatestMigration(graph);\n\t\tif (latestMigration) fromHash = latestMigration.to;\n\t}\n\tif (fromHash === toStorageHash && !options.from) return notOk(errorRuntime(\"MIGRATION.NO_CHANGES\", \"No changes detected\", {\n\t\twhy: \"The from and to contract hashes are identical — there is nothing to migrate.\",\n\t\tfix: \"Change the contract and run `prisma-next contract emit` before creating a new migration. To author a data-only migration on the current contract hash, pass `--from <hash>` explicitly.\"\n\t}));\n\tconst timestamp = /* @__PURE__ */ new Date();\n\tconst packageDir = join(appMigrationsDir, formatMigrationDirName(timestamp, options.name ?? \"migration\"));\n\tconst baseMetadata = {\n\t\tfrom: fromHash,\n\t\tto: toStorageHash,\n\t\tprovidedInvariants: [],\n\t\tcreatedAt: timestamp.toISOString()\n\t};\n\tconst metadata = {\n\t\t...baseMetadata,\n\t\tmigrationHash: computeMigrationHash(baseMetadata, [])\n\t};\n\tconst migrations = getTargetMigrations(config.target);\n\tif (!migrations) return notOk(errorTargetMigrationNotSupported({ why: `Target \"${config.target.targetId}\" does not support migrations` }));\n\ttry {\n\t\tassertFrameworkComponentsCompatible(config.family.familyId, config.target.targetId, [\n\t\t\tconfig.target,\n\t\t\tconfig.adapter,\n\t\t\t...config.extensions ?? []\n\t\t]);\n\t\tconst resolveSpecifier = createProjectSpecifierResolver(options.config);\n\t\tawait writeMigrationPackage(packageDir, metadata, []);\n\t\tconst destinationArtifacts = getEmittedArtifactPaths(contractPathAbsolute);\n\t\tconst [contractJsonRaw, contractDts] = await Promise.all([readFile(destinationArtifacts.jsonPath, \"utf-8\"), readFile(destinationArtifacts.dtsPath, \"utf-8\")]);\n\t\tawait writeContractSnapshot(migrationsDir, toStorageHash, {\n\t\t\tcontractJson: JSON.parse(contractJsonRaw),\n\t\t\tcontractDts\n\t\t});\n\t\tawait writeMigrationTs(packageDir, migrations.createPlanner(controlAdapter).emptyMigration({\n\t\t\tpackageDir,\n\t\t\tcontractJsonPath: join(contractSnapshotDir(migrationsDir, toStorageHash), \"contract.json\"),\n\t\t\tfromHash,\n\t\t\ttoHash: toStorageHash,\n\t\t\tsnapshotsImportPath: snapshotsImportPathFrom(packageDir, migrationsDir)\n\t\t}, APP_SPACE_ID).renderTypeScript(resolveSpecifier));\n\t\treturn ok({\n\t\t\tok: true,\n\t\t\tdir: relative(process.cwd(), packageDir),\n\t\t\tfrom: fromHash,\n\t\t\tto: toStorageHash,\n\t\t\tsummary: `Scaffolded migration at ${relative(process.cwd(), packageDir)}`\n\t\t});\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 scaffold migration: ${error instanceof Error ? error.message : String(error)}` }));\n\t}\n}\nfunction createMigrationNewCommand() {\n\tconst command = new Command(\"new\");\n\tsetCommandDescriptions(command, \"Scaffold a new migration for manual authoring\", \"Creates a migration package with a migration.ts file for manual authoring.\\nWrite the migration body in migration.ts, then run the file with Node\\n(`node migration.ts`) to self-emit ops.json and attest the package.\");\n\tsetCommandExamples(command, [\"prisma-next migration new --name split-name\", \"prisma-next migration new --name custom-fk --from abc123...\"]);\n\taddGlobalOptions(command).option(\"--name <slug>\", \"Migration name (used in directory name)\").option(\"--from <hash>\", \"Starting contract hash (default: latest migration target)\").option(\"--config <path>\", \"Path to prisma-next.config.ts\").action(async (options) => {\n\t\tconst flags = parseGlobalFlagsOrExit(options);\n\t\tconst ui = createTerminalUI(flags);\n\t\tif (!flags.json && !flags.quiet) {\n\t\t\tconst header = formatStyledHeader({\n\t\t\t\tcommand: \"migration new\",\n\t\t\t\tdescription: \"Scaffold a new migration\",\n\t\t\t\tdetails: [],\n\t\t\t\tflags\n\t\t\t});\n\t\t\tui.stderr(header);\n\t\t}\n\t\tconst exitCode = handleResult(await executeMigrationNewCommand(options), flags, ui, (value) => {\n\t\t\tif (flags.json) ui.output(JSON.stringify(value, null, 2));\n\t\t\telse if (!flags.quiet) {\n\t\t\t\tui.output(`\\nScaffolded migration at ${value.dir}`);\n\t\t\t\tui.output(` from: ${value.from}`);\n\t\t\t\tui.output(` to: ${value.to}`);\n\t\t\t\tui.output(`\\nEdit migration.ts, then run it directly (\\`node \"${value.dir}/migration.ts\"\\`) to self-emit and attest.`);\n\t\t\t}\n\t\t});\n\t\tprocess.exit(exitCode);\n\t});\n\treturn command;\n}\n//#endregion\nexport { createMigrationNewCommand };\n\n//# sourceMappingURL=migration-new.mjs.map"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,eAAe,2BAA2B,SAAS;CAClD,MAAM,SAAS,MAAM,WAAW,QAAQ,MAAM;CAC9C,MAAM,EAAE,eAAe,kBAAkB,0BAA0B,sBAAsB,QAAQ,QAAQ,MAAM;CAC/G,MAAM,QAAQ,mBAAmB,MAAM;CACvC,MAAM,iBAAiB,OAAO,OAAO,OAAO,KAAK;CACjD,MAAM,iBAAiB,OAAO,QAAQ,OAAO,KAAK;CAClD,MAAM,uBAAuB,oBAAoB,MAAM;CACvD,IAAI;CACJ,IAAI;EACH,sBAAsB,MAAM,SAAS,sBAAsB,OAAO;CACnE,SAAS,OAAO;EACf,IAAI,iBAAiB,SAAS,MAAM,SAAS,UAAU,OAAO,MAAMA,eAAa,sBAAsB,8BAA8B,wBAAwB;GAC5J,KAAK,8BAA8B;GACnC,KAAK;EACN,CAAC,CAAC;EACF,MAAM;CACP;CACA,IAAI;CACJ,IAAI;EACH,MAAM,iBAAiB,KAAK,MAAM,mBAAmB;EACrD,aAAa,eAAe,oBAAoB,cAAc;CAC/D,SAAS,OAAO;EACf,OAAO,MAAMA,eAAa,6CAA6C,4BAA4B;GAClG,KAAK,yBAAyB,qBAAq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CAAC,CAAC;CACzL;AACD;AACA,SAAS,4BAA4B;CACpC,MAAM,UAAU,IAAI,QAAQ,KAAK;CACjC,uBAAuB,SAAS,iDAAiD,wNAAwN;CACzS,mBAAmB,SAAS,CAAC,+CAA+C,6DAA6D,CAAC;CAC1I,iBAAiB,OAAO,CAAC,CAAC,OAAO,iBAAiB,yCAAyC,CAAC,CAAC,OAAO,iBAAiB,2DAA2D,CAAC,CAAC,OAAO,mBAAmB,+BAA+B,CAAC,CAAC,OAAO,OAAO,YAAY;EACtQ,MAAM,QAAQ,uBAAuB,OAAO;EAC5C,MAAM,KAAK,iBAAiB,KAAK;EACjC,IAAI,CAAC,MAAM,QAAQ,CAAC,MAAM,OAAO;GAChC,MAAM,SAAS,mBAAmB;IACjC,SAAS;IACT,aAAa;IACb,SAAS,CAAC;IACV;GACD,CAAC;GACD,GAAG,OAAO,MAAM;EACjB;EACA,MAAM,WAAW,aAAa,MAAM,2BAA2B,OAAO,GAAG,OAAO,KAAK,UAAU;GAC9F,IAAI,MAAM,MAAM,GAAG,OAAO,KAAK,UAAU,OAAO,MAAM,CAAC,CAAC;QACnD,IAAI,CAAC,MAAM,OAAO;IACtB,GAAG,OAAO,6BAA6B,MAAM,KAAK;IAClD,GAAG,OAAO,WAAW,MAAM,MAAM;IACjC,GAAG,OAAO,WAAW,MAAM,IAAI;IAC/B,GAAG,OAAO,sDAAsD,MAAM,IAAI,2CAA2C;GACtH;EACD,CAAC;EACD,QAAQ,KAAK,QAAQ;CACtB,CAAC;CACD,OAAO;AACR"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"migration-plan-CxXAXYc8-Dnp-v8Nl.mjs","names":["CliStructuredError"],"sources":["../../../../1-framework/3-tooling/cli/dist/migration-plan-CxXAXYc8.mjs"],"sourcesContent":["import { A as formatStyledHeader, B as errorContractValidationFailed, F as CliStructuredError, Q as errorPlanForgotTheFlag, W as errorFileNotFound, X as errorMigrationPlanningFailed, _ as createTerminalUI, ct as errorUnexpected, g as parseGlobalFlagsOrExit, it as errorSnapshotMissing, l as setCommandDescriptions, lt as mapRefResolutionError, o as resolveContractPath, ot as errorTargetMigrationNotSupported, r as getTargetMigrations, s as resolveMigrationPaths, t as addGlobalOptions, u as setCommandExamples, y as handleResult } from \"./command-helpers-C4WpR-QE.mjs\";\nimport { t as assertFrameworkComponentsCompatible } from \"./framework-components-3DdB31mk.mjs\";\nimport { t as createProjectSpecifierResolver } from \"./project-import-root-C_bd0ooL.mjs\";\nimport { c as toExtensionInputs, i as loadContractSpaceAggregateForCli, t as buildContractSpaceAggregate } from \"./contract-space-aggregate-loader-CziO_ZRW.mjs\";\nimport { t as mapContractAtError } from \"./contract-at-errors-YdCQ5OOk.mjs\";\nimport { Command } from \"commander\";\nimport { loadConfig } from \"@internal/config-loader\";\nimport { getEmittedArtifactPaths } from \"@internal/emitter\";\nimport { notOk, ok } from \"@internal/utils/result\";\nimport { join, relative } from \"pathe\";\nimport { readFile } from \"node:fs/promises\";\nimport { createControlStack, hasOperationPreview } from \"@internal/framework-components/control\";\nimport { emitContractSpaceArtifacts, planAllSpaces, readContractSpaceHeadRef, spaceMigrationDirectory } from \"@internal/migration-tools/spaces\";\nimport { MigrationToolsError } from \"@internal/migration-tools/errors\";\nimport { assertHashIsGraphNode, findLatestMigration, isGraphNode } from \"@internal/migration-tools/migration-graph\";\nimport { snapshotsImportPathFrom, writeContractSnapshot } from \"@internal/migration-tools/contract-snapshot-store\";\nimport { parseContractRef } from \"@internal/migration-tools/ref-resolution\";\nimport { computeMigrationHash } from \"@internal/migration-tools/hash\";\nimport { formatMigrationDirName, materialiseExtensionMigrationPackageIfMissing, writeMigrationPackage } from \"@internal/migration-tools/io\";\nimport { writeMigrationTs } from \"@internal/migration-tools/migration-ts\";\nimport { deriveProvidedInvariants } from \"@internal/migration-tools/invariants\";\n//#region src/utils/contract-space-seed-phase.ts\n/**\n* Phase-1 of the two-phase `migration plan` pipeline (sub-spec § 4).\n*\n* For every extension that exposes a `contractSpace`:\n*\n* 1. Read the on-disk head ref (returns `null` on first emit).\n* 2. Write the head contract into the migrations-root snapshot store\n* (write-if-absent, keyed by hash) and unconditionally re-emit\n* `refs/head.json`, via {@link emitContractSpaceArtifacts}. The\n* framework owns `refs/head.json`; re-emit is the contract for that\n* file. The snapshot itself is only written once per distinct hash.\n* 3. Materialise any descriptor-shipped migration packages not yet on\n* disk via {@link materialiseExtensionMigrationPackageIfMissing}.\n* Existing packages are left untouched (by-existence skip).\n*\n* The return value lets the caller render a per-space status line and\n* lets the phase-2 aggregate loader run on a now-consistent disk state\n* (every loaded extension is guaranteed to have its head ref pinned\n* to the descriptor's hash and to ship every package the descriptor\n* declares).\n*\n* Output ordering is deterministic and alphabetical by spaceId (via\n* {@link planAllSpaces}, which also detects duplicate spaceIds). This\n* matches the canonical sort order used by every other aggregate\n* surface (`migrate`, `migration status`, the runner).\n*/\nasync function runContractSpaceSeedPhase(inputs) {\n\tconst planned = planAllSpaces(inputs.extensions.filter((pack) => pack.contractSpace !== void 0).map((pack) => ({\n\t\tspaceId: pack.id,\n\t\tpriorContract: null,\n\t\tnewContract: pack.contractSpace.contractJson,\n\t\t__pack: pack.contractSpace\n\t})), (input) => input.__pack.migrations);\n\tconst descriptorBySpace = /* @__PURE__ */ new Map();\n\tfor (const pack of inputs.extensions) if (pack.contractSpace !== void 0) descriptorBySpace.set(pack.id, pack.contractSpace);\n\tconst seeded = [];\n\tfor (const space of planned) {\n\t\tconst descriptor = descriptorBySpace.get(space.spaceId);\n\t\tif (descriptor === void 0) continue;\n\t\tconst priorHash = (await readContractSpaceHeadRef(inputs.migrationsDir, space.spaceId))?.hash ?? null;\n\t\tawait emitContractSpaceArtifacts(inputs.migrationsDir, space.spaceId, {\n\t\t\tcontract: descriptor.contractJson,\n\t\t\tcontractDts: buildPlaceholderContractDts(space.spaceId),\n\t\t\theadRef: {\n\t\t\t\thash: descriptor.headRef.hash,\n\t\t\t\tinvariants: descriptor.headRef.invariants\n\t\t\t}\n\t\t});\n\t\tconst spaceDir = spaceMigrationDirectory(inputs.migrationsDir, space.spaceId);\n\t\tconst newMigrationDirs = [];\n\t\tfor (const pkg of space.migrationPackages) {\n\t\t\tconst { written } = await materialiseExtensionMigrationPackageIfMissing(spaceDir, pkg);\n\t\t\tif (written) newMigrationDirs.push(pkg.dirName);\n\t\t}\n\t\tconst action = priorHash !== descriptor.headRef.hash || newMigrationDirs.length > 0 ? \"updated\" : \"unchanged\";\n\t\tseeded.push({\n\t\t\tspaceId: space.spaceId,\n\t\t\taction,\n\t\t\tpriorHash,\n\t\t\tnewHash: descriptor.headRef.hash,\n\t\t\tnewMigrationDirs\n\t\t});\n\t}\n\treturn { seeded };\n}\n/**\n* Placeholder `.d.ts` content for an extension space's on-disk mirror.\n*\n* Rendering a fully-typed `.d.ts` for an extension contract requires\n* the SQL-family renderer with the codec / typemap registry threaded\n* through; until that integration ships, the on-disk `.d.ts` is a\n* stub `export {};` module that documents how consumers should\n* validate the sibling `contract.json`. The stub typechecks on its\n* own and does not need any TypeScript suppressions.\n*/\nfunction buildPlaceholderContractDts(spaceId) {\n\treturn [\n\t\t\"/**\",\n\t\t` * Placeholder \\`.d.ts\\` for extension space \"${spaceId}\".`,\n\t\t\" *\",\n\t\t\" * The framework re-emits this file on every `migration plan` run\",\n\t\t\" * alongside `contract.json` and `refs/head.json`. A typed `.d.ts`\",\n\t\t\" * rendering pass for extension contracts is tracked separately;\",\n\t\t\" * until that ships, consumers should import `contract.json`\",\n\t\t\" * and pass it through the target descriptor’s `contractSerializer`.\",\n\t\t\" */\",\n\t\t\"export {};\",\n\t\t\"\"\n\t].join(\"\\n\");\n}\n//#endregion\n//#region src/utils/plan-resolution.ts\nconst FULL_HASH_PATTERN = /^([0-9a-f]{64}|empty)$/;\nfunction looksLikeFullHash(input) {\n\treturn FULL_HASH_PATTERN.test(input);\n}\nfunction graphIsEmpty(space) {\n\treturn space.packages.length === 0;\n}\nfunction getReachableRefs(refs, graph) {\n\treturn Object.entries(refs).flatMap(([name, entry]) => entry && isGraphNode(entry.hash, graph) ? [{\n\t\tname,\n\t\thash: entry.hash\n\t}] : []).sort((a, b) => a.name.localeCompare(b.name));\n}\nfunction assertFromIsGraphNode(fromHash, graph, refs, graphTipHash) {\n\ttry {\n\t\tassertHashIsGraphNode(fromHash, graph);\n\t} catch (error) {\n\t\tif (MigrationToolsError.is(error) && error.code === \"MIGRATION.HASH_NOT_IN_GRAPH\") throw errorPlanForgotTheFlag(fromHash, getReachableRefs(refs, graph), graphTipHash, { cause: error });\n\t\tthrow error;\n\t}\n}\nasync function resolveContractRef(parsed, space, options) {\n\tconst { hash, provenance } = parsed;\n\tconst refName = provenance.kind === \"ref\" ? provenance.refName : void 0;\n\ttry {\n\t\tconst at = await space.contractAt(hash, refName !== void 0 ? { refName } : void 0);\n\t\tif (at.provenance === \"ref\") return ok({\n\t\t\tkind: \"ref\",\n\t\t\thash: at.hash,\n\t\t\tcontract: at.contract,\n\t\t\tcontractJson: at.contractJson,\n\t\t\tcontractDts: at.contractDts\n\t\t});\n\t\treturn ok({\n\t\t\tkind: \"graph-node\",\n\t\t\thash: at.hash,\n\t\t\tcontract: at.contract,\n\t\t\tcontractJson: at.contractJson,\n\t\t\tcontractDts: at.contractDts\n\t\t});\n\t} catch (error) {\n\t\treturn mapContractAtError(error, options?.artifactRole !== void 0 ? { artifactRole: options.artifactRole } : void 0);\n\t}\n}\nasync function resolveFromPolicy(parsed, input, refs, explicitFromLabel) {\n\tconst resolution = await resolveContractRef(parsed, input.space, {\n\t\t...explicitFromLabel !== void 0 ? { explicitLabel: explicitFromLabel } : {},\n\t\tartifactRole: \"from\"\n\t});\n\tif (!resolution.ok) return resolution;\n\tif (resolution.value.kind === \"graph-node\") return ok({\n\t\tkind: \"graph-node\",\n\t\tfromHash: resolution.value.hash,\n\t\tfromContract: resolution.value.contract\n\t});\n\tconst { hash, contract, contractJson, contractDts } = resolution.value;\n\tif (graphIsEmpty(input.space)) return ok({\n\t\tkind: \"auto-baseline\",\n\t\tfromHash: hash,\n\t\tfromContract: contract,\n\t\tcontractDts,\n\t\tcontractJson\n\t});\n\tconst graph = input.space.graph();\n\tconst graphTip = findLatestMigration(graph)?.to ?? null;\n\ttry {\n\t\tassertFromIsGraphNode(hash, graph, refs, graphTip);\n\t} catch (error) {\n\t\tif (CliStructuredError.is(error)) return notOk(error);\n\t\tthrow error;\n\t}\n\treturn ok({\n\t\tkind: \"ref\",\n\t\tfromHash: hash,\n\t\tfromContract: contract,\n\t\tcontractDts,\n\t\tcontractJson\n\t});\n}\nasync function resolveFromForPlan(input) {\n\tconst { optionsFrom, space } = input;\n\tconst graph = space.graph();\n\tconst refs = space.refs;\n\tif (optionsFrom === void 0) {\n\t\tconst dbRef = refs[\"db\"];\n\t\tif (!dbRef) return ok({\n\t\t\tkind: \"greenfield\",\n\t\t\tfromHash: null,\n\t\t\tfromContract: null\n\t\t});\n\t\treturn resolveFromPolicy({\n\t\t\thash: dbRef.hash,\n\t\t\tprovenance: {\n\t\t\t\tkind: \"ref\",\n\t\t\t\trefName: \"db\"\n\t\t\t}\n\t\t}, input, refs);\n\t}\n\tconst refResult = parseContractRef(optionsFrom, {\n\t\tgraph,\n\t\trefs\n\t});\n\tif (!refResult.ok) {\n\t\tif (looksLikeFullHash(optionsFrom)) {\n\t\t\tconst empty = graphIsEmpty(space);\n\t\t\tconst graphTip = findLatestMigration(graph)?.to ?? null;\n\t\t\tif (empty) return notOk(errorSnapshotMissing(optionsFrom, { viaRef: false }));\n\t\t\treturn notOk(errorPlanForgotTheFlag(optionsFrom, getReachableRefs(refs, graph), graphTip));\n\t\t}\n\t\treturn notOk(mapRefResolutionError(refResult.failure));\n\t}\n\treturn resolveFromPolicy(refResult.value, input, refs, optionsFrom);\n}\nasync function resolveToForPlan(optionsTo, input) {\n\tconst { space } = input;\n\tconst graph = space.graph();\n\tconst refs = space.refs;\n\tconst refResult = parseContractRef(optionsTo, {\n\t\tgraph,\n\t\trefs\n\t});\n\tif (!refResult.ok) return notOk(mapRefResolutionError(refResult.failure));\n\tconst resolution = await resolveContractRef(refResult.value, space, {\n\t\texplicitLabel: optionsTo,\n\t\tartifactRole: \"to\"\n\t});\n\tif (!resolution.ok) return resolution;\n\tconst { hash, contract, contractJson, contractDts } = resolution.value;\n\treturn ok({\n\t\thash,\n\t\tcontract,\n\t\tcontractJson,\n\t\tcontractDts\n\t});\n}\n//#endregion\n//#region src/commands/migration-plan.ts\nasync function runPlannerLeg(planner, migrations, frameworkComponents, contract, fromContract, spaceId, ownership, snapshotsImportPath, resolveImportSpecifier) {\n\tconst fromSchema = migrations.contractToSchema(fromContract, frameworkComponents);\n\tconst plannerResult = planner.plan({\n\t\tcontract,\n\t\tschema: fromSchema,\n\t\tpolicy: { allowedOperationClasses: [\n\t\t\t\"additive\",\n\t\t\t\"widening\",\n\t\t\t\"destructive\",\n\t\t\t\"data\"\n\t\t] },\n\t\tfromContract,\n\t\tframeworkComponents,\n\t\tspaceId,\n\t\townership,\n\t\tsnapshotsImportPath\n\t});\n\tif (plannerResult.kind === \"failure\") return notOk(errorMigrationPlanningFailed({ conflicts: plannerResult.conflicts }));\n\tlet plannedOps = [];\n\tlet hasPlaceholders = false;\n\ttry {\n\t\tplannedOps = await Promise.all(plannerResult.plan.operations);\n\t\tif (plannedOps.length === 0) return notOk(errorMigrationPlanningFailed({ conflicts: [{\n\t\t\tkind: \"unsupportedChange\",\n\t\t\tsummary: \"Contract changed but planner produced no operations. This indicates unsupported or ignored changes.\"\n\t\t}] }));\n\t} catch (e) {\n\t\tif (CliStructuredError.is(e) && e.code === \"MIGRATION.UNFILLED_PLACEHOLDER\") hasPlaceholders = true;\n\t\telse throw e;\n\t}\n\treturn ok({\n\t\tplannedOps,\n\t\tmigrationTsContent: plannerResult.plan.renderTypeScript(resolveImportSpecifier),\n\t\thasPlaceholders\n\t});\n}\nasync function writePlannedMigrationPackage(packageDir, fromHash, toHash, createdAt, leg) {\n\tconst opsForWrite = leg.hasPlaceholders ? [] : leg.plannedOps;\n\tconst metadataWithInvariants = {\n\t\tfrom: fromHash,\n\t\tto: toHash,\n\t\tprovidedInvariants: deriveProvidedInvariants(opsForWrite),\n\t\tcreatedAt: createdAt.toISOString()\n\t};\n\tawait writeMigrationPackage(packageDir, {\n\t\t...metadataWithInvariants,\n\t\tmigrationHash: computeMigrationHash(metadataWithInvariants, opsForWrite)\n\t}, opsForWrite);\n\tawait writeMigrationTs(packageDir, leg.migrationTsContent);\n}\nasync function executeMigrationPlanCommand(options, flags, ui, startTime) {\n\tconst config = await loadConfig(options.config);\n\tconst { configPath, migrationsDir, appMigrationsDir, appMigrationsRelative } = resolveMigrationPaths(options.config, config);\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\t{\n\t\t\t\tlabel: \"config\",\n\t\t\t\tvalue: configPath\n\t\t\t},\n\t\t\t{\n\t\t\t\tlabel: \"contract\",\n\t\t\t\tvalue: contractPath\n\t\t\t},\n\t\t\t{\n\t\t\t\tlabel: \"migrations\",\n\t\t\t\tvalue: appMigrationsRelative\n\t\t\t}\n\t\t];\n\t\tif (options.from) details.push({\n\t\t\tlabel: \"from\",\n\t\t\tvalue: options.from\n\t\t});\n\t\tif (options.to) details.push({\n\t\t\tlabel: \"to\",\n\t\t\tvalue: options.to\n\t\t});\n\t\tif (options.name) details.push({\n\t\t\tlabel: \"name\",\n\t\t\tvalue: options.name\n\t\t});\n\t\tconst header = formatStyledHeader({\n\t\t\tcommand: \"migration plan\",\n\t\t\tdescription: \"Plan a migration from contract changes\",\n\t\t\turl: \"https://pris.ly/migration-plan\",\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\tconst stack = createControlStack(config);\n\tconst familyInstance = config.family.create(stack);\n\tconst controlAdapter = config.adapter.create(stack);\n\tlet toContract;\n\ttry {\n\t\ttoContract = familyInstance.deserializeContract(JSON.parse(contractJsonContent));\n\t} catch (error) {\n\t\treturn notOk(errorContractValidationFailed(`Contract at ${contractPathAbsolute} failed to deserialize: ${error instanceof Error ? error.message : String(error)}`, { where: { path: contractPathAbsolute } }));\n\t}\n\tconst rawStorageHash = toContract.storage?.storageHash;\n\tif (typeof rawStorageHash !== \"string\") return notOk(errorContractValidationFailed(\"Contract is missing storageHash\", { where: { path: contractPathAbsolute } }));\n\tlet toStorageHash = rawStorageHash;\n\tlet toArtifacts = null;\n\tlet fromContract = null;\n\tlet fromHash = null;\n\tlet snapshotStartContract = null;\n\tlet isAutoBaseline = false;\n\tconst tolerantAggregateResult = await loadContractSpaceAggregateForCli({\n\t\ttargetId: config.target.targetId,\n\t\tmigrationsDir,\n\t\tappContract: toContract,\n\t\textensions: config.extensions ?? [],\n\t\tdeserializeContract: (json) => familyInstance.deserializeContract(json)\n\t});\n\tif (!tolerantAggregateResult.ok) return notOk(tolerantAggregateResult.failure);\n\tconst resolutionSpace = tolerantAggregateResult.value.app;\n\tconst resolutionResult = await resolveFromForPlan({\n\t\toptionsFrom: options.from,\n\t\tspace: resolutionSpace\n\t});\n\tif (!resolutionResult.ok) return notOk(resolutionResult.failure);\n\tswitch (resolutionResult.value.kind) {\n\t\tcase \"greenfield\": break;\n\t\tcase \"graph-node\":\n\t\t\tfromHash = resolutionResult.value.fromHash;\n\t\t\tfromContract = resolutionResult.value.fromContract;\n\t\t\tbreak;\n\t\tcase \"ref\":\n\t\t\tfromHash = resolutionResult.value.fromHash;\n\t\t\tfromContract = resolutionResult.value.fromContract;\n\t\t\tsnapshotStartContract = {\n\t\t\t\tfromHash: resolutionResult.value.fromHash,\n\t\t\t\tcontractJson: resolutionResult.value.contractJson,\n\t\t\t\tcontractDts: resolutionResult.value.contractDts\n\t\t\t};\n\t\t\tbreak;\n\t\tcase \"auto-baseline\":\n\t\t\tfromHash = resolutionResult.value.fromHash;\n\t\t\tfromContract = resolutionResult.value.fromContract;\n\t\t\tsnapshotStartContract = {\n\t\t\t\tfromHash: resolutionResult.value.fromHash,\n\t\t\t\tcontractJson: resolutionResult.value.contractJson,\n\t\t\t\tcontractDts: resolutionResult.value.contractDts\n\t\t\t};\n\t\t\tisAutoBaseline = true;\n\t\t\tbreak;\n\t}\n\tif (options.to !== void 0) {\n\t\tconst toResolution = await resolveToForPlan(options.to, { space: resolutionSpace });\n\t\tif (!toResolution.ok) return notOk(toResolution.failure);\n\t\ttoContract = toResolution.value.contract;\n\t\ttoStorageHash = toResolution.value.hash;\n\t\ttoArtifacts = {\n\t\t\tcontractJson: toResolution.value.contractJson,\n\t\t\tcontractDts: toResolution.value.contractDts\n\t\t};\n\t}\n\tconst resolveImportSpecifier = createProjectSpecifierResolver(options.config);\n\tconst seedResult = await runContractSpaceSeedPhase({\n\t\tmigrationsDir,\n\t\textensions: toExtensionInputs(config.extensions ?? [])\n\t});\n\tif (!flags.json && !flags.quiet) {\n\t\tfor (const record of seedResult.seeded) if (record.action === \"updated\") {\n\t\t\tconst pkgSuffix = record.newMigrationDirs.length > 0 ? `; ${record.newMigrationDirs.length} new migration package(s) materialised` : \"\";\n\t\t\tui.step(`Updated ${record.spaceId} to ${record.newHash}${pkgSuffix}`);\n\t\t}\n\t}\n\tconst emittedExtensionDirs = seedResult.seeded.flatMap((r) => r.newMigrationDirs.map((dirName) => ({\n\t\tspaceId: r.spaceId,\n\t\tdirName\n\t})));\n\tif (fromHash === toStorageHash && !isAutoBaseline) return ok({\n\t\tok: true,\n\t\tnoOp: true,\n\t\tfrom: fromHash,\n\t\tto: toStorageHash,\n\t\toperations: [],\n\t\temittedExtensionDirs,\n\t\tsummary: \"No changes detected between contracts\",\n\t\ttimings: { total: Date.now() - startTime }\n\t});\n\tconst migrations = getTargetMigrations(config.target);\n\tif (!migrations) return notOk(errorTargetMigrationNotSupported({ why: `Target \"${config.target.id}\" does not support migrations` }));\n\tconst aggregateResult = await buildContractSpaceAggregate({\n\t\ttargetId: config.target.targetId,\n\t\tmigrationsDir,\n\t\tappContract: toContract,\n\t\textensions: config.extensions ?? [],\n\t\tdeserializeContract: (json) => familyInstance.deserializeContract(json)\n\t});\n\tif (!aggregateResult.ok) return notOk(aggregateResult.failure);\n\tconst aggregate = aggregateResult.value;\n\tconst frameworkComponents = assertFrameworkComponentsCompatible(config.family.familyId, config.target.targetId, [\n\t\tconfig.target,\n\t\tconfig.adapter,\n\t\t...config.extensions ?? []\n\t]);\n\tasync function writeDestinationSnapshot(destHash) {\n\t\tif (toArtifacts !== null) {\n\t\t\tawait writeContractSnapshot(migrationsDir, destHash, {\n\t\t\t\tcontractJson: toArtifacts.contractJson,\n\t\t\t\tcontractDts: toArtifacts.contractDts\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\t\tconst destinationArtifacts = getEmittedArtifactPaths(contractPathAbsolute);\n\t\tconst [contractJsonRaw, contractDts] = await Promise.all([readFile(destinationArtifacts.jsonPath, \"utf-8\"), readFile(destinationArtifacts.dtsPath, \"utf-8\")]);\n\t\tawait writeContractSnapshot(migrationsDir, destHash, {\n\t\t\tcontractJson: JSON.parse(contractJsonRaw),\n\t\t\tcontractDts\n\t\t});\n\t}\n\ttry {\n\t\tconst planner = migrations.createPlanner(controlAdapter);\n\t\tif (isAutoBaseline && fromHash !== null && fromContract !== null && snapshotStartContract !== null) {\n\t\t\tconst baselineTimestamp = /* @__PURE__ */ new Date();\n\t\t\tconst deltaTimestamp = new Date(baselineTimestamp.getTime() + 6e4);\n\t\t\tconst baselineDirName = formatMigrationDirName(baselineTimestamp, \"baseline\");\n\t\t\tconst deltaDirName = formatMigrationDirName(deltaTimestamp, options.name ?? \"migration\");\n\t\t\tconst baselinePackageDir = join(appMigrationsDir, baselineDirName);\n\t\t\tconst deltaPackageDir = join(appMigrationsDir, deltaDirName);\n\t\t\tconst baselineLeg = await runPlannerLeg(planner, migrations, frameworkComponents, fromContract, null, aggregate.app.spaceId, aggregate, snapshotsImportPathFrom(baselinePackageDir, migrationsDir), resolveImportSpecifier);\n\t\t\tif (!baselineLeg.ok) return notOk(baselineLeg.failure);\n\t\t\tawait writePlannedMigrationPackage(baselinePackageDir, null, fromHash, baselineTimestamp, baselineLeg.value);\n\t\t\tawait writeContractSnapshot(migrationsDir, fromHash, {\n\t\t\t\tcontractJson: snapshotStartContract.contractJson,\n\t\t\t\tcontractDts: snapshotStartContract.contractDts\n\t\t\t});\n\t\t\tif (fromHash === toStorageHash) {\n\t\t\t\tconst baselineOps = baselineLeg.value.hasPlaceholders ? [] : baselineLeg.value.plannedOps;\n\t\t\t\tif (baselineLeg.value.hasPlaceholders) {\n\t\t\t\t\tconst baselineDir = relative(process.cwd(), baselinePackageDir);\n\t\t\t\t\treturn ok({\n\t\t\t\t\t\tok: true,\n\t\t\t\t\t\tnoOp: false,\n\t\t\t\t\t\tfrom: fromHash,\n\t\t\t\t\t\tto: toStorageHash,\n\t\t\t\t\t\tdir: baselineDir,\n\t\t\t\t\t\tbaselineDir,\n\t\t\t\t\t\toperations: [],\n\t\t\t\t\t\temittedExtensionDirs,\n\t\t\t\t\t\tpendingPlaceholders: true,\n\t\t\t\t\t\tsummary: \"Planned baseline with placeholder(s) — edit migration.ts then run `node migration.ts` to self-emit\",\n\t\t\t\t\t\ttimings: { total: Date.now() - startTime }\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tconst preview = hasOperationPreview(familyInstance) ? familyInstance.toOperationPreview(baselineOps) : void 0;\n\t\t\t\treturn ok({\n\t\t\t\t\tok: true,\n\t\t\t\t\tnoOp: false,\n\t\t\t\t\tfrom: fromHash,\n\t\t\t\t\tto: toStorageHash,\n\t\t\t\t\tbaselineDir: relative(process.cwd(), baselinePackageDir),\n\t\t\t\t\toperations: baselineOps.map((op) => ({\n\t\t\t\t\t\tid: op.id,\n\t\t\t\t\t\tlabel: op.label,\n\t\t\t\t\t\toperationClass: op.operationClass\n\t\t\t\t\t})),\n\t\t\t\t\temittedExtensionDirs,\n\t\t\t\t\t...preview !== void 0 ? { preview } : {},\n\t\t\t\t\tsummary: buildAutoBaselinePlanSummary(0, emittedExtensionDirs.length),\n\t\t\t\t\ttimings: { total: Date.now() - startTime }\n\t\t\t\t});\n\t\t\t}\n\t\t\tconst deltaLeg = await runPlannerLeg(planner, migrations, frameworkComponents, aggregate.app.contract(), fromContract, aggregate.app.spaceId, aggregate, snapshotsImportPathFrom(deltaPackageDir, migrationsDir), resolveImportSpecifier);\n\t\t\tif (!deltaLeg.ok) return notOk(deltaLeg.failure);\n\t\t\tawait writePlannedMigrationPackage(deltaPackageDir, fromHash, toStorageHash, deltaTimestamp, deltaLeg.value);\n\t\t\tawait writeDestinationSnapshot(toStorageHash);\n\t\t\tawait writeContractSnapshot(migrationsDir, fromHash, {\n\t\t\t\tcontractJson: snapshotStartContract.contractJson,\n\t\t\t\tcontractDts: snapshotStartContract.contractDts\n\t\t\t});\n\t\t\tconst deltaOps = deltaLeg.value.hasPlaceholders ? [] : deltaLeg.value.plannedOps;\n\t\t\tif (deltaLeg.value.hasPlaceholders) return ok({\n\t\t\t\tok: true,\n\t\t\t\tnoOp: false,\n\t\t\t\tfrom: fromHash,\n\t\t\t\tto: toStorageHash,\n\t\t\t\tdir: relative(process.cwd(), deltaPackageDir),\n\t\t\t\tbaselineDir: relative(process.cwd(), baselinePackageDir),\n\t\t\t\toperations: [],\n\t\t\t\temittedExtensionDirs,\n\t\t\t\tpendingPlaceholders: true,\n\t\t\t\tsummary: \"Planned baseline + migration with placeholder(s) — edit migration.ts then run `node migration.ts` to self-emit\",\n\t\t\t\ttimings: { total: Date.now() - startTime }\n\t\t\t});\n\t\t\tconst preview = hasOperationPreview(familyInstance) ? familyInstance.toOperationPreview(deltaOps) : void 0;\n\t\t\treturn ok({\n\t\t\t\tok: true,\n\t\t\t\tnoOp: false,\n\t\t\t\tfrom: fromHash,\n\t\t\t\tto: toStorageHash,\n\t\t\t\tdir: relative(process.cwd(), deltaPackageDir),\n\t\t\t\tbaselineDir: relative(process.cwd(), baselinePackageDir),\n\t\t\t\toperations: deltaOps.map((op) => ({\n\t\t\t\t\tid: op.id,\n\t\t\t\t\tlabel: op.label,\n\t\t\t\t\toperationClass: op.operationClass\n\t\t\t\t})),\n\t\t\t\temittedExtensionDirs,\n\t\t\t\t...preview !== void 0 ? { preview } : {},\n\t\t\t\tsummary: buildAutoBaselinePlanSummary(deltaOps.length, emittedExtensionDirs.length),\n\t\t\t\ttimings: { total: Date.now() - startTime }\n\t\t\t});\n\t\t}\n\t\tconst timestamp = /* @__PURE__ */ new Date();\n\t\tconst packageDir = join(appMigrationsDir, formatMigrationDirName(timestamp, options.name ?? \"migration\"));\n\t\tconst deltaLeg = await runPlannerLeg(planner, migrations, frameworkComponents, aggregate.app.contract(), fromContract, aggregate.app.spaceId, aggregate, snapshotsImportPathFrom(packageDir, migrationsDir), resolveImportSpecifier);\n\t\tif (!deltaLeg.ok) return notOk(deltaLeg.failure);\n\t\tawait writePlannedMigrationPackage(packageDir, fromHash, toStorageHash, timestamp, deltaLeg.value);\n\t\tawait writeDestinationSnapshot(toStorageHash);\n\t\tif (snapshotStartContract !== null) await writeContractSnapshot(migrationsDir, snapshotStartContract.fromHash, {\n\t\t\tcontractJson: snapshotStartContract.contractJson,\n\t\t\tcontractDts: snapshotStartContract.contractDts\n\t\t});\n\t\tif (deltaLeg.value.hasPlaceholders) return ok({\n\t\t\tok: true,\n\t\t\tnoOp: false,\n\t\t\tfrom: fromHash,\n\t\t\tto: toStorageHash,\n\t\t\tdir: relative(process.cwd(), packageDir),\n\t\t\toperations: [],\n\t\t\temittedExtensionDirs,\n\t\t\tpendingPlaceholders: true,\n\t\t\tsummary: \"Planned migration with placeholder(s) — edit migration.ts then run `node migration.ts` to self-emit\",\n\t\t\ttimings: { total: Date.now() - startTime }\n\t\t});\n\t\tconst plannedOps = deltaLeg.value.plannedOps;\n\t\tconst preview = hasOperationPreview(familyInstance) ? familyInstance.toOperationPreview(plannedOps) : void 0;\n\t\treturn ok({\n\t\t\tok: true,\n\t\t\tnoOp: false,\n\t\t\tfrom: fromHash,\n\t\t\tto: toStorageHash,\n\t\t\tdir: relative(process.cwd(), packageDir),\n\t\t\toperations: plannedOps.map((op) => ({\n\t\t\t\tid: op.id,\n\t\t\t\tlabel: op.label,\n\t\t\t\toperationClass: op.operationClass\n\t\t\t})),\n\t\t\temittedExtensionDirs,\n\t\t\t...preview !== void 0 ? { preview } : {},\n\t\t\tsummary: buildPlanSummary(plannedOps.length, emittedExtensionDirs.length),\n\t\t\ttimings: { total: Date.now() - startTime }\n\t\t});\n\t} catch (error) {\n\t\tif (CliStructuredError.is(error)) return notOk(error);\n\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\treturn notOk(errorUnexpected(message, { why: `Unexpected error during migration plan: ${message}` }));\n\t}\n}\nfunction createMigrationPlanCommand() {\n\tconst command = new Command(\"plan\");\n\tsetCommandDescriptions(command, \"Plan a migration from contract changes\", \"Compares the emitted contract against the latest on-disk migration state and\\nproduces a new migration package with the required operations. No database\\nconnection is needed — this is a fully offline operation.\");\n\tsetCommandExamples(command, [\n\t\t\"prisma-next migration plan\",\n\t\t\"prisma-next migration plan --name add-users-table\",\n\t\t\"prisma-next migration plan --to <migration-dir>^ --name rollback\"\n\t]);\n\taddGlobalOptions(command).option(\"--config <path>\", \"Path to prisma-next.config.ts\").option(\"--name <slug>\", \"Name slug for the migration directory\", \"migration\").option(\"--from <contract>\", \"Starting contract reference (hash, prefix, ref name, migration dir name, <dir>^, or ./path)\").option(\"--to <contract>\", \"Destination contract reference (hash, prefix, ref name, migration dir name, <dir>^, or ./path); defaults to the emitted contract\").action(async (options) => {\n\t\tconst flags = parseGlobalFlagsOrExit(options);\n\t\tconst startTime = Date.now();\n\t\tconst ui = createTerminalUI(flags);\n\t\tconst exitCode = handleResult(await executeMigrationPlanCommand(options, flags, ui, startTime), flags, ui, (planResult) => {\n\t\t\tif (flags.json) ui.output(JSON.stringify(planResult, null, 2));\n\t\t\telse if (!flags.quiet) ui.log(formatMigrationPlanOutput(planResult, flags));\n\t\t});\n\t\tprocess.exit(exitCode);\n\t});\n\treturn command;\n}\n/**\n* Compose the success-line summary so the cross-space side effect\n* (extension-space migration packages materialised on disk during\n* this `plan` run) is visible in the top line — not just in the\n* step log above it.\n*\n* Example outputs:\n* - `Planned 3 operation(s)` (app-space-only project)\n* - `Planned 3 operation(s); materialised 1 extension-space migration` (one extension)\n* - `Planned 3 operation(s); materialised 2 extension-space migrations` (two extensions)\n*\n* Locks AC3 at the summary-line level: a reader of the success line\n* can tell that something happened beyond the app space.\n*/\nfunction buildPlanSummary(plannedOpsCount, emittedExtensionDirsCount) {\n\tconst base = `Planned ${plannedOpsCount} operation(s)`;\n\tif (emittedExtensionDirsCount === 0) return base;\n\treturn `${base}; materialised ${emittedExtensionDirsCount} ${emittedExtensionDirsCount === 1 ? \"extension-space migration\" : \"extension-space migrations\"}`;\n}\nfunction buildAutoBaselinePlanSummary(deltaOpsCount, emittedExtensionDirsCount) {\n\tconst base = `Planned baseline + ${deltaOpsCount} operation(s)`;\n\tif (emittedExtensionDirsCount === 0) return base;\n\treturn `${base}; materialised ${emittedExtensionDirsCount} ${emittedExtensionDirsCount === 1 ? \"extension-space migration\" : \"extension-space migrations\"}`;\n}\nfunction formatMigrationPlanOutput(result, flags) {\n\tconst lines = [];\n\tconst useColor = flags.color !== false;\n\tconst green_ = useColor ? (s) => `\\x1b[32m${s}\\x1b[0m` : (s) => s;\n\tconst yellow_ = useColor ? (s) => `\\x1b[33m${s}\\x1b[0m` : (s) => s;\n\tconst dim_ = useColor ? (s) => `\\x1b[2m${s}\\x1b[0m` : (s) => s;\n\tfunction appendEmittedExtensions() {\n\t\tif (result.emittedExtensionDirs.length === 0) return;\n\t\tlines.push(\"\");\n\t\tlines.push(dim_(\"Emitted extension migrations:\"));\n\t\tfor (const entry of result.emittedExtensionDirs) lines.push(dim_(` ${entry.spaceId} → migrations/${entry.spaceId}/${entry.dirName}`));\n\t\tlines.push(\"\");\n\t\tlines.push(`Next: review the extension migrations above, then run ${green_(\"prisma-next migrate\")}.`);\n\t}\n\tif (result.noOp) {\n\t\tlines.push(`${green_(\"✔\")} No changes detected`);\n\t\tlines.push(dim_(` from: ${result.from}`));\n\t\tlines.push(dim_(` to: ${result.to}`));\n\t\tappendEmittedExtensions();\n\t\treturn lines.join(\"\\n\");\n\t}\n\tif (result.pendingPlaceholders) {\n\t\tlines.push(`${yellow_(\"⚠\")} ${result.summary}`);\n\t\tlines.push(\"\");\n\t\tlines.push(dim_(`from: ${result.from}`));\n\t\tlines.push(dim_(`to: ${result.to}`));\n\t\tif (result.dir) lines.push(dim_(`dir: ${result.dir}`));\n\t\tlines.push(\"\");\n\t\tlines.push(\"Open migration.ts and replace each `placeholder(...)` call with your actual query.\");\n\t\tlines.push(`Then run: ${green_(`node ${result.dir ?? \"<dir>\"}/migration.ts`)}`);\n\t\tappendEmittedExtensions();\n\t\treturn lines.join(\"\\n\");\n\t}\n\tlines.push(`${green_(\"✔\")} ${result.summary}`);\n\tlines.push(\"\");\n\tif (result.operations.length > 0) {\n\t\tlines.push(dim_(\"│\"));\n\t\tfor (let i = 0; i < result.operations.length; i++) {\n\t\t\tconst op = result.operations[i];\n\t\t\tconst treeChar = i === result.operations.length - 1 ? \"└\" : \"├\";\n\t\t\tconst destructiveMarker = op.operationClass === \"destructive\" ? ` ${yellow_(\"(destructive)\")}` : \"\";\n\t\t\tlines.push(`${dim_(treeChar)}─ ${op.label}${destructiveMarker}`);\n\t\t}\n\t\tif (result.operations.some((op) => op.operationClass === \"destructive\")) {\n\t\t\tlines.push(\"\");\n\t\t\tlines.push(`${yellow_(\"⚠\")} This migration contains destructive operations that may cause data loss.`);\n\t\t}\n\t\tlines.push(\"\");\n\t}\n\tlines.push(dim_(`from: ${result.from}`));\n\tlines.push(dim_(`to: ${result.to}`));\n\tif (result.baselineDir) lines.push(dim_(`Baseline → ${result.baselineDir}`));\n\tif (result.dir) lines.push(dim_(`App space → ${result.dir}`));\n\tfor (const entry of result.emittedExtensionDirs) lines.push(dim_(`Extension space ${entry.spaceId} → migrations/${entry.spaceId}/${entry.dirName}`));\n\tlines.push(\"\");\n\tconst reviewTarget = result.baselineDir !== void 0 && result.dir !== void 0 ? `${result.baselineDir} and ${result.dir}` : result.baselineDir ?? result.dir ?? \"<dir>\";\n\tlines.push(`Next: review ${green_(reviewTarget)} if needed, then run ${green_(\"prisma-next migrate\")}.`);\n\tif (result.preview && result.preview.statements.length > 0) {\n\t\tconst allSql = result.preview.statements.every((s) => s.language === \"sql\");\n\t\tlines.push(\"\");\n\t\tlines.push(dim_(allSql ? \"DDL preview\" : \"Operation preview\"));\n\t\tlines.push(\"\");\n\t\tfor (const statement of result.preview.statements) {\n\t\t\tconst trimmed = statement.text.trim();\n\t\t\tif (!trimmed) continue;\n\t\t\tconst line = statement.language === \"sql\" && !trimmed.endsWith(\";\") ? `${trimmed};` : trimmed;\n\t\t\tlines.push(line);\n\t\t}\n\t}\n\tif (flags.verbose && result.timings) {\n\t\tlines.push(\"\");\n\t\tlines.push(dim_(`Total time: ${result.timings.total}ms`));\n\t}\n\treturn lines.join(\"\\n\");\n}\n/**\n* Resolve a migration package by **target contract hash** (`metadata.to`)\n* using exact match or prefix match.\n*\n* Note: matches `metadata.to` (the contract hash this migration produces),\n* not `metadata.migrationHash` (the package's content-addressed identity).\n* Tries exact match first, then prefix match. Returns the matched package on\n* success, or a discriminated failure indicating whether the prefix was\n* ambiguous or simply not found.\n*\n* @internal Exported for testing only.\n*/\nfunction resolveBundleByPrefix(bundles, needle) {\n\tconst exact = bundles.find((p) => p.metadata.to === needle);\n\tif (exact) return ok(exact);\n\tconst candidates = bundles.filter((p) => p.metadata.to.startsWith(needle));\n\tif (candidates.length === 1) return ok(candidates[0]);\n\tif (candidates.length > 1) return notOk({\n\t\treason: \"ambiguous\",\n\t\tcount: candidates.length\n\t});\n\treturn notOk({ reason: \"not-found\" });\n}\n//#endregion\nexport { formatMigrationPlanOutput as n, resolveBundleByPrefix as r, createMigrationPlanCommand as t };\n\n//# sourceMappingURL=migration-plan-CxXAXYc8.mjs.map"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgDA,eAAe,0BAA0B,QAAQ;CAChD,MAAM,UAAU,cAAc,OAAO,WAAW,QAAQ,SAAS,KAAK,kBAAkB,KAAK,CAAC,CAAC,CAAC,KAAK,UAAU;EAC9G,SAAS,KAAK;EACd,eAAe;EACf,aAAa,KAAK,cAAc;EAChC,QAAQ,KAAK;CACd,EAAE,IAAI,UAAU,MAAM,OAAO,UAAU;CACvC,MAAM,oCAAoC,IAAI,IAAI;CAClD,KAAK,MAAM,QAAQ,OAAO,YAAY,IAAI,KAAK,kBAAkB,KAAK,GAAG,kBAAkB,IAAI,KAAK,IAAI,KAAK,aAAa;CAC1H,MAAM,SAAS,CAAC;CAChB,KAAK,MAAM,SAAS,SAAS;EAC5B,MAAM,aAAa,kBAAkB,IAAI,MAAM,OAAO;EACtD,IAAI,eAAe,KAAK,GAAG;EAC3B,MAAM,aAAa,MAAM,yBAAyB,OAAO,eAAe,MAAM,OAAO,EAAA,EAAI,QAAQ;EACjG,MAAM,2BAA2B,OAAO,eAAe,MAAM,SAAS;GACrE,UAAU,WAAW;GACrB,aAAa,4BAA4B,MAAM,OAAO;GACtD,SAAS;IACR,MAAM,WAAW,QAAQ;IACzB,YAAY,WAAW,QAAQ;GAChC;EACD,CAAC;EACD,MAAM,WAAW,wBAAwB,OAAO,eAAe,MAAM,OA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