@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
@@ -1,8 +1,11 @@
1
- import { faker } from "./faker.mjs";
2
- import { ObjectionFactory } from "./ObjectionFactory.mjs";
3
- import { PostgresObjectionMigrator } from "./PostgresObjectionMigrator.mjs";
4
- import { IsolationLevel, extendWithFixtures as extendWithFixtures$1 } from "./VitestTransactionIsolator.mjs";
5
- import { VitestObjectionTransactionIsolator } from "./VitestObjectionTransactionIsolator.mjs";
1
+ import "./Factory-BFVnMMCC.mjs";
2
+ import { faker } from "./faker-BGKYFoCT.mjs";
3
+ import { ObjectionFactory } from "./ObjectionFactory-QCJ7u0Ql.mjs";
4
+ import "./PostgresMigrator-DVAY04qN.mjs";
5
+ import { PostgresObjectionMigrator } from "./PostgresObjectionMigrator-DjPKdUbm.mjs";
6
+ import { IsolationLevel, extendWithFixtures } from "./VitestTransactionIsolator-D6ZxLWys.mjs";
7
+ import { VitestObjectionTransactionIsolator } from "./VitestObjectionTransactionIsolator-CNo40EdC.mjs";
8
+
6
9
  //#region src/objection.ts
7
10
  /**
8
11
  * Creates a wrapped Vitest test API with automatic transaction rollback for Objection.js.
@@ -49,7 +52,8 @@ import { VitestObjectionTransactionIsolator } from "./VitestObjectionTransaction
49
52
  * ```
50
53
  */
51
54
  function wrapVitestObjectionTransaction(api, options) {
52
- return new VitestObjectionTransactionIsolator(api).wrapVitestWithTransaction(options);
55
+ const wrapper = new VitestObjectionTransactionIsolator(api);
56
+ return wrapper.wrapVitestWithTransaction(options);
53
57
  }
54
58
  /**
55
59
  * Extends an Objection.js transaction-wrapped test with additional fixtures.
@@ -99,10 +103,10 @@ function wrapVitestObjectionTransaction(api, options) {
99
103
  * });
100
104
  * ```
101
105
  */
