@geekmidas/testkit 10.0.0-alpha.4 → 10.0.0-alpha.41

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 (295) hide show
  1. package/README.md +74 -0
  2. package/dist/Factory.cjs +51 -2
  3. package/dist/Factory.cjs.map +1 -0
  4. package/dist/Factory.d.cts +143 -3
  5. package/dist/Factory.d.cts.map +1 -0
  6. package/dist/Factory.d.mts +143 -3
  7. package/dist/Factory.d.mts.map +1 -0
  8. package/dist/Factory.mjs +50 -2
  9. package/dist/Factory.mjs.map +1 -0
  10. package/dist/KyselyFactory.cjs +237 -4
  11. package/dist/KyselyFactory.cjs.map +1 -0
  12. package/dist/KyselyFactory.d.cts +224 -4
  13. package/dist/KyselyFactory.d.cts.map +1 -0
  14. package/dist/KyselyFactory.d.mts +224 -4
  15. package/dist/KyselyFactory.d.mts.map +1 -0
  16. package/dist/KyselyFactory.mjs +236 -4
  17. package/dist/KyselyFactory.mjs.map +1 -0
  18. package/dist/ObjectionFactory.cjs +265 -4
  19. package/dist/ObjectionFactory.cjs.map +1 -0
  20. package/dist/ObjectionFactory.d.cts +237 -4
  21. package/dist/ObjectionFactory.d.cts.map +1 -0
  22. package/dist/ObjectionFactory.d.mts +237 -4
  23. package/dist/ObjectionFactory.d.mts.map +1 -0
  24. package/dist/ObjectionFactory.mjs +264 -4
  25. package/dist/ObjectionFactory.mjs.map +1 -0
  26. package/dist/PostgresKyselyMigrator.cjs +94 -3
  27. package/dist/PostgresKyselyMigrator.cjs.map +1 -0
  28. package/dist/PostgresKyselyMigrator.d.cts +80 -3
  29. package/dist/PostgresKyselyMigrator.d.cts.map +1 -0
  30. package/dist/PostgresKyselyMigrator.d.mts +80 -3
  31. package/dist/PostgresKyselyMigrator.d.mts.map +1 -0
  32. package/dist/PostgresKyselyMigrator.mjs +93 -3
  33. package/dist/PostgresKyselyMigrator.mjs.map +1 -0
  34. package/dist/{PostgresMigrator-C_QQ6q35.d.mts → PostgresMigrator-CDPnnwMJ.d.cts} +11 -5
  35. package/dist/PostgresMigrator-CDPnnwMJ.d.cts.map +1 -0
  36. package/dist/{PostgresMigrator-CeYy-eHF.d.cts → PostgresMigrator-CDPnnwMJ.d.mts} +11 -5
  37. package/dist/PostgresMigrator-CDPnnwMJ.d.mts.map +1 -0
  38. package/dist/PostgresMigrator.cjs +178 -2
  39. package/dist/PostgresMigrator.cjs.map +1 -0
  40. package/dist/PostgresMigrator.d.cts +1 -1
  41. package/dist/PostgresMigrator.d.mts +1 -1
  42. package/dist/PostgresMigrator.mjs +175 -2
  43. package/dist/PostgresMigrator.mjs.map +1 -0
  44. package/dist/PostgresObjectionMigrator.cjs +118 -3
  45. package/dist/PostgresObjectionMigrator.cjs.map +1 -0
  46. package/dist/PostgresObjectionMigrator.d.cts +75 -3
  47. package/dist/PostgresObjectionMigrator.d.cts.map +1 -0
  48. package/dist/PostgresObjectionMigrator.d.mts +75 -3
  49. package/dist/PostgresObjectionMigrator.d.mts.map +1 -0
  50. package/dist/PostgresObjectionMigrator.mjs +117 -3
  51. package/dist/PostgresObjectionMigrator.mjs.map +1 -0
  52. package/dist/VitestKyselyTransactionIsolator.cjs +66 -3
  53. package/dist/VitestKyselyTransactionIsolator.cjs.map +1 -0
  54. package/dist/VitestKyselyTransactionIsolator.d.cts +60 -3
  55. package/dist/VitestKyselyTransactionIsolator.d.cts.map +1 -0
  56. package/dist/VitestKyselyTransactionIsolator.d.mts +60 -3
  57. package/dist/VitestKyselyTransactionIsolator.d.mts.map +1 -0
  58. package/dist/VitestKyselyTransactionIsolator.mjs +65 -3
  59. package/dist/VitestKyselyTransactionIsolator.mjs.map +1 -0
  60. package/dist/VitestObjectionTransactionIsolator.cjs +62 -3
  61. package/dist/VitestObjectionTransactionIsolator.cjs.map +1 -0
  62. package/dist/VitestObjectionTransactionIsolator.d.cts +56 -3
  63. package/dist/VitestObjectionTransactionIsolator.d.cts.map +1 -0
  64. package/dist/VitestObjectionTransactionIsolator.d.mts +56 -3
  65. package/dist/VitestObjectionTransactionIsolator.d.mts.map +1 -0
  66. package/dist/VitestObjectionTransactionIsolator.mjs +61 -3
  67. package/dist/VitestObjectionTransactionIsolator.mjs.map +1 -0
  68. package/dist/VitestTransactionIsolator.cjs +187 -4
  69. package/dist/VitestTransactionIsolator.cjs.map +1 -0
  70. package/dist/VitestTransactionIsolator.d.cts +219 -2
  71. package/dist/VitestTransactionIsolator.d.cts.map +1 -0
  72. package/dist/VitestTransactionIsolator.d.mts +219 -2
  73. package/dist/VitestTransactionIsolator.d.mts.map +1 -0
  74. package/dist/VitestTransactionIsolator.mjs +184 -2
  75. package/dist/VitestTransactionIsolator.mjs.map +1 -0
  76. package/dist/aws.cjs +3 -4
  77. package/dist/aws.cjs.map +1 -1
  78. package/dist/aws.d.cts +3 -8
  79. package/dist/aws.d.cts.map +1 -1
  80. package/dist/aws.d.mts +3 -8
  81. package/dist/aws.d.mts.map +1 -1
  82. package/dist/aws.mjs +1 -2
  83. package/dist/aws.mjs.map +1 -1
  84. package/dist/benchmark.cjs +2 -2
  85. package/dist/benchmark.cjs.map +1 -1
  86. package/dist/benchmark.d.cts +4 -6
  87. package/dist/benchmark.d.cts.map +1 -1
  88. package/dist/benchmark.d.mts +4 -6
  89. package/dist/benchmark.d.mts.map +1 -1
  90. package/dist/benchmark.mjs +1 -1
  91. package/dist/benchmark.mjs.map +1 -1
  92. package/dist/better-auth.cjs +17 -8
  93. package/dist/better-auth.cjs.map +1 -1
  94. package/dist/better-auth.d.cts +13142 -5
  95. package/dist/better-auth.d.cts.map +1 -1
  96. package/dist/better-auth.d.mts +13142 -5
  97. package/dist/better-auth.d.mts.map +1 -1
  98. package/dist/better-auth.mjs +15 -6
  99. package/dist/better-auth.mjs.map +1 -1
  100. package/dist/browser.cjs +127 -0
  101. package/dist/browser.cjs.map +1 -0
  102. package/dist/browser.d.cts +47 -0
  103. package/dist/browser.d.cts.map +1 -0
  104. package/dist/browser.d.mts +47 -0
  105. package/dist/browser.d.mts.map +1 -0
  106. package/dist/browser.mjs +125 -0
  107. package/dist/browser.mjs.map +1 -0
  108. package/dist/context.cjs +80 -0
  109. package/dist/context.cjs.map +1 -0
  110. package/dist/context.d.cts +55 -0
  111. package/dist/context.d.cts.map +1 -0
  112. package/dist/context.d.mts +55 -0
  113. package/dist/context.d.mts.map +1 -0
  114. package/dist/context.mjs +73 -0
  115. package/dist/context.mjs.map +1 -0
  116. package/dist/faker.cjs +313 -8
  117. package/dist/faker.cjs.map +1 -0
  118. package/dist/faker.d.cts +169 -2
  119. package/dist/faker.d.cts.map +1 -0
  120. package/dist/faker.d.mts +169 -2
  121. package/dist/faker.d.mts.map +1 -0
  122. package/dist/faker.mjs +305 -2
  123. package/dist/faker.mjs.map +1 -0
  124. package/dist/helpers.cjs +6 -5
  125. package/dist/helpers.cjs.map +1 -1
  126. package/dist/helpers.d.cts +1 -5
  127. package/dist/helpers.d.cts.map +1 -1
  128. package/dist/helpers.d.mts +1 -5
  129. package/dist/helpers.d.mts.map +1 -1
  130. package/dist/helpers.mjs +1 -2
  131. package/dist/helpers.mjs.map +1 -1
  132. package/dist/initScript.cjs +15 -15
  133. package/dist/initScript.cjs.map +1 -1
  134. package/dist/initScript.d.cts +2 -4
  135. package/dist/initScript.d.cts.map +1 -1
  136. package/dist/initScript.d.mts +2 -4
  137. package/dist/initScript.d.mts.map +1 -1
  138. package/dist/initScript.mjs +10 -12
  139. package/dist/initScript.mjs.map +1 -1
  140. package/dist/kysely.cjs +10 -13
  141. package/dist/kysely.cjs.map +1 -1
  142. package/dist/kysely.d.cts +10 -14
  143. package/dist/kysely.d.cts.map +1 -1
  144. package/dist/kysely.d.mts +10 -14
  145. package/dist/kysely.d.mts.map +1 -1
  146. package/dist/kysely.mjs +10 -14
  147. package/dist/kysely.mjs.map +1 -1
  148. package/dist/logger.cjs +3 -4
  149. package/dist/logger.cjs.map +1 -1
  150. package/dist/logger.d.cts +1 -5
  151. package/dist/logger.d.cts.map +1 -1
  152. package/dist/logger.d.mts +1 -5
  153. package/dist/logger.d.mts.map +1 -1
  154. package/dist/logger.mjs +1 -2
  155. package/dist/logger.mjs.map +1 -1
  156. package/dist/mailbox.cjs +95 -0
  157. package/dist/mailbox.cjs.map +1 -0
  158. package/dist/mailbox.d.cts +58 -0
  159. package/dist/mailbox.d.cts.map +1 -0
  160. package/dist/mailbox.d.mts +58 -0
  161. package/dist/mailbox.d.mts.map +1 -0
  162. package/dist/mailbox.mjs +92 -0
  163. package/dist/mailbox.mjs.map +1 -0
  164. package/dist/objection.cjs +10 -13
  165. package/dist/objection.cjs.map +1 -1
  166. package/dist/objection.d.cts +10 -14
  167. package/dist/objection.d.cts.map +1 -1
  168. package/dist/objection.d.mts +10 -14
  169. package/dist/objection.d.mts.map +1 -1
  170. package/dist/objection.mjs +10 -14
  171. package/dist/objection.mjs.map +1 -1
  172. package/dist/os/directory.cjs +31 -2
  173. package/dist/os/directory.cjs.map +1 -0
  174. package/dist/os/directory.d.cts +9 -2
  175. package/dist/os/directory.d.cts.map +1 -0
  176. package/dist/os/directory.d.mts +9 -2
  177. package/dist/os/directory.d.mts.map +1 -0
  178. package/dist/os/directory.mjs +25 -2
  179. package/dist/os/directory.mjs.map +1 -0
  180. package/dist/os/index.cjs +3 -3
  181. package/dist/os/index.d.cts +1 -1
  182. package/dist/os/index.d.mts +1 -1
  183. package/dist/os/index.mjs +2 -3
  184. package/dist/requestContext.cjs +10 -11
  185. package/dist/requestContext.cjs.map +1 -1
  186. package/dist/requestContext.d.cts +4 -8
  187. package/dist/requestContext.d.cts.map +1 -1
  188. package/dist/requestContext.d.mts +4 -8
  189. package/dist/requestContext.d.mts.map +1 -1
  190. package/dist/requestContext.mjs +1 -2
  191. package/dist/requestContext.mjs.map +1 -1
  192. package/dist/{chunk-CUT6urMc.cjs → rolldown-runtime-VH7oDXx4.cjs} +8 -10
  193. package/dist/timer.cjs +2 -2
  194. package/dist/timer.cjs.map +1 -1
  195. package/dist/timer.d.cts +1 -4
  196. package/dist/timer.d.cts.map +1 -1
  197. package/dist/timer.d.mts +1 -4
  198. package/dist/timer.d.mts.map +1 -1
  199. package/dist/timer.mjs +1 -1
  200. package/dist/timer.mjs.map +1 -1
  201. package/dist/transactions.cjs +123 -0
  202. package/dist/transactions.cjs.map +1 -0
  203. package/dist/transactions.d.cts +44 -0
  204. package/dist/transactions.d.cts.map +1 -0
  205. package/dist/transactions.d.mts +44 -0
  206. package/dist/transactions.d.mts.map +1 -0
  207. package/dist/transactions.mjs +118 -0
  208. package/dist/transactions.mjs.map +1 -0
  209. package/package.json +51 -8
  210. package/dist/Factory-AWn1IulI.d.cts +0 -147
  211. package/dist/Factory-AWn1IulI.d.cts.map +0 -1
  212. package/dist/Factory-BFVnMMCC.mjs +0 -51
  213. package/dist/Factory-BFVnMMCC.mjs.map +0 -1
  214. package/dist/Factory-BhjUOBWN.cjs +0 -57
  215. package/dist/Factory-BhjUOBWN.cjs.map +0 -1
  216. package/dist/Factory-C15SSK8_.d.mts +0 -147
  217. package/dist/Factory-C15SSK8_.d.mts.map +0 -1
  218. package/dist/KyselyFactory-BFqVIn_0.cjs +0 -246
  219. package/dist/KyselyFactory-BFqVIn_0.cjs.map +0 -1
  220. package/dist/KyselyFactory-C9Snz24z.d.mts +0 -228
  221. package/dist/KyselyFactory-C9Snz24z.d.mts.map +0 -1
  222. package/dist/KyselyFactory-CxUJCi--.d.cts +0 -228
  223. package/dist/KyselyFactory-CxUJCi--.d.cts.map +0 -1
  224. package/dist/KyselyFactory-DMswpwji.mjs +0 -241
  225. package/dist/KyselyFactory-DMswpwji.mjs.map +0 -1
  226. package/dist/ObjectionFactory-BeFBYcan.cjs +0 -272
  227. package/dist/ObjectionFactory-BeFBYcan.cjs.map +0 -1
  228. package/dist/ObjectionFactory-CYvaa0kU.d.cts +0 -241
  229. package/dist/ObjectionFactory-CYvaa0kU.d.cts.map +0 -1
  230. package/dist/ObjectionFactory-Cf2WI4o_.d.mts +0 -241
  231. package/dist/ObjectionFactory-Cf2WI4o_.d.mts.map +0 -1
  232. package/dist/ObjectionFactory-QCJ7u0Ql.mjs +0 -267
  233. package/dist/ObjectionFactory-QCJ7u0Ql.mjs.map +0 -1
  234. package/dist/PostgresKyselyMigrator-B2M6Gjvv.d.cts +0 -84
  235. package/dist/PostgresKyselyMigrator-B2M6Gjvv.d.cts.map +0 -1
  236. package/dist/PostgresKyselyMigrator-BGBxjnFv.cjs +0 -101
  237. package/dist/PostgresKyselyMigrator-BGBxjnFv.cjs.map +0 -1
  238. package/dist/PostgresKyselyMigrator-CvwXycJE.d.mts +0 -84
  239. package/dist/PostgresKyselyMigrator-CvwXycJE.d.mts.map +0 -1
  240. package/dist/PostgresKyselyMigrator-PI0QhvB1.mjs +0 -95
  241. package/dist/PostgresKyselyMigrator-PI0QhvB1.mjs.map +0 -1
  242. package/dist/PostgresMigrator-C_QQ6q35.d.mts.map +0 -1
  243. package/dist/PostgresMigrator-CeYy-eHF.d.cts.map +0 -1
  244. package/dist/PostgresMigrator-DVAY04qN.mjs +0 -166
  245. package/dist/PostgresMigrator-DVAY04qN.mjs.map +0 -1
  246. package/dist/PostgresMigrator-M9jpzOvN.cjs +0 -172
  247. package/dist/PostgresMigrator-M9jpzOvN.cjs.map +0 -1
  248. package/dist/PostgresObjectionMigrator-1j6YIB1c.d.mts +0 -79
  249. package/dist/PostgresObjectionMigrator-1j6YIB1c.d.mts.map +0 -1
  250. package/dist/PostgresObjectionMigrator-DHVC9h_P.d.cts +0 -79
  251. package/dist/PostgresObjectionMigrator-DHVC9h_P.d.cts.map +0 -1
  252. package/dist/PostgresObjectionMigrator-DSaPhwjY.cjs +0 -123
  253. package/dist/PostgresObjectionMigrator-DSaPhwjY.cjs.map +0 -1
  254. package/dist/PostgresObjectionMigrator-DjPKdUbm.mjs +0 -118
  255. package/dist/PostgresObjectionMigrator-DjPKdUbm.mjs.map +0 -1
  256. package/dist/VitestKyselyTransactionIsolator-1Saieke7.mjs +0 -67
  257. package/dist/VitestKyselyTransactionIsolator-1Saieke7.mjs.map +0 -1
  258. package/dist/VitestKyselyTransactionIsolator-BjJSXryR.cjs +0 -72
  259. package/dist/VitestKyselyTransactionIsolator-BjJSXryR.cjs.map +0 -1
  260. package/dist/VitestKyselyTransactionIsolator-CwlTo6yf.d.mts +0 -64
  261. package/dist/VitestKyselyTransactionIsolator-CwlTo6yf.d.mts.map +0 -1
  262. package/dist/VitestKyselyTransactionIsolator-DJasVuIZ.d.cts +0 -64
  263. package/dist/VitestKyselyTransactionIsolator-DJasVuIZ.d.cts.map +0 -1
  264. package/dist/VitestObjectionTransactionIsolator-B_VSWFum.mjs +0 -63
  265. package/dist/VitestObjectionTransactionIsolator-B_VSWFum.mjs.map +0 -1
  266. package/dist/VitestObjectionTransactionIsolator-CTTjvTPO.d.cts +0 -60
  267. package/dist/VitestObjectionTransactionIsolator-CTTjvTPO.d.cts.map +0 -1
  268. package/dist/VitestObjectionTransactionIsolator-CyZG6nq4.d.mts +0 -60
  269. package/dist/VitestObjectionTransactionIsolator-CyZG6nq4.d.mts.map +0 -1
  270. package/dist/VitestObjectionTransactionIsolator-DDoJTu7e.cjs +0 -68
  271. package/dist/VitestObjectionTransactionIsolator-DDoJTu7e.cjs.map +0 -1
  272. package/dist/VitestTransactionIsolator-BLaw80cx.d.mts +0 -223
  273. package/dist/VitestTransactionIsolator-BLaw80cx.d.mts.map +0 -1
  274. package/dist/VitestTransactionIsolator-CvwPecpl.mjs +0 -188
  275. package/dist/VitestTransactionIsolator-CvwPecpl.mjs.map +0 -1
  276. package/dist/VitestTransactionIsolator-DyiX-QtK.cjs +0 -206
  277. package/dist/VitestTransactionIsolator-DyiX-QtK.cjs.map +0 -1
  278. package/dist/VitestTransactionIsolator-glcxyS_R.d.cts +0 -223
  279. package/dist/VitestTransactionIsolator-glcxyS_R.d.cts.map +0 -1
  280. package/dist/directory-BxjqmtCT.mjs +0 -27
  281. package/dist/directory-BxjqmtCT.mjs.map +0 -1
  282. package/dist/directory-DD_xQoSh.cjs +0 -33
  283. package/dist/directory-DD_xQoSh.cjs.map +0 -1
  284. package/dist/directory-DiQ_DkaF.d.mts +0 -13
  285. package/dist/directory-DiQ_DkaF.d.mts.map +0 -1
  286. package/dist/directory-zIEh5ZPl.d.cts +0 -13
  287. package/dist/directory-zIEh5ZPl.d.cts.map +0 -1
  288. package/dist/faker-B14IEMIN.cjs +0 -304
  289. package/dist/faker-B14IEMIN.cjs.map +0 -1
  290. package/dist/faker-B6bmbGCM.d.mts +0 -166
  291. package/dist/faker-B6bmbGCM.d.mts.map +0 -1
  292. package/dist/faker-BGKYFoCT.mjs +0 -262
  293. package/dist/faker-BGKYFoCT.mjs.map +0 -1
  294. package/dist/faker-DvxiCtxc.d.cts +0 -166
  295. package/dist/faker-DvxiCtxc.d.cts.map +0 -1
