@prisma/orm-family-sql 8.0.0-rc.2-dev.3 → 8.0.0-rc.20-dev.1
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/README.md +2 -6
- package/dist/{aggregate-descriptor-registry-C7hel5O7.mjs → aggregate-descriptor-registry-ZrKjxwQe.mjs} +5 -5
- package/dist/aggregate-descriptor-registry-ZrKjxwQe.mjs.map +1 -0
- package/dist/ast-D0miQ1B6.mjs +372 -0
- package/dist/ast-D0miQ1B6.mjs.map +1 -0
- package/dist/ast-YEMe_B8z.d.mts +292 -0
- package/dist/ast-YEMe_B8z.d.mts.map +1 -0
- package/dist/attribute-specs-DA_RwQFB.d.mts +114 -0
- package/dist/attribute-specs-DA_RwQFB.d.mts.map +1 -0
- package/dist/{authored-check-naming-Hf9990DV.mjs → authored-check-naming-BHGJhjqn.mjs} +5 -5
- package/dist/authored-check-naming-BHGJhjqn.mjs.map +1 -0
- package/dist/{authored-check-naming-BWBe-PVE.d.mts → authored-check-naming-D-o196ry.d.mts} +3 -3
- package/dist/authored-check-naming-D-o196ry.d.mts.map +1 -0
- package/dist/authoring-entity-types-CgKIgWq5-pEdfjam5.d.mts +9 -0
- package/dist/authoring-entity-types-CgKIgWq5-pEdfjam5.d.mts.map +1 -0
- package/dist/builder.d.mts +4 -3
- package/dist/builder__runtime.d.mts +29 -31
- package/dist/builder__runtime.d.mts.map +1 -1
- package/dist/builder__runtime.mjs +261 -191
- package/dist/builder__runtime.mjs.map +1 -1
- package/dist/builder__types.d.mts +6 -3
- package/dist/{canonicalization-hooks-dmXkOR4a.mjs → canonicalization-hooks-Ce1v_TDl.mjs} +2 -2
- package/dist/canonicalization-hooks-Ce1v_TDl.mjs.map +1 -0
- package/dist/{canonicalization-hooks-CYnW_sGn.d.mts → canonicalization-hooks-DyapQ0my.d.mts} +2 -2
- package/dist/canonicalization-hooks-DyapQ0my.d.mts.map +1 -0
- package/dist/{check-constraint-B7qGu6rc-HvQjjX82.d.mts → check-constraint-B7qGu6rc-Bk2ezWXu.d.mts} +4 -4
- package/dist/check-constraint-B7qGu6rc-Bk2ezWXu.d.mts.map +1 -0
- package/dist/{codec-descriptor-registry-N0dhtKaH.mjs → codec-descriptor-registry-CiiFzMtb.mjs} +13 -40
- package/dist/codec-descriptor-registry-CiiFzMtb.mjs.map +1 -0
- package/dist/collection-methods-BB8YH69u.d.mts +1 -0
- package/dist/collection-methods-D2UnCS0S-DOy2qHYS.d.mts +77 -0
- package/dist/collection-methods-D2UnCS0S-DOy2qHYS.d.mts.map +1 -0
- package/dist/{config-types-D9fdKG3g.d.mts → config-types-C-1mIiJO.d.mts} +5 -5
- package/dist/config-types-C-1mIiJO.d.mts.map +1 -0
- package/dist/{config-types-gAm54C_v.mjs → config-types-DkEeq_qq.mjs} +10 -6
- package/dist/config-types-DkEeq_qq.mjs.map +1 -0
- package/dist/{contract-builder-D4a5dT7j.mjs → contract-builder-50lF0kz1.mjs} +431 -226
- package/dist/contract-builder-50lF0kz1.mjs.map +1 -0
- package/dist/contract-builder-C_Zi57iD.d.mts +1967 -0
- package/dist/contract-builder-C_Zi57iD.d.mts.map +1 -0
- package/dist/contract-emitter.d.mts +4 -7
- package/dist/contract-emitter.d.mts.map +1 -1
- package/dist/contract-emitter.mjs +1 -1
- package/dist/{contract-errors-BCN6RVI5-5IHBF_lg.mjs → contract-errors-BCN6RVI5-DoH6b_KZ.mjs} +2 -2
- package/dist/contract-errors-BCN6RVI5-DoH6b_KZ.mjs.map +1 -0
- package/dist/contract-prisma7__provider.d.mts +97 -0
- package/dist/contract-prisma7__provider.d.mts.map +1 -0
- package/dist/contract-prisma7__provider.mjs +2011 -0
- package/dist/contract-prisma7__provider.mjs.map +1 -0
- package/dist/contract-psl.d.mts +18 -29
- package/dist/contract-psl.d.mts.map +1 -1
- package/dist/contract-psl.mjs +1 -1
- package/dist/contract-psl__attribute-specs.d.mts +2 -0
- package/dist/contract-psl__attribute-specs.mjs +2 -0
- package/dist/contract-psl__default-table-name.d.mts +7 -0
- package/dist/contract-psl__default-table-name.d.mts.map +1 -0
- package/dist/contract-psl__default-table-name.mjs +2 -0
- package/dist/contract-psl__diagnostics.d.mts +12 -0
- package/dist/contract-psl__diagnostics.d.mts.map +1 -0
- package/dist/contract-psl__diagnostics.mjs +2 -0
- package/dist/contract-psl__map-names.d.mts +16 -0
- package/dist/contract-psl__map-names.d.mts.map +1 -0
- package/dist/contract-psl__map-names.mjs +21 -0
- package/dist/contract-psl__map-names.mjs.map +1 -0
- package/dist/contract-psl__provider.d.mts +3 -3
- package/dist/contract-psl__provider.d.mts.map +1 -1
- package/dist/contract-psl__provider.mjs +95 -46
- package/dist/contract-psl__provider.mjs.map +1 -1
- package/dist/contract-ts.d.mts +5 -5
- package/dist/contract-ts.mjs +5 -4
- 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 +4 -4
- package/dist/contract-ts__contract-builder.mjs +4 -3
- package/dist/{contract-view-BMR5IWk4.mjs → contract-view-DqpzeYeE.mjs} +2 -2
- package/dist/contract-view-DqpzeYeE.mjs.map +1 -0
- package/dist/{contract-view-CPHxoAEX.d.mts → contract-view-DuB35or0.d.mts} +3 -3
- package/dist/contract-view-DuB35or0.d.mts.map +1 -0
- package/dist/contract.d.mts +30 -28
- package/dist/contract.mjs +23 -18
- package/dist/contract__authored-check-naming.d.mts +1 -1
- package/dist/contract__authored-check-naming.mjs +1 -1
- package/dist/contract__canonicalization-hooks.d.mts +1 -1
- package/dist/contract__canonicalization-hooks.mjs +1 -1
- package/dist/contract__contract-view.d.mts +1 -1
- package/dist/contract__contract-view.mjs +1 -1
- package/dist/contract__data-type-support.d.mts +2 -0
- package/dist/contract__data-type-support.mjs +2 -0
- package/dist/contract__data-type.d.mts +2 -0
- package/dist/contract__data-type.mjs +3 -0
- package/dist/contract__entity-handle-lowering-hook.d.mts +2 -2
- package/dist/contract__entity-handle-lowering-hook.mjs +2 -2
- 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-naming.d.mts +2 -2
- package/dist/contract__index-naming.mjs +2 -2
- package/dist/contract__index-type-validation.d.mts +2 -2
- package/dist/contract__index-type-validation.mjs +1 -1
- package/dist/contract__index-types.d.mts +3 -3
- package/dist/contract__index-types.mjs +2 -2
- package/dist/contract__referential-action-sql.d.mts +1 -1
- package/dist/contract__referential-action-sql.mjs +1 -1
- package/dist/contract__resolve-storage-table.d.mts +1 -1
- package/dist/contract__resolve-storage-table.mjs +1 -1
- package/dist/contract__sql-expression.d.mts +2 -0
- package/dist/contract__sql-expression.mjs +2 -0
- package/dist/contract__types.d.mts +12 -12
- package/dist/contract__types.mjs +4 -4
- package/dist/contract__validators.d.mts +2 -2
- package/dist/contract__validators.mjs +3 -3
- package/dist/contract__value-set-derivation-hook.d.mts +1 -1
- package/dist/contract__value-set-derivation-hook.mjs +1 -1
- package/dist/control-BK50zF6c.mjs +2721 -0
- package/dist/control-BK50zF6c.mjs.map +1 -0
- package/dist/control-ChAUdOOu.d.mts +1416 -0
- package/dist/control-ChAUdOOu.d.mts.map +1 -0
- package/dist/{control-adapter-C99J7aEF-B7eQd7vD.d.mts → control-adapter-Bn0uhplA-BzP2uPqJ.d.mts} +27 -44
- package/dist/control-adapter-Bn0uhplA-BzP2uPqJ.d.mts.map +1 -0
- package/dist/control-adapter-NZ2kKc4x.d.mts +13 -0
- package/dist/control-adapter-NZ2kKc4x.d.mts.map +1 -0
- package/dist/control-adapter-SlQkTEwT.mjs +16 -0
- package/dist/control-adapter-SlQkTEwT.mjs.map +1 -0
- package/dist/data-type-BFSpaotu.mjs +52 -0
- package/dist/data-type-BFSpaotu.mjs.map +1 -0
- package/dist/data-type-DJIvKQHf.d.mts +158 -0
- package/dist/data-type-DJIvKQHf.d.mts.map +1 -0
- package/dist/data-type-support-BhSoPUFj.mjs +9 -0
- package/dist/data-type-support-BhSoPUFj.mjs.map +1 -0
- package/dist/data-type-support-CXpA0ex-.d.mts +7 -0
- package/dist/data-type-support-CXpA0ex-.d.mts.map +1 -0
- package/dist/{db-D18PrXKW-DvTv4JFn.d.mts → db-D1d75IvM-D4mRDC6w.d.mts} +123 -128
- package/dist/db-D1d75IvM-D4mRDC6w.d.mts.map +1 -0
- package/dist/{ddl-types-CXx4vPz6-BsgrnSUY.d.mts → ddl-types-By5mT2_S-CdaaFvsX.d.mts} +24 -29
- package/dist/ddl-types-By5mT2_S-CdaaFvsX.d.mts.map +1 -0
- package/dist/default-mapping-CAOONlKQ-4m07nb-O.d.mts +39 -0
- package/dist/default-mapping-CAOONlKQ-4m07nb-O.d.mts.map +1 -0
- package/dist/default-table-name-BfFY8qYR-CWZFDX6v.mjs +9 -0
- package/dist/default-table-name-BfFY8qYR-CWZFDX6v.mjs.map +1 -0
- package/dist/derived-checks-D5HVRvqN-BJx1gwPA.mjs +1508 -0
- package/dist/derived-checks-D5HVRvqN-BJx1gwPA.mjs.map +1 -0
- package/dist/{derived-checks-DPdD01O0-DGqOFjs6.d.mts → derived-checks-DpPkO6Dt-9U9UJZOo.d.mts} +4 -4
- package/dist/derived-checks-DpPkO6Dt-9U9UJZOo.d.mts.map +1 -0
- package/dist/diagnostics-RHJxoiIk.mjs +23 -0
- package/dist/diagnostics-RHJxoiIk.mjs.map +1 -0
- package/dist/{diff-DbTNVm2f.d.mts → diff-1qHOLoUB.d.mts} +23 -10
- package/dist/diff-1qHOLoUB.d.mts.map +1 -0
- package/dist/diff-C1rFOhek.mjs +21 -0
- package/dist/diff-C1rFOhek.mjs.map +1 -0
- package/dist/{dist-ZK6oeI5e.mjs → dist-C8Y-PPuE.mjs} +36 -212
- package/dist/dist-C8Y-PPuE.mjs.map +1 -0
- package/dist/{dist-C_q1_QR9.mjs → dist-CHz1hF8M.mjs} +2 -2
- package/dist/dist-CHz1hF8M.mjs.map +1 -0
- package/dist/{dist-x6jvtkKM.mjs → dist-CMDXybwm.mjs} +2 -2
- package/dist/dist-CMDXybwm.mjs.map +1 -0
- package/dist/{driver-types-BQtRkOJ0-Bv2RPSfr.d.mts → driver-types-DRsYeq3j-BimeCnUk.d.mts} +11 -2
- package/dist/driver-types-DRsYeq3j-BimeCnUk.d.mts.map +1 -0
- package/dist/entity-handle-lowering-hook-BJZSlVVF.mjs +16 -0
- package/dist/entity-handle-lowering-hook-BJZSlVVF.mjs.map +1 -0
- package/dist/{entity-handle-lowering-hook-CIvRKBfa.d.mts → entity-handle-lowering-hook-BuvLtgFi.d.mts} +8 -11
- package/dist/entity-handle-lowering-hook-BuvLtgFi.d.mts.map +1 -0
- package/dist/{entity-kinds-B5cUFU22.d.mts → entity-kinds-BPG2xCZV.d.mts} +7 -7
- package/dist/entity-kinds-BPG2xCZV.d.mts.map +1 -0
- package/dist/{entity-kinds-D7vwoN_T-CCBwFJy0.mjs → entity-kinds-JR5SAm5h-DOH6VUtL.mjs} +31 -28
- package/dist/entity-kinds-JR5SAm5h-DOH6VUtL.mjs.map +1 -0
- package/dist/{errors-B5g0xWro-mWH2C07F.mjs → errors-B5g0xWro-C8plbqga.mjs} +2 -2
- package/dist/errors-B5g0xWro-C8plbqga.mjs.map +1 -0
- package/dist/errors.d.mts +1 -1
- package/dist/errors.d.mts.map +1 -1
- package/dist/errors.mjs +1 -1
- package/dist/exports-C3wGYtID-D65DEUTC.mjs +2389 -0
- package/dist/exports-C3wGYtID-D65DEUTC.mjs.map +1 -0
- package/dist/{expression-FJK6Ar-d.d.mts → expression-6ld_ZQL6-fOuazzzm.d.mts} +37 -16
- package/dist/expression-6ld_ZQL6-fOuazzzm.d.mts.map +1 -0
- package/dist/expression-CieaNuRM-B1uVqxwd.d.mts +22 -0
- package/dist/expression-CieaNuRM-B1uVqxwd.d.mts.map +1 -0
- package/dist/expression-D8HstQiB.d.mts +2 -0
- package/dist/{expression-CX5mTA-z.mjs → expression-impl-B-XNINxr-BhN2sysZ.mjs} +41 -18
- package/dist/expression-impl-B-XNINxr-BhN2sysZ.mjs.map +1 -0
- package/dist/{factories-SVor5xIT.mjs → factories-Crobuxwn.mjs} +27 -20
- package/dist/factories-Crobuxwn.mjs.map +1 -0
- package/dist/{factories-P3qBQhO-.d.mts → factories-DbNP9qfs.d.mts} +16 -10
- package/dist/factories-DbNP9qfs.d.mts.map +1 -0
- package/dist/family.d.mts +17 -13
- package/dist/family.mjs +17 -12
- package/dist/family__control-adapter.d.mts +3 -3
- package/dist/family__control-adapter.mjs +2 -1
- package/dist/family__control.d.mts +5 -4
- package/dist/family__control.mjs +4 -4
- package/dist/family__diff.d.mts +2 -3
- package/dist/family__diff.mjs +2 -2
- package/dist/family__ir.d.mts +1 -1
- package/dist/family__ir.mjs +2 -2
- package/dist/family__migration.d.mts +1 -1
- package/dist/family__migration.mjs +1 -1
- package/dist/family__pack.d.mts +2 -249
- package/dist/family__pack.mjs +3 -18
- package/dist/family__psl-build.d.mts +3 -0
- package/dist/family__psl-build.mjs +3 -0
- package/dist/family__psl-infer.d.mts +2 -2
- package/dist/family__psl-infer.mjs +2 -2
- package/dist/family__runtime.d.mts +2 -2
- package/dist/family__runtime.mjs +2 -2
- package/dist/family__verify.d.mts +1 -1
- package/dist/family__verify.mjs +1 -1
- package/dist/foreign-key-materialization-48P2V8on.d.mts +98 -0
- package/dist/foreign-key-materialization-48P2V8on.d.mts.map +1 -0
- package/dist/foreign-key-materialization-BM59w_Xg.mjs +287 -0
- package/dist/foreign-key-materialization-BM59w_Xg.mjs.map +1 -0
- package/dist/{foreign-key-C-iTPuRT-C9ip8zFx.d.mts → foreign-key-qkDFfG8t-TaK_GYWR.d.mts} +21 -5
- package/dist/foreign-key-qkDFfG8t-TaK_GYWR.d.mts.map +1 -0
- package/dist/functions-CsOoN7I3.mjs +88 -0
- package/dist/functions-CsOoN7I3.mjs.map +1 -0
- package/dist/functions-EW-RrRn3.d.mts +73 -0
- package/dist/functions-EW-RrRn3.d.mts.map +1 -0
- package/dist/generator-functions-D_qdqBV--Bq296cED.mjs +544 -0
- package/dist/generator-functions-D_qdqBV--Bq296cED.mjs.map +1 -0
- package/dist/index-7nHHQsAj.d.mts +606 -0
- package/dist/index-7nHHQsAj.d.mts.map +1 -0
- package/dist/{index-C5I8D-MB.d.mts → index-Nqc3OHR_.d.mts} +4 -5
- package/dist/index-Nqc3OHR_.d.mts.map +1 -0
- package/dist/index-equivalence-DswCiq5l-CGsyPP9B.mjs +109 -0
- package/dist/index-equivalence-DswCiq5l-CGsyPP9B.mjs.map +1 -0
- package/dist/{index-naming-DREt6js7-CRH27yUv.mjs → index-naming-BOcJT1B3-mG8Fd6KN.mjs} +35 -9
- package/dist/index-naming-BOcJT1B3-mG8Fd6KN.mjs.map +1 -0
- package/dist/{index-naming-Ct65z5Xk.d.mts → index-naming-Cs6wwia3.d.mts} +15 -5
- package/dist/index-naming-Cs6wwia3.d.mts.map +1 -0
- package/dist/index-reference-4wsdeB7v-DCwswK-q.d.mts +67 -0
- package/dist/index-reference-4wsdeB7v-DCwswK-q.d.mts.map +1 -0
- package/dist/index-reference-BQSrkRfT.mjs +55 -0
- package/dist/index-reference-BQSrkRfT.mjs.map +1 -0
- package/dist/index-reference-D8ewQRJr.d.mts +1 -0
- package/dist/index-type-validation-DJEMmmw0.mjs +42 -0
- package/dist/index-type-validation-DJEMmmw0.mjs.map +1 -0
- package/dist/index-type-validation-fGGwAHWc.d.mts +16 -0
- package/dist/index-type-validation-fGGwAHWc.d.mts.map +1 -0
- package/dist/index-types-H1O43iYT-BD0VwPqV.d.mts +66 -0
- package/dist/index-types-H1O43iYT-BD0VwPqV.d.mts.map +1 -0
- package/dist/index-types-pC_5vADQ-BOOBi14R.mjs +95 -0
- package/dist/index-types-pC_5vADQ-BOOBi14R.mjs.map +1 -0
- package/dist/index-types-snhtt_Fo.d.mts +1 -0
- package/dist/interpreter-D5qk4B---CG0C7kdx.mjs +2280 -0
- package/dist/interpreter-D5qk4B---CG0C7kdx.mjs.map +1 -0
- package/dist/{ir-Bghjt-FG.d.mts → ir-BvptQsFW.d.mts} +11 -5
- package/dist/ir-BvptQsFW.d.mts.map +1 -0
- package/dist/{ir-I-xciGUH.mjs → ir-DzsUDO8e.mjs} +2 -2
- package/dist/ir-DzsUDO8e.mjs.map +1 -0
- package/dist/{middleware-AhTz1BOW-th-Suxuf.d.mts → middleware-DHkW6pRr-DM6hd9iZ.d.mts} +5 -5
- package/dist/middleware-DHkW6pRr-DM6hd9iZ.d.mts.map +1 -0
- package/dist/middleware-gqy3l13N.d.mts +1 -0
- package/dist/{middleware-CMr4CHNz-DHIUdxlm.mjs → middleware-yBAfiVWn-DZO0vCRQ.mjs} +3 -3
- package/dist/middleware-yBAfiVWn-DZO0vCRQ.mjs.map +1 -0
- package/dist/{migration-CK4oePIo.mjs → migration-BJQjkqFz.mjs} +4 -4
- package/dist/migration-BJQjkqFz.mjs.map +1 -0
- package/dist/{migration-CjDRZNep.d.mts → migration-Cxmpzaz0.d.mts} +6 -6
- package/dist/migration-Cxmpzaz0.d.mts.map +1 -0
- package/dist/{naming-CV9j2pXl-KARaDReS.d.mts → naming-BcD36g9T-Mfe_xGGL.d.mts} +9 -14
- package/dist/naming-BcD36g9T-Mfe_xGGL.d.mts.map +1 -0
- package/dist/{naming-DKr4TJd7-Cszhq9RV.mjs → naming-bM5qm5PY-jOg3JFMb.mjs} +20 -31
- package/dist/naming-bM5qm5PY-jOg3JFMb.mjs.map +1 -0
- package/dist/{ddl-types-BGdnAbXo-DKPHPUGx.mjs → opaque-sql-Dset3kln-CtsPDTXn.mjs} +24 -11
- package/dist/opaque-sql-Dset3kln-CtsPDTXn.mjs.map +1 -0
- package/dist/operations.d.mts +1 -1
- package/dist/operations.mjs +1 -1
- package/dist/orm-client.d.mts +817 -267
- package/dist/orm-client.d.mts.map +1 -1
- package/dist/orm-client.mjs +4719 -2942
- package/dist/orm-client.mjs.map +1 -1
- package/dist/pack-DA8HZ2mo.d.mts +535 -0
- package/dist/pack-DA8HZ2mo.d.mts.map +1 -0
- package/dist/pack-gSvGQWqs.mjs +80 -0
- package/dist/pack-gSvGQWqs.mjs.map +1 -0
- package/dist/{plan-CDxduYaN-pLIyyJaB.d.mts → plan-Cr4azjnG-CuL8FqXC.d.mts} +12 -8
- package/dist/plan-Cr4azjnG-CuL8FqXC.d.mts.map +1 -0
- package/dist/{plan-Dh0LbYIv-Crx5-ThG.mjs → plan-Dh0LbYIv-ubBSdUgl.mjs} +2 -2
- package/dist/plan-Dh0LbYIv-ubBSdUgl.mjs.map +1 -0
- package/dist/plan-Di6Gs2JD.d.mts +2 -0
- package/dist/psl-attribute-parsing-BCsFWsSp-BJ-wGlY6.mjs +42 -0
- package/dist/psl-attribute-parsing-BCsFWsSp-BJ-wGlY6.mjs.map +1 -0
- package/dist/psl-build-DFBG6vhz.mjs +426 -0
- package/dist/psl-build-DFBG6vhz.mjs.map +1 -0
- package/dist/psl-build-RelubU2E.d.mts +112 -0
- package/dist/psl-build-RelubU2E.d.mts.map +1 -0
- package/dist/psl-column-resolution-ChZqioOc-BREg4J7d.d.mts +24 -0
- package/dist/psl-column-resolution-ChZqioOc-BREg4J7d.d.mts.map +1 -0
- package/dist/psl-field-resolution-C5KQ7kzP-B0NwuRWV.mjs +1960 -0
- package/dist/psl-field-resolution-C5KQ7kzP-B0NwuRWV.mjs.map +1 -0
- package/dist/psl-infer--g4i84Go.mjs +201 -0
- package/dist/psl-infer--g4i84Go.mjs.map +1 -0
- package/dist/psl-infer-DzoxPZGd.d.mts +80 -0
- package/dist/psl-infer-DzoxPZGd.d.mts.map +1 -0
- package/dist/psl-names-C3cwe0rg-D1CTmC3a.mjs +66 -0
- package/dist/psl-names-C3cwe0rg-D1CTmC3a.mjs.map +1 -0
- package/dist/{query-lane-context-Qa-eddrE-kuZ8Z86-.d.mts → query-lane-context-BCEoKy0_-CzmyavC9.d.mts} +20 -49
- package/dist/query-lane-context-BCEoKy0_-CzmyavC9.d.mts.map +1 -0
- package/dist/query-lane-context-VqH0mS9B.d.mts +1 -0
- package/dist/{referential-action-sql-DJ9ps6-S.d.mts → referential-action-sql-B2vKoUK6.d.mts} +3 -3
- package/dist/referential-action-sql-B2vKoUK6.d.mts.map +1 -0
- package/dist/{referential-action-sql-DSqkrySN.mjs → referential-action-sql-BLzCtTi8.mjs} +2 -2
- package/dist/referential-action-sql-BLzCtTi8.mjs.map +1 -0
- package/dist/relational-core.d.mts +14 -13
- package/dist/relational-core.mjs +8 -8
- package/dist/relational-core__aggregate-descriptor-registry.d.mts +2 -2
- package/dist/relational-core__aggregate-descriptor-registry.d.mts.map +1 -1
- package/dist/relational-core__aggregate-descriptor-registry.mjs +1 -1
- package/dist/relational-core__ast.d.mts +5 -5
- package/dist/relational-core__ast.mjs +5 -5
- package/dist/relational-core__codec-descriptor-registry.d.mts +7 -8
- package/dist/relational-core__codec-descriptor-registry.d.mts.map +1 -1
- package/dist/relational-core__codec-descriptor-registry.mjs +1 -1
- package/dist/relational-core__collection-methods.d.mts +3 -0
- package/dist/relational-core__contract-free.d.mts +18 -8
- package/dist/relational-core__contract-free.d.mts.map +1 -1
- package/dist/relational-core__contract-free.mjs +26 -10
- package/dist/relational-core__contract-free.mjs.map +1 -1
- package/dist/relational-core__expression.d.mts +4 -2
- package/dist/relational-core__expression.mjs +2 -2
- package/dist/relational-core__functions.d.mts +2 -0
- package/dist/relational-core__functions.mjs +2 -0
- package/dist/relational-core__index-reference.d.mts +3 -0
- package/dist/relational-core__index-reference.mjs +2 -0
- package/dist/relational-core__middleware.d.mts +2 -2
- package/dist/relational-core__middleware.mjs +1 -1
- package/dist/relational-core__plan.d.mts +4 -4
- package/dist/relational-core__plan.mjs +1 -1
- package/dist/relational-core__query-lane-context.d.mts +3 -3
- package/dist/relational-core__types.d.mts +2 -2
- package/dist/{resolve-storage-table-DZsfnzeW.mjs → resolve-storage-table-BHLQsOza.mjs} +3 -3
- package/dist/resolve-storage-table-BHLQsOza.mjs.map +1 -0
- package/dist/{resolve-storage-table-Nyrgk4h8.d.mts → resolve-storage-table-DCqtmnSU.d.mts} +4 -4
- package/dist/resolve-storage-table-DCqtmnSU.d.mts.map +1 -0
- package/dist/{runtime-tIHpGCcG.mjs → runtime-6tH1yOxK.mjs} +6 -6
- package/dist/runtime-6tH1yOxK.mjs.map +1 -0
- package/dist/{runtime-DpKF2Yu2.d.mts → runtime-CF6rAlE5.d.mts} +7 -8
- package/dist/runtime-CF6rAlE5.d.mts.map +1 -0
- package/dist/runtime.d.mts +5 -5
- package/dist/runtime.mjs +2 -1799
- package/dist/runtime__internal__prepared-query.d.mts +2 -2
- package/dist/runtime__internal__prepared-query.mjs +2 -2
- package/dist/{schema-differ-DpG_gnur-DFAtGezx.d.mts → schema-differ-DmP74bB8-tqHKiJ88.d.mts} +6 -6
- package/dist/schema-differ-DmP74bB8-tqHKiJ88.d.mts.map +1 -0
- package/dist/schema-ir.d.mts +2 -2
- package/dist/schema-ir.mjs +2 -2
- package/dist/schema-ir__naming.d.mts +1 -1
- package/dist/schema-ir__naming.mjs +1 -1
- package/dist/schema-ir__types.d.mts +3 -3
- package/dist/schema-ir__types.mjs +2 -2
- package/dist/{schema-verify-C_PEdlAr-Dxxjm6EM.mjs → schema-verify-C3wbdviw-DMjIubOr.mjs} +50 -8
- package/dist/schema-verify-C3wbdviw-DMjIubOr.mjs.map +1 -0
- package/dist/{serialized-index-CrgG8ct1-DG3JpHc7.d.mts → serialized-index-CrgG8ct1-DKVJ7TDX.d.mts} +4 -4
- package/dist/serialized-index-CrgG8ct1-DKVJ7TDX.d.mts.map +1 -0
- package/dist/{serialized-index-nBTwanKy-_ddEK4tk.mjs → serialized-index-DjCCnXB1-DMA7BtO2.mjs} +4 -4
- package/dist/serialized-index-DjCCnXB1-DMA7BtO2.mjs.map +1 -0
- package/dist/{sql-contract-serializer-2oBWuxTe-DKZTf2n8.mjs → sql-contract-serializer-sMY3prTx-D2BfrNxs.mjs} +41 -16
- package/dist/sql-contract-serializer-sMY3prTx-D2BfrNxs.mjs.map +1 -0
- package/dist/sql-data-type-D7M-YTTY-D2vRqDxn.mjs +400 -0
- package/dist/sql-data-type-D7M-YTTY-D2vRqDxn.mjs.map +1 -0
- package/dist/{sql-execution-plan--jKyLpe5-CMGhgO0M.d.mts → sql-execution-plan-3uxYjHyu-DLknM-Pj.d.mts} +3 -3
- package/dist/sql-execution-plan-3uxYjHyu-DLknM-Pj.d.mts.map +1 -0
- package/dist/sql-expression-B4BrhGPi.d.mts +62 -0
- package/dist/sql-expression-B4BrhGPi.d.mts.map +1 -0
- package/dist/sql-expression-CKgKznXS.mjs +137 -0
- package/dist/sql-expression-CKgKznXS.mjs.map +1 -0
- package/dist/{sql-index-ByAAE7K8-DKj2V86p.d.mts → sql-index-ByAAE7K8-Dqtn_vUL.d.mts} +4 -4
- package/dist/sql-index-ByAAE7K8-Dqtn_vUL.d.mts.map +1 -0
- package/dist/{sql-node-kEz6YFZo-v2F7delx.d.mts → sql-node-kEz6YFZo-1ogT6Cxt.d.mts} +2 -2
- package/dist/sql-node-kEz6YFZo-1ogT6Cxt.d.mts.map +1 -0
- package/dist/{sql-storage-8LqxeLAY-DH4DdUXx.d.mts → sql-storage-DeCAh5Hi-CEM-m8cs.d.mts} +19 -22
- package/dist/sql-storage-DeCAh5Hi-CEM-m8cs.d.mts.map +1 -0
- package/dist/{storage-table-DSeWszOL-CI-cItEK.d.mts → storage-table-Bf1ZjnxO-pUj6pyP0.d.mts} +17 -24
- package/dist/storage-table-Bf1ZjnxO-pUj6pyP0.d.mts.map +1 -0
- package/dist/{storage-table-ZzbR-xzQ-BRoTQE_2.mjs → storage-table-DDvN83mw-DkbBFmK9.mjs} +12 -9
- package/dist/storage-table-DDvN83mw-DkbBFmK9.mjs.map +1 -0
- package/dist/{storage-value-set-BGlj5Uus-CvZD--GG.d.mts → storage-value-set-BGlj5Uus-ny2k-0PA.d.mts} +3 -3
- package/dist/storage-value-set-BGlj5Uus-ny2k-0PA.d.mts.map +1 -0
- package/dist/transaction-state-BfXhs7D7-DhmbySW9.mjs +45 -0
- package/dist/transaction-state-BfXhs7D7-DhmbySW9.mjs.map +1 -0
- package/dist/transaction-state-DR3nKTmH-D29jmVE-.d.mts +115 -0
- package/dist/transaction-state-DR3nKTmH-D29jmVE-.d.mts.map +1 -0
- package/dist/types-B9wSEUsV.d.mts +1 -0
- package/dist/{types-CUsJrvEl.mjs → types-CTdSkl0s.mjs} +13 -6
- package/dist/types-CTdSkl0s.mjs.map +1 -0
- package/dist/types-CkAd8SWm.d.mts +57 -0
- package/dist/types-CkAd8SWm.d.mts.map +1 -0
- package/dist/{types-IqZMLrFC-DcH8v_u3.d.mts → types-Cq6ImLAB-RlU4jJAX.d.mts} +27 -41
- package/dist/types-Cq6ImLAB-RlU4jJAX.d.mts.map +1 -0
- package/dist/{types-YStFFkKs-D9UAmnON.d.mts → types-CuCxAQat-Dz8P4xyt.d.mts} +141 -86
- package/dist/types-CuCxAQat-Dz8P4xyt.d.mts.map +1 -0
- package/dist/types-DfKvtJwS-CrpWTGBJ.d.mts +273 -0
- package/dist/types-DfKvtJwS-CrpWTGBJ.d.mts.map +1 -0
- package/dist/{types-4YenawkP-CwaaZSid.mjs → types-DoyiTsjg-2YMhMJDA.mjs} +181 -80
- package/dist/types-DoyiTsjg-2YMhMJDA.mjs.map +1 -0
- package/dist/{types-v3qxLLxo-DCeKv7yY.d.mts → types-DriMIMNQ-BkbsW7w3.d.mts} +68 -34
- package/dist/types-DriMIMNQ-BkbsW7w3.d.mts.map +1 -0
- package/dist/{types-Dt4e_jC--COeP8xzN.mjs → types-NTQsD2MS-xcLtvKO9.mjs} +83 -17
- package/dist/types-NTQsD2MS-xcLtvKO9.mjs.map +1 -0
- package/dist/{types-CyxGtOOh-BggSa6Fe.d.mts → types-TXO7x1BA-CYYIY8NI.d.mts} +14 -14
- package/dist/types-TXO7x1BA-CYYIY8NI.d.mts.map +1 -0
- package/dist/types-ljUNyiWe.d.mts +1 -0
- package/dist/{unique-constraint-M5TlQnJQ-BiIHJ85k.d.mts → unique-constraint-M5TlQnJQ-qX-maNUV.d.mts} +3 -3
- package/dist/unique-constraint-M5TlQnJQ-qX-maNUV.d.mts.map +1 -0
- package/dist/{util-DQQgv2j1-D6INZaRG.mjs → util-BBgcP3gI-CpL-0VuC.mjs} +12 -3
- package/dist/util-BBgcP3gI-CpL-0VuC.mjs.map +1 -0
- package/dist/{validators-CrWD6bSP.mjs → validators-BwA7ttZM.mjs} +0 -0
- package/dist/validators-BwA7ttZM.mjs.map +1 -0
- package/dist/{validators-Belo8QqM.d.mts → validators-FJs8HvFr.d.mts} +54 -16
- package/dist/validators-FJs8HvFr.d.mts.map +1 -0
- package/dist/{value-set-derivation-hook-BhgGVtw0.d.mts → value-set-derivation-hook-3E437jPU.d.mts} +3 -3
- package/dist/value-set-derivation-hook-3E437jPU.d.mts.map +1 -0
- package/dist/{value-set-derivation-hook-Di9JZ0X7.mjs → value-set-derivation-hook-HVaxhALD.mjs} +2 -2
- package/dist/value-set-derivation-hook-HVaxhALD.mjs.map +1 -0
- package/dist/{verify-u0UTdZgD-DSAaz9rW.mjs → verify-BVk5bjdH-DhKm6hB3.mjs} +8 -7
- package/dist/verify-BVk5bjdH-DhKm6hB3.mjs.map +1 -0
- package/dist/{verify-zDRnw0Rn.d.mts → verify-DHXbuZPB.d.mts} +2 -2
- package/dist/verify-DHXbuZPB.d.mts.map +1 -0
- package/package.json +33 -22
- package/dist/aggregate-descriptor-registry-C7hel5O7.mjs.map +0 -1
- package/dist/ast-HFcfQZr-.d.mts +0 -206
- package/dist/ast-HFcfQZr-.d.mts.map +0 -1
- package/dist/ast-Lbl4VwqP.mjs +0 -325
- package/dist/ast-Lbl4VwqP.mjs.map +0 -1
- package/dist/authored-check-naming-BWBe-PVE.d.mts.map +0 -1
- package/dist/authored-check-naming-Hf9990DV.mjs.map +0 -1
- package/dist/authoring-type-constructors-Blqoa2Ua-DqvNCOb2.mjs +0 -316
- package/dist/authoring-type-constructors-Blqoa2Ua-DqvNCOb2.mjs.map +0 -1
- package/dist/canonicalization-hooks-CYnW_sGn.d.mts.map +0 -1
- package/dist/canonicalization-hooks-dmXkOR4a.mjs.map +0 -1
- package/dist/check-constraint-B7qGu6rc-HvQjjX82.d.mts.map +0 -1
- package/dist/codec-descriptor-registry-N0dhtKaH.mjs.map +0 -1
- package/dist/config-types-D9fdKG3g.d.mts.map +0 -1
- package/dist/config-types-gAm54C_v.mjs.map +0 -1
- package/dist/contract-builder-CG_tGDbB.d.mts +0 -1360
- package/dist/contract-builder-CG_tGDbB.d.mts.map +0 -1
- package/dist/contract-builder-D4a5dT7j.mjs.map +0 -1
- package/dist/contract-errors-BCN6RVI5-5IHBF_lg.mjs.map +0 -1
- package/dist/contract-view-BMR5IWk4.mjs.map +0 -1
- package/dist/contract-view-CPHxoAEX.d.mts.map +0 -1
- package/dist/contract__pack-types.d.mts +0 -2
- package/dist/control-D3cB5YQp.mjs +0 -1267
- package/dist/control-D3cB5YQp.mjs.map +0 -1
- package/dist/control-DTLJ1WtZ.d.mts +0 -945
- package/dist/control-DTLJ1WtZ.d.mts.map +0 -1
- package/dist/control-adapter-C99J7aEF-B7eQd7vD.d.mts.map +0 -1
- package/dist/control-adapter-MZJQiwcE.d.mts +0 -1
- package/dist/db-D18PrXKW-DvTv4JFn.d.mts.map +0 -1
- package/dist/ddl-types-BGdnAbXo-DKPHPUGx.mjs.map +0 -1
- package/dist/ddl-types-CXx4vPz6-BsgrnSUY.d.mts.map +0 -1
- package/dist/derived-checks-DFMRmiAu-DGfB8aS4.mjs +0 -1057
- package/dist/derived-checks-DFMRmiAu-DGfB8aS4.mjs.map +0 -1
- package/dist/derived-checks-DPdD01O0-DGqOFjs6.d.mts.map +0 -1
- package/dist/diff-B16bL_IR.mjs +0 -13
- package/dist/diff-B16bL_IR.mjs.map +0 -1
- package/dist/diff-DbTNVm2f.d.mts.map +0 -1
- package/dist/dist-C_q1_QR9.mjs.map +0 -1
- package/dist/dist-ZK6oeI5e.mjs.map +0 -1
- package/dist/dist-x6jvtkKM.mjs.map +0 -1
- package/dist/driver-types-BQtRkOJ0-Bv2RPSfr.d.mts.map +0 -1
- package/dist/entity-handle-lowering-hook-CIvRKBfa.d.mts.map +0 -1
- package/dist/entity-handle-lowering-hook-DwLIKNiS.mjs +0 -11
- package/dist/entity-handle-lowering-hook-DwLIKNiS.mjs.map +0 -1
- package/dist/entity-kinds-B5cUFU22.d.mts.map +0 -1
- package/dist/entity-kinds-D7vwoN_T-CCBwFJy0.mjs.map +0 -1
- package/dist/errors-B5g0xWro-mWH2C07F.mjs.map +0 -1
- package/dist/expression-CX5mTA-z.mjs.map +0 -1
- package/dist/expression-FJK6Ar-d.d.mts.map +0 -1
- package/dist/factories-P3qBQhO-.d.mts.map +0 -1
- package/dist/factories-SVor5xIT.mjs.map +0 -1
- package/dist/family__pack.d.mts.map +0 -1
- package/dist/family__pack.mjs.map +0 -1
- package/dist/foreign-key-C-iTPuRT-C9ip8zFx.d.mts.map +0 -1
- package/dist/foreign-key-materialization-CkvOzJWy.d.mts +0 -65
- package/dist/foreign-key-materialization-CkvOzJWy.d.mts.map +0 -1
- package/dist/foreign-key-materialization-Cu7-7LHl.mjs +0 -73
- package/dist/foreign-key-materialization-Cu7-7LHl.mjs.map +0 -1
- package/dist/index-C-vQOMY_.d.mts +0 -84
- package/dist/index-C-vQOMY_.d.mts.map +0 -1
- package/dist/index-C5I8D-MB.d.mts.map +0 -1
- package/dist/index-naming-Ct65z5Xk.d.mts.map +0 -1
- package/dist/index-naming-DREt6js7-CRH27yUv.mjs.map +0 -1
- package/dist/index-type-validation-COH4d78M.mjs +0 -17
- package/dist/index-type-validation-COH4d78M.mjs.map +0 -1
- package/dist/index-type-validation-CZ5L2lli.d.mts +0 -10
- package/dist/index-type-validation-CZ5L2lli.d.mts.map +0 -1
- package/dist/index-types-CNhHgKHi.d.mts +0 -1
- package/dist/index-types-DJQ_xwaE.mjs +0 -40
- package/dist/index-types-DJQ_xwaE.mjs.map +0 -1
- package/dist/index-types-DPVhsW0v-D-BikM4h.d.mts +0 -31
- package/dist/index-types-DPVhsW0v-D-BikM4h.d.mts.map +0 -1
- package/dist/interpreter-DyiUUAWh-DYdjIpiE.mjs +0 -3680
- package/dist/interpreter-DyiUUAWh-DYdjIpiE.mjs.map +0 -1
- package/dist/ir-Bghjt-FG.d.mts.map +0 -1
- package/dist/ir-I-xciGUH.mjs.map +0 -1
- package/dist/lane-query-builder.d.mts +0 -236
- package/dist/lane-query-builder.d.mts.map +0 -1
- package/dist/lane-query-builder.mjs +0 -67
- package/dist/lane-query-builder.mjs.map +0 -1
- package/dist/middleware--TtoxUiW.d.mts +0 -1
- package/dist/middleware-AhTz1BOW-th-Suxuf.d.mts.map +0 -1
- package/dist/middleware-CMr4CHNz-DHIUdxlm.mjs.map +0 -1
- package/dist/migration-CK4oePIo.mjs.map +0 -1
- package/dist/migration-CjDRZNep.d.mts.map +0 -1
- package/dist/naming-CV9j2pXl-KARaDReS.d.mts.map +0 -1
- package/dist/naming-DKr4TJd7-Cszhq9RV.mjs.map +0 -1
- package/dist/pack-types-BcLTpwbv.d.mts +0 -14
- package/dist/pack-types-BcLTpwbv.d.mts.map +0 -1
- package/dist/plan-BHLdb0Z7.d.mts +0 -2
- package/dist/plan-CDxduYaN-pLIyyJaB.d.mts.map +0 -1
- package/dist/plan-Dh0LbYIv-Crx5-ThG.mjs.map +0 -1
- package/dist/prepared-query-BJr50wPm-ChoqfJbX.mjs +0 -22
- package/dist/prepared-query-BJr50wPm-ChoqfJbX.mjs.map +0 -1
- package/dist/prepared-statement-9QpkE6JG-C430V3MO.d.mts +0 -529
- package/dist/prepared-statement-9QpkE6JG-C430V3MO.d.mts.map +0 -1
- package/dist/psl-infer-CCAD6FWA.d.mts +0 -119
- package/dist/psl-infer-CCAD6FWA.d.mts.map +0 -1
- package/dist/psl-infer-Dk5kgKre.mjs +0 -362
- package/dist/psl-infer-Dk5kgKre.mjs.map +0 -1
- package/dist/query-lane-context-Qa-eddrE-kuZ8Z86-.d.mts.map +0 -1
- package/dist/query-lane-context-XMvk7fmY.d.mts +0 -1
- package/dist/referential-action-sql-DJ9ps6-S.d.mts.map +0 -1
- package/dist/referential-action-sql-DSqkrySN.mjs.map +0 -1
- package/dist/resolve-storage-table-DZsfnzeW.mjs.map +0 -1
- package/dist/resolve-storage-table-Nyrgk4h8.d.mts.map +0 -1
- package/dist/runtime-DpKF2Yu2.d.mts.map +0 -1
- package/dist/runtime-tIHpGCcG.mjs.map +0 -1
- package/dist/runtime.mjs.map +0 -1
- package/dist/schema-differ-DpG_gnur-DFAtGezx.d.mts.map +0 -1
- package/dist/schema-verify-C_PEdlAr-Dxxjm6EM.mjs.map +0 -1
- package/dist/serialized-index-CrgG8ct1-DG3JpHc7.d.mts.map +0 -1
- package/dist/serialized-index-nBTwanKy-_ddEK4tk.mjs.map +0 -1
- package/dist/sql-contract-serializer-2oBWuxTe-DKZTf2n8.mjs.map +0 -1
- package/dist/sql-execution-plan--jKyLpe5-CMGhgO0M.d.mts.map +0 -1
- package/dist/sql-index-ByAAE7K8-DKj2V86p.d.mts.map +0 -1
- package/dist/sql-node-kEz6YFZo-v2F7delx.d.mts.map +0 -1
- package/dist/sql-storage-8LqxeLAY-DH4DdUXx.d.mts.map +0 -1
- package/dist/storage-table-DSeWszOL-CI-cItEK.d.mts.map +0 -1
- package/dist/storage-table-ZzbR-xzQ-BRoTQE_2.mjs.map +0 -1
- package/dist/storage-value-set-BGlj5Uus-CvZD--GG.d.mts.map +0 -1
- package/dist/timestamp-now-generator-DRXygu32-DN9Qb1uI.mjs +0 -173
- package/dist/timestamp-now-generator-DRXygu32-DN9Qb1uI.mjs.map +0 -1
- package/dist/types-4YenawkP-CwaaZSid.mjs.map +0 -1
- package/dist/types-B0msOnBM.d.mts +0 -1
- package/dist/types-BDUG29Df-LE85dIXP.d.mts +0 -161
- package/dist/types-BDUG29Df-LE85dIXP.d.mts.map +0 -1
- package/dist/types-CUsJrvEl.mjs.map +0 -1
- package/dist/types-CyxGtOOh-BggSa6Fe.d.mts.map +0 -1
- package/dist/types-Dt4e_jC--COeP8xzN.mjs.map +0 -1
- package/dist/types-Dwcw0F8X.d.mts +0 -1
- package/dist/types-IqZMLrFC-DcH8v_u3.d.mts.map +0 -1
- package/dist/types-UcHa2cTe.d.mts +0 -17
- package/dist/types-UcHa2cTe.d.mts.map +0 -1
- package/dist/types-YStFFkKs-D9UAmnON.d.mts.map +0 -1
- package/dist/types-v3qxLLxo-DCeKv7yY.d.mts.map +0 -1
- package/dist/unique-constraint-M5TlQnJQ-BiIHJ85k.d.mts.map +0 -1
- package/dist/util-DQQgv2j1-D6INZaRG.mjs.map +0 -1
- package/dist/validators-Belo8QqM.d.mts.map +0 -1
- package/dist/validators-CrWD6bSP.mjs.map +0 -1
- package/dist/value-set-derivation-hook-BhgGVtw0.d.mts.map +0 -1
- package/dist/value-set-derivation-hook-Di9JZ0X7.mjs.map +0 -1
- package/dist/verify-u0UTdZgD-DSAaz9rW.mjs.map +0 -1
- package/dist/verify-zDRnw0Rn.d.mts.map +0 -1
- /package/dist/{contract__pack-types.mjs → relational-core__collection-methods.mjs} +0 -0
|
@@ -1,1057 +0,0 @@
|
|
|
1
|
-
import { i as computeCheckContentHash, r as composeCheckWirePrefix, s as derivedCheckPrefixes } from "./naming-DKr4TJd7-Cszhq9RV.mjs";
|
|
2
|
-
import { n as lowerAuthoredIndex } from "./index-naming-DREt6js7-CRH27yUv.mjs";
|
|
3
|
-
import { t as lowerAuthoredCheck } from "./authored-check-naming-Hf9990DV.mjs";
|
|
4
|
-
import { t as sqlContractCanonicalizationHooks } from "./canonicalization-hooks-dmXkOR4a.mjs";
|
|
5
|
-
import { c as StorageTable, i as Index, t as CheckConstraint } from "./storage-table-ZzbR-xzQ-BRoTQE_2.mjs";
|
|
6
|
-
import { n as checkConstraintInputFromSerialized } from "./serialized-index-nBTwanKy-_ddEK4tk.mjs";
|
|
7
|
-
import { m as valueSetEntityKind, p as tableEntityKind } from "./entity-kinds-D7vwoN_T-CCBwFJy0.mjs";
|
|
8
|
-
import { r as materializeForeignKeysAndIndexes } from "./foreign-key-materialization-Cu7-7LHl.mjs";
|
|
9
|
-
import { t as validateIndexTypes } from "./index-type-validation-COH4d78M.mjs";
|
|
10
|
-
import { t as createIndexTypeRegistry } from "./index-types-DJQ_xwaE.mjs";
|
|
11
|
-
import { a as SqlStorage, o as applyFkDefaults, s as isMaterializedSqlNamespace, u as toStorageTypeInstance } from "./types-CUsJrvEl.mjs";
|
|
12
|
-
import { u as validateStorageSemantics } from "./validators-CrWD6bSP.mjs";
|
|
13
|
-
import { t as deriveValueSetFromEntity } from "./value-set-derivation-hook-Di9JZ0X7.mjs";
|
|
14
|
-
import { structuredError } from "@prisma/orm-framework/utils/structured-error";
|
|
15
|
-
import { flushAuthoringWarnings, isAuthoringEntityTypeDescriptor } from "@prisma/orm-framework/components/authoring";
|
|
16
|
-
import { UNBOUND_NAMESPACE_ID } from "@prisma/orm-framework/components/ir";
|
|
17
|
-
import { InternalError } from "@prisma/orm-framework/utils/internal-error";
|
|
18
|
-
import { asNamespaceId, coreHash, crossRef, effectiveControlPolicy } from "@prisma/orm-framework/contract/types";
|
|
19
|
-
import { ifDefined } from "@prisma/orm-framework/utils/defined";
|
|
20
|
-
import { blindCast } from "@prisma/orm-framework/utils/casts";
|
|
21
|
-
import { computeExecutionHash, computeProfileHash, computeStorageHash } from "@prisma/orm-framework/contract/hashing";
|
|
22
|
-
import { mergeCapabilityMatrices } from "@prisma/orm-framework/contract-authoring";
|
|
23
|
-
import { applySpecifierDefaultControlPolicy } from "@prisma/orm-framework/contract/apply-specifier-default-control-policy";
|
|
24
|
-
import { invariant } from "@prisma/orm-framework/utils/assertions";
|
|
25
|
-
//#region ../../../2-sql/2-authoring/contract-ts/dist/derived-checks-DFMRmiAu.mjs
|
|
26
|
-
function contractError(code, message, options) {
|
|
27
|
-
return structuredError(code, message, options);
|
|
28
|
-
}
|
|
29
|
-
function encodeViaCodec(value, codecId, codecLookup) {
|
|
30
|
-
const codec = codecLookup?.get(codecId);
|
|
31
|
-
if (codec) return codec.encodeJson(value);
|
|
32
|
-
return blindCast(value);
|
|
33
|
-
}
|
|
34
|
-
function encodeColumnDefault(defaultInput, codecId, codecLookup, many = false) {
|
|
35
|
-
if (defaultInput.kind === "function") return {
|
|
36
|
-
kind: "function",
|
|
37
|
-
expression: defaultInput.expression
|
|
38
|
-
};
|
|
39
|
-
if (many) {
|
|
40
|
-
if (!Array.isArray(defaultInput.value)) throw new InternalError(`Literal default on a list column must be an array; received ${typeof defaultInput.value}. A scalar default on a list field must be rejected at the authoring surface.`);
|
|
41
|
-
return {
|
|
42
|
-
kind: "literal",
|
|
43
|
-
value: defaultInput.value.map((element) => encodeViaCodec(element, codecId, codecLookup))
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
return {
|
|
47
|
-
kind: "literal",
|
|
48
|
-
value: encodeViaCodec(defaultInput.value, codecId, codecLookup)
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
function assertStorageSemantics(definition, contract) {
|
|
52
|
-
const semanticErrors = validateStorageSemantics(contract.storage);
|
|
53
|
-
if (semanticErrors.length > 0) throw contractError("CONTRACT.VALIDATION_FAILED", `Contract semantic validation failed: ${semanticErrors.join("; ")}`, { meta: { errors: semanticErrors } });
|
|
54
|
-
const indexTypeRegistry = createIndexTypeRegistry();
|
|
55
|
-
const packsToRegister = [definition.target, ...Object.values(definition.extensions ?? {})];
|
|
56
|
-
for (const pack of packsToRegister) {
|
|
57
|
-
const registration = pack.indexTypes;
|
|
58
|
-
if (registration === void 0) continue;
|
|
59
|
-
if (typeof registration !== "object" || registration === null || !Array.isArray(registration.entries)) throw contractError("CONTRACT.PACK_CONTRIBUTION_INVALID", `Pack "${pack.id ?? "<unknown>"}" declares "indexTypes" but its value is not an IndexTypeRegistration (expected an object with an "entries" array; got ${typeof registration}).`, { meta: {
|
|
60
|
-
packId: pack.id,
|
|
61
|
-
contribution: "indexTypes",
|
|
62
|
-
reason: "invalid-shape"
|
|
63
|
-
} });
|
|
64
|
-
for (const entry of registration.entries) indexTypeRegistry.register(entry);
|
|
65
|
-
}
|
|
66
|
-
validateIndexTypes(contract, indexTypeRegistry);
|
|
67
|
-
}
|
|
68
|
-
function assertKnownTargetModel(modelsByName, modelsByCoordinate, sourceModelName, targetModelName, targetNamespaceId, context) {
|
|
69
|
-
const targetModel = targetNamespaceId !== void 0 && targetNamespaceId.length > 0 ? modelsByCoordinate.get(`${targetNamespaceId}:${targetModelName}`) : modelsByName.get(targetModelName);
|
|
70
|
-
if (!targetModel) {
|
|
71
|
-
const qualified = targetNamespaceId !== void 0 && targetNamespaceId.length > 0 ? `${targetNamespaceId}.${targetModelName}` : targetModelName;
|
|
72
|
-
throw contractError("CONTRACT.MODEL_UNKNOWN", `${context} on model "${sourceModelName}" references unknown model "${qualified}"`, { meta: {
|
|
73
|
-
sourceModel: sourceModelName,
|
|
74
|
-
targetModel: qualified,
|
|
75
|
-
context
|
|
76
|
-
} });
|
|
77
|
-
}
|
|
78
|
-
return targetModel;
|
|
79
|
-
}
|
|
80
|
-
function assertTargetTableMatches(sourceModelName, targetModel, referencedTableName, context) {
|
|
81
|
-
if (targetModel.tableName !== referencedTableName) throw contractError("CONTRACT.TABLE_MISMATCH", `${context} on model "${sourceModelName}" references table "${referencedTableName}" but model "${targetModel.modelName}" maps to "${targetModel.tableName}"`, { meta: {
|
|
82
|
-
sourceModel: sourceModelName,
|
|
83
|
-
referencedTable: referencedTableName,
|
|
84
|
-
mappedTable: targetModel.tableName,
|
|
85
|
-
context
|
|
86
|
-
} });
|
|
87
|
-
}
|
|
88
|
-
function isValueObjectField(field) {
|
|
89
|
-
return "valueObjectName" in field;
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* Resolves a deferred entity-ref column descriptor (e.g. a `pg.enum(handle)`
|
|
93
|
-
* column) against the field's now-known owning namespace: attaches the
|
|
94
|
-
* storage `valueSet` ref the collected entity's derived value-set is stored
|
|
95
|
-
* under. `nativeType` / `typeParams.typeName` stay bare here — schema
|
|
96
|
-
* qualification (e.g. `auth.aal_level`) is a target concern applied in the
|
|
97
|
-
* next step, `qualifyColumnDescriptor`. A descriptor with no `entityRef` (the
|
|
98
|
-
* ordinary case) passes through unchanged.
|
|
99
|
-
*/
|
|
100
|
-
function resolveEntityRefDescriptor(descriptor, namespaceId) {
|
|
101
|
-
const entityRef = descriptor.entityRef;
|
|
102
|
-
if (entityRef === void 0) return descriptor;
|
|
103
|
-
return {
|
|
104
|
-
...descriptor,
|
|
105
|
-
valueSet: {
|
|
106
|
-
plane: "storage",
|
|
107
|
-
entityKind: "valueSet",
|
|
108
|
-
namespaceId,
|
|
109
|
-
entityName: entityRef.entityName
|
|
110
|
-
}
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* Structural check for a target that contributes a `qualifyColumnType` hook
|
|
115
|
-
* on its authoring contributions. Duck-typed (mirroring
|
|
116
|
-
* `contract-psl`'s `hasColumnFromEntityHook`) so the SQL family stays blind
|
|
117
|
-
* to the target's qualification logic and no framework/family interface has
|
|
118
|
-
* to name the hook.
|
|
119
|
-
*/
|
|
120
|
-
function hasColumnTypeQualifier(authoring) {
|
|
121
|
-
return "qualifyColumnType" in authoring && typeof authoring.qualifyColumnType === "function";
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* Structural check for a target that contributes a `renderCheckExpressions`
|
|
125
|
-
* hook, duck-typed for the same reason {@link hasColumnTypeQualifier} is: the
|
|
126
|
-
* SQL family stays blind to the target's predicate syntax.
|
|
127
|
-
*/
|
|
128
|
-
function hasCheckExpressionRenderer(authoring) {
|
|
129
|
-
return "renderCheckExpressions" in authoring && typeof authoring.renderCheckExpressions === "function";
|
|
130
|
-
}
|
|
131
|
-
function resolveCheckExpressionRenderer(target) {
|
|
132
|
-
const authoring = target.authoring;
|
|
133
|
-
if (authoring === void 0) return void 0;
|
|
134
|
-
return hasCheckExpressionRenderer(authoring) ? authoring.renderCheckExpressions : void 0;
|
|
135
|
-
}
|
|
136
|
-
/**
|
|
137
|
-
* The member values a membership check must enforce, encoded exactly as the
|
|
138
|
-
* column stores them. Only string members can be written as a predicate, so a
|
|
139
|
-
* numeric enum fails here rather than emitting a wrong text-shaped check.
|
|
140
|
-
*/
|
|
141
|
-
function checkMemberValues(handle, codecLookup) {
|
|
142
|
-
const encoded = handle.values.map((value) => encodeViaCodec(value, handle.codecId, codecLookup));
|
|
143
|
-
const values = [];
|
|
144
|
-
for (const value of encoded) {
|
|
145
|
-
if (typeof value !== "string") throw contractError("CONTRACT.ENUM_INVALID", `enumType("${handle.enumName}"): has a non-string value; numeric-enum CHECK constraints are not yet supported.`, { meta: {
|
|
146
|
-
enumName: handle.enumName,
|
|
147
|
-
reason: "non-string-member-value"
|
|
148
|
-
} });
|
|
149
|
-
values.push(value);
|
|
150
|
-
}
|
|
151
|
-
return values;
|
|
152
|
-
}
|
|
153
|
-
/**
|
|
154
|
-
* Resolves a field's authored `noCheck` kinds against its column shape:
|
|
155
|
-
* the bare form (`[]`) becomes every kind the shape derives, and a named
|
|
156
|
-
* kind that can never apply to the shape is an authoring error
|
|
157
|
-
* (`CONTRACT.CHECK_OPTOUT_INVALID`). Returns the concrete kinds in
|
|
158
|
-
* canonical ascending order — the only form the contract persists.
|
|
159
|
-
*/
|
|
160
|
-
function resolveNoCheckKinds(input) {
|
|
161
|
-
const derivable = [];
|
|
162
|
-
if (input.many) derivable.push("elementNotNull");
|
|
163
|
-
if (input.isDomainEnum) derivable.push("membership");
|
|
164
|
-
const subject = `Field "${input.modelName}.${input.fieldName}"`;
|
|
165
|
-
const meta = {
|
|
166
|
-
modelName: input.modelName,
|
|
167
|
-
fieldName: input.fieldName
|
|
168
|
-
};
|
|
169
|
-
if (input.kinds.length === 0) {
|
|
170
|
-
if (derivable.length === 0) throw contractError("CONTRACT.CHECK_OPTOUT_INVALID", `${subject}: noCheck() waives nothing — this column's shape derives no generated checks.`, { meta: {
|
|
171
|
-
...meta,
|
|
172
|
-
reason: "no-derivable-checks"
|
|
173
|
-
} });
|
|
174
|
-
return derivable;
|
|
175
|
-
}
|
|
176
|
-
const seen = /* @__PURE__ */ new Set();
|
|
177
|
-
for (const kind of input.kinds) {
|
|
178
|
-
if (seen.has(kind)) throw contractError("CONTRACT.CHECK_OPTOUT_INVALID", `${subject}: noCheck("${kind}") names the same kind twice.`, { meta: {
|
|
179
|
-
...meta,
|
|
180
|
-
kind,
|
|
181
|
-
reason: "duplicate-kind"
|
|
182
|
-
} });
|
|
183
|
-
seen.add(kind);
|
|
184
|
-
if (!derivable.includes(kind)) throw contractError("CONTRACT.CHECK_OPTOUT_INVALID", `${subject}: noCheck("${kind}") does not apply — ${kind === "membership" ? "membership checks are derived only from enumType() value sets" : "element-non-null checks are derived only for list columns"}.`, { meta: {
|
|
185
|
-
...meta,
|
|
186
|
-
kind,
|
|
187
|
-
reason: "inapplicable-kind"
|
|
188
|
-
} });
|
|
189
|
-
}
|
|
190
|
-
return [...input.kinds].sort();
|
|
191
|
-
}
|
|
192
|
-
/**
|
|
193
|
-
* Names the target's rendered checks and lowers them into contract entities.
|
|
194
|
-
*
|
|
195
|
-
* Naming is composed family-side ({@link composeCheckWirePrefix}) rather than
|
|
196
|
-
* by the target, and suffixed with the predicate's content hash. Composing
|
|
197
|
-
* family-side is what makes the truncation safe — two prefixes that truncate
|
|
198
|
-
* alike still differ in their hashes, and the family can see that the
|
|
199
|
-
* (table, column, kind) triple they were built from is unique per table,
|
|
200
|
-
* rather than having to assume something about SQL text it declares itself
|
|
201
|
-
* unable to read.
|
|
202
|
-
*/
|
|
203
|
-
function lowerRenderedChecks(tableName, candidates) {
|
|
204
|
-
return candidates.map((candidate) => new CheckConstraint({
|
|
205
|
-
naming: {
|
|
206
|
-
kind: "wire",
|
|
207
|
-
prefix: composeCheckWirePrefix(tableName, candidate.columnName, candidate.kind),
|
|
208
|
-
hash: computeCheckContentHash(candidate.expression)
|
|
209
|
-
},
|
|
210
|
-
expression: candidate.expression
|
|
211
|
-
}));
|
|
212
|
-
}
|
|
213
|
-
function resolveColumnTypeQualifier(target) {
|
|
214
|
-
const authoring = target.authoring;
|
|
215
|
-
if (authoring === void 0) return void 0;
|
|
216
|
-
return hasColumnTypeQualifier(authoring) ? authoring.qualifyColumnType : void 0;
|
|
217
|
-
}
|
|
218
|
-
/**
|
|
219
|
-
* Applies the target's `qualifyColumnType` hook to a scalar column descriptor
|
|
220
|
-
* at construction, so the storage column and the domain field (which derives
|
|
221
|
-
* its `type.typeParams` from the storage column) are both built already
|
|
222
|
-
* qualified in a single pass. A descriptor whose codec the target leaves
|
|
223
|
-
* unchanged passes through untouched.
|
|
224
|
-
*/
|
|
225
|
-
function qualifyColumnDescriptor(descriptor, namespaceId, qualify) {
|
|
226
|
-
if (qualify === void 0) return descriptor;
|
|
227
|
-
const qualified = qualify({
|
|
228
|
-
codecId: descriptor.codecId,
|
|
229
|
-
nativeType: descriptor.nativeType,
|
|
230
|
-
...ifDefined("typeParams", descriptor.typeParams)
|
|
231
|
-
}, namespaceId);
|
|
232
|
-
if (qualified.nativeType === descriptor.nativeType && qualified.typeParams === descriptor.typeParams) return descriptor;
|
|
233
|
-
return {
|
|
234
|
-
...descriptor,
|
|
235
|
-
nativeType: qualified.nativeType,
|
|
236
|
-
...ifDefined("typeParams", qualified.typeParams)
|
|
237
|
-
};
|
|
238
|
-
}
|
|
239
|
-
/**
|
|
240
|
-
* Records a deferred column's entity-ref into the namespace-scoped collection
|
|
241
|
-
* accumulator (`namespaceId → entityKind → entityName`) — folded into the same
|
|
242
|
-
* namespace assembly `deriveEntityValueSets`/`entries.<kind>` step as the
|
|
243
|
-
* entities-channel attachments, so a column-collected entity gets its
|
|
244
|
-
* value-set the same way an entities-channel one does.
|
|
245
|
-
*
|
|
246
|
-
* The same handle reused by many columns in one namespace is normal (a native
|
|
247
|
-
* enum type backs any number of columns) and records the identical entity once.
|
|
248
|
-
* Two *different* entity instances sharing a name+kind in one namespace is a
|
|
249
|
-
* name collision — the emitted `entries.valueSet.<name>` could only reflect one
|
|
250
|
-
* of them, silently mismatching the other column's type/cast. PSL hard-errors
|
|
251
|
-
* on the equivalent (`PSL_DUPLICATE_DECLARATION`); the TS path rejects it too.
|
|
252
|
-
*/
|
|
253
|
-
function collectEntityFromColumn(collected, namespaceId, entityRef) {
|
|
254
|
-
const forNs = collected[namespaceId] ?? {};
|
|
255
|
-
const forKind = forNs[entityRef.entityKind] ?? {};
|
|
256
|
-
const existing = forKind[entityRef.entityName];
|
|
257
|
-
if (existing !== void 0 && existing !== entityRef.entity) throw contractError("CONTRACT.NAME_DUPLICATE", `buildSqlContractFromDefinition: two different "${entityRef.entityKind}" entities named "${entityRef.entityName}" in namespace "${namespaceId}" — pack-entity names must be unique per namespace.`, { meta: {
|
|
258
|
-
kind: entityRef.entityKind,
|
|
259
|
-
name: entityRef.entityName,
|
|
260
|
-
namespaceId
|
|
261
|
-
} });
|
|
262
|
-
forKind[entityRef.entityName] = entityRef.entity;
|
|
263
|
-
forNs[entityRef.entityKind] = forKind;
|
|
264
|
-
collected[namespaceId] = forNs;
|
|
265
|
-
}
|
|
266
|
-
/**
|
|
267
|
-
* Merges a namespace's entities-channel attachments (lowered from the
|
|
268
|
-
* `entities` handle list, carried on `ContractDefinition.attachedEntities`)
|
|
269
|
-
* with the entities collected from that namespace's deferred entity-ref
|
|
270
|
-
* columns. A column-collected entity that shadows a *different* attached
|
|
271
|
-
* entity of the same kind+name (or vice-versa) is the same name-collision bug
|
|
272
|
-
* `collectEntityFromColumn` guards against across columns, so it is rejected
|
|
273
|
-
* the same way — by entity identity, so the same handle attached and used by
|
|
274
|
-
* a column does not throw.
|
|
275
|
-
*/
|
|
276
|
-
function mergeColumnAndAttachedEntities(namespaceId, attached, columnCollected) {
|
|
277
|
-
if (attached === void 0) return columnCollected;
|
|
278
|
-
if (columnCollected === void 0) return attached;
|
|
279
|
-
const kinds = /* @__PURE__ */ new Set([...Object.keys(attached), ...Object.keys(columnCollected)]);
|
|
280
|
-
const result = {};
|
|
281
|
-
for (const kind of kinds) {
|
|
282
|
-
const attachedForKind = attached[kind];
|
|
283
|
-
const columnForKind = columnCollected[kind];
|
|
284
|
-
for (const [name, entity] of Object.entries(columnForKind ?? {})) {
|
|
285
|
-
const existing = attachedForKind?.[name];
|
|
286
|
-
if (existing !== void 0 && existing !== entity) throw contractError("CONTRACT.NAME_DUPLICATE", `buildSqlContractFromDefinition: two different "${kind}" entities named "${name}" in namespace "${namespaceId}" — a column-referenced entity conflicts with an attached one; pack-entity names must be unique per namespace.`, { meta: {
|
|
287
|
-
kind,
|
|
288
|
-
name,
|
|
289
|
-
namespaceId
|
|
290
|
-
} });
|
|
291
|
-
}
|
|
292
|
-
result[kind] = {
|
|
293
|
-
...attachedForKind,
|
|
294
|
-
...columnForKind
|
|
295
|
-
};
|
|
296
|
-
}
|
|
297
|
-
return result;
|
|
298
|
-
}
|
|
299
|
-
const JSONB_CODEC_ID = "pg/jsonb@1";
|
|
300
|
-
const JSONB_NATIVE_TYPE = "jsonb";
|
|
301
|
-
function resolveModelNamespaceId(model, modelNameToNamespaceId, defaultNamespaceId) {
|
|
302
|
-
if (model.namespaceId !== void 0 && model.namespaceId.length > 0) return model.namespaceId;
|
|
303
|
-
return modelNameToNamespaceId.get(model.modelName) ?? defaultNamespaceId;
|
|
304
|
-
}
|
|
305
|
-
function buildThroughDescriptor(through, tableNamespaceByName, targetModel, modelName, fieldName, defaultNamespaceId) {
|
|
306
|
-
if (!tableNamespaceByName.has(through.table)) throw contractError("CONTRACT.MODEL_UNKNOWN", `buildSqlContractFromDefinition: junction table "${through.table}" for relation "${modelName}.${fieldName}" is not a declared model.`, { meta: {
|
|
307
|
-
sourceModel: modelName,
|
|
308
|
-
relationName: fieldName,
|
|
309
|
-
junctionTable: through.table
|
|
310
|
-
} });
|
|
311
|
-
const namespaceId = through.namespaceId ?? defaultNamespaceId;
|
|
312
|
-
return {
|
|
313
|
-
table: through.table,
|
|
314
|
-
namespaceId,
|
|
315
|
-
parentColumns: through.parentColumns,
|
|
316
|
-
childColumns: through.childColumns,
|
|
317
|
-
targetColumns: targetColumnsForJunction(targetModel, fieldName)
|
|
318
|
-
};
|
|
319
|
-
}
|
|
320
|
-
function targetColumnsForJunction(targetModel, fieldName) {
|
|
321
|
-
const primaryKeyColumns = targetModel.id?.columns;
|
|
322
|
-
if (primaryKeyColumns && primaryKeyColumns.length > 0) return primaryKeyColumns;
|
|
323
|
-
const firstUnique = targetModel.uniques?.find((u) => u.columns.length > 0);
|
|
324
|
-
if (firstUnique) return firstUnique.columns;
|
|
325
|
-
throw contractError("CONTRACT.IDENTITY_INVALID", `M:N target model "${targetModel.modelName}" (relation field "${fieldName}") has no primary id or unique key to derive junction targetColumns.`, { meta: {
|
|
326
|
-
modelName: targetModel.modelName,
|
|
327
|
-
reason: "no-key-for-junction-target-columns"
|
|
328
|
-
} });
|
|
329
|
-
}
|
|
330
|
-
function buildStorageColumn(field, storageValueSetRef, codecLookup) {
|
|
331
|
-
if (isValueObjectField(field)) {
|
|
332
|
-
const encodedDefault = field.default !== void 0 ? encodeColumnDefault(field.default, JSONB_CODEC_ID, codecLookup) : void 0;
|
|
333
|
-
return {
|
|
334
|
-
nativeType: JSONB_NATIVE_TYPE,
|
|
335
|
-
codecId: JSONB_CODEC_ID,
|
|
336
|
-
nullable: field.nullable,
|
|
337
|
-
...ifDefined("default", encodedDefault)
|
|
338
|
-
};
|
|
339
|
-
}
|
|
340
|
-
const codecId = field.descriptor.codecId;
|
|
341
|
-
const encodedDefault = field.default !== void 0 ? encodeColumnDefault(field.default, codecId, codecLookup, field.many === true) : void 0;
|
|
342
|
-
const valueSet = storageValueSetRef ?? field.descriptor.valueSet;
|
|
343
|
-
return {
|
|
344
|
-
nativeType: field.descriptor.nativeType,
|
|
345
|
-
codecId,
|
|
346
|
-
nullable: field.nullable,
|
|
347
|
-
...field.many ? { many: true } : {},
|
|
348
|
-
...field.noCheck !== void 0 ? { noCheck: [...field.noCheck].sort() } : {},
|
|
349
|
-
...ifDefined("typeParams", field.descriptor.typeParams),
|
|
350
|
-
...ifDefined("default", encodedDefault),
|
|
351
|
-
...ifDefined("typeRef", field.descriptor.typeRef),
|
|
352
|
-
...ifDefined("valueSet", valueSet)
|
|
353
|
-
};
|
|
354
|
-
}
|
|
355
|
-
function buildDomainField(field, column, domainValueSetRef) {
|
|
356
|
-
if (isValueObjectField(field)) return {
|
|
357
|
-
type: {
|
|
358
|
-
kind: "valueObject",
|
|
359
|
-
name: field.valueObjectName
|
|
360
|
-
},
|
|
361
|
-
nullable: field.nullable,
|
|
362
|
-
...field.many ? { many: true } : {}
|
|
363
|
-
};
|
|
364
|
-
return {
|
|
365
|
-
type: {
|
|
366
|
-
kind: "scalar",
|
|
367
|
-
codecId: column.codecId,
|
|
368
|
-
...ifDefined("typeParams", column.typeParams)
|
|
369
|
-
},
|
|
370
|
-
nullable: column.nullable,
|
|
371
|
-
...field.many ? { many: true } : {},
|
|
372
|
-
...ifDefined("valueSet", domainValueSetRef)
|
|
373
|
-
};
|
|
374
|
-
}
|
|
375
|
-
function collectStorageNamespaceCoordinateIds(definition) {
|
|
376
|
-
const ids = /* @__PURE__ */ new Set();
|
|
377
|
-
ids.add(definition.target.defaultNamespaceId);
|
|
378
|
-
for (const id of definition.namespaces ?? []) if (id.length > 0) ids.add(id);
|
|
379
|
-
for (const model of definition.models) if (model.namespaceId !== void 0 && model.namespaceId.length > 0) ids.add(model.namespaceId);
|
|
380
|
-
for (const id of Object.keys(definition.attachedEntities ?? {})) if (id.length > 0) ids.add(id);
|
|
381
|
-
return ids;
|
|
382
|
-
}
|
|
383
|
-
/**
|
|
384
|
-
* Entry kinds the framework assembler itself manages (`table` from models,
|
|
385
|
-
* `valueSet` from `enums` and attached-entity value-set derivation). A
|
|
386
|
-
* pack-attached entity claiming one of these would silently clobber or be
|
|
387
|
-
* clobbered by the managed slot, so it is rejected outright.
|
|
388
|
-
*/
|
|
389
|
-
const MANAGED_ENTRY_KINDS = /* @__PURE__ */ new Set([tableEntityKind.kind, valueSetEntityKind.kind]);
|
|
390
|
-
function assertNoManagedEntityKinds(namespaceId, entitiesForNs) {
|
|
391
|
-
if (entitiesForNs === void 0) return;
|
|
392
|
-
for (const kind of Object.keys(entitiesForNs)) if (MANAGED_ENTRY_KINDS.has(kind)) throw contractError("CONTRACT.ENTITY_KIND_INVALID", `buildSqlContractFromDefinition: attached entity in namespace "${namespaceId}" declares entry kind "${kind}", which is managed by the framework (table/valueSet) and cannot be attached.`, { meta: {
|
|
393
|
-
entityKind: kind,
|
|
394
|
-
namespaceId
|
|
395
|
-
} });
|
|
396
|
-
}
|
|
397
|
-
/**
|
|
398
|
-
* Walks the flat `entityTypes` namespace tree contributed by the target pack
|
|
399
|
-
* and every extension pack, indexing descriptors by their `discriminator` —
|
|
400
|
-
* the same string a pack entity's entries-map key (`entries.<kind>`) uses.
|
|
401
|
-
* Mirrors `contract-psl`'s `buildEntityTypesByDiscriminator`, recomposed here
|
|
402
|
-
* from the packs `ContractDefinition` already carries (`target` +
|
|
403
|
-
* `extensions`) since the TS assembler has no single pre-merged
|
|
404
|
-
* `AuthoringContributions` input to read the way the PSL interpreter does.
|
|
405
|
-
*/
|
|
406
|
-
function collectEntityTypeDescriptorsByDiscriminator(definition) {
|
|
407
|
-
const result = /* @__PURE__ */ new Map();
|
|
408
|
-
const walk = (namespace) => {
|
|
409
|
-
for (const value of Object.values(namespace)) if (isAuthoringEntityTypeDescriptor(value)) result.set(value.discriminator, value);
|
|
410
|
-
else walk(value);
|
|
411
|
-
};
|
|
412
|
-
const components = [definition.target, ...Object.values(definition.extensions ?? {})];
|
|
413
|
-
for (const component of components) {
|
|
414
|
-
const entityTypes = component.authoring?.entityTypes;
|
|
415
|
-
if (entityTypes !== void 0) walk(entityTypes);
|
|
416
|
-
}
|
|
417
|
-
return result;
|
|
418
|
-
}
|
|
419
|
-
/**
|
|
420
|
-
* Derives value-sets for every pack entity declared in one namespace,
|
|
421
|
-
* reusing the same `SqlValueSetDerivingEntityTypeOutput.deriveValueSet` hook
|
|
422
|
-
* `contract-psl`'s `lowerExtensionBlocksForNamespace` folds into
|
|
423
|
-
* `entries.valueSet` on the PSL path — so a TS-attached entity (e.g. a
|
|
424
|
-
* native enum) gets its value-set the same way. Entity kinds with no
|
|
425
|
-
* registered descriptor, or whose descriptor output doesn't derive a
|
|
426
|
-
* value-set, contribute nothing.
|
|
427
|
-
*/
|
|
428
|
-
function deriveEntityValueSets(entitiesForNs, entityTypesByDiscriminator) {
|
|
429
|
-
if (entitiesForNs === void 0) return void 0;
|
|
430
|
-
let result;
|
|
431
|
-
for (const [kind, entitiesByName] of Object.entries(entitiesForNs)) {
|
|
432
|
-
const descriptor = entityTypesByDiscriminator.get(kind);
|
|
433
|
-
if (descriptor === void 0) continue;
|
|
434
|
-
for (const [name, entity] of Object.entries(entitiesByName)) {
|
|
435
|
-
const derivedValueSet = deriveValueSetFromEntity(descriptor.output, entity);
|
|
436
|
-
if (derivedValueSet === void 0) continue;
|
|
437
|
-
result ??= {};
|
|
438
|
-
result[name] = derivedValueSet;
|
|
439
|
-
}
|
|
440
|
-
}
|
|
441
|
-
return result;
|
|
442
|
-
}
|
|
443
|
-
/**
|
|
444
|
-
* Merges a namespace's `enumType()`-derived value-sets with its pack-entity-
|
|
445
|
-
* derived value-sets. Both land in the same `entries.valueSet[name]` slot —
|
|
446
|
-
* which drives value-set → codec typing and the domain-enum CHECK — so a
|
|
447
|
-
* same-named entry in both would let one silently overwrite the other and
|
|
448
|
-
* corrupt whichever column resolves against it. The same collision class the
|
|
449
|
-
* `mergeColumnAndAttachedEntities` guard rejects; the PSL path already hard-errors
|
|
450
|
-
* on the equivalent (`interpretPslDocumentToSqlContract`). Reject it here too.
|
|
451
|
-
*/
|
|
452
|
-
function mergeNamespaceValueSets(namespaceId, enumValueSets, packValueSets) {
|
|
453
|
-
if (enumValueSets !== void 0 && packValueSets !== void 0) {
|
|
454
|
-
for (const name of Object.keys(packValueSets)) if (Object.hasOwn(enumValueSets, name)) throw contractError("CONTRACT.NAME_DUPLICATE", `buildSqlContractFromDefinition: value-set "${name}" in namespace "${namespaceId}" is derived from both an enum and a pack entity — names must be unique per namespace.`, { meta: {
|
|
455
|
-
kind: "valueSet",
|
|
456
|
-
name,
|
|
457
|
-
namespaceId
|
|
458
|
-
} });
|
|
459
|
-
}
|
|
460
|
-
return {
|
|
461
|
-
...enumValueSets,
|
|
462
|
-
...packValueSets
|
|
463
|
-
};
|
|
464
|
-
}
|
|
465
|
-
function ensureUnboundNamespaceSlot(namespaces, createNamespace) {
|
|
466
|
-
if (Object.hasOwn(namespaces, UNBOUND_NAMESPACE_ID)) return namespaces;
|
|
467
|
-
const unbound = createNamespace({
|
|
468
|
-
id: UNBOUND_NAMESPACE_ID,
|
|
469
|
-
entries: { table: {} }
|
|
470
|
-
});
|
|
471
|
-
return {
|
|
472
|
-
[UNBOUND_NAMESPACE_ID]: unbound,
|
|
473
|
-
...namespaces
|
|
474
|
-
};
|
|
475
|
-
}
|
|
476
|
-
const DERIVABLE_CHECK_KINDS = ["membership", "elementNotNull"];
|
|
477
|
-
/**
|
|
478
|
-
* Which of `columnNames` could have produced `prefix` for some
|
|
479
|
-
* {@link CheckKind} — the reverse of {@link derivedCheckPrefixes}, used only
|
|
480
|
-
* to name the collision in `CONTRACT.CHECK_NAME_RESERVED`'s message. Callers
|
|
481
|
-
* already know `prefix` is a member of `derivedCheckPrefixes(tableName,
|
|
482
|
-
* columnNames)`, so the result is never empty.
|
|
483
|
-
*/
|
|
484
|
-
function columnsProducingCheckPrefix(tableName, columnNames, prefix) {
|
|
485
|
-
return columnNames.filter((columnName) => DERIVABLE_CHECK_KINDS.some((kind) => composeCheckWirePrefix(tableName, columnName, kind) === prefix));
|
|
486
|
-
}
|
|
487
|
-
function buildSqlContractFromDefinition(definition, codecLookup) {
|
|
488
|
-
const target = definition.target.targetId;
|
|
489
|
-
const defaultNamespaceId = definition.target.defaultNamespaceId;
|
|
490
|
-
const qualifyColumnType = resolveColumnTypeQualifier(definition.target);
|
|
491
|
-
const renderCheckExpressions = resolveCheckExpressionRenderer(definition.target);
|
|
492
|
-
const targetFamily = "sql";
|
|
493
|
-
const resolveNamespaceId = (m) => m.namespaceId !== void 0 && m.namespaceId.length > 0 ? m.namespaceId : defaultNamespaceId;
|
|
494
|
-
const modelsByName = new Map(definition.models.map((m) => [m.modelName, m]));
|
|
495
|
-
const tableNamespaceByName = new Map(definition.models.map((m) => [m.tableName, m.namespaceId !== void 0 && m.namespaceId.length > 0 ? m.namespaceId : defaultNamespaceId]));
|
|
496
|
-
const modelsByCoordinate = new Map(definition.models.map((m) => [`${resolveNamespaceId(m)}:${m.modelName}`, m]));
|
|
497
|
-
const tablesByNamespace = {};
|
|
498
|
-
const authoringWarnings = [...definition.warnings ?? []];
|
|
499
|
-
const modelNameToNamespaceId = /* @__PURE__ */ new Map();
|
|
500
|
-
const executionDefaults = [];
|
|
501
|
-
const modelsByNamespace = {};
|
|
502
|
-
const collectedColumnEntities = {};
|
|
503
|
-
const rootEntries = [];
|
|
504
|
-
for (const semanticModel of definition.models) {
|
|
505
|
-
const tableName = semanticModel.tableName;
|
|
506
|
-
const namespaceId = semanticModel.namespaceId !== void 0 && semanticModel.namespaceId.length > 0 ? semanticModel.namespaceId : defaultNamespaceId;
|
|
507
|
-
modelNameToNamespaceId.set(semanticModel.modelName, namespaceId);
|
|
508
|
-
if (!semanticModel.sharesBaseTable) rootEntries.push({
|
|
509
|
-
tableName,
|
|
510
|
-
namespaceId,
|
|
511
|
-
ref: crossRef(semanticModel.modelName, namespaceId)
|
|
512
|
-
});
|
|
513
|
-
const columns = {};
|
|
514
|
-
const fieldToColumn = {};
|
|
515
|
-
const domainFields = {};
|
|
516
|
-
const domainFieldRefs = {};
|
|
517
|
-
const checksForTable = [];
|
|
518
|
-
const derivesChecks = effectiveControlPolicy(semanticModel.control, definition.defaultControlPolicy) === "managed";
|
|
519
|
-
for (const field of semanticModel.fields) {
|
|
520
|
-
const executionDefaultPhases = field.executionDefaults?.onCreate || field.executionDefaults?.onUpdate ? field.executionDefaults : void 0;
|
|
521
|
-
if (executionDefaultPhases) {
|
|
522
|
-
if (field.default !== void 0) throw contractError("CONTRACT.DEFAULT_INVALID", `Field "${semanticModel.modelName}.${field.fieldName}" cannot define both default and executionDefaults.`, { meta: {
|
|
523
|
-
modelName: semanticModel.modelName,
|
|
524
|
-
fieldName: field.fieldName,
|
|
525
|
-
reason: "default-and-executionDefaults"
|
|
526
|
-
} });
|
|
527
|
-
if (field.nullable) throw contractError("CONTRACT.DEFAULT_INVALID", `Field "${semanticModel.modelName}.${field.fieldName}" cannot be nullable when executionDefaults are present.`, { meta: {
|
|
528
|
-
modelName: semanticModel.modelName,
|
|
529
|
-
fieldName: field.fieldName,
|
|
530
|
-
reason: "nullable-with-executionDefaults"
|
|
531
|
-
} });
|
|
532
|
-
}
|
|
533
|
-
const enumHandle = !isValueObjectField(field) ? field.enumTypeHandle : void 0;
|
|
534
|
-
const storageValueSetRef = enumHandle !== void 0 ? {
|
|
535
|
-
plane: "storage",
|
|
536
|
-
entityKind: "valueSet",
|
|
537
|
-
namespaceId: defaultNamespaceId,
|
|
538
|
-
entityName: enumHandle.enumName
|
|
539
|
-
} : void 0;
|
|
540
|
-
const domainValueSetRef = enumHandle !== void 0 ? {
|
|
541
|
-
plane: "domain",
|
|
542
|
-
entityKind: "enum",
|
|
543
|
-
namespaceId: defaultNamespaceId,
|
|
544
|
-
entityName: enumHandle.enumName
|
|
545
|
-
} : void 0;
|
|
546
|
-
let resolvedField = field;
|
|
547
|
-
if (!isValueObjectField(field)) {
|
|
548
|
-
let descriptor = field.descriptor;
|
|
549
|
-
const entityRef = descriptor.entityRef;
|
|
550
|
-
if (entityRef !== void 0) {
|
|
551
|
-
collectEntityFromColumn(collectedColumnEntities, namespaceId, entityRef);
|
|
552
|
-
descriptor = resolveEntityRefDescriptor(descriptor, namespaceId);
|
|
553
|
-
}
|
|
554
|
-
descriptor = qualifyColumnDescriptor(descriptor, namespaceId, qualifyColumnType);
|
|
555
|
-
if (descriptor !== field.descriptor) resolvedField = {
|
|
556
|
-
...field,
|
|
557
|
-
descriptor
|
|
558
|
-
};
|
|
559
|
-
}
|
|
560
|
-
if (!isValueObjectField(resolvedField) && resolvedField.noCheck !== void 0) {
|
|
561
|
-
const { noCheck: authoredNoCheck, ...withoutNoCheck } = resolvedField;
|
|
562
|
-
resolvedField = derivesChecks ? {
|
|
563
|
-
...withoutNoCheck,
|
|
564
|
-
noCheck: resolveNoCheckKinds({
|
|
565
|
-
modelName: semanticModel.modelName,
|
|
566
|
-
fieldName: field.fieldName,
|
|
567
|
-
kinds: authoredNoCheck,
|
|
568
|
-
many: resolvedField.many === true,
|
|
569
|
-
isDomainEnum: enumHandle !== void 0
|
|
570
|
-
})
|
|
571
|
-
} : withoutNoCheck;
|
|
572
|
-
}
|
|
573
|
-
const column = buildStorageColumn(resolvedField, storageValueSetRef, codecLookup);
|
|
574
|
-
columns[field.columnName] = column;
|
|
575
|
-
fieldToColumn[field.fieldName] = field.columnName;
|
|
576
|
-
if (renderCheckExpressions !== void 0 && derivesChecks) {
|
|
577
|
-
const waivedKinds = !isValueObjectField(resolvedField) ? resolvedField.noCheck : void 0;
|
|
578
|
-
checksForTable.push(...lowerRenderedChecks(tableName, renderCheckExpressions({
|
|
579
|
-
tableName,
|
|
580
|
-
columnName: field.columnName,
|
|
581
|
-
many: column.many === true,
|
|
582
|
-
memberValues: enumHandle !== void 0 ? checkMemberValues(enumHandle, codecLookup) : void 0
|
|
583
|
-
}).filter((candidate) => !(waivedKinds?.includes(candidate.kind) ?? false))));
|
|
584
|
-
}
|
|
585
|
-
domainFields[field.fieldName] = buildDomainField(field, column, domainValueSetRef);
|
|
586
|
-
if (isValueObjectField(field)) domainFieldRefs[field.fieldName] = {
|
|
587
|
-
kind: "valueObject",
|
|
588
|
-
name: field.valueObjectName,
|
|
589
|
-
...field.many ? { many: true } : {}
|
|
590
|
-
};
|
|
591
|
-
else if (field.many) domainFieldRefs[field.fieldName] = {
|
|
592
|
-
kind: "scalar",
|
|
593
|
-
many: true
|
|
594
|
-
};
|
|
595
|
-
if (executionDefaultPhases) executionDefaults.push({
|
|
596
|
-
ref: {
|
|
597
|
-
namespace: namespaceId,
|
|
598
|
-
table: tableName,
|
|
599
|
-
column: field.columnName
|
|
600
|
-
},
|
|
601
|
-
...ifDefined("onCreate", executionDefaultPhases.onCreate),
|
|
602
|
-
...ifDefined("onUpdate", executionDefaultPhases.onUpdate)
|
|
603
|
-
});
|
|
604
|
-
}
|
|
605
|
-
const authoringForeignKeys = (semanticModel.foreignKeys ?? []).map((fk) => {
|
|
606
|
-
if (fk.references.spaceId !== void 0) {
|
|
607
|
-
const targetNamespaceId = fk.references.namespaceId ?? defaultNamespaceId;
|
|
608
|
-
return {
|
|
609
|
-
source: {
|
|
610
|
-
namespaceId: asNamespaceId(namespaceId),
|
|
611
|
-
tableName,
|
|
612
|
-
columns: fk.columns
|
|
613
|
-
},
|
|
614
|
-
target: {
|
|
615
|
-
namespaceId: asNamespaceId(targetNamespaceId),
|
|
616
|
-
tableName: fk.references.table,
|
|
617
|
-
columns: fk.references.columns,
|
|
618
|
-
spaceId: fk.references.spaceId
|
|
619
|
-
},
|
|
620
|
-
...applyFkDefaults({
|
|
621
|
-
...ifDefined("constraint", fk.constraint),
|
|
622
|
-
...ifDefined("index", fk.index)
|
|
623
|
-
}, definition.foreignKeyDefaults),
|
|
624
|
-
...ifDefined("name", fk.name),
|
|
625
|
-
...ifDefined("onDelete", fk.onDelete),
|
|
626
|
-
...ifDefined("onUpdate", fk.onUpdate)
|
|
627
|
-
};
|
|
628
|
-
}
|
|
629
|
-
const targetModel = assertKnownTargetModel(modelsByName, modelsByCoordinate, semanticModel.modelName, fk.references.model, fk.references.namespaceId, "Foreign key");
|
|
630
|
-
assertTargetTableMatches(semanticModel.modelName, targetModel, fk.references.table, "Foreign key");
|
|
631
|
-
const targetNamespaceId = fk.references.namespaceId ?? (targetModel.namespaceId !== void 0 && targetModel.namespaceId.length > 0 ? targetModel.namespaceId : defaultNamespaceId);
|
|
632
|
-
return {
|
|
633
|
-
source: {
|
|
634
|
-
namespaceId: asNamespaceId(namespaceId),
|
|
635
|
-
tableName,
|
|
636
|
-
columns: fk.columns
|
|
637
|
-
},
|
|
638
|
-
target: {
|
|
639
|
-
namespaceId: asNamespaceId(targetNamespaceId),
|
|
640
|
-
tableName: fk.references.table,
|
|
641
|
-
columns: fk.references.columns
|
|
642
|
-
},
|
|
643
|
-
...applyFkDefaults({
|
|
644
|
-
...ifDefined("constraint", fk.constraint),
|
|
645
|
-
...ifDefined("index", fk.index)
|
|
646
|
-
}, definition.foreignKeyDefaults),
|
|
647
|
-
...ifDefined("name", fk.name),
|
|
648
|
-
...ifDefined("onDelete", fk.onDelete),
|
|
649
|
-
...ifDefined("onUpdate", fk.onUpdate)
|
|
650
|
-
};
|
|
651
|
-
});
|
|
652
|
-
if (semanticModel.sharesBaseTable && semanticModel.checks && semanticModel.checks.length > 0) throw contractError("CONTRACT.CHECK_ON_STI_VARIANT", `Model "${semanticModel.modelName}" declares a check constraint but shares its base model's storage table (single-table inheritance) and has no table of its own to declare it on. Declare the check on the base model instead.`, { meta: {
|
|
653
|
-
tableName,
|
|
654
|
-
modelName: semanticModel.modelName
|
|
655
|
-
} });
|
|
656
|
-
if (!semanticModel.sharesBaseTable) {
|
|
657
|
-
const uniques = (semanticModel.uniques ?? []).map((u) => ({
|
|
658
|
-
columns: u.columns,
|
|
659
|
-
...ifDefined("name", u.name)
|
|
660
|
-
}));
|
|
661
|
-
const declaredIndexes = (semanticModel.indexes ?? []).map((i) => lowerAuthoredIndex(tableName, blindCast({
|
|
662
|
-
...ifDefined("columns", i.columns),
|
|
663
|
-
...ifDefined("expression", i.expression),
|
|
664
|
-
where: i.where,
|
|
665
|
-
unique: i.unique,
|
|
666
|
-
map: i.map,
|
|
667
|
-
name: i.name,
|
|
668
|
-
type: i.type,
|
|
669
|
-
options: i.options
|
|
670
|
-
}), authoringWarnings));
|
|
671
|
-
if (semanticModel.checks !== void 0 && semanticModel.checks.length > 0) {
|
|
672
|
-
const tableColumnNames = Object.keys(columns);
|
|
673
|
-
const reservedCheckPrefixes = derivedCheckPrefixes(tableName, tableColumnNames);
|
|
674
|
-
for (const authoredCheck of semanticModel.checks) {
|
|
675
|
-
const lowered = lowerAuthoredCheck(tableName, authoredCheck, authoringWarnings);
|
|
676
|
-
if (lowered.naming.kind === "wire" && reservedCheckPrefixes.has(lowered.naming.prefix)) {
|
|
677
|
-
const collidingColumns = columnsProducingCheckPrefix(tableName, tableColumnNames, lowered.naming.prefix);
|
|
678
|
-
const columnList = collidingColumns.map((name) => `"${name}"`).join(", ");
|
|
679
|
-
throw contractError("CONTRACT.CHECK_NAME_RESERVED", `Check "${lowered.naming.prefix}" on table "${tableName}": this name's prefix matches the shape a derived enforcement check would use for column${collidingColumns.length === 1 ? "" : "s"} ${columnList} of this table, so it can't be told apart from one. Choose a different name.`, { meta: {
|
|
680
|
-
tableName,
|
|
681
|
-
prefix: lowered.naming.prefix,
|
|
682
|
-
collidingColumns
|
|
683
|
-
} });
|
|
684
|
-
}
|
|
685
|
-
checksForTable.push(new CheckConstraint(lowered));
|
|
686
|
-
}
|
|
687
|
-
}
|
|
688
|
-
const primaryKey = semanticModel.id ? {
|
|
689
|
-
columns: semanticModel.id.columns,
|
|
690
|
-
...ifDefined("name", semanticModel.id.name)
|
|
691
|
-
} : void 0;
|
|
692
|
-
const { foreignKeys, indexes } = materializeForeignKeysAndIndexes(tableName, authoringForeignKeys, declaredIndexes, uniques, primaryKey);
|
|
693
|
-
const tableInput = {
|
|
694
|
-
columns,
|
|
695
|
-
...ifDefined("control", semanticModel.control),
|
|
696
|
-
uniques,
|
|
697
|
-
indexes: indexes.map((i) => new Index(i)),
|
|
698
|
-
foreignKeys,
|
|
699
|
-
...primaryKey ? { primaryKey } : {},
|
|
700
|
-
...checksForTable.length > 0 ? { checks: checksForTable } : {}
|
|
701
|
-
};
|
|
702
|
-
let nsTables = tablesByNamespace[namespaceId];
|
|
703
|
-
if (nsTables === void 0) {
|
|
704
|
-
nsTables = {};
|
|
705
|
-
tablesByNamespace[namespaceId] = nsTables;
|
|
706
|
-
}
|
|
707
|
-
if (nsTables[tableName] !== void 0) throw contractError("CONTRACT.NAME_DUPLICATE", `buildSqlContractFromDefinition: duplicate table "${tableName}" in namespace "${namespaceId}".`, { meta: {
|
|
708
|
-
kind: "table",
|
|
709
|
-
name: tableName,
|
|
710
|
-
namespaceId
|
|
711
|
-
} });
|
|
712
|
-
nsTables[tableName] = tableInput;
|
|
713
|
-
}
|
|
714
|
-
const storageFields = {};
|
|
715
|
-
for (const [fieldName, columnName] of Object.entries(fieldToColumn)) storageFields[fieldName] = { column: columnName };
|
|
716
|
-
const columnToField = new Map(Object.entries(fieldToColumn).map(([field, col]) => [col, field]));
|
|
717
|
-
const modelRelations = {};
|
|
718
|
-
for (const relation of semanticModel.relations ?? []) {
|
|
719
|
-
if (relation.spaceId !== void 0) {
|
|
720
|
-
const targetNamespaceId = relation.namespaceId ?? defaultNamespaceId;
|
|
721
|
-
modelRelations[relation.fieldName] = {
|
|
722
|
-
to: crossRef(relation.toModel, targetNamespaceId, relation.spaceId),
|
|
723
|
-
cardinality: "N:1",
|
|
724
|
-
on: {
|
|
725
|
-
localFields: relation.on.parentColumns.map((col) => columnToField.get(col) ?? col),
|
|
726
|
-
targetFields: relation.on.childColumns
|
|
727
|
-
}
|
|
728
|
-
};
|
|
729
|
-
continue;
|
|
730
|
-
}
|
|
731
|
-
const targetModel = assertKnownTargetModel(modelsByName, modelsByCoordinate, semanticModel.modelName, relation.toModel, relation.toNamespaceId, "Relation");
|
|
732
|
-
assertTargetTableMatches(semanticModel.modelName, targetModel, relation.toTable, "Relation");
|
|
733
|
-
const targetColumnToField = new Map(targetModel.fields.map((f) => [f.columnName, f.fieldName]));
|
|
734
|
-
const to = crossRef(relation.toModel, relation.toNamespaceId !== void 0 && relation.toNamespaceId.length > 0 ? relation.toNamespaceId : resolveModelNamespaceId(targetModel, modelNameToNamespaceId, defaultNamespaceId));
|
|
735
|
-
const on = {
|
|
736
|
-
localFields: relation.on.parentColumns.map((col) => columnToField.get(col) ?? col),
|
|
737
|
-
targetFields: relation.on.childColumns.map((col) => targetColumnToField.get(col) ?? col)
|
|
738
|
-
};
|
|
739
|
-
if (relation.cardinality === "N:M") {
|
|
740
|
-
if (!relation.through) throw contractError("CONTRACT.RELATION_INVALID", `Relation "${semanticModel.modelName}.${relation.fieldName}" with cardinality "N:M" requires through metadata`, { meta: {
|
|
741
|
-
modelName: semanticModel.modelName,
|
|
742
|
-
relationName: relation.fieldName,
|
|
743
|
-
reason: "many-to-many-missing-through"
|
|
744
|
-
} });
|
|
745
|
-
modelRelations[relation.fieldName] = {
|
|
746
|
-
to,
|
|
747
|
-
cardinality: "N:M",
|
|
748
|
-
on,
|
|
749
|
-
through: buildThroughDescriptor(relation.through, tableNamespaceByName, targetModel, semanticModel.modelName, relation.fieldName, defaultNamespaceId)
|
|
750
|
-
};
|
|
751
|
-
} else modelRelations[relation.fieldName] = {
|
|
752
|
-
to,
|
|
753
|
-
cardinality: relation.cardinality,
|
|
754
|
-
on
|
|
755
|
-
};
|
|
756
|
-
}
|
|
757
|
-
let namespaceModels = modelsByNamespace[namespaceId];
|
|
758
|
-
if (namespaceModels === void 0) {
|
|
759
|
-
namespaceModels = {};
|
|
760
|
-
modelsByNamespace[namespaceId] = namespaceModels;
|
|
761
|
-
}
|
|
762
|
-
namespaceModels[semanticModel.modelName] = {
|
|
763
|
-
storage: {
|
|
764
|
-
table: tableName,
|
|
765
|
-
namespaceId,
|
|
766
|
-
fields: storageFields
|
|
767
|
-
},
|
|
768
|
-
fields: domainFields,
|
|
769
|
-
relations: modelRelations
|
|
770
|
-
};
|
|
771
|
-
}
|
|
772
|
-
const rootTableNameCounts = /* @__PURE__ */ new Map();
|
|
773
|
-
for (const entry of rootEntries) rootTableNameCounts.set(entry.tableName, (rootTableNameCounts.get(entry.tableName) ?? 0) + 1);
|
|
774
|
-
const roots = {};
|
|
775
|
-
for (const entry of rootEntries) {
|
|
776
|
-
const key = (rootTableNameCounts.get(entry.tableName) ?? 0) > 1 ? `${entry.namespaceId}.${entry.tableName}` : entry.tableName;
|
|
777
|
-
roots[key] = entry.ref;
|
|
778
|
-
}
|
|
779
|
-
const rawStorageTypes = definition.storageTypes ?? {};
|
|
780
|
-
const documentTypes = Object.fromEntries(Object.entries(rawStorageTypes).map(([name, entry]) => {
|
|
781
|
-
if (entry.kind === "codec-instance") return [name, entry];
|
|
782
|
-
return [name, toStorageTypeInstance({
|
|
783
|
-
codecId: entry.codecId,
|
|
784
|
-
nativeType: entry.nativeType,
|
|
785
|
-
typeParams: entry.typeParams ?? {}
|
|
786
|
-
})];
|
|
787
|
-
}));
|
|
788
|
-
const namespaceCoordinateIds = collectStorageNamespaceCoordinateIds(definition);
|
|
789
|
-
const domainEnumsByNs = {};
|
|
790
|
-
const storageValueSetsByNs = {};
|
|
791
|
-
for (const [enumName, handle] of Object.entries(definition.enums ?? {})) {
|
|
792
|
-
if (enumName !== handle.enumName) throw contractError("CONTRACT.ENUM_INVALID", `enum declaration key "${enumName}" must match enumType name "${handle.enumName}". Aliases are not supported.`, { meta: {
|
|
793
|
-
enumName: handle.enumName,
|
|
794
|
-
declarationKey: enumName,
|
|
795
|
-
reason: "key-name-mismatch"
|
|
796
|
-
} });
|
|
797
|
-
const nsId = defaultNamespaceId;
|
|
798
|
-
let domainSlot = domainEnumsByNs[nsId];
|
|
799
|
-
if (domainSlot === void 0) {
|
|
800
|
-
domainSlot = {};
|
|
801
|
-
domainEnumsByNs[nsId] = domainSlot;
|
|
802
|
-
}
|
|
803
|
-
domainSlot[enumName] = {
|
|
804
|
-
codecId: handle.codecId,
|
|
805
|
-
members: handle.enumMembers.map((m) => ({
|
|
806
|
-
name: m.name,
|
|
807
|
-
value: encodeViaCodec(m.value, handle.codecId, codecLookup)
|
|
808
|
-
}))
|
|
809
|
-
};
|
|
810
|
-
let storageSlot = storageValueSetsByNs[nsId];
|
|
811
|
-
if (storageSlot === void 0) {
|
|
812
|
-
storageSlot = {};
|
|
813
|
-
storageValueSetsByNs[nsId] = storageSlot;
|
|
814
|
-
}
|
|
815
|
-
storageSlot[enumName] = {
|
|
816
|
-
kind: "valueSet",
|
|
817
|
-
values: handle.values.map((v) => encodeViaCodec(v, handle.codecId, codecLookup))
|
|
818
|
-
};
|
|
819
|
-
}
|
|
820
|
-
const { createNamespace } = definition;
|
|
821
|
-
const entityTypesByDiscriminator = collectEntityTypeDescriptorsByDiscriminator(definition);
|
|
822
|
-
const namespaces = Object.fromEntries([...namespaceCoordinateIds].sort().map((id) => {
|
|
823
|
-
const entitiesForNs = mergeColumnAndAttachedEntities(id, definition.attachedEntities?.[id], collectedColumnEntities[id]);
|
|
824
|
-
assertNoManagedEntityKinds(id, entitiesForNs);
|
|
825
|
-
const enumValueSetEntries = storageValueSetsByNs[id];
|
|
826
|
-
const packValueSetEntries = deriveEntityValueSets(entitiesForNs, entityTypesByDiscriminator);
|
|
827
|
-
const valueSetEntries = enumValueSetEntries !== void 0 || packValueSetEntries !== void 0 ? mergeNamespaceValueSets(id, enumValueSetEntries, packValueSetEntries) : void 0;
|
|
828
|
-
const nsInput = {
|
|
829
|
-
id,
|
|
830
|
-
entries: {
|
|
831
|
-
table: tablesByNamespace[id] ?? {},
|
|
832
|
-
...entitiesForNs,
|
|
833
|
-
...valueSetEntries !== void 0 && Object.keys(valueSetEntries).length > 0 ? { valueSet: valueSetEntries } : {}
|
|
834
|
-
}
|
|
835
|
-
};
|
|
836
|
-
return [id, createNamespace(nsInput)];
|
|
837
|
-
}));
|
|
838
|
-
const storageWithoutHash = {
|
|
839
|
-
...Object.keys(documentTypes).length > 0 ? { types: documentTypes } : {},
|
|
840
|
-
namespaces: defaultNamespaceId === UNBOUND_NAMESPACE_ID ? ensureUnboundNamespaceSlot(namespaces, createNamespace) : namespaces
|
|
841
|
-
};
|
|
842
|
-
const storageHash = definition.storageHash ? coreHash(definition.storageHash) : computeStorageHash({
|
|
843
|
-
target,
|
|
844
|
-
targetFamily,
|
|
845
|
-
storage: storageWithoutHash,
|
|
846
|
-
...sqlContractCanonicalizationHooks
|
|
847
|
-
});
|
|
848
|
-
const storage = new SqlStorage({
|
|
849
|
-
...storageWithoutHash,
|
|
850
|
-
storageHash
|
|
851
|
-
});
|
|
852
|
-
const executionSection = executionDefaults.length > 0 ? { mutations: { defaults: executionDefaults.sort((a, b) => {
|
|
853
|
-
const tableCompare = a.ref.table.localeCompare(b.ref.table);
|
|
854
|
-
if (tableCompare !== 0) return tableCompare;
|
|
855
|
-
return a.ref.column.localeCompare(b.ref.column);
|
|
856
|
-
}) } } : void 0;
|
|
857
|
-
const extensionNamespaces = definition.extensions ? Object.values(definition.extensions).map((pack) => pack.id) : void 0;
|
|
858
|
-
const extensions = { ...definition.extensions || {} };
|
|
859
|
-
if (extensionNamespaces) {
|
|
860
|
-
for (const namespace of extensionNamespaces) if (!Object.hasOwn(extensions, namespace)) extensions[namespace] = {};
|
|
861
|
-
}
|
|
862
|
-
const extensionPackCapabilitySources = definition.extensions ? Object.values(definition.extensions).map((pack) => pack.capabilities) : [];
|
|
863
|
-
const capabilities = mergeCapabilityMatrices(definition.target.capabilities, ...extensionPackCapabilitySources);
|
|
864
|
-
const profileHash = computeProfileHash({
|
|
865
|
-
target,
|
|
866
|
-
targetFamily,
|
|
867
|
-
capabilities: {}
|
|
868
|
-
});
|
|
869
|
-
const executionWithHash = executionSection ? {
|
|
870
|
-
...executionSection,
|
|
871
|
-
executionHash: computeExecutionHash({
|
|
872
|
-
target,
|
|
873
|
-
targetFamily,
|
|
874
|
-
execution: executionSection
|
|
875
|
-
})
|
|
876
|
-
} : void 0;
|
|
877
|
-
const valueObjects = definition.valueObjects && definition.valueObjects.length > 0 ? Object.fromEntries(definition.valueObjects.map((vo) => [vo.name, { fields: Object.fromEntries(vo.fields.map((f) => [f.fieldName, isValueObjectField(f) ? {
|
|
878
|
-
type: {
|
|
879
|
-
kind: "valueObject",
|
|
880
|
-
name: f.valueObjectName
|
|
881
|
-
},
|
|
882
|
-
nullable: f.nullable,
|
|
883
|
-
...f.many ? { many: true } : {}
|
|
884
|
-
} : {
|
|
885
|
-
type: {
|
|
886
|
-
kind: "scalar",
|
|
887
|
-
codecId: f.descriptor.codecId,
|
|
888
|
-
...ifDefined("typeParams", f.descriptor.typeParams)
|
|
889
|
-
},
|
|
890
|
-
nullable: f.nullable
|
|
891
|
-
}])) }])) : void 0;
|
|
892
|
-
const domainNamespaceIds = new Set(Object.keys(modelsByNamespace));
|
|
893
|
-
if (domainNamespaceIds.size === 0) domainNamespaceIds.add(defaultNamespaceId);
|
|
894
|
-
if (valueObjects !== void 0) domainNamespaceIds.add(defaultNamespaceId);
|
|
895
|
-
for (const nsId of Object.keys(domainEnumsByNs)) domainNamespaceIds.add(nsId);
|
|
896
|
-
const domainNamespaces = Object.fromEntries([...domainNamespaceIds].sort().map((namespaceId) => {
|
|
897
|
-
const modelsInNs = modelsByNamespace[namespaceId] ?? {};
|
|
898
|
-
const enumsInNs = domainEnumsByNs[namespaceId];
|
|
899
|
-
return [namespaceId, {
|
|
900
|
-
models: modelsInNs,
|
|
901
|
-
...namespaceId === defaultNamespaceId && valueObjects !== void 0 ? { valueObjects } : {},
|
|
902
|
-
...enumsInNs !== void 0 && Object.keys(enumsInNs).length > 0 ? { enum: enumsInNs } : {}
|
|
903
|
-
}];
|
|
904
|
-
}));
|
|
905
|
-
const contract = {
|
|
906
|
-
target,
|
|
907
|
-
targetFamily,
|
|
908
|
-
...ifDefined("defaultControlPolicy", definition.defaultControlPolicy),
|
|
909
|
-
domain: { namespaces: domainNamespaces },
|
|
910
|
-
roots,
|
|
911
|
-
storage,
|
|
912
|
-
...executionWithHash ? { execution: executionWithHash } : {},
|
|
913
|
-
extensions,
|
|
914
|
-
capabilities,
|
|
915
|
-
profileHash,
|
|
916
|
-
meta: {}
|
|
917
|
-
};
|
|
918
|
-
assertStorageSemantics(definition, contract);
|
|
919
|
-
flushAuthoringWarnings(authoringWarnings);
|
|
920
|
-
return contract;
|
|
921
|
-
}
|
|
922
|
-
/**
|
|
923
|
-
* The one step every SQL contract specifier funnels its loaded contract
|
|
924
|
-
* through: stamp the specifier's default control policy, then strip derived
|
|
925
|
-
* checks from every table the stamped policy leaves non-managed. Composing the
|
|
926
|
-
* two here is what keeps the managed-only consequence from being skipped on
|
|
927
|
-
* any specifier route.
|
|
928
|
-
*/
|
|
929
|
-
function applySqlSpecifierControlPolicy(contract, defaultControlPolicy, createNamespace) {
|
|
930
|
-
return stripDerivedChecksFromNonManagedTables(applySpecifierDefaultControlPolicy(contract, defaultControlPolicy), createNamespace);
|
|
931
|
-
}
|
|
932
|
-
/**
|
|
933
|
-
* Removes generated enforcement checks from every table whose effective
|
|
934
|
-
* control policy is not `managed`.
|
|
935
|
-
*
|
|
936
|
-
* A check is derived iff its wire prefix is one derivation would produce for
|
|
937
|
-
* some column of its table — {@link derivedCheckPrefixes} enumerates that
|
|
938
|
-
* set. Wire-naming alone no longer identifies derivation: an authored
|
|
939
|
-
* `name:` check (`@@check` / `check()`) is wire-named too, so a bare
|
|
940
|
-
* `check.prefix === undefined` test would delete an author's own constraint
|
|
941
|
-
* from every non-`managed` table. The prefix-shape rule tests against the
|
|
942
|
-
* table's own columns instead of the naming mode, so an authored check with
|
|
943
|
-
* an unrelated prefix survives.
|
|
944
|
-
*
|
|
945
|
-
* The rule is weaker than recomputing the content hash `contract infer`
|
|
946
|
-
* uses: that needs `postgresRenderCheckExpressions` to know what a kind
|
|
947
|
-
* renders, and this funnel has no target descriptor to reach it through. It
|
|
948
|
-
* can only ask whether some column could have produced a prefix of this
|
|
949
|
-
* shape, not whether this exact column produced this exact check. The gap
|
|
950
|
-
* that opens — an authored name that collides with a derived-prefix shape —
|
|
951
|
-
* is closed at authoring time instead: such a name is rejected
|
|
952
|
-
* (`CONTRACT.CHECK_NAME_RESERVED`) before it ever reaches storage.
|
|
953
|
-
*
|
|
954
|
-
* Why derivation stops at the namespace boundary: the contract *describes* an
|
|
955
|
-
* external schema, it does not *prescribe* enforcement for it. Deriving a check
|
|
956
|
-
* for a table Prisma Next never creates declares a constraint the live database
|
|
957
|
-
* has no reason to carry, and `external` fails verify on a declared shape the
|
|
958
|
-
* database lacks — an unfixable failure, since no plan may emit DDL there
|
|
959
|
-
* either.
|
|
960
|
-
*
|
|
961
|
-
* This is the post-build half of the rule. Authoring skips derivation for a
|
|
962
|
-
* table whose policy is known in the source; this pass catches the policy a
|
|
963
|
-
* contract *specifier* applies after the contract is already built, which is
|
|
964
|
-
* the only signal a pack like the Supabase extension gives. Specifiers reach
|
|
965
|
-
* it through `applySqlSpecifierControlPolicy` above.
|
|
966
|
-
*
|
|
967
|
-
* Returns the contract unchanged (same reference) when nothing is stripped.
|
|
968
|
-
* When something is, the storage hash is recomputed — the stripped contract
|
|
969
|
-
* describes different storage.
|
|
970
|
-
*/
|
|
971
|
-
function stripDerivedChecksFromNonManagedTables(contract, createNamespace) {
|
|
972
|
-
const storage = contract.storage;
|
|
973
|
-
if (!isSqlStorageShaped(storage)) return contract;
|
|
974
|
-
let anyStripped = false;
|
|
975
|
-
const namespaces = {};
|
|
976
|
-
for (const [namespaceId, namespace] of Object.entries(storage.namespaces)) {
|
|
977
|
-
if (!isMaterializedSqlNamespace(namespace)) return contract;
|
|
978
|
-
const tables = namespace.entries["table"];
|
|
979
|
-
if (tables === void 0) {
|
|
980
|
-
namespaces[namespaceId] = namespace;
|
|
981
|
-
continue;
|
|
982
|
-
}
|
|
983
|
-
let namespaceStripped = false;
|
|
984
|
-
const nextTables = {};
|
|
985
|
-
for (const [tableName, table] of Object.entries(tables)) {
|
|
986
|
-
const stripped = StorageTable.is(table) ? withoutDerivedChecks(tableName, table, contract.defaultControlPolicy) : table;
|
|
987
|
-
if (stripped !== table) namespaceStripped = true;
|
|
988
|
-
nextTables[tableName] = stripped;
|
|
989
|
-
}
|
|
990
|
-
if (!namespaceStripped) {
|
|
991
|
-
namespaces[namespaceId] = namespace;
|
|
992
|
-
continue;
|
|
993
|
-
}
|
|
994
|
-
anyStripped = true;
|
|
995
|
-
namespaces[namespaceId] = createNamespace({
|
|
996
|
-
id: namespace.id,
|
|
997
|
-
entries: {
|
|
998
|
-
...namespace.entries,
|
|
999
|
-
table: nextTables
|
|
1000
|
-
}
|
|
1001
|
-
});
|
|
1002
|
-
}
|
|
1003
|
-
if (!anyStripped) return contract;
|
|
1004
|
-
const storageWithoutHash = {
|
|
1005
|
-
namespaces,
|
|
1006
|
-
...ifDefined("types", storage.types)
|
|
1007
|
-
};
|
|
1008
|
-
return {
|
|
1009
|
-
...contract,
|
|
1010
|
-
storage: new SqlStorage({
|
|
1011
|
-
...storageWithoutHash,
|
|
1012
|
-
storageHash: computeStorageHash({
|
|
1013
|
-
target: contract.target,
|
|
1014
|
-
targetFamily: contract.targetFamily,
|
|
1015
|
-
storage: storageWithoutHash,
|
|
1016
|
-
...sqlContractCanonicalizationHooks
|
|
1017
|
-
})
|
|
1018
|
-
})
|
|
1019
|
-
};
|
|
1020
|
-
}
|
|
1021
|
-
/**
|
|
1022
|
-
* Structural stand-in for `instanceof SqlStorage`: like the checks it wraps, a
|
|
1023
|
-
* storage instance can arrive from a realm whose IR classes are a separate
|
|
1024
|
-
* copy (the dist e2e shape), where an `instanceof` test would miss.
|
|
1025
|
-
*/
|
|
1026
|
-
function isSqlStorageShaped(x) {
|
|
1027
|
-
if (typeof x !== "object" || x === null || !("namespaces" in x)) return false;
|
|
1028
|
-
return typeof x.namespaces === "object" && x.namespaces !== null;
|
|
1029
|
-
}
|
|
1030
|
-
/** The table itself when it keeps every check, a rebuilt one when it does not. */
|
|
1031
|
-
function withoutDerivedChecks(tableName, table, contractDefault) {
|
|
1032
|
-
const checks = table.checks;
|
|
1033
|
-
if (checks === void 0 || checks.length === 0) return table;
|
|
1034
|
-
if (effectiveControlPolicy(table.control, contractDefault) === "managed") return table;
|
|
1035
|
-
const columnNames = Object.keys(table.columns);
|
|
1036
|
-
invariant(columnNames.length > 0, `withoutDerivedChecks: table "${tableName}" carries checks but its column map is empty. The caller must pass the table's real, complete column set — an empty or partial map makes every check misclassify as non-derived and survive the strip.`);
|
|
1037
|
-
const derivedPrefixes = derivedCheckPrefixes(tableName, columnNames);
|
|
1038
|
-
const kept = checks.filter((check) => check.prefix === void 0 || !derivedPrefixes.has(check.prefix));
|
|
1039
|
-
if (kept.length === checks.length) return table;
|
|
1040
|
-
return new StorageTable({
|
|
1041
|
-
columns: table.columns,
|
|
1042
|
-
uniques: table.uniques,
|
|
1043
|
-
indexes: table.indexes,
|
|
1044
|
-
foreignKeys: table.foreignKeys,
|
|
1045
|
-
...ifDefined("primaryKey", table.primaryKey),
|
|
1046
|
-
...ifDefined("control", table.control),
|
|
1047
|
-
...kept.length > 0 ? { checks: kept.map((check) => checkConstraintInputFromSerialized({
|
|
1048
|
-
name: check.name,
|
|
1049
|
-
...ifDefined("prefix", check.prefix),
|
|
1050
|
-
expression: check.expression
|
|
1051
|
-
})) } : {}
|
|
1052
|
-
});
|
|
1053
|
-
}
|
|
1054
|
-
//#endregion
|
|
1055
|
-
export { buildSqlContractFromDefinition as n, contractError as r, applySqlSpecifierControlPolicy as t };
|
|
1056
|
-
|
|
1057
|
-
//# sourceMappingURL=derived-checks-DFMRmiAu-DGfB8aS4.mjs.map
|