@ghostry/fabricator-extension-faker-v10 0.0.1 → 0.0.2

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 CHANGED
@@ -1,6 +1,22 @@
1
+ <div align="center">
2
+
3
+ <img src="https://docs.ghostry.dev/fabricator/logo.png" alt="fabricator" width="96" height="96">
4
+
1
5
  # @ghostry/fabricator-extension-faker-v10
2
6
 
3
- [`@faker-js/faker`](https://fakerjs.dev) integration for [`@ghostry/fabricator`](https://www.npmjs.com/package/@ghostry/fabricator). Faker's generators draw from the same seed as every other builder in a schema, so `T.faker.person.fullName()` replays exactly like `T.string` does — no second seed to track, no drift between runs.
7
+ **Seeded faker generators for `@ghostry/fabricator`.**
8
+
9
+ [![npm](https://img.shields.io/badge/npm-ffffff.svg?style=for-the-badge&color=000000&logo=npm&logoColor=CB3837)](https://www.npmjs.com/package/@ghostry/fabricator-extension-faker-v10)
10
+ [![npmx](https://img.shields.io/badge/npmx-ffffff.svg?style=for-the-badge&color=000000&logo=data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNTMiIGhlaWdodD0iMTUzIiB2ZXJzaW9uPSIxLjEiIHZpZXdCb3g9IjAgMCAxNTMgMTUzIj4KICA8ZyB0cmFuc2Zvcm09InRyYW5zbGF0ZSgxNi43MDQgOS45ODI3KSI+CiAgICA8cGF0aCBkPSJtMC45MzQ3NiA5Ny4yMDVoMjQuMDgxdjIzLjY5M2gtMjQuMDgxeiIgZmlsbD0iI2ZmZiI+PC9wYXRoPgogICAgPHBhdGggZD0ibTEwMy4xMi05LjIzMDctMy42MjExIDEwLjI0Ni00Ni4zMDkgMTMxLTMuNjIxMSAxMC4yNDZoMTUuNTM3bDMuNjIxMS0xMC4yNDYgMTEuNzE3LTMzLjE0OCAzOC4yMTEtMTA4LjF6IiBmaWxsPSIjNTFjOGZjIj48L3BhdGg+CiAgPC9nPgo8L3N2Zz4K&logoColor=51C8FC)](https://npmx.dev/package/@ghostry/fabricator-extension-faker-v10)
11
+ [![jsr](https://img.shields.io/badge/jsr-ffffff?style=for-the-badge&color=000000&logo=jsr&logoColor=F7DF1E)](https://jsr.io/@ghostry/fabricator-extension-faker-v10)
12
+ [![github](https://img.shields.io/badge/github-ffffff?style=for-the-badge&color=000000&logo=github&logoColor=ffffff)](https://github.com/ghostry-dev/fabricator)
13
+ [![typescript](https://img.shields.io/badge/typescript-ffffff?style=for-the-badge&color=000000&logo=typescript&logoColor=3178C6)](#)
14
+ [![bun](https://img.shields.io/badge/bun-ffffff?style=for-the-badge&color=000000&logo=bun&logoColor=FBF0DF)](#)
15
+ [![node](https://img.shields.io/badge/node-ffffff?style=for-the-badge&color=000000&logo=nodedotjs&logoColor=5FA04E)](#)
16
+
17
+ </div>
18
+
19
+ [`@faker-js/faker`](https://fakerjs.dev) integration for [`@ghostry/fabricator`](https://www.npmjs.com/package/@ghostry/fabricator). Faker's generators draw from the same stream as every other builder in a schema, so `T.faker.person.fullName()` replays exactly like `T.string` does — nothing additional to track, no drift between runs.
4
20
 
5
21
  Targets `@faker-js/faker` 10.x specifically — hence the `-v10` suffix, matching the adapter packages' convention. A future faker major is a sibling package with its own peer range, not a version bump of this one.
6
22
 
@@ -43,21 +59,21 @@ Faker's relative-date methods resolve against the same instance `clock` that `T.
43
59
 
44
60
  A faker method could have been wrapped as an opaque producer, and that is the one thing this package refuses to do — an `opaque` schema converts to `Type.Unknown()` in any adapter and is invisible to `combinatorial`/`coverage`. Each builder instead returns the core kind matching the method's own return type:
45
61
 
46
- | faker returns | builder returns | via the TypeBox adapter |
47
- | ------------------- | ----------------------- | --------------------------------- |
48
- | `string` (207) | `T.string` | `Type.String()` |
49
- | `Date` (7) | `T.date` | `Type.Date()` |
50
- | a record shape (7) | `T.object({ ... })` | `Type.Object({ ... })` |
51
- | a literal union (6) | `T.enum.uniform([...])` | `Type.Union([Type.Literal(), …])` |
52
- | `number` (6) | `T.number` | `Type.Number()` |
53
- | `boolean` (1) | `T.boolean` | `Type.Boolean()` |
54
- | `bigint` (1) | `T.bigint` | `Type.BigInt()` |
55
- | `number[]` (1) | `T.array(T.number)` | `Type.Array(Type.Number())` |
56
- | `Date[]` (1) | `T.array(T.date)` | `Type.Array(Type.Date())` |
62
+ | faker returns | builder returns | via the TypeBox adapter |
63
+ | ---------------------- | ------------------------------- | -------------------------------------------- |
64
+ | `string` (207) | `T.string` | `Type.String()` |
65
+ | `Date` (7) | `T.date` | `Type.Date()` |
66
+ | a record shape (7) | `T.object({ ... })` | `Type.Object({ ... })` |
67
+ | a literal union (6) | `T.enum.uniform([...])` | `Type.Union([Type.Literal(), …])` |
68
+ | `number` (6) | `T.number` | `Type.Number()` |
69
+ | `boolean` (1) | `T.boolean` | `Type.Boolean()` |
70
+ | `bigint` (1) | `T.bigint` | `Type.BigInt()` |
71
+ | `[number, number]` (1) | `T.tuple([T.number, T.number])` | `Type.Tuple([Type.Number(), Type.Number()])` |
72
+ | `Date[]` (1) | `T.array(T.date)` | `Type.Array(Type.Date())` |
57
73
 
58
74
  Seventeen string methods whose output satisfies a JSON-Schema format regardless of the options passed additionally carry it — `internet.email()` converts to `Type.String({ format: "email" })`, `database.mongodbObjectId()` to a `pattern`.
59
75
 
60
- The kind table is generated by probing a real `Faker`, and a compile-time assertion checks every entry's value type against faker's own declared return type — so a faker release that changes one fails `tsc` at that entry rather than silently emitting a wrong schema.
76
+ The mirror is hand-written, not generated — one declaration per builder and one implementation, kept in agreement by the compiler. A compile-time assertion checks every entry's value type against faker's own declared return type, so a faker release that changes one fails `tsc` at that entry rather than silently emitting a wrong schema.
61
77
 
62
78
  ## Three deviations from faker's own API
63
79
 
@@ -75,7 +91,7 @@ T.faker.color.rgb.channels({ includeAlpha: true });
75
91
 
76
92
  The same applies to `cmyk`, `hsl`, `hwb`, `lab`, `lch`, and `colorByCSSColorSpace`. `color`'s other four methods are ordinary builders.
77
93
 
78
- **A method declared as a literal union becomes an `enum`, not a `string`.** `person.sexType()` gives `T.enum.uniform(["female", "generic", "male"])`, so it converts to a union of literals and is enumerable by `combinatorial`/`coverage` rather than an unconstrained string.
94
+ **Where faker's declared return type is narrower than its JS type, the kind narrows with it.** A literal union becomes an `enum`, not a `string`: `person.sexType()` gives `T.enum.uniform(["female", "generic", "male"])`, so it converts to a union of literals and is enumerable by `combinatorial`/`coverage` rather than an unconstrained string. A fixed-arity array becomes a `tuple`, not an `array`: `location.nearbyGPSCoordinate()` gives `T.tuple([T.number, T.number])`, since no option can change its `[latitude, longitude]` arity — unlike the color channels above, which is why those stay `T.array`.
79
95
 
80
96
  ## `use` — for what the mirror doesn't cover
81
97
 
@@ -94,7 +110,7 @@ T.faker.use.opaque((f) => f.helpers.arrayElement(["free", "pro"] as const));
94
110
 
95
111
  ## Notes
96
112
 
97
- `faker.seed(...)` is inert here, by design: fabricator's seed governs, and a second one competing for control of the same output is the bug this package exists to remove. Pass a different `seed` to `initialize()` instead.
113
+ `faker.seed(...)` is inert here, by design: fabricator's seeding governs, and a second one competing for control of the same output is the bug this package exists to remove. Change the instance's `clock` — or its `salt`, if it has one — instead.
98
114
 
99
115
  A builder called outside `fabricate()` throws `FakerExtensionError.NoActiveScopeError` — there is no active fabrication to draw from. `FakerExtensionError` extends core's `FabricatorError`, so one `catch` still covers both packages.
100
116
 
@@ -24,7 +24,7 @@
24
24
  * producer rather than a length bound.
25
25
  * - `color`'s 7 split methods are a `{ text, channels }` pair each rather than
26
26
  * one ambiguous builder, since their return type depends on their arguments;
27
- * see the deviation policy in `CLAUDE.md`'s "The faker extension". All 7 name
27
+ * see the deviation policy in `AGENTS.md`'s "The faker extension". All 7 name
28
28
  * `format: "decimal"` on `.channels()`, not only `rgb`: bare is right at
29
29
  * runtime for the other 6, but not provable through faker's declarations,
30
30
  * whose _first_ overload takes `format?: StringColorFormat` and returns
@@ -45,7 +45,7 @@
45
45
  * Fix the entry in **both** files; the annotation on `build` fails until they
46
46
  * agree.
47
47
  *
48
- * These assertions resolve through built `dist/`, not `src/` (`CLAUDE.md`'s
48
+ * These assertions resolve through built `dist/`, not `src/` (`AGENTS.md`'s
49
49
  * test-import convention), so a `src`-only edit proves nothing about faker
50
50
  * drift until you rebuild. A disagreement between this file and `./Build.ts` is
51
51
  * caught without one, being internal to `src`.
@@ -12,7 +12,7 @@ export type Registry = Pick<typeof registry, "array" | "bigint" | "boolean" | "d
12
12
  * Every module the mirror covers, intersected with `keyof Faker` so every
13
13
  * downstream `Faker[$M]` indexing is sound. `FakerModules/Types.ts` is the
14
14
  * source of truth — `helpers` is absent from it deliberately (deviation policy
15
- * in `CLAUDE.md`'s "The faker extension"), so this type excludes it without
15
+ * in `AGENTS.md`'s "The faker extension"), so this type excludes it without
16
16
  * saying so twice.
17
17
  *
18
18
  * `test/index.types.test.ts`'s `_ModulesExhaustive` holds this to faker's own
@@ -60,7 +60,7 @@ export type FakerExtension = FakerModules & {
60
60
  * (`src/index.ts`'s `draw`).
61
61
  *
62
62
  * How `helpers` is reached (omitted from the mirror — deviation policy in
63
- * `CLAUDE.md`'s "The faker extension"). Kind-tagged forms (`.string`,
63
+ * `AGENTS.md`'s "The faker extension"). Kind-tagged forms (`.string`,
64
64
  * `.number`, `.date`, `.boolean`, `.bigint`) keep adapter compatibility
65
65
  * available there too. `.opaque` is the **only** way to get an `opaque`
66
66
  * schema out of this package — honest, since it is the one place the caller
@@ -7,7 +7,7 @@ export type { FakerExtension as FakerTypes } from "./Types";
7
7
  * The mirror's type-level machinery — not needed to _use_ it, but exported so a
8
8
  * consumer (or this package's compile-time checks in
9
9
  * `test/index.types.test.ts`) can name a module or method without a relative
10
- * `./Types` path tests otherwise avoid (`CLAUDE.md`: tests resolve through the
10
+ * `./Types` path tests otherwise avoid (`AGENTS.md`: tests resolve through the
11
11
  * package specifier, exercising built `dist/`).
12
12
  *
13
13
  * `FakerModules` is the surface those checks are made _against_ — every
@@ -29,9 +29,9 @@ export type FakerConfig = ConstructorParameters<typeof Faker>[0]["config"];
29
29
  *
30
30
  * No `seed` option and no pre-built `Faker`: a pre-built instance's randomizer
31
31
  * is fixed at construction, and accepting one would either ignore it silently
32
- * or let it compete with fabricator's seed. `create` is the honest escape: the
33
- * caller builds the instance; it still receives this bridge's `randomizer`, so
34
- * reproducibility survives.
32
+ * or let it compete with fabricator's seeding. `create` is the honest escape:
33
+ * the caller builds the instance; it still receives this bridge's `randomizer`,
34
+ * so reproducibility survives.
35
35
  */
36
36
  export type Options = {
37
37
  locale: LocaleDefinition | LocaleDefinition[];
@@ -63,7 +63,7 @@ export type Options = {
63
63
  * `FakerExtension` (`./Types.ts`) is spelled out explicitly rather than
64
64
  * inferred. An inferred type would reach into each kind's `Schema` interface —
65
65
  * internal to `@ghostry/fabricator`, unreachable from its `.` export — and
66
- * declaration emission (`tsgo`, not `tsc --noEmit`; see `CLAUDE.md`'s
66
+ * declaration emission (`tsgo`, not `tsc --noEmit`; see `AGENTS.md`'s
67
67
  * declaration-emit trap) refuses to print an anonymous expansion of one. Even
68
68
  * where it printed it would be the wrong contract: inference would surface each
69
69
  * builder's incidental narrowness (`Schema<{ produce; hints }>`) where the
package/package.json CHANGED
@@ -1,12 +1,17 @@
1
1
  {
2
2
  "name": "@ghostry/fabricator-extension-faker-v10",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "license": "MIT",
5
5
  "description": "@faker-js/faker integration for @ghostry/fabricator — faker's data generators, seeded and reproducible through the fabricator instance that calls them.",
6
6
  "keywords": [
7
7
  "factory",
8
+ "reproducible",
9
+ "fixtures",
10
+ "testing",
11
+ "mock",
12
+ "schema",
8
13
  "faker",
9
- "extension"
14
+ "typescript"
10
15
  ],
11
16
  "author": {
12
17
  "name": "Patrick Rebsch"
@@ -16,9 +21,13 @@
16
21
  "url": "git+https://github.com/ghostry-dev/fabricator",
17
22
  "directory": "pkg/fabricator-extension-faker-v10"
18
23
  },
19
- "homepage": "https://github.com/ghostry-dev/fabricator",
24
+ "homepage": "https://docs.ghostry.dev/fabricator/",
20
25
  "bugs": "https://github.com/ghostry-dev/fabricator/issues",
21
26
  "type": "module",
27
+ "sideEffects": false,
28
+ "engines": {
29
+ "node": ">=20.0.0"
30
+ },
22
31
  "types": "./dist/types/index.d.ts",
23
32
  "module": "./dist/esm/index.js",
24
33
  "exports": {
@@ -55,8 +64,8 @@
55
64
  "@faker-js/faker": "^10.5.0"
56
65
  },
57
66
  "devDependencies": {
58
- "@ghostry/fabricator": "0.0.1",
59
- "@ghostry/fabricator-adapter-typebox-v0": "0.0.1",
67
+ "@ghostry/fabricator": "0.0.5",
68
+ "@ghostry/fabricator-adapter-typebox-v0": "0.0.2",
60
69
  "@faker-js/faker": "^10.5.0",
61
70
  "@sinclair/typebox": "^0.34.52"
62
71
  }