@geekmidas/testkit 0.4.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (209) hide show
  1. package/dist/Factory-BFVnMMCC.mjs.map +1 -1
  2. package/dist/Factory-BhjUOBWN.cjs.map +1 -1
  3. package/dist/{Factory-c16c27Y6.d.cts → Factory-Bx0AJXZB.d.cts} +3 -2
  4. package/dist/Factory-Bx0AJXZB.d.cts.map +1 -0
  5. package/dist/{Factory-BcGJjLc8.d.mts → Factory-SFupxRC2.d.mts} +2 -1
  6. package/dist/Factory-SFupxRC2.d.mts.map +1 -0
  7. package/dist/Factory.d.cts +2 -2
  8. package/dist/Factory.d.mts +1 -1
  9. package/dist/KyselyFactory-BFqVIn_0.cjs.map +1 -1
  10. package/dist/KyselyFactory-DMswpwji.mjs.map +1 -1
  11. package/dist/{KyselyFactory-uZ45h7YU.d.cts → KyselyFactory-KLeKH43i.d.cts} +4 -3
  12. package/dist/KyselyFactory-KLeKH43i.d.cts.map +1 -0
  13. package/dist/{KyselyFactory-Cj-EultY.d.mts → KyselyFactory-vAxYodck.d.mts} +3 -2
  14. package/dist/KyselyFactory-vAxYodck.d.mts.map +1 -0
  15. package/dist/KyselyFactory.d.cts +3 -3
  16. package/dist/KyselyFactory.d.mts +2 -2
  17. package/dist/{ObjectionFactory-DL4qkuF1.d.mts → ObjectionFactory-BWjB49-i.d.mts} +3 -2
  18. package/dist/ObjectionFactory-BWjB49-i.d.mts.map +1 -0
  19. package/dist/ObjectionFactory-BeFBYcan.cjs.map +1 -1
  20. package/dist/ObjectionFactory-QCJ7u0Ql.mjs.map +1 -1
  21. package/dist/{ObjectionFactory-CdhzKs4f.d.cts → ObjectionFactory-aMGvAKt9.d.cts} +4 -3
  22. package/dist/ObjectionFactory-aMGvAKt9.d.cts.map +1 -0
  23. package/dist/ObjectionFactory.d.cts +3 -3
  24. package/dist/ObjectionFactory.d.mts +2 -2
  25. package/dist/{PostgresKyselyMigrator-upT-hmrz.mjs → PostgresKyselyMigrator-6sE1KOni.mjs} +2 -2
  26. package/dist/PostgresKyselyMigrator-6sE1KOni.mjs.map +1 -0
  27. package/dist/{PostgresKyselyMigrator-CIx3AFSR.d.mts → PostgresKyselyMigrator-CBltSOq5.d.cts} +3 -2
  28. package/dist/PostgresKyselyMigrator-CBltSOq5.d.cts.map +1 -0
  29. package/dist/{PostgresKyselyMigrator-CfytARcA.cjs → PostgresKyselyMigrator-D6IbPq8t.cjs} +2 -2
  30. package/dist/PostgresKyselyMigrator-D6IbPq8t.cjs.map +1 -0
  31. package/dist/{PostgresKyselyMigrator-CQ3aUoy_.d.cts → PostgresKyselyMigrator-DrVWncqd.d.mts} +3 -2
  32. package/dist/PostgresKyselyMigrator-DrVWncqd.d.mts.map +1 -0
  33. package/dist/PostgresKyselyMigrator.cjs +2 -2
  34. package/dist/PostgresKyselyMigrator.d.cts +2 -2
  35. package/dist/PostgresKyselyMigrator.d.mts +2 -2
  36. package/dist/PostgresKyselyMigrator.mjs +2 -2
  37. package/dist/{PostgresMigrator-DbuJGAVy.mjs → PostgresMigrator-BjjenqSd.mjs} +2 -2
  38. package/dist/PostgresMigrator-BjjenqSd.mjs.map +1 -0
  39. package/dist/{PostgresMigrator-D5UkK1_K.d.cts → PostgresMigrator-Bres0U6E.d.cts} +2 -1
  40. package/dist/PostgresMigrator-Bres0U6E.d.cts.map +1 -0
  41. package/dist/{PostgresMigrator-DFcNdCvD.cjs → PostgresMigrator-D6dQn0x2.cjs} +2 -2
  42. package/dist/PostgresMigrator-D6dQn0x2.cjs.map +1 -0
  43. package/dist/{PostgresMigrator-DQaRxoaY.d.mts → PostgresMigrator-S-YYosAC.d.mts} +2 -1
  44. package/dist/PostgresMigrator-S-YYosAC.d.mts.map +1 -0
  45. package/dist/PostgresMigrator.cjs +1 -1
  46. package/dist/PostgresMigrator.d.cts +1 -1
  47. package/dist/PostgresMigrator.d.mts +1 -1
  48. package/dist/PostgresMigrator.mjs +1 -1
  49. package/dist/{PostgresObjectionMigrator-CZHHcCOv.d.cts → PostgresObjectionMigrator-CPfBAP7r.d.cts} +3 -2
  50. package/dist/PostgresObjectionMigrator-CPfBAP7r.d.cts.map +1 -0
  51. package/dist/{PostgresObjectionMigrator-BG6ymgnt.cjs → PostgresObjectionMigrator-DK8ODIHQ.cjs} +2 -2
  52. package/dist/PostgresObjectionMigrator-DK8ODIHQ.cjs.map +1 -0
  53. package/dist/{PostgresObjectionMigrator-D_hCcrQu.d.mts → PostgresObjectionMigrator-DVEqB5tp.d.mts} +3 -2
  54. package/dist/PostgresObjectionMigrator-DVEqB5tp.d.mts.map +1 -0
  55. package/dist/{PostgresObjectionMigrator-DPj2pOpX.mjs → PostgresObjectionMigrator-D_QxXbIN.mjs} +2 -2
  56. package/dist/PostgresObjectionMigrator-D_QxXbIN.mjs.map +1 -0
  57. package/dist/PostgresObjectionMigrator.cjs +2 -2
  58. package/dist/PostgresObjectionMigrator.d.cts +2 -2
  59. package/dist/PostgresObjectionMigrator.d.mts +2 -2
  60. package/dist/PostgresObjectionMigrator.mjs +2 -2
  61. package/dist/{VitestKyselyTransactionIsolator-D3EZZhjZ.d.cts → VitestKyselyTransactionIsolator-CduJlHoT.d.cts} +4 -3
  62. package/dist/VitestKyselyTransactionIsolator-CduJlHoT.d.cts.map +1 -0
  63. package/dist/{VitestKyselyTransactionIsolator-Dxlp1u0f.d.mts → VitestKyselyTransactionIsolator-Cswnnj0k.d.mts} +4 -3
  64. package/dist/VitestKyselyTransactionIsolator-Cswnnj0k.d.mts.map +1 -0
  65. package/dist/{VitestKyselyTransactionIsolator-EvDLk5zg.cjs → VitestKyselyTransactionIsolator-D7RRXOBa.cjs} +2 -2
  66. package/dist/VitestKyselyTransactionIsolator-D7RRXOBa.cjs.map +1 -0
  67. package/dist/{VitestKyselyTransactionIsolator-CNURW8y6.mjs → VitestKyselyTransactionIsolator-DceyIqr4.mjs} +2 -2
  68. package/dist/VitestKyselyTransactionIsolator-DceyIqr4.mjs.map +1 -0
  69. package/dist/VitestKyselyTransactionIsolator.cjs +1 -1
  70. package/dist/VitestKyselyTransactionIsolator.d.cts +2 -2
  71. package/dist/VitestKyselyTransactionIsolator.d.mts +2 -2
  72. package/dist/VitestKyselyTransactionIsolator.mjs +1 -1
  73. package/dist/{VitestObjectionTransactionIsolator-1TpsPqfG.d.cts → VitestObjectionTransactionIsolator-BXoR6xdG.d.cts} +4 -3
  74. package/dist/VitestObjectionTransactionIsolator-BXoR6xdG.d.cts.map +1 -0
  75. package/dist/{VitestObjectionTransactionIsolator-CM5KTAFA.cjs → VitestObjectionTransactionIsolator-CdLRrzNf.cjs} +2 -2
  76. package/dist/VitestObjectionTransactionIsolator-CdLRrzNf.cjs.map +1 -0
  77. package/dist/{VitestObjectionTransactionIsolator-jQFaCz0u.mjs → VitestObjectionTransactionIsolator-OF2osYY5.mjs} +2 -2
  78. package/dist/VitestObjectionTransactionIsolator-OF2osYY5.mjs.map +1 -0
  79. package/dist/{VitestObjectionTransactionIsolator-i9jIgU8Q.d.mts → VitestObjectionTransactionIsolator-x6hY5j4u.d.mts} +4 -3
  80. package/dist/VitestObjectionTransactionIsolator-x6hY5j4u.d.mts.map +1 -0
  81. package/dist/VitestObjectionTransactionIsolator.cjs +1 -1
  82. package/dist/VitestObjectionTransactionIsolator.d.cts +2 -2
  83. package/dist/VitestObjectionTransactionIsolator.d.mts +2 -2
  84. package/dist/VitestObjectionTransactionIsolator.mjs +1 -1
  85. package/dist/{VitestTransactionIsolator-BvR19bYn.d.mts → VitestTransactionIsolator-BNWJqh9f.d.mts} +3 -2
  86. package/dist/VitestTransactionIsolator-BNWJqh9f.d.mts.map +1 -0
  87. package/dist/VitestTransactionIsolator-CMfJXZP8.cjs.map +1 -1
  88. package/dist/{VitestTransactionIsolator-CwQaxZLP.d.cts → VitestTransactionIsolator-CSroc7Df.d.cts} +3 -2
  89. package/dist/VitestTransactionIsolator-CSroc7Df.d.cts.map +1 -0
  90. package/dist/VitestTransactionIsolator-DQ7tLqgV.mjs.map +1 -1
  91. package/dist/VitestTransactionIsolator.d.cts +1 -1
  92. package/dist/VitestTransactionIsolator.d.mts +1 -1
  93. package/dist/aws.cjs.map +1 -1
  94. package/dist/aws.d.cts +2 -0
  95. package/dist/aws.d.cts.map +1 -0
  96. package/dist/aws.d.mts +2 -0
  97. package/dist/aws.d.mts.map +1 -0
  98. package/dist/aws.mjs.map +1 -1
  99. package/dist/benchmark.cjs.map +1 -1
  100. package/dist/benchmark.d.cts +1 -0
  101. package/dist/benchmark.d.cts.map +1 -0
  102. package/dist/benchmark.d.mts +1 -0
  103. package/dist/benchmark.d.mts.map +1 -0
  104. package/dist/benchmark.mjs.map +1 -1
  105. package/dist/better-auth.cjs +29 -30
  106. package/dist/better-auth.cjs.map +1 -1
  107. package/dist/better-auth.d.cts +2 -2
  108. package/dist/better-auth.d.cts.map +1 -0
  109. package/dist/better-auth.d.mts.map +1 -0
  110. package/dist/better-auth.mjs +29 -30
  111. package/dist/better-auth.mjs.map +1 -1
  112. package/dist/directory-B-Ozljzk.mjs.map +1 -1
  113. package/dist/directory-BVC8g7cX.cjs.map +1 -1
  114. package/dist/{directory-BXavAeJZ.d.mts → directory-CVrfTq1I.d.mts} +2 -1
  115. package/dist/directory-CVrfTq1I.d.mts.map +1 -0
  116. package/dist/directory-Cys9g76X.d.cts +13 -0
  117. package/dist/directory-Cys9g76X.d.cts.map +1 -0
  118. package/dist/faker-B14IEMIN.cjs.map +1 -1
  119. package/dist/faker-BGKYFoCT.mjs.map +1 -1
  120. package/dist/{faker-DvxiCtxc.d.cts → faker-BSH1EMtg.d.cts} +3 -3
  121. package/dist/faker-BSH1EMtg.d.cts.map +1 -0
  122. package/dist/faker-DHh7xs4u.d.mts.map +1 -0
  123. package/dist/faker.d.cts +1 -1
  124. package/dist/helpers.cjs.map +1 -1
  125. package/dist/helpers.d.cts +1 -0
  126. package/dist/helpers.d.cts.map +1 -0
  127. package/dist/helpers.d.mts +1 -0
  128. package/dist/helpers.d.mts.map +1 -0
  129. package/dist/helpers.mjs.map +1 -1
  130. package/dist/kysely.cjs +3 -3
  131. package/dist/kysely.cjs.map +1 -1
  132. package/dist/kysely.d.cts +8 -7
  133. package/dist/kysely.d.cts.map +1 -0
  134. package/dist/kysely.d.mts +7 -6
  135. package/dist/kysely.d.mts.map +1 -0
  136. package/dist/kysely.mjs +3 -3
  137. package/dist/kysely.mjs.map +1 -1
  138. package/dist/logger.cjs.map +1 -1
  139. package/dist/logger.d.cts +1 -0
  140. package/dist/logger.d.cts.map +1 -0
  141. package/dist/logger.d.mts +1 -0
  142. package/dist/logger.d.mts.map +1 -0
  143. package/dist/logger.mjs.map +1 -1
  144. package/dist/objection.cjs +3 -3
  145. package/dist/objection.cjs.map +1 -1
  146. package/dist/objection.d.cts +8 -7
  147. package/dist/objection.d.cts.map +1 -0
  148. package/dist/objection.d.mts +7 -6
  149. package/dist/objection.d.mts.map +1 -0
  150. package/dist/objection.mjs +3 -3
  151. package/dist/objection.mjs.map +1 -1
  152. package/dist/os/directory.d.cts +1 -1
  153. package/dist/os/directory.d.mts +1 -1
  154. package/dist/os/index.d.cts +1 -1
  155. package/dist/os/index.d.mts +1 -1
  156. package/dist/timer.cjs.map +1 -1
  157. package/dist/timer.d.cts +2 -0
  158. package/dist/timer.d.cts.map +1 -0
  159. package/dist/timer.d.mts +2 -0
  160. package/dist/timer.d.mts.map +1 -0
  161. package/dist/timer.mjs.map +1 -1
  162. package/package.json +5 -5
  163. package/src/Factory.ts +72 -72
  164. package/src/KyselyFactory.ts +330 -330
  165. package/src/ObjectionFactory.ts +354 -355
  166. package/src/PostgresKyselyMigrator.ts +37 -37
  167. package/src/PostgresMigrator.ts +107 -107
  168. package/src/PostgresObjectionMigrator.ts +91 -91
  169. package/src/VitestKyselyTransactionIsolator.ts +27 -27
  170. package/src/VitestObjectionTransactionIsolator.ts +39 -39
  171. package/src/VitestTransactionIsolator.ts +196 -195
  172. package/src/__tests__/Factory.spec.ts +163 -155
  173. package/src/__tests__/KyselyFactory.spec.ts +443 -439
  174. package/src/__tests__/ObjectionFactory.spec.ts +563 -557
  175. package/src/__tests__/PostgresKyselyMigrator.spec.ts +641 -641
  176. package/src/__tests__/PostgresMigrator.spec.ts +341 -341
  177. package/src/__tests__/PostgresObjectionMigrator.spec.ts +578 -578
  178. package/src/__tests__/VitestObjectionTransactionIsolator.spec.ts +114 -114
  179. package/src/__tests__/benchmark.spec.ts +140 -0
  180. package/src/__tests__/better-auth.spec.ts +15 -15
  181. package/src/__tests__/faker.spec.ts +226 -137
  182. package/src/__tests__/integration.spec.ts +597 -597
  183. package/src/__tests__/utilities.spec.ts +211 -0
  184. package/src/aws.ts +104 -104
  185. package/src/benchmark.ts +12 -12
  186. package/src/better-auth.ts +286 -301
  187. package/src/faker.ts +153 -153
  188. package/src/helpers.ts +6 -6
  189. package/src/kysely.ts +33 -33
  190. package/src/logger.ts +10 -10
  191. package/src/objection.ts +31 -31
  192. package/src/os/directory.ts +11 -10
  193. package/src/timer.ts +1 -1
  194. package/test/globalSetup.ts +45 -45
  195. package/test/helpers.ts +189 -189
  196. package/test/migrations/1749664623372_user.ts +13 -13
  197. package/tsconfig.json +9 -0
  198. package/vitest.config.ts +4 -4
  199. package/dist/PostgresKyselyMigrator-CfytARcA.cjs.map +0 -1
  200. package/dist/PostgresKyselyMigrator-upT-hmrz.mjs.map +0 -1
  201. package/dist/PostgresMigrator-DFcNdCvD.cjs.map +0 -1
  202. package/dist/PostgresMigrator-DbuJGAVy.mjs.map +0 -1
  203. package/dist/PostgresObjectionMigrator-BG6ymgnt.cjs.map +0 -1
  204. package/dist/PostgresObjectionMigrator-DPj2pOpX.mjs.map +0 -1
  205. package/dist/VitestKyselyTransactionIsolator-CNURW8y6.mjs.map +0 -1
  206. package/dist/VitestKyselyTransactionIsolator-EvDLk5zg.cjs.map +0 -1
  207. package/dist/VitestObjectionTransactionIsolator-CM5KTAFA.cjs.map +0 -1
  208. package/dist/VitestObjectionTransactionIsolator-jQFaCz0u.mjs.map +0 -1
  209. package/dist/directory-Mi7tdOuD.d.cts +0 -12
@@ -1,4 +1,4 @@
1
- import { IsolationLevel, VitestPostgresTransactionIsolator } from "./VitestTransactionIsolator-BvR19bYn.mjs";
1
+ import { IsolationLevel, VitestPostgresTransactionIsolator } from "./VitestTransactionIsolator-BNWJqh9f.mjs";
2
2
  import { Knex } from "knex";
3
3
 
4
4
  //#region src/VitestObjectionTransactionIsolator.d.ts
