appos 0.3.5-0 → 0.3.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 (281) hide show
  1. package/dist/bin/main.mjs +2 -2
  2. package/dist/exports/api/adapter-C2mMJKvG.mjs +1504 -0
  3. package/dist/exports/api/{auth-schema.mjs → auth-schema-CON4yFFY.mjs} +2 -3
  4. package/dist/exports/api/bun-sqlite-dialect-CPpPZa23.mjs +155 -0
  5. package/dist/exports/{cli/_virtual/rolldown_runtime.mjs → api/chunk-CyXqrcp_.mjs} +14 -1
  6. package/dist/exports/api/conditions-DjBAWfiK.mjs +116 -0
  7. package/dist/exports/api/dialect-CUUD24Ge.mjs +72 -0
  8. package/dist/exports/api/env-CwT3zhez.mjs +1 -0
  9. package/dist/exports/api/esm-_hkVMulx.mjs +15816 -0
  10. package/dist/exports/api/event-BHFSE6hY.mjs +20983 -0
  11. package/dist/exports/api/extract-blob-metadata-BMgUEPcW.mjs +4 -0
  12. package/dist/exports/api/extract-blob-metadata-_9RUEwoU.mjs +9818 -0
  13. package/dist/exports/api/generate-image-variant-DOIzj1wJ.mjs +4 -0
  14. package/dist/exports/api/generate-image-variant-DxOPoGAk.mjs +118 -0
  15. package/dist/exports/api/generate-preview-CvTFuq58.mjs +160 -0
  16. package/dist/exports/api/generate-preview-Dk3coswZ.mjs +4 -0
  17. package/dist/exports/api/index.d.mts +7347 -20
  18. package/dist/exports/api/index.mjs +146856 -18
  19. package/dist/exports/api/kysely-adapter-CmP2TbkS.mjs +296 -0
  20. package/dist/exports/api/memory-adapter-BzhRhLFK.mjs +212 -0
  21. package/dist/exports/api/node-sqlite-dialect-Bl5suBxl.mjs +155 -0
  22. package/dist/exports/api/orm-CMqufD21.mjs +153690 -0
  23. package/dist/exports/api/orm-DXqYuKvB.d.mts +11 -0
  24. package/dist/exports/api/orm.d.mts +2 -11
  25. package/dist/exports/api/orm.mjs +4 -42
  26. package/dist/exports/api/pdf-YxB2Hm1p.mjs +25822 -0
  27. package/dist/exports/api/purge-attachment-Cf6KH2Jv.mjs +34 -0
  28. package/dist/exports/api/purge-attachment-DIuil7ps.mjs +4 -0
  29. package/dist/exports/{cli/api/workflows/purge-audit-logs.mjs → api/purge-audit-logs-z6j_Pu47.mjs} +3 -3
  30. package/dist/exports/{cli/api/workflows/purge-unattached-blobs.mjs → api/purge-unattached-blobs-B0TfY5Hk.mjs} +1 -1
  31. package/dist/exports/api/react-BYhV5bYt.mjs +1131 -0
  32. package/dist/exports/api/server.node-DyVrQ6cz.mjs +19298 -0
  33. package/dist/exports/api/table-6bTIEqON.mjs +2636 -0
  34. package/dist/exports/api/{workflows/track-db-changes.mjs → track-db-changes-BysaV6nN.mjs} +14 -14
  35. package/dist/exports/api/{workflow.mjs → workflow-BuSWHcX-.mjs} +121 -10
  36. package/dist/exports/api/workflows/auth-schema-BFve3hgZ.mjs +2813 -0
  37. package/dist/exports/api/{_virtual/rolldown_runtime.mjs → workflows/chunk-B36mNPO4.mjs} +5 -1
  38. package/dist/exports/api/workflows/extract-blob-metadata-BcWKvY2K.mjs +9818 -0
  39. package/dist/exports/api/workflows/{generate-image-variant.mjs → generate-image-variant-BAFvL_zV.mjs} +20 -20
  40. package/dist/exports/{cli/api/workflows/generate-preview.mjs → api/workflows/generate-preview-BjlIVYYp.mjs} +6 -6
  41. package/dist/exports/api/workflows/index.d.mts +2011 -1
  42. package/dist/exports/api/workflows/index.mjs +2 -1
  43. package/dist/exports/api/workflows/pdf-DUB8zyIc.mjs +25822 -0
  44. package/dist/exports/{cli/api/workflows/purge-attachment.mjs → api/workflows/purge-attachment-k_sdxTPY.mjs} +3 -3
  45. package/dist/exports/api/workflows/{purge-audit-logs.mjs → purge-audit-logs-zCyWj4Mw.mjs} +12 -3
  46. package/dist/exports/api/workflows/{purge-unattached-blobs.mjs → purge-unattached-blobs-CdsuFAeW.mjs} +1 -1
  47. package/dist/exports/api/workflows/track-db-changes-CiKaI9gT.mjs +20943 -0
  48. package/dist/exports/api/workflows/track-db-changes-DEWQYryO.mjs +4 -0
  49. package/dist/exports/{cli/api/workflow.mjs → api/workflows/workflow-BjM2xCa6.mjs} +23 -3
  50. package/dist/exports/api/workflows/zod-Br0enFWK.mjs +12333 -0
  51. package/dist/exports/api/zod-CdrJdBtV.mjs +12571 -0
  52. package/dist/exports/cli/auth-schema-CNuOqPi-.mjs +2813 -0
  53. package/dist/exports/{api/workflows/_virtual/rolldown_runtime.mjs → cli/chunk-B36mNPO4.mjs} +5 -1
  54. package/dist/exports/cli/extract-blob-metadata-CV1Ke90d.mjs +9818 -0
  55. package/dist/exports/cli/{api/workflows/generate-image-variant.mjs → generate-image-variant-CM1BrVvZ.mjs} +20 -20
  56. package/dist/exports/{api/workflows/generate-preview.mjs → cli/generate-preview-DdHQ3ukz.mjs} +6 -6
  57. package/dist/exports/cli/index.d.mts +2142 -2
  58. package/dist/exports/cli/index.mjs +41 -1
  59. package/dist/exports/cli/pdf-CLUPEIdT.mjs +25822 -0
  60. package/dist/exports/{api/workflows/purge-attachment.mjs → cli/purge-attachment-Dc_J74dG.mjs} +3 -3
  61. package/dist/exports/cli/purge-audit-logs-DFhWh-Bx.mjs +56 -0
  62. package/dist/exports/cli/purge-unattached-blobs-C1MRlM_2.mjs +46 -0
  63. package/dist/exports/cli/track-db-changes-CfneOF2_.mjs +20943 -0
  64. package/dist/exports/{api/workflows/api/workflow.mjs → cli/workflow-DSbbXBMt.mjs} +23 -3
  65. package/dist/exports/cli/zod-7q0_Mtnn.mjs +12333 -0
  66. package/dist/exports/devtools/BaseTanStackRouterDevtoolsPanel-BBz1qLry-DUwdvyLv.js +2090 -0
  67. package/dist/exports/devtools/EIDV623S-B7f6114d.js +2497 -0
  68. package/dist/exports/devtools/FloatingTanStackRouterDevtools-DymJEvfG-BHuQHiRR.js +237 -0
  69. package/dist/exports/devtools/MIMHJGAX-Cb3wf11F.js +10903 -0
  70. package/dist/exports/devtools/Q7LWSL4U-BoEO3rNq.js +37 -0
  71. package/dist/exports/devtools/VLTTJS3N-CIyRc84e.js +44 -0
  72. package/dist/exports/devtools/index.js +1724 -3
  73. package/dist/exports/devtools/utils-YRTCpRgb.js +1670 -0
  74. package/dist/exports/tests/api.d.mts +7354 -5
  75. package/dist/exports/tests/api.mjs +79 -1
  76. package/dist/exports/tests/auth-schema-DUCJw-_2.mjs +1 -0
  77. package/dist/exports/tests/chunk-Cii4FAhs.mjs +1 -0
  78. package/dist/exports/tests/conditions-B0ffVJ5E.mjs +1 -0
  79. package/dist/exports/tests/constants-DHjjg05J.mjs +1 -0
  80. package/dist/exports/tests/dist-D6vgKv3t.mjs +7 -0
  81. package/dist/exports/tests/dist-EfrRkq5c.mjs +296 -0
  82. package/dist/exports/tests/extract-blob-metadata-Dv343Vcn.mjs +169 -0
  83. package/dist/exports/tests/generate-image-variant-cQc8q0kh.mjs +1 -0
  84. package/dist/exports/tests/generate-preview-HaTMd2hS.mjs +1 -0
  85. package/dist/exports/tests/magic-string.es-D6VRmdiF.mjs +14 -0
  86. package/dist/exports/tests/mock-BvkO5nlm.mjs +1 -0
  87. package/dist/exports/tests/mock.mjs +1 -1
  88. package/dist/exports/tests/pdf-BDsS3vjF.mjs +13 -0
  89. package/dist/exports/tests/purge-attachment-D4uOzHRi.mjs +1 -0
  90. package/dist/exports/tests/purge-audit-logs-DiPcc09d.mjs +1 -0
  91. package/dist/exports/tests/purge-unattached-blobs-CqW6tlIC.mjs +1 -0
  92. package/dist/exports/tests/react.mjs +6 -1
  93. package/dist/exports/tests/setup.d.mts +1 -1
  94. package/dist/exports/tests/setup.mjs +34 -1
  95. package/dist/exports/tests/table-CbU04119.mjs +1 -0
  96. package/dist/exports/tests/track-db-changes-Bd4W-P1q.mjs +1 -0
  97. package/dist/exports/tests/vi.2VT5v0um-Cme1b0Dl.mjs +348 -0
  98. package/dist/exports/tests/{api/workflow.mjs → workflow-DwZxTqdH.mjs} +1 -1
  99. package/dist/exports/tests/zod-DcpxsMPz.mjs +23 -0
  100. package/dist/exports/vendors/date.js +13236 -1
  101. package/dist/exports/vendors/toolkit.js +2206 -1
  102. package/dist/exports/vendors/zod.js +12344 -1
  103. package/dist/exports/vite/api-DGRU_RdM.mjs +27 -0
  104. package/dist/exports/vite/build-CxJAu2Bn.mjs +1 -0
  105. package/dist/exports/vite/build2-BMK0OFVt.mjs +16 -0
  106. package/dist/exports/vite/chunk-CxnlK1Zi.mjs +1 -0
  107. package/dist/exports/vite/chunk-PtveFMYu.mjs +1 -0
  108. package/dist/exports/vite/dist-Bxp8DqWh.mjs +114 -0
  109. package/dist/exports/vite/dist-CX51FKbX.mjs +1 -0
  110. package/dist/exports/vite/dist-DcyNr-KR.mjs +1 -0
  111. package/dist/exports/vite/dist-j3-Khlzt.mjs +1 -0
  112. package/dist/exports/vite/experimental-index-3KsfmUbz.mjs +1 -0
  113. package/dist/exports/vite/false-BNJbUKYT.mjs +1 -0
  114. package/dist/exports/vite/false-BvrPEDU6.mjs +1 -0
  115. package/dist/exports/vite/index.d.mts +1 -1
  116. package/dist/exports/vite/index.mjs +26 -1
  117. package/dist/exports/vite/internal-C5cVwRiK.mjs +1 -0
  118. package/dist/exports/vite/jiti-BjSPrFvg.mjs +9 -0
  119. package/dist/exports/vite/lexer-DQCqS3nf-C6xCDOEQ.mjs +3 -0
  120. package/dist/exports/vite/lib-CMv7Sfwa.mjs +1 -0
  121. package/dist/exports/vite/lib-D9TnS-7w.mjs +1 -0
  122. package/dist/exports/vite/lib-DuBRr9dH.mjs +382 -0
  123. package/dist/exports/vite/node-DI8AnY_i.mjs +437 -0
  124. package/dist/exports/vite/postcss-BtmDpj-c.mjs +32 -0
  125. package/dist/exports/vite/postcss-import-Bk_ZCd6c.mjs +5 -0
  126. package/dist/exports/vite/rolldown-build-CNW2eye_-CJNfyXdF.mjs +13 -0
  127. package/dist/exports/vitest/api-CPv6lnxG.mjs +27 -0
  128. package/dist/exports/vitest/build2-28i3OiJ3.mjs +16 -0
  129. package/dist/exports/vitest/chunk-_e2jlDPK.mjs +1 -0
  130. package/dist/exports/vitest/chunk-jwDkFoXW.mjs +1 -0
  131. package/dist/exports/vitest/config.mjs +77 -1
  132. package/dist/exports/vitest/dist-L-OpshPJ.mjs +114 -0
  133. package/dist/exports/vitest/index.mjs +348 -1
  134. package/dist/exports/vitest/jiti-eNGOyHIo.mjs +9 -0
  135. package/dist/exports/vitest/lexer-DQCqS3nf-TWLyIqlY.mjs +3 -0
  136. package/dist/exports/vitest/lib-C3G64csm.mjs +1 -0
  137. package/dist/exports/vitest/magic-string.es-CxM5Ubyl.mjs +14 -0
  138. package/dist/exports/vitest/module-runner-DsF4L04D.mjs +1 -0
  139. package/dist/exports/vitest/postcss-BxLp_Too.mjs +32 -0
  140. package/dist/exports/vitest/postcss-import-5pKj3f5q.mjs +5 -0
  141. package/dist/exports/web/browser-ponyfill-DxTJMXNq.js +443 -0
  142. package/dist/exports/web/chunk-DksrlJLg.js +49 -0
  143. package/dist/exports/web/index.d.ts +2546 -2
  144. package/dist/exports/web/index.js +9295 -6
  145. package/dist/exports/web/plugin-DqTFWG7p.js +250 -0
  146. package/package.json +1 -1
  147. package/dist/exports/api/app-context.d.mts +0 -115
  148. package/dist/exports/api/app-context.mjs +0 -24
  149. package/dist/exports/api/auth-schema.d.mts +0 -4248
  150. package/dist/exports/api/auth.d.mts +0 -402
  151. package/dist/exports/api/auth.mjs +0 -188
  152. package/dist/exports/api/cache.d.mts +0 -44
  153. package/dist/exports/api/cache.mjs +0 -28
  154. package/dist/exports/api/config.d.mts +0 -28
  155. package/dist/exports/api/config.mjs +0 -72
  156. package/dist/exports/api/constants.mjs +0 -92
  157. package/dist/exports/api/container.d.mts +0 -210
  158. package/dist/exports/api/container.mjs +0 -49
  159. package/dist/exports/api/database.d.mts +0 -101
  160. package/dist/exports/api/database.mjs +0 -219
  161. package/dist/exports/api/event.d.mts +0 -235
  162. package/dist/exports/api/event.mjs +0 -236
  163. package/dist/exports/api/i18n.d.mts +0 -34
  164. package/dist/exports/api/i18n.mjs +0 -45
  165. package/dist/exports/api/instrumentation.d.mts +0 -7
  166. package/dist/exports/api/instrumentation.mjs +0 -40
  167. package/dist/exports/api/logger.d.mts +0 -21
  168. package/dist/exports/api/logger.mjs +0 -26
  169. package/dist/exports/api/mailer.d.mts +0 -70
  170. package/dist/exports/api/mailer.mjs +0 -37
  171. package/dist/exports/api/middleware/request-logger.d.mts +0 -24
  172. package/dist/exports/api/middleware.d.mts +0 -39
  173. package/dist/exports/api/middleware.mjs +0 -73
  174. package/dist/exports/api/openapi.d.mts +0 -271
  175. package/dist/exports/api/openapi.mjs +0 -507
  176. package/dist/exports/api/otel.d.mts +0 -40
  177. package/dist/exports/api/otel.mjs +0 -56
  178. package/dist/exports/api/redis.d.mts +0 -34
  179. package/dist/exports/api/redis.mjs +0 -41
  180. package/dist/exports/api/storage-schema.d.mts +0 -707
  181. package/dist/exports/api/storage-schema.mjs +0 -72
  182. package/dist/exports/api/storage.d.mts +0 -506
  183. package/dist/exports/api/storage.mjs +0 -833
  184. package/dist/exports/api/web/auth.mjs +0 -17
  185. package/dist/exports/api/workflow.d.mts +0 -250
  186. package/dist/exports/api/workflows/api/auth-schema.mjs +0 -373
  187. package/dist/exports/api/workflows/api/auth.d.mts +0 -379
  188. package/dist/exports/api/workflows/api/cache.d.mts +0 -44
  189. package/dist/exports/api/workflows/api/config.d.mts +0 -18
  190. package/dist/exports/api/workflows/api/container.d.mts +0 -167
  191. package/dist/exports/api/workflows/api/database.d.mts +0 -47
  192. package/dist/exports/api/workflows/api/event.d.mts +0 -68
  193. package/dist/exports/api/workflows/api/event.mjs +0 -126
  194. package/dist/exports/api/workflows/api/logger.d.mts +0 -21
  195. package/dist/exports/api/workflows/api/mailer.d.mts +0 -70
  196. package/dist/exports/api/workflows/api/orm.d.mts +0 -13
  197. package/dist/exports/api/workflows/api/redis.mjs +0 -3
  198. package/dist/exports/api/workflows/api/storage-schema.d.mts +0 -699
  199. package/dist/exports/api/workflows/api/storage.d.mts +0 -396
  200. package/dist/exports/api/workflows/api/workflow.d.mts +0 -24
  201. package/dist/exports/api/workflows/constants.mjs +0 -23
  202. package/dist/exports/api/workflows/extract-blob-metadata.mjs +0 -132
  203. package/dist/exports/api/workflows/generate-image-variant.d.mts +0 -63
  204. package/dist/exports/api/workflows/track-db-changes.d.mts +0 -72
  205. package/dist/exports/cli/api/auth-schema.mjs +0 -373
  206. package/dist/exports/cli/api/auth.d.mts +0 -379
  207. package/dist/exports/cli/api/cache.d.mts +0 -44
  208. package/dist/exports/cli/api/config.d.mts +0 -18
  209. package/dist/exports/cli/api/container.d.mts +0 -167
  210. package/dist/exports/cli/api/database.d.mts +0 -47
  211. package/dist/exports/cli/api/event.d.mts +0 -68
  212. package/dist/exports/cli/api/event.mjs +0 -126
  213. package/dist/exports/cli/api/logger.d.mts +0 -21
  214. package/dist/exports/cli/api/mailer.d.mts +0 -70
  215. package/dist/exports/cli/api/orm.d.mts +0 -13
  216. package/dist/exports/cli/api/redis.mjs +0 -3
  217. package/dist/exports/cli/api/storage-schema.d.mts +0 -699
  218. package/dist/exports/cli/api/storage.d.mts +0 -396
  219. package/dist/exports/cli/api/workflow.d.mts +0 -2
  220. package/dist/exports/cli/api/workflows/extract-blob-metadata.mjs +0 -132
  221. package/dist/exports/cli/api/workflows/generate-image-variant.d.mts +0 -63
  222. package/dist/exports/cli/api/workflows/track-db-changes.mjs +0 -110
  223. package/dist/exports/cli/command.d.mts +0 -56
  224. package/dist/exports/cli/command.mjs +0 -43
  225. package/dist/exports/cli/constants.mjs +0 -23
  226. package/dist/exports/cli/context.d.mts +0 -170
  227. package/dist/exports/tests/_virtual/rolldown_runtime.mjs +0 -1
  228. package/dist/exports/tests/api/app-context.d.mts +0 -115
  229. package/dist/exports/tests/api/app-context.mjs +0 -1
  230. package/dist/exports/tests/api/auth-schema.d.mts +0 -4248
  231. package/dist/exports/tests/api/auth-schema.mjs +0 -1
  232. package/dist/exports/tests/api/auth.d.mts +0 -402
  233. package/dist/exports/tests/api/cache.d.mts +0 -44
  234. package/dist/exports/tests/api/config.d.mts +0 -28
  235. package/dist/exports/tests/api/container.d.mts +0 -210
  236. package/dist/exports/tests/api/database.d.mts +0 -101
  237. package/dist/exports/tests/api/database.mjs +0 -1
  238. package/dist/exports/tests/api/event.d.mts +0 -235
  239. package/dist/exports/tests/api/event.mjs +0 -1
  240. package/dist/exports/tests/api/i18n.d.mts +0 -34
  241. package/dist/exports/tests/api/index.d.mts +0 -26
  242. package/dist/exports/tests/api/logger.d.mts +0 -21
  243. package/dist/exports/tests/api/mailer.d.mts +0 -70
  244. package/dist/exports/tests/api/middleware/error-handler.mjs +0 -1
  245. package/dist/exports/tests/api/middleware/health.mjs +0 -1
  246. package/dist/exports/tests/api/middleware/i18n.mjs +0 -1
  247. package/dist/exports/tests/api/middleware/request-logger.d.mts +0 -24
  248. package/dist/exports/tests/api/middleware/request-logger.mjs +0 -1
  249. package/dist/exports/tests/api/middleware/shutdown.mjs +0 -1
  250. package/dist/exports/tests/api/middleware/timeout.mjs +0 -1
  251. package/dist/exports/tests/api/middleware.d.mts +0 -39
  252. package/dist/exports/tests/api/middleware.mjs +0 -1
  253. package/dist/exports/tests/api/openapi.d.mts +0 -271
  254. package/dist/exports/tests/api/openapi.mjs +0 -1
  255. package/dist/exports/tests/api/orm.d.mts +0 -13
  256. package/dist/exports/tests/api/otel.d.mts +0 -40
  257. package/dist/exports/tests/api/redis.d.mts +0 -34
  258. package/dist/exports/tests/api/redis.mjs +0 -1
  259. package/dist/exports/tests/api/server.mjs +0 -1
  260. package/dist/exports/tests/api/storage-schema.d.mts +0 -707
  261. package/dist/exports/tests/api/storage.d.mts +0 -506
  262. package/dist/exports/tests/api/workflow.d.mts +0 -250
  263. package/dist/exports/tests/api/workflows/extract-blob-metadata.mjs +0 -1
  264. package/dist/exports/tests/api/workflows/generate-image-variant.d.mts +0 -63
  265. package/dist/exports/tests/api/workflows/generate-image-variant.mjs +0 -1
  266. package/dist/exports/tests/api/workflows/generate-preview.mjs +0 -1
  267. package/dist/exports/tests/api/workflows/purge-attachment.mjs +0 -1
  268. package/dist/exports/tests/api/workflows/purge-audit-logs.mjs +0 -1
  269. package/dist/exports/tests/api/workflows/purge-unattached-blobs.mjs +0 -1
  270. package/dist/exports/tests/api/workflows/track-db-changes.mjs +0 -1
  271. package/dist/exports/tests/constants.mjs +0 -1
  272. package/dist/exports/tests/instrumentation.d.mts +0 -7
  273. package/dist/exports/tests/instrumentation.mjs +0 -1
  274. package/dist/exports/web/api/auth.d.ts +0 -125
  275. package/dist/exports/web/api/database.d.ts +0 -4
  276. package/dist/exports/web/api/logger.d.ts +0 -1
  277. package/dist/exports/web/auth.d.ts +0 -2388
  278. package/dist/exports/web/auth.js +0 -75
  279. package/dist/exports/web/i18n.d.ts +0 -42
  280. package/dist/exports/web/i18n.js +0 -45
  281. /package/dist/exports/tests/{api/middleware/youch-handler.mjs → youch-handler-Ch5yf6im.mjs} +0 -0
