@kubb/swagger-ts 2.11.1 → 2.12.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/src/typeParser.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import transformers from '@kubb/core/transformers'
2
2
  import { print } from '@kubb/parser'
3
3
  import * as factory from '@kubb/parser/factory'
4
- import { isKeyword, SchemaGenerator, schemaKeywords } from '@kubb/swagger'
4
+ import { SchemaGenerator, isKeyword, schemaKeywords } from '@kubb/swagger'
5
5
 
6
6
  import type { ts } from '@kubb/parser'
7
7
  import type { Schema, SchemaKeywordMapper, SchemaMapper } from '@kubb/swagger'
@@ -18,7 +18,6 @@ export const typeKeywordMapper = {
18
18
 
19
19
  return factory.createTypeLiteralNode(nodes)
20
20
  },
21
- lazy: undefined,
22
21
  string: () => factory.keywordTypeNodes.string,
23
22
  boolean: () => factory.keywordTypeNodes.boolean,
24
23
  undefined: () => factory.keywordTypeNodes.undefined,
@@ -107,7 +106,7 @@ export const typeKeywordMapper = {
107
106
  type: undefined,
108
107
  format: undefined,
109
108
  catchall: undefined,
110
- } satisfies SchemaMapper<(ctx?: any) => ts.Node | null | undefined>
109
+ } satisfies SchemaMapper<ts.Node | null | undefined>
111
110
 