@@ -1,3 +1,32 @@
1
- const require_directory = require('../directory-DD_xQoSh.cjs');
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;
2
31
 
3
- exports.itWithDir = require_directory.itWithDir;
32
+ //# sourceMappingURL=directory.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"directory.cjs","names":["it","os","crypto","path","fs"],"sources":["../../src/os/directory.ts"],"sourcesContent":["import crypto from 'node:crypto';\nimport fs from 'node:fs/promises';\nimport os from 'node:os';\nimport path from 'node:path';\nimport { it } from 'vitest';\n\nexport const itWithDir = it.extend<DirectoryFixtures>({\n\t// This fixture automatically provides a transaction to each test\n\t// biome-ignore lint/correctness/noEmptyPattern: this has to be like this to satisfy Biome\n\tdir: async ({}, use) => {\n\t\tconst tempDir = os.tmpdir();\n\t\tconst directoryName = crypto.randomUUID().replace(/-/g, '').toUpperCase();\n\t\tconst dir = path.join(tempDir, directoryName);\n\t\tawait fs.mkdir(dir, { recursive: true });\n\t\tawait use(dir);\n\t\tawait fs.rm(dir, { recursive: true, force: true });\n\n\t\t// Clean up keystore directory that may have been created at ~/.gkm/{directoryName}\n\t\tconst keystoreDir = path.join(os.homedir(), '.gkm', directoryName);\n\t\tawait fs.rm(keystoreDir, { recursive: true, force: true });\n\t},\n});\n\nexport interface DirectoryFixtures {\n\tdir: string;\n}\n"],"mappings":";;;;;;;;;;;;AAMA,MAAa,YAAYA,OAAAA,GAAG,OAA0B,EAGrD,KAAK,OAAO,IAAI,QAAQ;CACvB,MAAM,UAAUC,QAAAA,QAAG,OAAO;CAC1B,MAAM,gBAAgBC,YAAAA,QAAO,WAAW,CAAC,CAAC,QAAQ,MAAM,EAAE,CAAC,CAAC,YAAY;CACxE,MAAM,MAAMC,UAAAA,QAAK,KAAK,SAAS,aAAa;CAC5C,MAAMC,iBAAAA,QAAG,MAAM,KAAK,EAAE,WAAW,KAAK,CAAC;CACvC,MAAM,IAAI,GAAG;CACb,MAAMA,iBAAAA,QAAG,GAAG,KAAK;EAAE,WAAW;EAAM,OAAO;CAAK,CAAC;CAGjD,MAAM,cAAcD,UAAAA,QAAK,KAAKF,QAAAA,QAAG,QAAQ,GAAG,QAAQ,aAAa;CACjE,MAAMG,iBAAAA,QAAG,GAAG,aAAa;EAAE,WAAW;EAAM,OAAO;CAAK,CAAC;AAC1D,EACD,CAAC"}
@@ -1,2 +1,9 @@
1
- import { DirectoryFixtures, itWithDir } from "../directory-zIEh5ZPl.cjs";
2
- export { DirectoryFixtures, itWithDir };
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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"directory.d.cts","names":[],"sources":["../../src/os/directory.ts"],"mappings":";qBAMa,4BAAS;EAAA;;iBAiBL;EAChB"}
@@ -1,2 +1,9 @@
1
- import { DirectoryFixtures, itWithDir } from "../directory-DiQ_DkaF.mjs";
2
- export { DirectoryFixtures, itWithDir };
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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"directory.d.mts","names":[],"sources":["../../src/os/directory.ts"],"mappings":";qBAMa,4BAAS;EAAA;;iBAiBL;EAChB"}
@@ -1,3 +1,26 @@
1
- import { itWithDir } from "../directory-BxjqmtCT.mjs";
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 };
2
25
 