@@ -32,7 +32,7 @@ import { Knex } from "knex";
32
32
  * ```
33
33
  */
34
34
  declare class VitestObjectionTransactionIsolator extends VitestPostgresTransactionIsolator<Knex, Knex.Transaction> {
35
- destroy(conn: Knex<any, any[]>): Promise<void>;
35
+ destroy(_conn: Knex<any, any[]>): Promise<void>;
36
36
  /**
37
37
  * Creates a Knex transaction with the specified isolation level.
38
38
  * Implements the abstract transact method from VitestPostgresTransactionIsolator.
@@ -54,6 +54,7 @@ declare class VitestObjectionTransactionIsolator extends VitestPostgresTransacti
54
54
  */
55
55
  transact(connection: Knex, level: IsolationLevel, fn: (trx: Knex.Transaction) => Promise<void>): Promise<void>;
56
56
  }
57
+ //# sourceMappingURL=VitestObjectionTransactionIsolator.d.ts.map
57
58
  //#endregion
58
59
  export { VitestObjectionTransactionIsolator };
59
- //# sourceMappingURL=VitestObjectionTransactionIsolator-i9jIgU8Q.d.mts.map
60
+ //# sourceMappingURL=VitestObjectionTransactionIsolator-x6hY5j4u.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"VitestObjectionTransactionIsolator-x6hY5j4u.d.mts","names":[],"sources":["../src/VitestObjectionTransactionIsolator.ts"],"sourcesContent":[],"mappings":";;;;;;;AAkCA;;;;;;;;;;;;AAAyF;;;;;;;;;;;;;;cAA5E,kCAAA,SAA2C,kCACvD,MACA,IAAA,CAAK;iBAEgB,mBAAmB;;;;;;;;;;;;;;;;;;;;uBAqB3B,aACL,0BACG,IAAA,CAAK,gBAAgB,gBAC7B"}
@@ -1,4 +1,4 @@
1
1
  require('./VitestTransactionIsolator-CMfJXZP8.cjs');
2
- const require_VitestObjectionTransactionIsolator = require('./VitestObjectionTransactionIsolator-CM5KTAFA.cjs');
2
+ const require_VitestObjectionTransactionIsolator = require('./VitestObjectionTransactionIsolator-CdLRrzNf.cjs');
3
3
 
4
4
  exports.VitestObjectionTransactionIsolator = require_VitestObjectionTransactionIsolator.VitestObjectionTransactionIsolator;
@@ -1,3 +1,3 @@
1
- import "./VitestTransactionIsolator-CwQaxZLP.cjs";
2
- import { VitestObjectionTransactionIsolator } from "./VitestObjectionTransactionIsolator-1TpsPqfG.cjs";
1
+ import "./VitestTransactionIsolator-CSroc7Df.cjs";
2
+ import { VitestObjectionTransactionIsolator } from "./VitestObjectionTransactionIsolator-BXoR6xdG.cjs";
3
3
  export { VitestObjectionTransactionIsolator };
@@ -1,3 +1,3 @@
1
- import "./VitestTransactionIsolator-BvR19bYn.mjs";
2
- import { VitestObjectionTransactionIsolator } from "./VitestObjectionTransactionIsolator-i9jIgU8Q.mjs";
1
+ import "./VitestTransactionIsolator-BNWJqh9f.mjs";
2
+ import { VitestObjectionTransactionIsolator } from "./VitestObjectionTransactionIsolator-x6hY5j4u.mjs";
3
3
  export { VitestObjectionTransactionIsolator };
@@ -1,4 +1,4 @@
1
1
  import "./VitestTransactionIsolator-DQ7tLqgV.mjs";
2
- import { VitestObjectionTransactionIsolator } from "./VitestObjectionTransactionIsolator-jQFaCz0u.mjs";
2
+ import { VitestObjectionTransactionIsolator } from "./VitestObjectionTransactionIsolator-OF2osYY5.mjs";
3
3
 
4
4
  export { VitestObjectionTransactionIsolator };
@@ -9,7 +9,7 @@ import { TestAPI } from "vitest";
9
9
  * @template Transaction - The transaction type specific to the database driver
10
10
  * @template Extended - Additional context properties provided by the extend function
11
11
  */
12
- interface DatabaseFixtures<Transaction, Extended = object> {
12
+ interface DatabaseFixtures<Transaction, _Extended = object> {
13
13
  /**
14
14
  * The database transaction available to the test.
15
15
  * All database operations should use this transaction to ensure proper rollback.
@@ -201,6 +201,7 @@ type TestWithExtendedFixtures<Transaction, Extended extends Record<string, unkno
201
201
  * ```
202
202
  */
203
203
  declare function extendWithFixtures<Transaction, Extended extends Record<string, unknown>, T extends ReturnType<TestAPI['extend']> = any>(wrappedTest: T, fixtures: FixtureCreators<Transaction, Extended>): TestWithExtendedFixtures<Transaction, Extended, T>;
204
+ //# sourceMappingURL=VitestTransactionIsolator.d.ts.map
204
205
  //#endregion
205
206
  export { DatabaseConnection, DatabaseConnectionFn, DatabaseFixtures, ExtendContextFn, ExtendedDatabaseFixtures, FixtureCreators, IsolationLevel, TestWithExtendedFixtures, TransactionWrapperOptions, VitestPostgresTransactionIsolator, extendWithFixtures };
