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
@@ -1,4 +1,4 @@
1
- import { A as Schema, At as DriverConfig, F as LinkedClientConfig, Ft as VibORMClient, Nn as QueryExecutionContext, Pn as QueryResult, Pt as NoExtraDriverConfigKeys, d as MigrationSessionAttestation, h as DriverResultParser, kn as TransactionOptionSupport, m as PinnedSessionReservation, s as DatabaseAdapter, u as Driver } from "./index-Ci8b13Lm.mjs";
1
+ import { A as Schema, An as TransactionOptionSupport, At as DriverConfig, F as LinkedClientConfig, Fn as QueryResult, Ft as VibORMClient, Pn as QueryExecutionContext, Pt as NoExtraDriverConfigKeys, d as MigrationSessionAttestation, h as DriverResultParser, m as PinnedSessionReservation, s as DatabaseAdapter, u as Driver } from "./index-DRX_LLQM.mjs";
2
2
 
3
3
  //#region src/drivers/bun-sql/index.d.ts
4
4
 
package/dist/bun-sql.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import{n as e}from"./chunk-BuuaeEvq.mjs";import{o as t}from"./normalized-result-BF7gr4_b.mjs";import{d as n,l as r}from"./error-mapping-6op318w6.mjs";import{c as i}from"./execution-context-asSCmyas.mjs";import{n as a}from"./client-DACEO6tS.mjs";import{i as o,t as s}from"./pinned-session-FYOFV_gB.mjs";import{c,d as l,o as u,t as d,u as f}from"./driver-DseQwbsu.mjs";import{t as p}from"./postgres-adapter-B7hzWhky.mjs";import{n as m}from"./relation-bound-BrZLsSke.mjs";function normalizeBunSQLParams(e,t){let n;for(let r=0;r<t.length;r+=1){let i=t[r];Array.isArray(i)&&(n??=[...t],n[r]=e.array(i,`TEXT`).serializedValues)}return n??t}const h={parseField:(e,t,n)=>t===`int`&&e instanceof Int32Array?n(Array.from(e),t):n(e,t)},g={client:!0,databaseUrl:!0,options:!0,pgvector:!0,postgis:!0,sharedRelationBodies:!0,relationsPerStatement:!0,namespace:!0,migrationSessionAttestation:!0};var BunSQLDriver=class extends d{result=h;maxBindParametersPerStatement=65535;driverOptions;suppliedClient;constructor(e={}){super(`postgresql`,`bun-sql`);let t=l(e);this.driverOptions=e,this.suppliedClient=e.client,this.suppliedClient&&(this.client=this.suppliedClient),p(this,t,e),u(this,`migrationSessionAttestation`,f(e))}migrationSessionEndpoints(){let{databaseUrl:e,options:t}=this.driverOptions,n=this.suppliedClient?.options;return[e,t?.hostname,n?.hostname,n?.url]}async initClient(){if(this.suppliedClient!==void 0)return this.suppliedClient;let{SQL:e}=await import(`bun`);return this.driverOptions.databaseUrl?new e({...this.driverOptions.options,url:this.driverOptions.databaseUrl}):new e(this.driverOptions.options??{})}async closeClient(e){e!==this.suppliedClient&&await e.close()}async execute(e,n,r,i){let a=i?.operation??`execute`,o=await e.unsafe(n,normalizeBunSQLParams(e,r)).catch(e=>{throw m(this.adapter,e),e});return{rows:o,rowCount:t(o.count,{provider:`bun-sql`,operation:a})}}async executeRaw(e,n,r,i){let a=i?.operation??`executeRaw`,o=await e.unsafe(n,r);return{rows:o,rowCount:t(o.count,{provider:`bun-sql`,operation:a})}}transactionOptionSupport(){return{isolationLevel:`post-begin`,timeout:!0,maxWait:`unsupported`,maxWaitReason:`Bun SQL acquires the connection inside sql.begin(), which VibORM cannot observe or bound — the wait would be unbounded no matter what maxWait said`}}async transaction(e,t,a){if(`savepoint`in e)throw r(this.driverName);return n({run:t=>e.begin(t),callback:t,phases:i(a),close:async()=>void 0})}async pinnedSession(){let e=await this.getClient({operation:`pinnedSession`});if(`savepoint`in e)throw r(this.driverName);let t=await e.reserve();return{session:t,release:(n,r)=>o({driverName:this.driverName,discard:n,lost:r,reset:()=>t.unsafe(`SELECT pg_advisory_unlock_all()`),release:()=>t.release(),closeOwnedTransport:e===this.suppliedClient?void 0:async()=>{this.client=null,this.initPromise=null,await e.close({timeout:s/1e3})}})}}};function createClient(e){c(e,`bun-sql`,g);let{client:t,databaseUrl:n,options:r,pgvector:i,postgis:o}=e,s=l(e),u=f(e);return a(e,new BunSQLDriver({client:t,databaseUrl:n,options:r,pgvector:i,postgis:o,sharedRelationBodies:e.sharedRelationBodies,relationsPerStatement:e.relationsPerStatement,namespace:s,migrationSessionAttestation:u}))}export{BunSQLDriver,createClient};
1
+ import{n as e}from"./chunk-BuuaeEvq.mjs";import{o as t}from"./normalized-result-23DWxZVY.mjs";import{l as n}from"./execution-context-_oajgBi4.mjs";import{f as r,u as i}from"./error-mapping-DRY49A3C.mjs";import{n as a}from"./client-BqgVSbk0.mjs";import{i as o,t as s}from"./pinned-session-BdON2d0V.mjs";import{c,d as l,o as u,t as d,u as f}from"./driver-szWYBmjD.mjs";import{t as p}from"./postgres-adapter-DxhZu7Qw.mjs";import{n as m}from"./relation-bound-Bj7X-EUE.mjs";function normalizeBunSQLParams(e,t){let n;for(let r=0;r<t.length;r+=1){let i=t[r];Array.isArray(i)&&(n??=[...t],n[r]=e.array(i,`TEXT`).serializedValues)}return n??t}const h={parseField:(e,t,n)=>t===`int`&&e instanceof Int32Array?n(Array.from(e),t):n(e,t)},g={client:!0,databaseUrl:!0,options:!0,pgvector:!0,postgis:!0,sharedRelationBodies:!0,relationsPerStatement:!0,namespace:!0,migrationSessionAttestation:!0};var BunSQLDriver=class extends d{result=h;maxBindParametersPerStatement=65535;driverOptions;suppliedClient;constructor(e={}){super(`postgresql`,`bun-sql`);let t=l(e);this.driverOptions=e,this.suppliedClient=e.client,this.suppliedClient&&(this.client=this.suppliedClient),p(this,t,e),u(this,`migrationSessionAttestation`,f(e))}migrationSessionEndpoints(){let{databaseUrl:e,options:t}=this.driverOptions,n=this.suppliedClient?.options;return[e,t?.hostname,n?.hostname,n?.url]}async initClient(){if(this.suppliedClient!==void 0)return this.suppliedClient;let{SQL:e}=await import(`bun`);return this.driverOptions.databaseUrl?new e({...this.driverOptions.options,url:this.driverOptions.databaseUrl}):new e(this.driverOptions.options??{})}async closeClient(e){e!==this.suppliedClient&&await e.close()}async execute(e,n,r,i){let a=i?.operation??`execute`,o=await e.unsafe(n,normalizeBunSQLParams(e,r)).catch(e=>{throw m(this.adapter,e),e});return{rows:o,rowCount:t(o.count,{provider:`bun-sql`,operation:a})}}async executeRaw(e,n,r,i){let a=i?.operation??`executeRaw`,o=await e.unsafe(n,r);return{rows:o,rowCount:t(o.count,{provider:`bun-sql`,operation:a})}}transactionOptionSupport(){return{isolationLevel:`post-begin`,timeout:!0,maxWait:`unsupported`,maxWaitReason:`Bun SQL acquires the connection inside sql.begin(), which VibORM cannot observe or bound — the wait would be unbounded no matter what maxWait said`}}async transaction(e,t,a){if(`savepoint`in e)throw i(this.driverName);return r({run:t=>e.begin(t),callback:t,phases:n(a),close:async()=>void 0})}async pinnedSession(){let e=await this.getClient({operation:`pinnedSession`});if(`savepoint`in e)throw i(this.driverName);let t=await e.reserve();return{session:t,release:(n,r)=>o({driverName:this.driverName,discard:n,lost:r,reset:()=>t.unsafe(`SELECT pg_advisory_unlock_all()`),release:()=>t.release(),closeOwnedTransport:e===this.suppliedClient?void 0:async()=>{this.client=null,this.initPromise=null,await e.close({timeout:s/1e3})}})}}};function createClient(e){c(e,`bun-sql`,g);let{client:t,databaseUrl:n,options:r,pgvector:i,postgis:o}=e,s=l(e),u=f(e);return a(e,new BunSQLDriver({client:t,databaseUrl:n,options:r,pgvector:i,postgis:o,sharedRelationBodies:e.sharedRelationBodies,relationsPerStatement:e.relationsPerStatement,namespace:s,migrationSessionAttestation:u}))}export{BunSQLDriver,createClient};
2
2
  //# sourceMappingURL=bun-sql.mjs.map
@@ -1,4 +1,4 @@
1
- import { A as Schema, At as DriverConfig, F as LinkedClientConfig, Ft as VibORMClient, Nn as QueryExecutionContext, Pn as QueryResult, Pt as NoExtraDriverConfigKeys, h as DriverResultParser, kn as TransactionOptionSupport, p as SqliteMigrationCapability, s as DatabaseAdapter, u as Driver } from "./index-Ci8b13Lm.mjs";
1
+ import { A as Schema, An as TransactionOptionSupport, At as DriverConfig, F as LinkedClientConfig, Fn as QueryResult, Ft as VibORMClient, Pn as QueryExecutionContext, Pt as NoExtraDriverConfigKeys, h as DriverResultParser, p as SqliteMigrationCapability, s as DatabaseAdapter, u as Driver } from "./index-DRX_LLQM.mjs";
2
2
 
3
3
  //#region src/drivers/bun-sqlite/index.d.ts
4
4
 