102
- function extendWithFixtures(wrappedTest, fixtures) {
103
- return extendWithFixtures$1(wrappedTest, fixtures);
106
+ function extendWithFixtures$1(wrappedTest, fixtures) {
107
+ return extendWithFixtures(wrappedTest, fixtures);
104
108
  }
105
- //#endregion
106
- export { IsolationLevel, ObjectionFactory, PostgresObjectionMigrator, VitestObjectionTransactionIsolator, extendWithFixtures, faker, wrapVitestObjectionTransaction };
107
109
 
110
+ //#endregion
111
+ export { IsolationLevel, ObjectionFactory, PostgresObjectionMigrator, VitestObjectionTransactionIsolator, extendWithFixtures$1 as extendWithFixtures, faker, wrapVitestObjectionTransaction };
108
112
  //# sourceMappingURL=objection.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"objection.mjs","names":["baseExtendWithFixtures"],"sources":["../src/objection.ts"],"sourcesContent":["import type { Knex } from 'knex';\nimport type { TestAPI } from 'vitest';\nimport { VitestObjectionTransactionIsolator } from './VitestObjectionTransactionIsolator';\nimport {\n\textendWithFixtures as baseExtendWithFixtures,\n\ttype DatabaseConnection,\n\ttype FixtureCreators,\n\ttype IsolationLevel,\n} from './VitestTransactionIsolator';\n\n/**\n * Objection.js-specific exports for test utilities.\n * Provides factory implementation for creating test data with Objection.js ORM\n * and transaction isolation for test suites.\n */\n\nexport type { ExtractSeedAttrs, FactorySeed } from './Factory';\nexport { ObjectionFactory } from './ObjectionFactory';\nexport { PostgresObjectionMigrator } from './PostgresObjectionMigrator';\nexport { VitestObjectionTransactionIsolator } from './VitestObjectionTransactionIsolator';\nexport type {\n\tDatabaseFixtures,\n\tExtendedDatabaseFixtures,\n\tFixtureCreators,\n\tTestWithExtendedFixtures,\n\tTransactionWrapperOptions,\n} from './VitestTransactionIsolator';\nexport { IsolationLevel } from './VitestTransactionIsolator';\n\n/**\n * Objection.js-specific options for transaction wrapping.\n */\nexport interface ObjectionTransactionOptions<\n\tExtended extends Record<string, unknown> = {},\n> {\n\t/** Function that creates or returns a Knex database connection */\n\tconnection: DatabaseConnection<Knex>;\n\t/** Optional setup function to run within the transaction before each test */\n\tsetup?: (trx: Knex.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<Knex.Transaction, Extended>;\n}\n\n// Re-export faker and FakerFactory for type portability in declaration files\nexport { type FakerFactory, faker } from './faker';\n\n/**\n * Creates a wrapped Vitest test API with automatic transaction rollback for Objection.js.\n * Each test runs in an isolated database transaction that is rolled back after completion.\n * This ensures tests don't affect each other's data and run faster than truncating tables.\n *\n * @template Extended - Additional fixtures to provide\n * @param api - The Vitest test API (usually `test` from vitest)\n * @param options - Configuration options for transaction wrapping\n * @returns A wrapped test API that provides transaction isolation\n *\n * @example\n * ```typescript\n * import { test } from 'vitest';\n * import { wrapVitestObjectionTransaction } from '@geekmidas/testkit/objection';\n * import { knex } from './database';\n * import { User } from './models';\n *\n * // Create isolated test with automatic rollback\n * const isolatedTest = wrapVitestObjectionTransaction(test, {\n * connection: knex,\n * });\n *\n * // Use in tests - each test gets its own transaction\n * isolatedTest('should create user', async ({ trx }) => {\n * const user = await User.query(trx)\n * .insert({ name: 'Test User', email: 'test@example.com' });\n *\n * expect(user).toBeDefined();\n * });\n *\n * // With fixtures for factories\n * const it = wrapVitestObjectionTransaction<{ factory: Factory }>(test, {\n * connection: knex,\n * fixtures: {\n * factory: (trx) => new Factory(trx),\n * },\n * });\n *\n * it('should create user with factory', async ({ trx, factory }) => {\n * const user = await factory.insert('user', { name: 'Test' });\n * expect(user.id).toBeDefined();\n * });\n * ```\n */\nexport function wrapVitestObjectionTransaction<\n\tExtended extends Record<string, unknown> = {},\n>(api: TestAPI, options: ObjectionTransactionOptions<Extended>) {\n\tconst wrapper = new VitestObjectionTransactionIsolator(api);\n\n\treturn wrapper.wrapVitestWithTransaction(options);\n}\n\n/**\n * Extends an Objection.js transaction-wrapped test with additional fixtures.\n * Each fixture receives the transaction and can create dependencies like factories or repositories.\n *\n * @template Extended - The type of additional fixtures to provide\n * @param wrappedTest - The base wrapped test from wrapVitestObjectionTransaction\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 { test } from 'vitest';\n * import { wrapVitestObjectionTransaction, extendWithFixtures, ObjectionFactory } from '@geekmidas/testkit/objection';\n * import { User } from './models';\n *\n * // Define your builders\n * const builders = {\n * user: ObjectionFactory.createBuilder(User, ({ faker }) => ({\n * name: faker.person.fullName(),\n * email: faker.internet.email(),\n * })),\n * };\n *\n * // Create base wrapped test\n * const baseTest = wrapVitestObjectionTransaction(test, {\n * connection: knex,\n * setup: createTestTables,\n * });\n *\n * // Extend with fixtures - each fixture receives the transaction\n * const it = extendWithFixtures<{ factory: ObjectionFactory<typeof builders, {}> }>(\n * baseTest,\n * {\n * factory: (trx) => new ObjectionFactory(builders, {}, trx),\n * }\n * );\n *\n * // Use in tests - both trx and factory are available\n * it('should create user with factory', async ({ trx, factory }) => {\n * const user = await factory.insert('user', { name: 'Test User' });\n * expect(user.id).toBeDefined();\n *\n * // Verify in database\n * const found = await User.query(trx).findById(user.id);\n * expect(found?.name).toBe('Test User');\n * });\n * ```\n */\nexport function extendWithFixtures<\n\tExtended extends Record<string, unknown>,\n\tT extends ReturnType<TestAPI['extend']> = ReturnType<TestAPI['extend']>,\n>(wrappedTest: T, fixtures: FixtureCreators<Knex.Transaction, Extended>) {\n\treturn baseExtendWithFixtures<Knex.Transaction, Extended, T>(\n\t\twrappedTest,\n\t\tfixtures,\n\t);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4FA,SAAgB,+BAEd,KAAc,SAAgD;CAG/D,OAAO,IAFa,mCAAmC,GAE1C,CAAC,CAAC,0BAA0B,OAAO;AACjD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkDA,SAAgB,mBAGd,aAAgB,UAAuD;CACxE,OAAOA,qBACN,aACA,QACD;AACD"}
1
+ {"version":3,"file":"objection.mjs","names":["api: TestAPI","options: ObjectionTransactionOptions<Extended>","extendWithFixtures","wrappedTest: T","fixtures: FixtureCreators<Knex.Transaction, Extended>"],"sources":["../src/objection.ts"],"sourcesContent":["import type { Knex } from 'knex';\nimport type { TestAPI } from 'vitest';\nimport { VitestObjectionTransactionIsolator } from './VitestObjectionTransactionIsolator';\nimport {\n\textendWithFixtures as baseExtendWithFixtures,\n\ttype DatabaseConnection,\n\ttype FixtureCreators,\n\ttype IsolationLevel,\n} from './VitestTransactionIsolator';\n\n/**\n * Objection.js-specific exports for test utilities.\n * Provides factory implementation for creating test data with Objection.js ORM\n * and transaction isolation for test suites.\n */\n\nexport type { ExtractSeedAttrs, FactorySeed } from './Factory';\nexport { ObjectionFactory } from './ObjectionFactory';\nexport { PostgresObjectionMigrator } from './PostgresObjectionMigrator';\nexport { VitestObjectionTransactionIsolator } from './VitestObjectionTransactionIsolator';\nexport type {\n\tDatabaseFixtures,\n\tExtendedDatabaseFixtures,\n\tFixtureCreators,\n\tTestWithExtendedFixtures,\n\tTransactionWrapperOptions,\n} from './VitestTransactionIsolator';\nexport { IsolationLevel } from './VitestTransactionIsolator';\n\n/**\n * Objection.js-specific options for transaction wrapping.\n */\nexport interface ObjectionTransactionOptions<\n\tExtended extends Record<string, unknown> = {},\n> {\n\t/** Function that creates or returns a Knex database connection */\n\tconnection: DatabaseConnection<Knex>;\n\t/** Optional setup function to run within the transaction before each test */\n\tsetup?: (trx: Knex.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<Knex.Transaction, Extended>;\n}\n\n// Re-export faker and FakerFactory for type portability in declaration files\nexport { type FakerFactory, faker } from './faker';\n\n/**\n * Creates a wrapped Vitest test API with automatic transaction rollback for Objection.js.\n * Each test runs in an isolated database transaction that is rolled back after completion.\n * This ensures tests don't affect each other's data and run faster than truncating tables.\n *\n * @template Extended - Additional fixtures to provide\n * @param api - The Vitest test API (usually `test` from vitest)\n * @param options - Configuration options for transaction wrapping\n * @returns A wrapped test API that provides transaction isolation\n *\n * @example\n * ```typescript\n * import { test } from 'vitest';\n * import { wrapVitestObjectionTransaction } from '@geekmidas/testkit/objection';\n * import { knex } from './database';\n * import { User } from './models';\n *\n * // Create isolated test with automatic rollback\n * const isolatedTest = wrapVitestObjectionTransaction(test, {\n * connection: knex,\n * });\n *\n * // Use in tests - each test gets its own transaction\n * isolatedTest('should create user', async ({ trx }) => {\n * const user = await User.query(trx)\n * .insert({ name: 'Test User', email: 'test@example.com' });\n *\n * expect(user).toBeDefined();\n * });\n *\n * // With fixtures for factories\n * const it = wrapVitestObjectionTransaction<{ factory: Factory }>(test, {\n * connection: knex,\n * fixtures: {\n * factory: (trx) => new Factory(trx),\n * },\n * });\n *\n * it('should create user with factory', async ({ trx, factory }) => {\n * const user = await factory.insert('user', { name: 'Test' });\n * expect(user.id).toBeDefined();\n * });\n * ```\n */\nexport function wrapVitestObjectionTransaction<\n\tExtended extends Record<string, unknown> = {},\n>(api: TestAPI, options: ObjectionTransactionOptions<Extended>) {\n\tconst wrapper = new VitestObjectionTransactionIsolator(api);\n\n\treturn wrapper.wrapVitestWithTransaction(options);\n}\n\n/**\n * Extends an Objection.js transaction-wrapped test with additional fixtures.\n * Each fixture receives the transaction and can create dependencies like factories or repositories.\n *\n * @template Extended - The type of additional fixtures to provide\n * @param wrappedTest - The base wrapped test from wrapVitestObjectionTransaction\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 { test } from 'vitest';\n * import { wrapVitestObjectionTransaction, extendWithFixtures, ObjectionFactory } from '@geekmidas/testkit/objection';\n * import { User } from './models';\n *\n * // Define your builders\n * const builders = {\n * user: ObjectionFactory.createBuilder(User, ({ faker }) => ({\n * name: faker.person.fullName(),\n * email: faker.internet.email(),\n * })),\n * };\n *\n * // Create base wrapped test\n * const baseTest = wrapVitestObjectionTransaction(test, {\n * connection: knex,\n * setup: createTestTables,\n * });\n *\n * // Extend with fixtures - each fixture receives the transaction\n * const it = extendWithFixtures<{ factory: ObjectionFactory<typeof builders, {}> }>(\n * baseTest,\n * {\n * factory: (trx) => new ObjectionFactory(builders, {}, trx),\n * }\n * );\n *\n * // Use in tests - both trx and factory are available\n * it('should create user with factory', async ({ trx, factory }) => {\n * const user = await factory.insert('user', { name: 'Test User' });\n * expect(user.id).toBeDefined();\n *\n * // Verify in database\n * const found = await User.query(trx).findById(user.id);\n * expect(found?.name).toBe('Test User');\n * });\n * ```\n */\nexport function extendWithFixtures<\n\tExtended extends Record<string, unknown>,\n\tT extends ReturnType<TestAPI['extend']> = ReturnType<TestAPI['extend']>,\n>(wrappedTest: T, fixtures: FixtureCreators<Knex.Transaction, Extended>) {\n\treturn baseExtendWithFixtures<Knex.Transaction, Extended, T>(\n\t\twrappedTest,\n\t\tfixtures,\n\t);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4FA,SAAgB,+BAEdA,KAAcC,SAAgD;CAC/D,MAAM,UAAU,IAAI,mCAAmC;AAEvD,QAAO,QAAQ,0BAA0B,QAAQ;AACjD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkDD,SAAgBC,qBAGdC,aAAgBC,UAAuD;AACxE,QAAO,mBACN,aACA,SACA;AACD"}
@@ -1,32 +1,3 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_rolldown_runtime = require("../rolldown-runtime-VH7oDXx4.cjs");
3
- let vitest = require("vitest");
4
- let node_crypto = require("node:crypto");
5
- node_crypto = require_rolldown_runtime.__toESM(node_crypto, 1);
6
- let node_fs_promises = require("node:fs/promises");
7
- node_fs_promises = require_rolldown_runtime.__toESM(node_fs_promises, 1);
8
- let node_os = require("node:os");
9
- node_os = require_rolldown_runtime.__toESM(node_os, 1);
10
- let node_path = require("node:path");
11
- node_path = require_rolldown_runtime.__toESM(node_path, 1);
12
- //#region src/os/directory.ts
13
- const itWithDir = vitest.it.extend({ dir: async ({}, use) => {
14
- const tempDir = node_os.default.tmpdir();
15
- const directoryName = node_crypto.default.randomUUID().replace(/-/g, "").toUpperCase();
16
- const dir = node_path.default.join(tempDir, directoryName);
17
- await node_fs_promises.default.mkdir(dir, { recursive: true });
18
- await use(dir);
19
- await node_fs_promises.default.rm(dir, {
20
- recursive: true,
21
- force: true
22
- });
23
- const keystoreDir = node_path.default.join(node_os.default.homedir(), ".gkm", directoryName);
24
- await node_fs_promises.default.rm(keystoreDir, {
25
- recursive: true,
26
- force: true
27
- });
28
- } });
29
- //#endregion
30
- exports.itWithDir = itWithDir;
1
+ const require_directory = require('../directory-DD_xQoSh.cjs');
31
2
 
32
- //# sourceMappingURL=directory.cjs.map
3
+ exports.itWithDir = require_directory.itWithDir;
@@ -1,9 +1,2 @@
1
- //#region src/os/directory.d.ts
2
- export declare const itWithDir: import("vitest").TestAPI<{
3
- dir: string;
4
- }>;
5
- export interface DirectoryFixtures {
6
- dir: string;
7
- }
8
- //#endregion
9
- //# sourceMappingURL=directory.d.cts.map
1
+ import { DirectoryFixtures, itWithDir } from "../directory-Bpz5c5pj.cjs";
2
+ export { DirectoryFixtures, itWithDir };
@@ -1,9 +1,2 @@
1
- //#region src/os/directory.d.ts
2
- export declare const itWithDir: import("vitest").TestAPI<{
3
- dir: string;
4
- }>;
5
- export interface DirectoryFixtures {
6
- dir: string;
7
- }
8
- //#endregion
9
- //# sourceMappingURL=directory.d.mts.map
1
+ import { DirectoryFixtures, itWithDir } from "../directory-CVrfTq1I.mjs";
2
+ export { DirectoryFixtures, itWithDir };
@@ -1,26 +1,3 @@
1
- import { it } from "vitest";
2
- import crypto from "node:crypto";
3
- import fs from "node:fs/promises";
4
- import os from "node:os";
5
- import path from "node:path";
6
- //#region src/os/directory.ts
7
- const itWithDir = it.extend({ dir: async ({}, use) => {
8
- const tempDir = os.tmpdir();
9
- const directoryName = crypto.randomUUID().replace(/-/g, "").toUpperCase();
10
- const dir = path.join(tempDir, directoryName);
11
- await fs.mkdir(dir, { recursive: true });
12
- await use(dir);
13
- await fs.rm(dir, {
14
- recursive: true,
15
- force: true
16
- });
17
- const keystoreDir = path.join(os.homedir(), ".gkm", directoryName);
18
- await fs.rm(keystoreDir, {
19
- recursive: true,
20
- force: true
21
- });
22
- } });
23
- //#endregion
24
- export { itWithDir };
1
+ import { itWithDir } from "../directory-BxjqmtCT.mjs";
25
2
 
26
- //# sourceMappingURL=directory.mjs.map
3
+ export { itWithDir };
package/dist/os/index.cjs CHANGED
@@ -1,3 +1,3 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_os_directory = require("./directory.cjs");
3
- exports.itWithDir = require_os_directory.itWithDir;
1
+ const require_directory = require('../directory-DD_xQoSh.cjs');
2
+
3
+ exports.itWithDir = require_directory.itWithDir;
@@ -1,2 +1,2 @@
1
- import { itWithDir } from "./directory.cjs";
1
+ import { itWithDir } from "../directory-Bpz5c5pj.cjs";
2
2
  export { itWithDir };
@@ -1,2 +1,2 @@
1
- import { itWithDir } from "./directory.mjs";
1
+ import { itWithDir } from "../directory-CVrfTq1I.mjs";
2
2
  export { itWithDir };
package/dist/os/index.mjs CHANGED
@@ -1,2 +1,3 @@
1
- import { itWithDir } from "./directory.mjs";
2
- export { itWithDir };
1
+ import { itWithDir } from "../directory-BxjqmtCT.mjs";
2
+
3
+ export { itWithDir };
@@ -1,11 +1,12 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- let _geekmidas_services = require("@geekmidas/services");
3
- let node_crypto = require("node:crypto");
4
- let _geekmidas_logger_console = require("@geekmidas/logger/console");
1
+ const require_chunk = require('./chunk-CUT6urMc.cjs');
2
+ const node_crypto = require_chunk.__toESM(require("node:crypto"));
3
+ const __geekmidas_logger_console = require_chunk.__toESM(require("@geekmidas/logger/console"));
4
+ const __geekmidas_services = require_chunk.__toESM(require("@geekmidas/services"));
5
+
5
6
  //#region src/requestContext.ts
6
7
  function resolveContext(opts = {}) {
7
8
  return {
8
- logger: opts.logger ?? new _geekmidas_logger_console.ConsoleLogger({ app: "test" }),
9
+ logger: opts.logger ?? new __geekmidas_logger_console.ConsoleLogger({ app: "test" }),
9
10
  requestId: opts.requestId ?? (0, node_crypto.randomUUID)(),
10
11
  startTime: opts.startTime ?? Date.now()
11
12
  };
@@ -23,7 +24,7 @@ function resolveContext(opts = {}) {
23
24
  * ```
24
25
  */
25
26
  function runInRequestContext(fn, opts = {}) {
26
- return (0, _geekmidas_services.runWithRequestContext)(resolveContext(opts), fn);
27
+ return (0, __geekmidas_services.runWithRequestContext)(resolveContext(opts), fn);
27
28
  }
28
29
  /**
29
30
  * Vitest fixture creator. Spread the result into `.extend()` and every test
@@ -42,11 +43,11 @@ function runInRequestContext(fn, opts = {}) {
42
43
  */
43
44
  function requestContextFixture(opts = {}) {
44
45
  return { requestContext: [async ({}, use) => {
45
- (0, _geekmidas_services.enterRequestContext)(resolveContext(opts));
46
+ (0, __geekmidas_services.enterRequestContext)(resolveContext(opts));
46
47
  try {
47
- await use(_geekmidas_services.serviceContext);
48
+ await use(__geekmidas_services.serviceContext);
48
49
  } finally {
49
- (0, _geekmidas_services.exitRequestContext)();
50
+ (0, __geekmidas_services.exitRequestContext)();
50
51
  }
51
52
  }, { auto: true }] };
52
53
  }
@@ -71,9 +72,9 @@ function requestContextFixture(opts = {}) {
71
72
  function withRequestContext(testApi, opts = {}) {
72
73
  return testApi.extend(requestContextFixture(opts));
73
74
  }
75
+
74
76
  //#endregion
75
77
  exports.requestContextFixture = requestContextFixture;
76
78
  exports.runInRequestContext = runInRequestContext;
77
79
  exports.withRequestContext = withRequestContext;
78
-
79
80
  //# sourceMappingURL=requestContext.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"requestContext.cjs","names":["ConsoleLogger","randomUUID","runWithRequestContext","serviceContext"],"sources":["../src/requestContext.ts"],"sourcesContent":["import { randomUUID } from 'node:crypto';\nimport type { Logger } from '@geekmidas/logger';\nimport { ConsoleLogger } from '@geekmidas/logger/console';\nimport {\n\tenterRequestContext,\n\texitRequestContext,\n\trunWithRequestContext,\n\ttype ServiceContext,\n\tserviceContext,\n} from '@geekmidas/services';\nimport type { TestAPI } from 'vitest';\n\n/**\n * Options for setting up a request context in tests. Any field omitted\n * is filled with a test-friendly default (ConsoleLogger, random UUID,\n * Date.now()).\n */\nexport interface RequestContextOptions {\n\t/** Logger exposed via serviceContext.getLogger(). */\n\tlogger?: Logger;\n\t/** Request id exposed via serviceContext.getRequestId(). */\n\trequestId?: string;\n\t/** Start time exposed via serviceContext.getRequestStartTime(). */\n\tstartTime?: number;\n}\n\nfunction resolveContext(opts: RequestContextOptions = {}) {\n\treturn {\n\t\tlogger: opts.logger ?? new ConsoleLogger({ app: 'test' }),\n\t\trequestId: opts.requestId ?? randomUUID(),\n\t\tstartTime: opts.startTime ?? Date.now(),\n\t};\n}\n\n/**\n * Run a function inside a request context with test-friendly defaults.\n * Useful when you need `serviceContext` to be available for a single call\n * (e.g. invoking `Service.register({ context })` outside a wrapped test).\n *\n * @example\n * ```ts\n * await runInRequestContext(() =>\n * discovery.register([databaseService]),\n * );\n * ```\n */\nexport function runInRequestContext<T>(\n\tfn: () => T | Promise<T>,\n\topts: RequestContextOptions = {},\n): T | Promise<T> {\n\treturn runWithRequestContext(resolveContext(opts), fn);\n}\n\n/**\n * Vitest fixture creator. Spread the result into `.extend()` and every test\n * runs inside `runWithRequestContext`, even tests that don't destructure\n * `requestContext` directly (the fixture is registered as `auto`).\n *\n * @example\n * ```ts\n * const it = test.extend({ ...requestContextFixture() });\n *\n * it('registers services with context', async ({ requestContext }) => {\n * await discovery.register([databaseService]);\n * expect(requestContext.getRequestId()).toBeDefined();\n * });\n * ```\n */\nexport function requestContextFixture(opts: RequestContextOptions = {}) {\n\treturn {\n\t\trequestContext: [\n\t\t\tasync (\n\t\t\t\t// biome-ignore lint/correctness/noEmptyPattern: vitest fixture signature\n\t\t\t\t{}: {},\n\t\t\t\tuse: (value: ServiceContext) => Promise<void>,\n\t\t\t) => {\n\t\t\t\t// Vitest suspends the fixture on `await use(...)` and runs the test\n\t\t\t\t// body in a continuation of the runner's async context. A scoped\n\t\t\t\t// `runWithRequestContext` callback ends as soon as we hand control\n\t\t\t\t// to the runner, so the test body would see no context. Instead,\n\t\t\t\t// mutate the current task's store with `enterRequestContext` —\n\t\t\t\t// async/await preserves that store across the suspension, so the\n\t\t\t\t// test body sees it. We restore on the way out so subsequent tests\n\t\t\t\t// don't inherit the value.\n\t\t\t\tenterRequestContext(resolveContext(opts));\n\t\t\t\ttry {\n\t\t\t\t\tawait use(serviceContext);\n\t\t\t\t} finally {\n\t\t\t\t\texitRequestContext();\n\t\t\t\t}\n\t\t\t},\n\t\t\t{ auto: true },\n\t\t] as const,\n\t};\n}\n\n/**\n * Wrap any Vitest `TestAPI` (including the one returned by\n * `wrapVitestKyselyTransaction`) so every test runs inside\n * `runWithRequestContext`. Compose with the transaction wrappers:\n *\n * @example\n * ```ts\n * import { wrapVitestKyselyTransaction } from '@geekmidas/testkit/kysely';\n * import { withRequestContext } from '@geekmidas/testkit/request-context';\n *\n * const baseIt = wrapVitestKyselyTransaction<DB>(it, { connection: db });\n * const itWithCtx = withRequestContext(baseIt);\n *\n * itWithCtx('runs inside trx + context', async ({ trx, requestContext }) => {\n * // serviceContext is set up; Service.register({ context }) works here.\n * });\n * ```\n */\nexport function withRequestContext<\n\tT extends TestAPI | ReturnType<TestAPI['extend']>,\n>(testApi: T, opts: RequestContextOptions = {}): T {\n\treturn (testApi as any).extend(requestContextFixture(opts));\n}\n"],"mappings":";;;;;AA0BA,SAAS,eAAe,OAA8B,CAAC,GAAG;CACzD,OAAO;EACN,QAAQ,KAAK,UAAU,IAAIA,0BAAAA,cAAc,EAAE,KAAK,OAAO,CAAC;EACxD,WAAW,KAAK,cAAA,GAAaC,YAAAA,WAAAA,CAAW;EACxC,WAAW,KAAK,aAAa,KAAK,IAAI;CACvC;AACD;;;;;;;;;;;;;AAcA,SAAgB,oBACf,IACA,OAA8B,CAAC,GACd;CACjB,QAAA,GAAOC,oBAAAA,sBAAAA,CAAsB,eAAe,IAAI,GAAG,EAAE;AACtD;;;;;;;;;;;;;;;;AAiBA,SAAgB,sBAAsB,OAA8B,CAAC,GAAG;CACvE,OAAO,EACN,gBAAgB,CACf,OAEC,IACA,QACI;EASJ,CAAA,GAAA,oBAAA,oBAAA,CAAoB,eAAe,IAAI,CAAC;EACxC,IAAI;GACH,MAAM,IAAIC,oBAAAA,cAAc;EACzB,UAAU;GACT,CAAA,GAAA,oBAAA,mBAAA,CAAmB;EACpB;CACD,GACA,EAAE,MAAM,KAAK,CACd,EACD;AACD;;;;;;;;;;;;;;;;;;;AAoBA,SAAgB,mBAEd,SAAY,OAA8B,CAAC,GAAM;CAClD,OAAQ,QAAgB,OAAO,sBAAsB,IAAI,CAAC;AAC3D"}
1
+ {"version":3,"file":"requestContext.cjs","names":["opts: RequestContextOptions","ConsoleLogger","fn: () => T | Promise<T>","use: (value: ServiceContext) => Promise<void>","serviceContext","testApi: T"],"sources":["../src/requestContext.ts"],"sourcesContent":["import { randomUUID } from 'node:crypto';\nimport type { Logger } from '@geekmidas/logger';\nimport { ConsoleLogger } from '@geekmidas/logger/console';\nimport {\n\tenterRequestContext,\n\texitRequestContext,\n\trunWithRequestContext,\n\ttype ServiceContext,\n\tserviceContext,\n} from '@geekmidas/services';\nimport type { TestAPI } from 'vitest';\n\n/**\n * Options for setting up a request context in tests. Any field omitted\n * is filled with a test-friendly default (ConsoleLogger, random UUID,\n * Date.now()).\n */\nexport interface RequestContextOptions {\n\t/** Logger exposed via serviceContext.getLogger(). */\n\tlogger?: Logger;\n\t/** Request id exposed via serviceContext.getRequestId(). */\n\trequestId?: string;\n\t/** Start time exposed via serviceContext.getRequestStartTime(). */\n\tstartTime?: number;\n}\n\nfunction resolveContext(opts: RequestContextOptions = {}) {\n\treturn {\n\t\tlogger: opts.logger ?? new ConsoleLogger({ app: 'test' }),\n\t\trequestId: opts.requestId ?? randomUUID(),\n\t\tstartTime: opts.startTime ?? Date.now(),\n\t};\n}\n\n/**\n * Run a function inside a request context with test-friendly defaults.\n * Useful when you need `serviceContext` to be available for a single call\n * (e.g. invoking `Service.register({ context })` outside a wrapped test).\n *\n * @example\n * ```ts\n * await runInRequestContext(() =>\n * discovery.register([databaseService]),\n * );\n * ```\n */\nexport function runInRequestContext<T>(\n\tfn: () => T | Promise<T>,\n\topts: RequestContextOptions = {},\n): T | Promise<T> {\n\treturn runWithRequestContext(resolveContext(opts), fn);\n}\n\n/**\n * Vitest fixture creator. Spread the result into `.extend()` and every test\n * runs inside `runWithRequestContext`, even tests that don't destructure\n * `requestContext` directly (the fixture is registered as `auto`).\n *\n * @example\n * ```ts\n * const it = test.extend({ ...requestContextFixture() });\n *\n * it('registers services with context', async ({ requestContext }) => {\n * await discovery.register([databaseService]);\n * expect(requestContext.getRequestId()).toBeDefined();\n * });\n * ```\n */\nexport function requestContextFixture(opts: RequestContextOptions = {}) {\n\treturn {\n\t\trequestContext: [\n\t\t\tasync (\n\t\t\t\t// biome-ignore lint/correctness/noEmptyPattern: vitest fixture signature\n\t\t\t\t{}: {},\n\t\t\t\tuse: (value: ServiceContext) => Promise<void>,\n\t\t\t) => {\n\t\t\t\t// Vitest suspends the fixture on `await use(...)` and runs the test\n\t\t\t\t// body in a continuation of the runner's async context. A scoped\n\t\t\t\t// `runWithRequestContext` callback ends as soon as we hand control\n\t\t\t\t// to the runner, so the test body would see no context. Instead,\n\t\t\t\t// mutate the current task's store with `enterRequestContext` —\n\t\t\t\t// async/await preserves that store across the suspension, so the\n\t\t\t\t// test body sees it. We restore on the way out so subsequent tests\n\t\t\t\t// don't inherit the value.\n\t\t\t\tenterRequestContext(resolveContext(opts));\n\t\t\t\ttry {\n\t\t\t\t\tawait use(serviceContext);\n\t\t\t\t} finally {\n\t\t\t\t\texitRequestContext();\n\t\t\t\t}\n\t\t\t},\n\t\t\t{ auto: true },\n\t\t] as const,\n\t};\n}\n\n/**\n * Wrap any Vitest `TestAPI` (including the one returned by\n * `wrapVitestKyselyTransaction`) so every test runs inside\n * `runWithRequestContext`. Compose with the transaction wrappers:\n *\n * @example\n * ```ts\n * import { wrapVitestKyselyTransaction } from '@geekmidas/testkit/kysely';\n * import { withRequestContext } from '@geekmidas/testkit/request-context';\n *\n * const baseIt = wrapVitestKyselyTransaction<DB>(it, { connection: db });\n * const itWithCtx = withRequestContext(baseIt);\n *\n * itWithCtx('runs inside trx + context', async ({ trx, requestContext }) => {\n * // serviceContext is set up; Service.register({ context }) works here.\n * });\n * ```\n */\nexport function withRequestContext<\n\tT extends TestAPI | ReturnType<TestAPI['extend']>,\n>(testApi: T, opts: RequestContextOptions = {}): T {\n\treturn (testApi as any).extend(requestContextFixture(opts));\n}\n"],"mappings":";;;;;;AA0BA,SAAS,eAAeA,OAA8B,CAAE,GAAE;AACzD,QAAO;EACN,QAAQ,KAAK,UAAU,IAAIC,yCAAc,EAAE,KAAK,OAAQ;EACxD,WAAW,KAAK,aAAa,6BAAY;EACzC,WAAW,KAAK,aAAa,KAAK,KAAK;CACvC;AACD;;;;;;;;;;;;;AAcD,SAAgB,oBACfC,IACAF,OAA8B,CAAE,GACf;AACjB,QAAO,gDAAsB,eAAe,KAAK,EAAE,GAAG;AACtD;;;;;;;;;;;;;;;;AAiBD,SAAgB,sBAAsBA,OAA8B,CAAE,GAAE;AACvE,QAAO,EACN,gBAAgB,CACf,OAEC,EAAM,EACNG,QACI;AASJ,gDAAoB,eAAe,KAAK,CAAC;AACzC,MAAI;AACH,SAAM,IAAIC,oCAAe;EACzB,UAAS;AACT,iDAAoB;EACpB;CACD,GACD,EAAE,MAAM,KAAM,CACd,EACD;AACD;;;;;;;;;;;;;;;;;;;AAoBD,SAAgB,mBAEdC,SAAYL,OAA8B,CAAE,GAAK;AAClD,QAAO,AAAC,QAAgB,OAAO,sBAAsB,KAAK,CAAC;AAC3D"}
@@ -1,13 +1,15 @@
1
- import { ServiceContext } from "@geekmidas/services";
2
1
  import { TestAPI } from "vitest";
3
2
  import { Logger } from "@geekmidas/logger";
3
+ import { ServiceContext } from "@geekmidas/services";
4
+
4
5
  //#region src/requestContext.d.ts
6
+
5
7
  /**
6
8
  * Options for setting up a request context in tests. Any field omitted
7
9
  * is filled with a test-friendly default (ConsoleLogger, random UUID,
8
10
  * Date.now()).
9
11
  */
10
- export interface RequestContextOptions {
12
+ interface RequestContextOptions {
11
13
  /** Logger exposed via serviceContext.getLogger(). */
12
14
  logger?: Logger;
13
15
  /** Request id exposed via serviceContext.getRequestId(). */
@@ -27,7 +29,7 @@ export interface RequestContextOptions {
27
29
  * );
28
30
  * ```
29
31
  */
30
- export declare function runInRequestContext<T>(fn: () => T | Promise<T>, opts?: RequestContextOptions): T | Promise<T>;
32
+ declare function runInRequestContext<T>(fn: () => T | Promise<T>, opts?: RequestContextOptions): T | Promise<T>;
31
33
  /**
32
34
  * Vitest fixture creator. Spread the result into `.extend()` and every test
33
35
  * runs inside `runWithRequestContext`, even tests that don't destructure
@@ -43,7 +45,7 @@ export declare function runInRequestContext<T>(fn: () => T | Promise<T>, opts?:
43
45
  * });
44
46
  * ```
45
47
  */
46
- export declare function requestContextFixture(opts?: RequestContextOptions): {
48
+ declare function requestContextFixture(opts?: RequestContextOptions): {
47
49
  requestContext: readonly [({}: {}, use: (value: ServiceContext) => Promise<void>) => Promise<void>, {
48
50
  readonly auto: true;
49
51
  }];
@@ -66,6 +68,8 @@ export declare function requestContextFixture(opts?: RequestContextOptions): {
66
68
  * });
67
69
  * ```
68
70
  */
69
- export declare function withRequestContext<T extends TestAPI | ReturnType<TestAPI['extend']>>(testApi: T, opts?: RequestContextOptions): T;
71
+ declare function withRequestContext<T extends TestAPI | ReturnType<TestAPI['extend']>>(testApi: T, opts?: RequestContextOptions): T;
72
+ //# sourceMappingURL=requestContext.d.ts.map
70
73
  //#endregion
74
+ export { RequestContextOptions, requestContextFixture, runInRequestContext, withRequestContext };
71
75
  //# sourceMappingURL=requestContext.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"requestContext.d.cts","names":[],"sources":["../src/requestContext.ts"],"mappings":";;;;;;;;;iBAiBiB;;EAEhB,SAAS;;EAET;;EAEA;;;;;;;;;;;;;;wBAuBe,oBAAoB,GACnC,UAAU,IAAI,QAAQ,IACtB,OAAM,wBACJ,IAAI,QAAQ;;;;;;;;;;;;;;;;wBAmBC,sBAAsB,OAAM;EAE1C,mCAGQ,MACA,OAAO,mBAAmB,kBAAa;aAiB5C;;;;;;;;;;;;;;;;;;;;;wBAuBW,mBACf,UAAU,UAAU,WAAW,oBAC9B,SAAS,GAAG,OAAM,wBAA6B"}
1
+ {"version":3,"file":"requestContext.d.cts","names":[],"sources":["../src/requestContext.ts"],"sourcesContent":[],"mappings":";;;;;;;;AAiBA;AA6BA;;AACW,UA9BM,qBAAA,CA8BN;EAAC;EAAY,MAAT,CAAA,EA5BL,MA4BK;EAAO;EACW,SAC9B,CAAA,EAAA,MAAA;EAAC;EAAY,SAAT,CAAA,EAAA,MAAA;AAAO;AAmBd;;;;;;AAMiD;AAwCjD;;;;;AAEW,iBAtEK,mBAsEL,CAAA,CAAA,CAAA,CAAA,EAAA,EAAA,GAAA,GArEA,CAqEA,GArEI,OAqEJ,CArEY,CAqEZ,CAAA,EAAA,IAAA,CAAA,EApEJ,qBAoEI,CAAA,EAnER,CAmEQ,GAnEJ,OAmEI,CAnEI,CAmEJ,CAAA;;;AAAuC;;;;;;;;;;;;;iBAhDlC,qBAAA,QAA4B;kDAM3B,mBAAmB,kBAAa;;;;;;;;;;;;;;;;;;;;;;iBAwCjC,6BACL,UAAU,WAAW,6BACrB,UAAS,wBAA6B"}
@@ -1,13 +1,15 @@
1
- import { ServiceContext } from "@geekmidas/services";
2
1
  import { TestAPI } from "vitest";
2
+ import { ServiceContext } from "@geekmidas/services";
3
3
  import { Logger } from "@geekmidas/logger";
4
+
4
5
  //#region src/requestContext.d.ts
6
+
5
7
  /**
6
8
  * Options for setting up a request context in tests. Any field omitted
7
9
  * is filled with a test-friendly default (ConsoleLogger, random UUID,
8
10
  * Date.now()).
9
11
  */
10
- export interface RequestContextOptions {
12
+ interface RequestContextOptions {
11
13
  /** Logger exposed via serviceContext.getLogger(). */
12
14
  logger?: Logger;
13
15
  /** Request id exposed via serviceContext.getRequestId(). */
@@ -27,7 +29,7 @@ export interface RequestContextOptions {
27
29
  * );
28
30
  * ```
29
31
  */
30
- export declare function runInRequestContext<T>(fn: () => T | Promise<T>, opts?: RequestContextOptions): T | Promise<T>;
32
+ declare function runInRequestContext<T>(fn: () => T | Promise<T>, opts?: RequestContextOptions): T | Promise<T>;
31
33
  /**
32
34
  * Vitest fixture creator. Spread the result into `.extend()` and every test
33
35
  * runs inside `runWithRequestContext`, even tests that don't destructure
@@ -43,7 +45,7 @@ export declare function runInRequestContext<T>(fn: () => T | Promise<T>, opts?:
43
45
  * });
44
46
  * ```
45
47
  */
46
- export declare function requestContextFixture(opts?: RequestContextOptions): {
48
+ declare function requestContextFixture(opts?: RequestContextOptions): {
47
49
  requestContext: readonly [({}: {}, use: (value: ServiceContext) => Promise<void>) => Promise<void>, {
48
50
  readonly auto: true;
49
51
  }];
@@ -66,6 +68,8 @@ export declare function requestContextFixture(opts?: RequestContextOptions): {
66
68
  * });
67
69
  * ```
68
70
  */
69
- export declare function withRequestContext<T extends TestAPI | ReturnType<TestAPI['extend']>>(testApi: T, opts?: RequestContextOptions): T;
71
+ declare function withRequestContext<T extends TestAPI | ReturnType<TestAPI['extend']>>(testApi: T, opts?: RequestContextOptions): T;
72
+ //# sourceMappingURL=requestContext.d.ts.map
70
73
  //#endregion
74
+ export { RequestContextOptions, requestContextFixture, runInRequestContext, withRequestContext };
71
75
  //# sourceMappingURL=requestContext.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"requestContext.d.mts","names":[],"sources":["../src/requestContext.ts"],"mappings":";;;;;;;;;iBAiBiB;;EAEhB,SAAS;;EAET;;EAEA;;;;;;;;;;;;;;wBAuBe,oBAAoB,GACnC,UAAU,IAAI,QAAQ,IACtB,OAAM,wBACJ,IAAI,QAAQ;;;;;;;;;;;;;;;;wBAmBC,sBAAsB,OAAM;EAE1C,mCAGQ,MACA,OAAO,mBAAmB,kBAAa;aAiB5C;;;;;;;;;;;;;;;;;;;;;wBAuBW,mBACf,UAAU,UAAU,WAAW,oBAC9B,SAAS,GAAG,OAAM,wBAA6B"}
1
+ {"version":3,"file":"requestContext.d.mts","names":[],"sources":["../src/requestContext.ts"],"sourcesContent":[],"mappings":";;;;;;;;AAiBA;AA6BA;;AACW,UA9BM,qBAAA,CA8BN;EAAC;EAAY,MAAT,CAAA,EA5BL,MA4BK;EAAO;EACW,SAC9B,CAAA,EAAA,MAAA;EAAC;EAAY,SAAT,CAAA,EAAA,MAAA;AAAO;AAmBd;;;;;;AAMiD;AAwCjD;;;;;AAEW,iBAtEK,mBAsEL,CAAA,CAAA,CAAA,CAAA,EAAA,EAAA,GAAA,GArEA,CAqEA,GArEI,OAqEJ,CArEY,CAqEZ,CAAA,EAAA,IAAA,CAAA,EApEJ,qBAoEI,CAAA,EAnER,CAmEQ,GAnEJ,OAmEI,CAnEI,CAmEJ,CAAA;;;AAAuC;;;;;;;;;;;;;iBAhDlC,qBAAA,QAA4B;kDAM3B,mBAAmB,kBAAa;;;;;;;;;;;;;;;;;;;;;;iBAwCjC,6BACL,UAAU,WAAW,6BACrB,UAAS,wBAA6B"}
@@ -1,6 +1,7 @@
1
- import { enterRequestContext, exitRequestContext, runWithRequestContext, serviceContext } from "@geekmidas/services";
2
1
  import { randomUUID } from "node:crypto";
3
2
  import { ConsoleLogger } from "@geekmidas/logger/console";
3
+ import { enterRequestContext, exitRequestContext, runWithRequestContext, serviceContext } from "@geekmidas/services";
4
+
4
5
  //#region src/requestContext.ts
5
6
  function resolveContext(opts = {}) {
6
7
  return {
@@ -70,7 +71,7 @@ function requestContextFixture(opts = {}) {
70
71
  function withRequestContext(testApi, opts = {}) {
71
72
  return testApi.extend(requestContextFixture(opts));
72
73
  }
74
+
73
75
  //#endregion
74
76
  export { requestContextFixture, runInRequestContext, withRequestContext };
75
-
76
77
  //# sourceMappingURL=requestContext.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"requestContext.mjs","names":[],"sources":["../src/requestContext.ts"],"sourcesContent":["import { randomUUID } from 'node:crypto';\nimport type { Logger } from '@geekmidas/logger';\nimport { ConsoleLogger } from '@geekmidas/logger/console';\nimport {\n\tenterRequestContext,\n\texitRequestContext,\n\trunWithRequestContext,\n\ttype ServiceContext,\n\tserviceContext,\n} from '@geekmidas/services';\nimport type { TestAPI } from 'vitest';\n\n/**\n * Options for setting up a request context in tests. Any field omitted\n * is filled with a test-friendly default (ConsoleLogger, random UUID,\n * Date.now()).\n */\nexport interface RequestContextOptions {\n\t/** Logger exposed via serviceContext.getLogger(). */\n\tlogger?: Logger;\n\t/** Request id exposed via serviceContext.getRequestId(). */\n\trequestId?: string;\n\t/** Start time exposed via serviceContext.getRequestStartTime(). */\n\tstartTime?: number;\n}\n\nfunction resolveContext(opts: RequestContextOptions = {}) {\n\treturn {\n\t\tlogger: opts.logger ?? new ConsoleLogger({ app: 'test' }),\n\t\trequestId: opts.requestId ?? randomUUID(),\n\t\tstartTime: opts.startTime ?? Date.now(),\n\t};\n}\n\n/**\n * Run a function inside a request context with test-friendly defaults.\n * Useful when you need `serviceContext` to be available for a single call\n * (e.g. invoking `Service.register({ context })` outside a wrapped test).\n *\n * @example\n * ```ts\n * await runInRequestContext(() =>\n * discovery.register([databaseService]),\n * );\n * ```\n */\nexport function runInRequestContext<T>(\n\tfn: () => T | Promise<T>,\n\topts: RequestContextOptions = {},\n): T | Promise<T> {\n\treturn runWithRequestContext(resolveContext(opts), fn);\n}\n\n/**\n * Vitest fixture creator. Spread the result into `.extend()` and every test\n * runs inside `runWithRequestContext`, even tests that don't destructure\n * `requestContext` directly (the fixture is registered as `auto`).\n *\n * @example\n * ```ts\n * const it = test.extend({ ...requestContextFixture() });\n *\n * it('registers services with context', async ({ requestContext }) => {\n * await discovery.register([databaseService]);\n * expect(requestContext.getRequestId()).toBeDefined();\n * });\n * ```\n */\nexport function requestContextFixture(opts: RequestContextOptions = {}) {\n\treturn {\n\t\trequestContext: [\n\t\t\tasync (\n\t\t\t\t// biome-ignore lint/correctness/noEmptyPattern: vitest fixture signature\n\t\t\t\t{}: {},\n\t\t\t\tuse: (value: ServiceContext) => Promise<void>,\n\t\t\t) => {\n\t\t\t\t// Vitest suspends the fixture on `await use(...)` and runs the test\n\t\t\t\t// body in a continuation of the runner's async context. A scoped\n\t\t\t\t// `runWithRequestContext` callback ends as soon as we hand control\n\t\t\t\t// to the runner, so the test body would see no context. Instead,\n\t\t\t\t// mutate the current task's store with `enterRequestContext` —\n\t\t\t\t// async/await preserves that store across the suspension, so the\n\t\t\t\t// test body sees it. We restore on the way out so subsequent tests\n\t\t\t\t// don't inherit the value.\n\t\t\t\tenterRequestContext(resolveContext(opts));\n\t\t\t\ttry {\n\t\t\t\t\tawait use(serviceContext);\n\t\t\t\t} finally {\n\t\t\t\t\texitRequestContext();\n\t\t\t\t}\n\t\t\t},\n\t\t\t{ auto: true },\n\t\t] as const,\n\t};\n}\n\n/**\n * Wrap any Vitest `TestAPI` (including the one returned by\n * `wrapVitestKyselyTransaction`) so every test runs inside\n * `runWithRequestContext`. Compose with the transaction wrappers:\n *\n * @example\n * ```ts\n * import { wrapVitestKyselyTransaction } from '@geekmidas/testkit/kysely';\n * import { withRequestContext } from '@geekmidas/testkit/request-context';\n *\n * const baseIt = wrapVitestKyselyTransaction<DB>(it, { connection: db });\n * const itWithCtx = withRequestContext(baseIt);\n *\n * itWithCtx('runs inside trx + context', async ({ trx, requestContext }) => {\n * // serviceContext is set up; Service.register({ context }) works here.\n * });\n * ```\n */\nexport function withRequestContext<\n\tT extends TestAPI | ReturnType<TestAPI['extend']>,\n>(testApi: T, opts: RequestContextOptions = {}): T {\n\treturn (testApi as any).extend(requestContextFixture(opts));\n}\n"],"mappings":";;;;AA0BA,SAAS,eAAe,OAA8B,CAAC,GAAG;CACzD,OAAO;EACN,QAAQ,KAAK,UAAU,IAAI,cAAc,EAAE,KAAK,OAAO,CAAC;EACxD,WAAW,KAAK,aAAa,WAAW;EACxC,WAAW,KAAK,aAAa,KAAK,IAAI;CACvC;AACD;;;;;;;;;;;;;AAcA,SAAgB,oBACf,IACA,OAA8B,CAAC,GACd;CACjB,OAAO,sBAAsB,eAAe,IAAI,GAAG,EAAE;AACtD;;;;;;;;;;;;;;;;AAiBA,SAAgB,sBAAsB,OAA8B,CAAC,GAAG;CACvE,OAAO,EACN,gBAAgB,CACf,OAEC,IACA,QACI;EASJ,oBAAoB,eAAe,IAAI,CAAC;EACxC,IAAI;GACH,MAAM,IAAI,cAAc;EACzB,UAAU;GACT,mBAAmB;EACpB;CACD,GACA,EAAE,MAAM,KAAK,CACd,EACD;AACD;;;;;;;;;;;;;;;;;;;AAoBA,SAAgB,mBAEd,SAAY,OAA8B,CAAC,GAAM;CAClD,OAAQ,QAAgB,OAAO,sBAAsB,IAAI,CAAC;AAC3D"}
1
+ {"version":3,"file":"requestContext.mjs","names":["opts: RequestContextOptions","fn: () => T | Promise<T>","use: (value: ServiceContext) => Promise<void>","testApi: T"],"sources":["../src/requestContext.ts"],"sourcesContent":["import { randomUUID } from 'node:crypto';\nimport type { Logger } from '@geekmidas/logger';\nimport { ConsoleLogger } from '@geekmidas/logger/console';\nimport {\n\tenterRequestContext,\n\texitRequestContext,\n\trunWithRequestContext,\n\ttype ServiceContext,\n\tserviceContext,\n} from '@geekmidas/services';\nimport type { TestAPI } from 'vitest';\n\n/**\n * Options for setting up a request context in tests. Any field omitted\n * is filled with a test-friendly default (ConsoleLogger, random UUID,\n * Date.now()).\n */\nexport interface RequestContextOptions {\n\t/** Logger exposed via serviceContext.getLogger(). */\n\tlogger?: Logger;\n\t/** Request id exposed via serviceContext.getRequestId(). */\n\trequestId?: string;\n\t/** Start time exposed via serviceContext.getRequestStartTime(). */\n\tstartTime?: number;\n}\n\nfunction resolveContext(opts: RequestContextOptions = {}) {\n\treturn {\n\t\tlogger: opts.logger ?? new ConsoleLogger({ app: 'test' }),\n\t\trequestId: opts.requestId ?? randomUUID(),\n\t\tstartTime: opts.startTime ?? Date.now(),\n\t};\n}\n\n/**\n * Run a function inside a request context with test-friendly defaults.\n * Useful when you need `serviceContext` to be available for a single call\n * (e.g. invoking `Service.register({ context })` outside a wrapped test).\n *\n * @example\n * ```ts\n * await runInRequestContext(() =>\n * discovery.register([databaseService]),\n * );\n * ```\n */\nexport function runInRequestContext<T>(\n\tfn: () => T | Promise<T>,\n\topts: RequestContextOptions = {},\n): T | Promise<T> {\n\treturn runWithRequestContext(resolveContext(opts), fn);\n}\n\n/**\n * Vitest fixture creator. Spread the result into `.extend()` and every test\n * runs inside `runWithRequestContext`, even tests that don't destructure\n * `requestContext` directly (the fixture is registered as `auto`).\n *\n * @example\n * ```ts\n * const it = test.extend({ ...requestContextFixture() });\n *\n * it('registers services with context', async ({ requestContext }) => {\n * await discovery.register([databaseService]);\n * expect(requestContext.getRequestId()).toBeDefined();\n * });\n * ```\n */\nexport function requestContextFixture(opts: RequestContextOptions = {}) {\n\treturn {\n\t\trequestContext: [\n\t\t\tasync (\n\t\t\t\t// biome-ignore lint/correctness/noEmptyPattern: vitest fixture signature\n\t\t\t\t{}: {},\n\t\t\t\tuse: (value: ServiceContext) => Promise<void>,\n\t\t\t) => {\n\t\t\t\t// Vitest suspends the fixture on `await use(...)` and runs the test\n\t\t\t\t// body in a continuation of the runner's async context. A scoped\n\t\t\t\t// `runWithRequestContext` callback ends as soon as we hand control\n\t\t\t\t// to the runner, so the test body would see no context. Instead,\n\t\t\t\t// mutate the current task's store with `enterRequestContext` —\n\t\t\t\t// async/await preserves that store across the suspension, so the\n\t\t\t\t// test body sees it. We restore on the way out so subsequent tests\n\t\t\t\t// don't inherit the value.\n\t\t\t\tenterRequestContext(resolveContext(opts));\n\t\t\t\ttry {\n\t\t\t\t\tawait use(serviceContext);\n\t\t\t\t} finally {\n\t\t\t\t\texitRequestContext();\n\t\t\t\t}\n\t\t\t},\n\t\t\t{ auto: true },\n\t\t] as const,\n\t};\n}\n\n/**\n * Wrap any Vitest `TestAPI` (including the one returned by\n * `wrapVitestKyselyTransaction`) so every test runs inside\n * `runWithRequestContext`. Compose with the transaction wrappers:\n *\n * @example\n * ```ts\n * import { wrapVitestKyselyTransaction } from '@geekmidas/testkit/kysely';\n * import { withRequestContext } from '@geekmidas/testkit/request-context';\n *\n * const baseIt = wrapVitestKyselyTransaction<DB>(it, { connection: db });\n * const itWithCtx = withRequestContext(baseIt);\n *\n * itWithCtx('runs inside trx + context', async ({ trx, requestContext }) => {\n * // serviceContext is set up; Service.register({ context }) works here.\n * });\n * ```\n */\nexport function withRequestContext<\n\tT extends TestAPI | ReturnType<TestAPI['extend']>,\n>(testApi: T, opts: RequestContextOptions = {}): T {\n\treturn (testApi as any).extend(requestContextFixture(opts));\n}\n"],"mappings":";;;;;AA0BA,SAAS,eAAeA,OAA8B,CAAE,GAAE;AACzD,QAAO;EACN,QAAQ,KAAK,UAAU,IAAI,cAAc,EAAE,KAAK,OAAQ;EACxD,WAAW,KAAK,aAAa,YAAY;EACzC,WAAW,KAAK,aAAa,KAAK,KAAK;CACvC;AACD;;;;;;;;;;;;;AAcD,SAAgB,oBACfC,IACAD,OAA8B,CAAE,GACf;AACjB,QAAO,sBAAsB,eAAe,KAAK,EAAE,GAAG;AACtD;;;;;;;;;;;;;;;;AAiBD,SAAgB,sBAAsBA,OAA8B,CAAE,GAAE;AACvE,QAAO,EACN,gBAAgB,CACf,OAEC,EAAM,EACNE,QACI;AASJ,sBAAoB,eAAe,KAAK,CAAC;AACzC,MAAI;AACH,SAAM,IAAI,eAAe;EACzB,UAAS;AACT,uBAAoB;EACpB;CACD,GACD,EAAE,MAAM,KAAM,CACd,EACD;AACD;;;;;;;;;;;;;;;;;;;AAoBD,SAAgB,mBAEdC,SAAYH,OAA8B,CAAE,GAAK;AAClD,QAAO,AAAC,QAAgB,OAAO,sBAAsB,KAAK,CAAC;AAC3D"}
package/dist/timer.cjs CHANGED
@@ -1,9 +1,9 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
1
+
2
2
  //#region src/timer.ts
3
3
  function waitFor(ms) {
4
4
  return new Promise((resolve) => setTimeout(resolve, ms));
5
5
  }
6
+
6
7
  //#endregion
7
8
  exports.waitFor = waitFor;
8
-
9
9
  //# sourceMappingURL=timer.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"timer.cjs","names":[],"sources":["../src/timer.ts"],"sourcesContent":["export function waitFor(ms: number) {\n\treturn new Promise((resolve) => setTimeout(resolve, ms));\n}\n"],"mappings":";;AAAA,SAAgB,QAAQ,IAAY;CACnC,OAAO,IAAI,SAAS,YAAY,WAAW,SAAS,EAAE,CAAC;AACxD"}
1
+ {"version":3,"file":"timer.cjs","names":["ms: number"],"sources":["../src/timer.ts"],"sourcesContent":["export function waitFor(ms: number) {\n\treturn new Promise((resolve) => setTimeout(resolve, ms));\n}\n"],"mappings":";;AAAA,SAAgB,QAAQA,IAAY;AACnC,QAAO,IAAI,QAAQ,CAAC,YAAY,WAAW,SAAS,GAAG;AACvD"}
package/dist/timer.d.cts CHANGED
@@ -1,4 +1,7 @@
1
1
  //#region src/timer.d.ts
2
- export declare function waitFor(ms: number): Promise<unknown>;
2
+ declare function waitFor(ms: number): Promise<unknown>;
3
+ //# sourceMappingURL=timer.d.ts.map
4
+
3
5
  //#endregion
6
+ export { waitFor };
4
7
  //# sourceMappingURL=timer.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"timer.d.cts","names":[],"sources":["../src/timer.ts"],"mappings":";wBAAgB,QAAQ,aAAU"}
1
+ {"version":3,"file":"timer.d.cts","names":[],"sources":["../src/timer.ts"],"sourcesContent":[],"mappings":";iBAAgB,OAAA,cAAkB;AAAlC"}
package/dist/timer.d.mts CHANGED
@@ -1,4 +1,7 @@
1
1
  //#region src/timer.d.ts
2
- export declare function waitFor(ms: number): Promise<unknown>;
2
+ declare function waitFor(ms: number): Promise<unknown>;
3
+ //# sourceMappingURL=timer.d.ts.map
4
+
3
5
  //#endregion
6
+ export { waitFor };
4
7
  //# sourceMappingURL=timer.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"timer.d.mts","names":[],"sources":["../src/timer.ts"],"mappings":";wBAAgB,QAAQ,aAAU"}
1
+ {"version":3,"file":"timer.d.mts","names":[],"sources":["../src/timer.ts"],"sourcesContent":[],"mappings":";iBAAgB,OAAA,cAAkB;AAAlC"}
package/dist/timer.mjs CHANGED
@@ -2,7 +2,7 @@
2
2
  function waitFor(ms) {
3
3
  return new Promise((resolve) => setTimeout(resolve, ms));
4
4
  }
5
+
5
6
  //#endregion
6
7
  export { waitFor };
7
-
8
8
  //# sourceMappingURL=timer.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"timer.mjs","names":[],"sources":["../src/timer.ts"],"sourcesContent":["export function waitFor(ms: number) {\n\treturn new Promise((resolve) => setTimeout(resolve, ms));\n}\n"],"mappings":";AAAA,SAAgB,QAAQ,IAAY;CACnC,OAAO,IAAI,SAAS,YAAY,WAAW,SAAS,EAAE,CAAC;AACxD"}
1
+ {"version":3,"file":"timer.mjs","names":["ms: number"],"sources":["../src/timer.ts"],"sourcesContent":["export function waitFor(ms: number) {\n\treturn new Promise((resolve) => setTimeout(resolve, ms));\n}\n"],"mappings":";AAAA,SAAgB,QAAQA,IAAY;AACnC,QAAO,IAAI,QAAQ,CAAC,YAAY,WAAW,SAAS,GAAG;AACvD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geekmidas/testkit",
3
- "version": "10.0.0-alpha.99",
3
+ "version": "10.0.0",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "exports": {
@@ -113,65 +113,16 @@
113
113
  "types": "./dist/requestContext.d.cts",
114
114
  "default": "./dist/requestContext.cjs"
115
115
  }
116
- },
117
- "./browser": {
118
- "import": {
119
- "types": "./dist/browser.d.mts",
120
- "default": "./dist/browser.mjs"
121
- },
122
- "require": {
123
- "types": "./dist/browser.d.cts",
124
- "default": "./dist/browser.cjs"
125
- }
126
- },
127
- "./context": {
128
- "import": {
129
- "types": "./dist/context.d.mts",
130
- "default": "./dist/context.mjs"
131
- },
132
- "require": {
133
- "types": "./dist/context.d.cts",
134
- "default": "./dist/context.cjs"
135
- }
136
- },
137
- "./mailbox": {
138
- "import": {
139
- "types": "./dist/mailbox.d.mts",
140
- "default": "./dist/mailbox.mjs"
141
- },
142
- "require": {
143
- "types": "./dist/mailbox.d.cts",
144
- "default": "./dist/mailbox.cjs"
145
- }
146
- },
147
- "./transactions": {
148
- "import": {
149
- "types": "./dist/transactions.d.mts",
150
- "default": "./dist/transactions.mjs"
151
- },
152
- "require": {
153
- "types": "./dist/transactions.d.cts",
154
- "default": "./dist/transactions.cjs"
155
- }
156
116
  }
157
117
  },
158
- "files": [
159
- "dist"
160
- ],
161
118
  "dependencies": {
162
- "@faker-js/faker": "~10.6.0",
163
- "tough-cookie": "~6.0.2",
164
- "@geekmidas/envkit": "^10.0.0-alpha.99",
165
- "@geekmidas/logger": "^10.0.0-alpha.99",
166
- "@geekmidas/services": "^10.0.0-alpha.99"
119
+ "@faker-js/faker": "~9.9.0"
167
120
  },
168
121
  "devDependencies": {
169
- "@better-auth/test-utils": "~1.7.6",
170
- "@types/pg": "~8.23.1",
171
- "better-auth": "~1.7.6",
172
- "@geekmidas/envkit": "^10.0.0-alpha.99",
173
- "@geekmidas/logger": "^10.0.0-alpha.99",
174
- "@geekmidas/services": "^10.0.0-alpha.99"
122
+ "@types/pg": "~8.15.4",
123
+ "@geekmidas/envkit": "^10.0.0",
124
+ "@geekmidas/services": "^10.0.0",
125
+ "@geekmidas/logger": "^10.0.0"
175
126
  },
176
127
  "repository": {
177
128
  "type": "git",
@@ -182,16 +133,28 @@
182
133
  "access": "public"
183
134
  },
184
135
  "peerDependencies": {
185
- "kysely": "~0.29.6",
186
- "pg": ">=8.23.0",
187
- "knex": ">=3.3.0",
188
- "objection": ">=3.1.5",
136
+ "kysely": "~0.29.4",
137
+ "pg": "~8.16.3",
138
+ "knex": "~3.1.0",
139
+ "objection": "~3.1.5",
189
140
  "db-errors": "~0.2.3",
190
- "vitest": "~5.0.2",
191
- "@types/aws-lambda": ">=8.10.163",
192
- "better-auth": ">=1.7.5"
141
+ "vitest": "~3.2.4",
142
+ "@types/aws-lambda": ">=8.10.92",
143
+ "better-auth": ">=1.3.34",
144
+ "@geekmidas/envkit": "^10.0.0",
145
+ "@geekmidas/logger": "^10.0.0",
146
+ "@geekmidas/services": "^10.0.0"
193
147
  },
194
148
  "peerDependenciesMeta": {
149
+ "@geekmidas/envkit": {
150
+ "optional": true
151
+ },
152
+ "@geekmidas/logger": {
153
+ "optional": true
154
+ },
155
+ "@geekmidas/services": {
156
+ "optional": true
157
+ },
195
158
  "kysely": {
196
159
  "optional": true
197
160
  },
@@ -216,8 +179,5 @@
216
179
  "better-auth": {
217
180
  "optional": true
218
181
  }
219
- },
220
- "scripts": {
221
- "build": "tsdown --config ../../tsdown.config.ts --filter ."
222
182
  }
223
183
  }