@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
|
@@ -0,0 +1,1960 @@
|
|
|
1
|
+
import { u as sqlCodecColumnLength } from "./sql-data-type-D7M-YTTY-D2vRqDxn.mjs";
|
|
2
|
+
import { p as sqlTextFromStored, t as SQL_EXPRESSION_DATA_TYPE_ID } from "./sql-expression-CKgKznXS.mjs";
|
|
3
|
+
import { n as checkSqlDefaultText, o as reservedSqlDefaultText } from "./validators-BwA7ttZM.mjs";
|
|
4
|
+
import { i as isValueObjectMember, o as storedAsListColumn } from "./derived-checks-D5HVRvqN-BJx1gwPA.mjs";
|
|
5
|
+
import { n as getAttribute, o as storageName, t as formatDbAttributeMigrationMessage } from "./psl-attribute-parsing-BCsFWsSp-BJ-wGlY6.mjs";
|
|
6
|
+
import { structuredError } from "@prisma/orm-framework/utils/structured-error";
|
|
7
|
+
import { ifDefined } from "@prisma/orm-framework/utils/defined";
|
|
8
|
+
import { admittedForms, castTypedValue, describeExpected, describeRefusal, describeRefusedValueType, exactRewrite, instantiateAuthoringTypeAlias, instantiateAuthoringTypeConstructor, isAuthoringEntityTypeDescriptor, readWrittenValue, tagForm, validateAuthoringHelperArguments, validateAuthoringTypeParams } from "@prisma/orm-framework/components/authoring";
|
|
9
|
+
import { codecForRef, dataTypeParams, readContractValue } from "@prisma/orm-framework/components/codec";
|
|
10
|
+
import { blindCast } from "@prisma/orm-framework/utils/casts";
|
|
11
|
+
import { InternalError, isInternalError } from "@prisma/orm-framework/utils/internal-error";
|
|
12
|
+
import { FunctionCallAst } from "@prisma/orm-framework/psl-parser/syntax";
|
|
13
|
+
import { invariant } from "@prisma/orm-framework/utils/assertions";
|
|
14
|
+
import { notOk, ok } from "@prisma/orm-framework/utils/result";
|
|
15
|
+
import { describeTaggedLiteralFailure as describeTaggedLiteralFailure$1 } from "@prisma/orm-framework/components/control";
|
|
16
|
+
import { bool, contributedTypeCodecId, contributedTypeOf, dataTypeValue, diagnosticSource, entityRef, fieldAttribute, fieldRef, funcCall, generatorAttributeSpec, identifier, interpretAttribute, leafDiagnostic, list, mapArg, modelAttribute, nodePslSpan, nodeSourceText, numLiteral, oneOf, optional, record, referencedFieldRef, refuseRepeatedTypeAliasAttributes, str, taggedLiteral, typeAttribute, typeAttributeSpecContextOfField, typeAttributeSubjectLabel, typeGeneratorAttributeSpec, typeReferenceNode, writtenList, writtenScalar } from "@prisma/orm-framework/psl-parser";
|
|
17
|
+
import { instantiatePslFieldPreset, isBareTypeConstructor, mapPslHelperArgs, reportPresetNotCalled, reportTypeConstructorNotCalled } from "@prisma/orm-framework/psl-parser/interpret";
|
|
18
|
+
//#region ../../../2-sql-family/2-authoring/contract-psl/dist/psl-field-resolution-C5KQ7kzP.mjs
|
|
19
|
+
function contractError(code, message, options) {
|
|
20
|
+
return structuredError(code, message, options);
|
|
21
|
+
}
|
|
22
|
+
/** A written value the column's type, under the column's parameters, or the column's codec refuses. */
|
|
23
|
+
const PSL_INVALID_DEFAULT_LITERAL = "PSL_INVALID_DEFAULT_LITERAL";
|
|
24
|
+
/** A written value whose data type the receiving type neither is nor casts from. */
|
|
25
|
+
const PSL_VALUE_TYPE_INCOMPATIBLE = "PSL_VALUE_TYPE_INCOMPATIBLE";
|
|
26
|
+
/** A single value written as the default of a column that holds a list. */
|
|
27
|
+
const PSL_DEFAULT_LIST_EXPECTED = "PSL_DEFAULT_LIST_EXPECTED";
|
|
28
|
+
function messageOf(error) {
|
|
29
|
+
return error instanceof Error ? error.message : String(error);
|
|
30
|
+
}
|
|
31
|
+
function refused(refusal, suggestedTypes) {
|
|
32
|
+
return {
|
|
33
|
+
ok: false,
|
|
34
|
+
refusal,
|
|
35
|
+
suggestedTypes
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
function readOneValue(dataTypes, written, elementIndex, suggestedTypes) {
|
|
39
|
+
const read = readWrittenValue(dataTypes, written);
|
|
40
|
+
return read.ok ? {
|
|
41
|
+
ok: true,
|
|
42
|
+
typed: read.value
|
|
43
|
+
} : refused({
|
|
44
|
+
...read.failure,
|
|
45
|
+
elementIndex
|
|
46
|
+
}, suggestedTypes);
|
|
47
|
+
}
|
|
48
|
+
/** The column's `typeParams` as the codec reference carries them, so `vector(3)` checks its length. */
|
|
49
|
+
function codecRefTypeParams(typeParams) {
|
|
50
|
+
return typeParams === void 0 ? void 0 : blindCast(typeParams);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* The column's codec descriptor, and `read`, which makes a value in its stored JSON form a value of the column's type under the column's parameters, and checks it with the column's codec, built with those parameters.
|
|
54
|
+
*/
|
|
55
|
+
function storedValueReader(input) {
|
|
56
|
+
const descriptor = input.lookups.codecLookup.descriptorFor(input.column.codecId);
|
|
57
|
+
const codec = codecForRef(input.lookups.codecLookup, {
|
|
58
|
+
codecId: input.column.codecId,
|
|
59
|
+
...ifDefined("typeParams", codecRefTypeParams(input.column.typeParams))
|
|
60
|
+
});
|
|
61
|
+
if (codec === void 0 || descriptor === void 0) throw new InternalError(`Field "${input.fieldPath}": no codec descriptor is registered for "${input.column.codecId}", but the column was resolved from one.`);
|
|
62
|
+
const suggestedTypes = [descriptor.dataType];
|
|
63
|
+
const params = dataTypeParams(codec.dataType, input.column.typeParams);
|
|
64
|
+
const read = (written, elementIndex) => {
|
|
65
|
+
let stored;
|
|
66
|
+
try {
|
|
67
|
+
const value = codec.dataType.valueFrom(written, params);
|
|
68
|
+
codec.fromDataTypeValue(value);
|
|
69
|
+
stored = codec.dataType.toContract(value);
|
|
70
|
+
} catch (error) {
|
|
71
|
+
if (isInternalError(error)) throw error;
|
|
72
|
+
return {
|
|
73
|
+
ok: false,
|
|
74
|
+
refusal: {
|
|
75
|
+
kind: "refused-by-column",
|
|
76
|
+
codecId: input.column.codecId,
|
|
77
|
+
message: messageOf(error),
|
|
78
|
+
elementIndex
|
|
79
|
+
},
|
|
80
|
+
suggestedTypes
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
return {
|
|
84
|
+
ok: true,
|
|
85
|
+
value: stored
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
return {
|
|
89
|
+
descriptor,
|
|
90
|
+
params,
|
|
91
|
+
read
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Reads a value already in its stored JSON form, such as one member of a JSON document default, as a value of the column's type checked by the column's codec. Worded as {@link lowerDataTypeDefault} words the same refusals.
|
|
96
|
+
*/
|
|
97
|
+
function readStoredValue(input) {
|
|
98
|
+
const reading = storedValueReader(input).read(input.value, void 0);
|
|
99
|
+
return reading.ok ? reading : {
|
|
100
|
+
ok: false,
|
|
101
|
+
...storedRefusalMessage(reading.refusal, `Field "${input.fieldPath}"`)
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Read one `@default(...)` value for a column, refusing in parts so each contract source words its
|
|
106
|
+
* own diagnostic. `isList` selects the check: a list column's elements are each read and cast
|
|
107
|
+
* against the element codec's data type, while a scalar column takes a written list only through
|
|
108
|
+
* its type's list cast — which is how `pgvector.Vector(3) @default([0.1, 0.2])` is read.
|
|
109
|
+
*/
|
|
110
|
+
function readDataTypeDefault(input) {
|
|
111
|
+
const { descriptor, params, read: readStored } = storedValueReader({
|
|
112
|
+
column: input.column,
|
|
113
|
+
lookups: {
|
|
114
|
+
codecLookup: input.codecLookup,
|
|
115
|
+
dataTypeLookup: input.dataTypes.lookup
|
|
116
|
+
},
|
|
117
|
+
fieldPath: input.fieldPath
|
|
118
|
+
});
|
|
119
|
+
const columnType = descriptor.dataType;
|
|
120
|
+
const suggestedTypes = [columnType];
|
|
121
|
+
const readOne = (written, elementIndex) => {
|
|
122
|
+
const read = readOneValue(input.dataTypes, written, elementIndex, suggestedTypes);
|
|
123
|
+
if (!read.ok) return read;
|
|
124
|
+
const cast = castTypedValue(input.dataTypes, columnType, params, read.typed);
|
|
125
|
+
if (!cast.ok) {
|
|
126
|
+
const { failure } = cast;
|
|
127
|
+
return failure.kind === "refused-by-type" ? refused({
|
|
128
|
+
kind: "refused-by-column",
|
|
129
|
+
codecId: input.column.codecId,
|
|
130
|
+
message: failure.message,
|
|
131
|
+
elementIndex
|
|
132
|
+
}, suggestedTypes) : refused({
|
|
133
|
+
...failure,
|
|
134
|
+
elementIndex
|
|
135
|
+
}, suggestedTypes);
|
|
136
|
+
}
|
|
137
|
+
return readStored(cast.value.value, elementIndex);
|
|
138
|
+
};
|
|
139
|
+
if (input.written.kind !== "list") {
|
|
140
|
+
if (input.isList) return refused({
|
|
141
|
+
kind: "not-a-list",
|
|
142
|
+
elementIndex: void 0
|
|
143
|
+
}, suggestedTypes);
|
|
144
|
+
return readOne(input.written, void 0);
|
|
145
|
+
}
|
|
146
|
+
if (input.isList) {
|
|
147
|
+
const elements = [];
|
|
148
|
+
for (const [elementIndex, written] of input.written.elements.entries()) {
|
|
149
|
+
if (written.kind === "list") return nestedList(elementIndex, suggestedTypes);
|
|
150
|
+
const element = readOne(written, elementIndex);
|
|
151
|
+
if (!element.ok) return element;
|
|
152
|
+
elements.push(element.value);
|
|
153
|
+
}
|
|
154
|
+
return {
|
|
155
|
+
ok: true,
|
|
156
|
+
value: elements
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
return readListIntoScalar({
|
|
160
|
+
...input,
|
|
161
|
+
written: input.written,
|
|
162
|
+
columnType,
|
|
163
|
+
readStored
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
function nestedList(elementIndex, suggestedTypes) {
|
|
167
|
+
return refused({
|
|
168
|
+
kind: "unreadable",
|
|
169
|
+
message: "a list holds values, not other lists",
|
|
170
|
+
elementIndex
|
|
171
|
+
}, suggestedTypes);
|
|
172
|
+
}
|
|
173
|
+
/** A written list on a column that is not a list: the column's type takes it through its list cast. */
|
|
174
|
+
function readListIntoScalar(input) {
|
|
175
|
+
const declaration = input.dataTypes.lookup.get(input.columnType);
|
|
176
|
+
const listCast = declaration?.listCast;
|
|
177
|
+
if (listCast === void 0) return refused({
|
|
178
|
+
kind: "no-list-cast",
|
|
179
|
+
receivingType: input.columnType,
|
|
180
|
+
casts: Object.keys(declaration?.casts ?? {}),
|
|
181
|
+
elementIndex: void 0
|
|
182
|
+
}, [input.columnType]);
|
|
183
|
+
const elements = [];
|
|
184
|
+
for (const [elementIndex, written] of input.written.elements.entries()) {
|
|
185
|
+
if (written.kind === "list") return nestedList(elementIndex, listCast.of);
|
|
186
|
+
const read = readOneValue(input.dataTypes, written, elementIndex, listCast.of);
|
|
187
|
+
if (!read.ok) return read;
|
|
188
|
+
if (!listCast.of.includes(read.typed.type)) return refused({
|
|
189
|
+
kind: "no-element-cast",
|
|
190
|
+
receivingType: input.columnType,
|
|
191
|
+
valueType: read.typed.type,
|
|
192
|
+
elementTypes: listCast.of,
|
|
193
|
+
elementIndex
|
|
194
|
+
}, listCast.of);
|
|
195
|
+
elements.push(read.typed.value);
|
|
196
|
+
}
|
|
197
|
+
try {
|
|
198
|
+
return input.readStored(listCast.cast(elements), void 0);
|
|
199
|
+
} catch (error) {
|
|
200
|
+
if (isInternalError(error)) throw error;
|
|
201
|
+
return refused({
|
|
202
|
+
kind: "unreadable",
|
|
203
|
+
message: messageOf(error),
|
|
204
|
+
elementIndex: void 0
|
|
205
|
+
}, [input.columnType]);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
/** Where a diagnostic is about, for a message: `Field "N.count" at element 2`. */
|
|
209
|
+
function location(subject, elementIndex) {
|
|
210
|
+
return elementIndex === void 0 ? subject : `${subject} at element ${elementIndex + 1}`;
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* What may be written where every one of `types` is received, each form once: `a number`. A column
|
|
214
|
+
* whose type nothing writes still takes a `sql` literal, which `@default` stores as a SQL expression.
|
|
215
|
+
*/
|
|
216
|
+
function formsOf(dataTypes, types) {
|
|
217
|
+
const forms = admittedForms(dataTypes, types);
|
|
218
|
+
return forms.length === 0 ? [tagForm("sql")] : forms;
|
|
219
|
+
}
|
|
220
|
+
/** The exact rewrite of the written value a `no-cast` refusal is about, before list elements are renumbered to the source list. */
|
|
221
|
+
function rewriteOf(refusal, written, dataTypes) {
|
|
222
|
+
if (refusal.kind !== "no-cast") return void 0;
|
|
223
|
+
const refused = refusal.elementIndex === void 0 || written.kind !== "list" ? written : written.elements[refusal.elementIndex];
|
|
224
|
+
return refused === void 0 || refused.kind === "list" ? void 0 : exactRewrite(dataTypes, refusal, refused);
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* {@link readDataTypeDefault} worded as a PSL diagnostic's code, message and span: a cast-rule
|
|
228
|
+
* refusal at the written value, or the element of a written list it is about; a refusal only
|
|
229
|
+
* defaults have at the `@default` attribute.
|
|
230
|
+
*/
|
|
231
|
+
function lowerDataTypeDefault(input) {
|
|
232
|
+
const read = readDataTypeDefault({
|
|
233
|
+
...input,
|
|
234
|
+
fieldPath: input.subject
|
|
235
|
+
});
|
|
236
|
+
if (read.ok) return read;
|
|
237
|
+
const refusal = atSourceElement(read.refusal, input.sourceElementIndexes);
|
|
238
|
+
return {
|
|
239
|
+
ok: false,
|
|
240
|
+
...refusalMessage(refusal, input.subject, input.dataTypes, guidanceFor(read, input.written, input.dataTypes)),
|
|
241
|
+
span: refusalSpan(refusal, input.spans, input.subject)
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
/** What a refusal of `written` tells the author to write instead. */
|
|
245
|
+
function guidanceFor(failure, written, dataTypes) {
|
|
246
|
+
return {
|
|
247
|
+
forms: formsOf(dataTypes, failure.suggestedTypes),
|
|
248
|
+
rewrite: rewriteOf(failure.refusal, written, dataTypes)
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
function atSourceElement(refusal, sourceElementIndexes) {
|
|
252
|
+
if (refusal.elementIndex === void 0) return refusal;
|
|
253
|
+
const elementIndex = sourceElementIndexes?.[refusal.elementIndex];
|
|
254
|
+
return elementIndex === void 0 ? refusal : {
|
|
255
|
+
...refusal,
|
|
256
|
+
elementIndex
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
function codecRefusalMessage(refusal, subject) {
|
|
260
|
+
return {
|
|
261
|
+
code: PSL_INVALID_DEFAULT_LITERAL,
|
|
262
|
+
message: `${location(subject, refusal.elementIndex)}: ${refusal.message}`
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
function storedRefusalMessage(refusal, subject) {
|
|
266
|
+
if (refusal.kind === "refused-by-column") return codecRefusalMessage(refusal, subject);
|
|
267
|
+
return {
|
|
268
|
+
code: "PSL_INVALID_LITERAL",
|
|
269
|
+
message: `${location(subject, refusal.elementIndex)}: ${refusal.message}`
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
/** A refusal worded as a PSL diagnostic's code and message; `guidance` says what to write instead. */
|
|
273
|
+
function refusalMessage(refusal, subject, dataTypes, guidance) {
|
|
274
|
+
const where = location(subject, refusal.elementIndex);
|
|
275
|
+
switch (refusal.kind) {
|
|
276
|
+
case "not-a-list": return {
|
|
277
|
+
code: PSL_DEFAULT_LIST_EXPECTED,
|
|
278
|
+
message: `${where}: this column holds a list, so its default is a list literal, as in [1, 2]`
|
|
279
|
+
};
|
|
280
|
+
case "refused-by-column": return codecRefusalMessage(refusal, subject);
|
|
281
|
+
case "no-list-cast": return {
|
|
282
|
+
code: PSL_VALUE_TYPE_INCOMPATIBLE,
|
|
283
|
+
message: `${where}: ${describeExpected(guidance.forms)}; got a list`
|
|
284
|
+
};
|
|
285
|
+
case "no-element-cast": return {
|
|
286
|
+
code: PSL_VALUE_TYPE_INCOMPATIBLE,
|
|
287
|
+
message: `${where}: ${describeRefusedValueType(refusal, dataTypes, guidance)}`
|
|
288
|
+
};
|
|
289
|
+
default: {
|
|
290
|
+
const { code, message } = describeRefusal(refusal, dataTypes, guidance);
|
|
291
|
+
return {
|
|
292
|
+
code,
|
|
293
|
+
message: `${where}: ${message}`
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
function refusalSpan(refusal, spans, subject) {
|
|
299
|
+
switch (refusal.kind) {
|
|
300
|
+
case "not-a-list":
|
|
301
|
+
case "refused-by-column": return spans.attribute;
|
|
302
|
+
default: return writtenValueSpan(spans, refusal.elementIndex, subject);
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
function writtenValueSpan(spans, elementIndex, subject) {
|
|
306
|
+
if (elementIndex === void 0) return spans.value;
|
|
307
|
+
const span = spans.elements[elementIndex];
|
|
308
|
+
if (span === void 0) throw new InternalError(`${subject}: a refused @default list element ${elementIndex + 1} has no written span.`);
|
|
309
|
+
return span;
|
|
310
|
+
}
|
|
311
|
+
function formatSupportedFunctionList(registry) {
|
|
312
|
+
const signatures = Array.from(registry.entries()).sort(([a], [b]) => a.localeCompare(b)).flatMap(([functionName, entry]) => {
|
|
313
|
+
const usageSignatures = entry.usageSignatures?.filter((signature) => signature.length > 0);
|
|
314
|
+
return usageSignatures && usageSignatures.length > 0 ? usageSignatures : [`${functionName}()`];
|
|
315
|
+
});
|
|
316
|
+
return signatures.length > 0 ? signatures.join(", ") : "none";
|
|
317
|
+
}
|
|
318
|
+
/** The diagnostic message for a `dbgenerated(...)` call, which raw SQL tagged literals replaced. */
|
|
319
|
+
function removedDbgeneratedMessage(registry) {
|
|
320
|
+
return `Default function "dbgenerated" was removed. Write the SQL as a tagged literal: @default(sql\`<expression>\`). Supported functions: ${formatSupportedFunctionList(registry)}.`;
|
|
321
|
+
}
|
|
322
|
+
function lowerDefaultFunctionWithRegistry(input) {
|
|
323
|
+
const entry = input.registry.get(input.call.fn);
|
|
324
|
+
if (entry) {
|
|
325
|
+
const result = entry.lower({
|
|
326
|
+
call: input.call,
|
|
327
|
+
context: input.context
|
|
328
|
+
});
|
|
329
|
+
return result.ok ? result : {
|
|
330
|
+
...result,
|
|
331
|
+
kind: "external"
|
|
332
|
+
};
|
|
333
|
+
}
|
|
334
|
+
const supportedFunctionList = formatSupportedFunctionList(input.registry);
|
|
335
|
+
return {
|
|
336
|
+
ok: false,
|
|
337
|
+
kind: "owned",
|
|
338
|
+
diagnostic: {
|
|
339
|
+
code: "PSL_UNKNOWN_DEFAULT_FUNCTION",
|
|
340
|
+
message: `Default function "${input.call.fn}" is not supported in SQL PSL provider v1. Supported functions: ${supportedFunctionList}.`,
|
|
341
|
+
...input.source.at(input.call.span)
|
|
342
|
+
}
|
|
343
|
+
};
|
|
344
|
+
}
|
|
345
|
+
function buildModelAttributeCtx(input) {
|
|
346
|
+
return {
|
|
347
|
+
sources: input.sources,
|
|
348
|
+
selfModel: input.selfModel,
|
|
349
|
+
binder: input.binder,
|
|
350
|
+
symbols: input.symbols
|
|
351
|
+
};
|
|
352
|
+
}
|
|
353
|
+
function buildFieldAttributeCtx(input) {
|
|
354
|
+
return {
|
|
355
|
+
sources: input.sources,
|
|
356
|
+
selfModel: input.selfModel,
|
|
357
|
+
field: input.field,
|
|
358
|
+
binder: input.binder,
|
|
359
|
+
symbols: input.symbols
|
|
360
|
+
};
|
|
361
|
+
}
|
|
362
|
+
function modelAttributeSpecsFrom(modelAttributesByName) {
|
|
363
|
+
const result = Object.create(null);
|
|
364
|
+
for (const [name, descriptor] of modelAttributesByName) result[name] = blindCast(descriptor.spec);
|
|
365
|
+
return result;
|
|
366
|
+
}
|
|
367
|
+
function interpretModelAttribute(input) {
|
|
368
|
+
const result = interpretAttribute(input.node, input.spec, buildModelAttributeCtx({
|
|
369
|
+
symbols: input.symbols,
|
|
370
|
+
selfModel: input.model,
|
|
371
|
+
sources: input.sources,
|
|
372
|
+
binder: input.binder
|
|
373
|
+
}));
|
|
374
|
+
if (!result.ok) {
|
|
375
|
+
input.diagnostics.push(...result.failure);
|
|
376
|
+
return;
|
|
377
|
+
}
|
|
378
|
+
return result.value;
|
|
379
|
+
}
|
|
380
|
+
function interpretFieldAttribute(input) {
|
|
381
|
+
const result = interpretAttribute(input.node, input.spec, buildFieldAttributeCtx({
|
|
382
|
+
symbols: input.symbols,
|
|
383
|
+
selfModel: input.model,
|
|
384
|
+
field: input.field,
|
|
385
|
+
sources: input.sources,
|
|
386
|
+
binder: input.binder
|
|
387
|
+
}));
|
|
388
|
+
if (!result.ok) {
|
|
389
|
+
input.diagnostics.push(...result.failure);
|
|
390
|
+
return;
|
|
391
|
+
}
|
|
392
|
+
return result.value;
|
|
393
|
+
}
|
|
394
|
+
/** Interprets an attribute that reads only its type, such as `@default` on a field or a type alias, draining parse failures into `diagnostics`. */
|
|
395
|
+
function interpretTypeAttribute(input) {
|
|
396
|
+
const result = interpretAttribute(input.node, input.spec, {
|
|
397
|
+
sources: input.sources,
|
|
398
|
+
symbols: input.symbols,
|
|
399
|
+
binder: input.binder
|
|
400
|
+
});
|
|
401
|
+
if (!result.ok) {
|
|
402
|
+
input.diagnostics.push(...result.failure);
|
|
403
|
+
return;
|
|
404
|
+
}
|
|
405
|
+
return result.value;
|
|
406
|
+
}
|
|
407
|
+
function validateMappedName(value, ctx, attributeNode) {
|
|
408
|
+
return value.name === "" ? [leafDiagnostic(ctx, attributeNode, "Mapped name must not be empty")] : [];
|
|
409
|
+
}
|
|
410
|
+
const mapModelSpec = modelAttribute("map", {
|
|
411
|
+
documentation: "Maps this model to a database table name.",
|
|
412
|
+
positional: [{
|
|
413
|
+
key: "name",
|
|
414
|
+
type: str(),
|
|
415
|
+
documentation: "The nonempty database table name."
|
|
416
|
+
}],
|
|
417
|
+
refine: validateMappedName
|
|
418
|
+
});
|
|
419
|
+
const mapFieldSpec = fieldAttribute("map", {
|
|
420
|
+
documentation: "Maps this field to a database column name.",
|
|
421
|
+
positional: [{
|
|
422
|
+
key: "name",
|
|
423
|
+
type: str(),
|
|
424
|
+
documentation: "The nonempty database column name."
|
|
425
|
+
}],
|
|
426
|
+
refine: validateMappedName
|
|
427
|
+
});
|
|
428
|
+
function nullLiteral() {
|
|
429
|
+
const nullIdentifier = identifier("null", { documentation: "A null list element or nullable scalar default." });
|
|
430
|
+
return mapArg({
|
|
431
|
+
kind: "null",
|
|
432
|
+
label: "null",
|
|
433
|
+
parse: (arg, ctx) => {
|
|
434
|
+
const result = nullIdentifier.parse(arg, ctx);
|
|
435
|
+
return result.ok ? ok(null) : result;
|
|
436
|
+
}
|
|
437
|
+
}, (_null, arg, ctx) => ({
|
|
438
|
+
kind: "null",
|
|
439
|
+
span: nodePslSpan(arg.syntax, ctx.sources)
|
|
440
|
+
}));
|
|
441
|
+
}
|
|
442
|
+
/**
|
|
443
|
+
* A call to the registered default function `name`, with its signature built from the stack's data types when it needs them. Its binding diagnostics name it as a default function.
|
|
444
|
+
*/
|
|
445
|
+
function defaultFunctionCall(name, entry, dataTypes) {
|
|
446
|
+
const signature = blindCast(entry.signature);
|
|
447
|
+
return funcCall(name, typeof signature === "function" ? signature(dataTypes) : signature, { label: `Default function "${name}"` });
|
|
448
|
+
}
|
|
449
|
+
/** The data type of the column a field declares, when its type, or the named type it is declared with, is a constructor or preset the stack knows. */
|
|
450
|
+
function receivingDataType(ctx) {
|
|
451
|
+
const typeConstructor = ctx.typeConstructor;
|
|
452
|
+
return typeConstructor === void 0 ? void 0 : ctx.dataTypes.dataTypeOfCodec(contributedTypeCodecId(typeConstructor.descriptor));
|
|
453
|
+
}
|
|
454
|
+
/** Whether a value of `type` can be written for a column of `receiving`: it is that type, or the column's type casts from it. An unknown column takes every type. */
|
|
455
|
+
function receives(dataTypes, receiving, type) {
|
|
456
|
+
if (receiving === void 0 || type === receiving) return true;
|
|
457
|
+
const receivingType = dataTypes.lookup.get(receiving);
|
|
458
|
+
if (receivingType === void 0) return true;
|
|
459
|
+
return Object.hasOwn(receivingType.casts, type) || (receivingType.listCast?.of.some((of) => of === type) ?? false);
|
|
460
|
+
}
|
|
461
|
+
function scalarDefaultArms(isList, receiving, dataTypes, defaultFunctionRegistry) {
|
|
462
|
+
const tagArms = (admits) => {
|
|
463
|
+
const tagsByDocumentation = /* @__PURE__ */ new Map();
|
|
464
|
+
for (const [key, entry] of Object.entries(dataTypes.entries)) {
|
|
465
|
+
if (entry.written.kind !== "tag" || !admits(key)) continue;
|
|
466
|
+
const tags = tagsByDocumentation.get(entry.documentation);
|
|
467
|
+
if (tags === void 0) tagsByDocumentation.set(entry.documentation, [entry.written.tag]);
|
|
468
|
+
else tags.push(entry.written.tag);
|
|
469
|
+
}
|
|
470
|
+
return [...tagsByDocumentation].map(([documentation, tags]) => writtenScalar(taggedLiteral(tags, { documentation })));
|
|
471
|
+
};
|
|
472
|
+
const columnTags = () => tagArms((dataType) => dataType === SQL_EXPRESSION_DATA_TYPE_ID || !isList && receives(dataTypes, receiving, dataType));
|
|
473
|
+
const literal = () => oneOf(writtenScalar(str()), writtenScalar(numLiteral()), writtenScalar(bool()), nullLiteral(), ...tagArms((dataType) => dataType !== SQL_EXPRESSION_DATA_TYPE_ID && receives(dataTypes, receiving, dataType)));
|
|
474
|
+
const listArm = () => writtenList(literal());
|
|
475
|
+
const funcArms = [...defaultFunctionRegistry.entries()].map(([name, entry]) => mapArg(defaultFunctionCall(name, entry, dataTypes), (call) => ({
|
|
476
|
+
kind: "default-function",
|
|
477
|
+
call
|
|
478
|
+
})));
|
|
479
|
+
return isList ? [
|
|
480
|
+
listArm(),
|
|
481
|
+
...funcArms,
|
|
482
|
+
...columnTags()
|
|
483
|
+
] : [
|
|
484
|
+
writtenScalar(str()),
|
|
485
|
+
writtenScalar(numLiteral()),
|
|
486
|
+
writtenScalar(bool()),
|
|
487
|
+
nullLiteral(),
|
|
488
|
+
...funcArms,
|
|
489
|
+
...columnTags(),
|
|
490
|
+
listArm()
|
|
491
|
+
];
|
|
492
|
+
}
|
|
493
|
+
/**
|
|
494
|
+
* The `@default` value arms, with a `dbgenerated(...)` call reported as removed before the arms
|
|
495
|
+
* are tried, so the author is told what replaced it instead of being shown the list of arms.
|
|
496
|
+
*/
|
|
497
|
+
function defaultValueArm(arms, registry, generatorFunctions, subject) {
|
|
498
|
+
const value = arms.length === 1 && arms[0].kind === "list" ? arms[0] : oneOf(...arms);
|
|
499
|
+
return {
|
|
500
|
+
...value,
|
|
501
|
+
parse: (arg, ctx) => {
|
|
502
|
+
const callee = FunctionCallAst.cast(arg.syntax)?.path().join(".");
|
|
503
|
+
if (callee === "dbgenerated") return notOk([leafDiagnostic(ctx, arg, removedDbgeneratedMessage(registry), "PSL_UNKNOWN_DEFAULT_FUNCTION")]);
|
|
504
|
+
if (callee !== void 0 && !registry.has(callee) && generatorFunctions.has(callee)) {
|
|
505
|
+
const call = nodeSourceText(arg, ctx);
|
|
506
|
+
return notOk([leafDiagnostic(ctx, arg, `${subject}: ${call} is a value the client generates, and @default sets a database default only. Write @onCreate(${call}) instead.`, "PSL_GENERATOR_IN_DEFAULT")]);
|
|
507
|
+
}
|
|
508
|
+
return value.parse(arg, ctx);
|
|
509
|
+
}
|
|
510
|
+
};
|
|
511
|
+
}
|
|
512
|
+
function noEnumMember() {
|
|
513
|
+
return {
|
|
514
|
+
kind: "rejecting",
|
|
515
|
+
label: "enum member",
|
|
516
|
+
message: "Enum declares no members",
|
|
517
|
+
parse: (arg, ctx) => notOk([leafDiagnostic(ctx, arg, "Enum declares no members")])
|
|
518
|
+
};
|
|
519
|
+
}
|
|
520
|
+
function enumMemberNames(ctx) {
|
|
521
|
+
const resolution = ctx.typeResolution;
|
|
522
|
+
if (resolution?.kind !== "block" || resolution.symbol.keyword !== "enum") return void 0;
|
|
523
|
+
const block = resolution.symbol;
|
|
524
|
+
const names = [];
|
|
525
|
+
const seen = /* @__PURE__ */ new Set();
|
|
526
|
+
for (const entry of block.entries) {
|
|
527
|
+
const key = entry.key()?.name();
|
|
528
|
+
if (key === void 0 || seen.has(key)) continue;
|
|
529
|
+
seen.add(key);
|
|
530
|
+
names.push(key);
|
|
531
|
+
}
|
|
532
|
+
return names;
|
|
533
|
+
}
|
|
534
|
+
function enumDefaultArms(members, enumName, isList) {
|
|
535
|
+
const [first, ...rest] = members;
|
|
536
|
+
if (first === void 0) return [noEnumMember()];
|
|
537
|
+
const member = (name) => mapArg(identifier(name, { documentation: `The \`${name}\` member of enum \`${enumName}\`.` }), (parsed) => ({
|
|
538
|
+
kind: "member",
|
|
539
|
+
name: parsed
|
|
540
|
+
}));
|
|
541
|
+
if (isList) return [mapArg(list(oneOf(member(first), ...rest.map(member), nullLiteral())), (elements) => ({
|
|
542
|
+
kind: "member-list",
|
|
543
|
+
elements
|
|
544
|
+
}))];
|
|
545
|
+
return [member(first), ...rest.map(member)];
|
|
546
|
+
}
|
|
547
|
+
/** The spec of `@default` on a field or a type alias, offering the values its type takes. */
|
|
548
|
+
function typeDefaultSpec(ctx) {
|
|
549
|
+
const members = enumMemberNames(ctx);
|
|
550
|
+
return typeAttribute("default", {
|
|
551
|
+
documentation: "Supplies a default value when this field is omitted from a mutation.",
|
|
552
|
+
positional: [{
|
|
553
|
+
key: "value",
|
|
554
|
+
type: defaultValueArm(members === void 0 ? scalarDefaultArms(ctx.list, receivingDataType(ctx), ctx.dataTypes, ctx.defaultFunctionRegistry) : enumDefaultArms(members, ctx.typeName, ctx.list), ctx.defaultFunctionRegistry, ctx.generatorFunctions, typeAttributeSubjectLabel(ctx.subject)),
|
|
555
|
+
documentation: "A literal, enum member, or registered default function compatible with this field."
|
|
556
|
+
}]
|
|
557
|
+
});
|
|
558
|
+
}
|
|
559
|
+
const idFieldSpec = fieldAttribute("id", {
|
|
560
|
+
documentation: "Makes this field the primary key of the table.",
|
|
561
|
+
named: { map: {
|
|
562
|
+
type: optional(str()),
|
|
563
|
+
documentation: "The database primary-key constraint name."
|
|
564
|
+
} }
|
|
565
|
+
});
|
|
566
|
+
const uniqueFieldSpec = fieldAttribute("unique", {
|
|
567
|
+
documentation: "Requires values in this field to be unique.",
|
|
568
|
+
named: { map: {
|
|
569
|
+
type: optional(str()),
|
|
570
|
+
documentation: "The database unique-constraint name."
|
|
571
|
+
} }
|
|
572
|
+
});
|
|
573
|
+
const idModelSpec = modelAttribute("id", {
|
|
574
|
+
documentation: "Declares a compound primary key for this table.",
|
|
575
|
+
positional: [{
|
|
576
|
+
key: "fields",
|
|
577
|
+
type: list(fieldRef(), {
|
|
578
|
+
allowEmpty: false,
|
|
579
|
+
unique: true
|
|
580
|
+
}),
|
|
581
|
+
documentation: "The ordered, nonempty list of distinct primary-key fields."
|
|
582
|
+
}],
|
|
583
|
+
named: { map: {
|
|
584
|
+
type: optional(str()),
|
|
585
|
+
documentation: "The database primary-key constraint name."
|
|
586
|
+
} }
|
|
587
|
+
});
|
|
588
|
+
const uniqueModelSpec = modelAttribute("unique", {
|
|
589
|
+
documentation: "Requires the combination of these fields to be unique.",
|
|
590
|
+
positional: [{
|
|
591
|
+
key: "fields",
|
|
592
|
+
type: list(fieldRef(), {
|
|
593
|
+
allowEmpty: false,
|
|
594
|
+
unique: true
|
|
595
|
+
}),
|
|
596
|
+
documentation: "The ordered, nonempty list of distinct fields in the unique constraint."
|
|
597
|
+
}],
|
|
598
|
+
named: { map: {
|
|
599
|
+
type: optional(str()),
|
|
600
|
+
documentation: "The database unique-constraint name."
|
|
601
|
+
} }
|
|
602
|
+
});
|
|
603
|
+
const PSL_INDEX_FIELDS_XOR_EXPRESSION = "PSL_INDEX_FIELDS_XOR_EXPRESSION";
|
|
604
|
+
const PSL_INDEX_EXPRESSION_REQUIRES_NAME = "PSL_INDEX_EXPRESSION_REQUIRES_NAME";
|
|
605
|
+
const PSL_INDEX_NAME_XOR_MAP = "PSL_INDEX_NAME_XOR_MAP";
|
|
606
|
+
function indexModelSpec(ctx) {
|
|
607
|
+
return modelAttribute("index", {
|
|
608
|
+
documentation: "Declares a database index over fields or a SQL expression, optionally restricted by a predicate.",
|
|
609
|
+
positional: [{
|
|
610
|
+
key: "fields",
|
|
611
|
+
type: optional(list(fieldRef(), {
|
|
612
|
+
allowEmpty: false,
|
|
613
|
+
unique: true
|
|
614
|
+
})),
|
|
615
|
+
documentation: "The ordered list of distinct indexed fields. Mutually exclusive with `expression`."
|
|
616
|
+
}],
|
|
617
|
+
named: {
|
|
618
|
+
expression: {
|
|
619
|
+
type: optional(dataTypeValue(SQL_EXPRESSION_DATA_TYPE_ID, ctx.dataTypes)),
|
|
620
|
+
documentation: "The SQL index expression. Requires `name` or `map` and cannot be combined with a fields list."
|
|
621
|
+
},
|
|
622
|
+
where: {
|
|
623
|
+
type: optional(dataTypeValue(SQL_EXPRESSION_DATA_TYPE_ID, ctx.dataTypes)),
|
|
624
|
+
documentation: "The SQL predicate restricting rows included in a partial index."
|
|
625
|
+
},
|
|
626
|
+
unique: {
|
|
627
|
+
type: optional(bool()),
|
|
628
|
+
documentation: "Whether the index enforces uniqueness."
|
|
629
|
+
},
|
|
630
|
+
name: {
|
|
631
|
+
type: optional(str()),
|
|
632
|
+
documentation: "The index name. Mutually exclusive with `map`."
|
|
633
|
+
},
|
|
634
|
+
map: {
|
|
635
|
+
type: optional(str()),
|
|
636
|
+
documentation: "The database index name. Mutually exclusive with `name`."
|
|
637
|
+
},
|
|
638
|
+
type: {
|
|
639
|
+
type: optional(str()),
|
|
640
|
+
documentation: "The target-specific index access method."
|
|
641
|
+
},
|
|
642
|
+
options: {
|
|
643
|
+
type: optional(record(str())),
|
|
644
|
+
documentation: "Target-specific index options. Requires an explicit `type`."
|
|
645
|
+
}
|
|
646
|
+
},
|
|
647
|
+
refine: (value, ctx, attributeNode) => {
|
|
648
|
+
const diagnostics = [];
|
|
649
|
+
if (value.fields === void 0 === (value.expression === void 0)) diagnostics.push(leafDiagnostic(ctx, attributeNode, "`@@index` requires exactly one of a fields list or an `expression` argument", PSL_INDEX_FIELDS_XOR_EXPRESSION));
|
|
650
|
+
if (value.expression !== void 0 && value.name === void 0 && value.map === void 0) diagnostics.push(leafDiagnostic(ctx, attributeNode, "`@@index` with an `expression` argument requires a `name` or `map` argument (a default name cannot be derived from an expression)", PSL_INDEX_EXPRESSION_REQUIRES_NAME));
|
|
651
|
+
if (value.name !== void 0 && value.map !== void 0) diagnostics.push(leafDiagnostic(ctx, attributeNode, "`@@index` takes at most one of `name` and `map`", PSL_INDEX_NAME_XOR_MAP));
|
|
652
|
+
if (value.options !== void 0 && value.type === void 0) diagnostics.push(leafDiagnostic(ctx, attributeNode, "`@@index` options argument requires a type argument"));
|
|
653
|
+
return diagnostics;
|
|
654
|
+
}
|
|
655
|
+
});
|
|
656
|
+
}
|
|
657
|
+
const PSL_CHECK_REQUIRES_NAME_OR_MAP = "PSL_CHECK_REQUIRES_NAME_OR_MAP";
|
|
658
|
+
const PSL_CHECK_NAME_XOR_MAP = "PSL_CHECK_NAME_XOR_MAP";
|
|
659
|
+
const PSL_CHECK_EXPRESSION_EMPTY = "PSL_CHECK_EXPRESSION_EMPTY";
|
|
660
|
+
/**
|
|
661
|
+
* A single-table-inheritance variant (`@@base` with no own `@@map`) shares
|
|
662
|
+
* its base model's storage table and has no table of its own to declare a
|
|
663
|
+
* check on — raised from {@link interpretPslDocumentToSqlContract}, not from
|
|
664
|
+
* this spec's own `refine`, because the rule needs the model's `@@base`
|
|
665
|
+
* declaration, which a single attribute's `refine` cannot see.
|
|
666
|
+
*/
|
|
667
|
+
const PSL_CHECK_ON_STI_VARIANT = "PSL_CHECK_ON_STI_VARIANT";
|
|
668
|
+
function checkModelSpec(ctx) {
|
|
669
|
+
return modelAttribute("check", {
|
|
670
|
+
documentation: "Declares a named database CHECK constraint on this table.",
|
|
671
|
+
named: {
|
|
672
|
+
expression: {
|
|
673
|
+
type: dataTypeValue(SQL_EXPRESSION_DATA_TYPE_ID, ctx.dataTypes),
|
|
674
|
+
documentation: "The nonempty SQL predicate checked for each row."
|
|
675
|
+
},
|
|
676
|
+
name: {
|
|
677
|
+
type: optional(str()),
|
|
678
|
+
documentation: "The constraint name. Exactly one of `name` and `map` is required."
|
|
679
|
+
},
|
|
680
|
+
map: {
|
|
681
|
+
type: optional(str()),
|
|
682
|
+
documentation: "The database constraint name. Exactly one of `name` and `map` is required."
|
|
683
|
+
}
|
|
684
|
+
},
|
|
685
|
+
refine: (value, ctx, attributeNode) => {
|
|
686
|
+
const diagnostics = [];
|
|
687
|
+
if (sqlTextFromStored(value.expression.value.value).trim().length === 0) diagnostics.push(leafDiagnostic(ctx, attributeNode, "`@@check` expression must not be empty — an empty predicate is not a constraint", PSL_CHECK_EXPRESSION_EMPTY));
|
|
688
|
+
if (value.name === void 0 && value.map === void 0) diagnostics.push(leafDiagnostic(ctx, attributeNode, "`@@check` requires a `name` or `map` argument (a default name cannot be derived — a check has no column tuple to name itself after)", PSL_CHECK_REQUIRES_NAME_OR_MAP));
|
|
689
|
+
if (value.name !== void 0 && value.map !== void 0) diagnostics.push(leafDiagnostic(ctx, attributeNode, "`@@check` takes at most one of `name` and `map`", PSL_CHECK_NAME_XOR_MAP));
|
|
690
|
+
return diagnostics;
|
|
691
|
+
}
|
|
692
|
+
});
|
|
693
|
+
}
|
|
694
|
+
const controlModelSpec = modelAttribute("control", {
|
|
695
|
+
documentation: "Sets how schema management treats this model’s storage.",
|
|
696
|
+
positional: [{
|
|
697
|
+
key: "policy",
|
|
698
|
+
documentation: "The storage control policy: `managed`, `tolerated`, `external`, or `observed`.",
|
|
699
|
+
type: oneOf(identifier("managed", { documentation: "Verifies the declared shape strictly and allows migrations to create, alter, or drop the storage object." }), identifier("tolerated", { documentation: "Verifies declared columns while allowing extra columns. Migrations may create missing storage, but never alter or drop existing storage." }), identifier("external", { documentation: "Verifies declared storage without creating, altering, or dropping it." }), identifier("observed", { documentation: "Reports storage differences as warnings rather than verification failures and never emits migration operations." }))
|
|
700
|
+
}]
|
|
701
|
+
});
|
|
702
|
+
const discriminatorModelSpec = modelAttribute("discriminator", {
|
|
703
|
+
documentation: "Selects the field that identifies inheritance variants of this model.",
|
|
704
|
+
positional: [{
|
|
705
|
+
key: "field",
|
|
706
|
+
type: fieldRef(),
|
|
707
|
+
documentation: "The discriminator field on this model."
|
|
708
|
+
}]
|
|
709
|
+
});
|
|
710
|
+
function baseModelSpec() {
|
|
711
|
+
return modelAttribute("base", {
|
|
712
|
+
documentation: "Declares this model as a variant of a base model.",
|
|
713
|
+
positional: [{
|
|
714
|
+
key: "base",
|
|
715
|
+
type: entityRef({ kind: "model" }),
|
|
716
|
+
documentation: "The base model to inherit from."
|
|
717
|
+
}, {
|
|
718
|
+
key: "value",
|
|
719
|
+
type: writtenScalar(str()),
|
|
720
|
+
documentation: "The discriminator value identifying this variant, a value of the discriminator column's type."
|
|
721
|
+
}]
|
|
722
|
+
});
|
|
723
|
+
}
|
|
724
|
+
function relationAttributeSpan(ctx) {
|
|
725
|
+
const node = getAttribute(ctx.field.attributes, "relation")?.node;
|
|
726
|
+
if (node !== void 0) return nodePslSpan(node.syntax, ctx.sources);
|
|
727
|
+
return ctx.field.span;
|
|
728
|
+
}
|
|
729
|
+
function relationInvariants(parsed, ctx) {
|
|
730
|
+
if (parsed.fields !== void 0 !== (parsed.references !== void 0)) return [{
|
|
731
|
+
code: "PSL_INVALID_ATTRIBUTE_SYNTAX",
|
|
732
|
+
message: `Relation field "${ctx.selfModel.name}.${ctx.field.name}" requires fields and references arguments`,
|
|
733
|
+
...diagnosticSource(ctx.sources, ctx.field.node.syntax).at(relationAttributeSpan(ctx))
|
|
734
|
+
}];
|
|
735
|
+
return [];
|
|
736
|
+
}
|
|
737
|
+
const referentialActionArgument = () => oneOf(identifier("NoAction", { documentation: "Rejects a change that would violate the foreign key when the constraint is checked; checking may be deferred when supported and configured." }), identifier("Restrict", { documentation: "Rejects deleting or updating a referenced row while referencing rows remain, without deferring the check." }), identifier("Cascade", { documentation: "Propagates deletion or key updates of a referenced row to its referencing rows." }), identifier("SetNull", { documentation: "Sets referencing foreign-key fields to null when the referenced row is deleted or its key changes. The fields must allow null." }), identifier("SetDefault", { documentation: "Sets referencing foreign-key fields to their defaults when the referenced row is deleted or its key changes. The resulting values must satisfy the foreign key." }));
|
|
738
|
+
const relationFieldSpec = fieldAttribute("relation", {
|
|
739
|
+
documentation: "Defines the relation name, foreign-key fields, and referential actions for this relation.",
|
|
740
|
+
positional: [{
|
|
741
|
+
key: "name",
|
|
742
|
+
type: optional(str()),
|
|
743
|
+
documentation: "The relation name used to pair both sides. May also be supplied by name."
|
|
744
|
+
}],
|
|
745
|
+
named: {
|
|
746
|
+
name: {
|
|
747
|
+
type: optional(str()),
|
|
748
|
+
documentation: "The relation name used to pair both sides. Cannot also be supplied positionally."
|
|
749
|
+
},
|
|
750
|
+
fields: {
|
|
751
|
+
type: optional(list(fieldRef(), {
|
|
752
|
+
allowEmpty: false,
|
|
753
|
+
unique: true
|
|
754
|
+
})),
|
|
755
|
+
documentation: "The ordered local foreign-key fields. Must be supplied together with `references`."
|
|
756
|
+
},
|
|
757
|
+
references: {
|
|
758
|
+
type: optional(list(referencedFieldRef(), {
|
|
759
|
+
allowEmpty: false,
|
|
760
|
+
unique: true
|
|
761
|
+
})),
|
|
762
|
+
documentation: "The corresponding fields on the referenced model. Must be supplied together with `fields`."
|
|
763
|
+
},
|
|
764
|
+
map: {
|
|
765
|
+
type: optional(str()),
|
|
766
|
+
documentation: "The database foreign-key constraint name."
|
|
767
|
+
},
|
|
768
|
+
onDelete: {
|
|
769
|
+
type: optional(referentialActionArgument()),
|
|
770
|
+
documentation: "The referential action when a referenced row is deleted."
|
|
771
|
+
},
|
|
772
|
+
onUpdate: {
|
|
773
|
+
type: optional(referentialActionArgument()),
|
|
774
|
+
documentation: "The referential action when a referenced key is updated."
|
|
775
|
+
},
|
|
776
|
+
index: {
|
|
777
|
+
type: optional(oneOf(bool(), str())),
|
|
778
|
+
documentation: "Whether to create an index for the relation’s foreign-key fields (`false` for none), or the name of an index, unique constraint or primary key on this model to use instead. The name is the `name` or `map` it was given, or an index’s stored name, and its first columns must be the foreign-key fields in order."
|
|
779
|
+
}
|
|
780
|
+
},
|
|
781
|
+
refine: relationInvariants
|
|
782
|
+
});
|
|
783
|
+
function modelSpecContext(input) {
|
|
784
|
+
return {
|
|
785
|
+
symbols: input.symbols,
|
|
786
|
+
model: input.model,
|
|
787
|
+
defaultFunctionRegistry: input.defaultFunctionRegistry,
|
|
788
|
+
generatorFunctions: input.generatorFunctions,
|
|
789
|
+
dataTypes: input.dataTypes
|
|
790
|
+
};
|
|
791
|
+
}
|
|
792
|
+
function fieldSpecContext(input) {
|
|
793
|
+
const node = typeReferenceNode(input.field);
|
|
794
|
+
const typeResolution = node === void 0 ? void 0 : input.binder.symbolForNode(node);
|
|
795
|
+
return {
|
|
796
|
+
symbols: input.symbols,
|
|
797
|
+
model: input.model,
|
|
798
|
+
field: input.field,
|
|
799
|
+
typeResolution,
|
|
800
|
+
typeConstructor: contributedTypeOf(typeResolution, input.binder),
|
|
801
|
+
defaultFunctionRegistry: input.defaultFunctionRegistry,
|
|
802
|
+
generatorFunctions: input.generatorFunctions,
|
|
803
|
+
dataTypes: input.dataTypes
|
|
804
|
+
};
|
|
805
|
+
}
|
|
806
|
+
/** Every entry is a factory over the spec context, whether or not its spec reads it. ADR 249. */
|
|
807
|
+
const sqlAttributeSpecs = {
|
|
808
|
+
model: {
|
|
809
|
+
map: (_ctx) => mapModelSpec,
|
|
810
|
+
id: (_ctx) => idModelSpec,
|
|
811
|
+
unique: (_ctx) => uniqueModelSpec,
|
|
812
|
+
index: indexModelSpec,
|
|
813
|
+
check: checkModelSpec,
|
|
814
|
+
control: (_ctx) => controlModelSpec,
|
|
815
|
+
discriminator: (_ctx) => discriminatorModelSpec,
|
|
816
|
+
base: (_ctx) => baseModelSpec()
|
|
817
|
+
},
|
|
818
|
+
field: {
|
|
819
|
+
map: (_ctx) => mapFieldSpec,
|
|
820
|
+
id: (_ctx) => idFieldSpec,
|
|
821
|
+
unique: (_ctx) => uniqueFieldSpec,
|
|
822
|
+
relation: (_ctx) => relationFieldSpec,
|
|
823
|
+
default: (ctx) => typeDefaultSpec(typeAttributeSpecContextOfField(ctx)),
|
|
824
|
+
onCreate: generatorAttributeSpec("onCreate"),
|
|
825
|
+
onUpdate: generatorAttributeSpec("onUpdate")
|
|
826
|
+
}
|
|
827
|
+
};
|
|
828
|
+
/**
|
|
829
|
+
* The value-object column's default as the document it holds, and in the form the column stores. A
|
|
830
|
+
* column may store the document's JSON text, as `sqlite/json@1` does, so its codec reads the stored
|
|
831
|
+
* value into the document the composite type describes. A list literal on a list of value objects
|
|
832
|
+
* is read element by element; the column stores the list's document in its own form.
|
|
833
|
+
*/
|
|
834
|
+
function valueObjectDefaultDocument(input) {
|
|
835
|
+
const codec = codecForRef(input.codecLookup, { codecId: input.codecId });
|
|
836
|
+
if (codec === void 0) return {
|
|
837
|
+
document: input.stored,
|
|
838
|
+
stored: input.stored
|
|
839
|
+
};
|
|
840
|
+
if (input.elementwise && Array.isArray(input.stored)) {
|
|
841
|
+
const document = input.stored.map((element) => readDocument(codec, element));
|
|
842
|
+
return {
|
|
843
|
+
document,
|
|
844
|
+
stored: codec.dataType.toContract(codec.toDataTypeValue(document))
|
|
845
|
+
};
|
|
846
|
+
}
|
|
847
|
+
return {
|
|
848
|
+
document: readDocument(codec, input.stored),
|
|
849
|
+
stored: input.stored
|
|
850
|
+
};
|
|
851
|
+
}
|
|
852
|
+
/** The column's codec has already read `stored` while the default was lowered, so it reads again. */
|
|
853
|
+
function readDocument(codec, stored) {
|
|
854
|
+
if (stored === null) return null;
|
|
855
|
+
return blindCast(readContractValue(codec, stored, void 0));
|
|
856
|
+
}
|
|
857
|
+
/** Each way the default does not match the composite type. */
|
|
858
|
+
function valueObjectDefaultMismatches(input) {
|
|
859
|
+
const mismatches = [];
|
|
860
|
+
const shape = (path, message) => mismatches.push({
|
|
861
|
+
code: PSL_VALUE_TYPE_INCOMPATIBLE,
|
|
862
|
+
message: `Field "${path}": ${message}`
|
|
863
|
+
});
|
|
864
|
+
const checkObject = (value, valueObjectName, path) => {
|
|
865
|
+
const valueObject = input.types.nodes.get(valueObjectName);
|
|
866
|
+
const declared = input.types.declaredMembers.get(valueObjectName);
|
|
867
|
+
if (valueObject === void 0 || declared === void 0) throw new InternalError(`Field "${path}" is typed by the value object "${valueObjectName}", which the contract does not declare.`);
|
|
868
|
+
if (!isJsonObject(value)) {
|
|
869
|
+
shape(path, `a value of "${valueObjectName}" is a JSON object, not ${jsonKind(value)}`);
|
|
870
|
+
return;
|
|
871
|
+
}
|
|
872
|
+
for (const key of Object.keys(value)) if (!declared.has(key)) shape(path, `"${key}" is not a member of "${valueObjectName}"`);
|
|
873
|
+
for (const member of valueObject.fields) checkMember(value[member.fieldName], member, `${path}.${member.fieldName}`);
|
|
874
|
+
};
|
|
875
|
+
const checkMember = (value, member, path) => {
|
|
876
|
+
if (value === void 0) {
|
|
877
|
+
if (!member.nullable) shape(path, "the member is required, and the default has no value for it");
|
|
878
|
+
return;
|
|
879
|
+
}
|
|
880
|
+
if (value === null && member.nullable) return;
|
|
881
|
+
if (member.many === true) {
|
|
882
|
+
if (!Array.isArray(value)) {
|
|
883
|
+
shape(path, `the member is a list, so its value is a JSON array, not ${jsonKind(value)}`);
|
|
884
|
+
return;
|
|
885
|
+
}
|
|
886
|
+
for (const [index, element] of value.entries()) {
|
|
887
|
+
if (element === null && member.elementNullable) continue;
|
|
888
|
+
checkOne(element, member, `${path}[${index}]`, "an element of the member is not null");
|
|
889
|
+
}
|
|
890
|
+
return;
|
|
891
|
+
}
|
|
892
|
+
checkOne(value, member, path, "the member is not optional, so its value is not null");
|
|
893
|
+
};
|
|
894
|
+
const checkOne = (value, member, path, notNull) => {
|
|
895
|
+
if (isValueObjectMember(member)) {
|
|
896
|
+
if (value === null) shape(path, notNull);
|
|
897
|
+
else checkObject(value, member.valueObjectName, path);
|
|
898
|
+
return;
|
|
899
|
+
}
|
|
900
|
+
const reading = readStoredValue({
|
|
901
|
+
value,
|
|
902
|
+
column: member.descriptor,
|
|
903
|
+
lookups: input.lookups,
|
|
904
|
+
fieldPath: path
|
|
905
|
+
});
|
|
906
|
+
if (!reading.ok) {
|
|
907
|
+
if (value === null) shape(path, notNull);
|
|
908
|
+
else mismatches.push({
|
|
909
|
+
code: reading.code,
|
|
910
|
+
message: reading.message
|
|
911
|
+
});
|
|
912
|
+
return;
|
|
913
|
+
}
|
|
914
|
+
const enumMismatch = enumValueMismatch(value, member, path, input.lookups.codecLookup);
|
|
915
|
+
if (enumMismatch !== void 0) mismatches.push(enumMismatch);
|
|
916
|
+
};
|
|
917
|
+
if (input.value === null) {
|
|
918
|
+
if (input.nullable) return mismatches;
|
|
919
|
+
shape(input.fieldPath, input.list ? "the default of a list of value objects is a JSON array, not null" : "the default of a value object is a JSON object, not null");
|
|
920
|
+
return mismatches;
|
|
921
|
+
}
|
|
922
|
+
if (input.list) {
|
|
923
|
+
if (!Array.isArray(input.value)) {
|
|
924
|
+
shape(input.fieldPath, `the default of a list of value objects is a JSON array, not ${jsonKind(input.value)}`);
|
|
925
|
+
return mismatches;
|
|
926
|
+
}
|
|
927
|
+
for (const [index, element] of input.value.entries()) {
|
|
928
|
+
if (element === null && input.elementNullable) continue;
|
|
929
|
+
checkObject(element, input.valueObjectName, `${input.fieldPath}[${index}]`);
|
|
930
|
+
}
|
|
931
|
+
return mismatches;
|
|
932
|
+
}
|
|
933
|
+
if (!isJsonObject(input.value)) {
|
|
934
|
+
shape(input.fieldPath, `the default of a value object is a JSON object, not ${jsonKind(input.value)}`);
|
|
935
|
+
return mismatches;
|
|
936
|
+
}
|
|
937
|
+
checkObject(input.value, input.valueObjectName, input.fieldPath);
|
|
938
|
+
return mismatches;
|
|
939
|
+
}
|
|
940
|
+
/**
|
|
941
|
+
* A member typed by an enum takes only the enum's values, in the form its codec stores them, as a model field of that enum takes only its members.
|
|
942
|
+
*/
|
|
943
|
+
function enumValueMismatch(value, member, path, codecLookup) {
|
|
944
|
+
const handle = member.enumTypeHandle;
|
|
945
|
+
if (handle === void 0) return void 0;
|
|
946
|
+
const codec = codecLookup.get(handle.codecId);
|
|
947
|
+
const stored = handle.values.map((enumValue) => codec === void 0 ? enumValue : codec.dataType.toContract(codec.toDataTypeValue(enumValue)));
|
|
948
|
+
if (stored.some((storedValue) => storedValue === value)) return void 0;
|
|
949
|
+
return {
|
|
950
|
+
code: PSL_INVALID_DEFAULT_LITERAL,
|
|
951
|
+
message: `Field "${path}": Expected one of: ${stored.map((storedValue) => JSON.stringify(storedValue)).join(" | ")}`
|
|
952
|
+
};
|
|
953
|
+
}
|
|
954
|
+
function isJsonObject(value) {
|
|
955
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
956
|
+
}
|
|
957
|
+
function jsonKind(value) {
|
|
958
|
+
if (value === null) return "null";
|
|
959
|
+
if (Array.isArray(value)) return "a JSON array";
|
|
960
|
+
if (typeof value === "object") return "a JSON object";
|
|
961
|
+
return `a JSON ${typeof value}`;
|
|
962
|
+
}
|
|
963
|
+
function argumentSpan(call, descriptors, index) {
|
|
964
|
+
if (index === void 0) return call.span;
|
|
965
|
+
const name = descriptors?.[index]?.name;
|
|
966
|
+
const named = call.args.find((arg) => arg.kind === "named" && arg.name === name);
|
|
967
|
+
const positional = call.args.filter((arg) => arg.kind === "positional")[index];
|
|
968
|
+
return (named ?? positional)?.span ?? call.span;
|
|
969
|
+
}
|
|
970
|
+
/**
|
|
971
|
+
* Checks the type parameters a constructor or preset produced against its codec's parameter schema,
|
|
972
|
+
* reporting a failure at the argument the failing parameter came from. Returns whether they passed.
|
|
973
|
+
*/
|
|
974
|
+
function checkPslTypeParams(input) {
|
|
975
|
+
const helperPath = input.call.path.join(".");
|
|
976
|
+
try {
|
|
977
|
+
validateAuthoringTypeParams(helperPath, input.template, input.typeParams, input.codecLookup.descriptorFor(input.template.codecId)?.paramsSchema);
|
|
978
|
+
return true;
|
|
979
|
+
} catch (error) {
|
|
980
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
981
|
+
input.diagnostics.push({
|
|
982
|
+
code: "PSL_INVALID_ATTRIBUTE_ARGUMENT",
|
|
983
|
+
message: `${input.subject} ${message}`,
|
|
984
|
+
...input.source.at(argumentSpan(input.call, input.args, argumentIndexOf(error)))
|
|
985
|
+
});
|
|
986
|
+
return false;
|
|
987
|
+
}
|
|
988
|
+
}
|
|
989
|
+
function argumentIndexOf(error) {
|
|
990
|
+
if (typeof error !== "object" || error === null || !("details" in error)) return void 0;
|
|
991
|
+
const { details } = error;
|
|
992
|
+
if (typeof details !== "object" || details === null || !("argumentIndex" in details)) return;
|
|
993
|
+
return typeof details.argumentIndex === "number" ? details.argumentIndex : void 0;
|
|
994
|
+
}
|
|
995
|
+
/**
|
|
996
|
+
* Walks `authoringContributions.entityTypes` segment-by-segment and returns
|
|
997
|
+
* the entity type descriptor at the resolved path, or `undefined` if no
|
|
998
|
+
* descriptor is registered.
|
|
999
|
+
*
|
|
1000
|
+
* Used by the PSL interpreter to dispatch declarative entity-shaped
|
|
1001
|
+
* declarations (`enum`, future `namespace { … }`, …) through the
|
|
1002
|
+
* pack entity-type mechanism — the descriptor's `factory` (or
|
|
1003
|
+
* `template`) materialises the IR-class instance without the
|
|
1004
|
+
* interpreter knowing target-specific construction.
|
|
1005
|
+
*/
|
|
1006
|
+
function getAuthoringEntity(contributions, path) {
|
|
1007
|
+
let current = contributions?.entityTypes;
|
|
1008
|
+
for (const segment of path) {
|
|
1009
|
+
if (typeof current !== "object" || current === null || "kind" in current) return;
|
|
1010
|
+
current = current[segment];
|
|
1011
|
+
}
|
|
1012
|
+
return current !== void 0 && isAuthoringEntityTypeDescriptor(current) ? current : void 0;
|
|
1013
|
+
}
|
|
1014
|
+
function instantiatePslTypeConstructor(input) {
|
|
1015
|
+
const helperPath = input.call.path.join(".");
|
|
1016
|
+
const args = mapPslHelperArgs({
|
|
1017
|
+
args: input.call.args,
|
|
1018
|
+
descriptors: input.descriptor.args ?? [],
|
|
1019
|
+
helperLabel: `constructor "${helperPath}"`,
|
|
1020
|
+
span: input.call.span,
|
|
1021
|
+
diagnostics: input.diagnostics,
|
|
1022
|
+
source: input.source,
|
|
1023
|
+
entityLabel: input.entityLabel,
|
|
1024
|
+
dataTypes: input.dataTypes
|
|
1025
|
+
});
|
|
1026
|
+
if (!args) return;
|
|
1027
|
+
let output;
|
|
1028
|
+
try {
|
|
1029
|
+
validateAuthoringHelperArguments(helperPath, input.descriptor.args, args);
|
|
1030
|
+
output = instantiateAuthoringTypeConstructor(input.descriptor, args);
|
|
1031
|
+
} catch (error) {
|
|
1032
|
+
if (isInternalError(error)) throw error;
|
|
1033
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
1034
|
+
input.diagnostics.push({
|
|
1035
|
+
code: "PSL_INVALID_ATTRIBUTE_ARGUMENT",
|
|
1036
|
+
message: `${input.entityLabel} constructor "${helperPath}" ${message}`,
|
|
1037
|
+
...input.source.at(input.call.span)
|
|
1038
|
+
});
|
|
1039
|
+
return;
|
|
1040
|
+
}
|
|
1041
|
+
return checkPslTypeParams({
|
|
1042
|
+
call: input.call,
|
|
1043
|
+
subject: `${input.entityLabel} constructor "${helperPath}"`,
|
|
1044
|
+
args: input.descriptor.args,
|
|
1045
|
+
template: input.descriptor.output,
|
|
1046
|
+
typeParams: output.typeParams,
|
|
1047
|
+
codecLookup: input.codecLookup,
|
|
1048
|
+
diagnostics: input.diagnostics,
|
|
1049
|
+
source: input.source
|
|
1050
|
+
}) ? output : void 0;
|
|
1051
|
+
}
|
|
1052
|
+
/**
|
|
1053
|
+
* Structural check for a codec descriptor exposing the authoring-time
|
|
1054
|
+
* `columnFromEntity` hook a type constructor's `entityRefArg` resolves
|
|
1055
|
+
* through (e.g. the `pg/enum@1` codec descriptor). No casts.
|
|
1056
|
+
*/
|
|
1057
|
+
function hasColumnFromEntityHook(descriptor) {
|
|
1058
|
+
return "columnFromEntity" in descriptor && typeof descriptor.columnFromEntity === "function";
|
|
1059
|
+
}
|
|
1060
|
+
/**
|
|
1061
|
+
* Resolves a type-constructor call whose descriptor declares an
|
|
1062
|
+
* `entityRefArg` (e.g. `pg.enum(AalLevel)`): extracts the call's sole
|
|
1063
|
+
* positional-argument ref string, resolves it against the field's
|
|
1064
|
+
* namespace's already-lowered extension entities (keyed by the declared
|
|
1065
|
+
* `entityRefArg.entityKind`, then block name), and converts the resolved
|
|
1066
|
+
* entity to column params via the `columnFromEntity` authoring hook on the
|
|
1067
|
+
* codec descriptor registered for `descriptor.output.codecId`. The
|
|
1068
|
+
* `typeParams.typeName` `columnFromEntity` returns is bare — schema
|
|
1069
|
+
* qualification (e.g. `auth.aal_level`) is a target concern, applied later
|
|
1070
|
+
* when the target builds the field's namespace. A `valueSet` ref is
|
|
1071
|
+
* attached when the same namespace derived a value-set under the same block
|
|
1072
|
+
* name (the generic `deriveValueSet` mechanism), scoped to the field's own
|
|
1073
|
+
* namespace.
|
|
1074
|
+
*/
|
|
1075
|
+
function resolveEntityRefTypeConstructorCall(input) {
|
|
1076
|
+
const entityRefArg = input.descriptor.entityRefArg;
|
|
1077
|
+
if (entityRefArg === void 0) throw new InternalError("resolveEntityRefTypeConstructorCall called with a descriptor that does not declare an entityRefArg. This is an interpreter bug.");
|
|
1078
|
+
const helperPath = input.call.path.join(".");
|
|
1079
|
+
const positionalArgs = input.call.args.filter((arg) => arg.kind === "positional");
|
|
1080
|
+
const argument = positionalArgs[entityRefArg.index];
|
|
1081
|
+
const ref = argument?.value;
|
|
1082
|
+
const node = argument?.expression?.syntax;
|
|
1083
|
+
const resolution = node === void 0 ? void 0 : input.binder?.symbolForNode(node);
|
|
1084
|
+
if (input.call.args.length !== 1 || positionalArgs.length !== 1 || ref === void 0 || input.binder !== void 0 && resolution === void 0) {
|
|
1085
|
+
input.diagnostics.push({
|
|
1086
|
+
code: "PSL_INVALID_ATTRIBUTE_ARGUMENT",
|
|
1087
|
+
message: `${input.entityLabel} type constructor "${helperPath}" expects exactly one positional argument naming the referenced entity`,
|
|
1088
|
+
...input.source.at(input.call.span)
|
|
1089
|
+
});
|
|
1090
|
+
return NOT_RESOLVED;
|
|
1091
|
+
}
|
|
1092
|
+
let entityName = ref;
|
|
1093
|
+
let entityNamespaceId = input.namespaceId;
|
|
1094
|
+
const reportUnknownRef = () => {
|
|
1095
|
+
input.diagnostics.push({
|
|
1096
|
+
code: "PSL_UNKNOWN_ENTITY_REF",
|
|
1097
|
+
message: `${input.entityLabel} type constructor "${helperPath}(${ref})" does not resolve — no entity named "${ref}" was found in namespace "${entityNamespaceId ?? "(unspecified)"}"`,
|
|
1098
|
+
...input.source.at(input.call.span)
|
|
1099
|
+
});
|
|
1100
|
+
return NOT_RESOLVED;
|
|
1101
|
+
};
|
|
1102
|
+
if (resolution !== void 0) {
|
|
1103
|
+
if (resolution.kind === "unresolved") return NOT_RESOLVED;
|
|
1104
|
+
if (resolution.kind !== "block") return reportUnknownRef();
|
|
1105
|
+
entityName = resolution.symbol.name;
|
|
1106
|
+
entityNamespaceId = resolution.namespace.id;
|
|
1107
|
+
}
|
|
1108
|
+
const entities = entityNamespaceId === void 0 ? void 0 : input.namespaceExtensionEntities?.get(entityNamespaceId);
|
|
1109
|
+
const entity = entities?.[entityRefArg.entityKind]?.[entityName];
|
|
1110
|
+
if (entity === void 0) return reportUnknownRef();
|
|
1111
|
+
const codecId = input.descriptor.output.codecId;
|
|
1112
|
+
const codecDescriptor = input.codecLookup.descriptorFor(codecId);
|
|
1113
|
+
if (codecDescriptor === void 0 || !hasColumnFromEntityHook(codecDescriptor)) throw contractError("CONTRACT.PACK_CONTRIBUTION_INVALID", `Type constructor "${helperPath}" registers codecId "${codecId}" with an entity-ref argument, but its codec descriptor has no "columnFromEntity" authoring hook. This is a contributor bug in the pack registering "${helperPath}", not a user-schema error.`, { meta: {
|
|
1114
|
+
helperPath,
|
|
1115
|
+
codecId
|
|
1116
|
+
} });
|
|
1117
|
+
const resolved = codecDescriptor.columnFromEntity(entity);
|
|
1118
|
+
if (resolved === void 0) return reportUnknownRef();
|
|
1119
|
+
const valueSet = entities?.["valueSet"]?.[entityName] !== void 0 && entityNamespaceId !== void 0 ? {
|
|
1120
|
+
plane: "storage",
|
|
1121
|
+
entityKind: "valueSet",
|
|
1122
|
+
namespaceId: entityNamespaceId,
|
|
1123
|
+
entityName
|
|
1124
|
+
} : void 0;
|
|
1125
|
+
return {
|
|
1126
|
+
ok: true,
|
|
1127
|
+
descriptor: {
|
|
1128
|
+
codecId,
|
|
1129
|
+
...resolved.typeParams !== void 0 ? { typeParams: resolved.typeParams } : {},
|
|
1130
|
+
...valueSet !== void 0 ? { valueSet } : {}
|
|
1131
|
+
}
|
|
1132
|
+
};
|
|
1133
|
+
}
|
|
1134
|
+
const NOT_RESOLVED = { ok: false };
|
|
1135
|
+
function instantiateFieldTypeConstructor(input) {
|
|
1136
|
+
if (input.descriptor.entityRefArg !== void 0) return resolveEntityRefTypeConstructorCall({
|
|
1137
|
+
call: input.call,
|
|
1138
|
+
descriptor: input.descriptor,
|
|
1139
|
+
namespaceId: input.namespaceId,
|
|
1140
|
+
namespaceExtensionEntities: input.namespaceExtensionEntities,
|
|
1141
|
+
binder: input.binder,
|
|
1142
|
+
codecLookup: input.codecLookup,
|
|
1143
|
+
diagnostics: input.diagnostics,
|
|
1144
|
+
source: input.source,
|
|
1145
|
+
entityLabel: input.entityLabel
|
|
1146
|
+
});
|
|
1147
|
+
const instantiated = instantiatePslTypeConstructor({
|
|
1148
|
+
call: input.call,
|
|
1149
|
+
descriptor: input.descriptor,
|
|
1150
|
+
codecLookup: input.codecLookup,
|
|
1151
|
+
diagnostics: input.diagnostics,
|
|
1152
|
+
source: input.source,
|
|
1153
|
+
entityLabel: input.entityLabel,
|
|
1154
|
+
dataTypes: input.dataTypes
|
|
1155
|
+
});
|
|
1156
|
+
return instantiated === void 0 ? NOT_RESOLVED : {
|
|
1157
|
+
ok: true,
|
|
1158
|
+
descriptor: instantiated
|
|
1159
|
+
};
|
|
1160
|
+
}
|
|
1161
|
+
function instantiateFieldPreset(input) {
|
|
1162
|
+
const instantiated = instantiatePslFieldPreset(input);
|
|
1163
|
+
if (!instantiated) return NOT_RESOLVED;
|
|
1164
|
+
if (!checkPslTypeParams({
|
|
1165
|
+
call: input.call,
|
|
1166
|
+
subject: `${input.entityLabel} preset "${input.call.path.join(".")}"`,
|
|
1167
|
+
args: input.descriptor.args,
|
|
1168
|
+
template: input.descriptor.output,
|
|
1169
|
+
typeParams: instantiated.descriptor.typeParams,
|
|
1170
|
+
codecLookup: input.codecLookup,
|
|
1171
|
+
diagnostics: input.diagnostics,
|
|
1172
|
+
source: input.source
|
|
1173
|
+
})) return NOT_RESOLVED;
|
|
1174
|
+
const presetContributions = {
|
|
1175
|
+
nullable: instantiated.nullable,
|
|
1176
|
+
id: instantiated.id,
|
|
1177
|
+
unique: instantiated.unique,
|
|
1178
|
+
...instantiated.default !== void 0 ? { default: instantiated.default } : {},
|
|
1179
|
+
...instantiated.executionDefaults !== void 0 ? { executionDefaults: instantiated.executionDefaults } : {}
|
|
1180
|
+
};
|
|
1181
|
+
return {
|
|
1182
|
+
ok: true,
|
|
1183
|
+
descriptor: instantiated.descriptor,
|
|
1184
|
+
presetContributions
|
|
1185
|
+
};
|
|
1186
|
+
}
|
|
1187
|
+
function resolvedKindLabel(resolution) {
|
|
1188
|
+
switch (resolution.kind) {
|
|
1189
|
+
case "compositeType": return "composite type";
|
|
1190
|
+
case "namedType": return "type alias";
|
|
1191
|
+
case "block": return resolution.symbol.keyword;
|
|
1192
|
+
case "crossSpace": return "type of another contract space";
|
|
1193
|
+
default: return resolution.kind;
|
|
1194
|
+
}
|
|
1195
|
+
}
|
|
1196
|
+
function resolveFieldTypeDescriptor(input) {
|
|
1197
|
+
const { field, resolution, entityLabel, diagnostics } = input;
|
|
1198
|
+
if (field.malformedType || resolution === void 0) return NOT_RESOLVED;
|
|
1199
|
+
const source = diagnosticSource(input.sources, field.node.syntax);
|
|
1200
|
+
const unsupported = (message) => {
|
|
1201
|
+
diagnostics.push({
|
|
1202
|
+
code: "PSL_UNSUPPORTED_FIELD_TYPE",
|
|
1203
|
+
message,
|
|
1204
|
+
...source.at(field.span)
|
|
1205
|
+
});
|
|
1206
|
+
return NOT_RESOLVED;
|
|
1207
|
+
};
|
|
1208
|
+
const call = field.typeConstructor;
|
|
1209
|
+
switch (resolution.kind) {
|
|
1210
|
+
case "unresolved":
|
|
1211
|
+
case "namespace":
|
|
1212
|
+
case "contributedNamespace":
|
|
1213
|
+
case "mixin": return NOT_RESOLVED;
|
|
1214
|
+
case "contributedType": {
|
|
1215
|
+
const { descriptor, path } = resolution.symbol;
|
|
1216
|
+
const written = path.join(".");
|
|
1217
|
+
if (descriptor.kind === "typeAlias") {
|
|
1218
|
+
if (call !== void 0) {
|
|
1219
|
+
diagnostics.push({
|
|
1220
|
+
code: "PSL_INVALID_ATTRIBUTE_ARGUMENT",
|
|
1221
|
+
message: `${written} is a type alias and takes no arguments.`,
|
|
1222
|
+
...source.at(call.span)
|
|
1223
|
+
});
|
|
1224
|
+
return NOT_RESOLVED;
|
|
1225
|
+
}
|
|
1226
|
+
return {
|
|
1227
|
+
ok: true,
|
|
1228
|
+
descriptor: instantiateAuthoringTypeAlias(descriptor).type
|
|
1229
|
+
};
|
|
1230
|
+
}
|
|
1231
|
+
if (descriptor.kind === "fieldPreset") {
|
|
1232
|
+
if (call === void 0) {
|
|
1233
|
+
reportPresetNotCalled({
|
|
1234
|
+
entityLabel,
|
|
1235
|
+
presetPath: written,
|
|
1236
|
+
source,
|
|
1237
|
+
span: field.span,
|
|
1238
|
+
diagnostics
|
|
1239
|
+
});
|
|
1240
|
+
return NOT_RESOLVED;
|
|
1241
|
+
}
|
|
1242
|
+
return instantiateFieldPreset({
|
|
1243
|
+
call,
|
|
1244
|
+
descriptor,
|
|
1245
|
+
codecLookup: input.codecLookup,
|
|
1246
|
+
diagnostics,
|
|
1247
|
+
source,
|
|
1248
|
+
entityLabel,
|
|
1249
|
+
dataTypes: input.dataTypes
|
|
1250
|
+
});
|
|
1251
|
+
}
|
|
1252
|
+
if (call !== void 0) return instantiateFieldTypeConstructor({
|
|
1253
|
+
...input,
|
|
1254
|
+
call,
|
|
1255
|
+
descriptor,
|
|
1256
|
+
source
|
|
1257
|
+
});
|
|
1258
|
+
if (!isBareTypeConstructor(descriptor)) {
|
|
1259
|
+
reportTypeConstructorNotCalled({
|
|
1260
|
+
entityLabel,
|
|
1261
|
+
path: written,
|
|
1262
|
+
descriptor,
|
|
1263
|
+
source,
|
|
1264
|
+
span: field.span,
|
|
1265
|
+
diagnostics
|
|
1266
|
+
});
|
|
1267
|
+
return NOT_RESOLVED;
|
|
1268
|
+
}
|
|
1269
|
+
return {
|
|
1270
|
+
ok: true,
|
|
1271
|
+
descriptor: instantiateAuthoringTypeConstructor(descriptor, [])
|
|
1272
|
+
};
|
|
1273
|
+
}
|
|
1274
|
+
case "field":
|
|
1275
|
+
case "attribute":
|
|
1276
|
+
case "parameter":
|
|
1277
|
+
case "function":
|
|
1278
|
+
case "constant": throw new InternalError(`The type of ${entityLabel} resolved to a ${resolution.kind}; a type reference never names one. This is a binder bug.`);
|
|
1279
|
+
}
|
|
1280
|
+
if (call !== void 0) return unsupported(`${entityLabel} calls "${call.path.join(".")}", which is a ${resolvedKindLabel(resolution)}, not a type constructor. Remove the arguments.`);
|
|
1281
|
+
switch (resolution.kind) {
|
|
1282
|
+
case "namedType": {
|
|
1283
|
+
const alias = input.typeAliases.get(resolution.symbol);
|
|
1284
|
+
return alias === void 0 ? NOT_RESOLVED : {
|
|
1285
|
+
ok: true,
|
|
1286
|
+
descriptor: alias.descriptor
|
|
1287
|
+
};
|
|
1288
|
+
}
|
|
1289
|
+
case "block": {
|
|
1290
|
+
if (resolution.symbol.keyword !== "enum") return unsupported(`${entityLabel} is typed by the ${resolution.symbol.keyword} "${resolution.symbol.name}", which is not a column type.`);
|
|
1291
|
+
const descriptor = input.enumTypeDescriptors.get(resolution.symbol);
|
|
1292
|
+
return descriptor === void 0 ? NOT_RESOLVED : {
|
|
1293
|
+
ok: true,
|
|
1294
|
+
descriptor
|
|
1295
|
+
};
|
|
1296
|
+
}
|
|
1297
|
+
case "model":
|
|
1298
|
+
case "compositeType": return unsupported(`${entityLabel} is typed by the ${resolvedKindLabel(resolution)} "${resolution.symbol.name}", which is not a column type.`);
|
|
1299
|
+
case "crossSpace": return unsupported(`${entityLabel} type "${field.typeName}" is a type of contract space "${field.typeContractSpaceId}"; only a relation field can name a type of another contract space.`);
|
|
1300
|
+
}
|
|
1301
|
+
}
|
|
1302
|
+
const PSL_INVALID_DEFAULT_SQL = "PSL_INVALID_DEFAULT_SQL";
|
|
1303
|
+
const TAGGED_LITERAL_CANONICALIZATION_CODES = {
|
|
1304
|
+
nul: "PSL_TAGGED_LITERAL_NUL",
|
|
1305
|
+
"too-large": "PSL_TAGGED_LITERAL_TOO_LARGE"
|
|
1306
|
+
};
|
|
1307
|
+
/**
|
|
1308
|
+
* Refuses a `null` element in the list default of a field whose list elements are not nullable,
|
|
1309
|
+
* at the first `null`. Returns whether it refused.
|
|
1310
|
+
*/
|
|
1311
|
+
function rejectStrictListNullDefault(input) {
|
|
1312
|
+
if (input.owner.elementOptional) return false;
|
|
1313
|
+
const nullElement = input.elements.find(isParsedNullLiteral);
|
|
1314
|
+
if (nullElement === void 0) return false;
|
|
1315
|
+
input.diagnostics.push({
|
|
1316
|
+
code: "PSL_INVALID_DEFAULT_APPLICABILITY",
|
|
1317
|
+
message: `${typeAttributeSubjectLabel(input.owner.specContext.subject)} has strict list elements and cannot use null in a literal list default. Make the element type nullable or remove null from the default.`,
|
|
1318
|
+
...input.source.at(nullElement.span)
|
|
1319
|
+
});
|
|
1320
|
+
return true;
|
|
1321
|
+
}
|
|
1322
|
+
function isParsedNullLiteral(element) {
|
|
1323
|
+
return element.kind === "null";
|
|
1324
|
+
}
|
|
1325
|
+
function fieldAttributeOwner(input) {
|
|
1326
|
+
const { field, model } = input;
|
|
1327
|
+
return {
|
|
1328
|
+
attributes: field.attributes,
|
|
1329
|
+
optional: field.optional,
|
|
1330
|
+
list: field.list,
|
|
1331
|
+
elementOptional: field.elementOptional,
|
|
1332
|
+
specContext: typeAttributeSpecContextOfField(fieldSpecContext({
|
|
1333
|
+
symbols: input.symbolTable,
|
|
1334
|
+
model,
|
|
1335
|
+
field,
|
|
1336
|
+
binder: input.binder,
|
|
1337
|
+
defaultFunctionRegistry: input.defaultFunctionRegistry,
|
|
1338
|
+
generatorFunctions: input.generatorFunctions,
|
|
1339
|
+
dataTypes: input.dataTypes
|
|
1340
|
+
})),
|
|
1341
|
+
loweringNames: {
|
|
1342
|
+
modelName: model.name,
|
|
1343
|
+
fieldName: field.name
|
|
1344
|
+
}
|
|
1345
|
+
};
|
|
1346
|
+
}
|
|
1347
|
+
function lowerDefaultForField(input) {
|
|
1348
|
+
return lowerTypeDefault({
|
|
1349
|
+
...input,
|
|
1350
|
+
owner: fieldAttributeOwner(input)
|
|
1351
|
+
});
|
|
1352
|
+
}
|
|
1353
|
+
/** The default a field's or type alias's `@default(...)` lowers to for its column. */
|
|
1354
|
+
function lowerTypeDefault(input) {
|
|
1355
|
+
const node = getAttribute(input.owner.attributes, "default")?.node;
|
|
1356
|
+
if (node === void 0) return {};
|
|
1357
|
+
const source = diagnosticSource(input.sources, node.syntax);
|
|
1358
|
+
const subject = typeAttributeSubjectLabel(input.owner.specContext.subject);
|
|
1359
|
+
const interpreted = interpretTypeAttribute({
|
|
1360
|
+
symbols: input.symbolTable,
|
|
1361
|
+
node,
|
|
1362
|
+
spec: typeDefaultSpec(input.owner.specContext),
|
|
1363
|
+
sources: input.sources,
|
|
1364
|
+
binder: input.binder,
|
|
1365
|
+
diagnostics: input.diagnostics
|
|
1366
|
+
});
|
|
1367
|
+
if (interpreted === void 0) return {};
|
|
1368
|
+
const value = interpreted.value;
|
|
1369
|
+
const attributeSpan = nodePslSpan(node.syntax, input.sources);
|
|
1370
|
+
if (value.kind === "null") {
|
|
1371
|
+
if (!input.owner.optional) {
|
|
1372
|
+
input.diagnostics.push({
|
|
1373
|
+
code: "PSL_INVALID_DEFAULT_APPLICABILITY",
|
|
1374
|
+
message: `${subject} is non-nullable and cannot use null as its literal default. Make the field nullable or use a non-null default.`,
|
|
1375
|
+
...source.at()
|
|
1376
|
+
});
|
|
1377
|
+
return {};
|
|
1378
|
+
}
|
|
1379
|
+
return { defaultValue: {
|
|
1380
|
+
kind: "literal",
|
|
1381
|
+
value: null,
|
|
1382
|
+
inStoredForm: true
|
|
1383
|
+
} };
|
|
1384
|
+
}
|
|
1385
|
+
if (value.kind === "list" && rejectStrictListNullDefault({
|
|
1386
|
+
...input,
|
|
1387
|
+
elements: value.elements,
|
|
1388
|
+
source
|
|
1389
|
+
})) return {};
|
|
1390
|
+
const readsListElements = (written) => input.isListColumn || input.owner.list && written.kind === "list";
|
|
1391
|
+
const readAsLiteral = (written, spans, sourceElementIndexes) => {
|
|
1392
|
+
const lowered = lowerDataTypeDefault({
|
|
1393
|
+
written,
|
|
1394
|
+
spans,
|
|
1395
|
+
sourceElementIndexes,
|
|
1396
|
+
isList: readsListElements(written),
|
|
1397
|
+
column: {
|
|
1398
|
+
codecId: input.columnDescriptor.codecId,
|
|
1399
|
+
typeParams: input.columnTypeParams
|
|
1400
|
+
},
|
|
1401
|
+
codecLookup: input.codecLookup,
|
|
1402
|
+
dataTypes: input.dataTypes,
|
|
1403
|
+
subject
|
|
1404
|
+
});
|
|
1405
|
+
if (!lowered.ok) {
|
|
1406
|
+
input.diagnostics.push({
|
|
1407
|
+
code: lowered.code,
|
|
1408
|
+
message: lowered.message,
|
|
1409
|
+
...source.at(lowered.span)
|
|
1410
|
+
});
|
|
1411
|
+
return {};
|
|
1412
|
+
}
|
|
1413
|
+
let restoredValue = lowered.value;
|
|
1414
|
+
if (value.kind === "list" && value.elements.some(isParsedNullLiteral) && Array.isArray(lowered.value)) {
|
|
1415
|
+
let index = 0;
|
|
1416
|
+
const nonNullValues = lowered.value;
|
|
1417
|
+
restoredValue = value.elements.map((element) => element.kind === "null" ? null : nonNullValues[index++] ?? null);
|
|
1418
|
+
}
|
|
1419
|
+
if (input.valueObjectDefault !== void 0) {
|
|
1420
|
+
const { document, stored } = valueObjectDefaultDocument({
|
|
1421
|
+
stored: restoredValue,
|
|
1422
|
+
elementwise: readsListElements(written) && !input.isListColumn,
|
|
1423
|
+
codecId: input.columnDescriptor.codecId,
|
|
1424
|
+
codecLookup: input.codecLookup
|
|
1425
|
+
});
|
|
1426
|
+
const mismatches = valueObjectDefaultMismatches({
|
|
1427
|
+
fieldPath: input.owner.specContext.subject.name,
|
|
1428
|
+
value: document,
|
|
1429
|
+
list: input.owner.list,
|
|
1430
|
+
nullable: input.owner.optional,
|
|
1431
|
+
elementNullable: input.owner.elementOptional,
|
|
1432
|
+
...input.valueObjectDefault,
|
|
1433
|
+
lookups: {
|
|
1434
|
+
codecLookup: input.codecLookup,
|
|
1435
|
+
dataTypeLookup: input.dataTypes.lookup
|
|
1436
|
+
}
|
|
1437
|
+
});
|
|
1438
|
+
for (const { code, message } of mismatches) input.diagnostics.push({
|
|
1439
|
+
code,
|
|
1440
|
+
message,
|
|
1441
|
+
...source.at()
|
|
1442
|
+
});
|
|
1443
|
+
if (mismatches.length > 0) return {};
|
|
1444
|
+
return { defaultValue: {
|
|
1445
|
+
kind: "literal",
|
|
1446
|
+
value: stored,
|
|
1447
|
+
inStoredForm: true
|
|
1448
|
+
} };
|
|
1449
|
+
}
|
|
1450
|
+
return { defaultValue: {
|
|
1451
|
+
kind: "literal",
|
|
1452
|
+
value: restoredValue,
|
|
1453
|
+
inStoredForm: true
|
|
1454
|
+
} };
|
|
1455
|
+
};
|
|
1456
|
+
const canonicalized = (scalar) => {
|
|
1457
|
+
if (scalar.written !== void 0) return scalar.written;
|
|
1458
|
+
input.diagnostics.push({
|
|
1459
|
+
code: TAGGED_LITERAL_CANONICALIZATION_CODES[scalar.reason],
|
|
1460
|
+
message: describeTaggedLiteralFailure$1(scalar.reason),
|
|
1461
|
+
...source.at(scalar.span)
|
|
1462
|
+
});
|
|
1463
|
+
};
|
|
1464
|
+
const sqlExpressionDefault = (text, span) => {
|
|
1465
|
+
const reserved = reservedSqlDefaultText(text);
|
|
1466
|
+
const refusal = reserved === void 0 ? checkSqlDefaultText(text) : `Write @default(${reserved}()) instead of sql\`${reserved}()\`; ${reserved}() is a Prisma default function, not raw SQL.`;
|
|
1467
|
+
if (refusal !== void 0) {
|
|
1468
|
+
input.diagnostics.push({
|
|
1469
|
+
code: PSL_INVALID_DEFAULT_SQL,
|
|
1470
|
+
message: refusal,
|
|
1471
|
+
...source.at(span)
|
|
1472
|
+
});
|
|
1473
|
+
return {};
|
|
1474
|
+
}
|
|
1475
|
+
return { defaultValue: {
|
|
1476
|
+
kind: "function",
|
|
1477
|
+
expression: text
|
|
1478
|
+
} };
|
|
1479
|
+
};
|
|
1480
|
+
if (value.kind === "member" || value.kind === "member-list") return {};
|
|
1481
|
+
if (input.columnDescriptor.valueSet !== void 0) {
|
|
1482
|
+
const memberName = (element) => element.kind === "scalar" && element.written?.kind === "string" ? element.written.text : void 0;
|
|
1483
|
+
if (value.kind === "scalar") {
|
|
1484
|
+
const member = memberName(value);
|
|
1485
|
+
if (member !== void 0) return { defaultValue: {
|
|
1486
|
+
kind: "literal",
|
|
1487
|
+
value: member
|
|
1488
|
+
} };
|
|
1489
|
+
}
|
|
1490
|
+
if (value.kind === "list") {
|
|
1491
|
+
const members = value.elements.map((element) => element.kind === "null" ? null : memberName(element));
|
|
1492
|
+
if (members.every((member) => member !== void 0)) return { defaultValue: {
|
|
1493
|
+
kind: "literal",
|
|
1494
|
+
value: members
|
|
1495
|
+
} };
|
|
1496
|
+
}
|
|
1497
|
+
}
|
|
1498
|
+
if (value.kind === "list") {
|
|
1499
|
+
const elements = [];
|
|
1500
|
+
const sourceElementIndexes = [];
|
|
1501
|
+
for (const [sourceIndex, element] of value.elements.entries()) {
|
|
1502
|
+
if (element.kind === "null") continue;
|
|
1503
|
+
const written = canonicalized(element);
|
|
1504
|
+
if (written === void 0) return {};
|
|
1505
|
+
elements.push(written);
|
|
1506
|
+
sourceElementIndexes.push(sourceIndex);
|
|
1507
|
+
}
|
|
1508
|
+
return readAsLiteral({
|
|
1509
|
+
kind: "list",
|
|
1510
|
+
elements
|
|
1511
|
+
}, {
|
|
1512
|
+
attribute: attributeSpan,
|
|
1513
|
+
value: value.span,
|
|
1514
|
+
elements: value.elements.map((element) => element.span)
|
|
1515
|
+
}, sourceElementIndexes);
|
|
1516
|
+
}
|
|
1517
|
+
if (value.kind === "scalar") {
|
|
1518
|
+
const written = canonicalized(value);
|
|
1519
|
+
if (written === void 0) return {};
|
|
1520
|
+
const spans = {
|
|
1521
|
+
attribute: attributeSpan,
|
|
1522
|
+
value: value.span,
|
|
1523
|
+
elements: []
|
|
1524
|
+
};
|
|
1525
|
+
if (written.kind !== "tag") return readAsLiteral(written, spans);
|
|
1526
|
+
const read = readWrittenValue(input.dataTypes, written);
|
|
1527
|
+
if (read.ok && read.value.type === SQL_EXPRESSION_DATA_TYPE_ID) return sqlExpressionDefault(sqlTextFromStored(read.value.value), value.span);
|
|
1528
|
+
return readAsLiteral(written, spans);
|
|
1529
|
+
}
|
|
1530
|
+
const { call } = value;
|
|
1531
|
+
const context = {
|
|
1532
|
+
sourceId: input.sources.sourceFileFor(node.syntax).filename,
|
|
1533
|
+
...input.owner.loweringNames,
|
|
1534
|
+
columnCodecId: input.columnDescriptor.codecId
|
|
1535
|
+
};
|
|
1536
|
+
const lowered = lowerDefaultFunctionWithRegistry({
|
|
1537
|
+
call,
|
|
1538
|
+
registry: input.defaultFunctionRegistry,
|
|
1539
|
+
context,
|
|
1540
|
+
source
|
|
1541
|
+
});
|
|
1542
|
+
if (!lowered.ok) {
|
|
1543
|
+
if (lowered.kind === "owned") input.diagnostics.push(lowered.diagnostic);
|
|
1544
|
+
else input.diagnostics.pushExternal(lowered.diagnostic);
|
|
1545
|
+
return {};
|
|
1546
|
+
}
|
|
1547
|
+
return { defaultValue: lowered.value.defaultValue };
|
|
1548
|
+
}
|
|
1549
|
+
const GENERATOR_PHASES = ["onCreate", "onUpdate"];
|
|
1550
|
+
/** The generators a field's `@onCreate(fn())` and `@onUpdate(fn())` resolve to for its column, or `undefined` for a field with neither. */
|
|
1551
|
+
function lowerGeneratorAttributesForField(input) {
|
|
1552
|
+
return lowerTypeGenerators({
|
|
1553
|
+
...input,
|
|
1554
|
+
owner: fieldAttributeOwner(input)
|
|
1555
|
+
});
|
|
1556
|
+
}
|
|
1557
|
+
/** The generators the `@onCreate(fn())` and `@onUpdate(fn())` of a field or type alias resolve to for its column, or `undefined` when it has neither. */
|
|
1558
|
+
function lowerTypeGenerators(input) {
|
|
1559
|
+
const { subject } = input.owner.specContext;
|
|
1560
|
+
const label = typeAttributeSubjectLabel(subject);
|
|
1561
|
+
const phases = {};
|
|
1562
|
+
for (const phase of GENERATOR_PHASES) {
|
|
1563
|
+
const [attribute, duplicate] = input.owner.attributes.filter(({ name }) => name === phase);
|
|
1564
|
+
if (attribute === void 0) continue;
|
|
1565
|
+
if (duplicate !== void 0) {
|
|
1566
|
+
input.diagnostics.push({
|
|
1567
|
+
code: "PSL_DUPLICATE_ATTRIBUTE",
|
|
1568
|
+
message: `\`@${phase}\` declared more than once on ${subject.kind} "${subject.name}".`,
|
|
1569
|
+
...diagnosticSource(input.sources, duplicate.node.syntax).at(duplicate.span)
|
|
1570
|
+
});
|
|
1571
|
+
continue;
|
|
1572
|
+
}
|
|
1573
|
+
const node = attribute.node;
|
|
1574
|
+
const interpreted = interpretTypeAttribute({
|
|
1575
|
+
symbols: input.symbolTable,
|
|
1576
|
+
node,
|
|
1577
|
+
spec: typeGeneratorAttributeSpec(phase, input.owner.specContext),
|
|
1578
|
+
sources: input.sources,
|
|
1579
|
+
binder: input.binder,
|
|
1580
|
+
diagnostics: input.diagnostics
|
|
1581
|
+
});
|
|
1582
|
+
if (interpreted === void 0) continue;
|
|
1583
|
+
const call = interpreted.value;
|
|
1584
|
+
const resolution = input.generatorFunctions.resolve({
|
|
1585
|
+
name: call.fn,
|
|
1586
|
+
args: call.args
|
|
1587
|
+
}, {
|
|
1588
|
+
codecId: input.columnDescriptor.codecId,
|
|
1589
|
+
typeParams: input.columnTypeParams,
|
|
1590
|
+
length: sqlCodecColumnLength(input.dataTypes, input.columnDescriptor.codecId, input.columnTypeParams)
|
|
1591
|
+
});
|
|
1592
|
+
if (resolution.ok) {
|
|
1593
|
+
phases[phase] = resolution.generator;
|
|
1594
|
+
continue;
|
|
1595
|
+
}
|
|
1596
|
+
input.diagnostics.push({
|
|
1597
|
+
code: "PSL_GENERATOR_NOT_APPLICABLE",
|
|
1598
|
+
message: resolution.reason === "refused" ? `${label}: ${resolution.message}` : `${label}: ${call.fn}() does not apply to codec "${input.columnDescriptor.codecId}".`,
|
|
1599
|
+
...diagnosticSource(input.sources, node.syntax).at(call.span)
|
|
1600
|
+
});
|
|
1601
|
+
}
|
|
1602
|
+
return phases.onCreate === void 0 && phases.onUpdate === void 0 ? void 0 : phases;
|
|
1603
|
+
}
|
|
1604
|
+
/** The default a field's or type alias's `@default(...)` names among the members of its enum. */
|
|
1605
|
+
function lowerEnumDefault(input) {
|
|
1606
|
+
const { owner, enumHandle, diagnostics } = input;
|
|
1607
|
+
const node = getAttribute(owner.attributes, "default")?.node;
|
|
1608
|
+
if (node === void 0) return {};
|
|
1609
|
+
if (enumHandle.enumMembers.length === 0) return {};
|
|
1610
|
+
const interpreted = interpretTypeAttribute({
|
|
1611
|
+
node,
|
|
1612
|
+
spec: typeDefaultSpec(owner.specContext),
|
|
1613
|
+
symbols: input.symbolTable,
|
|
1614
|
+
sources: input.sources,
|
|
1615
|
+
binder: input.binder,
|
|
1616
|
+
diagnostics
|
|
1617
|
+
});
|
|
1618
|
+
if (interpreted === void 0) return {};
|
|
1619
|
+
const member = interpreted.value;
|
|
1620
|
+
if (member.kind === "member-list") {
|
|
1621
|
+
if (rejectStrictListNullDefault({
|
|
1622
|
+
owner,
|
|
1623
|
+
elements: member.elements,
|
|
1624
|
+
source: diagnosticSource(input.sources, node.syntax),
|
|
1625
|
+
diagnostics
|
|
1626
|
+
})) return {};
|
|
1627
|
+
return { defaultValue: {
|
|
1628
|
+
kind: "literal",
|
|
1629
|
+
value: blindCast(member.elements.map((entry) => entry.kind === "null" ? null : enumHandle.enumMembers.find((candidate) => candidate.name === entry.name)?.value))
|
|
1630
|
+
} };
|
|
1631
|
+
}
|
|
1632
|
+
invariant(member.kind === "member", "the enum @default grammar admits only member identifiers");
|
|
1633
|
+
const match = enumHandle.enumMembers.find((m) => m.name === member.name);
|
|
1634
|
+
if (!match) return {};
|
|
1635
|
+
return { defaultValue: {
|
|
1636
|
+
kind: "literal",
|
|
1637
|
+
value: blindCast(match.value)
|
|
1638
|
+
} };
|
|
1639
|
+
}
|
|
1640
|
+
const MODEL_COORDINATE_SEPARATOR = "\0";
|
|
1641
|
+
function modelCoordinateKey(namespaceId, modelName) {
|
|
1642
|
+
return `${namespaceId}${MODEL_COORDINATE_SEPARATOR}${modelName}`;
|
|
1643
|
+
}
|
|
1644
|
+
const GENERATOR_ATTRIBUTE_NAMES = ["onCreate", "onUpdate"];
|
|
1645
|
+
const REMOVED_ATTRIBUTE_RULES = /* @__PURE__ */ new Map([["updatedAt", {
|
|
1646
|
+
hint: "Use @onCreate(now()) @onUpdate(now()), or type the field temporal.UpdatedAt.",
|
|
1647
|
+
suppressWhen: (field) => field.attributes.some((attribute) => attribute.name === "onUpdate")
|
|
1648
|
+
}]]);
|
|
1649
|
+
{
|
|
1650
|
+
const overlap = [...REMOVED_ATTRIBUTE_RULES.keys()].filter((name) => Object.hasOwn(sqlAttributeSpecs.field, name));
|
|
1651
|
+
if (overlap.length > 0) throw new InternalError(`Registered SQL field attributes and REMOVED_ATTRIBUTE_RULES must not overlap. Names in both: ${overlap.join(", ")}`);
|
|
1652
|
+
}
|
|
1653
|
+
function describeUnsupportedSqlAttribute(sources) {
|
|
1654
|
+
return ({ attribute, level, owner, field }) => {
|
|
1655
|
+
if (owner.kind === "compositeType") return void 0;
|
|
1656
|
+
if (owner.kind === "mixin" && owner.keyword === "type") return void 0;
|
|
1657
|
+
if (level === "model") {
|
|
1658
|
+
const source = diagnosticSource(sources, owner.node.syntax);
|
|
1659
|
+
return {
|
|
1660
|
+
code: "PSL_UNSUPPORTED_MODEL_ATTRIBUTE",
|
|
1661
|
+
message: `${owner.kind === "mixin" ? "Mixin" : "Model"} "${owner.name}" uses unsupported attribute "@@${attribute.name}"`,
|
|
1662
|
+
...source.at(attribute.span)
|
|
1663
|
+
};
|
|
1664
|
+
}
|
|
1665
|
+
if (field === void 0) return void 0;
|
|
1666
|
+
const source = diagnosticSource(sources, field.node.syntax);
|
|
1667
|
+
if (attribute.name.startsWith("db.")) return {
|
|
1668
|
+
code: "PSL_UNSUPPORTED_FIELD_ATTRIBUTE",
|
|
1669
|
+
message: formatDbAttributeMigrationMessage(attribute),
|
|
1670
|
+
...source.at(attribute.span)
|
|
1671
|
+
};
|
|
1672
|
+
const baseMessage = `Field "${owner.name}.${field.name}" uses unsupported attribute "@${attribute.name}"`;
|
|
1673
|
+
const removedRule = REMOVED_ATTRIBUTE_RULES.get(attribute.name);
|
|
1674
|
+
return {
|
|
1675
|
+
code: "PSL_UNSUPPORTED_FIELD_ATTRIBUTE",
|
|
1676
|
+
message: removedRule && !removedRule.suppressWhen(field) ? `${baseMessage}. ${removedRule.hint}` : baseMessage,
|
|
1677
|
+
...source.at(attribute.span)
|
|
1678
|
+
};
|
|
1679
|
+
};
|
|
1680
|
+
}
|
|
1681
|
+
function extractFieldConstraintNames(input) {
|
|
1682
|
+
const idAttribute = getAttribute(input.field.attributes, "id");
|
|
1683
|
+
const uniqueAttribute = getAttribute(input.field.attributes, "unique");
|
|
1684
|
+
const idNode = getAttribute(input.field.attributes, "id")?.node;
|
|
1685
|
+
const idName = idNode === void 0 ? void 0 : interpretFieldAttribute({
|
|
1686
|
+
node: idNode,
|
|
1687
|
+
symbols: input.symbolTable,
|
|
1688
|
+
spec: sqlAttributeSpecs.field.id(input.specContext),
|
|
1689
|
+
model: input.model,
|
|
1690
|
+
field: input.field,
|
|
1691
|
+
sources: input.sources,
|
|
1692
|
+
binder: input.binder,
|
|
1693
|
+
diagnostics: input.diagnostics
|
|
1694
|
+
})?.map;
|
|
1695
|
+
const uniqueNode = getAttribute(input.field.attributes, "unique")?.node;
|
|
1696
|
+
return {
|
|
1697
|
+
idAttribute,
|
|
1698
|
+
uniqueAttribute,
|
|
1699
|
+
idName,
|
|
1700
|
+
uniqueName: uniqueNode === void 0 ? void 0 : interpretFieldAttribute({
|
|
1701
|
+
node: uniqueNode,
|
|
1702
|
+
symbols: input.symbolTable,
|
|
1703
|
+
spec: sqlAttributeSpecs.field.unique(input.specContext),
|
|
1704
|
+
model: input.model,
|
|
1705
|
+
field: input.field,
|
|
1706
|
+
sources: input.sources,
|
|
1707
|
+
binder: input.binder,
|
|
1708
|
+
diagnostics: input.diagnostics
|
|
1709
|
+
})?.map
|
|
1710
|
+
};
|
|
1711
|
+
}
|
|
1712
|
+
function collectResolvedFields(input) {
|
|
1713
|
+
const { model, symbolTable, enumTypeDescriptors, typeAliases, valueObjectTypes, authoringContributions, binder, targetId, defaultFunctionRegistry, generatorFunctions, dataTypes, diagnostics, sources, scalarColumnDescriptors, enumHandles, capabilities, namespaceId, namespaceExtensionEntities, codecLookup } = input;
|
|
1714
|
+
const resolvedFields = [];
|
|
1715
|
+
const valueObjectStorageTypeName = authoringContributions?.valueObjectStorageType;
|
|
1716
|
+
for (const field of Object.values(model.fields)) {
|
|
1717
|
+
const source = diagnosticSource(sources, field.node.syntax);
|
|
1718
|
+
const fieldTypeReference = typeReferenceNode(field);
|
|
1719
|
+
const fieldTypeResolution = fieldTypeReference === void 0 ? void 0 : binder.symbolForNode(fieldTypeReference);
|
|
1720
|
+
const isModelField = fieldTypeResolution?.kind === "model";
|
|
1721
|
+
if (field.list && isModelField) continue;
|
|
1722
|
+
const relationAttribute = getAttribute(field.attributes, "relation");
|
|
1723
|
+
if (isModelField && relationAttribute) continue;
|
|
1724
|
+
if (field.typeContractSpaceId !== void 0 && relationAttribute) continue;
|
|
1725
|
+
if (isModelField) continue;
|
|
1726
|
+
const valueObjectName = fieldTypeResolution?.kind === "compositeType" ? fieldTypeResolution.symbol.name : void 0;
|
|
1727
|
+
const isValueObjectField = valueObjectName !== void 0;
|
|
1728
|
+
const isListField = field.list;
|
|
1729
|
+
const isListColumn = storedAsListColumn({
|
|
1730
|
+
list: isListField,
|
|
1731
|
+
typedByValueObject: isValueObjectField
|
|
1732
|
+
});
|
|
1733
|
+
let descriptor;
|
|
1734
|
+
let presetContributions;
|
|
1735
|
+
const resolveInput = {
|
|
1736
|
+
field,
|
|
1737
|
+
resolution: fieldTypeResolution,
|
|
1738
|
+
enumTypeDescriptors,
|
|
1739
|
+
typeAliases,
|
|
1740
|
+
diagnostics,
|
|
1741
|
+
sources,
|
|
1742
|
+
entityLabel: `Field "${model.name}.${field.name}"`,
|
|
1743
|
+
...ifDefined("namespaceId", namespaceId),
|
|
1744
|
+
...ifDefined("namespaceExtensionEntities", namespaceExtensionEntities),
|
|
1745
|
+
binder,
|
|
1746
|
+
codecLookup,
|
|
1747
|
+
dataTypes
|
|
1748
|
+
};
|
|
1749
|
+
if (isValueObjectField) {
|
|
1750
|
+
if (valueObjectStorageTypeName === void 0) {
|
|
1751
|
+
diagnostics.push({
|
|
1752
|
+
code: "PSL_UNSUPPORTED_FIELD_TYPE",
|
|
1753
|
+
message: `Field "${model.name}.${field.name}" is typed by the composite type "${field.typeName}", but the adapter of the stack declares no storage type for value objects, so the field has no column to be stored in.`,
|
|
1754
|
+
...source.at(field.span)
|
|
1755
|
+
});
|
|
1756
|
+
continue;
|
|
1757
|
+
}
|
|
1758
|
+
descriptor = scalarColumnDescriptors.get(valueObjectStorageTypeName);
|
|
1759
|
+
if (descriptor === void 0) throw new InternalError(`The stack declares "${valueObjectStorageTypeName}" as its value-object storage type, but it is not one of the stack's scalar types; the control stack checks this when it is assembled.`);
|
|
1760
|
+
} else if (isListField) {
|
|
1761
|
+
if (capabilities["sql"]?.["scalarList"] !== true) {
|
|
1762
|
+
diagnostics.push({
|
|
1763
|
+
code: "PSL_SCALAR_LIST_UNSUPPORTED_TARGET",
|
|
1764
|
+
message: `Field "${model.name}.${field.name}" is a scalar list, but target "${targetId}" does not support scalar lists (the adapter does not report the "scalarList" capability). Remove the list or author it against a target that supports scalar lists.`,
|
|
1765
|
+
...source.at(field.span)
|
|
1766
|
+
});
|
|
1767
|
+
continue;
|
|
1768
|
+
}
|
|
1769
|
+
const resolved = resolveFieldTypeDescriptor(resolveInput);
|
|
1770
|
+
if (!resolved.ok) continue;
|
|
1771
|
+
if (resolved.presetContributions) {
|
|
1772
|
+
diagnostics.push({
|
|
1773
|
+
code: "PSL_PRESET_NOT_LIST",
|
|
1774
|
+
message: `Field "${model.name}.${field.name}" uses a field-preset call as a list element type. Presets cannot be list elements; remove "[]" or use a scalar type.`,
|
|
1775
|
+
...source.at(field.span)
|
|
1776
|
+
});
|
|
1777
|
+
continue;
|
|
1778
|
+
}
|
|
1779
|
+
descriptor = resolved.descriptor;
|
|
1780
|
+
} else {
|
|
1781
|
+
const resolved = resolveFieldTypeDescriptor(resolveInput);
|
|
1782
|
+
if (!resolved.ok) continue;
|
|
1783
|
+
descriptor = resolved.descriptor;
|
|
1784
|
+
presetContributions = resolved.presetContributions;
|
|
1785
|
+
}
|
|
1786
|
+
if (!descriptor) continue;
|
|
1787
|
+
if (presetContributions?.id && field.optional) {
|
|
1788
|
+
diagnostics.push({
|
|
1789
|
+
code: "PSL_PRESET_NOT_OPTIONAL",
|
|
1790
|
+
message: `Field "${model.name}.${field.name}" is a primary key through its field preset, so it cannot be optional; primary key columns must be NOT NULL. Remove "?" or use a preset that does not make the field a primary key.`,
|
|
1791
|
+
...source.at(field.span)
|
|
1792
|
+
});
|
|
1793
|
+
continue;
|
|
1794
|
+
}
|
|
1795
|
+
const typeAlias = typeAliases.ofResolution(fieldTypeResolution);
|
|
1796
|
+
if (typeAlias !== void 0) refuseRepeatedTypeAliasAttributes({
|
|
1797
|
+
field,
|
|
1798
|
+
fieldPath: `${model.name}.${field.name}`,
|
|
1799
|
+
alias: typeAlias.alias,
|
|
1800
|
+
sources,
|
|
1801
|
+
diagnostics
|
|
1802
|
+
});
|
|
1803
|
+
const defaultAttribute = getAttribute(field.attributes, "default");
|
|
1804
|
+
if (presetContributions?.default && defaultAttribute) {
|
|
1805
|
+
diagnostics.push({
|
|
1806
|
+
code: "PSL_PRESET_AND_DEFAULT_CONFLICT",
|
|
1807
|
+
message: `Field "${model.name}.${field.name}" uses a field-preset call that already sets a database default, so it cannot also declare @default(...). Remove @default(...) or use a preset without a default.`,
|
|
1808
|
+
...source.at(defaultAttribute.span)
|
|
1809
|
+
});
|
|
1810
|
+
continue;
|
|
1811
|
+
}
|
|
1812
|
+
const enumHandle = fieldTypeResolution?.kind === "block" ? enumHandles.get(fieldTypeResolution.symbol) : typeAlias?.enumHandle;
|
|
1813
|
+
const fieldLowering = {
|
|
1814
|
+
modelName: model.name,
|
|
1815
|
+
fieldName: field.name,
|
|
1816
|
+
field,
|
|
1817
|
+
model,
|
|
1818
|
+
symbolTable,
|
|
1819
|
+
sources: input.sources,
|
|
1820
|
+
binder: input.binder,
|
|
1821
|
+
defaultFunctionRegistry,
|
|
1822
|
+
generatorFunctions,
|
|
1823
|
+
dataTypes,
|
|
1824
|
+
diagnostics
|
|
1825
|
+
};
|
|
1826
|
+
const ownDefault = defaultAttribute ? enumHandle ? lowerEnumDefault({
|
|
1827
|
+
...fieldLowering,
|
|
1828
|
+
owner: fieldAttributeOwner(fieldLowering),
|
|
1829
|
+
enumHandle
|
|
1830
|
+
}) : lowerDefaultForField({
|
|
1831
|
+
...fieldLowering,
|
|
1832
|
+
columnDescriptor: descriptor,
|
|
1833
|
+
columnTypeParams: descriptor.typeParams,
|
|
1834
|
+
isListColumn,
|
|
1835
|
+
valueObjectDefault: valueObjectName === void 0 ? void 0 : {
|
|
1836
|
+
valueObjectName,
|
|
1837
|
+
types: valueObjectTypes
|
|
1838
|
+
},
|
|
1839
|
+
codecLookup
|
|
1840
|
+
}) : {};
|
|
1841
|
+
if (isListField && typeAlias?.defaultValue !== void 0) {
|
|
1842
|
+
diagnostics.push({
|
|
1843
|
+
code: "PSL_DEFAULT_LIST_EXPECTED",
|
|
1844
|
+
message: `Field "${model.name}.${field.name}" is a list, but its type alias "${typeAlias.name}" sets @default for a single value. Remove "[]" or the @default of the alias.`,
|
|
1845
|
+
...source.at(field.span)
|
|
1846
|
+
});
|
|
1847
|
+
continue;
|
|
1848
|
+
}
|
|
1849
|
+
const loweredDefault = { ...ifDefined("defaultValue", typeAlias?.defaultValue ?? ownDefault.defaultValue) };
|
|
1850
|
+
const generatedValues = mergeExecutionDefaults(lowerGeneratorAttributesForField({
|
|
1851
|
+
...fieldLowering,
|
|
1852
|
+
columnDescriptor: descriptor,
|
|
1853
|
+
columnTypeParams: descriptor.typeParams
|
|
1854
|
+
}), typeAlias?.executionDefaults);
|
|
1855
|
+
if (isListField && loweredDefault.defaultValue?.kind === "function" && loweredDefault.defaultValue.expression === "autoincrement()") {
|
|
1856
|
+
diagnostics.push({
|
|
1857
|
+
code: "PSL_LIST_AUTOINCREMENT_UNSUPPORTED",
|
|
1858
|
+
message: `Field "${model.name}.${field.name}" is a list and cannot use autoincrement(); it is a Prisma marker for a sequence-backed scalar column, not SQL.`,
|
|
1859
|
+
...source.at(defaultAttribute?.span ?? field.span)
|
|
1860
|
+
});
|
|
1861
|
+
continue;
|
|
1862
|
+
}
|
|
1863
|
+
const ownGeneratorAttribute = GENERATOR_ATTRIBUTE_NAMES.map((name) => getAttribute(field.attributes, name)).find((attribute) => attribute !== void 0);
|
|
1864
|
+
if (isListField && generatedValues !== void 0) {
|
|
1865
|
+
const fieldLabel = `Field "${model.name}.${field.name}"`;
|
|
1866
|
+
const perElement = "Lists have no per-element generated values;";
|
|
1867
|
+
const call = ownGeneratorAttribute?.args.find((arg) => arg.kind === "positional")?.value.trim() ?? "";
|
|
1868
|
+
diagnostics.push({
|
|
1869
|
+
code: "PSL_LIST_EXECUTION_DEFAULT_UNSUPPORTED",
|
|
1870
|
+
message: ownGeneratorAttribute === void 0 ? `${fieldLabel} is a list, and its type alias "${typeAlias?.name}" generates a value. ${perElement} remove "[]" or type the field without the alias.` : `${fieldLabel} is a list and cannot use @${ownGeneratorAttribute.name}(${call}). ${perElement} remove @${ownGeneratorAttribute.name}(...).`,
|
|
1871
|
+
...source.at(ownGeneratorAttribute?.span ?? field.span)
|
|
1872
|
+
});
|
|
1873
|
+
continue;
|
|
1874
|
+
}
|
|
1875
|
+
const presetPhaseConflict = GENERATOR_ATTRIBUTE_NAMES.find((phase) => presetContributions?.executionDefaults?.[phase] !== void 0 && generatedValues?.[phase] !== void 0);
|
|
1876
|
+
if (presetPhaseConflict !== void 0) {
|
|
1877
|
+
const phaseText = presetPhaseConflict === "onCreate" ? "on create" : "on update";
|
|
1878
|
+
diagnostics.push({
|
|
1879
|
+
code: "PSL_PRESET_AND_DEFAULT_CONFLICT",
|
|
1880
|
+
message: `Field "${model.name}.${field.name}" uses a field-preset call that already generates a value ${phaseText}, so @${presetPhaseConflict}(...) cannot set one too. Remove @${presetPhaseConflict}(...) or use a preset without an ${presetPhaseConflict} generator.`,
|
|
1881
|
+
...source.at(getAttribute(field.attributes, presetPhaseConflict)?.span ?? field.span)
|
|
1882
|
+
});
|
|
1883
|
+
continue;
|
|
1884
|
+
}
|
|
1885
|
+
const mappedColumnName = storageName(field, input.physicalNames);
|
|
1886
|
+
const specContext = fieldSpecContext({
|
|
1887
|
+
symbols: symbolTable,
|
|
1888
|
+
model,
|
|
1889
|
+
field,
|
|
1890
|
+
binder,
|
|
1891
|
+
defaultFunctionRegistry,
|
|
1892
|
+
generatorFunctions,
|
|
1893
|
+
dataTypes
|
|
1894
|
+
});
|
|
1895
|
+
const { idAttribute, uniqueAttribute, idName, uniqueName } = extractFieldConstraintNames({
|
|
1896
|
+
symbolTable: input.symbolTable,
|
|
1897
|
+
model,
|
|
1898
|
+
field,
|
|
1899
|
+
specContext,
|
|
1900
|
+
sources: input.sources,
|
|
1901
|
+
binder: input.binder,
|
|
1902
|
+
diagnostics
|
|
1903
|
+
});
|
|
1904
|
+
let isIdField = Boolean(idAttribute);
|
|
1905
|
+
if (idAttribute && isListField) {
|
|
1906
|
+
diagnostics.push({
|
|
1907
|
+
code: "PSL_LIST_ID_UNSUPPORTED",
|
|
1908
|
+
message: `Field "${model.name}.${field.name}" is a list and cannot be a primary key. Remove @id; a list cannot be an identity column.`,
|
|
1909
|
+
...source.at(idAttribute.span)
|
|
1910
|
+
});
|
|
1911
|
+
continue;
|
|
1912
|
+
}
|
|
1913
|
+
if (idAttribute && field.optional) {
|
|
1914
|
+
diagnostics.push({
|
|
1915
|
+
code: "PSL_INVALID_ATTRIBUTE_ARGUMENT",
|
|
1916
|
+
message: `Field "${model.name}.${field.name}" @id cannot be optional; primary key columns must be NOT NULL`,
|
|
1917
|
+
...source.at(idAttribute.span)
|
|
1918
|
+
});
|
|
1919
|
+
isIdField = false;
|
|
1920
|
+
}
|
|
1921
|
+
if (presetContributions && idAttribute && !presetContributions.id) {
|
|
1922
|
+
diagnostics.push({
|
|
1923
|
+
code: "PSL_PRESET_AND_ID_CONFLICT",
|
|
1924
|
+
message: `Field "${model.name}.${field.name}" uses a field-preset call and cannot also declare @id. Use a preset that contributes id semantics, or drop @id.`,
|
|
1925
|
+
...source.at(idAttribute.span)
|
|
1926
|
+
});
|
|
1927
|
+
continue;
|
|
1928
|
+
}
|
|
1929
|
+
const fieldExecutionDefaults = mergeExecutionDefaults(generatedValues, presetContributions?.executionDefaults);
|
|
1930
|
+
const fieldDefaultValue = presetContributions?.default ?? loweredDefault.defaultValue;
|
|
1931
|
+
resolvedFields.push({
|
|
1932
|
+
field,
|
|
1933
|
+
columnName: mappedColumnName,
|
|
1934
|
+
descriptor,
|
|
1935
|
+
nullable: field.optional || Boolean(presetContributions?.nullable),
|
|
1936
|
+
...ifDefined("defaultValue", fieldDefaultValue),
|
|
1937
|
+
...ifDefined("executionDefaults", fieldExecutionDefaults),
|
|
1938
|
+
isId: isIdField || Boolean(presetContributions?.id),
|
|
1939
|
+
isUnique: Boolean(uniqueAttribute) || Boolean(presetContributions?.unique),
|
|
1940
|
+
...ifDefined("idName", idName),
|
|
1941
|
+
...ifDefined("uniqueName", uniqueName),
|
|
1942
|
+
...ifDefined("many", isListField ? true : void 0),
|
|
1943
|
+
...ifDefined("elementNullable", field.elementOptional ? true : void 0),
|
|
1944
|
+
...ifDefined("valueObjectTypeName", valueObjectName),
|
|
1945
|
+
...ifDefined("enumTypeHandle", enumHandle)
|
|
1946
|
+
});
|
|
1947
|
+
}
|
|
1948
|
+
return resolvedFields;
|
|
1949
|
+
}
|
|
1950
|
+
function mergeExecutionDefaults(fromAttributes, fromPreset) {
|
|
1951
|
+
if (fromAttributes === void 0 || fromPreset === void 0) return fromPreset ?? fromAttributes;
|
|
1952
|
+
return {
|
|
1953
|
+
...fromAttributes,
|
|
1954
|
+
...fromPreset
|
|
1955
|
+
};
|
|
1956
|
+
}
|
|
1957
|
+
//#endregion
|
|
1958
|
+
export { modelSpecContext as _, describeUnsupportedSqlAttribute as a, sqlAttributeSpecs as b, instantiateFieldTypeConstructor as c, interpretModelAttribute as d, lowerEnumDefault as f, modelCoordinateKey as g, modelAttributeSpecsFrom as h, defaultFunctionCall as i, instantiatePslTypeConstructor as l, lowerTypeGenerators as m, collectResolvedFields as n, fieldSpecContext as o, lowerTypeDefault as p, contractError as r, getAuthoringEntity as s, PSL_CHECK_ON_STI_VARIANT as t, interpretFieldAttribute as u, readDataTypeDefault as v, resolveFieldTypeDescriptor as y };
|
|
1959
|
+
|
|
1960
|
+
//# sourceMappingURL=psl-field-resolution-C5KQ7kzP-B0NwuRWV.mjs.map
|