@kubb/plugin-oas 3.0.0-alpha.9 → 3.0.0-beta.10

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.
Files changed (99) hide show
  1. package/README.md +14 -5
  2. package/dist/OperationGenerator-Dko8Xtd7.d.cts +561 -0
  3. package/dist/OperationGenerator-Dko8Xtd7.d.ts +561 -0
  4. package/dist/{Schema-B1vcPGiK.d.ts → Schema-C2cbPYX1.d.cts} +1 -12
  5. package/dist/{Schema-DoSFh7Qd.d.cts → Schema-CbtIvprh.d.ts} +1 -12
  6. package/dist/chunk-2TGWPVZN.cjs +92 -0
  7. package/dist/chunk-2TGWPVZN.cjs.map +1 -0
  8. package/dist/chunk-A3ROGKLW.cjs +752 -0
  9. package/dist/chunk-A3ROGKLW.cjs.map +1 -0
  10. package/dist/chunk-ABOQ73FL.cjs +36 -0
  11. package/dist/chunk-ABOQ73FL.cjs.map +1 -0
  12. package/dist/chunk-BG77DP54.js +30 -0
  13. package/dist/chunk-BG77DP54.js.map +1 -0
  14. package/dist/chunk-GF26SDHQ.js +28 -0
  15. package/dist/chunk-GF26SDHQ.js.map +1 -0
  16. package/dist/chunk-JA75IPYU.js +744 -0
  17. package/dist/chunk-JA75IPYU.js.map +1 -0
  18. package/dist/chunk-PADR76WZ.cjs +4 -0
  19. package/dist/chunk-PADR76WZ.cjs.map +1 -0
  20. package/dist/chunk-QAFBZLJA.cjs +48 -0
  21. package/dist/{chunk-SZDO532A.js.map → chunk-QAFBZLJA.cjs.map} +1 -1
  22. package/dist/chunk-R47XMJ32.js +3 -0
  23. package/dist/chunk-R47XMJ32.js.map +1 -0
  24. package/dist/chunk-TNWNNVQW.js +88 -0
  25. package/dist/chunk-TNWNNVQW.js.map +1 -0
  26. package/dist/chunk-XNCEFOE6.js +45 -0
  27. package/dist/chunk-XNCEFOE6.js.map +1 -0
  28. package/dist/chunk-ZWHQ54JM.cjs +32 -0
  29. package/dist/chunk-ZWHQ54JM.cjs.map +1 -0
  30. package/dist/components.cjs +20 -12
  31. package/dist/components.cjs.map +1 -1
  32. package/dist/components.d.cts +3 -6
  33. package/dist/components.d.ts +3 -6
  34. package/dist/components.js +3 -12
  35. package/dist/components.js.map +1 -1
  36. package/dist/generators.cjs +14 -0
  37. package/dist/generators.cjs.map +1 -0
  38. package/dist/generators.d.cts +9 -0
  39. package/dist/generators.d.ts +9 -0
  40. package/dist/generators.js +5 -0
  41. package/dist/generators.js.map +1 -0
  42. package/dist/hooks.cjs +90 -57
  43. package/dist/hooks.cjs.map +1 -1
  44. package/dist/hooks.d.cts +37 -10
  45. package/dist/hooks.d.ts +37 -10
  46. package/dist/hooks.js +79 -53
  47. package/dist/hooks.js.map +1 -1
  48. package/dist/index.cjs +142 -189
  49. package/dist/index.cjs.map +1 -1
  50. package/dist/index.d.cts +2 -5
  51. package/dist/index.d.ts +2 -5
  52. package/dist/index.js +82 -156
  53. package/dist/index.js.map +1 -1
  54. package/dist/utils.cjs +32 -45
  55. package/dist/utils.cjs.map +1 -1
  56. package/dist/utils.d.cts +4 -13
  57. package/dist/utils.d.ts +4 -13
  58. package/dist/utils.js +8 -44
  59. package/dist/utils.js.map +1 -1
  60. package/package.json +20 -14
  61. package/src/OperationGenerator.ts +30 -39
  62. package/src/SchemaGenerator.ts +70 -11
  63. package/src/SchemaMapper.ts +24 -5
  64. package/src/components/Schema.tsx +1 -99
  65. package/src/generator.tsx +22 -18
  66. package/src/generators/index.ts +1 -0
  67. package/src/generators/jsonGenerator.ts +32 -0
  68. package/src/hooks/index.ts +2 -0
  69. package/src/hooks/useOperationManager.ts +56 -31
  70. package/src/hooks/useSchemaManager.ts +77 -0
  71. package/src/index.ts +2 -4
  72. package/src/plugin.ts +69 -56
  73. package/src/types.ts +29 -22
  74. package/src/utils/getParams.ts +1 -1
  75. package/src/utils/getSchemaFactory.ts +1 -1
  76. package/src/utils/index.ts +0 -1
  77. package/src/utils/parseFromConfig.ts +7 -7
  78. package/dist/OperationGenerator-By5WOmWB.d.ts +0 -165
  79. package/dist/OperationGenerator-Gd1X7wUz.d.cts +0 -165
  80. package/dist/SchemaMapper-sGcY1xL5.d.cts +0 -247
  81. package/dist/SchemaMapper-sGcY1xL5.d.ts +0 -247
  82. package/dist/chunk-75BIOXB7.cjs +0 -7
  83. package/dist/chunk-75BIOXB7.cjs.map +0 -1
  84. package/dist/chunk-IAUV3UKH.cjs +0 -3965
  85. package/dist/chunk-IAUV3UKH.cjs.map +0 -1
  86. package/dist/chunk-M347763D.js +0 -3965
  87. package/dist/chunk-M347763D.js.map +0 -1
  88. package/dist/chunk-N7EEVJA6.js +0 -35
  89. package/dist/chunk-N7EEVJA6.js.map +0 -1
  90. package/dist/chunk-NU4F7G47.cjs +0 -89
  91. package/dist/chunk-NU4F7G47.cjs.map +0 -1
  92. package/dist/chunk-O76YQFZB.cjs +0 -35
  93. package/dist/chunk-O76YQFZB.cjs.map +0 -1
  94. package/dist/chunk-SQ64ESS4.js +0 -7
  95. package/dist/chunk-SQ64ESS4.js.map +0 -1
  96. package/dist/chunk-SZDO532A.js +0 -89
  97. package/dist/types-CZTUCaE5.d.cts +0 -145
  98. package/dist/types-CZTUCaE5.d.ts +0 -145
  99. package/src/utils/refSorter.ts +0 -13
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/kubb/kubb/packages/plugin-oas/dist/index.cjs","../src/index.ts","../src/OperationGenerator.ts","../src/plugin.ts","../src/generator.tsx"],"names":["method","methods"],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B,gCAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACF,wDAA6B;AAC7B;AACA;ACjBA,8CAAA,CAAA;ADmBA;AACA;AEpBA,8CAAA,CAAA;AAAA,kCAAiD;AACjD,mHAAyB;AA+BlB,IAAM,mBAAA,EAAN,MAAA,QAIG,oBAA2D;AAAA,EACnE,CAAA,mBAAA,EAA0C,CAAC,CAAA;AAAA,EAC3C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;AACqB,MAAA;AAEsB,MAAA;AACV,MAAA;AAE2C,MAAA;AACxC,QAAA;AACK,QAAA;AAErB,QAAA;AACX,UAAA;AACN,UAAA;AACM,UAAA;AACmB,YAAA;AACzB,UAAA;AACS,UAAA;AACP,YAAA;AACsB,cAAA;AACN,cAAA;AACD,cAAA;AACe,cAAA;AAC9B,YAAA;AACF,UAAA;AACD,QAAA;AACH,MAAA;AAE6C,MAAA;AACnB,MAAA;AAC5B,IAAA;AACF,EAAA;AACD;AHkRkD;AACA;AI3YnD;AAsEY;AAlEoB;AAmCsG;AAC7H,EAAA;AACT;AAagJ;AACvI,EAAA;AACF,IAAA;AACmC,IAAA;AACN,MAAA;AACpB,QAAA;AACV,MAAA;AAE6C,MAAA;AACrB,MAAA;AACA,QAAA;AACvB,MAAA;AAEI,MAAA;AACH,wBAAA;AAKF,MAAA;AAEY,MAAA;AACd,IAAA;AAC+C,IAAA;AAChB,MAAA;AACnB,QAAA;AACV,MAAA;AAE6C,MAAA;AACrB,MAAA;AACA,QAAA;AACvB,MAAA;AAEI,MAAA;AACH,wBAAA;AAOF,MAAA;AAEY,MAAA;AACd,IAAA;AAC+C,IAAA;AACnB,MAAA;AAChB,QAAA;AACV,MAAA;AAE6C,MAAA;AACrB,MAAA;AACA,QAAA;AACvB,MAAA;AAE2C,MAAA;AAEvC,MAAA;AACH,wBAAA;AAOF,MAAA;AAEY,MAAA;AACd,IAAA;AACF,EAAA;AACF;AJmUmD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/home/runner/work/kubb/kubb/packages/plugin-oas/dist/index.cjs","sourcesContent":[null,"export type {\n GetOperationGeneratorOptions,\n OperationMethodResult,\n} from './OperationGenerator.ts'\nexport { OperationGenerator } from './OperationGenerator.ts'\nexport { pluginOas, pluginOasName } from './plugin.ts'\nexport type {\n GetSchemaGeneratorOptions,\n SchemaGeneratorBuildOptions,\n SchemaGeneratorOptions,\n} from './SchemaGenerator.ts'\nexport type { SchemaMethodResult } from './SchemaGenerator.ts'\nexport { SchemaGenerator } from './SchemaGenerator.ts'\nexport type {\n Schema,\n SchemaKeyword,\n SchemaKeywordBase,\n SchemaKeywordMapper,\n SchemaMapper,\n} from './SchemaMapper.ts'\nexport { isKeyword, schemaKeywords } from './SchemaMapper.ts'\nexport type * from './types.ts'\nexport { createGenerator, createReactGenerator } from './generator.tsx'\nexport type { ReactGeneratorOptions } from './generator.tsx'\nexport type { Generator, GeneratorOptions } from './generator.tsx'\n","import { BaseGenerator, type FileMetaBase } from '@kubb/core'\nimport transformers from '@kubb/core/transformers'\n\nimport type { PluginFactoryOptions, PluginManager } from '@kubb/core'\nimport type * as KubbFile from '@kubb/fs/types'\n\nimport type { Plugin } from '@kubb/core'\nimport type { HttpMethod, Oas, OasTypes, Operation, contentType } from '@kubb/oas'\nimport type { Generator } from './generator.tsx'\nimport type { Exclude, Include, OperationSchemas, OperationsByMethod, Override } from './types.ts'\n\n/**\n * @deprecated\n */\nexport type GetOperationGeneratorOptions<T extends OperationGenerator<any, any, any>> = T extends OperationGenerator<infer Options, any, any> ? Options : never\n\nexport type OperationMethodResult<TFileMeta extends FileMetaBase> = Promise<KubbFile.File<TFileMeta> | Array<KubbFile.File<TFileMeta>> | null>\n\ntype Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {\n oas: Oas\n exclude: Array<Exclude> | undefined\n include: Array<Include> | undefined\n override: Array<Override<TOptions>> | undefined\n contentType: contentType | undefined\n pluginManager: PluginManager\n /**\n * Current plugin\n */\n plugin: Plugin<TPluginOptions>\n mode: KubbFile.Mode\n}\n\nexport class OperationGenerator<\n TOptions = unknown,\n TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions,\n TFileMeta extends FileMetaBase = FileMetaBase,\n> extends BaseGenerator<TOptions, Context<TOptions, TPluginOptions>> {\n #operationsByMethod: OperationsByMethod = {}\n get operationsByMethod(): OperationsByMethod {\n return this.#operationsByMethod\n }\n\n set operationsByMethod(paths: OperationsByMethod) {\n this.#operationsByMethod = paths\n }\n\n #getOptions(operation: Operation, method: HttpMethod): Partial<TOptions> {\n const { override = [] } = this.context\n\n return (\n override.find(({ pattern, type }) => {\n if (type === 'tag') {\n return !!operation.getTags()[0]?.name.match(pattern)\n }\n\n if (type === 'operationId') {\n return !!operation.getOperationId().match(pattern)\n }\n\n if (type === 'path') {\n return !!operation.path.match(pattern)\n }\n\n if (type === 'method') {\n return !!method.match(pattern)\n }\n\n return false\n })?.options || {}\n )\n }\n\n /**\n *\n * @deprecated\n */\n #isExcluded(operation: Operation, method: HttpMethod): boolean {\n const { exclude = [] } = this.context\n let matched = false\n\n exclude.forEach(({ pattern, type }) => {\n if (type === 'tag' && !matched) {\n matched = !!operation.getTags()[0]?.name.match(pattern)\n }\n\n if (type === 'operationId' && !matched) {\n matched = !!operation.getOperationId().match(pattern)\n }\n\n if (type === 'path' && !matched) {\n matched = !!operation.path.match(pattern)\n }\n\n if (type === 'method' && !matched) {\n matched = !!method.match(pattern)\n }\n })\n\n return matched\n }\n\n /**\n *\n * @deprecated\n */\n #isIncluded(operation: Operation, method: HttpMethod): boolean {\n const { include = [] } = this.context\n let matched = false\n\n include.forEach(({ pattern, type }) => {\n if (type === 'tag' && !matched) {\n matched = !!operation.getTags()[0]?.name.match(pattern)\n }\n\n if (type === 'operationId' && !matched) {\n matched = !!operation.getOperationId().match(pattern)\n }\n\n if (type === 'path' && !matched) {\n matched = !!operation.path.match(pattern)\n }\n\n if (type === 'method' && !matched) {\n matched = !!method.match(pattern)\n }\n })\n\n return matched\n }\n\n getSchemas(\n operation: Operation,\n {\n forStatusCode,\n resolveName = (name) => name,\n }: {\n forStatusCode?: string | number\n resolveName?: (name: string) => string\n } = {},\n ): OperationSchemas {\n const pathParamsSchema = this.context.oas.getParametersSchema(operation, 'path')\n const queryParamsSchema = this.context.oas.getParametersSchema(operation, 'query')\n const headerParamsSchema = this.context.oas.getParametersSchema(operation, 'header')\n const requestSchema = this.context.oas.getRequestSchema(operation)\n const responseStatusCode =\n forStatusCode || (operation.schema.responses && Object.keys(operation.schema.responses).find((key) => key.startsWith('2'))) || 200\n const responseSchema = this.context.oas.getResponseSchema(operation, responseStatusCode)\n const statusCodes = operation.getResponseStatusCodes().map((statusCode) => {\n let name = statusCode\n if (name === 'default') {\n name = 'error'\n }\n\n const schema = this.context.oas.getResponseSchema(operation, statusCode)\n\n return {\n name: resolveName(transformers.pascalCase(`${operation.getOperationId()} ${name}`)),\n description: (operation.getResponseByStatusCode(statusCode) as OasTypes.ResponseObject)?.description,\n schema,\n operation,\n operationName: transformers.pascalCase(`${operation.getOperationId()}`),\n statusCode: name === 'error' ? undefined : Number(statusCode),\n keys: schema?.properties ? Object.keys(schema.properties) : undefined,\n }\n })\n\n return {\n pathParams: pathParamsSchema\n ? {\n name: resolveName(transformers.pascalCase(`${operation.getOperationId()} PathParams`)),\n operation,\n operationName: transformers.pascalCase(`${operation.getOperationId()}`),\n schema: pathParamsSchema,\n keys: pathParamsSchema.properties ? Object.keys(pathParamsSchema.properties) : undefined,\n }\n : undefined,\n queryParams: queryParamsSchema\n ? {\n name: resolveName(transformers.pascalCase(`${operation.getOperationId()} QueryParams`)),\n operation,\n operationName: transformers.pascalCase(`${operation.getOperationId()}`),\n schema: queryParamsSchema,\n keys: queryParamsSchema.properties ? Object.keys(queryParamsSchema.properties) : [],\n }\n : undefined,\n headerParams: headerParamsSchema\n ? {\n name: resolveName(transformers.pascalCase(`${operation.getOperationId()} HeaderParams`)),\n operation,\n operationName: transformers.pascalCase(`${operation.getOperationId()}`),\n schema: headerParamsSchema,\n keys: headerParamsSchema.properties ? Object.keys(headerParamsSchema.properties) : undefined,\n }\n : undefined,\n request: requestSchema\n ? {\n name: resolveName(transformers.pascalCase(`${operation.getOperationId()} ${operation.method === 'get' ? 'queryRequest' : 'mutationRequest'}`)),\n description: (operation.schema.requestBody as OasTypes.RequestBodyObject)?.description,\n operation,\n operationName: transformers.pascalCase(`${operation.getOperationId()}`),\n schema: requestSchema,\n keys: requestSchema.properties ? Object.keys(requestSchema.properties) : undefined,\n keysToOmit: requestSchema.properties\n ? Object.keys(requestSchema.properties).filter((key) => {\n const item = requestSchema.properties?.[key] as OasTypes.SchemaObject\n\n return item?.readOnly\n })\n : undefined,\n }\n : undefined,\n response: {\n name: resolveName(transformers.pascalCase(`${operation.getOperationId()} ${operation.method === 'get' ? 'queryResponse' : 'mutationResponse'}`)),\n description: operation.getResponseAsJSONSchema(responseStatusCode)?.at(0)?.description,\n operation,\n operationName: transformers.pascalCase(`${operation.getOperationId()}`),\n schema: responseSchema,\n statusCode: Number(responseStatusCode),\n keys: responseSchema?.properties ? Object.keys(responseSchema.properties) : undefined,\n keysToOmit: responseSchema?.properties\n ? Object.keys(responseSchema.properties).filter((key) => {\n const item = responseSchema.properties?.[key] as OasTypes.SchemaObject\n return item?.writeOnly\n })\n : undefined,\n },\n errors: statusCodes.filter((item) => item.statusCode?.toString().startsWith('4') || item.statusCode?.toString().startsWith('5')),\n statusCodes,\n }\n }\n\n #methods = ['get', 'post', 'patch', 'put', 'delete']\n\n async build(...generators: Array<Generator<Extract<TOptions, PluginFactoryOptions>>>): Promise<Array<KubbFile.File<TFileMeta>>> {\n const { oas } = this.context\n\n const paths = oas.getPaths()\n this.operationsByMethod = Object.entries(paths).reduce((acc, [path, method]) => {\n const methods = Object.keys(method) as HttpMethod[]\n\n methods.forEach((method) => {\n const operation = oas.operation(path, method)\n if (operation && [this.#methods].some((methods) => method === operation.method)) {\n const isExcluded = this.#isExcluded(operation, method)\n const isIncluded = this.context.include ? this.#isIncluded(operation, method) : true\n\n if (isIncluded && !isExcluded) {\n if (!acc[path]) {\n acc[path] = {} as OperationsByMethod['get']\n }\n acc[path] = {\n ...acc[path],\n [method]: {\n operation,\n schemas: this.getSchemas(operation),\n },\n } as OperationsByMethod['get']\n }\n }\n })\n\n return acc\n }, {} as OperationsByMethod)\n\n const promises = Object.keys(this.operationsByMethod).reduce((acc, path) => {\n const methods = this.operationsByMethod[path] ? (Object.keys(this.operationsByMethod[path]!) as HttpMethod[]) : []\n\n methods.forEach((method) => {\n const { operation } = this.operationsByMethod[path]?.[method]!\n const options = this.#getOptions(operation, method)\n\n const methodToCall = this[method as keyof typeof this] as any\n\n if (typeof methodToCall === 'function') {\n const promiseMethod = methodToCall?.call(this, operation, {\n ...this.options,\n ...options,\n })\n\n if (promiseMethod) {\n acc.push(promiseMethod)\n }\n }\n\n const promiseOperation = this.operation.call(this, operation, {\n ...this.options,\n ...options,\n })\n\n if (promiseOperation) {\n acc.push(promiseOperation)\n }\n\n generators?.forEach((generator) => {\n const promise = generator.operation?.({\n instance: this,\n operation,\n options: {\n ...this.options,\n ...options,\n },\n } as any) as Promise<Array<KubbFile.File<TFileMeta>>>\n\n if (promise) {\n acc.push(promise)\n }\n })\n })\n\n return acc\n }, [] as OperationMethodResult<TFileMeta>[])\n\n const operations = Object.values(this.operationsByMethod).map((item) => Object.values(item).map((item) => item.operation))\n\n promises.push(this.all(operations.flat().filter(Boolean), this.operationsByMethod))\n\n generators?.forEach((generator) => {\n const promise = generator.operations?.({\n instance: this,\n operations: operations.flat().filter(Boolean),\n operationsByMethod: this.operationsByMethod,\n options: this.options,\n } as any) as Promise<Array<KubbFile.File<TFileMeta>>>\n\n if (promise) {\n promises.push(promise)\n }\n })\n\n const files = await Promise.all(promises)\n\n // using .flat because operationGenerator[method] can return a array of files or just one file\n return files.flat().filter(Boolean)\n }\n\n /**\n * Operation\n */\n async operation(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta> {\n return []\n }\n\n /**\n * GET\n */\n async get(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta> {\n return []\n }\n\n /**\n * POST\n */\n async post(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta> {\n return []\n }\n /**\n * PATCH\n */\n async patch(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta> {\n return []\n }\n\n /**\n * PUT\n */\n async put(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta> {\n return []\n }\n\n /**\n * DELETE\n */\n async delete(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta> {\n return []\n }\n\n /**\n * Combination of GET, POST, PATCH, PUT, DELETE\n */\n async all(operations: Operation[], paths: OperationsByMethod): OperationMethodResult<TFileMeta> {\n return []\n }\n}\n","import path from 'node:path'\n\nimport { createPlugin } from '@kubb/core'\nimport { camelCase } from '@kubb/core/transformers'\n\nimport { getSchemas } from './utils/getSchemas.ts'\nimport { parseFromConfig } from './utils/parseFromConfig.ts'\n\nimport type { Config } from '@kubb/core'\nimport type { Logger } from '@kubb/core/logger'\nimport type { Oas, OasTypes } from '@kubb/oas'\nimport type { FormatOptions } from '@kubb/oas/parser'\nimport type { PluginOas } from './types.ts'\n\nexport const pluginOasName = 'plugin-oas' satisfies PluginOas['name']\n\nexport const pluginOas = createPlugin<PluginOas>((options) => {\n const {\n output = { path: 'schemas', export: false },\n experimentalFilter: filter,\n experimentalSort: sort,\n validate = true,\n serverIndex = 0,\n contentType,\n oasClass,\n } = options\n\n const getOas = async ({ config, logger, formatOptions }: { config: Config; logger: Logger; formatOptions?: FormatOptions }): Promise<Oas> => {\n try {\n // needs to be in a different variable or the catch here will not work(return of a promise instead)\n const oas = await parseFromConfig(config, formatOptions, oasClass)\n\n if (validate) {\n await oas.valdiate()\n }\n\n return oas\n } catch (e) {\n const error = e as Error\n\n logger.emit('warning', error?.message)\n return parseFromConfig(config, {}, oasClass)\n }\n }\n\n return {\n name: pluginOasName,\n output:\n output === false\n ? {\n path: '',\n exportType: false,\n }\n : {\n exportType: 'barrelNamed',\n ...output,\n },\n options,\n context() {\n const { config, logger } = this\n\n return {\n getOas(formatOptions) {\n return getOas({ config, logger, formatOptions })\n },\n async getSchemas({ includes } = {}) {\n const oas = await this.getOas()\n return getSchemas({ oas, contentType, includes })\n },\n async getBaseURL() {\n const oasInstance = await this.getOas()\n const baseURL = oasInstance.api.servers?.at(serverIndex)?.url\n return baseURL\n },\n contentType,\n }\n },\n async buildStart() {\n if (!output) {\n return\n }\n\n const oas = await getOas({\n config: this.config,\n logger: this.logger,\n formatOptions: {\n filterSet: filter,\n sortSet: sort,\n },\n })\n await oas.dereference()\n\n const root = path.resolve(this.config.root, this.config.output.path)\n const schemas = getSchemas({ oas, contentType })\n\n const mapSchema = async ([name, schema]: [string, OasTypes.SchemaObject]) => {\n const baseName = `${camelCase(name)}.json` as `${string}.json`\n const resolvedPath = path.resolve(root, output.path, baseName)\n\n await this.addFile({\n path: resolvedPath,\n baseName,\n meta: {\n pluginKey: this.plugin.key,\n },\n sources: [\n {\n name: camelCase(name),\n isExportable: false,\n isIndexable: false,\n value: JSON.stringify(schema),\n },\n ],\n })\n }\n\n const promises = Object.entries(schemas).map(mapSchema)\n await Promise.all(promises)\n },\n }\n})\n","import type { PluginFactoryOptions } from '@kubb/core'\nimport type * as KubbFile from '@kubb/fs/types'\nimport type { Operation, SchemaObject } from '@kubb/oas'\nimport { Oas } from '@kubb/plugin-oas/components'\nimport { App, createRoot } from '@kubb/react'\nimport type { KubbNode } from '@kubb/react/types'\nimport type { OperationGenerator } from './OperationGenerator.ts'\nimport type { SchemaGenerator, SchemaGeneratorOptions } from './SchemaGenerator.ts'\nimport type { OperationsByMethod } from './types.ts'\n\ntype OperationsProps<TOptions extends PluginFactoryOptions> = {\n instance: Omit<OperationGenerator<TOptions>, 'build'>\n options: TOptions['resolvedOptions']\n operations: Array<Operation>\n operationsByMethod: OperationsByMethod\n}\n\ntype OperationProps<TOptions extends PluginFactoryOptions> = {\n instance: Omit<OperationGenerator<TOptions>, 'build'>\n options: TOptions['resolvedOptions']\n operation: Operation\n}\n\ntype SchemaProps<TOptions extends PluginFactoryOptions> = {\n instance: Omit<SchemaGenerator<SchemaGeneratorOptions, TOptions>, 'build'>\n name: string\n schema: SchemaObject\n options: TOptions['resolvedOptions']\n}\n\nexport type GeneratorOptions<TOptions extends PluginFactoryOptions> = {\n name: string\n operations?: (props: OperationsProps<TOptions>) => Promise<KubbFile.File[]>\n operation?: (props: OperationProps<TOptions>) => Promise<KubbFile.File[]>\n schema?: (props: SchemaProps<TOptions>) => Promise<KubbFile.File[]>\n}\n\nexport type Generator<TOptions extends PluginFactoryOptions> = GeneratorOptions<TOptions>\n\nexport function createGenerator<TOptions extends PluginFactoryOptions>(parseOptions: GeneratorOptions<TOptions>): Generator<TOptions> {\n return parseOptions\n}\n\nexport type ReactGeneratorOptions<TOptions extends PluginFactoryOptions> = {\n name: string\n Operations?: (props: OperationsProps<TOptions>) => KubbNode\n Operation?: (props: OperationProps<TOptions>) => KubbNode\n Schema?: (props: SchemaProps<TOptions>) => KubbNode\n /**\n * Combine all react nodes and only render ones(to string or render)\n */\n render?: () => any\n}\n\nexport function createReactGenerator<TOptions extends PluginFactoryOptions>(parseOptions: ReactGeneratorOptions<TOptions>): Generator<TOptions> {\n return {\n ...parseOptions,\n async operations({ instance, options, operations, operationsByMethod }) {\n if (!parseOptions.Operations) {\n return []\n }\n\n const { pluginManager, oas, plugin, mode } = instance.context\n const root = createRoot({\n logger: pluginManager.logger,\n })\n\n root.render(\n <App pluginManager={pluginManager} plugin={plugin} mode={mode}>\n <Oas oas={oas} operations={operations} generator={instance}>\n <parseOptions.Operations operations={operations} instance={instance} operationsByMethod={operationsByMethod} options={options} />\n </Oas>\n </App>,\n )\n\n return root.files\n },\n async operation({ instance, operation, options }) {\n if (!parseOptions.Operation) {\n return []\n }\n\n const { pluginManager, oas, plugin, mode } = instance.context\n const root = createRoot({\n logger: pluginManager.logger,\n })\n\n root.render(\n <App pluginManager={pluginManager} plugin={{ ...plugin, options }} mode={mode}>\n <Oas oas={oas} operations={[operation]} generator={instance}>\n <Oas.Operation operation={operation}>\n <parseOptions.Operation operation={operation} options={options} instance={instance} />\n </Oas.Operation>\n </Oas>\n </App>,\n )\n\n return root.files\n },\n async schema({ instance, schema, name, options }) {\n if (!parseOptions.Schema) {\n return []\n }\n\n const { pluginManager, oas, plugin, mode } = instance.context\n const root = createRoot({\n logger: pluginManager.logger,\n })\n\n const tree = instance.parse({ schema, name })\n\n root.render(\n <App pluginManager={pluginManager} plugin={{ ...plugin, options }} mode={mode}>\n <Oas oas={oas}>\n <Oas.Schema name={name} value={schema} tree={tree}>\n <parseOptions.Schema schema={schema} options={options} instance={instance} name={name} />\n </Oas.Schema>\n </Oas>\n </App>,\n )\n\n return root.files\n },\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/OperationGenerator.ts","../src/plugin.ts"],"names":["BaseGenerator","transformers","path","method","methods","item","createPlugin","jsonGenerator","parseFromConfig","getSchemas","options","FileManager","SchemaGenerator"],"mappings":";;;;;;;;;;;;;;;;;AA2Ba,IAAA,kBAAA,GAAN,cAGGA,kBAA6G,CAAA;AAAA,EACrH,sBAA0C,EAAC;AAAA,EAC3C,IAAI,kBAAyC,GAAA;AAC3C,IAAA,OAAO,IAAK,CAAA,mBAAA;AAAA;AACd,EAEA,IAAI,mBAAmB,KAA2B,EAAA;AAChD,IAAA,IAAA,CAAK,mBAAsB,GAAA,KAAA;AAAA;AAC7B,EAEA,WAAA,CAAY,WAAsB,MAAgE,EAAA;AAChG,IAAA,MAAM,EAAE,QAAA,GAAW,EAAC,KAAM,IAAK,CAAA,OAAA;AAE/B,IAAA,OACE,SAAS,IAAK,CAAA,CAAC,EAAE,OAAA,EAAS,MAAW,KAAA;AACnC,MAAA,IAAI,SAAS,KAAO,EAAA;AAClB,QAAO,OAAA,CAAC,CAAC,SAAU,CAAA,OAAA,GAAU,CAAC,CAAA,EAAG,IAAK,CAAA,KAAA,CAAM,OAAO,CAAA;AAAA;AAGrD,MAAA,IAAI,SAAS,aAAe,EAAA;AAC1B,QAAA,OAAO,CAAC,CAAC,SAAA,CAAU,cAAe,EAAA,CAAE,MAAM,OAAO,CAAA;AAAA;AAGnD,MAAA,IAAI,SAAS,MAAQ,EAAA;AACnB,QAAA,OAAO,CAAC,CAAC,SAAU,CAAA,IAAA,CAAK,MAAM,OAAO,CAAA;AAAA;AAGvC,MAAA,IAAI,SAAS,QAAU,EAAA;AACrB,QAAA,OAAO,CAAC,CA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","sourcesContent":["import { BaseGenerator, type FileMetaBase } from '@kubb/core'\nimport transformers from '@kubb/core/transformers'\n\nimport type { PluginFactoryOptions, PluginManager } from '@kubb/core'\nimport type * as KubbFile from '@kubb/fs/types'\n\nimport type { Plugin } from '@kubb/core'\nimport type { HttpMethod, Oas, OasTypes, Operation, SchemaObject, contentType } from '@kubb/oas'\nimport type { Generator } from './generator.tsx'\nimport type { Exclude, Include, OperationSchemas, OperationsByMethod, Override } from './types.ts'\n\nexport type OperationMethodResult<TFileMeta extends FileMetaBase> = Promise<KubbFile.File<TFileMeta> | Array<KubbFile.File<TFileMeta>> | null>\n\ntype Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {\n oas: Oas\n exclude: Array<Exclude> | undefined\n include: Array<Include> | undefined\n override: Array<Override<TOptions>> | undefined\n contentType: contentType | undefined\n pluginManager: PluginManager\n /**\n * Current plugin\n */\n plugin: Plugin<TPluginOptions>\n mode: KubbFile.Mode\n}\n\nexport class OperationGenerator<\n TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions,\n TFileMeta extends FileMetaBase = FileMetaBase,\n> extends BaseGenerator<TPluginOptions['resolvedOptions'], Context<TPluginOptions['resolvedOptions'], TPluginOptions>> {\n #operationsByMethod: OperationsByMethod = {}\n get operationsByMethod(): OperationsByMethod {\n return this.#operationsByMethod\n }\n\n set operationsByMethod(paths: OperationsByMethod) {\n this.#operationsByMethod = paths\n }\n\n #getOptions(operation: Operation, method: HttpMethod): Partial<TPluginOptions['resolvedOptions']> {\n const { override = [] } = this.context\n\n return (\n override.find(({ pattern, type }) => {\n if (type === 'tag') {\n return !!operation.getTags()[0]?.name.match(pattern)\n }\n\n if (type === 'operationId') {\n return !!operation.getOperationId().match(pattern)\n }\n\n if (type === 'path') {\n return !!operation.path.match(pattern)\n }\n\n if (type === 'method') {\n return !!method.match(pattern)\n }\n\n return false\n })?.options || {}\n )\n }\n\n #isExcluded(operation: Operation, method: HttpMethod): boolean {\n const { exclude = [] } = this.context\n let matched = false\n\n exclude.forEach(({ pattern, type }) => {\n if (type === 'tag' && !matched) {\n matched = !!operation.getTags()[0]?.name.match(pattern)\n }\n\n if (type === 'operationId' && !matched) {\n matched = !!operation.getOperationId().match(pattern)\n }\n\n if (type === 'path' && !matched) {\n matched = !!operation.path.match(pattern)\n }\n\n if (type === 'method' && !matched) {\n matched = !!method.match(pattern)\n }\n })\n\n return matched\n }\n\n #isIncluded(operation: Operation, method: HttpMethod): boolean {\n const { include = [] } = this.context\n let matched = false\n\n include.forEach(({ pattern, type }) => {\n if (type === 'tag' && !matched) {\n matched = !!operation.getTags()[0]?.name.match(pattern)\n }\n\n if (type === 'operationId' && !matched) {\n matched = !!operation.getOperationId().match(pattern)\n }\n\n if (type === 'path' && !matched) {\n matched = !!operation.path.match(pattern)\n }\n\n if (type === 'method' && !matched) {\n matched = !!method.match(pattern)\n }\n })\n\n return matched\n }\n\n getSchemas(\n operation: Operation,\n {\n resolveName = (name) => name,\n }: {\n resolveName?: (name: string) => string\n } = {},\n ): OperationSchemas {\n const pathParamsSchema = this.context.oas.getParametersSchema(operation, 'path')\n const queryParamsSchema = this.context.oas.getParametersSchema(operation, 'query')\n const headerParamsSchema = this.context.oas.getParametersSchema(operation, 'header')\n const requestSchema = this.context.oas.getRequestSchema(operation)\n const statusCodes = operation.getResponseStatusCodes().map((statusCode) => {\n let name = statusCode\n if (name === 'default') {\n name = 'error'\n }\n\n const schema = this.context.oas.getResponseSchema(operation, statusCode)\n\n return {\n name: resolveName(transformers.pascalCase(`${operation.getOperationId()} ${name}`)),\n description: (operation.getResponseByStatusCode(statusCode) as OasTypes.ResponseObject)?.description,\n schema,\n operation,\n operationName: transformers.pascalCase(`${operation.getOperationId()}`),\n statusCode: name === 'error' ? undefined : Number(statusCode),\n keys: schema?.properties ? Object.keys(schema.properties) : undefined,\n keysToOmit: schema?.properties\n ? Object.keys(schema.properties).filter((key) => {\n const item = schema.properties?.[key] as OasTypes.SchemaObject\n return item?.writeOnly\n })\n : undefined,\n }\n })\n const hasResponses = statusCodes.some((item) => item.statusCode?.toString().startsWith('2'))\n\n return {\n pathParams: pathParamsSchema\n ? {\n name: resolveName(transformers.pascalCase(`${operation.getOperationId()} PathParams`)),\n operation,\n operationName: transformers.pascalCase(`${operation.getOperationId()}`),\n schema: pathParamsSchema,\n keys: pathParamsSchema.properties ? Object.keys(pathParamsSchema.properties) : undefined,\n }\n : undefined,\n queryParams: queryParamsSchema\n ? {\n name: resolveName(transformers.pascalCase(`${operation.getOperationId()} QueryParams`)),\n operation,\n operationName: transformers.pascalCase(`${operation.getOperationId()}`),\n schema: queryParamsSchema,\n keys: queryParamsSchema.properties ? Object.keys(queryParamsSchema.properties) : [],\n }\n : undefined,\n headerParams: headerParamsSchema\n ? {\n name: resolveName(transformers.pascalCase(`${operation.getOperationId()} HeaderParams`)),\n operation,\n operationName: transformers.pascalCase(`${operation.getOperationId()}`),\n schema: headerParamsSchema,\n keys: headerParamsSchema.properties ? Object.keys(headerParamsSchema.properties) : undefined,\n }\n : undefined,\n request: requestSchema\n ? {\n name: resolveName(transformers.pascalCase(`${operation.getOperationId()} ${operation.method === 'get' ? 'queryRequest' : 'mutationRequest'}`)),\n description: (operation.schema.requestBody as OasTypes.RequestBodyObject)?.description,\n operation,\n operationName: transformers.pascalCase(`${operation.getOperationId()}`),\n schema: requestSchema,\n keys: requestSchema.properties ? Object.keys(requestSchema.properties) : undefined,\n keysToOmit: requestSchema.properties\n ? Object.keys(requestSchema.properties).filter((key) => {\n const item = requestSchema.properties?.[key] as OasTypes.SchemaObject\n\n return item?.readOnly\n })\n : undefined,\n }\n : undefined,\n response: {\n name: resolveName(transformers.pascalCase(`${operation.getOperationId()} ${operation.method === 'get' ? 'queryResponse' : 'mutationResponse'}`)),\n operation,\n operationName: transformers.pascalCase(`${operation.getOperationId()}`),\n schema: {\n oneOf: hasResponses\n ? statusCodes\n .filter((item) => item.statusCode?.toString().startsWith('2'))\n .map((item) => {\n return {\n ...item.schema,\n $ref: resolveName(transformers.pascalCase(`${operation.getOperationId()} ${item.statusCode}`)),\n }\n })\n : undefined,\n } as SchemaObject,\n },\n responses: statusCodes.filter((item) => item.statusCode?.toString().startsWith('2')),\n errors: statusCodes.filter((item) => item.statusCode?.toString().startsWith('4') || item.statusCode?.toString().startsWith('5')),\n statusCodes,\n }\n }\n\n #methods = ['get', 'post', 'patch', 'put', 'delete']\n\n async build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<KubbFile.File<TFileMeta>>> {\n const { oas } = this.context\n\n const paths = oas.getPaths()\n this.operationsByMethod = Object.entries(paths).reduce((acc, [path, method]) => {\n const methods = Object.keys(method) as HttpMethod[]\n\n methods.forEach((method) => {\n const operation = oas.operation(path, method)\n if (operation && [this.#methods].some((methods) => method === operation.method)) {\n const isExcluded = this.#isExcluded(operation, method)\n const isIncluded = this.context.include ? this.#isIncluded(operation, method) : true\n\n if (isIncluded && !isExcluded) {\n if (!acc[path]) {\n acc[path] = {} as OperationsByMethod['get']\n }\n acc[path] = {\n ...acc[path],\n [method]: {\n operation,\n schemas: this.getSchemas(operation),\n },\n } as OperationsByMethod['get']\n }\n }\n })\n\n return acc\n }, {} as OperationsByMethod)\n\n const promises = Object.keys(this.operationsByMethod).reduce((acc, path) => {\n const methods = this.operationsByMethod[path] ? (Object.keys(this.operationsByMethod[path]!) as HttpMethod[]) : []\n\n methods.forEach((method) => {\n const { operation } = this.operationsByMethod[path]?.[method]!\n const options = this.#getOptions(operation, method)\n\n const methodToCall = this[method as keyof typeof this] as any\n\n if (typeof methodToCall === 'function') {\n const promiseMethod = methodToCall?.call(this, operation, {\n ...this.options,\n ...options,\n })\n\n if (promiseMethod) {\n acc.push(promiseMethod)\n }\n }\n\n const promiseOperation = this.operation.call(this, operation, {\n ...this.options,\n ...options,\n })\n\n if (promiseOperation) {\n acc.push(promiseOperation)\n }\n\n generators?.forEach((generator) => {\n const promise = generator.operation?.({\n instance: this,\n operation,\n options: {\n ...this.options,\n ...options,\n },\n } as any) as Promise<Array<KubbFile.File<TFileMeta>>>\n\n if (promise) {\n acc.push(promise)\n }\n })\n })\n\n return acc\n }, [] as OperationMethodResult<TFileMeta>[])\n\n const operations = Object.values(this.operationsByMethod).map((item) => Object.values(item).map((item) => item.operation))\n\n promises.push(this.all(operations.flat().filter(Boolean), this.operationsByMethod))\n\n generators?.forEach((generator) => {\n const promise = generator.operations?.({\n instance: this,\n operations: operations.flat().filter(Boolean),\n operationsByMethod: this.operationsByMethod,\n options: this.options,\n } as any) as Promise<Array<KubbFile.File<TFileMeta>>>\n\n if (promise) {\n promises.push(promise)\n }\n })\n\n const files = await Promise.all(promises)\n\n // using .flat because operationGenerator[method] can return a array of files or just one file\n return files.flat().filter(Boolean)\n }\n\n /**\n * Operation\n */\n async operation(operation: Operation, options: TPluginOptions['resolvedOptions']): OperationMethodResult<TFileMeta> {\n return []\n }\n\n /**\n * GET\n */\n async get(operation: Operation, options: TPluginOptions['resolvedOptions']): OperationMethodResult<TFileMeta> {\n return []\n }\n\n /**\n * POST\n */\n async post(operation: Operation, options: TPluginOptions['resolvedOptions']): OperationMethodResult<TFileMeta> {\n return []\n }\n /**\n * PATCH\n */\n async patch(operation: Operation, options: TPluginOptions['resolvedOptions']): OperationMethodResult<TFileMeta> {\n return []\n }\n\n /**\n * PUT\n */\n async put(operation: Operation, options: TPluginOptions['resolvedOptions']): OperationMethodResult<TFileMeta> {\n return []\n }\n\n /**\n * DELETE\n */\n async delete(operation: Operation, options: TPluginOptions['resolvedOptions']): OperationMethodResult<TFileMeta> {\n return []\n }\n\n /**\n * Combination of GET, POST, PATCH, PUT, DELETE\n */\n async all(operations: Operation[], paths: OperationsByMethod): OperationMethodResult<TFileMeta> {\n return []\n }\n}\n","import { FileManager, createPlugin } from '@kubb/core'\n\nimport { getSchemas } from './utils/getSchemas.ts'\nimport { parseFromConfig } from './utils/parseFromConfig.ts'\n\nimport path from 'node:path'\nimport type { Config } from '@kubb/core'\nimport type { Logger } from '@kubb/core/logger'\nimport type { Oas } from '@kubb/oas'\nimport { OperationGenerator } from './OperationGenerator.ts'\nimport { SchemaGenerator } from './SchemaGenerator.ts'\nimport { jsonGenerator } from './generators'\nimport type { PluginOas } from './types.ts'\n\nexport const pluginOasName = 'plugin-oas' satisfies PluginOas['name']\n\nexport const pluginOas = createPlugin<PluginOas>((options) => {\n const {\n output = {\n path: 'schemas',\n },\n validate = true,\n generators = [jsonGenerator],\n serverIndex = 0,\n contentType,\n oasClass,\n } = options\n\n const getOas = async ({ config, logger }: { config: Config; logger: Logger }): Promise<Oas> => {\n try {\n // needs to be in a different variable or the catch here will not work(return of a promise instead)\n const oas = await parseFromConfig(config, oasClass)\n\n if (validate) {\n await oas.valdiate()\n }\n\n return oas\n } catch (e) {\n const error = e as Error\n\n logger.emit('warning', error?.message)\n return parseFromConfig(config, oasClass)\n }\n }\n\n return {\n name: pluginOasName,\n options: {\n output,\n ...options,\n },\n context() {\n const { config, logger } = this\n\n return {\n getOas() {\n return getOas({ config, logger })\n },\n async getSchemas({ includes } = {}) {\n const oas = await this.getOas()\n return getSchemas({ oas, contentType, includes })\n },\n async getBaseURL() {\n const oasInstance = await this.getOas()\n return oasInstance.api.servers?.at(serverIndex)?.url\n },\n contentType,\n }\n },\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 === 'single') {\n /**\n * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend\n * Other plugins then need to call addOrAppend instead of just add from the fileManager class\n */\n return path.resolve(root, output.path)\n }\n\n return path.resolve(root, output.path, baseName)\n },\n async buildStart() {\n if (!output) {\n return\n }\n\n const oas = await getOas({\n config: this.config,\n logger: this.logger,\n })\n await oas.dereference()\n\n const schemaGenerator = new SchemaGenerator(\n {\n unknownType: 'unknown',\n dateType: 'date',\n transformers: {},\n ...this.plugin.options,\n },\n {\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType,\n include: undefined,\n override: undefined,\n mode: 'split',\n output: output.path,\n },\n )\n\n const schemaFiles = await schemaGenerator.build(...generators)\n await this.addFile(...schemaFiles)\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType,\n exclude: undefined,\n include: undefined,\n override: undefined,\n mode: 'split',\n })\n\n const operationFiles = await operationGenerator.build(...generators)\n\n await this.addFile(...operationFiles)\n },\n }\n})\n"]}
package/dist/index.d.cts CHANGED
@@ -1,12 +1,9 @@
1
- export { h as Generator, i as GeneratorOptions, G as GetOperationGeneratorOptions, b as GetSchemaGeneratorOptions, a as OperationGenerator, O as OperationMethodResult, R as ReactGeneratorOptions, e as SchemaGenerator, S as SchemaGeneratorBuildOptions, c as SchemaGeneratorOptions, d as SchemaMethodResult, f as createGenerator, g as createReactGenerator } from './OperationGenerator-Gd1X7wUz.cjs';
1
+ import { O as Options, P as PluginOas } from './OperationGenerator-Dko8Xtd7.cjs';
2
+ export { A as API, E as Exclude, o as Generator, p as GeneratorOptions, G as GetSchemaGeneratorOptions, I as Include, b as OperationGenerator, a as OperationMethodResult, v as OperationSchema, w as OperationSchemas, x as OperationsByMethod, y as Override, R as ReactGeneratorOptions, r as Ref, t as Refs, q as ResolvePathOptions, u as Resolver, f as Schema, e as SchemaGenerator, S as SchemaGeneratorBuildOptions, c as SchemaGeneratorOptions, h as SchemaKeyword, i as SchemaKeywordBase, j as SchemaKeywordMapper, k as SchemaMapper, d as SchemaMethodResult, g as SchemaTree, m as createGenerator, n as createReactGenerator, l as isKeyword, s as schemaKeywords } from './OperationGenerator-Dko8Xtd7.cjs';
2
3
  import * as _kubb_core from '@kubb/core';
