viborm 1.5.0 → 1.6.0

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 (277) hide show
  1. package/README.md +4 -2
  2. package/dist/{adapter-internals-Cy2QEBnH.mjs → adapter-internals-DULbfdmQ.mjs} +1 -1
  3. package/dist/{adapter-internals-Cy2QEBnH.mjs.map → adapter-internals-DULbfdmQ.mjs.map} +1 -1
  4. package/dist/{adapter-namespace-NnXlXR8c.mjs → adapter-namespace-CFtC8LbT.mjs} +2 -2
  5. package/dist/{adapter-namespace-NnXlXR8c.mjs.map → adapter-namespace-CFtC8LbT.mjs.map} +1 -1
  6. package/dist/{adapter-result-parser-D6lluSMi.mjs → adapter-result-parser-C0vW9am8.mjs} +1 -1
  7. package/dist/{adapter-result-parser-D6lluSMi.mjs.map → adapter-result-parser-C0vW9am8.mjs.map} +1 -1
  8. package/dist/adapters.d.mts +1 -1
  9. package/dist/adapters.mjs +1 -1
  10. package/dist/{array-literal-BsbbSLw3.mjs → array-literal-Dohoq5rT.mjs} +1 -1
  11. package/dist/{array-literal-BsbbSLw3.mjs.map → array-literal-Dohoq5rT.mjs.map} +1 -1
  12. package/dist/base-wlv81COV.mjs +2 -0
  13. package/dist/base-wlv81COV.mjs.map +1 -0
  14. package/dist/{batch-refs-BYCu1JnQ.mjs → batch-refs-cBYAKzaE.mjs} +2 -2
  15. package/dist/{batch-refs-BYCu1JnQ.mjs.map → batch-refs-cBYAKzaE.mjs.map} +1 -1
  16. package/dist/bind-parameter-capacity-4OU6feZG.mjs +2 -0
  17. package/dist/{bind-parameter-capacity-D6p9HrbB.mjs.map → bind-parameter-capacity-4OU6feZG.mjs.map} +1 -1
  18. package/dist/{builder-BxCr9ANq.mjs → builder-D0GQK-fA.mjs} +2 -2
  19. package/dist/{builder-BxCr9ANq.mjs.map → builder-D0GQK-fA.mjs.map} +1 -1
  20. package/dist/bun-sql.d.mts +1 -1
  21. package/dist/bun-sql.mjs +1 -1
  22. package/dist/bun-sqlite.d.mts +1 -1
  23. package/dist/bun-sqlite.mjs +1 -1
  24. package/dist/bun-sqlite.mjs.map +1 -1
  25. package/dist/cache/cloudflare-kv.d.mts +1 -1
  26. package/dist/cache/cloudflare-kv.mjs +1 -1
  27. package/dist/cache/memory.d.mts +1 -1
  28. package/dist/cache/memory.mjs +1 -1
  29. package/dist/cache/memory.mjs.map +1 -1
  30. package/dist/cache.d.mts +1 -1
  31. package/dist/cache.mjs +1 -1
  32. package/dist/cache.mjs.map +1 -1
  33. package/dist/{canonical-json-acY4dQNQ.mjs → canonical-json-D_FgOt4S.mjs} +2 -2
  34. package/dist/{canonical-json-acY4dQNQ.mjs.map → canonical-json-D_FgOt4S.mjs.map} +1 -1
  35. package/dist/chain-BQoDfo80.mjs +2 -0
  36. package/dist/{chain-C4EUyLzF.mjs.map → chain-BQoDfo80.mjs.map} +1 -1
  37. package/dist/cli.mjs +1 -1
  38. package/dist/client-BCcIdDl8.mjs +49 -0
  39. package/dist/client-BCcIdDl8.mjs.map +1 -0
  40. package/dist/client-BqgVSbk0.mjs +2 -0
  41. package/dist/client-BqgVSbk0.mjs.map +1 -0
  42. package/dist/{client-D-XiaClb.d.mts → client-C5BGyg5n.d.mts} +3 -3
  43. package/dist/client.d.mts +1 -1
  44. package/dist/client.mjs +1 -1
  45. package/dist/{clock-CJotKAxc.mjs → clock-QtW83Dcm.mjs} +1 -1
  46. package/dist/{clock-CJotKAxc.mjs.map → clock-QtW83Dcm.mjs.map} +1 -1
  47. package/dist/config.d.mts +2 -2
  48. package/dist/config.mjs +1 -1
  49. package/dist/{current-C2fZL9Ln.mjs → current-CEWlNJcP.mjs} +1 -1
  50. package/dist/{current-C2fZL9Ln.mjs.map → current-CEWlNJcP.mjs.map} +1 -1
  51. package/dist/d1.d.mts +1 -1
  52. package/dist/d1.mjs +1 -1
  53. package/dist/d1.mjs.map +1 -1
  54. package/dist/{datetime-physical-codec-CFoeuitT.mjs → datetime-physical-codec-Bl6M6vF5.mjs} +2 -2
  55. package/dist/{datetime-physical-codec-CFoeuitT.mjs.map → datetime-physical-codec-Bl6M6vF5.mjs.map} +1 -1
  56. package/dist/driver-Dv2GJyGs.mjs +2 -0
  57. package/dist/{driver-BqD-3_jO.mjs.map → driver-Dv2GJyGs.mjs.map} +1 -1
  58. package/dist/driver-szWYBmjD.mjs +2 -0
  59. package/dist/{driver-DseQwbsu.mjs.map → driver-szWYBmjD.mjs.map} +1 -1
  60. package/dist/driver.d.mts +1 -1
  61. package/dist/driver.mjs +1 -1
  62. package/dist/error-mapping-DRY49A3C.mjs +2 -0
  63. package/dist/error-mapping-DRY49A3C.mjs.map +1 -0
  64. package/dist/every-DIG9CPly.mjs +2 -0
  65. package/dist/{every-CqR4_Xsx.mjs.map → every-DIG9CPly.mjs.map} +1 -1
  66. package/dist/execution-context-_oajgBi4.mjs +2 -0
  67. package/dist/execution-context-_oajgBi4.mjs.map +1 -0
  68. package/dist/{fs-estate-N_F2YqYa.mjs → fs-estate-DNCM7hYC.mjs} +2 -2
  69. package/dist/{fs-estate-N_F2YqYa.mjs.map → fs-estate-DNCM7hYC.mjs.map} +1 -1
  70. package/dist/{geo-area-codec-4W5b7whM.mjs → geo-area-codec-H50rrGiF.mjs} +2 -2
  71. package/dist/{geo-area-codec-4W5b7whM.mjs.map → geo-area-codec-H50rrGiF.mjs.map} +1 -1
  72. package/dist/geo-point-codec-mjROsQX-.mjs +2 -0
  73. package/dist/{geo-point-codec-pAWYj5ZZ.mjs.map → geo-point-codec-mjROsQX-.mjs.map} +1 -1
  74. package/dist/{hydration-Az2rjp5a.mjs → hydration-BQ7tYLtA.mjs} +2 -2
  75. package/dist/{hydration-Az2rjp5a.mjs.map → hydration-BQ7tYLtA.mjs.map} +1 -1
  76. package/dist/{identifier-conversion-ufaCNi9E.mjs → identifier-conversion-DV63mwKG.mjs} +2 -2
  77. package/dist/{identifier-conversion-ufaCNi9E.mjs.map → identifier-conversion-DV63mwKG.mjs.map} +1 -1
  78. package/dist/{identity-CmRos0Yf.mjs → identity-B75EaVTM.mjs} +2 -2
  79. package/dist/{identity-CmRos0Yf.mjs.map → identity-B75EaVTM.mjs.map} +1 -1
  80. package/dist/{index-Ci8b13Lm.d.mts → index-DRX_LLQM.d.mts} +47 -8
  81. package/dist/index.d.mts +2 -2
  82. package/dist/index.mjs +1 -1
  83. package/dist/index.mjs.map +1 -1
  84. package/dist/instrumentation.d.mts +1 -1
  85. package/dist/instrumentation.mjs +1 -1
  86. package/dist/{invariant-D_fIjY_z.mjs → invariant-B5znICP_.mjs} +1 -1
  87. package/dist/{invariant-D_fIjY_z.mjs.map → invariant-B5znICP_.mjs.map} +1 -1
  88. package/dist/{json-number-CGXpPu4D.mjs → json-number-DoseUwuo.mjs} +1 -1
  89. package/dist/{json-number-CGXpPu4D.mjs.map → json-number-DoseUwuo.mjs.map} +1 -1
  90. package/dist/key-rszcmZdB.mjs +2 -0
  91. package/dist/{key-CyLRw0ne.mjs.map → key-rszcmZdB.mjs.map} +1 -1
  92. package/dist/{libsql-DnbEwMY5.mjs → libsql-CAZVcr9G.mjs} +2 -2
  93. package/dist/{libsql-DnbEwMY5.mjs.map → libsql-CAZVcr9G.mjs.map} +1 -1
  94. package/dist/libsql.d.mts +1 -1
  95. package/dist/libsql.mjs +1 -1
  96. package/dist/{memory-CJ7m33Gi.mjs → memory-CqWRO6-3.mjs} +2 -2
  97. package/dist/{memory-CJ7m33Gi.mjs.map → memory-CqWRO6-3.mjs.map} +1 -1
  98. package/dist/migrations/mysql.d.mts +5 -5
  99. package/dist/migrations/mysql.mjs +1 -1
  100. package/dist/migrations/postgres.d.mts +5 -5
  101. package/dist/migrations/postgres.mjs +1 -1
  102. package/dist/migrations/sqlite.d.mts +5 -5
  103. package/dist/migrations/sqlite.mjs +1 -1
  104. package/dist/migrations/storage/durable-object.d.mts +1 -1
  105. package/dist/migrations/storage/durable-object.mjs +1 -1
  106. package/dist/migrations/storage/fs.d.mts +1 -1
  107. package/dist/migrations/storage/fs.mjs +1 -1
  108. package/dist/migrations/storage/r2.d.mts +1 -1
  109. package/dist/migrations/storage/r2.mjs +1 -1
  110. package/dist/migrations/tenant.d.mts +3 -3
  111. package/dist/migrations/tenant.mjs +1 -1
  112. package/dist/migrations-OE5D32qo.mjs +2 -0
  113. package/dist/migrations-OE5D32qo.mjs.map +1 -0
  114. package/dist/migrations.d.mts +5 -5
  115. package/dist/migrations.mjs +1 -1
  116. package/dist/{mysql-9C0lSVzX.mjs → mysql-BPPBSJzl.mjs} +2 -2
  117. package/dist/{mysql-9C0lSVzX.mjs.map → mysql-BPPBSJzl.mjs.map} +1 -1
  118. package/dist/mysql-adapter-Dbo7l0lI.mjs +2 -0
  119. package/dist/mysql-adapter-Dbo7l0lI.mjs.map +1 -0
  120. package/dist/mysql2.d.mts +1 -1
  121. package/dist/mysql2.mjs +1 -1
  122. package/dist/{native-types-asNCr26n.mjs → native-types-6wCGP1a1.mjs} +1 -1
  123. package/dist/{native-types-asNCr26n.mjs.map → native-types-6wCGP1a1.mjs.map} +1 -1
  124. package/dist/neon-http.d.mts +1 -1
  125. package/dist/neon-http.mjs +1 -1
  126. package/dist/neon-http.mjs.map +1 -1
  127. package/dist/normalized-result-23DWxZVY.mjs +2 -0
  128. package/dist/{normalized-result-BF7gr4_b.mjs.map → normalized-result-23DWxZVY.mjs.map} +1 -1
  129. package/dist/{object-store-H7fJwgPR.d.mts → object-store-Cs3AueG5.d.mts} +4 -4
  130. package/dist/{object-store-WjVilDvN.mjs → object-store-DmnlQy7V.mjs} +2 -2
  131. package/dist/{object-store-WjVilDvN.mjs.map → object-store-DmnlQy7V.mjs.map} +1 -1
  132. package/dist/observation-BcT8Cs3d.mjs +2 -0
  133. package/dist/observation-BcT8Cs3d.mjs.map +1 -0
  134. package/dist/on.d.mts +80 -0
  135. package/dist/on.mjs +2 -0
  136. package/dist/on.mjs.map +1 -0
  137. package/dist/permissions.d.mts +1 -1
  138. package/dist/permissions.mjs +1 -1
  139. package/dist/pg.d.mts +1 -1
  140. package/dist/pg.mjs +1 -1
  141. package/dist/pg.mjs.map +1 -1
  142. package/dist/pglite.d.mts +1 -1
  143. package/dist/pglite.mjs +1 -1
  144. package/dist/{physical-C4D-979R.mjs → physical-DT6C54w7.mjs} +2 -2
  145. package/dist/{physical-C4D-979R.mjs.map → physical-DT6C54w7.mjs.map} +1 -1
  146. package/dist/pinned-session-BdON2d0V.mjs +2 -0
  147. package/dist/{pinned-session-FYOFV_gB.mjs.map → pinned-session-BdON2d0V.mjs.map} +1 -1
  148. package/dist/planetscale.d.mts +1 -1
  149. package/dist/planetscale.mjs +1 -1
  150. package/dist/planetscale.mjs.map +1 -1
  151. package/dist/{planner-CUcPdJwD.d.mts → planner-BxCcoO8s.d.mts} +32 -2
  152. package/dist/{postgres-BPeNXAZR.mjs → postgres-BK_aOx_C.mjs} +44 -37
  153. package/dist/postgres-BK_aOx_C.mjs.map +1 -0
  154. package/dist/postgres-adapter-CVazEDVI.mjs +2 -0
  155. package/dist/postgres-adapter-CVazEDVI.mjs.map +1 -0
  156. package/dist/postgres-adapter-DxhZu7Qw.mjs +2 -0
  157. package/dist/{postgres-adapter-B7hzWhky.mjs.map → postgres-adapter-DxhZu7Qw.mjs.map} +1 -1
  158. package/dist/postgres-result-DYeVeHuT.mjs +2 -0
  159. package/dist/{postgres-result-BCUQf8b_.mjs.map → postgres-result-DYeVeHuT.mjs.map} +1 -1
  160. package/dist/postgres.d.mts +1 -1
  161. package/dist/postgres.mjs +1 -1
  162. package/dist/postgres.mjs.map +1 -1
  163. package/dist/{provider-limits-D0ECF7_Q.mjs → provider-limits-zLe7S_0W.mjs} +2 -2
  164. package/dist/{provider-limits-D0ECF7_Q.mjs.map → provider-limits-zLe7S_0W.mjs.map} +1 -1
  165. package/dist/{validation-gwZYm3Yn.mjs → query-CTna5P9o.mjs} +2 -2
  166. package/dist/query-CTna5P9o.mjs.map +1 -0
  167. package/dist/{relation-bound-BrZLsSke.mjs → relation-bound-Bj7X-EUE.mjs} +1 -1
  168. package/dist/{relation-bound-BrZLsSke.mjs.map → relation-bound-Bj7X-EUE.mjs.map} +1 -1
  169. package/dist/{result-parsing-CQf_eCl8.mjs → result-parsing-C2044903.mjs} +1 -1
  170. package/dist/{result-parsing-CQf_eCl8.mjs.map → result-parsing-C2044903.mjs.map} +1 -1
  171. package/dist/result-shape-C8QFUuIt.mjs +2 -0
  172. package/dist/{result-shape-ic2j3Tze.mjs.map → result-shape-C8QFUuIt.mjs.map} +1 -1
  173. package/dist/rows-D7ns2l0U.mjs +2 -0
  174. package/dist/{rows-YyvK9MDz.mjs.map → rows-D7ns2l0U.mjs.map} +1 -1
  175. package/dist/{scalar-Dyns7kc7.mjs → scalar-D6QmJ22_.mjs} +2 -2
  176. package/dist/{scalar-Dyns7kc7.mjs.map → scalar-D6QmJ22_.mjs.map} +1 -1
  177. package/dist/schema/json.d.mts +1 -1
  178. package/dist/schema/json.mjs +1 -1
  179. package/dist/{schema-CUm_yh6L.mjs → schema-CY9kOwJ-.mjs} +2 -2
  180. package/dist/{schema-CUm_yh6L.mjs.map → schema-CY9kOwJ-.mjs.map} +1 -1
  181. package/dist/{schema-introspection-LpRNeSG2.mjs → schema-introspection-CfqmM3Cz.mjs} +2 -2
  182. package/dist/{schema-introspection-LpRNeSG2.mjs.map → schema-introspection-CfqmM3Cz.mjs.map} +1 -1
  183. package/dist/schema.d.mts +1 -1
  184. package/dist/schema.mjs +1 -1
  185. package/dist/{select-assembly-BjT_fDbu.mjs → select-assembly-D7FEenz2.mjs} +2 -2
  186. package/dist/select-assembly-D7FEenz2.mjs.map +1 -0
  187. package/dist/{settle-C4w1GfTU.mjs → settle-CObilv26.mjs} +2 -2
  188. package/dist/{settle-C4w1GfTU.mjs.map → settle-CObilv26.mjs.map} +1 -1
  189. package/dist/{sha256-_Nu4s32f.mjs → sha256-Da07rzvR.mjs} +1 -1
  190. package/dist/{sha256-_Nu4s32f.mjs.map → sha256-Da07rzvR.mjs.map} +1 -1
  191. package/dist/soft-delete.d.mts +1 -1
  192. package/dist/{sql-BvHwL73I.mjs → sql-DGtEeP8z.mjs} +1 -1
  193. package/dist/{sql-BvHwL73I.mjs.map → sql-DGtEeP8z.mjs.map} +1 -1
  194. package/dist/{sql-statement-tokens-4J5l5Lyt.mjs → sql-statement-tokens-DL3ooNs7.mjs} +1 -1
  195. package/dist/{sql-statement-tokens-4J5l5Lyt.mjs.map → sql-statement-tokens-DL3ooNs7.mjs.map} +1 -1
  196. package/dist/sql.d.mts +1 -1
  197. package/dist/sql.mjs +1 -1
  198. package/dist/sqlite-adapter-DqT6HeDs.mjs +2 -0
  199. package/dist/sqlite-adapter-DqT6HeDs.mjs.map +1 -0
  200. package/dist/{sqlite-utils-C5_KQPZn.mjs → sqlite-utils-DeDlMJKj.mjs} +2 -2
  201. package/dist/{sqlite-utils-C5_KQPZn.mjs.map → sqlite-utils-DeDlMJKj.mjs.map} +1 -1
  202. package/dist/sqlite3.d.mts +1 -1
  203. package/dist/sqlite3.mjs +1 -1
  204. package/dist/sqlite3.mjs.map +1 -1
  205. package/dist/{standard-sql-DmKF8msN.mjs → standard-sql-BErrm6AV.mjs} +2 -2
  206. package/dist/{standard-sql-DmKF8msN.mjs.map → standard-sql-BErrm6AV.mjs.map} +1 -1
  207. package/dist/{suppressed-failure-Bdo2aK81.mjs → suppressed-failure-3C4sFXvH.mjs} +1 -1
  208. package/dist/{suppressed-failure-Bdo2aK81.mjs.map → suppressed-failure-3C4sFXvH.mjs.map} +1 -1
  209. package/dist/{to-many-DxQuOBuq.mjs → to-many-DqYv9-vp.mjs} +2 -2
  210. package/dist/{to-many-DxQuOBuq.mjs.map → to-many-DqYv9-vp.mjs.map} +1 -1
  211. package/dist/{transaction-4dfqals6.mjs → transaction-D5LHYn-r.mjs} +2 -2
  212. package/dist/{transaction-4dfqals6.mjs.map → transaction-D5LHYn-r.mjs.map} +1 -1
  213. package/dist/{transaction-operation-CU1zlxiG.mjs → transaction-operation-Co3hw8yz.mjs} +2 -2
  214. package/dist/{transaction-operation-CU1zlxiG.mjs.map → transaction-operation-Co3hw8yz.mjs.map} +1 -1
  215. package/dist/{types-C5Oxz9yp.mjs → types-CJgtjXtu.mjs} +1 -1
  216. package/dist/{types-C5Oxz9yp.mjs.map → types-CJgtjXtu.mjs.map} +1 -1
  217. package/dist/{utils-CQ2nQwwO.mjs → utils-DooFtO1V.mjs} +3 -3
  218. package/dist/utils-DooFtO1V.mjs.map +1 -0
  219. package/dist/{v-BcroBusN.mjs → v-yKivkoka.mjs} +2 -2
  220. package/dist/{v-BcroBusN.mjs.map → v-yKivkoka.mjs.map} +1 -1
  221. package/dist/validation-pfpKPPZ_.mjs +2 -0
  222. package/dist/validation-pfpKPPZ_.mjs.map +1 -0
  223. package/dist/{validation-CjWRiLWU.mjs → validation-u-sZDdfD.mjs} +2 -2
  224. package/dist/{validation-CjWRiLWU.mjs.map → validation-u-sZDdfD.mjs.map} +1 -1
  225. package/dist/validation.d.mts +1 -1
  226. package/dist/validation.mjs +1 -1
  227. package/dist/{validator-yrGnrsAo.mjs → validator-XVm02V0K.mjs} +2 -2
  228. package/dist/{validator-yrGnrsAo.mjs.map → validator-XVm02V0K.mjs.map} +1 -1
  229. package/dist/version-WvqPqZJ4.mjs +2 -0
  230. package/dist/{version-Dt62tqkV.mjs.map → version-WvqPqZJ4.mjs.map} +1 -1
  231. package/dist/write-sinks-CoB5PPw9.mjs +2 -0
  232. package/dist/write-sinks-CoB5PPw9.mjs.map +1 -0
  233. package/dist/writes-CD0mNS5-.mjs +2 -0
  234. package/dist/writes-CD0mNS5-.mjs.map +1 -0
  235. package/package.json +36 -15
  236. package/dist/base-D3m1S7Uc.mjs +0 -2
  237. package/dist/base-D3m1S7Uc.mjs.map +0 -1
  238. package/dist/bind-parameter-capacity-D6p9HrbB.mjs +0 -2
  239. package/dist/cache-CIPRF-pz.mjs +0 -2
  240. package/dist/cache-CIPRF-pz.mjs.map +0 -1
  241. package/dist/chain-C4EUyLzF.mjs +0 -2
  242. package/dist/client-CnXO0M-E.mjs +0 -49
  243. package/dist/client-CnXO0M-E.mjs.map +0 -1
  244. package/dist/client-DACEO6tS.mjs +0 -2
  245. package/dist/client-DACEO6tS.mjs.map +0 -1
  246. package/dist/driver-BqD-3_jO.mjs +0 -2
  247. package/dist/driver-DseQwbsu.mjs +0 -2
  248. package/dist/error-mapping-6op318w6.mjs +0 -2
  249. package/dist/error-mapping-6op318w6.mjs.map +0 -1
  250. package/dist/every-CqR4_Xsx.mjs +0 -2
  251. package/dist/execution-context-asSCmyas.mjs +0 -2
  252. package/dist/execution-context-asSCmyas.mjs.map +0 -1
  253. package/dist/geo-point-codec-pAWYj5ZZ.mjs +0 -2
  254. package/dist/key-CyLRw0ne.mjs +0 -2
  255. package/dist/migrations-Bn1SatyB.mjs +0 -2
  256. package/dist/migrations-Bn1SatyB.mjs.map +0 -1
  257. package/dist/mysql-adapter-B1U35CJn.mjs +0 -2
  258. package/dist/mysql-adapter-B1U35CJn.mjs.map +0 -1
  259. package/dist/normalized-result-BF7gr4_b.mjs +0 -2
  260. package/dist/observation-Co72iCd1.mjs +0 -2
  261. package/dist/observation-Co72iCd1.mjs.map +0 -1
  262. package/dist/pinned-session-FYOFV_gB.mjs +0 -2
  263. package/dist/postgres-BPeNXAZR.mjs.map +0 -1
  264. package/dist/postgres-adapter-B7hzWhky.mjs +0 -2
  265. package/dist/postgres-adapter-CJmoxTW7.mjs +0 -2
  266. package/dist/postgres-adapter-CJmoxTW7.mjs.map +0 -1
  267. package/dist/postgres-result-BCUQf8b_.mjs +0 -2
  268. package/dist/result-shape-ic2j3Tze.mjs +0 -2
  269. package/dist/rows-YyvK9MDz.mjs +0 -2
  270. package/dist/select-assembly-BjT_fDbu.mjs.map +0 -1
  271. package/dist/sqlite-adapter-CLWY4B8w.mjs +0 -2
  272. package/dist/sqlite-adapter-CLWY4B8w.mjs.map +0 -1
  273. package/dist/utils-CQ2nQwwO.mjs.map +0 -1
  274. package/dist/validation-gwZYm3Yn.mjs.map +0 -1
  275. package/dist/version-Dt62tqkV.mjs +0 -2
  276. /package/dist/{contract-Dw0FR78e.d.mts → contract-H_WiAUaR.d.mts} +0 -0
  277. /package/dist/{sql-Q_twK-wW.d.mts → sql-CF5Xi6z-.d.mts} +0 -0
