@prisma/orm-target-postgres 8.0.0-rc.2-dev.3 → 8.0.0-rc.20-dev.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +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
|
@@ -0,0 +1,1342 @@
|
|
|
1
|
+
import { A as PG_TIME_TEMPORAL_CODEC_ID, C as PG_TIMESTAMPTZ_DATE_CODEC_ID, D as PG_TIMESTAMP_TEMPORAL_CODEC_ID, E as PG_TIMESTAMP_STRING_CODEC_ID, O as PG_TIMETZ_CODEC_ID, T as PG_TIMESTAMPTZ_TEMPORAL_CODEC_ID, a as PG_DATE_STRING_CODEC_ID, k as PG_TIME_STRING_CODEC_ID, o as PG_DATE_TEMPORAL_CODEC_ID, s as PG_ENUM_CODEC_ID, w as PG_TIMESTAMPTZ_STRING_CODEC_ID } from "./codec-ids-BMhEpFwv-B8Zh0s_Q.mjs";
|
|
2
|
+
import { c as postgresError } from "./errors-BrhQYgdL-IvZHPjwL.mjs";
|
|
3
|
+
import { t as PostgresNativeEnum } from "./postgres-native-enum-CdP3b_-R-DgG3pi5p.mjs";
|
|
4
|
+
import { N as requireTemporal } from "./codecs-CRl9-i_r-Co-bgYl3.mjs";
|
|
5
|
+
import { f as weightGroupsOf, i as POSTGRES_TEXT_SEARCH_LANGUAGES, l as fullTextIndexProblems, n as FULL_TEXT_INDEX_TYPE, o as describeFullTextIndexProblem } from "./full-text-index-definition-BPxQQBuC-VLyQ1kEL.mjs";
|
|
6
|
+
import { a as PostgresRlsPolicySchema, i as PostgresRlsPolicy, n as PostgresRlsEnablement, o as PostgresRole, r as PostgresRlsEnablementSchema, s as PostgresRoleSchema, t as PostgresNativeEnumSchema } from "./postgres-schema-C6w1rzOF-D1fdwqRx.mjs";
|
|
7
|
+
import { t as postgresCodecTraitsOf } from "./postgres-codec-traits-CnP5Bjxp-Dxdgv0TI.mjs";
|
|
8
|
+
import { r as computeContentHash } from "./canonicalize-RdxoUHao-FTTkizfe.mjs";
|
|
9
|
+
import { blindCast } from "@prisma/orm-framework/utils/casts";
|
|
10
|
+
import { UNBOUND_NAMESPACE_ID } from "@prisma/orm-framework/components/ir";
|
|
11
|
+
import { assertDefined, invariant } from "@prisma/orm-framework/utils/assertions";
|
|
12
|
+
import { assertWireNamePrefixLength, normalizeSqlBody } from "@prisma/orm-family-sql/schema-ir/naming";
|
|
13
|
+
import { ifDefined } from "@prisma/orm-framework/utils/defined";
|
|
14
|
+
import { sqlTargetTypeConstructors, temporalCodecPresetWithPrecision, temporalStringAuthoringPresets } from "@prisma/orm-family-sql/family/pack";
|
|
15
|
+
import { TIMESTAMP_NOW_GENERATOR_ID, temporalAuthoringPresets, temporalCodecPreset, temporalTypeAliases } from "@prisma/orm-framework/components/authoring";
|
|
16
|
+
import { blockAttribute, bool, dataTypeValue, entityRef, fieldRef, identifier, leafDiagnostic, list, mapBlock, modelAttribute, oneOf, optional, str, structBlock } from "@prisma/orm-framework/psl-parser";
|
|
17
|
+
import { exactNameBodyWarning } from "@prisma/orm-family-sql/contract/index-naming";
|
|
18
|
+
import { SQL_EXPRESSION_DATA_TYPE_ID, requireSqlExpression, sqlTextFromStored } from "@prisma/orm-family-sql/contract/sql-expression";
|
|
19
|
+
import { singleGeneratorBinding } from "@prisma/orm-framework/components/components";
|
|
20
|
+
//#region ../../../3-targets/postgres/1-target/dist/authoring-SbdvmVJh.mjs
|
|
21
|
+
/**
|
|
22
|
+
* The Postgres "now" generators, one per date and time codec except `pg/timestamptz-date@1`, which uses the framework's `timestampNow`. All read the clock through `Date.now()` and write UTC. The time generators round down to their `precision` param. The string generators are named after the codec they serve and write the text PostgreSQL prints in a UTC session, with milliseconds and no trailing zeros in the fraction.
|
|
23
|
+
*/
|
|
24
|
+
const INSTANT_NOW_GENERATOR_ID = "instantNow";
|
|
25
|
+
const PLAIN_DATE_TIME_NOW_GENERATOR_ID = "plainDateTimeNow";
|
|
26
|
+
const PLAIN_DATE_NOW_GENERATOR_ID = "plainDateNow";
|
|
27
|
+
const PLAIN_TIME_NOW_GENERATOR_ID = "plainTimeNow";
|
|
28
|
+
const TIMESTAMP_STRING_NOW_GENERATOR_ID = "timestampStringNow";
|
|
29
|
+
const TIMESTAMPTZ_STRING_NOW_GENERATOR_ID = "timestamptzStringNow";
|
|
30
|
+
const DATE_STRING_NOW_GENERATOR_ID = "dateStringNow";
|
|
31
|
+
const TIME_STRING_NOW_GENERATOR_ID = "timeStringNow";
|
|
32
|
+
const TIMETZ_NOW_GENERATOR_ID = "timetzNow";
|
|
33
|
+
const UTC_OFFSET = "+00";
|
|
34
|
+
const MAX_TIME_PRECISION = 6;
|
|
35
|
+
function fractionDigitsOf(params) {
|
|
36
|
+
const precision = params?.["precision"];
|
|
37
|
+
return typeof precision === "number" ? precision : MAX_TIME_PRECISION;
|
|
38
|
+
}
|
|
39
|
+
function utcNow(fractionDigits = MAX_TIME_PRECISION) {
|
|
40
|
+
const iso = new Date(Date.now()).toISOString();
|
|
41
|
+
const [wholeSeconds = "", fraction = ""] = iso.slice(11, -1).split(".");
|
|
42
|
+
const kept = fraction.slice(0, fractionDigits).replace(/0+$/, "");
|
|
43
|
+
return {
|
|
44
|
+
date: iso.slice(0, 10),
|
|
45
|
+
time: kept === "" ? wholeSeconds : `${wholeSeconds}.${kept}`
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
/** Rounds down, so PostgreSQL stores the value without rounding it up, which can reach `24:00:00`. */
|
|
49
|
+
function truncateTime(time, fractionDigits) {
|
|
50
|
+
if (fractionDigits <= 0) return time.round({
|
|
51
|
+
smallestUnit: "second",
|
|
52
|
+
roundingMode: "trunc"
|
|
53
|
+
});
|
|
54
|
+
const smallestUnit = fractionDigits <= 3 ? "millisecond" : "microsecond";
|
|
55
|
+
const unitDigits = fractionDigits <= 3 ? 3 : 6;
|
|
56
|
+
return time.round({
|
|
57
|
+
smallestUnit,
|
|
58
|
+
roundingIncrement: 10 ** (unitDigits - Math.min(fractionDigits, unitDigits)),
|
|
59
|
+
roundingMode: "trunc"
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
function utcDateTimeNow(generatorId) {
|
|
63
|
+
return requireTemporal({ generatorId }).Instant.fromEpochMilliseconds(Date.now()).toZonedDateTimeISO("UTC");
|
|
64
|
+
}
|
|
65
|
+
function instantNow() {
|
|
66
|
+
return requireTemporal({ generatorId: INSTANT_NOW_GENERATOR_ID }).Instant.fromEpochMilliseconds(Date.now());
|
|
67
|
+
}
|
|
68
|
+
function plainDateTimeNow() {
|
|
69
|
+
return utcDateTimeNow(PLAIN_DATE_TIME_NOW_GENERATOR_ID).toPlainDateTime();
|
|
70
|
+
}
|
|
71
|
+
function plainDateNow() {
|
|
72
|
+
return utcDateTimeNow(PLAIN_DATE_NOW_GENERATOR_ID).toPlainDate();
|
|
73
|
+
}
|
|
74
|
+
function plainTimeNow(params) {
|
|
75
|
+
return truncateTime(utcDateTimeNow(PLAIN_TIME_NOW_GENERATOR_ID).toPlainTime(), fractionDigitsOf(params));
|
|
76
|
+
}
|
|
77
|
+
function timestampStringNow() {
|
|
78
|
+
const { date, time } = utcNow();
|
|
79
|
+
return `${date} ${time}`;
|
|
80
|
+
}
|
|
81
|
+
function timestamptzStringNow() {
|
|
82
|
+
return `${timestampStringNow()}${UTC_OFFSET}`;
|
|
83
|
+
}
|
|
84
|
+
function dateStringNow() {
|
|
85
|
+
return utcNow().date;
|
|
86
|
+
}
|
|
87
|
+
function timeStringNow(params) {
|
|
88
|
+
return utcNow(fractionDigitsOf(params)).time;
|
|
89
|
+
}
|
|
90
|
+
function timetzNow(params) {
|
|
91
|
+
return `${timeStringNow(params)}${UTC_OFFSET}`;
|
|
92
|
+
}
|
|
93
|
+
const postgresNowGenerators = [
|
|
94
|
+
{
|
|
95
|
+
id: INSTANT_NOW_GENERATOR_ID,
|
|
96
|
+
generate: instantNow
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
id: PLAIN_DATE_TIME_NOW_GENERATOR_ID,
|
|
100
|
+
generate: plainDateTimeNow
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
id: PLAIN_DATE_NOW_GENERATOR_ID,
|
|
104
|
+
generate: plainDateNow
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
id: PLAIN_TIME_NOW_GENERATOR_ID,
|
|
108
|
+
generate: plainTimeNow
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
id: TIMESTAMP_STRING_NOW_GENERATOR_ID,
|
|
112
|
+
generate: timestampStringNow
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
id: TIMESTAMPTZ_STRING_NOW_GENERATOR_ID,
|
|
116
|
+
generate: timestamptzStringNow
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
id: DATE_STRING_NOW_GENERATOR_ID,
|
|
120
|
+
generate: dateStringNow
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
id: TIME_STRING_NOW_GENERATOR_ID,
|
|
124
|
+
generate: timeStringNow
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
id: TIMETZ_NOW_GENERATOR_ID,
|
|
128
|
+
generate: timetzNow
|
|
129
|
+
}
|
|
130
|
+
];
|
|
131
|
+
function postgresNowGeneratorControlDescriptors() {
|
|
132
|
+
return postgresNowGenerators.map(({ id }) => ({ id }));
|
|
133
|
+
}
|
|
134
|
+
/** The "now" generator for each codec that has one. The `temporal` field presets read it. */
|
|
135
|
+
const postgresNowGeneratorIds = {
|
|
136
|
+
[PG_DATE_TEMPORAL_CODEC_ID]: PLAIN_DATE_NOW_GENERATOR_ID,
|
|
137
|
+
[PG_DATE_STRING_CODEC_ID]: DATE_STRING_NOW_GENERATOR_ID,
|
|
138
|
+
[PG_TIME_TEMPORAL_CODEC_ID]: PLAIN_TIME_NOW_GENERATOR_ID,
|
|
139
|
+
[PG_TIME_STRING_CODEC_ID]: TIME_STRING_NOW_GENERATOR_ID,
|
|
140
|
+
[PG_TIMETZ_CODEC_ID]: TIMETZ_NOW_GENERATOR_ID,
|
|
141
|
+
[PG_TIMESTAMP_TEMPORAL_CODEC_ID]: PLAIN_DATE_TIME_NOW_GENERATOR_ID,
|
|
142
|
+
[PG_TIMESTAMP_STRING_CODEC_ID]: TIMESTAMP_STRING_NOW_GENERATOR_ID,
|
|
143
|
+
[PG_TIMESTAMPTZ_TEMPORAL_CODEC_ID]: INSTANT_NOW_GENERATOR_ID,
|
|
144
|
+
[PG_TIMESTAMPTZ_STRING_CODEC_ID]: TIMESTAMPTZ_STRING_NOW_GENERATOR_ID,
|
|
145
|
+
[PG_TIMESTAMPTZ_DATE_CODEC_ID]: TIMESTAMP_NOW_GENERATOR_ID
|
|
146
|
+
};
|
|
147
|
+
new Map(Object.entries(postgresNowGeneratorIds));
|
|
148
|
+
/** The codecs whose "now" generator takes the column's precision, so that it rounds down where PostgreSQL would round a time up to `24:00:00`. */
|
|
149
|
+
const postgresNowGeneratorTakesPrecision = {
|
|
150
|
+
[PG_TIME_TEMPORAL_CODEC_ID]: true,
|
|
151
|
+
[PG_TIME_STRING_CODEC_ID]: true,
|
|
152
|
+
[PG_TIMETZ_CODEC_ID]: true
|
|
153
|
+
};
|
|
154
|
+
/** The `now` generator function bound to each Postgres date and time codec, with the column's precision on the three time codecs. */
|
|
155
|
+
const postgresNowGeneratorFunction = {
|
|
156
|
+
name: "now",
|
|
157
|
+
bindings: Object.entries(postgresNowGeneratorIds).map(([codecId, generatorId]) => singleGeneratorBinding({
|
|
158
|
+
codecIds: [codecId],
|
|
159
|
+
generatorId,
|
|
160
|
+
paramsFromField: (column) => {
|
|
161
|
+
const precision = column.typeParams?.["precision"];
|
|
162
|
+
return Object.hasOwn(postgresNowGeneratorTakesPrecision, codecId) && typeof precision === "number" ? { precision } : void 0;
|
|
163
|
+
}
|
|
164
|
+
}))
|
|
165
|
+
};
|
|
166
|
+
/** The data type of every size argument on Postgres, such as a length or a precision: a typmod is an `int4`. */
|
|
167
|
+
const PG_SIZE_TYPE = "pg/int4";
|
|
168
|
+
/**
|
|
169
|
+
* The base PSL scalars as zero-arg type constructors in the unified authoring
|
|
170
|
+
* channel. Each names a codec; the column's database type is its data type's.
|
|
171
|
+
*
|
|
172
|
+
* The type position is the only storage decider: a mutation-default generator
|
|
173
|
+
* (`@onCreate(uuid())`) never re-picks a column's storage.
|
|
174
|
+
*/
|
|
175
|
+
const postgresScalarAuthoringTypes = {
|
|
176
|
+
String: {
|
|
177
|
+
kind: "typeConstructor",
|
|
178
|
+
inferred: true,
|
|
179
|
+
documentation: "Variable-length text stored as PostgreSQL text.",
|
|
180
|
+
output: { codecId: "pg/text@1" }
|
|
181
|
+
},
|
|
182
|
+
Boolean: {
|
|
183
|
+
kind: "typeConstructor",
|
|
184
|
+
inferred: true,
|
|
185
|
+
documentation: "A true or false value stored as PostgreSQL boolean.",
|
|
186
|
+
output: { codecId: "pg/bool@1" }
|
|
187
|
+
},
|
|
188
|
+
Int: {
|
|
189
|
+
kind: "typeConstructor",
|
|
190
|
+
inferred: true,
|
|
191
|
+
documentation: "A signed 32-bit integer represented as a JavaScript number.",
|
|
192
|
+
output: { codecId: "pg/int4@1" }
|
|
193
|
+
},
|
|
194
|
+
BigInt: {
|
|
195
|
+
kind: "typeConstructor",
|
|
196
|
+
inferred: true,
|
|
197
|
+
documentation: "A signed 64-bit integer represented as a JavaScript bigint.",
|
|
198
|
+
output: { codecId: "pg/int8@1" }
|
|
199
|
+
},
|
|
200
|
+
Float: {
|
|
201
|
+
kind: "typeConstructor",
|
|
202
|
+
inferred: true,
|
|
203
|
+
documentation: "A double-precision floating-point number.",
|
|
204
|
+
output: { codecId: "pg/float8@1" }
|
|
205
|
+
},
|
|
206
|
+
Decimal: {
|
|
207
|
+
kind: "typeConstructor",
|
|
208
|
+
documentation: "An exact decimal value stored as PostgreSQL numeric.",
|
|
209
|
+
output: { codecId: "pg/numeric@1" }
|
|
210
|
+
},
|
|
211
|
+
DateTime: {
|
|
212
|
+
kind: "typeConstructor",
|
|
213
|
+
documentation: "An instant stored as PostgreSQL timestamptz and represented as Temporal.Instant.",
|
|
214
|
+
output: { codecId: "pg/timestamptz-temporal@1" }
|
|
215
|
+
},
|
|
216
|
+
Json: {
|
|
217
|
+
kind: "typeConstructor",
|
|
218
|
+
inferred: true,
|
|
219
|
+
documentation: "A JSON value stored as PostgreSQL json.",
|
|
220
|
+
output: { codecId: "pg/json@1" }
|
|
221
|
+
},
|
|
222
|
+
Jsonb: {
|
|
223
|
+
kind: "typeConstructor",
|
|
224
|
+
inferred: true,
|
|
225
|
+
documentation: "A JSON value stored in PostgreSQL binary jsonb format.",
|
|
226
|
+
output: { codecId: "pg/jsonb@1" }
|
|
227
|
+
},
|
|
228
|
+
Bytes: {
|
|
229
|
+
kind: "typeConstructor",
|
|
230
|
+
inferred: true,
|
|
231
|
+
documentation: "Binary data stored as PostgreSQL bytea.",
|
|
232
|
+
output: { codecId: "pg/bytea@1" }
|
|
233
|
+
}
|
|
234
|
+
};
|
|
235
|
+
const postgresNativeAuthoringTypes = {
|
|
236
|
+
VarChar: {
|
|
237
|
+
kind: "typeConstructor",
|
|
238
|
+
inferred: true,
|
|
239
|
+
documentation: "Variable-length text with an optional maximum character length.",
|
|
240
|
+
args: [{
|
|
241
|
+
kind: "value",
|
|
242
|
+
dataType: PG_SIZE_TYPE,
|
|
243
|
+
name: "length",
|
|
244
|
+
optional: true
|
|
245
|
+
}],
|
|
246
|
+
output: {
|
|
247
|
+
codecId: "sql/varchar@1",
|
|
248
|
+
typeParams: { length: {
|
|
249
|
+
kind: "arg",
|
|
250
|
+
index: 0
|
|
251
|
+
} }
|
|
252
|
+
}
|
|
253
|
+
},
|
|
254
|
+
Char: {
|
|
255
|
+
kind: "typeConstructor",
|
|
256
|
+
inferred: true,
|
|
257
|
+
documentation: "Fixed-length, blank-padded text with an optional character length.",
|
|
258
|
+
args: [{
|
|
259
|
+
kind: "value",
|
|
260
|
+
dataType: PG_SIZE_TYPE,
|
|
261
|
+
name: "length",
|
|
262
|
+
optional: true
|
|
263
|
+
}],
|
|
264
|
+
output: {
|
|
265
|
+
codecId: "sql/char@1",
|
|
266
|
+
typeParams: { length: {
|
|
267
|
+
kind: "arg",
|
|
268
|
+
index: 0
|
|
269
|
+
} }
|
|
270
|
+
}
|
|
271
|
+
},
|
|
272
|
+
Numeric: {
|
|
273
|
+
kind: "typeConstructor",
|
|
274
|
+
inferred: true,
|
|
275
|
+
documentation: "An exact decimal value with optional precision and scale.",
|
|
276
|
+
args: [{
|
|
277
|
+
kind: "value",
|
|
278
|
+
dataType: PG_SIZE_TYPE,
|
|
279
|
+
name: "precision",
|
|
280
|
+
optional: true
|
|
281
|
+
}, {
|
|
282
|
+
kind: "value",
|
|
283
|
+
dataType: PG_SIZE_TYPE,
|
|
284
|
+
name: "scale",
|
|
285
|
+
optional: true
|
|
286
|
+
}],
|
|
287
|
+
output: {
|
|
288
|
+
codecId: "pg/numeric@1",
|
|
289
|
+
typeParams: {
|
|
290
|
+
precision: {
|
|
291
|
+
kind: "arg",
|
|
292
|
+
index: 0
|
|
293
|
+
},
|
|
294
|
+
scale: {
|
|
295
|
+
kind: "arg",
|
|
296
|
+
index: 1
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
},
|
|
301
|
+
Timestamp: {
|
|
302
|
+
kind: "typeConstructor",
|
|
303
|
+
documentation: "A date and time without a time zone, represented as Temporal.PlainDateTime.",
|
|
304
|
+
args: [{
|
|
305
|
+
kind: "value",
|
|
306
|
+
dataType: PG_SIZE_TYPE,
|
|
307
|
+
name: "precision",
|
|
308
|
+
optional: true
|
|
309
|
+
}],
|
|
310
|
+
output: {
|
|
311
|
+
codecId: "pg/timestamp-temporal@1",
|
|
312
|
+
typeParams: { precision: {
|
|
313
|
+
kind: "arg",
|
|
314
|
+
index: 0
|
|
315
|
+
} }
|
|
316
|
+
}
|
|
317
|
+
},
|
|
318
|
+
Timestamptz: {
|
|
319
|
+
kind: "typeConstructor",
|
|
320
|
+
documentation: "An instant represented as Temporal.Instant, with optional fractional-second precision.",
|
|
321
|
+
args: [{
|
|
322
|
+
kind: "value",
|
|
323
|
+
dataType: PG_SIZE_TYPE,
|
|
324
|
+
name: "precision",
|
|
325
|
+
optional: true
|
|
326
|
+
}],
|
|
327
|
+
output: {
|
|
328
|
+
codecId: "pg/timestamptz-temporal@1",
|
|
329
|
+
typeParams: { precision: {
|
|
330
|
+
kind: "arg",
|
|
331
|
+
index: 0
|
|
332
|
+
} }
|
|
333
|
+
}
|
|
334
|
+
},
|
|
335
|
+
Time: {
|
|
336
|
+
kind: "typeConstructor",
|
|
337
|
+
documentation: "A time of day without a time zone, represented as Temporal.PlainTime.",
|
|
338
|
+
args: [{
|
|
339
|
+
kind: "value",
|
|
340
|
+
dataType: PG_SIZE_TYPE,
|
|
341
|
+
name: "precision",
|
|
342
|
+
optional: true
|
|
343
|
+
}],
|
|
344
|
+
output: {
|
|
345
|
+
codecId: "pg/time-temporal@1",
|
|
346
|
+
typeParams: { precision: {
|
|
347
|
+
kind: "arg",
|
|
348
|
+
index: 0
|
|
349
|
+
} }
|
|
350
|
+
}
|
|
351
|
+
},
|
|
352
|
+
Timetz: {
|
|
353
|
+
kind: "typeConstructor",
|
|
354
|
+
inferred: true,
|
|
355
|
+
documentation: "A time of day with a UTC offset stored as PostgreSQL timetz.",
|
|
356
|
+
args: [{
|
|
357
|
+
kind: "value",
|
|
358
|
+
dataType: PG_SIZE_TYPE,
|
|
359
|
+
name: "precision",
|
|
360
|
+
optional: true
|
|
361
|
+
}],
|
|
362
|
+
output: {
|
|
363
|
+
codecId: "pg/timetz@1",
|
|
364
|
+
typeParams: { precision: {
|
|
365
|
+
kind: "arg",
|
|
366
|
+
index: 0
|
|
367
|
+
} }
|
|
368
|
+
}
|
|
369
|
+
},
|
|
370
|
+
Uuid: {
|
|
371
|
+
kind: "typeConstructor",
|
|
372
|
+
inferred: true,
|
|
373
|
+
documentation: "A universally unique identifier stored as PostgreSQL uuid.",
|
|
374
|
+
output: { codecId: "pg/uuid@1" }
|
|
375
|
+
},
|
|
376
|
+
Inet: {
|
|
377
|
+
kind: "typeConstructor",
|
|
378
|
+
inferred: true,
|
|
379
|
+
documentation: "An IPv4 or IPv6 address with an optional subnet mask.",
|
|
380
|
+
output: { codecId: "pg/inet@1" }
|
|
381
|
+
},
|
|
382
|
+
SmallInt: {
|
|
383
|
+
kind: "typeConstructor",
|
|
384
|
+
inferred: true,
|
|
385
|
+
documentation: "A signed 16-bit integer represented as a JavaScript number.",
|
|
386
|
+
output: { codecId: "pg/int2@1" }
|
|
387
|
+
},
|
|
388
|
+
Real: {
|
|
389
|
+
kind: "typeConstructor",
|
|
390
|
+
inferred: true,
|
|
391
|
+
documentation: "A single-precision floating-point number.",
|
|
392
|
+
output: { codecId: "pg/float4@1" }
|
|
393
|
+
},
|
|
394
|
+
Date: {
|
|
395
|
+
kind: "typeConstructor",
|
|
396
|
+
documentation: "A calendar date represented as Temporal.PlainDate.",
|
|
397
|
+
output: { codecId: "pg/date-temporal@1" }
|
|
398
|
+
},
|
|
399
|
+
DateString: {
|
|
400
|
+
kind: "typeConstructor",
|
|
401
|
+
inferred: true,
|
|
402
|
+
documentation: "A PostgreSQL date represented as database text rather than Temporal.PlainDate.",
|
|
403
|
+
output: { codecId: "pg/date-string@1" }
|
|
404
|
+
},
|
|
405
|
+
TimestampString: {
|
|
406
|
+
kind: "typeConstructor",
|
|
407
|
+
inferred: true,
|
|
408
|
+
documentation: "A timestamp without a time zone represented as PostgreSQL text.",
|
|
409
|
+
args: [{
|
|
410
|
+
kind: "value",
|
|
411
|
+
dataType: PG_SIZE_TYPE,
|
|
412
|
+
name: "precision",
|
|
413
|
+
optional: true
|
|
414
|
+
}],
|
|
415
|
+
output: {
|
|
416
|
+
codecId: "pg/timestamp-string@1",
|
|
417
|
+
typeParams: { precision: {
|
|
418
|
+
kind: "arg",
|
|
419
|
+
index: 0
|
|
420
|
+
} }
|
|
421
|
+
}
|
|
422
|
+
},
|
|
423
|
+
TimestamptzJsDate: {
|
|
424
|
+
kind: "typeConstructor",
|
|
425
|
+
documentation: "An instant stored as PostgreSQL timestamptz and represented as a JavaScript Date.",
|
|
426
|
+
args: [{
|
|
427
|
+
kind: "value",
|
|
428
|
+
dataType: PG_SIZE_TYPE,
|
|
429
|
+
name: "precision",
|
|
430
|
+
optional: true
|
|
431
|
+
}],
|
|
432
|
+
output: {
|
|
433
|
+
codecId: PG_TIMESTAMPTZ_DATE_CODEC_ID,
|
|
434
|
+
typeParams: { precision: {
|
|
435
|
+
kind: "arg",
|
|
436
|
+
index: 0
|
|
437
|
+
} }
|
|
438
|
+
}
|
|
439
|
+
},
|
|
440
|
+
TimestamptzString: {
|
|
441
|
+
kind: "typeConstructor",
|
|
442
|
+
inferred: true,
|
|
443
|
+
documentation: "A timestamp with time zone represented as PostgreSQL text.",
|
|
444
|
+
args: [{
|
|
445
|
+
kind: "value",
|
|
446
|
+
dataType: PG_SIZE_TYPE,
|
|
447
|
+
name: "precision",
|
|
448
|
+
optional: true
|
|
449
|
+
}],
|
|
450
|
+
output: {
|
|
451
|
+
codecId: "pg/timestamptz-string@1",
|
|
452
|
+
typeParams: { precision: {
|
|
453
|
+
kind: "arg",
|
|
454
|
+
index: 0
|
|
455
|
+
} }
|
|
456
|
+
}
|
|
457
|
+
},
|
|
458
|
+
TimeString: {
|
|
459
|
+
kind: "typeConstructor",
|
|
460
|
+
inferred: true,
|
|
461
|
+
documentation: "A time of day without a time zone represented as PostgreSQL text.",
|
|
462
|
+
args: [{
|
|
463
|
+
kind: "value",
|
|
464
|
+
dataType: PG_SIZE_TYPE,
|
|
465
|
+
name: "precision",
|
|
466
|
+
optional: true
|
|
467
|
+
}],
|
|
468
|
+
output: {
|
|
469
|
+
codecId: "pg/time-string@1",
|
|
470
|
+
typeParams: { precision: {
|
|
471
|
+
kind: "arg",
|
|
472
|
+
index: 0
|
|
473
|
+
} }
|
|
474
|
+
}
|
|
475
|
+
},
|
|
476
|
+
Bit: {
|
|
477
|
+
kind: "typeConstructor",
|
|
478
|
+
inferred: true,
|
|
479
|
+
documentation: "A fixed-length bit string with an optional length in bits.",
|
|
480
|
+
args: [{
|
|
481
|
+
kind: "value",
|
|
482
|
+
dataType: PG_SIZE_TYPE,
|
|
483
|
+
name: "length",
|
|
484
|
+
optional: true
|
|
485
|
+
}],
|
|
486
|
+
output: {
|
|
487
|
+
codecId: "pg/bit@1",
|
|
488
|
+
typeParams: { length: {
|
|
489
|
+
kind: "arg",
|
|
490
|
+
index: 0
|
|
491
|
+
} }
|
|
492
|
+
}
|
|
493
|
+
},
|
|
494
|
+
VarBit: {
|
|
495
|
+
kind: "typeConstructor",
|
|
496
|
+
inferred: true,
|
|
497
|
+
documentation: "A variable-length bit string with an optional maximum length in bits.",
|
|
498
|
+
args: [{
|
|
499
|
+
kind: "value",
|
|
500
|
+
dataType: PG_SIZE_TYPE,
|
|
501
|
+
name: "length",
|
|
502
|
+
optional: true
|
|
503
|
+
}],
|
|
504
|
+
output: {
|
|
505
|
+
codecId: "pg/varbit@1",
|
|
506
|
+
typeParams: { length: {
|
|
507
|
+
kind: "arg",
|
|
508
|
+
index: 0
|
|
509
|
+
} }
|
|
510
|
+
}
|
|
511
|
+
},
|
|
512
|
+
Interval: {
|
|
513
|
+
kind: "typeConstructor",
|
|
514
|
+
inferred: true,
|
|
515
|
+
documentation: "A span of time stored as PostgreSQL interval, with optional fractional-second precision.",
|
|
516
|
+
args: [{
|
|
517
|
+
kind: "value",
|
|
518
|
+
dataType: PG_SIZE_TYPE,
|
|
519
|
+
name: "precision",
|
|
520
|
+
optional: true
|
|
521
|
+
}],
|
|
522
|
+
output: {
|
|
523
|
+
codecId: "pg/interval@1",
|
|
524
|
+
typeParams: { precision: {
|
|
525
|
+
kind: "arg",
|
|
526
|
+
index: 0
|
|
527
|
+
} }
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
};
|
|
531
|
+
/**
|
|
532
|
+
* The base scalars and native types as type constructors. The target contributes them, so PSL and the TypeScript builder's `type.*` see the same names.
|
|
533
|
+
*/
|
|
534
|
+
const postgresScalarAndNativeTypeConstructors = {
|
|
535
|
+
...postgresScalarAuthoringTypes,
|
|
536
|
+
...postgresNativeAuthoringTypes
|
|
537
|
+
};
|
|
538
|
+
const PSL_POLICY_INVALID_MAP = "PSL_POLICY_INVALID_MAP";
|
|
539
|
+
const PSL_FULL_TEXT_INDEX_TOO_MANY_GROUPS = "PSL_FULL_TEXT_INDEX_TOO_MANY_GROUPS";
|
|
540
|
+
const PSL_FULL_TEXT_INDEX_EMPTY_GROUP = "PSL_FULL_TEXT_INDEX_EMPTY_GROUP";
|
|
541
|
+
const PSL_FULL_TEXT_INDEX_DUPLICATE_FIELD = "PSL_FULL_TEXT_INDEX_DUPLICATE_FIELD";
|
|
542
|
+
const PSL_FULL_TEXT_INDEX_REQUIRES_NAME = "PSL_FULL_TEXT_INDEX_REQUIRES_NAME";
|
|
543
|
+
const PSL_FULL_TEXT_INDEX_NAME_XOR_MAP = "PSL_FULL_TEXT_INDEX_NAME_XOR_MAP";
|
|
544
|
+
const PSL_FULL_TEXT_INDEX_TEXT_FIELD = "PSL_FULL_TEXT_INDEX_TEXT_FIELD";
|
|
545
|
+
const PSL_NATIVE_ENUM_DUPLICATE_MEMBER_VALUE = "PSL_NATIVE_ENUM_DUPLICATE_MEMBER_VALUE";
|
|
546
|
+
const PSL_NATIVE_ENUM_MISSING_MEMBERS = "PSL_NATIVE_ENUM_MISSING_MEMBERS";
|
|
547
|
+
const PSL_ROLE_BLOCK_OUTSIDE_UNBOUND_NAMESPACE = "PSL_ROLE_BLOCK_OUTSIDE_UNBOUND_NAMESPACE";
|
|
548
|
+
/**
|
|
549
|
+
* `pg.enum(<ref>)` registers as an ordinary type constructor whose sole
|
|
550
|
+
* positional argument names a `native_enum` entity instead of carrying a
|
|
551
|
+
* literal value. The interpreter resolves the ref to the `native_enum`
|
|
552
|
+
* entity generically (driven by `entityRefArg`); the `pg/enum@1` codec
|
|
553
|
+
* descriptor's `columnFromEntity` hook (see `codecs.ts`) converts that
|
|
554
|
+
* entity into the column's `typeParams`. The column's type name comes from the
|
|
555
|
+
* `pg/enum` data type, which renders `typeParams.typeName`.
|
|
556
|
+
*/
|
|
557
|
+
const postgresAuthoringTypes = {
|
|
558
|
+
.../* @__PURE__ */ sqlTargetTypeConstructors({ sizeType: PG_SIZE_TYPE }),
|
|
559
|
+
BigIntNumber: {
|
|
560
|
+
kind: "typeConstructor",
|
|
561
|
+
documentation: "A PostgreSQL 64-bit integer represented as a JavaScript number within its safe integer range.",
|
|
562
|
+
output: { codecId: "pg/int8number@1" }
|
|
563
|
+
},
|
|
564
|
+
UnboundedInt: {
|
|
565
|
+
kind: "typeConstructor",
|
|
566
|
+
documentation: "An arbitrary-precision integer stored as PostgreSQL numeric and represented as bigint.",
|
|
567
|
+
output: { codecId: "pg/unboundedint@1" }
|
|
568
|
+
},
|
|
569
|
+
pg: { enum: {
|
|
570
|
+
kind: "typeConstructor",
|
|
571
|
+
inferred: true,
|
|
572
|
+
entityRefArg: {
|
|
573
|
+
index: 0,
|
|
574
|
+
entityKind: "native_enum"
|
|
575
|
+
},
|
|
576
|
+
output: { codecId: PG_ENUM_CODEC_ID }
|
|
577
|
+
} },
|
|
578
|
+
temporal: /* @__PURE__ */ postgresTemporalTypeAliases()
|
|
579
|
+
};
|
|
580
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
581
|
+
function postgresTemporalTypeAliases() {
|
|
582
|
+
const temporal = temporalTypeAliases({ codecId: PG_TIMESTAMPTZ_TEMPORAL_CODEC_ID }, "a Temporal.Instant");
|
|
583
|
+
const string = temporalTypeAliases({ codecId: PG_TIMESTAMPTZ_STRING_CODEC_ID }, "a string, the timestamp as Postgres writes it, such as 2024-01-02 03:04:05+00");
|
|
584
|
+
const jsDate = temporalTypeAliases({ codecId: PG_TIMESTAMPTZ_DATE_CODEC_ID }, "a JavaScript Date");
|
|
585
|
+
return {
|
|
586
|
+
...temporal,
|
|
587
|
+
CreatedAtString: string.CreatedAt,
|
|
588
|
+
UpdatedAtString: string.UpdatedAt,
|
|
589
|
+
CreatedAtJsDate: jsDate.CreatedAt,
|
|
590
|
+
UpdatedAtJsDate: jsDate.UpdatedAt
|
|
591
|
+
};
|
|
592
|
+
}
|
|
593
|
+
const policyTargetParam = {
|
|
594
|
+
type: entityRef({ kind: "model" }),
|
|
595
|
+
documentation: "The model protected by this policy; it must declare @@rls."
|
|
596
|
+
};
|
|
597
|
+
const policyRolesParam = {
|
|
598
|
+
type: optional(list(oneOf(entityRef({
|
|
599
|
+
kind: "block",
|
|
600
|
+
keyword: "role"
|
|
601
|
+
}), identifier()))),
|
|
602
|
+
documentation: "The database roles to which this policy applies."
|
|
603
|
+
};
|
|
604
|
+
function policyUsingParam(ctx) {
|
|
605
|
+
return {
|
|
606
|
+
type: optional(dataTypeValue(SQL_EXPRESSION_DATA_TYPE_ID, ctx.dataTypes)),
|
|
607
|
+
documentation: "A SQL predicate controlling which rows this policy permits."
|
|
608
|
+
};
|
|
609
|
+
}
|
|
610
|
+
function policyWithCheckParam(ctx) {
|
|
611
|
+
return {
|
|
612
|
+
type: optional(dataTypeValue(SQL_EXPRESSION_DATA_TYPE_ID, ctx.dataTypes)),
|
|
613
|
+
documentation: "A SQL predicate checking rows being written by this policy."
|
|
614
|
+
};
|
|
615
|
+
}
|
|
616
|
+
const policyPermissiveParam = {
|
|
617
|
+
type: optional(bool()),
|
|
618
|
+
documentation: "Whether the policy is permissive (combined with OR) rather than restrictive (combined with AND)."
|
|
619
|
+
};
|
|
620
|
+
function policyUsingOnlySpec(ctx) {
|
|
621
|
+
return structBlock({ parameters: {
|
|
622
|
+
target: policyTargetParam,
|
|
623
|
+
roles: policyRolesParam,
|
|
624
|
+
using: policyUsingParam(ctx),
|
|
625
|
+
permissive: policyPermissiveParam
|
|
626
|
+
} });
|
|
627
|
+
}
|
|
628
|
+
function policyWithCheckOnlySpec(ctx) {
|
|
629
|
+
return structBlock({ parameters: {
|
|
630
|
+
target: policyTargetParam,
|
|
631
|
+
roles: policyRolesParam,
|
|
632
|
+
withCheck: policyWithCheckParam(ctx),
|
|
633
|
+
permissive: policyPermissiveParam
|
|
634
|
+
} });
|
|
635
|
+
}
|
|
636
|
+
function policyBothPredicatesSpec(ctx) {
|
|
637
|
+
return structBlock({ parameters: {
|
|
638
|
+
target: policyTargetParam,
|
|
639
|
+
roles: policyRolesParam,
|
|
640
|
+
using: policyUsingParam(ctx),
|
|
641
|
+
withCheck: policyWithCheckParam(ctx),
|
|
642
|
+
permissive: policyPermissiveParam
|
|
643
|
+
} });
|
|
644
|
+
}
|
|
645
|
+
function roleSpec() {
|
|
646
|
+
return structBlock({ parameters: {} });
|
|
647
|
+
}
|
|
648
|
+
function nativeEnumSpec() {
|
|
649
|
+
return mapBlock({ value: {
|
|
650
|
+
type: str(),
|
|
651
|
+
documentation: "The member value stored in the database enum type."
|
|
652
|
+
} });
|
|
653
|
+
}
|
|
654
|
+
/**
|
|
655
|
+
* The block keyword that authors each row-level security operation. The keyword is the operation, so
|
|
656
|
+
* a policy block has no `operation` parameter. The reader looks a block's operation up here, and
|
|
657
|
+
* `contract infer` and `contract print` look up the keyword to write.
|
|
658
|
+
*/
|
|
659
|
+
const POLICY_BLOCK_KEYWORDS = {
|
|
660
|
+
select: "policy_select",
|
|
661
|
+
insert: "policy_insert",
|
|
662
|
+
update: "policy_update",
|
|
663
|
+
delete: "policy_delete",
|
|
664
|
+
all: "policy_all"
|
|
665
|
+
};
|
|
666
|
+
function isRlsPolicyOperation(value) {
|
|
667
|
+
return Object.hasOwn(POLICY_BLOCK_KEYWORDS, value);
|
|
668
|
+
}
|
|
669
|
+
/** The operation a `policy_<operation>` block keyword authors, or `undefined` for another keyword. */
|
|
670
|
+
function policyOperationOfKeyword(keyword) {
|
|
671
|
+
return Object.keys(POLICY_BLOCK_KEYWORDS).filter(isRlsPolicyOperation).find((operation) => POLICY_BLOCK_KEYWORDS[operation] === keyword);
|
|
672
|
+
}
|
|
673
|
+
/**
|
|
674
|
+
* Assembles a {@link PostgresRlsPolicy} from lowered inputs: normalizes the
|
|
675
|
+
* predicates, computes the content-hash wire name, and constructs the frozen
|
|
676
|
+
* entity. The single hash-assembly body shared by the PSL block lowering
|
|
677
|
+
* ({@link lowerRlsPolicyFromBlock}) and the TS entity-handle lowering
|
|
678
|
+
* ({@link postgresLowerEntityHandles}) so the two surfaces cannot drift.
|
|
679
|
+
*/
|
|
680
|
+
function buildRlsPolicyEntity(input) {
|
|
681
|
+
const permissive = input.permissive ?? true;
|
|
682
|
+
const wireHash = computeContentHash({
|
|
683
|
+
...ifDefined("using", input.using !== void 0 ? normalizeSqlBody(input.using) : void 0),
|
|
684
|
+
...ifDefined("withCheck", input.withCheck !== void 0 ? normalizeSqlBody(input.withCheck) : void 0),
|
|
685
|
+
roles: input.roles,
|
|
686
|
+
operation: input.operation,
|
|
687
|
+
permissive
|
|
688
|
+
});
|
|
689
|
+
return new PostgresRlsPolicy({
|
|
690
|
+
naming: {
|
|
691
|
+
kind: "wire",
|
|
692
|
+
prefix: input.prefix,
|
|
693
|
+
hash: wireHash
|
|
694
|
+
},
|
|
695
|
+
tableName: input.tableName,
|
|
696
|
+
namespaceId: input.namespaceId,
|
|
697
|
+
operation: input.operation,
|
|
698
|
+
roles: input.roles,
|
|
699
|
+
using: input.using,
|
|
700
|
+
withCheck: input.withCheck,
|
|
701
|
+
permissive
|
|
702
|
+
});
|
|
703
|
+
}
|
|
704
|
+
function lowerRlsPolicyFromBlock(block, ctx) {
|
|
705
|
+
const prefix = block.name;
|
|
706
|
+
const operation = policyOperationOfKeyword(block.keyword) ?? "select";
|
|
707
|
+
const target = block.resolvedModelRefs?.["target"];
|
|
708
|
+
assertDefined(target, `lowerRlsPolicyFromBlock: policy "${block.name}" reached the factory without a projected \`target\` coordinate; the interpreter projects checked model references before invoking entity factories.`);
|
|
709
|
+
const roles = block.values.roles === void 0 ? [] : block.values.roles.map((role) => typeof role === "string" ? role : role.declaration.name).sort();
|
|
710
|
+
const using = block.values.using === void 0 ? void 0 : sqlTextFromStored(block.values.using.value.value);
|
|
711
|
+
const withCheck = block.values.withCheck === void 0 ? void 0 : sqlTextFromStored(block.values.withCheck.value.value);
|
|
712
|
+
const permissive = block.values.permissive ?? true;
|
|
713
|
+
const mapAttr = block.attributes["map"];
|
|
714
|
+
if (mapAttr !== void 0) {
|
|
715
|
+
const exactName = mapAttr.args["name"];
|
|
716
|
+
invariant(typeof exactName === "string", "@@map on a policy block parses one string argument");
|
|
717
|
+
ctx.warnings?.push(exactNameBodyWarning("policy", exactName));
|
|
718
|
+
return new PostgresRlsPolicy({
|
|
719
|
+
naming: {
|
|
720
|
+
kind: "exact",
|
|
721
|
+
name: exactName
|
|
722
|
+
},
|
|
723
|
+
tableName: target.tableName,
|
|
724
|
+
namespaceId: target.namespaceId,
|
|
725
|
+
operation,
|
|
726
|
+
roles,
|
|
727
|
+
using,
|
|
728
|
+
withCheck,
|
|
729
|
+
permissive
|
|
730
|
+
});
|
|
731
|
+
}
|
|
732
|
+
return buildRlsPolicyEntity({
|
|
733
|
+
prefix,
|
|
734
|
+
tableName: target.tableName,
|
|
735
|
+
namespaceId: target.namespaceId,
|
|
736
|
+
operation,
|
|
737
|
+
roles,
|
|
738
|
+
...ifDefined("using", using),
|
|
739
|
+
...ifDefined("withCheck", withCheck),
|
|
740
|
+
permissive
|
|
741
|
+
});
|
|
742
|
+
}
|
|
743
|
+
const policyEntityTypeOutput = {
|
|
744
|
+
factory: lowerRlsPolicyFromBlock,
|
|
745
|
+
pslPlacement: (entity) => ({ namespaceId: entity.namespaceId })
|
|
746
|
+
};
|
|
747
|
+
function lowerNativeEnumFromBlock(block, ctx) {
|
|
748
|
+
const sourceId = ctx.sourceId ?? "unknown";
|
|
749
|
+
const diagnostics = ctx.diagnostics;
|
|
750
|
+
const mapAttr = block.attributes["map"];
|
|
751
|
+
let typeName = block.name;
|
|
752
|
+
if (mapAttr !== void 0) {
|
|
753
|
+
const mapped = mapAttr.args["name"];
|
|
754
|
+
invariant(typeof mapped === "string", "@@map on a native_enum block parses one string argument");
|
|
755
|
+
typeName = mapped;
|
|
756
|
+
}
|
|
757
|
+
let memberError = false;
|
|
758
|
+
const seenValues = /* @__PURE__ */ new Set();
|
|
759
|
+
const members = [];
|
|
760
|
+
for (const [memberName, value] of Object.entries(block.values)) {
|
|
761
|
+
if (seenValues.has(value)) {
|
|
762
|
+
diagnostics?.push({
|
|
763
|
+
code: PSL_NATIVE_ENUM_DUPLICATE_MEMBER_VALUE,
|
|
764
|
+
message: `native_enum "${block.name}": duplicate member value "${value}"`,
|
|
765
|
+
sourceId,
|
|
766
|
+
span: block.parameterSpans[memberName] ?? block.span
|
|
767
|
+
});
|
|
768
|
+
memberError = true;
|
|
769
|
+
continue;
|
|
770
|
+
}
|
|
771
|
+
seenValues.add(value);
|
|
772
|
+
members.push(value);
|
|
773
|
+
}
|
|
774
|
+
if (memberError) return void 0;
|
|
775
|
+
if (members.length === 0) {
|
|
776
|
+
diagnostics?.push({
|
|
777
|
+
code: PSL_NATIVE_ENUM_MISSING_MEMBERS,
|
|
778
|
+
message: `native_enum "${block.name}" must have at least one member`,
|
|
779
|
+
sourceId,
|
|
780
|
+
span: block.span
|
|
781
|
+
});
|
|
782
|
+
return;
|
|
783
|
+
}
|
|
784
|
+
return new PostgresNativeEnum({
|
|
785
|
+
typeName,
|
|
786
|
+
members
|
|
787
|
+
});
|
|
788
|
+
}
|
|
789
|
+
/**
|
|
790
|
+
* `native_enum`'s entity-type factory output, checked separately from the assembled
|
|
791
|
+
* `postgresAuthoringEntityTypes` map below: `deriveValueSet` is SQL-family surface
|
|
792
|
+
* ({@link SqlValueSetDerivingEntityTypeOutput}), not part of the framework
|
|
793
|
+
* `AuthoringEntityTypeFactoryOutput` shape, so folding it directly into the map's single
|
|
794
|
+
* `satisfies AuthoringEntityTypeNamespace` check would trip an excess-property error. Checking it
|
|
795
|
+
* here against the intersection of both shapes keeps it structurally valid against each without
|
|
796
|
+
* widening the map's own check.
|
|
797
|
+
*/
|
|
798
|
+
const nativeEnumEntityTypeOutput = {
|
|
799
|
+
factory: lowerNativeEnumFromBlock,
|
|
800
|
+
deriveValueSet: (entity) => ({
|
|
801
|
+
kind: "valueSet",
|
|
802
|
+
values: [...entity.members]
|
|
803
|
+
})
|
|
804
|
+
};
|
|
805
|
+
/**
|
|
806
|
+
* Lowers a `role <name> {}` block into a {@link PostgresRole}. Roles are
|
|
807
|
+
* cluster-scoped in Postgres, so the block must be declared inside
|
|
808
|
+
* `namespace unbound { … }` — any other lexical namespace (a named schema,
|
|
809
|
+
* or the default bucket top-level declarations resolve to) is a load-time
|
|
810
|
+
* diagnostic. The lowered entity carries the unbound coordinate.
|
|
811
|
+
*/
|
|
812
|
+
function lowerRoleFromBlock(block, ctx) {
|
|
813
|
+
if (block.namespaceId !== UNBOUND_NAMESPACE_ID) {
|
|
814
|
+
ctx.diagnostics?.push({
|
|
815
|
+
code: PSL_ROLE_BLOCK_OUTSIDE_UNBOUND_NAMESPACE,
|
|
816
|
+
message: `\`role\` block "${block.name}" must be declared inside \`namespace unbound { }\`, not in namespace "${block.namespaceId}"`,
|
|
817
|
+
sourceId: ctx.sourceId ?? "unknown",
|
|
818
|
+
span: block.span
|
|
819
|
+
});
|
|
820
|
+
return;
|
|
821
|
+
}
|
|
822
|
+
return new PostgresRole({
|
|
823
|
+
name: block.name,
|
|
824
|
+
namespaceId: UNBOUND_NAMESPACE_ID
|
|
825
|
+
});
|
|
826
|
+
}
|
|
827
|
+
const postgresAuthoringEntityTypes = {
|
|
828
|
+
role: {
|
|
829
|
+
kind: "entity",
|
|
830
|
+
discriminator: "role",
|
|
831
|
+
validatorSchema: PostgresRoleSchema,
|
|
832
|
+
output: { factory: lowerRoleFromBlock }
|
|
833
|
+
},
|
|
834
|
+
rls: {
|
|
835
|
+
kind: "entity",
|
|
836
|
+
discriminator: "rls",
|
|
837
|
+
validatorSchema: PostgresRlsEnablementSchema,
|
|
838
|
+
output: { factory: (input) => new PostgresRlsEnablement(input) }
|
|
839
|
+
},
|
|
840
|
+
policy: {
|
|
841
|
+
kind: "entity",
|
|
842
|
+
discriminator: "policy",
|
|
843
|
+
validatorSchema: PostgresRlsPolicySchema,
|
|
844
|
+
output: policyEntityTypeOutput
|
|
845
|
+
},
|
|
846
|
+
native_enum: {
|
|
847
|
+
kind: "entity",
|
|
848
|
+
discriminator: "native_enum",
|
|
849
|
+
validatorSchema: PostgresNativeEnumSchema,
|
|
850
|
+
output: nativeEnumEntityTypeOutput
|
|
851
|
+
}
|
|
852
|
+
};
|
|
853
|
+
/**
|
|
854
|
+
* Field presets contributed by the Postgres target pack.
|
|
855
|
+
*
|
|
856
|
+
* These mirror the PSL scalar-to-codec mapping used by the Postgres adapter
|
|
857
|
+
* (see `createPostgresPslScalarTypeDescriptors`), so that authoring a field
|
|
858
|
+
* via the TS callback surface (e.g. `field.int()`) and via the PSL scalar
|
|
859
|
+
* surface (e.g. `Int`) lowers to byte-identical contracts.
|
|
860
|
+
*
|
|
861
|
+
* The `uuidNative` / `id.uuidv4Native` / `id.uuidv7Native` presets use the
|
|
862
|
+
* native Postgres `uuid` type (codecId `pg/uuid@1`). For cross-target
|
|
863
|
+
* portability use `uuidString` / `id.uuidv4String` / `id.uuidv7String` from
|
|
864
|
+
* the family pack instead.
|
|
865
|
+
*/
|
|
866
|
+
const policyRequiresRls = {
|
|
867
|
+
parameter: "target",
|
|
868
|
+
attribute: "rls"
|
|
869
|
+
};
|
|
870
|
+
const policyMapAttribute = blockAttribute("map", {
|
|
871
|
+
documentation: "Maps this row-level security policy to its PostgreSQL policy name.",
|
|
872
|
+
positional: [{
|
|
873
|
+
key: "name",
|
|
874
|
+
type: str(),
|
|
875
|
+
documentation: "The nonempty PostgreSQL policy name."
|
|
876
|
+
}],
|
|
877
|
+
refine: (parsed, ctx, attributeNode) => parsed.name === "" ? [leafDiagnostic(ctx, attributeNode, "@@map policy name must be a non-empty string", PSL_POLICY_INVALID_MAP)] : []
|
|
878
|
+
});
|
|
879
|
+
const policyBlockAttributes = { map: () => policyMapAttribute };
|
|
880
|
+
const nativeEnumMapAttribute = blockAttribute("map", {
|
|
881
|
+
documentation: "Maps this native enum to its PostgreSQL type name.",
|
|
882
|
+
positional: [{
|
|
883
|
+
key: "name",
|
|
884
|
+
type: str(),
|
|
885
|
+
documentation: "The PostgreSQL enum type name."
|
|
886
|
+
}]
|
|
887
|
+
});
|
|
888
|
+
const postgresAuthoringPslBlockDescriptors = {
|
|
889
|
+
[POLICY_BLOCK_KEYWORDS.select]: {
|
|
890
|
+
kind: "pslBlock",
|
|
891
|
+
keyword: POLICY_BLOCK_KEYWORDS.select,
|
|
892
|
+
documentation: "Defines a row-level security policy controlling which rows can be selected.",
|
|
893
|
+
discriminator: "policy",
|
|
894
|
+
name: { required: true },
|
|
895
|
+
spec: policyUsingOnlySpec,
|
|
896
|
+
requiresModelAttribute: policyRequiresRls,
|
|
897
|
+
attributes: policyBlockAttributes
|
|
898
|
+
},
|
|
899
|
+
[POLICY_BLOCK_KEYWORDS.delete]: {
|
|
900
|
+
kind: "pslBlock",
|
|
901
|
+
keyword: POLICY_BLOCK_KEYWORDS.delete,
|
|
902
|
+
documentation: "Defines a row-level security policy controlling which rows can be deleted.",
|
|
903
|
+
discriminator: "policy",
|
|
904
|
+
name: { required: true },
|
|
905
|
+
spec: policyUsingOnlySpec,
|
|
906
|
+
requiresModelAttribute: policyRequiresRls,
|
|
907
|
+
attributes: policyBlockAttributes
|
|
908
|
+
},
|
|
909
|
+
[POLICY_BLOCK_KEYWORDS.insert]: {
|
|
910
|
+
kind: "pslBlock",
|
|
911
|
+
keyword: POLICY_BLOCK_KEYWORDS.insert,
|
|
912
|
+
documentation: "Defines a row-level security policy checking rows being inserted.",
|
|
913
|
+
discriminator: "policy",
|
|
914
|
+
name: { required: true },
|
|
915
|
+
spec: policyWithCheckOnlySpec,
|
|
916
|
+
requiresModelAttribute: policyRequiresRls,
|
|
917
|
+
attributes: policyBlockAttributes
|
|
918
|
+
},
|
|
919
|
+
[POLICY_BLOCK_KEYWORDS.update]: {
|
|
920
|
+
kind: "pslBlock",
|
|
921
|
+
keyword: POLICY_BLOCK_KEYWORDS.update,
|
|
922
|
+
documentation: "Defines a row-level security policy controlling row visibility and checks for updates.",
|
|
923
|
+
discriminator: "policy",
|
|
924
|
+
name: { required: true },
|
|
925
|
+
spec: policyBothPredicatesSpec,
|
|
926
|
+
requiresModelAttribute: policyRequiresRls,
|
|
927
|
+
attributes: policyBlockAttributes
|
|
928
|
+
},
|
|
929
|
+
[POLICY_BLOCK_KEYWORDS.all]: {
|
|
930
|
+
kind: "pslBlock",
|
|
931
|
+
keyword: POLICY_BLOCK_KEYWORDS.all,
|
|
932
|
+
documentation: "Defines a row-level security policy applying to all operations.",
|
|
933
|
+
discriminator: "policy",
|
|
934
|
+
name: { required: true },
|
|
935
|
+
spec: policyBothPredicatesSpec,
|
|
936
|
+
requiresModelAttribute: policyRequiresRls,
|
|
937
|
+
attributes: policyBlockAttributes
|
|
938
|
+
},
|
|
939
|
+
native_enum: {
|
|
940
|
+
kind: "pslBlock",
|
|
941
|
+
keyword: "native_enum",
|
|
942
|
+
documentation: "Defines a PostgreSQL enum type with named string-valued members.",
|
|
943
|
+
discriminator: "native_enum",
|
|
944
|
+
name: { required: true },
|
|
945
|
+
spec: nativeEnumSpec,
|
|
946
|
+
nameIsStorageName: true,
|
|
947
|
+
attributes: { map: () => nativeEnumMapAttribute }
|
|
948
|
+
},
|
|
949
|
+
/**
|
|
950
|
+
* PSL block descriptor for `role` (e.g. `role anon {}`). Name-only, no
|
|
951
|
+
* parameters and no body content. Declared inside `namespace unbound { }`
|
|
952
|
+
* — see {@link lowerRoleFromBlock} for the placement check and the
|
|
953
|
+
* coordinate the lowered entity carries.
|
|
954
|
+
*/
|
|
955
|
+
role: {
|
|
956
|
+
kind: "pslBlock",
|
|
957
|
+
keyword: "role",
|
|
958
|
+
documentation: "Declares an existing database role in namespace unbound for use in security policies.",
|
|
959
|
+
discriminator: "role",
|
|
960
|
+
name: { required: true },
|
|
961
|
+
spec: roleSpec
|
|
962
|
+
}
|
|
963
|
+
};
|
|
964
|
+
const postgresRlsSpec = modelAttribute("rls", { documentation: "Enables PostgreSQL row-level security on this model’s table." });
|
|
965
|
+
const postgresRlsSpecFactory = () => postgresRlsSpec;
|
|
966
|
+
const [firstLanguage, ...remainingLanguages] = POSTGRES_TEXT_SEARCH_LANGUAGES;
|
|
967
|
+
const fullTextField = fieldRef();
|
|
968
|
+
function postgresFullTextIndexSpec(ctx) {
|
|
969
|
+
return modelAttribute("fullTextIndex", {
|
|
970
|
+
documentation: "Indexes text fields for full-text search. Each item of the list is a weight group, strongest first; a nested list puts several fields in one group. Pass the index from the table's `indexes` to `fullTextMatches` and `fullTextRank` to search the same document.",
|
|
971
|
+
positional: [{
|
|
972
|
+
key: "fields",
|
|
973
|
+
type: oneOf(fullTextField, list(oneOf(fullTextField, list(fullTextField)), {
|
|
974
|
+
allowEmpty: false,
|
|
975
|
+
label: "(field name | field name[])[]"
|
|
976
|
+
})),
|
|
977
|
+
documentation: "The fields to index: one field, or a list of fields and lists of fields. Each top-level item is a weight group, from A down to D."
|
|
978
|
+
}],
|
|
979
|
+
named: {
|
|
980
|
+
language: {
|
|
981
|
+
type: optional(oneOf(str(firstLanguage), ...remainingLanguages.map((language) => str(language)))),
|
|
982
|
+
documentation: "The text-search configuration. Defaults to `english`, and must match the language the query operations are given."
|
|
983
|
+
},
|
|
984
|
+
name: {
|
|
985
|
+
type: optional(str()),
|
|
986
|
+
documentation: "The index name. Mutually exclusive with `map`."
|
|
987
|
+
},
|
|
988
|
+
map: {
|
|
989
|
+
type: optional(str()),
|
|
990
|
+
documentation: "The database index name. Mutually exclusive with `name`."
|
|
991
|
+
},
|
|
992
|
+
where: {
|
|
993
|
+
type: optional(dataTypeValue(SQL_EXPRESSION_DATA_TYPE_ID, ctx.dataTypes)),
|
|
994
|
+
documentation: "The SQL predicate restricting rows included in a partial index."
|
|
995
|
+
}
|
|
996
|
+
},
|
|
997
|
+
refine: (value, ctx, attributeNode) => {
|
|
998
|
+
const diagnostics = fullTextIndexProblems({ weightGroups: weightGroupsOf(value.fields, isFieldName) }).filter(isPslFullTextIndexProblem).map((problem) => leafDiagnostic(ctx, attributeNode, describeFullTextIndexProblem("`@@fullTextIndex`", problem), FULL_TEXT_INDEX_PROBLEM_CODES[problem.kind]));
|
|
999
|
+
if (value.name === void 0 && value.map === void 0) diagnostics.push(leafDiagnostic(ctx, attributeNode, "`@@fullTextIndex` requires a `name` or `map` argument", PSL_FULL_TEXT_INDEX_REQUIRES_NAME));
|
|
1000
|
+
if (value.name !== void 0 && value.map !== void 0) diagnostics.push(leafDiagnostic(ctx, attributeNode, "`@@fullTextIndex` takes at most one of `name` and `map`", PSL_FULL_TEXT_INDEX_NAME_XOR_MAP));
|
|
1001
|
+
return diagnostics;
|
|
1002
|
+
}
|
|
1003
|
+
});
|
|
1004
|
+
}
|
|
1005
|
+
function isFieldName(value) {
|
|
1006
|
+
return typeof value === "string";
|
|
1007
|
+
}
|
|
1008
|
+
function isPslFullTextIndexProblem(problem) {
|
|
1009
|
+
return problem.kind !== "unique" && problem.kind !== "no-fields";
|
|
1010
|
+
}
|
|
1011
|
+
const FULL_TEXT_INDEX_PROBLEM_CODES = {
|
|
1012
|
+
"too-many-groups": PSL_FULL_TEXT_INDEX_TOO_MANY_GROUPS,
|
|
1013
|
+
"empty-group": PSL_FULL_TEXT_INDEX_EMPTY_GROUP,
|
|
1014
|
+
"duplicate-field": PSL_FULL_TEXT_INDEX_DUPLICATE_FIELD,
|
|
1015
|
+
"not-text": PSL_FULL_TEXT_INDEX_TEXT_FIELD
|
|
1016
|
+
};
|
|
1017
|
+
const postgresFullTextIndexSpecFactory = (ctx) => postgresFullTextIndexSpec(ctx);
|
|
1018
|
+
/**
|
|
1019
|
+
* `@@` model attributes contributed by the Postgres target pack.
|
|
1020
|
+
*
|
|
1021
|
+
* `@@rls` is argument-less: presence marks the model's table
|
|
1022
|
+
* RLS-controlled. It lowers to a {@link PostgresRlsEnablement} marker in
|
|
1023
|
+
* the namespace's `entries.rls`, keyed by the model's table name — the
|
|
1024
|
+
* marker (never the policy set) is what drives
|
|
1025
|
+
* `ENABLE`/`DISABLE ROW LEVEL SECURITY` planning.
|
|
1026
|
+
*/
|
|
1027
|
+
const postgresAuthoringModelAttributes = {
|
|
1028
|
+
rls: {
|
|
1029
|
+
kind: "modelAttribute",
|
|
1030
|
+
attribute: "rls",
|
|
1031
|
+
spec: postgresRlsSpecFactory,
|
|
1032
|
+
lower: (_parsed, ctx) => ({
|
|
1033
|
+
key: ctx.storageName,
|
|
1034
|
+
entity: new PostgresRlsEnablement({
|
|
1035
|
+
tableName: ctx.storageName,
|
|
1036
|
+
namespaceId: ctx.namespaceId
|
|
1037
|
+
})
|
|
1038
|
+
})
|
|
1039
|
+
},
|
|
1040
|
+
fullTextIndex: {
|
|
1041
|
+
kind: "modelAttribute",
|
|
1042
|
+
attribute: "fullTextIndex",
|
|
1043
|
+
spec: postgresFullTextIndexSpecFactory,
|
|
1044
|
+
repeatable: true,
|
|
1045
|
+
lower: (parsed, ctx) => {
|
|
1046
|
+
const fieldGroups = weightGroupsOf(parsed.fields, isFieldName);
|
|
1047
|
+
const problems = fullTextIndexProblems({
|
|
1048
|
+
weightGroups: fieldGroups,
|
|
1049
|
+
codecs: {
|
|
1050
|
+
codecIdOf: (fieldName) => ctx.fieldStorageName(fieldName) === void 0 ? void 0 : ctx.fieldCodecId(fieldName),
|
|
1051
|
+
traitsOf: postgresCodecTraitsOf
|
|
1052
|
+
}
|
|
1053
|
+
}).filter(isPslFullTextIndexProblem);
|
|
1054
|
+
for (const problem of problems) ctx.diagnostics?.push({
|
|
1055
|
+
code: FULL_TEXT_INDEX_PROBLEM_CODES[problem.kind],
|
|
1056
|
+
message: describeFullTextIndexProblem("`@@fullTextIndex`", problem, (fieldName) => `${ctx.modelName}.${fieldName}`),
|
|
1057
|
+
sourceId: ctx.sourceId ?? "unknown"
|
|
1058
|
+
});
|
|
1059
|
+
if (problems.length > 0) return void 0;
|
|
1060
|
+
const weightGroups = fieldGroups.map((group) => group.map((fieldName) => {
|
|
1061
|
+
const columnName = ctx.fieldStorageName(fieldName);
|
|
1062
|
+
assertDefined(columnName, `@@fullTextIndex field "${fieldName}" has no storage column`);
|
|
1063
|
+
return columnName;
|
|
1064
|
+
}));
|
|
1065
|
+
return { index: {
|
|
1066
|
+
columns: weightGroups.flat(),
|
|
1067
|
+
type: FULL_TEXT_INDEX_TYPE,
|
|
1068
|
+
options: {
|
|
1069
|
+
weightGroups,
|
|
1070
|
+
language: parsed.language ?? "english"
|
|
1071
|
+
},
|
|
1072
|
+
where: parsed.where === void 0 ? void 0 : sqlTextFromStored(parsed.where.value.value),
|
|
1073
|
+
unique: void 0,
|
|
1074
|
+
name: parsed.name,
|
|
1075
|
+
map: parsed.map
|
|
1076
|
+
} };
|
|
1077
|
+
}
|
|
1078
|
+
}
|
|
1079
|
+
};
|
|
1080
|
+
const postgresAuthoringFieldPresets = {
|
|
1081
|
+
text: {
|
|
1082
|
+
kind: "fieldPreset",
|
|
1083
|
+
output: { codecId: "pg/text@1" }
|
|
1084
|
+
},
|
|
1085
|
+
int: {
|
|
1086
|
+
kind: "fieldPreset",
|
|
1087
|
+
output: { codecId: "pg/int4@1" }
|
|
1088
|
+
},
|
|
1089
|
+
bigint: {
|
|
1090
|
+
kind: "fieldPreset",
|
|
1091
|
+
output: { codecId: "pg/int8@1" }
|
|
1092
|
+
},
|
|
1093
|
+
float: {
|
|
1094
|
+
kind: "fieldPreset",
|
|
1095
|
+
output: { codecId: "pg/float8@1" }
|
|
1096
|
+
},
|
|
1097
|
+
decimal: {
|
|
1098
|
+
kind: "fieldPreset",
|
|
1099
|
+
output: { codecId: "pg/numeric@1" }
|
|
1100
|
+
},
|
|
1101
|
+
boolean: {
|
|
1102
|
+
kind: "fieldPreset",
|
|
1103
|
+
output: { codecId: "pg/bool@1" }
|
|
1104
|
+
},
|
|
1105
|
+
json: {
|
|
1106
|
+
kind: "fieldPreset",
|
|
1107
|
+
output: { codecId: "pg/jsonb@1" }
|
|
1108
|
+
},
|
|
1109
|
+
bytes: {
|
|
1110
|
+
kind: "fieldPreset",
|
|
1111
|
+
output: { codecId: "pg/bytea@1" }
|
|
1112
|
+
},
|
|
1113
|
+
dateTime: {
|
|
1114
|
+
kind: "fieldPreset",
|
|
1115
|
+
output: { codecId: "pg/timestamptz-temporal@1" }
|
|
1116
|
+
},
|
|
1117
|
+
temporal: {
|
|
1118
|
+
createdAtJsDate: (/* @__PURE__ */ temporalAuthoringPresets({
|
|
1119
|
+
codecId: PG_TIMESTAMPTZ_DATE_CODEC_ID,
|
|
1120
|
+
generatorId: postgresNowGeneratorIds[PG_TIMESTAMPTZ_DATE_CODEC_ID]
|
|
1121
|
+
})).createdAt,
|
|
1122
|
+
updatedAtJsDate: (/* @__PURE__ */ temporalAuthoringPresets({
|
|
1123
|
+
codecId: PG_TIMESTAMPTZ_DATE_CODEC_ID,
|
|
1124
|
+
generatorId: postgresNowGeneratorIds[PG_TIMESTAMPTZ_DATE_CODEC_ID]
|
|
1125
|
+
})).updatedAt,
|
|
1126
|
+
timestamptzJsDate: /* @__PURE__ */ temporalCodecPresetWithPrecision({
|
|
1127
|
+
sizeType: PG_SIZE_TYPE,
|
|
1128
|
+
codecId: PG_TIMESTAMPTZ_DATE_CODEC_ID,
|
|
1129
|
+
generatorId: postgresNowGeneratorIds[PG_TIMESTAMPTZ_DATE_CODEC_ID]
|
|
1130
|
+
}),
|
|
1131
|
+
.../* @__PURE__ */ temporalAuthoringPresets({
|
|
1132
|
+
codecId: PG_TIMESTAMPTZ_TEMPORAL_CODEC_ID,
|
|
1133
|
+
generatorId: postgresNowGeneratorIds[PG_TIMESTAMPTZ_TEMPORAL_CODEC_ID]
|
|
1134
|
+
}),
|
|
1135
|
+
.../* @__PURE__ */ temporalStringAuthoringPresets({
|
|
1136
|
+
codecId: PG_TIMESTAMPTZ_STRING_CODEC_ID,
|
|
1137
|
+
generatorId: postgresNowGeneratorIds[PG_TIMESTAMPTZ_STRING_CODEC_ID]
|
|
1138
|
+
}),
|
|
1139
|
+
timestamp: /* @__PURE__ */ temporalCodecPresetWithPrecision({
|
|
1140
|
+
sizeType: PG_SIZE_TYPE,
|
|
1141
|
+
codecId: PG_TIMESTAMP_TEMPORAL_CODEC_ID,
|
|
1142
|
+
generatorId: postgresNowGeneratorIds[PG_TIMESTAMP_TEMPORAL_CODEC_ID]
|
|
1143
|
+
}),
|
|
1144
|
+
timestamptz: /* @__PURE__ */ temporalCodecPresetWithPrecision({
|
|
1145
|
+
sizeType: PG_SIZE_TYPE,
|
|
1146
|
+
codecId: PG_TIMESTAMPTZ_TEMPORAL_CODEC_ID,
|
|
1147
|
+
generatorId: postgresNowGeneratorIds[PG_TIMESTAMPTZ_TEMPORAL_CODEC_ID]
|
|
1148
|
+
}),
|
|
1149
|
+
timestampString: /* @__PURE__ */ temporalCodecPresetWithPrecision({
|
|
1150
|
+
sizeType: PG_SIZE_TYPE,
|
|
1151
|
+
codecId: PG_TIMESTAMP_STRING_CODEC_ID,
|
|
1152
|
+
generatorId: postgresNowGeneratorIds[PG_TIMESTAMP_STRING_CODEC_ID]
|
|
1153
|
+
}),
|
|
1154
|
+
timestamptzString: /* @__PURE__ */ temporalCodecPresetWithPrecision({
|
|
1155
|
+
sizeType: PG_SIZE_TYPE,
|
|
1156
|
+
codecId: PG_TIMESTAMPTZ_STRING_CODEC_ID,
|
|
1157
|
+
generatorId: postgresNowGeneratorIds[PG_TIMESTAMPTZ_STRING_CODEC_ID]
|
|
1158
|
+
}),
|
|
1159
|
+
date: /* @__PURE__ */ temporalCodecPreset({
|
|
1160
|
+
codecId: PG_DATE_TEMPORAL_CODEC_ID,
|
|
1161
|
+
generatorId: postgresNowGeneratorIds[PG_DATE_TEMPORAL_CODEC_ID]
|
|
1162
|
+
}),
|
|
1163
|
+
dateString: /* @__PURE__ */ temporalCodecPreset({
|
|
1164
|
+
codecId: PG_DATE_STRING_CODEC_ID,
|
|
1165
|
+
generatorId: postgresNowGeneratorIds[PG_DATE_STRING_CODEC_ID]
|
|
1166
|
+
}),
|
|
1167
|
+
time: /* @__PURE__ */ temporalCodecPresetWithPrecision({
|
|
1168
|
+
sizeType: PG_SIZE_TYPE,
|
|
1169
|
+
codecId: PG_TIME_TEMPORAL_CODEC_ID,
|
|
1170
|
+
generatorId: postgresNowGeneratorIds[PG_TIME_TEMPORAL_CODEC_ID],
|
|
1171
|
+
nowTakesPrecision: postgresNowGeneratorTakesPrecision[PG_TIME_TEMPORAL_CODEC_ID]
|
|
1172
|
+
}),
|
|
1173
|
+
timeString: /* @__PURE__ */ temporalCodecPresetWithPrecision({
|
|
1174
|
+
sizeType: PG_SIZE_TYPE,
|
|
1175
|
+
codecId: PG_TIME_STRING_CODEC_ID,
|
|
1176
|
+
generatorId: postgresNowGeneratorIds[PG_TIME_STRING_CODEC_ID],
|
|
1177
|
+
nowTakesPrecision: postgresNowGeneratorTakesPrecision[PG_TIME_STRING_CODEC_ID]
|
|
1178
|
+
}),
|
|
1179
|
+
/** Produces a string: no Temporal type holds a time of day with an offset. */
|
|
1180
|
+
timetz: /* @__PURE__ */ temporalCodecPresetWithPrecision({
|
|
1181
|
+
sizeType: PG_SIZE_TYPE,
|
|
1182
|
+
codecId: PG_TIMETZ_CODEC_ID,
|
|
1183
|
+
generatorId: postgresNowGeneratorIds[PG_TIMETZ_CODEC_ID],
|
|
1184
|
+
nowTakesPrecision: postgresNowGeneratorTakesPrecision[PG_TIMETZ_CODEC_ID]
|
|
1185
|
+
})
|
|
1186
|
+
},
|
|
1187
|
+
uuidNative: {
|
|
1188
|
+
kind: "fieldPreset",
|
|
1189
|
+
output: { codecId: "pg/uuid@1" }
|
|
1190
|
+
},
|
|
1191
|
+
id: {
|
|
1192
|
+
uuidv4Native: {
|
|
1193
|
+
kind: "fieldPreset",
|
|
1194
|
+
output: {
|
|
1195
|
+
codecId: "pg/uuid@1",
|
|
1196
|
+
executionDefaults: { onCreate: {
|
|
1197
|
+
kind: "generator",
|
|
1198
|
+
id: "uuidv4"
|
|
1199
|
+
} },
|
|
1200
|
+
id: true
|
|
1201
|
+
}
|
|
1202
|
+
},
|
|
1203
|
+
uuidv7Native: {
|
|
1204
|
+
kind: "fieldPreset",
|
|
1205
|
+
output: {
|
|
1206
|
+
codecId: "pg/uuid@1",
|
|
1207
|
+
executionDefaults: { onCreate: {
|
|
1208
|
+
kind: "generator",
|
|
1209
|
+
id: "uuidv7"
|
|
1210
|
+
} },
|
|
1211
|
+
id: true
|
|
1212
|
+
}
|
|
1213
|
+
}
|
|
1214
|
+
}
|
|
1215
|
+
};
|
|
1216
|
+
function predicateText(predicate, what) {
|
|
1217
|
+
return predicate === void 0 ? void 0 : requireSqlExpression(predicate, what).text;
|
|
1218
|
+
}
|
|
1219
|
+
/**
|
|
1220
|
+
* Resolves an entity handle's `target` ref to a table coordinate of this
|
|
1221
|
+
* contract, or throws the load-time diagnostic naming the handle: a
|
|
1222
|
+
* cross-space target is rejected (you cannot CREATE POLICY on a table
|
|
1223
|
+
* another space owns) and an unresolved target names the model.
|
|
1224
|
+
*/
|
|
1225
|
+
function requireLocalTarget(refs, subject) {
|
|
1226
|
+
const target = refs["target"];
|
|
1227
|
+
if (target !== void 0 && target.kind === "resolved") return {
|
|
1228
|
+
namespaceId: target.namespaceId,
|
|
1229
|
+
tableName: target.tableName
|
|
1230
|
+
};
|
|
1231
|
+
if (target !== void 0 && target.kind === "cross-space") throw postgresError("CONTRACT.POLICY_INVALID", `defineContract: ${subject} targets model "${target.modelName ?? target.tableName}", which lives in another contract space. Policies and rlsEnabled entries must target a model declared in this contract.`, { meta: {
|
|
1232
|
+
model: target.modelName ?? target.tableName,
|
|
1233
|
+
reason: "cross-space-target"
|
|
1234
|
+
} });
|
|
1235
|
+
throw postgresError("CONTRACT.MODEL_UNKNOWN", `defineContract: ${subject} targets model "${target?.modelName ?? "<anonymous>"}", which is not in the contract's models. Add the model to \`models\`.`, { meta: { model: target?.modelName ?? "<anonymous>" } });
|
|
1236
|
+
}
|
|
1237
|
+
/**
|
|
1238
|
+
* The SQL-family entity-handle batch lowering hook for the Postgres pack
|
|
1239
|
+
* (`SqlEntityHandleLoweringContribution`). Receives every `entities` handle
|
|
1240
|
+
* whose kind this pack registered — batch, so the cross-entity diagnostics
|
|
1241
|
+
* (duplicate prefix, policy without rlsEnabled, duplicate role) can see
|
|
1242
|
+
* sibling handles — and lowers them with the same keying and hash assembly
|
|
1243
|
+
* as the PSL path: `policy` keyed by prefix (wire name via
|
|
1244
|
+
* {@link buildRlsPolicyEntity}), `rls` keyed by table name, `role` keyed by
|
|
1245
|
+
* name and filed under the default namespace (roles are declared
|
|
1246
|
+
* contract-wide; PSL has no role block to set a precedent).
|
|
1247
|
+
*/
|
|
1248
|
+
function postgresLowerEntityHandles(input) {
|
|
1249
|
+
const enablements = /* @__PURE__ */ new Map();
|
|
1250
|
+
const roles = /* @__PURE__ */ new Map();
|
|
1251
|
+
const policies = [];
|
|
1252
|
+
const coordinateKey = (coordinate) => `${coordinate.namespaceId} ${coordinate.tableName}`;
|
|
1253
|
+
for (const { handle, refs } of input.handles) switch (handle.entityKind) {
|
|
1254
|
+
case "rls": {
|
|
1255
|
+
const coordinate = requireLocalTarget(refs, "an rlsEnabled entry");
|
|
1256
|
+
const key = coordinateKey(coordinate);
|
|
1257
|
+
if (!enablements.has(key)) enablements.set(key, {
|
|
1258
|
+
coordinate,
|
|
1259
|
+
entity: new PostgresRlsEnablement({
|
|
1260
|
+
tableName: coordinate.tableName,
|
|
1261
|
+
namespaceId: coordinate.namespaceId
|
|
1262
|
+
})
|
|
1263
|
+
});
|
|
1264
|
+
break;
|
|
1265
|
+
}
|
|
1266
|
+
case "role": {
|
|
1267
|
+
const roleHandle = blindCast(handle);
|
|
1268
|
+
if (roles.has(roleHandle.name)) throw postgresError("CONTRACT.ROLE_INVALID", `defineContract: role "${roleHandle.name}" is declared more than once in the entities list.`, { meta: {
|
|
1269
|
+
role: roleHandle.name,
|
|
1270
|
+
reason: "duplicate"
|
|
1271
|
+
} });
|
|
1272
|
+
roles.set(roleHandle.name, new PostgresRole({
|
|
1273
|
+
name: roleHandle.name,
|
|
1274
|
+
namespaceId: UNBOUND_NAMESPACE_ID
|
|
1275
|
+
}));
|
|
1276
|
+
break;
|
|
1277
|
+
}
|
|
1278
|
+
case "policy": {
|
|
1279
|
+
const policyHandle = blindCast(handle);
|
|
1280
|
+
policies.push({
|
|
1281
|
+
handle: policyHandle,
|
|
1282
|
+
refs
|
|
1283
|
+
});
|
|
1284
|
+
break;
|
|
1285
|
+
}
|
|
1286
|
+
default: throw postgresError("CONTRACT.ENTITY_KIND_INVALID", `defineContract: the postgres pack does not lower "${handle.entityKind}" handles from the entities list.`, { meta: { entityKind: handle.entityKind } });
|
|
1287
|
+
}
|
|
1288
|
+
const rows = [];
|
|
1289
|
+
const seenPrefixes = /* @__PURE__ */ new Set();
|
|
1290
|
+
for (const { handle: policy, refs } of policies) {
|
|
1291
|
+
const prefix = policy.name;
|
|
1292
|
+
assertWireNamePrefixLength(prefix, "defineContract: policy prefix");
|
|
1293
|
+
const coordinate = requireLocalTarget(refs, `policy "${prefix}"`);
|
|
1294
|
+
if (!enablements.has(coordinateKey(coordinate))) {
|
|
1295
|
+
const target = refs["target"];
|
|
1296
|
+
throw postgresError("CONTRACT.POLICY_INVALID", `defineContract: policy "${prefix}" targets model "${target?.modelName ?? coordinate.tableName}", whose table is not RLS-enabled. Add rlsEnabled(<model>) to the entities list.`, { meta: {
|
|
1297
|
+
prefix,
|
|
1298
|
+
model: target?.modelName ?? coordinate.tableName,
|
|
1299
|
+
reason: "target-not-rls-enabled"
|
|
1300
|
+
} });
|
|
1301
|
+
}
|
|
1302
|
+
const prefixKey = `${coordinate.namespaceId} ${prefix}`;
|
|
1303
|
+
if (seenPrefixes.has(prefixKey)) throw postgresError("CONTRACT.POLICY_INVALID", `defineContract: policy prefix "${prefix}" is declared more than once in namespace "${coordinate.namespaceId}". Policy prefixes must be unique per namespace.`, { meta: {
|
|
1304
|
+
prefix,
|
|
1305
|
+
namespaceId: coordinate.namespaceId,
|
|
1306
|
+
reason: "duplicate-prefix"
|
|
1307
|
+
} });
|
|
1308
|
+
seenPrefixes.add(prefixKey);
|
|
1309
|
+
const roleNames = [...new Set(policy.roles.map((roleHandle) => roleHandle.name))].sort();
|
|
1310
|
+
rows.push({
|
|
1311
|
+
namespaceId: coordinate.namespaceId,
|
|
1312
|
+
entityKind: "policy",
|
|
1313
|
+
key: prefix,
|
|
1314
|
+
entity: buildRlsPolicyEntity({
|
|
1315
|
+
prefix,
|
|
1316
|
+
tableName: coordinate.tableName,
|
|
1317
|
+
namespaceId: coordinate.namespaceId,
|
|
1318
|
+
operation: policy.operation,
|
|
1319
|
+
roles: roleNames,
|
|
1320
|
+
...ifDefined("using", predicateText(policy.using, `Policy "${prefix}" using`)),
|
|
1321
|
+
...ifDefined("withCheck", predicateText(policy.withCheck, `Policy "${prefix}" withCheck`))
|
|
1322
|
+
})
|
|
1323
|
+
});
|
|
1324
|
+
}
|
|
1325
|
+
for (const { coordinate, entity } of enablements.values()) rows.push({
|
|
1326
|
+
namespaceId: coordinate.namespaceId,
|
|
1327
|
+
entityKind: "rls",
|
|
1328
|
+
key: coordinate.tableName,
|
|
1329
|
+
entity
|
|
1330
|
+
});
|
|
1331
|
+
for (const [name, entity] of roles) rows.push({
|
|
1332
|
+
namespaceId: UNBOUND_NAMESPACE_ID,
|
|
1333
|
+
entityKind: "role",
|
|
1334
|
+
key: name,
|
|
1335
|
+
entity
|
|
1336
|
+
});
|
|
1337
|
+
return rows;
|
|
1338
|
+
}
|
|
1339
|
+
//#endregion
|
|
1340
|
+
export { postgresAuthoringPslBlockDescriptors as a, postgresNativeAuthoringTypes as c, postgresNowGenerators as d, postgresScalarAndNativeTypeConstructors as f, postgresAuthoringModelAttributes as i, postgresNowGeneratorControlDescriptors as l, postgresAuthoringEntityTypes as n, postgresAuthoringTypes as o, postgresScalarAuthoringTypes as p, postgresAuthoringFieldPresets as r, postgresLowerEntityHandles as s, POLICY_BLOCK_KEYWORDS as t, postgresNowGeneratorFunction as u };
|
|
1341
|
+
|
|
1342
|
+
//# sourceMappingURL=authoring-SbdvmVJh-nQ7YliD_.mjs.map
|