@prisma/orm-family-sql 8.0.0-rc.14-dev.29 → 8.0.0-rc.14-dev.30

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 (233) hide show
  1. package/dist/{aggregate-descriptor-registry-CJF2KxUb.mjs → aggregate-descriptor-registry-B3RG0Zom.mjs} +2 -2
  2. package/dist/{aggregate-descriptor-registry-CJF2KxUb.mjs.map → aggregate-descriptor-registry-B3RG0Zom.mjs.map} +1 -1
  3. package/dist/{ast-dPjHeaNs.d.mts → ast-BUbHXpzG.d.mts} +7 -105
  4. package/dist/ast-BUbHXpzG.d.mts.map +1 -0
  5. package/dist/ast-CQZn-6Wd.mjs +310 -0
  6. package/dist/ast-CQZn-6Wd.mjs.map +1 -0
  7. package/dist/{authoring-entity-types-CZ-vdwYS-BfyaoH53.d.mts → authoring-entity-types-CZ-vdwYS-C25VGQVB.d.mts} +2 -2
  8. package/dist/{authoring-entity-types-CZ-vdwYS-BfyaoH53.d.mts.map → authoring-entity-types-CZ-vdwYS-C25VGQVB.d.mts.map} +1 -1
  9. package/dist/{authoring-type-constructors-DIyheCzv-BSrAEZsD.mjs → authoring-type-constructors-dihiQslc-hldmqa1r.mjs} +22 -28
  10. package/dist/authoring-type-constructors-dihiQslc-hldmqa1r.mjs.map +1 -0
  11. package/dist/builder.d.mts +2 -2
  12. package/dist/builder__runtime.d.mts +6 -6
  13. package/dist/builder__runtime.mjs +3 -3
  14. package/dist/builder__types.d.mts +2 -2
  15. package/dist/{codec-descriptor-registry-u6_e6WfA.mjs → codec-descriptor-registry-BW0REwkz.mjs} +2 -11
  16. package/dist/{codec-descriptor-registry-u6_e6WfA.mjs.map → codec-descriptor-registry-BW0REwkz.mjs.map} +1 -1
  17. package/dist/{config-types-DNRmpGNL.mjs → config-types-ump1oN82.mjs} +8 -4
  18. package/dist/config-types-ump1oN82.mjs.map +1 -0
  19. package/dist/{contract-builder-Br5TlHMh.d.mts → contract-builder-BXxFihYc.d.mts} +16 -11
  20. package/dist/contract-builder-BXxFihYc.d.mts.map +1 -0
  21. package/dist/{contract-builder-C3MYW38z.mjs → contract-builder-CQvwPGAW.mjs} +29 -24
  22. package/dist/contract-builder-CQvwPGAW.mjs.map +1 -0
  23. package/dist/contract-emitter.d.mts +1 -1
  24. package/dist/contract-emitter.mjs +1 -1
  25. package/dist/contract-prisma7__provider.d.mts +2 -1
  26. package/dist/contract-prisma7__provider.d.mts.map +1 -1
  27. package/dist/contract-prisma7__provider.mjs +16 -9
  28. package/dist/contract-prisma7__provider.mjs.map +1 -1
  29. package/dist/contract-psl.d.mts +4 -4
  30. package/dist/contract-psl.d.mts.map +1 -1
  31. package/dist/contract-psl.mjs +1 -1
  32. package/dist/contract-psl__attribute-specs.d.mts +2 -2
  33. package/dist/contract-psl__attribute-specs.mjs +1 -1
  34. package/dist/contract-psl__provider.mjs +2 -2
  35. package/dist/contract-psl__provider.mjs.map +1 -1
  36. package/dist/contract-ts.d.mts +1 -1
  37. package/dist/contract-ts.mjs +3 -3
  38. package/dist/contract-ts__config-types.mjs +1 -1
  39. package/dist/contract-ts__contract-builder.d.mts +1 -1
  40. package/dist/contract-ts__contract-builder.mjs +2 -2
  41. package/dist/contract.d.mts +5 -3
  42. package/dist/contract.mjs +11 -8
  43. package/dist/contract__data-type-support.d.mts +2 -0
  44. package/dist/contract__data-type-support.mjs +2 -0
  45. package/dist/contract__data-type.d.mts +2 -0
  46. package/dist/contract__data-type.mjs +3 -0
  47. package/dist/contract__entity-kinds.mjs +1 -1
  48. package/dist/contract__factories.mjs +1 -1
  49. package/dist/contract__sql-expression.d.mts +1 -1
  50. package/dist/contract__sql-expression.mjs +1 -1
  51. package/dist/contract__types.mjs +3 -3
  52. package/dist/contract__validators.d.mts +1 -1
  53. package/dist/contract__validators.mjs +2 -2
  54. package/dist/{control-BYOcSVih.mjs → control-BYT1Lgtm.mjs} +76 -117
  55. package/dist/control-BYT1Lgtm.mjs.map +1 -0
  56. package/dist/{control-DL9y6GfG.d.mts → control-Bpk8PtSL.d.mts} +40 -128
  57. package/dist/control-Bpk8PtSL.d.mts.map +1 -0
  58. package/dist/{control-adapter-WoXvPNj4-D64oWh9I.d.mts → control-adapter-BVN98SzR-C-H_T7s-.d.mts} +8 -20
  59. package/dist/control-adapter-BVN98SzR-C-H_T7s-.d.mts.map +1 -0
  60. package/dist/control-adapter-DSGwSagr.d.mts +1 -0
  61. package/dist/data-type-CAPmGXg9.mjs +297 -0
  62. package/dist/data-type-CAPmGXg9.mjs.map +1 -0
  63. package/dist/data-type-CpqSDmR_.d.mts +113 -0
  64. package/dist/data-type-CpqSDmR_.d.mts.map +1 -0
  65. package/dist/data-type-support-B_Dr1cxB.d.mts +92 -0
  66. package/dist/data-type-support-B_Dr1cxB.d.mts.map +1 -0
  67. package/dist/{ast-5hifzBHC.mjs → data-type-support-rpD1jyZd.mjs} +6 -329
  68. package/dist/data-type-support-rpD1jyZd.mjs.map +1 -0
  69. package/dist/{db-DLjWu9-f-BjAFEKe9.d.mts → db-DLjWu9-f-T8QbxDGY.d.mts} +6 -6
  70. package/dist/{db-DLjWu9-f-BjAFEKe9.d.mts.map → db-DLjWu9-f-T8QbxDGY.d.mts.map} +1 -1
  71. package/dist/{ddl-types-B48YmQSt-DLCUHORB.d.mts → ddl-types-BUqZdoZK-vyWnW2PW.d.mts} +3 -3
  72. package/dist/{ddl-types-B48YmQSt-DLCUHORB.d.mts.map → ddl-types-BUqZdoZK-vyWnW2PW.d.mts.map} +1 -1
  73. package/dist/{derived-checks-C_y1rk6O-DwCaGICl.mjs → derived-checks-CILnJKoa-D42YRW01.mjs} +48 -25
  74. package/dist/derived-checks-CILnJKoa-D42YRW01.mjs.map +1 -0
  75. package/dist/diff-B16bL_IR.mjs.map +1 -1
  76. package/dist/{diff-CJI5hKWL.d.mts → diff-BsHizC0z.d.mts} +6 -6
  77. package/dist/{diff-CJI5hKWL.d.mts.map → diff-BsHizC0z.d.mts.map} +1 -1
  78. package/dist/{dist-BdePIXOu.mjs → dist-C_HYPisk.mjs} +3 -3
  79. package/dist/{dist-BdePIXOu.mjs.map → dist-C_HYPisk.mjs.map} +1 -1
  80. package/dist/{entity-kinds-ChX-owgJ-DqGkW6Dq.mjs → entity-kinds-BNQFeECV-BOJmOArY.mjs} +4 -4
  81. package/dist/{entity-kinds-ChX-owgJ-DqGkW6Dq.mjs.map → entity-kinds-BNQFeECV-BOJmOArY.mjs.map} +1 -1
  82. package/dist/{expression-n9sdM2RA.d.mts → expression-Bf_MkeQS.d.mts} +3 -3
  83. package/dist/{expression-n9sdM2RA.d.mts.map → expression-Bf_MkeQS.d.mts.map} +1 -1
  84. package/dist/{expression-vAEOvq7J.mjs → expression-Bv8X6-Qg.mjs} +2 -2
  85. package/dist/{expression-vAEOvq7J.mjs.map → expression-Bv8X6-Qg.mjs.map} +1 -1
  86. package/dist/{factories-BnzIZxE1.mjs → factories-D6haP7by.mjs} +2 -2
  87. package/dist/{factories-BnzIZxE1.mjs.map → factories-D6haP7by.mjs.map} +1 -1
  88. package/dist/family.d.mts +13 -13
  89. package/dist/family.mjs +7 -7
  90. package/dist/family__control-adapter.d.mts +2 -2
  91. package/dist/family__control.d.mts +5 -5
  92. package/dist/family__control.mjs +4 -4
  93. package/dist/family__diff.d.mts +3 -3
  94. package/dist/family__diff.mjs +1 -1
  95. package/dist/family__ir.mjs +1 -1
  96. package/dist/family__migration.d.mts +1 -1
  97. package/dist/family__pack.d.mts +1 -1
  98. package/dist/family__pack.mjs +2 -2
  99. package/dist/family__pack.mjs.map +1 -1
  100. package/dist/family__psl-build.d.mts +2 -2
  101. package/dist/family__psl-build.mjs +1 -1
  102. package/dist/family__psl-infer.d.mts +1 -1
  103. package/dist/family__verify.mjs +1 -1
  104. package/dist/{index-BoQtw7lz.d.mts → index-D2ho4por.d.mts} +9 -9
  105. package/dist/{index-BoQtw7lz.d.mts.map → index-D2ho4por.d.mts.map} +1 -1
  106. package/dist/index-type-validation-COH4d78M.mjs.map +1 -1
  107. package/dist/{interpreter-C8cP92FD-BfjuQvb1.mjs → interpreter-CDflex9x-Bx84tcl5.mjs} +33 -29
  108. package/dist/interpreter-CDflex9x-Bx84tcl5.mjs.map +1 -0
  109. package/dist/{middleware-CuGBptK0-xrXqWhc7.d.mts → middleware-BtMX6nSF-DUnzMyGl.d.mts} +3 -3
  110. package/dist/{middleware-CuGBptK0-xrXqWhc7.d.mts.map → middleware-BtMX6nSF-DUnzMyGl.d.mts.map} +1 -1
  111. package/dist/middleware-pBMsszaq.d.mts +1 -0
  112. package/dist/{migration-CSEh4QPu.d.mts → migration-oet2BBxc.d.mts} +2 -2
  113. package/dist/{migration-CSEh4QPu.d.mts.map → migration-oet2BBxc.d.mts.map} +1 -1
  114. package/dist/numeral-text-Cqu87pVe-DJCqBaSC.mjs +20 -0
  115. package/dist/numeral-text-Cqu87pVe-DJCqBaSC.mjs.map +1 -0
  116. package/dist/orm-client.d.mts +11 -11
  117. package/dist/orm-client.mjs +6 -6
  118. package/dist/{pack-C3mqZevM.d.mts → pack-C-JTs3HQ.d.mts} +2 -16
  119. package/dist/pack-C-JTs3HQ.d.mts.map +1 -0
  120. package/dist/plan-BbkBYyGR.d.mts +2 -0
  121. package/dist/{plan-B7g2kDfQ-Dth0BeTe.d.mts → plan-BlQITcbP-DvbDlHXA.d.mts} +3 -3
  122. package/dist/plan-BlQITcbP-DvbDlHXA.d.mts.map +1 -0
  123. package/dist/{prepared-statement-Cv54gpY_-DbHPSN5Q.d.mts → prepared-statement-Cv54gpY_-dg9Qr8sK.d.mts} +14 -14
  124. package/dist/{prepared-statement-Cv54gpY_-DbHPSN5Q.d.mts.map → prepared-statement-Cv54gpY_-dg9Qr8sK.d.mts.map} +1 -1
  125. package/dist/{psl-build-zkIJwkdq.mjs → psl-build-B6nw6MAM.mjs} +18 -17
  126. package/dist/psl-build-B6nw6MAM.mjs.map +1 -0
  127. package/dist/{psl-build-BnM1ZTyK.d.mts → psl-build-BrW7lQMO.d.mts} +2 -2
  128. package/dist/psl-build-BrW7lQMO.d.mts.map +1 -0
  129. package/dist/{psl-column-resolution-sNpXQygQ-BBo4tqwO.d.mts → psl-column-resolution-BegCa1-t-BJJ9WB1c.d.mts} +4 -5
  130. package/dist/psl-column-resolution-BegCa1-t-BJJ9WB1c.d.mts.map +1 -0
  131. package/dist/{psl-field-resolution-_o74AUE4-C-vTNklI.mjs → psl-field-resolution-CKMm6Gx0-CdzpWIV5.mjs} +69 -17
  132. package/dist/psl-field-resolution-CKMm6Gx0-CdzpWIV5.mjs.map +1 -0
  133. package/dist/{psl-infer-BwbmOInx.d.mts → psl-infer-DzH2Khty.d.mts} +4 -4
  134. package/dist/{psl-infer-BwbmOInx.d.mts.map → psl-infer-DzH2Khty.d.mts.map} +1 -1
  135. package/dist/query-lane-context-CLtywrTY.d.mts +1 -0
  136. package/dist/{query-lane-context-BSmWfohZ-Jn0AbOQt.d.mts → query-lane-context-OSV9X636-CcPv1TZj.d.mts} +6 -10
  137. package/dist/query-lane-context-OSV9X636-CcPv1TZj.d.mts.map +1 -0
  138. package/dist/relational-core.d.mts +12 -12
  139. package/dist/relational-core.mjs +4 -4
  140. package/dist/relational-core__aggregate-descriptor-registry.d.mts +1 -1
  141. package/dist/relational-core__aggregate-descriptor-registry.mjs +1 -1
  142. package/dist/relational-core__ast.d.mts +4 -4
  143. package/dist/relational-core__ast.mjs +3 -3
  144. package/dist/relational-core__codec-descriptor-registry.d.mts +2 -2
  145. package/dist/relational-core__codec-descriptor-registry.mjs +1 -1
  146. package/dist/relational-core__contract-free.d.mts +4 -2
  147. package/dist/relational-core__contract-free.d.mts.map +1 -1
  148. package/dist/relational-core__contract-free.mjs +10 -4
  149. package/dist/relational-core__contract-free.mjs.map +1 -1
  150. package/dist/relational-core__expression.d.mts +1 -1
  151. package/dist/relational-core__expression.mjs +1 -1
  152. package/dist/relational-core__middleware.d.mts +2 -2
  153. package/dist/relational-core__plan.d.mts +3 -3
  154. package/dist/relational-core__query-lane-context.d.mts +2 -2
  155. package/dist/relational-core__types.d.mts +2 -2
  156. package/dist/runtime.d.mts +4 -4
  157. package/dist/runtime.mjs +6 -6
  158. package/dist/runtime__internal__prepared-query.d.mts +1 -1
  159. package/dist/{schema-differ-DpG_gnur-CUh9eZM-.d.mts → schema-differ-DpG_gnur-if2KDxZC.d.mts} +3 -3
  160. package/dist/{schema-differ-DpG_gnur-CUh9eZM-.d.mts.map → schema-differ-DpG_gnur-if2KDxZC.d.mts.map} +1 -1
  161. package/dist/schema-ir.d.mts +2 -2
  162. package/dist/schema-ir.mjs +1 -1
  163. package/dist/schema-ir__types.d.mts +3 -3
  164. package/dist/schema-ir__types.mjs +1 -1
  165. package/dist/{schema-verify-Xmpe1PGb-Bcd_2avJ.mjs → schema-verify-lPfqY_aE-CZCO8my1.mjs} +32 -6
  166. package/dist/schema-verify-lPfqY_aE-CZCO8my1.mjs.map +1 -0
  167. package/dist/{serialized-index-B5X7s-oX-CVs8-5Rw.mjs → serialized-index-BeGqqsrC-PymnV1h-.mjs} +3 -3
  168. package/dist/{serialized-index-B5X7s-oX-CVs8-5Rw.mjs.map → serialized-index-BeGqqsrC-PymnV1h-.mjs.map} +1 -1
  169. package/dist/{sql-contract-serializer-C90xg7_q-C_Okh4NM.mjs → sql-contract-serializer-C90xg7_q-4UVEMTWO.mjs} +5 -5
  170. package/dist/{sql-contract-serializer-C90xg7_q-C_Okh4NM.mjs.map → sql-contract-serializer-C90xg7_q-4UVEMTWO.mjs.map} +1 -1
  171. package/dist/{sql-execution-plan-Db0j752I-dJ-JGxbD.d.mts → sql-execution-plan-CV6K4o9N-DAIvJbkb.d.mts} +3 -3
  172. package/dist/sql-execution-plan-CV6K4o9N-DAIvJbkb.d.mts.map +1 -0
  173. package/dist/{sql-expression-BXx0Ilj-.mjs → sql-expression-D7GsLgDM.mjs} +2 -2
  174. package/dist/{sql-expression-BXx0Ilj-.mjs.map → sql-expression-D7GsLgDM.mjs.map} +1 -1
  175. package/dist/{sql-expression-D_hbJOgM.d.mts → sql-expression-DE_MTt3T.d.mts} +2 -2
  176. package/dist/{sql-expression-D_hbJOgM.d.mts.map → sql-expression-DE_MTt3T.d.mts.map} +1 -1
  177. package/dist/{storage-table-ADhJ4Imk-CwcQVFXC.mjs → storage-table-BwwDKQkD-BN9cZrGX.mjs} +2 -2
  178. package/dist/{storage-table-ADhJ4Imk-CwcQVFXC.mjs.map → storage-table-BwwDKQkD-BN9cZrGX.mjs.map} +1 -1
  179. package/dist/{type-map-DpfnXzun-DZaSuJXh.d.mts → type-map-DmIbL4o--BfPMblbZ.d.mts} +4 -4
  180. package/dist/type-map-DmIbL4o--BfPMblbZ.d.mts.map +1 -0
  181. package/dist/{types-BPi4d3WI-D8PIEqBU.mjs → types-BLnsGaJf-m-qTW3ox.mjs} +3 -3
  182. package/dist/{types-BPi4d3WI-D8PIEqBU.mjs.map → types-BLnsGaJf-m-qTW3ox.mjs.map} +1 -1
  183. package/dist/{types-ByKpjyVh-CtYwWrbL.d.mts → types-CcGO_LSh-BKHiJvvA.d.mts} +8 -26
  184. package/dist/types-CcGO_LSh-BKHiJvvA.d.mts.map +1 -0
  185. package/dist/{types-Z-l6gAVD.mjs → types-Cn4JEguu.mjs} +2 -2
  186. package/dist/{types-Z-l6gAVD.mjs.map → types-Cn4JEguu.mjs.map} +1 -1
  187. package/dist/{types-DAoMCSPl-D2ajBTpK.mjs → types-CyPuXMTn-pumFirZ6.mjs} +4 -7
  188. package/dist/types-CyPuXMTn-pumFirZ6.mjs.map +1 -0
  189. package/dist/types-DZA5xxDT.d.mts +1 -0
  190. package/dist/{types-BzpC_V7p-DyBYmK1f.d.mts → types-Da1Y_OI7-BPyFwdFU.d.mts} +4 -43
  191. package/dist/types-Da1Y_OI7-BPyFwdFU.d.mts.map +1 -0
  192. package/dist/{types-BGHABElw-C5dqoVCg.d.mts → types-DpwLgzPO-Cb9nQ-Wt.d.mts} +6 -6
  193. package/dist/{types-BGHABElw-C5dqoVCg.d.mts.map → types-DpwLgzPO-Cb9nQ-Wt.d.mts.map} +1 -1
  194. package/dist/{types-Yui2yFf6-DYiGm9ET.d.mts → types-Dskga3R1-BtXuRmbf.d.mts} +3 -3
  195. package/dist/{types-Yui2yFf6-DYiGm9ET.d.mts.map → types-Dskga3R1-BtXuRmbf.d.mts.map} +1 -1
  196. package/dist/types-QvcS13Qc.d.mts +1 -0
  197. package/dist/{validators-D1wQns12.d.mts → validators-B-4g3vwP.d.mts} +2 -2
  198. package/dist/{validators-D1wQns12.d.mts.map → validators-B-4g3vwP.d.mts.map} +1 -1
  199. package/dist/{validators-Cx6UXIBf.mjs → validators-IGdAEEIM.mjs} +4 -4
  200. package/dist/{validators-Cx6UXIBf.mjs.map → validators-IGdAEEIM.mjs.map} +1 -1
  201. package/dist/{verify-BVk5bjdH-BXgGLM2U.mjs → verify-BVk5bjdH-dq5M4iIh.mjs} +2 -2
  202. package/dist/{verify-BVk5bjdH-BXgGLM2U.mjs.map → verify-BVk5bjdH-dq5M4iIh.mjs.map} +1 -1
  203. package/package.json +20 -18
  204. package/dist/ast-5hifzBHC.mjs.map +0 -1
  205. package/dist/ast-dPjHeaNs.d.mts.map +0 -1
  206. package/dist/authoring-type-constructors-DIyheCzv-BSrAEZsD.mjs.map +0 -1
  207. package/dist/config-types-DNRmpGNL.mjs.map +0 -1
  208. package/dist/contract-builder-Br5TlHMh.d.mts.map +0 -1
  209. package/dist/contract-builder-C3MYW38z.mjs.map +0 -1
  210. package/dist/control-BYOcSVih.mjs.map +0 -1
  211. package/dist/control-DL9y6GfG.d.mts.map +0 -1
  212. package/dist/control-adapter-C1hjk3Ic.d.mts +0 -1
  213. package/dist/control-adapter-WoXvPNj4-D64oWh9I.d.mts.map +0 -1
  214. package/dist/derived-checks-C_y1rk6O-DwCaGICl.mjs.map +0 -1
  215. package/dist/interpreter-C8cP92FD-BfjuQvb1.mjs.map +0 -1
  216. package/dist/middleware-CN4vQuOi.d.mts +0 -1
  217. package/dist/pack-C3mqZevM.d.mts.map +0 -1
  218. package/dist/plan-B7g2kDfQ-Dth0BeTe.d.mts.map +0 -1
  219. package/dist/plan-CrKSowWJ.d.mts +0 -2
  220. package/dist/psl-build-BnM1ZTyK.d.mts.map +0 -1
  221. package/dist/psl-build-zkIJwkdq.mjs.map +0 -1
  222. package/dist/psl-column-resolution-sNpXQygQ-BBo4tqwO.d.mts.map +0 -1
  223. package/dist/psl-field-resolution-_o74AUE4-C-vTNklI.mjs.map +0 -1
  224. package/dist/query-lane-context-BSmWfohZ-Jn0AbOQt.d.mts.map +0 -1
  225. package/dist/query-lane-context-DWdmmnrN.d.mts +0 -1
  226. package/dist/schema-verify-Xmpe1PGb-Bcd_2avJ.mjs.map +0 -1
  227. package/dist/sql-execution-plan-Db0j752I-dJ-JGxbD.d.mts.map +0 -1
  228. package/dist/type-map-DpfnXzun-DZaSuJXh.d.mts.map +0 -1
  229. package/dist/types-ByKpjyVh-CtYwWrbL.d.mts.map +0 -1
  230. package/dist/types-BzpC_V7p-DyBYmK1f.d.mts.map +0 -1
  231. package/dist/types-CQBRYgDW.d.mts +0 -1
  232. package/dist/types-DAoMCSPl-D2ajBTpK.mjs.map +0 -1
  233. package/dist/types-DdTdsdMn.d.mts +0 -1
