@kubb/plugin-ts 5.0.0-alpha.2 → 5.0.0-alpha.3
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-LmqJfxMv.js → components-CRjwjdyE.js} +8 -4
- package/dist/components-CRjwjdyE.js.map +1 -0
- package/dist/{components-9wydyqUx.cjs → components-DI0aTIBg.cjs} +133 -3
- package/dist/components-DI0aTIBg.cjs.map +1 -0
- package/dist/components.cjs +1 -1
- package/dist/components.js +1 -1
- package/dist/generators.cjs +3 -2
- package/dist/generators.d.ts +11 -5
- package/dist/generators.js +2 -2
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/plugin-D5rCK1zO.cjs +992 -0
- package/dist/plugin-D5rCK1zO.cjs.map +1 -0
- package/dist/plugin-DmwgRHK8.js +944 -0
- package/dist/plugin-DmwgRHK8.js.map +1 -0
- package/package.json +5 -5
- package/src/components/v2/Type.tsx +165 -0
- package/src/factory.ts +2 -0
- package/src/generators/index.ts +1 -0
- package/src/generators/typeGenerator.tsx +1 -0
- package/src/generators/v2/typeGenerator.tsx +196 -0
- package/src/plugin.ts +31 -7
- package/src/printer.ts +24 -1
- package/dist/components-9wydyqUx.cjs.map +0 -1
- package/dist/components-LmqJfxMv.js.map +0 -1
- package/dist/plugin-CNkzbtpl.cjs +0 -508
- package/dist/plugin-CNkzbtpl.cjs.map +0 -1
- package/dist/plugin-DoLrDl9P.js +0 -476
- package/dist/plugin-DoLrDl9P.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-DmwgRHK8.js","names":["factory.createUnionDeclaration","factory.createTypeReferenceNode","factory.createIdentifier","factory.createTypeAliasDeclaration","factory.createTypeLiteralNode","factory.createPropertySignature","factory.createIndexedAccessTypeNode","factory.createTypeOperatorNode","typeGenerator","Type","factory.createLiteralTypeNode","factory.createTrue","factory.createFalse","factory.createPrefixUnaryExpression","factory.createNumericLiteral","factory.createStringLiteral","factory.createTypeReferenceNode","factory.createIdentifier","factory.createOptionalTypeNode","factory.createRestTypeNode","factory.createArrayTypeNode","factory.createTupleTypeNode","factory.createUnionDeclaration","factory.createIndexSignature","factory.createIntersectionDeclaration","factory.createTypeLiteralNode","factory.createArrayDeclaration","factory.createPropertySignature","factory.appendJSDocToNode","factory.createTypeReferenceNode","factory.createIdentifier","factory.createArrayTypeNode","factory.createUnionDeclaration","factory.createTypeDeclaration","factory.createOmitDeclaration","factory.createEnumDeclaration","typeGenerator","typeGeneratorV2"],"sources":["../../../internals/utils/src/object.ts","../src/generators/typeGenerator.tsx","../src/printer.ts","../src/components/v2/Type.tsx","../src/generators/v2/typeGenerator.tsx","../src/plugin.ts"],"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 * Serializes plugin options for safe JSON transport.\n * Strips functions, symbols, and `undefined` values recursively.\n */\nexport function serializePluginOptions<TOptions extends object>(options: TOptions): TOptions {\n if (options === null || options === undefined) return {} as TOptions\n if (typeof options !== 'object') return options\n if (Array.isArray(options)) return options.map(serializePluginOptions) as unknown as TOptions\n\n const serialized: Record<string, unknown> = {}\n for (const [key, value] of Object.entries(options)) {\n if (typeof value === 'function' || typeof value === 'symbol' || value === undefined) continue\n serialized[key] = value !== null && typeof value === 'object' ? serializePluginOptions(value as object) : value\n }\n return serialized as TOptions\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 | undefined {\n const parts = Array.isArray(param) ? param : param.split('.')\n if (parts.length === 0 || (parts.length === 1 && parts[0] === '')) return undefined\n return `${accessor}?.['${`${parts.join(\"']?.['\")}']`}`\n}\n","import { pascalCase } from '@internals/utils'\nimport type { PluginManager } from '@kubb/core'\nimport { useMode, usePluginManager } from '@kubb/core/hooks'\nimport { safePrint } from '@kubb/fabric-core/parsers/typescript'\nimport type { Operation } from '@kubb/oas'\nimport { isKeyword, type OperationSchemas, type OperationSchema as OperationSchemaType, SchemaGenerator, schemaKeywords } from '@kubb/plugin-oas'\nimport { createReactGenerator } from '@kubb/plugin-oas/generators'\nimport { useOas, useOperationManager, useSchemaManager } from '@kubb/plugin-oas/hooks'\nimport { applyParamsCasing, getBanner, getFooter, getImports, isParameterSchema } from '@kubb/plugin-oas/utils'\nimport { File } from '@kubb/react-fabric'\nimport ts from 'typescript'\nimport { Type } from '../components'\nimport * as factory from '../factory.ts'\nimport { createUrlTemplateType, getUnknownType, keywordTypeNodes } from '../factory.ts'\nimport { pluginTsName } from '../plugin.ts'\nimport type { PluginTs } from '../types'\n\nfunction printCombinedSchema({ name, schemas, pluginManager }: { name: string; schemas: OperationSchemas; pluginManager: PluginManager }): string {\n const properties: Record<string, ts.TypeNode> = {}\n\n if (schemas.response) {\n properties['response'] = factory.createUnionDeclaration({\n nodes: schemas.responses.map((res) => {\n const identifier = pluginManager.resolveName({\n name: res.name,\n pluginName: pluginTsName,\n type: 'function',\n })\n\n return factory.createTypeReferenceNode(factory.createIdentifier(identifier), undefined)\n }),\n })!\n }\n\n if (schemas.request) {\n const identifier = pluginManager.resolveName({\n name: schemas.request.name,\n pluginName: pluginTsName,\n type: 'function',\n })\n properties['request'] = factory.createTypeReferenceNode(factory.createIdentifier(identifier), undefined)\n }\n\n if (schemas.pathParams) {\n const identifier = pluginManager.resolveName({\n name: schemas.pathParams.name,\n pluginName: pluginTsName,\n type: 'function',\n })\n properties['pathParams'] = factory.createTypeReferenceNode(factory.createIdentifier(identifier), undefined)\n }\n\n if (schemas.queryParams) {\n const identifier = pluginManager.resolveName({\n name: schemas.queryParams.name,\n pluginName: pluginTsName,\n type: 'function',\n })\n properties['queryParams'] = factory.createTypeReferenceNode(factory.createIdentifier(identifier), undefined)\n }\n\n if (schemas.headerParams) {\n const identifier = pluginManager.resolveName({\n name: schemas.headerParams.name,\n pluginName: pluginTsName,\n type: 'function',\n })\n properties['headerParams'] = factory.createTypeReferenceNode(factory.createIdentifier(identifier), undefined)\n }\n\n if (schemas.errors) {\n properties['errors'] = factory.createUnionDeclaration({\n nodes: schemas.errors.map((error) => {\n const identifier = pluginManager.resolveName({\n name: error.name,\n pluginName: pluginTsName,\n type: 'function',\n })\n\n return factory.createTypeReferenceNode(factory.createIdentifier(identifier), undefined)\n }),\n })!\n }\n\n const namespaceNode = factory.createTypeAliasDeclaration({\n name,\n type: factory.createTypeLiteralNode(\n Object.keys(properties)\n .map((key) => {\n const type = properties[key]\n if (!type) {\n return undefined\n }\n\n return factory.createPropertySignature({\n name: pascalCase(key),\n type,\n })\n })\n .filter(Boolean),\n ),\n modifiers: [factory.modifiers.export],\n })\n\n return safePrint(namespaceNode)\n}\n\nfunction printRequestSchema({\n baseName,\n operation,\n schemas,\n pluginManager,\n}: {\n baseName: string\n operation: Operation\n schemas: OperationSchemas\n pluginManager: PluginManager\n}): string {\n const name = pluginManager.resolveName({\n name: `${baseName} Request`,\n pluginName: pluginTsName,\n type: 'type',\n })\n\n const results: string[] = []\n\n // Generate DataRequest type\n const dataRequestProperties: ts.PropertySignature[] = []\n\n if (schemas.request) {\n const identifier = pluginManager.resolveName({\n name: schemas.request.name,\n pluginName: pluginTsName,\n type: 'type',\n })\n dataRequestProperties.push(\n factory.createPropertySignature({\n name: 'data',\n questionToken: true,\n type: factory.createTypeReferenceNode(factory.createIdentifier(identifier), undefined),\n }),\n )\n } else {\n dataRequestProperties.push(\n factory.createPropertySignature({\n name: 'data',\n questionToken: true,\n type: keywordTypeNodes.never,\n }),\n )\n }\n\n // Add pathParams property\n if (schemas.pathParams) {\n const identifier = pluginManager.resolveName({\n name: schemas.pathParams.name,\n pluginName: pluginTsName,\n type: 'type',\n })\n dataRequestProperties.push(\n factory.createPropertySignature({\n name: 'pathParams',\n type: factory.createTypeReferenceNode(factory.createIdentifier(identifier), undefined),\n }),\n )\n } else {\n dataRequestProperties.push(\n factory.createPropertySignature({\n name: 'pathParams',\n questionToken: true,\n type: keywordTypeNodes.never,\n }),\n )\n }\n\n // Add queryParams property\n if (schemas.queryParams) {\n const identifier = pluginManager.resolveName({\n name: schemas.queryParams.name,\n pluginName: pluginTsName,\n type: 'type',\n })\n dataRequestProperties.push(\n factory.createPropertySignature({\n name: 'queryParams',\n questionToken: true,\n type: factory.createTypeReferenceNode(factory.createIdentifier(identifier), undefined),\n }),\n )\n } else {\n dataRequestProperties.push(\n factory.createPropertySignature({\n name: 'queryParams',\n questionToken: true,\n type: keywordTypeNodes.never,\n }),\n )\n }\n\n // Add headerParams property\n if (schemas.headerParams) {\n const identifier = pluginManager.resolveName({\n name: schemas.headerParams.name,\n pluginName: pluginTsName,\n type: 'type',\n })\n dataRequestProperties.push(\n factory.createPropertySignature({\n name: 'headerParams',\n questionToken: true,\n type: factory.createTypeReferenceNode(factory.createIdentifier(identifier), undefined),\n }),\n )\n } else {\n dataRequestProperties.push(\n factory.createPropertySignature({\n name: 'headerParams',\n questionToken: true,\n type: keywordTypeNodes.never,\n }),\n )\n }\n\n // Add url property with template literal type\n dataRequestProperties.push(\n factory.createPropertySignature({\n name: 'url',\n type: createUrlTemplateType(operation.path),\n }),\n )\n\n const dataRequestNode = factory.createTypeAliasDeclaration({\n name,\n type: factory.createTypeLiteralNode(dataRequestProperties),\n modifiers: [factory.modifiers.export],\n })\n\n results.push(safePrint(dataRequestNode))\n\n return results.join('\\n\\n')\n}\n\nfunction printResponseSchema({\n baseName,\n schemas,\n pluginManager,\n unknownType,\n}: {\n baseName: string\n schemas: OperationSchemas\n pluginManager: PluginManager\n unknownType: PluginTs['resolvedOptions']['unknownType']\n}): string {\n const results: string[] = []\n\n const name = pluginManager.resolveName({\n name: `${baseName} ResponseData`,\n pluginName: pluginTsName,\n type: 'type',\n })\n\n // Generate Responses type (mapping status codes to response types)\n if (schemas.responses && schemas.responses.length > 0) {\n const responsesProperties: ts.PropertySignature[] = schemas.responses.map((res) => {\n const identifier = pluginManager.resolveName({\n name: res.name,\n pluginName: pluginTsName,\n type: 'type',\n })\n\n return factory.createPropertySignature({\n name: res.statusCode?.toString() ?? 'default',\n type: factory.createTypeReferenceNode(factory.createIdentifier(identifier), undefined),\n })\n })\n\n const responsesNode = factory.createTypeAliasDeclaration({\n name: `${baseName}Responses`,\n type: factory.createTypeLiteralNode(responsesProperties),\n modifiers: [factory.modifiers.export],\n })\n\n results.push(safePrint(responsesNode))\n\n // Generate Response type (union via indexed access)\n const responseNode = factory.createTypeAliasDeclaration({\n name,\n type: factory.createIndexedAccessTypeNode(\n factory.createTypeReferenceNode(factory.createIdentifier(`${baseName}Responses`), undefined),\n factory.createTypeOperatorNode(\n ts.SyntaxKind.KeyOfKeyword,\n factory.createTypeReferenceNode(factory.createIdentifier(`${baseName}Responses`), undefined),\n ),\n ),\n modifiers: [factory.modifiers.export],\n })\n\n results.push(safePrint(responseNode))\n } else {\n const responseNode = factory.createTypeAliasDeclaration({\n name,\n modifiers: [factory.modifiers.export],\n type: getUnknownType(unknownType),\n })\n\n results.push(safePrint(responseNode))\n }\n\n return results.join('\\n\\n')\n}\n\nexport const typeGenerator = createReactGenerator<PluginTs, '1'>({\n name: 'typescript',\n version: '1',\n Operation({ operation, generator, plugin }) {\n const {\n options,\n options: { mapper, enumType, enumKeyCasing, syntaxType, optionalType, arrayType, unknownType, paramsCasing },\n } = plugin\n\n const mode = useMode()\n const pluginManager = usePluginManager()\n\n const oas = useOas()\n const { getSchemas, getFile, getName, getGroup } = useOperationManager(generator)\n const schemaManager = useSchemaManager()\n\n const name = getName(operation, { type: 'type', pluginName: pluginTsName })\n\n const file = getFile(operation)\n const schemas = getSchemas(operation)\n const schemaGenerator = new SchemaGenerator(options, {\n fabric: generator.context.fabric,\n oas,\n events: generator.context.events,\n plugin,\n pluginManager,\n mode,\n override: options.override,\n })\n\n const operationSchemas = [schemas.pathParams, schemas.queryParams, schemas.headerParams, schemas.statusCodes, schemas.request, schemas.response]\n .flat()\n .filter(Boolean)\n\n const mapOperationSchema = ({ name, schema, description, keysToOmit, ...options }: OperationSchemaType) => {\n // Apply paramsCasing transformation to pathParams, queryParams, and headerParams (not response)\n const shouldTransform = paramsCasing && isParameterSchema(name)\n const transformedSchema = shouldTransform ? applyParamsCasing(schema, paramsCasing) : schema\n\n const tree = schemaGenerator.parse({ schema: transformedSchema, name, parentName: null })\n const imports = getImports(tree)\n const group = options.operation ? getGroup(options.operation) : undefined\n\n const type = {\n name: schemaManager.getName(name, { type: 'type' }),\n typedName: schemaManager.getName(name, { type: 'type' }),\n file: schemaManager.getFile(options.operationName || name, { group }),\n }\n\n return (\n <>\n {mode === 'split' &&\n imports.map((imp) => (\n <File.Import key={[name, imp.name, imp.path, imp.isTypeOnly].join('-')} root={file.path} path={imp.path} name={imp.name} isTypeOnly />\n ))}\n <Type\n name={type.name}\n typedName={type.typedName}\n description={description}\n tree={tree}\n schema={transformedSchema}\n mapper={mapper}\n enumType={enumType}\n enumKeyCasing={enumKeyCasing}\n optionalType={optionalType}\n arrayType={arrayType}\n keysToOmit={keysToOmit}\n syntaxType={syntaxType}\n />\n </>\n )\n }\n\n const responseName = schemaManager.getName(schemas.response.name, {\n type: 'type',\n })\n\n const combinedSchemaName = operation.method === 'get' ? `${name}Query` : `${name}Mutation`\n\n return (\n <File\n baseName={file.baseName}\n path={file.path}\n meta={file.meta}\n banner={getBanner({ oas, output: plugin.options.output, config: pluginManager.config })}\n footer={getFooter({ oas, output: plugin.options.output })}\n >\n {operationSchemas.map(mapOperationSchema)}\n\n {generator.context.UNSTABLE_NAMING ? (\n <>\n <File.Source name={`${name}Request`} isExportable isIndexable isTypeOnly>\n {printRequestSchema({ baseName: name, operation, schemas, pluginManager })}\n </File.Source>\n <File.Source name={responseName} isExportable isIndexable isTypeOnly>\n {printResponseSchema({ baseName: name, schemas, pluginManager, unknownType })}\n </File.Source>\n </>\n ) : (\n <File.Source name={combinedSchemaName} isExportable isIndexable isTypeOnly>\n {printCombinedSchema({ name: combinedSchemaName, schemas, pluginManager })}\n </File.Source>\n )}\n </File>\n )\n },\n Schema({ schema, plugin }) {\n const {\n options: { mapper, enumType, enumKeyCasing, syntaxType, optionalType, arrayType, output },\n } = plugin\n const mode = useMode()\n\n const oas = useOas()\n const pluginManager = usePluginManager()\n\n const { getName, getFile } = useSchemaManager()\n const imports = getImports(schema.tree)\n const schemaFromTree = schema.tree.find((item) => item.keyword === schemaKeywords.schema)\n\n let typedName = getName(schema.name, { type: 'type' })\n\n if (['asConst', 'asPascalConst'].includes(enumType) && schemaFromTree && isKeyword(schemaFromTree, schemaKeywords.enum)) {\n typedName = typedName += 'Key' //Suffix for avoiding collisions (https://github.com/kubb-labs/kubb/issues/1873)\n }\n\n const type = {\n name: getName(schema.name, { type: 'function' }),\n typedName,\n file: getFile(schema.name),\n }\n\n return (\n <File\n baseName={type.file.baseName}\n path={type.file.path}\n meta={type.file.meta}\n banner={getBanner({ oas, output, config: pluginManager.config })}\n footer={getFooter({ oas, output })}\n >\n {mode === 'split' &&\n imports.map((imp) => (\n <File.Import key={[schema.name, imp.path, imp.isTypeOnly].join('-')} root={type.file.path} path={imp.path} name={imp.name} isTypeOnly />\n ))}\n <Type\n name={type.name}\n typedName={type.typedName}\n description={schema.value.description}\n tree={schema.tree}\n schema={schema.value}\n mapper={mapper}\n enumType={enumType}\n enumKeyCasing={enumKeyCasing}\n optionalType={optionalType}\n arrayType={arrayType}\n syntaxType={syntaxType}\n />\n </File>\n )\n },\n})\n","import { jsStringEscape, stringify } from '@internals/utils'\nimport { isPlainStringType } from '@kubb/ast'\nimport type { ArraySchemaNode, SchemaNode } from '@kubb/ast/types'\nimport type { PrinterFactoryOptions } from '@kubb/core'\nimport { definePrinter } from '@kubb/core'\nimport type ts from 'typescript'\nimport * as factory from './factory.ts'\n\ntype TsOptions = {\n /**\n * @default `'questionToken'`\n */\n optionalType: 'questionToken' | 'undefined' | 'questionTokenAndUndefined'\n /**\n * @default `'array'`\n */\n arrayType: 'array' | 'generic'\n /**\n * @default `'inlineLiteral'`\n */\n enumType: 'enum' | 'asConst' | 'asPascalConst' | 'constEnum' | 'literal' | 'inlineLiteral'\n}\n\ntype TsPrinter = PrinterFactoryOptions<'typescript', TsOptions, ts.TypeNode>\n\nfunction constToTypeNode(value: string | number | boolean, format: 'string' | 'number' | 'boolean'): ts.TypeNode | undefined {\n if (format === 'boolean') {\n return factory.createLiteralTypeNode(value === true ? factory.createTrue() : factory.createFalse())\n }\n if (format === 'number' && typeof value === 'number') {\n if (value < 0) {\n return factory.createLiteralTypeNode(factory.createPrefixUnaryExpression(factory.SyntaxKind.MinusToken, factory.createNumericLiteral(Math.abs(value))))\n }\n return factory.createLiteralTypeNode(factory.createNumericLiteral(value))\n }\n return factory.createLiteralTypeNode(factory.createStringLiteral(String(value)))\n}\n\nfunction dateOrStringNode(node: { representation?: string }): ts.TypeNode {\n return node.representation === 'date' ? factory.createTypeReferenceNode(factory.createIdentifier('Date')) : factory.keywordTypeNodes.string\n}\n\nfunction buildMemberNodes(members: Array<SchemaNode> | undefined, print: (node: SchemaNode) => ts.TypeNode | null | undefined): Array<ts.TypeNode> {\n return (members ?? []).map(print).filter(Boolean) as Array<ts.TypeNode>\n}\n\nfunction buildTupleNode(node: ArraySchemaNode, print: (node: SchemaNode) => ts.TypeNode | null | undefined): ts.TypeNode | undefined {\n let items = (node.items ?? []).map(print).filter(Boolean) as Array<ts.TypeNode>\n\n const restNode = node.rest ? (print(node.rest) ?? undefined) : undefined\n const { min, max } = node\n\n if (max !== undefined) {\n items = items.slice(0, max)\n if (items.length < max && restNode) {\n items = [...items, ...Array(max - items.length).fill(restNode)]\n }\n }\n\n if (min !== undefined) {\n items = items.map((item, i) => (i >= min ? factory.createOptionalTypeNode(item) : item))\n }\n\n if (max === undefined && restNode) {\n items.push(factory.createRestTypeNode(factory.createArrayTypeNode(restNode)))\n }\n\n return factory.createTupleTypeNode(items)\n}\n\nfunction buildPropertyType(schema: SchemaNode, baseType: ts.TypeNode, optionalType: TsOptions['optionalType']): ts.TypeNode {\n const addsUndefined = ['undefined', 'questionTokenAndUndefined'].includes(optionalType)\n\n let type = baseType\n\n if (schema.nullable) {\n type = factory.createUnionDeclaration({ nodes: [type, factory.keywordTypeNodes.null] }) as ts.TypeNode\n }\n\n if ((schema.nullish || schema.optional) && addsUndefined) {\n type = factory.createUnionDeclaration({ nodes: [type, factory.keywordTypeNodes.undefined] }) as ts.TypeNode\n }\n\n return type\n}\n\nfunction buildPropertyJSDocComments(schema: SchemaNode): Array<string | undefined> {\n return [\n 'description' in schema && schema.description ? `@description ${jsStringEscape(schema.description as string)}` : undefined,\n 'deprecated' in schema && schema.deprecated ? '@deprecated' : undefined,\n 'min' in schema && schema.min !== undefined ? `@minLength ${schema.min}` : undefined,\n 'max' in schema && schema.max !== undefined ? `@maxLength ${schema.max}` : undefined,\n 'pattern' in schema && schema.pattern ? `@pattern ${schema.pattern}` : undefined,\n 'default' in schema && schema.default !== undefined\n ? `@default ${'primitive' in schema && schema.primitive === 'string' ? stringify(schema.default as string) : schema.default}`\n : undefined,\n 'example' in schema && schema.example !== undefined ? `@example ${schema.example}` : undefined,\n 'primitive' in schema && schema.primitive\n ? [`@type ${schema.primitive || 'unknown'}`, 'optional' in schema && schema.optional ? ' | undefined' : undefined].filter(Boolean).join('')\n : undefined,\n ]\n}\n\nfunction buildIndexSignatures(\n node: { additionalProperties?: SchemaNode | boolean; patternProperties?: Record<string, SchemaNode> },\n propertyCount: number,\n print: (node: SchemaNode) => ts.TypeNode | null | undefined,\n): Array<ts.TypeElement> {\n const elements: Array<ts.TypeElement> = []\n\n if (node.additionalProperties && node.additionalProperties !== true) {\n const additionalType = (print(node.additionalProperties as SchemaNode) ?? factory.keywordTypeNodes.unknown) as ts.TypeNode\n elements.push(factory.createIndexSignature(propertyCount > 0 ? factory.keywordTypeNodes.unknown : additionalType))\n } else if (node.additionalProperties === true) {\n elements.push(factory.createIndexSignature(factory.keywordTypeNodes.unknown))\n }\n\n if (node.patternProperties) {\n const first = Object.values(node.patternProperties)[0]\n if (first) {\n let patternType = (print(first) ?? factory.keywordTypeNodes.unknown) as ts.TypeNode\n if (first.nullable) {\n patternType = factory.createUnionDeclaration({ nodes: [patternType, factory.keywordTypeNodes.null] }) as ts.TypeNode\n }\n elements.push(factory.createIndexSignature(patternType))\n }\n }\n\n return elements\n}\n\n/**\n * Converts a `SchemaNode` AST node into a TypeScript `ts.TypeNode`.\n *\n * Built on `definePrinter` — dispatches on `node.type`, with options closed over\n * per printer instance. Produces the same `ts.TypeNode` output as the keyword-based\n * `parse` in `parser.ts`.\n */\nexport const printerTs = definePrinter<TsPrinter>((options) => ({\n name: 'typescript',\n options,\n nodes: {\n any: () => factory.keywordTypeNodes.any,\n unknown: () => factory.keywordTypeNodes.unknown,\n void: () => factory.keywordTypeNodes.void,\n boolean: () => factory.keywordTypeNodes.boolean,\n null: () => factory.keywordTypeNodes.null,\n blob: () => factory.createTypeReferenceNode('Blob', []),\n string: () => factory.keywordTypeNodes.string,\n uuid: () => factory.keywordTypeNodes.string,\n email: () => factory.keywordTypeNodes.string,\n url: () => factory.keywordTypeNodes.string,\n datetime: () => factory.keywordTypeNodes.string,\n number: () => factory.keywordTypeNodes.number,\n integer: () => factory.keywordTypeNodes.number,\n bigint: () => factory.keywordTypeNodes.bigint,\n date: (node) => dateOrStringNode(node),\n time: (node) => dateOrStringNode(node),\n ref(node) {\n if (!node.name) {\n return undefined\n }\n return factory.createTypeReferenceNode(node.name, undefined)\n },\n enum(node) {\n const values = node.namedEnumValues?.map((v) => v.value) ?? node.enumValues ?? []\n\n if (this.options.enumType === 'inlineLiteral' || !node.name) {\n const literalNodes = values\n .filter((v): v is string | number | boolean => v !== null)\n .map((value) => constToTypeNode(value, typeof value === 'number' ? 'number' : typeof value === 'boolean' ? 'boolean' : 'string'))\n .filter(Boolean) as Array<ts.TypeNode>\n\n return factory.createUnionDeclaration({ withParentheses: true, nodes: literalNodes }) ?? undefined\n }\n\n const typeName = ['asConst', 'asPascalConst'].includes(this.options.enumType) ? `${node.name}Key` : node.name\n\n return factory.createTypeReferenceNode(typeName, undefined)\n },\n union(node) {\n const members = node.members ?? []\n\n const hasStringLiteral = members.some((m) => m.type === 'enum' && m.enumType === 'string')\n const hasPlainString = members.some((m) => isPlainStringType(m))\n\n if (hasStringLiteral && hasPlainString) {\n const nodes = members\n .map((m) => {\n if (isPlainStringType(m)) {\n return factory.createIntersectionDeclaration({\n nodes: [factory.keywordTypeNodes.string, factory.createTypeLiteralNode([])],\n withParentheses: true,\n }) as ts.TypeNode\n }\n\n return this.print(m)\n })\n .filter(Boolean) as Array<ts.TypeNode>\n\n return factory.createUnionDeclaration({ withParentheses: true, nodes }) ?? undefined\n }\n\n return factory.createUnionDeclaration({ withParentheses: true, nodes: buildMemberNodes(members, this.print) }) ?? undefined\n },\n intersection(node) {\n return factory.createIntersectionDeclaration({ withParentheses: true, nodes: buildMemberNodes(node.members, this.print) }) ?? undefined\n },\n array(node) {\n const itemNodes = (node.items ?? []).map((item) => this.print(item)).filter(Boolean) as Array<ts.TypeNode>\n\n return factory.createArrayDeclaration({ nodes: itemNodes, arrayType: this.options.arrayType }) ?? undefined\n },\n tuple(node) {\n return buildTupleNode(node, this.print)\n },\n object(node) {\n const addsQuestionToken = ['questionToken', 'questionTokenAndUndefined'].includes(this.options.optionalType)\n const { print } = this\n\n const propertyNodes: Array<ts.TypeElement> = node.properties.map((prop) => {\n const baseType = (print(prop.schema) ?? factory.keywordTypeNodes.unknown) as ts.TypeNode\n const type = buildPropertyType(prop.schema, baseType, this.options.optionalType)\n\n const propertyNode = factory.createPropertySignature({\n questionToken: prop.schema.optional || prop.schema.nullish ? addsQuestionToken : false,\n name: prop.name,\n type,\n readOnly: prop.schema.readOnly,\n })\n\n return factory.appendJSDocToNode({ node: propertyNode, comments: buildPropertyJSDocComments(prop.schema) })\n })\n\n const allElements = [...propertyNodes, ...buildIndexSignatures(node, propertyNodes.length, print)]\n\n if (!allElements.length) {\n return factory.keywordTypeNodes.object\n }\n\n return factory.createTypeLiteralNode(allElements)\n },\n },\n}))\n","import { camelCase, jsStringEscape, pascalCase, trimQuotes } from '@internals/utils'\nimport { collect } from '@kubb/ast'\nimport type { EnumSchemaNode, SchemaNode } from '@kubb/ast/types'\nimport { safePrint } from '@kubb/fabric-core/parsers/typescript'\nimport { File } from '@kubb/react-fabric'\nimport type { FabricReactNode } from '@kubb/react-fabric/types'\nimport type ts from 'typescript'\nimport * as factory from '../../factory.ts'\nimport { printerTs } from '../../printer.ts'\nimport type { PluginTs } from '../../types.ts'\n\ntype Props = {\n name: string\n typedName: string\n node: SchemaNode\n optionalType: PluginTs['resolvedOptions']['optionalType']\n arrayType: PluginTs['resolvedOptions']['arrayType']\n enumType: PluginTs['resolvedOptions']['enumType']\n enumKeyCasing: PluginTs['resolvedOptions']['enumKeyCasing']\n syntaxType: PluginTs['resolvedOptions']['syntaxType']\n description?: string\n keysToOmit?: string[]\n}\n\nexport function Type({ name, typedName, node, keysToOmit, optionalType, arrayType, syntaxType, enumType, enumKeyCasing, ...rest }: Props): FabricReactNode {\n const typeNodes: ts.Node[] = []\n\n const description = rest.description || node?.description\n const enumSchemaNodes = collect<EnumSchemaNode>(node, {\n schema(n): EnumSchemaNode | undefined {\n if (n.type === 'enum' && n.name) return n as EnumSchemaNode\n },\n })\n\n const printer = printerTs({ optionalType, arrayType, enumType })\n let type = printer.print(node)\n\n if (!type) {\n return\n }\n\n // Add a \"Key\" suffix to avoid collisions where necessary\n if (['asConst', 'asPascalConst'].includes(enumType) && enumSchemaNodes.length > 0) {\n const isDirectEnum = node.type === 'array' && node.items !== undefined\n const isEnumOnly = 'enum' in node && node.enum\n\n if (isDirectEnum || isEnumOnly) {\n const enumSchemaNode = enumSchemaNodes[0]!\n const typeNameWithKey = `${enumSchemaNode.name!}Key`\n\n type = factory.createTypeReferenceNode(typeNameWithKey)\n\n if (isDirectEnum) {\n if (arrayType === 'generic') {\n type = factory.createTypeReferenceNode(factory.createIdentifier('Array'), [type])\n } else {\n type = factory.createArrayTypeNode(type)\n }\n }\n }\n }\n\n if (node) {\n if (node.nullable) {\n type = factory.createUnionDeclaration({\n nodes: [type, factory.keywordTypeNodes.null],\n }) as ts.TypeNode\n }\n\n if (node.nullish && ['undefined', 'questionTokenAndUndefined'].includes(optionalType as string)) {\n type = factory.createUnionDeclaration({\n nodes: [type, factory.keywordTypeNodes.undefined],\n }) as ts.TypeNode\n }\n\n if (node.optional && ['undefined', 'questionTokenAndUndefined'].includes(optionalType as string)) {\n type = factory.createUnionDeclaration({\n nodes: [type, factory.keywordTypeNodes.undefined],\n }) as ts.TypeNode\n }\n }\n\n const useTypeGeneration = syntaxType === 'type' || [factory.syntaxKind.union].includes(type.kind as typeof factory.syntaxKind.union) || !!keysToOmit?.length\n\n typeNodes.push(\n factory.createTypeDeclaration({\n name,\n isExportable: true,\n type: keysToOmit?.length\n ? factory.createOmitDeclaration({\n keys: keysToOmit,\n type,\n nonNullable: true,\n })\n : type,\n syntax: useTypeGeneration ? 'type' : 'interface',\n comments: [\n node?.title ? `${jsStringEscape(node.title)}` : undefined,\n description ? `@description ${jsStringEscape(description)}` : undefined,\n node?.deprecated ? '@deprecated' : undefined,\n node && 'min' in node && node.min !== undefined ? `@minLength ${node.min}` : undefined,\n node && 'max' in node && node.max !== undefined ? `@maxLength ${node.max}` : undefined,\n node && 'pattern' in node && node.pattern ? `@pattern ${node.pattern}` : undefined,\n node?.default ? `@default ${node.default}` : undefined,\n node?.example ? `@example ${node.example}` : undefined,\n ],\n }),\n )\n\n const enums = [...new Map(enumSchemaNodes.map((n) => [n.name, n])).values()].map((enumSchemaNode) => {\n const enumName = enumType === 'asPascalConst' ? pascalCase(enumSchemaNode.name!) : camelCase(enumSchemaNode.name!)\n const typeName = ['asConst', 'asPascalConst'].includes(enumType) ? `${enumSchemaNode.name!}Key` : enumSchemaNode.name!\n\n const [nameNode, typeNode] = factory.createEnumDeclaration({\n name: enumName,\n typeName,\n enums: (enumSchemaNode.namedEnumValues?.map((v) => [trimQuotes(v.name.toString()), v.value]) ??\n enumSchemaNode.enumValues?.filter((v): v is NonNullable<typeof v> => v !== null && v !== undefined).map((v) => [trimQuotes(v.toString()), v]) ??\n []) as unknown as Array<[string, string]>,\n type: enumType,\n enumKeyCasing,\n })\n\n return {\n nameNode,\n typeNode,\n name: enumName,\n typeName,\n }\n })\n\n // Skip enum exports when using inlineLiteral\n const shouldExportEnums = enumType !== 'inlineLiteral'\n const shouldExportType = enumType === 'inlineLiteral' || enums.every((item) => item.typeName !== name)\n\n return (\n <>\n {shouldExportEnums &&\n enums.map(({ name: enumName, nameNode, typeName, typeNode }) => (\n <>\n {nameNode && (\n <File.Source name={enumName} isExportable isIndexable isTypeOnly={false}>\n {safePrint(nameNode)}\n </File.Source>\n )}\n {\n <File.Source\n name={typeName}\n isIndexable\n isExportable={['enum', 'asConst', 'asPascalConst', 'constEnum', 'literal', undefined].includes(enumType)}\n isTypeOnly={['asConst', 'asPascalConst', 'literal', undefined].includes(enumType)}\n >\n {safePrint(typeNode)}\n </File.Source>\n }\n </>\n ))}\n {shouldExportType && (\n <File.Source name={typedName} isTypeOnly isExportable isIndexable>\n {safePrint(...typeNodes)}\n </File.Source>\n )}\n </>\n )\n}\n","import type { SchemaNode } from '@kubb/ast/types'\nimport { useKubb } from '@kubb/core/hooks'\nimport { createReactGenerator } from '@kubb/plugin-oas/generators'\nimport { File } from '@kubb/react-fabric'\nimport { Type } from '../../components/v2/Type.tsx'\nimport type { PluginTs } from '../../types'\n\nexport const typeGenerator = createReactGenerator<PluginTs, '2'>({\n name: 'typescript',\n version: '2',\n Operation({ node, adapter, options }) {\n const { enumType, enumKeyCasing, optionalType, arrayType, syntaxType } = options\n\n const { plugin, mode, getFile, resolveName } = useKubb<PluginTs>()\n\n const file = getFile({\n name: node.operationId,\n pluginName: plugin.name,\n extname: '.ts',\n mode,\n })\n\n function renderSchemaType({ node: schemaNode, name, typedName, description }: { node: SchemaNode; name: string; typedName: string; description?: string }) {\n const imports = adapter.getImports(schemaNode, (schemaName) => ({\n name: resolveName({\n name: schemaName,\n pluginName: plugin.name,\n type: 'type',\n }),\n path: getFile({\n name: schemaName,\n pluginName: plugin.name,\n extname: '.ts',\n mode,\n }).path,\n }))\n\n return (\n <>\n {mode === 'split' &&\n imports.map((imp) => <File.Import key={[name, imp.path, imp.isTypeOnly].join('-')} root={file.path} path={imp.path} name={imp.name} isTypeOnly />)}\n\n <Type\n name={name}\n typedName={typedName}\n node={schemaNode}\n description={description}\n enumType={enumType}\n enumKeyCasing={enumKeyCasing}\n optionalType={optionalType}\n arrayType={arrayType}\n syntaxType={syntaxType}\n />\n </>\n )\n }\n\n // Parameter types — each parameter rendered as its own type\n const paramTypes = node.parameters.map((param) => {\n const name = resolveName({\n name: `${node.operationId} ${param.name}`,\n pluginName: plugin.name,\n type: 'function',\n })\n const typedName = resolveName({\n name: `${node.operationId} ${param.name}`,\n pluginName: plugin.name,\n type: 'type',\n })\n\n return renderSchemaType({ node: param.schema, name, typedName })\n })\n\n // Response types\n const responseTypes = node.responses\n .filter((res) => res.schema)\n .map((res) => {\n const schemaNode = res.schema!\n const responseName = `${node.operationId} ${res.statusCode}`\n const resolvedName = resolveName({\n name: responseName,\n pluginName: plugin.name,\n type: 'function',\n })\n const typedName = resolveName({\n name: responseName,\n pluginName: plugin.name,\n type: 'type',\n })\n\n return renderSchemaType({ node: schemaNode, name: resolvedName, typedName, description: res.description })\n })\n\n // Request body type\n const requestType = node.requestBody\n ? (() => {\n const requestName = `${node.operationId} MutationRequest`\n const resolvedName = resolveName({\n name: requestName,\n pluginName: plugin.name,\n type: 'function',\n })\n const typedName = resolveName({\n name: requestName,\n pluginName: plugin.name,\n type: 'type',\n })\n\n return renderSchemaType({ node: node.requestBody, name: resolvedName, typedName, description: node.requestBody.description })\n })()\n : null\n\n return (\n <File baseName={file.baseName} path={file.path} meta={file.meta}>\n {paramTypes}\n {responseTypes}\n {requestType}\n </File>\n )\n },\n Schema({ node, adapter, options }) {\n const { enumType, enumKeyCasing, syntaxType, optionalType, arrayType } = options\n const { plugin, mode, resolveName, getFile } = useKubb<PluginTs>()\n\n if (!node.name) {\n return\n }\n\n const imports = adapter.getImports(node, (schemaName) => ({\n name: resolveName({\n name: schemaName,\n pluginName: plugin.name,\n type: 'type',\n }),\n path: getFile({\n name: schemaName,\n pluginName: plugin.name,\n extname: '.ts',\n mode,\n // options: {\n // group\n // },\n }).path,\n }))\n\n const isEnumSchema = node.type === 'enum'\n\n let typedName = resolveName({\n name: node.name,\n pluginName: plugin.name,\n type: 'type',\n })\n\n if (['asConst', 'asPascalConst'].includes(enumType) && isEnumSchema) {\n typedName = typedName += 'Key'\n }\n\n const type = {\n name: resolveName({\n name: node.name,\n pluginName: plugin.name,\n type: 'function',\n }),\n typedName,\n file: getFile({\n name: node.name,\n pluginName: plugin.name,\n extname: '.ts',\n mode,\n // options: {\n // group\n // },\n }),\n } as const\n\n return (\n <File baseName={type.file.baseName} path={type.file.path} meta={type.file.meta}>\n {mode === 'split' &&\n imports.map((imp) => (\n <File.Import key={[node.name, imp.path, imp.isTypeOnly].join('-')} root={type.file.path} path={imp.path} name={imp.name} isTypeOnly />\n ))}\n\n <Type\n name={type.name}\n typedName={type.typedName}\n node={node}\n enumType={enumType}\n enumKeyCasing={enumKeyCasing}\n optionalType={optionalType}\n arrayType={arrayType}\n syntaxType={syntaxType}\n />\n </File>\n )\n },\n})\n","import path from 'node:path'\nimport { camelCase, pascalCase } from '@internals/utils'\nimport { walk } from '@kubb/ast'\nimport { definePlugin, type Group, getBarrelFiles, getMode } from '@kubb/core'\nimport { buildOperation, buildSchema, OperationGenerator, pluginOasName, SchemaGenerator } from '@kubb/plugin-oas'\nimport { typeGenerator, typeGeneratorV2 } from './generators'\nimport type { PluginTs } from './types.ts'\n\nexport const pluginTsName = 'plugin-ts' satisfies PluginTs['name']\n\nexport const pluginTs = definePlugin<PluginTs>((options) => {\n const {\n output = { path: 'types', barrelType: 'named' },\n group,\n exclude = [],\n include,\n override = [],\n enumType = 'asConst',\n enumKeyCasing = 'none',\n enumSuffix = 'enum',\n dateType = 'string',\n integerType = 'number',\n unknownType = 'any',\n optionalType = 'questionToken',\n arrayType = 'array',\n emptySchemaType = unknownType,\n syntaxType = 'type',\n transformers = {},\n mapper = {},\n paramsCasing,\n generators = [typeGenerator, typeGeneratorV2].filter(Boolean),\n contentType,\n UNSTABLE_NAMING,\n } = options\n\n // @deprecated Will be removed in v5 when collisionDetection defaults to true\n const usedEnumNames = {}\n\n return {\n name: pluginTsName,\n options: {\n output,\n transformers,\n dateType,\n integerType,\n optionalType,\n arrayType,\n enumType,\n enumKeyCasing,\n enumSuffix,\n unknownType,\n emptySchemaType,\n syntaxType,\n group,\n override,\n mapper,\n paramsCasing,\n usedEnumNames,\n },\n pre: [pluginOasName],\n //resolveOptions(operation|schema): ResolvedOptions\n resolvePath(baseName, pathMode, options) {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = pathMode ?? 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 (group && (options?.group?.path || options?.group?.tag)) {\n const groupName: Group['name'] = group?.name\n ? group.name\n : (ctx) => {\n if (group?.type === 'path') {\n return `${ctx.group.split('/')[1]}`\n }\n return `${camelCase(ctx.group)}Controller`\n }\n\n return path.resolve(\n root,\n output.path,\n groupName({\n group: group.type === 'path' ? options.group.path! : options.group.tag!,\n }),\n baseName,\n )\n }\n\n return path.resolve(root, output.path, baseName)\n },\n resolveName(name, type) {\n const resolvedName = pascalCase(name, { isFile: type === 'file' })\n\n if (type) {\n return transformers?.name?.(resolvedName, type) || resolvedName\n }\n\n return resolvedName\n },\n async install() {\n const { config, fabric, plugin, adapter, rootNode, pluginManager, openInStudio } = this\n\n const root = path.resolve(config.root, config.output.path)\n const mode = getMode(path.resolve(root, output.path))\n\n if (adapter) {\n await openInStudio({ ast: true })\n\n await walk(\n rootNode,\n {\n async schema(schemaNode) {\n const writeTasks = generators.map(async (generator) => {\n if (generator.type === 'react' && generator.version === '2') {\n await buildSchema(schemaNode, {\n adapter,\n config,\n fabric,\n Component: generator.Schema,\n plugin,\n pluginManager,\n mode,\n version: generator.version,\n })\n }\n })\n\n await writeTasks\n },\n async operation(operationNode) {\n const writeTasks = generators.map(async (generator) => {\n if (generator.type === 'react' && generator.version === '2') {\n await buildOperation(operationNode, {\n adapter,\n config,\n fabric,\n Component: generator.Operation,\n plugin,\n pluginManager,\n mode,\n version: generator.version,\n })\n }\n })\n\n await writeTasks\n },\n },\n { depth: 'shallow' },\n )\n\n return\n }\n\n // v1 flow\n\n const oas = await this.getOas()\n\n const schemaGenerator = new SchemaGenerator(this.plugin.options, {\n fabric: this.fabric,\n oas,\n pluginManager: this.pluginManager,\n events: this.events,\n plugin: this.plugin,\n contentType,\n include: undefined,\n override,\n mode,\n output: output.path,\n })\n\n const schemaFiles = await schemaGenerator.build(...generators)\n await this.upsertFile(...schemaFiles)\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n fabric: this.fabric,\n oas,\n pluginManager: this.pluginManager,\n events: this.events,\n plugin: this.plugin,\n contentType,\n exclude,\n include,\n override,\n mode,\n UNSTABLE_NAMING,\n })\n\n const operationFiles = await operationGenerator.build(...generators)\n await this.upsertFile(...operationFiles)\n\n const barrelFiles = await getBarrelFiles(this.fabric.files, {\n type: output.barrelType ?? 'named',\n root,\n output,\n meta: {\n pluginName: this.plugin.name,\n },\n })\n\n await this.upsertFile(...barrelFiles)\n },\n }\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AASA,SAAgB,UAAU,OAAsD;AAC9E,KAAI,UAAU,KAAA,KAAa,UAAU,KAAM,QAAO;AAClD,QAAO,KAAK,UAAU,WAAW,MAAM,UAAU,CAAC,CAAC;;;;ACMrD,SAAS,oBAAoB,EAAE,MAAM,SAAS,iBAAoG;CAChJ,MAAM,aAA0C,EAAE;AAElD,KAAI,QAAQ,SACV,YAAW,cAAcA,uBAA+B,EACtD,OAAO,QAAQ,UAAU,KAAK,QAAQ;AAOpC,SAAOC,wBAAgCC,iBANpB,cAAc,YAAY;GAC3C,MAAM,IAAI;GACV,YAAY;GACZ,MAAM;GACP,CAAC,CAEyE,EAAE,KAAA,EAAU;GACvF,EACH,CAAC;AAGJ,KAAI,QAAQ,QAMV,YAAW,aAAaD,wBAAgCC,iBALrC,cAAc,YAAY;EAC3C,MAAM,QAAQ,QAAQ;EACtB,YAAY;EACZ,MAAM;EACP,CAAC,CAC0F,EAAE,KAAA,EAAU;AAG1G,KAAI,QAAQ,WAMV,YAAW,gBAAgBD,wBAAgCC,iBALxC,cAAc,YAAY;EAC3C,MAAM,QAAQ,WAAW;EACzB,YAAY;EACZ,MAAM;EACP,CAAC,CAC6F,EAAE,KAAA,EAAU;AAG7G,KAAI,QAAQ,YAMV,YAAW,iBAAiBD,wBAAgCC,iBALzC,cAAc,YAAY;EAC3C,MAAM,QAAQ,YAAY;EAC1B,YAAY;EACZ,MAAM;EACP,CAAC,CAC8F,EAAE,KAAA,EAAU;AAG9G,KAAI,QAAQ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5.0.0-alpha.
|
|
3
|
+
"version": "5.0.0-alpha.3",
|
|
4
4
|
"description": "TypeScript code generation plugin for Kubb, transforming OpenAPI schemas into TypeScript interfaces, types, and utility functions.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -71,10 +71,10 @@
|
|
|
71
71
|
"@kubb/react-fabric": "0.13.3",
|
|
72
72
|
"remeda": "^2.33.6",
|
|
73
73
|
"typescript": "5.9.3",
|
|
74
|
-
"@kubb/ast": "5.0.0-alpha.
|
|
75
|
-
"@kubb/core": "5.0.0-alpha.
|
|
76
|
-
"@kubb/oas": "5.0.0-alpha.
|
|
77
|
-
"@kubb/plugin-oas": "5.0.0-alpha.
|
|
74
|
+
"@kubb/ast": "5.0.0-alpha.3",
|
|
75
|
+
"@kubb/core": "5.0.0-alpha.3",
|
|
76
|
+
"@kubb/oas": "5.0.0-alpha.3",
|
|
77
|
+
"@kubb/plugin-oas": "5.0.0-alpha.3"
|
|
78
78
|
},
|
|
79
79
|
"peerDependencies": {
|
|
80
80
|
"@kubb/react-fabric": "0.13.3"
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { camelCase, jsStringEscape, pascalCase, trimQuotes } from '@internals/utils'
|
|
2
|
+
import { collect } from '@kubb/ast'
|
|
3
|
+
import type { EnumSchemaNode, SchemaNode } from '@kubb/ast/types'
|
|
4
|
+
import { safePrint } from '@kubb/fabric-core/parsers/typescript'
|
|
5
|
+
import { File } from '@kubb/react-fabric'
|
|
6
|
+
import type { FabricReactNode } from '@kubb/react-fabric/types'
|
|
7
|
+
import type ts from 'typescript'
|
|
8
|
+
import * as factory from '../../factory.ts'
|
|
9
|
+
import { printerTs } from '../../printer.ts'
|
|
10
|
+
import type { PluginTs } from '../../types.ts'
|
|
11
|
+
|
|
12
|
+
type Props = {
|
|
13
|
+
name: string
|
|
14
|
+
typedName: string
|
|
15
|
+
node: SchemaNode
|
|
16
|
+
optionalType: PluginTs['resolvedOptions']['optionalType']
|
|
17
|
+
arrayType: PluginTs['resolvedOptions']['arrayType']
|
|
18
|
+
enumType: PluginTs['resolvedOptions']['enumType']
|
|
19
|
+
enumKeyCasing: PluginTs['resolvedOptions']['enumKeyCasing']
|
|
20
|
+
syntaxType: PluginTs['resolvedOptions']['syntaxType']
|
|
21
|
+
description?: string
|
|
22
|
+
keysToOmit?: string[]
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function Type({ name, typedName, node, keysToOmit, optionalType, arrayType, syntaxType, enumType, enumKeyCasing, ...rest }: Props): FabricReactNode {
|
|
26
|
+
const typeNodes: ts.Node[] = []
|
|
27
|
+
|
|
28
|
+
const description = rest.description || node?.description
|
|
29
|
+
const enumSchemaNodes = collect<EnumSchemaNode>(node, {
|
|
30
|
+
schema(n): EnumSchemaNode | undefined {
|
|
31
|
+
if (n.type === 'enum' && n.name) return n as EnumSchemaNode
|
|
32
|
+
},
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
const printer = printerTs({ optionalType, arrayType, enumType })
|
|
36
|
+
let type = printer.print(node)
|
|
37
|
+
|
|
38
|
+
if (!type) {
|
|
39
|
+
return
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Add a "Key" suffix to avoid collisions where necessary
|
|
43
|
+
if (['asConst', 'asPascalConst'].includes(enumType) && enumSchemaNodes.length > 0) {
|
|
44
|
+
const isDirectEnum = node.type === 'array' && node.items !== undefined
|
|
45
|
+
const isEnumOnly = 'enum' in node && node.enum
|
|
46
|
+
|
|
47
|
+
if (isDirectEnum || isEnumOnly) {
|
|
48
|
+
const enumSchemaNode = enumSchemaNodes[0]!
|
|
49
|
+
const typeNameWithKey = `${enumSchemaNode.name!}Key`
|
|
50
|
+
|
|
51
|
+
type = factory.createTypeReferenceNode(typeNameWithKey)
|
|
52
|
+
|
|
53
|
+
if (isDirectEnum) {
|
|
54
|
+
if (arrayType === 'generic') {
|
|
55
|
+
type = factory.createTypeReferenceNode(factory.createIdentifier('Array'), [type])
|
|
56
|
+
} else {
|
|
57
|
+
type = factory.createArrayTypeNode(type)
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (node) {
|
|
64
|
+
if (node.nullable) {
|
|
65
|
+
type = factory.createUnionDeclaration({
|
|
66
|
+
nodes: [type, factory.keywordTypeNodes.null],
|
|
67
|
+
}) as ts.TypeNode
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (node.nullish && ['undefined', 'questionTokenAndUndefined'].includes(optionalType as string)) {
|
|
71
|
+
type = factory.createUnionDeclaration({
|
|
72
|
+
nodes: [type, factory.keywordTypeNodes.undefined],
|
|
73
|
+
}) as ts.TypeNode
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (node.optional && ['undefined', 'questionTokenAndUndefined'].includes(optionalType as string)) {
|
|
77
|
+
type = factory.createUnionDeclaration({
|
|
78
|
+
nodes: [type, factory.keywordTypeNodes.undefined],
|
|
79
|
+
}) as ts.TypeNode
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const useTypeGeneration = syntaxType === 'type' || [factory.syntaxKind.union].includes(type.kind as typeof factory.syntaxKind.union) || !!keysToOmit?.length
|
|
84
|
+
|
|
85
|
+
typeNodes.push(
|
|
86
|
+
factory.createTypeDeclaration({
|
|
87
|
+
name,
|
|
88
|
+
isExportable: true,
|
|
89
|
+
type: keysToOmit?.length
|
|
90
|
+
? factory.createOmitDeclaration({
|
|
91
|
+
keys: keysToOmit,
|
|
92
|
+
type,
|
|
93
|
+
nonNullable: true,
|
|
94
|
+
})
|
|
95
|
+
: type,
|
|
96
|
+
syntax: useTypeGeneration ? 'type' : 'interface',
|
|
97
|
+
comments: [
|
|
98
|
+
node?.title ? `${jsStringEscape(node.title)}` : undefined,
|
|
99
|
+
description ? `@description ${jsStringEscape(description)}` : undefined,
|
|
100
|
+
node?.deprecated ? '@deprecated' : undefined,
|
|
101
|
+
node && 'min' in node && node.min !== undefined ? `@minLength ${node.min}` : undefined,
|
|
102
|
+
node && 'max' in node && node.max !== undefined ? `@maxLength ${node.max}` : undefined,
|
|
103
|
+
node && 'pattern' in node && node.pattern ? `@pattern ${node.pattern}` : undefined,
|
|
104
|
+
node?.default ? `@default ${node.default}` : undefined,
|
|
105
|
+
node?.example ? `@example ${node.example}` : undefined,
|
|
106
|
+
],
|
|
107
|
+
}),
|
|
108
|
+
)
|
|
109
|
+
|
|
110
|
+
const enums = [...new Map(enumSchemaNodes.map((n) => [n.name, n])).values()].map((enumSchemaNode) => {
|
|
111
|
+
const enumName = enumType === 'asPascalConst' ? pascalCase(enumSchemaNode.name!) : camelCase(enumSchemaNode.name!)
|
|
112
|
+
const typeName = ['asConst', 'asPascalConst'].includes(enumType) ? `${enumSchemaNode.name!}Key` : enumSchemaNode.name!
|
|
113
|
+
|
|
114
|
+
const [nameNode, typeNode] = factory.createEnumDeclaration({
|
|
115
|
+
name: enumName,
|
|
116
|
+
typeName,
|
|
117
|
+
enums: (enumSchemaNode.namedEnumValues?.map((v) => [trimQuotes(v.name.toString()), v.value]) ??
|
|
118
|
+
enumSchemaNode.enumValues?.filter((v): v is NonNullable<typeof v> => v !== null && v !== undefined).map((v) => [trimQuotes(v.toString()), v]) ??
|
|
119
|
+
[]) as unknown as Array<[string, string]>,
|
|
120
|
+
type: enumType,
|
|
121
|
+
enumKeyCasing,
|
|
122
|
+
})
|
|
123
|
+
|
|
124
|
+
return {
|
|
125
|
+
nameNode,
|
|
126
|
+
typeNode,
|
|
127
|
+
name: enumName,
|
|
128
|
+
typeName,
|
|
129
|
+
}
|
|
130
|
+
})
|
|
131
|
+
|
|
132
|
+
// Skip enum exports when using inlineLiteral
|
|
133
|
+
const shouldExportEnums = enumType !== 'inlineLiteral'
|
|
134
|
+
const shouldExportType = enumType === 'inlineLiteral' || enums.every((item) => item.typeName !== name)
|
|
135
|
+
|
|
136
|
+
return (
|
|
137
|
+
<>
|
|
138
|
+
{shouldExportEnums &&
|
|
139
|
+
enums.map(({ name: enumName, nameNode, typeName, typeNode }) => (
|
|
140
|
+
<>
|
|
141
|
+
{nameNode && (
|
|
142
|
+
<File.Source name={enumName} isExportable isIndexable isTypeOnly={false}>
|
|
143
|
+
{safePrint(nameNode)}
|
|
144
|
+
</File.Source>
|
|
145
|
+
)}
|
|
146
|
+
{
|
|
147
|
+
<File.Source
|
|
148
|
+
name={typeName}
|
|
149
|
+
isIndexable
|
|
150
|
+
isExportable={['enum', 'asConst', 'asPascalConst', 'constEnum', 'literal', undefined].includes(enumType)}
|
|
151
|
+
isTypeOnly={['asConst', 'asPascalConst', 'literal', undefined].includes(enumType)}
|
|
152
|
+
>
|
|
153
|
+
{safePrint(typeNode)}
|
|
154
|
+
</File.Source>
|
|
155
|
+
}
|
|
156
|
+
</>
|
|
157
|
+
))}
|
|
158
|
+
{shouldExportType && (
|
|
159
|
+
<File.Source name={typedName} isTypeOnly isExportable isIndexable>
|
|
160
|
+
{safePrint(...typeNodes)}
|
|
161
|
+
</File.Source>
|
|
162
|
+
)}
|
|
163
|
+
</>
|
|
164
|
+
)
|
|
165
|
+
}
|
package/src/factory.ts
CHANGED
|
@@ -15,6 +15,8 @@ export const modifiers = {
|
|
|
15
15
|
|
|
16
16
|
export const syntaxKind = {
|
|
17
17
|
union: SyntaxKind.UnionType as 192,
|
|
18
|
+
literalType: SyntaxKind.LiteralType,
|
|
19
|
+
stringLiteral: SyntaxKind.StringLiteral,
|
|
18
20
|
} as const
|
|
19
21
|
|
|
20
22
|
export function getUnknownType(unknownType: 'any' | 'unknown' | 'void' | undefined) {
|
package/src/generators/index.ts
CHANGED
|
@@ -385,6 +385,7 @@ export const typeGenerator = createReactGenerator<PluginTs, '1'>({
|
|
|
385
385
|
const responseName = schemaManager.getName(schemas.response.name, {
|
|
386
386
|
type: 'type',
|
|
387
387
|
})
|
|
388
|
+
|
|
388
389
|
const combinedSchemaName = operation.method === 'get' ? `${name}Query` : `${name}Mutation`
|
|
389
390
|
|
|
390
391
|
return (
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import type { SchemaNode } from '@kubb/ast/types'
|
|
2
|
+
import { useKubb } from '@kubb/core/hooks'
|
|
3
|
+
import { createReactGenerator } from '@kubb/plugin-oas/generators'
|
|
4
|
+
import { File } from '@kubb/react-fabric'
|
|
5
|
+
import { Type } from '../../components/v2/Type.tsx'
|
|
6
|
+
import type { PluginTs } from '../../types'
|
|
7
|
+
|
|
8
|
+
export const typeGenerator = createReactGenerator<PluginTs, '2'>({
|
|
9
|
+
name: 'typescript',
|
|
10
|
+
version: '2',
|
|
11
|
+
Operation({ node, adapter, options }) {
|
|
12
|
+
const { enumType, enumKeyCasing, optionalType, arrayType, syntaxType } = options
|
|
13
|
+
|
|
14
|
+
const { plugin, mode, getFile, resolveName } = useKubb<PluginTs>()
|
|
15
|
+
|
|
16
|
+
const file = getFile({
|
|
17
|
+
name: node.operationId,
|
|
18
|
+
pluginName: plugin.name,
|
|
19
|
+
extname: '.ts',
|
|
20
|
+
mode,
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
function renderSchemaType({ node: schemaNode, name, typedName, description }: { node: SchemaNode; name: string; typedName: string; description?: string }) {
|
|
24
|
+
const imports = adapter.getImports(schemaNode, (schemaName) => ({
|
|
25
|
+
name: resolveName({
|
|
26
|
+
name: schemaName,
|
|
27
|
+
pluginName: plugin.name,
|
|
28
|
+
type: 'type',
|
|
29
|
+
}),
|
|
30
|
+
path: getFile({
|
|
31
|
+
name: schemaName,
|
|
32
|
+
pluginName: plugin.name,
|
|
33
|
+
extname: '.ts',
|
|
34
|
+
mode,
|
|
35
|
+
}).path,
|
|
36
|
+
}))
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<>
|
|
40
|
+
{mode === 'split' &&
|
|
41
|
+
imports.map((imp) => <File.Import key={[name, imp.path, imp.isTypeOnly].join('-')} root={file.path} path={imp.path} name={imp.name} isTypeOnly />)}
|
|
42
|
+
|
|
43
|
+
<Type
|
|
44
|
+
name={name}
|
|
45
|
+
typedName={typedName}
|
|
46
|
+
node={schemaNode}
|
|
47
|
+
description={description}
|
|
48
|
+
enumType={enumType}
|
|
49
|
+
enumKeyCasing={enumKeyCasing}
|
|
50
|
+
optionalType={optionalType}
|
|
51
|
+
arrayType={arrayType}
|
|
52
|
+
syntaxType={syntaxType}
|
|
53
|
+
/>
|
|
54
|
+
</>
|
|
55
|
+
)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Parameter types — each parameter rendered as its own type
|
|
59
|
+
const paramTypes = node.parameters.map((param) => {
|
|
60
|
+
const name = resolveName({
|
|
61
|
+
name: `${node.operationId} ${param.name}`,
|
|
62
|
+
pluginName: plugin.name,
|
|
63
|
+
type: 'function',
|
|
64
|
+
})
|
|
65
|
+
const typedName = resolveName({
|
|
66
|
+
name: `${node.operationId} ${param.name}`,
|
|
67
|
+
pluginName: plugin.name,
|
|
68
|
+
type: 'type',
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
return renderSchemaType({ node: param.schema, name, typedName })
|
|
72
|
+
})
|
|
73
|
+
|
|
74
|
+
// Response types
|
|
75
|
+
const responseTypes = node.responses
|
|
76
|
+
.filter((res) => res.schema)
|
|
77
|
+
.map((res) => {
|
|
78
|
+
const schemaNode = res.schema!
|
|
79
|
+
const responseName = `${node.operationId} ${res.statusCode}`
|
|
80
|
+
const resolvedName = resolveName({
|
|
81
|
+
name: responseName,
|
|
82
|
+
pluginName: plugin.name,
|
|
83
|
+
type: 'function',
|
|
84
|
+
})
|
|
85
|
+
const typedName = resolveName({
|
|
86
|
+
name: responseName,
|
|
87
|
+
pluginName: plugin.name,
|
|
88
|
+
type: 'type',
|
|
89
|
+
})
|
|
90
|
+
|
|
91
|
+
return renderSchemaType({ node: schemaNode, name: resolvedName, typedName, description: res.description })
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
// Request body type
|
|
95
|
+
const requestType = node.requestBody
|
|
96
|
+
? (() => {
|
|
97
|
+
const requestName = `${node.operationId} MutationRequest`
|
|
98
|
+
const resolvedName = resolveName({
|
|
99
|
+
name: requestName,
|
|
100
|
+
pluginName: plugin.name,
|
|
101
|
+
type: 'function',
|
|
102
|
+
})
|
|
103
|
+
const typedName = resolveName({
|
|
104
|
+
name: requestName,
|
|
105
|
+
pluginName: plugin.name,
|
|
106
|
+
type: 'type',
|
|
107
|
+
})
|
|
108
|
+
|
|
109
|
+
return renderSchemaType({ node: node.requestBody, name: resolvedName, typedName, description: node.requestBody.description })
|
|
110
|
+
})()
|
|
111
|
+
: null
|
|
112
|
+
|
|
113
|
+
return (
|
|
114
|
+
<File baseName={file.baseName} path={file.path} meta={file.meta}>
|
|
115
|
+
{paramTypes}
|
|
116
|
+
{responseTypes}
|
|
117
|
+
{requestType}
|
|
118
|
+
</File>
|
|
119
|
+
)
|
|
120
|
+
},
|
|
121
|
+
Schema({ node, adapter, options }) {
|
|
122
|
+
const { enumType, enumKeyCasing, syntaxType, optionalType, arrayType } = options
|
|
123
|
+
const { plugin, mode, resolveName, getFile } = useKubb<PluginTs>()
|
|
124
|
+
|
|
125
|
+
if (!node.name) {
|
|
126
|
+
return
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
const imports = adapter.getImports(node, (schemaName) => ({
|
|
130
|
+
name: resolveName({
|
|
131
|
+
name: schemaName,
|
|
132
|
+
pluginName: plugin.name,
|
|
133
|
+
type: 'type',
|
|
134
|
+
}),
|
|
135
|
+
path: getFile({
|
|
136
|
+
name: schemaName,
|
|
137
|
+
pluginName: plugin.name,
|
|
138
|
+
extname: '.ts',
|
|
139
|
+
mode,
|
|
140
|
+
// options: {
|
|
141
|
+
// group
|
|
142
|
+
// },
|
|
143
|
+
}).path,
|
|
144
|
+
}))
|
|
145
|
+
|
|
146
|
+
const isEnumSchema = node.type === 'enum'
|
|
147
|
+
|
|
148
|
+
let typedName = resolveName({
|
|
149
|
+
name: node.name,
|
|
150
|
+
pluginName: plugin.name,
|
|
151
|
+
type: 'type',
|
|
152
|
+
})
|
|
153
|
+
|
|
154
|
+
if (['asConst', 'asPascalConst'].includes(enumType) && isEnumSchema) {
|
|
155
|
+
typedName = typedName += 'Key'
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
const type = {
|
|
159
|
+
name: resolveName({
|
|
160
|
+
name: node.name,
|
|
161
|
+
pluginName: plugin.name,
|
|
162
|
+
type: 'function',
|
|
163
|
+
}),
|
|
164
|
+
typedName,
|
|
165
|
+
file: getFile({
|
|
166
|
+
name: node.name,
|
|
167
|
+
pluginName: plugin.name,
|
|
168
|
+
extname: '.ts',
|
|
169
|
+
mode,
|
|
170
|
+
// options: {
|
|
171
|
+
// group
|
|
172
|
+
// },
|
|
173
|
+
}),
|
|
174
|
+
} as const
|
|
175
|
+
|
|
176
|
+
return (
|
|
177
|
+
<File baseName={type.file.baseName} path={type.file.path} meta={type.file.meta}>
|
|
178
|
+
{mode === 'split' &&
|
|
179
|
+
imports.map((imp) => (
|
|
180
|
+
<File.Import key={[node.name, imp.path, imp.isTypeOnly].join('-')} root={type.file.path} path={imp.path} name={imp.name} isTypeOnly />
|
|
181
|
+
))}
|
|
182
|
+
|
|
183
|
+
<Type
|
|
184
|
+
name={type.name}
|
|
185
|
+
typedName={type.typedName}
|
|
186
|
+
node={node}
|
|
187
|
+
enumType={enumType}
|
|
188
|
+
enumKeyCasing={enumKeyCasing}
|
|
189
|
+
optionalType={optionalType}
|
|
190
|
+
arrayType={arrayType}
|
|
191
|
+
syntaxType={syntaxType}
|
|
192
|
+
/>
|
|
193
|
+
</File>
|
|
194
|
+
)
|
|
195
|
+
},
|
|
196
|
+
})
|
package/src/plugin.ts
CHANGED
|
@@ -2,8 +2,8 @@ import path from 'node:path'
|
|
|
2
2
|
import { camelCase, pascalCase } from '@internals/utils'
|
|
3
3
|
import { walk } from '@kubb/ast'
|
|
4
4
|
import { definePlugin, type Group, getBarrelFiles, getMode } from '@kubb/core'
|
|
5
|
-
import { buildSchema, OperationGenerator, pluginOasName, SchemaGenerator } from '@kubb/plugin-oas'
|
|
6
|
-
import { typeGenerator } from './generators'
|
|
5
|
+
import { buildOperation, buildSchema, OperationGenerator, pluginOasName, SchemaGenerator } from '@kubb/plugin-oas'
|
|
6
|
+
import { typeGenerator, typeGeneratorV2 } from './generators'
|
|
7
7
|
import type { PluginTs } from './types.ts'
|
|
8
8
|
|
|
9
9
|
export const pluginTsName = 'plugin-ts' satisfies PluginTs['name']
|
|
@@ -28,7 +28,7 @@ export const pluginTs = definePlugin<PluginTs>((options) => {
|
|
|
28
28
|
transformers = {},
|
|
29
29
|
mapper = {},
|
|
30
30
|
paramsCasing,
|
|
31
|
-
generators = [typeGenerator].filter(Boolean),
|
|
31
|
+
generators = [typeGenerator, typeGeneratorV2].filter(Boolean),
|
|
32
32
|
contentType,
|
|
33
33
|
UNSTABLE_NAMING,
|
|
34
34
|
} = options
|
|
@@ -58,6 +58,7 @@ export const pluginTs = definePlugin<PluginTs>((options) => {
|
|
|
58
58
|
usedEnumNames,
|
|
59
59
|
},
|
|
60
60
|
pre: [pluginOasName],
|
|
61
|
+
//resolveOptions(operation|schema): ResolvedOptions
|
|
61
62
|
resolvePath(baseName, pathMode, options) {
|
|
62
63
|
const root = path.resolve(this.config.root, this.config.output.path)
|
|
63
64
|
const mode = pathMode ?? getMode(path.resolve(root, output.path))
|
|
@@ -102,25 +103,46 @@ export const pluginTs = definePlugin<PluginTs>((options) => {
|
|
|
102
103
|
return resolvedName
|
|
103
104
|
},
|
|
104
105
|
async install() {
|
|
105
|
-
const { config, fabric, plugin } = this
|
|
106
|
+
const { config, fabric, plugin, adapter, rootNode, pluginManager, openInStudio } = this
|
|
106
107
|
|
|
107
108
|
const root = path.resolve(config.root, config.output.path)
|
|
108
109
|
const mode = getMode(path.resolve(root, output.path))
|
|
109
110
|
|
|
110
|
-
if (
|
|
111
|
-
await
|
|
111
|
+
if (adapter) {
|
|
112
|
+
await openInStudio({ ast: true })
|
|
112
113
|
|
|
113
114
|
await walk(
|
|
114
|
-
|
|
115
|
+
rootNode,
|
|
115
116
|
{
|
|
116
117
|
async schema(schemaNode) {
|
|
117
118
|
const writeTasks = generators.map(async (generator) => {
|
|
118
119
|
if (generator.type === 'react' && generator.version === '2') {
|
|
119
120
|
await buildSchema(schemaNode, {
|
|
121
|
+
adapter,
|
|
120
122
|
config,
|
|
121
123
|
fabric,
|
|
122
124
|
Component: generator.Schema,
|
|
123
125
|
plugin,
|
|
126
|
+
pluginManager,
|
|
127
|
+
mode,
|
|
128
|
+
version: generator.version,
|
|
129
|
+
})
|
|
130
|
+
}
|
|
131
|
+
})
|
|
132
|
+
|
|
133
|
+
await writeTasks
|
|
134
|
+
},
|
|
135
|
+
async operation(operationNode) {
|
|
136
|
+
const writeTasks = generators.map(async (generator) => {
|
|
137
|
+
if (generator.type === 'react' && generator.version === '2') {
|
|
138
|
+
await buildOperation(operationNode, {
|
|
139
|
+
adapter,
|
|
140
|
+
config,
|
|
141
|
+
fabric,
|
|
142
|
+
Component: generator.Operation,
|
|
143
|
+
plugin,
|
|
144
|
+
pluginManager,
|
|
145
|
+
mode,
|
|
124
146
|
version: generator.version,
|
|
125
147
|
})
|
|
126
148
|
}
|
|
@@ -135,6 +157,8 @@ export const pluginTs = definePlugin<PluginTs>((options) => {
|
|
|
135
157
|
return
|
|
136
158
|
}
|
|
137
159
|
|
|
160
|
+
// v1 flow
|
|
161
|
+
|
|
138
162
|
const oas = await this.getOas()
|
|
139
163
|
|
|
140
164
|
const schemaGenerator = new SchemaGenerator(this.plugin.options, {
|