3
- export { itWithDir };
26
+ //# sourceMappingURL=directory.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"directory.mjs","names":[],"sources":["../../src/os/directory.ts"],"sourcesContent":["import crypto from 'node:crypto';\nimport fs from 'node:fs/promises';\nimport os from 'node:os';\nimport path from 'node:path';\nimport { it } from 'vitest';\n\nexport const itWithDir = it.extend<DirectoryFixtures>({\n\t// This fixture automatically provides a transaction to each test\n\t// biome-ignore lint/correctness/noEmptyPattern: this has to be like this to satisfy Biome\n\tdir: async ({}, use) => {\n\t\tconst tempDir = os.tmpdir();\n\t\tconst directoryName = crypto.randomUUID().replace(/-/g, '').toUpperCase();\n\t\tconst dir = path.join(tempDir, directoryName);\n\t\tawait fs.mkdir(dir, { recursive: true });\n\t\tawait use(dir);\n\t\tawait fs.rm(dir, { recursive: true, force: true });\n\n\t\t// Clean up keystore directory that may have been created at ~/.gkm/{directoryName}\n\t\tconst keystoreDir = path.join(os.homedir(), '.gkm', directoryName);\n\t\tawait fs.rm(keystoreDir, { recursive: true, force: true });\n\t},\n});\n\nexport interface DirectoryFixtures {\n\tdir: string;\n}\n"],"mappings":";;;;;;AAMA,MAAa,YAAY,GAAG,OAA0B,EAGrD,KAAK,OAAO,IAAI,QAAQ;CACvB,MAAM,UAAU,GAAG,OAAO;CAC1B,MAAM,gBAAgB,OAAO,WAAW,CAAC,CAAC,QAAQ,MAAM,EAAE,CAAC,CAAC,YAAY;CACxE,MAAM,MAAM,KAAK,KAAK,SAAS,aAAa;CAC5C,MAAM,GAAG,MAAM,KAAK,EAAE,WAAW,KAAK,CAAC;CACvC,MAAM,IAAI,GAAG;CACb,MAAM,GAAG,GAAG,KAAK;EAAE,WAAW;EAAM,OAAO;CAAK,CAAC;CAGjD,MAAM,cAAc,KAAK,KAAK,GAAG,QAAQ,GAAG,QAAQ,aAAa;CACjE,MAAM,GAAG,GAAG,aAAa;EAAE,WAAW;EAAM,OAAO;CAAK,CAAC;AAC1D,EACD,CAAC"}
package/dist/os/index.cjs CHANGED
@@ -1,3 +1,3 @@
1
- const require_directory = require('../directory-DD_xQoSh.cjs');
2
-
3
- exports.itWithDir = require_directory.itWithDir;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_os_directory = require("./directory.cjs");
3
+ exports.itWithDir = require_os_directory.itWithDir;
@@ -1,2 +1,2 @@
1
- import { itWithDir } from "../directory-zIEh5ZPl.cjs";
1
+ import { itWithDir } from "./directory.cjs";
2
2
  export { itWithDir };
