@prisma/orm-toolchain 0.16.0-dev.36
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-CcG-fB8r-CDs5C9vt.mjs +597 -0
- package/dist/migration-check-CcG-fB8r-CDs5C9vt.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-CFlzlRmu-DewBN8Ys.mjs +444 -0
- package/dist/migration-status-CFlzlRmu-DewBN8Ys.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-CeGMYFYX-h3OcU__O.d.mts +192 -0
- package/dist/schemas-CeGMYFYX-h3OcU__O.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 +127 -0
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { t as MigrationMetadata$1 } from "./metadata-2nbOAGsV-uYNeq2Cp.mjs";
|
|
2
|
+
import { ControlStack, MigrationPlan, MigrationPlanOperation } from "@prisma/orm-framework/components/control";
|
|
3
|
+
import { Contract } from "@prisma/orm-framework/contract/types";
|
|
4
|
+
//#region ../../../1-framework/3-tooling/migration/dist/exports/migration.d.mts
|
|
5
|
+
//#region src/migration-base.d.ts
|
|
6
|
+
interface MigrationMeta {
|
|
7
|
+
readonly from: string | null;
|
|
8
|
+
readonly to: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Base class for migrations.
|
|
12
|
+
*
|
|
13
|
+
* A `Migration` subclass is itself a `MigrationPlan`: CLI commands and the
|
|
14
|
+
* runner can consume it directly via `targetId`, `operations`, `origin`, and
|
|
15
|
+
* `destination`.
|
|
16
|
+
*
|
|
17
|
+
* The from/to identities come from `describe()`. A migration provides them in
|
|
18
|
+
* one of two ways:
|
|
19
|
+
* - **Contract-derived (default):** assign the `contract.json` imports from
|
|
20
|
+
* the snapshot store (`migrations/snapshots/<hex>/contract.json`) to
|
|
21
|
+
* `startContractJson` / `endContractJson`; the concrete `describe()` below
|
|
22
|
+
* derives `to`/`from` from their
|
|
23
|
+
* `storage.storageHash`. The family bases additionally expose typed view
|
|
24
|
+
* getters (`startContract` / `endContract`) over the same JSON.
|
|
25
|
+
* - **Override (e.g. extension migrations that carry no contract):** override
|
|
26
|
+
* `describe()` directly; the override wins and the JSON fields are unused.
|
|
27
|
+
*
|
|
28
|
+
* The `Start` / `End` generics carry each migration's precise contract types so
|
|
29
|
+
* the family-base view getters resolve to fully-typed views.
|
|
30
|
+
*/
|
|
31
|
+
declare abstract class Migration<_TOperation extends MigrationPlanOperation = MigrationPlanOperation, TFamilyId extends string = string, TTargetId extends string = string, _Start extends Contract = Contract, _End extends Contract = Contract> implements MigrationPlan {
|
|
32
|
+
abstract readonly targetId: string;
|
|
33
|
+
/**
|
|
34
|
+
* The migration's end-state contract JSON (the `contract.json` import from
|
|
35
|
+
* the snapshot store). When set, the derived `describe()` reads `to` from its
|
|
36
|
+
* `storage.storageHash`. Family bases build the typed `endContract` view from
|
|
37
|
+
* it. Optional so `describe()`-overriding migrations (no contract) compile.
|
|
38
|
+
*
|
|
39
|
+
* Typed with a plain `storageHash: string`, not the branded
|
|
40
|
+
* `StorageHashBase`, so a raw `contract.json` import — whose `storageHash`
|
|
41
|
+
* is an untyped string literal — is assignable without a cast. The full
|
|
42
|
+
* `Start`/`End` contract typing is applied downstream in the family bases'
|
|
43
|
+
* view getters (via `<Family>ContractView.fromJson<…>`).
|
|
44
|
+
*/
|
|
45
|
+
readonly endContractJson?: {
|
|
46
|
+
readonly storage: {
|
|
47
|
+
readonly storageHash: string;
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* The migration's start-state contract JSON (the `contract.json` import
|
|
52
|
+
* from the snapshot store). Absent for a baseline migration (`from`
|
|
53
|
+
* derives to `null`). Family bases build the typed `startContract` view from
|
|
54
|
+
* it.
|
|
55
|
+
*/
|
|
56
|
+
readonly startContractJson?: {
|
|
57
|
+
readonly storage: {
|
|
58
|
+
readonly storageHash: string;
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Assembled `ControlStack` injected by the orchestrator (`runMigration`).
|
|
63
|
+
*
|
|
64
|
+
* Subclasses (e.g. `PostgresMigration`) read the stack to materialize their
|
|
65
|
+
* adapter once per instance. Optional at the abstract level so unit tests can
|
|
66
|
+
* construct `Migration` instances purely for `operations` / `describe`
|
|
67
|
+
* assertions without needing a real stack; concrete subclasses that need the
|
|
68
|
+
* stack at runtime should narrow the parameter to required.
|
|
69
|
+
*/
|
|
70
|
+
protected readonly stack: ControlStack<TFamilyId, TTargetId> | undefined;
|
|
71
|
+
constructor(stack?: ControlStack<TFamilyId, TTargetId>);
|
|
72
|
+
/**
|
|
73
|
+
* Ordered list of operations this migration performs.
|
|
74
|
+
*
|
|
75
|
+
* Implemented as a getter so that subclasses can either precompute the list
|
|
76
|
+
* in their constructor or build it lazily per access. Entries may be Promises
|
|
77
|
+
* when the target requires async codec resolution (e.g. DDL literal defaults).
|
|
78
|
+
*/
|
|
79
|
+
abstract get operations(): readonly (MigrationPlanOperation | Promise<MigrationPlanOperation>)[];
|
|
80
|
+
/**
|
|
81
|
+
* Metadata inputs used to build `migration.json` and to derive the plan's
|
|
82
|
+
* origin/destination identities.
|
|
83
|
+
*
|
|
84
|
+
* Default derivation: `to = endContractJson.storage.storageHash`,
|
|
85
|
+
* `from = startContractJson?.storage.storageHash ?? null`. A migration that
|
|
86
|
+
* carries no contract JSON (e.g. an extension migration) must override this;
|
|
87
|
+
* otherwise it throws, since `migration.json` requires a `to` identity.
|
|
88
|
+
*/
|
|
89
|
+
describe(): MigrationMeta;
|
|
90
|
+
get origin(): {
|
|
91
|
+
readonly storageHash: string;
|
|
92
|
+
} | null;
|
|
93
|
+
get destination(): {
|
|
94
|
+
readonly storageHash: string;
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Lazy-memoized `endContract` / `startContract` view accessors, one instance
|
|
99
|
+
* held per migration. Each target base (`MongoMigration`, `SqliteMigration`,
|
|
100
|
+
* `PostgresMigration`) creates one `MigrationContractViews` field from
|
|
101
|
+
* `this` — passing its own `<Family>ContractView.fromJson<…>` as `fromJson`
|
|
102
|
+
* and a name for error messages — and forwards its
|
|
103
|
+
* `endContract`/`startContract` getters to it.
|
|
104
|
+
*
|
|
105
|
+
* `endContract` throws `MIGRATION.CONTRACT_VIEW_MISSING` when the migration
|
|
106
|
+
* has no `endContractJson` (mirrors `describe()`'s own requirement).
|
|
107
|
+
* `startContract` returns `null` for a baseline migration (no
|
|
108
|
+
* `startContractJson`) instead of throwing.
|
|
109
|
+
*/
|
|
110
|
+
declare class MigrationContractViews<TView> {
|
|
111
|
+
#private;
|
|
112
|
+
private readonly migration;
|
|
113
|
+
private readonly className;
|
|
114
|
+
private readonly fromJson;
|
|
115
|
+
constructor(migration: Migration, className: string, fromJson: (json: unknown) => TView);
|
|
116
|
+
get endContract(): TView;
|
|
117
|
+
get startContract(): TView | null;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Returns true when `import.meta.url` resolves to the same file that was
|
|
121
|
+
* invoked as the node entrypoint (`process.argv[1]`). Used by
|
|
122
|
+
* `MigrationCLI.run` (in `@internal/cli/migration-cli`) to no-op when
|
|
123
|
+
* the migration module is being imported (e.g. by another script) rather
|
|
124
|
+
* than executed directly.
|
|
125
|
+
*/
|
|
126
|
+
declare function isDirectEntrypoint(importMetaUrl: string): boolean;
|
|
127
|
+
/**
|
|
128
|
+
* In-memory artifacts produced from a `Migration` instance: the
|
|
129
|
+
* serialized `ops.json` body, the `migration.json` metadata object, and
|
|
130
|
+
* its serialized form. Returned by `buildMigrationArtifacts` so callers
|
|
131
|
+
* (today: `MigrationCLI.run` in `@internal/cli/migration-cli`) can
|
|
132
|
+
* decide how to persist them — write to disk, print in dry-run, ship
|
|
133
|
+
* over the wire — without coupling artifact construction to file I/O.
|
|
134
|
+
*
|
|
135
|
+
* `metadataJson` is `JSON.stringify(metadata, null, 2)` — the canonical
|
|
136
|
+
* on-disk shape that the arktype loader-schema in `./io` validates.
|
|
137
|
+
*/
|
|
138
|
+
interface MigrationArtifacts {
|
|
139
|
+
readonly opsJson: string;
|
|
140
|
+
readonly metadata: MigrationMetadata$1;
|
|
141
|
+
readonly metadataJson: string;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Pure conversion from a `Migration` instance (plus the previously
|
|
145
|
+
* scaffolded metadata, when one exists on disk) to the in-memory
|
|
146
|
+
* artifacts that downstream tooling persists. Owns metadata validation,
|
|
147
|
+
* metadata synthesis/preservation, and the content-addressed
|
|
148
|
+
* `migrationHash` computation, but performs no file I/O — callers handle
|
|
149
|
+
* reads (to source `existing`) and writes (to persist `opsJson` /
|
|
150
|
+
* `metadataJson`).
|
|
151
|
+
*/
|
|
152
|
+
declare function buildMigrationArtifacts(instance: Migration, existing: Partial<MigrationMetadata$1> | null): Promise<MigrationArtifacts>;
|
|
153
|
+
//#endregion
|
|
154
|
+
export { buildMigrationArtifacts as a, MigrationMeta as i, MigrationArtifacts as n, isDirectEntrypoint as o, MigrationContractViews as r, Migration as t };
|
|
155
|
+
//# sourceMappingURL=migration-B2ljMJim.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migration-B2ljMJim.d.mts","names":[],"sources":["../../../../1-framework/3-tooling/migration/dist/exports/migration.d.mts"],"mappings":";;;;;UAIU;WACC;WACA;;;;;;;;;;;;;;;;;;;;;;;uBAuBY,UAAU,oBAAoB,yBAAyB,wBAAwB,mCAAmC,mCAAmC,eAAe,WAAW,UAAU,aAAa,WAAW,qBAAqB;oBACzO;;;;;;;;;;;;;WAaT;aACE;eACE;;;;;;;;;WASJ;aACE;eACE;;;;;;;;;;;;qBAYM,OAAO,aAAa,WAAW;EAClD,YAAY,QAAQ,aAAa,WAAW;;;;;;;;eAQ/B,wBAAwB,yBAAyB,QAAQ;;;;;;;;;;EAUtE,YAAY;MACR;aACO;;MAEP;aACO;;;;;;;;;;;;;;;;cAgBC,uBAAuB;;mBAElB;mBACA;mBACA;EACjB,YAAY,WAAW,WAAW,mBAAmB,WAAW,kBAAkB;MAC9E,eAAe;MACf,iBAAiB;;;;;;;;;iBASN,mBAAmB;;;;;;;;;;;;UAY1B;WACC;WACA,UAAU;WACV;;;;;;;;;;;iBAWM,wBAAwB,UAAU,WAAW,UAAU,QAAQ,8BAA8B,QAAQ"}
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import { A as errorOperationsNotArray, c as errorDescribeMissingEndContract, s as errorDescribeInvalidMetadata, v as errorInvalidOperationEntry, w as errorMigrationContractViewMissing } from "./errors-IpZm1Skp-BH495dRd.mjs";
|
|
2
|
+
import { t as computeMigrationHash } from "./hash-DH8hl5Rq-BpM2t3Nu.mjs";
|
|
3
|
+
import { t as deriveProvidedInvariants } from "./invariants-lXzy6txi-DAoP4nTE.mjs";
|
|
4
|
+
import { t as MigrationOpSchema } from "./op-schema-BSVHzEQN-DIWt28D8.mjs";
|
|
5
|
+
import { type } from "arktype";
|
|
6
|
+
import { realpathSync } from "node:fs";
|
|
7
|
+
import { fileURLToPath } from "node:url";
|
|
8
|
+
//#region ../../../1-framework/3-tooling/migration/dist/exports/migration.mjs
|
|
9
|
+
const MigrationMetaSchema = type({
|
|
10
|
+
from: "string > 0 | null",
|
|
11
|
+
to: "string"
|
|
12
|
+
});
|
|
13
|
+
/**
|
|
14
|
+
* Base class for migrations.
|
|
15
|
+
*
|
|
16
|
+
* A `Migration` subclass is itself a `MigrationPlan`: CLI commands and the
|
|
17
|
+
* runner can consume it directly via `targetId`, `operations`, `origin`, and
|
|
18
|
+
* `destination`.
|
|
19
|
+
*
|
|
20
|
+
* The from/to identities come from `describe()`. A migration provides them in
|
|
21
|
+
* one of two ways:
|
|
22
|
+
* - **Contract-derived (default):** assign the `contract.json` imports from
|
|
23
|
+
* the snapshot store (`migrations/snapshots/<hex>/contract.json`) to
|
|
24
|
+
* `startContractJson` / `endContractJson`; the concrete `describe()` below
|
|
25
|
+
* derives `to`/`from` from their
|
|
26
|
+
* `storage.storageHash`. The family bases additionally expose typed view
|
|
27
|
+
* getters (`startContract` / `endContract`) over the same JSON.
|
|
28
|
+
* - **Override (e.g. extension migrations that carry no contract):** override
|
|
29
|
+
* `describe()` directly; the override wins and the JSON fields are unused.
|
|
30
|
+
*
|
|
31
|
+
* The `Start` / `End` generics carry each migration's precise contract types so
|
|
32
|
+
* the family-base view getters resolve to fully-typed views.
|
|
33
|
+
*/
|
|
34
|
+
var Migration = class {
|
|
35
|
+
/**
|
|
36
|
+
* The migration's end-state contract JSON (the `contract.json` import from
|
|
37
|
+
* the snapshot store). When set, the derived `describe()` reads `to` from its
|
|
38
|
+
* `storage.storageHash`. Family bases build the typed `endContract` view from
|
|
39
|
+
* it. Optional so `describe()`-overriding migrations (no contract) compile.
|
|
40
|
+
*
|
|
41
|
+
* Typed with a plain `storageHash: string`, not the branded
|
|
42
|
+
* `StorageHashBase`, so a raw `contract.json` import — whose `storageHash`
|
|
43
|
+
* is an untyped string literal — is assignable without a cast. The full
|
|
44
|
+
* `Start`/`End` contract typing is applied downstream in the family bases'
|
|
45
|
+
* view getters (via `<Family>ContractView.fromJson<…>`).
|
|
46
|
+
*/
|
|
47
|
+
endContractJson;
|
|
48
|
+
/**
|
|
49
|
+
* The migration's start-state contract JSON (the `contract.json` import
|
|
50
|
+
* from the snapshot store). Absent for a baseline migration (`from`
|
|
51
|
+
* derives to `null`). Family bases build the typed `startContract` view from
|
|
52
|
+
* it.
|
|
53
|
+
*/
|
|
54
|
+
startContractJson;
|
|
55
|
+
/**
|
|
56
|
+
* Assembled `ControlStack` injected by the orchestrator (`runMigration`).
|
|
57
|
+
*
|
|
58
|
+
* Subclasses (e.g. `PostgresMigration`) read the stack to materialize their
|
|
59
|
+
* adapter once per instance. Optional at the abstract level so unit tests can
|
|
60
|
+
* construct `Migration` instances purely for `operations` / `describe`
|
|
61
|
+
* assertions without needing a real stack; concrete subclasses that need the
|
|
62
|
+
* stack at runtime should narrow the parameter to required.
|
|
63
|
+
*/
|
|
64
|
+
stack;
|
|
65
|
+
constructor(stack) {
|
|
66
|
+
this.stack = stack;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Metadata inputs used to build `migration.json` and to derive the plan's
|
|
70
|
+
* origin/destination identities.
|
|
71
|
+
*
|
|
72
|
+
* Default derivation: `to = endContractJson.storage.storageHash`,
|
|
73
|
+
* `from = startContractJson?.storage.storageHash ?? null`. A migration that
|
|
74
|
+
* carries no contract JSON (e.g. an extension migration) must override this;
|
|
75
|
+
* otherwise it throws, since `migration.json` requires a `to` identity.
|
|
76
|
+
*/
|
|
77
|
+
describe() {
|
|
78
|
+
const end = this.endContractJson;
|
|
79
|
+
if (end === void 0) throw errorDescribeMissingEndContract();
|
|
80
|
+
return {
|
|
81
|
+
from: this.startContractJson?.storage.storageHash ?? null,
|
|
82
|
+
to: end.storage.storageHash
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
get origin() {
|
|
86
|
+
const from = this.describe().from;
|
|
87
|
+
return from === null ? null : { storageHash: from };
|
|
88
|
+
}
|
|
89
|
+
get destination() {
|
|
90
|
+
return { storageHash: this.describe().to };
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* Lazy-memoized `endContract` / `startContract` view accessors, one instance
|
|
95
|
+
* held per migration. Each target base (`MongoMigration`, `SqliteMigration`,
|
|
96
|
+
* `PostgresMigration`) creates one `MigrationContractViews` field from
|
|
97
|
+
* `this` — passing its own `<Family>ContractView.fromJson<…>` as `fromJson`
|
|
98
|
+
* and a name for error messages — and forwards its
|
|
99
|
+
* `endContract`/`startContract` getters to it.
|
|
100
|
+
*
|
|
101
|
+
* `endContract` throws `MIGRATION.CONTRACT_VIEW_MISSING` when the migration
|
|
102
|
+
* has no `endContractJson` (mirrors `describe()`'s own requirement).
|
|
103
|
+
* `startContract` returns `null` for a baseline migration (no
|
|
104
|
+
* `startContractJson`) instead of throwing.
|
|
105
|
+
*/
|
|
106
|
+
var MigrationContractViews = class {
|
|
107
|
+
migration;
|
|
108
|
+
className;
|
|
109
|
+
fromJson;
|
|
110
|
+
#endView;
|
|
111
|
+
#startView;
|
|
112
|
+
constructor(migration, className, fromJson) {
|
|
113
|
+
this.migration = migration;
|
|
114
|
+
this.className = className;
|
|
115
|
+
this.fromJson = fromJson;
|
|
116
|
+
}
|
|
117
|
+
get endContract() {
|
|
118
|
+
if (this.#endView === void 0) {
|
|
119
|
+
const json = this.migration.endContractJson;
|
|
120
|
+
if (json === void 0) throw errorMigrationContractViewMissing(this.className, "endContract", "endContractJson");
|
|
121
|
+
this.#endView = this.fromJson(json);
|
|
122
|
+
}
|
|
123
|
+
return this.#endView;
|
|
124
|
+
}
|
|
125
|
+
get startContract() {
|
|
126
|
+
if (this.#startView === void 0) {
|
|
127
|
+
const json = this.migration.startContractJson;
|
|
128
|
+
this.#startView = json === void 0 ? null : this.fromJson(json);
|
|
129
|
+
}
|
|
130
|
+
return this.#startView;
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
/**
|
|
134
|
+
* Returns true when `import.meta.url` resolves to the same file that was
|
|
135
|
+
* invoked as the node entrypoint (`process.argv[1]`). Used by
|
|
136
|
+
* `MigrationCLI.run` (in `@internal/cli/migration-cli`) to no-op when
|
|
137
|
+
* the migration module is being imported (e.g. by another script) rather
|
|
138
|
+
* than executed directly.
|
|
139
|
+
*/
|
|
140
|
+
function isDirectEntrypoint(importMetaUrl) {
|
|
141
|
+
const metaFilename = fileURLToPath(importMetaUrl);
|
|
142
|
+
const argv1 = process.argv[1];
|
|
143
|
+
if (!argv1) return false;
|
|
144
|
+
try {
|
|
145
|
+
return realpathSync(metaFilename) === realpathSync(argv1);
|
|
146
|
+
} catch {
|
|
147
|
+
return false;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Build the attested metadata from `describe()`-derived metadata, the
|
|
152
|
+
* operations list, and the previously-scaffolded metadata (if any).
|
|
153
|
+
*
|
|
154
|
+
* When a `migration.json` already exists for this package (the common
|
|
155
|
+
* case: it was scaffolded by `migration plan`), preserve `createdAt`
|
|
156
|
+
* set there — that field is owned by the CLI scaffolder, not the authored
|
|
157
|
+
* class. Only the `describe()`-derived fields (`from`, `to`) and the
|
|
158
|
+
* operations change as the author iterates. When no metadata exists yet
|
|
159
|
+
* (a bare `migration.ts` run from scratch), synthesize a minimal but
|
|
160
|
+
* schema-conformant record so the resulting package can still be read,
|
|
161
|
+
* verified, and applied.
|
|
162
|
+
*
|
|
163
|
+
* The `migrationHash` is recomputed against the current metadata + ops so
|
|
164
|
+
* the on-disk artifacts are always fully attested.
|
|
165
|
+
*/
|
|
166
|
+
function buildAttestedMetadata(meta, ops, existing) {
|
|
167
|
+
const baseMetadata = {
|
|
168
|
+
from: meta.from,
|
|
169
|
+
to: meta.to,
|
|
170
|
+
providedInvariants: deriveProvidedInvariants(ops),
|
|
171
|
+
createdAt: existing?.createdAt ?? (/* @__PURE__ */ new Date()).toISOString()
|
|
172
|
+
};
|
|
173
|
+
const migrationHash = computeMigrationHash(baseMetadata, ops);
|
|
174
|
+
return {
|
|
175
|
+
...baseMetadata,
|
|
176
|
+
migrationHash
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Pure conversion from a `Migration` instance (plus the previously
|
|
181
|
+
* scaffolded metadata, when one exists on disk) to the in-memory
|
|
182
|
+
* artifacts that downstream tooling persists. Owns metadata validation,
|
|
183
|
+
* metadata synthesis/preservation, and the content-addressed
|
|
184
|
+
* `migrationHash` computation, but performs no file I/O — callers handle
|
|
185
|
+
* reads (to source `existing`) and writes (to persist `opsJson` /
|
|
186
|
+
* `metadataJson`).
|
|
187
|
+
*/
|
|
188
|
+
async function buildMigrationArtifacts(instance, existing) {
|
|
189
|
+
const rawOps = instance.operations;
|
|
190
|
+
if (!Array.isArray(rawOps)) throw errorOperationsNotArray();
|
|
191
|
+
const ops = await Promise.all(rawOps);
|
|
192
|
+
for (let index = 0; index < ops.length; index++) {
|
|
193
|
+
const result = MigrationOpSchema(ops[index]);
|
|
194
|
+
if (result instanceof type.errors) throw errorInvalidOperationEntry(index, result.summary);
|
|
195
|
+
}
|
|
196
|
+
const rawMeta = instance.describe();
|
|
197
|
+
const parsed = MigrationMetaSchema(rawMeta);
|
|
198
|
+
if (parsed instanceof type.errors) throw errorDescribeInvalidMetadata(parsed.summary);
|
|
199
|
+
const metadata = buildAttestedMetadata(parsed, ops, existing);
|
|
200
|
+
return {
|
|
201
|
+
opsJson: JSON.stringify(ops, null, 2),
|
|
202
|
+
metadata,
|
|
203
|
+
metadataJson: JSON.stringify(metadata, null, 2)
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
//#endregion
|
|
207
|
+
export { isDirectEntrypoint as i, MigrationContractViews as n, buildMigrationArtifacts as r, Migration as t };
|
|
208
|
+
|
|
209
|
+
//# sourceMappingURL=migration-BuUmO7It.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migration-BuUmO7It.mjs","names":["#endView","#startView"],"sources":["../../../../1-framework/3-tooling/migration/dist/exports/migration.mjs"],"sourcesContent":["import { A as errorOperationsNotArray, c as errorDescribeMissingEndContract, s as errorDescribeInvalidMetadata, v as errorInvalidOperationEntry, w as errorMigrationContractViewMissing } from \"../errors-IpZm1Skp.mjs\";\nimport { t as computeMigrationHash } from \"../hash-DH8hl5Rq.mjs\";\nimport { t as deriveProvidedInvariants } from \"../invariants-lXzy6txi.mjs\";\nimport { t as MigrationOpSchema } from \"../op-schema-BSVHzEQN.mjs\";\nimport { type } from \"arktype\";\nimport { realpathSync } from \"node:fs\";\nimport { fileURLToPath } from \"node:url\";\n//#region src/migration-base.ts\nconst MigrationMetaSchema = type({\n\tfrom: \"string > 0 | null\",\n\tto: \"string\"\n});\n/**\n* Base class for migrations.\n*\n* A `Migration` subclass is itself a `MigrationPlan`: CLI commands and the\n* runner can consume it directly via `targetId`, `operations`, `origin`, and\n* `destination`.\n*\n* The from/to identities come from `describe()`. A migration provides them in\n* one of two ways:\n* - **Contract-derived (default):** assign the `contract.json` imports from\n* the snapshot store (`migrations/snapshots/<hex>/contract.json`) to\n* `startContractJson` / `endContractJson`; the concrete `describe()` below\n* derives `to`/`from` from their\n* `storage.storageHash`. The family bases additionally expose typed view\n* getters (`startContract` / `endContract`) over the same JSON.\n* - **Override (e.g. extension migrations that carry no contract):** override\n* `describe()` directly; the override wins and the JSON fields are unused.\n*\n* The `Start` / `End` generics carry each migration's precise contract types so\n* the family-base view getters resolve to fully-typed views.\n*/\nvar Migration = class {\n\t/**\n\t* The migration's end-state contract JSON (the `contract.json` import from\n\t* the snapshot store). When set, the derived `describe()` reads `to` from its\n\t* `storage.storageHash`. Family bases build the typed `endContract` view from\n\t* it. Optional so `describe()`-overriding migrations (no contract) compile.\n\t*\n\t* Typed with a plain `storageHash: string`, not the branded\n\t* `StorageHashBase`, so a raw `contract.json` import — whose `storageHash`\n\t* is an untyped string literal — is assignable without a cast. The full\n\t* `Start`/`End` contract typing is applied downstream in the family bases'\n\t* view getters (via `<Family>ContractView.fromJson<…>`).\n\t*/\n\tendContractJson;\n\t/**\n\t* The migration's start-state contract JSON (the `contract.json` import\n\t* from the snapshot store). Absent for a baseline migration (`from`\n\t* derives to `null`). Family bases build the typed `startContract` view from\n\t* it.\n\t*/\n\tstartContractJson;\n\t/**\n\t* Assembled `ControlStack` injected by the orchestrator (`runMigration`).\n\t*\n\t* Subclasses (e.g. `PostgresMigration`) read the stack to materialize their\n\t* adapter once per instance. Optional at the abstract level so unit tests can\n\t* construct `Migration` instances purely for `operations` / `describe`\n\t* assertions without needing a real stack; concrete subclasses that need the\n\t* stack at runtime should narrow the parameter to required.\n\t*/\n\tstack;\n\tconstructor(stack) {\n\t\tthis.stack = stack;\n\t}\n\t/**\n\t* Metadata inputs used to build `migration.json` and to derive the plan's\n\t* origin/destination identities.\n\t*\n\t* Default derivation: `to = endContractJson.storage.storageHash`,\n\t* `from = startContractJson?.storage.storageHash ?? null`. A migration that\n\t* carries no contract JSON (e.g. an extension migration) must override this;\n\t* otherwise it throws, since `migration.json` requires a `to` identity.\n\t*/\n\tdescribe() {\n\t\tconst end = this.endContractJson;\n\t\tif (end === void 0) throw errorDescribeMissingEndContract();\n\t\treturn {\n\t\t\tfrom: this.startContractJson?.storage.storageHash ?? null,\n\t\t\tto: end.storage.storageHash\n\t\t};\n\t}\n\tget origin() {\n\t\tconst from = this.describe().from;\n\t\treturn from === null ? null : { storageHash: from };\n\t}\n\tget destination() {\n\t\treturn { storageHash: this.describe().to };\n\t}\n};\n/**\n* Lazy-memoized `endContract` / `startContract` view accessors, one instance\n* held per migration. Each target base (`MongoMigration`, `SqliteMigration`,\n* `PostgresMigration`) creates one `MigrationContractViews` field from\n* `this` — passing its own `<Family>ContractView.fromJson<…>` as `fromJson`\n* and a name for error messages — and forwards its\n* `endContract`/`startContract` getters to it.\n*\n* `endContract` throws `MIGRATION.CONTRACT_VIEW_MISSING` when the migration\n* has no `endContractJson` (mirrors `describe()`'s own requirement).\n* `startContract` returns `null` for a baseline migration (no\n* `startContractJson`) instead of throwing.\n*/\nvar MigrationContractViews = class {\n\tmigration;\n\tclassName;\n\tfromJson;\n\t#endView;\n\t#startView;\n\tconstructor(migration, className, fromJson) {\n\t\tthis.migration = migration;\n\t\tthis.className = className;\n\t\tthis.fromJson = fromJson;\n\t}\n\tget endContract() {\n\t\tif (this.#endView === void 0) {\n\t\t\tconst json = this.migration.endContractJson;\n\t\t\tif (json === void 0) throw errorMigrationContractViewMissing(this.className, \"endContract\", \"endContractJson\");\n\t\t\tthis.#endView = this.fromJson(json);\n\t\t}\n\t\treturn this.#endView;\n\t}\n\tget startContract() {\n\t\tif (this.#startView === void 0) {\n\t\t\tconst json = this.migration.startContractJson;\n\t\t\tthis.#startView = json === void 0 ? null : this.fromJson(json);\n\t\t}\n\t\treturn this.#startView;\n\t}\n};\n/**\n* Returns true when `import.meta.url` resolves to the same file that was\n* invoked as the node entrypoint (`process.argv[1]`). Used by\n* `MigrationCLI.run` (in `@internal/cli/migration-cli`) to no-op when\n* the migration module is being imported (e.g. by another script) rather\n* than executed directly.\n*/\nfunction isDirectEntrypoint(importMetaUrl) {\n\tconst metaFilename = fileURLToPath(importMetaUrl);\n\tconst argv1 = process.argv[1];\n\tif (!argv1) return false;\n\ttry {\n\t\treturn realpathSync(metaFilename) === realpathSync(argv1);\n\t} catch {\n\t\treturn false;\n\t}\n}\n/**\n* Build the attested metadata from `describe()`-derived metadata, the\n* operations list, and the previously-scaffolded metadata (if any).\n*\n* When a `migration.json` already exists for this package (the common\n* case: it was scaffolded by `migration plan`), preserve `createdAt`\n* set there — that field is owned by the CLI scaffolder, not the authored\n* class. Only the `describe()`-derived fields (`from`, `to`) and the\n* operations change as the author iterates. When no metadata exists yet\n* (a bare `migration.ts` run from scratch), synthesize a minimal but\n* schema-conformant record so the resulting package can still be read,\n* verified, and applied.\n*\n* The `migrationHash` is recomputed against the current metadata + ops so\n* the on-disk artifacts are always fully attested.\n*/\nfunction buildAttestedMetadata(meta, ops, existing) {\n\tconst baseMetadata = {\n\t\tfrom: meta.from,\n\t\tto: meta.to,\n\t\tprovidedInvariants: deriveProvidedInvariants(ops),\n\t\tcreatedAt: existing?.createdAt ?? (/* @__PURE__ */ new Date()).toISOString()\n\t};\n\tconst migrationHash = computeMigrationHash(baseMetadata, ops);\n\treturn {\n\t\t...baseMetadata,\n\t\tmigrationHash\n\t};\n}\n/**\n* Pure conversion from a `Migration` instance (plus the previously\n* scaffolded metadata, when one exists on disk) to the in-memory\n* artifacts that downstream tooling persists. Owns metadata validation,\n* metadata synthesis/preservation, and the content-addressed\n* `migrationHash` computation, but performs no file I/O — callers handle\n* reads (to source `existing`) and writes (to persist `opsJson` /\n* `metadataJson`).\n*/\nasync function buildMigrationArtifacts(instance, existing) {\n\tconst rawOps = instance.operations;\n\tif (!Array.isArray(rawOps)) throw errorOperationsNotArray();\n\tconst ops = await Promise.all(rawOps);\n\tfor (let index = 0; index < ops.length; index++) {\n\t\tconst result = MigrationOpSchema(ops[index]);\n\t\tif (result instanceof type.errors) throw errorInvalidOperationEntry(index, result.summary);\n\t}\n\tconst rawMeta = instance.describe();\n\tconst parsed = MigrationMetaSchema(rawMeta);\n\tif (parsed instanceof type.errors) throw errorDescribeInvalidMetadata(parsed.summary);\n\tconst metadata = buildAttestedMetadata(parsed, ops, existing);\n\treturn {\n\t\topsJson: JSON.stringify(ops, null, 2),\n\t\tmetadata,\n\t\tmetadataJson: JSON.stringify(metadata, null, 2)\n\t};\n}\n//#endregion\nexport { Migration, MigrationContractViews, buildMigrationArtifacts, isDirectEntrypoint };\n\n//# sourceMappingURL=migration.mjs.map"],"mappings":";;;;;;;;AAQA,MAAM,sBAAsB,KAAK;CAChC,MAAM;CACN,IAAI;AACL,CAAC;;;;;;;;;;;;;;;;;;;;;;AAsBD,IAAI,YAAY,MAAM;;;;;;;;;;;;;CAarB;;;;;;;CAOA;;;;;;;;;;CAUA;CACA,YAAY,OAAO;EAClB,KAAK,QAAQ;CACd;;;;;;;;;;CAUA,WAAW;EACV,MAAM,MAAM,KAAK;EACjB,IAAI,QAAQ,KAAK,GAAG,MAAM,gCAAgC;EAC1D,OAAO;GACN,MAAM,KAAK,mBAAmB,QAAQ,eAAe;GACrD,IAAI,IAAI,QAAQ;EACjB;CACD;CACA,IAAI,SAAS;EACZ,MAAM,OAAO,KAAK,SAAS,CAAC,CAAC;EAC7B,OAAO,SAAS,OAAO,OAAO,EAAE,aAAa,KAAK;CACnD;CACA,IAAI,cAAc;EACjB,OAAO,EAAE,aAAa,KAAK,SAAS,CAAC,CAAC,GAAG;CAC1C;AACD;;;;;;;;;;;;;;AAcA,IAAI,yBAAyB,MAAM;CAClC;CACA;CACA;CACA;CACA;CACA,YAAY,WAAW,WAAW,UAAU;EAC3C,KAAK,YAAY;EACjB,KAAK,YAAY;EACjB,KAAK,WAAW;CACjB;CACA,IAAI,cAAc;EACjB,IAAI,KAAKA,aAAa,KAAK,GAAG;GAC7B,MAAM,OAAO,KAAK,UAAU;GAC5B,IAAI,SAAS,KAAK,GAAG,MAAM,kCAAkC,KAAK,WAAW,eAAe,iBAAiB;GAC7G,KAAKA,WAAW,KAAK,SAAS,IAAI;EACnC;EACA,OAAO,KAAKA;CACb;CACA,IAAI,gBAAgB;EACnB,IAAI,KAAKC,eAAe,KAAK,GAAG;GAC/B,MAAM,OAAO,KAAK,UAAU;GAC5B,KAAKA,aAAa,SAAS,KAAK,IAAI,OAAO,KAAK,SAAS,IAAI;EAC9D;EACA,OAAO,KAAKA;CACb;AACD;;;;;;;;AAQA,SAAS,mBAAmB,eAAe;CAC1C,MAAM,eAAe,cAAc,aAAa;CAChD,MAAM,QAAQ,QAAQ,KAAK;CAC3B,IAAI,CAAC,OAAO,OAAO;CACnB,IAAI;EACH,OAAO,aAAa,YAAY,MAAM,aAAa,KAAK;CACzD,QAAQ;EACP,OAAO;CACR;AACD;;;;;;;;;;;;;;;;;AAiBA,SAAS,sBAAsB,MAAM,KAAK,UAAU;CACnD,MAAM,eAAe;EACpB,MAAM,KAAK;EACX,IAAI,KAAK;EACT,oBAAoB,yBAAyB,GAAG;EAChD,WAAW,UAAU,8BAA8B,IAAI,KAAK,EAAA,CAAG,YAAY;CAC5E;CACA,MAAM,gBAAgB,qBAAqB,cAAc,GAAG;CAC5D,OAAO;EACN,GAAG;EACH;CACD;AACD;;;;;;;;;;AAUA,eAAe,wBAAwB,UAAU,UAAU;CAC1D,MAAM,SAAS,SAAS;CACxB,IAAI,CAAC,MAAM,QAAQ,MAAM,GAAG,MAAM,wBAAwB;CAC1D,MAAM,MAAM,MAAM,QAAQ,IAAI,MAAM;CACpC,KAAK,IAAI,QAAQ,GAAG,QAAQ,IAAI,QAAQ,SAAS;EAChD,MAAM,SAAS,kBAAkB,IAAI,MAAM;EAC3C,IAAI,kBAAkB,KAAK,QAAQ,MAAM,2BAA2B,OAAO,OAAO,OAAO;CAC1F;CACA,MAAM,UAAU,SAAS,SAAS;CAClC,MAAM,SAAS,oBAAoB,OAAO;CAC1C,IAAI,kBAAkB,KAAK,QAAQ,MAAM,6BAA6B,OAAO,OAAO;CACpF,MAAM,WAAW,sBAAsB,QAAQ,KAAK,QAAQ;CAC5D,OAAO;EACN,SAAS,KAAK,UAAU,KAAK,MAAM,CAAC;EACpC;EACA,cAAc,KAAK,UAAU,UAAU,MAAM,CAAC;CAC/C;AACD"}
|