@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,313 @@
|
|
|
1
|
+
import { E as errorMissingFile, S as errorInvalidSlug, T as errorMigrationHashMismatch, _ as errorInvalidManifest, g as errorInvalidJson, j as errorProvidedInvariantsMismatch, m as errorInvalidDestName, t as MigrationToolsError, u as errorDirectoryExists } from "./errors-IpZm1Skp-BH495dRd.mjs";
|
|
2
|
+
import { i as readContractSnapshotJsonTolerant } from "./contract-snapshot-store-sf5nP4mb-MLpG-ihh.mjs";
|
|
3
|
+
import { n as verifyMigrationHash } from "./hash-DH8hl5Rq-BpM2t3Nu.mjs";
|
|
4
|
+
import { t as deriveProvidedInvariants } from "./invariants-lXzy6txi-DAoP4nTE.mjs";
|
|
5
|
+
import { n as MigrationOpsSchema } from "./op-schema-BSVHzEQN-DIWt28D8.mjs";
|
|
6
|
+
import { ifDefined } from "@prisma/orm-framework/utils/defined";
|
|
7
|
+
import { basename, dirname, join, resolve } from "pathe";
|
|
8
|
+
import { copyFile, mkdir, readFile, readdir, rm, stat, writeFile } from "node:fs/promises";
|
|
9
|
+
import { type } from "arktype";
|
|
10
|
+
//#region ../../../1-framework/3-tooling/migration/dist/io-C8TdyBKt.mjs
|
|
11
|
+
const MANIFEST_FILE = "migration.json";
|
|
12
|
+
const OPS_FILE = "ops.json";
|
|
13
|
+
const MAX_SLUG_LENGTH = 64;
|
|
14
|
+
function hasErrnoCode(error, code) {
|
|
15
|
+
return error instanceof Error && error.code === code;
|
|
16
|
+
}
|
|
17
|
+
const MigrationMetadataSchema = type({
|
|
18
|
+
"+": "reject",
|
|
19
|
+
from: "string > 0 | null",
|
|
20
|
+
to: "string",
|
|
21
|
+
migrationHash: "string",
|
|
22
|
+
providedInvariants: "string[]",
|
|
23
|
+
createdAt: "string"
|
|
24
|
+
});
|
|
25
|
+
async function writeMigrationPackage(dir, metadata, ops) {
|
|
26
|
+
await mkdir(dirname(dir), { recursive: true });
|
|
27
|
+
try {
|
|
28
|
+
await mkdir(dir);
|
|
29
|
+
} catch (error) {
|
|
30
|
+
if (hasErrnoCode(error, "EEXIST")) throw errorDirectoryExists(dir);
|
|
31
|
+
throw error;
|
|
32
|
+
}
|
|
33
|
+
await writeFile(join(dir, MANIFEST_FILE), JSON.stringify(metadata, null, 2), { flag: "wx" });
|
|
34
|
+
await writeFile(join(dir, OPS_FILE), JSON.stringify(ops, null, 2), { flag: "wx" });
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Materialise an in-memory {@link MigrationPackage} to a per-space
|
|
38
|
+
* directory on disk.
|
|
39
|
+
*
|
|
40
|
+
* Writes two files under `<targetDir>/<pkg.dirName>/`:
|
|
41
|
+
*
|
|
42
|
+
* - `migration.json` — the manifest (pretty-printed, matches
|
|
43
|
+
* {@link writeMigrationPackage}'s output for byte-for-byte parity with
|
|
44
|
+
* app-space migrations).
|
|
45
|
+
* - `ops.json` — the operation list (pretty-printed).
|
|
46
|
+
*
|
|
47
|
+
* Distinct verb from the lower-level {@link writeMigrationPackage}
|
|
48
|
+
* (which takes constituent `(metadata, ops)`): callers reading
|
|
49
|
+
* `materialise…` know they are persisting a struct-typed package.
|
|
50
|
+
*
|
|
51
|
+
* Overwrite-idempotent: the per-package directory is cleared before
|
|
52
|
+
* each emit, so re-running against the same `targetDir` produces
|
|
53
|
+
* byte-identical contents and never leaves stale files behind. The
|
|
54
|
+
* lower-level {@link writeMigrationPackage} stays strict because the
|
|
55
|
+
* CLI authoring path (`migration plan` / `migration new`) deliberately
|
|
56
|
+
* refuses to clobber an existing authored migration; this helper is
|
|
57
|
+
* the re-emit path that is supposed to converge on a single canonical
|
|
58
|
+
* on-disk shape.
|
|
59
|
+
*
|
|
60
|
+
* The per-space head contract resolves through
|
|
61
|
+
* `<projectMigrationsDir>/snapshots/<hex>/` (written by
|
|
62
|
+
* {@link import('./emit-contract-space-artifacts').emitContractSpaceArtifacts}),
|
|
63
|
+
* not inside the per-package directory. The runner reads only
|
|
64
|
+
* `migration.json` + `ops.json` from each package.
|
|
65
|
+
*/
|
|
66
|
+
async function materialiseMigrationPackage(targetDir, pkg) {
|
|
67
|
+
const dir = join(targetDir, pkg.dirName);
|
|
68
|
+
await rm(dir, {
|
|
69
|
+
recursive: true,
|
|
70
|
+
force: true
|
|
71
|
+
});
|
|
72
|
+
await writeMigrationPackage(dir, pkg.metadata, pkg.ops);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Idempotent variant of {@link materialiseMigrationPackage}: writes the
|
|
76
|
+
* package only if `<targetDir>/<pkg.dirName>/` does not already exist on
|
|
77
|
+
* disk as a directory; returns `{ written: false }` when the package
|
|
78
|
+
* directory is present (no rewrite, no comparison — by-existence skip).
|
|
79
|
+
*
|
|
80
|
+
* Concretely:
|
|
81
|
+
* - existing directory → skip silently, return `{ written: false }`.
|
|
82
|
+
* - missing path → write three files via {@link materialiseMigrationPackage},
|
|
83
|
+
* return `{ written: true }`.
|
|
84
|
+
* - path exists but is not a directory (file/symlink) → treated as
|
|
85
|
+
* missing; {@link materialiseMigrationPackage} will attempt creation
|
|
86
|
+
* and fail with an appropriate OS error.
|
|
87
|
+
* - any other I/O error from `stat` → propagated unchanged.
|
|
88
|
+
*
|
|
89
|
+
* Used by the CLI's `runContractSpaceExtensionMigrationsPass` to
|
|
90
|
+
* materialise extension migration packages into a project's
|
|
91
|
+
* `migrations/<spaceId>/` directory, and by extension-package tests
|
|
92
|
+
* that mirror the same idempotent-rematerialise property locally
|
|
93
|
+
* without taking a CLI dependency.
|
|
94
|
+
*/
|
|
95
|
+
async function materialiseExtensionMigrationPackageIfMissing(targetDir, pkg) {
|
|
96
|
+
if (await directoryExists(join(targetDir, pkg.dirName))) return { written: false };
|
|
97
|
+
await materialiseMigrationPackage(targetDir, pkg);
|
|
98
|
+
return { written: true };
|
|
99
|
+
}
|
|
100
|
+
async function directoryExists(p) {
|
|
101
|
+
try {
|
|
102
|
+
return (await stat(p)).isDirectory();
|
|
103
|
+
} catch (error) {
|
|
104
|
+
if (hasErrnoCode(error, "ENOENT")) return false;
|
|
105
|
+
throw error;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Copy a list of files into `destDir`, optionally renaming each one.
|
|
110
|
+
*
|
|
111
|
+
* The destination directory is created (with `recursive: true`) if it
|
|
112
|
+
* does not already exist. Each source path is copied byte-for-byte into
|
|
113
|
+
* `destDir/<destName>`; missing sources throw `ENOENT`. The helper is
|
|
114
|
+
* intentionally generic: callers own the list of files and the naming
|
|
115
|
+
* convention for the copies.
|
|
116
|
+
*/
|
|
117
|
+
async function copyFilesWithRename(destDir, files) {
|
|
118
|
+
await mkdir(destDir, { recursive: true });
|
|
119
|
+
for (const file of files) {
|
|
120
|
+
if (basename(file.destName) !== file.destName) throw errorInvalidDestName(file.destName);
|
|
121
|
+
await copyFile(file.sourcePath, join(destDir, file.destName));
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
async function writeMigrationMetadata(dir, metadata) {
|
|
125
|
+
await writeFile(join(dir, MANIFEST_FILE), `${JSON.stringify(metadata, null, 2)}\n`);
|
|
126
|
+
}
|
|
127
|
+
async function writeMigrationOps(dir, ops) {
|
|
128
|
+
await writeFile(join(dir, OPS_FILE), `${JSON.stringify(ops, null, 2)}\n`);
|
|
129
|
+
}
|
|
130
|
+
async function readMigrationPackage(dir, options) {
|
|
131
|
+
const absoluteDir = resolve(dir);
|
|
132
|
+
const manifestPath = join(absoluteDir, MANIFEST_FILE);
|
|
133
|
+
const opsPath = join(absoluteDir, OPS_FILE);
|
|
134
|
+
let manifestRaw;
|
|
135
|
+
try {
|
|
136
|
+
manifestRaw = await readFile(manifestPath, "utf-8");
|
|
137
|
+
} catch (error) {
|
|
138
|
+
if (hasErrnoCode(error, "ENOENT")) throw errorMissingFile(MANIFEST_FILE, absoluteDir);
|
|
139
|
+
throw error;
|
|
140
|
+
}
|
|
141
|
+
let opsRaw;
|
|
142
|
+
try {
|
|
143
|
+
opsRaw = await readFile(opsPath, "utf-8");
|
|
144
|
+
} catch (error) {
|
|
145
|
+
if (hasErrnoCode(error, "ENOENT")) throw errorMissingFile(OPS_FILE, absoluteDir);
|
|
146
|
+
throw error;
|
|
147
|
+
}
|
|
148
|
+
let metadata;
|
|
149
|
+
try {
|
|
150
|
+
metadata = JSON.parse(manifestRaw);
|
|
151
|
+
} catch (e) {
|
|
152
|
+
throw errorInvalidJson(manifestPath, e instanceof Error ? e.message : String(e));
|
|
153
|
+
}
|
|
154
|
+
let ops;
|
|
155
|
+
try {
|
|
156
|
+
ops = JSON.parse(opsRaw);
|
|
157
|
+
} catch (e) {
|
|
158
|
+
throw errorInvalidJson(opsPath, e instanceof Error ? e.message : String(e));
|
|
159
|
+
}
|
|
160
|
+
validateMetadata(metadata, manifestPath);
|
|
161
|
+
validateOps(ops, opsPath);
|
|
162
|
+
const derivedInvariants = deriveProvidedInvariants(ops);
|
|
163
|
+
if (!arraysEqual(metadata.providedInvariants, derivedInvariants)) throw errorProvidedInvariantsMismatch(manifestPath, metadata.providedInvariants, derivedInvariants);
|
|
164
|
+
const endContractJson = await readContractSnapshotJsonTolerant(options.migrationsDir, metadata.to);
|
|
165
|
+
const pkg = {
|
|
166
|
+
dirName: basename(absoluteDir),
|
|
167
|
+
dirPath: absoluteDir,
|
|
168
|
+
metadata,
|
|
169
|
+
ops,
|
|
170
|
+
...ifDefined("endContractJson", endContractJson)
|
|
171
|
+
};
|
|
172
|
+
const verification = verifyMigrationHash(pkg);
|
|
173
|
+
if (!verification.ok) throw errorMigrationHashMismatch(absoluteDir, verification.storedHash, verification.computedHash);
|
|
174
|
+
return pkg;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Reads a migration package's manifest and ops without running hash or
|
|
178
|
+
* invariants verification. Returns `null` when the files cannot be read or
|
|
179
|
+
* parsed (i.e. when the package is genuinely unloadable).
|
|
180
|
+
*
|
|
181
|
+
* Used by {@link readMigrationsDir} to retain a package whose hash or
|
|
182
|
+
* invariants diverge from what is stored on disk — the raw content is still
|
|
183
|
+
* useful for display / querying; only integrity is in question.
|
|
184
|
+
*/
|
|
185
|
+
async function readMigrationPackageRaw(dir) {
|
|
186
|
+
const absoluteDir = resolve(dir);
|
|
187
|
+
const manifestPath = join(absoluteDir, MANIFEST_FILE);
|
|
188
|
+
const opsPath = join(absoluteDir, OPS_FILE);
|
|
189
|
+
let manifestRaw;
|
|
190
|
+
try {
|
|
191
|
+
manifestRaw = await readFile(manifestPath, "utf-8");
|
|
192
|
+
} catch {
|
|
193
|
+
return null;
|
|
194
|
+
}
|
|
195
|
+
let opsRaw;
|
|
196
|
+
try {
|
|
197
|
+
opsRaw = await readFile(opsPath, "utf-8");
|
|
198
|
+
} catch {
|
|
199
|
+
return null;
|
|
200
|
+
}
|
|
201
|
+
let metadata;
|
|
202
|
+
try {
|
|
203
|
+
metadata = JSON.parse(manifestRaw);
|
|
204
|
+
} catch {
|
|
205
|
+
return null;
|
|
206
|
+
}
|
|
207
|
+
let ops;
|
|
208
|
+
try {
|
|
209
|
+
ops = JSON.parse(opsRaw);
|
|
210
|
+
} catch {
|
|
211
|
+
return null;
|
|
212
|
+
}
|
|
213
|
+
if (MigrationMetadataSchema(metadata) instanceof type.errors) return null;
|
|
214
|
+
if (MigrationOpsSchema(ops) instanceof type.errors) return null;
|
|
215
|
+
return {
|
|
216
|
+
dirName: basename(absoluteDir),
|
|
217
|
+
dirPath: absoluteDir,
|
|
218
|
+
metadata,
|
|
219
|
+
ops
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
function arraysEqual(a, b) {
|
|
223
|
+
if (a.length !== b.length) return false;
|
|
224
|
+
for (let i = 0; i < a.length; i++) if (a[i] !== b[i]) return false;
|
|
225
|
+
return true;
|
|
226
|
+
}
|
|
227
|
+
function validateMetadata(metadata, filePath) {
|
|
228
|
+
const result = MigrationMetadataSchema(metadata);
|
|
229
|
+
if (result instanceof type.errors) throw errorInvalidManifest(filePath, result.summary);
|
|
230
|
+
}
|
|
231
|
+
function validateOps(ops, filePath) {
|
|
232
|
+
const result = MigrationOpsSchema(ops);
|
|
233
|
+
if (result instanceof type.errors) throw errorInvalidManifest(filePath, result.summary);
|
|
234
|
+
}
|
|
235
|
+
function packageLoadProblemDetailFromError(error) {
|
|
236
|
+
if (MigrationToolsError.is(error)) return error.why;
|
|
237
|
+
if (error instanceof Error) return error.message;
|
|
238
|
+
return String(error);
|
|
239
|
+
}
|
|
240
|
+
async function readMigrationsDir(migrationsRoot, options) {
|
|
241
|
+
let entries;
|
|
242
|
+
try {
|
|
243
|
+
entries = await readdir(migrationsRoot);
|
|
244
|
+
} catch (error) {
|
|
245
|
+
if (hasErrnoCode(error, "ENOENT")) return {
|
|
246
|
+
packages: [],
|
|
247
|
+
problems: []
|
|
248
|
+
};
|
|
249
|
+
throw error;
|
|
250
|
+
}
|
|
251
|
+
const packages = [];
|
|
252
|
+
const problems = [];
|
|
253
|
+
for (const entry of entries.sort()) {
|
|
254
|
+
const entryPath = join(migrationsRoot, entry);
|
|
255
|
+
if (!(await stat(entryPath)).isDirectory()) continue;
|
|
256
|
+
const manifestPath = join(entryPath, MANIFEST_FILE);
|
|
257
|
+
try {
|
|
258
|
+
await stat(manifestPath);
|
|
259
|
+
} catch {
|
|
260
|
+
continue;
|
|
261
|
+
}
|
|
262
|
+
let pkg;
|
|
263
|
+
try {
|
|
264
|
+
pkg = await readMigrationPackage(entryPath, options);
|
|
265
|
+
} catch (error) {
|
|
266
|
+
const dirName = entry;
|
|
267
|
+
if (MigrationToolsError.is(error)) {
|
|
268
|
+
if (error.code === "MIGRATION.HASH_MISMATCH") {
|
|
269
|
+
const details = error.details;
|
|
270
|
+
const rawPkg = await readMigrationPackageRaw(entryPath);
|
|
271
|
+
if (rawPkg !== null) packages.push(rawPkg);
|
|
272
|
+
problems.push({
|
|
273
|
+
kind: "hashMismatch",
|
|
274
|
+
dirName,
|
|
275
|
+
stored: typeof details?.["storedHash"] === "string" ? details["storedHash"] : "",
|
|
276
|
+
computed: typeof details?.["computedHash"] === "string" ? details["computedHash"] : ""
|
|
277
|
+
});
|
|
278
|
+
continue;
|
|
279
|
+
}
|
|
280
|
+
if (error.code === "MIGRATION.PROVIDED_INVARIANTS_MISMATCH") {
|
|
281
|
+
const rawPkg = await readMigrationPackageRaw(entryPath);
|
|
282
|
+
if (rawPkg !== null) packages.push(rawPkg);
|
|
283
|
+
problems.push({
|
|
284
|
+
kind: "providedInvariantsMismatch",
|
|
285
|
+
dirName
|
|
286
|
+
});
|
|
287
|
+
continue;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
problems.push({
|
|
291
|
+
kind: "packageUnloadable",
|
|
292
|
+
dirName,
|
|
293
|
+
detail: packageLoadProblemDetailFromError(error)
|
|
294
|
+
});
|
|
295
|
+
continue;
|
|
296
|
+
}
|
|
297
|
+
packages.push(pkg);
|
|
298
|
+
}
|
|
299
|
+
return {
|
|
300
|
+
packages,
|
|
301
|
+
problems
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
function formatMigrationDirName(timestamp, slug) {
|
|
305
|
+
const sanitized = slug.toLowerCase().replace(/[^a-z0-9]/g, "_").replace(/_+/g, "_").replace(/^_|_$/g, "");
|
|
306
|
+
if (sanitized.length === 0) throw errorInvalidSlug(slug);
|
|
307
|
+
const truncated = sanitized.slice(0, MAX_SLUG_LENGTH);
|
|
308
|
+
return `${timestamp.getUTCFullYear()}${String(timestamp.getUTCMonth() + 1).padStart(2, "0")}${String(timestamp.getUTCDate()).padStart(2, "0")}T${String(timestamp.getUTCHours()).padStart(2, "0")}${String(timestamp.getUTCMinutes()).padStart(2, "0")}_${truncated}`;
|
|
309
|
+
}
|
|
310
|
+
//#endregion
|
|
311
|
+
export { materialiseMigrationPackage as a, writeMigrationMetadata as c, materialiseExtensionMigrationPackageIfMissing as i, writeMigrationOps as l, copyFilesWithRename as n, readMigrationPackage as o, formatMigrationDirName as r, readMigrationsDir as s, MANIFEST_FILE as t, writeMigrationPackage as u };
|
|
312
|
+
|
|
313
|
+
//# sourceMappingURL=io-C8TdyBKt-DloEBi70.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"io-C8TdyBKt-DloEBi70.mjs","names":[],"sources":["../../../../1-framework/3-tooling/migration/dist/io-C8TdyBKt.mjs"],"sourcesContent":["import { E as errorMissingFile, S as errorInvalidSlug, T as errorMigrationHashMismatch, _ as errorInvalidManifest, g as errorInvalidJson, j as errorProvidedInvariantsMismatch, m as errorInvalidDestName, t as MigrationToolsError, u as errorDirectoryExists } from \"./errors-IpZm1Skp.mjs\";\nimport { i as readContractSnapshotJsonTolerant } from \"./contract-snapshot-store-sf5nP4mb.mjs\";\nimport { n as verifyMigrationHash } from \"./hash-DH8hl5Rq.mjs\";\nimport { t as deriveProvidedInvariants } from \"./invariants-lXzy6txi.mjs\";\nimport { n as MigrationOpsSchema } from \"./op-schema-BSVHzEQN.mjs\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { basename, dirname, join, resolve } from \"pathe\";\nimport { copyFile, mkdir, readFile, readdir, rm, stat, writeFile } from \"node:fs/promises\";\nimport { type } from \"arktype\";\n//#region src/io.ts\nconst MANIFEST_FILE = \"migration.json\";\nconst OPS_FILE = \"ops.json\";\nconst MAX_SLUG_LENGTH = 64;\nfunction hasErrnoCode(error, code) {\n\treturn error instanceof Error && error.code === code;\n}\nconst MigrationMetadataSchema = type({\n\t\"+\": \"reject\",\n\tfrom: \"string > 0 | null\",\n\tto: \"string\",\n\tmigrationHash: \"string\",\n\tprovidedInvariants: \"string[]\",\n\tcreatedAt: \"string\"\n});\nasync function writeMigrationPackage(dir, metadata, ops) {\n\tawait mkdir(dirname(dir), { recursive: true });\n\ttry {\n\t\tawait mkdir(dir);\n\t} catch (error) {\n\t\tif (hasErrnoCode(error, \"EEXIST\")) throw errorDirectoryExists(dir);\n\t\tthrow error;\n\t}\n\tawait writeFile(join(dir, MANIFEST_FILE), JSON.stringify(metadata, null, 2), { flag: \"wx\" });\n\tawait writeFile(join(dir, OPS_FILE), JSON.stringify(ops, null, 2), { flag: \"wx\" });\n}\n/**\n* Materialise an in-memory {@link MigrationPackage} to a per-space\n* directory on disk.\n*\n* Writes two files under `<targetDir>/<pkg.dirName>/`:\n*\n* - `migration.json` — the manifest (pretty-printed, matches\n* {@link writeMigrationPackage}'s output for byte-for-byte parity with\n* app-space migrations).\n* - `ops.json` — the operation list (pretty-printed).\n*\n* Distinct verb from the lower-level {@link writeMigrationPackage}\n* (which takes constituent `(metadata, ops)`): callers reading\n* `materialise…` know they are persisting a struct-typed package.\n*\n* Overwrite-idempotent: the per-package directory is cleared before\n* each emit, so re-running against the same `targetDir` produces\n* byte-identical contents and never leaves stale files behind. The\n* lower-level {@link writeMigrationPackage} stays strict because the\n* CLI authoring path (`migration plan` / `migration new`) deliberately\n* refuses to clobber an existing authored migration; this helper is\n* the re-emit path that is supposed to converge on a single canonical\n* on-disk shape.\n*\n* The per-space head contract resolves through\n* `<projectMigrationsDir>/snapshots/<hex>/` (written by\n* {@link import('./emit-contract-space-artifacts').emitContractSpaceArtifacts}),\n* not inside the per-package directory. The runner reads only\n* `migration.json` + `ops.json` from each package.\n*/\nasync function materialiseMigrationPackage(targetDir, pkg) {\n\tconst dir = join(targetDir, pkg.dirName);\n\tawait rm(dir, {\n\t\trecursive: true,\n\t\tforce: true\n\t});\n\tawait writeMigrationPackage(dir, pkg.metadata, pkg.ops);\n}\n/**\n* Idempotent variant of {@link materialiseMigrationPackage}: writes the\n* package only if `<targetDir>/<pkg.dirName>/` does not already exist on\n* disk as a directory; returns `{ written: false }` when the package\n* directory is present (no rewrite, no comparison — by-existence skip).\n*\n* Concretely:\n* - existing directory → skip silently, return `{ written: false }`.\n* - missing path → write three files via {@link materialiseMigrationPackage},\n* return `{ written: true }`.\n* - path exists but is not a directory (file/symlink) → treated as\n* missing; {@link materialiseMigrationPackage} will attempt creation\n* and fail with an appropriate OS error.\n* - any other I/O error from `stat` → propagated unchanged.\n*\n* Used by the CLI's `runContractSpaceExtensionMigrationsPass` to\n* materialise extension migration packages into a project's\n* `migrations/<spaceId>/` directory, and by extension-package tests\n* that mirror the same idempotent-rematerialise property locally\n* without taking a CLI dependency.\n*/\nasync function materialiseExtensionMigrationPackageIfMissing(targetDir, pkg) {\n\tif (await directoryExists(join(targetDir, pkg.dirName))) return { written: false };\n\tawait materialiseMigrationPackage(targetDir, pkg);\n\treturn { written: true };\n}\nasync function directoryExists(p) {\n\ttry {\n\t\treturn (await stat(p)).isDirectory();\n\t} catch (error) {\n\t\tif (hasErrnoCode(error, \"ENOENT\")) return false;\n\t\tthrow error;\n\t}\n}\n/**\n* Copy a list of files into `destDir`, optionally renaming each one.\n*\n* The destination directory is created (with `recursive: true`) if it\n* does not already exist. Each source path is copied byte-for-byte into\n* `destDir/<destName>`; missing sources throw `ENOENT`. The helper is\n* intentionally generic: callers own the list of files and the naming\n* convention for the copies.\n*/\nasync function copyFilesWithRename(destDir, files) {\n\tawait mkdir(destDir, { recursive: true });\n\tfor (const file of files) {\n\t\tif (basename(file.destName) !== file.destName) throw errorInvalidDestName(file.destName);\n\t\tawait copyFile(file.sourcePath, join(destDir, file.destName));\n\t}\n}\nasync function writeMigrationMetadata(dir, metadata) {\n\tawait writeFile(join(dir, MANIFEST_FILE), `${JSON.stringify(metadata, null, 2)}\\n`);\n}\nasync function writeMigrationOps(dir, ops) {\n\tawait writeFile(join(dir, OPS_FILE), `${JSON.stringify(ops, null, 2)}\\n`);\n}\nasync function readMigrationPackage(dir, options) {\n\tconst absoluteDir = resolve(dir);\n\tconst manifestPath = join(absoluteDir, MANIFEST_FILE);\n\tconst opsPath = join(absoluteDir, OPS_FILE);\n\tlet manifestRaw;\n\ttry {\n\t\tmanifestRaw = await readFile(manifestPath, \"utf-8\");\n\t} catch (error) {\n\t\tif (hasErrnoCode(error, \"ENOENT\")) throw errorMissingFile(MANIFEST_FILE, absoluteDir);\n\t\tthrow error;\n\t}\n\tlet opsRaw;\n\ttry {\n\t\topsRaw = await readFile(opsPath, \"utf-8\");\n\t} catch (error) {\n\t\tif (hasErrnoCode(error, \"ENOENT\")) throw errorMissingFile(OPS_FILE, absoluteDir);\n\t\tthrow error;\n\t}\n\tlet metadata;\n\ttry {\n\t\tmetadata = JSON.parse(manifestRaw);\n\t} catch (e) {\n\t\tthrow errorInvalidJson(manifestPath, e instanceof Error ? e.message : String(e));\n\t}\n\tlet ops;\n\ttry {\n\t\tops = JSON.parse(opsRaw);\n\t} catch (e) {\n\t\tthrow errorInvalidJson(opsPath, e instanceof Error ? e.message : String(e));\n\t}\n\tvalidateMetadata(metadata, manifestPath);\n\tvalidateOps(ops, opsPath);\n\tconst derivedInvariants = deriveProvidedInvariants(ops);\n\tif (!arraysEqual(metadata.providedInvariants, derivedInvariants)) throw errorProvidedInvariantsMismatch(manifestPath, metadata.providedInvariants, derivedInvariants);\n\tconst endContractJson = await readContractSnapshotJsonTolerant(options.migrationsDir, metadata.to);\n\tconst pkg = {\n\t\tdirName: basename(absoluteDir),\n\t\tdirPath: absoluteDir,\n\t\tmetadata,\n\t\tops,\n\t\t...ifDefined(\"endContractJson\", endContractJson)\n\t};\n\tconst verification = verifyMigrationHash(pkg);\n\tif (!verification.ok) throw errorMigrationHashMismatch(absoluteDir, verification.storedHash, verification.computedHash);\n\treturn pkg;\n}\n/**\n* Reads a migration package's manifest and ops without running hash or\n* invariants verification. Returns `null` when the files cannot be read or\n* parsed (i.e. when the package is genuinely unloadable).\n*\n* Used by {@link readMigrationsDir} to retain a package whose hash or\n* invariants diverge from what is stored on disk — the raw content is still\n* useful for display / querying; only integrity is in question.\n*/\nasync function readMigrationPackageRaw(dir) {\n\tconst absoluteDir = resolve(dir);\n\tconst manifestPath = join(absoluteDir, MANIFEST_FILE);\n\tconst opsPath = join(absoluteDir, OPS_FILE);\n\tlet manifestRaw;\n\ttry {\n\t\tmanifestRaw = await readFile(manifestPath, \"utf-8\");\n\t} catch {\n\t\treturn null;\n\t}\n\tlet opsRaw;\n\ttry {\n\t\topsRaw = await readFile(opsPath, \"utf-8\");\n\t} catch {\n\t\treturn null;\n\t}\n\tlet metadata;\n\ttry {\n\t\tmetadata = JSON.parse(manifestRaw);\n\t} catch {\n\t\treturn null;\n\t}\n\tlet ops;\n\ttry {\n\t\tops = JSON.parse(opsRaw);\n\t} catch {\n\t\treturn null;\n\t}\n\tif (MigrationMetadataSchema(metadata) instanceof type.errors) return null;\n\tif (MigrationOpsSchema(ops) instanceof type.errors) return null;\n\treturn {\n\t\tdirName: basename(absoluteDir),\n\t\tdirPath: absoluteDir,\n\t\tmetadata,\n\t\tops\n\t};\n}\nfunction arraysEqual(a, b) {\n\tif (a.length !== b.length) return false;\n\tfor (let i = 0; i < a.length; i++) if (a[i] !== b[i]) return false;\n\treturn true;\n}\nfunction validateMetadata(metadata, filePath) {\n\tconst result = MigrationMetadataSchema(metadata);\n\tif (result instanceof type.errors) throw errorInvalidManifest(filePath, result.summary);\n}\nfunction validateOps(ops, filePath) {\n\tconst result = MigrationOpsSchema(ops);\n\tif (result instanceof type.errors) throw errorInvalidManifest(filePath, result.summary);\n}\nfunction packageLoadProblemDetailFromError(error) {\n\tif (MigrationToolsError.is(error)) return error.why;\n\tif (error instanceof Error) return error.message;\n\treturn String(error);\n}\nasync function readMigrationsDir(migrationsRoot, options) {\n\tlet entries;\n\ttry {\n\t\tentries = await readdir(migrationsRoot);\n\t} catch (error) {\n\t\tif (hasErrnoCode(error, \"ENOENT\")) return {\n\t\t\tpackages: [],\n\t\t\tproblems: []\n\t\t};\n\t\tthrow error;\n\t}\n\tconst packages = [];\n\tconst problems = [];\n\tfor (const entry of entries.sort()) {\n\t\tconst entryPath = join(migrationsRoot, entry);\n\t\tif (!(await stat(entryPath)).isDirectory()) continue;\n\t\tconst manifestPath = join(entryPath, MANIFEST_FILE);\n\t\ttry {\n\t\t\tawait stat(manifestPath);\n\t\t} catch {\n\t\t\tcontinue;\n\t\t}\n\t\tlet pkg;\n\t\ttry {\n\t\t\tpkg = await readMigrationPackage(entryPath, options);\n\t\t} catch (error) {\n\t\t\tconst dirName = entry;\n\t\t\tif (MigrationToolsError.is(error)) {\n\t\t\t\tif (error.code === \"MIGRATION.HASH_MISMATCH\") {\n\t\t\t\t\tconst details = error.details;\n\t\t\t\t\tconst rawPkg = await readMigrationPackageRaw(entryPath);\n\t\t\t\t\tif (rawPkg !== null) packages.push(rawPkg);\n\t\t\t\t\tproblems.push({\n\t\t\t\t\t\tkind: \"hashMismatch\",\n\t\t\t\t\t\tdirName,\n\t\t\t\t\t\tstored: typeof details?.[\"storedHash\"] === \"string\" ? details[\"storedHash\"] : \"\",\n\t\t\t\t\t\tcomputed: typeof details?.[\"computedHash\"] === \"string\" ? details[\"computedHash\"] : \"\"\n\t\t\t\t\t});\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tif (error.code === \"MIGRATION.PROVIDED_INVARIANTS_MISMATCH\") {\n\t\t\t\t\tconst rawPkg = await readMigrationPackageRaw(entryPath);\n\t\t\t\t\tif (rawPkg !== null) packages.push(rawPkg);\n\t\t\t\t\tproblems.push({\n\t\t\t\t\t\tkind: \"providedInvariantsMismatch\",\n\t\t\t\t\t\tdirName\n\t\t\t\t\t});\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\t\t\tproblems.push({\n\t\t\t\tkind: \"packageUnloadable\",\n\t\t\t\tdirName,\n\t\t\t\tdetail: packageLoadProblemDetailFromError(error)\n\t\t\t});\n\t\t\tcontinue;\n\t\t}\n\t\tpackages.push(pkg);\n\t}\n\treturn {\n\t\tpackages,\n\t\tproblems\n\t};\n}\nfunction formatMigrationDirName(timestamp, slug) {\n\tconst sanitized = slug.toLowerCase().replace(/[^a-z0-9]/g, \"_\").replace(/_+/g, \"_\").replace(/^_|_$/g, \"\");\n\tif (sanitized.length === 0) throw errorInvalidSlug(slug);\n\tconst truncated = sanitized.slice(0, MAX_SLUG_LENGTH);\n\treturn `${timestamp.getUTCFullYear()}${String(timestamp.getUTCMonth() + 1).padStart(2, \"0\")}${String(timestamp.getUTCDate()).padStart(2, \"0\")}T${String(timestamp.getUTCHours()).padStart(2, \"0\")}${String(timestamp.getUTCMinutes()).padStart(2, \"0\")}_${truncated}`;\n}\n//#endregion\nexport { materialiseMigrationPackage as a, writeMigrationMetadata as c, materialiseExtensionMigrationPackageIfMissing as i, writeMigrationOps as l, copyFilesWithRename as n, readMigrationPackage as o, formatMigrationDirName as r, readMigrationsDir as s, MANIF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 -0,0 +1 @@
|
|
|
1
|
+
import "./io-sr4CO9_t-C3eV_kn-.mjs";
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { n as OnDiskMigrationPackage, t as MigrationOps } from "./package-CfWiDNrr-ZR4HM_Iz.mjs";
|
|
2
|
+
import { MigrationMetadata, MigrationPackage } from "@prisma/orm-framework/components/control";
|
|
3
|
+
//#region ../../../1-framework/3-tooling/migration/dist/io-sr4CO9_t.d.mts
|
|
4
|
+
//#region src/io.d.ts
|
|
5
|
+
interface ReadMigrationPackageOptions {
|
|
6
|
+
readonly migrationsDir: string;
|
|
7
|
+
}
|
|
8
|
+
declare function writeMigrationPackage(dir: string, metadata: MigrationMetadata, ops: MigrationOps): Promise<void>;
|
|
9
|
+
/**
|
|
10
|
+
* Materialise an in-memory {@link MigrationPackage} to a per-space
|
|
11
|
+
* directory on disk.
|
|
12
|
+
*
|
|
13
|
+
* Writes two files under `<targetDir>/<pkg.dirName>/`:
|
|
14
|
+
*
|
|
15
|
+
* - `migration.json` — the manifest (pretty-printed, matches
|
|
16
|
+
* {@link writeMigrationPackage}'s output for byte-for-byte parity with
|
|
17
|
+
* app-space migrations).
|
|
18
|
+
* - `ops.json` — the operation list (pretty-printed).
|
|
19
|
+
*
|
|
20
|
+
* Distinct verb from the lower-level {@link writeMigrationPackage}
|
|
21
|
+
* (which takes constituent `(metadata, ops)`): callers reading
|
|
22
|
+
* `materialise…` know they are persisting a struct-typed package.
|
|
23
|
+
*
|
|
24
|
+
* Overwrite-idempotent: the per-package directory is cleared before
|
|
25
|
+
* each emit, so re-running against the same `targetDir` produces
|
|
26
|
+
* byte-identical contents and never leaves stale files behind. The
|
|
27
|
+
* lower-level {@link writeMigrationPackage} stays strict because the
|
|
28
|
+
* CLI authoring path (`migration plan` / `migration new`) deliberately
|
|
29
|
+
* refuses to clobber an existing authored migration; this helper is
|
|
30
|
+
* the re-emit path that is supposed to converge on a single canonical
|
|
31
|
+
* on-disk shape.
|
|
32
|
+
*
|
|
33
|
+
* The per-space head contract resolves through
|
|
34
|
+
* `<projectMigrationsDir>/snapshots/<hex>/` (written by
|
|
35
|
+
* {@link import('./emit-contract-space-artifacts').emitContractSpaceArtifacts}),
|
|
36
|
+
* not inside the per-package directory. The runner reads only
|
|
37
|
+
* `migration.json` + `ops.json` from each package.
|
|
38
|
+
*/
|
|
39
|
+
declare function materialiseMigrationPackage(targetDir: string, pkg: MigrationPackage): Promise<void>;
|
|
40
|
+
/**
|
|
41
|
+
* Idempotent variant of {@link materialiseMigrationPackage}: writes the
|
|
42
|
+
* package only if `<targetDir>/<pkg.dirName>/` does not already exist on
|
|
43
|
+
* disk as a directory; returns `{ written: false }` when the package
|
|
44
|
+
* directory is present (no rewrite, no comparison — by-existence skip).
|
|
45
|
+
*
|
|
46
|
+
* Concretely:
|
|
47
|
+
* - existing directory → skip silently, return `{ written: false }`.
|
|
48
|
+
* - missing path → write three files via {@link materialiseMigrationPackage},
|
|
49
|
+
* return `{ written: true }`.
|
|
50
|
+
* - path exists but is not a directory (file/symlink) → treated as
|
|
51
|
+
* missing; {@link materialiseMigrationPackage} will attempt creation
|
|
52
|
+
* and fail with an appropriate OS error.
|
|
53
|
+
* - any other I/O error from `stat` → propagated unchanged.
|
|
54
|
+
*
|
|
55
|
+
* Used by the CLI's `runContractSpaceExtensionMigrationsPass` to
|
|
56
|
+
* materialise extension migration packages into a project's
|
|
57
|
+
* `migrations/<spaceId>/` directory, and by extension-package tests
|
|
58
|
+
* that mirror the same idempotent-rematerialise property locally
|
|
59
|
+
* without taking a CLI dependency.
|
|
60
|
+
*/
|
|
61
|
+
declare function materialiseExtensionMigrationPackageIfMissing(targetDir: string, pkg: MigrationPackage): Promise<{
|
|
62
|
+
readonly written: boolean;
|
|
63
|
+
}>;
|
|
64
|
+
/**
|
|
65
|
+
* Copy a list of files into `destDir`, optionally renaming each one.
|
|
66
|
+
*
|
|
67
|
+
* The destination directory is created (with `recursive: true`) if it
|
|
68
|
+
* does not already exist. Each source path is copied byte-for-byte into
|
|
69
|
+
* `destDir/<destName>`; missing sources throw `ENOENT`. The helper is
|
|
70
|
+
* intentionally generic: callers own the list of files and the naming
|
|
71
|
+
* convention for the copies.
|
|
72
|
+
*/
|
|
73
|
+
declare function copyFilesWithRename(destDir: string, files: readonly {
|
|
74
|
+
readonly sourcePath: string;
|
|
75
|
+
readonly destName: string;
|
|
76
|
+
}[]): Promise<void>;
|
|
77
|
+
declare function writeMigrationMetadata(dir: string, metadata: MigrationMetadata): Promise<void>;
|
|
78
|
+
declare function writeMigrationOps(dir: string, ops: MigrationOps): Promise<void>;
|
|
79
|
+
declare function readMigrationPackage(dir: string, options: ReadMigrationPackageOptions): Promise<OnDiskMigrationPackage>;
|
|
80
|
+
/**
|
|
81
|
+
* A per-package load-time problem returned by {@link readMigrationsDir}.
|
|
82
|
+
*
|
|
83
|
+
* Three variants, matching the relocated throws from the load path:
|
|
84
|
+
*
|
|
85
|
+
* - `hashMismatch` — stored `migrationHash` differs from the recomputed value.
|
|
86
|
+
* The package is **retained** in the returned `packages` array.
|
|
87
|
+
* - `providedInvariantsMismatch` — `migration.json` declares different
|
|
88
|
+
* `providedInvariants` than `ops.json` implies. The package is **retained**.
|
|
89
|
+
* - `packageUnloadable` — the manifest is missing, unparseable, or schema-
|
|
90
|
+
* invalid. The package is **omitted** from `packages`.
|
|
91
|
+
*
|
|
92
|
+
* Callers that need the `spaceId` context (e.g. the aggregate loader) attach
|
|
93
|
+
* it when converting to {@link import('./integrity-violation').IntegrityViolation}.
|
|
94
|
+
*/
|
|
95
|
+
type PackageLoadProblem = {
|
|
96
|
+
readonly kind: 'hashMismatch';
|
|
97
|
+
readonly dirName: string;
|
|
98
|
+
readonly stored: string;
|
|
99
|
+
readonly computed: string;
|
|
100
|
+
} | {
|
|
101
|
+
readonly kind: 'providedInvariantsMismatch';
|
|
102
|
+
readonly dirName: string;
|
|
103
|
+
} | {
|
|
104
|
+
readonly kind: 'packageUnloadable';
|
|
105
|
+
readonly dirName: string;
|
|
106
|
+
readonly detail: string;
|
|
107
|
+
};
|
|
108
|
+
/**
|
|
109
|
+
* Result returned by {@link readMigrationsDir}.
|
|
110
|
+
*
|
|
111
|
+
* - `packages` — every package that could be read; hash-mismatched and
|
|
112
|
+
* invariants-mismatched packages are included here (the problem is
|
|
113
|
+
* represented rather than fatal).
|
|
114
|
+
* - `problems` — one entry per package that had a load-time issue.
|
|
115
|
+
* `packageUnloadable` entries are **not** in `packages`.
|
|
116
|
+
*/
|
|
117
|
+
interface ReadMigrationsDirResult {
|
|
118
|
+
readonly packages: readonly OnDiskMigrationPackage[];
|
|
119
|
+
readonly problems: readonly PackageLoadProblem[];
|
|
120
|
+
}
|
|
121
|
+
declare function readMigrationsDir(migrationsRoot: string, options: ReadMigrationPackageOptions): Promise<ReadMigrationsDirResult>;
|
|
122
|
+
declare function formatMigrationDirName(timestamp: Date, slug: string): string;
|
|
123
|
+
//#endregion
|
|
124
|
+
export { materialiseExtensionMigrationPackageIfMissing as a, readMigrationsDir as c, writeMigrationPackage as d, formatMigrationDirName as i, writeMigrationMetadata as l, ReadMigrationsDirResult as n, materialiseMigrationPackage as o, copyFilesWithRename as r, readMigrationPackage as s, PackageLoadProblem as t, writeMigrationOps as u };
|
|
125
|
+
//# sourceMappingURL=io-sr4CO9_t-C3eV_kn-.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"io-sr4CO9_t-C3eV_kn-.d.mts","names":[],"sources":["../../../../1-framework/3-tooling/migration/dist/io-sr4CO9_t.d.mts"],"mappings":";;;;UAGU;WACC;;iBAEM,sBAAsB,aAAa,UAAU,mBAAmB,KAAK,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA+BpF,4BAA4B,mBAAmB,KAAK,mBAAmB;;;;;;;;;;;;;;;;;;;;;;iBAsBvE,8CAA8C,mBAAmB,KAAK,mBAAmB;WAC/F;;;;;;;;;;;iBAWM,oBAAoB,iBAAiB;WAC3C;WACA;MACL;iBACW,uBAAuB,aAAa,UAAU,oBAAoB;iBAClE,kBAAkB,aAAa,KAAK,eAAe;iBACnD,qBAAqB,aAAa,SAAS,8BAA8B,QAAQ;;;;;;;;;;;;;;;;KAgB7F;WACM;WACA;WACA;WACA;;WAEA;WACA;;WAEA;WACA;WACA;;;;;;;;;;;UAWD;WACC,mBAAmB;WACnB,mBAAmB;;iBAEb,kBAAkB,wBAAwB,SAAS,8BAA8B,QAAQ;iBACzF,uBAAuB,WAAW,MAAM"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
//#region ../../../1-framework/3-tooling/migration/dist/exports/ledger-origin.d.mts
|
|
2
|
+
//#region src/ledger-origin.d.ts
|
|
3
|
+
declare function ledgerOriginFromStored(originCoreHash: string | null): string | null;
|
|
4
|
+
//#endregion
|
|
5
|
+
export { ledgerOriginFromStored as t };
|
|
6
|
+
//# sourceMappingURL=ledger-origin-BGRN77Oy.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ledger-origin-BGRN77Oy.d.mts","names":[],"sources":["../../../../1-framework/3-tooling/migration/dist/exports/ledger-origin.d.mts"],"mappings":";;iBACiB,uBAAuB"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
//#region ../../../1-framework/3-tooling/migration/dist/exports/ledger-origin.mjs
|
|
2
|
+
function ledgerOriginFromStored(originCoreHash) {
|
|
3
|
+
if (originCoreHash === null || originCoreHash === "" || originCoreHash === "empty") return null;
|
|
4
|
+
return originCoreHash;
|
|
5
|
+
}
|
|
6
|
+
//#endregion
|
|
7
|
+
export { ledgerOriginFromStored as t };
|
|
8
|
+
|
|
9
|
+
//# sourceMappingURL=ledger-origin-D7PN4Fon.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ledger-origin-D7PN4Fon.mjs","names":[],"sources":["../../../../1-framework/3-tooling/migration/dist/exports/ledger-origin.mjs"],"sourcesContent":["import \"../constants-CM-w38DQ.mjs\";\n//#region src/ledger-origin.ts\nfunction ledgerOriginFromStored(originCoreHash) {\n\tif (originCoreHash === null || originCoreHash === \"\" || originCoreHash === \"empty\") return null;\n\treturn originCoreHash;\n}\n//#endregion\nexport { ledgerOriginFromStored };\n\n//# sourceMappingURL=ledger-origin.mjs.map"],"mappings":";AAEA,SAAS,uBAAuB,gBAAgB;CAC/C,IAAI,mBAAmB,QAAQ,mBAAmB,MAAM,mBAAmB,SAAS,OAAO;CAC3F,OAAO;AACR"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "./metadata-2nbOAGsV-uYNeq2Cp.mjs";
|