@kubb/plugin-faker 5.4.0 → 5.4.1
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/dist/index.cjs +12 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -7
- package/dist/index.d.ts +6 -7
- package/dist/index.js +12 -7
- package/dist/index.js.map +1 -1
- package/docs/options.md +13 -10
- package/docs/overview.md +2 -2
- package/package.json +4 -4
package/docs/options.md
CHANGED
|
@@ -41,7 +41,7 @@ Factories in a schema cycle use the declared model as their base return type to
|
|
|
41
41
|
:::
|
|
42
42
|
|
|
43
43
|
:::field{name="'schema'"}
|
|
44
|
-
Accepts `Partial<Model>` and returns the declared model type, including optional and nullable fields. Use it for fixtures
|
|
44
|
+
Accepts `Partial<Model>` and returns the declared model type, including optional and nullable fields. Use it for fixtures that change after creation.
|
|
45
45
|
:::
|
|
46
46
|
|
|
47
47
|
::
|
|
@@ -78,7 +78,9 @@ pluginFaker({
|
|
|
78
78
|
|
|
79
79
|
### dateParser
|
|
80
80
|
|
|
81
|
-
Library used to format `date` and `time` fields represented as strings. Pick a value other than `'faker'` when
|
|
81
|
+
Library used to format `date`, `time`, and `date-time` fields represented as strings. Pick a value other than `'faker'` when the project already uses a date library, and install that library in the consuming app.
|
|
82
|
+
|
|
83
|
+
Generated `date` and `time` strings use `YYYY-MM-DD` and `HH:mm:ss`. A `date-time` string is `toISOString()` output with `'faker'`. Any other parser formats it as `YYYY-MM-DDTHH:mm:ss[Z]`, without the `Z` for a local date-time and with a numeric offset when the schema declares one.
|
|
82
84
|
|
|
83
85
|
| | |
|
|
84
86
|
| -------- | ------------------------------------------ |
|
|
@@ -101,7 +103,7 @@ Renders it as `moment(faker.date.anytime()).format('YYYY-MM-DD')`.
|
|
|
101
103
|
:::
|
|
102
104
|
|
|
103
105
|
:::field{name="Custom module"}
|
|
104
|
-
Pass a module
|
|
106
|
+
Pass the name of a module whose default export has the dayjs API, because generated code calls `name(faker.date.anytime()).format('YYYY-MM-DD')`. Kubb imports the default export under the camelCased module name, so `'my-date-lib'` becomes `myDateLib` and `'@scope/lib'` becomes `scopeLib`.
|
|
105
107
|
:::
|
|
106
108
|
|
|
107
109
|
::
|
|
@@ -123,7 +125,7 @@ Default value. Generates `faker.helpers.fromRegExp(/pattern/)` without an extra
|
|
|
123
125
|
:::
|
|
124
126
|
|
|
125
127
|
:::field{name="'randexp'"}
|
|
126
|
-
Generates `new RandExp(pattern).gen()`. Supports a wider regex grammar and
|
|
128
|
+
Generates `new RandExp(pattern).gen()`. Supports a wider regex grammar and needs `randexp` installed in the consuming app.
|
|
127
129
|
:::
|
|
128
130
|
|
|
129
131
|
::
|
|
@@ -140,7 +142,7 @@ Faker locale code. It switches the named import to `fakerXX` from `@faker-js/fak
|
|
|
140
142
|
|
|
141
143
|
### seed
|
|
142
144
|
|
|
143
|
-
Kubb passes this value to `faker.seed(...)` at the top of each
|
|
145
|
+
Kubb passes this value to `faker.seed(...)` once at the top of each generated file, so every run returns the same sequence of data. A second call to the same factory returns the next values in that sequence. Use it for snapshot tests. Pass a single number or an array of numbers. Factories still accept overrides, such as `createPet({ name: 'Rex' })`.
|
|
144
146
|
|
|
145
147
|
| | |
|
|
146
148
|
| -------- | -------------------- |
|
|
@@ -167,16 +169,17 @@ type ResolverFakerPatch = {
|
|
|
167
169
|
}
|
|
168
170
|
imports?(options: ResolveImportsOptions): Array<ImportNode>
|
|
169
171
|
param?: {
|
|
170
|
-
name?(node: OperationNode, param: ParameterNode): string // → '
|
|
172
|
+
name?(node: OperationNode, param: ParameterNode): string // → 'createShowPetByIdPathPetId'
|
|
171
173
|
path?(node: OperationNode, param: ParameterNode): string // → 'createShowPetByIdPath'
|
|
172
174
|
query?(node: OperationNode, param: ParameterNode): string // → 'createListPetsQuery'
|
|
173
175
|
headers?(node: OperationNode, param: ParameterNode): string // → 'createDeletePetHeaders'
|
|
176
|
+
cookies?(node: OperationNode, param: ParameterNode): string // → 'createGetSessionCookies'
|
|
174
177
|
}
|
|
175
178
|
response?: {
|
|
176
|
-
status?(node: OperationNode, statusCode: StatusCode): string // → '
|
|
177
|
-
body?(node: OperationNode): string // → '
|
|
178
|
-
response?(node: OperationNode): string // → '
|
|
179
|
-
responses?(node: OperationNode): string // → '
|
|
179
|
+
status?(node: OperationNode, statusCode: StatusCode): string // → 'createListPetsStatus200'
|
|
180
|
+
body?(node: OperationNode): string // → 'createCreatePetsBody'
|
|
181
|
+
response?(node: OperationNode): string // → 'createListPetsResponse'
|
|
182
|
+
responses?(node: OperationNode): string // → 'createListPetsResponses'
|
|
180
183
|
}
|
|
181
184
|
}
|
|
182
185
|
```
|
package/docs/overview.md
CHANGED
|
@@ -12,9 +12,9 @@ Use the factories in tests, Storybook, and local development without a running b
|
|
|
12
12
|
|
|
13
13
|
## Options worth knowing
|
|
14
14
|
|
|
15
|
-
- `seed` passes a fixed seed to `faker.seed(...)`, so every run returns the same data.
|
|
15
|
+
- `seed` passes a fixed seed to `faker.seed(...)`, so every run returns the same sequence of data.
|
|
16
16
|
- `locale` sets the Faker locale. The default is `en`.
|
|
17
|
-
- `dateParser` formats `date` and `time` strings with `faker` (default), `dayjs`, or `moment`.
|
|
17
|
+
- `dateParser` formats `date`, `time`, and `date-time` strings with `faker` (default), `dayjs`, or `moment`. Generation fails with `dayjs` or `moment` when the adapter types a date or time as `Date`, for example with `dateType: 'date'`.
|
|
18
18
|
- `regexGenerator` turns a `pattern` into a string with `faker` (default) or `randexp`.
|
|
19
19
|
- `typeMode` sets the factory types: `inferred` (default) derives them from the generated values, and `schema` uses the declared model type.
|
|
20
20
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/plugin-faker",
|
|
3
|
-
"version": "5.4.
|
|
3
|
+
"version": "5.4.1",
|
|
4
4
|
"description": "Generate Faker.js mock data factories with Kubb. Produces realistic seed data and fixtures for development and testing.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"code-generation",
|
|
@@ -79,9 +79,9 @@
|
|
|
79
79
|
"registry": "https://registry.npmjs.org/"
|
|
80
80
|
},
|
|
81
81
|
"dependencies": {
|
|
82
|
-
"@kubb/kit": "^5.18.
|
|
83
|
-
"@kubb/plugin-ts": "^5.5.
|
|
84
|
-
"@kubb/renderer-jsx": "^5.18.
|
|
82
|
+
"@kubb/kit": "^5.18.8",
|
|
83
|
+
"@kubb/plugin-ts": "^5.5.1",
|
|
84
|
+
"@kubb/renderer-jsx": "^5.18.8"
|
|
85
85
|
},
|
|
86
86
|
"devDependencies": {
|
|
87
87
|
"@faker-js/faker": "^10.6.0",
|