@@ -1,2 +1,2 @@
1
- import{n as e}from"./chunk-BuuaeEvq.mjs";import{a as t,r as n}from"./validation-gwZYm3Yn.mjs";import{n as r}from"./client-DACEO6tS.mjs";import{c as i,n as a,r as o,t as s}from"./driver-DseQwbsu.mjs";import{a as c,c as l,i as u,l as d,n as f,s as p,t as m}from"./sqlite-utils-C5_KQPZn.mjs";import{t as h}from"./sqlite-adapter-CLWY4B8w.mjs";function requireSafeIntegers(e){if(typeof e.safeIntegers!=`function`)throw new t(`bun:sqlite`,`Statement.safeIntegers`,`This Bun build cannot read INTEGER columns as BigInt, so any value past 2^53 would come back silently rounded. Upgrade to Bun 1.1.14 or newer.`);return e}function reusesStatements(e){let t;for(let n=Object.getPrototypeOf(e);n;n=Object.getPrototypeOf(n))Object.hasOwn(n,`prepare`)&&(t=n.prepare);return e.prepare===t}const g=/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/u;function convertValuesForBunSQLite(e){return e.map(e=>{let t=f(e);if(typeof t==`string`&&g.test(t))throw TypeError(`bun:sqlite cannot preserve unpaired UTF-16 surrogates; the parameter was refused before dispatch.`);return t instanceof Uint8Array||!u(t)?t:l(t)})}const _={client:!0,dataDir:!0,options:!0};var BunSQLiteDriver=class extends s{adapter=new h;maxBindParametersPerStatement=32766;result=d;sqliteMigrationCapability=a;serializeTransactions=!0;driverOptions;suppliedClient;busyTimeout;constructor(e={}){if(super(`sqlite`,`bun-sqlite`),this.driverOptions=e,this.busyTimeout=e.options?.timeout??5e3,!Number.isSafeInteger(this.busyTimeout)||this.busyTimeout<0)throw new n(`The bun-sqlite "timeout" option must be a non-negative integer number of milliseconds.`,{meta:{driver:`bun-sqlite`,operation:`configuration`}});if(this.suppliedClient=e.client,this.suppliedClient){let e=this.suppliedClient.query(`PRAGMA foreign_keys`).get();if(!e||typeof e!=`object`||Reflect.get(e,`foreign_keys`)!==1)throw new n(`A supplied bun:sqlite Database must enable PRAGMA foreign_keys = ON before wrapping.`,{meta:{driver:`bun-sqlite`}});this.client=this.suppliedClient,Object.defineProperty(this,`connectionQueue`,{value:o(this.suppliedClient)})}}async initClient(){if(this.suppliedClient)return this.suppliedClient;let{Database:e}=await import(`bun:sqlite`),t=this.driverOptions.dataDir??`:memory:`,{timeout:n,...r}=this.driverOptions.options??{},i=Object.keys(r).length===0?new e(t):new e(t,r);return i.exec(`PRAGMA foreign_keys = ON`),i.exec(`PRAGMA busy_timeout = ${this.busyTimeout}`),i}async closeClient(e){e!==this.suppliedClient&&e.close()}async execute(e,t,n,r){let i=convertValuesForBunSQLite(n);return this.runStatement(e,t,i,r?.model!==`$raw`)}async executeRaw(e,t,n){let r=n?convertValuesForBunSQLite(n):void 0;return this.runStatement(e,t,r,!1)}runStatement(e,t,n,r){let i=r&&reusesStatements(e)?e.query(t):e.prepare(t);if(i.columnNames.length>0){requireSafeIntegers(i).safeIntegers(!0);let e=n?i.all(...n):i.all();return{rows:r?e:c(e),rowCount:e.length}}return{rows:[],rowCount:(n?i.run(...n):i.run()).changes}}transactionOptionSupport(){return m}async transaction(e,t,n){return p(e,t,n)}};function createClient(e){i(e,`bun-sqlite`,_,{databaseUrl:`pass the database file as dataDir`});let{client:t,dataDir:n,options:a}=e;return r(e,new BunSQLiteDriver({client:t,dataDir:n,options:a}))}export{BunSQLiteDriver,createClient};
1
+ import{n as e}from"./chunk-BuuaeEvq.mjs";import{r as t,t as n}from"./query-CTna5P9o.mjs";import{n as r}from"./client-BqgVSbk0.mjs";import{c as i,n as a,r as o,t as s}from"./driver-szWYBmjD.mjs";import{a as c,c as l,i as u,l as d,n as f,s as p,t as m}from"./sqlite-utils-DeDlMJKj.mjs";import{t as h}from"./sqlite-adapter-DqT6HeDs.mjs";function requireSafeIntegers(e){if(typeof e.safeIntegers!=`function`)throw new t(`bun:sqlite`,`Statement.safeIntegers`,`This Bun build cannot read INTEGER columns as BigInt, so any value past 2^53 would come back silently rounded. Upgrade to Bun 1.1.14 or newer.`);return e}function reusesStatements(e){let t;for(let n=Object.getPrototypeOf(e);n;n=Object.getPrototypeOf(n))Object.hasOwn(n,`prepare`)&&(t=n.prepare);return e.prepare===t}const g=/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/u;function convertValuesForBunSQLite(e){return e.map(e=>{let t=f(e);if(typeof t==`string`&&g.test(t))throw TypeError(`bun:sqlite cannot preserve unpaired UTF-16 surrogates; the parameter was refused before dispatch.`);return t instanceof Uint8Array||!u(t)?t:l(t)})}const _={client:!0,dataDir:!0,options:!0};var BunSQLiteDriver=class extends s{adapter=new h;maxBindParametersPerStatement=32766;result=d;sqliteMigrationCapability=a;serializeTransactions=!0;driverOptions;suppliedClient;busyTimeout;constructor(e={}){if(super(`sqlite`,`bun-sqlite`),this.driverOptions=e,this.busyTimeout=e.options?.timeout??5e3,!Number.isSafeInteger(this.busyTimeout)||this.busyTimeout<0)throw new n(`The bun-sqlite "timeout" option must be a non-negative integer number of milliseconds.`,{meta:{driver:`bun-sqlite`,operation:`configuration`}});if(this.suppliedClient=e.client,this.suppliedClient){let e=this.suppliedClient.query(`PRAGMA foreign_keys`).get();if(!e||typeof e!=`object`||Reflect.get(e,`foreign_keys`)!==1)throw new n(`A supplied bun:sqlite Database must enable PRAGMA foreign_keys = ON before wrapping.`,{meta:{driver:`bun-sqlite`}});this.client=this.suppliedClient,Object.defineProperty(this,`connectionQueue`,{value:o(this.suppliedClient)})}}async initClient(){if(this.suppliedClient)return this.suppliedClient;let{Database:e}=await import(`bun:sqlite`),t=this.driverOptions.dataDir??`:memory:`,{timeout:n,...r}=this.driverOptions.options??{},i=Object.keys(r).length===0?new e(t):new e(t,r);return i.exec(`PRAGMA foreign_keys = ON`),i.exec(`PRAGMA busy_timeout = ${this.busyTimeout}`),i}async closeClient(e){e!==this.suppliedClient&&e.close()}async execute(e,t,n,r){let i=convertValuesForBunSQLite(n);return this.runStatement(e,t,i,r?.model!==`$raw`)}async executeRaw(e,t,n){let r=n?convertValuesForBunSQLite(n):void 0;return this.runStatement(e,t,r,!1)}runStatement(e,t,n,r){let i=r&&reusesStatements(e)?e.query(t):e.prepare(t);if(i.columnNames.length>0){requireSafeIntegers(i).safeIntegers(!0);let e=n?i.all(...n):i.all();return{rows:r?e:c(e),rowCount:e.length}}return{rows:[],rowCount:(n?i.run(...n):i.run()).changes}}transactionOptionSupport(){return m}async transaction(e,t,n){return p(e,t,n)}};function createClient(e){i(e,`bun-sqlite`,_,{databaseUrl:`pass the database file as dataDir`});let{client:t,dataDir:n,options:a}=e;return r(e,new BunSQLiteDriver({client:t,dataDir:n,options:a}))}export{BunSQLiteDriver,createClient};
2
2
  //# sourceMappingURL=bun-sqlite.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"bun-sqlite.mjs","names":[],"sources":["../src/drivers/bun-sqlite/index.ts"],"sourcesContent":["import { physicalConnectionQueue } from \"../connection-scope\";\nimport { refuseUnknownDriverConfigKeys } from \"../shared/driver-options\";\nimport {\n LOCAL_SQLITE_TRANSACTION_SUPPORT,\n normalizeSQLiteRawRows,\n runLocalSQLiteTransaction,\n} from \"../shared/sqlite-utils\";\n/**\n * Bun SQLite Driver\n *\n * Driver implementation for Bun's built-in SQLite (bun:sqlite).\n */\n\nimport type { DatabaseAdapter } from \"@adapters/database-adapter\";\nimport { SQLiteAdapter } from \"@adapters/databases/sqlite/sqlite-adapter\";\nimport {\n createClientFromDriverConfig,\n type DriverConfig,\n type LinkedClientConfig,\n type NoExtraDriverConfigKeys,\n type VibORMClient,\n} from \"@client/client\";\nimport type { Schema } from \"@client/types\";\nimport { ClientInitializationError, FeatureNotSupportedError } from \"@errors\";\nimport {\n Driver,\n type DriverResultParser,\n type QueryExecutionContext,\n SQLITE_MIGRATION_CAPABILITY,\n} from \"../driver\";\nimport {\n convertValueForSQLite,\n isSQLiteBinaryValue,\n sqliteBinaryToUint8Array,\n sqliteResultParser,\n type TransactionOptionSupport,\n} from \"../shared\";\nimport type { QueryResult } from \"../types\";\n\n// ============================================================\n// TYPE DECLARATIONS FOR BUN:SQLITE\n// ============================================================\n\n// Bun's Database type - we define inline to avoid requiring bun types at compile time\ninterface BunSQLiteDatabase {\n query<T = unknown>(sql: string): BunSQLiteStatement<T>;\n prepare<T = unknown>(sql: string): BunSQLiteStatement<T>;\n run(sql: string, ...params: unknown[]): void;\n exec(sql: string): void;\n readonly inTransaction: boolean;\n close(): void;\n transaction<T>(fn: () => T): () => T;\n}\n\ninterface BunSQLiteStatement<T = unknown> {\n readonly columnNames: string[];\n all(...params: unknown[]): T[];\n get(...params: unknown[]): T | null;\n run(...params: unknown[]): {\n changes: number;\n lastInsertRowid: number | bigint;\n };\n /**\n * Reads INTEGER columns as BigInt instead of lossy JS numbers. Present on\n * `bun:sqlite` statements since Bun 1.1.14; the driver refuses to read\n * rather than return corrupted values when it is missing.\n */\n safeIntegers(safe: boolean): BunSQLiteStatement<T>;\n values(...params: unknown[]): unknown[][];\n}\n\n/**\n * `safeIntegers()` is what keeps an INTEGER past 2^53 from being rounded on\n * the way out of SQLite. A `bun:sqlite` old enough to lack it cannot answer\n * the query truthfully, so the read is refused instead of silently returning\n * a corrupted number — the one outcome that must never ship.\n */\nfunction requireSafeIntegers<T>(\n stmt: BunSQLiteStatement<T>\n): BunSQLiteStatement<T> {\n if (typeof stmt.safeIntegers !== \"function\") {\n throw new FeatureNotSupportedError(\n \"bun:sqlite\",\n \"Statement.safeIntegers\",\n \"This Bun build cannot read INTEGER columns as BigInt, so any value past 2^53 would come back silently rounded. Upgrade to Bun 1.1.14 or newer.\"\n );\n }\n return stmt;\n}\n\n/**\n * Typed statements come from `bun:sqlite`'s own bounded statement cache\n * (`query`), which dies with the database: `close()` finalizes it, and a closed\n * database refuses instead of answering. The cache is reused only while\n * `prepare` is the one `bun:sqlite` defines at the base of the class chain; a\n * database whose `prepare` was replaced or overridden sees every call.\n */\nfunction reusesStatements(db: BunSQLiteDatabase): boolean {\n let stock: unknown;\n for (\n let proto = Object.getPrototypeOf(db);\n proto;\n proto = Object.getPrototypeOf(proto)\n )\n if (Object.hasOwn(proto, \"prepare\")) stock = proto.prepare;\n return db.prepare === stock;\n}\n\nconst UNPAIRED_SURROGATE_PATTERN =\n /[\\uD800-\\uDBFF](?![\\uDC00-\\uDFFF])|(?<![\\uD800-\\uDBFF])[\\uDC00-\\uDFFF]/u;\n\nfunction convertValuesForBunSQLite(values: unknown[]): unknown[] {\n return values.map((parameter) => {\n const value = convertValueForSQLite(parameter);\n if (typeof value === \"string\" && UNPAIRED_SURROGATE_PATTERN.test(value)) {\n throw new TypeError(\n \"bun:sqlite cannot preserve unpaired UTF-16 surrogates; the parameter was refused before dispatch.\"\n );\n }\n if (value instanceof Uint8Array || !isSQLiteBinaryValue(value)) {\n return value;\n }\n return sqliteBinaryToUint8Array(value);\n });\n}\n\n// ============================================================\n// EXPORTED OPTIONS\n// ============================================================\n\nexport interface BunSQLiteOptions {\n readonly?: boolean;\n create?: boolean;\n readwrite?: boolean;\n strict?: boolean;\n /**\n * Busy timeout in milliseconds, applied as `PRAGMA busy_timeout`. A VibORM\n * option: `bun:sqlite` has none of its own. Defaults to 5000.\n */\n timeout?: number;\n}\n\nexport interface BunSQLiteDriverOptions {\n client?: BunSQLiteDatabase;\n dataDir?: string;\n options?: BunSQLiteOptions;\n}\n\nexport type BunSQLiteClientConfig<C extends DriverConfig> =\n BunSQLiteDriverOptions & C;\n\nconst BUN_SQLITE_CONFIG_KEYS: Record<keyof BunSQLiteDriverOptions, true> = {\n client: true,\n dataDir: true,\n options: true,\n};\n\n// ============================================================\n// DRIVER IMPLEMENTATION\n// ============================================================\n\nexport class BunSQLiteDriver extends Driver<\n BunSQLiteDatabase,\n BunSQLiteDatabase\n> {\n readonly adapter: DatabaseAdapter = new SQLiteAdapter();\n readonly maxBindParametersPerStatement: number | undefined = 32_766;\n readonly result: DriverResultParser = sqliteResultParser;\n readonly sqliteMigrationCapability = SQLITE_MIGRATION_CAPABILITY;\n protected override readonly serializeTransactions = true;\n\n private readonly driverOptions: BunSQLiteDriverOptions;\n private readonly suppliedClient: BunSQLiteDatabase | undefined;\n /** Interpolated into a PRAGMA, so it is admitted here as an integer. */\n private readonly busyTimeout: number;\n\n constructor(options: BunSQLiteDriverOptions = {}) {\n super(\"sqlite\", \"bun-sqlite\");\n this.driverOptions = options;\n this.busyTimeout = options.options?.timeout ?? 5000;\n if (!Number.isSafeInteger(this.busyTimeout) || this.busyTimeout < 0) {\n throw new ClientInitializationError(\n 'The bun-sqlite \"timeout\" option must be a non-negative integer number of milliseconds.',\n { meta: { driver: \"bun-sqlite\", operation: \"configuration\" } }\n );\n }\n\n this.suppliedClient = options.client;\n if (this.suppliedClient) {\n const enabled = this.suppliedClient.query(\"PRAGMA foreign_keys\").get();\n if (\n !enabled ||\n typeof enabled !== \"object\" ||\n Reflect.get(enabled, \"foreign_keys\") !== 1\n ) {\n throw new ClientInitializationError(\n \"A supplied bun:sqlite Database must enable PRAGMA foreign_keys = ON before wrapping.\",\n { meta: { driver: \"bun-sqlite\" } }\n );\n }\n this.client = this.suppliedClient;\n Object.defineProperty(this, \"connectionQueue\", {\n value: physicalConnectionQueue(this.suppliedClient),\n });\n }\n }\n\n protected async initClient(): Promise<BunSQLiteDatabase> {\n if (this.suppliedClient) return this.suppliedClient;\n // Dynamic import for bun:sqlite\n const { Database } = await import(\"bun:sqlite\");\n\n const dataDir = this.driverOptions.dataDir ?? \":memory:\";\n // `timeout` is VibORM's own key, not one of bun:sqlite's open flags.\n const { timeout: _timeout, ...openFlags } =\n this.driverOptions.options ?? {};\n\n // bun:sqlite derives its open flags from this object and rejects one that\n // names no access mode: `new Database(path, {})` throws SQLITE_MISUSE\n // (\"flags must include SQLITE_OPEN_READONLY or SQLITE_OPEN_READWRITE\").\n // An options bag that says nothing must mean nothing, so the argument is\n // omitted entirely and Bun applies its own default (readwrite + create).\n const db = (Object.keys(openFlags).length === 0\n ? new Database(dataDir)\n : new Database(dataDir, openFlags)) as unknown as BunSQLiteDatabase;\n\n // bun:sqlite leaves SQLite's foreign_keys default (OFF), which would let a\n // dangling FK write report success while sqlite3 and libsql refuse it.\n // Enforcement is a viborm guarantee, not an inherited library default.\n db.exec(\"PRAGMA foreign_keys = ON\");\n db.exec(`PRAGMA busy_timeout = ${this.busyTimeout}`);\n\n return db;\n }\n\n protected async closeClient(db: BunSQLiteDatabase): Promise<void> {\n if (db !== this.suppliedClient) db.close();\n }\n\n protected async execute<T>(\n client: BunSQLiteDatabase,\n sql: string,\n params: unknown[],\n context?: QueryExecutionContext\n ): Promise<QueryResult<T>> {\n const values = convertValuesForBunSQLite(params);\n return this.runStatement<T>(client, sql, values, context?.model !== \"$raw\");\n }\n\n protected async executeRaw<T>(\n client: BunSQLiteDatabase,\n sql: string,\n params?: unknown[]\n ): Promise<QueryResult<T>> {\n const values = params ? convertValuesForBunSQLite(params) : undefined;\n return this.runStatement<T>(client, sql, values, false);\n }\n\n private runStatement<T>(\n db: BunSQLiteDatabase,\n sql: string,\n values: unknown[] | undefined,\n typed: boolean\n ): QueryResult<T> {\n const stmt =\n typed && reusesStatements(db) ? db.query(sql) : db.prepare(sql);\n\n if (stmt.columnNames.length > 0) {\n // Read once without precision loss, including unsafe raw queries.\n requireSafeIntegers(stmt).safeIntegers(true);\n const rows = (values ? stmt.all(...values) : stmt.all()) as T[];\n return {\n rows: typed ? rows : normalizeSQLiteRawRows(rows),\n rowCount: rows.length,\n };\n }\n\n const result = values ? stmt.run(...values) : stmt.run();\n return { rows: [] as T[], rowCount: result.changes };\n }\n\n protected override transactionOptionSupport(): TransactionOptionSupport {\n return LOCAL_SQLITE_TRANSACTION_SUPPORT;\n }\n\n protected async transaction<T>(\n client: BunSQLiteDatabase,\n fn: (tx: BunSQLiteDatabase) => Promise<T>,\n context?: QueryExecutionContext\n ): Promise<T> {\n return runLocalSQLiteTransaction(client, fn, context);\n }\n}\n\n// ============================================================\n// CONVENIENCE FUNCTION\n// ============================================================\n\nexport function createClient<S extends Schema, C extends DriverConfig<S>>(\n config: BunSQLiteClientConfig<C> &\n DriverConfig<S> &\n NoExtraDriverConfigKeys<C, BunSQLiteDriverOptions, S>\n): VibORMClient<{\n [P in keyof LinkedClientConfig<\n C & { driver: BunSQLiteDriver }\n >]: LinkedClientConfig<C & { driver: BunSQLiteDriver }>[P];\n}> {\n refuseUnknownDriverConfigKeys(config, \"bun-sqlite\", BUN_SQLITE_CONFIG_KEYS, {\n databaseUrl: \"pass the database file as dataDir\",\n });\n const { client, dataDir, options } = config;\n\n const driver = new BunSQLiteDriver({ client, dataDir, options });\n\n return createClientFromDriverConfig<S, C, BunSQLiteDriver>(config, driver);\n}\n"],"mappings":"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"}
