@kubb/plugin-faker 3.0.0-alpha.1 → 3.0.0-alpha.11
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.cjs +137 -178
- package/dist/components.cjs.map +1 -1
- package/dist/components.js +66 -115
- package/dist/components.js.map +1 -1
- package/dist/index.cjs +137 -180
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +55 -106
- package/dist/index.js.map +1 -1
- package/package.json +13 -13
- package/src/OperationGenerator.tsx +1 -0
- package/src/components/OperationSchema.tsx +11 -13
- package/src/components/Schema.tsx +5 -7
- package/src/plugin.ts +16 -33
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/kubb/kubb/packages/plugin-faker/dist/index.cjs","../src/plugin.ts","../src/OperationGenerator.tsx","../src/components/OperationSchema.tsx","../src/SchemaGenerator.tsx","../src/components/Schema.tsx","../src/parser/index.ts"],"names":["value","options","schema","jsx","SchemaGenerator","transformers","path"],"mappings":"AAAA;ACAA,wEAAiB;AAEjB,kCAAyD;AACzD,mHAA0B;AAC1B,yCAA+B;AAC/B,6CAA8B;AAC9B,gDAAqC;AACrC,2CAA6B;ADC7B;AACA;AETA;AACA,yDAAoB;AACpB,oCAAgC;AFWhC;AACA;AGdA;AACA,+CAA0D;AAC1D;AACA;AHgBA;AACA;AInBA;AAEA;AACA;AJoBA;AACA;AKzBA;AACA;AACA;AAEA;AACA;AACA;AL0BA;AACA;AMjCA;AACA;AAKO,IAAM,mBAAA,EAAqB;AAAA,EAChC,GAAA,EAAK,CAAA,EAAA,GAAM,WAAA;AAAA,EACX,OAAA,EAAS,CAAA,EAAA,GAAM,SAAA;AAAA,EACf,MAAA,EAAQ,CAAC,GAAA,EAAc,GAAA,EAAA,GAAiB;AACtC,IAAA,GAAA,CAAI,IAAA,IAAQ,KAAA,EAAA,GAAa,IAAA,IAAQ,KAAA,CAAA,EAAW;AAC1C,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AAA;AACR,IAAA;AACM,IAAA;AACK,MAAA;AACP,QAAA;AACF,MAAA;AAEM,MAAA;AAEF,MAAA;AACI,QAAA;AACJ,UAAA;AACA,UAAA;AACA,UAAA;AACA,UAAA;AACA,UAAA;AACA,UAAA;AACA,UAAA;AACD,QAAA;AAEK,QAAA;AACR,MAAA;AAEM,MAAA;AACJ,QAAA;AACA,QAAA;AACQ,QAAA;AACA,QAAA;AACT,MAAA;AACH,IAAA;AACF,EAAA;AACD;ADsae;AACA;AACA;AACA","file":"/home/runner/work/kubb/kubb/packages/plugin-faker/dist/index.cjs","sourcesContent":[null,"import path from 'node:path'\n\nimport { FileManager, PluginManager, createPlugin } from '@kubb/core'\nimport { camelCase } from '@kubb/core/transformers'\nimport { renderTemplate } from '@kubb/core/utils'\nimport { pluginOasName } from '@kubb/plugin-oas'\nimport { getGroupedByTagFiles } from '@kubb/plugin-oas/utils'\nimport { pluginTsName } from '@kubb/plugin-ts'\n\nimport { OperationGenerator } from './OperationGenerator.tsx'\nimport { SchemaGenerator } from './SchemaGenerator.tsx'\n\nimport type { Plugin } from '@kubb/core'\nimport type { PluginOas } from '@kubb/plugin-oas'\nimport type { PluginFaker } from './types.ts'\n\nexport const pluginFakerName = 'plugin-faker' satisfies PluginFaker['name']\n\nexport const pluginFaker = createPlugin<PluginFaker>((options) => {\n const {\n output = { path: 'mocks' },\n seed,\n group,\n exclude = [],\n include,\n override = [],\n transformers = {},\n mapper = {},\n dateType = 'string',\n unknownType = 'any',\n dateParser,\n regexGenerator = 'faker',\n } = options\n const template = group?.output ? group.output : `${output.path}/{{tag}}Controller`\n\n return {\n name: pluginFakerName,\n options: {\n extName: output.extName,\n transformers,\n dateType,\n seed,\n unknownType,\n dateParser,\n mapper,\n override,\n regexGenerator,\n },\n pre: [pluginOasName, pluginTsName],\n resolvePath(baseName, pathMode, options) {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = pathMode ?? FileManager.getMode(path.resolve(root, output.path))\n\n if (mode === 'single') {\n /**\n * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend\n * Other plugins then need to call addOrAppend instead of just add from the fileManager class\n */\n return path.resolve(root, output.path)\n }\n\n if (options?.tag && group?.type === 'tag') {\n const tag = camelCase(options.tag)\n\n return path.resolve(root, renderTemplate(template, { tag }), baseName)\n }\n\n return path.resolve(root, output.path, baseName)\n },\n resolveName(name, type) {\n const resolvedName = camelCase(name, {\n prefix: type ? 'create' : undefined,\n isFile: type === 'file',\n })\n\n if (type) {\n return transformers?.name?.(resolvedName, type) || resolvedName\n }\n\n return resolvedName\n },\n async writeFile(path, source) {\n if (!path.endsWith('.ts') || !source) {\n return\n }\n\n return this.fileManager.write(path, source, { sanity: false })\n },\n async buildStart() {\n const [swaggerPlugin]: [Plugin<PluginOas>] = PluginManager.getDependedPlugins<PluginOas>(this.plugins, [pluginOasName])\n\n const oas = await swaggerPlugin.api.getOas()\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = FileManager.getMode(path.resolve(root, output.path))\n\n const schemaGenerator = new SchemaGenerator(this.plugin.options, {\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType: swaggerPlugin.api.contentType,\n include: undefined,\n override,\n mode,\n output: output.path,\n })\n\n const schemaFiles = await schemaGenerator.build()\n await this.addFile(...schemaFiles)\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType: swaggerPlugin.api.contentType,\n exclude,\n include,\n override,\n mode,\n })\n\n const operationFiles = await operationGenerator.build()\n await this.addFile(...operationFiles)\n },\n async buildEnd() {\n if (this.config.output.write === false) {\n return\n }\n\n const root = path.resolve(this.config.root, this.config.output.path)\n\n if (group?.type === 'tag') {\n const rootFiles = await getGroupedByTagFiles({\n logger: this.logger,\n files: this.fileManager.files,\n plugin: this.plugin,\n template,\n exportAs: group.exportAs || '{{tag}}Mocks',\n root,\n output,\n })\n\n await this.addFile(...rootFiles)\n }\n\n await this.fileManager.addIndexes({\n root,\n output,\n meta: { pluginKey: this.plugin.key },\n logger: this.logger,\n })\n },\n }\n})\n","import { OperationGenerator as Generator } from '@kubb/plugin-oas'\nimport { Oas } from '@kubb/plugin-oas/components'\nimport { App, createRoot } from '@kubb/react'\n\nimport { OperationSchema } from './components/OperationSchema.tsx'\n\nimport type { Operation } from '@kubb/oas'\nimport type { OperationMethodResult } from '@kubb/plugin-oas'\nimport type { FileMeta, PluginFaker } from './types.ts'\n\nexport class OperationGenerator extends Generator<PluginFaker['resolvedOptions'], PluginFaker> {\n async operation(operation: Operation, options: PluginFaker['resolvedOptions']): OperationMethodResult<FileMeta> {\n const { oas, pluginManager, plugin, mode } = this.context\n\n const root = createRoot({\n logger: pluginManager.logger,\n })\n root.render(\n <App pluginManager={pluginManager} plugin={{ ...plugin, options }} mode={mode}>\n <Oas oas={oas} operations={[operation]} generator={this}>\n <Oas.Operation operation={operation}>\n <OperationSchema.File />\n </Oas.Operation>\n </Oas>\n </App>,\n )\n\n return root.files\n }\n}\n","import { Oas } from '@kubb/plugin-oas/components'\nimport { useOas, useOperation, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { File, Parser, useApp } from '@kubb/react'\nimport { pluginTsName } from '@kubb/plugin-ts'\n\nimport { SchemaGenerator } from '../SchemaGenerator.tsx'\n\nimport type { OperationSchema as OperationSchemaType } from '@kubb/plugin-oas'\nimport type { ReactNode } from 'react'\nimport type { FileMeta, PluginFaker } from '../types.ts'\nimport { Schema } from './Schema.tsx'\n\ntype Props = {\n description?: string\n}\n\nexport function OperationSchema({ description }: Props): ReactNode {\n return <Schema withData={false} description={description} />\n}\n\ntype FileProps = {}\n\nOperationSchema.File = function ({}: FileProps): ReactNode {\n const { plugin, pluginManager, mode } = useApp<PluginFaker>()\n\n const oas = useOas()\n const { getSchemas, getFile } = useOperationManager()\n const operation = useOperation()\n\n const file = getFile(operation)\n const schemas = getSchemas(operation)\n const generator = new SchemaGenerator(plugin.options, {\n oas,\n plugin,\n pluginManager,\n mode,\n override: plugin.options.override,\n })\n\n const items = [schemas.pathParams, schemas.queryParams, schemas.headerParams, schemas.statusCodes, schemas.request, schemas.response].flat().filter(Boolean)\n\n const mapItem = ({ name, schema, description, ...options }: OperationSchemaType, i: number) => {\n // used for this.options.typed\n const typeName = pluginManager.resolveName({\n name,\n pluginKey: [pluginTsName],\n type: 'type',\n })\n const typeFileName = pluginManager.resolveName({\n name: options.operationName || name,\n pluginKey: [pluginTsName],\n type: 'file',\n })\n const typePath = pluginManager.resolvePath({\n baseName: typeFileName,\n pluginKey: [pluginTsName],\n options: { tag: options.operation?.getTags()[0]?.name },\n })\n\n const tree = generator.parse({ schema, name })\n\n return (\n <Oas.Schema key={i} name={name} value={schema} tree={tree}>\n {typeName && typePath && <File.Import extName={plugin.options.extName} isTypeOnly root={file.path} path={typePath} name={[typeName]} />}\n {plugin.options.dateParser && <File.Import path={plugin.options.dateParser} name={plugin.options.dateParser} />}\n\n {mode === 'split' && <Oas.Schema.Imports extName={plugin.options.extName} />}\n <File.Source>\n <OperationSchema description={description} />\n </File.Source>\n </Oas.Schema>\n )\n }\n\n return (\n <Parser language=\"typescript\">\n <File<FileMeta> baseName={file.baseName} path={file.path} meta={file.meta}>\n <File.Import name={['faker']} path=\"@faker-js/faker\" />\n {plugin.options.regexGenerator === 'randexp' && <File.Import name={'RandExp'} path={'randexp'} />}\n {items.map(mapItem)}\n </File>\n </Parser>\n )\n}\n","import type { SchemaObject } from '@kubb/oas'\nimport { SchemaGenerator as Generator } from '@kubb/plugin-oas'\nimport type { SchemaMethodResult } from '@kubb/plugin-oas'\nimport { Oas } from '@kubb/plugin-oas/components'\nimport { App, createRoot } from '@kubb/react'\nimport { Schema } from './components/Schema.tsx'\nimport type { FileMeta, PluginFaker } from './types.ts'\n\nexport class SchemaGenerator extends Generator<PluginFaker['resolvedOptions'], PluginFaker> {\n async schema(name: string, schema: SchemaObject, options: PluginFaker['resolvedOptions']): SchemaMethodResult<FileMeta> {\n const { oas, pluginManager, plugin, mode, output } = this.context\n\n const root = createRoot({\n logger: pluginManager.logger,\n })\n\n const tree = this.parse({ schema, name })\n\n root.render(\n <App pluginManager={pluginManager} plugin={{ ...plugin, options }} mode={mode}>\n <Oas oas={oas}>\n <Oas.Schema name={name} value={schema} tree={tree}>\n <Schema.File />\n </Oas.Schema>\n </Oas>\n </App>,\n )\n\n return root.files\n }\n}\n","import { Oas } from '@kubb/plugin-oas/components'\nimport { File, Function, useApp, useFile } from '@kubb/react'\nimport { pluginTsName } from '@kubb/plugin-ts'\n\nimport transformers from '@kubb/core/transformers'\nimport { schemaKeywords } from '@kubb/plugin-oas'\nimport { useSchema } from '@kubb/plugin-oas/hooks'\nimport type { ReactNode } from 'react'\nimport * as parserFaker from '../parser/index.ts'\nimport { pluginFakerName } from '../plugin.ts'\nimport type { PluginFaker } from '../types.ts'\n\ntype Props = {\n description?: string\n withData?: boolean\n}\n\nexport function Schema(props: Props): ReactNode {\n const { withData, description } = props\n const { tree, name } = useSchema()\n const {\n pluginManager,\n plugin: {\n options: { dateParser, regexGenerator, mapper, seed },\n },\n } = useApp<PluginFaker>()\n\n // all checks are also inside this.schema(React)\n const resolvedName = pluginManager.resolveName({\n name,\n pluginKey: [pluginFakerName],\n type: 'function',\n })\n\n const typeName = pluginManager.resolveName({\n name,\n pluginKey: [pluginTsName],\n type: 'type',\n })\n\n const fakerText = parserFaker.joinItems(\n tree\n .map((schema) => parserFaker.parse(undefined, schema, { name: resolvedName, typeName, seed, regexGenerator, mapper, withData, dateParser }))\n .filter(Boolean),\n )\n\n let fakerDefaultOverride: '' | '[]' | '{}' | undefined = undefined\n let fakerTextWithOverride = fakerText\n\n if (withData && fakerText.startsWith('{')) {\n fakerDefaultOverride = '{}'\n fakerTextWithOverride = `{\n ...${fakerText},\n ...data\n}`\n }\n\n if (withData && fakerText.startsWith('faker.helpers.arrayElements')) {\n fakerDefaultOverride = '[]'\n fakerTextWithOverride = `[\n ...${fakerText},\n ...data\n ]`\n }\n\n const params = fakerDefaultOverride ? `data: NonNullable<Partial<${typeName}>> = ${fakerDefaultOverride}` : `data?: NonNullable<Partial<${typeName}>>`\n\n return (\n <>\n <Function\n export\n name={resolvedName}\n JSDoc={{ comments: [description ? `@description ${transformers.jsStringEscape(description)}` : undefined].filter(Boolean) }}\n params={withData ? params : ''}\n returnType={typeName ? `NonNullable<${typeName}>` : ''}\n >\n {seed ? `faker.seed(${JSON.stringify(seed)})` : ''}\n <br />\n <Function.Return>{fakerTextWithOverride}</Function.Return>\n </Function>\n <br />\n </>\n )\n}\n\ntype FileProps = {}\n\nSchema.File = function ({}: FileProps): ReactNode {\n const { pluginManager } = useApp<PluginFaker>()\n const { tree, schema } = useSchema()\n\n const withData = tree.some(\n (schema) =>\n schema.keyword === schemaKeywords.array ||\n schema.keyword === schemaKeywords.and ||\n schema.keyword === schemaKeywords.object ||\n schema.keyword === schemaKeywords.union ||\n schema.keyword === schemaKeywords.tuple,\n )\n\n return (\n <Oas.Schema.File output={pluginManager.config.output.path}>\n <Schema.Imports />\n <File.Source>\n <Schema description={schema?.description} withData={withData} />\n </File.Source>\n </Oas.Schema.File>\n )\n}\nSchema.Imports = (): ReactNode => {\n const {\n pluginManager,\n plugin: {\n options: { extName, dateParser, regexGenerator },\n },\n } = useApp<PluginFaker>()\n const { path: root } = useFile()\n const { name, tree, schema } = useSchema()\n\n // used for this.options.typed\n const typeName = pluginManager.resolveName({\n name,\n pluginKey: [pluginTsName],\n type: 'type',\n })\n\n const typeFileName = pluginManager.resolveName({\n name: name,\n pluginKey: [pluginTsName],\n type: 'file',\n })\n\n const typePath = pluginManager.resolvePath({\n baseName: typeFileName,\n pluginKey: [pluginTsName],\n })\n\n return (\n <>\n <File.Import name={['faker']} path=\"@faker-js/faker\" />\n {regexGenerator === 'randexp' && <File.Import name={'RandExp'} path={'randexp'} />}\n {dateParser && <File.Import path={dateParser} name={dateParser} />}\n {typeName && typePath && <File.Import extName={extName} isTypeOnly root={root} path={typePath} name={[typeName]} />}\n </>\n )\n}\n","import transformers from '@kubb/core/transformers'\nimport { SchemaGenerator, isKeyword, schemaKeywords } from '@kubb/plugin-oas'\n\nimport type { Schema, SchemaKeywordBase, SchemaKeywordMapper, SchemaMapper } from '@kubb/plugin-oas'\nimport type { Options } from '../types.ts'\n\nexport const fakerKeywordMapper = {\n any: () => 'undefined',\n unknown: () => 'unknown',\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 (min !== undefined) {\n return `faker.number.float({ min: ${min} })`\n }\n\n if (max !== undefined) {\n return `faker.number.float({ max: ${max} })`\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 (min !== undefined) {\n return `faker.number.int({ min: ${min} })`\n }\n\n if (max !== undefined) {\n return `faker.number.int({ max: ${max} })`\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 (min !== undefined) {\n return `faker.string.alpha({ length: { min: ${min} } })`\n }\n\n if (max !== undefined) {\n return `faker.string.alpha({ length: { max: ${max} } })`\n }\n\n return 'faker.string.alpha()'\n },\n boolean: () => 'faker.datatype.boolean()',\n undefined: () => 'undefined',\n null: () => 'null',\n array: (items: string[] = []) => `faker.helpers.arrayElements([${items.join(', ')}]) as any`,\n tuple: (items: string[] = []) => `faker.helpers.arrayElements([${items.join(', ')}]) as any`,\n enum: (items: Array<string | number> = []) => `faker.helpers.arrayElement<any>([${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?: string) => {\n if (type === 'string') {\n if (parser) {\n return `${parser}(faker.date.anytime()).format(\"YYYY-MM-DD\")`\n }\n return 'faker.date.anytime().toString()'\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?: string) => {\n if (type === 'string') {\n if (parser) {\n return `${parser}(faker.date.anytime()).format(\"HH:mm:ss\")`\n }\n return 'faker.date.anytime().toString()'\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(${transformers.toRegExpString(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.imageUrl() 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 strict: undefined,\n deprecated: undefined,\n example: undefined,\n schema: undefined,\n catchall: undefined,\n name: 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 name: string\n typeName?: string\n description?: string\n\n seed?: number | number[]\n regexGenerator?: 'faker' | 'randexp'\n withData?: boolean\n dateParser?: Options['dateParser']\n mapper?: Record<string, string>\n}\n\nexport function parse(parent: Schema | undefined, current: Schema, 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 return fakerKeywordMapper.union(current.args.map((schema) => parse(current, schema, { ...options, withData: false })).filter(Boolean))\n }\n\n if (isKeyword(current, schemaKeywords.and)) {\n return fakerKeywordMapper.and(current.args.map((schema) => parse(current, schema, { ...options, withData: false })).filter(Boolean))\n }\n\n if (isKeyword(current, schemaKeywords.array)) {\n return fakerKeywordMapper.array(current.args.items.map((schema) => parse(current, schema, { ...options, withData: false })).filter(Boolean))\n }\n\n if (isKeyword(current, schemaKeywords.enum)) {\n return fakerKeywordMapper.enum(\n current.args.items.map((schema) => {\n if (schema.format === 'number') {\n return schema.name\n }\n return transformers.stringify(schema.name)\n }),\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.withData) {\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((schema) => parse(current, schema, { ...options, withData: false }))\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(current.args.items.map((schema) => parse(current, schema, { ...options, withData: false })).filter(Boolean))\n }\n\n return parse(current, current.args.items, { ...options, withData: 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 (parent) {\n const minSchema = SchemaGenerator.find([parent], schemaKeywords.min)\n const maxSchema = SchemaGenerator.find([parent], 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 (parent) {\n const minSchema = SchemaGenerator.find([parent], schemaKeywords.min)\n const maxSchema = SchemaGenerator.find([parent], 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 (parent) {\n const minSchema = SchemaGenerator.find([parent], schemaKeywords.min)\n const maxSchema = SchemaGenerator.find([parent], 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"]}
|
|
1
|
+
{"version":3,"sources":["../src/parser/index.ts","../src/components/Schema.tsx","../src/SchemaGenerator.tsx","../src/components/OperationSchema.tsx","../src/OperationGenerator.tsx","../src/plugin.ts"],"names":["transformers","isKeyword","schemaKeywords","SchemaGenerator","value","options","useSchema","useApp","pluginTsName","jsxs","File","Function","jsx","schema","Oas","useFile","Fragment","Generator","createRoot","App","useOas","useOperationManager","useOperation","createPlugin","pluginOasName","path","FileManager","camelCase","renderTemplate","PluginManager"],"mappings":";;;;;;;;;;;;;;;;;;;AAMO,IAAM,kBAAqB,GAAA;AAAA,EAChC,KAAK,MAAM,WAAA;AAAA,EACX,SAAS,MAAM,SAAA;AAAA,EACf,MAAA,EAAQ,CAAC,GAAA,EAAc,GAAiB,KAAA;AACtC,IAAI,IAAA,GAAA,KAAQ,KAAa,CAAA,IAAA,GAAA,KAAQ,KAAW,CAAA,EAAA;AAC1C,MAAO,OAAA,CAAA,0BAAA,EAA6B,GAAG,CAAA,OAAA,EAAU,GAAG,CAAA,GAAA,CAAA,CAAA;AAAA,KACtD;AAEA,IAAA,IAAI,QAAQ,KAAW,CAAA,EAAA;AACrB,MAAA,OAAO,6BAA6B,GAAG,CAAA,GAAA,CAAA,CAAA;AAAA,KACzC;AAEA,IAAA,IAAI,QAAQ,KAAW,CAAA,EAAA;AACrB,MAAA,OAAO,6BAA6B,GAAG,CAAA,GAAA,CAAA,CAAA;AAAA,KACzC;AAEA,IAAO,OAAA,sBAAA,CAAA;AAAA,GACT;AAAA,EACA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ACzB;AAAA,UACA,QAAQ,IAAK,CAAA,MAAA;AAAA,SACd,CAAA,CAAA;AAED,QAAM,MAAA,IAAA,CAAK,OAAQ,CAAA,GAAG,WAAW,CAAA,CAAA;AAAA,OACnC;AAAA,KACF;AAAA,GACF,CAAA;AACF,CAAC","file":"index.cjs","sourcesContent":["import transformers from '@kubb/core/transformers'\nimport { SchemaGenerator, isKeyword, schemaKeywords } from '@kubb/plugin-oas'\n\nimport type { Schema, SchemaKeywordBase, SchemaKeywordMapper, SchemaMapper } from '@kubb/plugin-oas'\nimport type { Options } from '../types.ts'\n\nexport const fakerKeywordMapper = {\n any: () => 'undefined',\n unknown: () => 'unknown',\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 (min !== undefined) {\n return `faker.number.float({ min: ${min} })`\n }\n\n if (max !== undefined) {\n return `faker.number.float({ max: ${max} })`\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 (min !== undefined) {\n return `faker.number.int({ min: ${min} })`\n }\n\n if (max !== undefined) {\n return `faker.number.int({ max: ${max} })`\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 (min !== undefined) {\n return `faker.string.alpha({ length: { min: ${min} } })`\n }\n\n if (max !== undefined) {\n return `faker.string.alpha({ length: { max: ${max} } })`\n }\n\n return 'faker.string.alpha()'\n },\n boolean: () => 'faker.datatype.boolean()',\n undefined: () => 'undefined',\n null: () => 'null',\n array: (items: string[] = []) => `faker.helpers.arrayElements([${items.join(', ')}]) as any`,\n tuple: (items: string[] = []) => `faker.helpers.arrayElements([${items.join(', ')}]) as any`,\n enum: (items: Array<string | number> = []) => `faker.helpers.arrayElement<any>([${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?: string) => {\n if (type === 'string') {\n if (parser) {\n return `${parser}(faker.date.anytime()).format(\"YYYY-MM-DD\")`\n }\n return 'faker.date.anytime().toString()'\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?: string) => {\n if (type === 'string') {\n if (parser) {\n return `${parser}(faker.date.anytime()).format(\"HH:mm:ss\")`\n }\n return 'faker.date.anytime().toString()'\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(${transformers.toRegExpString(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.imageUrl() 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 strict: undefined,\n deprecated: undefined,\n example: undefined,\n schema: undefined,\n catchall: undefined,\n name: 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 name: string\n typeName?: string\n description?: string\n\n seed?: number | number[]\n regexGenerator?: 'faker' | 'randexp'\n withData?: boolean\n dateParser?: Options['dateParser']\n mapper?: Record<string, string>\n}\n\nexport function parse(parent: Schema | undefined, current: Schema, 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 return fakerKeywordMapper.union(current.args.map((schema) => parse(current, schema, { ...options, withData: false })).filter(Boolean))\n }\n\n if (isKeyword(current, schemaKeywords.and)) {\n return fakerKeywordMapper.and(current.args.map((schema) => parse(current, schema, { ...options, withData: false })).filter(Boolean))\n }\n\n if (isKeyword(current, schemaKeywords.array)) {\n return fakerKeywordMapper.array(current.args.items.map((schema) => parse(current, schema, { ...options, withData: false })).filter(Boolean))\n }\n\n if (isKeyword(current, schemaKeywords.enum)) {\n return fakerKeywordMapper.enum(\n current.args.items.map((schema) => {\n if (schema.format === 'number') {\n return schema.name\n }\n return transformers.stringify(schema.name)\n }),\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.withData) {\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((schema) => parse(current, schema, { ...options, withData: false }))\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(current.args.items.map((schema) => parse(current, schema, { ...options, withData: false })).filter(Boolean))\n }\n\n return parse(current, current.args.items, { ...options, withData: 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 (parent) {\n const minSchema = SchemaGenerator.find([parent], schemaKeywords.min)\n const maxSchema = SchemaGenerator.find([parent], 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 (parent) {\n const minSchema = SchemaGenerator.find([parent], schemaKeywords.min)\n const maxSchema = SchemaGenerator.find([parent], 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 (parent) {\n const minSchema = SchemaGenerator.find([parent], schemaKeywords.min)\n const maxSchema = SchemaGenerator.find([parent], 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 { Oas } from '@kubb/plugin-oas/components'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { File, Function, useApp, useFile } from '@kubb/react'\n\nimport transformers from '@kubb/core/transformers'\nimport { schemaKeywords } from '@kubb/plugin-oas'\nimport { useSchema } from '@kubb/plugin-oas/hooks'\nimport type { ReactNode } from 'react'\nimport * as parserFaker from '../parser/index.ts'\nimport { pluginFakerName } from '../plugin.ts'\nimport type { PluginFaker } from '../types.ts'\n\ntype Props = {\n description?: string\n withData?: boolean\n}\n\nexport function Schema(props: Props): ReactNode {\n const { withData, description } = props\n const { tree, name } = useSchema()\n const {\n pluginManager,\n plugin: {\n options: { dateParser, regexGenerator, mapper, seed },\n },\n } = useApp<PluginFaker>()\n\n // all checks are also inside this.schema(React)\n const resolvedName = pluginManager.resolveName({\n name,\n pluginKey: [pluginFakerName],\n type: 'function',\n })\n\n const typeName = pluginManager.resolveName({\n name,\n pluginKey: [pluginTsName],\n type: 'type',\n })\n\n const fakerText = parserFaker.joinItems(\n tree\n .map((schema) => parserFaker.parse(undefined, schema, { name: resolvedName, typeName, seed, regexGenerator, mapper, withData, dateParser }))\n .filter(Boolean),\n )\n\n let fakerDefaultOverride: '' | '[]' | '{}' | undefined = undefined\n let fakerTextWithOverride = fakerText\n\n if (withData && fakerText.startsWith('{')) {\n fakerDefaultOverride = '{}'\n fakerTextWithOverride = `{\n ...${fakerText},\n ...data\n}`\n }\n\n if (withData && fakerText.startsWith('faker.helpers.arrayElements')) {\n fakerDefaultOverride = '[]'\n fakerTextWithOverride = `[\n ...${fakerText},\n ...data\n ]`\n }\n\n const params = fakerDefaultOverride ? `data: NonNullable<Partial<${typeName}>> = ${fakerDefaultOverride}` : `data?: NonNullable<Partial<${typeName}>>`\n\n return (\n <File.Source name={resolvedName} isExportable isIndexable>\n <Function\n export\n name={resolvedName}\n JSDoc={{ comments: [description ? `@description ${transformers.jsStringEscape(description)}` : undefined].filter(Boolean) }}\n params={withData ? params : ''}\n returnType={typeName ? `NonNullable<${typeName}>` : ''}\n >\n {seed ? `faker.seed(${JSON.stringify(seed)})` : ''}\n <br />\n <Function.Return>{fakerTextWithOverride}</Function.Return>\n </Function>\n <br />\n </File.Source>\n )\n}\n\ntype FileProps = {}\n\nSchema.File = function ({}: FileProps): ReactNode {\n const { pluginManager } = useApp<PluginFaker>()\n const { tree, schema } = useSchema()\n\n const withData = tree.some(\n (schema) =>\n schema.keyword === schemaKeywords.array ||\n schema.keyword === schemaKeywords.and ||\n schema.keyword === schemaKeywords.object ||\n schema.keyword === schemaKeywords.union ||\n schema.keyword === schemaKeywords.tuple,\n )\n\n return (\n <Oas.Schema.File output={pluginManager.config.output.path}>\n <Schema.Imports />\n <Schema description={schema?.description} withData={withData} />\n </Oas.Schema.File>\n )\n}\nSchema.Imports = (): ReactNode => {\n const {\n pluginManager,\n plugin: {\n options: { extName, dateParser, regexGenerator },\n },\n } = useApp<PluginFaker>()\n const { path: root } = useFile()\n const { name, tree, schema } = useSchema()\n\n // used for this.options.typed\n const typeName = pluginManager.resolveName({\n name,\n pluginKey: [pluginTsName],\n type: 'type',\n })\n\n const typeFileName = pluginManager.resolveName({\n name: name,\n pluginKey: [pluginTsName],\n type: 'file',\n })\n\n const typePath = pluginManager.resolvePath({\n baseName: typeFileName,\n pluginKey: [pluginTsName],\n })\n\n return (\n <>\n <File.Import name={['faker']} path=\"@faker-js/faker\" />\n {regexGenerator === 'randexp' && <File.Import name={'RandExp'} path={'randexp'} />}\n {dateParser && <File.Import path={dateParser} name={dateParser} />}\n {typeName && typePath && <File.Import isTypeOnly root={root} path={typePath} name={[typeName]} />}\n </>\n )\n}\n","import type { SchemaObject } from '@kubb/oas'\nimport { SchemaGenerator as Generator } from '@kubb/plugin-oas'\nimport type { SchemaMethodResult } from '@kubb/plugin-oas'\nimport { Oas } from '@kubb/plugin-oas/components'\nimport { App, createRoot } from '@kubb/react'\nimport { Schema } from './components/Schema.tsx'\nimport type { FileMeta, PluginFaker } from './types.ts'\n\nexport class SchemaGenerator extends Generator<PluginFaker['resolvedOptions'], PluginFaker> {\n async schema(name: string, schema: SchemaObject, options: PluginFaker['resolvedOptions']): SchemaMethodResult<FileMeta> {\n const { oas, pluginManager, plugin, mode, output } = this.context\n\n const root = createRoot({\n logger: pluginManager.logger,\n })\n\n const tree = this.parse({ schema, name })\n\n root.render(\n <App pluginManager={pluginManager} plugin={{ ...plugin, options }} mode={mode}>\n <Oas oas={oas}>\n <Oas.Schema name={name} value={schema} tree={tree}>\n <Schema.File />\n </Oas.Schema>\n </Oas>\n </App>,\n )\n\n return root.files\n }\n}\n","import { Oas } from '@kubb/plugin-oas/components'\nimport { useOas, useOperation, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { File, useApp } from '@kubb/react'\n\nimport { SchemaGenerator } from '../SchemaGenerator.tsx'\n\nimport type { OperationSchema as OperationSchemaType } from '@kubb/plugin-oas'\nimport type { ReactNode } from 'react'\nimport type { FileMeta, PluginFaker } from '../types.ts'\nimport { Schema } from './Schema.tsx'\n\ntype Props = {\n description?: string\n}\n\nexport function OperationSchema({ description }: Props): ReactNode {\n return <Schema withData={false} description={description} />\n}\n\ntype FileProps = {}\n\nOperationSchema.File = function ({}: FileProps): ReactNode {\n const { plugin, pluginManager, mode } = useApp<PluginFaker>()\n\n const oas = useOas()\n const { getSchemas, getFile } = useOperationManager()\n const operation = useOperation()\n\n const file = getFile(operation)\n const schemas = getSchemas(operation)\n const generator = new SchemaGenerator(plugin.options, {\n oas,\n plugin,\n pluginManager,\n mode,\n override: plugin.options.override,\n })\n\n const items = [schemas.pathParams, schemas.queryParams, schemas.headerParams, schemas.statusCodes, schemas.request, schemas.response].flat().filter(Boolean)\n\n const mapItem = ({ name, schema, description, ...options }: OperationSchemaType, i: number) => {\n // used for this.options.typed\n const typeName = pluginManager.resolveName({\n name,\n pluginKey: [pluginTsName],\n type: 'type',\n })\n const typeFileName = pluginManager.resolveName({\n name: options.operationName || name,\n pluginKey: [pluginTsName],\n type: 'file',\n })\n\n // todo replace by getFile\n const typePath = pluginManager.resolvePath({\n baseName: typeFileName,\n pluginKey: [pluginTsName],\n options: { tag: options.operation?.getTags()[0]?.name },\n })\n\n const tree = generator.parse({ schema, name })\n\n return (\n <Oas.Schema key={i} name={name} value={schema} tree={tree}>\n {typeName && typePath && <File.Import isTypeOnly root={file.path} path={typePath} name={[typeName]} />}\n {plugin.options.dateParser && <File.Import path={plugin.options.dateParser} name={plugin.options.dateParser} />}\n\n {mode === 'split' && <Oas.Schema.Imports />}\n <OperationSchema description={description} />\n </Oas.Schema>\n )\n }\n\n return (\n <File<FileMeta> baseName={file.baseName} path={file.path} meta={file.meta}>\n <File.Import name={['faker']} path=\"@faker-js/faker\" />\n {plugin.options.regexGenerator === 'randexp' && <File.Import name={'RandExp'} path={'randexp'} />}\n {items.map(mapItem)}\n </File>\n )\n}\n","import { OperationGenerator as Generator } from '@kubb/plugin-oas'\nimport { Oas } from '@kubb/plugin-oas/components'\nimport { App, createRoot } from '@kubb/react'\n\nimport { OperationSchema } from './components/OperationSchema.tsx'\n\nimport type { Operation } from '@kubb/oas'\nimport type { OperationMethodResult } from '@kubb/plugin-oas'\nimport type { FileMeta, PluginFaker } from './types.ts'\n\nexport class OperationGenerator extends Generator<PluginFaker['resolvedOptions'], PluginFaker> {\n async operation(operation: Operation, options: PluginFaker['resolvedOptions']): OperationMethodResult<FileMeta> {\n const { oas, pluginManager, plugin, mode } = this.context\n\n const root = createRoot({\n logger: pluginManager.logger,\n })\n\n root.render(\n <App pluginManager={pluginManager} plugin={{ ...plugin, options }} mode={mode}>\n <Oas oas={oas} operations={[operation]} generator={this}>\n <Oas.Operation operation={operation}>\n <OperationSchema.File />\n </Oas.Operation>\n </Oas>\n </App>,\n )\n\n return root.files\n }\n}\n","import path from 'node:path'\n\nimport { FileManager, PluginManager, createPlugin } from '@kubb/core'\nimport { camelCase } from '@kubb/core/transformers'\nimport { renderTemplate } from '@kubb/core/utils'\nimport { pluginOasName } from '@kubb/plugin-oas'\n\nimport { pluginTsName } from '@kubb/plugin-ts'\n\nimport { OperationGenerator } from './OperationGenerator.tsx'\nimport { SchemaGenerator } from './SchemaGenerator.tsx'\n\nimport type { Plugin } from '@kubb/core'\nimport type { PluginOas } from '@kubb/plugin-oas'\nimport type { PluginFaker } from './types.ts'\n\nexport const pluginFakerName = 'plugin-faker' satisfies PluginFaker['name']\n\nexport const pluginFaker = createPlugin<PluginFaker>((options) => {\n const {\n output = { path: 'mocks' },\n seed,\n group,\n exclude = [],\n include,\n override = [],\n transformers = {},\n mapper = {},\n dateType = 'string',\n unknownType = 'any',\n dateParser,\n regexGenerator = 'faker',\n } = options\n const template = group?.output ? group.output : `${output.path}/{{tag}}Controller`\n\n return {\n name: pluginFakerName,\n output: {\n exportType: 'barrelNamed',\n ...output,\n },\n options: {\n extName: output.extName,\n transformers,\n dateType,\n seed,\n unknownType,\n dateParser,\n mapper,\n override,\n regexGenerator,\n },\n pre: [pluginOasName, pluginTsName],\n resolvePath(baseName, pathMode, options) {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = pathMode ?? FileManager.getMode(path.resolve(root, output.path))\n\n if (mode === 'single') {\n /**\n * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend\n * Other plugins then need to call addOrAppend instead of just add from the fileManager class\n */\n return path.resolve(root, output.path)\n }\n\n if (options?.tag && group?.type === 'tag') {\n const tag = camelCase(options.tag)\n\n return path.resolve(root, renderTemplate(template, { tag }), baseName)\n }\n\n return path.resolve(root, output.path, baseName)\n },\n resolveName(name, type) {\n const resolvedName = camelCase(name, {\n prefix: type ? 'create' : undefined,\n isFile: type === 'file',\n })\n\n if (type) {\n return transformers?.name?.(resolvedName, type) || resolvedName\n }\n\n return resolvedName\n },\n async buildStart() {\n const [swaggerPlugin]: [Plugin<PluginOas>] = PluginManager.getDependedPlugins<PluginOas>(this.plugins, [pluginOasName])\n\n const oas = await swaggerPlugin.context.getOas()\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = FileManager.getMode(path.resolve(root, output.path))\n\n const schemaGenerator = new SchemaGenerator(this.plugin.options, {\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType: swaggerPlugin.context.contentType,\n include: undefined,\n override,\n mode,\n output: output.path,\n })\n\n const schemaFiles = await schemaGenerator.build()\n await this.addFile(...schemaFiles)\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType: swaggerPlugin.context.contentType,\n exclude,\n include,\n override,\n mode,\n })\n\n const operationFiles = await operationGenerator.build()\n await this.addFile(...operationFiles)\n\n if (this.config.output.exportType) {\n const barrelFiles = await this.fileManager.getBarrelFiles({\n root,\n output,\n files: this.fileManager.files,\n meta: {\n pluginKey: this.plugin.key,\n },\n logger: this.logger,\n })\n\n await this.addFile(...barrelFiles)\n }\n },\n }\n})\n"]}
|
package/dist/index.js
CHANGED
|
@@ -1,39 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
import { OperationGenerator as Generator2 } from "@kubb/plugin-oas";
|
|
12
|
-
import { Oas as Oas4 } from "@kubb/plugin-oas/components";
|
|
13
|
-
import { App as App2, createRoot as createRoot2 } from "@kubb/react";
|
|
14
|
-
|
|
15
|
-
// src/components/OperationSchema.tsx
|
|
16
|
-
import { Oas as Oas3 } from "@kubb/plugin-oas/components";
|
|
17
|
-
import { useOas, useOperation, useOperationManager } from "@kubb/plugin-oas/hooks";
|
|
18
|
-
import { File as File2, Parser, useApp as useApp2 } from "@kubb/react";
|
|
19
|
-
import { pluginTsName as pluginTsName2 } from "@kubb/plugin-ts";
|
|
20
|
-
|
|
21
|
-
// src/SchemaGenerator.tsx
|
|
22
|
-
import { SchemaGenerator as Generator } from "@kubb/plugin-oas";
|
|
23
|
-
import { Oas as Oas2 } from "@kubb/plugin-oas/components";
|
|
24
|
-
import { App, createRoot } from "@kubb/react";
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { createPlugin, FileManager, PluginManager } from '@kubb/core';
|
|
3
|
+
import transformers, { camelCase } from '@kubb/core/transformers';
|
|
4
|
+
import { renderTemplate } from '@kubb/core/utils';
|
|
5
|
+
import { pluginOasName, SchemaGenerator, OperationGenerator as OperationGenerator$1, schemaKeywords, isKeyword } from '@kubb/plugin-oas';
|
|
6
|
+
import { pluginTsName } from '@kubb/plugin-ts';
|
|
7
|
+
import { Oas } from '@kubb/plugin-oas/components';
|
|
8
|
+
import { createRoot, App, useApp, File, Function, useFile } from '@kubb/react';
|
|
9
|
+
import { useSchema, useOas, useOperationManager, useOperation } from '@kubb/plugin-oas/hooks';
|
|
10
|
+
import { jsx, jsxs, Fragment } from '@kubb/react/jsx-runtime';
|
|
25
11
|
|
|
26
|
-
// src/
|
|
27
|
-
import { Oas } from "@kubb/plugin-oas/components";
|
|
28
|
-
import { File, Function, useApp, useFile } from "@kubb/react";
|
|
29
|
-
import { pluginTsName } from "@kubb/plugin-ts";
|
|
30
|
-
import transformers2 from "@kubb/core/transformers";
|
|
31
|
-
import { schemaKeywords as schemaKeywords2 } from "@kubb/plugin-oas";
|
|
32
|
-
import { useSchema } from "@kubb/plugin-oas/hooks";
|
|
33
|
-
|
|
34
|
-
// src/parser/index.ts
|
|
35
|
-
import transformers from "@kubb/core/transformers";
|
|
36
|
-
import { SchemaGenerator, isKeyword, schemaKeywords } from "@kubb/plugin-oas";
|
|
12
|
+
// src/plugin.ts
|
|
37
13
|
var fakerKeywordMapper = {
|
|
38
14
|
any: () => "undefined",
|
|
39
15
|
unknown: () => "unknown",
|
|
@@ -271,9 +247,6 @@ function parse(parent, current, options) {
|
|
|
271
247
|
}
|
|
272
248
|
return void 0;
|
|
273
249
|
}
|
|
274
|
-
|
|
275
|
-
// src/components/Schema.tsx
|
|
276
|
-
import { Fragment, jsx, jsxs } from "@kubb/react/jsx-runtime";
|
|
277
250
|
function Schema(props) {
|
|
278
251
|
const { withData, description } = props;
|
|
279
252
|
const { tree, name } = useSchema();
|
|
@@ -313,13 +286,13 @@ function Schema(props) {
|
|
|
313
286
|
]`;
|
|
314
287
|
}
|
|
315
288
|
const params = fakerDefaultOverride ? `data: NonNullable<Partial<${typeName}>> = ${fakerDefaultOverride}` : `data?: NonNullable<Partial<${typeName}>>`;
|
|
316
|
-
return /* @__PURE__ */ jsxs(
|
|
289
|
+
return /* @__PURE__ */ jsxs(File.Source, { name: resolvedName, isExportable: true, isIndexable: true, children: [
|
|
317
290
|
/* @__PURE__ */ jsxs(
|
|
318
291
|
Function,
|
|
319
292
|
{
|
|
320
293
|
export: true,
|
|
321
294
|
name: resolvedName,
|
|
322
|
-
JSDoc: { comments: [description ? `@description ${
|
|
295
|
+
JSDoc: { comments: [description ? `@description ${transformers.jsStringEscape(description)}` : void 0].filter(Boolean) },
|
|
323
296
|
params: withData ? params : "",
|
|
324
297
|
returnType: typeName ? `NonNullable<${typeName}>` : "",
|
|
325
298
|
children: [
|
|
@@ -336,11 +309,11 @@ Schema.File = function({}) {
|
|
|
336
309
|
const { pluginManager } = useApp();
|
|
337
310
|
const { tree, schema } = useSchema();
|
|
338
311
|
const withData = tree.some(
|
|
339
|
-
(schema2) => schema2.keyword ===
|
|
312
|
+
(schema2) => schema2.keyword === schemaKeywords.array || schema2.keyword === schemaKeywords.and || schema2.keyword === schemaKeywords.object || schema2.keyword === schemaKeywords.union || schema2.keyword === schemaKeywords.tuple
|
|
340
313
|
);
|
|
341
314
|
return /* @__PURE__ */ jsxs(Oas.Schema.File, { output: pluginManager.config.output.path, children: [
|
|
342
315
|
/* @__PURE__ */ jsx(Schema.Imports, {}),
|
|
343
|
-
/* @__PURE__ */ jsx(
|
|
316
|
+
/* @__PURE__ */ jsx(Schema, { description: schema?.description, withData })
|
|
344
317
|
] });
|
|
345
318
|
};
|
|
346
319
|
Schema.Imports = () => {
|
|
@@ -370,13 +343,10 @@ Schema.Imports = () => {
|
|
|
370
343
|
/* @__PURE__ */ jsx(File.Import, { name: ["faker"], path: "@faker-js/faker" }),
|
|
371
344
|
regexGenerator === "randexp" && /* @__PURE__ */ jsx(File.Import, { name: "RandExp", path: "randexp" }),
|
|
372
345
|
dateParser && /* @__PURE__ */ jsx(File.Import, { path: dateParser, name: dateParser }),
|
|
373
|
-
typeName && typePath && /* @__PURE__ */ jsx(File.Import, {
|
|
346
|
+
typeName && typePath && /* @__PURE__ */ jsx(File.Import, { isTypeOnly: true, root, path: typePath, name: [typeName] })
|
|
374
347
|
] });
|
|
375
348
|
};
|
|
376
|
-
|
|
377
|
-
// src/SchemaGenerator.tsx
|
|
378
|
-
import { jsx as jsx2 } from "@kubb/react/jsx-runtime";
|
|
379
|
-
var SchemaGenerator2 = class extends Generator {
|
|
349
|
+
var SchemaGenerator2 = class extends SchemaGenerator {
|
|
380
350
|
async schema(name, schema, options) {
|
|
381
351
|
const { oas, pluginManager, plugin, mode, output } = this.context;
|
|
382
352
|
const root = createRoot({
|
|
@@ -384,19 +354,16 @@ var SchemaGenerator2 = class extends Generator {
|
|
|
384
354
|
});
|
|
385
355
|
const tree = this.parse({ schema, name });
|
|
386
356
|
root.render(
|
|
387
|
-
/* @__PURE__ */
|
|
357
|
+
/* @__PURE__ */ jsx(App, { pluginManager, plugin: { ...plugin, options }, mode, children: /* @__PURE__ */ jsx(Oas, { oas, children: /* @__PURE__ */ jsx(Oas.Schema, { name, value: schema, tree, children: /* @__PURE__ */ jsx(Schema.File, {}) }) }) })
|
|
388
358
|
);
|
|
389
359
|
return root.files;
|
|
390
360
|
}
|
|
391
361
|
};
|
|
392
|
-
|
|
393
|
-
// src/components/OperationSchema.tsx
|
|
394
|
-
import { jsx as jsx3, jsxs as jsxs2 } from "@kubb/react/jsx-runtime";
|
|
395
362
|
function OperationSchema({ description }) {
|
|
396
|
-
return /* @__PURE__ */
|
|
363
|
+
return /* @__PURE__ */ jsx(Schema, { withData: false, description });
|
|
397
364
|
}
|
|
398
365
|
OperationSchema.File = function({}) {
|
|
399
|
-
const { plugin, pluginManager, mode } =
|
|
366
|
+
const { plugin, pluginManager, mode } = useApp();
|
|
400
367
|
const oas = useOas();
|
|
401
368
|
const { getSchemas, getFile } = useOperationManager();
|
|
402
369
|
const operation = useOperation();
|
|
@@ -413,44 +380,41 @@ OperationSchema.File = function({}) {
|
|
|
413
380
|
const mapItem = ({ name, schema, description, ...options }, i) => {
|
|
414
381
|
const typeName = pluginManager.resolveName({
|
|
415
382
|
name,
|
|
416
|
-
pluginKey: [
|
|
383
|
+
pluginKey: [pluginTsName],
|
|
417
384
|
type: "type"
|
|
418
385
|
});
|
|
419
386
|
const typeFileName = pluginManager.resolveName({
|
|
420
387
|
name: options.operationName || name,
|
|
421
|
-
pluginKey: [
|
|
388
|
+
pluginKey: [pluginTsName],
|
|
422
389
|
type: "file"
|
|
423
390
|
});
|
|
424
391
|
const typePath = pluginManager.resolvePath({
|
|
425
392
|
baseName: typeFileName,
|
|
426
|
-
pluginKey: [
|
|
393
|
+
pluginKey: [pluginTsName],
|
|
427
394
|
options: { tag: options.operation?.getTags()[0]?.name }
|
|
428
395
|
});
|
|
429
396
|
const tree = generator.parse({ schema, name });
|
|
430
|
-
return /* @__PURE__ */
|
|
431
|
-
typeName && typePath && /* @__PURE__ */
|
|
432
|
-
plugin.options.dateParser && /* @__PURE__ */
|
|
433
|
-
mode === "split" && /* @__PURE__ */
|
|
434
|
-
/* @__PURE__ */
|
|
397
|
+
return /* @__PURE__ */ jsxs(Oas.Schema, { name, value: schema, tree, children: [
|
|
398
|
+
typeName && typePath && /* @__PURE__ */ jsx(File.Import, { isTypeOnly: true, root: file.path, path: typePath, name: [typeName] }),
|
|
399
|
+
plugin.options.dateParser && /* @__PURE__ */ jsx(File.Import, { path: plugin.options.dateParser, name: plugin.options.dateParser }),
|
|
400
|
+
mode === "split" && /* @__PURE__ */ jsx(Oas.Schema.Imports, {}),
|
|
401
|
+
/* @__PURE__ */ jsx(OperationSchema, { description })
|
|
435
402
|
] }, i);
|
|
436
403
|
};
|
|
437
|
-
return /* @__PURE__ */
|
|
438
|
-
/* @__PURE__ */
|
|
439
|
-
plugin.options.regexGenerator === "randexp" && /* @__PURE__ */
|
|
404
|
+
return /* @__PURE__ */ jsxs(File, { baseName: file.baseName, path: file.path, meta: file.meta, children: [
|
|
405
|
+
/* @__PURE__ */ jsx(File.Import, { name: ["faker"], path: "@faker-js/faker" }),
|
|
406
|
+
plugin.options.regexGenerator === "randexp" && /* @__PURE__ */ jsx(File.Import, { name: "RandExp", path: "randexp" }),
|
|
440
407
|
items.map(mapItem)
|
|
441
|
-
] })
|
|
408
|
+
] });
|
|
442
409
|
};
|
|
443
|
-
|
|
444
|
-
// src/OperationGenerator.tsx
|
|
445
|
-
import { jsx as jsx4 } from "@kubb/react/jsx-runtime";
|
|
446
|
-
var OperationGenerator = class extends Generator2 {
|
|
410
|
+
var OperationGenerator = class extends OperationGenerator$1 {
|
|
447
411
|
async operation(operation, options) {
|
|
448
412
|
const { oas, pluginManager, plugin, mode } = this.context;
|
|
449
|
-
const root =
|
|
413
|
+
const root = createRoot({
|
|
450
414
|
logger: pluginManager.logger
|
|
451
415
|
});
|
|
452
416
|
root.render(
|
|
453
|
-
/* @__PURE__ */
|
|
417
|
+
/* @__PURE__ */ jsx(App, { pluginManager, plugin: { ...plugin, options }, mode, children: /* @__PURE__ */ jsx(Oas, { oas, operations: [operation], generator: this, children: /* @__PURE__ */ jsx(Oas.Operation, { operation, children: /* @__PURE__ */ jsx(OperationSchema.File, {}) }) }) })
|
|
454
418
|
);
|
|
455
419
|
return root.files;
|
|
456
420
|
}
|
|
@@ -476,6 +440,10 @@ var pluginFaker = createPlugin((options) => {
|
|
|
476
440
|
const template = group?.output ? group.output : `${output.path}/{{tag}}Controller`;
|
|
477
441
|
return {
|
|
478
442
|
name: pluginFakerName,
|
|
443
|
+
output: {
|
|
444
|
+
exportType: "barrelNamed",
|
|
445
|
+
...output
|
|
446
|
+
},
|
|
479
447
|
options: {
|
|
480
448
|
extName: output.extName,
|
|
481
449
|
transformers: transformers3,
|
|
@@ -487,7 +455,7 @@ var pluginFaker = createPlugin((options) => {
|
|
|
487
455
|
override,
|
|
488
456
|
regexGenerator
|
|
489
457
|
},
|
|
490
|
-
pre: [pluginOasName,
|
|
458
|
+
pre: [pluginOasName, pluginTsName],
|
|
491
459
|
resolvePath(baseName, pathMode, options2) {
|
|
492
460
|
const root = path.resolve(this.config.root, this.config.output.path);
|
|
493
461
|
const mode = pathMode ?? FileManager.getMode(path.resolve(root, output.path));
|
|
@@ -510,22 +478,16 @@ var pluginFaker = createPlugin((options) => {
|
|
|
510
478
|
}
|
|
511
479
|
return resolvedName;
|
|
512
480
|
},
|
|
513
|
-
async writeFile(path2, source) {
|
|
514
|
-
if (!path2.endsWith(".ts") || !source) {
|
|
515
|
-
return;
|
|
516
|
-
}
|
|
517
|
-
return this.fileManager.write(path2, source, { sanity: false });
|
|
518
|
-
},
|
|
519
481
|
async buildStart() {
|
|
520
482
|
const [swaggerPlugin] = PluginManager.getDependedPlugins(this.plugins, [pluginOasName]);
|
|
521
|
-
const oas = await swaggerPlugin.
|
|
483
|
+
const oas = await swaggerPlugin.context.getOas();
|
|
522
484
|
const root = path.resolve(this.config.root, this.config.output.path);
|
|
523
485
|
const mode = FileManager.getMode(path.resolve(root, output.path));
|
|
524
486
|
const schemaGenerator = new SchemaGenerator2(this.plugin.options, {
|
|
525
487
|
oas,
|
|
526
488
|
pluginManager: this.pluginManager,
|
|
527
489
|
plugin: this.plugin,
|
|
528
|
-
contentType: swaggerPlugin.
|
|
490
|
+
contentType: swaggerPlugin.context.contentType,
|
|
529
491
|
include: void 0,
|
|
530
492
|
override,
|
|
531
493
|
mode,
|
|
@@ -537,7 +499,7 @@ var pluginFaker = createPlugin((options) => {
|
|
|
537
499
|
oas,
|
|
538
500
|
pluginManager: this.pluginManager,
|
|
539
501
|
plugin: this.plugin,
|
|
540
|
-
contentType: swaggerPlugin.
|
|
502
|
+
contentType: swaggerPlugin.context.contentType,
|
|
541
503
|
exclude,
|
|
542
504
|
include,
|
|
543
505
|
override,
|
|
@@ -545,35 +507,22 @@ var pluginFaker = createPlugin((options) => {
|
|
|
545
507
|
});
|
|
546
508
|
const operationFiles = await operationGenerator.build();
|
|
547
509
|
await this.addFile(...operationFiles);
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
if (this.config.output.write === false) {
|
|
551
|
-
return;
|
|
552
|
-
}
|
|
553
|
-
const root = path.resolve(this.config.root, this.config.output.path);
|
|
554
|
-
if (group?.type === "tag") {
|
|
555
|
-
const rootFiles = await getGroupedByTagFiles({
|
|
556
|
-
logger: this.logger,
|
|
557
|
-
files: this.fileManager.files,
|
|
558
|
-
plugin: this.plugin,
|
|
559
|
-
template,
|
|
560
|
-
exportAs: group.exportAs || "{{tag}}Mocks",
|
|
510
|
+
if (this.config.output.exportType) {
|
|
511
|
+
const barrelFiles = await this.fileManager.getBarrelFiles({
|
|
561
512
|
root,
|
|
562
|
-
output
|
|
513
|
+
output,
|
|
514
|
+
files: this.fileManager.files,
|
|
515
|
+
meta: {
|
|
516
|
+
pluginKey: this.plugin.key
|
|
517
|
+
},
|
|
518
|
+
logger: this.logger
|
|
563
519
|
});
|
|
564
|
-
await this.addFile(...
|
|
520
|
+
await this.addFile(...barrelFiles);
|
|
565
521
|
}
|
|
566
|
-
await this.fileManager.addIndexes({
|
|
567
|
-
root,
|
|
568
|
-
output,
|
|
569
|
-
meta: { pluginKey: this.plugin.key },
|
|
570
|
-
logger: this.logger
|
|
571
|
-
});
|
|
572
522
|
}
|
|
573
523
|
};
|
|
574
524
|
});
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
};
|
|
525
|
+
|
|
526
|
+
export { pluginFaker, pluginFakerName };
|
|
527
|
+
//# sourceMappingURL=index.js.map
|
|
579
528
|
//# sourceMappingURL=index.js.map
|