@@ -0,0 +1,297 @@
1
+ import { t as contractError } from "./contract-errors-BCN6RVI5-5IHBF_lg.mjs";
2
+ import { dataType, objectSchemaKeys } from "@prisma/orm-framework/components/codec";
3
+ import { blindCast } from "@prisma/orm-framework/utils/casts";
4
+ import { ifDefined } from "@prisma/orm-framework/utils/defined";
5
+ import { InternalError } from "@prisma/orm-framework/utils/internal-error";
6
+ import { type } from "arktype";
7
+ //#region ../../../2-sql/1-core/contract/dist/data-type.mjs
8
+ const PLACEHOLDER = /\{([A-Za-z][A-Za-z0-9]*)\}/g;
9
+ const LITERAL_CHARACTERS = /^[a-z0-9_ (),.]*$/;
10
+ const REGEXP_SPECIAL = /[.*+?^${}()|[\]\\]/g;
11
+ function paramKeysOf(id, schema) {
12
+ if (schema === void 0) return [];
13
+ const keys = objectSchemaKeys(schema);
14
+ if (keys === void 0) refuseDeclaration(id, "its parameter schema must be an arktype object schema.");
15
+ return keys;
16
+ }
17
+ function placeholdersOf(text) {
18
+ return [...text.matchAll(PLACEHOLDER)].map((match) => match[1] ?? "");
19
+ }
20
+ function placeholderSetOf(text) {
21
+ return [...placeholdersOf(text)].sort().join(",");
22
+ }
23
+ function patternOf(text) {
24
+ const escaped = text.replace(REGEXP_SPECIAL, "\\$&");
25
+ return new RegExp(`^${escaped.replace(/\\\{[A-Za-z][A-Za-z0-9]*\\\}/g, "(\\d+)")}$`);
26
+ }
27
+ function refuseDeclaration(id, why) {
28
+ throw new InternalError(`Data type ${id}: ${why}`);
29
+ }
30
+ function checkText(id, text, paramKeys) {
31
+ const quoted = JSON.stringify(text.text);
32
+ const refuse = (why) => refuseDeclaration(id, `the text ${quoted} ${why}.`);
33
+ if (text.text === "") refuse("is empty");
34
+ if (text.text !== text.text.trim()) refuse("starts or ends with a space");
35
+ if (text.text.includes(" ")) refuse("has two spaces in a row");
36
+ const literal = text.text.replace(PLACEHOLDER, "");
37
+ if (literal.includes("{") || literal.includes("}")) refuse("has a placeholder that is not written {name}");
38
+ if (!LITERAL_CHARACTERS.test(literal)) refuse("must be lower case and contain only letters, digits, spaces, brackets, commas, dots, underscores and placeholders");
39
+ for (const name of placeholdersOf(text.text)) if (!paramKeys.includes(name)) refuse(`names the parameter {${name}}, which the type does not declare`);
40
+ if (text.display === void 0) return;
41
+ const display = JSON.stringify(text.display);
42
+ if (text.display.toLowerCase() !== text.text.toLowerCase()) refuse(`has the display ${display}, which differs from it beyond letter case`);
43
+ if (placeholdersOf(text.display).join(",") !== placeholdersOf(text.text).join(",")) refuse(`has the display ${display}, which writes a placeholder differently`);
44
+ }
45
+ function checkMarks(id, texts) {
46
+ const marked = /* @__PURE__ */ new Map();
47
+ for (const text of texts) {
48
+ const key = placeholderSetOf(text.text);
49
+ const entry = marked.get(key) ?? {};
50
+ for (const mark of ["written", "catalog"]) {
51
+ if (text[mark] !== true) continue;
52
+ const other = entry[mark];
53
+ if (other !== void 0) refuseDeclaration(id, `the texts ${JSON.stringify(other)} and ${JSON.stringify(text.text)} have the same placeholders and are both ${mark}.`);
54
+ entry[mark] = text.text;
55
+ }
56
+ marked.set(key, entry);
57
+ }
58
+ }
59
+ function checkKindClaim(id, spec) {
60
+ if (spec.claimsKind === void 0) {
61
+ if (spec.render !== void 0) refuseDeclaration(id, "render is allowed only together with claimsKind.");
62
+ if (spec.fromReported !== void 0) refuseDeclaration(id, "fromReported is allowed only together with claimsKind.");
63
+ return;
64
+ }
65
+ if (spec.texts !== void 0) refuseDeclaration(id, "a type that claims a kind declares no texts.");
66
+ }
67
+ const identity = (params) => params;
68
+ function acceptsParams(type$1, params) {
69
+ return type$1.params === void 0 || !(type$1.params(params) instanceof type.errors);
70
+ }
71
+ function checkNormalFormsWritten(type) {
72
+ const written = new Set(type.sql.texts.filter((text) => text.written === true).map((text) => placeholderSetOf(text.text)));
73
+ if (written.size === 0) return;
74
+ const probes = [{}, ...type.sql.texts.map((text) => Object.fromEntries(placeholdersOf(text.text).map((name) => [name, 1])))];
75
+ for (const probe of probes) {
76
+ if (!acceptsParams(type, probe)) continue;
77
+ const normalKeys = presentKeys(type.sql.normalize(probe));
78
+ if (!written.has([...normalKeys].sort().join(","))) refuseDeclaration(type.id, `the parameters ${formatKeys(Object.keys(probe))} have the normal form ${formatKeys(normalKeys)}, which no written text takes.`);
79
+ }
80
+ }
81
+ /** Declare a SQL data type, refusing a declaration that breaks a rule of the module. */
82
+ function sqlDataType(id, spec) {
83
+ const { params: _untypedParams, ...declared } = dataType(id, spec);
84
+ const texts = spec.texts ?? [];
85
+ const paramKeys = paramKeysOf(declared.id, spec.params);
86
+ for (const text of texts) checkText(declared.id, text, paramKeys);
87
+ checkMarks(declared.id, texts);
88
+ checkKindClaim(declared.id, spec);
89
+ const type = {
90
+ ...declared,
91
+ ...ifDefined("params", spec.params),
92
+ sql: {
93
+ texts,
94
+ claimsKind: spec.claimsKind,
95
+ normalize: spec.normalize ?? identity,
96
+ render: spec.render,
97
+ fromReported: spec.fromReported
98
+ }
99
+ };
100
+ checkNormalFormsWritten(type);
101
+ return type;
102
+ }
103
+ /** Whether `type` is a data type a SQL column can have. `sql/expression` is the one data type no column has. */
104
+ function isSqlDataType(type) {
105
+ return "sql" in type;
106
+ }
107
+ /** The parameters of `typeParams` that `type` declares; codec-owned keys are dropped. */
108
+ function dataTypeParams(type, typeParams) {
109
+ if (typeParams === void 0) return {};
110
+ const kept = {};
111
+ for (const key of paramKeysOf(type.id, type.params)) if (Object.hasOwn(typeParams, key)) kept[key] = typeParams[key];
112
+ return kept;
113
+ }
114
+ function presentKeys(params) {
115
+ return Object.keys(params).filter((key) => params[key] !== void 0);
116
+ }
117
+ function formatKeys(keys) {
118
+ return `[${[...keys].sort().join(", ")}]`;
119
+ }
120
+ /** The parameters, when `type` accepts them; otherwise `CONTRACT.TYPE_PARAMS_INVALID` naming each parameter at fault. */
121
+ function validateSqlTypeParams(type$2, params) {
122
+ if (type$2.params === void 0) return blindCast(params);
123
+ const result = type$2.params(params);
124
+ if (result instanceof type.errors) throw contractError("CONTRACT.TYPE_PARAMS_INVALID", `${type$2.id}: ${result.summary}`, { meta: {
125
+ dataType: type$2.id,
126
+ parameters: [...new Set(result.map((error) => error.path.map(String).join(".")))]
127
+ } });
128
+ return blindCast(params);
129
+ }
130
+ function pickText(type, mark, keys) {
131
+ const candidates = type.sql.texts.filter((text) => text[mark] === true);
132
+ const wanted = [...keys].sort().join(",");
133
+ const found = candidates.find((text) => placeholderSetOf(text.text) === wanted);
134
+ if (found !== void 0) return found;
135
+ const verb = mark === "written" ? "written" : "reported";
136
+ const takes = candidates.length === 0 ? `it is never ${verb}` : `it is ${verb} with ${candidates.map((text) => formatKeys(placeholdersOf(text.text))).join(", ")}`;
137
+ throw contractError("CONTRACT.TYPE_PARAMS_INVALID", `${type.id} cannot be ${verb} with parameters ${formatKeys(keys)}; ${takes}`, { meta: {
138
+ dataType: type.id,
139
+ parameters: [...keys]
140
+ } });
141
+ }
142
+ function substitute(type, text, params) {
143
+ return (text.display ?? text.text).replace(PLACEHOLDER, (_, name) => {
144
+ const value = params[name];
145
+ if (!Number.isSafeInteger(value)) throw contractError("CONTRACT.TYPE_PARAMS_INVALID", `${type.id}: the parameter ${name} is written into the type name and must be an integer`, { meta: {
146
+ dataType: type.id,
147
+ parameters: [name]
148
+ } });
149
+ return String(value);
150
+ });
151
+ }
152
+ /** The name of `type` with no parameters, for places where parameters must not appear. */
153
+ function sqlBaseName(type, params) {
154
+ if (type.sql.render !== void 0) return type.sql.render(validateSqlTypeParams(type, params));
155
+ const fewest = type.sql.texts.filter((text) => text.written === true).reduce((best, text) => best === void 0 || placeholdersOf(text.text).length < placeholdersOf(best.text).length ? text : best, void 0);
156
+ if (fewest === void 0) throw new InternalError(`Data type ${type.id} has no written text and no render, so it has no base name.`);
157
+ const name = fewest.display ?? fewest.text;
158
+ if (placeholdersOf(fewest.text).length === 0) return name;
159
+ const bracket = name.indexOf("(");
160
+ return bracket === -1 ? name : name.slice(0, bracket);
161
+ }
162
+ /**
163
+ * The base name of `type` with `params`, unquoted. It differs from {@link sqlBaseName} only for a
164
+ * type that claims a kind: there it is the `typeName` parameter as written (`app.status`), where
165
+ * `sqlBaseName` gives the quoted name `render` writes into SQL (`"app"."status"`).
166
+ */
167
+ function unquotedSqlBaseName(type, params) {
168
+ if (type.sql.claimsKind === void 0) return sqlBaseName(type, params);
169
+ const { typeName } = validateSqlTypeParams(type, params);
170
+ if (typeof typeName !== "string") throw new InternalError(`Data type ${type.id} claims the kind "${type.sql.claimsKind}" but declares no string typeName parameter.`);
171
+ return typeName;
172
+ }
173
+ const ADD_THE_CODEC_PACK = "Add the pack that provides the codec, and so declares its data type, to the configuration: to `extensions` in prisma.config or in defineContract.";
174
+ /** The SQL data type the codec `codecId` represents. */
175
+ function sqlDataTypeOfCodec(codecId, lookups) {
176
+ const descriptor = lookups.codecLookup.descriptorFor(codecId);
177
+ if (descriptor === void 0) throw contractError("CONTRACT.CODEC_DESCRIPTOR_MISSING", `No codec "${codecId}" is registered, so its column type cannot be named.`, {
178
+ fix: ADD_THE_CODEC_PACK,
179
+ meta: { codecId }
180
+ });
181
+ const type = lookups.dataTypeLookup.get(descriptor.dataType);
182
+ if (type === void 0) throw contractError("CONTRACT.DATA_TYPE_UNREGISTERED", `Codec "${codecId}" represents data type "${descriptor.dataType}", which no component registers.`, {
183
+ fix: ADD_THE_CODEC_PACK,
184
+ meta: {
185
+ codecId,
186
+ dataType: descriptor.dataType
187
+ }
188
+ });
189
+ if (!isSqlDataType(type)) throw new InternalError(`Data type ${type.id} is not a SQL data type, so it has no type name.`);
190
+ return type;
191
+ }
192
+ /** {@link unquotedSqlBaseName} of the data type the codec `codecId` represents. */
193
+ function unquotedSqlBaseNameOfCodec(codecId, typeParams, lookups) {
194
+ const type = sqlDataTypeOfCodec(codecId, lookups);
195
+ return unquotedSqlBaseName(type, dataTypeParams(type, typeParams));
196
+ }
197
+ /** The text a migration writes for `type` with the raw `params`. */
198
+ function renderSqlTypeName(type, params) {
199
+ const validated = validateSqlTypeParams(type, params);
200
+ if (type.sql.render !== void 0) return type.sql.render(validated);
201
+ const normalized = type.sql.normalize(validated);
202
+ return substitute(type, pickText(type, "written", presentKeys(params).filter((key) => Object.hasOwn(normalized, key))), params);
203
+ }
204
+ /** The text the database catalog prints for `type` with `params`, in their normal form. */
205
+ function renderSqlCatalogText(type, params) {
206
+ const validated = validateSqlTypeParams(type, params);
207
+ if (type.sql.claimsKind !== void 0) throw new InternalError(`Data type ${type.id} claims the kind "${type.sql.claimsKind}" and has no catalog text.`);
208
+ const normalized = type.sql.normalize(validated);
209
+ return substitute(type, pickText(type, "catalog", presentKeys(normalized)), normalized);
210
+ }
211
+ function prepareReportedText(text) {
212
+ let prepared = "";
213
+ let quoted = false;
214
+ let spacePending = false;
215
+ for (const character of text.trim()) {
216
+ if (!quoted && /\s/.test(character)) {
217
+ spacePending = true;
218
+ continue;
219
+ }
220
+ if (spacePending && !/[(,]$/.test(prepared) && character !== ")") prepared += " ";
221
+ spacePending = false;
222
+ if (character === "\"") quoted = !quoted;
223
+ prepared += quoted ? character : character.toLowerCase();
224
+ }
225
+ return prepared;
226
+ }
227
+ function claims(text) {
228
+ return text.catalog === true || text.written !== true;
229
+ }
230
+ function claimingTexts(type) {
231
+ return type.sql.texts.filter(claims).map((text) => text.text);
232
+ }
233
+ function textsCollide(a, b) {
234
+ const withOnes = (text) => text.replace(PLACEHOLDER, "1");
235
+ return patternOf(a).test(withOnes(b)) || patternOf(b).test(withOnes(a));
236
+ }
237
+ function collisionBetween(first, second) {
238
+ const kind = first.sql.claimsKind;
239
+ if (kind !== void 0 && kind === second.sql.claimsKind) return {
240
+ by: "kind",
241
+ kind
242
+ };
243
+ for (const a of claimingTexts(first)) {
244
+ const b = claimingTexts(second).find((text) => textsCollide(a, text));
245
+ if (b !== void 0) return {
246
+ by: "text",
247
+ first: a,
248
+ second: b
249
+ };
250
+ }
251
+ }
252
+ /**
253
+ * The first two SQL data types in `types` that would both recognise one reported type: a claiming
254
+ * text of each collides, or both claim the same kind. Two texts collide when either one's pattern
255
+ * matches the other with each placeholder written as 1.
256
+ */
257
+ function findSqlDataTypeCollision(types) {
258
+ const sqlTypes = types.filter(isSqlDataType);
259
+ for (const [index, first] of sqlTypes.entries()) for (const second of sqlTypes.slice(index + 1)) {
260
+ const claims = collisionBetween(first, second);
261
+ if (claims !== void 0) return {
262
+ first,
263
+ second,
264
+ claims
265
+ };
266
+ }
267
+ }
268
+ /**
269
+ * The data type that claims a reported type, with its parameters in normal form, or undefined when
270
+ * no type in `dataTypes` claims it or its parameters fail the type's schema.
271
+ */
272
+ function resolveReportedSqlType(reported, dataTypes) {
273
+ const sqlTypes = dataTypes.filter(isSqlDataType);
274
+ if (reported.kind !== void 0) {
275
+ const claimant = sqlTypes.find((type) => type.sql.claimsKind === reported.kind);
276
+ if (claimant === void 0) return void 0;
277
+ return resolvedWith(claimant, claimant.sql.fromReported?.(reported) ?? {});
278
+ }
279
+ const text = prepareReportedText(reported.text);
280
+ for (const type of sqlTypes) for (const candidate of type.sql.texts) {
281
+ if (!claims(candidate)) continue;
282
+ const match = patternOf(candidate.text).exec(text);
283
+ if (match === null) continue;
284
+ return resolvedWith(type, Object.fromEntries(placeholdersOf(candidate.text).map((name, index) => [name, Number.parseInt(match[index + 1] ?? "", 10)])));
285
+ }
286
+ }
287
+ function resolvedWith(type$3, params) {
288
+ if (type$3.params !== void 0 && type$3.params(params) instanceof type.errors) return void 0;
289
+ return {
290
+ dataType: type$3.id,
291
+ typeParams: type$3.sql.normalize(params)
292
+ };
293
+ }
294
+ //#endregion
295
+ export { renderSqlTypeName as a, sqlDataType as c, unquotedSqlBaseNameOfCodec as d, validateSqlTypeParams as f, renderSqlCatalogText as i, sqlDataTypeOfCodec as l, findSqlDataTypeCollision as n, resolveReportedSqlType as o, isSqlDataType as r, sqlBaseName as s, dataTypeParams as t, unquotedSqlBaseName as u };
296
+
297
+ //# sourceMappingURL=data-type-CAPmGXg9.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data-type-CAPmGXg9.mjs","names":[],"sources":["../../../../2-sql/1-core/contract/dist/data-type.mjs"],"sourcesContent":["import { t as contractError } from \"./contract-errors-BCN6RVI5.mjs\";\nimport { t as numeralText } from \"./numeral-text-Cqu87pVe.mjs\";\nimport { dataType, objectSchemaKeys } from \"@internal/framework-components/codec\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { InternalError } from \"@internal/utils/internal-error\";\nimport { type } from \"arktype\";\n//#region src/sql-data-type.ts\nconst PLACEHOLDER = /\\{([A-Za-z][A-Za-z0-9]*)\\}/g;\nconst LITERAL_CHARACTERS = /^[a-z0-9_ (),.]*$/;\nconst REGEXP_SPECIAL = /[.*+?^${}()|[\\]\\\\]/g;\nfunction paramKeysOf(id, schema) {\n\tif (schema === void 0) return [];\n\tconst keys = objectSchemaKeys(schema);\n\tif (keys === void 0) refuseDeclaration(id, \"its parameter schema must be an arktype object schema.\");\n\treturn keys;\n}\nfunction placeholdersOf(text) {\n\treturn [...text.matchAll(PLACEHOLDER)].map((match) => match[1] ?? \"\");\n}\nfunction placeholderSetOf(text) {\n\treturn [...placeholdersOf(text)].sort().join(\",\");\n}\nfunction patternOf(text) {\n\tconst escaped = text.replace(REGEXP_SPECIAL, \"\\\\$&\");\n\treturn new RegExp(`^${escaped.replace(/\\\\\\{[A-Za-z][A-Za-z0-9]*\\\\\\}/g, \"(\\\\d+)\")}$`);\n}\nfunction refuseDeclaration(id, why) {\n\tthrow new InternalError(`Data type ${id}: ${why}`);\n}\nfunction checkText(id, text, paramKeys) {\n\tconst quoted = JSON.stringify(text.text);\n\tconst refuse = (why) => refuseDeclaration(id, `the text ${quoted} ${why}.`);\n\tif (text.text === \"\") refuse(\"is empty\");\n\tif (text.text !== text.text.trim()) refuse(\"starts or ends with a space\");\n\tif (text.text.includes(\" \")) refuse(\"has two spaces in a row\");\n\tconst literal = text.text.replace(PLACEHOLDER, \"\");\n\tif (literal.includes(\"{\") || literal.includes(\"}\")) refuse(\"has a placeholder that is not written {name}\");\n\tif (!LITERAL_CHARACTERS.test(literal)) refuse(\"must be lower case and contain only letters, digits, spaces, brackets, commas, dots, underscores and placeholders\");\n\tfor (const name of placeholdersOf(text.text)) if (!paramKeys.includes(name)) refuse(`names the parameter {${name}}, which the type does not declare`);\n\tif (text.display === void 0) return;\n\tconst display = JSON.stringify(text.display);\n\tif (text.display.toLowerCase() !== text.text.toLowerCase()) refuse(`has the display ${display}, which differs from it beyond letter case`);\n\tif (placeholdersOf(text.display).join(\",\") !== placeholdersOf(text.text).join(\",\")) refuse(`has the display ${display}, which writes a placeholder differently`);\n}\nfunction checkMarks(id, texts) {\n\tconst marked = /* @__PURE__ */ new Map();\n\tfor (const text of texts) {\n\t\tconst key = placeholderSetOf(text.text);\n\t\tconst entry = marked.get(key) ?? {};\n\t\tfor (const mark of [\"written\", \"catalog\"]) {\n\t\t\tif (text[mark] !== true) continue;\n\t\t\tconst other = entry[mark];\n\t\t\tif (other !== void 0) refuseDeclaration(id, `the texts ${JSON.stringify(other)} and ${JSON.stringify(text.text)} have the same placeholders and are both ${mark}.`);\n\t\t\tentry[mark] = text.text;\n\t\t}\n\t\tmarked.set(key, entry);\n\t}\n}\nfunction checkKindClaim(id, spec) {\n\tif (spec.claimsKind === void 0) {\n\t\tif (spec.render !== void 0) refuseDeclaration(id, \"render is allowed only together with claimsKind.\");\n\t\tif (spec.fromReported !== void 0) refuseDeclaration(id, \"fromReported is allowed only together with claimsKind.\");\n\t\treturn;\n\t}\n\tif (spec.texts !== void 0) refuseDeclaration(id, \"a type that claims a kind declares no texts.\");\n}\nconst identity = (params) => params;\nfunction acceptsParams(type$1, params) {\n\treturn type$1.params === void 0 || !(type$1.params(params) instanceof type.errors);\n}\nfunction checkNormalFormsWritten(type) {\n\tconst written = new Set(type.sql.texts.filter((text) => text.written === true).map((text) => placeholderSetOf(text.text)));\n\tif (written.size === 0) return;\n\tconst probes = [{}, ...type.sql.texts.map((text) => Object.fromEntries(placeholdersOf(text.text).map((name) => [name, 1])))];\n\tfor (const probe of probes) {\n\t\tif (!acceptsParams(type, probe)) continue;\n\t\tconst normalKeys = presentKeys(type.sql.normalize(probe));\n\t\tif (!written.has([...normalKeys].sort().join(\",\"))) refuseDeclaration(type.id, `the parameters ${formatKeys(Object.keys(probe))} have the normal form ${formatKeys(normalKeys)}, which no written text takes.`);\n\t}\n}\n/** Declare a SQL data type, refusing a declaration that breaks a rule of the module. */\nfunction sqlDataType(id, spec) {\n\tconst { params: _untypedParams, ...declared } = dataType(id, spec);\n\tconst texts = spec.texts ?? [];\n\tconst paramKeys = paramKeysOf(declared.id, spec.params);\n\tfor (const text of texts) checkText(declared.id, text, paramKeys);\n\tcheckMarks(declared.id, texts);\n\tcheckKindClaim(declared.id, spec);\n\tconst type = {\n\t\t...declared,\n\t\t...ifDefined(\"params\", spec.params),\n\t\tsql: {\n\t\t\ttexts,\n\t\t\tclaimsKind: spec.claimsKind,\n\t\t\tnormalize: spec.normalize ?? identity,\n\t\t\trender: spec.render,\n\t\t\tfromReported: spec.fromReported\n\t\t}\n\t};\n\tcheckNormalFormsWritten(type);\n\treturn type;\n}\n/** Whether `type` is a data type a SQL column can have. `sql/expression` is the one data type no column has. */\nfunction isSqlDataType(type) {\n\treturn \"sql\" in type;\n}\n/** The parameters of `typeParams` that `type` declares; codec-owned keys are dropped. */\nfunction dataTypeParams(type, typeParams) {\n\tif (typeParams === void 0) return {};\n\tconst kept = {};\n\tfor (const key of paramKeysOf(type.id, type.params)) if (Object.hasOwn(typeParams, key)) kept[key] = typeParams[key];\n\treturn kept;\n}\nfunction presentKeys(params) {\n\treturn Object.keys(params).filter((key) => params[key] !== void 0);\n}\nfunction formatKeys(keys) {\n\treturn `[${[...keys].sort().join(\", \")}]`;\n}\n/** The parameters, when `type` accepts them; otherwise `CONTRACT.TYPE_PARAMS_INVALID` naming each parameter at fault. */\nfunction validateSqlTypeParams(type$2, params) {\n\tif (type$2.params === void 0) return blindCast(params);\n\tconst result = type$2.params(params);\n\tif (result instanceof type.errors) throw contractError(\"CONTRACT.TYPE_PARAMS_INVALID\", `${type$2.id}: ${result.summary}`, { meta: {\n\t\tdataType: type$2.id,\n\t\tparameters: [...new Set(result.map((error) => error.path.map(String).join(\".\")))]\n\t} });\n\treturn blindCast(params);\n}\nfunction pickText(type, mark, keys) {\n\tconst candidates = type.sql.texts.filter((text) => text[mark] === true);\n\tconst wanted = [...keys].sort().join(\",\");\n\tconst found = candidates.find((text) => placeholderSetOf(text.text) === wanted);\n\tif (found !== void 0) return found;\n\tconst verb = mark === \"written\" ? \"written\" : \"reported\";\n\tconst takes = candidates.length === 0 ? `it is never ${verb}` : `it is ${verb} with ${candidates.map((text) => formatKeys(placeholdersOf(text.text))).join(\", \")}`;\n\tthrow contractError(\"CONTRACT.TYPE_PARAMS_INVALID\", `${type.id} cannot be ${verb} with parameters ${formatKeys(keys)}; ${takes}`, { meta: {\n\t\tdataType: type.id,\n\t\tparameters: [...keys]\n\t} });\n}\nfunction substitute(type, text, params) {\n\treturn (text.display ?? text.text).replace(PLACEHOLDER, (_, name) => {\n\t\tconst value = params[name];\n\t\tif (!Number.isSafeInteger(value)) throw contractError(\"CONTRACT.TYPE_PARAMS_INVALID\", `${type.id}: the parameter ${name} is written into the type name and must be an integer`, { meta: {\n\t\t\tdataType: type.id,\n\t\t\tparameters: [name]\n\t\t} });\n\t\treturn String(value);\n\t});\n}\n/** The name of `type` with no parameters, for places where parameters must not appear. */\nfunction sqlBaseName(type, params) {\n\tif (type.sql.render !== void 0) return type.sql.render(validateSqlTypeParams(type, params));\n\tconst fewest = type.sql.texts.filter((text) => text.written === true).reduce((best, text) => best === void 0 || placeholdersOf(text.text).length < placeholdersOf(best.text).length ? text : best, void 0);\n\tif (fewest === void 0) throw new InternalError(`Data type ${type.id} has no written text and no render, so it has no base name.`);\n\tconst name = fewest.display ?? fewest.text;\n\tif (placeholdersOf(fewest.text).length === 0) return name;\n\tconst bracket = name.indexOf(\"(\");\n\treturn bracket === -1 ? name : name.slice(0, bracket);\n}\n/**\n* The base name of `type` with `params`, unquoted. It differs from {@link sqlBaseName} only for a\n* type that claims a kind: there it is the `typeName` parameter as written (`app.status`), where\n* `sqlBaseName` gives the quoted name `render` writes into SQL (`\"app\".\"status\"`).\n*/\nfunction unquotedSqlBaseName(type, params) {\n\tif (type.sql.claimsKind === void 0) return sqlBaseName(type, params);\n\tconst { typeName } = validateSqlTypeParams(type, params);\n\tif (typeof typeName !== \"string\") throw new InternalError(`Data type ${type.id} claims the kind \"${type.sql.claimsKind}\" but declares no string typeName parameter.`);\n\treturn typeName;\n}\nconst ADD_THE_CODEC_PACK = \"Add the pack that provides the codec, and so declares its data type, to the configuration: to `extensions` in prisma.config or in defineContract.\";\n/** The SQL data type the codec `codecId` represents. */\nfunction sqlDataTypeOfCodec(codecId, lookups) {\n\tconst descriptor = lookups.codecLookup.descriptorFor(codecId);\n\tif (descriptor === void 0) throw contractError(\"CONTRACT.CODEC_DESCRIPTOR_MISSING\", `No codec \"${codecId}\" is registered, so its column type cannot be named.`, {\n\t\tfix: ADD_THE_CODEC_PACK,\n\t\tmeta: { codecId }\n\t});\n\tconst type = lookups.dataTypeLookup.get(descriptor.dataType);\n\tif (type === void 0) throw contractError(\"CONTRACT.DATA_TYPE_UNREGISTERED\", `Codec \"${codecId}\" represents data type \"${descriptor.dataType}\", which no component registers.`, {\n\t\tfix: ADD_THE_CODEC_PACK,\n\t\tmeta: {\n\t\t\tcodecId,\n\t\t\tdataType: descriptor.dataType\n\t\t}\n\t});\n\tif (!isSqlDataType(type)) throw new InternalError(`Data type ${type.id} is not a SQL data type, so it has no type name.`);\n\treturn type;\n}\n/** {@link unquotedSqlBaseName} of the data type the codec `codecId` represents. */\nfunction unquotedSqlBaseNameOfCodec(codecId, typeParams, lookups) {\n\tconst type = sqlDataTypeOfCodec(codecId, lookups);\n\treturn unquotedSqlBaseName(type, dataTypeParams(type, typeParams));\n}\n/** The text a migration writes for `type` with the raw `params`. */\nfunction renderSqlTypeName(type, params) {\n\tconst validated = validateSqlTypeParams(type, params);\n\tif (type.sql.render !== void 0) return type.sql.render(validated);\n\tconst normalized = type.sql.normalize(validated);\n\treturn substitute(type, pickText(type, \"written\", presentKeys(params).filter((key) => Object.hasOwn(normalized, key))), params);\n}\n/** The text the database catalog prints for `type` with `params`, in their normal form. */\nfunction renderSqlCatalogText(type, params) {\n\tconst validated = validateSqlTypeParams(type, params);\n\tif (type.sql.claimsKind !== void 0) throw new InternalError(`Data type ${type.id} claims the kind \"${type.sql.claimsKind}\" and has no catalog text.`);\n\tconst normalized = type.sql.normalize(validated);\n\treturn substitute(type, pickText(type, \"catalog\", presentKeys(normalized)), normalized);\n}\nfunction prepareReportedText(text) {\n\tlet prepared = \"\";\n\tlet quoted = false;\n\tlet spacePending = false;\n\tfor (const character of text.trim()) {\n\t\tif (!quoted && /\\s/.test(character)) {\n\t\t\tspacePending = true;\n\t\t\tcontinue;\n\t\t}\n\t\tif (spacePending && !/[(,]$/.test(prepared) && character !== \")\") prepared += \" \";\n\t\tspacePending = false;\n\t\tif (character === \"\\\"\") quoted = !quoted;\n\t\tprepared += quoted ? character : character.toLowerCase();\n\t}\n\treturn prepared;\n}\nfunction claims(text) {\n\treturn text.catalog === true || text.written !== true;\n}\nfunction claimingTexts(type) {\n\treturn type.sql.texts.filter(claims).map((text) => text.text);\n}\nfunction textsCollide(a, b) {\n\tconst withOnes = (text) => text.replace(PLACEHOLDER, \"1\");\n\treturn patternOf(a).test(withOnes(b)) || patternOf(b).test(withOnes(a));\n}\nfunction collisionBetween(first, second) {\n\tconst kind = first.sql.claimsKind;\n\tif (kind !== void 0 && kind === second.sql.claimsKind) return {\n\t\tby: \"kind\",\n\t\tkind\n\t};\n\tfor (const a of claimingTexts(first)) {\n\t\tconst b = claimingTexts(second).find((text) => textsCollide(a, text));\n\t\tif (b !== void 0) return {\n\t\t\tby: \"text\",\n\t\t\tfirst: a,\n\t\t\tsecond: b\n\t\t};\n\t}\n}\n/**\n* The first two SQL data types in `types` that would both recognise one reported type: a claiming\n* text of each collides, or both claim the same kind. Two texts collide when either one's pattern\n* matches the other with each placeholder written as 1.\n*/\nfunction findSqlDataTypeCollision(types) {\n\tconst sqlTypes = types.filter(isSqlDataType);\n\tfor (const [index, first] of sqlTypes.entries()) for (const second of sqlTypes.slice(index + 1)) {\n\t\tconst claims = collisionBetween(first, second);\n\t\tif (claims !== void 0) return {\n\t\t\tfirst,\n\t\t\tsecond,\n\t\t\tclaims\n\t\t};\n\t}\n}\n/**\n* The data type that claims a reported type, with its parameters in normal form, or undefined when\n* no type in `dataTypes` claims it or its parameters fail the type's schema.\n*/\nfunction resolveReportedSqlType(reported, dataTypes) {\n\tconst sqlTypes = dataTypes.filter(isSqlDataType);\n\tif (reported.kind !== void 0) {\n\t\tconst claimant = sqlTypes.find((type) => type.sql.claimsKind === reported.kind);\n\t\tif (claimant === void 0) return void 0;\n\t\treturn resolvedWith(claimant, claimant.sql.fromReported?.(reported) ?? {});\n\t}\n\tconst text = prepareReportedText(reported.text);\n\tfor (const type of sqlTypes) for (const candidate of type.sql.texts) {\n\t\tif (!claims(candidate)) continue;\n\t\tconst match = patternOf(candidate.text).exec(text);\n\t\tif (match === null) continue;\n\t\treturn resolvedWith(type, Object.fromEntries(placeholdersOf(candidate.text).map((name, index) => [name, Number.parseInt(match[index + 1] ?? \"\", 10)])));\n\t}\n}\nfunction resolvedWith(type$3, params) {\n\tif (type$3.params !== void 0 && type$3.params(params) instanceof type.errors) return void 0;\n\treturn {\n\t\tdataType: type$3.id,\n\t\ttypeParams: type$3.sql.normalize(params)\n\t};\n}\n//#endregion\nexport { dataTypeParams, findSqlDataTypeCollision, isSqlDataType, numeralText, renderSqlCatalogText, renderSqlTypeName, resolveReportedSqlType, sqlBaseName, sqlDataType, sqlDataTypeOfCodec, unquotedSqlBaseName, unquotedSqlBaseNameOfCodec, validateSqlTypeParams };\n\n//# sourceMappingURL=data-type.mjs.map"],"mappings":";;;;;;;AAQA,MAAM,cAAc;AACpB,MAAM,qBAAqB;AAC3B,MAAM,iBAAiB;AACvB,SAAS,YAAY,IAAI,QAAQ;CAChC,IAAI,WAAW,KAAK,GAAG,OAAO,CAAC;CAC/B,MAAM,OAAO,iBAAiB,MAAM;CACpC,IAAI,SAAS,KAAK,GAAG,kBAAkB,IAAI,wDAAwD;CACnG,OAAO;AACR;AACA,SAAS,eAAe,MAAM;CAC7B,OAAO,CAAC,GAAG,KAAK,SAAS,WAAW,CAAC,CAAC,CAAC,KAAK,UAAU,MAAM,MAAM,EAAE;AACrE;AACA,SAAS,iBAAiB,MAAM;CAC/B,OAAO,CAAC,GAAG,eAAe,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,GAAG;AACjD;AACA,SAAS,UAAU,MAAM;CACxB,MAAM,UAAU,KAAK,QAAQ,gBAAgB,MAA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AAG,OAAO;GAC7B;GACA;GACA;EACD;CACD;AACD;;;;;AAKA,SAAS,uBAAuB,UAAU,WAAW;CACpD,MAAM,WAAW,UAAU,OAAO,aAAa;CAC/C,IAAI,SAAS,SAAS,KAAK,GAAG;EAC7B,MAAM,WAAW,SAAS,MAAM,SAAS,KAAK,IAAI,eAAe,SAAS,IAAI;EAC9E,IAAI,aAAa,KAAK,GAAG,OAAO,KAAK;EACrC,OAAO,aAAa,UAAU,SAAS,IAAI,eAAe,QAAQ,KAAK,CAAC,CAAC;CAC1E;CACA,MAAM,OAAO,oBAAoB,SAAS,IAAI;CAC9C,KAAK,MAAM,QAAQ,UAAU,KAAK,MAAM,aAAa,KAAK,IAAI,OAAO;EACpE,IAAI,CAAC,OAAO,SAAS,GAAG;EACxB,MAAM,QAAQ,UAAU,UAAU,IAAI,CAAC,CAAC,KAAK,IAAI;EACjD,IAAI,UAAU,MAAM;EACpB,OAAO,aAAa,MAAM,OAAO,YAAY,eAAe,UAAU,IAAI,CAAC,CAAC,KAAK,MAAM,UAAU,CAAC,MAAM,OAAO,SAAS,MAAM,QAAQ,MAAM,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;CACvJ;AACD;AACA,SAAS,aAAa,QAAQ,QAAQ;CACrC,IAAI,OAAO,WAAW,KAAK,KAAK,OAAO,OAAO,MAAM,aAAa,KAAK,QAAQ,OAAO,KAAK;CAC1F,OAAO;EACN,UAAU,OAAO;EACjB,YAAY,OAAO,IAAI,UAAU,MAAM;CACxC;AACD"}
@@ -0,0 +1,113 @@
1
+ import { CodecLookupWithDescriptors, DataType, DataTypeId, DataTypeLookup, DataTypeSpec } from "@prisma/orm-framework/components/codec";
2
+ import { Type } from "arktype";
3
+ //#region ../../../2-sql/1-core/contract/dist/data-type.d.mts
4
+ //#region src/numeral-text.d.ts
5
+ /**
6
+ * A number as a contract source writes it: no exponent, because no schema language has that syntax,
7
+ * so the decimal point moves to where the exponent puts it. A non-finite number is its own word.
8
+ */
9
+ declare function numeralText(value: number): string;
10
+ //#endregion
11
+ //#region src/sql-data-type.d.ts
12
+ /** One way a database type is written or reported. */
13
+ interface SqlTypeText {
14
+ /** Lower case with single spaces; `{name}` stands for the parameter `name`. */
15
+ readonly text: string;
16
+ /** A migration writes this text. */
17
+ readonly written?: true;
18
+ /** The database catalog prints this text. */
19
+ readonly catalog?: true;
20
+ /** The exact characters written and printed, when they differ from `text` in letter case only. */
21
+ readonly display?: string;
22
+ }
23
+ type SqlTypeParams = Readonly<Record<string, unknown>>;
24
+ /** What introspection hands over about the element type of one column. */
25
+ interface ReportedSqlType {
26
+ /** The catalog text of the element type. */
27
+ readonly text: string;
28
+ /** The target's word for the type's kind, such as `enum`; undefined for a base type. */
29
+ readonly kind: string | undefined;
30
+ readonly schema: string | undefined;
31
+ /** The type's name, unquoted. */
32
+ readonly name: string | undefined;
33
+ }
34
+ interface SqlDataTypeSpec<Params extends SqlTypeParams = SqlTypeParams> extends DataTypeSpec {
35
+ readonly params?: Type<Params>;
36
+ readonly texts?: readonly SqlTypeText[];
37
+ /** The kind of reported type this data type claims, instead of any text. */
38
+ readonly claimsKind?: string;
39
+ readonly normalize?: (params: Params) => Params;
40
+ readonly render?: (params: Params) => string;
41
+ readonly fromReported?: (reported: ReportedSqlType) => Params;
42
+ }
43
+ interface SqlDataTypeFacts<Params extends SqlTypeParams = SqlTypeParams> {
44
+ readonly texts: readonly SqlTypeText[];
45
+ readonly claimsKind: string | undefined;
46
+ readonly normalize: (params: Params) => Params;
47
+ readonly render: ((params: Params) => string) | undefined;
48
+ readonly fromReported: ((reported: ReportedSqlType) => Params) | undefined;
49
+ }
50
+ interface SqlDataType<Params extends SqlTypeParams = SqlTypeParams> extends DataType {
51
+ readonly params?: Type<Params>;
52
+ readonly sql: SqlDataTypeFacts<Params>;
53
+ }
54
+ interface ResolvedSqlType {
55
+ readonly dataType: DataTypeId;
56
+ readonly typeParams: SqlTypeParams;
57
+ }
58
+ /** Declare a SQL data type, refusing a declaration that breaks a rule of the module. */
59
+ declare function sqlDataType<Params extends SqlTypeParams = SqlTypeParams>(id: string, spec: SqlDataTypeSpec<Params>): SqlDataType<Params>;
60
+ /** Whether `type` is a data type a SQL column can have. `sql/expression` is the one data type no column has. */
61
+ declare function isSqlDataType(type: DataType): type is SqlDataType;
62
+ /** The parameters of `typeParams` that `type` declares; codec-owned keys are dropped. */
63
+ declare function dataTypeParams(type: DataType, typeParams: SqlTypeParams | undefined): SqlTypeParams;
64
+ /** The parameters, when `type` accepts them; otherwise `CONTRACT.TYPE_PARAMS_INVALID` naming each parameter at fault. */
65
+ declare function validateSqlTypeParams<Params extends SqlTypeParams>(type: SqlDataType<Params>, params: SqlTypeParams): Params;
66
+ /** The name of `type` with no parameters, for places where parameters must not appear. */
67
+ declare function sqlBaseName<Params extends SqlTypeParams>(type: SqlDataType<Params>, params: SqlTypeParams): string;
68
+ /**
69
+ * The base name of `type` with `params`, unquoted. It differs from {@link sqlBaseName} only for a
70
+ * type that claims a kind: there it is the `typeName` parameter as written (`app.status`), where
71
+ * `sqlBaseName` gives the quoted name `render` writes into SQL (`"app"."status"`).
72
+ */
73
+ declare function unquotedSqlBaseName<Params extends SqlTypeParams>(type: SqlDataType<Params>, params: SqlTypeParams): string;
74
+ /** The lookups that find the data type a codec represents. */
75
+ interface SqlTypeLookups {
76
+ readonly codecLookup: Pick<CodecLookupWithDescriptors, 'descriptorFor'>;
77
+ readonly dataTypeLookup: Pick<DataTypeLookup, 'get'>;
78
+ }
79
+ /** The SQL data type the codec `codecId` represents. */
80
+ declare function sqlDataTypeOfCodec(codecId: string, lookups: SqlTypeLookups): SqlDataType;
81
+ /** {@link unquotedSqlBaseName} of the data type the codec `codecId` represents. */
82
+ declare function unquotedSqlBaseNameOfCodec(codecId: string, typeParams: SqlTypeParams | undefined, lookups: SqlTypeLookups): string;
83
+ /** The text a migration writes for `type` with the raw `params`. */
84
+ declare function renderSqlTypeName<Params extends SqlTypeParams>(type: SqlDataType<Params>, params: SqlTypeParams): string;
85
+ /** The text the database catalog prints for `type` with `params`, in their normal form. */
86
+ declare function renderSqlCatalogText<Params extends SqlTypeParams>(type: SqlDataType<Params>, params: SqlTypeParams): string;
87
+ /** Two SQL data types that would both recognise one reported type, and what each claims. */
88
+ interface SqlDataTypeCollision {
89
+ readonly first: SqlDataType;
90
+ readonly second: SqlDataType;
91
+ readonly claims: {
92
+ readonly by: 'text';
93
+ readonly first: string;
94
+ readonly second: string;
95
+ } | {
96
+ readonly by: 'kind';
97
+ readonly kind: string;
98
+ };
99
+ }
100
+ /**
101
+ * The first two SQL data types in `types` that would both recognise one reported type: a claiming
102
+ * text of each collides, or both claim the same kind. Two texts collide when either one's pattern
103
+ * matches the other with each placeholder written as 1.
104
+ */
105
+ declare function findSqlDataTypeCollision(types: readonly DataType[]): SqlDataTypeCollision | undefined;
106
+ /**
107
+ * The data type that claims a reported type, with its parameters in normal form, or undefined when
108
+ * no type in `dataTypes` claims it or its parameters fail the type's schema.
109
+ */
110
+ declare function resolveReportedSqlType(reported: ReportedSqlType, dataTypes: readonly DataType[]): ResolvedSqlType | undefined;
111
+ //#endregion
112
+ export { validateSqlTypeParams as S, sqlBaseName as _, SqlDataTypeFacts as a, unquotedSqlBaseName as b, SqlTypeParams as c, findSqlDataTypeCollision as d, isSqlDataType as f, resolveReportedSqlType as g, renderSqlTypeName as h, SqlDataTypeCollision as i, SqlTypeText as l, renderSqlCatalogText as m, ResolvedSqlType as n, SqlDataTypeSpec as o, numeralText as p, SqlDataType as r, SqlTypeLookups as s, ReportedSqlType as t, dataTypeParams as u, sqlDataType as v, unquotedSqlBaseNameOfCodec as x, sqlDataTypeOfCodec as y };
113
+ //# sourceMappingURL=data-type-CpqSDmR_.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data-type-CpqSDmR_.d.mts","names":[],"sources":["../../../../2-sql/1-core/contract/dist/data-type.d.mts"],"mappings":";;;;;;;;iBAOiB,YAAY;;;;UAInB;;WAEC;;WAEA;;WAEA;;WAEA;;KAEN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ue } from "@prisma/orm-framework/contract/types";
3
+ //#region ../../../2-sql/1-core/contract/dist/data-type-support.d.mts
4
+ //#region src/data-type-support.d.ts
5
+ /** Whether `text` is a whole number or a decimal as a contract source writes one. */
6
+ declare function isNumeralText(text: string): boolean;
7
+ /**
8
+ * A written numeral as the contract stores it. Leading zeros and the sign of zero never change a
9
+ * number, so they go; trailing zeros stay, because a type without a scale keeps them.
10
+ */
11
+ declare function canonicalNumeralText(text: string): string;
12
+ /**
13
+ * The canonical form of a 64-bit integer type: digit text. A database reads an integer default back as a number when it is a safe integer, so a safe integer reads as its digit text too; any other number may already have lost digits and is refused.
14
+ */
15
+ declare const integerTextCanonicalForm: ToCanonicalForm;
16
+ /** A string as a contract source writes it, with the escapes its string reader resolves. */
17
+ declare function escapePslString(value: string): string;
18
+ /** Which data type a written number is, and whether that type stores it as a number or as text. */
19
+ interface NumberClassification {
20
+ readonly type: DataTypeId;
21
+ readonly form: 'number' | 'text';
22
+ }
23
+ /** One integer type and the range of whole numbers it holds. */
24
+ interface IntegerStep extends NumberClassification {
25
+ readonly min: bigint;
26
+ readonly max: bigint;
27
+ }
28
+ /** The range of a signed integer of `bits` bits. */
29
+ declare function signedRange(bits: number): {
30
+ readonly min: bigint;
31
+ readonly max: bigint;
32
+ };
33
+ interface NumberClassifierSpec {
34
+ /** Tried in order; the first whose range holds the digits wins. */
35
+ readonly integers: readonly IntegerStep[];
36
+ /** A whole number no step holds. Absent means the target has no type for it. */
37
+ readonly largerWhole?: NumberClassification | undefined;
38
+ /** A number with a fraction. Absent means the target has no type for it. */
39
+ readonly fraction?: NumberClassification | undefined;
40
+ /** `NaN`, `Infinity` and `-Infinity`. Absent means the target has no type for them. */
41
+ readonly words?: NumberClassification | undefined;
42
+ }
43
+ /**
44
+ * The classifier one target's plain-number authoring entry carries: it reads the digits and says
45
+ * which of the target's types the value is, in that type's canonical form. `undefined` means no
46
+ * type of this target holds the number.
47
+ */
48
+ declare function createNumberClassifier(spec: NumberClassifierSpec): (text: string) => {
49
+ readonly type: DataTypeId;
50
+ readonly value: JsonValue;
51
+ } | undefined;
52
+ /**
53
+ * Read a JSON body into the document it holds.
54
+ *
55
+ * `JSON.parse` reads a numeral too large for a double as `Infinity`, and `JSON.stringify` writes
56
+ * that back as `null`, so a document holding one would not be the document stored; it is refused
57
+ * here instead, naming where the number is.
58
+ */
59
+ declare function parseJsonBody(text: string): JsonValue;
60
+ /** Write a document as the body of a JSON literal. */
61
+ declare function printJsonBody(value: JsonValue): string;
62
+ //#endregion
63
+ //#region src/date-time-canonical-form.d.ts
64
+ /**
65
+ * The reader the SQL targets build the canonical form of each date and time type with; ADR 254
66
+ * states the forms and the text it reads.
67
+ */
68
+ /** What a date or time type holds, which decides the text it reads and writes. */
69
+ type DateTimeShape = 'date' | 'time' | 'timeWithOffset' | 'dateTime' | 'instant';
70
+ interface CanonicalDateTimeOptions {
71
+ readonly shape: DateTimeShape;
72
+ /** The data type id, which messages name. */
73
+ readonly dataTypeId: string;
74
+ /** The largest UTC offset the type holds, in hours. Defaults to 23. */
75
+ readonly maxOffsetHours?: number;
76
+ /** The most digits after the decimal point the type holds. Defaults to 6, microseconds. */
77
+ readonly maxFractionDigits?: 3 | 6;
78
+ /** The earliest and latest values the type holds, each in canonical form. */
79
+ readonly range?: {
80
+ readonly earliest: string;
81
+ readonly latest: string;
82
+ };
83
+ }
84
+ /**
85
+ * The canonical form of written date or time text, or a refusal with a message that says what is
86
+ * wrong and shows text the type holds. `written` is the text as its author wrote it, which the
87
+ * message shows, when a target rewrote it into ISO 8601 before calling this.
88
+ */
89
+ declare function canonicalDateTime(text: string, options: CanonicalDateTimeOptions, written?: string): string;
90
+ //#endregion
91
+ export { NumberClassifierSpec as a, createNumberClassifier as c, isNumeralText as d, parseJsonBody as f, NumberClassification as i, escapePslString as l, signedRange as m, DateTimeShape as n, canonicalDateTime as o, printJsonBody as p, IntegerStep as r, canonicalNumeralText as s, CanonicalDateTimeOptions as t, integerTextCanonicalForm as u };
92
+ //# sourceMappingURL=data-type-support-B_Dr1cxB.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data-type-support-B_Dr1cxB.d.mts","names":[],"sources":["../../../../2-sql/1-core/contract/dist/data-type-support.d.mts"],"mappings":";;;;;iBAIiB,cAAc;;;;;iBAKd,qBAAqB;;;;cAIxB,0BAA0B;;iBAEvB,gBAAgB;;UAEvB;WACC,MAAM;WACN;;;UAGD,oBAAoB;WACnB;WACA;;;iBAGM,YAAY;WAClB;WACA;;UAED;;WAEC,mBAAmB;;WAEnB,cAAc;;WAEd,WAAW;;WAEX,QAAQ;;;;;;;iBAOF,uBAAuB,MAAM,wBAAwB;WAC3D,MAAM;WACN,OAAO;;;;;;;;;iBASD,cAAc,eAAe;;iBAE7B,cAAc,OAAO;;;;;;;;KAQjC;UACK;WACC,OAAO;;WAEP;;WAEA;;WAEA;;WAEA;aACE;aACA;;;;;;;;iBAQI,kBAAkB,cAAc,SAAS,0BAA0B"}