206
- //# sourceMappingURL=VitestTransactionIsolator-BvR19bYn.d.mts.map
207
+ //# sourceMappingURL=VitestTransactionIsolator-BNWJqh9f.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"VitestTransactionIsolator-BNWJqh9f.d.mts","names":[],"sources":["../src/VitestTransactionIsolator.ts"],"sourcesContent":[],"mappings":";;;;;;AASA;AAWA;;;;AAGoC,UAdnB,gBAcmB,CAAA,WAAA,EAAA,YAAA,MAAA,CAAA,CAAA;EAAQ;AAe5C;;;EACiB,GACZ,EA1BC,WA0BD;;;AAAkB;AAQvB;AAkDsB,KA9EV,wBA8EU,CAAA,WAAiC,EAAA,WAAA,MAAA,CAAA,GA3EnD,gBA2EmD,CA3ElC,WA2EkC,CAAA,GA3EnB,QA2EmB;;;;;;;;;;;;;;AAkD5C,KA9GC,eA8GD,CAAA,WAAA,EAAA,QAAA,CAAA,GAAA,CAAA,GAAA,EA7GL,WA6GK,EAAA,GA5GN,QA4GM,GA5GK,OA4GL,CA5Ga,QA4Gb,CAAA;;;;;AAAuD;AA6ElE;AAAgC,aAjLpB,cAAA;EAiLoB;;;AAA6B;EACjD,gBAAA,GAAA,kBAAkB;EAAA;;;AAA6B;EAK1C,cAAA,GAAA,gBAAyB;EAAA;;;;EAMX,eAEhB,GAAA,iBAAA;EAAW;;;;EAIuB,YAArC,GAAA,cAAA;AAAe;AAO3B;;;;;;;;;;AAM2B;AAW3B;;;;;;;;;;;;;;;;AAiBuD,uBA1LjC,iCA0LiC,CAAA,KAAA,EAAA,WAAA,CAAA,CAAA;EAAC,iBACjD,GAAA;EAAO;AAqCd;;;;;;;;EAOgD,SAArC,QAAA,CAAA,IAAA,EA5NH,KA4NG,EAAA,cAAA,EA3NO,cA2NP,EAAA,EAAA,EAAA,CAAA,GAAA,EA1NC,WA0ND,EAAA,GA1NiB,OA0NjB,CAAA,IAAA,CAAA,CAAA,EAzNP,OAyNO,CAAA,IAAA,CAAA;EAAe,SACE,OAAA,CAAA,IAAA,EAxNJ,KAwNI,CAAA,EAxNI,OAwNJ,CAAA,IAAA,CAAA;EAAW;;;AAAZ;;mBAlNQ;;;;;;;;;;;;;;;;;;;;;;;;;;6CA2BS,uCACjC,0BAA0B,OAAO,aAAa,YAAS,QAAA,iBAAA,uBAAA;;KA6EtD,mCAAmC,OAAO,QAAQ;KAClD,2BAA2B,qBAAqB;;;;UAK3C,+DAGC;;cAGL,mBAAmB;;gBAEjB,gBAAgB;;mBAEb;;aAEN,gBAAgB,aAAa;;;;;;KAO7B,8CAEM,yCAEL,iBACN,gBACD,SAAS,KAAK,QAAQ,SAAS;;;;;;;;;KAWzB,uDAEM,0CACA,WAAW,qBAAqB,WAChD,sBAEE;iDAIQ,iBAAiB,eAAe,WAAW,MAChD;kEAMK,iBAAiB,eAAe,WAAW,MAChD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAqCS,iDAEE,mCAEP,WAAW,uCAER,aACH,gBAAgB,aAAa,YACrC,yBAAyB,aAAa,UAAU"}
@@ -1 +1 @@
1
- {"version":3,"file":"VitestTransactionIsolator-CMfJXZP8.cjs","names":["api: TestAPI","options: TransactionWrapperOptions<TConn, Transaction, Extended>","additionalFixtures: Record<string, unknown>","use: (value: unknown) => Promise<void>","use: (value: Transaction) => Promise<void>","testError: Error | undefined","wrappedTest: T","fixtures: FixtureCreators<Transaction, Extended>","fixtureDefinitions: Record<string, any>"],"sources":["../src/VitestTransactionIsolator.ts"],"sourcesContent":["import type { TestAPI } from 'vitest';\n\n/**\n * Type definition for test fixtures that provide transaction access.\n * Used with Vitest's test.extend() API to inject transactions into tests.\n *\n * @template Transaction - The transaction type specific to the database driver\n * @template Extended - Additional context properties provided by the extend function\n */\nexport interface DatabaseFixtures<Transaction, Extended = object> {\n /**\n * The database transaction available to the test.\n * All database operations should use this transaction to ensure proper rollback.\n */\n trx: Transaction;\n}\n\n/**\n * Combined fixtures type that merges the base transaction fixture with extended context.\n */\nexport type ExtendedDatabaseFixtures<\n Transaction,\n Extended = object,\n> = DatabaseFixtures<Transaction> & Extended;\n\n/**\n * Function type for extending test context with additional properties.\n * Receives the transaction and returns additional context to be merged with { trx }.\n *\n * @template Transaction - The transaction type\n * @template Extended - The type of additional context to provide\n *\n * @example\n * ```typescript\n * const extendContext: ExtendContextFn<Transaction<DB>, { factory: KyselyFactory }> =\n * (trx) => ({ factory: new KyselyFactory(builders, seeds, trx) });\n * ```\n */\nexport type ExtendContextFn<Transaction, Extended> = (\n trx: Transaction,\n) => Extended | Promise<Extended>;\n\n/**\n * PostgreSQL transaction isolation levels.\n * Controls the visibility of concurrent transactions.\n *\n * @see https://www.postgresql.org/docs/current/transaction-iso.html\n */\nexport enum IsolationLevel {\n /**\n * Lowest isolation level. Allows dirty reads.\n * Not recommended for testing.\n */\n READ_UNCOMMITTED = 'READ UNCOMMITTED',\n /**\n * Default PostgreSQL isolation level.\n * Prevents dirty reads but allows non-repeatable reads.\n */\n READ_COMMITTED = 'READ COMMITTED',\n /**\n * Prevents dirty reads and non-repeatable reads.\n * Recommended for most test scenarios.\n */\n REPEATABLE_READ = 'REPEATABLE READ',\n /**\n * Highest isolation level. Prevents all phenomena.\n * May cause performance overhead in tests.\n */\n SERIALIZABLE = 'SERIALIZABLE',\n}\n\n/**\n * Abstract base class for implementing database transaction isolation in Vitest tests.\n * Provides automatic transaction rollback after each test to maintain test isolation.\n * Subclasses must implement the transact() method for their specific database driver.\n *\n * @template TConn - The database connection type\n * @template Transaction - The transaction type\n *\n * @example\n * ```typescript\n * // Implement for your database driver\n * class MyDatabaseIsolator extends VitestPostgresTransactionIsolator<MyDB, MyTx> {\n * async transact(conn: MyDB, level: IsolationLevel, fn: (tx: MyTx) => Promise<void>) {\n * await conn.transaction(level, fn);\n * }\n * }\n *\n * // Use in tests\n * const isolator = new MyDatabaseIsolator(test);\n * const isolatedTest = isolator.wrapVitestWithTransaction(db);\n *\n * isolatedTest('should create user', async ({ trx }) => {\n * await trx.insert('users', { name: 'Test' });\n * // Data is automatically rolled back after test\n * });\n * ```\n */\nexport abstract class VitestPostgresTransactionIsolator<TConn, Transaction> {\n /**\n * Abstract method to create a transaction with the specified isolation level.\n * Must be implemented by subclasses for specific database drivers.\n *\n * @param conn - The database connection\n * @param isolationLevel - The transaction isolation level\n * @param fn - The function to execute within the transaction\n * @returns Promise that resolves when the transaction completes\n */\n abstract transact(\n conn: TConn,\n isolationLevel: IsolationLevel,\n fn: (trx: Transaction) => Promise<void>,\n ): Promise<void>;\n\n abstract destroy(conn: TConn): Promise<void>;\n /**\n * Creates a new VitestPostgresTransactionIsolator instance.\n *\n * @param api - The Vitest test API (usually the `test` export from vitest)\n */\n constructor(private readonly api: TestAPI) {}\n\n /**\n * Creates a wrapped version of Vitest's test API that provides transaction isolation.\n * Each test will run within a database transaction that is automatically rolled back.\n *\n * @param options - Configuration options for transaction wrapping\n * @returns A wrapped test API with transaction support\n *\n * @example\n * ```typescript\n * const isolatedTest = isolator.wrapVitestWithTransaction({\n * connection: db,\n * setup: async (trx) => {\n * await trx.insert('settings', { key: 'test', value: 'true' });\n * },\n * fixtures: {\n * factory: (trx) => new Factory(trx),\n * },\n * });\n *\n * isolatedTest('test with transaction', async ({ trx, factory }) => {\n * const user = await factory.insert('user', { name: 'Test' });\n * expect(user).toBeDefined();\n * });\n * ```\n */\n wrapVitestWithTransaction<Extended extends Record<string, unknown> = {}>(\n options: TransactionWrapperOptions<TConn, Transaction, Extended>,\n ) {\n const {\n connection,\n setup,\n isolationLevel = IsolationLevel.REPEATABLE_READ,\n fixtures,\n } = options;\n\n // Build fixture definitions for additional fixtures that depend on trx\n const additionalFixtures: Record<string, unknown> = {};\n if (fixtures) {\n for (const [key, creator] of Object.entries(fixtures)) {\n additionalFixtures[key] = async (\n { trx }: { trx: Transaction },\n use: (value: unknown) => Promise<void>,\n ) => {\n const value = await (creator as (trx: Transaction) => unknown)(trx);\n await use(value);\n };\n }\n }\n\n type CombinedFixtures = DatabaseFixtures<Transaction> & Extended;\n\n // Cast to bypass Vitest's strict fixture typing which can't infer\n // dynamically built fixture objects\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const extendFn = this.api.extend as <T>(fixtures: any) => TestAPI<T>;\n\n return extendFn<CombinedFixtures>({\n // This fixture automatically provides a transaction to each test\n trx: async ({}, use: (value: Transaction) => Promise<void>) => {\n // Create a custom error class for rollback\n class TestRollback extends Error {\n constructor() {\n super('Test rollback');\n this.name = 'TestRollback';\n }\n }\n\n let testError: Error | undefined;\n const conn = await connection();\n try {\n await this.transact(conn, isolationLevel, async (transaction) => {\n try {\n // Provide the transaction to the test\n await setup?.(transaction);\n await use(transaction);\n } catch (error) {\n // Capture any test errors\n testError = error as Error;\n }\n\n // Always throw to trigger rollback\n throw new TestRollback();\n });\n } catch (error) {\n // Only rethrow if it's not our rollback error\n if (!(error instanceof TestRollback)) {\n throw error;\n }\n\n // If the test had an error, throw it now\n if (testError) {\n throw testError;\n }\n } finally {\n await this.destroy(conn);\n }\n },\n ...additionalFixtures,\n });\n }\n}\n\nexport type DatabaseConnectionFn<Conn> = () => Conn | Promise<Conn>;\nexport type DatabaseConnection<Conn> = DatabaseConnectionFn<Conn>;\n\n/**\n * Options for wrapping Vitest tests with database transaction isolation.\n */\nexport interface TransactionWrapperOptions<\n TConn,\n Transaction,\n Extended extends Record<string, unknown> = {},\n> {\n /** Function that creates or returns a database connection */\n connection: DatabaseConnection<TConn>;\n /** Optional setup function to run within the transaction before each test */\n setup?: (trx: Transaction) => Promise<void>;\n /** Transaction isolation level (defaults to REPEATABLE_READ) */\n isolationLevel?: IsolationLevel;\n /** Additional fixtures that depend on the transaction */\n fixtures?: FixtureCreators<Transaction, Extended>;\n}\n\n/**\n * Type for fixture creator functions that depend on the transaction.\n * Each function receives the transaction and returns the fixture value.\n */\nexport type FixtureCreators<\n Transaction,\n Extended extends Record<string, unknown>,\n> = {\n [K in keyof Extended]: (\n trx: Transaction,\n ) => Extended[K] | Promise<Extended[K]>;\n};\n\n/**\n * The test API returned by extendWithFixtures.\n * Provides access to both the transaction (trx) and all extended fixtures.\n *\n * @template Transaction - The transaction type\n * @template Extended - The type of additional fixtures provided\n * @template BaseTest - The base wrapped test type\n */\nexport type TestWithExtendedFixtures<\n Transaction,\n Extended extends Record<string, unknown>,\n BaseTest extends ReturnType<TestAPI['extend']> = ReturnType<\n TestAPI['extend']\n >,\n> = BaseTest & {\n <C extends object>(\n name: string,\n fn: (\n context: DatabaseFixtures<Transaction> & Extended & C,\n ) => Promise<void>,\n ): void;\n <C extends object>(\n name: string,\n options: object,\n fn: (\n context: DatabaseFixtures<Transaction> & Extended & C,\n ) => Promise<void>,\n ): void;\n};\n\n/**\n * Extends a wrapped test API with additional fixtures that depend on the transaction.\n * This allows composing test context with factories, repositories, or other helpers.\n *\n * @template Transaction - The transaction type\n * @template Extended - The type of additional context to provide\n * @param wrappedTest - The base wrapped test from wrapVitestWithTransaction\n * @param fixtures - Object mapping fixture names to creator functions\n * @returns An extended test API with both trx and the additional fixtures\n *\n * @example\n * ```typescript\n * import { wrapVitestKyselyTransaction, extendWithFixtures } from '@geekmidas/testkit/kysely';\n *\n * // Create base wrapped test\n * const baseTest = wrapVitestKyselyTransaction(test, {\n * connection: db,\n * setup: createTestTables,\n * });\n *\n * // Extend with fixtures\n * const it = extendWithFixtures(baseTest, {\n * factory: (trx) => new KyselyFactory(builders, seeds, trx),\n * userRepo: (trx) => new UserRepository(trx),\n * });\n *\n * // Use in tests - trx and all fixtures are available\n * it('should create user with factory', async ({ trx, factory, userRepo }) => {\n * const user = await factory.insert('user', { name: 'Test' });\n * expect(user).toBeDefined();\n * });\n * ```\n */\nexport function extendWithFixtures<\n Transaction,\n Extended extends Record<string, unknown>,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n T extends ReturnType<TestAPI['extend']> = any,\n>(\n wrappedTest: T,\n fixtures: FixtureCreators<Transaction, Extended>,\n): TestWithExtendedFixtures<Transaction, Extended, T> {\n // Build fixture definitions for Vitest's extend API\n const fixtureDefinitions: Record<string, any> = {};\n\n for (const [key, creator] of Object.entries(fixtures)) {\n fixtureDefinitions[key] = async (\n { trx }: { trx: Transaction },\n use: (value: unknown) => Promise<void>,\n ) => {\n const value = await (creator as (trx: Transaction) => unknown)(trx);\n await use(value);\n };\n }\n\n return (wrappedTest as any).extend(fixtureDefinitions);\n}\n"],"mappings":";;;;;;;;AAgDA,IAAY,4DAAL;;;;;AAKL;;;;;AAKA;;;;;AAKA;;;;;AAKA;;AACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BD,IAAsB,oCAAtB,MAA4E;;;;;;CAsB1E,YAA6BA,KAAc;EAAd;CAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;CA2B7C,0BACEC,SACA;EACA,MAAM,EACJ,YACA,OACA,iBAAiB,eAAe,iBAChC,UACD,GAAG;EAGJ,MAAMC,qBAA8C,CAAE;AACtD,MAAI,SACF,MAAK,MAAM,CAAC,KAAK,QAAQ,IAAI,OAAO,QAAQ,SAAS,CACnD,oBAAmB,OAAO,OACxB,EAAE,KAA2B,EAC7BC,QACG;GACH,MAAM,QAAQ,MAAM,AAAC,QAA0C,IAAI;AACnE,SAAM,IAAI,MAAM;EACjB;EASL,MAAM,WAAW,KAAK,IAAI;AAE1B,SAAO,SAA2B;GAEhC,KAAK,OAAO,EAAE,EAAEC,QAA+C;IAE7D,MAAM,qBAAqB,MAAM;KAC/B,cAAc;AACZ,YAAM,gBAAgB;AACtB,WAAK,OAAO;KACb;IACF;IAED,IAAIC;IACJ,MAAM,OAAO,MAAM,YAAY;AAC/B,QAAI;AACF,WAAM,KAAK,SAAS,MAAM,gBAAgB,OAAO,gBAAgB;AAC/D,UAAI;AAEF,aAAM,QAAQ,YAAY;AAC1B,aAAM,IAAI,YAAY;MACvB,SAAQ,OAAO;AAEd,mBAAY;MACb;AAGD,YAAM,IAAI;KACX,EAAC;IACH,SAAQ,OAAO;AAEd,WAAM,iBAAiB,cACrB,OAAM;AAIR,SAAI,UACF,OAAM;IAET,UAAS;AACR,WAAM,KAAK,QAAQ,KAAK;IACzB;GACF;GACD,GAAG;EACJ,EAAC;CACH;AACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmGD,SAAgB,mBAMdC,aACAC,UACoD;CAEpD,MAAMC,qBAA0C,CAAE;AAElD,MAAK,MAAM,CAAC,KAAK,QAAQ,IAAI,OAAO,QAAQ,SAAS,CACnD,oBAAmB,OAAO,OACxB,EAAE,KAA2B,EAC7BL,QACG;EACH,MAAM,QAAQ,MAAM,AAAC,QAA0C,IAAI;AACnE,QAAM,IAAI,MAAM;CACjB;AAGH,QAAO,AAAC,YAAoB,OAAO,mBAAmB;AACvD"}
1
+ {"version":3,"file":"VitestTransactionIsolator-CMfJXZP8.cjs","names":["api: TestAPI","options: TransactionWrapperOptions<TConn, Transaction, Extended>","additionalFixtures: Record<string, unknown>","use: (value: unknown) => Promise<void>","use: (value: Transaction) => Promise<void>","testError: Error | undefined","wrappedTest: T","fixtures: FixtureCreators<Transaction, Extended>","fixtureDefinitions: Record<string, any>"],"sources":["../src/VitestTransactionIsolator.ts"],"sourcesContent":["import type { TestAPI } from 'vitest';\n\n/**\n * Type definition for test fixtures that provide transaction access.\n * Used with Vitest's test.extend() API to inject transactions into tests.\n *\n * @template Transaction - The transaction type specific to the database driver\n * @template Extended - Additional context properties provided by the extend function\n */\nexport interface DatabaseFixtures<Transaction, _Extended = object> {\n\t/**\n\t * The database transaction available to the test.\n\t * All database operations should use this transaction to ensure proper rollback.\n\t */\n\ttrx: Transaction;\n}\n\n/**\n * Combined fixtures type that merges the base transaction fixture with extended context.\n */\nexport type ExtendedDatabaseFixtures<\n\tTransaction,\n\tExtended = object,\n> = DatabaseFixtures<Transaction> & Extended;\n\n/**\n * Function type for extending test context with additional properties.\n * Receives the transaction and returns additional context to be merged with { trx }.\n *\n * @template Transaction - The transaction type\n * @template Extended - The type of additional context to provide\n *\n * @example\n * ```typescript\n * const extendContext: ExtendContextFn<Transaction<DB>, { factory: KyselyFactory }> =\n * (trx) => ({ factory: new KyselyFactory(builders, seeds, trx) });\n * ```\n */\nexport type ExtendContextFn<Transaction, Extended> = (\n\ttrx: Transaction,\n) => Extended | Promise<Extended>;\n\n/**\n * PostgreSQL transaction isolation levels.\n * Controls the visibility of concurrent transactions.\n *\n * @see https://www.postgresql.org/docs/current/transaction-iso.html\n */\nexport enum IsolationLevel {\n\t/**\n\t * Lowest isolation level. Allows dirty reads.\n\t * Not recommended for testing.\n\t */\n\tREAD_UNCOMMITTED = 'READ UNCOMMITTED',\n\t/**\n\t * Default PostgreSQL isolation level.\n\t * Prevents dirty reads but allows non-repeatable reads.\n\t */\n\tREAD_COMMITTED = 'READ COMMITTED',\n\t/**\n\t * Prevents dirty reads and non-repeatable reads.\n\t * Recommended for most test scenarios.\n\t */\n\tREPEATABLE_READ = 'REPEATABLE READ',\n\t/**\n\t * Highest isolation level. Prevents all phenomena.\n\t * May cause performance overhead in tests.\n\t */\n\tSERIALIZABLE = 'SERIALIZABLE',\n}\n\n/**\n * Abstract base class for implementing database transaction isolation in Vitest tests.\n * Provides automatic transaction rollback after each test to maintain test isolation.\n * Subclasses must implement the transact() method for their specific database driver.\n *\n * @template TConn - The database connection type\n * @template Transaction - The transaction type\n *\n * @example\n * ```typescript\n * // Implement for your database driver\n * class MyDatabaseIsolator extends VitestPostgresTransactionIsolator<MyDB, MyTx> {\n * async transact(conn: MyDB, level: IsolationLevel, fn: (tx: MyTx) => Promise<void>) {\n * await conn.transaction(level, fn);\n * }\n * }\n *\n * // Use in tests\n * const isolator = new MyDatabaseIsolator(test);\n * const isolatedTest = isolator.wrapVitestWithTransaction(db);\n *\n * isolatedTest('should create user', async ({ trx }) => {\n * await trx.insert('users', { name: 'Test' });\n * // Data is automatically rolled back after test\n * });\n * ```\n */\nexport abstract class VitestPostgresTransactionIsolator<TConn, Transaction> {\n\t/**\n\t * Abstract method to create a transaction with the specified isolation level.\n\t * Must be implemented by subclasses for specific database drivers.\n\t *\n\t * @param conn - The database connection\n\t * @param isolationLevel - The transaction isolation level\n\t * @param fn - The function to execute within the transaction\n\t * @returns Promise that resolves when the transaction completes\n\t */\n\tabstract transact(\n\t\tconn: TConn,\n\t\tisolationLevel: IsolationLevel,\n\t\tfn: (trx: Transaction) => Promise<void>,\n\t): Promise<void>;\n\n\tabstract destroy(conn: TConn): Promise<void>;\n\t/**\n\t * Creates a new VitestPostgresTransactionIsolator instance.\n\t *\n\t * @param api - The Vitest test API (usually the `test` export from vitest)\n\t */\n\tconstructor(private readonly api: TestAPI) {}\n\n\t/**\n\t * Creates a wrapped version of Vitest's test API that provides transaction isolation.\n\t * Each test will run within a database transaction that is automatically rolled back.\n\t *\n\t * @param options - Configuration options for transaction wrapping\n\t * @returns A wrapped test API with transaction support\n\t *\n\t * @example\n\t * ```typescript\n\t * const isolatedTest = isolator.wrapVitestWithTransaction({\n\t * connection: db,\n\t * setup: async (trx) => {\n\t * await trx.insert('settings', { key: 'test', value: 'true' });\n\t * },\n\t * fixtures: {\n\t * factory: (trx) => new Factory(trx),\n\t * },\n\t * });\n\t *\n\t * isolatedTest('test with transaction', async ({ trx, factory }) => {\n\t * const user = await factory.insert('user', { name: 'Test' });\n\t * expect(user).toBeDefined();\n\t * });\n\t * ```\n\t */\n\twrapVitestWithTransaction<Extended extends Record<string, unknown> = {}>(\n\t\toptions: TransactionWrapperOptions<TConn, Transaction, Extended>,\n\t) {\n\t\tconst {\n\t\t\tconnection,\n\t\t\tsetup,\n\t\t\tisolationLevel = IsolationLevel.REPEATABLE_READ,\n\t\t\tfixtures,\n\t\t} = options;\n\n\t\t// Build fixture definitions for additional fixtures that depend on trx\n\t\tconst additionalFixtures: Record<string, unknown> = {};\n\t\tif (fixtures) {\n\t\t\tfor (const [key, creator] of Object.entries(fixtures)) {\n\t\t\t\tadditionalFixtures[key] = async (\n\t\t\t\t\t{ trx }: { trx: Transaction },\n\t\t\t\t\tuse: (value: unknown) => Promise<void>,\n\t\t\t\t) => {\n\t\t\t\t\tconst value = await (creator as (trx: Transaction) => unknown)(trx);\n\t\t\t\t\tawait use(value);\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\ttype CombinedFixtures = DatabaseFixtures<Transaction> & Extended;\n\n\t\t// Cast to bypass Vitest's strict fixture typing which can't infer\n\t\t// dynamically built fixture objects\n\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\tconst extendFn = this.api.extend as <T>(fixtures: any) => TestAPI<T>;\n\n\t\treturn extendFn<CombinedFixtures>({\n\t\t\t// This fixture automatically provides a transaction to each test\n\t\t\t// biome-ignore lint/correctness/noEmptyPattern: this has to be like this to satisfy Biome\n\t\t\ttrx: async ({}: {}, use: (value: Transaction) => Promise<void>) => {\n\t\t\t\t// Create a custom error class for rollback\n\t\t\t\tclass TestRollback extends Error {\n\t\t\t\t\tconstructor() {\n\t\t\t\t\t\tsuper('Test rollback');\n\t\t\t\t\t\tthis.name = 'TestRollback';\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tlet testError: Error | undefined;\n\t\t\t\tconst conn = await connection();\n\t\t\t\ttry {\n\t\t\t\t\tawait this.transact(conn, isolationLevel, async (transaction) => {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t// Provide the transaction to the test\n\t\t\t\t\t\t\tawait setup?.(transaction);\n\t\t\t\t\t\t\tawait use(transaction);\n\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\t// Capture any test errors\n\t\t\t\t\t\t\ttestError = error as Error;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Always throw to trigger rollback\n\t\t\t\t\t\tthrow new TestRollback();\n\t\t\t\t\t});\n\t\t\t\t} catch (error) {\n\t\t\t\t\t// Only rethrow if it's not our rollback error\n\t\t\t\t\tif (!(error instanceof TestRollback)) {\n\t\t\t\t\t\tthrow error;\n\t\t\t\t\t}\n\n\t\t\t\t\t// If the test had an error, throw it now\n\t\t\t\t\tif (testError) {\n\t\t\t\t\t\tthrow testError;\n\t\t\t\t\t}\n\t\t\t\t} finally {\n\t\t\t\t\tawait this.destroy(conn);\n\t\t\t\t}\n\t\t\t},\n\t\t\t...additionalFixtures,\n\t\t});\n\t}\n}\n\nexport type DatabaseConnectionFn<Conn> = () => Conn | Promise<Conn>;\nexport type DatabaseConnection<Conn> = DatabaseConnectionFn<Conn>;\n\n/**\n * Options for wrapping Vitest tests with database transaction isolation.\n */\nexport interface TransactionWrapperOptions<\n\tTConn,\n\tTransaction,\n\tExtended extends Record<string, unknown> = {},\n> {\n\t/** Function that creates or returns a database connection */\n\tconnection: DatabaseConnection<TConn>;\n\t/** Optional setup function to run within the transaction before each test */\n\tsetup?: (trx: Transaction) => Promise<void>;\n\t/** Transaction isolation level (defaults to REPEATABLE_READ) */\n\tisolationLevel?: IsolationLevel;\n\t/** Additional fixtures that depend on the transaction */\n\tfixtures?: FixtureCreators<Transaction, Extended>;\n}\n\n/**\n * Type for fixture creator functions that depend on the transaction.\n * Each function receives the transaction and returns the fixture value.\n */\nexport type FixtureCreators<\n\tTransaction,\n\tExtended extends Record<string, unknown>,\n> = {\n\t[K in keyof Extended]: (\n\t\ttrx: Transaction,\n\t) => Extended[K] | Promise<Extended[K]>;\n};\n\n/**\n * The test API returned by extendWithFixtures.\n * Provides access to both the transaction (trx) and all extended fixtures.\n *\n * @template Transaction - The transaction type\n * @template Extended - The type of additional fixtures provided\n * @template BaseTest - The base wrapped test type\n */\nexport type TestWithExtendedFixtures<\n\tTransaction,\n\tExtended extends Record<string, unknown>,\n\tBaseTest extends ReturnType<TestAPI['extend']> = ReturnType<\n\t\tTestAPI['extend']\n\t>,\n> = BaseTest & {\n\t<C extends object>(\n\t\tname: string,\n\t\tfn: (\n\t\t\tcontext: DatabaseFixtures<Transaction> & Extended & C,\n\t\t) => Promise<void>,\n\t): void;\n\t<C extends object>(\n\t\tname: string,\n\t\toptions: object,\n\t\tfn: (\n\t\t\tcontext: DatabaseFixtures<Transaction> & Extended & C,\n\t\t) => Promise<void>,\n\t): void;\n};\n\n/**\n * Extends a wrapped test API with additional fixtures that depend on the transaction.\n * This allows composing test context with factories, repositories, or other helpers.\n *\n * @template Transaction - The transaction type\n * @template Extended - The type of additional context to provide\n * @param wrappedTest - The base wrapped test from wrapVitestWithTransaction\n * @param fixtures - Object mapping fixture names to creator functions\n * @returns An extended test API with both trx and the additional fixtures\n *\n * @example\n * ```typescript\n * import { wrapVitestKyselyTransaction, extendWithFixtures } from '@geekmidas/testkit/kysely';\n *\n * // Create base wrapped test\n * const baseTest = wrapVitestKyselyTransaction(test, {\n * connection: db,\n * setup: createTestTables,\n * });\n *\n * // Extend with fixtures\n * const it = extendWithFixtures(baseTest, {\n * factory: (trx) => new KyselyFactory(builders, seeds, trx),\n * userRepo: (trx) => new UserRepository(trx),\n * });\n *\n * // Use in tests - trx and all fixtures are available\n * it('should create user with factory', async ({ trx, factory, userRepo }) => {\n * const user = await factory.insert('user', { name: 'Test' });\n * expect(user).toBeDefined();\n * });\n * ```\n */\nexport function extendWithFixtures<\n\tTransaction,\n\tExtended extends Record<string, unknown>,\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tT extends ReturnType<TestAPI['extend']> = any,\n>(\n\twrappedTest: T,\n\tfixtures: FixtureCreators<Transaction, Extended>,\n): TestWithExtendedFixtures<Transaction, Extended, T> {\n\t// Build fixture definitions for Vitest's extend API\n\tconst fixtureDefinitions: Record<string, any> = {};\n\n\tfor (const [key, creator] of Object.entries(fixtures)) {\n\t\tfixtureDefinitions[key] = async (\n\t\t\t{ trx }: { trx: Transaction },\n\t\t\tuse: (value: unknown) => Promise<void>,\n\t\t) => {\n\t\t\tconst value = await (creator as (trx: Transaction) => unknown)(trx);\n\t\t\tawait use(value);\n\t\t};\n\t}\n\n\treturn (wrappedTest as any).extend(fixtureDefinitions);\n}\n"],"mappings":";;;;;;;;AAgDA,IAAY,4DAAL;;;;;AAKN;;;;;AAKA;;;;;AAKA;;;;;AAKA;;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BD,IAAsB,oCAAtB,MAA4E;;;;;;CAsB3E,YAA6BA,KAAc;EAAd;CAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;CA2B7C,0BACCC,SACC;EACD,MAAM,EACL,YACA,OACA,iBAAiB,eAAe,iBAChC,UACA,GAAG;EAGJ,MAAMC,qBAA8C,CAAE;AACtD,MAAI,SACH,MAAK,MAAM,CAAC,KAAK,QAAQ,IAAI,OAAO,QAAQ,SAAS,CACpD,oBAAmB,OAAO,OACzB,EAAE,KAA2B,EAC7BC,QACI;GACJ,MAAM,QAAQ,MAAM,AAAC,QAA0C,IAAI;AACnE,SAAM,IAAI,MAAM;EAChB;EASH,MAAM,WAAW,KAAK,IAAI;AAE1B,SAAO,SAA2B;GAGjC,KAAK,OAAO,EAAM,EAAEC,QAA+C;IAElE,MAAM,qBAAqB,MAAM;KAChC,cAAc;AACb,YAAM,gBAAgB;AACtB,WAAK,OAAO;KACZ;IACD;IAED,IAAIC;IACJ,MAAM,OAAO,MAAM,YAAY;AAC/B,QAAI;AACH,WAAM,KAAK,SAAS,MAAM,gBAAgB,OAAO,gBAAgB;AAChE,UAAI;AAEH,aAAM,QAAQ,YAAY;AAC1B,aAAM,IAAI,YAAY;MACtB,SAAQ,OAAO;AAEf,mBAAY;MACZ;AAGD,YAAM,IAAI;KACV,EAAC;IACF,SAAQ,OAAO;AAEf,WAAM,iBAAiB,cACtB,OAAM;AAIP,SAAI,UACH,OAAM;IAEP,UAAS;AACT,WAAM,KAAK,QAAQ,KAAK;IACxB;GACD;GACD,GAAG;EACH,EAAC;CACF;AACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmGD,SAAgB,mBAMfC,aACAC,UACqD;CAErD,MAAMC,qBAA0C,CAAE;AAElD,MAAK,MAAM,CAAC,KAAK,QAAQ,IAAI,OAAO,QAAQ,SAAS,CACpD,oBAAmB,OAAO,OACzB,EAAE,KAA2B,EAC7BL,QACI;EACJ,MAAM,QAAQ,MAAM,AAAC,QAA0C,IAAI;AACnE,QAAM,IAAI,MAAM;CAChB;AAGF,QAAO,AAAC,YAAoB,OAAO,mBAAmB;AACtD"}
@@ -9,7 +9,7 @@ import { TestAPI } from "vitest";
9
9
  * @template Transaction - The transaction type specific to the database driver