package/README.md CHANGED
@@ -87,10 +87,12 @@ separate [migration workflow](docs/content/docs/migration/index.mdx).
87
87
  instrumentation, omit, soft-delete and permissions tools.
88
88
  - Fixed-decimal values, millisecond DateTime values, GeoPoint and PostgreSQL vector
89
89
  operations with explicit provider requirements.
90
+ - [VibORM Studio](docs/content/docs/studio.mdx) (`npx @viborm/studio`): the schema
91
+ as a diagram, and the rows to browse and edit through your own client.
90
92
 
91
93
  See the [driver matrix](docs/content/docs/drivers/index.mdx) for actual provider
92
- qualification and hosted limitations. SQL Server, a database browser, read-replica
93
- routing and cross-schema relations are not implemented.
94
+ qualification and hosted limitations. SQL Server, read-replica routing and
95
+ cross-schema relations are not implemented.
94
96
 
95
97
  ## Contracts to know
96
98
 
@@ -1,2 +1,2 @@
1
1
  import{n as e}from"./chunk-BuuaeEvq.mjs";const t=Symbol(`viborm.adapterInternals`);function hasAdapterInternals(e){return t in e}function installAdapterInternals(e,n){Object.defineProperty(e,t,{configurable:!1,enumerable:!1,value:Object.freeze(n),writable:!1})}function getAdapterInternals(e){if(!hasAdapterInternals(e))throw TypeError(`The database adapter must extend a VibORM dialect adapter.`);return e[t]}function assembleAdapterSelect(e,t){return getAdapterInternals(e).select(t)}export{getAdapterInternals as n,installAdapterInternals as r,assembleAdapterSelect as t};
2
- //# sourceMappingURL=adapter-internals-Cy2QEBnH.mjs.map
2
+ //# sourceMappingURL=adapter-internals-DULbfdmQ.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"adapter-internals-Cy2QEBnH.mjs","names":[],"sources":["../src/adapters/adapter-internals.ts"],"sourcesContent":["import type { Sql } from \"@sql\";\nimport type { BatchReferenceSqlAdapter } from \"./adapter-core-types\";\nimport type { QueryParts } from \"./adapter-query-parts\";\nimport type { ConstraintIdentities } from \"./constraint-identity\";\nimport type { DatabaseAdapter } from \"./database-adapter\";\n\nexport type { QueryParts } from \"./adapter-query-parts\";\n\nconst ADAPTER_INTERNALS: unique symbol = Symbol(\"viborm.adapterInternals\");\n\ninterface AdapterInternals {\n readonly select: (parts: QueryParts) => Sql;\n readonly batchRefs: BatchReferenceSqlAdapter;\n readonly constraints: ConstraintIdentities;\n}\n\ninterface AdapterWithInternals extends DatabaseAdapter {\n readonly [ADAPTER_INTERNALS]: AdapterInternals;\n}\n\nfunction hasAdapterInternals(\n adapter: DatabaseAdapter\n): adapter is AdapterWithInternals {\n return ADAPTER_INTERNALS in adapter;\n}\n\n/** Install the one query-engine-only dialect seam on a concrete adapter. */\nexport function installAdapterInternals(\n adapter: DatabaseAdapter,\n internals: AdapterInternals\n): void {\n Object.defineProperty(adapter, ADAPTER_INTERNALS, {\n configurable: false,\n enumerable: false,\n value: Object.freeze(internals),\n writable: false,\n });\n}\n\n/** Read the internal seam installed by a stock dialect adapter. */\nexport function getAdapterInternals(\n adapter: DatabaseAdapter\n): AdapterInternals {\n if (!hasAdapterInternals(adapter)) {\n throw new TypeError(\n \"The database adapter must extend a VibORM dialect adapter.\"\n );\n }\n return adapter[ADAPTER_INTERNALS];\n}\n\n/** Assemble one query-engine SELECT without exposing its parts publicly. */\nexport function assembleAdapterSelect(\n adapter: DatabaseAdapter,\n parts: QueryParts\n): Sql {\n return getAdapterInternals(adapter).select(parts);\n}\n"],"mappings":"yCAQA,MAAM,EAAmC,OAAO,0BAA0B,CAY1E,SAAS,oBACP,EACiC,CACjC,OAAO,KAAqB,EAI9B,SAAgB,wBACd,EACA,EACM,CACN,OAAO,eAAe,EAAS,EAAmB,CAChD,aAAc,GACd,WAAY,GACZ,MAAO,OAAO,OAAO,EAAU,CAC/B,SAAU,GACX,CAAC,CAIJ,SAAgB,oBACd,EACkB,CAClB,GAAI,CAAC,oBAAoB,EAAQ,CAC/B,MAAU,UACR,6DACD,CAEH,OAAO,EAAQ,GAIjB,SAAgB,sBACd,EACA,EACK,CACL,OAAO,oBAAoB,EAAQ,CAAC,OAAO,EAAM"}
1
+ {"version":3,"file":"adapter-internals-DULbfdmQ.mjs","names":[],"sources":["../src/adapters/adapter-internals.ts"],"sourcesContent":["import type { Sql } from \"@sql\";\nimport type { BatchReferenceSqlAdapter } from \"./adapter-core-types\";\nimport type { QueryParts } from \"./adapter-query-parts\";\nimport type { ConstraintIdentities } from \"./constraint-identity\";\nimport type { DatabaseAdapter } from \"./database-adapter\";\n\nexport type { QueryParts } from \"./adapter-query-parts\";\n\nconst ADAPTER_INTERNALS: unique symbol = Symbol(\"viborm.adapterInternals\");\n\ninterface AdapterInternals {\n readonly select: (parts: QueryParts) => Sql;\n readonly batchRefs: BatchReferenceSqlAdapter;\n readonly constraints: ConstraintIdentities;\n}\n\ninterface AdapterWithInternals extends DatabaseAdapter {\n readonly [ADAPTER_INTERNALS]: AdapterInternals;\n}\n\nfunction hasAdapterInternals(\n adapter: DatabaseAdapter\n): adapter is AdapterWithInternals {\n return ADAPTER_INTERNALS in adapter;\n}\n\n/** Install the one query-engine-only dialect seam on a concrete adapter. */\nexport function installAdapterInternals(\n adapter: DatabaseAdapter,\n internals: AdapterInternals\n): void {\n Object.defineProperty(adapter, ADAPTER_INTERNALS, {\n configurable: false,\n enumerable: false,\n value: Object.freeze(internals),\n writable: false,\n });\n}\n\n/** Read the internal seam installed by a stock dialect adapter. */\nexport function getAdapterInternals(\n adapter: DatabaseAdapter\n): AdapterInternals {\n if (!hasAdapterInternals(adapter)) {\n throw new TypeError(\n \"The database adapter must extend a VibORM dialect adapter.\"\n );\n }\n return adapter[ADAPTER_INTERNALS];\n}\n\n/** Assemble one query-engine SELECT without exposing its parts publicly. */\nexport function assembleAdapterSelect(\n adapter: DatabaseAdapter,\n parts: QueryParts\n): Sql {\n return getAdapterInternals(adapter).select(parts);\n}\n"],"mappings":"yCAQA,MAAM,EAAmC,OAAO,0BAA0B,CAY1E,SAAS,oBACP,EACiC,CACjC,OAAO,KAAqB,EAI9B,SAAgB,wBACd,EACA,EACM,CACN,OAAO,eAAe,EAAS,EAAmB,CAChD,aAAc,GACd,WAAY,GACZ,MAAO,OAAO,OAAO,EAAU,CAC/B,SAAU,GACX,CAAC,CAIJ,SAAgB,oBACd,EACkB,CAClB,GAAI,CAAC,oBAAoB,EAAQ,CAC/B,MAAU,UACR,6DACD,CAEH,OAAO,EAAQ,GAIjB,SAAgB,sBACd,EACA,EACK,CACL,OAAO,oBAAoB,EAAQ,CAAC,OAAO,EAAM"}
@@ -1,2 +1,2 @@
1
- import{n as e}from"./chunk-BuuaeEvq.mjs";import{Ft as t}from"./geo-point-codec-pAWYj5ZZ.mjs";function installAdapterNamespace(e,n,r){Object.defineProperty(e,`namespace`,{value:n===void 0?void 0:t(n,r),writable:!1,enumerable:!0,configurable:!1})}export{installAdapterNamespace as t};
2
- //# sourceMappingURL=adapter-namespace-NnXlXR8c.mjs.map
1
+ import{n as e}from"./chunk-BuuaeEvq.mjs";import{Ft as t}from"./geo-point-codec-mjROsQX-.mjs";function installAdapterNamespace(e,n,r){Object.defineProperty(e,`namespace`,{value:n===void 0?void 0:t(n,r),writable:!1,enumerable:!0,configurable:!1})}export{installAdapterNamespace as t};
2
+ //# sourceMappingURL=adapter-namespace-CFtC8LbT.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"adapter-namespace-NnXlXR8c.mjs","names":[],"sources":["../src/adapters/adapter-namespace.ts"],"sourcesContent":["// The adapter's namespace fact, installed once.\n//\n// `readonly` is a compile-time claim, and query rendering, migrations, cache\n// scope and instrumentation all read this one object at execution time. The\n// property is therefore installed as an own, non-writable, non-configurable\n// value: hostile JavaScript that binds a cache scope and then rewrites the\n// qualifier before the statement runs fails at the assignment instead.\n//\n// The whole adapter is deliberately NOT frozen — the existing vector test seam\n// remains mutable. GeoPoint is installed separately as another immutable fact.\n\nimport { type NamespaceDialect, normalizeNamespace } from \"@schema/identifier\";\n\n/**\n * Validate one constructor argument and install it. `undefined` installs an\n * immutable absence, which is what an unbound MySQL adapter means.\n */\nexport function installAdapterNamespace(\n adapter: object,\n namespace: unknown,\n dialect: NamespaceDialect\n): void {\n Object.defineProperty(adapter, \"namespace\", {\n value:\n namespace === undefined\n ? undefined\n : normalizeNamespace(namespace, dialect),\n writable: false,\n enumerable: true,\n configurable: false,\n });\n}\n"],"mappings":"6FAiBA,SAAgB,wBACd,EACA,EACA,EACM,CACN,OAAO,eAAe,EAAS,YAAa,CAC1C,MACE,IAAc,IAAA,GACV,IAAA,GACA,EAAmB,EAAW,EAAQ,CAC5C,SAAU,GACV,WAAY,GACZ,aAAc,GACf,CAAC"}
1
+ {"version":3,"file":"adapter-namespace-CFtC8LbT.mjs","names":[],"sources":["../src/adapters/adapter-namespace.ts"],"sourcesContent":["// The adapter's namespace fact, installed once.\n//\n// `readonly` is a compile-time claim, and query rendering, migrations, cache\n// scope and instrumentation all read this one object at execution time. The\n// property is therefore installed as an own, non-writable, non-configurable\n// value: hostile JavaScript that binds a cache scope and then rewrites the\n// qualifier before the statement runs fails at the assignment instead.\n//\n// The whole adapter is deliberately NOT frozen — the existing vector test seam\n// remains mutable. GeoPoint is installed separately as another immutable fact.\n\nimport { type NamespaceDialect, normalizeNamespace } from \"@schema/identifier\";\n\n/**\n * Validate one constructor argument and install it. `undefined` installs an\n * immutable absence, which is what an unbound MySQL adapter means.\n */\nexport function installAdapterNamespace(\n adapter: object,\n namespace: unknown,\n dialect: NamespaceDialect\n): void {\n Object.defineProperty(adapter, \"namespace\", {\n value:\n namespace === undefined\n ? undefined\n : normalizeNamespace(namespace, dialect),\n writable: false,\n enumerable: true,\n configurable: false,\n });\n}\n"],"mappings":"6FAiBA,SAAgB,wBACd,EACA,EACA,EACM,CACN,OAAO,eAAe,EAAS,YAAa,CAC1C,MACE,IAAc,IAAA,GACV,IAAA,GACA,EAAmB,EAAW,EAAQ,CAC5C,SAAU,GACV,WAAY,GACZ,aAAc,GACf,CAAC"}
@@ -1,2 +1,2 @@
1
1
  import{n as e}from"./chunk-BuuaeEvq.mjs";const passThroughParseResult=(e,t,n)=>n();export{passThroughParseResult as t};
2
- //# sourceMappingURL=adapter-result-parser-D6lluSMi.mjs.map
2
+ //# sourceMappingURL=adapter-result-parser-C0vW9am8.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"adapter-result-parser-D6lluSMi.mjs","names":[],"sources":["../src/adapters/adapter-result-parser.ts"],"sourcesContent":["import type { NativeTypeDeclaration } from \"@schema/scalars/native-types\";\nimport type { DateTimePhysicalForm } from \"@validation/primitives/datetime-physical-codec\";\nimport type { DecimalPhysicalRepresentation } from \"@validation/primitives/decimal-codec\";\nimport type {\n IdDomain,\n IdRepresentation,\n} from \"@validation/primitives/id-codec\";\n\nexport interface AdapterResultParser {\n /**\n * How this dialect physically spells a decimal on the way back.\n *\n * `\"coefficient\"` means the column stores (and therefore returns) the signed\n * unscaled integer, cast to text before a driver can round an int64 into a\n * double — the SQLite family, which has no exact decimal type. Every other\n * provider returns native exact decimal text, which is the default when this\n * is unset.\n *\n * It is DECLARED and never inferred: at scale 2 the text `\"120\"` is logical\n * 120 in one vocabulary and logical 1.2 in the other, so a value cannot be\n * read without knowing which promise produced it. Declaring it on the adapter\n * is also what keeps the result parser from asking a dialect question, which\n * the layering rule forbids.\n */\n decimalRepresentation?: DecimalPhysicalRepresentation;\n\n /**\n * How this dialect physically spells a decimal LIST on the way back.\n *\n * `\"coefficient\"` means the column holds a JSON array of unscaled coefficient\n * STRINGS, read back as the container text — JSON has no exact decimal, and a\n * numeric token would already have been rounded past 2^53 by JavaScript or D1\n * (plan 6.1). Unset means the column is a native decimal array whose members\n * arrive as exact decimal text, one JavaScript array member each.\n *\n * A SEPARATE declaration from {@link AdapterResultParser.decimalRepresentation}\n * because the two genuinely differ: MySQL's scalar column is `DECIMAL(p,s)`\n * and answers with text while its list column is JSON and answers with\n * coefficients. Deriving one from the other would decode every MySQL list\n * member at the wrong scale, and the two spellings are indistinguishable by\n * inspection — at scale 2 the member `\"120\"` is 120 in one and 1.2 in the\n * other.\n */\n decimalListRepresentation?: DecimalPhysicalRepresentation;\n\n /**\n * How this dialect physically spells a datetime column that DECLARES the given\n * native type. Unset means timestamp text for every field, which is what every\n * dialect with a temporal column type stores.\n *\n * A function rather than a value because this promise is per FIELD, not per\n * dialect: SQLite has no temporal type at all, so `s.dateTime()` accepts a\n * declaration choosing between TEXT, an INTEGER count of epoch milliseconds\n * and a REAL Julian day, and the DDL already builds the column that way. The\n * adapter is asked because the declaration is dialect vocabulary — a\n * PostgreSQL native type reaching a SQLite adapter describes no column here\n * and answers `\"text\"` like an undeclared field.\n *\n * It is DECLARED and never inferred for the same reason\n * {@link AdapterResultParser.decimalRepresentation} is: the number\n * `2460324.9375` is one instant as a Julian day and a completely different one\n * as milliseconds, so a value cannot be read without knowing which promise\n * produced it.\n */\n dateTimeRepresentation?: (\n nativeType: NativeTypeDeclaration | undefined\n ) => DateTimePhysicalForm;\n\n /**\n * How this dialect physically spells an enum LIST on the way back.\n *\n * `\"arrayText\"` means the column is a native enum array whose element type no\n * driver's result-type table knows, so the provider answers the array's own\n * text (`{ADMIN,USER}`) — PostgreSQL. Unset means the column is the dialect's\n * JSON list container and the members arrive through the JSON reading like\n * every other list.\n *\n * It is DECLARED and never inferred for the same reason\n * {@link AdapterResultParser.decimalRepresentation} is: the two spellings\n * collide on the empty container — `{}` is an empty PostgreSQL array AND a\n * valid JSON object — so a value cannot be read without knowing which promise\n * produced it, and reading array text on a JSON dialect would accept\n * malformed rows every other list type refuses.\n */\n enumListRepresentation?: \"arrayText\";\n\n /**\n * How this dialect physically spells one identifier DOMAIN on a column that\n * declares the given native type.\n *\n * `\"text\"` is the whole public string; `\"uuid\"` the payload as canonical UUID\n * text, which is what a PostgreSQL `uuid` column returns; `\"bytes\"` the\n * payload's own bytes, in whatever binary shape the driver spells them.\n *\n * A function of the DOMAIN and the field's own native type override, not a\n * constant, because both move the answer: a ULID is `bytea` on PostgreSQL and\n * `BINARY(16)` on MySQL, and a `varchar(26)` override keeps either one text\n * while the domain stays admitted. It is DECLARED and never inferred for the\n * same reason {@link AdapterResultParser.decimalRepresentation} is — sixteen\n * bytes and a 36-character string are the same identifier, and a value cannot\n * be read without knowing which promise produced it.\n *\n * Unset means the dialect stores every domain as text. Every shipped adapter\n * declares it; the option exists so a custom adapter that keeps text columns\n * is a complete adapter.\n */\n idRepresentation?: (\n domain: IdDomain,\n nativeType: NativeTypeDeclaration | undefined\n ) => IdRepresentation;\n\n /**\n * When `true`, {@link AdapterResultParser.parseField} performs NO\n * transformation for any scalar type (it is a pure `next()` passthrough) and\n * the provider returns native JS values (text→string, int→number,\n * bool→boolean, float→number). This lets the result parser take an identity\n * fast path for plain string/int/number/boolean columns, skipping the typed\n * decode switch. The path stays byte-identical: a per-value guard defers any\n * non-native value back to the full parser. Adapters that coerce field values\n * (MySQL/SQLite: 0/1→boolean, JSON-as-text, …) leave this unset.\n */\n nativeScalarPassthrough?: boolean;\n\n /**\n * One OPERATION's raw result, once, before it is decoded.\n *\n * This dialect's chance to reshape what the provider answered for a verb,\n * asked exactly once per operation by `Queries.decodeResult` (Arnaud's D-28)\n * with the operation's own rows — never per statement and never per member.\n * It is a REQUIRED member, and every adapter the estate ships installs the\n * one {@link passThroughParseResult} below for it: a result's MEANING belongs\n * to the engine's decoder, which asks for its own aliases and reads them\n * back, and a VALUE's meaning to {@link AdapterResultParser.parseField} and\n * the scalar codecs one level down. Arnaud's D-40 deleted the two legs that\n * decided otherwise (MySQL's count-column normalisation, PostgreSQL's bigint\n * conversion) after measuring both answering `undefined` on every live\n * operation.\n *\n * @param raw - Raw database result\n * @param operation - Query operation type\n * @param next - Call to continue with default parsing\n * - `next()` uses original raw value\n * - `next(transformed)` uses the transformed value\n *\n * @returns Parsed result or result of `next()`\n *\n * @example\n * // Every shipped adapter: the result is the decoder's.\n * parseResult: passThroughParseResult\n */\n parseResult: (\n raw: unknown,\n operation: import(\"../query-engine/types\").Operation,\n next: (value?: unknown) => unknown\n ) => unknown;\n\n /**\n * Parse relation value (nested JSON from includes)\n *\n * @param value - Raw relation value from database\n * @param next - Call to continue with default parsing\n * - `next()` uses original value\n * - `next(parsed)` uses the parsed value\n *\n * @returns Parsed relation or result of `next()`\n *\n * @example\n * // Parse JSON strings (MySQL/SQLite)\n * parseRelation: (value, next) => {\n * const parsed = tryParseJsonString(value);\n * return parsed !== undefined ? next(parsed) : next();\n * }\n */\n parseRelation: (\n value: unknown,\n next: (value?: unknown) => unknown\n ) => unknown;\n\n /**\n * Parse field value by type\n *\n * @param value - Raw field value from database\n * @param scalarType - Scalar type (boolean, datetime, bigint, etc.)\n * @param next - Pass a value to the query engine's strict scalar parser\n * - `next()` uses original value\n * - `next(converted)` uses the converted value\n *\n * @returns Decoded field value. The query engine strictly parses it once.\n *\n * @example\n * // Convert 0/1 to boolean (SQLite/MySQL)\n * parseField: (value, scalarType, next) => {\n * if (scalarType !== 'boolean') return next();\n * const bool = parseIntegerBoolean(value);\n * return bool === undefined ? next() : next(bool);\n * }\n */\n parseField: (\n value: unknown,\n scalarType: string,\n next: (value?: unknown) => unknown\n ) => unknown;\n}\n\n/**\n * The `parseResult` every adapter this estate ships installs: the contract's\n * shape, deciding nothing.\n *\n * ONE object, referenced by the SQLite, MySQL and PostgreSQL adapters, so the\n * answer \"this dialect decides nothing about a RESULT\" has a single owner\n * rather than three byte-identical members in three files (Arnaud's D-43). It\n * lives beside the member it implements because this is the file where the\n * contract's shape is declared: the required signature and the do-nothing\n * answer to it are then one fact in one place, and the doc above cannot drift\n * from the value below it.\n *\n * It does NOT close the seam. `Queries.decodeResult` still asks the adapter's\n * own `parseResult` once per operation, so an adapter from outside this estate\n * that installs its own — to recover a result whose transport reshaped it —\n * is still asked and still honoured (Arnaud's D-42: the member stays a public\n * extension point). Both facts are pinned together by \"the three shipped\n * adapters share one pass-through, and a custom adapter's own is still asked\"\n * in `tests/contracts/engine/query/parity-decoding.core.test.ts`.\n */\nexport const passThroughParseResult: AdapterResultParser[\"parseResult\"] = (\n _raw,\n _operation,\n next\n) => next();\n"],"mappings":"yCAgOA,MAAa,wBACX,EACA,EACA,IACG,GAAM"}
1
+ {"version":3,"file":"adapter-result-parser-C0vW9am8.mjs","names":[],"sources":["../src/adapters/adapter-result-parser.ts"],"sourcesContent":["import type { NativeTypeDeclaration } from \"@schema/scalars/native-types\";\nimport type { DateTimePhysicalForm } from \"@validation/primitives/datetime-physical-codec\";\nimport type { DecimalPhysicalRepresentation } from \"@validation/primitives/decimal-codec\";\nimport type {\n IdDomain,\n IdRepresentation,\n} from \"@validation/primitives/id-codec\";\n\nexport interface AdapterResultParser {\n /**\n * How this dialect physically spells a decimal on the way back.\n *\n * `\"coefficient\"` means the column stores (and therefore returns) the signed\n * unscaled integer, cast to text before a driver can round an int64 into a\n * double — the SQLite family, which has no exact decimal type. Every other\n * provider returns native exact decimal text, which is the default when this\n * is unset.\n *\n * It is DECLARED and never inferred: at scale 2 the text `\"120\"` is logical\n * 120 in one vocabulary and logical 1.2 in the other, so a value cannot be\n * read without knowing which promise produced it. Declaring it on the adapter\n * is also what keeps the result parser from asking a dialect question, which\n * the layering rule forbids.\n */\n decimalRepresentation?: DecimalPhysicalRepresentation;\n\n /**\n * How this dialect physically spells a decimal LIST on the way back.\n *\n * `\"coefficient\"` means the column holds a JSON array of unscaled coefficient\n * STRINGS, read back as the container text — JSON has no exact decimal, and a\n * numeric token would already have been rounded past 2^53 by JavaScript or D1\n * (plan 6.1). Unset means the column is a native decimal array whose members\n * arrive as exact decimal text, one JavaScript array member each.\n *\n * A SEPARATE declaration from {@link AdapterResultParser.decimalRepresentation}\n * because the two genuinely differ: MySQL's scalar column is `DECIMAL(p,s)`\n * and answers with text while its list column is JSON and answers with\n * coefficients. Deriving one from the other would decode every MySQL list\n * member at the wrong scale, and the two spellings are indistinguishable by\n * inspection — at scale 2 the member `\"120\"` is 120 in one and 1.2 in the\n * other.\n */\n decimalListRepresentation?: DecimalPhysicalRepresentation;\n\n /**\n * How this dialect physically spells a datetime column that DECLARES the given\n * native type. Unset means timestamp text for every field, which is what every\n * dialect with a temporal column type stores.\n *\n * A function rather than a value because this promise is per FIELD, not per\n * dialect: SQLite has no temporal type at all, so `s.dateTime()` accepts a\n * declaration choosing between TEXT, an INTEGER count of epoch milliseconds\n * and a REAL Julian day, and the DDL already builds the column that way. The\n * adapter is asked because the declaration is dialect vocabulary — a\n * PostgreSQL native type reaching a SQLite adapter describes no column here\n * and answers `\"text\"` like an undeclared field.\n *\n * It is DECLARED and never inferred for the same reason\n * {@link AdapterResultParser.decimalRepresentation} is: the number\n * `2460324.9375` is one instant as a Julian day and a completely different one\n * as milliseconds, so a value cannot be read without knowing which promise\n * produced it.\n */\n dateTimeRepresentation?: (\n nativeType: NativeTypeDeclaration | undefined\n ) => DateTimePhysicalForm;\n\n /**\n * How this dialect physically spells an enum LIST on the way back.\n *\n * `\"arrayText\"` means the column is a native enum array whose element type no\n * driver's result-type table knows, so the provider answers the array's own\n * text (`{ADMIN,USER}`) — PostgreSQL. Unset means the column is the dialect's\n * JSON list container and the members arrive through the JSON reading like\n * every other list.\n *\n * It is DECLARED and never inferred for the same reason\n * {@link AdapterResultParser.decimalRepresentation} is: the two spellings\n * collide on the empty container — `{}` is an empty PostgreSQL array AND a\n * valid JSON object — so a value cannot be read without knowing which promise\n * produced it, and reading array text on a JSON dialect would accept\n * malformed rows every other list type refuses.\n */\n enumListRepresentation?: \"arrayText\";\n\n /**\n * How this dialect physically spells one identifier DOMAIN on a column that\n * declares the given native type.\n *\n * `\"text\"` is the whole public string; `\"uuid\"` the payload as canonical UUID\n * text, which is what a PostgreSQL `uuid` column returns; `\"bytes\"` the\n * payload's own bytes, in whatever binary shape the driver spells them.\n *\n * A function of the DOMAIN and the field's own native type override, not a\n * constant, because both move the answer: a ULID is `bytea` on PostgreSQL and\n * `BINARY(16)` on MySQL, and a `varchar(26)` override keeps either one text\n * while the domain stays admitted. It is DECLARED and never inferred for the\n * same reason {@link AdapterResultParser.decimalRepresentation} is — sixteen\n * bytes and a 36-character string are the same identifier, and a value cannot\n * be read without knowing which promise produced it.\n *\n * Unset means the dialect stores every domain as text. Every shipped adapter\n * declares it; the option exists so a custom adapter that keeps text columns\n * is a complete adapter.\n */\n idRepresentation?: (\n domain: IdDomain,\n nativeType: NativeTypeDeclaration | undefined\n ) => IdRepresentation;\n\n /**\n * When `true`, {@link AdapterResultParser.parseField} performs NO\n * transformation for any scalar type (it is a pure `next()` passthrough) and\n * the provider returns native JS values (text→string, int→number,\n * bool→boolean, float→number). This lets the result parser take an identity\n * fast path for plain string/int/number/boolean columns, skipping the typed\n * decode switch. The path stays byte-identical: a per-value guard defers any\n * non-native value back to the full parser. Adapters that coerce field values\n * (MySQL/SQLite: 0/1→boolean, JSON-as-text, …) leave this unset.\n */\n nativeScalarPassthrough?: boolean;\n\n /**\n * One OPERATION's raw result, once, before it is decoded.\n *\n * This dialect's chance to reshape what the provider answered for a verb,\n * asked exactly once per operation by `Queries.decodeResult` (Arnaud's D-28)\n * with the operation's own rows — never per statement and never per member.\n * It is a REQUIRED member, and every adapter the estate ships installs the\n * one {@link passThroughParseResult} below for it: a result's MEANING belongs\n * to the engine's decoder, which asks for its own aliases and reads them\n * back, and a VALUE's meaning to {@link AdapterResultParser.parseField} and\n * the scalar codecs one level down. Arnaud's D-40 deleted the two legs that\n * decided otherwise (MySQL's count-column normalisation, PostgreSQL's bigint\n * conversion) after measuring both answering `undefined` on every live\n * operation.\n *\n * @param raw - Raw database result\n * @param operation - Query operation type\n * @param next - Call to continue with default parsing\n * - `next()` uses original raw value\n * - `next(transformed)` uses the transformed value\n *\n * @returns Parsed result or result of `next()`\n *\n * @example\n * // Every shipped adapter: the result is the decoder's.\n * parseResult: passThroughParseResult\n */\n parseResult: (\n raw: unknown,\n operation: import(\"../query-engine/types\").Operation,\n next: (value?: unknown) => unknown\n ) => unknown;\n\n /**\n * Parse relation value (nested JSON from includes)\n *\n * @param value - Raw relation value from database\n * @param next - Call to continue with default parsing\n * - `next()` uses original value\n * - `next(parsed)` uses the parsed value\n *\n * @returns Parsed relation or result of `next()`\n *\n * @example\n * // Parse JSON strings (MySQL/SQLite)\n * parseRelation: (value, next) => {\n * const parsed = tryParseJsonString(value);\n * return parsed !== undefined ? next(parsed) : next();\n * }\n */\n parseRelation: (\n value: unknown,\n next: (value?: unknown) => unknown\n ) => unknown;\n\n /**\n * Parse field value by type\n *\n * @param value - Raw field value from database\n * @param scalarType - Scalar type (boolean, datetime, bigint, etc.)\n * @param next - Pass a value to the query engine's strict scalar parser\n * - `next()` uses original value\n * - `next(converted)` uses the converted value\n *\n * @returns Decoded field value. The query engine strictly parses it once.\n *\n * @example\n * // Convert 0/1 to boolean (SQLite/MySQL)\n * parseField: (value, scalarType, next) => {\n * if (scalarType !== 'boolean') return next();\n * const bool = parseIntegerBoolean(value);\n * return bool === undefined ? next() : next(bool);\n * }\n */\n parseField: (\n value: unknown,\n scalarType: string,\n next: (value?: unknown) => unknown\n ) => unknown;\n}\n\n/**\n * The `parseResult` every adapter this estate ships installs: the contract's\n * shape, deciding nothing.\n *\n * ONE object, referenced by the SQLite, MySQL and PostgreSQL adapters, so the\n * answer \"this dialect decides nothing about a RESULT\" has a single owner\n * rather than three byte-identical members in three files (Arnaud's D-43). It\n * lives beside the member it implements because this is the file where the\n * contract's shape is declared: the required signature and the do-nothing\n * answer to it are then one fact in one place, and the doc above cannot drift\n * from the value below it.\n *\n * It does NOT close the seam. `Queries.decodeResult` still asks the adapter's\n * own `parseResult` once per operation, so an adapter from outside this estate\n * that installs its own — to recover a result whose transport reshaped it —\n * is still asked and still honoured (Arnaud's D-42: the member stays a public\n * extension point). Both facts are pinned together by \"the three shipped\n * adapters share one pass-through, and a custom adapter's own is still asked\"\n * in `tests/contracts/engine/query/parity-decoding.core.test.ts`.\n */\nexport const passThroughParseResult: AdapterResultParser[\"parseResult\"] = (\n _raw,\n _operation,\n next\n) => next();\n"],"mappings":"yCAgOA,MAAa,wBACX,EACA,EACA,IACG,GAAM"}
@@ -1,2 +1,2 @@
1
- import { a as PostgresAdapter, i as SQLiteAdapter, n as postgresAdapter, o as MySQLAdapter, r as sqliteAdapter, s as DatabaseAdapter, t as mysqlAdapter } from "./index-Ci8b13Lm.mjs";
1
+ import { a as PostgresAdapter, i as SQLiteAdapter, n as postgresAdapter, o as MySQLAdapter, r as sqliteAdapter, s as DatabaseAdapter, t as mysqlAdapter } from "./index-DRX_LLQM.mjs";
2
2
  export { type DatabaseAdapter, MySQLAdapter, PostgresAdapter, SQLiteAdapter, mysqlAdapter, postgresAdapter, sqliteAdapter };