3
- import { O as Options, P as PluginOas } from './types-CZTUCaE5.cjs';
4
- export { A as API, E as Exclude, I as Include, d as OperationSchema, e as OperationSchemas, f as OperationsByMethod, g as Override, a as Ref, b as Refs, R as ResolvePathOptions, c as Resolver } from './types-CZTUCaE5.cjs';
5
- export { S as Schema, a as SchemaKeyword, b as SchemaKeywordBase, c as SchemaKeywordMapper, d as SchemaMapper, i as isKeyword, s as schemaKeywords } from './SchemaMapper-sGcY1xL5.cjs';
6
4
  import '@kubb/fs/types';
7
5
  import '@kubb/oas';
8
6
  import '@kubb/react/types';
9
- import '@kubb/oas/parser';
10
7
 
11
8
  declare const pluginOasName = "plugin-oas";
12
9
  declare const pluginOas: (options?: Options | undefined) => _kubb_core.UserPluginWithLifeCycle<PluginOas>;
package/dist/index.d.ts CHANGED
@@ -1,12 +1,9 @@
1
- export { h as Generator, i as GeneratorOptions, G as GetOperationGeneratorOptions, b as GetSchemaGeneratorOptions, a as OperationGenerator, O as OperationMethodResult, R as ReactGeneratorOptions, e as SchemaGenerator, S as SchemaGeneratorBuildOptions, c as SchemaGeneratorOptions, d as SchemaMethodResult, f as createGenerator, g as createReactGenerator } from './OperationGenerator-By5WOmWB.js';
1
+ import { O as Options, P as PluginOas } from './OperationGenerator-Dko8Xtd7.js';
2
+ export { A as API, E as Exclude, o as Generator, p as GeneratorOptions, G as GetSchemaGeneratorOptions, I as Include, b as OperationGenerator, a as OperationMethodResult, v as OperationSchema, w as OperationSchemas, x as OperationsByMethod, y as Override, R as ReactGeneratorOptions, r as Ref, t as Refs, q as ResolvePathOptions, u as Resolver, f as Schema, e as SchemaGenerator, S as SchemaGeneratorBuildOptions, c as SchemaGeneratorOptions, h as SchemaKeyword, i as SchemaKeywordBase, j as SchemaKeywordMapper, k as SchemaMapper, d as SchemaMethodResult, g as SchemaTree, m as createGenerator, n as createReactGenerator, l as isKeyword, s as schemaKeywords } from './OperationGenerator-Dko8Xtd7.js';
2
3
  import * as _kubb_core from '@kubb/core';
