@kubb/plugin-faker 4.4.1 → 4.5.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/{components-DdXRywj6.js → components-B6wjVu4Y.js} +32 -25
- package/dist/components-B6wjVu4Y.js.map +1 -0
- package/dist/{components-BtFAhtPK.cjs → components-Dq57kUQf.cjs} +32 -25
- package/dist/components-Dq57kUQf.cjs.map +1 -0
- package/dist/components.cjs +1 -1
- package/dist/components.d.cts +1 -1
- package/dist/components.d.ts +1 -1
- package/dist/components.js +1 -1
- package/dist/{fakerGenerator-6YTX8ENZ.cjs → fakerGenerator-CYRnwp6R.cjs} +40 -47
- package/dist/fakerGenerator-CYRnwp6R.cjs.map +1 -0
- package/dist/{fakerGenerator-D3zaPh1_.js → fakerGenerator-CfTiMdtr.js} +41 -48
- package/dist/fakerGenerator-CfTiMdtr.js.map +1 -0
- package/dist/generators.cjs +2 -2
- package/dist/generators.d.cts +1 -1
- package/dist/generators.d.ts +1 -1
- package/dist/generators.js +2 -2
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/{types-Dda1jVMe.d.ts → types-CEWRTyrN.d.ts} +168 -174
- package/dist/{types-DRMQqYat.d.cts → types-NHbH6Svj.d.cts} +168 -174
- package/package.json +8 -8
- package/src/components/Faker.tsx +1 -3
- package/src/generators/__snapshots__/enumNames.ts +1 -1
- package/src/generators/__snapshots__/enumVarNames.ts +1 -1
- package/src/generators/fakerGenerator.tsx +17 -18
- package/src/parser.ts +9 -13
- package/src/types.ts +2 -1
- package/dist/components-BtFAhtPK.cjs.map +0 -1
- package/dist/components-DdXRywj6.js.map +0 -1
- package/dist/fakerGenerator-6YTX8ENZ.cjs.map +0 -1
- package/dist/fakerGenerator-D3zaPh1_.js.map +0 -1
|
@@ -105,31 +105,35 @@ function joinItems(items) {
|
|
|
105
105
|
default: return fakerKeywordMapper.union(items);
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
|
-
function parse({ current, parent, name, siblings }, options) {
|
|
108
|
+
function parse({ schema, current, parent, name, siblings }, options) {
|
|
109
109
|
const value = fakerKeywordMapper[current.keyword];
|
|
110
110
|
if (!value) return;
|
|
111
111
|
if (isKeyword(current, schemaKeywords.union)) {
|
|
112
112
|
if (Array.isArray(current.args) && !current.args.length) return "";
|
|
113
|
-
return fakerKeywordMapper.union(current.args.map((
|
|
113
|
+
return fakerKeywordMapper.union(current.args.map((it) => parse({
|
|
114
|
+
schema,
|
|
114
115
|
parent: current,
|
|
115
|
-
|
|
116
|
+
name,
|
|
117
|
+
current: it,
|
|
116
118
|
siblings
|
|
117
119
|
}, {
|
|
118
120
|
...options,
|
|
119
121
|
canOverride: false
|
|
120
122
|
})).filter(Boolean));
|
|
121
123
|
}
|
|
122
|
-
if (isKeyword(current, schemaKeywords.and)) return fakerKeywordMapper.and(current.args.map((
|
|
124
|
+
if (isKeyword(current, schemaKeywords.and)) return fakerKeywordMapper.and(current.args.map((it) => parse({
|
|
125
|
+
schema,
|
|
123
126
|
parent: current,
|
|
124
|
-
current:
|
|
127
|
+
current: it,
|
|
125
128
|
siblings
|
|
126
129
|
}, {
|
|
127
130
|
...options,
|
|
128
131
|
canOverride: false
|
|
129
132
|
})).filter(Boolean));
|
|
130
|
-
if (isKeyword(current, schemaKeywords.array)) return fakerKeywordMapper.array(current.args.items.map((
|
|
133
|
+
if (isKeyword(current, schemaKeywords.array)) return fakerKeywordMapper.array(current.args.items.map((it) => parse({
|
|
134
|
+
schema,
|
|
131
135
|
parent: current,
|
|
132
|
-
current:
|
|
136
|
+
current: it,
|
|
133
137
|
siblings
|
|
134
138
|
}, {
|
|
135
139
|
...options,
|
|
@@ -137,15 +141,15 @@ function parse({ current, parent, name, siblings }, options) {
|
|
|
137
141
|
canOverride: false
|
|
138
142
|
})).filter(Boolean), current.args.min, current.args.max);
|
|
139
143
|
if (isKeyword(current, schemaKeywords.enum)) {
|
|
140
|
-
if (parent ? isKeyword(parent, schemaKeywords.tuple) : false) return fakerKeywordMapper.enum(current.args.items.map((schema) => {
|
|
141
|
-
if (schema.format === "number") return schema.value;
|
|
142
|
-
if (schema.format === "boolean") return schema.value;
|
|
143
|
-
return transformers.stringify(schema.value);
|
|
144
|
+
if (parent ? isKeyword(parent, schemaKeywords.tuple) : false) return fakerKeywordMapper.enum(current.args.items.map((schema$1) => {
|
|
145
|
+
if (schema$1.format === "number") return schema$1.value;
|
|
146
|
+
if (schema$1.format === "boolean") return schema$1.value;
|
|
147
|
+
return transformers.stringify(schema$1.value);
|
|
144
148
|
}));
|
|
145
|
-
return fakerKeywordMapper.enum(current.args.items.map((schema) => {
|
|
146
|
-
if (schema.format === "number") return schema.value;
|
|
147
|
-
if (schema.format === "boolean") return schema.value;
|
|
148
|
-
return transformers.stringify(schema.value);
|
|
149
|
+
return fakerKeywordMapper.enum(current.args.items.map((schema$1) => {
|
|
150
|
+
if (schema$1.format === "number") return schema$1.value;
|
|
151
|
+
if (schema$1.format === "boolean") return schema$1.value;
|
|
152
|
+
return transformers.stringify(schema$1.value);
|
|
149
153
|
}), name ? options.typeName : void 0);
|
|
150
154
|
}
|
|
151
155
|
if (isKeyword(current, schemaKeywords.ref)) {
|
|
@@ -154,15 +158,16 @@ function parse({ current, parent, name, siblings }, options) {
|
|
|
154
158
|
return `${current.args.name}()`;
|
|
155
159
|
}
|
|
156
160
|
if (isKeyword(current, schemaKeywords.object)) return `{${Object.entries(current.args?.properties || {}).filter((item) => {
|
|
157
|
-
const schema = item[1];
|
|
158
|
-
return schema && typeof schema.map === "function";
|
|
161
|
+
const schema$1 = item[1];
|
|
162
|
+
return schema$1 && typeof schema$1.map === "function";
|
|
159
163
|
}).map(([name$1, schemas]) => {
|
|
160
|
-
const mappedName = schemas.find((schema) => schema.keyword === schemaKeywords.name)?.args || name$1;
|
|
164
|
+
const mappedName = schemas.find((schema$1) => schema$1.keyword === schemaKeywords.name)?.args || name$1;
|
|
161
165
|
if (options.mapper?.[mappedName]) return `"${name$1}": ${options.mapper?.[mappedName]}`;
|
|
162
|
-
return `"${name$1}": ${joinItems(schemas.sort(schemaKeywordSorter).map((
|
|
166
|
+
return `"${name$1}": ${joinItems(schemas.sort(schemaKeywordSorter).map((it) => parse({
|
|
167
|
+
schema,
|
|
163
168
|
name: name$1,
|
|
164
169
|
parent: current,
|
|
165
|
-
current:
|
|
170
|
+
current: it,
|
|
166
171
|
siblings: schemas
|
|
167
172
|
}, {
|
|
168
173
|
...options,
|
|
@@ -171,15 +176,17 @@ function parse({ current, parent, name, siblings }, options) {
|
|
|
171
176
|
})).filter(Boolean))}`;
|
|
172
177
|
}).join(",")}}`;
|
|
173
178
|
if (isKeyword(current, schemaKeywords.tuple)) {
|
|
174
|
-
if (Array.isArray(current.args.items)) return fakerKeywordMapper.tuple(current.args.items.map((
|
|
179
|
+
if (Array.isArray(current.args.items)) return fakerKeywordMapper.tuple(current.args.items.map((it) => parse({
|
|
180
|
+
schema,
|
|
175
181
|
parent: current,
|
|
176
|
-
current:
|
|
182
|
+
current: it,
|
|
177
183
|
siblings
|
|
178
184
|
}, {
|
|
179
185
|
...options,
|
|
180
186
|
canOverride: false
|
|
181
187
|
})).filter(Boolean));
|
|
182
188
|
return parse({
|
|
189
|
+
schema,
|
|
183
190
|
parent: current,
|
|
184
191
|
current: current.args.items,
|
|
185
192
|
siblings
|
|
@@ -232,13 +239,13 @@ function parse({ current, parent, name, siblings }, options) {
|
|
|
232
239
|
//#region src/components/Faker.tsx
|
|
233
240
|
function Faker({ tree, description, name, typeName, seed, regexGenerator, canOverride, mapper, dateParser }) {
|
|
234
241
|
const fakerText = joinItems(tree.map((schema, _index, siblings) => parse({
|
|
242
|
+
name,
|
|
243
|
+
schema,
|
|
235
244
|
parent: void 0,
|
|
236
245
|
current: schema,
|
|
237
246
|
siblings
|
|
238
247
|
}, {
|
|
239
|
-
name,
|
|
240
248
|
typeName,
|
|
241
|
-
seed,
|
|
242
249
|
regexGenerator,
|
|
243
250
|
mapper,
|
|
244
251
|
canOverride,
|
|
@@ -294,4 +301,4 @@ function Faker({ tree, description, name, typeName, seed, regexGenerator, canOve
|
|
|
294
301
|
|
|
295
302
|
//#endregion
|
|
296
303
|
export { Faker as t };
|
|
297
|
-
//# sourceMappingURL=components-
|
|
304
|
+
//# sourceMappingURL=components-B6wjVu4Y.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"components-B6wjVu4Y.js","names":["schema","name","value","parserFaker.joinItems","parserFaker.parse"],"sources":["../src/parser.ts","../src/components/Faker.tsx"],"sourcesContent":["import transformers from '@kubb/core/transformers'\nimport type { Schema, SchemaKeywordBase, SchemaKeywordMapper, SchemaMapper } from '@kubb/plugin-oas'\nimport { isKeyword, SchemaGenerator, type SchemaTree, schemaKeywords } from '@kubb/plugin-oas'\nimport type { Options } from './types.ts'\n\nconst fakerKeywordMapper = {\n any: () => 'undefined',\n unknown: () => 'undefined',\n void: () => 'undefined',\n number: (min?: number, max?: number) => {\n if (max !== undefined && min !== undefined) {\n return `faker.number.float({ min: ${min}, max: ${max} })`\n }\n\n if (max !== undefined) {\n return `faker.number.float({ max: ${max} })`\n }\n\n if (min !== undefined) {\n return `faker.number.float({ min: ${min} })`\n }\n\n return 'faker.number.float()'\n },\n integer: (min?: number, max?: number) => {\n if (max !== undefined && min !== undefined) {\n return `faker.number.int({ min: ${min}, max: ${max} })`\n }\n\n if (max !== undefined) {\n return `faker.number.int({ max: ${max} })`\n }\n\n if (min !== undefined) {\n return `faker.number.int({ min: ${min} })`\n }\n\n return 'faker.number.int()'\n },\n string: (min?: number, max?: number) => {\n if (max !== undefined && min !== undefined) {\n return `faker.string.alpha({ length: { min: ${min}, max: ${max} } })`\n }\n\n if (max !== undefined) {\n return `faker.string.alpha({ length: ${max} })`\n }\n\n if (min !== undefined) {\n return `faker.string.alpha({ length: ${min} })`\n }\n\n return 'faker.string.alpha()'\n },\n boolean: () => 'faker.datatype.boolean()',\n undefined: () => 'undefined',\n null: () => 'null',\n array: (items: string[] = [], min?: number, max?: number) => {\n if (items.length > 1) {\n return `faker.helpers.arrayElements([${items.join(', ')}])`\n }\n const item = items.at(0)\n\n if (min !== undefined && max !== undefined) {\n return `faker.helpers.multiple(() => (${item}), { count: { min: ${min}, max: ${max} }})`\n }\n if (min !== undefined) {\n return `faker.helpers.multiple(() => (${item}), { count: ${min} })`\n }\n if (max !== undefined) {\n return `faker.helpers.multiple(() => (${item}), { count: { min: 0, max: ${max} }})`\n }\n\n return `faker.helpers.multiple(() => (${item}))`\n },\n tuple: (items: string[] = []) => `[${items.join(', ')}]`,\n enum: (items: Array<string | number | boolean | undefined> = [], type = 'any') => `faker.helpers.arrayElement<${type}>([${items.join(', ')}])`,\n union: (items: string[] = []) => `faker.helpers.arrayElement<any>([${items.join(', ')}])`,\n /**\n * ISO 8601\n */\n datetime: () => 'faker.date.anytime().toISOString()',\n /**\n * Type `'date'` Date\n * Type `'string'` ISO date format (YYYY-MM-DD)\n * @default ISO date format (YYYY-MM-DD)\n */\n date: (type: 'date' | 'string' = 'string', parser: Options['dateParser'] = 'faker') => {\n if (type === 'string') {\n if (parser !== 'faker') {\n return `${parser}(faker.date.anytime()).format(\"YYYY-MM-DD\")`\n }\n return 'faker.date.anytime().toISOString().substring(0, 10)'\n }\n\n if (parser !== 'faker') {\n throw new Error(`type '${type}' and parser '${parser}' can not work together`)\n }\n\n return 'faker.date.anytime()'\n },\n /**\n * Type `'date'` Date\n * Type `'string'` ISO time format (HH:mm:ss[.SSSSSS])\n * @default ISO time format (HH:mm:ss[.SSSSSS])\n */\n time: (type: 'date' | 'string' = 'string', parser: Options['dateParser'] = 'faker') => {\n if (type === 'string') {\n if (parser !== 'faker') {\n return `${parser}(faker.date.anytime()).format(\"HH:mm:ss\")`\n }\n return 'faker.date.anytime().toISOString().substring(11, 19)'\n }\n\n if (parser !== 'faker') {\n throw new Error(`type '${type}' and parser '${parser}' can not work together`)\n }\n\n return 'faker.date.anytime()'\n },\n uuid: () => 'faker.string.uuid()',\n url: () => 'faker.internet.url()',\n and: (items: string[] = []) => `Object.assign({}, ${items.join(', ')})`,\n object: () => 'object',\n ref: () => 'ref',\n matches: (value = '', regexGenerator: 'faker' | 'randexp' = 'faker') => {\n if (regexGenerator === 'randexp') {\n return `${transformers.toRegExpString(value, 'RandExp')}.gen()`\n }\n return `faker.helpers.fromRegExp(\"${value}\")`\n },\n email: () => 'faker.internet.email()',\n firstName: () => 'faker.person.firstName()',\n lastName: () => 'faker.person.lastName()',\n password: () => 'faker.internet.password()',\n phone: () => 'faker.phone.number()',\n blob: () => 'faker.image.url() as unknown as Blob',\n default: undefined,\n describe: undefined,\n const: (value?: string | number) => (value as string) ?? '',\n max: undefined,\n min: undefined,\n nullable: undefined,\n nullish: undefined,\n optional: undefined,\n readOnly: undefined,\n writeOnly: undefined,\n deprecated: undefined,\n example: undefined,\n schema: undefined,\n catchall: undefined,\n name: undefined,\n interface: undefined,\n exclusiveMaximum: undefined,\n exclusiveMinimum: undefined,\n} satisfies SchemaMapper<string | null | undefined>\n\n/**\n * @link based on https://github.com/cellular/oazapfts/blob/7ba226ebb15374e8483cc53e7532f1663179a22c/src/codegen/generate.ts#L398\n */\n\nfunction schemaKeywordSorter(_a: Schema, b: Schema) {\n if (b.keyword === 'null') {\n return -1\n }\n\n return 0\n}\n\nexport function joinItems(items: string[]): string {\n switch (items.length) {\n case 0:\n return 'undefined'\n case 1:\n return items[0]!\n default:\n return fakerKeywordMapper.union(items)\n }\n}\n\ntype ParserOptions = {\n typeName?: string\n regexGenerator?: 'faker' | 'randexp'\n canOverride?: boolean\n dateParser?: Options['dateParser']\n mapper?: Record<string, string>\n}\n\nexport function parse({ schema, current, parent, name, siblings }: SchemaTree, options: ParserOptions): string | null | undefined {\n const value = fakerKeywordMapper[current.keyword as keyof typeof fakerKeywordMapper]\n\n if (!value) {\n return undefined\n }\n\n if (isKeyword(current, schemaKeywords.union)) {\n if (Array.isArray(current.args) && !current.args.length) {\n return ''\n }\n\n return fakerKeywordMapper.union(\n current.args.map((it) => parse({ schema, parent: current, name, current: it, siblings }, { ...options, canOverride: false })).filter(Boolean),\n )\n }\n\n if (isKeyword(current, schemaKeywords.and)) {\n return fakerKeywordMapper.and(\n current.args.map((it) => parse({ schema, parent: current, current: it, siblings }, { ...options, canOverride: false })).filter(Boolean),\n )\n }\n\n if (isKeyword(current, schemaKeywords.array)) {\n return fakerKeywordMapper.array(\n current.args.items\n .map((it) =>\n parse(\n { schema, parent: current, current: it, siblings },\n {\n ...options,\n typeName: `NonNullable<${options.typeName}>[number]`,\n canOverride: false,\n },\n ),\n )\n .filter(Boolean),\n current.args.min,\n current.args.max,\n )\n }\n\n if (isKeyword(current, schemaKeywords.enum)) {\n const isParentTuple = parent ? isKeyword(parent, schemaKeywords.tuple) : false\n\n if (isParentTuple) {\n return fakerKeywordMapper.enum(\n current.args.items.map((schema) => {\n if (schema.format === 'number') {\n return schema.value\n }\n\n if (schema.format === 'boolean') {\n return schema.value\n }\n return transformers.stringify(schema.value)\n }),\n )\n }\n\n return fakerKeywordMapper.enum(\n current.args.items.map((schema) => {\n if (schema.format === 'number') {\n return schema.value\n }\n if (schema.format === 'boolean') {\n return schema.value\n }\n return transformers.stringify(schema.value)\n }),\n // TODO replace this with getEnumNameFromSchema\n name ? options.typeName : undefined,\n )\n }\n\n if (isKeyword(current, schemaKeywords.ref)) {\n if (!current.args?.name) {\n throw new Error(`Name not defined for keyword ${current.keyword}`)\n }\n\n if (options.canOverride) {\n return `${current.args.name}(data)`\n }\n\n return `${current.args.name}()`\n }\n\n if (isKeyword(current, schemaKeywords.object)) {\n const argsObject = Object.entries(current.args?.properties || {})\n .filter((item) => {\n const schema = item[1]\n return schema && typeof schema.map === 'function'\n })\n .map(([name, schemas]) => {\n const nameSchema = schemas.find((schema) => schema.keyword === schemaKeywords.name) as SchemaKeywordMapper['name']\n const mappedName = nameSchema?.args || name\n\n // custom mapper(pluginOptions)\n if (options.mapper?.[mappedName]) {\n return `\"${name}\": ${options.mapper?.[mappedName]}`\n }\n\n return `\"${name}\": ${joinItems(\n schemas\n .sort(schemaKeywordSorter)\n .map((it) =>\n parse(\n { schema, name, parent: current, current: it, siblings: schemas },\n {\n ...options,\n typeName: `NonNullable<${options.typeName}>[${JSON.stringify(name)}]`,\n canOverride: false,\n },\n ),\n )\n .filter(Boolean),\n )}`\n })\n .join(',')\n\n return `{${argsObject}}`\n }\n\n if (isKeyword(current, schemaKeywords.tuple)) {\n if (Array.isArray(current.args.items)) {\n return fakerKeywordMapper.tuple(\n current.args.items.map((it) => parse({ schema, parent: current, current: it, siblings }, { ...options, canOverride: false })).filter(Boolean),\n )\n }\n\n return parse({ schema, parent: current, current: current.args.items, siblings }, { ...options, canOverride: false })\n }\n\n if (isKeyword(current, schemaKeywords.const)) {\n if (current.args.format === 'number' && current.args.name !== undefined) {\n return fakerKeywordMapper.const(current.args.name?.toString())\n }\n return fakerKeywordMapper.const(transformers.stringify(current.args.value))\n }\n\n if (isKeyword(current, schemaKeywords.matches) && current.args) {\n return fakerKeywordMapper.matches(current.args, options.regexGenerator)\n }\n\n if (isKeyword(current, schemaKeywords.null) || isKeyword(current, schemaKeywords.undefined) || isKeyword(current, schemaKeywords.any)) {\n return value() || ''\n }\n\n if (isKeyword(current, schemaKeywords.string)) {\n if (siblings) {\n const minSchema = SchemaGenerator.find(siblings, schemaKeywords.min)\n const maxSchema = SchemaGenerator.find(siblings, schemaKeywords.max)\n\n return fakerKeywordMapper.string(minSchema?.args, maxSchema?.args)\n }\n\n return fakerKeywordMapper.string()\n }\n\n if (isKeyword(current, schemaKeywords.number)) {\n if (siblings) {\n const minSchema = SchemaGenerator.find(siblings, schemaKeywords.min)\n const maxSchema = SchemaGenerator.find(siblings, schemaKeywords.max)\n\n return fakerKeywordMapper.number(minSchema?.args, maxSchema?.args)\n }\n\n return fakerKeywordMapper.number()\n }\n\n if (isKeyword(current, schemaKeywords.integer)) {\n if (siblings) {\n const minSchema = SchemaGenerator.find(siblings, schemaKeywords.min)\n const maxSchema = SchemaGenerator.find(siblings, schemaKeywords.max)\n\n return fakerKeywordMapper.integer(minSchema?.args, maxSchema?.args)\n }\n\n return fakerKeywordMapper.integer()\n }\n\n if (isKeyword(current, schemaKeywords.datetime)) {\n return fakerKeywordMapper.datetime()\n }\n\n if (isKeyword(current, schemaKeywords.date)) {\n return fakerKeywordMapper.date(current.args.type, options.dateParser)\n }\n\n if (isKeyword(current, schemaKeywords.time)) {\n return fakerKeywordMapper.time(current.args.type, options.dateParser)\n }\n\n if (current.keyword in fakerKeywordMapper && 'args' in current) {\n const value = fakerKeywordMapper[current.keyword as keyof typeof fakerKeywordMapper] as (typeof fakerKeywordMapper)['const']\n\n const options = JSON.stringify((current as SchemaKeywordBase<unknown>).args)\n\n return value(options)\n }\n\n if (current.keyword in fakerKeywordMapper) {\n return value()\n }\n\n return undefined\n}\n","import transformers from '@kubb/core/transformers'\nimport type { Schema } from '@kubb/plugin-oas'\nimport { File, Function, FunctionParams } from '@kubb/react-fabric'\nimport type { KubbNode } from '@kubb/react-fabric/types'\nimport * as parserFaker from '../parser.ts'\nimport type { PluginFaker } from '../types.ts'\n\ntype Props = {\n name: string\n typeName: string\n tree: Array<Schema>\n seed?: PluginFaker['options']['seed']\n description?: string\n regexGenerator?: PluginFaker['options']['regexGenerator']\n mapper?: PluginFaker['options']['mapper']\n dateParser?: PluginFaker['options']['dateParser']\n canOverride: boolean\n}\n\nexport function Faker({ tree, description, name, typeName, seed, regexGenerator, canOverride, mapper, dateParser }: Props): KubbNode {\n const fakerText = parserFaker.joinItems(\n tree\n .map((schema, _index, siblings) =>\n parserFaker.parse(\n { name, schema, parent: undefined, current: schema, siblings },\n {\n typeName,\n regexGenerator,\n mapper,\n canOverride,\n dateParser,\n },\n ),\n )\n .filter(Boolean),\n )\n\n const isArray = fakerText.startsWith('faker.helpers.arrayElements') || fakerText.startsWith('faker.helpers.multiple')\n const isObject = fakerText.startsWith('{')\n const isTuple = fakerText.startsWith('faker.helpers.arrayElement')\n\n const isSimpleString = name === 'string'\n const isSimpleInt = name === 'integer'\n const isSimpleFloat = name === 'float'\n\n let fakerTextWithOverride = fakerText\n\n if (canOverride && isObject) {\n fakerTextWithOverride = `{\n ...${fakerText},\n ...data || {}\n}`\n }\n\n if (canOverride && isTuple) {\n fakerTextWithOverride = `data || ${fakerText}`\n }\n\n if (canOverride && isArray) {\n fakerTextWithOverride = `[\n ...${fakerText},\n ...data || []\n ]`\n }\n\n if (canOverride && isSimpleString) {\n fakerTextWithOverride = 'data ?? faker.string.alpha()'\n }\n\n if (canOverride && isSimpleInt) {\n fakerTextWithOverride = 'data ?? faker.number.int()'\n }\n\n if (canOverride && isSimpleFloat) {\n fakerTextWithOverride = 'data ?? faker.number.float()'\n }\n\n let type = `Partial<${typeName}>`\n\n if (isArray) type = typeName\n else if (isSimpleString) type = name\n else if (isSimpleInt || isSimpleFloat) type = 'number'\n\n const params = FunctionParams.factory({\n data: {\n // making a partial out of an array does not make sense\n type,\n optional: true,\n },\n })\n\n let returnType = canOverride ? typeName : undefined\n\n if (isSimpleString || isSimpleInt || isSimpleFloat) returnType = type\n\n return (\n <File.Source name={name} isExportable isIndexable>\n <Function\n export\n name={name}\n JSDoc={{ comments: [description ? `@description ${transformers.jsStringEscape(description)}` : undefined].filter(Boolean) }}\n params={canOverride ? params.toConstructor() : undefined}\n returnType={returnType}\n >\n {seed ? `faker.seed(${JSON.stringify(seed)})` : undefined}\n <br />\n {`return ${fakerTextWithOverride}`}\n </Function>\n </File.Source>\n )\n}\n"],"mappings":";;;;;;AAKA,MAAM,qBAAqB;CACzB,WAAW;CACX,eAAe;CACf,YAAY;CACZ,SAAS,KAAc,QAAiB;AACtC,MAAI,QAAQ,UAAa,QAAQ,OAC/B,QAAO,6BAA6B,IAAI,SAAS,IAAI;AAGvD,MAAI,QAAQ,OACV,QAAO,6BAA6B,IAAI;AAG1C,MAAI,QAAQ,OACV,QAAO,6BAA6B,IAAI;AAG1C,SAAO;;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,QAAS,QAAO;UACX,eAAgB,QAAO;UACvB,eAAe,cAAe,QAAO;CAE9C,MAAM,SAAS,eAAe,QAAQ,EACpC,MAAM;EAEJ;EACA,UAAU;EACX,EACF,CAAC;CAEF,IAAI,aAAa,cAAc,WAAW;AAE1C,KAAI,kBAAkB,eAAe,cAAe,cAAa;AAEjE,QACE,oBAAC,KAAK;EAAa;EAAM;EAAa;YACpC,qBAAC;GACC;GACM;GACN,OAAO,EAAE,UAAU,CAAC,cAAc,gBAAgB,aAAa,eAAe,YAAY,KAAK,OAAU,CAAC,OAAO,QAAQ,EAAE;GAC3H,QAAQ,cAAc,OAAO,eAAe,GAAG;GACnC;;IAEX,OAAO,cAAc,KAAK,UAAU,KAAK,CAAC,KAAK;IAChD,oBAAC,SAAK;IACL,UAAU;;IACF;GACC"}
|
|
@@ -132,31 +132,35 @@ function joinItems(items) {
|
|
|
132
132
|
default: return fakerKeywordMapper.union(items);
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
|
-
function parse({ current, parent, name, siblings }, options) {
|
|
135
|
+
function parse({ schema, current, parent, name, siblings }, options) {
|
|
136
136
|
const value = fakerKeywordMapper[current.keyword];
|
|
137
137
|
if (!value) return;
|
|
138
138
|
if ((0, __kubb_plugin_oas.isKeyword)(current, __kubb_plugin_oas.schemaKeywords.union)) {
|
|
139
139
|
if (Array.isArray(current.args) && !current.args.length) return "";
|
|
140
|
-
return fakerKeywordMapper.union(current.args.map((
|
|
140
|
+
return fakerKeywordMapper.union(current.args.map((it) => parse({
|
|
141
|
+
schema,
|
|
141
142
|
parent: current,
|
|
142
|
-
|
|
143
|
+
name,
|
|
144
|
+
current: it,
|
|
143
145
|
siblings
|
|
144
146
|
}, {
|
|
145
147
|
...options,
|
|
146
148
|
canOverride: false
|
|
147
149
|
})).filter(Boolean));
|
|
148
150
|
}
|
|
149
|
-
if ((0, __kubb_plugin_oas.isKeyword)(current, __kubb_plugin_oas.schemaKeywords.and)) return fakerKeywordMapper.and(current.args.map((
|
|
151
|
+
if ((0, __kubb_plugin_oas.isKeyword)(current, __kubb_plugin_oas.schemaKeywords.and)) return fakerKeywordMapper.and(current.args.map((it) => parse({
|
|
152
|
+
schema,
|
|
150
153
|
parent: current,
|
|
151
|
-
current:
|
|
154
|
+
current: it,
|
|
152
155
|
siblings
|
|
153
156
|
}, {
|
|
154
157
|
...options,
|
|
155
158
|
canOverride: false
|
|
156
159
|
})).filter(Boolean));
|
|
157
|
-
if ((0, __kubb_plugin_oas.isKeyword)(current, __kubb_plugin_oas.schemaKeywords.array)) return fakerKeywordMapper.array(current.args.items.map((
|
|
160
|
+
if ((0, __kubb_plugin_oas.isKeyword)(current, __kubb_plugin_oas.schemaKeywords.array)) return fakerKeywordMapper.array(current.args.items.map((it) => parse({
|
|
161
|
+
schema,
|
|
158
162
|
parent: current,
|
|
159
|
-
current:
|
|
163
|
+
current: it,
|
|
160
164
|
siblings
|
|
161
165
|
}, {
|
|
162
166
|
...options,
|
|
@@ -164,15 +168,15 @@ function parse({ current, parent, name, siblings }, options) {
|
|
|
164
168
|
canOverride: false
|
|
165
169
|
})).filter(Boolean), current.args.min, current.args.max);
|
|
166
170
|
if ((0, __kubb_plugin_oas.isKeyword)(current, __kubb_plugin_oas.schemaKeywords.enum)) {
|
|
167
|
-
if (parent ? (0, __kubb_plugin_oas.isKeyword)(parent, __kubb_plugin_oas.schemaKeywords.tuple) : false) return fakerKeywordMapper.enum(current.args.items.map((schema) => {
|
|
168
|
-
if (schema.format === "number") return schema.value;
|
|
169
|
-
if (schema.format === "boolean") return schema.value;
|
|
170
|
-
return __kubb_core_transformers.default.stringify(schema.value);
|
|
171
|
+
if (parent ? (0, __kubb_plugin_oas.isKeyword)(parent, __kubb_plugin_oas.schemaKeywords.tuple) : false) return fakerKeywordMapper.enum(current.args.items.map((schema$1) => {
|
|
172
|
+
if (schema$1.format === "number") return schema$1.value;
|
|
173
|
+
if (schema$1.format === "boolean") return schema$1.value;
|
|
174
|
+
return __kubb_core_transformers.default.stringify(schema$1.value);
|
|
171
175
|
}));
|
|
172
|
-
return fakerKeywordMapper.enum(current.args.items.map((schema) => {
|
|
173
|
-
if (schema.format === "number") return schema.value;
|
|
174
|
-
if (schema.format === "boolean") return schema.value;
|
|
175
|
-
return __kubb_core_transformers.default.stringify(schema.value);
|
|
176
|
+
return fakerKeywordMapper.enum(current.args.items.map((schema$1) => {
|
|
177
|
+
if (schema$1.format === "number") return schema$1.value;
|
|
178
|
+
if (schema$1.format === "boolean") return schema$1.value;
|
|
179
|
+
return __kubb_core_transformers.default.stringify(schema$1.value);
|
|
176
180
|
}), name ? options.typeName : void 0);
|
|
177
181
|
}
|
|
178
182
|
if ((0, __kubb_plugin_oas.isKeyword)(current, __kubb_plugin_oas.schemaKeywords.ref)) {
|
|
@@ -181,15 +185,16 @@ function parse({ current, parent, name, siblings }, options) {
|
|
|
181
185
|
return `${current.args.name}()`;
|
|
182
186
|
}
|
|
183
187
|
if ((0, __kubb_plugin_oas.isKeyword)(current, __kubb_plugin_oas.schemaKeywords.object)) return `{${Object.entries(current.args?.properties || {}).filter((item) => {
|
|
184
|
-
const schema = item[1];
|
|
185
|
-
return schema && typeof schema.map === "function";
|
|
188
|
+
const schema$1 = item[1];
|
|
189
|
+
return schema$1 && typeof schema$1.map === "function";
|
|
186
190
|
}).map(([name$1, schemas]) => {
|
|
187
|
-
const mappedName = schemas.find((schema) => schema.keyword === __kubb_plugin_oas.schemaKeywords.name)?.args || name$1;
|
|
191
|
+
const mappedName = schemas.find((schema$1) => schema$1.keyword === __kubb_plugin_oas.schemaKeywords.name)?.args || name$1;
|
|
188
192
|
if (options.mapper?.[mappedName]) return `"${name$1}": ${options.mapper?.[mappedName]}`;
|
|
189
|
-
return `"${name$1}": ${joinItems(schemas.sort(schemaKeywordSorter).map((
|
|
193
|
+
return `"${name$1}": ${joinItems(schemas.sort(schemaKeywordSorter).map((it) => parse({
|
|
194
|
+
schema,
|
|
190
195
|
name: name$1,
|
|
191
196
|
parent: current,
|
|
192
|
-
current:
|
|
197
|
+
current: it,
|
|
193
198
|
siblings: schemas
|
|
194
199
|
}, {
|
|
195
200
|
...options,
|
|
@@ -198,15 +203,17 @@ function parse({ current, parent, name, siblings }, options) {
|
|
|
198
203
|
})).filter(Boolean))}`;
|
|
199
204
|
}).join(",")}}`;
|
|
200
205
|
if ((0, __kubb_plugin_oas.isKeyword)(current, __kubb_plugin_oas.schemaKeywords.tuple)) {
|
|
201
|
-
if (Array.isArray(current.args.items)) return fakerKeywordMapper.tuple(current.args.items.map((
|
|
206
|
+
if (Array.isArray(current.args.items)) return fakerKeywordMapper.tuple(current.args.items.map((it) => parse({
|
|
207
|
+
schema,
|
|
202
208
|
parent: current,
|
|
203
|
-
current:
|
|
209
|
+
current: it,
|
|
204
210
|
siblings
|
|
205
211
|
}, {
|
|
206
212
|
...options,
|
|
207
213
|
canOverride: false
|
|
208
214
|
})).filter(Boolean));
|
|
209
215
|
return parse({
|
|
216
|
+
schema,
|
|
210
217
|
parent: current,
|
|
211
218
|
current: current.args.items,
|
|
212
219
|
siblings
|
|
@@ -259,13 +266,13 @@ function parse({ current, parent, name, siblings }, options) {
|
|
|
259
266
|
//#region src/components/Faker.tsx
|
|
260
267
|
function Faker({ tree, description, name, typeName, seed, regexGenerator, canOverride, mapper, dateParser }) {
|
|
261
268
|
const fakerText = joinItems(tree.map((schema, _index, siblings) => parse({
|
|
269
|
+
name,
|
|
270
|
+
schema,
|
|
262
271
|
parent: void 0,
|
|
263
272
|
current: schema,
|
|
264
273
|
siblings
|
|
265
274
|
}, {
|
|
266
|
-
name,
|
|
267
275
|
typeName,
|
|
268
|
-
seed,
|
|
269
276
|
regexGenerator,
|
|
270
277
|
mapper,
|
|
271
278
|
canOverride,
|
|
@@ -332,4 +339,4 @@ Object.defineProperty(exports, '__toESM', {
|
|
|
332
339
|
return __toESM;
|
|
333
340
|
}
|
|
334
341
|
});
|
|
335
|
-
//# sourceMappingURL=components-
|
|
342
|
+
//# sourceMappingURL=components-Dq57kUQf.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"components-Dq57kUQf.cjs","names":["transformers","schemaKeywords","schema","name","SchemaGenerator","value","parserFaker.joinItems","parserFaker.parse","FunctionParams","File","Function","transformers"],"sources":["../src/parser.ts","../src/components/Faker.tsx"],"sourcesContent":["import transformers from '@kubb/core/transformers'\nimport type { Schema, SchemaKeywordBase, SchemaKeywordMapper, SchemaMapper } from '@kubb/plugin-oas'\nimport { isKeyword, SchemaGenerator, type SchemaTree, schemaKeywords } from '@kubb/plugin-oas'\nimport type { Options } from './types.ts'\n\nconst fakerKeywordMapper = {\n any: () => 'undefined',\n unknown: () => 'undefined',\n void: () => 'undefined',\n number: (min?: number, max?: number) => {\n if (max !== undefined && min !== undefined) {\n return `faker.number.float({ min: ${min}, max: ${max} })`\n }\n\n if (max !== undefined) {\n return `faker.number.float({ max: ${max} })`\n }\n\n if (min !== undefined) {\n return `faker.number.float({ min: ${min} })`\n }\n\n return 'faker.number.float()'\n },\n integer: (min?: number, max?: number) => {\n if (max !== undefined && min !== undefined) {\n return `faker.number.int({ min: ${min}, max: ${max} })`\n }\n\n if (max !== undefined) {\n return `faker.number.int({ max: ${max} })`\n }\n\n if (min !== undefined) {\n return `faker.number.int({ min: ${min} })`\n }\n\n return 'faker.number.int()'\n },\n string: (min?: number, max?: number) => {\n if (max !== undefined && min !== undefined) {\n return `faker.string.alpha({ length: { min: ${min}, max: ${max} } })`\n }\n\n if (max !== undefined) {\n return `faker.string.alpha({ length: ${max} })`\n }\n\n if (min !== undefined) {\n return `faker.string.alpha({ length: ${min} })`\n }\n\n return 'faker.string.alpha()'\n },\n boolean: () => 'faker.datatype.boolean()',\n undefined: () => 'undefined',\n null: () => 'null',\n array: (items: string[] = [], min?: number, max?: number) => {\n if (items.length > 1) {\n return `faker.helpers.arrayElements([${items.join(', ')}])`\n }\n const item = items.at(0)\n\n if (min !== undefined && max !== undefined) {\n return `faker.helpers.multiple(() => (${item}), { count: { min: ${min}, max: ${max} }})`\n }\n if (min !== undefined) {\n return `faker.helpers.multiple(() => (${item}), { count: ${min} })`\n }\n if (max !== undefined) {\n return `faker.helpers.multiple(() => (${item}), { count: { min: 0, max: ${max} }})`\n }\n\n return `faker.helpers.multiple(() => (${item}))`\n },\n tuple: (items: string[] = []) => `[${items.join(', ')}]`,\n enum: (items: Array<string | number | boolean | undefined> = [], type = 'any') => `faker.helpers.arrayElement<${type}>([${items.join(', ')}])`,\n union: (items: string[] = []) => `faker.helpers.arrayElement<any>([${items.join(', ')}])`,\n /**\n * ISO 8601\n */\n datetime: () => 'faker.date.anytime().toISOString()',\n /**\n * Type `'date'` Date\n * Type `'string'` ISO date format (YYYY-MM-DD)\n * @default ISO date format (YYYY-MM-DD)\n */\n date: (type: 'date' | 'string' = 'string', parser: Options['dateParser'] = 'faker') => {\n if (type === 'string') {\n if (parser !== 'faker') {\n return `${parser}(faker.date.anytime()).format(\"YYYY-MM-DD\")`\n }\n return 'faker.date.anytime().toISOString().substring(0, 10)'\n }\n\n if (parser !== 'faker') {\n throw new Error(`type '${type}' and parser '${parser}' can not work together`)\n }\n\n return 'faker.date.anytime()'\n },\n /**\n * Type `'date'` Date\n * Type `'string'` ISO time format (HH:mm:ss[.SSSSSS])\n * @default ISO time format (HH:mm:ss[.SSSSSS])\n */\n time: (type: 'date' | 'string' = 'string', parser: Options['dateParser'] = 'faker') => {\n if (type === 'string') {\n if (parser !== 'faker') {\n return `${parser}(faker.date.anytime()).format(\"HH:mm:ss\")`\n }\n return 'faker.date.anytime().toISOString().substring(11, 19)'\n }\n\n if (parser !== 'faker') {\n throw new Error(`type '${type}' and parser '${parser}' can not work together`)\n }\n\n return 'faker.date.anytime()'\n },\n uuid: () => 'faker.string.uuid()',\n url: () => 'faker.internet.url()',\n and: (items: string[] = []) => `Object.assign({}, ${items.join(', ')})`,\n object: () => 'object',\n ref: () => 'ref',\n matches: (value = '', regexGenerator: 'faker' | 'randexp' = 'faker') => {\n if (regexGenerator === 'randexp') {\n return `${transformers.toRegExpString(value, 'RandExp')}.gen()`\n }\n return `faker.helpers.fromRegExp(\"${value}\")`\n },\n email: () => 'faker.internet.email()',\n firstName: () => 'faker.person.firstName()',\n lastName: () => 'faker.person.lastName()',\n password: () => 'faker.internet.password()',\n phone: () => 'faker.phone.number()',\n blob: () => 'faker.image.url() as unknown as Blob',\n default: undefined,\n describe: undefined,\n const: (value?: string | number) => (value as string) ?? '',\n max: undefined,\n min: undefined,\n nullable: undefined,\n nullish: undefined,\n optional: undefined,\n readOnly: undefined,\n writeOnly: undefined,\n deprecated: undefined,\n example: undefined,\n schema: undefined,\n catchall: undefined,\n name: undefined,\n interface: undefined,\n exclusiveMaximum: undefined,\n exclusiveMinimum: undefined,\n} satisfies SchemaMapper<string | null | undefined>\n\n/**\n * @link based on https://github.com/cellular/oazapfts/blob/7ba226ebb15374e8483cc53e7532f1663179a22c/src/codegen/generate.ts#L398\n */\n\nfunction schemaKeywordSorter(_a: Schema, b: Schema) {\n if (b.keyword === 'null') {\n return -1\n }\n\n return 0\n}\n\nexport function joinItems(items: string[]): string {\n switch (items.length) {\n case 0:\n return 'undefined'\n case 1:\n return items[0]!\n default:\n return fakerKeywordMapper.union(items)\n }\n}\n\ntype ParserOptions = {\n typeName?: string\n regexGenerator?: 'faker' | 'randexp'\n canOverride?: boolean\n dateParser?: Options['dateParser']\n mapper?: Record<string, string>\n}\n\nexport function parse({ schema, current, parent, name, siblings }: SchemaTree, options: ParserOptions): string | null | undefined {\n const value = fakerKeywordMapper[current.keyword as keyof typeof fakerKeywordMapper]\n\n if (!value) {\n return undefined\n }\n\n if (isKeyword(current, schemaKeywords.union)) {\n if (Array.isArray(current.args) && !current.args.length) {\n return ''\n }\n\n return fakerKeywordMapper.union(\n current.args.map((it) => parse({ schema, parent: current, name, current: it, siblings }, { ...options, canOverride: false })).filter(Boolean),\n )\n }\n\n if (isKeyword(current, schemaKeywords.and)) {\n return fakerKeywordMapper.and(\n current.args.map((it) => parse({ schema, parent: current, current: it, siblings }, { ...options, canOverride: false })).filter(Boolean),\n )\n }\n\n if (isKeyword(current, schemaKeywords.array)) {\n return fakerKeywordMapper.array(\n current.args.items\n .map((it) =>\n parse(\n { schema, parent: current, current: it, siblings },\n {\n ...options,\n typeName: `NonNullable<${options.typeName}>[number]`,\n canOverride: false,\n },\n ),\n )\n .filter(Boolean),\n current.args.min,\n current.args.max,\n )\n }\n\n if (isKeyword(current, schemaKeywords.enum)) {\n const isParentTuple = parent ? isKeyword(parent, schemaKeywords.tuple) : false\n\n if (isParentTuple) {\n return fakerKeywordMapper.enum(\n current.args.items.map((schema) => {\n if (schema.format === 'number') {\n return schema.value\n }\n\n if (schema.format === 'boolean') {\n return schema.value\n }\n return transformers.stringify(schema.value)\n }),\n )\n }\n\n return fakerKeywordMapper.enum(\n current.args.items.map((schema) => {\n if (schema.format === 'number') {\n return schema.value\n }\n if (schema.format === 'boolean') {\n return schema.value\n }\n return transformers.stringify(schema.value)\n }),\n // TODO replace this with getEnumNameFromSchema\n name ? options.typeName : undefined,\n )\n }\n\n if (isKeyword(current, schemaKeywords.ref)) {\n if (!current.args?.name) {\n throw new Error(`Name not defined for keyword ${current.keyword}`)\n }\n\n if (options.canOverride) {\n return `${current.args.name}(data)`\n }\n\n return `${current.args.name}()`\n }\n\n if (isKeyword(current, schemaKeywords.object)) {\n const argsObject = Object.entries(current.args?.properties || {})\n .filter((item) => {\n const schema = item[1]\n return schema && typeof schema.map === 'function'\n })\n .map(([name, schemas]) => {\n const nameSchema = schemas.find((schema) => schema.keyword === schemaKeywords.name) as SchemaKeywordMapper['name']\n const mappedName = nameSchema?.args || name\n\n // custom mapper(pluginOptions)\n if (options.mapper?.[mappedName]) {\n return `\"${name}\": ${options.mapper?.[mappedName]}`\n }\n\n return `\"${name}\": ${joinItems(\n schemas\n .sort(schemaKeywordSorter)\n .map((it) =>\n parse(\n { schema, name, parent: current, current: it, siblings: schemas },\n {\n ...options,\n typeName: `NonNullable<${options.typeName}>[${JSON.stringify(name)}]`,\n canOverride: false,\n },\n ),\n )\n .filter(Boolean),\n )}`\n })\n .join(',')\n\n return `{${argsObject}}`\n }\n\n if (isKeyword(current, schemaKeywords.tuple)) {\n if (Array.isArray(current.args.items)) {\n return fakerKeywordMapper.tuple(\n current.args.items.map((it) => parse({ schema, parent: current, current: it, siblings }, { ...options, canOverride: false })).filter(Boolean),\n )\n }\n\n return parse({ schema, parent: current, current: current.args.items, siblings }, { ...options, canOverride: false })\n }\n\n if (isKeyword(current, schemaKeywords.const)) {\n if (current.args.format === 'number' && current.args.name !== undefined) {\n return fakerKeywordMapper.const(current.args.name?.toString())\n }\n return fakerKeywordMapper.const(transformers.stringify(current.args.value))\n }\n\n if (isKeyword(current, schemaKeywords.matches) && current.args) {\n return fakerKeywordMapper.matches(current.args, options.regexGenerator)\n }\n\n if (isKeyword(current, schemaKeywords.null) || isKeyword(current, schemaKeywords.undefined) || isKeyword(current, schemaKeywords.any)) {\n return value() || ''\n }\n\n if (isKeyword(current, schemaKeywords.string)) {\n if (siblings) {\n const minSchema = SchemaGenerator.find(siblings, schemaKeywords.min)\n const maxSchema = SchemaGenerator.find(siblings, schemaKeywords.max)\n\n return fakerKeywordMapper.string(minSchema?.args, maxSchema?.args)\n }\n\n return fakerKeywordMapper.string()\n }\n\n if (isKeyword(current, schemaKeywords.number)) {\n if (siblings) {\n const minSchema = SchemaGenerator.find(siblings, schemaKeywords.min)\n const maxSchema = SchemaGenerator.find(siblings, schemaKeywords.max)\n\n return fakerKeywordMapper.number(minSchema?.args, maxSchema?.args)\n }\n\n return fakerKeywordMapper.number()\n }\n\n if (isKeyword(current, schemaKeywords.integer)) {\n if (siblings) {\n const minSchema = SchemaGenerator.find(siblings, schemaKeywords.min)\n const maxSchema = SchemaGenerator.find(siblings, schemaKeywords.max)\n\n return fakerKeywordMapper.integer(minSchema?.args, maxSchema?.args)\n }\n\n return fakerKeywordMapper.integer()\n }\n\n if (isKeyword(current, schemaKeywords.datetime)) {\n return fakerKeywordMapper.datetime()\n }\n\n if (isKeyword(current, schemaKeywords.date)) {\n return fakerKeywordMapper.date(current.args.type, options.dateParser)\n }\n\n if (isKeyword(current, schemaKeywords.time)) {\n return fakerKeywordMapper.time(current.args.type, options.dateParser)\n }\n\n if (current.keyword in fakerKeywordMapper && 'args' in current) {\n const value = fakerKeywordMapper[current.keyword as keyof typeof fakerKeywordMapper] as (typeof fakerKeywordMapper)['const']\n\n const options = JSON.stringify((current as SchemaKeywordBase<unknown>).args)\n\n return value(options)\n }\n\n if (current.keyword in fakerKeywordMapper) {\n return value()\n }\n\n return undefined\n}\n","import transformers from '@kubb/core/transformers'\nimport type { Schema } from '@kubb/plugin-oas'\nimport { File, Function, FunctionParams } from '@kubb/react-fabric'\nimport type { KubbNode } from '@kubb/react-fabric/types'\nimport * as parserFaker from '../parser.ts'\nimport type { PluginFaker } from '../types.ts'\n\ntype Props = {\n name: string\n typeName: string\n tree: Array<Schema>\n seed?: PluginFaker['options']['seed']\n description?: string\n regexGenerator?: PluginFaker['options']['regexGenerator']\n mapper?: PluginFaker['options']['mapper']\n dateParser?: PluginFaker['options']['dateParser']\n canOverride: boolean\n}\n\nexport function Faker({ tree, description, name, typeName, seed, regexGenerator, canOverride, mapper, dateParser }: Props): KubbNode {\n const fakerText = parserFaker.joinItems(\n tree\n .map((schema, _index, siblings) =>\n parserFaker.parse(\n { name, schema, parent: undefined, current: schema, siblings },\n {\n typeName,\n regexGenerator,\n mapper,\n canOverride,\n dateParser,\n },\n ),\n )\n .filter(Boolean),\n )\n\n const isArray = fakerText.startsWith('faker.helpers.arrayElements') || fakerText.startsWith('faker.helpers.multiple')\n const isObject = fakerText.startsWith('{')\n const isTuple = fakerText.startsWith('faker.helpers.arrayElement')\n\n const isSimpleString = name === 'string'\n const isSimpleInt = name === 'integer'\n const isSimpleFloat = name === 'float'\n\n let fakerTextWithOverride = fakerText\n\n if (canOverride && isObject) {\n fakerTextWithOverride = `{\n ...${fakerText},\n ...data || {}\n}`\n }\n\n if (canOverride && isTuple) {\n fakerTextWithOverride = `data || ${fakerText}`\n }\n\n if (canOverride && isArray) {\n fakerTextWithOverride = `[\n ...${fakerText},\n ...data || []\n ]`\n }\n\n if (canOverride && isSimpleString) {\n fakerTextWithOverride = 'data ?? faker.string.alpha()'\n }\n\n if (canOverride && isSimpleInt) {\n fakerTextWithOverride = 'data ?? faker.number.int()'\n }\n\n if (canOverride && isSimpleFloat) {\n fakerTextWithOverride = 'data ?? faker.number.float()'\n }\n\n let type = `Partial<${typeName}>`\n\n if (isArray) type = typeName\n else if (isSimpleString) type = name\n else if (isSimpleInt || isSimpleFloat) type = 'number'\n\n const params = FunctionParams.factory({\n data: {\n // making a partial out of an array does not make sense\n type,\n optional: true,\n },\n })\n\n let returnType = canOverride ? typeName : undefined\n\n if (isSimpleString || isSimpleInt || isSimpleFloat) returnType = type\n\n return (\n <File.Source name={name} isExportable isIndexable>\n <Function\n export\n name={name}\n JSDoc={{ comments: [description ? `@description ${transformers.jsStringEscape(description)}` : undefined].filter(Boolean) }}\n params={canOverride ? params.toConstructor() : undefined}\n returnType={returnType}\n >\n {seed ? `faker.seed(${JSON.stringify(seed)})` : undefined}\n <br />\n {`return ${fakerTextWithOverride}`}\n </Function>\n </File.Source>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,MAAM,qBAAqB;CACzB,WAAW;CACX,eAAe;CACf,YAAY;CACZ,SAAS,KAAc,QAAiB;AACtC,MAAI,QAAQ,UAAa,QAAQ,OAC/B,QAAO,6BAA6B,IAAI,SAAS,IAAI;AAGvD,MAAI,QAAQ,OACV,QAAO,6BAA6B,IAAI;AAG1C,MAAI,QAAQ,OACV,QAAO,6BAA6B,IAAI;AAG1C,SAAO;;CAET,UAAU,KAAc,QAAiB;AACvC,MAAI,QAAQ,UAAa,QAAQ,OAC/B,QAAO,2BAA2B,IAAI,SAAS,IAAI;AAGrD,MAAI,QAAQ,OACV,QAAO,2BAA2B,IAAI;AAGxC,MAA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eAAe,cAAe,cAAa;AAEjE,QACE,yDAACC,yBAAK;EAAa;EAAM;EAAa;YACpC,0DAACC;GACC;GACM;GACN,OAAO,EAAE,UAAU,CAAC,cAAc,gBAAgBC,iCAAa,eAAe,YAAY,KAAK,OAAU,CAAC,OAAO,QAAQ,EAAE;GAC3H,QAAQ,cAAc,OAAO,eAAe,GAAG;GACnC;;IAEX,OAAO,cAAc,KAAK,UAAU,KAAK,CAAC,KAAK;IAChD,yDAAC,SAAK;IACL,UAAU;;IACF;GACC"}
|
package/dist/components.cjs
CHANGED
package/dist/components.d.cts
CHANGED
package/dist/components.d.ts
CHANGED
package/dist/components.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
const require_components = require('./components-
|
|
1
|
+
const require_components = require('./components-Dq57kUQf.cjs');
|
|
2
2
|
let __kubb_plugin_oas = require("@kubb/plugin-oas");
|
|
3
3
|
__kubb_plugin_oas = require_components.__toESM(__kubb_plugin_oas);
|
|
4
4
|
let __kubb_plugin_ts = require("@kubb/plugin-ts");
|
|
5
5
|
__kubb_plugin_ts = require_components.__toESM(__kubb_plugin_ts);
|
|
6
6
|
let __kubb_core_hooks = require("@kubb/core/hooks");
|
|
7
7
|
__kubb_core_hooks = require_components.__toESM(__kubb_core_hooks);
|
|
8
|
-
let
|
|
9
|
-
|
|
8
|
+
let __kubb_plugin_oas_generators = require("@kubb/plugin-oas/generators");
|
|
9
|
+
__kubb_plugin_oas_generators = require_components.__toESM(__kubb_plugin_oas_generators);
|
|
10
10
|
let __kubb_plugin_oas_hooks = require("@kubb/plugin-oas/hooks");
|
|
11
11
|
__kubb_plugin_oas_hooks = require_components.__toESM(__kubb_plugin_oas_hooks);
|
|
12
12
|
let __kubb_plugin_oas_utils = require("@kubb/plugin-oas/utils");
|
|
@@ -17,20 +17,19 @@ let __kubb_react_fabric_jsx_runtime = require("@kubb/react-fabric/jsx-runtime");
|
|
|
17
17
|
__kubb_react_fabric_jsx_runtime = require_components.__toESM(__kubb_react_fabric_jsx_runtime);
|
|
18
18
|
|
|
19
19
|
//#region src/generators/fakerGenerator.tsx
|
|
20
|
-
const fakerGenerator = (0,
|
|
20
|
+
const fakerGenerator = (0, __kubb_plugin_oas_generators.createReactGenerator)({
|
|
21
21
|
name: "faker",
|
|
22
|
-
Operation({ operation,
|
|
23
|
-
const { dateParser, regexGenerator, seed, mapper } =
|
|
24
|
-
const plugin = (0, __kubb_core_hooks.usePlugin)();
|
|
22
|
+
Operation({ operation, generator, plugin }) {
|
|
23
|
+
const { options, options: { dateParser, regexGenerator, seed, mapper } } = plugin;
|
|
25
24
|
const mode = (0, __kubb_core_hooks.useMode)();
|
|
26
25
|
const pluginManager = (0, __kubb_core_hooks.usePluginManager)();
|
|
27
26
|
const oas = (0, __kubb_plugin_oas_hooks.useOas)();
|
|
28
|
-
const { getSchemas, getFile, getGroup } = (0, __kubb_plugin_oas_hooks.useOperationManager)();
|
|
27
|
+
const { getSchemas, getFile, getGroup } = (0, __kubb_plugin_oas_hooks.useOperationManager)(generator);
|
|
29
28
|
const schemaManager = (0, __kubb_plugin_oas_hooks.useSchemaManager)();
|
|
30
29
|
const file = getFile(operation);
|
|
31
30
|
const schemas = getSchemas(operation);
|
|
32
31
|
const schemaGenerator = new __kubb_plugin_oas.SchemaGenerator(options, {
|
|
33
|
-
fabric:
|
|
32
|
+
fabric: generator.context.fabric,
|
|
34
33
|
oas,
|
|
35
34
|
plugin,
|
|
36
35
|
pluginManager,
|
|
@@ -45,7 +44,7 @@ const fakerGenerator = (0, __kubb_plugin_oas.createReactGenerator)({
|
|
|
45
44
|
schemas.request,
|
|
46
45
|
schemas.response
|
|
47
46
|
].flat().filter(Boolean);
|
|
48
|
-
const mapOperationSchema = ({ name, schema: schemaObject, description,...options$1 }
|
|
47
|
+
const mapOperationSchema = ({ name, schema: schemaObject, description,...options$1 }) => {
|
|
49
48
|
const tree = schemaGenerator.parse({
|
|
50
49
|
schemaObject,
|
|
51
50
|
name
|
|
@@ -67,39 +66,34 @@ const fakerGenerator = (0, __kubb_plugin_oas.createReactGenerator)({
|
|
|
67
66
|
})
|
|
68
67
|
};
|
|
69
68
|
const canOverride = tree.some(({ keyword }) => keyword === __kubb_plugin_oas.schemaKeywords.array || keyword === __kubb_plugin_oas.schemaKeywords.and || keyword === __kubb_plugin_oas.schemaKeywords.object || keyword === __kubb_plugin_oas.schemaKeywords.union || keyword === __kubb_plugin_oas.schemaKeywords.tuple);
|
|
70
|
-
return /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsxs)(
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
seed,
|
|
99
|
-
canOverride
|
|
100
|
-
})
|
|
101
|
-
]
|
|
102
|
-
}, i);
|
|
69
|
+
return /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsxs)(__kubb_react_fabric.Fragment, { children: [
|
|
70
|
+
canOverride && /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.File.Import, {
|
|
71
|
+
isTypeOnly: true,
|
|
72
|
+
root: file.path,
|
|
73
|
+
path: type.file.path,
|
|
74
|
+
name: [type.name]
|
|
75
|
+
}),
|
|
76
|
+
imports.map((imp) => /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.File.Import, {
|
|
77
|
+
root: file.path,
|
|
78
|
+
path: imp.path,
|
|
79
|
+
name: imp.name
|
|
80
|
+
}, [
|
|
81
|
+
imp.path,
|
|
82
|
+
imp.name,
|
|
83
|
+
imp.isTypeOnly
|
|
84
|
+
].join("-"))),
|
|
85
|
+
/* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(require_components.Faker, {
|
|
86
|
+
name: faker.name,
|
|
87
|
+
typeName: type.name,
|
|
88
|
+
description,
|
|
89
|
+
tree,
|
|
90
|
+
regexGenerator,
|
|
91
|
+
dateParser,
|
|
92
|
+
mapper,
|
|
93
|
+
seed,
|
|
94
|
+
canOverride
|
|
95
|
+
})
|
|
96
|
+
] });
|
|
103
97
|
};
|
|
104
98
|
return /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsxs)(__kubb_react_fabric.File, {
|
|
105
99
|
baseName: file.baseName,
|
|
@@ -131,10 +125,9 @@ const fakerGenerator = (0, __kubb_plugin_oas.createReactGenerator)({
|
|
|
131
125
|
]
|
|
132
126
|
});
|
|
133
127
|
},
|
|
134
|
-
Schema({ schema,
|
|
135
|
-
const { dateParser, regexGenerator, seed, mapper } = options;
|
|
128
|
+
Schema({ schema, plugin }) {
|
|
136
129
|
const { getName, getFile, getImports } = (0, __kubb_plugin_oas_hooks.useSchemaManager)();
|
|
137
|
-
const { options: { output } } =
|
|
130
|
+
const { options: { output, dateParser, regexGenerator, seed, mapper } } = plugin;
|
|
138
131
|
const pluginManager = (0, __kubb_core_hooks.usePluginManager)();
|
|
139
132
|
const oas = (0, __kubb_plugin_oas_hooks.useOas)();
|
|
140
133
|
const imports = getImports(schema.tree);
|
|
@@ -214,4 +207,4 @@ Object.defineProperty(exports, 'fakerGenerator', {
|
|
|
214
207
|
return fakerGenerator;
|
|
215
208
|
}
|
|
216
209
|
});
|
|
217
|
-
//# sourceMappingURL=fakerGenerator-
|
|
210
|
+
//# sourceMappingURL=fakerGenerator-CYRnwp6R.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fakerGenerator-CYRnwp6R.cjs","names":["SchemaGenerator","options","pluginTsName","schemaKeywords","Fragment","File","Faker"],"sources":["../src/generators/fakerGenerator.tsx"],"sourcesContent":["import { useMode, usePluginManager } from '@kubb/core/hooks'\nimport { type OperationSchema as OperationSchemaType, SchemaGenerator, schemaKeywords } from '@kubb/plugin-oas'\nimport { createReactGenerator } from '@kubb/plugin-oas/generators'\nimport { useOas, useOperationManager, useSchemaManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { File, Fragment } from '@kubb/react-fabric'\nimport { Faker } from '../components'\nimport type { PluginFaker } from '../types'\n\nexport const fakerGenerator = createReactGenerator<PluginFaker>({\n name: 'faker',\n Operation({ operation, generator, plugin }) {\n const {\n options,\n options: { dateParser, regexGenerator, seed, mapper },\n } = plugin\n const mode = useMode()\n const pluginManager = usePluginManager()\n\n const oas = useOas()\n const { getSchemas, getFile, getGroup } = useOperationManager(generator)\n const schemaManager = useSchemaManager()\n\n const file = getFile(operation)\n const schemas = getSchemas(operation)\n const schemaGenerator = new SchemaGenerator(options, {\n fabric: generator.context.fabric,\n oas,\n plugin,\n pluginManager,\n mode,\n override: options.override,\n })\n\n const operationSchemas = [schemas.pathParams, schemas.queryParams, schemas.headerParams, schemas.statusCodes, schemas.request, schemas.response]\n .flat()\n .filter(Boolean)\n\n const mapOperationSchema = ({ name, schema: schemaObject, description, ...options }: OperationSchemaType) => {\n const tree = schemaGenerator.parse({ schemaObject, name })\n const imports = schemaManager.getImports(tree)\n const group = options.operation ? getGroup(options.operation) : undefined\n\n const faker = {\n name: schemaManager.getName(name, { type: 'function' }),\n file: schemaManager.getFile(name),\n }\n\n const type = {\n name: schemaManager.getName(name, { type: 'type', pluginKey: [pluginTsName] }),\n file: schemaManager.getFile(options.operationName || name, { pluginKey: [pluginTsName], group }),\n }\n\n const canOverride = tree.some(\n ({ keyword }) =>\n keyword === schemaKeywords.array ||\n keyword === schemaKeywords.and ||\n keyword === schemaKeywords.object ||\n keyword === schemaKeywords.union ||\n keyword === schemaKeywords.tuple,\n )\n\n return (\n <Fragment>\n {canOverride && <File.Import isTypeOnly root={file.path} path={type.file.path} name={[type.name]} />}\n {imports.map((imp) => (\n <File.Import key={[imp.path, imp.name, imp.isTypeOnly].join('-')} root={file.path} path={imp.path} name={imp.name} />\n ))}\n <Faker\n name={faker.name}\n typeName={type.name}\n description={description}\n tree={tree}\n regexGenerator={regexGenerator}\n dateParser={dateParser}\n mapper={mapper}\n seed={seed}\n canOverride={canOverride}\n />\n </Fragment>\n )\n }\n\n return (\n <File\n baseName={file.baseName}\n path={file.path}\n meta={file.meta}\n banner={getBanner({ oas, output: plugin.options.output, config: pluginManager.config })}\n footer={getFooter({ oas, output: plugin.options.output })}\n >\n <File.Import name={['faker']} path=\"@faker-js/faker\" />\n {regexGenerator === 'randexp' && <File.Import name={'RandExp'} path={'randexp'} />}\n {dateParser !== 'faker' && <File.Import path={dateParser} name={dateParser} />}\n {operationSchemas.map(mapOperationSchema)}\n </File>\n )\n },\n Schema({ schema, plugin }) {\n const { getName, getFile, getImports } = useSchemaManager()\n const {\n options: { output, dateParser, regexGenerator, seed, mapper },\n } = plugin\n const pluginManager = usePluginManager()\n const oas = useOas()\n const imports = getImports(schema.tree)\n\n const faker = {\n name: getName(schema.name, { type: 'function' }),\n file: getFile(schema.name),\n }\n\n const type = {\n name: getName(schema.name, { type: 'type', pluginKey: [pluginTsName] }),\n file: getFile(schema.name, { pluginKey: [pluginTsName] }),\n }\n\n const canOverride = schema.tree.some(\n ({ keyword }) =>\n keyword === schemaKeywords.array ||\n keyword === schemaKeywords.and ||\n keyword === schemaKeywords.object ||\n keyword === schemaKeywords.union ||\n keyword === schemaKeywords.tuple ||\n keyword === schemaKeywords.string ||\n keyword === schemaKeywords.integer ||\n keyword === schemaKeywords.number,\n )\n\n return (\n <File\n baseName={faker.file.baseName}\n path={faker.file.path}\n meta={faker.file.meta}\n banner={getBanner({ oas, output, config: pluginManager.config })}\n footer={getFooter({ oas, output })}\n >\n <File.Import name={['faker']} path=\"@faker-js/faker\" />\n {regexGenerator === 'randexp' && <File.Import name={'RandExp'} path={'randexp'} />}\n {dateParser !== 'faker' && <File.Import path={dateParser} name={dateParser} />}\n <File.Import isTypeOnly root={faker.file.path} path={type.file.path} name={[type.name]} />\n {imports.map((imp) => (\n <File.Import key={[imp.path, imp.name, imp.isTypeOnly].join('-')} root={faker.file.path} path={imp.path} name={imp.name} />\n ))}\n\n <Faker\n name={faker.name}\n typeName={type.name}\n description={schema.value.description}\n tree={schema.tree}\n regexGenerator={regexGenerator}\n dateParser={dateParser}\n mapper={mapper}\n seed={seed}\n canOverride={canOverride}\n />\n </File>\n )\n },\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAUA,MAAa,wEAAmD;CAC9D,MAAM;CACN,UAAU,EAAE,WAAW,WAAW,UAAU;EAC1C,MAAM,EACJ,SACA,SAAS,EAAE,YAAY,gBAAgB,MAAM,aAC3C;EACJ,MAAM,uCAAgB;EACtB,MAAM,yDAAkC;EAExC,MAAM,2CAAc;EACpB,MAAM,EAAE,YAAY,SAAS,8DAAiC,UAAU;EACxE,MAAM,+DAAkC;EAExC,MAAM,OAAO,QAAQ,UAAU;EAC/B,MAAM,UAAU,WAAW,UAAU;EACrC,MAAM,kBAAkB,IAAIA,kCAAgB,SAAS;GACnD,QAAQ,UAAU,QAAQ;GAC1B;GACA;GACA;GACA;GACA,UAAU,QAAQ;GACnB,CAAC;EAEF,MAAM,mBAAmB;GAAC,QAAQ;GAAY,QAAQ;GAAa,QAAQ;GAAc,QAAQ;GAAa,QAAQ;GAAS,QAAQ;GAAS,CAC7I,MAAM,CACN,OAAO,QAAQ;EAElB,MAAM,sBAAsB,EAAE,MAAM,QAAQ,cAAc,YAAa,GAAGC,gBAAmC;GAC3G,MAAM,OAAO,gBAAgB,MAAM;IAAE;IAAc;IAAM,CAAC;GAC1D,MAAM,UAAU,cAAc,WAAW,KAAK;GAC9C,MAAM,QAAQA,UAAQ,YAAY,SAASA,UAAQ,UAAU,GAAG;GAEhE,MAAM,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