10
10
  * @template Extended - Additional context properties provided by the extend function
11
11
  */
12
- interface DatabaseFixtures<Transaction, Extended = object> {
12
+ interface DatabaseFixtures<Transaction, _Extended = object> {
13
13
  /**
14
14
  * The database transaction available to the test.
15
15
  * All database operations should use this transaction to ensure proper rollback.
@@ -201,6 +201,7 @@ type TestWithExtendedFixtures<Transaction, Extended extends Record<string, unkno
201
201
  * ```
202
202
  */
203
203
  declare function extendWithFixtures<Transaction, Extended extends Record<string, unknown>, T extends ReturnType<TestAPI['extend']> = any>(wrappedTest: T, fixtures: FixtureCreators<Transaction, Extended>): TestWithExtendedFixtures<Transaction, Extended, T>;
204
+ //# sourceMappingURL=VitestTransactionIsolator.d.ts.map
204
205
  //#endregion
205
206
  export { DatabaseConnection, DatabaseConnectionFn, DatabaseFixtures, ExtendContextFn, ExtendedDatabaseFixtures, FixtureCreators, IsolationLevel, TestWithExtendedFixtures, TransactionWrapperOptions, VitestPostgresTransactionIsolator, extendWithFixtures };
206
- //# sourceMappingURL=VitestTransactionIsolator-CwQaxZLP.d.cts.map
207
+ //# sourceMappingURL=VitestTransactionIsolator-CSroc7Df.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"VitestTransactionIsolator-CSroc7Df.d.cts","names":[],"sources":["../src/VitestTransactionIsolator.ts"],"sourcesContent":[],"mappings":";;;;;;AASA;AAWA;;;;AAGoC,UAdnB,gBAcmB,CAAA,WAAA,EAAA,YAAA,MAAA,CAAA,CAAA;EAAQ;AAe5C;;;EACiB,GACZ,EA1BC,WA0BD;;;AAAkB;AAQvB;AAkDsB,KA9EV,wBA8EU,CAAA,WAAiC,EAAA,WAAA,MAAA,CAAA,GA3EnD,gBA2EmD,CA3ElC,WA2EkC,CAAA,GA3EnB,QA2EmB;;;;;;;;;;;;;;AAkD5C,KA9GC,eA8GD,CAAA,WAAA,EAAA,QAAA,CAAA,GAAA,CAAA,GAAA,EA7GL,WA6GK,EAAA,GA5GN,QA4GM,GA5GK,OA4GL,CA5Ga,QA4Gb,CAAA;;;;;AAAuD;AA6ElE;AAAgC,aAjLpB,cAAA;EAiLoB;;;AAA6B;EACjD,gBAAA,GAAA,kBAAkB;EAAA;;;AAA6B;EAK1C,cAAA,GAAA,gBAAyB;EAAA;;;;EAMX,eAEhB,GAAA,iBAAA;EAAW;;;;EAIuB,YAArC,GAAA,cAAA;AAAe;AAO3B;;;;;;;;;;AAM2B;AAW3B;;;;;;;;;;;;;;;;AAiBuD,uBA1LjC,iCA0LiC,CAAA,KAAA,EAAA,WAAA,CAAA,CAAA;EAAC,iBACjD,GAAA;EAAO;AAqCd;;;;;;;;EAOgD,SAArC,QAAA,CAAA,IAAA,EA5NH,KA4NG,EAAA,cAAA,EA3NO,cA2NP,EAAA,EAAA,EAAA,CAAA,GAAA,EA1NC,WA0ND,EAAA,GA1NiB,OA0NjB,CAAA,IAAA,CAAA,CAAA,EAzNP,OAyNO,CAAA,IAAA,CAAA;EAAe,SACE,OAAA,CAAA,IAAA,EAxNJ,KAwNI,CAAA,EAxNI,OAwNJ,CAAA,IAAA,CAAA;EAAW;;;AAAZ;;mBAlNQ;;;;;;;;;;;;;;;;;;;;;;;;;;6CA2BS,uCACjC,0BAA0B,OAAO,aAAa,YAAS,QAAA,iBAAA,uBAAA;;KA6EtD,mCAAmC,OAAO,QAAQ;KAClD,2BAA2B,qBAAqB;;;;UAK3C,+DAGC;;cAGL,mBAAmB;;gBAEjB,gBAAgB;;mBAEb;;aAEN,gBAAgB,aAAa;;;;;;KAO7B,8CAEM,yCAEL,iBACN,gBACD,SAAS,KAAK,QAAQ,SAAS;;;;;;;;;KAWzB,uDAEM,0CACA,WAAW,qBAAqB,WAChD,sBAEE;iDAIQ,iBAAiB,eAAe,WAAW,MAChD;kEAMK,iBAAiB,eAAe,WAAW,MAChD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAqCS,iDAEE,mCAEP,WAAW,uCAER,aACH,gBAAgB,aAAa,YACrC,yBAAyB,aAAa,UAAU"}
@@ -1 +1 @@
1
- {"version":3,"file":"VitestTransactionIsolator-DQ7tLqgV.mjs","names":["api: TestAPI","options: TransactionWrapperOptions<TConn, Transaction, Extended>","additionalFixtures: Record<string, unknown>","use: (value: unknown) => Promise<void>","use: (value: Transaction) => Promise<void>","testError: Error | undefined","wrappedTest: T","fixtures: FixtureCreators<Transaction, Extended>","fixtureDefinitions: Record<string, any>"],"sources":["../src/VitestTransactionIsolator.ts"],"sourcesContent":["import type { TestAPI } from 'vitest';\n\n/**\n * Type definition for test fixtures that provide transaction access.\n * Used with Vitest's test.extend() API to inject transactions into tests.\n *\n * @template Transaction - The transaction type specific to the database driver\n * @template Extended - Additional context properties provided by the extend function\n */\nexport interface DatabaseFixtures<Transaction, Extended = object> {\n /**\n * The database transaction available to the test.\n * All database operations should use this transaction to ensure proper rollback.\n */\n trx: Transaction;\n}\n\n/**\n * Combined fixtures type that merges the base transaction fixture with extended context.\n */\nexport type ExtendedDatabaseFixtures<\n Transaction,\n Extended = object,\n> = DatabaseFixtures<Transaction> & Extended;\n\n/**\n * Function type for extending test context with additional properties.\n * Receives the transaction and returns additional context to be merged with { trx }.\n *\n * @template Transaction - The transaction type\n * @template Extended - The type of additional context to provide\n *\n * @example\n * ```typescript\n * const extendContext: ExtendContextFn<Transaction<DB>, { factory: KyselyFactory }> =\n * (trx) => ({ factory: new KyselyFactory(builders, seeds, trx) });\n * ```\n */\nexport type ExtendContextFn<Transaction, Extended> = (\n trx: Transaction,\n) => Extended | Promise<Extended>;\n\n/**\n * PostgreSQL transaction isolation levels.\n * Controls the visibility of concurrent transactions.\n *\n * @see https://www.postgresql.org/docs/current/transaction-iso.html\n */\nexport enum IsolationLevel {\n /**\n * Lowest isolation level. Allows dirty reads.\n * Not recommended for testing.\n */\n READ_UNCOMMITTED = 'READ UNCOMMITTED',\n /**\n * Default PostgreSQL isolation level.\n * Prevents dirty reads but allows non-repeatable reads.\n */\n READ_COMMITTED = 'READ COMMITTED',\n /**\n * Prevents dirty reads and non-repeatable reads.\n * Recommended for most test scenarios.\n */\n REPEATABLE_READ = 'REPEATABLE READ',\n /**\n * Highest isolation level. Prevents all phenomena.\n * May cause performance overhead in tests.\n */\n SERIALIZABLE = 'SERIALIZABLE',\n}\n\n/**\n * Abstract base class for implementing database transaction isolation in Vitest tests.\n * Provides automatic transaction rollback after each test to maintain test isolation.\n * Subclasses must implement the transact() method for their specific database driver.\n *\n * @template TConn - The database connection type\n * @template Transaction - The transaction type\n *\n * @example\n * ```typescript\n * // Implement for your database driver\n * class MyDatabaseIsolator extends VitestPostgresTransactionIsolator<MyDB, MyTx> {\n * async transact(conn: MyDB, level: IsolationLevel, fn: (tx: MyTx) => Promise<void>) {\n * await conn.transaction(level, fn);\n * }\n * }\n *\n * // Use in tests\n * const isolator = new MyDatabaseIsolator(test);\n * const isolatedTest = isolator.wrapVitestWithTransaction(db);\n *\n * isolatedTest('should create user', async ({ trx }) => {\n * await trx.insert('users', { name: 'Test' });\n * // Data is automatically rolled back after test\n * });\n * ```\n */\nexport abstract class VitestPostgresTransactionIsolator<TConn, Transaction> {\n /**\n * Abstract method to create a transaction with the specified isolation level.\n * Must be implemented by subclasses for specific database drivers.\n *\n * @param conn - The database connection\n * @param isolationLevel - The transaction isolation level\n * @param fn - The function to execute within the transaction\n * @returns Promise that resolves when the transaction completes\n */\n abstract transact(\n conn: TConn,\n isolationLevel: IsolationLevel,\n fn: (trx: Transaction) => Promise<void>,\n ): Promise<void>;\n\n abstract destroy(conn: TConn): Promise<void>;\n /**\n * Creates a new VitestPostgresTransactionIsolator instance.\n *\n * @param api - The Vitest test API (usually the `test` export from vitest)\n */\n constructor(private readonly api: TestAPI) {}\n\n /**\n * Creates a wrapped version of Vitest's test API that provides transaction isolation.\n * Each test will run within a database transaction that is automatically rolled back.\n *\n * @param options - Configuration options for transaction wrapping\n * @returns A wrapped test API with transaction support\n *\n * @example\n * ```typescript\n * const isolatedTest = isolator.wrapVitestWithTransaction({\n * connection: db,\n * setup: async (trx) => {\n * await trx.insert('settings', { key: 'test', value: 'true' });\n * },\n * fixtures: {\n * factory: (trx) => new Factory(trx),\n * },\n * });\n *\n * isolatedTest('test with transaction', async ({ trx, factory }) => {\n * const user = await factory.insert('user', { name: 'Test' });\n * expect(user).toBeDefined();\n * });\n * ```\n */\n wrapVitestWithTransaction<Extended extends Record<string, unknown> = {}>(\n options: TransactionWrapperOptions<TConn, Transaction, Extended>,\n ) {\n const {\n connection,\n setup,\n isolationLevel = IsolationLevel.REPEATABLE_READ,\n fixtures,\n } = options;\n\n // Build fixture definitions for additional fixtures that depend on trx\n const additionalFixtures: Record<string, unknown> = {};\n if (fixtures) {\n for (const [key, creator] of Object.entries(fixtures)) {\n additionalFixtures[key] = async (\n { trx }: { trx: Transaction },\n use: (value: unknown) => Promise<void>,\n ) => {\n const value = await (creator as (trx: Transaction) => unknown)(trx);\n await use(value);\n };\n }\n }\n\n type CombinedFixtures = DatabaseFixtures<Transaction> & Extended;\n\n // Cast to bypass Vitest's strict fixture typing which can't infer\n // dynamically built fixture objects\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const extendFn = this.api.extend as <T>(fixtures: any) => TestAPI<T>;\n\n return extendFn<CombinedFixtures>({\n // This fixture automatically provides a transaction to each test\n trx: async ({}, use: (value: Transaction) => Promise<void>) => {\n // Create a custom error class for rollback\n class TestRollback extends Error {\n constructor() {\n super('Test rollback');\n this.name = 'TestRollback';\n }\n }\n\n let testError: Error | undefined;\n const conn = await connection();\n try {\n await this.transact(conn, isolationLevel, async (transaction) => {\n try {\n // Provide the transaction to the test\n await setup?.(transaction);\n await use(transaction);\n } catch (error) {\n // Capture any test errors\n testError = error as Error;\n }\n\n // Always throw to trigger rollback\n throw new TestRollback();\n });\n } catch (error) {\n // Only rethrow if it's not our rollback error\n if (!(error instanceof TestRollback)) {\n throw error;\n }\n\n // If the test had an error, throw it now\n if (testError) {\n throw testError;\n }\n } finally {\n await this.destroy(conn);\n }\n },\n ...additionalFixtures,\n });\n }\n}\n\nexport type DatabaseConnectionFn<Conn> = () => Conn | Promise<Conn>;\nexport type DatabaseConnection<Conn> = DatabaseConnectionFn<Conn>;\n\n/**\n * Options for wrapping Vitest tests with database transaction isolation.\n */\nexport interface TransactionWrapperOptions<\n TConn,\n Transaction,\n Extended extends Record<string, unknown> = {},\n> {\n /** Function that creates or returns a database connection */\n connection: DatabaseConnection<TConn>;\n /** Optional setup function to run within the transaction before each test */\n setup?: (trx: Transaction) => Promise<void>;\n /** Transaction isolation level (defaults to REPEATABLE_READ) */\n isolationLevel?: IsolationLevel;\n /** Additional fixtures that depend on the transaction */\n fixtures?: FixtureCreators<Transaction, Extended>;\n}\n\n/**\n * Type for fixture creator functions that depend on the transaction.\n * Each function receives the transaction and returns the fixture value.\n */\nexport type FixtureCreators<\n Transaction,\n Extended extends Record<string, unknown>,\n> = {\n [K in keyof Extended]: (\n trx: Transaction,\n ) => Extended[K] | Promise<Extended[K]>;\n};\n\n/**\n * The test API returned by extendWithFixtures.\n * Provides access to both the transaction (trx) and all extended fixtures.\n *\n * @template Transaction - The transaction type\n * @template Extended - The type of additional fixtures provided\n * @template BaseTest - The base wrapped test type\n */\nexport type TestWithExtendedFixtures<\n Transaction,\n Extended extends Record<string, unknown>,\n BaseTest extends ReturnType<TestAPI['extend']> = ReturnType<\n TestAPI['extend']\n >,\n> = BaseTest & {\n <C extends object>(\n name: string,\n fn: (\n context: DatabaseFixtures<Transaction> & Extended & C,\n ) => Promise<void>,\n ): void;\n <C extends object>(\n name: string,\n options: object,\n fn: (\n context: DatabaseFixtures<Transaction> & Extended & C,\n ) => Promise<void>,\n ): void;\n};\n\n/**\n * Extends a wrapped test API with additional fixtures that depend on the transaction.\n * This allows composing test context with factories, repositories, or other helpers.\n *\n * @template Transaction - The transaction type\n * @template Extended - The type of additional context to provide\n * @param wrappedTest - The base wrapped test from wrapVitestWithTransaction\n * @param fixtures - Object mapping fixture names to creator functions\n * @returns An extended test API with both trx and the additional fixtures\n *\n * @example\n * ```typescript\n * import { wrapVitestKyselyTransaction, extendWithFixtures } from '@geekmidas/testkit/kysely';\n *\n * // Create base wrapped test\n * const baseTest = wrapVitestKyselyTransaction(test, {\n * connection: db,\n * setup: createTestTables,\n * });\n *\n * // Extend with fixtures\n * const it = extendWithFixtures(baseTest, {\n * factory: (trx) => new KyselyFactory(builders, seeds, trx),\n * userRepo: (trx) => new UserRepository(trx),\n * });\n *\n * // Use in tests - trx and all fixtures are available\n * it('should create user with factory', async ({ trx, factory, userRepo }) => {\n * const user = await factory.insert('user', { name: 'Test' });\n * expect(user).toBeDefined();\n * });\n * ```\n */\nexport function extendWithFixtures<\n Transaction,\n Extended extends Record<string, unknown>,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n T extends ReturnType<TestAPI['extend']> = any,\n>(\n wrappedTest: T,\n fixtures: FixtureCreators<Transaction, Extended>,\n): TestWithExtendedFixtures<Transaction, Extended, T> {\n // Build fixture definitions for Vitest's extend API\n const fixtureDefinitions: Record<string, any> = {};\n\n for (const [key, creator] of Object.entries(fixtures)) {\n fixtureDefinitions[key] = async (\n { trx }: { trx: Transaction },\n use: (value: unknown) => Promise<void>,\n ) => {\n const value = await (creator as (trx: Transaction) => unknown)(trx);\n await use(value);\n };\n }\n\n return (wrappedTest as any).extend(fixtureDefinitions);\n}\n"],"mappings":";;;;;;;AAgDA,IAAY,4DAAL;;;;;AAKL;;;;;AAKA;;;;;AAKA;;;;;AAKA;;AACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BD,IAAsB,oCAAtB,MAA4E;;;;;;CAsB1E,YAA6BA,KAAc;EAAd;CAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;CA2B7C,0BACEC,SACA;EACA,MAAM,EACJ,YACA,OACA,iBAAiB,eAAe,iBAChC,UACD,GAAG;EAGJ,MAAMC,qBAA8C,CAAE;AACtD,MAAI,SACF,MAAK,MAAM,CAAC,KAAK,QAAQ,IAAI,OAAO,QAAQ,SAAS,CACnD,oBAAmB,OAAO,OACxB,EAAE,KAA2B,EAC7BC,QACG;GACH,MAAM,QAAQ,MAAM,AAAC,QAA0C,IAAI;AACnE,SAAM,IAAI,MAAM;EACjB;EASL,MAAM,WAAW,KAAK,IAAI;AAE1B,SAAO,SAA2B;GAEhC,KAAK,OAAO,EAAE,EAAEC,QAA+C;IAE7D,MAAM,qBAAqB,MAAM;KAC/B,cAAc;AACZ,YAAM,gBAAgB;AACtB,WAAK,OAAO;KACb;IACF;IAED,IAAIC;IACJ,MAAM,OAAO,MAAM,YAAY;AAC/B,QAAI;AACF,WAAM,KAAK,SAAS,MAAM,gBAAgB,OAAO,gBAAgB;AAC/D,UAAI;AAEF,aAAM,QAAQ,YAAY;AAC1B,aAAM,IAAI,YAAY;MACvB,SAAQ,OAAO;AAEd,mBAAY;MACb;AAGD,YAAM,IAAI;KACX,EAAC;IACH,SAAQ,OAAO;AAEd,WAAM,iBAAiB,cACrB,OAAM;AAIR,SAAI,UACF,OAAM;IAET,UAAS;AACR,WAAM,KAAK,QAAQ,KAAK;IACzB;GACF;GACD,GAAG;EACJ,EAAC;CACH;AACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmGD,SAAgB,mBAMdC,aACAC,UACoD;CAEpD,MAAMC,qBAA0C,CAAE;AAElD,MAAK,MAAM,CAAC,KAAK,QAAQ,IAAI,OAAO,QAAQ,SAAS,CACnD,oBAAmB,OAAO,OACxB,EAAE,KAA2B,EAC7BL,QACG;EACH,MAAM,QAAQ,MAAM,AAAC,QAA0C,IAAI;AACnE,QAAM,IAAI,MAAM;CACjB;AAGH,QAAO,AAAC,YAAoB,OAAO,mBAAmB;AACvD"}
1
+ {"version":3,"file":"VitestTransactionIsolator-DQ7tLqgV.mjs","names":["api: TestAPI","options: TransactionWrapperOptions<TConn, Transaction, Extended>","additionalFixtures: Record<string, unknown>","use: (value: unknown) => Promise<void>","use: (value: Transaction) => Promise<void>","testError: Error | undefined","wrappedTest: T","fixtures: FixtureCreators<Transaction, Extended>","fixtureDefinitions: Record<string, any>"],"sources":["../src/VitestTransactionIsolator.ts"],"sourcesContent":["import type { TestAPI } from 'vitest';\n\n/**\n * Type definition for test fixtures that provide transaction access.\n * Used with Vitest's test.extend() API to inject transactions into tests.\n *\n * @template Transaction - The transaction type specific to the database driver\n * @template Extended - Additional context properties provided by the extend function\n */\nexport interface DatabaseFixtures<Transaction, _Extended = object> {\n\t/**\n\t * The database transaction available to the test.\n\t * All database operations should use this transaction to ensure proper rollback.\n\t */\n\ttrx: Transaction;\n}\n\n/**\n * Combined fixtures type that merges the base transaction fixture with extended context.\n */\nexport type ExtendedDatabaseFixtures<\n\tTransaction,\n\tExtended = object,\n> = DatabaseFixtures<Transaction> & Extended;\n\n/**\n * Function type for extending test context with additional properties.\n * Receives the transaction and returns additional context to be merged with { trx }.\n *\n * @template Transaction - The transaction type\n * @template Extended - The type of additional context to provide\n *\n * @example\n * ```typescript\n * const extendContext: ExtendContextFn<Transaction<DB>, { factory: KyselyFactory }> =\n * (trx) => ({ factory: new KyselyFactory(builders, seeds, trx) });\n * ```\n */\nexport type ExtendContextFn<Transaction, Extended> = (\n\ttrx: Transaction,\n) => Extended | Promise<Extended>;\n\n/**\n * PostgreSQL transaction isolation levels.\n * Controls the visibility of concurrent transactions.\n *\n * @see https://www.postgresql.org/docs/current/transaction-iso.html\n */\nexport enum IsolationLevel {\n\t/**\n\t * Lowest isolation level. Allows dirty reads.\n\t * Not recommended for testing.\n\t */\n\tREAD_UNCOMMITTED = 'READ UNCOMMITTED',\n\t/**\n\t * Default PostgreSQL isolation level.\n\t * Prevents dirty reads but allows non-repeatable reads.\n\t */\n\tREAD_COMMITTED = 'READ COMMITTED',\n\t/**\n\t * Prevents dirty reads and non-repeatable reads.\n\t * Recommended for most test scenarios.\n\t */\n\tREPEATABLE_READ = 'REPEATABLE READ',\n\t/**\n\t * Highest isolation level. Prevents all phenomena.\n\t * May cause performance overhead in tests.\n\t */\n\tSERIALIZABLE = 'SERIALIZABLE',\n}\n\n/**\n * Abstract base class for implementing database transaction isolation in Vitest tests.\n * Provides automatic transaction rollback after each test to maintain test isolation.\n * Subclasses must implement the transact() method for their specific database driver.\n *\n * @template TConn - The database connection type\n * @template Transaction - The transaction type\n *\n * @example\n * ```typescript\n * // Implement for your database driver\n * class MyDatabaseIsolator extends VitestPostgresTransactionIsolator<MyDB, MyTx> {\n * async transact(conn: MyDB, level: IsolationLevel, fn: (tx: MyTx) => Promise<void>) {\n * await conn.transaction(level, fn);\n * }\n * }\n *\n * // Use in tests\n * const isolator = new MyDatabaseIsolator(test);\n * const isolatedTest = isolator.wrapVitestWithTransaction(db);\n *\n * isolatedTest('should create user', async ({ trx }) => {\n * await trx.insert('users', { name: 'Test' });\n * // Data is automatically rolled back after test\n * });\n * ```\n */\nexport abstract class VitestPostgresTransactionIsolator<TConn, Transaction> {\n\t/**\n\t * Abstract method to create a transaction with the specified isolation level.\n\t * Must be implemented by subclasses for specific database drivers.\n\t *\n\t * @param conn - The database connection\n\t * @param isolationLevel - The transaction isolation level\n\t * @param fn - The function to execute within the transaction\n\t * @returns Promise that resolves when the transaction completes\n\t */\n\tabstract transact(\n\t\tconn: TConn,\n\t\tisolationLevel: IsolationLevel,\n\t\tfn: (trx: Transaction) => Promise<void>,\n\t): Promise<void>;\n\n\tabstract destroy(conn: TConn): Promise<void>;\n\t/**\n\t * Creates a new VitestPostgresTransactionIsolator instance.\n\t *\n\t * @param api - The Vitest test API (usually the `test` export from vitest)\n\t */\n\tconstructor(private readonly api: TestAPI) {}\n\n\t/**\n\t * Creates a wrapped version of Vitest's test API that provides transaction isolation.\n\t * Each test will run within a database transaction that is automatically rolled back.\n\t *\n\t * @param options - Configuration options for transaction wrapping\n\t * @returns A wrapped test API with transaction support\n\t *\n\t * @example\n\t * ```typescript\n\t * const isolatedTest = isolator.wrapVitestWithTransaction({\n\t * connection: db,\n\t * setup: async (trx) => {\n\t * await trx.insert('settings', { key: 'test', value: 'true' });\n\t * },\n\t * fixtures: {\n\t * factory: (trx) => new Factory(trx),\n\t * },\n\t * });\n\t *\n\t * isolatedTest('test with transaction', async ({ trx, factory }) => {\n\t * const user = await factory.insert('user', { name: 'Test' });\n\t * expect(user).toBeDefined();\n\t * });\n\t * ```\n\t */\n\twrapVitestWithTransaction<Extended extends Record<string, unknown> = {}>(\n\t\toptions: TransactionWrapperOptions<TConn, Transaction, Extended>,\n\t) {\n\t\tconst {\n\t\t\tconnection,\n\t\t\tsetup,\n\t\t\tisolationLevel = IsolationLevel.REPEATABLE_READ,\n\t\t\tfixtures,\n\t\t} = options;\n\n\t\t// Build fixture definitions for additional fixtures that depend on trx\n\t\tconst additionalFixtures: Record<string, unknown> = {};\n\t\tif (fixtures) {\n\t\t\tfor (const [key, creator] of Object.entries(fixtures)) {\n\t\t\t\tadditionalFixtures[key] = async (\n\t\t\t\t\t{ trx }: { trx: Transaction },\n\t\t\t\t\tuse: (value: unknown) => Promise<void>,\n\t\t\t\t) => {\n\t\t\t\t\tconst value = await (creator as (trx: Transaction) => unknown)(trx);\n\t\t\t\t\tawait use(value);\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\ttype CombinedFixtures = DatabaseFixtures<Transaction> & Extended;\n\n\t\t// Cast to bypass Vitest's strict fixture typing which can't infer\n\t\t// dynamically built fixture objects\n\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\tconst extendFn = this.api.extend as <T>(fixtures: any) => TestAPI<T>;\n\n\t\treturn extendFn<CombinedFixtures>({\n\t\t\t// This fixture automatically provides a transaction to each test\n\t\t\t// biome-ignore lint/correctness/noEmptyPattern: this has to be like this to satisfy Biome\n\t\t\ttrx: async ({}: {}, use: (value: Transaction) => Promise<void>) => {\n\t\t\t\t// Create a custom error class for rollback\n\t\t\t\tclass TestRollback extends Error {\n\t\t\t\t\tconstructor() {\n\t\t\t\t\t\tsuper('Test rollback');\n\t\t\t\t\t\tthis.name = 'TestRollback';\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tlet testError: Error | undefined;\n\t\t\t\tconst conn = await connection();\n\t\t\t\ttry {\n\t\t\t\t\tawait this.transact(conn, isolationLevel, async (transaction) => {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t// Provide the transaction to the test\n\t\t\t\t\t\t\tawait setup?.(transaction);\n\t\t\t\t\t\t\tawait use(transaction);\n\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\t// Capture any test errors\n\t\t\t\t\t\t\ttestError = error as Error;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Always throw to trigger rollback\n\t\t\t\t\t\tthrow new TestRollback();\n\t\t\t\t\t});\n\t\t\t\t} catch (error) {\n\t\t\t\t\t// Only rethrow if it's not our rollback error\n\t\t\t\t\tif (!(error instanceof TestRollback)) {\n\t\t\t\t\t\tthrow error;\n\t\t\t\t\t}\n\n\t\t\t\t\t// If the test had an error, throw it now\n\t\t\t\t\tif (testError) {\n\t\t\t\t\t\tthrow testError;\n\t\t\t\t\t}\n\t\t\t\t} finally {\n\t\t\t\t\tawait this.destroy(conn);\n\t\t\t\t}\n\t\t\t},\n\t\t\t...additionalFixtures,\n\t\t});\n\t}\n}\n\nexport type DatabaseConnectionFn<Conn> = () => Conn | Promise<Conn>;\nexport type DatabaseConnection<Conn> = DatabaseConnectionFn<Conn>;\n\n/**\n * Options for wrapping Vitest tests with database transaction isolation.\n */\nexport interface TransactionWrapperOptions<\n\tTConn,\n\tTransaction,\n\tExtended extends Record<string, unknown> = {},\n> {\n\t/** Function that creates or returns a database connection */\n\tconnection: DatabaseConnection<TConn>;\n\t/** Optional setup function to run within the transaction before each test */\n\tsetup?: (trx: Transaction) => Promise<void>;\n\t/** Transaction isolation level (defaults to REPEATABLE_READ) */\n\tisolationLevel?: IsolationLevel;\n\t/** Additional fixtures that depend on the transaction */\n\tfixtures?: FixtureCreators<Transaction, Extended>;\n}\n\n/**\n * Type for fixture creator functions that depend on the transaction.\n * Each function receives the transaction and returns the fixture value.\n */\nexport type FixtureCreators<\n\tTransaction,\n\tExtended extends Record<string, unknown>,\n> = {\n\t[K in keyof Extended]: (\n\t\ttrx: Transaction,\n\t) => Extended[K] | Promise<Extended[K]>;\n};\n\n/**\n * The test API returned by extendWithFixtures.\n * Provides access to both the transaction (trx) and all extended fixtures.\n *\n * @template Transaction - The transaction type\n * @template Extended - The type of additional fixtures provided\n * @template BaseTest - The base wrapped test type\n */\nexport type TestWithExtendedFixtures<\n\tTransaction,\n\tExtended extends Record<string, unknown>,\n\tBaseTest extends ReturnType<TestAPI['extend']> = ReturnType<\n\t\tTestAPI['extend']\n\t>,\n> = BaseTest & {\n\t<C extends object>(\n\t\tname: string,\n\t\tfn: (\n\t\t\tcontext: DatabaseFixtures<Transaction> & Extended & C,\n\t\t) => Promise<void>,\n\t): void;\n\t<C extends object>(\n\t\tname: string,\n\t\toptions: object,\n\t\tfn: (\n\t\t\tcontext: DatabaseFixtures<Transaction> & Extended & C,\n\t\t) => Promise<void>,\n\t): void;\n};\n\n/**\n * Extends a wrapped test API with additional fixtures that depend on the transaction.\n * This allows composing test context with factories, repositories, or other helpers.\n *\n * @template Transaction - The transaction type\n * @template Extended - The type of additional context to provide\n * @param wrappedTest - The base wrapped test from wrapVitestWithTransaction\n * @param fixtures - Object mapping fixture names to creator functions\n * @returns An extended test API with both trx and the additional fixtures\n *\n * @example\n * ```typescript\n * import { wrapVitestKyselyTransaction, extendWithFixtures } from '@geekmidas/testkit/kysely';\n *\n * // Create base wrapped test\n * const baseTest = wrapVitestKyselyTransaction(test, {\n * connection: db,\n * setup: createTestTables,\n * });\n *\n * // Extend with fixtures\n * const it = extendWithFixtures(baseTest, {\n * factory: (trx) => new KyselyFactory(builders, seeds, trx),\n * userRepo: (trx) => new UserRepository(trx),\n * });\n *\n * // Use in tests - trx and all fixtures are available\n * it('should create user with factory', async ({ trx, factory, userRepo }) => {\n * const user = await factory.insert('user', { name: 'Test' });\n * expect(user).toBeDefined();\n * });\n * ```\n */\nexport function extendWithFixtures<\n\tTransaction,\n\tExtended extends Record<string, unknown>,\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tT extends ReturnType<TestAPI['extend']> = any,\n>(\n\twrappedTest: T,\n\tfixtures: FixtureCreators<Transaction, Extended>,\n): TestWithExtendedFixtures<Transaction, Extended, T> {\n\t// Build fixture definitions for Vitest's extend API\n\tconst fixtureDefinitions: Record<string, any> = {};\n\n\tfor (const [key, creator] of Object.entries(fixtures)) {\n\t\tfixtureDefinitions[key] = async (\n\t\t\t{ trx }: { trx: Transaction },\n\t\t\tuse: (value: unknown) => Promise<void>,\n\t\t) => {\n\t\t\tconst value = await (creator as (trx: Transaction) => unknown)(trx);\n\t\t\tawait use(value);\n\t\t};\n\t}\n\n\treturn (wrappedTest as any).extend(fixtureDefinitions);\n}\n"],"mappings":";;;;;;;AAgDA,IAAY,4DAAL;;;;;AAKN;;;;;AAKA;;;;;AAKA;;;;;AAKA;;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BD,IAAsB,oCAAtB,MAA4E;;;;;;CAsB3E,YAA6BA,KAAc;EAAd;CAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;CA2B7C,0BACCC,SACC;EACD,MAAM,EACL,YACA,OACA,iBAAiB,eAAe,iBAChC,UACA,GAAG;EAGJ,MAAMC,qBAA8C,CAAE;AACtD,MAAI,SACH,MAAK,MAAM,CAAC,KAAK,QAAQ,IAAI,OAAO,QAAQ,SAAS,CACpD,oBAAmB,OAAO,OACzB,EAAE,KAA2B,EAC7BC,QACI;GACJ,MAAM,QAAQ,MAAM,AAAC,QAA0C,IAAI;AACnE,SAAM,IAAI,MAAM;EAChB;EASH,MAAM,WAAW,KAAK,IAAI;AAE1B,SAAO,SAA2B;GAGjC,KAAK,OAAO,EAAM,EAAEC,QAA+C;IAElE,MAAM,qBAAqB,MAAM;KAChC,cAAc;AACb,YAAM,gBAAgB;AACtB,WAAK,OAAO;KACZ;IACD;IAED,IAAIC;IACJ,MAAM,OAAO,MAAM,YAAY;AAC/B,QAAI;AACH,WAAM,KAAK,SAAS,MAAM,gBAAgB,OAAO,gBAAgB;AAChE,UAAI;AAEH,aAAM,QAAQ,YAAY;AAC1B,aAAM,IAAI,YAAY;MACtB,SAAQ,OAAO;AAEf,mBAAY;MACZ;AAGD,YAAM,IAAI;KACV,EAAC;IACF,SAAQ,OAAO;AAEf,WAAM,iBAAiB,cACtB,OAAM;AAIP,SAAI,UACH,OAAM;IAEP,UAAS;AACT,WAAM,KAAK,QAAQ,KAAK;IACxB;GACD;GACD,GAAG;EACH,EAAC;CACF;AACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmGD,SAAgB,mBAMfC,aACAC,UACqD;CAErD,MAAMC,qBAA0C,CAAE;AAElD,MAAK,MAAM,CAAC,KAAK,QAAQ,IAAI,OAAO,QAAQ,SAAS,CACpD,oBAAmB,OAAO,OACzB,EAAE,KAA2B,EAC7BL,QACI;EACJ,MAAM,QAAQ,MAAM,AAAC,QAA0C,IAAI;AACnE,QAAM,IAAI,MAAM;CAChB;AAGF,QAAO,AAAC,YAAoB,OAAO,mBAAmB;AACtD"}
@@ -1,2 +1,2 @@
1
- import { DatabaseConnection, DatabaseConnectionFn, DatabaseFixtures, ExtendContextFn, ExtendedDatabaseFixtures, FixtureCreators, IsolationLevel, TestWithExtendedFixtures, TransactionWrapperOptions, VitestPostgresTransactionIsolator, extendWithFixtures } from "./VitestTransactionIsolator-CwQaxZLP.cjs";
1
+ import { DatabaseConnection, DatabaseConnectionFn, DatabaseFixtures, ExtendContextFn, ExtendedDatabaseFixtures, FixtureCreators, IsolationLevel, TestWithExtendedFixtures, TransactionWrapperOptions, VitestPostgresTransactionIsolator, extendWithFixtures } from "./VitestTransactionIsolator-CSroc7Df.cjs";
2
2
  export { DatabaseConnection, DatabaseConnectionFn, DatabaseFixtures, ExtendContextFn, ExtendedDatabaseFixtures, FixtureCreators, IsolationLevel, TestWithExtendedFixtures, TransactionWrapperOptions, VitestPostgresTransactionIsolator, extendWithFixtures };
@@ -1,2 +1,2 @@
1
- import { DatabaseConnection, DatabaseConnectionFn, DatabaseFixtures, ExtendContextFn, ExtendedDatabaseFixtures, FixtureCreators, IsolationLevel, TestWithExtendedFixtures, TransactionWrapperOptions, VitestPostgresTransactionIsolator, extendWithFixtures } from "./VitestTransactionIsolator-BvR19bYn.mjs";
1
+ import { DatabaseConnection, DatabaseConnectionFn, DatabaseFixtures, ExtendContextFn, ExtendedDatabaseFixtures, FixtureCreators, IsolationLevel, TestWithExtendedFixtures, TransactionWrapperOptions, VitestPostgresTransactionIsolator, extendWithFixtures } from "./VitestTransactionIsolator-BNWJqh9f.mjs";
2
2
  export { DatabaseConnection, DatabaseConnectionFn, DatabaseFixtures, ExtendContextFn, ExtendedDatabaseFixtures, FixtureCreators, IsolationLevel, TestWithExtendedFixtures, TransactionWrapperOptions, VitestPostgresTransactionIsolator, extendWithFixtures };
package/dist/aws.cjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"aws.cjs","names":["overrides: Partial<APIGatewayProxyEvent>","overrides: Partial<APIGatewayProxyEventV2>"],"sources":["../src/aws.ts"],"sourcesContent":["import type {\n APIGatewayProxyEvent,\n APIGatewayProxyEventV2,\n Context,\n} from 'aws-lambda';\nimport { vi } from 'vitest';\n\n/**\n * Shared test utilities for AWS Lambda adapter testing\n */\n\n/**\n * Creates a mock AWS Lambda Context for testing\n */\nexport function createMockContext(): Context {\n return {\n awsRequestId: 'test-request-id',\n callbackWaitsForEmptyEventLoop: false,\n functionName: 'test-function',\n functionVersion: '1',\n invokedFunctionArn:\n 'arn:aws:lambda:us-east-1:123456789012:function:test-function',\n memoryLimitInMB: '128',\n logGroupName: '/aws/lambda/test-function',\n logStreamName: '2024/01/01/[$LATEST]abcdef123456',\n getRemainingTimeInMillis: () => 5000,\n done: vi.fn(),\n fail: vi.fn(),\n succeed: vi.fn(),\n };\n}\n\n/**\n * Creates a mock AWS API Gateway V1 (REST API) event for testing\n */\nexport function createMockV1Event(\n overrides: Partial<APIGatewayProxyEvent> = {},\n): APIGatewayProxyEvent {\n return {\n body: null,\n headers: {\n 'content-type': 'application/json',\n 'user-agent': 'test-agent',\n host: 'test.example.com',\n },\n multiValueHeaders: {},\n httpMethod: 'GET',\n isBase64Encoded: false,\n path: '/test',\n pathParameters: null,\n queryStringParameters: null,\n multiValueQueryStringParameters: null,\n stageVariables: null,\n requestContext: {\n accountId: '123456789012',\n apiId: 'api-id',\n authorizer: null,\n protocol: 'HTTP/1.1',\n httpMethod: 'GET',\n path: '/test',\n stage: 'test',\n requestId: 'request-id',\n requestTimeEpoch: 1704067200000,\n resourceId: 'resource-id',\n resourcePath: '/test',\n identity: {\n accessKey: null,\n accountId: null,\n apiKey: null,\n apiKeyId: null,\n caller: null,\n cognitoAuthenticationProvider: null,\n cognitoAuthenticationType: null,\n cognitoIdentityId: null,\n cognitoIdentityPoolId: null,\n principalOrgId: null,\n sourceIp: '127.0.0.1',\n user: null,\n userAgent: 'test-agent',\n userArn: null,\n clientCert: null,\n },\n },\n resource: '/test',\n ...overrides,\n };\n}\n\n/**\n * Creates a mock AWS API Gateway V2 (HTTP API) event for testing\n */\nexport function createMockV2Event(\n overrides: Partial<APIGatewayProxyEventV2> = {},\n): APIGatewayProxyEventV2 {\n return {\n version: '2.0',\n routeKey: 'GET /test',\n rawPath: '/test',\n rawQueryString: '',\n headers: {\n 'content-type': 'application/json',\n 'user-agent': 'test-agent',\n host: 'test.example.com',\n },\n requestContext: {\n accountId: '123456789012',\n apiId: 'api-id',\n domainName: 'test.example.com',\n domainPrefix: 'api',\n requestId: 'request-id',\n routeKey: 'GET /test',\n stage: 'test',\n time: '01/Jan/2024:00:00:00 +0000',\n timeEpoch: 1704067200000,\n http: {\n method: 'GET',\n path: '/test',\n protocol: 'HTTP/1.1',\n sourceIp: '127.0.0.1',\n userAgent: 'test-agent',\n },\n },\n body: undefined,\n pathParameters: undefined,\n isBase64Encoded: false,\n stageVariables: undefined,\n queryStringParameters: undefined,\n cookies: undefined,\n ...overrides,\n };\n}\n"],"mappings":";;;;;;;;;;AAcA,SAAgB,oBAA6B;AAC3C,QAAO;EACL,cAAc;EACd,gCAAgC;EAChC,cAAc;EACd,iBAAiB;EACjB,oBACE;EACF,iBAAiB;EACjB,cAAc;EACd,eAAe;EACf,0BAA0B,MAAM;EAChC,MAAM,UAAG,IAAI;EACb,MAAM,UAAG,IAAI;EACb,SAAS,UAAG,IAAI;CACjB;AACF;;;;AAKD,SAAgB,kBACdA,YAA2C,CAAE,GACvB;AACtB,QAAO;EACL,MAAM;EACN,SAAS;GACP,gBAAgB;GAChB,cAAc;GACd,MAAM;EACP;EACD,mBAAmB,CAAE;EACrB,YAAY;EACZ,iBAAiB;EACjB,MAAM;EACN,gBAAgB;EAChB,uBAAuB;EACvB,iCAAiC;EACjC,gBAAgB;EAChB,gBAAgB;GACd,WAAW;GACX,OAAO;GACP,YAAY;GACZ,UAAU;GACV,YAAY;GACZ,MAAM;GACN,OAAO;GACP,WAAW;GACX,kBAAkB;GAClB,YAAY;GACZ,cAAc;GACd,UAAU;IACR,WAAW;IACX,WAAW;IACX,QAAQ;IACR,UAAU;IACV,QAAQ;IACR,+BAA+B;IAC/B,2BAA2B;IAC3B,mBAAmB;IACnB,uBAAuB;IACvB,gBAAgB;IAChB,UAAU;IACV,MAAM;IACN,WAAW;IACX,SAAS;IACT,YAAY;GACb;EACF;EACD,UAAU;EACV,GAAG;CACJ;AACF;;;;AAKD,SAAgB,kBACdC,YAA6C,CAAE,GACvB;AACxB,QAAO;EACL,SAAS;EACT,UAAU;EACV,SAAS;EACT,gBAAgB;EAChB,SAAS;GACP,gBAAgB;GAChB,cAAc;GACd,MAAM;EACP;EACD,gBAAgB;GACd,WAAW;GACX,OAAO;GACP,YAAY;GACZ,cAAc;GACd,WAAW;GACX,UAAU;GACV,OAAO;GACP,MAAM;GACN,WAAW;GACX,MAAM;IACJ,QAAQ;IACR,MAAM;IACN,UAAU;IACV,UAAU;IACV,WAAW;GACZ;EACF;EACD;EACA;EACA,iBAAiB;EACjB;EACA;EACA;EACA,GAAG;CACJ;AACF"}
1
+ {"version":3,"file":"aws.cjs","names":["overrides: Partial<APIGatewayProxyEvent>","overrides: Partial<APIGatewayProxyEventV2>"],"sources":["../src/aws.ts"],"sourcesContent":["import type {\n\tAPIGatewayProxyEvent,\n\tAPIGatewayProxyEventV2,\n\tContext,\n} from 'aws-lambda';\nimport { vi } from 'vitest';\n\n/**\n * Shared test utilities for AWS Lambda adapter testing\n */\n\n/**\n * Creates a mock AWS Lambda Context for testing\n */\nexport function createMockContext(): Context {\n\treturn {\n\t\tawsRequestId: 'test-request-id',\n\t\tcallbackWaitsForEmptyEventLoop: false,\n\t\tfunctionName: 'test-function',\n\t\tfunctionVersion: '1',\n\t\tinvokedFunctionArn:\n\t\t\t'arn:aws:lambda:us-east-1:123456789012:function:test-function',\n\t\tmemoryLimitInMB: '128',\n\t\tlogGroupName: '/aws/lambda/test-function',\n\t\tlogStreamName: '2024/01/01/[$LATEST]abcdef123456',\n\t\tgetRemainingTimeInMillis: () => 5000,\n\t\tdone: vi.fn(),\n\t\tfail: vi.fn(),\n\t\tsucceed: vi.fn(),\n\t};\n}\n\n/**\n * Creates a mock AWS API Gateway V1 (REST API) event for testing\n */\nexport function createMockV1Event(\n\toverrides: Partial<APIGatewayProxyEvent> = {},\n): APIGatewayProxyEvent {\n\treturn {\n\t\tbody: null,\n\t\theaders: {\n\t\t\t'content-type': 'application/json',\n\t\t\t'user-agent': 'test-agent',\n\t\t\thost: 'test.example.com',\n\t\t},\n\t\tmultiValueHeaders: {},\n\t\thttpMethod: 'GET',\n\t\tisBase64Encoded: false,\n\t\tpath: '/test',\n\t\tpathParameters: null,\n\t\tqueryStringParameters: null,\n\t\tmultiValueQueryStringParameters: null,\n\t\tstageVariables: null,\n\t\trequestContext: {\n\t\t\taccountId: '123456789012',\n\t\t\tapiId: 'api-id',\n\t\t\tauthorizer: null,\n\t\t\tprotocol: 'HTTP/1.1',\n\t\t\thttpMethod: 'GET',\n\t\t\tpath: '/test',\n\t\t\tstage: 'test',\n\t\t\trequestId: 'request-id',\n\t\t\trequestTimeEpoch: 1704067200000,\n\t\t\tresourceId: 'resource-id',\n\t\t\tresourcePath: '/test',\n\t\t\tidentity: {\n\t\t\t\taccessKey: null,\n\t\t\t\taccountId: null,\n\t\t\t\tapiKey: null,\n\t\t\t\tapiKeyId: null,\n\t\t\t\tcaller: null,\n\t\t\t\tcognitoAuthenticationProvider: null,\n\t\t\t\tcognitoAuthenticationType: null,\n\t\t\t\tcognitoIdentityId: null,\n\t\t\t\tcognitoIdentityPoolId: null,\n\t\t\t\tprincipalOrgId: null,\n\t\t\t\tsourceIp: '127.0.0.1',\n\t\t\t\tuser: null,\n\t\t\t\tuserAgent: 'test-agent',\n\t\t\t\tuserArn: null,\n\t\t\t\tclientCert: null,\n\t\t\t},\n\t\t},\n\t\tresource: '/test',\n\t\t...overrides,\n\t};\n}\n\n/**\n * Creates a mock AWS API Gateway V2 (HTTP API) event for testing\n */\nexport function createMockV2Event(\n\toverrides: Partial<APIGatewayProxyEventV2> = {},\n): APIGatewayProxyEventV2 {\n\treturn {\n\t\tversion: '2.0',\n\t\trouteKey: 'GET /test',\n\t\trawPath: '/test',\n\t\trawQueryString: '',\n\t\theaders: {\n\t\t\t'content-type': 'application/json',\n\t\t\t'user-agent': 'test-agent',\n\t\t\thost: 'test.example.com',\n\t\t},\n\t\trequestContext: {\n\t\t\taccountId: '123456789012',\n\t\t\tapiId: 'api-id',\n\t\t\tdomainName: 'test.example.com',\n\t\t\tdomainPrefix: 'api',\n\t\t\trequestId: 'request-id',\n\t\t\trouteKey: 'GET /test',\n\t\t\tstage: 'test',\n\t\t\ttime: '01/Jan/2024:00:00:00 +0000',\n\t\t\ttimeEpoch: 1704067200000,\n\t\t\thttp: {\n\t\t\t\tmethod: 'GET',\n\t\t\t\tpath: '/test',\n\t\t\t\tprotocol: 'HTTP/1.1',\n\t\t\t\tsourceIp: '127.0.0.1',\n\t\t\t\tuserAgent: 'test-agent',\n\t\t\t},\n\t\t},\n\t\tbody: undefined,\n\t\tpathParameters: undefined,\n\t\tisBase64Encoded: false,\n\t\tstageVariables: undefined,\n\t\tqueryStringParameters: undefined,\n\t\tcookies: undefined,\n\t\t...overrides,\n\t};\n}\n"],"mappings":";;;;;;;;;;AAcA,SAAgB,oBAA6B;AAC5C,QAAO;EACN,cAAc;EACd,gCAAgC;EAChC,cAAc;EACd,iBAAiB;EACjB,oBACC;EACD,iBAAiB;EACjB,cAAc;EACd,eAAe;EACf,0BAA0B,MAAM;EAChC,MAAM,UAAG,IAAI;EACb,MAAM,UAAG,IAAI;EACb,SAAS,UAAG,IAAI;CAChB;AACD;;;;AAKD,SAAgB,kBACfA,YAA2C,CAAE,GACtB;AACvB,QAAO;EACN,MAAM;EACN,SAAS;GACR,gBAAgB;GAChB,cAAc;GACd,MAAM;EACN;EACD,mBAAmB,CAAE;EACrB,YAAY;EACZ,iBAAiB;EACjB,MAAM;EACN,gBAAgB;EAChB,uBAAuB;EACvB,iCAAiC;EACjC,gBAAgB;EAChB,gBAAgB;GACf,WAAW;GACX,OAAO;GACP,YAAY;GACZ,UAAU;GACV,YAAY;GACZ,MAAM;GACN,OAAO;GACP,WAAW;GACX,kBAAkB;GAClB,YAAY;GACZ,cAAc;GACd,UAAU;IACT,WAAW;IACX,WAAW;IACX,QAAQ;IACR,UAAU;IACV,QAAQ;IACR,+BAA+B;IAC/B,2BAA2B;IAC3B,mBAAmB;IACnB,uBAAuB;IACvB,gBAAgB;IAChB,UAAU;IACV,MAAM;IACN,WAAW;IACX,SAAS;IACT,YAAY;GACZ;EACD;EACD,UAAU;EACV,GAAG;CACH;AACD;;;;AAKD,SAAgB,kBACfC,YAA6C,CAAE,GACtB;AACzB,QAAO;EACN,SAAS;EACT,UAAU;EACV,SAAS;EACT,gBAAgB;EAChB,SAAS;GACR,gBAAgB;GAChB,cAAc;GACd,MAAM;EACN;EACD,gBAAgB;GACf,WAAW;GACX,OAAO;GACP,YAAY;GACZ,cAAc;GACd,WAAW;GACX,UAAU;GACV,OAAO;GACP,MAAM;GACN,WAAW;GACX,MAAM;IACL,QAAQ;IACR,MAAM;IACN,UAAU;IACV,UAAU;IACV,WAAW;GACX;EACD;EACD;EACA;EACA,iBAAiB;EACjB;EACA;EACA;EACA,GAAG;CACH;AACD"}
package/dist/aws.d.cts CHANGED
@@ -17,6 +17,8 @@ declare function createMockV1Event(overrides?: Partial<APIGatewayProxyEvent>): A
17
17
  * Creates a mock AWS API Gateway V2 (HTTP API) event for testing
18
18
  */
19
19
  declare function createMockV2Event(overrides?: Partial<APIGatewayProxyEventV2>): APIGatewayProxyEventV2;
20
+ //# sourceMappingURL=aws.d.ts.map
21
+
20
22
  //#endregion
21
23
  export { createMockContext, createMockV1Event, createMockV2Event };
22
24
  //# sourceMappingURL=aws.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aws.d.cts","names":[],"sources":["../src/aws.ts"],"sourcesContent":[],"mappings":";;;;;;AAcA;AAqBA;;;AACY,iBAtBI,iBAAA,CAAA,CAsBJ,EAtByB,OAsBzB;;AACW;AAsDvB;AAAiC,iBAxDjB,iBAAA,CAwDiB,SAAA,CAAA,EAvDrB,OAuDqB,CAvDb,oBAuDa,CAAA,CAAA,EAtD9B,oBAsD8B;;;;AAER,iBAFT,iBAAA,CAES,SAAA,CAAA,EADb,OACa,CADL,sBACK,CAAA,CAAA,EAAtB,sBAAsB"}
package/dist/aws.d.mts CHANGED
@@ -17,6 +17,8 @@ declare function createMockV1Event(overrides?: Partial<APIGatewayProxyEvent>): A
17
17
  * Creates a mock AWS API Gateway V2 (HTTP API) event for testing
18
18
  */
19
19
  declare function createMockV2Event(overrides?: Partial<APIGatewayProxyEventV2>): APIGatewayProxyEventV2;
20
+ //# sourceMappingURL=aws.d.ts.map
21
+
20
22
  //#endregion
21
23
  export { createMockContext, createMockV1Event, createMockV2Event };
22
24
  //# sourceMappingURL=aws.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aws.d.mts","names":[],"sources":["../src/aws.ts"],"sourcesContent":[],"mappings":";;;;;;AAcA;AAqBA;;;AACY,iBAtBI,iBAAA,CAAA,CAsBJ,EAtByB,OAsBzB;;AACW;AAsDvB;AAAiC,iBAxDjB,iBAAA,CAwDiB,SAAA,CAAA,EAvDrB,OAuDqB,CAvDb,oBAuDa,CAAA,CAAA,EAtD9B,oBAsD8B;;;;AAER,iBAFT,iBAAA,CAES,SAAA,CAAA,EADb,OACa,CADL,sBACK,CAAA,CAAA,EAAtB,sBAAsB"}
package/dist/aws.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"aws.mjs","names":["overrides: Partial<APIGatewayProxyEvent>","overrides: Partial<APIGatewayProxyEventV2>"],"sources":["../src/aws.ts"],"sourcesContent":["import type {\n APIGatewayProxyEvent,\n APIGatewayProxyEventV2,\n Context,\n} from 'aws-lambda';\nimport { vi } from 'vitest';\n\n/**\n * Shared test utilities for AWS Lambda adapter testing\n */\n\n/**\n * Creates a mock AWS Lambda Context for testing\n */\nexport function createMockContext(): Context {\n return {\n awsRequestId: 'test-request-id',\n callbackWaitsForEmptyEventLoop: false,\n functionName: 'test-function',\n functionVersion: '1',\n invokedFunctionArn:\n 'arn:aws:lambda:us-east-1:123456789012:function:test-function',\n memoryLimitInMB: '128',\n logGroupName: '/aws/lambda/test-function',\n logStreamName: '2024/01/01/[$LATEST]abcdef123456',\n getRemainingTimeInMillis: () => 5000,\n done: vi.fn(),\n fail: vi.fn(),\n succeed: vi.fn(),\n };\n}\n\n/**\n * Creates a mock AWS API Gateway V1 (REST API) event for testing\n */\nexport function createMockV1Event(\n overrides: Partial<APIGatewayProxyEvent> = {},\n): APIGatewayProxyEvent {\n return {\n body: null,\n headers: {\n 'content-type': 'application/json',\n 'user-agent': 'test-agent',\n host: 'test.example.com',\n },\n multiValueHeaders: {},\n httpMethod: 'GET',\n isBase64Encoded: false,\n path: '/test',\n pathParameters: null,\n queryStringParameters: null,\n multiValueQueryStringParameters: null,\n stageVariables: null,\n requestContext: {\n accountId: '123456789012',\n apiId: 'api-id',\n authorizer: null,\n protocol: 'HTTP/1.1',\n httpMethod: 'GET',\n path: '/test',\n stage: 'test',\n requestId: 'request-id',\n requestTimeEpoch: 1704067200000,\n resourceId: 'resource-id',\n resourcePath: '/test',\n identity: {\n accessKey: null,\n accountId: null,\n apiKey: null,\n apiKeyId: null,\n caller: null,\n cognitoAuthenticationProvider: null,\n cognitoAuthenticationType: null,\n cognitoIdentityId: null,\n cognitoIdentityPoolId: null,\n principalOrgId: null,\n sourceIp: '127.0.0.1',\n user: null,\n userAgent: 'test-agent',\n userArn: null,\n clientCert: null,\n },\n },\n resource: '/test',\n ...overrides,\n };\n}\n\n/**\n * Creates a mock AWS API Gateway V2 (HTTP API) event for testing\n */\nexport function createMockV2Event(\n overrides: Partial<APIGatewayProxyEventV2> = {},\n): APIGatewayProxyEventV2 {\n return {\n version: '2.0',\n routeKey: 'GET /test',\n rawPath: '/test',\n rawQueryString: '',\n headers: {\n 'content-type': 'application/json',\n 'user-agent': 'test-agent',\n host: 'test.example.com',\n },\n requestContext: {\n accountId: '123456789012',\n apiId: 'api-id',\n domainName: 'test.example.com',\n domainPrefix: 'api',\n requestId: 'request-id',\n routeKey: 'GET /test',\n stage: 'test',\n time: '01/Jan/2024:00:00:00 +0000',\n timeEpoch: 1704067200000,\n http: {\n method: 'GET',\n path: '/test',\n protocol: 'HTTP/1.1',\n sourceIp: '127.0.0.1',\n userAgent: 'test-agent',\n },\n },\n body: undefined,\n pathParameters: undefined,\n isBase64Encoded: false,\n stageVariables: undefined,\n queryStringParameters: undefined,\n cookies: undefined,\n ...overrides,\n };\n}\n"],"mappings":";;;;;;;;;AAcA,SAAgB,oBAA6B;AAC3C,QAAO;EACL,cAAc;EACd,gCAAgC;EAChC,cAAc;EACd,iBAAiB;EACjB,oBACE;EACF,iBAAiB;EACjB,cAAc;EACd,eAAe;EACf,0BAA0B,MAAM;EAChC,MAAM,GAAG,IAAI;EACb,MAAM,GAAG,IAAI;EACb,SAAS,GAAG,IAAI;CACjB;AACF;;;;AAKD,SAAgB,kBACdA,YAA2C,CAAE,GACvB;AACtB,QAAO;EACL,MAAM;EACN,SAAS;GACP,gBAAgB;GAChB,cAAc;GACd,MAAM;EACP;EACD,mBAAmB,CAAE;EACrB,YAAY;EACZ,iBAAiB;EACjB,MAAM;EACN,gBAAgB;EAChB,uBAAuB;EACvB,iCAAiC;EACjC,gBAAgB;EAChB,gBAAgB;GACd,WAAW;GACX,OAAO;GACP,YAAY;GACZ,UAAU;GACV,YAAY;GACZ,MAAM;GACN,OAAO;GACP,WAAW;GACX,kBAAkB;GAClB,YAAY;GACZ,cAAc;GACd,UAAU;IACR,WAAW;IACX,WAAW;IACX,QAAQ;IACR,UAAU;IACV,QAAQ;IACR,+BAA+B;IAC/B,2BAA2B;IAC3B,mBAAmB;IACnB,uBAAuB;IACvB,gBAAgB;IAChB,UAAU;IACV,MAAM;IACN,WAAW;IACX,SAAS;IACT,YAAY;GACb;EACF;EACD,UAAU;EACV,GAAG;CACJ;AACF;;;;AAKD,SAAgB,kBACdC,YAA6C,CAAE,GACvB;AACxB,QAAO;EACL,SAAS;EACT,UAAU;EACV,SAAS;EACT,gBAAgB;EAChB,SAAS;GACP,gBAAgB;GAChB,cAAc;GACd,MAAM;EACP;EACD,gBAAgB;GACd,WAAW;GACX,OAAO;GACP,YAAY;GACZ,cAAc;GACd,WAAW;GACX,UAAU;GACV,OAAO;GACP,MAAM;GACN,WAAW;GACX,MAAM;IACJ,QAAQ;IACR,MAAM;IACN,UAAU;IACV,UAAU;IACV,WAAW;GACZ;EACF;EACD;EACA;EACA,iBAAiB;EACjB;EACA;EACA;EACA,GAAG;CACJ;AACF"}
1
+ {"version":3,"file":"aws.mjs","names":["overrides: Partial<APIGatewayProxyEvent>","overrides: Partial<APIGatewayProxyEventV2>"],"sources":["../src/aws.ts"],"sourcesContent":["import type {\n\tAPIGatewayProxyEvent,\n\tAPIGatewayProxyEventV2,\n\tContext,\n} from 'aws-lambda';\nimport { vi } from 'vitest';\n\n/**\n * Shared test utilities for AWS Lambda adapter testing\n */\n\n/**\n * Creates a mock AWS Lambda Context for testing\n */\nexport function createMockContext(): Context {\n\treturn {\n\t\tawsRequestId: 'test-request-id',\n\t\tcallbackWaitsForEmptyEventLoop: false,\n\t\tfunctionName: 'test-function',\n\t\tfunctionVersion: '1',\n\t\tinvokedFunctionArn:\n\t\t\t'arn:aws:lambda:us-east-1:123456789012:function:test-function',\n\t\tmemoryLimitInMB: '128',\n\t\tlogGroupName: '/aws/lambda/test-function',\n\t\tlogStreamName: '2024/01/01/[$LATEST]abcdef123456',\n\t\tgetRemainingTimeInMillis: () => 5000,\n\t\tdone: vi.fn(),\n\t\tfail: vi.fn(),\n\t\tsucceed: vi.fn(),\n\t};\n}\n\n/**\n * Creates a mock AWS API Gateway V1 (REST API) event for testing\n */\nexport function createMockV1Event(\n\toverrides: Partial<APIGatewayProxyEvent> = {},\n): APIGatewayProxyEvent {\n\treturn {\n\t\tbody: null,\n\t\theaders: {\n\t\t\t'content-type': 'application/json',\n\t\t\t'user-agent': 'test-agent',\n\t\t\thost: 'test.example.com',\n\t\t},\n\t\tmultiValueHeaders: {},\n\t\thttpMethod: 'GET',\n\t\tisBase64Encoded: false,\n\t\tpath: '/test',\n\t\tpathParameters: null,\n\t\tqueryStringParameters: null,\n\t\tmultiValueQueryStringParameters: null,\n\t\tstageVariables: null,\n\t\trequestContext: {\n\t\t\taccountId: '123456789012',\n\t\t\tapiId: 'api-id',\n\t\t\tauthorizer: null,\n\t\t\tprotocol: 'HTTP/1.1',\n\t\t\thttpMethod: 'GET',\n\t\t\tpath: '/test',\n\t\t\tstage: 'test',\n\t\t\trequestId: 'request-id',\n\t\t\trequestTimeEpoch: 1704067200000,\n\t\t\tresourceId: 'resource-id',\n\t\t\tresourcePath: '/test',\n\t\t\tidentity: {\n\t\t\t\taccessKey: null,\n\t\t\t\taccountId: null,\n\t\t\t\tapiKey: null,\n\t\t\t\tapiKeyId: null,\n\t\t\t\tcaller: null,\n\t\t\t\tcognitoAuthenticationProvider: null,\n\t\t\t\tcognitoAuthenticationType: null,\n\t\t\t\tcognitoIdentityId: null,\n\t\t\t\tcognitoIdentityPoolId: null,\n\t\t\t\tprincipalOrgId: null,\n\t\t\t\tsourceIp: '127.0.0.1',\n\t\t\t\tuser: null,\n\t\t\t\tuserAgent: 'test-agent',\n\t\t\t\tuserArn: null,\n\t\t\t\tclientCert: null,\n\t\t\t},\n\t\t},\n\t\tresource: '/test',\n\t\t...overrides,\n\t};\n}\n\n/**\n * Creates a mock AWS API Gateway V2 (HTTP API) event for testing\n */\nexport function createMockV2Event(\n\toverrides: Partial<APIGatewayProxyEventV2> = {},\n): APIGatewayProxyEventV2 {\n\treturn {\n\t\tversion: '2.0',\n\t\trouteKey: 'GET /test',\n\t\trawPath: '/test',\n\t\trawQueryString: '',\n\t\theaders: {\n\t\t\t'content-type': 'application/json',\n\t\t\t'user-agent': 'test-agent',\n\t\t\thost: 'test.example.com',\n\t\t},\n\t\trequestContext: {\n\t\t\taccountId: '123456789012',\n\t\t\tapiId: 'api-id',\n\t\t\tdomainName: 'test.example.com',\n\t\t\tdomainPrefix: 'api',\n\t\t\trequestId: 'request-id',\n\t\t\trouteKey: 'GET /test',\n\t\t\tstage: 'test',\n\t\t\ttime: '01/Jan/2024:00:00:00 +0000',\n\t\t\ttimeEpoch: 1704067200000,\n\t\t\thttp: {\n\t\t\t\tmethod: 'GET',\n\t\t\t\tpath: '/test',\n\t\t\t\tprotocol: 'HTTP/1.1',\n\t\t\t\tsourceIp: '127.0.0.1',\n\t\t\t\tuserAgent: 'test-agent',\n\t\t\t},\n\t\t},\n\t\tbody: undefined,\n\t\tpathParameters: undefined,\n\t\tisBase64Encoded: false,\n\t\tstageVariables: undefined,\n\t\tqueryStringParameters: undefined,\n\t\tcookies: undefined,\n\t\t...overrides,\n\t};\n}\n"],"mappings":";;;;;;;;;AAcA,SAAgB,oBAA6B;AAC5C,QAAO;EACN,cAAc;EACd,gCAAgC;EAChC,cAAc;EACd,iBAAiB;EACjB,oBACC;EACD,iBAAiB;EACjB,cAAc;EACd,eAAe;EACf,0BAA0B,MAAM;EAChC,MAAM,GAAG,IAAI;EACb,MAAM,GAAG,IAAI;EACb,SAAS,GAAG,IAAI;CAChB;AACD;;;;AAKD,SAAgB,kBACfA,YAA2C,CAAE,GACtB;AACvB,QAAO;EACN,MAAM;EACN,SAAS;GACR,gBAAgB;GAChB,cAAc;GACd,MAAM;EACN;EACD,mBAAmB,CAAE;EACrB,YAAY;EACZ,iBAAiB;EACjB,MAAM;EACN,gBAAgB;EAChB,uBAAuB;EACvB,iCAAiC;EACjC,gBAAgB;EAChB,gBAAgB;GACf,WAAW;GACX,OAAO;GACP,YAAY;GACZ,UAAU;GACV,YAAY;GACZ,MAAM;GACN,OAAO;GACP,WAAW;GACX,kBAAkB;GAClB,YAAY;GACZ,cAAc;GACd,UAAU;IACT,WAAW;IACX,WAAW;IACX,QAAQ;IACR,UAAU;IACV,QAAQ;IACR,+BAA+B;IAC/B,2BAA2B;IAC3B,mBAAmB;IACnB,uBAAuB;IACvB,gBAAgB;IAChB,UAAU;IACV,MAAM;IACN,WAAW;IACX,SAAS;IACT,YAAY;GACZ;EACD;EACD,UAAU;EACV,GAAG;CACH;AACD;;;;AAKD,SAAgB,kBACfC,YAA6C,CAAE,GACtB;AACzB,QAAO;EACN,SAAS;EACT,UAAU;EACV,SAAS;EACT,gBAAgB;EAChB,SAAS;GACR,gBAAgB;GAChB,cAAc;GACd,MAAM;EACN;EACD,gBAAgB;GACf,WAAW;GACX,OAAO;GACP,YAAY;GACZ,cAAc;GACd,WAAW;GACX,UAAU;GACV,OAAO;GACP,MAAM;GACN,WAAW;GACX,MAAM;IACL,QAAQ;IACR,MAAM;IACN,UAAU;IACV,UAAU;IACV,WAAW;GACX;EACD;EACD;EACA;EACA,iBAAiB;EACjB;EACA;EACA;EACA,GAAG;CACH;AACD"}
@@ -1 +1 @@
1
- {"version":3,"file":"benchmark.cjs","names":["count: number","prefix: string","subnet: string"],"sources":["../src/benchmark.ts"],"sourcesContent":["/**\n * Generates an array of test records for benchmark data sets.\n *\n * @param count - Number of records to generate\n * @returns Array of test data objects\n */\nexport function generateTestData(\n count: number,\n): Array<{ id: string; name: string; value: number }> {\n return Array.from({ length: count }, (_, i) => ({\n id: `id-${i}`,\n name: `Item ${i}`,\n value: Math.random() * 1000,\n }));\n}\n\n/**\n * Generates unique keys for cache benchmarks to avoid collisions.\n *\n * @param prefix - Key prefix\n * @param count - Number of keys to generate\n * @returns Array of unique cache keys\n */\nexport function generateCacheKeys(prefix: string, count: number): string[] {\n return Array.from({ length: count }, (_, i) => `${prefix}:${i}`);\n}\n\n/**\n * Generates IP addresses for rate limit benchmarks.\n *\n * @param count - Number of IPs to generate\n * @param subnet - Subnet prefix (default: '192.168.1')\n * @returns Array of IP addresses\n */\nexport function generateIpAddresses(\n count: number,\n subnet: string = '192.168.1',\n): string[] {\n return Array.from({ length: count }, (_, i) => `${subnet}.${i % 256}`);\n}\n\n/**\n * Creates a random IP address for rate limit benchmarks.\n */\nexport function randomIpAddress(): string {\n const octet = () => Math.floor(Math.random() * 256);\n return `${octet()}.${octet()}.${octet()}.${octet()}`;\n}\n"],"mappings":";;;;;;;;AAMA,SAAgB,iBACdA,OACoD;AACpD,QAAO,MAAM,KAAK,EAAE,QAAQ,MAAO,GAAE,CAAC,GAAG,OAAO;EAC9C,KAAK,KAAK,EAAE;EACZ,OAAO,OAAO,EAAE;EAChB,OAAO,KAAK,QAAQ,GAAG;CACxB,GAAE;AACJ;;;;;;;;AASD,SAAgB,kBAAkBC,QAAgBD,OAAyB;AACzE,QAAO,MAAM,KAAK,EAAE,QAAQ,MAAO,GAAE,CAAC,GAAG,OAAO,EAAE,OAAO,GAAG,EAAE,EAAE;AACjE;;;;;;;;AASD,SAAgB,oBACdA,OACAE,SAAiB,aACP;AACV,QAAO,MAAM,KAAK,EAAE,QAAQ,MAAO,GAAE,CAAC,GAAG,OAAO,EAAE,OAAO,GAAG,IAAI,IAAI,EAAE;AACvE;;;;AAKD,SAAgB,kBAA0B;CACxC,MAAM,QAAQ,MAAM,KAAK,MAAM,KAAK,QAAQ,GAAG,IAAI;AACnD,SAAQ,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,GAAG,OAAO,CAAC,GAAG,OAAO,CAAC;AACpD"}
1
+ {"version":3,"file":"benchmark.cjs","names":["count: number","prefix: string","subnet: string"],"sources":["../src/benchmark.ts"],"sourcesContent":["/**\n * Generates an array of test records for benchmark data sets.\n *\n * @param count - Number of records to generate\n * @returns Array of test data objects\n */\nexport function generateTestData(\n\tcount: number,\n): Array<{ id: string; name: string; value: number }> {\n\treturn Array.from({ length: count }, (_, i) => ({\n\t\tid: `id-${i}`,\n\t\tname: `Item ${i}`,\n\t\tvalue: Math.random() * 1000,\n\t}));\n}\n\n/**\n * Generates unique keys for cache benchmarks to avoid collisions.\n *\n * @param prefix - Key prefix\n * @param count - Number of keys to generate\n * @returns Array of unique cache keys\n */\nexport function generateCacheKeys(prefix: string, count: number): string[] {\n\treturn Array.from({ length: count }, (_, i) => `${prefix}:${i}`);\n}\n\n/**\n * Generates IP addresses for rate limit benchmarks.\n *\n * @param count - Number of IPs to generate\n * @param subnet - Subnet prefix (default: '192.168.1')\n * @returns Array of IP addresses\n */\nexport function generateIpAddresses(\n\tcount: number,\n\tsubnet: string = '192.168.1',\n): string[] {\n\treturn Array.from({ length: count }, (_, i) => `${subnet}.${i % 256}`);\n}\n\n/**\n * Creates a random IP address for rate limit benchmarks.\n */\nexport function randomIpAddress(): string {\n\tconst octet = () => Math.floor(Math.random() * 256);\n\treturn `${octet()}.${octet()}.${octet()}.${octet()}`;\n}\n"],"mappings":";;;;;;;;AAMA,SAAgB,iBACfA,OACqD;AACrD,QAAO,MAAM,KAAK,EAAE,QAAQ,MAAO,GAAE,CAAC,GAAG,OAAO;EAC/C,KAAK,KAAK,EAAE;EACZ,OAAO,OAAO,EAAE;EAChB,OAAO,KAAK,QAAQ,GAAG;CACvB,GAAE;AACH;;;;;;;;AASD,SAAgB,kBAAkBC,QAAgBD,OAAyB;AAC1E,QAAO,MAAM,KAAK,EAAE,QAAQ,MAAO,GAAE,CAAC,GAAG,OAAO,EAAE,OAAO,GAAG,EAAE,EAAE;AAChE;;;;;;;;AASD,SAAgB,oBACfA,OACAE,SAAiB,aACN;AACX,QAAO,MAAM,KAAK,EAAE,QAAQ,MAAO,GAAE,CAAC,GAAG,OAAO,EAAE,OAAO,GAAG,IAAI,IAAI,EAAE;AACtE;;;;AAKD,SAAgB,kBAA0B;CACzC,MAAM,QAAQ,MAAM,KAAK,MAAM,KAAK,QAAQ,GAAG,IAAI;AACnD,SAAQ,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,GAAG,OAAO,CAAC,GAAG,OAAO,CAAC;AACnD"}
@@ -30,6 +30,7 @@ declare function generateIpAddresses(count: number, subnet?: string): string[];
30
30
  * Creates a random IP address for rate limit benchmarks.
