@anil-labs/factory 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +54 -0
- package/LICENSE +21 -0
- package/README.md +371 -0
- package/dist/builders/index.d.cts +40 -0
- package/dist/builders/index.d.ts +40 -0
- package/dist/chunks/faker-BOtDMmjd.cjs +1430 -0
- package/dist/chunks/faker-BOtDMmjd.cjs.map +1 -0
- package/dist/chunks/faker-BlEhpR26.mjs +1287 -0
- package/dist/chunks/faker-BlEhpR26.mjs.map +1 -0
- package/dist/chunks/persist-DcARfeC-.cjs +134 -0
- package/dist/chunks/persist-DcARfeC-.cjs.map +1 -0
- package/dist/chunks/persist-ZGX3NWMF.mjs +117 -0
- package/dist/chunks/persist-ZGX3NWMF.mjs.map +1 -0
- package/dist/core/collection.d.cts +41 -0
- package/dist/core/collection.d.ts +41 -0
- package/dist/core/factory.d.cts +115 -0
- package/dist/core/factory.d.ts +115 -0
- package/dist/core/index.d.cts +6 -0
- package/dist/core/index.d.ts +6 -0
- package/dist/core/registry.d.cts +20 -0
- package/dist/core/registry.d.ts +20 -0
- package/dist/core/sequence.d.cts +36 -0
- package/dist/core/sequence.d.ts +36 -0
- package/dist/core/types.d.cts +47 -0
- package/dist/core/types.d.ts +47 -0
- package/dist/faker/color.d.cts +22 -0
- package/dist/faker/color.d.ts +22 -0
- package/dist/faker/commerce.d.cts +21 -0
- package/dist/faker/commerce.d.ts +21 -0
- package/dist/faker/company.d.cts +20 -0
- package/dist/faker/company.d.ts +20 -0
- package/dist/faker/datatype.d.cts +16 -0
- package/dist/faker/datatype.d.ts +16 -0
- package/dist/faker/date.d.cts +29 -0
- package/dist/faker/date.d.ts +29 -0
- package/dist/faker/faker.d.cts +82 -0
- package/dist/faker/faker.d.ts +82 -0
- package/dist/faker/finance.d.cts +25 -0
- package/dist/faker/finance.d.ts +25 -0
- package/dist/faker/helpers.d.cts +52 -0
- package/dist/faker/helpers.d.ts +52 -0
- package/dist/faker/image.d.cts +22 -0
- package/dist/faker/image.d.ts +22 -0
- package/dist/faker/index.d.cts +21 -0
- package/dist/faker/index.d.ts +21 -0
- package/dist/faker/internet.d.cts +33 -0
- package/dist/faker/internet.d.ts +33 -0
- package/dist/faker/locale.d.cts +26 -0
- package/dist/faker/locale.d.ts +26 -0
- package/dist/faker/location.d.cts +30 -0
- package/dist/faker/location.d.ts +30 -0
- package/dist/faker/lorem.d.cts +26 -0
- package/dist/faker/lorem.d.ts +26 -0
- package/dist/faker/number.d.cts +31 -0
- package/dist/faker/number.d.ts +31 -0
- package/dist/faker/person.d.cts +29 -0
- package/dist/faker/person.d.ts +29 -0
- package/dist/faker/regex.d.cts +19 -0
- package/dist/faker/regex.d.ts +19 -0
- package/dist/faker/string.d.cts +33 -0
- package/dist/faker/string.d.ts +33 -0
- package/dist/faker/system.d.cts +29 -0
- package/dist/faker/system.d.ts +29 -0
- package/dist/faker.cjs +26 -0
- package/dist/faker.mjs +3 -0
- package/dist/index.cjs +635 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +37 -0
- package/dist/index.d.ts +37 -0
- package/dist/index.mjs +596 -0
- package/dist/index.mjs.map +1 -0
- package/dist/locales/en.cjs +351 -0
- package/dist/locales/en.cjs.map +1 -0
- package/dist/locales/en.d.cts +11 -0
- package/dist/locales/en.d.ts +11 -0
- package/dist/locales/en.mjs +350 -0
- package/dist/locales/en.mjs.map +1 -0
- package/dist/locales/types.d.cts +30 -0
- package/dist/locales/types.d.ts +30 -0
- package/dist/persist/console.d.cts +15 -0
- package/dist/persist/console.d.ts +15 -0
- package/dist/persist/http.d.cts +42 -0
- package/dist/persist/http.d.ts +42 -0
- package/dist/persist/index.d.cts +5 -0
- package/dist/persist/index.d.ts +5 -0
- package/dist/persist/memory.d.cts +26 -0
- package/dist/persist/memory.d.ts +26 -0
- package/dist/persist.cjs +5 -0
- package/dist/persist.mjs +2 -0
- package/dist/prng/index.d.cts +5 -0
- package/dist/prng/index.d.ts +5 -0
- package/dist/prng/mulberry32.d.cts +19 -0
- package/dist/prng/mulberry32.d.ts +19 -0
- package/dist/prng/types.d.cts +23 -0
- package/dist/prng/types.d.ts +23 -0
- package/dist/snapshot/index.d.cts +16 -0
- package/dist/snapshot/index.d.ts +16 -0
- package/package.json +136 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pseudo-random number generator interface.
|
|
3
|
+
*
|
|
4
|
+
* All randomness in the package flows through this single contract — swap
|
|
5
|
+
* the implementation (`Mulberry32`, `Sfc32`, an external PRNG) without
|
|
6
|
+
* touching any consumer code.
|
|
7
|
+
*/
|
|
8
|
+
export interface Prng {
|
|
9
|
+
/** Boolean with probability `chance` of `true` (default 0.5). */
|
|
10
|
+
bool(chance?: number): boolean;
|
|
11
|
+
/** Read the current seed (useful for snapshot / debug). */
|
|
12
|
+
readonly currentSeed: number;
|
|
13
|
+
/** Float in `[min, max)` with `decimals` fixed digits. */
|
|
14
|
+
float(min: number, max: number, decimals?: number): number;
|
|
15
|
+
/** Integer in `[min, max]` inclusive. */
|
|
16
|
+
int(min: number, max: number): number;
|
|
17
|
+
/** Float in `[0, 1)` — the primitive every other method derives from. */
|
|
18
|
+
next(): number;
|
|
19
|
+
/** Pick a random element from a non-empty array. */
|
|
20
|
+
pick<T>(items: readonly T[]): T;
|
|
21
|
+
/** Reseed the generator. Resets the internal state to the new seed. */
|
|
22
|
+
seed(seed: number): void;
|
|
23
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pseudo-random number generator interface.
|
|
3
|
+
*
|
|
4
|
+
* All randomness in the package flows through this single contract — swap
|
|
5
|
+
* the implementation (`Mulberry32`, `Sfc32`, an external PRNG) without
|
|
6
|
+
* touching any consumer code.
|
|
7
|
+
*/
|
|
8
|
+
export interface Prng {
|
|
9
|
+
/** Boolean with probability `chance` of `true` (default 0.5). */
|
|
10
|
+
bool(chance?: number): boolean;
|
|
11
|
+
/** Read the current seed (useful for snapshot / debug). */
|
|
12
|
+
readonly currentSeed: number;
|
|
13
|
+
/** Float in `[min, max)` with `decimals` fixed digits. */
|
|
14
|
+
float(min: number, max: number, decimals?: number): number;
|
|
15
|
+
/** Integer in `[min, max]` inclusive. */
|
|
16
|
+
int(min: number, max: number): number;
|
|
17
|
+
/** Float in `[0, 1)` — the primitive every other method derives from. */
|
|
18
|
+
next(): number;
|
|
19
|
+
/** Pick a random element from a non-empty array. */
|
|
20
|
+
pick<T>(items: readonly T[]): T;
|
|
21
|
+
/** Reseed the generator. Resets the internal state to the new seed. */
|
|
22
|
+
seed(seed: number): void;
|
|
23
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Snapshot helpers.
|
|
3
|
+
*
|
|
4
|
+
* The package doesn't write files itself — it just normalises payloads so
|
|
5
|
+
* test runners (vitest, jest) can snapshot them deterministically.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { snapshot } from '@anil-labs/factory'
|
|
10
|
+
*
|
|
11
|
+
* const items = UserFactory.seed(42).count(3).make()
|
|
12
|
+
* expect(snapshot(items)).toMatchSnapshot()
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
/** Recursively normalise dates, undefineds, and key order so snapshots are stable. */
|
|
16
|
+
export declare function snapshot(value: unknown): unknown;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Snapshot helpers.
|
|
3
|
+
*
|
|
4
|
+
* The package doesn't write files itself — it just normalises payloads so
|
|
5
|
+
* test runners (vitest, jest) can snapshot them deterministically.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { snapshot } from '@anil-labs/factory'
|
|
10
|
+
*
|
|
11
|
+
* const items = UserFactory.seed(42).count(3).make()
|
|
12
|
+
* expect(snapshot(items)).toMatchSnapshot()
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
/** Recursively normalise dates, undefineds, and key order so snapshots are stable. */
|
|
16
|
+
export declare function snapshot(value: unknown): unknown;
|
package/package.json
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@anil-labs/factory",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Laravel-inspired model factory + faceted faker for TypeScript. Seedable, locale-aware, framework-agnostic, zero runtime deps.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"author": {
|
|
8
|
+
"name": "Anil Kumar Thakur",
|
|
9
|
+
"url": "https://github.com/anilkumarthakur60"
|
|
10
|
+
},
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "git+https://github.com/anilkumarthakur60/factory.git"
|
|
14
|
+
},
|
|
15
|
+
"homepage": "https://github.com/anilkumarthakur60/factory#readme",
|
|
16
|
+
"bugs": {
|
|
17
|
+
"url": "https://github.com/anilkumarthakur60/factory/issues"
|
|
18
|
+
},
|
|
19
|
+
"main": "./dist/index.cjs",
|
|
20
|
+
"module": "./dist/index.mjs",
|
|
21
|
+
"types": "./dist/index.d.ts",
|
|
22
|
+
"exports": {
|
|
23
|
+
".": {
|
|
24
|
+
"import": {
|
|
25
|
+
"types": "./dist/index.d.ts",
|
|
26
|
+
"default": "./dist/index.mjs"
|
|
27
|
+
},
|
|
28
|
+
"require": {
|
|
29
|
+
"types": "./dist/index.d.cts",
|
|
30
|
+
"default": "./dist/index.cjs"
|
|
31
|
+
},
|
|
32
|
+
"default": "./dist/index.mjs"
|
|
33
|
+
},
|
|
34
|
+
"./faker": {
|
|
35
|
+
"import": {
|
|
36
|
+
"types": "./dist/faker/index.d.ts",
|
|
37
|
+
"default": "./dist/faker.mjs"
|
|
38
|
+
},
|
|
39
|
+
"require": {
|
|
40
|
+
"types": "./dist/faker/index.d.cts",
|
|
41
|
+
"default": "./dist/faker.cjs"
|
|
42
|
+
},
|
|
43
|
+
"default": "./dist/faker.mjs"
|
|
44
|
+
},
|
|
45
|
+
"./persist": {
|
|
46
|
+
"import": {
|
|
47
|
+
"types": "./dist/persist/index.d.ts",
|
|
48
|
+
"default": "./dist/persist.mjs"
|
|
49
|
+
},
|
|
50
|
+
"require": {
|
|
51
|
+
"types": "./dist/persist/index.d.cts",
|
|
52
|
+
"default": "./dist/persist.cjs"
|
|
53
|
+
},
|
|
54
|
+
"default": "./dist/persist.mjs"
|
|
55
|
+
},
|
|
56
|
+
"./locales/en": {
|
|
57
|
+
"import": {
|
|
58
|
+
"types": "./dist/locales/en.d.ts",
|
|
59
|
+
"default": "./dist/locales/en.mjs"
|
|
60
|
+
},
|
|
61
|
+
"require": {
|
|
62
|
+
"types": "./dist/locales/en.d.cts",
|
|
63
|
+
"default": "./dist/locales/en.cjs"
|
|
64
|
+
},
|
|
65
|
+
"default": "./dist/locales/en.mjs"
|
|
66
|
+
},
|
|
67
|
+
"./package.json": "./package.json"
|
|
68
|
+
},
|
|
69
|
+
"files": [
|
|
70
|
+
"dist",
|
|
71
|
+
"README.md",
|
|
72
|
+
"LICENSE",
|
|
73
|
+
"CHANGELOG.md"
|
|
74
|
+
],
|
|
75
|
+
"scripts": {
|
|
76
|
+
"clean": "rm -rf dist coverage",
|
|
77
|
+
"build": "vite build",
|
|
78
|
+
"test": "vitest run",
|
|
79
|
+
"test:watch": "vitest",
|
|
80
|
+
"test:coverage": "vitest run --coverage",
|
|
81
|
+
"typecheck": "tsc --noEmit",
|
|
82
|
+
"lint": "eslint .",
|
|
83
|
+
"lint:fix": "eslint . --fix",
|
|
84
|
+
"format": "prettier --write .",
|
|
85
|
+
"format:check": "prettier --check .",
|
|
86
|
+
"verify": "npm run typecheck && npm run lint && npm run format:check && npm test",
|
|
87
|
+
"docs:dev": "vitepress dev docs",
|
|
88
|
+
"docs:build": "vitepress build docs",
|
|
89
|
+
"docs:preview": "vitepress preview docs",
|
|
90
|
+
"prepublishOnly": "npm run clean && npm run verify && npm run build",
|
|
91
|
+
"prepack": "node -e \"const f=require('./package.json').files;console.log('\\n[prepack] tarball will include only:',f.join(', '));console.log('[prepack] docs/, src/, tests/, configs are excluded.\\n')\""
|
|
92
|
+
},
|
|
93
|
+
"devDependencies": {
|
|
94
|
+
"@eslint/js": "^10.0.1",
|
|
95
|
+
"@microsoft/api-extractor": "^7.58.7",
|
|
96
|
+
"@types/node": "^25.9.1",
|
|
97
|
+
"@vitest/coverage-v8": "^4.1.7",
|
|
98
|
+
"eslint": "^10.4.0",
|
|
99
|
+
"eslint-config-prettier": "^10.1.8",
|
|
100
|
+
"eslint-plugin-perfectionist": "^5.9.0",
|
|
101
|
+
"prettier": "^3.8.3",
|
|
102
|
+
"typescript": "^6.0.3",
|
|
103
|
+
"typescript-eslint": "^8.59.4",
|
|
104
|
+
"vite": "^8.0.13",
|
|
105
|
+
"vite-plugin-dts": "^5.0.1",
|
|
106
|
+
"vitepress": "^1.6.4",
|
|
107
|
+
"vitest": "^4.1.7"
|
|
108
|
+
},
|
|
109
|
+
"engines": {
|
|
110
|
+
"node": ">=20"
|
|
111
|
+
},
|
|
112
|
+
"keywords": [
|
|
113
|
+
"factory",
|
|
114
|
+
"faker",
|
|
115
|
+
"test-data",
|
|
116
|
+
"laravel",
|
|
117
|
+
"eloquent",
|
|
118
|
+
"seeder",
|
|
119
|
+
"mock",
|
|
120
|
+
"typescript",
|
|
121
|
+
"fixtures",
|
|
122
|
+
"seedable",
|
|
123
|
+
"locale",
|
|
124
|
+
"esm",
|
|
125
|
+
"cjs",
|
|
126
|
+
"isomorphic",
|
|
127
|
+
"browser",
|
|
128
|
+
"node",
|
|
129
|
+
"bun",
|
|
130
|
+
"deno"
|
|
131
|
+
],
|
|
132
|
+
"sideEffects": false,
|
|
133
|
+
"publishConfig": {
|
|
134
|
+
"access": "public"
|
|
135
|
+
}
|
|
136
|
+
}
|