@prisma/orm-target-postgres 0.16.0-dev.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +23 -0
- package/dist/adapter-CWvVo0PV.d.mts +22 -0
- package/dist/adapter-CWvVo0PV.d.mts.map +1 -0
- package/dist/adapter-DhqcO3YO-jzwDVcCv.mjs +70 -0
- package/dist/adapter-DhqcO3YO-jzwDVcCv.mjs.map +1 -0
- package/dist/adapter.d.mts +12 -0
- package/dist/adapter.mjs +7 -0
- package/dist/adapter__adapter.d.mts +2 -0
- package/dist/adapter__adapter.mjs +2 -0
- package/dist/adapter__column-types.d.mts +2 -0
- package/dist/adapter__column-types.mjs +2 -0
- package/dist/adapter__control.d.mts +5 -0
- package/dist/adapter__control.mjs +441 -0
- package/dist/adapter__control.mjs.map +1 -0
- package/dist/adapter__operation-types.d.mts +2 -0
- package/dist/adapter__operation-types.mjs +1 -0
- package/dist/adapter__runtime.d.mts +2 -0
- package/dist/adapter__runtime.mjs +38 -0
- package/dist/adapter__runtime.mjs.map +1 -0
- package/dist/adapter__types.d.mts +4 -0
- package/dist/adapter__types.mjs +1 -0
- package/dist/authoring-03FwIL2k-kPjZAp3s.mjs +757 -0
- package/dist/authoring-03FwIL2k-kPjZAp3s.mjs.map +1 -0
- package/dist/canonicalize-CQlxSR4D-MnrT5gtW.d.mts +34 -0
- package/dist/canonicalize-CQlxSR4D-MnrT5gtW.d.mts.map +1 -0
- package/dist/canonicalize-CrN3u_xM-D4MrOqcB.mjs +59 -0
- package/dist/canonicalize-CrN3u_xM-D4MrOqcB.mjs.map +1 -0
- package/dist/codec-descriptor-Bec_zukr-BfvtUqhm.d.mts +37 -0
- package/dist/codec-descriptor-Bec_zukr-BfvtUqhm.d.mts.map +1 -0
- package/dist/codec-descriptor-Bg-_412t.d.mts +1 -0
- package/dist/codec-descriptor-CB6x0xEu-C-Zn2IEz.mjs +135 -0
- package/dist/codec-descriptor-CB6x0xEu-C-Zn2IEz.mjs.map +1 -0
- package/dist/codec-ids-CsOU3xDv-mPI0INiF.d.mts +33 -0
- package/dist/codec-ids-CsOU3xDv-mPI0INiF.d.mts.map +1 -0
- package/dist/codec-ids-fgafMLR7.d.mts +1 -0
- package/dist/codec-ids-tX7Svtz--BuOfRaVU.mjs +33 -0
- package/dist/codec-ids-tX7Svtz--BuOfRaVU.mjs.map +1 -0
- package/dist/codec-types-BHwY9Ff-.d.mts +2 -0
- package/dist/codec-types-mWhnDEAf-CAQzGFnF.d.mts +82 -0
- package/dist/codec-types-mWhnDEAf-CAQzGFnF.d.mts.map +1 -0
- package/dist/codecs-CBl0nD44-CaWPc1bd.mjs +1486 -0
- package/dist/codecs-CBl0nD44-CaWPc1bd.mjs.map +1 -0
- package/dist/codecs-CHIVTNZs.mjs +15 -0
- package/dist/codecs-CHIVTNZs.mjs.map +1 -0
- package/dist/codecs-Cvqvb9pV-Cdc51FKY.d.mts +589 -0
- package/dist/codecs-Cvqvb9pV-Cdc51FKY.d.mts.map +1 -0
- package/dist/codecs-DBn-uIv-.d.mts +15 -0
- package/dist/codecs-DBn-uIv-.d.mts.map +1 -0
- package/dist/column-types-BH-MU6uU.d.mts +108 -0
- package/dist/column-types-BH-MU6uU.d.mts.map +1 -0
- package/dist/column-types-CwAyCgp2.mjs +126 -0
- package/dist/column-types-CwAyCgp2.mjs.map +1 -0
- package/dist/contract-free-BZUS18FU.mjs +118 -0
- package/dist/contract-free-BZUS18FU.mjs.map +1 -0
- package/dist/contract-free-DzpGxLfb.d.mts +258 -0
- package/dist/contract-free-DzpGxLfb.d.mts.map +1 -0
- package/dist/control-2F195jJk.d.mts +11 -0
- package/dist/control-2F195jJk.d.mts.map +1 -0
- package/dist/control-6WFTtLAM.mjs +60 -0
- package/dist/control-6WFTtLAM.mjs.map +1 -0
- package/dist/control-B-FTbEnE.d.mts +22 -0
- package/dist/control-B-FTbEnE.d.mts.map +1 -0
- package/dist/control-D85zv_aY.d.mts +199 -0
- package/dist/control-D85zv_aY.d.mts.map +1 -0
- package/dist/control-DRMWptiJ.mjs +1355 -0
- package/dist/control-DRMWptiJ.mjs.map +1 -0
- package/dist/control-adapter-B9t0g7Pf-HrCxlM65.mjs +1901 -0
- package/dist/control-adapter-B9t0g7Pf-HrCxlM65.mjs.map +1 -0
- package/dist/control-policy-Cl3RRSPg-CT3QGpR3.mjs +1257 -0
- package/dist/control-policy-Cl3RRSPg-CT3QGpR3.mjs.map +1 -0
- package/dist/data-transform-BSM7TQpE.d.mts +1 -0
- package/dist/data-transform-ChZzy2dP-CxVCat_8.mjs +53 -0
- package/dist/data-transform-ChZzy2dP-CxVCat_8.mjs.map +1 -0
- package/dist/data-transform-Ck5FbyNO-BNE7QlAo.d.mts +38 -0
- package/dist/data-transform-Ck5FbyNO-BNE7QlAo.d.mts.map +1 -0
- package/dist/ddl-B4Rh8ntj.d.mts +1 -0
- package/dist/ddl-BdP4q3KY-Duef4uHw.mjs +395 -0
- package/dist/ddl-BdP4q3KY-Duef4uHw.mjs.map +1 -0
- package/dist/default-normalizer-B36TOul4.d.mts +31 -0
- package/dist/default-normalizer-B36TOul4.d.mts.map +1 -0
- package/dist/default-normalizer-Ba5ZebHM-isV86rjy.mjs +253 -0
- package/dist/default-normalizer-Ba5ZebHM-isV86rjy.mjs.map +1 -0
- package/dist/descriptor-meta-2IlVC6_d-DnV00Qd_.mjs +351 -0
- package/dist/descriptor-meta-2IlVC6_d-DnV00Qd_.mjs.map +1 -0
- package/dist/descriptor-meta-DnHabAS3-C53XXPQw.mjs +28 -0
- package/dist/descriptor-meta-DnHabAS3-C53XXPQw.mjs.map +1 -0
- package/dist/descriptor-meta-runtime-UwYdV8fD-B_m_Ha8r.mjs +13 -0
- package/dist/descriptor-meta-runtime-UwYdV8fD-B_m_Ha8r.mjs.map +1 -0
- package/dist/diff-database-schema-BfRs2vrG-D2o4KII0.mjs +390 -0
- package/dist/diff-database-schema-BfRs2vrG-D2o4KII0.mjs.map +1 -0
- package/dist/diff-database-schema-DsoNznGC.d.mts +38 -0
- package/dist/diff-database-schema-DsoNznGC.d.mts.map +1 -0
- package/dist/driver.d.mts +3 -0
- package/dist/driver.mjs +2 -0
- package/dist/driver__control.d.mts +2 -0
- package/dist/driver__control.mjs +2 -0
- package/dist/driver__runtime.d.mts +2 -0
- package/dist/driver__runtime.mjs +597 -0
- package/dist/driver__runtime.mjs.map +1 -0
- package/dist/errors-DCcVX4j1.d.mts +32 -0
- package/dist/errors-DCcVX4j1.d.mts.map +1 -0
- package/dist/errors-kYxOQjdD-D4T3rbVp.mjs +39 -0
- package/dist/errors-kYxOQjdD-D4T3rbVp.mjs.map +1 -0
- package/dist/issue-planner-jkY6p-Ca.d.mts +105 -0
- package/dist/issue-planner-jkY6p-Ca.d.mts.map +1 -0
- package/dist/migration-CBSAPE8S.d.mts +25 -0
- package/dist/migration-CBSAPE8S.d.mts.map +1 -0
- package/dist/migration-PTHAY9Cv.mjs +21 -0
- package/dist/migration-PTHAY9Cv.mjs.map +1 -0
- package/dist/namespace-ids-xtp_ZY86-Cpp8PTxD.mjs +7 -0
- package/dist/namespace-ids-xtp_ZY86-Cpp8PTxD.mjs.map +1 -0
- package/dist/native-type-normalizer-DqJlOTeX.d.mts +19 -0
- package/dist/native-type-normalizer-DqJlOTeX.d.mts.map +1 -0
- package/dist/native-type-normalizer-yvd3tqv-.mjs +38 -0
- package/dist/native-type-normalizer-yvd3tqv-.mjs.map +1 -0
- package/dist/nodes-BU-V-aZA-RqwPH68u.d.mts +235 -0
- package/dist/nodes-BU-V-aZA-RqwPH68u.d.mts.map +1 -0
- package/dist/nodes-DAvDJLvJ-BBdvFXNa.mjs +255 -0
- package/dist/nodes-DAvDJLvJ-BBdvFXNa.mjs.map +1 -0
- package/dist/normalize-error-CNjgVO71-CLlZ3CuJ.mjs +121 -0
- package/dist/normalize-error-CNjgVO71-CLlZ3CuJ.mjs.map +1 -0
- package/dist/op-factory-call-DifL68KT-Bo6pxs-R.mjs +2009 -0
- package/dist/op-factory-call-DifL68KT-Bo6pxs-R.mjs.map +1 -0
- package/dist/op-factory-call-FEA5mnWH.d.mts +1 -0
- package/dist/op-factory-call-jd4cgfjA-CyNT4YVn.d.mts +521 -0
- package/dist/op-factory-call-jd4cgfjA-CyNT4YVn.d.mts.map +1 -0
- package/dist/operation-types-BfRocNI8.d.mts +22 -0
- package/dist/operation-types-BfRocNI8.d.mts.map +1 -0
- package/dist/pack-DFM4tmob.d.mts +610 -0
- package/dist/pack-DFM4tmob.d.mts.map +1 -0
- package/dist/planner-Bmje9ii8-B99fEsNM.mjs +588 -0
- package/dist/planner-Bmje9ii8-B99fEsNM.mjs.map +1 -0
- package/dist/planner-DL4Bh5Nk.d.mts +163 -0
- package/dist/planner-DL4Bh5Nk.d.mts.map +1 -0
- package/dist/planner-ddl-builders-CbfICQfm-CxYiLrhX.mjs +102 -0
- package/dist/planner-ddl-builders-CbfICQfm-CxYiLrhX.mjs.map +1 -0
- package/dist/planner-ddl-builders-ijp60-JO.d.mts +19 -0
- package/dist/planner-ddl-builders-ijp60-JO.d.mts.map +1 -0
- package/dist/planner-identity-values-BmHn5C6U-BYBbUAyR.mjs +90 -0
- package/dist/planner-identity-values-BmHn5C6U-BYBbUAyR.mjs.map +1 -0
- package/dist/planner-identity-values-TfEhnoWa.d.mts +25 -0
- package/dist/planner-identity-values-TfEhnoWa.d.mts.map +1 -0
- package/dist/planner-produced-postgres-migration-B0PQLLUb-qsS6cQqX.d.mts +25 -0
- package/dist/planner-produced-postgres-migration-B0PQLLUb-qsS6cQqX.d.mts.map +1 -0
- package/dist/planner-produced-postgres-migration-C3GPZWeC.d.mts +1 -0
- package/dist/planner-produced-postgres-migration-Cicg2sXg-Ck9iDxGI.mjs +47 -0
- package/dist/planner-produced-postgres-migration-Cicg2sXg-Ck9iDxGI.mjs.map +1 -0
- package/dist/planner-schema-lookup-C4DHAddq.d.mts +21 -0
- package/dist/planner-schema-lookup-C4DHAddq.d.mts.map +1 -0
- package/dist/planner-schema-lookup-kMIVP2y--CdO4VlnF.mjs +57 -0
- package/dist/planner-schema-lookup-kMIVP2y--CdO4VlnF.mjs.map +1 -0
- package/dist/planner-sql-checks-CFgbRTJw.d.mts +20 -0
- package/dist/planner-sql-checks-CFgbRTJw.d.mts.map +1 -0
- package/dist/planner-sql-checks-DRc_78n8-C9nHOrvU.mjs +152 -0
- package/dist/planner-sql-checks-DRc_78n8-C9nHOrvU.mjs.map +1 -0
- package/dist/planner-target-details-HkP4RrRO-_xPQVPF0.d.mts +12 -0
- package/dist/planner-target-details-HkP4RrRO-_xPQVPF0.d.mts.map +1 -0
- package/dist/planner-type-resolution-Bt2f_q-F-C4T6YTae.mjs +15 -0
- package/dist/planner-type-resolution-Bt2f_q-F-C4T6YTae.mjs.map +1 -0
- package/dist/postgres-contract-view-2OP5JnXl-D2fpy4-8.d.mts +36 -0
- package/dist/postgres-contract-view-2OP5JnXl-D2fpy4-8.d.mts.map +1 -0
- package/dist/postgres-contract-view-FdLX7dV9-Cat1VKV9.mjs +144 -0
- package/dist/postgres-contract-view-FdLX7dV9-Cat1VKV9.mjs.map +1 -0
- package/dist/postgres-database-schema-node-CyfpHXDr-BqyozkQE.d.mts +285 -0
- package/dist/postgres-database-schema-node-CyfpHXDr-BqyozkQE.d.mts.map +1 -0
- package/dist/postgres-migration-CDJj7CvD-Bsqs_fVo.d.mts +260 -0
- package/dist/postgres-migration-CDJj7CvD-Bsqs_fVo.d.mts.map +1 -0
- package/dist/postgres-migration-CJshdIZn-DYYjgdD0.mjs +201 -0
- package/dist/postgres-migration-CJshdIZn-DYYjgdD0.mjs.map +1 -0
- package/dist/postgres-native-enum-CdP3b_-R-Cgz9KEKx.mjs +45 -0
- package/dist/postgres-native-enum-CdP3b_-R-Cgz9KEKx.mjs.map +1 -0
- package/dist/postgres-rls-policy-CnDxf3z9-C3LIHAIG.d.mts +61 -0
- package/dist/postgres-rls-policy-CnDxf3z9-C3LIHAIG.d.mts.map +1 -0
- package/dist/postgres-role-schema-node-B8Z5i5D--PObwlU2Z.mjs +204 -0
- package/dist/postgres-role-schema-node-B8Z5i5D--PObwlU2Z.mjs.map +1 -0
- package/dist/postgres-schema-KSzLDONj-CsXGoY8b.mjs +421 -0
- package/dist/postgres-schema-KSzLDONj-CsXGoY8b.mjs.map +1 -0
- package/dist/postgres-schema-Xsjt3RKO-Buv2X8ai.d.mts +269 -0
- package/dist/postgres-schema-Xsjt3RKO-Buv2X8ai.d.mts.map +1 -0
- package/dist/postgres-table-schema-node-BBkitBQh-DT1T5VWU.mjs +212 -0
- package/dist/postgres-table-schema-node-BBkitBQh-DT1T5VWU.mjs.map +1 -0
- package/dist/render-ops-DPwhZt2W.d.mts +11 -0
- package/dist/render-ops-DPwhZt2W.d.mts.map +1 -0
- package/dist/render-ops-DxzTxSsv-Bz85uUHk.mjs +34 -0
- package/dist/render-ops-DxzTxSsv-Bz85uUHk.mjs.map +1 -0
- package/dist/render-typescript-6sCFvMBh.d.mts +21 -0
- package/dist/render-typescript-6sCFvMBh.d.mts.map +1 -0
- package/dist/render-typescript-Cw3lFO28-Cx0lXWmv.mjs +117 -0
- package/dist/render-typescript-Cw3lFO28-Cx0lXWmv.mjs.map +1 -0
- package/dist/resolve-ddl-schema-CxqlLW47-0GiHRziS.mjs +22 -0
- package/dist/resolve-ddl-schema-CxqlLW47-0GiHRziS.mjs.map +1 -0
- package/dist/runtime-BbSRVwdd.d.mts +12 -0
- package/dist/runtime-BbSRVwdd.d.mts.map +1 -0
- package/dist/runtime-CDewySU9.d.mts +55 -0
- package/dist/runtime-CDewySU9.d.mts.map +1 -0
- package/dist/runtime-_TfO66h5.d.mts +32 -0
- package/dist/runtime-_TfO66h5.d.mts.map +1 -0
- package/dist/schema-ir-annotations-DuuYh0gl.d.mts +15 -0
- package/dist/schema-ir-annotations-DuuYh0gl.d.mts.map +1 -0
- package/dist/schema-node-kinds-qlnURWJy-Bo30pwTM.d.mts +30 -0
- package/dist/schema-node-kinds-qlnURWJy-Bo30pwTM.d.mts.map +1 -0
- package/dist/sql-utils-BnBlQxyh-DaX9Nb7Z.mjs +90 -0
- package/dist/sql-utils-BnBlQxyh-DaX9Nb7Z.mjs.map +1 -0
- package/dist/sql-utils-DW6fkczF.d.mts +62 -0
- package/dist/sql-utils-DW6fkczF.d.mts.map +1 -0
- package/dist/table-source-ikHOZmhD-DriY1Lcr.d.mts +15 -0
- package/dist/table-source-ikHOZmhD-DriY1Lcr.d.mts.map +1 -0
- package/dist/target.d.mts +47 -0
- package/dist/target.mjs +34 -0
- package/dist/target__codec-descriptor.d.mts +3 -0
- package/dist/target__codec-descriptor.mjs +2 -0
- package/dist/target__codec-ids.d.mts +3 -0
- package/dist/target__codec-ids.mjs +2 -0
- package/dist/target__codec-types.d.mts +4 -0
- package/dist/target__codec-types.mjs +1 -0
- package/dist/target__codecs.d.mts +3 -0
- package/dist/target__codecs.mjs +3 -0
- package/dist/target__contract-free.d.mts +3 -0
- package/dist/target__contract-free.mjs +4 -0
- package/dist/target__control.d.mts +2 -0
- package/dist/target__control.mjs +2 -0
- package/dist/target__data-transform.d.mts +3 -0
- package/dist/target__data-transform.mjs +2 -0
- package/dist/target__ddl.d.mts +4 -0
- package/dist/target__ddl.mjs +2 -0
- package/dist/target__default-normalizer.d.mts +2 -0
- package/dist/target__default-normalizer.mjs +2 -0
- package/dist/target__diff-database-schema.d.mts +2 -0
- package/dist/target__diff-database-schema.mjs +2 -0
- package/dist/target__errors.d.mts +2 -0
- package/dist/target__errors.mjs +2 -0
- package/dist/target__issue-planner.d.mts +2 -0
- package/dist/target__issue-planner.mjs +2 -0
- package/dist/target__migration.d.mts +4 -0
- package/dist/target__migration.mjs +5 -0
- package/dist/target__native-type-normalizer.d.mts +2 -0
- package/dist/target__native-type-normalizer.mjs +2 -0
- package/dist/target__op-factory-call.d.mts +3 -0
- package/dist/target__op-factory-call.mjs +2 -0
- package/dist/target__pack.d.mts +2 -0
- package/dist/target__pack.mjs +2 -0
- package/dist/target__planner-ddl-builders.d.mts +2 -0
- package/dist/target__planner-ddl-builders.mjs +2 -0
- package/dist/target__planner-identity-values.d.mts +2 -0
- package/dist/target__planner-identity-values.mjs +2 -0
- package/dist/target__planner-produced-postgres-migration.d.mts +3 -0
- package/dist/target__planner-produced-postgres-migration.mjs +2 -0
- package/dist/target__planner-schema-lookup.d.mts +2 -0
- package/dist/target__planner-schema-lookup.mjs +2 -0
- package/dist/target__planner-sql-checks.d.mts +2 -0
- package/dist/target__planner-sql-checks.mjs +2 -0
- package/dist/target__planner-target-details.d.mts +2 -0
- package/dist/target__planner-target-details.mjs +1 -0
- package/dist/target__planner.d.mts +2 -0
- package/dist/target__planner.mjs +3 -0
- package/dist/target__render-ops.d.mts +2 -0
- package/dist/target__render-ops.mjs +2 -0
- package/dist/target__render-typescript.d.mts +2 -0
- package/dist/target__render-typescript.mjs +2 -0
- package/dist/target__rls-canonicalize.d.mts +2 -0
- package/dist/target__rls-canonicalize.mjs +2 -0
- package/dist/target__runtime.d.mts +3 -0
- package/dist/target__runtime.mjs +23 -0
- package/dist/target__runtime.mjs.map +1 -0
- package/dist/target__schema-ir-annotations.d.mts +2 -0
- package/dist/target__schema-ir-annotations.mjs +2 -0
- package/dist/target__sql-utils.d.mts +2 -0
- package/dist/target__sql-utils.mjs +2 -0
- package/dist/target__types.d.mts +7 -0
- package/dist/target__types.mjs +5 -0
- package/dist/types-CkryN1AS-6MNZLjLY.d.mts +27 -0
- package/dist/types-CkryN1AS-6MNZLjLY.d.mts.map +1 -0
- package/dist/types-Cp_Jf2tk.d.mts +1 -0
- package/dist/types-ue6jkJyF-BQJzjx1P.d.mts +10 -0
- package/dist/types-ue6jkJyF-BQJzjx1P.d.mts.map +1 -0
- package/dist/types-xa86TkcV.d.mts +32 -0
- package/dist/types-xa86TkcV.d.mts.map +1 -0
- package/package.json +95 -0
|
@@ -0,0 +1,1486 @@
|
|
|
1
|
+
import { a as postgresCodec, r as definePostgresCodecs, t as PostgresCodecDescriptor } from "./codec-descriptor-CB6x0xEu-C-Zn2IEz.mjs";
|
|
2
|
+
import { C as PG_TIMETZ_CODEC_ID, D as PG_VARCHAR_CODEC_ID, E as PG_VARBIT_CODEC_ID, S as PG_TIMESTAMP_CODEC_ID, T as PG_UUID_CODEC_ID, _ as PG_JSON_CODEC_ID, a as PG_DATE_CODEC_ID, b as PG_TEXT_CODEC_ID, c as PG_FLOAT8_CODEC_ID, d as PG_INT2_CODEC_ID, f as PG_INT4_CODEC_ID, g as PG_JSONB_CODEC_ID, h as PG_INT_CODEC_ID, i as PG_CHAR_CODEC_ID, l as PG_FLOAT_CODEC_ID, m as PG_INTERVAL_CODEC_ID, n as PG_BOOL_CODEC_ID, o as PG_ENUM_CODEC_ID, p as PG_INT8_CODEC_ID, r as PG_BYTEA_CODEC_ID, s as PG_FLOAT4_CODEC_ID, t as PG_BIT_CODEC_ID, u as PG_INET_CODEC_ID, v as PG_NUMERIC_CODEC_ID, w as PG_TIME_CODEC_ID, x as PG_TIMESTAMPTZ_CODEC_ID, y as PG_TEXT_ARRAY_CODEC_ID } from "./codec-ids-tX7Svtz--BuOfRaVU.mjs";
|
|
3
|
+
import { n as postgresError } from "./errors-kYxOQjdD-D4T3rbVp.mjs";
|
|
4
|
+
import { t as PostgresNativeEnum } from "./postgres-native-enum-CdP3b_-R-Cgz9KEKx.mjs";
|
|
5
|
+
import { BinaryExpr, CaseExpr, CastExpr, FunctionCallExpr, LiteralExpr, NullCheckExpr, OrExpr, SqlCharCodec, SqlFloatCodec, SqlIntCodec, SqlVarcharCodec, sqlCharDescriptor, sqlFloatDescriptor, sqlIntDescriptor, sqlTextDescriptor, sqlTimestampDescriptor, sqlVarcharDescriptor } from "@prisma/orm-family-sql/relational-core/ast";
|
|
6
|
+
import { CodecImpl, column, renderTsLiteral, voidParamsSchema } from "@prisma/orm-framework/components/codec";
|
|
7
|
+
import { blindCast } from "@prisma/orm-framework/utils/casts";
|
|
8
|
+
import { UNBOUND_NAMESPACE_ID } from "@prisma/orm-framework/components/ir";
|
|
9
|
+
import { type } from "arktype";
|
|
10
|
+
//#region ../../../3-targets/3-targets/postgres/dist/codecs-CBl0nD44.mjs
|
|
11
|
+
function renderLength(typeName, typeParams) {
|
|
12
|
+
const length = typeParams["length"];
|
|
13
|
+
if (length === void 0) return;
|
|
14
|
+
if (typeof length !== "number" || !Number.isFinite(length) || !Number.isInteger(length)) throw postgresError("RUNTIME.TYPE_PARAMS_INVALID", `renderOutputType: expected integer "length" in typeParams for ${typeName}, got ${String(length)}`, { meta: {
|
|
15
|
+
nativeType: typeName,
|
|
16
|
+
param: "length",
|
|
17
|
+
received: String(length)
|
|
18
|
+
} });
|
|
19
|
+
return `${typeName}<${length}>`;
|
|
20
|
+
}
|
|
21
|
+
function renderPrecision(typeName, typeParams) {
|
|
22
|
+
const precision = typeParams["precision"];
|
|
23
|
+
if (precision === void 0) return typeName;
|
|
24
|
+
if (typeof precision !== "number" || !Number.isFinite(precision) || !Number.isInteger(precision)) throw postgresError("RUNTIME.TYPE_PARAMS_INVALID", `renderOutputType: expected integer "precision" in typeParams for ${typeName}, got ${String(precision)}`, { meta: {
|
|
25
|
+
nativeType: typeName,
|
|
26
|
+
param: "precision",
|
|
27
|
+
received: String(precision)
|
|
28
|
+
} });
|
|
29
|
+
return `${typeName}<${precision}>`;
|
|
30
|
+
}
|
|
31
|
+
const pgNumericDecode = (wire) => {
|
|
32
|
+
if (typeof wire === "number") return String(wire);
|
|
33
|
+
return wire;
|
|
34
|
+
};
|
|
35
|
+
const DECIMAL_INTEGER = /^-?\d+$/;
|
|
36
|
+
/** Reads an `int8` wire or JSON value as a `bigint`, rejecting anything `BigInt()` would misread. */
|
|
37
|
+
const pgInt8Decode = (wire) => {
|
|
38
|
+
if (typeof wire === "bigint") return wire;
|
|
39
|
+
const text = String(wire);
|
|
40
|
+
if (!DECIMAL_INTEGER.test(text)) throw postgresError("RUNTIME.DECODE_FAILED", "pg/int8@1 value must be a decimal integer", { meta: {
|
|
41
|
+
codecId: "pg/int8@1",
|
|
42
|
+
received: text
|
|
43
|
+
} });
|
|
44
|
+
return BigInt(text);
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Renders an `int8` default as a `bigint` literal. The canonical JSON is decimal
|
|
48
|
+
* text but the application type is `bigint`, so a plain string literal would not
|
|
49
|
+
* typecheck against the emitted column type.
|
|
50
|
+
*/
|
|
51
|
+
const pgInt8RenderValueLiteral = (value) => typeof value === "string" && DECIMAL_INTEGER.test(value) ? `${value}n` : void 0;
|
|
52
|
+
const pgNumericRenderOutputType = (typeParams) => {
|
|
53
|
+
const precision = typeParams.precision;
|
|
54
|
+
if (precision === void 0) return void 0;
|
|
55
|
+
if (typeof precision !== "number" || !Number.isFinite(precision) || !Number.isInteger(precision)) throw postgresError("RUNTIME.TYPE_PARAMS_INVALID", `renderOutputType: expected integer "precision" in typeParams for Numeric, got ${String(precision)}`, { meta: {
|
|
56
|
+
nativeType: "Numeric",
|
|
57
|
+
param: "precision",
|
|
58
|
+
received: String(precision)
|
|
59
|
+
} });
|
|
60
|
+
const scale = typeParams.scale;
|
|
61
|
+
if (scale === void 0) return `Numeric<${precision}>`;
|
|
62
|
+
if (typeof scale !== "number" || !Number.isFinite(scale) || !Number.isInteger(scale)) throw postgresError("RUNTIME.TYPE_PARAMS_INVALID", `renderOutputType: expected integer "scale" in typeParams for Numeric, got ${String(scale)}`, { meta: {
|
|
63
|
+
nativeType: "Numeric",
|
|
64
|
+
param: "scale",
|
|
65
|
+
received: String(scale)
|
|
66
|
+
} });
|
|
67
|
+
return `Numeric<${precision}, ${scale}>`;
|
|
68
|
+
};
|
|
69
|
+
const ISO_8601_TIMESTAMP = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,9})?$/;
|
|
70
|
+
const ISO_8601_TIMESTAMPTZ = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,9})?(?:Z|[+-]\d{2}:\d{2})$/;
|
|
71
|
+
const pgTimestampEncodeJson = (value) => value.toISOString().slice(0, -1);
|
|
72
|
+
const pgTimestampDecodeJson = (json) => {
|
|
73
|
+
if (typeof json !== "string") throw postgresError("RUNTIME.DECODE_FAILED", `Expected ISO date string for pg/timestamp@1, got ${typeof json}`, { meta: {
|
|
74
|
+
codecId: "pg/timestamp@1",
|
|
75
|
+
received: typeof json
|
|
76
|
+
} });
|
|
77
|
+
if (!ISO_8601_TIMESTAMP.test(json)) throw postgresError("RUNTIME.DECODE_FAILED", `Invalid ISO date string for pg/timestamp@1: ${json}`, { meta: {
|
|
78
|
+
codecId: "pg/timestamp@1",
|
|
79
|
+
received: json
|
|
80
|
+
} });
|
|
81
|
+
const date = /* @__PURE__ */ new Date(`${json}Z`);
|
|
82
|
+
if (Number.isNaN(date.getTime())) throw postgresError("RUNTIME.DECODE_FAILED", `Invalid ISO date string for pg/timestamp@1: ${json}`, { meta: {
|
|
83
|
+
codecId: "pg/timestamp@1",
|
|
84
|
+
received: json
|
|
85
|
+
} });
|
|
86
|
+
return date;
|
|
87
|
+
};
|
|
88
|
+
const pgTimestamptzEncodeJson = (value) => value.toISOString().replace(/Z$/, "+00:00");
|
|
89
|
+
const pgTimestamptzDecodeJson = (json) => {
|
|
90
|
+
if (typeof json !== "string") throw postgresError("RUNTIME.DECODE_FAILED", `Expected ISO date string for pg/timestamptz@1, got ${typeof json}`, { meta: {
|
|
91
|
+
codecId: "pg/timestamptz@1",
|
|
92
|
+
received: typeof json
|
|
93
|
+
} });
|
|
94
|
+
if (!ISO_8601_TIMESTAMPTZ.test(json)) throw postgresError("RUNTIME.DECODE_FAILED", `Invalid ISO date string for pg/timestamptz@1: ${json}`, { meta: {
|
|
95
|
+
codecId: "pg/timestamptz@1",
|
|
96
|
+
received: json
|
|
97
|
+
} });
|
|
98
|
+
const date = new Date(json);
|
|
99
|
+
if (Number.isNaN(date.getTime())) throw postgresError("RUNTIME.DECODE_FAILED", `Invalid ISO date string for pg/timestamptz@1: ${json}`, { meta: {
|
|
100
|
+
codecId: "pg/timestamptz@1",
|
|
101
|
+
received: json
|
|
102
|
+
} });
|
|
103
|
+
return date;
|
|
104
|
+
};
|
|
105
|
+
const ISO_8601_DATE = /^(\d{4})-(\d{2})-(\d{2})$/;
|
|
106
|
+
function formatDateOnly(year, month, day) {
|
|
107
|
+
return `${String(year).padStart(4, "0")}-${String(month).padStart(2, "0")}-${String(day).padStart(2, "0")}`;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* A Postgres `date` has no time-of-day or timezone component, so `pg/date@1`
|
|
111
|
+
* canonicalizes its JS-level value as a `Date` at UTC midnight
|
|
112
|
+
* (`Date.UTC(y, m, d)`), independent of the process's local timezone.
|
|
113
|
+
*
|
|
114
|
+
* `pgDateEncode` reads the calendar date via UTC getters (matching that
|
|
115
|
+
* canonical form) and formats it as `YYYY-MM-DD` directly, bypassing the pg
|
|
116
|
+
* driver's own `Date` serialization (`dateToString`), which reads *local*
|
|
117
|
+
* getters and would shift the calendar day near midnight in negative-UTC-offset
|
|
118
|
+
* environments.
|
|
119
|
+
*/
|
|
120
|
+
const pgDateEncode = (value) => formatDateOnly(value.getUTCFullYear(), value.getUTCMonth() + 1, value.getUTCDate());
|
|
121
|
+
/**
|
|
122
|
+
* Normalizes the pg driver's already-parsed `Date` for a `date` column into
|
|
123
|
+
* the canonical UTC-midnight form. The driver (via `postgres-date`) builds
|
|
124
|
+
* that `Date` at *local* midnight from the wire text; reading it back with the
|
|
125
|
+
* same (local) getters recovers the exact calendar date the driver parsed,
|
|
126
|
+
* and reconstructing via `Date.UTC` makes the result's instant independent of
|
|
127
|
+
* the process's timezone.
|
|
128
|
+
*/
|
|
129
|
+
const pgDateDecode = (wire) => new Date(Date.UTC(wire.getFullYear(), wire.getMonth(), wire.getDate()));
|
|
130
|
+
const pgDateEncodeJson = (value) => pgDateEncode(value);
|
|
131
|
+
const pgDateDecodeJson = (json) => {
|
|
132
|
+
if (typeof json !== "string") throw postgresError("RUNTIME.DECODE_FAILED", `Expected date string for pg/date@1, got ${typeof json}`, { meta: {
|
|
133
|
+
codecId: "pg/date@1",
|
|
134
|
+
received: typeof json
|
|
135
|
+
} });
|
|
136
|
+
const match = ISO_8601_DATE.exec(json);
|
|
137
|
+
if (!match) throw postgresError("RUNTIME.DECODE_FAILED", `Invalid date string for pg/date@1: ${json}`, { meta: {
|
|
138
|
+
codecId: "pg/date@1",
|
|
139
|
+
received: json
|
|
140
|
+
} });
|
|
141
|
+
const [, yearText, monthText, dayText] = match;
|
|
142
|
+
const year = Number(yearText);
|
|
143
|
+
const month = Number(monthText) - 1;
|
|
144
|
+
const day = Number(dayText);
|
|
145
|
+
const date = new Date(Date.UTC(year, month, day));
|
|
146
|
+
if (date.getUTCFullYear() !== year || date.getUTCMonth() !== month || date.getUTCDate() !== day) throw postgresError("RUNTIME.DECODE_FAILED", `Invalid date string for pg/date@1: ${json}`, { meta: {
|
|
147
|
+
codecId: "pg/date@1",
|
|
148
|
+
received: json
|
|
149
|
+
} });
|
|
150
|
+
return date;
|
|
151
|
+
};
|
|
152
|
+
const ISO_DURATION = /^P(?!$)(-?\d+Y)?(-?\d+M)?(-?\d+D)?(?:T(?!$)(-?\d+H)?(-?\d+M)?(-?\d+(?:\.\d+)?S)?)?$/;
|
|
153
|
+
const MICROS_PER_SECOND = 1000000n;
|
|
154
|
+
/**
|
|
155
|
+
* Converts a fractional-seconds digit string to microseconds, rounding rather
|
|
156
|
+
* than truncating past the sixth digit.
|
|
157
|
+
*
|
|
158
|
+
* PostgreSQL rounds: `INTERVAL '1.1234567 seconds'` is `1.123457`, and
|
|
159
|
+
* `'1.9999999 seconds'` carries into `2`. Truncating here made the parsed value
|
|
160
|
+
* disagree with the database for any input past microsecond resolution.
|
|
161
|
+
*
|
|
162
|
+
* Ties round toward positive infinity, matching `Math.round` on the sibling path
|
|
163
|
+
* that reads the driver's component object — so the two agree. PostgreSQL's own
|
|
164
|
+
* tie behaviour is unobservable, because it parses the literal into a double
|
|
165
|
+
* first and an exact half never survives that.
|
|
166
|
+
*/
|
|
167
|
+
const microsFromFraction = (fraction, negative) => {
|
|
168
|
+
if (fraction === "") return 0n;
|
|
169
|
+
const kept = BigInt(fraction.slice(0, 6).padEnd(6, "0"));
|
|
170
|
+
const rest = fraction.slice(6).replace(/0+$/, "");
|
|
171
|
+
if (rest === "") return kept;
|
|
172
|
+
const half = rest[0] === "5" && rest.length === 1;
|
|
173
|
+
return rest > "5" || half && !negative ? kept + 1n : kept;
|
|
174
|
+
};
|
|
175
|
+
const intervalFieldsOf = (text) => {
|
|
176
|
+
const match = ISO_DURATION.exec(text);
|
|
177
|
+
if (match === null) throw postgresError("RUNTIME.DECODE_FAILED", `pg/interval@1 value must be an ISO-8601 duration, got ${text}`, { meta: {
|
|
178
|
+
codecId: "pg/interval@1",
|
|
179
|
+
received: text
|
|
180
|
+
} });
|
|
181
|
+
const [, years, months, days, hours, minutes, seconds] = match;
|
|
182
|
+
const wholeNumber = (part) => part === void 0 ? 0 : Number(part.slice(0, -1));
|
|
183
|
+
const secondsLiteral = seconds === void 0 ? "0" : seconds.slice(0, -1);
|
|
184
|
+
const negative = secondsLiteral.startsWith("-");
|
|
185
|
+
const [whole = "0", fraction = ""] = secondsLiteral.replace("-", "").split(".");
|
|
186
|
+
const magnitude = BigInt(whole) * MICROS_PER_SECOND + microsFromFraction(fraction, negative);
|
|
187
|
+
return {
|
|
188
|
+
months: wholeNumber(years) * 12 + wholeNumber(months),
|
|
189
|
+
days: wholeNumber(days),
|
|
190
|
+
micros: BigInt(wholeNumber(hours)) * 3600n * MICROS_PER_SECOND + BigInt(wholeNumber(minutes)) * 60n * MICROS_PER_SECOND + (negative ? -magnitude : magnitude)
|
|
191
|
+
};
|
|
192
|
+
};
|
|
193
|
+
const secondsText = (micros) => {
|
|
194
|
+
const sign = micros < 0n ? "-" : "";
|
|
195
|
+
const magnitude = micros < 0n ? -micros : micros;
|
|
196
|
+
const whole = magnitude / MICROS_PER_SECOND % 60n;
|
|
197
|
+
const fraction = magnitude % MICROS_PER_SECOND;
|
|
198
|
+
return `${sign}${whole}${fraction === 0n ? "" : `.${fraction.toString().padStart(6, "0").replace(/0+$/, "")}`}`;
|
|
199
|
+
};
|
|
200
|
+
/**
|
|
201
|
+
* Renders {@link PgInterval} the way PostgreSQL spells an interval under
|
|
202
|
+
* `IntervalStyle = 'iso_8601'`: zero components omitted, `T` present only when a
|
|
203
|
+
* time component is, each component carrying its own sign, and an all-zero
|
|
204
|
+
* interval written `PT0S`.
|
|
205
|
+
*/
|
|
206
|
+
const formatIsoDuration = ({ months, days, micros }) => {
|
|
207
|
+
const years = Math.trunc(months / 12);
|
|
208
|
+
const restMonths = months % 12;
|
|
209
|
+
const sign = micros < 0n ? "-" : "";
|
|
210
|
+
const magnitude = micros < 0n ? -micros : micros;
|
|
211
|
+
const hours = magnitude / (3600n * MICROS_PER_SECOND);
|
|
212
|
+
const minutes = magnitude / (60n * MICROS_PER_SECOND) % 60n;
|
|
213
|
+
const hasSeconds = magnitude % (60n * MICROS_PER_SECOND) !== 0n;
|
|
214
|
+
const parts = [
|
|
215
|
+
years === 0 ? "" : `${years}Y`,
|
|
216
|
+
restMonths === 0 ? "" : `${restMonths}M`,
|
|
217
|
+
days === 0 ? "" : `${days}D`
|
|
218
|
+
];
|
|
219
|
+
const time = [
|
|
220
|
+
hours === 0n ? "" : `${sign}${hours}H`,
|
|
221
|
+
minutes === 0n ? "" : `${sign}${minutes}M`,
|
|
222
|
+
hasSeconds ? `${secondsText(micros)}S` : ""
|
|
223
|
+
].join("");
|
|
224
|
+
const rendered = `P${parts.join("")}${time === "" ? "" : `T${time}`}`;
|
|
225
|
+
return rendered === "P" ? "PT0S" : rendered;
|
|
226
|
+
};
|
|
227
|
+
/** Renders the application value as its canonical ISO-8601 duration. */
|
|
228
|
+
const pgIntervalToIso = (value) => formatIsoDuration(value);
|
|
229
|
+
const pgIntervalEncodeJson = (value) => formatIsoDuration(value);
|
|
230
|
+
const pgIntervalDecodeJson = (json) => {
|
|
231
|
+
if (typeof json !== "string") throw postgresError("RUNTIME.DECODE_FAILED", "pg/interval@1 database JSON value must be an ISO-8601 duration string", { meta: {
|
|
232
|
+
codecId: "pg/interval@1",
|
|
233
|
+
received: typeof json
|
|
234
|
+
} });
|
|
235
|
+
return intervalFieldsOf(json);
|
|
236
|
+
};
|
|
237
|
+
/**
|
|
238
|
+
* Reads the driver's wire value into the application value. `pg` parses an
|
|
239
|
+
* interval into a component object, which is the same three fields under other
|
|
240
|
+
* names; a text wire value is an ISO-8601 duration, because that is what the
|
|
241
|
+
* codec writes.
|
|
242
|
+
*/
|
|
243
|
+
const pgIntervalDecode = (wire) => {
|
|
244
|
+
if (typeof wire === "string") return intervalFieldsOf(wire);
|
|
245
|
+
const part = (name) => {
|
|
246
|
+
const raw = wire[name];
|
|
247
|
+
return typeof raw === "number" ? raw : 0;
|
|
248
|
+
};
|
|
249
|
+
const seconds = part("seconds") + part("milliseconds") / 1e3;
|
|
250
|
+
return {
|
|
251
|
+
months: part("years") * 12 + part("months"),
|
|
252
|
+
days: part("days"),
|
|
253
|
+
micros: BigInt(part("hours")) * 3600n * MICROS_PER_SECOND + BigInt(part("minutes")) * 60n * MICROS_PER_SECOND + BigInt(Math.round(seconds * 1e6))
|
|
254
|
+
};
|
|
255
|
+
};
|
|
256
|
+
const BASE64_TEXT = /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/;
|
|
257
|
+
const pgByteaEncodeJson = (value) => Buffer.from(value).toString("base64");
|
|
258
|
+
const pgByteaDecodeJson = (value) => {
|
|
259
|
+
if (typeof value !== "string" || !BASE64_TEXT.test(value)) throw postgresError("RUNTIME.DECODE_FAILED", "pg/bytea@1 database JSON value must be a base64 string", { meta: { codecId: "pg/bytea@1" } });
|
|
260
|
+
return new Uint8Array(Buffer.from(value, "base64"));
|
|
261
|
+
};
|
|
262
|
+
const pgJsonEncode = (value) => JSON.stringify(value);
|
|
263
|
+
const pgJsonDecode = (wire) => typeof wire === "string" ? JSON.parse(wire) : wire;
|
|
264
|
+
const pgJsonbEncode = (value) => JSON.stringify(value);
|
|
265
|
+
const pgJsonbDecode = (wire) => typeof wire === "string" ? JSON.parse(wire) : wire;
|
|
266
|
+
const lengthParamsSchema = type({ "length?": "number.integer > 0" });
|
|
267
|
+
const numericParamsSchema = type({
|
|
268
|
+
"precision?": "number.integer > 0 & number.integer <= 1000",
|
|
269
|
+
"scale?": "number.integer >= 0"
|
|
270
|
+
});
|
|
271
|
+
const precisionParamsSchema = type({ "precision?": "number.integer >= 0 & number.integer <= 6" });
|
|
272
|
+
const PG_TEXT_NATIVE_TYPE = "text";
|
|
273
|
+
const PG_TEXT_ARRAY_NATIVE_TYPE = "text[]";
|
|
274
|
+
const PG_INT4_NATIVE_TYPE = "integer";
|
|
275
|
+
const PG_INT2_NATIVE_TYPE = "smallint";
|
|
276
|
+
const PG_INT8_NATIVE_TYPE = "bigint";
|
|
277
|
+
const PG_FLOAT4_NATIVE_TYPE = "real";
|
|
278
|
+
const PG_FLOAT8_NATIVE_TYPE = "double precision";
|
|
279
|
+
const PG_NUMERIC_NATIVE_TYPE = "numeric";
|
|
280
|
+
const PG_DATE_NATIVE_TYPE = "date";
|
|
281
|
+
const PG_TIMESTAMP_NATIVE_TYPE = "timestamp without time zone";
|
|
282
|
+
const PG_TIMESTAMPTZ_NATIVE_TYPE = "timestamp with time zone";
|
|
283
|
+
const PG_TIME_NATIVE_TYPE = "time";
|
|
284
|
+
const PG_TIMETZ_NATIVE_TYPE = "timetz";
|
|
285
|
+
const PG_BOOL_NATIVE_TYPE = "boolean";
|
|
286
|
+
const PG_BIT_NATIVE_TYPE = "bit";
|
|
287
|
+
const PG_VARBIT_NATIVE_TYPE = "bit varying";
|
|
288
|
+
const PG_BYTEA_NATIVE_TYPE = "bytea";
|
|
289
|
+
const PG_INTERVAL_NATIVE_TYPE = "interval";
|
|
290
|
+
const PG_JSON_NATIVE_TYPE = "json";
|
|
291
|
+
const PG_JSONB_NATIVE_TYPE = "jsonb";
|
|
292
|
+
/**
|
|
293
|
+
* Projects the expression unchanged, for codecs whose canonical JSON is what
|
|
294
|
+
* PostgreSQL's own JSON conversion already produces.
|
|
295
|
+
*
|
|
296
|
+
* Identity here is a claim about the target's behaviour, not an absence of one:
|
|
297
|
+
* the codec's conformance cases are what test it, including at the boundaries
|
|
298
|
+
* of the representation — escaping, sign, and range — where a native conversion
|
|
299
|
+
* would be most likely to diverge.
|
|
300
|
+
*/
|
|
301
|
+
/**
|
|
302
|
+
* Whether a string is numeric text in the form PostgreSQL *prints*, which is
|
|
303
|
+
* narrower than the form it accepts.
|
|
304
|
+
*
|
|
305
|
+
* `numeric` reads `+123`, `.5`, `1.`, `1e5`, `0x1f`, `1_000` and whitespace-padded
|
|
306
|
+
* input, but prints every one of them in a single normalised form — `123`,
|
|
307
|
+
* `0.5`, `1`, `100000`, `31`, `1000`, `12`. The projection reads the column back
|
|
308
|
+
* through that printing, so accepting an input spelling here would produce an
|
|
309
|
+
* application value the projection can never return: `encodeJson('1e5')` would
|
|
310
|
+
* claim `1e5` where the database yields `100000`.
|
|
311
|
+
*
|
|
312
|
+
* `NaN`, `Infinity` and `-Infinity` are genuine `numeric` values, not error
|
|
313
|
+
* states, and PostgreSQL emits them into JSON as strings — so they belong to the
|
|
314
|
+
* canonical form and round-trip like any other value.
|
|
315
|
+
*/
|
|
316
|
+
const CANONICAL_NUMERIC_TEXT = /^(?:-?\d+(?:\.\d+)?|NaN|-?Infinity)$/;
|
|
317
|
+
const isCanonicalNumericText = (value) => CANONICAL_NUMERIC_TEXT.test(value);
|
|
318
|
+
const identityJsonProjection = (expression) => expression;
|
|
319
|
+
/**
|
|
320
|
+
* Projects a numeric-valued expression as decimal text.
|
|
321
|
+
*
|
|
322
|
+
* The cast is part of the projected expression, which is what makes it correct:
|
|
323
|
+
* whatever `jsonProjection` returns is the argument the JSON constructor
|
|
324
|
+
* receives, so casting here happens *before* PostgreSQL builds the JSON value.
|
|
325
|
+
* Handed a `numeric` or `int8` directly, the constructor emits a JSON **number**,
|
|
326
|
+
* and every digit past IEEE-754's 53 bits of significand is gone by the time the
|
|
327
|
+
* driver has parsed it — before any codec can intervene. A cast applied to the
|
|
328
|
+
* constructor's result instead of its argument would be too late to matter.
|
|
329
|
+
*/
|
|
330
|
+
const decimalTextJsonProjection = (expression) => CastExpr.as(expression, "text");
|
|
331
|
+
/**
|
|
332
|
+
* Projects a `bytea` as base64 text.
|
|
333
|
+
*
|
|
334
|
+
* Like the decimal-text cast, the encoding is part of the projected expression:
|
|
335
|
+
* PostgreSQL's own JSON conversion of a `bytea` emits its `\x`-prefixed hex
|
|
336
|
+
* output form, so the base64 encoding has to replace that conversion rather
|
|
337
|
+
* than post-process it.
|
|
338
|
+
*
|
|
339
|
+
* `encode` emits RFC 2045 base64, which carries a line break every 76
|
|
340
|
+
* characters — so any value over 56 bytes arrives wrapped. The breaks are
|
|
341
|
+
* removed here, because the canonical form is unwrapped base64 and
|
|
342
|
+
* `decodeJson` rejects anything else. `chr(10)` rather than a newline literal
|
|
343
|
+
* keeps the rendered SQL on one line.
|
|
344
|
+
*/
|
|
345
|
+
const base64JsonProjection = (expression) => FunctionCallExpr.of("translate", [
|
|
346
|
+
FunctionCallExpr.of("encode", [expression, LiteralExpr.of("base64")]),
|
|
347
|
+
FunctionCallExpr.of("chr", [LiteralExpr.of(10)]),
|
|
348
|
+
LiteralExpr.of("")
|
|
349
|
+
]);
|
|
350
|
+
/**
|
|
351
|
+
* Projects a `timestamptz` as a UTC ISO-8601 string that no session setting can
|
|
352
|
+
* move.
|
|
353
|
+
*
|
|
354
|
+
* A `timestamptz` handed straight to a JSON constructor is rendered in the
|
|
355
|
+
* session's `TimeZone`, so the same stored instant reads as `+00:00`, `-05:00`
|
|
356
|
+
* or `+05:30` depending on who is connected. `timezone('UTC', …)` resolves the
|
|
357
|
+
* instant to UTC wall-clock independently of the session, and the explicit
|
|
358
|
+
* `to_char` format pins the rendering rather than inheriting `DateStyle`.
|
|
359
|
+
*/
|
|
360
|
+
const utcIsoJsonProjection = (expression) => FunctionCallExpr.of("to_char", [FunctionCallExpr.of("timezone", [LiteralExpr.of("UTC"), expression]), LiteralExpr.of("YYYY-MM-DD\"T\"HH24:MI:SS.MS\"+00:00\"")]);
|
|
361
|
+
const datePart = (field, expression) => FunctionCallExpr.of("date_part", [LiteralExpr.of(field), expression]);
|
|
362
|
+
const whenNonZero = (value, rendered) => CaseExpr.of([{
|
|
363
|
+
condition: BinaryExpr.neq(value, LiteralExpr.of(0)),
|
|
364
|
+
value: rendered
|
|
365
|
+
}], LiteralExpr.of(null));
|
|
366
|
+
/**
|
|
367
|
+
* Projects an `interval` as an ISO-8601 duration.
|
|
368
|
+
*
|
|
369
|
+
* An interval carries months, days and microseconds independently — `P1M` and
|
|
370
|
+
* `P30D` are different intervals — so the projection reads each field with
|
|
371
|
+
* `date_part` and assembles them rather than reducing the value to an epoch,
|
|
372
|
+
* which would have to choose a length for a month. `IntervalStyle` decides how
|
|
373
|
+
* PostgreSQL spells an interval and cannot be bound per expression, so the
|
|
374
|
+
* spelling is constructed here instead of inherited.
|
|
375
|
+
*
|
|
376
|
+
* `concat` drops NULL arguments, so a zero component is omitted by rendering as
|
|
377
|
+
* NULL; the seconds field is taken through `numeric` because a `double
|
|
378
|
+
* precision` microsecond renders in scientific notation.
|
|
379
|
+
*
|
|
380
|
+
* That same NULL-dropping is why the whole assembly sits under an explicit NULL
|
|
381
|
+
* check: for a NULL interval every field is NULL, `concat` yields `'P'`, and the
|
|
382
|
+
* zero-duration fallback below would report an absent value as a zero one.
|
|
383
|
+
*/
|
|
384
|
+
const isoDurationJsonProjection = (expression) => {
|
|
385
|
+
const field = (name) => datePart(name, expression);
|
|
386
|
+
const seconds = CastExpr.as(field("second"), "numeric");
|
|
387
|
+
const assembled = FunctionCallExpr.of("concat", [
|
|
388
|
+
LiteralExpr.of("P"),
|
|
389
|
+
whenNonZero(field("year"), FunctionCallExpr.of("concat", [field("year"), LiteralExpr.of("Y")])),
|
|
390
|
+
whenNonZero(field("month"), FunctionCallExpr.of("concat", [field("month"), LiteralExpr.of("M")])),
|
|
391
|
+
whenNonZero(field("day"), FunctionCallExpr.of("concat", [field("day"), LiteralExpr.of("D")])),
|
|
392
|
+
CaseExpr.of([{
|
|
393
|
+
condition: OrExpr.of([
|
|
394
|
+
BinaryExpr.neq(field("hour"), LiteralExpr.of(0)),
|
|
395
|
+
BinaryExpr.neq(field("minute"), LiteralExpr.of(0)),
|
|
396
|
+
BinaryExpr.neq(field("second"), LiteralExpr.of(0))
|
|
397
|
+
]),
|
|
398
|
+
value: LiteralExpr.of("T")
|
|
399
|
+
}], LiteralExpr.of(null)),
|
|
400
|
+
whenNonZero(field("hour"), FunctionCallExpr.of("concat", [field("hour"), LiteralExpr.of("H")])),
|
|
401
|
+
whenNonZero(field("minute"), FunctionCallExpr.of("concat", [field("minute"), LiteralExpr.of("M")])),
|
|
402
|
+
whenNonZero(field("second"), FunctionCallExpr.of("concat", [seconds, LiteralExpr.of("S")]))
|
|
403
|
+
]);
|
|
404
|
+
return CaseExpr.of([{
|
|
405
|
+
condition: NullCheckExpr.isNull(expression),
|
|
406
|
+
value: LiteralExpr.of(null)
|
|
407
|
+
}], FunctionCallExpr.of("coalesce", [FunctionCallExpr.of("nullif", [assembled, LiteralExpr.of("P")]), LiteralExpr.of("PT0S")]));
|
|
408
|
+
};
|
|
409
|
+
const postgresSqlCharDescriptor = postgresCodec(sqlCharDescriptor, {
|
|
410
|
+
nativeType: () => "character",
|
|
411
|
+
jsonProjection: identityJsonProjection
|
|
412
|
+
});
|
|
413
|
+
const postgresSqlVarcharDescriptor = postgresCodec(sqlVarcharDescriptor, {
|
|
414
|
+
nativeType: () => "character varying",
|
|
415
|
+
jsonProjection: identityJsonProjection
|
|
416
|
+
});
|
|
417
|
+
const postgresSqlIntDescriptor = postgresCodec(sqlIntDescriptor, {
|
|
418
|
+
nativeType: () => "int4",
|
|
419
|
+
jsonProjection: identityJsonProjection
|
|
420
|
+
});
|
|
421
|
+
const postgresSqlFloatDescriptor = postgresCodec(sqlFloatDescriptor, {
|
|
422
|
+
nativeType: () => "float8",
|
|
423
|
+
jsonProjection: identityJsonProjection
|
|
424
|
+
});
|
|
425
|
+
const postgresSqlTextDescriptor = postgresCodec(sqlTextDescriptor, {
|
|
426
|
+
nativeType: () => "text",
|
|
427
|
+
jsonProjection: identityJsonProjection
|
|
428
|
+
});
|
|
429
|
+
const postgresSqlTimestampDescriptor = postgresCodec(sqlTimestampDescriptor, {
|
|
430
|
+
nativeType: () => "timestamp",
|
|
431
|
+
jsonProjection: identityJsonProjection
|
|
432
|
+
});
|
|
433
|
+
var PgTextCodec = class extends CodecImpl {
|
|
434
|
+
async encode(value, _ctx) {
|
|
435
|
+
return value;
|
|
436
|
+
}
|
|
437
|
+
async decode(wire, _ctx) {
|
|
438
|
+
return wire;
|
|
439
|
+
}
|
|
440
|
+
encodeJson(value) {
|
|
441
|
+
return value;
|
|
442
|
+
}
|
|
443
|
+
decodeJson(json) {
|
|
444
|
+
return json;
|
|
445
|
+
}
|
|
446
|
+
};
|
|
447
|
+
var PgTextDescriptor = class extends PostgresCodecDescriptor {
|
|
448
|
+
nativeType() {
|
|
449
|
+
return PG_TEXT_NATIVE_TYPE;
|
|
450
|
+
}
|
|
451
|
+
jsonProjection(expression) {
|
|
452
|
+
return expression;
|
|
453
|
+
}
|
|
454
|
+
codecId = PG_TEXT_CODEC_ID;
|
|
455
|
+
traits = [
|
|
456
|
+
"equality",
|
|
457
|
+
"order",
|
|
458
|
+
"textual"
|
|
459
|
+
];
|
|
460
|
+
targetTypes = ["text"];
|
|
461
|
+
paramsSchema = voidParamsSchema;
|
|
462
|
+
renderValueLiteral(value) {
|
|
463
|
+
return renderTsLiteral(value);
|
|
464
|
+
}
|
|
465
|
+
factory() {
|
|
466
|
+
return () => new PgTextCodec(this);
|
|
467
|
+
}
|
|
468
|
+
};
|
|
469
|
+
const pgTextDescriptor = new PgTextDescriptor();
|
|
470
|
+
const pgTextColumn = () => column(pgTextDescriptor.factory(), pgTextDescriptor.codecId, void 0, "text");
|
|
471
|
+
/**
|
|
472
|
+
* Codec for a `pg.enum(Ref)` column bound to a native Postgres enum type.
|
|
473
|
+
* Text passthrough, identical to `pg/text@1` — encode/decode do not carry the
|
|
474
|
+
* enum's member values; membership is enforced by the native type itself, not
|
|
475
|
+
* by this codec. `renderValueLiteral` renders a member value as its TS
|
|
476
|
+
* literal, which is what drives the column's typed value-union (via
|
|
477
|
+
* `renderValueSetType` reading the column's `valueSet` ref) — the codec
|
|
478
|
+
* itself carries no params of its own; typing comes entirely from the
|
|
479
|
+
* column's value-set, not from `pg/enum@1`.
|
|
480
|
+
*
|
|
481
|
+
* A distinct codec id (rather than reusing `pg/text@1` on a plain text
|
|
482
|
+
* column) keeps native-enum columns independently identifiable — from a
|
|
483
|
+
* column's `codecId` alone, without also inspecting `nativeType` — which
|
|
484
|
+
* the managed (DDL) phase needs to target `CREATE TYPE`/`ALTER TYPE`
|
|
485
|
+
* operations at exactly the columns that use one.
|
|
486
|
+
*/
|
|
487
|
+
var PgEnumCodec = class extends CodecImpl {
|
|
488
|
+
async encode(value, _ctx) {
|
|
489
|
+
return value;
|
|
490
|
+
}
|
|
491
|
+
async decode(wire, _ctx) {
|
|
492
|
+
return wire;
|
|
493
|
+
}
|
|
494
|
+
encodeJson(value) {
|
|
495
|
+
return value;
|
|
496
|
+
}
|
|
497
|
+
decodeJson(json) {
|
|
498
|
+
return blindCast(json);
|
|
499
|
+
}
|
|
500
|
+
};
|
|
501
|
+
/**
|
|
502
|
+
* Narrows codec `typeParams` to {@link PgEnumParams} — the shape that binds a
|
|
503
|
+
* column to a named database type (a native enum's `CREATE TYPE` name).
|
|
504
|
+
*/
|
|
505
|
+
function isPgEnumParams(value) {
|
|
506
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) && "typeName" in value && typeof value.typeName === "string";
|
|
507
|
+
}
|
|
508
|
+
const pgEnumParamsSchema = type({ typeName: "string" });
|
|
509
|
+
var PgEnumDescriptor = class extends PostgresCodecDescriptor {
|
|
510
|
+
nativeType(params) {
|
|
511
|
+
return params.typeName;
|
|
512
|
+
}
|
|
513
|
+
jsonProjection(expression) {
|
|
514
|
+
return expression;
|
|
515
|
+
}
|
|
516
|
+
codecId = PG_ENUM_CODEC_ID;
|
|
517
|
+
traits = [
|
|
518
|
+
"equality",
|
|
519
|
+
"order",
|
|
520
|
+
"textual"
|
|
521
|
+
];
|
|
522
|
+
targetTypes = ["text"];
|
|
523
|
+
paramsSchema = pgEnumParamsSchema;
|
|
524
|
+
renderValueLiteral(value) {
|
|
525
|
+
return renderTsLiteral(value);
|
|
526
|
+
}
|
|
527
|
+
factory(_params) {
|
|
528
|
+
return () => new PgEnumCodec(this);
|
|
529
|
+
}
|
|
530
|
+
/**
|
|
531
|
+
* Authoring-time hook a `pg.enum(<ref>)` type constructor calls once it has
|
|
532
|
+
* resolved its ref argument to the referenced `native_enum` entity:
|
|
533
|
+
* produces this codec's per-column `typeParams` and native type from the
|
|
534
|
+
* entity's bare type name. Schema-qualification (`auth.aal_level` for a
|
|
535
|
+
* named non-default schema) is not this hook's concern — the field's
|
|
536
|
+
* namespace isn't known at this call site for every authoring path (the TS
|
|
537
|
+
* builder resolves a column before it knows its model's namespace), so it is
|
|
538
|
+
* applied later, at contract construction, by {@link qualifyNativeType} via
|
|
539
|
+
* the target's `authoring.qualifyColumnType` hook. `nativeType` mirrors
|
|
540
|
+
* `typeParams.typeName` — the same value `nativeTypeFor` derives at render
|
|
541
|
+
* time — so the column's declared native type and the render-time cast
|
|
542
|
+
* agree. Returns `undefined` if `entity` is not a `PostgresNativeEnum` (a
|
|
543
|
+
* contributor bug, not a user-schema error — the caller decides how to
|
|
544
|
+
* report it).
|
|
545
|
+
*/
|
|
546
|
+
columnFromEntity(entity) {
|
|
547
|
+
if (!PostgresNativeEnum.is(entity)) return void 0;
|
|
548
|
+
return {
|
|
549
|
+
typeParams: { typeName: entity.typeName },
|
|
550
|
+
nativeType: entity.typeName
|
|
551
|
+
};
|
|
552
|
+
}
|
|
553
|
+
/**
|
|
554
|
+
* Schema-qualifies this native enum type's name for the namespace the
|
|
555
|
+
* consuming column lives in: `${namespaceId}.${typeName}` for a named
|
|
556
|
+
* non-default schema, bare for the target's default schema (`public`) or
|
|
557
|
+
* the late-bound unbound sentinel (whose schema `search_path` resolves at
|
|
558
|
+
* runtime). Postgres's `format_type()` reports the bare name for a
|
|
559
|
+
* public-schema type, so a public column's declared native type must stay
|
|
560
|
+
* bare to match. Owned here because the codec owns its native type.
|
|
561
|
+
*/
|
|
562
|
+
qualifyNativeType(typeName, namespaceId) {
|
|
563
|
+
return namespaceId === "public" || namespaceId === UNBOUND_NAMESPACE_ID ? typeName : `${namespaceId}.${typeName}`;
|
|
564
|
+
}
|
|
565
|
+
};
|
|
566
|
+
const pgEnumDescriptor = new PgEnumDescriptor();
|
|
567
|
+
/**
|
|
568
|
+
* Contract-construction-time column-type qualifier the Postgres target
|
|
569
|
+
* contributes through `authoring.qualifyColumnType`.
|
|
570
|
+
* `buildSqlContractFromDefinition` calls this for every column as it is
|
|
571
|
+
* constructed, passing the column's bare type info and its owning
|
|
572
|
+
* `namespaceId`; a native-enum column (`pg/enum@1`) gets its type name
|
|
573
|
+
* schema-qualified for that namespace (via
|
|
574
|
+
* {@link PgEnumDescriptor.qualifyNativeType}), keeping `nativeType` and
|
|
575
|
+
* `typeParams.typeName` in sync. Every other codec passes through unchanged.
|
|
576
|
+
* Both the PSL `pg.enum(Ref)` path and the TS `pg.enum(handle)` path route
|
|
577
|
+
* through here — the dispatch keys off the codec id, not authoring surface.
|
|
578
|
+
*/
|
|
579
|
+
function postgresQualifyColumnType(input, namespaceId) {
|
|
580
|
+
if (input.codecId !== "pg/enum@1") return input;
|
|
581
|
+
const bareTypeName = input.typeParams?.["typeName"];
|
|
582
|
+
if (typeof bareTypeName !== "string") return input;
|
|
583
|
+
const qualified = pgEnumDescriptor.qualifyNativeType(bareTypeName, namespaceId);
|
|
584
|
+
return {
|
|
585
|
+
nativeType: qualified,
|
|
586
|
+
typeParams: {
|
|
587
|
+
...input.typeParams,
|
|
588
|
+
typeName: qualified
|
|
589
|
+
}
|
|
590
|
+
};
|
|
591
|
+
}
|
|
592
|
+
/**
|
|
593
|
+
* Postgres `text[]` codec. Encode is an identity pass-through: the pg wire
|
|
594
|
+
* driver serialises a JS `string[]` to a Postgres array literal under the
|
|
595
|
+
* `$N::text[]` cast the renderer emits from this codec's `text[]` native type,
|
|
596
|
+
* and decode reads it back as a JS array. Used by the control plane to write
|
|
597
|
+
* the marker's `invariants` column. Not a user-facing scalar — it is not part
|
|
598
|
+
* of the authorable `CodecTypes` surface, only the runtime codec registry.
|
|
599
|
+
*/
|
|
600
|
+
var PgTextArrayCodec = class extends CodecImpl {
|
|
601
|
+
async encode(value, _ctx) {
|
|
602
|
+
return value;
|
|
603
|
+
}
|
|
604
|
+
async decode(wire, _ctx) {
|
|
605
|
+
return wire;
|
|
606
|
+
}
|
|
607
|
+
encodeJson(value) {
|
|
608
|
+
return [...value];
|
|
609
|
+
}
|
|
610
|
+
decodeJson(json) {
|
|
611
|
+
return Array.isArray(json) ? json.map((entry) => String(entry)) : [];
|
|
612
|
+
}
|
|
613
|
+
};
|
|
614
|
+
var PgTextArrayDescriptor = class extends PostgresCodecDescriptor {
|
|
615
|
+
nativeType() {
|
|
616
|
+
return PG_TEXT_ARRAY_NATIVE_TYPE;
|
|
617
|
+
}
|
|
618
|
+
jsonProjection(expression) {
|
|
619
|
+
return expression;
|
|
620
|
+
}
|
|
621
|
+
codecId = PG_TEXT_ARRAY_CODEC_ID;
|
|
622
|
+
traits = ["equality"];
|
|
623
|
+
targetTypes = ["text[]"];
|
|
624
|
+
paramsSchema = voidParamsSchema;
|
|
625
|
+
factory() {
|
|
626
|
+
return () => new PgTextArrayCodec(this);
|
|
627
|
+
}
|
|
628
|
+
};
|
|
629
|
+
const pgTextArrayDescriptor = new PgTextArrayDescriptor();
|
|
630
|
+
var PgInt4Codec = class extends CodecImpl {
|
|
631
|
+
async encode(value, _ctx) {
|
|
632
|
+
return value;
|
|
633
|
+
}
|
|
634
|
+
async decode(wire, _ctx) {
|
|
635
|
+
return wire;
|
|
636
|
+
}
|
|
637
|
+
encodeJson(value) {
|
|
638
|
+
return value;
|
|
639
|
+
}
|
|
640
|
+
decodeJson(json) {
|
|
641
|
+
return json;
|
|
642
|
+
}
|
|
643
|
+
};
|
|
644
|
+
var PgInt4Descriptor = class extends PostgresCodecDescriptor {
|
|
645
|
+
nativeType() {
|
|
646
|
+
return PG_INT4_NATIVE_TYPE;
|
|
647
|
+
}
|
|
648
|
+
jsonProjection(expression) {
|
|
649
|
+
return expression;
|
|
650
|
+
}
|
|
651
|
+
codecId = PG_INT4_CODEC_ID;
|
|
652
|
+
traits = [
|
|
653
|
+
"equality",
|
|
654
|
+
"order",
|
|
655
|
+
"numeric"
|
|
656
|
+
];
|
|
657
|
+
targetTypes = ["int4"];
|
|
658
|
+
paramsSchema = voidParamsSchema;
|
|
659
|
+
renderValueLiteral(value) {
|
|
660
|
+
return renderTsLiteral(value);
|
|
661
|
+
}
|
|
662
|
+
factory() {
|
|
663
|
+
return () => new PgInt4Codec(this);
|
|
664
|
+
}
|
|
665
|
+
};
|
|
666
|
+
const pgInt4Descriptor = new PgInt4Descriptor();
|
|
667
|
+
const pgInt4Column = () => column(pgInt4Descriptor.factory(), pgInt4Descriptor.codecId, void 0, "int4");
|
|
668
|
+
var PgInt2Codec = class extends CodecImpl {
|
|
669
|
+
async encode(value, _ctx) {
|
|
670
|
+
return value;
|
|
671
|
+
}
|
|
672
|
+
async decode(wire, _ctx) {
|
|
673
|
+
return wire;
|
|
674
|
+
}
|
|
675
|
+
encodeJson(value) {
|
|
676
|
+
return value;
|
|
677
|
+
}
|
|
678
|
+
decodeJson(json) {
|
|
679
|
+
return json;
|
|
680
|
+
}
|
|
681
|
+
};
|
|
682
|
+
var PgInt2Descriptor = class extends PostgresCodecDescriptor {
|
|
683
|
+
nativeType() {
|
|
684
|
+
return PG_INT2_NATIVE_TYPE;
|
|
685
|
+
}
|
|
686
|
+
jsonProjection(expression) {
|
|
687
|
+
return expression;
|
|
688
|
+
}
|
|
689
|
+
codecId = PG_INT2_CODEC_ID;
|
|
690
|
+
traits = [
|
|
691
|
+
"equality",
|
|
692
|
+
"order",
|
|
693
|
+
"numeric"
|
|
694
|
+
];
|
|
695
|
+
targetTypes = ["int2"];
|
|
696
|
+
paramsSchema = voidParamsSchema;
|
|
697
|
+
renderValueLiteral(value) {
|
|
698
|
+
return renderTsLiteral(value);
|
|
699
|
+
}
|
|
700
|
+
factory() {
|
|
701
|
+
return () => new PgInt2Codec(this);
|
|
702
|
+
}
|
|
703
|
+
};
|
|
704
|
+
const pgInt2Descriptor = new PgInt2Descriptor();
|
|
705
|
+
const pgInt2Column = () => column(pgInt2Descriptor.factory(), pgInt2Descriptor.codecId, void 0, "int2");
|
|
706
|
+
/**
|
|
707
|
+
* A Postgres `int8` spans the full signed 64-bit range, which a JS `number`
|
|
708
|
+
* cannot hold past 2^53. Application values are `bigint` and the canonical JSON
|
|
709
|
+
* is decimal text; the wire form is the decimal string `pg` reads and writes for
|
|
710
|
+
* this type.
|
|
711
|
+
*/
|
|
712
|
+
var PgInt8Codec = class extends CodecImpl {
|
|
713
|
+
async encode(value, _ctx) {
|
|
714
|
+
return value.toString();
|
|
715
|
+
}
|
|
716
|
+
async decode(wire, _ctx) {
|
|
717
|
+
return pgInt8Decode(wire);
|
|
718
|
+
}
|
|
719
|
+
encodeJson(value) {
|
|
720
|
+
return value.toString();
|
|
721
|
+
}
|
|
722
|
+
decodeJson(json) {
|
|
723
|
+
if (typeof json !== "string") throw postgresError("RUNTIME.DECODE_FAILED", "pg/int8@1 database JSON value must be a decimal string", { meta: {
|
|
724
|
+
codecId: PG_INT8_CODEC_ID,
|
|
725
|
+
received: typeof json
|
|
726
|
+
} });
|
|
727
|
+
return pgInt8Decode(json);
|
|
728
|
+
}
|
|
729
|
+
};
|
|
730
|
+
var PgInt8Descriptor = class extends PostgresCodecDescriptor {
|
|
731
|
+
nativeType() {
|
|
732
|
+
return PG_INT8_NATIVE_TYPE;
|
|
733
|
+
}
|
|
734
|
+
jsonProjection(expression) {
|
|
735
|
+
return decimalTextJsonProjection(expression);
|
|
736
|
+
}
|
|
737
|
+
codecId = PG_INT8_CODEC_ID;
|
|
738
|
+
traits = [
|
|
739
|
+
"equality",
|
|
740
|
+
"order",
|
|
741
|
+
"numeric"
|
|
742
|
+
];
|
|
743
|
+
targetTypes = ["int8"];
|
|
744
|
+
paramsSchema = voidParamsSchema;
|
|
745
|
+
renderValueLiteral(value) {
|
|
746
|
+
return pgInt8RenderValueLiteral(value);
|
|
747
|
+
}
|
|
748
|
+
factory() {
|
|
749
|
+
return () => new PgInt8Codec(this);
|
|
750
|
+
}
|
|
751
|
+
};
|
|
752
|
+
const pgInt8Descriptor = new PgInt8Descriptor();
|
|
753
|
+
const pgInt8Column = () => column(pgInt8Descriptor.factory(), pgInt8Descriptor.codecId, void 0, "int8");
|
|
754
|
+
var PgFloat4Codec = class extends CodecImpl {
|
|
755
|
+
async encode(value, _ctx) {
|
|
756
|
+
return value;
|
|
757
|
+
}
|
|
758
|
+
async decode(wire, _ctx) {
|
|
759
|
+
return wire;
|
|
760
|
+
}
|
|
761
|
+
encodeJson(value) {
|
|
762
|
+
return value;
|
|
763
|
+
}
|
|
764
|
+
decodeJson(json) {
|
|
765
|
+
return json;
|
|
766
|
+
}
|
|
767
|
+
};
|
|
768
|
+
var PgFloat4Descriptor = class extends PostgresCodecDescriptor {
|
|
769
|
+
nativeType() {
|
|
770
|
+
return PG_FLOAT4_NATIVE_TYPE;
|
|
771
|
+
}
|
|
772
|
+
jsonProjection(expression) {
|
|
773
|
+
return expression;
|
|
774
|
+
}
|
|
775
|
+
codecId = PG_FLOAT4_CODEC_ID;
|
|
776
|
+
traits = [
|
|
777
|
+
"equality",
|
|
778
|
+
"order",
|
|
779
|
+
"numeric"
|
|
780
|
+
];
|
|
781
|
+
targetTypes = ["float4"];
|
|
782
|
+
paramsSchema = voidParamsSchema;
|
|
783
|
+
renderValueLiteral(value) {
|
|
784
|
+
return renderTsLiteral(value);
|
|
785
|
+
}
|
|
786
|
+
factory() {
|
|
787
|
+
return () => new PgFloat4Codec(this);
|
|
788
|
+
}
|
|
789
|
+
};
|
|
790
|
+
const pgFloat4Descriptor = new PgFloat4Descriptor();
|
|
791
|
+
const pgFloat4Column = () => column(pgFloat4Descriptor.factory(), pgFloat4Descriptor.codecId, void 0, "float4");
|
|
792
|
+
var PgFloat8Codec = class extends CodecImpl {
|
|
793
|
+
async encode(value, _ctx) {
|
|
794
|
+
return value;
|
|
795
|
+
}
|
|
796
|
+
async decode(wire, _ctx) {
|
|
797
|
+
return wire;
|
|
798
|
+
}
|
|
799
|
+
encodeJson(value) {
|
|
800
|
+
return value;
|
|
801
|
+
}
|
|
802
|
+
decodeJson(json) {
|
|
803
|
+
return json;
|
|
804
|
+
}
|
|
805
|
+
};
|
|
806
|
+
var PgFloat8Descriptor = class extends PostgresCodecDescriptor {
|
|
807
|
+
nativeType() {
|
|
808
|
+
return PG_FLOAT8_NATIVE_TYPE;
|
|
809
|
+
}
|
|
810
|
+
jsonProjection(expression) {
|
|
811
|
+
return expression;
|
|
812
|
+
}
|
|
813
|
+
codecId = PG_FLOAT8_CODEC_ID;
|
|
814
|
+
traits = [
|
|
815
|
+
"equality",
|
|
816
|
+
"order",
|
|
817
|
+
"numeric"
|
|
818
|
+
];
|
|
819
|
+
targetTypes = ["float8"];
|
|
820
|
+
paramsSchema = voidParamsSchema;
|
|
821
|
+
renderValueLiteral(value) {
|
|
822
|
+
return renderTsLiteral(value);
|
|
823
|
+
}
|
|
824
|
+
factory() {
|
|
825
|
+
return () => new PgFloat8Codec(this);
|
|
826
|
+
}
|
|
827
|
+
};
|
|
828
|
+
const pgFloat8Descriptor = new PgFloat8Descriptor();
|
|
829
|
+
const pgFloat8Column = () => column(pgFloat8Descriptor.factory(), pgFloat8Descriptor.codecId, void 0, "float8");
|
|
830
|
+
var PgBoolCodec = class extends CodecImpl {
|
|
831
|
+
async encode(value, _ctx) {
|
|
832
|
+
return value;
|
|
833
|
+
}
|
|
834
|
+
async decode(wire, _ctx) {
|
|
835
|
+
return wire;
|
|
836
|
+
}
|
|
837
|
+
encodeJson(value) {
|
|
838
|
+
return value;
|
|
839
|
+
}
|
|
840
|
+
decodeJson(json) {
|
|
841
|
+
return json;
|
|
842
|
+
}
|
|
843
|
+
};
|
|
844
|
+
var PgBoolDescriptor = class extends PostgresCodecDescriptor {
|
|
845
|
+
nativeType() {
|
|
846
|
+
return PG_BOOL_NATIVE_TYPE;
|
|
847
|
+
}
|
|
848
|
+
jsonProjection(expression) {
|
|
849
|
+
return expression;
|
|
850
|
+
}
|
|
851
|
+
codecId = PG_BOOL_CODEC_ID;
|
|
852
|
+
traits = ["equality", "boolean"];
|
|
853
|
+
targetTypes = ["bool"];
|
|
854
|
+
paramsSchema = voidParamsSchema;
|
|
855
|
+
renderValueLiteral(value) {
|
|
856
|
+
return renderTsLiteral(value);
|
|
857
|
+
}
|
|
858
|
+
factory() {
|
|
859
|
+
return () => new PgBoolCodec(this);
|
|
860
|
+
}
|
|
861
|
+
};
|
|
862
|
+
const pgBoolDescriptor = new PgBoolDescriptor();
|
|
863
|
+
const pgBoolColumn = () => column(pgBoolDescriptor.factory(), pgBoolDescriptor.codecId, void 0, "bool");
|
|
864
|
+
var PgNumericCodec = class extends CodecImpl {
|
|
865
|
+
async encode(value, _ctx) {
|
|
866
|
+
return value;
|
|
867
|
+
}
|
|
868
|
+
async decode(wire, _ctx) {
|
|
869
|
+
return pgNumericDecode(wire);
|
|
870
|
+
}
|
|
871
|
+
encodeJson(value) {
|
|
872
|
+
if (!isCanonicalNumericText(value)) throw postgresError("RUNTIME.ENCODE_FAILED", "pg/numeric@1 application value must be canonical numeric text: an optionally negated decimal numeral, or NaN, Infinity or -Infinity", { meta: {
|
|
873
|
+
codecId: PG_NUMERIC_CODEC_ID,
|
|
874
|
+
received: value
|
|
875
|
+
} });
|
|
876
|
+
return value;
|
|
877
|
+
}
|
|
878
|
+
decodeJson(json) {
|
|
879
|
+
if (typeof json !== "string") throw postgresError("RUNTIME.DECODE_FAILED", "pg/numeric@1 database JSON value must be a decimal string", { meta: {
|
|
880
|
+
codecId: PG_NUMERIC_CODEC_ID,
|
|
881
|
+
received: typeof json
|
|
882
|
+
} });
|
|
883
|
+
return json;
|
|
884
|
+
}
|
|
885
|
+
};
|
|
886
|
+
var PgNumericDescriptor = class extends PostgresCodecDescriptor {
|
|
887
|
+
nativeType() {
|
|
888
|
+
return PG_NUMERIC_NATIVE_TYPE;
|
|
889
|
+
}
|
|
890
|
+
jsonProjection(expression) {
|
|
891
|
+
return decimalTextJsonProjection(expression);
|
|
892
|
+
}
|
|
893
|
+
codecId = PG_NUMERIC_CODEC_ID;
|
|
894
|
+
traits = [
|
|
895
|
+
"equality",
|
|
896
|
+
"order",
|
|
897
|
+
"numeric"
|
|
898
|
+
];
|
|
899
|
+
targetTypes = ["numeric", "decimal"];
|
|
900
|
+
paramsSchema = numericParamsSchema;
|
|
901
|
+
renderOutputType(params) {
|
|
902
|
+
return pgNumericRenderOutputType(params);
|
|
903
|
+
}
|
|
904
|
+
factory(_params) {
|
|
905
|
+
return () => new PgNumericCodec(this);
|
|
906
|
+
}
|
|
907
|
+
};
|
|
908
|
+
const pgNumericDescriptor = new PgNumericDescriptor();
|
|
909
|
+
const pgNumericColumn = (params = {}) => column(pgNumericDescriptor.factory(params), pgNumericDescriptor.codecId, params, "numeric");
|
|
910
|
+
/**
|
|
911
|
+
* A Postgres `date` has no time-of-day or timezone component. This codec
|
|
912
|
+
* canonicalizes its JS-level value as a `Date` at UTC midnight, so its
|
|
913
|
+
* round-trip is independent of the process's local timezone — see
|
|
914
|
+
* `pgDateEncode`/`pgDateDecode` in `codec-helpers.ts`.
|
|
915
|
+
*/
|
|
916
|
+
var PgDateCodec = class extends CodecImpl {
|
|
917
|
+
async encode(value, _ctx) {
|
|
918
|
+
return pgDateEncode(value);
|
|
919
|
+
}
|
|
920
|
+
async decode(wire, _ctx) {
|
|
921
|
+
return pgDateDecode(wire);
|
|
922
|
+
}
|
|
923
|
+
encodeJson(value) {
|
|
924
|
+
return pgDateEncodeJson(value);
|
|
925
|
+
}
|
|
926
|
+
decodeJson(json) {
|
|
927
|
+
return pgDateDecodeJson(json);
|
|
928
|
+
}
|
|
929
|
+
};
|
|
930
|
+
var PgDateDescriptor = class extends PostgresCodecDescriptor {
|
|
931
|
+
nativeType() {
|
|
932
|
+
return PG_DATE_NATIVE_TYPE;
|
|
933
|
+
}
|
|
934
|
+
jsonProjection(expression) {
|
|
935
|
+
return expression;
|
|
936
|
+
}
|
|
937
|
+
codecId = PG_DATE_CODEC_ID;
|
|
938
|
+
traits = ["equality", "order"];
|
|
939
|
+
targetTypes = ["date"];
|
|
940
|
+
paramsSchema = voidParamsSchema;
|
|
941
|
+
factory() {
|
|
942
|
+
return () => new PgDateCodec(this);
|
|
943
|
+
}
|
|
944
|
+
};
|
|
945
|
+
const pgDateDescriptor = new PgDateDescriptor();
|
|
946
|
+
const pgDateColumn = () => column(pgDateDescriptor.factory(), pgDateDescriptor.codecId, void 0, "date");
|
|
947
|
+
var PgTimestampCodec = class extends CodecImpl {
|
|
948
|
+
async encode(value, _ctx) {
|
|
949
|
+
return value;
|
|
950
|
+
}
|
|
951
|
+
async decode(wire, _ctx) {
|
|
952
|
+
return wire;
|
|
953
|
+
}
|
|
954
|
+
encodeJson(value) {
|
|
955
|
+
return pgTimestampEncodeJson(value);
|
|
956
|
+
}
|
|
957
|
+
decodeJson(json) {
|
|
958
|
+
return pgTimestampDecodeJson(json);
|
|
959
|
+
}
|
|
960
|
+
};
|
|
961
|
+
var PgTimestampDescriptor = class extends PostgresCodecDescriptor {
|
|
962
|
+
nativeType() {
|
|
963
|
+
return PG_TIMESTAMP_NATIVE_TYPE;
|
|
964
|
+
}
|
|
965
|
+
jsonProjection(expression) {
|
|
966
|
+
return expression;
|
|
967
|
+
}
|
|
968
|
+
codecId = PG_TIMESTAMP_CODEC_ID;
|
|
969
|
+
traits = ["equality", "order"];
|
|
970
|
+
targetTypes = ["timestamp"];
|
|
971
|
+
paramsSchema = precisionParamsSchema;
|
|
972
|
+
renderOutputType(params) {
|
|
973
|
+
return renderPrecision("Timestamp", params);
|
|
974
|
+
}
|
|
975
|
+
factory(_params) {
|
|
976
|
+
return () => new PgTimestampCodec(this);
|
|
977
|
+
}
|
|
978
|
+
};
|
|
979
|
+
const pgTimestampDescriptor = new PgTimestampDescriptor();
|
|
980
|
+
const pgTimestampColumn = (params = {}) => column(pgTimestampDescriptor.factory(params), pgTimestampDescriptor.codecId, params, "timestamp");
|
|
981
|
+
var PgTimestamptzCodec = class extends CodecImpl {
|
|
982
|
+
async encode(value, _ctx) {
|
|
983
|
+
return value;
|
|
984
|
+
}
|
|
985
|
+
async decode(wire, _ctx) {
|
|
986
|
+
return wire;
|
|
987
|
+
}
|
|
988
|
+
encodeJson(value) {
|
|
989
|
+
return pgTimestamptzEncodeJson(value);
|
|
990
|
+
}
|
|
991
|
+
decodeJson(json) {
|
|
992
|
+
return pgTimestamptzDecodeJson(json);
|
|
993
|
+
}
|
|
994
|
+
};
|
|
995
|
+
var PgTimestamptzDescriptor = class extends PostgresCodecDescriptor {
|
|
996
|
+
nativeType() {
|
|
997
|
+
return PG_TIMESTAMPTZ_NATIVE_TYPE;
|
|
998
|
+
}
|
|
999
|
+
jsonProjection(expression) {
|
|
1000
|
+
return utcIsoJsonProjection(expression);
|
|
1001
|
+
}
|
|
1002
|
+
codecId = PG_TIMESTAMPTZ_CODEC_ID;
|
|
1003
|
+
traits = ["equality", "order"];
|
|
1004
|
+
targetTypes = ["timestamptz"];
|
|
1005
|
+
paramsSchema = precisionParamsSchema;
|
|
1006
|
+
renderOutputType(params) {
|
|
1007
|
+
return renderPrecision("Timestamptz", params);
|
|
1008
|
+
}
|
|
1009
|
+
factory(_params) {
|
|
1010
|
+
return () => new PgTimestamptzCodec(this);
|
|
1011
|
+
}
|
|
1012
|
+
};
|
|
1013
|
+
const pgTimestamptzDescriptor = new PgTimestamptzDescriptor();
|
|
1014
|
+
const pgTimestamptzColumn = (params = {}) => column(pgTimestamptzDescriptor.factory(params), pgTimestamptzDescriptor.codecId, params, "timestamptz");
|
|
1015
|
+
var PgTimeCodec = class extends CodecImpl {
|
|
1016
|
+
async encode(value, _ctx) {
|
|
1017
|
+
return value;
|
|
1018
|
+
}
|
|
1019
|
+
async decode(wire, _ctx) {
|
|
1020
|
+
return wire;
|
|
1021
|
+
}
|
|
1022
|
+
encodeJson(value) {
|
|
1023
|
+
return value;
|
|
1024
|
+
}
|
|
1025
|
+
decodeJson(json) {
|
|
1026
|
+
return json;
|
|
1027
|
+
}
|
|
1028
|
+
};
|
|
1029
|
+
var PgTimeDescriptor = class extends PostgresCodecDescriptor {
|
|
1030
|
+
nativeType() {
|
|
1031
|
+
return PG_TIME_NATIVE_TYPE;
|
|
1032
|
+
}
|
|
1033
|
+
jsonProjection(expression) {
|
|
1034
|
+
return expression;
|
|
1035
|
+
}
|
|
1036
|
+
codecId = PG_TIME_CODEC_ID;
|
|
1037
|
+
traits = ["equality", "order"];
|
|
1038
|
+
targetTypes = ["time"];
|
|
1039
|
+
paramsSchema = precisionParamsSchema;
|
|
1040
|
+
renderOutputType(params) {
|
|
1041
|
+
return renderPrecision("Time", params);
|
|
1042
|
+
}
|
|
1043
|
+
factory(_params) {
|
|
1044
|
+
return () => new PgTimeCodec(this);
|
|
1045
|
+
}
|
|
1046
|
+
};
|
|
1047
|
+
const pgTimeDescriptor = new PgTimeDescriptor();
|
|
1048
|
+
const pgTimeColumn = (params = {}) => column(pgTimeDescriptor.factory(params), pgTimeDescriptor.codecId, params, "time");
|
|
1049
|
+
var PgTimetzCodec = class extends CodecImpl {
|
|
1050
|
+
async encode(value, _ctx) {
|
|
1051
|
+
return value;
|
|
1052
|
+
}
|
|
1053
|
+
async decode(wire, _ctx) {
|
|
1054
|
+
return wire;
|
|
1055
|
+
}
|
|
1056
|
+
encodeJson(value) {
|
|
1057
|
+
return value;
|
|
1058
|
+
}
|
|
1059
|
+
decodeJson(json) {
|
|
1060
|
+
return json;
|
|
1061
|
+
}
|
|
1062
|
+
};
|
|
1063
|
+
var PgTimetzDescriptor = class extends PostgresCodecDescriptor {
|
|
1064
|
+
nativeType() {
|
|
1065
|
+
return PG_TIMETZ_NATIVE_TYPE;
|
|
1066
|
+
}
|
|
1067
|
+
jsonProjection(expression) {
|
|
1068
|
+
return expression;
|
|
1069
|
+
}
|
|
1070
|
+
codecId = PG_TIMETZ_CODEC_ID;
|
|
1071
|
+
traits = ["equality", "order"];
|
|
1072
|
+
targetTypes = ["timetz"];
|
|
1073
|
+
paramsSchema = precisionParamsSchema;
|
|
1074
|
+
renderOutputType(params) {
|
|
1075
|
+
return renderPrecision("Timetz", params);
|
|
1076
|
+
}
|
|
1077
|
+
factory(_params) {
|
|
1078
|
+
return () => new PgTimetzCodec(this);
|
|
1079
|
+
}
|
|
1080
|
+
};
|
|
1081
|
+
const pgTimetzDescriptor = new PgTimetzDescriptor();
|
|
1082
|
+
const pgTimetzColumn = (params = {}) => column(pgTimetzDescriptor.factory(params), pgTimetzDescriptor.codecId, params, "timetz");
|
|
1083
|
+
var PgBitCodec = class extends CodecImpl {
|
|
1084
|
+
async encode(value, _ctx) {
|
|
1085
|
+
return value;
|
|
1086
|
+
}
|
|
1087
|
+
async decode(wire, _ctx) {
|
|
1088
|
+
return wire;
|
|
1089
|
+
}
|
|
1090
|
+
encodeJson(value) {
|
|
1091
|
+
return value;
|
|
1092
|
+
}
|
|
1093
|
+
decodeJson(json) {
|
|
1094
|
+
return json;
|
|
1095
|
+
}
|
|
1096
|
+
};
|
|
1097
|
+
var PgBitDescriptor = class extends PostgresCodecDescriptor {
|
|
1098
|
+
nativeType() {
|
|
1099
|
+
return PG_BIT_NATIVE_TYPE;
|
|
1100
|
+
}
|
|
1101
|
+
jsonProjection(expression) {
|
|
1102
|
+
return expression;
|
|
1103
|
+
}
|
|
1104
|
+
codecId = PG_BIT_CODEC_ID;
|
|
1105
|
+
traits = ["equality", "order"];
|
|
1106
|
+
targetTypes = ["bit"];
|
|
1107
|
+
paramsSchema = lengthParamsSchema;
|
|
1108
|
+
renderOutputType(params) {
|
|
1109
|
+
return renderLength("Bit", params);
|
|
1110
|
+
}
|
|
1111
|
+
factory(_params) {
|
|
1112
|
+
return () => new PgBitCodec(this);
|
|
1113
|
+
}
|
|
1114
|
+
};
|
|
1115
|
+
const pgBitDescriptor = new PgBitDescriptor();
|
|
1116
|
+
const pgBitColumn = (params = {}) => column(pgBitDescriptor.factory(params), pgBitDescriptor.codecId, params, "bit");
|
|
1117
|
+
var PgVarbitCodec = class extends CodecImpl {
|
|
1118
|
+
async encode(value, _ctx) {
|
|
1119
|
+
return value;
|
|
1120
|
+
}
|
|
1121
|
+
async decode(wire, _ctx) {
|
|
1122
|
+
return wire;
|
|
1123
|
+
}
|
|
1124
|
+
encodeJson(value) {
|
|
1125
|
+
return value;
|
|
1126
|
+
}
|
|
1127
|
+
decodeJson(json) {
|
|
1128
|
+
return json;
|
|
1129
|
+
}
|
|
1130
|
+
};
|
|
1131
|
+
var PgVarbitDescriptor = class extends PostgresCodecDescriptor {
|
|
1132
|
+
nativeType() {
|
|
1133
|
+
return PG_VARBIT_NATIVE_TYPE;
|
|
1134
|
+
}
|
|
1135
|
+
jsonProjection(expression) {
|
|
1136
|
+
return expression;
|
|
1137
|
+
}
|
|
1138
|
+
codecId = PG_VARBIT_CODEC_ID;
|
|
1139
|
+
traits = ["equality", "order"];
|
|
1140
|
+
targetTypes = ["bit varying"];
|
|
1141
|
+
paramsSchema = lengthParamsSchema;
|
|
1142
|
+
renderOutputType(params) {
|
|
1143
|
+
return renderLength("VarBit", params);
|
|
1144
|
+
}
|
|
1145
|
+
factory(_params) {
|
|
1146
|
+
return () => new PgVarbitCodec(this);
|
|
1147
|
+
}
|
|
1148
|
+
};
|
|
1149
|
+
const pgVarbitDescriptor = new PgVarbitDescriptor();
|
|
1150
|
+
const pgVarbitColumn = (params = {}) => column(pgVarbitDescriptor.factory(params), pgVarbitDescriptor.codecId, params, "bit varying");
|
|
1151
|
+
var PgByteaCodec = class extends CodecImpl {
|
|
1152
|
+
async encode(value, _ctx) {
|
|
1153
|
+
return value;
|
|
1154
|
+
}
|
|
1155
|
+
async decode(wire, _ctx) {
|
|
1156
|
+
return wire instanceof Uint8Array && wire.constructor === Uint8Array ? wire : new Uint8Array(wire.buffer, wire.byteOffset, wire.byteLength);
|
|
1157
|
+
}
|
|
1158
|
+
encodeJson(value) {
|
|
1159
|
+
return pgByteaEncodeJson(value);
|
|
1160
|
+
}
|
|
1161
|
+
decodeJson(json) {
|
|
1162
|
+
return pgByteaDecodeJson(json);
|
|
1163
|
+
}
|
|
1164
|
+
};
|
|
1165
|
+
var PgByteaDescriptor = class extends PostgresCodecDescriptor {
|
|
1166
|
+
nativeType() {
|
|
1167
|
+
return PG_BYTEA_NATIVE_TYPE;
|
|
1168
|
+
}
|
|
1169
|
+
jsonProjection(expression) {
|
|
1170
|
+
return base64JsonProjection(expression);
|
|
1171
|
+
}
|
|
1172
|
+
codecId = PG_BYTEA_CODEC_ID;
|
|
1173
|
+
traits = ["equality"];
|
|
1174
|
+
targetTypes = ["bytea"];
|
|
1175
|
+
paramsSchema = voidParamsSchema;
|
|
1176
|
+
factory() {
|
|
1177
|
+
return () => new PgByteaCodec(this);
|
|
1178
|
+
}
|
|
1179
|
+
};
|
|
1180
|
+
const pgByteaDescriptor = new PgByteaDescriptor();
|
|
1181
|
+
const PG_UUID_NATIVE_TYPE = "uuid";
|
|
1182
|
+
var PgUuidCodec = class extends CodecImpl {
|
|
1183
|
+
async encode(value, _ctx) {
|
|
1184
|
+
return value;
|
|
1185
|
+
}
|
|
1186
|
+
async decode(wire, _ctx) {
|
|
1187
|
+
return wire;
|
|
1188
|
+
}
|
|
1189
|
+
encodeJson(value) {
|
|
1190
|
+
return value;
|
|
1191
|
+
}
|
|
1192
|
+
decodeJson(json) {
|
|
1193
|
+
return blindCast(json);
|
|
1194
|
+
}
|
|
1195
|
+
};
|
|
1196
|
+
var PgUuidDescriptor = class extends PostgresCodecDescriptor {
|
|
1197
|
+
nativeType() {
|
|
1198
|
+
return PG_UUID_NATIVE_TYPE;
|
|
1199
|
+
}
|
|
1200
|
+
jsonProjection(expression) {
|
|
1201
|
+
return expression;
|
|
1202
|
+
}
|
|
1203
|
+
codecId = PG_UUID_CODEC_ID;
|
|
1204
|
+
traits = ["equality", "order"];
|
|
1205
|
+
targetTypes = ["uuid"];
|
|
1206
|
+
paramsSchema = voidParamsSchema;
|
|
1207
|
+
factory() {
|
|
1208
|
+
return () => new PgUuidCodec(this);
|
|
1209
|
+
}
|
|
1210
|
+
};
|
|
1211
|
+
const pgUuidDescriptor = new PgUuidDescriptor();
|
|
1212
|
+
const pgUuidColumn = () => column(pgUuidDescriptor.factory(), pgUuidDescriptor.codecId, void 0, "uuid");
|
|
1213
|
+
const PG_INET_NATIVE_TYPE = "inet";
|
|
1214
|
+
var PgInetCodec = class extends CodecImpl {
|
|
1215
|
+
async encode(value, _ctx) {
|
|
1216
|
+
return value;
|
|
1217
|
+
}
|
|
1218
|
+
async decode(wire, _ctx) {
|
|
1219
|
+
return wire;
|
|
1220
|
+
}
|
|
1221
|
+
encodeJson(value) {
|
|
1222
|
+
return value;
|
|
1223
|
+
}
|
|
1224
|
+
decodeJson(json) {
|
|
1225
|
+
return blindCast(json);
|
|
1226
|
+
}
|
|
1227
|
+
};
|
|
1228
|
+
var PgInetDescriptor = class extends PostgresCodecDescriptor {
|
|
1229
|
+
nativeType() {
|
|
1230
|
+
return PG_INET_NATIVE_TYPE;
|
|
1231
|
+
}
|
|
1232
|
+
jsonProjection(expression) {
|
|
1233
|
+
return expression;
|
|
1234
|
+
}
|
|
1235
|
+
codecId = PG_INET_CODEC_ID;
|
|
1236
|
+
traits = ["equality", "order"];
|
|
1237
|
+
targetTypes = ["inet"];
|
|
1238
|
+
paramsSchema = voidParamsSchema;
|
|
1239
|
+
factory() {
|
|
1240
|
+
return () => new PgInetCodec(this);
|
|
1241
|
+
}
|
|
1242
|
+
};
|
|
1243
|
+
const pgInetDescriptor = new PgInetDescriptor();
|
|
1244
|
+
const pgInetColumn = () => column(pgInetDescriptor.factory(), pgInetDescriptor.codecId, void 0, "inet");
|
|
1245
|
+
/**
|
|
1246
|
+
* An application value is a {@link PgInterval} — the three fields PostgreSQL
|
|
1247
|
+
* actually stores, `{ months, days, micros }` — and its canonical JSON is the
|
|
1248
|
+
* ISO-8601 duration string PostgreSQL spells under
|
|
1249
|
+
* `IntervalStyle = 'iso_8601'`: `P1M`, `P30D`, `P1Y2M3DT4H5M6S`, `PT0S` for
|
|
1250
|
+
* zero, each component carrying its own sign.
|
|
1251
|
+
*
|
|
1252
|
+
* Value and representation are independent here, as they are for `pg/bytea@1`
|
|
1253
|
+
* (`Uint8Array` carried as base64) and `pg/int8@1` (`bigint` carried as decimal
|
|
1254
|
+
* text). Reading an interval hands back numbers to compute with rather than a
|
|
1255
|
+
* string to parse; writing one takes the same numbers.
|
|
1256
|
+
*
|
|
1257
|
+
* The fields stay independent because a month has no fixed length: `{months: 1}`
|
|
1258
|
+
* and `{days: 30}` are different values and neither converts to the other. The
|
|
1259
|
+
* ISO rendering normalises only in its own spelling — twelve months render as a
|
|
1260
|
+
* year — so `{months: 13}` renders `P1Y1M` and reads back as `{months: 13}`.
|
|
1261
|
+
*/
|
|
1262
|
+
var PgIntervalCodec = class extends CodecImpl {
|
|
1263
|
+
async encode(value, _ctx) {
|
|
1264
|
+
return pgIntervalToIso(value);
|
|
1265
|
+
}
|
|
1266
|
+
async decode(wire, _ctx) {
|
|
1267
|
+
return pgIntervalDecode(wire);
|
|
1268
|
+
}
|
|
1269
|
+
encodeJson(value) {
|
|
1270
|
+
return pgIntervalEncodeJson(value);
|
|
1271
|
+
}
|
|
1272
|
+
decodeJson(json) {
|
|
1273
|
+
return pgIntervalDecodeJson(json);
|
|
1274
|
+
}
|
|
1275
|
+
};
|
|
1276
|
+
var PgIntervalDescriptor = class extends PostgresCodecDescriptor {
|
|
1277
|
+
nativeType() {
|
|
1278
|
+
return PG_INTERVAL_NATIVE_TYPE;
|
|
1279
|
+
}
|
|
1280
|
+
jsonProjection(expression) {
|
|
1281
|
+
return isoDurationJsonProjection(expression);
|
|
1282
|
+
}
|
|
1283
|
+
codecId = PG_INTERVAL_CODEC_ID;
|
|
1284
|
+
traits = ["equality", "order"];
|
|
1285
|
+
targetTypes = ["interval"];
|
|
1286
|
+
paramsSchema = precisionParamsSchema;
|
|
1287
|
+
renderOutputType(params) {
|
|
1288
|
+
return renderPrecision("Interval", params);
|
|
1289
|
+
}
|
|
1290
|
+
factory(_params) {
|
|
1291
|
+
return () => new PgIntervalCodec(this);
|
|
1292
|
+
}
|
|
1293
|
+
};
|
|
1294
|
+
const pgIntervalDescriptor = new PgIntervalDescriptor();
|
|
1295
|
+
const pgIntervalColumn = (params = {}) => column(pgIntervalDescriptor.factory(params), pgIntervalDescriptor.codecId, params, "interval");
|
|
1296
|
+
var PgJsonCodec = class extends CodecImpl {
|
|
1297
|
+
async encode(value, _ctx) {
|
|
1298
|
+
return pgJsonEncode(value);
|
|
1299
|
+
}
|
|
1300
|
+
async decode(wire, _ctx) {
|
|
1301
|
+
return pgJsonDecode(wire);
|
|
1302
|
+
}
|
|
1303
|
+
encodeJson(value) {
|
|
1304
|
+
return value;
|
|
1305
|
+
}
|
|
1306
|
+
decodeJson(json) {
|
|
1307
|
+
return json;
|
|
1308
|
+
}
|
|
1309
|
+
};
|
|
1310
|
+
var PgJsonDescriptor = class extends PostgresCodecDescriptor {
|
|
1311
|
+
nativeType() {
|
|
1312
|
+
return PG_JSON_NATIVE_TYPE;
|
|
1313
|
+
}
|
|
1314
|
+
jsonProjection(expression) {
|
|
1315
|
+
return expression;
|
|
1316
|
+
}
|
|
1317
|
+
codecId = PG_JSON_CODEC_ID;
|
|
1318
|
+
traits = [];
|
|
1319
|
+
targetTypes = ["json"];
|
|
1320
|
+
paramsSchema = voidParamsSchema;
|
|
1321
|
+
factory() {
|
|
1322
|
+
return () => new PgJsonCodec(this);
|
|
1323
|
+
}
|
|
1324
|
+
};
|
|
1325
|
+
const pgJsonDescriptor = new PgJsonDescriptor();
|
|
1326
|
+
const pgJsonColumn = () => column(pgJsonDescriptor.factory(), pgJsonDescriptor.codecId, void 0, "json");
|
|
1327
|
+
var PgJsonbCodec = class extends CodecImpl {
|
|
1328
|
+
async encode(value, _ctx) {
|
|
1329
|
+
return pgJsonbEncode(value);
|
|
1330
|
+
}
|
|
1331
|
+
async decode(wire, _ctx) {
|
|
1332
|
+
return pgJsonbDecode(wire);
|
|
1333
|
+
}
|
|
1334
|
+
encodeJson(value) {
|
|
1335
|
+
return value;
|
|
1336
|
+
}
|
|
1337
|
+
decodeJson(json) {
|
|
1338
|
+
return json;
|
|
1339
|
+
}
|
|
1340
|
+
};
|
|
1341
|
+
var PgJsonbDescriptor = class extends PostgresCodecDescriptor {
|
|
1342
|
+
nativeType() {
|
|
1343
|
+
return PG_JSONB_NATIVE_TYPE;
|
|
1344
|
+
}
|
|
1345
|
+
jsonProjection(expression) {
|
|
1346
|
+
return expression;
|
|
1347
|
+
}
|
|
1348
|
+
codecId = PG_JSONB_CODEC_ID;
|
|
1349
|
+
traits = ["equality"];
|
|
1350
|
+
targetTypes = ["jsonb"];
|
|
1351
|
+
paramsSchema = voidParamsSchema;
|
|
1352
|
+
factory() {
|
|
1353
|
+
return () => new PgJsonbCodec(this);
|
|
1354
|
+
}
|
|
1355
|
+
};
|
|
1356
|
+
const pgJsonbDescriptor = new PgJsonbDescriptor();
|
|
1357
|
+
const pgJsonbColumn = () => column(pgJsonbDescriptor.factory(), pgJsonbDescriptor.codecId, void 0, "jsonb");
|
|
1358
|
+
const PG_CHAR_NATIVE_TYPE = "character";
|
|
1359
|
+
const PG_VARCHAR_NATIVE_TYPE = "character varying";
|
|
1360
|
+
const PG_INT_NATIVE_TYPE = "integer";
|
|
1361
|
+
const PG_FLOAT_NATIVE_TYPE = "double precision";
|
|
1362
|
+
var PgCharDescriptor = class extends PostgresCodecDescriptor {
|
|
1363
|
+
nativeType() {
|
|
1364
|
+
return PG_CHAR_NATIVE_TYPE;
|
|
1365
|
+
}
|
|
1366
|
+
jsonProjection(expression) {
|
|
1367
|
+
return expression;
|
|
1368
|
+
}
|
|
1369
|
+
codecId = PG_CHAR_CODEC_ID;
|
|
1370
|
+
targetTypes = ["character"];
|
|
1371
|
+
traits = sqlCharDescriptor.traits;
|
|
1372
|
+
paramsSchema = sqlCharDescriptor.paramsSchema;
|
|
1373
|
+
renderOutputType(params) {
|
|
1374
|
+
return sqlCharDescriptor.renderOutputType(params);
|
|
1375
|
+
}
|
|
1376
|
+
renderValueLiteral(value) {
|
|
1377
|
+
return renderTsLiteral(value);
|
|
1378
|
+
}
|
|
1379
|
+
factory(_params) {
|
|
1380
|
+
return () => new SqlCharCodec(this);
|
|
1381
|
+
}
|
|
1382
|
+
};
|
|
1383
|
+
const pgCharDescriptor = new PgCharDescriptor();
|
|
1384
|
+
const pgCharColumn = (params = {}) => column(pgCharDescriptor.factory(params), pgCharDescriptor.codecId, params, "character");
|
|
1385
|
+
var PgVarcharDescriptor = class extends PostgresCodecDescriptor {
|
|
1386
|
+
nativeType() {
|
|
1387
|
+
return PG_VARCHAR_NATIVE_TYPE;
|
|
1388
|
+
}
|
|
1389
|
+
jsonProjection(expression) {
|
|
1390
|
+
return expression;
|
|
1391
|
+
}
|
|
1392
|
+
codecId = PG_VARCHAR_CODEC_ID;
|
|
1393
|
+
targetTypes = ["character varying"];
|
|
1394
|
+
traits = sqlVarcharDescriptor.traits;
|
|
1395
|
+
paramsSchema = sqlVarcharDescriptor.paramsSchema;
|
|
1396
|
+
renderOutputType(params) {
|
|
1397
|
+
return sqlVarcharDescriptor.renderOutputType(params);
|
|
1398
|
+
}
|
|
1399
|
+
renderValueLiteral(value) {
|
|
1400
|
+
return renderTsLiteral(value);
|
|
1401
|
+
}
|
|
1402
|
+
factory(_params) {
|
|
1403
|
+
return () => new SqlVarcharCodec(this);
|
|
1404
|
+
}
|
|
1405
|
+
};
|
|
1406
|
+
const pgVarcharDescriptor = new PgVarcharDescriptor();
|
|
1407
|
+
const pgVarcharColumn = (params = {}) => column(pgVarcharDescriptor.factory(params), pgVarcharDescriptor.codecId, params, "character varying");
|
|
1408
|
+
var PgIntDescriptor = class extends PostgresCodecDescriptor {
|
|
1409
|
+
nativeType() {
|
|
1410
|
+
return PG_INT_NATIVE_TYPE;
|
|
1411
|
+
}
|
|
1412
|
+
jsonProjection(expression) {
|
|
1413
|
+
return expression;
|
|
1414
|
+
}
|
|
1415
|
+
codecId = PG_INT_CODEC_ID;
|
|
1416
|
+
targetTypes = ["int4"];
|
|
1417
|
+
traits = sqlIntDescriptor.traits;
|
|
1418
|
+
paramsSchema = sqlIntDescriptor.paramsSchema;
|
|
1419
|
+
renderValueLiteral(value) {
|
|
1420
|
+
return renderTsLiteral(value);
|
|
1421
|
+
}
|
|
1422
|
+
factory() {
|
|
1423
|
+
return () => new SqlIntCodec(this);
|
|
1424
|
+
}
|
|
1425
|
+
};
|
|
1426
|
+
const pgIntDescriptor = new PgIntDescriptor();
|
|
1427
|
+
const pgIntColumn = () => column(pgIntDescriptor.factory(), pgIntDescriptor.codecId, void 0, "int4");
|
|
1428
|
+
var PgFloatDescriptor = class extends PostgresCodecDescriptor {
|
|
1429
|
+
nativeType() {
|
|
1430
|
+
return PG_FLOAT_NATIVE_TYPE;
|
|
1431
|
+
}
|
|
1432
|
+
jsonProjection(expression) {
|
|
1433
|
+
return expression;
|
|
1434
|
+
}
|
|
1435
|
+
codecId = PG_FLOAT_CODEC_ID;
|
|
1436
|
+
targetTypes = ["float8"];
|
|
1437
|
+
traits = sqlFloatDescriptor.traits;
|
|
1438
|
+
paramsSchema = sqlFloatDescriptor.paramsSchema;
|
|
1439
|
+
renderValueLiteral(value) {
|
|
1440
|
+
return renderTsLiteral(value);
|
|
1441
|
+
}
|
|
1442
|
+
factory() {
|
|
1443
|
+
return () => new SqlFloatCodec(this);
|
|
1444
|
+
}
|
|
1445
|
+
};
|
|
1446
|
+
const pgFloatDescriptor = new PgFloatDescriptor();
|
|
1447
|
+
const pgFloatColumn = () => column(pgFloatDescriptor.factory(), pgFloatDescriptor.codecId, void 0, "float8");
|
|
1448
|
+
const codecDescriptors = definePostgresCodecs([
|
|
1449
|
+
postgresSqlCharDescriptor,
|
|
1450
|
+
postgresSqlVarcharDescriptor,
|
|
1451
|
+
postgresSqlIntDescriptor,
|
|
1452
|
+
postgresSqlFloatDescriptor,
|
|
1453
|
+
postgresSqlTextDescriptor,
|
|
1454
|
+
postgresSqlTimestampDescriptor,
|
|
1455
|
+
pgTextDescriptor,
|
|
1456
|
+
pgEnumDescriptor,
|
|
1457
|
+
pgCharDescriptor,
|
|
1458
|
+
pgVarcharDescriptor,
|
|
1459
|
+
pgIntDescriptor,
|
|
1460
|
+
pgFloatDescriptor,
|
|
1461
|
+
pgInt4Descriptor,
|
|
1462
|
+
pgInt2Descriptor,
|
|
1463
|
+
pgInt8Descriptor,
|
|
1464
|
+
pgFloat4Descriptor,
|
|
1465
|
+
pgFloat8Descriptor,
|
|
1466
|
+
pgNumericDescriptor,
|
|
1467
|
+
pgDateDescriptor,
|
|
1468
|
+
pgTimestampDescriptor,
|
|
1469
|
+
pgTimestamptzDescriptor,
|
|
1470
|
+
pgTimeDescriptor,
|
|
1471
|
+
pgTimetzDescriptor,
|
|
1472
|
+
pgBoolDescriptor,
|
|
1473
|
+
pgBitDescriptor,
|
|
1474
|
+
pgVarbitDescriptor,
|
|
1475
|
+
pgByteaDescriptor,
|
|
1476
|
+
pgUuidDescriptor,
|
|
1477
|
+
pgInetDescriptor,
|
|
1478
|
+
pgIntervalDescriptor,
|
|
1479
|
+
pgJsonDescriptor,
|
|
1480
|
+
pgJsonbDescriptor,
|
|
1481
|
+
pgTextArrayDescriptor
|
|
1482
|
+
]);
|
|
1483
|
+
//#endregion
|
|
1484
|
+
export { pgTimestamptzColumn as C, pgVarcharColumn as D, pgVarbitColumn as E, postgresQualifyColumnType as O, pgTimestampColumn as S, pgUuidColumn as T, pgJsonColumn as _, pgCharColumn as a, pgTextColumn as b, pgFloat4Column as c, pgInetColumn as d, pgInt2Column as f, pgIntervalColumn as g, pgIntColumn as h, pgBoolColumn as i, pgFloat8Column as l, pgInt8Column as m, isPgEnumParams as n, pgDateColumn as o, pgInt4Column as p, pgBitColumn as r, pgEnumDescriptor as s, codecDescriptors as t, pgFloatColumn as u, pgJsonbColumn as v, pgTimetzColumn as w, pgTimeColumn as x, pgNumericColumn as y };
|
|
1485
|
+
|
|
1486
|
+
//# sourceMappingURL=codecs-CBl0nD44-CaWPc1bd.mjs.map
|