31
31
  */
32
32
  declare function randomIpAddress(): string;
33
+ //# sourceMappingURL=benchmark.d.ts.map
33
34
  //#endregion
34
35
  export { generateCacheKeys, generateIpAddresses, generateTestData, randomIpAddress };
35
36
  //# sourceMappingURL=benchmark.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"benchmark.d.cts","names":[],"sources":["../src/benchmark.ts"],"sourcesContent":[],"mappings":";;AAMA;AAiBA;AAWA;AAUA;;iBAtCgB,gBAAA,iBAEb;;;;;;;;;;;;iBAea,iBAAA;;;;;;;;iBAWA,mBAAA;;;;iBAUA,eAAA,CAAA"}
@@ -30,6 +30,7 @@ declare function generateIpAddresses(count: number, subnet?: string): string[];
30
30
  * Creates a random IP address for rate limit benchmarks.
31
31
  */
32
32
  declare function randomIpAddress(): string;
33
+ //# sourceMappingURL=benchmark.d.ts.map
33
34
  //#endregion
34
35
  export { generateCacheKeys, generateIpAddresses, generateTestData, randomIpAddress };
35
36
  //# sourceMappingURL=benchmark.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"benchmark.d.mts","names":[],"sources":["../src/benchmark.ts"],"sourcesContent":[],"mappings":";;AAMA;AAiBA;AAWA;AAUA;;iBAtCgB,gBAAA,iBAEb;;;;;;;;;;;;iBAea,iBAAA;;;;;;;;iBAWA,mBAAA;;;;iBAUA,eAAA,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"benchmark.mjs","names":["count: number","prefix: string","subnet: string"],"sources":["../src/benchmark.ts"],"sourcesContent":["/**\n * Generates an array of test records for benchmark data sets.\n *\n * @param count - Number of records to generate\n * @returns Array of test data objects\n */\nexport function generateTestData(\n count: number,\n): Array<{ id: string; name: string; value: number }> {\n return Array.from({ length: count }, (_, i) => ({\n id: `id-${i}`,\n name: `Item ${i}`,\n value: Math.random() * 1000,\n }));\n}\n\n/**\n * Generates unique keys for cache benchmarks to avoid collisions.\n *\n * @param prefix - Key prefix\n * @param count - Number of keys to generate\n * @returns Array of unique cache keys\n */\nexport function generateCacheKeys(prefix: string, count: number): string[] {\n return Array.from({ length: count }, (_, i) => `${prefix}:${i}`);\n}\n\n/**\n * Generates IP addresses for rate limit benchmarks.\n *\n * @param count - Number of IPs to generate\n * @param subnet - Subnet prefix (default: '192.168.1')\n * @returns Array of IP addresses\n */\nexport function generateIpAddresses(\n count: number,\n subnet: string = '192.168.1',\n): string[] {\n return Array.from({ length: count }, (_, i) => `${subnet}.${i % 256}`);\n}\n\n/**\n * Creates a random IP address for rate limit benchmarks.\n */\nexport function randomIpAddress(): string {\n const octet = () => Math.floor(Math.random() * 256);\n return `${octet()}.${octet()}.${octet()}.${octet()}`;\n}\n"],"mappings":";;;;;;;AAMA,SAAgB,iBACdA,OACoD;AACpD,QAAO,MAAM,KAAK,EAAE,QAAQ,MAAO,GAAE,CAAC,GAAG,OAAO;EAC9C,KAAK,KAAK,EAAE;EACZ,OAAO,OAAO,EAAE;EAChB,OAAO,KAAK,QAAQ,GAAG;CACxB,GAAE;AACJ;;;;;;;;AASD,SAAgB,kBAAkBC,QAAgBD,OAAyB;AACzE,QAAO,MAAM,KAAK,EAAE,QAAQ,MAAO,GAAE,CAAC,GAAG,OAAO,EAAE,OAAO,GAAG,EAAE,EAAE;AACjE;;;;;;;;AASD,SAAgB,oBACdA,OACAE,SAAiB,aACP;AACV,QAAO,MAAM,KAAK,EAAE,QAAQ,MAAO,GAAE,CAAC,GAAG,OAAO,EAAE,OAAO,GAAG,IAAI,IAAI,EAAE;AACvE;;;;AAKD,SAAgB,kBAA0B;CACxC,MAAM,QAAQ,MAAM,KAAK,MAAM,KAAK,QAAQ,GAAG,IAAI;AACnD,SAAQ,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,GAAG,OAAO,CAAC,GAAG,OAAO,CAAC;AACpD"}
