@geekmidas/testkit 10.0.0-alpha.99 → 10.0.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 (337) hide show
  1. package/CHANGELOG.md +160 -0
  2. package/README.md +0 -74
  3. package/dist/Factory-BFVnMMCC.mjs +51 -0
  4. package/dist/Factory-BFVnMMCC.mjs.map +1 -0
  5. package/dist/Factory-BOX312yd.d.cts +147 -0
  6. package/dist/Factory-BOX312yd.d.cts.map +1 -0
  7. package/dist/Factory-BhjUOBWN.cjs +57 -0
  8. package/dist/Factory-BhjUOBWN.cjs.map +1 -0
  9. package/dist/Factory-SFupxRC2.d.mts +147 -0
  10. package/dist/Factory-SFupxRC2.d.mts.map +1 -0
  11. package/dist/Factory.cjs +2 -51
  12. package/dist/Factory.d.cts +3 -143
  13. package/dist/Factory.d.mts +3 -143
  14. package/dist/Factory.mjs +2 -50
  15. package/dist/KyselyFactory-BFqVIn_0.cjs +246 -0
  16. package/dist/KyselyFactory-BFqVIn_0.cjs.map +1 -0
  17. package/dist/KyselyFactory-DMswpwji.mjs +241 -0
  18. package/dist/KyselyFactory-DMswpwji.mjs.map +1 -0
  19. package/dist/KyselyFactory-Dy5zzV4B.d.cts +228 -0
  20. package/dist/KyselyFactory-Dy5zzV4B.d.cts.map +1 -0
  21. package/dist/KyselyFactory-vAxYodck.d.mts +228 -0
  22. package/dist/KyselyFactory-vAxYodck.d.mts.map +1 -0
  23. package/dist/KyselyFactory.cjs +4 -237
  24. package/dist/KyselyFactory.d.cts +4 -224
  25. package/dist/KyselyFactory.d.mts +4 -224
  26. package/dist/KyselyFactory.mjs +4 -236
  27. package/dist/ObjectionFactory-BWjB49-i.d.mts +241 -0
  28. package/dist/ObjectionFactory-BWjB49-i.d.mts.map +1 -0
  29. package/dist/ObjectionFactory-BeFBYcan.cjs +272 -0
  30. package/dist/ObjectionFactory-BeFBYcan.cjs.map +1 -0
  31. package/dist/ObjectionFactory-CD-WFuMJ.d.cts +241 -0
  32. package/dist/ObjectionFactory-CD-WFuMJ.d.cts.map +1 -0
  33. package/dist/ObjectionFactory-QCJ7u0Ql.mjs +267 -0
  34. package/dist/ObjectionFactory-QCJ7u0Ql.mjs.map +1 -0
  35. package/dist/ObjectionFactory.cjs +4 -265
  36. package/dist/ObjectionFactory.d.cts +4 -237
  37. package/dist/ObjectionFactory.d.mts +4 -237
  38. package/dist/ObjectionFactory.mjs +4 -264
  39. package/dist/PostgresKyselyMigrator-B2M6Gjvv.d.cts +84 -0
  40. package/dist/PostgresKyselyMigrator-B2M6Gjvv.d.cts.map +1 -0
  41. package/dist/PostgresKyselyMigrator-BGBxjnFv.cjs +101 -0
  42. package/dist/PostgresKyselyMigrator-BGBxjnFv.cjs.map +1 -0
  43. package/dist/PostgresKyselyMigrator-CvwXycJE.d.mts +84 -0
  44. package/dist/PostgresKyselyMigrator-CvwXycJE.d.mts.map +1 -0
  45. package/dist/PostgresKyselyMigrator-PI0QhvB1.mjs +95 -0
  46. package/dist/PostgresKyselyMigrator-PI0QhvB1.mjs.map +1 -0
  47. package/dist/PostgresKyselyMigrator.cjs +3 -94
  48. package/dist/PostgresKyselyMigrator.d.cts +3 -80
  49. package/dist/PostgresKyselyMigrator.d.mts +3 -80
  50. package/dist/PostgresKyselyMigrator.mjs +3 -93
  51. package/dist/{PostgresMigrator-CDPnnwMJ.d.cts → PostgresMigrator-C_QQ6q35.d.mts} +5 -11
  52. package/dist/PostgresMigrator-C_QQ6q35.d.mts.map +1 -0
  53. package/dist/{PostgresMigrator-CDPnnwMJ.d.mts → PostgresMigrator-CeYy-eHF.d.cts} +5 -11
  54. package/dist/PostgresMigrator-CeYy-eHF.d.cts.map +1 -0
  55. package/dist/PostgresMigrator-DVAY04qN.mjs +166 -0
  56. package/dist/PostgresMigrator-DVAY04qN.mjs.map +1 -0
  57. package/dist/PostgresMigrator-M9jpzOvN.cjs +172 -0
  58. package/dist/PostgresMigrator-M9jpzOvN.cjs.map +1 -0
  59. package/dist/PostgresMigrator.cjs +2 -178
  60. package/dist/PostgresMigrator.d.cts +1 -1
  61. package/dist/PostgresMigrator.d.mts +1 -1
  62. package/dist/PostgresMigrator.mjs +2 -175
  63. package/dist/PostgresObjectionMigrator-1j6YIB1c.d.mts +79 -0
  64. package/dist/PostgresObjectionMigrator-1j6YIB1c.d.mts.map +1 -0
  65. package/dist/PostgresObjectionMigrator-DHVC9h_P.d.cts +79 -0
  66. package/dist/PostgresObjectionMigrator-DHVC9h_P.d.cts.map +1 -0
  67. package/dist/PostgresObjectionMigrator-DSaPhwjY.cjs +123 -0
  68. package/dist/PostgresObjectionMigrator-DSaPhwjY.cjs.map +1 -0
  69. package/dist/PostgresObjectionMigrator-DjPKdUbm.mjs +118 -0
  70. package/dist/PostgresObjectionMigrator-DjPKdUbm.mjs.map +1 -0
  71. package/dist/PostgresObjectionMigrator.cjs +3 -118
  72. package/dist/PostgresObjectionMigrator.d.cts +3 -75
  73. package/dist/PostgresObjectionMigrator.d.mts +3 -75
  74. package/dist/PostgresObjectionMigrator.mjs +3 -117
  75. package/dist/VitestKyselyTransactionIsolator-0CqOsuc9.cjs +65 -0
  76. package/dist/VitestKyselyTransactionIsolator-0CqOsuc9.cjs.map +1 -0
  77. package/dist/VitestKyselyTransactionIsolator-CduJlHoT.d.cts +59 -0
  78. package/dist/VitestKyselyTransactionIsolator-CduJlHoT.d.cts.map +1 -0
  79. package/dist/VitestKyselyTransactionIsolator-CfSMOFlN.mjs +60 -0
  80. package/dist/VitestKyselyTransactionIsolator-CfSMOFlN.mjs.map +1 -0
  81. package/dist/VitestKyselyTransactionIsolator-Cswnnj0k.d.mts +59 -0
  82. package/dist/VitestKyselyTransactionIsolator-Cswnnj0k.d.mts.map +1 -0
  83. package/dist/VitestKyselyTransactionIsolator.cjs +3 -66
  84. package/dist/VitestKyselyTransactionIsolator.d.cts +3 -60
  85. package/dist/VitestKyselyTransactionIsolator.d.mts +3 -60
  86. package/dist/VitestKyselyTransactionIsolator.mjs +3 -65
  87. package/dist/VitestObjectionTransactionIsolator-B5J9jjKq.cjs +68 -0
  88. package/dist/VitestObjectionTransactionIsolator-B5J9jjKq.cjs.map +1 -0
  89. package/dist/VitestObjectionTransactionIsolator-BXoR6xdG.d.cts +60 -0
  90. package/dist/VitestObjectionTransactionIsolator-BXoR6xdG.d.cts.map +1 -0
  91. package/dist/VitestObjectionTransactionIsolator-CNo40EdC.mjs +63 -0
  92. package/dist/VitestObjectionTransactionIsolator-CNo40EdC.mjs.map +1 -0
  93. package/dist/VitestObjectionTransactionIsolator-x6hY5j4u.d.mts +60 -0
  94. package/dist/VitestObjectionTransactionIsolator-x6hY5j4u.d.mts.map +1 -0
  95. package/dist/VitestObjectionTransactionIsolator.cjs +3 -62
  96. package/dist/VitestObjectionTransactionIsolator.d.cts +3 -56
  97. package/dist/VitestObjectionTransactionIsolator.d.mts +3 -56
  98. package/dist/VitestObjectionTransactionIsolator.mjs +3 -61
  99. package/dist/VitestTransactionIsolator-BNWJqh9f.d.mts +207 -0
  100. package/dist/VitestTransactionIsolator-BNWJqh9f.d.mts.map +1 -0
  101. package/dist/VitestTransactionIsolator-CSroc7Df.d.cts +207 -0
  102. package/dist/VitestTransactionIsolator-CSroc7Df.d.cts.map +1 -0
  103. package/dist/VitestTransactionIsolator-CtZaOUjH.cjs +193 -0
  104. package/dist/VitestTransactionIsolator-CtZaOUjH.cjs.map +1 -0
  105. package/dist/VitestTransactionIsolator-D6ZxLWys.mjs +175 -0
  106. package/dist/VitestTransactionIsolator-D6ZxLWys.mjs.map +1 -0
  107. package/dist/VitestTransactionIsolator.cjs +4 -187
  108. package/dist/VitestTransactionIsolator.d.cts +2 -219
  109. package/dist/VitestTransactionIsolator.d.mts +2 -219
  110. package/dist/VitestTransactionIsolator.mjs +2 -184
  111. package/dist/aws.cjs +4 -3
  112. package/dist/aws.cjs.map +1 -1
  113. package/dist/aws.d.cts +8 -3
  114. package/dist/aws.d.cts.map +1 -1
  115. package/dist/aws.d.mts +8 -3
  116. package/dist/aws.d.mts.map +1 -1
  117. package/dist/aws.mjs +2 -1
  118. package/dist/aws.mjs.map +1 -1
  119. package/dist/benchmark.cjs +2 -2
  120. package/dist/benchmark.cjs.map +1 -1
  121. package/dist/benchmark.d.cts +6 -4
  122. package/dist/benchmark.d.cts.map +1 -1
  123. package/dist/benchmark.d.mts +6 -4
  124. package/dist/benchmark.d.mts.map +1 -1
  125. package/dist/benchmark.mjs +1 -1
  126. package/dist/benchmark.mjs.map +1 -1
  127. package/dist/better-auth.cjs +15 -31
  128. package/dist/better-auth.cjs.map +1 -1
  129. package/dist/better-auth.d.cts +4 -13142
  130. package/dist/better-auth.d.cts.map +1 -1
  131. package/dist/better-auth.d.mts +4 -13142
  132. package/dist/better-auth.d.mts.map +1 -1
  133. package/dist/better-auth.mjs +13 -29
  134. package/dist/better-auth.mjs.map +1 -1
  135. package/dist/{rolldown-runtime-VH7oDXx4.cjs → chunk-CUT6urMc.cjs} +10 -8
  136. package/dist/directory-Bpz5c5pj.d.cts +13 -0
  137. package/dist/directory-Bpz5c5pj.d.cts.map +1 -0
  138. package/dist/directory-BxjqmtCT.mjs +27 -0
  139. package/dist/directory-BxjqmtCT.mjs.map +1 -0
  140. package/dist/directory-CVrfTq1I.d.mts +13 -0
  141. package/dist/directory-CVrfTq1I.d.mts.map +1 -0
  142. package/dist/directory-DD_xQoSh.cjs +33 -0
  143. package/dist/directory-DD_xQoSh.cjs.map +1 -0
  144. package/dist/faker-B14IEMIN.cjs +304 -0
  145. package/dist/faker-B14IEMIN.cjs.map +1 -0
  146. package/dist/faker-BGKYFoCT.mjs +262 -0
  147. package/dist/faker-BGKYFoCT.mjs.map +1 -0
  148. package/dist/faker-Cg76aFNO.d.cts +166 -0
  149. package/dist/faker-Cg76aFNO.d.cts.map +1 -0
  150. package/dist/faker-DHh7xs4u.d.mts +166 -0
  151. package/dist/faker-DHh7xs4u.d.mts.map +1 -0
  152. package/dist/faker.cjs +8 -313
  153. package/dist/faker.d.cts +2 -169
  154. package/dist/faker.d.mts +2 -169
  155. package/dist/faker.mjs +2 -305
  156. package/dist/helpers.cjs +5 -6
  157. package/dist/helpers.cjs.map +1 -1
  158. package/dist/helpers.d.cts +5 -1
  159. package/dist/helpers.d.cts.map +1 -1
  160. package/dist/helpers.d.mts +5 -1
  161. package/dist/helpers.d.mts.map +1 -1
  162. package/dist/helpers.mjs +2 -1
  163. package/dist/helpers.mjs.map +1 -1
  164. package/dist/initScript.cjs +15 -15
  165. package/dist/initScript.cjs.map +1 -1
  166. package/dist/initScript.d.cts +4 -2
  167. package/dist/initScript.d.cts.map +1 -1
  168. package/dist/initScript.d.mts +4 -2
  169. package/dist/initScript.d.mts.map +1 -1
  170. package/dist/initScript.mjs +12 -10
  171. package/dist/initScript.mjs.map +1 -1
  172. package/dist/kysely.cjs +13 -10
  173. package/dist/kysely.cjs.map +1 -1
  174. package/dist/kysely.d.cts +14 -10
  175. package/dist/kysely.d.cts.map +1 -1
  176. package/dist/kysely.d.mts +14 -10
  177. package/dist/kysely.d.mts.map +1 -1
  178. package/dist/kysely.mjs +14 -10
  179. package/dist/kysely.mjs.map +1 -1
  180. package/dist/logger.cjs +4 -3
  181. package/dist/logger.cjs.map +1 -1
  182. package/dist/logger.d.cts +5 -1
  183. package/dist/logger.d.cts.map +1 -1
  184. package/dist/logger.d.mts +5 -1
  185. package/dist/logger.d.mts.map +1 -1
  186. package/dist/logger.mjs +2 -1
  187. package/dist/logger.mjs.map +1 -1
  188. package/dist/objection.cjs +13 -10
  189. package/dist/objection.cjs.map +1 -1
  190. package/dist/objection.d.cts +14 -10
  191. package/dist/objection.d.cts.map +1 -1
  192. package/dist/objection.d.mts +14 -10
  193. package/dist/objection.d.mts.map +1 -1
  194. package/dist/objection.mjs +14 -10
  195. package/dist/objection.mjs.map +1 -1
  196. package/dist/os/directory.cjs +2 -31
  197. package/dist/os/directory.d.cts +2 -9
  198. package/dist/os/directory.d.mts +2 -9
  199. package/dist/os/directory.mjs +2 -25
  200. package/dist/os/index.cjs +3 -3
  201. package/dist/os/index.d.cts +1 -1
  202. package/dist/os/index.d.mts +1 -1
  203. package/dist/os/index.mjs +3 -2
  204. package/dist/requestContext.cjs +11 -10
  205. package/dist/requestContext.cjs.map +1 -1
  206. package/dist/requestContext.d.cts +9 -5
  207. package/dist/requestContext.d.cts.map +1 -1
  208. package/dist/requestContext.d.mts +9 -5
  209. package/dist/requestContext.d.mts.map +1 -1
  210. package/dist/requestContext.mjs +3 -2
  211. package/dist/requestContext.mjs.map +1 -1
  212. package/dist/timer.cjs +2 -2
  213. package/dist/timer.cjs.map +1 -1
  214. package/dist/timer.d.cts +4 -1
  215. package/dist/timer.d.cts.map +1 -1
  216. package/dist/timer.d.mts +4 -1
  217. package/dist/timer.d.mts.map +1 -1
  218. package/dist/timer.mjs +1 -1
  219. package/dist/timer.mjs.map +1 -1
  220. package/package.json +25 -65
  221. package/src/Factory.ts +174 -0
  222. package/src/KyselyFactory.ts +391 -0
  223. package/src/ObjectionFactory.ts +412 -0
  224. package/src/PostgresKyselyMigrator.ts +104 -0
  225. package/src/PostgresMigrator.ts +193 -0
  226. package/src/PostgresObjectionMigrator.ts +138 -0
  227. package/src/VitestKyselyTransactionIsolator.ts +72 -0
  228. package/src/VitestObjectionTransactionIsolator.ts +75 -0
  229. package/src/VitestTransactionIsolator.ts +348 -0
  230. package/src/__tests__/Factory.spec.ts +178 -0
  231. package/src/__tests__/KyselyFactory.spec.ts +458 -0
  232. package/src/__tests__/ObjectionFactory.spec.ts +586 -0
  233. package/src/__tests__/PostgresKyselyMigrator.spec.ts +794 -0
  234. package/src/__tests__/PostgresMigrator.spec.ts +471 -0
  235. package/src/__tests__/PostgresObjectionMigrator.spec.ts +634 -0
  236. package/src/__tests__/VitestObjectionTransactionIsolator.spec.ts +138 -0
  237. package/src/__tests__/benchmark.spec.ts +140 -0
  238. package/src/__tests__/better-auth.spec.ts +21 -0
  239. package/src/__tests__/faker.spec.ts +231 -0
  240. package/src/__tests__/initScript.spec.ts +332 -0
  241. package/src/__tests__/integration.spec.ts +610 -0
  242. package/src/__tests__/requestContext.spec.ts +113 -0
  243. package/src/__tests__/utilities.spec.ts +211 -0
  244. package/src/aws.ts +131 -0
  245. package/src/benchmark.ts +48 -0
  246. package/src/better-auth.ts +310 -0
  247. package/src/faker.ts +349 -0
  248. package/src/helpers.ts +45 -0
  249. package/src/initScript.ts +122 -0
  250. package/src/kysely.ts +166 -0
  251. package/src/logger.ts +18 -0
  252. package/src/objection.ts +157 -0
  253. package/src/os/directory.ts +26 -0
  254. package/src/os/index.ts +1 -0
  255. package/src/requestContext.ts +119 -0
  256. package/src/timer.ts +3 -0
  257. package/test/globalSetup.ts +54 -0
  258. package/test/helpers.ts +268 -0
  259. package/test/migrations/1749664623372_user.ts +22 -0
  260. package/tsconfig.json +9 -0
  261. package/vitest.config.ts +8 -0
  262. package/dist/Factory.cjs.map +0 -1
  263. package/dist/Factory.d.cts.map +0 -1
  264. package/dist/Factory.d.mts.map +0 -1
  265. package/dist/Factory.mjs.map +0 -1
  266. package/dist/KyselyFactory.cjs.map +0 -1
  267. package/dist/KyselyFactory.d.cts.map +0 -1
  268. package/dist/KyselyFactory.d.mts.map +0 -1
  269. package/dist/KyselyFactory.mjs.map +0 -1
  270. package/dist/ObjectionFactory.cjs.map +0 -1
  271. package/dist/ObjectionFactory.d.cts.map +0 -1
  272. package/dist/ObjectionFactory.d.mts.map +0 -1
  273. package/dist/ObjectionFactory.mjs.map +0 -1
  274. package/dist/PostgresKyselyMigrator.cjs.map +0 -1
  275. package/dist/PostgresKyselyMigrator.d.cts.map +0 -1
  276. package/dist/PostgresKyselyMigrator.d.mts.map +0 -1
  277. package/dist/PostgresKyselyMigrator.mjs.map +0 -1
  278. package/dist/PostgresMigrator-CDPnnwMJ.d.cts.map +0 -1
  279. package/dist/PostgresMigrator-CDPnnwMJ.d.mts.map +0 -1
  280. package/dist/PostgresMigrator.cjs.map +0 -1
  281. package/dist/PostgresMigrator.mjs.map +0 -1
  282. package/dist/PostgresObjectionMigrator.cjs.map +0 -1
  283. package/dist/PostgresObjectionMigrator.d.cts.map +0 -1
  284. package/dist/PostgresObjectionMigrator.d.mts.map +0 -1
  285. package/dist/PostgresObjectionMigrator.mjs.map +0 -1
  286. package/dist/VitestKyselyTransactionIsolator.cjs.map +0 -1
  287. package/dist/VitestKyselyTransactionIsolator.d.cts.map +0 -1
  288. package/dist/VitestKyselyTransactionIsolator.d.mts.map +0 -1
  289. package/dist/VitestKyselyTransactionIsolator.mjs.map +0 -1
  290. package/dist/VitestObjectionTransactionIsolator.cjs.map +0 -1
  291. package/dist/VitestObjectionTransactionIsolator.d.cts.map +0 -1
  292. package/dist/VitestObjectionTransactionIsolator.d.mts.map +0 -1
  293. package/dist/VitestObjectionTransactionIsolator.mjs.map +0 -1
  294. package/dist/VitestTransactionIsolator.cjs.map +0 -1
  295. package/dist/VitestTransactionIsolator.d.cts.map +0 -1
  296. package/dist/VitestTransactionIsolator.d.mts.map +0 -1
  297. package/dist/VitestTransactionIsolator.mjs.map +0 -1
  298. package/dist/browser.cjs +0 -149
  299. package/dist/browser.cjs.map +0 -1
  300. package/dist/browser.d.cts +0 -62
  301. package/dist/browser.d.cts.map +0 -1
  302. package/dist/browser.d.mts +0 -62
  303. package/dist/browser.d.mts.map +0 -1
  304. package/dist/browser.mjs +0 -147
  305. package/dist/browser.mjs.map +0 -1
  306. package/dist/context.cjs +0 -80
  307. package/dist/context.cjs.map +0 -1
  308. package/dist/context.d.cts +0 -55
  309. package/dist/context.d.cts.map +0 -1
  310. package/dist/context.d.mts +0 -55
  311. package/dist/context.d.mts.map +0 -1
  312. package/dist/context.mjs +0 -73
  313. package/dist/context.mjs.map +0 -1
  314. package/dist/faker.cjs.map +0 -1
  315. package/dist/faker.d.cts.map +0 -1
  316. package/dist/faker.d.mts.map +0 -1
  317. package/dist/faker.mjs.map +0 -1
  318. package/dist/mailbox.cjs +0 -95
  319. package/dist/mailbox.cjs.map +0 -1
  320. package/dist/mailbox.d.cts +0 -58
  321. package/dist/mailbox.d.cts.map +0 -1
  322. package/dist/mailbox.d.mts +0 -58
  323. package/dist/mailbox.d.mts.map +0 -1
  324. package/dist/mailbox.mjs +0 -92
  325. package/dist/mailbox.mjs.map +0 -1
  326. package/dist/os/directory.cjs.map +0 -1
  327. package/dist/os/directory.d.cts.map +0 -1
  328. package/dist/os/directory.d.mts.map +0 -1
  329. package/dist/os/directory.mjs.map +0 -1
  330. package/dist/transactions.cjs +0 -239
  331. package/dist/transactions.cjs.map +0 -1
  332. package/dist/transactions.d.cts +0 -44
  333. package/dist/transactions.d.cts.map +0 -1
  334. package/dist/transactions.d.mts +0 -44
  335. package/dist/transactions.d.mts.map +0 -1
  336. package/dist/transactions.mjs +0 -234
  337. package/dist/transactions.mjs.map +0 -1
