@kubb/plugin-faker 5.0.0-beta.4 → 5.0.0-beta.56
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +39 -22
- package/dist/{Faker-CdyPfOPg.d.ts → Faker-A5UuxwJj.d.ts} +3 -3
- package/dist/{Faker-fcQEB9i5.js → Faker-CHh0JtBG.js} +41 -145
- package/dist/Faker-CHh0JtBG.js.map +1 -0
- package/dist/{Faker-BgleOzVN.cjs → Faker-CcGjn5ZM.cjs} +40 -174
- package/dist/Faker-CcGjn5ZM.cjs.map +1 -0
- package/dist/components.cjs +1 -1
- package/dist/components.d.ts +1 -1
- package/dist/components.js +1 -1
- package/dist/{fakerGenerator-D7daHCh6.js → fakerGenerator-DDNsdbH2.js} +237 -94
- package/dist/fakerGenerator-DDNsdbH2.js.map +1 -0
- package/dist/{fakerGenerator-VJEVzLjc.cjs → fakerGenerator-DrwGWYwv.cjs} +240 -97
- package/dist/fakerGenerator-DrwGWYwv.cjs.map +1 -0
- package/dist/fakerGenerator-KKVr-CA2.d.ts +14 -0
- package/dist/generators.cjs +1 -1
- package/dist/generators.d.ts +1 -1
- package/dist/generators.js +1 -1
- package/dist/index.cjs +240 -69
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +35 -15
- package/dist/index.js +241 -70
- package/dist/index.js.map +1 -1
- package/dist/{printerFaker-CJiwzoto.d.ts → printerFaker-CMCJT3FB.d.ts} +68 -35
- package/package.json +12 -22
- package/src/components/Faker.tsx +51 -65
- package/src/generators/fakerGenerator.tsx +108 -72
- package/src/plugin.ts +27 -23
- package/src/printers/printerFaker.ts +102 -40
- package/src/resolvers/resolverFaker.ts +31 -39
- package/src/types.ts +40 -31
- package/src/utils.ts +7 -106
- package/dist/Faker-BgleOzVN.cjs.map +0 -1
- package/dist/Faker-fcQEB9i5.js.map +0 -1
- package/dist/fakerGenerator-C3Ho3BaI.d.ts +0 -9
- package/dist/fakerGenerator-D7daHCh6.js.map +0 -1
- package/dist/fakerGenerator-VJEVzLjc.cjs.map +0 -1
- package/extension.yaml +0 -364
- /package/dist/{chunk--u3MIqq1.js → chunk-C0LytTxp.js} +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fakerGenerator-D7daHCh6.js","names":[],"sources":["../../../internals/utils/src/object.ts","../../../internals/utils/src/regexp.ts","../src/printers/printerFaker.ts","../src/generators/fakerGenerator.tsx"],"sourcesContent":["import { trimQuotes } from './string.ts'\n\n/**\n * Serializes a primitive value to a JSON string literal, stripping any surrounding quote characters first.\n *\n * @example\n * stringify('hello') // '\"hello\"'\n * stringify('\"hello\"') // '\"hello\"'\n */\nexport function stringify(value: string | number | boolean | undefined): string {\n if (value === undefined || value === null) return '\"\"'\n return JSON.stringify(trimQuotes(value.toString()))\n}\n\n/**\n * Converts a plain object into a multiline key-value string suitable for embedding in generated code.\n * Nested objects are recursively stringified with indentation.\n *\n * @example\n * stringifyObject({ foo: 'bar', nested: { a: 1 } })\n * // 'foo: bar,\\nnested: {\\n a: 1\\n }'\n */\nexport function stringifyObject(value: Record<string, unknown>): string {\n const items = Object.entries(value)\n .map(([key, val]) => {\n if (val !== null && typeof val === 'object') {\n return `${key}: {\\n ${stringifyObject(val as Record<string, unknown>)}\\n }`\n }\n return `${key}: ${val}`\n })\n .filter(Boolean)\n return items.join(',\\n')\n}\n\n/**\n * Converts a dot-notation path or string array into an optional-chaining accessor expression.\n *\n * @example\n * getNestedAccessor('pagination.next.id', 'lastPage')\n * // → \"lastPage?.['pagination']?.['next']?.['id']\"\n */\nexport function getNestedAccessor(param: string | string[], accessor: string): string | null {\n const parts = Array.isArray(param) ? param : param.split('.')\n if (parts.length === 0 || (parts.length === 1 && parts[0] === '')) return null\n return `${accessor}?.['${`${parts.join(\"']?.['\")}']`}`\n}\n","import { trimQuotes } from './string.ts'\n\n/**\n * Converts a pattern string into a `new RegExp(...)` constructor call or a regex literal string.\n * Inline flags expressed as `^(?im)` prefixes are extracted and applied to the resulting expression.\n * Pass `null` as the second argument to emit a `/pattern/flags` literal instead.\n *\n * @example\n * toRegExpString('^(?im)foo') // → 'new RegExp(\"foo\", \"im\")'\n * toRegExpString('^(?im)foo', null) // → '/foo/im'\n */\nexport function toRegExpString(text: string, func: string | null = 'RegExp'): string {\n const raw = trimQuotes(text)\n\n const match = raw.match(/^\\^(\\(\\?([igmsuy]+)\\))/i)\n const replacementTarget = match?.[1] ?? ''\n const matchedFlags = match?.[2]\n const cleaned = raw\n .replace(/^\\\\?\\//, '')\n .replace(/\\\\?\\/$/, '')\n .replace(replacementTarget, '')\n\n const { source, flags } = new RegExp(cleaned, matchedFlags)\n\n if (func === null) return `/${source}/${flags}`\n\n return `new ${func}(${JSON.stringify(source)}${flags ? `, ${JSON.stringify(flags)}` : ''})`\n}\n","import { stringify, toRegExpString } from '@internals/utils'\nimport { ast } from '@kubb/core'\nimport type { PluginFaker, ResolverFaker } from '../types.ts'\n\n/**\n * Partial printer nodes for Faker generation, mapping schema types to output strings.\n */\nexport type PrinterFakerNodes = ast.PrinterPartial<string, PrinterFakerOptions>\n\n/**\n * Configuration options for the Faker printer, including resolvers, mappers, and cyclic schema tracking.\n */\nexport type PrinterFakerOptions = {\n dateParser?: PluginFaker['resolvedOptions']['dateParser']\n regexGenerator?: PluginFaker['resolvedOptions']['regexGenerator']\n mapper?: PluginFaker['resolvedOptions']['mapper']\n resolver: ResolverFaker\n typeName?: string\n schemaName?: string\n nestedInObject?: boolean\n nodes?: PrinterFakerNodes\n /**\n * Names of schemas that participate in a circular dependency chain.\n * Properties whose schema transitively references one of these are emitted\n * as lazy getters so that user overrides via the `data` parameter prevent\n * the recursive faker call from ever executing (avoiding stack overflow).\n */\n cyclicSchemas?: ReadonlySet<string>\n}\n\n/**\n * Factory options for the Faker printer, defining input/output types and configuration.\n */\nexport type PrinterFakerFactory = ast.PrinterFactoryOptions<'faker', PrinterFakerOptions, string, string>\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 bigint: () => 'faker.number.bigInt()',\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 null: () => 'null',\n array: (items: string[] = [], min?: number, max?: number) => {\n if (items.length > 1) {\n return `faker.helpers.arrayElements([${items.join(', ')}])`\n }\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\n if (min !== undefined) {\n return `faker.helpers.multiple(() => (${item}), { count: ${min} })`\n }\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 datetime: () => 'faker.date.anytime().toISOString()',\n date: (representation: 'date' | 'string' = 'string', parser: PluginFaker['resolvedOptions']['dateParser'] = 'faker') => {\n if (representation === 'string') {\n if (parser !== 'faker') {\n return `${parser}(faker.date.anytime()).format(\"YYYY-MM-DD\")`\n }\n\n return 'faker.date.anytime().toISOString().substring(0, 10)'\n }\n\n if (parser !== 'faker') {\n throw new Error(`type '${representation}' and parser '${parser}' can not work together`)\n }\n\n return 'faker.date.anytime()'\n },\n time: (representation: 'date' | 'string' = 'string', parser: PluginFaker['resolvedOptions']['dateParser'] = 'faker') => {\n if (representation === 'string') {\n if (parser !== 'faker') {\n return `${parser}(faker.date.anytime()).format(\"HH:mm:ss\")`\n }\n\n return 'faker.date.anytime().toISOString().substring(11, 19)'\n }\n\n if (parser !== 'faker') {\n throw new Error(`type '${representation}' 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[] = []) => {\n if (items.length === 0) {\n return '{}'\n }\n\n if (items.length === 1) {\n return items[0] ?? '{}'\n }\n\n return `{...${items.join(', ...')}}`\n },\n matches: (value = '', regexGenerator: 'faker' | 'randexp' = 'faker') => {\n if (regexGenerator === 'randexp') {\n return `${toRegExpString(value, 'RandExp')}.gen()`\n }\n\n return `faker.helpers.fromRegExp(\"${value}\")`\n },\n email: () => 'faker.internet.email()',\n blob: () => 'faker.image.url() as unknown as Blob',\n} as const\n\nfunction getEnumValues(node: ast.EnumSchemaNode): Array<string | number | boolean | undefined> {\n if (node.namedEnumValues?.length) {\n return node.namedEnumValues.map((item) => item.value as string | number | boolean | undefined)\n }\n\n return (node.enumValues ?? []) as Array<string | number | boolean | undefined>\n}\n\nfunction parseEnumValue(value: string | number | boolean | undefined) {\n if (typeof value === 'string') {\n return stringify(value)\n }\n\n return value\n}\n\n/**\n * Creates a Faker printer that generates mock data generation code from schema nodes.\n * Handles circular references gracefully by emitting memoizing getters for cyclic properties.\n */\nexport const printerFaker: (options: PrinterFakerOptions) => ast.Printer<PrinterFakerFactory> = ast.definePrinter<PrinterFakerFactory>((options) => {\n const printNested = (node: ast.SchemaNode, overrideOptions: Partial<PrinterFakerOptions> = {}): string => {\n return (\n printerFaker({\n ...options,\n ...overrideOptions,\n nodes: options.nodes,\n }).print(node) ?? 'undefined'\n )\n }\n\n return {\n name: 'faker',\n options,\n nodes: {\n any: () => fakerKeywordMapper.any(),\n unknown: () => fakerKeywordMapper.unknown(),\n void: () => fakerKeywordMapper.void(),\n boolean: () => fakerKeywordMapper.boolean(),\n null: () => fakerKeywordMapper.null(),\n string(node) {\n if (node.pattern) {\n return fakerKeywordMapper.matches(node.pattern, this.options.regexGenerator)\n }\n\n return fakerKeywordMapper.string(node.min, node.max)\n },\n email: () => fakerKeywordMapper.email(),\n url: () => fakerKeywordMapper.url(),\n uuid: () => fakerKeywordMapper.uuid(),\n number(node) {\n return fakerKeywordMapper.number(node.min, node.max)\n },\n integer(node) {\n return fakerKeywordMapper.integer(node.min, node.max)\n },\n bigint: () => fakerKeywordMapper.bigint(),\n blob: () => fakerKeywordMapper.blob(),\n datetime: () => fakerKeywordMapper.datetime(),\n date(node) {\n return fakerKeywordMapper.date(node.representation ?? 'string', this.options.dateParser)\n },\n time(node) {\n return fakerKeywordMapper.time(node.representation ?? 'string', this.options.dateParser)\n },\n ref(node) {\n // Parser-generated refs (with $ref) carry raw schema names that need resolving.\n // Use the canonical name from the $ref path — node.name may have been overridden\n // (e.g. by single-member allOf flatten using the property-derived child name).\n // Inline refs (without $ref) from faker utils already carry resolved helper names.\n const refName = node.ref ? (ast.extractRefName(node.ref) ?? node.name ?? node.schema?.name) : (node.name ?? node.schema?.name)\n\n if (!refName) {\n throw new Error('Name not defined for ref node')\n }\n\n if (this.options.schemaName && refName === this.options.schemaName) {\n return 'undefined as any'\n }\n\n // Internal helper refs (for generated response/data helpers) are already\n // emitted with resolver output and should not be transformed twice.\n const resolvedName = node.ref ? this.options.resolver.resolveName(refName) : refName\n\n if (!this.options.nestedInObject) {\n return `${resolvedName}(data)`\n }\n\n return `${resolvedName}()`\n },\n enum(node) {\n return fakerKeywordMapper.enum(getEnumValues(node).map(parseEnumValue), this.options.typeName)\n },\n union(node): string {\n const items: string[] = (node.members ?? [])\n .map((member) =>\n printNested(member, {\n nestedInObject: true,\n }),\n )\n .filter((item): item is string => Boolean(item))\n\n return fakerKeywordMapper.union(items)\n },\n intersection(node): string {\n const items: string[] = (node.members ?? [])\n .map((member) =>\n printNested(member, {\n nestedInObject: true,\n }),\n )\n .filter((item): item is string => Boolean(item))\n\n return fakerKeywordMapper.and(items)\n },\n array(node): string {\n const items: string[] = (node.items ?? [])\n .map((member) =>\n printNested(member, {\n typeName: this.options.typeName ? `NonNullable<${this.options.typeName}>[number]` : undefined,\n nestedInObject: true,\n }),\n )\n .filter((item): item is string => Boolean(item))\n\n return fakerKeywordMapper.array(items, node.min, node.max)\n },\n tuple(node): string {\n const items: string[] = (node.items ?? [])\n .map((member, index) =>\n printNested(member, {\n typeName: this.options.typeName ? `NonNullable<${this.options.typeName}>[${index}]` : undefined,\n nestedInObject: true,\n }),\n )\n .filter((item): item is string => Boolean(item))\n\n return fakerKeywordMapper.tuple(items)\n },\n object(node): string {\n const cyclicSchemas = this.options.cyclicSchemas\n const properties = (node.properties ?? [])\n .map((property): string => {\n if (this.options.mapper && Object.hasOwn(this.options.mapper, property.name)) {\n return `\"${property.name}\": ${this.options.mapper[property.name]}`\n }\n\n const value: string =\n printNested(property.schema, {\n typeName: this.options.typeName ? `NonNullable<${this.options.typeName}>[${JSON.stringify(property.name)}]` : undefined,\n nestedInObject: true,\n }) ?? 'undefined'\n\n // When the property's schema transitively references a schema that is\n // part of a circular dependency (other than the current schema itself),\n // emit a memoizing lazy getter. On first access it computes the value,\n // replaces itself with a plain data property via Object.defineProperty,\n // and returns the cached value – so every subsequent read is stable.\n if (cyclicSchemas && ast.containsCircularRef(property.schema, { circularSchemas: cyclicSchemas, excludeName: this.options.schemaName })) {\n return `get ${property.name}() { const _value = ${value}; Object.defineProperty(this, ${JSON.stringify(property.name)}, { value: _value, configurable: true, writable: true, enumerable: true }); return _value }`\n }\n\n return `\"${property.name}\": ${value}`\n })\n .join(',')\n\n return `{${properties}}`\n },\n ...options.nodes,\n },\n print(node) {\n return this.transform(node) ?? null\n },\n }\n})\n","import { ast, defineGenerator } from '@kubb/core'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { File, jsxRenderer } from '@kubb/renderer-jsx'\nimport { Faker } from '../components/Faker.tsx'\nimport { printerFaker } from '../printers/printerFaker.ts'\nimport type { PluginFaker } from '../types.ts'\nimport {\n aliasConflictingImports,\n buildResponseUnionSchema,\n canOverrideSchema,\n filterUsedImports,\n localeToFakerImport,\n resolveParamNameByLocation,\n resolveSchemaRef,\n resolveTypeReference,\n rewriteAliasedImports,\n} from '../utils.ts'\n\nexport const fakerGenerator = defineGenerator<PluginFaker>({\n name: 'faker',\n renderer: jsxRenderer,\n schema(node, ctx) {\n const { adapter, config, resolver, root } = ctx\n const { output, group, dateParser, regexGenerator, mapper, seed, locale, printer } = ctx.options\n const pluginTs = ctx.driver.getPlugin(pluginTsName)\n\n if (!node.name || !pluginTs || !adapter.inputNode) {\n return\n }\n\n const tsResolver = ctx.driver.getResolver(pluginTsName)\n\n const schemaNode = resolveSchemaRef(node, adapter.inputNode.schemas)\n const schemaName = schemaNode.name ?? node.name\n const mode = ctx.getMode(output)\n const meta = {\n name: resolver.resolveName(schemaName),\n file: resolver.resolveFile({ name: schemaName, extname: '.ts' }, { root, output, group }),\n typeName: tsResolver.resolveTypeName(schemaName),\n typeFile: tsResolver.resolveFile(\n { name: schemaName, extname: '.ts' },\n { root, output: pluginTs.options?.output ?? output, group: pluginTs.options?.group },\n ),\n } as const\n const canOverride = canOverrideSchema(schemaNode)\n const cyclicSchemas = adapter.inputNode ? ast.findCircularSchemas(adapter.inputNode.schemas) : undefined\n const printerInstance = printerFaker({\n resolver,\n schemaName,\n typeName: meta.typeName,\n dateParser,\n regexGenerator,\n mapper,\n nodes: printer?.nodes,\n cyclicSchemas,\n })\n const fakerText = printerInstance.print(schemaNode) ?? 'undefined'\n const typeReference = resolveTypeReference({\n node: schemaNode,\n canOverride,\n name: meta.name,\n typeName: meta.typeName,\n filePath: meta.file.path,\n typeFilePath: meta.typeFile.path,\n })\n\n const imports = adapter\n .getImports(schemaNode, (schemaName) => ({\n name: resolver.resolveName(schemaName),\n path: resolver.resolveFile({ name: schemaName, extname: '.ts' }, { root, output, group }).path,\n }))\n .filter((entry) => entry.path !== meta.file.path)\n const usedImports = filterUsedImports(imports, fakerText)\n\n return (\n <File\n baseName={meta.file.baseName}\n path={meta.file.path}\n meta={meta.file.meta}\n banner={resolver.resolveBanner(adapter.inputNode, { output, config })}\n footer={resolver.resolveFooter(adapter.inputNode, { output, config })}\n >\n <File.Import name={locale ? [{ propertyName: localeToFakerImport(locale), name: 'faker' }] : ['faker']} path=\"@faker-js/faker\" />\n {regexGenerator === 'randexp' && <File.Import name={'RandExp'} path={'randexp'} />}\n {dateParser !== 'faker' && <File.Import path={dateParser} name={dateParser} />}\n {typeReference.importPath && <File.Import isTypeOnly root={meta.file.path} path={typeReference.importPath} name={[meta.typeName]} />}\n {mode === 'split' &&\n usedImports.map((imp) => <File.Import key={[schemaName, imp.path, imp.name].join('-')} root={meta.file.path} path={imp.path} name={imp.name} />)}\n <Faker\n name={meta.name}\n typeName={typeReference.typeName}\n description={schemaNode.description}\n node={schemaNode}\n printer={printerInstance}\n seed={seed}\n canOverride={canOverride}\n />\n </File>\n )\n },\n operation(node, ctx) {\n const { adapter, config, resolver, root } = ctx\n const { output, group, paramsCasing, dateParser, regexGenerator, mapper, seed, locale, printer } = ctx.options\n const pluginTs = ctx.driver.getPlugin(pluginTsName)\n\n if (!pluginTs) {\n return\n }\n\n const tsResolver = ctx.driver.getResolver(pluginTsName)\n\n const params = ast.caseParams(node.parameters, paramsCasing)\n const paramEntries = params.map((param) => ({\n param,\n name: resolveParamNameByLocation(resolver, node, param),\n typeName: resolveParamNameByLocation(tsResolver, node, param),\n }))\n const responseEntries = node.responses.map((response) => ({\n response,\n name: resolver.resolveResponseStatusName(node, response.statusCode),\n typeName: tsResolver.resolveResponseStatusName(node, response.statusCode),\n }))\n const dataEntry = node.requestBody?.content?.[0]?.schema\n ? {\n schema: {\n ...node.requestBody.content![0]!.schema!,\n description: node.requestBody.description ?? node.requestBody.content![0]!.schema!.description,\n },\n name: resolver.resolveDataName(node),\n typeName: tsResolver.resolveDataName(node),\n description: node.requestBody.description ?? node.requestBody.content![0]!.schema!.description,\n }\n : null\n const responseName = resolver.resolveResponseName(node)\n const localHelperNames = new Set([\n ...paramEntries.map((entry) => entry.name),\n ...responseEntries.map((entry) => entry.name),\n ...(dataEntry ? [dataEntry.name] : []),\n responseName,\n ])\n const meta = {\n file: resolver.resolveFile({ name: node.operationId, extname: '.ts', tag: node.tags[0] ?? 'default', path: node.path }, { root, output, group }),\n typeFile: tsResolver.resolveFile(\n {\n name: node.operationId,\n extname: '.ts',\n tag: node.tags[0] ?? 'default',\n path: node.path,\n },\n {\n root,\n output: pluginTs.options?.output ?? output,\n group: pluginTs.options?.group,\n },\n ),\n } as const\n\n function resolveMockImports(schema: ast.SchemaNode) {\n return adapter\n .getImports(schema, (schemaName) => ({\n name: resolver.resolveName(schemaName),\n path: resolver.resolveFile({ name: schemaName, extname: '.ts' }, { root, output, group }).path,\n }))\n .filter((entry) => entry.path !== meta.file.path)\n }\n\n function renderEntry({\n schema,\n name,\n typeName,\n description,\n skipImportNames = [],\n }: {\n schema: ast.SchemaNode | null\n name: string\n typeName: string\n description?: string\n skipImportNames?: Array<string>\n }) {\n if (!schema) {\n return null\n }\n\n const canOverride = canOverrideSchema(schema)\n const cyclicSchemas = adapter.inputNode ? ast.findCircularSchemas(adapter.inputNode.schemas) : undefined\n const printerInstance = printerFaker({\n resolver,\n schemaName: name,\n typeName,\n dateParser,\n regexGenerator,\n mapper,\n nodes: printer?.nodes,\n cyclicSchemas,\n })\n const fakerText = printerInstance.print(schema) ?? 'undefined'\n const usedImports = filterUsedImports(resolveMockImports(schema), fakerText, skipImportNames)\n const { imports, aliases } = aliasConflictingImports(usedImports, localHelperNames)\n const rewrittenFakerText = rewriteAliasedImports(fakerText, aliases)\n const typeReference = resolveTypeReference({\n node: schema,\n canOverride,\n name,\n typeName,\n filePath: meta.file.path,\n typeFilePath: meta.typeFile.path,\n })\n\n return (\n <>\n {typeReference.importPath && <File.Import isTypeOnly root={meta.file.path} path={typeReference.importPath} name={[typeName]} />}\n {imports.map((imp) => (\n <File.Import key={[name, imp.path, imp.name].join('-')} root={meta.file.path} path={imp.path} name={imp.name} />\n ))}\n <Faker\n name={name}\n typeName={typeReference.typeName}\n description={description}\n node={schema}\n printer={{ ...printerInstance, print: () => rewrittenFakerText }}\n seed={seed}\n canOverride={canOverride}\n />\n </>\n )\n }\n\n return (\n <File\n baseName={meta.file.baseName}\n path={meta.file.path}\n meta={meta.file.meta}\n banner={resolver.resolveBanner(adapter.inputNode, { output, config })}\n footer={resolver.resolveFooter(adapter.inputNode, { output, config })}\n >\n <File.Import name={locale ? [{ propertyName: localeToFakerImport(locale), name: 'faker' }] : ['faker']} path=\"@faker-js/faker\" />\n {regexGenerator === 'randexp' && <File.Import name={'RandExp'} path={'randexp'} />}\n {dateParser !== 'faker' && <File.Import path={dateParser} name={dateParser} />}\n {paramEntries.map(({ param, name, typeName }) =>\n renderEntry({\n schema: param.schema,\n name,\n typeName,\n }),\n )}\n {responseEntries.map(({ response, name, typeName }) =>\n renderEntry({\n schema: response.schema,\n name,\n typeName,\n description: response.description,\n }),\n )}\n {dataEntry\n ? renderEntry({\n schema: dataEntry.schema,\n name: dataEntry.name,\n typeName: dataEntry.typeName,\n description: dataEntry.description,\n })\n : null}\n {renderEntry({\n schema: buildResponseUnionSchema(node, resolver),\n name: responseName,\n typeName: tsResolver.resolveResponseName(node),\n skipImportNames: responseEntries.map(({ name }) => name),\n })}\n </File>\n )\n },\n})\n"],"mappings":";;;;;;;;;;;;;;AASA,SAAgB,UAA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,oBAAoB,KAAK;KAC9C,iBAAiB,gBAAgB,KAAK,EAAE,WAAW,KAAK;KACzD,CAAC;IACG;;;CAGZ,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fakerGenerator-VJEVzLjc.cjs","names":["trimQuotes","trimQuotes","ast","jsxRenderer","pluginTsName","resolveSchemaRef","canOverrideSchema","ast","resolveTypeReference","filterUsedImports","File","localeToFakerImport","Faker","resolveParamNameByLocation","aliasConflictingImports","rewriteAliasedImports","buildResponseUnionSchema"],"sources":["../../../internals/utils/src/object.ts","../../../internals/utils/src/regexp.ts","../src/printers/printerFaker.ts","../src/generators/fakerGenerator.tsx"],"sourcesContent":["import { trimQuotes } from './string.ts'\n\n/**\n * Serializes a primitive value to a JSON string literal, stripping any surrounding quote characters first.\n *\n * @example\n * stringify('hello') // '\"hello\"'\n * stringify('\"hello\"') // '\"hello\"'\n */\nexport function stringify(value: string | number | boolean | undefined): string {\n if (value === undefined || value === null) return '\"\"'\n return JSON.stringify(trimQuotes(value.toString()))\n}\n\n/**\n * Converts a plain object into a multiline key-value string suitable for embedding in generated code.\n * Nested objects are recursively stringified with indentation.\n *\n * @example\n * stringifyObject({ foo: 'bar', nested: { a: 1 } })\n * // 'foo: bar,\\nnested: {\\n a: 1\\n }'\n */\nexport function stringifyObject(value: Record<string, unknown>): string {\n const items = Object.entries(value)\n .map(([key, val]) => {\n if (val !== null && typeof val === 'object') {\n return `${key}: {\\n ${stringifyObject(val as Record<string, unknown>)}\\n }`\n }\n return `${key}: ${val}`\n })\n .filter(Boolean)\n return items.join(',\\n')\n}\n\n/**\n * Converts a dot-notation path or string array into an optional-chaining accessor expression.\n *\n * @example\n * getNestedAccessor('pagination.next.id', 'lastPage')\n * // → \"lastPage?.['pagination']?.['next']?.['id']\"\n */\nexport function getNestedAccessor(param: string | string[], accessor: string): string | null {\n const parts = Array.isArray(param) ? param : param.split('.')\n if (parts.length === 0 || (parts.length === 1 && parts[0] === '')) return null\n return `${accessor}?.['${`${parts.join(\"']?.['\")}']`}`\n}\n","import { trimQuotes } from './string.ts'\n\n/**\n * Converts a pattern string into a `new RegExp(...)` constructor call or a regex literal string.\n * Inline flags expressed as `^(?im)` prefixes are extracted and applied to the resulting expression.\n * Pass `null` as the second argument to emit a `/pattern/flags` literal instead.\n *\n * @example\n * toRegExpString('^(?im)foo') // → 'new RegExp(\"foo\", \"im\")'\n * toRegExpString('^(?im)foo', null) // → '/foo/im'\n */\nexport function toRegExpString(text: string, func: string | null = 'RegExp'): string {\n const raw = trimQuotes(text)\n\n const match = raw.match(/^\\^(\\(\\?([igmsuy]+)\\))/i)\n const replacementTarget = match?.[1] ?? ''\n const matchedFlags = match?.[2]\n const cleaned = raw\n .replace(/^\\\\?\\//, '')\n .replace(/\\\\?\\/$/, '')\n .replace(replacementTarget, '')\n\n const { source, flags } = new RegExp(cleaned, matchedFlags)\n\n if (func === null) return `/${source}/${flags}`\n\n return `new ${func}(${JSON.stringify(source)}${flags ? `, ${JSON.stringify(flags)}` : ''})`\n}\n","import { stringify, toRegExpString } from '@internals/utils'\nimport { ast } from '@kubb/core'\nimport type { PluginFaker, ResolverFaker } from '../types.ts'\n\n/**\n * Partial printer nodes for Faker generation, mapping schema types to output strings.\n */\nexport type PrinterFakerNodes = ast.PrinterPartial<string, PrinterFakerOptions>\n\n/**\n * Configuration options for the Faker printer, including resolvers, mappers, and cyclic schema tracking.\n */\nexport type PrinterFakerOptions = {\n dateParser?: PluginFaker['resolvedOptions']['dateParser']\n regexGenerator?: PluginFaker['resolvedOptions']['regexGenerator']\n mapper?: PluginFaker['resolvedOptions']['mapper']\n resolver: ResolverFaker\n typeName?: string\n schemaName?: string\n nestedInObject?: boolean\n nodes?: PrinterFakerNodes\n /**\n * Names of schemas that participate in a circular dependency chain.\n * Properties whose schema transitively references one of these are emitted\n * as lazy getters so that user overrides via the `data` parameter prevent\n * the recursive faker call from ever executing (avoiding stack overflow).\n */\n cyclicSchemas?: ReadonlySet<string>\n}\n\n/**\n * Factory options for the Faker printer, defining input/output types and configuration.\n */\nexport type PrinterFakerFactory = ast.PrinterFactoryOptions<'faker', PrinterFakerOptions, string, string>\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 bigint: () => 'faker.number.bigInt()',\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 null: () => 'null',\n array: (items: string[] = [], min?: number, max?: number) => {\n if (items.length > 1) {\n return `faker.helpers.arrayElements([${items.join(', ')}])`\n }\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\n if (min !== undefined) {\n return `faker.helpers.multiple(() => (${item}), { count: ${min} })`\n }\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 datetime: () => 'faker.date.anytime().toISOString()',\n date: (representation: 'date' | 'string' = 'string', parser: PluginFaker['resolvedOptions']['dateParser'] = 'faker') => {\n if (representation === 'string') {\n if (parser !== 'faker') {\n return `${parser}(faker.date.anytime()).format(\"YYYY-MM-DD\")`\n }\n\n return 'faker.date.anytime().toISOString().substring(0, 10)'\n }\n\n if (parser !== 'faker') {\n throw new Error(`type '${representation}' and parser '${parser}' can not work together`)\n }\n\n return 'faker.date.anytime()'\n },\n time: (representation: 'date' | 'string' = 'string', parser: PluginFaker['resolvedOptions']['dateParser'] = 'faker') => {\n if (representation === 'string') {\n if (parser !== 'faker') {\n return `${parser}(faker.date.anytime()).format(\"HH:mm:ss\")`\n }\n\n return 'faker.date.anytime().toISOString().substring(11, 19)'\n }\n\n if (parser !== 'faker') {\n throw new Error(`type '${representation}' 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[] = []) => {\n if (items.length === 0) {\n return '{}'\n }\n\n if (items.length === 1) {\n return items[0] ?? '{}'\n }\n\n return `{...${items.join(', ...')}}`\n },\n matches: (value = '', regexGenerator: 'faker' | 'randexp' = 'faker') => {\n if (regexGenerator === 'randexp') {\n return `${toRegExpString(value, 'RandExp')}.gen()`\n }\n\n return `faker.helpers.fromRegExp(\"${value}\")`\n },\n email: () => 'faker.internet.email()',\n blob: () => 'faker.image.url() as unknown as Blob',\n} as const\n\nfunction getEnumValues(node: ast.EnumSchemaNode): Array<string | number | boolean | undefined> {\n if (node.namedEnumValues?.length) {\n return node.namedEnumValues.map((item) => item.value as string | number | boolean | undefined)\n }\n\n return (node.enumValues ?? []) as Array<string | number | boolean | undefined>\n}\n\nfunction parseEnumValue(value: string | number | boolean | undefined) {\n if (typeof value === 'string') {\n return stringify(value)\n }\n\n return value\n}\n\n/**\n * Creates a Faker printer that generates mock data generation code from schema nodes.\n * Handles circular references gracefully by emitting memoizing getters for cyclic properties.\n */\nexport const printerFaker: (options: PrinterFakerOptions) => ast.Printer<PrinterFakerFactory> = ast.definePrinter<PrinterFakerFactory>((options) => {\n const printNested = (node: ast.SchemaNode, overrideOptions: Partial<PrinterFakerOptions> = {}): string => {\n return (\n printerFaker({\n ...options,\n ...overrideOptions,\n nodes: options.nodes,\n }).print(node) ?? 'undefined'\n )\n }\n\n return {\n name: 'faker',\n options,\n nodes: {\n any: () => fakerKeywordMapper.any(),\n unknown: () => fakerKeywordMapper.unknown(),\n void: () => fakerKeywordMapper.void(),\n boolean: () => fakerKeywordMapper.boolean(),\n null: () => fakerKeywordMapper.null(),\n string(node) {\n if (node.pattern) {\n return fakerKeywordMapper.matches(node.pattern, this.options.regexGenerator)\n }\n\n return fakerKeywordMapper.string(node.min, node.max)\n },\n email: () => fakerKeywordMapper.email(),\n url: () => fakerKeywordMapper.url(),\n uuid: () => fakerKeywordMapper.uuid(),\n number(node) {\n return fakerKeywordMapper.number(node.min, node.max)\n },\n integer(node) {\n return fakerKeywordMapper.integer(node.min, node.max)\n },\n bigint: () => fakerKeywordMapper.bigint(),\n blob: () => fakerKeywordMapper.blob(),\n datetime: () => fakerKeywordMapper.datetime(),\n date(node) {\n return fakerKeywordMapper.date(node.representation ?? 'string', this.options.dateParser)\n },\n time(node) {\n return fakerKeywordMapper.time(node.representation ?? 'string', this.options.dateParser)\n },\n ref(node) {\n // Parser-generated refs (with $ref) carry raw schema names that need resolving.\n // Use the canonical name from the $ref path — node.name may have been overridden\n // (e.g. by single-member allOf flatten using the property-derived child name).\n // Inline refs (without $ref) from faker utils already carry resolved helper names.\n const refName = node.ref ? (ast.extractRefName(node.ref) ?? node.name ?? node.schema?.name) : (node.name ?? node.schema?.name)\n\n if (!refName) {\n throw new Error('Name not defined for ref node')\n }\n\n if (this.options.schemaName && refName === this.options.schemaName) {\n return 'undefined as any'\n }\n\n // Internal helper refs (for generated response/data helpers) are already\n // emitted with resolver output and should not be transformed twice.\n const resolvedName = node.ref ? this.options.resolver.resolveName(refName) : refName\n\n if (!this.options.nestedInObject) {\n return `${resolvedName}(data)`\n }\n\n return `${resolvedName}()`\n },\n enum(node) {\n return fakerKeywordMapper.enum(getEnumValues(node).map(parseEnumValue), this.options.typeName)\n },\n union(node): string {\n const items: string[] = (node.members ?? [])\n .map((member) =>\n printNested(member, {\n nestedInObject: true,\n }),\n )\n .filter((item): item is string => Boolean(item))\n\n return fakerKeywordMapper.union(items)\n },\n intersection(node): string {\n const items: string[] = (node.members ?? [])\n .map((member) =>\n printNested(member, {\n nestedInObject: true,\n }),\n )\n .filter((item): item is string => Boolean(item))\n\n return fakerKeywordMapper.and(items)\n },\n array(node): string {\n const items: string[] = (node.items ?? [])\n .map((member) =>\n printNested(member, {\n typeName: this.options.typeName ? `NonNullable<${this.options.typeName}>[number]` : undefined,\n nestedInObject: true,\n }),\n )\n .filter((item): item is string => Boolean(item))\n\n return fakerKeywordMapper.array(items, node.min, node.max)\n },\n tuple(node): string {\n const items: string[] = (node.items ?? [])\n .map((member, index) =>\n printNested(member, {\n typeName: this.options.typeName ? `NonNullable<${this.options.typeName}>[${index}]` : undefined,\n nestedInObject: true,\n }),\n )\n .filter((item): item is string => Boolean(item))\n\n return fakerKeywordMapper.tuple(items)\n },\n object(node): string {\n const cyclicSchemas = this.options.cyclicSchemas\n const properties = (node.properties ?? [])\n .map((property): string => {\n if (this.options.mapper && Object.hasOwn(this.options.mapper, property.name)) {\n return `\"${property.name}\": ${this.options.mapper[property.name]}`\n }\n\n const value: string =\n printNested(property.schema, {\n typeName: this.options.typeName ? `NonNullable<${this.options.typeName}>[${JSON.stringify(property.name)}]` : undefined,\n nestedInObject: true,\n }) ?? 'undefined'\n\n // When the property's schema transitively references a schema that is\n // part of a circular dependency (other than the current schema itself),\n // emit a memoizing lazy getter. On first access it computes the value,\n // replaces itself with a plain data property via Object.defineProperty,\n // and returns the cached value – so every subsequent read is stable.\n if (cyclicSchemas && ast.containsCircularRef(property.schema, { circularSchemas: cyclicSchemas, excludeName: this.options.schemaName })) {\n return `get ${property.name}() { const _value = ${value}; Object.defineProperty(this, ${JSON.stringify(property.name)}, { value: _value, configurable: true, writable: true, enumerable: true }); return _value }`\n }\n\n return `\"${property.name}\": ${value}`\n })\n .join(',')\n\n return `{${properties}}`\n },\n ...options.nodes,\n },\n print(node) {\n return this.transform(node) ?? null\n },\n }\n})\n","import { ast, defineGenerator } from '@kubb/core'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { File, jsxRenderer } from '@kubb/renderer-jsx'\nimport { Faker } from '../components/Faker.tsx'\nimport { printerFaker } from '../printers/printerFaker.ts'\nimport type { PluginFaker } from '../types.ts'\nimport {\n aliasConflictingImports,\n buildResponseUnionSchema,\n canOverrideSchema,\n filterUsedImports,\n localeToFakerImport,\n resolveParamNameByLocation,\n resolveSchemaRef,\n resolveTypeReference,\n rewriteAliasedImports,\n} from '../utils.ts'\n\nexport const fakerGenerator = defineGenerator<PluginFaker>({\n name: 'faker',\n renderer: jsxRenderer,\n schema(node, ctx) {\n const { adapter, config, resolver, root } = ctx\n const { output, group, dateParser, regexGenerator, mapper, seed, locale, printer } = ctx.options\n const pluginTs = ctx.driver.getPlugin(pluginTsName)\n\n if (!node.name || !pluginTs || !adapter.inputNode) {\n return\n }\n\n const tsResolver = ctx.driver.getResolver(pluginTsName)\n\n const schemaNode = resolveSchemaRef(node, adapter.inputNode.schemas)\n const schemaName = schemaNode.name ?? node.name\n const mode = ctx.getMode(output)\n const meta = {\n name: resolver.resolveName(schemaName),\n file: resolver.resolveFile({ name: schemaName, extname: '.ts' }, { root, output, group }),\n typeName: tsResolver.resolveTypeName(schemaName),\n typeFile: tsResolver.resolveFile(\n { name: schemaName, extname: '.ts' },\n { root, output: pluginTs.options?.output ?? output, group: pluginTs.options?.group },\n ),\n } as const\n const canOverride = canOverrideSchema(schemaNode)\n const cyclicSchemas = adapter.inputNode ? ast.findCircularSchemas(adapter.inputNode.schemas) : undefined\n const printerInstance = printerFaker({\n resolver,\n schemaName,\n typeName: meta.typeName,\n dateParser,\n regexGenerator,\n mapper,\n nodes: printer?.nodes,\n cyclicSchemas,\n })\n const fakerText = printerInstance.print(schemaNode) ?? 'undefined'\n const typeReference = resolveTypeReference({\n node: schemaNode,\n canOverride,\n name: meta.name,\n typeName: meta.typeName,\n filePath: meta.file.path,\n typeFilePath: meta.typeFile.path,\n })\n\n const imports = adapter\n .getImports(schemaNode, (schemaName) => ({\n name: resolver.resolveName(schemaName),\n path: resolver.resolveFile({ name: schemaName, extname: '.ts' }, { root, output, group }).path,\n }))\n .filter((entry) => entry.path !== meta.file.path)\n const usedImports = filterUsedImports(imports, fakerText)\n\n return (\n <File\n baseName={meta.file.baseName}\n path={meta.file.path}\n meta={meta.file.meta}\n banner={resolver.resolveBanner(adapter.inputNode, { output, config })}\n footer={resolver.resolveFooter(adapter.inputNode, { output, config })}\n >\n <File.Import name={locale ? [{ propertyName: localeToFakerImport(locale), name: 'faker' }] : ['faker']} path=\"@faker-js/faker\" />\n {regexGenerator === 'randexp' && <File.Import name={'RandExp'} path={'randexp'} />}\n {dateParser !== 'faker' && <File.Import path={dateParser} name={dateParser} />}\n {typeReference.importPath && <File.Import isTypeOnly root={meta.file.path} path={typeReference.importPath} name={[meta.typeName]} />}\n {mode === 'split' &&\n usedImports.map((imp) => <File.Import key={[schemaName, imp.path, imp.name].join('-')} root={meta.file.path} path={imp.path} name={imp.name} />)}\n <Faker\n name={meta.name}\n typeName={typeReference.typeName}\n description={schemaNode.description}\n node={schemaNode}\n printer={printerInstance}\n seed={seed}\n canOverride={canOverride}\n />\n </File>\n )\n },\n operation(node, ctx) {\n const { adapter, config, resolver, root } = ctx\n const { output, group, paramsCasing, dateParser, regexGenerator, mapper, seed, locale, printer } = ctx.options\n const pluginTs = ctx.driver.getPlugin(pluginTsName)\n\n if (!pluginTs) {\n return\n }\n\n const tsResolver = ctx.driver.getResolver(pluginTsName)\n\n const params = ast.caseParams(node.parameters, paramsCasing)\n const paramEntries = params.map((param) => ({\n param,\n name: resolveParamNameByLocation(resolver, node, param),\n typeName: resolveParamNameByLocation(tsResolver, node, param),\n }))\n const responseEntries = node.responses.map((response) => ({\n response,\n name: resolver.resolveResponseStatusName(node, response.statusCode),\n typeName: tsResolver.resolveResponseStatusName(node, response.statusCode),\n }))\n const dataEntry = node.requestBody?.content?.[0]?.schema\n ? {\n schema: {\n ...node.requestBody.content![0]!.schema!,\n description: node.requestBody.description ?? node.requestBody.content![0]!.schema!.description,\n },\n name: resolver.resolveDataName(node),\n typeName: tsResolver.resolveDataName(node),\n description: node.requestBody.description ?? node.requestBody.content![0]!.schema!.description,\n }\n : null\n const responseName = resolver.resolveResponseName(node)\n const localHelperNames = new Set([\n ...paramEntries.map((entry) => entry.name),\n ...responseEntries.map((entry) => entry.name),\n ...(dataEntry ? [dataEntry.name] : []),\n responseName,\n ])\n const meta = {\n file: resolver.resolveFile({ name: node.operationId, extname: '.ts', tag: node.tags[0] ?? 'default', path: node.path }, { root, output, group }),\n typeFile: tsResolver.resolveFile(\n {\n name: node.operationId,\n extname: '.ts',\n tag: node.tags[0] ?? 'default',\n path: node.path,\n },\n {\n root,\n output: pluginTs.options?.output ?? output,\n group: pluginTs.options?.group,\n },\n ),\n } as const\n\n function resolveMockImports(schema: ast.SchemaNode) {\n return adapter\n .getImports(schema, (schemaName) => ({\n name: resolver.resolveName(schemaName),\n path: resolver.resolveFile({ name: schemaName, extname: '.ts' }, { root, output, group }).path,\n }))\n .filter((entry) => entry.path !== meta.file.path)\n }\n\n function renderEntry({\n schema,\n name,\n typeName,\n description,\n skipImportNames = [],\n }: {\n schema: ast.SchemaNode | null\n name: string\n typeName: string\n description?: string\n skipImportNames?: Array<string>\n }) {\n if (!schema) {\n return null\n }\n\n const canOverride = canOverrideSchema(schema)\n const cyclicSchemas = adapter.inputNode ? ast.findCircularSchemas(adapter.inputNode.schemas) : undefined\n const printerInstance = printerFaker({\n resolver,\n schemaName: name,\n typeName,\n dateParser,\n regexGenerator,\n mapper,\n nodes: printer?.nodes,\n cyclicSchemas,\n })\n const fakerText = printerInstance.print(schema) ?? 'undefined'\n const usedImports = filterUsedImports(resolveMockImports(schema), fakerText, skipImportNames)\n const { imports, aliases } = aliasConflictingImports(usedImports, localHelperNames)\n const rewrittenFakerText = rewriteAliasedImports(fakerText, aliases)\n const typeReference = resolveTypeReference({\n node: schema,\n canOverride,\n name,\n typeName,\n filePath: meta.file.path,\n typeFilePath: meta.typeFile.path,\n })\n\n return (\n <>\n {typeReference.importPath && <File.Import isTypeOnly root={meta.file.path} path={typeReference.importPath} name={[typeName]} />}\n {imports.map((imp) => (\n <File.Import key={[name, imp.path, imp.name].join('-')} root={meta.file.path} path={imp.path} name={imp.name} />\n ))}\n <Faker\n name={name}\n typeName={typeReference.typeName}\n description={description}\n node={schema}\n printer={{ ...printerInstance, print: () => rewrittenFakerText }}\n seed={seed}\n canOverride={canOverride}\n />\n </>\n )\n }\n\n return (\n <File\n baseName={meta.file.baseName}\n path={meta.file.path}\n meta={meta.file.meta}\n banner={resolver.resolveBanner(adapter.inputNode, { output, config })}\n footer={resolver.resolveFooter(adapter.inputNode, { output, config })}\n >\n <File.Import name={locale ? [{ propertyName: localeToFakerImport(locale), name: 'faker' }] : ['faker']} path=\"@faker-js/faker\" />\n {regexGenerator === 'randexp' && <File.Import name={'RandExp'} path={'randexp'} />}\n {dateParser !== 'faker' && <File.Import path={dateParser} name={dateParser} />}\n {paramEntries.map(({ param, name, typeName }) =>\n renderEntry({\n schema: param.schema,\n name,\n typeName,\n }),\n )}\n {responseEntries.map(({ response, name, typeName }) =>\n renderEntry({\n schema: response.schema,\n name,\n typeName,\n description: response.description,\n }),\n )}\n {dataEntry\n ? renderEntry({\n schema: dataEntry.schema,\n name: dataEntry.name,\n typeName: dataEntry.typeName,\n description: dataEntry.description,\n })\n : null}\n {renderEntry({\n schema: buildResponseUnionSchema(node, resolver),\n name: responseName,\n typeName: tsResolver.resolveResponseName(node),\n skipImportNames: responseEntries.map(({ name }) => name),\n })}\n </File>\n )\n },\n})\n"],"mappings":";;;;;;;;;;;;;AASA,SAAgB,UAAU,OAAsD;AAC9E,KAAI,UAAU,KAAA,KAAa,UAAU,KAAM,QAAO;AAClD,QAAO,KAAK,UAAUA,cAAAA,WAAW,MAAM,UAAU,CAAC,CAAC;;;;;;;;;;;;;ACArD,SAAgB,eAAe,MAAc,OAAsB,UAAkB;CACnF,MAAM,MAAMC,cAAAA,WAAW,KAAK;CAE5B,MAAM,QAAQ,IAAI,MAAM,0BAA0B;CAClD,MAAM,oBAAoB,QAAQ,MAAM;CACxC,MAAM,eAAe,QAAQ;CAC7B,MAAM,UAAU,IACb,QAAQ,UAAU,GAAG,CACrB,QAAQ,UAAU,GAAG,CACrB,QAAQ,mBAAmB,GAAG;CAEjC,MAAM,EAAE,QAAQ,UAAU,IAAI,OAAO,SAAS,aAAa;AAE3D,KAAI,SAAS,KAAM,QAAO,IAAI,OAAO,GAAG;AAExC,QAAO,OAAO,KAAK,GAAG,KAAK,UAAU,OAAO,GAAG,QAAQ,KAAK,KAAK,UAAU,MAAM,KAAK,GAAG;;;;ACS3F,MAAM,qBAAqB;CACzB,WAAW;CACX,eAAe;CACf,YAAY;CACZ,SAAS,KAAc,QAAiB;AACtC,MAAI,QAAQ,KAAA,KAAa,QAAQ,KAAA,EAC/B,QAAO,6BAA6B,IAAI,SAAS,IAAI;AAGvD,MAAI,QAAQ,KAAA,EACV,QAAO,6BAA6B,IAAI;AAG1C,MAAI,QAAQ,KAAA,EACV,QAAO,6BAA6B,IAAI;AAG1C,SAAO;;CAET,UAAU,KAAc,QAAiB;AACvC,MAAI,QAAQ,KAAA,KAAa,QAAQ,KAAA,EAC/B,QAAO,2BAA2B,IAAI,SAAS,IAAI;AAGrD,MAAI,QAAQ,KAAA,EACV,QAAO,2BAA2B,IAAI;AAGxC,MAAI,QAAQ,KAAA,EACV,Q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;IAAQ,CAAC;aALvE;IAOE,iBAAA,GAAA,+BAAA,KAACA,mBAAAA,KAAK,QAAN;KAAa,MAAM,SAAS,CAAC;MAAE,cAAcC,cAAAA,oBAAoB,OAAO;MAAE,MAAM;MAAS,CAAC,GAAG,CAAC,QAAQ;KAAE,MAAK;KAAoB,CAAA;IAChI,mBAAmB,aAAa,iBAAA,GAAA,+BAAA,KAACD,mBAAAA,KAAK,QAAN;KAAa,MAAM;KAAW,MAAM;KAAa,CAAA;IACjF,eAAe,WAAW,iBAAA,GAAA,+BAAA,KAACA,mBAAAA,KAAK,QAAN;KAAa,MAAM;KAAY,MAAM;KAAc,CAAA;IAC7E,aAAa,KAAK,EAAE,OAAO,MAAM,eAChC,YAAY;KACV,QAAQ,MAAM;KACd;KACA;KACD,CAAC,CACH;IACA,gBAAgB,KAAK,EAAE,UAAU,MAAM,eACtC,YAAY;KACV,QAAQ,SAAS;KACjB;KACA;KACA,aAAa,SAAS;KACvB,CAAC,CACH;IACA,YACG,YAAY;KACV,QAAQ,UAAU;KAClB,MAAM,UAAU;KAChB,UAAU,UAAU;KACpB,aAAa,UAAU;KACxB,CAAC,GACF;IACH,YAAY;KACX,QAAQM,cAAAA,yBAAyB,MAAM,SAAS;KAChD,MAAM;KACN,UAAU,WAAW,oBAAoB,KAAK;KAC9C,iBAAiB,gBAAgB,KAAK,EAAE,WAAW,KAAK;KACzD,CAAC;IACG;;;CAGZ,CAAC"}
|
package/extension.yaml
DELETED
|
@@ -1,364 +0,0 @@
|
|
|
1
|
-
$schema: https://kubb.dev/schemas/extension.json
|
|
2
|
-
kind: plugin
|
|
3
|
-
id: plugin-faker
|
|
4
|
-
name: Faker
|
|
5
|
-
description: Generate realistic mock data using Faker.js from OpenAPI specifications.
|
|
6
|
-
category: mocks
|
|
7
|
-
type: official
|
|
8
|
-
npmPackage: "@kubb/plugin-faker"
|
|
9
|
-
docsPath: /plugins/plugin-faker
|
|
10
|
-
repo: https://github.com/kubb-labs/plugins
|
|
11
|
-
maintainers:
|
|
12
|
-
- name: Stijn Van Hulle
|
|
13
|
-
github: stijnvanhulle
|
|
14
|
-
compatibility:
|
|
15
|
-
kubb: ">=5.0.0"
|
|
16
|
-
node: ">=22"
|
|
17
|
-
tags:
|
|
18
|
-
- faker
|
|
19
|
-
- mock-data
|
|
20
|
-
- mocks
|
|
21
|
-
- fixtures
|
|
22
|
-
- testing
|
|
23
|
-
- codegen
|
|
24
|
-
- openapi
|
|
25
|
-
dependencies:
|
|
26
|
-
- plugin-ts
|
|
27
|
-
resources:
|
|
28
|
-
documentation: https://kubb.dev/plugins/plugin-faker
|
|
29
|
-
repository: https://github.com/kubb-labs/plugins
|
|
30
|
-
issues: https://github.com/kubb-labs/plugins/issues
|
|
31
|
-
changelog: https://github.com/kubb-labs/plugins/blob/main/packages/plugin-faker/CHANGELOG.md
|
|
32
|
-
codesandbox: https://codesandbox.io/p/github/kubb-labs/plugins/main/examples/faker
|
|
33
|
-
featured: false
|
|
34
|
-
icon:
|
|
35
|
-
light: https://kubb.dev/feature/faker.svg
|
|
36
|
-
intro: |
|
|
37
|
-
# @kubb/plugin-faker
|
|
38
|
-
|
|
39
|
-
Generate mock data factories from your OpenAPI schema using [Faker.js](https://fakerjs.dev/). Create realistic test data that matches your API's types.
|
|
40
|
-
options:
|
|
41
|
-
- name: output
|
|
42
|
-
type: Output
|
|
43
|
-
required: false
|
|
44
|
-
default: "{ path: 'mocks', barrelType: 'named' }"
|
|
45
|
-
description: Specify the export location for the files and define the behavior of the output.
|
|
46
|
-
properties:
|
|
47
|
-
- name: path
|
|
48
|
-
type: string
|
|
49
|
-
required: true
|
|
50
|
-
description: Output directory or file for the generated code, relative to the global `output.path`.
|
|
51
|
-
tip: |
|
|
52
|
-
if `output.path` is a file, `group` cannot be used.
|
|
53
|
-
default: "'mocks'"
|
|
54
|
-
- name: barrelType
|
|
55
|
-
type: "'all' | 'named' | 'propagate' | false"
|
|
56
|
-
required: false
|
|
57
|
-
default: "'named'"
|
|
58
|
-
description: Specify what to export and optionally disable barrel-file generation.
|
|
59
|
-
tip: |
|
|
60
|
-
Using `propagate` will prevent a plugin from creating a barrel file, but it will still propagate, allowing [`output.barrelType`](https://kubb.dev/docs/5.x/configuration#output-barreltype) to export the specific function or type.
|
|
61
|
-
examples:
|
|
62
|
-
- name: all
|
|
63
|
-
files:
|
|
64
|
-
- lang: typescript
|
|
65
|
-
code: |
|
|
66
|
-
export * from './gen/petService.ts'
|
|
67
|
-
twoslash: false
|
|
68
|
-
- name: named
|
|
69
|
-
files:
|
|
70
|
-
- lang: typescript
|
|
71
|
-
code: |
|
|
72
|
-
export { PetService } from './gen/petService.ts'
|
|
73
|
-
twoslash: false
|
|
74
|
-
- name: propagate
|
|
75
|
-
files:
|
|
76
|
-
- lang: typescript
|
|
77
|
-
code: ""
|
|
78
|
-
twoslash: false
|
|
79
|
-
- name: "false"
|
|
80
|
-
files:
|
|
81
|
-
- lang: typescript
|
|
82
|
-
code: ""
|
|
83
|
-
twoslash: false
|
|
84
|
-
- name: banner
|
|
85
|
-
type: "string | ((node: RootNode) => string)"
|
|
86
|
-
required: false
|
|
87
|
-
description: Add a banner comment at the top of every generated file. Accepts a static string or a function that receives the `RootNode` and returns a string.
|
|
88
|
-
- name: footer
|
|
89
|
-
type: "string | ((node: RootNode) => string)"
|
|
90
|
-
required: false
|
|
91
|
-
description: Add a footer comment at the end of every generated file. Accepts a static string or a function that receives the `RootNode` and returns a string.
|
|
92
|
-
- name: override
|
|
93
|
-
type: boolean
|
|
94
|
-
required: false
|
|
95
|
-
default: "false"
|
|
96
|
-
description: Whether Kubb overrides existing external files that can be generated if they already exist.
|
|
97
|
-
- name: group
|
|
98
|
-
type: Group
|
|
99
|
-
required: false
|
|
100
|
-
description: |
|
|
101
|
-
Grouping combines files in a folder based on a specific `type`.
|
|
102
|
-
examples:
|
|
103
|
-
- name: kubb.config.ts
|
|
104
|
-
files:
|
|
105
|
-
- lang: typescript
|
|
106
|
-
code: |
|
|
107
|
-
group: {
|
|
108
|
-
type: 'tag',
|
|
109
|
-
name({ group }) {
|
|
110
|
-
return `${group}Controller`
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
twoslash: false
|
|
114
|
-
body: |
|
|
115
|
-
With the configuration above, the generator emits:
|
|
116
|
-
|
|
117
|
-
```text
|
|
118
|
-
.
|
|
119
|
-
├── src/
|
|
120
|
-
│ └── petController/
|
|
121
|
-
│ │ ├── addPet.ts
|
|
122
|
-
│ │ └── getPet.ts
|
|
123
|
-
│ └── storeController/
|
|
124
|
-
│ ├── createStore.ts
|
|
125
|
-
│ └── getStoreById.ts
|
|
126
|
-
├── petStore.yaml
|
|
127
|
-
├── kubb.config.ts
|
|
128
|
-
└── package.json
|
|
129
|
-
```
|
|
130
|
-
properties:
|
|
131
|
-
- name: type
|
|
132
|
-
type: "'tag'"
|
|
133
|
-
required: true
|
|
134
|
-
description: Specify the property to group files by. Required when `group` is defined.
|
|
135
|
-
note: |
|
|
136
|
-
`Required: true*` means this is required only when the `group` option is used. The `group` option itself is optional.
|
|
137
|
-
body: |
|
|
138
|
-
- `'tag'`: Uses the first tag from `operation.getTags().at(0)?.name`
|
|
139
|
-
- name: name
|
|
140
|
-
type: "(context: GroupContext) => string"
|
|
141
|
-
required: false
|
|
142
|
-
default: (ctx) => `${ctx.group}Controller`
|
|
143
|
-
description: Return the name of a group based on the group name. This is used for file and helper name generation.
|
|
144
|
-
- name: dateParser
|
|
145
|
-
type: "'faker' | 'dayjs' | 'moment' | string"
|
|
146
|
-
required: false
|
|
147
|
-
default: "'faker'"
|
|
148
|
-
description: Choose which formatter to use for `date`, `time`, or `datetime` fields represented as strings.
|
|
149
|
-
tip: |
|
|
150
|
-
You can use another library that exposes a default export. Kubb adds the import automatically.
|
|
151
|
-
examples:
|
|
152
|
-
- name: "'faker'"
|
|
153
|
-
files:
|
|
154
|
-
- lang: ts
|
|
155
|
-
code: |
|
|
156
|
-
faker.date.anytime().toISOString().substring(0, 10)
|
|
157
|
-
- name: "'dayjs'"
|
|
158
|
-
files:
|
|
159
|
-
- lang: ts
|
|
160
|
-
code: |
|
|
161
|
-
dayjs(faker.date.anytime()).format('YYYY-MM-DD')
|
|
162
|
-
- name: "'moment'"
|
|
163
|
-
files:
|
|
164
|
-
- lang: ts
|
|
165
|
-
code: |
|
|
166
|
-
moment(faker.date.anytime()).format('YYYY-MM-DD')
|
|
167
|
-
- name: mapper
|
|
168
|
-
type: Record<string, string>
|
|
169
|
-
required: false
|
|
170
|
-
description: Override individual properties with custom Faker expressions.
|
|
171
|
-
- name: paramsCasing
|
|
172
|
-
type: "'camelcase'"
|
|
173
|
-
required: false
|
|
174
|
-
description: Transform parameter property names in generated mocks for path, query, and headers.
|
|
175
|
-
important: |
|
|
176
|
-
Use the same `paramsCasing` value in `@kubb/plugin-ts` so the generated mock objects stay compatible with the generated types.
|
|
177
|
-
- name: regexGenerator
|
|
178
|
-
type: "'faker' | 'randexp'"
|
|
179
|
-
required: false
|
|
180
|
-
default: "'faker'"
|
|
181
|
-
description: Generate strings from regex patterns using Faker or randexp.
|
|
182
|
-
examples:
|
|
183
|
-
- name: "'faker'"
|
|
184
|
-
files:
|
|
185
|
-
- lang: ts
|
|
186
|
-
code: |
|
|
187
|
-
faker.helpers.fromRegExp('^[A-Z]+$')
|
|
188
|
-
- name: "'randexp'"
|
|
189
|
-
files:
|
|
190
|
-
- lang: ts
|
|
191
|
-
code: |
|
|
192
|
-
new RandExp(/^[A-Z]+$/).gen()
|
|
193
|
-
- name: seed
|
|
194
|
-
type: number | number[]
|
|
195
|
-
required: false
|
|
196
|
-
description: Seed faker for deterministic output.
|
|
197
|
-
- name: locale
|
|
198
|
-
type: string
|
|
199
|
-
required: false
|
|
200
|
-
default: "'en'"
|
|
201
|
-
description: Generate mock data using a locale-specific Faker instance.
|
|
202
|
-
tip: |
|
|
203
|
-
See the [Faker.js localization docs](https://fakerjs.dev/api/localization.html) for the full list of supported locales.
|
|
204
|
-
examples:
|
|
205
|
-
- name: "'de'"
|
|
206
|
-
files:
|
|
207
|
-
- lang: ts
|
|
208
|
-
code: |
|
|
209
|
-
import { fakerDE as faker } from '@faker-js/faker'
|
|
210
|
-
- name: "'de_AT'"
|
|
211
|
-
files:
|
|
212
|
-
- lang: ts
|
|
213
|
-
code: |
|
|
214
|
-
import { fakerDE_AT as faker } from '@faker-js/faker'
|
|
215
|
-
- name: include
|
|
216
|
-
type: Array<Include>
|
|
217
|
-
required: false
|
|
218
|
-
description: Array containing include parameters to include tags, operations, methods, paths, or content types.
|
|
219
|
-
codeBlock:
|
|
220
|
-
lang: typescript
|
|
221
|
-
title: Include
|
|
222
|
-
code: |
|
|
223
|
-
export type Include = {
|
|
224
|
-
type: 'tag' | 'operationId' | 'path' | 'method' | 'contentType'
|
|
225
|
-
pattern: string | RegExp
|
|
226
|
-
}
|
|
227
|
-
- name: exclude
|
|
228
|
-
type: Array<Exclude>
|
|
229
|
-
required: false
|
|
230
|
-
description: Array containing exclude parameters to exclude or skip tags, operations, methods, paths, or content types.
|
|
231
|
-
codeBlock:
|
|
232
|
-
lang: typescript
|
|
233
|
-
title: Exclude
|
|
234
|
-
code: |
|
|
235
|
-
export type Exclude = {
|
|
236
|
-
type: 'tag' | 'operationId' | 'path' | 'method' | 'contentType'
|
|
237
|
-
pattern: string | RegExp
|
|
238
|
-
}
|
|
239
|
-
- name: override
|
|
240
|
-
type: Array<Override>
|
|
241
|
-
required: false
|
|
242
|
-
description: Array containing override parameters to override `options` based on tags, operations, methods, paths, or content types.
|
|
243
|
-
codeBlock:
|
|
244
|
-
lang: typescript
|
|
245
|
-
title: Override
|
|
246
|
-
code: |
|
|
247
|
-
export type Override = {
|
|
248
|
-
type: 'tag' | 'operationId' | 'path' | 'method' | 'contentType'
|
|
249
|
-
pattern: string | RegExp
|
|
250
|
-
options: PluginOptions
|
|
251
|
-
}
|
|
252
|
-
- name: generators
|
|
253
|
-
type: Array<Generator<PluginFaker>>
|
|
254
|
-
required: false
|
|
255
|
-
experimental: true
|
|
256
|
-
description: |
|
|
257
|
-
Define additional generators next to the built-in generators.
|
|
258
|
-
|
|
259
|
-
See [Generators](https://kubb.dev/docs/5.x/guides/creating-plugins) for more information on how to use generators.
|
|
260
|
-
- name: resolver
|
|
261
|
-
type: Partial<ResolverFaker>
|
|
262
|
-
required: false
|
|
263
|
-
description: Customize helper naming on top of the active compatibility preset.
|
|
264
|
-
codeBlock:
|
|
265
|
-
lang: typescript
|
|
266
|
-
code: |
|
|
267
|
-
pluginFaker({
|
|
268
|
-
resolver: {
|
|
269
|
-
resolveName(name) {
|
|
270
|
-
return `${this.default(name)}Mock`
|
|
271
|
-
},
|
|
272
|
-
},
|
|
273
|
-
})
|
|
274
|
-
- name: transformer
|
|
275
|
-
type: ast.Visitor
|
|
276
|
-
required: false
|
|
277
|
-
description: Apply a single AST visitor before the faker helpers are rendered.
|
|
278
|
-
codeBlock:
|
|
279
|
-
lang: typescript
|
|
280
|
-
code: |
|
|
281
|
-
pluginFaker({
|
|
282
|
-
transformer: {
|
|
283
|
-
schema(node) {
|
|
284
|
-
return { ...node, description: undefined }
|
|
285
|
-
},
|
|
286
|
-
},
|
|
287
|
-
})
|
|
288
|
-
- name: printer
|
|
289
|
-
type: "{ nodes?: PrinterFakerNodes }"
|
|
290
|
-
required: false
|
|
291
|
-
description: |
|
|
292
|
-
Override individual printer node handlers to customize how specific schema types are rendered.
|
|
293
|
-
|
|
294
|
-
Each key is a `SchemaType` (for example `'integer'`, `'date'`, or `'ref'`). The function you provide replaces the built-in handler for that type. Use `this.transform` to recurse into nested schema nodes and `this.options` to read printer options.
|
|
295
|
-
examples:
|
|
296
|
-
- name: Override integer to float()
|
|
297
|
-
files:
|
|
298
|
-
- lang: typescript
|
|
299
|
-
code: |
|
|
300
|
-
import { pluginFaker } from '@kubb/plugin-faker'
|
|
301
|
-
|
|
302
|
-
pluginFaker({
|
|
303
|
-
printer: {
|
|
304
|
-
nodes: {
|
|
305
|
-
integer() {
|
|
306
|
-
return 'faker.number.float()'
|
|
307
|
-
},
|
|
308
|
-
},
|
|
309
|
-
},
|
|
310
|
-
})
|
|
311
|
-
twoslash: false
|
|
312
|
-
- name: Override date strings
|
|
313
|
-
files:
|
|
314
|
-
- lang: typescript
|
|
315
|
-
code: |
|
|
316
|
-
import { pluginFaker } from '@kubb/plugin-faker'
|
|
317
|
-
|
|
318
|
-
pluginFaker({
|
|
319
|
-
printer: {
|
|
320
|
-
nodes: {
|
|
321
|
-
date(node) {
|
|
322
|
-
if (node.representation === 'string') {
|
|
323
|
-
return 'new Date().toISOString().substring(0, 10)'
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
return 'new Date()'
|
|
327
|
-
},
|
|
328
|
-
},
|
|
329
|
-
},
|
|
330
|
-
})
|
|
331
|
-
twoslash: false
|
|
332
|
-
examples:
|
|
333
|
-
- name: kubb.config.ts
|
|
334
|
-
files:
|
|
335
|
-
- lang: typescript
|
|
336
|
-
code: |
|
|
337
|
-
import { defineConfig } from 'kubb'
|
|
338
|
-
import { pluginFaker } from '@kubb/plugin-faker'
|
|
339
|
-
import { pluginTs } from '@kubb/plugin-ts'
|
|
340
|
-
|
|
341
|
-
export default defineConfig({
|
|
342
|
-
input: {
|
|
343
|
-
path: './petStore.yaml',
|
|
344
|
-
},
|
|
345
|
-
output: {
|
|
346
|
-
path: './src/gen',
|
|
347
|
-
},
|
|
348
|
-
plugins: [
|
|
349
|
-
pluginTs({
|
|
350
|
-
output: {
|
|
351
|
-
path: './types',
|
|
352
|
-
},
|
|
353
|
-
}),
|
|
354
|
-
pluginFaker({
|
|
355
|
-
output: {
|
|
356
|
-
path: './mocks',
|
|
357
|
-
barrelType: 'named',
|
|
358
|
-
},
|
|
359
|
-
seed: [100],
|
|
360
|
-
paramsCasing: 'camelcase',
|
|
361
|
-
}),
|
|
362
|
-
],
|
|
363
|
-
})
|
|
364
|
-
twoslash: false
|
|
File without changes
|