@@ -0,0 +1,296 @@
1
+ import { t as createAdapterFactory } from "./adapter-C2mMJKvG.mjs";
2
+ import { l as sql } from "./esm-_hkVMulx.mjs";
3
+ import { n as getKyselyDatabaseType, t as createKyselyAdapter } from "./dialect-CUUD24Ge.mjs";
4
+
5
+ //#region ../../node_modules/.bun/better-auth@1.4.7+f768ad5b9455517d/node_modules/better-auth/dist/adapters/kysely-adapter/kysely-adapter.mjs
6
+ const kyselyAdapter = (db, config) => {
7
+ let lazyOptions = null;
8
+ const createCustomAdapter = (db$1) => {
9
+ return ({ getFieldName, schema, getDefaultFieldName, getDefaultModelName, getFieldAttributes, getModelName }) => {
10
+ const selectAllJoins = (join) => {
11
+ const allSelects = [];
12
+ const allSelectsStr = [];
13
+ if (join) for (const [joinModel, _] of Object.entries(join)) {
14
+ const fields = schema[getDefaultModelName(joinModel)]?.fields;
15
+ const [_joinModelSchema, joinModelName] = joinModel.includes(".") ? joinModel.split(".") : [void 0, joinModel];
16
+ if (!fields) continue;
17
+ fields.id = { type: "string" };
18
+ for (const [field, fieldAttr] of Object.entries(fields)) {
19
+ allSelects.push(sql`${sql.ref(`join_${joinModelName}`)}.${sql.ref(fieldAttr.fieldName || field)} as ${sql.ref(`_joined_${joinModelName}_${fieldAttr.fieldName || field}`)}`);
20
+ allSelectsStr.push({
21
+ joinModel,
22
+ joinModelRef: joinModelName,
23
+ fieldName: fieldAttr.fieldName || field
24
+ });
25
+ }
26
+ }
27
+ return {
28
+ allSelectsStr,
29
+ allSelects
30
+ };
31
+ };
32
+ const withReturning = async (values, builder, model, where) => {
33
+ let res;
34
+ if (config?.type === "mysql") {
35
+ await builder.execute();
36
+ const field = values.id ? "id" : where.length > 0 && where[0]?.field ? where[0].field : "id";
37
+ if (!values.id && where.length === 0) {
38
+ res = await db$1.selectFrom(model).selectAll().orderBy(getFieldName({
39
+ model,
40
+ field
41
+ }), "desc").limit(1).executeTakeFirst();
42
+ return res;
43
+ }
44
+ const value = values[field] || where[0]?.value;
45
+ res = await db$1.selectFrom(model).selectAll().orderBy(getFieldName({
46
+ model,
47
+ field
48
+ }), "desc").where(getFieldName({
49
+ model,
50
+ field
51
+ }), "=", value).limit(1).executeTakeFirst();
52
+ return res;
53
+ }
54
+ if (config?.type === "mssql") {
55
+ res = await builder.outputAll("inserted").executeTakeFirst();
56
+ return res;
57
+ }
58
+ res = await builder.returningAll().executeTakeFirst();
59
+ return res;
60
+ };
61
+ function convertWhereClause(model, w) {
62
+ if (!w) return {
63
+ and: null,
64
+ or: null
65
+ };
66
+ const conditions = {
67
+ and: [],
68
+ or: []
69
+ };
70
+ w.forEach((condition) => {
71
+ let { field: _field, value: _value, operator = "=", connector = "AND" } = condition;
72
+ let value = _value;
73
+ let field = getFieldName({
74
+ model,
75
+ field: _field
76
+ });
77
+ const expr = (eb) => {
78
+ const f = `${model}.${field}`;
79
+ if (operator.toLowerCase() === "in") return eb(f, "in", Array.isArray(value) ? value : [value]);
80
+ if (operator.toLowerCase() === "not_in") return eb(f, "not in", Array.isArray(value) ? value : [value]);
81
+ if (operator === "contains") return eb(f, "like", `%${value}%`);
82
+ if (operator === "starts_with") return eb(f, "like", `${value}%`);
83
+ if (operator === "ends_with") return eb(f, "like", `%${value}`);
84
+ if (operator === "eq") return eb(f, "=", value);
85
+ if (operator === "ne") return eb(f, "<>", value);
86
+ if (operator === "gt") return eb(f, ">", value);
87
+ if (operator === "gte") return eb(f, ">=", value);
88
+ if (operator === "lt") return eb(f, "<", value);
89
+ if (operator === "lte") return eb(f, "<=", value);
90
+ return eb(f, operator, value);
91
+ };
92
+ if (connector === "OR") conditions.or.push(expr);
93
+ else conditions.and.push(expr);
94
+ });
95
+ return {
96
+ and: conditions.and.length ? conditions.and : null,
97
+ or: conditions.or.length ? conditions.or : null
98
+ };
99
+ }
100
+ function processJoinedResults(rows, joinConfig, allSelectsStr) {
101
+ if (!joinConfig || !rows.length) return rows;
102
+ const groupedByMainId = /* @__PURE__ */ new Map();
103
+ for (const currentRow of rows) {
104
+ const mainModelFields = {};
105
+ const joinedModelFields = {};
106
+ for (const [joinModel] of Object.entries(joinConfig)) joinedModelFields[getModelName(joinModel)] = {};
107
+ for (const [key, value] of Object.entries(currentRow)) {
108
+ const keyStr = String(key);
109
+ let assigned = false;
110
+ for (const { joinModel, fieldName, joinModelRef } of allSelectsStr) if (keyStr === `_joined_${joinModelRef}_${fieldName}`) {
111
+ joinedModelFields[getModelName(joinModel)][getFieldName({
112
+ model: joinModel,
113
+ field: fieldName
114
+ })] = value;
115
+ assigned = true;
116
+ break;
117
+ }
118
+ if (!assigned) mainModelFields[key] = value;
119
+ }
120
+ const mainId = mainModelFields.id;
121
+ if (!mainId) continue;
122
+ if (!groupedByMainId.has(mainId)) {
123
+ const entry$1 = { ...mainModelFields };
124
+ for (const [joinModel, joinAttr] of Object.entries(joinConfig)) entry$1[getModelName(joinModel)] = joinAttr.relation === "one-to-one" ? null : [];
125
+ groupedByMainId.set(mainId, entry$1);
126
+ }
127
+ const entry = groupedByMainId.get(mainId);
128
+ for (const [joinModel, joinAttr] of Object.entries(joinConfig)) {
129
+ const isUnique = joinAttr.relation === "one-to-one";
130
+ const limit = joinAttr.limit ?? 100;
131
+ const joinedObj = joinedModelFields[getModelName(joinModel)];
132
+ const hasData = joinedObj && Object.keys(joinedObj).length > 0 && Object.values(joinedObj).some((value) => value !== null && value !== void 0);
133
+ if (isUnique) entry[getModelName(joinModel)] = hasData ? joinedObj : null;
134
+ else {
135
+ const joinModelName = getModelName(joinModel);
136
+ if (Array.isArray(entry[joinModelName]) && hasData) {
137
+ if (entry[joinModelName].length >= limit) continue;
138
+ const idFieldName = getFieldName({
139
+ model: joinModel,
140
+ field: "id"
141
+ });
142
+ const joinedId = joinedObj[idFieldName];
143
+ if (joinedId) {
144
+ if (!entry[joinModelName].some((item) => item[idFieldName] === joinedId) && entry[joinModelName].length < limit) entry[joinModelName].push(joinedObj);
145
+ } else if (entry[joinModelName].length < limit) entry[joinModelName].push(joinedObj);
146
+ }
147
+ }
148
+ }
149
+ }
150
+ let result = Array.from(groupedByMainId.values());
151
+ for (const entry of result) for (const [joinModel, joinAttr] of Object.entries(joinConfig)) if (joinAttr.relation !== "one-to-one") {
152
+ const joinModelName = getModelName(joinModel);
153
+ if (Array.isArray(entry[joinModelName])) {
154
+ const limit = joinAttr.limit ?? 100;
155
+ if (entry[joinModelName].length > limit) entry[joinModelName] = entry[joinModelName].slice(0, limit);
156
+ }
157
+ }
158
+ return result;
159
+ }
160
+ return {
161
+ async create({ data, model }) {
162
+ return await withReturning(data, db$1.insertInto(model).values(data), model, []);
163
+ },
164
+ async findOne({ model, where, select, join }) {
165
+ const { and, or } = convertWhereClause(model, where);
166
+ let query = db$1.selectFrom((eb) => {
167
+ let b = eb.selectFrom(model);
168
+ if (and) b = b.where((eb$1) => eb$1.and(and.map((expr) => expr(eb$1))));
169
+ if (or) b = b.where((eb$1) => eb$1.or(or.map((expr) => expr(eb$1))));
170
+ return b.selectAll().as("primary");
171
+ }).selectAll("primary");
172
+ if (join) for (const [joinModel, joinAttr] of Object.entries(join)) {
173
+ const [_joinModelSchema, joinModelName] = joinModel.includes(".") ? joinModel.split(".") : [void 0, joinModel];
174
+ query = query.leftJoin(`${joinModel} as join_${joinModelName}`, (join$1) => join$1.onRef(`join_${joinModelName}.${joinAttr.on.to}`, "=", `primary.${joinAttr.on.from}`));
175
+ }
176
+ const { allSelectsStr, allSelects } = selectAllJoins(join);
177
+ query = query.select(allSelects);
178
+ const res = await query.execute();
179
+ if (!res || !Array.isArray(res) || res.length === 0) return null;
180
+ const row = res[0];
181
+ if (join) return processJoinedResults(res, join, allSelectsStr)[0];
182
+ return row;
183
+ },
184
+ async findMany({ model, where, limit, offset, sortBy, join }) {
185
+ const { and, or } = convertWhereClause(model, where);
186
+ let query = db$1.selectFrom((eb) => {
187
+ let b = eb.selectFrom(model);
188
+ if (config?.type === "mssql") {
189
+ if (offset !== void 0) {
190
+ if (!sortBy) b = b.orderBy(getFieldName({
191
+ model,
192
+ field: "id"
193
+ }));
194
+ b = b.offset(offset).fetch(limit || 100);
195
+ } else if (limit !== void 0) b = b.top(limit);
196
+ } else {
197
+ if (limit !== void 0) b = b.limit(limit);
198
+ if (offset !== void 0) b = b.offset(offset);
199
+ }
200
+ if (sortBy?.field) b = b.orderBy(`${getFieldName({
201
+ model,
202
+ field: sortBy.field
203
+ })}`, sortBy.direction);
204
+ if (and) b = b.where((eb$1) => eb$1.and(and.map((expr) => expr(eb$1))));
205
+ if (or) b = b.where((eb$1) => eb$1.or(or.map((expr) => expr(eb$1))));
206
+ return b.selectAll().as("primary");
207
+ }).selectAll("primary");
208
+ if (join) for (const [joinModel, joinAttr] of Object.entries(join)) {
209
+ const [_joinModelSchema, joinModelName] = joinModel.includes(".") ? joinModel.split(".") : [void 0, joinModel];
210
+ query = query.leftJoin(`${joinModel} as join_${joinModelName}`, (join$1) => join$1.onRef(`join_${joinModelName}.${joinAttr.on.to}`, "=", `primary.${joinAttr.on.from}`));
211
+ }
212
+ const { allSelectsStr, allSelects } = selectAllJoins(join);
213
+ query = query.select(allSelects);
214
+ if (sortBy?.field) query = query.orderBy(`${getFieldName({
215
+ model,
216
+ field: sortBy.field
217
+ })}`, sortBy.direction);
218
+ const res = await query.execute();
219
+ if (!res) return [];
220
+ if (join) return processJoinedResults(res, join, allSelectsStr);
221
+ return res;
222
+ },
223
+ async update({ model, where, update: values }) {
224
+ const { and, or } = convertWhereClause(model, where);
225
+ let query = db$1.updateTable(model).set(values);
226
+ if (and) query = query.where((eb) => eb.and(and.map((expr) => expr(eb))));
227
+ if (or) query = query.where((eb) => eb.or(or.map((expr) => expr(eb))));
228
+ return await withReturning(values, query, model, where);
229
+ },
230
+ async updateMany({ model, where, update: values }) {
231
+ const { and, or } = convertWhereClause(model, where);
232
+ let query = db$1.updateTable(model).set(values);
233
+ if (and) query = query.where((eb) => eb.and(and.map((expr) => expr(eb))));
234
+ if (or) query = query.where((eb) => eb.or(or.map((expr) => expr(eb))));
235
+ const res = (await query.executeTakeFirst()).numUpdatedRows;
236
+ return res > Number.MAX_SAFE_INTEGER ? Number.MAX_SAFE_INTEGER : Number(res);
237
+ },
238
+ async count({ model, where }) {
239
+ const { and, or } = convertWhereClause(model, where);
240
+ let query = db$1.selectFrom(model).select(db$1.fn.count("id").as("count"));
241
+ if (and) query = query.where((eb) => eb.and(and.map((expr) => expr(eb))));
242
+ if (or) query = query.where((eb) => eb.or(or.map((expr) => expr(eb))));
243
+ const res = await query.execute();
244
+ if (typeof res[0].count === "number") return res[0].count;
245
+ if (typeof res[0].count === "bigint") return Number(res[0].count);
246
+ return parseInt(res[0].count);
247
+ },
248
+ async delete({ model, where }) {
249
+ const { and, or } = convertWhereClause(model, where);
250
+ let query = db$1.deleteFrom(model);
251
+ if (and) query = query.where((eb) => eb.and(and.map((expr) => expr(eb))));
252
+ if (or) query = query.where((eb) => eb.or(or.map((expr) => expr(eb))));
253
+ await query.execute();
254
+ },
255
+ async deleteMany({ model, where }) {
256
+ const { and, or } = convertWhereClause(model, where);
257
+ let query = db$1.deleteFrom(model);
258
+ if (and) query = query.where((eb) => eb.and(and.map((expr) => expr(eb))));
259
+ if (or) query = query.where((eb) => eb.or(or.map((expr) => expr(eb))));
260
+ const res = (await query.executeTakeFirst()).numDeletedRows;
261
+ return res > Number.MAX_SAFE_INTEGER ? Number.MAX_SAFE_INTEGER : Number(res);
262
+ },
263
+ options: config
264
+ };
265
+ };
266
+ };
267
+ let adapterOptions = null;
268
+ adapterOptions = {
269
+ config: {
270
+ adapterId: "kysely",
271
+ adapterName: "Kysely Adapter",
272
+ usePlural: config?.usePlural,
273
+ debugLogs: config?.debugLogs,
274
+ supportsBooleans: config?.type === "sqlite" || config?.type === "mssql" || config?.type === "mysql" || !config?.type ? false : true,
275
+ supportsDates: config?.type === "sqlite" || config?.type === "mssql" || !config?.type ? false : true,
276
+ supportsJSON: config?.type === "postgres" ? true : false,
277
+ supportsArrays: false,
278
+ supportsUUIDs: config?.type === "postgres" ? true : false,
279
+ transaction: config?.transaction ? (cb) => db.transaction().execute((trx) => {
280
+ return cb(createAdapterFactory({
281
+ config: adapterOptions.config,
282
+ adapter: createCustomAdapter(trx)
283
+ })(lazyOptions));
284
+ }) : false
285
+ },
286
+ adapter: createCustomAdapter(db)
287
+ };
288
+ const adapter = createAdapterFactory(adapterOptions);
289
+ return (options) => {
290
+ lazyOptions = options;
291
+ return adapter(options);
292
+ };
293
+ };
294
+
295
+ //#endregion
296
+ export { createKyselyAdapter, kyselyAdapter };
@@ -0,0 +1,212 @@
1
+ import { t as createAdapterFactory, v as logger } from "./adapter-C2mMJKvG.mjs";
2
+ import "./env-CwT3zhez.mjs";
3
+
4
+ //#region ../../node_modules/.bun/better-auth@1.4.7+f768ad5b9455517d/node_modules/better-auth/dist/adapters/memory-adapter/memory-adapter.mjs
5
+ const memoryAdapter = (db, config) => {
6
+ let lazyOptions = null;
7
+ let adapterCreator = createAdapterFactory({
8
+ config: {
9
+ adapterId: "memory",
10
+ adapterName: "Memory Adapter",
11
+ usePlural: false,
12
+ debugLogs: config?.debugLogs || false,
13
+ customTransformInput(props) {
14
+ if ((props.options.advanced?.database?.useNumberId || props.options.advanced?.database?.generateId === "serial") && props.field === "id" && props.action === "create") return db[props.model].length + 1;
15
+ return props.data;
16
+ },
17
+ transaction: async (cb) => {
18
+ let clone = structuredClone(db);
19
+ try {
20
+ return await cb(adapterCreator(lazyOptions));
21
+ } catch (error) {
22
+ Object.keys(db).forEach((key) => {
23
+ db[key] = clone[key];
24
+ });
25
+ throw error;
26
+ }
27
+ }
28
+ },
29
+ adapter: ({ getFieldName, options, getModelName }) => {
30
+ const applySortToRecords = (records, sortBy, model) => {
31
+ if (!sortBy) return records;
32
+ return records.sort((a, b) => {
33
+ const field = getFieldName({
34
+ model,
35
+ field: sortBy.field
36
+ });
37
+ const aValue = a[field];
38
+ const bValue = b[field];
39
+ let comparison = 0;
40
+ if (aValue == null && bValue == null) comparison = 0;
41
+ else if (aValue == null) comparison = -1;
42
+ else if (bValue == null) comparison = 1;
43
+ else if (typeof aValue === "string" && typeof bValue === "string") comparison = aValue.localeCompare(bValue);
44
+ else if (aValue instanceof Date && bValue instanceof Date) comparison = aValue.getTime() - bValue.getTime();
45
+ else if (typeof aValue === "number" && typeof bValue === "number") comparison = aValue - bValue;
46
+ else if (typeof aValue === "boolean" && typeof bValue === "boolean") comparison = aValue === bValue ? 0 : aValue ? 1 : -1;
47
+ else comparison = String(aValue).localeCompare(String(bValue));
48
+ return sortBy.direction === "asc" ? comparison : -comparison;
49
+ });
50
+ };
51
+ function convertWhereClause(where, model, join) {
52
+ const execute = (where$1, model$1) => {
53
+ const table = db[model$1];
54
+ if (!table) {
55
+ logger.error(`[MemoryAdapter] Model ${model$1} not found in the DB`, Object.keys(db));
56
+ throw new Error(`Model ${model$1} not found`);
57
+ }
58
+ const evalClause = (record, clause) => {
59
+ const { field, value, operator } = clause;
60
+ switch (operator) {
61
+ case "in":
62
+ if (!Array.isArray(value)) throw new Error("Value must be an array");
63
+ return value.includes(record[field]);
64
+ case "not_in":
65
+ if (!Array.isArray(value)) throw new Error("Value must be an array");
66
+ return !value.includes(record[field]);
67
+ case "contains": return record[field].includes(value);
68
+ case "starts_with": return record[field].startsWith(value);
69
+ case "ends_with": return record[field].endsWith(value);
70
+ case "ne": return record[field] !== value;
71
+ case "gt": return value != null && Boolean(record[field] > value);
72
+ case "gte": return value != null && Boolean(record[field] >= value);
73
+ case "lt": return value != null && Boolean(record[field] < value);
74
+ case "lte": return value != null && Boolean(record[field] <= value);
75
+ default: return record[field] === value;
76
+ }
77
+ };
78
+ return table.filter((record) => {
79
+ if (!where$1.length || where$1.length === 0) return true;
80
+ let result = evalClause(record, where$1[0]);
81
+ for (const clause of where$1) {
82
+ const clauseResult = evalClause(record, clause);
83
+ if (clause.connector === "OR") result = result || clauseResult;
84
+ else result = result && clauseResult;
85
+ }
86
+ return result;
87
+ });
88
+ };
89
+ if (!join) return execute(where, model);
90
+ const baseRecords = execute(where, model);
91
+ const grouped = /* @__PURE__ */ new Map();
92
+ const seenIds = /* @__PURE__ */ new Map();
93
+ for (const baseRecord of baseRecords) {
94
+ const baseId = String(baseRecord.id);
95
+ if (!grouped.has(baseId)) {
96
+ const nested = { ...baseRecord };
97
+ for (const [joinModel, joinAttr] of Object.entries(join)) {
98
+ const joinModelName = getModelName(joinModel);
99
+ if (joinAttr.relation === "one-to-one") nested[joinModelName] = null;
100
+ else {
101
+ nested[joinModelName] = [];
102
+ seenIds.set(`${baseId}-${joinModel}`, /* @__PURE__ */ new Set());
103
+ }
104
+ }
105
+ grouped.set(baseId, nested);
106
+ }
107
+ const nestedEntry = grouped.get(baseId);
108
+ for (const [joinModel, joinAttr] of Object.entries(join)) {
109
+ const joinModelName = getModelName(joinModel);
110
+ const joinTable = db[joinModelName];
111
+ if (!joinTable) {
112
+ logger.error(`[MemoryAdapter] JoinOption model ${joinModelName} not found in the DB`, Object.keys(db));
113
+ throw new Error(`JoinOption model ${joinModelName} not found`);
114
+ }
115
+ const matchingRecords = joinTable.filter((joinRecord) => joinRecord[joinAttr.on.to] === baseRecord[joinAttr.on.from]);
116
+ if (joinAttr.relation === "one-to-one") nestedEntry[joinModelName] = matchingRecords[0] || null;
117
+ else {
118
+ const seenSet = seenIds.get(`${baseId}-${joinModel}`);
119
+ const limit = joinAttr.limit ?? 100;
120
+ let count = 0;
121
+ for (const matchingRecord of matchingRecords) {
122
+ if (count >= limit) break;
123
+ if (!seenSet.has(matchingRecord.id)) {
124
+ nestedEntry[joinModelName].push(matchingRecord);
125
+ seenSet.add(matchingRecord.id);
126
+ count++;
127
+ }
128
+ }
129
+ }
130
+ }
131
+ }
132
+ return Array.from(grouped.values());
133
+ }
134
+ return {
135
+ create: async ({ model, data }) => {
136
+ if (options.advanced?.database?.useNumberId || options.advanced?.database?.generateId === "serial") data.id = db[getModelName(model)].length + 1;
137
+ if (!db[model]) db[model] = [];
138
+ db[model].push(data);
139
+ return data;
140
+ },
141
+ findOne: async ({ model, where, join }) => {
142
+ const res = convertWhereClause(where, model, join);
143
+ if (join) {
144
+ const resArray = res;
145
+ if (!resArray.length) return null;
146
+ return resArray[0];
147
+ }
148
+ return res[0] || null;
149
+ },
150
+ findMany: async ({ model, where, sortBy, limit, offset, join }) => {
151
+ let res = convertWhereClause(where || [], model, join);
152
+ if (join) {
153
+ const resArray = res;
154
+ if (!resArray.length) return [];
155
+ applySortToRecords(resArray, sortBy, model);
156
+ let paginatedRecords = resArray;
157
+ if (offset !== void 0) paginatedRecords = paginatedRecords.slice(offset);
158
+ if (limit !== void 0) paginatedRecords = paginatedRecords.slice(0, limit);
159
+ return paginatedRecords;
160
+ }
161
+ let table = applySortToRecords(res, sortBy, model);
162
+ if (offset !== void 0) table = table.slice(offset);
163
+ if (limit !== void 0) table = table.slice(0, limit);
164
+ return table || [];
165
+ },
166
+ count: async ({ model, where }) => {
167
+ if (where) return convertWhereClause(where, model).length;
168
+ return db[model].length;
169
+ },
170
+ update: async ({ model, where, update }) => {
171
+ const res = convertWhereClause(where, model);
172
+ res.forEach((record) => {
173
+ Object.assign(record, update);
174
+ });
175
+ return res[0] || null;
176
+ },
177
+ delete: async ({ model, where }) => {
178
+ const table = db[model];
179
+ const res = convertWhereClause(where, model);
180
+ db[model] = table.filter((record) => !res.includes(record));
181
+ },
182
+ deleteMany: async ({ model, where }) => {
183
+ const table = db[model];
184
+ const res = convertWhereClause(where, model);
185
+ let count = 0;
186
+ db[model] = table.filter((record) => {
187
+ if (res.includes(record)) {
188
+ count++;
189
+ return false;
190
+ }
191
+ return !res.includes(record);
192
+ });
193
+ return count;
194
+ },
195
+ updateMany({ model, where, update }) {
196
+ const res = convertWhereClause(where, model);
197
+ res.forEach((record) => {
198
+ Object.assign(record, update);
199
+ });
200
+ return res[0] || null;
201
+ }
202
+ };
203
+ }
204
+ });
205
+ return (options) => {
206
+ lazyOptions = options;
207
+ return adapterCreator(options);
208
+ };
209
+ };
210
+
211
+ //#endregion
212
+ export { memoryAdapter };
@@ -0,0 +1,155 @@
1
+ import { a as DEFAULT_MIGRATION_LOCK_TABLE, c as DefaultQueryCompiler, l as sql, o as DEFAULT_MIGRATION_TABLE, s as CompiledQuery } from "./esm-_hkVMulx.mjs";
2
+
3
+ //#region ../../node_modules/.bun/better-auth@1.4.7+f768ad5b9455517d/node_modules/better-auth/dist/adapters/kysely-adapter/node-sqlite-dialect.mjs
4
+ var NodeSqliteAdapter = class {
5
+ get supportsCreateIfNotExists() {
6
+ return true;
7
+ }
8
+ get supportsTransactionalDdl() {
9
+ return false;
10
+ }
11
+ get supportsReturning() {
12
+ return true;
13
+ }
14
+ async acquireMigrationLock() {}
15
+ async releaseMigrationLock() {}
16
+ get supportsOutput() {
17
+ return true;
18
+ }
19
+ };
20
+ var NodeSqliteDriver = class {
21
+ #config;
22
+ #connectionMutex = new ConnectionMutex();
23
+ #db;
24
+ #connection;
25
+ constructor(config) {
26
+ this.#config = { ...config };
27
+ }
28
+ async init() {
29
+ this.#db = this.#config.database;
30
+ this.#connection = new NodeSqliteConnection(this.#db);
31
+ if (this.#config.onCreateConnection) await this.#config.onCreateConnection(this.#connection);
32
+ }
33
+ async acquireConnection() {
34
+ await this.#connectionMutex.lock();
35
+ return this.#connection;
36
+ }
37
+ async beginTransaction(connection) {
38
+ await connection.executeQuery(CompiledQuery.raw("begin"));
39
+ }
40
+ async commitTransaction(connection) {
41
+ await connection.executeQuery(CompiledQuery.raw("commit"));
42
+ }
43
+ async rollbackTransaction(connection) {
44
+ await connection.executeQuery(CompiledQuery.raw("rollback"));
45
+ }
46
+ async releaseConnection() {
47
+ this.#connectionMutex.unlock();
48
+ }
49
+ async destroy() {
50
+ this.#db?.close();
51
+ }
52
+ };
53
+ var NodeSqliteConnection = class {
54
+ #db;
55
+ constructor(db) {
56
+ this.#db = db;
57
+ }
58
+ executeQuery(compiledQuery) {
59
+ const { sql: sql$1, parameters } = compiledQuery;
60
+ const rows = this.#db.prepare(sql$1).all(...parameters);
61
+ return Promise.resolve({ rows });
62
+ }
63
+ async *streamQuery() {
64
+ throw new Error("Streaming query is not supported by SQLite driver.");
65
+ }
66
+ };
67
+ var ConnectionMutex = class {
68
+ #promise;
69
+ #resolve;
70
+ async lock() {
71
+ while (this.#promise) await this.#promise;
72
+ this.#promise = new Promise((resolve) => {
73
+ this.#resolve = resolve;
74
+ });
75
+ }
76
+ unlock() {
77
+ const resolve = this.#resolve;
78
+ this.#promise = void 0;
79
+ this.#resolve = void 0;
80
+ resolve?.();
81
+ }
82
+ };
83
+ var NodeSqliteIntrospector = class {
84
+ #db;
85
+ constructor(db) {
86
+ this.#db = db;
87
+ }
88
+ async getSchemas() {
89
+ return [];
90
+ }
91
+ async getTables(options = { withInternalKyselyTables: false }) {
92
+ let query = this.#db.selectFrom("sqlite_schema").where("type", "=", "table").where("name", "not like", "sqlite_%").select("name").$castTo();
93
+ if (!options.withInternalKyselyTables) query = query.where("name", "!=", DEFAULT_MIGRATION_TABLE).where("name", "!=", DEFAULT_MIGRATION_LOCK_TABLE);
94
+ const tables = await query.execute();
95
+ return Promise.all(tables.map(({ name }) => this.#getTableMetadata(name)));
96
+ }
97
+ async getMetadata(options) {
98
+ return { tables: await this.getTables(options) };
99
+ }
100
+ async #getTableMetadata(table) {
101
+ const db = this.#db;
102
+ const autoIncrementCol = (await db.selectFrom("sqlite_master").where("name", "=", table).select("sql").$castTo().execute())[0]?.sql?.split(/[\(\),]/)?.find((it) => it.toLowerCase().includes("autoincrement"))?.split(/\s+/)?.[0]?.replace(/["`]/g, "");
103
+ return {
104
+ name: table,
105
+ columns: (await db.selectFrom(sql`pragma_table_info(${table})`.as("table_info")).select([
106
+ "name",
107
+ "type",
108
+ "notnull",
109
+ "dflt_value"
110
+ ]).execute()).map((col) => ({
111
+ name: col.name,
112
+ dataType: col.type,
113
+ isNullable: !col.notnull,
114
+ isAutoIncrementing: col.name === autoIncrementCol,
115
+ hasDefaultValue: col.dflt_value != null
116
+ })),
117
+ isView: true
118
+ };
119
+ }
120
+ };
121
+ var NodeSqliteQueryCompiler = class extends DefaultQueryCompiler {
122
+ getCurrentParameterPlaceholder() {
123
+ return "?";
124
+ }
125
+ getLeftIdentifierWrapper() {
126
+ return "\"";
127
+ }
128
+ getRightIdentifierWrapper() {
129
+ return "\"";
130
+ }
131
+ getAutoIncrement() {
132
+ return "autoincrement";
133
+ }
134
+ };
135
+ var NodeSqliteDialect = class {
136
+ #config;
137
+ constructor(config) {
138
+ this.#config = { ...config };
139
+ }
140
+ createDriver() {
141
+ return new NodeSqliteDriver(this.#config);
142
+ }
143
+ createQueryCompiler() {
144
+ return new NodeSqliteQueryCompiler();
145
+ }
146
+ createAdapter() {
147
+ return new NodeSqliteAdapter();
148
+ }
149
+ createIntrospector(db) {
150
+ return new NodeSqliteIntrospector(db);
151
+ }
152
+ };
153
+
154
+ //#endregion
155
+ export { NodeSqliteDialect };