@@ -0,0 +1,207 @@
1
+ import { TestAPI } from "vitest";
2
+
3
+ //#region src/VitestTransactionIsolator.d.ts
4
+
5
+ /**
6
+ * Type definition for test fixtures that provide transaction access.
7
+ * Used with Vitest's test.extend() API to inject transactions into tests.
8
+ *
9
+ * @template Transaction - The transaction type specific to the database driver
10
+ * @template Extended - Additional context properties provided by the extend function
11
+ */
12
+ interface DatabaseFixtures<Transaction, _Extended = object> {
13
+ /**
14
+ * The database transaction available to the test.
15
+ * All database operations should use this transaction to ensure proper rollback.
16
+ */
17
+ trx: Transaction;
18
+ }
19
+ /**
20
+ * Combined fixtures type that merges the base transaction fixture with extended context.
21
+ */
22
+ type ExtendedDatabaseFixtures<Transaction, Extended = object> = DatabaseFixtures<Transaction> & Extended;
23
+ /**
24
+ * Function type for extending test context with additional properties.
25
+ * Receives the transaction and returns additional context to be merged with { trx }.
26
+ *
27
+ * @template Transaction - The transaction type
28
+ * @template Extended - The type of additional context to provide
29
+ *
30
+ * @example
31
+ * ```typescript
32
+ * const extendContext: ExtendContextFn<Transaction<DB>, { factory: KyselyFactory }> =
33
+ * (trx) => ({ factory: new KyselyFactory(builders, seeds, trx) });
34
+ * ```
35
+ */
36
+ type ExtendContextFn<Transaction, Extended> = (trx: Transaction) => Extended | Promise<Extended>;
37
+ /**
38
+ * PostgreSQL transaction isolation levels.
39
+ * Controls the visibility of concurrent transactions.
40
+ *
41
+ * @see https://www.postgresql.org/docs/current/transaction-iso.html
42
+ */
43
+ declare enum IsolationLevel {
44
+ /**
45
+ * Lowest isolation level. Allows dirty reads.
46
+ * Not recommended for testing.
47
+ */
48
+ READ_UNCOMMITTED = "READ UNCOMMITTED",
49
+ /**
50
+ * Default PostgreSQL isolation level.
51
+ * Prevents dirty reads but allows non-repeatable reads.
52
+ */
53
+ READ_COMMITTED = "READ COMMITTED",
54
+ /**
55
+ * Prevents dirty reads and non-repeatable reads.
56
+ * Recommended for most test scenarios.
57
+ */
58
+ REPEATABLE_READ = "REPEATABLE READ",
59
+ /**
60
+ * Highest isolation level. Prevents all phenomena.
61
+ * May cause performance overhead in tests.
62
+ */
63
+ SERIALIZABLE = "SERIALIZABLE",
64
+ }
65
+ /**
66
+ * Abstract base class for implementing database transaction isolation in Vitest tests.
67
+ * Provides automatic transaction rollback after each test to maintain test isolation.
68
+ * Subclasses must implement the transact() method for their specific database driver.
69
+ *
70
+ * @template TConn - The database connection type
71
+ * @template Transaction - The transaction type
72
+ *
73
+ * @example
74
+ * ```typescript
75
+ * // Implement for your database driver
76
+ * class MyDatabaseIsolator extends VitestPostgresTransactionIsolator<MyDB, MyTx> {
77
+ * async transact(conn: MyDB, level: IsolationLevel, fn: (tx: MyTx) => Promise<void>) {
78
+ * await conn.transaction(level, fn);
79
+ * }
80
+ * }
81
+ *
82
+ * // Use in tests
83
+ * const isolator = new MyDatabaseIsolator(test);
84
+ * const isolatedTest = isolator.wrapVitestWithTransaction(db);
85
+ *
86
+ * isolatedTest('should create user', async ({ trx }) => {
87
+ * await trx.insert('users', { name: 'Test' });
88
+ * // Data is automatically rolled back after test
89
+ * });
90
+ * ```
91
+ */
92
+ declare abstract class VitestPostgresTransactionIsolator<TConn, Transaction> {
93
+ private readonly api;
94
+ /**
95
+ * Abstract method to create a transaction with the specified isolation level.
96
+ * Must be implemented by subclasses for specific database drivers.
97
+ *
98
+ * @param conn - The database connection
99
+ * @param isolationLevel - The transaction isolation level
100
+ * @param fn - The function to execute within the transaction
101
+ * @returns Promise that resolves when the transaction completes
102
+ */
103
+ abstract transact(conn: TConn, isolationLevel: IsolationLevel, fn: (trx: Transaction) => Promise<void>): Promise<void>;
104
+ abstract destroy(conn: TConn): Promise<void>;
105
+ /**
106
+ * Creates a new VitestPostgresTransactionIsolator instance.
107
+ *
108
+ * @param api - The Vitest test API (usually the `test` export from vitest)
109
+ */
110
+ constructor(api: TestAPI);
111
+ /**
112
+ * Creates a wrapped version of Vitest's test API that provides transaction isolation.
113
+ * Each test will run within a database transaction that is automatically rolled back.
114
+ *
115
+ * @param options - Configuration options for transaction wrapping
116
+ * @returns A wrapped test API with transaction support
117
+ *
118
+ * @example
119
+ * ```typescript
120
+ * const isolatedTest = isolator.wrapVitestWithTransaction({
121
+ * connection: db,
122
+ * setup: async (trx) => {
123
+ * await trx.insert('settings', { key: 'test', value: 'true' });
124
+ * },
125
+ * fixtures: {
126
+ * factory: (trx) => new Factory(trx),
127
+ * },
128
+ * });
129
+ *
130
+ * isolatedTest('test with transaction', async ({ trx, factory }) => {
131
+ * const user = await factory.insert('user', { name: 'Test' });
132
+ * expect(user).toBeDefined();
133
+ * });
134
+ * ```
135
+ */
136
+ wrapVitestWithTransaction<Extended extends Record<string, unknown> = {}>(options: TransactionWrapperOptions<TConn, Transaction, Extended>): TestAPI<DatabaseFixtures<Transaction, object> & Extended>;
137
+ }
138
+ type DatabaseConnectionFn<Conn> = () => Conn | Promise<Conn>;
139
+ type DatabaseConnection<Conn> = DatabaseConnectionFn<Conn>;
140
+ /**
141
+ * Options for wrapping Vitest tests with database transaction isolation.
142
+ */
143
+ interface TransactionWrapperOptions<TConn, Transaction, Extended extends Record<string, unknown> = {}> {
144
+ /** Function that creates or returns a database connection */
145
+ connection: DatabaseConnection<TConn>;
146
+ /** Optional setup function to run within the transaction before each test */
147
+ setup?: (trx: Transaction) => Promise<void>;
148
+ /** Transaction isolation level (defaults to REPEATABLE_READ) */
149
+ isolationLevel?: IsolationLevel;
150
+ /** Additional fixtures that depend on the transaction */
151
+ fixtures?: FixtureCreators<Transaction, Extended>;
152
+ }
153
+ /**
154
+ * Type for fixture creator functions that depend on the transaction.
155
+ * Each function receives the transaction and returns the fixture value.
156
+ */
157
+ type FixtureCreators<Transaction, Extended extends Record<string, unknown>> = { [K in keyof Extended]: (trx: Transaction) => Extended[K] | Promise<Extended[K]> };
158
+ /**
159
+ * The test API returned by extendWithFixtures.
160
+ * Provides access to both the transaction (trx) and all extended fixtures.
161
+ *
162
+ * @template Transaction - The transaction type
163
+ * @template Extended - The type of additional fixtures provided
164
+ * @template BaseTest - The base wrapped test type
165
+ */
166
+ type TestWithExtendedFixtures<Transaction, Extended extends Record<string, unknown>, BaseTest extends ReturnType<TestAPI['extend']> = ReturnType<TestAPI['extend']>> = BaseTest & {
167
+ <C extends object>(name: string, fn: (context: DatabaseFixtures<Transaction> & Extended & C) => Promise<void>): void;
168
+ <C extends object>(name: string, options: object, fn: (context: DatabaseFixtures<Transaction> & Extended & C) => Promise<void>): void;
169
+ };
170
+ /**
171
+ * Extends a wrapped test API with additional fixtures that depend on the transaction.
172
+ * This allows composing test context with factories, repositories, or other helpers.
173
+ *
174
+ * @template Transaction - The transaction type
175
+ * @template Extended - The type of additional context to provide
176
+ * @param wrappedTest - The base wrapped test from wrapVitestWithTransaction
177
+ * @param fixtures - Object mapping fixture names to creator functions
178
+ * @returns An extended test API with both trx and the additional fixtures
179
+ *
180
+ * @example
181
+ * ```typescript
182
+ * import { wrapVitestKyselyTransaction, extendWithFixtures } from '@geekmidas/testkit/kysely';
183
+ *
184
+ * // Create base wrapped test
185
+ * const baseTest = wrapVitestKyselyTransaction(test, {
186
+ * connection: db,
187
+ * setup: createTestTables,
188
+ * });
189
+ *
190
+ * // Extend with fixtures
191
+ * const it = extendWithFixtures(baseTest, {
192
+ * factory: (trx) => new KyselyFactory(builders, seeds, trx),
193
+ * userRepo: (trx) => new UserRepository(trx),
194
+ * });
195
+ *
196
+ * // Use in tests - trx and all fixtures are available
197
+ * it('should create user with factory', async ({ trx, factory, userRepo }) => {
198
+ * const user = await factory.insert('user', { name: 'Test' });
199
+ * expect(user).toBeDefined();
200
+ * });
201
+ * ```
202
+ */
203
+ declare function extendWithFixtures<Transaction, Extended extends Record<string, unknown>, T extends ReturnType<TestAPI['extend']> = any>(wrappedTest: T, fixtures: FixtureCreators<Transaction, Extended>): TestWithExtendedFixtures<Transaction, Extended, T>;
204
+ //# sourceMappingURL=VitestTransactionIsolator.d.ts.map
205
+ //#endregion
206
+ export { DatabaseConnection, DatabaseConnectionFn, DatabaseFixtures, ExtendContextFn, ExtendedDatabaseFixtures, FixtureCreators, IsolationLevel, TestWithExtendedFixtures, TransactionWrapperOptions, VitestPostgresTransactionIsolator, extendWithFixtures };
207
+ //# sourceMappingURL=VitestTransactionIsolator-BNWJqh9f.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"VitestTransactionIsolator-BNWJqh9f.d.mts","names":[],"sources":["../src/VitestTransactionIsolator.ts"],"sourcesContent":[],"mappings":";;;;;;AASA;AAWA;;;;AAGoC,UAdnB,gBAcmB,CAAA,WAAA,EAAA,YAAA,MAAA,CAAA,CAAA;EAAQ;AAe5C;;;EACiB,GACZ,EA1BC,WA0BD;;;AAAkB;AAQvB;AAkDsB,KA9EV,wBA8EU,CAAA,WAAiC,EAAA,WAAA,MAAA,CAAA,GA3EnD,gBA2EmD,CA3ElC,WA2EkC,CAAA,GA3EnB,QA2EmB;;;;;;;;;;;;;;AAkD5C,KA9GC,eA8GD,CAAA,WAAA,EAAA,QAAA,CAAA,GAAA,CAAA,GAAA,EA7GL,WA6GK,EAAA,GA5GN,QA4GM,GA5GK,OA4GL,CA5Ga,QA4Gb,CAAA;;;;;AAAuD;AA+ElE;AAAgC,aAnLpB,cAAA;EAmLoB;;;AAA6B;EACjD,gBAAA,GAAA,kBAAkB;EAAA;;;AAA6B;EAK1C,cAAA,GAAA,gBAAyB;EAAA;;;;EAMX,eAEhB,GAAA,iBAAA;EAAW;;;;EAIuB,YAArC,GAAA,cAAA;AAAe;AAO3B;;;;;;;;;;AAM2B;AAW3B;;;;;;;;;;;;;;;;AAiBuD,uBA5LjC,iCA4LiC,CAAA,KAAA,EAAA,WAAA,CAAA,CAAA;EAAC,iBACjD,GAAA;EAAO;AAqCd;;;;;;;;EAOgD,SAArC,QAAA,CAAA,IAAA,EA9NH,KA8NG,EAAA,cAAA,EA7NO,cA6NP,EAAA,EAAA,EAAA,CAAA,GAAA,EA5NC,WA4ND,EAAA,GA5NiB,OA4NjB,CAAA,IAAA,CAAA,CAAA,EA3NP,OA2NO,CAAA,IAAA,CAAA;EAAe,SACE,OAAA,CAAA,IAAA,EA1NJ,KA0NI,CAAA,EA1NI,OA0NJ,CAAA,IAAA,CAAA;EAAW;;;AAAZ;;mBApNQ;;;;;;;;;;;;;;;;;;;;;;;;;;6CA2BS,uCACjC,0BAA0B,OAAO,aAAa,YAAS,QAAA,iBAAA,uBAAA;;KA+EtD,mCAAmC,OAAO,QAAQ;KAClD,2BAA2B,qBAAqB;;;;UAK3C,+DAGC;;cAGL,mBAAmB;;gBAEjB,gBAAgB;;mBAEb;;aAEN,gBAAgB,aAAa;;;;;;KAO7B,8CAEM,yCAEL,iBACN,gBACD,SAAS,KAAK,QAAQ,SAAS;;;;;;;;;KAWzB,uDAEM,0CACA,WAAW,qBAAqB,WAChD,sBAEE;iDAIQ,iBAAiB,eAAe,WAAW,MAChD;kEAMK,iBAAiB,eAAe,WAAW,MAChD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAqCS,iDAEE,mCAEP,WAAW,uCAER,aACH,gBAAgB,aAAa,YACrC,yBAAyB,aAAa,UAAU"}
@@ -0,0 +1,207 @@
1
+ import { TestAPI } from "vitest";
2
+
3
+ //#region src/VitestTransactionIsolator.d.ts
4
+
5
+ /**
6
+ * Type definition for test fixtures that provide transaction access.
7
+ * Used with Vitest's test.extend() API to inject transactions into tests.
8
+ *
9
+ * @template Transaction - The transaction type specific to the database driver
10
+ * @template Extended - Additional context properties provided by the extend function
11
+ */
12
+ interface DatabaseFixtures<Transaction, _Extended = object> {
13
+ /**
14
+ * The database transaction available to the test.
15
+ * All database operations should use this transaction to ensure proper rollback.
16
+ */
17
+ trx: Transaction;
18
+ }
19
+ /**
20
+ * Combined fixtures type that merges the base transaction fixture with extended context.
21
+ */
22
+ type ExtendedDatabaseFixtures<Transaction, Extended = object> = DatabaseFixtures<Transaction> & Extended;
23
+ /**
24
+ * Function type for extending test context with additional properties.
25
+ * Receives the transaction and returns additional context to be merged with { trx }.
26
+ *
27
+ * @template Transaction - The transaction type
28
+ * @template Extended - The type of additional context to provide
29
+ *
30
+ * @example
31
+ * ```typescript
32
+ * const extendContext: ExtendContextFn<Transaction<DB>, { factory: KyselyFactory }> =
33
+ * (trx) => ({ factory: new KyselyFactory(builders, seeds, trx) });
34
+ * ```
35
+ */
36
+ type ExtendContextFn<Transaction, Extended> = (trx: Transaction) => Extended | Promise<Extended>;
37
+ /**
38
+ * PostgreSQL transaction isolation levels.
39
+ * Controls the visibility of concurrent transactions.
40
+ *
41
+ * @see https://www.postgresql.org/docs/current/transaction-iso.html
42
+ */
43
+ declare enum IsolationLevel {
44
+ /**
45
+ * Lowest isolation level. Allows dirty reads.
46
+ * Not recommended for testing.
47
+ */
48
+ READ_UNCOMMITTED = "READ UNCOMMITTED",
49
+ /**
50
+ * Default PostgreSQL isolation level.
51
+ * Prevents dirty reads but allows non-repeatable reads.
52
+ */
53
+ READ_COMMITTED = "READ COMMITTED",
54
+ /**
55
+ * Prevents dirty reads and non-repeatable reads.
56
+ * Recommended for most test scenarios.
57
+ */
58
+ REPEATABLE_READ = "REPEATABLE READ",
59
+ /**
60
+ * Highest isolation level. Prevents all phenomena.
61
+ * May cause performance overhead in tests.
62
+ */
63
+ SERIALIZABLE = "SERIALIZABLE",
64
+ }
65
+ /**
66
+ * Abstract base class for implementing database transaction isolation in Vitest tests.
67
+ * Provides automatic transaction rollback after each test to maintain test isolation.
68
+ * Subclasses must implement the transact() method for their specific database driver.
69
+ *
70
+ * @template TConn - The database connection type
71
+ * @template Transaction - The transaction type
72
+ *
73
+ * @example
74
+ * ```typescript
75
+ * // Implement for your database driver
76
+ * class MyDatabaseIsolator extends VitestPostgresTransactionIsolator<MyDB, MyTx> {
77
+ * async transact(conn: MyDB, level: IsolationLevel, fn: (tx: MyTx) => Promise<void>) {
78
+ * await conn.transaction(level, fn);
79
+ * }
80
+ * }
81
+ *
82
+ * // Use in tests
83
+ * const isolator = new MyDatabaseIsolator(test);
84
+ * const isolatedTest = isolator.wrapVitestWithTransaction(db);
85
+ *
86
+ * isolatedTest('should create user', async ({ trx }) => {
87
+ * await trx.insert('users', { name: 'Test' });
88
+ * // Data is automatically rolled back after test
89
+ * });
90
+ * ```
91
+ */
92
+ declare abstract class VitestPostgresTransactionIsolator<TConn, Transaction> {
93
+ private readonly api;
94
+ /**
95
+ * Abstract method to create a transaction with the specified isolation level.
96
+ * Must be implemented by subclasses for specific database drivers.
97
+ *
98
+ * @param conn - The database connection
99
+ * @param isolationLevel - The transaction isolation level
100
+ * @param fn - The function to execute within the transaction
101
+ * @returns Promise that resolves when the transaction completes
102
+ */
103
+ abstract transact(conn: TConn, isolationLevel: IsolationLevel, fn: (trx: Transaction) => Promise<void>): Promise<void>;
104
+ abstract destroy(conn: TConn): Promise<void>;
105
+ /**
106
+ * Creates a new VitestPostgresTransactionIsolator instance.
107
+ *
108
+ * @param api - The Vitest test API (usually the `test` export from vitest)
109
+ */
110
+ constructor(api: TestAPI);
111
+ /**
112
+ * Creates a wrapped version of Vitest's test API that provides transaction isolation.
113
+ * Each test will run within a database transaction that is automatically rolled back.
114
+ *
115
+ * @param options - Configuration options for transaction wrapping
116
+ * @returns A wrapped test API with transaction support
117
+ *
118
+ * @example
119
+ * ```typescript
120
+ * const isolatedTest = isolator.wrapVitestWithTransaction({
121
+ * connection: db,
122
+ * setup: async (trx) => {
123
+ * await trx.insert('settings', { key: 'test', value: 'true' });
124
+ * },
125
+ * fixtures: {
126
+ * factory: (trx) => new Factory(trx),
127
+ * },
128
+ * });
129
+ *
130
+ * isolatedTest('test with transaction', async ({ trx, factory }) => {
131
+ * const user = await factory.insert('user', { name: 'Test' });
132
+ * expect(user).toBeDefined();
133
+ * });
134
+ * ```
135
+ */
136
+ wrapVitestWithTransaction<Extended extends Record<string, unknown> = {}>(options: TransactionWrapperOptions<TConn, Transaction, Extended>): TestAPI<DatabaseFixtures<Transaction, object> & Extended>;
137
+ }
138
+ type DatabaseConnectionFn<Conn> = () => Conn | Promise<Conn>;
139
+ type DatabaseConnection<Conn> = DatabaseConnectionFn<Conn>;
140
+ /**
141
+ * Options for wrapping Vitest tests with database transaction isolation.
142
+ */
143
+ interface TransactionWrapperOptions<TConn, Transaction, Extended extends Record<string, unknown> = {}> {
144
+ /** Function that creates or returns a database connection */
145
+ connection: DatabaseConnection<TConn>;
146
+ /** Optional setup function to run within the transaction before each test */
147
+ setup?: (trx: Transaction) => Promise<void>;
148
+ /** Transaction isolation level (defaults to REPEATABLE_READ) */
149
+ isolationLevel?: IsolationLevel;
150
+ /** Additional fixtures that depend on the transaction */
151
+ fixtures?: FixtureCreators<Transaction, Extended>;
152
+ }
153
+ /**
154
+ * Type for fixture creator functions that depend on the transaction.
155
+ * Each function receives the transaction and returns the fixture value.
156
+ */
157
+ type FixtureCreators<Transaction, Extended extends Record<string, unknown>> = { [K in keyof Extended]: (trx: Transaction) => Extended[K] | Promise<Extended[K]> };
158
+ /**
159
+ * The test API returned by extendWithFixtures.
160
+ * Provides access to both the transaction (trx) and all extended fixtures.
161
+ *
162
+ * @template Transaction - The transaction type
163
+ * @template Extended - The type of additional fixtures provided
164
+ * @template BaseTest - The base wrapped test type
165
+ */
166
+ type TestWithExtendedFixtures<Transaction, Extended extends Record<string, unknown>, BaseTest extends ReturnType<TestAPI['extend']> = ReturnType<TestAPI['extend']>> = BaseTest & {
167
+ <C extends object>(name: string, fn: (context: DatabaseFixtures<Transaction> & Extended & C) => Promise<void>): void;
168
+ <C extends object>(name: string, options: object, fn: (context: DatabaseFixtures<Transaction> & Extended & C) => Promise<void>): void;
169
+ };
170
+ /**
171
+ * Extends a wrapped test API with additional fixtures that depend on the transaction.
172
+ * This allows composing test context with factories, repositories, or other helpers.
173
+ *
174
+ * @template Transaction - The transaction type
175
+ * @template Extended - The type of additional context to provide
176
+ * @param wrappedTest - The base wrapped test from wrapVitestWithTransaction
177
+ * @param fixtures - Object mapping fixture names to creator functions
178
+ * @returns An extended test API with both trx and the additional fixtures
179
+ *
180
+ * @example
181
+ * ```typescript
182
+ * import { wrapVitestKyselyTransaction, extendWithFixtures } from '@geekmidas/testkit/kysely';
183
+ *
184
+ * // Create base wrapped test
185
+ * const baseTest = wrapVitestKyselyTransaction(test, {
186
+ * connection: db,
187
+ * setup: createTestTables,
188
+ * });
189
+ *
190
+ * // Extend with fixtures
191
+ * const it = extendWithFixtures(baseTest, {
192
+ * factory: (trx) => new KyselyFactory(builders, seeds, trx),
193
+ * userRepo: (trx) => new UserRepository(trx),
194
+ * });
195
+ *
196
+ * // Use in tests - trx and all fixtures are available
197
+ * it('should create user with factory', async ({ trx, factory, userRepo }) => {
198
+ * const user = await factory.insert('user', { name: 'Test' });
199
+ * expect(user).toBeDefined();
200
+ * });
201
+ * ```
202
+ */
203
+ declare function extendWithFixtures<Transaction, Extended extends Record<string, unknown>, T extends ReturnType<TestAPI['extend']> = any>(wrappedTest: T, fixtures: FixtureCreators<Transaction, Extended>): TestWithExtendedFixtures<Transaction, Extended, T>;
204
+ //# sourceMappingURL=VitestTransactionIsolator.d.ts.map
205
+ //#endregion
206
+ export { DatabaseConnection, DatabaseConnectionFn, DatabaseFixtures, ExtendContextFn, ExtendedDatabaseFixtures, FixtureCreators, IsolationLevel, TestWithExtendedFixtures, TransactionWrapperOptions, VitestPostgresTransactionIsolator, extendWithFixtures };
207
+ //# sourceMappingURL=VitestTransactionIsolator-CSroc7Df.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"VitestTransactionIsolator-CSroc7Df.d.cts","names":[],"sources":["../src/VitestTransactionIsolator.ts"],"sourcesContent":[],"mappings":";;;;;;AASA;AAWA;;;;AAGoC,UAdnB,gBAcmB,CAAA,WAAA,EAAA,YAAA,MAAA,CAAA,CAAA;EAAQ;AAe5C;;;EACiB,GACZ,EA1BC,WA0BD;;;AAAkB;AAQvB;AAkDsB,KA9EV,wBA8EU,CAAA,WAAiC,EAAA,WAAA,MAAA,CAAA,GA3EnD,gBA2EmD,CA3ElC,WA2EkC,CAAA,GA3EnB,QA2EmB;;;;;;;;;;;;;;AAkD5C,KA9GC,eA8GD,CAAA,WAAA,EAAA,QAAA,CAAA,GAAA,CAAA,GAAA,EA7GL,WA6GK,EAAA,GA5GN,QA4GM,GA5GK,OA4GL,CA5Ga,QA4Gb,CAAA;;;;;AAAuD;AA+ElE;AAAgC,aAnLpB,cAAA;EAmLoB;;;AAA6B;EACjD,gBAAA,GAAA,kBAAkB;EAAA;;;AAA6B;EAK1C,cAAA,GAAA,gBAAyB;EAAA;;;;EAMX,eAEhB,GAAA,iBAAA;EAAW;;;;EAIuB,YAArC,GAAA,cAAA;AAAe;AAO3B;;;;;;;;;;AAM2B;AAW3B;;;;;;;;;;;;;;;;AAiBuD,uBA5LjC,iCA4LiC,CAAA,KAAA,EAAA,WAAA,CAAA,CAAA;EAAC,iBACjD,GAAA;EAAO;AAqCd;;;;;;;;EAOgD,SAArC,QAAA,CAAA,IAAA,EA9NH,KA8NG,EAAA,cAAA,EA7NO,cA6NP,EAAA,EAAA,EAAA,CAAA,GAAA,EA5NC,WA4ND,EAAA,GA5NiB,OA4NjB,CAAA,IAAA,CAAA,CAAA,EA3NP,OA2NO,CAAA,IAAA,CAAA;EAAe,SACE,OAAA,CAAA,IAAA,EA1NJ,KA0NI,CAAA,EA1NI,OA0NJ,CAAA,IAAA,CAAA;EAAW;;;AAAZ;;mBApNQ;;;;;;;;;;;;;;;;;;;;;;;;;;6CA2BS,uCACjC,0BAA0B,OAAO,aAAa,YAAS,QAAA,iBAAA,uBAAA;;KA+EtD,mCAAmC,OAAO,QAAQ;KAClD,2BAA2B,qBAAqB;;;;UAK3C,+DAGC;;cAGL,mBAAmB;;gBAEjB,gBAAgB;;mBAEb;;aAEN,gBAAgB,aAAa;;;;;;KAO7B,8CAEM,yCAEL,iBACN,gBACD,SAAS,KAAK,QAAQ,SAAS;;;;;;;;;KAWzB,uDAEM,0CACA,WAAW,qBAAqB,WAChD,sBAEE;iDAIQ,iBAAiB,eAAe,WAAW,MAChD;kEAMK,iBAAiB,eAAe,WAAW,MAChD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAqCS,iDAEE,mCAEP,WAAW,uCAER,aACH,gBAAgB,aAAa,YACrC,yBAAyB,aAAa,UAAU"}
@@ -0,0 +1,193 @@
1
+
2
+ //#region src/VitestTransactionIsolator.ts
3
+ /**
4
+ * PostgreSQL transaction isolation levels.
5
+ * Controls the visibility of concurrent transactions.
6
+ *
7
+ * @see https://www.postgresql.org/docs/current/transaction-iso.html
8
+ */
9
+ let IsolationLevel = /* @__PURE__ */ function(IsolationLevel$1) {
10
+ /**
11
+ * Lowest isolation level. Allows dirty reads.
12
+ * Not recommended for testing.
13
+ */
14
+ IsolationLevel$1["READ_UNCOMMITTED"] = "READ UNCOMMITTED";
15
+ /**
16
+ * Default PostgreSQL isolation level.
17
+ * Prevents dirty reads but allows non-repeatable reads.
18
+ */
19
+ IsolationLevel$1["READ_COMMITTED"] = "READ COMMITTED";
20
+ /**
21
+ * Prevents dirty reads and non-repeatable reads.
22
+ * Recommended for most test scenarios.
23
+ */
24
+ IsolationLevel$1["REPEATABLE_READ"] = "REPEATABLE READ";
25
+ /**
26
+ * Highest isolation level. Prevents all phenomena.
27
+ * May cause performance overhead in tests.
28
+ */
29
+ IsolationLevel$1["SERIALIZABLE"] = "SERIALIZABLE";
30
+ return IsolationLevel$1;
31
+ }({});
32
+ /**
33
+ * Abstract base class for implementing database transaction isolation in Vitest tests.
34
+ * Provides automatic transaction rollback after each test to maintain test isolation.
35
+ * Subclasses must implement the transact() method for their specific database driver.
36
+ *
37
+ * @template TConn - The database connection type
38
+ * @template Transaction - The transaction type
39
+ *
40
+ * @example
41
+ * ```typescript
42
+ * // Implement for your database driver
43
+ * class MyDatabaseIsolator extends VitestPostgresTransactionIsolator<MyDB, MyTx> {
44
+ * async transact(conn: MyDB, level: IsolationLevel, fn: (tx: MyTx) => Promise<void>) {
45
+ * await conn.transaction(level, fn);
46
+ * }
47
+ * }
48
+ *
49
+ * // Use in tests
50
+ * const isolator = new MyDatabaseIsolator(test);
51
+ * const isolatedTest = isolator.wrapVitestWithTransaction(db);
52
+ *
53
+ * isolatedTest('should create user', async ({ trx }) => {
54
+ * await trx.insert('users', { name: 'Test' });
55
+ * // Data is automatically rolled back after test
56
+ * });
57
+ * ```
58
+ */
59
+ var VitestPostgresTransactionIsolator = class {
60
+ /**
61
+ * Creates a new VitestPostgresTransactionIsolator instance.
62
+ *
63
+ * @param api - The Vitest test API (usually the `test` export from vitest)
64
+ */
65
+ constructor(api) {
66
+ this.api = api;
67
+ }
68
+ /**
69
+ * Creates a wrapped version of Vitest's test API that provides transaction isolation.
70
+ * Each test will run within a database transaction that is automatically rolled back.
71
+ *
72
+ * @param options - Configuration options for transaction wrapping
73
+ * @returns A wrapped test API with transaction support
74
+ *
75
+ * @example
76
+ * ```typescript
77
+ * const isolatedTest = isolator.wrapVitestWithTransaction({
78
+ * connection: db,
79
+ * setup: async (trx) => {
80
+ * await trx.insert('settings', { key: 'test', value: 'true' });
81
+ * },
82
+ * fixtures: {
83
+ * factory: (trx) => new Factory(trx),
84
+ * },
85
+ * });
86
+ *
87
+ * isolatedTest('test with transaction', async ({ trx, factory }) => {
88
+ * const user = await factory.insert('user', { name: 'Test' });
89
+ * expect(user).toBeDefined();
90
+ * });
91
+ * ```
92
+ */
93
+ wrapVitestWithTransaction(options) {
94
+ const { connection, setup, isolationLevel = IsolationLevel.REPEATABLE_READ, fixtures } = options;
95
+ const additionalFixtures = {};
96
+ if (fixtures) for (const [key, creator] of Object.entries(fixtures)) additionalFixtures[key] = async ({ trx }, use) => {
97
+ const value = await creator(trx);
98
+ await use(value);
99
+ };
100
+ const api = this.api;
101
+ return api.extend({
102
+ trx: async ({}, use) => {
103
+ class TestRollback extends Error {
104
+ constructor() {
105
+ super("Test rollback");
106
+ this.name = "TestRollback";
107
+ }
108
+ }
109
+ let testError;
110
+ const conn = await connection();
111
+ try {
112
+ await this.transact(conn, isolationLevel, async (transaction) => {
113
+ try {
114
+ await setup?.(transaction);
115
+ await use(transaction);
116
+ } catch (error) {
117
+ testError = error;
118
+ }
119
+ throw new TestRollback();
120
+ });
121
+ } catch (error) {
122
+ if (!(error instanceof TestRollback)) throw error;
123
+ if (testError) throw testError;
124
+ } finally {
125
+ await this.destroy(conn);
126
+ }
127
+ },
128
+ ...additionalFixtures
129
+ });
130
+ }
131
+ };
132
+ /**
133
+ * Extends a wrapped test API with additional fixtures that depend on the transaction.
134
+ * This allows composing test context with factories, repositories, or other helpers.
135
+ *
136
+ * @template Transaction - The transaction type
137
+ * @template Extended - The type of additional context to provide
138
+ * @param wrappedTest - The base wrapped test from wrapVitestWithTransaction
139
+ * @param fixtures - Object mapping fixture names to creator functions
140
+ * @returns An extended test API with both trx and the additional fixtures
141
+ *
142
+ * @example
143
+ * ```typescript
144
+ * import { wrapVitestKyselyTransaction, extendWithFixtures } from '@geekmidas/testkit/kysely';
145
+ *
146
+ * // Create base wrapped test
147
+ * const baseTest = wrapVitestKyselyTransaction(test, {
148
+ * connection: db,
149
+ * setup: createTestTables,
150
+ * });
151
+ *
152
+ * // Extend with fixtures
153
+ * const it = extendWithFixtures(baseTest, {
154
+ * factory: (trx) => new KyselyFactory(builders, seeds, trx),
155
+ * userRepo: (trx) => new UserRepository(trx),
156
+ * });
157
+ *
158
+ * // Use in tests - trx and all fixtures are available
159
+ * it('should create user with factory', async ({ trx, factory, userRepo }) => {
160
+ * const user = await factory.insert('user', { name: 'Test' });
161
+ * expect(user).toBeDefined();
162
+ * });
163
+ * ```
164
+ */
165
+ function extendWithFixtures(wrappedTest, fixtures) {
166
+ const fixtureDefinitions = {};
167
+ for (const [key, creator] of Object.entries(fixtures)) fixtureDefinitions[key] = async ({ trx }, use) => {
168
+ const value = await creator(trx);
169
+ await use(value);
170
+ };
171
+ return wrappedTest.extend(fixtureDefinitions);
172
+ }
173
+
174
+ //#endregion
175
+ Object.defineProperty(exports, 'IsolationLevel', {
176
+ enumerable: true,
177
+ get: function () {
178
+ return IsolationLevel;
179
+ }
180
+ });
181
+ Object.defineProperty(exports, 'VitestPostgresTransactionIsolator', {
182
+ enumerable: true,
183
+ get: function () {
184
+ return VitestPostgresTransactionIsolator;
185
+ }
186
+ });
187
+ Object.defineProperty(exports, 'extendWithFixtures', {
188
+ enumerable: true,
189
+ get: function () {
190
+ return extendWithFixtures;
191
+ }
192
+ });
193
+ //# sourceMappingURL=VitestTransactionIsolator-CtZaOUjH.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"VitestTransactionIsolator-CtZaOUjH.cjs","names":["api: TestAPI","options: TransactionWrapperOptions<TConn, Transaction, Extended>","additionalFixtures: Record<string, unknown>","use: (value: unknown) => Promise<void>","use: (value: Transaction) => Promise<void>","testError: Error | undefined","wrappedTest: T","fixtures: FixtureCreators<Transaction, Extended>","fixtureDefinitions: Record<string, any>"],"sources":["../src/VitestTransactionIsolator.ts"],"sourcesContent":["import type { TestAPI } from 'vitest';\n\n/**\n * Type definition for test fixtures that provide transaction access.\n * Used with Vitest's test.extend() API to inject transactions into tests.\n *\n * @template Transaction - The transaction type specific to the database driver\n * @template Extended - Additional context properties provided by the extend function\n */\nexport interface DatabaseFixtures<Transaction, _Extended = object> {\n\t/**\n\t * The database transaction available to the test.\n\t * All database operations should use this transaction to ensure proper rollback.\n\t */\n\ttrx: Transaction;\n}\n\n/**\n * Combined fixtures type that merges the base transaction fixture with extended context.\n */\nexport type ExtendedDatabaseFixtures<\n\tTransaction,\n\tExtended = object,\n> = DatabaseFixtures<Transaction> & Extended;\n\n/**\n * Function type for extending test context with additional properties.\n * Receives the transaction and returns additional context to be merged with { trx }.\n *\n * @template Transaction - The transaction type\n * @template Extended - The type of additional context to provide\n *\n * @example\n * ```typescript\n * const extendContext: ExtendContextFn<Transaction<DB>, { factory: KyselyFactory }> =\n * (trx) => ({ factory: new KyselyFactory(builders, seeds, trx) });\n * ```\n */\nexport type ExtendContextFn<Transaction, Extended> = (\n\ttrx: Transaction,\n) => Extended | Promise<Extended>;\n\n/**\n * PostgreSQL transaction isolation levels.\n * Controls the visibility of concurrent transactions.\n *\n * @see https://www.postgresql.org/docs/current/transaction-iso.html\n */\nexport enum IsolationLevel {\n\t/**\n\t * Lowest isolation level. Allows dirty reads.\n\t * Not recommended for testing.\n\t */\n\tREAD_UNCOMMITTED = 'READ UNCOMMITTED',\n\t/**\n\t * Default PostgreSQL isolation level.\n\t * Prevents dirty reads but allows non-repeatable reads.\n\t */\n\tREAD_COMMITTED = 'READ COMMITTED',\n\t/**\n\t * Prevents dirty reads and non-repeatable reads.\n\t * Recommended for most test scenarios.\n\t */\n\tREPEATABLE_READ = 'REPEATABLE READ',\n\t/**\n\t * Highest isolation level. Prevents all phenomena.\n\t * May cause performance overhead in tests.\n\t */\n\tSERIALIZABLE = 'SERIALIZABLE',\n}\n\n/**\n * Abstract base class for implementing database transaction isolation in Vitest tests.\n * Provides automatic transaction rollback after each test to maintain test isolation.\n * Subclasses must implement the transact() method for their specific database driver.\n *\n * @template TConn - The database connection type\n * @template Transaction - The transaction type\n *\n * @example\n * ```typescript\n * // Implement for your database driver\n * class MyDatabaseIsolator extends VitestPostgresTransactionIsolator<MyDB, MyTx> {\n * async transact(conn: MyDB, level: IsolationLevel, fn: (tx: MyTx) => Promise<void>) {\n * await conn.transaction(level, fn);\n * }\n * }\n *\n * // Use in tests\n * const isolator = new MyDatabaseIsolator(test);\n * const isolatedTest = isolator.wrapVitestWithTransaction(db);\n *\n * isolatedTest('should create user', async ({ trx }) => {\n * await trx.insert('users', { name: 'Test' });\n * // Data is automatically rolled back after test\n * });\n * ```\n */\nexport abstract class VitestPostgresTransactionIsolator<TConn, Transaction> {\n\t/**\n\t * Abstract method to create a transaction with the specified isolation level.\n\t * Must be implemented by subclasses for specific database drivers.\n\t *\n\t * @param conn - The database connection\n\t * @param isolationLevel - The transaction isolation level\n\t * @param fn - The function to execute within the transaction\n\t * @returns Promise that resolves when the transaction completes\n\t */\n\tabstract transact(\n\t\tconn: TConn,\n\t\tisolationLevel: IsolationLevel,\n\t\tfn: (trx: Transaction) => Promise<void>,\n\t): Promise<void>;\n\n\tabstract destroy(conn: TConn): Promise<void>;\n\t/**\n\t * Creates a new VitestPostgresTransactionIsolator instance.\n\t *\n\t * @param api - The Vitest test API (usually the `test` export from vitest)\n\t */\n\tconstructor(private readonly api: TestAPI) {}\n\n\t/**\n\t * Creates a wrapped version of Vitest's test API that provides transaction isolation.\n\t * Each test will run within a database transaction that is automatically rolled back.\n\t *\n\t * @param options - Configuration options for transaction wrapping\n\t * @returns A wrapped test API with transaction support\n\t *\n\t * @example\n\t * ```typescript\n\t * const isolatedTest = isolator.wrapVitestWithTransaction({\n\t * connection: db,\n\t * setup: async (trx) => {\n\t * await trx.insert('settings', { key: 'test', value: 'true' });\n\t * },\n\t * fixtures: {\n\t * factory: (trx) => new Factory(trx),\n\t * },\n\t * });\n\t *\n\t * isolatedTest('test with transaction', async ({ trx, factory }) => {\n\t * const user = await factory.insert('user', { name: 'Test' });\n\t * expect(user).toBeDefined();\n\t * });\n\t * ```\n\t */\n\twrapVitestWithTransaction<Extended extends Record<string, unknown> = {}>(\n\t\toptions: TransactionWrapperOptions<TConn, Transaction, Extended>,\n\t) {\n\t\tconst {\n\t\t\tconnection,\n\t\t\tsetup,\n\t\t\tisolationLevel = IsolationLevel.REPEATABLE_READ,\n\t\t\tfixtures,\n\t\t} = options;\n\n\t\t// Build fixture definitions for additional fixtures that depend on trx\n\t\tconst additionalFixtures: Record<string, unknown> = {};\n\t\tif (fixtures) {\n\t\t\tfor (const [key, creator] of Object.entries(fixtures)) {\n\t\t\t\tadditionalFixtures[key] = async (\n\t\t\t\t\t{ trx }: { trx: Transaction },\n\t\t\t\t\tuse: (value: unknown) => Promise<void>,\n\t\t\t\t) => {\n\t\t\t\t\tconst value = await (creator as (trx: Transaction) => unknown)(trx);\n\t\t\t\t\tawait use(value);\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\ttype CombinedFixtures = DatabaseFixtures<Transaction> & Extended;\n\n\t\t// Cast to bypass Vitest's strict fixture typing which can't infer\n\t\t// dynamically built fixture objects\n\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\tconst api = this.api as TestAPI & {\n\t\t\textend: <T>(fixtures: any) => TestAPI<T>;\n\t\t};\n\n\t\treturn api.extend<CombinedFixtures>({\n\t\t\t// This fixture automatically provides a transaction to each test\n\t\t\t// biome-ignore lint/correctness/noEmptyPattern: this has to be like this to satisfy Biome\n\t\t\ttrx: async ({}: {}, use: (value: Transaction) => Promise<void>) => {\n\t\t\t\t// Create a custom error class for rollback\n\t\t\t\tclass TestRollback extends Error {\n\t\t\t\t\tconstructor() {\n\t\t\t\t\t\tsuper('Test rollback');\n\t\t\t\t\t\tthis.name = 'TestRollback';\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tlet testError: Error | undefined;\n\t\t\t\tconst conn = await connection();\n\t\t\t\ttry {\n\t\t\t\t\tawait this.transact(conn, isolationLevel, async (transaction) => {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t// Provide the transaction to the test\n\t\t\t\t\t\t\tawait setup?.(transaction);\n\t\t\t\t\t\t\tawait use(transaction);\n\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\t// Capture any test errors\n\t\t\t\t\t\t\ttestError = error as Error;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Always throw to trigger rollback\n\t\t\t\t\t\tthrow new TestRollback();\n\t\t\t\t\t});\n\t\t\t\t} catch (error) {\n\t\t\t\t\t// Only rethrow if it's not our rollback error\n\t\t\t\t\tif (!(error instanceof TestRollback)) {\n\t\t\t\t\t\tthrow error;\n\t\t\t\t\t}\n\n\t\t\t\t\t// If the test had an error, throw it now\n\t\t\t\t\tif (testError) {\n\t\t\t\t\t\tthrow testError;\n\t\t\t\t\t}\n\t\t\t\t} finally {\n\t\t\t\t\tawait this.destroy(conn);\n\t\t\t\t}\n\t\t\t},\n\t\t\t...additionalFixtures,\n\t\t});\n\t}\n}\n\nexport type DatabaseConnectionFn<Conn> = () => Conn | Promise<Conn>;\nexport type DatabaseConnection<Conn> = DatabaseConnectionFn<Conn>;\n\n/**\n * Options for wrapping Vitest tests with database transaction isolation.\n */\nexport interface TransactionWrapperOptions<\n\tTConn,\n\tTransaction,\n\tExtended extends Record<string, unknown> = {},\n> {\n\t/** Function that creates or returns a database connection */\n\tconnection: DatabaseConnection<TConn>;\n\t/** Optional setup function to run within the transaction before each test */\n\tsetup?: (trx: Transaction) => Promise<void>;\n\t/** Transaction isolation level (defaults to REPEATABLE_READ) */\n\tisolationLevel?: IsolationLevel;\n\t/** Additional fixtures that depend on the transaction */\n\tfixtures?: FixtureCreators<Transaction, Extended>;\n}\n\n/**\n * Type for fixture creator functions that depend on the transaction.\n * Each function receives the transaction and returns the fixture value.\n */\nexport type FixtureCreators<\n\tTransaction,\n\tExtended extends Record<string, unknown>,\n> = {\n\t[K in keyof Extended]: (\n\t\ttrx: Transaction,\n\t) => Extended[K] | Promise<Extended[K]>;\n};\n\n/**\n * The test API returned by extendWithFixtures.\n * Provides access to both the transaction (trx) and all extended fixtures.\n *\n * @template Transaction - The transaction type\n * @template Extended - The type of additional fixtures provided\n * @template BaseTest - The base wrapped test type\n */\nexport type TestWithExtendedFixtures<\n\tTransaction,\n\tExtended extends Record<string, unknown>,\n\tBaseTest extends ReturnType<TestAPI['extend']> = ReturnType<\n\t\tTestAPI['extend']\n\t>,\n> = BaseTest & {\n\t<C extends object>(\n\t\tname: string,\n\t\tfn: (\n\t\t\tcontext: DatabaseFixtures<Transaction> & Extended & C,\n\t\t) => Promise<void>,\n\t): void;\n\t<C extends object>(\n\t\tname: string,\n\t\toptions: object,\n\t\tfn: (\n\t\t\tcontext: DatabaseFixtures<Transaction> & Extended & C,\n\t\t) => Promise<void>,\n\t): void;\n};\n\n/**\n * Extends a wrapped test API with additional fixtures that depend on the transaction.\n * This allows composing test context with factories, repositories, or other helpers.\n *\n * @template Transaction - The transaction type\n * @template Extended - The type of additional context to provide\n * @param wrappedTest - The base wrapped test from wrapVitestWithTransaction\n * @param fixtures - Object mapping fixture names to creator functions\n * @returns An extended test API with both trx and the additional fixtures\n *\n * @example\n * ```typescript\n * import { wrapVitestKyselyTransaction, extendWithFixtures } from '@geekmidas/testkit/kysely';\n *\n * // Create base wrapped test\n * const baseTest = wrapVitestKyselyTransaction(test, {\n * connection: db,\n * setup: createTestTables,\n * });\n *\n * // Extend with fixtures\n * const it = extendWithFixtures(baseTest, {\n * factory: (trx) => new KyselyFactory(builders, seeds, trx),\n * userRepo: (trx) => new UserRepository(trx),\n * });\n *\n * // Use in tests - trx and all fixtures are available\n * it('should create user with factory', async ({ trx, factory, userRepo }) => {\n * const user = await factory.insert('user', { name: 'Test' });\n * expect(user).toBeDefined();\n * });\n * ```\n */\nexport function extendWithFixtures<\n\tTransaction,\n\tExtended extends Record<string, unknown>,\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tT extends ReturnType<TestAPI['extend']> = any,\n>(\n\twrappedTest: T,\n\tfixtures: FixtureCreators<Transaction, Extended>,\n): TestWithExtendedFixtures<Transaction, Extended, T> {\n\t// Build fixture definitions for Vitest's extend API\n\tconst fixtureDefinitions: Record<string, any> = {};\n\n\tfor (const [key, creator] of Object.entries(fixtures)) {\n\t\tfixtureDefinitions[key] = async (\n\t\t\t{ trx }: { trx: Transaction },\n\t\t\tuse: (value: unknown) => Promise<void>,\n\t\t) => {\n\t\t\tconst value = await (creator as (trx: Transaction) => unknown)(trx);\n\t\t\tawait use(value);\n\t\t};\n\t}\n\n\treturn (wrappedTest as any).extend(fixtureDefinitions);\n}\n"],"mappings":";;;;;;;;AAgDA,IAAY,4DAAL;;;;;AAKN;;;;;AAKA;;;;;AAKA;;;;;AAKA;;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BD,IAAsB,oCAAtB,MAA4E;;;;;;CAsB3E,YAA6BA,KAAc;EAAd;CAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;CA2B7C,0BACCC,SACC;EACD,MAAM,EACL,YACA,OACA,iBAAiB,eAAe,iBAChC,UACA,GAAG;EAGJ,MAAMC,qBAA8C,CAAE;AACtD,MAAI,SACH,MAAK,MAAM,CAAC,KAAK,QAAQ,IAAI,OAAO,QAAQ,SAAS,CACpD,oBAAmB,OAAO,OACzB,EAAE,KAA2B,EAC7BC,QACI;GACJ,MAAM,QAAQ,MAAM,AAAC,QAA0C,IAAI;AACnE,SAAM,IAAI,MAAM;EAChB;EASH,MAAM,MAAM,KAAK;AAIjB,SAAO,IAAI,OAAyB;GAGnC,KAAK,OAAO,EAAM,EAAEC,QAA+C;IAElE,MAAM,qBAAqB,MAAM;KAChC,cAAc;AACb,YAAM,gBAAgB;AACtB,WAAK,OAAO;KACZ;IACD;IAED,IAAIC;IACJ,MAAM,OAAO,MAAM,YAAY;AAC/B,QAAI;AACH,WAAM,KAAK,SAAS,MAAM,gBAAgB,OAAO,gBAAgB;AAChE,UAAI;AAEH,aAAM,QAAQ,YAAY;AAC1B,aAAM,IAAI,YAAY;MACtB,SAAQ,OAAO;AAEf,mBAAY;MACZ;AAGD,YAAM,IAAI;KACV,EAAC;IACF,SAAQ,OAAO;AAEf,WAAM,iBAAiB,cACtB,OAAM;AAIP,SAAI,UACH,OAAM;IAEP,UAAS;AACT,WAAM,KAAK,QAAQ,KAAK;IACxB;GACD;GACD,GAAG;EACH,EAAC;CACF;AACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmGD,SAAgB,mBAMfC,aACAC,UACqD;CAErD,MAAMC,qBAA0C,CAAE;AAElD,MAAK,MAAM,CAAC,KAAK,QAAQ,IAAI,OAAO,QAAQ,SAAS,CACpD,oBAAmB,OAAO,OACzB,EAAE,KAA2B,EAC7BL,QACI;EACJ,MAAM,QAAQ,MAAM,AAAC,QAA0C,IAAI;AACnE,QAAM,IAAI,MAAM;CAChB;AAGF,QAAO,AAAC,YAAoB,OAAO,mBAAmB;AACtD"}