1
+ {"version":3,"file":"bun-sqlite.mjs","names":[],"sources":["../src/drivers/bun-sqlite/index.ts"],"sourcesContent":["import { physicalConnectionQueue } from \"../connection-scope\";\nimport { refuseUnknownDriverConfigKeys } from \"../shared/driver-options\";\nimport {\n LOCAL_SQLITE_TRANSACTION_SUPPORT,\n normalizeSQLiteRawRows,\n runLocalSQLiteTransaction,\n} from \"../shared/sqlite-utils\";\n/**\n * Bun SQLite Driver\n *\n * Driver implementation for Bun's built-in SQLite (bun:sqlite).\n */\n\nimport type { DatabaseAdapter } from \"@adapters/database-adapter\";\nimport { SQLiteAdapter } from \"@adapters/databases/sqlite/sqlite-adapter\";\nimport {\n createClientFromDriverConfig,\n type DriverConfig,\n type LinkedClientConfig,\n type NoExtraDriverConfigKeys,\n type VibORMClient,\n} from \"@client/client\";\nimport type { Schema } from \"@client/types\";\nimport { ClientInitializationError, FeatureNotSupportedError } from \"@errors\";\nimport {\n Driver,\n type DriverResultParser,\n type QueryExecutionContext,\n SQLITE_MIGRATION_CAPABILITY,\n} from \"../driver\";\nimport {\n convertValueForSQLite,\n isSQLiteBinaryValue,\n sqliteBinaryToUint8Array,\n sqliteResultParser,\n type TransactionOptionSupport,\n} from \"../shared\";\nimport type { QueryResult } from \"../types\";\n\n// ============================================================\n// TYPE DECLARATIONS FOR BUN:SQLITE\n// ============================================================\n\n// Bun's Database type - we define inline to avoid requiring bun types at compile time\ninterface BunSQLiteDatabase {\n query<T = unknown>(sql: string): BunSQLiteStatement<T>;\n prepare<T = unknown>(sql: string): BunSQLiteStatement<T>;\n run(sql: string, ...params: unknown[]): void;\n exec(sql: string): void;\n readonly inTransaction: boolean;\n close(): void;\n transaction<T>(fn: () => T): () => T;\n}\n\ninterface BunSQLiteStatement<T = unknown> {\n readonly columnNames: string[];\n all(...params: unknown[]): T[];\n get(...params: unknown[]): T | null;\n run(...params: unknown[]): {\n changes: number;\n lastInsertRowid: number | bigint;\n };\n /**\n * Reads INTEGER columns as BigInt instead of lossy JS numbers. Present on\n * `bun:sqlite` statements since Bun 1.1.14; the driver refuses to read\n * rather than return corrupted values when it is missing.\n */\n safeIntegers(safe: boolean): BunSQLiteStatement<T>;\n values(...params: unknown[]): unknown[][];\n}\n\n/**\n * `safeIntegers()` is what keeps an INTEGER past 2^53 from being rounded on\n * the way out of SQLite. A `bun:sqlite` old enough to lack it cannot answer\n * the query truthfully, so the read is refused instead of silently returning\n * a corrupted number — the one outcome that must never ship.\n */\nfunction requireSafeIntegers<T>(\n stmt: BunSQLiteStatement<T>\n): BunSQLiteStatement<T> {\n if (typeof stmt.safeIntegers !== \"function\") {\n throw new FeatureNotSupportedError(\n \"bun:sqlite\",\n \"Statement.safeIntegers\",\n \"This Bun build cannot read INTEGER columns as BigInt, so any value past 2^53 would come back silently rounded. Upgrade to Bun 1.1.14 or newer.\"\n );\n }\n return stmt;\n}\n\n/**\n * Typed statements come from `bun:sqlite`'s own bounded statement cache\n * (`query`), which dies with the database: `close()` finalizes it, and a closed\n * database refuses instead of answering. The cache is reused only while\n * `prepare` is the one `bun:sqlite` defines at the base of the class chain; a\n * database whose `prepare` was replaced or overridden sees every call.\n */\nfunction reusesStatements(db: BunSQLiteDatabase): boolean {\n let stock: unknown;\n for (\n let proto = Object.getPrototypeOf(db);\n proto;\n proto = Object.getPrototypeOf(proto)\n )\n if (Object.hasOwn(proto, \"prepare\")) stock = proto.prepare;\n return db.prepare === stock;\n}\n\nconst UNPAIRED_SURROGATE_PATTERN =\n /[\\uD800-\\uDBFF](?![\\uDC00-\\uDFFF])|(?<![\\uD800-\\uDBFF])[\\uDC00-\\uDFFF]/u;\n\nfunction convertValuesForBunSQLite(values: unknown[]): unknown[] {\n return values.map((parameter) => {\n const value = convertValueForSQLite(parameter);\n if (typeof value === \"string\" && UNPAIRED_SURROGATE_PATTERN.test(value)) {\n throw new TypeError(\n \"bun:sqlite cannot preserve unpaired UTF-16 surrogates; the parameter was refused before dispatch.\"\n );\n }\n if (value instanceof Uint8Array || !isSQLiteBinaryValue(value)) {\n return value;\n }\n return sqliteBinaryToUint8Array(value);\n });\n}\n\n// ============================================================\n// EXPORTED OPTIONS\n// ============================================================\n\nexport interface BunSQLiteOptions {\n readonly?: boolean;\n create?: boolean;\n readwrite?: boolean;\n strict?: boolean;\n /**\n * Busy timeout in milliseconds, applied as `PRAGMA busy_timeout`. A VibORM\n * option: `bun:sqlite` has none of its own. Defaults to 5000.\n */\n timeout?: number;\n}\n\nexport interface BunSQLiteDriverOptions {\n client?: BunSQLiteDatabase;\n dataDir?: string;\n options?: BunSQLiteOptions;\n}\n\nexport type BunSQLiteClientConfig<C extends DriverConfig> =\n BunSQLiteDriverOptions & C;\n\nconst BUN_SQLITE_CONFIG_KEYS: Record<keyof BunSQLiteDriverOptions, true> = {\n client: true,\n dataDir: true,\n options: true,\n};\n\n// ============================================================\n// DRIVER IMPLEMENTATION\n// ============================================================\n\nexport class BunSQLiteDriver extends Driver<\n BunSQLiteDatabase,\n BunSQLiteDatabase\n> {\n readonly adapter: DatabaseAdapter = new SQLiteAdapter();\n readonly maxBindParametersPerStatement: number | undefined = 32_766;\n readonly result: DriverResultParser = sqliteResultParser;\n readonly sqliteMigrationCapability = SQLITE_MIGRATION_CAPABILITY;\n protected override readonly serializeTransactions = true;\n\n private readonly driverOptions: BunSQLiteDriverOptions;\n private readonly suppliedClient: BunSQLiteDatabase | undefined;\n /** Interpolated into a PRAGMA, so it is admitted here as an integer. */\n private readonly busyTimeout: number;\n\n constructor(options: BunSQLiteDriverOptions = {}) {\n super(\"sqlite\", \"bun-sqlite\");\n this.driverOptions = options;\n this.busyTimeout = options.options?.timeout ?? 5000;\n if (!Number.isSafeInteger(this.busyTimeout) || this.busyTimeout < 0) {\n throw new ClientInitializationError(\n 'The bun-sqlite \"timeout\" option must be a non-negative integer number of milliseconds.',\n { meta: { driver: \"bun-sqlite\", operation: \"configuration\" } }\n );\n }\n\n this.suppliedClient = options.client;\n if (this.suppliedClient) {\n const enabled = this.suppliedClient.query(\"PRAGMA foreign_keys\").get();\n if (\n !enabled ||\n typeof enabled !== \"object\" ||\n Reflect.get(enabled, \"foreign_keys\") !== 1\n ) {\n throw new ClientInitializationError(\n \"A supplied bun:sqlite Database must enable PRAGMA foreign_keys = ON before wrapping.\",\n { meta: { driver: \"bun-sqlite\" } }\n );\n }\n this.client = this.suppliedClient;\n Object.defineProperty(this, \"connectionQueue\", {\n value: physicalConnectionQueue(this.suppliedClient),\n });\n }\n }\n\n protected async initClient(): Promise<BunSQLiteDatabase> {\n if (this.suppliedClient) return this.suppliedClient;\n // Dynamic import for bun:sqlite\n const { Database } = await import(\"bun:sqlite\");\n\n const dataDir = this.driverOptions.dataDir ?? \":memory:\";\n // `timeout` is VibORM's own key, not one of bun:sqlite's open flags.\n const { timeout: _timeout, ...openFlags } =\n this.driverOptions.options ?? {};\n\n // bun:sqlite derives its open flags from this object and rejects one that\n // names no access mode: `new Database(path, {})` throws SQLITE_MISUSE\n // (\"flags must include SQLITE_OPEN_READONLY or SQLITE_OPEN_READWRITE\").\n // An options bag that says nothing must mean nothing, so the argument is\n // omitted entirely and Bun applies its own default (readwrite + create).\n const db = (Object.keys(openFlags).length === 0\n ? new Database(dataDir)\n : new Database(dataDir, openFlags)) as unknown as BunSQLiteDatabase;\n\n // bun:sqlite leaves SQLite's foreign_keys default (OFF), which would let a\n // dangling FK write report success while sqlite3 and libsql refuse it.\n // Enforcement is a viborm guarantee, not an inherited library default.\n db.exec(\"PRAGMA foreign_keys = ON\");\n db.exec(`PRAGMA busy_timeout = ${this.busyTimeout}`);\n\n return db;\n }\n\n protected async closeClient(db: BunSQLiteDatabase): Promise<void> {\n if (db !== this.suppliedClient) db.close();\n }\n\n protected async execute<T>(\n client: BunSQLiteDatabase,\n sql: string,\n params: unknown[],\n context?: QueryExecutionContext\n ): Promise<QueryResult<T>> {\n const values = convertValuesForBunSQLite(params);\n return this.runStatement<T>(client, sql, values, context?.model !== \"$raw\");\n }\n\n protected async executeRaw<T>(\n client: BunSQLiteDatabase,\n sql: string,\n params?: unknown[]\n ): Promise<QueryResult<T>> {\n const values = params ? convertValuesForBunSQLite(params) : undefined;\n return this.runStatement<T>(client, sql, values, false);\n }\n\n private runStatement<T>(\n db: BunSQLiteDatabase,\n sql: string,\n values: unknown[] | undefined,\n typed: boolean\n ): QueryResult<T> {\n const stmt =\n typed && reusesStatements(db) ? db.query(sql) : db.prepare(sql);\n\n if (stmt.columnNames.length > 0) {\n // Read once without precision loss, including unsafe raw queries.\n requireSafeIntegers(stmt).safeIntegers(true);\n const rows = (values ? stmt.all(...values) : stmt.all()) as T[];\n return {\n rows: typed ? rows : normalizeSQLiteRawRows(rows),\n rowCount: rows.length,\n };\n }\n\n const result = values ? stmt.run(...values) : stmt.run();\n return { rows: [] as T[], rowCount: result.changes };\n }\n\n protected override transactionOptionSupport(): TransactionOptionSupport {\n return LOCAL_SQLITE_TRANSACTION_SUPPORT;\n }\n\n protected async transaction<T>(\n client: BunSQLiteDatabase,\n fn: (tx: BunSQLiteDatabase) => Promise<T>,\n context?: QueryExecutionContext\n ): Promise<T> {\n return runLocalSQLiteTransaction(client, fn, context);\n }\n}\n\n// ============================================================\n// CONVENIENCE FUNCTION\n// ============================================================\n\nexport function createClient<S extends Schema, C extends DriverConfig<S>>(\n config: BunSQLiteClientConfig<C> &\n DriverConfig<S> &\n NoExtraDriverConfigKeys<C, BunSQLiteDriverOptions, S>\n): VibORMClient<{\n [P in keyof LinkedClientConfig<\n C & { driver: BunSQLiteDriver }\n >]: LinkedClientConfig<C & { driver: BunSQLiteDriver }>[P];\n}> {\n refuseUnknownDriverConfigKeys(config, \"bun-sqlite\", BUN_SQLITE_CONFIG_KEYS, {\n databaseUrl: \"pass the database file as dataDir\",\n });\n const { client, dataDir, options } = config;\n\n const driver = new BunSQLiteDriver({ client, dataDir, options });\n\n return createClientFromDriverConfig<S, C, BunSQLiteDriver>(config, driver);\n}\n"],"mappings":"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"}
@@ -1,4 +1,4 @@
1
- import { bn as CacheDriver, xn as CacheEntry } from "../index-Ci8b13Lm.mjs";
1
+ import { Sn as CacheEntry, xn as CacheDriver } from "../index-DRX_LLQM.mjs";
2
2
  import { KVNamespace } from "@cloudflare/workers-types";
