@prisma/orm-target-postgres 8.0.0-rc.18-dev.15 → 8.0.0-rc.18-dev.17

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.
Files changed (215) hide show
  1. package/dist/{adapter-HQtZIZ2r-kQG81kJ1.mjs → adapter-C2XsLnXe-DLYvtWWr.mjs} +6 -6
  2. package/dist/{adapter-HQtZIZ2r-kQG81kJ1.mjs.map → adapter-C2XsLnXe-DLYvtWWr.mjs.map} +1 -1
  3. package/dist/{adapter-BiuJIKUc.d.mts → adapter-N4hlaZy6.d.mts} +5 -5
  4. package/dist/{adapter-BiuJIKUc.d.mts.map → adapter-N4hlaZy6.d.mts.map} +1 -1
  5. package/dist/adapter.d.mts +8 -9
  6. package/dist/adapter.mjs +5 -6
  7. package/dist/adapter__adapter.d.mts +1 -1
  8. package/dist/adapter__adapter.mjs +2 -2
  9. package/dist/adapter__control.d.mts +3 -4
  10. package/dist/adapter__control.mjs +6 -7
  11. package/dist/adapter__control.mjs.map +1 -1
  12. package/dist/adapter__runtime.d.mts +1 -1
  13. package/dist/adapter__runtime.mjs +4 -4
  14. package/dist/adapter__runtime.mjs.map +1 -1
  15. package/dist/adapter__sql-renderer.d.mts +1 -1
  16. package/dist/adapter__sql-renderer.mjs +1 -1
  17. package/dist/adapter__types.d.mts +3 -3
  18. package/dist/{aggregates-BNxcV7HS.d.mts → aggregates-BgI1xxMl.d.mts} +3 -3
  19. package/dist/{aggregates-BNxcV7HS.d.mts.map → aggregates-BgI1xxMl.d.mts.map} +1 -1
  20. package/dist/{aggregates-Brwk0sYS.mjs → aggregates-DHIDeR2f.mjs} +3 -3
  21. package/dist/{aggregates-Brwk0sYS.mjs.map → aggregates-DHIDeR2f.mjs.map} +1 -1
  22. package/dist/{authoring-BPkERq95-SR5fDsa_.mjs → authoring-DAorKc0L-DpWukVxn.mjs} +8 -8
  23. package/dist/authoring-DAorKc0L-DpWukVxn.mjs.map +1 -0
  24. package/dist/{autoincrement-widths-D_WhWVXx-D6BupdY2.mjs → autoincrement-widths-BLCRgB3t-BWl20PCZ.mjs} +3 -3
  25. package/dist/{autoincrement-widths-D_WhWVXx-D6BupdY2.mjs.map → autoincrement-widths-BLCRgB3t-BWl20PCZ.mjs.map} +1 -1
  26. package/dist/codec-descriptor-BlMs1rkg.d.mts +1 -0
  27. package/dist/{codec-descriptor-DkeVTJ3N-XTfZgDGp.d.mts → codec-descriptor-Cbz5bbma-dxeoAwS2.d.mts} +4 -4
  28. package/dist/codec-descriptor-Cbz5bbma-dxeoAwS2.d.mts.map +1 -0
  29. package/dist/{codec-descriptor-C5Ec_6Mw-CpacG1CL.mjs → codec-descriptor-DSMjoW72-ZoCcTHLX.mjs} +3 -4
  30. package/dist/codec-descriptor-DSMjoW72-ZoCcTHLX.mjs.map +1 -0
  31. package/dist/{codec-registry-DSRFjaLX-Dwg0yBK7.mjs → codec-registry-pg69n-o5-D8K3p40k.mjs} +5 -5
  32. package/dist/{codec-registry-DSRFjaLX-Dwg0yBK7.mjs.map → codec-registry-pg69n-o5-D8K3p40k.mjs.map} +1 -1
  33. package/dist/{codec-type-map-BznmYkRz-QD11Yx27.d.mts → codec-type-map-eTeOtvJB-c3tjqXBa.d.mts} +4 -4
  34. package/dist/{codec-type-map-BznmYkRz-QD11Yx27.d.mts.map → codec-type-map-eTeOtvJB-c3tjqXBa.d.mts.map} +1 -1
  35. package/dist/{codec-types-BZXuhZ1c-B9YQf_UN.d.mts → codec-types-Cf0IZ0WQ-CMVP-ecb.d.mts} +4 -4
  36. package/dist/{codec-types-BZXuhZ1c-B9YQf_UN.d.mts.map → codec-types-Cf0IZ0WQ-CMVP-ecb.d.mts.map} +1 -1
  37. package/dist/codec-types-o-BM2rPP.d.mts +2 -0
  38. package/dist/{codecs-BChKdFcD.d.mts → codecs-B-8uGsxq.d.mts} +3 -3
  39. package/dist/{codecs-BChKdFcD.d.mts.map → codecs-B-8uGsxq.d.mts.map} +1 -1
  40. package/dist/{codecs-CQaKsvhH-X9bscCr9.mjs → codecs-CaWZPjFi-hllqyGdW.mjs} +605 -574
  41. package/dist/codecs-CaWZPjFi-hllqyGdW.mjs.map +1 -0
  42. package/dist/{codecs-CCzJelD2-bt89qO8s.d.mts → codecs-DanVXZ_F-D1_8_x3j.d.mts} +150 -169
  43. package/dist/codecs-DanVXZ_F-D1_8_x3j.d.mts.map +1 -0
  44. package/dist/{contract-contributions-DC-ACLe5-BtAuL8oB.mjs → contract-contributions-C8XjOBIq-BuK0mnF9.mjs} +55 -40
  45. package/dist/contract-contributions-C8XjOBIq-BuK0mnF9.mjs.map +1 -0
  46. package/dist/{control-Bs7Il_Ju.mjs → control--DStfvkM.mjs} +17 -14
  47. package/dist/control--DStfvkM.mjs.map +1 -0
  48. package/dist/{control-B0dyj3WB.d.mts → control-Co7_lX4j.d.mts} +2 -11
  49. package/dist/control-Co7_lX4j.d.mts.map +1 -0
  50. package/dist/{control-B6nnypMh.d.mts → control-Mc7bM0Ho.d.mts} +4 -14
  51. package/dist/control-Mc7bM0Ho.d.mts.map +1 -0
  52. package/dist/{control-policy-CQ8hGDrk-jyie0S2j.mjs → control-policy-DrK_x_Qd-BcT8Z5TM.mjs} +13 -30
  53. package/dist/control-policy-DrK_x_Qd-BcT8Z5TM.mjs.map +1 -0
  54. package/dist/{data-type-entries-MxmSzT8p-D8CgbLxS.mjs → data-type-entries-DECnlc43-BYnGiJLy.mjs} +30 -3
  55. package/dist/data-type-entries-DECnlc43-BYnGiJLy.mjs.map +1 -0
  56. package/dist/data-types-BIvSDTYw-AK5Is74Z.mjs +961 -0
  57. package/dist/data-types-BIvSDTYw-AK5Is74Z.mjs.map +1 -0
  58. package/dist/{data-types-BDkZIUMI.d.mts → data-types-BkFfMhgz.d.mts} +10 -16
  59. package/dist/{data-types-BDkZIUMI.d.mts.map → data-types-BkFfMhgz.d.mts.map} +1 -1
  60. package/dist/default-normalizer-BqFHmlox-CP8ywN-r.mjs +313 -0
  61. package/dist/default-normalizer-BqFHmlox-CP8ywN-r.mjs.map +1 -0
  62. package/dist/default-normalizer-CTAiFe9Y.d.mts +25 -0
  63. package/dist/default-normalizer-CTAiFe9Y.d.mts.map +1 -0
  64. package/dist/{descriptor-meta-CqUL_be_-BkT3aEIm.mjs → descriptor-meta-CNFvhRlG-8_vCDF2W.mjs} +6 -6
  65. package/dist/{descriptor-meta-CqUL_be_-BkT3aEIm.mjs.map → descriptor-meta-CNFvhRlG-8_vCDF2W.mjs.map} +1 -1
  66. package/dist/{descriptor-meta-DzC2NwDh-C_D6wtZj.mjs → descriptor-meta-_qLKFkLd-Cb4H-vZf.mjs} +4 -4
  67. package/dist/{descriptor-meta-DzC2NwDh-C_D6wtZj.mjs.map → descriptor-meta-_qLKFkLd-Cb4H-vZf.mjs.map} +1 -1
  68. package/dist/{descriptor-meta-runtime-CpGl9XzU-CZHs_TNl.mjs → descriptor-meta-runtime-BKtwKsDm-BirZ12T5.mjs} +3 -3
  69. package/dist/{descriptor-meta-runtime-CpGl9XzU-CZHs_TNl.mjs.map → descriptor-meta-runtime-BKtwKsDm-BirZ12T5.mjs.map} +1 -1
  70. package/dist/{diff-database-schema-BKkcK7s--BxbpuwVf.mjs → diff-database-schema-C6fmfclD-Dqn9QqOO.mjs} +4 -4
  71. package/dist/{diff-database-schema-BKkcK7s--BxbpuwVf.mjs.map → diff-database-schema-C6fmfclD-Dqn9QqOO.mjs.map} +1 -1
  72. package/dist/{full-text-DzMPXaCj.d.mts → full-text-Ht1M3vH4.d.mts} +3 -3
  73. package/dist/{full-text-DzMPXaCj.d.mts.map → full-text-Ht1M3vH4.d.mts.map} +1 -1
  74. package/dist/{full-text-collection-method-B9e_oZFf-dyzLx5i6.d.mts → full-text-collection-method-Dye6N2u5-DGPEZRTD.d.mts} +4 -4
  75. package/dist/full-text-collection-method-Dye6N2u5-DGPEZRTD.d.mts.map +1 -0
  76. package/dist/{infer-psl-contract-DgOUfqJq-At4pgf6x.mjs → infer-psl-contract-hJUt-dtW-iwec11iw.mjs} +160 -56
  77. package/dist/infer-psl-contract-hJUt-dtW-iwec11iw.mjs.map +1 -0
  78. package/dist/{issue-planner-DDhlcfH2.d.mts → issue-planner-B3E9yChD.d.mts} +2 -2
  79. package/dist/{issue-planner-DDhlcfH2.d.mts.map → issue-planner-B3E9yChD.d.mts.map} +1 -1
  80. package/dist/migration-CbOh59ZJ.mjs.map +1 -1
  81. package/dist/{migration-DdE7N4ne.d.mts → migration-cGzKlTv0.d.mts} +2 -2
  82. package/dist/{migration-DdE7N4ne.d.mts.map → migration-cGzKlTv0.d.mts.map} +1 -1
  83. package/dist/{op-factory-call-BCBPUVFr-CW8l_JKw.mjs → op-factory-call-DJz5P0h1-Cs7DC10N.mjs} +4 -4
  84. package/dist/{op-factory-call-BCBPUVFr-CW8l_JKw.mjs.map → op-factory-call-DJz5P0h1-Cs7DC10N.mjs.map} +1 -1
  85. package/dist/op-factory-call-uVDKZqw1.d.mts +1 -0
  86. package/dist/{op-factory-call-COYbR6tp-XukKl6qj.d.mts → op-factory-call-z5TKsamx-DDfPa57U.d.mts} +2 -2
  87. package/dist/{op-factory-call-COYbR6tp-XukKl6qj.d.mts.map → op-factory-call-z5TKsamx-DDfPa57U.d.mts.map} +1 -1
  88. package/dist/{operation-types-BAiYtHkM-BN_YTibJ.d.mts → operation-types--RnlMCZS-qXBhNS1Q.d.mts} +3 -3
  89. package/dist/{operation-types-BAiYtHkM-BN_YTibJ.d.mts.map → operation-types--RnlMCZS-qXBhNS1Q.d.mts.map} +1 -1
  90. package/dist/operation-types-Dfg-5VmM.d.mts +1 -0
  91. package/dist/{pack-4sJCj0w-.d.mts → pack-_zBIeh-3.d.mts} +4 -4
  92. package/dist/{pack-4sJCj0w-.d.mts.map → pack-_zBIeh-3.d.mts.map} +1 -1
  93. package/dist/{planner-Pcd2R46Y.d.mts → planner-BBGH1cAB.d.mts} +2 -2
  94. package/dist/{planner-Pcd2R46Y.d.mts.map → planner-BBGH1cAB.d.mts.map} +1 -1
  95. package/dist/planner-ddl-builders-Byw5BICu.d.mts +16 -0
  96. package/dist/planner-ddl-builders-Byw5BICu.d.mts.map +1 -0
  97. package/dist/planner-ddl-builders-D0r6cT4A-D9Wm1myF.mjs +29 -0
  98. package/dist/planner-ddl-builders-D0r6cT4A-D9Wm1myF.mjs.map +1 -0
  99. package/dist/{planner-RhYHAxZm-9qT-aXSU.mjs → planner-ewMcuoHd-DwCCA-Kc.mjs} +9 -8
  100. package/dist/planner-ewMcuoHd-DwCCA-Kc.mjs.map +1 -0
  101. package/dist/{planner-identity-values-DwvdO5iZ-C9_lmJx6.mjs → planner-identity-values-CWUHmsB9-CBQ00C_3.mjs} +3 -3
  102. package/dist/{planner-identity-values-DwvdO5iZ-C9_lmJx6.mjs.map → planner-identity-values-CWUHmsB9-CBQ00C_3.mjs.map} +1 -1
  103. package/dist/planner-produced-postgres-migration-D-ZcNy7h.d.mts +1 -0
  104. package/dist/{planner-produced-postgres-migration-B3b3MBKL-CxswQFN2.mjs → planner-produced-postgres-migration-Dy5zHiFB-BDpfjZD5.mjs} +4 -4
  105. package/dist/{planner-produced-postgres-migration-B3b3MBKL-CxswQFN2.mjs.map → planner-produced-postgres-migration-Dy5zHiFB-BDpfjZD5.mjs.map} +1 -1
  106. package/dist/{planner-produced-postgres-migration-eM7nl_4L-DSW4rLOj.d.mts → planner-produced-postgres-migration-sxhIP3Te-Cn3sD9zE.d.mts} +3 -3
  107. package/dist/planner-produced-postgres-migration-sxhIP3Te-Cn3sD9zE.d.mts.map +1 -0
  108. package/dist/{planner-sql-checks-BV2akIx8-l8qCWzYf.mjs → planner-sql-checks-D0w3Kt_G-Bh1Vlz0T.mjs} +5 -5
  109. package/dist/{planner-sql-checks-BV2akIx8-l8qCWzYf.mjs.map → planner-sql-checks-D0w3Kt_G-Bh1Vlz0T.mjs.map} +1 -1
  110. package/dist/{postgres-codec-traits-DOTVjmpT-B4f6Rkh7.mjs → postgres-codec-traits-DY-tFVjg-CjMZUKNx.mjs} +3 -3
  111. package/dist/{postgres-codec-traits-DOTVjmpT-B4f6Rkh7.mjs.map → postgres-codec-traits-DY-tFVjg-CjMZUKNx.mjs.map} +1 -1
  112. package/dist/{postgres-contract-view-Cei64xbt-BcDzLVah.mjs → postgres-contract-view-o6bwzfH6-D4jvq9PJ.mjs} +6 -6
  113. package/dist/{postgres-contract-view-Cei64xbt-BcDzLVah.mjs.map → postgres-contract-view-o6bwzfH6-D4jvq9PJ.mjs.map} +1 -1
  114. package/dist/{postgres-migration-D0TY1HnO-CXuyvNiq.d.mts → postgres-migration-D6_R3__I-rFg_i2gz.d.mts} +2 -2
  115. package/dist/{postgres-migration-D0TY1HnO-CXuyvNiq.d.mts.map → postgres-migration-D6_R3__I-rFg_i2gz.d.mts.map} +1 -1
  116. package/dist/{postgres-migration-Bj3MPD7z-Clk_A5s-.mjs → postgres-migration-Dtkb6eDn-CrButm3l.mjs} +14 -22
  117. package/dist/postgres-migration-Dtkb6eDn-CrButm3l.mjs.map +1 -0
  118. package/dist/{prisma7-binding-BwBQ58iZ.mjs → prisma7-binding-BsucflfD.mjs} +106 -87
  119. package/dist/prisma7-binding-BsucflfD.mjs.map +1 -0
  120. package/dist/{prisma7-binding-LcYpTBjP.d.mts → prisma7-binding-DGp7Ea38.d.mts} +24 -15
  121. package/dist/prisma7-binding-DGp7Ea38.d.mts.map +1 -0
  122. package/dist/{render-ops-TAy4wxZ8-FnL41Aq3.mjs → render-ops-Db7MhDM0-DsIQjmcY.mjs} +3 -3
  123. package/dist/{render-ops-TAy4wxZ8-FnL41Aq3.mjs.map → render-ops-Db7MhDM0-DsIQjmcY.mjs.map} +1 -1
  124. package/dist/{runtime-CNTEAZIz.d.mts → runtime-CXQ7Xh-G.d.mts} +2 -2
  125. package/dist/{runtime-CNTEAZIz.d.mts.map → runtime-CXQ7Xh-G.d.mts.map} +1 -1
  126. package/dist/{runtime-C1HMiDVY.d.mts → runtime-CmUxJgD8.d.mts} +2 -2
  127. package/dist/{runtime-C1HMiDVY.d.mts.map → runtime-CmUxJgD8.d.mts.map} +1 -1
  128. package/dist/{sql-renderer-Q8LMpTcq-CliGmy0r.mjs → sql-renderer-CD5aYQos-nO-jTG1T.mjs} +5 -4
  129. package/dist/sql-renderer-CD5aYQos-nO-jTG1T.mjs.map +1 -0
  130. package/dist/{sql-renderer-hQ3HTY-B.d.mts → sql-renderer-dk7d0cK0.d.mts} +4 -4
  131. package/dist/{sql-renderer-hQ3HTY-B.d.mts.map → sql-renderer-dk7d0cK0.d.mts.map} +1 -1
  132. package/dist/target.d.mts +27 -27
  133. package/dist/target.mjs +23 -24
  134. package/dist/target__aggregates.d.mts +1 -1
  135. package/dist/target__aggregates.mjs +1 -1
  136. package/dist/target__codec-descriptor.d.mts +2 -2
  137. package/dist/target__codec-descriptor.mjs +1 -1
  138. package/dist/target__codec-types.d.mts +3 -3
  139. package/dist/target__codecs.d.mts +2 -2
  140. package/dist/target__codecs.mjs +2 -3
  141. package/dist/target__control.d.mts +2 -2
  142. package/dist/target__control.mjs +4 -5
  143. package/dist/target__data-types.d.mts +2 -2
  144. package/dist/target__data-types.mjs +3 -3
  145. package/dist/target__default-normalizer.d.mts +2 -2
  146. package/dist/target__default-normalizer.mjs +2 -2
  147. package/dist/target__diff-database-schema.mjs +1 -1
  148. package/dist/target__full-text-index-authoring.mjs +1 -1
  149. package/dist/target__full-text.d.mts +3 -3
  150. package/dist/target__issue-planner.d.mts +1 -1
  151. package/dist/target__issue-planner.mjs +1 -1
  152. package/dist/target__migration.d.mts +2 -2
  153. package/dist/target__migration.mjs +2 -2
  154. package/dist/target__op-factory-call.d.mts +2 -2
  155. package/dist/target__op-factory-call.mjs +1 -1
  156. package/dist/target__operation-types.d.mts +2 -2
  157. package/dist/target__pack.d.mts +2 -2
  158. package/dist/target__pack.mjs +1 -1
  159. package/dist/target__planner-ddl-builders.d.mts +2 -2
  160. package/dist/target__planner-ddl-builders.mjs +2 -2
  161. package/dist/target__planner-identity-values.mjs +1 -1
  162. package/dist/target__planner-produced-postgres-migration.d.mts +2 -2
  163. package/dist/target__planner-produced-postgres-migration.mjs +1 -1
  164. package/dist/target__planner-sql-checks.mjs +1 -1
  165. package/dist/target__planner.d.mts +1 -1
  166. package/dist/target__planner.mjs +2 -2
  167. package/dist/target__prisma7-binding.d.mts +1 -1
  168. package/dist/target__prisma7-binding.mjs +1 -1
  169. package/dist/target__render-ops.mjs +1 -1
  170. package/dist/target__runtime.d.mts +2 -2
  171. package/dist/target__runtime.mjs +4 -4
  172. package/dist/target__runtime.mjs.map +1 -1
  173. package/dist/{types-D6lgKhE5-DYkeCAjr.d.mts → types-D6lgKhE5-CjLf9QtO.d.mts} +5 -5
  174. package/dist/{types-D6lgKhE5-DYkeCAjr.d.mts.map → types-D6lgKhE5-CjLf9QtO.d.mts.map} +1 -1
  175. package/dist/types-xDgmVoc4.d.mts +2 -0
  176. package/package.json +9 -9
  177. package/dist/authoring-BPkERq95-SR5fDsa_.mjs.map +0 -1
  178. package/dist/codec-descriptor-C5Ec_6Mw-CpacG1CL.mjs.map +0 -1
  179. package/dist/codec-descriptor-DAQDOwCJ.d.mts +0 -1
  180. package/dist/codec-descriptor-DkeVTJ3N-XTfZgDGp.d.mts.map +0 -1
  181. package/dist/codec-helpers-IfGdyCFt-ihgFCc7D.mjs +0 -571
  182. package/dist/codec-helpers-IfGdyCFt-ihgFCc7D.mjs.map +0 -1
  183. package/dist/codec-types-ZfL8TSVm.d.mts +0 -2
  184. package/dist/codecs-CCzJelD2-bt89qO8s.d.mts.map +0 -1
  185. package/dist/codecs-CQaKsvhH-X9bscCr9.mjs.map +0 -1
  186. package/dist/contract-contributions-DC-ACLe5-BtAuL8oB.mjs.map +0 -1
  187. package/dist/control-B0dyj3WB.d.mts.map +0 -1
  188. package/dist/control-B6nnypMh.d.mts.map +0 -1
  189. package/dist/control-Bs7Il_Ju.mjs.map +0 -1
  190. package/dist/control-policy-CQ8hGDrk-jyie0S2j.mjs.map +0 -1
  191. package/dist/data-type-entries-MxmSzT8p-D8CgbLxS.mjs.map +0 -1
  192. package/dist/data-types-DnIWGq_1-DTMjYG8M.mjs +0 -375
  193. package/dist/data-types-DnIWGq_1-DTMjYG8M.mjs.map +0 -1
  194. package/dist/default-normalizer-BnxtqsRm-CDjZe4vK.mjs +0 -510
  195. package/dist/default-normalizer-BnxtqsRm-CDjZe4vK.mjs.map +0 -1
  196. package/dist/default-normalizer-ZZ7Y5boE.d.mts +0 -31
  197. package/dist/default-normalizer-ZZ7Y5boE.d.mts.map +0 -1
  198. package/dist/full-text-collection-method-B9e_oZFf-dyzLx5i6.d.mts.map +0 -1
  199. package/dist/infer-psl-contract-DgOUfqJq-At4pgf6x.mjs.map +0 -1
  200. package/dist/list-decoder-DXee1orj-K3y-hxiI.mjs +0 -22
  201. package/dist/list-decoder-DXee1orj-K3y-hxiI.mjs.map +0 -1
  202. package/dist/op-factory-call-B58Fw5Rz.d.mts +0 -1
  203. package/dist/operation-types-CScw-diG.d.mts +0 -1
  204. package/dist/planner-RhYHAxZm-9qT-aXSU.mjs.map +0 -1
  205. package/dist/planner-ddl-builders-BBQC5ET6.d.mts +0 -38
  206. package/dist/planner-ddl-builders-BBQC5ET6.d.mts.map +0 -1
  207. package/dist/planner-ddl-builders-oCsZMJ3b-BTMfg1YV.mjs +0 -91
  208. package/dist/planner-ddl-builders-oCsZMJ3b-BTMfg1YV.mjs.map +0 -1
  209. package/dist/planner-produced-postgres-migration-DiBkh1Tj.d.mts +0 -1
  210. package/dist/planner-produced-postgres-migration-eM7nl_4L-DSW4rLOj.d.mts.map +0 -1
  211. package/dist/postgres-migration-Bj3MPD7z-Clk_A5s-.mjs.map +0 -1
  212. package/dist/prisma7-binding-BwBQ58iZ.mjs.map +0 -1
  213. package/dist/prisma7-binding-LcYpTBjP.d.mts.map +0 -1
  214. package/dist/sql-renderer-Q8LMpTcq-CliGmy0r.mjs.map +0 -1
  215. package/dist/types-DIUPMK41.d.mts +0 -2
