@geekmidas/testkit 10.0.0-alpha.98 → 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/dist/faker.cjs
CHANGED
|
@@ -1,314 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
let _faker_js_faker = require("@faker-js/faker");
|
|
3
|
-
//#region src/faker.ts
|
|
4
|
-
/**
|
|
5
|
-
* Atomic counter implementation for thread-safe sequence generation.
|
|
6
|
-
* Provides a clean abstraction for generating sequential numbers in tests.
|
|
7
|
-
* While JavaScript is single-threaded, this class makes the intent explicit.
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* ```typescript
|
|
11
|
-
* const counter = new AtomicCounter(100);
|
|
12
|
-
* console.log(counter.increment()); // 101
|
|
13
|
-
* console.log(counter.increment()); // 102
|
|
14
|
-
* console.log(counter.get()); // 102
|
|
15
|
-
* counter.reset(200);
|
|
16
|
-
* console.log(counter.increment()); // 201
|
|
17
|
-
* ```
|
|
18
|
-
*/
|
|
19
|
-
var AtomicCounter = class {
|
|
20
|
-
/**
|
|
21
|
-
* The current counter value.
|
|
22
|
-
* @private
|
|
23
|
-
*/
|
|
24
|
-
value;
|
|
25
|
-
/**
|
|
26
|
-
* Creates a new atomic counter.
|
|
27
|
-
* @param initialValue - The starting value (default: 0)
|
|
28
|
-
*/
|
|
29
|
-
constructor(initialValue = 0) {
|
|
30
|
-
this.value = initialValue;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Increments the counter and returns the new value.
|
|
34
|
-
* @returns The incremented value
|
|
35
|
-
*/
|
|
36
|
-
increment() {
|
|
37
|
-
return ++this.value;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Gets the current counter value without incrementing.
|
|
41
|
-
* @returns The current value
|
|
42
|
-
*/
|
|
43
|
-
get() {
|
|
44
|
-
return this.value;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Resets the counter to a specific value.
|
|
48
|
-
* @param value - The new value (default: 0)
|
|
49
|
-
*/
|
|
50
|
-
reset(value = 0) {
|
|
51
|
-
this.value = value;
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
/**
|
|
55
|
-
* Generates random timestamp fields for database records.
|
|
56
|
-
* Creates a createdAt date in the past and an updatedAt date between creation and now.
|
|
57
|
-
* Milliseconds are set to 0 for cleaner database storage.
|
|
58
|
-
*
|
|
59
|
-
* @returns Object with createdAt and updatedAt Date fields
|
|
60
|
-
*
|
|
61
|
-
* @example
|
|
62
|
-
* ```typescript
|
|
63
|
-
* const { createdAt, updatedAt } = timestamps();
|
|
64
|
-
* console.log(createdAt); // 2023-05-15T10:30:00.000Z
|
|
65
|
-
* console.log(updatedAt); // 2023-11-20T14:45:00.000Z
|
|
66
|
-
*
|
|
67
|
-
* // Use in factory
|
|
68
|
-
* const user = {
|
|
69
|
-
* name: 'John Doe',
|
|
70
|
-
* ...timestamps()
|
|
71
|
-
* };
|
|
72
|
-
* ```
|
|
73
|
-
*/
|
|
74
|
-
function timestamps() {
|
|
75
|
-
const createdAt = faker.date.past();
|
|
76
|
-
const updatedAt = faker.date.between({
|
|
77
|
-
from: createdAt,
|
|
78
|
-
to: /* @__PURE__ */ new Date()
|
|
79
|
-
});
|
|
80
|
-
createdAt.setMilliseconds(0);
|
|
81
|
-
updatedAt.setMilliseconds(0);
|
|
82
|
-
return {
|
|
83
|
-
createdAt,
|
|
84
|
-
updatedAt
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* Generates a reverse domain name identifier.
|
|
89
|
-
* Useful for creating unique identifiers that follow domain naming conventions.
|
|
90
|
-
*
|
|
91
|
-
* @param suffix - Optional suffix to append to the identifier
|
|
92
|
-
* @returns A reverse domain name string (e.g., "com.example.feature123")
|
|
93
|
-
*
|
|
94
|
-
* @example
|
|
95
|
-
* ```typescript
|
|
96
|
-
* console.log(identifier()); // "com.example.widget1"
|
|
97
|
-
* console.log(identifier('user')); // "org.acme.user"
|
|
98
|
-
* console.log(identifier('api')); // "net.demo.api"
|
|
99
|
-
* ```
|
|
100
|
-
*/
|
|
101
|
-
function identifier(suffix) {
|
|
102
|
-
return [
|
|
103
|
-
faker.internet.domainSuffix(),
|
|
104
|
-
faker.internet.domainWord(),
|
|
105
|
-
suffix ? suffix : faker.internet.domainWord() + sequence("identifier")
|
|
106
|
-
].join(".");
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* Storage for named sequence counters.
|
|
110
|
-
* Each sequence maintains its own independent counter.
|
|
111
|
-
* @private
|
|
112
|
-
*/
|
|
113
|
-
const sequences = /* @__PURE__ */ new Map();
|
|
114
|
-
/**
|
|
115
|
-
* Generates sequential numbers for a named sequence.
|
|
116
|
-
* Useful for creating unique IDs or numbered test data.
|
|
117
|
-
* Each named sequence maintains its own counter.
|
|
118
|
-
*
|
|
119
|
-
* @param name - The sequence name (default: 'default')
|
|
120
|
-
* @returns The next number in the sequence
|
|
121
|
-
*
|
|
122
|
-
* @example
|
|
123
|
-
* ```typescript
|
|
124
|
-
* console.log(sequence()); // 1
|
|
125
|
-
* console.log(sequence()); // 2
|
|
126
|
-
* console.log(sequence('user')); // 1
|
|
127
|
-
* console.log(sequence('user')); // 2
|
|
128
|
-
* console.log(sequence()); // 3
|
|
129
|
-
*
|
|
130
|
-
* // Use in factories
|
|
131
|
-
* const email = `user${sequence('email')}@example.com`;
|
|
132
|
-
* ```
|
|
133
|
-
*/
|
|
134
|
-
function sequence(name = "default") {
|
|
135
|
-
if (!sequences.has(name)) sequences.set(name, new AtomicCounter());
|
|
136
|
-
return sequences.get(name).increment();
|
|
137
|
-
}
|
|
138
|
-
/**
|
|
139
|
-
* Resets a named sequence counter to a specific value.
|
|
140
|
-
* Useful for resetting sequences between test suites.
|
|
141
|
-
*
|
|
142
|
-
* @param name - The sequence name to reset (default: 'default')
|
|
143
|
-
* @param value - The new starting value (default: 0)
|
|
144
|
-
*
|
|
145
|
-
* @example
|
|
146
|
-
* ```typescript
|
|
147
|
-
* sequence('user'); // 1
|
|
148
|
-
* sequence('user'); // 2
|
|
149
|
-
* resetSequence('user');
|
|
150
|
-
* sequence('user'); // 1
|
|
151
|
-
*
|
|
152
|
-
* resetSequence('order', 1000);
|
|
153
|
-
* sequence('order'); // 1001
|
|
154
|
-
* ```
|
|
155
|
-
*/
|
|
156
|
-
function resetSequence(name = "default", value = 0) {
|
|
157
|
-
if (sequences.has(name)) sequences.get(name).reset(value);
|
|
158
|
-
else sequences.set(name, new AtomicCounter(value));
|
|
159
|
-
}
|
|
160
|
-
/**
|
|
161
|
-
* Resets all sequence counters.
|
|
162
|
-
* Useful for cleaning up between test suites to ensure predictable sequences.
|
|
163
|
-
*
|
|
164
|
-
* @example
|
|
165
|
-
* ```typescript
|
|
166
|
-
* // In test setup
|
|
167
|
-
* beforeEach(() => {
|
|
168
|
-
* resetAllSequences();
|
|
169
|
-
* });
|
|
170
|
-
*
|
|
171
|
-
* it('starts sequences from 1', () => {
|
|
172
|
-
* expect(sequence()).toBe(1);
|
|
173
|
-
* expect(sequence('user')).toBe(1);
|
|
174
|
-
* });
|
|
175
|
-
* ```
|
|
176
|
-
*/
|
|
177
|
-
function resetAllSequences() {
|
|
178
|
-
sequences.clear();
|
|
179
|
-
}
|
|
180
|
-
/**
|
|
181
|
-
* Generates a random price as a number.
|
|
182
|
-
* Converts faker's string price to a numeric value.
|
|
183
|
-
*
|
|
184
|
-
* @returns A random price number
|
|
185
|
-
*
|
|
186
|
-
* @example
|
|
187
|
-
* ```typescript
|
|
188
|
-
* const productPrice = price(); // 29.99
|
|
189
|
-
* const total = price() * quantity; // Numeric calculation
|
|
190
|
-
* ```
|
|
191
|
-
*/
|
|
192
|
-
function price() {
|
|
193
|
-
return +faker.commerce.price();
|
|
194
|
-
}
|
|
195
|
-
/**
|
|
196
|
-
* A birthdate for someone of the given age today: exactly `min` years old, or
|
|
197
|
-
* anywhere from `min` to `max` inclusive.
|
|
198
|
-
*
|
|
199
|
-
* Through faker's own `date.birthdate`, so seeding faker makes it repeatable.
|
|
200
|
-
*
|
|
201
|
-
* @param min - The youngest age, in whole years
|
|
202
|
-
* @param max - The oldest age, in whole years (default: `min`)
|
|
203
|
-
* @returns The birthdate
|
|
204
|
-
*
|
|
205
|
-
* @example
|
|
206
|
-
* ```typescript
|
|
207
|
-
* faker.age(18); // someone who is 18 today
|
|
208
|
-
* faker.age(18, 24); // someone aged 18 to 24
|
|
209
|
-
* ```
|
|
210
|
-
*/
|
|
211
|
-
function age(min, max = min) {
|
|
212
|
-
if (min < 0 || max < min) throw new AgeRangeInvalid(min, max);
|
|
213
|
-
return _faker_js_faker.faker.date.birthdate({
|
|
214
|
-
mode: "age",
|
|
215
|
-
min,
|
|
216
|
-
max
|
|
217
|
-
});
|
|
218
|
-
}
|
|
219
|
-
/** An age range no one can be: a negative age, or an oldest below a youngest. */
|
|
220
|
-
var AgeRangeInvalid = class extends Error {
|
|
221
|
-
min;
|
|
222
|
-
max;
|
|
223
|
-
constructor(min, max) {
|
|
224
|
-
super(`faker.age(${min}, ${max}) asks for an age no one can be. Pass the youngest age first and the oldest second, neither negative: faker.age(18) or faker.age(18, 24).`);
|
|
225
|
-
this.min = min;
|
|
226
|
-
this.max = max;
|
|
227
|
-
this.name = "AgeRangeInvalid";
|
|
228
|
-
}
|
|
229
|
-
};
|
|
230
|
-
function coordinateInRadius(center, radius) {
|
|
231
|
-
const d = radius / 6378137;
|
|
232
|
-
const theta = 2 * Math.PI * Math.random();
|
|
233
|
-
const r = d * Math.sqrt(Math.random());
|
|
234
|
-
const lat1 = center.lat * Math.PI / 180;
|
|
235
|
-
const lng1 = center.lng * Math.PI / 180;
|
|
236
|
-
const lat2 = Math.asin(Math.sin(lat1) * Math.cos(r) + Math.cos(lat1) * Math.sin(r) * Math.cos(theta));
|
|
237
|
-
const lng2 = lng1 + Math.atan2(Math.sin(theta) * Math.sin(r) * Math.cos(lat1), Math.cos(r) - Math.sin(lat1) * Math.sin(lat2));
|
|
238
|
-
return {
|
|
239
|
-
lat: lat2 * 180 / Math.PI,
|
|
240
|
-
lng: lng2 * 180 / Math.PI
|
|
241
|
-
};
|
|
242
|
-
}
|
|
243
|
-
function coordinateOutsideRadius(center, minRadiusMeters, maxRadiusMeters) {
|
|
244
|
-
const earth = 6378137;
|
|
245
|
-
const minD = minRadiusMeters / earth;
|
|
246
|
-
const maxD = maxRadiusMeters / earth;
|
|
247
|
-
const theta = 2 * Math.PI * Math.random();
|
|
248
|
-
const r = Math.sqrt(minD * minD + (maxD * maxD - minD * minD) * Math.random());
|
|
249
|
-
const lat1 = center.lat * Math.PI / 180;
|
|
250
|
-
const lng1 = center.lng * Math.PI / 180;
|
|
251
|
-
const lat2 = Math.asin(Math.sin(lat1) * Math.cos(r) + Math.cos(lat1) * Math.sin(r) * Math.cos(theta));
|
|
252
|
-
const normalizedLng = ((lng1 + Math.atan2(Math.sin(theta) * Math.sin(r) * Math.cos(lat1), Math.cos(r) - Math.sin(lat1) * Math.sin(lat2))) * 180 / Math.PI + 540) % 360 - 180;
|
|
253
|
-
return {
|
|
254
|
-
lat: lat2 * 180 / Math.PI,
|
|
255
|
-
lng: normalizedLng
|
|
256
|
-
};
|
|
257
|
-
}
|
|
258
|
-
/**
|
|
259
|
-
* Enhanced faker instance with additional utility methods for testing.
|
|
260
|
-
* Extends @faker-js/faker with custom methods for common test data generation patterns.
|
|
261
|
-
*
|
|
262
|
-
* @example
|
|
263
|
-
* ```typescript
|
|
264
|
-
* import { faker } from '@geekmidas/testkit';
|
|
265
|
-
*
|
|
266
|
-
* // Use standard faker methods
|
|
267
|
-
* const name = faker.person.fullName();
|
|
268
|
-
* const email = faker.internet.email();
|
|
269
|
-
*
|
|
270
|
-
* // Use custom extensions
|
|
271
|
-
* const { createdAt, updatedAt } = faker.timestamps();
|
|
272
|
-
* const id = faker.identifier('user');
|
|
273
|
-
* const orderNumber = faker.sequence('order');
|
|
274
|
-
* const productPrice = faker.price();
|
|
275
|
-
* ```
|
|
276
|
-
*/
|
|
277
|
-
/**
|
|
278
|
-
* `faker.internet`, with every address lowercase.
|
|
279
|
-
*
|
|
280
|
-
* An auth server stores addresses lowercased — Better Auth does — so a test
|
|
281
|
-
* that signs in as faker's `Ada.Lovelace@…` and reads back `ada.lovelace@…`
|
|
282
|
-
* fails only when faker happened to capitalise: a flake, not a bug. The rest
|
|
283
|
-
* of the module is faker's own, through the prototype.
|
|
284
|
-
*/
|
|
285
|
-
const internet = Object.assign(Object.create(_faker_js_faker.faker.internet), {
|
|
286
|
-
email: (...args) => _faker_js_faker.faker.internet.email(...args).toLowerCase(),
|
|
287
|
-
exampleEmail: (...args) => _faker_js_faker.faker.internet.exampleEmail(...args).toLowerCase()
|
|
288
|
-
});
|
|
289
|
-
const faker = Object.freeze(Object.assign({}, _faker_js_faker.faker, {
|
|
290
|
-
internet,
|
|
291
|
-
seed: (seed) => _faker_js_faker.faker.seed(seed),
|
|
292
|
-
timestamps,
|
|
293
|
-
identifier,
|
|
294
|
-
sequence,
|
|
295
|
-
resetSequence,
|
|
296
|
-
resetAllSequences,
|
|
297
|
-
price,
|
|
298
|
-
age,
|
|
299
|
-
coordinates: {
|
|
300
|
-
within: coordinateInRadius,
|
|
301
|
-
outside: coordinateOutsideRadius
|
|
302
|
-
}
|
|
303
|
-
}));
|
|
304
|
-
//#endregion
|
|
305
|
-
exports.AgeRangeInvalid = AgeRangeInvalid;
|
|
306
|
-
exports.coordinateInRadius = coordinateInRadius;
|
|
307
|
-
exports.faker = faker;
|
|
308
|
-
exports.identifier = identifier;
|
|
309
|
-
exports.resetAllSequences = resetAllSequences;
|
|
310
|
-
exports.resetSequence = resetSequence;
|
|
311
|
-
exports.sequence = sequence;
|
|
312
|
-
exports.timestamps = timestamps;
|
|
1
|
+
const require_faker = require('./faker-B14IEMIN.cjs');
|
|
313
2
|
|
|
314
|
-
|
|
3
|
+
exports.coordinateInRadius = require_faker.coordinateInRadius;
|
|
4
|
+
exports.faker = require_faker.faker;
|
|
5
|
+
exports.identifier = require_faker.identifier;
|
|
6
|
+
exports.resetAllSequences = require_faker.resetAllSequences;
|
|
7
|
+
exports.resetSequence = require_faker.resetSequence;
|
|
8
|
+
exports.sequence = require_faker.sequence;
|
|
9
|
+
exports.timestamps = require_faker.timestamps;
|
package/dist/faker.d.cts
CHANGED
|
@@ -1,169 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
* Generates random timestamp fields for database records.
|
|
4
|
-
* Creates a createdAt date in the past and an updatedAt date between creation and now.
|
|
5
|
-
* Milliseconds are set to 0 for cleaner database storage.
|
|
6
|
-
*
|
|
7
|
-
* @returns Object with createdAt and updatedAt Date fields
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* ```typescript
|
|
11
|
-
* const { createdAt, updatedAt } = timestamps();
|
|
12
|
-
* console.log(createdAt); // 2023-05-15T10:30:00.000Z
|
|
13
|
-
* console.log(updatedAt); // 2023-11-20T14:45:00.000Z
|
|
14
|
-
*
|
|
15
|
-
* // Use in factory
|
|
16
|
-
* const user = {
|
|
17
|
-
* name: 'John Doe',
|
|
18
|
-
* ...timestamps()
|
|
19
|
-
* };
|
|
20
|
-
* ```
|
|
21
|
-
*/
|
|
22
|
-
export declare function timestamps(): Timestamps;
|
|
23
|
-
/**
|
|
24
|
-
* Generates a reverse domain name identifier.
|
|
25
|
-
* Useful for creating unique identifiers that follow domain naming conventions.
|
|
26
|
-
*
|
|
27
|
-
* @param suffix - Optional suffix to append to the identifier
|
|
28
|
-
* @returns A reverse domain name string (e.g., "com.example.feature123")
|
|
29
|
-
*
|
|
30
|
-
* @example
|
|
31
|
-
* ```typescript
|
|
32
|
-
* console.log(identifier()); // "com.example.widget1"
|
|
33
|
-
* console.log(identifier('user')); // "org.acme.user"
|
|
34
|
-
* console.log(identifier('api')); // "net.demo.api"
|
|
35
|
-
* ```
|
|
36
|
-
*/
|
|
37
|
-
export declare function identifier(suffix?: string): string;
|
|
38
|
-
/**
|
|
39
|
-
* Generates sequential numbers for a named sequence.
|
|
40
|
-
* Useful for creating unique IDs or numbered test data.
|
|
41
|
-
* Each named sequence maintains its own counter.
|
|
42
|
-
*
|
|
43
|
-
* @param name - The sequence name (default: 'default')
|
|
44
|
-
* @returns The next number in the sequence
|
|
45
|
-
*
|
|
46
|
-
* @example
|
|
47
|
-
* ```typescript
|
|
48
|
-
* console.log(sequence()); // 1
|
|
49
|
-
* console.log(sequence()); // 2
|
|
50
|
-
* console.log(sequence('user')); // 1
|
|
51
|
-
* console.log(sequence('user')); // 2
|
|
52
|
-
* console.log(sequence()); // 3
|
|
53
|
-
*
|
|
54
|
-
* // Use in factories
|
|
55
|
-
* const email = `user${sequence('email')}@example.com`;
|
|
56
|
-
* ```
|
|
57
|
-
*/
|
|
58
|
-
export declare function sequence(name?: string): number;
|
|
59
|
-
/**
|
|
60
|
-
* Resets a named sequence counter to a specific value.
|
|
61
|
-
* Useful for resetting sequences between test suites.
|
|
62
|
-
*
|
|
63
|
-
* @param name - The sequence name to reset (default: 'default')
|
|
64
|
-
* @param value - The new starting value (default: 0)
|
|
65
|
-
*
|
|
66
|
-
* @example
|
|
67
|
-
* ```typescript
|
|
68
|
-
* sequence('user'); // 1
|
|
69
|
-
* sequence('user'); // 2
|
|
70
|
-
* resetSequence('user');
|
|
71
|
-
* sequence('user'); // 1
|
|
72
|
-
*
|
|
73
|
-
* resetSequence('order', 1000);
|
|
74
|
-
* sequence('order'); // 1001
|
|
75
|
-
* ```
|
|
76
|
-
*/
|
|
77
|
-
export declare function resetSequence(name?: string, value?: number): void;
|
|
78
|
-
/**
|
|
79
|
-
* Resets all sequence counters.
|
|
80
|
-
* Useful for cleaning up between test suites to ensure predictable sequences.
|
|
81
|
-
*
|
|
82
|
-
* @example
|
|
83
|
-
* ```typescript
|
|
84
|
-
* // In test setup
|
|
85
|
-
* beforeEach(() => {
|
|
86
|
-
* resetAllSequences();
|
|
87
|
-
* });
|
|
88
|
-
*
|
|
89
|
-
* it('starts sequences from 1', () => {
|
|
90
|
-
* expect(sequence()).toBe(1);
|
|
91
|
-
* expect(sequence('user')).toBe(1);
|
|
92
|
-
* });
|
|
93
|
-
* ```
|
|
94
|
-
*/
|
|
95
|
-
export declare function resetAllSequences(): void;
|
|
96
|
-
/**
|
|
97
|
-
* Generates a random price as a number.
|
|
98
|
-
* Converts faker's string price to a numeric value.
|
|
99
|
-
*
|
|
100
|
-
* @returns A random price number
|
|
101
|
-
*
|
|
102
|
-
* @example
|
|
103
|
-
* ```typescript
|
|
104
|
-
* const productPrice = price(); // 29.99
|
|
105
|
-
* const total = price() * quantity; // Numeric calculation
|
|
106
|
-
* ```
|
|
107
|
-
*/
|
|
108
|
-
declare function price(): number;
|
|
109
|
-
/**
|
|
110
|
-
* A birthdate for someone of the given age today: exactly `min` years old, or
|
|
111
|
-
* anywhere from `min` to `max` inclusive.
|
|
112
|
-
*
|
|
113
|
-
* Through faker's own `date.birthdate`, so seeding faker makes it repeatable.
|
|
114
|
-
*
|
|
115
|
-
* @param min - The youngest age, in whole years
|
|
116
|
-
* @param max - The oldest age, in whole years (default: `min`)
|
|
117
|
-
* @returns The birthdate
|
|
118
|
-
*
|
|
119
|
-
* @example
|
|
120
|
-
* ```typescript
|
|
121
|
-
* faker.age(18); // someone who is 18 today
|
|
122
|
-
* faker.age(18, 24); // someone aged 18 to 24
|
|
123
|
-
* ```
|
|
124
|
-
*/
|
|
125
|
-
declare function age(min: number, max?: number): Date;
|
|
126
|
-
/** An age range no one can be: a negative age, or an oldest below a youngest. */
|
|
127
|
-
export declare class AgeRangeInvalid extends Error {
|
|
128
|
-
readonly min: number;
|
|
129
|
-
readonly max: number;
|
|
130
|
-
constructor(min: number, max: number);
|
|
131
|
-
}
|
|
132
|
-
type Coordinate = {
|
|
133
|
-
lat: number;
|
|
134
|
-
lng: number;
|
|
135
|
-
};
|
|
136
|
-
export declare function coordinateInRadius(center: Coordinate, radius: number): Coordinate;
|
|
137
|
-
declare function coordinateOutsideRadius(center: Coordinate, minRadiusMeters: number, maxRadiusMeters: number): Coordinate;
|
|
138
|
-
export declare const faker: Readonly<import("@faker-js/faker").Faker & {
|
|
139
|
-
internet: import("@faker-js/faker").InternetModule;
|
|
140
|
-
seed: (seed?: number) => number;
|
|
141
|
-
timestamps: typeof timestamps;
|
|
142
|
-
identifier: typeof identifier;
|
|
143
|
-
sequence: typeof sequence;
|
|
144
|
-
resetSequence: typeof resetSequence;
|
|
145
|
-
resetAllSequences: typeof resetAllSequences;
|
|
146
|
-
price: typeof price;
|
|
147
|
-
age: typeof age;
|
|
148
|
-
coordinates: {
|
|
149
|
-
within: typeof coordinateInRadius;
|
|
150
|
-
outside: typeof coordinateOutsideRadius;
|
|
151
|
-
};
|
|
152
|
-
}>;
|
|
153
|
-
/**
|
|
154
|
-
* Type definition for timestamp fields.
|
|
155
|
-
* Used by the timestamps() function to generate date fields.
|
|
156
|
-
*/
|
|
157
|
-
export type Timestamps = {
|
|
158
|
-
/** The creation date */
|
|
159
|
-
createdAt: Date;
|
|
160
|
-
/** The last update date */
|
|
161
|
-
updatedAt: Date;
|
|
162
|
-
};
|
|
163
|
-
/**
|
|
164
|
-
* Type definition for the enhanced faker factory.
|
|
165
|
-
* Includes all standard faker methods plus custom extensions.
|
|
166
|
-
*/
|
|
167
|
-
export type FakerFactory = typeof faker;
|
|
168
|
-
//#endregion
|
|
169
|
-
//# sourceMappingURL=faker.d.cts.map
|
|
1
|
+
import { FakerFactory, Timestamps, coordinateInRadius, faker, identifier, resetAllSequences, resetSequence, sequence, timestamps } from "./faker-Cg76aFNO.cjs";
|
|
2
|
+
export { FakerFactory, Timestamps, coordinateInRadius, faker, identifier, resetAllSequences, resetSequence, sequence, timestamps };
|
package/dist/faker.d.mts
CHANGED
|
@@ -1,169 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
* Generates random timestamp fields for database records.
|
|
4
|
-
* Creates a createdAt date in the past and an updatedAt date between creation and now.
|
|
5
|
-
* Milliseconds are set to 0 for cleaner database storage.
|
|
6
|
-
*
|
|
7
|
-
* @returns Object with createdAt and updatedAt Date fields
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* ```typescript
|
|
11
|
-
* const { createdAt, updatedAt } = timestamps();
|
|
12
|
-
* console.log(createdAt); // 2023-05-15T10:30:00.000Z
|
|
13
|
-
* console.log(updatedAt); // 2023-11-20T14:45:00.000Z
|
|
14
|
-
*
|
|
15
|
-
* // Use in factory
|
|
16
|
-
* const user = {
|
|
17
|
-
* name: 'John Doe',
|
|
18
|
-
* ...timestamps()
|
|
19
|
-
* };
|
|
20
|
-
* ```
|
|
21
|
-
*/
|
|
22
|
-
export declare function timestamps(): Timestamps;
|
|
23
|
-
/**
|
|
24
|
-
* Generates a reverse domain name identifier.
|
|
25
|
-
* Useful for creating unique identifiers that follow domain naming conventions.
|
|
26
|
-
*
|
|
27
|
-
* @param suffix - Optional suffix to append to the identifier
|
|
28
|
-
* @returns A reverse domain name string (e.g., "com.example.feature123")
|
|
29
|
-
*
|
|
30
|
-
* @example
|
|
31
|
-
* ```typescript
|
|
32
|
-
* console.log(identifier()); // "com.example.widget1"
|
|
33
|
-
* console.log(identifier('user')); // "org.acme.user"
|
|
34
|
-
* console.log(identifier('api')); // "net.demo.api"
|
|
35
|
-
* ```
|
|
36
|
-
*/
|
|
37
|
-
export declare function identifier(suffix?: string): string;
|
|
38
|
-
/**
|
|
39
|
-
* Generates sequential numbers for a named sequence.
|
|
40
|
-
* Useful for creating unique IDs or numbered test data.
|
|
41
|
-
* Each named sequence maintains its own counter.
|
|
42
|
-
*
|
|
43
|
-
* @param name - The sequence name (default: 'default')
|
|
44
|
-
* @returns The next number in the sequence
|
|
45
|
-
*
|
|
46
|
-
* @example
|
|
47
|
-
* ```typescript
|
|
48
|
-
* console.log(sequence()); // 1
|
|
49
|
-
* console.log(sequence()); // 2
|
|
50
|
-
* console.log(sequence('user')); // 1
|
|
51
|
-
* console.log(sequence('user')); // 2
|
|
52
|
-
* console.log(sequence()); // 3
|
|
53
|
-
*
|
|
54
|
-
* // Use in factories
|
|
55
|
-
* const email = `user${sequence('email')}@example.com`;
|
|
56
|
-
* ```
|
|
57
|
-
*/
|
|
58
|
-
export declare function sequence(name?: string): number;
|
|
59
|
-
/**
|
|
60
|
-
* Resets a named sequence counter to a specific value.
|
|
61
|
-
* Useful for resetting sequences between test suites.
|
|
62
|
-
*
|
|
63
|
-
* @param name - The sequence name to reset (default: 'default')
|
|
64
|
-
* @param value - The new starting value (default: 0)
|
|
65
|
-
*
|
|
66
|
-
* @example
|
|
67
|
-
* ```typescript
|
|
68
|
-
* sequence('user'); // 1
|
|
69
|
-
* sequence('user'); // 2
|
|
70
|
-
* resetSequence('user');
|
|
71
|
-
* sequence('user'); // 1
|
|
72
|
-
*
|
|
73
|
-
* resetSequence('order', 1000);
|
|
74
|
-
* sequence('order'); // 1001
|
|
75
|
-
* ```
|
|
76
|
-
*/
|
|
77
|
-
export declare function resetSequence(name?: string, value?: number): void;
|
|
78
|
-
/**
|
|
79
|
-
* Resets all sequence counters.
|
|
80
|
-
* Useful for cleaning up between test suites to ensure predictable sequences.
|
|
81
|
-
*
|
|
82
|
-
* @example
|
|
83
|
-
* ```typescript
|
|
84
|
-
* // In test setup
|
|
85
|
-
* beforeEach(() => {
|
|
86
|
-
* resetAllSequences();
|
|
87
|
-
* });
|
|
88
|
-
*
|
|
89
|
-
* it('starts sequences from 1', () => {
|
|
90
|
-
* expect(sequence()).toBe(1);
|
|
91
|
-
* expect(sequence('user')).toBe(1);
|
|
92
|
-
* });
|
|
93
|
-
* ```
|
|
94
|
-
*/
|
|
95
|
-
export declare function resetAllSequences(): void;
|
|
96
|
-
/**
|
|
97
|
-
* Generates a random price as a number.
|
|
98
|
-
* Converts faker's string price to a numeric value.
|
|
99
|
-
*
|
|
100
|
-
* @returns A random price number
|
|
101
|
-
*
|
|
102
|
-
* @example
|
|
103
|
-
* ```typescript
|
|
104
|
-
* const productPrice = price(); // 29.99
|
|
105
|
-
* const total = price() * quantity; // Numeric calculation
|
|
106
|
-
* ```
|
|
107
|
-
*/
|
|
108
|
-
declare function price(): number;
|
|
109
|
-
/**
|
|
110
|
-
* A birthdate for someone of the given age today: exactly `min` years old, or
|
|
111
|
-
* anywhere from `min` to `max` inclusive.
|
|
112
|
-
*
|
|
113
|
-
* Through faker's own `date.birthdate`, so seeding faker makes it repeatable.
|
|
114
|
-
*
|
|
115
|
-
* @param min - The youngest age, in whole years
|
|
116
|
-
* @param max - The oldest age, in whole years (default: `min`)
|
|
117
|
-
* @returns The birthdate
|
|
118
|
-
*
|
|
119
|
-
* @example
|
|
120
|
-
* ```typescript
|
|
121
|
-
* faker.age(18); // someone who is 18 today
|
|
122
|
-
* faker.age(18, 24); // someone aged 18 to 24
|
|
123
|
-
* ```
|
|
124
|
-
*/
|
|
125
|
-
declare function age(min: number, max?: number): Date;
|
|
126
|
-
/** An age range no one can be: a negative age, or an oldest below a youngest. */
|
|
127
|
-
export declare class AgeRangeInvalid extends Error {
|
|
128
|
-
readonly min: number;
|
|
129
|
-
readonly max: number;
|
|
130
|
-
constructor(min: number, max: number);
|
|
131
|
-
}
|
|
132
|
-
type Coordinate = {
|
|
133
|
-
lat: number;
|
|
134
|
-
lng: number;
|
|
135
|
-
};
|
|
136
|
-
export declare function coordinateInRadius(center: Coordinate, radius: number): Coordinate;
|
|
137
|
-
declare function coordinateOutsideRadius(center: Coordinate, minRadiusMeters: number, maxRadiusMeters: number): Coordinate;
|
|
138
|
-
export declare const faker: Readonly<import("@faker-js/faker").Faker & {
|
|
139
|
-
internet: import("@faker-js/faker").InternetModule;
|
|
140
|
-
seed: (seed?: number) => number;
|
|
141
|
-
timestamps: typeof timestamps;
|
|
142
|
-
identifier: typeof identifier;
|
|
143
|
-
sequence: typeof sequence;
|
|
144
|
-
resetSequence: typeof resetSequence;
|
|
145
|
-
resetAllSequences: typeof resetAllSequences;
|
|
146
|
-
price: typeof price;
|
|
147
|
-
age: typeof age;
|
|
148
|
-
coordinates: {
|
|
149
|
-
within: typeof coordinateInRadius;
|
|
150
|
-
outside: typeof coordinateOutsideRadius;
|
|
151
|
-
};
|
|
152
|
-
}>;
|
|
153
|
-
/**
|
|
154
|
-
* Type definition for timestamp fields.
|
|
155
|
-
* Used by the timestamps() function to generate date fields.
|
|
156
|
-
*/
|
|
157
|
-
export type Timestamps = {
|
|
158
|
-
/** The creation date */
|
|
159
|
-
createdAt: Date;
|
|
160
|
-
/** The last update date */
|
|
161
|
-
updatedAt: Date;
|
|
162
|
-
};
|
|
163
|
-
/**
|
|
164
|
-
* Type definition for the enhanced faker factory.
|
|
165
|
-
* Includes all standard faker methods plus custom extensions.
|
|
166
|
-
*/
|
|
167
|
-
export type FakerFactory = typeof faker;
|
|
168
|
-
//#endregion
|
|
169
|
-
//# sourceMappingURL=faker.d.mts.map
|
|
1
|
+
import { FakerFactory, Timestamps, coordinateInRadius, faker, identifier, resetAllSequences, resetSequence, sequence, timestamps } from "./faker-DHh7xs4u.mjs";
|
|
2
|
+
export { FakerFactory, Timestamps, coordinateInRadius, faker, identifier, resetAllSequences, resetSequence, sequence, timestamps };
|