1
+ {"version":3,"file":"benchmark.mjs","names":["count: number","prefix: string","subnet: string"],"sources":["../src/benchmark.ts"],"sourcesContent":["/**\n * Generates an array of test records for benchmark data sets.\n *\n * @param count - Number of records to generate\n * @returns Array of test data objects\n */\nexport function generateTestData(\n\tcount: number,\n): Array<{ id: string; name: string; value: number }> {\n\treturn Array.from({ length: count }, (_, i) => ({\n\t\tid: `id-${i}`,\n\t\tname: `Item ${i}`,\n\t\tvalue: Math.random() * 1000,\n\t}));\n}\n\n/**\n * Generates unique keys for cache benchmarks to avoid collisions.\n *\n * @param prefix - Key prefix\n * @param count - Number of keys to generate\n * @returns Array of unique cache keys\n */\nexport function generateCacheKeys(prefix: string, count: number): string[] {\n\treturn Array.from({ length: count }, (_, i) => `${prefix}:${i}`);\n}\n\n/**\n * Generates IP addresses for rate limit benchmarks.\n *\n * @param count - Number of IPs to generate\n * @param subnet - Subnet prefix (default: '192.168.1')\n * @returns Array of IP addresses\n */\nexport function generateIpAddresses(\n\tcount: number,\n\tsubnet: string = '192.168.1',\n): string[] {\n\treturn Array.from({ length: count }, (_, i) => `${subnet}.${i % 256}`);\n}\n\n/**\n * Creates a random IP address for rate limit benchmarks.\n */\nexport function randomIpAddress(): string {\n\tconst octet = () => Math.floor(Math.random() * 256);\n\treturn `${octet()}.${octet()}.${octet()}.${octet()}`;\n}\n"],"mappings":";;;;;;;AAMA,SAAgB,iBACfA,OACqD;AACrD,QAAO,MAAM,KAAK,EAAE,QAAQ,MAAO,GAAE,CAAC,GAAG,OAAO;EAC/C,KAAK,KAAK,EAAE;EACZ,OAAO,OAAO,EAAE;EAChB,OAAO,KAAK,QAAQ,GAAG;CACvB,GAAE;AACH;;;;;;;;AASD,SAAgB,kBAAkBC,QAAgBD,OAAyB;AAC1E,QAAO,MAAM,KAAK,EAAE,QAAQ,MAAO,GAAE,CAAC,GAAG,OAAO,EAAE,OAAO,GAAG,EAAE,EAAE;AAChE;;;;;;;;AASD,SAAgB,oBACfA,OACAE,SAAiB,aACN;AACX,QAAO,MAAM,KAAK,EAAE,QAAQ,MAAO,GAAE,CAAC,GAAG,OAAO,EAAE,OAAO,GAAG,IAAI,IAAI,EAAE;AACtE;;;;AAKD,SAAgB,kBAA0B;CACzC,MAAM,QAAQ,MAAM,KAAK,MAAM,KAAK,QAAQ,GAAG,IAAI;AACnD,SAAQ,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,GAAG,OAAO,CAAC,GAAG,OAAO,CAAC;AACnD"}
@@ -99,29 +99,21 @@ const memoryAdapter = (config = {}, store = /* @__PURE__ */ new Map()) => {
99
99
  supportsBooleans: true,
100
100
  supportsNumericIds: false
101
101
  },
