@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,688 @@
|
|
|
1
|
+
import { n as SqlObjectNaming } from "./naming-jLgdauLi-C84G_UHi.mjs";
|
|
2
|
+
import { IRNodeBase } from "@prisma/orm-framework/components/ir";
|
|
3
|
+
import { ColumnDefault } from "@prisma/orm-framework/contract/types";
|
|
4
|
+
import { CodecRef } from "@prisma/orm-framework/components/codec";
|
|
5
|
+
import { DiffSubjectGranularity, DiffableNode, SchemaNodeRef } from "@prisma/orm-framework/components/control";
|
|
6
|
+
//#region ../../../2-sql/1-core/schema-ir/dist/types-CvbBw1Jo.d.mts
|
|
7
|
+
//#region src/ir/sql-schema-ir-node.d.ts
|
|
8
|
+
/**
|
|
9
|
+
* SQL Schema IR node base. Carries the family-level
|
|
10
|
+
* `kind = 'sql-schema-ir'` discriminator and inherits the framework's
|
|
11
|
+
* `freezeNode` affordance.
|
|
12
|
+
*
|
|
13
|
+
* SQL Schema IR represents the actual database state as discovered by
|
|
14
|
+
* introspection (the parallel to SQL Contract IR, which represents the
|
|
15
|
+
* desired state).
|
|
16
|
+
*
|
|
17
|
+
* The discriminator is installed as a non-enumerable own property,
|
|
18
|
+
* matching the SqlNode pattern. This keeps `JSON.stringify(node)`
|
|
19
|
+
* canonical (no `kind` field), keeps `toEqual({...})` test assertions
|
|
20
|
+
* against pre-lift flat shapes passing, and keeps `node.kind` readable
|
|
21
|
+
* for dispatch.
|
|
22
|
+
*
|
|
23
|
+
* Both `kind` and `nodeKind` are required: every concrete leaf is a node
|
|
24
|
+
* the generic differ can pair and compare, so every leaf must declare which
|
|
25
|
+
* node it is. `nodeKind` has no default here — every direct subclass sets its
|
|
26
|
+
* own literal value (the relational leaves via `RelationalSchemaNodeKind`,
|
|
27
|
+
* target concretions via their own vocabulary, e.g. `PostgresSchemaNodeKind`).
|
|
28
|
+
*/
|
|
29
|
+
declare abstract class SqlSchemaIRNode extends IRNodeBase {
|
|
30
|
+
readonly kind: string;
|
|
31
|
+
/**
|
|
32
|
+
* Enumerable discriminant identifying which node this is (column / primary
|
|
33
|
+
* key / foreign key / unique / index / check / database / namespace /
|
|
34
|
+
* table / policy / role / …). Concretions set a unique value; the
|
|
35
|
+
* `.is`/`.assert` guards compare against it. Unlike `kind`, it is
|
|
36
|
+
* enumerable, so it survives a spread that flattens a node into a plain
|
|
37
|
+
* object.
|
|
38
|
+
*/
|
|
39
|
+
abstract readonly nodeKind: string;
|
|
40
|
+
constructor();
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Asserts `node` matches `predicate`, narrowing its type to `T`. The one
|
|
44
|
+
* shared implementation every node class's `static assert` and `isEqualTo`
|
|
45
|
+
* reach for, instead of each hand-writing its own throw: the message names
|
|
46
|
+
* the class the caller expected.
|
|
47
|
+
*/
|
|
48
|
+
declare function assertNode<T extends SqlSchemaIRNode>(node: SqlSchemaIRNode | undefined, className: string, predicate: (node: SqlSchemaIRNode) => node is T): asserts node is T;
|
|
49
|
+
/**
|
|
50
|
+
* Defines a non-enumerable own property, the same treatment `kind` gets
|
|
51
|
+
* above: a derivation-time render-support field stays out of
|
|
52
|
+
* `JSON.stringify`, `toEqual({...})` structural assertions, and spreads,
|
|
53
|
+
* while remaining directly readable (`node.field`) for the one consumer
|
|
54
|
+
* that resolves it at plan time. A no-op when `value` is `undefined` — the
|
|
55
|
+
* property is simply absent, matching every other optional field on these
|
|
56
|
+
* nodes.
|
|
57
|
+
*/
|
|
58
|
+
declare function defineNonEnumerable<T extends object>(target: T, key: string, value: unknown): void;
|
|
59
|
+
//#endregion
|
|
60
|
+
//#region src/ir/primary-key.d.ts
|
|
61
|
+
interface PrimaryKeyInput {
|
|
62
|
+
readonly columns: readonly string[];
|
|
63
|
+
readonly name?: string;
|
|
64
|
+
/**
|
|
65
|
+
* The key's own column nodes, as root-anchored chains. The derivation
|
|
66
|
+
* stamps them so the primary key is dropped before the columns it is built
|
|
67
|
+
* on. Never compared by `isEqualTo`.
|
|
68
|
+
*/
|
|
69
|
+
readonly dependsOn?: readonly SchemaNodeRef[];
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Primary-key Schema IR node. Mirrors the Contract IR `PrimaryKey`
|
|
73
|
+
* shape (same `columns` + optional `name`) so verification can compare
|
|
74
|
+
* intent and actual structurally. Defined here independently to avoid
|
|
75
|
+
* a sql-schema-ir -> sql-contract dependency.
|
|
76
|
+
*
|
|
77
|
+
* Implements `DiffableNode` so a primary key is directly a table's diff-tree
|
|
78
|
+
* child. `id` is a fixed sentinel — a table has at most one primary key, so
|
|
79
|
+
* there is never a sibling to disambiguate against. `isEqualTo` compares the
|
|
80
|
+
* column tuple; the PK's own `name` is a database-assigned label with no
|
|
81
|
+
* semantic weight, so it is not compared (mirrors the policy node's
|
|
82
|
+
* name-insensitivity to non-identifying detail).
|
|
83
|
+
*/
|
|
84
|
+
declare class PrimaryKey extends SqlSchemaIRNode implements DiffableNode {
|
|
85
|
+
readonly nodeKind: "sql-primary-key";
|
|
86
|
+
readonly columns: readonly string[];
|
|
87
|
+
readonly name?: string;
|
|
88
|
+
/** See {@link PrimaryKeyInput.dependsOn}. Non-enumerable so it stays out of JSON and structural equality, matching `SqlColumnIR.codecRef`. */
|
|
89
|
+
readonly dependsOn?: readonly SchemaNodeRef[];
|
|
90
|
+
constructor(input: PrimaryKeyInput);
|
|
91
|
+
get id(): string;
|
|
92
|
+
children(): readonly DiffableNode[];
|
|
93
|
+
static is(node: SqlSchemaIRNode): node is PrimaryKey;
|
|
94
|
+
isEqualTo(other: DiffableNode): boolean;
|
|
95
|
+
}
|
|
96
|
+
//#endregion
|
|
97
|
+
//#region src/ir/schema-node-kinds.d.ts
|
|
98
|
+
/**
|
|
99
|
+
* The `nodeKind` discriminant for each relational schema-diff leaf node.
|
|
100
|
+
* Each node carries a unique value; the differ pairs siblings by `id`, and
|
|
101
|
+
* these kinds distinguish the node types that appear as `PostgresTableSchemaNode`
|
|
102
|
+
* children (columns, primary key, foreign keys, uniques, indexes, checks) from
|
|
103
|
+
* each other and from the RLS policy/role kinds a target defines separately.
|
|
104
|
+
*/
|
|
105
|
+
declare const RelationalSchemaNodeKind: {
|
|
106
|
+
readonly schema: "sql-schema";
|
|
107
|
+
readonly table: "sql-table";
|
|
108
|
+
readonly column: "sql-column";
|
|
109
|
+
readonly columnDefault: "sql-column-default";
|
|
110
|
+
readonly primaryKey: "sql-primary-key";
|
|
111
|
+
readonly foreignKey: "sql-foreign-key";
|
|
112
|
+
readonly unique: "sql-unique";
|
|
113
|
+
readonly index: "sql-index";
|
|
114
|
+
readonly check: "sql-check-constraint";
|
|
115
|
+
};
|
|
116
|
+
type RelationalSchemaNodeKind = (typeof RelationalSchemaNodeKind)[keyof typeof RelationalSchemaNodeKind];
|
|
117
|
+
/**
|
|
118
|
+
* Looks up the subject granularity for a relational `nodeKind`. Throws for a
|
|
119
|
+
* `nodeKind` outside this map (a target-specific kind, e.g. Postgres's
|
|
120
|
+
* namespace/table/policy/role) — those map their own kinds directly rather
|
|
121
|
+
* than through this family-level map.
|
|
122
|
+
*/
|
|
123
|
+
declare function relationalNodeGranularity(nodeKind: string): DiffSubjectGranularity;
|
|
124
|
+
/**
|
|
125
|
+
* Looks up the storage `entityKind` for a relational `nodeKind` — sibling of
|
|
126
|
+
* {@link relationalNodeGranularity}, resolved by `nodeKind` equality against
|
|
127
|
+
* {@link RELATIONAL_NODE_ENTITY_KIND}. `undefined` for a target-specific kind
|
|
128
|
+
* (targets map their own kinds directly) or a relational kind with no entity
|
|
129
|
+
* of its own.
|
|
130
|
+
*/
|
|
131
|
+
declare function relationalNodeEntityKind(nodeKind: string): string | undefined;
|
|
132
|
+
//#endregion
|
|
133
|
+
//#region src/ir/sql-check-constraint-ir.d.ts
|
|
134
|
+
interface SqlCheckConstraintIRInput {
|
|
135
|
+
/** Constraint name as stored in the database catalog. */
|
|
136
|
+
readonly name: string;
|
|
137
|
+
/** Column the check restricts. */
|
|
138
|
+
readonly column: string;
|
|
139
|
+
/** Permitted values the column must be IN. */
|
|
140
|
+
readonly permittedValues: readonly string[];
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Schema IR node for a table-level check constraint that restricts a
|
|
144
|
+
* column to a set of permitted values (an enum-style `IN (...)` check).
|
|
145
|
+
*
|
|
146
|
+
* Carries the **resolved values** rather than a raw SQL predicate so
|
|
147
|
+
* callers can compare value-sets without parsing SQL.
|
|
148
|
+
*
|
|
149
|
+
* Implements `DiffableNode` so a check constraint is directly a table's
|
|
150
|
+
* diff-tree child: `id` is the constraint name. `isEqualTo` compares
|
|
151
|
+
* `column` and the permitted-value set (order-insensitive — the database
|
|
152
|
+
* does not guarantee `IN (...)` ordering).
|
|
153
|
+
*/
|
|
154
|
+
declare class SqlCheckConstraintIR extends SqlSchemaIRNode implements DiffableNode {
|
|
155
|
+
readonly nodeKind: "sql-check-constraint";
|
|
156
|
+
readonly name: string;
|
|
157
|
+
readonly column: string;
|
|
158
|
+
readonly permittedValues: readonly string[];
|
|
159
|
+
constructor(input: SqlCheckConstraintIRInput);
|
|
160
|
+
get id(): string;
|
|
161
|
+
children(): readonly DiffableNode[];
|
|
162
|
+
static is(node: SqlSchemaIRNode): node is SqlCheckConstraintIR;
|
|
163
|
+
/**
|
|
164
|
+
* Compares the permitted-value sets only (unordered), matching the
|
|
165
|
+
* relational walk's `verifyCheckConstraints`: two checks pairing by name
|
|
166
|
+
* compare their value sets — the `column` field is descriptive, not part
|
|
167
|
+
* of the comparison, so a name-paired check with equal values verifies
|
|
168
|
+
* regardless of which column carries it.
|
|
169
|
+
*/
|
|
170
|
+
isEqualTo(other: DiffableNode): boolean;
|
|
171
|
+
}
|
|
172
|
+
//#endregion
|
|
173
|
+
//#region src/ir/sql-column-default-ir.d.ts
|
|
174
|
+
interface SqlColumnDefaultIRInput {
|
|
175
|
+
/** Structured resolved default (contract-declared or normalizer-parsed). */
|
|
176
|
+
readonly resolved?: ColumnDefault;
|
|
177
|
+
/** Raw database default expression, when known (introspected side). */
|
|
178
|
+
readonly raw?: string;
|
|
179
|
+
/**
|
|
180
|
+
* Native-type context for temporal literal normalization — the owning
|
|
181
|
+
* column's resolved native type.
|
|
182
|
+
*/
|
|
183
|
+
readonly nativeTypeContext?: string;
|
|
184
|
+
/**
|
|
185
|
+
* The owning column's array-ness, threaded through so the planner's
|
|
186
|
+
* set-default op-builder can render an array-literal default (e.g.
|
|
187
|
+
* `ARRAY[...]`) the same way the pre-`plan(start, end)` op-path did. See
|
|
188
|
+
* {@link import('./sql-column-ir').SqlColumnIRInput.many}.
|
|
189
|
+
*/
|
|
190
|
+
readonly many?: boolean;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Schema-diff node for a column's default value. The default is the one
|
|
194
|
+
* column attribute with an extra/missing/drift lifecycle of its own, so it
|
|
195
|
+
* is a child node of the column rather than a compared attribute: an
|
|
196
|
+
* undeclared live default surfaces as `not-expected`, a declared default the
|
|
197
|
+
* database lacks as `not-found`, and a divergent value as `not-equal` — the
|
|
198
|
+
* three reasons cover the legacy `extra_default` / `default_missing` /
|
|
199
|
+
* `default_mismatch` vocabulary with no attribute inspection.
|
|
200
|
+
*
|
|
201
|
+
* `id` is a fixed sentinel — a column has at most one default. Built
|
|
202
|
+
* transiently by `SqlColumnIR.children()` from the column's own fields;
|
|
203
|
+
* never constructed by derivation or introspection directly.
|
|
204
|
+
*/
|
|
205
|
+
declare class SqlColumnDefaultIR extends SqlSchemaIRNode implements DiffableNode {
|
|
206
|
+
readonly nodeKind: "sql-column-default";
|
|
207
|
+
readonly resolved?: ColumnDefault;
|
|
208
|
+
readonly raw?: string;
|
|
209
|
+
readonly nativeTypeContext?: string;
|
|
210
|
+
/** See {@link SqlColumnDefaultIRInput.many}. Non-enumerable so it stays out of JSON and structural equality. */
|
|
211
|
+
readonly many?: boolean;
|
|
212
|
+
constructor(input: SqlColumnDefaultIRInput);
|
|
213
|
+
get id(): string;
|
|
214
|
+
children(): readonly DiffableNode[];
|
|
215
|
+
static is(node: SqlSchemaIRNode): node is SqlColumnDefaultIR;
|
|
216
|
+
/**
|
|
217
|
+
* Structured comparison with `this` as the expected side: both sides
|
|
218
|
+
* resolved compare per the relational walk's `columnDefaultsEqual`
|
|
219
|
+
* semantics; a declared expected default against an unparseable actual
|
|
220
|
+
* (raw present, no resolved parse) is a mismatch; two raw-only nodes fall
|
|
221
|
+
* back to raw string equality.
|
|
222
|
+
*/
|
|
223
|
+
isEqualTo(other: DiffableNode): boolean;
|
|
224
|
+
}
|
|
225
|
+
//#endregion
|
|
226
|
+
//#region src/ir/sql-column-ir.d.ts
|
|
227
|
+
/**
|
|
228
|
+
* Namespaced annotations for extensibility. Each namespace
|
|
229
|
+
* (e.g. `pg`, `pgvector`) owns its annotations subtree.
|
|
230
|
+
*/
|
|
231
|
+
type SqlAnnotations = {
|
|
232
|
+
readonly [namespace: string]: unknown;
|
|
233
|
+
};
|
|
234
|
+
interface SqlColumnIRInput {
|
|
235
|
+
readonly name: string;
|
|
236
|
+
readonly nativeType: string;
|
|
237
|
+
readonly nullable: boolean;
|
|
238
|
+
/** Raw database default expression (e.g. `'hello'::text`, `nextval('seq')`). */
|
|
239
|
+
readonly default?: string;
|
|
240
|
+
readonly annotations?: SqlAnnotations;
|
|
241
|
+
/** True when the column is a native array (e.g. `text[]`, `int4[]`). The `nativeType` carries the element type only (e.g. `text`, `int4`). */
|
|
242
|
+
readonly many?: boolean;
|
|
243
|
+
/**
|
|
244
|
+
* Fully resolved native type, comparable across the two diff sides:
|
|
245
|
+
* the contract-derived side stamps the codec-expanded type (typeRef
|
|
246
|
+
* resolved, parameterized types expanded, `[]` appended for arrays);
|
|
247
|
+
* the introspected side stamps the target-normalized type with the same
|
|
248
|
+
* `[]` convention. Stamped at construction by derivation/introspection;
|
|
249
|
+
* absent on raw hand-built nodes.
|
|
250
|
+
*/
|
|
251
|
+
readonly resolvedNativeType?: string;
|
|
252
|
+
/**
|
|
253
|
+
* Structured default, comparable across the two diff sides: the
|
|
254
|
+
* contract-derived side stamps the contract's `ColumnDefault`; the
|
|
255
|
+
* introspected side stamps the target default-normalizer's parse of the
|
|
256
|
+
* raw expression. Absent when the column declares no default, or when
|
|
257
|
+
* the introspected raw default could not be parsed.
|
|
258
|
+
*/
|
|
259
|
+
readonly resolvedDefault?: ColumnDefault;
|
|
260
|
+
/**
|
|
261
|
+
* The column's resolved codec reference — the identity the migration
|
|
262
|
+
* planner's op-builders resolve DDL type rendering against at plan time
|
|
263
|
+
* (parameterized type expansion, e.g. `character` + `{ length: 36 }` →
|
|
264
|
+
* `character(36)`), calling the same codec hooks the pre-`plan(start,
|
|
265
|
+
* end)` op-path called. Carried the same way the query AST carries
|
|
266
|
+
* `CodecRef` (TML-2456) and the migration DDL renderer (TML-2918).
|
|
267
|
+
* Stamped on the EXPECTED (contract-derived) column at derivation,
|
|
268
|
+
* post-`typeRef` resolution (the referenced storage type's own
|
|
269
|
+
* codec/params, not the column's `typeRef` pointer). Absent on
|
|
270
|
+
* introspected/hand-built nodes — the actual side never renders DDL —
|
|
271
|
+
* and never compared by `isEqualTo`.
|
|
272
|
+
*/
|
|
273
|
+
readonly codecRef?: CodecRef;
|
|
274
|
+
/**
|
|
275
|
+
* The column's resolved BASE native type: pre-parameter-expansion,
|
|
276
|
+
* pre-array-suffix (e.g. `character`, not `character(36)` or
|
|
277
|
+
* `character[]`). Distinct from {@link resolvedNativeType} (the EXPANDED
|
|
278
|
+
* comparison value) — DDL rendering re-expands a parameterized type at
|
|
279
|
+
* plan time from this base, so it must not already carry the expansion.
|
|
280
|
+
* Stamped alongside {@link codecRef}.
|
|
281
|
+
*/
|
|
282
|
+
readonly codecBaseNativeType?: string;
|
|
283
|
+
/**
|
|
284
|
+
* True when the contract column declared its type via a named
|
|
285
|
+
* `storage.types` reference (`typeRef`) rather than inline fields — the
|
|
286
|
+
* migration planner quotes the base native type as an identifier in this
|
|
287
|
+
* case (e.g. a native enum's type name), matching the pre-`plan(start,
|
|
288
|
+
* end)` rendering exactly.
|
|
289
|
+
*/
|
|
290
|
+
readonly codecNamedType?: boolean;
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Schema IR node for a single column on a table, as observed by
|
|
294
|
+
* introspection. Unlike the Contract IR `StorageColumn`, this carries
|
|
295
|
+
* the column's `name` (Schema IR columns are returned as arrays from
|
|
296
|
+
* introspection queries; the parent table re-keys them into a record
|
|
297
|
+
* for downstream consumers).
|
|
298
|
+
*
|
|
299
|
+
* Implements `DiffableNode` so a column is directly a table's diff-tree
|
|
300
|
+
* child: `id` is the column name (unique among a table's columns); `isEqualTo`
|
|
301
|
+
* compares this column's own attributes only — never children, since a
|
|
302
|
+
* column is a leaf. When both sides carry `resolvedNativeType` (stamped at
|
|
303
|
+
* derivation/introspection), the comparison uses the resolved values —
|
|
304
|
+
* resolved native type, nullability, and structured default equality per
|
|
305
|
+
* the relational walk's `columnDefaultsEqual` semantics, with `this` as the
|
|
306
|
+
* expected side. Otherwise it falls back to comparing raw fields.
|
|
307
|
+
*/
|
|
308
|
+
declare class SqlColumnIR extends SqlSchemaIRNode implements DiffableNode {
|
|
309
|
+
readonly nodeKind: "sql-column";
|
|
310
|
+
readonly name: string;
|
|
311
|
+
readonly nativeType: string;
|
|
312
|
+
readonly nullable: boolean;
|
|
313
|
+
readonly default?: string;
|
|
314
|
+
readonly annotations?: SqlAnnotations;
|
|
315
|
+
/** True when the column is a native array (e.g. `text[]`, `int4[]`). The `nativeType` carries the element type only (e.g. `text`, `int4`). */
|
|
316
|
+
readonly many?: boolean;
|
|
317
|
+
readonly resolvedNativeType?: string;
|
|
318
|
+
readonly resolvedDefault?: ColumnDefault;
|
|
319
|
+
/** See {@link SqlColumnIRInput.codecRef}. Non-enumerable so it stays out of JSON and structural equality. */
|
|
320
|
+
readonly codecRef?: CodecRef;
|
|
321
|
+
/** See {@link SqlColumnIRInput.codecBaseNativeType}. Non-enumerable, same reason as {@link codecRef}. */
|
|
322
|
+
readonly codecBaseNativeType?: string;
|
|
323
|
+
/** See {@link SqlColumnIRInput.codecNamedType}. Non-enumerable, same reason as {@link codecRef}. */
|
|
324
|
+
readonly codecNamedType?: boolean;
|
|
325
|
+
constructor(input: SqlColumnIRInput);
|
|
326
|
+
get id(): string;
|
|
327
|
+
/**
|
|
328
|
+
* The column's default, when declared/present, is the column's one child
|
|
329
|
+
* node — it has an extra/missing/drift lifecycle of its own, so the differ
|
|
330
|
+
* recurses to it rather than `isEqualTo` comparing it. Built transiently
|
|
331
|
+
* from this column's own fields.
|
|
332
|
+
*/
|
|
333
|
+
children(): readonly DiffableNode[];
|
|
334
|
+
static is(node: SqlSchemaIRNode): node is SqlColumnIR;
|
|
335
|
+
/**
|
|
336
|
+
* Compares the column's own attributes only — the default lives on the
|
|
337
|
+
* child node. When both sides carry `resolvedNativeType`, the resolved
|
|
338
|
+
* value governs (array-ness rides on its `[]` suffix); otherwise raw
|
|
339
|
+
* fields compare.
|
|
340
|
+
*/
|
|
341
|
+
isEqualTo(other: DiffableNode): boolean;
|
|
342
|
+
}
|
|
343
|
+
//#endregion
|
|
344
|
+
//#region src/ir/sql-foreign-key-ir.d.ts
|
|
345
|
+
type SqlReferentialAction = 'noAction' | 'restrict' | 'cascade' | 'setNull' | 'setDefault';
|
|
346
|
+
interface SqlForeignKeyIRInput {
|
|
347
|
+
readonly columns: readonly string[];
|
|
348
|
+
readonly referencedTable: string;
|
|
349
|
+
readonly referencedColumns: readonly string[];
|
|
350
|
+
/** Schema (namespace) of the referenced table — populated by adapters that introspect cross-schema FKs. */
|
|
351
|
+
readonly referencedSchema?: string;
|
|
352
|
+
readonly name?: string;
|
|
353
|
+
readonly onDelete?: SqlReferentialAction;
|
|
354
|
+
readonly onUpdate?: SqlReferentialAction;
|
|
355
|
+
readonly annotations?: SqlAnnotations;
|
|
356
|
+
/**
|
|
357
|
+
* The real live DDL namespace of the referenced table, comparable across
|
|
358
|
+
* the two diff sides. Contract-derived trees stamp it explicitly (resolving
|
|
359
|
+
* namespace ids — including the unbound sentinel — to the DDL namespace);
|
|
360
|
+
* introspected FKs default it to `referencedSchema`, whose value already
|
|
361
|
+
* is the live namespace. Folded into `id` in place of the raw value so an
|
|
362
|
+
* unbound-namespace contract FK pairs with its introspected counterpart.
|
|
363
|
+
*/
|
|
364
|
+
readonly resolvedReferencedNamespace?: string;
|
|
365
|
+
/**
|
|
366
|
+
* The referenced table's node, as the root-anchored chain the differ pairs
|
|
367
|
+
* siblings with. Stamped by the derivation, which holds the parent
|
|
368
|
+
* (database/namespace) context the chain's shape depends on. Never
|
|
369
|
+
* compared by `isEqualTo`.
|
|
370
|
+
*/
|
|
371
|
+
readonly dependsOn?: readonly SchemaNodeRef[];
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* Schema IR node for a foreign-key constraint as observed by
|
|
375
|
+
* introspection. The `referencedTable` / `referencedColumns` field
|
|
376
|
+
* names match the introspection vocabulary (`pg_constraint.confkey`,
|
|
377
|
+
* etc.) and intentionally differ from the Contract IR's nested
|
|
378
|
+
* `references: { table, columns }` shape so that the verifier's
|
|
379
|
+
* structural comparison stays explicit about which side it's reading.
|
|
380
|
+
*
|
|
381
|
+
* Implements `DiffableNode` so a foreign key is directly a table's diff-tree
|
|
382
|
+
* child. Foreign keys are frequently unnamed (introspection may not carry a
|
|
383
|
+
* constraint name, and the contract side never invents one), so `id` is
|
|
384
|
+
* derived from the referencing/referenced coordinates rather than `name` —
|
|
385
|
+
* the same tuple that makes two FK constraints the same constraint. This
|
|
386
|
+
* also serves as the comparison key: two FKs with the same coordinates are
|
|
387
|
+
* paired by the differ, and `isEqualTo` then compares the remaining
|
|
388
|
+
* attribute — the referential actions.
|
|
389
|
+
*/
|
|
390
|
+
declare class SqlForeignKeyIR extends SqlSchemaIRNode implements DiffableNode {
|
|
391
|
+
readonly nodeKind: "sql-foreign-key";
|
|
392
|
+
readonly columns: readonly string[];
|
|
393
|
+
readonly referencedTable: string;
|
|
394
|
+
readonly referencedColumns: readonly string[];
|
|
395
|
+
readonly referencedSchema?: string;
|
|
396
|
+
readonly name?: string;
|
|
397
|
+
readonly onDelete?: SqlReferentialAction;
|
|
398
|
+
readonly onUpdate?: SqlReferentialAction;
|
|
399
|
+
readonly annotations?: SqlAnnotations;
|
|
400
|
+
readonly resolvedReferencedNamespace?: string;
|
|
401
|
+
/** See {@link SqlForeignKeyIRInput.dependsOn}. Non-enumerable so it stays out of JSON and structural equality, matching `SqlColumnIR.codecRef`. */
|
|
402
|
+
readonly dependsOn?: readonly SchemaNodeRef[];
|
|
403
|
+
constructor(input: SqlForeignKeyIRInput);
|
|
404
|
+
get id(): string;
|
|
405
|
+
children(): readonly DiffableNode[];
|
|
406
|
+
static is(node: SqlSchemaIRNode): node is SqlForeignKeyIR;
|
|
407
|
+
/**
|
|
408
|
+
* Referential-action comparison with `this` as the expected side, matching
|
|
409
|
+
* the relational walk's `getReferentialActionMismatches`: `noAction` is the
|
|
410
|
+
* database default and equivalent to an undeclared action, and drift is
|
|
411
|
+
* flagged only when the expected side declares a (normalized) action.
|
|
412
|
+
*/
|
|
413
|
+
isEqualTo(other: DiffableNode): boolean;
|
|
414
|
+
}
|
|
415
|
+
//#endregion
|
|
416
|
+
//#region src/ir/sql-index-ir.d.ts
|
|
417
|
+
/**
|
|
418
|
+
* An index's element structure — exactly one of a column tuple or an opaque
|
|
419
|
+
* expression, unrepresentable-otherwise at the type level. No discriminant
|
|
420
|
+
* is stored (the node keeps flat readonly accessors); the constructor's xor
|
|
421
|
+
* throw stays as the backstop for introspection rows and JSON-derived
|
|
422
|
+
* inputs that bypass this union.
|
|
423
|
+
*/
|
|
424
|
+
type SqlIndexElements = {
|
|
425
|
+
/** Column-tuple elements. */
|
|
426
|
+
readonly columns: readonly string[];
|
|
427
|
+
readonly expression?: never;
|
|
428
|
+
} | {
|
|
429
|
+
readonly columns?: never;
|
|
430
|
+
/**
|
|
431
|
+
* Opaque SQL: the entire element list between the parens of CREATE
|
|
432
|
+
* INDEX — one string, never parsed.
|
|
433
|
+
*/
|
|
434
|
+
readonly expression: string;
|
|
435
|
+
};
|
|
436
|
+
type SqlIndexIRInput = SqlIndexElements & {
|
|
437
|
+
/** The node's identity. Read back off a built node with `namingOf`. */
|
|
438
|
+
readonly naming: SqlObjectNaming;
|
|
439
|
+
/** Opaque SQL: partial-index predicate (WHERE body, without the keyword). */
|
|
440
|
+
readonly where: string | undefined;
|
|
441
|
+
readonly unique: boolean;
|
|
442
|
+
readonly type: string | undefined;
|
|
443
|
+
readonly options: Record<string, unknown> | undefined;
|
|
444
|
+
readonly annotations: SqlAnnotations | undefined;
|
|
445
|
+
/**
|
|
446
|
+
* The index's own column nodes, as root-anchored chains. The derivation
|
|
447
|
+
* stamps them so an index is dropped before the columns it is built on
|
|
448
|
+
* (Postgres auto-drops the index when a covered column goes). An expression
|
|
449
|
+
* index stamps chains to every column of its table — a deterministic
|
|
450
|
+
* over-approximation, since the opaque expression is never parsed. Never
|
|
451
|
+
* compared by `isEqualTo`.
|
|
452
|
+
*/
|
|
453
|
+
readonly dependsOn: readonly SchemaNodeRef[] | undefined;
|
|
454
|
+
/**
|
|
455
|
+
* Whether the index is partial (has a row predicate). Required: every
|
|
456
|
+
* producer must assert partiality explicitly, because a partial unique
|
|
457
|
+
* index does not guarantee at-most-one row per key and so cannot back a
|
|
458
|
+
* 1:1 relation — "unknown" must not silently default to "total". Never
|
|
459
|
+
* compared by `isEqualTo` and never serialized.
|
|
460
|
+
*/
|
|
461
|
+
readonly partial: boolean;
|
|
462
|
+
};
|
|
463
|
+
/**
|
|
464
|
+
* Schema IR node for a secondary index as observed by introspection.
|
|
465
|
+
* Unlike the Contract IR `Index`, the Schema IR carries an explicit
|
|
466
|
+
* `unique` field — introspection sees the underlying index regardless
|
|
467
|
+
* of whether the user expressed it as `@@index` or `@@unique`, and the
|
|
468
|
+
* verifier needs to distinguish them when comparing to the Contract.
|
|
469
|
+
*
|
|
470
|
+
* Implements `DiffableNode` so an index is directly a table's diff-tree
|
|
471
|
+
* child. Indexes are name-identified: every index — contract-derived or
|
|
472
|
+
* introspected — carries its full physical name, and `id` is that name.
|
|
473
|
+
* Names are catalog-unique per schema, so two indexes legitimately sharing
|
|
474
|
+
* one column tuple (a unique index beside a redundant plain index) are two
|
|
475
|
+
* distinct siblings, and expression indexes need no column tuple at all.
|
|
476
|
+
*
|
|
477
|
+
* `isEqualTo` is selected by the receiver (the differ always calls
|
|
478
|
+
* `expected.isEqualTo(actual)`) and delegates to {@link contentEquals} —
|
|
479
|
+
* the single node-owned content relation: both modes compare `unique`
|
|
480
|
+
* strict, `type` and option values through the named normalization seams,
|
|
481
|
+
* and `columns` ordered-strict when both sides carry them; an exact-named
|
|
482
|
+
* receiver (`prefix === undefined`) additionally byte-compares
|
|
483
|
+
* `expression`/`where` (both sides are reprints in the supported flow —
|
|
484
|
+
* normalizing would only mask real drift); a wire-named receiver never
|
|
485
|
+
* compares bodies (the wire-name hash already commits to them).
|
|
486
|
+
*
|
|
487
|
+
* `expression`, `where`, and `unique` are genuine SQL-family attributes —
|
|
488
|
+
* functional and partial indexes are standard SQL that any SQL target may
|
|
489
|
+
* introspect, so the family node must represent them; a target declining
|
|
490
|
+
* to author them is a capability decision, not target-specificity.
|
|
491
|
+
*/
|
|
492
|
+
declare class SqlIndexIR extends SqlSchemaIRNode implements DiffableNode {
|
|
493
|
+
readonly nodeKind: "sql-index";
|
|
494
|
+
readonly name: string;
|
|
495
|
+
readonly unique: boolean;
|
|
496
|
+
readonly prefix?: string;
|
|
497
|
+
readonly columns?: readonly string[];
|
|
498
|
+
readonly expression?: string;
|
|
499
|
+
readonly where?: string;
|
|
500
|
+
readonly type?: string;
|
|
501
|
+
readonly options?: Record<string, unknown>;
|
|
502
|
+
readonly annotations?: SqlAnnotations;
|
|
503
|
+
/** See {@link SqlIndexIRInput.dependsOn}. Non-enumerable so it stays out of JSON and structural equality, matching `SqlColumnIR.codecRef`. */
|
|
504
|
+
readonly dependsOn?: readonly SchemaNodeRef[];
|
|
505
|
+
/** See {@link SqlIndexIRInput.partial}. Non-enumerable so it stays out of JSON and structural equality, matching `dependsOn`. */
|
|
506
|
+
readonly partial: boolean;
|
|
507
|
+
constructor(input: SqlIndexIRInput);
|
|
508
|
+
get id(): string;
|
|
509
|
+
children(): readonly DiffableNode[];
|
|
510
|
+
static is(node: SqlSchemaIRNode): node is SqlIndexIR;
|
|
511
|
+
/**
|
|
512
|
+
* Mode-selected structural equality — see the class doc. Delegates to the
|
|
513
|
+
* single node-owned relation: `columns` compare ordered-strict when both
|
|
514
|
+
* sides carry them; an exact receiver (`prefix === undefined`)
|
|
515
|
+
* byte-compares `expression ?? ''` and `where ?? ''`; a wire-named receiver
|
|
516
|
+
* never compares bodies (the wire-name hash already commits to them).
|
|
517
|
+
*/
|
|
518
|
+
isEqualTo(other: DiffableNode): boolean;
|
|
519
|
+
/**
|
|
520
|
+
* The single index content-equality relation — every comparer (the differ
|
|
521
|
+
* via {@link isEqualTo}, the planner's rename content-pairing) calls this
|
|
522
|
+
* with its mode-appropriate strictness rather than growing a parallel
|
|
523
|
+
* relation:
|
|
524
|
+
*
|
|
525
|
+
* - `columnPresence: 'when-both-defined'` (the differ's rule) compares
|
|
526
|
+
* the tuples ordered-strict only when both sides carry them — a paired
|
|
527
|
+
* node's identity already agreed, so a column node meeting an
|
|
528
|
+
* expression node skips the tuple.
|
|
529
|
+
* - `columnPresence: 'matching'` (the rename-pairing rule) additionally
|
|
530
|
+
* requires presence to agree: a column index never pairs an expression
|
|
531
|
+
* index.
|
|
532
|
+
* - `bodies: 'verbatim'` byte-compares `expression ?? ''` / `where ?? ''`
|
|
533
|
+
* (absent ≡ empty, no normalization — both sides are reprints in the
|
|
534
|
+
* supported flow); `bodies: 'ignored'` skips them (wire identity —
|
|
535
|
+
* the wire-name hash commits to the content).
|
|
536
|
+
*
|
|
537
|
+
* `unique` compares strictly; `type` and option VALUES compare through
|
|
538
|
+
* the named normalization seams below.
|
|
539
|
+
*/
|
|
540
|
+
contentEquals(other: SqlIndexIR, strictness: {
|
|
541
|
+
readonly columnPresence: 'when-both-defined' | 'matching';
|
|
542
|
+
readonly bodies: 'verbatim' | 'ignored';
|
|
543
|
+
}): boolean;
|
|
544
|
+
}
|
|
545
|
+
//#endregion
|
|
546
|
+
//#region src/ir/sql-unique-ir.d.ts
|
|
547
|
+
interface SqlUniqueIRInput {
|
|
548
|
+
readonly columns: readonly string[];
|
|
549
|
+
readonly name?: string;
|
|
550
|
+
readonly annotations?: SqlAnnotations;
|
|
551
|
+
/**
|
|
552
|
+
* The constraint's own column nodes, as root-anchored chains. The
|
|
553
|
+
* derivation stamps them so a unique constraint is dropped before the
|
|
554
|
+
* columns it is built on. Never compared by `isEqualTo`.
|
|
555
|
+
*/
|
|
556
|
+
readonly dependsOn?: readonly SchemaNodeRef[];
|
|
557
|
+
}
|
|
558
|
+
/**
|
|
559
|
+
* Schema IR node for a table-level unique constraint as observed by
|
|
560
|
+
* introspection.
|
|
561
|
+
*
|
|
562
|
+
* Implements `DiffableNode` so a unique constraint is directly a table's
|
|
563
|
+
* diff-tree child. Unique constraints are frequently unnamed, so `id` is
|
|
564
|
+
* derived from the column tuple rather than `name` — the column tuple is
|
|
565
|
+
* also what makes two unique constraints the same constraint, so it doubles
|
|
566
|
+
* as the pairing key. There are no further attributes to compare once
|
|
567
|
+
* columns are equal (the differ pairs on `id`), so `isEqualTo` is identity.
|
|
568
|
+
*/
|
|
569
|
+
declare class SqlUniqueIR extends SqlSchemaIRNode implements DiffableNode {
|
|
570
|
+
readonly nodeKind: "sql-unique";
|
|
571
|
+
readonly columns: readonly string[];
|
|
572
|
+
readonly name?: string;
|
|
573
|
+
readonly annotations?: SqlAnnotations;
|
|
574
|
+
/** See {@link SqlUniqueIRInput.dependsOn}. Non-enumerable so it stays out of JSON and structural equality, matching `SqlColumnIR.codecRef`. */
|
|
575
|
+
readonly dependsOn?: readonly SchemaNodeRef[];
|
|
576
|
+
constructor(input: SqlUniqueIRInput);
|
|
577
|
+
get id(): string;
|
|
578
|
+
children(): readonly DiffableNode[];
|
|
579
|
+
static is(node: SqlSchemaIRNode): node is SqlUniqueIR;
|
|
580
|
+
isEqualTo(other: DiffableNode): boolean;
|
|
581
|
+
}
|
|
582
|
+
//#endregion
|
|
583
|
+
//#region src/ir/sql-table-ir.d.ts
|
|
584
|
+
interface SqlTableIRInput {
|
|
585
|
+
readonly name: string;
|
|
586
|
+
readonly columns: Record<string, SqlColumnIR | SqlColumnIRInput>;
|
|
587
|
+
readonly foreignKeys: ReadonlyArray<SqlForeignKeyIR | SqlForeignKeyIRInput>;
|
|
588
|
+
readonly uniques: ReadonlyArray<SqlUniqueIR | SqlUniqueIRInput>;
|
|
589
|
+
readonly indexes: ReadonlyArray<SqlIndexIR | SqlIndexIRInput>;
|
|
590
|
+
readonly primaryKey?: PrimaryKey | PrimaryKeyInput;
|
|
591
|
+
readonly annotations?: SqlAnnotations;
|
|
592
|
+
/** Optional check constraints for enum-restricted columns. Omitted when none present. */
|
|
593
|
+
readonly checks?: ReadonlyArray<SqlCheckConstraintIR | SqlCheckConstraintIRInput>;
|
|
594
|
+
}
|
|
595
|
+
/**
|
|
596
|
+
* Schema IR node for a single table as observed by introspection.
|
|
597
|
+
*
|
|
598
|
+
* Unlike the Contract IR `StorageTable`, this carries the table's
|
|
599
|
+
* `name` — introspection queries return tables as arrays and the
|
|
600
|
+
* verifier keys them into `SqlSchemaIR.tables` afterwards, so the name
|
|
601
|
+
* stays on the table object for downstream call sites that walk
|
|
602
|
+
* `Object.values(schema.tables)`.
|
|
603
|
+
*
|
|
604
|
+
* The constructor normalises nested IR-class fields so downstream
|
|
605
|
+
* walks see a uniform AST regardless of whether the input was a
|
|
606
|
+
* plain-data literal (from introspection) or already-constructed
|
|
607
|
+
* class instances.
|
|
608
|
+
*
|
|
609
|
+
* Implements `DiffableNode` so a flat (single-schema) tree is directly
|
|
610
|
+
* diffable: `id` is the table name; `isEqualTo` is identity (the table's
|
|
611
|
+
* structural drift is entirely expressed by its children); `children()`
|
|
612
|
+
* yields every column, the primary key (when present), every foreign key,
|
|
613
|
+
* unique, index, and check constraint — the same composition and order as
|
|
614
|
+
* the Postgres table node, minus policies.
|
|
615
|
+
*/
|
|
616
|
+
declare class SqlTableIR extends SqlSchemaIRNode implements DiffableNode {
|
|
617
|
+
readonly nodeKind: "sql-table";
|
|
618
|
+
readonly name: string;
|
|
619
|
+
readonly columns: Readonly<Record<string, SqlColumnIR>>;
|
|
620
|
+
readonly foreignKeys: ReadonlyArray<SqlForeignKeyIR>;
|
|
621
|
+
readonly uniques: ReadonlyArray<SqlUniqueIR>;
|
|
622
|
+
readonly indexes: ReadonlyArray<SqlIndexIR>;
|
|
623
|
+
readonly primaryKey?: PrimaryKey;
|
|
624
|
+
readonly annotations?: SqlAnnotations;
|
|
625
|
+
readonly checks?: ReadonlyArray<SqlCheckConstraintIR>;
|
|
626
|
+
constructor(input: SqlTableIRInput);
|
|
627
|
+
get id(): string;
|
|
628
|
+
isEqualTo(other: DiffableNode): boolean;
|
|
629
|
+
children(): readonly DiffableNode[];
|
|
630
|
+
}
|
|
631
|
+
//#endregion
|
|
632
|
+
//#region src/ir/sql-schema-ir.d.ts
|
|
633
|
+
interface SqlSchemaIRInput {
|
|
634
|
+
readonly tables: Record<string, SqlTableIR | SqlTableIRInput>;
|
|
635
|
+
readonly annotations?: SqlAnnotations;
|
|
636
|
+
}
|
|
637
|
+
/**
|
|
638
|
+
* Root Schema IR node representing the complete database schema as
|
|
639
|
+
* observed by introspection. Target-agnostic; used by both verifiers
|
|
640
|
+
* (compare against intended Contract storage) and migration planners
|
|
641
|
+
* (derive operations needed to reconcile).
|
|
642
|
+
*
|
|
643
|
+
* The constructor normalises nested `SqlTableIR` instances so
|
|
644
|
+
* downstream walks see a uniform AST regardless of whether the input
|
|
645
|
+
* was a plain-data literal or already-constructed class instances.
|
|
646
|
+
*
|
|
647
|
+
* Implements `DiffableNode` as the root of a flat (single-schema) diff
|
|
648
|
+
* tree: `id` is the fixed sentinel `'database'` (roots have no siblings),
|
|
649
|
+
* `isEqualTo` is identity (a container has no own attributes), and
|
|
650
|
+
* `children()` yields the table nodes.
|
|
651
|
+
*/
|
|
652
|
+
declare class SqlSchemaIR extends SqlSchemaIRNode implements DiffableNode {
|
|
653
|
+
readonly nodeKind: "sql-schema";
|
|
654
|
+
readonly tables: Readonly<Record<string, SqlTableIR>>;
|
|
655
|
+
readonly annotations?: SqlAnnotations;
|
|
656
|
+
constructor(input: SqlSchemaIRInput);
|
|
657
|
+
get id(): string;
|
|
658
|
+
isEqualTo(other: DiffableNode): boolean;
|
|
659
|
+
children(): readonly DiffableNode[];
|
|
660
|
+
}
|
|
661
|
+
//#endregion
|
|
662
|
+
//#region src/types.d.ts
|
|
663
|
+
/**
|
|
664
|
+
* SQL type metadata for control-plane and execution-plane type
|
|
665
|
+
* availability and mapping. Read-only view of type information
|
|
666
|
+
* without encode/decode behavior.
|
|
667
|
+
*/
|
|
668
|
+
interface SqlTypeMetadata {
|
|
669
|
+
/** Namespaced type identifier, e.g. `pg/int4@1`, `pg/text@1`. */
|
|
670
|
+
readonly typeId: string;
|
|
671
|
+
/** Contract scalar type IDs this type can handle. */
|
|
672
|
+
readonly targetTypes: readonly string[];
|
|
673
|
+
/**
|
|
674
|
+
* Native database type name (target-specific). Optional because
|
|
675
|
+
* not all types have a native database representation.
|
|
676
|
+
*/
|
|
677
|
+
readonly nativeType?: string;
|
|
678
|
+
}
|
|
679
|
+
/**
|
|
680
|
+
* Registry interface for SQL type metadata. Provides read-only
|
|
681
|
+
* iteration over type metadata entries.
|
|
682
|
+
*/
|
|
683
|
+
interface SqlTypeMetadataRegistry {
|
|
684
|
+
values(): IterableIterator<SqlTypeMetadata>;
|
|
685
|
+
}
|
|
686
|
+
//#endregion
|
|
687
|
+
export { SqlUniqueIR as C, relationalNodeEntityKind as D, defineNonEnumerable as E, relationalNodeGranularity as O, SqlTypeMetadataRegistry as S, assertNode as T, SqlSchemaIRInput as _, SqlCheckConstraintIR as a, SqlTableIRInput as b, SqlColumnDefaultIRInput as c, SqlForeignKeyIR as d, SqlForeignKeyIRInput as f, SqlSchemaIR as g, SqlReferentialAction as h, SqlAnnotations as i, SqlColumnIR as l, SqlIndexIRInput as m, PrimaryKeyInput as n, SqlCheckConstraintIRInput as o, SqlIndexIR as p, RelationalSchemaNodeKind as r, SqlColumnDefaultIR as s, PrimaryKey as t, SqlColumnIRInput as u, SqlSchemaIRNode as v, SqlUniqueIRInput as w, SqlTypeMetadata as x, SqlTableIR as y };
|
|
688
|
+
//# sourceMappingURL=types-CvbBw1Jo-3KQdErJY.d.mts.map
|