@kubb/swagger-ts 2.3.0 → 2.4.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.
@@ -107,19 +107,23 @@ function printCombinedSchema(name, operation, schemas) {
107
107
  })
108
108
  });
109
109
  }
110
- const namespaceNode = factory2.createNamespaceDeclaration({
110
+ const namespaceNode = factory2.createTypeAliasDeclaration({
111
111
  name: operation.method === "get" ? `${name}Query` : `${name}Mutation`,
112
- statements: Object.keys(properties).map((key) => {
113
- const type = properties[key];
114
- if (!type) {
115
- return void 0;
116
- }
117
- return factory2.createTypeAliasDeclaration({
118
- modifiers: [factory2.modifiers.export],
119
- name: transformers2.pascalCase(key),
120
- type
121
- });
122
- }).filter(Boolean)
112
+ type: factory2.createTypeLiteralNode(
113
+ Object.keys(properties).map((key) => {
114
+ const type = properties[key];
115
+ if (!type) {
116
+ return void 0;
117
+ }
118
+ return factory2.createPropertySignature(
119
+ {
120
+ name: transformers2.pascalCase(key),
121
+ type
122
+ }
123
+ );
124
+ }).filter(Boolean)
125
+ ),
126
+ modifiers: [factory2.modifiers.export]
123
127
  });
124
128
  return print(namespaceNode);
125
129
  }
@@ -241,7 +245,7 @@ var definePlugin = createPlugin((options) => {
241
245
  return path.resolve(root, output.path, baseName);
242
246
  },
243
247
  resolveName(name, type) {
244
- const resolvedName = pascalCase(name);
248
+ const resolvedName = pascalCase(name, { isFile: type === "file" });
245
249
  if (type) {
246
250
  return transformers5?.name?.(resolvedName, type) || resolvedName;
247
251
  }
@@ -358,15 +362,19 @@ var TypeGenerator = class extends Generator {
358
362
  }
359
363
  build({
360
364
  schema,
365
+ optional,
361
366
  baseName,
362
367
  description,
363
368
  keysToOmit
364
369
  }) {
365
370
  const nodes = [];
366
- const type = this.getTypeFromSchema(schema, baseName);
371
+ let type = this.getTypeFromSchema(schema, baseName);
367
372
  if (!type) {
368
373
  return this.extraNodes;
369
374
  }
375
+ if (optional) {
376
+ type = factory2.createUnionDeclaration({ nodes: [type, factory2.keywordTypeNodes.undefined] });
377
+ }
370
378
  const node = factory2.createTypeAliasDeclaration({
371
379
  modifiers: [factory2.modifiers.export],
372
380
  name: this.context.pluginManager.resolveName({ name: baseName, pluginKey, type: "type" }),
@@ -461,7 +469,8 @@ getRefAlias_fn = function(obj, _baseName) {
461
469
  propertyName,
462
470
  originalName
463
471
  };
464
- const path2 = this.context.pluginManager.resolvePath({ baseName: propertyName, pluginKey });
472
+ const fileName = this.context.pluginManager.resolveName({ name: originalName, pluginKey, type: "file" });
473
+ const path2 = this.context.pluginManager.resolvePath({ baseName: fileName, pluginKey });
465
474
  this.imports.push({
466
475
  ref,
467
476
  path: path2 || "",
@@ -624,11 +633,13 @@ var TypeBuilder = class extends OasBuilder {
624
633
  const codes = [];
625
634
  const generated = this.items.filter((operationSchema) => name ? operationSchema.name === name : true).sort(transformers2.nameSorter).map((operationSchema) => {
626
635
  const generator = new TypeGenerator(this.options, this.context);
636
+ const required = Array.isArray(operationSchema.schema?.required) ? !!operationSchema.schema.required.length : !!operationSchema.schema?.required;
627
637
  const sources = generator.build({
628
638
  schema: operationSchema.schema,
629
639
  baseName: operationSchema.name,
630
640
  description: operationSchema.description,
631
- keysToOmit: operationSchema.keysToOmit
641
+ keysToOmit: operationSchema.keysToOmit,
642
+ optional: !required && !!operationSchema.name.includes("Params")
632
643
  });
633
644
  importMeta.push(...generator.imports);
634
645
  return {
@@ -749,4 +760,4 @@ Mutation.File = function({ mode }) {
749
760
 
750
761
  export { Mutation, Oas, Query, definePlugin, pluginKey, pluginName };
751
762
  //# sourceMappingURL=out.js.map
752
- //# sourceMappingURL=chunk-RKPGFITS.js.map
763
+ //# sourceMappingURL=chunk-7UWJRVRW.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/Mutation.tsx","../src/TypeBuilder.ts","../src/TypeGenerator.ts","../src/plugin.ts","../src/OperationGenerator.tsx","../src/components/Oas.tsx","../src/components/Query.tsx"],"names":["transformers","print","factory","File","usePlugin","usePluginManager","useOas","useOperation","useOperationFile","useOperationName","useSchemas","Generator","keywordTypeNodes","Template","pluginKey","Fragment","jsx","jsxs","options","node","path","printCombinedSchema"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,OAAOA,mBAAkB;AACzB,SAAS,SAAAC,cAAa;AACtB,YAAYC,cAAa;AACzB,SAAS,QAAAC,OAAM,aAAAC,YAAW,oBAAAC,yBAAwB;AAClD,SAAS,UAAAC,SAAQ,gBAAAC,eAAc,oBAAAC,mBAAkB,oBAAAC,mBAAkB,cAAAC,mBAAkB;;;ACJrF,OAAOV,mBAAkB;AACzB,SAAS,SAAAC,cAAa;AACtB,SAAS,kBAAkB;AAC3B,SAAS,kBAAkB;;;ACH3B,SAAS,aAAAU,kBAAiB;AAC1B,OAAOX,mBAAkB;AACzB,SAAS,qBAAqB;AAC9B,YAAYE,cAAa;AACzB,SAAS,oBAAAU,yBAAwB;AACjC,SAAS,kBAAkB,mBAAmB;;;ACL9C,OAAO,UAAU;AAEjB,SAAS,cAAc,aAAa,qBAAqB;AACzD,SAAS,WAAW,kBAAkB;AACtC,SAAS,sBAAsB;AAC/B,SAAS,cAAc,yBAAyB;;;ACLhD,SAAS,kBAAkB;AAC3B,SAAS,sBAAsB,iBAAiB;;;ACDhD,SAAS,MAAM,MAAM,iBAAiB;AACtC,SAAS,eAAe;AACxB,SAAS,cAAc;AAqBnB,mBAEE,KAFF;AANJ,SAAS,SAAS;AAAA,EAChB;AAAA,EACA;AAAA,EACA;AACF,GAA6B;AAC3B,SACE,iCACG;AAAA,oBAAgB,IAAI,MAAM,KAAK,UAAU,KAAK,QAAW,CAAC,CAAC;AAAA,IAC5D,oBAAC,QAAG;AAAA,IACJ,oBAAC,QAAK,MAAM,UAAU,QAAM,MACzB,0BAAgB,IAAI,KACvB;AAAA,KACF;AAEJ;AAEA,IAAM,mBAAmB,EAAE,SAAS,SAAS;AAWtC,SAAS,IAAI;AAAA,EAClB;AAAA,EACA;AAAA,EACA,UAAAC,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AAM,UAAU,IAAI,YAAY,SAAS,EAAE,KAAK,cAAc,CAAC,EAC5D,IAAI,QAAQ,UAAU,EACtB,IAAI,QAAQ,WAAW,EACvB,IAAI,QAAQ,YAAY,EACxB,IAAI,QAAQ,QAAQ,EACpB,IAAI,QAAQ,OAAO,EACnB,IAAI,QAAQ,MAAM;AAErB,QAAM,EAAE,QAAQ,QAAQ,IAAI,QAAQ,MAAM;AAE1C,SACE,gBAAAS,KAAAD,WAAA,EACE,0BAAAE;AAAA,IAACd;AAAA,IAAA;AAAA,MACC,UAAU,KAAK;AAAA,MACf,MAAM,KAAK;AAAA,MACX,MAAM,KAAK;AAAA,MAEV;AAAA,iBAAS,eAAe,QAAQ,IAAI,CAAC,MAAM,UAAU;AACpD,iBAAO,gBAAAa,KAACb,MAAK,QAAL,EAAwB,MAAM,KAAK,MAAO,GAAG,QAA5B,KAAkC;AAAA,QAC7D,CAAC;AAAA,QACD,gBAAAc,MAACd,MAAK,QAAL,EACE;AAAA;AAAA,UACAkB,qBAAoB,aAAa,WAAW,OAAO;AAAA,WACtD;AAAA;AAAA;AAAA,EACF,GACF;AAEJ","sourcesContent":["import transformers from '@kubb/core/transformers'\nimport { print } from '@kubb/parser'\nimport * as factory from '@kubb/parser/factory'\nimport { File, usePlugin, usePluginManager } from '@kubb/react'\nimport { useOas, useOperation, useOperationFile, useOperationName, useSchemas } from '@kubb/swagger/hooks'\n\nimport { TypeBuilder } from '../TypeBuilder.ts'\n\nimport type { KubbFile } from '@kubb/core'\nimport type { ts } from '@kubb/parser'\nimport type { OperationSchemas } from '@kubb/swagger'\nimport type { Operation } from '@kubb/swagger/oas'\nimport type { ReactNode } from 'react'\nimport type { FileMeta, PluginOptions } from '../types.ts'\n\ntype Props = {\n builder: TypeBuilder\n}\n\nfunction printCombinedSchema(name: string, operation: Operation, schemas: OperationSchemas): string {\n const properties: Record<string, ts.TypeNode> = {\n 'response': factory.createTypeReferenceNode(\n factory.createIdentifier(schemas.response.name),\n undefined,\n ),\n }\n\n if (schemas.request) {\n properties['request'] = factory.createTypeReferenceNode(\n factory.createIdentifier(schemas.request.name),\n undefined,\n )\n }\n\n if (schemas.pathParams) {\n properties['pathParams'] = factory.createTypeReferenceNode(\n factory.createIdentifier(schemas.pathParams.name),\n undefined,\n )\n }\n\n if (schemas.queryParams) {\n properties['queryParams'] = factory.createTypeReferenceNode(\n factory.createIdentifier(schemas.queryParams.name),\n undefined,\n )\n }\n\n if (schemas.headerParams) {\n properties['headerParams'] = factory.createTypeReferenceNode(\n factory.createIdentifier(schemas.headerParams.name),\n undefined,\n )\n }\n\n if (schemas.errors) {\n properties['errors'] = factory.createUnionDeclaration({\n nodes: schemas.errors.map(error => {\n return factory.createTypeReferenceNode(\n factory.createIdentifier(error.name),\n undefined,\n )\n }),\n })!\n }\n\n const namespaceNode = factory.createNamespaceDeclaration({\n name: operation.method === 'get' ? `${name}Query` : `${name}Mutation`,\n statements: Object.keys(properties).map(key => {\n const type = properties[key]\n if (!type) {\n return undefined\n }\n return factory.createTypeAliasDeclaration({\n modifiers: [factory.modifiers.export],\n name: transformers.pascalCase(key),\n type,\n })\n }).filter(Boolean),\n })\n\n return print(namespaceNode)\n}\n\nexport function Mutation({\n builder,\n}: Props): ReactNode {\n const { source } = builder.build()\n\n return (\n <>\n {source}\n </>\n )\n}\n\ntype FileProps = {\n mode: KubbFile.Mode\n}\n\nMutation.File = function({ mode }: FileProps): ReactNode {\n const { options } = usePlugin<PluginOptions>()\n\n const schemas = useSchemas()\n const pluginManager = usePluginManager()\n const oas = useOas()\n const file = useOperationFile()\n const factoryName = useOperationName({ type: 'type' })\n const operation = useOperation()\n\n const builder = new TypeBuilder(options, { oas, pluginManager })\n .add(schemas.pathParams)\n .add(schemas.queryParams)\n .add(schemas.headerParams)\n .add(schemas.response)\n .add(schemas.request)\n .add(schemas.errors)\n\n const { source, imports } = builder.build()\n\n return (\n <>\n <File<FileMeta>\n baseName={file.baseName}\n path={file.path}\n meta={file.meta}\n >\n {mode === 'directory' && imports.map((item, index) => {\n return <File.Import key={index} root={file.path} {...item} />\n })}\n <File.Source>\n {source}\n {printCombinedSchema(factoryName, operation, schemas)}\n </File.Source>\n </File>\n </>\n )\n}\n","import transformers from '@kubb/core/transformers'\nimport { print } from '@kubb/parser'\nimport { OasBuilder } from '@kubb/swagger'\nimport { refsSorter } from '@kubb/swagger/utils'\n\nimport { TypeGenerator } from './TypeGenerator.ts'\n\nimport type { KubbFile } from '@kubb/core'\nimport type { ImportMeta } from '@kubb/swagger'\nimport type { PluginOptions } from './types.ts'\n\nexport class TypeBuilder extends OasBuilder<PluginOptions['resolvedOptions']> {\n build(name?: string): Required<Pick<KubbFile.File, 'imports' | 'source'>> {\n const importMeta: ImportMeta[] = []\n const codes: string[] = []\n\n const generated = this.items\n .filter((operationSchema) => (name ? operationSchema.name === name : true))\n .sort(transformers.nameSorter)\n .map((operationSchema) => {\n const generator = new TypeGenerator(this.options, this.context)\n const required = Array.isArray(operationSchema.schema?.required) ? !!operationSchema.schema.required.length : !!operationSchema.schema?.required\n\n const sources = generator.build({\n schema: operationSchema.schema,\n baseName: operationSchema.name,\n description: operationSchema.description,\n keysToOmit: operationSchema.keysToOmit,\n optional: !required && !!operationSchema.name.includes('Params'),\n })\n\n importMeta.push(...generator.imports)\n\n return {\n import: {\n refs: generator.refs,\n name: operationSchema.name,\n },\n sources,\n }\n })\n .sort(refsSorter)\n\n generated.forEach((item) => {\n codes.push(print(item.sources))\n })\n\n const imports: KubbFile.Import[] = importMeta.map((item) => {\n return {\n name: [item.ref.propertyName],\n path: item.path,\n isTypeOnly: item.isTypeOnly,\n }\n })\n\n return {\n imports,\n source: transformers.combineCodes(codes),\n }\n }\n}\n","import { Generator } from '@kubb/core'\nimport transformers from '@kubb/core/transformers'\nimport { getUniqueName } from '@kubb/core/utils'\nimport * as factory from '@kubb/parser/factory'\nimport { keywordTypeNodes } from '@kubb/parser/factory'\nimport { getSchemaFactory, isReference } from '@kubb/swagger/utils'\n\nimport { pluginKey } from './plugin.ts'\n\nimport type { PluginManager } from '@kubb/core'\nimport type { ts } from '@kubb/parser'\nimport type { ImportMeta, Refs } from '@kubb/swagger'\nimport type { Oas, OasTypes, OpenAPIV3, OpenAPIV3_1 } from '@kubb/swagger/oas'\nimport type { PluginOptions } from './types.ts'\n\n// based on https://github.com/cellular/oazapfts/blob/7ba226ebb15374e8483cc53e7532f1663179a22c/src/codegen/generate.ts#L398\n\ntype Context = {\n oas: Oas\n pluginManager: PluginManager\n}\n\nexport class TypeGenerator extends Generator<PluginOptions['resolvedOptions'], Context> {\n refs: Refs = {}\n imports: ImportMeta[] = []\n\n extraNodes: ts.Node[] = []\n\n aliases: ts.TypeAliasDeclaration[] = []\n\n // Keep track of already used type aliases\n #usedAliasNames: Record<string, number> = {}\n\n build({\n schema,\n optional,\n baseName,\n description,\n keysToOmit,\n }: {\n schema: OasTypes.SchemaObject\n baseName: string\n description?: string\n optional?: boolean\n keysToOmit?: string[]\n }): ts.Node[] {\n const nodes: ts.Node[] = []\n let type = this.getTypeFromSchema(schema, baseName)\n\n if (!type) {\n return this.extraNodes\n }\n\n if (optional) {\n type = factory.createUnionDeclaration({ nodes: [type, factory.keywordTypeNodes.undefined] }) as ts.TypeNode\n }\n\n const node = factory.createTypeAliasDeclaration({\n modifiers: [factory.modifiers.export],\n name: this.context.pluginManager.resolveName({ name: baseName, pluginKey, type: 'type' }),\n type: keysToOmit?.length ? factory.createOmitDeclaration({ keys: keysToOmit, type, nonNullable: true }) : type,\n })\n\n if (description) {\n nodes.push(\n factory.appendJSDocToNode({\n node,\n comments: [`@description ${transformers.trim(description)}`],\n }),\n )\n } else {\n nodes.push(node)\n }\n\n // filter out if the export name is the same as one that we already defined in extraNodes(see enum)\n const filterdNodes = nodes.filter(\n (node: ts.Node) =>\n !this.extraNodes.some(\n (extraNode: ts.Node) => (extraNode as ts.TypeAliasDeclaration)?.name?.escapedText === (node as ts.TypeAliasDeclaration)?.name?.escapedText,\n ),\n )\n\n return [...this.extraNodes, ...filterdNodes]\n }\n\n /**\n * Creates a type node from a given schema.\n * Delegates to getBaseTypeFromSchema internally and\n * optionally adds a union with null.\n */\n getTypeFromSchema(schema?: OasTypes.SchemaObject, name?: string): ts.TypeNode | null {\n const type = this.#getBaseTypeFromSchema(schema, name)\n\n if (!type) {\n return null\n }\n\n if (schema && !schema.nullable) {\n return type\n }\n\n return factory.createUnionDeclaration({ nodes: [type, factory.keywordTypeNodes.null] })\n }\n\n /**\n * Recursively creates a type literal with the given props.\n */\n #getTypeFromProperties(baseSchema?: OasTypes.SchemaObject, baseName?: string): ts.TypeNode | null {\n const { optionalType } = this.options\n const properties = baseSchema?.properties || {}\n const required = baseSchema?.required\n const additionalProperties = baseSchema?.additionalProperties\n\n const members: Array<ts.TypeElement | null> = Object.keys(properties).map((name) => {\n const schema = properties[name] as OasTypes.SchemaObject\n\n const isRequired = Array.isArray(required) ? required.includes(name) : !!required\n let type = this.getTypeFromSchema(schema, this.context.pluginManager.resolveName({ name: `${baseName || ''} ${name}`, pluginKey, type: 'type' }))\n\n if (!type) {\n return null\n }\n\n if (!isRequired && ['undefined', 'questionTokenAndUndefined'].includes(optionalType as string)) {\n type = factory.createUnionDeclaration({ nodes: [type, factory.keywordTypeNodes.undefined] })\n }\n const propertySignature = factory.createPropertySignature({\n questionToken: ['questionToken', 'questionTokenAndUndefined'].includes(optionalType as string) && !isRequired,\n name,\n type: type as ts.TypeNode,\n readOnly: schema.readOnly,\n })\n\n return factory.appendJSDocToNode({\n node: propertySignature,\n comments: [\n schema.description ? `@description ${schema.description}` : undefined,\n schema.type ? `@type ${schema.type?.toString()}${isRequired ? '' : ' | undefined'} ${schema.format || ''}` : undefined,\n schema.example ? `@example ${schema.example as string}` : undefined,\n schema.deprecated ? `@deprecated` : undefined,\n schema.default !== undefined && typeof schema.default === 'string' ? `@default '${schema.default}'` : undefined,\n schema.default !== undefined && typeof schema.default !== 'string' ? `@default ${schema.default as string}` : undefined,\n ].filter(Boolean),\n })\n\n return propertySignature\n })\n if (additionalProperties) {\n const type = additionalProperties === true ? factory.keywordTypeNodes.any : this.getTypeFromSchema(additionalProperties as OasTypes.SchemaObject)\n\n if (type) {\n members.push(factory.createIndexSignature(type))\n }\n }\n return factory.createTypeLiteralNode(members.filter(Boolean))\n }\n\n /**\n * Create a type alias for the schema referenced by the given ReferenceObject\n */\n #getRefAlias(obj: OpenAPIV3.ReferenceObject, _baseName?: string) {\n const { $ref } = obj\n let ref = this.refs[$ref]\n\n if (ref) {\n return factory.createTypeReferenceNode(ref.propertyName, undefined)\n }\n\n const originalName = getUniqueName($ref.replace(/.+\\//, ''), this.#usedAliasNames)\n const propertyName = this.context.pluginManager.resolveName({ name: originalName, pluginKey, type: 'type' })\n\n ref = this.refs[$ref] = {\n propertyName,\n originalName,\n }\n\n const fileName = this.context.pluginManager.resolveName({ name: originalName, pluginKey, type: 'file' })\n const path = this.context.pluginManager.resolvePath({ baseName: fileName, pluginKey })\n\n this.imports.push({\n ref,\n path: path || '',\n isTypeOnly: true,\n })\n\n return factory.createTypeReferenceNode(ref.propertyName, undefined)\n }\n\n #getParsedSchema(schema?: OasTypes.SchemaObject) {\n const parsedSchema = getSchemaFactory(this.context.oas)(schema)\n return parsedSchema\n }\n\n /**\n * This is the very core of the OpenAPI to TS conversion - it takes a\n * schema and returns the appropriate type.\n */\n #getBaseTypeFromSchema(\n _schema: OasTypes.SchemaObject | undefined,\n baseName?: string,\n ): ts.TypeNode | null {\n const { schema, version } = this.#getParsedSchema(_schema)\n\n if (!schema) {\n return factory.keywordTypeNodes.any\n }\n\n if (isReference(schema)) {\n return this.#getRefAlias(schema, baseName)\n }\n\n if (schema.oneOf) {\n // union\n const schemaWithoutOneOf = { ...schema, oneOf: undefined } as OasTypes.SchemaObject\n\n const union = factory.createUnionDeclaration({\n withParentheses: true,\n nodes: schema.oneOf\n .map((item) => {\n return item && this.getTypeFromSchema(item as OasTypes.SchemaObject)\n })\n .filter((item) => {\n return item && item !== factory.keywordTypeNodes.any\n }) as Array<ts.TypeNode>,\n })\n\n if (schemaWithoutOneOf.properties) {\n return factory.createIntersectionDeclaration({\n nodes: [this.getTypeFromSchema(schemaWithoutOneOf, baseName), union].filter(Boolean),\n })\n }\n\n return union\n }\n\n if (schema.anyOf) {\n const schemaWithoutAnyOf = { ...schema, anyOf: undefined } as OasTypes.SchemaObject\n\n const union = factory.createUnionDeclaration({\n withParentheses: true,\n nodes: schema.anyOf\n .map((item) => {\n return item && this.getTypeFromSchema(item as OasTypes.SchemaObject)\n })\n .filter((item) => {\n return item && item !== factory.keywordTypeNodes.any\n }) as Array<ts.TypeNode>,\n })\n\n if (schemaWithoutAnyOf.properties) {\n return factory.createIntersectionDeclaration({\n nodes: [this.getTypeFromSchema(schemaWithoutAnyOf, baseName), union].filter(Boolean),\n })\n }\n\n return union\n }\n if (schema.allOf) {\n // intersection/add\n const schemaWithoutAllOf = { ...schema, allOf: undefined } as OasTypes.SchemaObject\n\n const and = factory.createIntersectionDeclaration({\n withParentheses: true,\n nodes: schema.allOf\n .map((item) => {\n return item && this.getTypeFromSchema(item as OasTypes.SchemaObject)\n })\n .filter((item) => {\n return item && item !== factory.keywordTypeNodes.any\n }) as Array<ts.TypeNode>,\n })\n\n if (schemaWithoutAllOf.properties) {\n return factory.createIntersectionDeclaration({\n nodes: [this.getTypeFromSchema(schemaWithoutAllOf, baseName), and].filter(Boolean),\n })\n }\n\n return and\n }\n\n /**\n * Enum will be defined outside the baseType(hints the baseName check)\n */\n if (schema.enum && baseName) {\n const enumName = getUniqueName(baseName, this.options.usedEnumNames)\n\n let enums: [key: string, value: string | number][] = [...new Set(schema.enum)].map((key) => [key, key])\n\n const extensionEnums: Array<typeof enums> = ['x-enumNames', 'x-enum-varnames']\n .filter(extensionKey => extensionKey in schema)\n .map((extensionKey) =>\n [...new Set(schema[extensionKey as keyof typeof schema] as string[])].map((key, index) => [key, schema.enum?.[index] as string] as const)\n )\n\n if (extensionEnums.length > 0 && extensionEnums[0]) {\n enums = extensionEnums[0]\n }\n\n this.extraNodes.push(\n ...factory.createEnumDeclaration({\n name: transformers.camelCase(enumName),\n typeName: this.context.pluginManager.resolveName({ name: enumName, pluginKey, type: 'type' }),\n enums,\n type: this.options.enumType,\n }),\n )\n return factory.createTypeReferenceNode(this.context.pluginManager.resolveName({ name: enumName, pluginKey, type: 'type' }), undefined)\n }\n\n if (schema.enum) {\n return factory.createUnionDeclaration({\n nodes: schema.enum.map((name) => {\n return factory.createLiteralTypeNode(typeof name === 'number' ? factory.createNumericLiteral(name) : factory.createStringLiteral(`${name}`))\n }) as unknown as Array<ts.TypeNode>,\n })\n }\n\n if ('items' in schema) {\n // items -> array\n const node = this.getTypeFromSchema(schema.items as OasTypes.SchemaObject, baseName)\n if (node) {\n return factory.createArrayTypeNode(node)\n }\n }\n\n /**\n * OpenAPI 3.1\n * @link https://json-schema.org/understanding-json-schema/reference/array.html#tuple-validation\n */\n\n if ('prefixItems' in schema) {\n const prefixItems = schema.prefixItems as OasTypes.SchemaObject[]\n\n return factory.createTupleDeclaration({\n nodes: prefixItems.map((item) => {\n // no baseType so we can fall back on an union when using enum\n return this.getTypeFromSchema(item, undefined)\n }) as Array<ts.TypeNode>,\n })\n }\n\n if (schema.properties || schema.additionalProperties) {\n // properties -> literal type\n return this.#getTypeFromProperties(schema, baseName)\n }\n\n /**\n * validate \"const\" property as defined in JSON-Schema-Validation\n *\n * https://json-schema.org/draft/2020-12/json-schema-validation#name-const\n *\n * > 6.1.3. const\n * > The value of this keyword MAY be of any type, including null.\n * > Use of this keyword is functionally equivalent to an \"enum\" (Section 6.1.2) with a single value.\n * > An instance validates successfully against this keyword if its value is equal to the value of the keyword.\n */\n if (version === '3.1' && 'const' in schema) {\n // const keyword takes precendence over the actual type.\n if (schema['const']) {\n if (typeof schema['const'] === 'string') {\n return factory.createLiteralTypeNode(factory.createStringLiteral(schema['const']))\n } else if (typeof schema['const'] === 'number') {\n return factory.createLiteralTypeNode(factory.createNumericLiteral(schema['const']))\n }\n } else {\n return keywordTypeNodes.null\n }\n }\n\n if (schema.type) {\n if (Array.isArray(schema.type)) {\n // TODO remove hardcoded first type, second nullable\n // OPENAPI v3.1.0: https://www.openapis.org/blog/2021/02/16/migrating-from-openapi-3-0-to-3-1-0\n const [type, nullable] = schema.type as Array<OpenAPIV3_1.NonArraySchemaObjectType>\n\n return factory.createUnionDeclaration({\n nodes: [\n this.getTypeFromSchema(\n {\n ...schema,\n type,\n },\n baseName,\n ),\n nullable ? factory.createLiteralTypeNode(factory.createNull()) : undefined,\n ].filter(Boolean),\n })\n }\n\n if (this.options.dateType === 'date' && ['date', 'date-time'].some((item) => item === schema.format)) {\n return factory.createTypeReferenceNode(factory.createIdentifier('Date'))\n }\n\n // string, boolean, null, number\n if (schema.type in factory.keywordTypeNodes) {\n return factory.keywordTypeNodes[schema.type as keyof typeof factory.keywordTypeNodes]\n }\n }\n\n if (schema.format === 'binary') {\n return factory.createTypeReferenceNode('Blob', [])\n }\n\n return factory.keywordTypeNodes.any\n }\n}\n","import path from 'node:path'\n\nimport { createPlugin, FileManager, PluginManager } from '@kubb/core'\nimport { camelCase, pascalCase } from '@kubb/core/transformers'\nimport { renderTemplate } from '@kubb/core/utils'\nimport { pluginName as swaggerPluginName } from '@kubb/swagger'\n\nimport { OperationGenerator } from './OperationGenerator.tsx'\nimport { TypeBuilder } from './TypeBuilder.ts'\n\nimport type { KubbFile, KubbPlugin } from '@kubb/core'\nimport type { PluginOptions as SwaggerPluginOptions } from '@kubb/swagger'\nimport type { OasTypes } from '@kubb/swagger/oas'\nimport type { PluginOptions } from './types.ts'\nexport const pluginName = 'swagger-ts' satisfies PluginOptions['name']\nexport const pluginKey: PluginOptions['key'] = [pluginName] satisfies PluginOptions['key']\n\nexport const definePlugin = createPlugin<PluginOptions>((options) => {\n const {\n output = { path: 'types' },\n group,\n exclude = [],\n include,\n override = [],\n enumType = 'asConst',\n dateType = 'string',\n optionalType = 'questionToken',\n transformers = {},\n oasType = false,\n } = options\n const template = group?.output ? group.output : `${output.path}/{{tag}}Controller`\n\n return {\n name: pluginName,\n options: {\n transformers,\n dateType,\n enumType,\n optionalType,\n oasType,\n // keep the used enumnames between TypeBuilder and OperationGenerator per plugin(pluginKey)\n usedEnumNames: {},\n },\n pre: [swaggerPluginName],\n resolvePath(baseName, directory, options) {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = FileManager.getMode(path.resolve(root, output.path))\n\n if (mode === 'file') {\n /**\n * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend\n * Other plugins then need to call addOrAppend instead of just add from the fileManager class\n */\n return path.resolve(root, output.path)\n }\n\n if (options?.tag && group?.type === 'tag') {\n const tag = camelCase(options.tag)\n\n return path.resolve(root, renderTemplate(template, { tag }), baseName)\n }\n\n return path.resolve(root, output.path, baseName)\n },\n resolveName(name, type) {\n const resolvedName = pascalCase(name, { isFile: type === 'file' })\n\n if (type) {\n return transformers?.name?.(resolvedName, type) || resolvedName\n }\n\n return resolvedName\n },\n async writeFile(source, writePath) {\n if (!writePath.endsWith('.ts') || !source) {\n return\n }\n\n return this.fileManager.write(source, writePath, { sanity: false })\n },\n async buildStart() {\n const [swaggerPlugin]: [KubbPlugin<SwaggerPluginOptions>] = PluginManager.getDependedPlugins<SwaggerPluginOptions>(this.plugins, [swaggerPluginName])\n\n const oas = await swaggerPlugin.api.getOas()\n\n const schemas = await swaggerPlugin.api.getSchemas()\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = FileManager.getMode(path.resolve(root, output.path))\n const builder = new TypeBuilder(this.plugin.options, { oas, pluginManager: this.pluginManager })\n\n builder.add(\n Object.entries(schemas).map(([name, schema]: [string, OasTypes.SchemaObject]) => ({ name, schema })),\n )\n\n if (mode === 'directory') {\n const mapFolderSchema = async ([name]: [string, OasTypes.SchemaObject]) => {\n const baseName = `${this.resolveName({ name, pluginKey: this.plugin.key, type: 'file' })}.ts` as const\n const resolvedPath = this.resolvePath({ baseName, pluginKey: this.plugin.key })\n const { source, imports } = builder.build(name)\n\n if (!resolvedPath) {\n return null\n }\n\n return this.addFile({\n path: resolvedPath,\n baseName,\n source,\n imports: imports.map(item => ({ ...item, root: resolvedPath })),\n meta: {\n pluginKey: this.plugin.key,\n },\n })\n }\n\n const promises = Object.entries(schemas).map(mapFolderSchema)\n\n await Promise.all(promises)\n }\n\n if (mode === 'file') {\n const resolvedPath = this.resolvePath({ baseName: '', pluginKey: this.plugin.key })\n const { source } = builder.build()\n\n if (!resolvedPath) {\n return\n }\n\n await this.addFile({\n path: resolvedPath,\n baseName: output.path as KubbFile.BaseName,\n source,\n imports: [],\n meta: {\n pluginKey: this.plugin.key,\n },\n })\n }\n\n const operationGenerator = new OperationGenerator(\n this.plugin.options,\n {\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType: swaggerPlugin.api.contentType,\n exclude,\n include,\n override,\n mode,\n },\n )\n\n const files = await operationGenerator.build()\n await this.addFile(...files)\n },\n async buildEnd() {\n if (this.config.output.write === false) {\n return\n }\n\n const root = path.resolve(this.config.root, this.config.output.path)\n\n await this.fileManager.addIndexes({\n root,\n output,\n meta: { pluginKey: this.plugin.key },\n })\n },\n }\n})\n","import { createRoot } from '@kubb/react'\nimport { OperationGenerator as Generator } from '@kubb/swagger'\n\nimport { Mutation } from './components/Mutation.tsx'\nimport { Oas } from './components/Oas.tsx'\nimport { Query } from './components/Query.tsx'\n\nimport type { AppContextProps } from '@kubb/react'\nimport type { OperationMethodResult, OperationSchemas } from '@kubb/swagger'\nimport type { Operation } from '@kubb/swagger/oas'\nimport type { FileMeta, PluginOptions } from './types.ts'\n\nexport class OperationGenerator extends Generator<PluginOptions['resolvedOptions'], PluginOptions> {\n async all(): OperationMethodResult<FileMeta> {\n const { oas, pluginManager, plugin } = this.context\n\n if (!plugin.options.oasType) {\n return null\n }\n\n const root = createRoot<AppContextProps>({ logger: pluginManager.logger })\n root.render(\n <Oas.File name=\"oas\" typeName=\"Oas\" />,\n { meta: { oas, pluginManager, plugin } },\n )\n\n return root.files\n }\n\n async get(operation: Operation, schemas: OperationSchemas, options: PluginOptions['resolvedOptions']): OperationMethodResult<FileMeta> {\n const { oas, pluginManager, plugin, mode = 'directory' } = this.context\n\n const root = createRoot<AppContextProps<PluginOptions['appMeta']>>({ logger: pluginManager.logger })\n root.render(\n <Query.File mode={mode} />,\n { meta: { oas, pluginManager, plugin: { ...plugin, options }, schemas, operation } },\n )\n\n return root.files\n }\n\n async post(operation: Operation, schemas: OperationSchemas, options: PluginOptions['resolvedOptions']): OperationMethodResult<FileMeta> {\n const { oas, pluginManager, plugin, mode = 'directory' } = this.context\n\n const root = createRoot<AppContextProps<PluginOptions['appMeta']>>({ logger: pluginManager.logger })\n root.render(\n <Mutation.File mode={mode} />,\n { meta: { oas, pluginManager, plugin: { ...plugin, options }, schemas, operation } },\n )\n\n return root.files\n }\n\n async put(operation: Operation, schemas: OperationSchemas, options: PluginOptions['resolvedOptions']): OperationMethodResult<FileMeta> {\n return this.post(operation, schemas, options)\n }\n async patch(operation: Operation, schemas: OperationSchemas, options: PluginOptions['resolvedOptions']): OperationMethodResult<FileMeta> {\n return this.post(operation, schemas, options)\n }\n async delete(operation: Operation, schemas: OperationSchemas, options: PluginOptions['resolvedOptions']): OperationMethodResult<FileMeta> {\n return this.post(operation, schemas, options)\n }\n}\n","import { File, Type, usePlugin } from '@kubb/react'\nimport { useFile } from '@kubb/react'\nimport { useOas } from '@kubb/swagger/hooks'\n\nimport type { OasTypes } from '@kubb/swagger/oas'\nimport type { ReactNode } from 'react'\nimport type { FileMeta, PluginOptions } from '../types.ts'\n\ntype TemplateProps = {\n /**\n * Name of the function\n */\n name: string\n typeName: string\n api: OasTypes.OASDocument\n}\n\nfunction Template({\n name,\n typeName,\n api,\n}: TemplateProps): ReactNode {\n return (\n <>\n {`export const ${name} = ${JSON.stringify(api, undefined, 2)} as const`}\n <br />\n <Type name={typeName} export>\n {`Infer<typeof ${name}>`}\n </Type>\n </>\n )\n}\n\nconst defaultTemplates = { default: Template } as const\n\ntype Props = {\n name: string\n typeName: string\n /**\n * This will make it possible to override the default behaviour.\n */\n Template?: React.ComponentType<React.ComponentProps<typeof Template>>\n}\n\nexport function Oas({\n name,\n typeName,\n Template = defaultTemplates.default,\n}: Props): ReactNode {\n const oas = useOas()\n\n return <Template name={name} typeName={typeName} api={oas.api} />\n}\n\ntype FileProps = {\n name: string\n typeName: string\n /**\n * This will make it possible to override the default behaviour.\n */\n templates?: typeof defaultTemplates\n}\n\nOas.File = function({ name, typeName, templates = defaultTemplates }: FileProps): ReactNode {\n const { key: pluginKey } = usePlugin<PluginOptions>()\n const file = useFile({ name, pluginKey })\n\n const Template = templates.default\n\n return (\n <File<FileMeta>\n baseName={file.baseName}\n path={file.path}\n meta={file.meta}\n >\n <File.Import name={['Infer']} path=\"@kubb/swagger-ts/oas\" isTypeOnly />\n <File.Source>\n <Oas Template={Template} name={name} typeName={typeName} />\n </File.Source>\n </File>\n )\n}\n\nOas.templates = defaultTemplates\n","import transformers from '@kubb/core/transformers'\nimport { print } from '@kubb/parser'\nimport * as factory from '@kubb/parser/factory'\nimport { File, usePlugin, usePluginManager } from '@kubb/react'\nimport { useOas, useOperation, useOperationFile, useOperationName, useSchemas } from '@kubb/swagger/hooks'\n\nimport { TypeBuilder } from '../TypeBuilder.ts'\n\nimport type { KubbFile } from '@kubb/core'\nimport type { ts } from '@kubb/parser'\nimport type { OperationSchemas } from '@kubb/swagger'\nimport type { Operation } from '@kubb/swagger/oas'\nimport type { ReactNode } from 'react'\nimport type { FileMeta, PluginOptions } from '../types.ts'\n\ntype Props = {\n builder: TypeBuilder\n}\n\nfunction printCombinedSchema(name: string, operation: Operation, schemas: OperationSchemas): string {\n const properties: Record<string, ts.TypeNode> = {\n 'response': factory.createTypeReferenceNode(\n factory.createIdentifier(schemas.response.name),\n undefined,\n ),\n }\n\n if (schemas.request) {\n properties['request'] = factory.createTypeReferenceNode(\n factory.createIdentifier(schemas.request.name),\n undefined,\n )\n }\n\n if (schemas.pathParams) {\n properties['pathParams'] = factory.createTypeReferenceNode(\n factory.createIdentifier(schemas.pathParams.name),\n undefined,\n )\n }\n\n if (schemas.queryParams) {\n properties['queryParams'] = factory.createTypeReferenceNode(\n factory.createIdentifier(schemas.queryParams.name),\n undefined,\n )\n }\n\n if (schemas.headerParams) {\n properties['headerParams'] = factory.createTypeReferenceNode(\n factory.createIdentifier(schemas.headerParams.name),\n undefined,\n )\n }\n\n if (schemas.errors) {\n properties['errors'] = factory.createUnionDeclaration({\n nodes: schemas.errors.map(error => {\n return factory.createTypeReferenceNode(\n factory.createIdentifier(error.name),\n undefined,\n )\n }),\n })!\n }\n\n const namespaceNode = factory.createTypeAliasDeclaration({\n name: operation.method === 'get' ? `${name}Query` : `${name}Mutation`,\n type: factory.createTypeLiteralNode(\n Object.keys(properties).map(key => {\n const type = properties[key]\n if (!type) {\n return undefined\n }\n\n return factory.createPropertySignature(\n {\n name: transformers.pascalCase(key),\n type,\n },\n )\n }).filter(Boolean),\n ),\n modifiers: [factory.modifiers.export],\n })\n\n return print(namespaceNode)\n}\n\nexport function Query({\n builder,\n}: Props): ReactNode {\n const { source } = builder.build()\n\n return (\n <>\n {source}\n </>\n )\n}\n\ntype FileProps = {\n mode: KubbFile.Mode\n}\n\nQuery.File = function({ mode }: FileProps): ReactNode {\n const { options } = usePlugin<PluginOptions>()\n\n const schemas = useSchemas()\n const pluginManager = usePluginManager()\n const oas = useOas()\n const file = useOperationFile()\n const factoryName = useOperationName({ type: 'type' })\n const operation = useOperation()\n\n const builder = new TypeBuilder(options, { oas, pluginManager })\n .add(schemas.pathParams)\n .add(schemas.queryParams)\n .add(schemas.headerParams)\n .add(schemas.response)\n .add(schemas.errors)\n\n const { source, imports } = builder.build()\n\n return (\n <>\n <File<FileMeta>\n baseName={file.baseName}\n path={file.path}\n meta={file.meta}\n >\n {mode === 'directory' && imports.map((item, index) => {\n return <File.Import key={index} root={file.path} {...item} />\n })}\n <File.Source>\n {source}\n {printCombinedSchema(factoryName, operation, schemas)}\n </File.Source>\n </File>\n </>\n )\n}\n"]}
@@ -132,19 +132,23 @@ function printCombinedSchema(name, operation, schemas) {
132
132
  })
133
133
  });
134
134
  }
135
- const namespaceNode = factory2__namespace.createNamespaceDeclaration({
135
+ const namespaceNode = factory2__namespace.createTypeAliasDeclaration({
136
136
  name: operation.method === "get" ? `${name}Query` : `${name}Mutation`,
137
- statements: Object.keys(properties).map((key) => {
138
- const type = properties[key];
139
- if (!type) {
140
- return void 0;
141
- }
142
- return factory2__namespace.createTypeAliasDeclaration({
143
- modifiers: [factory2__namespace.modifiers.export],
144
- name: transformers2__default.default.pascalCase(key),
145
- type
146
- });
147
- }).filter(Boolean)
137
+ type: factory2__namespace.createTypeLiteralNode(
138
+ Object.keys(properties).map((key) => {
139
+ const type = properties[key];
140
+ if (!type) {
141
+ return void 0;
142
+ }
143
+ return factory2__namespace.createPropertySignature(
144
+ {
145
+ name: transformers2__default.default.pascalCase(key),
146
+ type
147
+ }
148
+ );
149
+ }).filter(Boolean)
150
+ ),
151
+ modifiers: [factory2__namespace.modifiers.export]
148
152
  });
149
153
  return parser.print(namespaceNode);
150
154
  }
@@ -266,7 +270,7 @@ var definePlugin = core.createPlugin((options) => {
266
270
  return path__default.default.resolve(root, output.path, baseName);
267
271
  },
268
272
  resolveName(name, type) {
269
- const resolvedName = transformers2.pascalCase(name);
273
+ const resolvedName = transformers2.pascalCase(name, { isFile: type === "file" });
270
274
  if (type) {
271
275
  return transformers5?.name?.(resolvedName, type) || resolvedName;
272
276
  }
@@ -383,15 +387,19 @@ var TypeGenerator = class extends core.Generator {
383
387
  }
384
388
  build({
385
389
  schema,
390
+ optional,
386
391
  baseName,
387
392
  description,
388
393
  keysToOmit
389
394
  }) {
390
395
  const nodes = [];
391
- const type = this.getTypeFromSchema(schema, baseName);
396
+ let type = this.getTypeFromSchema(schema, baseName);
392
397
  if (!type) {
393
398
  return this.extraNodes;
394
399
  }
400
+ if (optional) {
401
+ type = factory2__namespace.createUnionDeclaration({ nodes: [type, factory2__namespace.keywordTypeNodes.undefined] });
402
+ }
395
403
  const node = factory2__namespace.createTypeAliasDeclaration({
396
404
  modifiers: [factory2__namespace.modifiers.export],
397
405
  name: this.context.pluginManager.resolveName({ name: baseName, pluginKey, type: "type" }),
@@ -486,7 +494,8 @@ getRefAlias_fn = function(obj, _baseName) {
486
494
  propertyName,
487
495
  originalName
488
496
  };
489
- const path2 = this.context.pluginManager.resolvePath({ baseName: propertyName, pluginKey });
497
+ const fileName = this.context.pluginManager.resolveName({ name: originalName, pluginKey, type: "file" });
498
+ const path2 = this.context.pluginManager.resolvePath({ baseName: fileName, pluginKey });
490
499
  this.imports.push({
491
500
  ref,
492
501
  path: path2 || "",
@@ -649,11 +658,13 @@ var TypeBuilder = class extends swagger.OasBuilder {
649
658
  const codes = [];
650
659
  const generated = this.items.filter((operationSchema) => name ? operationSchema.name === name : true).sort(transformers2__default.default.nameSorter).map((operationSchema) => {
651
660
  const generator = new TypeGenerator(this.options, this.context);
661
+ const required = Array.isArray(operationSchema.schema?.required) ? !!operationSchema.schema.required.length : !!operationSchema.schema?.required;
652
662
  const sources = generator.build({
653
663
  schema: operationSchema.schema,
654
664
  baseName: operationSchema.name,
655
665
  description: operationSchema.description,
656
- keysToOmit: operationSchema.keysToOmit
666
+ keysToOmit: operationSchema.keysToOmit,
667
+ optional: !required && !!operationSchema.name.includes("Params")
657
668
  });
658
669
  importMeta.push(...generator.imports);
659
670
  return {
@@ -779,4 +790,4 @@ exports.definePlugin = definePlugin;
779
790
  exports.pluginKey = pluginKey;
780
791
  exports.pluginName = pluginName;
781
792
  //# sourceMappingURL=out.js.map
782
- //# sourceMappingURL=chunk-IPPTNCEN.cjs.map
793
+ //# sourceMappingURL=chunk-CMZLMWOU.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/Mutation.tsx","../src/TypeBuilder.ts","../src/TypeGenerator.ts","../src/plugin.ts","../src/OperationGenerator.tsx","../src/components/Oas.tsx","../src/components/Query.tsx"],"names":["transformers","print","factory","File","usePlugin","usePluginManager","useOas","useOperation","useOperationFile","useOperationName","useSchemas","Generator","keywordTypeNodes","Template","pluginKey","Fragment","jsx","jsxs","options","node","path","printCombinedSchema"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,OAAOA,mBAAkB;AACzB,SAAS,SAAAC,cAAa;AACtB,YAAYC,cAAa;AACzB,SAAS,QAAAC,OAAM,aAAAC,YAAW,oBAAAC,yBAAwB;AAClD,SAAS,UAAAC,SAAQ,gBAAAC,eAAc,oBAAAC,mBAAkB,oBAAAC,mBAAkB,cAAAC,mBAAkB;;;ACJrF,OAAOV,mBAAkB;AACzB,SAAS,SAAAC,cAAa;AACtB,SAAS,kBAAkB;AAC3B,SAAS,kBAAkB;;;ACH3B,SAAS,aAAAU,kBAAiB;AAC1B,OAAOX,mBAAkB;AACzB,SAAS,qBAAqB;AAC9B,YAAYE,cAAa;AACzB,SAAS,oBAAAU,yBAAwB;AACjC,SAAS,kBAAkB,mBAAmB;;;ACL9C,OAAO,UAAU;AAEjB,SAAS,cAAc,aAAa,qBAAqB;AACzD,SAAS,WAAW,kBAAkB;AACtC,SAAS,sBAAsB;AAC/B,SAAS,cAAc,yBAAyB;;;ACLhD,SAAS,kBAAkB;AAC3B,SAAS,sBAAsB,iBAAiB;;;ACDhD,SAAS,MAAM,MAAM,iBAAiB;AACtC,SAAS,eAAe;AACxB,SAAS,cAAc;AAqBnB,mBAEE,KAFF;AANJ,SAAS,SAAS;AAAA,EAChB;AAAA,EACA;AAAA,EACA;AACF,GAA6B;AAC3B,SACE,iCACG;AAAA,oBAAgB,IAAI,MAAM,KAAK,UAAU,KAAK,QAAW,CAAC,CAAC;AAAA,IAC5D,oBAAC,QAAG;AAAA,IACJ,oBAAC,QAAK,MAAM,UAAU,QAAM,MACzB,0BAAgB,IAAI,KACvB;AAAA,KACF;AAEJ;AAEA,IAAM,mBAAmB,EAAE,SAAS,SAAS;AAWtC,SAAS,IAAI;AAAA,EAClB;AAAA,EACA;AAAA,EACA,UAAAC,Y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AM,UAAU,IAAI,YAAY,SAAS,EAAE,KAAK,cAAc,CAAC,EAC5D,IAAI,QAAQ,UAAU,EACtB,IAAI,QAAQ,WAAW,EACvB,IAAI,QAAQ,YAAY,EACxB,IAAI,QAAQ,QAAQ,EACpB,IAAI,QAAQ,OAAO,EACnB,IAAI,QAAQ,MAAM;AAErB,QAAM,EAAE,QAAQ,QAAQ,IAAI,QAAQ,MAAM;AAE1C,SACE,gBAAAS,KAAAD,WAAA,EACE,0BAAAE;AAAA,IAACd;AAAA,IAAA;AAAA,MACC,UAAU,KAAK;AAAA,MACf,MAAM,KAAK;AAAA,MACX,MAAM,KAAK;AAAA,MAEV;AAAA,iBAAS,eAAe,QAAQ,IAAI,CAAC,MAAM,UAAU;AACpD,iBAAO,gBAAAa,KAACb,MAAK,QAAL,EAAwB,MAAM,KAAK,MAAO,GAAG,QAA5B,KAAkC;AAAA,QAC7D,CAAC;AAAA,QACD,gBAAAc,MAACd,MAAK,QAAL,EACE;AAAA;AAAA,UACAkB,qBAAoB,aAAa,WAAW,OAAO;AAAA,WACtD;AAAA;AAAA;AAAA,EACF,GACF;AAEJ","sourcesContent":["import transformers from '@kubb/core/transformers'\nimport { print } from '@kubb/parser'\nimport * as factory from '@kubb/parser/factory'\nimport { File, usePlugin, usePluginManager } from '@kubb/react'\nimport { useOas, useOperation, useOperationFile, useOperationName, useSchemas } from '@kubb/swagger/hooks'\n\nimport { TypeBuilder } from '../TypeBuilder.ts'\n\nimport type { KubbFile } from '@kubb/core'\nimport type { ts } from '@kubb/parser'\nimport type { OperationSchemas } from '@kubb/swagger'\nimport type { Operation } from '@kubb/swagger/oas'\nimport type { ReactNode } from 'react'\nimport type { FileMeta, PluginOptions } from '../types.ts'\n\ntype Props = {\n builder: TypeBuilder\n}\n\nfunction printCombinedSchema(name: string, operation: Operation, schemas: OperationSchemas): string {\n const properties: Record<string, ts.TypeNode> = {\n 'response': factory.createTypeReferenceNode(\n factory.createIdentifier(schemas.response.name),\n undefined,\n ),\n }\n\n if (schemas.request) {\n properties['request'] = factory.createTypeReferenceNode(\n factory.createIdentifier(schemas.request.name),\n undefined,\n )\n }\n\n if (schemas.pathParams) {\n properties['pathParams'] = factory.createTypeReferenceNode(\n factory.createIdentifier(schemas.pathParams.name),\n undefined,\n )\n }\n\n if (schemas.queryParams) {\n properties['queryParams'] = factory.createTypeReferenceNode(\n factory.createIdentifier(schemas.queryParams.name),\n undefined,\n )\n }\n\n if (schemas.headerParams) {\n properties['headerParams'] = factory.createTypeReferenceNode(\n factory.createIdentifier(schemas.headerParams.name),\n undefined,\n )\n }\n\n if (schemas.errors) {\n properties['errors'] = factory.createUnionDeclaration({\n nodes: schemas.errors.map(error => {\n return factory.createTypeReferenceNode(\n factory.createIdentifier(error.name),\n undefined,\n )\n }),\n })!\n }\n\n const namespaceNode = factory.createNamespaceDeclaration({\n name: operation.method === 'get' ? `${name}Query` : `${name}Mutation`,\n statements: Object.keys(properties).map(key => {\n const type = properties[key]\n if (!type) {\n return undefined\n }\n return factory.createTypeAliasDeclaration({\n modifiers: [factory.modifiers.export],\n name: transformers.pascalCase(key),\n type,\n })\n }).filter(Boolean),\n })\n\n return print(namespaceNode)\n}\n\nexport function Mutation({\n builder,\n}: Props): ReactNode {\n const { source } = builder.build()\n\n return (\n <>\n {source}\n </>\n )\n}\n\ntype FileProps = {\n mode: KubbFile.Mode\n}\n\nMutation.File = function({ mode }: FileProps): ReactNode {\n const { options } = usePlugin<PluginOptions>()\n\n const schemas = useSchemas()\n const pluginManager = usePluginManager()\n const oas = useOas()\n const file = useOperationFile()\n const factoryName = useOperationName({ type: 'type' })\n const operation = useOperation()\n\n const builder = new TypeBuilder(options, { oas, pluginManager })\n .add(schemas.pathParams)\n .add(schemas.queryParams)\n .add(schemas.headerParams)\n .add(schemas.response)\n .add(schemas.request)\n .add(schemas.errors)\n\n const { source, imports } = builder.build()\n\n return (\n <>\n <File<FileMeta>\n baseName={file.baseName}\n path={file.path}\n meta={file.meta}\n >\n {mode === 'directory' && imports.map((item, index) => {\n return <File.Import key={index} root={file.path} {...item} />\n })}\n <File.Source>\n {source}\n {printCombinedSchema(factoryName, operation, schemas)}\n </File.Source>\n </File>\n </>\n )\n}\n","import transformers from '@kubb/core/transformers'\nimport { print } from '@kubb/parser'\nimport { OasBuilder } from '@kubb/swagger'\nimport { refsSorter } from '@kubb/swagger/utils'\n\nimport { TypeGenerator } from './TypeGenerator.ts'\n\nimport type { KubbFile } from '@kubb/core'\nimport type { ImportMeta } from '@kubb/swagger'\nimport type { PluginOptions } from './types.ts'\n\nexport class TypeBuilder extends OasBuilder<PluginOptions['resolvedOptions']> {\n build(name?: string): Required<Pick<KubbFile.File, 'imports' | 'source'>> {\n const importMeta: ImportMeta[] = []\n const codes: string[] = []\n\n const generated = this.items\n .filter((operationSchema) => (name ? operationSchema.name === name : true))\n .sort(transformers.nameSorter)\n .map((operationSchema) => {\n const generator = new TypeGenerator(this.options, this.context)\n const required = Array.isArray(operationSchema.schema?.required) ? !!operationSchema.schema.required.length : !!operationSchema.schema?.required\n\n const sources = generator.build({\n schema: operationSchema.schema,\n baseName: operationSchema.name,\n description: operationSchema.description,\n keysToOmit: operationSchema.keysToOmit,\n optional: !required && !!operationSchema.name.includes('Params'),\n })\n\n importMeta.push(...generator.imports)\n\n return {\n import: {\n refs: generator.refs,\n name: operationSchema.name,\n },\n sources,\n }\n })\n .sort(refsSorter)\n\n generated.forEach((item) => {\n codes.push(print(item.sources))\n })\n\n const imports: KubbFile.Import[] = importMeta.map((item) => {\n return {\n name: [item.ref.propertyName],\n path: item.path,\n isTypeOnly: item.isTypeOnly,\n }\n })\n\n return {\n imports,\n source: transformers.combineCodes(codes),\n }\n }\n}\n","import { Generator } from '@kubb/core'\nimport transformers from '@kubb/core/transformers'\nimport { getUniqueName } from '@kubb/core/utils'\nimport * as factory from '@kubb/parser/factory'\nimport { keywordTypeNodes } from '@kubb/parser/factory'\nimport { getSchemaFactory, isReference } from '@kubb/swagger/utils'\n\nimport { pluginKey } from './plugin.ts'\n\nimport type { PluginManager } from '@kubb/core'\nimport type { ts } from '@kubb/parser'\nimport type { ImportMeta, Refs } from '@kubb/swagger'\nimport type { Oas, OasTypes, OpenAPIV3, OpenAPIV3_1 } from '@kubb/swagger/oas'\nimport type { PluginOptions } from './types.ts'\n\n// based on https://github.com/cellular/oazapfts/blob/7ba226ebb15374e8483cc53e7532f1663179a22c/src/codegen/generate.ts#L398\n\ntype Context = {\n oas: Oas\n pluginManager: PluginManager\n}\n\nexport class TypeGenerator extends Generator<PluginOptions['resolvedOptions'], Context> {\n refs: Refs = {}\n imports: ImportMeta[] = []\n\n extraNodes: ts.Node[] = []\n\n aliases: ts.TypeAliasDeclaration[] = []\n\n // Keep track of already used type aliases\n #usedAliasNames: Record<string, number> = {}\n\n build({\n schema,\n optional,\n baseName,\n description,\n keysToOmit,\n }: {\n schema: OasTypes.SchemaObject\n baseName: string\n description?: string\n optional?: boolean\n keysToOmit?: string[]\n }): ts.Node[] {\n const nodes: ts.Node[] = []\n let type = this.getTypeFromSchema(schema, baseName)\n\n if (!type) {\n return this.extraNodes\n }\n\n if (optional) {\n type = factory.createUnionDeclaration({ nodes: [type, factory.keywordTypeNodes.undefined] }) as ts.TypeNode\n }\n\n const node = factory.createTypeAliasDeclaration({\n modifiers: [factory.modifiers.export],\n name: this.context.pluginManager.resolveName({ name: baseName, pluginKey, type: 'type' }),\n type: keysToOmit?.length ? factory.createOmitDeclaration({ keys: keysToOmit, type, nonNullable: true }) : type,\n })\n\n if (description) {\n nodes.push(\n factory.appendJSDocToNode({\n node,\n comments: [`@description ${transformers.trim(description)}`],\n }),\n )\n } else {\n nodes.push(node)\n }\n\n // filter out if the export name is the same as one that we already defined in extraNodes(see enum)\n const filterdNodes = nodes.filter(\n (node: ts.Node) =>\n !this.extraNodes.some(\n (extraNode: ts.Node) => (extraNode as ts.TypeAliasDeclaration)?.name?.escapedText === (node as ts.TypeAliasDeclaration)?.name?.escapedText,\n ),\n )\n\n return [...this.extraNodes, ...filterdNodes]\n }\n\n /**\n * Creates a type node from a given schema.\n * Delegates to getBaseTypeFromSchema internally and\n * optionally adds a union with null.\n */\n getTypeFromSchema(schema?: OasTypes.SchemaObject, name?: string): ts.TypeNode | null {\n const type = this.#getBaseTypeFromSchema(schema, name)\n\n if (!type) {\n return null\n }\n\n if (schema && !schema.nullable) {\n return type\n }\n\n return factory.createUnionDeclaration({ nodes: [type, factory.keywordTypeNodes.null] })\n }\n\n /**\n * Recursively creates a type literal with the given props.\n */\n #getTypeFromProperties(baseSchema?: OasTypes.SchemaObject, baseName?: string): ts.TypeNode | null {\n const { optionalType } = this.options\n const properties = baseSchema?.properties || {}\n const required = baseSchema?.required\n const additionalProperties = baseSchema?.additionalProperties\n\n const members: Array<ts.TypeElement | null> = Object.keys(properties).map((name) => {\n const schema = properties[name] as OasTypes.SchemaObject\n\n const isRequired = Array.isArray(required) ? required.includes(name) : !!required\n let type = this.getTypeFromSchema(schema, this.context.pluginManager.resolveName({ name: `${baseName || ''} ${name}`, pluginKey, type: 'type' }))\n\n if (!type) {\n return null\n }\n\n if (!isRequired && ['undefined', 'questionTokenAndUndefined'].includes(optionalType as string)) {\n type = factory.createUnionDeclaration({ nodes: [type, factory.keywordTypeNodes.undefined] })\n }\n const propertySignature = factory.createPropertySignature({\n questionToken: ['questionToken', 'questionTokenAndUndefined'].includes(optionalType as string) && !isRequired,\n name,\n type: type as ts.TypeNode,\n readOnly: schema.readOnly,\n })\n\n return factory.appendJSDocToNode({\n node: propertySignature,\n comments: [\n schema.description ? `@description ${schema.description}` : undefined,\n schema.type ? `@type ${schema.type?.toString()}${isRequired ? '' : ' | undefined'} ${schema.format || ''}` : undefined,\n schema.example ? `@example ${schema.example as string}` : undefined,\n schema.deprecated ? `@deprecated` : undefined,\n schema.default !== undefined && typeof schema.default === 'string' ? `@default '${schema.default}'` : undefined,\n schema.default !== undefined && typeof schema.default !== 'string' ? `@default ${schema.default as string}` : undefined,\n ].filter(Boolean),\n })\n\n return propertySignature\n })\n if (additionalProperties) {\n const type = additionalProperties === true ? factory.keywordTypeNodes.any : this.getTypeFromSchema(additionalProperties as OasTypes.SchemaObject)\n\n if (type) {\n members.push(factory.createIndexSignature(type))\n }\n }\n return factory.createTypeLiteralNode(members.filter(Boolean))\n }\n\n /**\n * Create a type alias for the schema referenced by the given ReferenceObject\n */\n #getRefAlias(obj: OpenAPIV3.ReferenceObject, _baseName?: string) {\n const { $ref } = obj\n let ref = this.refs[$ref]\n\n if (ref) {\n return factory.createTypeReferenceNode(ref.propertyName, undefined)\n }\n\n const originalName = getUniqueName($ref.replace(/.+\\//, ''), this.#usedAliasNames)\n const propertyName = this.context.pluginManager.resolveName({ name: originalName, pluginKey, type: 'type' })\n\n ref = this.refs[$ref] = {\n propertyName,\n originalName,\n }\n\n const fileName = this.context.pluginManager.resolveName({ name: originalName, pluginKey, type: 'file' })\n const path = this.context.pluginManager.resolvePath({ baseName: fileName, pluginKey })\n\n this.imports.push({\n ref,\n path: path || '',\n isTypeOnly: true,\n })\n\n return factory.createTypeReferenceNode(ref.propertyName, undefined)\n }\n\n #getParsedSchema(schema?: OasTypes.SchemaObject) {\n const parsedSchema = getSchemaFactory(this.context.oas)(schema)\n return parsedSchema\n }\n\n /**\n * This is the very core of the OpenAPI to TS conversion - it takes a\n * schema and returns the appropriate type.\n */\n #getBaseTypeFromSchema(\n _schema: OasTypes.SchemaObject | undefined,\n baseName?: string,\n ): ts.TypeNode | null {\n const { schema, version } = this.#getParsedSchema(_schema)\n\n if (!schema) {\n return factory.keywordTypeNodes.any\n }\n\n if (isReference(schema)) {\n return this.#getRefAlias(schema, baseName)\n }\n\n if (schema.oneOf) {\n // union\n const schemaWithoutOneOf = { ...schema, oneOf: undefined } as OasTypes.SchemaObject\n\n const union = factory.createUnionDeclaration({\n withParentheses: true,\n nodes: schema.oneOf\n .map((item) => {\n return item && this.getTypeFromSchema(item as OasTypes.SchemaObject)\n })\n .filter((item) => {\n return item && item !== factory.keywordTypeNodes.any\n }) as Array<ts.TypeNode>,\n })\n\n if (schemaWithoutOneOf.properties) {\n return factory.createIntersectionDeclaration({\n nodes: [this.getTypeFromSchema(schemaWithoutOneOf, baseName), union].filter(Boolean),\n })\n }\n\n return union\n }\n\n if (schema.anyOf) {\n const schemaWithoutAnyOf = { ...schema, anyOf: undefined } as OasTypes.SchemaObject\n\n const union = factory.createUnionDeclaration({\n withParentheses: true,\n nodes: schema.anyOf\n .map((item) => {\n return item && this.getTypeFromSchema(item as OasTypes.SchemaObject)\n })\n .filter((item) => {\n return item && item !== factory.keywordTypeNodes.any\n }) as Array<ts.TypeNode>,\n })\n\n if (schemaWithoutAnyOf.properties) {\n return factory.createIntersectionDeclaration({\n nodes: [this.getTypeFromSchema(schemaWithoutAnyOf, baseName), union].filter(Boolean),\n })\n }\n\n return union\n }\n if (schema.allOf) {\n // intersection/add\n const schemaWithoutAllOf = { ...schema, allOf: undefined } as OasTypes.SchemaObject\n\n const and = factory.createIntersectionDeclaration({\n withParentheses: true,\n nodes: schema.allOf\n .map((item) => {\n return item && this.getTypeFromSchema(item as OasTypes.SchemaObject)\n })\n .filter((item) => {\n return item && item !== factory.keywordTypeNodes.any\n }) as Array<ts.TypeNode>,\n })\n\n if (schemaWithoutAllOf.properties) {\n return factory.createIntersectionDeclaration({\n nodes: [this.getTypeFromSchema(schemaWithoutAllOf, baseName), and].filter(Boolean),\n })\n }\n\n return and\n }\n\n /**\n * Enum will be defined outside the baseType(hints the baseName check)\n */\n if (schema.enum && baseName) {\n const enumName = getUniqueName(baseName, this.options.usedEnumNames)\n\n let enums: [key: string, value: string | number][] = [...new Set(schema.enum)].map((key) => [key, key])\n\n const extensionEnums: Array<typeof enums> = ['x-enumNames', 'x-enum-varnames']\n .filter(extensionKey => extensionKey in schema)\n .map((extensionKey) =>\n [...new Set(schema[extensionKey as keyof typeof schema] as string[])].map((key, index) => [key, schema.enum?.[index] as string] as const)\n )\n\n if (extensionEnums.length > 0 && extensionEnums[0]) {\n enums = extensionEnums[0]\n }\n\n this.extraNodes.push(\n ...factory.createEnumDeclaration({\n name: transformers.camelCase(enumName),\n typeName: this.context.pluginManager.resolveName({ name: enumName, pluginKey, type: 'type' }),\n enums,\n type: this.options.enumType,\n }),\n )\n return factory.createTypeReferenceNode(this.context.pluginManager.resolveName({ name: enumName, pluginKey, type: 'type' }), undefined)\n }\n\n if (schema.enum) {\n return factory.createUnionDeclaration({\n nodes: schema.enum.map((name) => {\n return factory.createLiteralTypeNode(typeof name === 'number' ? factory.createNumericLiteral(name) : factory.createStringLiteral(`${name}`))\n }) as unknown as Array<ts.TypeNode>,\n })\n }\n\n if ('items' in schema) {\n // items -> array\n const node = this.getTypeFromSchema(schema.items as OasTypes.SchemaObject, baseName)\n if (node) {\n return factory.createArrayTypeNode(node)\n }\n }\n\n /**\n * OpenAPI 3.1\n * @link https://json-schema.org/understanding-json-schema/reference/array.html#tuple-validation\n */\n\n if ('prefixItems' in schema) {\n const prefixItems = schema.prefixItems as OasTypes.SchemaObject[]\n\n return factory.createTupleDeclaration({\n nodes: prefixItems.map((item) => {\n // no baseType so we can fall back on an union when using enum\n return this.getTypeFromSchema(item, undefined)\n }) as Array<ts.TypeNode>,\n })\n }\n\n if (schema.properties || schema.additionalProperties) {\n // properties -> literal type\n return this.#getTypeFromProperties(schema, baseName)\n }\n\n /**\n * validate \"const\" property as defined in JSON-Schema-Validation\n *\n * https://json-schema.org/draft/2020-12/json-schema-validation#name-const\n *\n * > 6.1.3. const\n * > The value of this keyword MAY be of any type, including null.\n * > Use of this keyword is functionally equivalent to an \"enum\" (Section 6.1.2) with a single value.\n * > An instance validates successfully against this keyword if its value is equal to the value of the keyword.\n */\n if (version === '3.1' && 'const' in schema) {\n // const keyword takes precendence over the actual type.\n if (schema['const']) {\n if (typeof schema['const'] === 'string') {\n return factory.createLiteralTypeNode(factory.createStringLiteral(schema['const']))\n } else if (typeof schema['const'] === 'number') {\n return factory.createLiteralTypeNode(factory.createNumericLiteral(schema['const']))\n }\n } else {\n return keywordTypeNodes.null\n }\n }\n\n if (schema.type) {\n if (Array.isArray(schema.type)) {\n // TODO remove hardcoded first type, second nullable\n // OPENAPI v3.1.0: https://www.openapis.org/blog/2021/02/16/migrating-from-openapi-3-0-to-3-1-0\n const [type, nullable] = schema.type as Array<OpenAPIV3_1.NonArraySchemaObjectType>\n\n return factory.createUnionDeclaration({\n nodes: [\n this.getTypeFromSchema(\n {\n ...schema,\n type,\n },\n baseName,\n ),\n nullable ? factory.createLiteralTypeNode(factory.createNull()) : undefined,\n ].filter(Boolean),\n })\n }\n\n if (this.options.dateType === 'date' && ['date', 'date-time'].some((item) => item === schema.format)) {\n return factory.createTypeReferenceNode(factory.createIdentifier('Date'))\n }\n\n // string, boolean, null, number\n if (schema.type in factory.keywordTypeNodes) {\n return factory.keywordTypeNodes[schema.type as keyof typeof factory.keywordTypeNodes]\n }\n }\n\n if (schema.format === 'binary') {\n return factory.createTypeReferenceNode('Blob', [])\n }\n\n return factory.keywordTypeNodes.any\n }\n}\n","import path from 'node:path'\n\nimport { createPlugin, FileManager, PluginManager } from '@kubb/core'\nimport { camelCase, pascalCase } from '@kubb/core/transformers'\nimport { renderTemplate } from '@kubb/core/utils'\nimport { pluginName as swaggerPluginName } from '@kubb/swagger'\n\nimport { OperationGenerator } from './OperationGenerator.tsx'\nimport { TypeBuilder } from './TypeBuilder.ts'\n\nimport type { KubbFile, KubbPlugin } from '@kubb/core'\nimport type { PluginOptions as SwaggerPluginOptions } from '@kubb/swagger'\nimport type { OasTypes } from '@kubb/swagger/oas'\nimport type { PluginOptions } from './types.ts'\nexport const pluginName = 'swagger-ts' satisfies PluginOptions['name']\nexport const pluginKey: PluginOptions['key'] = [pluginName] satisfies PluginOptions['key']\n\nexport const definePlugin = createPlugin<PluginOptions>((options) => {\n const {\n output = { path: 'types' },\n group,\n exclude = [],\n include,\n override = [],\n enumType = 'asConst',\n dateType = 'string',\n optionalType = 'questionToken',\n transformers = {},\n oasType = false,\n } = options\n const template = group?.output ? group.output : `${output.path}/{{tag}}Controller`\n\n return {\n name: pluginName,\n options: {\n transformers,\n dateType,\n enumType,\n optionalType,\n oasType,\n // keep the used enumnames between TypeBuilder and OperationGenerator per plugin(pluginKey)\n usedEnumNames: {},\n },\n pre: [swaggerPluginName],\n resolvePath(baseName, directory, options) {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = FileManager.getMode(path.resolve(root, output.path))\n\n if (mode === 'file') {\n /**\n * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend\n * Other plugins then need to call addOrAppend instead of just add from the fileManager class\n */\n return path.resolve(root, output.path)\n }\n\n if (options?.tag && group?.type === 'tag') {\n const tag = camelCase(options.tag)\n\n return path.resolve(root, renderTemplate(template, { tag }), baseName)\n }\n\n return path.resolve(root, output.path, baseName)\n },\n resolveName(name, type) {\n const resolvedName = pascalCase(name, { isFile: type === 'file' })\n\n if (type) {\n return transformers?.name?.(resolvedName, type) || resolvedName\n }\n\n return resolvedName\n },\n async writeFile(source, writePath) {\n if (!writePath.endsWith('.ts') || !source) {\n return\n }\n\n return this.fileManager.write(source, writePath, { sanity: false })\n },\n async buildStart() {\n const [swaggerPlugin]: [KubbPlugin<SwaggerPluginOptions>] = PluginManager.getDependedPlugins<SwaggerPluginOptions>(this.plugins, [swaggerPluginName])\n\n const oas = await swaggerPlugin.api.getOas()\n\n const schemas = await swaggerPlugin.api.getSchemas()\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = FileManager.getMode(path.resolve(root, output.path))\n const builder = new TypeBuilder(this.plugin.options, { oas, pluginManager: this.pluginManager })\n\n builder.add(\n Object.entries(schemas).map(([name, schema]: [string, OasTypes.SchemaObject]) => ({ name, schema })),\n )\n\n if (mode === 'directory') {\n const mapFolderSchema = async ([name]: [string, OasTypes.SchemaObject]) => {\n const baseName = `${this.resolveName({ name, pluginKey: this.plugin.key, type: 'file' })}.ts` as const\n const resolvedPath = this.resolvePath({ baseName, pluginKey: this.plugin.key })\n const { source, imports } = builder.build(name)\n\n if (!resolvedPath) {\n return null\n }\n\n return this.addFile({\n path: resolvedPath,\n baseName,\n source,\n imports: imports.map(item => ({ ...item, root: resolvedPath })),\n meta: {\n pluginKey: this.plugin.key,\n },\n })\n }\n\n const promises = Object.entries(schemas).map(mapFolderSchema)\n\n await Promise.all(promises)\n }\n\n if (mode === 'file') {\n const resolvedPath = this.resolvePath({ baseName: '', pluginKey: this.plugin.key })\n const { source } = builder.build()\n\n if (!resolvedPath) {\n return\n }\n\n await this.addFile({\n path: resolvedPath,\n baseName: output.path as KubbFile.BaseName,\n source,\n imports: [],\n meta: {\n pluginKey: this.plugin.key,\n },\n })\n }\n\n const operationGenerator = new OperationGenerator(\n this.plugin.options,\n {\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType: swaggerPlugin.api.contentType,\n exclude,\n include,\n override,\n mode,\n },\n )\n\n const files = await operationGenerator.build()\n await this.addFile(...files)\n },\n async buildEnd() {\n if (this.config.output.write === false) {\n return\n }\n\n const root = path.resolve(this.config.root, this.config.output.path)\n\n await this.fileManager.addIndexes({\n root,\n output,\n meta: { pluginKey: this.plugin.key },\n })\n },\n }\n})\n","import { createRoot } from '@kubb/react'\nimport { OperationGenerator as Generator } from '@kubb/swagger'\n\nimport { Mutation } from './components/Mutation.tsx'\nimport { Oas } from './components/Oas.tsx'\nimport { Query } from './components/Query.tsx'\n\nimport type { AppContextProps } from '@kubb/react'\nimport type { OperationMethodResult, OperationSchemas } from '@kubb/swagger'\nimport type { Operation } from '@kubb/swagger/oas'\nimport type { FileMeta, PluginOptions } from './types.ts'\n\nexport class OperationGenerator extends Generator<PluginOptions['resolvedOptions'], PluginOptions> {\n async all(): OperationMethodResult<FileMeta> {\n const { oas, pluginManager, plugin } = this.context\n\n if (!plugin.options.oasType) {\n return null\n }\n\n const root = createRoot<AppContextProps>({ logger: pluginManager.logger })\n root.render(\n <Oas.File name=\"oas\" typeName=\"Oas\" />,\n { meta: { oas, pluginManager, plugin } },\n )\n\n return root.files\n }\n\n async get(operation: Operation, schemas: OperationSchemas, options: PluginOptions['resolvedOptions']): OperationMethodResult<FileMeta> {\n const { oas, pluginManager, plugin, mode = 'directory' } = this.context\n\n const root = createRoot<AppContextProps<PluginOptions['appMeta']>>({ logger: pluginManager.logger })\n root.render(\n <Query.File mode={mode} />,\n { meta: { oas, pluginManager, plugin: { ...plugin, options }, schemas, operation } },\n )\n\n return root.files\n }\n\n async post(operation: Operation, schemas: OperationSchemas, options: PluginOptions['resolvedOptions']): OperationMethodResult<FileMeta> {\n const { oas, pluginManager, plugin, mode = 'directory' } = this.context\n\n const root = createRoot<AppContextProps<PluginOptions['appMeta']>>({ logger: pluginManager.logger })\n root.render(\n <Mutation.File mode={mode} />,\n { meta: { oas, pluginManager, plugin: { ...plugin, options }, schemas, operation } },\n )\n\n return root.files\n }\n\n async put(operation: Operation, schemas: OperationSchemas, options: PluginOptions['resolvedOptions']): OperationMethodResult<FileMeta> {\n return this.post(operation, schemas, options)\n }\n async patch(operation: Operation, schemas: OperationSchemas, options: PluginOptions['resolvedOptions']): OperationMethodResult<FileMeta> {\n return this.post(operation, schemas, options)\n }\n async delete(operation: Operation, schemas: OperationSchemas, options: PluginOptions['resolvedOptions']): OperationMethodResult<FileMeta> {\n return this.post(operation, schemas, options)\n }\n}\n","import { File, Type, usePlugin } from '@kubb/react'\nimport { useFile } from '@kubb/react'\nimport { useOas } from '@kubb/swagger/hooks'\n\nimport type { OasTypes } from '@kubb/swagger/oas'\nimport type { ReactNode } from 'react'\nimport type { FileMeta, PluginOptions } from '../types.ts'\n\ntype TemplateProps = {\n /**\n * Name of the function\n */\n name: string\n typeName: string\n api: OasTypes.OASDocument\n}\n\nfunction Template({\n name,\n typeName,\n api,\n}: TemplateProps): ReactNode {\n return (\n <>\n {`export const ${name} = ${JSON.stringify(api, undefined, 2)} as const`}\n <br />\n <Type name={typeName} export>\n {`Infer<typeof ${name}>`}\n </Type>\n </>\n )\n}\n\nconst defaultTemplates = { default: Template } as const\n\ntype Props = {\n name: string\n typeName: string\n /**\n * This will make it possible to override the default behaviour.\n */\n Template?: React.ComponentType<React.ComponentProps<typeof Template>>\n}\n\nexport function Oas({\n name,\n typeName,\n Template = defaultTemplates.default,\n}: Props): ReactNode {\n const oas = useOas()\n\n return <Template name={name} typeName={typeName} api={oas.api} />\n}\n\ntype FileProps = {\n name: string\n typeName: string\n /**\n * This will make it possible to override the default behaviour.\n */\n templates?: typeof defaultTemplates\n}\n\nOas.File = function({ name, typeName, templates = defaultTemplates }: FileProps): ReactNode {\n const { key: pluginKey } = usePlugin<PluginOptions>()\n const file = useFile({ name, pluginKey })\n\n const Template = templates.default\n\n return (\n <File<FileMeta>\n baseName={file.baseName}\n path={file.path}\n meta={file.meta}\n >\n <File.Import name={['Infer']} path=\"@kubb/swagger-ts/oas\" isTypeOnly />\n <File.Source>\n <Oas Template={Template} name={name} typeName={typeName} />\n </File.Source>\n </File>\n )\n}\n\nOas.templates = defaultTemplates\n","import transformers from '@kubb/core/transformers'\nimport { print } from '@kubb/parser'\nimport * as factory from '@kubb/parser/factory'\nimport { File, usePlugin, usePluginManager } from '@kubb/react'\nimport { useOas, useOperation, useOperationFile, useOperationName, useSchemas } from '@kubb/swagger/hooks'\n\nimport { TypeBuilder } from '../TypeBuilder.ts'\n\nimport type { KubbFile } from '@kubb/core'\nimport type { ts } from '@kubb/parser'\nimport type { OperationSchemas } from '@kubb/swagger'\nimport type { Operation } from '@kubb/swagger/oas'\nimport type { ReactNode } from 'react'\nimport type { FileMeta, PluginOptions } from '../types.ts'\n\ntype Props = {\n builder: TypeBuilder\n}\n\nfunction printCombinedSchema(name: string, operation: Operation, schemas: OperationSchemas): string {\n const properties: Record<string, ts.TypeNode> = {\n 'response': factory.createTypeReferenceNode(\n factory.createIdentifier(schemas.response.name),\n undefined,\n ),\n }\n\n if (schemas.request) {\n properties['request'] = factory.createTypeReferenceNode(\n factory.createIdentifier(schemas.request.name),\n undefined,\n )\n }\n\n if (schemas.pathParams) {\n properties['pathParams'] = factory.createTypeReferenceNode(\n factory.createIdentifier(schemas.pathParams.name),\n undefined,\n )\n }\n\n if (schemas.queryParams) {\n properties['queryParams'] = factory.createTypeReferenceNode(\n factory.createIdentifier(schemas.queryParams.name),\n undefined,\n )\n }\n\n if (schemas.headerParams) {\n properties['headerParams'] = factory.createTypeReferenceNode(\n factory.createIdentifier(schemas.headerParams.name),\n undefined,\n )\n }\n\n if (schemas.errors) {\n properties['errors'] = factory.createUnionDeclaration({\n nodes: schemas.errors.map(error => {\n return factory.createTypeReferenceNode(\n factory.createIdentifier(error.name),\n undefined,\n )\n }),\n })!\n }\n\n const namespaceNode = factory.createTypeAliasDeclaration({\n name: operation.method === 'get' ? `${name}Query` : `${name}Mutation`,\n type: factory.createTypeLiteralNode(\n Object.keys(properties).map(key => {\n const type = properties[key]\n if (!type) {\n return undefined\n }\n\n return factory.createPropertySignature(\n {\n name: transformers.pascalCase(key),\n type,\n },\n )\n }).filter(Boolean),\n ),\n modifiers: [factory.modifiers.export],\n })\n\n return print(namespaceNode)\n}\n\nexport function Query({\n builder,\n}: Props): ReactNode {\n const { source } = builder.build()\n\n return (\n <>\n {source}\n </>\n )\n}\n\ntype FileProps = {\n mode: KubbFile.Mode\n}\n\nQuery.File = function({ mode }: FileProps): ReactNode {\n const { options } = usePlugin<PluginOptions>()\n\n const schemas = useSchemas()\n const pluginManager = usePluginManager()\n const oas = useOas()\n const file = useOperationFile()\n const factoryName = useOperationName({ type: 'type' })\n const operation = useOperation()\n\n const builder = new TypeBuilder(options, { oas, pluginManager })\n .add(schemas.pathParams)\n .add(schemas.queryParams)\n .add(schemas.headerParams)\n .add(schemas.response)\n .add(schemas.errors)\n\n const { source, imports } = builder.build()\n\n return (\n <>\n <File<FileMeta>\n baseName={file.baseName}\n path={file.path}\n meta={file.meta}\n >\n {mode === 'directory' && imports.map((item, index) => {\n return <File.Import key={index} root={file.path} {...item} />\n })}\n <File.Source>\n {source}\n {printCombinedSchema(factoryName, operation, schemas)}\n </File.Source>\n </File>\n </>\n )\n}\n"]}
@@ -1,20 +1,20 @@
1
1
  'use strict';
2
2
 
3
- var chunkIPPTNCEN_cjs = require('./chunk-IPPTNCEN.cjs');
3
+ var chunkCMZLMWOU_cjs = require('./chunk-CMZLMWOU.cjs');
4
4
 
5
5
 
6
6
 
7
7
  Object.defineProperty(exports, "Mutation", {
8
8
  enumerable: true,
9
- get: function () { return chunkIPPTNCEN_cjs.Mutation; }
9
+ get: function () { return chunkCMZLMWOU_cjs.Mutation; }
10
10
  });
11
11
  Object.defineProperty(exports, "Oas", {
12
12
  enumerable: true,
13
- get: function () { return chunkIPPTNCEN_cjs.Oas; }
13
+ get: function () { return chunkCMZLMWOU_cjs.Oas; }
14
14
  });
15
15
  Object.defineProperty(exports, "Query", {
16
16
  enumerable: true,
17
- get: function () { return chunkIPPTNCEN_cjs.Query; }
17
+ get: function () { return chunkCMZLMWOU_cjs.Query; }
18
18
  });
19
19
  //# sourceMappingURL=out.js.map
20
20
  //# sourceMappingURL=components.cjs.map
@@ -1,3 +1,3 @@
1
- export { Mutation, Oas, Query } from './chunk-RKPGFITS.js';
1
+ export { Mutation, Oas, Query } from './chunk-7UWJRVRW.js';
2
2
  //# sourceMappingURL=out.js.map
3
3
  //# sourceMappingURL=components.js.map