@prisma/orm-family-sql 8.0.0-rc.16-dev.9 → 8.0.0-rc.16-dev.10
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/{ast-Bf6J9_ra.d.mts → ast-Bmb-2vbO.d.mts} +3 -3
- package/dist/{ast-Bf6J9_ra.d.mts.map → ast-Bmb-2vbO.d.mts.map} +1 -1
- package/dist/{authoring-entity-types-CZ-vdwYS-Bq3LXsCn.d.mts → authoring-entity-types-CZ-vdwYS-BLYHcBXG.d.mts} +2 -2
- package/dist/{authoring-entity-types-CZ-vdwYS-Bq3LXsCn.d.mts.map → authoring-entity-types-CZ-vdwYS-BLYHcBXG.d.mts.map} +1 -1
- package/dist/{authoring-type-constructors-0Iv2zdwS-CVl4womm.mjs → authoring-type-constructors-0Iv2zdwS-ClKI8Uuk.mjs} +2 -2
- package/dist/{authoring-type-constructors-0Iv2zdwS-CVl4womm.mjs.map → authoring-type-constructors-0Iv2zdwS-ClKI8Uuk.mjs.map} +1 -1
- package/dist/builder.d.mts +2 -2
- package/dist/builder__runtime.d.mts +9 -9
- package/dist/builder__runtime.mjs +1 -1
- package/dist/builder__types.d.mts +2 -2
- package/dist/{codec-descriptor-registry-D7bl9ayf.mjs → codec-descriptor-registry-CdIIOkuE.mjs} +2 -2
- package/dist/{codec-descriptor-registry-D7bl9ayf.mjs.map → codec-descriptor-registry-CdIIOkuE.mjs.map} +1 -1
- package/dist/{config-types-DeIF6WyF.mjs → config-types-D0sxpKAN.mjs} +2 -2
- package/dist/{config-types-DeIF6WyF.mjs.map → config-types-D0sxpKAN.mjs.map} +1 -1
- package/dist/{config-types-Cag6qJnA.d.mts → config-types-DB6gRJ5K.d.mts} +4 -4
- package/dist/{config-types-Cag6qJnA.d.mts.map → config-types-DB6gRJ5K.d.mts.map} +1 -1
- package/dist/{contract-builder-BaJMQFAc.d.mts → contract-builder-V5pFHDv3.d.mts} +14 -11
- package/dist/contract-builder-V5pFHDv3.d.mts.map +1 -0
- package/dist/{contract-builder-BlFrYr97.mjs → contract-builder-tEax3I2q.mjs} +4 -4
- package/dist/{contract-builder-BlFrYr97.mjs.map → contract-builder-tEax3I2q.mjs.map} +1 -1
- package/dist/contract-emitter.mjs +1 -1
- package/dist/contract-prisma7__provider.d.mts +2 -2
- package/dist/contract-prisma7__provider.mjs +36 -8
- package/dist/contract-prisma7__provider.mjs.map +1 -1
- package/dist/contract-psl.d.mts +3 -3
- package/dist/contract-psl.mjs +1 -1
- package/dist/contract-psl__attribute-specs.d.mts +4 -4
- package/dist/contract-psl__attribute-specs.d.mts.map +1 -1
- package/dist/contract-psl__attribute-specs.mjs +1 -1
- package/dist/contract-psl__provider.d.mts +2 -2
- package/dist/contract-psl__provider.mjs +2 -2
- package/dist/contract-psl__provider.mjs.map +1 -1
- package/dist/contract-ts.d.mts +3 -3
- package/dist/contract-ts.mjs +3 -3
- package/dist/contract-ts__config-types.d.mts +1 -1
- package/dist/contract-ts__config-types.mjs +1 -1
- package/dist/contract-ts__contract-builder.d.mts +2 -2
- package/dist/contract-ts__contract-builder.mjs +2 -2
- package/dist/{contract-view-Cd6_tdxU.d.mts → contract-view-C1xX3yIj.d.mts} +2 -2
- package/dist/{contract-view-Cd6_tdxU.d.mts.map → contract-view-C1xX3yIj.d.mts.map} +1 -1
- package/dist/contract.d.mts +14 -14
- package/dist/contract.mjs +9 -8
- package/dist/contract__contract-view.d.mts +1 -1
- package/dist/contract__entity-kinds.d.mts +1 -1
- package/dist/contract__entity-kinds.mjs +1 -1
- package/dist/contract__factories.d.mts +1 -1
- package/dist/contract__factories.mjs +1 -1
- package/dist/contract__foreign-key-materialization.d.mts +2 -2
- package/dist/contract__foreign-key-materialization.mjs +3 -2
- package/dist/contract__index-type-validation.d.mts +1 -1
- package/dist/contract__referential-action-sql.d.mts +1 -1
- package/dist/contract__resolve-storage-table.d.mts +1 -1
- package/dist/contract__types.d.mts +6 -6
- package/dist/contract__types.mjs +3 -3
- package/dist/contract__validators.d.mts +1 -1
- package/dist/contract__validators.mjs +2 -2
- package/dist/{control-BkyDhucB.d.mts → control-B3Mb21Md.d.mts} +16 -16
- package/dist/{control-BkyDhucB.d.mts.map → control-B3Mb21Md.d.mts.map} +1 -1
- package/dist/{control-BRbds4vn.mjs → control-C5Yy0n3w.mjs} +10 -10
- package/dist/{control-BRbds4vn.mjs.map → control-C5Yy0n3w.mjs.map} +1 -1
- package/dist/control-adapter-BXQ29_fa.d.mts +1 -0
- package/dist/{control-adapter-CkFfBVei-Ba9JNrCN.d.mts → control-adapter-CkFfBVei-BLYeKcLW.d.mts} +6 -6
- package/dist/{control-adapter-CkFfBVei-Ba9JNrCN.d.mts.map → control-adapter-CkFfBVei-BLYeKcLW.d.mts.map} +1 -1
- package/dist/{db-D7R5zKiH-SEM04lcK.d.mts → db-D7R5zKiH-P7Tg4ZXk.d.mts} +9 -9
- package/dist/{db-D7R5zKiH-SEM04lcK.d.mts.map → db-D7R5zKiH-P7Tg4ZXk.d.mts.map} +1 -1
- package/dist/{ddl-types-DtKZjNtN-6TxFf4bH.d.mts → ddl-types-DtKZjNtN-CByECwns.d.mts} +4 -4
- package/dist/{ddl-types-DtKZjNtN-6TxFf4bH.d.mts.map → ddl-types-DtKZjNtN-CByECwns.d.mts.map} +1 -1
- package/dist/{derived-checks-DdguQPYm-BP57ljP8.mjs → derived-checks-D5zdlyyh-CPofdm1W.mjs} +30 -20
- package/dist/{derived-checks-DdguQPYm-BP57ljP8.mjs.map → derived-checks-D5zdlyyh-CPofdm1W.mjs.map} +1 -1
- package/dist/{derived-checks-DpPkO6Dt-BituyKFg.d.mts → derived-checks-DpPkO6Dt-D3M7YEr2.d.mts} +3 -3
- package/dist/{derived-checks-DpPkO6Dt-BituyKFg.d.mts.map → derived-checks-DpPkO6Dt-D3M7YEr2.d.mts.map} +1 -1
- package/dist/{diff-DMOqiT2h.d.mts → diff-CBqsNkxe.d.mts} +6 -6
- package/dist/{diff-DMOqiT2h.d.mts.map → diff-CBqsNkxe.d.mts.map} +1 -1
- package/dist/{dist-7hmkNQGd.mjs → dist-Dm_hQ-hh.mjs} +2 -2
- package/dist/{dist-7hmkNQGd.mjs.map → dist-Dm_hQ-hh.mjs.map} +1 -1
- package/dist/{entity-kinds-DCwkg9t7.d.mts → entity-kinds--HvqT50S.d.mts} +2 -2
- package/dist/{entity-kinds-DCwkg9t7.d.mts.map → entity-kinds--HvqT50S.d.mts.map} +1 -1
- package/dist/{entity-kinds-JlqzyFoo-kIaAUFyK.mjs → entity-kinds-O3V1K26U-B8TUrsX2.mjs} +16 -5
- package/dist/entity-kinds-O3V1K26U-B8TUrsX2.mjs.map +1 -0
- package/dist/{expression-B-QXMOmY.d.mts → expression-DE893va7.d.mts} +7 -7
- package/dist/{expression-B-QXMOmY.d.mts.map → expression-DE893va7.d.mts.map} +1 -1
- package/dist/{factories-BsUyFxsk.mjs → factories-Bp41Aity.mjs} +4 -3
- package/dist/factories-Bp41Aity.mjs.map +1 -0
- package/dist/{factories-CgVRbL8l.d.mts → factories-DzLBAAvj.d.mts} +4 -4
- package/dist/{factories-CgVRbL8l.d.mts.map → factories-DzLBAAvj.d.mts.map} +1 -1
- package/dist/family.d.mts +13 -13
- package/dist/family.mjs +6 -6
- package/dist/family__control-adapter.d.mts +2 -2
- package/dist/family__control.d.mts +4 -4
- package/dist/family__control.mjs +3 -3
- package/dist/family__diff.d.mts +2 -2
- package/dist/family__diff.mjs +1 -1
- package/dist/family__ir.d.mts +1 -1
- package/dist/family__ir.mjs +1 -1
- package/dist/family__migration.d.mts +1 -1
- package/dist/family__pack.d.mts +1 -1
- package/dist/family__pack.mjs +2 -2
- package/dist/family__psl-build.mjs +1 -1
- package/dist/family__psl-infer.d.mts +1 -1
- package/dist/family__psl-infer.mjs +1 -1
- package/dist/family__runtime.d.mts +2 -2
- package/dist/foreign-key-materialization-Cv3q8Pix.mjs +278 -0
- package/dist/foreign-key-materialization-Cv3q8Pix.mjs.map +1 -0
- package/dist/foreign-key-materialization-D0Ltg78T.d.mts +96 -0
- package/dist/foreign-key-materialization-D0Ltg78T.d.mts.map +1 -0
- package/dist/{foreign-key-C-iTPuRT-C9ip8zFx.d.mts → foreign-key-qkDFfG8t-Fyrzd0VI.d.mts} +20 -4
- package/dist/foreign-key-qkDFfG8t-Fyrzd0VI.d.mts.map +1 -0
- package/dist/{index-qOLTnfYz.d.mts → index-CnpTmyXs.d.mts} +3 -3
- package/dist/{index-qOLTnfYz.d.mts.map → index-CnpTmyXs.d.mts.map} +1 -1
- package/dist/index-equivalence-DswCiq5l-C7wLMPwF.mjs +109 -0
- package/dist/index-equivalence-DswCiq5l-C7wLMPwF.mjs.map +1 -0
- package/dist/{index-DYjWQAcJ.d.mts → index-oNRBExeI.d.mts} +11 -11
- package/dist/{index-DYjWQAcJ.d.mts.map → index-oNRBExeI.d.mts.map} +1 -1
- package/dist/{index-type-validation-BHppm9U-.d.mts → index-type-validation-B925ye4q.d.mts} +3 -3
- package/dist/{index-type-validation-BHppm9U-.d.mts.map → index-type-validation-B925ye4q.d.mts.map} +1 -1
- package/dist/{interpreter-BF5Xrf3W-bdklH78q.mjs → interpreter-DlG-2o64-DmykcFbp.mjs} +64 -17
- package/dist/interpreter-DlG-2o64-DmykcFbp.mjs.map +1 -0
- package/dist/{ir-BYHqe2mj.d.mts → ir-BPrf_vgX.d.mts} +3 -3
- package/dist/{ir-BYHqe2mj.d.mts.map → ir-BPrf_vgX.d.mts.map} +1 -1
- package/dist/middleware-DwaZ6s12.d.mts +1 -0
- package/dist/{middleware-mLwvcOLS-6Y52seRP.d.mts → middleware-mLwvcOLS-SaqhgsmA.d.mts} +2 -2
- package/dist/{middleware-mLwvcOLS-6Y52seRP.d.mts.map → middleware-mLwvcOLS-SaqhgsmA.d.mts.map} +1 -1
- package/dist/{migration-C5HGygKM.d.mts → migration-C_J49WKy.d.mts} +4 -4
- package/dist/{migration-C5HGygKM.d.mts.map → migration-C_J49WKy.d.mts.map} +1 -1
- package/dist/operations.d.mts +1 -1
- package/dist/orm-client.d.mts +15 -15
- package/dist/orm-client.mjs +1 -1
- package/dist/{pack-l0vLQrO8.d.mts → pack-DZtuLikU.d.mts} +3 -3
- package/dist/{pack-l0vLQrO8.d.mts.map → pack-DZtuLikU.d.mts.map} +1 -1
- package/dist/plan-Dhl03MtT.d.mts +2 -0
- package/dist/{plan-cGEaSXHv-2F5y-Dpy.d.mts → plan-cGEaSXHv-BeW-cC5v.d.mts} +4 -4
- package/dist/{plan-cGEaSXHv-2F5y-Dpy.d.mts.map → plan-cGEaSXHv-BeW-cC5v.d.mts.map} +1 -1
- package/dist/{prepared-statement-YtgdlN7e-DBJtJAm7.d.mts → prepared-statement-YtgdlN7e-CI1fD5IM.d.mts} +16 -16
- package/dist/{prepared-statement-YtgdlN7e-DBJtJAm7.d.mts.map → prepared-statement-YtgdlN7e-CI1fD5IM.d.mts.map} +1 -1
- package/dist/{psl-build-Di-cBOCv.mjs → psl-build-B5iMVWHu.mjs} +2 -2
- package/dist/{psl-build-Di-cBOCv.mjs.map → psl-build-B5iMVWHu.mjs.map} +1 -1
- package/dist/{psl-column-resolution-CNtNJ7g7-CR_auHUV.d.mts → psl-column-resolution-CNtNJ7g7-CEuutj8I.d.mts} +2 -2
- package/dist/{psl-column-resolution-CNtNJ7g7-CR_auHUV.d.mts.map → psl-column-resolution-CNtNJ7g7-CEuutj8I.d.mts.map} +1 -1
- package/dist/{psl-field-resolution-DUCrDnuq-DSxPrd-4.mjs → psl-field-resolution-BW0ZuqBd-Dv18ERa7.mjs} +6 -6
- package/dist/psl-field-resolution-BW0ZuqBd-Dv18ERa7.mjs.map +1 -0
- package/dist/{psl-infer-fU7LRjTx.mjs → psl-infer-B0yuv-j_.mjs} +22 -16
- package/dist/psl-infer-B0yuv-j_.mjs.map +1 -0
- package/dist/{psl-infer-Cm7eDSA-.d.mts → psl-infer-DkPZJnUM.d.mts} +11 -12
- package/dist/{psl-infer-Cm7eDSA-.d.mts.map → psl-infer-DkPZJnUM.d.mts.map} +1 -1
- package/dist/query-lane-context-BaoHpLsE.d.mts +1 -0
- package/dist/{query-lane-context-CJoNBspB-Ylhia3fC.d.mts → query-lane-context-CJoNBspB-CR_n8DNB.d.mts} +5 -5
- package/dist/{query-lane-context-CJoNBspB-Ylhia3fC.d.mts.map → query-lane-context-CJoNBspB-CR_n8DNB.d.mts.map} +1 -1
- package/dist/{referential-action-sql-DJ9ps6-S.d.mts → referential-action-sql-Cw1Q0YSd.d.mts} +2 -2
- package/dist/referential-action-sql-Cw1Q0YSd.d.mts.map +1 -0
- package/dist/relational-core.d.mts +11 -11
- package/dist/relational-core__aggregate-descriptor-registry.d.mts +1 -1
- package/dist/relational-core__ast.d.mts +3 -3
- package/dist/relational-core__codec-descriptor-registry.d.mts +4 -4
- package/dist/relational-core__codec-descriptor-registry.mjs +1 -1
- package/dist/relational-core__contract-free.d.mts +4 -4
- package/dist/relational-core__expression.d.mts +1 -1
- package/dist/relational-core__middleware.d.mts +2 -2
- package/dist/relational-core__plan.d.mts +3 -3
- package/dist/relational-core__query-lane-context.d.mts +2 -2
- package/dist/relational-core__types.d.mts +2 -2
- package/dist/{resolve-storage-table-Ba33K41A.d.mts → resolve-storage-table-B7m9cFy4.d.mts} +3 -3
- package/dist/{resolve-storage-table-Ba33K41A.d.mts.map → resolve-storage-table-B7m9cFy4.d.mts.map} +1 -1
- package/dist/{runtime-BUemUdMk.d.mts → runtime-Ca7PVQcJ.d.mts} +2 -2
- package/dist/{runtime-BUemUdMk.d.mts.map → runtime-Ca7PVQcJ.d.mts.map} +1 -1
- package/dist/runtime.d.mts +4 -4
- package/dist/runtime.mjs +2 -2
- package/dist/runtime__internal__prepared-query.d.mts +1 -1
- package/dist/{schema-differ-CqWOkoW9--uxNOini.d.mts → schema-differ-CqWOkoW9-BABSAGGB.d.mts} +3 -3
- package/dist/{schema-differ-CqWOkoW9--uxNOini.d.mts.map → schema-differ-CqWOkoW9-BABSAGGB.d.mts.map} +1 -1
- package/dist/{schema-verify-DIfHSB4I-CjYnmUuD.mjs → schema-verify-DIfHSB4I-Dx3Tq9hf.mjs} +2 -2
- package/dist/{schema-verify-DIfHSB4I-CjYnmUuD.mjs.map → schema-verify-DIfHSB4I-Dx3Tq9hf.mjs.map} +1 -1
- package/dist/{serialized-index-QAYy0fjm-zxvK3RBa.mjs → serialized-index-C26m_DWu-CnNi8WAI.mjs} +3 -3
- package/dist/{serialized-index-QAYy0fjm-zxvK3RBa.mjs.map → serialized-index-C26m_DWu-CnNi8WAI.mjs.map} +1 -1
- package/dist/{sql-contract-serializer-DDaAVCQr-CLDkZLXO.mjs → sql-contract-serializer-DDaAVCQr-c3jZiPS3.mjs} +4 -4
- package/dist/{sql-contract-serializer-DDaAVCQr-CLDkZLXO.mjs.map → sql-contract-serializer-DDaAVCQr-c3jZiPS3.mjs.map} +1 -1
- package/dist/{sql-execution-plan-C7XauPPu-BMi8hJlv.d.mts → sql-execution-plan-C7XauPPu-BFhGKvp4.d.mts} +2 -2
- package/dist/{sql-execution-plan-C7XauPPu-BMi8hJlv.d.mts.map → sql-execution-plan-C7XauPPu-BFhGKvp4.d.mts.map} +1 -1
- package/dist/{sql-storage-DSnnRQAf-DaHPnley.d.mts → sql-storage-BTlJLUID-O6fBB_am.d.mts} +3 -3
- package/dist/{sql-storage-DSnnRQAf-DaHPnley.d.mts.map → sql-storage-BTlJLUID-O6fBB_am.d.mts.map} +1 -1
- package/dist/{storage-table-CyL4CNMi-ByGZXmzd.mjs → storage-table-B7OSPl3G-EOodFPzq.mjs} +5 -3
- package/dist/storage-table-B7OSPl3G-EOodFPzq.mjs.map +1 -0
- package/dist/{storage-table-BBcKoAuF-CssyCQhM.d.mts → storage-table-WXeVNycx-tlFMnbig.d.mts} +3 -3
- package/dist/{storage-table-BBcKoAuF-CssyCQhM.d.mts.map → storage-table-WXeVNycx-tlFMnbig.d.mts.map} +1 -1
- package/dist/{types-BJQcLx-8-DSnaugR4.d.mts → types-BJQcLx-8-DY221fiX.d.mts} +10 -10
- package/dist/{types-BJQcLx-8-DSnaugR4.d.mts.map → types-BJQcLx-8-DY221fiX.d.mts.map} +1 -1
- package/dist/{types-DkOYK86-.d.mts → types-BURWzacK.d.mts} +5 -5
- package/dist/{types-DkOYK86-.d.mts.map → types-BURWzacK.d.mts.map} +1 -1
- package/dist/{types-DDHgx581.mjs → types-C7oOtFcJ.mjs} +2 -2
- package/dist/{types-DDHgx581.mjs.map → types-C7oOtFcJ.mjs.map} +1 -1
- package/dist/{types-CzxOObSY-CNWyrf87.d.mts → types-CzxOObSY-DEfjmbj1.d.mts} +7 -7
- package/dist/{types-CzxOObSY-CNWyrf87.d.mts.map → types-CzxOObSY-DEfjmbj1.d.mts.map} +1 -1
- package/dist/{types-DV040Uuq-Bu8CnbMa.d.mts → types-DFZhLz18-C_h0u-Zx.d.mts} +8 -7
- package/dist/types-DFZhLz18-C_h0u-Zx.d.mts.map +1 -0
- package/dist/types-DLjT0ADz.d.mts +1 -0
- package/dist/{types-Sh5HuaZE-C8I29pGQ.d.mts → types-Sh5HuaZE-B_FQUPng.d.mts} +2 -2
- package/dist/{types-Sh5HuaZE-C8I29pGQ.d.mts.map → types-Sh5HuaZE-B_FQUPng.d.mts.map} +1 -1
- package/dist/{validators-BAa0JKuB.d.mts → validators-Cr_FFJAG.d.mts} +5 -4
- package/dist/{validators-BAa0JKuB.d.mts.map → validators-Cr_FFJAG.d.mts.map} +1 -1
- package/dist/{validators-Xx-TKcx3.mjs → validators-oyDG5mVX.mjs} +22 -2
- package/dist/validators-oyDG5mVX.mjs.map +1 -0
- package/package.json +18 -18
- package/dist/contract-builder-BaJMQFAc.d.mts.map +0 -1
- package/dist/control-adapter-CD_gz6TI.d.mts +0 -1
- package/dist/entity-kinds-JlqzyFoo-kIaAUFyK.mjs.map +0 -1
- package/dist/factories-BsUyFxsk.mjs.map +0 -1
- package/dist/foreign-key-C-iTPuRT-C9ip8zFx.d.mts.map +0 -1
- package/dist/foreign-key-materialization-IGfTKmHV.mjs +0 -73
- package/dist/foreign-key-materialization-IGfTKmHV.mjs.map +0 -1
- package/dist/foreign-key-materialization-U4M9cqKd.d.mts +0 -65
- package/dist/foreign-key-materialization-U4M9cqKd.d.mts.map +0 -1
- package/dist/interpreter-BF5Xrf3W-bdklH78q.mjs.map +0 -1
- package/dist/middleware-BFoORv3y.d.mts +0 -1
- package/dist/plan-CmfWjqtI.d.mts +0 -2
- package/dist/psl-field-resolution-DUCrDnuq-DSxPrd-4.mjs.map +0 -1
- package/dist/psl-infer-fU7LRjTx.mjs.map +0 -1
- package/dist/query-lane-context-qK5s2okl.d.mts +0 -1
- package/dist/referential-action-sql-DJ9ps6-S.d.mts.map +0 -1
- package/dist/storage-table-CyL4CNMi-ByGZXmzd.mjs.map +0 -1
- package/dist/types-14L6c26e.d.mts +0 -1
- package/dist/types-DV040Uuq-Bu8CnbMa.d.mts.map +0 -1
- package/dist/validators-Xx-TKcx3.mjs.map +0 -1
package/dist/family__pack.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { b as sqlAttributeSpecs } from "./psl-field-resolution-
|
|
2
|
-
import { i as sqlFamilyPslBlockDescriptors, n as sqlFamilyAuthoringTypes, r as sqlFamilyEntityTypes, t as sqlFamilyAuthoringFieldPresets } from "./authoring-type-constructors-0Iv2zdwS-
|
|
1
|
+
import { b as sqlAttributeSpecs } from "./psl-field-resolution-BW0ZuqBd-Dv18ERa7.mjs";
|
|
2
|
+
import { i as sqlFamilyPslBlockDescriptors, n as sqlFamilyAuthoringTypes, r as sqlFamilyEntityTypes, t as sqlFamilyAuthoringFieldPresets } from "./authoring-type-constructors-0Iv2zdwS-ClKI8Uuk.mjs";
|
|
3
3
|
//#region ../../../2-sql/9-family/dist/pack.mjs
|
|
4
4
|
const sqlFamilyPack = {
|
|
5
5
|
kind: "family",
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as buildChildRelationField, c as inferRelations, d as toFieldName, f as toModelName, i as RelationField, l as pluralize, n as InferredRelations, o as deriveBackRelationFieldName, r as PslPrinterOptions, s as deriveRelationFieldName, t as EnumInfo, u as toEnumName } from "./psl-infer-
|
|
1
|
+
import { a as buildChildRelationField, c as inferRelations, d as toFieldName, f as toModelName, i as RelationField, l as pluralize, n as InferredRelations, o as deriveBackRelationFieldName, r as PslPrinterOptions, s as deriveRelationFieldName, t as EnumInfo, u as toEnumName } from "./psl-infer-DkPZJnUM.mjs";
|
|
2
2
|
export { type EnumInfo, type InferredRelations, type PslPrinterOptions, type RelationField, buildChildRelationField, deriveBackRelationFieldName, deriveRelationFieldName, inferRelations, pluralize, toEnumName, toFieldName, toModelName };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as pluralize, c as toModelName, i as inferRelations, n as deriveBackRelationFieldName, o as toEnumName, r as deriveRelationFieldName, s as toFieldName, t as buildChildRelationField } from "./psl-infer-
|
|
1
|
+
import { a as pluralize, c as toModelName, i as inferRelations, n as deriveBackRelationFieldName, o as toEnumName, r as deriveRelationFieldName, s as toFieldName, t as buildChildRelationField } from "./psl-infer-B0yuv-j_.mjs";
|
|
2
2
|
export { buildChildRelationField, deriveBackRelationFieldName, deriveRelationFieldName, inferRelations, pluralize, toEnumName, toFieldName, toModelName };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { n as resolveStorageTable, t as ResolvedStorageTable } from "./resolve-storage-table-
|
|
2
|
-
import { a as timestampNowRuntimeGenerator, i as sqlRuntimeFamilyDescriptor, n as UNBOUND_DOMAIN_NAMESPACE_ID, r as resolveDomainModel, t as ResolvedDomainModel } from "./runtime-
|
|
1
|
+
import { n as resolveStorageTable, t as ResolvedStorageTable } from "./resolve-storage-table-B7m9cFy4.mjs";
|
|
2
|
+
import { a as timestampNowRuntimeGenerator, i as sqlRuntimeFamilyDescriptor, n as UNBOUND_DOMAIN_NAMESPACE_ID, r as resolveDomainModel, t as ResolvedDomainModel } from "./runtime-Ca7PVQcJ.mjs";
|
|
3
3
|
export { type ResolvedDomainModel, type ResolvedStorageTable, UNBOUND_DOMAIN_NAMESPACE_ID, sqlRuntimeFamilyDescriptor as default, resolveDomainModel, resolveStorageTable, timestampNowRuntimeGenerator };
|
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
import { t as contractError } from "./contract-errors-BCN6RVI5-5IHBF_lg.mjs";
|
|
2
|
+
import { g as truncateToWireNamePrefixBytes, l as nameOf, o as defaultIndexName } from "./naming-DkG_OegU-DpENNdZX.mjs";
|
|
3
|
+
import { r as lowerAuthoredIndex } from "./index-naming-Cj1Anq-T-NX841eiU.mjs";
|
|
4
|
+
import { i as leadingBackingObjectName, n as identicalIndexes, o as servingKey, r as indexNodeOf, s as startsWithColumns, t as derivedBackingIndexIsRedundant } from "./index-equivalence-DswCiq5l-C7wLMPwF.mjs";
|
|
5
|
+
import { UNBOUND_NAMESPACE_ID } from "@prisma/orm-framework/components/ir";
|
|
6
|
+
import { InternalError } from "@prisma/orm-framework/utils/internal-error";
|
|
7
|
+
import { asNamespaceId } from "@prisma/orm-framework/contract/types";
|
|
8
|
+
//#region ../../../2-sql/1-core/contract/dist/foreign-key-materialization.mjs
|
|
9
|
+
const IDENTICAL_DESCRIPTION = "the planner sees them as the same index. The contract keeps both because each is named.";
|
|
10
|
+
const REDUNDANT_DESCRIPTION = "which already serves the same lookups.";
|
|
11
|
+
/**
|
|
12
|
+
* Removes the indexes of one table that duplicate another. Two indexes are identical when the planner sees them as the same index apart from their names (see {@link identicalIndexes}); of an identical group the pass keeps the indexes named by the user, or the first one when none is. A plain non-unique index whose columns are those of the primary key, a unique constraint or a unique index without a predicate is redundant (see {@link servingKey}), and the pass removes it unless it is named by the user. Every index named by the user survives; the pass warns about each one that duplicates another, and refuses two identical indexes both named with `name:`, whose wire names the planner could not tell apart.
|
|
13
|
+
*/
|
|
14
|
+
function deduplicateIndexes(input) {
|
|
15
|
+
const { tableName, warnings } = input;
|
|
16
|
+
const replacements = /* @__PURE__ */ new Map();
|
|
17
|
+
const nodes = new Map(input.indexes.map((candidate) => [candidate, indexNodeOf(candidate.index)]));
|
|
18
|
+
const nodeOf = (candidate) => {
|
|
19
|
+
const node = nodes.get(candidate);
|
|
20
|
+
if (node === void 0) throw new InternalError("every candidate has a node");
|
|
21
|
+
return node;
|
|
22
|
+
};
|
|
23
|
+
const groups = [];
|
|
24
|
+
for (const candidate of input.indexes) {
|
|
25
|
+
const position = groups.findIndex(([first]) => identicalIndexes(nodeOf(first), nodeOf(candidate)));
|
|
26
|
+
const group = groups[position];
|
|
27
|
+
if (group === void 0) groups.push([candidate]);
|
|
28
|
+
else groups[position] = [...group, candidate];
|
|
29
|
+
}
|
|
30
|
+
for (const group of groups) {
|
|
31
|
+
const named = group.filter((candidate) => candidate.namedByUser);
|
|
32
|
+
const wireNamed = named.filter((candidate) => candidate.index.naming.kind === "wire");
|
|
33
|
+
if (wireNamed.length > 1) throw identicalWireNamedIndexesError(tableName, wireNamed);
|
|
34
|
+
const kept = named[0] ?? group[0];
|
|
35
|
+
for (const candidate of group) if (candidate !== kept && !candidate.namedByUser) replacements.set(candidate, {
|
|
36
|
+
kind: "index",
|
|
37
|
+
index: kept
|
|
38
|
+
});
|
|
39
|
+
if (named.length > 1) warnings.push(identicalIndexesWarning(tableName, named));
|
|
40
|
+
}
|
|
41
|
+
const survivors = input.indexes.filter((candidate) => !replacements.has(candidate));
|
|
42
|
+
for (const candidate of survivors) {
|
|
43
|
+
const servedBy = servingKey(nodeOf(candidate), {
|
|
44
|
+
indexes: survivors,
|
|
45
|
+
nodeOf,
|
|
46
|
+
uniques: input.uniques,
|
|
47
|
+
primaryKey: input.primaryKey
|
|
48
|
+
});
|
|
49
|
+
if (servedBy === void 0) continue;
|
|
50
|
+
if (candidate.namedByUser) warnings.push(redundantIndexWarning(tableName, candidate, servedBy));
|
|
51
|
+
else replacements.set(candidate, servedBy);
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
indexes: input.indexes.filter((candidate) => !replacements.has(candidate)),
|
|
55
|
+
replacements
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
function identicalWireNamedIndexesError(tableName, wireNamed) {
|
|
59
|
+
return contractError("CONTRACT.ARGUMENT_INVALID", `Indexes ${quotedList(wireNamed.map((candidate) => writtenName(candidate.index)))} on table "${tableName}" are identical and both named with name:; the planner pairs wire-named indexes by their content, so it could not tell them apart.`, {
|
|
60
|
+
fix: "Remove one of them, or name one with map: to keep both under exact names.",
|
|
61
|
+
meta: {
|
|
62
|
+
tableName,
|
|
63
|
+
indexes: wireNamed.map((candidate) => writtenName(candidate.index))
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
/** The name the source wrote: the prefix of a wire-named index, the whole name of an exact one. */
|
|
68
|
+
function writtenName(index) {
|
|
69
|
+
return index.naming.kind === "wire" ? index.naming.prefix : index.naming.name;
|
|
70
|
+
}
|
|
71
|
+
function quotedList(names) {
|
|
72
|
+
const quoted = names.map((name) => `"${name}"`);
|
|
73
|
+
return quoted.length <= 2 ? quoted.join(" and ") : `${quoted.slice(0, -1).join(", ")} and ${quoted.at(-1)}`;
|
|
74
|
+
}
|
|
75
|
+
function identicalIndexesWarning(tableName, named) {
|
|
76
|
+
const names = quotedList(named.map((candidate) => writtenName(candidate.index)));
|
|
77
|
+
return {
|
|
78
|
+
code: "PN_INDEX_DUPLICATE",
|
|
79
|
+
message: `Indexes ${names} on table "${tableName}" are identical: ${IDENTICAL_DESCRIPTION} Remove one of them.`,
|
|
80
|
+
item: `table "${tableName}": indexes ${names}`,
|
|
81
|
+
summary: `tables have named indexes that are identical: ${IDENTICAL_DESCRIPTION} Remove one of each.`
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
function describeReplacement(replacement) {
|
|
85
|
+
switch (replacement.kind) {
|
|
86
|
+
case "primaryKey": return "the primary key";
|
|
87
|
+
case "uniqueConstraint": return replacement.unique.name === void 0 ? `the unique constraint on (${replacement.unique.columns.join(", ")})` : `the unique constraint "${replacement.unique.name}"`;
|
|
88
|
+
case "index": return `the unique index "${writtenName(replacement.index.index)}"`;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
function redundantIndexWarning(tableName, candidate, servedBy) {
|
|
92
|
+
const name = writtenName(candidate.index);
|
|
93
|
+
return {
|
|
94
|
+
code: "PN_INDEX_REDUNDANT",
|
|
95
|
+
message: `Index "${name}" on table "${tableName}" has the same columns as ${describeReplacement(servedBy)}, ${REDUNDANT_DESCRIPTION} The contract keeps the index because it is named. Remove it.`,
|
|
96
|
+
item: `table "${tableName}": index "${name}"`,
|
|
97
|
+
summary: `tables have a named index with the same columns as a unique constraint, unique index or primary key, ${REDUNDANT_DESCRIPTION} The contract keeps each index because it is named. Remove them.`
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
/** The `meta.reason` of the refusal of a relation's `index: "<name>"`, which a source can report at the relation. */
|
|
101
|
+
const FOREIGN_KEY_INDEX_UNRESOLVED = "foreign-key-index-unresolved";
|
|
102
|
+
/**
|
|
103
|
+
* Lowers a table's authored foreign keys and indexes into the entities `contract.json` persists. A `constraint: false` foreign key contributes no `foreignKeys[]` entry. A foreign key with `index: true` gets a derived backing index; one with `index: "<name>"` uses what the table declares under that name. The table's indexes then pass through {@link deduplicateIndexes}, and each foreign key states what backs it in the result: an index by name, or the primary key or a unique constraint by kind.
|
|
104
|
+
*/
|
|
105
|
+
function materializeForeignKeysAndIndexes(input) {
|
|
106
|
+
const { tableName, declaredIndexes, uniques, primaryKey } = input;
|
|
107
|
+
const derivedIndexes = [];
|
|
108
|
+
const intents = input.foreignKeys.map((foreignKey) => {
|
|
109
|
+
const { constraint, index, ...reference } = foreignKey;
|
|
110
|
+
if (index !== true) return {
|
|
111
|
+
constraint,
|
|
112
|
+
reference,
|
|
113
|
+
index
|
|
114
|
+
};
|
|
115
|
+
const derived = derivedBackingIndex(tableName, reference.source.columns);
|
|
116
|
+
derivedIndexes.push(derived);
|
|
117
|
+
return {
|
|
118
|
+
constraint,
|
|
119
|
+
reference,
|
|
120
|
+
index: derived
|
|
121
|
+
};
|
|
122
|
+
});
|
|
123
|
+
const deduplicated = deduplicateIndexes({
|
|
124
|
+
tableName,
|
|
125
|
+
indexes: [...declaredIndexes, ...derivedIndexes],
|
|
126
|
+
uniques,
|
|
127
|
+
primaryKey,
|
|
128
|
+
warnings: input.warnings
|
|
129
|
+
});
|
|
130
|
+
const resolve = (backing) => foreignKeyIndexOf(resolveReplacement(backing, deduplicated.replacements));
|
|
131
|
+
return {
|
|
132
|
+
foreignKeys: intents.flatMap(({ constraint, reference, index }) => {
|
|
133
|
+
const backing = index === false ? void 0 : typeof index === "string" ? namedBackingObject(reference.source, index, {
|
|
134
|
+
declaredIndexes,
|
|
135
|
+
uniques,
|
|
136
|
+
primaryKey,
|
|
137
|
+
resolve
|
|
138
|
+
}) : resolve({
|
|
139
|
+
kind: "index",
|
|
140
|
+
index
|
|
141
|
+
});
|
|
142
|
+
if (!constraint) return [];
|
|
143
|
+
return [backing === void 0 ? reference : {
|
|
144
|
+
...reference,
|
|
145
|
+
index: backing
|
|
146
|
+
}];
|
|
147
|
+
}),
|
|
148
|
+
indexes: deduplicated.indexes.map((candidate) => candidate.index)
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Whether a table's declared indexes, unique constraints or primary key already serve a foreign key on `columns`, so the build would drop a derived backing index again. A source that writes no backing index of its own, such as a Prisma 7 schema, leaves the foreign key's `index` to the build where this holds, so the stored foreign key states what backs it.
|
|
153
|
+
*/
|
|
154
|
+
function declaredIndexesServeForeignKey(columns, table) {
|
|
155
|
+
return derivedBackingIndexIsRedundant(columns, {
|
|
156
|
+
indexes: table.indexes,
|
|
157
|
+
nodeOf: indexNodeOf,
|
|
158
|
+
uniques: table.uniques,
|
|
159
|
+
primaryKey: table.primaryKey
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* The name to give a relation's `index` argument when the table's declared indexes and keys serve a foreign key on `columns` although the build would keep a derived backing index beside them (see {@link leadingBackingObjectName}).
|
|
164
|
+
*/
|
|
165
|
+
function declaredBackingObjectName(columns, table) {
|
|
166
|
+
return leadingBackingObjectName(columns, {
|
|
167
|
+
indexes: table.indexes,
|
|
168
|
+
nodeOf: indexNodeOf,
|
|
169
|
+
nameOf: (index) => nameOf(index.naming),
|
|
170
|
+
uniques: table.uniques,
|
|
171
|
+
primaryKey: table.primaryKey
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* What a foreign key on `columns` states it is backed by when its relation says nothing, beside a table whose indexes all carry the `name` or `map` the source gave them, as a printed contract's do. A printer writes a relation's `index` argument only where the stored foreign key differs from this.
|
|
176
|
+
*/
|
|
177
|
+
function defaultForeignKeyIndex(tableName, columns, table) {
|
|
178
|
+
const reference = {
|
|
179
|
+
namespaceId: asNamespaceId(UNBOUND_NAMESPACE_ID),
|
|
180
|
+
tableName,
|
|
181
|
+
columns
|
|
182
|
+
};
|
|
183
|
+
const [foreignKey] = materializeForeignKeysAndIndexes({
|
|
184
|
+
tableName,
|
|
185
|
+
foreignKeys: [{
|
|
186
|
+
source: reference,
|
|
187
|
+
target: reference,
|
|
188
|
+
constraint: true,
|
|
189
|
+
index: true
|
|
190
|
+
}],
|
|
191
|
+
declaredIndexes: table.indexes.map((index) => ({
|
|
192
|
+
index,
|
|
193
|
+
namedByUser: true
|
|
194
|
+
})),
|
|
195
|
+
uniques: table.uniques,
|
|
196
|
+
primaryKey: table.primaryKey,
|
|
197
|
+
warnings: []
|
|
198
|
+
}).foreignKeys;
|
|
199
|
+
return typeof foreignKey?.index === "object" ? foreignKey.index : void 0;
|
|
200
|
+
}
|
|
201
|
+
function derivedBackingIndex(tableName, columns) {
|
|
202
|
+
return {
|
|
203
|
+
index: lowerAuthoredIndex(tableName, {
|
|
204
|
+
columns,
|
|
205
|
+
where: void 0,
|
|
206
|
+
unique: void 0,
|
|
207
|
+
map: void 0,
|
|
208
|
+
name: truncateToWireNamePrefixBytes(defaultIndexName(tableName, columns)),
|
|
209
|
+
type: void 0,
|
|
210
|
+
options: void 0
|
|
211
|
+
}),
|
|
212
|
+
namedByUser: false
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* What a relation's `index: "<name>"` points at. The name is the `name` or `map` the source gave an index, unique constraint or primary key, or an index's stored name; an unnamed index's default name does not count. Identical indexes count as one, so the name is resolved after they merge. The object must start with the foreign key's columns, in order, or it would not serve the foreign key's lookups.
|
|
217
|
+
*/
|
|
218
|
+
function namedBackingObject(source, name, table) {
|
|
219
|
+
const { namespaceId, tableName, columns } = source;
|
|
220
|
+
const subject = `The foreign key on table "${tableName}" columns (${columns.join(", ")}) names "${name}" as its index`;
|
|
221
|
+
const meta = {
|
|
222
|
+
reason: FOREIGN_KEY_INDEX_UNRESOLVED,
|
|
223
|
+
namespaceId,
|
|
224
|
+
tableName,
|
|
225
|
+
columns,
|
|
226
|
+
index: name
|
|
227
|
+
};
|
|
228
|
+
const indexes = table.declaredIndexes.filter((candidate) => candidate.namedByUser && writtenName(candidate.index) === name || nameOf(candidate.index.naming) === name);
|
|
229
|
+
const keys = [...table.uniques.filter((unique) => unique.name === name), ...table.primaryKey?.name === name ? [table.primaryKey] : []];
|
|
230
|
+
const resolvedIndexes = [...new Map(indexes.map((index) => {
|
|
231
|
+
const resolved = table.resolve({
|
|
232
|
+
kind: "index",
|
|
233
|
+
index
|
|
234
|
+
});
|
|
235
|
+
return [JSON.stringify(resolved), {
|
|
236
|
+
index,
|
|
237
|
+
resolved
|
|
238
|
+
}];
|
|
239
|
+
})).values()];
|
|
240
|
+
const matches = resolvedIndexes.length + keys.length;
|
|
241
|
+
if (matches === 0) throw contractError("CONTRACT.ARGUMENT_INVALID", `${subject}, but table "${tableName}" has no index, unique constraint or primary key with that name.`, {
|
|
242
|
+
fix: `Declare an index, unique constraint or primary key named "${name}" on table "${tableName}", or drop the index argument so the foreign key gets its own backing index.`,
|
|
243
|
+
meta
|
|
244
|
+
});
|
|
245
|
+
if (matches > 1) throw contractError("CONTRACT.ARGUMENT_INVALID", `${subject}, but table "${tableName}" has more than one index, unique constraint or primary key with that name.`, {
|
|
246
|
+
fix: `Give the object the foreign key should use a name no other index, unique constraint or primary key of table "${tableName}" has, and name that on the relation.`,
|
|
247
|
+
meta
|
|
248
|
+
});
|
|
249
|
+
const [match] = resolvedIndexes;
|
|
250
|
+
const key = keys[0];
|
|
251
|
+
const objectColumns = match !== void 0 ? match.index.index.columns : key?.columns;
|
|
252
|
+
if (objectColumns === void 0 || !startsWithColumns(objectColumns, columns)) throw contractError("CONTRACT.ARGUMENT_INVALID", `${subject}, but ${objectColumns === void 0 ? "it indexes an expression, not the foreign key's columns" : `its columns (${objectColumns.join(", ")}) do not start with the foreign key's columns`}, so it does not serve the foreign key's lookups.`, {
|
|
253
|
+
fix: `Name an index, unique constraint or primary key whose first columns are (${columns.join(", ")}), or drop the index argument so the foreign key gets its own backing index.`,
|
|
254
|
+
meta
|
|
255
|
+
});
|
|
256
|
+
if (match !== void 0) return match.resolved;
|
|
257
|
+
return key === table.primaryKey ? { primaryKey: true } : { unique: objectColumns };
|
|
258
|
+
}
|
|
259
|
+
function resolveReplacement(backing, replacements) {
|
|
260
|
+
let current = backing;
|
|
261
|
+
while (current.kind === "index") {
|
|
262
|
+
const replacement = replacements.get(current.index);
|
|
263
|
+
if (replacement === void 0) break;
|
|
264
|
+
current = replacement;
|
|
265
|
+
}
|
|
266
|
+
return current;
|
|
267
|
+
}
|
|
268
|
+
function foreignKeyIndexOf(backing) {
|
|
269
|
+
switch (backing.kind) {
|
|
270
|
+
case "index": return { name: nameOf(backing.index.index.naming) };
|
|
271
|
+
case "uniqueConstraint": return { unique: backing.unique.columns };
|
|
272
|
+
case "primaryKey": return { primaryKey: true };
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
//#endregion
|
|
276
|
+
export { materializeForeignKeysAndIndexes as a, defaultForeignKeyIndex as i, declaredBackingObjectName as n, declaredIndexesServeForeignKey as r, FOREIGN_KEY_INDEX_UNRESOLVED as t };
|
|
277
|
+
|
|
278
|
+
//# sourceMappingURL=foreign-key-materialization-Cv3q8Pix.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"foreign-key-materialization-Cv3q8Pix.mjs","names":[],"sources":["../../../../2-sql/1-core/contract/dist/foreign-key-materialization.mjs"],"sourcesContent":["import { t as contractError } from \"./contract-errors-BCN6RVI5.mjs\";\nimport { r as lowerAuthoredIndex } from \"./index-naming-Cj1Anq-T.mjs\";\nimport { i as leadingBackingObjectName, n as identicalIndexes, o as servingKey, r as indexNodeOf, s as startsWithColumns, t as derivedBackingIndexIsRedundant } from \"./index-equivalence-DswCiq5l.mjs\";\nimport { defaultIndexName, nameOf, truncateToWireNamePrefixBytes } from \"@internal/sql-schema-ir/naming\";\nimport { UNBOUND_NAMESPACE_ID } from \"@internal/framework-components/ir\";\nimport { InternalError } from \"@internal/utils/internal-error\";\nimport { asNamespaceId } from \"@internal/contract/types\";\n//#region src/index-deduplication.ts\nconst IDENTICAL_DESCRIPTION = \"the planner sees them as the same index. The contract keeps both because each is named.\";\nconst REDUNDANT_DESCRIPTION = \"which already serves the same lookups.\";\n/**\n* Removes the indexes of one table that duplicate another. Two indexes are identical when the planner sees them as the same index apart from their names (see {@link identicalIndexes}); of an identical group the pass keeps the indexes named by the user, or the first one when none is. A plain non-unique index whose columns are those of the primary key, a unique constraint or a unique index without a predicate is redundant (see {@link servingKey}), and the pass removes it unless it is named by the user. Every index named by the user survives; the pass warns about each one that duplicates another, and refuses two identical indexes both named with `name:`, whose wire names the planner could not tell apart.\n*/\nfunction deduplicateIndexes(input) {\n\tconst { tableName, warnings } = input;\n\tconst replacements = /* @__PURE__ */ new Map();\n\tconst nodes = new Map(input.indexes.map((candidate) => [candidate, indexNodeOf(candidate.index)]));\n\tconst nodeOf = (candidate) => {\n\t\tconst node = nodes.get(candidate);\n\t\tif (node === void 0) throw new InternalError(\"every candidate has a node\");\n\t\treturn node;\n\t};\n\tconst groups = [];\n\tfor (const candidate of input.indexes) {\n\t\tconst position = groups.findIndex(([first]) => identicalIndexes(nodeOf(first), nodeOf(candidate)));\n\t\tconst group = groups[position];\n\t\tif (group === void 0) groups.push([candidate]);\n\t\telse groups[position] = [...group, candidate];\n\t}\n\tfor (const group of groups) {\n\t\tconst named = group.filter((candidate) => candidate.namedByUser);\n\t\tconst wireNamed = named.filter((candidate) => candidate.index.naming.kind === \"wire\");\n\t\tif (wireNamed.length > 1) throw identicalWireNamedIndexesError(tableName, wireNamed);\n\t\tconst kept = named[0] ?? group[0];\n\t\tfor (const candidate of group) if (candidate !== kept && !candidate.namedByUser) replacements.set(candidate, {\n\t\t\tkind: \"index\",\n\t\t\tindex: kept\n\t\t});\n\t\tif (named.length > 1) warnings.push(identicalIndexesWarning(tableName, named));\n\t}\n\tconst survivors = input.indexes.filter((candidate) => !replacements.has(candidate));\n\tfor (const candidate of survivors) {\n\t\tconst servedBy = servingKey(nodeOf(candidate), {\n\t\t\tindexes: survivors,\n\t\t\tnodeOf,\n\t\t\tuniques: input.uniques,\n\t\t\tprimaryKey: input.primaryKey\n\t\t});\n\t\tif (servedBy === void 0) continue;\n\t\tif (candidate.namedByUser) warnings.push(redundantIndexWarning(tableName, candidate, servedBy));\n\t\telse replacements.set(candidate, servedBy);\n\t}\n\treturn {\n\t\tindexes: input.indexes.filter((candidate) => !replacements.has(candidate)),\n\t\treplacements\n\t};\n}\nfunction identicalWireNamedIndexesError(tableName, wireNamed) {\n\treturn contractError(\"CONTRACT.ARGUMENT_INVALID\", `Indexes ${quotedList(wireNamed.map((candidate) => writtenName(candidate.index)))} on table \"${tableName}\" are identical and both named with name:; the planner pairs wire-named indexes by their content, so it could not tell them apart.`, {\n\t\tfix: \"Remove one of them, or name one with map: to keep both under exact names.\",\n\t\tmeta: {\n\t\t\ttableName,\n\t\t\tindexes: wireNamed.map((candidate) => writtenName(candidate.index))\n\t\t}\n\t});\n}\n/** The name the source wrote: the prefix of a wire-named index, the whole name of an exact one. */\nfunction writtenName(index) {\n\treturn index.naming.kind === \"wire\" ? index.naming.prefix : index.naming.name;\n}\nfunction quotedList(names) {\n\tconst quoted = names.map((name) => `\"${name}\"`);\n\treturn quoted.length <= 2 ? quoted.join(\" and \") : `${quoted.slice(0, -1).join(\", \")} and ${quoted.at(-1)}`;\n}\nfunction identicalIndexesWarning(tableName, named) {\n\tconst names = quotedList(named.map((candidate) => writtenName(candidate.index)));\n\treturn {\n\t\tcode: \"PN_INDEX_DUPLICATE\",\n\t\tmessage: `Indexes ${names} on table \"${tableName}\" are identical: ${IDENTICAL_DESCRIPTION} Remove one of them.`,\n\t\titem: `table \"${tableName}\": indexes ${names}`,\n\t\tsummary: `tables have named indexes that are identical: ${IDENTICAL_DESCRIPTION} Remove one of each.`\n\t};\n}\nfunction describeReplacement(replacement) {\n\tswitch (replacement.kind) {\n\t\tcase \"primaryKey\": return \"the primary key\";\n\t\tcase \"uniqueConstraint\": return replacement.unique.name === void 0 ? `the unique constraint on (${replacement.unique.columns.join(\", \")})` : `the unique constraint \"${replacement.unique.name}\"`;\n\t\tcase \"index\": return `the unique index \"${writtenName(replacement.index.index)}\"`;\n\t}\n}\nfunction redundantIndexWarning(tableName, candidate, servedBy) {\n\tconst name = writtenName(candidate.index);\n\treturn {\n\t\tcode: \"PN_INDEX_REDUNDANT\",\n\t\tmessage: `Index \"${name}\" on table \"${tableName}\" has the same columns as ${describeReplacement(servedBy)}, ${REDUNDANT_DESCRIPTION} The contract keeps the index because it is named. Remove it.`,\n\t\titem: `table \"${tableName}\": index \"${name}\"`,\n\t\tsummary: `tables have a named index with the same columns as a unique constraint, unique index or primary key, ${REDUNDANT_DESCRIPTION} The contract keeps each index because it is named. Remove them.`\n\t};\n}\n//#endregion\n//#region src/foreign-key-materialization.ts\n/** The `meta.reason` of the refusal of a relation's `index: \"<name>\"`, which a source can report at the relation. */\nconst FOREIGN_KEY_INDEX_UNRESOLVED = \"foreign-key-index-unresolved\";\n/**\n* Lowers a table's authored foreign keys and indexes into the entities `contract.json` persists. A `constraint: false` foreign key contributes no `foreignKeys[]` entry. A foreign key with `index: true` gets a derived backing index; one with `index: \"<name>\"` uses what the table declares under that name. The table's indexes then pass through {@link deduplicateIndexes}, and each foreign key states what backs it in the result: an index by name, or the primary key or a unique constraint by kind.\n*/\nfunction materializeForeignKeysAndIndexes(input) {\n\tconst { tableName, declaredIndexes, uniques, primaryKey } = input;\n\tconst derivedIndexes = [];\n\tconst intents = input.foreignKeys.map((foreignKey) => {\n\t\tconst { constraint, index, ...reference } = foreignKey;\n\t\tif (index !== true) return {\n\t\t\tconstraint,\n\t\t\treference,\n\t\t\tindex\n\t\t};\n\t\tconst derived = derivedBackingIndex(tableName, reference.source.columns);\n\t\tderivedIndexes.push(derived);\n\t\treturn {\n\t\t\tconstraint,\n\t\t\treference,\n\t\t\tindex: derived\n\t\t};\n\t});\n\tconst deduplicated = deduplicateIndexes({\n\t\ttableName,\n\t\tindexes: [...declaredIndexes, ...derivedIndexes],\n\t\tuniques,\n\t\tprimaryKey,\n\t\twarnings: input.warnings\n\t});\n\tconst resolve = (backing) => foreignKeyIndexOf(resolveReplacement(backing, deduplicated.replacements));\n\treturn {\n\t\tforeignKeys: intents.flatMap(({ constraint, reference, index }) => {\n\t\t\tconst backing = index === false ? void 0 : typeof index === \"string\" ? namedBackingObject(reference.source, index, {\n\t\t\t\tdeclaredIndexes,\n\t\t\t\tuniques,\n\t\t\t\tprimaryKey,\n\t\t\t\tresolve\n\t\t\t}) : resolve({\n\t\t\t\tkind: \"index\",\n\t\t\t\tindex\n\t\t\t});\n\t\t\tif (!constraint) return [];\n\t\t\treturn [backing === void 0 ? reference : {\n\t\t\t\t...reference,\n\t\t\t\tindex: backing\n\t\t\t}];\n\t\t}),\n\t\tindexes: deduplicated.indexes.map((candidate) => candidate.index)\n\t};\n}\n/**\n* Whether a table's declared indexes, unique constraints or primary key already serve a foreign key on `columns`, so the build would drop a derived backing index again. A source that writes no backing index of its own, such as a Prisma 7 schema, leaves the foreign key's `index` to the build where this holds, so the stored foreign key states what backs it.\n*/\nfunction declaredIndexesServeForeignKey(columns, table) {\n\treturn derivedBackingIndexIsRedundant(columns, {\n\t\tindexes: table.indexes,\n\t\tnodeOf: indexNodeOf,\n\t\tuniques: table.uniques,\n\t\tprimaryKey: table.primaryKey\n\t});\n}\n/**\n* The name to give a relation's `index` argument when the table's declared indexes and keys serve a foreign key on `columns` although the build would keep a derived backing index beside them (see {@link leadingBackingObjectName}).\n*/\nfunction declaredBackingObjectName(columns, table) {\n\treturn leadingBackingObjectName(columns, {\n\t\tindexes: table.indexes,\n\t\tnodeOf: indexNodeOf,\n\t\tnameOf: (index) => nameOf(index.naming),\n\t\tuniques: table.uniques,\n\t\tprimaryKey: table.primaryKey\n\t});\n}\n/**\n* What a foreign key on `columns` states it is backed by when its relation says nothing, beside a table whose indexes all carry the `name` or `map` the source gave them, as a printed contract's do. A printer writes a relation's `index` argument only where the stored foreign key differs from this.\n*/\nfunction defaultForeignKeyIndex(tableName, columns, table) {\n\tconst reference = {\n\t\tnamespaceId: asNamespaceId(UNBOUND_NAMESPACE_ID),\n\t\ttableName,\n\t\tcolumns\n\t};\n\tconst [foreignKey] = materializeForeignKeysAndIndexes({\n\t\ttableName,\n\t\tforeignKeys: [{\n\t\t\tsource: reference,\n\t\t\ttarget: reference,\n\t\t\tconstraint: true,\n\t\t\tindex: true\n\t\t}],\n\t\tdeclaredIndexes: table.indexes.map((index) => ({\n\t\t\tindex,\n\t\t\tnamedByUser: true\n\t\t})),\n\t\tuniques: table.uniques,\n\t\tprimaryKey: table.primaryKey,\n\t\twarnings: []\n\t}).foreignKeys;\n\treturn typeof foreignKey?.index === \"object\" ? foreignKey.index : void 0;\n}\nfunction derivedBackingIndex(tableName, columns) {\n\treturn {\n\t\tindex: lowerAuthoredIndex(tableName, {\n\t\t\tcolumns,\n\t\t\twhere: void 0,\n\t\t\tunique: void 0,\n\t\t\tmap: void 0,\n\t\t\tname: truncateToWireNamePrefixBytes(defaultIndexName(tableName, columns)),\n\t\t\ttype: void 0,\n\t\t\toptions: void 0\n\t\t}),\n\t\tnamedByUser: false\n\t};\n}\n/**\n* What a relation's `index: \"<name>\"` points at. The name is the `name` or `map` the source gave an index, unique constraint or primary key, or an index's stored name; an unnamed index's default name does not count. Identical indexes count as one, so the name is resolved after they merge. The object must start with the foreign key's columns, in order, or it would not serve the foreign key's lookups.\n*/\nfunction namedBackingObject(source, name, table) {\n\tconst { namespaceId, tableName, columns } = source;\n\tconst subject = `The foreign key on table \"${tableName}\" columns (${columns.join(\", \")}) names \"${name}\" as its index`;\n\tconst meta = {\n\t\treason: FOREIGN_KEY_INDEX_UNRESOLVED,\n\t\tnamespaceId,\n\t\ttableName,\n\t\tcolumns,\n\t\tindex: name\n\t};\n\tconst indexes = table.declaredIndexes.filter((candidate) => candidate.namedByUser && writtenName(candidate.index) === name || nameOf(candidate.index.naming) === name);\n\tconst keys = [...table.uniques.filter((unique) => unique.name === name), ...table.primaryKey?.name === name ? [table.primaryKey] : []];\n\tconst resolvedIndexes = [...new Map(indexes.map((index) => {\n\t\tconst resolved = table.resolve({\n\t\t\tkind: \"index\",\n\t\t\tindex\n\t\t});\n\t\treturn [JSON.stringify(resolved), {\n\t\t\tindex,\n\t\t\tresolved\n\t\t}];\n\t})).values()];\n\tconst matches = resolvedIndexes.length + keys.length;\n\tif (matches === 0) throw contractError(\"CONTRACT.ARGUMENT_INVALID\", `${subject}, but table \"${tableName}\" has no index, unique constraint or primary key with that name.`, {\n\t\tfix: `Declare an index, unique constraint or primary key named \"${name}\" on table \"${tableName}\", or drop the index argument so the foreign key gets its own backing index.`,\n\t\tmeta\n\t});\n\tif (matches > 1) throw contractError(\"CONTRACT.ARGUMENT_INVALID\", `${subject}, but table \"${tableName}\" has more than one index, unique constraint or primary key with that name.`, {\n\t\tfix: `Give the object the foreign key should use a name no other index, unique constraint or primary key of table \"${tableName}\" has, and name that on the relation.`,\n\t\tmeta\n\t});\n\tconst [match] = resolvedIndexes;\n\tconst key = keys[0];\n\tconst objectColumns = match !== void 0 ? match.index.index.columns : key?.columns;\n\tif (objectColumns === void 0 || !startsWithColumns(objectColumns, columns)) throw contractError(\"CONTRACT.ARGUMENT_INVALID\", `${subject}, but ${objectColumns === void 0 ? \"it indexes an expression, not the foreign key's columns\" : `its columns (${objectColumns.join(\", \")}) do not start with the foreign key's columns`}, so it does not serve the foreign key's lookups.`, {\n\t\tfix: `Name an index, unique constraint or primary key whose first columns are (${columns.join(\", \")}), or drop the index argument so the foreign key gets its own backing index.`,\n\t\tmeta\n\t});\n\tif (match !== void 0) return match.resolved;\n\treturn key === table.primaryKey ? { primaryKey: true } : { unique: objectColumns };\n}\nfunction resolveReplacement(backing, replacements) {\n\tlet current = backing;\n\twhile (current.kind === \"index\") {\n\t\tconst replacement = replacements.get(current.index);\n\t\tif (replacement === void 0) break;\n\t\tcurrent = replacement;\n\t}\n\treturn current;\n}\nfunction foreignKeyIndexOf(backing) {\n\tswitch (backing.kind) {\n\t\tcase \"index\": return { name: nameOf(backing.index.index.naming) };\n\t\tcase \"uniqueConstraint\": return { unique: backing.unique.columns };\n\t\tcase \"primaryKey\": return { primaryKey: true };\n\t}\n}\n//#endregion\nexport { FOREIGN_KEY_INDEX_UNRESOLVED, declaredBackingObjectName, declaredIndexesServeForeignKey, defaultForeignKeyIndex, derivedBackingIndexIsRedundant, leadingBackingObjectName, materializeForeignKeysAndIndexes };\n\n//# sourceMappingURL=foreign-key-materialization.mjs.map"],"mappings":";;;;;;;;AAQA,MAAM,wBAAwB;AAC9B,MAAM,wBAAwB;;;;AAI9B,SAAS,mBAAmB,OAAO;CAClC,MAAM,EAAE,WAAW,aAAa;CAChC,MAAM,+BAA+B,IAAI,IAAI;CAC7C,MAAM,QAAQ,IAAI,IAAI,MAAM,QAAQ,KAAK,cAAc,CAAC,WAAW,YAAY,UAAU,KAAK,CAAC,CAAC,CAAC;CACjG,MAAM,UAAU,cAAc;EAC7B,MAAM,OAAO,MAAM,IAA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a,IAAI,QAAQ,KAAK;EAClD,IAAI,gBAAgB,KAAK,GAAG;EAC5B,UAAU;CACX;CACA,OAAO;AACR;AACA,SAAS,kBAAkB,SAAS;CACnC,QAAQ,QAAQ,MAAhB;EACC,KAAK,SAAS,OAAO,EAAE,MAAM,OAAO,QAAQ,MAAM,MAAM,MAAM,EAAE;EAChE,KAAK,oBAAoB,OAAO,EAAE,QAAQ,QAAQ,OAAO,QAAQ;EACjE,KAAK,cAAc,OAAO,EAAE,YAAY,KAAK;CAC9C;AACD"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { a as ForeignKeyReferenceInput, n as ForeignKeyIndex, o as ReferentialAction, r as ForeignKeyInput } from "./foreign-key-qkDFfG8t-Fyrzd0VI.mjs";
|
|
2
|
+
import { i as UniqueConstraintInput, n as PrimaryKeyInput } from "./unique-constraint-M5TlQnJQ-BiIHJ85k.mjs";
|
|
3
|
+
import { r as IndexInput } from "./sql-index-ByAAE7K8-DPkZtr7t.mjs";
|
|
4
|
+
import { m as SqlIndexIR } from "./types-CLsPsUiw-Db1BsN9R.mjs";
|
|
5
|
+
import "./types-D6XuABFQ.mjs";
|
|
6
|
+
import { AuthoringWarningSink } from "@prisma/orm-framework/components/authoring";
|
|
7
|
+
//#region ../../../2-sql/1-core/contract/dist/foreign-key-materialization.d.mts
|
|
8
|
+
//#region src/index-equivalence.d.ts
|
|
9
|
+
type Keyed = {
|
|
10
|
+
readonly columns: readonly string[];
|
|
11
|
+
};
|
|
12
|
+
interface KeyedTable<TIndex, TUnique extends Keyed, TPrimaryKey extends Keyed> {
|
|
13
|
+
readonly indexes: readonly TIndex[];
|
|
14
|
+
readonly nodeOf: (index: TIndex) => SqlIndexIR;
|
|
15
|
+
readonly uniques: readonly TUnique[];
|
|
16
|
+
readonly primaryKey: TPrimaryKey | undefined;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Whether the contract build would drop the backing index it derives for a foreign key on `columns`, because the table already has an identical index or a key serving its lookups. `contract infer` asks this of a live table to decide whether a relation needs `index: false`.
|
|
20
|
+
*/
|
|
21
|
+
declare function derivedBackingIndexIsRedundant<TIndex, TUnique extends Keyed, TPrimaryKey extends Keyed>(columns: readonly string[], table: KeyedTable<TIndex, TUnique, TPrimaryKey>): boolean;
|
|
22
|
+
type NamedKey = Keyed & {
|
|
23
|
+
readonly name?: string | undefined;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* The name of an object of the table that serves lookups on `columns` although the build would keep a derived backing index beside it: a named primary key or unique constraint, or a plain index, whose first columns are `columns`. A source that derives no backing index of its own names it on the relation instead of writing `index: false`.
|
|
27
|
+
*/
|
|
28
|
+
declare function leadingBackingObjectName<TIndex, TUnique extends NamedKey, TPrimaryKey extends NamedKey>(columns: readonly string[], table: KeyedTable<TIndex, TUnique, TPrimaryKey> & {
|
|
29
|
+
readonly nameOf: (index: TIndex) => string;
|
|
30
|
+
}): string | undefined;
|
|
31
|
+
//#endregion
|
|
32
|
+
//#region src/index-deduplication.d.ts
|
|
33
|
+
/** An index of a table as the contract source gives it, before duplicates are removed. */
|
|
34
|
+
interface IndexCandidate {
|
|
35
|
+
readonly index: IndexInput;
|
|
36
|
+
/** The source gave the index a `name` or `map`. A derived backing index, and an index without either, are not named by the user. */
|
|
37
|
+
readonly namedByUser: boolean;
|
|
38
|
+
}
|
|
39
|
+
//#endregion
|
|
40
|
+
//#region src/foreign-key-materialization.d.ts
|
|
41
|
+
/** The `meta.reason` of the refusal of a relation's `index: "<name>"`, which a source can report at the relation. */
|
|
42
|
+
declare const FOREIGN_KEY_INDEX_UNRESOLVED = "foreign-key-index-unresolved";
|
|
43
|
+
/**
|
|
44
|
+
* A foreign key as authored: the referential coordinates plus the `constraint` and `index` intent. `index` is `true` for a derived backing index, `false` for none, or the name of an index, unique constraint or primary key the source declares on the same table.
|
|
45
|
+
*/
|
|
46
|
+
interface ForeignKeyAuthoringInput {
|
|
47
|
+
readonly source: ForeignKeyReferenceInput;
|
|
48
|
+
readonly target: ForeignKeyReferenceInput;
|
|
49
|
+
readonly name?: string;
|
|
50
|
+
readonly onDelete?: ReferentialAction;
|
|
51
|
+
readonly onUpdate?: ReferentialAction;
|
|
52
|
+
readonly constraint: boolean;
|
|
53
|
+
readonly index: boolean | string;
|
|
54
|
+
}
|
|
55
|
+
interface MaterializedTableConstraints {
|
|
56
|
+
readonly foreignKeys: readonly ForeignKeyInput[];
|
|
57
|
+
readonly indexes: readonly IndexInput[];
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Lowers a table's authored foreign keys and indexes into the entities `contract.json` persists. A `constraint: false` foreign key contributes no `foreignKeys[]` entry. A foreign key with `index: true` gets a derived backing index; one with `index: "<name>"` uses what the table declares under that name. The table's indexes then pass through {@link deduplicateIndexes}, and each foreign key states what backs it in the result: an index by name, or the primary key or a unique constraint by kind.
|
|
61
|
+
*/
|
|
62
|
+
declare function materializeForeignKeysAndIndexes(input: {
|
|
63
|
+
readonly tableName: string;
|
|
64
|
+
readonly foreignKeys: readonly ForeignKeyAuthoringInput[];
|
|
65
|
+
readonly declaredIndexes: readonly IndexCandidate[];
|
|
66
|
+
readonly uniques: readonly UniqueConstraintInput[];
|
|
67
|
+
readonly primaryKey: PrimaryKeyInput | undefined;
|
|
68
|
+
readonly warnings: AuthoringWarningSink;
|
|
69
|
+
}): MaterializedTableConstraints;
|
|
70
|
+
/**
|
|
71
|
+
* Whether a table's declared indexes, unique constraints or primary key already serve a foreign key on `columns`, so the build would drop a derived backing index again. A source that writes no backing index of its own, such as a Prisma 7 schema, leaves the foreign key's `index` to the build where this holds, so the stored foreign key states what backs it.
|
|
72
|
+
*/
|
|
73
|
+
declare function declaredIndexesServeForeignKey(columns: readonly string[], table: {
|
|
74
|
+
readonly indexes: readonly IndexInput[];
|
|
75
|
+
readonly uniques: readonly UniqueConstraintInput[];
|
|
76
|
+
readonly primaryKey: PrimaryKeyInput | undefined;
|
|
77
|
+
}): boolean;
|
|
78
|
+
/**
|
|
79
|
+
* The name to give a relation's `index` argument when the table's declared indexes and keys serve a foreign key on `columns` although the build would keep a derived backing index beside them (see {@link leadingBackingObjectName}).
|
|
80
|
+
*/
|
|
81
|
+
declare function declaredBackingObjectName(columns: readonly string[], table: {
|
|
82
|
+
readonly indexes: readonly IndexInput[];
|
|
83
|
+
readonly uniques: readonly UniqueConstraintInput[];
|
|
84
|
+
readonly primaryKey: PrimaryKeyInput | undefined;
|
|
85
|
+
}): string | undefined;
|
|
86
|
+
/**
|
|
87
|
+
* What a foreign key on `columns` states it is backed by when its relation says nothing, beside a table whose indexes all carry the `name` or `map` the source gave them, as a printed contract's do. A printer writes a relation's `index` argument only where the stored foreign key differs from this.
|
|
88
|
+
*/
|
|
89
|
+
declare function defaultForeignKeyIndex(tableName: string, columns: readonly string[], table: {
|
|
90
|
+
readonly indexes: readonly IndexInput[];
|
|
91
|
+
readonly uniques: readonly UniqueConstraintInput[];
|
|
92
|
+
readonly primaryKey: PrimaryKeyInput | undefined;
|
|
93
|
+
}): ForeignKeyIndex | undefined;
|
|
94
|
+
//#endregion
|
|
95
|
+
export { declaredBackingObjectName as a, derivedBackingIndexIsRedundant as c, MaterializedTableConstraints as i, leadingBackingObjectName as l, ForeignKeyAuthoringInput as n, declaredIndexesServeForeignKey as o, IndexCandidate as r, defaultForeignKeyIndex as s, FOREIGN_KEY_INDEX_UNRESOLVED as t, materializeForeignKeysAndIndexes as u };
|
|
96
|
+
//# sourceMappingURL=foreign-key-materialization-D0Ltg78T.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"foreign-key-materialization-D0Ltg78T.d.mts","names":[],"sources":["../../../../2-sql/1-core/contract/dist/foreign-key-materialization.d.mts"],"mappings":";;;;;;;;KAMK;WACM;;UAED,WAAW,QAAQ,gBAAgB,OAAO,oBAAoB;WAC7D,kBAAkB;WAClB,SAAS,OAAO,WAAW;WAC3B,kBAAkB;WAClB,YAAY;;;;;iBAKN,+BAA+B,QAAQ,gBAAgB,OAAO,oBAAoB,OAAO,4BAA4B,OAAO,WAAW,QAAQ,SAAS;KACpK,WAAW;WACL;;;;;iBAKM,yBAAyB,QAAQ,gBAAgB,UAAU,oBAAoB,UAAU,4BAA4B,OAAO,WAAW,QAAQ,SAAS;WAC9J,SAAS,OAAO;;;;;UAKjB;WACC,OAAO;;WAEP;;;;;cAKG;;;;UAIJ;WACC,QAAQ;WACR,QAAQ;WACR;WACA,WAAW;WACX,WAAW;WACX;WACA;;UAED;WACC,sBAAsB;WACtB,kBAAkB;;;;;iBAKZ,iCAAiC;WACvC;WACA,sBAAsB;WACtB,0BAA0B;WAC1B,kBAAkB;WAClB,YAAY;WACZ,UAAU;IACjB;;;;iBAIa,+BAA+B,4BAA4B;WACjE,kBAAkB;WAClB,kBAAkB;WAClB,YAAY;;;;;iBAKN,0BAA0B,4BAA4B;WAC5D,kBAAkB;WAClB,kBAAkB;WAClB,YAAY;;;;;iBAKN,uBAAuB,mBAAmB,4BAA4B;WAC5E,kBAAkB;WAClB,kBAAkB;WAClB,YAAY;IACnB"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as SqlNode } from "./sql-node-kEz6YFZo-v2F7delx.mjs";
|
|
2
2
|
import { NamespaceId } from "@prisma/orm-framework/contract/types";
|
|
3
|
-
//#region ../../../2-sql/1-core/contract/dist/foreign-key-
|
|
3
|
+
//#region ../../../2-sql/1-core/contract/dist/foreign-key-qkDFfG8t.d.mts
|
|
4
4
|
//#region src/ir/foreign-key-reference.d.ts
|
|
5
5
|
/**
|
|
6
6
|
* Input for a foreign-key reference (one side of a foreign-key declaration).
|
|
@@ -46,12 +46,26 @@ declare class ForeignKeyReference extends SqlNode {
|
|
|
46
46
|
//#endregion
|
|
47
47
|
//#region src/ir/foreign-key.d.ts
|
|
48
48
|
type ReferentialAction = 'noAction' | 'restrict' | 'cascade' | 'setNull' | 'setDefault';
|
|
49
|
+
/**
|
|
50
|
+
* What serves a foreign key's lookups on its own table, each in the way the contract identifies it: an index by its stored name, the primary key by kind, a unique constraint by its columns. The first columns of each are the foreign key's columns.
|
|
51
|
+
*/
|
|
52
|
+
type ForeignKeyIndex = {
|
|
53
|
+
readonly name: string;
|
|
54
|
+
} | {
|
|
55
|
+
readonly primaryKey: true;
|
|
56
|
+
} | {
|
|
57
|
+
readonly unique: readonly string[];
|
|
58
|
+
};
|
|
49
59
|
interface ForeignKeyInput {
|
|
50
60
|
readonly source: ForeignKeyReference | ForeignKeyReferenceInput;
|
|
51
61
|
readonly target: ForeignKeyReference | ForeignKeyReferenceInput;
|
|
52
62
|
readonly name?: string;
|
|
53
63
|
readonly onDelete?: ReferentialAction;
|
|
54
64
|
readonly onUpdate?: ReferentialAction;
|
|
65
|
+
/**
|
|
66
|
+
* A `contract.json` emitted before 0.16 stores `true` or `false` here, the superseded per-foreign-key flag; it says nothing about the table's indexes and reads as absent.
|
|
67
|
+
*/
|
|
68
|
+
readonly index?: ForeignKeyIndex | boolean;
|
|
55
69
|
}
|
|
56
70
|
/**
|
|
57
71
|
* SQL Contract IR node for a table-level foreign-key declaration — the
|
|
@@ -62,7 +76,8 @@ interface ForeignKeyInput {
|
|
|
62
76
|
* authoring-time decisions (PSL `@relation(index:)`, TS `fk({ constraint,
|
|
63
77
|
* index })`) resolved once at `contract emit` — a `constraint: false` FK
|
|
64
78
|
* simply has no entry here, and a backing index (if any) is its own discrete,
|
|
65
|
-
* named entry in the table's `indexes[]`.
|
|
79
|
+
* named entry in the table's `indexes[]`. `index` says what serves the
|
|
80
|
+
* foreign key's lookups; it is absent when nothing backs the foreign key.
|
|
66
81
|
*
|
|
67
82
|
* Each FK carries explicit `source` and `target` {@link ForeignKeyReference}
|
|
68
83
|
* coordinates (namespace, table, columns). For single-namespace contracts the
|
|
@@ -79,9 +94,10 @@ declare class ForeignKey extends SqlNode {
|
|
|
79
94
|
readonly name?: string;
|
|
80
95
|
readonly onDelete?: ReferentialAction;
|
|
81
96
|
readonly onUpdate?: ReferentialAction;
|
|
97
|
+
readonly index?: ForeignKeyIndex;
|
|
82
98
|
constructor(input: ForeignKeyInput);
|
|
83
99
|
static from(value: ForeignKey | ForeignKeyInput): ForeignKey;
|
|
84
100
|
}
|
|
85
101
|
//#endregion
|
|
86
|
-
export {
|
|
87
|
-
//# sourceMappingURL=foreign-key-
|
|
102
|
+
export { ForeignKeyReferenceInput as a, ForeignKeyReference as i, ForeignKeyIndex as n, ReferentialAction as o, ForeignKeyInput as r, ForeignKey as t };
|
|
103
|
+
//# sourceMappingURL=foreign-key-qkDFfG8t-Fyrzd0VI.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"foreign-key-qkDFfG8t-Fyrzd0VI.d.mts","names":[],"sources":["../../../../2-sql/1-core/contract/dist/foreign-key-qkDFfG8t.d.mts"],"mappings":";;;;;;;;;;;;;;;UAcU;WACC;WACA;WACA;WACA;;;;;;;;;;;;;;;;;;cAkBG,4BAA4B;WAC/B,aAAa;WACb;WACA;WACA;EACT,YAAY,OAAO;SACZ,KAAK,OAAO,sBAAsB,2BAA2B;;;;KAIjE;;;;KAIA;WACM;;WAEA;;WAEA;;UAED;WACC,QAAQ,sBAAsB;WAC9B,QAAQ,sBAAsB;WAC9B;WACA,WAAW;WACX,WAAW;;;;WAIX,QAAQ;;;;;;;;;;;;;;;;;;;;;;;cAuBL,mBAAmB;WACtB,QAAQ;WACR,QAAQ;WACR;WACA,WAAW;WACX,WAAW;WACX,QAAQ;EACjB,YAAY,OAAO;SACZ,KAAK,OAAO,aAAa,kBAAkB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { w as QueryOperationTypeEntry } from "./types-
|
|
2
|
-
import "./types-
|
|
1
|
+
import { w as QueryOperationTypeEntry } from "./types-DFZhLz18-C_h0u-Zx.mjs";
|
|
2
|
+
import "./types-BURWzacK.mjs";
|
|
3
3
|
import { OperationDescriptor, OperationDescriptors, OperationRegistry } from "@prisma/orm-framework/operations";
|
|
4
4
|
//#region ../../../2-sql/1-core/operations/dist/index.d.mts
|
|
5
5
|
//#region src/index.d.ts
|
|
@@ -21,4 +21,4 @@ type SqlOperationRegistry = OperationRegistry<SqlOperationEntry>;
|
|
|
21
21
|
declare function createSqlOperationRegistry(): SqlOperationRegistry;
|
|
22
22
|
//#endregion
|
|
23
23
|
export { SqlOperationRegistry as a, SqlOperationEntry as i, SqlOperationDescriptor as n, createSqlOperationRegistry as o, SqlOperationDescriptors as r, SqlLoweringSpec as t };
|
|
24
|
-
//# sourceMappingURL=index-
|
|
24
|
+
//# sourceMappingURL=index-CnpTmyXs.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-
|
|
1
|
+
{"version":3,"file":"index-CnpTmyXs.d.mts","names":[],"sources":["../../../../2-sql/1-core/operations/dist/index.d.mts"],"mappings":";;;;;UAGU;WACC;WACA;;;;;;;;;KASN,oBAAoB;KACpB,yBAAyB,oBAAoB;KAC7C,0BAA0B,qBAAqB;KAC/C,uBAAuB,kBAAkB;iBAC7B,8BAA8B"}
|