@@ -1,17 +1,286 @@
1
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, F as PG_VARCHAR_CODEC_ID, M as PG_UNBOUNDED_INT_CODEC_ID, N as PG_UUID_CODEC_ID, O as PG_TIMETZ_CODEC_ID, P as PG_VARBIT_CODEC_ID, S as PG_TEXT_CODEC_ID, T as PG_TIMESTAMPTZ_TEMPORAL_CODEC_ID, _ as PG_INT_CODEC_ID, a as PG_DATE_STRING_CODEC_ID, b as PG_NUMERIC_CODEC_ID, c as PG_FLOAT4_CODEC_ID, d as PG_INET_CODEC_ID, f as PG_INT2_CODEC_ID, g as PG_INTERVAL_CODEC_ID, h as PG_INT8_NUMBER_CODEC_ID, i as PG_CHAR_CODEC_ID, j as PG_TSQUERY_CODEC_ID, k as PG_TIME_STRING_CODEC_ID, l as PG_FLOAT8_CODEC_ID, m as PG_INT8_CODEC_ID, n as PG_BOOL_CODEC_ID, o as PG_DATE_TEMPORAL_CODEC_ID, p as PG_INT4_CODEC_ID, r as PG_BYTEA_CODEC_ID, s as PG_ENUM_CODEC_ID, t as PG_BIT_CODEC_ID, u as PG_FLOAT_CODEC_ID, v as PG_JSONB_CODEC_ID, w as PG_TIMESTAMPTZ_STRING_CODEC_ID, x as PG_TEXT_ARRAY_CODEC_ID, y as PG_JSON_CODEC_ID } from "./codec-ids-Cb0yO-IS--e0P2rfI.mjs";
2
- import { a as postgresCodec, r as definePostgresCodecs, t as PostgresCodecDescriptor } from "./codec-descriptor-C5Ec_6Mw-CpacG1CL.mjs";
2
+ import { a as postgresCodec, r as definePostgresCodecs, t as PostgresCodecDescriptor } from "./codec-descriptor-DSMjoW72-ZoCcTHLX.mjs";
3
3
  import { a as errorTemporalUnrepresentable, i as errorTemporalUnavailableForDefault, n as errorTemporalNonIsoCalendar, o as errorTemporalWrongType, r as errorTemporalUnavailable, s as postgresError } from "./errors-DYyzTYzE-39CV_aMo.mjs";
4
- import { A as pgJsonbEncode, C as pgIntervalDecode, D as pgJsonDecode, E as pgIntervalToIso, M as pgUnboundedIntDecode, O as pgJsonEncode, T as pgIntervalEncodeJson, _ as pgInt8Decode, a as decimalTextBigintLiteral, b as pgInt8NumberEncode, c as fitsFloat4, d as pgBigintEncodeJson, g as pgFloatEncode, h as pgByteaEncodeJson, i as canonicalUuid, j as pgNumericDecode, k as pgJsonbDecode, l as floatNumberLiteral, m as pgByteaDecodeWire, n as FLOAT4_MAX, o as decimalTextNumberLiteral, p as pgByteaDecodeJson, r as canonicalInet, s as fitsCharacterLength, t as CANONICAL_UUID, u as pgBigintEncode, v as pgInt8NumberDecode, w as pgIntervalDecodeJson, x as pgInt8NumberEncodeJson, y as pgInt8NumberDecodeJson } from "./codec-helpers-IfGdyCFt-ihgFCc7D.mjs";
5
- import { A as pgTimestamptz, C as pgPrecisionParams, D as pgTimeCanonical, E as pgTime, F as pgUuid, I as pgVarbit, L as pgVarchar, M as pgTimetz, N as pgTimetzCanonical, O as pgTimestamp, P as pgTsquery, S as pgNumericParams, T as pgTextArray, _ as pgInt8, a as pgBytea, b as pgJsonb, c as pgDate, d as pgEnumParams, f as pgFloat4, g as pgInt4, h as pgInt2, i as pgBool, j as pgTimestamptzCanonical, k as pgTimestampCanonical, l as pgDateCanonical, m as pgInet, n as pgBit, o as pgChar, p as pgFloat8, r as pgBitLengthParams, s as pgCharacterLengthParams, u as pgEnum, v as pgInterval, w as pgText, x as pgNumeric, y as pgJson } from "./data-types-DnIWGq_1-DTMjYG8M.mjs";
4
+ import { A as pgJsonb, B as pgTimestamptz, C as pgInet, D as pgInterval, E as pgInt8, F as pgTextArray, G as pgUuid, H as pgTimetz, I as pgTime, K as pgVarbit, M as pgNumericParams, N as pgPrecisionParams, P as pgText, R as pgTimestamp, S as pgFloat8, T as pgInt4, V as pgTimestamptzStoredText, W as pgTsquery, X as postgresYearText, Y as postgresIntervalFields, _ as pgDate, a as formatIsoDuration, b as pgEnumParams, c as microsFromFraction, d as pgBool, f as pgBytea, g as pgCharacterLengthParams, h as pgChar, j as pgNumeric, k as pgJson, l as pgBit, n as ISO_DURATION, o as intervalFieldsOf, q as pgVarchar, r as MICROS_PER_SECOND, s as isoYearText, t as BYTEA_TEXT, u as pgBitLengthParams, w as pgInt2, x as pgFloat4, y as pgEnum } from "./data-types-BIvSDTYw-AK5Is74Z.mjs";
6
5
  import { t as PostgresNativeEnum } from "./postgres-native-enum-CdP3b_-R-Cgz9KEKx.mjs";
7
- import { BinaryExpr, CaseExpr, CastExpr, FunctionCallExpr, LiteralExpr, NullCheckExpr, OrExpr, SqlCharCodec, SqlFloatCodec, SqlIntCodec, SqlVarcharCodec, sqlCharDescriptor, sqlFloatDescriptor, sqlIntDescriptor, sqlTextDescriptor, sqlVarcharDescriptor } from "@prisma/orm-family-sql/relational-core/ast";
6
+ import { CastExpr, SqlCharCodec, SqlFloatCodec, SqlIntCodec, SqlTextCodec, SqlVarcharCodec, sqlCharDescriptor, sqlFloatDescriptor, sqlIntDescriptor, sqlTextDescriptor, sqlVarcharDescriptor } from "@prisma/orm-family-sql/relational-core/ast";
8
7
  import { isStructuredError } from "@prisma/orm-framework/utils/structured-error";
9
- import { CodecImpl, INT32_RANGE, INT64_RANGE, column, decodeJsonBoolean, decodeJsonFloat, decodeJsonInteger, decodeJsonIntegerText, decodeJsonMatching, decodeJsonString, encodeJsonFloat, isNonFiniteText, refuseJsonValue, renderTsLiteral } from "@prisma/orm-framework/components/codec";
8
+ import { CodecImpl, SAFE_INTEGER_BIGINT_RANGE, column, floatToJson, isNonFiniteText, readJsonFloat, readJsonIntegerText, refuseJsonValue, renderTsLiteral } from "@prisma/orm-framework/components/codec";
10
9
  import { blindCast } from "@prisma/orm-framework/utils/casts";
11
- import { counted, withoutTrailing } from "@prisma/orm-framework/utils/text";
12
- import { canonicalDateTime, canonicalNumeralText } from "@prisma/orm-family-sql/contract/data-type-support";
10
+ import { numeralText } from "@prisma/orm-family-sql/contract/data-type";
11
+ import { storedNumeralText } from "@prisma/orm-family-sql/contract/data-type-support";
13
12
  import { UNBOUND_NAMESPACE_ID } from "@prisma/orm-framework/components/ir";