3
- import { O as Options, P as PluginOas } from './types-CZTUCaE5.js';
4
- export { A as API, E as Exclude, I as Include, d as OperationSchema, e as OperationSchemas, f as OperationsByMethod, g as Override, a as Ref, b as Refs, R as ResolvePathOptions, c as Resolver } from './types-CZTUCaE5.js';
5
- export { S as Schema, a as SchemaKeyword, b as SchemaKeywordBase, c as SchemaKeywordMapper, d as SchemaMapper, i as isKeyword, s as schemaKeywords } from './SchemaMapper-sGcY1xL5.js';
6
4
  import '@kubb/fs/types';
7
5
  import '@kubb/oas';
8
6
  import '@kubb/react/types';
9
- import '@kubb/oas/parser';
10
7
 
11
8
  declare const pluginOasName = "plugin-oas";
12
9
  declare const pluginOas: (options?: Options | undefined) => _kubb_core.UserPluginWithLifeCycle<PluginOas>;
package/dist/index.js CHANGED
@@ -1,27 +1,15 @@
1
- import {
2
- parseFromConfig
3
- } from "./chunk-N7EEVJA6.js";
4
- import "./chunk-SQ64ESS4.js";
5
- import {
6
- Oas,
7
- SchemaGenerator,
8
- isKeyword,
9
- require_jsx_runtime,
10
- schemaKeywords
11
- } from "./chunk-M347763D.js";
12
- import {
13
- __toESM,
14
- getSchemas,
15
- init_esm_shims
16
- } from "./chunk-SZDO532A.js";
1
+ import { parseFromConfig } from './chunk-BG77DP54.js';
2
+ import { jsonGenerator } from './chunk-TNWNNVQW.js';
3
+ export { createGenerator, createReactGenerator } from './chunk-TNWNNVQW.js';
4
+ import './chunk-R47XMJ32.js';
5
+ import { SchemaGenerator } from './chunk-JA75IPYU.js';
6
+ export { SchemaGenerator, isKeyword, schemaKeywords } from './chunk-JA75IPYU.js';
7
+ import { getSchemas } from './chunk-XNCEFOE6.js';
8
+ import './chunk-GF26SDHQ.js';
9
+ import { createPlugin, FileManager, BaseGenerator } from '@kubb/core';
10
+ import transformers from '@kubb/core/transformers';
11
+ import path from 'node:path';
17
12
 
