@prisma/orm-toolchain 0.16.0
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/LICENSE +201 -0
- package/README.md +28 -0
- package/dist/aggregate-B4mhR4Sk.mjs +1012 -0
- package/dist/aggregate-B4mhR4Sk.mjs.map +1 -0
- package/dist/aggregate-BflrjWPO.d.mts +803 -0
- package/dist/aggregate-BflrjWPO.d.mts.map +1 -0
- package/dist/bin__prisma-next.mjs +800 -0
- package/dist/bin__prisma-next.mjs.map +1 -0
- package/dist/cli-telemetry.d.mts +367 -0
- package/dist/cli-telemetry.d.mts.map +1 -0
- package/dist/cli-telemetry.mjs +48 -0
- package/dist/cli-telemetry.mjs.map +1 -0
- package/dist/cli-telemetry__sender.d.mts +1 -0
- package/dist/cli-telemetry__sender.mjs +1 -0
- package/dist/cli.d.mts +31 -0
- package/dist/cli.d.mts.map +1 -0
- package/dist/cli.mjs +180 -0
- package/dist/cli.mjs.map +1 -0
- package/dist/cli__commands__contract-emit.d.mts +2 -0
- package/dist/cli__commands__contract-emit.mjs +2 -0
- package/dist/cli__commands__contract-infer.d.mts +7 -0
- package/dist/cli__commands__contract-infer.d.mts.map +1 -0
- package/dist/cli__commands__contract-infer.mjs +2 -0
- package/dist/cli__commands__db-init.d.mts +7 -0
- package/dist/cli__commands__db-init.d.mts.map +1 -0
- package/dist/cli__commands__db-init.mjs +2 -0
- package/dist/cli__commands__db-schema.d.mts +7 -0
- package/dist/cli__commands__db-schema.d.mts.map +1 -0
- package/dist/cli__commands__db-schema.mjs +2 -0
- package/dist/cli__commands__db-sign.d.mts +7 -0
- package/dist/cli__commands__db-sign.d.mts.map +1 -0
- package/dist/cli__commands__db-sign.mjs +2 -0
- package/dist/cli__commands__db-update.d.mts +7 -0
- package/dist/cli__commands__db-update.d.mts.map +1 -0
- package/dist/cli__commands__db-update.mjs +2 -0
- package/dist/cli__commands__db-verify.d.mts +7 -0
- package/dist/cli__commands__db-verify.d.mts.map +1 -0
- package/dist/cli__commands__db-verify.mjs +2 -0
- package/dist/cli__commands__migrate.d.mts +66 -0
- package/dist/cli__commands__migrate.d.mts.map +1 -0
- package/dist/cli__commands__migrate.mjs +2 -0
- package/dist/cli__commands__migration-check.d.mts +64 -0
- package/dist/cli__commands__migration-check.d.mts.map +1 -0
- package/dist/cli__commands__migration-check.mjs +3 -0
- package/dist/cli__commands__migration-graph.d.mts +36 -0
- package/dist/cli__commands__migration-graph.d.mts.map +1 -0
- package/dist/cli__commands__migration-graph.mjs +2 -0
- package/dist/cli__commands__migration-list.d.mts +79 -0
- package/dist/cli__commands__migration-list.d.mts.map +1 -0
- package/dist/cli__commands__migration-list.mjs +2 -0
- package/dist/cli__commands__migration-log.d.mts +20 -0
- package/dist/cli__commands__migration-log.d.mts.map +1 -0
- package/dist/cli__commands__migration-log.mjs +2 -0
- package/dist/cli__commands__migration-new.d.mts +7 -0
- package/dist/cli__commands__migration-new.d.mts.map +1 -0
- package/dist/cli__commands__migration-new.mjs +2 -0
- package/dist/cli__commands__migration-plan.d.mts +79 -0
- package/dist/cli__commands__migration-plan.d.mts.map +1 -0
- package/dist/cli__commands__migration-plan.mjs +2 -0
- package/dist/cli__commands__migration-show.d.mts +27 -0
- package/dist/cli__commands__migration-show.d.mts.map +1 -0
- package/dist/cli__commands__migration-show.mjs +2 -0
- package/dist/cli__commands__migration-status.d.mts +55 -0
- package/dist/cli__commands__migration-status.d.mts.map +1 -0
- package/dist/cli__commands__migration-status.mjs +3 -0
- package/dist/cli__commands__ref.d.mts +34 -0
- package/dist/cli__commands__ref.d.mts.map +1 -0
- package/dist/cli__commands__ref.mjs +2 -0
- package/dist/cli__commands__telemetry.d.mts +7 -0
- package/dist/cli__commands__telemetry.d.mts.map +1 -0
- package/dist/cli__commands__telemetry.mjs +2 -0
- package/dist/cli__config-types.d.mts +2 -0
- package/dist/cli__config-types.mjs +2 -0
- package/dist/cli__control-api.d.mts +141 -0
- package/dist/cli__control-api.d.mts.map +1 -0
- package/dist/cli__control-api.mjs +4 -0
- package/dist/cli__init-output.d.mts +37 -0
- package/dist/cli__init-output.d.mts.map +1 -0
- package/dist/cli__init-output.mjs +2 -0
- package/dist/cli__migration-cli.d.mts +79 -0
- package/dist/cli__migration-cli.d.mts.map +1 -0
- package/dist/cli__migration-cli.mjs +407 -0
- package/dist/cli__migration-cli.mjs.map +1 -0
- package/dist/client-75qrAPqf-DZAVUxFa.mjs +1606 -0
- package/dist/client-75qrAPqf-DZAVUxFa.mjs.map +1 -0
- package/dist/command-helpers-CAoXqAY9-DWUBcTXM.mjs +1671 -0
- package/dist/command-helpers-CAoXqAY9-DWUBcTXM.mjs.map +1 -0
- package/dist/config-loader.d.mts +18 -0
- package/dist/config-loader.d.mts.map +1 -0
- package/dist/config-loader.mjs +2 -0
- package/dist/constants-CM-w38DQ-Cz_EXbOc.mjs +10 -0
- package/dist/constants-CM-w38DQ-Cz_EXbOc.mjs.map +1 -0
- package/dist/constants-Dkcn8Qu4.d.mts +10 -0
- package/dist/constants-Dkcn8Qu4.d.mts.map +1 -0
- package/dist/contract-at-errors-BX7w-p19-SxA8eaV2.mjs +36 -0
- package/dist/contract-at-errors-BX7w-p19-SxA8eaV2.mjs.map +1 -0
- package/dist/contract-emit-0hSjbuxp-BBOKldTZ.mjs +148 -0
- package/dist/contract-emit-0hSjbuxp-BBOKldTZ.mjs.map +1 -0
- package/dist/contract-emit-B65_UiFn.d.mts +7 -0
- package/dist/contract-emit-B65_UiFn.d.mts.map +1 -0
- package/dist/contract-emit-B6odMoem-CK3diBPk.mjs +359 -0
- package/dist/contract-emit-B6odMoem-CK3diBPk.mjs.map +1 -0
- package/dist/contract-enrichment-DrMvvY2A-DxNGeF4d.mjs +56 -0
- package/dist/contract-enrichment-DrMvvY2A-DxNGeF4d.mjs.map +1 -0
- package/dist/contract-infer-BnkqpftN-DVM2eKJ3.mjs +73 -0
- package/dist/contract-infer-BnkqpftN-DVM2eKJ3.mjs.map +1 -0
- package/dist/contract-snapshot-store-CbqynbtE.d.mts +28 -0
- package/dist/contract-snapshot-store-CbqynbtE.d.mts.map +1 -0
- package/dist/contract-snapshot-store-sf5nP4mb-MLpG-ihh.mjs +118 -0
- package/dist/contract-snapshot-store-sf5nP4mb-MLpG-ihh.mjs.map +1 -0
- package/dist/contract-space-aggregate-loader-CFH-336b-BhAyRQEL.mjs +302 -0
- package/dist/contract-space-aggregate-loader-CFH-336b-BhAyRQEL.mjs.map +1 -0
- package/dist/db-init-Vbkb_TKZ.mjs +153 -0
- package/dist/db-init-Vbkb_TKZ.mjs.map +1 -0
- package/dist/db-schema-ClQCu3xY.mjs +47 -0
- package/dist/db-schema-ClQCu3xY.mjs.map +1 -0
- package/dist/db-sign-jjXDgQ1u.mjs +175 -0
- package/dist/db-sign-jjXDgQ1u.mjs.map +1 -0
- package/dist/db-update-BQlrqtDD.mjs +183 -0
- package/dist/db-update-BQlrqtDD.mjs.map +1 -0
- package/dist/db-verify-CKPsRFrj-3udprZQD.mjs +396 -0
- package/dist/db-verify-CKPsRFrj-3udprZQD.mjs.map +1 -0
- package/dist/domain-type-generation-DAn9y5d2-BgoT5uKI.mjs +334 -0
- package/dist/domain-type-generation-DAn9y5d2-BgoT5uKI.mjs.map +1 -0
- package/dist/domain-type-generation-PkAb39ob-Ct8AGqow.d.mts +63 -0
- package/dist/domain-type-generation-PkAb39ob-Ct8AGqow.d.mts.map +1 -0
- package/dist/emitter.d.mts +75 -0
- package/dist/emitter.d.mts.map +1 -0
- package/dist/emitter.mjs +3 -0
- package/dist/emitter__domain-type-generation.d.mts +2 -0
- package/dist/emitter__domain-type-generation.mjs +2 -0
- package/dist/emitter__type-expression-safety.d.mts +6 -0
- package/dist/emitter__type-expression-safety.d.mts.map +1 -0
- package/dist/emitter__type-expression-safety.mjs +2 -0
- package/dist/errors--qsXZUtL.d.mts +72 -0
- package/dist/errors--qsXZUtL.d.mts.map +1 -0
- package/dist/errors-IpZm1Skp-BH495dRd.mjs +378 -0
- package/dist/errors-IpZm1Skp-BH495dRd.mjs.map +1 -0
- package/dist/exports-BN0vFTxG.mjs +276 -0
- package/dist/exports-BN0vFTxG.mjs.map +1 -0
- package/dist/exports-B_xhKZmC.mjs +1436 -0
- package/dist/exports-B_xhKZmC.mjs.map +1 -0
- package/dist/exports-D3-NwrMA-CadaBGQ3.mjs +154 -0
- package/dist/exports-D3-NwrMA-CadaBGQ3.mjs.map +1 -0
- package/dist/exports-Dl2aGAk7.mjs +119 -0
- package/dist/exports-Dl2aGAk7.mjs.map +1 -0
- package/dist/format-ByDm2goZ-DKLyhNHo.mjs +101 -0
- package/dist/format-ByDm2goZ-DKLyhNHo.mjs.map +1 -0
- package/dist/framework-components-CjshQKHA-Dlp6Leo5.mjs +58 -0
- package/dist/framework-components-CjshQKHA-Dlp6Leo5.mjs.map +1 -0
- package/dist/global-flags-BpoOYtNZ-CHZD3fud.d.mts +35 -0
- package/dist/global-flags-BpoOYtNZ-CHZD3fud.d.mts.map +1 -0
- package/dist/graph-bDjJ4GL9-BhFevsJS.d.mts +28 -0
- package/dist/graph-bDjJ4GL9-BhFevsJS.d.mts.map +1 -0
- package/dist/graph-membership-DW6nnbyQ-Bp2KcVwR.mjs +14 -0
- package/dist/graph-membership-DW6nnbyQ-Bp2KcVwR.mjs.map +1 -0
- package/dist/hash-DH8hl5Rq-BpM2t3Nu.mjs +64 -0
- package/dist/hash-DH8hl5Rq-BpM2t3Nu.mjs.map +1 -0
- package/dist/hash-XZYYKJ-i.d.mts +53 -0
- package/dist/hash-XZYYKJ-i.d.mts.map +1 -0
- package/dist/import-roots-B6CtsWXb.d.mts +119 -0
- package/dist/import-roots-B6CtsWXb.d.mts.map +1 -0
- package/dist/import-roots-NDOIEDVj.mjs +217 -0
- package/dist/import-roots-NDOIEDVj.mjs.map +1 -0
- package/dist/init-DHctXAI9-DSlaaYXN.mjs +2186 -0
- package/dist/init-DHctXAI9-DSlaaYXN.mjs.map +1 -0
- package/dist/inspect-live-schema-CnwYTRZ0-BErPHMni.mjs +91 -0
- package/dist/inspect-live-schema-CnwYTRZ0-BErPHMni.mjs.map +1 -0
- package/dist/invariants-B5wLrgQS.d.mts +39 -0
- package/dist/invariants-B5wLrgQS.d.mts.map +1 -0
- package/dist/invariants-lXzy6txi-DAoP4nTE.mjs +57 -0
- package/dist/invariants-lXzy6txi-DAoP4nTE.mjs.map +1 -0
- package/dist/io-C8TdyBKt-DloEBi70.mjs +313 -0
- package/dist/io-C8TdyBKt-DloEBi70.mjs.map +1 -0
- package/dist/io-DYfeLJxR.d.mts +1 -0
- package/dist/io-sr4CO9_t-C3eV_kn-.d.mts +125 -0
- package/dist/io-sr4CO9_t-C3eV_kn-.d.mts.map +1 -0
- package/dist/ledger-origin-BGRN77Oy.d.mts +6 -0
- package/dist/ledger-origin-BGRN77Oy.d.mts.map +1 -0
- package/dist/ledger-origin-D7PN4Fon.mjs +9 -0
- package/dist/ledger-origin-D7PN4Fon.mjs.map +1 -0
- package/dist/metadata-2nbOAGsV-uYNeq2Cp.d.mts +2 -0
- package/dist/metadata-BtscDay2.d.mts +1 -0
- package/dist/migrate-Cb_iv264.mjs +500 -0
- package/dist/migrate-Cb_iv264.mjs.map +1 -0
- package/dist/migration-B2ljMJim.d.mts +155 -0
- package/dist/migration-B2ljMJim.d.mts.map +1 -0
- package/dist/migration-BuUmO7It.mjs +209 -0
- package/dist/migration-BuUmO7It.mjs.map +1 -0
- package/dist/migration-check-DcwUnadt-B6Qoh0ot.mjs +597 -0
- package/dist/migration-check-DcwUnadt-B6Qoh0ot.mjs.map +1 -0
- package/dist/migration-command-scaffold-BCuoeAki-B1pVGX8d.mjs +103 -0
- package/dist/migration-command-scaffold-BCuoeAki-B1pVGX8d.mjs.map +1 -0
- package/dist/migration-graph-CBf9ORe7-B4xAF8GN.mjs +500 -0
- package/dist/migration-graph-CBf9ORe7-B4xAF8GN.mjs.map +1 -0
- package/dist/migration-graph-DkoCC0Qy.mjs +185 -0
- package/dist/migration-graph-DkoCC0Qy.mjs.map +1 -0
- package/dist/migration-graph-Dqndu0i5.d.mts +9 -0
- package/dist/migration-graph-Dqndu0i5.d.mts.map +1 -0
- package/dist/migration-graph-command-render-BKrg6BPv-BP8Pfj4J.mjs +1945 -0
- package/dist/migration-graph-command-render-BKrg6BPv-BP8Pfj4J.mjs.map +1 -0
- package/dist/migration-graph-tarTxJ99-BrGBANeE.d.mts +124 -0
- package/dist/migration-graph-tarTxJ99-BrGBANeE.d.mts.map +1 -0
- package/dist/migration-list-BFBeo1_X-c0kqYokL.mjs +228 -0
- package/dist/migration-list-BFBeo1_X-c0kqYokL.mjs.map +1 -0
- package/dist/migration-log-CS5IWcNq-BQ-32Low.mjs +220 -0
- package/dist/migration-log-CS5IWcNq-BQ-32Low.mjs.map +1 -0
- package/dist/migration-new-BurCjyaQ.mjs +168 -0
- package/dist/migration-new-BurCjyaQ.mjs.map +1 -0
- package/dist/migration-path-target-D3Sj55PI-BICblCuk.mjs +38 -0
- package/dist/migration-path-target-D3Sj55PI-BICblCuk.mjs.map +1 -0
- package/dist/migration-plan-q_L84PN1-BWE0LTH6.mjs +759 -0
- package/dist/migration-plan-q_L84PN1-BWE0LTH6.mjs.map +1 -0
- package/dist/migration-show-Bx5I5aW9.mjs +171 -0
- package/dist/migration-show-Bx5I5aW9.mjs.map +1 -0
- package/dist/migration-status-CE7cQLDq-B1jDVmqG.mjs +444 -0
- package/dist/migration-status-CE7cQLDq-B1jDVmqG.mjs.map +1 -0
- package/dist/migration-tools.d.mts +23 -0
- package/dist/migration-tools.mjs +17 -0
- package/dist/migration-tools__aggregate.d.mts +2 -0
- package/dist/migration-tools__aggregate.mjs +2 -0
- package/dist/migration-tools__constants.d.mts +2 -0
- package/dist/migration-tools__constants.mjs +2 -0
- package/dist/migration-tools__contract-snapshot-store.d.mts +2 -0
- package/dist/migration-tools__contract-snapshot-store.mjs +2 -0
- package/dist/migration-tools__errors.d.mts +2 -0
- package/dist/migration-tools__errors.mjs +2 -0
- package/dist/migration-tools__graph.d.mts +2 -0
- package/dist/migration-tools__graph.mjs +1 -0
- package/dist/migration-tools__hash.d.mts +2 -0
- package/dist/migration-tools__hash.mjs +2 -0
- package/dist/migration-tools__invariants.d.mts +2 -0
- package/dist/migration-tools__invariants.mjs +2 -0
- package/dist/migration-tools__io.d.mts +3 -0
- package/dist/migration-tools__io.mjs +2 -0
- package/dist/migration-tools__ledger-origin.d.mts +2 -0
- package/dist/migration-tools__ledger-origin.mjs +2 -0
- package/dist/migration-tools__metadata.d.mts +3 -0
- package/dist/migration-tools__metadata.mjs +1 -0
- package/dist/migration-tools__migration-graph.d.mts +3 -0
- package/dist/migration-tools__migration-graph.mjs +3 -0
- package/dist/migration-tools__migration-ts.d.mts +2 -0
- package/dist/migration-tools__migration-ts.mjs +2 -0
- package/dist/migration-tools__migration.d.mts +2 -0
- package/dist/migration-tools__migration.mjs +2 -0
- package/dist/migration-tools__package.d.mts +3 -0
- package/dist/migration-tools__package.mjs +1 -0
- package/dist/migration-tools__ref-resolution.d.mts +2 -0
- package/dist/migration-tools__ref-resolution.mjs +2 -0
- package/dist/migration-tools__refs.d.mts +2 -0
- package/dist/migration-tools__refs.mjs +2 -0
- package/dist/migration-tools__spaces.d.mts +3 -0
- package/dist/migration-tools__spaces.mjs +3 -0
- package/dist/migration-ts-CNaAtK8C.d.mts +38 -0
- package/dist/migration-ts-CNaAtK8C.d.mts.map +1 -0
- package/dist/migration-ts-FyF55c4M.mjs +67 -0
- package/dist/migration-ts-FyF55c4M.mjs.map +1 -0
- package/dist/op-schema-BSVHzEQN-DIWt28D8.mjs +13 -0
- package/dist/op-schema-BSVHzEQN-DIWt28D8.mjs.map +1 -0
- package/dist/output-DWNYqZGc-D2sRgLAm.mjs +109 -0
- package/dist/output-DWNYqZGc-D2sRgLAm.mjs.map +1 -0
- package/dist/package-CfWiDNrr-ZR4HM_Iz.d.mts +21 -0
- package/dist/package-CfWiDNrr-ZR4HM_Iz.d.mts.map +1 -0
- package/dist/package-N9PPdFV_.d.mts +3 -0
- package/dist/progress-adapter-CjAeTxY_-BXYSd1eY.mjs +43 -0
- package/dist/progress-adapter-CjAeTxY_-BXYSd1eY.mjs.map +1 -0
- package/dist/project-import-root-CpwLCDLY-DkVwAnWj.mjs +99 -0
- package/dist/project-import-root-CpwLCDLY-DkVwAnWj.mjs.map +1 -0
- package/dist/publish-surface.d.mts +3 -0
- package/dist/publish-surface.mjs +3 -0
- package/dist/publish-surface__import-roots.d.mts +2 -0
- package/dist/publish-surface__import-roots.mjs +2 -0
- package/dist/publish-surface__shells.d.mts +2 -0
- package/dist/publish-surface__shells.mjs +2 -0
- package/dist/quick-reference-mongo.md +114 -0
- package/dist/quick-reference-postgres.md +93 -0
- package/dist/readme-mongo.md +35 -0
- package/dist/readme-postgres.md +34 -0
- package/dist/ref-B6cTthTi.mjs +171 -0
- package/dist/ref-B6cTthTi.mjs.map +1 -0
- package/dist/ref-advancement-CSPMoQs3-fEipZrdu.mjs +57 -0
- package/dist/ref-advancement-CSPMoQs3-fEipZrdu.mjs.map +1 -0
- package/dist/ref-resolution-BjJBWPjX.mjs +250 -0
- package/dist/ref-resolution-BjJBWPjX.mjs.map +1 -0
- package/dist/ref-resolution-COGOSL57.d.mts +127 -0
- package/dist/ref-resolution-COGOSL57.d.mts.map +1 -0
- package/dist/refs-BDbB9BRB-D6Za3Q49.mjs +241 -0
- package/dist/refs-BDbB9BRB-D6Za3Q49.mjs.map +1 -0
- package/dist/refs-BNCUu58Y-BIso5Jfg.d.mts +43 -0
- package/dist/refs-BNCUu58Y-BIso5Jfg.d.mts.map +1 -0
- package/dist/schemas-CfGSxH5b-BSjB3nZS.d.mts +192 -0
- package/dist/schemas-CfGSxH5b-BSjB3nZS.d.mts.map +1 -0
- package/dist/schemas-KhXMzNA_-CzZ7GFX_.mjs +112 -0
- package/dist/schemas-KhXMzNA_-CzZ7GFX_.mjs.map +1 -0
- package/dist/shells-BenrJHp2.mjs +602 -0
- package/dist/shells-BenrJHp2.mjs.map +1 -0
- package/dist/shells-COHV_Ozf.d.mts +135 -0
- package/dist/shells-COHV_Ozf.d.mts.map +1 -0
- package/dist/spaces-C27bA-xc.mjs +267 -0
- package/dist/spaces-C27bA-xc.mjs.map +1 -0
- package/dist/spaces-DxFj5y8l.d.mts +415 -0
- package/dist/spaces-DxFj5y8l.d.mts.map +1 -0
- package/dist/telemetry-CmbCa3Ld-CmE5zcIG.mjs +120 -0
- package/dist/telemetry-CmbCa3Ld-CmE5zcIG.mjs.map +1 -0
- package/dist/terminal-ui-BN4QOsm5-Bf3pim46.d.mts +133 -0
- package/dist/terminal-ui-BN4QOsm5-Bf3pim46.d.mts.map +1 -0
- package/dist/type-expression-safety-CgHTWypx.mjs +8 -0
- package/dist/type-expression-safety-CgHTWypx.mjs.map +1 -0
- package/dist/types-DZWEs4si-D8UlyJI0.d.mts +893 -0
- package/dist/types-DZWEs4si-D8UlyJI0.d.mts.map +1 -0
- package/dist/verify-DnVNjc5C-BGdsblBK.mjs +283 -0
- package/dist/verify-DnVNjc5C-BGdsblBK.mjs.map +1 -0
- package/dist/verify-contract-spaces-BZDcJsuA-De8v4Z4T.mjs +252 -0
- package/dist/verify-contract-spaces-BZDcJsuA-De8v4Z4T.mjs.map +1 -0
- package/dist/verify-contract-spaces-Cc1u_wJo-BilPJS2S.d.mts +136 -0
- package/dist/verify-contract-spaces-Cc1u_wJo-BilPJS2S.d.mts.map +1 -0
- package/dist/vite-plugin-contract-emit.d.mts +54 -0
- package/dist/vite-plugin-contract-emit.d.mts.map +1 -0
- package/dist/vite-plugin-contract-emit.mjs +303 -0
- package/dist/vite-plugin-contract-emit.mjs.map +1 -0
- package/package.json +122 -0
|
@@ -0,0 +1,759 @@
|
|
|
1
|
+
import { t as MigrationToolsError } from "./errors-IpZm1Skp-BH495dRd.mjs";
|
|
2
|
+
import { a as snapshotsImportPathFrom, o as writeContractSnapshot } from "./contract-snapshot-store-sf5nP4mb-MLpG-ihh.mjs";
|
|
3
|
+
import { t as computeMigrationHash } from "./hash-DH8hl5Rq-BpM2t3Nu.mjs";
|
|
4
|
+
import { t as deriveProvidedInvariants } from "./invariants-lXzy6txi-DAoP4nTE.mjs";
|
|
5
|
+
import { i as materialiseExtensionMigrationPackageIfMissing, r as formatMigrationDirName, u as writeMigrationPackage } from "./io-C8TdyBKt-DloEBi70.mjs";
|
|
6
|
+
import { r as findLatestMigration } from "./migration-graph-CBf9ORe7-B4xAF8GN.mjs";
|
|
7
|
+
import { c as spaceMigrationDirectory, s as readContractSpaceHeadRef } from "./verify-contract-spaces-BZDcJsuA-De8v4Z4T.mjs";
|
|
8
|
+
import { i as emitContractSpaceArtifacts, o as planAllSpaces } from "./spaces-C27bA-xc.mjs";
|
|
9
|
+
import { C as errorPlanForgotTheFlag, K as getTargetMigrations, N as errorUnexpected, Q as mapRefResolutionError, W as formatStyledHeader, Z as mapMigrationToolsError, at as resolveMigrationPaths, ct as setCommandExamples, d as errorContractValidationFailed, h as errorFileNotFound, it as resolveContractPath, j as errorTargetMigrationNotSupported, k as errorSnapshotMissing, o as createTerminalUI, q as handleResult, r as addGlobalOptions, st as setCommandDescriptions, t as CliStructuredError$1, tt as parseGlobalFlagsOrExit, x as errorMigrationPlanningFailed } from "./command-helpers-CAoXqAY9-DWUBcTXM.mjs";
|
|
10
|
+
import { t as assertFrameworkComponentsCompatible } from "./framework-components-CjshQKHA-Dlp6Leo5.mjs";
|
|
11
|
+
import { t as createProjectSpecifierResolver } from "./project-import-root-CpwLCDLY-DkVwAnWj.mjs";
|
|
12
|
+
import { r as getEmittedArtifactPaths } from "./exports-D3-NwrMA-CadaBGQ3.mjs";
|
|
13
|
+
import { r as loadConfig } from "./exports-Dl2aGAk7.mjs";
|
|
14
|
+
import { n as isGraphNode, t as assertHashIsGraphNode } from "./graph-membership-DW6nnbyQ-Bp2KcVwR.mjs";
|
|
15
|
+
import { c as toExtensionInputs, i as loadContractSpaceAggregateForCli, t as buildContractSpaceAggregate } from "./contract-space-aggregate-loader-CFH-336b-BhAyRQEL.mjs";
|
|
16
|
+
import { n as parseContractRef } from "./ref-resolution-BjJBWPjX.mjs";
|
|
17
|
+
import { i as writeMigrationTs } from "./migration-ts-FyF55c4M.mjs";
|
|
18
|
+
import { t as mapContractAtError } from "./contract-at-errors-BX7w-p19-SxA8eaV2.mjs";
|
|
19
|
+
import { notOk, ok } from "@prisma/orm-framework/utils/result";
|
|
20
|
+
import { join, relative } from "pathe";
|
|
21
|
+
import { readFile } from "node:fs/promises";
|
|
22
|
+
import { createControlStack, hasOperationPreview } from "@prisma/orm-framework/components/control";
|
|
23
|
+
import { Command } from "commander";
|
|
24
|
+
//#region ../../../1-framework/3-tooling/cli/dist/migration-plan-q_L84PN1.mjs
|
|
25
|
+
/**
|
|
26
|
+
* Phase-1 of the two-phase `migration plan` pipeline (sub-spec § 4).
|
|
27
|
+
*
|
|
28
|
+
* For every extension that exposes a `contractSpace`:
|
|
29
|
+
*
|
|
30
|
+
* 1. Read the on-disk head ref (returns `null` on first emit).
|
|
31
|
+
* 2. Write the head contract into the migrations-root snapshot store
|
|
32
|
+
* (write-if-absent, keyed by hash) and unconditionally re-emit
|
|
33
|
+
* `refs/head.json`, via {@link emitContractSpaceArtifacts}. The
|
|
34
|
+
* framework owns `refs/head.json`; re-emit is the contract for that
|
|
35
|
+
* file. The snapshot itself is only written once per distinct hash.
|
|
36
|
+
* 3. Materialise any descriptor-shipped migration packages not yet on
|
|
37
|
+
* disk via {@link materialiseExtensionMigrationPackageIfMissing}.
|
|
38
|
+
* Existing packages are left untouched (by-existence skip).
|
|
39
|
+
*
|
|
40
|
+
* The return value lets the caller render a per-space status line and
|
|
41
|
+
* lets the phase-2 aggregate loader run on a now-consistent disk state
|
|
42
|
+
* (every loaded extension is guaranteed to have its head ref pinned
|
|
43
|
+
* to the descriptor's hash and to ship every package the descriptor
|
|
44
|
+
* declares).
|
|
45
|
+
*
|
|
46
|
+
* Output ordering is deterministic and alphabetical by spaceId (via
|
|
47
|
+
* {@link planAllSpaces}, which also detects duplicate spaceIds). This
|
|
48
|
+
* matches the canonical sort order used by every other aggregate
|
|
49
|
+
* surface (`migrate`, `migration status`, the runner).
|
|
50
|
+
*/
|
|
51
|
+
async function runContractSpaceSeedPhase(inputs) {
|
|
52
|
+
const planned = planAllSpaces(inputs.extensions.filter((pack) => pack.contractSpace !== void 0).map((pack) => ({
|
|
53
|
+
spaceId: pack.id,
|
|
54
|
+
priorContract: null,
|
|
55
|
+
newContract: pack.contractSpace.contractJson,
|
|
56
|
+
__pack: pack.contractSpace
|
|
57
|
+
})), (input) => input.__pack.migrations);
|
|
58
|
+
const descriptorBySpace = /* @__PURE__ */ new Map();
|
|
59
|
+
for (const pack of inputs.extensions) if (pack.contractSpace !== void 0) descriptorBySpace.set(pack.id, pack.contractSpace);
|
|
60
|
+
const seeded = [];
|
|
61
|
+
for (const space of planned) {
|
|
62
|
+
const descriptor = descriptorBySpace.get(space.spaceId);
|
|
63
|
+
if (descriptor === void 0) continue;
|
|
64
|
+
const priorHash = (await readContractSpaceHeadRef(inputs.migrationsDir, space.spaceId))?.hash ?? null;
|
|
65
|
+
await emitContractSpaceArtifacts(inputs.migrationsDir, space.spaceId, {
|
|
66
|
+
contract: descriptor.contractJson,
|
|
67
|
+
contractDts: buildPlaceholderContractDts(space.spaceId),
|
|
68
|
+
headRef: {
|
|
69
|
+
hash: descriptor.headRef.hash,
|
|
70
|
+
invariants: descriptor.headRef.invariants
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
const spaceDir = spaceMigrationDirectory(inputs.migrationsDir, space.spaceId);
|
|
74
|
+
const newMigrationDirs = [];
|
|
75
|
+
for (const pkg of space.migrationPackages) {
|
|
76
|
+
const { written } = await materialiseExtensionMigrationPackageIfMissing(spaceDir, pkg);
|
|
77
|
+
if (written) newMigrationDirs.push(pkg.dirName);
|
|
78
|
+
}
|
|
79
|
+
const action = priorHash !== descriptor.headRef.hash || newMigrationDirs.length > 0 ? "updated" : "unchanged";
|
|
80
|
+
seeded.push({
|
|
81
|
+
spaceId: space.spaceId,
|
|
82
|
+
action,
|
|
83
|
+
priorHash,
|
|
84
|
+
newHash: descriptor.headRef.hash,
|
|
85
|
+
newMigrationDirs
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
return { seeded };
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Placeholder `.d.ts` content for an extension space's on-disk mirror.
|
|
92
|
+
*
|
|
93
|
+
* Rendering a fully-typed `.d.ts` for an extension contract requires
|
|
94
|
+
* the SQL-family renderer with the codec / typemap registry threaded
|
|
95
|
+
* through; until that integration ships, the on-disk `.d.ts` is a
|
|
96
|
+
* stub `export {};` module that documents how consumers should
|
|
97
|
+
* validate the sibling `contract.json`. The stub typechecks on its
|
|
98
|
+
* own and does not need any TypeScript suppressions.
|
|
99
|
+
*/
|
|
100
|
+
function buildPlaceholderContractDts(spaceId) {
|
|
101
|
+
return [
|
|
102
|
+
"/**",
|
|
103
|
+
` * Placeholder \`.d.ts\` for extension space "${spaceId}".`,
|
|
104
|
+
" *",
|
|
105
|
+
" * The framework re-emits this file on every `migration plan` run",
|
|
106
|
+
" * alongside `contract.json` and `refs/head.json`. A typed `.d.ts`",
|
|
107
|
+
" * rendering pass for extension contracts is tracked separately;",
|
|
108
|
+
" * until that ships, consumers should import `contract.json`",
|
|
109
|
+
" * and pass it through the target descriptor’s `contractSerializer`.",
|
|
110
|
+
" */",
|
|
111
|
+
"export {};",
|
|
112
|
+
""
|
|
113
|
+
].join("\n");
|
|
114
|
+
}
|
|
115
|
+
const FULL_HASH_PATTERN = /^([0-9a-f]{64}|empty)$/;
|
|
116
|
+
function looksLikeFullHash(input) {
|
|
117
|
+
return FULL_HASH_PATTERN.test(input);
|
|
118
|
+
}
|
|
119
|
+
function graphIsEmpty(space) {
|
|
120
|
+
return space.packages.length === 0;
|
|
121
|
+
}
|
|
122
|
+
function getReachableRefs(refs, graph) {
|
|
123
|
+
return Object.entries(refs).flatMap(([name, entry]) => entry && isGraphNode(entry.hash, graph) ? [{
|
|
124
|
+
name,
|
|
125
|
+
hash: entry.hash
|
|
126
|
+
}] : []).sort((a, b) => a.name.localeCompare(b.name));
|
|
127
|
+
}
|
|
128
|
+
function assertFromIsGraphNode(fromHash, graph, refs, graphTipHash) {
|
|
129
|
+
try {
|
|
130
|
+
assertHashIsGraphNode(fromHash, graph);
|
|
131
|
+
} catch (error) {
|
|
132
|
+
if (MigrationToolsError.is(error) && error.code === "MIGRATION.HASH_NOT_IN_GRAPH") throw errorPlanForgotTheFlag(fromHash, getReachableRefs(refs, graph), graphTipHash);
|
|
133
|
+
throw error;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
async function resolveContractRef(parsed, space, options) {
|
|
137
|
+
const { hash, provenance } = parsed;
|
|
138
|
+
const refName = provenance.kind === "ref" ? provenance.refName : void 0;
|
|
139
|
+
try {
|
|
140
|
+
const at = await space.contractAt(hash, refName !== void 0 ? { refName } : void 0);
|
|
141
|
+
if (at.provenance === "ref") return ok({
|
|
142
|
+
kind: "ref",
|
|
143
|
+
hash: at.hash,
|
|
144
|
+
contract: at.contract,
|
|
145
|
+
contractJson: at.contractJson,
|
|
146
|
+
contractDts: at.contractDts
|
|
147
|
+
});
|
|
148
|
+
return ok({
|
|
149
|
+
kind: "graph-node",
|
|
150
|
+
hash: at.hash,
|
|
151
|
+
contract: at.contract,
|
|
152
|
+
contractJson: at.contractJson,
|
|
153
|
+
contractDts: at.contractDts
|
|
154
|
+
});
|
|
155
|
+
} catch (error) {
|
|
156
|
+
return mapContractAtError(error, options?.artifactRole !== void 0 ? { artifactRole: options.artifactRole } : void 0);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
async function resolveFromPolicy(parsed, input, refs, explicitFromLabel) {
|
|
160
|
+
const resolution = await resolveContractRef(parsed, input.space, {
|
|
161
|
+
...explicitFromLabel !== void 0 ? { explicitLabel: explicitFromLabel } : {},
|
|
162
|
+
artifactRole: "from"
|
|
163
|
+
});
|
|
164
|
+
if (!resolution.ok) return resolution;
|
|
165
|
+
if (resolution.value.kind === "graph-node") return ok({
|
|
166
|
+
kind: "graph-node",
|
|
167
|
+
fromHash: resolution.value.hash,
|
|
168
|
+
fromContract: resolution.value.contract
|
|
169
|
+
});
|
|
170
|
+
const { hash, contract, contractJson, contractDts } = resolution.value;
|
|
171
|
+
if (graphIsEmpty(input.space)) return ok({
|
|
172
|
+
kind: "auto-baseline",
|
|
173
|
+
fromHash: hash,
|
|
174
|
+
fromContract: contract,
|
|
175
|
+
contractDts,
|
|
176
|
+
contractJson
|
|
177
|
+
});
|
|
178
|
+
const graph = input.space.graph();
|
|
179
|
+
const graphTip = findLatestMigration(graph)?.to ?? null;
|
|
180
|
+
try {
|
|
181
|
+
assertFromIsGraphNode(hash, graph, refs, graphTip);
|
|
182
|
+
} catch (error) {
|
|
183
|
+
if (CliStructuredError$1.is(error)) return notOk(error);
|
|
184
|
+
throw error;
|
|
185
|
+
}
|
|
186
|
+
return ok({
|
|
187
|
+
kind: "ref",
|
|
188
|
+
fromHash: hash,
|
|
189
|
+
fromContract: contract,
|
|
190
|
+
contractDts,
|
|
191
|
+
contractJson
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
async function resolveFromForPlan(input) {
|
|
195
|
+
const { optionsFrom, space } = input;
|
|
196
|
+
const graph = space.graph();
|
|
197
|
+
const refs = space.refs;
|
|
198
|
+
if (optionsFrom === void 0) {
|
|
199
|
+
const dbRef = refs["db"];
|
|
200
|
+
if (!dbRef) return ok({
|
|
201
|
+
kind: "greenfield",
|
|
202
|
+
fromHash: null,
|
|
203
|
+
fromContract: null
|
|
204
|
+
});
|
|
205
|
+
return resolveFromPolicy({
|
|
206
|
+
hash: dbRef.hash,
|
|
207
|
+
provenance: {
|
|
208
|
+
kind: "ref",
|
|
209
|
+
refName: "db"
|
|
210
|
+
}
|
|
211
|
+
}, input, refs);
|
|
212
|
+
}
|
|
213
|
+
const refResult = parseContractRef(optionsFrom, {
|
|
214
|
+
graph,
|
|
215
|
+
refs
|
|
216
|
+
});
|
|
217
|
+
if (!refResult.ok) {
|
|
218
|
+
if (looksLikeFullHash(optionsFrom)) {
|
|
219
|
+
const empty = graphIsEmpty(space);
|
|
220
|
+
const graphTip = findLatestMigration(graph)?.to ?? null;
|
|
221
|
+
if (empty) return notOk(errorSnapshotMissing(optionsFrom, { viaRef: false }));
|
|
222
|
+
return notOk(errorPlanForgotTheFlag(optionsFrom, getReachableRefs(refs, graph), graphTip));
|
|
223
|
+
}
|
|
224
|
+
return notOk(mapRefResolutionError(refResult.failure));
|
|
225
|
+
}
|
|
226
|
+
return resolveFromPolicy(refResult.value, input, refs, optionsFrom);
|
|
227
|
+
}
|
|
228
|
+
async function resolveToForPlan(optionsTo, input) {
|
|
229
|
+
const { space } = input;
|
|
230
|
+
const graph = space.graph();
|
|
231
|
+
const refs = space.refs;
|
|
232
|
+
const refResult = parseContractRef(optionsTo, {
|
|
233
|
+
graph,
|
|
234
|
+
refs
|
|
235
|
+
});
|
|
236
|
+
if (!refResult.ok) return notOk(mapRefResolutionError(refResult.failure));
|
|
237
|
+
const resolution = await resolveContractRef(refResult.value, space, {
|
|
238
|
+
explicitLabel: optionsTo,
|
|
239
|
+
artifactRole: "to"
|
|
240
|
+
});
|
|
241
|
+
if (!resolution.ok) return resolution;
|
|
242
|
+
const { hash, contract, contractJson, contractDts } = resolution.value;
|
|
243
|
+
return ok({
|
|
244
|
+
hash,
|
|
245
|
+
contract,
|
|
246
|
+
contractJson,
|
|
247
|
+
contractDts
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
async function runPlannerLeg(planner, migrations, frameworkComponents, contract, fromContract, spaceId, ownership, snapshotsImportPath, resolveImportSpecifier) {
|
|
251
|
+
const fromSchema = migrations.contractToSchema(fromContract, frameworkComponents);
|
|
252
|
+
const plannerResult = planner.plan({
|
|
253
|
+
contract,
|
|
254
|
+
schema: fromSchema,
|
|
255
|
+
policy: { allowedOperationClasses: [
|
|
256
|
+
"additive",
|
|
257
|
+
"widening",
|
|
258
|
+
"destructive",
|
|
259
|
+
"data"
|
|
260
|
+
] },
|
|
261
|
+
fromContract,
|
|
262
|
+
frameworkComponents,
|
|
263
|
+
spaceId,
|
|
264
|
+
ownership,
|
|
265
|
+
snapshotsImportPath
|
|
266
|
+
});
|
|
267
|
+
if (plannerResult.kind === "failure") return notOk(errorMigrationPlanningFailed({ conflicts: plannerResult.conflicts }));
|
|
268
|
+
let plannedOps = [];
|
|
269
|
+
let hasPlaceholders = false;
|
|
270
|
+
try {
|
|
271
|
+
plannedOps = await Promise.all(plannerResult.plan.operations);
|
|
272
|
+
if (plannedOps.length === 0) return notOk(errorMigrationPlanningFailed({ conflicts: [{
|
|
273
|
+
kind: "unsupportedChange",
|
|
274
|
+
summary: "Contract changed but planner produced no operations. This indicates unsupported or ignored changes."
|
|
275
|
+
}] }));
|
|
276
|
+
} catch (e) {
|
|
277
|
+
if (CliStructuredError$1.is(e) && e.code === "MIGRATION.UNFILLED_PLACEHOLDER") hasPlaceholders = true;
|
|
278
|
+
else throw e;
|
|
279
|
+
}
|
|
280
|
+
return ok({
|
|
281
|
+
plannedOps,
|
|
282
|
+
migrationTsContent: plannerResult.plan.renderTypeScript(resolveImportSpecifier),
|
|
283
|
+
hasPlaceholders
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
async function writePlannedMigrationPackage(packageDir, fromHash, toHash, createdAt, leg) {
|
|
287
|
+
const opsForWrite = leg.hasPlaceholders ? [] : leg.plannedOps;
|
|
288
|
+
const metadataWithInvariants = {
|
|
289
|
+
from: fromHash,
|
|
290
|
+
to: toHash,
|
|
291
|
+
providedInvariants: deriveProvidedInvariants(opsForWrite),
|
|
292
|
+
createdAt: createdAt.toISOString()
|
|
293
|
+
};
|
|
294
|
+
await writeMigrationPackage(packageDir, {
|
|
295
|
+
...metadataWithInvariants,
|
|
296
|
+
migrationHash: computeMigrationHash(metadataWithInvariants, opsForWrite)
|
|
297
|
+
}, opsForWrite);
|
|
298
|
+
await writeMigrationTs(packageDir, leg.migrationTsContent);
|
|
299
|
+
}
|
|
300
|
+
async function executeMigrationPlanCommand(options, flags, ui, startTime) {
|
|
301
|
+
const config = await loadConfig(options.config);
|
|
302
|
+
const { configPath, migrationsDir, appMigrationsDir, appMigrationsRelative } = resolveMigrationPaths(options.config, config);
|
|
303
|
+
const contractPathAbsolute = resolveContractPath(config);
|
|
304
|
+
const contractPath = relative(process.cwd(), contractPathAbsolute);
|
|
305
|
+
if (!flags.json && !flags.quiet) {
|
|
306
|
+
const details = [
|
|
307
|
+
{
|
|
308
|
+
label: "config",
|
|
309
|
+
value: configPath
|
|
310
|
+
},
|
|
311
|
+
{
|
|
312
|
+
label: "contract",
|
|
313
|
+
value: contractPath
|
|
314
|
+
},
|
|
315
|
+
{
|
|
316
|
+
label: "migrations",
|
|
317
|
+
value: appMigrationsRelative
|
|
318
|
+
}
|
|
319
|
+
];
|
|
320
|
+
if (options.from) details.push({
|
|
321
|
+
label: "from",
|
|
322
|
+
value: options.from
|
|
323
|
+
});
|
|
324
|
+
if (options.to) details.push({
|
|
325
|
+
label: "to",
|
|
326
|
+
value: options.to
|
|
327
|
+
});
|
|
328
|
+
if (options.name) details.push({
|
|
329
|
+
label: "name",
|
|
330
|
+
value: options.name
|
|
331
|
+
});
|
|
332
|
+
const header = formatStyledHeader({
|
|
333
|
+
command: "migration plan",
|
|
334
|
+
description: "Plan a migration from contract changes",
|
|
335
|
+
url: "https://pris.ly/migration-plan",
|
|
336
|
+
details,
|
|
337
|
+
flags
|
|
338
|
+
});
|
|
339
|
+
ui.stderr(header);
|
|
340
|
+
}
|
|
341
|
+
let contractJsonContent;
|
|
342
|
+
try {
|
|
343
|
+
contractJsonContent = await readFile(contractPathAbsolute, "utf-8");
|
|
344
|
+
} catch (error) {
|
|
345
|
+
if (error instanceof Error && error.code === "ENOENT") return notOk(errorFileNotFound(contractPathAbsolute, {
|
|
346
|
+
why: `Contract file not found at ${contractPathAbsolute}`,
|
|
347
|
+
fix: `Run \`prisma-next contract emit\` to generate ${contractPath}, or update \`config.contract.output\` in ${configPath}`
|
|
348
|
+
}));
|
|
349
|
+
return notOk(errorUnexpected(error instanceof Error ? error.message : String(error), { why: `Failed to read contract file: ${error instanceof Error ? error.message : String(error)}` }));
|
|
350
|
+
}
|
|
351
|
+
const stack = createControlStack(config);
|
|
352
|
+
const familyInstance = config.family.create(stack);
|
|
353
|
+
const controlAdapter = config.adapter.create(stack);
|
|
354
|
+
let toContract;
|
|
355
|
+
try {
|
|
356
|
+
toContract = familyInstance.deserializeContract(JSON.parse(contractJsonContent));
|
|
357
|
+
} catch (error) {
|
|
358
|
+
return notOk(errorContractValidationFailed(`Contract at ${contractPathAbsolute} failed to deserialize: ${error instanceof Error ? error.message : String(error)}`, { where: { path: contractPathAbsolute } }));
|
|
359
|
+
}
|
|
360
|
+
const rawStorageHash = toContract.storage?.storageHash;
|
|
361
|
+
if (typeof rawStorageHash !== "string") return notOk(errorContractValidationFailed("Contract is missing storageHash", { where: { path: contractPathAbsolute } }));
|
|
362
|
+
let toStorageHash = rawStorageHash;
|
|
363
|
+
let toArtifacts = null;
|
|
364
|
+
let fromContract = null;
|
|
365
|
+
let fromHash = null;
|
|
366
|
+
let snapshotStartContract = null;
|
|
367
|
+
let isAutoBaseline = false;
|
|
368
|
+
const tolerantAggregateResult = await loadContractSpaceAggregateForCli({
|
|
369
|
+
targetId: config.target.targetId,
|
|
370
|
+
migrationsDir,
|
|
371
|
+
appContract: toContract,
|
|
372
|
+
extensions: config.extensions ?? [],
|
|
373
|
+
deserializeContract: (json) => familyInstance.deserializeContract(json)
|
|
374
|
+
});
|
|
375
|
+
if (!tolerantAggregateResult.ok) return notOk(tolerantAggregateResult.failure);
|
|
376
|
+
const resolutionSpace = tolerantAggregateResult.value.app;
|
|
377
|
+
const resolutionResult = await resolveFromForPlan({
|
|
378
|
+
optionsFrom: options.from,
|
|
379
|
+
space: resolutionSpace
|
|
380
|
+
});
|
|
381
|
+
if (!resolutionResult.ok) return notOk(resolutionResult.failure);
|
|
382
|
+
switch (resolutionResult.value.kind) {
|
|
383
|
+
case "greenfield": break;
|
|
384
|
+
case "graph-node":
|
|
385
|
+
fromHash = resolutionResult.value.fromHash;
|
|
386
|
+
fromContract = resolutionResult.value.fromContract;
|
|
387
|
+
break;
|
|
388
|
+
case "ref":
|
|
389
|
+
fromHash = resolutionResult.value.fromHash;
|
|
390
|
+
fromContract = resolutionResult.value.fromContract;
|
|
391
|
+
snapshotStartContract = {
|
|
392
|
+
fromHash: resolutionResult.value.fromHash,
|
|
393
|
+
contractJson: resolutionResult.value.contractJson,
|
|
394
|
+
contractDts: resolutionResult.value.contractDts
|
|
395
|
+
};
|
|
396
|
+
break;
|
|
397
|
+
case "auto-baseline":
|
|
398
|
+
fromHash = resolutionResult.value.fromHash;
|
|
399
|
+
fromContract = resolutionResult.value.fromContract;
|
|
400
|
+
snapshotStartContract = {
|
|
401
|
+
fromHash: resolutionResult.value.fromHash,
|
|
402
|
+
contractJson: resolutionResult.value.contractJson,
|
|
403
|
+
contractDts: resolutionResult.value.contractDts
|
|
404
|
+
};
|
|
405
|
+
isAutoBaseline = true;
|
|
406
|
+
break;
|
|
407
|
+
}
|
|
408
|
+
if (options.to !== void 0) {
|
|
409
|
+
const toResolution = await resolveToForPlan(options.to, { space: resolutionSpace });
|
|
410
|
+
if (!toResolution.ok) return notOk(toResolution.failure);
|
|
411
|
+
toContract = toResolution.value.contract;
|
|
412
|
+
toStorageHash = toResolution.value.hash;
|
|
413
|
+
toArtifacts = {
|
|
414
|
+
contractJson: toResolution.value.contractJson,
|
|
415
|
+
contractDts: toResolution.value.contractDts
|
|
416
|
+
};
|
|
417
|
+
}
|
|
418
|
+
const resolveImportSpecifier = createProjectSpecifierResolver(options.config);
|
|
419
|
+
const seedResult = await runContractSpaceSeedPhase({
|
|
420
|
+
migrationsDir,
|
|
421
|
+
extensions: toExtensionInputs(config.extensions ?? [])
|
|
422
|
+
});
|
|
423
|
+
if (!flags.json && !flags.quiet) {
|
|
424
|
+
for (const record of seedResult.seeded) if (record.action === "updated") {
|
|
425
|
+
const pkgSuffix = record.newMigrationDirs.length > 0 ? `; ${record.newMigrationDirs.length} new migration package(s) materialised` : "";
|
|
426
|
+
ui.step(`Updated ${record.spaceId} to ${record.newHash}${pkgSuffix}`);
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
const emittedExtensionDirs = seedResult.seeded.flatMap((r) => r.newMigrationDirs.map((dirName) => ({
|
|
430
|
+
spaceId: r.spaceId,
|
|
431
|
+
dirName
|
|
432
|
+
})));
|
|
433
|
+
if (fromHash === toStorageHash && !isAutoBaseline) return ok({
|
|
434
|
+
ok: true,
|
|
435
|
+
noOp: true,
|
|
436
|
+
from: fromHash,
|
|
437
|
+
to: toStorageHash,
|
|
438
|
+
operations: [],
|
|
439
|
+
emittedExtensionDirs,
|
|
440
|
+
summary: "No changes detected between contracts",
|
|
441
|
+
timings: { total: Date.now() - startTime }
|
|
442
|
+
});
|
|
443
|
+
const migrations = getTargetMigrations(config.target);
|
|
444
|
+
if (!migrations) return notOk(errorTargetMigrationNotSupported({ why: `Target "${config.target.id}" does not support migrations` }));
|
|
445
|
+
const aggregateResult = await buildContractSpaceAggregate({
|
|
446
|
+
targetId: config.target.targetId,
|
|
447
|
+
migrationsDir,
|
|
448
|
+
appContract: toContract,
|
|
449
|
+
extensions: config.extensions ?? [],
|
|
450
|
+
deserializeContract: (json) => familyInstance.deserializeContract(json)
|
|
451
|
+
});
|
|
452
|
+
if (!aggregateResult.ok) return notOk(aggregateResult.failure);
|
|
453
|
+
const aggregate = aggregateResult.value;
|
|
454
|
+
const frameworkComponents = assertFrameworkComponentsCompatible(config.family.familyId, config.target.targetId, [
|
|
455
|
+
config.target,
|
|
456
|
+
config.adapter,
|
|
457
|
+
...config.extensions ?? []
|
|
458
|
+
]);
|
|
459
|
+
async function writeDestinationSnapshot(destHash) {
|
|
460
|
+
if (toArtifacts !== null) {
|
|
461
|
+
await writeContractSnapshot(migrationsDir, destHash, {
|
|
462
|
+
contractJson: toArtifacts.contractJson,
|
|
463
|
+
contractDts: toArtifacts.contractDts
|
|
464
|
+
});
|
|
465
|
+
return;
|
|
466
|
+
}
|
|
467
|
+
const destinationArtifacts = getEmittedArtifactPaths(contractPathAbsolute);
|
|
468
|
+
const [contractJsonRaw, contractDts] = await Promise.all([readFile(destinationArtifacts.jsonPath, "utf-8"), readFile(destinationArtifacts.dtsPath, "utf-8")]);
|
|
469
|
+
await writeContractSnapshot(migrationsDir, destHash, {
|
|
470
|
+
contractJson: JSON.parse(contractJsonRaw),
|
|
471
|
+
contractDts
|
|
472
|
+
});
|
|
473
|
+
}
|
|
474
|
+
try {
|
|
475
|
+
const planner = migrations.createPlanner(controlAdapter);
|
|
476
|
+
if (isAutoBaseline && fromHash !== null && fromContract !== null && snapshotStartContract !== null) {
|
|
477
|
+
const baselineTimestamp = /* @__PURE__ */ new Date();
|
|
478
|
+
const deltaTimestamp = new Date(baselineTimestamp.getTime() + 6e4);
|
|
479
|
+
const baselineDirName = formatMigrationDirName(baselineTimestamp, "baseline");
|
|
480
|
+
const deltaDirName = formatMigrationDirName(deltaTimestamp, options.name ?? "migration");
|
|
481
|
+
const baselinePackageDir = join(appMigrationsDir, baselineDirName);
|
|
482
|
+
const deltaPackageDir = join(appMigrationsDir, deltaDirName);
|
|
483
|
+
const baselineLeg = await runPlannerLeg(planner, migrations, frameworkComponents, fromContract, null, aggregate.app.spaceId, aggregate, snapshotsImportPathFrom(baselinePackageDir, migrationsDir), resolveImportSpecifier);
|
|
484
|
+
if (!baselineLeg.ok) return notOk(baselineLeg.failure);
|
|
485
|
+
await writePlannedMigrationPackage(baselinePackageDir, null, fromHash, baselineTimestamp, baselineLeg.value);
|
|
486
|
+
await writeContractSnapshot(migrationsDir, fromHash, {
|
|
487
|
+
contractJson: snapshotStartContract.contractJson,
|
|
488
|
+
contractDts: snapshotStartContract.contractDts
|
|
489
|
+
});
|
|
490
|
+
if (fromHash === toStorageHash) {
|
|
491
|
+
const baselineOps = baselineLeg.value.hasPlaceholders ? [] : baselineLeg.value.plannedOps;
|
|
492
|
+
if (baselineLeg.value.hasPlaceholders) {
|
|
493
|
+
const baselineDir = relative(process.cwd(), baselinePackageDir);
|
|
494
|
+
return ok({
|
|
495
|
+
ok: true,
|
|
496
|
+
noOp: false,
|
|
497
|
+
from: fromHash,
|
|
498
|
+
to: toStorageHash,
|
|
499
|
+
dir: baselineDir,
|
|
500
|
+
baselineDir,
|
|
501
|
+
operations: [],
|
|
502
|
+
emittedExtensionDirs,
|
|
503
|
+
pendingPlaceholders: true,
|
|
504
|
+
summary: "Planned baseline with placeholder(s) — edit migration.ts then run `node migration.ts` to self-emit",
|
|
505
|
+
timings: { total: Date.now() - startTime }
|
|
506
|
+
});
|
|
507
|
+
}
|
|
508
|
+
const preview = hasOperationPreview(familyInstance) ? familyInstance.toOperationPreview(baselineOps) : void 0;
|
|
509
|
+
return ok({
|
|
510
|
+
ok: true,
|
|
511
|
+
noOp: false,
|
|
512
|
+
from: fromHash,
|
|
513
|
+
to: toStorageHash,
|
|
514
|
+
baselineDir: relative(process.cwd(), baselinePackageDir),
|
|
515
|
+
operations: baselineOps.map((op) => ({
|
|
516
|
+
id: op.id,
|
|
517
|
+
label: op.label,
|
|
518
|
+
operationClass: op.operationClass
|
|
519
|
+
})),
|
|
520
|
+
emittedExtensionDirs,
|
|
521
|
+
...preview !== void 0 ? { preview } : {},
|
|
522
|
+
summary: buildAutoBaselinePlanSummary(0, emittedExtensionDirs.length),
|
|
523
|
+
timings: { total: Date.now() - startTime }
|
|
524
|
+
});
|
|
525
|
+
}
|
|
526
|
+
const deltaLeg = await runPlannerLeg(planner, migrations, frameworkComponents, aggregate.app.contract(), fromContract, aggregate.app.spaceId, aggregate, snapshotsImportPathFrom(deltaPackageDir, migrationsDir), resolveImportSpecifier);
|
|
527
|
+
if (!deltaLeg.ok) return notOk(deltaLeg.failure);
|
|
528
|
+
await writePlannedMigrationPackage(deltaPackageDir, fromHash, toStorageHash, deltaTimestamp, deltaLeg.value);
|
|
529
|
+
await writeDestinationSnapshot(toStorageHash);
|
|
530
|
+
await writeContractSnapshot(migrationsDir, fromHash, {
|
|
531
|
+
contractJson: snapshotStartContract.contractJson,
|
|
532
|
+
contractDts: snapshotStartContract.contractDts
|
|
533
|
+
});
|
|
534
|
+
const deltaOps = deltaLeg.value.hasPlaceholders ? [] : deltaLeg.value.plannedOps;
|
|
535
|
+
if (deltaLeg.value.hasPlaceholders) return ok({
|
|
536
|
+
ok: true,
|
|
537
|
+
noOp: false,
|
|
538
|
+
from: fromHash,
|
|
539
|
+
to: toStorageHash,
|
|
540
|
+
dir: relative(process.cwd(), deltaPackageDir),
|
|
541
|
+
baselineDir: relative(process.cwd(), baselinePackageDir),
|
|
542
|
+
operations: [],
|
|
543
|
+
emittedExtensionDirs,
|
|
544
|
+
pendingPlaceholders: true,
|
|
545
|
+
summary: "Planned baseline + migration with placeholder(s) — edit migration.ts then run `node migration.ts` to self-emit",
|
|
546
|
+
timings: { total: Date.now() - startTime }
|
|
547
|
+
});
|
|
548
|
+
const preview = hasOperationPreview(familyInstance) ? familyInstance.toOperationPreview(deltaOps) : void 0;
|
|
549
|
+
return ok({
|
|
550
|
+
ok: true,
|
|
551
|
+
noOp: false,
|
|
552
|
+
from: fromHash,
|
|
553
|
+
to: toStorageHash,
|
|
554
|
+
dir: relative(process.cwd(), deltaPackageDir),
|
|
555
|
+
baselineDir: relative(process.cwd(), baselinePackageDir),
|
|
556
|
+
operations: deltaOps.map((op) => ({
|
|
557
|
+
id: op.id,
|
|
558
|
+
label: op.label,
|
|
559
|
+
operationClass: op.operationClass
|
|
560
|
+
})),
|
|
561
|
+
emittedExtensionDirs,
|
|
562
|
+
...preview !== void 0 ? { preview } : {},
|
|
563
|
+
summary: buildAutoBaselinePlanSummary(deltaOps.length, emittedExtensionDirs.length),
|
|
564
|
+
timings: { total: Date.now() - startTime }
|
|
565
|
+
});
|
|
566
|
+
}
|
|
567
|
+
const timestamp = /* @__PURE__ */ new Date();
|
|
568
|
+
const packageDir = join(appMigrationsDir, formatMigrationDirName(timestamp, options.name ?? "migration"));
|
|
569
|
+
const deltaLeg = await runPlannerLeg(planner, migrations, frameworkComponents, aggregate.app.contract(), fromContract, aggregate.app.spaceId, aggregate, snapshotsImportPathFrom(packageDir, migrationsDir), resolveImportSpecifier);
|
|
570
|
+
if (!deltaLeg.ok) return notOk(deltaLeg.failure);
|
|
571
|
+
await writePlannedMigrationPackage(packageDir, fromHash, toStorageHash, timestamp, deltaLeg.value);
|
|
572
|
+
await writeDestinationSnapshot(toStorageHash);
|
|
573
|
+
if (snapshotStartContract !== null) await writeContractSnapshot(migrationsDir, snapshotStartContract.fromHash, {
|
|
574
|
+
contractJson: snapshotStartContract.contractJson,
|
|
575
|
+
contractDts: snapshotStartContract.contractDts
|
|
576
|
+
});
|
|
577
|
+
if (deltaLeg.value.hasPlaceholders) return ok({
|
|
578
|
+
ok: true,
|
|
579
|
+
noOp: false,
|
|
580
|
+
from: fromHash,
|
|
581
|
+
to: toStorageHash,
|
|
582
|
+
dir: relative(process.cwd(), packageDir),
|
|
583
|
+
operations: [],
|
|
584
|
+
emittedExtensionDirs,
|
|
585
|
+
pendingPlaceholders: true,
|
|
586
|
+
summary: "Planned migration with placeholder(s) — edit migration.ts then run `node migration.ts` to self-emit",
|
|
587
|
+
timings: { total: Date.now() - startTime }
|
|
588
|
+
});
|
|
589
|
+
const plannedOps = deltaLeg.value.plannedOps;
|
|
590
|
+
const preview = hasOperationPreview(familyInstance) ? familyInstance.toOperationPreview(plannedOps) : void 0;
|
|
591
|
+
return ok({
|
|
592
|
+
ok: true,
|
|
593
|
+
noOp: false,
|
|
594
|
+
from: fromHash,
|
|
595
|
+
to: toStorageHash,
|
|
596
|
+
dir: relative(process.cwd(), packageDir),
|
|
597
|
+
operations: plannedOps.map((op) => ({
|
|
598
|
+
id: op.id,
|
|
599
|
+
label: op.label,
|
|
600
|
+
operationClass: op.operationClass
|
|
601
|
+
})),
|
|
602
|
+
emittedExtensionDirs,
|
|
603
|
+
...preview !== void 0 ? { preview } : {},
|
|
604
|
+
summary: buildPlanSummary(plannedOps.length, emittedExtensionDirs.length),
|
|
605
|
+
timings: { total: Date.now() - startTime }
|
|
606
|
+
});
|
|
607
|
+
} catch (error) {
|
|
608
|
+
if (CliStructuredError$1.is(error)) return notOk(error);
|
|
609
|
+
if (MigrationToolsError.is(error)) return notOk(mapMigrationToolsError(error));
|
|
610
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
611
|
+
return notOk(errorUnexpected(message, { why: `Unexpected error during migration plan: ${message}` }));
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
function createMigrationPlanCommand() {
|
|
615
|
+
const command = new Command("plan");
|
|
616
|
+
setCommandDescriptions(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.");
|
|
617
|
+
setCommandExamples(command, [
|
|
618
|
+
"prisma-next migration plan",
|
|
619
|
+
"prisma-next migration plan --name add-users-table",
|
|
620
|
+
"prisma-next migration plan --to <migration-dir>^ --name rollback"
|
|
621
|
+
]);
|
|
622
|
+
addGlobalOptions(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) => {
|
|
623
|
+
const flags = parseGlobalFlagsOrExit(options);
|
|
624
|
+
const startTime = Date.now();
|
|
625
|
+
const ui = createTerminalUI(flags);
|
|
626
|
+
const exitCode = handleResult(await executeMigrationPlanCommand(options, flags, ui, startTime), flags, ui, (planResult) => {
|
|
627
|
+
if (flags.json) ui.output(JSON.stringify(planResult, null, 2));
|
|
628
|
+
else if (!flags.quiet) ui.log(formatMigrationPlanOutput(planResult, flags));
|
|
629
|
+
});
|
|
630
|
+
process.exit(exitCode);
|
|
631
|
+
});
|
|
632
|
+
return command;
|
|
633
|
+
}
|
|
634
|
+
/**
|
|
635
|
+
* Compose the success-line summary so the cross-space side effect
|
|
636
|
+
* (extension-space migration packages materialised on disk during
|
|
637
|
+
* this `plan` run) is visible in the top line — not just in the
|
|
638
|
+
* step log above it.
|
|
639
|
+
*
|
|
640
|
+
* Example outputs:
|
|
641
|
+
* - `Planned 3 operation(s)` (app-space-only project)
|
|
642
|
+
* - `Planned 3 operation(s); materialised 1 extension-space migration` (one extension)
|
|
643
|
+
* - `Planned 3 operation(s); materialised 2 extension-space migrations` (two extensions)
|
|
644
|
+
*
|
|
645
|
+
* Locks AC3 at the summary-line level: a reader of the success line
|
|
646
|
+
* can tell that something happened beyond the app space.
|
|
647
|
+
*/
|
|
648
|
+
function buildPlanSummary(plannedOpsCount, emittedExtensionDirsCount) {
|
|
649
|
+
const base = `Planned ${plannedOpsCount} operation(s)`;
|
|
650
|
+
if (emittedExtensionDirsCount === 0) return base;
|
|
651
|
+
return `${base}; materialised ${emittedExtensionDirsCount} ${emittedExtensionDirsCount === 1 ? "extension-space migration" : "extension-space migrations"}`;
|
|
652
|
+
}
|
|
653
|
+
function buildAutoBaselinePlanSummary(deltaOpsCount, emittedExtensionDirsCount) {
|
|
654
|
+
const base = `Planned baseline + ${deltaOpsCount} operation(s)`;
|
|
655
|
+
if (emittedExtensionDirsCount === 0) return base;
|
|
656
|
+
return `${base}; materialised ${emittedExtensionDirsCount} ${emittedExtensionDirsCount === 1 ? "extension-space migration" : "extension-space migrations"}`;
|
|
657
|
+
}
|
|
658
|
+
function formatMigrationPlanOutput(result, flags) {
|
|
659
|
+
const lines = [];
|
|
660
|
+
const useColor = flags.color !== false;
|
|
661
|
+
const green_ = useColor ? (s) => `\x1b[32m${s}\x1b[0m` : (s) => s;
|
|
662
|
+
const yellow_ = useColor ? (s) => `\x1b[33m${s}\x1b[0m` : (s) => s;
|
|
663
|
+
const dim_ = useColor ? (s) => `\x1b[2m${s}\x1b[0m` : (s) => s;
|
|
664
|
+
function appendEmittedExtensions() {
|
|
665
|
+
if (result.emittedExtensionDirs.length === 0) return;
|
|
666
|
+
lines.push("");
|
|
667
|
+
lines.push(dim_("Emitted extension migrations:"));
|
|
668
|
+
for (const entry of result.emittedExtensionDirs) lines.push(dim_(` ${entry.spaceId} → migrations/${entry.spaceId}/${entry.dirName}`));
|
|
669
|
+
lines.push("");
|
|
670
|
+
lines.push(`Next: review the extension migrations above, then run ${green_("prisma-next migrate")}.`);
|
|
671
|
+
}
|
|
672
|
+
if (result.noOp) {
|
|
673
|
+
lines.push(`${green_("✔")} No changes detected`);
|
|
674
|
+
lines.push(dim_(` from: ${result.from}`));
|
|
675
|
+
lines.push(dim_(` to: ${result.to}`));
|
|
676
|
+
appendEmittedExtensions();
|
|
677
|
+
return lines.join("\n");
|
|
678
|
+
}
|
|
679
|
+
if (result.pendingPlaceholders) {
|
|
680
|
+
lines.push(`${yellow_("⚠")} ${result.summary}`);
|
|
681
|
+
lines.push("");
|
|
682
|
+
lines.push(dim_(`from: ${result.from}`));
|
|
683
|
+
lines.push(dim_(`to: ${result.to}`));
|
|
684
|
+
if (result.dir) lines.push(dim_(`dir: ${result.dir}`));
|
|
685
|
+
lines.push("");
|
|
686
|
+
lines.push("Open migration.ts and replace each `placeholder(...)` call with your actual query.");
|
|
687
|
+
lines.push(`Then run: ${green_(`node ${result.dir ?? "<dir>"}/migration.ts`)}`);
|
|
688
|
+
appendEmittedExtensions();
|
|
689
|
+
return lines.join("\n");
|
|
690
|
+
}
|
|
691
|
+
lines.push(`${green_("✔")} ${result.summary}`);
|
|
692
|
+
lines.push("");
|
|
693
|
+
if (result.operations.length > 0) {
|
|
694
|
+
lines.push(dim_("│"));
|
|
695
|
+
for (let i = 0; i < result.operations.length; i++) {
|
|
696
|
+
const op = result.operations[i];
|
|
697
|
+
const treeChar = i === result.operations.length - 1 ? "└" : "├";
|
|
698
|
+
const destructiveMarker = op.operationClass === "destructive" ? ` ${yellow_("(destructive)")}` : "";
|
|
699
|
+
lines.push(`${dim_(treeChar)}─ ${op.label}${destructiveMarker}`);
|
|
700
|
+
}
|
|
701
|
+
if (result.operations.some((op) => op.operationClass === "destructive")) {
|
|
702
|
+
lines.push("");
|
|
703
|
+
lines.push(`${yellow_("⚠")} This migration contains destructive operations that may cause data loss.`);
|
|
704
|
+
}
|
|
705
|
+
lines.push("");
|
|
706
|
+
}
|
|
707
|
+
lines.push(dim_(`from: ${result.from}`));
|
|
708
|
+
lines.push(dim_(`to: ${result.to}`));
|
|
709
|
+
if (result.baselineDir) lines.push(dim_(`Baseline → ${result.baselineDir}`));
|
|
710
|
+
if (result.dir) lines.push(dim_(`App space → ${result.dir}`));
|
|
711
|
+
for (const entry of result.emittedExtensionDirs) lines.push(dim_(`Extension space ${entry.spaceId} → migrations/${entry.spaceId}/${entry.dirName}`));
|
|
712
|
+
lines.push("");
|
|
713
|
+
const reviewTarget = result.baselineDir !== void 0 && result.dir !== void 0 ? `${result.baselineDir} and ${result.dir}` : result.baselineDir ?? result.dir ?? "<dir>";
|
|
714
|
+
lines.push(`Next: review ${green_(reviewTarget)} if needed, then run ${green_("prisma-next migrate")}.`);
|
|
715
|
+
if (result.preview && result.preview.statements.length > 0) {
|
|
716
|
+
const allSql = result.preview.statements.every((s) => s.language === "sql");
|
|
717
|
+
lines.push("");
|
|
718
|
+
lines.push(dim_(allSql ? "DDL preview" : "Operation preview"));
|
|
719
|
+
lines.push("");
|
|
720
|
+
for (const statement of result.preview.statements) {
|
|
721
|
+
const trimmed = statement.text.trim();
|
|
722
|
+
if (!trimmed) continue;
|
|
723
|
+
const line = statement.language === "sql" && !trimmed.endsWith(";") ? `${trimmed};` : trimmed;
|
|
724
|
+
lines.push(line);
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
if (flags.verbose && result.timings) {
|
|
728
|
+
lines.push("");
|
|
729
|
+
lines.push(dim_(`Total time: ${result.timings.total}ms`));
|
|
730
|
+
}
|
|
731
|
+
return lines.join("\n");
|
|
732
|
+
}
|
|
733
|
+
/**
|
|
734
|
+
* Resolve a migration package by **target contract hash** (`metadata.to`)
|
|
735
|
+
* using exact match or prefix match.
|
|
736
|
+
*
|
|
737
|
+
* Note: matches `metadata.to` (the contract hash this migration produces),
|
|
738
|
+
* not `metadata.migrationHash` (the package's content-addressed identity).
|
|
739
|
+
* Tries exact match first, then prefix match. Returns the matched package on
|
|
740
|
+
* success, or a discriminated failure indicating whether the prefix was
|
|
741
|
+
* ambiguous or simply not found.
|
|
742
|
+
*
|
|
743
|
+
* @internal Exported for testing only.
|
|
744
|
+
*/
|
|
745
|
+
function resolveBundleByPrefix(bundles, needle) {
|
|
746
|
+
const exact = bundles.find((p) => p.metadata.to === needle);
|
|
747
|
+
if (exact) return ok(exact);
|
|
748
|
+
const candidates = bundles.filter((p) => p.metadata.to.startsWith(needle));
|
|
749
|
+
if (candidates.length === 1) return ok(candidates[0]);
|
|
750
|
+
if (candidates.length > 1) return notOk({
|
|
751
|
+
reason: "ambiguous",
|
|
752
|
+
count: candidates.length
|
|
753
|
+
});
|
|
754
|
+
return notOk({ reason: "not-found" });
|
|
755
|
+
}
|
|
756
|
+
//#endregion
|
|
757
|
+
export { formatMigrationPlanOutput as n, resolveBundleByPrefix as r, createMigrationPlanCommand as t };
|
|
758
|
+
|
|
759
|
+
//# sourceMappingURL=migration-plan-q_L84PN1-BWE0LTH6.mjs.map
|