@kubb/plugin-ts 4.18.5 → 4.19.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components.d.cts +1 -1
- package/dist/components.d.ts +1 -1
- package/dist/generators.d.cts +1 -1
- package/dist/generators.d.ts +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/plugin-BGBQy-1t.js.map +1 -1
- package/dist/plugin-Ccu95l6Z.cjs.map +1 -1
- package/dist/{types-DpL83O8r.d.ts → types-B3VHYzaa.d.ts} +27 -4
- package/dist/{types-BMfQRWAb.d.cts → types-C_985bgc.d.cts} +27 -4
- package/package.json +4 -4
- package/src/plugin.ts +1 -0
package/dist/components.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as Schema, n as PluginTs, o as SchemaObject, s as __name } from "./types-
|
|
1
|
+
import { i as Schema, n as PluginTs, o as SchemaObject, s as __name } from "./types-C_985bgc.cjs";
|
|
2
2
|
import { KubbNode } from "@kubb/react-fabric/types";
|
|
3
3
|
|
|
4
4
|
//#region src/components/Type.d.ts
|
package/dist/components.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as __name } from "./chunk-eQyhnF5A.js";
|
|
2
|
-
import { i as Schema, n as PluginTs, o as SchemaObject } from "./types-
|
|
2
|
+
import { i as Schema, n as PluginTs, o as SchemaObject } from "./types-B3VHYzaa.js";
|
|
3
3
|
import { KubbNode } from "@kubb/react-fabric/types";
|
|
4
4
|
|
|
5
5
|
//#region src/components/Type.d.ts
|
package/dist/generators.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as PluginTs, r as ReactGenerator, s as __name } from "./types-
|
|
1
|
+
import { n as PluginTs, r as ReactGenerator, s as __name } from "./types-C_985bgc.cjs";
|
|
2
2
|
|
|
3
3
|
//#region src/generators/typeGenerator.d.ts
|
|
4
4
|
declare const typeGenerator: ReactGenerator<PluginTs>;
|
package/dist/generators.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as __name } from "./chunk-eQyhnF5A.js";
|
|
2
|
-
import { n as PluginTs, r as ReactGenerator } from "./types-
|
|
2
|
+
import { n as PluginTs, r as ReactGenerator } from "./types-B3VHYzaa.js";
|
|
3
3
|
|
|
4
4
|
//#region src/generators/typeGenerator.d.ts
|
|
5
5
|
declare const typeGenerator: ReactGenerator<PluginTs>;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as UserPluginWithLifeCycle, n as PluginTs, s as __name, t as Options } from "./types-
|
|
1
|
+
import { a as UserPluginWithLifeCycle, n as PluginTs, s as __name, t as Options } from "./types-C_985bgc.cjs";
|
|
2
2
|
|
|
3
3
|
//#region src/plugin.d.ts
|
|
4
4
|
declare const pluginTsName = "plugin-ts";
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as __name } from "./chunk-eQyhnF5A.js";
|
|
2
|
-
import { a as UserPluginWithLifeCycle, n as PluginTs, t as Options } from "./types-
|
|
2
|
+
import { a as UserPluginWithLifeCycle, n as PluginTs, t as Options } from "./types-B3VHYzaa.js";
|
|
3
3
|
|
|
4
4
|
//#region src/plugin.d.ts
|
|
5
5
|
declare const pluginTsName = "plugin-ts";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin-BGBQy-1t.js","names":["factory.createUnionDeclaration","factory.createTypeReferenceNode","factory.createIdentifier","factory.createTypeAliasDeclaration","factory.createTypeLiteralNode","factory.createPropertySignature","factory.createIndexedAccessTypeNode","factory.createTypeOperatorNode","options","name","options","transformers"],"sources":["../src/generators/typeGenerator.tsx","../src/plugin.ts"],"sourcesContent":["import type { PluginManager } from '@kubb/core'\nimport { useMode, usePluginManager } from '@kubb/core/hooks'\nimport transformers from '@kubb/core/transformers'\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 { getBanner, getFooter } 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 pluginKey: [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 pluginKey: [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 pluginKey: [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 pluginKey: [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 pluginKey: [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 pluginKey: [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: transformers.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 pluginKey: [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 pluginKey: [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 pluginKey: [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 pluginKey: [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 pluginKey: [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 pluginKey: [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 pluginKey: [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>({\n name: 'typescript',\n Operation({ operation, generator, plugin }) {\n const {\n options,\n options: { mapper, enumType, enumKeyCasing, syntaxType, optionalType, arrayType, unknownType },\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', pluginKey: [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 const tree = schemaGenerator.parse({ schema, name, parentName: null })\n const imports = schemaManager.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={schema}\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 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, getImports, 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 (enumType === 'asConst' && 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 path from 'node:path'\nimport { definePlugin, type Group, getBarrelFiles, getMode } from '@kubb/core'\nimport { camelCase, pascalCase } from '@kubb/core/transformers'\nimport { OperationGenerator, pluginOasName, SchemaGenerator } from '@kubb/plugin-oas'\nimport { typeGenerator } 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 unknownType = 'any',\n optionalType = 'questionToken',\n arrayType = 'array',\n emptySchemaType = unknownType,\n syntaxType = 'type',\n transformers = {},\n mapper = {},\n generators = [typeGenerator].filter(Boolean),\n contentType,\n UNSTABLE_NAMING,\n } = options\n\n const usedEnumNames = {}\n\n return {\n name: pluginTsName,\n options: {\n output,\n transformers,\n dateType,\n optionalType,\n arrayType,\n enumType,\n enumKeyCasing,\n enumSuffix,\n unknownType,\n emptySchemaType,\n syntaxType,\n group,\n override,\n mapper,\n usedEnumNames,\n },\n pre: [pluginOasName],\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 root = path.resolve(this.config.root, this.config.output.path)\n const mode = getMode(path.resolve(root, output.path))\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 pluginKey: this.plugin.key,\n },\n })\n\n await this.upsertFile(...barrelFiles)\n },\n }\n})\n"],"mappings":";;;;;;;;;;;;;;;;AAiBA,SAAS,oBAAoB,EAAE,MAAM,SAAS,iBAAoG;CAChJ,MAAM,aAA0C,EAAE;AAElD,KAAI,QAAQ,SACV,YAAW,cAAcA,uBAA+B,EACtD,OAAO,QAAQ,UAAU,KAAK,QAAQ;EACpC,MAAM,aAAa,cAAc,YAAY;GAC3C,MAAM,IAAI;GACV,WAAW,CAAC,aAAa;GACzB,MAAM;GACP,CAAC;AAEF,SAAOC,wBAAgCC,iBAAyB,WAAW,EAAE,OAAU;GACvF,EACH,CAAC;AAGJ,KAAI,QAAQ,SAAS;EACnB,MAAM,aAAa,cAAc,YAAY;GAC3C,MAAM,QAAQ,QAAQ;GACtB,WAAW,CAAC,aAAa;GACzB,MAAM;GACP,CAAC;AACF,aAAW,aAAaD,wBAAgCC,iBAAyB,WAAW,EAAE,OAAU;;AAG1G,KAAI,QAAQ,YAAY;EACtB,MAAM,aAAa,cAAc,YAAY;GAC3C,MAAM,QAAQ,WAAW;GACzB,WAAW,CAAC,aAAa;GACzB,MAAM;GACP,CAAC;AACF,aAAW,gBAAgBD,wBAAgCC,iBAAyB,WAAW,EAAE,OAAU;;AAG7G,KAAI,QAAQ,aAAa;EACvB,MAAM,aAAa,cAAc,YAAY;GAC3C,MAAM,QAAQ,YAAY;GAC1B,WAAW,CAAC,aAAa;GACzB,MAAM;GACP,CAAC;AACF,aAAW,iBAAiBD,wBAAgCC,iBAAyB,WAAW,EAAE,OAAU;;AAG9G,KAAI,QAAQ,cAAc;EACxB,MAAM,aAAa,cAAc,YAAY;GAC3C,MAAM,QAAQ,aAAa;GAC3B,WAAW,CAAC,aAAa;GACzB,MA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,GAAG,WAAW;AAC9D,SAAM,KAAK,WAAW,GAAG,YAAY;GAgBrC,MAAM,iBAAiB,MAdI,IAAI,mBAAmB,KAAK,OAAO,SAAS;IACrE,QAAQ,KAAK;IACb;IACA,eAAe,KAAK;IACpB,QAAQ,KAAK;IACb,QAAQ,KAAK;IACb;IACA;IACA;IACA;IACA;IACA;IACD,CAAC,CAE8C,MAAM,GAAG,WAAW;AACpE,SAAM,KAAK,WAAW,GAAG,eAAe;GAExC,MAAM,cAAc,MAAM,eAAe,KAAK,OAAO,OAAO;IAC1D,MAAM,OAAO,cAAc;IAC3B;IACA;IACA,MAAM,EACJ,WAAW,KAAK,OAAO,KACxB;IACF,CAAC;AAEF,SAAM,KAAK,WAAW,GAAG,YAAY;;EAExC;EACD"}
|
|
1
|
+
{"version":3,"file":"plugin-BGBQy-1t.js","names":["factory.createUnionDeclaration","factory.createTypeReferenceNode","factory.createIdentifier","factory.createTypeAliasDeclaration","factory.createTypeLiteralNode","factory.createPropertySignature","factory.createIndexedAccessTypeNode","factory.createTypeOperatorNode","options","name","options","transformers"],"sources":["../src/generators/typeGenerator.tsx","../src/plugin.ts"],"sourcesContent":["import type { PluginManager } from '@kubb/core'\nimport { useMode, usePluginManager } from '@kubb/core/hooks'\nimport transformers from '@kubb/core/transformers'\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 { getBanner, getFooter } 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 pluginKey: [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 pluginKey: [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 pluginKey: [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 pluginKey: [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 pluginKey: [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 pluginKey: [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: transformers.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 pluginKey: [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 pluginKey: [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 pluginKey: [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 pluginKey: [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 pluginKey: [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 pluginKey: [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 pluginKey: [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>({\n name: 'typescript',\n Operation({ operation, generator, plugin }) {\n const {\n options,\n options: { mapper, enumType, enumKeyCasing, syntaxType, optionalType, arrayType, unknownType },\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', pluginKey: [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 const tree = schemaGenerator.parse({ schema, name, parentName: null })\n const imports = schemaManager.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={schema}\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 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, getImports, 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 (enumType === 'asConst' && 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 path from 'node:path'\nimport { definePlugin, type Group, getBarrelFiles, getMode } from '@kubb/core'\nimport { camelCase, pascalCase } from '@kubb/core/transformers'\nimport { OperationGenerator, pluginOasName, SchemaGenerator } from '@kubb/plugin-oas'\nimport { typeGenerator } 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 unknownType = 'any',\n optionalType = 'questionToken',\n arrayType = 'array',\n emptySchemaType = unknownType,\n syntaxType = 'type',\n transformers = {},\n mapper = {},\n generators = [typeGenerator].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 optionalType,\n arrayType,\n enumType,\n enumKeyCasing,\n enumSuffix,\n unknownType,\n emptySchemaType,\n syntaxType,\n group,\n override,\n mapper,\n usedEnumNames,\n },\n pre: [pluginOasName],\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 root = path.resolve(this.config.root, this.config.output.path)\n const mode = getMode(path.resolve(root, output.path))\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 pluginKey: this.plugin.key,\n },\n })\n\n await this.upsertFile(...barrelFiles)\n },\n }\n})\n"],"mappings":";;;;;;;;;;;;;;;;AAiBA,SAAS,oBAAoB,EAAE,MAAM,SAAS,iBAAoG;CAChJ,MAAM,aAA0C,EAAE;AAElD,KAAI,QAAQ,SACV,YAAW,cAAcA,uBAA+B,EACtD,OAAO,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IAC3B;IACA;IACA,MAAM,EACJ,WAAW,KAAK,OAAO,KACxB;IACF,CAAC;AAEF,SAAM,KAAK,WAAW,GAAG,YAAY;;EAExC;EACD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin-Ccu95l6Z.cjs","names":["transformers","keywordTypeNodes","createUrlTemplateType","ts","getUnknownType","SchemaGenerator","options","name","File","Type","schemaKeywords","pluginOasName","path","options","transformers","SchemaGenerator","OperationGenerator"],"sources":["../src/generators/typeGenerator.tsx","../src/plugin.ts"],"sourcesContent":["import type { PluginManager } from '@kubb/core'\nimport { useMode, usePluginManager } from '@kubb/core/hooks'\nimport transformers from '@kubb/core/transformers'\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 { getBanner, getFooter } 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 pluginKey: [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 pluginKey: [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 pluginKey: [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 pluginKey: [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 pluginKey: [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 pluginKey: [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: transformers.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 pluginKey: [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 pluginKey: [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 pluginKey: [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 pluginKey: [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 pluginKey: [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 pluginKey: [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 pluginKey: [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>({\n name: 'typescript',\n Operation({ operation, generator, plugin }) {\n const {\n options,\n options: { mapper, enumType, enumKeyCasing, syntaxType, optionalType, arrayType, unknownType },\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', pluginKey: [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 const tree = schemaGenerator.parse({ schema, name, parentName: null })\n const imports = schemaManager.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={schema}\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 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, getImports, 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 (enumType === 'asConst' && 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 path from 'node:path'\nimport { definePlugin, type Group, getBarrelFiles, getMode } from '@kubb/core'\nimport { camelCase, pascalCase } from '@kubb/core/transformers'\nimport { OperationGenerator, pluginOasName, SchemaGenerator } from '@kubb/plugin-oas'\nimport { typeGenerator } 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 unknownType = 'any',\n optionalType = 'questionToken',\n arrayType = 'array',\n emptySchemaType = unknownType,\n syntaxType = 'type',\n transformers = {},\n mapper = {},\n generators = [typeGenerator].filter(Boolean),\n contentType,\n UNSTABLE_NAMING,\n } = options\n\n const usedEnumNames = {}\n\n return {\n name: pluginTsName,\n options: {\n output,\n transformers,\n dateType,\n optionalType,\n arrayType,\n enumType,\n enumKeyCasing,\n enumSuffix,\n unknownType,\n emptySchemaType,\n syntaxType,\n group,\n override,\n mapper,\n usedEnumNames,\n },\n pre: [pluginOasName],\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 root = path.resolve(this.config.root, this.config.output.path)\n const mode = getMode(path.resolve(root, output.path))\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 pluginKey: this.plugin.key,\n },\n })\n\n await this.upsertFile(...barrelFiles)\n },\n }\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;AAiBA,SAAS,oBAAoB,EAAE,MAAM,SAAS,iBAAoG;CAChJ,MAAM,aAA0C,EAAE;AAElD,KAAI,QAAQ,SACV,YAAW,wDAA6C,EACtD,OAAO,QAAQ,UAAU,KAAK,QAAQ;EACpC,MAAM,aAAa,cAAc,YAAY;GAC3C,MAAM,IAAI;GACV,WAAW,CAAC,aAAa;GACzB,MAAM;GACP,CAAC;AAEF,wFAAgE,WAAW,EAAE,OAAU;GACvF,EACH,CAAC;AAGJ,KAAI,QAAQ,SAAS;EACnB,MAAM,aAAa,cAAc,YAAY;GAC3C,MAAM,QAAQ,QAAQ;GACtB,WAAW,CAAC,aAAa;GACzB,MAAM;GACP,CAAC;AACF,aAAW,4FAAsE,WAAW,EAAE,OAAU;;AAG1G,KAAI,QAAQ,YAAY;EACtB,MAAM,aAAa,cAAc,YAAY;GAC3C,MAAM,Q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GAgBrC,MAAM,iBAAiB,MAdI,IAAIC,oCAAmB,KAAK,OAAO,SAAS;IACrE,QAAQ,KAAK;IACb;IACA,eAAe,KAAK;IACpB,QAAQ,KAAK;IACb,QAAQ,KAAK;IACb;IACA;IACA;IACA;IACA;IACA;IACD,CAAC,CAE8C,MAAM,GAAG,WAAW;AACpE,SAAM,KAAK,WAAW,GAAG,eAAe;GAExC,MAAM,cAAc,qCAAqB,KAAK,OAAO,OAAO;IAC1D,MAAM,OAAO,cAAc;IAC3B;IACA;IACA,MAAM,EACJ,WAAW,KAAK,OAAO,KACxB;IACF,CAAC;AAEF,SAAM,KAAK,WAAW,GAAG,YAAY;;EAExC;EACD"}
|
|
1
|
+
{"version":3,"file":"plugin-Ccu95l6Z.cjs","names":["transformers","keywordTypeNodes","createUrlTemplateType","ts","getUnknownType","SchemaGenerator","options","name","File","Type","schemaKeywords","pluginOasName","path","options","transformers","SchemaGenerator","OperationGenerator"],"sources":["../src/generators/typeGenerator.tsx","../src/plugin.ts"],"sourcesContent":["import type { PluginManager } from '@kubb/core'\nimport { useMode, usePluginManager } from '@kubb/core/hooks'\nimport transformers from '@kubb/core/transformers'\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 { getBanner, getFooter } 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 pluginKey: [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 pluginKey: [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 pluginKey: [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 pluginKey: [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 pluginKey: [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 pluginKey: [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: transformers.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 pluginKey: [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 pluginKey: [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 pluginKey: [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 pluginKey: [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 pluginKey: [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 pluginKey: [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 pluginKey: [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>({\n name: 'typescript',\n Operation({ operation, generator, plugin }) {\n const {\n options,\n options: { mapper, enumType, enumKeyCasing, syntaxType, optionalType, arrayType, unknownType },\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', pluginKey: [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 const tree = schemaGenerator.parse({ schema, name, parentName: null })\n const imports = schemaManager.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={schema}\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 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, getImports, 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 (enumType === 'asConst' && 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 path from 'node:path'\nimport { definePlugin, type Group, getBarrelFiles, getMode } from '@kubb/core'\nimport { camelCase, pascalCase } from '@kubb/core/transformers'\nimport { OperationGenerator, pluginOasName, SchemaGenerator } from '@kubb/plugin-oas'\nimport { typeGenerator } 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 unknownType = 'any',\n optionalType = 'questionToken',\n arrayType = 'array',\n emptySchemaType = unknownType,\n syntaxType = 'type',\n transformers = {},\n mapper = {},\n generators = [typeGenerator].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 optionalType,\n arrayType,\n enumType,\n enumKeyCasing,\n enumSuffix,\n unknownType,\n emptySchemaType,\n syntaxType,\n group,\n override,\n mapper,\n usedEnumNames,\n },\n pre: [pluginOasName],\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 root = path.resolve(this.config.root, this.config.output.path)\n const mode = getMode(path.resolve(root, output.path))\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 pluginKey: this.plugin.key,\n },\n })\n\n await this.upsertFile(...barrelFiles)\n },\n }\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;AAiBA,SAAS,oBAAoB,EAAE,MAAM,SAAS,iBAAoG;CAChJ,MAAM,aAA0C,EAAE;AAElD,KAAI,QAAQ,SACV,YAAW,wDAA6C,EACtD,OAAO,QAAQ,UAAU,KAAK,QAAQ;EACpC,MAAM,aAAa,cAAc,YAAY;GAC3C,MAAM,IAAI;GACV,WAAW,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QAAQ,MAAM,OAAO,KAAK,CAAC;GACrD,MAAM,MAAM,MAAM,KAAK,QAAQ;GAe/B,MAAM,cAAc,MAbI,IAAIG,iCAAgB,KAAK,OAAO,SAAS;IAC/D,QAAQ,KAAK;IACb;IACA,eAAe,KAAK;IACpB,QAAQ,KAAK;IACb,QAAQ,KAAK;IACb;IACA,SAAS;IACT;IACA;IACA,QAAQ,OAAO;IAChB,CAAC,CAEwC,MAAM,GAAG,WAAW;AAC9D,SAAM,KAAK,WAAW,GAAG,YAAY;GAgBrC,MAAM,iBAAiB,MAdI,IAAIC,oCAAmB,KAAK,OAAO,SAAS;IACrE,QAAQ,KAAK;IACb;IACA,eAAe,KAAK;IACpB,QAAQ,KAAK;IACb,QAAQ,KAAK;IACb;IACA;IACA;IACA;IACA;IACA;IACD,CAAC,CAE8C,MAAM,GAAG,WAAW;AACpE,SAAM,KAAK,WAAW,GAAG,eAAe;GAExC,MAAM,cAAc,qCAAqB,KAAK,OAAO,OAAO;IAC1D,MAAM,OAAO,cAAc;IAC3B;IACA;IACA,MAAM,EACJ,WAAW,KAAK,OAAO,KACxB;IACF,CAAC;AAEF,SAAM,KAAK,WAAW,GAAG,YAAY;;EAExC;EACD"}
|
|
@@ -20,16 +20,21 @@ type Operation$1 = Operation;
|
|
|
20
20
|
type DiscriminatorObject$1 = DiscriminatorObject;
|
|
21
21
|
//#endregion
|
|
22
22
|
//#region ../oas/src/Oas.d.ts
|
|
23
|
-
type
|
|
23
|
+
type OasOptions = {
|
|
24
24
|
contentType?: contentType;
|
|
25
25
|
discriminator?: 'strict' | 'inherit';
|
|
26
|
+
/**
|
|
27
|
+
* Resolve name collisions when schemas from different components share the same name (case-insensitive).
|
|
28
|
+
* @default false
|
|
29
|
+
*/
|
|
30
|
+
collisionDetection?: boolean;
|
|
26
31
|
};
|
|
27
32
|
declare class Oas extends BaseOas {
|
|
28
33
|
#private;
|
|
29
34
|
document: Document;
|
|
30
35
|
constructor(document: Document);
|
|
31
|
-
setOptions(options:
|
|
32
|
-
get options():
|
|
36
|
+
setOptions(options: OasOptions): void;
|
|
37
|
+
get options(): OasOptions;
|
|
33
38
|
get<T = unknown>($ref: string): T | null;
|
|
34
39
|
getKey($ref: string): string | undefined;
|
|
35
40
|
set($ref: string, value: unknown): false | undefined;
|
|
@@ -40,6 +45,18 @@ declare class Oas extends BaseOas {
|
|
|
40
45
|
getParametersSchema(operation: Operation$1, inKey: 'path' | 'query' | 'header'): SchemaObject$1 | null;
|
|
41
46
|
validate(): Promise<oas_normalize_lib_types0.ValidationResult>;
|
|
42
47
|
flattenSchema(schema: SchemaObject$1 | null): SchemaObject$1 | null;
|
|
48
|
+
/**
|
|
49
|
+
* Get schemas from OpenAPI components (schemas, responses, requestBodies).
|
|
50
|
+
* Returns schemas in dependency order along with name mapping for collision resolution.
|
|
51
|
+
*/
|
|
52
|
+
getSchemas(options?: {
|
|
53
|
+
contentType?: contentType;
|
|
54
|
+
includes?: Array<'schemas' | 'responses' | 'requestBodies'>;
|
|
55
|
+
collisionDetection?: boolean;
|
|
56
|
+
}): {
|
|
57
|
+
schemas: Record<string, SchemaObject$1>;
|
|
58
|
+
nameMapping: Map<string, string>;
|
|
59
|
+
};
|
|
43
60
|
}
|
|
44
61
|
//#endregion
|
|
45
62
|
//#region ../core/src/BaseGenerator.d.ts
|
|
@@ -1102,6 +1119,11 @@ type SchemaGeneratorOptions = {
|
|
|
1102
1119
|
emptySchemaType: 'any' | 'unknown' | 'void';
|
|
1103
1120
|
enumType?: 'enum' | 'asConst' | 'asPascalConst' | 'constEnum' | 'literal' | 'inlineLiteral';
|
|
1104
1121
|
enumSuffix?: string;
|
|
1122
|
+
/**
|
|
1123
|
+
* @deprecated Will be removed in v5. Use `collisionDetection: true` instead to prevent enum name collisions.
|
|
1124
|
+
* When `collisionDetection` is enabled, the rootName-based approach eliminates the need for numeric suffixes.
|
|
1125
|
+
* @internal
|
|
1126
|
+
*/
|
|
1105
1127
|
usedEnumNames?: Record<string, number>;
|
|
1106
1128
|
mapper?: Record<string, string>;
|
|
1107
1129
|
typed?: boolean;
|
|
@@ -1122,6 +1144,7 @@ type SchemaProps$1 = {
|
|
|
1122
1144
|
schema: SchemaObject$1 | null;
|
|
1123
1145
|
name: string | null;
|
|
1124
1146
|
parentName: string | null;
|
|
1147
|
+
rootName?: string | null;
|
|
1125
1148
|
};
|
|
1126
1149
|
declare class SchemaGenerator<TOptions extends SchemaGeneratorOptions = SchemaGeneratorOptions, TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TOptions, Context<TOptions, TPluginOptions>> {
|
|
1127
1150
|
#private;
|
|
@@ -1326,4 +1349,4 @@ type ResolvedOptions = {
|
|
|
1326
1349
|
type PluginTs = PluginFactoryOptions<'plugin-ts', Options, ResolvedOptions, never, ResolvePathOptions>;
|
|
1327
1350
|
//#endregion
|
|
1328
1351
|
export { UserPluginWithLifeCycle as a, Schema as i, PluginTs as n, SchemaObject$1 as o, ReactGenerator as r, Options as t };
|
|
1329
|
-
//# sourceMappingURL=types-
|
|
1352
|
+
//# sourceMappingURL=types-B3VHYzaa.d.ts.map
|
|
@@ -21,16 +21,21 @@ type Operation$1 = Operation;
|
|
|
21
21
|
type DiscriminatorObject$1 = DiscriminatorObject;
|
|
22
22
|
//#endregion
|
|
23
23
|
//#region ../oas/src/Oas.d.ts
|
|
24
|
-
type
|
|
24
|
+
type OasOptions = {
|
|
25
25
|
contentType?: contentType;
|
|
26
26
|
discriminator?: 'strict' | 'inherit';
|
|
27
|
+
/**
|
|
28
|
+
* Resolve name collisions when schemas from different components share the same name (case-insensitive).
|
|
29
|
+
* @default false
|
|
30
|
+
*/
|
|
31
|
+
collisionDetection?: boolean;
|
|
27
32
|
};
|
|
28
33
|
declare class Oas extends BaseOas {
|
|
29
34
|
#private;
|
|
30
35
|
document: Document;
|
|
31
36
|
constructor(document: Document);
|
|
32
|
-
setOptions(options:
|
|
33
|
-
get options():
|
|
37
|
+
setOptions(options: OasOptions): void;
|
|
38
|
+
get options(): OasOptions;
|
|
34
39
|
get<T = unknown>($ref: string): T | null;
|
|
35
40
|
getKey($ref: string): string | undefined;
|
|
36
41
|
set($ref: string, value: unknown): false | undefined;
|
|
@@ -41,6 +46,18 @@ declare class Oas extends BaseOas {
|
|
|
41
46
|
getParametersSchema(operation: Operation$1, inKey: 'path' | 'query' | 'header'): SchemaObject$1 | null;
|
|
42
47
|
validate(): Promise<oas_normalize_lib_types0.ValidationResult>;
|
|
43
48
|
flattenSchema(schema: SchemaObject$1 | null): SchemaObject$1 | null;
|
|
49
|
+
/**
|
|
50
|
+
* Get schemas from OpenAPI components (schemas, responses, requestBodies).
|
|
51
|
+
* Returns schemas in dependency order along with name mapping for collision resolution.
|
|
52
|
+
*/
|
|
53
|
+
getSchemas(options?: {
|
|
54
|
+
contentType?: contentType;
|
|
55
|
+
includes?: Array<'schemas' | 'responses' | 'requestBodies'>;
|
|
56
|
+
collisionDetection?: boolean;
|
|
57
|
+
}): {
|
|
58
|
+
schemas: Record<string, SchemaObject$1>;
|
|
59
|
+
nameMapping: Map<string, string>;
|
|
60
|
+
};
|
|
44
61
|
}
|
|
45
62
|
//#endregion
|
|
46
63
|
//#region ../core/src/BaseGenerator.d.ts
|
|
@@ -1103,6 +1120,11 @@ type SchemaGeneratorOptions = {
|
|
|
1103
1120
|
emptySchemaType: 'any' | 'unknown' | 'void';
|
|
1104
1121
|
enumType?: 'enum' | 'asConst' | 'asPascalConst' | 'constEnum' | 'literal' | 'inlineLiteral';
|
|
1105
1122
|
enumSuffix?: string;
|
|
1123
|
+
/**
|
|
1124
|
+
* @deprecated Will be removed in v5. Use `collisionDetection: true` instead to prevent enum name collisions.
|
|
1125
|
+
* When `collisionDetection` is enabled, the rootName-based approach eliminates the need for numeric suffixes.
|
|
1126
|
+
* @internal
|
|
1127
|
+
*/
|
|
1106
1128
|
usedEnumNames?: Record<string, number>;
|
|
1107
1129
|
mapper?: Record<string, string>;
|
|
1108
1130
|
typed?: boolean;
|
|
@@ -1123,6 +1145,7 @@ type SchemaProps$1 = {
|
|
|
1123
1145
|
schema: SchemaObject$1 | null;
|
|
1124
1146
|
name: string | null;
|
|
1125
1147
|
parentName: string | null;
|
|
1148
|
+
rootName?: string | null;
|
|
1126
1149
|
};
|
|
1127
1150
|
declare class SchemaGenerator<TOptions extends SchemaGeneratorOptions = SchemaGeneratorOptions, TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TOptions, Context<TOptions, TPluginOptions>> {
|
|
1128
1151
|
#private;
|
|
@@ -1327,4 +1350,4 @@ type ResolvedOptions = {
|
|
|
1327
1350
|
type PluginTs = PluginFactoryOptions<'plugin-ts', Options, ResolvedOptions, never, ResolvePathOptions>;
|
|
1328
1351
|
//#endregion
|
|
1329
1352
|
export { UserPluginWithLifeCycle as a, Schema as i, PluginTs as n, SchemaObject$1 as o, ReactGenerator as r, __name as s, Options as t };
|
|
1330
|
-
//# sourceMappingURL=types-
|
|
1353
|
+
//# sourceMappingURL=types-C_985bgc.d.cts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/plugin-ts",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.19.1",
|
|
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",
|
|
@@ -69,9 +69,9 @@
|
|
|
69
69
|
"natural-orderby": "^5.0.0",
|
|
70
70
|
"remeda": "^2.33.4",
|
|
71
71
|
"typescript": "5.9.3",
|
|
72
|
-
"@kubb/core": "4.
|
|
73
|
-
"@kubb/oas": "4.
|
|
74
|
-
"@kubb/plugin-oas": "4.
|
|
72
|
+
"@kubb/core": "4.19.1",
|
|
73
|
+
"@kubb/oas": "4.19.1",
|
|
74
|
+
"@kubb/plugin-oas": "4.19.1"
|
|
75
75
|
},
|
|
76
76
|
"peerDependencies": {
|
|
77
77
|
"@kubb/react-fabric": "0.12.4",
|