@geekmidas/testkit 10.0.0-alpha.99 → 10.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (337) hide show
  1. package/CHANGELOG.md +160 -0
  2. package/README.md +0 -74
  3. package/dist/Factory-BFVnMMCC.mjs +51 -0
  4. package/dist/Factory-BFVnMMCC.mjs.map +1 -0
  5. package/dist/Factory-BOX312yd.d.cts +147 -0
  6. package/dist/Factory-BOX312yd.d.cts.map +1 -0
  7. package/dist/Factory-BhjUOBWN.cjs +57 -0
  8. package/dist/Factory-BhjUOBWN.cjs.map +1 -0
  9. package/dist/Factory-SFupxRC2.d.mts +147 -0
  10. package/dist/Factory-SFupxRC2.d.mts.map +1 -0
  11. package/dist/Factory.cjs +2 -51
  12. package/dist/Factory.d.cts +3 -143
  13. package/dist/Factory.d.mts +3 -143
  14. package/dist/Factory.mjs +2 -50
  15. package/dist/KyselyFactory-BFqVIn_0.cjs +246 -0
  16. package/dist/KyselyFactory-BFqVIn_0.cjs.map +1 -0
  17. package/dist/KyselyFactory-DMswpwji.mjs +241 -0
  18. package/dist/KyselyFactory-DMswpwji.mjs.map +1 -0
  19. package/dist/KyselyFactory-Dy5zzV4B.d.cts +228 -0
  20. package/dist/KyselyFactory-Dy5zzV4B.d.cts.map +1 -0
  21. package/dist/KyselyFactory-vAxYodck.d.mts +228 -0
  22. package/dist/KyselyFactory-vAxYodck.d.mts.map +1 -0
  23. package/dist/KyselyFactory.cjs +4 -237
  24. package/dist/KyselyFactory.d.cts +4 -224
  25. package/dist/KyselyFactory.d.mts +4 -224
  26. package/dist/KyselyFactory.mjs +4 -236
  27. package/dist/ObjectionFactory-BWjB49-i.d.mts +241 -0
  28. package/dist/ObjectionFactory-BWjB49-i.d.mts.map +1 -0
  29. package/dist/ObjectionFactory-BeFBYcan.cjs +272 -0
  30. package/dist/ObjectionFactory-BeFBYcan.cjs.map +1 -0
  31. package/dist/ObjectionFactory-CD-WFuMJ.d.cts +241 -0
  32. package/dist/ObjectionFactory-CD-WFuMJ.d.cts.map +1 -0
  33. package/dist/ObjectionFactory-QCJ7u0Ql.mjs +267 -0
  34. package/dist/ObjectionFactory-QCJ7u0Ql.mjs.map +1 -0
  35. package/dist/ObjectionFactory.cjs +4 -265
  36. package/dist/ObjectionFactory.d.cts +4 -237
  37. package/dist/ObjectionFactory.d.mts +4 -237
  38. package/dist/ObjectionFactory.mjs +4 -264
  39. package/dist/PostgresKyselyMigrator-B2M6Gjvv.d.cts +84 -0
  40. package/dist/PostgresKyselyMigrator-B2M6Gjvv.d.cts.map +1 -0
  41. package/dist/PostgresKyselyMigrator-BGBxjnFv.cjs +101 -0
  42. package/dist/PostgresKyselyMigrator-BGBxjnFv.cjs.map +1 -0
  43. package/dist/PostgresKyselyMigrator-CvwXycJE.d.mts +84 -0
  44. package/dist/PostgresKyselyMigrator-CvwXycJE.d.mts.map +1 -0
  45. package/dist/PostgresKyselyMigrator-PI0QhvB1.mjs +95 -0
  46. package/dist/PostgresKyselyMigrator-PI0QhvB1.mjs.map +1 -0
  47. package/dist/PostgresKyselyMigrator.cjs +3 -94
  48. package/dist/PostgresKyselyMigrator.d.cts +3 -80
  49. package/dist/PostgresKyselyMigrator.d.mts +3 -80
  50. package/dist/PostgresKyselyMigrator.mjs +3 -93
  51. package/dist/{PostgresMigrator-CDPnnwMJ.d.cts → PostgresMigrator-C_QQ6q35.d.mts} +5 -11
  52. package/dist/PostgresMigrator-C_QQ6q35.d.mts.map +1 -0
  53. package/dist/{PostgresMigrator-CDPnnwMJ.d.mts → PostgresMigrator-CeYy-eHF.d.cts} +5 -11
  54. package/dist/PostgresMigrator-CeYy-eHF.d.cts.map +1 -0
  55. package/dist/PostgresMigrator-DVAY04qN.mjs +166 -0
  56. package/dist/PostgresMigrator-DVAY04qN.mjs.map +1 -0
  57. package/dist/PostgresMigrator-M9jpzOvN.cjs +172 -0
  58. package/dist/PostgresMigrator-M9jpzOvN.cjs.map +1 -0
  59. package/dist/PostgresMigrator.cjs +2 -178
  60. package/dist/PostgresMigrator.d.cts +1 -1
  61. package/dist/PostgresMigrator.d.mts +1 -1
  62. package/dist/PostgresMigrator.mjs +2 -175
  63. package/dist/PostgresObjectionMigrator-1j6YIB1c.d.mts +79 -0
  64. package/dist/PostgresObjectionMigrator-1j6YIB1c.d.mts.map +1 -0
  65. package/dist/PostgresObjectionMigrator-DHVC9h_P.d.cts +79 -0
  66. package/dist/PostgresObjectionMigrator-DHVC9h_P.d.cts.map +1 -0
  67. package/dist/PostgresObjectionMigrator-DSaPhwjY.cjs +123 -0
  68. package/dist/PostgresObjectionMigrator-DSaPhwjY.cjs.map +1 -0
  69. package/dist/PostgresObjectionMigrator-DjPKdUbm.mjs +118 -0
  70. package/dist/PostgresObjectionMigrator-DjPKdUbm.mjs.map +1 -0
  71. package/dist/PostgresObjectionMigrator.cjs +3 -118
  72. package/dist/PostgresObjectionMigrator.d.cts +3 -75
  73. package/dist/PostgresObjectionMigrator.d.mts +3 -75
  74. package/dist/PostgresObjectionMigrator.mjs +3 -117
  75. package/dist/VitestKyselyTransactionIsolator-0CqOsuc9.cjs +65 -0
  76. package/dist/VitestKyselyTransactionIsolator-0CqOsuc9.cjs.map +1 -0
  77. package/dist/VitestKyselyTransactionIsolator-CduJlHoT.d.cts +59 -0
  78. package/dist/VitestKyselyTransactionIsolator-CduJlHoT.d.cts.map +1 -0
  79. package/dist/VitestKyselyTransactionIsolator-CfSMOFlN.mjs +60 -0
  80. package/dist/VitestKyselyTransactionIsolator-CfSMOFlN.mjs.map +1 -0
  81. package/dist/VitestKyselyTransactionIsolator-Cswnnj0k.d.mts +59 -0
  82. package/dist/VitestKyselyTransactionIsolator-Cswnnj0k.d.mts.map +1 -0
  83. package/dist/VitestKyselyTransactionIsolator.cjs +3 -66
  84. package/dist/VitestKyselyTransactionIsolator.d.cts +3 -60
  85. package/dist/VitestKyselyTransactionIsolator.d.mts +3 -60
  86. package/dist/VitestKyselyTransactionIsolator.mjs +3 -65
  87. package/dist/VitestObjectionTransactionIsolator-B5J9jjKq.cjs +68 -0
  88. package/dist/VitestObjectionTransactionIsolator-B5J9jjKq.cjs.map +1 -0
  89. package/dist/VitestObjectionTransactionIsolator-BXoR6xdG.d.cts +60 -0
  90. package/dist/VitestObjectionTransactionIsolator-BXoR6xdG.d.cts.map +1 -0
  91. package/dist/VitestObjectionTransactionIsolator-CNo40EdC.mjs +63 -0
  92. package/dist/VitestObjectionTransactionIsolator-CNo40EdC.mjs.map +1 -0
  93. package/dist/VitestObjectionTransactionIsolator-x6hY5j4u.d.mts +60 -0
  94. package/dist/VitestObjectionTransactionIsolator-x6hY5j4u.d.mts.map +1 -0
  95. package/dist/VitestObjectionTransactionIsolator.cjs +3 -62
  96. package/dist/VitestObjectionTransactionIsolator.d.cts +3 -56
  97. package/dist/VitestObjectionTransactionIsolator.d.mts +3 -56
  98. package/dist/VitestObjectionTransactionIsolator.mjs +3 -61
  99. package/dist/VitestTransactionIsolator-BNWJqh9f.d.mts +207 -0
  100. package/dist/VitestTransactionIsolator-BNWJqh9f.d.mts.map +1 -0
  101. package/dist/VitestTransactionIsolator-CSroc7Df.d.cts +207 -0
  102. package/dist/VitestTransactionIsolator-CSroc7Df.d.cts.map +1 -0
  103. package/dist/VitestTransactionIsolator-CtZaOUjH.cjs +193 -0
  104. package/dist/VitestTransactionIsolator-CtZaOUjH.cjs.map +1 -0
  105. package/dist/VitestTransactionIsolator-D6ZxLWys.mjs +175 -0
  106. package/dist/VitestTransactionIsolator-D6ZxLWys.mjs.map +1 -0
  107. package/dist/VitestTransactionIsolator.cjs +4 -187
  108. package/dist/VitestTransactionIsolator.d.cts +2 -219
  109. package/dist/VitestTransactionIsolator.d.mts +2 -219
  110. package/dist/VitestTransactionIsolator.mjs +2 -184
  111. package/dist/aws.cjs +4 -3
  112. package/dist/aws.cjs.map +1 -1
  113. package/dist/aws.d.cts +8 -3
  114. package/dist/aws.d.cts.map +1 -1
  115. package/dist/aws.d.mts +8 -3
  116. package/dist/aws.d.mts.map +1 -1
  117. package/dist/aws.mjs +2 -1
  118. package/dist/aws.mjs.map +1 -1
  119. package/dist/benchmark.cjs +2 -2
  120. package/dist/benchmark.cjs.map +1 -1
  121. package/dist/benchmark.d.cts +6 -4
  122. package/dist/benchmark.d.cts.map +1 -1
  123. package/dist/benchmark.d.mts +6 -4
  124. package/dist/benchmark.d.mts.map +1 -1
  125. package/dist/benchmark.mjs +1 -1
  126. package/dist/benchmark.mjs.map +1 -1
  127. package/dist/better-auth.cjs +15 -31
  128. package/dist/better-auth.cjs.map +1 -1
  129. package/dist/better-auth.d.cts +4 -13142
  130. package/dist/better-auth.d.cts.map +1 -1
  131. package/dist/better-auth.d.mts +4 -13142
  132. package/dist/better-auth.d.mts.map +1 -1
  133. package/dist/better-auth.mjs +13 -29
  134. package/dist/better-auth.mjs.map +1 -1
  135. package/dist/{rolldown-runtime-VH7oDXx4.cjs → chunk-CUT6urMc.cjs} +10 -8
  136. package/dist/directory-Bpz5c5pj.d.cts +13 -0
  137. package/dist/directory-Bpz5c5pj.d.cts.map +1 -0
  138. package/dist/directory-BxjqmtCT.mjs +27 -0
  139. package/dist/directory-BxjqmtCT.mjs.map +1 -0
  140. package/dist/directory-CVrfTq1I.d.mts +13 -0
  141. package/dist/directory-CVrfTq1I.d.mts.map +1 -0
  142. package/dist/directory-DD_xQoSh.cjs +33 -0
  143. package/dist/directory-DD_xQoSh.cjs.map +1 -0
  144. package/dist/faker-B14IEMIN.cjs +304 -0
  145. package/dist/faker-B14IEMIN.cjs.map +1 -0
  146. package/dist/faker-BGKYFoCT.mjs +262 -0
  147. package/dist/faker-BGKYFoCT.mjs.map +1 -0
  148. package/dist/faker-Cg76aFNO.d.cts +166 -0
  149. package/dist/faker-Cg76aFNO.d.cts.map +1 -0
  150. package/dist/faker-DHh7xs4u.d.mts +166 -0
  151. package/dist/faker-DHh7xs4u.d.mts.map +1 -0
  152. package/dist/faker.cjs +8 -313
  153. package/dist/faker.d.cts +2 -169
  154. package/dist/faker.d.mts +2 -169
  155. package/dist/faker.mjs +2 -305
  156. package/dist/helpers.cjs +5 -6
  157. package/dist/helpers.cjs.map +1 -1
  158. package/dist/helpers.d.cts +5 -1
  159. package/dist/helpers.d.cts.map +1 -1
  160. package/dist/helpers.d.mts +5 -1
  161. package/dist/helpers.d.mts.map +1 -1
  162. package/dist/helpers.mjs +2 -1
  163. package/dist/helpers.mjs.map +1 -1
  164. package/dist/initScript.cjs +15 -15
  165. package/dist/initScript.cjs.map +1 -1
  166. package/dist/initScript.d.cts +4 -2
  167. package/dist/initScript.d.cts.map +1 -1
  168. package/dist/initScript.d.mts +4 -2
  169. package/dist/initScript.d.mts.map +1 -1
  170. package/dist/initScript.mjs +12 -10
  171. package/dist/initScript.mjs.map +1 -1
  172. package/dist/kysely.cjs +13 -10
  173. package/dist/kysely.cjs.map +1 -1
  174. package/dist/kysely.d.cts +14 -10
  175. package/dist/kysely.d.cts.map +1 -1
  176. package/dist/kysely.d.mts +14 -10
  177. package/dist/kysely.d.mts.map +1 -1
  178. package/dist/kysely.mjs +14 -10
  179. package/dist/kysely.mjs.map +1 -1
  180. package/dist/logger.cjs +4 -3
  181. package/dist/logger.cjs.map +1 -1
  182. package/dist/logger.d.cts +5 -1
  183. package/dist/logger.d.cts.map +1 -1
  184. package/dist/logger.d.mts +5 -1
  185. package/dist/logger.d.mts.map +1 -1
  186. package/dist/logger.mjs +2 -1
  187. package/dist/logger.mjs.map +1 -1
  188. package/dist/objection.cjs +13 -10
  189. package/dist/objection.cjs.map +1 -1
  190. package/dist/objection.d.cts +14 -10
  191. package/dist/objection.d.cts.map +1 -1
  192. package/dist/objection.d.mts +14 -10
  193. package/dist/objection.d.mts.map +1 -1
  194. package/dist/objection.mjs +14 -10
  195. package/dist/objection.mjs.map +1 -1
  196. package/dist/os/directory.cjs +2 -31
  197. package/dist/os/directory.d.cts +2 -9
  198. package/dist/os/directory.d.mts +2 -9
  199. package/dist/os/directory.mjs +2 -25
  200. package/dist/os/index.cjs +3 -3
  201. package/dist/os/index.d.cts +1 -1
  202. package/dist/os/index.d.mts +1 -1
  203. package/dist/os/index.mjs +3 -2
  204. package/dist/requestContext.cjs +11 -10
  205. package/dist/requestContext.cjs.map +1 -1
  206. package/dist/requestContext.d.cts +9 -5
  207. package/dist/requestContext.d.cts.map +1 -1
  208. package/dist/requestContext.d.mts +9 -5
  209. package/dist/requestContext.d.mts.map +1 -1
  210. package/dist/requestContext.mjs +3 -2
  211. package/dist/requestContext.mjs.map +1 -1
  212. package/dist/timer.cjs +2 -2
  213. package/dist/timer.cjs.map +1 -1
  214. package/dist/timer.d.cts +4 -1
  215. package/dist/timer.d.cts.map +1 -1
  216. package/dist/timer.d.mts +4 -1
  217. package/dist/timer.d.mts.map +1 -1
  218. package/dist/timer.mjs +1 -1
  219. package/dist/timer.mjs.map +1 -1
  220. package/package.json +25 -65
  221. package/src/Factory.ts +174 -0
  222. package/src/KyselyFactory.ts +391 -0
  223. package/src/ObjectionFactory.ts +412 -0
  224. package/src/PostgresKyselyMigrator.ts +104 -0
  225. package/src/PostgresMigrator.ts +193 -0
  226. package/src/PostgresObjectionMigrator.ts +138 -0
  227. package/src/VitestKyselyTransactionIsolator.ts +72 -0
  228. package/src/VitestObjectionTransactionIsolator.ts +75 -0
  229. package/src/VitestTransactionIsolator.ts +348 -0
  230. package/src/__tests__/Factory.spec.ts +178 -0
  231. package/src/__tests__/KyselyFactory.spec.ts +458 -0
  232. package/src/__tests__/ObjectionFactory.spec.ts +586 -0
  233. package/src/__tests__/PostgresKyselyMigrator.spec.ts +794 -0
  234. package/src/__tests__/PostgresMigrator.spec.ts +471 -0
  235. package/src/__tests__/PostgresObjectionMigrator.spec.ts +634 -0
  236. package/src/__tests__/VitestObjectionTransactionIsolator.spec.ts +138 -0
  237. package/src/__tests__/benchmark.spec.ts +140 -0
  238. package/src/__tests__/better-auth.spec.ts +21 -0
  239. package/src/__tests__/faker.spec.ts +231 -0
  240. package/src/__tests__/initScript.spec.ts +332 -0
  241. package/src/__tests__/integration.spec.ts +610 -0
  242. package/src/__tests__/requestContext.spec.ts +113 -0
  243. package/src/__tests__/utilities.spec.ts +211 -0
  244. package/src/aws.ts +131 -0
  245. package/src/benchmark.ts +48 -0
  246. package/src/better-auth.ts +310 -0
  247. package/src/faker.ts +349 -0
  248. package/src/helpers.ts +45 -0
  249. package/src/initScript.ts +122 -0
  250. package/src/kysely.ts +166 -0
  251. package/src/logger.ts +18 -0
  252. package/src/objection.ts +157 -0
  253. package/src/os/directory.ts +26 -0
  254. package/src/os/index.ts +1 -0
  255. package/src/requestContext.ts +119 -0
  256. package/src/timer.ts +3 -0
  257. package/test/globalSetup.ts +54 -0
  258. package/test/helpers.ts +268 -0
  259. package/test/migrations/1749664623372_user.ts +22 -0
  260. package/tsconfig.json +9 -0
  261. package/vitest.config.ts +8 -0
  262. package/dist/Factory.cjs.map +0 -1
  263. package/dist/Factory.d.cts.map +0 -1
  264. package/dist/Factory.d.mts.map +0 -1
  265. package/dist/Factory.mjs.map +0 -1
  266. package/dist/KyselyFactory.cjs.map +0 -1
  267. package/dist/KyselyFactory.d.cts.map +0 -1
  268. package/dist/KyselyFactory.d.mts.map +0 -1
  269. package/dist/KyselyFactory.mjs.map +0 -1
  270. package/dist/ObjectionFactory.cjs.map +0 -1
  271. package/dist/ObjectionFactory.d.cts.map +0 -1
  272. package/dist/ObjectionFactory.d.mts.map +0 -1
  273. package/dist/ObjectionFactory.mjs.map +0 -1
  274. package/dist/PostgresKyselyMigrator.cjs.map +0 -1
  275. package/dist/PostgresKyselyMigrator.d.cts.map +0 -1
  276. package/dist/PostgresKyselyMigrator.d.mts.map +0 -1
  277. package/dist/PostgresKyselyMigrator.mjs.map +0 -1
  278. package/dist/PostgresMigrator-CDPnnwMJ.d.cts.map +0 -1
  279. package/dist/PostgresMigrator-CDPnnwMJ.d.mts.map +0 -1
  280. package/dist/PostgresMigrator.cjs.map +0 -1
  281. package/dist/PostgresMigrator.mjs.map +0 -1
  282. package/dist/PostgresObjectionMigrator.cjs.map +0 -1
  283. package/dist/PostgresObjectionMigrator.d.cts.map +0 -1
  284. package/dist/PostgresObjectionMigrator.d.mts.map +0 -1
  285. package/dist/PostgresObjectionMigrator.mjs.map +0 -1
  286. package/dist/VitestKyselyTransactionIsolator.cjs.map +0 -1
  287. package/dist/VitestKyselyTransactionIsolator.d.cts.map +0 -1
  288. package/dist/VitestKyselyTransactionIsolator.d.mts.map +0 -1
  289. package/dist/VitestKyselyTransactionIsolator.mjs.map +0 -1
  290. package/dist/VitestObjectionTransactionIsolator.cjs.map +0 -1
  291. package/dist/VitestObjectionTransactionIsolator.d.cts.map +0 -1
  292. package/dist/VitestObjectionTransactionIsolator.d.mts.map +0 -1
  293. package/dist/VitestObjectionTransactionIsolator.mjs.map +0 -1
  294. package/dist/VitestTransactionIsolator.cjs.map +0 -1
  295. package/dist/VitestTransactionIsolator.d.cts.map +0 -1
  296. package/dist/VitestTransactionIsolator.d.mts.map +0 -1
  297. package/dist/VitestTransactionIsolator.mjs.map +0 -1
  298. package/dist/browser.cjs +0 -149
  299. package/dist/browser.cjs.map +0 -1
  300. package/dist/browser.d.cts +0 -62
  301. package/dist/browser.d.cts.map +0 -1
  302. package/dist/browser.d.mts +0 -62
  303. package/dist/browser.d.mts.map +0 -1
  304. package/dist/browser.mjs +0 -147
  305. package/dist/browser.mjs.map +0 -1
  306. package/dist/context.cjs +0 -80
  307. package/dist/context.cjs.map +0 -1
  308. package/dist/context.d.cts +0 -55
  309. package/dist/context.d.cts.map +0 -1
  310. package/dist/context.d.mts +0 -55
  311. package/dist/context.d.mts.map +0 -1
  312. package/dist/context.mjs +0 -73
  313. package/dist/context.mjs.map +0 -1
  314. package/dist/faker.cjs.map +0 -1
  315. package/dist/faker.d.cts.map +0 -1
  316. package/dist/faker.d.mts.map +0 -1
  317. package/dist/faker.mjs.map +0 -1
  318. package/dist/mailbox.cjs +0 -95
  319. package/dist/mailbox.cjs.map +0 -1
  320. package/dist/mailbox.d.cts +0 -58
  321. package/dist/mailbox.d.cts.map +0 -1
  322. package/dist/mailbox.d.mts +0 -58
  323. package/dist/mailbox.d.mts.map +0 -1
  324. package/dist/mailbox.mjs +0 -92
  325. package/dist/mailbox.mjs.map +0 -1
  326. package/dist/os/directory.cjs.map +0 -1
  327. package/dist/os/directory.d.cts.map +0 -1
  328. package/dist/os/directory.d.mts.map +0 -1
  329. package/dist/os/directory.mjs.map +0 -1
  330. package/dist/transactions.cjs +0 -239
  331. package/dist/transactions.cjs.map +0 -1
  332. package/dist/transactions.d.cts +0 -44
  333. package/dist/transactions.d.cts.map +0 -1
  334. package/dist/transactions.d.mts +0 -44
  335. package/dist/transactions.d.mts.map +0 -1
  336. package/dist/transactions.mjs +0 -234
  337. package/dist/transactions.mjs.map +0 -1
