@prisma/orm-toolchain 8.0.0-rc.1-dev.28 → 8.0.0-rc.1-dev.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{aggregate-BKbHUHLA.mjs → aggregate-BBsCbXgJ.mjs} +8 -8
- package/dist/{aggregate-BKbHUHLA.mjs.map → aggregate-BBsCbXgJ.mjs.map} +1 -1
- package/dist/bin__prisma-next.mjs +25 -25
- package/dist/bin__prisma-next.mjs.map +1 -1
- package/dist/cli.d.mts +2 -2
- package/dist/cli.mjs +257 -93
- package/dist/cli.mjs.map +1 -1
- package/dist/cli__commands__contract-emit.mjs +1 -1
- package/dist/cli__commands__contract-infer.mjs +1 -1
- package/dist/cli__commands__db-init.mjs +1 -1
- package/dist/cli__commands__db-schema.mjs +1 -1
- package/dist/cli__commands__db-sign.mjs +1 -1
- package/dist/cli__commands__db-update.mjs +1 -1
- package/dist/cli__commands__db-verify.mjs +1 -1
- package/dist/cli__commands__migrate.mjs +1 -1
- package/dist/cli__commands__migration-check.mjs +1 -1
- package/dist/cli__commands__migration-graph.d.mts.map +1 -1
- package/dist/cli__commands__migration-graph.mjs +1 -1
- package/dist/cli__commands__migration-list.mjs +1 -1
- package/dist/cli__commands__migration-log.mjs +1 -1
- package/dist/cli__commands__migration-new.mjs +1 -1
- package/dist/cli__commands__migration-plan.mjs +1 -1
- package/dist/cli__commands__migration-show.mjs +1 -1
- package/dist/cli__commands__migration-status.mjs +1 -1
- package/dist/cli__commands__ref.mjs +1 -1
- package/dist/cli__commands__telemetry.mjs +1 -1
- package/dist/cli__control-api.d.mts +14 -13
- package/dist/cli__control-api.d.mts.map +1 -1
- package/dist/cli__control-api.mjs +15 -15
- package/dist/cli__migration-cli.mjs +2 -2
- package/dist/{client-CaIWFVnh-PVaTEvdx.mjs → client-C4Gh4PBz-BMUlBcuE.mjs} +6 -6
- package/dist/{client-CaIWFVnh-PVaTEvdx.mjs.map → client-C4Gh4PBz-BMUlBcuE.mjs.map} +1 -1
- package/dist/{command-helpers-DutQjYgy-CDfFwtAa.mjs → command-helpers-Dw3LDEu_-B4AETH4D.mjs} +4 -4
- package/dist/{command-helpers-DutQjYgy-CDfFwtAa.mjs.map → command-helpers-Dw3LDEu_-B4AETH4D.mjs.map} +1 -1
- package/dist/{contract-at-errors-BsQiGdZC-BY8u2is4.mjs → contract-at-errors-BsQiGdZC-D8l9-WWt.mjs} +2 -2
- package/dist/{contract-at-errors-BsQiGdZC-BY8u2is4.mjs.map → contract-at-errors-BsQiGdZC-D8l9-WWt.mjs.map} +1 -1
- package/dist/{contract-emit-BJDLPMxp-qaGmQUQr.mjs → contract-emit-CIdgw3Kq-BcfYaUfn.mjs} +4 -4
- package/dist/{contract-emit-BJDLPMxp-qaGmQUQr.mjs.map → contract-emit-CIdgw3Kq-BcfYaUfn.mjs.map} +1 -1
- package/dist/{contract-infer-B929dnCJ-KkT9frLY.mjs → contract-infer-xOEwVWds-CE5gw1PF.mjs} +5 -5
- package/dist/{contract-infer-B929dnCJ-KkT9frLY.mjs.map → contract-infer-xOEwVWds-CE5gw1PF.mjs.map} +1 -1
- package/dist/{contract-snapshot-resolution-D2f9kGs0-BenF4tbi.mjs → contract-snapshot-resolution-BnH6_mw7-BrzAsS93.mjs} +6 -6
- package/dist/{contract-snapshot-resolution-D2f9kGs0-BenF4tbi.mjs.map → contract-snapshot-resolution-BnH6_mw7-BrzAsS93.mjs.map} +1 -1
- package/dist/{contract-snapshot-store-C9-J6OBn-kpuB2oCK.mjs → contract-snapshot-store-B0G1Fw_F-C4JjmWEA.mjs} +3 -3
- package/dist/{contract-snapshot-store-C9-J6OBn-kpuB2oCK.mjs.map → contract-snapshot-store-B0G1Fw_F-C4JjmWEA.mjs.map} +1 -1
- package/dist/{contract-space-aggregate-loader-sF0OJ6oz-jRjdZoyZ.mjs → contract-space-aggregate-loader-1wG1OiDk-D75luh5-.mjs} +5 -5
- package/dist/{contract-space-aggregate-loader-sF0OJ6oz-jRjdZoyZ.mjs.map → contract-space-aggregate-loader-1wG1OiDk-D75luh5-.mjs.map} +1 -1
- package/dist/{db-init-CU_x-p2M-_6oEFLiG.mjs → db-init-CEk9Utl4-vGmJajwZ.mjs} +6 -6
- package/dist/{db-init-CU_x-p2M-_6oEFLiG.mjs.map → db-init-CEk9Utl4-vGmJajwZ.mjs.map} +1 -1
- package/dist/{db-schema-BKAn8UrM-DP4k7BAB.mjs → db-schema-D_PJvBI3-BTnfCqbX.mjs} +6 -6
- package/dist/{db-schema-BKAn8UrM-DP4k7BAB.mjs.map → db-schema-D_PJvBI3-BTnfCqbX.mjs.map} +1 -1
- package/dist/{db-sign-BQF-jVXg-D467Bhpj.mjs → db-sign-Bparnnii-Yd5pb4VF.mjs} +7 -7
- package/dist/{db-sign-BQF-jVXg-D467Bhpj.mjs.map → db-sign-Bparnnii-Yd5pb4VF.mjs.map} +1 -1
- package/dist/{db-update-B0_Q4ykE-CT9vcaMu.mjs → db-update-CsKZyDYp-B8Zl7W4k.mjs} +7 -7
- package/dist/{db-update-B0_Q4ykE-CT9vcaMu.mjs.map → db-update-CsKZyDYp-B8Zl7W4k.mjs.map} +1 -1
- package/dist/{db-verify-C0DJc8z6-f3gZeEMD.mjs → db-verify-B33E7HXH-D87fiNt3.mjs} +6 -6
- package/dist/{db-verify-C0DJc8z6-f3gZeEMD.mjs.map → db-verify-B33E7HXH-D87fiNt3.mjs.map} +1 -1
- package/dist/{errors-Co-8oaiB-CB-6Uqki.mjs → errors-CXbGUWGu-BQi6YS-H.mjs} +51 -2
- package/dist/errors-CXbGUWGu-BQi6YS-H.mjs.map +1 -0
- package/dist/{errors-NRmFpwR1.d.mts → errors-KWM8yBAL.d.mts} +3 -1
- package/dist/errors-KWM8yBAL.d.mts.map +1 -0
- package/dist/{format-SYdHyutg-IqXk-tDV.mjs → format-CYdgHub4-Cs6VcFje.mjs} +4 -4
- package/dist/{format-SYdHyutg-IqXk-tDV.mjs.map → format-CYdgHub4-Cs6VcFje.mjs.map} +1 -1
- package/dist/{graph-membership-BEmNEMtP-rz61CLM5.mjs → graph-membership-BViWUMpP-Cgu4Z2ox.mjs} +3 -3
- package/dist/{graph-membership-BEmNEMtP-rz61CLM5.mjs.map → graph-membership-BViWUMpP-Cgu4Z2ox.mjs.map} +1 -1
- package/dist/{init-DXx66xTA-BkK1aEw0.mjs → init-CrypFQwk-XiyERkdi.mjs} +3 -3
- package/dist/{init-DXx66xTA-BkK1aEw0.mjs.map → init-CrypFQwk-XiyERkdi.mjs.map} +1 -1
- package/dist/{inspect-live-schema-D8d7aI6a-_Q_4S5wm.mjs → inspect-live-schema-BAiaX0n9-DBQFEsMC.mjs} +4 -4
- package/dist/{inspect-live-schema-D8d7aI6a-_Q_4S5wm.mjs.map → inspect-live-schema-BAiaX0n9-DBQFEsMC.mjs.map} +1 -1
- package/dist/{invariants-C1WVUAH7-DlOBTTkM.mjs → invariants-CTHy88OP-DJ-i5yTz.mjs} +3 -3
- package/dist/{invariants-C1WVUAH7-DlOBTTkM.mjs.map → invariants-CTHy88OP-DJ-i5yTz.mjs.map} +1 -1
- package/dist/{invariants-TW5CizTS-BsIpi4h4.mjs → invariants-CsxL0lbZ-B9Hfpj2R.mjs} +6 -6
- package/dist/{invariants-TW5CizTS-BsIpi4h4.mjs.map → invariants-CsxL0lbZ-B9Hfpj2R.mjs.map} +1 -1
- package/dist/{io-CHUUeHh0-CbyTkKP6.mjs → io-635GlNx1-D94PxRc-.mjs} +5 -5
- package/dist/{io-CHUUeHh0-CbyTkKP6.mjs.map → io-635GlNx1-D94PxRc-.mjs.map} +1 -1
- package/dist/{migrate-vNMZJk7M-DKogRyOh.mjs → migrate-DYx_CSbN-BuQ0lk-0.mjs} +13 -13
- package/dist/{migrate-vNMZJk7M-DKogRyOh.mjs.map → migrate-DYx_CSbN-BuQ0lk-0.mjs.map} +1 -1
- package/dist/{migrate-show-C-fdCznr-BH88FGVn.mjs → migrate-show-CPZEq35I-DeL3WVjs.mjs} +9 -9
- package/dist/{migrate-show-C-fdCznr-BH88FGVn.mjs.map → migrate-show-CPZEq35I-DeL3WVjs.mjs.map} +1 -1
- package/dist/{migration-check-C-2GTAGq-Duc0P6Uo.mjs → migration-check-BUAcSrvA-DSS5Yvco.mjs} +9 -9
- package/dist/{migration-check-C-2GTAGq-Duc0P6Uo.mjs.map → migration-check-BUAcSrvA-DSS5Yvco.mjs.map} +1 -1
- package/dist/{migration-check-DATj3HSn-Del6ZSln.mjs → migration-check-D0ABv6pO-BCJRf3lE.mjs} +6 -6
- package/dist/{migration-check-DATj3HSn-Del6ZSln.mjs.map → migration-check-D0ABv6pO-BCJRf3lE.mjs.map} +1 -1
- package/dist/{migration-command-scaffold-BezR8GWB-BZFB2PC-.mjs → migration-command-scaffold-CIMPoR6f-Ba-S9gXa.mjs} +4 -4
- package/dist/{migration-command-scaffold-BezR8GWB-BZFB2PC-.mjs.map → migration-command-scaffold-CIMPoR6f-Ba-S9gXa.mjs.map} +1 -1
- package/dist/{migration-graph-B1mg_jel-HVG6FLD0.mjs → migration-graph-BsGstA5L-BQiNbrkP.mjs} +9 -9
- package/dist/{migration-graph-B1mg_jel-HVG6FLD0.mjs.map → migration-graph-BsGstA5L-BQiNbrkP.mjs.map} +1 -1
- package/dist/{migration-graph-BtP1Va3T-CMOZgqVW.mjs → migration-graph-BtP1Va3T-C8PpuaYw.mjs} +2 -2
- package/dist/{migration-graph-BtP1Va3T-CMOZgqVW.mjs.map → migration-graph-BtP1Va3T-C8PpuaYw.mjs.map} +1 -1
- package/dist/{migration-graph-DDaOHo10-yJFAbKCu.mjs → migration-graph-_SJImD5V-D5RCc651.mjs} +3 -3
- package/dist/{migration-graph-DDaOHo10-yJFAbKCu.mjs.map → migration-graph-_SJImD5V-D5RCc651.mjs.map} +1 -1
- package/dist/{migration-graph-command-render-BKrg6BPv-BP8Pfj4J.mjs → migration-graph-command-render-CgdHruiZ-B6V4gmUe.mjs} +321 -153
- package/dist/migration-graph-command-render-CgdHruiZ-B6V4gmUe.mjs.map +1 -0
- package/dist/{migration-graph-sections-BVqyqBHg-DAwWjIIf.mjs → migration-graph-sections-CceYWPCP-LqImOaK1.mjs} +6 -4
- package/dist/migration-graph-sections-CceYWPCP-LqImOaK1.mjs.map +1 -0
- package/dist/{migration-_C5W2uXF.mjs → migration-gubSSeMk.mjs} +3 -3
- package/dist/{migration-_C5W2uXF.mjs.map → migration-gubSSeMk.mjs.map} +1 -1
- package/dist/{migration-list-AKRIIovW-Cr39jOaI.mjs → migration-list-AKRIIovW-BN-Zrwk0.mjs} +3 -3
- package/dist/{migration-list-AKRIIovW-Cr39jOaI.mjs.map → migration-list-AKRIIovW-BN-Zrwk0.mjs.map} +1 -1
- package/dist/{migration-list-RSlyGyvD-KKmZtdY1.mjs → migration-list-BiVyonwG-CdMbBV5Z.mjs} +7 -7
- package/dist/{migration-list-RSlyGyvD-KKmZtdY1.mjs.map → migration-list-BiVyonwG-CdMbBV5Z.mjs.map} +1 -1
- package/dist/{migration-log-CBfOcyPC-DTqCL1cs.mjs → migration-log-Z3-L172x-CvQTNJvI.mjs} +7 -7
- package/dist/{migration-log-CBfOcyPC-DTqCL1cs.mjs.map → migration-log-Z3-L172x-CvQTNJvI.mjs.map} +1 -1
- package/dist/{migration-log-table-C0dSMG9T-BhBYrdka.mjs → migration-log-table-JR7fFVbE-DR2mom6h.mjs} +4 -4
- package/dist/{migration-log-table-C0dSMG9T-BhBYrdka.mjs.map → migration-log-table-JR7fFVbE-DR2mom6h.mjs.map} +1 -1
- package/dist/{migration-new-1LYliIXy-BK_Xz0Z6.mjs → migration-new-DDnQd7Ql-1WT_J_zf.mjs} +5 -5
- package/dist/{migration-new-1LYliIXy-BK_Xz0Z6.mjs.map → migration-new-DDnQd7Ql-1WT_J_zf.mjs.map} +1 -1
- package/dist/{migration-new-DcPO4tiw-Bew7S-bj.mjs → migration-new-ZlgxFcbH-CxlZs2hr.mjs} +8 -8
- package/dist/{migration-new-DcPO4tiw-Bew7S-bj.mjs.map → migration-new-ZlgxFcbH-CxlZs2hr.mjs.map} +1 -1
- package/dist/{migration-plan-B0z2Qpa5-6b1SJSsb.mjs → migration-plan-CROSunPS-B66Rh_6T.mjs} +5 -5
- package/dist/{migration-plan-B0z2Qpa5-6b1SJSsb.mjs.map → migration-plan-CROSunPS-B66Rh_6T.mjs.map} +1 -1
- package/dist/{migration-plan-Cb7s5Ifx-Bwa2O0Ov.mjs → migration-plan-DiLJTAep-2B463CwW.mjs} +14 -14
- package/dist/{migration-plan-Cb7s5Ifx-Bwa2O0Ov.mjs.map → migration-plan-DiLJTAep-2B463CwW.mjs.map} +1 -1
- package/dist/{migration-show-BRy1GVBE-NuwoczhZ.mjs → migration-show-mJD52S2d-DiD-rCBB.mjs} +7 -7
- package/dist/{migration-show-BRy1GVBE-NuwoczhZ.mjs.map → migration-show-mJD52S2d-DiD-rCBB.mjs.map} +1 -1
- package/dist/{migration-status-Dob4onB1-0YkQF25g.mjs → migration-status-Df6EwEun-CbrQHa3S.mjs} +11 -11
- package/dist/{migration-status-Dob4onB1-0YkQF25g.mjs.map → migration-status-Df6EwEun-CbrQHa3S.mjs.map} +1 -1
- package/dist/migration-tools.d.mts +1 -1
- package/dist/migration-tools.mjs +12 -12
- package/dist/migration-tools__aggregate.mjs +1 -1
- package/dist/migration-tools__contract-snapshot-store.mjs +1 -1
- package/dist/migration-tools__errors.d.mts +1 -1
- package/dist/migration-tools__errors.mjs +1 -1
- package/dist/migration-tools__invariants.mjs +1 -1
- package/dist/migration-tools__io.mjs +1 -1
- package/dist/migration-tools__migration-graph.mjs +2 -2
- package/dist/migration-tools__migration.mjs +1 -1
- package/dist/migration-tools__ref-resolution.mjs +1 -1
- package/dist/migration-tools__refs.mjs +1 -1
- package/dist/migration-tools__spaces.mjs +2 -2
- package/dist/{ref-B643Z0CS-CoJgdv7h.mjs → ref-Cycefq_T-DQE5AM66.mjs} +5 -5
- package/dist/{ref-B643Z0CS-CoJgdv7h.mjs.map → ref-Cycefq_T-DQE5AM66.mjs.map} +1 -1
- package/dist/{ref-D9J4TNYz-Dk7HCAoq.mjs → ref-DftuSibc-CasZ6LgA.mjs} +10 -10
- package/dist/{ref-D9J4TNYz-Dk7HCAoq.mjs.map → ref-DftuSibc-CasZ6LgA.mjs.map} +1 -1
- package/dist/{ref-advancement-DaZBzm7m-Deq5Cs7O.mjs → ref-advancement-DaZBzm7m-WoqnFAyr.mjs} +4 -4
- package/dist/{ref-advancement-DaZBzm7m-Deq5Cs7O.mjs.map → ref-advancement-DaZBzm7m-WoqnFAyr.mjs.map} +1 -1
- package/dist/{ref-resolution-Bi4lpxM8-BX-7sl0f.mjs → ref-resolution-Bi4lpxM8-BbfL_yv8.mjs} +2 -2
- package/dist/{ref-resolution-Bi4lpxM8-BX-7sl0f.mjs.map → ref-resolution-Bi4lpxM8-BbfL_yv8.mjs.map} +1 -1
- package/dist/{ref-resolution-Ct2GMcNB.mjs → ref-resolution-sGcINe7o.mjs} +2 -2
- package/dist/{ref-resolution-Ct2GMcNB.mjs.map → ref-resolution-sGcINe7o.mjs.map} +1 -1
- package/dist/{refs-B2BL8z3i-DGGFB7Mj.mjs → refs-WK86uYYp-B6EZkmmT.mjs} +19 -3
- package/dist/refs-WK86uYYp-B6EZkmmT.mjs.map +1 -0
- package/dist/{refs-fQLFcMoq-UTlvnijY.mjs → refs-fQLFcMoq-aTBeUU9H.mjs} +4 -4
- package/dist/{refs-fQLFcMoq-UTlvnijY.mjs.map → refs-fQLFcMoq-aTBeUU9H.mjs.map} +1 -1
- package/dist/{spaces-DBTCE3Js.mjs → spaces-BG2w0P8d.mjs} +6 -6
- package/dist/{spaces-DBTCE3Js.mjs.map → spaces-BG2w0P8d.mjs.map} +1 -1
- package/dist/{telemetry-DFEbk6sD-BYEW2bCJ.mjs → telemetry-LP1Suxsf-CY1l7lD0.mjs} +4 -4
- package/dist/{telemetry-DFEbk6sD-BYEW2bCJ.mjs.map → telemetry-LP1Suxsf-CY1l7lD0.mjs.map} +1 -1
- package/dist/{terminal-ui-DQNCDg2u-B3PFqjB8.mjs → terminal-ui-JJKxvT0q-CPDEJqqU.mjs} +35 -11
- package/dist/terminal-ui-JJKxvT0q-CPDEJqqU.mjs.map +1 -0
- package/dist/{verify-contract-spaces-WvjSiWcB-DZPPCwWO.mjs → verify-contract-spaces-DhJTb0zM-_oh6W6lp.mjs} +4 -4
- package/dist/{verify-contract-spaces-WvjSiWcB-DZPPCwWO.mjs.map → verify-contract-spaces-DhJTb0zM-_oh6W6lp.mjs.map} +1 -1
- package/dist/{verify-TphNCyMu-h8vrnbud.mjs → verify-wUSBDQwh-Bv3NV9WG.mjs} +3 -3
- package/dist/{verify-TphNCyMu-h8vrnbud.mjs.map → verify-wUSBDQwh-Bv3NV9WG.mjs.map} +1 -1
- package/package.json +13 -13
- package/dist/errors-Co-8oaiB-CB-6Uqki.mjs.map +0 -1
- package/dist/errors-NRmFpwR1.d.mts.map +0 -1
- package/dist/migration-graph-command-render-BKrg6BPv-BP8Pfj4J.mjs.map +0 -1
- package/dist/migration-graph-sections-BVqyqBHg-DAwWjIIf.mjs.map +0 -1
- package/dist/refs-B2BL8z3i-DGGFB7Mj.mjs.map +0 -1
- package/dist/terminal-ui-DQNCDg2u-B3PFqjB8.mjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contract-space-aggregate-loader-sF0OJ6oz-jRjdZoyZ.mjs","names":["CliStructuredError"],"sources":["../../../../1-framework/3-tooling/cli/dist/contract-space-aggregate-loader-sF0OJ6oz.mjs"],"sourcesContent":["import { M as errorUnexpected, t as CliStructuredError } from \"./cli-errors-CihMAEVj.mjs\";\nimport { o as readContractEnvelope, s as resolveContractPath } from \"./command-helpers-DutQjYgy.mjs\";\nimport { notOk, ok } from \"@internal/utils/result\";\nimport { readFile } from \"node:fs/promises\";\nimport { createControlStack } from \"@internal/framework-components/control\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { loadContractSpaceAggregate } from \"@internal/migration-tools/aggregate\";\nimport { EMPTY_CONTRACT_HASH } from \"@internal/migration-tools/constants\";\nimport { MigrationToolsError } from \"@internal/migration-tools/errors\";\n//#region src/utils/extension-pack-inputs.ts\n/**\n* Project the CLI's `Config.extensions` array into the canonical\n* {@link ExtensionPackInput} shape. The single `as ExtensionPackLike`\n* structural cast in the CLI lives inside this function.\n*/\nfunction toExtensionInputs(extensions) {\n\treturn extensions.map((raw) => {\n\t\tconst pack = raw;\n\t\tif (pack.contractSpace === void 0) return {\n\t\t\tid: pack.id,\n\t\t\ttargetId: pack.targetId\n\t\t};\n\t\treturn {\n\t\t\tid: pack.id,\n\t\t\ttargetId: pack.targetId,\n\t\t\tcontractSpace: {\n\t\t\t\tcontractJson: pack.contractSpace.contractJson,\n\t\t\t\theadRef: pack.contractSpace.headRef,\n\t\t\t\tmigrations: pack.contractSpace.migrations ?? []\n\t\t\t}\n\t\t};\n\t});\n}\n/**\n* Minimal aggregate-loader projection that extracts `id` + `targetId`\n* from raw extension pack descriptors **without invoking any\n* `contractSpace` accessor**. Inspects the own-property descriptor so\n* that getter-backed `contractSpace` declarations are detected but\n* never called.\n*\n* Inclusion semantics match {@link toDeclaredExtensions}: a data\n* property whose value is explicitly `undefined` is treated as \"no\n* contract-space declaration\" and skipped, mirroring the\n* `pack.contractSpace === undefined` check used on canonicalised\n* inputs. Prototype-chain `contractSpace` properties (no own\n* descriptor) are also skipped.\n*\n* This variant must be used by `buildContractSpaceAggregate` so that\n* the aggregate path (including `db verify`) never reads\n* `contractSpace.contractJson` from extension descriptors — the loader\n* always reads the contract from on-disk artefacts instead.\n*/\nfunction toDeclaredExtensionsFromRaw(extensions) {\n\tconst entries = [];\n\tfor (const raw of extensions) {\n\t\tif (typeof raw !== \"object\" || raw === null) continue;\n\t\tconst descriptor = Object.getOwnPropertyDescriptor(raw, \"contractSpace\");\n\t\tif (descriptor === void 0) continue;\n\t\tif (\"value\" in descriptor && descriptor.value === void 0) continue;\n\t\tconst pack = raw;\n\t\tentries.push({\n\t\t\tid: pack.id,\n\t\t\ttargetId: pack.targetId\n\t\t});\n\t}\n\treturn entries;\n}\n//#endregion\n//#region src/control-api/operations/contract-space-aggregate-loader.ts\nconst CONTRACT_SPACES_DOCS_URL = \"https://pris.ly/contract-spaces\";\nfunction contractSpaceViolationError(summary, options) {\n\treturn new CliStructuredError(\"MIGRATION.CONTRACT_SPACE_VIOLATION\", summary, {\n\t\twhy: options.why,\n\t\tfix: options.fix,\n\t\tdocsUrl: CONTRACT_SPACES_DOCS_URL,\n\t\tmeta: { violations: options.violations }\n\t});\n}\n/**\n* Build the `MIGRATION.CONTRACT_SPACE_VIOLATION` structured-error envelope for a contract-space\n* target mismatch. Shared between the declared-extension precheck (the\n* descriptor's configured target disagrees with the project target) and\n* the on-disk-contract check surfaced by `checkIntegrity`.\n*/\nfunction targetMismatchError(spaceId, expected, actual) {\n\treturn contractSpaceViolationError(`Contract-space target mismatch for \"${spaceId}\"`, {\n\t\twhy: `Space \"${spaceId}\" targets \"${actual}\" but the project's adapter targets \"${expected}\".`,\n\t\tfix: \"Update the extension descriptor to target the configured database, or change the project adapter.\",\n\t\tviolations: [{\n\t\t\tkind: \"targetMismatch\",\n\t\t\tspaceId,\n\t\t\texpected,\n\t\t\tactual\n\t\t}]\n\t});\n}\n/**\n* Human-readable detail for an integrity violation, used as the `why`\n* of the `integrityFailure` envelope. Mirrors the messages the prior\n* throw-on-load loader produced so downstream consumers see the same\n* text for the same on-disk state.\n*/\nfunction describeIntegrityViolation(violation) {\n\tswitch (violation.kind) {\n\t\tcase \"hashMismatch\": return `Migration \"${violation.dirName}\" stored hash \"${violation.stored}\" does not match computed hash \"${violation.computed}\".`;\n\t\tcase \"providedInvariantsMismatch\": return `Migration \"${violation.dirName}\" providedInvariants in migration.json disagrees with ops.json.`;\n\t\tcase \"packageUnloadable\": return `Migration \"${violation.dirName}\" could not be loaded: ${violation.detail}`;\n\t\tcase \"sameSourceAndTarget\": return `Migration \"${violation.dirName}\" has source equal to target (${violation.hash}) with no data invariant — a true no-op self-edge.`;\n\t\tcase \"headRefMissing\": return `Head ref \\`refs/head.json\\` is missing for contract space \"${violation.spaceId}\".`;\n\t\tcase \"headRefNotInGraph\": return `Head ref ${violation.hash} for contract space \"${violation.spaceId}\" is not present in the migration graph.`;\n\t\tcase \"refUnreadable\": return `Ref \"${violation.refName}\" for contract space \"${violation.spaceId}\" is unreadable: ${violation.detail}`;\n\t\tcase \"duplicateMigrationHash\": return `Multiple migrations in space \"${violation.spaceId}\" share migrationHash \"${violation.migrationHash}\" (${violation.dirNames.join(\", \")}).`;\n\t\tdefault: {\n\t\t\tconst spaceId = \"spaceId\" in violation ? violation.spaceId : \"*\";\n\t\t\treturn `Integrity violation \"${violation.kind}\" for contract space \"${spaceId}\".`;\n\t\t}\n\t}\n}\n/**\n* Map the integrity violations `checkIntegrity` reports into a single\n* CLI structured-error envelope, preserving the error codes the prior\n* throw-on-load loader emitted: `MIGRATION.CONTRACT_SPACE_LAYOUT_VIOLATION`\n* (layout drift, bundled) and `MIGRATION.CONTRACT_SPACE_VIOLATION` (target /\n* disjointness / contract-validation / structural integrity). Returns\n* `null` when there is nothing to refuse on.\n*\n* Precedence reproduces the prior loader's first-failure ordering:\n* layout drift first (every offence bundled into one envelope), then\n* target mismatch, then disjointness, then a contract-validation\n* failure, then any remaining structural integrity violation.\n*/\nfunction mapIntegrityViolations(violations) {\n\tif (violations.length === 0) return null;\n\tconst layout = violations.filter((v) => v.kind === \"orphanSpaceDir\" || v.kind === \"declaredButUnmigrated\");\n\tif (layout.length > 0) {\n\t\tconst lines = layout.map((v) => `- [${v.kind}] ${v.spaceId}`);\n\t\treturn new CliStructuredError(\"MIGRATION.CONTRACT_SPACE_LAYOUT_VIOLATION\", layout.length === 1 ? \"Contract-space layout violation detected\" : `Contract-space layout violations detected (${layout.length})`, {\n\t\t\twhy: `The on-disk \\`migrations/\\` directory and your \\`extensions\\` declaration are not in agreement.\\n${lines.join(\"\\n\")}`,\n\t\t\tfix: \"Declare the extension in `extensions` and re-emit its contract-space artefacts, or remove the orphan `migrations/<space>` directory.\",\n\t\t\tdocsUrl: CONTRACT_SPACES_DOCS_URL,\n\t\t\tmeta: { violations: layout }\n\t\t});\n\t}\n\tconst targetMismatch = violations.find((v) => v.kind === \"targetMismatch\");\n\tif (targetMismatch && targetMismatch.kind === \"targetMismatch\") return targetMismatchError(targetMismatch.spaceId, targetMismatch.expected, targetMismatch.actual);\n\tconst disjointness = violations.find((v) => v.kind === \"disjointness\");\n\tif (disjointness && disjointness.kind === \"disjointness\") return contractSpaceViolationError(`Contract-space disjointness violation: storage element \"${disjointness.element}\" claimed by multiple spaces`, {\n\t\twhy: `Spaces ${disjointness.claimedBy.map((s) => `\"${s}\"`).join(\", \")} all claim the storage element \"${disjointness.element}\". Each storage element must be owned by exactly one contract space.`,\n\t\tfix: \"Update the conflicting contracts so each storage element is claimed by exactly one space.\",\n\t\tviolations: [disjointness]\n\t});\n\tconst contractUnreadable = violations.find((v) => v.kind === \"contractUnreadable\");\n\tif (contractUnreadable && contractUnreadable.kind === \"contractUnreadable\") return contractSpaceViolationError(`Contract-space contract validation failed for \"${contractUnreadable.spaceId}\"`, {\n\t\twhy: contractUnreadable.detail,\n\t\tfix: \"Re-emit the extension contract with `prisma-next contract emit`, or fix the extension pack descriptor producing the invalid contract.\",\n\t\tviolations: [contractUnreadable]\n\t});\n\tconst structural = violations[0];\n\treturn contractSpaceViolationError(`Contract-space integrity failure for \"${\"spaceId\" in structural ? structural.spaceId : \"*\"}\"`, {\n\t\twhy: describeIntegrityViolation(structural),\n\t\tfix: \"Re-emit the affected migration package(s) or restore the on-disk `migrations/` directory from version control.\",\n\t\tviolations: [structural]\n\t});\n}\nfunction declaredExtensionsFromInputs(extensions) {\n\treturn toDeclaredExtensionsFromRaw(extensions);\n}\n/**\n* Reject extension descriptors whose configured target disagrees with\n* the project target before any on-disk read.\n*/\nfunction refuseDeclaredExtensionTargetMismatch(inputs) {\n\tfor (const declared of declaredExtensionsFromInputs(inputs.extensions)) if (declared.targetId !== inputs.targetId) return targetMismatchError(declared.id, inputs.targetId, declared.targetId);\n\treturn null;\n}\n/**\n* Load the tolerant {@link ContractSpaceAggregate} once at the CLI\n* surface. Construction never throws on disk content; callers query\n* {@link ContractSpaceAggregate.app} / extension facets instead of\n* re-reading `migrations/`.\n*/\nasync function loadContractSpaceAggregateForCli(inputs) {\n\tconst targetFailure = refuseDeclaredExtensionTargetMismatch(inputs);\n\tif (targetFailure) return notOk(targetFailure);\n\treturn ok(await loadContractSpaceAggregate({\n\t\tmigrationsDir: inputs.migrationsDir,\n\t\tdeserializeContract: inputs.deserializeContract,\n\t\tappContract: inputs.appContract\n\t}));\n}\n/**\n* Run `checkIntegrity` on a loaded aggregate and map violations into\n* the contract-space refusal envelope, or return `null` when the model\n* is acceptable for the requested check scope.\n*/\nfunction refuseContractSpaceIntegrity(aggregate, options) {\n\treturn mapIntegrityViolations(aggregate.checkIntegrity(options));\n}\nconst PACKAGE_CORRUPTION_KINDS = /* @__PURE__ */ new Set([\n\t\"hashMismatch\",\n\t\"providedInvariantsMismatch\",\n\t\"packageUnloadable\"\n]);\n/**\n* Reader-subset integrity refusal for `migration status`: package\n* corruptions only (`hashMismatch`, `providedInvariantsMismatch`,\n* `packageUnloadable`).\n*/\nfunction refusePackageCorruptionOnAggregate(aggregate) {\n\treturn mapIntegrityViolations(aggregate.checkIntegrity().filter((v) => PACKAGE_CORRUPTION_KINDS.has(v.kind)));\n}\n/**\n* Construct the tolerant {@link ContractSpaceAggregate} at the CLI\n* surface and apply the explicit integrity refusal.\n*\n* App-space migration packages are read from `migrations/<app>/` by the\n* loader itself; callers no longer thread them through.\n*/\nasync function buildContractSpaceAggregate(inputs) {\n\tconst declaredExtensions = declaredExtensionsFromInputs(inputs.extensions);\n\tconst loaded = await loadContractSpaceAggregateForCli(inputs);\n\tif (!loaded.ok) return loaded;\n\tconst failure = refuseContractSpaceIntegrity(loaded.value, {\n\t\tdeclaredExtensions,\n\t\tcheckContracts: true\n\t});\n\tif (failure) return notOk(failure);\n\treturn ok(loaded.value);\n}\n/**\n* Build a minimal app {@link Contract} carrying only the project's\n* contract-identity (`storage.storageHash` + `target` / `targetFamily`)\n* when the real `contract.json` is absent or undeserializable.\n*\n* `loadContractSpaceAggregate` requires an `appContract` to synthesise the\n* app space's head ref from its storage hash. Read commands query only that\n* hash and the target — never `models` — so an empty-`models` stand-in is\n* sufficient for them. It is *not* a valid contract for any consumer that\n* reads schema, which is why this is confined to the read-aggregate path.\n*/\nfunction appContractStandInFromIdentity(args) {\n\treturn blindCast({\n\t\tstorage: { storageHash: args.contractHash },\n\t\tschemaVersion: \"0.0.0\",\n\t\ttarget: args.targetId,\n\t\ttargetFamily: args.targetFamily,\n\t\tmodels: {},\n\t\tprofileHash: EMPTY_CONTRACT_HASH\n\t});\n}\nasync function loadContractRawSafely(config) {\n\ttry {\n\t\tconst raw = await readFile(resolveContractPath(config), \"utf-8\");\n\t\treturn JSON.parse(raw);\n\t} catch {\n\t\treturn null;\n\t}\n}\n/**\n* Tolerant {@link ContractSpaceAggregate} assembly for read-only CLI\n* commands. No integrity gate — callers query `aggregate.app` (or other\n* facets) without re-reading `migrations/`. When `contract.json` is absent\n* or undeserializable, the app contract falls back to an identity-only\n* stand-in ({@link appContractStandInFromIdentity}), so these commands\n* load without requiring a readable contract.\n*/\nasync function buildReadAggregate(config, options) {\n\tlet contractHash = EMPTY_CONTRACT_HASH;\n\ttry {\n\t\tcontractHash = (await readContractEnvelope(config)).storageHash;\n\t} catch {}\n\ttry {\n\t\tconst contractRawForAggregate = await loadContractRawSafely(config);\n\t\tconst stack = createControlStack(config);\n\t\tconst familyInstance = config.family.create(stack);\n\t\tconst deserializeContract = (json) => familyInstance.deserializeContract(json);\n\t\tlet appContractForLoad = appContractStandInFromIdentity({\n\t\t\tcontractHash,\n\t\t\ttargetId: config.target.id,\n\t\t\ttargetFamily: config.target.familyId\n\t\t});\n\t\tif (contractRawForAggregate !== null) try {\n\t\t\tappContractForLoad = deserializeContract(contractRawForAggregate);\n\t\t} catch {}\n\t\tconst loaded = await loadContractSpaceAggregateForCli({\n\t\t\ttargetId: config.target.id,\n\t\t\tmigrationsDir: options.migrationsDir,\n\t\t\tappContract: appContractForLoad,\n\t\t\textensions: config.extensions ?? [],\n\t\t\tdeserializeContract\n\t\t});\n\t\tif (!loaded.ok) return loaded;\n\t\treturn ok({\n\t\t\taggregate: loaded.value,\n\t\t\tcontractHash\n\t\t});\n\t} catch (error) {\n\t\tif (MigrationToolsError.is(error)) return notOk(error);\n\t\treturn notOk(errorUnexpected(error instanceof Error ? error.message : String(error), { why: `Failed to read migrations directory: ${error instanceof Error ? error.message : String(error)}` }));\n\t}\n}\n//#endregion\nexport { loadContractSpaceAggregateForCli as a, refuseDeclaredExtensionTargetMismatch as c, toExtensionInputs as d, loadContractRawSafely as i, refusePackageCorruptionOnAggregate as l, buildContractSpaceAggregate as n, mapIntegrityViolations as o, buildReadAggregate as r, refuseContractSpaceIntegrity as s, appContractStandInFromIdentity as t, toDeclaredExtensionsFromRaw as u };\n\n//# sourceMappingURL=contract-space-aggregate-loader-sF0OJ6oz.mjs.map"],"mappings":";;;;;;;;;;;;;;;AAeA,SAAS,kBAAkB,YAAY;CACtC,OAAO,WAAW,KAAK,QAAQ;EAC9B,MAAM,OAAO;EACb,IAAI,KAAK,kBAAkB,KAAK,GAAG,OAAO;GACzC,IAAI,KAAK;GACT,UAAU,KAAK;EAChB;EACA,OAAO;GACN,IAAI,KAAK;GACT,UAAU,KAAK;GACf,eAAe;IACd,cAAc,KAAK,cAAc;IACjC,SAAS,KAAK,cAAc;IAC5B,YAAY,KAAK,cAAc,cAAc,CAAC;GAC/C;EACD;CACD,CAAC;AACF;;;;;;;;;;;;;;;;;;;;AAoBA,SAAS,4BAA4B,YAAY;CAChD,MAAM,UAAU,CAAC;CACjB,KAAK,MAAM,OAAO,YAAY;EAC7B,IAAI,OAAO,QAAQ,YAAY,QAAQ,MAAM;EAC7C,MAAM,aAAa,OAAO,yBAAyB,KAAK,eAAe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,MAAM,UAAU,OAAO,KAAK,IAAI,CAAC,CAAC;CAChM;AACD"}
|
|
1
|
+
{"version":3,"file":"contract-space-aggregate-loader-1wG1OiDk-D75luh5-.mjs","names":["CliStructuredError"],"sources":["../../../../1-framework/3-tooling/cli/dist/contract-space-aggregate-loader-1wG1OiDk.mjs"],"sourcesContent":["import { M as errorUnexpected, t as CliStructuredError } from \"./cli-errors-CihMAEVj.mjs\";\nimport { o as readContractEnvelope, s as resolveContractPath } from \"./command-helpers-Dw3LDEu_.mjs\";\nimport { notOk, ok } from \"@internal/utils/result\";\nimport { readFile } from \"node:fs/promises\";\nimport { createControlStack } from \"@internal/framework-components/control\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { loadContractSpaceAggregate } from \"@internal/migration-tools/aggregate\";\nimport { EMPTY_CONTRACT_HASH } from \"@internal/migration-tools/constants\";\nimport { MigrationToolsError } from \"@internal/migration-tools/errors\";\n//#region src/utils/extension-pack-inputs.ts\n/**\n* Project the CLI's `Config.extensions` array into the canonical\n* {@link ExtensionPackInput} shape. The single `as ExtensionPackLike`\n* structural cast in the CLI lives inside this function.\n*/\nfunction toExtensionInputs(extensions) {\n\treturn extensions.map((raw) => {\n\t\tconst pack = raw;\n\t\tif (pack.contractSpace === void 0) return {\n\t\t\tid: pack.id,\n\t\t\ttargetId: pack.targetId\n\t\t};\n\t\treturn {\n\t\t\tid: pack.id,\n\t\t\ttargetId: pack.targetId,\n\t\t\tcontractSpace: {\n\t\t\t\tcontractJson: pack.contractSpace.contractJson,\n\t\t\t\theadRef: pack.contractSpace.headRef,\n\t\t\t\tmigrations: pack.contractSpace.migrations ?? []\n\t\t\t}\n\t\t};\n\t});\n}\n/**\n* Minimal aggregate-loader projection that extracts `id` + `targetId`\n* from raw extension pack descriptors **without invoking any\n* `contractSpace` accessor**. Inspects the own-property descriptor so\n* that getter-backed `contractSpace` declarations are detected but\n* never called.\n*\n* Inclusion semantics match {@link toDeclaredExtensions}: a data\n* property whose value is explicitly `undefined` is treated as \"no\n* contract-space declaration\" and skipped, mirroring the\n* `pack.contractSpace === undefined` check used on canonicalised\n* inputs. Prototype-chain `contractSpace` properties (no own\n* descriptor) are also skipped.\n*\n* This variant must be used by `buildContractSpaceAggregate` so that\n* the aggregate path (including `db verify`) never reads\n* `contractSpace.contractJson` from extension descriptors — the loader\n* always reads the contract from on-disk artefacts instead.\n*/\nfunction toDeclaredExtensionsFromRaw(extensions) {\n\tconst entries = [];\n\tfor (const raw of extensions) {\n\t\tif (typeof raw !== \"object\" || raw === null) continue;\n\t\tconst descriptor = Object.getOwnPropertyDescriptor(raw, \"contractSpace\");\n\t\tif (descriptor === void 0) continue;\n\t\tif (\"value\" in descriptor && descriptor.value === void 0) continue;\n\t\tconst pack = raw;\n\t\tentries.push({\n\t\t\tid: pack.id,\n\t\t\ttargetId: pack.targetId\n\t\t});\n\t}\n\treturn entries;\n}\n//#endregion\n//#region src/control-api/operations/contract-space-aggregate-loader.ts\nconst CONTRACT_SPACES_DOCS_URL = \"https://pris.ly/contract-spaces\";\nfunction contractSpaceViolationError(summary, options) {\n\treturn new CliStructuredError(\"MIGRATION.CONTRACT_SPACE_VIOLATION\", summary, {\n\t\twhy: options.why,\n\t\tfix: options.fix,\n\t\tdocsUrl: CONTRACT_SPACES_DOCS_URL,\n\t\tmeta: { violations: options.violations }\n\t});\n}\n/**\n* Build the `MIGRATION.CONTRACT_SPACE_VIOLATION` structured-error envelope for a contract-space\n* target mismatch. Shared between the declared-extension precheck (the\n* descriptor's configured target disagrees with the project target) and\n* the on-disk-contract check surfaced by `checkIntegrity`.\n*/\nfunction targetMismatchError(spaceId, expected, actual) {\n\treturn contractSpaceViolationError(`Contract-space target mismatch for \"${spaceId}\"`, {\n\t\twhy: `Space \"${spaceId}\" targets \"${actual}\" but the project's adapter targets \"${expected}\".`,\n\t\tfix: \"Update the extension descriptor to target the configured database, or change the project adapter.\",\n\t\tviolations: [{\n\t\t\tkind: \"targetMismatch\",\n\t\t\tspaceId,\n\t\t\texpected,\n\t\t\tactual\n\t\t}]\n\t});\n}\n/**\n* Human-readable detail for an integrity violation, used as the `why`\n* of the `integrityFailure` envelope. Mirrors the messages the prior\n* throw-on-load loader produced so downstream consumers see the same\n* text for the same on-disk state.\n*/\nfunction describeIntegrityViolation(violation) {\n\tswitch (violation.kind) {\n\t\tcase \"hashMismatch\": return `Migration \"${violation.dirName}\" stored hash \"${violation.stored}\" does not match computed hash \"${violation.computed}\".`;\n\t\tcase \"providedInvariantsMismatch\": return `Migration \"${violation.dirName}\" providedInvariants in migration.json disagrees with ops.json.`;\n\t\tcase \"packageUnloadable\": return `Migration \"${violation.dirName}\" could not be loaded: ${violation.detail}`;\n\t\tcase \"sameSourceAndTarget\": return `Migration \"${violation.dirName}\" has source equal to target (${violation.hash}) with no data invariant — a true no-op self-edge.`;\n\t\tcase \"headRefMissing\": return `Head ref \\`refs/head.json\\` is missing for contract space \"${violation.spaceId}\".`;\n\t\tcase \"headRefNotInGraph\": return `Head ref ${violation.hash} for contract space \"${violation.spaceId}\" is not present in the migration graph.`;\n\t\tcase \"refUnreadable\": return `Ref \"${violation.refName}\" for contract space \"${violation.spaceId}\" is unreadable: ${violation.detail}`;\n\t\tcase \"duplicateMigrationHash\": return `Multiple migrations in space \"${violation.spaceId}\" share migrationHash \"${violation.migrationHash}\" (${violation.dirNames.join(\", \")}).`;\n\t\tdefault: {\n\t\t\tconst spaceId = \"spaceId\" in violation ? violation.spaceId : \"*\";\n\t\t\treturn `Integrity violation \"${violation.kind}\" for contract space \"${spaceId}\".`;\n\t\t}\n\t}\n}\n/**\n* Map the integrity violations `checkIntegrity` reports into a single\n* CLI structured-error envelope, preserving the error codes the prior\n* throw-on-load loader emitted: `MIGRATION.CONTRACT_SPACE_LAYOUT_VIOLATION`\n* (layout drift, bundled) and `MIGRATION.CONTRACT_SPACE_VIOLATION` (target /\n* disjointness / contract-validation / structural integrity). Returns\n* `null` when there is nothing to refuse on.\n*\n* Precedence reproduces the prior loader's first-failure ordering:\n* layout drift first (every offence bundled into one envelope), then\n* target mismatch, then disjointness, then a contract-validation\n* failure, then any remaining structural integrity violation.\n*/\nfunction mapIntegrityViolations(violations) {\n\tif (violations.length === 0) return null;\n\tconst layout = violations.filter((v) => v.kind === \"orphanSpaceDir\" || v.kind === \"declaredButUnmigrated\");\n\tif (layout.length > 0) {\n\t\tconst lines = layout.map((v) => `- [${v.kind}] ${v.spaceId}`);\n\t\treturn new CliStructuredError(\"MIGRATION.CONTRACT_SPACE_LAYOUT_VIOLATION\", layout.length === 1 ? \"Contract-space layout violation detected\" : `Contract-space layout violations detected (${layout.length})`, {\n\t\t\twhy: `The on-disk \\`migrations/\\` directory and your \\`extensions\\` declaration are not in agreement.\\n${lines.join(\"\\n\")}`,\n\t\t\tfix: \"Declare the extension in `extensions` and re-emit its contract-space artefacts, or remove the orphan `migrations/<space>` directory.\",\n\t\t\tdocsUrl: CONTRACT_SPACES_DOCS_URL,\n\t\t\tmeta: { violations: layout }\n\t\t});\n\t}\n\tconst targetMismatch = violations.find((v) => v.kind === \"targetMismatch\");\n\tif (targetMismatch && targetMismatch.kind === \"targetMismatch\") return targetMismatchError(targetMismatch.spaceId, targetMismatch.expected, targetMismatch.actual);\n\tconst disjointness = violations.find((v) => v.kind === \"disjointness\");\n\tif (disjointness && disjointness.kind === \"disjointness\") return contractSpaceViolationError(`Contract-space disjointness violation: storage element \"${disjointness.element}\" claimed by multiple spaces`, {\n\t\twhy: `Spaces ${disjointness.claimedBy.map((s) => `\"${s}\"`).join(\", \")} all claim the storage element \"${disjointness.element}\". Each storage element must be owned by exactly one contract space.`,\n\t\tfix: \"Update the conflicting contracts so each storage element is claimed by exactly one space.\",\n\t\tviolations: [disjointness]\n\t});\n\tconst contractUnreadable = violations.find((v) => v.kind === \"contractUnreadable\");\n\tif (contractUnreadable && contractUnreadable.kind === \"contractUnreadable\") return contractSpaceViolationError(`Contract-space contract validation failed for \"${contractUnreadable.spaceId}\"`, {\n\t\twhy: contractUnreadable.detail,\n\t\tfix: \"Re-emit the extension contract with `prisma-next contract emit`, or fix the extension pack descriptor producing the invalid contract.\",\n\t\tviolations: [contractUnreadable]\n\t});\n\tconst structural = violations[0];\n\treturn contractSpaceViolationError(`Contract-space integrity failure for \"${\"spaceId\" in structural ? structural.spaceId : \"*\"}\"`, {\n\t\twhy: describeIntegrityViolation(structural),\n\t\tfix: \"Re-emit the affected migration package(s) or restore the on-disk `migrations/` directory from version control.\",\n\t\tviolations: [structural]\n\t});\n}\nfunction declaredExtensionsFromInputs(extensions) {\n\treturn toDeclaredExtensionsFromRaw(extensions);\n}\n/**\n* Reject extension descriptors whose configured target disagrees with\n* the project target before any on-disk read.\n*/\nfunction refuseDeclaredExtensionTargetMismatch(inputs) {\n\tfor (const declared of declaredExtensionsFromInputs(inputs.extensions)) if (declared.targetId !== inputs.targetId) return targetMismatchError(declared.id, inputs.targetId, declared.targetId);\n\treturn null;\n}\n/**\n* Load the tolerant {@link ContractSpaceAggregate} once at the CLI\n* surface. Construction never throws on disk content; callers query\n* {@link ContractSpaceAggregate.app} / extension facets instead of\n* re-reading `migrations/`.\n*/\nasync function loadContractSpaceAggregateForCli(inputs) {\n\tconst targetFailure = refuseDeclaredExtensionTargetMismatch(inputs);\n\tif (targetFailure) return notOk(targetFailure);\n\treturn ok(await loadContractSpaceAggregate({\n\t\tmigrationsDir: inputs.migrationsDir,\n\t\tdeserializeContract: inputs.deserializeContract,\n\t\tappContract: inputs.appContract\n\t}));\n}\n/**\n* Run `checkIntegrity` on a loaded aggregate and map violations into\n* the contract-space refusal envelope, or return `null` when the model\n* is acceptable for the requested check scope.\n*/\nfunction refuseContractSpaceIntegrity(aggregate, options) {\n\treturn mapIntegrityViolations(aggregate.checkIntegrity(options));\n}\nconst PACKAGE_CORRUPTION_KINDS = /* @__PURE__ */ new Set([\n\t\"hashMismatch\",\n\t\"providedInvariantsMismatch\",\n\t\"packageUnloadable\"\n]);\n/**\n* Reader-subset integrity refusal for `migration status`: package\n* corruptions only (`hashMismatch`, `providedInvariantsMismatch`,\n* `packageUnloadable`).\n*/\nfunction refusePackageCorruptionOnAggregate(aggregate) {\n\treturn mapIntegrityViolations(aggregate.checkIntegrity().filter((v) => PACKAGE_CORRUPTION_KINDS.has(v.kind)));\n}\n/**\n* Construct the tolerant {@link ContractSpaceAggregate} at the CLI\n* surface and apply the explicit integrity refusal.\n*\n* App-space migration packages are read from `migrations/<app>/` by the\n* loader itself; callers no longer thread them through.\n*/\nasync function buildContractSpaceAggregate(inputs) {\n\tconst declaredExtensions = declaredExtensionsFromInputs(inputs.extensions);\n\tconst loaded = await loadContractSpaceAggregateForCli(inputs);\n\tif (!loaded.ok) return loaded;\n\tconst failure = refuseContractSpaceIntegrity(loaded.value, {\n\t\tdeclaredExtensions,\n\t\tcheckContracts: true\n\t});\n\tif (failure) return notOk(failure);\n\treturn ok(loaded.value);\n}\n/**\n* Build a minimal app {@link Contract} carrying only the project's\n* contract-identity (`storage.storageHash` + `target` / `targetFamily`)\n* when the real `contract.json` is absent or undeserializable.\n*\n* `loadContractSpaceAggregate` requires an `appContract` to synthesise the\n* app space's head ref from its storage hash. Read commands query only that\n* hash and the target — never `models` — so an empty-`models` stand-in is\n* sufficient for them. It is *not* a valid contract for any consumer that\n* reads schema, which is why this is confined to the read-aggregate path.\n*/\nfunction appContractStandInFromIdentity(args) {\n\treturn blindCast({\n\t\tstorage: { storageHash: args.contractHash },\n\t\tschemaVersion: \"0.0.0\",\n\t\ttarget: args.targetId,\n\t\ttargetFamily: args.targetFamily,\n\t\tmodels: {},\n\t\tprofileHash: EMPTY_CONTRACT_HASH\n\t});\n}\nasync function loadContractRawSafely(config) {\n\ttry {\n\t\tconst raw = await readFile(resolveContractPath(config), \"utf-8\");\n\t\treturn JSON.parse(raw);\n\t} catch {\n\t\treturn null;\n\t}\n}\n/**\n* Tolerant {@link ContractSpaceAggregate} assembly for read-only CLI\n* commands. No integrity gate — callers query `aggregate.app` (or other\n* facets) without re-reading `migrations/`. When `contract.json` is absent\n* or undeserializable, the app contract falls back to an identity-only\n* stand-in ({@link appContractStandInFromIdentity}), so these commands\n* load without requiring a readable contract.\n*/\nasync function buildReadAggregate(config, options) {\n\tlet contractHash = EMPTY_CONTRACT_HASH;\n\ttry {\n\t\tcontractHash = (await readContractEnvelope(config)).storageHash;\n\t} catch {}\n\ttry {\n\t\tconst contractRawForAggregate = await loadContractRawSafely(config);\n\t\tconst stack = createControlStack(config);\n\t\tconst familyInstance = config.family.create(stack);\n\t\tconst deserializeContract = (json) => familyInstance.deserializeContract(json);\n\t\tlet appContractForLoad = appContractStandInFromIdentity({\n\t\t\tcontractHash,\n\t\t\ttargetId: config.target.id,\n\t\t\ttargetFamily: config.target.familyId\n\t\t});\n\t\tif (contractRawForAggregate !== null) try {\n\t\t\tappContractForLoad = deserializeContract(contractRawForAggregate);\n\t\t} catch {}\n\t\tconst loaded = await loadContractSpaceAggregateForCli({\n\t\t\ttargetId: config.target.id,\n\t\t\tmigrationsDir: options.migrationsDir,\n\t\t\tappContract: appContractForLoad,\n\t\t\textensions: config.extensions ?? [],\n\t\t\tdeserializeContract\n\t\t});\n\t\tif (!loaded.ok) return loaded;\n\t\treturn ok({\n\t\t\taggregate: loaded.value,\n\t\t\tcontractHash\n\t\t});\n\t} catch (error) {\n\t\tif (MigrationToolsError.is(error)) return notOk(error);\n\t\treturn notOk(errorUnexpected(error instanceof Error ? error.message : String(error), { why: `Failed to read migrations directory: ${error instanceof Error ? error.message : String(error)}` }));\n\t}\n}\n//#endregion\nexport { loadContractSpaceAggregateForCli as a, refuseDeclaredExtensionTargetMismatch as c, toExtensionInputs as d, loadContractRawSafely as i, refusePackageCorruptionOnAggregate as l, buildContractSpaceAggregate as n, mapIntegrityViolations as o, buildReadAggregate as r, refuseContractSpaceIntegrity as s, appContractStandInFromIdentity as t, toDeclaredExtensionsFromRaw as u };\n\n//# sourceMappingURL=contract-space-aggregate-loader-1wG1OiDk.mjs.map"],"mappings":";;;;;;;;;;;;;;;AAeA,SAAS,kBAAkB,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AO,OAAO;EAC7B,CAAC;EACD,IAAI,4BAA4B,MAAM,IAAI;GACzC,qBAAqB,oBAAoB,uBAAuB;EACjE,QAAQ,CAAC;EACT,MAAM,SAAS,MAAM,iCAAiC;GACrD,UAAU,OAAO,OAAO;GACxB,eAAe,QAAQ;GACvB,aAAa;GACb,YAAY,OAAO,cAAc,CAAC;GAClC;EACD,CAAC;EACD,IAAI,CAAC,OAAO,IAAI,OAAO;EACvB,OAAO,GAAG;GACT,WAAW,OAAO;GAClB;EACD,CAAC;CACF,SAAS,OAAO;EACf,IAAI,oBAAoB,GAAG,KAAK,GAAG,OAAO,MAAM,KAAK;EACrD,OAAO,MAAM,gBAAgB,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,GAAG,EAAE,KAAK,wCAAwC,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,IAAI,CAAC,CAAC;CAChM;AACD"}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { D as errorRunnerFailed, N as errorUnexpected, O as errorRuntime$1, s as errorContractValidationFailed, t as CliStructuredError$1, y as errorMigrationPlanningFailed } from "./cli-errors-CihMAEVj-C1uUYBop.mjs";
|
|
2
|
-
import { c as
|
|
3
|
-
import { _ as resolveMigrationPaths, b as setCommandExamples, m as parseGlobalFlagsOrExit, n as closeQuietly, u as handleResult, v as sanitizeErrorMessage, y as setCommandDescriptions } from "./command-helpers-
|
|
4
|
-
import { o as resolveRefAdvancementFields } from "./ref-advancement-DaZBzm7m-
|
|
5
|
-
import { n as prepareMigrationContext, t as addMigrationCommandOptions } from "./migration-command-scaffold-
|
|
2
|
+
import { c as formatMigrationApplyOutput, l as formatMigrationJson, r as createTerminalUI, u as formatMigrationPlanOutput } from "./terminal-ui-JJKxvT0q-CPDEJqqU.mjs";
|
|
3
|
+
import { _ as resolveMigrationPaths, b as setCommandExamples, m as parseGlobalFlagsOrExit, n as closeQuietly, u as handleResult, v as sanitizeErrorMessage, y as setCommandDescriptions } from "./command-helpers-Dw3LDEu_-B4AETH4D.mjs";
|
|
4
|
+
import { o as resolveRefAdvancementFields } from "./ref-advancement-DaZBzm7m-WoqnFAyr.mjs";
|
|
5
|
+
import { n as prepareMigrationContext, t as addMigrationCommandOptions } from "./migration-command-scaffold-CIMPoR6f-Ba-S9gXa.mjs";
|
|
6
6
|
import { ifDefined } from "@prisma/orm-framework/utils/defined";
|
|
7
7
|
import { isStructuredError } from "@prisma/orm-framework/utils/structured-error";
|
|
8
8
|
import { assertNever } from "@prisma/orm-framework/utils/internal-error";
|
|
9
9
|
import { notOk, ok } from "@prisma/orm-framework/utils/result";
|
|
10
10
|
import { Command } from "commander";
|
|
11
|
-
//#region ../../../1-framework/3-tooling/cli/dist/db-init-
|
|
11
|
+
//#region ../../../1-framework/3-tooling/cli/dist/db-init-CEk9Utl4.mjs
|
|
12
12
|
/**
|
|
13
13
|
* Maps a DbInitFailure to a CliStructuredError for consistent error handling.
|
|
14
14
|
*/
|
|
@@ -138,4 +138,4 @@ function createDbInitCommand() {
|
|
|
138
138
|
//#endregion
|
|
139
139
|
export { createDbInitCommand as t };
|
|
140
140
|
|
|
141
|
-
//# sourceMappingURL=db-init-
|
|
141
|
+
//# sourceMappingURL=db-init-CEk9Utl4-vGmJajwZ.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"db-init-CU_x-p2M-_6oEFLiG.mjs","names":["errorRuntime","CliStructuredError"],"sources":["../../../../1-framework/3-tooling/cli/dist/db-init-CU_x-p2M.mjs"],"sourcesContent":["import { D as errorRuntime, E as errorRunnerFailed, M as errorUnexpected, o as errorContractValidationFailed, t as CliStructuredError, v as errorMigrationPlanningFailed } from \"./cli-errors-CihMAEVj.mjs\";\nimport { c as formatMigrationPlanOutput, o as formatMigrationApplyOutput, s as formatMigrationJson, t as createTerminalUI } from \"./terminal-ui-DQNCDg2u.mjs\";\nimport { _ as parseGlobalFlagsOrExit, c as resolveMigrationPaths, d as setCommandExamples, l as sanitizeErrorMessage, n as closeQuietly, u as setCommandDescriptions, v as handleResult } from \"./command-helpers-DutQjYgy.mjs\";\nimport { o as resolveRefAdvancementFields } from \"./ref-advancement-DaZBzm7m.mjs\";\nimport { n as prepareMigrationContext, t as addMigrationCommandOptions } from \"./migration-command-scaffold-BezR8GWB.mjs\";\nimport { Command } from \"commander\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { notOk, ok } from \"@internal/utils/result\";\nimport { assertNever } from \"@internal/utils/internal-error\";\nimport { isStructuredError } from \"@internal/utils/structured-error\";\n//#region src/commands/db-init.ts\n/**\n* Maps a DbInitFailure to a CliStructuredError for consistent error handling.\n*/\nfunction mapDbInitFailure(failure) {\n\tif (failure.code === \"PLANNING_FAILED\") return errorMigrationPlanningFailed({ conflicts: failure.conflicts ?? [] });\n\tif (failure.code === \"MIGRATION.MARKER_ORIGIN_MISMATCH\") {\n\t\tconst mismatchParts = [];\n\t\tif (failure.marker?.storageHash !== failure.destination?.storageHash && failure.marker?.storageHash && failure.destination?.storageHash) mismatchParts.push(`storageHash (marker: ${failure.marker.storageHash}, destination: ${failure.destination.storageHash})`);\n\t\tif (failure.marker?.profileHash !== failure.destination?.profileHash && failure.marker?.profileHash && failure.destination?.profileHash) mismatchParts.push(`profileHash (marker: ${failure.marker.profileHash}, destination: ${failure.destination.profileHash})`);\n\t\treturn errorRuntime(\"MIGRATION.MARKER_ORIGIN_MISMATCH\", `Existing database signature does not match plan destination.${mismatchParts.length > 0 ? ` Mismatch in ${mismatchParts.join(\" and \")}.` : \"\"}`, {\n\t\t\twhy: \"Database has an existing signature (marker) that does not match the target contract\",\n\t\t\tfix: \"If bootstrapping, drop/reset the database then re-run `prisma-next db init`; otherwise reconcile schema/marker using your migration workflow\",\n\t\t\tmeta: {\n\t\t\t\t...ifDefined(\"markerStorageHash\", failure.marker?.storageHash),\n\t\t\t\t...ifDefined(\"destinationStorageHash\", failure.destination?.storageHash),\n\t\t\t\t...ifDefined(\"markerProfileHash\", failure.marker?.profileHash),\n\t\t\t\t...ifDefined(\"destinationProfileHash\", failure.destination?.profileHash)\n\t\t\t}\n\t\t});\n\t}\n\tif (failure.code === \"RUNNER_FAILED\") {\n\t\tconst fix = (typeof failure.meta?.[\"runnerErrorCode\"] === \"string\" ? failure.meta[\"runnerErrorCode\"] : void 0) === \"MIGRATION.LEGACY_MARKER_SHAPE\" ? \"Legacy marker-table shape detected. Drop `prisma_contract.marker` (Postgres) or `_prisma_marker` (SQLite) and re-run `prisma-next db init` to recreate it with the current per-space schema.\" : \"Fix the schema mismatch (db init is additive-only), or drop/reset the database and re-run `prisma-next db init`\";\n\t\treturn errorRunnerFailed(failure.summary, {\n\t\t\twhy: failure.why ?? \"Migration runner failed\",\n\t\t\tfix,\n\t\t\t...ifDefined(\"meta\", failure.meta),\n\t\t\t...ifDefined(\"cause\", failure.cause)\n\t\t});\n\t}\n\tconst exhaustive = failure.code;\n\treturn assertNever(exhaustive, `Unhandled DbInitFailure code: ${String(exhaustive)}`);\n}\n/**\n* Executes the db init command and returns a structured Result.\n*/\nasync function executeDbInitCommand(options, flags, ui, startTime) {\n\tconst ctxResult = await prepareMigrationContext(options, flags, ui, {\n\t\tcommandName: \"db init\",\n\t\tdescription: \"Bootstrap a database to match the current contract\",\n\t\turl: \"https://pris.ly/db-init\"\n\t});\n\tif (!ctxResult.ok) return ctxResult;\n\tconst { client, config, contractJson, dbConnection, onProgress, contractPathAbsolute } = ctxResult.value;\n\tconst { migrationsDir, refsDir } = resolveMigrationPaths(options.config, config, process.cwd());\n\ttry {\n\t\tawait client.connect(dbConnection);\n\t\tconst result = await client.dbInit({\n\t\t\tcontract: contractJson,\n\t\t\tmode: options.dryRun ? \"plan\" : \"apply\",\n\t\t\tmigrationsDir,\n\t\t\tonProgress\n\t\t});\n\t\tif (!result.ok) return notOk(mapDbInitFailure(result.failure));\n\t\tconst advancementHash = result.value.mode === \"apply\" ? result.value.marker?.storageHash ?? result.value.destination.storageHash : result.value.destination.storageHash;\n\t\tconst advancement = await resolveRefAdvancementFields({\n\t\t\t...ifDefined(\"advanceRef\", options.advanceRef),\n\t\t\t...ifDefined(\"db\", options.db),\n\t\t\trefsDir,\n\t\t\tmigrationsDir,\n\t\t\tcontractJson,\n\t\t\tcontractJsonPath: contractPathAbsolute,\n\t\t\tmode: result.value.mode,\n\t\t\thash: advancementHash\n\t\t});\n\t\tif (!advancement.ok) return notOk(advancement.failure);\n\t\tconst refAdvancementFields = advancement.value;\n\t\treturn ok({\n\t\t\tok: true,\n\t\t\tmode: result.value.mode,\n\t\t\tplan: {\n\t\t\t\ttargetId: ctxResult.value.config.target.targetId,\n\t\t\t\tdestination: {\n\t\t\t\t\tstorageHash: result.value.destination.storageHash,\n\t\t\t\t\t...ifDefined(\"profileHash\", result.value.destination.profileHash)\n\t\t\t\t},\n\t\t\t\toperations: result.value.plan.operations.map((op) => ({\n\t\t\t\t\tid: op.id,\n\t\t\t\t\tlabel: op.label,\n\t\t\t\t\toperationClass: op.operationClass\n\t\t\t\t})),\n\t\t\t\t...ifDefined(\"preview\", result.value.plan.preview)\n\t\t\t},\n\t\t\t...result.value.execution ? { execution: {\n\t\t\t\toperationsPlanned: result.value.execution.operationsPlanned,\n\t\t\t\toperationsExecuted: result.value.execution.operationsExecuted\n\t\t\t} } : {},\n\t\t\t...result.value.marker ? { marker: {\n\t\t\t\tstorageHash: result.value.marker.storageHash,\n\t\t\t\t...ifDefined(\"profileHash\", result.value.marker.profileHash)\n\t\t\t} } : {},\n\t\t\t...ifDefined(\"perSpace\", result.value.perSpace),\n\t\t\tadvancedRef: refAdvancementFields.advancedRef,\n\t\t\tplannedAdvanceRef: refAdvancementFields.plannedAdvanceRef,\n\t\t\tsummary: result.value.summary,\n\t\t\ttimings: { total: Date.now() - startTime }\n\t\t});\n\t} catch (error) {\n\t\tif (CliStructuredError.is(error)) return notOk(error);\n\t\tif (isStructuredError(error) && error.code === \"CONTRACT.VALIDATION_FAILED\") return notOk(errorContractValidationFailed(`Contract validation failed: ${error.message}`, { where: { path: contractPathAbsolute } }));\n\t\tconst safeMessage = sanitizeErrorMessage(error instanceof Error ? error.message : String(error), typeof dbConnection === \"string\" ? dbConnection : void 0);\n\t\treturn notOk(errorUnexpected(safeMessage, { why: `Unexpected error during db init: ${safeMessage}` }));\n\t} finally {\n\t\tawait closeQuietly(client);\n\t}\n}\nfunction createDbInitCommand() {\n\tconst command = new Command(\"init\");\n\tsetCommandDescriptions(command, \"Bootstrap a database to match the current contract and sign it\", \"Initializes a database to match your emitted contract using additive-only operations.\\nCreates any missing tables, columns, indexes, and constraints defined in your contract.\\nLeaves existing compatible structures in place, surfaces conflicts when destructive changes\\nwould be required, and signs the database to track contract state. Use --dry-run to\\npreview changes without applying.\");\n\tsetCommandExamples(command, [\"prisma-next db init --db $DATABASE_URL\", \"prisma-next db init --db $DATABASE_URL --dry-run\"]);\n\taddMigrationCommandOptions(command);\n\tcommand.option(\"--advance-ref <name>\", \"Ref to advance to the post-command contract hash\");\n\tcommand.action(async (options) => {\n\t\tconst flags = parseGlobalFlagsOrExit(options);\n\t\tconst startTime = Date.now();\n\t\tconst ui = createTerminalUI(flags);\n\t\tconst exitCode = handleResult(await executeDbInitCommand(options, flags, ui, startTime), flags, ui, (dbInitResult) => {\n\t\t\tif (flags.json) ui.output(formatMigrationJson(dbInitResult));\n\t\t\telse {\n\t\t\t\tconst output = dbInitResult.mode === \"plan\" ? formatMigrationPlanOutput(dbInitResult, flags) : formatMigrationApplyOutput(dbInitResult, flags);\n\t\t\t\tif (output) ui.log(output);\n\t\t\t}\n\t\t});\n\t\tprocess.exit(exitCode);\n\t});\n\treturn command;\n}\n//#endregion\nexport { createDbInitCommand as t };\n\n//# sourceMappingURL=db-init-CU_x-p2M.mjs.map"],"mappings":";;;;;;;;;;;;;;AAcA,SAAS,iBAAiB,SAAS;CAClC,IAAI,QAAQ,SAAS,mBAAmB,OAAO,6BAA6B,EAAE,WAAW,QAAQ,aAAa,CAAC,EAAE,CAAC;CAClH,IAAI,QAAQ,SAAS,oCAAoC;EAC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G,OAAO,oBAAoB,YAAY,CAAC;QACtD;IACJ,MAAM,SAAS,aAAa,SAAS,SAAS,0BAA0B,cAAc,KAAK,IAAI,2BAA2B,cAAc,KAAK;IAC7I,IAAI,QAAQ,GAAG,IAAI,MAAM;GAC1B;EACD,CAAC;EACD,QAAQ,KAAK,QAAQ;CACtB,CAAC;CACD,OAAO;AACR"}
|
|
1
|
+
{"version":3,"file":"db-init-CEk9Utl4-vGmJajwZ.mjs","names":["errorRuntime","CliStructuredError"],"sources":["../../../../1-framework/3-tooling/cli/dist/db-init-CEk9Utl4.mjs"],"sourcesContent":["import { D as errorRuntime, E as errorRunnerFailed, M as errorUnexpected, o as errorContractValidationFailed, t as CliStructuredError, v as errorMigrationPlanningFailed } from \"./cli-errors-CihMAEVj.mjs\";\nimport { c as formatMigrationPlanOutput, o as formatMigrationApplyOutput, s as formatMigrationJson, t as createTerminalUI } from \"./terminal-ui-JJKxvT0q.mjs\";\nimport { _ as parseGlobalFlagsOrExit, c as resolveMigrationPaths, d as setCommandExamples, l as sanitizeErrorMessage, n as closeQuietly, u as setCommandDescriptions, v as handleResult } from \"./command-helpers-Dw3LDEu_.mjs\";\nimport { o as resolveRefAdvancementFields } from \"./ref-advancement-DaZBzm7m.mjs\";\nimport { n as prepareMigrationContext, t as addMigrationCommandOptions } from \"./migration-command-scaffold-CIMPoR6f.mjs\";\nimport { Command } from \"commander\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { notOk, ok } from \"@internal/utils/result\";\nimport { assertNever } from \"@internal/utils/internal-error\";\nimport { isStructuredError } from \"@internal/utils/structured-error\";\n//#region src/commands/db-init.ts\n/**\n* Maps a DbInitFailure to a CliStructuredError for consistent error handling.\n*/\nfunction mapDbInitFailure(failure) {\n\tif (failure.code === \"PLANNING_FAILED\") return errorMigrationPlanningFailed({ conflicts: failure.conflicts ?? [] });\n\tif (failure.code === \"MIGRATION.MARKER_ORIGIN_MISMATCH\") {\n\t\tconst mismatchParts = [];\n\t\tif (failure.marker?.storageHash !== failure.destination?.storageHash && failure.marker?.storageHash && failure.destination?.storageHash) mismatchParts.push(`storageHash (marker: ${failure.marker.storageHash}, destination: ${failure.destination.storageHash})`);\n\t\tif (failure.marker?.profileHash !== failure.destination?.profileHash && failure.marker?.profileHash && failure.destination?.profileHash) mismatchParts.push(`profileHash (marker: ${failure.marker.profileHash}, destination: ${failure.destination.profileHash})`);\n\t\treturn errorRuntime(\"MIGRATION.MARKER_ORIGIN_MISMATCH\", `Existing database signature does not match plan destination.${mismatchParts.length > 0 ? ` Mismatch in ${mismatchParts.join(\" and \")}.` : \"\"}`, {\n\t\t\twhy: \"Database has an existing signature (marker) that does not match the target contract\",\n\t\t\tfix: \"If bootstrapping, drop/reset the database then re-run `prisma-next db init`; otherwise reconcile schema/marker using your migration workflow\",\n\t\t\tmeta: {\n\t\t\t\t...ifDefined(\"markerStorageHash\", failure.marker?.storageHash),\n\t\t\t\t...ifDefined(\"destinationStorageHash\", failure.destination?.storageHash),\n\t\t\t\t...ifDefined(\"markerProfileHash\", failure.marker?.profileHash),\n\t\t\t\t...ifDefined(\"destinationProfileHash\", failure.destination?.profileHash)\n\t\t\t}\n\t\t});\n\t}\n\tif (failure.code === \"RUNNER_FAILED\") {\n\t\tconst fix = (typeof failure.meta?.[\"runnerErrorCode\"] === \"string\" ? failure.meta[\"runnerErrorCode\"] : void 0) === \"MIGRATION.LEGACY_MARKER_SHAPE\" ? \"Legacy marker-table shape detected. Drop `prisma_contract.marker` (Postgres) or `_prisma_marker` (SQLite) and re-run `prisma-next db init` to recreate it with the current per-space schema.\" : \"Fix the schema mismatch (db init is additive-only), or drop/reset the database and re-run `prisma-next db init`\";\n\t\treturn errorRunnerFailed(failure.summary, {\n\t\t\twhy: failure.why ?? \"Migration runner failed\",\n\t\t\tfix,\n\t\t\t...ifDefined(\"meta\", failure.meta),\n\t\t\t...ifDefined(\"cause\", failure.cause)\n\t\t});\n\t}\n\tconst exhaustive = failure.code;\n\treturn assertNever(exhaustive, `Unhandled DbInitFailure code: ${String(exhaustive)}`);\n}\n/**\n* Executes the db init command and returns a structured Result.\n*/\nasync function executeDbInitCommand(options, flags, ui, startTime) {\n\tconst ctxResult = await prepareMigrationContext(options, flags, ui, {\n\t\tcommandName: \"db init\",\n\t\tdescription: \"Bootstrap a database to match the current contract\",\n\t\turl: \"https://pris.ly/db-init\"\n\t});\n\tif (!ctxResult.ok) return ctxResult;\n\tconst { client, config, contractJson, dbConnection, onProgress, contractPathAbsolute } = ctxResult.value;\n\tconst { migrationsDir, refsDir } = resolveMigrationPaths(options.config, config, process.cwd());\n\ttry {\n\t\tawait client.connect(dbConnection);\n\t\tconst result = await client.dbInit({\n\t\t\tcontract: contractJson,\n\t\t\tmode: options.dryRun ? \"plan\" : \"apply\",\n\t\t\tmigrationsDir,\n\t\t\tonProgress\n\t\t});\n\t\tif (!result.ok) return notOk(mapDbInitFailure(result.failure));\n\t\tconst advancementHash = result.value.mode === \"apply\" ? result.value.marker?.storageHash ?? result.value.destination.storageHash : result.value.destination.storageHash;\n\t\tconst advancement = await resolveRefAdvancementFields({\n\t\t\t...ifDefined(\"advanceRef\", options.advanceRef),\n\t\t\t...ifDefined(\"db\", options.db),\n\t\t\trefsDir,\n\t\t\tmigrationsDir,\n\t\t\tcontractJson,\n\t\t\tcontractJsonPath: contractPathAbsolute,\n\t\t\tmode: result.value.mode,\n\t\t\thash: advancementHash\n\t\t});\n\t\tif (!advancement.ok) return notOk(advancement.failure);\n\t\tconst refAdvancementFields = advancement.value;\n\t\treturn ok({\n\t\t\tok: true,\n\t\t\tmode: result.value.mode,\n\t\t\tplan: {\n\t\t\t\ttargetId: ctxResult.value.config.target.targetId,\n\t\t\t\tdestination: {\n\t\t\t\t\tstorageHash: result.value.destination.storageHash,\n\t\t\t\t\t...ifDefined(\"profileHash\", result.value.destination.profileHash)\n\t\t\t\t},\n\t\t\t\toperations: result.value.plan.operations.map((op) => ({\n\t\t\t\t\tid: op.id,\n\t\t\t\t\tlabel: op.label,\n\t\t\t\t\toperationClass: op.operationClass\n\t\t\t\t})),\n\t\t\t\t...ifDefined(\"preview\", result.value.plan.preview)\n\t\t\t},\n\t\t\t...result.value.execution ? { execution: {\n\t\t\t\toperationsPlanned: result.value.execution.operationsPlanned,\n\t\t\t\toperationsExecuted: result.value.execution.operationsExecuted\n\t\t\t} } : {},\n\t\t\t...result.value.marker ? { marker: {\n\t\t\t\tstorageHash: result.value.marker.storageHash,\n\t\t\t\t...ifDefined(\"profileHash\", result.value.marker.profileHash)\n\t\t\t} } : {},\n\t\t\t...ifDefined(\"perSpace\", result.value.perSpace),\n\t\t\tadvancedRef: refAdvancementFields.advancedRef,\n\t\t\tplannedAdvanceRef: refAdvancementFields.plannedAdvanceRef,\n\t\t\tsummary: result.value.summary,\n\t\t\ttimings: { total: Date.now() - startTime }\n\t\t});\n\t} catch (error) {\n\t\tif (CliStructuredError.is(error)) return notOk(error);\n\t\tif (isStructuredError(error) && error.code === \"CONTRACT.VALIDATION_FAILED\") return notOk(errorContractValidationFailed(`Contract validation failed: ${error.message}`, { where: { path: contractPathAbsolute } }));\n\t\tconst safeMessage = sanitizeErrorMessage(error instanceof Error ? error.message : String(error), typeof dbConnection === \"string\" ? dbConnection : void 0);\n\t\treturn notOk(errorUnexpected(safeMessage, { why: `Unexpected error during db init: ${safeMessage}` }));\n\t} finally {\n\t\tawait closeQuietly(client);\n\t}\n}\nfunction createDbInitCommand() {\n\tconst command = new Command(\"init\");\n\tsetCommandDescriptions(command, \"Bootstrap a database to match the current contract and sign it\", \"Initializes a database to match your emitted contract using additive-only operations.\\nCreates any missing tables, columns, indexes, and constraints defined in your contract.\\nLeaves existing compatible structures in place, surfaces conflicts when destructive changes\\nwould be required, and signs the database to track contract state. Use --dry-run to\\npreview changes without applying.\");\n\tsetCommandExamples(command, [\"prisma-next db init --db $DATABASE_URL\", \"prisma-next db init --db $DATABASE_URL --dry-run\"]);\n\taddMigrationCommandOptions(command);\n\tcommand.option(\"--advance-ref <name>\", \"Ref to advance to the post-command contract hash\");\n\tcommand.action(async (options) => {\n\t\tconst flags = parseGlobalFlagsOrExit(options);\n\t\tconst startTime = Date.now();\n\t\tconst ui = createTerminalUI(flags);\n\t\tconst exitCode = handleResult(await executeDbInitCommand(options, flags, ui, startTime), flags, ui, (dbInitResult) => {\n\t\t\tif (flags.json) ui.output(formatMigrationJson(dbInitResult));\n\t\t\telse {\n\t\t\t\tconst output = dbInitResult.mode === \"plan\" ? formatMigrationPlanOutput(dbInitResult, flags) : formatMigrationApplyOutput(dbInitResult, flags);\n\t\t\t\tif (output) ui.log(output);\n\t\t\t}\n\t\t});\n\t\tprocess.exit(exitCode);\n\t});\n\treturn command;\n}\n//#endregion\nexport { createDbInitCommand as t };\n\n//# sourceMappingURL=db-init-CEk9Utl4.mjs.map"],"mappings":";;;;;;;;;;;;;;AAcA,SAAS,iBAAiB,SAAS;CAClC,IAAI,QAAQ,SAAS,mBAAmB,OAAO,6BAA6B,EAAE,WAAW,QAAQ,aAAa,CAAC,EAAE,CAAC;CAClH,IAAI,QAAQ,SAAS,oCAAoC;EACxD,MAAM,gBAAgB,CAAC;EACvB,IAAI,QAAQ,QAAQ,gBAAgB,QAAQ,aAAa,eAAe,QAAQ,QAAQ,eAAe,QAAQ,aAAa,aAAa,cAAc,KAAK,wBAAwB,QAAQ,OAAO,YAAY,iBAAiB,QAAQ,YAAY,YAAY,EAAE;EAClQ,IAAI,QAAQ,QAAQ,gBAAgB,QAAQ,aAAa,eAAe,QAAQ,QAAQ,eAAe,QAAQ,aAAa,aAAa,cAAc,KAAK,wBAAwB,QAAQ,OAAO,YAAY,iBAAiB,QAAQ,YAAY,YAAY,EAAE;EAClQ,OAAOA,eAAa,oCAAoC,+DAA+D,cAAc,SAAS,IAAI,gBAAgB,cAAc,KAAK,OAAO,EAAE,KAAK,MAAM;GACxM,KAAK;GACL,KAAK;GACL,MAAM;IACL,GAAG,UAAU,qBAAqB,QAAQ,QAAQ,WAAW;IAC7D,GAAG,UAAU,0BAA0B,Q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AAc,qBAAqB,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,GAAG,OAAO,iBAAiB,WAAW,eAAe,KAAK,CAAC;EACzJ,OAAO,MAAM,gBAAgB,aAAa,EAAE,KAAK,oCAAoC,cAAc,CAAC,CAAC;CACtG,UAAU;EACT,MAAM,aAAa,MAAM;CAC1B;AACD;AACA,SAAS,sBAAsB;CAC9B,MAAM,UAAU,IAAI,QAAQ,MAAM;CAClC,uBAAuB,SAAS,kEAAkE,qYAAqY;CACve,mBAAmB,SAAS,CAAC,0CAA0C,kDAAkD,CAAC;CAC1H,2BAA2B,OAAO;CAClC,QAAQ,OAAO,wBAAwB,kDAAkD;CACzF,QAAQ,OAAO,OAAO,YAAY;EACjC,MAAM,QAAQ,uBAAuB,OAAO;EAC5C,MAAM,YAAY,KAAK,IAAI;EAC3B,MAAM,KAAK,iBAAiB,KAAK;EACjC,MAAM,WAAW,aAAa,MAAM,qBAAqB,SAAS,OAAO,IAAI,SAAS,GAAG,OAAO,KAAK,iBAAiB;GACrH,IAAI,MAAM,MAAM,GAAG,OAAO,oBAAoB,YAAY,CAAC;QACtD;IACJ,MAAM,SAAS,aAAa,SAAS,SAAS,0BAA0B,cAAc,KAAK,IAAI,2BAA2B,cAAc,KAAK;IAC7I,IAAI,QAAQ,GAAG,IAAI,MAAM;GAC1B;EACD,CAAC;EACD,QAAQ,KAAK,QAAQ;CACtB,CAAC;CACD,OAAO;AACR"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { b as setCommandExamples, m as parseGlobalFlagsOrExit, t as addGlobalOptions, u as handleResult, y as setCommandDescriptions } from "./command-helpers-
|
|
3
|
-
import { t as inspectLiveSchema } from "./inspect-live-schema-
|
|
4
|
-
import { n as formatIntrospectOutput, t as formatIntrospectJson } from "./verify-
|
|
1
|
+
import { r as createTerminalUI } from "./terminal-ui-JJKxvT0q-CPDEJqqU.mjs";
|
|
2
|
+
import { b as setCommandExamples, m as parseGlobalFlagsOrExit, t as addGlobalOptions, u as handleResult, y as setCommandDescriptions } from "./command-helpers-Dw3LDEu_-B4AETH4D.mjs";
|
|
3
|
+
import { t as inspectLiveSchema } from "./inspect-live-schema-BAiaX0n9-DBQFEsMC.mjs";
|
|
4
|
+
import { n as formatIntrospectOutput, t as formatIntrospectJson } from "./verify-wUSBDQwh-Bv3NV9WG.mjs";
|
|
5
5
|
import { Command } from "commander";
|
|
6
|
-
//#region ../../../1-framework/3-tooling/cli/dist/db-schema-
|
|
6
|
+
//#region ../../../1-framework/3-tooling/cli/dist/db-schema-D_PJvBI3.mjs
|
|
7
7
|
function toIntrospectSchemaResult(result) {
|
|
8
8
|
return {
|
|
9
9
|
ok: true,
|
|
@@ -45,4 +45,4 @@ function createDbSchemaCommand() {
|
|
|
45
45
|
//#endregion
|
|
46
46
|
export { createDbSchemaCommand as t };
|
|
47
47
|
|
|
48
|
-
//# sourceMappingURL=db-schema-
|
|
48
|
+
//# sourceMappingURL=db-schema-D_PJvBI3-BTnfCqbX.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"db-schema-
|
|
1
|
+
{"version":3,"file":"db-schema-D_PJvBI3-BTnfCqbX.mjs","names":[],"sources":["../../../../1-framework/3-tooling/cli/dist/db-schema-D_PJvBI3.mjs"],"sourcesContent":["import { t as createTerminalUI } from \"./terminal-ui-JJKxvT0q.mjs\";\nimport { _ as parseGlobalFlagsOrExit, d as setCommandExamples, t as addGlobalOptions, u as setCommandDescriptions, v as handleResult } from \"./command-helpers-Dw3LDEu_.mjs\";\nimport { t as inspectLiveSchema } from \"./inspect-live-schema-BAiaX0n9.mjs\";\nimport { n as formatIntrospectOutput, t as formatIntrospectJson } from \"./verify-wUSBDQwh.mjs\";\nimport { Command } from \"commander\";\n//#region src/commands/db-schema.ts\nfunction toIntrospectSchemaResult(result) {\n\treturn {\n\t\tok: true,\n\t\tsummary: \"Schema read successfully\",\n\t\ttarget: result.target,\n\t\tschema: result.schema,\n\t\tmeta: result.meta,\n\t\ttimings: result.timings\n\t};\n}\nfunction createDbSchemaCommand() {\n\tconst command = new Command(\"schema\");\n\tsetCommandDescriptions(command, \"Inspect the live database schema\", \"Reads the live database schema and prints it as a tree by default or as JSON with\\n--json. This command is always read-only and never writes files. To save machine-\\nreadable output, use shell redirection, for example `prisma-next db schema --json > schema.json`.\");\n\tsetCommandExamples(command, [\n\t\t\"prisma-next db schema --db $DATABASE_URL\",\n\t\t\"prisma-next db schema --db $DATABASE_URL --json\",\n\t\t\"prisma-next db schema --db $DATABASE_URL --json > schema.json\"\n\t]);\n\taddGlobalOptions(command).option(\"--db <url>\", \"Database connection string\").option(\"--config <path>\", \"Path to prisma-next.config.ts\").action(async (options) => {\n\t\tconst flags = parseGlobalFlagsOrExit(options);\n\t\tconst ui = createTerminalUI(flags);\n\t\tconst exitCode = handleResult(await inspectLiveSchema(options, flags, ui, Date.now(), {\n\t\t\tcommandName: \"db schema\",\n\t\t\tdescription: \"Inspect the live database schema\",\n\t\t\turl: \"https://pris.ly/db-schema\"\n\t\t}), flags, ui, (value) => {\n\t\t\tconst introspectResult = toIntrospectSchemaResult(value);\n\t\t\tif (flags.json) {\n\t\t\t\tui.output(formatIntrospectJson(introspectResult));\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst output = formatIntrospectOutput(introspectResult, value.schemaView, flags);\n\t\t\tif (output) ui.log(output);\n\t\t});\n\t\tprocess.exit(exitCode);\n\t});\n\treturn command;\n}\n//#endregion\nexport { createDbSchemaCommand as t };\n\n//# sourceMappingURL=db-schema-D_PJvBI3.mjs.map"],"mappings":";;;;;;AAMA,SAAS,yBAAyB,QAAQ;CACzC,OAAO;EACN,IAAI;EACJ,SAAS;EACT,QAAQ,OAAO;EACf,QAAQ,OAAO;EACf,MAAM,OAAO;EACb,SAAS,OAAO;CACjB;AACD;AACA,SAAS,wBAAwB;CAChC,MAAM,UAAU,IAAI,QAAQ,QAAQ;CACpC,uBAAuB,SAAS,oCAAoC,yQAAyQ;CAC7U,mBAAmB,SAAS;EAC3B;EACA;EACA;CACD,CAAC;CACD,iBAAiB,OAAO,CAAC,CAAC,OAAO,cAAc,4BAA4B,CAAC,CAAC,OAAO,mBAAmB,+BAA+B,CAAC,CAAC,OAAO,OAAO,YAAY;EACjK,MAAM,QAAQ,uBAAuB,OAAO;EAC5C,MAAM,KAAK,iBAAiB,KAAK;EACjC,MAAM,WAAW,aAAa,MAAM,kBAAkB,SAAS,OAAO,IAAI,KAAK,IAAI,GAAG;GACrF,aAAa;GACb,aAAa;GACb,KAAK;EACN,CAAC,GAAG,OAAO,KAAK,UAAU;GACzB,MAAM,mBAAmB,yBAAyB,KAAK;GACvD,IAAI,MAAM,MAAM;IACf,GAAG,OAAO,qBAAqB,gBAAgB,CAAC;IAChD;GACD;GACA,MAAM,SAAS,uBAAuB,kBAAkB,MAAM,YAAY,KAAK;GAC/E,IAAI,QAAQ,GAAG,IAAI,MAAM;EAC1B,CAAC;EACD,QAAQ,KAAK,QAAQ;CACtB,CAAC;CACD,OAAO;AACR"}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { o as loadConfigForSections } from "./exports-BZLNbtkY.mjs";
|
|
2
2
|
import { N as errorUnexpected, c as errorDatabaseConnectionRequired, d as errorFileNotFound, s as errorContractValidationFailed, t as CliStructuredError$1, u as errorDriverRequired } from "./cli-errors-CihMAEVj-C1uUYBop.mjs";
|
|
3
|
-
import {
|
|
4
|
-
import { _ as resolveMigrationPaths, b as setCommandExamples, f as maskConnectionUrl, g as resolveContractPath, m as parseGlobalFlagsOrExit, n as closeQuietly, s as formatStyledHeader, t as addGlobalOptions, u as handleResult, y as setCommandDescriptions } from "./command-helpers-
|
|
3
|
+
import { r as createTerminalUI } from "./terminal-ui-JJKxvT0q-CPDEJqqU.mjs";
|
|
4
|
+
import { _ as resolveMigrationPaths, b as setCommandExamples, f as maskConnectionUrl, g as resolveContractPath, m as parseGlobalFlagsOrExit, n as closeQuietly, s as formatStyledHeader, t as addGlobalOptions, u as handleResult, y as setCommandDescriptions } from "./command-helpers-Dw3LDEu_-B4AETH4D.mjs";
|
|
5
5
|
import { t as createProgressAdapter } from "./progress-adapter-CjAeTxY_-BXYSd1eY.mjs";
|
|
6
|
-
import { t as createControlClient } from "./client-
|
|
7
|
-
import { t as resolveContractRefToSnapshot } from "./contract-snapshot-resolution-
|
|
8
|
-
import { a as formatSignJson, i as formatSchemaVerifyOutput, o as formatSignOutput, r as formatSchemaVerifyJson } from "./verify-
|
|
6
|
+
import { t as createControlClient } from "./client-C4Gh4PBz-BMUlBcuE.mjs";
|
|
7
|
+
import { t as resolveContractRefToSnapshot } from "./contract-snapshot-resolution-BnH6_mw7-BrzAsS93.mjs";
|
|
8
|
+
import { a as formatSignJson, i as formatSchemaVerifyOutput, o as formatSignOutput, r as formatSchemaVerifyJson } from "./verify-wUSBDQwh-Bv3NV9WG.mjs";
|
|
9
9
|
import { relative, resolve } from "pathe";
|
|
10
10
|
import { isStructuredError } from "@prisma/orm-framework/utils/structured-error";
|
|
11
11
|
import { readFile } from "node:fs/promises";
|
|
12
12
|
import { notOk, ok } from "@prisma/orm-framework/utils/result";
|
|
13
13
|
import { Command } from "commander";
|
|
14
|
-
//#region ../../../1-framework/3-tooling/cli/dist/db-sign-
|
|
14
|
+
//#region ../../../1-framework/3-tooling/cli/dist/db-sign-Bparnnii.mjs
|
|
15
15
|
/**
|
|
16
16
|
* Executes the db sign command and returns a structured Result.
|
|
17
17
|
* Success: SignDatabaseResult (sign happened)
|
|
@@ -169,4 +169,4 @@ function createDbSignCommand() {
|
|
|
169
169
|
//#endregion
|
|
170
170
|
export { createDbSignCommand as t };
|
|
171
171
|
|
|
172
|
-
//# sourceMappingURL=db-sign-
|
|
172
|
+
//# sourceMappingURL=db-sign-Bparnnii-Yd5pb4VF.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"db-sign-BQF-jVXg-D467Bhpj.mjs","names":["CliStructuredError"],"sources":["../../../../1-framework/3-tooling/cli/dist/db-sign-BQF-jVXg.mjs"],"sourcesContent":["import { M as errorUnexpected, l as errorDriverRequired, o as errorContractValidationFailed, s as errorDatabaseConnectionRequired, t as CliStructuredError, u as errorFileNotFound } from \"./cli-errors-CihMAEVj.mjs\";\nimport { t as createTerminalUI } from \"./terminal-ui-DQNCDg2u.mjs\";\nimport { S as formatStyledHeader, _ as parseGlobalFlagsOrExit, a as maskConnectionUrl, c as resolveMigrationPaths, d as setCommandExamples, n as closeQuietly, s as resolveContractPath, t as addGlobalOptions, u as setCommandDescriptions, v as handleResult } from \"./command-helpers-DutQjYgy.mjs\";\nimport { t as createProgressAdapter } from \"./progress-adapter-CjAeTxY_.mjs\";\nimport { t as createControlClient } from \"./client-CaIWFVnh.mjs\";\nimport { a as formatSignJson, i as formatSchemaVerifyOutput, o as formatSignOutput, r as formatSchemaVerifyJson } from \"./verify-TphNCyMu.mjs\";\nimport { t as resolveContractRefToSnapshot } from \"./contract-snapshot-resolution-D2f9kGs0.mjs\";\nimport { Command } from \"commander\";\nimport { loadConfigForSections } from \"@internal/config-loader\";\nimport { notOk, ok } from \"@internal/utils/result\";\nimport { relative, resolve } from \"pathe\";\nimport { readFile } from \"node:fs/promises\";\nimport { isStructuredError } from \"@internal/utils/structured-error\";\n//#region src/commands/db-sign.ts\n/**\n* Executes the db sign command and returns a structured Result.\n* Success: SignDatabaseResult (sign happened)\n* Failure: CliStructuredError (infra error) or VerifyDatabaseSchemaResult (schema mismatch)\n*/\nasync function executeDbSignCommand(contractArg, options, flags, ui) {\n\tconst configResult = await loadConfigForSections(options.config, [\n\t\t\"family\",\n\t\t\"target\",\n\t\t\"adapter\",\n\t\t\"driver\",\n\t\t\"extensions\",\n\t\t\"db\",\n\t\t\"migrations\",\n\t\t\"contract\"\n\t]);\n\tif (!configResult.ok) return configResult;\n\tconst config = configResult.value;\n\tconst configPath = options.config ? relative(process.cwd(), resolve(options.config)) : \"prisma-next.config.ts\";\n\tconst contractPathAbsolute = resolveContractPath(config);\n\tconst contractPath = relative(process.cwd(), contractPathAbsolute);\n\tconst effectiveContractArg = contractArg ?? options.contract;\n\tif (!flags.json && !flags.quiet) {\n\t\tconst details = [{\n\t\t\tlabel: \"config\",\n\t\t\tvalue: configPath\n\t\t}, {\n\t\t\tlabel: \"contract\",\n\t\t\tvalue: effectiveContractArg ?? contractPath\n\t\t}];\n\t\tif (options.db) details.push({\n\t\t\tlabel: \"database\",\n\t\t\tvalue: maskConnectionUrl(options.db)\n\t\t});\n\t\tconst header = formatStyledHeader({\n\t\t\tcommand: \"db sign\",\n\t\t\tdescription: \"Sign the database with your contract so you can safely run queries\",\n\t\t\turl: \"https://pris.ly/db-sign\",\n\t\t\tdetails,\n\t\t\tflags\n\t\t});\n\t\tui.stderr(header);\n\t}\n\tlet contractJson;\n\tif (effectiveContractArg) try {\n\t\tconst { migrationsDir } = resolveMigrationPaths(options.config, config, process.cwd());\n\t\tconst resolved = await resolveContractRefToSnapshot({\n\t\t\tconfig,\n\t\t\tmigrationsDir,\n\t\t\trefInput: effectiveContractArg,\n\t\t\tcontractPathAbsolute,\n\t\t\tfallbackToEmitted: true\n\t\t});\n\t\tif (!resolved.ok) return notOk(resolved.failure);\n\t\tcontractJson = resolved.value.contractJson;\n\t} catch (error) {\n\t\tif (error instanceof CliStructuredError) return notOk(error);\n\t\treturn notOk(errorUnexpected(error instanceof Error ? error.message : String(error), { why: `Failed to resolve contract reference: ${error instanceof Error ? error.message : String(error)}` }));\n\t}\n\telse {\n\t\tlet contractJsonContent;\n\t\ttry {\n\t\t\tcontractJsonContent = await readFile(contractPathAbsolute, \"utf-8\");\n\t\t} catch (error) {\n\t\t\tif (error instanceof Error && error.code === \"ENOENT\") return notOk(errorFileNotFound(contractPathAbsolute, {\n\t\t\t\twhy: `Contract file not found at ${contractPathAbsolute}`,\n\t\t\t\tfix: `Run \\`prisma-next contract emit\\` to generate ${contractPath}, or update \\`config.contract.output\\` in ${configPath}`\n\t\t\t}));\n\t\t\treturn notOk(errorUnexpected(error instanceof Error ? error.message : String(error), { why: `Failed to read contract file: ${error instanceof Error ? error.message : String(error)}` }));\n\t\t}\n\t\ttry {\n\t\t\tcontractJson = JSON.parse(contractJsonContent);\n\t\t} catch (error) {\n\t\t\treturn notOk(errorContractValidationFailed(`Contract JSON is invalid: ${error instanceof Error ? error.message : String(error)}`, { where: { path: contractPathAbsolute } }));\n\t\t}\n\t}\n\tconst dbConnection = options.db ?? config.db?.connection;\n\tif (!dbConnection) return notOk(errorDatabaseConnectionRequired({\n\t\twhy: `Database connection is required for db sign (set db.connection in ${configPath}, or pass --db <url>)`,\n\t\tcommandName: \"db sign\"\n\t}));\n\tif (!config.driver) return notOk(errorDriverRequired({ why: \"Config.driver is required for db sign\" }));\n\tconst client = createControlClient({\n\t\tfamily: config.family,\n\t\ttarget: config.target,\n\t\tadapter: config.adapter,\n\t\tdriver: config.driver,\n\t\textensions: config.extensions ?? []\n\t});\n\tconst onProgress = createProgressAdapter({\n\t\tui,\n\t\tflags\n\t});\n\ttry {\n\t\tconst schemaVerifyResult = await client.schemaVerify({\n\t\t\tcontract: contractJson,\n\t\t\tstrict: false,\n\t\t\tconnection: dbConnection,\n\t\t\tonProgress\n\t\t});\n\t\tif (!schemaVerifyResult.ok) return notOk(schemaVerifyResult);\n\t\treturn ok(await client.sign({\n\t\t\tcontract: contractJson,\n\t\t\tcontractPath,\n\t\t\tconfigPath,\n\t\t\tonProgress\n\t\t}));\n\t} catch (error) {\n\t\tif (error instanceof CliStructuredError) return notOk(error);\n\t\tif (isStructuredError(error) && error.code === \"CONTRACT.VALIDATION_FAILED\") return notOk(errorContractValidationFailed(`Contract validation failed: ${error.message}`, { where: { path: contractPathAbsolute } }));\n\t\treturn notOk(errorUnexpected(error instanceof Error ? error.message : String(error), { why: `Unexpected error during db sign: ${error instanceof Error ? error.message : String(error)}` }));\n\t} finally {\n\t\tawait closeQuietly(client);\n\t}\n}\nfunction createDbSignCommand() {\n\tconst command = new Command(\"sign\");\n\tsetCommandDescriptions(command, \"Sign the database with your contract so you can safely run queries\", \"Verifies that your database schema satisfies the emitted contract, and if so, writes or\\nupdates the database signature. This command is idempotent and safe to run\\nin CI/deployment pipelines. The signature records that this database instance is aligned\\nwith a specific contract version.\");\n\tsetCommandExamples(command, [\n\t\t\"prisma-next db sign --db $DATABASE_URL\",\n\t\t\"prisma-next db sign production --db $DATABASE_URL\",\n\t\t\"prisma-next db sign --contract production --db $DATABASE_URL\"\n\t]);\n\taddGlobalOptions(command).argument(\"[contract]\", \"Contract reference (hash, prefix, ref name, or migration dir name)\").option(\"--db <url>\", \"Database connection string\").option(\"--config <path>\", \"Path to prisma-next.config.ts\").option(\"--contract <contract>\", \"Contract reference (hash, prefix, ref name, migration dir name, <dir>^, or ./path)\").action(async (positionalContract, options) => {\n\t\tconst flags = parseGlobalFlagsOrExit(options);\n\t\tif (positionalContract && options.contract) {\n\t\t\tprocess.stderr.write(\"Cannot specify both a positional contract argument and --contract flag.\\n\");\n\t\t\tprocess.exit(2);\n\t\t\treturn;\n\t\t}\n\t\tconst ui = createTerminalUI(flags);\n\t\tconst result = await executeDbSignCommand(positionalContract, options, flags, ui);\n\t\tif (result.ok) {\n\t\t\tif (flags.json) ui.output(formatSignJson(result.value));\n\t\t\telse {\n\t\t\t\tconst output = formatSignOutput(result.value, flags);\n\t\t\t\tif (output) ui.log(output);\n\t\t\t}\n\t\t\tprocess.exit(0);\n\t\t}\n\t\tconst failure = result.failure;\n\t\tif (failure instanceof CliStructuredError) {\n\t\t\tconst exitCode = handleResult(result, flags, ui);\n\t\t\tprocess.exit(exitCode);\n\t\t}\n\t\tif (flags.json) ui.output(formatSchemaVerifyJson(failure));\n\t\telse {\n\t\t\tconst output = formatSchemaVerifyOutput(failure, flags);\n\t\t\tif (output) ui.log(output);\n\t\t}\n\t\tprocess.exit(1);\n\t});\n\treturn command;\n}\n//#endregion\nexport { createDbSignCommand as t };\n\n//# sourceMappingURL=db-sign-BQF-jVXg.mjs.map"],"mappings":";;;;;;;;;;;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EACA,MAAM,UAAU,OAAO;EACvB,IAAI,mBAAmBA,sBAAoB;GAC1C,MAAM,WAAW,aAAa,QAAQ,OAAO,EAAE;GAC/C,QAAQ,KAAK,QAAQ;EACtB;EACA,IAAI,MAAM,MAAM,GAAG,OAAO,uBAAuB,OAAO,CAAC;OACpD;GACJ,MAAM,SAAS,yBAAyB,SAAS,KAAK;GACtD,IAAI,QAAQ,GAAG,IAAI,MAAM;EAC1B;EACA,QAAQ,KAAK,CAAC;CACf,CAAC;CACD,OAAO;AACR"}
|
|
1
|
+
{"version":3,"file":"db-sign-Bparnnii-Yd5pb4VF.mjs","names":["CliStructuredError"],"sources":["../../../../1-framework/3-tooling/cli/dist/db-sign-Bparnnii.mjs"],"sourcesContent":["import { M as errorUnexpected, l as errorDriverRequired, o as errorContractValidationFailed, s as errorDatabaseConnectionRequired, t as CliStructuredError, u as errorFileNotFound } from \"./cli-errors-CihMAEVj.mjs\";\nimport { t as createTerminalUI } from \"./terminal-ui-JJKxvT0q.mjs\";\nimport { S as formatStyledHeader, _ as parseGlobalFlagsOrExit, a as maskConnectionUrl, c as resolveMigrationPaths, d as setCommandExamples, n as closeQuietly, s as resolveContractPath, t as addGlobalOptions, u as setCommandDescriptions, v as handleResult } from \"./command-helpers-Dw3LDEu_.mjs\";\nimport { t as createProgressAdapter } from \"./progress-adapter-CjAeTxY_.mjs\";\nimport { t as createControlClient } from \"./client-C4Gh4PBz.mjs\";\nimport { a as formatSignJson, i as formatSchemaVerifyOutput, o as formatSignOutput, r as formatSchemaVerifyJson } from \"./verify-wUSBDQwh.mjs\";\nimport { t as resolveContractRefToSnapshot } from \"./contract-snapshot-resolution-BnH6_mw7.mjs\";\nimport { Command } from \"commander\";\nimport { loadConfigForSections } from \"@internal/config-loader\";\nimport { notOk, ok } from \"@internal/utils/result\";\nimport { relative, resolve } from \"pathe\";\nimport { readFile } from \"node:fs/promises\";\nimport { isStructuredError } from \"@internal/utils/structured-error\";\n//#region src/commands/db-sign.ts\n/**\n* Executes the db sign command and returns a structured Result.\n* Success: SignDatabaseResult (sign happened)\n* Failure: CliStructuredError (infra error) or VerifyDatabaseSchemaResult (schema mismatch)\n*/\nasync function executeDbSignCommand(contractArg, options, flags, ui) {\n\tconst configResult = await loadConfigForSections(options.config, [\n\t\t\"family\",\n\t\t\"target\",\n\t\t\"adapter\",\n\t\t\"driver\",\n\t\t\"extensions\",\n\t\t\"db\",\n\t\t\"migrations\",\n\t\t\"contract\"\n\t]);\n\tif (!configResult.ok) return configResult;\n\tconst config = configResult.value;\n\tconst configPath = options.config ? relative(process.cwd(), resolve(options.config)) : \"prisma-next.config.ts\";\n\tconst contractPathAbsolute = resolveContractPath(config);\n\tconst contractPath = relative(process.cwd(), contractPathAbsolute);\n\tconst effectiveContractArg = contractArg ?? options.contract;\n\tif (!flags.json && !flags.quiet) {\n\t\tconst details = [{\n\t\t\tlabel: \"config\",\n\t\t\tvalue: configPath\n\t\t}, {\n\t\t\tlabel: \"contract\",\n\t\t\tvalue: effectiveContractArg ?? contractPath\n\t\t}];\n\t\tif (options.db) details.push({\n\t\t\tlabel: \"database\",\n\t\t\tvalue: maskConnectionUrl(options.db)\n\t\t});\n\t\tconst header = formatStyledHeader({\n\t\t\tcommand: \"db sign\",\n\t\t\tdescription: \"Sign the database with your contract so you can safely run queries\",\n\t\t\turl: \"https://pris.ly/db-sign\",\n\t\t\tdetails,\n\t\t\tflags\n\t\t});\n\t\tui.stderr(header);\n\t}\n\tlet contractJson;\n\tif (effectiveContractArg) try {\n\t\tconst { migrationsDir } = resolveMigrationPaths(options.config, config, process.cwd());\n\t\tconst resolved = await resolveContractRefToSnapshot({\n\t\t\tconfig,\n\t\t\tmigrationsDir,\n\t\t\trefInput: effectiveContractArg,\n\t\t\tcontractPathAbsolute,\n\t\t\tfallbackToEmitted: true\n\t\t});\n\t\tif (!resolved.ok) return notOk(resolved.failure);\n\t\tcontractJson = resolved.value.contractJson;\n\t} catch (error) {\n\t\tif (error instanceof CliStructuredError) return notOk(error);\n\t\treturn notOk(errorUnexpected(error instanceof Error ? error.message : String(error), { why: `Failed to resolve contract reference: ${error instanceof Error ? error.message : String(error)}` }));\n\t}\n\telse {\n\t\tlet contractJsonContent;\n\t\ttry {\n\t\t\tcontractJsonContent = await readFile(contractPathAbsolute, \"utf-8\");\n\t\t} catch (error) {\n\t\t\tif (error instanceof Error && error.code === \"ENOENT\") return notOk(errorFileNotFound(contractPathAbsolute, {\n\t\t\t\twhy: `Contract file not found at ${contractPathAbsolute}`,\n\t\t\t\tfix: `Run \\`prisma-next contract emit\\` to generate ${contractPath}, or update \\`config.contract.output\\` in ${configPath}`\n\t\t\t}));\n\t\t\treturn notOk(errorUnexpected(error instanceof Error ? error.message : String(error), { why: `Failed to read contract file: ${error instanceof Error ? error.message : String(error)}` }));\n\t\t}\n\t\ttry {\n\t\t\tcontractJson = JSON.parse(contractJsonContent);\n\t\t} catch (error) {\n\t\t\treturn notOk(errorContractValidationFailed(`Contract JSON is invalid: ${error instanceof Error ? error.message : String(error)}`, { where: { path: contractPathAbsolute } }));\n\t\t}\n\t}\n\tconst dbConnection = options.db ?? config.db?.connection;\n\tif (!dbConnection) return notOk(errorDatabaseConnectionRequired({\n\t\twhy: `Database connection is required for db sign (set db.connection in ${configPath}, or pass --db <url>)`,\n\t\tcommandName: \"db sign\"\n\t}));\n\tif (!config.driver) return notOk(errorDriverRequired({ why: \"Config.driver is required for db sign\" }));\n\tconst client = createControlClient({\n\t\tfamily: config.family,\n\t\ttarget: config.target,\n\t\tadapter: config.adapter,\n\t\tdriver: config.driver,\n\t\textensions: config.extensions ?? []\n\t});\n\tconst onProgress = createProgressAdapter({\n\t\tui,\n\t\tflags\n\t});\n\ttry {\n\t\tconst schemaVerifyResult = await client.schemaVerify({\n\t\t\tcontract: contractJson,\n\t\t\tstrict: false,\n\t\t\tconnection: dbConnection,\n\t\t\tonProgress\n\t\t});\n\t\tif (!schemaVerifyResult.ok) return notOk(schemaVerifyResult);\n\t\treturn ok(await client.sign({\n\t\t\tcontract: contractJson,\n\t\t\tcontractPath,\n\t\t\tconfigPath,\n\t\t\tonProgress\n\t\t}));\n\t} catch (error) {\n\t\tif (error instanceof CliStructuredError) return notOk(error);\n\t\tif (isStructuredError(error) && error.code === \"CONTRACT.VALIDATION_FAILED\") return notOk(errorContractValidationFailed(`Contract validation failed: ${error.message}`, { where: { path: contractPathAbsolute } }));\n\t\treturn notOk(errorUnexpected(error instanceof Error ? error.message : String(error), { why: `Unexpected error during db sign: ${error instanceof Error ? error.message : String(error)}` }));\n\t} finally {\n\t\tawait closeQuietly(client);\n\t}\n}\nfunction createDbSignCommand() {\n\tconst command = new Command(\"sign\");\n\tsetCommandDescriptions(command, \"Sign the database with your contract so you can safely run queries\", \"Verifies that your database schema satisfies the emitted contract, and if so, writes or\\nupdates the database signature. This command is idempotent and safe to run\\nin CI/deployment pipelines. The signature records that this database instance is aligned\\nwith a specific contract version.\");\n\tsetCommandExamples(command, [\n\t\t\"prisma-next db sign --db $DATABASE_URL\",\n\t\t\"prisma-next db sign production --db $DATABASE_URL\",\n\t\t\"prisma-next db sign --contract production --db $DATABASE_URL\"\n\t]);\n\taddGlobalOptions(command).argument(\"[contract]\", \"Contract reference (hash, prefix, ref name, or migration dir name)\").option(\"--db <url>\", \"Database connection string\").option(\"--config <path>\", \"Path to prisma-next.config.ts\").option(\"--contract <contract>\", \"Contract reference (hash, prefix, ref name, migration dir name, <dir>^, or ./path)\").action(async (positionalContract, options) => {\n\t\tconst flags = parseGlobalFlagsOrExit(options);\n\t\tif (positionalContract && options.contract) {\n\t\t\tprocess.stderr.write(\"Cannot specify both a positional contract argument and --contract flag.\\n\");\n\t\t\tprocess.exit(2);\n\t\t\treturn;\n\t\t}\n\t\tconst ui = createTerminalUI(flags);\n\t\tconst result = await executeDbSignCommand(positionalContract, options, flags, ui);\n\t\tif (result.ok) {\n\t\t\tif (flags.json) ui.output(formatSignJson(result.value));\n\t\t\telse {\n\t\t\t\tconst output = formatSignOutput(result.value, flags);\n\t\t\t\tif (output) ui.log(output);\n\t\t\t}\n\t\t\tprocess.exit(0);\n\t\t}\n\t\tconst failure = result.failure;\n\t\tif (failure instanceof CliStructuredError) {\n\t\t\tconst exitCode = handleResult(result, flags, ui);\n\t\t\tprocess.exit(exitCode);\n\t\t}\n\t\tif (flags.json) ui.output(formatSchemaVerifyJson(failure));\n\t\telse {\n\t\t\tconst output = formatSchemaVerifyOutput(failure, flags);\n\t\t\tif (output) ui.log(output);\n\t\t}\n\t\tprocess.exit(1);\n\t});\n\treturn command;\n}\n//#endregion\nexport { createDbSignCommand as t };\n\n//# sourceMappingURL=db-sign-Bparnnii.mjs.map"],"mappings":";;;;;;;;;;;;;;;;;;;AAmBA,eAAe,qBAAqB,aAAa,SAAS,OAAO,IAAI;CACpE,MAAM,eAAe,MAAM,sBAAsB,QAAQ,QAAQ;EAChE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACD,CAAC;CACD,IAAI,CAAC,aAAa,IAAI,OAAO;CAC7B,MAAM,SAAS,aAAa;CAC5B,MAAM,aAAa,QAAQ,SAAS,SAAS,QAAQ,IAAI,GAAG,QAAQ,QAAQ,MAAM,CAAC,IAAI;CACvF,MAAM,uBAAuB,oBAAoB,MAAM;CACvD,MAAM,eAAe,SAAS,QAAQ,IAAI,GAAG,oBAAoB;CACjE,MAAM,uBAAuB,eAAe,QAAQ;CACpD,IAAI,CAAC,MAAM,QAAQ,CAAC,MAAM,OAAO;EAChC,MAAM,UAAU,CAAC;GAChB,OAAO;GACP,OAAO;EACR,GAAG;GACF,OAAO;GACP,OAAO,wBAAwB;EAChC,CAAC;EACD,IAAI,QAAQ,IAAI,QAAQ,KAAK;GAC5B,OAAO;GACP,OAAO,kBAAkB,QAAQ,EAAE;EACpC,CAAC;EACD,MAAM,SAAS,mBAAmB;GACjC,SAAS;GACT,aAAa;GACb,KAAK;GACL;GACA;EACD,CAAC;EACD,GAAG,OAAO,MAAM;CACjB;CACA,IAAI;CACJ,IAAI,sBAAsB,IAAI;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,uBAAuB,OAAO;EAC5C,IAAI,sBAAsB,QAAQ,UAAU;GAC3C,QAAQ,OAAO,MAAM,2EAA2E;GAChG,QAAQ,KAAK,CAAC;GACd;EACD;EACA,MAAM,KAAK,iBAAiB,KAAK;EACjC,MAAM,SAAS,MAAM,qBAAqB,oBAAoB,SAAS,OAAO,EAAE;EAChF,IAAI,OAAO,IAAI;GACd,IAAI,MAAM,MAAM,GAAG,OAAO,eAAe,OAAO,KAAK,CAAC;QACjD;IACJ,MAAM,SAAS,iBAAiB,OAAO,OAAO,KAAK;IACnD,IAAI,QAAQ,GAAG,IAAI,MAAM;GAC1B;GACA,QAAQ,KAAK,CAAC;EACf;EACA,MAAM,UAAU,OAAO;EACvB,IAAI,mBAAmBA,sBAAoB;GAC1C,MAAM,WAAW,aAAa,QAAQ,OAAO,EAAE;GAC/C,QAAQ,KAAK,QAAQ;EACtB;EACA,IAAI,MAAM,MAAM,GAAG,OAAO,uBAAuB,OAAO,CAAC;OACpD;GACJ,MAAM,SAAS,yBAAyB,SAAS,KAAK;GACtD,IAAI,QAAQ,GAAG,IAAI,MAAM;EAC1B;EACA,QAAQ,KAAK,CAAC;CACf,CAAC;CACD,OAAO;AACR"}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { D as errorRunnerFailed, N as errorUnexpected, l as errorDestructiveChanges, n as ERROR_CODE_DESTRUCTIVE_CHANGES, s as errorContractValidationFailed, t as CliStructuredError$1, y as errorMigrationPlanningFailed } from "./cli-errors-CihMAEVj-C1uUYBop.mjs";
|
|
2
|
-
import { c as
|
|
3
|
-
import { _ as resolveMigrationPaths, b as setCommandExamples, m as parseGlobalFlagsOrExit, n as closeQuietly, u as handleResult, v as sanitizeErrorMessage, y as setCommandDescriptions } from "./command-helpers-
|
|
4
|
-
import { o as resolveRefAdvancementFields } from "./ref-advancement-DaZBzm7m-
|
|
5
|
-
import { n as prepareMigrationContext, t as addMigrationCommandOptions } from "./migration-command-scaffold-
|
|
6
|
-
import { t as resolveContractRefToSnapshot } from "./contract-snapshot-resolution-
|
|
2
|
+
import { c as formatMigrationApplyOutput, l as formatMigrationJson, r as createTerminalUI, u as formatMigrationPlanOutput } from "./terminal-ui-JJKxvT0q-CPDEJqqU.mjs";
|
|
3
|
+
import { _ as resolveMigrationPaths, b as setCommandExamples, m as parseGlobalFlagsOrExit, n as closeQuietly, u as handleResult, v as sanitizeErrorMessage, y as setCommandDescriptions } from "./command-helpers-Dw3LDEu_-B4AETH4D.mjs";
|
|
4
|
+
import { o as resolveRefAdvancementFields } from "./ref-advancement-DaZBzm7m-WoqnFAyr.mjs";
|
|
5
|
+
import { n as prepareMigrationContext, t as addMigrationCommandOptions } from "./migration-command-scaffold-CIMPoR6f-Ba-S9gXa.mjs";
|
|
6
|
+
import { t as resolveContractRefToSnapshot } from "./contract-snapshot-resolution-BnH6_mw7-BrzAsS93.mjs";
|
|
7
7
|
import { ifDefined } from "@prisma/orm-framework/utils/defined";
|
|
8
8
|
import { isStructuredError } from "@prisma/orm-framework/utils/structured-error";
|
|
9
9
|
import { assertNever } from "@prisma/orm-framework/utils/internal-error";
|
|
10
10
|
import { notOk, ok } from "@prisma/orm-framework/utils/result";
|
|
11
11
|
import { Command } from "commander";
|
|
12
|
-
//#region ../../../1-framework/3-tooling/cli/dist/db-update-
|
|
12
|
+
//#region ../../../1-framework/3-tooling/cli/dist/db-update-CsKZyDYp.mjs
|
|
13
13
|
/**
|
|
14
14
|
* Maps a DbUpdateFailure to a CliStructuredError for consistent error handling.
|
|
15
15
|
*/
|
|
@@ -159,4 +159,4 @@ function createDbUpdateCommand() {
|
|
|
159
159
|
//#endregion
|
|
160
160
|
export { createDbUpdateCommand as t };
|
|
161
161
|
|
|
162
|
-
//# sourceMappingURL=db-update-
|
|
162
|
+
//# sourceMappingURL=db-update-CsKZyDYp-B8Zl7W4k.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"db-update-B0_Q4ykE-CT9vcaMu.mjs","names":["CliStructuredError"],"sources":["../../../../1-framework/3-tooling/cli/dist/db-update-B0_Q4ykE.mjs"],"sourcesContent":["import { E as errorRunnerFailed, M as errorUnexpected, c as errorDestructiveChanges, n as ERROR_CODE_DESTRUCTIVE_CHANGES, o as errorContractValidationFailed, t as CliStructuredError, v as errorMigrationPlanningFailed } from \"./cli-errors-CihMAEVj.mjs\";\nimport { c as formatMigrationPlanOutput, o as formatMigrationApplyOutput, s as formatMigrationJson, t as createTerminalUI } from \"./terminal-ui-DQNCDg2u.mjs\";\nimport { _ as parseGlobalFlagsOrExit, c as resolveMigrationPaths, d as setCommandExamples, l as sanitizeErrorMessage, n as closeQuietly, u as setCommandDescriptions, v as handleResult } from \"./command-helpers-DutQjYgy.mjs\";\nimport { o as resolveRefAdvancementFields } from \"./ref-advancement-DaZBzm7m.mjs\";\nimport { n as prepareMigrationContext, t as addMigrationCommandOptions } from \"./migration-command-scaffold-BezR8GWB.mjs\";\nimport { t as resolveContractRefToSnapshot } from \"./contract-snapshot-resolution-D2f9kGs0.mjs\";\nimport { Command } from \"commander\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { notOk, ok } from \"@internal/utils/result\";\nimport { assertNever } from \"@internal/utils/internal-error\";\nimport { isStructuredError } from \"@internal/utils/structured-error\";\n//#region src/commands/db-update.ts\n/**\n* Maps a DbUpdateFailure to a CliStructuredError for consistent error handling.\n*/\nfunction mapDbUpdateFailure(failure) {\n\tif (failure.code === \"PLANNING_FAILED\") return errorMigrationPlanningFailed({ conflicts: failure.conflicts ?? [] });\n\tif (failure.code === \"RUNNER_FAILED\") {\n\t\tconst fix = (typeof failure.meta?.[\"runnerErrorCode\"] === \"string\" ? failure.meta[\"runnerErrorCode\"] : void 0) === \"MIGRATION.LEGACY_MARKER_SHAPE\" ? \"Legacy marker-table shape detected. Drop `prisma_contract.marker` (Postgres) or `_prisma_marker` (SQLite) and re-run `prisma-next db init` to recreate it with the current per-space schema.\" : \"Inspect the reported conflict, reconcile schema drift if needed, then re-run `prisma-next db update`\";\n\t\treturn errorRunnerFailed(failure.summary, {\n\t\t\twhy: failure.why ?? \"Migration runner failed\",\n\t\t\tfix,\n\t\t\tmeta: {\n\t\t\t\t...failure.meta,\n\t\t\t\t...failure.warnings && failure.warnings.length > 0 ? { plannerWarnings: failure.warnings } : {}\n\t\t\t},\n\t\t\t...ifDefined(\"cause\", failure.cause)\n\t\t});\n\t}\n\tif (failure.code === \"DESTRUCTIVE_CHANGES\") return errorDestructiveChanges(failure.summary, {\n\t\t...ifDefined(\"why\", failure.why),\n\t\tfix: \"Re-run with `-y` to apply destructive changes, or use `--dry-run` to preview first\",\n\t\t...ifDefined(\"meta\", failure.meta)\n\t});\n\tconst exhaustive = failure.code;\n\treturn assertNever(exhaustive, `Unhandled DbUpdateFailure code: ${String(exhaustive)}`);\n}\n/**\n* Executes the db update command and returns a structured Result.\n*/\nasync function executeDbUpdateCommand(options, flags, ui, startTime) {\n\tconst ctxResult = await prepareMigrationContext(options, flags, ui, {\n\t\tcommandName: \"db update\",\n\t\tdescription: \"Update your database schema to match your contract\",\n\t\turl: \"https://pris.ly/db-update\"\n\t});\n\tif (!ctxResult.ok) return ctxResult;\n\tconst { client, config, dbConnection, onProgress, contractPathAbsolute } = ctxResult.value;\n\tlet { contractJson } = ctxResult.value;\n\tlet contractJsonPathForSnapshot = contractPathAbsolute;\n\tconst { migrationsDir, refsDir } = resolveMigrationPaths(options.config, config, process.cwd());\n\tif (options.to) {\n\t\tconst resolved = await resolveContractRefToSnapshot({\n\t\t\tconfig,\n\t\t\tmigrationsDir,\n\t\t\trefInput: options.to,\n\t\t\tcontractPathAbsolute,\n\t\t\tfallbackToEmitted: false,\n\t\t\tmissingBundleFlag: \"--to\"\n\t\t});\n\t\tif (!resolved.ok) return notOk(resolved.failure);\n\t\tcontractJson = resolved.value.contractJson;\n\t\tcontractJsonPathForSnapshot = resolved.value.contractJsonPath;\n\t}\n\ttry {\n\t\tawait client.connect(dbConnection);\n\t\tconst result = await client.dbUpdate({\n\t\t\tcontract: contractJson,\n\t\t\tmode: options.dryRun ? \"plan\" : \"apply\",\n\t\t\tmigrationsDir,\n\t\t\t...flags.yes ? { acceptDataLoss: true } : {},\n\t\t\tonProgress\n\t\t});\n\t\tif (!result.ok) return notOk(mapDbUpdateFailure(result.failure));\n\t\tconst advancementHash = result.value.mode === \"apply\" ? result.value.marker?.storageHash ?? result.value.destination.storageHash : result.value.destination.storageHash;\n\t\tconst advancement = await resolveRefAdvancementFields({\n\t\t\t...ifDefined(\"advanceRef\", options.advanceRef),\n\t\t\t...ifDefined(\"db\", options.db),\n\t\t\trefsDir,\n\t\t\tmigrationsDir,\n\t\t\tcontractJson,\n\t\t\tcontractJsonPath: contractJsonPathForSnapshot,\n\t\t\tmode: result.value.mode,\n\t\t\thash: advancementHash\n\t\t});\n\t\tif (!advancement.ok) return notOk(advancement.failure);\n\t\tconst refAdvancementFields = advancement.value;\n\t\treturn ok({\n\t\t\tok: true,\n\t\t\tmode: result.value.mode,\n\t\t\tplan: {\n\t\t\t\ttargetId: ctxResult.value.config.target.targetId,\n\t\t\t\tdestination: {\n\t\t\t\t\tstorageHash: result.value.destination.storageHash,\n\t\t\t\t\t...ifDefined(\"profileHash\", result.value.destination.profileHash)\n\t\t\t\t},\n\t\t\t\toperations: result.value.plan.operations.map((op) => ({\n\t\t\t\t\tid: op.id,\n\t\t\t\t\tlabel: op.label,\n\t\t\t\t\toperationClass: op.operationClass\n\t\t\t\t})),\n\t\t\t\t...ifDefined(\"preview\", result.value.plan.preview)\n\t\t\t},\n\t\t\t...ifDefined(\"execution\", result.value.execution ? {\n\t\t\t\toperationsPlanned: result.value.execution.operationsPlanned,\n\t\t\t\toperationsExecuted: result.value.execution.operationsExecuted\n\t\t\t} : void 0),\n\t\t\t...ifDefined(\"marker\", result.value.marker ? {\n\t\t\t\tstorageHash: result.value.marker.storageHash,\n\t\t\t\t...ifDefined(\"profileHash\", result.value.marker.profileHash)\n\t\t\t} : void 0),\n\t\t\t...ifDefined(\"perSpace\", result.value.perSpace),\n\t\t\t...ifDefined(\"warnings\", result.value.warnings),\n\t\t\tadvancedRef: refAdvancementFields.advancedRef,\n\t\t\tplannedAdvanceRef: refAdvancementFields.plannedAdvanceRef,\n\t\t\tsummary: result.value.summary,\n\t\t\ttimings: { total: Date.now() - startTime }\n\t\t});\n\t} catch (error) {\n\t\tif (CliStructuredError.is(error)) return notOk(error);\n\t\tif (isStructuredError(error) && error.code === \"CONTRACT.VALIDATION_FAILED\") return notOk(errorContractValidationFailed(`Contract validation failed: ${error.message}`, { where: { path: contractPathAbsolute } }));\n\t\tconst safeMessage = sanitizeErrorMessage(error instanceof Error ? error.message : String(error), typeof dbConnection === \"string\" ? dbConnection : void 0);\n\t\treturn notOk(errorUnexpected(safeMessage, { why: `Unexpected error during db update: ${safeMessage}` }));\n\t} finally {\n\t\tawait closeQuietly(client);\n\t}\n}\nfunction createDbUpdateCommand() {\n\tconst command = new Command(\"update\");\n\tsetCommandDescriptions(command, \"Update your database schema to match your contract\", \"Compares your database schema to the emitted contract and applies the necessary\\nchanges. Works on any database, whether or not it has been initialized with `db init`.\\nDestructive operations prompt for confirmation in interactive mode. Use -y to\\nauto-accept or --dry-run to preview first.\");\n\tsetCommandExamples(command, [\"prisma-next db update --db $DATABASE_URL\", \"prisma-next db update --db $DATABASE_URL --dry-run\"]);\n\taddMigrationCommandOptions(command);\n\tcommand.option(\"--to <contract>\", \"Target contract reference (hash, prefix, ref name, migration dir name, <dir>^, or ./path)\");\n\tcommand.option(\"--advance-ref <name>\", \"Ref to advance to the post-command contract hash\");\n\tcommand.action(async (options) => {\n\t\tconst flags = parseGlobalFlagsOrExit(options);\n\t\tconst startTime = Date.now();\n\t\tconst ui = createTerminalUI(flags);\n\t\tlet result = await executeDbUpdateCommand(options, flags, ui, startTime);\n\t\tif (!result.ok && result.failure.code === ERROR_CODE_DESTRUCTIVE_CHANGES && flags.interactive && !flags.json && !flags.yes) {\n\t\t\tconst destructiveOps = result.failure.meta?.destructiveOperations ?? [];\n\t\t\tif (destructiveOps.length > 0) ui.warn(`${destructiveOps.length} destructive operation(s) that may cause data loss:\\n${destructiveOps.map((op) => ` ${ui.yellow(\"▸\")} ${op.label}`).join(\"\\n\")}`);\n\t\t\tif (await ui.confirm(\"Apply destructive changes? This cannot be undone.\")) result = await executeDbUpdateCommand(options, {\n\t\t\t\t...flags,\n\t\t\t\tyes: true\n\t\t\t}, ui, Date.now());\n\t\t}\n\t\tconst exitCode = handleResult(result, flags, ui, (dbUpdateResult) => {\n\t\t\tif (flags.json) ui.output(formatMigrationJson(dbUpdateResult));\n\t\t\telse {\n\t\t\t\tconst output = dbUpdateResult.mode === \"plan\" ? formatMigrationPlanOutput(dbUpdateResult, flags) : formatMigrationApplyOutput(dbUpdateResult, flags);\n\t\t\t\tif (output) ui.log(output);\n\t\t\t}\n\t\t});\n\t\tprocess.exit(exitCode);\n\t});\n\treturn command;\n}\n//#endregion\nexport { createDbUpdateCommand as t };\n\n//# sourceMappingURL=db-update-B0_Q4ykE.mjs.map"],"mappings":";;;;;;;;;;;;;;;AAeA,SAAS,mBAAmB,SAAS;CACpC,IAAI,QAAQ,SAAS,mBAAmB,OAAO,6BAA6B,EAAE,WAAW,QAAQ,aAAa,CAAC,EAAE,CAAC;CAClH,IAAI,QAAQ,SAAS,iBAAiB;EACrC,MAAM,OAAO,OAAO,QAAQ,OAAO,uBAAuB,WAAW,QAAQ,KAAK,qBAAqB,KAAK,OAAO,kCAAkC,iMAAiM;EACtV,OAAO,kBAAkB,QAAQ,SAAS;GACzC,KAAK,QAAQ,OAAO;GACpB;GACA,MAAM;IACL,GAAG,QAAQ;IACX,GAAG,QAAQ,YAAY,QAAQ,SAAS,SAAS,IAAI,EAAE,iBAAiB,QAAQ,SAAS,IAAI,CAAC;GAC/F;GACA,GAAG,UAAU,SAAS,QAAQ,KAAK;EACpC,CAAC;CACF;CACA,IAAI,QAAQ,SAAS,uBAAuB,OAAO,wBAAwB,QAAQ,SAAS;EAC3F,GAAG,UAA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,GAAG,OAAO,oBAAoB,cAAc,CAAC;QACxD;IACJ,MAAM,SAAS,eAAe,SAAS,SAAS,0BAA0B,gBAAgB,KAAK,IAAI,2BAA2B,gBAAgB,KAAK;IACnJ,IAAI,QAAQ,GAAG,IAAI,MAAM;GAC1B;EACD,CAAC;EACD,QAAQ,KAAK,QAAQ;CACtB,CAAC;CACD,OAAO;AACR"}
|
|
1
|
+
{"version":3,"file":"db-update-CsKZyDYp-B8Zl7W4k.mjs","names":["CliStructuredError"],"sources":["../../../../1-framework/3-tooling/cli/dist/db-update-CsKZyDYp.mjs"],"sourcesContent":["import { E as errorRunnerFailed, M as errorUnexpected, c as errorDestructiveChanges, n as ERROR_CODE_DESTRUCTIVE_CHANGES, o as errorContractValidationFailed, t as CliStructuredError, v as errorMigrationPlanningFailed } from \"./cli-errors-CihMAEVj.mjs\";\nimport { c as formatMigrationPlanOutput, o as formatMigrationApplyOutput, s as formatMigrationJson, t as createTerminalUI } from \"./terminal-ui-JJKxvT0q.mjs\";\nimport { _ as parseGlobalFlagsOrExit, c as resolveMigrationPaths, d as setCommandExamples, l as sanitizeErrorMessage, n as closeQuietly, u as setCommandDescriptions, v as handleResult } from \"./command-helpers-Dw3LDEu_.mjs\";\nimport { o as resolveRefAdvancementFields } from \"./ref-advancement-DaZBzm7m.mjs\";\nimport { n as prepareMigrationContext, t as addMigrationCommandOptions } from \"./migration-command-scaffold-CIMPoR6f.mjs\";\nimport { t as resolveContractRefToSnapshot } from \"./contract-snapshot-resolution-BnH6_mw7.mjs\";\nimport { Command } from \"commander\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { notOk, ok } from \"@internal/utils/result\";\nimport { assertNever } from \"@internal/utils/internal-error\";\nimport { isStructuredError } from \"@internal/utils/structured-error\";\n//#region src/commands/db-update.ts\n/**\n* Maps a DbUpdateFailure to a CliStructuredError for consistent error handling.\n*/\nfunction mapDbUpdateFailure(failure) {\n\tif (failure.code === \"PLANNING_FAILED\") return errorMigrationPlanningFailed({ conflicts: failure.conflicts ?? [] });\n\tif (failure.code === \"RUNNER_FAILED\") {\n\t\tconst fix = (typeof failure.meta?.[\"runnerErrorCode\"] === \"string\" ? failure.meta[\"runnerErrorCode\"] : void 0) === \"MIGRATION.LEGACY_MARKER_SHAPE\" ? \"Legacy marker-table shape detected. Drop `prisma_contract.marker` (Postgres) or `_prisma_marker` (SQLite) and re-run `prisma-next db init` to recreate it with the current per-space schema.\" : \"Inspect the reported conflict, reconcile schema drift if needed, then re-run `prisma-next db update`\";\n\t\treturn errorRunnerFailed(failure.summary, {\n\t\t\twhy: failure.why ?? \"Migration runner failed\",\n\t\t\tfix,\n\t\t\tmeta: {\n\t\t\t\t...failure.meta,\n\t\t\t\t...failure.warnings && failure.warnings.length > 0 ? { plannerWarnings: failure.warnings } : {}\n\t\t\t},\n\t\t\t...ifDefined(\"cause\", failure.cause)\n\t\t});\n\t}\n\tif (failure.code === \"DESTRUCTIVE_CHANGES\") return errorDestructiveChanges(failure.summary, {\n\t\t...ifDefined(\"why\", failure.why),\n\t\tfix: \"Re-run with `-y` to apply destructive changes, or use `--dry-run` to preview first\",\n\t\t...ifDefined(\"meta\", failure.meta)\n\t});\n\tconst exhaustive = failure.code;\n\treturn assertNever(exhaustive, `Unhandled DbUpdateFailure code: ${String(exhaustive)}`);\n}\n/**\n* Executes the db update command and returns a structured Result.\n*/\nasync function executeDbUpdateCommand(options, flags, ui, startTime) {\n\tconst ctxResult = await prepareMigrationContext(options, flags, ui, {\n\t\tcommandName: \"db update\",\n\t\tdescription: \"Update your database schema to match your contract\",\n\t\turl: \"https://pris.ly/db-update\"\n\t});\n\tif (!ctxResult.ok) return ctxResult;\n\tconst { client, config, dbConnection, onProgress, contractPathAbsolute } = ctxResult.value;\n\tlet { contractJson } = ctxResult.value;\n\tlet contractJsonPathForSnapshot = contractPathAbsolute;\n\tconst { migrationsDir, refsDir } = resolveMigrationPaths(options.config, config, process.cwd());\n\tif (options.to) {\n\t\tconst resolved = await resolveContractRefToSnapshot({\n\t\t\tconfig,\n\t\t\tmigrationsDir,\n\t\t\trefInput: options.to,\n\t\t\tcontractPathAbsolute,\n\t\t\tfallbackToEmitted: false,\n\t\t\tmissingBundleFlag: \"--to\"\n\t\t});\n\t\tif (!resolved.ok) return notOk(resolved.failure);\n\t\tcontractJson = resolved.value.contractJson;\n\t\tcontractJsonPathForSnapshot = resolved.value.contractJsonPath;\n\t}\n\ttry {\n\t\tawait client.connect(dbConnection);\n\t\tconst result = await client.dbUpdate({\n\t\t\tcontract: contractJson,\n\t\t\tmode: options.dryRun ? \"plan\" : \"apply\",\n\t\t\tmigrationsDir,\n\t\t\t...flags.yes ? { acceptDataLoss: true } : {},\n\t\t\tonProgress\n\t\t});\n\t\tif (!result.ok) return notOk(mapDbUpdateFailure(result.failure));\n\t\tconst advancementHash = result.value.mode === \"apply\" ? result.value.marker?.storageHash ?? result.value.destination.storageHash : result.value.destination.storageHash;\n\t\tconst advancement = await resolveRefAdvancementFields({\n\t\t\t...ifDefined(\"advanceRef\", options.advanceRef),\n\t\t\t...ifDefined(\"db\", options.db),\n\t\t\trefsDir,\n\t\t\tmigrationsDir,\n\t\t\tcontractJson,\n\t\t\tcontractJsonPath: contractJsonPathForSnapshot,\n\t\t\tmode: result.value.mode,\n\t\t\thash: advancementHash\n\t\t});\n\t\tif (!advancement.ok) return notOk(advancement.failure);\n\t\tconst refAdvancementFields = advancement.value;\n\t\treturn ok({\n\t\t\tok: true,\n\t\t\tmode: result.value.mode,\n\t\t\tplan: {\n\t\t\t\ttargetId: ctxResult.value.config.target.targetId,\n\t\t\t\tdestination: {\n\t\t\t\t\tstorageHash: result.value.destination.storageHash,\n\t\t\t\t\t...ifDefined(\"profileHash\", result.value.destination.profileHash)\n\t\t\t\t},\n\t\t\t\toperations: result.value.plan.operations.map((op) => ({\n\t\t\t\t\tid: op.id,\n\t\t\t\t\tlabel: op.label,\n\t\t\t\t\toperationClass: op.operationClass\n\t\t\t\t})),\n\t\t\t\t...ifDefined(\"preview\", result.value.plan.preview)\n\t\t\t},\n\t\t\t...ifDefined(\"execution\", result.value.execution ? {\n\t\t\t\toperationsPlanned: result.value.execution.operationsPlanned,\n\t\t\t\toperationsExecuted: result.value.execution.operationsExecuted\n\t\t\t} : void 0),\n\t\t\t...ifDefined(\"marker\", result.value.marker ? {\n\t\t\t\tstorageHash: result.value.marker.storageHash,\n\t\t\t\t...ifDefined(\"profileHash\", result.value.marker.profileHash)\n\t\t\t} : void 0),\n\t\t\t...ifDefined(\"perSpace\", result.value.perSpace),\n\t\t\t...ifDefined(\"warnings\", result.value.warnings),\n\t\t\tadvancedRef: refAdvancementFields.advancedRef,\n\t\t\tplannedAdvanceRef: refAdvancementFields.plannedAdvanceRef,\n\t\t\tsummary: result.value.summary,\n\t\t\ttimings: { total: Date.now() - startTime }\n\t\t});\n\t} catch (error) {\n\t\tif (CliStructuredError.is(error)) return notOk(error);\n\t\tif (isStructuredError(error) && error.code === \"CONTRACT.VALIDATION_FAILED\") return notOk(errorContractValidationFailed(`Contract validation failed: ${error.message}`, { where: { path: contractPathAbsolute } }));\n\t\tconst safeMessage = sanitizeErrorMessage(error instanceof Error ? error.message : String(error), typeof dbConnection === \"string\" ? dbConnection : void 0);\n\t\treturn notOk(errorUnexpected(safeMessage, { why: `Unexpected error during db update: ${safeMessage}` }));\n\t} finally {\n\t\tawait closeQuietly(client);\n\t}\n}\nfunction createDbUpdateCommand() {\n\tconst command = new Command(\"update\");\n\tsetCommandDescriptions(command, \"Update your database schema to match your contract\", \"Compares your database schema to the emitted contract and applies the necessary\\nchanges. Works on any database, whether or not it has been initialized with `db init`.\\nDestructive operations prompt for confirmation in interactive mode. Use -y to\\nauto-accept or --dry-run to preview first.\");\n\tsetCommandExamples(command, [\"prisma-next db update --db $DATABASE_URL\", \"prisma-next db update --db $DATABASE_URL --dry-run\"]);\n\taddMigrationCommandOptions(command);\n\tcommand.option(\"--to <contract>\", \"Target contract reference (hash, prefix, ref name, migration dir name, <dir>^, or ./path)\");\n\tcommand.option(\"--advance-ref <name>\", \"Ref to advance to the post-command contract hash\");\n\tcommand.action(async (options) => {\n\t\tconst flags = parseGlobalFlagsOrExit(options);\n\t\tconst startTime = Date.now();\n\t\tconst ui = createTerminalUI(flags);\n\t\tlet result = await executeDbUpdateCommand(options, flags, ui, startTime);\n\t\tif (!result.ok && result.failure.code === ERROR_CODE_DESTRUCTIVE_CHANGES && flags.interactive && !flags.json && !flags.yes) {\n\t\t\tconst destructiveOps = result.failure.meta?.destructiveOperations ?? [];\n\t\t\tif (destructiveOps.length > 0) ui.warn(`${destructiveOps.length} destructive operation(s) that may cause data loss:\\n${destructiveOps.map((op) => ` ${ui.yellow(\"▸\")} ${op.label}`).join(\"\\n\")}`);\n\t\t\tif (await ui.confirm(\"Apply destructive changes? This cannot be undone.\")) result = await executeDbUpdateCommand(options, {\n\t\t\t\t...flags,\n\t\t\t\tyes: true\n\t\t\t}, ui, Date.now());\n\t\t}\n\t\tconst exitCode = handleResult(result, flags, ui, (dbUpdateResult) => {\n\t\t\tif (flags.json) ui.output(formatMigrationJson(dbUpdateResult));\n\t\t\telse {\n\t\t\t\tconst output = dbUpdateResult.mode === \"plan\" ? formatMigrationPlanOutput(dbUpdateResult, flags) : formatMigrationApplyOutput(dbUpdateResult, flags);\n\t\t\t\tif (output) ui.log(output);\n\t\t\t}\n\t\t});\n\t\tprocess.exit(exitCode);\n\t});\n\treturn command;\n}\n//#endregion\nexport { createDbUpdateCommand as t };\n\n//# sourceMappingURL=db-update-CsKZyDYp.mjs.map"],"mappings":";;;;;;;;;;;;;;;AAeA,SAAS,mBAAmB,SAAS;CACpC,IAAI,QAAQ,SAAS,mBAAmB,OAAO,6BAA6B,EAAE,WAAW,QAAQ,aAAa,CAAC,EAAE,CAAC;CAClH,IAAI,QAAQ,SAAS,iBAAiB;EACrC,MAAM,OAAO,OAAO,QAAQ,OAAO,uBAAuB,WAAW,QAAQ,KAAK,qBAAqB,KAAK,OAAO,kCAAkC,iMAAiM;EACtV,OAAO,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D,eAAe,KAAK,OAAO,KAAK,GAAG,OAAO,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC,CAAC,KAAK,IAAI,GAAG;GACjM,IAAI,MAAM,GAAG,QAAQ,mDAAmD,GAAG,SAAS,MAAM,uBAAuB,SAAS;IACzH,GAAG;IACH,KAAK;GACN,GAAG,IAAI,KAAK,IAAI,CAAC;EAClB;EACA,MAAM,WAAW,aAAa,QAAQ,OAAO,KAAK,mBAAmB;GACpE,IAAI,MAAM,MAAM,GAAG,OAAO,oBAAoB,cAAc,CAAC;QACxD;IACJ,MAAM,SAAS,eAAe,SAAS,SAAS,0BAA0B,gBAAgB,KAAK,IAAI,2BAA2B,gBAAgB,KAAK;IACnJ,IAAI,QAAQ,GAAG,IAAI,MAAM;GAC1B;EACD,CAAC;EACD,QAAQ,KAAK,QAAQ;CACtB,CAAC;CACD,OAAO;AACR"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { o as loadConfigForSections } from "./exports-BZLNbtkY.mjs";
|
|
2
2
|
import { M as errorTargetMismatch, N as errorUnexpected, O as errorRuntime$1, _ as errorMarkerMissing, c as errorDatabaseConnectionRequired, d as errorFileNotFound, f as errorHashMismatch, s as errorContractValidationFailed, t as CliStructuredError$1, u as errorDriverRequired } from "./cli-errors-CihMAEVj-C1uUYBop.mjs";
|
|
3
|
-
import {
|
|
4
|
-
import { _ as resolveMigrationPaths, b as setCommandExamples, f as maskConnectionUrl, g as resolveContractPath, m as parseGlobalFlagsOrExit, n as closeQuietly, s as formatStyledHeader, t as addGlobalOptions, u as handleResult, y as setCommandDescriptions } from "./command-helpers-
|
|
3
|
+
import { r as createTerminalUI } from "./terminal-ui-JJKxvT0q-CPDEJqqU.mjs";
|
|
4
|
+
import { _ as resolveMigrationPaths, b as setCommandExamples, f as maskConnectionUrl, g as resolveContractPath, m as parseGlobalFlagsOrExit, n as closeQuietly, s as formatStyledHeader, t as addGlobalOptions, u as handleResult, y as setCommandDescriptions } from "./command-helpers-Dw3LDEu_-B4AETH4D.mjs";
|
|
5
5
|
import { t as createProgressAdapter } from "./progress-adapter-CjAeTxY_-BXYSd1eY.mjs";
|
|
6
|
-
import { t as createControlClient } from "./client-
|
|
7
|
-
import { c as formatVerifyOutput, i as formatSchemaVerifyOutput, r as formatSchemaVerifyJson, s as formatVerifyJson } from "./verify-
|
|
6
|
+
import { t as createControlClient } from "./client-C4Gh4PBz-BMUlBcuE.mjs";
|
|
7
|
+
import { c as formatVerifyOutput, i as formatSchemaVerifyOutput, r as formatSchemaVerifyJson, s as formatVerifyJson } from "./verify-wUSBDQwh-Bv3NV9WG.mjs";
|
|
8
8
|
import { ifDefined } from "@prisma/orm-framework/utils/defined";
|
|
9
9
|
import { relative, resolve } from "pathe";
|
|
10
10
|
import { isStructuredError } from "@prisma/orm-framework/utils/structured-error";
|
|
@@ -13,7 +13,7 @@ import { readFile } from "node:fs/promises";
|
|
|
13
13
|
import { VERIFY_CODE_HASH_MISMATCH, VERIFY_CODE_MARKER_MISSING, VERIFY_CODE_TARGET_MISMATCH, createControlStack } from "@prisma/orm-framework/components/control";
|
|
14
14
|
import { notOk, ok } from "@prisma/orm-framework/utils/result";
|
|
15
15
|
import { Command } from "commander";
|
|
16
|
-
//#region ../../../1-framework/3-tooling/cli/dist/db-verify-
|
|
16
|
+
//#region ../../../1-framework/3-tooling/cli/dist/db-verify-B33E7HXH.mjs
|
|
17
17
|
/**
|
|
18
18
|
* Collapse the aggregate verifier's per-space contract-satisfaction results
|
|
19
19
|
* into a single {@link VerifyDatabaseSchemaResult} for the CLI display
|
|
@@ -413,4 +413,4 @@ function createDbVerifyCommand() {
|
|
|
413
413
|
//#endregion
|
|
414
414
|
export { createDbVerifyCommand as t };
|
|
415
415
|
|
|
416
|
-
//# sourceMappingURL=db-verify-
|
|
416
|
+
//# sourceMappingURL=db-verify-B33E7HXH-D87fiNt3.mjs.map
|