@geekmidas/testkit 10.0.0-alpha.4 → 10.0.0-alpha.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +74 -0
- package/dist/Factory.cjs +51 -2
- package/dist/Factory.cjs.map +1 -0
- package/dist/Factory.d.cts +143 -3
- package/dist/Factory.d.cts.map +1 -0
- package/dist/Factory.d.mts +143 -3
- package/dist/Factory.d.mts.map +1 -0
- package/dist/Factory.mjs +50 -2
- package/dist/Factory.mjs.map +1 -0
- package/dist/KyselyFactory.cjs +237 -4
- package/dist/KyselyFactory.cjs.map +1 -0
- package/dist/KyselyFactory.d.cts +224 -4
- package/dist/KyselyFactory.d.cts.map +1 -0
- package/dist/KyselyFactory.d.mts +224 -4
- package/dist/KyselyFactory.d.mts.map +1 -0
- package/dist/KyselyFactory.mjs +236 -4
- package/dist/KyselyFactory.mjs.map +1 -0
- package/dist/ObjectionFactory.cjs +265 -4
- package/dist/ObjectionFactory.cjs.map +1 -0
- package/dist/ObjectionFactory.d.cts +237 -4
- package/dist/ObjectionFactory.d.cts.map +1 -0
- package/dist/ObjectionFactory.d.mts +237 -4
- package/dist/ObjectionFactory.d.mts.map +1 -0
- package/dist/ObjectionFactory.mjs +264 -4
- package/dist/ObjectionFactory.mjs.map +1 -0
- package/dist/PostgresKyselyMigrator.cjs +94 -3
- package/dist/PostgresKyselyMigrator.cjs.map +1 -0
- package/dist/PostgresKyselyMigrator.d.cts +80 -3
- package/dist/PostgresKyselyMigrator.d.cts.map +1 -0
- package/dist/PostgresKyselyMigrator.d.mts +80 -3
- package/dist/PostgresKyselyMigrator.d.mts.map +1 -0
- package/dist/PostgresKyselyMigrator.mjs +93 -3
- package/dist/PostgresKyselyMigrator.mjs.map +1 -0
- package/dist/{PostgresMigrator-C_QQ6q35.d.mts → PostgresMigrator-CDPnnwMJ.d.cts} +11 -5
- package/dist/PostgresMigrator-CDPnnwMJ.d.cts.map +1 -0
- package/dist/{PostgresMigrator-CeYy-eHF.d.cts → PostgresMigrator-CDPnnwMJ.d.mts} +11 -5
- package/dist/PostgresMigrator-CDPnnwMJ.d.mts.map +1 -0
- package/dist/PostgresMigrator.cjs +178 -2
- package/dist/PostgresMigrator.cjs.map +1 -0
- package/dist/PostgresMigrator.d.cts +1 -1
- package/dist/PostgresMigrator.d.mts +1 -1
- package/dist/PostgresMigrator.mjs +175 -2
- package/dist/PostgresMigrator.mjs.map +1 -0
- package/dist/PostgresObjectionMigrator.cjs +118 -3
- package/dist/PostgresObjectionMigrator.cjs.map +1 -0
- package/dist/PostgresObjectionMigrator.d.cts +75 -3
- package/dist/PostgresObjectionMigrator.d.cts.map +1 -0
- package/dist/PostgresObjectionMigrator.d.mts +75 -3
- package/dist/PostgresObjectionMigrator.d.mts.map +1 -0
- package/dist/PostgresObjectionMigrator.mjs +117 -3
- package/dist/PostgresObjectionMigrator.mjs.map +1 -0
- package/dist/VitestKyselyTransactionIsolator.cjs +66 -3
- package/dist/VitestKyselyTransactionIsolator.cjs.map +1 -0
- package/dist/VitestKyselyTransactionIsolator.d.cts +60 -3
- package/dist/VitestKyselyTransactionIsolator.d.cts.map +1 -0
- package/dist/VitestKyselyTransactionIsolator.d.mts +60 -3
- package/dist/VitestKyselyTransactionIsolator.d.mts.map +1 -0
- package/dist/VitestKyselyTransactionIsolator.mjs +65 -3
- package/dist/VitestKyselyTransactionIsolator.mjs.map +1 -0
- package/dist/VitestObjectionTransactionIsolator.cjs +62 -3
- package/dist/VitestObjectionTransactionIsolator.cjs.map +1 -0
- package/dist/VitestObjectionTransactionIsolator.d.cts +56 -3
- package/dist/VitestObjectionTransactionIsolator.d.cts.map +1 -0
- package/dist/VitestObjectionTransactionIsolator.d.mts +56 -3
- package/dist/VitestObjectionTransactionIsolator.d.mts.map +1 -0
- package/dist/VitestObjectionTransactionIsolator.mjs +61 -3
- package/dist/VitestObjectionTransactionIsolator.mjs.map +1 -0
- package/dist/VitestTransactionIsolator.cjs +187 -4
- package/dist/VitestTransactionIsolator.cjs.map +1 -0
- package/dist/VitestTransactionIsolator.d.cts +219 -2
- package/dist/VitestTransactionIsolator.d.cts.map +1 -0
- package/dist/VitestTransactionIsolator.d.mts +219 -2
- package/dist/VitestTransactionIsolator.d.mts.map +1 -0
- package/dist/VitestTransactionIsolator.mjs +184 -2
- package/dist/VitestTransactionIsolator.mjs.map +1 -0
- package/dist/aws.cjs +3 -4
- package/dist/aws.cjs.map +1 -1
- package/dist/aws.d.cts +3 -8
- package/dist/aws.d.cts.map +1 -1
- package/dist/aws.d.mts +3 -8
- package/dist/aws.d.mts.map +1 -1
- package/dist/aws.mjs +1 -2
- 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 +4 -6
- package/dist/benchmark.d.cts.map +1 -1
- package/dist/benchmark.d.mts +4 -6
- 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 +17 -8
- package/dist/better-auth.cjs.map +1 -1
- package/dist/better-auth.d.cts +13142 -5
- package/dist/better-auth.d.cts.map +1 -1
- package/dist/better-auth.d.mts +13142 -5
- package/dist/better-auth.d.mts.map +1 -1
- package/dist/better-auth.mjs +15 -6
- package/dist/better-auth.mjs.map +1 -1
- package/dist/browser.cjs +127 -0
- package/dist/browser.cjs.map +1 -0
- package/dist/browser.d.cts +47 -0
- package/dist/browser.d.cts.map +1 -0
- package/dist/browser.d.mts +47 -0
- package/dist/browser.d.mts.map +1 -0
- package/dist/browser.mjs +125 -0
- package/dist/browser.mjs.map +1 -0
- package/dist/context.cjs +80 -0
- package/dist/context.cjs.map +1 -0
- package/dist/context.d.cts +55 -0
- package/dist/context.d.cts.map +1 -0
- package/dist/context.d.mts +55 -0
- package/dist/context.d.mts.map +1 -0
- package/dist/context.mjs +73 -0
- package/dist/context.mjs.map +1 -0
- package/dist/faker.cjs +313 -8
- package/dist/faker.cjs.map +1 -0
- package/dist/faker.d.cts +169 -2
- package/dist/faker.d.cts.map +1 -0
- package/dist/faker.d.mts +169 -2
- package/dist/faker.d.mts.map +1 -0
- package/dist/faker.mjs +305 -2
- package/dist/faker.mjs.map +1 -0
- package/dist/helpers.cjs +6 -5
- package/dist/helpers.cjs.map +1 -1
- package/dist/helpers.d.cts +1 -5
- package/dist/helpers.d.cts.map +1 -1
- package/dist/helpers.d.mts +1 -5
- package/dist/helpers.d.mts.map +1 -1
- package/dist/helpers.mjs +1 -2
- 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 +2 -4
- package/dist/initScript.d.cts.map +1 -1
- package/dist/initScript.d.mts +2 -4
- package/dist/initScript.d.mts.map +1 -1
- package/dist/initScript.mjs +10 -12
- package/dist/initScript.mjs.map +1 -1
- package/dist/kysely.cjs +10 -13
- package/dist/kysely.cjs.map +1 -1
- package/dist/kysely.d.cts +10 -14
- package/dist/kysely.d.cts.map +1 -1
- package/dist/kysely.d.mts +10 -14
- package/dist/kysely.d.mts.map +1 -1
- package/dist/kysely.mjs +10 -14
- package/dist/kysely.mjs.map +1 -1
- package/dist/logger.cjs +3 -4
- package/dist/logger.cjs.map +1 -1
- package/dist/logger.d.cts +1 -5
- package/dist/logger.d.cts.map +1 -1
- package/dist/logger.d.mts +1 -5
- package/dist/logger.d.mts.map +1 -1
- package/dist/logger.mjs +1 -2
- package/dist/logger.mjs.map +1 -1
- package/dist/mailbox.cjs +95 -0
- package/dist/mailbox.cjs.map +1 -0
- package/dist/mailbox.d.cts +58 -0
- package/dist/mailbox.d.cts.map +1 -0
- package/dist/mailbox.d.mts +58 -0
- package/dist/mailbox.d.mts.map +1 -0
- package/dist/mailbox.mjs +92 -0
- package/dist/mailbox.mjs.map +1 -0
- package/dist/objection.cjs +10 -13
- package/dist/objection.cjs.map +1 -1
- package/dist/objection.d.cts +10 -14
- package/dist/objection.d.cts.map +1 -1
- package/dist/objection.d.mts +10 -14
- package/dist/objection.d.mts.map +1 -1
- package/dist/objection.mjs +10 -14
- package/dist/objection.mjs.map +1 -1
- package/dist/os/directory.cjs +31 -2
- package/dist/os/directory.cjs.map +1 -0
- package/dist/os/directory.d.cts +9 -2
- package/dist/os/directory.d.cts.map +1 -0
- package/dist/os/directory.d.mts +9 -2
- package/dist/os/directory.d.mts.map +1 -0
- package/dist/os/directory.mjs +25 -2
- package/dist/os/directory.mjs.map +1 -0
- 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 +2 -3
- package/dist/requestContext.cjs +10 -11
- package/dist/requestContext.cjs.map +1 -1
- package/dist/requestContext.d.cts +4 -8
- package/dist/requestContext.d.cts.map +1 -1
- package/dist/requestContext.d.mts +4 -8
- package/dist/requestContext.d.mts.map +1 -1
- package/dist/requestContext.mjs +1 -2
- package/dist/requestContext.mjs.map +1 -1
- package/dist/{chunk-CUT6urMc.cjs → rolldown-runtime-VH7oDXx4.cjs} +8 -10
- package/dist/timer.cjs +2 -2
- package/dist/timer.cjs.map +1 -1
- package/dist/timer.d.cts +1 -4
- package/dist/timer.d.cts.map +1 -1
- package/dist/timer.d.mts +1 -4
- package/dist/timer.d.mts.map +1 -1
- package/dist/timer.mjs +1 -1
- package/dist/timer.mjs.map +1 -1
- package/dist/transactions.cjs +123 -0
- package/dist/transactions.cjs.map +1 -0
- package/dist/transactions.d.cts +44 -0
- package/dist/transactions.d.cts.map +1 -0
- package/dist/transactions.d.mts +44 -0
- package/dist/transactions.d.mts.map +1 -0
- package/dist/transactions.mjs +118 -0
- package/dist/transactions.mjs.map +1 -0
- package/package.json +51 -8
- package/dist/Factory-AWn1IulI.d.cts +0 -147
- package/dist/Factory-AWn1IulI.d.cts.map +0 -1
- package/dist/Factory-BFVnMMCC.mjs +0 -51
- package/dist/Factory-BFVnMMCC.mjs.map +0 -1
- package/dist/Factory-BhjUOBWN.cjs +0 -57
- package/dist/Factory-BhjUOBWN.cjs.map +0 -1
- package/dist/Factory-C15SSK8_.d.mts +0 -147
- package/dist/Factory-C15SSK8_.d.mts.map +0 -1
- package/dist/KyselyFactory-BFqVIn_0.cjs +0 -246
- package/dist/KyselyFactory-BFqVIn_0.cjs.map +0 -1
- package/dist/KyselyFactory-C9Snz24z.d.mts +0 -228
- package/dist/KyselyFactory-C9Snz24z.d.mts.map +0 -1
- package/dist/KyselyFactory-CxUJCi--.d.cts +0 -228
- package/dist/KyselyFactory-CxUJCi--.d.cts.map +0 -1
- package/dist/KyselyFactory-DMswpwji.mjs +0 -241
- package/dist/KyselyFactory-DMswpwji.mjs.map +0 -1
- package/dist/ObjectionFactory-BeFBYcan.cjs +0 -272
- package/dist/ObjectionFactory-BeFBYcan.cjs.map +0 -1
- package/dist/ObjectionFactory-CYvaa0kU.d.cts +0 -241
- package/dist/ObjectionFactory-CYvaa0kU.d.cts.map +0 -1
- package/dist/ObjectionFactory-Cf2WI4o_.d.mts +0 -241
- package/dist/ObjectionFactory-Cf2WI4o_.d.mts.map +0 -1
- package/dist/ObjectionFactory-QCJ7u0Ql.mjs +0 -267
- package/dist/ObjectionFactory-QCJ7u0Ql.mjs.map +0 -1
- package/dist/PostgresKyselyMigrator-B2M6Gjvv.d.cts +0 -84
- package/dist/PostgresKyselyMigrator-B2M6Gjvv.d.cts.map +0 -1
- package/dist/PostgresKyselyMigrator-BGBxjnFv.cjs +0 -101
- package/dist/PostgresKyselyMigrator-BGBxjnFv.cjs.map +0 -1
- package/dist/PostgresKyselyMigrator-CvwXycJE.d.mts +0 -84
- package/dist/PostgresKyselyMigrator-CvwXycJE.d.mts.map +0 -1
- package/dist/PostgresKyselyMigrator-PI0QhvB1.mjs +0 -95
- package/dist/PostgresKyselyMigrator-PI0QhvB1.mjs.map +0 -1
- package/dist/PostgresMigrator-C_QQ6q35.d.mts.map +0 -1
- package/dist/PostgresMigrator-CeYy-eHF.d.cts.map +0 -1
- package/dist/PostgresMigrator-DVAY04qN.mjs +0 -166
- package/dist/PostgresMigrator-DVAY04qN.mjs.map +0 -1
- package/dist/PostgresMigrator-M9jpzOvN.cjs +0 -172
- package/dist/PostgresMigrator-M9jpzOvN.cjs.map +0 -1
- package/dist/PostgresObjectionMigrator-1j6YIB1c.d.mts +0 -79
- package/dist/PostgresObjectionMigrator-1j6YIB1c.d.mts.map +0 -1
- package/dist/PostgresObjectionMigrator-DHVC9h_P.d.cts +0 -79
- package/dist/PostgresObjectionMigrator-DHVC9h_P.d.cts.map +0 -1
- package/dist/PostgresObjectionMigrator-DSaPhwjY.cjs +0 -123
- package/dist/PostgresObjectionMigrator-DSaPhwjY.cjs.map +0 -1
- package/dist/PostgresObjectionMigrator-DjPKdUbm.mjs +0 -118
- package/dist/PostgresObjectionMigrator-DjPKdUbm.mjs.map +0 -1
- package/dist/VitestKyselyTransactionIsolator-1Saieke7.mjs +0 -67
- package/dist/VitestKyselyTransactionIsolator-1Saieke7.mjs.map +0 -1
- package/dist/VitestKyselyTransactionIsolator-BjJSXryR.cjs +0 -72
- package/dist/VitestKyselyTransactionIsolator-BjJSXryR.cjs.map +0 -1
- package/dist/VitestKyselyTransactionIsolator-CwlTo6yf.d.mts +0 -64
- package/dist/VitestKyselyTransactionIsolator-CwlTo6yf.d.mts.map +0 -1
- package/dist/VitestKyselyTransactionIsolator-DJasVuIZ.d.cts +0 -64
- package/dist/VitestKyselyTransactionIsolator-DJasVuIZ.d.cts.map +0 -1
- package/dist/VitestObjectionTransactionIsolator-B_VSWFum.mjs +0 -63
- package/dist/VitestObjectionTransactionIsolator-B_VSWFum.mjs.map +0 -1
- package/dist/VitestObjectionTransactionIsolator-CTTjvTPO.d.cts +0 -60
- package/dist/VitestObjectionTransactionIsolator-CTTjvTPO.d.cts.map +0 -1
- package/dist/VitestObjectionTransactionIsolator-CyZG6nq4.d.mts +0 -60
- package/dist/VitestObjectionTransactionIsolator-CyZG6nq4.d.mts.map +0 -1
- package/dist/VitestObjectionTransactionIsolator-DDoJTu7e.cjs +0 -68
- package/dist/VitestObjectionTransactionIsolator-DDoJTu7e.cjs.map +0 -1
- package/dist/VitestTransactionIsolator-BLaw80cx.d.mts +0 -223
- package/dist/VitestTransactionIsolator-BLaw80cx.d.mts.map +0 -1
- package/dist/VitestTransactionIsolator-CvwPecpl.mjs +0 -188
- package/dist/VitestTransactionIsolator-CvwPecpl.mjs.map +0 -1
- package/dist/VitestTransactionIsolator-DyiX-QtK.cjs +0 -206
- package/dist/VitestTransactionIsolator-DyiX-QtK.cjs.map +0 -1
- package/dist/VitestTransactionIsolator-glcxyS_R.d.cts +0 -223
- package/dist/VitestTransactionIsolator-glcxyS_R.d.cts.map +0 -1
- package/dist/directory-BxjqmtCT.mjs +0 -27
- package/dist/directory-BxjqmtCT.mjs.map +0 -1
- package/dist/directory-DD_xQoSh.cjs +0 -33
- package/dist/directory-DD_xQoSh.cjs.map +0 -1
- package/dist/directory-DiQ_DkaF.d.mts +0 -13
- package/dist/directory-DiQ_DkaF.d.mts.map +0 -1
- package/dist/directory-zIEh5ZPl.d.cts +0 -13
- package/dist/directory-zIEh5ZPl.d.cts.map +0 -1
- package/dist/faker-B14IEMIN.cjs +0 -304
- package/dist/faker-B14IEMIN.cjs.map +0 -1
- package/dist/faker-B6bmbGCM.d.mts +0 -166
- package/dist/faker-B6bmbGCM.d.mts.map +0 -1
- package/dist/faker-BGKYFoCT.mjs +0 -262
- package/dist/faker-BGKYFoCT.mjs.map +0 -1
- package/dist/faker-DvxiCtxc.d.cts +0 -166
- package/dist/faker-DvxiCtxc.d.cts.map +0 -1
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
import * as _faker_js_faker4 from "@faker-js/faker";
|
|
2
|
-
|
|
3
|
-
//#region src/faker.d.ts
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Generates random timestamp fields for database records.
|
|
7
|
-
* Creates a createdAt date in the past and an updatedAt date between creation and now.
|
|
8
|
-
* Milliseconds are set to 0 for cleaner database storage.
|
|
9
|
-
*
|
|
10
|
-
* @returns Object with createdAt and updatedAt Date fields
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* ```typescript
|
|
14
|
-
* const { createdAt, updatedAt } = timestamps();
|
|
15
|
-
* console.log(createdAt); // 2023-05-15T10:30:00.000Z
|
|
16
|
-
* console.log(updatedAt); // 2023-11-20T14:45:00.000Z
|
|
17
|
-
*
|
|
18
|
-
* // Use in factory
|
|
19
|
-
* const user = {
|
|
20
|
-
* name: 'John Doe',
|
|
21
|
-
* ...timestamps()
|
|
22
|
-
* };
|
|
23
|
-
* ```
|
|
24
|
-
*/
|
|
25
|
-
declare function timestamps(): Timestamps;
|
|
26
|
-
/**
|
|
27
|
-
* Generates a reverse domain name identifier.
|
|
28
|
-
* Useful for creating unique identifiers that follow domain naming conventions.
|
|
29
|
-
*
|
|
30
|
-
* @param suffix - Optional suffix to append to the identifier
|
|
31
|
-
* @returns A reverse domain name string (e.g., "com.example.feature123")
|
|
32
|
-
*
|
|
33
|
-
* @example
|
|
34
|
-
* ```typescript
|
|
35
|
-
* console.log(identifier()); // "com.example.widget1"
|
|
36
|
-
* console.log(identifier('user')); // "org.acme.user"
|
|
37
|
-
* console.log(identifier('api')); // "net.demo.api"
|
|
38
|
-
* ```
|
|
39
|
-
*/
|
|
40
|
-
declare function identifier(suffix?: string): string;
|
|
41
|
-
/**
|
|
42
|
-
* Generates sequential numbers for a named sequence.
|
|
43
|
-
* Useful for creating unique IDs or numbered test data.
|
|
44
|
-
* Each named sequence maintains its own counter.
|
|
45
|
-
*
|
|
46
|
-
* @param name - The sequence name (default: 'default')
|
|
47
|
-
* @returns The next number in the sequence
|
|
48
|
-
*
|
|
49
|
-
* @example
|
|
50
|
-
* ```typescript
|
|
51
|
-
* console.log(sequence()); // 1
|
|
52
|
-
* console.log(sequence()); // 2
|
|
53
|
-
* console.log(sequence('user')); // 1
|
|
54
|
-
* console.log(sequence('user')); // 2
|
|
55
|
-
* console.log(sequence()); // 3
|
|
56
|
-
*
|
|
57
|
-
* // Use in factories
|
|
58
|
-
* const email = `user${sequence('email')}@example.com`;
|
|
59
|
-
* ```
|
|
60
|
-
*/
|
|
61
|
-
declare function sequence(name?: string): number;
|
|
62
|
-
/**
|
|
63
|
-
* Resets a named sequence counter to a specific value.
|
|
64
|
-
* Useful for resetting sequences between test suites.
|
|
65
|
-
*
|
|
66
|
-
* @param name - The sequence name to reset (default: 'default')
|
|
67
|
-
* @param value - The new starting value (default: 0)
|
|
68
|
-
*
|
|
69
|
-
* @example
|
|
70
|
-
* ```typescript
|
|
71
|
-
* sequence('user'); // 1
|
|
72
|
-
* sequence('user'); // 2
|
|
73
|
-
* resetSequence('user');
|
|
74
|
-
* sequence('user'); // 1
|
|
75
|
-
*
|
|
76
|
-
* resetSequence('order', 1000);
|
|
77
|
-
* sequence('order'); // 1001
|
|
78
|
-
* ```
|
|
79
|
-
*/
|
|
80
|
-
declare function resetSequence(name?: string, value?: number): void;
|
|
81
|
-
/**
|
|
82
|
-
* Resets all sequence counters.
|
|
83
|
-
* Useful for cleaning up between test suites to ensure predictable sequences.
|
|
84
|
-
*
|
|
85
|
-
* @example
|
|
86
|
-
* ```typescript
|
|
87
|
-
* // In test setup
|
|
88
|
-
* beforeEach(() => {
|
|
89
|
-
* resetAllSequences();
|
|
90
|
-
* });
|
|
91
|
-
*
|
|
92
|
-
* it('starts sequences from 1', () => {
|
|
93
|
-
* expect(sequence()).toBe(1);
|
|
94
|
-
* expect(sequence('user')).toBe(1);
|
|
95
|
-
* });
|
|
96
|
-
* ```
|
|
97
|
-
*/
|
|
98
|
-
declare function resetAllSequences(): void;
|
|
99
|
-
/**
|
|
100
|
-
* Generates a random price as a number.
|
|
101
|
-
* Converts faker's string price to a numeric value.
|
|
102
|
-
*
|
|
103
|
-
* @returns A random price number
|
|
104
|
-
*
|
|
105
|
-
* @example
|
|
106
|
-
* ```typescript
|
|
107
|
-
* const productPrice = price(); // 29.99
|
|
108
|
-
* const total = price() * quantity; // Numeric calculation
|
|
109
|
-
* ```
|
|
110
|
-
*/
|
|
111
|
-
declare function price(): number;
|
|
112
|
-
type Coordinate = {
|
|
113
|
-
lat: number;
|
|
114
|
-
lng: number;
|
|
115
|
-
};
|
|
116
|
-
declare function coordinateInRadius(center: Coordinate, radius: number): Coordinate;
|
|
117
|
-
declare function coordinateOutsideRadius(center: Coordinate, minRadiusMeters: number, maxRadiusMeters: number): Coordinate;
|
|
118
|
-
/**
|
|
119
|
-
* Enhanced faker instance with additional utility methods for testing.
|
|
120
|
-
* Extends @faker-js/faker with custom methods for common test data generation patterns.
|
|
121
|
-
*
|
|
122
|
-
* @example
|
|
123
|
-
* ```typescript
|
|
124
|
-
* import { faker } from '@geekmidas/testkit';
|
|
125
|
-
*
|
|
126
|
-
* // Use standard faker methods
|
|
127
|
-
* const name = faker.person.fullName();
|
|
128
|
-
* const email = faker.internet.email();
|
|
129
|
-
*
|
|
130
|
-
* // Use custom extensions
|
|
131
|
-
* const { createdAt, updatedAt } = faker.timestamps();
|
|
132
|
-
* const id = faker.identifier('user');
|
|
133
|
-
* const orderNumber = faker.sequence('order');
|
|
134
|
-
* const productPrice = faker.price();
|
|
135
|
-
* ```
|
|
136
|
-
*/
|
|
137
|
-
declare const faker$1: Readonly<_faker_js_faker4.Faker & {
|
|
138
|
-
timestamps: typeof timestamps;
|
|
139
|
-
identifier: typeof identifier;
|
|
140
|
-
sequence: typeof sequence;
|
|
141
|
-
resetSequence: typeof resetSequence;
|
|
142
|
-
resetAllSequences: typeof resetAllSequences;
|
|
143
|
-
price: typeof price;
|
|
144
|
-
coordinates: {
|
|
145
|
-
within: typeof coordinateInRadius;
|
|
146
|
-
outside: typeof coordinateOutsideRadius;
|
|
147
|
-
};
|
|
148
|
-
}>;
|
|
149
|
-
/**
|
|
150
|
-
* Type definition for timestamp fields.
|
|
151
|
-
* Used by the timestamps() function to generate date fields.
|
|
152
|
-
*/
|
|
153
|
-
type Timestamps = {
|
|
154
|
-
/** The creation date */
|
|
155
|
-
createdAt: Date;
|
|
156
|
-
/** The last update date */
|
|
157
|
-
updatedAt: Date;
|
|
158
|
-
};
|
|
159
|
-
/**
|
|
160
|
-
* Type definition for the enhanced faker factory.
|
|
161
|
-
* Includes all standard faker methods plus custom extensions.
|
|
162
|
-
*/
|
|
163
|
-
type FakerFactory = typeof faker$1;
|
|
164
|
-
//#endregion
|
|
165
|
-
export { FakerFactory, Timestamps, coordinateInRadius, faker$1 as faker, identifier, resetAllSequences, resetSequence, sequence, timestamps };
|
|
166
|
-
//# sourceMappingURL=faker-B6bmbGCM.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"faker-B6bmbGCM.d.mts","names":[],"sources":["../src/faker.ts"],"sourcesContent":[],"mappings":";;;;;;;AAkFA;AA2BA;AAmCA;AA2BA;AA0BA;AAEC;AAca;AASd;;;;AAGa;AA4BZ;;;;AAMY;AA2DA,iBA5OG,UAAA,CAAA,CAyPf,EAzP6B,UAyP7B;;;;;;;;;;;;AAbiB;AAmBlB;;AAEY,iBAtOI,UAAA,CAsOJ,MAAA,CAAA,EAAA,MAAA,CAAA,EAAA,MAAA;;AAEI;AAOhB;;;;;;;;;;;;;;;;;;iBA5MgB,QAAA;;;;;;;;;;;;;;;;;;;iBA2BA,aAAA;;;;;;;;;;;;;;;;;;iBA0BA,iBAAA,CAAA;;;;;;;;;;;;;iBAgBP,KAAA,CAAA;KAIJ,UAAA;;;;iBAKW,kBAAA,SACP,6BAEN;iBA8BM,uBAAA,SACA,+DAGN;;;;;;;;;;;;;;;;;;;;cA2DU,SAAK,SAajB,gBAAA,CAbiB,KAAA;qBAAA;;;;;;;;;;;;;;;KAmBN,UAAA;;aAEA;;aAEA;;;;;;KAOA,YAAA,UAAsB"}
|
package/dist/faker-BGKYFoCT.mjs
DELETED
|
@@ -1,262 +0,0 @@
|
|
|
1
|
-
import { faker } from "@faker-js/faker";
|
|
2
|
-
|
|
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$1.date.past();
|
|
76
|
-
const updatedAt = faker$1.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$1.internet.domainSuffix(),
|
|
104
|
-
faker$1.internet.domainWord(),
|
|
105
|
-
suffix ? suffix : faker$1.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
|
-
const counter = sequences.get(name);
|
|
137
|
-
return counter.increment();
|
|
138
|
-
}
|
|
139
|
-
/**
|
|
140
|
-
* Resets a named sequence counter to a specific value.
|
|
141
|
-
* Useful for resetting sequences between test suites.
|
|
142
|
-
*
|
|
143
|
-
* @param name - The sequence name to reset (default: 'default')
|
|
144
|
-
* @param value - The new starting value (default: 0)
|
|
145
|
-
*
|
|
146
|
-
* @example
|
|
147
|
-
* ```typescript
|
|
148
|
-
* sequence('user'); // 1
|
|
149
|
-
* sequence('user'); // 2
|
|
150
|
-
* resetSequence('user');
|
|
151
|
-
* sequence('user'); // 1
|
|
152
|
-
*
|
|
153
|
-
* resetSequence('order', 1000);
|
|
154
|
-
* sequence('order'); // 1001
|
|
155
|
-
* ```
|
|
156
|
-
*/
|
|
157
|
-
function resetSequence(name = "default", value = 0) {
|
|
158
|
-
if (sequences.has(name)) {
|
|
159
|
-
const counter = sequences.get(name);
|
|
160
|
-
counter.reset(value);
|
|
161
|
-
} else sequences.set(name, new AtomicCounter(value));
|
|
162
|
-
}
|
|
163
|
-
/**
|
|
164
|
-
* Resets all sequence counters.
|
|
165
|
-
* Useful for cleaning up between test suites to ensure predictable sequences.
|
|
166
|
-
*
|
|
167
|
-
* @example
|
|
168
|
-
* ```typescript
|
|
169
|
-
* // In test setup
|
|
170
|
-
* beforeEach(() => {
|
|
171
|
-
* resetAllSequences();
|
|
172
|
-
* });
|
|
173
|
-
*
|
|
174
|
-
* it('starts sequences from 1', () => {
|
|
175
|
-
* expect(sequence()).toBe(1);
|
|
176
|
-
* expect(sequence('user')).toBe(1);
|
|
177
|
-
* });
|
|
178
|
-
* ```
|
|
179
|
-
*/
|
|
180
|
-
function resetAllSequences() {
|
|
181
|
-
sequences.clear();
|
|
182
|
-
}
|
|
183
|
-
/**
|
|
184
|
-
* Generates a random price as a number.
|
|
185
|
-
* Converts faker's string price to a numeric value.
|
|
186
|
-
*
|
|
187
|
-
* @returns A random price number
|
|
188
|
-
*
|
|
189
|
-
* @example
|
|
190
|
-
* ```typescript
|
|
191
|
-
* const productPrice = price(); // 29.99
|
|
192
|
-
* const total = price() * quantity; // Numeric calculation
|
|
193
|
-
* ```
|
|
194
|
-
*/
|
|
195
|
-
function price() {
|
|
196
|
-
return +faker$1.commerce.price();
|
|
197
|
-
}
|
|
198
|
-
function coordinateInRadius(center, radius) {
|
|
199
|
-
const earth = 6378137;
|
|
200
|
-
const d = radius / earth;
|
|
201
|
-
const theta = 2 * Math.PI * Math.random();
|
|
202
|
-
const r = d * Math.sqrt(Math.random());
|
|
203
|
-
const lat1 = center.lat * Math.PI / 180;
|
|
204
|
-
const lng1 = center.lng * Math.PI / 180;
|
|
205
|
-
const lat2 = Math.asin(Math.sin(lat1) * Math.cos(r) + Math.cos(lat1) * Math.sin(r) * Math.cos(theta));
|
|
206
|
-
const lng2 = lng1 + Math.atan2(Math.sin(theta) * Math.sin(r) * Math.cos(lat1), Math.cos(r) - Math.sin(lat1) * Math.sin(lat2));
|
|
207
|
-
return {
|
|
208
|
-
lat: lat2 * 180 / Math.PI,
|
|
209
|
-
lng: lng2 * 180 / Math.PI
|
|
210
|
-
};
|
|
211
|
-
}
|
|
212
|
-
function coordinateOutsideRadius(center, minRadiusMeters, maxRadiusMeters) {
|
|
213
|
-
const earth = 6378137;
|
|
214
|
-
const minD = minRadiusMeters / earth;
|
|
215
|
-
const maxD = maxRadiusMeters / earth;
|
|
216
|
-
const theta = 2 * Math.PI * Math.random();
|
|
217
|
-
const r = Math.sqrt(minD * minD + (maxD * maxD - minD * minD) * Math.random());
|
|
218
|
-
const lat1 = center.lat * Math.PI / 180;
|
|
219
|
-
const lng1 = center.lng * Math.PI / 180;
|
|
220
|
-
const lat2 = Math.asin(Math.sin(lat1) * Math.cos(r) + Math.cos(lat1) * Math.sin(r) * Math.cos(theta));
|
|
221
|
-
const lng2 = lng1 + Math.atan2(Math.sin(theta) * Math.sin(r) * Math.cos(lat1), Math.cos(r) - Math.sin(lat1) * Math.sin(lat2));
|
|
222
|
-
const normalizedLng = (lng2 * 180 / Math.PI + 540) % 360 - 180;
|
|
223
|
-
return {
|
|
224
|
-
lat: lat2 * 180 / Math.PI,
|
|
225
|
-
lng: normalizedLng
|
|
226
|
-
};
|
|
227
|
-
}
|
|
228
|
-
/**
|
|
229
|
-
* Enhanced faker instance with additional utility methods for testing.
|
|
230
|
-
* Extends @faker-js/faker with custom methods for common test data generation patterns.
|
|
231
|
-
*
|
|
232
|
-
* @example
|
|
233
|
-
* ```typescript
|
|
234
|
-
* import { faker } from '@geekmidas/testkit';
|
|
235
|
-
*
|
|
236
|
-
* // Use standard faker methods
|
|
237
|
-
* const name = faker.person.fullName();
|
|
238
|
-
* const email = faker.internet.email();
|
|
239
|
-
*
|
|
240
|
-
* // Use custom extensions
|
|
241
|
-
* const { createdAt, updatedAt } = faker.timestamps();
|
|
242
|
-
* const id = faker.identifier('user');
|
|
243
|
-
* const orderNumber = faker.sequence('order');
|
|
244
|
-
* const productPrice = faker.price();
|
|
245
|
-
* ```
|
|
246
|
-
*/
|
|
247
|
-
const faker$1 = Object.freeze(Object.assign({}, faker, {
|
|
248
|
-
timestamps,
|
|
249
|
-
identifier,
|
|
250
|
-
sequence,
|
|
251
|
-
resetSequence,
|
|
252
|
-
resetAllSequences,
|
|
253
|
-
price,
|
|
254
|
-
coordinates: {
|
|
255
|
-
within: coordinateInRadius,
|
|
256
|
-
outside: coordinateOutsideRadius
|
|
257
|
-
}
|
|
258
|
-
}));
|
|
259
|
-
|
|
260
|
-
//#endregion
|
|
261
|
-
export { coordinateInRadius, faker$1 as faker, identifier, resetAllSequences, resetSequence, sequence, timestamps };
|
|
262
|
-
//# sourceMappingURL=faker-BGKYFoCT.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"faker-BGKYFoCT.mjs","names":["suffix?: string","center: Coordinate","radius: number","minRadiusMeters: number","maxRadiusMeters: number","faker","baseFaker"],"sources":["../src/faker.ts"],"sourcesContent":["import { faker as baseFaker } from '@faker-js/faker';\n\n// NOTE: This is a simple way to extend `faker` with additional methods\n\n/**\n * Atomic counter implementation for thread-safe sequence generation.\n * Provides a clean abstraction for generating sequential numbers in tests.\n * While JavaScript is single-threaded, this class makes the intent explicit.\n *\n * @example\n * ```typescript\n * const counter = new AtomicCounter(100);\n * console.log(counter.increment()); // 101\n * console.log(counter.increment()); // 102\n * console.log(counter.get()); // 102\n * counter.reset(200);\n * console.log(counter.increment()); // 201\n * ```\n */\nclass AtomicCounter {\n\t/**\n\t * The current counter value.\n\t * @private\n\t */\n\tprivate value: number;\n\n\t/**\n\t * Creates a new atomic counter.\n\t * @param initialValue - The starting value (default: 0)\n\t */\n\tconstructor(initialValue = 0) {\n\t\tthis.value = initialValue;\n\t}\n\n\t/**\n\t * Increments the counter and returns the new value.\n\t * @returns The incremented value\n\t */\n\tincrement(): number {\n\t\t// In Node.js, JavaScript is single-threaded within the event loop,\n\t\t// so this operation is already atomic. However, this class provides\n\t\t// a cleaner abstraction and makes the intent explicit.\n\t\treturn ++this.value;\n\t}\n\n\t/**\n\t * Gets the current counter value without incrementing.\n\t * @returns The current value\n\t */\n\tget(): number {\n\t\treturn this.value;\n\t}\n\n\t/**\n\t * Resets the counter to a specific value.\n\t * @param value - The new value (default: 0)\n\t */\n\treset(value = 0): void {\n\t\tthis.value = value;\n\t}\n}\n\n/**\n * Generates random timestamp fields for database records.\n * Creates a createdAt date in the past and an updatedAt date between creation and now.\n * Milliseconds are set to 0 for cleaner database storage.\n *\n * @returns Object with createdAt and updatedAt Date fields\n *\n * @example\n * ```typescript\n * const { createdAt, updatedAt } = timestamps();\n * console.log(createdAt); // 2023-05-15T10:30:00.000Z\n * console.log(updatedAt); // 2023-11-20T14:45:00.000Z\n *\n * // Use in factory\n * const user = {\n * name: 'John Doe',\n * ...timestamps()\n * };\n * ```\n */\nexport function timestamps(): Timestamps {\n\tconst createdAt = faker.date.past();\n\tconst updatedAt = faker.date.between({\n\t\tfrom: createdAt,\n\t\tto: new Date(),\n\t});\n\n\tcreatedAt.setMilliseconds(0);\n\tupdatedAt.setMilliseconds(0);\n\n\treturn { createdAt, updatedAt };\n}\n\n/**\n * Generates a reverse domain name identifier.\n * Useful for creating unique identifiers that follow domain naming conventions.\n *\n * @param suffix - Optional suffix to append to the identifier\n * @returns A reverse domain name string (e.g., \"com.example.feature123\")\n *\n * @example\n * ```typescript\n * console.log(identifier()); // \"com.example.widget1\"\n * console.log(identifier('user')); // \"org.acme.user\"\n * console.log(identifier('api')); // \"net.demo.api\"\n * ```\n */\nexport function identifier(suffix?: string): string {\n\treturn [\n\t\tfaker.internet.domainSuffix(),\n\t\tfaker.internet.domainWord(),\n\t\tsuffix ? suffix : faker.internet.domainWord() + sequence('identifier'),\n\t].join('.');\n}\n\n/**\n * Storage for named sequence counters.\n * Each sequence maintains its own independent counter.\n * @private\n */\nconst sequences = new Map<string, AtomicCounter>();\n\n/**\n * Generates sequential numbers for a named sequence.\n * Useful for creating unique IDs or numbered test data.\n * Each named sequence maintains its own counter.\n *\n * @param name - The sequence name (default: 'default')\n * @returns The next number in the sequence\n *\n * @example\n * ```typescript\n * console.log(sequence()); // 1\n * console.log(sequence()); // 2\n * console.log(sequence('user')); // 1\n * console.log(sequence('user')); // 2\n * console.log(sequence()); // 3\n *\n * // Use in factories\n * const email = `user${sequence('email')}@example.com`;\n * ```\n */\nexport function sequence(name = 'default'): number {\n\tif (!sequences.has(name)) {\n\t\tsequences.set(name, new AtomicCounter());\n\t}\n\n\tconst counter = sequences.get(name) as AtomicCounter;\n\treturn counter.increment();\n}\n\n/**\n * Resets a named sequence counter to a specific value.\n * Useful for resetting sequences between test suites.\n *\n * @param name - The sequence name to reset (default: 'default')\n * @param value - The new starting value (default: 0)\n *\n * @example\n * ```typescript\n * sequence('user'); // 1\n * sequence('user'); // 2\n * resetSequence('user');\n * sequence('user'); // 1\n *\n * resetSequence('order', 1000);\n * sequence('order'); // 1001\n * ```\n */\nexport function resetSequence(name = 'default', value = 0): void {\n\tif (sequences.has(name)) {\n\t\tconst counter = sequences.get(name) as AtomicCounter;\n\t\tcounter.reset(value);\n\t} else {\n\t\tsequences.set(name, new AtomicCounter(value));\n\t}\n}\n\n/**\n * Resets all sequence counters.\n * Useful for cleaning up between test suites to ensure predictable sequences.\n *\n * @example\n * ```typescript\n * // In test setup\n * beforeEach(() => {\n * resetAllSequences();\n * });\n *\n * it('starts sequences from 1', () => {\n * expect(sequence()).toBe(1);\n * expect(sequence('user')).toBe(1);\n * });\n * ```\n */\nexport function resetAllSequences(): void {\n\tsequences.clear();\n}\n\n/**\n * Generates a random price as a number.\n * Converts faker's string price to a numeric value.\n *\n * @returns A random price number\n *\n * @example\n * ```typescript\n * const productPrice = price(); // 29.99\n * const total = price() * quantity; // Numeric calculation\n * ```\n */\nfunction price(): number {\n\treturn +faker.commerce.price();\n}\n\ntype Coordinate = {\n\tlat: number;\n\tlng: number;\n};\n\nexport function coordinateInRadius(\n\tcenter: Coordinate,\n\tradius: number,\n): Coordinate {\n\t// Earth's radius in meters\n\tconst earth = 6378137;\n\t// Convert radius from meters to degrees\n\tconst d = radius / earth;\n\n\t// Random bearing and distance\n\tconst theta = 2 * Math.PI * Math.random();\n\tconst r = d * Math.sqrt(Math.random());\n\n\tconst lat1 = (center.lat * Math.PI) / 180;\n\tconst lng1 = (center.lng * Math.PI) / 180;\n\n\tconst lat2 = Math.asin(\n\t\tMath.sin(lat1) * Math.cos(r) +\n\t\t\tMath.cos(lat1) * Math.sin(r) * Math.cos(theta),\n\t);\n\tconst lng2 =\n\t\tlng1 +\n\t\tMath.atan2(\n\t\t\tMath.sin(theta) * Math.sin(r) * Math.cos(lat1),\n\t\t\tMath.cos(r) - Math.sin(lat1) * Math.sin(lat2),\n\t\t);\n\n\treturn {\n\t\tlat: (lat2 * 180) / Math.PI,\n\t\tlng: (lng2 * 180) / Math.PI,\n\t};\n}\n\nfunction coordinateOutsideRadius(\n\tcenter: Coordinate,\n\tminRadiusMeters: number,\n\tmaxRadiusMeters: number,\n): Coordinate {\n\t// Earth's radius in meters\n\tconst earth = 6378137;\n\n\t// Convert radii from meters to radians\n\tconst minD = minRadiusMeters / earth;\n\tconst maxD = maxRadiusMeters / earth;\n\n\t// Random bearing\n\tconst theta = 2 * Math.PI * Math.random();\n\n\t// Random distance in annular ring (uniform distribution by area)\n\t// For uniform distribution in annulus: r = sqrt(r_min² + (r_max² - r_min²) * random)\n\tconst r = Math.sqrt(\n\t\tminD * minD + (maxD * maxD - minD * minD) * Math.random(),\n\t);\n\n\tconst lat1 = (center.lat * Math.PI) / 180;\n\tconst lng1 = (center.lng * Math.PI) / 180;\n\n\tconst lat2 = Math.asin(\n\t\tMath.sin(lat1) * Math.cos(r) +\n\t\t\tMath.cos(lat1) * Math.sin(r) * Math.cos(theta),\n\t);\n\tconst lng2 =\n\t\tlng1 +\n\t\tMath.atan2(\n\t\t\tMath.sin(theta) * Math.sin(r) * Math.cos(lat1),\n\t\t\tMath.cos(r) - Math.sin(lat1) * Math.sin(lat2),\n\t\t);\n\n\t// Normalize longitude to [-180, 180]\n\tconst normalizedLng = (((lng2 * 180) / Math.PI + 540) % 360) - 180;\n\n\treturn {\n\t\tlat: (lat2 * 180) / Math.PI,\n\t\tlng: normalizedLng,\n\t};\n}\n\n/**\n * Enhanced faker instance with additional utility methods for testing.\n * Extends @faker-js/faker with custom methods for common test data generation patterns.\n *\n * @example\n * ```typescript\n * import { faker } from '@geekmidas/testkit';\n *\n * // Use standard faker methods\n * const name = faker.person.fullName();\n * const email = faker.internet.email();\n *\n * // Use custom extensions\n * const { createdAt, updatedAt } = faker.timestamps();\n * const id = faker.identifier('user');\n * const orderNumber = faker.sequence('order');\n * const productPrice = faker.price();\n * ```\n */\nexport const faker = Object.freeze(\n\tObject.assign({}, baseFaker, {\n\t\ttimestamps,\n\t\tidentifier,\n\t\tsequence,\n\t\tresetSequence,\n\t\tresetAllSequences,\n\t\tprice,\n\t\tcoordinates: {\n\t\t\twithin: coordinateInRadius,\n\t\t\toutside: coordinateOutsideRadius,\n\t\t},\n\t}),\n);\n\n/**\n * Type definition for timestamp fields.\n * Used by the timestamps() function to generate date fields.\n */\nexport type Timestamps = {\n\t/** The creation date */\n\tcreatedAt: Date;\n\t/** The last update date */\n\tupdatedAt: Date;\n};\n\n/**\n * Type definition for the enhanced faker factory.\n * Includes all standard faker methods plus custom extensions.\n */\nexport type FakerFactory = typeof faker;\n"],"mappings":"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"}
|
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
import * as _faker_js_faker2 from "@faker-js/faker";
|
|
2
|
-
|
|
3
|
-
//#region src/faker.d.ts
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Generates random timestamp fields for database records.
|
|
7
|
-
* Creates a createdAt date in the past and an updatedAt date between creation and now.
|
|
8
|
-
* Milliseconds are set to 0 for cleaner database storage.
|
|
9
|
-
*
|
|
10
|
-
* @returns Object with createdAt and updatedAt Date fields
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* ```typescript
|
|
14
|
-
* const { createdAt, updatedAt } = timestamps();
|
|
15
|
-
* console.log(createdAt); // 2023-05-15T10:30:00.000Z
|
|
16
|
-
* console.log(updatedAt); // 2023-11-20T14:45:00.000Z
|
|
17
|
-
*
|
|
18
|
-
* // Use in factory
|
|
19
|
-
* const user = {
|
|
20
|
-
* name: 'John Doe',
|
|
21
|
-
* ...timestamps()
|
|
22
|
-
* };
|
|
23
|
-
* ```
|
|
24
|
-
*/
|
|
25
|
-
declare function timestamps(): Timestamps;
|
|
26
|
-
/**
|
|
27
|
-
* Generates a reverse domain name identifier.
|
|
28
|
-
* Useful for creating unique identifiers that follow domain naming conventions.
|
|
29
|
-
*
|
|
30
|
-
* @param suffix - Optional suffix to append to the identifier
|
|
31
|
-
* @returns A reverse domain name string (e.g., "com.example.feature123")
|
|
32
|
-
*
|
|
33
|
-
* @example
|
|
34
|
-
* ```typescript
|
|
35
|
-
* console.log(identifier()); // "com.example.widget1"
|
|
36
|
-
* console.log(identifier('user')); // "org.acme.user"
|
|
37
|
-
* console.log(identifier('api')); // "net.demo.api"
|
|
38
|
-
* ```
|
|
39
|
-
*/
|
|
40
|
-
declare function identifier(suffix?: string): string;
|
|
41
|
-
/**
|
|
42
|
-
* Generates sequential numbers for a named sequence.
|
|
43
|
-
* Useful for creating unique IDs or numbered test data.
|
|
44
|
-
* Each named sequence maintains its own counter.
|
|
45
|
-
*
|
|
46
|
-
* @param name - The sequence name (default: 'default')
|
|
47
|
-
* @returns The next number in the sequence
|
|
48
|
-
*
|
|
49
|
-
* @example
|
|
50
|
-
* ```typescript
|
|
51
|
-
* console.log(sequence()); // 1
|
|
52
|
-
* console.log(sequence()); // 2
|
|
53
|
-
* console.log(sequence('user')); // 1
|
|
54
|
-
* console.log(sequence('user')); // 2
|
|
55
|
-
* console.log(sequence()); // 3
|
|
56
|
-
*
|
|
57
|
-
* // Use in factories
|
|
58
|
-
* const email = `user${sequence('email')}@example.com`;
|
|
59
|
-
* ```
|
|
60
|
-
*/
|
|
61
|
-
declare function sequence(name?: string): number;
|
|
62
|
-
/**
|
|
63
|
-
* Resets a named sequence counter to a specific value.
|
|
64
|
-
* Useful for resetting sequences between test suites.
|
|
65
|
-
*
|
|
66
|
-
* @param name - The sequence name to reset (default: 'default')
|
|
67
|
-
* @param value - The new starting value (default: 0)
|
|
68
|
-
*
|
|
69
|
-
* @example
|
|
70
|
-
* ```typescript
|
|
71
|
-
* sequence('user'); // 1
|
|
72
|
-
* sequence('user'); // 2
|
|
73
|
-
* resetSequence('user');
|
|
74
|
-
* sequence('user'); // 1
|
|
75
|
-
*
|
|
76
|
-
* resetSequence('order', 1000);
|
|
77
|
-
* sequence('order'); // 1001
|
|
78
|
-
* ```
|
|
79
|
-
*/
|
|
80
|
-
declare function resetSequence(name?: string, value?: number): void;
|
|
81
|
-
/**
|
|
82
|
-
* Resets all sequence counters.
|
|
83
|
-
* Useful for cleaning up between test suites to ensure predictable sequences.
|
|
84
|
-
*
|
|
85
|
-
* @example
|
|
86
|
-
* ```typescript
|
|
87
|
-
* // In test setup
|
|
88
|
-
* beforeEach(() => {
|
|
89
|
-
* resetAllSequences();
|
|
90
|
-
* });
|
|
91
|
-
*
|
|
92
|
-
* it('starts sequences from 1', () => {
|
|
93
|
-
* expect(sequence()).toBe(1);
|
|
94
|
-
* expect(sequence('user')).toBe(1);
|
|
95
|
-
* });
|
|
96
|
-
* ```
|
|
97
|
-
*/
|
|
98
|
-
declare function resetAllSequences(): void;
|
|
99
|
-
/**
|
|
100
|
-
* Generates a random price as a number.
|
|
101
|
-
* Converts faker's string price to a numeric value.
|
|
102
|
-
*
|
|
103
|
-
* @returns A random price number
|
|
104
|
-
*
|
|
105
|
-
* @example
|
|
106
|
-
* ```typescript
|
|
107
|
-
* const productPrice = price(); // 29.99
|
|
108
|
-
* const total = price() * quantity; // Numeric calculation
|
|
109
|
-
* ```
|
|
110
|
-
*/
|
|
111
|
-
declare function price(): number;
|
|
112
|
-
type Coordinate = {
|
|
113
|
-
lat: number;
|
|
114
|
-
lng: number;
|
|
115
|
-
};
|
|
116
|
-
declare function coordinateInRadius(center: Coordinate, radius: number): Coordinate;
|
|
117
|
-
declare function coordinateOutsideRadius(center: Coordinate, minRadiusMeters: number, maxRadiusMeters: number): Coordinate;
|
|
118
|
-
/**
|
|
119
|
-
* Enhanced faker instance with additional utility methods for testing.
|
|
120
|
-
* Extends @faker-js/faker with custom methods for common test data generation patterns.
|
|
121
|
-
*
|
|
122
|
-
* @example
|
|
123
|
-
* ```typescript
|
|
124
|
-
* import { faker } from '@geekmidas/testkit';
|
|
125
|
-
*
|
|
126
|
-
* // Use standard faker methods
|
|
127
|
-
* const name = faker.person.fullName();
|
|
128
|
-
* const email = faker.internet.email();
|
|
129
|
-
*
|
|
130
|
-
* // Use custom extensions
|
|
131
|
-
* const { createdAt, updatedAt } = faker.timestamps();
|
|
132
|
-
* const id = faker.identifier('user');
|
|
133
|
-
* const orderNumber = faker.sequence('order');
|
|
134
|
-
* const productPrice = faker.price();
|
|
135
|
-
* ```
|
|
136
|
-
*/
|
|
137
|
-
declare const faker: Readonly<_faker_js_faker2.Faker & {
|
|
138
|
-
timestamps: typeof timestamps;
|
|
139
|
-
identifier: typeof identifier;
|
|
140
|
-
sequence: typeof sequence;
|
|
141
|
-
resetSequence: typeof resetSequence;
|
|
142
|
-
resetAllSequences: typeof resetAllSequences;
|
|
143
|
-
price: typeof price;
|
|
144
|
-
coordinates: {
|
|
145
|
-
within: typeof coordinateInRadius;
|
|
146
|
-
outside: typeof coordinateOutsideRadius;
|
|
147
|
-
};
|
|
148
|
-
}>;
|
|
149
|
-
/**
|
|
150
|
-
* Type definition for timestamp fields.
|
|
151
|
-
* Used by the timestamps() function to generate date fields.
|
|
152
|
-
*/
|
|
153
|
-
type Timestamps = {
|
|
154
|
-
/** The creation date */
|
|
155
|
-
createdAt: Date;
|
|
156
|
-
/** The last update date */
|
|
157
|
-
updatedAt: Date;
|
|
158
|
-
};
|
|
159
|
-
/**
|
|
160
|
-
* Type definition for the enhanced faker factory.
|
|
161
|
-
* Includes all standard faker methods plus custom extensions.
|
|
162
|
-
*/
|
|
163
|
-
type FakerFactory = typeof faker;
|
|
164
|
-
//#endregion
|
|
165
|
-
export { FakerFactory, Timestamps, coordinateInRadius, faker, identifier, resetAllSequences, resetSequence, sequence, timestamps };
|
|
166
|
-
//# sourceMappingURL=faker-DvxiCtxc.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"faker-DvxiCtxc.d.cts","names":[],"sources":["../src/faker.ts"],"sourcesContent":[],"mappings":";;;;;;;AAkFA;AA2BA;AAmCA;AA2BA;AA0BA;AAEC;AAca;AASd;;;;AAGa;AA4BZ;;;;AAMY;AA2DA,iBA5OG,UAAA,CAAA,CAyPf,EAzP6B,UAyP7B;;;;;;;;;;;;AAbiB;AAmBlB;;AAEY,iBAtOI,UAAA,CAsOJ,MAAA,CAAA,EAAA,MAAA,CAAA,EAAA,MAAA;;AAEI;AAOhB;;;;;;;;;;;;;;;;;;iBA5MgB,QAAA;;;;;;;;;;;;;;;;;;;iBA2BA,aAAA;;;;;;;;;;;;;;;;;;iBA0BA,iBAAA,CAAA;;;;;;;;;;;;;iBAgBP,KAAA,CAAA;KAIJ,UAAA;;;;iBAKW,kBAAA,SACP,6BAEN;iBA8BM,uBAAA,SACA,+DAGN;;;;;;;;;;;;;;;;;;;;cA2DU,OAAK,SAajB,gBAAA,CAbiB,KAAA;qBAAA;;;;;;;;;;;;;;;KAmBN,UAAA;;aAEA;;aAEA;;;;;;KAOA,YAAA,UAAsB"}
|