@prisma/orm-family-sql 0.16.0-dev.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +28 -0
- package/dist/ast-BstHjAoG.mjs +325 -0
- package/dist/ast-BstHjAoG.mjs.map +1 -0
- package/dist/ast-DSuzmsWn.d.mts +287 -0
- package/dist/ast-DSuzmsWn.d.mts.map +1 -0
- package/dist/authoring-type-constructors-Blqoa2Ua-DyCmD6mp.mjs +316 -0
- package/dist/authoring-type-constructors-Blqoa2Ua-DyCmD6mp.mjs.map +1 -0
- package/dist/build-contract-DBCz_YSs-DO0wMHai.mjs +778 -0
- package/dist/build-contract-DBCz_YSs-DO0wMHai.mjs.map +1 -0
- package/dist/builder.d.mts +3 -0
- package/dist/builder.mjs +1 -0
- package/dist/builder__runtime.d.mts +42 -0
- package/dist/builder__runtime.d.mts.map +1 -0
- package/dist/builder__runtime.mjs +955 -0
- package/dist/builder__runtime.mjs.map +1 -0
- package/dist/builder__types.d.mts +3 -0
- package/dist/builder__types.mjs +1 -0
- package/dist/canonicalization-hooks-CYnW_sGn.d.mts +10 -0
- package/dist/canonicalization-hooks-CYnW_sGn.d.mts.map +1 -0
- package/dist/canonicalization-hooks-DfIc_lOO.mjs +87 -0
- package/dist/canonicalization-hooks-DfIc_lOO.mjs.map +1 -0
- package/dist/codec-descriptor-registry-BJVJRftS.mjs +96 -0
- package/dist/codec-descriptor-registry-BJVJRftS.mjs.map +1 -0
- package/dist/codec-types-MOaceoPi-C5eL2sao.d.mts +116 -0
- package/dist/codec-types-MOaceoPi-C5eL2sao.d.mts.map +1 -0
- package/dist/config-types-47qB33rW.d.mts +21 -0
- package/dist/config-types-47qB33rW.d.mts.map +1 -0
- package/dist/config-types-N7PJc6VN.mjs +65 -0
- package/dist/config-types-N7PJc6VN.mjs.map +1 -0
- package/dist/contract-builder-MvJJrQ-5.d.mts +1306 -0
- package/dist/contract-builder-MvJJrQ-5.d.mts.map +1 -0
- package/dist/contract-builder-YjMQcvZ1.mjs +1615 -0
- package/dist/contract-builder-YjMQcvZ1.mjs.map +1 -0
- package/dist/contract-emitter.d.mts +25 -0
- package/dist/contract-emitter.d.mts.map +1 -0
- package/dist/contract-emitter.mjs +2 -0
- package/dist/contract-errors-BCN6RVI5-5IHBF_lg.mjs +9 -0
- package/dist/contract-errors-BCN6RVI5-5IHBF_lg.mjs.map +1 -0
- package/dist/contract-psl.d.mts +65 -0
- package/dist/contract-psl.d.mts.map +1 -0
- package/dist/contract-psl.mjs +2 -0
- package/dist/contract-psl__provider.d.mts +23 -0
- package/dist/contract-psl__provider.d.mts.map +1 -0
- package/dist/contract-psl__provider.mjs +105 -0
- package/dist/contract-psl__provider.mjs.map +1 -0
- package/dist/contract-ts.d.mts +3 -0
- package/dist/contract-ts.mjs +4 -0
- package/dist/contract-ts__config-types.d.mts +2 -0
- package/dist/contract-ts__config-types.mjs +2 -0
- package/dist/contract-ts__contract-builder.d.mts +2 -0
- package/dist/contract-ts__contract-builder.mjs +3 -0
- package/dist/contract-view-BMR5IWk4.mjs +39 -0
- package/dist/contract-view-BMR5IWk4.mjs.map +1 -0
- package/dist/contract-view-BbWQp6r4.d.mts +61 -0
- package/dist/contract-view-BbWQp6r4.d.mts.map +1 -0
- package/dist/contract.d.mts +26 -0
- package/dist/contract.mjs +17 -0
- package/dist/contract__canonicalization-hooks.d.mts +2 -0
- package/dist/contract__canonicalization-hooks.mjs +2 -0
- package/dist/contract__contract-view.d.mts +2 -0
- package/dist/contract__contract-view.mjs +2 -0
- package/dist/contract__entity-handle-lowering-hook.d.mts +2 -0
- package/dist/contract__entity-handle-lowering-hook.mjs +2 -0
- package/dist/contract__entity-kinds.d.mts +2 -0
- package/dist/contract__entity-kinds.mjs +2 -0
- package/dist/contract__factories.d.mts +2 -0
- package/dist/contract__factories.mjs +2 -0
- package/dist/contract__foreign-key-materialization.d.mts +2 -0
- package/dist/contract__foreign-key-materialization.mjs +2 -0
- package/dist/contract__index-naming.d.mts +2 -0
- package/dist/contract__index-naming.mjs +2 -0
- package/dist/contract__index-type-validation.d.mts +2 -0
- package/dist/contract__index-type-validation.mjs +2 -0
- package/dist/contract__index-types.d.mts +3 -0
- package/dist/contract__index-types.mjs +2 -0
- package/dist/contract__pack-types.d.mts +2 -0
- package/dist/contract__pack-types.mjs +1 -0
- package/dist/contract__referential-action-sql.d.mts +2 -0
- package/dist/contract__referential-action-sql.mjs +2 -0
- package/dist/contract__resolve-storage-table.d.mts +2 -0
- package/dist/contract__resolve-storage-table.mjs +2 -0
- package/dist/contract__types.d.mts +11 -0
- package/dist/contract__types.mjs +4 -0
- package/dist/contract__validators.d.mts +2 -0
- package/dist/contract__validators.mjs +3 -0
- package/dist/contract__value-set-derivation-hook.d.mts +2 -0
- package/dist/contract__value-set-derivation-hook.mjs +2 -0
- package/dist/control-B7iS4jv4.mjs +1326 -0
- package/dist/control-B7iS4jv4.mjs.map +1 -0
- package/dist/control-BHmsZudH.d.mts +948 -0
- package/dist/control-BHmsZudH.d.mts.map +1 -0
- package/dist/control-adapter-4y1O8Ps3.d.mts +1 -0
- package/dist/control-adapter-C99J7aEF-C-17lFY8.d.mts +191 -0
- package/dist/control-adapter-C99J7aEF-C-17lFY8.d.mts.map +1 -0
- package/dist/db-DhMsmBS--DKENDi3l.d.mts +365 -0
- package/dist/db-DhMsmBS--DKENDi3l.d.mts.map +1 -0
- package/dist/ddl-types-BMp2bWVS-D1waZJ4n.mjs +153 -0
- package/dist/ddl-types-BMp2bWVS-D1waZJ4n.mjs.map +1 -0
- package/dist/ddl-types-rrMsf77U-DGctYf-T.d.mts +149 -0
- package/dist/ddl-types-rrMsf77U-DGctYf-T.d.mts.map +1 -0
- package/dist/diff-B16bL_IR.mjs +13 -0
- package/dist/diff-B16bL_IR.mjs.map +1 -0
- package/dist/diff-DhlzHOMD.d.mts +104 -0
- package/dist/diff-DhlzHOMD.d.mts.map +1 -0
- package/dist/dist-C_q1_QR9.mjs +9 -0
- package/dist/dist-C_q1_QR9.mjs.map +1 -0
- package/dist/dist-DrScXbhq.mjs +414 -0
- package/dist/dist-DrScXbhq.mjs.map +1 -0
- package/dist/dist-x6jvtkKM.mjs +68 -0
- package/dist/dist-x6jvtkKM.mjs.map +1 -0
- package/dist/entity-handle-lowering-hook-CIvRKBfa.d.mts +92 -0
- package/dist/entity-handle-lowering-hook-CIvRKBfa.d.mts.map +1 -0
- package/dist/entity-handle-lowering-hook-DwLIKNiS.mjs +11 -0
- package/dist/entity-handle-lowering-hook-DwLIKNiS.mjs.map +1 -0
- package/dist/entity-kinds-DKxwKolf-CcsY-iYV.mjs +136 -0
- package/dist/entity-kinds-DKxwKolf-CcsY-iYV.mjs.map +1 -0
- package/dist/entity-kinds-Dh6VH4uK.d.mts +29 -0
- package/dist/entity-kinds-Dh6VH4uK.d.mts.map +1 -0
- package/dist/errors-B5g0xWro-mWH2C07F.mjs +9 -0
- package/dist/errors-B5g0xWro-mWH2C07F.mjs.map +1 -0
- package/dist/errors.d.mts +63 -0
- package/dist/errors.d.mts.map +1 -0
- package/dist/errors.mjs +2 -0
- package/dist/expression-DIf8F4Mc.d.mts +167 -0
- package/dist/expression-DIf8F4Mc.d.mts.map +1 -0
- package/dist/expression-RUO52bJB.mjs +109 -0
- package/dist/expression-RUO52bJB.mjs.map +1 -0
- package/dist/factories-B7tA4y9D.d.mts +39 -0
- package/dist/factories-B7tA4y9D.d.mts.map +1 -0
- package/dist/factories-CDG9zBxC.mjs +77 -0
- package/dist/factories-CDG9zBxC.mjs.map +1 -0
- package/dist/family.d.mts +13 -0
- package/dist/family.mjs +12 -0
- package/dist/family__control-adapter.d.mts +3 -0
- package/dist/family__control-adapter.mjs +1 -0
- package/dist/family__control.d.mts +4 -0
- package/dist/family__control.mjs +4 -0
- package/dist/family__diff.d.mts +3 -0
- package/dist/family__diff.mjs +3 -0
- package/dist/family__ir.d.mts +2 -0
- package/dist/family__ir.mjs +3 -0
- package/dist/family__migration.d.mts +2 -0
- package/dist/family__migration.mjs +2 -0
- package/dist/family__pack.d.mts +249 -0
- package/dist/family__pack.d.mts.map +1 -0
- package/dist/family__pack.mjs +18 -0
- package/dist/family__pack.mjs.map +1 -0
- package/dist/family__psl-infer.d.mts +2 -0
- package/dist/family__psl-infer.mjs +2 -0
- package/dist/family__runtime.d.mts +3 -0
- package/dist/family__runtime.mjs +3 -0
- package/dist/family__verify.d.mts +2 -0
- package/dist/family__verify.mjs +2 -0
- package/dist/foreign-key-BSy9u4O4-BnsOe5Nf.d.mts +85 -0
- package/dist/foreign-key-BSy9u4O4-BnsOe5Nf.d.mts.map +1 -0
- package/dist/foreign-key-materialization-Ca-wRbmj.d.mts +65 -0
- package/dist/foreign-key-materialization-Ca-wRbmj.d.mts.map +1 -0
- package/dist/foreign-key-materialization-HI7BIQrG.mjs +72 -0
- package/dist/foreign-key-materialization-HI7BIQrG.mjs.map +1 -0
- package/dist/index-Bb9U36N4.d.mts +511 -0
- package/dist/index-Bb9U36N4.d.mts.map +1 -0
- package/dist/index-BgaTJRxj.d.mts +25 -0
- package/dist/index-BgaTJRxj.d.mts.map +1 -0
- package/dist/index-naming-BZWoh45T.d.mts +62 -0
- package/dist/index-naming-BZWoh45T.d.mts.map +1 -0
- package/dist/index-naming-BoGBcMmI-DiJAr66H.mjs +108 -0
- package/dist/index-naming-BoGBcMmI-DiJAr66H.mjs.map +1 -0
- package/dist/index-type-validation-COH4d78M.mjs +17 -0
- package/dist/index-type-validation-COH4d78M.mjs.map +1 -0
- package/dist/index-type-validation-DN0L2mqm.d.mts +10 -0
- package/dist/index-type-validation-DN0L2mqm.d.mts.map +1 -0
- package/dist/index-types-CNhHgKHi.d.mts +1 -0
- package/dist/index-types-DJQ_xwaE.mjs +40 -0
- package/dist/index-types-DJQ_xwaE.mjs.map +1 -0
- package/dist/index-types-DPVhsW0v-D-BikM4h.d.mts +31 -0
- package/dist/index-types-DPVhsW0v-D-BikM4h.d.mts.map +1 -0
- package/dist/interpreter-5WgpL-ax-_nqHLUTr.mjs +3526 -0
- package/dist/interpreter-5WgpL-ax-_nqHLUTr.mjs.map +1 -0
- package/dist/ir-B3bKMnGQ.d.mts +123 -0
- package/dist/ir-B3bKMnGQ.d.mts.map +1 -0
- package/dist/ir-I-xciGUH.mjs +36 -0
- package/dist/ir-I-xciGUH.mjs.map +1 -0
- package/dist/lane-query-builder.d.mts +236 -0
- package/dist/lane-query-builder.d.mts.map +1 -0
- package/dist/lane-query-builder.mjs +67 -0
- package/dist/lane-query-builder.mjs.map +1 -0
- package/dist/middleware-B4XbF4d4-tfwBl6mX.d.mts +119 -0
- package/dist/middleware-B4XbF4d4-tfwBl6mX.d.mts.map +1 -0
- package/dist/middleware-ByRsXxxq.d.mts +1 -0
- package/dist/middleware-CMr4CHNz-DHIUdxlm.mjs +80 -0
- package/dist/middleware-CMr4CHNz-DHIUdxlm.mjs.map +1 -0
- package/dist/migration-CK4oePIo.mjs +44 -0
- package/dist/migration-CK4oePIo.mjs.map +1 -0
- package/dist/migration-CW0ZJLxP.d.mts +44 -0
- package/dist/migration-CW0ZJLxP.d.mts.map +1 -0
- package/dist/naming-BwqqVcZy-BgTObIQw.mjs +177 -0
- package/dist/naming-BwqqVcZy-BgTObIQw.mjs.map +1 -0
- package/dist/naming-jLgdauLi-C84G_UHi.d.mts +133 -0
- package/dist/naming-jLgdauLi-C84G_UHi.d.mts.map +1 -0
- package/dist/operations.d.mts +2 -0
- package/dist/operations.mjs +2 -0
- package/dist/orm-client.d.mts +1316 -0
- package/dist/orm-client.d.mts.map +1 -0
- package/dist/orm-client.mjs +4544 -0
- package/dist/orm-client.mjs.map +1 -0
- package/dist/pack-types-BcLTpwbv.d.mts +14 -0
- package/dist/pack-types-BcLTpwbv.d.mts.map +1 -0
- package/dist/plan-BTD8xFfa-Dd_K-A1R.d.mts +45 -0
- package/dist/plan-BTD8xFfa-Dd_K-A1R.d.mts.map +1 -0
- package/dist/plan-CkpcgUaM.mjs +34 -0
- package/dist/plan-CkpcgUaM.mjs.map +1 -0
- package/dist/plan-Cm4jaoNM.d.mts +2 -0
- package/dist/psl-infer-6je61Z6J.d.mts +119 -0
- package/dist/psl-infer-6je61Z6J.d.mts.map +1 -0
- package/dist/psl-infer-DGftl-HW.mjs +362 -0
- package/dist/psl-infer-DGftl-HW.mjs.map +1 -0
- package/dist/query-lane-context-Bz8XJZ45.d.mts +1 -0
- package/dist/query-lane-context-DtdVMqoz-C2Tj5QHA.d.mts +94 -0
- package/dist/query-lane-context-DtdVMqoz-C2Tj5QHA.d.mts.map +1 -0
- package/dist/referential-action-sql-Csd6dA8G.d.mts +12 -0
- package/dist/referential-action-sql-Csd6dA8G.d.mts.map +1 -0
- package/dist/referential-action-sql-DSqkrySN.mjs +17 -0
- package/dist/referential-action-sql-DSqkrySN.mjs.map +1 -0
- package/dist/relational-core.d.mts +13 -0
- package/dist/relational-core.mjs +8 -0
- package/dist/relational-core__ast.d.mts +5 -0
- package/dist/relational-core__ast.mjs +5 -0
- package/dist/relational-core__codec-descriptor-registry.d.mts +39 -0
- package/dist/relational-core__codec-descriptor-registry.d.mts.map +1 -0
- package/dist/relational-core__codec-descriptor-registry.mjs +2 -0
- package/dist/relational-core__contract-free.d.mts +220 -0
- package/dist/relational-core__contract-free.d.mts.map +1 -0
- package/dist/relational-core__contract-free.mjs +393 -0
- package/dist/relational-core__contract-free.mjs.map +1 -0
- package/dist/relational-core__expression.d.mts +2 -0
- package/dist/relational-core__expression.mjs +2 -0
- package/dist/relational-core__middleware.d.mts +3 -0
- package/dist/relational-core__middleware.mjs +2 -0
- package/dist/relational-core__plan.d.mts +4 -0
- package/dist/relational-core__plan.mjs +2 -0
- package/dist/relational-core__query-lane-context.d.mts +3 -0
- package/dist/relational-core__query-lane-context.mjs +1 -0
- package/dist/relational-core__types.d.mts +3 -0
- package/dist/relational-core__types.mjs +1 -0
- package/dist/resolve-storage-table-DUwyRJmP.d.mts +21 -0
- package/dist/resolve-storage-table-DUwyRJmP.d.mts.map +1 -0
- package/dist/resolve-storage-table-DZsfnzeW.mjs +46 -0
- package/dist/resolve-storage-table-DZsfnzeW.mjs.map +1 -0
- package/dist/runtime-DNewRuec.d.mts +46 -0
- package/dist/runtime-DNewRuec.d.mts.map +1 -0
- package/dist/runtime-tIHpGCcG.mjs +55 -0
- package/dist/runtime-tIHpGCcG.mjs.map +1 -0
- package/dist/runtime.d.mts +4 -0
- package/dist/runtime.mjs +1606 -0
- package/dist/runtime.mjs.map +1 -0
- package/dist/schema-differ-DpG_gnur-g5_iks8G.d.mts +47 -0
- package/dist/schema-differ-DpG_gnur-g5_iks8G.d.mts.map +1 -0
- package/dist/schema-ir.d.mts +2 -0
- package/dist/schema-ir.mjs +2 -0
- package/dist/schema-ir__naming.d.mts +2 -0
- package/dist/schema-ir__naming.mjs +2 -0
- package/dist/schema-ir__types.d.mts +3 -0
- package/dist/schema-ir__types.mjs +2 -0
- package/dist/schema-verify-vtFZbmGq-BNfTr6fU.mjs +222 -0
- package/dist/schema-verify-vtFZbmGq-BNfTr6fU.mjs.map +1 -0
- package/dist/serialized-index-B96AwqtU-DcqcB4q_.d.mts +26 -0
- package/dist/serialized-index-B96AwqtU-DcqcB4q_.d.mts.map +1 -0
- package/dist/serialized-index-Dp5_EjXD-DMsw8jf3.mjs +64 -0
- package/dist/serialized-index-Dp5_EjXD-DMsw8jf3.mjs.map +1 -0
- package/dist/sql-contract-serializer-2oBWuxTe-B9hzBBv1.mjs +171 -0
- package/dist/sql-contract-serializer-2oBWuxTe-B9hzBBv1.mjs.map +1 -0
- package/dist/sql-execution-plan-CJmsCP7n-DoEpNn7r.d.mts +32 -0
- package/dist/sql-execution-plan-CJmsCP7n-DoEpNn7r.d.mts.map +1 -0
- package/dist/sql-index-DsI8HAeK-BJsn-jvD.d.mts +72 -0
- package/dist/sql-index-DsI8HAeK-BJsn-jvD.d.mts.map +1 -0
- package/dist/sql-node-kEz6YFZo-v2F7delx.d.mts +42 -0
- package/dist/sql-node-kEz6YFZo-v2F7delx.d.mts.map +1 -0
- package/dist/sql-storage-B0QwiTg6-B8DVctJm.d.mts +171 -0
- package/dist/sql-storage-B0QwiTg6-B8DVctJm.d.mts.map +1 -0
- package/dist/storage-table-BBaAmanc-BwR37LMA.d.mts +130 -0
- package/dist/storage-table-BBaAmanc-BwR37LMA.d.mts.map +1 -0
- package/dist/storage-table-_LWDmPfv-DFhU2dML.mjs +277 -0
- package/dist/storage-table-_LWDmPfv-DFhU2dML.mjs.map +1 -0
- package/dist/storage-value-set-BGlj5Uus-CvZD--GG.d.mts +41 -0
- package/dist/storage-value-set-BGlj5Uus-CvZD--GG.d.mts.map +1 -0
- package/dist/timestamp-now-generator-DRXygu32-DN9Qb1uI.mjs +173 -0
- package/dist/timestamp-now-generator-DRXygu32-DN9Qb1uI.mjs.map +1 -0
- package/dist/types-BchwQpmO.d.mts +16 -0
- package/dist/types-BchwQpmO.d.mts.map +1 -0
- package/dist/types-BgkZru_1-H7yfikSQ.mjs +1444 -0
- package/dist/types-BgkZru_1-H7yfikSQ.mjs.map +1 -0
- package/dist/types-CMMQS6aG.mjs +111 -0
- package/dist/types-CMMQS6aG.mjs.map +1 -0
- package/dist/types-CuDrWc5v-ISVXBmBs.d.mts +134 -0
- package/dist/types-CuDrWc5v-ISVXBmBs.d.mts.map +1 -0
- package/dist/types-CvbBw1Jo-3KQdErJY.d.mts +688 -0
- package/dist/types-CvbBw1Jo-3KQdErJY.d.mts.map +1 -0
- package/dist/types-DIBA80mc-wf5wLmON.d.mts +723 -0
- package/dist/types-DIBA80mc-wf5wLmON.d.mts.map +1 -0
- package/dist/types-DMxc5KZa.d.mts +1 -0
- package/dist/types-Dl20lxky-DC_jdA0T.d.mts +247 -0
- package/dist/types-Dl20lxky-DC_jdA0T.d.mts.map +1 -0
- package/dist/types-DmhUVq4u-BpqqjPJx.mjs +719 -0
- package/dist/types-DmhUVq4u-BpqqjPJx.mjs.map +1 -0
- package/dist/types-IqZMLrFC-DtdJNICr.d.mts +426 -0
- package/dist/types-IqZMLrFC-DtdJNICr.d.mts.map +1 -0
- package/dist/types-TvBZ2Ne9.d.mts +1 -0
- package/dist/unique-constraint-jQWfH7dg-zLWtFp99.d.mts +32 -0
- package/dist/unique-constraint-jQWfH7dg-zLWtFp99.d.mts.map +1 -0
- package/dist/util-DQQgv2j1-D6INZaRG.mjs +34 -0
- package/dist/util-DQQgv2j1-D6INZaRG.mjs.map +1 -0
- package/dist/validators-C4PItWnf.mjs +0 -0
- package/dist/validators-C4PItWnf.mjs.map +1 -0
- package/dist/validators-CxeHhHrf.d.mts +206 -0
- package/dist/validators-CxeHhHrf.d.mts.map +1 -0
- package/dist/value-set-derivation-hook-BhgGVtw0.d.mts +35 -0
- package/dist/value-set-derivation-hook-BhgGVtw0.d.mts.map +1 -0
- package/dist/value-set-derivation-hook-Di9JZ0X7.mjs +22 -0
- package/dist/value-set-derivation-hook-Di9JZ0X7.mjs.map +1 -0
- package/dist/verify-E6Dd2vYp-gYwnlhLm.mjs +86 -0
- package/dist/verify-E6Dd2vYp-gYwnlhLm.mjs.map +1 -0
- package/dist/verify-zDRnw0Rn.d.mts +26 -0
- package/dist/verify-zDRnw0Rn.d.mts.map +1 -0
- package/package.json +112 -0
|
@@ -0,0 +1,1306 @@
|
|
|
1
|
+
import { a as ReferentialAction } from "./foreign-key-BSy9u4O4-BnsOe5Nf.mjs";
|
|
2
|
+
import { t as Index$1 } from "./sql-index-DsI8HAeK-BJsn-jvD.mjs";
|
|
3
|
+
import { c as SqlStorage, d as StorageTypeInstance, i as SqlNamespaceBase, s as SqlNamespaceInput } from "./sql-storage-B0QwiTg6-B8DVctJm.mjs";
|
|
4
|
+
import { k as TypeMaps, n as ContractWithTypeMaps } from "./types-CuDrWc5v-ISVXBmBs.mjs";
|
|
5
|
+
import "./types-BchwQpmO.mjs";
|
|
6
|
+
import { r as PackEntityHandle } from "./entity-handle-lowering-hook-CIvRKBfa.mjs";
|
|
7
|
+
import { n as AuthoredIndexMethod } from "./index-naming-BZWoh45T.mjs";
|
|
8
|
+
import { i as IndexTypeRegistration } from "./index-types-DPVhsW0v-D-BikM4h.mjs";
|
|
9
|
+
import "./index-types-CNhHgKHi.mjs";
|
|
10
|
+
import { StorageType } from "@prisma/orm-framework/components/ir";
|
|
11
|
+
import { ColumnDefault, ColumnDefaultLiteralInputValue, Contract, ContractEnum, ContractRelation, ContractValueObject, ControlPolicy, ExecutionMutationDefaultPhases, ExecutionMutationDefaultValue, NamespaceId, StorageHashBase } from "@prisma/orm-framework/contract/types";
|
|
12
|
+
import { AuthoringArgumentDescriptor, AuthoringFieldPresetDescriptor, AuthoringTypeConstructorDescriptor, AuthoringWarning } from "@prisma/orm-framework/components/authoring";
|
|
13
|
+
import { BoundEnumType, CodecInput, CodecTypeMap, EntityHelpersFromNamespace, EnumMember, EnumTypeHandle, ExtractAuthoringNamespaceFromPack, ForeignKeyDefaultsState, MergeExtensionAuthoringNamespaces, bindEnumType, enumType, member } from "@prisma/orm-framework/contract-authoring";
|
|
14
|
+
import { CodecLookup, ColumnTypeDescriptor } from "@prisma/orm-framework/components/codec";
|
|
15
|
+
import { ExtensionPackRef, FamilyPackRef, TargetPackRef } from "@prisma/orm-framework/components/components";
|
|
16
|
+
//#region ../../../2-sql/2-authoring/contract-ts/dist/contract-builder.d.mts
|
|
17
|
+
//#region src/contract-dsl.d.ts
|
|
18
|
+
type NamingStrategy = 'identity' | 'snake_case';
|
|
19
|
+
type NamingConfig = {
|
|
20
|
+
readonly tables?: NamingStrategy;
|
|
21
|
+
readonly columns?: NamingStrategy;
|
|
22
|
+
};
|
|
23
|
+
type NamedStorageTypeRef = string | StorageTypeInstance | EnumTypeHandle;
|
|
24
|
+
type NamedConstraintNameSpec<Name extends string = string> = {
|
|
25
|
+
readonly name: Name;
|
|
26
|
+
};
|
|
27
|
+
type ScalarFieldState<Descriptor extends ColumnTypeDescriptor = ColumnTypeDescriptor, TypeRef extends NamedStorageTypeRef | undefined = undefined, Nullable extends boolean = boolean, ColumnName extends string | undefined = string | undefined, IdSpec extends NamedConstraintSpec | undefined = undefined, UniqueSpec extends NamedConstraintSpec | undefined = undefined, Many extends boolean = false> = {
|
|
28
|
+
readonly kind: 'scalar';
|
|
29
|
+
readonly descriptor?: Descriptor | undefined;
|
|
30
|
+
readonly typeRef?: TypeRef | undefined;
|
|
31
|
+
readonly nullable: Nullable;
|
|
32
|
+
readonly columnName?: ColumnName | undefined;
|
|
33
|
+
readonly default?: ColumnDefault | undefined;
|
|
34
|
+
readonly executionDefaults?: ExecutionMutationDefaultPhases | undefined;
|
|
35
|
+
readonly many?: Many extends true ? true : undefined;
|
|
36
|
+
} & (IdSpec extends NamedConstraintSpec ? {
|
|
37
|
+
readonly id: IdSpec;
|
|
38
|
+
} : {
|
|
39
|
+
readonly id?: undefined;
|
|
40
|
+
}) & (UniqueSpec extends NamedConstraintSpec ? {
|
|
41
|
+
readonly unique: UniqueSpec;
|
|
42
|
+
} : {
|
|
43
|
+
readonly unique?: undefined;
|
|
44
|
+
});
|
|
45
|
+
type AnyScalarFieldState = {
|
|
46
|
+
readonly kind: 'scalar';
|
|
47
|
+
readonly descriptor?: ColumnTypeDescriptor | undefined;
|
|
48
|
+
readonly typeRef?: NamedStorageTypeRef | undefined;
|
|
49
|
+
readonly nullable: boolean;
|
|
50
|
+
readonly columnName?: string | undefined;
|
|
51
|
+
readonly default?: ColumnDefault | undefined;
|
|
52
|
+
readonly executionDefaults?: ExecutionMutationDefaultPhases | undefined;
|
|
53
|
+
readonly many?: boolean | undefined;
|
|
54
|
+
readonly id?: NamedConstraintSpec | undefined;
|
|
55
|
+
readonly unique?: NamedConstraintSpec | undefined;
|
|
56
|
+
};
|
|
57
|
+
type HasNamedConstraintId<State extends AnyScalarFieldState> = State extends ScalarFieldState<ColumnTypeDescriptor, NamedStorageTypeRef | undefined, boolean, string | undefined, infer IdSpec, NamedConstraintSpec | undefined, boolean> ? IdSpec extends NamedConstraintSpec ? true : false : false;
|
|
58
|
+
type HasNamedConstraintUnique<State extends AnyScalarFieldState> = State extends ScalarFieldState<ColumnTypeDescriptor, NamedStorageTypeRef | undefined, boolean, string | undefined, NamedConstraintSpec | undefined, infer UniqueSpec, boolean> ? UniqueSpec extends NamedConstraintSpec ? true : false : false;
|
|
59
|
+
type FieldSqlSpecForState<State extends AnyScalarFieldState> = {
|
|
60
|
+
readonly column?: string;
|
|
61
|
+
} & (HasNamedConstraintId<State> extends true ? {
|
|
62
|
+
readonly id?: NamedConstraintNameSpec;
|
|
63
|
+
} : Record<never, never>) & (HasNamedConstraintUnique<State> extends true ? {
|
|
64
|
+
readonly unique?: NamedConstraintNameSpec;
|
|
65
|
+
} : Record<never, never>);
|
|
66
|
+
type ApplyFieldSqlSpec<State extends AnyScalarFieldState, Spec extends FieldSqlSpecForState<State>> = State extends ScalarFieldState<infer Descriptor, infer TypeRef, infer Nullable, infer ColumnName, infer IdSpec, infer UniqueSpec, infer Many> ? ScalarFieldState<Descriptor, TypeRef, Nullable, Spec extends {
|
|
67
|
+
readonly column: infer NextColumn extends string;
|
|
68
|
+
} ? NextColumn : ColumnName, Spec extends {
|
|
69
|
+
readonly id: {
|
|
70
|
+
readonly name: infer IdName extends string;
|
|
71
|
+
};
|
|
72
|
+
} ? IdSpec extends NamedConstraintSpec ? NamedConstraintSpec<IdName> : IdSpec : IdSpec, Spec extends {
|
|
73
|
+
readonly unique: {
|
|
74
|
+
readonly name: infer UniqueName extends string;
|
|
75
|
+
};
|
|
76
|
+
} ? UniqueSpec extends NamedConstraintSpec ? NamedConstraintSpec<UniqueName> : UniqueSpec : UniqueSpec, Many> : AnyScalarFieldState;
|
|
77
|
+
type GeneratedFieldSpec = {
|
|
78
|
+
readonly type: ColumnTypeDescriptor;
|
|
79
|
+
readonly typeParams?: Record<string, unknown>;
|
|
80
|
+
readonly generated: ExecutionMutationDefaultValue;
|
|
81
|
+
};
|
|
82
|
+
declare class ScalarFieldBuilder<State extends AnyScalarFieldState = AnyScalarFieldState> {
|
|
83
|
+
private readonly state;
|
|
84
|
+
readonly __state: State;
|
|
85
|
+
constructor(state: State);
|
|
86
|
+
/**
|
|
87
|
+
* Returns the physical column name when `.column(name)` was called, or
|
|
88
|
+
* `undefined` when the field uses the default (logical field name) mapping.
|
|
89
|
+
* Used by cross-space FK lowering to stamp the physical column name onto
|
|
90
|
+
* `TargetFieldRef.columnName` so FK target columns are resolved correctly.
|
|
91
|
+
*/
|
|
92
|
+
get physicalColumnName(): string | undefined;
|
|
93
|
+
optional(): ScalarFieldBuilder<State extends ScalarFieldState<infer Descriptor, infer TypeRef, boolean, infer ColumnName, infer IdSpec, infer UniqueSpec, infer Many> ? ScalarFieldState<Descriptor, TypeRef, true, ColumnName, IdSpec, UniqueSpec, Many> : AnyScalarFieldState>;
|
|
94
|
+
column<ColumnName extends string>(name: ColumnName): ScalarFieldBuilder<State extends ScalarFieldState<infer Descriptor, infer TypeRef, infer Nullable, string | undefined, infer IdSpec, infer UniqueSpec, infer Many> ? ScalarFieldState<Descriptor, TypeRef, Nullable, ColumnName, IdSpec, UniqueSpec, Many> : AnyScalarFieldState>;
|
|
95
|
+
many(): ScalarFieldBuilder<State extends ScalarFieldState<infer Descriptor, infer TypeRef, infer Nullable, infer ColumnName, infer IdSpec, infer UniqueSpec, boolean> ? ScalarFieldState<Descriptor, TypeRef, Nullable, ColumnName, IdSpec, UniqueSpec, true> : AnyScalarFieldState>;
|
|
96
|
+
default(value: ColumnDefaultLiteralInputValue | ColumnDefault): ScalarFieldBuilder<State>;
|
|
97
|
+
defaultSql(expression: string): ScalarFieldBuilder<State>;
|
|
98
|
+
id<const Name extends string | undefined = undefined>(options?: NamedConstraintSpec<Name>): ScalarFieldBuilder<State extends ScalarFieldState<infer Descriptor, infer TypeRef, infer Nullable, infer ColumnName, NamedConstraintSpec | undefined, infer UniqueSpec, infer Many> ? ScalarFieldState<Descriptor, TypeRef, Nullable, ColumnName, NamedConstraintSpec<Name>, UniqueSpec, Many> : AnyScalarFieldState>;
|
|
99
|
+
unique<const Name extends string | undefined = undefined>(options?: NamedConstraintSpec<Name>): ScalarFieldBuilder<State extends ScalarFieldState<infer Descriptor, infer TypeRef, infer Nullable, infer ColumnName, infer IdSpec, NamedConstraintSpec | undefined, infer Many> ? ScalarFieldState<Descriptor, TypeRef, Nullable, ColumnName, IdSpec, NamedConstraintSpec<Name>, Many> : AnyScalarFieldState>;
|
|
100
|
+
sql<const Spec extends FieldSqlSpecForState<State>>(spec: Spec): ScalarFieldBuilder<ApplyFieldSqlSpec<State, Spec>>;
|
|
101
|
+
build(): State;
|
|
102
|
+
}
|
|
103
|
+
declare class EnumScalarFieldBuilder<Handle extends EnumTypeHandle, State extends AnyScalarFieldState = ScalarFieldState<ColumnTypeDescriptor, Handle, false, undefined>> extends ScalarFieldBuilder<State> {
|
|
104
|
+
#private;
|
|
105
|
+
constructor(state: State, handle: Handle);
|
|
106
|
+
default(value: Handle['values'][number]): EnumScalarFieldBuilder<Handle, State>;
|
|
107
|
+
defaultSql(_expression: never): never;
|
|
108
|
+
}
|
|
109
|
+
declare function columnField<Descriptor extends ColumnTypeDescriptor>(descriptor: Descriptor): ScalarFieldBuilder<ScalarFieldState<Descriptor, undefined, false, undefined>>;
|
|
110
|
+
declare function generatedField<Descriptor extends ColumnTypeDescriptor>(spec: GeneratedFieldSpec & {
|
|
111
|
+
readonly type: Descriptor;
|
|
112
|
+
}): ScalarFieldBuilder<ScalarFieldState<Descriptor, undefined, false, undefined>>;
|
|
113
|
+
declare function namedTypeField<TypeRef extends string>(typeRef: TypeRef): ScalarFieldBuilder<ScalarFieldState<ColumnTypeDescriptor, TypeRef, false, undefined>>;
|
|
114
|
+
declare function namedTypeField<TypeRef extends StorageTypeInstance>(typeRef: TypeRef): ScalarFieldBuilder<ScalarFieldState<ColumnTypeDescriptor<TypeRef['codecId']>, TypeRef, false, undefined>>;
|
|
115
|
+
declare function namedTypeField<Handle extends EnumTypeHandle>(typeRef: Handle): EnumScalarFieldBuilder<Handle>;
|
|
116
|
+
type RelationModelRefSource = 'string' | 'token' | 'lazyToken';
|
|
117
|
+
type TargetFieldRefSource = 'string' | 'token';
|
|
118
|
+
type EagerRelationModelName<ModelName extends string = string, Source extends Exclude<RelationModelRefSource, 'lazyToken'> = Exclude<RelationModelRefSource, 'lazyToken'>> = {
|
|
119
|
+
readonly kind: 'relationModelName';
|
|
120
|
+
readonly source: Source;
|
|
121
|
+
readonly modelName: ModelName;
|
|
122
|
+
};
|
|
123
|
+
type LazyRelationModelName<ModelName extends string = string> = {
|
|
124
|
+
readonly kind: 'lazyRelationModelName';
|
|
125
|
+
readonly source: 'lazyToken';
|
|
126
|
+
readonly resolve: () => ModelName;
|
|
127
|
+
};
|
|
128
|
+
type RelationModelSource<ModelName extends string = string> = EagerRelationModelName<ModelName> | LazyRelationModelName<ModelName>;
|
|
129
|
+
type BelongsToRelation<ToModel extends string = string, FromField extends string | readonly string[] = string | readonly string[], ToField extends string | readonly string[] = string | readonly string[], SqlSpec extends BelongsToRelationSqlSpec | undefined = undefined> = {
|
|
130
|
+
readonly kind: 'belongsTo';
|
|
131
|
+
readonly toModel: RelationModelSource<ToModel>;
|
|
132
|
+
readonly from: FromField;
|
|
133
|
+
readonly to: ToField;
|
|
134
|
+
readonly sql?: SqlSpec;
|
|
135
|
+
/**
|
|
136
|
+
* Contract-space identity of the target model. Populated when
|
|
137
|
+
* `belongsTo` receives a cross-space branded handle. Absent for
|
|
138
|
+
* local (same-space) relations.
|
|
139
|
+
*/
|
|
140
|
+
readonly spaceId?: string;
|
|
141
|
+
/**
|
|
142
|
+
* Physical table name of the cross-space target model. Only set
|
|
143
|
+
* when `spaceId` is present; read from the handle's `tableName`.
|
|
144
|
+
*/
|
|
145
|
+
readonly tableName?: string;
|
|
146
|
+
/**
|
|
147
|
+
* Namespace coordinate of the cross-space target model.
|
|
148
|
+
* Only set when `spaceId` is present.
|
|
149
|
+
*/
|
|
150
|
+
readonly namespaceId?: string;
|
|
151
|
+
};
|
|
152
|
+
type HasManyRelation<ToModel extends string = string, ByField extends string | readonly string[] = string | readonly string[]> = {
|
|
153
|
+
readonly kind: 'hasMany';
|
|
154
|
+
readonly toModel: RelationModelSource<ToModel>;
|
|
155
|
+
readonly by: ByField;
|
|
156
|
+
};
|
|
157
|
+
type HasOneRelation<ToModel extends string = string, ByField extends string | readonly string[] = string | readonly string[]> = {
|
|
158
|
+
readonly kind: 'hasOne';
|
|
159
|
+
readonly toModel: RelationModelSource<ToModel>;
|
|
160
|
+
readonly by: ByField;
|
|
161
|
+
};
|
|
162
|
+
type ManyToManyRelation<ToModel extends string = string, ThroughModel extends string = string, FromField extends string | readonly string[] = string | readonly string[], ToField extends string | readonly string[] = string | readonly string[]> = {
|
|
163
|
+
readonly kind: 'manyToMany';
|
|
164
|
+
readonly toModel: RelationModelSource<ToModel>;
|
|
165
|
+
readonly through: RelationModelSource<ThroughModel>;
|
|
166
|
+
readonly from: FromField;
|
|
167
|
+
readonly to: ToField;
|
|
168
|
+
};
|
|
169
|
+
type RelationState = BelongsToRelation<string, string | readonly string[], string | readonly string[], BelongsToRelationSqlSpec | undefined> | HasManyRelation | HasOneRelation | ManyToManyRelation;
|
|
170
|
+
type AnyRelationState = RelationState;
|
|
171
|
+
type AnyRelationBuilder = RelationBuilder<AnyRelationState>;
|
|
172
|
+
type ApplyBelongsToRelationSqlSpec<State extends RelationState, SqlSpec extends BelongsToRelationSqlSpec> = State extends BelongsToRelation<infer ToModel, infer FromField, infer ToField, BelongsToRelationSqlSpec | undefined> ? BelongsToRelation<ToModel, FromField, ToField, SqlSpec> : never;
|
|
173
|
+
declare class RelationBuilder<State extends RelationState = AnyRelationState> {
|
|
174
|
+
private readonly state;
|
|
175
|
+
readonly __state: State;
|
|
176
|
+
constructor(state: State);
|
|
177
|
+
sql<const SqlSpec extends BelongsToRelationSqlSpec>(this: State extends BelongsToRelation<string, string | readonly string[], string | readonly string[], BelongsToRelationSqlSpec | undefined> ? RelationBuilder<State> : never, spec: SqlSpec): RelationBuilder<ApplyBelongsToRelationSqlSpec<State, SqlSpec>>;
|
|
178
|
+
build(): State;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Reference to a column on the current (local) model.
|
|
182
|
+
*
|
|
183
|
+
* Source columns are always local to the contract being authored. The
|
|
184
|
+
* cross-space brand lives on `TargetFieldRef` (the target side of a foreign
|
|
185
|
+
* key), not here.
|
|
186
|
+
*/
|
|
187
|
+
type ColumnRef<FieldName extends string = string> = {
|
|
188
|
+
readonly kind: 'columnRef';
|
|
189
|
+
readonly fieldName: FieldName;
|
|
190
|
+
};
|
|
191
|
+
/**
|
|
192
|
+
* Reference to a field on a target model, produced by model `.refs` and
|
|
193
|
+
* `constraints.ref(modelName, fieldName)`.
|
|
194
|
+
*
|
|
195
|
+
* The `TSpaceId` phantom parameter carries the contract-space identity of the
|
|
196
|
+
* target model. Local model handles produce `TSpaceId = '<self>'`; extension
|
|
197
|
+
* handles carry the extension's `spaceId`. The brand is propagated from the
|
|
198
|
+
* parent `ContractModelBuilder` via the `spaceId?` property: absent means local
|
|
199
|
+
* (`'<self>'`), present means cross-space.
|
|
200
|
+
*/
|
|
201
|
+
type TargetFieldRef<ModelName extends string = string, FieldName extends string = string, TSpaceId extends string = string> = {
|
|
202
|
+
readonly kind: 'targetFieldRef';
|
|
203
|
+
readonly source: TargetFieldRefSource;
|
|
204
|
+
readonly modelName: ModelName;
|
|
205
|
+
readonly fieldName: FieldName;
|
|
206
|
+
/**
|
|
207
|
+
* Cross-space discriminator. When present, the referenced model lives in a
|
|
208
|
+
* different contract space identified by this value. Absent for local refs.
|
|
209
|
+
*/
|
|
210
|
+
readonly spaceId?: TSpaceId extends '<self>' ? never : TSpaceId;
|
|
211
|
+
/**
|
|
212
|
+
* Namespace id of the cross-space target model (e.g. `'auth'` for
|
|
213
|
+
* `supabase` `auth.User`). Only present for cross-space refs.
|
|
214
|
+
*/
|
|
215
|
+
readonly namespaceId?: string;
|
|
216
|
+
/**
|
|
217
|
+
* Physical table name of the cross-space target model. Only present for
|
|
218
|
+
* cross-space refs; allows the lowering path to bypass the local model
|
|
219
|
+
* registry.
|
|
220
|
+
*/
|
|
221
|
+
readonly tableName?: string;
|
|
222
|
+
/**
|
|
223
|
+
* Physical column name of the target field. Populated for cross-space refs
|
|
224
|
+
* when the extension handle's field used `.column(name)` to rename the
|
|
225
|
+
* physical column. When absent the logical `fieldName` is used as the column
|
|
226
|
+
* name. Only relevant for cross-space FK lowering — local FKs resolve column
|
|
227
|
+
* names via the local `fieldToColumn` map.
|
|
228
|
+
*/
|
|
229
|
+
readonly columnName?: string;
|
|
230
|
+
};
|
|
231
|
+
type ModelTokenRefs<ModelName extends string, Fields extends Record<string, ScalarFieldBuilder>, TSpaceId extends string = '<self>'> = { readonly [K in keyof Fields]: TargetFieldRef<ModelName, K & string, TSpaceId>; };
|
|
232
|
+
type ConstraintOptions<Name extends string | undefined = string | undefined> = {
|
|
233
|
+
readonly name?: Name;
|
|
234
|
+
};
|
|
235
|
+
type IndexTypeMap = Record<string, {
|
|
236
|
+
readonly options: unknown;
|
|
237
|
+
}>;
|
|
238
|
+
type IndexOptionsBase<Name extends string | undefined> = {
|
|
239
|
+
readonly name?: Name;
|
|
240
|
+
/** Exact physical name — adopted verbatim, no wire hash. Xor `name`. */
|
|
241
|
+
readonly map?: string;
|
|
242
|
+
/** Opaque SQL: partial-index predicate (WHERE body, without the keyword). */
|
|
243
|
+
readonly where?: string;
|
|
244
|
+
readonly unique?: boolean;
|
|
245
|
+
};
|
|
246
|
+
type IndexInput<Name extends string | undefined, IndexTypes extends IndexTypeMap> = keyof IndexTypes extends never ? IndexOptionsBase<Name> : (IndexOptionsBase<Name> & {
|
|
247
|
+
readonly type?: never;
|
|
248
|
+
readonly options?: never;
|
|
249
|
+
}) | { readonly [K in keyof IndexTypes & string]: IndexOptionsBase<Name> & {
|
|
250
|
+
readonly type: K;
|
|
251
|
+
readonly options: IndexTypes[K]['options'];
|
|
252
|
+
}; }[keyof IndexTypes & string];
|
|
253
|
+
/**
|
|
254
|
+
* The expression overload's input: the whole CREATE INDEX element list as
|
|
255
|
+
* one opaque string. `name` or `map` is required — enforced at lowering
|
|
256
|
+
* with the same diagnostics as PSL.
|
|
257
|
+
*/
|
|
258
|
+
type ExpressionIndexInput<Name extends string | undefined, IndexTypes extends IndexTypeMap> = IndexInput<Name, IndexTypes> & {
|
|
259
|
+
readonly expression: string;
|
|
260
|
+
};
|
|
261
|
+
type ForeignKeyOptions<Name extends string | undefined = string | undefined> = ConstraintOptions<Name> & {
|
|
262
|
+
readonly onDelete?: 'noAction' | 'restrict' | 'cascade' | 'setNull' | 'setDefault';
|
|
263
|
+
readonly onUpdate?: 'noAction' | 'restrict' | 'cascade' | 'setNull' | 'setDefault';
|
|
264
|
+
readonly constraint?: boolean;
|
|
265
|
+
readonly index?: boolean;
|
|
266
|
+
};
|
|
267
|
+
type BelongsToRelationSqlSpec<Name extends string | undefined = string | undefined> = {
|
|
268
|
+
readonly fk?: ForeignKeyOptions<Name>;
|
|
269
|
+
};
|
|
270
|
+
type IdConstraint<FieldNames extends readonly string[] = readonly string[], Name extends string | undefined = string | undefined> = {
|
|
271
|
+
readonly kind: 'id';
|
|
272
|
+
readonly fields: FieldNames;
|
|
273
|
+
readonly name?: Name;
|
|
274
|
+
};
|
|
275
|
+
type UniqueConstraint<FieldNames extends readonly string[] = readonly string[]> = {
|
|
276
|
+
readonly kind: 'unique';
|
|
277
|
+
readonly fields: FieldNames;
|
|
278
|
+
readonly name?: string;
|
|
279
|
+
};
|
|
280
|
+
/** An authored index constraint's element structure — field tuple xor expression. */
|
|
281
|
+
type IndexConstraintElements<FieldNames extends readonly string[] = readonly string[]> = {
|
|
282
|
+
/** Field-name tuple. */
|
|
283
|
+
readonly fields: FieldNames;
|
|
284
|
+
readonly expression?: never;
|
|
285
|
+
} | {
|
|
286
|
+
readonly fields?: never;
|
|
287
|
+
/** Opaque SQL: the entire CREATE INDEX element list — never parsed. */
|
|
288
|
+
readonly expression: string;
|
|
289
|
+
};
|
|
290
|
+
/** Options only exist as options of a type, so the pair is one union. */
|
|
291
|
+
type IndexConstraintMethod = {
|
|
292
|
+
readonly type?: undefined;
|
|
293
|
+
readonly options?: undefined;
|
|
294
|
+
} | {
|
|
295
|
+
readonly type: string;
|
|
296
|
+
readonly options?: Record<string, unknown>;
|
|
297
|
+
};
|
|
298
|
+
type IndexConstraint<FieldNames extends readonly string[] = readonly string[], Name extends string | undefined = string | undefined> = IndexConstraintElements<FieldNames> & IndexConstraintMethod & {
|
|
299
|
+
readonly kind: 'index';
|
|
300
|
+
readonly where?: string;
|
|
301
|
+
readonly unique?: boolean;
|
|
302
|
+
readonly name?: Name;
|
|
303
|
+
readonly map?: string;
|
|
304
|
+
};
|
|
305
|
+
type ForeignKeyConstraint<SourceFieldNames extends readonly string[] = readonly string[], TargetModelName extends string = string, TargetFieldNames extends readonly string[] = readonly string[], Name extends string | undefined = string | undefined> = {
|
|
306
|
+
readonly kind: 'fk';
|
|
307
|
+
readonly fields: SourceFieldNames;
|
|
308
|
+
readonly targetModel: TargetModelName;
|
|
309
|
+
readonly targetFields: TargetFieldNames;
|
|
310
|
+
readonly targetSource?: TargetFieldRefSource;
|
|
311
|
+
/**
|
|
312
|
+
* Cross-space discriminator. When present, the FK target lives in a
|
|
313
|
+
* different contract space identified by this value. Absent for local FKs.
|
|
314
|
+
*/
|
|
315
|
+
readonly targetSpaceId?: string;
|
|
316
|
+
/**
|
|
317
|
+
* Namespace coordinate of the cross-space target model. Populated when
|
|
318
|
+
* the target model handle carries a `namespace` (e.g. `auth` for supabase
|
|
319
|
+
* `auth.User`). Absent for local FKs.
|
|
320
|
+
*/
|
|
321
|
+
readonly targetNamespaceId?: string;
|
|
322
|
+
/**
|
|
323
|
+
* Table name of the cross-space target. Populated for cross-space FKs
|
|
324
|
+
* so the lowering path doesn't need a local model lookup.
|
|
325
|
+
*/
|
|
326
|
+
readonly targetTableName?: string;
|
|
327
|
+
readonly name?: Name;
|
|
328
|
+
readonly onDelete?: 'noAction' | 'restrict' | 'cascade' | 'setNull' | 'setDefault';
|
|
329
|
+
readonly onUpdate?: 'noAction' | 'restrict' | 'cascade' | 'setNull' | 'setDefault';
|
|
330
|
+
readonly constraint?: boolean;
|
|
331
|
+
readonly index?: boolean;
|
|
332
|
+
};
|
|
333
|
+
declare function createConstraintsDsl<IndexTypes extends IndexTypeMap = Record<never, never>>(): {
|
|
334
|
+
ref: <ModelName extends string, FieldName extends string>(modelName: ModelName, fieldName: FieldName) => TargetFieldRef<ModelName, FieldName>;
|
|
335
|
+
id: {
|
|
336
|
+
<FieldName extends string, Name extends string | undefined = undefined>(field: ColumnRef<FieldName>, options?: NamedConstraintSpec<Name>): IdConstraint<readonly [FieldName], Name>;
|
|
337
|
+
<FieldNames extends readonly string[], Name extends string | undefined = undefined>(fields: { readonly [K in keyof FieldNames]: ColumnRef<FieldNames[K] & string>; }, options?: NamedConstraintSpec<Name>): IdConstraint<FieldNames, Name>;
|
|
338
|
+
};
|
|
339
|
+
unique: {
|
|
340
|
+
<FieldName extends string>(field: ColumnRef<FieldName>, options?: ConstraintOptions): UniqueConstraint<readonly [FieldName]>;
|
|
341
|
+
<FieldNames extends readonly string[]>(fields: { readonly [K in keyof FieldNames]: ColumnRef<FieldNames[K] & string>; }, options?: ConstraintOptions): UniqueConstraint<FieldNames>;
|
|
342
|
+
};
|
|
343
|
+
index: {
|
|
344
|
+
<FieldNames extends readonly string[], Name extends string | undefined = undefined>(fields: { readonly [K in keyof FieldNames]: ColumnRef<FieldNames[K] & string>; }, options?: IndexInput<Name, IndexTypes>): IndexConstraint<FieldNames, Name>;
|
|
345
|
+
<Name extends string | undefined = undefined>(options: ExpressionIndexInput<Name, IndexTypes>): IndexConstraint<never, Name>;
|
|
346
|
+
};
|
|
347
|
+
foreignKey: {
|
|
348
|
+
<SourceFieldName extends string, TargetModelName extends string, TargetFieldName extends string, Name extends string | undefined = undefined>(field: ColumnRef<SourceFieldName>, target: TargetFieldRef<TargetModelName, TargetFieldName>, options?: ForeignKeyOptions<Name>): ForeignKeyConstraint<readonly [SourceFieldName], TargetModelName, readonly [TargetFieldName], Name>;
|
|
349
|
+
<SourceFieldNames extends readonly string[], TargetModelName extends string, TargetFieldNames extends readonly string[], Name extends string | undefined = undefined>(fields: { readonly [K in keyof SourceFieldNames]: ColumnRef<SourceFieldNames[K] & string>; }, target: { readonly [K in keyof TargetFieldNames]: TargetFieldRef<TargetModelName, TargetFieldNames[K] & string>; }, options?: ForeignKeyOptions<Name>): ForeignKeyConstraint<SourceFieldNames, TargetModelName, TargetFieldNames, Name>;
|
|
350
|
+
};
|
|
351
|
+
};
|
|
352
|
+
type ConstraintsDsl = ReturnType<typeof createConstraintsDsl>;
|
|
353
|
+
type ModelAttributesSpec = {
|
|
354
|
+
readonly id?: IdConstraint;
|
|
355
|
+
readonly uniques?: readonly UniqueConstraint[];
|
|
356
|
+
};
|
|
357
|
+
type SqlStageSpec = {
|
|
358
|
+
readonly table?: string;
|
|
359
|
+
readonly control?: ControlPolicy;
|
|
360
|
+
readonly indexes?: readonly IndexConstraint[];
|
|
361
|
+
readonly foreignKeys?: readonly ForeignKeyConstraint[];
|
|
362
|
+
};
|
|
363
|
+
type FieldRefs<Fields extends Record<string, ScalarFieldBuilder>> = { readonly [K in keyof Fields]: ColumnRef<K & string>; };
|
|
364
|
+
type AttributeContext<Fields extends Record<string, ScalarFieldBuilder>> = {
|
|
365
|
+
readonly fields: FieldRefs<Fields>;
|
|
366
|
+
readonly constraints: Pick<ConstraintsDsl, 'id' | 'unique'>;
|
|
367
|
+
};
|
|
368
|
+
type PackAwareIndex<IndexTypes extends IndexTypeMap> = {
|
|
369
|
+
<FieldNames extends readonly string[], Name extends string | undefined = undefined>(fields: { readonly [K in keyof FieldNames]: ColumnRef<FieldNames[K] & string>; }, options?: IndexInput<Name, IndexTypes>): IndexConstraint<FieldNames, Name>;
|
|
370
|
+
<Name extends string | undefined = undefined>(options: ExpressionIndexInput<Name, IndexTypes>): IndexConstraint<never, Name>;
|
|
371
|
+
};
|
|
372
|
+
type PackAwareSqlConstraints<IndexTypes extends IndexTypeMap> = {
|
|
373
|
+
readonly foreignKey: ConstraintsDsl['foreignKey'];
|
|
374
|
+
readonly ref: ConstraintsDsl['ref'];
|
|
375
|
+
readonly index: PackAwareIndex<IndexTypes>;
|
|
376
|
+
};
|
|
377
|
+
type SqlContext<Fields extends Record<string, ScalarFieldBuilder>, IndexTypes extends IndexTypeMap = Record<never, never>> = {
|
|
378
|
+
readonly cols: FieldRefs<Fields>;
|
|
379
|
+
readonly constraints: PackAwareSqlConstraints<IndexTypes>;
|
|
380
|
+
};
|
|
381
|
+
type StageInput<Context, Spec> = Spec | ((context: Context) => Spec);
|
|
382
|
+
type StaticLiteralName<Name> = Name extends string ? (string extends Name ? never : Name) : never;
|
|
383
|
+
type NamedConstraintLiteralName<Constraint> = Constraint extends {
|
|
384
|
+
readonly name?: infer Name;
|
|
385
|
+
} ? StaticLiteralName<Name> : never;
|
|
386
|
+
type DuplicateLiteralNames<Items extends readonly unknown[], Seen extends string = never, Duplicates extends string = never> = Items extends readonly [infer First, ...infer Rest extends readonly unknown[]] ? NamedConstraintLiteralName<First> extends (infer Name extends string) ? Name extends Seen ? DuplicateLiteralNames<Rest, Seen, Duplicates | Name> : DuplicateLiteralNames<Rest, Seen | Name, Duplicates> : DuplicateLiteralNames<Rest, Seen, Duplicates> : Duplicates;
|
|
387
|
+
type InlineIdLiteralName<Fields extends Record<string, ScalarFieldBuilder>> = { readonly [FieldName in keyof Fields]: FieldStateOf<Fields[FieldName]> extends {
|
|
388
|
+
readonly id: {
|
|
389
|
+
readonly name?: infer Name;
|
|
390
|
+
};
|
|
391
|
+
} ? StaticLiteralName<Name> : never; }[keyof Fields];
|
|
392
|
+
type AttributeIdLiteralName<AttributesSpec extends ModelAttributesSpec | undefined> = AttributesSpec extends {
|
|
393
|
+
readonly id?: {
|
|
394
|
+
readonly name?: infer Name;
|
|
395
|
+
};
|
|
396
|
+
} ? StaticLiteralName<Name> : never;
|
|
397
|
+
type ModelIdLiteralName<Fields extends Record<string, ScalarFieldBuilder>, AttributesSpec extends ModelAttributesSpec | undefined> = [AttributeIdLiteralName<AttributesSpec>] extends [never] ? InlineIdLiteralName<Fields> : AttributeIdLiteralName<AttributesSpec>;
|
|
398
|
+
type SqlIndexes<SqlSpec extends SqlStageSpec> = SqlSpec extends {
|
|
399
|
+
readonly indexes?: infer Indexes extends readonly unknown[];
|
|
400
|
+
} ? Indexes : readonly [];
|
|
401
|
+
type SqlForeignKeys<SqlSpec extends SqlStageSpec> = SqlSpec extends {
|
|
402
|
+
readonly foreignKeys?: infer ForeignKeys extends readonly unknown[];
|
|
403
|
+
} ? ForeignKeys : readonly [];
|
|
404
|
+
type SqlNamedObjects<SqlSpec extends SqlStageSpec> = [...SqlIndexes<SqlSpec>, ...SqlForeignKeys<SqlSpec>];
|
|
405
|
+
type ValidateSqlStageSpec<Fields extends Record<string, ScalarFieldBuilder>, AttributesSpec extends ModelAttributesSpec | undefined, SqlSpec extends SqlStageSpec> = [DuplicateLiteralNames<SqlNamedObjects<SqlSpec>>] extends [never] ? [Extract<ModelIdLiteralName<Fields, AttributesSpec>, NamedConstraintLiteralName<SqlNamedObjects<SqlSpec>[number]>>] extends [never] ? SqlSpec : never : never;
|
|
406
|
+
type ValidateAttributesStageSpec<Fields extends Record<string, ScalarFieldBuilder>, SqlSpec extends SqlStageSpec | undefined, AttributesSpec extends ModelAttributesSpec> = SqlSpec extends SqlStageSpec ? [Extract<ModelIdLiteralName<Fields, AttributesSpec>, NamedConstraintLiteralName<SqlNamedObjects<SqlSpec>[number]>>] extends [never] ? AttributesSpec : never : AttributesSpec;
|
|
407
|
+
declare class ContractModelBuilder<ModelName extends string | undefined, Fields extends Record<string, ScalarFieldBuilder>, Relations extends Record<string, AnyRelationBuilder> = Record<never, never>, AttributesSpec extends ModelAttributesSpec | undefined = undefined, SqlSpec extends SqlStageSpec | undefined = undefined, IndexTypes extends IndexTypeMap = Record<never, never>, TSpaceId extends string = '<self>'> {
|
|
408
|
+
readonly stageOne: {
|
|
409
|
+
readonly modelName?: ModelName;
|
|
410
|
+
readonly namespace?: string;
|
|
411
|
+
readonly fields: Fields;
|
|
412
|
+
readonly relations: Relations;
|
|
413
|
+
};
|
|
414
|
+
readonly attributesFactory?: StageInput<AttributeContext<Fields>, AttributesSpec> | undefined;
|
|
415
|
+
readonly sqlFactory?: StageInput<SqlContext<Fields, IndexTypes>, SqlSpec> | undefined;
|
|
416
|
+
readonly spaceId?: TSpaceId | undefined;
|
|
417
|
+
readonly tableName?: string | undefined;
|
|
418
|
+
readonly __name: ModelName;
|
|
419
|
+
readonly __fields: Fields;
|
|
420
|
+
readonly __relations: Relations;
|
|
421
|
+
readonly __attributes: AttributesSpec;
|
|
422
|
+
readonly __sql: SqlSpec;
|
|
423
|
+
readonly __indexTypes: IndexTypes;
|
|
424
|
+
readonly __spaceId: TSpaceId;
|
|
425
|
+
readonly refs: ModelName extends string ? ModelTokenRefs<ModelName, Fields, TSpaceId> : never;
|
|
426
|
+
constructor(stageOne: {
|
|
427
|
+
readonly modelName?: ModelName;
|
|
428
|
+
readonly namespace?: string;
|
|
429
|
+
readonly fields: Fields;
|
|
430
|
+
readonly relations: Relations;
|
|
431
|
+
}, attributesFactory?: StageInput<AttributeContext<Fields>, AttributesSpec> | undefined, sqlFactory?: StageInput<SqlContext<Fields, IndexTypes>, SqlSpec> | undefined, spaceId?: TSpaceId | undefined, tableName?: string | undefined);
|
|
432
|
+
ref<FieldName extends keyof Fields & string>(this: ModelName extends string ? ContractModelBuilder<ModelName, Fields, Relations, AttributesSpec, SqlSpec, IndexTypes> : never, fieldName: FieldName): TargetFieldRef<ModelName & string, FieldName>;
|
|
433
|
+
relations<const NextRelations extends Record<string, AnyRelationBuilder>>(relations: NextRelations): ContractModelBuilder<ModelName, Fields, Relations & NextRelations, AttributesSpec, SqlSpec, IndexTypes, TSpaceId>;
|
|
434
|
+
attributes<const NextAttributesSpec extends ModelAttributesSpec>(specOrFactory: StageInput<AttributeContext<Fields>, ValidateAttributesStageSpec<Fields, SqlSpec, NextAttributesSpec>>): ContractModelBuilder<ModelName, Fields, Relations, NextAttributesSpec, SqlSpec, IndexTypes, TSpaceId>;
|
|
435
|
+
sql<const NextSqlSpec extends SqlStageSpec>(specOrFactory: StageInput<SqlContext<Fields, IndexTypes>, NextSqlSpec>): [ValidateSqlStageSpec<Fields, AttributesSpec, NextSqlSpec>] extends [never] ? ContractModelBuilder<ModelName, Fields, Relations, AttributesSpec, never, IndexTypes, TSpaceId> : ContractModelBuilder<ModelName, Fields, Relations, AttributesSpec, NextSqlSpec, IndexTypes, TSpaceId>;
|
|
436
|
+
buildAttributesSpec(): AttributesSpec;
|
|
437
|
+
buildSqlSpec(): SqlSpec;
|
|
438
|
+
}
|
|
439
|
+
type NamedModelTokenShape<ModelName extends string = string, Fields extends Record<string, ScalarFieldBuilder> = Record<string, ScalarFieldBuilder>> = {
|
|
440
|
+
readonly stageOne: {
|
|
441
|
+
readonly modelName?: ModelName;
|
|
442
|
+
readonly fields: Fields;
|
|
443
|
+
};
|
|
444
|
+
};
|
|
445
|
+
type AnyNamedModelToken = NamedModelTokenShape<string, Record<string, ScalarFieldBuilder>>;
|
|
446
|
+
type LazyNamedModelToken<Token extends AnyNamedModelToken = AnyNamedModelToken> = () => Token;
|
|
447
|
+
type RelationFieldSelection<FieldName extends string> = FieldName | readonly FieldName[];
|
|
448
|
+
type RelationModelName<Target> = Target extends NamedModelTokenShape<infer ModelName extends string, Record<string, ScalarFieldBuilder>> ? ModelName : Target extends (() => infer Token) ? RelationModelName<Token> : never;
|
|
449
|
+
type RelationModelFieldNames<Target> = Target extends NamedModelTokenShape<string, infer Fields> ? keyof Fields & string : Target extends (() => infer Token) ? RelationModelFieldNames<Token> : never;
|
|
450
|
+
type ContractInput<Family extends FamilyPackRef<string> = FamilyPackRef<string>, Target extends TargetPackRef<'sql', string> = TargetPackRef<'sql', string>, Types extends Record<string, StorageTypeInstance> = Record<never, never>, Models extends Record<string, ContractModelBuilder<string | undefined, Record<string, ScalarFieldBuilder>, Record<string, AnyRelationBuilder>, ModelAttributesSpec | undefined, SqlStageSpec | undefined>> = Record<never, never>, Extensions extends Record<string, ExtensionPackRef<'sql', string>> | undefined = undefined> = {
|
|
451
|
+
readonly family: Family;
|
|
452
|
+
readonly target: Target;
|
|
453
|
+
readonly extensions?: Extensions;
|
|
454
|
+
readonly naming?: NamingConfig;
|
|
455
|
+
readonly storageHash?: string;
|
|
456
|
+
readonly foreignKeyDefaults?: ForeignKeyDefaultsState;
|
|
457
|
+
readonly defaultControlPolicy?: ControlPolicy;
|
|
458
|
+
/**
|
|
459
|
+
* Declared namespace coordinates the contract recognises. Per-model
|
|
460
|
+
* `namespace` references must reference an entry in this list (or the
|
|
461
|
+
* Postgres-specific late-binding keyword `unbound`). Reserved values:
|
|
462
|
+
*
|
|
463
|
+
* - `__unbound__` — IR sentinel for the late-binding slot.
|
|
464
|
+
* - `__unspecified__` — parser-synthesised AST bucket for top-level
|
|
465
|
+
* declarations (not a real namespace).
|
|
466
|
+
* - `unbound` — Postgres-specific reserved keyword (the PSL surface
|
|
467
|
+
* uses `namespace unbound { … }` to opt into late binding).
|
|
468
|
+
*
|
|
469
|
+
* SQLite contracts must declare an empty list (or omit the field) —
|
|
470
|
+
* SQLite has no schema concept and emits unqualified DDL.
|
|
471
|
+
*
|
|
472
|
+
* Populates `SqlStorage.namespaces` together with the
|
|
473
|
+
* {@link ContractInput.createNamespace} factory: each declared name
|
|
474
|
+
* (plus the framework-reserved `UNBOUND_NAMESPACE_ID` sentinel) is
|
|
475
|
+
* resolved through `createNamespace` and stored as the matching slot
|
|
476
|
+
* value. Models reference declared namespaces via their per-model
|
|
477
|
+
* `namespace` coordinate; entries that go unreferenced still occupy a
|
|
478
|
+
* slot so contracts that pre-declare schemas surface them on the live
|
|
479
|
+
* storage walk.
|
|
480
|
+
*/
|
|
481
|
+
readonly namespaces?: readonly string[];
|
|
482
|
+
/**
|
|
483
|
+
* Target-supplied factory that materialises a `SqlNamespaceBase` concretion
|
|
484
|
+
* for a declared namespace coordinate. The SQL family layer is
|
|
485
|
+
* target-agnostic and cannot import concretions like
|
|
486
|
+
* `PostgresSchema` or `SqliteUnboundDatabase`; the factory is the
|
|
487
|
+
* seam by which target packs hand the family the right runtime
|
|
488
|
+
* representation.
|
|
489
|
+
*
|
|
490
|
+
* Called once per distinct namespace id discovered in the contract:
|
|
491
|
+
* each entry of {@link ContractInput.namespaces}, every
|
|
492
|
+
* `StorageTable.namespaceId` referenced by a model, and the
|
|
493
|
+
* framework `UNBOUND_NAMESPACE_ID` sentinel (always present so the
|
|
494
|
+
* late-bound slot stays available regardless of authoring choices).
|
|
495
|
+
*/
|
|
496
|
+
readonly createNamespace: (input: SqlNamespaceInput) => SqlNamespaceBase;
|
|
497
|
+
readonly types?: Types;
|
|
498
|
+
readonly models?: Models;
|
|
499
|
+
readonly codecLookup?: CodecLookup;
|
|
500
|
+
/**
|
|
501
|
+
* Domain enum handles authored via `enumType()`. Each handle lowers to a
|
|
502
|
+
* domain `enum` entry and a storage `valueSet` entry in the target's
|
|
503
|
+
* default namespace. Fields reference the enum via `field.namedType(handle)`.
|
|
504
|
+
*/
|
|
505
|
+
readonly enums?: Record<string, EnumTypeHandle>;
|
|
506
|
+
/**
|
|
507
|
+
* Author-declared pack-entity handles, lowered by the pack that registered
|
|
508
|
+
* each handle's `entityKind` (through the SQL-family batch lowering hook)
|
|
509
|
+
* into namespace-scoped entry attachments at build time. Generic on
|
|
510
|
+
* purpose — neither this type nor the walk names a specific kind; a handle
|
|
511
|
+
* whose kind no composed pack registers is a build error. This is the only
|
|
512
|
+
* public channel for attaching pack entities.
|
|
513
|
+
*/
|
|
514
|
+
readonly entities?: readonly PackEntityHandle[];
|
|
515
|
+
};
|
|
516
|
+
declare function model<const ModelName extends string, Fields extends Record<string, ScalarFieldBuilder>, Relations extends Record<string, AnyRelationBuilder> = Record<never, never>>(modelName: ModelName, input: {
|
|
517
|
+
readonly fields: Fields;
|
|
518
|
+
readonly relations?: Relations;
|
|
519
|
+
readonly namespace?: string;
|
|
520
|
+
}): ContractModelBuilder<ModelName, Fields, Relations>;
|
|
521
|
+
declare function model<Fields extends Record<string, ScalarFieldBuilder>, Relations extends Record<string, AnyRelationBuilder> = Record<never, never>>(input: {
|
|
522
|
+
readonly fields: Fields;
|
|
523
|
+
readonly relations?: Relations;
|
|
524
|
+
readonly namespace?: string;
|
|
525
|
+
}): ContractModelBuilder<undefined, Fields, Relations>;
|
|
526
|
+
/**
|
|
527
|
+
* Factory for building a standalone branded extension model handle.
|
|
528
|
+
*
|
|
529
|
+
* Use this instead of `new ContractModelBuilder(…)` when constructing handles
|
|
530
|
+
* for models that live in a foreign contract space (e.g. a Supabase extension
|
|
531
|
+
* model referenced by a user's contract). The `spaceId` brands the returned
|
|
532
|
+
* handle so `refs.<field>.spaceId` carries the foreign space identifier.
|
|
533
|
+
*
|
|
534
|
+
* @param name - The domain model name as declared in the foreign contract
|
|
535
|
+
* (e.g. `'AuthUser'`, not a bare table alias like `'User'`).
|
|
536
|
+
* @param input.namespace - The namespace within the foreign space (e.g. `'auth'`).
|
|
537
|
+
* @param input.fields - Field definitions (use `field.column(…)`).
|
|
538
|
+
* @param input.table - The physical table name in the foreign schema.
|
|
539
|
+
* @param spaceId - The extension space identifier (e.g. `'supabase'`).
|
|
540
|
+
*/
|
|
541
|
+
declare function extensionModel<const ModelName extends string, Fields extends Record<string, ScalarFieldBuilder>, const TSpaceId extends string>(name: ModelName, input: {
|
|
542
|
+
readonly namespace: string;
|
|
543
|
+
readonly fields: Fields;
|
|
544
|
+
readonly table: string;
|
|
545
|
+
}, spaceId: TSpaceId): ContractModelBuilder<ModelName, Fields, Record<never, never>, undefined, undefined, Record<never, never>, TSpaceId>;
|
|
546
|
+
declare function belongsTo<Token extends AnyNamedModelToken, FromField extends string | readonly string[], ToField extends RelationFieldSelection<RelationModelFieldNames<Token>>>(toModel: Token | LazyNamedModelToken<Token>, options: {
|
|
547
|
+
readonly from: FromField;
|
|
548
|
+
readonly to: ToField;
|
|
549
|
+
}): RelationBuilder<BelongsToRelation<RelationModelName<Token>, FromField, ToField>>;
|
|
550
|
+
declare function belongsTo<ToModel extends string, FromField extends string | readonly string[], ToField extends string | readonly string[]>(toModel: ToModel, options: {
|
|
551
|
+
readonly from: FromField;
|
|
552
|
+
readonly to: ToField;
|
|
553
|
+
}): RelationBuilder<BelongsToRelation<ToModel, FromField, ToField>>;
|
|
554
|
+
declare function hasMany<Token extends AnyNamedModelToken, ByField extends RelationFieldSelection<RelationModelFieldNames<Token>>>(toModel: Token | LazyNamedModelToken<Token>, options: {
|
|
555
|
+
readonly by: ByField;
|
|
556
|
+
}): RelationBuilder<HasManyRelation<RelationModelName<Token>, ByField>>;
|
|
557
|
+
declare function hasMany<ToModel extends string, ByField extends string | readonly string[]>(toModel: ToModel, options: {
|
|
558
|
+
readonly by: ByField;
|
|
559
|
+
}): RelationBuilder<HasManyRelation<ToModel, ByField>>;
|
|
560
|
+
declare function hasOne<Token extends AnyNamedModelToken, ByField extends RelationFieldSelection<RelationModelFieldNames<Token>>>(toModel: Token | LazyNamedModelToken<Token>, options: {
|
|
561
|
+
readonly by: ByField;
|
|
562
|
+
}): RelationBuilder<HasOneRelation<RelationModelName<Token>, ByField>>;
|
|
563
|
+
declare function hasOne<ToModel extends string, ByField extends string | readonly string[]>(toModel: ToModel, options: {
|
|
564
|
+
readonly by: ByField;
|
|
565
|
+
}): RelationBuilder<HasOneRelation<ToModel, ByField>>;
|
|
566
|
+
declare function manyToMany<ToToken extends AnyNamedModelToken, ThroughToken extends AnyNamedModelToken, FromField extends RelationFieldSelection<RelationModelFieldNames<ThroughToken>>, ToField extends RelationFieldSelection<RelationModelFieldNames<ThroughToken>>>(toModel: ToToken | LazyNamedModelToken<ToToken>, options: {
|
|
567
|
+
readonly through: ThroughToken | LazyNamedModelToken<ThroughToken>;
|
|
568
|
+
readonly from: FromField;
|
|
569
|
+
readonly to: ToField;
|
|
570
|
+
}): RelationBuilder<ManyToManyRelation<RelationModelName<ToToken>, RelationModelName<ThroughToken>, FromField, ToField>>;
|
|
571
|
+
declare function manyToMany<ToModel extends string, ThroughModel extends string, FromField extends string | readonly string[], ToField extends string | readonly string[]>(toModel: ToModel, options: {
|
|
572
|
+
readonly through: ThroughModel;
|
|
573
|
+
readonly from: FromField;
|
|
574
|
+
readonly to: ToField;
|
|
575
|
+
}): RelationBuilder<ManyToManyRelation<ToModel, ThroughModel, FromField, ToField>>;
|
|
576
|
+
declare const rel: {
|
|
577
|
+
belongsTo: typeof belongsTo;
|
|
578
|
+
hasMany: typeof hasMany;
|
|
579
|
+
hasOne: typeof hasOne;
|
|
580
|
+
manyToMany: typeof manyToMany;
|
|
581
|
+
};
|
|
582
|
+
declare const field: {
|
|
583
|
+
column: typeof columnField;
|
|
584
|
+
generated: typeof generatedField;
|
|
585
|
+
namedType: typeof namedTypeField;
|
|
586
|
+
};
|
|
587
|
+
type FieldStateOf<T> = T extends ScalarFieldBuilder<infer State> ? State : never;
|
|
588
|
+
type IdFieldNames<T> = T extends IdConstraint<infer FieldNames> ? FieldNames : readonly string[];
|
|
589
|
+
type AttributeStageIdFieldNames<T> = T extends {
|
|
590
|
+
readonly id?: infer I;
|
|
591
|
+
} ? I extends IdConstraint ? IdFieldNames<I> : undefined : undefined;
|
|
592
|
+
//#endregion
|
|
593
|
+
//#region src/authoring-type-utils.d.ts
|
|
594
|
+
type UnionToIntersection<U> = (U extends unknown ? (value: U) => void : never) extends ((value: infer I) => void) ? I : never;
|
|
595
|
+
type NamedConstraintSpec<Name extends string | undefined = string | undefined> = {
|
|
596
|
+
readonly name?: Name;
|
|
597
|
+
};
|
|
598
|
+
type NamedConstraintState<Enabled extends boolean, Name extends string | undefined = undefined> = Enabled extends true ? NamedConstraintSpec<Name> : undefined;
|
|
599
|
+
type OptionalObjectArgumentKeys<Properties extends Record<string, AuthoringArgumentDescriptor>> = { readonly [K in keyof Properties]: Properties[K] extends {
|
|
600
|
+
readonly optional: true;
|
|
601
|
+
} ? K : never; }[keyof Properties];
|
|
602
|
+
type RequiredObjectArgumentKeys<Properties extends Record<string, AuthoringArgumentDescriptor>> = Exclude<keyof Properties, OptionalObjectArgumentKeys<Properties>>;
|
|
603
|
+
/**
|
|
604
|
+
* When every property is optional the result must be a plain weak type rather
|
|
605
|
+
* than `{} & { … }`: TypeScript's weak-type check rejects an object sharing
|
|
606
|
+
* none of the target's properties, but only when the target is weak — and an
|
|
607
|
+
* intersection with `{}` is not. The TS authoring surface runs no runtime
|
|
608
|
+
* argument validation, so this check is the only thing rejecting a foreign key
|
|
609
|
+
* such as `field.nanoid({ bogus: 1 })`.
|
|
610
|
+
*/
|
|
611
|
+
type ObjectArgumentType<Properties extends Record<string, AuthoringArgumentDescriptor>> = [RequiredObjectArgumentKeys<Properties>] extends [never] ? { readonly [K in OptionalObjectArgumentKeys<Properties>]?: ArgTypeFromDescriptor<Properties[K]>; } : { readonly [K in RequiredObjectArgumentKeys<Properties>]: ArgTypeFromDescriptor<Properties[K]>; } & { readonly [K in OptionalObjectArgumentKeys<Properties>]?: ArgTypeFromDescriptor<Properties[K]>; };
|
|
612
|
+
type ArgTypeFromDescriptor<Arg extends AuthoringArgumentDescriptor> = Arg extends {
|
|
613
|
+
readonly kind: 'string';
|
|
614
|
+
} ? string : Arg extends {
|
|
615
|
+
readonly kind: 'boolean';
|
|
616
|
+
} ? boolean : Arg extends {
|
|
617
|
+
readonly kind: 'number';
|
|
618
|
+
} ? number : Arg extends {
|
|
619
|
+
readonly kind: 'stringArray';
|
|
620
|
+
} ? readonly string[] : Arg extends {
|
|
621
|
+
readonly kind: 'option';
|
|
622
|
+
readonly values: infer Values extends readonly string[];
|
|
623
|
+
} ? Values[number] : Arg extends {
|
|
624
|
+
readonly kind: 'object';
|
|
625
|
+
readonly properties: infer Properties extends Record<string, AuthoringArgumentDescriptor>;
|
|
626
|
+
} ? ObjectArgumentType<Properties> : never;
|
|
627
|
+
/**
|
|
628
|
+
* Recursive rewrite (not a mapped tuple type) so a descriptor marked
|
|
629
|
+
* `optional: true` gets an optional tuple slot (`Type?`), letting callers
|
|
630
|
+
* omit it and every optional arg after it. Required args must precede
|
|
631
|
+
* optional args in a descriptor's `args` list — TypeScript rejects an
|
|
632
|
+
* optional tuple element followed by a required one, and the runtime
|
|
633
|
+
* (`validateAuthoringHelperArguments`'s `minimumArgs`) already treats an
|
|
634
|
+
* optional-before-required arg as effectively required.
|
|
635
|
+
*/
|
|
636
|
+
type TupleFromArgumentDescriptors<Args extends readonly AuthoringArgumentDescriptor[]> = Args extends readonly [infer Head extends AuthoringArgumentDescriptor, ...infer Tail extends readonly AuthoringArgumentDescriptor[]] ? Head extends {
|
|
637
|
+
readonly optional: true;
|
|
638
|
+
} ? readonly [ArgTypeFromDescriptor<Head>?, ...TupleFromArgumentDescriptors<Tail>] : readonly [ArgTypeFromDescriptor<Head>, ...TupleFromArgumentDescriptors<Tail>] : readonly [];
|
|
639
|
+
type SupportsNamedConstraintOptions<Descriptor extends AuthoringFieldPresetDescriptor> = Descriptor['output'] extends {
|
|
640
|
+
readonly id: true;
|
|
641
|
+
} ? true : Descriptor['output'] extends {
|
|
642
|
+
readonly unique: true;
|
|
643
|
+
} ? true : false;
|
|
644
|
+
type ResolveTemplateValue<Template, Args extends readonly unknown[]> = Template extends {
|
|
645
|
+
readonly kind: 'arg';
|
|
646
|
+
readonly index: infer Index extends number;
|
|
647
|
+
readonly path?: infer Path extends readonly string[] | undefined;
|
|
648
|
+
readonly default?: infer Default;
|
|
649
|
+
} ? ResolveTemplateArgValue<Args[Index], Path, Default, Args> : Template extends readonly unknown[] ? { readonly [K in keyof Template]: ResolveTemplateValue<Template[K], Args>; } : Template extends Record<string, unknown> ? { readonly [K in keyof Template]: ResolveTemplateValue<Template[K], Args>; } : Template;
|
|
650
|
+
type ResolveTemplatePathValue<Value, Path extends readonly string[] | undefined> = Path extends readonly [infer Segment extends string, ...infer Rest extends readonly string[]] ? Segment extends keyof NonNullable<Value> ? ResolveTemplatePathValue<NonNullable<Value>[Segment], Rest> : never : Value;
|
|
651
|
+
type ResolveTemplateDefaultValue<Value, Default, Args extends readonly unknown[]> = Default extends undefined ? Value : [Value] extends [never] ? ResolveTemplateValue<Default, Args> : undefined extends Value ? Exclude<Value, undefined> | ResolveTemplateValue<Default, Args> : Value;
|
|
652
|
+
type ResolveTemplateArgValue<Value, Path extends readonly string[] | undefined, Default, Args extends readonly unknown[]> = ResolveTemplateDefaultValue<ResolveTemplatePathValue<Value, Path>, Default, Args>;
|
|
653
|
+
type FieldBuilderFromPresetDescriptor<Descriptor extends AuthoringFieldPresetDescriptor, Args extends readonly unknown[] = readonly [], ConstraintName extends string | undefined = undefined> = ScalarFieldBuilder<ScalarFieldState<ColumnTypeDescriptor<ResolveTemplateValue<Descriptor['output']['codecId'], Args> extends string ? ResolveTemplateValue<Descriptor['output']['codecId'], Args> : string>, undefined, ResolveTemplateValue<Descriptor['output']['nullable'], Args> extends true ? true : false, undefined, NamedConstraintState<ResolveTemplateValue<Descriptor['output']['id'], Args> extends true ? true : false, ConstraintName>, NamedConstraintState<ResolveTemplateValue<Descriptor['output']['unique'], Args> extends true ? true : false, ConstraintName>>>;
|
|
654
|
+
type FieldHelperFunctionWithoutNamedConstraint<Descriptor extends AuthoringFieldPresetDescriptor> = Descriptor extends {
|
|
655
|
+
readonly args: infer Args extends readonly AuthoringArgumentDescriptor[];
|
|
656
|
+
} ? <const Params extends TupleFromArgumentDescriptors<Args>>(...args: Params) => FieldBuilderFromPresetDescriptor<Descriptor, Params> : () => FieldBuilderFromPresetDescriptor<Descriptor, readonly []>;
|
|
657
|
+
/**
|
|
658
|
+
* An intersection of two call signatures rather than one rest-tuple signature
|
|
659
|
+
* with a trailing `options?`. Once optional descriptors yield optional tuple
|
|
660
|
+
* slots, `Params` can infer as the empty tuple, and a single-argument call
|
|
661
|
+
* such as `field.id.nanoid({ size: 16 })` would bind its preset argument to
|
|
662
|
+
* the trailing optional `options` parameter. Resolving the no-options
|
|
663
|
+
* signature first, and falling through to the options-required signature only
|
|
664
|
+
* when the argument list cannot satisfy it, keeps both spellings working.
|
|
665
|
+
*/
|
|
666
|
+
type FieldHelperFunctionWithNamedConstraint<Descriptor extends AuthoringFieldPresetDescriptor> = Descriptor extends {
|
|
667
|
+
readonly args: infer Args extends readonly AuthoringArgumentDescriptor[];
|
|
668
|
+
} ? (<const Params extends TupleFromArgumentDescriptors<Args>>(...args: Params) => FieldBuilderFromPresetDescriptor<Descriptor, Params>) & (<const Params extends TupleFromArgumentDescriptors<Args>, const Name extends string | undefined = undefined>(...args: [...params: Params, options: NamedConstraintSpec<Name>]) => FieldBuilderFromPresetDescriptor<Descriptor, Params, Name>) : <const Name extends string | undefined = undefined>(options?: NamedConstraintSpec<Name>) => FieldBuilderFromPresetDescriptor<Descriptor, readonly [], Name>;
|
|
669
|
+
type FieldHelperFunction<Descriptor extends AuthoringFieldPresetDescriptor> = SupportsNamedConstraintOptions<Descriptor> extends true ? FieldHelperFunctionWithNamedConstraint<Descriptor> : FieldHelperFunctionWithoutNamedConstraint<Descriptor>;
|
|
670
|
+
type FieldHelpersFromNamespace<Namespace> = { readonly [K in keyof Namespace]: Namespace[K] extends AuthoringFieldPresetDescriptor ? FieldHelperFunction<Namespace[K]> : Namespace[K] extends Record<string, unknown> ? FieldHelpersFromNamespace<Namespace[K]> : never; };
|
|
671
|
+
//#endregion
|
|
672
|
+
//#region src/contract-types.d.ts
|
|
673
|
+
type PublicCodecTypes<CodecTypes extends Record<string, {
|
|
674
|
+
readonly output: unknown;
|
|
675
|
+
}>> = { readonly [CodecId in keyof CodecTypes]: Pick<CodecTypes[CodecId], Extract<keyof CodecTypes[CodecId], 'input' | 'output' | 'traits'>>; };
|
|
676
|
+
type ExtractCodecTypesFromPack<P> = P extends {
|
|
677
|
+
__codecTypes?: infer C extends Record<string, {
|
|
678
|
+
readonly output: unknown;
|
|
679
|
+
}>;
|
|
680
|
+
} ? PublicCodecTypes<C> : Record<string, never>;
|
|
681
|
+
type MergeExtensionCodecTypes<Packs extends Record<string, unknown>> = UnionToIntersection<{ [K in keyof Packs]: ExtractCodecTypesFromPack<Packs[K]>; }[keyof Packs]>;
|
|
682
|
+
type MergeExtensionCodecTypesSafe<Packs> = Packs extends Record<string, unknown> ? keyof Packs extends never ? Record<string, never> : MergeExtensionCodecTypes<Packs> : Record<string, never>;
|
|
683
|
+
type ExtractIndexTypesFromPack<P> = P extends {
|
|
684
|
+
readonly indexTypes: IndexTypeRegistration<infer M>;
|
|
685
|
+
} ? M : Record<never, never>;
|
|
686
|
+
type AllIndexTypeLiterals<Packs> = Packs extends Record<string, unknown> ? { [K in keyof Packs]: keyof ExtractIndexTypesFromPack<Packs[K]>; }[keyof Packs] & string : never;
|
|
687
|
+
type MergeExtensionIndexTypes<Packs extends Record<string, unknown>> = { readonly [Lit in AllIndexTypeLiterals<Packs>]: Extract<{ [K in keyof Packs]: Lit extends keyof ExtractIndexTypesFromPack<Packs[K]> ? ExtractIndexTypesFromPack<Packs[K]>[Lit] : never; }[keyof Packs], {
|
|
688
|
+
readonly options: unknown;
|
|
689
|
+
}>; };
|
|
690
|
+
type DefinitionExtensions<Definition> = Definition extends {
|
|
691
|
+
readonly extensions?: infer Packs extends Record<string, ExtensionPackRef<'sql', string>>;
|
|
692
|
+
} ? Packs : Record<never, never>;
|
|
693
|
+
type ExtractPackCapabilities<P> = P extends {
|
|
694
|
+
readonly capabilities?: infer Caps extends Record<string, Record<string, boolean>>;
|
|
695
|
+
} ? Caps : never;
|
|
696
|
+
type MergeExtensionPackCapabilities<Packs> = Packs extends Record<string, unknown> ? keyof Packs extends never ? Record<string, never> : UnionToIntersection<{ [K in keyof Packs]: ExtractPackCapabilities<Packs[K]>; }[keyof Packs]> : Record<string, never>;
|
|
697
|
+
type Defaulted<T, Fallback> = [T] extends [never] ? Fallback : T;
|
|
698
|
+
type DerivedCapabilities<Definition> = Defaulted<ExtractPackCapabilities<DefinitionTarget<Definition>>, Record<string, never>> & MergeExtensionPackCapabilities<DefinitionExtensions<Definition>>;
|
|
699
|
+
type DefinitionTargetId<Definition> = Definition extends {
|
|
700
|
+
readonly target: TargetPackRef<'sql', infer Target>;
|
|
701
|
+
} ? Target : never;
|
|
702
|
+
type Present<T> = Exclude<T, undefined>;
|
|
703
|
+
type CodecTypesFromDefinition<Definition> = ExtractCodecTypesFromPack<Definition extends {
|
|
704
|
+
readonly target: infer Target;
|
|
705
|
+
} ? Target : never> & MergeExtensionCodecTypesSafe<DefinitionExtensions<Definition>>;
|
|
706
|
+
type DefinitionTarget<Definition> = Definition extends {
|
|
707
|
+
readonly target: infer Target;
|
|
708
|
+
} ? Target : never;
|
|
709
|
+
type DefinitionModels<Definition> = Definition extends {
|
|
710
|
+
readonly models?: unknown;
|
|
711
|
+
} ? Present<Definition['models']> extends Record<string, unknown> ? Present<Definition['models']> : Record<never, never> : Record<never, never>;
|
|
712
|
+
type DefinitionNamespaces<Definition> = Definition extends {
|
|
713
|
+
readonly namespaces?: infer Names extends readonly string[];
|
|
714
|
+
} ? string[] extends Names ? never : readonly string[] extends Names ? never : Names[number] : never;
|
|
715
|
+
type DefinitionTypes<Definition> = Definition extends {
|
|
716
|
+
readonly types?: unknown;
|
|
717
|
+
} ? Present<Definition['types']> extends Record<string, StorageType> ? Present<Definition['types']> : Record<never, never> : Record<never, never>;
|
|
718
|
+
type DefinitionTableNaming<Definition> = Definition extends {
|
|
719
|
+
readonly naming?: {
|
|
720
|
+
readonly tables?: infer Strategy extends string;
|
|
721
|
+
};
|
|
722
|
+
} ? Strategy : undefined;
|
|
723
|
+
type DefinitionColumnNaming<Definition> = Definition extends {
|
|
724
|
+
readonly naming?: {
|
|
725
|
+
readonly columns?: infer Strategy extends string;
|
|
726
|
+
};
|
|
727
|
+
} ? Strategy : undefined;
|
|
728
|
+
type FirstChar<S extends string> = S extends `${infer First}${string}` ? First : '';
|
|
729
|
+
type CharKind<C extends string> = C extends '' ? 'end' : C extends Lowercase<C> ? C extends Uppercase<C> ? 'other' : 'lower' : 'upper';
|
|
730
|
+
type ShouldInsertSnakeUnderscore<PrevKind extends 'start' | 'lower' | 'upper' | 'other' | 'end', Current extends string, Next extends string> = CharKind<Current> extends 'upper' ? PrevKind extends 'start' ? false : PrevKind extends 'lower' | 'other' ? true : CharKind<Next> extends 'lower' ? true : false : false;
|
|
731
|
+
type SnakeCaseInternal<S extends string, PrevKind extends 'start' | 'lower' | 'upper' | 'other' | 'end' = 'start'> = S extends `${infer Current}${infer Rest}` ? `${ShouldInsertSnakeUnderscore<PrevKind, Current, FirstChar<Rest>> extends true ? '_' : ''}${Lowercase<Current>}${SnakeCaseInternal<Rest, CharKind<Current>>}` : '';
|
|
732
|
+
type SnakeCase<S extends string> = string extends S ? string : SnakeCaseInternal<S>;
|
|
733
|
+
type ApplyNamingType<Name extends string, Strategy extends string | undefined> = string extends Name ? string : Strategy extends 'snake_case' ? SnakeCase<Name> : Name;
|
|
734
|
+
type ModelNames<Definition> = keyof DefinitionModels<Definition> & string;
|
|
735
|
+
type ModelFields<Definition, ModelName extends ModelNames<Definition>> = DefinitionModels<Definition>[ModelName] extends {
|
|
736
|
+
readonly stageOne: {
|
|
737
|
+
readonly fields: Record<string, ScalarFieldBuilder>;
|
|
738
|
+
};
|
|
739
|
+
} ? DefinitionModels<Definition>[ModelName]['stageOne']['fields'] : Record<never, never>;
|
|
740
|
+
type ModelFieldNames<Definition, ModelName extends ModelNames<Definition>> = keyof ModelFields<Definition, ModelName> & string;
|
|
741
|
+
type StagedModelRelations<Definition, ModelName extends ModelNames<Definition>> = DefinitionModels<Definition>[ModelName] extends {
|
|
742
|
+
readonly stageOne: {
|
|
743
|
+
readonly relations: infer R;
|
|
744
|
+
};
|
|
745
|
+
} ? R extends Record<string, unknown> ? R : Record<never, never> : Record<never, never>;
|
|
746
|
+
type StagedModelRelationNames<Definition, ModelName extends ModelNames<Definition>> = keyof StagedModelRelations<Definition, ModelName> & string;
|
|
747
|
+
type ModelFieldState<Definition, ModelName extends ModelNames<Definition>, FieldName extends ModelFieldNames<Definition, ModelName>> = FieldStateOf<ModelFields<Definition, ModelName>[FieldName]>;
|
|
748
|
+
type ModelSql<Definition, ModelName extends ModelNames<Definition>> = DefinitionModels<Definition>[ModelName] extends {
|
|
749
|
+
readonly __sql: infer SqlSpec;
|
|
750
|
+
} ? SqlSpec : undefined;
|
|
751
|
+
type ModelAttributes<Definition, ModelName extends ModelNames<Definition>> = DefinitionModels<Definition>[ModelName] extends {
|
|
752
|
+
readonly __attributes: infer AttributesSpec;
|
|
753
|
+
} ? AttributesSpec : undefined;
|
|
754
|
+
type FieldDescriptorOf<FieldState> = Present<FieldState extends {
|
|
755
|
+
readonly descriptor?: infer Descriptor;
|
|
756
|
+
} ? Descriptor : never>;
|
|
757
|
+
type FieldTypeRefOf<FieldState> = Present<FieldState extends {
|
|
758
|
+
readonly typeRef?: infer TypeRef;
|
|
759
|
+
} ? TypeRef : never>;
|
|
760
|
+
type FieldNullableOf<FieldState> = FieldState extends {
|
|
761
|
+
readonly nullable: infer Nullable extends boolean;
|
|
762
|
+
} ? Nullable : boolean;
|
|
763
|
+
type FieldManyOf<FieldState> = FieldState extends {
|
|
764
|
+
readonly many?: true;
|
|
765
|
+
} ? true : false;
|
|
766
|
+
type FieldColumnOverrideOf<FieldState> = Present<FieldState extends {
|
|
767
|
+
readonly columnName?: infer ColumnName;
|
|
768
|
+
} ? ColumnName : never>;
|
|
769
|
+
type FieldInlineIdSpecOf<FieldState> = Present<FieldState extends {
|
|
770
|
+
readonly id?: infer IdSpec;
|
|
771
|
+
} ? IdSpec : never>;
|
|
772
|
+
type DescriptorCodecId<Descriptor> = Descriptor extends {
|
|
773
|
+
readonly codecId: infer CodecId extends string;
|
|
774
|
+
} ? CodecId : string;
|
|
775
|
+
type DescriptorNativeType<Descriptor> = Descriptor extends {
|
|
776
|
+
readonly nativeType: infer NativeType extends string;
|
|
777
|
+
} ? NativeType : string;
|
|
778
|
+
type DescriptorTypeParams<Descriptor> = Descriptor extends {
|
|
779
|
+
readonly typeParams: infer TypeParams extends Record<string, unknown>;
|
|
780
|
+
} ? TypeParams : undefined;
|
|
781
|
+
type DescriptorTypeRef<Descriptor> = Descriptor extends {
|
|
782
|
+
readonly typeRef: infer TypeRef extends string;
|
|
783
|
+
} ? TypeRef : undefined;
|
|
784
|
+
type LookupNamedStorageTypeKeyByValue<Definition, TypeRef extends StorageType> = { [TypeName in keyof DefinitionTypes<Definition> & string]: [TypeRef] extends [DefinitionTypes<Definition>[TypeName]] ? [DefinitionTypes<Definition>[TypeName]] extends [TypeRef] ? TypeName : never : never; }[keyof DefinitionTypes<Definition> & string];
|
|
785
|
+
type ResolveNamedStorageTypeKey<Definition, TypeRef> = TypeRef extends string ? TypeRef : TypeRef extends StorageType ? [LookupNamedStorageTypeKeyByValue<Definition, TypeRef>] extends [never] ? string : LookupNamedStorageTypeKeyByValue<Definition, TypeRef> : never;
|
|
786
|
+
type ResolveNamedStorageType<Definition, TypeRef> = ResolveNamedStorageTypeKey<Definition, TypeRef> extends (infer TypeName extends string) ? TypeName extends keyof DefinitionTypes<Definition> ? DefinitionTypes<Definition>[TypeName] : StorageTypeInstance : StorageTypeInstance;
|
|
787
|
+
type EnumFieldHandle<FieldState> = [FieldTypeRefOf<FieldState>] extends [never] ? never : FieldTypeRefOf<FieldState> extends EnumTypeHandle ? FieldTypeRefOf<FieldState> : never;
|
|
788
|
+
type EnumHandleDescriptor<Handle> = Handle extends {
|
|
789
|
+
readonly codecId: infer CodecId extends string;
|
|
790
|
+
readonly nativeType: infer NativeType extends string;
|
|
791
|
+
} ? {
|
|
792
|
+
readonly codecId: CodecId;
|
|
793
|
+
readonly nativeType: NativeType;
|
|
794
|
+
} : never;
|
|
795
|
+
type ResolveFieldDescriptor<Definition, FieldState> = [EnumFieldHandle<FieldState>] extends [never] ? [FieldDescriptorOf<FieldState>] extends [never] ? ResolveNamedStorageType<Definition, FieldTypeRefOf<FieldState>> : FieldDescriptorOf<FieldState> : EnumHandleDescriptor<EnumFieldHandle<FieldState>>;
|
|
796
|
+
type ResolveFieldColumnTypeRef<Definition, FieldState> = [EnumFieldHandle<FieldState>] extends [never] ? [FieldTypeRefOf<FieldState>] extends [never] ? DescriptorTypeRef<FieldDescriptorOf<FieldState>> : ResolveNamedStorageTypeKey<Definition, FieldTypeRefOf<FieldState>> : undefined;
|
|
797
|
+
type ResolveFieldColumnTypeParams<Definition, FieldState> = [ResolveFieldColumnTypeRef<Definition, FieldState>] extends [string] ? undefined : DescriptorTypeParams<FieldDescriptorOf<FieldState>>;
|
|
798
|
+
type ModelTableName<Definition, ModelName extends ModelNames<Definition>> = [Present<ModelSql<Definition, ModelName> extends {
|
|
799
|
+
readonly table?: infer TableName;
|
|
800
|
+
} ? TableName : never>] extends [never] ? ApplyNamingType<ModelName, DefinitionTableNaming<Definition>> : Present<ModelSql<Definition, ModelName> extends {
|
|
801
|
+
readonly table?: infer TableName;
|
|
802
|
+
} ? TableName : never> extends (infer ExplicitTableName extends string) ? ExplicitTableName : ApplyNamingType<ModelName, DefinitionTableNaming<Definition>>;
|
|
803
|
+
type ModelColumnName<Definition, ModelName extends ModelNames<Definition>, FieldName extends ModelFieldNames<Definition, ModelName>> = [FieldColumnOverrideOf<ModelFieldState<Definition, ModelName, FieldName>>] extends [never] ? ApplyNamingType<FieldName, DefinitionColumnNaming<Definition>> : FieldColumnOverrideOf<ModelFieldState<Definition, ModelName, FieldName>> extends (infer ExplicitColumnName extends string) ? ExplicitColumnName : ApplyNamingType<FieldName, DefinitionColumnNaming<Definition>>;
|
|
804
|
+
type FieldNamesToColumnNames<Definition, ModelName extends ModelNames<Definition>, FieldNames extends readonly string[]> = FieldNames extends readonly [] ? readonly [] : FieldNames extends readonly [infer First extends ModelFieldNames<Definition, ModelName>, ...infer Rest extends readonly string[]] ? readonly [ModelColumnName<Definition, ModelName, First>, ...FieldNamesToColumnNames<Definition, ModelName, Rest>] : readonly string[];
|
|
805
|
+
type InlineIdFieldName<Definition, ModelName extends ModelNames<Definition>> = { [FieldName in ModelFieldNames<Definition, ModelName>]: [FieldInlineIdSpecOf<ModelFieldState<Definition, ModelName, FieldName>>] extends [never] ? never : FieldName; }[ModelFieldNames<Definition, ModelName>];
|
|
806
|
+
type InlineIdFieldNames<Definition, ModelName extends ModelNames<Definition>> = [InlineIdFieldName<Definition, ModelName>] extends [never] ? undefined : readonly [InlineIdFieldName<Definition, ModelName>];
|
|
807
|
+
type InlineIdName<Definition, ModelName extends ModelNames<Definition>> = { [FieldName in ModelFieldNames<Definition, ModelName>]: FieldInlineIdSpecOf<ModelFieldState<Definition, ModelName, FieldName>> extends {
|
|
808
|
+
readonly name?: infer Name extends string;
|
|
809
|
+
} ? Name : never; }[ModelFieldNames<Definition, ModelName>];
|
|
810
|
+
type AttributeIdFieldNames<Definition, ModelName extends ModelNames<Definition>> = AttributeStageIdFieldNames<ModelAttributes<Definition, ModelName>>;
|
|
811
|
+
type AttributeIdName<Definition, ModelName extends ModelNames<Definition>> = Present<ModelAttributes<Definition, ModelName> extends {
|
|
812
|
+
readonly id?: {
|
|
813
|
+
readonly name?: infer Name extends string;
|
|
814
|
+
};
|
|
815
|
+
} ? Name : never>;
|
|
816
|
+
type ModelIdFieldNames<Definition, ModelName extends ModelNames<Definition>> = [AttributeIdFieldNames<Definition, ModelName>] extends [undefined] ? InlineIdFieldNames<Definition, ModelName> : AttributeIdFieldNames<Definition, ModelName>;
|
|
817
|
+
type ModelIdName<Definition, ModelName extends ModelNames<Definition>> = [AttributeIdName<Definition, ModelName>] extends [never] ? Present<InlineIdName<Definition, ModelName>> : AttributeIdName<Definition, ModelName>;
|
|
818
|
+
type StorageColumn<CodecId extends string, Nullable extends boolean, NativeType extends string, TypeRef extends string | undefined = undefined, TypeParams extends Record<string, unknown> | undefined = undefined, Many extends boolean = false> = {
|
|
819
|
+
readonly nativeType: NativeType;
|
|
820
|
+
readonly codecId: CodecId;
|
|
821
|
+
readonly nullable: Nullable;
|
|
822
|
+
readonly default?: ColumnDefault;
|
|
823
|
+
} & (TypeRef extends string ? {
|
|
824
|
+
readonly typeRef: TypeRef;
|
|
825
|
+
} : Record<never, never>) & (TypeParams extends Record<string, unknown> ? {
|
|
826
|
+
readonly typeParams: TypeParams;
|
|
827
|
+
} : Record<never, never>) & (Many extends true ? {
|
|
828
|
+
readonly many: true;
|
|
829
|
+
} : Record<never, never>);
|
|
830
|
+
type ModelStorageColumn<Definition, ModelName extends ModelNames<Definition>, FieldName extends string> = FieldName extends ModelFieldNames<Definition, ModelName> ? StorageColumn<DescriptorCodecId<ResolveFieldDescriptor<Definition, ModelFieldState<Definition, ModelName, FieldName>>>, FieldNullableOf<ModelFieldState<Definition, ModelName, FieldName>>, DescriptorNativeType<ResolveFieldDescriptor<Definition, ModelFieldState<Definition, ModelName, FieldName>>>, ResolveFieldColumnTypeRef<Definition, ModelFieldState<Definition, ModelName, FieldName>>, ResolveFieldColumnTypeParams<Definition, ModelFieldState<Definition, ModelName, FieldName>>, FieldManyOf<ModelFieldState<Definition, ModelName, FieldName>>> : never;
|
|
831
|
+
type BuiltModels<Definition> = { readonly [ModelName in ModelNames<Definition>]: {
|
|
832
|
+
readonly storage: {
|
|
833
|
+
readonly table: ModelTableName<Definition, ModelName>;
|
|
834
|
+
readonly fields: { readonly [FieldName in ModelFieldNames<Definition, ModelName>]: {
|
|
835
|
+
readonly column: ModelColumnName<Definition, ModelName, FieldName>;
|
|
836
|
+
}; };
|
|
837
|
+
};
|
|
838
|
+
readonly fields: { readonly [FieldName in ModelFieldNames<Definition, ModelName>]: {
|
|
839
|
+
readonly nullable: ModelStorageColumn<Definition, ModelName, FieldName>['nullable'];
|
|
840
|
+
readonly type: {
|
|
841
|
+
readonly kind: 'scalar';
|
|
842
|
+
readonly codecId: ModelStorageColumn<Definition, ModelName, FieldName>['codecId'];
|
|
843
|
+
};
|
|
844
|
+
}; };
|
|
845
|
+
readonly relations: { readonly [RelName in StagedModelRelationNames<Definition, ModelName>]: ContractRelation; };
|
|
846
|
+
}; };
|
|
847
|
+
type BuiltModelColumnMappings<Definition, ModelName extends ModelNames<Definition>> = BuiltModels<Definition>[ModelName]['storage']['fields'];
|
|
848
|
+
type BuiltModelTableName<Definition, ModelName extends ModelNames<Definition>> = BuiltModels<Definition>[ModelName]['storage']['table'];
|
|
849
|
+
type BuiltStorageTableColumns<Definition, ModelName extends ModelNames<Definition>> = { readonly [FieldName in keyof BuiltModelColumnMappings<Definition, ModelName> & string as BuiltModelColumnMappings<Definition, ModelName>[FieldName]['column']]: ModelStorageColumn<Definition, ModelName, FieldName>; };
|
|
850
|
+
type BuiltStorageTables<Definition> = { readonly [ModelName in ModelNames<Definition> as BuiltModelTableName<Definition, ModelName>]: {
|
|
851
|
+
readonly columns: BuiltStorageTableColumns<Definition, ModelName>;
|
|
852
|
+
readonly uniques: ReadonlyArray<{
|
|
853
|
+
readonly columns: readonly string[];
|
|
854
|
+
readonly name?: string;
|
|
855
|
+
}>;
|
|
856
|
+
readonly indexes: ReadonlyArray<Index$1>;
|
|
857
|
+
readonly foreignKeys: ReadonlyArray<{
|
|
858
|
+
readonly source: {
|
|
859
|
+
readonly namespaceId: NamespaceId;
|
|
860
|
+
readonly tableName: string;
|
|
861
|
+
readonly columns: readonly string[];
|
|
862
|
+
};
|
|
863
|
+
readonly target: {
|
|
864
|
+
readonly namespaceId: NamespaceId;
|
|
865
|
+
readonly spaceId?: string;
|
|
866
|
+
readonly tableName: string;
|
|
867
|
+
readonly columns: readonly string[];
|
|
868
|
+
};
|
|
869
|
+
readonly name?: string;
|
|
870
|
+
readonly onDelete?: ReferentialAction;
|
|
871
|
+
readonly onUpdate?: ReferentialAction;
|
|
872
|
+
readonly constraint: boolean;
|
|
873
|
+
readonly index: boolean;
|
|
874
|
+
}>;
|
|
875
|
+
} & (ModelIdFieldNames<Definition, ModelName> extends readonly string[] ? {
|
|
876
|
+
readonly primaryKey: {
|
|
877
|
+
readonly columns: FieldNamesToColumnNames<Definition, ModelName, ModelIdFieldNames<Definition, ModelName>>;
|
|
878
|
+
readonly name?: ModelIdName<Definition, ModelName>;
|
|
879
|
+
};
|
|
880
|
+
} : Record<string, never>); };
|
|
881
|
+
type DefinitionEnums<Definition> = Definition extends {
|
|
882
|
+
readonly enums?: infer E;
|
|
883
|
+
} ? Present<E> extends Record<string, EnumTypeHandle> ? string extends keyof Present<E> ? Record<never, never> : Present<E> : Record<never, never> : Record<never, never>;
|
|
884
|
+
type EnumHandleAccessorType<Handle> = Handle extends EnumTypeHandle<infer _Name, infer Values, infer Names, infer MembersMap> ? {
|
|
885
|
+
readonly values: Values;
|
|
886
|
+
readonly names: Names;
|
|
887
|
+
readonly members: MembersMap;
|
|
888
|
+
has(v: Values[number]): boolean;
|
|
889
|
+
nameOf(v: Values[number]): string | undefined;
|
|
890
|
+
ordinalOf(v: Values[number]): number;
|
|
891
|
+
} : never;
|
|
892
|
+
type BuiltEnumAccessors<Definition> = { readonly [K in keyof DefinitionEnums<Definition>]: EnumHandleAccessorType<DefinitionEnums<Definition>[K]>; };
|
|
893
|
+
type BuiltDocumentScopedTypes<Definition> = { readonly [K in keyof DefinitionTypes<Definition> as DefinitionTypes<Definition>[K] extends StorageTypeInstance ? K : never]: DefinitionTypes<Definition>[K]; };
|
|
894
|
+
type BuiltDomain<Definition> = BuiltDocumentScopedTypes<Definition> extends Record<never, never> ? Record<string, never> : {
|
|
895
|
+
readonly __unbound__: {
|
|
896
|
+
readonly types: BuiltDocumentScopedTypes<Definition>;
|
|
897
|
+
};
|
|
898
|
+
};
|
|
899
|
+
type BuiltDomainNamespace<Definition> = {
|
|
900
|
+
readonly models: BuiltModels<Definition>;
|
|
901
|
+
readonly valueObjects?: Record<string, ContractValueObject>;
|
|
902
|
+
readonly enum?: Record<string, ContractEnum>;
|
|
903
|
+
};
|
|
904
|
+
type DefaultStorageNamespaceId<Definition> = DefinitionTargetId<Definition> extends 'postgres' ? 'public' : '__unbound__';
|
|
905
|
+
type BuiltStorage<Definition> = {
|
|
906
|
+
readonly storageHash: StorageHashBase<string>;
|
|
907
|
+
readonly types?: BuiltDocumentScopedTypes<Definition>;
|
|
908
|
+
readonly namespaces: { readonly [K in DefaultStorageNamespaceId<Definition>]: {
|
|
909
|
+
readonly id: K;
|
|
910
|
+
readonly kind: string;
|
|
911
|
+
readonly entries: {
|
|
912
|
+
readonly table: BuiltStorageTables<Definition>;
|
|
913
|
+
};
|
|
914
|
+
}; } & { readonly [Ns in Exclude<DefinitionNamespaces<Definition>, DefaultStorageNamespaceId<Definition>>]: {
|
|
915
|
+
readonly id: Ns;
|
|
916
|
+
readonly kind: string;
|
|
917
|
+
readonly entries: {
|
|
918
|
+
readonly table: Record<never, never>;
|
|
919
|
+
};
|
|
920
|
+
}; };
|
|
921
|
+
};
|
|
922
|
+
type StorageColumnManyOf<Col> = Col extends {
|
|
923
|
+
readonly many: true;
|
|
924
|
+
} ? true : false;
|
|
925
|
+
type EnumValueUnion<FieldState> = [FieldTypeRefOf<FieldState>] extends [EnumTypeHandle<string, infer Values>] ? readonly unknown[] extends Values ? never : Values[number] : never;
|
|
926
|
+
type DescriptorEntityMembers<Descriptor> = Descriptor extends {
|
|
927
|
+
readonly entityRef: {
|
|
928
|
+
readonly entity: {
|
|
929
|
+
readonly members: infer Members extends readonly string[];
|
|
930
|
+
};
|
|
931
|
+
};
|
|
932
|
+
} ? Members : never;
|
|
933
|
+
type DescriptorValueSetUnion<FieldState> = [FieldDescriptorOf<FieldState>] extends [never] ? never : readonly string[] extends DescriptorEntityMembers<FieldDescriptorOf<FieldState>> ? never : DescriptorEntityMembers<FieldDescriptorOf<FieldState>>[number];
|
|
934
|
+
type CodecChannelType<Definition, ModelName extends ModelNames<Definition>, FieldName extends ModelFieldNames<Definition, ModelName>, Channel extends 'output' | 'input'> = ModelStorageColumn<Definition, ModelName, FieldName>['codecId'] extends (infer Id extends keyof CodecTypesFromDefinition<Definition>) ? CodecTypesFromDefinition<Definition>[Id] extends { readonly [K in Channel]: infer T; } ? StorageColumnManyOf<ModelStorageColumn<Definition, ModelName, FieldName>> extends true ? ReadonlyArray<T> : T : unknown : unknown;
|
|
935
|
+
type FieldValueUnion<FieldState> = [EnumValueUnion<FieldState>] extends [never] ? DescriptorValueSetUnion<FieldState> : EnumValueUnion<FieldState>;
|
|
936
|
+
type FieldChannelType<Definition, ModelName extends ModelNames<Definition>, FieldName extends ModelFieldNames<Definition, ModelName>, Channel extends 'output' | 'input'> = ([FieldValueUnion<ModelFieldState<Definition, ModelName, FieldName>>] extends [never] ? CodecChannelType<Definition, ModelName, FieldName, Channel> : StorageColumnManyOf<ModelStorageColumn<Definition, ModelName, FieldName>> extends true ? ReadonlyArray<FieldValueUnion<ModelFieldState<Definition, ModelName, FieldName>>> : FieldValueUnion<ModelFieldState<Definition, ModelName, FieldName>>) | (FieldNullableOf<ModelFieldState<Definition, ModelName, FieldName>> extends true ? null : never);
|
|
937
|
+
type FieldChannelTypes<Definition, Channel extends 'output' | 'input'> = { readonly [Ns in DefaultStorageNamespaceId<Definition>]: { readonly [ModelName in ModelNames<Definition>]: { readonly [FieldName in ModelFieldNames<Definition, ModelName>]: FieldChannelType<Definition, ModelName, FieldName, Channel>; }; }; };
|
|
938
|
+
type StorageColumnChannelTypes<Definition, Channel extends 'output' | 'input'> = { readonly [Ns in DefaultStorageNamespaceId<Definition>]: { readonly [ModelName in ModelNames<Definition> as BuiltModelTableName<Definition, ModelName>]: { readonly [FieldName in ModelFieldNames<Definition, ModelName> as BuiltModelColumnMappings<Definition, ModelName>[FieldName]['column']]: FieldChannelType<Definition, ModelName, FieldName, Channel>; }; }; };
|
|
939
|
+
type SqlContractResult<Definition> = ContractWithTypeMaps<Omit<Contract<BuiltStorage<Definition>>, 'domain'> & {
|
|
940
|
+
readonly target: DefinitionTargetId<Definition>;
|
|
941
|
+
readonly targetFamily: 'sql';
|
|
942
|
+
} & {
|
|
943
|
+
readonly domain: {
|
|
944
|
+
readonly namespaces: Readonly<Record<string, BuiltDomainNamespace<Definition>>>;
|
|
945
|
+
} & BuiltDomain<Definition>;
|
|
946
|
+
} & {
|
|
947
|
+
readonly extensions: keyof DefinitionExtensions<Definition> extends never ? Record<string, never> : DefinitionExtensions<Definition>;
|
|
948
|
+
readonly capabilities: DerivedCapabilities<Definition>;
|
|
949
|
+
readonly enumAccessors: BuiltEnumAccessors<Definition>;
|
|
950
|
+
}, TypeMaps<CodecTypesFromDefinition<Definition>, Record<string, never>, FieldChannelTypes<Definition, 'output'>, FieldChannelTypes<Definition, 'input'>, StorageColumnChannelTypes<Definition, 'output'>, StorageColumnChannelTypes<Definition, 'input'>>>;
|
|
951
|
+
//#endregion
|
|
952
|
+
//#region src/composed-authoring-helpers.d.ts
|
|
953
|
+
type ExtractTypeNamespaceFromPack<Pack> = ExtractAuthoringNamespaceFromPack<Pack, 'type', Record<never, never>>;
|
|
954
|
+
type ExtractFieldNamespaceFromPack<Pack> = ExtractAuthoringNamespaceFromPack<Pack, 'field', Record<never, never>>;
|
|
955
|
+
type ExtractEntitiesNamespaceFromPack<Pack> = ExtractAuthoringNamespaceFromPack<Pack, 'entityTypes', Record<never, never>>;
|
|
956
|
+
type MergeExtensionTypeNamespaces<Extensions> = MergeExtensionAuthoringNamespaces<Extensions, 'type'>;
|
|
957
|
+
type MergeExtensionFieldNamespaces<Extensions> = MergeExtensionAuthoringNamespaces<Extensions, 'field'>;
|
|
958
|
+
type MergeExtensionEntityNamespaces<Extensions> = MergeExtensionAuthoringNamespaces<Extensions, 'entityTypes'>;
|
|
959
|
+
type StorageTypeFromDescriptor<Descriptor extends AuthoringTypeConstructorDescriptor, Args extends readonly unknown[]> = {
|
|
960
|
+
readonly kind: 'codec-instance';
|
|
961
|
+
readonly codecId: ResolveTemplateValue<Descriptor['output']['codecId'], Args>;
|
|
962
|
+
readonly nativeType: ResolveTemplateValue<Descriptor['output']['nativeType'], Args>;
|
|
963
|
+
} & (Descriptor['output'] extends {
|
|
964
|
+
readonly typeParams: infer TypeParams extends Record<string, unknown>;
|
|
965
|
+
} ? {
|
|
966
|
+
readonly typeParams: ResolveTemplateValue<TypeParams, Args>;
|
|
967
|
+
} : {
|
|
968
|
+
readonly typeParams: Record<never, never>;
|
|
969
|
+
});
|
|
970
|
+
type TypeHelperFunction<Descriptor extends AuthoringTypeConstructorDescriptor> = Descriptor extends {
|
|
971
|
+
readonly args: infer Args extends readonly AuthoringArgumentDescriptor[];
|
|
972
|
+
} ? <const Params extends TupleFromArgumentDescriptors<Args>>(...args: Params) => StorageTypeFromDescriptor<Descriptor, Params> : () => StorageTypeFromDescriptor<Descriptor, readonly []>;
|
|
973
|
+
type TypeHelpersFromNamespace<Namespace> = { readonly [K in keyof Namespace]: Namespace[K] extends AuthoringTypeConstructorDescriptor ? TypeHelperFunction<Namespace[K]> : Namespace[K] extends Record<string, unknown> ? TypeHelpersFromNamespace<Namespace[K]> : never; };
|
|
974
|
+
type CoreFieldHelpers = Pick<typeof field, 'column' | 'generated' | 'namedType'>;
|
|
975
|
+
type MergeAllPackIndexTypes<Family, Target, Extensions> = MergeExtensionIndexTypes<{
|
|
976
|
+
readonly __family: Family;
|
|
977
|
+
readonly __target: Target;
|
|
978
|
+
} & (Extensions extends Record<string, unknown> ? Extensions : Record<never, never>)>;
|
|
979
|
+
type PackAwareModel<IndexTypes extends IndexTypeMap> = {
|
|
980
|
+
<const ModelName extends string, Fields extends Record<string, ScalarFieldBuilder>, Relations extends Record<string, AnyRelationBuilder> = Record<never, never>>(modelName: ModelName, input: {
|
|
981
|
+
readonly fields: Fields;
|
|
982
|
+
readonly relations?: Relations;
|
|
983
|
+
readonly namespace?: string;
|
|
984
|
+
}): ContractModelBuilder<ModelName, Fields, Relations, undefined, undefined, IndexTypes>;
|
|
985
|
+
<Fields extends Record<string, ScalarFieldBuilder>, Relations extends Record<string, AnyRelationBuilder> = Record<never, never>>(input: {
|
|
986
|
+
readonly fields: Fields;
|
|
987
|
+
readonly relations?: Relations;
|
|
988
|
+
readonly namespace?: string;
|
|
989
|
+
}): ContractModelBuilder<undefined, Fields, Relations, undefined, undefined, IndexTypes>;
|
|
990
|
+
};
|
|
991
|
+
type ComposedAuthoringHelpers<Family extends FamilyPackRef<string>, Target extends TargetPackRef<'sql', string>, Extensions extends Record<string, ExtensionPackRef<'sql', string>> | undefined> = EntityHelpersFromNamespace<ExtractEntitiesNamespaceFromPack<Family> & ExtractEntitiesNamespaceFromPack<Target> & MergeExtensionEntityNamespaces<Extensions>> & {
|
|
992
|
+
readonly field: CoreFieldHelpers & FieldHelpersFromNamespace<ExtractFieldNamespaceFromPack<Family> & ExtractFieldNamespaceFromPack<Target> & MergeExtensionFieldNamespaces<Extensions>>;
|
|
993
|
+
readonly model: PackAwareModel<MergeAllPackIndexTypes<Family, Target, Extensions>>;
|
|
994
|
+
readonly rel: typeof rel;
|
|
995
|
+
readonly type: TypeHelpersFromNamespace<ExtractTypeNamespaceFromPack<Family> & ExtractTypeNamespaceFromPack<Target> & MergeExtensionTypeNamespaces<Extensions>>;
|
|
996
|
+
};
|
|
997
|
+
//#endregion
|
|
998
|
+
//#region src/contract-definition.d.ts
|
|
999
|
+
/**
|
|
1000
|
+
* Namespace-scoped pack-entity attachments, the internal build IR carrying
|
|
1001
|
+
* the lowered `entities` handle list: namespace id → entity kind (the
|
|
1002
|
+
* discriminator the target/extension pack registered its
|
|
1003
|
+
* `AuthoringContributions.entityTypes` descriptor under, e.g. `native_enum`)
|
|
1004
|
+
* → entity name → the lowered entity instance. Generic on purpose — neither
|
|
1005
|
+
* the framework nor `contract-ts` names a specific entity kind here; the
|
|
1006
|
+
* shape mirrors `SqlNamespaceInput.entries` (`entries.<kind>[name]`), just
|
|
1007
|
+
* namespace-nested so an attachment can target any declared namespace
|
|
1008
|
+
* (default or named), not only the contract's default namespace. Produced by
|
|
1009
|
+
* the generic entity-handle walk in `buildContractDefinition`; never an
|
|
1010
|
+
* author-facing input.
|
|
1011
|
+
*/
|
|
1012
|
+
type AttachedEntities = Readonly<Record<string, Readonly<Record<string, Readonly<Record<string, unknown>>>>>>;
|
|
1013
|
+
interface FieldNode {
|
|
1014
|
+
readonly fieldName: string;
|
|
1015
|
+
readonly columnName: string;
|
|
1016
|
+
readonly descriptor: ColumnTypeDescriptor;
|
|
1017
|
+
readonly nullable: boolean;
|
|
1018
|
+
readonly default?: ColumnDefault;
|
|
1019
|
+
readonly executionDefaults?: ExecutionMutationDefaultPhases;
|
|
1020
|
+
readonly many?: boolean;
|
|
1021
|
+
/** Present when the field was authored with `field.namedType(enumHandle)`. */
|
|
1022
|
+
readonly enumTypeHandle?: EnumTypeHandle;
|
|
1023
|
+
}
|
|
1024
|
+
interface PrimaryKeyNode {
|
|
1025
|
+
readonly columns: readonly string[];
|
|
1026
|
+
readonly name?: string;
|
|
1027
|
+
}
|
|
1028
|
+
interface UniqueConstraintNode {
|
|
1029
|
+
readonly columns: readonly string[];
|
|
1030
|
+
readonly name?: string;
|
|
1031
|
+
}
|
|
1032
|
+
/** A definition-tree index's element structure — column tuple xor expression. */
|
|
1033
|
+
type IndexNodeElements = {
|
|
1034
|
+
/** Column tuple. */
|
|
1035
|
+
readonly columns: readonly string[];
|
|
1036
|
+
readonly expression?: never;
|
|
1037
|
+
} | {
|
|
1038
|
+
readonly columns?: never;
|
|
1039
|
+
/** Opaque SQL: the entire element list of CREATE INDEX — never parsed. */
|
|
1040
|
+
readonly expression: string;
|
|
1041
|
+
};
|
|
1042
|
+
type IndexNode = IndexNodeElements & AuthoredIndexMethod & {
|
|
1043
|
+
/** Opaque SQL: partial-index predicate (WHERE body, without the keyword). */
|
|
1044
|
+
readonly where: string | undefined;
|
|
1045
|
+
readonly unique: boolean | undefined;
|
|
1046
|
+
/** Exact physical name (`map:`) — adopted verbatim, no wire hash. */
|
|
1047
|
+
readonly map: string | undefined;
|
|
1048
|
+
/** Wire-name prefix (`name:`) — lowers to `<name>_<8hex>`. */
|
|
1049
|
+
readonly name: string | undefined;
|
|
1050
|
+
};
|
|
1051
|
+
interface ForeignKeyNode {
|
|
1052
|
+
readonly columns: readonly string[];
|
|
1053
|
+
readonly references: {
|
|
1054
|
+
readonly model: string;
|
|
1055
|
+
readonly table: string;
|
|
1056
|
+
readonly columns: readonly string[];
|
|
1057
|
+
/**
|
|
1058
|
+
* Namespace coordinate of the referenced table. When omitted the
|
|
1059
|
+
* assembler resolves the coordinate from the referenced model node's
|
|
1060
|
+
* own `namespaceId`; the field exists so authoring paths that already
|
|
1061
|
+
* know the target namespace can stamp it explicitly.
|
|
1062
|
+
*/
|
|
1063
|
+
readonly namespaceId?: string;
|
|
1064
|
+
/**
|
|
1065
|
+
* Contract-space identity of the referenced table. When present, the
|
|
1066
|
+
* table lives in a different contract space (identified by this value)
|
|
1067
|
+
* rather than the current contract. Absent for local FKs.
|
|
1068
|
+
*/
|
|
1069
|
+
readonly spaceId?: string;
|
|
1070
|
+
};
|
|
1071
|
+
readonly name?: string;
|
|
1072
|
+
readonly onDelete?: ReferentialAction;
|
|
1073
|
+
readonly onUpdate?: ReferentialAction;
|
|
1074
|
+
readonly constraint?: boolean;
|
|
1075
|
+
readonly index?: boolean;
|
|
1076
|
+
}
|
|
1077
|
+
interface RelationNode {
|
|
1078
|
+
readonly fieldName: string;
|
|
1079
|
+
readonly toModel: string;
|
|
1080
|
+
readonly toTable: string;
|
|
1081
|
+
/**
|
|
1082
|
+
* Namespace coordinate of the related model. When omitted the assembler
|
|
1083
|
+
* resolves the coordinate from the referenced model node's own
|
|
1084
|
+
* `namespaceId`; the field exists so authoring paths that already know the
|
|
1085
|
+
* target namespace can stamp it explicitly — required to disambiguate a
|
|
1086
|
+
* relation to a model whose bare name also exists in another namespace.
|
|
1087
|
+
*/
|
|
1088
|
+
readonly toNamespaceId?: string;
|
|
1089
|
+
readonly cardinality: '1:1' | '1:N' | 'N:1' | 'N:M';
|
|
1090
|
+
/**
|
|
1091
|
+
* Contract-space identity of the related model. When present, the
|
|
1092
|
+
* related model lives in a different contract space. Absent for local
|
|
1093
|
+
* (same-space) relations.
|
|
1094
|
+
*/
|
|
1095
|
+
readonly spaceId?: string;
|
|
1096
|
+
/**
|
|
1097
|
+
* Namespace coordinate of the related model in the foreign space.
|
|
1098
|
+
* Only set when `spaceId` is present.
|
|
1099
|
+
*/
|
|
1100
|
+
readonly namespaceId?: string;
|
|
1101
|
+
readonly on: {
|
|
1102
|
+
readonly parentTable: string;
|
|
1103
|
+
readonly parentColumns: readonly string[];
|
|
1104
|
+
readonly childTable: string;
|
|
1105
|
+
readonly childColumns: readonly string[];
|
|
1106
|
+
};
|
|
1107
|
+
readonly through?: {
|
|
1108
|
+
readonly table: string;
|
|
1109
|
+
/**
|
|
1110
|
+
* Namespace the junction table lives in. Set from the junction model's
|
|
1111
|
+
* declared namespace at lowering time; junction table names are unique per
|
|
1112
|
+
* namespace, not globally, so this disambiguates a junction whose bare table
|
|
1113
|
+
* name also exists in another namespace. Omitted for a junction in the
|
|
1114
|
+
* default namespace (resolved to the target's default at build time).
|
|
1115
|
+
*/
|
|
1116
|
+
readonly namespaceId?: string;
|
|
1117
|
+
readonly parentColumns: readonly string[];
|
|
1118
|
+
readonly childColumns: readonly string[];
|
|
1119
|
+
};
|
|
1120
|
+
}
|
|
1121
|
+
interface ValueObjectFieldNode {
|
|
1122
|
+
readonly fieldName: string;
|
|
1123
|
+
readonly columnName: string;
|
|
1124
|
+
readonly valueObjectName: string;
|
|
1125
|
+
readonly nullable: boolean;
|
|
1126
|
+
readonly default?: ColumnDefault;
|
|
1127
|
+
readonly executionDefaults?: ExecutionMutationDefaultPhases;
|
|
1128
|
+
readonly many?: boolean;
|
|
1129
|
+
}
|
|
1130
|
+
interface ValueObjectNode {
|
|
1131
|
+
readonly name: string;
|
|
1132
|
+
readonly fields: readonly (FieldNode | ValueObjectFieldNode)[];
|
|
1133
|
+
}
|
|
1134
|
+
interface ModelNode {
|
|
1135
|
+
readonly modelName: string;
|
|
1136
|
+
readonly tableName: string;
|
|
1137
|
+
/**
|
|
1138
|
+
* Resolved namespace coordinate for this model — the key into the
|
|
1139
|
+
* parent contract's `SqlStorage.namespaces` map. Omitting the field
|
|
1140
|
+
* (or setting it to the framework's `UNBOUND_NAMESPACE_ID` sentinel)
|
|
1141
|
+
* selects the late-bound slot, which renders as unqualified DDL.
|
|
1142
|
+
*
|
|
1143
|
+
* Populated by per-target PSL interpreters from the resolved
|
|
1144
|
+
* `namespace { … }` AST bucket; the TS builder also sets it from the
|
|
1145
|
+
* per-model `namespace` field once that authoring surface lands.
|
|
1146
|
+
*/
|
|
1147
|
+
readonly namespaceId?: string;
|
|
1148
|
+
readonly fields: readonly (FieldNode | ValueObjectFieldNode)[];
|
|
1149
|
+
readonly id?: PrimaryKeyNode;
|
|
1150
|
+
readonly uniques?: readonly UniqueConstraintNode[];
|
|
1151
|
+
readonly indexes?: readonly IndexNode[];
|
|
1152
|
+
readonly foreignKeys?: readonly ForeignKeyNode[];
|
|
1153
|
+
readonly relations?: readonly RelationNode[];
|
|
1154
|
+
readonly control?: ControlPolicy;
|
|
1155
|
+
/**
|
|
1156
|
+
* Single-table-inheritance variants share their base model's storage table:
|
|
1157
|
+
* the variant's columns are materialised onto the base `ModelNode`, and this
|
|
1158
|
+
* model contributes a domain model but no storage table of its own. When set,
|
|
1159
|
+
* the assembler builds the domain model but skips creating a (shadow) storage
|
|
1160
|
+
* table and a root for this model — the base owns both.
|
|
1161
|
+
*/
|
|
1162
|
+
readonly sharesBaseTable?: boolean;
|
|
1163
|
+
}
|
|
1164
|
+
interface ContractDefinition {
|
|
1165
|
+
readonly target: TargetPackRef<'sql', string>;
|
|
1166
|
+
readonly defaultControlPolicy?: ControlPolicy;
|
|
1167
|
+
readonly extensions?: Record<string, ExtensionPackRef<'sql', string>>;
|
|
1168
|
+
readonly storageHash?: string;
|
|
1169
|
+
readonly foreignKeyDefaults?: ForeignKeyDefaultsState;
|
|
1170
|
+
readonly storageTypes?: Record<string, StorageTypeInstance>;
|
|
1171
|
+
/**
|
|
1172
|
+
* Declared namespace coordinates for this contract — populates
|
|
1173
|
+
* `SqlStorage.namespaces` together with `createNamespace`.
|
|
1174
|
+
*/
|
|
1175
|
+
readonly namespaces?: readonly string[];
|
|
1176
|
+
/**
|
|
1177
|
+
* Authoring warnings collected by the definition producer before the
|
|
1178
|
+
* build runs (the PSL interpreter's entity factories run ahead of
|
|
1179
|
+
* `buildSqlContractFromDefinition`); seeds the build's single per-build
|
|
1180
|
+
* flush. Required key: a producer with nothing collected states
|
|
1181
|
+
* `undefined` explicitly.
|
|
1182
|
+
*/
|
|
1183
|
+
readonly warnings: readonly AuthoringWarning[] | undefined;
|
|
1184
|
+
/** Target-supplied factory that materialises a `SqlNamespaceBase` concretion for a declared namespace coordinate. */
|
|
1185
|
+
readonly createNamespace: (input: SqlNamespaceInput) => SqlNamespaceBase;
|
|
1186
|
+
readonly models: readonly ModelNode[];
|
|
1187
|
+
readonly valueObjects?: readonly ValueObjectNode[];
|
|
1188
|
+
/**
|
|
1189
|
+
* Domain enum handles authored via `enumType()`. Each entry lowers to a
|
|
1190
|
+
* domain `enum` entry and a storage `valueSet` entry in the contract's
|
|
1191
|
+
* default namespace.
|
|
1192
|
+
*/
|
|
1193
|
+
readonly enums?: Record<string, EnumTypeHandle>;
|
|
1194
|
+
/**
|
|
1195
|
+
* Pack-entity attachments lowered from the `entities` handle list, keyed by
|
|
1196
|
+
* namespace then entity kind then name. Each entity lands in
|
|
1197
|
+
* `storage.namespaces[ns].entries.<kind>`; when the registered entity-type
|
|
1198
|
+
* descriptor's factory output implements the
|
|
1199
|
+
* `SqlValueSetDerivingEntityTypeOutput.deriveValueSet` hook, the derived
|
|
1200
|
+
* value-set also folds into `entries.valueSet`, mirroring how `enums` flows
|
|
1201
|
+
* there. Internal build IR — populated by `buildContractDefinition`, not an
|
|
1202
|
+
* author input.
|
|
1203
|
+
*/
|
|
1204
|
+
readonly attachedEntities?: AttachedEntities;
|
|
1205
|
+
}
|
|
1206
|
+
//#endregion
|
|
1207
|
+
//#region src/build-contract.d.ts
|
|
1208
|
+
declare function buildSqlContractFromDefinition(definition: ContractDefinition, codecLookup?: CodecLookup): Contract<SqlStorage>;
|
|
1209
|
+
//#endregion
|
|
1210
|
+
//#region src/contract-builder.d.ts
|
|
1211
|
+
type ModelLike = {
|
|
1212
|
+
readonly stageOne: {
|
|
1213
|
+
readonly modelName?: string;
|
|
1214
|
+
readonly namespace?: string;
|
|
1215
|
+
readonly fields: Record<string, ScalarFieldBuilder>;
|
|
1216
|
+
readonly relations: Record<string, RelationBuilder<RelationState>>;
|
|
1217
|
+
};
|
|
1218
|
+
readonly __attributes: ModelAttributesSpec | undefined;
|
|
1219
|
+
readonly __sql: SqlStageSpec | undefined;
|
|
1220
|
+
buildAttributesSpec(): ModelAttributesSpec | undefined;
|
|
1221
|
+
buildSqlSpec(): SqlStageSpec | undefined;
|
|
1222
|
+
};
|
|
1223
|
+
type ContractDefinition$1<Family extends FamilyPackRef<string>, Target extends TargetPackRef<'sql', string>, Types extends Record<string, StorageTypeInstance>, Models extends Record<string, ModelLike>, Extensions extends Record<string, ExtensionPackRef<'sql', string>> | undefined, Naming extends ContractInput['naming'] | undefined, StorageHash extends string | undefined, ForeignKeyDefaults extends ForeignKeyDefaultsState | undefined, Namespaces extends readonly string[] | undefined = undefined, Enums extends Record<string, EnumTypeHandle> = Record<string, EnumTypeHandle>> = {
|
|
1224
|
+
readonly family: Family;
|
|
1225
|
+
readonly target: Target;
|
|
1226
|
+
readonly extensions?: Extensions;
|
|
1227
|
+
readonly naming?: Naming;
|
|
1228
|
+
readonly storageHash?: StorageHash;
|
|
1229
|
+
readonly foreignKeyDefaults?: ForeignKeyDefaults;
|
|
1230
|
+
readonly defaultControlPolicy?: ControlPolicy;
|
|
1231
|
+
readonly namespaces?: Namespaces;
|
|
1232
|
+
readonly createNamespace: (input: SqlNamespaceInput) => SqlNamespaceBase;
|
|
1233
|
+
readonly types?: Types;
|
|
1234
|
+
readonly models?: Models;
|
|
1235
|
+
readonly codecLookup?: CodecLookup;
|
|
1236
|
+
readonly enums?: Enums;
|
|
1237
|
+
readonly entities?: readonly PackEntityHandle[];
|
|
1238
|
+
};
|
|
1239
|
+
type ContractScaffold<Family extends FamilyPackRef<string>, Target extends TargetPackRef<'sql', string>, Extensions extends Record<string, ExtensionPackRef<'sql', string>> | undefined, Naming extends ContractInput['naming'] | undefined, StorageHash extends string | undefined, ForeignKeyDefaults extends ForeignKeyDefaultsState | undefined, Namespaces extends readonly string[] | undefined = undefined, Enums extends Record<string, EnumTypeHandle> = Record<string, EnumTypeHandle>> = {
|
|
1240
|
+
readonly family: Family;
|
|
1241
|
+
readonly target: Target;
|
|
1242
|
+
readonly extensions?: Extensions;
|
|
1243
|
+
readonly naming?: Naming;
|
|
1244
|
+
readonly storageHash?: StorageHash;
|
|
1245
|
+
readonly foreignKeyDefaults?: ForeignKeyDefaults;
|
|
1246
|
+
readonly defaultControlPolicy?: ControlPolicy;
|
|
1247
|
+
readonly namespaces?: Namespaces;
|
|
1248
|
+
readonly createNamespace: (input: SqlNamespaceInput) => SqlNamespaceBase;
|
|
1249
|
+
readonly types?: never;
|
|
1250
|
+
readonly models?: never;
|
|
1251
|
+
readonly codecLookup?: CodecLookup;
|
|
1252
|
+
readonly enums?: Enums;
|
|
1253
|
+
readonly entities?: readonly PackEntityHandle[];
|
|
1254
|
+
};
|
|
1255
|
+
type ContractFactory<Family extends FamilyPackRef<string>, Target extends TargetPackRef<'sql', string>, Types extends Record<string, StorageTypeInstance>, Models extends Record<string, ModelLike>, Extensions extends Record<string, ExtensionPackRef<'sql', string>> | undefined, Enums extends Record<string, EnumTypeHandle> = Record<string, EnumTypeHandle>> = (helpers: ComposedAuthoringHelpers<Family, Target, Extensions>) => {
|
|
1256
|
+
readonly types?: Types;
|
|
1257
|
+
readonly models?: Models;
|
|
1258
|
+
readonly enums?: Enums;
|
|
1259
|
+
readonly entities?: readonly PackEntityHandle[];
|
|
1260
|
+
};
|
|
1261
|
+
type BoundDefinitionInput<Types extends Record<string, StorageTypeInstance> = Record<never, never>, Models extends Record<string, ModelLike> = Record<never, never>, Extensions extends Record<string, ExtensionPackRef<'sql', string>> | undefined = undefined, Naming extends ContractInput['naming'] | undefined = undefined, StorageHash extends string | undefined = undefined, ForeignKeyDefaults extends ForeignKeyDefaultsState | undefined = undefined, Namespaces extends readonly string[] | undefined = undefined> = {
|
|
1262
|
+
readonly extensions?: Extensions;
|
|
1263
|
+
readonly naming?: Naming;
|
|
1264
|
+
readonly storageHash?: StorageHash;
|
|
1265
|
+
readonly foreignKeyDefaults?: ForeignKeyDefaults;
|
|
1266
|
+
readonly defaultControlPolicy?: ControlPolicy;
|
|
1267
|
+
readonly namespaces?: Namespaces;
|
|
1268
|
+
readonly createNamespace: (input: SqlNamespaceInput) => SqlNamespaceBase;
|
|
1269
|
+
readonly types?: Types;
|
|
1270
|
+
readonly models?: Models;
|
|
1271
|
+
readonly codecLookup?: CodecLookup;
|
|
1272
|
+
readonly enums?: Record<string, EnumTypeHandle>;
|
|
1273
|
+
readonly entities?: readonly PackEntityHandle[];
|
|
1274
|
+
};
|
|
1275
|
+
type LiteralEnums<E extends Record<string, EnumTypeHandle>> = string extends keyof E ? Record<never, never> : E;
|
|
1276
|
+
type MergeEnums<ScaffoldEnums extends Record<string, EnumTypeHandle>, FactoryEnums extends Record<string, EnumTypeHandle>> = LiteralEnums<ScaffoldEnums> & LiteralEnums<FactoryEnums>;
|
|
1277
|
+
type WithFamilyTarget<Input, F extends FamilyPackRef<string>, T extends TargetPackRef<'sql', string>> = Input & {
|
|
1278
|
+
readonly family: F;
|
|
1279
|
+
readonly target: T;
|
|
1280
|
+
};
|
|
1281
|
+
/**
|
|
1282
|
+
* Shared builder that assembles a SqlContract with pre-bound family and target.
|
|
1283
|
+
* Extension wrappers keep their own public overloads and delegate their impl body here;
|
|
1284
|
+
* this is a plain overloaded function (not a factory returning an overloaded function)
|
|
1285
|
+
* so no overloaded-function-return cast is needed.
|
|
1286
|
+
*
|
|
1287
|
+
* Overload 1: definition form (no factory).
|
|
1288
|
+
*/
|
|
1289
|
+
declare function buildBoundContract<const F extends FamilyPackRef<string>, const T extends TargetPackRef<'sql', string>, const Definition extends BoundDefinitionInput<Record<string, StorageTypeInstance>, Record<string, ModelLike>, Record<string, ExtensionPackRef<'sql', string>> | undefined, ContractInput['naming'] | undefined, string | undefined, ForeignKeyDefaultsState | undefined, readonly string[] | undefined>>(family: F, target: T, definition: Definition, factory?: undefined): SqlContractResult<WithFamilyTarget<Definition, F, T>>;
|
|
1290
|
+
/**
|
|
1291
|
+
* Overload 2: factory form.
|
|
1292
|
+
*/
|
|
1293
|
+
declare function buildBoundContract<const F extends FamilyPackRef<string>, const T extends TargetPackRef<'sql', string>, const Definition extends BoundDefinitionInput<Record<string, StorageTypeInstance>, Record<string, ModelLike>, Record<string, ExtensionPackRef<'sql', string>> | undefined, ContractInput['naming'] | undefined, string | undefined, ForeignKeyDefaultsState | undefined, readonly string[] | undefined>, const Built extends {
|
|
1294
|
+
readonly types?: Record<string, StorageTypeInstance>;
|
|
1295
|
+
readonly models?: Record<string, ModelLike>;
|
|
1296
|
+
readonly enums?: Record<string, EnumTypeHandle>;
|
|
1297
|
+
readonly entities?: readonly PackEntityHandle[];
|
|
1298
|
+
}>(family: F, target: T, definition: Definition, factory: (helpers: ComposedAuthoringHelpers<F, T, NonNullable<Definition['extensions']>>) => Built): SqlContractResult<WithFamilyTarget<Definition & Built, F, T>>;
|
|
1299
|
+
declare function defineContract<const Family extends FamilyPackRef<string>, const Target extends TargetPackRef<'sql', string>, const Types extends Record<string, StorageTypeInstance> = Record<never, never>, const Models extends Record<string, ModelLike> = Record<never, never>, const Extensions extends Record<string, ExtensionPackRef<'sql', string>> | undefined = undefined, const Naming extends ContractInput['naming'] | undefined = undefined, const StorageHash extends string | undefined = undefined, const ForeignKeyDefaults extends ForeignKeyDefaultsState | undefined = undefined, const Namespaces extends readonly string[] | undefined = undefined, const Enums extends Record<string, EnumTypeHandle> = Record<string, EnumTypeHandle>>(definition: ContractDefinition$1<Family, Target, Types, Models, Extensions, Naming, StorageHash, ForeignKeyDefaults, Namespaces, Enums>): SqlContractResult<ContractDefinition$1<Family, Target, Types, Models, Extensions, Naming, StorageHash, ForeignKeyDefaults, Namespaces, Enums>>;
|
|
1300
|
+
declare function defineContract<const Family extends FamilyPackRef<string>, const Target extends TargetPackRef<'sql', string>, const Types extends Record<string, StorageTypeInstance> = Record<never, never>, const Models extends Record<string, ModelLike> = Record<never, never>, const Extensions extends Record<string, ExtensionPackRef<'sql', string>> | undefined = undefined, const Naming extends ContractInput['naming'] | undefined = undefined, const StorageHash extends string | undefined = undefined, const ForeignKeyDefaults extends ForeignKeyDefaultsState | undefined = undefined, const Namespaces extends readonly string[] | undefined = undefined, const ScaffoldEnums extends Record<string, EnumTypeHandle> = Record<string, EnumTypeHandle>, const FactoryEnums extends Record<string, EnumTypeHandle> = Record<string, EnumTypeHandle>>(definition: ContractScaffold<Family, Target, Extensions, Naming, StorageHash, ForeignKeyDefaults, Namespaces, ScaffoldEnums>, factory: ContractFactory<Family, Target, Types, Models, Extensions, FactoryEnums>): SqlContractResult<ContractDefinition$1<Family, Target, Types, Models, Extensions, Naming, StorageHash, ForeignKeyDefaults, Namespaces, MergeEnums<ScaffoldEnums, FactoryEnums>>>;
|
|
1301
|
+
//#endregion
|
|
1302
|
+
//#region src/contract-lowering.d.ts
|
|
1303
|
+
declare function buildContractDefinition(definition: ContractInput): ContractDefinition;
|
|
1304
|
+
//#endregion
|
|
1305
|
+
export { field as A, bindEnumType as C, defineContract as D, buildSqlContractFromDefinition as E, model as M, rel as N, enumType as O, UniqueConstraintNode as S, buildContractDefinition as T, ModelNode as _, ComposedAuthoringHelpers as a, ScalarFieldBuilder as b, ContractModelBuilder as c, ExtractCodecTypesFromPack as d, FieldNode as f, ModelLike as g, MergeEnums as h, CodecTypeMap as i, member as j, extensionModel as k, EnumMember as l, IndexNode as m, BoundEnumType as n, ContractDefinition as o, ForeignKeyNode as p, CodecInput as r, ContractInput as s, AttachedEntities as t, EnumTypeHandle as u, PrimaryKeyNode as v, buildBoundContract as w, TargetFieldRef as x, RelationNode as y };
|
|
1306
|
+
//# sourceMappingURL=contract-builder-MvJJrQ-5.d.mts.map
|