@prisma/orm-target-postgres 8.0.0-rc.2-dev.3 → 8.0.0-rc.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -6
- package/dist/adapter-5qylEP__.d.mts +403 -0
- package/dist/adapter-5qylEP__.d.mts.map +1 -0
- package/dist/{adapter-B0xsc80z-sYcF0RVF.mjs → adapter-svGTIjA2-1p-Iw8D2.mjs} +24 -30
- package/dist/adapter-svGTIjA2-1p-Iw8D2.mjs.map +1 -0
- package/dist/adapter.d.mts +11 -13
- package/dist/adapter.mjs +7 -8
- package/dist/adapter__adapter.d.mts +2 -2
- package/dist/adapter__adapter.mjs +3 -2
- package/dist/adapter__column-types.d.mts +2 -2
- package/dist/adapter__column-types.mjs +2 -2
- package/dist/adapter__control.d.mts +4 -5
- package/dist/adapter__control.mjs +11 -423
- package/dist/adapter__control.mjs.map +1 -1
- package/dist/adapter__runtime.d.mts +1 -1
- package/dist/adapter__runtime.mjs +29 -19
- package/dist/adapter__runtime.mjs.map +1 -1
- package/dist/adapter__sql-renderer.d.mts +1 -1
- package/dist/adapter__sql-renderer.mjs +1 -1
- package/dist/adapter__types.d.mts +4 -3
- package/dist/aggregates-CEqqEg8k.d.mts +318 -0
- package/dist/aggregates-CEqqEg8k.d.mts.map +1 -0
- package/dist/{aggregates-Dh6HPdvC.mjs → aggregates-Dw-lAutX.mjs} +105 -40
- package/dist/aggregates-Dw-lAutX.mjs.map +1 -0
- package/dist/authoring-DWd5pnnV-BBX7P1wT.d.mts +52 -0
- package/dist/authoring-DWd5pnnV-BBX7P1wT.d.mts.map +1 -0
- package/dist/authoring-SbdvmVJh-nQ7YliD_.mjs +1342 -0
- package/dist/authoring-SbdvmVJh-nQ7YliD_.mjs.map +1 -0
- package/dist/autoincrement-widths-DonNJgfS-CCvZ4u1W.mjs +58 -0
- package/dist/autoincrement-widths-DonNJgfS-CCvZ4u1W.mjs.map +1 -0
- package/dist/{canonicalize-CQlxSR4D-MnrT5gtW.d.mts → canonicalize-B-xvDOdd-G3yUeKj4.d.mts} +7 -3
- package/dist/canonicalize-B-xvDOdd-G3yUeKj4.d.mts.map +1 -0
- package/dist/{canonicalize-CrN3u_xM-D4MrOqcB.mjs → canonicalize-RdxoUHao-FTTkizfe.mjs} +15 -3
- package/dist/canonicalize-RdxoUHao-FTTkizfe.mjs.map +1 -0
- package/dist/check-expressions-7uCCP01t-DtX2Vak9.mjs +48 -0
- package/dist/check-expressions-7uCCP01t-DtX2Vak9.mjs.map +1 -0
- package/dist/{check-expressions-DRgG8RN5-DiA-22aC.d.mts → check-expressions-CtTzM58x-LloO-5Vf.d.mts} +14 -13
- package/dist/check-expressions-CtTzM58x-LloO-5Vf.d.mts.map +1 -0
- package/dist/{codec-descriptor-LT7BpQta-BaDM8UQQ.mjs → codec-descriptor-DoR-cTFZ-BlG5Gj-X.mjs} +12 -21
- package/dist/codec-descriptor-DoR-cTFZ-BlG5Gj-X.mjs.map +1 -0
- package/dist/codec-descriptor-Fb3UoQGb.d.mts +1 -0
- package/dist/codec-descriptor-d1ByNBEk-DhrtS_5y.d.mts +47 -0
- package/dist/codec-descriptor-d1ByNBEk-DhrtS_5y.d.mts.map +1 -0
- package/dist/codec-ids-BMhEpFwv-B8Zh0s_Q.mjs +41 -0
- package/dist/codec-ids-BMhEpFwv-B8Zh0s_Q.mjs.map +1 -0
- package/dist/codec-ids-C6II64Wy-CPYTqDTT.d.mts +41 -0
- package/dist/codec-ids-C6II64Wy-CPYTqDTT.d.mts.map +1 -0
- package/dist/codec-ids-CcB5uBNf.d.mts +1 -0
- package/dist/codec-registry-D7XslgPe-DTZnVB8W.mjs +61 -0
- package/dist/codec-registry-D7XslgPe-DTZnVB8W.mjs.map +1 -0
- package/dist/codec-type-map-Fj5xCgwT-BeCXgfuR.d.mts +53 -0
- package/dist/codec-type-map-Fj5xCgwT-BeCXgfuR.d.mts.map +1 -0
- package/dist/codec-types-BBACckHa.d.mts +2 -0
- package/dist/codec-types-Ct_4iTVc-3tFJcIBo.d.mts +84 -0
- package/dist/codec-types-Ct_4iTVc-3tFJcIBo.d.mts.map +1 -0
- package/dist/codecs-CADK7dCR-C8WToYQb.d.mts +724 -0
- package/dist/codecs-CADK7dCR-C8WToYQb.d.mts.map +1 -0
- package/dist/codecs-CRl9-i_r-Co-bgYl3.mjs +1743 -0
- package/dist/codecs-CRl9-i_r-Co-bgYl3.mjs.map +1 -0
- package/dist/codecs-CoEpEqjM.d.mts +31 -0
- package/dist/codecs-CoEpEqjM.d.mts.map +1 -0
- package/dist/column-types-B4zsV-u3.mjs +106 -0
- package/dist/column-types-B4zsV-u3.mjs.map +1 -0
- package/dist/column-types-Bs2V0j8T.d.mts +164 -0
- package/dist/column-types-Bs2V0j8T.d.mts.map +1 -0
- package/dist/{control-adapter-DFr4gS-r-DM3KcZdQ.mjs → contract-contributions-Xz2FpyfI-CeQZqHKf.mjs} +489 -292
- package/dist/contract-contributions-Xz2FpyfI-CeQZqHKf.mjs.map +1 -0
- package/dist/{contract-free-DzpGxLfb.d.mts → contract-free-B6-wuc6M.d.mts} +36 -6
- package/dist/contract-free-B6-wuc6M.d.mts.map +1 -0
- package/dist/{contract-free-aQ4nT-_R.mjs → contract-free-o7olebm9.mjs} +13 -9
- package/dist/contract-free-o7olebm9.mjs.map +1 -0
- package/dist/control--HupSPoV.d.mts +847 -0
- package/dist/control--HupSPoV.d.mts.map +1 -0
- package/dist/{control-BaUpALVp.d.mts → control-CQEjh4P7.d.mts} +2 -2
- package/dist/control-CQEjh4P7.d.mts.map +1 -0
- package/dist/{control-DLTOAEHj.d.mts → control-D4cTcpcJ.d.mts} +22 -48
- package/dist/control-D4cTcpcJ.d.mts.map +1 -0
- package/dist/{control-Y6FxMu3o.mjs → control-DZQwENIP.mjs} +21 -9
- package/dist/control-DZQwENIP.mjs.map +1 -0
- package/dist/{control-policy-B53lnBCT-B9K9Cj1x.mjs → control-policy-DtU5u9Dm-44r_OF94.mjs} +444 -218
- package/dist/control-policy-DtU5u9Dm-44r_OF94.mjs.map +1 -0
- package/dist/{data-transform-ChZzy2dP-CxVCat_8.mjs → data-transform-h9agBu_c-RlC5A7aY.mjs} +12 -5
- package/dist/data-transform-h9agBu_c-RlC5A7aY.mjs.map +1 -0
- package/dist/{data-transform-Ck5FbyNO-BNE7QlAo.d.mts → data-transform-nGy9rz87-CE3DGlgn.d.mts} +15 -4
- package/dist/data-transform-nGy9rz87-CE3DGlgn.d.mts.map +1 -0
- package/dist/data-transform-nqkqNIb8.d.mts +1 -0
- package/dist/data-type-entries-gQW3-KSb-BIl8vgus.mjs +128 -0
- package/dist/data-type-entries-gQW3-KSb-BIl8vgus.mjs.map +1 -0
- package/dist/data-types--7V9yY1G.d.mts +99 -0
- package/dist/data-types--7V9yY1G.d.mts.map +1 -0
- package/dist/data-types-Chx0mjTP-DczU4S9b.mjs +950 -0
- package/dist/data-types-Chx0mjTP-DczU4S9b.mjs.map +1 -0
- package/dist/date-time-now-generators-CMkXVbMG-C-GjhReE.d.mts +45 -0
- package/dist/date-time-now-generators-CMkXVbMG-C-GjhReE.d.mts.map +1 -0
- package/dist/ddl-B7Rqlz6D-B7dRDgYb.mjs +647 -0
- package/dist/ddl-B7Rqlz6D-B7dRDgYb.mjs.map +1 -0
- package/dist/ddl-B8nQZTWN.d.mts +1 -0
- package/dist/default-constraint-names-Cz9Yoeim-sUzOGvIm.mjs +18 -0
- package/dist/default-constraint-names-Cz9Yoeim-sUzOGvIm.mjs.map +1 -0
- package/dist/default-normalizer-BqK6XxdC-2OUb2ybG.mjs +311 -0
- package/dist/default-normalizer-BqK6XxdC-2OUb2ybG.mjs.map +1 -0
- package/dist/default-normalizer-DO-cH75Q.d.mts +25 -0
- package/dist/default-normalizer-DO-cH75Q.d.mts.map +1 -0
- package/dist/descriptor-meta-BkD3nXF_-CZaNqC6r.mjs +36 -0
- package/dist/descriptor-meta-BkD3nXF_-CZaNqC6r.mjs.map +1 -0
- package/dist/descriptor-meta-DaFDNnHQ-QjiiAEtC.mjs +64 -0
- package/dist/descriptor-meta-DaFDNnHQ-QjiiAEtC.mjs.map +1 -0
- package/dist/descriptor-meta-runtime-Dft1L7eE-D8vpOz_Z.mjs +15 -0
- package/dist/descriptor-meta-runtime-Dft1L7eE-D8vpOz_Z.mjs.map +1 -0
- package/dist/{diff-database-schema-DsoNznGC.d.mts → diff-database-schema-BxzhZaVN.d.mts} +12 -7
- package/dist/diff-database-schema-BxzhZaVN.d.mts.map +1 -0
- package/dist/{diff-database-schema-DKq76rCk-uehceHYz.mjs → diff-database-schema-DAEzWtzU-DoyVgKqh.mjs} +38 -18
- package/dist/diff-database-schema-DAEzWtzU-DoyVgKqh.mjs.map +1 -0
- package/dist/driver.d.mts +3 -3
- package/dist/driver.mjs +3 -2
- package/dist/driver__control.d.mts +1 -1
- package/dist/driver__control.mjs +1 -1
- package/dist/driver__runtime.d.mts +2 -2
- package/dist/driver__runtime.mjs +2 -639
- package/dist/errors-BrhQYgdL-IvZHPjwL.mjs +103 -0
- package/dist/errors-BrhQYgdL-IvZHPjwL.mjs.map +1 -0
- package/dist/{errors-CU4xIwwk.d.mts → errors-D3Mj-x0o.d.mts} +3 -3
- package/dist/errors-D3Mj-x0o.d.mts.map +1 -0
- package/dist/full-text-BYg7EVX2.mjs +39 -0
- package/dist/full-text-BYg7EVX2.mjs.map +1 -0
- package/dist/full-text-SDbfxrE_.d.mts +26 -0
- package/dist/full-text-SDbfxrE_.d.mts.map +1 -0
- package/dist/full-text-collection-method-BFd2u2cs-Ba3OiWM3.d.mts +27 -0
- package/dist/full-text-collection-method-BFd2u2cs-Ba3OiWM3.d.mts.map +1 -0
- package/dist/full-text-index-authoring-CN1L9C1k.d.mts +7 -0
- package/dist/full-text-index-authoring-CN1L9C1k.d.mts.map +1 -0
- package/dist/full-text-index-definition-BPxQQBuC-VLyQ1kEL.mjs +195 -0
- package/dist/full-text-index-definition-BPxQQBuC-VLyQ1kEL.mjs.map +1 -0
- package/dist/full-text-index-definition-D5iBWLss-BEpqiucV.d.mts +71 -0
- package/dist/full-text-index-definition-D5iBWLss-BEpqiucV.d.mts.map +1 -0
- package/dist/full-text-parsers-CFFxiOrp-CrZ7VI1m.mjs +139 -0
- package/dist/full-text-parsers-CFFxiOrp-CrZ7VI1m.mjs.map +1 -0
- package/dist/full-text-search-document-Doy5TF7c-aMWM_1KB.mjs +54 -0
- package/dist/full-text-search-document-Doy5TF7c-aMWM_1KB.mjs.map +1 -0
- package/dist/index-types-BihjrAAq-C2VnfAyF.mjs +14 -0
- package/dist/index-types-BihjrAAq-C2VnfAyF.mjs.map +1 -0
- package/dist/indexes-BYf6nXVv-BXwLw7fO.d.mts +60 -0
- package/dist/indexes-BYf6nXVv-BXwLw7fO.d.mts.map +1 -0
- package/dist/infer-psl-contract-BSSHcuRi-ChdFSviw.mjs +1143 -0
- package/dist/infer-psl-contract-BSSHcuRi-ChdFSviw.mjs.map +1 -0
- package/dist/{issue-planner-Biq9Ls7e.d.mts → issue-planner-D-On52xP.d.mts} +39 -9
- package/dist/issue-planner-D-On52xP.d.mts.map +1 -0
- package/dist/list-decoder-BcrLExnx-DlCwavhu.d.mts +7 -0
- package/dist/list-decoder-BcrLExnx-DlCwavhu.d.mts.map +1 -0
- package/dist/marker-lock-BviIbusV.d.mts +11 -0
- package/dist/marker-lock-BviIbusV.d.mts.map +1 -0
- package/dist/marker-lock-DFc1Tfv5-BkBKBRE3.mjs +11 -0
- package/dist/marker-lock-DFc1Tfv5-BkBKBRE3.mjs.map +1 -0
- package/dist/{migration-PTHAY9Cv.mjs → migration-Be_iuIpn.mjs} +5 -4
- package/dist/migration-Be_iuIpn.mjs.map +1 -0
- package/dist/migration-D4lMmLVj.d.mts +26 -0
- package/dist/migration-D4lMmLVj.d.mts.map +1 -0
- package/dist/{namespace-ids-xtp_ZY86-Cpp8PTxD.mjs → namespace-ids-xtp_ZY86-Cxc0dBbO.mjs} +2 -2
- package/dist/namespace-ids-xtp_ZY86-Cxc0dBbO.mjs.map +1 -0
- package/dist/native-type-normalizer-BaGa9eeb.d.mts +30 -0
- package/dist/native-type-normalizer-BaGa9eeb.d.mts.map +1 -0
- package/dist/native-type-normalizer-Cn-RGt_E.mjs +24 -0
- package/dist/native-type-normalizer-Cn-RGt_E.mjs.map +1 -0
- package/dist/{nodes-DAvDJLvJ-BBdvFXNa.mjs → nodes-G8VTh4PM-DNvIhHag.mjs} +78 -7
- package/dist/nodes-G8VTh4PM-DNvIhHag.mjs.map +1 -0
- package/dist/{nodes-BU-V-aZA-RqwPH68u.d.mts → nodes-s0Oe37jT-Cw3BU2gL.d.mts} +82 -29
- package/dist/nodes-s0Oe37jT-Cw3BU2gL.d.mts.map +1 -0
- package/dist/op-factory-call-CRaVUOb_.d.mts +1 -0
- package/dist/{op-factory-call-H6zeDGLe-_1pAftJk.mjs → op-factory-call-gGX-mZu--0QUG5xH4.mjs} +1014 -258
- package/dist/op-factory-call-gGX-mZu--0QUG5xH4.mjs.map +1 -0
- package/dist/{op-factory-call-BAeyLFYf-BAgG1h1C.d.mts → op-factory-call-nLHvNx0O-BTBhGbOF.d.mts} +169 -111
- package/dist/op-factory-call-nLHvNx0O-BTBhGbOF.d.mts.map +1 -0
- package/dist/operation-types--Wa_cv45-RoRnL1Dn.d.mts +192 -0
- package/dist/operation-types--Wa_cv45-RoRnL1Dn.d.mts.map +1 -0
- package/dist/operation-types-OXILTAOX.d.mts +1 -0
- package/dist/pack-2CYw2w-b.d.mts +1573 -0
- package/dist/pack-2CYw2w-b.d.mts.map +1 -0
- package/dist/{planner-CT-7zSfk.d.mts → planner-AD3Dt57t.d.mts} +23 -51
- package/dist/planner-AD3Dt57t.d.mts.map +1 -0
- package/dist/planner-VuR6URu3-CCUT2Osx.mjs +954 -0
- package/dist/planner-VuR6URu3-CCUT2Osx.mjs.map +1 -0
- package/dist/planner-ddl-builders-CPM3y7cQ.d.mts +16 -0
- package/dist/planner-ddl-builders-CPM3y7cQ.d.mts.map +1 -0
- package/dist/planner-ddl-builders-cYnH52gC-BWifb_M6.mjs +28 -0
- package/dist/planner-ddl-builders-cYnH52gC-BWifb_M6.mjs.map +1 -0
- package/dist/planner-identity-values-Dsq989Lh.d.mts +26 -0
- package/dist/planner-identity-values-Dsq989Lh.d.mts.map +1 -0
- package/dist/planner-identity-values-QstrMJ2U-CcpaRVPY.mjs +70 -0
- package/dist/planner-identity-values-QstrMJ2U-CcpaRVPY.mjs.map +1 -0
- package/dist/planner-produced-postgres-migration-BBUwtjA_.d.mts +1 -0
- package/dist/{planner-produced-postgres-migration-D5m8nK6s-CbZ4hlbv.mjs → planner-produced-postgres-migration-BZclL_xO-uflxtYuP.mjs} +5 -5
- package/dist/planner-produced-postgres-migration-BZclL_xO-uflxtYuP.mjs.map +1 -0
- package/dist/{planner-produced-postgres-migration-BaviT8KK-Yo9kw6rs.d.mts → planner-produced-postgres-migration-DyIXJ3MR-DHO5wn_X.d.mts} +4 -4
- package/dist/planner-produced-postgres-migration-DyIXJ3MR-DHO5wn_X.d.mts.map +1 -0
- package/dist/{planner-schema-lookup-kMIVP2y--CdO4VlnF.mjs → planner-schema-lookup-BbUY9oVy.mjs} +2 -2
- package/dist/planner-schema-lookup-BbUY9oVy.mjs.map +1 -0
- package/dist/{planner-schema-lookup-C4DHAddq.d.mts → planner-schema-lookup-ceCNOGFf.d.mts} +2 -2
- package/dist/planner-schema-lookup-ceCNOGFf.d.mts.map +1 -0
- package/dist/planner-sql-checks-D-K44J19-CzvrqzNB.mjs +151 -0
- package/dist/planner-sql-checks-D-K44J19-CzvrqzNB.mjs.map +1 -0
- package/dist/planner-sql-checks-Ed-WGtge-D9ByMrW4.d.mts +37 -0
- package/dist/planner-sql-checks-Ed-WGtge-D9ByMrW4.d.mts.map +1 -0
- package/dist/planner-sql-checks-rEjFx_Jv.d.mts +1 -0
- package/dist/planner-target-details-CUEF0s90-6g-mOgTI.mjs +14 -0
- package/dist/planner-target-details-CUEF0s90-6g-mOgTI.mjs.map +1 -0
- package/dist/{planner-target-details-HkP4RrRO-_xPQVPF0.d.mts → planner-target-details-HkP4RrRO-D6VtK0jY.d.mts} +2 -2
- package/dist/planner-target-details-HkP4RrRO-D6VtK0jY.d.mts.map +1 -0
- package/dist/postgres-codec-traits-CnP5Bjxp-Dxdgv0TI.mjs +11 -0
- package/dist/postgres-codec-traits-CnP5Bjxp-Dxdgv0TI.mjs.map +1 -0
- package/dist/{postgres-contract-view-2OP5JnXl-D2fpy4-8.d.mts → postgres-contract-view-BFzIDwwN-hL3QLe_b.d.mts} +2 -2
- package/dist/postgres-contract-view-BFzIDwwN-hL3QLe_b.d.mts.map +1 -0
- package/dist/{postgres-contract-view-B8ykf2cO-T2LvWVFZ.mjs → postgres-contract-view-BO2elRMz-BqMBzJoJ.mjs} +27 -14
- package/dist/postgres-contract-view-BO2elRMz-BqMBzJoJ.mjs.map +1 -0
- package/dist/{postgres-database-schema-node-CyfpHXDr-BqyozkQE.d.mts → postgres-database-schema-node-Cv8usVNX-BmvGozi4.d.mts} +4 -4
- package/dist/postgres-database-schema-node-Cv8usVNX-BmvGozi4.d.mts.map +1 -0
- package/dist/postgres-migration-BSWmeRLo-CUfVTUf0.mjs +1312 -0
- package/dist/postgres-migration-BSWmeRLo-CUfVTUf0.mjs.map +1 -0
- package/dist/{postgres-migration-BNsrwlxh-CwI5BqAu.d.mts → postgres-migration-C5deJ3Ne-C4Jxu-e6.d.mts} +135 -15
- package/dist/postgres-migration-C5deJ3Ne-C4Jxu-e6.d.mts.map +1 -0
- package/dist/{postgres-native-enum-CdP3b_-R-Cgz9KEKx.mjs → postgres-native-enum-CdP3b_-R-DgG3pi5p.mjs} +2 -2
- package/dist/postgres-native-enum-CdP3b_-R-DgG3pi5p.mjs.map +1 -0
- package/dist/postgres-object-name-FPikIvOw-B8FfJI7z.mjs +23 -0
- package/dist/postgres-object-name-FPikIvOw-B8FfJI7z.mjs.map +1 -0
- package/dist/{postgres-rls-policy-CnDxf3z9-C3LIHAIG.d.mts → postgres-rls-policy-CnDxf3z9-BjpVyUnK.d.mts} +2 -2
- package/dist/postgres-rls-policy-CnDxf3z9-BjpVyUnK.d.mts.map +1 -0
- package/dist/{postgres-role-schema-node-B8Z5i5D--PObwlU2Z.mjs → postgres-role-schema-node-B8Z5i5D--BzOKm4N1.mjs} +3 -3
- package/dist/postgres-role-schema-node-B8Z5i5D--BzOKm4N1.mjs.map +1 -0
- package/dist/{postgres-schema-CF0yHESb-D7n2X21R.mjs → postgres-schema-C6w1rzOF-D1fdwqRx.mjs} +14 -12
- package/dist/postgres-schema-C6w1rzOF-D1fdwqRx.mjs.map +1 -0
- package/dist/{postgres-schema-Xsjt3RKO-Buv2X8ai.d.mts → postgres-schema-Xsjt3RKO-bis-SVSB.d.mts} +4 -4
- package/dist/postgres-schema-Xsjt3RKO-bis-SVSB.d.mts.map +1 -0
- package/dist/{postgres-table-schema-node-BBkitBQh-DT1T5VWU.mjs → postgres-table-schema-node-BBkitBQh-Dll8iaZT.mjs} +2 -2
- package/dist/postgres-table-schema-node-BBkitBQh-Dll8iaZT.mjs.map +1 -0
- package/dist/prisma7-binding-BjiLA9F7.mjs +307 -0
- package/dist/prisma7-binding-BjiLA9F7.mjs.map +1 -0
- package/dist/prisma7-binding-a56klfkc.d.mts +1651 -0
- package/dist/prisma7-binding-a56klfkc.d.mts.map +1 -0
- package/dist/{render-ops-DOsRP0Po-BKn_c_Ia.mjs → render-ops-BgqtCw9Z-T8BPTX85.mjs} +17 -10
- package/dist/render-ops-BgqtCw9Z-T8BPTX85.mjs.map +1 -0
- package/dist/{render-ops-DPwhZt2W.d.mts → render-ops-Bl84i7ut.d.mts} +3 -3
- package/dist/render-ops-Bl84i7ut.d.mts.map +1 -0
- package/dist/{render-typescript-6sCFvMBh.d.mts → render-typescript-BysdXYpH.d.mts} +2 -2
- package/dist/render-typescript-BysdXYpH.d.mts.map +1 -0
- package/dist/{render-typescript-Dqp1Spgn-B128r1qw.mjs → render-typescript-Dqp1Spgn-B4mJhuVr.mjs} +2 -2
- package/dist/render-typescript-Dqp1Spgn-B4mJhuVr.mjs.map +1 -0
- package/dist/resolve-ddl-schema-D3VNPMSm-BuB6NyOI.mjs +34 -0
- package/dist/resolve-ddl-schema-D3VNPMSm-BuB6NyOI.mjs.map +1 -0
- package/dist/{runtime-lHBKgjB9.d.mts → runtime-C0VXuM0b.d.mts} +4 -3
- package/dist/runtime-C0VXuM0b.d.mts.map +1 -0
- package/dist/runtime-CXfxy5ED.mjs +660 -0
- package/dist/runtime-CXfxy5ED.mjs.map +1 -0
- package/dist/{runtime-_TfO66h5.d.mts → runtime-Ci_toEDZ.d.mts} +12 -4
- package/dist/runtime-Ci_toEDZ.d.mts.map +1 -0
- package/dist/{runtime-DOXznQe0.d.mts → runtime-DtjW0GP_.d.mts} +4 -4
- package/dist/runtime-DtjW0GP_.d.mts.map +1 -0
- package/dist/{schema-ir-annotations-DuuYh0gl.d.mts → schema-ir-annotations-BygaWBiC.d.mts} +2 -2
- package/dist/schema-ir-annotations-BygaWBiC.d.mts.map +1 -0
- package/dist/{schema-node-kinds-qlnURWJy-Bo30pwTM.d.mts → schema-node-kinds-C52Bb1ve-DmxQRPPS.d.mts} +2 -2
- package/dist/schema-node-kinds-C52Bb1ve-DmxQRPPS.d.mts.map +1 -0
- package/dist/{normalize-error-CNjgVO71-CLlZ3CuJ.mjs → server-text-types-DeNPQpv5-DqX0h8WF.mjs} +45 -3
- package/dist/server-text-types-DeNPQpv5-DqX0h8WF.mjs.map +1 -0
- package/dist/{sql-renderer-ComgusFq-BBlqM1fw.mjs → sql-renderer-BdWJPa5F-Ct0CPlXc.mjs} +113 -123
- package/dist/sql-renderer-BdWJPa5F-Ct0CPlXc.mjs.map +1 -0
- package/dist/{sql-renderer-BgC0ZgLS.d.mts → sql-renderer-BiBhge7D.d.mts} +9 -7
- package/dist/sql-renderer-BiBhge7D.d.mts.map +1 -0
- package/dist/{sql-utils-DuzN3JZg-DiXy4Vah.mjs → sql-utils-Bnw3JbWf-BN0gcjZB.mjs} +31 -8
- package/dist/sql-utils-Bnw3JbWf-BN0gcjZB.mjs.map +1 -0
- package/dist/{sql-utils-DW6fkczF.d.mts → sql-utils-CnnGiZBc.d.mts} +12 -4
- package/dist/sql-utils-CnnGiZBc.d.mts.map +1 -0
- package/dist/{table-source-ikHOZmhD-DriY1Lcr.d.mts → table-source-ikHOZmhD-vYcblBYv.d.mts} +2 -2
- package/dist/table-source-ikHOZmhD-vYcblBYv.d.mts.map +1 -0
- package/dist/target.d.mts +61 -49
- package/dist/target.mjs +45 -36
- package/dist/target__aggregates.d.mts +1 -1
- package/dist/target__aggregates.mjs +1 -1
- package/dist/target__codec-descriptor.d.mts +2 -2
- package/dist/target__codec-descriptor.mjs +1 -1
- package/dist/target__codec-ids.d.mts +3 -3
- package/dist/target__codec-ids.mjs +2 -2
- package/dist/target__codec-types.d.mts +4 -4
- package/dist/target__codecs.d.mts +4 -3
- package/dist/target__codecs.mjs +3 -3
- package/dist/target__contract-free.d.mts +3 -3
- package/dist/target__contract-free.mjs +4 -4
- package/dist/target__control.d.mts +4 -2
- package/dist/target__control.mjs +2501 -2
- package/dist/target__control.mjs.map +1 -0
- package/dist/target__data-transform.d.mts +2 -2
- package/dist/target__data-transform.mjs +1 -1
- package/dist/target__data-types.d.mts +2 -0
- package/dist/target__data-types.mjs +3 -0
- package/dist/target__ddl.d.mts +4 -4
- package/dist/target__ddl.mjs +2 -2
- package/dist/target__default-normalizer.d.mts +2 -2
- package/dist/target__default-normalizer.mjs +2 -2
- package/dist/target__diff-database-schema.d.mts +1 -1
- package/dist/target__diff-database-schema.mjs +1 -1
- package/dist/target__errors.d.mts +1 -1
- package/dist/target__errors.mjs +1 -1
- package/dist/target__full-text-index-authoring.d.mts +3 -0
- package/dist/target__full-text-index-authoring.mjs +3 -0
- package/dist/target__full-text.d.mts +4 -0
- package/dist/target__full-text.mjs +3 -0
- package/dist/target__issue-planner.d.mts +1 -1
- package/dist/target__issue-planner.mjs +1 -1
- package/dist/target__marker-lock.d.mts +2 -0
- package/dist/target__marker-lock.mjs +2 -0
- package/dist/target__migration.d.mts +4 -4
- package/dist/target__migration.mjs +5 -5
- package/dist/target__native-type-normalizer.d.mts +2 -2
- package/dist/target__native-type-normalizer.mjs +2 -2
- package/dist/target__op-factory-call.d.mts +3 -3
- package/dist/target__op-factory-call.mjs +2 -2
- package/dist/target__operation-types.d.mts +4 -0
- package/dist/target__pack.d.mts +3 -2
- package/dist/target__pack.mjs +1 -1
- package/dist/target__planner-ddl-builders.d.mts +2 -2
- package/dist/target__planner-ddl-builders.mjs +2 -2
- package/dist/target__planner-identity-values.d.mts +1 -1
- package/dist/target__planner-identity-values.mjs +1 -1
- package/dist/target__planner-produced-postgres-migration.d.mts +2 -2
- package/dist/target__planner-produced-postgres-migration.mjs +1 -1
- package/dist/target__planner-schema-lookup.d.mts +1 -1
- package/dist/target__planner-schema-lookup.mjs +1 -1
- package/dist/target__planner-sql-checks.d.mts +3 -2
- package/dist/target__planner-sql-checks.mjs +2 -2
- package/dist/target__planner-target-details.d.mts +1 -1
- package/dist/target__planner.d.mts +1 -1
- package/dist/target__planner.mjs +2 -2
- package/dist/target__prisma7-binding.d.mts +2 -0
- package/dist/target__prisma7-binding.mjs +2 -0
- package/dist/target__render-ops.d.mts +1 -1
- package/dist/target__render-ops.mjs +1 -1
- package/dist/target__render-typescript.d.mts +1 -1
- package/dist/target__render-typescript.mjs +1 -1
- package/dist/target__rls-canonicalize.d.mts +2 -2
- package/dist/target__rls-canonicalize.mjs +2 -2
- package/dist/target__runtime.d.mts +6 -3
- package/dist/target__runtime.mjs +193 -4
- package/dist/target__runtime.mjs.map +1 -1
- package/dist/target__schema-ir-annotations.d.mts +1 -1
- package/dist/target__schema-ir-annotations.mjs +1 -1
- package/dist/target__sql-utils.d.mts +3 -2
- package/dist/target__sql-utils.mjs +4 -2
- package/dist/target__types.d.mts +7 -7
- package/dist/target__types.mjs +5 -5
- package/dist/types-AvjnIUna.d.mts +2 -0
- package/dist/types-D6lgKhE5-D1J9YJnd.d.mts +28 -0
- package/dist/types-D6lgKhE5-D1J9YJnd.d.mts.map +1 -0
- package/dist/{types-CjGjPLr5.d.mts → types-DOmgp_12.d.mts} +8 -8
- package/dist/types-DOmgp_12.d.mts.map +1 -0
- package/dist/{types-ue6jkJyF-BQJzjx1P.d.mts → types-ue6jkJyF-D79DmBTl.d.mts} +2 -2
- package/dist/types-ue6jkJyF-D79DmBTl.d.mts.map +1 -0
- package/package.json +22 -14
- package/dist/adapter-B0xsc80z-sYcF0RVF.mjs.map +0 -1
- package/dist/adapter-CPesdzv0.d.mts +0 -26
- package/dist/adapter-CPesdzv0.d.mts.map +0 -1
- package/dist/adapter__operation-types.d.mts +0 -2
- package/dist/aggregates-CgqNfj2O.d.mts +0 -10
- package/dist/aggregates-CgqNfj2O.d.mts.map +0 -1
- package/dist/aggregates-Dh6HPdvC.mjs.map +0 -1
- package/dist/authoring-BOpdZa2N-ClrLFiXw.mjs +0 -773
- package/dist/authoring-BOpdZa2N-ClrLFiXw.mjs.map +0 -1
- package/dist/canonicalize-CQlxSR4D-MnrT5gtW.d.mts.map +0 -1
- package/dist/canonicalize-CrN3u_xM-D4MrOqcB.mjs.map +0 -1
- package/dist/check-expressions-5vhxWaFy-CBcjFeur.mjs +0 -41
- package/dist/check-expressions-5vhxWaFy-CBcjFeur.mjs.map +0 -1
- package/dist/check-expressions-DRgG8RN5-DiA-22aC.d.mts.map +0 -1
- package/dist/codec-descriptor-Bec_zukr-BfvtUqhm.d.mts +0 -37
- package/dist/codec-descriptor-Bec_zukr-BfvtUqhm.d.mts.map +0 -1
- package/dist/codec-descriptor-Bg-_412t.d.mts +0 -1
- package/dist/codec-descriptor-LT7BpQta-BaDM8UQQ.mjs.map +0 -1
- package/dist/codec-ids-Bqu_IwO0-DKOdPizQ.d.mts +0 -35
- package/dist/codec-ids-Bqu_IwO0-DKOdPizQ.d.mts.map +0 -1
- package/dist/codec-ids-C5Rkltkw-DMf87l9s.mjs +0 -35
- package/dist/codec-ids-C5Rkltkw-DMf87l9s.mjs.map +0 -1
- package/dist/codec-ids-DJ6j6pZc.d.mts +0 -1
- package/dist/codec-types-BRU4F-7t-BaJbKF_i.d.mts +0 -84
- package/dist/codec-types-BRU4F-7t-BaJbKF_i.d.mts.map +0 -1
- package/dist/codec-types-bX63JRLf.d.mts +0 -2
- package/dist/codecs-B1HgsJZ2.mjs +0 -15
- package/dist/codecs-B1HgsJZ2.mjs.map +0 -1
- package/dist/codecs-BmPCJWqb-DveZGJvm.mjs +0 -1680
- package/dist/codecs-BmPCJWqb-DveZGJvm.mjs.map +0 -1
- package/dist/codecs-D8tLswBi-_nbo-Z8x.d.mts +0 -638
- package/dist/codecs-D8tLswBi-_nbo-Z8x.d.mts.map +0 -1
- package/dist/codecs-DmCKO7dg.d.mts +0 -15
- package/dist/codecs-DmCKO7dg.d.mts.map +0 -1
- package/dist/column-types-BH-MU6uU.d.mts +0 -108
- package/dist/column-types-BH-MU6uU.d.mts.map +0 -1
- package/dist/column-types-Bh92dNjD.mjs +0 -126
- package/dist/column-types-Bh92dNjD.mjs.map +0 -1
- package/dist/contract-free-DzpGxLfb.d.mts.map +0 -1
- package/dist/contract-free-aQ4nT-_R.mjs.map +0 -1
- package/dist/control-2F195jJk.d.mts +0 -11
- package/dist/control-2F195jJk.d.mts.map +0 -1
- package/dist/control-BaUpALVp.d.mts.map +0 -1
- package/dist/control-DLTOAEHj.d.mts.map +0 -1
- package/dist/control-V7OkAC55.mjs +0 -1459
- package/dist/control-V7OkAC55.mjs.map +0 -1
- package/dist/control-Y6FxMu3o.mjs.map +0 -1
- package/dist/control-adapter-DFr4gS-r-DM3KcZdQ.mjs.map +0 -1
- package/dist/control-policy-B53lnBCT-B9K9Cj1x.mjs.map +0 -1
- package/dist/data-transform-BSM7TQpE.d.mts +0 -1
- package/dist/data-transform-ChZzy2dP-CxVCat_8.mjs.map +0 -1
- package/dist/data-transform-Ck5FbyNO-BNE7QlAo.d.mts.map +0 -1
- package/dist/ddl-B4Rh8ntj.d.mts +0 -1
- package/dist/ddl-CNQJds-C-WfZ3y4y8.mjs +0 -395
- package/dist/ddl-CNQJds-C-WfZ3y4y8.mjs.map +0 -1
- package/dist/default-normalizer-B36TOul4.d.mts +0 -31
- package/dist/default-normalizer-B36TOul4.d.mts.map +0 -1
- package/dist/default-normalizer-Ba5ZebHM-isV86rjy.mjs +0 -253
- package/dist/default-normalizer-Ba5ZebHM-isV86rjy.mjs.map +0 -1
- package/dist/descriptor-meta-KVX21fsl-DBDoB4eg.mjs +0 -354
- package/dist/descriptor-meta-KVX21fsl-DBDoB4eg.mjs.map +0 -1
- package/dist/descriptor-meta-rilAH3ep-dAmiVLpe.mjs +0 -30
- package/dist/descriptor-meta-rilAH3ep-dAmiVLpe.mjs.map +0 -1
- package/dist/descriptor-meta-runtime-UwYdV8fD-B_m_Ha8r.mjs +0 -13
- package/dist/descriptor-meta-runtime-UwYdV8fD-B_m_Ha8r.mjs.map +0 -1
- package/dist/diff-database-schema-DKq76rCk-uehceHYz.mjs.map +0 -1
- package/dist/diff-database-schema-DsoNznGC.d.mts.map +0 -1
- package/dist/driver__runtime.mjs.map +0 -1
- package/dist/errors-CU4xIwwk.d.mts.map +0 -1
- package/dist/errors-DKjQzNaN-DFcF1thx.mjs +0 -39
- package/dist/errors-DKjQzNaN-DFcF1thx.mjs.map +0 -1
- package/dist/issue-planner-Biq9Ls7e.d.mts.map +0 -1
- package/dist/migration-PTHAY9Cv.mjs.map +0 -1
- package/dist/migration-aFeTWTOJ.d.mts +0 -25
- package/dist/migration-aFeTWTOJ.d.mts.map +0 -1
- package/dist/namespace-ids-xtp_ZY86-Cpp8PTxD.mjs.map +0 -1
- package/dist/native-type-normalizer-DqJlOTeX.d.mts +0 -19
- package/dist/native-type-normalizer-DqJlOTeX.d.mts.map +0 -1
- package/dist/native-type-normalizer-yvd3tqv-.mjs +0 -38
- package/dist/native-type-normalizer-yvd3tqv-.mjs.map +0 -1
- package/dist/nodes-BU-V-aZA-RqwPH68u.d.mts.map +0 -1
- package/dist/nodes-DAvDJLvJ-BBdvFXNa.mjs.map +0 -1
- package/dist/normalize-error-CNjgVO71-CLlZ3CuJ.mjs.map +0 -1
- package/dist/op-factory-call-BAeyLFYf-BAgG1h1C.d.mts.map +0 -1
- package/dist/op-factory-call-BTU8I_x0.d.mts +0 -1
- package/dist/op-factory-call-H6zeDGLe-_1pAftJk.mjs.map +0 -1
- package/dist/operation-types-BfRocNI8.d.mts +0 -22
- package/dist/operation-types-BfRocNI8.d.mts.map +0 -1
- package/dist/pack-CySS3DQU.d.mts +0 -626
- package/dist/pack-CySS3DQU.d.mts.map +0 -1
- package/dist/planner-CT-7zSfk.d.mts.map +0 -1
- package/dist/planner-D0uogzvT-1WyGIC5p.mjs +0 -671
- package/dist/planner-D0uogzvT-1WyGIC5p.mjs.map +0 -1
- package/dist/planner-ddl-builders-Chxh-LEQ-DXvwOeeA.mjs +0 -102
- package/dist/planner-ddl-builders-Chxh-LEQ-DXvwOeeA.mjs.map +0 -1
- package/dist/planner-ddl-builders-ijp60-JO.d.mts +0 -19
- package/dist/planner-ddl-builders-ijp60-JO.d.mts.map +0 -1
- package/dist/planner-identity-values-BmHn5C6U-BYBbUAyR.mjs +0 -90
- package/dist/planner-identity-values-BmHn5C6U-BYBbUAyR.mjs.map +0 -1
- package/dist/planner-identity-values-TfEhnoWa.d.mts +0 -25
- package/dist/planner-identity-values-TfEhnoWa.d.mts.map +0 -1
- package/dist/planner-produced-postgres-migration-BaviT8KK-Yo9kw6rs.d.mts.map +0 -1
- package/dist/planner-produced-postgres-migration-D5m8nK6s-CbZ4hlbv.mjs.map +0 -1
- package/dist/planner-produced-postgres-migration-D6C0T2xV.d.mts +0 -1
- package/dist/planner-schema-lookup-C4DHAddq.d.mts.map +0 -1
- package/dist/planner-schema-lookup-kMIVP2y--CdO4VlnF.mjs.map +0 -1
- package/dist/planner-sql-checks-CFgbRTJw.d.mts +0 -20
- package/dist/planner-sql-checks-CFgbRTJw.d.mts.map +0 -1
- package/dist/planner-sql-checks-ftgzvIO9-BTtBg2Vz.mjs +0 -152
- package/dist/planner-sql-checks-ftgzvIO9-BTtBg2Vz.mjs.map +0 -1
- package/dist/planner-target-details-HkP4RrRO-_xPQVPF0.d.mts.map +0 -1
- package/dist/planner-type-resolution-Bt2f_q-F-C4T6YTae.mjs +0 -15
- package/dist/planner-type-resolution-Bt2f_q-F-C4T6YTae.mjs.map +0 -1
- package/dist/postgres-contract-view-2OP5JnXl-D2fpy4-8.d.mts.map +0 -1
- package/dist/postgres-contract-view-B8ykf2cO-T2LvWVFZ.mjs.map +0 -1
- package/dist/postgres-database-schema-node-CyfpHXDr-BqyozkQE.d.mts.map +0 -1
- package/dist/postgres-migration-BNsrwlxh-CwI5BqAu.d.mts.map +0 -1
- package/dist/postgres-migration-Dbq3RGfZ-aMnwfEAb.mjs +0 -205
- package/dist/postgres-migration-Dbq3RGfZ-aMnwfEAb.mjs.map +0 -1
- package/dist/postgres-native-enum-CdP3b_-R-Cgz9KEKx.mjs.map +0 -1
- package/dist/postgres-rls-policy-CnDxf3z9-C3LIHAIG.d.mts.map +0 -1
- package/dist/postgres-role-schema-node-B8Z5i5D--PObwlU2Z.mjs.map +0 -1
- package/dist/postgres-schema-CF0yHESb-D7n2X21R.mjs.map +0 -1
- package/dist/postgres-schema-Xsjt3RKO-Buv2X8ai.d.mts.map +0 -1
- package/dist/postgres-table-schema-node-BBkitBQh-DT1T5VWU.mjs.map +0 -1
- package/dist/render-ops-DOsRP0Po-BKn_c_Ia.mjs.map +0 -1
- package/dist/render-ops-DPwhZt2W.d.mts.map +0 -1
- package/dist/render-typescript-6sCFvMBh.d.mts.map +0 -1
- package/dist/render-typescript-Dqp1Spgn-B128r1qw.mjs.map +0 -1
- package/dist/resolve-ddl-schema-CoaeNP35-C-UZldpj.mjs +0 -22
- package/dist/resolve-ddl-schema-CoaeNP35-C-UZldpj.mjs.map +0 -1
- package/dist/runtime-DOXznQe0.d.mts.map +0 -1
- package/dist/runtime-_TfO66h5.d.mts.map +0 -1
- package/dist/runtime-lHBKgjB9.d.mts.map +0 -1
- package/dist/schema-ir-annotations-DuuYh0gl.d.mts.map +0 -1
- package/dist/schema-node-kinds-qlnURWJy-Bo30pwTM.d.mts.map +0 -1
- package/dist/sql-renderer-BgC0ZgLS.d.mts.map +0 -1
- package/dist/sql-renderer-ComgusFq-BBlqM1fw.mjs.map +0 -1
- package/dist/sql-utils-DW6fkczF.d.mts.map +0 -1
- package/dist/sql-utils-DuzN3JZg-DiXy4Vah.mjs.map +0 -1
- package/dist/table-source-ikHOZmhD-DriY1Lcr.d.mts.map +0 -1
- package/dist/types-B-4d5_4a.d.mts +0 -1
- package/dist/types-CjGjPLr5.d.mts.map +0 -1
- package/dist/types-CkryN1AS-BcQRGsDn.d.mts +0 -27
- package/dist/types-CkryN1AS-BcQRGsDn.d.mts.map +0 -1
- package/dist/types-ue6jkJyF-BQJzjx1P.d.mts.map +0 -1
- /package/dist/{adapter__operation-types.mjs → target__operation-types.mjs} +0 -0
package/dist/{control-adapter-DFr4gS-r-DM3KcZdQ.mjs → contract-contributions-Xz2FpyfI-CeQZqHKf.mjs}
RENAMED
|
@@ -1,53 +1,60 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { t as
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import { t as
|
|
11
|
-
import { n as
|
|
12
|
-
import {
|
|
1
|
+
import { w as PG_TIMESTAMPTZ_STRING_CODEC_ID } from "./codec-ids-BMhEpFwv-B8Zh0s_Q.mjs";
|
|
2
|
+
import { t as postgresAggregateDescriptors } from "./aggregates-Dw-lAutX.mjs";
|
|
3
|
+
import { c as postgresError } from "./errors-BrhQYgdL-IvZHPjwL.mjs";
|
|
4
|
+
import { i as quoteIdentifier, n as escapeLiteral } from "./sql-utils-Bnw3JbWf-BN0gcjZB.mjs";
|
|
5
|
+
import { o as parsePostgresListText } from "./codecs-CRl9-i_r-Co-bgYl3.mjs";
|
|
6
|
+
import { o as postgresCodecRegistry } from "./codec-registry-D7XslgPe-DTZnVB8W.mjs";
|
|
7
|
+
import { a as jsonb, c as textArray, i as int8, l as timestamptz, n as buildSignMarkerBootstrapQueries, o as pgTable, r as int4, s as text, t as buildControlTableBootstrapQueries } from "./contract-free-o7olebm9.mjs";
|
|
8
|
+
import { i as policyRoleList, t as POLICY_COMMAND_SQL } from "./canonicalize-RdxoUHao-FTTkizfe.mjs";
|
|
9
|
+
import { n as PostgresSchemaNodeKind, r as PostgresTableSchemaNode, t as PostgresNativeEnumSchemaNode } from "./postgres-table-schema-node-BBkitBQh-Dll8iaZT.mjs";
|
|
10
|
+
import { i as PostgresRoleSchemaNode, n as PostgresNamespaceSchemaNode, r as PostgresPolicySchemaNode, t as PostgresDatabaseSchemaNode } from "./postgres-role-schema-node-B8Z5i5D--BzOKm4N1.mjs";
|
|
11
|
+
import { n as readPostgresDefault } from "./default-normalizer-BqK6XxdC-2OUb2ybG.mjs";
|
|
12
|
+
import { n as MARKER_LOCK_SQL, t as MARKER_LOCK_KEY } from "./marker-lock-DFc1Tfv5-BkBKBRE3.mjs";
|
|
13
|
+
import { t as introspectedTypeText } from "./native-type-normalizer-Cn-RGt_E.mjs";
|
|
14
|
+
import { n as renderLoweredSql, t as adapterError } from "./sql-renderer-BdWJPa5F-Ct0CPlXc.mjs";
|
|
15
|
+
import { RawExpr, encodeListLiteralDefault, encodeLiteralDefault, isDdlNode, renderOpaqueSql } from "@prisma/orm-family-sql/relational-core/ast";
|
|
16
|
+
import { codecForRef } from "@prisma/orm-framework/components/codec";
|
|
13
17
|
import { blindCast } from "@prisma/orm-framework/utils/casts";
|
|
18
|
+
import { InternalError } from "@prisma/orm-framework/utils/internal-error";
|
|
14
19
|
import { UNBOUND_NAMESPACE_ID } from "@prisma/orm-framework/components/ir";
|
|
15
|
-
import {
|
|
20
|
+
import { APP_SPACE_ID } from "@prisma/orm-framework/components/control";
|
|
16
21
|
import { namingOfLiveName } from "@prisma/orm-family-sql/schema-ir/naming";
|
|
17
|
-
import {
|
|
22
|
+
import { ifDefined } from "@prisma/orm-framework/utils/defined";
|
|
18
23
|
import { RelationalSchemaNodeKind } from "@prisma/orm-family-sql/schema-ir/types";
|
|
19
|
-
import {
|
|
24
|
+
import { checkSqlDefaultText, contractColumns, readColumnDefault } from "@prisma/orm-family-sql/family/control";
|
|
20
25
|
import { REFERENTIAL_ACTION_SQL } from "@prisma/orm-family-sql/contract/referential-action-sql";
|
|
21
|
-
import {
|
|
26
|
+
import { errorMarkerRowCorrupt, rethrowMarkerReadError, withMarkerReadErrorHandling } from "@prisma/orm-framework/errors/execution";
|
|
27
|
+
import { resolveIntrospectedColumnType } from "@prisma/orm-family-sql/family/control-adapter";
|
|
22
28
|
import { parseContractMarkerRow } from "@prisma/orm-family-sql/family/verify";
|
|
23
29
|
import { createAstCodecRegistry, deriveParamMetadata, encodeParamsWithMetadata } from "@prisma/orm-family-sql/runtime";
|
|
24
|
-
//#region ../../../3-targets/
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
30
|
+
//#region ../../../3-targets/postgres/2-adapter/dist/contract-contributions-Xz2FpyfI.mjs
|
|
31
|
+
const postgresAdapterCapabilities = Object.freeze({
|
|
32
|
+
postgres: {
|
|
33
|
+
orderBy: true,
|
|
34
|
+
limit: true,
|
|
35
|
+
lateral: true,
|
|
36
|
+
jsonAgg: true,
|
|
37
|
+
returning: true,
|
|
38
|
+
distinctOn: true,
|
|
39
|
+
forNoKeyUpdate: true,
|
|
40
|
+
forKeyShare: true
|
|
41
|
+
},
|
|
42
|
+
sql: {
|
|
43
|
+
enums: true,
|
|
44
|
+
returning: true,
|
|
45
|
+
defaultInInsert: true,
|
|
46
|
+
lateral: true,
|
|
47
|
+
scalarList: true,
|
|
48
|
+
checkConstraint: true,
|
|
49
|
+
insertOnConflictSkip: true,
|
|
50
|
+
insertOnConflictWithoutTarget: true,
|
|
51
|
+
forUpdate: true,
|
|
52
|
+
forShare: true,
|
|
53
|
+
lockOf: true,
|
|
54
|
+
lockNowait: true,
|
|
55
|
+
lockSkipLocked: true
|
|
56
|
+
}
|
|
57
|
+
});
|
|
51
58
|
function ledgerOriginFromStored(originCoreHash) {
|
|
52
59
|
if (originCoreHash === null || originCoreHash === "" || originCoreHash === "empty") return null;
|
|
53
60
|
return originCoreHash;
|
|
@@ -130,7 +137,7 @@ const infoSchemaTables = pgTable({
|
|
|
130
137
|
const NOW = new RawExpr({
|
|
131
138
|
parts: ["now()"],
|
|
132
139
|
returns: {
|
|
133
|
-
codecId:
|
|
140
|
+
codecId: PG_TIMESTAMPTZ_STRING_CODEC_ID,
|
|
134
141
|
nullable: false
|
|
135
142
|
}
|
|
136
143
|
});
|
|
@@ -142,30 +149,89 @@ async function execute(lower, driver, query) {
|
|
|
142
149
|
const encoded = await encodeControlQueryParams(lowered, query);
|
|
143
150
|
return (await driver.query(lowered.sql, encoded)).rows;
|
|
144
151
|
}
|
|
152
|
+
const KIND_OF_TYPTYPE = {
|
|
153
|
+
e: "enum",
|
|
154
|
+
d: "domain",
|
|
155
|
+
c: "composite",
|
|
156
|
+
r: "range",
|
|
157
|
+
m: "multirange"
|
|
158
|
+
};
|
|
159
|
+
function quotedIdentifier(name) {
|
|
160
|
+
return `"${name.replaceAll("\"", "\"\"")}"`;
|
|
161
|
+
}
|
|
162
|
+
function withoutSchemaPrefix(text, schema) {
|
|
163
|
+
for (const prefix of [`${schema}.`, `${quotedIdentifier(schema)}.`]) if (text.startsWith(prefix)) return text.slice(prefix.length);
|
|
164
|
+
return text;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* The column's element type as Postgres reports it. A base type outside `pg_catalog` loses the
|
|
168
|
+
* schema `format_type` prints when that schema is off the search path, so a type an extension
|
|
169
|
+
* installs in another schema, as Supabase installs `vector`, reads as it does in `public`.
|
|
170
|
+
*/
|
|
171
|
+
function reportedSqlType(element) {
|
|
172
|
+
const kind = KIND_OF_TYPTYPE[element.typtype];
|
|
173
|
+
return {
|
|
174
|
+
text: kind === void 0 && element.schema !== "pg_catalog" ? withoutSchemaPrefix(element.text, element.schema) : element.text,
|
|
175
|
+
kind,
|
|
176
|
+
schema: element.schema,
|
|
177
|
+
name: element.name
|
|
178
|
+
};
|
|
179
|
+
}
|
|
145
180
|
const POSTGRES_MARKER_TABLE = "prisma_contract.marker";
|
|
146
181
|
const POSTGRES_LEDGER_TABLE = "prisma_contract.ledger";
|
|
147
182
|
/**
|
|
183
|
+
* Tables another migration tool, not Prisma 8, keeps in an application schema: Prisma 7's ledger. `introspect` leaves them out unless the contract declares a table of that name in the same namespace.
|
|
184
|
+
*/
|
|
185
|
+
const OTHER_TOOL_MIGRATION_TABLES = /* @__PURE__ */ new Set(["_prisma_migrations"]);
|
|
186
|
+
function markerRowDecodeWhy(detail) {
|
|
187
|
+
return `Invalid contract marker row: ${detail}`;
|
|
188
|
+
}
|
|
189
|
+
function decodeMarkerInteger(value) {
|
|
190
|
+
if (!/^-?\d+$/.test(value)) throw new TypeError(`expected integer text, got ${JSON.stringify(value)}`);
|
|
191
|
+
return Number(value);
|
|
192
|
+
}
|
|
193
|
+
function decodePostgresMarkerRow(row, space) {
|
|
194
|
+
if (typeof row !== "object" || row === null) {
|
|
195
|
+
const cause = /* @__PURE__ */ new TypeError(`expected object marker row, got ${typeof row}`);
|
|
196
|
+
throw errorMarkerRowCorrupt({
|
|
197
|
+
why: markerRowDecodeWhy(cause.message),
|
|
198
|
+
space,
|
|
199
|
+
markerLocation: POSTGRES_MARKER_TABLE,
|
|
200
|
+
cause
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
const record = blindCast(row);
|
|
204
|
+
try {
|
|
205
|
+
return {
|
|
206
|
+
...record,
|
|
207
|
+
...typeof record.canonical_version === "string" ? { canonical_version: decodeMarkerInteger(record.canonical_version) } : {},
|
|
208
|
+
invariants: parsePostgresListText(record.invariants)
|
|
209
|
+
};
|
|
210
|
+
} catch (error) {
|
|
211
|
+
throw errorMarkerRowCorrupt({
|
|
212
|
+
why: markerRowDecodeWhy(error instanceof Error ? error.message : String(error)),
|
|
213
|
+
space,
|
|
214
|
+
markerLocation: POSTGRES_MARKER_TABLE,
|
|
215
|
+
cause: error
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
148
220
|
* Postgres control plane adapter for control-plane operations like introspection.
|
|
149
221
|
* Provides target-specific implementations for control-plane domain actions.
|
|
150
222
|
*/
|
|
151
223
|
var PostgresControlAdapter = class {
|
|
152
224
|
codecRegistry;
|
|
225
|
+
dataTypeLookup;
|
|
226
|
+
declaredDataTypes;
|
|
153
227
|
familyId = "sql";
|
|
154
228
|
targetId = "postgres";
|
|
155
|
-
|
|
229
|
+
/** `declaredDataTypes` are the stack's data types in assembly order, which introspection resolves each column's reported type over. */
|
|
230
|
+
constructor(codecRegistry, dataTypeLookup, declaredDataTypes) {
|
|
156
231
|
this.codecRegistry = codecRegistry;
|
|
232
|
+
this.dataTypeLookup = dataTypeLookup;
|
|
233
|
+
this.declaredDataTypes = declaredDataTypes;
|
|
157
234
|
}
|
|
158
|
-
/**
|
|
159
|
-
* Target-specific normalizer for raw Postgres default expressions.
|
|
160
|
-
* Used by schema verification to normalize raw defaults before comparison.
|
|
161
|
-
*/
|
|
162
|
-
normalizeDefault = parsePostgresDefault;
|
|
163
|
-
/**
|
|
164
|
-
* Target-specific normalizer for Postgres schema native type names.
|
|
165
|
-
* Used by schema verification to normalize introspected type names
|
|
166
|
-
* before comparison with contract native types.
|
|
167
|
-
*/
|
|
168
|
-
normalizeNativeType = normalizeSchemaNativeType;
|
|
169
235
|
bootstrapControlTableQueries() {
|
|
170
236
|
return buildControlTableBootstrapQueries();
|
|
171
237
|
}
|
|
@@ -182,18 +248,25 @@ var PostgresControlAdapter = class {
|
|
|
182
248
|
*/
|
|
183
249
|
lower(ast, context) {
|
|
184
250
|
if (isDdlNode(ast)) throw adapterError("RUNTIME.DDL_UNSUPPORTED", "lower() cannot lower DDL: DDL default literals require inline codec encoding, which is async. Use lowerToExecuteRequest().", { meta: { surface: "control-adapter" } });
|
|
185
|
-
return renderLoweredSql(ast, blindCast(context.contract), this.codecRegistry);
|
|
251
|
+
return renderLoweredSql(ast, blindCast(context.contract), this.codecRegistry, this.dataTypeLookup, postgresAdapterCapabilities);
|
|
252
|
+
}
|
|
253
|
+
async renderColumnDefault(column, table) {
|
|
254
|
+
if (column.default === void 0) return "";
|
|
255
|
+
return pgRenderDdlColumnDefault(column.default, column.type, this.codecRegistry, column.codecRef, {
|
|
256
|
+
table,
|
|
257
|
+
column: column.name
|
|
258
|
+
});
|
|
186
259
|
}
|
|
187
260
|
/**
|
|
188
261
|
* Lower an AST all the way to a driver-ready statement. For DDL nodes,
|
|
189
262
|
* literal column defaults are formatted as inline SQL with proper quoting and
|
|
190
|
-
*
|
|
263
|
+
* a `::` cast to the column's type. For query ASTs, params are kept as `$N`
|
|
191
264
|
* placeholders; wire values go in `params`. Does NOT call `this.lower()` —
|
|
192
265
|
* independent implementation.
|
|
193
266
|
*/
|
|
194
267
|
async lowerToExecuteRequest(ast, context) {
|
|
195
268
|
if (isDdlNode(ast)) return pgRenderDdlExecuteRequest(blindCast(ast), this.codecRegistry);
|
|
196
|
-
const lowered = renderLoweredSql(ast, blindCast(context?.contract), this.codecRegistry);
|
|
269
|
+
const lowered = renderLoweredSql(ast, blindCast(context?.contract), this.codecRegistry, this.dataTypeLookup, postgresAdapterCapabilities);
|
|
197
270
|
const params = await encodeControlQueryParams(lowered, ast, blindCast(this.codecRegistry));
|
|
198
271
|
return {
|
|
199
272
|
sql: lowered.sql,
|
|
@@ -233,13 +306,17 @@ var PostgresControlAdapter = class {
|
|
|
233
306
|
async readAllMarkersResult(driver) {
|
|
234
307
|
const lower = (query) => this.lower(query, { contract: void 0 });
|
|
235
308
|
if ((await execute(lower, driver, infoSchemaTables.select(infoSchemaTables.table_schema).where(infoSchemaTables.table_schema.eq("prisma_contract").and(infoSchemaTables.table_name.eq("marker"))).build())).length === 0) return /* @__PURE__ */ new Map();
|
|
236
|
-
await this.assertMarkerTableHasSpaceColumn(driver, APP_SPACE_ID);
|
|
237
309
|
const rows = blindCast(await execute(lower, driver, marker.select(marker.space, marker.core_hash, marker.profile_hash, marker.contract_json, marker.canonical_version, marker.updated_at, marker.app_tag, marker.meta, marker.invariants).build()));
|
|
238
310
|
const out = /* @__PURE__ */ new Map();
|
|
239
|
-
for (const row of rows)
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
})
|
|
311
|
+
for (const row of rows) try {
|
|
312
|
+
const decodedRow = decodePostgresMarkerRow(row, row.space);
|
|
313
|
+
out.set(row.space, parseContractMarkerRow(decodedRow));
|
|
314
|
+
} catch (error) {
|
|
315
|
+
rethrowMarkerReadError(error, {
|
|
316
|
+
space: row.space,
|
|
317
|
+
markerLocation: POSTGRES_MARKER_TABLE
|
|
318
|
+
});
|
|
319
|
+
}
|
|
243
320
|
return out;
|
|
244
321
|
}
|
|
245
322
|
/**
|
|
@@ -325,13 +402,27 @@ var PostgresControlAdapter = class {
|
|
|
325
402
|
...mergedInvariants !== void 0 ? { invariants: mergedInvariants } : {}
|
|
326
403
|
}).where(marker.space.eq(space).and(marker.core_hash.eq(expectedFrom))).returning(marker.space).build())).length > 0;
|
|
327
404
|
}
|
|
405
|
+
async withTransaction(driver, fn) {
|
|
406
|
+
await driver.query("BEGIN");
|
|
407
|
+
let result;
|
|
408
|
+
try {
|
|
409
|
+
result = await fn();
|
|
410
|
+
} catch (error) {
|
|
411
|
+
try {
|
|
412
|
+
await driver.query("ROLLBACK");
|
|
413
|
+
} catch (rollbackError) {
|
|
414
|
+
if (error instanceof Error && error.cause === void 0) error.cause = rollbackError;
|
|
415
|
+
}
|
|
416
|
+
throw error;
|
|
417
|
+
}
|
|
418
|
+
await driver.query("COMMIT");
|
|
419
|
+
return result;
|
|
420
|
+
}
|
|
421
|
+
async lockMarker(driver) {
|
|
422
|
+
await driver.query(MARKER_LOCK_SQL, [MARKER_LOCK_KEY]);
|
|
423
|
+
}
|
|
328
424
|
/**
|
|
329
|
-
* Appends a ledger entry for `space`. When the edge carries a
|
|
330
|
-
* destination contract snapshot, the content-addressed
|
|
331
|
-
* `prisma_contract.contract` store is populated first (keyed by the
|
|
332
|
-
* destination hash, DO NOTHING on revisit) so a reader never sees a
|
|
333
|
-
* ledger row whose stored destination contract is missing. See the
|
|
334
|
-
* `SqlControlAdapter.writeLedgerEntry` contract.
|
|
425
|
+
* Appends a ledger entry for `space`. When the edge carries a destination contract snapshot, the content-addressed `prisma_contract.contract` store is populated first (keyed by the destination hash, DO NOTHING on revisit) so a reader never sees a ledger row whose stored destination contract is missing. See the `SqlControlAdapter.writeLedgerEntry` contract.
|
|
335
426
|
*/
|
|
336
427
|
async writeLedgerEntry(driver, space, entry) {
|
|
337
428
|
const lower = (query) => this.lower(query, { contract: void 0 });
|
|
@@ -348,29 +439,22 @@ var PostgresControlAdapter = class {
|
|
|
348
439
|
operations: entry.operations
|
|
349
440
|
}).build());
|
|
350
441
|
}
|
|
351
|
-
async assertMarkerTableHasSpaceColumn(driver, space) {
|
|
352
|
-
const rows = (await driver.query(`select column_name
|
|
353
|
-
from information_schema.columns
|
|
354
|
-
where table_schema = 'prisma_contract'
|
|
355
|
-
and table_name = 'marker'`)).rows;
|
|
356
|
-
if (rows.length === 0) return;
|
|
357
|
-
if (!rows.every((row) => typeof row.column_name === "string")) return;
|
|
358
|
-
if (rows.some((row) => row.column_name === "space")) return;
|
|
359
|
-
rethrowMarkerReadError(/* @__PURE__ */ new Error("column \"space\" does not exist"), {
|
|
360
|
-
space,
|
|
361
|
-
markerLocation: POSTGRES_MARKER_TABLE
|
|
362
|
-
});
|
|
363
|
-
}
|
|
364
442
|
async readMarkerResult(driver, space) {
|
|
365
443
|
const lower = (query) => this.lower(query, { contract: void 0 });
|
|
366
444
|
if ((await execute(lower, driver, infoSchemaTables.select(infoSchemaTables.table_schema).where(infoSchemaTables.table_schema.eq("prisma_contract").and(infoSchemaTables.table_name.eq("marker"))).build())).length === 0) return { kind: "no-table" };
|
|
367
|
-
await this.assertMarkerTableHasSpaceColumn(driver, space);
|
|
368
445
|
const row = (await execute(lower, driver, marker.select(marker.core_hash, marker.profile_hash, marker.contract_json, marker.canonical_version, marker.updated_at, marker.app_tag, marker.meta, marker.invariants).where(marker.space.eq(space)).build()))[0];
|
|
369
446
|
if (!row) return { kind: "absent" };
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
447
|
+
try {
|
|
448
|
+
return {
|
|
449
|
+
kind: "present",
|
|
450
|
+
record: parseContractMarkerRow(decodePostgresMarkerRow(row, space))
|
|
451
|
+
};
|
|
452
|
+
} catch (error) {
|
|
453
|
+
rethrowMarkerReadError(error, {
|
|
454
|
+
space,
|
|
455
|
+
markerLocation: POSTGRES_MARKER_TABLE
|
|
456
|
+
});
|
|
457
|
+
}
|
|
374
458
|
}
|
|
375
459
|
/**
|
|
376
460
|
* Introspects a Postgres database schema and returns a raw SqlSchemaIR.
|
|
@@ -397,20 +481,26 @@ var PostgresControlAdapter = class {
|
|
|
397
481
|
* @returns Promise resolving to SqlSchemaIR representing the live database schema
|
|
398
482
|
*/
|
|
399
483
|
async introspect(driver, contract, schema = "public") {
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
484
|
+
return readWithDefaultOutputSettings(driver, async () => {
|
|
485
|
+
const declaredTables = extractContractTableNames(contract);
|
|
486
|
+
const declaredTablesBySchema = declaredTables.size > 0 ? await this.resolveNamespaceSchemas(driver, declaredTables) : /* @__PURE__ */ new Map([[schema, {
|
|
487
|
+
tables: /* @__PURE__ */ new Set(),
|
|
488
|
+
namespaceIds: []
|
|
489
|
+
}]]);
|
|
490
|
+
const contractColumnsOf = contractColumns(contract);
|
|
491
|
+
const namespaces = {};
|
|
492
|
+
let pgVersion = "unknown";
|
|
493
|
+
for (const [resolved, declaredHere] of declaredTablesBySchema) {
|
|
494
|
+
const { namespace, pgVersion: version } = await this.introspectSchema(driver, resolved, declaredHere.tables, (table, column) => contractColumnsOf.columnOf(declaredHere.namespaceIds, table, column));
|
|
495
|
+
namespaces[resolved] = namespace;
|
|
496
|
+
pgVersion = version;
|
|
497
|
+
}
|
|
498
|
+
return new PostgresDatabaseSchemaNode({
|
|
499
|
+
namespaces,
|
|
500
|
+
roles: await this.introspectRoles(driver),
|
|
501
|
+
existingSchemas: await this.listExistingSchemas(driver),
|
|
502
|
+
pgVersion
|
|
503
|
+
});
|
|
414
504
|
});
|
|
415
505
|
}
|
|
416
506
|
/**
|
|
@@ -444,19 +534,44 @@ var PostgresControlAdapter = class {
|
|
|
444
534
|
ORDER BY nspname`)).rows.map((row) => row.nspname);
|
|
445
535
|
}
|
|
446
536
|
/**
|
|
447
|
-
*
|
|
448
|
-
* mapping `UNBOUND_NAMESPACE_ID` to the connection's `current_schema()`
|
|
449
|
-
* and de-duplicating. The caller introspects one namespace node per
|
|
450
|
-
* resolved schema — there is no flat cross-schema merge, so two schemas
|
|
451
|
-
* holding a same-named table no longer collide.
|
|
537
|
+
* Reads a column's reported default: a function or SQL NULL as itself, and a literal with the column's codec, when the contract declares the column. A literal of a column the contract does not declare keeps only its raw text. When the contract's default is an expression that writes a literal, the codec reads that literal too, for the diff to compare the two values.
|
|
452
538
|
*/
|
|
453
|
-
async
|
|
454
|
-
const
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
539
|
+
async readReportedDefault(rawDefault, many, column) {
|
|
540
|
+
const reported = readPostgresDefault(rawDefault, many);
|
|
541
|
+
if (reported.kind === "function") return { resolvedDefault: reported };
|
|
542
|
+
if (reported.kind === "null") return { resolvedDefault: {
|
|
543
|
+
kind: "literal",
|
|
544
|
+
value: null
|
|
545
|
+
} };
|
|
546
|
+
const codec = column === void 0 ? void 0 : codecForRef(this.codecRegistry, column.codecRef);
|
|
547
|
+
if (codec === void 0) return {};
|
|
548
|
+
const expression = column?.defaultExpression;
|
|
549
|
+
const written = expression === void 0 ? void 0 : readPostgresDefault(expression, many);
|
|
550
|
+
return readColumnDefault(codec, {
|
|
551
|
+
literal: reported.literal,
|
|
552
|
+
raw: rawDefault
|
|
553
|
+
}, expression !== void 0 && written?.kind === "literal" ? {
|
|
554
|
+
literal: written.literal,
|
|
555
|
+
expression
|
|
556
|
+
} : void 0);
|
|
557
|
+
}
|
|
558
|
+
async resolveNamespaceSchemas(driver, declaredTables) {
|
|
559
|
+
const bySchema = /* @__PURE__ */ new Map();
|
|
560
|
+
for (const [id, tableNames] of declaredTables) {
|
|
561
|
+
const resolved = id === UNBOUND_NAMESPACE_ID ? await this.currentSchema(driver) : id;
|
|
562
|
+
const declared = bySchema.get(resolved) ?? {
|
|
563
|
+
tables: /* @__PURE__ */ new Set(),
|
|
564
|
+
namespaceIds: []
|
|
565
|
+
};
|
|
566
|
+
for (const name of tableNames) declared.tables.add(name);
|
|
567
|
+
declared.namespaceIds.push(id);
|
|
568
|
+
bySchema.set(resolved, declared);
|
|
569
|
+
}
|
|
570
|
+
return bySchema;
|
|
571
|
+
}
|
|
572
|
+
async currentSchema(driver) {
|
|
573
|
+
const { rows } = await driver.query("SELECT current_schema() AS current_schema");
|
|
574
|
+
return rows[0]?.current_schema ?? "public";
|
|
460
575
|
}
|
|
461
576
|
/**
|
|
462
577
|
* Introspects a single Postgres schema and returns the namespace node for
|
|
@@ -464,7 +579,7 @@ var PostgresControlAdapter = class {
|
|
|
464
579
|
* alongside the cluster-scoped Postgres version. Used by `introspect` as
|
|
465
580
|
* the per-namespace walk.
|
|
466
581
|
*/
|
|
467
|
-
async introspectSchema(driver, schema) {
|
|
582
|
+
async introspectSchema(driver, schema, declaredTables, contractColumnOf) {
|
|
468
583
|
const tablesResult = await driver.query(`SELECT table_name
|
|
469
584
|
FROM information_schema.tables
|
|
470
585
|
WHERE table_schema = $1
|
|
@@ -481,7 +596,11 @@ var PostgresControlAdapter = class {
|
|
|
481
596
|
numeric_scale,
|
|
482
597
|
column_default,
|
|
483
598
|
format_type(a.atttypid, a.atttypmod) AS formatted_type,
|
|
484
|
-
a.attidentity
|
|
599
|
+
a.attidentity,
|
|
600
|
+
format_type(COALESCE(et.oid, t.oid), a.atttypmod) AS reported_text,
|
|
601
|
+
COALESCE(et.typtype, t.typtype) AS reported_typtype,
|
|
602
|
+
tns.nspname AS reported_type_schema,
|
|
603
|
+
COALESCE(et.typname, t.typname) AS reported_type_name
|
|
485
604
|
FROM information_schema.columns c
|
|
486
605
|
JOIN pg_catalog.pg_class cl
|
|
487
606
|
ON cl.relname = c.table_name
|
|
@@ -493,6 +612,12 @@ var PostgresControlAdapter = class {
|
|
|
493
612
|
AND a.attname = c.column_name
|
|
494
613
|
AND a.attnum > 0
|
|
495
614
|
AND NOT a.attisdropped
|
|
615
|
+
JOIN pg_catalog.pg_type t
|
|
616
|
+
ON t.oid = a.atttypid
|
|
617
|
+
LEFT JOIN pg_catalog.pg_type et
|
|
618
|
+
ON et.typarray = t.oid
|
|
619
|
+
JOIN pg_catalog.pg_namespace tns
|
|
620
|
+
ON tns.oid = COALESCE(et.typnamespace, t.typnamespace)
|
|
496
621
|
WHERE c.table_schema = $1
|
|
497
622
|
ORDER BY c.table_name, c.ordinal_position`, [schema]);
|
|
498
623
|
const pkResult = await driver.query(`SELECT
|
|
@@ -623,31 +748,38 @@ var PostgresControlAdapter = class {
|
|
|
623
748
|
const tableName = tableRow.table_name;
|
|
624
749
|
const columns = {};
|
|
625
750
|
for (const colRow of columnsByTable.get(tableName) ?? []) {
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
751
|
+
const reportedType = colRow.reported_text ? reportedSqlType({
|
|
752
|
+
text: colRow.reported_text,
|
|
753
|
+
typtype: colRow.reported_typtype,
|
|
754
|
+
schema: colRow.reported_type_schema,
|
|
755
|
+
name: colRow.reported_type_name
|
|
756
|
+
}) : void 0;
|
|
757
|
+
const { typeText, many } = introspectedTypeText({
|
|
758
|
+
formattedType: colRow.formatted_type,
|
|
759
|
+
informationSchemaType: colRow.data_type,
|
|
760
|
+
udtName: colRow.udt_name,
|
|
761
|
+
characterMaximumLength: colRow.character_maximum_length,
|
|
762
|
+
numericPrecision: colRow.numeric_precision,
|
|
763
|
+
numericScale: colRow.numeric_scale,
|
|
764
|
+
...reportedType?.kind === "enum" ? { enumType: {
|
|
765
|
+
schema: colRow.reported_type_schema,
|
|
766
|
+
name: colRow.reported_type_name
|
|
767
|
+
} } : {}
|
|
768
|
+
});
|
|
638
769
|
const rawDefault = colRow.column_default ?? void 0;
|
|
639
|
-
const
|
|
770
|
+
const readDefault = colRow.attidentity === "a" || colRow.attidentity === "d" ? { resolvedDefault: {
|
|
640
771
|
kind: "function",
|
|
641
772
|
expression: "autoincrement()"
|
|
642
|
-
} : rawDefault !== void 0 ?
|
|
773
|
+
} } : rawDefault !== void 0 ? await this.readReportedDefault(rawDefault, many === true, contractColumnOf(tableName, colRow.column_name)) : {};
|
|
643
774
|
columns[colRow.column_name] = {
|
|
644
775
|
name: colRow.column_name,
|
|
645
|
-
|
|
776
|
+
typeText,
|
|
646
777
|
nullable: colRow.is_nullable === "YES",
|
|
647
778
|
...ifDefined("default", rawDefault),
|
|
648
779
|
...ifDefined("many", many),
|
|
649
|
-
|
|
650
|
-
...ifDefined("
|
|
780
|
+
...readDefault,
|
|
781
|
+
...ifDefined("reportedType", reportedType),
|
|
782
|
+
...reportedType === void 0 ? {} : resolveIntrospectedColumnType(reportedType, this.declaredDataTypes)
|
|
651
783
|
};
|
|
652
784
|
}
|
|
653
785
|
const pkRows = [...pksByTable.get(tableName) ?? []];
|
|
@@ -674,10 +806,10 @@ var PostgresControlAdapter = class {
|
|
|
674
806
|
});
|
|
675
807
|
}
|
|
676
808
|
const foreignKeys = Array.from(foreignKeysMap.values()).map((fk) => ({
|
|
677
|
-
columns:
|
|
809
|
+
columns: freezeStringArray(fk.columns),
|
|
678
810
|
referencedTable: fk.referencedTable,
|
|
679
811
|
referencedSchema: fk.referencedSchema,
|
|
680
|
-
referencedColumns:
|
|
812
|
+
referencedColumns: freezeStringArray(fk.referencedColumns),
|
|
681
813
|
name: fk.name,
|
|
682
814
|
...ifDefined("onDelete", mapReferentialAction(fk.deleteRule)),
|
|
683
815
|
...ifDefined("onUpdate", mapReferentialAction(fk.updateRule)),
|
|
@@ -695,7 +827,7 @@ var PostgresControlAdapter = class {
|
|
|
695
827
|
});
|
|
696
828
|
}
|
|
697
829
|
const uniques = Array.from(uniquesMap.values()).map((uq) => ({
|
|
698
|
-
columns:
|
|
830
|
+
columns: freezeStringArray(uq.columns),
|
|
699
831
|
name: uq.name,
|
|
700
832
|
dependsOn: postgresColumnDependsOn(schema, tableName, uq.columns)
|
|
701
833
|
}));
|
|
@@ -802,11 +934,14 @@ var PostgresControlAdapter = class {
|
|
|
802
934
|
ORDER BY c.relname`, [schema]);
|
|
803
935
|
const rlsEnabledByTable = new Map(rlsEnabledResult.rows.map((row) => [row.tablename, row.rls_enabled]));
|
|
804
936
|
const tables = {};
|
|
805
|
-
for (const [tableName, input] of Object.entries(tableInputs))
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
937
|
+
for (const [tableName, input] of Object.entries(tableInputs)) {
|
|
938
|
+
if (OTHER_TOOL_MIGRATION_TABLES.has(tableName) && !declaredTables.has(tableName)) continue;
|
|
939
|
+
tables[tableName] = new PostgresTableSchemaNode({
|
|
940
|
+
...input,
|
|
941
|
+
policies: policiesByTable.get(tableName) ?? [],
|
|
942
|
+
rlsEnabled: rlsEnabledByTable.get(tableName) ?? false
|
|
943
|
+
});
|
|
944
|
+
}
|
|
810
945
|
return {
|
|
811
946
|
namespace: new PostgresNamespaceSchemaNode({
|
|
812
947
|
schemaName: schema,
|
|
@@ -824,70 +959,24 @@ var PostgresControlAdapter = class {
|
|
|
824
959
|
}
|
|
825
960
|
};
|
|
826
961
|
/**
|
|
827
|
-
* Normalises a `name[]` column value from
|
|
962
|
+
* Normalises a `name[]` column value from Postgres catalog views such as
|
|
963
|
+
* `pg_policies.roles` and aggregate queries over `pg_enum.enumlabel`.
|
|
828
964
|
*
|
|
829
|
-
*
|
|
830
|
-
*
|
|
831
|
-
*
|
|
832
|
-
*
|
|
965
|
+
* Control-plane queries use the Postgres driver's raw-text parser policy for
|
|
966
|
+
* array OIDs, so this helper accepts raw Postgres array literals only. A native
|
|
967
|
+
* JS array at this boundary means the caller bypassed target-owned framing and
|
|
968
|
+
* is rejected rather than normalized as a second representation.
|
|
833
969
|
*
|
|
834
|
-
* The
|
|
970
|
+
* The parser honors Postgres array-literal quoting: an element
|
|
835
971
|
* containing a comma, quote, backslash, brace, or significant whitespace is
|
|
836
972
|
* emitted double-quoted with `\"` / `\\` escapes, and unquoted elements are
|
|
837
973
|
* whitespace-trimmed — so a label like `in progress` or `say "hi"` parses to
|
|
838
974
|
* its true value instead of being split or kept escaped.
|
|
839
975
|
*/
|
|
840
976
|
function parsePgNameArray(value) {
|
|
841
|
-
if (Array.isArray(value))
|
|
977
|
+
if (Array.isArray(value)) throw new TypeError(`expected raw text for a Postgres array, got ${typeof value}`);
|
|
842
978
|
if (typeof value !== "string") return [];
|
|
843
|
-
|
|
844
|
-
if (!trimmed.startsWith("{") || !trimmed.endsWith("}")) return [];
|
|
845
|
-
const inner = trimmed.slice(1, -1);
|
|
846
|
-
if (inner === "") return [];
|
|
847
|
-
const elements = [];
|
|
848
|
-
let current = "";
|
|
849
|
-
let inQuotes = false;
|
|
850
|
-
let wasQuoted = false;
|
|
851
|
-
const pushCurrent = () => {
|
|
852
|
-
elements.push(wasQuoted ? current : current.trim());
|
|
853
|
-
current = "";
|
|
854
|
-
wasQuoted = false;
|
|
855
|
-
};
|
|
856
|
-
let i = 0;
|
|
857
|
-
while (i < inner.length) {
|
|
858
|
-
const char = inner.charAt(i);
|
|
859
|
-
if (inQuotes) {
|
|
860
|
-
if (char === "\\") {
|
|
861
|
-
current += inner[i + 1] ?? "";
|
|
862
|
-
i += 2;
|
|
863
|
-
continue;
|
|
864
|
-
}
|
|
865
|
-
if (char === "\"") {
|
|
866
|
-
inQuotes = false;
|
|
867
|
-
i++;
|
|
868
|
-
continue;
|
|
869
|
-
}
|
|
870
|
-
current += char;
|
|
871
|
-
i++;
|
|
872
|
-
continue;
|
|
873
|
-
}
|
|
874
|
-
if (char === "\"") {
|
|
875
|
-
inQuotes = true;
|
|
876
|
-
wasQuoted = true;
|
|
877
|
-
i++;
|
|
878
|
-
continue;
|
|
879
|
-
}
|
|
880
|
-
if (char === ",") {
|
|
881
|
-
pushCurrent();
|
|
882
|
-
i++;
|
|
883
|
-
continue;
|
|
884
|
-
}
|
|
885
|
-
current += char;
|
|
886
|
-
i++;
|
|
887
|
-
}
|
|
888
|
-
if (inQuotes) return [];
|
|
889
|
-
pushCurrent();
|
|
890
|
-
return elements;
|
|
979
|
+
return parsePostgresListText(value).map((entry) => String(entry));
|
|
891
980
|
}
|
|
892
981
|
/**
|
|
893
982
|
* Maps `pg_policies.cmd` text values to the `RlsPolicyOperation` union.
|
|
@@ -903,37 +992,29 @@ function mapPgCmd(cmd) {
|
|
|
903
992
|
default: return "all";
|
|
904
993
|
}
|
|
905
994
|
}
|
|
995
|
+
function isRecord(value) {
|
|
996
|
+
return typeof value === "object" && value !== null;
|
|
997
|
+
}
|
|
998
|
+
function freezeStringArray(values) {
|
|
999
|
+
return Object.freeze([...values]);
|
|
1000
|
+
}
|
|
906
1001
|
/**
|
|
907
|
-
*
|
|
908
|
-
* or returns an empty array when no contract (or no storage / namespaces)
|
|
909
|
-
* is present. Used by `PostgresControlAdapter.introspect` to decide
|
|
910
|
-
* between the multi-namespace walk and the single-schema fallback.
|
|
1002
|
+
* The table names a contract's storage declares, keyed by namespace id. Empty when no contract (or no storage / namespaces) is present, which makes `PostgresControlAdapter.introspect` fall back to the single-schema walk.
|
|
911
1003
|
*/
|
|
912
|
-
function
|
|
913
|
-
if (contract
|
|
914
|
-
const storage = contract
|
|
915
|
-
if (storage
|
|
916
|
-
const namespaces = storage
|
|
917
|
-
if (namespaces
|
|
918
|
-
return Object.
|
|
1004
|
+
function extractContractTableNames(contract) {
|
|
1005
|
+
if (!isRecord(contract)) return /* @__PURE__ */ new Map();
|
|
1006
|
+
const storage = contract["storage"];
|
|
1007
|
+
if (!isRecord(storage)) return /* @__PURE__ */ new Map();
|
|
1008
|
+
const namespaces = storage["namespaces"];
|
|
1009
|
+
if (!isRecord(namespaces)) return /* @__PURE__ */ new Map();
|
|
1010
|
+
return new Map(Object.entries(namespaces).map(([id, namespace]) => [id, declaredTableNames(namespace)]));
|
|
919
1011
|
}
|
|
920
|
-
function
|
|
921
|
-
if (
|
|
922
|
-
|
|
923
|
-
if (
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
if (formattedType === "double precision") return "float8";
|
|
927
|
-
if (formattedType === "boolean") return "bool";
|
|
928
|
-
if (formattedType.startsWith("varchar")) return formattedType.replace("varchar", "character varying");
|
|
929
|
-
if (formattedType.startsWith("bpchar")) return formattedType.replace("bpchar", "character");
|
|
930
|
-
if (formattedType.startsWith("varbit")) return formattedType.replace("varbit", "bit varying");
|
|
931
|
-
if (dataType === "timestamp with time zone" || udtName === "timestamptz") return formattedType.replace("timestamp", "timestamptz").replace(" with time zone", "").trim();
|
|
932
|
-
if (dataType === "timestamp without time zone" || udtName === "timestamp") return formattedType.replace(" without time zone", "").trim();
|
|
933
|
-
if (dataType === "time with time zone" || udtName === "timetz") return formattedType.replace("time", "timetz").replace(" with time zone", "").trim();
|
|
934
|
-
if (dataType === "time without time zone" || udtName === "time") return formattedType.replace(" without time zone", "").trim();
|
|
935
|
-
if (formattedType.startsWith("\"") && formattedType.endsWith("\"")) return formattedType.slice(1, -1);
|
|
936
|
-
return formattedType;
|
|
1012
|
+
function declaredTableNames(namespace) {
|
|
1013
|
+
if (!isRecord(namespace)) return [];
|
|
1014
|
+
const entries = namespace["entries"];
|
|
1015
|
+
if (!isRecord(entries)) return [];
|
|
1016
|
+
const tables = entries["table"];
|
|
1017
|
+
return isRecord(tables) ? Object.keys(tables) : [];
|
|
937
1018
|
}
|
|
938
1019
|
const PG_REFERENTIAL_ACTION_MAP = {
|
|
939
1020
|
"NO ACTION": "noAction",
|
|
@@ -947,9 +1028,12 @@ const PG_REFERENTIAL_ACTION_MAP = {
|
|
|
947
1028
|
* Returns undefined for 'NO ACTION' (the database default) to keep the IR sparse.
|
|
948
1029
|
* Throws for unrecognized rules to prevent silent data loss.
|
|
949
1030
|
*/
|
|
1031
|
+
function isPgReferentialActionRule(rule) {
|
|
1032
|
+
return Object.hasOwn(PG_REFERENTIAL_ACTION_MAP, rule);
|
|
1033
|
+
}
|
|
950
1034
|
function mapReferentialAction(rule) {
|
|
1035
|
+
if (!isPgReferentialActionRule(rule)) throw adapterError("CONTRACT.INTROSPECTION_UNSUPPORTED", `Unknown PostgreSQL referential action rule: "${rule}". Expected one of: NO ACTION, RESTRICT, CASCADE, SET NULL, SET DEFAULT.`, { meta: { rule } });
|
|
951
1036
|
const mapped = PG_REFERENTIAL_ACTION_MAP[rule];
|
|
952
|
-
if (mapped === void 0) throw adapterError("CONTRACT.INTROSPECTION_UNSUPPORTED", `Unknown PostgreSQL referential action rule: "${rule}". Expected one of: NO ACTION, RESTRICT, CASCADE, SET NULL, SET DEFAULT.`, { meta: { rule } });
|
|
953
1037
|
if (mapped === "noAction") return void 0;
|
|
954
1038
|
return mapped;
|
|
955
1039
|
}
|
|
@@ -1012,9 +1096,13 @@ function postgresColumnDependsOn(namespaceId, tableName, columns) {
|
|
|
1012
1096
|
* Returns `undefined` when the input is null/empty (no WITH clause).
|
|
1013
1097
|
*/
|
|
1014
1098
|
function parsePgReloptions(reloptions, indexName) {
|
|
1015
|
-
if (
|
|
1099
|
+
if (Array.isArray(reloptions)) throw new TypeError(`expected raw text for a Postgres array, got ${typeof reloptions}`);
|
|
1100
|
+
if (reloptions === null || reloptions === void 0) return;
|
|
1101
|
+
if (typeof reloptions !== "string") return;
|
|
1102
|
+
const entries = parsePostgresListText(reloptions).map((entry) => String(entry));
|
|
1103
|
+
if (entries.length === 0) return;
|
|
1016
1104
|
const result = {};
|
|
1017
|
-
for (const entry of
|
|
1105
|
+
for (const entry of entries) {
|
|
1018
1106
|
const eq = entry.indexOf("=");
|
|
1019
1107
|
if (eq === -1) throw adapterError("CONTRACT.INTROSPECTION_UNSUPPORTED", `Postgres introspection: malformed reloption entry "${entry}" on index "${indexName}" (expected "key=value")`, { meta: {
|
|
1020
1108
|
entry,
|
|
@@ -1038,62 +1126,142 @@ function groupBy(items, key) {
|
|
|
1038
1126
|
}
|
|
1039
1127
|
return map;
|
|
1040
1128
|
}
|
|
1041
|
-
function pgIsTextLikeNativeType(
|
|
1042
|
-
return
|
|
1129
|
+
function pgIsTextLikeNativeType(typeText) {
|
|
1130
|
+
return typeText === "text" || typeText === "varchar" || typeText.startsWith("varchar(") || typeText === "character varying" || typeText.startsWith("character varying(") || typeText === "char" || typeText.startsWith("char(") || typeText === "character" || typeText.startsWith("character(");
|
|
1043
1131
|
}
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1132
|
+
const INTROSPECTION_OUTPUT_SETTINGS = {
|
|
1133
|
+
timeZone: "UTC",
|
|
1134
|
+
dateStyle: "ISO, MDY",
|
|
1135
|
+
intervalStyle: "postgres",
|
|
1136
|
+
byteaOutput: "hex"
|
|
1137
|
+
};
|
|
1138
|
+
async function readOutputSettings(driver) {
|
|
1139
|
+
const { rows } = await driver.query(`SELECT current_setting('TimeZone') AS "timeZone",
|
|
1140
|
+
current_setting('DateStyle') AS "dateStyle",
|
|
1141
|
+
current_setting('IntervalStyle') AS "intervalStyle",
|
|
1142
|
+
current_setting('bytea_output') AS "byteaOutput"`);
|
|
1143
|
+
return rows[0];
|
|
1144
|
+
}
|
|
1145
|
+
async function applyOutputSettings(driver, settings, local) {
|
|
1146
|
+
await driver.query(`SELECT set_config('TimeZone', $1, $5),
|
|
1147
|
+
set_config('DateStyle', $2, $5),
|
|
1148
|
+
set_config('IntervalStyle', $3, $5),
|
|
1149
|
+
set_config('bytea_output', $4, $5)`, [
|
|
1150
|
+
settings.timeZone,
|
|
1151
|
+
settings.dateStyle,
|
|
1152
|
+
settings.intervalStyle,
|
|
1153
|
+
settings.byteaOutput,
|
|
1154
|
+
local
|
|
1155
|
+
]);
|
|
1049
1156
|
}
|
|
1050
|
-
function
|
|
1051
|
-
|
|
1052
|
-
|
|
1157
|
+
function sameOutputSettings(a, b) {
|
|
1158
|
+
return a?.timeZone === b.timeZone && a.dateStyle === b.dateStyle && a.intervalStyle === b.intervalStyle && a.byteaOutput === b.byteaOutput;
|
|
1159
|
+
}
|
|
1160
|
+
/**
|
|
1161
|
+
* Runs `read` with the settings that shape printed values pinned to Postgres's defaults, then
|
|
1162
|
+
* restores the caller's. Postgres prints a `timestamptz` default in the session time zone, and
|
|
1163
|
+
* dates, intervals and bytea in the session styles, so pinning them gives the same text whatever
|
|
1164
|
+
* the server, the role, or the caller set.
|
|
1165
|
+
*
|
|
1166
|
+
* The settings are first set locally. A local setting outlives its own statement only inside a
|
|
1167
|
+
* transaction, so reading them back tells the two cases apart. Inside the caller's transaction they
|
|
1168
|
+
* are set and restored locally, so the caller's session values return when it commits; outside
|
|
1169
|
+
* one they are set and restored for the session. When `read` fails, its error is the one thrown;
|
|
1170
|
+
* inside a transaction the failure aborts it, and the caller's rollback restores the settings.
|
|
1171
|
+
*/
|
|
1172
|
+
async function readWithDefaultOutputSettings(driver, read) {
|
|
1173
|
+
const callerSettings = await readOutputSettings(driver);
|
|
1174
|
+
if (callerSettings === void 0) return read();
|
|
1175
|
+
await applyOutputSettings(driver, INTROSPECTION_OUTPUT_SETTINGS, true);
|
|
1176
|
+
const local = sameOutputSettings(await readOutputSettings(driver), INTROSPECTION_OUTPUT_SETTINGS);
|
|
1177
|
+
if (!local) await applyOutputSettings(driver, INTROSPECTION_OUTPUT_SETTINGS, false);
|
|
1178
|
+
const restore = () => applyOutputSettings(driver, callerSettings, local);
|
|
1179
|
+
let result;
|
|
1180
|
+
try {
|
|
1181
|
+
result = await read();
|
|
1182
|
+
} catch (error) {
|
|
1183
|
+
await restore().catch(() => void 0);
|
|
1184
|
+
throw error;
|
|
1185
|
+
}
|
|
1186
|
+
await restore();
|
|
1187
|
+
return result;
|
|
1188
|
+
}
|
|
1189
|
+
/**
|
|
1190
|
+
* A value as DDL writes it: `ARRAY[...]` of each element's literal, cast to the list type, for a list written to a list type, and otherwise the value's literal, cast to the column type where PostgreSQL would read it as another type.
|
|
1191
|
+
*/
|
|
1192
|
+
function pgInlineLiteral(wire, typeText, where) {
|
|
1193
|
+
if (Array.isArray(wire) && typeText.endsWith("[]")) {
|
|
1194
|
+
if (wire.length === 0) return "'{}'";
|
|
1195
|
+
return `ARRAY[${wire.map((element) => pgLiteralText(element, where)).join(", ")}]::${typeText}`;
|
|
1196
|
+
}
|
|
1197
|
+
const text = pgLiteralText(wire, where);
|
|
1198
|
+
return pgLiteralNeedsCast(wire, typeText) ? `${text}::${typeText}` : text;
|
|
1053
1199
|
}
|
|
1054
|
-
function
|
|
1200
|
+
function pgLiteralNeedsCast(wire, typeText) {
|
|
1201
|
+
if (typeof wire === "number") return !Number.isFinite(wire);
|
|
1202
|
+
if (typeof wire === "string" || wire instanceof Date) return !pgIsTextLikeNativeType(typeText);
|
|
1203
|
+
return typeof wire === "object" && wire !== null;
|
|
1204
|
+
}
|
|
1205
|
+
/** A value's literal without a cast: SQL NULL, a bare number or boolean, or quoted text. */
|
|
1206
|
+
function pgLiteralText(wire, where) {
|
|
1055
1207
|
if (wire === null) return "NULL";
|
|
1056
1208
|
if (typeof wire === "boolean") return wire ? "true" : "false";
|
|
1057
|
-
if (typeof wire === "number") {
|
|
1058
|
-
if (!Number.isFinite(wire)) throw adapterError("CONTRACT.DEFAULT_INVALID", `pgRenderDdlExecuteRequest: non-finite number wire value ${String(wire)} cannot be emitted as a DEFAULT literal for native type "${nativeType}"`, { meta: { nativeType } });
|
|
1059
|
-
return String(wire);
|
|
1060
|
-
}
|
|
1209
|
+
if (typeof wire === "number") return Number.isFinite(wire) ? String(wire) : `'${String(wire)}'`;
|
|
1061
1210
|
if (typeof wire === "bigint") return String(wire);
|
|
1062
1211
|
if (wire instanceof Date) {
|
|
1063
|
-
if (Number.isNaN(wire.getTime())) throw adapterError("CONTRACT.DEFAULT_INVALID", `
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
return pgIsTextLikeNativeType(nativeType) ? quoted : `${quoted}::${nativeType}`;
|
|
1212
|
+
if (Number.isNaN(wire.getTime())) throw adapterError("CONTRACT.DEFAULT_INVALID", `Column "${where.table}"."${where.column}" has an invalid Date default`, { meta: {
|
|
1213
|
+
table: where.table,
|
|
1214
|
+
column: where.column,
|
|
1215
|
+
reason: "invalid-date-default"
|
|
1216
|
+
} });
|
|
1217
|
+
return `'${escapeLiteral(wire.toISOString())}'`;
|
|
1070
1218
|
}
|
|
1071
|
-
if (wire
|
|
1072
|
-
if (Array.
|
|
1073
|
-
if (typeof wire === "object") return
|
|
1074
|
-
throw adapterError("CONTRACT.PACK_CONTRIBUTION_INVALID", `pgRenderDdlExecuteRequest: unexpected wire type "${typeof wire}"
|
|
1075
|
-
wireType: typeof wire,
|
|
1076
|
-
nativeType
|
|
1077
|
-
} });
|
|
1219
|
+
if (typeof wire === "string") return `'${escapeLiteral(wire)}'`;
|
|
1220
|
+
if (wire instanceof Uint8Array) return `'\\x${Array.from(wire).map((b) => b.toString(16).padStart(2, "0")).join("")}'`;
|
|
1221
|
+
if (typeof wire === "object") return `'${escapeLiteral(JSON.stringify(wire))}'`;
|
|
1222
|
+
throw adapterError("CONTRACT.PACK_CONTRIBUTION_INVALID", `pgRenderDdlExecuteRequest: unexpected wire type "${typeof wire}"`, { meta: { wireType: typeof wire } });
|
|
1078
1223
|
}
|
|
1079
|
-
|
|
1224
|
+
const SERIAL_FAMILY_TYPES = /* @__PURE__ */ new Set([
|
|
1225
|
+
"serial",
|
|
1226
|
+
"serial4",
|
|
1227
|
+
"bigserial",
|
|
1228
|
+
"serial8",
|
|
1229
|
+
"smallserial",
|
|
1230
|
+
"serial2"
|
|
1231
|
+
]);
|
|
1232
|
+
async function pgRenderDdlColumnDefault(def, typeText, codecLookup, codecRef, where) {
|
|
1080
1233
|
if (def.kind === "function") {
|
|
1081
|
-
if (def.expression === "autoincrement()")
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
if (codecRef !== void 0) {
|
|
1085
|
-
const codec = codecLookup.get(codecRef.codecId);
|
|
1086
|
-
if (codec !== void 0) {
|
|
1087
|
-
const value = def.value instanceof Date ? def.value : codec.decodeJson(def.value);
|
|
1088
|
-
return `DEFAULT ${pgInlineLiteral(await codec.encode(value, {}), nativeType)}`;
|
|
1234
|
+
if (def.expression.text === "autoincrement()") {
|
|
1235
|
+
if (!SERIAL_FAMILY_TYPES.has(typeText.toLowerCase())) throw postgresError("CONTRACT.DEFAULT_INVALID", `Column type "${typeText}" has an autoincrement() default but is not a SERIAL-family pseudo-type. Autoincrement columns must declare their type as SERIAL (or SERIAL4), BIGSERIAL (or SERIAL8), or SMALLSERIAL (or SERIAL2) — e.g. col(name, "SERIAL", { default: fn("autoincrement()") }).`, { meta: { typeText } });
|
|
1236
|
+
return "";
|
|
1089
1237
|
}
|
|
1238
|
+
if (checkSqlDefaultText(def.expression.text) !== void 0) throw postgresError("CONTRACT.DEFAULT_INVALID", `Unsafe default expression in contract: "${def.expression.text}". Default expressions must not contain semicolons, SQL comment tokens, dollar-quoting, or subqueries.`, { meta: { expression: def.expression.text } });
|
|
1239
|
+
return `DEFAULT (${renderOpaqueSql(def.expression)})`;
|
|
1090
1240
|
}
|
|
1091
|
-
return `DEFAULT ${pgInlineLiteral(def.value,
|
|
1241
|
+
return `DEFAULT ${pgInlineLiteral(await pgWrittenDefault(def.value, typeText, codecLookup, codecRef, where), typeText, where)}`;
|
|
1092
1242
|
}
|
|
1093
|
-
|
|
1243
|
+
/**
|
|
1244
|
+
* The value DDL writes for a literal default, and for each element of a list default: a value the codec reads as SQL NULL as `null`, and anything else as the codec's wire value (`fromDataTypeValue`, then `toWire`). Without a codec, the value as written.
|
|
1245
|
+
*/
|
|
1246
|
+
async function pgWrittenDefault(value, typeText, codecLookup, codecRef, where) {
|
|
1247
|
+
if (value === null && typeText.endsWith("[]")) return null;
|
|
1248
|
+
if (Array.isArray(value) && typeText.endsWith("[]")) {
|
|
1249
|
+
const encoded = codecRef === void 0 ? void 0 : await encodeListLiteralDefault(codecLookup, codecRef, value, where);
|
|
1250
|
+
return value.map((element, index) => pgWrittenValue(element, encoded?.[index]));
|
|
1251
|
+
}
|
|
1252
|
+
return pgWrittenValue(value, codecRef === void 0 ? void 0 : await encodeLiteralDefault(codecLookup, codecRef, value, where));
|
|
1253
|
+
}
|
|
1254
|
+
function pgWrittenValue(value, encoded) {
|
|
1255
|
+
if (encoded === void 0) return value;
|
|
1256
|
+
return encoded.kind === "sql-null" ? null : encoded.wire;
|
|
1257
|
+
}
|
|
1258
|
+
async function pgRenderDdlColumn(column, codecLookup, table) {
|
|
1094
1259
|
const parts = [quoteIdentifier(column.name), column.type];
|
|
1095
1260
|
if (column.default) {
|
|
1096
|
-
const clause = await pgRenderDdlColumnDefault(column.default, column.type, codecLookup, column.codecRef
|
|
1261
|
+
const clause = await pgRenderDdlColumnDefault(column.default, column.type, codecLookup, column.codecRef, {
|
|
1262
|
+
table,
|
|
1263
|
+
column: column.name
|
|
1264
|
+
});
|
|
1097
1265
|
if (clause.length > 0) parts.push(clause);
|
|
1098
1266
|
}
|
|
1099
1267
|
if (column.notNull) parts.push("NOT NULL");
|
|
@@ -1113,15 +1281,15 @@ function pgRenderDdlConstraint(constraint) {
|
|
|
1113
1281
|
if (constraint.name !== void 0) sql = `CONSTRAINT ${quoteIdentifier(constraint.name)} ${sql}`;
|
|
1114
1282
|
return sql;
|
|
1115
1283
|
}
|
|
1116
|
-
if (constraint.kind === "check-expression") return `CONSTRAINT ${quoteIdentifier(constraint.name)} CHECK (${constraint.expression})`;
|
|
1284
|
+
if (constraint.kind === "check-expression") return `CONSTRAINT ${quoteIdentifier(constraint.name)} CHECK (${renderOpaqueSql(constraint.expression)})`;
|
|
1117
1285
|
const cols = constraint.columns.map(quoteIdentifier).join(", ");
|
|
1118
1286
|
if (constraint.name !== void 0) return `CONSTRAINT ${quoteIdentifier(constraint.name)} UNIQUE (${cols})`;
|
|
1119
1287
|
return `UNIQUE (${cols})`;
|
|
1120
1288
|
}
|
|
1121
1289
|
async function pgRenderCreateTable(node, codecLookup) {
|
|
1122
1290
|
const ifNotExists = node.ifNotExists ? "IF NOT EXISTS " : "";
|
|
1123
|
-
const tableRef =
|
|
1124
|
-
const columnDefs = await Promise.all(node.columns.map((col) => pgRenderDdlColumn(col, codecLookup)));
|
|
1291
|
+
const tableRef = pgQualify(node.schema, node.table);
|
|
1292
|
+
const columnDefs = await Promise.all(node.columns.map((col) => pgRenderDdlColumn(col, codecLookup, node.table)));
|
|
1125
1293
|
const constraintDefs = node.constraints !== void 0 ? node.constraints.map(pgRenderDdlConstraint) : [];
|
|
1126
1294
|
return {
|
|
1127
1295
|
sql: `CREATE TABLE ${ifNotExists}${tableRef} (\n ${[...columnDefs, ...constraintDefs].join(",\n ")}\n)`,
|
|
@@ -1136,46 +1304,47 @@ function pgRenderCreateSchema(node) {
|
|
|
1136
1304
|
}
|
|
1137
1305
|
function pgRenderCreateType(node) {
|
|
1138
1306
|
return {
|
|
1139
|
-
sql: `CREATE TYPE ${
|
|
1307
|
+
sql: `CREATE TYPE ${pgQualify(node.schema, node.name)} AS ENUM (${node.values.map((value) => `'${escapeLiteral(value)}'`).join(", ")})`,
|
|
1140
1308
|
params: []
|
|
1141
1309
|
};
|
|
1142
1310
|
}
|
|
1143
1311
|
function pgRenderDropType(node) {
|
|
1144
1312
|
return {
|
|
1145
|
-
sql: `DROP TYPE ${
|
|
1313
|
+
sql: `DROP TYPE ${pgQualify(node.schema, node.name)}`,
|
|
1146
1314
|
params: []
|
|
1147
1315
|
};
|
|
1148
1316
|
}
|
|
1149
1317
|
async function pgRenderAlterTable(node, codecLookup) {
|
|
1150
|
-
const tableRef =
|
|
1318
|
+
const tableRef = pgQualify(node.schema, node.table);
|
|
1151
1319
|
const actionVisitor = {
|
|
1152
1320
|
async addColumn(action) {
|
|
1153
|
-
return `ADD COLUMN ${await pgRenderDdlColumn(action.column, codecLookup)}`;
|
|
1321
|
+
return `ADD COLUMN ${await pgRenderDdlColumn(action.column, codecLookup, node.table)}`;
|
|
1154
1322
|
},
|
|
1155
1323
|
dropDefault(action) {
|
|
1156
1324
|
return Promise.resolve(`ALTER COLUMN ${quoteIdentifier(action.columnName)} DROP DEFAULT`);
|
|
1325
|
+
},
|
|
1326
|
+
addConstraint(action) {
|
|
1327
|
+
return Promise.resolve(`ADD ${pgRenderDdlConstraint(action.constraint)}`);
|
|
1328
|
+
},
|
|
1329
|
+
alterColumnType(action) {
|
|
1330
|
+
const column = quoteIdentifier(action.columnName);
|
|
1331
|
+
const using = action.using === void 0 ? `${column}::${action.type}` : renderOpaqueSql(action.using);
|
|
1332
|
+
return Promise.resolve(`ALTER COLUMN ${column} TYPE ${action.type} USING ${using}`);
|
|
1157
1333
|
}
|
|
1158
1334
|
};
|
|
1159
1335
|
return {
|
|
1160
|
-
sql: `ALTER TABLE ${tableRef} ${(await Promise.all(node.actions.map((
|
|
1336
|
+
sql: `ALTER TABLE ${tableRef} ${(await Promise.all(node.actions.map((action) => action.accept(actionVisitor)))).join(", ")}`,
|
|
1161
1337
|
params: []
|
|
1162
1338
|
};
|
|
1163
1339
|
}
|
|
1164
|
-
const POLICY_OPERATION_SQL = {
|
|
1165
|
-
select: "SELECT",
|
|
1166
|
-
insert: "INSERT",
|
|
1167
|
-
update: "UPDATE",
|
|
1168
|
-
delete: "DELETE",
|
|
1169
|
-
all: "ALL"
|
|
1170
|
-
};
|
|
1171
1340
|
function pgRenderCreatePolicy(node) {
|
|
1172
1341
|
const tableRef = `${quoteIdentifier(node.schema)}.${quoteIdentifier(node.table)}`;
|
|
1173
1342
|
const permissiveness = node.permissive ? "PERMISSIVE" : "RESTRICTIVE";
|
|
1174
|
-
const command =
|
|
1175
|
-
const roles = node.roles.
|
|
1343
|
+
const command = POLICY_COMMAND_SQL[node.operation];
|
|
1344
|
+
const roles = policyRoleList(node.roles).join(", ");
|
|
1176
1345
|
let sql = `CREATE POLICY ${quoteIdentifier(node.name)} ON ${tableRef} AS ${permissiveness} FOR ${command} TO ${roles}`;
|
|
1177
|
-
if (node.using !== void 0) sql += ` USING (${node.using})`;
|
|
1178
|
-
if (node.withCheck !== void 0) sql += ` WITH CHECK (${node.withCheck})`;
|
|
1346
|
+
if (node.using !== void 0) sql += ` USING (${renderOpaqueSql(node.using)})`;
|
|
1347
|
+
if (node.withCheck !== void 0) sql += ` WITH CHECK (${renderOpaqueSql(node.withCheck)})`;
|
|
1179
1348
|
return {
|
|
1180
1349
|
sql,
|
|
1181
1350
|
params: []
|
|
@@ -1214,11 +1383,11 @@ function pgQualify(schema, name) {
|
|
|
1214
1383
|
return schema === void 0 ? quoteIdentifier(name) : `${quoteIdentifier(schema)}.${quoteIdentifier(name)}`;
|
|
1215
1384
|
}
|
|
1216
1385
|
function pgRenderCreateIndex(node) {
|
|
1217
|
-
const elementList = "columns" in node.elements ? node.elements.columns.map(quoteIdentifier).join(", ") : node.elements.expression;
|
|
1386
|
+
const elementList = "columns" in node.elements ? node.elements.columns.map(quoteIdentifier).join(", ") : renderOpaqueSql(node.elements.expression);
|
|
1218
1387
|
const unique = node.unique ? "UNIQUE " : "";
|
|
1219
1388
|
const using = node.type !== void 0 ? ` USING ${quoteIdentifier(node.type)}` : "";
|
|
1220
1389
|
const withClause = node.options !== void 0 && Object.keys(node.options).length > 0 ? ` WITH (${Object.entries(node.options).map(([key, value]) => `${quoteIdentifier(key)} = ${pgRenderIndexOptionValue(key, value)}`).join(", ")})` : "";
|
|
1221
|
-
const whereClause = node.where !== void 0 ? ` WHERE (${node.where})` : "";
|
|
1390
|
+
const whereClause = node.where !== void 0 ? ` WHERE (${renderOpaqueSql(node.where)})` : "";
|
|
1222
1391
|
return {
|
|
1223
1392
|
sql: `CREATE ${unique}INDEX ${quoteIdentifier(node.name)} ON ${pgQualify(node.schema, node.table)}${using} (${elementList})${withClause}${whereClause}`,
|
|
1224
1393
|
params: []
|
|
@@ -1242,6 +1411,24 @@ function pgRenderDisableRowLevelSecurity(node) {
|
|
|
1242
1411
|
params: []
|
|
1243
1412
|
};
|
|
1244
1413
|
}
|
|
1414
|
+
function pgRenderAlterTableSetSchema(node) {
|
|
1415
|
+
return {
|
|
1416
|
+
sql: `ALTER TABLE ${pgQualify(node.schema, node.table)} SET SCHEMA ${quoteIdentifier(node.to)}`,
|
|
1417
|
+
params: []
|
|
1418
|
+
};
|
|
1419
|
+
}
|
|
1420
|
+
function pgRenderAlterSchemaRename(node) {
|
|
1421
|
+
return {
|
|
1422
|
+
sql: `ALTER SCHEMA ${quoteIdentifier(node.schema)} RENAME TO ${quoteIdentifier(node.to)}`,
|
|
1423
|
+
params: []
|
|
1424
|
+
};
|
|
1425
|
+
}
|
|
1426
|
+
function pgRenderDropSchema(node) {
|
|
1427
|
+
return {
|
|
1428
|
+
sql: `DROP SCHEMA ${quoteIdentifier(node.schema)}`,
|
|
1429
|
+
params: []
|
|
1430
|
+
};
|
|
1431
|
+
}
|
|
1245
1432
|
async function pgRenderDdlExecuteRequest(ast, codecLookup) {
|
|
1246
1433
|
return ast.accept({
|
|
1247
1434
|
createTable: (node) => pgRenderCreateTable(node, codecLookup),
|
|
@@ -1255,10 +1442,20 @@ async function pgRenderDdlExecuteRequest(ast, codecLookup) {
|
|
|
1255
1442
|
createIndex: (node) => Promise.resolve(pgRenderCreateIndex(node)),
|
|
1256
1443
|
dropIndex: (node) => Promise.resolve(pgRenderDropIndex(node)),
|
|
1257
1444
|
alterIndexRename: (node) => Promise.resolve(pgRenderAlterIndexRename(node)),
|
|
1258
|
-
disableRowLevelSecurity: (node) => Promise.resolve(pgRenderDisableRowLevelSecurity(node))
|
|
1445
|
+
disableRowLevelSecurity: (node) => Promise.resolve(pgRenderDisableRowLevelSecurity(node)),
|
|
1446
|
+
alterTableSetSchema: (node) => Promise.resolve(pgRenderAlterTableSetSchema(node)),
|
|
1447
|
+
alterSchemaRename: (node) => Promise.resolve(pgRenderAlterSchemaRename(node)),
|
|
1448
|
+
dropSchema: (node) => Promise.resolve(pgRenderDropSchema(node))
|
|
1259
1449
|
});
|
|
1260
1450
|
}
|
|
1451
|
+
/**
|
|
1452
|
+
* What this adapter adds to every contract it runs: its capabilities and the aggregate overloads it lists. `prisma contract emit` reads them through the adapter's descriptor, and the TypeScript `defineContract` passes them to the contract build.
|
|
1453
|
+
*/
|
|
1454
|
+
const postgresAdapterContractContributions = {
|
|
1455
|
+
capabilities: postgresAdapterCapabilities,
|
|
1456
|
+
types: { aggregateDescriptors: postgresAggregateDescriptors }
|
|
1457
|
+
};
|
|
1261
1458
|
//#endregion
|
|
1262
|
-
export {
|
|
1459
|
+
export { postgresAdapterCapabilities as n, postgresAdapterContractContributions as r, PostgresControlAdapter as t };
|
|
1263
1460
|
|
|
1264
|
-
//# sourceMappingURL=
|
|
1461
|
+
//# sourceMappingURL=contract-contributions-Xz2FpyfI-CeQZqHKf.mjs.map
|