@kubb/plugin-faker 5.0.0-beta.3 → 5.0.0-beta.30

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.
Files changed (37) hide show
  1. package/README.md +26 -5
  2. package/dist/{Faker-CdyPfOPg.d.ts → Faker-BaLJxPyl.d.ts} +2 -2
  3. package/dist/{Faker-fcQEB9i5.js → Faker-CXZVQQ7e.js} +36 -99
  4. package/dist/Faker-CXZVQQ7e.js.map +1 -0
  5. package/dist/{Faker-BgleOzVN.cjs → Faker-CkJccVKI.cjs} +35 -122
  6. package/dist/Faker-CkJccVKI.cjs.map +1 -0
  7. package/dist/components.cjs +1 -1
  8. package/dist/components.d.ts +1 -1
  9. package/dist/components.js +1 -1
  10. package/dist/{fakerGenerator-D7daHCh6.js → fakerGenerator-BvMBDgwp.js} +126 -32
  11. package/dist/fakerGenerator-BvMBDgwp.js.map +1 -0
  12. package/dist/fakerGenerator-DSvAJTq3.d.ts +15 -0
  13. package/dist/{fakerGenerator-VJEVzLjc.cjs → fakerGenerator-DhNV9xBw.cjs} +127 -33
  14. package/dist/fakerGenerator-DhNV9xBw.cjs.map +1 -0
  15. package/dist/generators.cjs +1 -1
  16. package/dist/generators.d.ts +1 -1
  17. package/dist/generators.js +1 -1
  18. package/dist/index.cjs +177 -36
  19. package/dist/index.cjs.map +1 -1
  20. package/dist/index.d.ts +33 -12
  21. package/dist/index.js +178 -37
  22. package/dist/index.js.map +1 -1
  23. package/dist/{printerFaker-CJiwzoto.d.ts → printerFaker-Bhwq62d1.d.ts} +63 -26
  24. package/extension.yaml +817 -0
  25. package/package.json +8 -13
  26. package/src/components/Faker.tsx +44 -63
  27. package/src/generators/fakerGenerator.tsx +35 -35
  28. package/src/plugin.ts +23 -6
  29. package/src/printers/printerFaker.ts +80 -16
  30. package/src/resolvers/resolverFaker.ts +29 -37
  31. package/src/types.ts +36 -23
  32. package/src/utils.ts +6 -105
  33. package/dist/Faker-BgleOzVN.cjs.map +0 -1
  34. package/dist/Faker-fcQEB9i5.js.map +0 -1
  35. package/dist/fakerGenerator-C3Ho3BaI.d.ts +0 -9
  36. package/dist/fakerGenerator-D7daHCh6.js.map +0 -1
  37. package/dist/fakerGenerator-VJEVzLjc.cjs.map +0 -1