@@ -1,2 +1,2 @@
1
- import { itWithDir } from "../directory-DiQ_DkaF.mjs";
1
+ import { itWithDir } from "./directory.mjs";
2
2
  export { itWithDir };
package/dist/os/index.mjs CHANGED
@@ -1,3 +1,2 @@
1
- import { itWithDir } from "../directory-BxjqmtCT.mjs";
2
-
3
- export { itWithDir };
1
+ import { itWithDir } from "./directory.mjs";
2
+ export { itWithDir };
@@ -1,12 +1,11 @@
1
- const require_chunk = require('./chunk-CUT6urMc.cjs');
2
- const __geekmidas_services = require_chunk.__toESM(require("@geekmidas/services"));
3
- const node_crypto = require_chunk.__toESM(require("node:crypto"));
4
- const __geekmidas_logger_console = require_chunk.__toESM(require("@geekmidas/logger/console"));
5
-
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");
6
5
  //#region src/requestContext.ts
7
6
  function resolveContext(opts = {}) {
8
7
  return {
9
- logger: opts.logger ?? new __geekmidas_logger_console.ConsoleLogger({ app: "test" }),
8
+ logger: opts.logger ?? new _geekmidas_logger_console.ConsoleLogger({ app: "test" }),
10
9
  requestId: opts.requestId ?? (0, node_crypto.randomUUID)(),
11
10
  startTime: opts.startTime ?? Date.now()
12
11
  };
@@ -24,7 +23,7 @@ function resolveContext(opts = {}) {
24
23
  * ```
25
24
  */
26
25
  function runInRequestContext(fn, opts = {}) {
27
- return (0, __geekmidas_services.runWithRequestContext)(resolveContext(opts), fn);
26
+ return (0, _geekmidas_services.runWithRequestContext)(resolveContext(opts), fn);
28
27
  }
29
28
  /**
30
29
  * Vitest fixture creator. Spread the result into `.extend()` and every test
@@ -43,11 +42,11 @@ function runInRequestContext(fn, opts = {}) {
43
42
  */
44
43
  function requestContextFixture(opts = {}) {
45
44
  return { requestContext: [async ({}, use) => {
46
- (0, __geekmidas_services.enterRequestContext)(resolveContext(opts));
45
+ (0, _geekmidas_services.enterRequestContext)(resolveContext(opts));
47
46
  try {
48
- await use(__geekmidas_services.serviceContext);
47
+ await use(_geekmidas_services.serviceContext);
49
48
  } finally {
50
- (0, __geekmidas_services.exitRequestContext)();
49
+ (0, _geekmidas_services.exitRequestContext)();
51
50
  }
52
51
  }, { auto: true }] };
53
52
  }
@@ -72,9 +71,9 @@ function requestContextFixture(opts = {}) {
72
71
  function withRequestContext(testApi, opts = {}) {
73
72
  return testApi.extend(requestContextFixture(opts));
74
73
  }
75
-
76
74
  //#endregion
77
75
  exports.requestContextFixture = requestContextFixture;
78
76
  exports.runInRequestContext = runInRequestContext;
79
77
  exports.withRequestContext = withRequestContext;
78
+
80
79
  //# sourceMappingURL=requestContext.cjs.map
@@ -1 +1 @@
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
+ {"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,15 +1,13 @@
1
1
  import { ServiceContext } from "@geekmidas/services";
2
2
  import { TestAPI } from "vitest";
3
3
  import { Logger } from "@geekmidas/logger";
4
-
5
4
  //#region src/requestContext.d.ts
6
-
7
5
  /**
8
6
  * Options for setting up a request context in tests. Any field omitted
9
7
  * is filled with a test-friendly default (ConsoleLogger, random UUID,
10
8
  * Date.now()).
11
9
  */
12
- interface RequestContextOptions {
10
+ export interface RequestContextOptions {
13
11
  /** Logger exposed via serviceContext.getLogger(). */
14
12
  logger?: Logger;
15
13
  /** Request id exposed via serviceContext.getRequestId(). */
@@ -29,7 +27,7 @@ interface RequestContextOptions {
29
27
  * );
30
28
  * ```
31
29
  */
32
- declare function runInRequestContext<T>(fn: () => T | Promise<T>, opts?: RequestContextOptions): T | Promise<T>;
30
+ export declare function runInRequestContext<T>(fn: () => T | Promise<T>, opts?: RequestContextOptions): T | Promise<T>;
33
31
  /**
34
32
  * Vitest fixture creator. Spread the result into `.extend()` and every test
35
33
  * runs inside `runWithRequestContext`, even tests that don't destructure
@@ -45,7 +43,7 @@ declare function runInRequestContext<T>(fn: () => T | Promise<T>, opts?: Request
45
43
  * });
46
44
  * ```
47
45
  */
48
- declare function requestContextFixture(opts?: RequestContextOptions): {
46
+ export declare function requestContextFixture(opts?: RequestContextOptions): {
49
47
  requestContext: readonly [({}: {}, use: (value: ServiceContext) => Promise<void>) => Promise<void>, {
50
48
  readonly auto: true;
51
49
  }];
@@ -68,8 +66,6 @@ declare function requestContextFixture(opts?: RequestContextOptions): {
68
66
  * });
69
67
  * ```
70
68
  */
71
- declare function withRequestContext<T extends TestAPI | ReturnType<TestAPI['extend']>>(testApi: T, opts?: RequestContextOptions): T;
72
- //# sourceMappingURL=requestContext.d.ts.map
69
+ export declare function withRequestContext<T extends TestAPI | ReturnType<TestAPI['extend']>>(testApi: T, opts?: RequestContextOptions): T;
73
70
  //#endregion
74
- export { RequestContextOptions, requestContextFixture, runInRequestContext, withRequestContext };
75
71
  //# sourceMappingURL=requestContext.d.cts.map
@@ -1 +1 @@
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
+ {"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,15 +1,13 @@
1
1
  import { ServiceContext } from "@geekmidas/services";
2
2
  import { TestAPI } from "vitest";
3
3
  import { Logger } from "@geekmidas/logger";
4
-
5
4
  //#region src/requestContext.d.ts
6
-
7
5
  /**
8
6
  * Options for setting up a request context in tests. Any field omitted
9
7
  * is filled with a test-friendly default (ConsoleLogger, random UUID,
10
8
  * Date.now()).
11
9
  */
12
- interface RequestContextOptions {
10
+ export interface RequestContextOptions {
13
11
  /** Logger exposed via serviceContext.getLogger(). */
14
12
  logger?: Logger;
15
13
  /** Request id exposed via serviceContext.getRequestId(). */
@@ -29,7 +27,7 @@ interface RequestContextOptions {
29
27
  * );
30
28
  * ```
31
29
  */
32
- declare function runInRequestContext<T>(fn: () => T | Promise<T>, opts?: RequestContextOptions): T | Promise<T>;
30
+ export declare function runInRequestContext<T>(fn: () => T | Promise<T>, opts?: RequestContextOptions): T | Promise<T>;
33
31
  /**
34
32
  * Vitest fixture creator. Spread the result into `.extend()` and every test
35
33
  * runs inside `runWithRequestContext`, even tests that don't destructure
@@ -45,7 +43,7 @@ declare function runInRequestContext<T>(fn: () => T | Promise<T>, opts?: Request
45
43
  * });
46
44
  * ```
47
45
  */
48
- declare function requestContextFixture(opts?: RequestContextOptions): {
46
+ export declare function requestContextFixture(opts?: RequestContextOptions): {
49
47
  requestContext: readonly [({}: {}, use: (value: ServiceContext) => Promise<void>) => Promise<void>, {
50
48
  readonly auto: true;
51
49
  }];
@@ -68,8 +66,6 @@ declare function requestContextFixture(opts?: RequestContextOptions): {
68
66
  * });
69
67
  * ```
70
68
  */
71
- declare function withRequestContext<T extends TestAPI | ReturnType<TestAPI['extend']>>(testApi: T, opts?: RequestContextOptions): T;
72
- //# sourceMappingURL=requestContext.d.ts.map
69
+ export declare function withRequestContext<T extends TestAPI | ReturnType<TestAPI['extend']>>(testApi: T, opts?: RequestContextOptions): T;
73
70
  //#endregion
74
- export { RequestContextOptions, requestContextFixture, runInRequestContext, withRequestContext };
75
71
  //# sourceMappingURL=requestContext.d.mts.map
@@ -1 +1 @@
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
+ {"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,7 +1,6 @@
1
1
  import { enterRequestContext, exitRequestContext, runWithRequestContext, serviceContext } from "@geekmidas/services";
2
2
  import { randomUUID } from "node:crypto";
3
3
  import { ConsoleLogger } from "@geekmidas/logger/console";
4
-
5
4
  //#region src/requestContext.ts
6
5
  function resolveContext(opts = {}) {
7
6
  return {
@@ -71,7 +70,7 @@ function requestContextFixture(opts = {}) {
71
70
  function withRequestContext(testApi, opts = {}) {
72
71
  return testApi.extend(requestContextFixture(opts));
73
72
  }
74
-
75
73
  //#endregion
76
74
  export { requestContextFixture, runInRequestContext, withRequestContext };
75
+
77
76
  //# sourceMappingURL=requestContext.mjs.map
@@ -1 +1 @@
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"}
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,4 +1,4 @@
1
- //#region rolldown:runtime
1
+ //#region \0rolldown/runtime.js
2
2
  var __create = Object.create;
3
3
  var __defProp = Object.defineProperty;
4
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -15,16 +15,14 @@ var __copyProps = (to, from, except, desc) => {
15
15
  }
16
16
  return to;
17
17
  };
18
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
18
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
19
19
  value: mod,
20
20
  enumerable: true
21
21
  }) : target, mod));
22
-
23
22
  //#endregion
24
-
25
- Object.defineProperty(exports, '__toESM', {
26
- enumerable: true,
27
- get: function () {
28
- return __toESM;
29
- }
30
- });
23
+ Object.defineProperty(exports, "__toESM", {
24
+ enumerable: true,
25
+ get: function() {
26
+ return __toESM;
27
+ }
28
+ });
package/dist/timer.cjs CHANGED
@@ -1,9 +1,9 @@
1
-
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  //#region src/timer.ts
3
3
  function waitFor(ms) {
4
4
  return new Promise((resolve) => setTimeout(resolve, ms));
5
5
  }
6
-
7
6
  //#endregion
8
7
  exports.waitFor = waitFor;
8
+
9
9
  //# sourceMappingURL=timer.cjs.map
@@ -1 +1 @@
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"}
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"}
package/dist/timer.d.cts CHANGED
@@ -1,7 +1,4 @@
1
1
  //#region src/timer.d.ts
2
- declare function waitFor(ms: number): Promise<unknown>;
3
- //# sourceMappingURL=timer.d.ts.map
4
-
2
+ export declare function waitFor(ms: number): Promise<unknown>;
5
3
  //#endregion
6
- export { waitFor };
7
4
  //# sourceMappingURL=timer.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"timer.d.cts","names":[],"sources":["../src/timer.ts"],"sourcesContent":[],"mappings":";iBAAgB,OAAA,cAAkB;AAAlC"}
1
+ {"version":3,"file":"timer.d.cts","names":[],"sources":["../src/timer.ts"],"mappings":";wBAAgB,QAAQ,aAAU"}
package/dist/timer.d.mts CHANGED
@@ -1,7 +1,4 @@
1
1
  //#region src/timer.d.ts
2
- declare function waitFor(ms: number): Promise<unknown>;
3
- //# sourceMappingURL=timer.d.ts.map
4
-
2
+ export declare function waitFor(ms: number): Promise<unknown>;
5
3
  //#endregion
6
- export { waitFor };
7
4
  //# sourceMappingURL=timer.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"timer.d.mts","names":[],"sources":["../src/timer.ts"],"sourcesContent":[],"mappings":";iBAAgB,OAAA,cAAkB;AAAlC"}
1
+ {"version":3,"file":"timer.d.mts","names":[],"sources":["../src/timer.ts"],"mappings":";wBAAgB,QAAQ,aAAU"}
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
-
6
5
  //#endregion
7
6
  export { waitFor };
7
+
8
8
  //# sourceMappingURL=timer.mjs.map
@@ -1 +1 @@
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"}
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"}
@@ -0,0 +1,123 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_rolldown_runtime = require("./rolldown-runtime-VH7oDXx4.cjs");
3
+ let pg = require("pg");
4
+ pg = require_rolldown_runtime.__toESM(pg, 1);
5
+ let kysely = require("kysely");
6
+ //#region src/transactions.ts
7
+ /**
8
+ * A transaction per database, per test — as each runs deployed.
9
+ *
10
+ * An app's database and a schema tenant such as the auth server's are separate
11
+ * databases to the code using them: separate connections, credentials, roles
12
+ * and search paths. A test keeps them that way. Each gets its own connection,
13
+ * opened into a transaction the first time the test touches it, and every one
14
+ * is rolled back when the test ends.
15
+ *
16
+ * Code under test must be free to use transactions itself, and better-auth
17
+ * does — it also calls `db.connection()`, which Kysely refuses on a
18
+ * `Transaction`. So what a test hands over is not a `Transaction` but a Kysely
19
+ * over the one connection already inside the test's transaction, on which a
20
+ * `BEGIN` becomes a savepoint and a `COMMIT` releases it. Nothing the code does
21
+ * can end the transaction the test will roll back.
22
+ */
23
+ /**
24
+ * The connection settings for a database URL.
25
+ *
26
+ * `?search_path=` is not a libpq parameter: a URL carrying it connects and then
27
+ * resolves every name against `public`. Postgres takes it as a startup option,
28
+ * which is what a schema tenant's URL needs to reach its own tables.
29
+ */
30
+ function connectionConfig(url) {
31
+ const parsed = new URL(url);
32
+ const searchPath = parsed.searchParams.get("search_path");
33
+ if (!searchPath) return { connectionString: url };
34
+ parsed.searchParams.delete("search_path");
35
+ return {
36
+ connectionString: parsed.toString(),
37
+ options: `-c search_path=${searchPath}`
38
+ };
39
+ }
40
+ /**
41
+ * Open a connection to `url` and begin the transaction a test will roll back.
42
+ *
43
+ * `config` is what the database's own clients are built with — its plugins
44
+ * above all. The code under test is handed this Kysely in place of its own, so
45
+ * one built without them runs different queries than production does.
46
+ */
47
+ async function openBoundTransaction(url, config = {}) {
48
+ const client = new pg.default.Client(connectionConfig(url));
49
+ await client.connect();
50
+ await client.query("BEGIN");
51
+ return {
52
+ db: new kysely.Kysely({
53
+ ...config,
54
+ dialect: new kysely.PostgresDialect({ pool: {
55
+ connect: async () => savepointing(client),
56
+ end: async () => {}
57
+ } })
58
+ }),
59
+ async rollback() {
60
+ try {
61
+ await client.query("ROLLBACK");
62
+ } finally {
63
+ await client.end();
64
+ }
65
+ }
66
+ };
67
+ }
68
+ /**
69
+ * The client, with transaction control turned into savepoints.
70
+ *
71
+ * Kysely issues `begin`/`commit`/`rollback` as plain statements; this is the
72
+ * one place they can be caught. A depth counter names the savepoints, so
73
+ * nested transactions nest.
74
+ */
75
+ function savepointing(client) {
76
+ let depth = 0;
77
+ const query = client.query.bind(client);
78
+ const wrapped = Object.create(client);
79
+ Object.assign(wrapped, {
80
+ query: (text, ...rest) => {
81
+ const statement = typeof text === "string" ? text.trim().toLowerCase() : void 0;
82
+ if (statement === "begin" || statement?.startsWith("start transaction")) {
83
+ depth++;
84
+ return query(`SAVEPOINT test_sp_${depth}`);
85
+ }
86
+ if (statement === "commit") return query(`RELEASE SAVEPOINT test_sp_${depth--}`);
87
+ if (statement === "rollback") return query(`ROLLBACK TO SAVEPOINT test_sp_${depth--}`);
88
+ return query(text, ...rest);
89
+ },
90
+ release: () => {}
91
+ });
92
+ return wrapped;
93
+ }
94
+ /**
95
+ * The transactions one test has opened, by database.
96
+ *
97
+ * `get` opens a database's transaction the first time it is asked for and
98
+ * hands back the same one after that — including to a caller that asks while
99
+ * it is still opening. `rollbackAll` ends every one of them.
100
+ */
101
+ var TransactionRegistry = class {
102
+ open = /* @__PURE__ */ new Map();
103
+ get(key, url, config) {
104
+ let transaction = this.open.get(key);
105
+ if (!transaction) {
106
+ transaction = openBoundTransaction(url, config);
107
+ this.open.set(key, transaction);
108
+ }
109
+ return transaction.then(({ db }) => db);
110
+ }
111
+ async rollbackAll() {
112
+ const transactions = [...this.open.values()];
113
+ this.open.clear();
114
+ const failed = (await Promise.allSettled(transactions.map(async (transaction) => (await transaction).rollback()))).find((result) => result.status === "rejected");
115
+ if (failed) throw failed.reason;
116
+ }
117
+ };
118
+ //#endregion
119
+ exports.TransactionRegistry = TransactionRegistry;
120
+ exports.connectionConfig = connectionConfig;
121
+ exports.openBoundTransaction = openBoundTransaction;
122
+
123
+ //# sourceMappingURL=transactions.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transactions.cjs","names":["Kysely","PostgresDialect"],"sources":["../src/transactions.ts"],"sourcesContent":["/**\n * A transaction per database, per test — as each runs deployed.\n *\n * An app's database and a schema tenant such as the auth server's are separate\n * databases to the code using them: separate connections, credentials, roles\n * and search paths. A test keeps them that way. Each gets its own connection,\n * opened into a transaction the first time the test touches it, and every one\n * is rolled back when the test ends.\n *\n * Code under test must be free to use transactions itself, and better-auth\n * does — it also calls `db.connection()`, which Kysely refuses on a\n * `Transaction`. So what a test hands over is not a `Transaction` but a Kysely\n * over the one connection already inside the test's transaction, on which a\n * `BEGIN` becomes a savepoint and a `COMMIT` releases it. Nothing the code does\n * can end the transaction the test will roll back.\n */\n\nimport { Kysely, type KyselyConfig, PostgresDialect } from 'kysely';\nimport pg from 'pg';\n\n/** How to reach one database: a URL, and its search path as a startup option. */\nexport interface ConnectionConfig {\n\tconnectionString: string;\n\toptions?: string;\n}\n\n/**\n * The connection settings for a database URL.\n *\n * `?search_path=` is not a libpq parameter: a URL carrying it connects and then\n * resolves every name against `public`. Postgres takes it as a startup option,\n * which is what a schema tenant's URL needs to reach its own tables.\n */\nexport function connectionConfig(url: string): ConnectionConfig {\n\tconst parsed = new URL(url);\n\tconst searchPath = parsed.searchParams.get('search_path');\n\tif (!searchPath) return { connectionString: url };\n\n\tparsed.searchParams.delete('search_path');\n\treturn {\n\t\tconnectionString: parsed.toString(),\n\t\toptions: `-c search_path=${searchPath}`,\n\t};\n}\n\n/** One database's connection, inside a transaction the test will roll back. */\nexport interface BoundTransaction {\n\t/** Everything queried through this runs inside the test's transaction. */\n\treadonly db: Kysely<any>;\n\t/** Undo everything, and let the connection go. */\n\trollback(): Promise<void>;\n}\n\n/**\n * Open a connection to `url` and begin the transaction a test will roll back.\n *\n * `config` is what the database's own clients are built with — its plugins\n * above all. The code under test is handed this Kysely in place of its own, so\n * one built without them runs different queries than production does.\n */\nexport async function openBoundTransaction(\n\turl: string,\n\tconfig: Omit<KyselyConfig, 'dialect'> = {},\n): Promise<BoundTransaction> {\n\tconst client = new pg.Client(connectionConfig(url));\n\tawait client.connect();\n\tawait client.query('BEGIN');\n\n\treturn {\n\t\tdb: new Kysely({\n\t\t\t...config,\n\t\t\tdialect: new PostgresDialect({\n\t\t\t\t// A \"pool\" of the one connection. Released never, ended never: the\n\t\t\t\t// test owns it, and it closes in `rollback`.\n\t\t\t\tpool: {\n\t\t\t\t\tconnect: async () => savepointing(client),\n\t\t\t\t\tend: async () => {},\n\t\t\t\t} as unknown as pg.Pool,\n\t\t\t}),\n\t\t}),\n\t\tasync rollback() {\n\t\t\ttry {\n\t\t\t\tawait client.query('ROLLBACK');\n\t\t\t} finally {\n\t\t\t\tawait client.end();\n\t\t\t}\n\t\t},\n\t};\n}\n\n/**\n * The client, with transaction control turned into savepoints.\n *\n * Kysely issues `begin`/`commit`/`rollback` as plain statements; this is the\n * one place they can be caught. A depth counter names the savepoints, so\n * nested transactions nest.\n */\nfunction savepointing(client: pg.Client): pg.PoolClient {\n\tlet depth = 0;\n\tconst query = client.query.bind(client) as (...args: unknown[]) => unknown;\n\n\tconst wrapped = Object.create(client) as pg.PoolClient;\n\tObject.assign(wrapped, {\n\t\tquery: (text: unknown, ...rest: unknown[]) => {\n\t\t\tconst statement =\n\t\t\t\ttypeof text === 'string' ? text.trim().toLowerCase() : undefined;\n\n\t\t\tif (statement === 'begin' || statement?.startsWith('start transaction')) {\n\t\t\t\tdepth++;\n\t\t\t\treturn query(`SAVEPOINT test_sp_${depth}`);\n\t\t\t}\n\t\t\tif (statement === 'commit') {\n\t\t\t\treturn query(`RELEASE SAVEPOINT test_sp_${depth--}`);\n\t\t\t}\n\t\t\tif (statement === 'rollback') {\n\t\t\t\treturn query(`ROLLBACK TO SAVEPOINT test_sp_${depth--}`);\n\t\t\t}\n\t\t\treturn query(text, ...rest);\n\t\t},\n\t\trelease: () => {},\n\t});\n\treturn wrapped;\n}\n\n/**\n * The transactions one test has opened, by database.\n *\n * `get` opens a database's transaction the first time it is asked for and\n * hands back the same one after that — including to a caller that asks while\n * it is still opening. `rollbackAll` ends every one of them.\n */\nexport class TransactionRegistry<TKey = string> {\n\tprivate readonly open = new Map<TKey, Promise<BoundTransaction>>();\n\n\tget(\n\t\tkey: TKey,\n\t\turl: string,\n\t\tconfig?: Omit<KyselyConfig, 'dialect'>,\n\t): Promise<Kysely<any>> {\n\t\tlet transaction = this.open.get(key);\n\t\tif (!transaction) {\n\t\t\ttransaction = openBoundTransaction(url, config);\n\t\t\tthis.open.set(key, transaction);\n\t\t}\n\t\treturn transaction.then(({ db }) => db);\n\t}\n\n\tasync rollbackAll(): Promise<void> {\n\t\tconst transactions = [...this.open.values()];\n\t\tthis.open.clear();\n\n\t\tconst results = await Promise.allSettled(\n\t\t\ttransactions.map(async (transaction) => (await transaction).rollback()),\n\t\t);\n\t\tconst failed = results.find(\n\t\t\t(result): result is PromiseRejectedResult => result.status === 'rejected',\n\t\t);\n\t\tif (failed) throw failed.reason;\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCA,SAAgB,iBAAiB,KAA+B;CAC/D,MAAM,SAAS,IAAI,IAAI,GAAG;CAC1B,MAAM,aAAa,OAAO,aAAa,IAAI,aAAa;CACxD,IAAI,CAAC,YAAY,OAAO,EAAE,kBAAkB,IAAI;CAEhD,OAAO,aAAa,OAAO,aAAa;CACxC,OAAO;EACN,kBAAkB,OAAO,SAAS;EAClC,SAAS,kBAAkB;CAC5B;AACD;;;;;;;;AAiBA,eAAsB,qBACrB,KACA,SAAwC,CAAC,GACb;CAC5B,MAAM,SAAS,IAAI,GAAA,QAAG,OAAO,iBAAiB,GAAG,CAAC;CAClD,MAAM,OAAO,QAAQ;CACrB,MAAM,OAAO,MAAM,OAAO;CAE1B,OAAO;EACN,IAAI,IAAIA,OAAAA,OAAO;GACd,GAAG;GACH,SAAS,IAAIC,OAAAA,gBAAgB,EAG5B,MAAM;IACL,SAAS,YAAY,aAAa,MAAM;IACxC,KAAK,YAAY,CAAC;GACnB,EACD,CAAC;EACF,CAAC;EACD,MAAM,WAAW;GAChB,IAAI;IACH,MAAM,OAAO,MAAM,UAAU;GAC9B,UAAU;IACT,MAAM,OAAO,IAAI;GAClB;EACD;CACD;AACD;;;;;;;;AASA,SAAS,aAAa,QAAkC;CACvD,IAAI,QAAQ;CACZ,MAAM,QAAQ,OAAO,MAAM,KAAK,MAAM;CAEtC,MAAM,UAAU,OAAO,OAAO,MAAM;CACpC,OAAO,OAAO,SAAS;EACtB,QAAQ,MAAe,GAAG,SAAoB;GAC7C,MAAM,YACL,OAAO,SAAS,WAAW,KAAK,KAAK,CAAC,CAAC,YAAY,IAAI,KAAA;GAExD,IAAI,cAAc,WAAW,WAAW,WAAW,mBAAmB,GAAG;IACxE;IACA,OAAO,MAAM,qBAAqB,OAAO;GAC1C;GACA,IAAI,cAAc,UACjB,OAAO,MAAM,6BAA6B,SAAS;GAEpD,IAAI,cAAc,YACjB,OAAO,MAAM,iCAAiC,SAAS;GAExD,OAAO,MAAM,MAAM,GAAG,IAAI;EAC3B;EACA,eAAe,CAAC;CACjB,CAAC;CACD,OAAO;AACR;;;;;;;;AASA,IAAa,sBAAb,MAAgD;CAC/C,uBAAwB,IAAI,IAAqC;CAEjE,IACC,KACA,KACA,QACuB;EACvB,IAAI,cAAc,KAAK,KAAK,IAAI,GAAG;EACnC,IAAI,CAAC,aAAa;GACjB,cAAc,qBAAqB,KAAK,MAAM;GAC9C,KAAK,KAAK,IAAI,KAAK,WAAW;EAC/B;EACA,OAAO,YAAY,MAAM,EAAE,SAAS,EAAE;CACvC;CAEA,MAAM,cAA6B;EAClC,MAAM,eAAe,CAAC,GAAG,KAAK,KAAK,OAAO,CAAC;EAC3C,KAAK,KAAK,MAAM;EAKhB,MAAM,UAAS,MAHO,QAAQ,WAC7B,aAAa,IAAI,OAAO,iBAAiB,MAAM,YAAA,CAAa,SAAS,CAAC,CACvE,EAAA,CACuB,MACrB,WAA4C,OAAO,WAAW,UAChE;EACA,IAAI,QAAQ,MAAM,OAAO;CAC1B;AACD"}