@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
package/dist/context.mjs
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
|
+
//#region src/context.ts
|
|
3
|
+
/**
|
|
4
|
+
* The test a request belongs to.
|
|
5
|
+
*
|
|
6
|
+
* A feature test drives an app the way it runs deployed: a browser calls the
|
|
7
|
+
* API, the API calls the auth server, each over a URL. In a test those URLs are
|
|
8
|
+
* served in-process, and every request made on behalf of one test has to reach
|
|
9
|
+
* *that test's* transactions — its own call to the API, and the API's call to
|
|
10
|
+
* the auth server made while handling it.
|
|
11
|
+
*
|
|
12
|
+
* The id travels two ways. In-process, an `AsyncLocalStorage` carries it
|
|
13
|
+
* through every await a test and its handlers make. On the wire it is the
|
|
14
|
+
* `x-test-context-id` header, which a stamped `fetch` adds to every request made
|
|
15
|
+
* inside a context, so whatever serves the URL can find the context again —
|
|
16
|
+
* without any caller, including code under test, writing the header.
|
|
17
|
+
*/
|
|
18
|
+
/** The header a test context travels in between client and server. */
|
|
19
|
+
const TEST_CONTEXT_HEADER = "x-test-context-id";
|
|
20
|
+
const storage = new AsyncLocalStorage();
|
|
21
|
+
/** The context the running code belongs to, if any. */
|
|
22
|
+
function currentTestContext() {
|
|
23
|
+
return storage.getStore();
|
|
24
|
+
}
|
|
25
|
+
/** Run `fn` as the client side of the test `id`. */
|
|
26
|
+
function runInTestContext(id, fn) {
|
|
27
|
+
return storage.run({
|
|
28
|
+
id,
|
|
29
|
+
side: "client"
|
|
30
|
+
}, fn);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Run `fn` as a server handling a request for the test `id` — what whatever
|
|
34
|
+
* serves a URL in-process wraps each request in.
|
|
35
|
+
*/
|
|
36
|
+
function runAsServer(id, fn) {
|
|
37
|
+
return storage.run({
|
|
38
|
+
id,
|
|
39
|
+
side: "server"
|
|
40
|
+
}, fn);
|
|
41
|
+
}
|
|
42
|
+
/** The test a request was made for, read off its header. */
|
|
43
|
+
function testContextOf(request) {
|
|
44
|
+
return request.headers.get("x-test-context-id") ?? void 0;
|
|
45
|
+
}
|
|
46
|
+
/** `fetch`, adding the current test's id to every request made inside one. */
|
|
47
|
+
function stampedFetch(inner) {
|
|
48
|
+
return (input, init) => {
|
|
49
|
+
const context = currentTestContext();
|
|
50
|
+
if (!context) return inner(input, init);
|
|
51
|
+
const request = new Request(input, init);
|
|
52
|
+
if (!request.headers.has("x-test-context-id")) request.headers.set(TEST_CONTEXT_HEADER, context.id);
|
|
53
|
+
return inner(request);
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Stamp the global `fetch` with the current test's id.
|
|
58
|
+
*
|
|
59
|
+
* Install it after anything else that patches `fetch` — MSW's interceptor in
|
|
60
|
+
* particular — so the stamp is added before the request is intercepted.
|
|
61
|
+
* Returns what puts the previous `fetch` back.
|
|
62
|
+
*/
|
|
63
|
+
function installContextFetch() {
|
|
64
|
+
const previous = globalThis.fetch;
|
|
65
|
+
globalThis.fetch = stampedFetch(previous);
|
|
66
|
+
return () => {
|
|
67
|
+
globalThis.fetch = previous;
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
//#endregion
|
|
71
|
+
export { TEST_CONTEXT_HEADER, currentTestContext, installContextFetch, runAsServer, runInTestContext, stampedFetch, testContextOf };
|
|
72
|
+
|
|
73
|
+
//# sourceMappingURL=context.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.mjs","names":[],"sources":["../src/context.ts"],"sourcesContent":["/**\n * The test a request belongs to.\n *\n * A feature test drives an app the way it runs deployed: a browser calls the\n * API, the API calls the auth server, each over a URL. In a test those URLs are\n * served in-process, and every request made on behalf of one test has to reach\n * *that test's* transactions — its own call to the API, and the API's call to\n * the auth server made while handling it.\n *\n * The id travels two ways. In-process, an `AsyncLocalStorage` carries it\n * through every await a test and its handlers make. On the wire it is the\n * `x-test-context-id` header, which a stamped `fetch` adds to every request made\n * inside a context, so whatever serves the URL can find the context again —\n * without any caller, including code under test, writing the header.\n */\n\nimport { AsyncLocalStorage } from 'node:async_hooks';\n\n/** The header a test context travels in between client and server. */\nexport const TEST_CONTEXT_HEADER = 'x-test-context-id';\n\n/**\n * Which side of a URL the running code is on.\n *\n * `client` is the test itself and the frontend it renders — what a browser\n * does. `server` is a handler serving a request. The difference matters for\n * cookies: a browser attaches its cookies to what it sends, a server forwards\n * only what it was handed. A server call that picked up the browser's cookies\n * would hide the bug of a server that forgets to forward them.\n */\nexport type TestSide = 'client' | 'server';\n\nexport interface TestContext {\n\treadonly id: string;\n\treadonly side: TestSide;\n}\n\nconst storage = new AsyncLocalStorage<TestContext>();\n\n/** The context the running code belongs to, if any. */\nexport function currentTestContext(): TestContext | undefined {\n\treturn storage.getStore();\n}\n\n/** Run `fn` as the client side of the test `id`. */\nexport function runInTestContext<T>(id: string, fn: () => T): T {\n\treturn storage.run({ id, side: 'client' }, fn);\n}\n\n/**\n * Run `fn` as a server handling a request for the test `id` — what whatever\n * serves a URL in-process wraps each request in.\n */\nexport function runAsServer<T>(id: string, fn: () => T): T {\n\treturn storage.run({ id, side: 'server' }, fn);\n}\n\n/** The test a request was made for, read off its header. */\nexport function testContextOf(request: Request): string | undefined {\n\treturn request.headers.get(TEST_CONTEXT_HEADER) ?? undefined;\n}\n\n/** `fetch`, adding the current test's id to every request made inside one. */\nexport function stampedFetch(inner: typeof fetch): typeof fetch {\n\treturn (input, init) => {\n\t\tconst context = currentTestContext();\n\t\tif (!context) return inner(input, init);\n\n\t\tconst request = new Request(input, init);\n\t\tif (!request.headers.has(TEST_CONTEXT_HEADER)) {\n\t\t\trequest.headers.set(TEST_CONTEXT_HEADER, context.id);\n\t\t}\n\t\treturn inner(request);\n\t};\n}\n\n/**\n * Stamp the global `fetch` with the current test's id.\n *\n * Install it after anything else that patches `fetch` — MSW's interceptor in\n * particular — so the stamp is added before the request is intercepted.\n * Returns what puts the previous `fetch` back.\n */\nexport function installContextFetch(): () => void {\n\tconst previous = globalThis.fetch;\n\tglobalThis.fetch = stampedFetch(previous);\n\treturn () => {\n\t\tglobalThis.fetch = previous;\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAmBA,MAAa,sBAAsB;AAkBnC,MAAM,UAAU,IAAI,kBAA+B;;AAGnD,SAAgB,qBAA8C;CAC7D,OAAO,QAAQ,SAAS;AACzB;;AAGA,SAAgB,iBAAoB,IAAY,IAAgB;CAC/D,OAAO,QAAQ,IAAI;EAAE;EAAI,MAAM;CAAS,GAAG,EAAE;AAC9C;;;;;AAMA,SAAgB,YAAe,IAAY,IAAgB;CAC1D,OAAO,QAAQ,IAAI;EAAE;EAAI,MAAM;CAAS,GAAG,EAAE;AAC9C;;AAGA,SAAgB,cAAc,SAAsC;CACnE,OAAO,QAAQ,QAAQ,IAAA,mBAAuB,KAAK,KAAA;AACpD;;AAGA,SAAgB,aAAa,OAAmC;CAC/D,QAAQ,OAAO,SAAS;EACvB,MAAM,UAAU,mBAAmB;EACnC,IAAI,CAAC,SAAS,OAAO,MAAM,OAAO,IAAI;EAEtC,MAAM,UAAU,IAAI,QAAQ,OAAO,IAAI;EACvC,IAAI,CAAC,QAAQ,QAAQ,IAAA,mBAAuB,GAC3C,QAAQ,QAAQ,IAAI,qBAAqB,QAAQ,EAAE;EAEpD,OAAO,MAAM,OAAO;CACrB;AACD;;;;;;;;AASA,SAAgB,sBAAkC;CACjD,MAAM,WAAW,WAAW;CAC5B,WAAW,QAAQ,aAAa,QAAQ;CACxC,aAAa;EACZ,WAAW,QAAQ;CACpB;AACD"}
|
package/dist/faker.cjs
CHANGED
|
@@ -1,9 +1,314 @@
|
|
|
1
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
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;
|
|
2
313
|
|
|
3
|
-
|
|
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;
|
|
314
|
+
//# sourceMappingURL=faker.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"faker.cjs","names":["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\n/**\n * A birthdate for someone of the given age today: exactly `min` years old, or\n * anywhere from `min` to `max` inclusive.\n *\n * Through faker's own `date.birthdate`, so seeding faker makes it repeatable.\n *\n * @param min - The youngest age, in whole years\n * @param max - The oldest age, in whole years (default: `min`)\n * @returns The birthdate\n *\n * @example\n * ```typescript\n * faker.age(18); // someone who is 18 today\n * faker.age(18, 24); // someone aged 18 to 24\n * ```\n */\nfunction age(min: number, max: number = min): Date {\n\tif (min < 0 || max < min) throw new AgeRangeInvalid(min, max);\n\n\treturn baseFaker.date.birthdate({ mode: 'age', min, max });\n}\n\n/** An age range no one can be: a negative age, or an oldest below a youngest. */\nexport class AgeRangeInvalid extends Error {\n\tconstructor(\n\t\treadonly min: number,\n\t\treadonly max: number,\n\t) {\n\t\tsuper(\n\t\t\t`faker.age(${min}, ${max}) asks for an age no one can be. Pass the ` +\n\t\t\t\t'youngest age first and the oldest second, neither negative: ' +\n\t\t\t\t'faker.age(18) or faker.age(18, 24).',\n\t\t);\n\t\tthis.name = 'AgeRangeInvalid';\n\t}\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 */\n/**\n * `faker.internet`, with every address lowercase.\n *\n * An auth server stores addresses lowercased — Better Auth does — so a test\n * that signs in as faker's `Ada.Lovelace@…` and reads back `ada.lovelace@…`\n * fails only when faker happened to capitalise: a flake, not a bug. The rest\n * of the module is faker's own, through the prototype.\n */\nconst internet: typeof baseFaker.internet = Object.assign(\n\tObject.create(baseFaker.internet),\n\t{\n\t\temail: (...args: Parameters<typeof baseFaker.internet.email>) =>\n\t\t\tbaseFaker.internet.email(...args).toLowerCase(),\n\t\texampleEmail: (\n\t\t\t...args: Parameters<typeof baseFaker.internet.exampleEmail>\n\t\t) => baseFaker.internet.exampleEmail(...args).toLowerCase(),\n\t},\n);\n\nexport const faker = Object.freeze(\n\tObject.assign({}, baseFaker, {\n\t\tinternet,\n\t\t// A prototype method, so the spread above leaves it behind. The modules\n\t\t// copied across still draw from `baseFaker`, so seeding it seeds them.\n\t\tseed: (seed?: number) => baseFaker.seed(seed),\n\t\ttimestamps,\n\t\tidentifier,\n\t\tsequence,\n\t\tresetSequence,\n\t\tresetAllSequences,\n\t\tprice,\n\t\tage,\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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"}
|
package/dist/faker.d.cts
CHANGED
|
@@ -1,2 +1,169 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
//#region src/faker.d.ts
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"faker.d.cts","names":[],"sources":["../src/faker.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;wBAkFgB,cAAc;;;;;;;;;;;;;;;wBA2Bd,WAAW;;;;;;;;;;;;;;;;;;;;;wBAmCX,SAAS;;;;;;;;;;;;;;;;;;;wBA2BT,cAAc,eAAkB;;;;;;;;;;;;;;;;;;wBA0BhC;;;;;;;;;;;;;iBAgBP;;;;;;;;;;;;;;;;;iBAoBA,IAAI,aAAa,eAAoB;;qBAOjC,wBAAwB;WAE1B;WACA;EAFV,YACU,aACA;;KAWN;EACJ;EACA;;wBAGe,mBACf,QAAQ,YACR,iBACE;iBA8BM,wBACR,QAAQ,YACR,yBACA,0BACE;qBA8EU,OAAK,mCAAA;;EAKF,OAAA;;;;;;;;;IASb,eAAM;IACN,gBAAO;;;;;;;YASE;;EAEX,WAAW;;EAEX,WAAW;;;;;;YAOA,sBAAsB"}
|