@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.
- package/CHANGELOG.md +160 -0
- package/README.md +0 -74
- package/dist/Factory-BFVnMMCC.mjs +51 -0
- package/dist/Factory-BFVnMMCC.mjs.map +1 -0
- package/dist/Factory-BOX312yd.d.cts +147 -0
- package/dist/Factory-BOX312yd.d.cts.map +1 -0
- package/dist/Factory-BhjUOBWN.cjs +57 -0
- package/dist/Factory-BhjUOBWN.cjs.map +1 -0
- package/dist/Factory-SFupxRC2.d.mts +147 -0
- package/dist/Factory-SFupxRC2.d.mts.map +1 -0
- package/dist/Factory.cjs +2 -51
- package/dist/Factory.d.cts +3 -143
- package/dist/Factory.d.mts +3 -143
- package/dist/Factory.mjs +2 -50
- package/dist/KyselyFactory-BFqVIn_0.cjs +246 -0
- package/dist/KyselyFactory-BFqVIn_0.cjs.map +1 -0
- package/dist/KyselyFactory-DMswpwji.mjs +241 -0
- package/dist/KyselyFactory-DMswpwji.mjs.map +1 -0
- package/dist/KyselyFactory-Dy5zzV4B.d.cts +228 -0
- package/dist/KyselyFactory-Dy5zzV4B.d.cts.map +1 -0
- package/dist/KyselyFactory-vAxYodck.d.mts +228 -0
- package/dist/KyselyFactory-vAxYodck.d.mts.map +1 -0
- package/dist/KyselyFactory.cjs +4 -237
- package/dist/KyselyFactory.d.cts +4 -224
- package/dist/KyselyFactory.d.mts +4 -224
- package/dist/KyselyFactory.mjs +4 -236
- package/dist/ObjectionFactory-BWjB49-i.d.mts +241 -0
- package/dist/ObjectionFactory-BWjB49-i.d.mts.map +1 -0
- package/dist/ObjectionFactory-BeFBYcan.cjs +272 -0
- package/dist/ObjectionFactory-BeFBYcan.cjs.map +1 -0
- package/dist/ObjectionFactory-CD-WFuMJ.d.cts +241 -0
- package/dist/ObjectionFactory-CD-WFuMJ.d.cts.map +1 -0
- package/dist/ObjectionFactory-QCJ7u0Ql.mjs +267 -0
- package/dist/ObjectionFactory-QCJ7u0Ql.mjs.map +1 -0
- package/dist/ObjectionFactory.cjs +4 -265
- package/dist/ObjectionFactory.d.cts +4 -237
- package/dist/ObjectionFactory.d.mts +4 -237
- package/dist/ObjectionFactory.mjs +4 -264
- package/dist/PostgresKyselyMigrator-B2M6Gjvv.d.cts +84 -0
- package/dist/PostgresKyselyMigrator-B2M6Gjvv.d.cts.map +1 -0
- package/dist/PostgresKyselyMigrator-BGBxjnFv.cjs +101 -0
- package/dist/PostgresKyselyMigrator-BGBxjnFv.cjs.map +1 -0
- package/dist/PostgresKyselyMigrator-CvwXycJE.d.mts +84 -0
- package/dist/PostgresKyselyMigrator-CvwXycJE.d.mts.map +1 -0
- package/dist/PostgresKyselyMigrator-PI0QhvB1.mjs +95 -0
- package/dist/PostgresKyselyMigrator-PI0QhvB1.mjs.map +1 -0
- package/dist/PostgresKyselyMigrator.cjs +3 -94
- package/dist/PostgresKyselyMigrator.d.cts +3 -80
- package/dist/PostgresKyselyMigrator.d.mts +3 -80
- package/dist/PostgresKyselyMigrator.mjs +3 -93
- package/dist/{PostgresMigrator-CDPnnwMJ.d.cts → PostgresMigrator-C_QQ6q35.d.mts} +5 -11
- package/dist/PostgresMigrator-C_QQ6q35.d.mts.map +1 -0
- package/dist/{PostgresMigrator-CDPnnwMJ.d.mts → PostgresMigrator-CeYy-eHF.d.cts} +5 -11
- package/dist/PostgresMigrator-CeYy-eHF.d.cts.map +1 -0
- package/dist/PostgresMigrator-DVAY04qN.mjs +166 -0
- package/dist/PostgresMigrator-DVAY04qN.mjs.map +1 -0
- package/dist/PostgresMigrator-M9jpzOvN.cjs +172 -0
- package/dist/PostgresMigrator-M9jpzOvN.cjs.map +1 -0
- package/dist/PostgresMigrator.cjs +2 -178
- package/dist/PostgresMigrator.d.cts +1 -1
- package/dist/PostgresMigrator.d.mts +1 -1
- package/dist/PostgresMigrator.mjs +2 -175
- package/dist/PostgresObjectionMigrator-1j6YIB1c.d.mts +79 -0
- package/dist/PostgresObjectionMigrator-1j6YIB1c.d.mts.map +1 -0
- package/dist/PostgresObjectionMigrator-DHVC9h_P.d.cts +79 -0
- package/dist/PostgresObjectionMigrator-DHVC9h_P.d.cts.map +1 -0
- package/dist/PostgresObjectionMigrator-DSaPhwjY.cjs +123 -0
- package/dist/PostgresObjectionMigrator-DSaPhwjY.cjs.map +1 -0
- package/dist/PostgresObjectionMigrator-DjPKdUbm.mjs +118 -0
- package/dist/PostgresObjectionMigrator-DjPKdUbm.mjs.map +1 -0
- package/dist/PostgresObjectionMigrator.cjs +3 -118
- package/dist/PostgresObjectionMigrator.d.cts +3 -75
- package/dist/PostgresObjectionMigrator.d.mts +3 -75
- package/dist/PostgresObjectionMigrator.mjs +3 -117
- package/dist/VitestKyselyTransactionIsolator-0CqOsuc9.cjs +65 -0
- package/dist/VitestKyselyTransactionIsolator-0CqOsuc9.cjs.map +1 -0
- package/dist/VitestKyselyTransactionIsolator-CduJlHoT.d.cts +59 -0
- package/dist/VitestKyselyTransactionIsolator-CduJlHoT.d.cts.map +1 -0
- package/dist/VitestKyselyTransactionIsolator-CfSMOFlN.mjs +60 -0
- package/dist/VitestKyselyTransactionIsolator-CfSMOFlN.mjs.map +1 -0
- package/dist/VitestKyselyTransactionIsolator-Cswnnj0k.d.mts +59 -0
- package/dist/VitestKyselyTransactionIsolator-Cswnnj0k.d.mts.map +1 -0
- package/dist/VitestKyselyTransactionIsolator.cjs +3 -66
- package/dist/VitestKyselyTransactionIsolator.d.cts +3 -60
- package/dist/VitestKyselyTransactionIsolator.d.mts +3 -60
- package/dist/VitestKyselyTransactionIsolator.mjs +3 -65
- package/dist/VitestObjectionTransactionIsolator-B5J9jjKq.cjs +68 -0
- package/dist/VitestObjectionTransactionIsolator-B5J9jjKq.cjs.map +1 -0
- package/dist/VitestObjectionTransactionIsolator-BXoR6xdG.d.cts +60 -0
- package/dist/VitestObjectionTransactionIsolator-BXoR6xdG.d.cts.map +1 -0
- package/dist/VitestObjectionTransactionIsolator-CNo40EdC.mjs +63 -0
- package/dist/VitestObjectionTransactionIsolator-CNo40EdC.mjs.map +1 -0
- package/dist/VitestObjectionTransactionIsolator-x6hY5j4u.d.mts +60 -0
- package/dist/VitestObjectionTransactionIsolator-x6hY5j4u.d.mts.map +1 -0
- package/dist/VitestObjectionTransactionIsolator.cjs +3 -62
- package/dist/VitestObjectionTransactionIsolator.d.cts +3 -56
- package/dist/VitestObjectionTransactionIsolator.d.mts +3 -56
- package/dist/VitestObjectionTransactionIsolator.mjs +3 -61
- package/dist/VitestTransactionIsolator-BNWJqh9f.d.mts +207 -0
- package/dist/VitestTransactionIsolator-BNWJqh9f.d.mts.map +1 -0
- package/dist/VitestTransactionIsolator-CSroc7Df.d.cts +207 -0
- package/dist/VitestTransactionIsolator-CSroc7Df.d.cts.map +1 -0
- package/dist/VitestTransactionIsolator-CtZaOUjH.cjs +193 -0
- package/dist/VitestTransactionIsolator-CtZaOUjH.cjs.map +1 -0
- package/dist/VitestTransactionIsolator-D6ZxLWys.mjs +175 -0
- package/dist/VitestTransactionIsolator-D6ZxLWys.mjs.map +1 -0
- package/dist/VitestTransactionIsolator.cjs +4 -187
- package/dist/VitestTransactionIsolator.d.cts +2 -219
- package/dist/VitestTransactionIsolator.d.mts +2 -219
- package/dist/VitestTransactionIsolator.mjs +2 -184
- package/dist/aws.cjs +4 -3
- package/dist/aws.cjs.map +1 -1
- package/dist/aws.d.cts +8 -3
- package/dist/aws.d.cts.map +1 -1
- package/dist/aws.d.mts +8 -3
- package/dist/aws.d.mts.map +1 -1
- package/dist/aws.mjs +2 -1
- package/dist/aws.mjs.map +1 -1
- package/dist/benchmark.cjs +2 -2
- package/dist/benchmark.cjs.map +1 -1
- package/dist/benchmark.d.cts +6 -4
- package/dist/benchmark.d.cts.map +1 -1
- package/dist/benchmark.d.mts +6 -4
- package/dist/benchmark.d.mts.map +1 -1
- package/dist/benchmark.mjs +1 -1
- package/dist/benchmark.mjs.map +1 -1
- package/dist/better-auth.cjs +15 -31
- package/dist/better-auth.cjs.map +1 -1
- package/dist/better-auth.d.cts +4 -13142
- package/dist/better-auth.d.cts.map +1 -1
- package/dist/better-auth.d.mts +4 -13142
- package/dist/better-auth.d.mts.map +1 -1
- package/dist/better-auth.mjs +13 -29
- package/dist/better-auth.mjs.map +1 -1
- package/dist/{rolldown-runtime-VH7oDXx4.cjs → chunk-CUT6urMc.cjs} +10 -8
- package/dist/directory-Bpz5c5pj.d.cts +13 -0
- package/dist/directory-Bpz5c5pj.d.cts.map +1 -0
- package/dist/directory-BxjqmtCT.mjs +27 -0
- package/dist/directory-BxjqmtCT.mjs.map +1 -0
- package/dist/directory-CVrfTq1I.d.mts +13 -0
- package/dist/directory-CVrfTq1I.d.mts.map +1 -0
- package/dist/directory-DD_xQoSh.cjs +33 -0
- package/dist/directory-DD_xQoSh.cjs.map +1 -0
- package/dist/faker-B14IEMIN.cjs +304 -0
- package/dist/faker-B14IEMIN.cjs.map +1 -0
- package/dist/faker-BGKYFoCT.mjs +262 -0
- package/dist/faker-BGKYFoCT.mjs.map +1 -0
- package/dist/faker-Cg76aFNO.d.cts +166 -0
- package/dist/faker-Cg76aFNO.d.cts.map +1 -0
- package/dist/faker-DHh7xs4u.d.mts +166 -0
- package/dist/faker-DHh7xs4u.d.mts.map +1 -0
- package/dist/faker.cjs +8 -313
- package/dist/faker.d.cts +2 -169
- package/dist/faker.d.mts +2 -169
- package/dist/faker.mjs +2 -305
- package/dist/helpers.cjs +5 -6
- package/dist/helpers.cjs.map +1 -1
- package/dist/helpers.d.cts +5 -1
- package/dist/helpers.d.cts.map +1 -1
- package/dist/helpers.d.mts +5 -1
- package/dist/helpers.d.mts.map +1 -1
- package/dist/helpers.mjs +2 -1
- package/dist/helpers.mjs.map +1 -1
- package/dist/initScript.cjs +15 -15
- package/dist/initScript.cjs.map +1 -1
- package/dist/initScript.d.cts +4 -2
- package/dist/initScript.d.cts.map +1 -1
- package/dist/initScript.d.mts +4 -2
- package/dist/initScript.d.mts.map +1 -1
- package/dist/initScript.mjs +12 -10
- package/dist/initScript.mjs.map +1 -1
- package/dist/kysely.cjs +13 -10
- package/dist/kysely.cjs.map +1 -1
- package/dist/kysely.d.cts +14 -10
- package/dist/kysely.d.cts.map +1 -1
- package/dist/kysely.d.mts +14 -10
- package/dist/kysely.d.mts.map +1 -1
- package/dist/kysely.mjs +14 -10
- package/dist/kysely.mjs.map +1 -1
- package/dist/logger.cjs +4 -3
- package/dist/logger.cjs.map +1 -1
- package/dist/logger.d.cts +5 -1
- package/dist/logger.d.cts.map +1 -1
- package/dist/logger.d.mts +5 -1
- package/dist/logger.d.mts.map +1 -1
- package/dist/logger.mjs +2 -1
- package/dist/logger.mjs.map +1 -1
- package/dist/objection.cjs +13 -10
- package/dist/objection.cjs.map +1 -1
- package/dist/objection.d.cts +14 -10
- package/dist/objection.d.cts.map +1 -1
- package/dist/objection.d.mts +14 -10
- package/dist/objection.d.mts.map +1 -1
- package/dist/objection.mjs +14 -10
- package/dist/objection.mjs.map +1 -1
- package/dist/os/directory.cjs +2 -31
- package/dist/os/directory.d.cts +2 -9
- package/dist/os/directory.d.mts +2 -9
- package/dist/os/directory.mjs +2 -25
- package/dist/os/index.cjs +3 -3
- package/dist/os/index.d.cts +1 -1
- package/dist/os/index.d.mts +1 -1
- package/dist/os/index.mjs +3 -2
- package/dist/requestContext.cjs +11 -10
- package/dist/requestContext.cjs.map +1 -1
- package/dist/requestContext.d.cts +9 -5
- package/dist/requestContext.d.cts.map +1 -1
- package/dist/requestContext.d.mts +9 -5
- package/dist/requestContext.d.mts.map +1 -1
- package/dist/requestContext.mjs +3 -2
- package/dist/requestContext.mjs.map +1 -1
- package/dist/timer.cjs +2 -2
- package/dist/timer.cjs.map +1 -1
- package/dist/timer.d.cts +4 -1
- package/dist/timer.d.cts.map +1 -1
- package/dist/timer.d.mts +4 -1
- package/dist/timer.d.mts.map +1 -1
- package/dist/timer.mjs +1 -1
- package/dist/timer.mjs.map +1 -1
- package/package.json +25 -65
- package/src/Factory.ts +174 -0
- package/src/KyselyFactory.ts +391 -0
- package/src/ObjectionFactory.ts +412 -0
- package/src/PostgresKyselyMigrator.ts +104 -0
- package/src/PostgresMigrator.ts +193 -0
- package/src/PostgresObjectionMigrator.ts +138 -0
- package/src/VitestKyselyTransactionIsolator.ts +72 -0
- package/src/VitestObjectionTransactionIsolator.ts +75 -0
- package/src/VitestTransactionIsolator.ts +348 -0
- package/src/__tests__/Factory.spec.ts +178 -0
- package/src/__tests__/KyselyFactory.spec.ts +458 -0
- package/src/__tests__/ObjectionFactory.spec.ts +586 -0
- package/src/__tests__/PostgresKyselyMigrator.spec.ts +794 -0
- package/src/__tests__/PostgresMigrator.spec.ts +471 -0
- package/src/__tests__/PostgresObjectionMigrator.spec.ts +634 -0
- package/src/__tests__/VitestObjectionTransactionIsolator.spec.ts +138 -0
- package/src/__tests__/benchmark.spec.ts +140 -0
- package/src/__tests__/better-auth.spec.ts +21 -0
- package/src/__tests__/faker.spec.ts +231 -0
- package/src/__tests__/initScript.spec.ts +332 -0
- package/src/__tests__/integration.spec.ts +610 -0
- package/src/__tests__/requestContext.spec.ts +113 -0
- package/src/__tests__/utilities.spec.ts +211 -0
- package/src/aws.ts +131 -0
- package/src/benchmark.ts +48 -0
- package/src/better-auth.ts +310 -0
- package/src/faker.ts +349 -0
- package/src/helpers.ts +45 -0
- package/src/initScript.ts +122 -0
- package/src/kysely.ts +166 -0
- package/src/logger.ts +18 -0
- package/src/objection.ts +157 -0
- package/src/os/directory.ts +26 -0
- package/src/os/index.ts +1 -0
- package/src/requestContext.ts +119 -0
- package/src/timer.ts +3 -0
- package/test/globalSetup.ts +54 -0
- package/test/helpers.ts +268 -0
- package/test/migrations/1749664623372_user.ts +22 -0
- package/tsconfig.json +9 -0
- package/vitest.config.ts +8 -0
- package/dist/Factory.cjs.map +0 -1
- package/dist/Factory.d.cts.map +0 -1
- package/dist/Factory.d.mts.map +0 -1
- package/dist/Factory.mjs.map +0 -1
- package/dist/KyselyFactory.cjs.map +0 -1
- package/dist/KyselyFactory.d.cts.map +0 -1
- package/dist/KyselyFactory.d.mts.map +0 -1
- package/dist/KyselyFactory.mjs.map +0 -1
- package/dist/ObjectionFactory.cjs.map +0 -1
- package/dist/ObjectionFactory.d.cts.map +0 -1
- package/dist/ObjectionFactory.d.mts.map +0 -1
- package/dist/ObjectionFactory.mjs.map +0 -1
- package/dist/PostgresKyselyMigrator.cjs.map +0 -1
- package/dist/PostgresKyselyMigrator.d.cts.map +0 -1
- package/dist/PostgresKyselyMigrator.d.mts.map +0 -1
- package/dist/PostgresKyselyMigrator.mjs.map +0 -1
- package/dist/PostgresMigrator-CDPnnwMJ.d.cts.map +0 -1
- package/dist/PostgresMigrator-CDPnnwMJ.d.mts.map +0 -1
- package/dist/PostgresMigrator.cjs.map +0 -1
- package/dist/PostgresMigrator.mjs.map +0 -1
- package/dist/PostgresObjectionMigrator.cjs.map +0 -1
- package/dist/PostgresObjectionMigrator.d.cts.map +0 -1
- package/dist/PostgresObjectionMigrator.d.mts.map +0 -1
- package/dist/PostgresObjectionMigrator.mjs.map +0 -1
- package/dist/VitestKyselyTransactionIsolator.cjs.map +0 -1
- package/dist/VitestKyselyTransactionIsolator.d.cts.map +0 -1
- package/dist/VitestKyselyTransactionIsolator.d.mts.map +0 -1
- package/dist/VitestKyselyTransactionIsolator.mjs.map +0 -1
- package/dist/VitestObjectionTransactionIsolator.cjs.map +0 -1
- package/dist/VitestObjectionTransactionIsolator.d.cts.map +0 -1
- package/dist/VitestObjectionTransactionIsolator.d.mts.map +0 -1
- package/dist/VitestObjectionTransactionIsolator.mjs.map +0 -1
- package/dist/VitestTransactionIsolator.cjs.map +0 -1
- package/dist/VitestTransactionIsolator.d.cts.map +0 -1
- package/dist/VitestTransactionIsolator.d.mts.map +0 -1
- package/dist/VitestTransactionIsolator.mjs.map +0 -1
- package/dist/browser.cjs +0 -149
- package/dist/browser.cjs.map +0 -1
- package/dist/browser.d.cts +0 -62
- package/dist/browser.d.cts.map +0 -1
- package/dist/browser.d.mts +0 -62
- package/dist/browser.d.mts.map +0 -1
- package/dist/browser.mjs +0 -147
- package/dist/browser.mjs.map +0 -1
- package/dist/context.cjs +0 -80
- package/dist/context.cjs.map +0 -1
- package/dist/context.d.cts +0 -55
- package/dist/context.d.cts.map +0 -1
- package/dist/context.d.mts +0 -55
- package/dist/context.d.mts.map +0 -1
- package/dist/context.mjs +0 -73
- package/dist/context.mjs.map +0 -1
- package/dist/faker.cjs.map +0 -1
- package/dist/faker.d.cts.map +0 -1
- package/dist/faker.d.mts.map +0 -1
- package/dist/faker.mjs.map +0 -1
- package/dist/mailbox.cjs +0 -95
- package/dist/mailbox.cjs.map +0 -1
- package/dist/mailbox.d.cts +0 -58
- package/dist/mailbox.d.cts.map +0 -1
- package/dist/mailbox.d.mts +0 -58
- package/dist/mailbox.d.mts.map +0 -1
- package/dist/mailbox.mjs +0 -92
- package/dist/mailbox.mjs.map +0 -1
- package/dist/os/directory.cjs.map +0 -1
- package/dist/os/directory.d.cts.map +0 -1
- package/dist/os/directory.d.mts.map +0 -1
- package/dist/os/directory.mjs.map +0 -1
- package/dist/transactions.cjs +0 -239
- package/dist/transactions.cjs.map +0 -1
- package/dist/transactions.d.cts +0 -44
- package/dist/transactions.d.cts.map +0 -1
- package/dist/transactions.d.mts +0 -44
- package/dist/transactions.d.mts.map +0 -1
- package/dist/transactions.mjs +0 -234
- package/dist/transactions.mjs.map +0 -1
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
# @geekmidas/testkit
|
|
2
|
+
|
|
3
|
+
## 10.0.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies []:
|
|
8
|
+
- @geekmidas/envkit@10.0.0
|
|
9
|
+
- @geekmidas/logger@10.0.0
|
|
10
|
+
- @geekmidas/services@10.0.0
|
|
11
|
+
|
|
12
|
+
## 9.0.2
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- [#12](https://github.com/geekmidas/toolbox/pull/12) [`d53863a`](https://github.com/geekmidas/toolbox/commit/d53863a84db2e4ab5420e08f79128b637043fc42) Thanks [@geekmidas](https://github.com/geekmidas)! - Align every published package on a single version and keep them in step.
|
|
17
|
+
|
|
18
|
+
All packages now share one version, enforced by a changesets `fixed` group. The
|
|
19
|
+
baseline is 9.0.1 — @geekmidas/client's published version — so nothing moves
|
|
20
|
+
backwards; this release takes the whole set to 9.0.2 together.
|
|
21
|
+
|
|
22
|
+
Independent versions made "which version of the docs applies to me"
|
|
23
|
+
unanswerable: a reader on constructs@7 and cli@2 was on no version at all. One
|
|
24
|
+
number per release makes versioned documentation possible, and lets 9 freeze as
|
|
25
|
+
the current paradigm while the constructs rework is developed against it.
|
|
26
|
+
|
|
27
|
+
Every release now publishes every package, and a major anywhere is a major
|
|
28
|
+
everywhere. Peer ranges get simpler in return.
|
|
29
|
+
|
|
30
|
+
- Updated dependencies [[`d53863a`](https://github.com/geekmidas/toolbox/commit/d53863a84db2e4ab5420e08f79128b637043fc42)]:
|
|
31
|
+
- @geekmidas/envkit@9.0.2
|
|
32
|
+
- @geekmidas/logger@9.0.2
|
|
33
|
+
- @geekmidas/services@9.0.2
|
|
34
|
+
|
|
35
|
+
## 3.1.1
|
|
36
|
+
|
|
37
|
+
### Patch Changes
|
|
38
|
+
|
|
39
|
+
- 🐛 [#11](https://github.com/geekmidas/toolbox/pull/11) [`40f4dc0`](https://github.com/geekmidas/toolbox/commit/40f4dc095911b2223a255029d8f776caf7781309) Thanks [@geekmidas](https://github.com/geekmidas)! - Patch release across all packages to realign published versions with the
|
|
40
|
+
registry. The previous release only published the four packages that had
|
|
41
|
+
version bumps; the remaining packages failed with "cannot publish over the
|
|
42
|
+
previously published versions" because their versions were unchanged.
|
|
43
|
+
- Updated dependencies [[`40f4dc0`](https://github.com/geekmidas/toolbox/commit/40f4dc095911b2223a255029d8f776caf7781309)]:
|
|
44
|
+
- @geekmidas/envkit@1.1.1
|
|
45
|
+
- @geekmidas/logger@1.0.3
|
|
46
|
+
- @geekmidas/services@2.0.1
|
|
47
|
+
|
|
48
|
+
## 3.1.0
|
|
49
|
+
|
|
50
|
+
### Minor Changes
|
|
51
|
+
|
|
52
|
+
- [#9](https://github.com/geekmidas/toolbox/pull/9) [`e31a60a`](https://github.com/geekmidas/toolbox/commit/e31a60a971366180a0e7bec6e7da56d8f36aa21f) Thanks [@geekmidas](https://github.com/geekmidas)! - Support kysely 0.29.
|
|
53
|
+
|
|
54
|
+
kysely 0.29 moved `Migrator` and `FileMigrationProvider` from the root barrel
|
|
55
|
+
(`'kysely'`) to the `'kysely/migration'` subpath. `@geekmidas/testkit`'s
|
|
56
|
+
`PostgresKyselyMigrator` now imports `Migrator` from `'kysely/migration'` and
|
|
57
|
+
its kysely peer becomes `~0.29.4` — consumers must be on kysely 0.29+.
|
|
58
|
+
|
|
59
|
+
The library packages that only declare a kysely _peer_ (`db`, `audit`, `studio`,
|
|
60
|
+
`telescope`) don't touch the moved symbols, so their peer range is _widened_ to
|
|
61
|
+
`>=0.28.2 <0.30.0` — they now support both 0.28 and 0.29 (non-breaking).
|
|
62
|
+
|
|
63
|
+
`@geekmidas/cli`'s scaffolded `test/globalSetup.ts` template now imports
|
|
64
|
+
`FileMigrationProvider` from `'kysely/migration'` so generated projects work on
|
|
65
|
+
kysely 0.29.
|
|
66
|
+
|
|
67
|
+
## 3.0.0
|
|
68
|
+
|
|
69
|
+
### Patch Changes
|
|
70
|
+
|
|
71
|
+
- Updated dependencies [[`7323f34`](https://github.com/geekmidas/toolbox/commit/7323f34176d63170dd53450889ac0b5959420c3c), [`79e2929`](https://github.com/geekmidas/toolbox/commit/79e292978d3dbc8927e25814bdb051d1c380600a)]:
|
|
72
|
+
- @geekmidas/envkit@1.1.0
|
|
73
|
+
- @geekmidas/services@2.0.0
|
|
74
|
+
|
|
75
|
+
## 2.0.0
|
|
76
|
+
|
|
77
|
+
### Patch Changes
|
|
78
|
+
|
|
79
|
+
- Updated dependencies [[`811d740`](https://github.com/geekmidas/toolbox/commit/811d740ae3875d59ad1b0dc50261266963c8cb76)]:
|
|
80
|
+
- @geekmidas/services@1.1.0
|
|
81
|
+
|
|
82
|
+
## 1.0.9
|
|
83
|
+
|
|
84
|
+
### Patch Changes
|
|
85
|
+
|
|
86
|
+
- 🐛 [#3](https://github.com/geekmidas/toolbox/pull/3) [`42fda53`](https://github.com/geekmidas/toolbox/commit/42fda532bdf4489a3352f6a684f5f30beafccedd) Thanks [@geekmidas](https://github.com/geekmidas)! - Fix stale logger from service initialization
|
|
87
|
+
|
|
88
|
+
- Updated dependencies [[`42fda53`](https://github.com/geekmidas/toolbox/commit/42fda532bdf4489a3352f6a684f5f30beafccedd)]:
|
|
89
|
+
- @geekmidas/services@1.0.4
|
|
90
|
+
|
|
91
|
+
## 1.0.8
|
|
92
|
+
|
|
93
|
+
### Patch Changes
|
|
94
|
+
|
|
95
|
+
- ✨ [`351f73b`](https://github.com/geekmidas/toolbox/commit/351f73b032bc0742b7f611a9fbcdfc85bbfd69a8) Thanks [@geekmidas](https://github.com/geekmidas)! - Update request context and add support for trpc
|
|
96
|
+
|
|
97
|
+
- Updated dependencies [[`351f73b`](https://github.com/geekmidas/toolbox/commit/351f73b032bc0742b7f611a9fbcdfc85bbfd69a8)]:
|
|
98
|
+
- @geekmidas/services@1.0.3
|
|
99
|
+
|
|
100
|
+
## 1.0.7
|
|
101
|
+
|
|
102
|
+
### Patch Changes
|
|
103
|
+
|
|
104
|
+
- 🐛 [`d70c6c0`](https://github.com/geekmidas/toolbox/commit/d70c6c0aeb8a79da2473ac77dbd8255a4a2f5651) Thanks [@geekmidas](https://github.com/geekmidas)! - Fix `package.json` exports so TypeScript declarations resolve correctly under NodeNext/Bundler module resolution. Each subpath export now nests `types` inside its `import`/`require` condition, pointing at the `.d.mts` and `.d.cts` files that `tsdown` actually emits (previously the exports referenced non-existent `.d.ts` files, causing type-resolution failures for consumers). Both ESM (`.mjs`) and CJS (`.cjs`) runtime entry points are preserved. Additionally, `@geekmidas/ui` had `import` paths pointing at `.js` files that were never emitted — those are corrected to `.mjs`.
|
|
105
|
+
|
|
106
|
+
- Updated dependencies [[`d70c6c0`](https://github.com/geekmidas/toolbox/commit/d70c6c0aeb8a79da2473ac77dbd8255a4a2f5651)]:
|
|
107
|
+
- @geekmidas/envkit@1.0.7
|
|
108
|
+
- @geekmidas/logger@1.0.2
|
|
109
|
+
|
|
110
|
+
## 1.0.6
|
|
111
|
+
|
|
112
|
+
### Patch Changes
|
|
113
|
+
|
|
114
|
+
- 🐛 [`b8a17e3`](https://github.com/geekmidas/toolbox/commit/b8a17e33de415a5d749297f7840564e824609a92) Thanks [@geekmidas](https://github.com/geekmidas)! - Fix global zod registry and fix this reference on test extensions
|
|
115
|
+
|
|
116
|
+
## 1.0.5
|
|
117
|
+
|
|
118
|
+
### Patch Changes
|
|
119
|
+
|
|
120
|
+
- 🐛 [`184c254`](https://github.com/geekmidas/toolbox/commit/184c2547a674d37c48948a9922c947ca98ff1f17) Thanks [@geekmidas](https://github.com/geekmidas)! - Fix script parsing
|
|
121
|
+
|
|
122
|
+
## 1.0.4
|
|
123
|
+
|
|
124
|
+
### Patch Changes
|
|
125
|
+
|
|
126
|
+
- ✨ [`7815080`](https://github.com/geekmidas/toolbox/commit/781508030df7f67881f5e79349338f62b35ed684) Thanks [@geekmidas](https://github.com/geekmidas)! - Add after create hook for init scripts
|
|
127
|
+
|
|
128
|
+
## 1.0.3
|
|
129
|
+
|
|
130
|
+
### Patch Changes
|
|
131
|
+
|
|
132
|
+
- ✨ [`e99f8cb`](https://github.com/geekmidas/toolbox/commit/e99f8cbb95fa5b818d94ee99b308c2ac0b239e0b) Thanks [@geekmidas](https://github.com/geekmidas)! - Add initialization scripts for postgres
|
|
133
|
+
|
|
134
|
+
## 1.0.2
|
|
135
|
+
|
|
136
|
+
### Patch Changes
|
|
137
|
+
|
|
138
|
+
- ✨ [`83a24de`](https://github.com/geekmidas/toolbox/commit/83a24de902b3fadd98444cab552ecd84f32b6661) Thanks [@geekmidas](https://github.com/geekmidas)! - Add pg-boss event publisher/subscriber, CLI setup and upgrade commands, and secrets sync via AWS SSM
|
|
139
|
+
- ✨ **@geekmidas/events**: Add pg-boss backend for event publishing and subscribing with connection string support
|
|
140
|
+
- ✨ **@geekmidas/cli**: Add `gkm setup` command for dev environment initialization, `gkm upgrade` command with workspace detection, and secrets push/pull via AWS SSM Parameter Store
|
|
141
|
+
- 🐛 **@geekmidas/testkit**: Fix database creation race condition in PostgresMigrator
|
|
142
|
+
- ✨ **@geekmidas/constructs**: Add integration tests for pg-boss with HonoEndpoint
|
|
143
|
+
|
|
144
|
+
## 1.0.1
|
|
145
|
+
|
|
146
|
+
### Patch Changes
|
|
147
|
+
|
|
148
|
+
- ✨ [`3b6d7d9`](https://github.com/geekmidas/toolbox/commit/3b6d7d9ed41dc08675395d937248a8ab754af9e1) Thanks [@geekmidas](https://github.com/geekmidas)! - Add state provider configuration to workspace config
|
|
149
|
+
|
|
150
|
+
## 1.0.0
|
|
151
|
+
|
|
152
|
+
### Major Changes
|
|
153
|
+
|
|
154
|
+
- [`ff7b115`](https://github.com/geekmidas/toolbox/commit/ff7b11599f60f84ac6cdc73714c853ecf786b2e8) Thanks [@geekmidas](https://github.com/geekmidas)! - Version 1 Stable release
|
|
155
|
+
|
|
156
|
+
### Patch Changes
|
|
157
|
+
|
|
158
|
+
- Updated dependencies [[`ff7b115`](https://github.com/geekmidas/toolbox/commit/ff7b11599f60f84ac6cdc73714c853ecf786b2e8)]:
|
|
159
|
+
- @geekmidas/envkit@1.0.0
|
|
160
|
+
- @geekmidas/logger@1.0.0
|
package/README.md
CHANGED
|
@@ -54,12 +54,6 @@ import { itWithDir } from '@geekmidas/testkit/os';
|
|
|
54
54
|
import { createMockContext, createMockV1Event, createMockV2Event } from '@geekmidas/testkit/aws';
|
|
55
55
|
import { createMockLogger } from '@geekmidas/testkit/logger';
|
|
56
56
|
import { memoryAdapter } from '@geekmidas/testkit/better-auth';
|
|
57
|
-
|
|
58
|
-
// Feature tests: the primitives `@geekmidas/constructs/testing` builds on
|
|
59
|
-
import { Browser } from '@geekmidas/testkit/browser';
|
|
60
|
-
import { createMailbox } from '@geekmidas/testkit/mailbox';
|
|
61
|
-
import { runInTestContext, installContextFetch } from '@geekmidas/testkit/context';
|
|
62
|
-
import { TransactionRegistry } from '@geekmidas/testkit/transactions';
|
|
63
57
|
```
|
|
64
58
|
|
|
65
59
|
## Quick Start
|
|
@@ -327,74 +321,6 @@ describe('Authentication', () => {
|
|
|
327
321
|
});
|
|
328
322
|
```
|
|
329
323
|
|
|
330
|
-
## Feature Test Primitives
|
|
331
|
-
|
|
332
|
-
The pieces a feature test is built from — a test that drives an app the way it
|
|
333
|
-
runs deployed: a browser signs in, calls the API, the API calls the auth server,
|
|
334
|
-
each over a URL, every database in a transaction that is rolled back. The wiring
|
|
335
|
-
that knows about constructs lives in `@geekmidas/constructs/testing`; these know
|
|
336
|
-
nothing about them.
|
|
337
|
-
|
|
338
|
-
### `Browser`
|
|
339
|
-
|
|
340
|
-
A `fetch` with a cookie jar that follows the browser's rules (RFC 6265): a
|
|
341
|
-
`Set-Cookie` lands in the jar, and every later request to a URL the cookie
|
|
342
|
-
belongs to carries it. Redirects are followed hop by hop, keeping each hop's
|
|
343
|
-
cookies. Give it to an app's real clients:
|
|
344
|
-
|
|
345
|
-
```typescript
|
|
346
|
-
import { Browser as TestBrowser } from '@geekmidas/testkit/browser';
|
|
347
|
-
|
|
348
|
-
export class Browser extends TestBrowser {
|
|
349
|
-
readonly api = createApi({ baseURL: process.env.API_URL, fetch: this.fetch });
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
const browser = new Browser();
|
|
353
|
-
await browser.visit(magicLink); // 302 + Set-Cookie → the jar
|
|
354
|
-
await browser.api.get('/profile'); // sent with the session cookie
|
|
355
|
-
const restore = browser.install(); // the global fetch, for module-level clients
|
|
356
|
-
```
|
|
357
|
-
|
|
358
|
-
On the server side of a test — a handler serving a request — `browser.fetch` is
|
|
359
|
-
the plain `fetch`: a server forwards what it was handed and never reaches into a
|
|
360
|
-
browser's jar.
|
|
361
|
-
|
|
362
|
-
### `createMailbox`
|
|
363
|
-
|
|
364
|
-
Reads the mail an app actually sent, from Mailpit's HTTP API. One address per
|
|
365
|
-
test keeps tests apart, since Mailpit has one inbox and no transactions:
|
|
366
|
-
|
|
367
|
-
```typescript
|
|
368
|
-
const mailbox = createMailbox({ inbox: process.env.MAILER_INBOX_URL! });
|
|
369
|
-
|
|
370
|
-
const email = await mailbox('ada@shop.test').last(); // waits for it to arrive
|
|
371
|
-
await browser.visit(email.link!);
|
|
372
|
-
await mailbox('ada@shop.test').clear();
|
|
373
|
-
```
|
|
374
|
-
|
|
375
|
-
### Test context
|
|
376
|
-
|
|
377
|
-
`runInTestContext(id, fn)` carries a test's id through every await;
|
|
378
|
-
`installContextFetch()` stamps it onto every outgoing request as
|
|
379
|
-
`x-test-context-id`, so whatever serves a URL in-process finds the test the
|
|
380
|
-
request belongs to — including a request the code under test made while
|
|
381
|
-
handling another one.
|
|
382
|
-
|
|
383
|
-
### `TransactionRegistry`
|
|
384
|
-
|
|
385
|
-
One transaction per database per test — an app's database and a schema tenant
|
|
386
|
-
each on their own connection, as deployed — opened the first time the test
|
|
387
|
-
touches it and rolled back by `rollbackAll()`. Code under test may use
|
|
388
|
-
transactions freely: a `BEGIN` becomes a savepoint, so nothing it does can end
|
|
389
|
-
the test's transaction.
|
|
390
|
-
|
|
391
|
-
```typescript
|
|
392
|
-
const registry = new TransactionRegistry();
|
|
393
|
-
const db = await registry.get('Database', process.env.DATABASE_URL!);
|
|
394
|
-
// …
|
|
395
|
-
await registry.rollbackAll();
|
|
396
|
-
```
|
|
397
|
-
|
|
398
324
|
## Database Migration
|
|
399
325
|
|
|
400
326
|
TestKit includes utilities for managing test database migrations.
|
|
@@ -0,0 +1,51 @@
|
|
|
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
|
+
|
|
49
|
+
//#endregion
|
|
50
|
+
export { Factory };
|
|
51
|
+
//# sourceMappingURL=Factory-BFVnMMCC.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Factory-BFVnMMCC.mjs","names":["seedFn: Seed"],"sources":["../src/Factory.ts"],"sourcesContent":["import type { FakerFactory } from './faker';\n\n/**\n * Abstract base class for database factories used in testing.\n * Provides a standardized interface for creating test data using builder and seed patterns.\n *\n * @template Builders - Record of builder functions for creating individual entities\n * @template Seeds - Record of seed functions for creating complex test scenarios\n *\n * @example\n * ```typescript\n * // Define builders for creating individual records\n * const builders = {\n * user: (attrs) => ({ name: 'Test User', email: 'test@example.com', ...attrs }),\n * post: (attrs) => ({ title: 'Test Post', content: 'Content', ...attrs })\n * };\n *\n * // Define seeds for complex scenarios\n * const seeds = {\n * userWithPosts: async (attrs, factory) => {\n * const user = await factory.insert('user', attrs);\n * await factory.insertMany(3, 'post', { userId: user.id });\n * return user;\n * }\n * };\n * ```\n */\nexport abstract class Factory<\n\tBuilders extends Record<string, any>,\n\tSeeds extends Record<string, any>,\n> {\n\t/**\n\t * Creates a typed seed function with proper type inference.\n\t * This is a utility method to help with TypeScript type checking when defining seeds.\n\t *\n\t * @template Seed - The seed function type\n\t * @param seedFn - The seed function to wrap\n\t * @returns The same seed function with proper typing\n\t *\n\t * @example\n\t * ```typescript\n\t * const userWithPostsSeed = Factory.createSeed(async ({ attrs, factory, db }) => {\n\t * const user = await factory.insert('user', attrs);\n\t * return user;\n\t * });\n\t * ```\n\t */\n\tstatic createSeed<Seed extends FactorySeed>(seedFn: Seed): Seed {\n\t\treturn seedFn;\n\t}\n\t/**\n\t * Inserts an object into the database using a builder function.\n\t *\n\t * @param builderName - The name of the builder to use\n\t * @param attrs - The attributes to insert\n\t */\n\tabstract insert<K extends keyof Builders>(\n\t\tbuilderName: K,\n\t\tattrs?: Parameters<Builders[K]>[0],\n\t): Promise<Awaited<ReturnType<Builders[K]>>>;\n\n\t/**\n\t * Inserts multiple objects into the database\n\t *\n\t * @param count - Number of objects to insert\n\t * @param builderName - The name of the builder to use\n\t * @param attrs - The attributes to insert\n\t */\n\tabstract insertMany<K extends keyof Builders>(\n\t\tcount: number,\n\t\tbuilderName: K,\n\t\tattrs?:\n\t\t\t| Parameters<Builders[K]>[0]\n\t\t\t| ((\n\t\t\t\t\tidx: number,\n\t\t\t\t\tfaker: FakerFactory,\n\t\t\t ) => Promise<Parameters<Builders[K]>[0]>),\n\t): Promise<Awaited<ReturnType<Builders[K]>>[]>;\n\n\t/**\n\t * Seeds the database using a seed function.\n\t *\n\t * @param seedName - The name of the seed to use\n\t * @returns The result of the seed function\n\t * @param attrs - The attributes to pass to the seed function\n\t */\n\tabstract seed<K extends keyof Seeds>(\n\t\tseedName: K,\n\t\tattrs?: ExtractSeedAttrs<Seeds[K]>,\n\t): ReturnType<Seeds[K]>;\n}\n\n/**\n * Type definition for a factory builder function that can work with different database types.\n * Builders are responsible for creating individual database records with default values and relationships.\n *\n * @template Attrs - The attributes/input type for the builder\n * @template Factory - The factory instance type\n * @template Result - The type of object returned by the builder\n * @template DB - The database connection type (Kysely, Knex, etc.)\n *\n * @param attrs - Partial attributes to override defaults\n * @param factory - The factory instance for creating related records\n * @param db - The database connection\n * @returns The created record or a promise resolving to it\n *\n * @example\n * ```typescript\n * const userBuilder: MixedFactoryBuilder<UserAttrs, Factory, User, Kysely<DB>> =\n * async (attrs, factory, db) => {\n * return {\n * id: faker.string.uuid(),\n * name: faker.person.fullName(),\n * email: faker.internet.email(),\n * ...attrs\n * };\n * };\n * ```\n */\nexport type MixedFactoryBuilder<\n\tAttrs = any,\n\tFactory = any,\n\tResult = any,\n\tDB = any,\n> = (attrs: Attrs, factory: Factory, db: DB) => Result | Promise<Result>;\n\n/**\n * Type definition for a factory seed function used to create complex test scenarios.\n * Seeds typically create multiple related records to set up a complete test environment.\n *\n * @template Attrs - The attributes/input type for the seed\n * @template Factory - The factory instance type\n * @template Result - The type of object returned by the seed\n * @template DB - The database connection type (Kysely, Knex, etc.)\n *\n * @param context - Object containing attrs, factory, and db\n * @param context.attrs - Configuration attributes for the seed\n * @param context.factory - The factory instance for creating records\n * @param context.db - The database connection\n * @returns A promise resolving to the seed result\n *\n * @example\n * ```typescript\n * const userWithPostsSeed: FactorySeed<{ postCount?: number }, Factory, User, DB> =\n * async ({ attrs, factory, db }) => {\n * const user = await factory.insert('user', attrs);\n * const postCount = attrs.postCount || 3;\n *\n * for (let i = 0; i < postCount; i++) {\n * await factory.insert('post', { userId: user.id });\n * }\n *\n * return user;\n * };\n * ```\n */\nexport type FactorySeed<\n\tAttrs = any,\n\tFactory = any,\n\tResult = any,\n\tDB = any,\n> = (context: { attrs: Attrs; factory: Factory; db: DB }) => Promise<Result>;\n\n/**\n * Helper type to extract the Attrs type from a FactorySeed function.\n * Used internally by Factory implementations to correctly type the seed method parameters.\n */\nexport type ExtractSeedAttrs<T> = T extends (context: {\n\tattrs: infer A;\n\tfactory: any;\n\tdb: any;\n}) => any\n\t? A\n\t: never;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,IAAsB,UAAtB,MAGE;;;;;;;;;;;;;;;;;CAiBD,OAAO,WAAqCA,QAAoB;AAC/D,SAAO;CACP;AAyCD"}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { FakerFactory } from "./faker-Cg76aFNO.cjs";
|
|
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-BOX312yd.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Factory-BOX312yd.d.cts","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"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
|
|
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
|
+
|
|
50
|
+
//#endregion
|
|
51
|
+
Object.defineProperty(exports, 'Factory', {
|
|
52
|
+
enumerable: true,
|
|
53
|
+
get: function () {
|
|
54
|
+
return Factory;
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
//# sourceMappingURL=Factory-BhjUOBWN.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Factory-BhjUOBWN.cjs","names":["seedFn: Seed"],"sources":["../src/Factory.ts"],"sourcesContent":["import type { FakerFactory } from './faker';\n\n/**\n * Abstract base class for database factories used in testing.\n * Provides a standardized interface for creating test data using builder and seed patterns.\n *\n * @template Builders - Record of builder functions for creating individual entities\n * @template Seeds - Record of seed functions for creating complex test scenarios\n *\n * @example\n * ```typescript\n * // Define builders for creating individual records\n * const builders = {\n * user: (attrs) => ({ name: 'Test User', email: 'test@example.com', ...attrs }),\n * post: (attrs) => ({ title: 'Test Post', content: 'Content', ...attrs })\n * };\n *\n * // Define seeds for complex scenarios\n * const seeds = {\n * userWithPosts: async (attrs, factory) => {\n * const user = await factory.insert('user', attrs);\n * await factory.insertMany(3, 'post', { userId: user.id });\n * return user;\n * }\n * };\n * ```\n */\nexport abstract class Factory<\n\tBuilders extends Record<string, any>,\n\tSeeds extends Record<string, any>,\n> {\n\t/**\n\t * Creates a typed seed function with proper type inference.\n\t * This is a utility method to help with TypeScript type checking when defining seeds.\n\t *\n\t * @template Seed - The seed function type\n\t * @param seedFn - The seed function to wrap\n\t * @returns The same seed function with proper typing\n\t *\n\t * @example\n\t * ```typescript\n\t * const userWithPostsSeed = Factory.createSeed(async ({ attrs, factory, db }) => {\n\t * const user = await factory.insert('user', attrs);\n\t * return user;\n\t * });\n\t * ```\n\t */\n\tstatic createSeed<Seed extends FactorySeed>(seedFn: Seed): Seed {\n\t\treturn seedFn;\n\t}\n\t/**\n\t * Inserts an object into the database using a builder function.\n\t *\n\t * @param builderName - The name of the builder to use\n\t * @param attrs - The attributes to insert\n\t */\n\tabstract insert<K extends keyof Builders>(\n\t\tbuilderName: K,\n\t\tattrs?: Parameters<Builders[K]>[0],\n\t): Promise<Awaited<ReturnType<Builders[K]>>>;\n\n\t/**\n\t * Inserts multiple objects into the database\n\t *\n\t * @param count - Number of objects to insert\n\t * @param builderName - The name of the builder to use\n\t * @param attrs - The attributes to insert\n\t */\n\tabstract insertMany<K extends keyof Builders>(\n\t\tcount: number,\n\t\tbuilderName: K,\n\t\tattrs?:\n\t\t\t| Parameters<Builders[K]>[0]\n\t\t\t| ((\n\t\t\t\t\tidx: number,\n\t\t\t\t\tfaker: FakerFactory,\n\t\t\t ) => Promise<Parameters<Builders[K]>[0]>),\n\t): Promise<Awaited<ReturnType<Builders[K]>>[]>;\n\n\t/**\n\t * Seeds the database using a seed function.\n\t *\n\t * @param seedName - The name of the seed to use\n\t * @returns The result of the seed function\n\t * @param attrs - The attributes to pass to the seed function\n\t */\n\tabstract seed<K extends keyof Seeds>(\n\t\tseedName: K,\n\t\tattrs?: ExtractSeedAttrs<Seeds[K]>,\n\t): ReturnType<Seeds[K]>;\n}\n\n/**\n * Type definition for a factory builder function that can work with different database types.\n * Builders are responsible for creating individual database records with default values and relationships.\n *\n * @template Attrs - The attributes/input type for the builder\n * @template Factory - The factory instance type\n * @template Result - The type of object returned by the builder\n * @template DB - The database connection type (Kysely, Knex, etc.)\n *\n * @param attrs - Partial attributes to override defaults\n * @param factory - The factory instance for creating related records\n * @param db - The database connection\n * @returns The created record or a promise resolving to it\n *\n * @example\n * ```typescript\n * const userBuilder: MixedFactoryBuilder<UserAttrs, Factory, User, Kysely<DB>> =\n * async (attrs, factory, db) => {\n * return {\n * id: faker.string.uuid(),\n * name: faker.person.fullName(),\n * email: faker.internet.email(),\n * ...attrs\n * };\n * };\n * ```\n */\nexport type MixedFactoryBuilder<\n\tAttrs = any,\n\tFactory = any,\n\tResult = any,\n\tDB = any,\n> = (attrs: Attrs, factory: Factory, db: DB) => Result | Promise<Result>;\n\n/**\n * Type definition for a factory seed function used to create complex test scenarios.\n * Seeds typically create multiple related records to set up a complete test environment.\n *\n * @template Attrs - The attributes/input type for the seed\n * @template Factory - The factory instance type\n * @template Result - The type of object returned by the seed\n * @template DB - The database connection type (Kysely, Knex, etc.)\n *\n * @param context - Object containing attrs, factory, and db\n * @param context.attrs - Configuration attributes for the seed\n * @param context.factory - The factory instance for creating records\n * @param context.db - The database connection\n * @returns A promise resolving to the seed result\n *\n * @example\n * ```typescript\n * const userWithPostsSeed: FactorySeed<{ postCount?: number }, Factory, User, DB> =\n * async ({ attrs, factory, db }) => {\n * const user = await factory.insert('user', attrs);\n * const postCount = attrs.postCount || 3;\n *\n * for (let i = 0; i < postCount; i++) {\n * await factory.insert('post', { userId: user.id });\n * }\n *\n * return user;\n * };\n * ```\n */\nexport type FactorySeed<\n\tAttrs = any,\n\tFactory = any,\n\tResult = any,\n\tDB = any,\n> = (context: { attrs: Attrs; factory: Factory; db: DB }) => Promise<Result>;\n\n/**\n * Helper type to extract the Attrs type from a FactorySeed function.\n * Used internally by Factory implementations to correctly type the seed method parameters.\n */\nexport type ExtractSeedAttrs<T> = T extends (context: {\n\tattrs: infer A;\n\tfactory: any;\n\tdb: any;\n}) => any\n\t? A\n\t: never;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,IAAsB,UAAtB,MAGE;;;;;;;;;;;;;;;;;CAiBD,OAAO,WAAqCA,QAAoB;AAC/D,SAAO;CACP;AAyCD"}
|