@@ -0,0 +1,147 @@
1
+ import { FakerFactory } from "./faker-DHh7xs4u.mjs";
2
+
3
+ //#region src/Factory.d.ts
4
+
5
+ /**
6
+ * Abstract base class for database factories used in testing.
7
+ * Provides a standardized interface for creating test data using builder and seed patterns.
8
+ *
9
+ * @template Builders - Record of builder functions for creating individual entities
10
+ * @template Seeds - Record of seed functions for creating complex test scenarios
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * // Define builders for creating individual records
15
+ * const builders = {
16
+ * user: (attrs) => ({ name: 'Test User', email: 'test@example.com', ...attrs }),
17
+ * post: (attrs) => ({ title: 'Test Post', content: 'Content', ...attrs })
18
+ * };
19
+ *
20
+ * // Define seeds for complex scenarios
21
+ * const seeds = {
22
+ * userWithPosts: async (attrs, factory) => {
23
+ * const user = await factory.insert('user', attrs);
24
+ * await factory.insertMany(3, 'post', { userId: user.id });
25
+ * return user;
26
+ * }
27
+ * };
28
+ * ```
29
+ */
30
+ declare abstract class Factory<Builders extends Record<string, any>, Seeds extends Record<string, any>> {
31
+ /**
32
+ * Creates a typed seed function with proper type inference.
33
+ * This is a utility method to help with TypeScript type checking when defining seeds.
34
+ *
35
+ * @template Seed - The seed function type
36
+ * @param seedFn - The seed function to wrap
37
+ * @returns The same seed function with proper typing
38
+ *
39
+ * @example
40
+ * ```typescript
41
+ * const userWithPostsSeed = Factory.createSeed(async ({ attrs, factory, db }) => {
42
+ * const user = await factory.insert('user', attrs);
43
+ * return user;
44
+ * });
45
+ * ```
46
+ */
47
+ static createSeed<Seed extends FactorySeed>(seedFn: Seed): Seed;
48
+ /**
49
+ * Inserts an object into the database using a builder function.
50
+ *
51
+ * @param builderName - The name of the builder to use
52
+ * @param attrs - The attributes to insert
53
+ */
54
+ abstract insert<K extends keyof Builders>(builderName: K, attrs?: Parameters<Builders[K]>[0]): Promise<Awaited<ReturnType<Builders[K]>>>;
55
+ /**
56
+ * Inserts multiple objects into the database
57
+ *
58
+ * @param count - Number of objects to insert
59
+ * @param builderName - The name of the builder to use
60
+ * @param attrs - The attributes to insert
61
+ */
62
+ abstract insertMany<K extends keyof Builders>(count: number, builderName: K, attrs?: Parameters<Builders[K]>[0] | ((idx: number, faker: FakerFactory) => Promise<Parameters<Builders[K]>[0]>)): Promise<Awaited<ReturnType<Builders[K]>>[]>;
63
+ /**
64
+ * Seeds the database using a seed function.
65
+ *
66
+ * @param seedName - The name of the seed to use
67
+ * @returns The result of the seed function
68
+ * @param attrs - The attributes to pass to the seed function
69
+ */
70
+ abstract seed<K extends keyof Seeds>(seedName: K, attrs?: ExtractSeedAttrs<Seeds[K]>): ReturnType<Seeds[K]>;
71
+ }
72
+ /**
73
+ * Type definition for a factory builder function that can work with different database types.
74
+ * Builders are responsible for creating individual database records with default values and relationships.
75
+ *
76
+ * @template Attrs - The attributes/input type for the builder
77
+ * @template Factory - The factory instance type
78
+ * @template Result - The type of object returned by the builder
79
+ * @template DB - The database connection type (Kysely, Knex, etc.)
80
+ *
81
+ * @param attrs - Partial attributes to override defaults
82
+ * @param factory - The factory instance for creating related records
83
+ * @param db - The database connection
84
+ * @returns The created record or a promise resolving to it
85
+ *
86
+ * @example
87
+ * ```typescript
88
+ * const userBuilder: MixedFactoryBuilder<UserAttrs, Factory, User, Kysely<DB>> =
89
+ * async (attrs, factory, db) => {
90
+ * return {
91
+ * id: faker.string.uuid(),
92
+ * name: faker.person.fullName(),
93
+ * email: faker.internet.email(),
94
+ * ...attrs
95
+ * };
96
+ * };
97
+ * ```
98
+ */
99
+ type MixedFactoryBuilder<Attrs = any, Factory = any, Result = any, DB = any> = (attrs: Attrs, factory: Factory, db: DB) => Result | Promise<Result>;
100
+ /**
101
+ * Type definition for a factory seed function used to create complex test scenarios.
102
+ * Seeds typically create multiple related records to set up a complete test environment.
103
+ *
104
+ * @template Attrs - The attributes/input type for the seed
105
+ * @template Factory - The factory instance type
106
+ * @template Result - The type of object returned by the seed
107
+ * @template DB - The database connection type (Kysely, Knex, etc.)
108
+ *
109
+ * @param context - Object containing attrs, factory, and db
110
+ * @param context.attrs - Configuration attributes for the seed
111
+ * @param context.factory - The factory instance for creating records
112
+ * @param context.db - The database connection
113
+ * @returns A promise resolving to the seed result
114
+ *
115
+ * @example
116
+ * ```typescript
117
+ * const userWithPostsSeed: FactorySeed<{ postCount?: number }, Factory, User, DB> =
118
+ * async ({ attrs, factory, db }) => {
119
+ * const user = await factory.insert('user', attrs);
120
+ * const postCount = attrs.postCount || 3;
121
+ *
122
+ * for (let i = 0; i < postCount; i++) {
123
+ * await factory.insert('post', { userId: user.id });
124
+ * }
125
+ *
126
+ * return user;
127
+ * };
128
+ * ```
129
+ */
130
+ type FactorySeed<Attrs = any, Factory = any, Result = any, DB = any> = (context: {
131
+ attrs: Attrs;
132
+ factory: Factory;
133
+ db: DB;
134
+ }) => Promise<Result>;
135
+ /**
136
+ * Helper type to extract the Attrs type from a FactorySeed function.
137
+ * Used internally by Factory implementations to correctly type the seed method parameters.
138
+ */
139
+ type ExtractSeedAttrs<T> = T extends ((context: {
140
+ attrs: infer A;
141
+ factory: any;
142
+ db: any;
143
+ }) => any) ? A : never;
144
+ //# sourceMappingURL=Factory.d.ts.map
145
+ //#endregion
146
+ export { ExtractSeedAttrs, Factory, FactorySeed, MixedFactoryBuilder };
147
+ //# sourceMappingURL=Factory-SFupxRC2.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Factory-SFupxRC2.d.mts","names":[],"sources":["../src/Factory.ts"],"sourcesContent":[],"mappings":";;;;;;AA2BA;;;;;;;;;;;;;;;;;;;;;;;AAiD6B,uBAjDP,OAiDO,CAAA,iBAhDX,MAgDW,CAAA,MAAA,EAAA,GAAA,CAAA,EAAA,cA/Cd,MA+Cc,CAAA,MAAA,EAAA,GAAA,CAAA,CAAA,CAAA;EAAQ;;;;;;;;;;;;;;;;EAavB,OAAA,UAAA,CAAA,aA1CkB,WA0ClB,CAAA,CAAA,MAAA,EA1CuC,IA0CvC,CAAA,EA1C8C,IA0C9C;EA8BF;;;;;;EAK0C,SAAW,MAAA,CAAA,UAAA,MApEhC,QAoEgC,CAAA,CAAA,WAAA,EAnElD,CAmEkD,EAAA,KAAA,CAAA,EAlEvD,UAkEuD,CAlE5C,QAkE4C,CAlEnC,CAkEmC,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAjE7D,OAiE6D,CAjErD,OAiEqD,CAjE7C,UAiE6C,CAjElC,QAiEkC,CAjEzB,CAiEyB,CAAA,CAAA,CAAA,CAAA;EAAM;AAAP;AAgChE;;;;;EAKsD,SAAe,UAAA,CAAA,UAAA,MA7FhC,QA6FgC,CAAA,CAAA,KAAA,EAAA,MAAA,EAAA,WAAA,EA3FtD,CA2FsD,EAAA,KAAA,CAAA,EAzFhE,UAyFgE,CAzFrD,QAyFqD,CAzF5C,CAyF4C,CAAA,CAAA,CAAA,CAAA,CAAA,GAAA,CAAA,CAAA,GAAA,EAAA,MAAA,EAAA,KAAA,EAtFzD,YAsFyD,EAAA,GArF3D,OAqF2D,CArFnD,UAqFmD,CArFxC,QAqFwC,CArF/B,CAqF+B,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EApFjE,OAoFiE,CApFzD,OAoFyD,CApFjD,UAoFiD,CApFtC,QAoFsC,CApF7B,CAoF6B,CAAA,CAAA,CAAA,EAAA,CAAA;EAAM;AAAP;AAMpE;;;;AAKI;gCAtF2B,iBACnB,WACF,iBAAiB,MAAM,MAC7B,WAAW,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA8BT,kFAKA,gBAAgB,aAAa,OAAO,SAAS,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAgCrD;SAKW;WAAgB;MAAa;MAAS,QAAQ;;;;;KAMzD,sBAAsB;;;;aAK/B"}
package/dist/Factory.cjs CHANGED
@@ -1,52 +1,3 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- //#region src/Factory.ts
3
- /**
4
- * Abstract base class for database factories used in testing.
5
- * Provides a standardized interface for creating test data using builder and seed patterns.
6
- *
7
- * @template Builders - Record of builder functions for creating individual entities
8
- * @template Seeds - Record of seed functions for creating complex test scenarios
9
- *
10
- * @example
11
- * ```typescript
12
- * // Define builders for creating individual records
13
- * const builders = {
14
- * user: (attrs) => ({ name: 'Test User', email: 'test@example.com', ...attrs }),
15
- * post: (attrs) => ({ title: 'Test Post', content: 'Content', ...attrs })
16
- * };
17
- *
18
- * // Define seeds for complex scenarios
19
- * const seeds = {
20
- * userWithPosts: async (attrs, factory) => {
21
- * const user = await factory.insert('user', attrs);
22
- * await factory.insertMany(3, 'post', { userId: user.id });
23
- * return user;
24
- * }
25
- * };
26
- * ```
27
- */
28
- var Factory = class {
29
- /**
30
- * Creates a typed seed function with proper type inference.
31
- * This is a utility method to help with TypeScript type checking when defining seeds.
32
- *
33
- * @template Seed - The seed function type
34
- * @param seedFn - The seed function to wrap
35
- * @returns The same seed function with proper typing
36
- *
37
- * @example
38
- * ```typescript
39
- * const userWithPostsSeed = Factory.createSeed(async ({ attrs, factory, db }) => {
40
- * const user = await factory.insert('user', attrs);
41
- * return user;
42
- * });
43
- * ```
44
- */
45
- static createSeed(seedFn) {
46
- return seedFn;
47
- }
48
- };
49
- //#endregion
50
- exports.Factory = Factory;
1
+ const require_Factory = require('./Factory-BhjUOBWN.cjs');
51
2
 