102
- adapter: ({ debugLog, transformInput, transformOutput, getModelName, transformWhereClause }) => ({
103
- create: async ({ data, model, select }) => {
102
+ adapter: ({ debugLog, getModelName, transformWhereClause }) => ({
103
+ create: async ({ data, model }) => {
104
104
  debugLog("CREATE", {
105
105
  model,
106
106
  data
107
107
  });
108
108
  const modelName = getModelName(model);
109
109
  const modelData = storeInstance.getModel(modelName);
110
- const transformedData = await transformInput(data, model, "create");
111
- if (!transformedData.id) transformedData.id = crypto.randomUUID();
112
- modelData.set(transformedData.id, {
113
- ...transformedData,
114
- ...data
115
- });
116
- if (data.email_address) modelData.set(transformedData.id, {
117
- ...transformedData,
118
- email: data.email_address
119
- });
120
- const created = modelData.get(transformedData.id);
121
- const out = await transformOutput(created, model, select);
122
- return out;
110
+ const record = data;
111
+ if (!record.id) record.id = crypto.randomUUID();
112
+ const id = record.id;
113
+ modelData.set(id, { ...record });
114
+ return modelData.get(id);
123
115
  },
124
- findOne: async ({ where, model, select }) => {
116
+ findOne: async ({ where, model }) => {
125
117
  debugLog("FIND_ONE", {
126
118
  model,
127
119
  where
@@ -132,10 +124,7 @@ const memoryAdapter = (config = {}, store = /* @__PURE__ */ new Map()) => {
132
124
  model,
133
125
  where
134
126
  });
135
- for (const record of modelData.values()) if (matchesWhere(record, transformedWhere)) {
136
- const t = await transformOutput(record, model, select);
137
- return t;
138
- }
127
+ for (const record of modelData.values()) if (matchesWhere(record, transformedWhere)) return record;
139
128
  return null;
140
129
  },
141
130
  findMany: async ({ where, model, limit, offset, sortBy }) => {
@@ -153,7 +142,7 @@ const memoryAdapter = (config = {}, store = /* @__PURE__ */ new Map()) => {
153
142
  if (sortBy) results = applySorting(results, sortBy);
154
143
  if (offset) results = results.slice(offset);
155
144
  if (limit) results = results.slice(0, limit);
156
- return Promise.all(results.map((record) => transformOutput(record, model)));
145
+ return results;
157
146
  },
158
147
  update: async ({ where, update, model }) => {
159
148
  debugLog("UPDATE", {
@@ -167,13 +156,12 @@ const memoryAdapter = (config = {}, store = /* @__PURE__ */ new Map()) => {
167
156
  where
168
157
  });
169
158
  for (const [id, record] of modelData.entries()) if (matchesWhere(record, transformedWhere)) {
170
- const transformedData = await transformInput(update, model, "update");
171
159
  const updated = {
172
160
  ...record,
173
- ...transformedData
161
+ ...update
174
162
  };
175
163
  modelData.set(id, updated);
176
- return transformOutput(updated, model);
164
+ return updated;
177
165
  }
178
166
  return null;
179
167
  },
@@ -189,11 +177,10 @@ const memoryAdapter = (config = {}, store = /* @__PURE__ */ new Map()) => {
189
177
  where
190
178
  });
191
179
  let count = 0;
192
- const transformedData = await transformInput(update, model, "update");
193
180
  for (const [id, record] of modelData.entries()) if (matchesWhere(record, transformedWhere)) {
194
181
  modelData.set(id, {
195
182
  ...record,
196
- ...transformedData
183
+ ...update
197
184
  });
198
185
  count++;
199
186
  }
@@ -206,7 +193,11 @@ const memoryAdapter = (config = {}, store = /* @__PURE__ */ new Map()) => {
206
193
  });
207
194
  const modelName = getModelName(model);
208
195
  const modelData = storeInstance.getModel(modelName);
209
- for (const [id, record] of modelData.entries()) if (matchesWhere(record, where)) {
196
+ const transformedWhere = transformWhereClause({
197
+ model,
198
+ where
199
+ });
200
+ for (const [id, record] of modelData.entries()) if (matchesWhere(record, transformedWhere)) {
210
201
  modelData.delete(id);
211
202
  return;
212
203
  }
@@ -218,15 +209,23 @@ const memoryAdapter = (config = {}, store = /* @__PURE__ */ new Map()) => {
218
209
  });
219
210
  const modelName = getModelName(model);
220
211
  const modelData = storeInstance.getModel(modelName);
212
+ const transformedWhere = transformWhereClause({
213
+ model,
214
+ where
215
+ });
221
216
  const toDelete = [];
222
- for (const [id, record] of modelData.entries()) if (matchesWhere(record, where)) toDelete.push(id);
223
- toDelete.forEach((id) => modelData.delete(id));
217
+ for (const [id, record] of modelData.entries()) if (matchesWhere(record, transformedWhere)) toDelete.push(id);
218
+ for (const id of toDelete) modelData.delete(id);
224
219
  return toDelete.length;
225
220
  },
226
221
  count: async ({ where, model }) => {
227
222
  const modelName = getModelName(model);
228
223
  const modelData = storeInstance.getModel(modelName);
229
- return Array.from(modelData.values()).filter((record) => matchesWhere(record, where)).length;
224
+ const transformedWhere = transformWhereClause({
225
+ model,
226
+ where
227
+ });
228
+ return Array.from(modelData.values()).filter((record) => matchesWhere(record, transformedWhere)).length;
230
229
  }
231
230
  })
232
231
  });