3
3
 
4
4
  //#region src/cache/drivers/cloudflare-kv.d.ts
@@ -1,2 +1,2 @@
1
- import{n as e}from"../chunk-BuuaeEvq.mjs";import{t}from"../driver-BqD-3_jO.mjs";var CloudflareKVCache=class extends t{#e;constructor(e){super(`cloudflare-kv`),this.#e=e}async get(e){return await this.#e.get(e,`json`)||null}async set(e,t,n){let r=Math.max(60,Math.ceil(t/1e3));await this.#e.put(e,JSON.stringify(n),{expirationTtl:r})}async delete(e){await Promise.all(e.map(e=>this.#e.delete(e)))}async clear(e){let t;do{let n=await this.#e.list({prefix:e,cursor:t});await Promise.all(n.keys.map(e=>this.#e.delete(e.name))),t=n.list_complete?void 0:n.cursor}while(t)}};export{CloudflareKVCache};
1
+ import{n as e}from"../chunk-BuuaeEvq.mjs";import{t}from"../driver-Dv2GJyGs.mjs";var CloudflareKVCache=class extends t{#e;constructor(e){super(`cloudflare-kv`),this.#e=e}async get(e){return await this.#e.get(e,`json`)||null}async set(e,t,n){let r=Math.max(60,Math.ceil(t/1e3));await this.#e.put(e,JSON.stringify(n),{expirationTtl:r})}async delete(e){await Promise.all(e.map(e=>this.#e.delete(e)))}async clear(e){let t;do{let n=await this.#e.list({prefix:e,cursor:t});await Promise.all(n.keys.map(e=>this.#e.delete(e.name))),t=n.list_complete?void 0:n.cursor}while(t)}};export{CloudflareKVCache};
2
2
  //# sourceMappingURL=cloudflare-kv.mjs.map
@@ -1,4 +1,4 @@
1
- import { bn as CacheDriver, xn as CacheEntry } from "../index-Ci8b13Lm.mjs";
1
+ import { Sn as CacheEntry, xn as CacheDriver } from "../index-DRX_LLQM.mjs";
2
2
 
3
3
  //#region src/cache/drivers/memory.d.ts
4
4
  interface MemoryCacheOptions {
@@ -1,2 +1,2 @@
1
- import{n as e}from"../chunk-BuuaeEvq.mjs";import{t}from"../cache-CIPRF-pz.mjs";import{t as n}from"../driver-BqD-3_jO.mjs";var MemoryCache=class extends n{#e=new Map;#t;#n;constructor(e,...n){if(super(`memory`),n.length)throw new t(`MemoryCache received extra construction arguments.`);let r=1024;if(e!==void 0){let n;try{n=Object.getOwnPropertyDescriptors(e)}catch{throw new t(`MemoryCache options could not be inspected.`)}let i=n.maxEntries,a=i&&`value`in i?i.value:void 0;if(Reflect.ownKeys(n).length!==1||!i||!(`value`in i)||typeof a!=`number`||!Number.isSafeInteger(a)||a<1)throw new t(`MemoryCache options must contain a positive safe-integer maxEntries only.`);r=a}this.#t=r}async get(e){let t=this.#e.get(e);return t?(this.#e.delete(e),this.clock.now()>=t.expiresAt?(this.#r(),null):(this.#e.set(e,t),t.entry)):null}async set(e,t,n){for(this.#e.delete(e),this.#e.set(e,{entry:n,expiresAt:this.clock.now()+t});this.#e.size>this.#t;){let e=this.#e.keys().next().value;e!==void 0&&this.#e.delete(e)}this.#i(t)}async delete(e){for(let t of e)this.#e.delete(t);this.#r()}async clear(e){for(let t of this.#e.keys())t.startsWith(e)&&this.#e.delete(t);this.#r()}#r(){this.#e.size||(this.#n?.cancel(),this.#n=void 0)}#i(e=6e4){this.#n||!this.#e.size||(this.#n=this.clock.setTimeout(()=>{this.#n=void 0;let e=this.clock.now();for(let[t,n]of this.#e)e>=n.expiresAt&&this.#e.delete(t);this.#i()},Math.min(e,6e4)),this.#n.unref?.())}async disconnect(){this.#e.clear(),this.#r()}};export{MemoryCache};
1
+ import{n as e}from"../chunk-BuuaeEvq.mjs";import{p as t}from"../observation-BcT8Cs3d.mjs";import{t as n}from"../driver-Dv2GJyGs.mjs";var MemoryCache=class extends n{#e=new Map;#t;#n;constructor(e,...n){if(super(`memory`),n.length)throw new t(`MemoryCache received extra construction arguments.`);let r=1024;if(e!==void 0){let n;try{n=Object.getOwnPropertyDescriptors(e)}catch{throw new t(`MemoryCache options could not be inspected.`)}let i=n.maxEntries,a=i&&`value`in i?i.value:void 0;if(Reflect.ownKeys(n).length!==1||!i||!(`value`in i)||typeof a!=`number`||!Number.isSafeInteger(a)||a<1)throw new t(`MemoryCache options must contain a positive safe-integer maxEntries only.`);r=a}this.#t=r}async get(e){let t=this.#e.get(e);return t?(this.#e.delete(e),this.clock.now()>=t.expiresAt?(this.#r(),null):(this.#e.set(e,t),t.entry)):null}async set(e,t,n){for(this.#e.delete(e),this.#e.set(e,{entry:n,expiresAt:this.clock.now()+t});this.#e.size>this.#t;){let e=this.#e.keys().next().value;e!==void 0&&this.#e.delete(e)}this.#i(t)}async delete(e){for(let t of e)this.#e.delete(t);this.#r()}async clear(e){for(let t of this.#e.keys())t.startsWith(e)&&this.#e.delete(t);this.#r()}#r(){this.#e.size||(this.#n?.cancel(),this.#n=void 0)}#i(e=6e4){this.#n||!this.#e.size||(this.#n=this.clock.setTimeout(()=>{this.#n=void 0;let e=this.clock.now();for(let[t,n]of this.#e)e>=n.expiresAt&&this.#e.delete(t);this.#i()},Math.min(e,6e4)),this.#n.unref?.())}async disconnect(){this.#e.clear(),this.#r()}};export{MemoryCache};
2
2
  //# sourceMappingURL=memory.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"memory.mjs","names":["#store","#maxEntries","#idle","#schedule","#timer"],"sources":["../../src/cache/drivers/memory.ts"],"sourcesContent":["/** In-memory LRU cache with a bounded entry count and one expiry sweep. */\nimport type { ClockTimer } from \"../../clock\";\nimport { CacheConfigurationError } from \"../../errors\";\nimport { CacheDriver, type CacheEntry } from \"../driver\";\n\nexport interface MemoryCacheOptions {\n readonly maxEntries: number;\n}\n\nexport class MemoryCache<\n const Options extends MemoryCacheOptions = MemoryCacheOptions,\n> extends CacheDriver {\n readonly #store = new Map<string, { entry: CacheEntry; expiresAt: number }>();\n readonly #maxEntries: number;\n #timer?: ClockTimer;\n\n constructor(\n options?: Options &\n Record<Exclude<keyof Options, keyof MemoryCacheOptions>, never>,\n ...extra: never[]\n ) {\n super(\"memory\");\n if (extra.length)\n throw new CacheConfigurationError(\n \"MemoryCache received extra construction arguments.\"\n );\n let maxEntries = 1024;\n if (options !== undefined) {\n let descriptors: PropertyDescriptorMap;\n try {\n descriptors = Object.getOwnPropertyDescriptors(options);\n } catch {\n throw new CacheConfigurationError(\n \"MemoryCache options could not be inspected.\"\n );\n }\n const limit = descriptors.maxEntries;\n const supplied: unknown =\n limit && \"value\" in limit ? limit.value : undefined;\n if (\n Reflect.ownKeys(descriptors).length !== 1 ||\n !limit ||\n !(\"value\" in limit) ||\n typeof supplied !== \"number\" ||\n !Number.isSafeInteger(supplied) ||\n supplied < 1\n )\n throw new CacheConfigurationError(\n \"MemoryCache options must contain a positive safe-integer maxEntries only.\"\n );\n maxEntries = supplied;\n }\n this.#maxEntries = maxEntries;\n }\n\n protected async get<T>(key: string): Promise<CacheEntry<T> | null> {\n const stored = this.#store.get(key);\n if (!stored) return null;\n this.#store.delete(key);\n if (this.clock.now() >= stored.expiresAt) {\n this.#idle();\n return null;\n }\n this.#store.set(key, stored);\n return stored.entry as CacheEntry<T>;\n }\n\n protected async set<T>(\n key: string,\n storageTtl: number,\n entry: CacheEntry<T>\n ): Promise<void> {\n this.#store.delete(key);\n this.#store.set(key, { entry, expiresAt: this.clock.now() + storageTtl });\n while (this.#store.size > this.#maxEntries) {\n const oldest = this.#store.keys().next().value;\n if (oldest !== undefined) this.#store.delete(oldest);\n }\n this.#schedule(storageTtl);\n }\n\n protected async delete(keys: string[]): Promise<void> {\n for (const key of keys) this.#store.delete(key);\n this.#idle();\n }\n\n protected async clear(prefix: string): Promise<void> {\n for (const key of this.#store.keys())\n if (key.startsWith(prefix)) this.#store.delete(key);\n this.#idle();\n }\n\n #idle(): void {\n if (this.#store.size) return;\n this.#timer?.cancel();\n this.#timer = undefined;\n }\n\n #schedule(delay = 60_000): void {\n if (this.#timer || !this.#store.size) return;\n this.#timer = this.clock.setTimeout(\n () => {\n this.#timer = undefined;\n const now = this.clock.now();\n for (const [key, stored] of this.#store)\n if (now >= stored.expiresAt) this.#store.delete(key);\n this.#schedule();\n },\n Math.min(delay, 60_000)\n );\n this.#timer.unref?.();\n }\n\n override async disconnect(): Promise<void> {\n this.#store.clear();\n this.#idle();\n }\n}\n"],"mappings":"0HASA,IAAa,YAAb,cAEU,CAAY,CACpB,GAAkB,IAAI,IACtB,GACA,GAEA,YACE,EAEA,GAAG,EACH,CAEA,GADA,MAAM,SAAS,CACX,EAAM,OACR,MAAM,IAAI,EACR,qDACD,CACH,IAAI,EAAa,KACjB,GAAI,IAAY,IAAA,GAAW,CACzB,IAAI,EACJ,GAAI,CACF,EAAc,OAAO,0BAA0B,EAAQ,MACjD,CACN,MAAM,IAAI,EACR,8CACD,CAEH,IAAM,EAAQ,EAAY,WACpB,EACJ,GAAS,UAAW,EAAQ,EAAM,MAAQ,IAAA,GAC5C,GACE,QAAQ,QAAQ,EAAY,CAAC,SAAW,GACxC,CAAC,GACD,EAAE,UAAW,IACb,OAAO,GAAa,UACpB,CAAC,OAAO,cAAc,EAAS,EAC/B,EAAW,EAEX,MAAM,IAAI,EACR,4EACD,CACH,EAAa,EAEf,MAAA,EAAmB,EAGrB,MAAgB,IAAO,EAA4C,CACjE,IAAM,EAAS,MAAA,EAAY,IAAI,EAAI,CAQnC,OAPK,GACL,MAAA,EAAY,OAAO,EAAI,CACnB,KAAK,MAAM,KAAK,EAAI,EAAO,WAC7B,MAAA,GAAY,CACL,OAET,MAAA,EAAY,IAAI,EAAK,EAAO,CACrB,EAAO,QAPM,KAUtB,MAAgB,IACd,EACA,EACA,EACe,CAGf,IAFA,MAAA,EAAY,OAAO,EAAI,CACvB,MAAA,EAAY,IAAI,EAAK,CAAE,QAAO,UAAW,KAAK,MAAM,KAAK,CAAG,EAAY,CAAC,CAClE,MAAA,EAAY,KAAO,MAAA,GAAkB,CAC1C,IAAM,EAAS,MAAA,EAAY,MAAM,CAAC,MAAM,CAAC,MACrC,IAAW,IAAA,IAAW,MAAA,EAAY,OAAO,EAAO,CAEtD,MAAA,EAAe,EAAW,CAG5B,MAAgB,OAAO,EAA+B,CACpD,IAAK,IAAM,KAAO,EAAM,MAAA,EAAY,OAAO,EAAI,CAC/C,MAAA,GAAY,CAGd,MAAgB,MAAM,EAA+B,CACnD,IAAK,IAAM,KAAO,MAAA,EAAY,MAAM,CAC9B,EAAI,WAAW,EAAO,EAAE,MAAA,EAAY,OAAO,EAAI,CACrD,MAAA,GAAY,CAGd,IAAc,CACR,MAAA,EAAY,OAChB,MAAA,GAAa,QAAQ,CACrB,MAAA,EAAc,IAAA,IAGhB,GAAU,EAAQ,IAAc,CAC1B,MAAA,GAAe,CAAC,MAAA,EAAY,OAChC,MAAA,EAAc,KAAK,MAAM,eACjB,CACJ,MAAA,EAAc,IAAA,GACd,IAAM,EAAM,KAAK,MAAM,KAAK,CAC5B,IAAK,GAAM,CAAC,EAAK,KAAW,MAAA,EACtB,GAAO,EAAO,WAAW,MAAA,EAAY,OAAO,EAAI,CACtD,MAAA,GAAgB,EAElB,KAAK,IAAI,EAAO,IAAO,CACxB,CACD,MAAA,EAAY,SAAS,EAGvB,MAAe,YAA4B,CACzC,MAAA,EAAY,OAAO,CACnB,MAAA,GAAY"}
1
+ {"version":3,"file":"memory.mjs","names":["#store","#maxEntries","#idle","#schedule","#timer"],"sources":["../../src/cache/drivers/memory.ts"],"sourcesContent":["/** In-memory LRU cache with a bounded entry count and one expiry sweep. */\nimport type { ClockTimer } from \"../../clock\";\nimport { CacheConfigurationError } from \"../../errors\";\nimport { CacheDriver, type CacheEntry } from \"../driver\";\n\nexport interface MemoryCacheOptions {\n readonly maxEntries: number;\n}\n\nexport class MemoryCache<\n const Options extends MemoryCacheOptions = MemoryCacheOptions,\n> extends CacheDriver {\n readonly #store = new Map<string, { entry: CacheEntry; expiresAt: number }>();\n readonly #maxEntries: number;\n #timer?: ClockTimer;\n\n constructor(\n options?: Options &\n Record<Exclude<keyof Options, keyof MemoryCacheOptions>, never>,\n ...extra: never[]\n ) {\n super(\"memory\");\n if (extra.length)\n throw new CacheConfigurationError(\n \"MemoryCache received extra construction arguments.\"\n );\n let maxEntries = 1024;\n if (options !== undefined) {\n let descriptors: PropertyDescriptorMap;\n try {\n descriptors = Object.getOwnPropertyDescriptors(options);\n } catch {\n throw new CacheConfigurationError(\n \"MemoryCache options could not be inspected.\"\n );\n }\n const limit = descriptors.maxEntries;\n const supplied: unknown =\n limit && \"value\" in limit ? limit.value : undefined;\n if (\n Reflect.ownKeys(descriptors).length !== 1 ||\n !limit ||\n !(\"value\" in limit) ||\n typeof supplied !== \"number\" ||\n !Number.isSafeInteger(supplied) ||\n supplied < 1\n )\n throw new CacheConfigurationError(\n \"MemoryCache options must contain a positive safe-integer maxEntries only.\"\n );\n maxEntries = supplied;\n }\n this.#maxEntries = maxEntries;\n }\n\n protected async get<T>(key: string): Promise<CacheEntry<T> | null> {\n const stored = this.#store.get(key);\n if (!stored) return null;\n this.#store.delete(key);\n if (this.clock.now() >= stored.expiresAt) {\n this.#idle();\n return null;\n }\n this.#store.set(key, stored);\n return stored.entry as CacheEntry<T>;\n }\n\n protected async set<T>(\n key: string,\n storageTtl: number,\n entry: CacheEntry<T>\n ): Promise<void> {\n this.#store.delete(key);\n this.#store.set(key, { entry, expiresAt: this.clock.now() + storageTtl });\n while (this.#store.size > this.#maxEntries) {\n const oldest = this.#store.keys().next().value;\n if (oldest !== undefined) this.#store.delete(oldest);\n }\n this.#schedule(storageTtl);\n }\n\n protected async delete(keys: string[]): Promise<void> {\n for (const key of keys) this.#store.delete(key);\n this.#idle();\n }\n\n protected async clear(prefix: string): Promise<void> {\n for (const key of this.#store.keys())\n if (key.startsWith(prefix)) this.#store.delete(key);\n this.#idle();\n }\n\n #idle(): void {\n if (this.#store.size) return;\n this.#timer?.cancel();\n this.#timer = undefined;\n }\n\n #schedule(delay = 60_000): void {\n if (this.#timer || !this.#store.size) return;\n this.#timer = this.clock.setTimeout(\n () => {\n this.#timer = undefined;\n const now = this.clock.now();\n for (const [key, stored] of this.#store)\n if (now >= stored.expiresAt) this.#store.delete(key);\n this.#schedule();\n },\n Math.min(delay, 60_000)\n );\n this.#timer.unref?.();\n }\n\n override async disconnect(): Promise<void> {\n this.#store.clear();\n this.#idle();\n }\n}\n"],"mappings":"qIASA,IAAa,YAAb,cAEU,CAAY,CACpB,GAAkB,IAAI,IACtB,GACA,GAEA,YACE,EAEA,GAAG,EACH,CAEA,GADA,MAAM,SAAS,CACX,EAAM,OACR,MAAM,IAAI,EACR,qDACD,CACH,IAAI,EAAa,KACjB,GAAI,IAAY,IAAA,GAAW,CACzB,IAAI,EACJ,GAAI,CACF,EAAc,OAAO,0BAA0B,EAAQ,MACjD,CACN,MAAM,IAAI,EACR,8CACD,CAEH,IAAM,EAAQ,EAAY,WACpB,EACJ,GAAS,UAAW,EAAQ,EAAM,MAAQ,IAAA,GAC5C,GACE,QAAQ,QAAQ,EAAY,CAAC,SAAW,GACxC,CAAC,GACD,EAAE,UAAW,IACb,OAAO,GAAa,UACpB,CAAC,OAAO,cAAc,EAAS,EAC/B,EAAW,EAEX,MAAM,IAAI,EACR,4EACD,CACH,EAAa,EAEf,MAAA,EAAmB,EAGrB,MAAgB,IAAO,EAA4C,CACjE,IAAM,EAAS,MAAA,EAAY,IAAI,EAAI,CAQnC,OAPK,GACL,MAAA,EAAY,OAAO,EAAI,CACnB,KAAK,MAAM,KAAK,EAAI,EAAO,WAC7B,MAAA,GAAY,CACL,OAET,MAAA,EAAY,IAAI,EAAK,EAAO,CACrB,EAAO,QAPM,KAUtB,MAAgB,IACd,EACA,EACA,EACe,CAGf,IAFA,MAAA,EAAY,OAAO,EAAI,CACvB,MAAA,EAAY,IAAI,EAAK,CAAE,QAAO,UAAW,KAAK,MAAM,KAAK,CAAG,EAAY,CAAC,CAClE,MAAA,EAAY,KAAO,MAAA,GAAkB,CAC1C,IAAM,EAAS,MAAA,EAAY,MAAM,CAAC,MAAM,CAAC,MACrC,IAAW,IAAA,IAAW,MAAA,EAAY,OAAO,EAAO,CAEtD,MAAA,EAAe,EAAW,CAG5B,MAAgB,OAAO,EAA+B,CACpD,IAAK,IAAM,KAAO,EAAM,MAAA,EAAY,OAAO,EAAI,CAC/C,MAAA,GAAY,CAGd,MAAgB,MAAM,EAA+B,CACnD,IAAK,IAAM,KAAO,MAAA,EAAY,MAAM,CAC9B,EAAI,WAAW,EAAO,EAAE,MAAA,EAAY,OAAO,EAAI,CACrD,MAAA,GAAY,CAGd,IAAc,CACR,MAAA,EAAY,OAChB,MAAA,GAAa,QAAQ,CACrB,MAAA,EAAc,IAAA,IAGhB,GAAU,EAAQ,IAAc,CAC1B,MAAA,GAAe,CAAC,MAAA,EAAY,OAChC,MAAA,EAAc,KAAK,MAAM,eACjB,CACJ,MAAA,EAAc,IAAA,GACd,IAAM,EAAM,KAAK,MAAM,KAAK,CAC5B,IAAK,GAAM,CAAC,EAAK,KAAW,MAAA,EACtB,GAAO,EAAO,WAAW,MAAA,EAAY,OAAO,EAAI,CACtD,MAAA,GAAgB,EAElB,KAAK,IAAI,EAAO,IAAO,CACxB,CACD,MAAA,EAAY,SAAS,EAGvB,MAAe,YAA4B,CACzC,MAAA,EAAY,OAAO,CACnB,MAAA,GAAY"}
package/dist/cache.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { Cn as WaitUntilFn, Sn as CacheSetOptions, Tn as WithCacheOptions, bn as CacheDriver, wn as CacheInvalidationOptions, xn as CacheEntry, zt as OfficialCacheExtension } from "./index-Ci8b13Lm.mjs";
1
+ import { Cn as CacheSetOptions, En as WithCacheOptions, Sn as CacheEntry, Tn as CacheInvalidationOptions, wn as WaitUntilFn, xn as CacheDriver, zt as OfficialCacheExtension } from "./index-DRX_LLQM.mjs";
2
2
 
3
3
  //#region src/cache/extension.d.ts
4
4
  interface CacheExtensionConfig {
package/dist/cache.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import{n as e}from"./chunk-BuuaeEvq.mjs";import{a as t,i as n,o as r,s as i}from"./value-guards-CK9guf2Z.mjs";import{A as a,F as o,I as s,M as c,O as l,T as u,a as d,c as f,l as p,t as m,v as h,w as g}from"./rows-YyvK9MDz.mjs";import{b as _}from"./base-D3m1S7Uc.mjs";import{i as v,t as y}from"./cache-CIPRF-pz.mjs";import{C as b,Mt as x,N as S,h as C,r as w,y as T}from"./geo-point-codec-pAWYj5ZZ.mjs";import{i as E,o as D}from"./key-CyLRw0ne.mjs";import{i as O}from"./builder-BxCr9ANq.mjs";import{t as k}from"./invariant-D_fIjY_z.mjs";import{t as A}from"./validation-CjWRiLWU.mjs";import{t as j}from"./sha256-_Nu4s32f.mjs";import{a as M,i as N,n as P,o as F,r as I,s as L,t as R}from"./driver-BqD-3_jO.mjs";const z=new Set([`findFirst`,`findMany`,`findUnique`,`findUniqueOrThrow`,`findFirstOrThrow`,`count`,`aggregate`,`groupBy`,`exist`]),B=new WeakMap;function admitMutationCacheOptions(e){let t=A(F,e);if(t.issues)throw new y(`Invalid mutation cache options: ${t.issues.map(e=>e.message).join(`, `)}`,{cause:x(t)});let n=t.value.invalidate===void 0?void 0:[...t.value.invalidate];n&&Object.freeze(n);let r=Object.freeze({autoInvalidate:t.value.autoInvalidate,...n===void 0?{}:{invalidate:n}});return B.set(r,r),r}function readMutationCacheOptions(e){let t=e?.cache;return r(t)?B.get(t):void 0}function cacheKeyOf(e,t,n){if(t===void 0)return e;if(Object.values(t).every(h)){if(n===void 0)return[e,t];try{return[e,t,n.map(rowsIdentity)]}catch{return}}}function prepareMutationCacheWriteOutcome(e,t,n,r,i,a){if(g(n))return Object.freeze({extension:`viborm.cache`,failurePolicy:`boundary-owned`,listener:async o=>{try{await N(e,t,r,i,a)}catch(e){throw new y(`Cache invalidation failed after mutation '${n}' on model '${t}'.`,{cause:_(e),meta:{method:`invalidate`,model:t,operation:n,commitCertainty:o.certainty}})}}})}function validateCacheableOperation(e){if(!z.has(e))throw new v(e,[...z])}function createCacheExecutionOptions(e,t,n){let r=A(L,e);if(r.issues)throw new y(`Invalid cache options: ${r.issues.map(e=>e.message).join(`, `)}`,{cause:x(r)});let{bypass:i,key:a,ttl:o,swr:s}=r.value;return{ttlMs:o,swr:resolveSwr(s,o),bypass:i,key:a,waitUntil:t,driverIdentity:n}}function executeCachedResultOperation(e,t,n,r,i,a,o,s){return I(e,t,n,r,i,a,o,s)}async function invalidateManualCache(e,t,n,r){let i=[...t];await N(e,`manual`,Object.freeze({invalidate:i}),n,r)}function resolveSwr(e,t){return e===void 0||e===!1?!1:e===!0?t*2:t+e}const V=new WeakMap;function settledRows(e){let t=Object.values(e.verbs??{}).some(e=>typeof e!=`function`&&typeof e.acyclic==`object`&&!Array.isArray(e.acyclic));if(!(d(e)||t))return e;let n=V.get(e);if(n)return n;let r=Object.fromEntries(Object.entries(e.verbs).map(([e,t])=>{let n=typeof t==`function`?t():t,r=n.acyclic;return[e,r===void 0||Array.isArray(r)?n:Object.freeze({...n,acyclic:r.resolve()})]})),i=Object.fromEntries(Object.entries(e.models).map(([e,t])=>[e,Object.fromEntries(Object.entries(t).map(([e,t])=>[e,Object.fromEntries(Object.entries(t).map(([e,t])=>[e,typeof t==`function`?t():t]))]))])),a=Object.freeze({...e,models:i,verbs:r});return V.set(e,a),a}const H=new WeakMap;function rowsIdentity(e){let t=m(e),n=H.get(t);if(n!==void 0)return n;let r=settledRows(t);if(!(f(t)&&Object.values(r.verbs??{}).every(e=>p(e))))return r;let i=j(new TextEncoder().encode(D(r))),a=Array.from(i,e=>e.toString(16).padStart(2,`0`)).join(``);return H.set(t,a),a}var CacheSnapshotFailure=class extends Error{};function failCacheSnapshot(){throw new CacheSnapshotFailure}function readSnapshotArray(e){if(!Array.isArray(e)||Object.getPrototypeOf(e)!==Array.prototype)return failCacheSnapshot();let t=Reflect.ownKeys(e),n=Reflect.getOwnPropertyDescriptor(e,`length`)?.value;if(typeof n!=`number`||!Number.isSafeInteger(n)||n<0||t.length!==n+1||t[n]!==`length`)return failCacheSnapshot();let r=Array(n);for(let i=0;i<n;i+=1){let n=String(i);if(t[i]!==n)return failCacheSnapshot();let a=Reflect.getOwnPropertyDescriptor(e,n);if(!(a&&`value`in a&&a.enumerable))return failCacheSnapshot();r[i]=a.value}return r}function readSnapshotRecord(e,t=!1){if(typeof e!=`object`||!e||Array.isArray(e))return failCacheSnapshot();let n=Object.getPrototypeOf(e);if(n!==Object.prototype&&!(t&&n===null))return failCacheSnapshot();let r=Reflect.ownKeys(e),i=Array(r.length);for(let t=0;t<r.length;t+=1){let n=r[t];if(typeof n!=`string`)return failCacheSnapshot();let a=Reflect.getOwnPropertyDescriptor(e,n);if(!(a&&`value`in a&&a.enumerable))return failCacheSnapshot();i[t]=[n,a.value]}return i}function defineSnapshotProperty(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0})}function enterSnapshotObject(e,t){e.has(t)&&failCacheSnapshot(),e.add(t)}function withSnapshotObject(e,t,n){enterSnapshotObject(e,t);try{return n()}finally{e.delete(t)}}function encodeSnapshotNumber(e){return typeof e!=`number`||!Number.isFinite(e)?failCacheSnapshot():Object.is(e,-0)?`-0`:String(e)}function decodeSnapshotNumber(e){if(typeof e!=`string`)return failCacheSnapshot();let t=Number(e);return!Number.isFinite(t)||encodeSnapshotNumber(t)!==e?failCacheSnapshot():t}function encodeSnapshotCount(e){return typeof e!=`number`||!Number.isSafeInteger(e)||e<0?failCacheSnapshot():String(e)}function decodeSnapshotCount(e){let t=decodeSnapshotNumber(e);return!Number.isSafeInteger(t)||t<0?failCacheSnapshot():t}const U=`null`,W=`string`,G=`boolean`,K=`number`,q=`array`,J=`object`;function snapshotJsonValue(e,t){return e===null?[U]:typeof e==`string`?[W,e]:typeof e==`boolean`?[G,e]:typeof e==`number`?[K,encodeSnapshotNumber(e)]:Array.isArray(e)?withSnapshotObject(t,e,()=>[q,readSnapshotArray(e).map(e=>snapshotJsonValue(e,t))]):typeof e==`object`&&e?withSnapshotObject(t,e,()=>[J,readSnapshotRecord(e,!0).map(([e,n])=>[e,snapshotJsonValue(n,t)])]):failCacheSnapshot()}function materializeJsonValue(e,t){return typeof e!=`object`||!e?failCacheSnapshot():withSnapshotObject(t,e,()=>{let n=readSnapshotArray(e),r=n[0];return r===U&&n.length===1?null:r===W&&n.length===2&&typeof n[1]==`string`||r===G&&n.length===2&&typeof n[1]==`boolean`?n[1]:r===K&&n.length===2?decodeSnapshotNumber(n[1]):r===q&&n.length===2?materializeJsonArray(n[1],t):r===J&&n.length===2?materializeJsonObject(n[1],t):failCacheSnapshot()})}function materializeJsonArray(e,t){return typeof e!=`object`||!e?failCacheSnapshot():withSnapshotObject(t,e,()=>readSnapshotArray(e).map(e=>materializeJsonValue(e,t)))}function materializeJsonObject(e,t){return typeof e!=`object`||!e?failCacheSnapshot():withSnapshotObject(t,e,()=>{let n=readSnapshotArray(e),r={},i=new Set;for(let e of n){if(typeof e!=`object`||!e)return failCacheSnapshot();let n=withSnapshotObject(t,e,()=>readSnapshotArray(e)),a=n[0];if(n.length!==2||typeof a!=`string`||i.has(a))return failCacheSnapshot();i.add(a),defineSnapshotProperty(r,a,materializeJsonValue(n[1],t))}return r})}const Y=/^(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d{1,3})?$/;function compileScalarCodec(e,t=!0){let n;if(`enumValues`in e)n=enumCodec(new Set(e.enumValues));else{let t=e[`~`].state;switch(t.type){case`string`:n=stringCodec();break;case`time`:n=timeCodec();break;case`int`:n=integerCodec();break;case`number`:n=numberCodec();break;case`decimal`:n=decimalCodec(t.decimal);break;case`boolean`:n=booleanCodec();break;case`bigint`:n=bigintCodec();break;case`datetime`:n=dateCodec(!1);break;case`date`:n=dateCodec(!0);break;case`json`:n=jsonCodec();break;case`vector`:n=vectorCodec(t.dimension);break;case`blob`:n=bytesCodec();break;case`point`:n=pointCodec();break}}let r=e[`~`].state,i=r.array?arrayCodec(n):n;return t&&r.nullable?nullableCodec(i):i}function taggedRelationCodec(e){return{snapshot(t,n){return typeof t!=`object`||!t?failCacheSnapshot():withSnapshotObject(n,t,()=>{let r=readSnapshotRecord(t);if(r.length!==2)return failCacheSnapshot();let i,a;for(let[e,t]of r)if(e===`type`&&typeof t==`string`)i=t;else if(e===`data`)a=t;else return failCacheSnapshot();let o=i===void 0?void 0:e.get(i);return!o||a==null?failCacheSnapshot():r.map(([e,t])=>[e,e===`type`?i:o.snapshot(t,n)])})},materialize(t,n){return materializeArray(t,n,t=>{if(t.length!==2)return failCacheSnapshot();let r=readEncodedEntries(t,n),i,a;for(let[e,t]of r)if(e===`type`&&typeof t==`string`)i=t;else if(e===`data`)a=t;else return failCacheSnapshot();let o=i===void 0?void 0:e.get(i);if(!o||a==null)return failCacheSnapshot();let s={};for(let[e]of r)defineSnapshotProperty(s,e,e===`type`?i:o.materialize(a,n));return s})}}}function recordCodec(e){return{snapshot(t,n){return typeof t!=`object`||!t?failCacheSnapshot():withSnapshotObject(n,t,()=>{let r=readSnapshotRecord(t);if(r.length!==e.size)return failCacheSnapshot();let i=new Set;return r.map(([t,r])=>{let a=e.get(t);return!a||i.has(t)?failCacheSnapshot():(i.add(t),[t,a.snapshot(r,n)])})})},materialize(t,n){return materializeArray(t,n,t=>{if(t.length!==e.size)return failCacheSnapshot();let r=readEncodedEntries(t,n),i=new Set,a={};for(let[t,o]of r){let r=e.get(t);if(!r||i.has(t))return failCacheSnapshot();i.add(t),defineSnapshotProperty(a,t,r.materialize(o,n))}return a})}}}function arrayCodec(e){return{snapshot(t,n){return Array.isArray(t)?withSnapshotObject(n,t,()=>readSnapshotArray(t).map(t=>e.snapshot(t,n))):failCacheSnapshot()},materialize(t,n){return materializeArray(t,n,t=>t.map(t=>e.materialize(t,n)))}}}function nullableCodec(e){return{snapshot(t,n){return t===null?null:e.snapshot(t,n)},materialize(t,n){return t===null?null:e.materialize(t,n)}}}function recursiveRelationCodec(e,t){return{snapshot:(n,r)=>walkRecursiveSlot(n,r,e,{read(n){let i={},a=[];for(let[t,r]of readSnapshotRecord(n))t===e.relation?a.push(r):defineSnapshotProperty(i,t,r);return[t.snapshot(i,r),a]},write:(e,t)=>[e,...t]}),materialize:(n,r)=>walkRecursiveSlot(n,r,e,{read(e){let[n,...i]=readSnapshotArray(e);return[t.materialize(n,r),i]},write(t,n){return n.length>0&&defineSnapshotProperty(t,e.relation,n[0]),t}})}}function walkRecursiveSlot(e,t,n,r){let open=(e,t,r,i)=>{let a;return a=n.many?readSnapshotArray(e):e===null?n.optional?[]:failCacheSnapshot():[e],{level:t,occurrences:a,outputs:[],owner:r,node:i,next:0}},i=[open(e,1)],a;for(;i.length>0;){let e=i.at(-1);if(e.next<e.occurrences.length){let a=e.occurrences[e.next];if(e.next+=1,typeof a!=`object`||!a)return failCacheSnapshot();enterSnapshotObject(t,a);let o=O(n.depth,e.level),[s,c]=r.read(a);if(c.length!==(o?1:0))return failCacheSnapshot();if(o){i.push(open(c[0],e.level+1,a,s));continue}t.delete(a),e.outputs.push(r.write(s,c));continue}i.pop();let o=n.many?e.outputs:e.outputs[0]??null;if(e.owner===void 0){a=o;continue}let s=i.at(-1);t.delete(e.owner),s.outputs.push(r.write(e.node,[o]))}return a}function booleanCodec(){return primitiveCodec(e=>typeof e==`boolean`?e:failCacheSnapshot(),e=>typeof e==`boolean`?e:failCacheSnapshot())}function numberCodec(){return primitiveCodec(encodeSnapshotNumber,decodeSnapshotNumber)}function countCodec(){return primitiveCodec(encodeSnapshotCount,decodeSnapshotCount)}function readEncodedEntries(e,t){let n=Array(e.length);for(let r=0;r<e.length;r+=1)n[r]=materializeArray(e[r],t,e=>e.length!==2||typeof e[0]!=`string`?failCacheSnapshot():[e[0],e[1]]);return n}function stringCodec(){return primitiveCodec(e=>typeof e==`string`?e:failCacheSnapshot(),e=>typeof e==`string`?e:failCacheSnapshot())}function timeCodec(){return primitiveCodec(e=>typeof e==`string`&&Y.test(e)?e:failCacheSnapshot(),e=>typeof e==`string`&&Y.test(e)?e:failCacheSnapshot())}function enumCodec(e){return primitiveCodec(t=>typeof t==`string`&&e.has(t)?t:failCacheSnapshot(),t=>typeof t==`string`&&e.has(t)?t:failCacheSnapshot())}function integerCodec(){return primitiveCodec(e=>typeof e!=`number`||!Number.isSafeInteger(e)?failCacheSnapshot():encodeSnapshotNumber(e),e=>{let t=decodeSnapshotNumber(e);return Number.isSafeInteger(t)?t:failCacheSnapshot()})}function decimalCodec(e){return primitiveCodec(t=>e?T(C(t),e)??failCacheSnapshot():failCacheSnapshot(),t=>{if(!e)return failCacheSnapshot();let n=T(t,e);return n!==void 0&&n===t?S(n):failCacheSnapshot()})}const X=new Map([[`Infinity`,1/0],[`-Infinity`,-1/0]]);function compileWidenedSumCodec(e){let{type:t}=e[`~`].state;if(t===`bigint`)return bigintCodec();if(t===`number`||t===`int`)return primitiveCodec(e=>e===1/0||e===-1/0?String(e):encodeSnapshotNumber(e),e=>X.get(e)??decodeSnapshotNumber(e));let n=e[`~`].state.decimal;return primitiveCodec(e=>n?b(C(e),n.scale)??failCacheSnapshot():failCacheSnapshot(),e=>{if(!n)return failCacheSnapshot();let t=b(e,n.scale);return t!==void 0&&t===e?S(t):failCacheSnapshot()})}function bigintCodec(){return primitiveCodec(e=>typeof e==`bigint`?e.toString():failCacheSnapshot(),e=>{if(typeof e!=`string`)return failCacheSnapshot();try{let t=BigInt(e);return t.toString()===e?t:failCacheSnapshot()}catch{return failCacheSnapshot()}})}function dateCodec(e){return primitiveCodec(t=>{if(!(t instanceof Date)||Object.getPrototypeOf(t)!==Date.prototype||Reflect.ownKeys(t).length!==0)return failCacheSnapshot();let n=Date.prototype.getTime.call(t);if(!Number.isFinite(n))return failCacheSnapshot();let r=Date.prototype.toISOString.call(t);return e&&!r.endsWith(`T00:00:00.000Z`)?failCacheSnapshot():r},t=>{if(typeof t!=`string`)return failCacheSnapshot();let n=new Date(t);return!Number.isFinite(n.getTime())||n.toISOString()!==t||e&&!t.endsWith(`T00:00:00.000Z`)?failCacheSnapshot():n})}function jsonCodec(){return{snapshot:snapshotJsonValue,materialize:materializeJsonValue}}function vectorCodec(e){return{snapshot(t,n){return Array.isArray(t)?withSnapshotObject(n,t,()=>{let n=readSnapshotArray(t);return e!==void 0&&n.length!==e?failCacheSnapshot():n.map(encodeSnapshotNumber)}):failCacheSnapshot()},materialize(t,n){return materializeArray(t,n,t=>e!==void 0&&t.length!==e?failCacheSnapshot():t.map(decodeSnapshotNumber))}}}function bytesCodec(){return{snapshot(e){if(!(e instanceof Uint8Array)||Object.getPrototypeOf(e)!==Uint8Array.prototype||Reflect.ownKeys(e).length!==e.byteLength)return failCacheSnapshot();let t=Array(e.byteLength);for(let n=0;n<e.byteLength;n+=1)t[n]=e[n];return t},materialize(e){let t=readSnapshotArray(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e+=1){let r=t[e];if(typeof r!=`number`||!Number.isInteger(r)||r<0||r>255)return failCacheSnapshot();n[e]=r}return n}}}function pointCodec(){let e=recordCodec(new Map([[`longitude`,numberCodec()],[`latitude`,numberCodec()]]));return{snapshot(t,n){let r=w(t);return r.issues?failCacheSnapshot():e.snapshot(r.value,n)},materialize(t,n){let r=w(e.materialize(t,n));return r.issues?failCacheSnapshot():r.value}}}function primitiveCodec(e,t){return{snapshot:e,materialize:t}}function materializeArray(e,t,n){return typeof e!=`object`||!e?failCacheSnapshot():withSnapshotObject(t,e,()=>n(readSnapshotArray(e)))}function cacheCodec(e,t){let n=shapeCodec(e.value,t),r=e.empty===null?nullableCodec(n):n;return Object.freeze({snapshot(e){try{return r.snapshot(e,new WeakSet)}catch(e){throw new y(`The operation result cannot be represented by the cache result codec.`,{cause:e instanceof Error?e:void 0,meta:{method:`snapshot`,operation:t}})}},materialize(e){try{return r.materialize(e,new WeakSet)}catch(e){throw new y(`The cached result snapshot is malformed.`,{cause:e instanceof Error?e:void 0,meta:{method:`materialize`,operation:t}})}}})}function shapeCodec(e,t){switch(e.kind){case`scalar`:return leafCodec(e,t);case`object`:{let n=new Map;for(let[r,i]of Object.entries(e.fields))n.set(r,shapeCodec(i,t));let r=recordCodec(n);return e.nullable===!1?r:nullableCodec(r)}case`collection`:return arrayCodec(shapeCodec(e.row,t));case`variants`:{let n=new Map;for(let[r,i]of Object.entries(e.arms))n.set(r,shapeCodec(e.many&&i.kind===`collection`?i.row:i,t));let r=taggedRelationCodec(n);return e.many?arrayCodec(r):nullableCodec(r)}case`recursive`:return recursiveRelationCodec({relation:e.relation,many:e.many,optional:e.optional,depth:e.recurrence.depth},shapeCodec(e.row,t))}}function leafCodec(e,t){let n=e.scalar,r;if(n)r=e.widened?compileWidenedSumCodec(n):compileScalarCodec(n,!1);else if(e.type===`boolean`)r=booleanCodec();else if(e.type===`int`)r=countCodec();else if(e.type===`number`)r=numberCodec();else throw new k(`Cannot cache a '${e.type}' result for '${t}': its scalar declaration is missing.`);return e.nullable?nullableCodec(r):r}function bindChain(e,t){let n=l(e);n!==void 0&&s(e,Object.freeze({driver:n.driver,version:n.version,waitUntil:n.waitUntil,scope:P(E({version:n.version,dialect:t.dialect,namespace:t.adapter.namespace}))}))}const Z=Object.freeze({admitMutationCacheOptions,bindChain,cacheCodec,cacheKeyOf,createCacheExecutionOptions,executeCachedResultOperation,invalidateManualCache,prepareMutationCacheWriteOutcome,readCacheExecutionOutcomes:M,readMutationCacheOptions,validateCacheableOperation});a(Z);function configurationError(e,t){throw new y(e,{cause:t===void 0?void 0:_(t)})}function isCacheDriver(e){try{return e instanceof R}catch(e){configurationError(`Cache extension driver capability could not be inspected.`,e)}}function snapshotConfig(e){r(e)||configurationError(`Cache extension configuration must be an object.`);let a;try{a=Reflect.ownKeys(e)}catch(e){configurationError(`Cache extension configuration could not be inspected.`,e)}for(let e of a)(typeof e!=`string`||e!==`driver`&&e!==`version`&&e!==`waitUntil`)&&configurationError(`Cache extension configuration has unknown member "${String(e)}".`);let read=t=>{if(a.includes(t))try{return e[t]}catch(e){configurationError(`Cache extension configuration member "${t}" could not be read.`,e)}},o=read(`driver`),s=read(`version`),c=read(`waitUntil`);return isCacheDriver(o)||configurationError(`Cache extension configuration requires a CacheDriver instance.`),s!==void 0&&!(i(s)||t(s)&&Number.isFinite(s))&&configurationError(`Cache extension configuration "version" must be a string or finite number.`),c!==void 0&&!n(c)&&configurationError(`Cache extension configuration "waitUntil" must be a function.`),Object.freeze({driver:o,version:s,waitUntil:c})}function cache(e){let t=snapshotConfig(e),query=({proceed:e})=>e();return o(query,t,Z),Object.freeze({name:u,query,controls:c})}export{R as CacheDriver,cache};
1
+ import{n as e}from"./chunk-BuuaeEvq.mjs";import{a as t,i as n,o as r,s as i}from"./value-guards-CK9guf2Z.mjs";import{A as a,F as o,I as s,M as c,O as l,T as u,a as d,c as f,l as p,t as m,v as h,w as g}from"./rows-D7ns2l0U.mjs";import{b as _}from"./base-wlv81COV.mjs";import{g as v,p as y}from"./observation-BcT8Cs3d.mjs";import{C as b,Mt as x,N as S,h as C,r as w,y as T}from"./geo-point-codec-mjROsQX-.mjs";import{i as E,o as D}from"./key-rszcmZdB.mjs";import{i as O}from"./builder-D0GQK-fA.mjs";import{t as k}from"./invariant-B5znICP_.mjs";import{t as A}from"./validation-u-sZDdfD.mjs";import{t as j}from"./sha256-Da07rzvR.mjs";import{a as M,i as N,n as P,o as F,r as I,s as L,t as R}from"./driver-Dv2GJyGs.mjs";const z=new Set([`findFirst`,`findMany`,`findUnique`,`findUniqueOrThrow`,`findFirstOrThrow`,`count`,`aggregate`,`groupBy`,`exist`]),B=new WeakMap;function admitMutationCacheOptions(e){let t=A(F,e);if(t.issues)throw new y(`Invalid mutation cache options: ${t.issues.map(e=>e.message).join(`, `)}`,{cause:x(t)});let n=t.value.invalidate===void 0?void 0:[...t.value.invalidate];n&&Object.freeze(n);let r=Object.freeze({autoInvalidate:t.value.autoInvalidate,...n===void 0?{}:{invalidate:n}});return B.set(r,r),r}function readMutationCacheOptions(e){let t=e?.cache;return r(t)?B.get(t):void 0}function cacheKeyOf(e,t,n){if(t===void 0)return e;if(Object.values(t).every(h)){if(n===void 0)return[e,t];try{return[e,t,n.map(rowsIdentity)]}catch{return}}}function prepareMutationCacheWriteOutcome(e,t,n,r,i,a){if(g(n))return Object.freeze({extension:`viborm.cache`,failurePolicy:`boundary-owned`,listener:async o=>{try{await N(e,t,r,i,a)}catch(e){throw new y(`Cache invalidation failed after mutation '${n}' on model '${t}'.`,{cause:_(e),meta:{method:`invalidate`,model:t,operation:n,commitCertainty:o.certainty}})}}})}function validateCacheableOperation(e){if(!z.has(e))throw new v(e,[...z])}function createCacheExecutionOptions(e,t,n){let r=A(L,e);if(r.issues)throw new y(`Invalid cache options: ${r.issues.map(e=>e.message).join(`, `)}`,{cause:x(r)});let{bypass:i,key:a,ttl:o,swr:s}=r.value;return{ttlMs:o,swr:resolveSwr(s,o),bypass:i,key:a,waitUntil:t,driverIdentity:n}}function executeCachedResultOperation(e,t,n,r,i,a,o,s){return I(e,t,n,r,i,a,o,s)}async function invalidateManualCache(e,t,n,r){let i=[...t];await N(e,`manual`,Object.freeze({invalidate:i}),n,r)}function resolveSwr(e,t){return e===void 0||e===!1?!1:e===!0?t*2:t+e}const V=new WeakMap;function settledRows(e){let t=Object.values(e.verbs??{}).some(e=>typeof e!=`function`&&typeof e.acyclic==`object`&&!Array.isArray(e.acyclic));if(!(d(e)||t))return e;let n=V.get(e);if(n)return n;let r=Object.fromEntries(Object.entries(e.verbs).map(([e,t])=>{let n=typeof t==`function`?t():t,r=n.acyclic;return[e,r===void 0||Array.isArray(r)?n:Object.freeze({...n,acyclic:r.resolve()})]})),i=Object.fromEntries(Object.entries(e.models).map(([e,t])=>[e,Object.fromEntries(Object.entries(t).map(([e,t])=>[e,Object.fromEntries(Object.entries(t).map(([e,t])=>[e,typeof t==`function`?t():t]))]))])),a=Object.freeze({...e,models:i,verbs:r});return V.set(e,a),a}const H=new WeakMap;function rowsIdentity(e){let t=m(e),n=H.get(t);if(n!==void 0)return n;let r=settledRows(t);if(!(f(t)&&Object.values(r.verbs??{}).every(e=>p(e))))return r;let i=j(new TextEncoder().encode(D(r))),a=Array.from(i,e=>e.toString(16).padStart(2,`0`)).join(``);return H.set(t,a),a}var CacheSnapshotFailure=class extends Error{};function failCacheSnapshot(){throw new CacheSnapshotFailure}function readSnapshotArray(e){if(!Array.isArray(e)||Object.getPrototypeOf(e)!==Array.prototype)return failCacheSnapshot();let t=Reflect.ownKeys(e),n=Reflect.getOwnPropertyDescriptor(e,`length`)?.value;if(typeof n!=`number`||!Number.isSafeInteger(n)||n<0||t.length!==n+1||t[n]!==`length`)return failCacheSnapshot();let r=Array(n);for(let i=0;i<n;i+=1){let n=String(i);if(t[i]!==n)return failCacheSnapshot();let a=Reflect.getOwnPropertyDescriptor(e,n);if(!(a&&`value`in a&&a.enumerable))return failCacheSnapshot();r[i]=a.value}return r}function readSnapshotRecord(e,t=!1){if(typeof e!=`object`||!e||Array.isArray(e))return failCacheSnapshot();let n=Object.getPrototypeOf(e);if(n!==Object.prototype&&!(t&&n===null))return failCacheSnapshot();let r=Reflect.ownKeys(e),i=Array(r.length);for(let t=0;t<r.length;t+=1){let n=r[t];if(typeof n!=`string`)return failCacheSnapshot();let a=Reflect.getOwnPropertyDescriptor(e,n);if(!(a&&`value`in a&&a.enumerable))return failCacheSnapshot();i[t]=[n,a.value]}return i}function defineSnapshotProperty(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0})}function enterSnapshotObject(e,t){e.has(t)&&failCacheSnapshot(),e.add(t)}function withSnapshotObject(e,t,n){enterSnapshotObject(e,t);try{return n()}finally{e.delete(t)}}function encodeSnapshotNumber(e){return typeof e!=`number`||!Number.isFinite(e)?failCacheSnapshot():Object.is(e,-0)?`-0`:String(e)}function decodeSnapshotNumber(e){if(typeof e!=`string`)return failCacheSnapshot();let t=Number(e);return!Number.isFinite(t)||encodeSnapshotNumber(t)!==e?failCacheSnapshot():t}function encodeSnapshotCount(e){return typeof e!=`number`||!Number.isSafeInteger(e)||e<0?failCacheSnapshot():String(e)}function decodeSnapshotCount(e){let t=decodeSnapshotNumber(e);return!Number.isSafeInteger(t)||t<0?failCacheSnapshot():t}const U=`null`,W=`string`,G=`boolean`,K=`number`,q=`array`,J=`object`;function snapshotJsonValue(e,t){return e===null?[U]:typeof e==`string`?[W,e]:typeof e==`boolean`?[G,e]:typeof e==`number`?[K,encodeSnapshotNumber(e)]:Array.isArray(e)?withSnapshotObject(t,e,()=>[q,readSnapshotArray(e).map(e=>snapshotJsonValue(e,t))]):typeof e==`object`&&e?withSnapshotObject(t,e,()=>[J,readSnapshotRecord(e,!0).map(([e,n])=>[e,snapshotJsonValue(n,t)])]):failCacheSnapshot()}function materializeJsonValue(e,t){return typeof e!=`object`||!e?failCacheSnapshot():withSnapshotObject(t,e,()=>{let n=readSnapshotArray(e),r=n[0];return r===U&&n.length===1?null:r===W&&n.length===2&&typeof n[1]==`string`||r===G&&n.length===2&&typeof n[1]==`boolean`?n[1]:r===K&&n.length===2?decodeSnapshotNumber(n[1]):r===q&&n.length===2?materializeJsonArray(n[1],t):r===J&&n.length===2?materializeJsonObject(n[1],t):failCacheSnapshot()})}function materializeJsonArray(e,t){return typeof e!=`object`||!e?failCacheSnapshot():withSnapshotObject(t,e,()=>readSnapshotArray(e).map(e=>materializeJsonValue(e,t)))}function materializeJsonObject(e,t){return typeof e!=`object`||!e?failCacheSnapshot():withSnapshotObject(t,e,()=>{let n=readSnapshotArray(e),r={},i=new Set;for(let e of n){if(typeof e!=`object`||!e)return failCacheSnapshot();let n=withSnapshotObject(t,e,()=>readSnapshotArray(e)),a=n[0];if(n.length!==2||typeof a!=`string`||i.has(a))return failCacheSnapshot();i.add(a),defineSnapshotProperty(r,a,materializeJsonValue(n[1],t))}return r})}const Y=/^(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d{1,3})?$/;function compileScalarCodec(e,t=!0){let n;if(`enumValues`in e)n=enumCodec(new Set(e.enumValues));else{let t=e[`~`].state;switch(t.type){case`string`:n=stringCodec();break;case`time`:n=timeCodec();break;case`int`:n=integerCodec();break;case`number`:n=numberCodec();break;case`decimal`:n=decimalCodec(t.decimal);break;case`boolean`:n=booleanCodec();break;case`bigint`:n=bigintCodec();break;case`datetime`:n=dateCodec(!1);break;case`date`:n=dateCodec(!0);break;case`json`:n=jsonCodec();break;case`vector`:n=vectorCodec(t.dimension);break;case`blob`:n=bytesCodec();break;case`point`:n=pointCodec();break}}let r=e[`~`].state,i=r.array?arrayCodec(n):n;return t&&r.nullable?nullableCodec(i):i}function taggedRelationCodec(e){return{snapshot(t,n){return typeof t!=`object`||!t?failCacheSnapshot():withSnapshotObject(n,t,()=>{let r=readSnapshotRecord(t);if(r.length!==2)return failCacheSnapshot();let i,a;for(let[e,t]of r)if(e===`type`&&typeof t==`string`)i=t;else if(e===`data`)a=t;else return failCacheSnapshot();let o=i===void 0?void 0:e.get(i);return!o||a==null?failCacheSnapshot():r.map(([e,t])=>[e,e===`type`?i:o.snapshot(t,n)])})},materialize(t,n){return materializeArray(t,n,t=>{if(t.length!==2)return failCacheSnapshot();let r=readEncodedEntries(t,n),i,a;for(let[e,t]of r)if(e===`type`&&typeof t==`string`)i=t;else if(e===`data`)a=t;else return failCacheSnapshot();let o=i===void 0?void 0:e.get(i);if(!o||a==null)return failCacheSnapshot();let s={};for(let[e]of r)defineSnapshotProperty(s,e,e===`type`?i:o.materialize(a,n));return s})}}}function recordCodec(e){return{snapshot(t,n){return typeof t!=`object`||!t?failCacheSnapshot():withSnapshotObject(n,t,()=>{let r=readSnapshotRecord(t);if(r.length!==e.size)return failCacheSnapshot();let i=new Set;return r.map(([t,r])=>{let a=e.get(t);return!a||i.has(t)?failCacheSnapshot():(i.add(t),[t,a.snapshot(r,n)])})})},materialize(t,n){return materializeArray(t,n,t=>{if(t.length!==e.size)return failCacheSnapshot();let r=readEncodedEntries(t,n),i=new Set,a={};for(let[t,o]of r){let r=e.get(t);if(!r||i.has(t))return failCacheSnapshot();i.add(t),defineSnapshotProperty(a,t,r.materialize(o,n))}return a})}}}function arrayCodec(e){return{snapshot(t,n){return Array.isArray(t)?withSnapshotObject(n,t,()=>readSnapshotArray(t).map(t=>e.snapshot(t,n))):failCacheSnapshot()},materialize(t,n){return materializeArray(t,n,t=>t.map(t=>e.materialize(t,n)))}}}function nullableCodec(e){return{snapshot(t,n){return t===null?null:e.snapshot(t,n)},materialize(t,n){return t===null?null:e.materialize(t,n)}}}function recursiveRelationCodec(e,t){return{snapshot:(n,r)=>walkRecursiveSlot(n,r,e,{read(n){let i={},a=[];for(let[t,r]of readSnapshotRecord(n))t===e.relation?a.push(r):defineSnapshotProperty(i,t,r);return[t.snapshot(i,r),a]},write:(e,t)=>[e,...t]}),materialize:(n,r)=>walkRecursiveSlot(n,r,e,{read(e){let[n,...i]=readSnapshotArray(e);return[t.materialize(n,r),i]},write(t,n){return n.length>0&&defineSnapshotProperty(t,e.relation,n[0]),t}})}}function walkRecursiveSlot(e,t,n,r){let open=(e,t,r,i)=>{let a;return a=n.many?readSnapshotArray(e):e===null?n.optional?[]:failCacheSnapshot():[e],{level:t,occurrences:a,outputs:[],owner:r,node:i,next:0}},i=[open(e,1)],a;for(;i.length>0;){let e=i.at(-1);if(e.next<e.occurrences.length){let a=e.occurrences[e.next];if(e.next+=1,typeof a!=`object`||!a)return failCacheSnapshot();enterSnapshotObject(t,a);let o=O(n.depth,e.level),[s,c]=r.read(a);if(c.length!==(o?1:0))return failCacheSnapshot();if(o){i.push(open(c[0],e.level+1,a,s));continue}t.delete(a),e.outputs.push(r.write(s,c));continue}i.pop();let o=n.many?e.outputs:e.outputs[0]??null;if(e.owner===void 0){a=o;continue}let s=i.at(-1);t.delete(e.owner),s.outputs.push(r.write(e.node,[o]))}return a}function booleanCodec(){return primitiveCodec(e=>typeof e==`boolean`?e:failCacheSnapshot(),e=>typeof e==`boolean`?e:failCacheSnapshot())}function numberCodec(){return primitiveCodec(encodeSnapshotNumber,decodeSnapshotNumber)}function countCodec(){return primitiveCodec(encodeSnapshotCount,decodeSnapshotCount)}function readEncodedEntries(e,t){let n=Array(e.length);for(let r=0;r<e.length;r+=1)n[r]=materializeArray(e[r],t,e=>e.length!==2||typeof e[0]!=`string`?failCacheSnapshot():[e[0],e[1]]);return n}function stringCodec(){return primitiveCodec(e=>typeof e==`string`?e:failCacheSnapshot(),e=>typeof e==`string`?e:failCacheSnapshot())}function timeCodec(){return primitiveCodec(e=>typeof e==`string`&&Y.test(e)?e:failCacheSnapshot(),e=>typeof e==`string`&&Y.test(e)?e:failCacheSnapshot())}function enumCodec(e){return primitiveCodec(t=>typeof t==`string`&&e.has(t)?t:failCacheSnapshot(),t=>typeof t==`string`&&e.has(t)?t:failCacheSnapshot())}function integerCodec(){return primitiveCodec(e=>typeof e!=`number`||!Number.isSafeInteger(e)?failCacheSnapshot():encodeSnapshotNumber(e),e=>{let t=decodeSnapshotNumber(e);return Number.isSafeInteger(t)?t:failCacheSnapshot()})}function decimalCodec(e){return primitiveCodec(t=>e?T(C(t),e)??failCacheSnapshot():failCacheSnapshot(),t=>{if(!e)return failCacheSnapshot();let n=T(t,e);return n!==void 0&&n===t?S(n):failCacheSnapshot()})}const X=new Map([[`Infinity`,1/0],[`-Infinity`,-1/0]]);function compileWidenedSumCodec(e){let{type:t}=e[`~`].state;if(t===`bigint`)return bigintCodec();if(t===`number`||t===`int`)return primitiveCodec(e=>e===1/0||e===-1/0?String(e):encodeSnapshotNumber(e),e=>X.get(e)??decodeSnapshotNumber(e));let n=e[`~`].state.decimal;return primitiveCodec(e=>n?b(C(e),n.scale)??failCacheSnapshot():failCacheSnapshot(),e=>{if(!n)return failCacheSnapshot();let t=b(e,n.scale);return t!==void 0&&t===e?S(t):failCacheSnapshot()})}function bigintCodec(){return primitiveCodec(e=>typeof e==`bigint`?e.toString():failCacheSnapshot(),e=>{if(typeof e!=`string`)return failCacheSnapshot();try{let t=BigInt(e);return t.toString()===e?t:failCacheSnapshot()}catch{return failCacheSnapshot()}})}function dateCodec(e){return primitiveCodec(t=>{if(!(t instanceof Date)||Object.getPrototypeOf(t)!==Date.prototype||Reflect.ownKeys(t).length!==0)return failCacheSnapshot();let n=Date.prototype.getTime.call(t);if(!Number.isFinite(n))return failCacheSnapshot();let r=Date.prototype.toISOString.call(t);return e&&!r.endsWith(`T00:00:00.000Z`)?failCacheSnapshot():r},t=>{if(typeof t!=`string`)return failCacheSnapshot();let n=new Date(t);return!Number.isFinite(n.getTime())||n.toISOString()!==t||e&&!t.endsWith(`T00:00:00.000Z`)?failCacheSnapshot():n})}function jsonCodec(){return{snapshot:snapshotJsonValue,materialize:materializeJsonValue}}function vectorCodec(e){return{snapshot(t,n){return Array.isArray(t)?withSnapshotObject(n,t,()=>{let n=readSnapshotArray(t);return e!==void 0&&n.length!==e?failCacheSnapshot():n.map(encodeSnapshotNumber)}):failCacheSnapshot()},materialize(t,n){return materializeArray(t,n,t=>e!==void 0&&t.length!==e?failCacheSnapshot():t.map(decodeSnapshotNumber))}}}function bytesCodec(){return{snapshot(e){if(!(e instanceof Uint8Array)||Object.getPrototypeOf(e)!==Uint8Array.prototype||Reflect.ownKeys(e).length!==e.byteLength)return failCacheSnapshot();let t=Array(e.byteLength);for(let n=0;n<e.byteLength;n+=1)t[n]=e[n];return t},materialize(e){let t=readSnapshotArray(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e+=1){let r=t[e];if(typeof r!=`number`||!Number.isInteger(r)||r<0||r>255)return failCacheSnapshot();n[e]=r}return n}}}function pointCodec(){let e=recordCodec(new Map([[`longitude`,numberCodec()],[`latitude`,numberCodec()]]));return{snapshot(t,n){let r=w(t);return r.issues?failCacheSnapshot():e.snapshot(r.value,n)},materialize(t,n){let r=w(e.materialize(t,n));return r.issues?failCacheSnapshot():r.value}}}function primitiveCodec(e,t){return{snapshot:e,materialize:t}}function materializeArray(e,t,n){return typeof e!=`object`||!e?failCacheSnapshot():withSnapshotObject(t,e,()=>n(readSnapshotArray(e)))}function cacheCodec(e,t){let n=shapeCodec(e.value,t),r=e.empty===null?nullableCodec(n):n;return Object.freeze({snapshot(e){try{return r.snapshot(e,new WeakSet)}catch(e){throw new y(`The operation result cannot be represented by the cache result codec.`,{cause:e instanceof Error?e:void 0,meta:{method:`snapshot`,operation:t}})}},materialize(e){try{return r.materialize(e,new WeakSet)}catch(e){throw new y(`The cached result snapshot is malformed.`,{cause:e instanceof Error?e:void 0,meta:{method:`materialize`,operation:t}})}}})}function shapeCodec(e,t){switch(e.kind){case`scalar`:return leafCodec(e,t);case`object`:{let n=new Map;for(let[r,i]of Object.entries(e.fields))n.set(r,shapeCodec(i,t));let r=recordCodec(n);return e.nullable===!1?r:nullableCodec(r)}case`collection`:return arrayCodec(shapeCodec(e.row,t));case`variants`:{let n=new Map;for(let[r,i]of Object.entries(e.arms))n.set(r,shapeCodec(e.many&&i.kind===`collection`?i.row:i,t));let r=taggedRelationCodec(n);return e.many?arrayCodec(r):nullableCodec(r)}case`recursive`:return recursiveRelationCodec({relation:e.relation,many:e.many,optional:e.optional,depth:e.recurrence.depth},shapeCodec(e.row,t))}}function leafCodec(e,t){let n=e.scalar,r;if(n)r=e.widened?compileWidenedSumCodec(n):compileScalarCodec(n,!1);else if(e.type===`boolean`)r=booleanCodec();else if(e.type===`int`)r=countCodec();else if(e.type===`number`)r=numberCodec();else throw new k(`Cannot cache a '${e.type}' result for '${t}': its scalar declaration is missing.`);return e.nullable?nullableCodec(r):r}function bindChain(e,t){let n=l(e);n!==void 0&&s(e,Object.freeze({driver:n.driver,version:n.version,waitUntil:n.waitUntil,scope:P(E({version:n.version,dialect:t.dialect,namespace:t.adapter.namespace}))}))}const Z=Object.freeze({admitMutationCacheOptions,bindChain,cacheCodec,cacheKeyOf,createCacheExecutionOptions,executeCachedResultOperation,invalidateManualCache,prepareMutationCacheWriteOutcome,readCacheExecutionOutcomes:M,readMutationCacheOptions,validateCacheableOperation});a(Z);function configurationError(e,t){throw new y(e,{cause:t===void 0?void 0:_(t)})}function isCacheDriver(e){try{return e instanceof R}catch(e){configurationError(`Cache extension driver capability could not be inspected.`,e)}}function snapshotConfig(e){r(e)||configurationError(`Cache extension configuration must be an object.`);let a;try{a=Reflect.ownKeys(e)}catch(e){configurationError(`Cache extension configuration could not be inspected.`,e)}for(let e of a)(typeof e!=`string`||e!==`driver`&&e!==`version`&&e!==`waitUntil`)&&configurationError(`Cache extension configuration has unknown member "${String(e)}".`);let read=t=>{if(a.includes(t))try{return e[t]}catch(e){configurationError(`Cache extension configuration member "${t}" could not be read.`,e)}},o=read(`driver`),s=read(`version`),c=read(`waitUntil`);return isCacheDriver(o)||configurationError(`Cache extension configuration requires a CacheDriver instance.`),s!==void 0&&!(i(s)||t(s)&&Number.isFinite(s))&&configurationError(`Cache extension configuration "version" must be a string or finite number.`),c!==void 0&&!n(c)&&configurationError(`Cache extension configuration "waitUntil" must be a function.`),Object.freeze({driver:o,version:s,waitUntil:c})}function cache(e){let t=snapshotConfig(e),query=({proceed:e})=>e();return o(query,t,Z),Object.freeze({name:u,query,controls:c})}export{R as CacheDriver,cache};
2
2
  //# sourceMappingURL=cache.mjs.map