14
- //#region ../../../3-targets/3-targets/postgres/dist/codecs-CQaKsvhH.mjs
13
+ import { parse } from "postgres-array";
14
+ //#region ../../../3-targets/3-targets/postgres/dist/codecs-CaWZPjFi.mjs
15
+ /**
16
+ * A `numeric` value as its canonical decimal text. A number is written out without an exponent,
17
+ * because `numeric` text has no exponent syntax and `toDataTypeValue` refuses one.
18
+ */
19
+ const pgNumericDecode = (wire) => {
20
+ if (typeof wire === "number") return numeralText(wire);
21
+ return wire;
22
+ };
23
+ const DECIMAL_INTEGER = /^-?\d+$/;
24
+ /**
25
+ * Requires an application value to be of the JS type the codec reads.
26
+ *
27
+ * A range check reads a value of the wrong type as a value out of range, and
28
+ * reports a number plainly inside the range as outside it — so the type is
29
+ * established first and answered for on its own terms, naming what a caller
30
+ * has to change.
31
+ */
32
+ const requireJsType = (codecId, expected, value) => {
33
+ if (typeof value === expected) return;
34
+ throw postgresError("RUNTIME.ENCODE_FAILED", `${codecId} value must be a ${expected}, got ${typeof value} ${String(value)}`, { meta: {
35
+ codecId,
36
+ received: typeof value
37
+ } });
38
+ };
39
+ /** Writes a `bigint` application value as the decimal text the wire form of the exact integer codecs carries. */
40
+ const pgBigintEncode = (codecId, value) => {
41
+ requireJsType(codecId, "bigint", value);
42
+ return value.toString();
43
+ };
44
+ /**
45
+ * Writes an application value as the decimal text these codecs carry as their
46
+ * canonical JSON.
47
+ *
48
+ * A schema-written literal default (`BigInt @default(0)`) arrives here as a
49
+ * `number`, since a number literal is the only integer a schema language
50
+ * writes, and one that is a safe integer names its value exactly. Past that
51
+ * range the literal was rounded before any of this ran, so the value written is
52
+ * not the value meant — which this refuses rather than minting an exact-looking
53
+ * total from it. A non-integral number is refused on the same terms.
54
+ */
55
+ const pgBigintDigits = (codecId, value) => {
56
+ if (typeof value !== "number") return pgBigintEncode(codecId, value);
57
+ if (!Number.isSafeInteger(value)) throw postgresError("RUNTIME.ENCODE_FAILED", `${codecId} number literal must be an integer within the safe integer range, got ${String(value)}`, { meta: {
58
+ codecId,
59
+ received: String(value)
60
+ } });
61
+ return BigInt(value).toString();
62
+ };
63
+ /**
64
+ * Reads a wire or JSON value as a `bigint`, rejecting anything `BigInt()` would
65
+ * misread. A number-typed wire value must also be a safe integer: past
66
+ * ±(2^53 − 1) the driver's `number` has already rounded, so stringifying it
67
+ * would mint a spuriously-exact `bigint` that need not equal the stored value.
68
+ */
69
+ const decimalIntegerDecode = (codecId, wire) => {
70
+ if (typeof wire === "bigint") return wire;
71
+ const text = String(wire);
72
+ if (!DECIMAL_INTEGER.test(text)) throw postgresError("RUNTIME.DECODE_FAILED", `${codecId} value must be a decimal integer`, { meta: {
73
+ codecId,
74
+ received: text
75
+ } });
76
+ if (typeof wire === "number" && !Number.isSafeInteger(wire)) throw postgresError("RUNTIME.DECODE_FAILED", `${codecId} wire number must be an integer within the safe integer range, got ${text}`, { meta: {
77
+ codecId,
78
+ received: text
79
+ } });
80
+ return BigInt(text);
81
+ };
82
+ /** Reads an `int8` wire or JSON value as a `bigint`, rejecting anything `BigInt()` would misread. */
83
+ const pgInt8Decode = (wire) => decimalIntegerDecode("pg/int8@1", wire);
84
+ /**
85
+ * Reads an unconstrained-`numeric` wire or JSON value as a `bigint`, rejecting
86
+ * non-integral values — including `NaN` and the infinities, which are `numeric`
87
+ * values but not integers.
88
+ */
89
+ const pgUnboundedIntDecode = (wire) => decimalIntegerDecode("pg/unboundedint@1", wire);
90
+ /**
91
+ * A SQL number literal has no form for `NaN` or the infinities; PostgreSQL reads and writes them as
92
+ * the text `NaN`, `Infinity`, `-Infinity`, so the float codecs carry them as that text on the wire,
93
+ * as `floatToJson` does in JSON.
94
+ */
95
+ const pgFloatEncode = (value) => Number.isFinite(value) ? value : String(value);
96
+ /**
97
+ * Requires an integer within ±(2^53 − 1), the range a JS `number` holds
98
+ * exactly. The guard throws rather than rounding: past the boundary a `number`
99
+ * silently loses digits, which is the failure mode this codec exists to refuse.
100
+ */
101
+ const pgInt8NumberGuard = (code, value) => {
102
+ if (!Number.isSafeInteger(value)) throw postgresError(code, `pg/int8number@1 value must be an integer within the safe integer range, got ${String(value)}`, { meta: {
103
+ codecId: "pg/int8number@1",
104
+ received: String(value)
105
+ } });
106
+ return value;
107
+ };
108
+ const pgInt8NumberEncode = (value) => {
109
+ requireJsType("pg/int8number@1", "number", value);
110
+ return String(pgInt8NumberGuard("RUNTIME.ENCODE_FAILED", value));
111
+ };
112
+ /**
113
+ * Reads an `int8` wire value as a `number`, throwing outside ±(2^53 − 1) and on
114
+ * non-integral input. Decimal text goes through `BigInt` before the range check
115
+ * so an out-of-range value is compared exactly rather than after rounding.
116
+ */
117
+ const pgInt8NumberDecode = (wire) => {
118
+ if (typeof wire === "number") return pgInt8NumberGuard("RUNTIME.DECODE_FAILED", wire);
119
+ const value = decimalIntegerDecode("pg/int8number@1", wire);
120
+ if (value < SAFE_INTEGER_BIGINT_RANGE.min || value > SAFE_INTEGER_BIGINT_RANGE.max) throw postgresError("RUNTIME.DECODE_FAILED", `pg/int8number@1 value must be an integer within the safe integer range, got ${value}`, { meta: {
121
+ codecId: "pg/int8number@1",
122
+ received: value.toString()
123
+ } });
124
+ return Number(value);
125
+ };
126
+ /** A `number` holds an integer exactly only within the safe integer range, so digit text past it is refused. */
127
+ const pgInt8NumberFromDigits = (digits) => Number(readJsonIntegerText("pg/int8number@1", digits, SAFE_INTEGER_BIGINT_RANGE));
128
+ /**
129
+ * Renders a decimal-text default as a `bigint` literal, for the codecs whose
130
+ * canonical JSON is decimal text while the application type is `bigint`
131
+ * (`pg/int8@1`, `pg/unboundedint@1`) — a plain string literal would not
132
+ * typecheck against the emitted column type.
133
+ */
134
+ const decimalTextBigintLiteral = (value) => typeof value === "string" && DECIMAL_INTEGER.test(value) ? `${value}n` : void 0;
135
+ /** Renders a float's stored number as a number literal. NaN and the infinities are stored as text and have no literal type, so they render nothing and the value set types as `number`. */
136
+ const floatNumberLiteral = (value) => typeof value === "number" ? String(value) : void 0;
137
+ /** Renders the decimal text of `pg/int8number@1`, whose application type is `number`, as a number literal. */
138
+ const decimalTextNumberLiteral = (value) => typeof value === "string" && DECIMAL_INTEGER.test(value) ? value : void 0;
139
+ /** Parses an ISO-8601 duration into the application value. */
140
+ const pgIntervalFromIso = (text) => intervalFieldsOf(text);
141
+ /** Renders the application value as its canonical ISO-8601 duration. */
142
+ const pgIntervalToIso = (value) => formatIsoDuration(value);
143
+ const ZERO_INTERVAL = {
144
+ months: 0,
145
+ days: 0,
146
+ micros: 0n
147
+ };
148
+ /** `count` with the sign `negative` gives it, never `-0`. */
149
+ const signed = (negative, count) => negative && count !== 0 ? -count : count;
150
+ const negated = ({ months, days, micros }) => ({
151
+ months: signed(true, months),
152
+ days: signed(true, days),
153
+ micros: -micros
154
+ });
155
+ /** Hours, minutes, seconds and a fraction of a second, with one sign for all of them. */
156
+ function timeMicros(negative, hours, minutes, seconds, fraction) {
157
+ const magnitude = (BigInt(hours) * 3600n + BigInt(minutes) * 60n + BigInt(seconds)) * MICROS_PER_SECOND + microsFromFraction(fraction, negative);
158
+ return negative ? -magnitude : magnitude;
159
+ }
160
+ const VERBOSE_FIELD = /^(-?)(\d+)(?:\.(\d+))? (year|mon|day|hour|min|sec)s?$/;
161
+ /**
162
+ * An interval as PostgreSQL prints it under `IntervalStyle = 'postgres_verbose'`: `@ 1 year 2 mons
163
+ * -3 days 4 hours 5 mins 6.5 secs`, each field with its own sign, and ` ago` negating the whole; `@ 0`
164
+ * for zero.
165
+ */
166
+ function verboseIntervalFields(text) {
167
+ if (!text.startsWith("@ ")) return void 0;
168
+ const ago = text.endsWith(" ago");
169
+ const body = text.slice(2, ago ? -4 : void 0);
170
+ if (body === "0") return ZERO_INTERVAL;
171
+ const words = body.split(" ");
172
+ if (words.length === 0 || words.length % 2 !== 0) return void 0;
173
+ let months = 0;
174
+ let days = 0;
175
+ let micros = 0n;
176
+ for (let index = 0; index < words.length; index += 2) {
177
+ const match = VERBOSE_FIELD.exec(`${words[index]} ${words[index + 1]}`);
178
+ if (match === null) return void 0;
179
+ const [, sign = "", whole = "0", fraction, unit] = match;
180
+ if (fraction !== void 0 && unit !== "sec") return void 0;
181
+ const negative = sign === "-";
182
+ const count = signed(negative, Number(whole));
183
+ if (unit === "year") months += count * 12;
184
+ else if (unit === "mon") months += count;
185
+ else if (unit === "day") days += count;
186
+ else if (unit === "hour") micros += BigInt(count) * 3600n * MICROS_PER_SECOND;
187
+ else if (unit === "min") micros += BigInt(count) * 60n * MICROS_PER_SECOND;
188
+ else micros += timeMicros(negative, "0", "0", whole, fraction ?? "");
189
+ }
190
+ const fields = {
191
+ months,
192
+ days,
193
+ micros
194
+ };
195
+ return ago ? negated(fields) : fields;
196
+ }
197
+ const SQL_MIXED = /^([+-])(\d+)-(\d+) ([+-])(\d+) ([+-])(\d+):(\d{2}):(\d{2})(?:\.(\d+))?$/;
198
+ const SQL_YEAR_MONTH = /^(-?)(\d+)-(\d+)$/;
199
+ const SQL_DAY_TIME = /^(-?)(?:(\d+) )?(\d+):(\d{2}):(\d{2})(?:\.(\d+))?$/;
200
+ /**
201
+ * An interval as PostgreSQL prints it under `IntervalStyle = 'sql_standard'`. A value with fields of
202
+ * one sign and of one kind, year-month or day-time, has a single leading sign for all of them:
203
+ * `-1-2`, `-1 2:03:04`, `-0:00:01.5`. Any other value signs each part: `+1-2 -3 +4:05:06.5`. Zero is
204
+ * `0`.
205
+ */
206
+ function sqlStandardIntervalFields(text) {
207
+ if (text === "0") return ZERO_INTERVAL;
208
+ const mixed = SQL_MIXED.exec(text);
209
+ if (mixed !== null) {
210
+ const [, yearSign, years = "0", months = "0", daySign, days = "0", timeSign] = mixed;
211
+ const monthCount = Number(years) * 12 + Number(months);
212
+ return {
213
+ months: signed(yearSign === "-", monthCount),
214
+ days: signed(daySign === "-", Number(days)),
215
+ micros: timeMicros(timeSign === "-", mixed[7] ?? "0", mixed[8] ?? "0", mixed[9] ?? "0", mixed[10] ?? "")
216
+ };
217
+ }
218
+ const yearMonth = SQL_YEAR_MONTH.exec(text);
219
+ if (yearMonth !== null) {
220
+ const [, sign, years = "0", months = "0"] = yearMonth;
221
+ const monthCount = Number(years) * 12 + Number(months);
222
+ return {
223
+ months: signed(sign === "-", monthCount),
224
+ days: 0,
225
+ micros: 0n
226
+ };
227
+ }
228
+ const dayTime = SQL_DAY_TIME.exec(text);
229
+ if (dayTime === null) return void 0;
230
+ const [, sign, days = "0", hours = "0", minutes = "0", seconds = "0", fraction = ""] = dayTime;
231
+ const negative = sign === "-";
232
+ return {
233
+ months: 0,
234
+ days: signed(negative, Number(days)),
235
+ micros: timeMicros(negative, hours, minutes, seconds, fraction)
236
+ };
237
+ }
238
+ /** Reads the interval text PostgreSQL prints under any `IntervalStyle`. */
239
+ const intervalTextFields = (text) => {
240
+ const fields = ISO_DURATION.test(text) ? intervalFieldsOf(text) : postgresIntervalFields(text) ?? verboseIntervalFields(text) ?? sqlStandardIntervalFields(text);
241
+ if (fields === void 0) throw postgresError("RUNTIME.DECODE_FAILED", `pg/interval@1 value must be interval text PostgreSQL prints under an IntervalStyle, got ${text}`, { meta: {
242
+ codecId: "pg/interval@1",
243
+ received: text
244
+ } });
245
+ return fields;
246
+ };
247
+ const pgIntervalDecode = (wire) => {
248
+ if (typeof wire === "string") return intervalTextFields(wire);
249
+ const part = (name) => {
250
+ const raw = wire[name];
251
+ return typeof raw === "number" ? raw : 0;
252
+ };
253
+ const seconds = part("seconds") + part("milliseconds") / 1e3;
254
+ return {
255
+ months: part("years") * 12 + part("months"),
256
+ days: part("days"),
257
+ micros: BigInt(part("hours")) * 3600n * MICROS_PER_SECOND + BigInt(part("minutes")) * 60n * MICROS_PER_SECOND + BigInt(Math.round(seconds * 1e6))
258
+ };
259
+ };
260
+ const pgByteaToBase64 = (value) => Buffer.from(value).toString("base64");
261
+ const pgByteaFromBase64 = (base64) => new Uint8Array(Buffer.from(base64, "base64"));
262
+ /** The text PostgreSQL prints for `bytea` under `bytea_output = 'escape'`: `\\` for a backslash, `\nnn` in octal for a byte outside printable ASCII, and every other byte as itself. */
263
+ const BYTEA_ESCAPE_TEXT = /^(?:[ -[\]-~]|\\\\|\\[0-3][0-7]{2})*$/;
264
+ const BYTEA_ESCAPE = /\\\\|\\([0-3][0-7]{2})|[ -[\]-~]/g;
265
+ function byteaOfEscapeText(text) {
266
+ const bytes = [];
267
+ for (const [token, octal] of text.matchAll(BYTEA_ESCAPE)) bytes.push(octal !== void 0 ? Number.parseInt(octal, 8) : token === "\\\\" ? 92 : token.charCodeAt(0));
268
+ return Uint8Array.from(bytes);
269
+ }
270
+ const pgByteaDecodeWire = (wire) => {
271
+ if (wire instanceof Uint8Array) return wire.constructor === Uint8Array ? wire : new Uint8Array(wire.buffer, wire.byteOffset, wire.byteLength);
272
+ if (BYTEA_TEXT.test(wire)) return new Uint8Array(Buffer.from(wire.slice(2), "hex"));
273
+ if (!wire.startsWith("\\x") && BYTEA_ESCAPE_TEXT.test(wire)) return byteaOfEscapeText(wire);
274
+ throw postgresError("RUNTIME.DECODE_FAILED", "pg/bytea@1 wire value must be a Uint8Array or bytea text, as PostgreSQL prints it under bytea_output 'hex' or 'escape'", { meta: {
275
+ codecId: "pg/bytea@1",
276
+ received: wire
277
+ } });
278
+ };
279
+ const parseJsonWire = JSON.parse;
280
+ const pgJsonEncode = (value) => JSON.stringify(value);
281
+ const pgJsonDecode = (wire) => typeof wire === "string" ? parseJsonWire(wire) : wire;
282
+ const pgJsonbEncode = (value) => JSON.stringify(value);
283
+ const pgJsonbDecode = (wire) => typeof wire === "string" ? parseJsonWire(wire) : wire;
15
284
  let fallback;
16
285
  /**
17
286
  * Sets the implementation `requireTemporal` returns when the runtime has no global `Temporal`.
@@ -30,22 +299,7 @@ function requireTemporal(meta) {
30
299
  throw "generatorId" in meta ? errorTemporalUnavailableForDefault(meta.generatorId) : errorTemporalUnavailable(meta.codecId, meta.operation);
31
300
  }
32
301
  const POSTGRES_TEMPORAL_SENTINELS = /* @__PURE__ */ new Set(["infinity", "-infinity"]);