package/dist/index.cjs CHANGED
@@ -2,8 +2,8 @@ Object.defineProperties(exports, {
2
2
  __esModule: { value: true },
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
- const require_Faker = require("./Faker-BgleOzVN.cjs");
6
- const require_fakerGenerator = require("./fakerGenerator-VJEVzLjc.cjs");
5
+ const require_Faker = require("./Faker-CkJccVKI.cjs");
6
+ const require_fakerGenerator = require("./fakerGenerator-DhNV9xBw.cjs");
7
7
  let node_path = require("node:path");
8
8
  node_path = require_Faker.__toESM(node_path, 1);
9
9
  let _kubb_core = require("@kubb/core");
@@ -52,42 +52,163 @@ function camelCase(text, { isFile, prefix = "", suffix = "" } = {}) {
52
52
  return toCamelOrPascal(`${prefix} ${text} ${suffix}`, false);
53
53
  }
54
54
  //#endregion
55
- //#region src/resolvers/resolverFaker.ts
56
- function isValidStrictIdentifier(name) {
57
- try {
58
- new Function(`"use strict"; const ${name} = 1;`);
59
- } catch {
60
- return false;
61
- }
62
- return true;
55
+ //#region ../../internals/utils/src/reserved.ts
56
+ /**
57
+ * JavaScript and Java reserved words.
58
+ * @link https://github.com/jonschlinkert/reserved/blob/master/index.js
59
+ */
60
+ const reservedWords = new Set([
61
+ "abstract",
62
+ "arguments",
63
+ "boolean",
64
+ "break",
65
+ "byte",
66
+ "case",
67
+ "catch",
68
+ "char",
69
+ "class",
70
+ "const",
71
+ "continue",
72
+ "debugger",
73
+ "default",
74
+ "delete",
75
+ "do",
76
+ "double",
77
+ "else",
78
+ "enum",
79
+ "eval",
80
+ "export",
81
+ "extends",
82
+ "false",
83
+ "final",
84
+ "finally",
85
+ "float",
86
+ "for",
87
+ "function",
88
+ "goto",
89
+ "if",
90
+ "implements",
91
+ "import",
92
+ "in",
93
+ "instanceof",
94
+ "int",
95
+ "interface",
96
+ "let",
97
+ "long",
98
+ "native",
99
+ "new",
100
+ "null",
101
+ "package",
102
+ "private",
103
+ "protected",
104
+ "public",
105
+ "return",
106
+ "short",
107
+ "static",
108
+ "super",
109
+ "switch",
110
+ "synchronized",
111
+ "this",
112
+ "throw",
113
+ "throws",
114
+ "transient",
115
+ "true",
116
+ "try",
117
+ "typeof",
118
+ "var",
119
+ "void",
120
+ "volatile",
121
+ "while",
122
+ "with",
123
+ "yield",
124
+ "Array",
125
+ "Date",
126
+ "hasOwnProperty",
127
+ "Infinity",
128
+ "isFinite",
129
+ "isNaN",
130
+ "isPrototypeOf",
131
+ "length",
132
+ "Math",
133
+ "name",
134
+ "NaN",
135
+ "Number",
136
+ "Object",
137
+ "prototype",
138
+ "String",
139
+ "toString",
140
+ "undefined",
141
+ "valueOf"
142
+ ]);
143
+ /**
144
+ * Returns `true` when `name` is a syntactically valid JavaScript variable name.
145
+ *
146
+ * @example
147
+ * ```ts
148
+ * isValidVarName('status') // true
149
+ * isValidVarName('class') // false (reserved word)
150
+ * isValidVarName('42foo') // false (starts with digit)
151
+ * ```
152
+ */
153
+ function isValidVarName(name) {
154
+ if (!name || reservedWords.has(name)) return false;
155
+ return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(name);
63
156
  }
64
157
  /**
65
- * Naming convention resolver for Faker plugin.
158
+ * Returns `name` when it's a syntactically valid JavaScript variable name,
159
+ * otherwise prefixes it with `_` so the result is a valid identifier.
66
160
  *
67
- * Provides default naming helpers using camelCase. Prefixes invalid identifiers with `_`.
161
+ * Useful for sanitizing OpenAPI schema names or operation IDs that start with
162
+ * a digit (e.g. `409`, `504AccountCancel`) before using them as exported
163
+ * variable, type, or function names.
68
164
  *
69
165
  * @example
70
- * `resolverFaker.default('list pets', 'function') // → 'listPets'`
166
+ * ```ts
167
+ * ensureValidVarName('409') // '_409'
168
+ * ensureValidVarName('504AccountCancel') // '_504AccountCancel'
169
+ * ensureValidVarName('Pet') // 'Pet'
170
+ * ensureValidVarName('class') // '_class'
171
+ * ```
172
+ */
173
+ function ensureValidVarName(name) {
174
+ if (!name || isValidVarName(name)) return name;
175
+ return `_${name}`;
176
+ }
177
+ //#endregion
178
+ //#region src/resolvers/resolverFaker.ts
179
+ /**
180
+ * Default resolver used by `@kubb/plugin-faker`. Decides the names and file
181
+ * paths for every generated mock factory. Functions and files are prefixed
182
+ * with `create` so `Pet` becomes `createPet`.
183
+ *
184
+ * @example Resolve a factory name
185
+ * ```ts
186
+ * import { resolverFaker } from '@kubb/plugin-faker'
187
+ *
188
+ * resolverFaker.default('list pets', 'function') // 'createListPets'
189
+ * ```
71
190
  */
72
- const resolverFaker = (0, _kubb_core.defineResolver)((ctx) => {
191
+ const resolverFaker = (0, _kubb_core.defineResolver)(() => {
73
192
  return {
74
193
  name: "default",
75
194
  pluginName: "plugin-faker",
76
195
  default(name, type) {
77
- const resolvedName = camelCase(name, { isFile: type === "file" });
78
- if (type === "file" || isValidStrictIdentifier(resolvedName)) return resolvedName;
79
- return `_${resolvedName}`;
196
+ const resolvedName = camelCase(name, {
197
+ isFile: type === "file",
198
+ prefix: "create"
199
+ });
200
+ return type === "file" ? resolvedName : ensureValidVarName(resolvedName);
80
201
  },
81
202
  resolveName(name, type) {
82
- return ctx.default(name, type);
203
+ return this.default(name, type);
83
204
  },
84
205
  resolvePathName(name, type) {
85
- return ctx.default(name, type);
206
+ return this.default(name, type);
86
207
  },
87
208
  resolveFile({ name, extname, tag, path: groupPath }, context) {
88
- const pathMode = _kubb_core.PluginDriver.getMode(node_path.default.resolve(context.root, context.output.path));
89
- const baseName = `${pathMode === "single" ? "" : ctx.resolveName(name, "file")}${extname}`;
90
- const filePath = ctx.resolvePath({
209
+ const pathMode = _kubb_core.KubbDriver.getMode(node_path.default.resolve(context.root, context.output.path));
210
+ const baseName = `${pathMode === "single" ? "" : this.resolveName(name, "file")}${extname}`;
211
+ const filePath = this.resolvePath({
91
212
  baseName,
92
213
  pathMode,
93
214
  tag,
@@ -100,48 +221,68 @@ const resolverFaker = (0, _kubb_core.defineResolver)((ctx) => {
100
221
  path: filePath,
101
222
  baseName,
102
223
  extname,
103
- meta: { pluginName: ctx.pluginName },
224
+ meta: { pluginName: this.pluginName },
104
225
  sources: [],
105
226
  imports: [],
106
227
  exports: []
107
228
  };
108
229
  },
109
230
  resolveParamName(node, param) {
110
- return ctx.resolveName(`${node.operationId} ${param.in} ${param.name}`);
231
+ return this.resolveName(`${node.operationId} ${param.in} ${param.name}`);
111
232
  },
112
233
  resolveDataName(node) {
113
- return ctx.resolveName(`${node.operationId} Data`);
234
+ return this.resolveName(`${node.operationId} Data`);
114
235
  },
115
236
  resolveResponseStatusName(node, statusCode) {
116
- return ctx.resolveName(`${node.operationId} Status ${statusCode}`);
237
+ return this.resolveName(`${node.operationId} Status ${statusCode}`);
117
238
  },
118
239
  resolveResponseName(node) {
119
- return ctx.resolveName(`${node.operationId} Response`);
240
+ return this.resolveName(`${node.operationId} Response`);
241
+ },
242
+ resolveResponsesName(node) {
243
+ return this.resolveName(`${node.operationId} Responses`);
120
244
  },
121
245
  resolvePathParamsName(node, param) {
122
- return ctx.resolveParamName(node, param);
246
+ return this.resolveParamName(node, param);
123
247
  },
124
248
  resolveQueryParamsName(node, param) {
125
- return ctx.resolveParamName(node, param);
249
+ return this.resolveParamName(node, param);
126
250
  },
127
251
  resolveHeaderParamsName(node, param) {
128
- return ctx.resolveParamName(node, param);
252
+ return this.resolveParamName(node, param);
129
253
  }
130
254
  };
131
255
  });
132
256
  //#endregion
133
257
  //#region src/plugin.ts
134
258
  /**
135
- * Canonical plugin name for `@kubb/plugin-faker`, used in driver lookups and warnings.
259
+ * Canonical plugin name for `@kubb/plugin-faker`. Used for driver lookups and
260
+ * cross-plugin dependency references.
136
261
  */
137
262
  const pluginFakerName = "plugin-faker";
138
263
  /**
139
- * Generates Faker mock data factories from OpenAPI/AST specification.
140
- *
141
- * Creates randomized test data and mock helpers from schema definitions.
264
+ * Generates one mock-data factory per OpenAPI schema using Faker.js. Call
265
+ * `createPet()` to get a realistic `Pet` object. Useful for tests, Storybook,
266
+ * and local development without a running backend.
142
267
  *
143
268
  * @example
144
- * `import pluginFaker from '@kubb/plugin-faker'; export default defineConfig({ plugins: [pluginFaker({ output: { path: 'mocks' } })], })`
269
+ * ```ts
270
+ * import { defineConfig } from 'kubb'
271
+ * import { pluginTs } from '@kubb/plugin-ts'
272
+ * import { pluginFaker } from '@kubb/plugin-faker'
273
+ *
274
+ * export default defineConfig({
275
+ * input: { path: './petStore.yaml' },
276
+ * output: { path: './src/gen' },
277
+ * plugins: [
278
+ * pluginTs(),
279
+ * pluginFaker({
280
+ * output: { path: './mocks' },
281
+ * seed: [100],
282
+ * }),
283
+ * ],
284
+ * })
285
+ * ```
145
286
  */
146
287
  const pluginFaker = (0, _kubb_core.definePlugin)((options) => {
147
288
  const { output = {
@@ -154,7 +295,7 @@ const pluginFaker = (0, _kubb_core.definePlugin)((options) => {
154
295
  if (group.type === "path") return `${ctx.group.split("/")[1]}`;
155
296
  return `${camelCase(ctx.group)}Controller`;
156
297
  }
157
- } : void 0;
298
+ } : null;
158
299
  return {
159
300
  name: pluginFakerName,
160
301
  options,
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["PluginDriver","path","pluginTsName","fakerGenerator"],"sources":["../../../internals/utils/src/casing.ts","../src/resolvers/resolverFaker.ts","../src/plugin.ts"],"sourcesContent":["type Options = {\n /**\n * When `true`, dot-separated segments are split on `.` and joined with `/` after casing.\n */\n isFile?: boolean\n /**\n * Text prepended before casing is applied.\n */\n prefix?: string\n /**\n * Text appended before casing is applied.\n */\n suffix?: string\n}\n\n/**\n * Shared implementation for camelCase and PascalCase conversion.\n * Splits on common word boundaries (spaces, hyphens, underscores, dots, slashes, colons)\n * and capitalizes each word according to `pascal`.\n *\n * When `pascal` is `true` the first word is also capitalized (PascalCase), otherwise only subsequent words are.\n */\nfunction toCamelOrPascal(text: string, pascal: boolean): string {\n const normalized = text\n .trim()\n .replace(/([a-z\\d])([A-Z])/g, '$1 $2')\n .replace(/([A-Z]+)([A-Z][a-z])/g, '$1 $2')\n .replace(/(\\d)([a-z])/g, '$1 $2')\n\n const words = normalized.split(/[\\s\\-_./\\\\:]+/).filter(Boolean)\n\n return words\n .map((word, i) => {\n const allUpper = word.length > 1 && word === word.toUpperCase()\n if (allUpper) return word\n if (i === 0 && !pascal) return word.charAt(0).toLowerCase() + word.slice(1)\n return word.charAt(0).toUpperCase() + word.slice(1)\n })\n .join('')\n .replace(/[^a-zA-Z0-9]/g, '')\n}\n\n/**\n * Splits `text` on `.` and applies `transformPart` to each segment.\n * The last segment receives `isLast = true`, all earlier segments receive `false`.\n * Segments are joined with `/` to form a file path.\n *\n * Only splits on dots followed by a letter so that version numbers\n * embedded in operationIds (e.g. `v2025.0`) are kept intact.\n */\nfunction applyToFileParts(text: string, transformPart: (part: string, isLast: boolean) => string): string {\n const parts = text.split(/\\.(?=[a-zA-Z])/)\n return parts.map((part, i) => transformPart(part, i === parts.length - 1)).join('/')\n}\n\n/**\n * Converts `text` to camelCase.\n * When `isFile` is `true`, dot-separated segments are each cased independently and joined with `/`.\n *\n * @example\n * camelCase('hello-world') // 'helloWorld'\n * camelCase('pet.petId', { isFile: true }) // 'pet/petId'\n */\nexport function camelCase(text: string, { isFile, prefix = '', suffix = '' }: Options = {}): string {\n if (isFile) {\n return applyToFileParts(text, (part, isLast) => camelCase(part, isLast ? { prefix, suffix } : {}))\n }\n\n return toCamelOrPascal(`${prefix} ${text} ${suffix}`, false)\n}\n\n/**\n * Converts `text` to PascalCase.\n * When `isFile` is `true`, the last dot-separated segment is PascalCased and earlier segments are camelCased.\n *\n * @example\n * pascalCase('hello-world') // 'HelloWorld'\n * pascalCase('pet.petId', { isFile: true }) // 'pet/PetId'\n */\nexport function pascalCase(text: string, { isFile, prefix = '', suffix = '' }: Options = {}): string {\n if (isFile) {\n return applyToFileParts(text, (part, isLast) => (isLast ? pascalCase(part, { prefix, suffix }) : camelCase(part)))\n }\n\n return toCamelOrPascal(`${prefix} ${text} ${suffix}`, true)\n}\n\n/**\n * Converts `text` to snake_case.\n *\n * @example\n * snakeCase('helloWorld') // 'hello_world'\n * snakeCase('Hello-World') // 'hello_world'\n */\nexport function snakeCase(text: string, { prefix = '', suffix = '' }: Omit<Options, 'isFile'> = {}): string {\n const processed = `${prefix} ${text} ${suffix}`.trim()\n return processed\n .replace(/([a-z])([A-Z])/g, '$1_$2')\n .replace(/[\\s\\-.]+/g, '_')\n .replace(/[^a-zA-Z0-9_]/g, '')\n .toLowerCase()\n .split('_')\n .filter(Boolean)\n .join('_')\n}\n\n/**\n * Converts `text` to SCREAMING_SNAKE_CASE.\n *\n * @example\n * screamingSnakeCase('helloWorld') // 'HELLO_WORLD'\n */\nexport function screamingSnakeCase(text: string, { prefix = '', suffix = '' }: Omit<Options, 'isFile'> = {}): string {\n return snakeCase(text, { prefix, suffix }).toUpperCase()\n}\n","import { createHash } from 'node:crypto'\nimport path from 'node:path'\nimport { camelCase } from '@internals/utils'\nimport { defineResolver, PluginDriver } from '@kubb/core'\nimport type { PluginFaker } from '../types.ts'\n\nfunction isValidStrictIdentifier(name: string): boolean {\n try {\n new Function(`\"use strict\"; const ${name} = 1;`)\n } catch {\n return false\n }\n\n return true\n}\n\n/**\n * Naming convention resolver for Faker plugin.\n *\n * Provides default naming helpers using camelCase. Prefixes invalid identifiers with `_`.\n *\n * @example\n * `resolverFaker.default('list pets', 'function') // → 'listPets'`\n */\nexport const resolverFaker = defineResolver<PluginFaker>((ctx) => {\n return {\n name: 'default',\n pluginName: 'plugin-faker',\n default(name, type) {\n const resolvedName = camelCase(name, { isFile: type === 'file' })\n\n if (type === 'file' || isValidStrictIdentifier(resolvedName)) {\n return resolvedName\n }\n\n return `_${resolvedName}`\n },\n resolveName(name, type) {\n return ctx.default(name, type)\n },\n resolvePathName(name, type) {\n return ctx.default(name, type)\n },\n resolveFile({ name, extname, tag, path: groupPath }, context) {\n const pathMode = PluginDriver.getMode(path.resolve(context.root, context.output.path))\n const baseName = `${pathMode === 'single' ? '' : ctx.resolveName(name, 'file')}${extname}` as `${string}.${string}`\n const filePath = ctx.resolvePath(\n {\n baseName,\n pathMode,\n tag,\n path: groupPath,\n },\n context,\n )\n\n return {\n kind: 'File',\n id: createHash('sha256').update(filePath).digest('hex'),\n name: path.basename(filePath, extname),\n path: filePath,\n baseName,\n extname,\n meta: { pluginName: ctx.pluginName },\n sources: [],\n imports: [],\n exports: [],\n }\n },\n resolveParamName(node, param) {\n return ctx.resolveName(`${node.operationId} ${param.in} ${param.name}`)\n },\n resolveDataName(node) {\n return ctx.resolveName(`${node.operationId} Data`)\n },\n resolveResponseStatusName(node, statusCode) {\n return ctx.resolveName(`${node.operationId} Status ${statusCode}`)\n },\n resolveResponseName(node) {\n return ctx.resolveName(`${node.operationId} Response`)\n },\n resolvePathParamsName(node, param) {\n return ctx.resolveParamName(node, param)\n },\n resolveQueryParamsName(node, param) {\n return ctx.resolveParamName(node, param)\n },\n resolveHeaderParamsName(node, param) {\n return ctx.resolveParamName(node, param)\n },\n }\n})\n","import { camelCase } from '@internals/utils'\nimport { definePlugin, type Group } from '@kubb/core'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { fakerGenerator } from './generators/fakerGenerator.tsx'\nimport { resolverFaker } from './resolvers/resolverFaker.ts'\nimport type { PluginFaker } from './types.ts'\n\n/**\n * Canonical plugin name for `@kubb/plugin-faker`, used in driver lookups and warnings.\n */\nexport const pluginFakerName = 'plugin-faker' satisfies PluginFaker['name']\n\n/**\n * Generates Faker mock data factories from OpenAPI/AST specification.\n *\n * Creates randomized test data and mock helpers from schema definitions.\n *\n * @example\n * `import pluginFaker from '@kubb/plugin-faker'; export default defineConfig({ plugins: [pluginFaker({ output: { path: 'mocks' } })], })`\n */\nexport const pluginFaker = definePlugin<PluginFaker>((options) => {\n const {\n output = { path: 'mocks', barrelType: 'named' },\n seed,\n locale,\n group,\n exclude = [],\n include,\n override = [],\n mapper = {},\n dateParser = 'faker',\n generators: userGenerators = [],\n regexGenerator = 'faker',\n paramsCasing,\n printer,\n resolver: userResolver,\n transformer: userTransformer,\n } = options\n\n const groupConfig = group\n ? ({\n ...group,\n name: group.name\n ? group.name\n : (ctx: { group: string }) => {\n if (group.type === 'path') {\n return `${ctx.group.split('/')[1]}`\n }\n\n return `${camelCase(ctx.group)}Controller`\n },\n } satisfies Group)\n : undefined\n\n return {\n name: pluginFakerName,\n options,\n dependencies: [pluginTsName],\n hooks: {\n 'kubb:plugin:setup'(ctx) {\n ctx.setOptions({\n output,\n seed,\n locale,\n exclude,\n include,\n override,\n group: groupConfig,\n mapper,\n dateParser,\n regexGenerator,\n paramsCasing,\n printer,\n })\n ctx.setResolver(userResolver ? { ...resolverFaker, ...userResolver } : resolverFaker)\n if (userTransformer) {\n ctx.setTransformer(userTransformer)\n }\n ctx.addGenerator(fakerGenerator)\n for (const generator of userGenerators) {\n ctx.addGenerator(generator)\n }\n },\n },\n }\n})\n\nexport default pluginFaker\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAsBA,SAAS,gBAAgB,MAAc,QAAyB;AAS9D,QARmB,KAChB,MAAM,CACN,QAAQ,qBAAqB,QAAQ,CACrC,QAAQ,yBAAyB,QAAQ,CACzC,QAAQ,gBAAgB,QAEH,CAAC,MAAM,gBAAgB,CAAC,OAAO,QAE3C,CACT,KAAK,MAAM,MAAM;AAEhB,MADiB,KAAK,SAAS,KAAK,SAAS,KAAK,aAAa,CACjD,QAAO;AACrB,MAAI,MAAM,KAAK,CAAC,OAAQ,QAAO,KAAK,OAAO,EAAE,CAAC,aAAa,GAAG,KAAK,MAAM,EAAE;AAC3E,SAAO,KAAK,OAAO,EAAE,CAAC,aAAa,GAAG,KAAK,MAAM,EAAE;GACnD,CACD,KAAK,GAAG,CACR,QAAQ,iBAAiB,GAAG;;;;;;;;;;AAWjC,SAAS,iBAAiB,MAAc,eAAkE;CACxG,MAAM,QAAQ,KAAK,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tC,GACD,KAAA;AAEJ,QAAO;EACL,MAAM;EACN;EACA,cAAc,CAACC,gBAAAA,aAAa;EAC5B,OAAO,EACL,oBAAoB,KAAK;AACvB,OAAI,WAAW;IACb;IACA;IACA;IACA;IACA;IACA;IACA,OAAO;IACP;IACA;IACA;IACA;IACA;IACD,CAAC;AACF,OAAI,YAAY,eAAe;IAAE,GAAG;IAAe,GAAG;IAAc,GAAG,cAAc;AACrF,OAAI,gBACF,KAAI,eAAe,gBAAgB;AAErC,OAAI,aAAaC,uBAAAA,eAAe;AAChC,QAAK,MAAM,aAAa,eACtB,KAAI,aAAa,UAAU;KAGhC;EACF;EACD"}
1
+ {"version":3,"file":"index.cjs","names":["KubbDriver","path","pluginTsName","fakerGenerator"],"sources":["../../../internals/utils/src/casing.ts","../../../internals/utils/src/reserved.ts","../src/resolvers/resolverFaker.ts","../src/plugin.ts"],"sourcesContent":["type Options = {\n /**\n * When `true`, dot-separated segments are split on `.` and joined with `/` after casing.\n */\n isFile?: boolean\n /**\n * Text prepended before casing is applied.\n */\n prefix?: string\n /**\n * Text appended before casing is applied.\n */\n suffix?: string\n}\n\n/**\n * Shared implementation for camelCase and PascalCase conversion.\n * Splits on common word boundaries (spaces, hyphens, underscores, dots, slashes, colons)\n * and capitalizes each word according to `pascal`.\n *\n * When `pascal` is `true` the first word is also capitalized (PascalCase), otherwise only subsequent words are.\n */\nfunction toCamelOrPascal(text: string, pascal: boolean): string {\n const normalized = text\n .trim()\n .replace(/([a-z\\d])([A-Z])/g, '$1 $2')\n .replace(/([A-Z]+)([A-Z][a-z])/g, '$1 $2')\n .replace(/(\\d)([a-z])/g, '$1 $2')\n\n const words = normalized.split(/[\\s\\-_./\\\\:]+/).filter(Boolean)\n\n return words\n .map((word, i) => {\n const allUpper = word.length > 1 && word === word.toUpperCase()\n if (allUpper) return word\n if (i === 0 && !pascal) return word.charAt(0).toLowerCase() + word.slice(1)\n return word.charAt(0).toUpperCase() + word.slice(1)\n })\n .join('')\n .replace(/[^a-zA-Z0-9]/g, '')\n}\n\n/**\n * Splits `text` on `.` and applies `transformPart` to each segment.\n * The last segment receives `isLast = true`, all earlier segments receive `false`.\n * Segments are joined with `/` to form a file path.\n *\n * Only splits on dots followed by a letter so that version numbers\n * embedded in operationIds (e.g. `v2025.0`) are kept intact.\n */\nfunction applyToFileParts(text: string, transformPart: (part: string, isLast: boolean) => string): string {\n const parts = text.split(/\\.(?=[a-zA-Z])/)\n return parts.map((part, i) => transformPart(part, i === parts.length - 1)).join('/')\n}\n\n/**\n * Converts `text` to camelCase.\n * When `isFile` is `true`, dot-separated segments are each cased independently and joined with `/`.\n *\n * @example\n * camelCase('hello-world') // 'helloWorld'\n * camelCase('pet.petId', { isFile: true }) // 'pet/petId'\n */\nexport function camelCase(text: string, { isFile, prefix = '', suffix = '' }: Options = {}): string {\n if (isFile) {\n return applyToFileParts(text, (part, isLast) => camelCase(part, isLast ? { prefix, suffix } : {}))\n }\n\n return toCamelOrPascal(`${prefix} ${text} ${suffix}`, false)\n}\n\n/**\n * Converts `text` to PascalCase.\n * When `isFile` is `true`, the last dot-separated segment is PascalCased and earlier segments are camelCased.\n *\n * @example\n * pascalCase('hello-world') // 'HelloWorld'\n * pascalCase('pet.petId', { isFile: true }) // 'pet/PetId'\n */\nexport function pascalCase(text: string, { isFile, prefix = '', suffix = '' }: Options = {}): string {\n if (isFile) {\n return applyToFileParts(text, (part, isLast) => (isLast ? pascalCase(part, { prefix, suffix }) : camelCase(part)))\n }\n\n return toCamelOrPascal(`${prefix} ${text} ${suffix}`, true)\n}\n\n/**\n * Converts `text` to snake_case.\n *\n * @example\n * snakeCase('helloWorld') // 'hello_world'\n * snakeCase('Hello-World') // 'hello_world'\n */\nexport function snakeCase(text: string, { prefix = '', suffix = '' }: Omit<Options, 'isFile'> = {}): string {\n const processed = `${prefix} ${text} ${suffix}`.trim()\n return processed\n .replace(/([a-z])([A-Z])/g, '$1_$2')\n .replace(/[\\s\\-.]+/g, '_')\n .replace(/[^a-zA-Z0-9_]/g, '')\n .toLowerCase()\n .split('_')\n .filter(Boolean)\n .join('_')\n}\n\n/**\n * Converts `text` to SCREAMING_SNAKE_CASE.\n *\n * @example\n * screamingSnakeCase('helloWorld') // 'HELLO_WORLD'\n */\nexport function screamingSnakeCase(text: string, { prefix = '', suffix = '' }: Omit<Options, 'isFile'> = {}): string {\n return snakeCase(text, { prefix, suffix }).toUpperCase()\n}\n","/**\n * JavaScript and Java reserved words.\n * @link https://github.com/jonschlinkert/reserved/blob/master/index.js\n */\nconst reservedWords = new Set([\n 'abstract',\n 'arguments',\n 'boolean',\n 'break',\n 'byte',\n 'case',\n 'catch',\n 'char',\n 'class',\n 'const',\n 'continue',\n 'debugger',\n 'default',\n 'delete',\n 'do',\n 'double',\n 'else',\n 'enum',\n 'eval',\n 'export',\n 'extends',\n 'false',\n 'final',\n 'finally',\n 'float',\n 'for',\n 'function',\n 'goto',\n 'if',\n 'implements',\n 'import',\n 'in',\n 'instanceof',\n 'int',\n 'interface',\n 'let',\n 'long',\n 'native',\n 'new',\n 'null',\n 'package',\n 'private',\n 'protected',\n 'public',\n 'return',\n 'short',\n 'static',\n 'super',\n 'switch',\n 'synchronized',\n 'this',\n 'throw',\n 'throws',\n 'transient',\n 'true',\n 'try',\n 'typeof',\n 'var',\n 'void',\n 'volatile',\n 'while',\n 'with',\n 'yield',\n 'Array',\n 'Date',\n 'hasOwnProperty',\n 'Infinity',\n 'isFinite',\n 'isNaN',\n 'isPrototypeOf',\n 'length',\n 'Math',\n 'name',\n 'NaN',\n 'Number',\n 'Object',\n 'prototype',\n 'String',\n 'toString',\n 'undefined',\n 'valueOf',\n] as const)\n\n/**\n * Returns `true` when `name` is a syntactically valid JavaScript variable name.\n *\n * @example\n * ```ts\n * isValidVarName('status') // true\n * isValidVarName('class') // false (reserved word)\n * isValidVarName('42foo') // false (starts with digit)\n * ```\n */\nexport function isValidVarName(name: string): boolean {\n if (!name || reservedWords.has(name as 'valueOf')) {\n return false\n }\n return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(name)\n}\n\n/**\n * Returns `name` when it's a syntactically valid JavaScript variable name,\n * otherwise prefixes it with `_` so the result is a valid identifier.\n *\n * Useful for sanitizing OpenAPI schema names or operation IDs that start with\n * a digit (e.g. `409`, `504AccountCancel`) before using them as exported\n * variable, type, or function names.\n *\n * @example\n * ```ts\n * ensureValidVarName('409') // '_409'\n * ensureValidVarName('504AccountCancel') // '_504AccountCancel'\n * ensureValidVarName('Pet') // 'Pet'\n * ensureValidVarName('class') // '_class'\n * ```\n */\nexport function ensureValidVarName(name: string): string {\n if (!name || isValidVarName(name)) {\n return name\n }\n return `_${name}`\n}\n","import { createHash } from 'node:crypto'\nimport path from 'node:path'\nimport { camelCase, ensureValidVarName } from '@internals/utils'\nimport { defineResolver, KubbDriver } from '@kubb/core'\nimport type { PluginFaker } from '../types.ts'\n\n/**\n * Default resolver used by `@kubb/plugin-faker`. Decides the names and file\n * paths for every generated mock factory. Functions and files are prefixed\n * with `create` so `Pet` becomes `createPet`.\n *\n * @example Resolve a factory name\n * ```ts\n * import { resolverFaker } from '@kubb/plugin-faker'\n *\n * resolverFaker.default('list pets', 'function') // 'createListPets'\n * ```\n */\nexport const resolverFaker = defineResolver<PluginFaker>(() => {\n return {\n name: 'default',\n pluginName: 'plugin-faker',\n default(name, type) {\n const resolvedName = camelCase(name, { isFile: type === 'file', prefix: 'create' })\n return type === 'file' ? resolvedName : ensureValidVarName(resolvedName)\n },\n resolveName(name, type) {\n return this.default(name, type)\n },\n resolvePathName(name, type) {\n return this.default(name, type)\n },\n resolveFile({ name, extname, tag, path: groupPath }, context) {\n const pathMode = KubbDriver.getMode(path.resolve(context.root, context.output.path))\n const baseName = `${pathMode === 'single' ? '' : this.resolveName(name, 'file')}${extname}` as `${string}.${string}`\n const filePath = this.resolvePath(\n {\n baseName,\n pathMode,\n tag,\n path: groupPath,\n },\n context,\n )\n\n return {\n kind: 'File',\n id: createHash('sha256').update(filePath).digest('hex'),\n name: path.basename(filePath, extname),\n path: filePath,\n baseName,\n extname,\n meta: { pluginName: this.pluginName },\n sources: [],\n imports: [],\n exports: [],\n }\n },\n resolveParamName(node, param) {\n return this.resolveName(`${node.operationId} ${param.in} ${param.name}`)\n },\n resolveDataName(node) {\n return this.resolveName(`${node.operationId} Data`)\n },\n resolveResponseStatusName(node, statusCode) {\n return this.resolveName(`${node.operationId} Status ${statusCode}`)\n },\n resolveResponseName(node) {\n return this.resolveName(`${node.operationId} Response`)\n },\n resolveResponsesName(node) {\n return this.resolveName(`${node.operationId} Responses`)\n },\n resolvePathParamsName(node, param) {\n return this.resolveParamName(node, param)\n },\n resolveQueryParamsName(node, param) {\n return this.resolveParamName(node, param)\n },\n resolveHeaderParamsName(node, param) {\n return this.resolveParamName(node, param)\n },\n }\n})\n","import { camelCase } from '@internals/utils'\nimport { definePlugin, type Group } from '@kubb/core'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { fakerGenerator } from './generators/fakerGenerator.tsx'\nimport { resolverFaker } from './resolvers/resolverFaker.ts'\nimport type { PluginFaker } from './types.ts'\n\n/**\n * Canonical plugin name for `@kubb/plugin-faker`. Used for driver lookups and\n * cross-plugin dependency references.\n */\nexport const pluginFakerName = 'plugin-faker' satisfies PluginFaker['name']\n\n/**\n * Generates one mock-data factory per OpenAPI schema using Faker.js. Call\n * `createPet()` to get a realistic `Pet` object. Useful for tests, Storybook,\n * and local development without a running backend.\n *\n * @example\n * ```ts\n * import { defineConfig } from 'kubb'\n * import { pluginTs } from '@kubb/plugin-ts'\n * import { pluginFaker } from '@kubb/plugin-faker'\n *\n * export default defineConfig({\n * input: { path: './petStore.yaml' },\n * output: { path: './src/gen' },\n * plugins: [\n * pluginTs(),\n * pluginFaker({\n * output: { path: './mocks' },\n * seed: [100],\n * }),\n * ],\n * })\n * ```\n */\nexport const pluginFaker = definePlugin<PluginFaker>((options) => {\n const {\n output = { path: 'mocks', barrelType: 'named' },\n seed,\n locale,\n group,\n exclude = [],\n include,\n override = [],\n mapper = {},\n dateParser = 'faker',\n generators: userGenerators = [],\n regexGenerator = 'faker',\n paramsCasing,\n printer,\n resolver: userResolver,\n transformer: userTransformer,\n } = options\n\n const groupConfig = group\n ? ({\n ...group,\n name: group.name\n ? group.name\n : (ctx: { group: string }) => {\n if (group.type === 'path') {\n return `${ctx.group.split('/')[1]}`\n }\n\n return `${camelCase(ctx.group)}Controller`\n },\n } satisfies Group)\n : null\n\n return {\n name: pluginFakerName,\n options,\n dependencies: [pluginTsName],\n hooks: {\n 'kubb:plugin:setup'(ctx) {\n ctx.setOptions({\n output,\n seed,\n locale,\n exclude,\n include,\n override,\n group: groupConfig,\n mapper,\n dateParser,\n regexGenerator,\n paramsCasing,\n printer,\n })\n ctx.setResolver(userResolver ? { ...resolverFaker, ...userResolver } : resolverFaker)\n if (userTransformer) {\n ctx.setTransformer(userTransformer)\n }\n ctx.addGenerator(fakerGenerator)\n for (const generator of userGenerators) {\n ctx.addGenerator(generator)\n }\n },\n },\n }\n})\n\nexport default pluginFaker\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAsBA,SAAS,gBAAgB,MAAc,QAAyB;CAS9D,OARmB,KAChB,MAAM,CACN,QAAQ,qBAAqB,QAAQ,CACrC,QAAQ,yBAAyB,QAAQ,CACzC,QAAQ,gBAAgB,QAEH,CAAC,MAAM,gBAAgB,CAAC,OAAO,QAE3C,CACT,KAAK,MAAM,MAAM;EAEhB,IADiB,KAAK,SAAS,KAAK,SAAS,KAAK,aAAa,EACjD,OAAO;EACrB,IAAI,MAAM,KAAK,CAAC,QAAQ,OAAO,KAAK,OAAO,EAAE,CAAC,aAAa,GAAG,KAAK,MAAM,EAAE;EAC3E,OAAO,KAAK,OAAO,EAAE,CAAC,aAAa,GAAG,KAAK,MAAM,EAAE;GACnD,CACD,KAAK,GAAG,CACR,QAAQ,iBAAiB,GAAG;;;;;;;;;;AAWjC,SAAS,iBAAiB,MAAc,eAAkE;CACxG,MAAM,QAAQ,KAAK,MAAM,iBAAiB;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AM,OAAO;GAClC,OAAO,KAAK,iBAAiB,MAAM,MAAM;;EAE3C,wBAAwB,MAAM,OAAO;GACnC,OAAO,KAAK,iBAAiB,MAAM,MAAM;;EAE5C;EACD;;;;;;;ACxEF,MAAa,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;AA0B/B,MAAa,eAAA,GAAA,WAAA,eAAyC,YAAY;CAChE,MAAM,EACJ,SAAS;EAAE,MAAM;EAAS,YAAY;EAAS,EAC/C,MACA,QACA,OACA,UAAU,EAAE,EACZ,SACA,WAAW,EAAE,EACb,SAAS,EAAE,EACX,aAAa,SACb,YAAY,iBAAiB,EAAE,EAC/B,iBAAiB,SACjB,cACA,SACA,UAAU,cACV,aAAa,oBACX;CAEJ,MAAM,cAAc,QACf;EACC,GAAG;EACH,MAAM,MAAM,OACR,MAAM,QACL,QAA2B;GAC1B,IAAI,MAAM,SAAS,QACjB,OAAO,GAAG,IAAI,MAAM,MAAM,IAAI,CAAC;GAGjC,OAAO,GAAG,UAAU,IAAI,MAAM,CAAC;;EAEtC,GACD;CAEJ,OAAO;EACL,MAAM;EACN;EACA,cAAc,CAACC,gBAAAA,aAAa;EAC5B,OAAO,EACL,oBAAoB,KAAK;GACvB,IAAI,WAAW;IACb;IACA;IACA;IACA;IACA;IACA;IACA,OAAO;IACP;IACA;IACA;IACA;IACA;IACD,CAAC;GACF,IAAI,YAAY,eAAe;IAAE,GAAG;IAAe,GAAG;IAAc,GAAG,cAAc;GACrF,IAAI,iBACF,IAAI,eAAe,gBAAgB;GAErC,IAAI,aAAaC,uBAAAA,eAAe;GAChC,KAAK,MAAM,aAAa,gBACtB,IAAI,aAAa,UAAU;KAGhC;EACF;EACD"}
package/dist/index.d.ts CHANGED
@@ -1,32 +1,53 @@
1
1
  import { t as __name } from "./chunk--u3MIqq1.js";
2
- import { a as Options, i as printerFaker, n as PrinterFakerNodes, o as PluginFaker, r as PrinterFakerOptions, s as ResolverFaker, t as PrinterFakerFactory } from "./printerFaker-CJiwzoto.js";
3
- import { t as Faker } from "./Faker-CdyPfOPg.js";
4
- import { t as fakerGenerator } from "./fakerGenerator-C3Ho3BaI.js";
2
+ import { a as Options, i as printerFaker, n as PrinterFakerNodes, o as PluginFaker, r as PrinterFakerOptions, s as ResolverFaker, t as PrinterFakerFactory } from "./printerFaker-Bhwq62d1.js";
3
+ import { t as Faker } from "./Faker-BaLJxPyl.js";
4
+ import { t as fakerGenerator } from "./fakerGenerator-DSvAJTq3.js";
5
5
  import * as _$_kubb_core0 from "@kubb/core";
6
6
 
7
7
  //#region src/plugin.d.ts
8
8
  /**
9
- * Canonical plugin name for `@kubb/plugin-faker`, used in driver lookups and warnings.
9
+ * Canonical plugin name for `@kubb/plugin-faker`. Used for driver lookups and
10
+ * cross-plugin dependency references.
10
11
  */
11
12
  declare const pluginFakerName = "plugin-faker";
12
13
  /**
13
- * Generates Faker mock data factories from OpenAPI/AST specification.
14
- *
15
- * Creates randomized test data and mock helpers from schema definitions.
14
+ * Generates one mock-data factory per OpenAPI schema using Faker.js. Call
15
+ * `createPet()` to get a realistic `Pet` object. Useful for tests, Storybook,
16
+ * and local development without a running backend.
16
17
  *
17
18
  * @example
18
- * `import pluginFaker from '@kubb/plugin-faker'; export default defineConfig({ plugins: [pluginFaker({ output: { path: 'mocks' } })], })`
19
+ * ```ts
20
+ * import { defineConfig } from 'kubb'
21
+ * import { pluginTs } from '@kubb/plugin-ts'
22
+ * import { pluginFaker } from '@kubb/plugin-faker'
23
+ *
24
+ * export default defineConfig({
25
+ * input: { path: './petStore.yaml' },
26
+ * output: { path: './src/gen' },
27
+ * plugins: [
28
+ * pluginTs(),
29
+ * pluginFaker({
30
+ * output: { path: './mocks' },
31
+ * seed: [100],
32
+ * }),
33
+ * ],
34
+ * })
35
+ * ```
19
36
  */
20
37
  declare const pluginFaker: (options?: Options | undefined) => _$_kubb_core0.Plugin<PluginFaker>;
21
38
  //#endregion
22
39
  //#region src/resolvers/resolverFaker.d.ts
23
40
  /**
24
- * Naming convention resolver for Faker plugin.
41
+ * Default resolver used by `@kubb/plugin-faker`. Decides the names and file
42
+ * paths for every generated mock factory. Functions and files are prefixed
43
+ * with `create` so `Pet` becomes `createPet`.
25
44
  *
26
- * Provides default naming helpers using camelCase. Prefixes invalid identifiers with `_`.
45
+ * @example Resolve a factory name
46
+ * ```ts
47
+ * import { resolverFaker } from '@kubb/plugin-faker'
27
48
  *
28
- * @example
29
- * `resolverFaker.default('list pets', 'function') // → 'listPets'`
49
+ * resolverFaker.default('list pets', 'function') // 'createListPets'
50
+ * ```
30
51
  */
31
52
  declare const resolverFaker: ResolverFaker;
32
53
  //#endregion