package/dist/adapters.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import{t as e}from"./postgres-adapter-CJmoxTW7.mjs";import{t}from"./mysql-adapter-B1U35CJn.mjs";import{t as n}from"./sqlite-adapter-CLWY4B8w.mjs";const r=new t,i=new e,a=new n;export{t as MySQLAdapter,e as PostgresAdapter,n as SQLiteAdapter,r as mysqlAdapter,i as postgresAdapter,a as sqliteAdapter};
1
+ import{t as e}from"./postgres-adapter-CVazEDVI.mjs";import{t}from"./mysql-adapter-Dbo7l0lI.mjs";import{t as n}from"./sqlite-adapter-DqT6HeDs.mjs";const r=new t,i=new e,a=new n;export{t as MySQLAdapter,e as PostgresAdapter,n as SQLiteAdapter,r as mysqlAdapter,i as postgresAdapter,a as sqliteAdapter};
2
2
  //# sourceMappingURL=adapters.mjs.map
@@ -1,2 +1,2 @@
1
1
  import{n as e}from"./chunk-BuuaeEvq.mjs";const t=/(["\\])/g;function arrayLiteralText(e){return`{${e.map(e=>`"${String(e).replace(t,`\\$1`)}"`).join(`,`)}}`}function readArrayLiteralText(e){if(!(e.startsWith(`{`)&&e.endsWith(`}`)))return;if(e===`{}`)return[];let t=[],n=1;for(;n<e.length-1;){let r=``,i=e[n]===`"`;i&&n++;let a=!i;for(;n<e.length-1;){let t=e[n++];if(t===`\\`)r+=e.charAt(n++);else if(i&&t===`"`){a=!0;break}else if(!i&&t===`,`){n--;break}else if(!i&&(t===`{`||t===`}`||t===`"`))return;else r+=t}if(!a)return;if(t.push(!i&&r===`NULL`?null:r),n===e.length-1)return t;if(e[n++]!==`,`||n===e.length-1)return}}export{readArrayLiteralText as n,arrayLiteralText as t};
2
- //# sourceMappingURL=array-literal-BsbbSLw3.mjs.map
2
+ //# sourceMappingURL=array-literal-Dohoq5rT.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"array-literal-BsbbSLw3.mjs","names":[],"sources":["../src/adapters/databases/postgres/array-literal.ts"],"sourcesContent":["const ARRAY_LITERAL_ESCAPES = /([\"\\\\])/g;\n\n/** The physical text of a PostgreSQL array; the destination supplies its type. */\nexport function arrayLiteralText(values: readonly unknown[]): string {\n const members = values.map(\n (value) => `\"${String(value).replace(ARRAY_LITERAL_ESCAPES, \"\\\\$1\")}\"`\n );\n return `{${members.join(\",\")}}`;\n}\n\n/** Read the one-dimensional array spelling PostgreSQL emits for scalar lists. */\nexport function readArrayLiteralText(\n text: string\n): (string | null)[] | undefined {\n if (!(text.startsWith(\"{\") && text.endsWith(\"}\"))) return;\n if (text === \"{}\") return [];\n const values: (string | null)[] = [];\n let cursor = 1;\n while (cursor < text.length - 1) {\n let value = \"\";\n const quoted = text[cursor] === '\"';\n if (quoted) cursor++;\n let closed = !quoted;\n while (cursor < text.length - 1) {\n const character = text[cursor++];\n if (character === \"\\\\\") {\n value += text.charAt(cursor++);\n } else if (quoted && character === '\"') {\n closed = true;\n break;\n } else if (!quoted && character === \",\") {\n cursor--;\n break;\n } else if (\n !quoted &&\n (character === \"{\" || character === \"}\" || character === '\"')\n )\n return;\n else value += character;\n }\n if (!closed) return;\n values.push(!quoted && value === \"NULL\" ? null : value);\n if (cursor === text.length - 1) return values;\n if (text[cursor++] !== \",\" || cursor === text.length - 1) return;\n }\n}\n"],"mappings":"yCAAA,MAAM,EAAwB,WAG9B,SAAgB,iBAAiB,EAAoC,CAInE,MAAO,IAHS,EAAO,IACpB,GAAU,IAAI,OAAO,EAAM,CAAC,QAAQ,EAAuB,OAAO,CAAC,GACrE,CACkB,KAAK,IAAI,CAAC,GAI/B,SAAgB,qBACd,EAC+B,CAC/B,GAAI,EAAE,EAAK,WAAW,IAAI,EAAI,EAAK,SAAS,IAAI,EAAG,OACnD,GAAI,IAAS,KAAM,MAAO,EAAE,CAC5B,IAAM,EAA4B,EAAE,CAChC,EAAS,EACb,KAAO,EAAS,EAAK,OAAS,GAAG,CAC/B,IAAI,EAAQ,GACN,EAAS,EAAK,KAAY,IAC5B,GAAQ,IACZ,IAAI,EAAS,CAAC,EACd,KAAO,EAAS,EAAK,OAAS,GAAG,CAC/B,IAAM,EAAY,EAAK,KACvB,GAAI,IAAc,KAChB,GAAS,EAAK,OAAO,IAAS,SACrB,GAAU,IAAc,IAAK,CACtC,EAAS,GACT,cACS,CAAC,GAAU,IAAc,IAAK,CACvC,IACA,cAEA,CAAC,IACA,IAAc,KAAO,IAAc,KAAO,IAAc,KAEzD,YACG,GAAS,EAEhB,GAAI,CAAC,EAAQ,OAEb,GADA,EAAO,KAAK,CAAC,GAAU,IAAU,OAAS,KAAO,EAAM,CACnD,IAAW,EAAK,OAAS,EAAG,OAAO,EACvC,GAAI,EAAK,OAAc,KAAO,IAAW,EAAK,OAAS,EAAG"}
1
+ {"version":3,"file":"array-literal-Dohoq5rT.mjs","names":[],"sources":["../src/adapters/databases/postgres/array-literal.ts"],"sourcesContent":["const ARRAY_LITERAL_ESCAPES = /([\"\\\\])/g;\n\n/** The physical text of a PostgreSQL array; the destination supplies its type. */\nexport function arrayLiteralText(values: readonly unknown[]): string {\n const members = values.map(\n (value) => `\"${String(value).replace(ARRAY_LITERAL_ESCAPES, \"\\\\$1\")}\"`\n );\n return `{${members.join(\",\")}}`;\n}\n\n/** Read the one-dimensional array spelling PostgreSQL emits for scalar lists. */\nexport function readArrayLiteralText(\n text: string\n): (string | null)[] | undefined {\n if (!(text.startsWith(\"{\") && text.endsWith(\"}\"))) return;\n if (text === \"{}\") return [];\n const values: (string | null)[] = [];\n let cursor = 1;\n while (cursor < text.length - 1) {\n let value = \"\";\n const quoted = text[cursor] === '\"';\n if (quoted) cursor++;\n let closed = !quoted;\n while (cursor < text.length - 1) {\n const character = text[cursor++];\n if (character === \"\\\\\") {\n value += text.charAt(cursor++);\n } else if (quoted && character === '\"') {\n closed = true;\n break;\n } else if (!quoted && character === \",\") {\n cursor--;\n break;\n } else if (\n !quoted &&\n (character === \"{\" || character === \"}\" || character === '\"')\n )\n return;\n else value += character;\n }\n if (!closed) return;\n values.push(!quoted && value === \"NULL\" ? null : value);\n if (cursor === text.length - 1) return values;\n if (text[cursor++] !== \",\" || cursor === text.length - 1) return;\n }\n}\n"],"mappings":"yCAAA,MAAM,EAAwB,WAG9B,SAAgB,iBAAiB,EAAoC,CAInE,MAAO,IAHS,EAAO,IACpB,GAAU,IAAI,OAAO,EAAM,CAAC,QAAQ,EAAuB,OAAO,CAAC,GACrE,CACkB,KAAK,IAAI,CAAC,GAI/B,SAAgB,qBACd,EAC+B,CAC/B,GAAI,EAAE,EAAK,WAAW,IAAI,EAAI,EAAK,SAAS,IAAI,EAAG,OACnD,GAAI,IAAS,KAAM,MAAO,EAAE,CAC5B,IAAM,EAA4B,EAAE,CAChC,EAAS,EACb,KAAO,EAAS,EAAK,OAAS,GAAG,CAC/B,IAAI,EAAQ,GACN,EAAS,EAAK,KAAY,IAC5B,GAAQ,IACZ,IAAI,EAAS,CAAC,EACd,KAAO,EAAS,EAAK,OAAS,GAAG,CAC/B,IAAM,EAAY,EAAK,KACvB,GAAI,IAAc,KAChB,GAAS,EAAK,OAAO,IAAS,SACrB,GAAU,IAAc,IAAK,CACtC,EAAS,GACT,cACS,CAAC,GAAU,IAAc,IAAK,CACvC,IACA,cAEA,CAAC,IACA,IAAc,KAAO,IAAc,KAAO,IAAc,KAEzD,YACG,GAAS,EAEhB,GAAI,CAAC,EAAQ,OAEb,GADA,EAAO,KAAK,CAAC,GAAU,IAAU,OAAS,KAAO,EAAM,CACnD,IAAW,EAAK,OAAS,EAAG,OAAO,EACvC,GAAI,EAAK,OAAc,KAAO,IAAW,EAAK,OAAS,EAAG"}
@@ -0,0 +1,2 @@
1
+ import{n as e}from"./chunk-BuuaeEvq.mjs";const t=`[Truncated]`,n=`[Unreadable]`,r=[`code`,`errno`,`sqlState`,`sqlstate`,`status`,`statusCode`],i=4096,a=/^\d{3}$/,o=/^[0-9A-Z]{5}$/,s=/^V\d{4,5}$/,c=/^P\d{4}$/,l=new Set(`00.01.02.03.08.09.0A.0B.0F.0L.0P.0Z.20.21.22.23.24.25.26.27.28.2B.2D.2F.34.38.39.3B.3D.3F.40.42.44.53.54.55.57.58.72.F0.HV.HY.IM.P0.S0.XA.XX`.split(`.`)),u=new Set(`CONNECTION_CLOSED.ABORTED.ALREADY_EXISTS.CANCELLED.DATA_LOSS.DEADLINE_EXCEEDED.EACCES.EADDRINUSE.EADDRNOTAVAIL.EAFNOSUPPORT.EAI_AGAIN.EALREADY.EBADF.EBUSY.ECONNABORTED.ECONNREFUSED.ECONNRESET.EEXIST.EHOSTUNREACH.EINTR.EINVAL.EISCONN.EMFILE.ENETUNREACH.ENFILE.ENOENT.ENOSPC.ENOTCONN.ENOTFOUND.EPERM.EPIPE.ER_BAD_FIELD_ERROR.ER_BAD_NULL_ERROR.ER_CON_COUNT_ERROR.ER_DATA_OUT_OF_RANGE.ER_NO_SUCH_TABLE.ER_TOO_MANY_USER_CONNECTIONS.ER_WARN_DATA_OUT_OF_RANGE.ER_CHECK_CONSTRAINT_VIOLATED.ER_DUP_ENTRY.ER_INVALID_JSON_TEXT_IN_PARAM.ER_LOCK_DEADLOCK.ER_LOCK_WAIT_TIMEOUT.ER_NO_REFERENCED_ROW_2.ER_ROW_IS_REFERENCED_2.EROFS.ETIMEDOUT.FAILED_PRECONDITION.INTERNAL.INVALID_ARGUMENT.NOT_FOUND.OUT_OF_RANGE.PERMISSION_DENIED.RESOURCE_EXHAUSTED.SQLITE_BUSY.SQLITE_BUSY_RECOVERY.SQLITE_BUSY_SNAPSHOT.SQLITE_BUSY_TIMEOUT.SQLITE_CONSTRAINT.SQLITE_CONSTRAINT_CHECK.SQLITE_CONSTRAINT_FOREIGNKEY.SQLITE_CONSTRAINT_NOTNULL.SQLITE_CONSTRAINT_UNIQUE.SQLITE_ERROR.SQLITE_LOCKED.SQLITE_LOCKED_SHAREDCACHE.SQLITE_LOCKED_VTAB.UNAUTHENTICATED.UNAVAILABLE.UNIMPLEMENTED.UNKNOWN`.split(`.`));function sanitizeBytes(e,t){let n=Math.min(e.byteLength,128,Math.max(0,256-t.entries)),r=[];for(let t=0;t<n;t+=1)r.push(e[t]);let i=createSafeRecord();return defineSafe(i,`type`,`binary`),defineSafe(i,`byteLength`,e.byteLength),defineSafe(i,`bytes`,r),e.byteLength>n&&defineSafe(i,`truncated`,!0),t.entries+=n,i}function sanitizeString(e,n){let r=Math.max(0,32768-n.characters),a=Math.min(e.length,i,r);return n.characters+=a,a===e.length?e:`${e.slice(0,a)}${t}`}function safeErrorString(e,t,n){let r=safeRead(e,t);return sanitizeString(typeof r==`string`?r:`Error`,n)}function getNestedCause(e){let t=safeRead(e,`originalCause`);if(isError(t))return t;let n=safeRead(e,`cause`);return isError(n)?n:void 0}function safeRead(e,t){try{return Reflect.get(e,t)}catch{return n}}function safeHasOwn(e,t){try{return Object.hasOwn(e,t)}catch{return!1}}function safeOwnPropertyDescriptor(e,t){try{return Reflect.getOwnPropertyDescriptor(e,t)}catch{return}}function isArrayValue(e){try{return Array.isArray(e)}catch{return!1}}function safeArrayLength(e){let t=safeRead(e,`length`);return typeof t==`number`&&Number.isSafeInteger(t)&&t>=0?t:0}function createSafeRecord(){return Object.create(null)}function defineSafe(e,t,n){try{Object.defineProperty(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0})}catch{}}function defineHidden(e,t,n){try{Object.defineProperty(e,t,{configurable:!1,enumerable:!1,value:n,writable:!1})}catch{}}function filterSafeErrorProperty(e,t){return e===`errno`?sanitizeProviderErrno(t):e===`sqlState`||e===`sqlstate`?sanitizeSqlState(t):e===`status`||e===`statusCode`?sanitizeProviderStatus(t):sanitizeProviderCode(t)}function sanitizeProviderCode(e){if(typeof e==`number`)return sanitizeProviderErrno(e);if(!(typeof e!=`string`||e.length>64))return s.test(e)||o.test(e)||u.has(e)?e:void 0}function sanitizeProviderErrno(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=0&&e<=2147483647?e:void 0}function sanitizeSqlState(e){return typeof e==`string`&&o.test(e)&&l.has(e.slice(0,2))?e:void 0}function sanitizeProviderStatus(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=100&&e<=999||typeof e==`string`&&a.test(e)?e:void 0}function isTrustedCode(e){return typeof e==`string`&&s.test(e)}function sanitizeTrustedCode(e){return isTrustedCode(e)?e:`V9001`}function sanitizeTrustedPrismaCode(e){return typeof e==`string`&&c.test(e)?e:void 0}function boundTrustedString(e){return e.length<=i?e:`${e.slice(0,i)}${t}`}function safeDateString(e){try{let t=Date.prototype.getTime.call(e);return Number.isFinite(t)?Date.prototype.toISOString.call(e):`Invalid Date`}catch{return`Invalid Date`}}function freezeDiagnosticValue(e){if(typeof e!=`object`||!e)return e;try{for(let t of Reflect.ownKeys(e)){let n=safeOwnPropertyDescriptor(e,t);n&&`value`in n&&freezeDiagnosticValue(n.value)}return Object.freeze(e)}catch{return e}}function isRecord(e){try{return typeof e==`object`&&!!e&&!Array.isArray(e)}catch{return!1}}function isError(e){try{return e instanceof Error}catch{return!1}}function errorCause(e){return isError(e)?e:Error(`A non-Error value was thrown.`,{cause:e})}function toError(e){return isError(e)?e:Error(describeThrown(e),{cause:e})}function describeThrown(e){try{return String(e)}catch{return`a thrown ${typeof e} whose own string conversion threw`}}const d=Object.freeze({includeParams:!1,includeSql:!1}),f=new Set([`query`,`querytext`,`sql`,`statement`]),p=new Set([`arguments`,`bindings`,`parameters`,`params`,`values`]),m=new Set([`cause`,`originalcause`]),text=e=>typeof e==`string`?e:void 0,flag=e=>typeof e==`boolean`?e:void 0,count=e=>typeof e==`number`&&Number.isFinite(e)&&e>=0&&e<=2**53-1?e:void 0,h=new Set([`none`,`committed`,`partial`,`may-have-committed`]),commitCertainty=e=>e===`committed`||e===`may-have-committed`?e:void 0,effectState=e=>typeof e==`string`&&h.has(e)?e:void 0,g=new Map([[`actualChecksum`,text],[`actualResultCount`,count],[`actualRowCount`,count],[`autoIncrement`,flag],[`callsite`,text],[`candidates`,sanitizeStringArray],[`clientTarget`,text],[`column`,text],[`columns`,sanitizeStringArray],[`command`,text],[`commitCertainty`,commitCertainty],[`conflictsWith`,text],[`constraint`,text],[`context`,text],[`correlationId`,text],[`deprecation`,text],[`dialect`,text],[`dispatchId`,text],[`driver`,text],[`effectState`,effectState],[`estateHash`,text],[`expectedChecksum`,text],[`expectedResultCount`,count],[`expectedRowCount`,count],[`expectedStatementCount`,count],[`feature`,text],[`field`,text],[`fromState`,text],[`hint`,text],[`indexName`,text],[`indexType`,text],[`journalTarget`,text],[`lastConfirmedStep`,text],[`method`,text],[`migrationIndex`,count],[`migrationName`,text],[`migrationsDir`,text],[`model`,text],[`namespace`,text],[`notice`,text],[`operation`,text],[`operationId`,text],[`parameterIndex`,count],[`params`,e=>isArrayValue(e)?e:void 0],[`partial`,flag],[`planHash`,text],[`providerCode`,sanitizeProviderCode],[`providerErrno`,sanitizeProviderErrno],[`providerSqlState`,sanitizeSqlState],[`providerStatus`,sanitizeProviderStatus],[`query`,text],[`recordSeriesProgress`,sanitizeRecordSeriesProgress],[`referencedTable`,text],[`relation`,text],[`relations`,sanitizeStringArray],[`representation`,text],[`resultIndex`,count],[`scalarType`,text],[`reason`,text],[`stateId`,text],[`statementIndex`,count],[`step`,text],[`strategy`,text],[`table`,text],[`target`,text],[`timeout`,count],[`toState`,text],[`type`,text]]),_=new Set([...g.keys()].filter(e=>e!==`deprecation`&&e!==`notice`)),v=`Underlying error details redacted`,y=`[Circular]`,b=t,x=n,S=Symbol(`viborm.trustedErrorSnapshot`),C=Symbol(`viborm.trustedRecordSeriesProgress`);function resolveDiagnosticDisclosure(e){return{includeSql:ownValue(e,`includeSql`)===!0,includeParams:ownValue(e,`includeParams`)===!0,includeProviderDetails:ownValue(e,`includeProviderDetails`)===!0,includeCallsite:ownValue(e,`includeCallsite`)===!0}}function sanitizeErrorMetadata(e,t){return sanitizeAllowedRecord(e,_,t,!1)}function sanitizeDiagnosticParameters(e,t){return sanitizeArray(e,createState(t),0,!1,!0)}function sanitizeErrorForLogging(e,t){let n=getTrustedErrorDisclosure(e);return sanitizeError(e,createState({...t,includeProviderDetails:n?.includeProviderDetails===!0||t?.includeProviderDetails===!0,includeCallsite:n?.includeCallsite===!0||t?.includeCallsite===!0}),0,!1)}function sanitizeErrorCause(e,t){return sanitizeError(e,createState(t),0,!0)}function serializeSanitizedError(e,t){if(e)return serializeError(e,createState(t),0)}function registerTrustedError(e,t){let n=resolveDiagnosticDisclosure(t.disclosure);defineHidden(e,S,Object.freeze({cause:t.cause?freezeDiagnosticValue(sanitizeError(t.cause,createState(n),0,!0)):void 0,code:sanitizeTrustedCode(t.code),disclosure:n,message:boundTrustedString(t.message),meta:freezeDiagnosticValue(sanitizeErrorMetadata(t.meta,n)),name:boundTrustedString(t.name),prismaCode:sanitizeTrustedPrismaCode(t.prismaCode),timestamp:safeDateString(t.timestamp),...t.validation?{validation:freezeDiagnosticValue(sanitizeValidationDetails(t.validation))}:{}}))}function serializeTrustedError(e){let t=getTrustedErrorSnapshot(e);if(!t)return;let n=createSafeRecord();return defineSafe(n,`name`,t.name),defineSafe(n,`message`,t.message),defineSafe(n,`code`,t.code),t.prismaCode!==void 0&&defineSafe(n,`prismaCode`,t.prismaCode),defineSafe(n,`meta`,trustedMetaWithRecordSeriesProgress(e,t)),t.validation&&(defineSafe(n,`source`,t.validation.source),defineSafe(n,`issues`,t.validation.issues)),defineSafe(n,`timestamp`,t.timestamp),defineSafe(n,`cause`,serializeSanitizedError(t.cause,t.disclosure)),n}function registerTrustedRecordSeriesProgress(e,t){defineHidden(e,C,freezeDiagnosticValue(t))}function getTrustedRecordSeriesProgress(e){return sanitizeRecordSeriesProgress(safeRead(e,C))}function sanitizeRecordSeriesProgress(e){if(!isRecord(e))return;let t=safeRead(e,`atomicity`),n=safeRead(e,`phase`),r=safeProgressInteger(safeRead(e,`committedSegments`)),i=safeProgressInteger(safeRead(e,`completedMembers`)),a=safeProgressInteger(safeRead(e,`committedWriteMembers`)),o=safeRead(e,`mayHaveCommittedSegment`),s=safeRead(e,`totalMembers`),c=s===void 0?void 0:safeProgressInteger(s),l=safeRead(e,`memberPath`),u=l===void 0?void 0:sanitizeProgressMemberPath(l);if(!(t!==`segment`||!isRecordSeriesProgressPhase(n)||r===void 0||i===void 0||a===void 0||o!==void 0&&o!==!0||s!==void 0&&c===void 0||l!==void 0&&u===void 0))return Object.freeze({atomicity:t,phase:n,committedSegments:r,completedMembers:i,committedWriteMembers:a,...o===!0?{mayHaveCommittedSegment:!0}:{},...u?{memberPath:Object.freeze(u)}:{},...c===void 0?{}:{totalMembers:c}})}function isRecordSeriesProgressPhase(e){return e===`capture`||e===`planning`||e===`prefix`||e===`member`||e===`suffix`||e===`result`||e===`invalidation`}function getTrustedErrorCause(e){return getTrustedErrorSnapshot(e)?.cause}const w=/([a-z][a-z0-9+.-]*:\/\/)[^/\s]*@/gi,T=/([a-z][a-z0-9+.-]*:\/\/)[^/\s]*:[^/\s]*$/gi,E=/\bBearer\s+[^\s,;]+/gi,D=/((?:password|passwd|pwd|token|auth[_-]?token|api[_-]?key|secret)["']?\s*[=:]\s*)(?:"[^"\n]*"|'[^'\n]*'|[^\s&,;]+)/gi;function ownValue(e,t){if(typeof e!=`object`||!e)return;let n=safeOwnPropertyDescriptor(e,t);return n&&`value`in n?n.value:void 0}function sanitizeDiagnosticText(e,t){return sanitizeString(e,t).replace(w,`$1[REDACTED]@`).replace(T,`$1[REDACTED]`).replace(D,`$1[REDACTED]`).replace(E,`Bearer [REDACTED]`)}function getTrustedErrorDisclosure(e){return getTrustedErrorSnapshot(e)?.disclosure}function sanitizeValidationDetails(e){let t=createState(),n=createSafeRecord();for(let r of[`kind`,`operation`,`model`,`property`,`builder`,`path`,`target`,`schemaType`]){let i=ownValue(e.source,r);typeof i==`string`&&defineSafe(n,r,sanitizeDiagnosticText(i,t))}let r=[];if(isArrayValue(e.issues))for(let n=0;n<Math.min(safeArrayLength(e.issues),128);n+=1){let i=ownValue(e.issues,String(n)),a=ownValue(i,`path`),o=ownValue(i,`message`);typeof a==`string`&&typeof o==`string`&&r.push({path:sanitizeDiagnosticText(a,t),message:sanitizeDiagnosticText(o,t)})}return{source:n,issues:r}}function createState(e){return{disclosure:resolveDiagnosticDisclosure(e),seen:new WeakSet,entries:0,characters:0}}function sanitizeUnknown(e,t,n,r,i){try{if(n>8||t.entries>=256)return b;if(typeof e==`string`)return r?v:sanitizeString(e,t);if(e===null||typeof e==`number`||typeof e==`boolean`)return e;if(typeof e==`bigint`)return sanitizeString(e.toString(),t);if(e===void 0)return`[Undefined]`;if(typeof e==`symbol`)return sanitizeString(String(e),t);if(typeof e==`function`)return`[Function]`;if(e instanceof Error)return sanitizeError(e,t,n,!0);if(e instanceof Date){let n=Date.prototype.getTime.call(e);return Number.isFinite(n)?sanitizeString(Date.prototype.toISOString.call(e),t):`[Invalid Date]`}return e instanceof ArrayBuffer?sanitizeBytes(new Uint8Array(e),t):ArrayBuffer.isView(e)?sanitizeBytes(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),t):t.seen.has(e)?y:(t.seen.add(e),isArrayValue(e)?sanitizeArray(e,t,n,r,i):sanitizeObject(e,t,n,r,i))}catch{return x}}function sanitizeArray(e,t,n,r,i){let a=Math.min(safeArrayLength(e),128),o=[];for(let s=0;s<a;s+=1){if(t.entries>=256){o.push(b);break}t.entries+=1;let a=safeOwnPropertyDescriptor(e,String(s)),c=a&&`value`in a?a.value:x;o.push(sanitizeUnknown(c,t,n+1,r,i))}return safeArrayLength(e)>a&&o.push(b),o}function sanitizeObject(e,t,n,r,i){let a=createSafeRecord();try{for(let o in e){if(!safeHasOwn(e,o))continue;if(t.entries>=256){defineSafe(a,`truncated`,b);break}let s=o.length<=64?o.toLowerCase():``;if(!i&&f.has(s)&&!t.disclosure.includeSql||!i&&p.has(s)&&!t.disclosure.includeParams||r&&(s===`stack`||!t.disclosure.includeProviderDetails&&(s===`message`||s===`detail`||s===`hint`))||s===`callsite`&&!t.disclosure.includeCallsite)continue;t.entries+=1;let c=safeOwnPropertyDescriptor(e,o),l=c&&`value`in c?c.value:x;defineSafe(a,sanitizeString(o,t),sanitizeUnknown(l,t,n+1,r||!i&&m.has(s),i||p.has(s)))}}catch{defineSafe(a,`unreadable`,x)}return a}function sanitizeError(e,t,n,i){if(n>8)return Error(b);if(t.seen.has(e))return Error(y);t.seen.add(e);let a=i?void 0:getTrustedErrorSnapshot(e),o=t.disclosure.includeProviderDetails?ownValue(e,`message`):void 0,s=Error(!a&&typeof o==`string`?sanitizeDiagnosticText(o,t):i?v:a?sanitizeString(a.message,t):`Error details redacted`);if(s.name=a?sanitizeString(a.name,t):`Error`,s.stack=void 0,t.disclosure.includeProviderDetails&&!a)for(let n of[`detail`,`hint`]){let r=ownValue(e,n);typeof r==`string`&&defineSafe(s,n,sanitizeDiagnosticText(r,t))}if(a)defineSafe(s,`code`,a.code),a.prismaCode!==void 0&&defineSafe(s,`prismaCode`,a.prismaCode);else for(let t of r){let n=filterSafeErrorProperty(t,ownValue(e,t));n!==void 0&&defineSafe(s,t,n)}let c=a?trustedMetaWithRecordSeriesProgress(e,a):void 0;if(!i&&c&&defineSafe(s,`meta`,sanitizeErrorMetadata(c,t.disclosure)),a){defineSafe(s,`timestamp`,a.timestamp),registerTrustedError(s,{cause:a.cause,code:a.code,disclosure:t.disclosure,message:a.message,meta:a.meta,name:a.name,prismaCode:a.prismaCode,timestamp:new Date(a.timestamp),...a.validation?{validation:{source:a.validation.source,issues:a.validation.issues}}:{}}),Object.defineProperty(s,`toJSON`,{value:()=>serializeTrustedError(s)});let n=sanitizeRecordSeriesProgress(safeRead(e,C));n&&registerTrustedRecordSeriesProgress(s,n)}let l=a?.cause??getNestedCause(e);if(l){let e=sanitizeError(l,t,n+1,!0);defineSafe(s,`cause`,e),defineSafe(s,`originalCause`,e)}return s}function sanitizeAllowedRecord(e,t,n,r){let i=createSafeRecord(),a=createState(n);for(let n of t){let t=safeOwnPropertyDescriptor(e,n);if(!(t&&`value`in t))continue;let o=filterAllowedDiagnosticValue(n,n===`callsite`&&typeof t.value==`string`?sanitizeDiagnosticText(t.value,a):t.value,r);o!==void 0&&defineSafe(i,n,o)}return sanitizeObject(i,a,0,!1,!1)}function filterAllowedDiagnosticValue(e,t,n){return e===`event`&&n?typeof t==`string`&&[`bypass`,`hit`,`miss`,`revalidate`].includes(t)?t:void 0:e===`status`&&n?typeof t==`string`&&[`cache-set-failed`,`error`,`fresh`,`stale`,`start`,`success`].includes(t)?t:void 0:g.get(e)?.(t)}function safeProgressInteger(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=0?e:void 0}function sanitizeProgressMemberPath(e){if(!isArrayValue(e))return;let t=safeArrayLength(e);if(t>32)return;let n=[];for(let r=0;r<t;r+=1){let t=safeOwnPropertyDescriptor(e,String(r));if(!(t&&`value`in t))return;let i=safeProgressInteger(t.value);if(i===void 0)return;n.push(i)}return n}function trustedMetaWithRecordSeriesProgress(e,t){let n=sanitizeErrorMetadata(t.meta,t.disclosure),r=sanitizeRecordSeriesProgress(safeRead(e,C));return r&&defineSafe(n,`recordSeriesProgress`,r),n}function sanitizeStringArray(e){if(!isArrayValue(e))return;let t=Math.min(safeArrayLength(e),128),n=[];for(let r=0;r<t;r+=1){let t=safeOwnPropertyDescriptor(e,String(r));if(!(t&&`value`in t)||typeof t.value!=`string`)return;n.push(t.value)}return n}function getTrustedErrorSnapshot(e){let t=safeRead(e,S);if(!isRecord(t))return;let n=safeRead(t,`cause`),r=safeRead(t,`code`),i=safeRead(t,`disclosure`),a=safeRead(t,`message`),o=safeRead(t,`meta`),s=safeRead(t,`name`),c=sanitizeTrustedPrismaCode(safeRead(t,`prismaCode`)),l=safeRead(t,`timestamp`),u=ownValue(t,`validation`);if(!(n!==void 0&&!isError(n)||typeof r!=`string`||!isResolvedDisclosure(i)||typeof a!=`string`||!isRecord(o)||typeof s!=`string`||typeof l!=`string`))return{cause:n,code:r,disclosure:i,message:a,meta:o,name:s,prismaCode:c,timestamp:l,...isRecord(u)?{validation:u}:{}}}function isResolvedDisclosure(e){return isRecord(e)&&typeof e.includeSql==`boolean`&&typeof e.includeParams==`boolean`&&typeof e.includeProviderDetails==`boolean`&&typeof e.includeCallsite==`boolean`}function serializeError(e,t,n){let i=createSafeRecord();if(t.seen.has(e))return defineSafe(i,`name`,`Error`),defineSafe(i,`message`,y),i;t.seen.add(e),defineSafe(i,`name`,safeErrorString(e,`name`,t)),defineSafe(i,`message`,safeErrorString(e,`message`,t));for(let t of r){let n=filterSafeErrorProperty(t,ownValue(e,t));n!==void 0&&defineSafe(i,t,n)}if(t.disclosure.includeProviderDetails)for(let n of[`detail`,`hint`]){let r=ownValue(e,n);typeof r==`string`&&defineSafe(i,n,sanitizeDiagnosticText(r,t))}let a=safeRead(e,`meta`);isRecord(a)&&defineSafe(i,`meta`,sanitizeUnknown(a,t,n+1,!0,!1));let o=getNestedCause(e);return o&&n<8&&defineSafe(i,`cause`,serializeError(o,t,n+1)),i}let O=function(e){return e.CONNECTION_FAILED=`V1001`,e.CONNECTION_TIMEOUT=`V1002`,e.CONNECTION_CLOSED=`V1003`,e.CLIENT_INITIALIZATION=`V1004`,e.CONNECTION_CAPACITY=`V1005`,e.QUERY_FAILED=`V2001`,e.QUERY_TIMEOUT=`V2002`,e.QUERY_SYNTAX=`V2003`,e.QUERY_SCHEMA_MISMATCH=`V2004`,e.QUERY_OUT_OF_RANGE=`V2005`,e.QUERY_RESULT_INVALID=`V2006`,e.UNIQUE_CONSTRAINT=`V3001`,e.FOREIGN_KEY_CONSTRAINT=`V3002`,e.NOT_NULL_CONSTRAINT=`V3003`,e.CHECK_CONSTRAINT=`V3004`,e.VALUE_TOO_LONG=`V3005`,e.VALIDATION_FAILED=`V4001`,e.INVALID_INPUT=`V4002`,e.MISSING_REQUIRED=`V4003`,e.TRANSACTION_FAILED=`V5001`,e.TRANSACTION_TIMEOUT=`V5002`,e.DEADLOCK=`V5003`,e.SERIALIZATION_FAILURE=`V5004`,e.INVALID_TRANSACTION_INPUT=`V5005`,e.TRANSACTION_CONTENTION=`V5006`,e.RECORD_NOT_FOUND=`V6001`,e.MODEL_NOT_FOUND=`V6002`,e.RELATION_NOT_FOUND=`V6003`,e.NESTED_WRITE_FAILED=`V7001`,e.NESTED_CREATE_FAILED=`V7002`,e.NESTED_UPDATE_FAILED=`V7003`,e.NESTED_DELETE_FAILED=`V7004`,e.NESTED_CONNECT_FAILED=`V7005`,e.NESTED_WRITE_ASSERTION_FAILED=`V7006`,e.FEATURE_NOT_SUPPORTED=`V8001`,e.DRIVER_NOT_SUPPORTED=`V8002`,e.UNSUPPORTED_OPERATION=`V8003`,e.CACHE_INVALID_TTL=`V10001`,e.CACHE_INVALID_KEY=`V10002`,e.CACHE_OPERATION_NOT_CACHEABLE=`V10003`,e.CACHE_CONFIGURATION=`V10004`,e.MIGRATION_FAILED=`V11001`,e.MIGRATION_NOT_FOUND=`V11002`,e.MIGRATION_CHECKSUM_MISMATCH=`V11003`,e.MIGRATION_DIALECT_MISMATCH=`V11004`,e.MIGRATION_LOCK_FAILED=`V11005`,e.MIGRATION_ALREADY_APPLIED=`V11006`,e.MIGRATION_OUT_OF_ORDER=`V11007`,e.MIGRATION_FILE_NOT_FOUND=`V11008`,e.MIGRATION_INVALID_STATE=`V11009`,e.MIGRATION_DESTRUCTIVE_REJECTED=`V11010`,e.MIGRATION_STORAGE_REQUIRED=`V11011`,e.MIGRATION_INVALID_ESTATE=`V11012`,e.MIGRATION_PATH_REQUIRED=`V11013`,e.MIGRATION_DRIFT=`V11014`,e.MIGRATION_MARKER_CONFLICT=`V11015`,e.MIGRATION_UNFINISHED_ATTEMPT=`V11016`,e.MIGRATION_CONSENT_REQUIRED=`V11017`,e.MIGRATION_CONSENT_MISMATCH=`V11018`,e.MIGRATION_PARTIAL_EFFECT=`V11019`,e.MIGRATION_AMBIGUOUS_COMMIT=`V11020`,e.MIGRATION_UNSUPPORTED_PROVIDER=`V11021`,e.MIGRATION_CORRUPTION=`V11022`,e.MIGRATION_INVALID_INDEX=`V11023`,e.OPERATION_ALREADY_EXECUTED=`V12001`,e.OPERATION_EXECUTION_CONFLICT=`V12002`,e.OPERATION_CLIENT_MISMATCH=`V12003`,e.OPERATION_SCOPE_MISMATCH=`V12004`,e.FORBIDDEN=`V13001`,e.INTERNAL_ERROR=`V9001`,e.SCHEMA_ERROR=`V9002`,e}({});const k=new Map([[O.CONNECTION_FAILED,`P1001`],[O.CONNECTION_TIMEOUT,`P1002`],[O.CONNECTION_CLOSED,`P1017`],[O.CLIENT_INITIALIZATION,`P1012`],[O.UNIQUE_CONSTRAINT,`P2002`],[O.FOREIGN_KEY_CONSTRAINT,`P2003`],[O.NOT_NULL_CONSTRAINT,`P2011`],[O.CHECK_CONSTRAINT,`P2004`],[O.VALUE_TOO_LONG,`P2000`],[O.VALIDATION_FAILED,`P2009`],[O.RECORD_NOT_FOUND,`P2025`]]);function toPrismaErrorCode(e){return k.get(e)}var VibORMError=class extends Error{static diagnosticName=`VibORMError`;code;originalCause;meta;timestamp;constructor(e,t,n){super(e);let r=readDiagnosticName(new.target);this.name=r,this.code=t,this.originalCause=n?.cause?sanitizeErrorCause(n.cause,n?.diagnostics):void 0,this.originalCause&&Object.defineProperty(this,`cause`,{value:this.originalCause,configurable:!0,writable:!0}),this.meta=sanitizeErrorMetadata(n?.meta??{},n?.diagnostics),this.timestamp=new Date,registerTrustedError(this,{cause:this.originalCause,code:t,disclosure:n?.diagnostics,message:e,meta:this.meta,name:r,prismaCode:toPrismaErrorCode(t),timestamp:this.timestamp,validation:n?.validation}),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}get prismaCode(){return toPrismaErrorCode(this.code)}isRetryable(){return verdictFor(this.code).retryable}toJSON(){return serializeTrustedError(this)??{name:`VibORMError`,message:`VibORM operation failed`,code:O.INTERNAL_ERROR,meta:{},timestamp:`Invalid Date`}}};function readDiagnosticName(e){let t=e;for(let e=0;e<16&&typeof t==`function`;e+=1){let e=safeOwnPropertyDescriptor(t,`diagnosticName`);if(e&&`value`in e&&typeof e.value==`string`&&e.value.length>0)return e.value;try{t=Object.getPrototypeOf(t)}catch{return`VibORMError`}}return`VibORMError`}function isVibORMError(e){return e instanceof VibORMError}const A={expected:!0,retryable:!1},j={expected:!0,retryable:!0},M={expected:!1,retryable:!1},N={[O.INTERNAL_ERROR]:!0,[O.SCHEMA_ERROR]:!0},P={[O.CONNECTION_FAILED]:!0,[O.CONNECTION_CAPACITY]:!0,[O.CONNECTION_TIMEOUT]:!0,[O.QUERY_TIMEOUT]:!0,[O.DEADLOCK]:!0,[O.SERIALIZATION_FAILURE]:!0,[O.TRANSACTION_CONTENTION]:!0};function verdictFor(e){return N[e]===!0?M:P[e]===!0?j:A}function isRetryableError(e){if(isVibORMError(e))return e.isRetryable();if(e instanceof Error&&`code`in e){let t=[`40001`,`40P01`,`SQLITE_BUSY`],n=e.code;return typeof n==`string`&&t.includes(n)}return!1}function wrapError(e,t=O.INTERNAL_ERROR,n,r){return isVibORMError(e)?e:new VibORMError(`VibORM operation failed`,t,{cause:e instanceof Error?e:Error(String(e)),meta:n,diagnostics:r})}export{isRecord as C,safeRead as D,safeOwnPropertyDescriptor as E,sanitizeSqlState as O,isError as S,safeArrayLength as T,sanitizeErrorMetadata as _,toPrismaErrorCode as a,errorCause as b,getTrustedErrorCause as c,registerTrustedRecordSeriesProgress as d,resolveDiagnosticDisclosure as f,sanitizeErrorForLogging as g,sanitizeErrorCause as h,isVibORMError as i,toError as k,getTrustedErrorDisclosure as l,sanitizeDiagnosticParameters as m,O as n,wrapError as o,sanitizeAllowedRecord as p,isRetryableError as r,d as s,VibORMError as t,getTrustedRecordSeriesProgress as u,sanitizeRecordSeriesProgress as v,isTrustedCode as w,isArrayValue as x,serializeTrustedError as y};
2
+ //# sourceMappingURL=base-wlv81COV.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base-wlv81COV.mjs","names":[],"sources":["../src/errors/diagnostic-safety.ts","../src/errors/diagnostics.ts","../src/errors/base.ts"],"sourcesContent":["export interface DiagnosticBudget {\n entries: number;\n characters: number;\n}\n\nexport const MAX_DIAGNOSTIC_ENTRIES = 256;\nexport const MAX_DIAGNOSTIC_ARRAY_LENGTH = 128;\nexport const TRUNCATED_DIAGNOSTIC_VALUE = \"[Truncated]\";\nexport const UNREADABLE_DIAGNOSTIC_VALUE = \"[Unreadable]\";\nexport const SAFE_ERROR_KEYS = [\n \"code\",\n \"errno\",\n \"sqlState\",\n \"sqlstate\",\n \"status\",\n \"statusCode\",\n] as const;\n\nconst MAX_STRING_LENGTH = 4096;\nconst MAX_TOTAL_CHARACTERS = 32_768;\nconst PROVIDER_STATUS_PATTERN = /^\\d{3}$/;\nconst SQL_STATE_PATTERN = /^[0-9A-Z]{5}$/;\nconst TRUSTED_CODE_PATTERN = /^V\\d{4,5}$/;\nconst PRISMA_CODE_PATTERN = /^P\\d{4}$/;\nconst SQL_STATE_CLASSES = new Set([\n \"00\",\n \"01\",\n \"02\",\n \"03\",\n \"08\",\n \"09\",\n \"0A\",\n \"0B\",\n \"0F\",\n \"0L\",\n \"0P\",\n \"0Z\",\n \"20\",\n \"21\",\n \"22\",\n \"23\",\n \"24\",\n \"25\",\n \"26\",\n \"27\",\n \"28\",\n \"2B\",\n \"2D\",\n \"2F\",\n \"34\",\n \"38\",\n \"39\",\n \"3B\",\n \"3D\",\n \"3F\",\n \"40\",\n \"42\",\n \"44\",\n \"53\",\n \"54\",\n \"55\",\n \"57\",\n \"58\",\n \"72\",\n \"F0\",\n \"HV\",\n \"HY\",\n \"IM\",\n \"P0\",\n \"S0\",\n \"XA\",\n \"XX\",\n]);\nconst STABLE_PROVIDER_CODES = new Set([\n \"CONNECTION_CLOSED\",\n \"ABORTED\",\n \"ALREADY_EXISTS\",\n \"CANCELLED\",\n \"DATA_LOSS\",\n \"DEADLINE_EXCEEDED\",\n \"EACCES\",\n \"EADDRINUSE\",\n \"EADDRNOTAVAIL\",\n \"EAFNOSUPPORT\",\n \"EAI_AGAIN\",\n \"EALREADY\",\n \"EBADF\",\n \"EBUSY\",\n \"ECONNABORTED\",\n \"ECONNREFUSED\",\n \"ECONNRESET\",\n \"EEXIST\",\n \"EHOSTUNREACH\",\n \"EINTR\",\n \"EINVAL\",\n \"EISCONN\",\n \"EMFILE\",\n \"ENETUNREACH\",\n \"ENFILE\",\n \"ENOENT\",\n \"ENOSPC\",\n \"ENOTCONN\",\n \"ENOTFOUND\",\n \"EPERM\",\n \"EPIPE\",\n \"ER_BAD_FIELD_ERROR\",\n \"ER_BAD_NULL_ERROR\",\n \"ER_CON_COUNT_ERROR\",\n \"ER_DATA_OUT_OF_RANGE\",\n \"ER_NO_SUCH_TABLE\",\n \"ER_TOO_MANY_USER_CONNECTIONS\",\n \"ER_WARN_DATA_OUT_OF_RANGE\",\n \"ER_CHECK_CONSTRAINT_VIOLATED\",\n \"ER_DUP_ENTRY\",\n \"ER_INVALID_JSON_TEXT_IN_PARAM\",\n \"ER_LOCK_DEADLOCK\",\n \"ER_LOCK_WAIT_TIMEOUT\",\n \"ER_NO_REFERENCED_ROW_2\",\n \"ER_ROW_IS_REFERENCED_2\",\n \"EROFS\",\n \"ETIMEDOUT\",\n \"FAILED_PRECONDITION\",\n \"INTERNAL\",\n \"INVALID_ARGUMENT\",\n \"NOT_FOUND\",\n \"OUT_OF_RANGE\",\n \"PERMISSION_DENIED\",\n \"RESOURCE_EXHAUSTED\",\n \"SQLITE_BUSY\",\n \"SQLITE_BUSY_RECOVERY\",\n \"SQLITE_BUSY_SNAPSHOT\",\n \"SQLITE_BUSY_TIMEOUT\",\n \"SQLITE_CONSTRAINT\",\n \"SQLITE_CONSTRAINT_CHECK\",\n \"SQLITE_CONSTRAINT_FOREIGNKEY\",\n \"SQLITE_CONSTRAINT_NOTNULL\",\n \"SQLITE_CONSTRAINT_UNIQUE\",\n \"SQLITE_ERROR\",\n \"SQLITE_LOCKED\",\n \"SQLITE_LOCKED_SHAREDCACHE\",\n \"SQLITE_LOCKED_VTAB\",\n \"UNAUTHENTICATED\",\n \"UNAVAILABLE\",\n \"UNIMPLEMENTED\",\n \"UNKNOWN\",\n]);\n\nexport function sanitizeBytes(\n value: Uint8Array,\n budget: DiagnosticBudget\n): unknown {\n const length = Math.min(\n value.byteLength,\n MAX_DIAGNOSTIC_ARRAY_LENGTH,\n Math.max(0, MAX_DIAGNOSTIC_ENTRIES - budget.entries)\n );\n const bytes: number[] = [];\n for (let index = 0; index < length; index += 1) {\n bytes.push(value[index]!);\n }\n const result = createSafeRecord();\n defineSafe(result, \"type\", \"binary\");\n defineSafe(result, \"byteLength\", value.byteLength);\n defineSafe(result, \"bytes\", bytes);\n if (value.byteLength > length) defineSafe(result, \"truncated\", true);\n budget.entries += length;\n return result;\n}\n\nexport function sanitizeString(\n value: string,\n budget: DiagnosticBudget\n): string {\n const available = Math.max(0, MAX_TOTAL_CHARACTERS - budget.characters);\n const length = Math.min(value.length, MAX_STRING_LENGTH, available);\n budget.characters += length;\n return length === value.length\n ? value\n : `${value.slice(0, length)}${TRUNCATED_DIAGNOSTIC_VALUE}`;\n}\n\nexport function safeErrorString(\n error: Error,\n key: \"name\" | \"message\",\n budget: DiagnosticBudget\n): string {\n const value = safeRead(error, key);\n return sanitizeString(typeof value === \"string\" ? value : \"Error\", budget);\n}\n\nexport function getNestedCause(error: Error): Error | undefined {\n const originalCause = safeRead(error, \"originalCause\");\n if (isError(originalCause)) return originalCause;\n const cause = safeRead(error, \"cause\");\n return isError(cause) ? cause : undefined;\n}\n\nexport function safeRead(value: object, key: PropertyKey): unknown {\n try {\n return Reflect.get(value, key);\n } catch {\n return UNREADABLE_DIAGNOSTIC_VALUE;\n }\n}\n\nexport function safeHasOwn(value: object, key: PropertyKey): boolean {\n try {\n return Object.hasOwn(value, key);\n } catch {\n return false;\n }\n}\n\nexport function safeOwnPropertyDescriptor(\n value: object,\n key: PropertyKey\n): PropertyDescriptor | undefined {\n try {\n return Reflect.getOwnPropertyDescriptor(value, key);\n } catch {\n return undefined;\n }\n}\n\nexport function isArrayValue(value: unknown): value is unknown[] {\n try {\n return Array.isArray(value);\n } catch {\n return false;\n }\n}\n\nexport function safeArrayLength(value: readonly unknown[]): number {\n const length = safeRead(value, \"length\");\n return typeof length === \"number\" &&\n Number.isSafeInteger(length) &&\n length >= 0\n ? length\n : 0;\n}\n\nexport function createSafeRecord(): Record<string, unknown> {\n return Object.create(null);\n}\n\nexport function defineSafe(target: object, key: string, value: unknown): void {\n try {\n Object.defineProperty(target, key, {\n configurable: true,\n enumerable: true,\n value,\n writable: true,\n });\n } catch {\n // The sanitizer owns every target, but remain total if the runtime rejects.\n }\n}\n\nexport function defineHidden(\n target: object,\n key: symbol,\n value: unknown\n): void {\n try {\n Object.defineProperty(target, key, {\n configurable: false,\n enumerable: false,\n value,\n writable: false,\n });\n } catch {\n // Registration is hardening; boundary sanitization still fails closed.\n }\n}\n\nexport function filterSafeErrorProperty(\n key: (typeof SAFE_ERROR_KEYS)[number],\n value: unknown\n): string | number | undefined {\n if (key === \"errno\") return sanitizeProviderErrno(value);\n if (key === \"sqlState\" || key === \"sqlstate\") {\n return sanitizeSqlState(value);\n }\n if (key === \"status\" || key === \"statusCode\") {\n return sanitizeProviderStatus(value);\n }\n return sanitizeProviderCode(value);\n}\n\nexport function sanitizeProviderCode(\n value: unknown\n): string | number | undefined {\n if (typeof value === \"number\") return sanitizeProviderErrno(value);\n if (typeof value !== \"string\" || value.length > 64) return undefined;\n // Any SQLSTATE-shaped code, standard class or not: a provider's own class\n // (PlanetScale Neki's `NK013`, a `RAISE … USING ERRCODE`) is what names\n // its refusal, and `providerSqlState` still admits only standard classes.\n return TRUSTED_CODE_PATTERN.test(value) ||\n SQL_STATE_PATTERN.test(value) ||\n STABLE_PROVIDER_CODES.has(value)\n ? value\n : undefined;\n}\n\nexport function sanitizeProviderErrno(value: unknown): number | undefined {\n return typeof value === \"number\" &&\n Number.isSafeInteger(value) &&\n value >= 0 &&\n value <= 2_147_483_647\n ? value\n : undefined;\n}\n\nexport function sanitizeSqlState(value: unknown): string | undefined {\n return typeof value === \"string\" &&\n SQL_STATE_PATTERN.test(value) &&\n SQL_STATE_CLASSES.has(value.slice(0, 2))\n ? value\n : undefined;\n}\n\nexport function sanitizeProviderStatus(\n value: unknown\n): string | number | undefined {\n if (\n typeof value === \"number\" &&\n Number.isSafeInteger(value) &&\n value >= 100 &&\n value <= 999\n ) {\n return value;\n }\n return typeof value === \"string\" && PROVIDER_STATUS_PATTERN.test(value)\n ? value\n : undefined;\n}\n\n/** The one shape rule for a VibORM code: `V` + four or five digits. */\nexport function isTrustedCode(value: unknown): value is string {\n return typeof value === \"string\" && TRUSTED_CODE_PATTERN.test(value);\n}\n\nexport function sanitizeTrustedCode(value: string): string {\n return isTrustedCode(value) ? value : \"V9001\";\n}\n\n/**\n * Prisma compatibility codes are `P` + four digits (P1001, P2002, …). Anything else is\n * dropped rather than echoed, so a hostile `prismaCode` cannot ride into diagnostics.\n */\nexport function sanitizeTrustedPrismaCode(value: unknown): string | undefined {\n return typeof value === \"string\" && PRISMA_CODE_PATTERN.test(value)\n ? value\n : undefined;\n}\n\nexport function boundTrustedString(value: string): string {\n return value.length <= MAX_STRING_LENGTH\n ? value\n : `${value.slice(0, MAX_STRING_LENGTH)}${TRUNCATED_DIAGNOSTIC_VALUE}`;\n}\n\nexport function safeDateString(value: Date): string {\n try {\n const milliseconds = Date.prototype.getTime.call(value);\n return Number.isFinite(milliseconds)\n ? Date.prototype.toISOString.call(value)\n : \"Invalid Date\";\n } catch {\n return \"Invalid Date\";\n }\n}\n\nexport function freezeDiagnosticValue<T>(value: T): T {\n if (typeof value !== \"object\" || value === null) return value;\n try {\n for (const key of Reflect.ownKeys(value)) {\n const descriptor = safeOwnPropertyDescriptor(value, key);\n if (descriptor && \"value\" in descriptor) {\n freezeDiagnosticValue(descriptor.value);\n }\n }\n return Object.freeze(value);\n } catch {\n return value;\n }\n}\n\nexport function isRecord(value: unknown): value is Record<string, unknown> {\n try {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n } catch {\n return false;\n }\n}\n\nexport function isError(value: unknown): value is Error {\n try {\n return value instanceof Error;\n } catch {\n return false;\n }\n}\n\n/**\n * The ONE normalizer for a thrown value that has to become an error's cause.\n *\n * A thrown `Error` stays the cause. Anything else becomes one deterministic\n * `Error` that keeps the thrown value as its own cause and never renders it —\n * rendering runs `toString` on a value chosen by whoever wrote the accessor.\n *\n * TOTAL, which a bare `thrown instanceof Error` is not: `instanceof` walks the\n * prototype chain through `[[GetPrototypeOf]]`, so a Proxy trap that throws\n * makes the TEST fail rather than the value. Every caller runs this inside the\n * `catch` that is building a typed error, so a throw here does not lose the\n * cause — it replaces the typed boundary with the trap's own error, and a\n * caller catching that boundary catches nothing. Driver options, the pinned\n * session, migrations, extensions, the cache and validation all normalize\n * through it rather than each writing the test again.\n */\nexport function errorCause(thrown: unknown): Error {\n if (isError(thrown)) return thrown;\n return new Error(\"A non-Error value was thrown.\", { cause: thrown });\n}\n\n/** Normalize one caught value into an Error without trusting its prototype. */\nexport function toError(thrown: unknown): Error {\n if (isError(thrown)) return thrown;\n return new Error(describeThrown(thrown), { cause: thrown });\n}\n\nfunction describeThrown(thrown: unknown): string {\n try {\n return String(thrown);\n } catch {\n return `a thrown ${typeof thrown} whose own string conversion threw`;\n }\n}\n","import {\n boundTrustedString,\n createSafeRecord,\n defineHidden,\n defineSafe,\n filterSafeErrorProperty,\n freezeDiagnosticValue,\n getNestedCause,\n isArrayValue,\n isError,\n isRecord,\n MAX_DIAGNOSTIC_ARRAY_LENGTH,\n MAX_DIAGNOSTIC_ENTRIES,\n SAFE_ERROR_KEYS,\n safeArrayLength,\n safeDateString,\n safeErrorString,\n safeHasOwn,\n safeOwnPropertyDescriptor,\n safeRead,\n sanitizeBytes,\n sanitizeProviderCode,\n sanitizeProviderErrno,\n sanitizeProviderStatus,\n sanitizeSqlState,\n sanitizeString,\n sanitizeTrustedCode,\n sanitizeTrustedPrismaCode,\n TRUNCATED_DIAGNOSTIC_VALUE,\n UNREADABLE_DIAGNOSTIC_VALUE,\n} from \"./diagnostic-safety\";\n\nexport interface DiagnosticDisclosure {\n includeSql?: boolean | undefined;\n includeParams?: boolean | undefined;\n /** Bounded provider message/detail/hint, with credential redaction. */\n includeProviderDetails?: boolean | undefined;\n /** The application stack captured when a deferred operation was created. */\n includeCallsite?: boolean | undefined;\n}\n\nexport const EMPTY_DISCLOSURE: DiagnosticDisclosure = Object.freeze({\n includeParams: false,\n includeSql: false,\n});\n\nexport interface ResolvedDiagnosticDisclosure {\n includeSql: boolean;\n includeParams: boolean;\n includeProviderDetails: boolean;\n includeCallsite: boolean;\n}\n\ninterface SanitizeState {\n readonly disclosure: ResolvedDiagnosticDisclosure;\n readonly seen: WeakSet<object>;\n entries: number;\n characters: number;\n}\n\ninterface TrustedErrorSnapshot {\n readonly cause?: Error | undefined;\n readonly code: string;\n readonly disclosure: ResolvedDiagnosticDisclosure;\n readonly message: string;\n readonly meta: Record<string, unknown>;\n readonly name: string;\n /** Prisma-compatible code, present only when the taxonomy claims one. */\n readonly prismaCode?: string | undefined;\n readonly timestamp: string;\n readonly validation?: Record<string, unknown>;\n}\n\nexport interface RecordSeriesProgress {\n readonly atomicity: \"segment\";\n readonly phase:\n | \"capture\"\n | \"planning\"\n | \"prefix\"\n | \"member\"\n | \"suffix\"\n | \"result\"\n | \"invalidation\";\n readonly committedSegments: number;\n readonly completedMembers: number;\n readonly committedWriteMembers: number;\n /** A dispatched write segment may be durable, but its provider could not acknowledge commit. */\n readonly mayHaveCommittedSegment?: true;\n readonly memberPath?: readonly number[];\n readonly totalMembers?: number;\n}\n\nconst MAX_DEPTH = 8;\nconst SQL_KEYS = new Set([\"query\", \"querytext\", \"sql\", \"statement\"]);\nconst PARAMETER_KEYS = new Set([\n \"arguments\",\n \"bindings\",\n \"parameters\",\n \"params\",\n \"values\",\n]);\nconst CAUSE_KEYS = new Set([\"cause\", \"originalcause\"]);\n/** How one metadata key's value is admitted: the value kept, or `undefined`. */\ntype MetaRule = (value: unknown) => unknown;\nconst text: MetaRule = (value) =>\n typeof value === \"string\" ? value : undefined;\nconst flag: MetaRule = (value) =>\n typeof value === \"boolean\" ? value : undefined;\n/** A finite, non-negative number no larger than `Number.MAX_SAFE_INTEGER`. */\nconst count: MetaRule = (value) =>\n typeof value === \"number\" &&\n Number.isFinite(value) &&\n value >= 0 &&\n value <= Number.MAX_SAFE_INTEGER\n ? value\n : undefined;\n// The migration-outcome keys (`stateId`, `fromState`, `toState`, `estateHash`,\n// `planHash`, `operationId`, `dispatchId`, `lastConfirmedStep`, `effectState`,\n// `partial`) are content addresses and authored operation ids of the estate,\n// never row data: a V11020 must still say which state and dispatch it lost.\nconst EFFECT_STATES: ReadonlySet<string> = new Set([\n \"none\",\n \"committed\",\n \"partial\",\n \"may-have-committed\",\n]);\n// Seven of these keys name a MIGRATION ESTATE: `namespace` (the configured\n// schema/database), `target`, `journalTarget` and `clientTarget` (formatted\n// estate descriptions a refusal compares), `command` (the migration verb that\n// was refused), `referencedTable` (the far end of a cross-database foreign\n// key), and `candidates` (the catalog spellings a configured namespace\n// matched). All seven are ORM configuration or catalog identifiers — never row\n// data, query text, or credentials — and plan §3.3 requires the normalized\n// namespace to reach safe metadata, so a refusal can be read programmatically\n// instead of only as prose.\nconst commitCertainty: MetaRule = (value) =>\n value === \"committed\" || value === \"may-have-committed\" ? value : undefined;\nconst effectState: MetaRule = (value) =>\n typeof value === \"string\" && EFFECT_STATES.has(value) ? value : undefined;\n/**\n * Every metadata key a sanitizer may keep, and how its value is admitted — in\n * key order, which is also the order sanitized metadata lists them.\n */\nconst META_KEY_VALUES: ReadonlyMap<string, MetaRule> = new Map<\n string,\n MetaRule\n>([\n [\"actualChecksum\", text],\n [\"actualResultCount\", count],\n [\"actualRowCount\", count],\n [\"autoIncrement\", flag],\n [\"callsite\", text],\n [\"candidates\", sanitizeStringArray],\n [\"clientTarget\", text],\n [\"column\", text],\n [\"columns\", sanitizeStringArray],\n [\"command\", text],\n [\"commitCertainty\", commitCertainty],\n [\"conflictsWith\", text],\n [\"constraint\", text],\n [\"context\", text],\n [\"correlationId\", text],\n [\"deprecation\", text],\n [\"dialect\", text],\n [\"dispatchId\", text],\n [\"driver\", text],\n [\"effectState\", effectState],\n [\"estateHash\", text],\n [\"expectedChecksum\", text],\n [\"expectedResultCount\", count],\n [\"expectedRowCount\", count],\n [\"expectedStatementCount\", count],\n [\"feature\", text],\n [\"field\", text],\n [\"fromState\", text],\n [\"hint\", text],\n [\"indexName\", text],\n [\"indexType\", text],\n [\"journalTarget\", text],\n [\"lastConfirmedStep\", text],\n [\"method\", text],\n [\"migrationIndex\", count],\n [\"migrationName\", text],\n [\"migrationsDir\", text],\n [\"model\", text],\n [\"namespace\", text],\n [\"notice\", text],\n [\"operation\", text],\n [\"operationId\", text],\n [\"parameterIndex\", count],\n [\"params\", (value) => (isArrayValue(value) ? value : undefined)],\n [\"partial\", flag],\n [\"planHash\", text],\n [\"providerCode\", sanitizeProviderCode],\n [\"providerErrno\", sanitizeProviderErrno],\n [\"providerSqlState\", sanitizeSqlState],\n [\"providerStatus\", sanitizeProviderStatus],\n [\"query\", text],\n [\"recordSeriesProgress\", sanitizeRecordSeriesProgress],\n [\"referencedTable\", text],\n [\"relation\", text],\n [\"relations\", sanitizeStringArray],\n [\"representation\", text],\n [\"resultIndex\", count],\n [\"scalarType\", text],\n [\"reason\", text],\n [\"stateId\", text],\n [\"statementIndex\", count],\n [\"step\", text],\n [\"strategy\", text],\n [\"table\", text],\n [\"target\", text],\n [\"timeout\", count],\n [\"toState\", text],\n [\"type\", text],\n]);\n// `deprecation` and `notice` are logger metadata (instrumentation/logger.ts);\n// an error's metadata keeps every other key.\nconst ERROR_META_KEYS: ReadonlySet<string> = new Set(\n [...META_KEY_VALUES.keys()].filter(\n (key) => key !== \"deprecation\" && key !== \"notice\"\n )\n);\nconst REDACTED_CAUSE_MESSAGE = \"Underlying error details redacted\";\nconst REDACTED_ERROR_MESSAGE = \"Error details redacted\";\nconst CIRCULAR_VALUE = \"[Circular]\";\nconst TRUNCATED_VALUE = TRUNCATED_DIAGNOSTIC_VALUE;\nconst UNREADABLE_VALUE = UNREADABLE_DIAGNOSTIC_VALUE;\nconst TRUSTED_ERROR_SNAPSHOT = Symbol(\"viborm.trustedErrorSnapshot\");\nconst TRUSTED_RECORD_SERIES_PROGRESS = Symbol(\n \"viborm.trustedRecordSeriesProgress\"\n);\n\nexport function resolveDiagnosticDisclosure(\n disclosure?: DiagnosticDisclosure\n): ResolvedDiagnosticDisclosure {\n return {\n includeSql: ownValue(disclosure, \"includeSql\") === true,\n includeParams: ownValue(disclosure, \"includeParams\") === true,\n includeProviderDetails:\n ownValue(disclosure, \"includeProviderDetails\") === true,\n includeCallsite: ownValue(disclosure, \"includeCallsite\") === true,\n };\n}\n\nexport function sanitizeErrorMetadata(\n value: Record<string, unknown>,\n disclosure?: DiagnosticDisclosure\n): Record<string, unknown> {\n return sanitizeAllowedRecord(value, ERROR_META_KEYS, disclosure, false);\n}\n\nexport function sanitizeDiagnosticParameters(\n value: readonly unknown[],\n disclosure?: DiagnosticDisclosure\n): unknown[] {\n return sanitizeArray(value, createState(disclosure), 0, false, true);\n}\n\nexport function sanitizeErrorForLogging(\n error: Error,\n disclosure?: DiagnosticDisclosure\n): Error {\n const trusted = getTrustedErrorDisclosure(error);\n return sanitizeError(\n error,\n createState({\n ...disclosure,\n // SQL/params stay channel-owned; these two diagnostics were selected by the operation.\n includeProviderDetails:\n trusted?.includeProviderDetails === true ||\n disclosure?.includeProviderDetails === true,\n includeCallsite:\n trusted?.includeCallsite === true ||\n disclosure?.includeCallsite === true,\n }),\n 0,\n false\n );\n}\n\nexport function sanitizeErrorCause(\n error: Error,\n disclosure?: DiagnosticDisclosure\n): Error {\n return sanitizeError(error, createState(disclosure), 0, true);\n}\n\nexport function serializeSanitizedError(\n error: Error | undefined,\n disclosure?: DiagnosticDisclosure\n): Record<string, unknown> | undefined {\n if (!error) return undefined;\n return serializeError(error, createState(disclosure), 0);\n}\n\nexport function registerTrustedError(\n error: Error,\n snapshot: {\n cause?: Error | undefined;\n code: string;\n disclosure?: DiagnosticDisclosure | undefined;\n message: string;\n meta: Record<string, unknown>;\n name: string;\n prismaCode?: string | undefined;\n timestamp: Date;\n validation?: { source: unknown; issues: unknown };\n }\n): void {\n const disclosure = resolveDiagnosticDisclosure(snapshot.disclosure);\n const trusted: TrustedErrorSnapshot = Object.freeze({\n cause: snapshot.cause\n ? freezeDiagnosticValue(\n sanitizeError(snapshot.cause, createState(disclosure), 0, true)\n )\n : undefined,\n code: sanitizeTrustedCode(snapshot.code),\n disclosure,\n message: boundTrustedString(snapshot.message),\n meta: freezeDiagnosticValue(\n sanitizeErrorMetadata(snapshot.meta, disclosure)\n ),\n name: boundTrustedString(snapshot.name),\n prismaCode: sanitizeTrustedPrismaCode(snapshot.prismaCode),\n timestamp: safeDateString(snapshot.timestamp),\n ...(snapshot.validation\n ? {\n validation: freezeDiagnosticValue(\n sanitizeValidationDetails(snapshot.validation)\n ),\n }\n : {}),\n });\n defineHidden(error, TRUSTED_ERROR_SNAPSHOT, trusted);\n}\n\nexport function serializeTrustedError(\n error: Error\n): Record<string, unknown> | undefined {\n const snapshot = getTrustedErrorSnapshot(error);\n if (!snapshot) return undefined;\n const serialized = createSafeRecord();\n defineSafe(serialized, \"name\", snapshot.name);\n defineSafe(serialized, \"message\", snapshot.message);\n defineSafe(serialized, \"code\", snapshot.code);\n if (snapshot.prismaCode !== undefined) {\n defineSafe(serialized, \"prismaCode\", snapshot.prismaCode);\n }\n defineSafe(\n serialized,\n \"meta\",\n trustedMetaWithRecordSeriesProgress(error, snapshot)\n );\n if (snapshot.validation) {\n defineSafe(serialized, \"source\", snapshot.validation.source);\n defineSafe(serialized, \"issues\", snapshot.validation.issues);\n }\n defineSafe(serialized, \"timestamp\", snapshot.timestamp);\n defineSafe(\n serialized,\n \"cause\",\n serializeSanitizedError(snapshot.cause, snapshot.disclosure)\n );\n return serialized;\n}\n\n/** Attach one already-sanitized committed-series diagnostic to trusted output. */\nexport function registerTrustedRecordSeriesProgress(\n error: Error,\n progress: RecordSeriesProgress\n): void {\n defineHidden(\n error,\n TRUSTED_RECORD_SERIES_PROGRESS,\n freezeDiagnosticValue(progress)\n );\n}\n\nexport function getTrustedRecordSeriesProgress(\n error: Error\n): RecordSeriesProgress | undefined {\n return sanitizeRecordSeriesProgress(\n safeRead(error, TRUSTED_RECORD_SERIES_PROGRESS)\n );\n}\n\nexport function sanitizeRecordSeriesProgress(\n value: unknown\n): RecordSeriesProgress | undefined {\n if (!isRecord(value)) return undefined;\n const atomicity = safeRead(value, \"atomicity\");\n const phase = safeRead(value, \"phase\");\n const committedSegments = safeProgressInteger(\n safeRead(value, \"committedSegments\")\n );\n const completedMembers = safeProgressInteger(\n safeRead(value, \"completedMembers\")\n );\n const committedWriteMembers = safeProgressInteger(\n safeRead(value, \"committedWriteMembers\")\n );\n const mayHaveCommittedSegmentValue = safeRead(\n value,\n \"mayHaveCommittedSegment\"\n );\n const totalMembersValue = safeRead(value, \"totalMembers\");\n const totalMembers =\n totalMembersValue === undefined\n ? undefined\n : safeProgressInteger(totalMembersValue);\n const memberPathValue = safeRead(value, \"memberPath\");\n const memberPath =\n memberPathValue === undefined\n ? undefined\n : sanitizeProgressMemberPath(memberPathValue);\n if (\n atomicity !== \"segment\" ||\n !isRecordSeriesProgressPhase(phase) ||\n committedSegments === undefined ||\n completedMembers === undefined ||\n committedWriteMembers === undefined ||\n (mayHaveCommittedSegmentValue !== undefined &&\n mayHaveCommittedSegmentValue !== true) ||\n (totalMembersValue !== undefined && totalMembers === undefined) ||\n (memberPathValue !== undefined && memberPath === undefined)\n ) {\n return undefined;\n }\n return Object.freeze({\n atomicity,\n phase,\n committedSegments,\n completedMembers,\n committedWriteMembers,\n ...(mayHaveCommittedSegmentValue === true\n ? { mayHaveCommittedSegment: true as const }\n : {}),\n ...(memberPath ? { memberPath: Object.freeze(memberPath) } : {}),\n ...(totalMembers !== undefined ? { totalMembers } : {}),\n });\n}\n\nfunction isRecordSeriesProgressPhase(\n value: unknown\n): value is RecordSeriesProgress[\"phase\"] {\n return (\n value === \"capture\" ||\n value === \"planning\" ||\n value === \"prefix\" ||\n value === \"member\" ||\n value === \"suffix\" ||\n value === \"result\" ||\n value === \"invalidation\"\n );\n}\n\nexport function getTrustedErrorCause(error: Error): Error | undefined {\n return getTrustedErrorSnapshot(error)?.cause;\n}\n\nconst URL_CREDENTIALS = /([a-z][a-z0-9+.-]*:\\/\\/)[^/\\s]*@/gi;\nconst TRUNCATED_URL_CREDENTIALS = /([a-z][a-z0-9+.-]*:\\/\\/)[^/\\s]*:[^/\\s]*$/gi;\nconst BEARER_CREDENTIALS = /\\bBearer\\s+[^\\s,;]+/gi;\nconst NAMED_CREDENTIALS =\n /((?:password|passwd|pwd|token|auth[_-]?token|api[_-]?key|secret)[\"']?\\s*[=:]\\s*)(?:\"[^\"\\n]*\"|'[^'\\n]*'|[^\\s&,;]+)/gi;\n\nfunction ownValue(value: unknown, key: string): unknown {\n if (typeof value !== \"object\" || value === null) return undefined;\n const descriptor = safeOwnPropertyDescriptor(value, key);\n return descriptor && \"value\" in descriptor ? descriptor.value : undefined;\n}\n\nfunction sanitizeDiagnosticText(value: string, state: SanitizeState): string {\n return sanitizeString(value, state)\n .replace(URL_CREDENTIALS, \"$1[REDACTED]@\")\n .replace(TRUNCATED_URL_CREDENTIALS, \"$1[REDACTED]\")\n .replace(NAMED_CREDENTIALS, \"$1[REDACTED]\")\n .replace(BEARER_CREDENTIALS, \"Bearer [REDACTED]\");\n}\n\n/** Preserve the selected disclosure through package-owned error clones. */\nexport function getTrustedErrorDisclosure(\n error: Error\n): DiagnosticDisclosure | undefined {\n return getTrustedErrorSnapshot(error)?.disclosure;\n}\n\nfunction sanitizeValidationDetails(details: {\n source: unknown;\n issues: unknown;\n}): Record<string, unknown> {\n const state = createState();\n const source = createSafeRecord();\n for (const key of [\n \"kind\",\n \"operation\",\n \"model\",\n \"property\",\n \"builder\",\n \"path\",\n \"target\",\n \"schemaType\",\n ]) {\n const value = ownValue(details.source, key);\n if (typeof value === \"string\")\n defineSafe(source, key, sanitizeDiagnosticText(value, state));\n }\n const issues: Record<string, unknown>[] = [];\n if (isArrayValue(details.issues)) {\n for (\n let index = 0;\n index <\n Math.min(safeArrayLength(details.issues), MAX_DIAGNOSTIC_ARRAY_LENGTH);\n index += 1\n ) {\n const issue = ownValue(details.issues, String(index));\n const path = ownValue(issue, \"path\");\n const message = ownValue(issue, \"message\");\n if (typeof path === \"string\" && typeof message === \"string\")\n issues.push({\n path: sanitizeDiagnosticText(path, state),\n message: sanitizeDiagnosticText(message, state),\n });\n }\n }\n return { source, issues };\n}\n\nfunction createState(disclosure?: DiagnosticDisclosure): SanitizeState {\n return {\n disclosure: resolveDiagnosticDisclosure(disclosure),\n seen: new WeakSet<object>(),\n entries: 0,\n characters: 0,\n };\n}\n\nfunction sanitizeUnknown(\n value: unknown,\n state: SanitizeState,\n depth: number,\n insideCause: boolean,\n insideParameters: boolean\n): unknown {\n try {\n if (depth > MAX_DEPTH || state.entries >= MAX_DIAGNOSTIC_ENTRIES) {\n return TRUNCATED_VALUE;\n }\n if (typeof value === \"string\") {\n return insideCause\n ? REDACTED_CAUSE_MESSAGE\n : sanitizeString(value, state);\n }\n if (\n value === null ||\n typeof value === \"number\" ||\n typeof value === \"boolean\"\n ) {\n return value;\n }\n if (typeof value === \"bigint\") {\n return sanitizeString(value.toString(), state);\n }\n if (typeof value === \"undefined\") return \"[Undefined]\";\n if (typeof value === \"symbol\") return sanitizeString(String(value), state);\n if (typeof value === \"function\") return \"[Function]\";\n if (value instanceof Error) {\n return sanitizeError(value, state, depth, true);\n }\n if (value instanceof Date) {\n const timestamp = Date.prototype.getTime.call(value);\n return Number.isFinite(timestamp)\n ? sanitizeString(Date.prototype.toISOString.call(value), state)\n : \"[Invalid Date]\";\n }\n if (value instanceof ArrayBuffer) {\n return sanitizeBytes(new Uint8Array(value), state);\n }\n if (ArrayBuffer.isView(value)) {\n return sanitizeBytes(\n new Uint8Array(value.buffer, value.byteOffset, value.byteLength),\n state\n );\n }\n if (state.seen.has(value)) return CIRCULAR_VALUE;\n state.seen.add(value);\n if (isArrayValue(value)) {\n return sanitizeArray(value, state, depth, insideCause, insideParameters);\n }\n return sanitizeObject(value, state, depth, insideCause, insideParameters);\n } catch {\n return UNREADABLE_VALUE;\n }\n}\n\nfunction sanitizeArray(\n value: readonly unknown[],\n state: SanitizeState,\n depth: number,\n insideCause: boolean,\n insideParameters: boolean\n): unknown[] {\n const length = Math.min(safeArrayLength(value), MAX_DIAGNOSTIC_ARRAY_LENGTH);\n const result: unknown[] = [];\n for (let index = 0; index < length; index += 1) {\n if (state.entries >= MAX_DIAGNOSTIC_ENTRIES) {\n result.push(TRUNCATED_VALUE);\n break;\n }\n state.entries += 1;\n const descriptor = safeOwnPropertyDescriptor(value, String(index));\n const entry =\n descriptor && \"value\" in descriptor ? descriptor.value : UNREADABLE_VALUE;\n result.push(\n sanitizeUnknown(entry, state, depth + 1, insideCause, insideParameters)\n );\n }\n if (safeArrayLength(value) > length) result.push(TRUNCATED_VALUE);\n return result;\n}\n\nfunction sanitizeObject(\n value: object,\n state: SanitizeState,\n depth: number,\n insideCause: boolean,\n insideParameters: boolean\n): Record<string, unknown> {\n const result = createSafeRecord();\n try {\n for (const key in value) {\n if (!safeHasOwn(value, key)) continue;\n if (state.entries >= MAX_DIAGNOSTIC_ENTRIES) {\n defineSafe(result, \"truncated\", TRUNCATED_VALUE);\n break;\n }\n const normalizedKey = key.length <= 64 ? key.toLowerCase() : \"\";\n if (\n !insideParameters &&\n SQL_KEYS.has(normalizedKey) &&\n !state.disclosure.includeSql\n ) {\n continue;\n }\n if (\n !insideParameters &&\n PARAMETER_KEYS.has(normalizedKey) &&\n !state.disclosure.includeParams\n ) {\n continue;\n }\n if (\n insideCause &&\n (normalizedKey === \"stack\" ||\n (!state.disclosure.includeProviderDetails &&\n (normalizedKey === \"message\" ||\n normalizedKey === \"detail\" ||\n normalizedKey === \"hint\")))\n ) {\n continue;\n }\n if (normalizedKey === \"callsite\" && !state.disclosure.includeCallsite)\n continue;\n state.entries += 1;\n const descriptor = safeOwnPropertyDescriptor(value, key);\n const raw =\n descriptor && \"value\" in descriptor\n ? descriptor.value\n : UNREADABLE_VALUE;\n defineSafe(\n result,\n sanitizeString(key, state),\n sanitizeUnknown(\n raw,\n state,\n depth + 1,\n insideCause || (!insideParameters && CAUSE_KEYS.has(normalizedKey)),\n insideParameters || PARAMETER_KEYS.has(normalizedKey)\n )\n );\n }\n } catch {\n defineSafe(result, \"unreadable\", UNREADABLE_VALUE);\n }\n return result;\n}\n\nfunction sanitizeError(\n error: Error,\n state: SanitizeState,\n depth: number,\n redactMessage: boolean\n): Error {\n if (depth > MAX_DEPTH) return new Error(TRUNCATED_VALUE);\n if (state.seen.has(error)) return new Error(CIRCULAR_VALUE);\n state.seen.add(error);\n\n const trusted = redactMessage ? undefined : getTrustedErrorSnapshot(error);\n const providerMessage = state.disclosure.includeProviderDetails\n ? ownValue(error, \"message\")\n : undefined;\n const sanitized = new Error(\n !trusted && typeof providerMessage === \"string\"\n ? sanitizeDiagnosticText(providerMessage, state)\n : redactMessage\n ? REDACTED_CAUSE_MESSAGE\n : trusted\n ? sanitizeString(trusted.message, state)\n : REDACTED_ERROR_MESSAGE\n );\n sanitized.name = trusted ? sanitizeString(trusted.name, state) : \"Error\";\n sanitized.stack = undefined;\n if (state.disclosure.includeProviderDetails && !trusted) {\n for (const key of [\"detail\", \"hint\"] as const) {\n const value = ownValue(error, key);\n if (typeof value === \"string\")\n defineSafe(sanitized, key, sanitizeDiagnosticText(value, state));\n }\n }\n\n if (trusted) {\n defineSafe(sanitized, \"code\", trusted.code);\n if (trusted.prismaCode !== undefined) {\n defineSafe(sanitized, \"prismaCode\", trusted.prismaCode);\n }\n } else {\n for (const key of SAFE_ERROR_KEYS) {\n const value = ownValue(error, key);\n const filtered = filterSafeErrorProperty(key, value);\n if (filtered !== undefined) defineSafe(sanitized, key, filtered);\n }\n }\n const meta = trusted\n ? trustedMetaWithRecordSeriesProgress(error, trusted)\n : undefined;\n if (!redactMessage && meta) {\n defineSafe(\n sanitized,\n \"meta\",\n sanitizeErrorMetadata(meta, state.disclosure)\n );\n }\n if (trusted) {\n defineSafe(sanitized, \"timestamp\", trusted.timestamp);\n registerTrustedError(sanitized, {\n cause: trusted.cause,\n code: trusted.code,\n disclosure: state.disclosure,\n message: trusted.message,\n meta: trusted.meta,\n name: trusted.name,\n prismaCode: trusted.prismaCode,\n timestamp: new Date(trusted.timestamp),\n ...(trusted.validation\n ? {\n validation: {\n source: trusted.validation.source,\n issues: trusted.validation.issues,\n },\n }\n : {}),\n });\n Object.defineProperty(sanitized, \"toJSON\", {\n value: () => serializeTrustedError(sanitized),\n });\n const progress = sanitizeRecordSeriesProgress(\n safeRead(error, TRUSTED_RECORD_SERIES_PROGRESS)\n );\n if (progress) registerTrustedRecordSeriesProgress(sanitized, progress);\n }\n\n const nested = trusted?.cause ?? getNestedCause(error);\n if (nested) {\n const safeCause = sanitizeError(nested, state, depth + 1, true);\n defineSafe(sanitized, \"cause\", safeCause);\n defineSafe(sanitized, \"originalCause\", safeCause);\n }\n return sanitized;\n}\n\n/**\n * Keep only the allowed keys of a metadata record, each sanitized. With\n * `validateLogMetadata`, `event` and `status` must also be known log values.\n */\nexport function sanitizeAllowedRecord(\n value: Record<string, unknown>,\n allowedKeys: ReadonlySet<string>,\n disclosure: DiagnosticDisclosure | undefined,\n validateLogMetadata: boolean\n): Record<string, unknown> {\n const selected = createSafeRecord();\n const state = createState(disclosure);\n for (const key of allowedKeys) {\n const descriptor = safeOwnPropertyDescriptor(value, key);\n if (!(descriptor && \"value\" in descriptor)) continue;\n const raw =\n key === \"callsite\" && typeof descriptor.value === \"string\"\n ? sanitizeDiagnosticText(descriptor.value, state)\n : descriptor.value;\n const filtered = filterAllowedDiagnosticValue(\n key,\n raw,\n validateLogMetadata\n );\n if (filtered === undefined) continue;\n defineSafe(selected, key, filtered);\n }\n return sanitizeObject(selected, state, 0, false, false);\n}\n\nfunction filterAllowedDiagnosticValue(\n key: string,\n value: unknown,\n validateLogMetadata: boolean\n): unknown {\n if (key === \"event\" && validateLogMetadata) {\n return typeof value === \"string\" &&\n [\"bypass\", \"hit\", \"miss\", \"revalidate\"].includes(value)\n ? value\n : undefined;\n }\n if (key === \"status\" && validateLogMetadata) {\n return typeof value === \"string\" &&\n [\n \"cache-set-failed\",\n \"error\",\n \"fresh\",\n \"stale\",\n \"start\",\n \"success\",\n ].includes(value)\n ? value\n : undefined;\n }\n // An unclassified key is refused: it has no rule until it receives one.\n return META_KEY_VALUES.get(key)?.(value);\n}\n\nfunction safeProgressInteger(value: unknown): number | undefined {\n return typeof value === \"number\" && Number.isSafeInteger(value) && value >= 0\n ? value\n : undefined;\n}\n\nfunction sanitizeProgressMemberPath(value: unknown): number[] | undefined {\n if (!isArrayValue(value)) return undefined;\n const length = safeArrayLength(value);\n if (length > 32) return undefined;\n const path: number[] = [];\n for (let index = 0; index < length; index += 1) {\n const descriptor = safeOwnPropertyDescriptor(value, String(index));\n if (!(descriptor && \"value\" in descriptor)) return undefined;\n const ordinal = safeProgressInteger(descriptor.value);\n if (ordinal === undefined) return undefined;\n path.push(ordinal);\n }\n return path;\n}\n\nfunction trustedMetaWithRecordSeriesProgress(\n error: Error,\n snapshot: TrustedErrorSnapshot\n): Record<string, unknown> {\n const meta = sanitizeErrorMetadata(snapshot.meta, snapshot.disclosure);\n const progress = sanitizeRecordSeriesProgress(\n safeRead(error, TRUSTED_RECORD_SERIES_PROGRESS)\n );\n if (progress) defineSafe(meta, \"recordSeriesProgress\", progress);\n return meta;\n}\n\nfunction sanitizeStringArray(value: unknown): string[] | undefined {\n if (!isArrayValue(value)) return undefined;\n const length = Math.min(safeArrayLength(value), MAX_DIAGNOSTIC_ARRAY_LENGTH);\n const strings: string[] = [];\n for (let index = 0; index < length; index += 1) {\n const descriptor = safeOwnPropertyDescriptor(value, String(index));\n if (!(descriptor && \"value\" in descriptor)) return undefined;\n if (typeof descriptor.value !== \"string\") return undefined;\n strings.push(descriptor.value);\n }\n return strings;\n}\n\nfunction getTrustedErrorSnapshot(\n error: Error\n): TrustedErrorSnapshot | undefined {\n const snapshot = safeRead(error, TRUSTED_ERROR_SNAPSHOT);\n if (!isRecord(snapshot)) return undefined;\n const cause = safeRead(snapshot, \"cause\");\n const code = safeRead(snapshot, \"code\");\n const disclosure = safeRead(snapshot, \"disclosure\");\n const message = safeRead(snapshot, \"message\");\n const meta = safeRead(snapshot, \"meta\");\n const name = safeRead(snapshot, \"name\");\n const prismaCode = sanitizeTrustedPrismaCode(\n safeRead(snapshot, \"prismaCode\")\n );\n const timestamp = safeRead(snapshot, \"timestamp\");\n const validation = ownValue(snapshot, \"validation\");\n if (\n (cause !== undefined && !isError(cause)) ||\n typeof code !== \"string\" ||\n !isResolvedDisclosure(disclosure) ||\n typeof message !== \"string\" ||\n !isRecord(meta) ||\n typeof name !== \"string\" ||\n typeof timestamp !== \"string\"\n ) {\n return undefined;\n }\n return {\n cause,\n code,\n disclosure,\n message,\n meta,\n name,\n prismaCode,\n timestamp,\n ...(isRecord(validation) ? { validation } : {}),\n };\n}\n\nfunction isResolvedDisclosure(\n value: unknown\n): value is ResolvedDiagnosticDisclosure {\n return (\n isRecord(value) &&\n typeof value.includeSql === \"boolean\" &&\n typeof value.includeParams === \"boolean\" &&\n typeof value.includeProviderDetails === \"boolean\" &&\n typeof value.includeCallsite === \"boolean\"\n );\n}\n\nfunction serializeError(\n error: Error,\n state: SanitizeState,\n depth: number\n): Record<string, unknown> {\n const serialized = createSafeRecord();\n if (state.seen.has(error)) {\n defineSafe(serialized, \"name\", \"Error\");\n defineSafe(serialized, \"message\", CIRCULAR_VALUE);\n return serialized;\n }\n state.seen.add(error);\n defineSafe(serialized, \"name\", safeErrorString(error, \"name\", state));\n defineSafe(serialized, \"message\", safeErrorString(error, \"message\", state));\n for (const key of SAFE_ERROR_KEYS) {\n const value = ownValue(error, key);\n const filtered = filterSafeErrorProperty(key, value);\n if (filtered !== undefined) defineSafe(serialized, key, filtered);\n }\n if (state.disclosure.includeProviderDetails) {\n for (const key of [\"detail\", \"hint\"] as const) {\n const value = ownValue(error, key);\n if (typeof value === \"string\")\n defineSafe(serialized, key, sanitizeDiagnosticText(value, state));\n }\n }\n const meta = safeRead(error, \"meta\");\n if (isRecord(meta)) {\n defineSafe(\n serialized,\n \"meta\",\n sanitizeUnknown(meta, state, depth + 1, true, false)\n );\n }\n const nested = getNestedCause(error);\n if (nested && depth < MAX_DEPTH) {\n defineSafe(serialized, \"cause\", serializeError(nested, state, depth + 1));\n }\n return serialized;\n}\n","import { safeOwnPropertyDescriptor } from \"./diagnostic-safety\";\nimport {\n type DiagnosticDisclosure,\n registerTrustedError,\n sanitizeErrorCause,\n sanitizeErrorMetadata,\n serializeTrustedError,\n} from \"./diagnostics\";\n\n/**\n * Error codes for programmatic error handling\n */\nexport enum VibORMErrorCode {\n // Connection errors (1xxx)\n CONNECTION_FAILED = \"V1001\",\n CONNECTION_TIMEOUT = \"V1002\",\n CONNECTION_CLOSED = \"V1003\",\n CLIENT_INITIALIZATION = \"V1004\",\n CONNECTION_CAPACITY = \"V1005\",\n\n // Query errors (2xxx)\n QUERY_FAILED = \"V2001\",\n QUERY_TIMEOUT = \"V2002\",\n QUERY_SYNTAX = \"V2003\",\n QUERY_SCHEMA_MISMATCH = \"V2004\",\n QUERY_OUT_OF_RANGE = \"V2005\",\n QUERY_RESULT_INVALID = \"V2006\",\n\n // Constraint errors (3xxx)\n UNIQUE_CONSTRAINT = \"V3001\",\n FOREIGN_KEY_CONSTRAINT = \"V3002\",\n NOT_NULL_CONSTRAINT = \"V3003\",\n CHECK_CONSTRAINT = \"V3004\",\n VALUE_TOO_LONG = \"V3005\",\n\n // Validation errors (4xxx)\n VALIDATION_FAILED = \"V4001\",\n INVALID_INPUT = \"V4002\",\n MISSING_REQUIRED = \"V4003\",\n\n // Transaction errors (5xxx)\n TRANSACTION_FAILED = \"V5001\",\n TRANSACTION_TIMEOUT = \"V5002\",\n DEADLOCK = \"V5003\",\n SERIALIZATION_FAILURE = \"V5004\",\n INVALID_TRANSACTION_INPUT = \"V5005\",\n TRANSACTION_CONTENTION = \"V5006\",\n\n // Not found errors (6xxx)\n RECORD_NOT_FOUND = \"V6001\",\n MODEL_NOT_FOUND = \"V6002\",\n RELATION_NOT_FOUND = \"V6003\",\n\n // Nested write errors (7xxx)\n NESTED_WRITE_FAILED = \"V7001\",\n NESTED_CREATE_FAILED = \"V7002\",\n NESTED_UPDATE_FAILED = \"V7003\",\n NESTED_DELETE_FAILED = \"V7004\",\n NESTED_CONNECT_FAILED = \"V7005\",\n NESTED_WRITE_ASSERTION_FAILED = \"V7006\",\n\n // Feature errors (8xxx)\n FEATURE_NOT_SUPPORTED = \"V8001\",\n DRIVER_NOT_SUPPORTED = \"V8002\",\n /** A payload SHAPE the query engine deliberately does not express (a documented\n * capability boundary), distinct from FEATURE_NOT_SUPPORTED (a dialect/driver\n * capability gap). Carried by UnsupportedOperationError. */\n UNSUPPORTED_OPERATION = \"V8003\",\n\n // Cache errors (10xxx)\n CACHE_INVALID_TTL = \"V10001\",\n CACHE_INVALID_KEY = \"V10002\",\n CACHE_OPERATION_NOT_CACHEABLE = \"V10003\",\n CACHE_CONFIGURATION = \"V10004\",\n\n // Migration errors (11xxx)\n MIGRATION_FAILED = \"V11001\",\n MIGRATION_NOT_FOUND = \"V11002\",\n MIGRATION_CHECKSUM_MISMATCH = \"V11003\",\n MIGRATION_DIALECT_MISMATCH = \"V11004\",\n MIGRATION_LOCK_FAILED = \"V11005\",\n MIGRATION_ALREADY_APPLIED = \"V11006\",\n MIGRATION_OUT_OF_ORDER = \"V11007\",\n MIGRATION_FILE_NOT_FOUND = \"V11008\",\n MIGRATION_INVALID_STATE = \"V11009\",\n MIGRATION_DESTRUCTIVE_REJECTED = \"V11010\",\n MIGRATION_STORAGE_REQUIRED = \"V11011\",\n MIGRATION_INVALID_ESTATE = \"V11012\",\n MIGRATION_PATH_REQUIRED = \"V11013\",\n MIGRATION_DRIFT = \"V11014\",\n MIGRATION_MARKER_CONFLICT = \"V11015\",\n MIGRATION_UNFINISHED_ATTEMPT = \"V11016\",\n MIGRATION_CONSENT_REQUIRED = \"V11017\",\n MIGRATION_CONSENT_MISMATCH = \"V11018\",\n MIGRATION_PARTIAL_EFFECT = \"V11019\",\n MIGRATION_AMBIGUOUS_COMMIT = \"V11020\",\n MIGRATION_UNSUPPORTED_PROVIDER = \"V11021\",\n MIGRATION_CORRUPTION = \"V11022\",\n MIGRATION_INVALID_INDEX = \"V11023\",\n\n // Pending operation errors (12xxx)\n OPERATION_ALREADY_EXECUTED = \"V12001\",\n OPERATION_EXECUTION_CONFLICT = \"V12002\",\n OPERATION_CLIENT_MISMATCH = \"V12003\",\n OPERATION_SCOPE_MISMATCH = \"V12004\",\n\n // Authorization errors (13xxx)\n FORBIDDEN = \"V13001\",\n\n // Internal errors (9xxx)\n INTERNAL_ERROR = \"V9001\",\n SCHEMA_ERROR = \"V9002\",\n}\n\n/**\n * A Prisma error code VibORM is willing to claim.\n *\n * Only codes that appear in {@link PRISMA_CODE_BY_VIBORM_CODE} are listed — the union is the\n * published surface, not the whole Prisma catalogue.\n */\nexport type PrismaErrorCode =\n | \"P1001\"\n | \"P1002\"\n | \"P1012\"\n | \"P1017\"\n | \"P2000\"\n | \"P2002\"\n | \"P2003\"\n | \"P2004\"\n | \"P2009\"\n | \"P2011\"\n | \"P2025\";\n\n/**\n * VibORM code → Prisma code, for `catch` blocks written against Prisma.\n *\n * Prisma surfaces its code as `error.code` on `PrismaClientKnownRequestError` (P2xxx) and as\n * `error.errorCode` on `PrismaClientInitializationError` (P1xxx). VibORM keeps its own stable\n * `V####` taxonomy on `error.code` and publishes the Prisma equivalent next to it as\n * `error.prismaCode`, so `if (e.prismaCode === \"P2002\")` is the one-token port of\n * `if (e.code === \"P2002\")`.\n *\n * **The table is deliberately partial.** A VibORM code maps only where Prisma documents a code\n * with the same meaning. Everything else reports `undefined` rather than a near-neighbour: an\n * unclaimed code is honest, a wrong one silently mis-routes a caller's error handling.\n *\n * Sources (checked 2026-07-27):\n * - https://www.prisma.io/docs/orm/reference/error-reference — P1001 \"Can't reach database\n * server\", P1002 \"…was reached but timed out\", P1012 schema validation error, P1017 \"Server\n * has closed the connection\", P2000 \"The provided value for the column is too long for the\n * column's type\", P2002 \"Unique constraint failed on the {constraint}\", P2003 \"Foreign key\n * constraint violated on the {constraint}\", P2004 \"A constraint failed on the database:\n * {database_error}\", P2009 \"Failed to validate the query: {query_validation_error}\", P2011\n * \"Null constraint violation on the {constraint}\", P2025 \"An operation failed because it\n * depends on one or more records that were required but not found\".\n * - prisma-engines `libs/user-facing-errors/src/query_engine/mod.rs` pins those codes to the\n * engine error kinds (`InputValueTooLong` = P2000, `UniqueKeyViolation` = P2002,\n * `ConstraintViolation` = P2004, `NullConstraintViolation` = P2011, …).\n *\n * Deliberately unmapped (documented refusals, not oversights):\n * - Transaction family (V5xxx). Prisma has P2028 (transaction API) and P2034 (write conflict\n * or deadlock), but VibORM's transaction family also carries `SQLITE_BUSY` and transaction\n * timeouts, so no member is 1:1 with either. Use {@link VibORMError.isRetryable} instead.\n * - Nested-write (V7xxx), cache (V10xxx), migration (V11xxx), pending-operation (V12xxx),\n * authorization (V13xxx), feature/driver support (V8xxx incl. `UnsupportedOperationError`)\n * and internal (V9xxx) codes: VibORM-only concepts with no Prisma counterpart.\n * - Query family (V2xxx). Prisma's P2010 is raw-query-specific and P2021/P2022 name a missing\n * table/column; a generic `QueryError` is none of those.\n */\nconst PRISMA_CODE_BY_VIBORM_CODE: ReadonlyMap<\n VibORMErrorCode,\n PrismaErrorCode\n> = new Map<VibORMErrorCode, PrismaErrorCode>([\n [VibORMErrorCode.CONNECTION_FAILED, \"P1001\"],\n [VibORMErrorCode.CONNECTION_TIMEOUT, \"P1002\"],\n [VibORMErrorCode.CONNECTION_CLOSED, \"P1017\"],\n [VibORMErrorCode.CLIENT_INITIALIZATION, \"P1012\"],\n [VibORMErrorCode.UNIQUE_CONSTRAINT, \"P2002\"],\n [VibORMErrorCode.FOREIGN_KEY_CONSTRAINT, \"P2003\"],\n [VibORMErrorCode.NOT_NULL_CONSTRAINT, \"P2011\"],\n [VibORMErrorCode.CHECK_CONSTRAINT, \"P2004\"],\n [VibORMErrorCode.VALUE_TOO_LONG, \"P2000\"],\n [VibORMErrorCode.VALIDATION_FAILED, \"P2009\"],\n [VibORMErrorCode.RECORD_NOT_FOUND, \"P2025\"],\n]);\n\n/**\n * Prisma equivalent of a VibORM error code, or `undefined` when VibORM claims none.\n */\nexport function toPrismaErrorCode(\n code: VibORMErrorCode\n): PrismaErrorCode | undefined {\n return PRISMA_CODE_BY_VIBORM_CODE.get(code);\n}\n\n/**\n * Error metadata for additional context\n */\nexport interface VibORMErrorMeta {\n /** Model name if applicable */\n model?: string;\n /** Operation being performed */\n operation?: string;\n /** Relation name if applicable */\n relation?: string;\n /** Table name */\n table?: string;\n /** Column names */\n columns?: string[];\n /** Constraint name */\n constraint?: string;\n /** SQL query (redacted by default) */\n query?: string;\n /** Query parameters */\n params?: unknown[];\n /** Feature name */\n feature?: string;\n /** Method name */\n method?: string;\n /** Durable write state known when the error surfaced. */\n commitCertainty?: \"committed\" | \"may-have-committed\";\n /** Additional context */\n [key: string]: unknown;\n}\n\n/** The options every VibORM error constructor forwards to {@link VibORMError}. */\nexport interface VibORMErrorOptions {\n cause?: Error | undefined;\n diagnostics?: DiagnosticDisclosure | undefined;\n meta?: VibORMErrorMeta | undefined;\n}\n\n/**\n * Base error class for all VibORM errors\n */\nexport class VibORMError extends Error {\n /** Stable serialized name that survives package minification. */\n static readonly diagnosticName: string = \"VibORMError\";\n\n /** Error code for programmatic handling */\n readonly code: VibORMErrorCode;\n /** Original cause if wrapping another error */\n readonly originalCause?: Error | undefined;\n /** Additional metadata */\n readonly meta: VibORMErrorMeta;\n /** Timestamp when error occurred */\n readonly timestamp: Date;\n\n constructor(\n message: string,\n code: VibORMErrorCode,\n options?: VibORMErrorOptions & {\n /** Internal validation boundary evidence, snapshotted with the error. */\n validation?: { source: unknown; issues: unknown };\n }\n ) {\n super(message);\n const diagnosticName = readDiagnosticName(new.target);\n this.name = diagnosticName;\n this.code = code;\n this.originalCause = options?.cause\n ? sanitizeErrorCause(options.cause, options?.diagnostics)\n : undefined;\n if (this.originalCause)\n Object.defineProperty(this, \"cause\", {\n value: this.originalCause,\n configurable: true,\n writable: true,\n });\n this.meta = sanitizeErrorMetadata(\n options?.meta ?? {},\n options?.diagnostics\n );\n this.timestamp = new Date();\n registerTrustedError(this, {\n cause: this.originalCause,\n code,\n disclosure: options?.diagnostics,\n message,\n meta: this.meta,\n name: diagnosticName,\n prismaCode: toPrismaErrorCode(code),\n timestamp: this.timestamp,\n validation: options?.validation,\n });\n\n // Maintain proper stack trace\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this, this.constructor);\n }\n }\n\n /**\n * Prisma error code for this error, or `undefined` when VibORM claims no equivalent.\n *\n * Lets a `catch` written for Prisma keep working: `if (error.prismaCode === \"P2002\")`.\n * See {@link PRISMA_CODE_BY_VIBORM_CODE} for the table and for what is deliberately unmapped.\n */\n get prismaCode(): PrismaErrorCode | undefined {\n return toPrismaErrorCode(this.code);\n }\n\n /**\n * Check if error is retryable (deadlock, serialization failure)\n *\n * Reads {@link verdictFor}, the one classification — so the retryable set cannot drift\n * from it, and a new code has to declare its retryability to compile.\n */\n isRetryable(): boolean {\n return verdictFor(this.code).retryable;\n }\n\n /**\n * Convert to JSON for logging/serialization\n */\n toJSON(): Record<string, unknown> {\n return (\n serializeTrustedError(this) ?? {\n name: \"VibORMError\",\n message: \"VibORM operation failed\",\n code: VibORMErrorCode.INTERNAL_ERROR,\n meta: {},\n timestamp: \"Invalid Date\",\n }\n );\n }\n}\n\nfunction readDiagnosticName(errorConstructor: typeof VibORMError): string {\n let candidate: unknown = errorConstructor;\n for (\n let depth = 0;\n depth < 16 && typeof candidate === \"function\";\n depth += 1\n ) {\n const descriptor = safeOwnPropertyDescriptor(candidate, \"diagnosticName\");\n if (\n descriptor &&\n \"value\" in descriptor &&\n typeof descriptor.value === \"string\" &&\n descriptor.value.length > 0\n ) {\n return descriptor.value;\n }\n try {\n candidate = Object.getPrototypeOf(candidate);\n } catch {\n return \"VibORMError\";\n }\n }\n return \"VibORMError\";\n}\n\n/**\n * Type guard to check if error is a VibORMError\n */\nexport function isVibORMError(error: unknown): error is VibORMError {\n return error instanceof VibORMError;\n}\n\n/**\n * An EXPECTED failure: the database refused, the caller's payload was refused, or a documented\n * capability boundary was reached. Something a caller can be handed and asked to handle.\n */\nexport interface QueryFailure {\n readonly kind: \"failure\";\n /** Always a VibORM error — an expected failure is, by definition, one with a taxonomy code. */\n readonly error: VibORMError;\n /** Whether re-running the same operation unchanged could succeed. */\n readonly retryable: boolean;\n}\n\n/**\n * A DEFECT: the engine broke its own invariant, or something that is not a VibORM error at all\n * was thrown. Nothing a caller can act on; it means a bug, not a refusal.\n */\nexport interface EngineDefect {\n readonly kind: \"defect\";\n readonly error: unknown;\n}\n\n/** The per-code verdict. Three module-level constants, so classification allocates nothing. */\ninterface CodeVerdict {\n readonly expected: boolean;\n readonly retryable: boolean;\n}\nconst EXPECTED: CodeVerdict = { expected: true, retryable: false };\nconst EXPECTED_RETRYABLE: CodeVerdict = { expected: true, retryable: true };\nconst DEFECT: CodeVerdict = { expected: false, retryable: false };\n\n/**\n * The taxonomy's disposition, code by code — the ONE place expected-vs-defect and\n * retryable-vs-not are decided. It is a type, so it costs no runtime bytes, and it is\n * complete by construction: {@link verdictFor} takes `keyof CodeDisposition`, so adding a\n * member to {@link VibORMErrorCode} without giving it a disposition here does not build.\n *\n * The rule the entries follow: a code is EXPECTED when something outside the engine said\n * no — the database, the caller's payload, the driver's capabilities, a documented shape\n * boundary. It is a DEFECT only when the engine itself is what went wrong. Retryable is the\n * strictly smaller question: could re-running the identical operation succeed?\n */\ninterface CodeDisposition {\n // Connection (1xxx). The server said no, or the client could not be built from the given\n // configuration — all outside the engine. Refused connections and timeouts can\n // recover with backoff; closed clients and invalid configuration cannot.\n [VibORMErrorCode.CONNECTION_TIMEOUT]: \"retryable\";\n [VibORMErrorCode.CONNECTION_FAILED]: \"retryable\";\n [VibORMErrorCode.CONNECTION_CAPACITY]: \"retryable\";\n [VibORMErrorCode.CONNECTION_CLOSED]: \"expected\";\n [VibORMErrorCode.CLIENT_INITIALIZATION]: \"expected\";\n\n // Query (2xxx). The statement reached the database and came back rejected. A timeout can\n // clear; a rejected statement re-sent unchanged is rejected again.\n [VibORMErrorCode.QUERY_TIMEOUT]: \"retryable\";\n [VibORMErrorCode.QUERY_FAILED]: \"expected\";\n [VibORMErrorCode.QUERY_SYNTAX]: \"expected\";\n [VibORMErrorCode.QUERY_SCHEMA_MISMATCH]: \"expected\";\n [VibORMErrorCode.QUERY_OUT_OF_RANGE]: \"expected\";\n [VibORMErrorCode.QUERY_RESULT_INVALID]: \"expected\";\n\n // Constraints (3xxx). The schema's own rules, enforced by the database. Never retryable:\n // the data has to change first.\n [VibORMErrorCode.UNIQUE_CONSTRAINT]: \"expected\";\n [VibORMErrorCode.FOREIGN_KEY_CONSTRAINT]: \"expected\";\n [VibORMErrorCode.NOT_NULL_CONSTRAINT]: \"expected\";\n [VibORMErrorCode.CHECK_CONSTRAINT]: \"expected\";\n [VibORMErrorCode.VALUE_TOO_LONG]: \"expected\";\n\n // Validation (4xxx). The caller's payload was refused before any I/O.\n [VibORMErrorCode.VALIDATION_FAILED]: \"expected\";\n [VibORMErrorCode.INVALID_INPUT]: \"expected\";\n [VibORMErrorCode.MISSING_REQUIRED]: \"expected\";\n\n // Transaction (5xxx). Lock contention, deadlock and serialization failure may clear\n // on a later attempt. Retryability does not prove a write was uncommitted or idempotent.\n // A local transaction timeout, plain failure or invalid option is not transient.\n [VibORMErrorCode.DEADLOCK]: \"retryable\";\n [VibORMErrorCode.SERIALIZATION_FAILURE]: \"retryable\";\n [VibORMErrorCode.TRANSACTION_CONTENTION]: \"retryable\";\n [VibORMErrorCode.TRANSACTION_FAILED]: \"expected\";\n [VibORMErrorCode.TRANSACTION_TIMEOUT]: \"expected\";\n [VibORMErrorCode.INVALID_TRANSACTION_INPUT]: \"expected\";\n\n // Not found (6xxx). `…OrThrow` did its job, or the caller named something the schema does\n // not define. Both are answers, not malfunctions.\n [VibORMErrorCode.RECORD_NOT_FOUND]: \"expected\";\n [VibORMErrorCode.MODEL_NOT_FOUND]: \"expected\";\n [VibORMErrorCode.RELATION_NOT_FOUND]: \"expected\";\n\n // Nested writes (7xxx). A precondition the caller's tree asserted did not hold — a connect\n // target that vanished, an ownership check that failed. The retry layer above the executor\n // re-runs the SPECIFIC raceable ones by their own marking (`meta.raceable` / a matched\n // `racePin`), never by this flag, which is why none of them is retryable here.\n [VibORMErrorCode.NESTED_WRITE_FAILED]: \"expected\";\n [VibORMErrorCode.NESTED_CREATE_FAILED]: \"expected\";\n [VibORMErrorCode.NESTED_UPDATE_FAILED]: \"expected\";\n [VibORMErrorCode.NESTED_DELETE_FAILED]: \"expected\";\n [VibORMErrorCode.NESTED_CONNECT_FAILED]: \"expected\";\n [VibORMErrorCode.NESTED_WRITE_ASSERTION_FAILED]: \"expected\";\n\n // Capability (8xxx). THE arm this whole classification exists for. V8003 is carried by\n // `UnsupportedOperationError`, which EXTENDS `QueryEngineError` — so an `instanceof\n // QueryEngineError` check calls a documented shape refusal an engine crash, which is the\n // mistake that surfaced 77 capability refusals as INTERNAL_ERROR for weeks. The code, not\n // the class, decides: V8003 is a refusal, V9001 below is the crash.\n [VibORMErrorCode.FEATURE_NOT_SUPPORTED]: \"expected\";\n [VibORMErrorCode.DRIVER_NOT_SUPPORTED]: \"expected\";\n [VibORMErrorCode.UNSUPPORTED_OPERATION]: \"expected\";\n\n // Cache (10xxx). Configuration and cacheability refusals, raised before anything runs.\n [VibORMErrorCode.CACHE_INVALID_TTL]: \"expected\";\n [VibORMErrorCode.CACHE_INVALID_KEY]: \"expected\";\n [VibORMErrorCode.CACHE_OPERATION_NOT_CACHEABLE]: \"expected\";\n [VibORMErrorCode.CACHE_CONFIGURATION]: \"expected\";\n\n // Migrations (11xxx). Every one of these is a statement about the migration history or the\n // target database, addressed to the operator. A lock failure looks retryable, but the\n // migration runner owns that decision (it needs its own backoff and its own bound), not a\n // generic per-operation retry.\n [VibORMErrorCode.MIGRATION_FAILED]: \"expected\";\n [VibORMErrorCode.MIGRATION_NOT_FOUND]: \"expected\";\n [VibORMErrorCode.MIGRATION_CHECKSUM_MISMATCH]: \"expected\";\n [VibORMErrorCode.MIGRATION_DIALECT_MISMATCH]: \"expected\";\n [VibORMErrorCode.MIGRATION_LOCK_FAILED]: \"expected\";\n [VibORMErrorCode.MIGRATION_ALREADY_APPLIED]: \"expected\";\n [VibORMErrorCode.MIGRATION_OUT_OF_ORDER]: \"expected\";\n [VibORMErrorCode.MIGRATION_FILE_NOT_FOUND]: \"expected\";\n [VibORMErrorCode.MIGRATION_INVALID_STATE]: \"expected\";\n [VibORMErrorCode.MIGRATION_DESTRUCTIVE_REJECTED]: \"expected\";\n [VibORMErrorCode.MIGRATION_STORAGE_REQUIRED]: \"expected\";\n [VibORMErrorCode.MIGRATION_INVALID_ESTATE]: \"expected\";\n [VibORMErrorCode.MIGRATION_PATH_REQUIRED]: \"expected\";\n [VibORMErrorCode.MIGRATION_DRIFT]: \"expected\";\n [VibORMErrorCode.MIGRATION_MARKER_CONFLICT]: \"expected\";\n [VibORMErrorCode.MIGRATION_UNFINISHED_ATTEMPT]: \"expected\";\n [VibORMErrorCode.MIGRATION_CONSENT_REQUIRED]: \"expected\";\n [VibORMErrorCode.MIGRATION_CONSENT_MISMATCH]: \"expected\";\n [VibORMErrorCode.MIGRATION_PARTIAL_EFFECT]: \"expected\";\n [VibORMErrorCode.MIGRATION_AMBIGUOUS_COMMIT]: \"expected\";\n [VibORMErrorCode.MIGRATION_UNSUPPORTED_PROVIDER]: \"expected\";\n [VibORMErrorCode.MIGRATION_CORRUPTION]: \"expected\";\n [VibORMErrorCode.MIGRATION_INVALID_INDEX]: \"expected\";\n\n // Pending operations (12xxx). Caller misuse of the operation lifecycle — awaiting twice,\n // mixing transaction scopes. A refusal aimed at the person writing the call.\n [VibORMErrorCode.OPERATION_ALREADY_EXECUTED]: \"expected\";\n [VibORMErrorCode.OPERATION_EXECUTION_CONFLICT]: \"expected\";\n [VibORMErrorCode.OPERATION_CLIENT_MISMATCH]: \"expected\";\n [VibORMErrorCode.OPERATION_SCOPE_MISMATCH]: \"expected\";\n\n // Authorization (13xxx). A policy judged the operation and said no: the caller's answer,\n // and re-running it unchanged is refused again until the rows it reads change.\n [VibORMErrorCode.FORBIDDEN]: \"expected\";\n\n // Internal (9xxx). The only two defects in the taxonomy: the engine broke its own\n // invariant, or the schema it was handed is not coherent. Neither is a refusal, and\n // retrying either just repeats the bug.\n [VibORMErrorCode.INTERNAL_ERROR]: \"defect\";\n [VibORMErrorCode.SCHEMA_ERROR]: \"defect\";\n}\n\ntype CodesWith<D extends CodeDisposition[keyof CodeDisposition]> = {\n [C in keyof CodeDisposition]: CodeDisposition[C] extends D ? C : never;\n}[keyof CodeDisposition];\n\n/**\n * The runtime projections of {@link CodeDisposition}: exactly its defect codes and exactly\n * its retryable codes (`satisfies` refuses a missing or an extra one); every other code is\n * expected and not retryable.\n */\nconst DEFECT_CODES: Partial<Record<VibORMErrorCode, true>> = {\n [VibORMErrorCode.INTERNAL_ERROR]: true,\n [VibORMErrorCode.SCHEMA_ERROR]: true,\n} satisfies Record<CodesWith<\"defect\">, true>;\nconst RETRYABLE_CODES: Partial<Record<VibORMErrorCode, true>> = {\n [VibORMErrorCode.CONNECTION_FAILED]: true,\n [VibORMErrorCode.CONNECTION_CAPACITY]: true,\n [VibORMErrorCode.CONNECTION_TIMEOUT]: true,\n [VibORMErrorCode.QUERY_TIMEOUT]: true,\n [VibORMErrorCode.DEADLOCK]: true,\n [VibORMErrorCode.SERIALIZATION_FAILURE]: true,\n [VibORMErrorCode.TRANSACTION_CONTENTION]: true,\n} satisfies Record<CodesWith<\"retryable\">, true>;\n\nfunction verdictFor(code: keyof CodeDisposition): CodeVerdict {\n if (DEFECT_CODES[code] === true) return DEFECT;\n return RETRYABLE_CODES[code] === true ? EXPECTED_RETRYABLE : EXPECTED;\n}\n\n/**\n * Classify a surfaced throwable as an expected failure or an engine defect.\n *\n * The one seam the executor and the routed retry policy share. Two rules, both encoded in\n * {@link verdictFor} rather than in `instanceof` chains:\n *\n * - Anything that is not a VibORM error is a DEFECT. A raw throwable escaping the engine means\n * a path that failed to normalize, not a refusal a caller was meant to receive.\n * - Everything else is decided by its CODE, which is why `UnsupportedOperationError` (V8003)\n * classifies as a refusal even though it extends `QueryEngineError`, and a bare\n * `QueryEngineError` (V9001) classifies as a defect even though it is the same class family.\n */\nexport function classifyFailure(error: unknown): QueryFailure | EngineDefect {\n if (!isVibORMError(error)) {\n return { kind: \"defect\", error };\n }\n const verdict = verdictFor(error.code);\n if (!verdict.expected) {\n return { kind: \"defect\", error };\n }\n return { kind: \"failure\", error, retryable: verdict.retryable };\n}\n\n/**\n * Check if error is retryable\n */\nexport function isRetryableError(error: unknown): boolean {\n if (isVibORMError(error)) {\n return error.isRetryable();\n }\n\n // Also check for database-specific error codes\n if (error instanceof Error && \"code\" in error) {\n const retryableCodes = [\"40001\", \"40P01\", \"SQLITE_BUSY\"];\n const code = error.code;\n return typeof code === \"string\" && retryableCodes.includes(code);\n }\n\n return false;\n}\n\n/**\n * Wrap unknown error in VibORMError\n */\nexport function wrapError(\n error: unknown,\n code: VibORMErrorCode = VibORMErrorCode.INTERNAL_ERROR,\n meta?: VibORMErrorMeta,\n diagnostics?: DiagnosticDisclosure\n): VibORMError {\n if (isVibORMError(error)) {\n return error;\n }\n\n const cause = error instanceof Error ? error : new Error(String(error));\n return new VibORMError(\"VibORM operation failed\", code, {\n cause,\n meta,\n diagnostics,\n });\n}\n"],"mappings":"yCAKA,MAEa,EAA6B,cAC7B,EAA8B,eAC9B,EAAkB,CAC7B,OACA,QACA,WACA,WACA,SACA,aACD,CAEK,EAAoB,KAEpB,EAA0B,UAC1B,EAAoB,gBACpB,EAAuB,aACvB,EAAsB,WACtB,EAAoB,IAAI,IAAI,yJAgDjC,CAAC,CACI,EAAwB,IAAI,IAAI,qiCAwErC,CAAC,CAEF,SAAgB,cACd,EACA,EACS,CACT,IAAM,EAAS,KAAK,IAClB,EAAM,WACN,IACA,KAAK,IAAI,EAAG,IAAyB,EAAO,QAAQ,CACrD,CACK,EAAkB,EAAE,CAC1B,IAAK,IAAI,EAAQ,EAAG,EAAQ,EAAQ,GAAS,EAC3C,EAAM,KAAK,EAAM,GAAQ,CAE3B,IAAM,EAAS,kBAAkB,CAMjC,OALA,WAAW,EAAQ,OAAQ,SAAS,CACpC,WAAW,EAAQ,aAAc,EAAM,WAAW,CAClD,WAAW,EAAQ,QAAS,EAAM,CAC9B,EAAM,WAAa,GAAQ,WAAW,EAAQ,YAAa,GAAK,CACpE,EAAO,SAAW,EACX,EAGT,SAAgB,eACd,EACA,EACQ,CACR,IAAM,EAAY,KAAK,IAAI,EAAG,MAAuB,EAAO,WAAW,CACjE,EAAS,KAAK,IAAI,EAAM,OAAQ,EAAmB,EAAU,CAEnE,MADA,GAAO,YAAc,EACd,IAAW,EAAM,OACpB,EACA,GAAG,EAAM,MAAM,EAAG,EAAO,GAAG,IAGlC,SAAgB,gBACd,EACA,EACA,EACQ,CACR,IAAM,EAAQ,SAAS,EAAO,EAAI,CAClC,OAAO,eAAe,OAAO,GAAU,SAAW,EAAQ,QAAS,EAAO,CAG5E,SAAgB,eAAe,EAAiC,CAC9D,IAAM,EAAgB,SAAS,EAAO,gBAAgB,C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gB,qBAAsB,IACtC,EAAgB,oBAAqB,IACrC,EAAgB,eAAgB,IAChC,EAAgB,UAAW,IAC3B,EAAgB,uBAAwB,IACxC,EAAgB,wBAAyB,GAC3C,CAED,SAAS,WAAW,EAA0C,CAE5D,OADI,EAAa,KAAU,GAAa,EACjC,EAAgB,KAAU,GAAO,EAAqB,EA6B/D,SAAgB,iBAAiB,EAAyB,CACxD,GAAI,cAAc,EAAM,CACtB,OAAO,EAAM,aAAa,CAI5B,GAAI,aAAiB,OAAS,SAAU,EAAO,CAC7C,IAAM,EAAiB,CAAC,QAAS,QAAS,cAAc,CAClD,EAAO,EAAM,KACnB,OAAO,OAAO,GAAS,UAAY,EAAe,SAAS,EAAK,CAGlE,MAAO,GAMT,SAAgB,UACd,EACA,EAAwB,EAAgB,eACxC,EACA,EACa,CAMb,OALI,cAAc,EAAM,CACf,EAIF,IAAI,YAAY,0BAA2B,EAAM,CACtD,MAFY,aAAiB,MAAQ,EAAY,MAAM,OAAO,EAAM,CAAC,CAGrE,OACA,cACD,CAAC"}
@@ -1,2 +1,2 @@
1
- import{n as e}from"./chunk-BuuaeEvq.mjs";import{o as t}from"./sql-BvHwL73I.mjs";const n=`__viborm_batch_refs`;function createOnConflictBatchRefs(e){return createBatchRefs({...e,store:(n,r,i)=>{let a=e.castValue(i);return t`INSERT INTO ${e.table} (${e.batchIdColumn}, ${e.keyColumn}, ${e.valueColumn}) VALUES (${n}, ${r}, ${a}) ${t.raw`ON CONFLICT`} (${e.batchIdColumn}, ${e.keyColumn}) DO UPDATE SET ${e.valueColumn} = EXCLUDED.${e.valueColumn}`}})}function createMySqlBatchRefs(e){return createBatchRefs({...e,store:(n,r,i)=>{let a=e.castValue(i);return t`INSERT INTO ${e.table} (${e.batchIdColumn}, ${e.keyColumn}, ${e.valueColumn}) VALUES (${n}, ${r}, ${a}) ${t.raw`ON DUPLICATE KEY UPDATE`} ${e.valueColumn} = ${e.duplicateValue}`}})}function createBatchRefs(e){let n=e.lastInsertId,r=e.storeReturning,i=r?(e,t,n,i)=>[r(e,t,n,i)]:n?(t,r,i)=>[i,e.store(t,r,n())]:void 0;return{setup:t=>[e.createTable],cleanup:n=>t`DELETE FROM ${e.table} WHERE ${e.batchIdColumn} = ${n}`,store:e.store,read:(n,r)=>t`(SELECT ${e.valueColumn} FROM ${e.table} WHERE ${e.batchIdColumn} = ${n} AND ${e.keyColumn} = ${r} ${t.raw`LIMIT 1`})`,...n?{storeLastInsertId:(t,r)=>e.store(t,r,n())}:{},...r?{storeReturning:r}:{},...i?{storeInsertedKey:i}:{}}}export{createMySqlBatchRefs as n,createOnConflictBatchRefs as r,n as t};
2
- //# sourceMappingURL=batch-refs-BYCu1JnQ.mjs.map
1
+ import{n as e}from"./chunk-BuuaeEvq.mjs";import{o as t}from"./sql-DGtEeP8z.mjs";const n=`__viborm_batch_refs`;function createOnConflictBatchRefs(e){return createBatchRefs({...e,store:(n,r,i)=>{let a=e.castValue(i);return t`INSERT INTO ${e.table} (${e.batchIdColumn}, ${e.keyColumn}, ${e.valueColumn}) VALUES (${n}, ${r}, ${a}) ${t.raw`ON CONFLICT`} (${e.batchIdColumn}, ${e.keyColumn}) DO UPDATE SET ${e.valueColumn} = EXCLUDED.${e.valueColumn}`}})}function createMySqlBatchRefs(e){return createBatchRefs({...e,store:(n,r,i)=>{let a=e.castValue(i);return t`INSERT INTO ${e.table} (${e.batchIdColumn}, ${e.keyColumn}, ${e.valueColumn}) VALUES (${n}, ${r}, ${a}) ${t.raw`ON DUPLICATE KEY UPDATE`} ${e.valueColumn} = ${e.duplicateValue}`}})}function createBatchRefs(e){let n=e.lastInsertId,r=e.storeReturning,i=r?(e,t,n,i)=>[r(e,t,n,i)]:n?(t,r,i)=>[i,e.store(t,r,n())]:void 0;return{setup:t=>[e.createTable],cleanup:n=>t`DELETE FROM ${e.table} WHERE ${e.batchIdColumn} = ${n}`,store:e.store,read:(n,r)=>t`(SELECT ${e.valueColumn} FROM ${e.table} WHERE ${e.batchIdColumn} = ${n} AND ${e.keyColumn} = ${r} ${t.raw`LIMIT 1`})`,...n?{storeLastInsertId:(t,r)=>e.store(t,r,n())}:{},...r?{storeReturning:r}:{},...i?{storeInsertedKey:i}:{}}}export{createMySqlBatchRefs as n,createOnConflictBatchRefs as r,n as t};
2
+ //# sourceMappingURL=batch-refs-cBYAKzaE.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"batch-refs-BYCu1JnQ.mjs","names":[],"sources":["../src/adapters/shared/batch-refs.ts"],"sourcesContent":["import { type Sql, sql } from \"@sql\";\nimport type { BatchReferenceSqlAdapter } from \"../adapter-core-types\";\n\n/**\n * The batch reference scratch table's name. The SQLite adapter spells it from\n * here, and SQLite migration introspection reads it to keep the scratch out of\n * a snapshot: on a transport without temporary objects (D1) the scratch is an\n * ordinary table in `main`.\n */\nexport const BATCH_REFS_TABLE = \"__viborm_batch_refs\";\n\ninterface OnConflictBatchRefsConfig {\n table: Sql;\n batchIdColumn: Sql;\n keyColumn: Sql;\n valueColumn: Sql;\n createTable: Sql;\n castValue: (valueSql: Sql) => Sql;\n lastInsertId?: () => Sql;\n /** The dialect's data-modifying CTE around an INSERT, storing its RETURNING. */\n storeReturning?: BatchReferenceSqlAdapter[\"storeReturning\"];\n}\n\ninterface MySqlBatchRefsConfig extends OnConflictBatchRefsConfig {\n duplicateValue: Sql;\n}\n\nexport function createOnConflictBatchRefs(\n config: OnConflictBatchRefsConfig\n): BatchReferenceSqlAdapter {\n return createBatchRefs({\n ...config,\n store: (batchId, key, valueSql) => {\n const value = config.castValue(valueSql);\n return sql`INSERT INTO ${config.table} (${config.batchIdColumn}, ${config.keyColumn}, ${config.valueColumn}) VALUES (${batchId}, ${key}, ${value}) ${sql.raw`ON CONFLICT`} (${config.batchIdColumn}, ${config.keyColumn}) DO UPDATE SET ${config.valueColumn} = EXCLUDED.${config.valueColumn}`;\n },\n });\n}\n\nexport function createMySqlBatchRefs(\n config: MySqlBatchRefsConfig\n): BatchReferenceSqlAdapter {\n return createBatchRefs({\n ...config,\n store: (batchId, key, valueSql) => {\n const value = config.castValue(valueSql);\n return sql`INSERT INTO ${config.table} (${config.batchIdColumn}, ${config.keyColumn}, ${config.valueColumn}) VALUES (${batchId}, ${key}, ${value}) ${sql.raw`ON DUPLICATE KEY UPDATE`} ${config.valueColumn} = ${config.duplicateValue}`;\n },\n });\n}\n\nfunction createBatchRefs(\n config: OnConflictBatchRefsConfig & {\n store: (batchId: string, key: string, valueSql: Sql) => Sql;\n }\n): BatchReferenceSqlAdapter {\n const lastInsertId = config.lastInsertId;\n const storeReturning = config.storeReturning;\n // One owner of \"how a generated increment key is stored\": the CTE store is\n // the INSERT itself; the last insert id is a second statement after it.\n const storeInsertedKey: BatchReferenceSqlAdapter[\"storeInsertedKey\"] =\n storeReturning\n ? (batchId, key, insert, column) => [\n storeReturning(batchId, key, insert, column),\n ]\n : lastInsertId\n ? (batchId, key, insert) => [\n insert,\n config.store(batchId, key, lastInsertId()),\n ]\n : undefined;\n\n return {\n setup: (_batchId) => [config.createTable],\n cleanup: (batchId) =>\n sql`DELETE FROM ${config.table} WHERE ${config.batchIdColumn} = ${batchId}`,\n store: config.store,\n read: (batchId, key) =>\n sql`(SELECT ${config.valueColumn} FROM ${config.table} WHERE ${config.batchIdColumn} = ${batchId} AND ${config.keyColumn} = ${key} ${sql.raw`LIMIT 1`})`,\n ...(lastInsertId\n ? {\n storeLastInsertId: (batchId: string, key: string) =>\n config.store(batchId, key, lastInsertId()),\n }\n : {}),\n ...(storeReturning ? { storeReturning } : {}),\n ...(storeInsertedKey ? { storeInsertedKey } : {}),\n };\n}\n"],"mappings":"gFASA,MAAa,EAAmB,sBAkBhC,SAAgB,0BACd,EAC0B,CAC1B,OAAO,gBAAgB,CACrB,GAAG,EACH,OAAQ,EAAS,EAAK,IAAa,CACjC,IAAM,EAAQ,EAAO,UAAU,EAAS,CACxC,MAAO,EAAG,eAAe,EAAO,MAAM,IAAI,EAAO,cAAc,IAAI,EAAO,UAAU,IAAI,EAAO,YA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KzaE.mjs","names":[],"sources":["../src/adapters/shared/batch-refs.ts"],"sourcesContent":["import { type Sql, sql } from \"@sql\";\nimport type { BatchReferenceSqlAdapter } from \"../adapter-core-types\";\n\n/**\n * The batch reference scratch table's name. The SQLite adapter spells it from\n * here, and SQLite migration introspection reads it to keep the scratch out of\n * a snapshot: on a transport without temporary objects (D1) the scratch is an\n * ordinary table in `main`.\n */\nexport const BATCH_REFS_TABLE = \"__viborm_batch_refs\";\n\ninterface OnConflictBatchRefsConfig {\n table: Sql;\n batchIdColumn: Sql;\n keyColumn: Sql;\n valueColumn: Sql;\n createTable: Sql;\n castValue: (valueSql: Sql) => Sql;\n lastInsertId?: () => Sql;\n /** The dialect's data-modifying CTE around an INSERT, storing its RETURNING. */\n storeReturning?: BatchReferenceSqlAdapter[\"storeReturning\"];\n}\n\ninterface MySqlBatchRefsConfig extends OnConflictBatchRefsConfig {\n duplicateValue: Sql;\n}\n\nexport function createOnConflictBatchRefs(\n config: OnConflictBatchRefsConfig\n): BatchReferenceSqlAdapter {\n return createBatchRefs({\n ...config,\n store: (batchId, key, valueSql) => {\n const value = config.castValue(valueSql);\n return sql`INSERT INTO ${config.table} (${config.batchIdColumn}, ${config.keyColumn}, ${config.valueColumn}) VALUES (${batchId}, ${key}, ${value}) ${sql.raw`ON CONFLICT`} (${config.batchIdColumn}, ${config.keyColumn}) DO UPDATE SET ${config.valueColumn} = EXCLUDED.${config.valueColumn}`;\n },\n });\n}\n\nexport function createMySqlBatchRefs(\n config: MySqlBatchRefsConfig\n): BatchReferenceSqlAdapter {\n return createBatchRefs({\n ...config,\n store: (batchId, key, valueSql) => {\n const value = config.castValue(valueSql);\n return sql`INSERT INTO ${config.table} (${config.batchIdColumn}, ${config.keyColumn}, ${config.valueColumn}) VALUES (${batchId}, ${key}, ${value}) ${sql.raw`ON DUPLICATE KEY UPDATE`} ${config.valueColumn} = ${config.duplicateValue}`;\n },\n });\n}\n\nfunction createBatchRefs(\n config: OnConflictBatchRefsConfig & {\n store: (batchId: string, key: string, valueSql: Sql) => Sql;\n }\n): BatchReferenceSqlAdapter {\n const lastInsertId = config.lastInsertId;\n const storeReturning = config.storeReturning;\n // One owner of \"how a generated increment key is stored\": the CTE store is\n // the INSERT itself; the last insert id is a second statement after it.\n const storeInsertedKey: BatchReferenceSqlAdapter[\"storeInsertedKey\"] =\n storeReturning\n ? (batchId, key, insert, column) => [\n storeReturning(batchId, key, insert, column),\n ]\n : lastInsertId\n ? (batchId, key, insert) => [\n insert,\n config.store(batchId, key, lastInsertId()),\n ]\n : undefined;\n\n return {\n setup: (_batchId) => [config.createTable],\n cleanup: (batchId) =>\n sql`DELETE FROM ${config.table} WHERE ${config.batchIdColumn} = ${batchId}`,\n store: config.store,\n read: (batchId, key) =>\n sql`(SELECT ${config.valueColumn} FROM ${config.table} WHERE ${config.batchIdColumn} = ${batchId} AND ${config.keyColumn} = ${key} ${sql.raw`LIMIT 1`})`,\n ...(lastInsertId\n ? {\n storeLastInsertId: (batchId: string, key: string) =>\n config.store(batchId, key, lastInsertId()),\n }\n : {}),\n ...(storeReturning ? { storeReturning } : {}),\n ...(storeInsertedKey ? { storeInsertedKey } : {}),\n };\n}\n"],"mappings":"gFASA,MAAa,EAAmB,sBAkBhC,SAAgB,0BACd,EAC0B,CAC1B,OAAO,gBAAgB,CACrB,GAAG,EACH,OAAQ,EAAS,EAAK,IAAa,CACjC,IAAM,EAAQ,EAAO,UAAU,EAAS,CACxC,MAAO,EAAG,eAAe,EAAO,MAAM,IAAI,EAAO,cAAc,IAAI,EAAO,UAAU,IAAI,EAAO,YAAY,YAAY,EAAQ,IAAI,EAAI,IAAI,EAAM,IAAI,EAAI,GAAG,cAAc,IAAI,EAAO,cAAc,IAAI,EAAO,UAAU,kBAAkB,EAAO,YAAY,cAAc,EAAO,eAErR,CAAC,CAGJ,SAAgB,qBACd,EAC0B,CAC1B,OAAO,gBAAgB,CACrB,GAAG,EACH,OAAQ,EAAS,EAAK,IAAa,CACjC,IAAM,EAAQ,EAAO,UAAU,EAAS,CACxC,MAAO,EAAG,eAAe,EAAO,MAAM,IAAI,EAAO,cAAc,IAAI,EAAO,UAAU,IAAI,EAAO,YAAY,YAAY,EAAQ,IAAI,EAAI,IAAI,EAAM,IAAI,EAAI,GAAG,0BAA0B,GAAG,EAAO,YAAY,KAAK,EAAO,kBAE3N,CAAC,CAGJ,SAAS,gBACP,EAG0B,CAC1B,IAAM,EAAe,EAAO,aACtB,EAAiB,EAAO,eAGxB,EACJ,GACK,EAAS,EAAK,EAAQ,IAAW,CAChC,EAAe,EAAS,EAAK,EAAQ,EAAO,CAC7C,CACD,GACG,EAAS,EAAK,IAAW,CACxB,EACA,EAAO,MAAM,EAAS,EAAK,GAAc,CAAC,CAC3C,CACD,IAAA,GAER,MAAO,CACL,MAAQ,GAAa,CAAC,EAAO,YAAY,CACzC,QAAU,GACR,CAAG,eAAe,EAAO,MAAM,SAAS,EAAO,cAAc,KAAK,IACpE,MAAO,EAAO,MACd,MAAO,EAAS,IACd,CAAG,WAAW,EAAO,YAAY,QAAQ,EAAO,MAAM,SAAS,EAAO,cAAc,KAAK,EAAQ,OAAO,EAAO,UAAU,KAAK,EAAI,GAAG,EAAI,GAAG,UAAU,GACxJ,GAAI,EACA,CACE,mBAAoB,EAAiB,IACnC,EAAO,MAAM,EAAS,EAAK,GAAc,CAAC,CAC7C,CACD,EAAE,CACN,GAAI,EAAiB,CAAE,iBAAgB,CAAG,EAAE,CAC5C,GAAI,EAAmB,CAAE,mBAAkB,CAAG,EAAE,CACjD"}
@@ -0,0 +1,2 @@
1
+ import{n as e}from"./chunk-BuuaeEvq.mjs";import{f as t}from"./query-CTna5P9o.mjs";function normalizedBindParameterLimit(e){return typeof e==`number`&&Number.isInteger(e)&&e>0?e:void 0}function assertStatementBindParameterCapacity(e,n,r,i){if(!(r===void 0||e.values.length<=r))throw new t(`Driver '${n}' cannot execute this ${i} because one indivisible statement needs ${e.values.length} bound values, above the verified limit of ${r}.`)}export{normalizedBindParameterLimit as n,assertStatementBindParameterCapacity as t};
2
+ //# sourceMappingURL=bind-parameter-capacity-4OU6feZG.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"bind-parameter-capacity-D6p9HrbB.mjs","names":[],"sources":["../src/drivers/bind-parameter-capacity.ts"],"sourcesContent":["import { UnsupportedOperationError } from \"@errors\";\nimport type { Sql } from \"@sql\";\n\n/** Normalize one driver's optional bind declaration into verified capacity. */\nexport function normalizedBindParameterLimit(\n limit: unknown\n): number | undefined {\n return typeof limit === \"number\" && Number.isInteger(limit) && limit > 0\n ? limit\n : undefined;\n}\n\n/** Refuse one materialized statement before it reaches provider I/O. */\nexport function assertStatementBindParameterCapacity(\n statement: Sql,\n driverName: string,\n limit: number | undefined,\n subject: string\n): void {\n if (limit === undefined || statement.values.length <= limit) return;\n throw new UnsupportedOperationError(\n `Driver '${driverName}' cannot execute this ${subject} because one indivisible statement needs ${statement.values.length} bound values, above the verified limit of ${limit}.`\n );\n}\n"],"mappings":"uFAIA,SAAgB,6BACd,EACoB,CACpB,OAAO,OAAO,GAAU,UAAY,OAAO,UAAU,EAAM,EAAI,EAAQ,EACnE,EACA,IAAA,GAIN,SAAgB,qCACd,EACA,EACA,EACA,EACM,CACF,SAAU,IAAA,IAAa,EAAU,OAAO,QAAU,GACtD,MAAM,IAAI,EACR,WAAW,EAAW,wBAAwB,EAAQ,2CAA2C,EAAU,OAAO,OAAO,6CAA6C,EAAM,GAC7K"}
1
+ {"version":3,"file":"bind-parameter-capacity-4OU6feZG.mjs","names":[],"sources":["../src/drivers/bind-parameter-capacity.ts"],"sourcesContent":["import { UnsupportedOperationError } from \"@errors\";\nimport type { Sql } from \"@sql\";\n\n/** Normalize one driver's optional bind declaration into verified capacity. */\nexport function normalizedBindParameterLimit(\n limit: unknown\n): number | undefined {\n return typeof limit === \"number\" && Number.isInteger(limit) && limit > 0\n ? limit\n : undefined;\n}\n\n/** Refuse one materialized statement before it reaches provider I/O. */\nexport function assertStatementBindParameterCapacity(\n statement: Sql,\n driverName: string,\n limit: number | undefined,\n subject: string\n): void {\n if (limit === undefined || statement.values.length <= limit) return;\n throw new UnsupportedOperationError(\n `Driver '${driverName}' cannot execute this ${subject} because one indivisible statement needs ${statement.values.length} bound values, above the verified limit of ${limit}.`\n );\n}\n"],"mappings":"kFAIA,SAAgB,6BACd,EACoB,CACpB,OAAO,OAAO,GAAU,UAAY,OAAO,UAAU,EAAM,EAAI,EAAQ,EACnE,EACA,IAAA,GAIN,SAAgB,qCACd,EACA,EACA,EACA,EACM,CACF,SAAU,IAAA,IAAa,EAAU,OAAO,QAAU,GACtD,MAAM,IAAI,EACR,WAAW,EAAW,wBAAwB,EAAQ,2CAA2C,EAAU,OAAO,OAAO,6CAA6C,EAAM,GAC7K"}