18
- // src/index.ts
19
- init_esm_shims();
20
-
21
- // src/OperationGenerator.ts
22
- init_esm_shims();
23
- import { BaseGenerator } from "@kubb/core";
24
- import transformers from "@kubb/core/transformers";
25
13
  var OperationGenerator = class extends BaseGenerator {
26
14
  #operationsByMethod = {};
27
15
  get operationsByMethod() {
@@ -48,10 +36,6 @@ var OperationGenerator = class extends BaseGenerator {
48
36
  return false;
49
37
  })?.options || {};
50
38
  }
51
- /**
52
- *
53
- * @deprecated
54
- */
55
39
  #isExcluded(operation, method) {
56
40
  const { exclude = [] } = this.context;
57
41
  let matched = false;
@@ -71,10 +55,6 @@ var OperationGenerator = class extends BaseGenerator {
71
55
  });
72
56
  return matched;
73
57
  }
74
- /**
75
- *
76
- * @deprecated
77
- */
78
58
  #isIncluded(operation, method) {
79
59
  const { include = [] } = this.context;
80
60
  let matched = false;
@@ -95,15 +75,12 @@ var OperationGenerator = class extends BaseGenerator {
95
75
  return matched;
96
76
  }
97
77
  getSchemas(operation, {
98
- forStatusCode,
99
78
  resolveName = (name) => name
100
79
  } = {}) {
101
80
  const pathParamsSchema = this.context.oas.getParametersSchema(operation, "path");
102
81
  const queryParamsSchema = this.context.oas.getParametersSchema(operation, "query");
103
82
  const headerParamsSchema = this.context.oas.getParametersSchema(operation, "header");
104
83
  const requestSchema = this.context.oas.getRequestSchema(operation);
105
- const responseStatusCode = forStatusCode || operation.schema.responses && Object.keys(operation.schema.responses).find((key) => key.startsWith("2")) || 200;
106
- const responseSchema = this.context.oas.getResponseSchema(operation, responseStatusCode);
107
84
  const statusCodes = operation.getResponseStatusCodes().map((statusCode) => {
108
85
  let name = statusCode;
109
86
  if (name === "default") {
@@ -117,9 +94,14 @@ var OperationGenerator = class extends BaseGenerator {
117
94
  operation,
118
95
  operationName: transformers.pascalCase(`${operation.getOperationId()}`),
119
96
  statusCode: name === "error" ? void 0 : Number(statusCode),
120
- keys: schema?.properties ? Object.keys(schema.properties) : void 0
97
+ keys: schema?.properties ? Object.keys(schema.properties) : void 0,
98
+ keysToOmit: schema?.properties ? Object.keys(schema.properties).filter((key) => {
99
+ const item = schema.properties?.[key];
100
+ return item?.writeOnly;
101
+ }) : void 0
121
102
  };
122
103
  });
104
+ const hasResponses = statusCodes.some((item) => item.statusCode?.toString().startsWith("2"));
123
105
  return {
124
106
  pathParams: pathParamsSchema ? {
125
107
  name: resolveName(transformers.pascalCase(`${operation.getOperationId()} PathParams`)),
@@ -156,17 +138,18 @@ var OperationGenerator = class extends BaseGenerator {
156
138
  } : void 0,
157
139
  response: {
158
140
  name: resolveName(transformers.pascalCase(`${operation.getOperationId()} ${operation.method === "get" ? "queryResponse" : "mutationResponse"}`)),
159
- description: operation.getResponseAsJSONSchema(responseStatusCode)?.at(0)?.description,
160
141
  operation,
161
142
  operationName: transformers.pascalCase(`${operation.getOperationId()}`),
162
- schema: responseSchema,
163
- statusCode: Number(responseStatusCode),
164
- keys: responseSchema?.properties ? Object.keys(responseSchema.properties) : void 0,
165
- keysToOmit: responseSchema?.properties ? Object.keys(responseSchema.properties).filter((key) => {
166
- const item = responseSchema.properties?.[key];
167
- return item?.writeOnly;
168
- }) : void 0
143
+ schema: {
144
+ oneOf: hasResponses ? statusCodes.filter((item) => item.statusCode?.toString().startsWith("2")).map((item) => {
145
+ return {
146
+ ...item.schema,
147
+ $ref: resolveName(transformers.pascalCase(`${operation.getOperationId()} ${item.statusCode}`))
148
+ };
149
+ }) : void 0
150
+ }
169
151
  },
152
+ responses: statusCodes.filter((item) => item.statusCode?.toString().startsWith("2")),
170
153
  errors: statusCodes.filter((item) => item.statusCode?.toString().startsWith("4") || item.statusCode?.toString().startsWith("5")),
171
154
  statusCodes
172
155
  };
@@ -295,26 +278,21 @@ var OperationGenerator = class extends BaseGenerator {
295
278
  return [];
296
279
  }
297
280
  };
298
-
299
- // src/plugin.ts
300
- init_esm_shims();
301
- import path from "node:path";
302
- import { createPlugin } from "@kubb/core";
303
- import { camelCase } from "@kubb/core/transformers";
304
281
  var pluginOasName = "plugin-oas";
305
282
  var pluginOas = createPlugin((options) => {
306
283
  const {
307
- output = { path: "schemas", export: false },
308
- experimentalFilter: filter,
309
- experimentalSort: sort,
284
+ output = {
285
+ path: "schemas"
286
+ },
310
287
  validate = true,
288
+ generators = [jsonGenerator],
311
289
  serverIndex = 0,
312
290
  contentType,
313
291
  oasClass
314
292
  } = options;
315
- const getOas = async ({ config, logger, formatOptions }) => {
293
+ const getOas = async ({ config, logger }) => {
316
294
  try {
317
- const oas = await parseFromConfig(config, formatOptions, oasClass);
295
+ const oas = await parseFromConfig(config, oasClass);
318
296
  if (validate) {
319
297
  await oas.valdiate();
320
298
  }
@@ -322,24 +300,20 @@ var pluginOas = createPlugin((options) => {
322
300
  } catch (e) {
323
301
  const error = e;
324
302
  logger.emit("warning", error?.message);
325
- return parseFromConfig(config, {}, oasClass);
303
+ return parseFromConfig(config, oasClass);
326
304
  }
327
305
  };
328
306
  return {
329
307
  name: pluginOasName,
330
- output: output === false ? {
331
- path: "",
332
- exportType: false
333
- } : {
334
- exportType: "barrelNamed",
335
- ...output
308
+ options: {
309
+ output,
310
+ ...options
336
311
  },
337
- options,
338
312
  context() {
339
313
  const { config, logger } = this;
340
314
  return {
341
- getOas(formatOptions) {
342
- return getOas({ config, logger, formatOptions });
315
+ getOas() {
316
+ return getOas({ config, logger });
343
317
  },
344
318
  async getSchemas({ includes } = {}) {
345
319
  const oas = await this.getOas();
@@ -347,112 +321,64 @@ var pluginOas = createPlugin((options) => {
347
321
  },
348
322
  async getBaseURL() {
349
323
  const oasInstance = await this.getOas();
350
- const baseURL = oasInstance.api.servers?.at(serverIndex)?.url;
351
- return baseURL;
324
+ return oasInstance.api.servers?.at(serverIndex)?.url;
352
325
  },
353
326
  contentType
354
327
  };
355
328
  },
329
+ resolvePath(baseName, pathMode, options2) {
330
+ const root = path.resolve(this.config.root, this.config.output.path);
331
+ const mode = pathMode ?? FileManager.getMode(path.resolve(root, output.path));
332
+ if (mode === "single") {
333
+ return path.resolve(root, output.path);
334
+ }
335
+ return path.resolve(root, output.path, baseName);
336
+ },
356
337
  async buildStart() {
357
338
  if (!output) {
358
339
  return;
359
340
  }
360
341
  const oas = await getOas({
361
342
  config: this.config,
362
- logger: this.logger,
363
- formatOptions: {
364
- filterSet: filter,
365
- sortSet: sort
366
- }
343
+ logger: this.logger
367
344
  });
368
345
  await oas.dereference();
369
- const root = path.resolve(this.config.root, this.config.output.path);
370
- const schemas = getSchemas({ oas, contentType });
371
- const mapSchema = async ([name, schema]) => {
372
- const baseName = `${camelCase(name)}.json`;
373
- const resolvedPath = path.resolve(root, output.path, baseName);
374
- await this.addFile({
375
- path: resolvedPath,
376
- baseName,
377
- meta: {
378
- pluginKey: this.plugin.key
379
- },
380
- sources: [
381
- {
382
- name: camelCase(name),
383
- isExportable: false,
384
- isIndexable: false,
385
- value: JSON.stringify(schema)
386
- }
387
- ]
388
- });
389
- };
390
- const promises = Object.entries(schemas).map(mapSchema);
391
- await Promise.all(promises);
392
- }
393
- };
394
- });
395
-
396
- // src/generator.tsx
397
- init_esm_shims();
398
- var import_jsx_runtime = __toESM(require_jsx_runtime(), 1);
399
- import { App, createRoot } from "@kubb/react";
400
- function createGenerator(parseOptions) {
401
- return parseOptions;
402
- }
403
- function createReactGenerator(parseOptions) {
404
- return {
405
- ...parseOptions,
406
- async operations({ instance, options, operations, operationsByMethod }) {
407
- if (!parseOptions.Operations) {
408
- return [];
409
- }
410
- const { pluginManager, oas, plugin, mode } = instance.context;
411
- const root = createRoot({
412
- logger: pluginManager.logger
413
- });
414
- root.render(
415
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(App, { pluginManager, plugin, mode, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Oas, { oas, operations, generator: instance, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(parseOptions.Operations, { operations, instance, operationsByMethod, options }) }) })
416
- );
417
- return root.files;
418
- },
419
- async operation({ instance, operation, options }) {
420
- if (!parseOptions.Operation) {
421
- return [];
422
- }
423
- const { pluginManager, oas, plugin, mode } = instance.context;
424
- const root = createRoot({
425
- logger: pluginManager.logger
426
- });
427
- root.render(
428
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(App, { pluginManager, plugin: { ...plugin, options }, mode, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Oas, { oas, operations: [operation], generator: instance, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Oas.Operation, { operation, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(parseOptions.Operation, { operation, options, instance }) }) }) })
346
+ const schemaGenerator = new SchemaGenerator(
347
+ {
348
+ unknownType: "unknown",
349
+ dateType: "date",
350
+ transformers: {},
351
+ ...this.plugin.options
352
+ },
353
+ {
354
+ oas,
355
+ pluginManager: this.pluginManager,
356
+ plugin: this.plugin,
357
+ contentType,
358
+ include: void 0,
359
+ override: void 0,
360
+ mode: "split",
361
+ output: output.path
362
+ }
429
363
  );
430
- return root.files;
431
- },
432
- async schema({ instance, schema, name, options }) {
433
- if (!parseOptions.Schema) {
434
- return [];
435
- }
436
- const { pluginManager, oas, plugin, mode } = instance.context;
437
- const root = createRoot({
438
- logger: pluginManager.logger
364
+ const schemaFiles = await schemaGenerator.build(...generators);
365
+ await this.addFile(...schemaFiles);
366
+ const operationGenerator = new OperationGenerator(this.plugin.options, {
367
+ oas,
368
+ pluginManager: this.pluginManager,
369
+ plugin: this.plugin,
370
+ contentType,
371
+ exclude: void 0,
372
+ include: void 0,
373
+ override: void 0,
374
+ mode: "split"
439
375
  });
440
- const tree = instance.parse({ schema, name });
441
- root.render(
442
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(App, { pluginManager, plugin: { ...plugin, options }, mode, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Oas, { oas, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Oas.Schema, { name, value: schema, tree, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(parseOptions.Schema, { schema, options, instance, name }) }) }) })
443
- );
444
- return root.files;
376
+ const operationFiles = await operationGenerator.build(...generators);
377
+ await this.addFile(...operationFiles);
445
378
  }
446
379
  };
447
- }
448
- export {
449
- OperationGenerator,
450
- SchemaGenerator,
451
- createGenerator,
452
- createReactGenerator,
453
- isKeyword,
454
- pluginOas,
455
- pluginOasName,
456
- schemaKeywords
457
- };
380
+ });
381
+
382
+ export { OperationGenerator, pluginOas, pluginOasName };
383
+ //# sourceMappingURL=index.js.map
458
384
  //# sourceMappingURL=index.js.map