33
- const EXPANDED_YEAR_DIGITS = 6;
34
- const ORDINARY_YEAR_DIGITS = 4;
35
- const BC_SUFFIX = " BC";
36
- function adaptPostgresEra(text) {
37
- const isBc = text.endsWith(BC_SUFFIX);
38
- const body = isBc ? text.slice(0, -3) : text;
39
- const yearEnd = body.indexOf("-");
40
- if (yearEnd <= 0) return text;
41
- const yearText = body.slice(0, yearEnd);
42
- if (!isBc && yearText.length <= ORDINARY_YEAR_DIGITS) return text;
43
- const year = Number(yearText);
44
- if (!Number.isInteger(year)) return text;
45
- const proleptic = isBc ? 1 - year : year;
46
- return `${proleptic < 0 ? "-" : "+"}${String(Math.abs(proleptic)).padStart(EXPANDED_YEAR_DIGITS, "0")}${body.slice(yearEnd)}`;
47
- }
48
- function decodeTemporalText(identity, wire, parse, adapt) {
302
+ function decodeTemporalText(identity, wire, parse) {
49
303
  const temporal = requireTemporal({
50
304
  codecId: identity.codecId,
51
305
  operation: "decode"
@@ -57,7 +311,7 @@ function decodeTemporalText(identity, wire, parse, adapt) {
57
311
  detail: `PostgreSQL's ${wire} is a sentinel with no position on the timeline, so no Temporal value denotes it`
58
312
  });
59
313
  try {
60
- return parse(temporal, adapt(wire));
314
+ return parse(temporal, isoYearText(wire));
61
315
  } catch (cause) {
62
316
  throw errorTemporalUnrepresentable({
63
317
  ...identity,
@@ -72,7 +326,7 @@ function encodeTemporalValue(identity, value) {
72
326
  const tag = typeof value === "object" && value !== null ? Reflect.get(value, Symbol.toStringTag) : void 0;
73
327
  if (tag !== identity.temporalTag) throw errorTemporalWrongType(identity.codecId, identity.temporalTag, identity.stringType, describeEncodeInput(value, tag));
74
328
  if (value.calendarId !== void 0 && value.calendarId !== "iso8601") throw errorTemporalNonIsoCalendar(identity.codecId, value.calendarId);
75
- return value.toString();
329
+ return postgresYearText(value.toString());
76
330
  }
77
331
  function describeEncodeInput(value, tag) {
78
332
  if (typeof tag === "string") return `a ${tag}`;
@@ -80,6 +334,11 @@ function describeEncodeInput(value, tag) {
80
334
  if (value === null) return "null";
81
335
  return `a ${typeof value}`;
82
336
  }
337
+ /** Refuses `infinity` and `-infinity` in a stored value, which no Temporal value or `Date` holds, naming the text codec of the type that does. */
338
+ function refuseInfinity(codecId, holds, textCodecId, text) {
339
+ if (!POSTGRES_TEMPORAL_SENTINELS.has(text)) return;
340
+ refuseJsonValue(codecId, `${holds}, not infinity or -infinity, which ${textCodecId} holds`, text);
341
+ }
83
342
  const DATE_TEMPORAL = {
84
343
  codecId: PG_DATE_TEMPORAL_CODEC_ID,
85
344
  stringType: "DateString",
@@ -100,27 +359,23 @@ const TIME_TEMPORAL = {
100
359
  stringType: "TimeString(p)",
101
360
  temporalTag: "Temporal.PlainTime"
102
361
  };
103
- const unadapted = (text) => text;
104
- const pgDateTemporalDecode = (wire) => decodeTemporalText(DATE_TEMPORAL, wire, (temporal, text) => temporal.PlainDate.from(text), adaptPostgresEra);
362
+ const pgDateTemporalDecode = (wire) => decodeTemporalText(DATE_TEMPORAL, wire, (temporal, text) => temporal.PlainDate.from(text));
105
363
  const pgDateTemporalEncode = (value) => encodeTemporalValue(DATE_TEMPORAL, value);
106
- const pgTimestampTemporalDecode = (wire) => decodeTemporalText(TIMESTAMP_TEMPORAL, wire, (temporal, text) => temporal.PlainDateTime.from(text), adaptPostgresEra);
364
+ const pgTimestampTemporalDecode = (wire) => decodeTemporalText(TIMESTAMP_TEMPORAL, wire, (temporal, text) => temporal.PlainDateTime.from(text));
107
365
  const pgTimestampTemporalEncode = (value) => encodeTemporalValue(TIMESTAMP_TEMPORAL, value);
108
- const pgTimestamptzTemporalDecode = (wire) => decodeTemporalText(TIMESTAMPTZ_TEMPORAL, wire, (temporal, text) => temporal.Instant.from(text), adaptPostgresEra);
366
+ const pgTimestamptzTemporalDecode = (wire) => decodeTemporalText(TIMESTAMPTZ_TEMPORAL, wire, (temporal, text) => temporal.Instant.from(text));
109
367
  const pgTimestamptzTemporalEncode = (value) => encodeTemporalValue(TIMESTAMPTZ_TEMPORAL, value);
110
- const pgTimeTemporalDecode = (wire) => decodeTemporalText(TIME_TEMPORAL, wire, (temporal, text) => temporal.PlainTime.from(text), unadapted);
368
+ const pgTimeTemporalDecode = (wire) => decodeTemporalText(TIME_TEMPORAL, wire, (temporal, text) => temporal.PlainTime.from(text));
111
369
  const pgTimeTemporalEncode = (value) => encodeTemporalValue(TIME_TEMPORAL, value);
112
370
  const EARLIEST_POSTGRES_TIMESTAMP_MILLISECONDS = (/* @__PURE__ */ new Date("-004713-11-24T00:00:00Z")).getTime();
113
371
  function utcText(value, codecId, zone) {
114
372
  const milliseconds = value.getTime();
115
373
  if (!Number.isFinite(milliseconds) || milliseconds < EARLIEST_POSTGRES_TIMESTAMP_MILLISECONDS) throw new RangeError(`${codecId} writes a Date as UTC text and needs a valid Date on or after 4714-11-24 BC, the earliest timestamp PostgreSQL holds; got ${String(value)}`);
116
- const year = value.getUTCFullYear();
117
374
  const iso = value.toISOString();
118
- const monthOnward = iso.slice(iso.indexOf("-", 1), -1);
119
- return `${String(year <= 0 ? 1 - year : year).padStart(ORDINARY_YEAR_DIGITS, "0")}${monthOnward}${zone}${year <= 0 ? BC_SUFFIX : ""}`;
375
+ return postgresYearText(zone === "Z" ? iso : iso.slice(0, -1));
120
376
  }
121
377
  const utcTimestampText = (value, codecId) => utcText(value, codecId, "");
122
378
  const utcTimestamptzText = (value, codecId) => utcText(value, codecId, "Z");
123
- const TIMESTAMPTZ_TEXT = /^([+-]\d{6}|\d{4,6})-(\d{2})-(\d{2})[ T](\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,6}))?(?:Z|([+-])(\d{2})(?::?(\d{2}))?(?::?(\d{2}))?)( BC)?$/;
124
379
  function invalidDate() {
125
380
  return /* @__PURE__ */ new RangeError(`${PG_TIMESTAMPTZ_DATE_CODEC_ID} requires a valid Date or a representable ISO PostgreSQL timestamp with time zone; use TimestamptzString for unsupported values`);
126
381
  }
@@ -132,47 +387,43 @@ function validateDate(value) {
132
387
  return value;
133
388
  }
134
389
  function decodeDate(wire) {
135
- const date = typeof wire === "string" ? parseDate(wire) : void 0;
136
- if (date === void 0) throw invalidDate();
390
+ const instant = typeof wire === "string" ? storedInstant(wire) : void 0;
391
+ const date = instant === void 0 ? void 0 : new Date(instant);
392
+ if (date === void 0 || !isRepresentable(date)) throw invalidDate();
137
393
  return date;
138
394
  }
139
- /** The instant a timestamp with time zone as PostgreSQL writes it names, or `undefined` when the text is not one. */
140
- function parseDate(text) {
141
- const match = TIMESTAMPTZ_TEXT.exec(text);
142
- if (!match) return void 0;
143
- const [, yearText = "", monthText, dayText, hourText, minuteText, secondText, fraction = "", sign, offsetHour = "0", offsetMinute = "0", offsetSecond = "0", era] = match;
144
- const year = era ? 1 - Number(yearText) : Number(yearText);
145
- const month = Number(monthText) - 1;
146
- const day = Number(dayText);
147
- const hour = Number(hourText);
148
- const minute = Number(minuteText);
149
- const second = Number(secondText);
150
- const milliseconds = Number(fraction.slice(0, 3).padEnd(3, "0"));
151
- const cycles = Math.floor((year - 2e3) / 400);
152
- const safeYear = year - cycles * 400;
153
- const local = /* @__PURE__ */ new Date(0);
154
- local.setUTCFullYear(safeYear, month, day);
155
- local.setUTCHours(hour, minute, second, milliseconds);
156
- if (era !== void 0 && (Number(yearText) === 0 || /^[+-]/.test(yearText)) || local.getUTCFullYear() !== safeYear || local.getUTCMonth() !== month || local.getUTCDate() !== day || local.getUTCHours() !== hour || local.getUTCMinutes() !== minute || local.getUTCSeconds() !== second || Number(offsetHour) > 15 || Number(offsetMinute) > 59 || Number(offsetSecond) > 59) return void 0;
157
- const offset = (Number(offsetHour) * 3600 + Number(offsetMinute) * 60 + Number(offsetSecond)) * (sign === "-" ? -1 : 1);
158
- const value = /* @__PURE__ */ new Date(local.getTime() - offset * 1e3 + cycles * 146097 * 864e5);
159
- return isRepresentable(value) ? value : void 0;
395
+ /** The instant, in its stored spelling, a stored timestamp with time zone names, or `undefined` for `infinity` and an instant outside the range a `Date` holds. */
396
+ function storedInstant(text) {
397
+ if (text === "infinity" || text === "-infinity") return void 0;
398
+ try {
399
+ return pgTimestamptzStoredText(text);
400
+ } catch (error) {
401
+ if (isStructuredError(error) && error.code === "CONTRACT.CAST_REFUSED") return void 0;
402
+ throw error;
403
+ }
404
+ }
405
+ /** The `Date` a stored timestamp with time zone names. A `Date` holds neither `infinity` nor an instant before 4714-11-24 BC or after +275760-09-13, so those are refused. */
406
+ function dateOfStoredText(codecId, text) {
407
+ const instant = storedInstant(text);
408
+ const date = instant === void 0 ? void 0 : new Date(instant);
409
+ if (date === void 0 || !isRepresentable(date)) return refuseJsonValue(codecId, `an instant a Date holds, from 4714-11-24 BC to +275760-09-13 and not infinity or -infinity, which ${PG_TIMESTAMPTZ_STRING_CODEC_ID} holds`, text);
410
+ return date;
160
411
  }
161
412
  function encodeDate(value) {
162
413
  return utcTimestamptzText(validateDate(value), PG_TIMESTAMPTZ_DATE_CODEC_ID);
163
414
  }
164
415
  var PgTimestamptzDateCodec = class extends CodecImpl {
165
- async encode(value, _ctx) {
416
+ async toWire(value, _ctx) {
166
417
  return encodeDate(value);
167
418
  }
168
- async decode(wire, _ctx) {
419
+ async fromWire(wire, _ctx) {
169
420
  return decodeDate(wire);
170
421
  }
171
- encodeJson(value) {
172
- return pgTimestamptzCanonical(validateDate(value).toISOString());
422
+ fromDataTypeValue(value) {
423
+ return dateOfStoredText(this.id, value.value);
173
424
  }
174
- decodeJson(json) {
175
- return parseDate(decodeJsonString("pg/timestamptz-date@1", json)) ?? refuseJsonValue("pg/timestamptz-date@1", "a timestamp with time zone as PostgreSQL writes it", json);
425
+ toDataTypeValue(input) {
426
+ return this.dataTypeValueOf(validateDate(input).toISOString());
176
427
  }
177
428
  };
178
429
  var PgTimestamptzDateDescriptor = class extends PostgresCodecDescriptor {
@@ -183,116 +434,40 @@ var PgTimestamptzDateDescriptor = class extends PostgresCodecDescriptor {
183
434
  codecId = PG_TIMESTAMPTZ_DATE_CODEC_ID;
184
435
  traits = ["equality", "order"];
185
436
  paramsSchema = pgPrecisionParams;
186
- factory(_params) {
187
- return () => new PgTimestamptzDateCodec(this);
437
+ factory(params) {
438
+ return () => new PgTimestamptzDateCodec(this, pgTimestamptz, params ?? {});
188
439
  }
189
440
  };
190
441
  const pgTimestamptzDateDescriptor = new PgTimestamptzDateDescriptor();
191
442
  const pgTimestamptzDateColumn = (params = {}) => column(pgTimestamptzDateDescriptor.factory(params), pgTimestamptzDateDescriptor.codecId, params);
192
- const YEAR = String.raw`(?:[+-]\d{6}|\d{4,7})`;
193
- const DATE = String.raw`${YEAR}-\d{2}-\d{2}`;
194
- const TIME = String.raw`\d{2}:\d{2}:\d{2}(?:\.\d{1,6})?`;
195
- const OFFSET = String.raw`(?:Z|[+-]\d{2}(?::\d{2}(?::\d{2})?)?)`;
196
- const INFINITY = "infinity|-infinity|";
197
- const BC = "(?: BC)?";
198
- const FORMS = {
199
- date: `${DATE}${BC}`,
200
- time: TIME,
201
- timeWithOffset: `${TIME}${OFFSET}`,
202
- dateTime: `${DATE}[ T]${TIME}${BC}`,
203
- instant: `${DATE}[ T]${TIME}${OFFSET}${BC}`
204
- };
205
- const DATED = /^([+-]?)(\d{4,7})(-.*?)( BC)?$/;
206
- const END_OF_DAY = /^24:00:00(?:\.0+)?(?![.\d])/;
207
- /** PostgreSQL's largest UTC offset, which it writes for no type past 15:59:59. */
208
- const MAX_OFFSET_HOURS = 15;
209
- function storedText(options) {
210
- return {
211
- dataType: options.dataType,
212
- shape: options.shape,
213
- pattern: new RegExp(`^(?:${options.infinity ? INFINITY : ""}${FORMS[options.shape]})$`),
214
- description: `${options.description} in ISO 8601 or as PostgreSQL writes it`,
215
- endOfDay: options.endOfDay
216
- };
217
- }
218
- const pgDateStoredText = storedText({
219
- dataType: pgDate.id,
220
- shape: "date",
221
- description: "a date",
222
- infinity: true,
223
- endOfDay: false
224
- });
225
- const pgTimeStoredText = storedText({
226
- dataType: pgTime.id,
227
- shape: "time",
228
- description: "a time of day",
229
- infinity: false,
230
- endOfDay: true
231
- });
232
- const pgTimetzStoredText = storedText({
233
- dataType: pgTimetz.id,
234
- shape: "timeWithOffset",
235
- description: "a time of day with a UTC offset",
236
- infinity: false,
237
- endOfDay: true
238
- });
239
- const pgTimestampStoredText = storedText({
240
- dataType: pgTimestamp.id,
241
- shape: "dateTime",
242
- description: "a date and time of day",
243
- infinity: true,
244
- endOfDay: false
245
- });
246
- const pgTimestamptzStoredText = storedText({
247
- dataType: pgTimestamptz.id,
248
- shape: "instant",
249
- description: "a date and time of day with a UTC offset",
250
- infinity: true,
251
- endOfDay: false
252
- });
253
- /** The text with its year moved into the 400-year cycle from 2000, or `undefined` for a year no calendar has. */
254
- function inGregorianCycle(text) {
255
- const match = DATED.exec(text);
256
- if (match === null) return text;
257
- const [, sign = "", digits = "", rest = "", bc] = match;
258
- const year = Number(digits);
259
- if (bc !== void 0 && (sign !== "" || year === 0) || sign === "-" && year === 0) return;
260
- return `${2e3 + ((bc !== void 0 ? 1 - year : sign === "-" ? -year : year) % 400 + 400) % 400}${rest}`;
443
+ function parsePostgresListText(wireValue) {
444
+ if (typeof wireValue !== "string") throw new TypeError(`expected raw text for a Postgres array, got ${typeof wireValue}`);
445
+ return blindCast(parse(wireValue));
261
446
  }
262
- function holdsValue(stored, text) {
263
- if (text === "infinity" || text === "-infinity") return true;
264
- const cycled = inGregorianCycle(text);
265
- if (cycled === void 0) return false;
266
- const read = stored.endOfDay ? cycled.replace(END_OF_DAY, "00:00:00") : cycled;
267
- try {
268
- canonicalDateTime(read, {
269
- shape: stored.shape,
270
- ownerId: stored.dataType,
271
- maxOffsetHours: MAX_OFFSET_HOURS
272
- });
273
- return true;
274
- } catch (error) {
275
- if (isStructuredError(error) && error.code === "CONTRACT.CAST_REFUSED") return false;
276
- throw error;
447
+ async function decodePostgresListText(wireValue, decodeElement) {
448
+ const decoded = [];
449
+ for (const element of parsePostgresListText(wireValue)) {
450
+ if (element === null) {
451
+ decoded.push(null);
452
+ continue;
453
+ }
454
+ decoded.push(await decodeElement(element));
277
455
  }
278
- }
279
- /** Reads a stored date or time text, refusing text in another form or naming no real date and time. */
280
- function decodeJsonDateTimeText(codecId, json, stored) {
281
- const text = decodeJsonMatching(codecId, json, stored.pattern, stored.description);
282
- return holdsValue(stored, text) ? text : refuseJsonValue(codecId, stored.description, json);
456
+ return decoded;
283
457
  }
284
458
  var PgDateTemporalCodec = class extends CodecImpl {
285
- async encode(value, _ctx) {
459
+ async toWire(value, _ctx) {
286
460
  return pgDateTemporalEncode(value);
287
461
  }
288
- async decode(wire, _ctx) {
462
+ async fromWire(wire, _ctx) {
289
463
  return pgDateTemporalDecode(wire);
290
464
  }
291
- encodeJson(value) {
292
- return pgDateCanonical(pgDateTemporalEncode(value));
465
+ fromDataTypeValue(value) {
466
+ refuseInfinity(this.id, "a date a Temporal.PlainDate holds", PG_DATE_STRING_CODEC_ID, value.value);
467
+ return pgDateTemporalDecode(value.value);
293
468
  }
294
- decodeJson(json) {
295
- return pgDateTemporalDecode(decodeJsonString(PG_DATE_TEMPORAL_CODEC_ID, json));
469
+ toDataTypeValue(input) {
470
+ return this.dataTypeValueOf(pgDateTemporalEncode(input));
296
471
  }
297
472
  };
298
473
  var PgDateTemporalDescriptor = class extends PostgresCodecDescriptor {
@@ -304,22 +479,23 @@ var PgDateTemporalDescriptor = class extends PostgresCodecDescriptor {
304
479
  traits = ["equality", "order"];
305
480
  paramsSchema = void 0;
306
481
  factory() {
307
- return () => new PgDateTemporalCodec(this);
482
+ return () => new PgDateTemporalCodec(this, pgDate);
308
483
  }
309
484
  };
310
485
  const pgDateTemporalDescriptor = new PgDateTemporalDescriptor();
311
486
  var PgTimestampTemporalCodec = class extends CodecImpl {
312
- async encode(value, _ctx) {
487
+ async toWire(value, _ctx) {
313
488
  return pgTimestampTemporalEncode(value);
314
489
  }
315
- async decode(wire, _ctx) {
490
+ async fromWire(wire, _ctx) {
316
491
  return pgTimestampTemporalDecode(wire);
317
492
  }
318
- encodeJson(value) {
319
- return pgTimestampCanonical(pgTimestampTemporalEncode(value));
493
+ fromDataTypeValue(value) {
494
+ refuseInfinity(this.id, "a date and time a Temporal.PlainDateTime holds", PG_TIMESTAMP_STRING_CODEC_ID, value.value);
495
+ return pgTimestampTemporalDecode(value.value);
320
496
  }
321
- decodeJson(json) {
322
- return pgTimestampTemporalDecode(decodeJsonString(PG_TIMESTAMP_TEMPORAL_CODEC_ID, json));
497
+ toDataTypeValue(input) {
498
+ return this.dataTypeValueOf(pgTimestampTemporalEncode(input));
323
499
  }
324
500
  };
325
501
  var PgTimestampTemporalDescriptor = class extends PostgresCodecDescriptor {
@@ -330,23 +506,24 @@ var PgTimestampTemporalDescriptor = class extends PostgresCodecDescriptor {
330
506
  codecId = PG_TIMESTAMP_TEMPORAL_CODEC_ID;
331
507
  traits = ["equality", "order"];
332
508
  paramsSchema = pgPrecisionParams;
333
- factory(_params) {
334
- return () => new PgTimestampTemporalCodec(this);
509
+ factory(params) {
510
+ return () => new PgTimestampTemporalCodec(this, pgTimestamp, params ?? {});
335
511
  }
336
512
  };
337
513
  const pgTimestampTemporalDescriptor = new PgTimestampTemporalDescriptor();
338
514
  var PgTimestamptzTemporalCodec = class extends CodecImpl {
339
- async encode(value, _ctx) {
515
+ async toWire(value, _ctx) {
340
516
  return pgTimestamptzTemporalEncode(value);
341
517
  }
342
- async decode(wire, _ctx) {
518
+ async fromWire(wire, _ctx) {
343
519
  return pgTimestamptzTemporalDecode(wire);
344
520
  }
345
- encodeJson(value) {
346
- return pgTimestamptzCanonical(pgTimestamptzTemporalEncode(value));
521
+ fromDataTypeValue(value) {
522
+ refuseInfinity(this.id, "an instant a Temporal.Instant holds", PG_TIMESTAMPTZ_STRING_CODEC_ID, value.value);
523
+ return pgTimestamptzTemporalDecode(value.value);
347
524
  }
348
- decodeJson(json) {
349
- return pgTimestamptzTemporalDecode(decodeJsonString(PG_TIMESTAMPTZ_TEMPORAL_CODEC_ID, json));
525
+ toDataTypeValue(input) {
526
+ return this.dataTypeValueOf(pgTimestamptzTemporalEncode(input));
350
527
  }
351
528
  };
352
529
  var PgTimestamptzTemporalDescriptor = class extends PostgresCodecDescriptor {
@@ -357,23 +534,23 @@ var PgTimestamptzTemporalDescriptor = class extends PostgresCodecDescriptor {
357
534
  codecId = PG_TIMESTAMPTZ_TEMPORAL_CODEC_ID;
358
535
  traits = ["equality", "order"];
359
536
  paramsSchema = pgPrecisionParams;
360
- factory(_params) {
361
- return () => new PgTimestamptzTemporalCodec(this);
537
+ factory(params) {
538
+ return () => new PgTimestamptzTemporalCodec(this, pgTimestamptz, params ?? {});
362
539
  }
363
540
  };
364
541
  const pgTimestamptzTemporalDescriptor = new PgTimestamptzTemporalDescriptor();
365
542
  var PgTimeTemporalCodec = class extends CodecImpl {
366
- async encode(value, _ctx) {
543
+ async toWire(value, _ctx) {
367
544
  return pgTimeTemporalEncode(value);
368
545
  }
369
- async decode(wire, _ctx) {
546
+ async fromWire(wire, _ctx) {
370
547
  return pgTimeTemporalDecode(wire);
371
548
  }
372
- encodeJson(value) {
373
- return pgTimeCanonical(pgTimeTemporalEncode(value));
549
+ fromDataTypeValue(value) {
550
+ return pgTimeTemporalDecode(value.value);
374
551
  }
375
- decodeJson(json) {
376
- return pgTimeTemporalDecode(decodeJsonString(PG_TIME_TEMPORAL_CODEC_ID, json));
552
+ toDataTypeValue(input) {
553
+ return this.dataTypeValueOf(pgTimeTemporalEncode(input));
377
554
  }
378
555
  };
379
556
  var PgTimeTemporalDescriptor = class extends PostgresCodecDescriptor {
@@ -384,23 +561,23 @@ var PgTimeTemporalDescriptor = class extends PostgresCodecDescriptor {
384
561
  codecId = PG_TIME_TEMPORAL_CODEC_ID;
385
562
  traits = ["equality", "order"];
386
563
  paramsSchema = pgPrecisionParams;
387
- factory(_params) {
388
- return () => new PgTimeTemporalCodec(this);
564
+ factory(params) {
565
+ return () => new PgTimeTemporalCodec(this, pgTime, params ?? {});
389
566
  }
390
567
  };
391
568
  const pgTimeTemporalDescriptor = new PgTimeTemporalDescriptor();
392
569
  var PgDateStringCodec = class extends CodecImpl {
393
- async encode(value, _ctx) {
394
- return value;
570
+ async toWire(value, _ctx) {
571
+ return postgresYearText(value);
395
572
  }
396
- async decode(wire, _ctx) {
573
+ async fromWire(wire, _ctx) {
397
574
  return wire;
398
575
  }
399
- encodeJson(value) {
400
- return pgDateCanonical(value);
576
+ fromDataTypeValue(value) {
577
+ return value.value;
401
578
  }
402
- decodeJson(json) {
403
- return decodeJsonDateTimeText(PG_DATE_STRING_CODEC_ID, json, pgDateStoredText);
579
+ toDataTypeValue(input) {
580
+ return this.dataTypeValueOf(input);
404
581
  }
405
582
  };
406
583
  var PgDateStringDescriptor = class extends PostgresCodecDescriptor {
@@ -412,22 +589,22 @@ var PgDateStringDescriptor = class extends PostgresCodecDescriptor {
412
589
  traits = ["equality", "order"];
413
590
  paramsSchema = void 0;
414
591
  factory() {
415
- return () => new PgDateStringCodec(this);
592
+ return () => new PgDateStringCodec(this, pgDate);
416
593
  }
417
594
  };
418
595
  const pgDateStringDescriptor = new PgDateStringDescriptor();
419
596
  var PgTimestampStringCodec = class extends CodecImpl {
420
- async encode(value, _ctx) {
421
- return value instanceof Date ? utcTimestampText(value, this.id) : value;
597
+ async toWire(value, _ctx) {
598
+ return value instanceof Date ? utcTimestampText(value, this.id) : postgresYearText(value);
422
599
  }
423
- async decode(wire, _ctx) {
600
+ async fromWire(wire, _ctx) {
424
601
  return wire;
425
602
  }
426
- encodeJson(value) {
427
- return pgTimestampCanonical(value);
603
+ fromDataTypeValue(value) {
604
+ return value.value;
428
605
  }
429
- decodeJson(json) {
430
- return decodeJsonDateTimeText(PG_TIMESTAMP_STRING_CODEC_ID, json, pgTimestampStoredText);
606
+ toDataTypeValue(input) {
607
+ return this.dataTypeValueOf(input);
431
608
  }
432
609
  };
433
610
  /** Why an enum cannot use a string timestamp codec, given how PostgreSQL prints a value and how the contract stores it. */
@@ -441,23 +618,23 @@ var PgTimestampStringDescriptor = class extends PostgresCodecDescriptor {
441
618
  traits = ["equality", "order"];
442
619
  enumRefusal = stringTimestampEnumRefusal("2024-01-02 03:04:05", "2024-01-02T03:04:05", "", "pg/timestamp-temporal@1");
443
620
  paramsSchema = pgPrecisionParams;
444
- factory(_params) {
445
- return () => new PgTimestampStringCodec(this);
621
+ factory(params) {
622
+ return () => new PgTimestampStringCodec(this, pgTimestamp, params ?? {});
446
623
  }
447
624
  };
448
625
  const pgTimestampStringDescriptor = new PgTimestampStringDescriptor();
449
626
  var PgTimestamptzStringCodec = class extends CodecImpl {
450
- async encode(value, _ctx) {
451
- return value instanceof Date ? utcTimestamptzText(value, this.id) : value;
627
+ async toWire(value, _ctx) {
628
+ return value instanceof Date ? utcTimestamptzText(value, this.id) : postgresYearText(value);
452
629
  }
453
- async decode(wire, _ctx) {
630
+ async fromWire(wire, _ctx) {
454
631
  return wire;
455
632
  }
456
- encodeJson(value) {
457
- return pgTimestamptzCanonical(value);
633
+ fromDataTypeValue(value) {
634
+ return value.value;
458
635
  }
459
- decodeJson(json) {
460
- return decodeJsonDateTimeText(PG_TIMESTAMPTZ_STRING_CODEC_ID, json, pgTimestamptzStoredText);
636
+ toDataTypeValue(input) {
637
+ return this.dataTypeValueOf(input);
461
638
  }
462
639
  };
463
640
  var PgTimestamptzStringDescriptor = class extends PostgresCodecDescriptor {
@@ -469,23 +646,23 @@ var PgTimestamptzStringDescriptor = class extends PostgresCodecDescriptor {
469
646
  traits = ["equality", "order"];
470
647
  enumRefusal = stringTimestampEnumRefusal("2024-01-02 03:04:05+00", "2024-01-02T03:04:05Z", " in the session's time zone", "pg/timestamptz-temporal@1");
471
648
  paramsSchema = pgPrecisionParams;
472
- factory(_params) {
473
- return () => new PgTimestamptzStringCodec(this);
649
+ factory(params) {
650
+ return () => new PgTimestamptzStringCodec(this, pgTimestamptz, params ?? {});
474
651
  }
475
652
  };
476
653
  const pgTimestamptzStringDescriptor = new PgTimestamptzStringDescriptor();
477
654
  var PgTimeStringCodec = class extends CodecImpl {
478
- async encode(value, _ctx) {
655
+ async toWire(value, _ctx) {
479
656
  return value;
480
657
  }
481
- async decode(wire, _ctx) {
658
+ async fromWire(wire, _ctx) {
482
659
  return wire;
483
660
  }
484
- encodeJson(value) {
485
- return pgTimeCanonical(value);
661
+ fromDataTypeValue(value) {
662
+ return value.value;
486
663
  }
487
- decodeJson(json) {
488
- return decodeJsonDateTimeText(PG_TIME_STRING_CODEC_ID, json, pgTimeStoredText);
664
+ toDataTypeValue(input) {
665
+ return this.dataTypeValueOf(input);
489
666
  }
490
667
  };
491
668
  var PgTimeStringDescriptor = class extends PostgresCodecDescriptor {
@@ -496,41 +673,21 @@ var PgTimeStringDescriptor = class extends PostgresCodecDescriptor {
496
673
  codecId = PG_TIME_STRING_CODEC_ID;
497
674
  traits = ["equality", "order"];
498
675
  paramsSchema = pgPrecisionParams;
499
- factory(_params) {
500
- return () => new PgTimeStringCodec(this);
676
+ factory(params) {
677
+ return () => new PgTimeStringCodec(this, pgTime, params ?? {});
501
678
  }
502
679
  };
503
680
  const pgTimeStringDescriptor = new PgTimeStringDescriptor();
504
681
  /** A decimal numeral: an optional minus sign, digits, and an optional fraction. */
505
682
  const DECIMAL_NUMERAL_TEXT = /^-?\d+(?:\.\d+)?$/;
506
- /**
507
- * Numeric text in the form PostgreSQL *prints*, which is narrower than the form it accepts.
508
- *
509
- * `numeric` reads `+123`, `.5`, `1.`, `1e5`, `0x1f`, `1_000`, `007`, `-0` and whitespace-padded
510
- * input, but prints every one of them in a single normalised form — `123`, `0.5`, `1`, `100000`,
511
- * `31`, `1000`, `7`, `0`. The projection reads the column back through that printing, so a value in
512
- * any other form is one the database never returns: `1e5` reads back as `100000`.
513
- *
514
- * `NaN`, `Infinity` and `-Infinity` are genuine `numeric` values, not error
515
- * states, and PostgreSQL emits them into JSON as strings — so they belong to the
516
- * canonical form and round-trip like any other value.
517
- */
518
- const CANONICAL_NUMERIC_TEXT = /^(?:(?!-0(?:\.0+)?$)-?(?:0|[1-9]\d*)(?:\.\d+)?|NaN|-?Infinity)$/;
519
- /**
520
- * Whether canonical numeric text is a value `numeric(precision, scale)` stores without rounding: a whole number of units of 10^-scale, and at most `precision` digits once counted in those units. A negative scale rounds to tens, hundreds and so on, and a scale above the precision allows only values below 1. NaN fits; an infinity does not.
521
- */
522
- function fitsNumeric(text, precision, scale) {
523
- if (text === "NaN") return true;
524
- if (text.endsWith("Infinity")) return false;
525
- const [whole = "", fraction = ""] = text.replace(/^-/, "").split(".");
526
- const significantFraction = withoutTrailing(fraction, "0");
527
- const digits = `${whole}${significantFraction}`.replace(/^0+/, "");
528
- if (digits === "") return true;
529
- const shift = scale - significantFraction.length;
530
- if (shift >= 0) return digits.length + shift <= precision;
531
- const units = withoutTrailing(digits, "0");
532
- if (digits.length - units.length < -shift) return false;
533
- return digits.length + shift <= precision;
683
+ /** A decimal numeral is written as PostgreSQL prints it, without leading zeros or a minus sign on zero; other spellings PostgreSQL reads, such as `1e5`, are refused. */
684
+ function numericJson(value) {
685
+ if (typeof value !== "string" || isNonFiniteText(value)) return value;
686
+ if (DECIMAL_NUMERAL_TEXT.test(value)) return storedNumeralText(value);
687
+ throw postgresError("RUNTIME.ENCODE_FAILED", "pg/numeric@1 application value must be numeric text: an optionally negated decimal numeral, or NaN, Infinity or -Infinity", { meta: {
688
+ codecId: PG_NUMERIC_CODEC_ID,
689
+ received: value
690
+ } });
534
691
  }
535
692
  /**
536
693
  * Projects the expression unchanged, for codecs whose canonical JSON is what
@@ -546,7 +703,6 @@ const identityJsonProjection = (expression) => expression;
546
703
  * Projects a `character` value as text, which drops the trailing spaces that pad it to its length and nothing else, so an include reads the value a flat read's `decode` returns.
547
704
  */
548
705
  const unpaddedCharJsonProjection = (expression) => CastExpr.as(expression, "text");
549
- const BIT_STRING = /^[01]*$/;
550
706
  const decodePostgresNumberWire = (wire) => typeof wire === "string" ? Number(wire) : wire;
551
707
  const decodePostgresBooleanWire = (wire) => {
552
708
  if (typeof wire === "boolean") return wire;
@@ -570,108 +726,50 @@ const decodePostgresBooleanWire = (wire) => {
570
726
  */
571
727
  const decimalTextJsonProjection = (expression) => CastExpr.as(expression, "text");
572
728
  /**
573
- * Projects a `bytea` as base64 text.
574
- *
575
- * Like the decimal-text cast, the encoding is part of the projected expression:
576
- * PostgreSQL's own JSON conversion of a `bytea` emits its `\x`-prefixed hex
577
- * output form, so the base64 encoding has to replace that conversion rather
578
- * than post-process it.
579
- *
580
- * `encode` emits RFC 2045 base64, which carries a line break every 76
581
- * characters — so any value over 56 bytes arrives wrapped. The breaks are
582
- * removed here, because the canonical form is unwrapped base64 and
583
- * `decodeJson` rejects anything else. `chr(10)` rather than a newline literal
584
- * keeps the rendered SQL on one line.
585
- */
586
- const base64JsonProjection = (expression) => FunctionCallExpr.of("translate", [
587
- FunctionCallExpr.of("encode", [expression, LiteralExpr.of("base64")]),
588
- FunctionCallExpr.of("chr", [LiteralExpr.of(10)]),
589
- LiteralExpr.of("")
590
- ]);
591
- const datePart = (field, expression) => FunctionCallExpr.of("date_part", [LiteralExpr.of(field), expression]);
592
- const whenNonZero = (value, rendered) => CaseExpr.of([{
593
- condition: BinaryExpr.neq(value, LiteralExpr.of(0)),
594
- value: rendered
595
- }], LiteralExpr.of(null));
596
- /**
597
- * Projects an `interval` as an ISO-8601 duration.
598
- *
599
- * An interval carries months, days and microseconds independently — `P1M` and
600
- * `P30D` are different intervals — so the projection reads each field with
601
- * `date_part` and assembles them rather than reducing the value to an epoch,
602
- * which would have to choose a length for a month. `IntervalStyle` decides how
603
- * PostgreSQL spells an interval and cannot be bound per expression, so the
604
- * spelling is constructed here instead of inherited.
605
- *
606
- * `concat` drops NULL arguments, so a zero component is omitted by rendering as
607
- * NULL; the seconds field is taken through `numeric` because a `double
608
- * precision` microsecond renders in scientific notation.
609
- *
610
- * That same NULL-dropping is why the whole assembly sits under an explicit NULL
611
- * check: for a NULL interval every field is NULL, `concat` yields `'P'`, and the
612
- * zero-duration fallback below would report an absent value as a zero one.
729
+ * Projects the text PostgreSQL prints for the value, which is the value the runtime driver returns
730
+ * for an ordinary row, so `fromWire` reads an included value as it reads a row (ADR 254, "Rows the
731
+ * database returns as JSON"). PostgreSQL's own JSON conversion would write another value: a `bytea`
732
+ * as its hex text but a `jsonb` document as the document itself, which `fromWire` cannot tell from
733
+ * the document's JSON text when the document is a string.
613
734
  */
614
- const isoDurationJsonProjection = (expression) => {
615
- const field = (name) => datePart(name, expression);
616
- const seconds = CastExpr.as(field("second"), "numeric");
617
- const assembled = FunctionCallExpr.of("concat", [
618
- LiteralExpr.of("P"),
619
- whenNonZero(field("year"), FunctionCallExpr.of("concat", [field("year"), LiteralExpr.of("Y")])),
620
- whenNonZero(field("month"), FunctionCallExpr.of("concat", [field("month"), LiteralExpr.of("M")])),
621
- whenNonZero(field("day"), FunctionCallExpr.of("concat", [field("day"), LiteralExpr.of("D")])),
622
- CaseExpr.of([{
623
- condition: OrExpr.of([
624
- BinaryExpr.neq(field("hour"), LiteralExpr.of(0)),
625
- BinaryExpr.neq(field("minute"), LiteralExpr.of(0)),
626
- BinaryExpr.neq(field("second"), LiteralExpr.of(0))
627
- ]),
628
- value: LiteralExpr.of("T")
629
- }], LiteralExpr.of(null)),
630
- whenNonZero(field("hour"), FunctionCallExpr.of("concat", [field("hour"), LiteralExpr.of("H")])),
631
- whenNonZero(field("minute"), FunctionCallExpr.of("concat", [field("minute"), LiteralExpr.of("M")])),
632
- whenNonZero(field("second"), FunctionCallExpr.of("concat", [seconds, LiteralExpr.of("S")]))
633
- ]);
634
- return CaseExpr.of([{
635
- condition: NullCheckExpr.isNull(expression),
636
- value: LiteralExpr.of(null)
637
- }], FunctionCallExpr.of("coalesce", [FunctionCallExpr.of("nullif", [assembled, LiteralExpr.of("P")]), LiteralExpr.of("PT0S")]));
638
- };
735
+ const printedTextJsonProjection = (expression) => CastExpr.as(expression, "text");
639
736
  const postgresSqlCharDescriptor = postgresCodec(sqlCharDescriptor, {
640
737
  dataType: pgChar,
641
738
  jsonProjection: unpaddedCharJsonProjection,
642
- factory: (descriptor, params) => () => new PgCharCodec(descriptor, params.length)
739
+ factory: (descriptor, dataType, params) => () => new SqlCharCodec(descriptor, dataType, params)
643
740
  });
644
741
  const postgresSqlVarcharDescriptor = postgresCodec(sqlVarcharDescriptor, {
645
742
  dataType: pgVarchar,
646
743
  jsonProjection: identityJsonProjection,
647
- factory: (descriptor, params) => () => new PgVarcharCodec(descriptor, params.length)
744
+ factory: (descriptor, dataType, params) => () => new SqlVarcharCodec(descriptor, dataType, params)
648
745
  });
649
746
  const postgresSqlIntDescriptor = postgresCodec(sqlIntDescriptor, {
650
747
  dataType: pgInt4,
651
748
  jsonProjection: identityJsonProjection,
652
- factory: (descriptor) => () => new PgIntCodec(descriptor)
749
+ factory: (descriptor, dataType) => () => new PgIntCodec(descriptor, dataType)
653
750
  });
654
751
  const postgresSqlFloatDescriptor = postgresCodec(sqlFloatDescriptor, {
655
752
  dataType: pgFloat8,
656
753
  jsonProjection: identityJsonProjection,
657
- factory: (descriptor) => () => new PgFloatCodec(descriptor)
754
+ factory: (descriptor, dataType) => () => new PgFloatCodec(descriptor, dataType)
658
755
  });
659
756
  const postgresSqlTextDescriptor = postgresCodec(sqlTextDescriptor, {
660
757
  dataType: pgText,
661
- jsonProjection: identityJsonProjection
758
+ jsonProjection: identityJsonProjection,
759
+ factory: (descriptor, dataType) => () => new SqlTextCodec(descriptor, dataType)
662
760
  });
663
761
  var PgTextCodec = class extends CodecImpl {
664
- async encode(value, _ctx) {
762
+ async toWire(value, _ctx) {
665
763
  return value;
666
764
  }
667
- async decode(wire, _ctx) {
765
+ async fromWire(wire, _ctx) {
668
766
  return wire;
669
767
  }
670
- encodeJson(value) {
671
- return value;
768
+ fromDataTypeValue(value) {
769
+ return value.value;
672
770
  }
673
- decodeJson(json) {
674
- return decodeJsonString(PG_TEXT_CODEC_ID, json);
771
+ toDataTypeValue(input) {
772
+ return this.dataTypeValueOf(input);
675
773
  }
676
774
  };
677
775
  var PgTextDescriptor = class extends PostgresCodecDescriptor {
@@ -690,7 +788,7 @@ var PgTextDescriptor = class extends PostgresCodecDescriptor {
690
788
  return renderTsLiteral(value);
691
789
  }
692
790
  factory() {
693
- return () => new PgTextCodec(this);
791
+ return () => new PgTextCodec(this, pgText);
694
792
  }
695
793
  };
696
794
  const pgTextDescriptor = new PgTextDescriptor();
@@ -715,17 +813,17 @@ const pgTextColumn = () => column(pgTextDescriptor.factory(), pgTextDescriptor.c
715
813
  * `ILIKE` or `to_tsvector` over an enum type.
716
814
  */
717
815
  var PgEnumCodec = class extends CodecImpl {
718
- async encode(value, _ctx) {
816
+ async toWire(value, _ctx) {
719
817
  return value;
720
818
  }
721
- async decode(wire, _ctx) {
819
+ async fromWire(wire, _ctx) {
722
820
  return wire;
723
821
  }
724
- encodeJson(value) {
725
- return value;
822
+ fromDataTypeValue(value) {
823
+ return value.value;
726
824
  }
727
- decodeJson(json) {
728
- return decodeJsonString(PG_ENUM_CODEC_ID, json);
825
+ toDataTypeValue(input) {
826
+ return this.dataTypeValueOf(input);
729
827
  }
730
828
  };
731
829
  /**
@@ -746,8 +844,8 @@ var PgEnumDescriptor = class extends PostgresCodecDescriptor {
746
844
  renderValueLiteral(value) {
747
845
  return renderTsLiteral(value);
748
846
  }
749
- factory(_params) {
750
- return () => new PgEnumCodec(this);
847
+ factory(params) {
848
+ return () => new PgEnumCodec(this, pgEnum, params);
751
849
  }
752
850
  /**
753
851
  * Authoring-time hook a `pg.enum(<ref>)` type constructor calls once it has
@@ -802,61 +900,63 @@ function postgresQualifyColumnType(input, namespaceId) {
802
900
  typeName: qualified
803
901
  } };
804
902
  }
903
+ /** The elements of the `text[]` text PostgreSQL prints, each a string or NULL. */
904
+ function readTextArrayWire(wire) {
905
+ return parsePostgresListText(wire).map((element) => {
906
+ if (element === null || typeof element === "string") return element;
907
+ throw postgresError("RUNTIME.DECODE_FAILED", `pg/text-array@1 reads a one-dimensional text[], and ${wire} has more dimensions`, { meta: {
908
+ codecId: PG_TEXT_ARRAY_CODEC_ID,
909
+ received: wire
910
+ } });
911
+ });
912
+ }
805
913
  /**
806
914
  * Postgres `text[]` control codec. Encode is an identity pass-through: the pg
807
915
  * wire driver serialises a JS `string[]` to a Postgres array literal under the
808
- * `$N::text[]` cast emitted from this codec's native type. Control-plane reads
809
- * that need semantic arrays parse raw array text before shared validation rather
810
- * than decoding this whole array value. Not a user-facing scalar — it is not
811
- * part of the authorable `CodecTypes` surface, only the runtime codec registry.
916
+ * `$N::text[]` cast emitted from this codec's native type. Decode reads the
917
+ * array text the driver returns, or an array a driver has already parsed. Not a
918
+ * user-facing scalar — it is not part of the authorable `CodecTypes` surface,
919
+ * only the runtime codec registry.
812
920
  */
813
921
  var PgTextArrayCodec = class extends CodecImpl {
814
- async encode(value, _ctx) {
922
+ async toWire(value, _ctx) {
815
923
  return value;
816
924
  }
817
- async decode(wire, _ctx) {
818
- return wire;
925
+ async fromWire(wire, _ctx) {
926
+ return typeof wire === "string" ? readTextArrayWire(wire) : wire;
819
927
  }
820
- encodeJson(value) {
821
- return [...value];
822
- }
823
- /** A `text[]` may hold NULL elements, which PostgreSQL writes as JSON `null`. */
824
- decodeJson(json) {
825
- const expected = "an array of strings and nulls";
826
- if (!Array.isArray(json)) return refuseJsonValue(PG_TEXT_ARRAY_CODEC_ID, expected, json);
827
- const elements = [];
828
- for (const entry of json) {
829
- if (entry !== null && typeof entry !== "string") return refuseJsonValue(PG_TEXT_ARRAY_CODEC_ID, expected, entry);
830
- elements.push(entry);
831
- }
832
- return elements;
928
+ fromDataTypeValue(value) {
929
+ return value.value;
930
+ }
931
+ toDataTypeValue(input) {
932
+ return this.dataTypeValueOf([...input]);
833
933
  }
834
934
  };
835
935
  var PgTextArrayDescriptor = class extends PostgresCodecDescriptor {
836
936
  jsonProjection(expression) {
837
- return expression;
937
+ return printedTextJsonProjection(expression);
838
938
  }
839
939
  dataType = pgTextArray.id;
840
940
  codecId = PG_TEXT_ARRAY_CODEC_ID;
841
941
  traits = ["equality"];
842
942
  paramsSchema = void 0;
843
943
  factory() {
844
- return () => new PgTextArrayCodec(this);
944
+ return () => new PgTextArrayCodec(this, pgTextArray);
845
945
  }
846
946
  };
847
947
  const pgTextArrayDescriptor = new PgTextArrayDescriptor();
848
948
  var PgInt4Codec = class extends CodecImpl {
849
- async encode(value, _ctx) {
949
+ async toWire(value, _ctx) {
850
950
  return value;
851
951
  }
852
- async decode(wire, _ctx) {
952
+ async fromWire(wire, _ctx) {
853
953
  return decodePostgresNumberWire(wire);
854
954
  }
855
- encodeJson(value) {
856
- return value;
955
+ fromDataTypeValue(value) {
956
+ return value.value;
857
957
  }
858
- decodeJson(json) {
859
- return decodeJsonInteger(PG_INT4_CODEC_ID, json, INT32_RANGE);
958
+ toDataTypeValue(input) {
959
+ return this.dataTypeValueOf(input);
860
960
  }
861
961
  };
862
962
  var PgInt4Descriptor = class extends PostgresCodecDescriptor {
@@ -875,26 +975,23 @@ var PgInt4Descriptor = class extends PostgresCodecDescriptor {
875
975
  return renderTsLiteral(value);
876
976
  }
877
977
  factory() {
878
- return () => new PgInt4Codec(this);
978
+ return () => new PgInt4Codec(this, pgInt4);
879
979
  }
880
980
  };
881
981
  const pgInt4Descriptor = new PgInt4Descriptor();
882
982
  const pgInt4Column = () => column(pgInt4Descriptor.factory(), pgInt4Descriptor.codecId, void 0);
883
983
  var PgInt2Codec = class extends CodecImpl {
884
- async encode(value, _ctx) {
984
+ async toWire(value, _ctx) {
885
985
  return value;
886
986
  }
887
- async decode(wire, _ctx) {
987
+ async fromWire(wire, _ctx) {
888
988
  return decodePostgresNumberWire(wire);
889
989
  }
890
- encodeJson(value) {
891
- return value;
990
+ fromDataTypeValue(value) {
991
+ return value.value;
892
992
  }
893
- decodeJson(json) {
894
- return decodeJsonInteger(PG_INT2_CODEC_ID, json, {
895
- min: -32768,
896
- max: 32767
897
- });
993
+ toDataTypeValue(input) {
994
+ return this.dataTypeValueOf(input);
898
995
  }
899
996
  };
900
997
  var PgInt2Descriptor = class extends PostgresCodecDescriptor {
@@ -913,7 +1010,7 @@ var PgInt2Descriptor = class extends PostgresCodecDescriptor {
913
1010
  return renderTsLiteral(value);
914
1011
  }
915
1012
  factory() {
916
- return () => new PgInt2Codec(this);
1013
+ return () => new PgInt2Codec(this, pgInt2);
917
1014
  }
918
1015
  };
919
1016
  const pgInt2Descriptor = new PgInt2Descriptor();
@@ -925,17 +1022,17 @@ const pgInt2Column = () => column(pgInt2Descriptor.factory(), pgInt2Descriptor.c
925
1022
  * this type.
926
1023
  */
927
1024
  var PgInt8Codec = class extends CodecImpl {
928
- async encode(value, _ctx) {
1025
+ async toWire(value, _ctx) {
929
1026
  return pgBigintEncode(PG_INT8_CODEC_ID, value);
930
1027
  }
931
- async decode(wire, _ctx) {
1028
+ async fromWire(wire, _ctx) {
932
1029
  return pgInt8Decode(wire);
933
1030
  }
934
- encodeJson(value) {
935
- return pgBigintEncodeJson(PG_INT8_CODEC_ID, value);
1031
+ fromDataTypeValue(value) {
1032
+ return BigInt(value.value);
936
1033
  }
937
- decodeJson(json) {
938
- return decodeJsonIntegerText(PG_INT8_CODEC_ID, json, INT64_RANGE);
1034
+ toDataTypeValue(input) {
1035
+ return this.dataTypeValueOf(pgBigintDigits(PG_INT8_CODEC_ID, input));
939
1036
  }
940
1037
  };
941
1038
  var PgInt8Descriptor = class extends PostgresCodecDescriptor {
@@ -954,7 +1051,7 @@ var PgInt8Descriptor = class extends PostgresCodecDescriptor {
954
1051
  return decimalTextBigintLiteral(value);
955
1052
  }
956
1053
  factory() {
957
- return () => new PgInt8Codec(this);
1054
+ return () => new PgInt8Codec(this, pgInt8);
958
1055
  }
959
1056
  };
960
1057
  const pgInt8Descriptor = new PgInt8Descriptor();
@@ -968,17 +1065,17 @@ const pgInt8Column = () => column(pgInt8Descriptor.factory(), pgInt8Descriptor.c
968
1065
  * claims no target type, so `int8` in type position stays `pg/int8@1`.
969
1066
  */
970
1067
  var PgInt8NumberCodec = class extends CodecImpl {
971
- async encode(value, _ctx) {
1068
+ async toWire(value, _ctx) {
972
1069
  return pgInt8NumberEncode(value);
973
1070
  }
974
- async decode(wire, _ctx) {
1071
+ async fromWire(wire, _ctx) {
975
1072
  return pgInt8NumberDecode(wire);
976
1073
  }
977
- encodeJson(value) {
978
- return pgInt8NumberEncodeJson(value);
1074
+ fromDataTypeValue(value) {
1075
+ return pgInt8NumberFromDigits(value.value);
979
1076
  }
980
- decodeJson(json) {
981
- return pgInt8NumberDecodeJson(json);
1077
+ toDataTypeValue(input) {
1078
+ return this.dataTypeValueOf(pgInt8NumberEncode(input));
982
1079
  }
983
1080
  };
984
1081
  var PgInt8NumberDescriptor = class extends PostgresCodecDescriptor {
@@ -997,25 +1094,23 @@ var PgInt8NumberDescriptor = class extends PostgresCodecDescriptor {
997
1094
  return decimalTextNumberLiteral(value);
998
1095
  }
999
1096
  factory() {
1000
- return () => new PgInt8NumberCodec(this);
1097
+ return () => new PgInt8NumberCodec(this, pgInt8);
1001
1098
  }
1002
1099
  };
1003
1100
  const pgInt8NumberDescriptor = new PgInt8NumberDescriptor();
1004
1101
  const pgInt8NumberColumn = () => column(pgInt8NumberDescriptor.factory(), pgInt8NumberDescriptor.codecId, void 0);
1005
1102
  var PgFloat4Codec = class extends CodecImpl {
1006
- async encode(value, _ctx) {
1103
+ async toWire(value, _ctx) {
1007
1104
  return pgFloatEncode(value);
1008
1105
  }
1009
- async decode(wire, _ctx) {
1106
+ async fromWire(wire, _ctx) {
1010
1107
  return decodePostgresNumberWire(wire);
1011
1108
  }
1012
- encodeJson(value) {
1013
- return encodeJsonFloat(value);
1109
+ fromDataTypeValue(value) {
1110
+ return readJsonFloat(this.id, value.value);
1014
1111
  }
1015
- decodeJson(json) {
1016
- const value = decodeJsonFloat(PG_FLOAT4_CODEC_ID, json);
1017
- if (Number.isFinite(value) && !fitsFloat4(value)) return refuseJsonValue(PG_FLOAT4_CODEC_ID, `a number float4 holds, at most ${FLOAT4_MAX} in magnitude and not so small that it becomes 0, or the text NaN, Infinity or -Infinity`, json);
1018
- return value;
1112
+ toDataTypeValue(input) {
1113
+ return this.dataTypeValueOf(floatToJson(input));
1019
1114
  }
1020
1115
  };
1021
1116
  var PgFloat4Descriptor = class extends PostgresCodecDescriptor {
@@ -1034,23 +1129,23 @@ var PgFloat4Descriptor = class extends PostgresCodecDescriptor {
1034
1129
  return floatNumberLiteral(value);
1035
1130
  }
1036
1131
  factory() {
1037
- return () => new PgFloat4Codec(this);
1132
+ return () => new PgFloat4Codec(this, pgFloat4);
1038
1133
  }
1039
1134
  };
1040
1135
  const pgFloat4Descriptor = new PgFloat4Descriptor();
1041
1136
  const pgFloat4Column = () => column(pgFloat4Descriptor.factory(), pgFloat4Descriptor.codecId, void 0);
1042
1137
  var PgFloat8Codec = class extends CodecImpl {
1043
- async encode(value, _ctx) {
1138
+ async toWire(value, _ctx) {
1044
1139
  return pgFloatEncode(value);
1045
1140
  }
1046
- async decode(wire, _ctx) {
1141
+ async fromWire(wire, _ctx) {
1047
1142
  return decodePostgresNumberWire(wire);
1048
1143
  }
1049
- encodeJson(value) {
1050
- return encodeJsonFloat(value);
1144
+ fromDataTypeValue(value) {
1145
+ return readJsonFloat(this.id, value.value);
1051
1146
  }
1052
- decodeJson(json) {
1053
- return decodeJsonFloat(PG_FLOAT8_CODEC_ID, json);
1147
+ toDataTypeValue(input) {
1148
+ return this.dataTypeValueOf(floatToJson(input));
1054
1149
  }
1055
1150
  };
1056
1151
  var PgFloat8Descriptor = class extends PostgresCodecDescriptor {
@@ -1069,23 +1164,23 @@ var PgFloat8Descriptor = class extends PostgresCodecDescriptor {
1069
1164
  return floatNumberLiteral(value);
1070
1165
  }
1071
1166
  factory() {
1072
- return () => new PgFloat8Codec(this);
1167
+ return () => new PgFloat8Codec(this, pgFloat8);
1073
1168
  }
1074
1169
  };
1075
1170
  const pgFloat8Descriptor = new PgFloat8Descriptor();
1076
1171
  const pgFloat8Column = () => column(pgFloat8Descriptor.factory(), pgFloat8Descriptor.codecId, void 0);
1077
1172
  var PgBoolCodec = class extends CodecImpl {
1078
- async encode(value, _ctx) {
1173
+ async toWire(value, _ctx) {
1079
1174
  return value;
1080
1175
  }
1081
- async decode(wire, _ctx) {
1176
+ async fromWire(wire, _ctx) {
1082
1177
  return decodePostgresBooleanWire(wire);
1083
1178
  }
1084
- encodeJson(value) {
1085
- return value;
1179
+ fromDataTypeValue(value) {
1180
+ return value.value;
1086
1181
  }
1087
- decodeJson(json) {
1088
- return decodeJsonBoolean(PG_BOOL_CODEC_ID, json);
1182
+ toDataTypeValue(input) {
1183
+ return this.dataTypeValueOf(input);
1089
1184
  }
1090
1185
  };
1091
1186
  var PgBoolDescriptor = class extends PostgresCodecDescriptor {
@@ -1100,42 +1195,23 @@ var PgBoolDescriptor = class extends PostgresCodecDescriptor {
1100
1195
  return renderTsLiteral(value);
1101
1196
  }
1102
1197
  factory() {
1103
- return () => new PgBoolCodec(this);
1198
+ return () => new PgBoolCodec(this, pgBool);
1104
1199
  }
1105
1200
  };
1106
1201
  const pgBoolDescriptor = new PgBoolDescriptor();
1107
1202
  const pgBoolColumn = () => column(pgBoolDescriptor.factory(), pgBoolDescriptor.codecId, void 0);
1108
1203
  var PgNumericCodec = class extends CodecImpl {
1109
- params;
1110
- async encode(value, _ctx) {
1204
+ async toWire(value, _ctx) {
1111
1205
  return value;
1112
1206
  }
1113
- async decode(wire, _ctx) {
1207
+ async fromWire(wire, _ctx) {
1114
1208
  return pgNumericDecode(wire);
1115
1209
  }
1116
- /** A decimal numeral is written as PostgreSQL prints it, without leading zeros or a minus sign on zero; other spellings PostgreSQL reads, such as `1e5`, are refused. */
1117
- encodeJson(value) {
1118
- if (typeof value !== "string" || isNonFiniteText(value)) return value;
1119
- if (DECIMAL_NUMERAL_TEXT.test(value)) return canonicalNumeralText(value);
1120
- throw postgresError("RUNTIME.ENCODE_FAILED", "pg/numeric@1 application value must be numeric text: an optionally negated decimal numeral, or NaN, Infinity or -Infinity", { meta: {
1121
- codecId: PG_NUMERIC_CODEC_ID,
1122
- received: value
1123
- } });
1210
+ fromDataTypeValue(value) {
1211
+ return value.value;
1124
1212
  }
1125
- constructor(descriptor, params) {
1126
- super(descriptor);
1127
- this.params = params;
1128
- }
1129
- decodeJson(json) {
1130
- if (typeof json !== "string" || !CANONICAL_NUMERIC_TEXT.test(json)) {
1131
- const printed = typeof json === "string" && DECIMAL_NUMERAL_TEXT.test(json) ? canonicalNumeralText(json) : void 0;
1132
- return refuseJsonValue(PG_NUMERIC_CODEC_ID, printed === void 0 ? "a decimal string" : `"${printed}", as PostgreSQL writes this value`, json);
1133
- }
1134
- const { precision } = this.params;
1135
- if (precision === void 0) return json;
1136
- const scale = this.params.scale ?? 0;
1137
- if (!fitsNumeric(json, precision, scale)) return refuseJsonValue(PG_NUMERIC_CODEC_ID, `a decimal string that numeric(${precision}, ${scale}) stores without rounding`, json);
1138
- return json;
1213
+ toDataTypeValue(input) {
1214
+ return this.dataTypeValueOf(numericJson(input));
1139
1215
  }
1140
1216
  };
1141
1217
  var PgNumericDescriptor = class extends PostgresCodecDescriptor {
@@ -1151,7 +1227,7 @@ var PgNumericDescriptor = class extends PostgresCodecDescriptor {
1151
1227
  ];
1152
1228
  paramsSchema = pgNumericParams;
1153
1229
  factory(params) {
1154
- return () => new PgNumericCodec(this, params ?? {});
1230
+ return () => new PgNumericCodec(this, pgNumeric, params ?? {});
1155
1231
  }
1156
1232
  };
1157
1233
  const pgNumericDescriptor = new PgNumericDescriptor();
@@ -1163,17 +1239,18 @@ const pgNumericColumn = (params = {}) => column(pgNumericDescriptor.factory(para
1163
1239
  * target type, so `numeric` and `decimal` in type position stay `pg/numeric@1`.
1164
1240
  */
1165
1241
  var PgUnboundedIntCodec = class extends CodecImpl {
1166
- async encode(value, _ctx) {
1242
+ async toWire(value, _ctx) {
1167
1243
  return pgBigintEncode(PG_UNBOUNDED_INT_CODEC_ID, value);
1168
1244
  }
1169
- async decode(wire, _ctx) {
1245
+ async fromWire(wire, _ctx) {
1170
1246
  return pgUnboundedIntDecode(wire);
1171
1247
  }
1172
- encodeJson(value) {
1173
- return pgBigintEncodeJson(PG_UNBOUNDED_INT_CODEC_ID, value);
1248
+ /** A `bigint` holds only a whole number, so a value with a fraction, or `NaN` or an infinity, is refused. */
1249
+ fromDataTypeValue(value) {
1250
+ return readJsonIntegerText(this.id, value.value);
1174
1251
  }
1175
- decodeJson(json) {
1176
- return decodeJsonIntegerText(PG_UNBOUNDED_INT_CODEC_ID, json);
1252
+ toDataTypeValue(input) {
1253
+ return this.dataTypeValueOf(pgBigintDigits(PG_UNBOUNDED_INT_CODEC_ID, input));
1177
1254
  }
1178
1255
  };
1179
1256
  var PgUnboundedIntDescriptor = class extends PostgresCodecDescriptor {
@@ -1191,24 +1268,24 @@ var PgUnboundedIntDescriptor = class extends PostgresCodecDescriptor {
1191
1268
  renderValueLiteral(value) {
1192
1269
  return decimalTextBigintLiteral(value);
1193
1270
  }
1194
- factory(_params) {
1195
- return () => new PgUnboundedIntCodec(this);
1271
+ factory(params) {
1272
+ return () => new PgUnboundedIntCodec(this, pgNumeric, params ?? {});
1196
1273
  }
1197
1274
  };
1198
1275
  const pgUnboundedIntDescriptor = new PgUnboundedIntDescriptor();
1199
1276
  const pgUnboundedIntColumn = () => column(pgUnboundedIntDescriptor.factory(), pgUnboundedIntDescriptor.codecId, void 0);
1200
1277
  var PgTimetzCodec = class extends CodecImpl {
1201
- async encode(value, _ctx) {
1278
+ async toWire(value, _ctx) {
1202
1279
  return value;
1203
1280
  }
1204
- async decode(wire, _ctx) {
1281
+ async fromWire(wire, _ctx) {
1205
1282
  return wire;
1206
1283
  }
1207
- encodeJson(value) {
1208
- return pgTimetzCanonical(value);
1284
+ fromDataTypeValue(value) {
1285
+ return value.value;
1209
1286
  }
1210
- decodeJson(json) {
1211
- return decodeJsonDateTimeText(PG_TIMETZ_CODEC_ID, json, pgTimetzStoredText);
1287
+ toDataTypeValue(input) {
1288
+ return this.dataTypeValueOf(input);
1212
1289
  }
1213
1290
  };
1214
1291
  var PgTimetzDescriptor = class extends PostgresCodecDescriptor {
@@ -1219,31 +1296,24 @@ var PgTimetzDescriptor = class extends PostgresCodecDescriptor {
1219
1296
  codecId = PG_TIMETZ_CODEC_ID;
1220
1297
  traits = ["equality", "order"];
1221
1298
  paramsSchema = pgPrecisionParams;
1222
- factory(_params) {
1223
- return () => new PgTimetzCodec(this);
1299
+ factory(params) {
1300
+ return () => new PgTimetzCodec(this, pgTimetz, params ?? {});
1224
1301
  }
1225
1302
  };
1226
1303
  const pgTimetzDescriptor = new PgTimetzDescriptor();
1227
1304
  const pgTimetzColumn = (params = {}) => column(pgTimetzDescriptor.factory(params), pgTimetzDescriptor.codecId, params);
1228
1305
  var PgBitCodec = class extends CodecImpl {
1229
- length;
1230
- async encode(value, _ctx) {
1306
+ async toWire(value, _ctx) {
1231
1307
  return value;
1232
1308
  }
1233
- async decode(wire, _ctx) {
1309
+ async fromWire(wire, _ctx) {
1234
1310
  return wire;
1235
1311
  }
1236
- encodeJson(value) {
1237
- return value;
1238
- }
1239
- constructor(descriptor, length) {
1240
- super(descriptor);
1241
- this.length = length;
1312
+ fromDataTypeValue(value) {
1313
+ return value.value;
1242
1314
  }
1243
- decodeJson(json) {
1244
- const bits = decodeJsonMatching(PG_BIT_CODEC_ID, json, BIT_STRING, "a string of 0 and 1 digits");
1245
- if (bits.length !== this.length) return refuseJsonValue(PG_BIT_CODEC_ID, `a string of exactly ${counted(this.length, "bit")}`, json);
1246
- return bits;
1315
+ toDataTypeValue(input) {
1316
+ return this.dataTypeValueOf(input);
1247
1317
  }
1248
1318
  };
1249
1319
  var PgBitDescriptor = class extends PostgresCodecDescriptor {
@@ -1255,30 +1325,23 @@ var PgBitDescriptor = class extends PostgresCodecDescriptor {
1255
1325
  traits = ["equality", "order"];
1256
1326
  paramsSchema = pgBitLengthParams;
1257
1327
  factory(params) {
1258
- return () => new PgBitCodec(this, params?.length ?? 1);
1328
+ return () => new PgBitCodec(this, pgBit, params ?? {});
1259
1329
  }
1260
1330
  };
1261
1331
  const pgBitDescriptor = new PgBitDescriptor();
1262
1332
  const pgBitColumn = (params = {}) => column(pgBitDescriptor.factory(params), pgBitDescriptor.codecId, params);
1263
1333
  var PgVarbitCodec = class extends CodecImpl {
1264
- length;
1265
- async encode(value, _ctx) {
1334
+ async toWire(value, _ctx) {
1266
1335
  return value;
1267
1336
  }
1268
- async decode(wire, _ctx) {
1337
+ async fromWire(wire, _ctx) {
1269
1338
  return wire;
1270
1339
  }
1271
- encodeJson(value) {
1272
- return value;
1273
- }
1274
- constructor(descriptor, length) {
1275
- super(descriptor);
1276
- this.length = length;
1340
+ fromDataTypeValue(value) {
1341
+ return value.value;
1277
1342
  }
1278
- decodeJson(json) {
1279
- const bits = decodeJsonMatching(PG_VARBIT_CODEC_ID, json, BIT_STRING, "a string of 0 and 1 digits");
1280
- if (this.length !== void 0 && bits.length > this.length) return refuseJsonValue(PG_VARBIT_CODEC_ID, `a string of at most ${counted(this.length, "bit")}`, json);
1281
- return bits;
1343
+ toDataTypeValue(input) {
1344
+ return this.dataTypeValueOf(input);
1282
1345
  }
1283
1346
  };
1284
1347
  var PgVarbitDescriptor = class extends PostgresCodecDescriptor {
@@ -1290,28 +1353,28 @@ var PgVarbitDescriptor = class extends PostgresCodecDescriptor {
1290
1353
  traits = ["equality", "order"];
1291
1354
  paramsSchema = pgBitLengthParams;
1292
1355
  factory(params) {
1293
- return () => new PgVarbitCodec(this, params?.length);
1356
+ return () => new PgVarbitCodec(this, pgVarbit, params ?? {});
1294
1357
  }
1295
1358
  };
1296
1359
  const pgVarbitDescriptor = new PgVarbitDescriptor();
1297
1360
  const pgVarbitColumn = (params = {}) => column(pgVarbitDescriptor.factory(params), pgVarbitDescriptor.codecId, params);
1298
1361
  var PgByteaCodec = class extends CodecImpl {
1299
- async encode(value, _ctx) {
1362
+ async toWire(value, _ctx) {
1300
1363
  return value;
1301
1364
  }
1302
- async decode(wire, _ctx) {
1365
+ async fromWire(wire, _ctx) {
1303
1366
  return pgByteaDecodeWire(wire);
1304
1367
  }
1305
- encodeJson(value) {
1306
- return pgByteaEncodeJson(value);
1368
+ fromDataTypeValue(value) {
1369
+ return pgByteaFromBase64(value.value);
1307
1370
  }
1308
- decodeJson(json) {
1309
- return pgByteaDecodeJson(json);
1371
+ toDataTypeValue(input) {
1372
+ return this.dataTypeValueOf(pgByteaToBase64(input));
1310
1373
  }
1311
1374
  };
1312
1375
  var PgByteaDescriptor = class extends PostgresCodecDescriptor {
1313
1376
  jsonProjection(expression) {
1314
- return base64JsonProjection(expression);
1377
+ return printedTextJsonProjection(expression);
1315
1378
  }
1316
1379
  dataType = pgBytea.id;
1317
1380
  codecId = PG_BYTEA_CODEC_ID;
@@ -1319,22 +1382,22 @@ var PgByteaDescriptor = class extends PostgresCodecDescriptor {
1319
1382
  enumRefusal = "The contract stores a bytea value as base64 text, which PostgreSQL reads as the bytes of that text, so no CHECK can compare a value with the members. No enum can use a bytea codec; use a text enum instead.";
1320
1383
  paramsSchema = void 0;
1321
1384
  factory() {
1322
- return () => new PgByteaCodec(this);
1385
+ return () => new PgByteaCodec(this, pgBytea);
1323
1386
  }
1324
1387
  };
1325
1388
  const pgByteaDescriptor = new PgByteaDescriptor();
1326
1389
  var PgUuidCodec = class extends CodecImpl {
1327
- async encode(value, _ctx) {
1390
+ async toWire(value, _ctx) {
1328
1391
  return value;
1329
1392
  }
1330
- async decode(wire, _ctx) {
1393
+ async fromWire(wire, _ctx) {
1331
1394
  return wire;
1332
1395
  }
1333
- encodeJson(value) {
1334
- return canonicalUuid(value) ?? value;
1396
+ fromDataTypeValue(value) {
1397
+ return value.value;
1335
1398
  }
1336
- decodeJson(json) {
1337
- return decodeJsonMatching(PG_UUID_CODEC_ID, json, CANONICAL_UUID, "a UUID as PostgreSQL writes it, in lower case and hyphenated 8-4-4-4-12");
1399
+ toDataTypeValue(input) {
1400
+ return this.dataTypeValueOf(input);
1338
1401
  }
1339
1402
  };
1340
1403
  var PgUuidDescriptor = class extends PostgresCodecDescriptor {
@@ -1346,25 +1409,23 @@ var PgUuidDescriptor = class extends PostgresCodecDescriptor {
1346
1409
  traits = ["equality", "order"];
1347
1410
  paramsSchema = void 0;
1348
1411
  factory() {
1349
- return () => new PgUuidCodec(this);
1412
+ return () => new PgUuidCodec(this, pgUuid);
1350
1413
  }
1351
1414
  };
1352
1415
  const pgUuidDescriptor = new PgUuidDescriptor();
1353
1416
  const pgUuidColumn = () => column(pgUuidDescriptor.factory(), pgUuidDescriptor.codecId, void 0);
1354
1417
  var PgInetCodec = class extends CodecImpl {
1355
- async encode(value, _ctx) {
1418
+ async toWire(value, _ctx) {
1356
1419
  return value;
1357
1420
  }
1358
- async decode(wire, _ctx) {
1421
+ async fromWire(wire, _ctx) {
1359
1422
  return wire;
1360
1423
  }
1361
- encodeJson(value) {
1362
- return canonicalInet(value) ?? value;
1424
+ fromDataTypeValue(value) {
1425
+ return value.value;
1363
1426
  }
1364
- decodeJson(json) {
1365
- const printed = typeof json === "string" ? canonicalInet(json) : void 0;
1366
- if (printed !== void 0 && printed === json) return printed;
1367
- return refuseJsonValue(PG_INET_CODEC_ID, printed === void 0 ? "an IP address as PostgreSQL writes it" : `"${printed}", as PostgreSQL writes this address`, json);
1427
+ toDataTypeValue(input) {
1428
+ return this.dataTypeValueOf(input);
1368
1429
  }
1369
1430
  };
1370
1431
  var PgInetDescriptor = class extends PostgresCodecDescriptor {
@@ -1376,23 +1437,23 @@ var PgInetDescriptor = class extends PostgresCodecDescriptor {
1376
1437
  traits = ["equality", "order"];
1377
1438
  paramsSchema = void 0;
1378
1439
  factory() {
1379
- return () => new PgInetCodec(this);
1440
+ return () => new PgInetCodec(this, pgInet);
1380
1441
  }
1381
1442
  };
1382
1443
  const pgInetDescriptor = new PgInetDescriptor();
1383
1444
  const pgInetColumn = () => column(pgInetDescriptor.factory(), pgInetDescriptor.codecId, void 0);
1384
1445
  var PgTsqueryCodec = class extends CodecImpl {
1385
- async encode(value, _ctx) {
1446
+ async toWire(value, _ctx) {
1386
1447
  return value;
1387
1448
  }
1388
- async decode(wire, _ctx) {
1449
+ async fromWire(wire, _ctx) {
1389
1450
  return blindCast(wire);
1390
1451
  }
1391
- encodeJson(value) {
1392
- return value;
1452
+ fromDataTypeValue(value) {
1453
+ return blindCast(value.value);
1393
1454
  }
1394
- decodeJson(json) {
1395
- return blindCast(decodeJsonString(PG_TSQUERY_CODEC_ID, json));
1455
+ toDataTypeValue(input) {
1456
+ return this.dataTypeValueOf(input);
1396
1457
  }
1397
1458
  };
1398
1459
  /**
@@ -1411,7 +1472,7 @@ var PgTsqueryDescriptor = class extends PostgresCodecDescriptor {
1411
1472
  enumRefusal = "PostgreSQL normalises the query text, so a member as written is not the value a query reads back: it prints a & b as 'a' & 'b'. No enum can use a tsquery codec; use a text enum instead.";
1412
1473
  paramsSchema = void 0;
1413
1474
  factory() {
1414
- return () => new PgTsqueryCodec(this);
1475
+ return () => new PgTsqueryCodec(this, pgTsquery);
1415
1476
  }
1416
1477
  };
1417
1478
  const pgTsqueryDescriptor = new PgTsqueryDescriptor();
@@ -1433,50 +1494,50 @@ const pgTsqueryDescriptor = new PgTsqueryDescriptor();
1433
1494
  * year — so `{months: 13}` renders `P1Y1M` and reads back as `{months: 13}`.
1434
1495
  */
1435
1496
  var PgIntervalCodec = class extends CodecImpl {
1436
- async encode(value, _ctx) {
1497
+ async toWire(value, _ctx) {
1437
1498
  return pgIntervalToIso(value);
1438
1499
  }
1439
- async decode(wire, _ctx) {
1500
+ async fromWire(wire, _ctx) {
1440
1501
  return pgIntervalDecode(wire);
1441
1502
  }
1442
- encodeJson(value) {
1443
- return pgIntervalEncodeJson(value);
1503
+ fromDataTypeValue(value) {
1504
+ return pgIntervalFromIso(value.value);
1444
1505
  }
1445
- decodeJson(json) {
1446
- return pgIntervalDecodeJson(json);
1506
+ toDataTypeValue(input) {
1507
+ return this.dataTypeValueOf(pgIntervalToIso(input));
1447
1508
  }
1448
1509
  };
1449
1510
  var PgIntervalDescriptor = class extends PostgresCodecDescriptor {
1450
1511
  jsonProjection(expression) {
1451
- return isoDurationJsonProjection(expression);
1512
+ return printedTextJsonProjection(expression);
1452
1513
  }
1453
1514
  dataType = pgInterval.id;
1454
1515
  codecId = PG_INTERVAL_CODEC_ID;
1455
1516
  traits = ["equality", "order"];
1456
1517
  paramsSchema = pgPrecisionParams;
1457
- factory(_params) {
1458
- return () => new PgIntervalCodec(this);
1518
+ factory(params) {
1519
+ return () => new PgIntervalCodec(this, pgInterval, params ?? {});
1459
1520
  }
1460
1521
  };
1461
1522
  const pgIntervalDescriptor = new PgIntervalDescriptor();
1462
1523
  const pgIntervalColumn = (params = {}) => column(pgIntervalDescriptor.factory(params), pgIntervalDescriptor.codecId, params);
1463
1524
  var PgJsonCodec = class extends CodecImpl {
1464
- async encode(value, _ctx) {
1525
+ async toWire(value, _ctx) {
1465
1526
  return pgJsonEncode(value);
1466
1527
  }
1467
- async decode(wire, _ctx) {
1528
+ async fromWire(wire, _ctx) {
1468
1529
  return pgJsonDecode(wire);
1469
1530
  }
1470
- encodeJson(value) {
1471
- return value;
1531
+ fromDataTypeValue(value) {
1532
+ return value.value;
1472
1533
  }
1473
- decodeJson(json) {
1474
- return json;
1534
+ toDataTypeValue(input) {
1535
+ return this.dataTypeValueOf(input);
1475
1536
  }
1476
1537
  };
1477
1538
  var PgJsonDescriptor = class extends PostgresCodecDescriptor {
1478
1539
  jsonProjection(expression) {
1479
- return expression;
1540
+ return printedTextJsonProjection(expression);
1480
1541
  }
1481
1542
  dataType = pgJson.id;
1482
1543
  codecId = PG_JSON_CODEC_ID;
@@ -1484,76 +1545,46 @@ var PgJsonDescriptor = class extends PostgresCodecDescriptor {
1484
1545
  enumRefusal = "The json type has no equality operator, so no CHECK can compare a value with the members. Use pg/jsonb@1, whose type has one.";
1485
1546
  paramsSchema = void 0;
1486
1547
  factory() {
1487
- return () => new PgJsonCodec(this);
1548
+ return () => new PgJsonCodec(this, pgJson);
1488
1549
  }
1489
1550
  };
1490
1551
  const pgJsonDescriptor = new PgJsonDescriptor();
1491
1552
  const pgJsonColumn = () => column(pgJsonDescriptor.factory(), pgJsonDescriptor.codecId, void 0);
1492
1553
  var PgJsonbCodec = class extends CodecImpl {
1493
- async encode(value, _ctx) {
1554
+ async toWire(value, _ctx) {
1494
1555
  return pgJsonbEncode(value);
1495
1556
  }
1496
- async decode(wire, _ctx) {
1557
+ async fromWire(wire, _ctx) {
1497
1558
  return pgJsonbDecode(wire);
1498
1559
  }
1499
- encodeJson(value) {
1500
- return value;
1560
+ fromDataTypeValue(value) {
1561
+ return value.value;
1501
1562
  }
1502
- decodeJson(json) {
1503
- return json;
1563
+ toDataTypeValue(input) {
1564
+ return this.dataTypeValueOf(input);
1504
1565
  }
1505
1566
  };
1506
1567
  var PgJsonbDescriptor = class extends PostgresCodecDescriptor {
1507
1568
  jsonProjection(expression) {
1508
- return expression;
1569
+ return printedTextJsonProjection(expression);
1509
1570
  }
1510
1571
  dataType = pgJsonb.id;
1511
1572
  codecId = PG_JSONB_CODEC_ID;
1512
1573
  traits = ["equality"];
1513
1574
  paramsSchema = void 0;
1514
1575
  factory() {
1515
- return () => new PgJsonbCodec(this);
1576
+ return () => new PgJsonbCodec(this, pgJsonb);
1516
1577
  }
1517
1578
  };
1518
1579
  const pgJsonbDescriptor = new PgJsonbDescriptor();
1519
1580
  const pgJsonbColumn = () => column(pgJsonbDescriptor.factory(), pgJsonbDescriptor.codecId, void 0);
1520
1581
  var PgIntCodec = class extends SqlIntCodec {
1521
- async decode(wire, _ctx) {
1582
+ async fromWire(wire, _ctx) {
1522
1583
  return decodePostgresNumberWire(wire);
1523
1584
  }
1524
- decodeJson(json) {
1525
- return decodeJsonInteger(this.id, json, INT32_RANGE);
1526
- }
1527
- };
1528
- /**
1529
- * `sql/char@1` as PostgreSQL stores it: a `character` column holds its length in characters, and one with no length is `character(1)`.
1530
- */
1531
- var PgCharCodec = class extends SqlCharCodec {
1532
- length;
1533
- constructor(descriptor, length) {
1534
- super(descriptor);
1535
- this.length = length ?? 1;
1536
- }
1537
- decodeJson(json) {
1538
- if (!fitsCharacterLength(decodeJsonString(this.id, json), this.length, true)) return refuseJsonValue(this.id, `a string of at most ${counted(this.length, "character")} before any trailing spaces`, json);
1539
- return super.decodeJson(json);
1540
- }
1541
- };
1542
- /** `sql/varchar@1` as PostgreSQL stores it: a `character varying` column with a length holds at most that many characters. */
1543
- var PgVarcharCodec = class extends SqlVarcharCodec {
1544
- length;
1545
- constructor(descriptor, length) {
1546
- super(descriptor);
1547
- this.length = length;
1548
- }
1549
- decodeJson(json) {
1550
- const text = super.decodeJson(json);
1551
- if (this.length !== void 0 && !fitsCharacterLength(text, this.length, false)) return refuseJsonValue(this.id, `a string of at most ${counted(this.length, "character")}`, json);
1552
- return text;
1553
- }
1554
1585
  };
1555
1586
  var PgFloatCodec = class extends SqlFloatCodec {
1556
- async decode(wire, _ctx) {
1587
+ async fromWire(wire, _ctx) {
1557
1588
  return decodePostgresNumberWire(wire);
1558
1589
  }
1559
1590
  };
@@ -1569,7 +1600,7 @@ var PgCharDescriptor = class extends PostgresCodecDescriptor {
1569
1600
  return renderTsLiteral(value);
1570
1601
  }
1571
1602
  factory(params) {
1572
- return () => new PgCharCodec(this, params?.length);
1603
+ return () => new SqlCharCodec(this, pgChar, params ?? {});
1573
1604
  }
1574
1605
  };
1575
1606
  const pgCharDescriptor = new PgCharDescriptor();
@@ -1586,7 +1617,7 @@ var PgVarcharDescriptor = class extends PostgresCodecDescriptor {
1586
1617
  return renderTsLiteral(value);
1587
1618
  }
1588
1619
  factory(params) {
1589
- return () => new PgVarcharCodec(this, params?.length);
1620
+ return () => new SqlVarcharCodec(this, pgVarchar, params ?? {});
1590
1621
  }
1591
1622
  };
1592
1623
  const pgVarcharDescriptor = new PgVarcharDescriptor();
@@ -1603,7 +1634,7 @@ var PgIntDescriptor = class extends PostgresCodecDescriptor {
1603
1634
  return renderTsLiteral(value);
1604
1635
  }
1605
1636
  factory() {
1606
- return () => new PgIntCodec(this);
1637
+ return () => new PgIntCodec(this, pgInt4);
1607
1638
  }
1608
1639
  };
1609
1640
  const pgIntDescriptor = new PgIntDescriptor();
@@ -1620,7 +1651,7 @@ var PgFloatDescriptor = class extends PostgresCodecDescriptor {
1620
1651
  return floatNumberLiteral(value);
1621
1652
  }
1622
1653
  factory() {
1623
- return () => new PgFloatCodec(this);
1654
+ return () => new PgFloatCodec(this, pgFloat8);
1624
1655
  }
1625
1656
  };
1626
1657
  const pgFloatDescriptor = new PgFloatDescriptor();
@@ -1668,6 +1699,6 @@ const codecDescriptors = definePostgresCodecs([
1668
1699
  pgTsqueryDescriptor
1669
1700
  ]);
1670
1701
  //#endregion
1671
- export { postgresQualifyColumnType as A, pgTimestamptzDateColumn as C, pgUuidColumn as D, pgUnboundedIntColumn as E, setFallbackTemporal as M, pgVarbitColumn as O, pgTextColumn as S, pgTimetzColumn as T, pgIntColumn as _, pgBitColumn as a, pgJsonbColumn as b, pgEnumDescriptor as c, pgFloatColumn as d, pgInetColumn as f, pgInt8NumberColumn as g, pgInt8Column as h, isPgEnumParams as i, requireTemporal as j, pgVarcharColumn as k, pgFloat4Column as l, pgInt4Column as m, PgTimestamptzDateDescriptor as n, pgBoolColumn as o, pgInt2Column as p, codecDescriptors as r, pgCharColumn as s, PgTimestamptzDateCodec as t, pgFloat8Column as u, pgIntervalColumn as v, pgTimestamptzDateDescriptor as w, pgNumericColumn as x, pgJsonColumn as y };
1702
+ export { pgVarbitColumn as A, pgNumericColumn as C, pgTimetzColumn as D, pgTimestamptzDateDescriptor as E, postgresQualifyColumnType as M, requireTemporal as N, pgUnboundedIntColumn as O, setFallbackTemporal as P, pgJsonbColumn as S, pgTimestamptzDateColumn as T, pgInt8Column as _, isPgEnumParams as a, pgIntervalColumn as b, pgBoolColumn as c, pgFloat4Column as d, pgFloat8Column as f, pgInt4Column as g, pgInt2Column as h, decodePostgresListText as i, pgVarcharColumn as j, pgUuidColumn as k, pgCharColumn as l, pgInetColumn as m, PgTimestamptzDateDescriptor as n, parsePostgresListText as o, pgFloatColumn as p, codecDescriptors as r, pgBitColumn as s, PgTimestamptzDateCodec as t, pgEnumDescriptor as u, pgInt8NumberColumn as v, pgTextColumn as w, pgJsonColumn as x, pgIntColumn as y };
1672
1703
 
1673
- //# sourceMappingURL=codecs-CQaKsvhH-X9bscCr9.mjs.map
1704
+ //# sourceMappingURL=codecs-CaWZPjFi-hllqyGdW.mjs.map