52
- //# sourceMappingURL=Factory.cjs.map
3
+ exports.Factory = require_Factory.Factory;
@@ -1,143 +1,3 @@
1
- import { FakerFactory } from "./faker.cjs";
2
- //#region src/Factory.d.ts
3
- /**
4
- * Abstract base class for database factories used in testing.
5
- * Provides a standardized interface for creating test data using builder and seed patterns.
6
- *
7
- * @template Builders - Record of builder functions for creating individual entities
8
- * @template Seeds - Record of seed functions for creating complex test scenarios
9
- *
10
- * @example
11
- * ```typescript
12
- * // Define builders for creating individual records
13
- * const builders = {
14
- * user: (attrs) => ({ name: 'Test User', email: 'test@example.com', ...attrs }),
15
- * post: (attrs) => ({ title: 'Test Post', content: 'Content', ...attrs })
16
- * };
17
- *
18
- * // Define seeds for complex scenarios
19
- * const seeds = {
20
- * userWithPosts: async (attrs, factory) => {
21
- * const user = await factory.insert('user', attrs);
22
- * await factory.insertMany(3, 'post', { userId: user.id });
23
- * return user;
24
- * }
25
- * };
26
- * ```
27
- */
28
- export declare abstract class Factory<Builders extends Record<string, any>, Seeds extends Record<string, any>> {
29
- /**
30
- * Creates a typed seed function with proper type inference.
31
- * This is a utility method to help with TypeScript type checking when defining seeds.
32
- *
33
- * @template Seed - The seed function type
34
- * @param seedFn - The seed function to wrap
35
- * @returns The same seed function with proper typing
36
- *
37
- * @example
38
- * ```typescript
39
- * const userWithPostsSeed = Factory.createSeed(async ({ attrs, factory, db }) => {
40
- * const user = await factory.insert('user', attrs);
41
- * return user;
42
- * });
43
- * ```
44
- */
45
- static createSeed<Seed extends FactorySeed>(seedFn: Seed): Seed;
46
- /**
47
- * Inserts an object into the database using a builder function.
48
- *
49
- * @param builderName - The name of the builder to use
50
- * @param attrs - The attributes to insert
51
- */
52
- abstract insert<K extends keyof Builders>(builderName: K, attrs?: Parameters<Builders[K]>[0]): Promise<Awaited<ReturnType<Builders[K]>>>;
53
- /**
54
- * Inserts multiple objects into the database
55
- *
56
- * @param count - Number of objects to insert
57
- * @param builderName - The name of the builder to use
58
- * @param attrs - The attributes to insert
59
- */
60
- abstract insertMany<K extends keyof Builders>(count: number, builderName: K, attrs?: Parameters<Builders[K]>[0] | ((idx: number, faker: FakerFactory) => Promise<Parameters<Builders[K]>[0]>)): Promise<Awaited<ReturnType<Builders[K]>>[]>;
61
- /**
62
- * Seeds the database using a seed function.
63
- *
64
- * @param seedName - The name of the seed to use
65
- * @returns The result of the seed function
66
- * @param attrs - The attributes to pass to the seed function
67
- */
68
- abstract seed<K extends keyof Seeds>(seedName: K, attrs?: ExtractSeedAttrs<Seeds[K]>): ReturnType<Seeds[K]>;
69
- }
70
- /**
71
- * Type definition for a factory builder function that can work with different database types.
72
- * Builders are responsible for creating individual database records with default values and relationships.
73
- *
74
- * @template Attrs - The attributes/input type for the builder
75
- * @template Factory - The factory instance type
76
- * @template Result - The type of object returned by the builder
77
- * @template DB - The database connection type (Kysely, Knex, etc.)
78
- *
79
- * @param attrs - Partial attributes to override defaults
80
- * @param factory - The factory instance for creating related records
81
- * @param db - The database connection
82
- * @returns The created record or a promise resolving to it
83
- *
84
- * @example
85
- * ```typescript
86
- * const userBuilder: MixedFactoryBuilder<UserAttrs, Factory, User, Kysely<DB>> =
87
- * async (attrs, factory, db) => {
88
- * return {
89
- * id: faker.string.uuid(),
90
- * name: faker.person.fullName(),
91
- * email: faker.internet.email(),
92
- * ...attrs
93
- * };
94
- * };
95
- * ```
96
- */
97
- export type MixedFactoryBuilder<Attrs = any, Factory = any, Result = any, DB = any> = (attrs: Attrs, factory: Factory, db: DB) => Result | Promise<Result>;
98
- /**
99
- * Type definition for a factory seed function used to create complex test scenarios.
100
- * Seeds typically create multiple related records to set up a complete test environment.
101
- *
102
- * @template Attrs - The attributes/input type for the seed
103
- * @template Factory - The factory instance type
104
- * @template Result - The type of object returned by the seed
105
- * @template DB - The database connection type (Kysely, Knex, etc.)
106
- *
107
- * @param context - Object containing attrs, factory, and db
108
- * @param context.attrs - Configuration attributes for the seed
109
- * @param context.factory - The factory instance for creating records
110
- * @param context.db - The database connection
111
- * @returns A promise resolving to the seed result
112
- *
113
- * @example
114
- * ```typescript
115
- * const userWithPostsSeed: FactorySeed<{ postCount?: number }, Factory, User, DB> =
116
- * async ({ attrs, factory, db }) => {
117
- * const user = await factory.insert('user', attrs);
118
- * const postCount = attrs.postCount || 3;
119
- *
120
- * for (let i = 0; i < postCount; i++) {
121
- * await factory.insert('post', { userId: user.id });
122
- * }
123
- *
124
- * return user;
125
- * };
126
- * ```
127
- */
128
- export type FactorySeed<Attrs = any, Factory = any, Result = any, DB = any> = (context: {
129
- attrs: Attrs;
130
- factory: Factory;
131
- db: DB;
132
- }) => Promise<Result>;
133
- /**
134
- * Helper type to extract the Attrs type from a FactorySeed function.
135
- * Used internally by Factory implementations to correctly type the seed method parameters.
136
- */
137
- export type ExtractSeedAttrs<T> = T extends ((context: {
138
- attrs: infer A;
139
- factory: any;
140
- db: any;
141
- }) => any) ? A : never;
142
- //#endregion
143
- //# sourceMappingURL=Factory.d.cts.map
1
+ import "./faker-Cg76aFNO.cjs";
2
+ import { ExtractSeedAttrs, Factory, FactorySeed, MixedFactoryBuilder } from "./Factory-BOX312yd.cjs";
3
+ export { ExtractSeedAttrs, Factory, FactorySeed, MixedFactoryBuilder };
@@ -1,143 +1,3 @@
1
- import { FakerFactory } from "./faker.mjs";
2
- //#region src/Factory.d.ts
3
- /**
4
- * Abstract base class for database factories used in testing.
5
- * Provides a standardized interface for creating test data using builder and seed patterns.
6
- *
7
- * @template Builders - Record of builder functions for creating individual entities
8
- * @template Seeds - Record of seed functions for creating complex test scenarios
9
- *
10
- * @example
11
- * ```typescript
12
- * // Define builders for creating individual records
13
- * const builders = {
14
- * user: (attrs) => ({ name: 'Test User', email: 'test@example.com', ...attrs }),
15
- * post: (attrs) => ({ title: 'Test Post', content: 'Content', ...attrs })
16
- * };
17
- *
18
- * // Define seeds for complex scenarios
19
- * const seeds = {
20
- * userWithPosts: async (attrs, factory) => {
21
- * const user = await factory.insert('user', attrs);
22
- * await factory.insertMany(3, 'post', { userId: user.id });
23
- * return user;
24
- * }
25
- * };
26
- * ```
27
- */
28
- export declare abstract class Factory<Builders extends Record<string, any>, Seeds extends Record<string, any>> {
29
- /**
30
- * Creates a typed seed function with proper type inference.
31
- * This is a utility method to help with TypeScript type checking when defining seeds.
32
- *
33
- * @template Seed - The seed function type
34
- * @param seedFn - The seed function to wrap
35
- * @returns The same seed function with proper typing
36
- *
37
- * @example
38
- * ```typescript
39
- * const userWithPostsSeed = Factory.createSeed(async ({ attrs, factory, db }) => {
40
- * const user = await factory.insert('user', attrs);
41
- * return user;
42
- * });
43
- * ```
44
- */
45
- static createSeed<Seed extends FactorySeed>(seedFn: Seed): Seed;
46
- /**
47
- * Inserts an object into the database using a builder function.
48
- *
49
- * @param builderName - The name of the builder to use
50
- * @param attrs - The attributes to insert
51
- */
52
- abstract insert<K extends keyof Builders>(builderName: K, attrs?: Parameters<Builders[K]>[0]): Promise<Awaited<ReturnType<Builders[K]>>>;
53
- /**
54
- * Inserts multiple objects into the database
55
- *
56
- * @param count - Number of objects to insert
57
- * @param builderName - The name of the builder to use
58
- * @param attrs - The attributes to insert
59
- */
60
- abstract insertMany<K extends keyof Builders>(count: number, builderName: K, attrs?: Parameters<Builders[K]>[0] | ((idx: number, faker: FakerFactory) => Promise<Parameters<Builders[K]>[0]>)): Promise<Awaited<ReturnType<Builders[K]>>[]>;
61
- /**
62
- * Seeds the database using a seed function.
63
- *
64
- * @param seedName - The name of the seed to use
65
- * @returns The result of the seed function
66
- * @param attrs - The attributes to pass to the seed function
67
- */
68
- abstract seed<K extends keyof Seeds>(seedName: K, attrs?: ExtractSeedAttrs<Seeds[K]>): ReturnType<Seeds[K]>;
69
- }
70
- /**
71
- * Type definition for a factory builder function that can work with different database types.
72
- * Builders are responsible for creating individual database records with default values and relationships.
73
- *
74
- * @template Attrs - The attributes/input type for the builder
75
- * @template Factory - The factory instance type
76
- * @template Result - The type of object returned by the builder
77
- * @template DB - The database connection type (Kysely, Knex, etc.)
78
- *
79
- * @param attrs - Partial attributes to override defaults
80
- * @param factory - The factory instance for creating related records
81
- * @param db - The database connection
82
- * @returns The created record or a promise resolving to it
83
- *
84
- * @example
85
- * ```typescript
86
- * const userBuilder: MixedFactoryBuilder<UserAttrs, Factory, User, Kysely<DB>> =
87
- * async (attrs, factory, db) => {
88
- * return {
89
- * id: faker.string.uuid(),
90
- * name: faker.person.fullName(),
91
- * email: faker.internet.email(),
92
- * ...attrs
93
- * };
94
- * };
95
- * ```
96
- */
97
- export type MixedFactoryBuilder<Attrs = any, Factory = any, Result = any, DB = any> = (attrs: Attrs, factory: Factory, db: DB) => Result | Promise<Result>;
98
- /**
99
- * Type definition for a factory seed function used to create complex test scenarios.
100
- * Seeds typically create multiple related records to set up a complete test environment.
101
- *
102
- * @template Attrs - The attributes/input type for the seed
103
- * @template Factory - The factory instance type
104
- * @template Result - The type of object returned by the seed
105
- * @template DB - The database connection type (Kysely, Knex, etc.)
106
- *
107
- * @param context - Object containing attrs, factory, and db
108
- * @param context.attrs - Configuration attributes for the seed
109
- * @param context.factory - The factory instance for creating records
110
- * @param context.db - The database connection
111
- * @returns A promise resolving to the seed result
112
- *
113
- * @example
114
- * ```typescript
115
- * const userWithPostsSeed: FactorySeed<{ postCount?: number }, Factory, User, DB> =
116
- * async ({ attrs, factory, db }) => {
117
- * const user = await factory.insert('user', attrs);
118
- * const postCount = attrs.postCount || 3;
119
- *
120
- * for (let i = 0; i < postCount; i++) {
121
- * await factory.insert('post', { userId: user.id });
122
- * }
123
- *
124
- * return user;
125
- * };
126
- * ```
127
- */
128
- export type FactorySeed<Attrs = any, Factory = any, Result = any, DB = any> = (context: {
129
- attrs: Attrs;
130
- factory: Factory;
131
- db: DB;
132
- }) => Promise<Result>;
133
- /**
134
- * Helper type to extract the Attrs type from a FactorySeed function.
135
- * Used internally by Factory implementations to correctly type the seed method parameters.
136
- */
137
- export type ExtractSeedAttrs<T> = T extends ((context: {
138
- attrs: infer A;
139
- factory: any;
140
- db: any;
141
- }) => any) ? A : never;
142
- //#endregion
143
- //# sourceMappingURL=Factory.d.mts.map
1
+ import "./faker-DHh7xs4u.mjs";
2
+ import { ExtractSeedAttrs, Factory, FactorySeed, MixedFactoryBuilder } from "./Factory-SFupxRC2.mjs";
3
+ export { ExtractSeedAttrs, Factory, FactorySeed, MixedFactoryBuilder };
package/dist/Factory.mjs CHANGED
@@ -1,51 +1,3 @@
1
- //#region src/Factory.ts
2
- /**
3
- * Abstract base class for database factories used in testing.
4
- * Provides a standardized interface for creating test data using builder and seed patterns.
5
- *
6
- * @template Builders - Record of builder functions for creating individual entities
7
- * @template Seeds - Record of seed functions for creating complex test scenarios
8
- *
9
- * @example
10
- * ```typescript
11
- * // Define builders for creating individual records
12
- * const builders = {
13
- * user: (attrs) => ({ name: 'Test User', email: 'test@example.com', ...attrs }),
14
- * post: (attrs) => ({ title: 'Test Post', content: 'Content', ...attrs })
15
- * };
16
- *
17
- * // Define seeds for complex scenarios
18
- * const seeds = {
19
- * userWithPosts: async (attrs, factory) => {
20
- * const user = await factory.insert('user', attrs);
21
- * await factory.insertMany(3, 'post', { userId: user.id });
22
- * return user;
23
- * }
24
- * };
25
- * ```
26
- */
27
- var Factory = class {
28
- /**
29
- * Creates a typed seed function with proper type inference.
30
- * This is a utility method to help with TypeScript type checking when defining seeds.
31
- *
32
- * @template Seed - The seed function type
33
- * @param seedFn - The seed function to wrap
34
- * @returns The same seed function with proper typing
35
- *
36
- * @example
37
- * ```typescript
38
- * const userWithPostsSeed = Factory.createSeed(async ({ attrs, factory, db }) => {
39
- * const user = await factory.insert('user', attrs);
40
- * return user;
41
- * });
42
- * ```
43
- */
44
- static createSeed(seedFn) {
45
- return seedFn;
46
- }
47
- };
48
- //#endregion
49
- export { Factory };
1
+ import { Factory } from "./Factory-BFVnMMCC.mjs";
50
2
 
51
- //# sourceMappingURL=Factory.mjs.map
3
+ export { Factory };