112
111
  type ParserOptions = {
113
112
  name: string
@@ -122,63 +121,50 @@ type ParserOptions = {
122
121
  */
123
122
  enumType: 'enum' | 'asConst' | 'asPascalConst' | 'constEnum' | 'literal'
124
123
  keysToOmit?: string[]
125
- mapper?: typeof typeKeywordMapper
124
+ mapper?: SchemaMapper
126
125
  }
127
126
 
128
- export function parseTypeMeta(item: Schema, options: ParserOptions): ts.Node | null | undefined {
129
- const mapper = options.mapper || typeKeywordMapper
130
- const value = mapper[item.keyword as keyof typeof mapper]
127
+ export function parseTypeMeta(parent: Schema | undefined, current: Schema, options: ParserOptions): ts.Node | null | undefined {
128
+ const value = typeKeywordMapper[current.keyword as keyof typeof typeKeywordMapper]
131
129
 
132
130
  if (!value) {
133
131
  return undefined
134
132
  }
135
133
 
136
- if (isKeyword(item, schemaKeywords.union)) {
137
- const value = mapper[item.keyword as keyof typeof mapper] as typeof typeKeywordMapper['union']
138
- return value(item.args.map(orItem => parseTypeMeta(orItem, options)).filter(Boolean) as ts.TypeNode[])
134
+ if (isKeyword(current, schemaKeywords.union)) {
135
+ return typeKeywordMapper.union(current.args.map((schema) => parseTypeMeta(current, schema, options)).filter(Boolean) as ts.TypeNode[])
139
136
  }
140
137
 
141
- if (isKeyword(item, schemaKeywords.and)) {
142
- const value = mapper[item.keyword as keyof typeof mapper] as typeof typeKeywordMapper['and']
143
- return value(item.args.map(orItem => parseTypeMeta(orItem, options)).filter(Boolean) as ts.TypeNode[])
138
+ if (isKeyword(current, schemaKeywords.and)) {
139
+ return typeKeywordMapper.and(current.args.map((schema) => parseTypeMeta(current, schema, options)).filter(Boolean) as ts.TypeNode[])
144
140
  }
145
141
 
146
- if (isKeyword(item, schemaKeywords.array)) {
147
- const value = mapper[item.keyword as keyof typeof mapper] as typeof typeKeywordMapper['array']
148
- return value(item.args.items.map(orItem => parseTypeMeta(orItem, options)).filter(Boolean) as ts.TypeNode[])
142
+ if (isKeyword(current, schemaKeywords.array)) {
143
+ return typeKeywordMapper.array(current.args.items.map((schema) => parseTypeMeta(current, schema, options)).filter(Boolean) as ts.TypeNode[])
149
144
  }
150
145
 
151
- if (isKeyword(item, schemaKeywords.enum)) {
152
- const value = mapper[item.keyword as keyof typeof mapper] as typeof typeKeywordMapper['enum']
153
- return value(item.args.typeName)
146
+ if (isKeyword(current, schemaKeywords.enum)) {
147
+ return typeKeywordMapper.enum(current.args.typeName)
154
148
  }
155
149
 
156
- if (isKeyword(item, schemaKeywords.ref)) {
157
- const value = mapper[item.keyword as keyof typeof mapper] as typeof typeKeywordMapper['ref']
158
- return value(item.args.name)
150
+ if (isKeyword(current, schemaKeywords.ref)) {
151
+ return typeKeywordMapper.ref(current.args.name)
159
152
  }
160
153
 
161
- if (isKeyword(item, schemaKeywords.blob)) {
154
+ if (isKeyword(current, schemaKeywords.blob)) {
162
155
  return value()
163
156
  }
164
157
 
165
- if (isKeyword(item, schemaKeywords.tuple)) {
166
- const value = mapper[item.keyword as keyof typeof mapper] as typeof typeKeywordMapper['tuple']
167
- return value(
168
- item.args.map(tupleItem => parseTypeMeta(tupleItem, options)).filter(Boolean) as ts.TypeNode[],
169
- )
158
+ if (isKeyword(current, schemaKeywords.tuple)) {
159
+ return typeKeywordMapper.tuple(current.args.map((schema) => parseTypeMeta(current, schema, options)).filter(Boolean) as ts.TypeNode[])
170
160
  }
171
161
 
172
- if (isKeyword(item, schemaKeywords.const)) {
173
- const value = mapper[item.keyword as keyof typeof mapper] as typeof typeKeywordMapper['const']
174
-
175
- return value(item.args.name, item.args.format)
162
+ if (isKeyword(current, schemaKeywords.const)) {
163
+ return typeKeywordMapper.const(current.args.name, current.args.format)
176
164
  }
177
165
 
178
- if (isKeyword(item, schemaKeywords.object)) {
179
- const value = mapper[item.keyword as keyof typeof mapper] as typeof typeKeywordMapper['object']
180
-
181
- const properties = Object.entries(item.args?.properties || {})
166
+ if (isKeyword(current, schemaKeywords.object)) {
167
+ const properties = Object.entries(current.args?.properties || {})
182
168
  .filter((item) => {
183
169
  const schemas = item[1]
184
170
  return schemas && typeof schemas.map === 'function'
@@ -187,31 +173,35 @@ export function parseTypeMeta(item: Schema, options: ParserOptions): ts.Node | n
187
173
  const name = item[0]
188
174
  const schemas = item[1]
189
175
 
190
- const isNullish = schemas.some(item => item.keyword === schemaKeywords.nullish)
191
- const isNullable = schemas.some(item => item.keyword === schemaKeywords.nullable)
192
- const isOptional = schemas.some(item => item.keyword === schemaKeywords.optional)
193
- const isReadonly = schemas.some(item => item.keyword === schemaKeywords.readOnly)
194
- const describeSchema = schemas.find(item => item.keyword === schemaKeywords.describe) as SchemaKeywordMapper['describe'] | undefined
195
- const deprecatedSchema = schemas.find(item => item.keyword === schemaKeywords.deprecated) as SchemaKeywordMapper['deprecated'] | undefined
196
- const defaultSchema = schemas.find(item => item.keyword === schemaKeywords.default) as SchemaKeywordMapper['default'] | undefined
197
- const exampleSchema = schemas.find(item => item.keyword === schemaKeywords.example) as SchemaKeywordMapper['example'] | undefined
198
- const typeSchema = schemas.find(item => item.keyword === schemaKeywords.type) as SchemaKeywordMapper['type'] | undefined
199
- const formatSchema = schemas.find(item => item.keyword === schemaKeywords.format) as SchemaKeywordMapper['format'] | undefined
200
-
201
- let type = schemas
202
- .map((item) => parseTypeMeta(item, options))
203
- .filter(Boolean)[0] as ts.TypeNode
176
+ const isNullish = schemas.some((schema) => schema.keyword === schemaKeywords.nullish)
177
+ const isNullable = schemas.some((schema) => schema.keyword === schemaKeywords.nullable)
178
+ const isOptional = schemas.some((schema) => schema.keyword === schemaKeywords.optional)
179
+ const isReadonly = schemas.some((schema) => schema.keyword === schemaKeywords.readOnly)
180
+ const describeSchema = schemas.find((schema) => schema.keyword === schemaKeywords.describe) as SchemaKeywordMapper['describe'] | undefined
181
+ const deprecatedSchema = schemas.find((schema) => schema.keyword === schemaKeywords.deprecated) as SchemaKeywordMapper['deprecated'] | undefined
182
+ const defaultSchema = schemas.find((schema) => schema.keyword === schemaKeywords.default) as SchemaKeywordMapper['default'] | undefined
183
+ const exampleSchema = schemas.find((schema) => schema.keyword === schemaKeywords.example) as SchemaKeywordMapper['example'] | undefined
184
+ const typeSchema = schemas.find((schema) => schema.keyword === schemaKeywords.type) as SchemaKeywordMapper['type'] | undefined
185
+ const formatSchema = schemas.find((schema) => schema.keyword === schemaKeywords.format) as SchemaKeywordMapper['format'] | undefined
186
+
187
+ let type = schemas.map((schema) => parseTypeMeta(current, schema, options)).filter(Boolean)[0] as ts.TypeNode
204
188
 
205
189
  if (isNullable) {
206
- type = factory.createUnionDeclaration({ nodes: [type, factory.keywordTypeNodes.null] }) as ts.TypeNode
190
+ type = factory.createUnionDeclaration({
191
+ nodes: [type, factory.keywordTypeNodes.null],
192
+ }) as ts.TypeNode
207
193
  }
208
194
 
209
195
  if (isNullish && ['undefined', 'questionTokenAndUndefined'].includes(options.optionalType as string)) {
210
- type = factory.createUnionDeclaration({ nodes: [type, factory.keywordTypeNodes.undefined] }) as ts.TypeNode
196
+ type = factory.createUnionDeclaration({
197
+ nodes: [type, factory.keywordTypeNodes.undefined],
198
+ }) as ts.TypeNode
211
199
  }
212
200
 
213
201
  if (isOptional && ['undefined', 'questionTokenAndUndefined'].includes(options.optionalType as string)) {
214
- type = factory.createUnionDeclaration({ nodes: [type, factory.keywordTypeNodes.undefined] }) as ts.TypeNode
202
+ type = factory.createUnionDeclaration({
203
+ nodes: [type, factory.keywordTypeNodes.undefined],
204
+ }) as ts.TypeNode
215
205
  }
216
206
 
217
207
  const propertySignature = factory.createPropertySignature({
@@ -225,36 +215,34 @@ export function parseTypeMeta(item: Schema, options: ParserOptions): ts.Node | n
225
215
  node: propertySignature,
226
216
  comments: [
227
217
  describeSchema ? `@description ${transformers.jsStringEscape(describeSchema.args)}` : undefined,
228
- deprecatedSchema ? `@deprecated` : undefined,
229
- defaultSchema
230
- ? `@default ${defaultSchema.args}`
231
- : undefined,
218
+ deprecatedSchema ? '@deprecated' : undefined,
219
+ defaultSchema ? `@default ${defaultSchema.args}` : undefined,
232
220
  exampleSchema ? `@example ${exampleSchema.args}` : undefined,
233
- typeSchema
234
- ? `@type ${typeSchema.args}${!isOptional ? '' : ' | undefined'} ${formatSchema?.args || ''}`
235
- : undefined,
221
+ typeSchema ? `@type ${typeSchema.args}${!isOptional ? '' : ' | undefined'} ${formatSchema?.args || ''}` : undefined,
236
222
  ].filter(Boolean),
237
223
  })
238
224
  })
239
225
 
240
- const additionalProperties = item.args?.additionalProperties?.length
241
- ? factory.createIndexSignature(item.args.additionalProperties.map(schema => parseTypeMeta(schema, options)).filter(Boolean).at(0) as ts.TypeNode)
226
+ const additionalProperties = current.args?.additionalProperties?.length
227
+ ? factory.createIndexSignature(
228
+ current.args.additionalProperties
229
+ .map((schema) => parseTypeMeta(current, schema, options))
230
+ .filter(Boolean)
231
+ .at(0) as ts.TypeNode,
232
+ )
242
233
  : undefined
243
234
 
244
- return value([...properties, additionalProperties].filter(Boolean))
235
+ return typeKeywordMapper.object([...properties, additionalProperties].filter(Boolean))
245
236
  }
246
237
 
247
- if (item.keyword in mapper) {
238
+ if (current.keyword in typeKeywordMapper) {
248
239
  return value()
249
240
  }
250
241
 
251
242
  return undefined
252
243
  }
253
244
 
254
- export function typeParser(
255
- schemas: Schema[],
256
- options: ParserOptions,
257
- ): string {
245
+ export function typeParser(schemas: Schema[], options: ParserOptions): string {
258
246
  const nodes: ts.Node[] = []
259
247
  const extraNodes: ts.Node[] = []
260
248
 
@@ -262,54 +250,66 @@ export function typeParser(
262
250
  return ''
263
251
  }
264
252
 
265
- const isNullish = schemas.some(item => item.keyword === schemaKeywords.nullish)
266
- const isNullable = schemas.some(item => item.keyword === schemaKeywords.nullable)
267
- const isOptional = schemas.some(item => item.keyword === schemaKeywords.optional)
253
+ const isNullish = schemas.some((item) => item.keyword === schemaKeywords.nullish)
254
+ const isNullable = schemas.some((item) => item.keyword === schemaKeywords.nullable)
255
+ const isOptional = schemas.some((item) => item.keyword === schemaKeywords.optional)
268
256
 
269
- let type = schemas.map((schema) => parseTypeMeta(schema, options)).filter(Boolean).at(0) as ts.TypeNode
270
- || typeKeywordMapper.undefined()
257
+ let type =
258
+ (schemas
259
+ .map((schema) => parseTypeMeta(undefined, schema, options))
260
+ .filter(Boolean)
261
+ .at(0) as ts.TypeNode) || typeKeywordMapper.undefined()
271
262
 
272
263
  if (isNullable) {
273
- type = factory.createUnionDeclaration({ nodes: [type, factory.keywordTypeNodes.null] }) as ts.TypeNode
264
+ type = factory.createUnionDeclaration({
265
+ nodes: [type, factory.keywordTypeNodes.null],
266
+ }) as ts.TypeNode
274
267
  }
275
268
 
276
269
  if (isNullish && ['undefined', 'questionTokenAndUndefined'].includes(options.optionalType as string)) {
277
- type = factory.createUnionDeclaration({ nodes: [type, factory.keywordTypeNodes.undefined] }) as ts.TypeNode
270
+ type = factory.createUnionDeclaration({
271
+ nodes: [type, factory.keywordTypeNodes.undefined],
272
+ }) as ts.TypeNode
278
273
  }
279
274
 
280
275
  if (isOptional && ['undefined', 'questionTokenAndUndefined'].includes(options.optionalType as string)) {
281
- type = factory.createUnionDeclaration({ nodes: [type, factory.keywordTypeNodes.undefined] }) as ts.TypeNode
276
+ type = factory.createUnionDeclaration({
277
+ nodes: [type, factory.keywordTypeNodes.undefined],
278
+ }) as ts.TypeNode
282
279
  }
283
280
 
284
281
  const node = factory.createTypeAliasDeclaration({
285
282
  modifiers: [factory.modifiers.export],
286
283
  name: options.name,
287
- type: options.keysToOmit?.length ? factory.createOmitDeclaration({ keys: options.keysToOmit, type, nonNullable: true }) : type,
284
+ type: options.keysToOmit?.length
285
+ ? factory.createOmitDeclaration({
286
+ keys: options.keysToOmit,
287
+ type,
288
+ nonNullable: true,
289
+ })
290
+ : type,
288
291
  })
289
292
 
290
293
  const enumSchemas = SchemaGenerator.deepSearch(schemas, schemaKeywords.enum)
291
294
  if (enumSchemas) {
292
- enumSchemas.forEach(enumSchema => {
293
- extraNodes.push(...factory.createEnumDeclaration({
294
- name: transformers.camelCase(enumSchema.args.name),
295
- typeName: enumSchema.args.typeName,
296
- enums: enumSchema.args.items.map(item => item.value === undefined ? undefined : [transformers.trimQuotes(item.name?.toString()), item.value]).filter(
297
- Boolean,
298
- ) as unknown as [
299
- string,
300
- string,
301
- ][],
302
- type: options.enumType,
303
- }))
295
+ enumSchemas.forEach((enumSchema) => {
296
+ extraNodes.push(
297
+ ...factory.createEnumDeclaration({
298
+ name: transformers.camelCase(enumSchema.args.name),
299
+ typeName: enumSchema.args.typeName,
300
+ enums: enumSchema.args.items
301
+ .map((item) => (item.value === undefined ? undefined : [transformers.trimQuotes(item.name?.toString()), item.value]))
302
+ .filter(Boolean) as unknown as [string, string][],
303
+ type: options.enumType,
304
+ }),
305
+ )
304
306
  })
305
307
  }
306
308
 
307
309
  nodes.push(
308
310
  factory.appendJSDocToNode({
309
311
  node,
310
- comments: [
311
- options.description ? `@description ${transformers.jsStringEscape(options.description)}` : undefined,
312
- ].filter(Boolean),
312
+ comments: [options.description ? `@description ${transformers.jsStringEscape(options.description)}` : undefined].filter(Boolean),
313
313
  }),
314
314
  )
315
315
 
package/src/types.ts CHANGED
@@ -51,7 +51,7 @@ export type Options = {
51
51
  /**
52
52
  * Array containing override parameters to override `options` based on tags/operations/methods/paths.
53
53
  */
54
- override?: Array<Override<Options>>
54
+ override?: Array<Override<ResolvedOptions>>
55
55
  /**
56
56
  * Choose to use `enum` or `as const` for enums
57
57
  * @default 'asConst'
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/plugin.ts","../src/OperationGenerator.tsx","../src/components/OasType.tsx","../src/components/OperationSchema.tsx","../src/SchemaGenerator.tsx","../src/typeParser.ts","../src/index.ts"],"sourcesContent":["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 { SchemaGenerator } from './SchemaGenerator.tsx'\n\nimport type { Plugin } from '@kubb/core'\nimport type { PluginOptions as SwaggerPluginOptions } from '@kubb/swagger'\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 enumSuffix = '',\n dateType = 'string',\n unknownType = 'any',\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 optionalType,\n oasType,\n enumType,\n enumSuffix,\n // keep the used enumnames between SchemaGenerator and OperationGenerator per plugin(pluginKey)\n usedEnumNames: {},\n unknownType,\n },\n pre: [swaggerPluginName],\n resolvePath(baseName, pathMode, options) {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = pathMode ?? FileManager.getMode(path.resolve(root, output.path))\n\n if (mode === '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]: [Plugin<SwaggerPluginOptions>] = PluginManager.getDependedPlugins<SwaggerPluginOptions>(this.plugins, [swaggerPluginName])\n\n const oas = await swaggerPlugin.api.getOas()\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = FileManager.getMode(path.resolve(root, output.path))\n\n const schemaGenerator = new SchemaGenerator(\n this.plugin.options,\n {\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType: swaggerPlugin.api.contentType,\n include: undefined,\n mode,\n output: output.path,\n },\n )\n\n const schemaFiles = await schemaGenerator.build()\n await this.addFile(...schemaFiles)\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 operationFiles = await operationGenerator.build()\n await this.addFile(...operationFiles)\n },\n async buildEnd() {\n if (this.config.output.write === false) {\n return\n }\n\n const root = path.resolve(this.config.root, this.config.output.path)\n\n 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'\nimport { Oas } from '@kubb/swagger/components'\n\nimport { OasType } from './components/OasType.tsx'\nimport { OperationSchema } from './components/OperationSchema.tsx'\n\nimport type { AppContextProps } from '@kubb/react'\nimport type { OperationMethodResult } 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(operations: Operation[]): OperationMethodResult<FileMeta> {\n const { oas, pluginManager, plugin } = this.context\n\n const root = createRoot<AppContextProps<PluginOptions['appMeta']>>({ logger: pluginManager.logger })\n\n root.render(\n <Oas oas={oas} operations={operations} getOperationSchemas={(...props) => this.getSchemas(...props)}>\n {plugin.options.oasType && <OasType.File name=\"oas\" typeName=\"Oas\" />}\n </Oas>,\n { meta: { pluginManager, plugin } },\n )\n\n return root.files\n }\n\n async operation(\n operation: Operation,\n options: PluginOptions['resolvedOptions'],\n ): OperationMethodResult<FileMeta> {\n const { oas, pluginManager, plugin, mode } = this.context\n\n const root = createRoot<AppContextProps<PluginOptions['appMeta']>>({ logger: pluginManager.logger })\n root.render(\n <Oas oas={oas} operations={[operation]} getOperationSchemas={(...props) => this.getSchemas(...props)}>\n <Oas.Operation operation={operation}>\n <OperationSchema.File mode={mode} />\n </Oas.Operation>\n </Oas>,\n { meta: { pluginManager, plugin: { ...plugin, options } } },\n )\n\n return root.files\n }\n\n async get(): OperationMethodResult<FileMeta> {\n return null\n }\n\n async post(): OperationMethodResult<FileMeta> {\n return null\n }\n\n async put(): OperationMethodResult<FileMeta> {\n return null\n }\n async patch(): OperationMethodResult<FileMeta> {\n return null\n }\n async delete(): OperationMethodResult<FileMeta> {\n return null\n }\n}\n","import { Editor, File, Type, usePlugin } from '@kubb/react'\nimport { useGetFile } 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 OasType({\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\nOasType.File = function({ name, typeName, templates = defaultTemplates }: FileProps): ReactNode {\n const { key: pluginKey } = usePlugin<PluginOptions>()\n const file = useGetFile({ name, extName: '.ts', pluginKey })\n\n const Template = templates.default\n\n return (\n <Editor language=\"typescript\">\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 <OasType Template={Template} name={name} typeName={typeName} />\n </File.Source>\n </File>\n </Editor>\n )\n}\n\nOasType.templates = defaultTemplates\n","/* eslint-disable no-empty-pattern */\n/* eslint-disable @typescript-eslint/ban-types */\nimport transformers from '@kubb/core/transformers'\nimport { print } from '@kubb/parser'\nimport * as factory from '@kubb/parser/factory'\nimport { Editor, File, usePlugin, usePluginManager } from '@kubb/react'\nimport { Oas, Schema } from '@kubb/swagger/components'\nimport { useGetOperationFile, useOas, useOperation, useOperationName, useOperationSchemas } from '@kubb/swagger/hooks'\n\nimport { SchemaGenerator } from '../SchemaGenerator.tsx'\n\nimport type { KubbFile } from '@kubb/core'\nimport type { ts } from '@kubb/parser'\nimport type { OperationSchema as OperationSchemaType } from '@kubb/swagger'\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\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 OperationSchema({}: Props): ReactNode {\n return (\n <>\n </>\n )\n}\n\ntype FileProps = {\n mode: KubbFile.Mode | undefined\n}\n\nOperationSchema.File = function({ mode = 'directory' }: FileProps): ReactNode {\n const plugin = usePlugin<PluginOptions>()\n\n const pluginManager = usePluginManager()\n const oas = useOas()\n const schemas = useOperationSchemas()\n const file = useGetOperationFile()\n const factoryName = useOperationName({ type: 'type' })\n const operation = useOperation()\n\n const generator = new SchemaGenerator(plugin.options, { oas, plugin, pluginManager })\n\n const items = [\n schemas.pathParams,\n schemas.queryParams,\n schemas.headerParams,\n schemas.statusCodes,\n schemas.request,\n schemas.response,\n ].flat().filter(Boolean)\n\n const mapItem = ({ name, schema: object, ...options }: OperationSchemaType, i: number) => {\n return (\n <Oas.Schema key={i} generator={generator} name={name} object={object}>\n {mode === 'directory'\n && <Schema.Imports isTypeOnly />}\n <File.Source>\n <Schema.Source options={options} />\n </File.Source>\n </Oas.Schema>\n )\n }\n\n return (\n <Editor language=\"typescript\">\n <File<FileMeta>\n baseName={file.baseName}\n path={file.path}\n meta={file.meta}\n >\n {items.map(mapItem)}\n\n <File.Source>\n {printCombinedSchema(factoryName, operation, schemas)}\n </File.Source>\n </File>\n </Editor>\n )\n}\n","import { createRoot } from '@kubb/react'\nimport { SchemaGenerator as Generator } from '@kubb/swagger'\nimport { Oas, Schema } from '@kubb/swagger/components'\nimport { pluginKey as swaggerTypeScriptPluginKey } from '@kubb/swagger-ts'\n\nimport { pluginKey } from './plugin.ts'\nimport { typeParser } from './typeParser.ts'\n\nimport type { AppContextProps } from '@kubb/react'\nimport type { Schema as SchemaType, SchemaGeneratorBuildOptions, SchemaMethodResult } from '@kubb/swagger'\nimport type { SchemaObject } from '@kubb/swagger/oas'\nimport type { FileMeta, PluginOptions } from './types.ts'\n\nexport class SchemaGenerator extends Generator<PluginOptions['resolvedOptions'], PluginOptions> {\n async schema(name: string, object: SchemaObject): SchemaMethodResult<FileMeta> {\n const { oas, pluginManager, mode, plugin, output } = this.context\n\n const root = createRoot<AppContextProps<PluginOptions['appMeta']>>({ logger: pluginManager.logger })\n\n root.render(\n <Oas oas={oas}>\n <Oas.Schema generator={this} name={name} object={object}>\n <Schema.File isTypeOnly output={output} mode={mode} />\n </Oas.Schema>\n </Oas>,\n { meta: { pluginManager, plugin } },\n )\n\n return root.files\n }\n // TODO convert to a react component called `Schema.Parser` with props parser as part of the SchemaContext\n getSource(name: string, schemas: SchemaType[], {\n keysToOmit,\n description,\n }: SchemaGeneratorBuildOptions = {}): string[] {\n const texts: string[] = []\n\n const resolvedName = this.context.pluginManager.resolveName({ name, pluginKey, type: 'function' })\n const resvoledTypeName = this.context.pluginManager.resolveName({ name, pluginKey: swaggerTypeScriptPluginKey, type: 'type' })\n\n const typeOutput = typeParser(schemas, {\n name: resolvedName,\n typeName: resvoledTypeName,\n description,\n enumType: this.options.enumType || 'asConst',\n optionalType: this.options.optionalType,\n keysToOmit,\n })\n\n texts.push(typeOutput)\n\n return texts\n }\n /**\n * @deprecated only used for testing\n */\n\n buildSource(name: string, schema: SchemaObject, options: SchemaGeneratorBuildOptions = {}): string[] {\n const schemas = this.buildSchemas(schema, name)\n\n return this.getSource(name, schemas, options)\n }\n}\n","import transformers from '@kubb/core/transformers'\nimport { print } from '@kubb/parser'\nimport * as factory from '@kubb/parser/factory'\nimport { isKeyword, SchemaGenerator, schemaKeywords } from '@kubb/swagger'\n\nimport type { ts } from '@kubb/parser'\nimport type { Schema, SchemaKeywordMapper, SchemaMapper } from '@kubb/swagger'\n\nexport const typeKeywordMapper = {\n any: () => factory.keywordTypeNodes.any,\n unknown: () => factory.keywordTypeNodes.unknown,\n number: () => factory.keywordTypeNodes.number,\n integer: () => factory.keywordTypeNodes.number,\n object: (nodes?: ts.TypeElement[]) => {\n if (!nodes) {\n return factory.keywordTypeNodes.object\n }\n\n return factory.createTypeLiteralNode(nodes)\n },\n lazy: undefined,\n string: () => factory.keywordTypeNodes.string,\n boolean: () => factory.keywordTypeNodes.boolean,\n undefined: () => factory.keywordTypeNodes.undefined,\n nullable: undefined,\n null: () => factory.keywordTypeNodes.null,\n nullish: undefined,\n array: (nodes?: ts.TypeNode[]) => {\n if (!nodes) {\n return undefined\n }\n\n return factory.createArrayDeclaration({ nodes })\n },\n tuple: (nodes?: ts.TypeNode[]) => {\n if (!nodes) {\n return undefined\n }\n\n return factory.createTupleTypeNode(nodes)\n },\n enum: (name?: string) => {\n if (!name) {\n return undefined\n }\n\n return factory.createTypeReferenceNode(name, undefined)\n },\n union: (nodes?: ts.TypeNode[]) => {\n if (!nodes) {\n return undefined\n }\n\n return factory.createUnionDeclaration({\n withParentheses: true,\n nodes,\n })\n },\n const: (name?: string | number, format?: 'string' | 'number') => {\n if (!name) {\n return undefined\n }\n\n if (format === 'number') {\n return factory.createLiteralTypeNode(factory.createNumericLiteral(name))\n }\n\n return factory.createLiteralTypeNode(factory.createStringLiteral(name.toString()))\n },\n datetime: () => factory.keywordTypeNodes.string,\n date: () => factory.createTypeReferenceNode(factory.createIdentifier('Date')),\n uuid: undefined,\n url: undefined,\n strict: undefined,\n default: undefined,\n and: (nodes?: ts.TypeNode[]) => {\n if (!nodes) {\n return undefined\n }\n\n return factory.createIntersectionDeclaration({\n withParentheses: true,\n nodes,\n })\n },\n describe: undefined,\n min: undefined,\n max: undefined,\n optional: undefined,\n matches: undefined,\n email: undefined,\n firstName: undefined,\n lastName: undefined,\n password: undefined,\n phone: undefined,\n readOnly: undefined,\n ref: (propertyName?: string) => {\n if (!propertyName) {\n return undefined\n }\n\n return factory.createTypeReferenceNode(propertyName, undefined)\n },\n blob: () => factory.createTypeReferenceNode('Blob', []),\n deprecated: undefined,\n example: undefined,\n type: undefined,\n format: undefined,\n catchall: undefined,\n} satisfies SchemaMapper<(ctx?: any) => ts.Node | null | undefined>\n\ntype ParserOptions = {\n name: string\n typeName?: string\n description?: string\n /**\n * @default `'questionToken'`\n */\n optionalType: 'questionToken' | 'undefined' | 'questionTokenAndUndefined'\n /**\n * @default `'asConst'`\n */\n enumType: 'enum' | 'asConst' | 'asPascalConst' | 'constEnum' | 'literal'\n keysToOmit?: string[]\n mapper?: typeof typeKeywordMapper\n}\n\nexport function parseTypeMeta(item: Schema, options: ParserOptions): ts.Node | null | undefined {\n const mapper = options.mapper || typeKeywordMapper\n const value = mapper[item.keyword as keyof typeof mapper]\n\n if (!value) {\n return undefined\n }\n\n if (isKeyword(item, schemaKeywords.union)) {\n const value = mapper[item.keyword as keyof typeof mapper] as typeof typeKeywordMapper['union']\n return value(item.args.map(orItem => parseTypeMeta(orItem, options)).filter(Boolean) as ts.TypeNode[])\n }\n\n if (isKeyword(item, schemaKeywords.and)) {\n const value = mapper[item.keyword as keyof typeof mapper] as typeof typeKeywordMapper['and']\n return value(item.args.map(orItem => parseTypeMeta(orItem, options)).filter(Boolean) as ts.TypeNode[])\n }\n\n if (isKeyword(item, schemaKeywords.array)) {\n const value = mapper[item.keyword as keyof typeof mapper] as typeof typeKeywordMapper['array']\n return value(item.args.items.map(orItem => parseTypeMeta(orItem, options)).filter(Boolean) as ts.TypeNode[])\n }\n\n if (isKeyword(item, schemaKeywords.enum)) {\n const value = mapper[item.keyword as keyof typeof mapper] as typeof typeKeywordMapper['enum']\n return value(item.args.typeName)\n }\n\n if (isKeyword(item, schemaKeywords.ref)) {\n const value = mapper[item.keyword as keyof typeof mapper] as typeof typeKeywordMapper['ref']\n return value(item.args.name)\n }\n\n if (isKeyword(item, schemaKeywords.blob)) {\n return value()\n }\n\n if (isKeyword(item, schemaKeywords.tuple)) {\n const value = mapper[item.keyword as keyof typeof mapper] as typeof typeKeywordMapper['tuple']\n return value(\n item.args.map(tupleItem => parseTypeMeta(tupleItem, options)).filter(Boolean) as ts.TypeNode[],\n )\n }\n\n if (isKeyword(item, schemaKeywords.const)) {\n const value = mapper[item.keyword as keyof typeof mapper] as typeof typeKeywordMapper['const']\n\n return value(item.args.name, item.args.format)\n }\n\n if (isKeyword(item, schemaKeywords.object)) {\n const value = mapper[item.keyword as keyof typeof mapper] as typeof typeKeywordMapper['object']\n\n const properties = Object.entries(item.args?.properties || {})\n .filter((item) => {\n const schemas = item[1]\n return schemas && typeof schemas.map === 'function'\n })\n .map((item) => {\n const name = item[0]\n const schemas = item[1]\n\n const isNullish = schemas.some(item => item.keyword === schemaKeywords.nullish)\n const isNullable = schemas.some(item => item.keyword === schemaKeywords.nullable)\n const isOptional = schemas.some(item => item.keyword === schemaKeywords.optional)\n const isReadonly = schemas.some(item => item.keyword === schemaKeywords.readOnly)\n const describeSchema = schemas.find(item => item.keyword === schemaKeywords.describe) as SchemaKeywordMapper['describe'] | undefined\n const deprecatedSchema = schemas.find(item => item.keyword === schemaKeywords.deprecated) as SchemaKeywordMapper['deprecated'] | undefined\n const defaultSchema = schemas.find(item => item.keyword === schemaKeywords.default) as SchemaKeywordMapper['default'] | undefined\n const exampleSchema = schemas.find(item => item.keyword === schemaKeywords.example) as SchemaKeywordMapper['example'] | undefined\n const typeSchema = schemas.find(item => item.keyword === schemaKeywords.type) as SchemaKeywordMapper['type'] | undefined\n const formatSchema = schemas.find(item => item.keyword === schemaKeywords.format) as SchemaKeywordMapper['format'] | undefined\n\n let type = schemas\n .map((item) => parseTypeMeta(item, options))\n .filter(Boolean)[0] as ts.TypeNode\n\n if (isNullable) {\n type = factory.createUnionDeclaration({ nodes: [type, factory.keywordTypeNodes.null] }) as ts.TypeNode\n }\n\n if (isNullish && ['undefined', 'questionTokenAndUndefined'].includes(options.optionalType as string)) {\n type = factory.createUnionDeclaration({ nodes: [type, factory.keywordTypeNodes.undefined] }) as ts.TypeNode\n }\n\n if (isOptional && ['undefined', 'questionTokenAndUndefined'].includes(options.optionalType as string)) {\n type = factory.createUnionDeclaration({ nodes: [type, factory.keywordTypeNodes.undefined] }) as ts.TypeNode\n }\n\n const propertySignature = factory.createPropertySignature({\n questionToken: isOptional && ['questionToken', 'questionTokenAndUndefined'].includes(options.optionalType as string),\n name,\n type,\n readOnly: isReadonly,\n })\n\n return factory.appendJSDocToNode({\n node: propertySignature,\n comments: [\n describeSchema ? `@description ${transformers.jsStringEscape(describeSchema.args)}` : undefined,\n deprecatedSchema ? `@deprecated` : undefined,\n defaultSchema\n ? `@default ${defaultSchema.args}`\n : undefined,\n exampleSchema ? `@example ${exampleSchema.args}` : undefined,\n typeSchema\n ? `@type ${typeSchema.args}${!isOptional ? '' : ' | undefined'} ${formatSchema?.args || ''}`\n : undefined,\n ].filter(Boolean),\n })\n })\n\n const additionalProperties = item.args?.additionalProperties?.length\n ? factory.createIndexSignature(item.args.additionalProperties.map(schema => parseTypeMeta(schema, options)).filter(Boolean).at(0) as ts.TypeNode)\n : undefined\n\n return value([...properties, additionalProperties].filter(Boolean))\n }\n\n if (item.keyword in mapper) {\n return value()\n }\n\n return undefined\n}\n\nexport function typeParser(\n schemas: Schema[],\n options: ParserOptions,\n): string {\n const nodes: ts.Node[] = []\n const extraNodes: ts.Node[] = []\n\n if (!schemas.length) {\n return ''\n }\n\n const isNullish = schemas.some(item => item.keyword === schemaKeywords.nullish)\n const isNullable = schemas.some(item => item.keyword === schemaKeywords.nullable)\n const isOptional = schemas.some(item => item.keyword === schemaKeywords.optional)\n\n let type = schemas.map((schema) => parseTypeMeta(schema, options)).filter(Boolean).at(0) as ts.TypeNode\n || typeKeywordMapper.undefined()\n\n if (isNullable) {\n type = factory.createUnionDeclaration({ nodes: [type, factory.keywordTypeNodes.null] }) as ts.TypeNode\n }\n\n if (isNullish && ['undefined', 'questionTokenAndUndefined'].includes(options.optionalType as string)) {\n type = factory.createUnionDeclaration({ nodes: [type, factory.keywordTypeNodes.undefined] }) as ts.TypeNode\n }\n\n if (isOptional && ['undefined', 'questionTokenAndUndefined'].includes(options.optionalType as string)) {\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: options.name,\n type: options.keysToOmit?.length ? factory.createOmitDeclaration({ keys: options.keysToOmit, type, nonNullable: true }) : type,\n })\n\n const enumSchemas = SchemaGenerator.deepSearch(schemas, schemaKeywords.enum)\n if (enumSchemas) {\n enumSchemas.forEach(enumSchema => {\n extraNodes.push(...factory.createEnumDeclaration({\n name: transformers.camelCase(enumSchema.args.name),\n typeName: enumSchema.args.typeName,\n enums: enumSchema.args.items.map(item => item.value === undefined ? undefined : [transformers.trimQuotes(item.name?.toString()), item.value]).filter(\n Boolean,\n ) as unknown as [\n string,\n string,\n ][],\n type: options.enumType,\n }))\n })\n }\n\n nodes.push(\n factory.appendJSDocToNode({\n node,\n comments: [\n options.description ? `@description ${transformers.jsStringEscape(options.description)}` : undefined,\n ].filter(Boolean),\n }),\n )\n\n const filterdNodes = nodes.filter(\n (node: ts.Node) =>\n !extraNodes.some(\n (extraNode: ts.Node) => (extraNode as ts.TypeAliasDeclaration)?.name?.escapedText === (node as ts.TypeAliasDeclaration)?.name?.escapedText,\n ),\n )\n\n return print([...extraNodes, ...filterdNodes])\n}\n","import { definePlugin } from './plugin.ts'\n\nexport { definePlugin, pluginKey, pluginName } from './plugin.ts'\nexport type * from './types.ts'\n\n/**\n * @deprecated Use `import { definePlugin } from '@kubb/swagger-ts'`\n */\nconst definePluginDefault = definePlugin\n\nexport default definePluginDefault\n"],"mappings":";AAAA,OAAO,UAAU;AAEjB,SAAS,cAAc,aAAa,qBAAqB;AACzD,SAAS,WAAW,kBAAkB;AACtC,SAAS,sBAAsB;AAC/B,SAAS,cAAc,yBAAyB;;;ACLhD,SAAS,cAAAA,mBAAkB;AAC3B,SAAS,sBAAsBC,kBAAiB;AAChD,SAAS,OAAAC,YAAW;;;ACFpB,SAAS,QAAQ,MAAM,MAAM,iBAAiB;AAC9C,SAAS,kBAAkB;AAC3B,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,Q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;AAAA,UACT;AAAA,UACA,QAAQ,OAAO;AAAA,QACjB;AAAA,MACF;AAEA,YAAM,cAAc,MAAM,gBAAgB,MAAM;AAChD,YAAM,KAAK,QAAQ,GAAG,WAAW;AAEjC,YAAM,qBAAqB,IAAI;AAAA,QAC7B,KAAK,OAAO;AAAA,QACZ;AAAA,UACE;AAAA,UACA,eAAe,KAAK;AAAA,UACpB,QAAQ,KAAK;AAAA,UACb,aAAa,cAAc,IAAI;AAAA,UAC/B;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,QACF;AAAA,MACF;AAEA,YAAM,iBAAiB,MAAM,mBAAmB,MAAM;AACtD,YAAM,KAAK,QAAQ,GAAG,cAAc;AAAA,IACtC;AAAA,IACA,MAAM,WAAW;AACf,UAAI,KAAK,OAAO,OAAO,UAAU,OAAO;AACtC;AAAA,MACF;AAEA,YAAM,OAAO,KAAK,QAAQ,KAAK,OAAO,MAAM,KAAK,OAAO,OAAO,IAAI;AAEnE,YAAM,KAAK,YAAY,WAAW;AAAA,QAChC;AAAA,QACA;AAAA,QACA,MAAM,EAAE,WAAW,KAAK,OAAO,IAAI;AAAA,MACrC,CAAC;AAAA,IACH;AAAA,EACF;AACF,CAAC;;;AMjID,IAAM,sBAAsB;AAE5B,IAAO,cAAQ;","names":["createRoot","Generator","Oas","Template","pluginKey","transformers","print","factory","Editor","File","usePlugin","Oas","Schema","useOas","value","item","node","jsx","SchemaGenerator","Fragment","jsx","jsxs","transformers","print","usePlugin","useOas","SchemaGenerator","Oas","Schema","File","Editor","jsx","Generator","createRoot","Oas","transformers","options","SchemaGenerator"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/plugin.ts","../src/OperationGenerator.tsx","../src/components/OasType.tsx","../src/components/OperationSchema.tsx","../src/SchemaGenerator.tsx","../src/typeParser.ts","../src/index.ts"],"names":["createRoot","Generator","Oas","Template","pluginKey","transformers","print","factory","Editor","File","usePlugin","Schema","useOas","value","item","node","jsx","SchemaGenerator","Fragment","j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AsB;AAE5B,IAAO,cAAQ","sourcesContent":["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 { SchemaGenerator } from './SchemaGenerator.tsx'\n\nimport type { Plugin } from '@kubb/core'\nimport type { PluginOptions as SwaggerPluginOptions } from '@kubb/swagger'\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 enumSuffix = '',\n dateType = 'string',\n unknownType = 'any',\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 optionalType,\n oasType,\n enumType,\n enumSuffix,\n // keep the used enumnames between SchemaGenerator and OperationGenerator per plugin(pluginKey)\n usedEnumNames: {},\n unknownType,\n },\n pre: [swaggerPluginName],\n resolvePath(baseName, pathMode, options) {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = pathMode ?? FileManager.getMode(path.resolve(root, output.path))\n\n if (mode === '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]: [Plugin<SwaggerPluginOptions>] = PluginManager.getDependedPlugins<SwaggerPluginOptions>(this.plugins, [swaggerPluginName])\n\n const oas = await swaggerPlugin.api.getOas()\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = FileManager.getMode(path.resolve(root, output.path))\n\n const schemaGenerator = new SchemaGenerator(\n this.plugin.options,\n {\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType: swaggerPlugin.api.contentType,\n include: undefined,\n mode,\n output: output.path,\n },\n )\n\n const schemaFiles = await schemaGenerator.build()\n await this.addFile(...schemaFiles)\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 operationFiles = await operationGenerator.build()\n await this.addFile(...operationFiles)\n },\n async buildEnd() {\n if (this.config.output.write === false) {\n return\n }\n\n const root = path.resolve(this.config.root, this.config.output.path)\n\n 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'\nimport { Oas } from '@kubb/swagger/components'\n\nimport { OasType } from './components/OasType.tsx'\nimport { OperationSchema } from './components/OperationSchema.tsx'\n\nimport type { AppContextProps } from '@kubb/react'\nimport type { OperationMethodResult } 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(operations: Operation[]): OperationMethodResult<FileMeta> {\n const { oas, pluginManager, plugin } = this.context\n\n const root = createRoot<AppContextProps<PluginOptions['appMeta']>>({ logger: pluginManager.logger })\n\n root.render(\n <Oas oas={oas} operations={operations} getOperationSchemas={(...props) => this.getSchemas(...props)}>\n {plugin.options.oasType && <OasType.File name=\"oas\" typeName=\"Oas\" />}\n </Oas>,\n { meta: { pluginManager, plugin } },\n )\n\n return root.files\n }\n\n async operation(\n operation: Operation,\n options: PluginOptions['resolvedOptions'],\n ): OperationMethodResult<FileMeta> {\n const { oas, pluginManager, plugin, mode } = this.context\n\n const root = createRoot<AppContextProps<PluginOptions['appMeta']>>({ logger: pluginManager.logger })\n root.render(\n <Oas oas={oas} operations={[operation]} getOperationSchemas={(...props) => this.getSchemas(...props)}>\n <Oas.Operation operation={operation}>\n <OperationSchema.File mode={mode} />\n </Oas.Operation>\n </Oas>,\n { meta: { pluginManager, plugin: { ...plugin, options } } },\n )\n\n return root.files\n }\n\n async get(): OperationMethodResult<FileMeta> {\n return null\n }\n\n async post(): OperationMethodResult<FileMeta> {\n return null\n }\n\n async put(): OperationMethodResult<FileMeta> {\n return null\n }\n async patch(): OperationMethodResult<FileMeta> {\n return null\n }\n async delete(): OperationMethodResult<FileMeta> {\n return null\n }\n}\n","import { Editor, File, Type, usePlugin } from '@kubb/react'\nimport { useGetFile } 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 OasType({\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\nOasType.File = function({ name, typeName, templates = defaultTemplates }: FileProps): ReactNode {\n const { key: pluginKey } = usePlugin<PluginOptions>()\n const file = useGetFile({ name, extName: '.ts', pluginKey })\n\n const Template = templates.default\n\n return (\n <Editor language=\"typescript\">\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 <OasType Template={Template} name={name} typeName={typeName} />\n </File.Source>\n </File>\n </Editor>\n )\n}\n\nOasType.templates = defaultTemplates\n","/* eslint-disable no-empty-pattern */\n/* eslint-disable @typescript-eslint/ban-types */\nimport transformers from '@kubb/core/transformers'\nimport { print } from '@kubb/parser'\nimport * as factory from '@kubb/parser/factory'\nimport { Editor, File, usePlugin, usePluginManager } from '@kubb/react'\nimport { Oas, Schema } from '@kubb/swagger/components'\nimport { useGetOperationFile, useOas, useOperation, useOperationName, useOperationSchemas } from '@kubb/swagger/hooks'\n\nimport { SchemaGenerator } from '../SchemaGenerator.tsx'\n\nimport type { KubbFile } from '@kubb/core'\nimport type { ts } from '@kubb/parser'\nimport type { OperationSchema as OperationSchemaType } from '@kubb/swagger'\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\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 OperationSchema({}: Props): ReactNode {\n return (\n <>\n </>\n )\n}\n\ntype FileProps = {\n mode: KubbFile.Mode | undefined\n}\n\nOperationSchema.File = function({ mode = 'directory' }: FileProps): ReactNode {\n const plugin = usePlugin<PluginOptions>()\n\n const pluginManager = usePluginManager()\n const oas = useOas()\n const schemas = useOperationSchemas()\n const file = useGetOperationFile()\n const factoryName = useOperationName({ type: 'type' })\n const operation = useOperation()\n\n const generator = new SchemaGenerator(plugin.options, { oas, plugin, pluginManager })\n\n const items = [\n schemas.pathParams,\n schemas.queryParams,\n schemas.headerParams,\n schemas.statusCodes,\n schemas.request,\n schemas.response,\n ].flat().filter(Boolean)\n\n const mapItem = ({ name, schema: object, ...options }: OperationSchemaType, i: number) => {\n return (\n <Oas.Schema key={i} generator={generator} name={name} object={object}>\n {mode === 'directory'\n && <Schema.Imports isTypeOnly />}\n <File.Source>\n <Schema.Source options={options} />\n </File.Source>\n </Oas.Schema>\n )\n }\n\n return (\n <Editor language=\"typescript\">\n <File<FileMeta>\n baseName={file.baseName}\n path={file.path}\n meta={file.meta}\n >\n {items.map(mapItem)}\n\n <File.Source>\n {printCombinedSchema(factoryName, operation, schemas)}\n </File.Source>\n </File>\n </Editor>\n )\n}\n","import { createRoot } from '@kubb/react'\nimport { SchemaGenerator as Generator } from '@kubb/swagger'\nimport { Oas, Schema } from '@kubb/swagger/components'\nimport { pluginKey as swaggerTypeScriptPluginKey } from '@kubb/swagger-ts'\n\nimport { pluginKey } from './plugin.ts'\nimport { typeParser } from './typeParser.ts'\n\nimport type { AppContextProps } from '@kubb/react'\nimport type { Schema as SchemaType, SchemaGeneratorBuildOptions, SchemaMethodResult } from '@kubb/swagger'\nimport type { SchemaObject } from '@kubb/swagger/oas'\nimport type { FileMeta, PluginOptions } from './types.ts'\n\nexport class SchemaGenerator extends Generator<PluginOptions['resolvedOptions'], PluginOptions> {\n async schema(name: string, object: SchemaObject): SchemaMethodResult<FileMeta> {\n const { oas, pluginManager, mode, plugin, output } = this.context\n\n const root = createRoot<AppContextProps<PluginOptions['appMeta']>>({ logger: pluginManager.logger })\n\n root.render(\n <Oas oas={oas}>\n <Oas.Schema generator={this} name={name} object={object}>\n <Schema.File isTypeOnly output={output} mode={mode} />\n </Oas.Schema>\n </Oas>,\n { meta: { pluginManager, plugin } },\n )\n\n return root.files\n }\n // TODO convert to a react component called `Schema.Parser` with props parser as part of the SchemaContext\n getSource(name: string, schemas: SchemaType[], {\n keysToOmit,\n description,\n }: SchemaGeneratorBuildOptions = {}): string[] {\n const texts: string[] = []\n\n const resolvedName = this.context.pluginManager.resolveName({ name, pluginKey, type: 'function' })\n const resvoledTypeName = this.context.pluginManager.resolveName({ name, pluginKey: swaggerTypeScriptPluginKey, type: 'type' })\n\n const typeOutput = typeParser(schemas, {\n name: resolvedName,\n typeName: resvoledTypeName,\n description,\n enumType: this.options.enumType || 'asConst',\n optionalType: this.options.optionalType,\n keysToOmit,\n })\n\n texts.push(typeOutput)\n\n return texts\n }\n /**\n * @deprecated only used for testing\n */\n\n buildSource(name: string, schema: SchemaObject, options: SchemaGeneratorBuildOptions = {}): string[] {\n const schemas = this.buildSchemas(schema, name)\n\n return this.getSource(name, schemas, options)\n }\n}\n","import transformers from '@kubb/core/transformers'\nimport { print } from '@kubb/parser'\nimport * as factory from '@kubb/parser/factory'\nimport { isKeyword, SchemaGenerator, schemaKeywords } from '@kubb/swagger'\n\nimport type { ts } from '@kubb/parser'\nimport type { Schema, SchemaKeywordMapper, SchemaMapper } from '@kubb/swagger'\n\nexport const typeKeywordMapper = {\n any: () => factory.keywordTypeNodes.any,\n unknown: () => factory.keywordTypeNodes.unknown,\n number: () => factory.keywordTypeNodes.number,\n integer: () => factory.keywordTypeNodes.number,\n object: (nodes?: ts.TypeElement[]) => {\n if (!nodes) {\n return factory.keywordTypeNodes.object\n }\n\n return factory.createTypeLiteralNode(nodes)\n },\n lazy: undefined,\n string: () => factory.keywordTypeNodes.string,\n boolean: () => factory.keywordTypeNodes.boolean,\n undefined: () => factory.keywordTypeNodes.undefined,\n nullable: undefined,\n null: () => factory.keywordTypeNodes.null,\n nullish: undefined,\n array: (nodes?: ts.TypeNode[]) => {\n if (!nodes) {\n return undefined\n }\n\n return factory.createArrayDeclaration({ nodes })\n },\n tuple: (nodes?: ts.TypeNode[]) => {\n if (!nodes) {\n return undefined\n }\n\n return factory.createTupleTypeNode(nodes)\n },\n enum: (name?: string) => {\n if (!name) {\n return undefined\n }\n\n return factory.createTypeReferenceNode(name, undefined)\n },\n union: (nodes?: ts.TypeNode[]) => {\n if (!nodes) {\n return undefined\n }\n\n return factory.createUnionDeclaration({\n withParentheses: true,\n nodes,\n })\n },\n const: (name?: string | number, format?: 'string' | 'number') => {\n if (!name) {\n return undefined\n }\n\n if (format === 'number') {\n return factory.createLiteralTypeNode(factory.createNumericLiteral(name))\n }\n\n return factory.createLiteralTypeNode(factory.createStringLiteral(name.toString()))\n },\n datetime: () => factory.keywordTypeNodes.string,\n date: () => factory.createTypeReferenceNode(factory.createIdentifier('Date')),\n uuid: undefined,\n url: undefined,\n strict: undefined,\n default: undefined,\n and: (nodes?: ts.TypeNode[]) => {\n if (!nodes) {\n return undefined\n }\n\n return factory.createIntersectionDeclaration({\n withParentheses: true,\n nodes,\n })\n },\n describe: undefined,\n min: undefined,\n max: undefined,\n optional: undefined,\n matches: undefined,\n email: undefined,\n firstName: undefined,\n lastName: undefined,\n password: undefined,\n phone: undefined,\n readOnly: undefined,\n ref: (propertyName?: string) => {\n if (!propertyName) {\n return undefined\n }\n\n return factory.createTypeReferenceNode(propertyName, undefined)\n },\n blob: () => factory.createTypeReferenceNode('Blob', []),\n deprecated: undefined,\n example: undefined,\n type: undefined,\n format: undefined,\n catchall: undefined,\n} satisfies SchemaMapper<(ctx?: any) => ts.Node | null | undefined>\n\ntype ParserOptions = {\n name: string\n typeName?: string\n description?: string\n /**\n * @default `'questionToken'`\n */\n optionalType: 'questionToken' | 'undefined' | 'questionTokenAndUndefined'\n /**\n * @default `'asConst'`\n */\n enumType: 'enum' | 'asConst' | 'asPascalConst' | 'constEnum' | 'literal'\n keysToOmit?: string[]\n mapper?: typeof typeKeywordMapper\n}\n\nexport function parseTypeMeta(item: Schema, options: ParserOptions): ts.Node | null | undefined {\n const mapper = options.mapper || typeKeywordMapper\n const value = mapper[item.keyword as keyof typeof mapper]\n\n if (!value) {\n return undefined\n }\n\n if (isKeyword(item, schemaKeywords.union)) {\n const value = mapper[item.keyword as keyof typeof mapper] as typeof typeKeywordMapper['union']\n return value(item.args.map(orItem => parseTypeMeta(orItem, options)).filter(Boolean) as ts.TypeNode[])\n }\n\n if (isKeyword(item, schemaKeywords.and)) {\n const value = mapper[item.keyword as keyof typeof mapper] as typeof typeKeywordMapper['and']\n return value(item.args.map(orItem => parseTypeMeta(orItem, options)).filter(Boolean) as ts.TypeNode[])\n }\n\n if (isKeyword(item, schemaKeywords.array)) {\n const value = mapper[item.keyword as keyof typeof mapper] as typeof typeKeywordMapper['array']\n return value(item.args.items.map(orItem => parseTypeMeta(orItem, options)).filter(Boolean) as ts.TypeNode[])\n }\n\n if (isKeyword(item, schemaKeywords.enum)) {\n const value = mapper[item.keyword as keyof typeof mapper] as typeof typeKeywordMapper['enum']\n return value(item.args.typeName)\n }\n\n if (isKeyword(item, schemaKeywords.ref)) {\n const value = mapper[item.keyword as keyof typeof mapper] as typeof typeKeywordMapper['ref']\n return value(item.args.name)\n }\n\n if (isKeyword(item, schemaKeywords.blob)) {\n return value()\n }\n\n if (isKeyword(item, schemaKeywords.tuple)) {\n const value = mapper[item.keyword as keyof typeof mapper] as typeof typeKeywordMapper['tuple']\n return value(\n item.args.map(tupleItem => parseTypeMeta(tupleItem, options)).filter(Boolean) as ts.TypeNode[],\n )\n }\n\n if (isKeyword(item, schemaKeywords.const)) {\n const value = mapper[item.keyword as keyof typeof mapper] as typeof typeKeywordMapper['const']\n\n return value(item.args.name, item.args.format)\n }\n\n if (isKeyword(item, schemaKeywords.object)) {\n const value = mapper[item.keyword as keyof typeof mapper] as typeof typeKeywordMapper['object']\n\n const properties = Object.entries(item.args?.properties || {})\n .filter((item) => {\n const schemas = item[1]\n return schemas && typeof schemas.map === 'function'\n })\n .map((item) => {\n const name = item[0]\n const schemas = item[1]\n\n const isNullish = schemas.some(item => item.keyword === schemaKeywords.nullish)\n const isNullable = schemas.some(item => item.keyword === schemaKeywords.nullable)\n const isOptional = schemas.some(item => item.keyword === schemaKeywords.optional)\n const isReadonly = schemas.some(item => item.keyword === schemaKeywords.readOnly)\n const describeSchema = schemas.find(item => item.keyword === schemaKeywords.describe) as SchemaKeywordMapper['describe'] | undefined\n const deprecatedSchema = schemas.find(item => item.keyword === schemaKeywords.deprecated) as SchemaKeywordMapper['deprecated'] | undefined\n const defaultSchema = schemas.find(item => item.keyword === schemaKeywords.default) as SchemaKeywordMapper['default'] | undefined\n const exampleSchema = schemas.find(item => item.keyword === schemaKeywords.example) as SchemaKeywordMapper['example'] | undefined\n const typeSchema = schemas.find(item => item.keyword === schemaKeywords.type) as SchemaKeywordMapper['type'] | undefined\n const formatSchema = schemas.find(item => item.keyword === schemaKeywords.format) as SchemaKeywordMapper['format'] | undefined\n\n let type = schemas\n .map((item) => parseTypeMeta(item, options))\n .filter(Boolean)[0] as ts.TypeNode\n\n if (isNullable) {\n type = factory.createUnionDeclaration({ nodes: [type, factory.keywordTypeNodes.null] }) as ts.TypeNode\n }\n\n if (isNullish && ['undefined', 'questionTokenAndUndefined'].includes(options.optionalType as string)) {\n type = factory.createUnionDeclaration({ nodes: [type, factory.keywordTypeNodes.undefined] }) as ts.TypeNode\n }\n\n if (isOptional && ['undefined', 'questionTokenAndUndefined'].includes(options.optionalType as string)) {\n type = factory.createUnionDeclaration({ nodes: [type, factory.keywordTypeNodes.undefined] }) as ts.TypeNode\n }\n\n const propertySignature = factory.createPropertySignature({\n questionToken: isOptional && ['questionToken', 'questionTokenAndUndefined'].includes(options.optionalType as string),\n name,\n type,\n readOnly: isReadonly,\n })\n\n return factory.appendJSDocToNode({\n node: propertySignature,\n comments: [\n describeSchema ? `@description ${transformers.jsStringEscape(describeSchema.args)}` : undefined,\n deprecatedSchema ? `@deprecated` : undefined,\n defaultSchema\n ? `@default ${defaultSchema.args}`\n : undefined,\n exampleSchema ? `@example ${exampleSchema.args}` : undefined,\n typeSchema\n ? `@type ${typeSchema.args}${!isOptional ? '' : ' | undefined'} ${formatSchema?.args || ''}`\n : undefined,\n ].filter(Boolean),\n })\n })\n\n const additionalProperties = item.args?.additionalProperties?.length\n ? factory.createIndexSignature(item.args.additionalProperties.map(schema => parseTypeMeta(schema, options)).filter(Boolean).at(0) as ts.TypeNode)\n : undefined\n\n return value([...properties, additionalProperties].filter(Boolean))\n }\n\n if (item.keyword in mapper) {\n return value()\n }\n\n return undefined\n}\n\nexport function typeParser(\n schemas: Schema[],\n options: ParserOptions,\n): string {\n const nodes: ts.Node[] = []\n const extraNodes: ts.Node[] = []\n\n if (!schemas.length) {\n return ''\n }\n\n const isNullish = schemas.some(item => item.keyword === schemaKeywords.nullish)\n const isNullable = schemas.some(item => item.keyword === schemaKeywords.nullable)\n const isOptional = schemas.some(item => item.keyword === schemaKeywords.optional)\n\n let type = schemas.map((schema) => parseTypeMeta(schema, options)).filter(Boolean).at(0) as ts.TypeNode\n || typeKeywordMapper.undefined()\n\n if (isNullable) {\n type = factory.createUnionDeclaration({ nodes: [type, factory.keywordTypeNodes.null] }) as ts.TypeNode\n }\n\n if (isNullish && ['undefined', 'questionTokenAndUndefined'].includes(options.optionalType as string)) {\n type = factory.createUnionDeclaration({ nodes: [type, factory.keywordTypeNodes.undefined] }) as ts.TypeNode\n }\n\n if (isOptional && ['undefined', 'questionTokenAndUndefined'].includes(options.optionalType as string)) {\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: options.name,\n type: options.keysToOmit?.length ? factory.createOmitDeclaration({ keys: options.keysToOmit, type, nonNullable: true }) : type,\n })\n\n const enumSchemas = SchemaGenerator.deepSearch(schemas, schemaKeywords.enum)\n if (enumSchemas) {\n enumSchemas.forEach(enumSchema => {\n extraNodes.push(...factory.createEnumDeclaration({\n name: transformers.camelCase(enumSchema.args.name),\n typeName: enumSchema.args.typeName,\n enums: enumSchema.args.items.map(item => item.value === undefined ? undefined : [transformers.trimQuotes(item.name?.toString()), item.value]).filter(\n Boolean,\n ) as unknown as [\n string,\n string,\n ][],\n type: options.enumType,\n }))\n })\n }\n\n nodes.push(\n factory.appendJSDocToNode({\n node,\n comments: [\n options.description ? `@description ${transformers.jsStringEscape(options.description)}` : undefined,\n ].filter(Boolean),\n }),\n )\n\n const filterdNodes = nodes.filter(\n (node: ts.Node) =>\n !extraNodes.some(\n (extraNode: ts.Node) => (extraNode as ts.TypeAliasDeclaration)?.name?.escapedText === (node as ts.TypeAliasDeclaration)?.name?.escapedText,\n ),\n )\n\n return print([...extraNodes, ...filterdNodes])\n}\n","import { definePlugin } from './plugin.ts'\n\nexport { definePlugin, pluginKey, pluginName } from './plugin.ts'\nexport type * from './types.ts'\n\n/**\n * @deprecated Use `import { definePlugin } from '@kubb/swagger-ts'`\n */\nconst definePluginDefault = definePlugin\n\nexport default definePluginDefault\n"]}