@kubb/plugin-oas 3.0.0-alpha.3 → 3.0.0-alpha.30

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 (105) hide show
  1. package/README.md +13 -4
  2. package/dist/OperationGenerator-DhPriVDJ.d.cts +554 -0
  3. package/dist/OperationGenerator-DhPriVDJ.d.ts +554 -0
  4. package/dist/Schema-BfZVq77f.d.cts +22 -0
  5. package/dist/Schema-IlDbvlbP.d.ts +22 -0
  6. package/dist/chunk-4H2KTGZM.cjs +92 -0
  7. package/dist/chunk-4H2KTGZM.cjs.map +1 -0
  8. package/dist/chunk-ABIWUCV7.js +88 -0
  9. package/dist/chunk-ABIWUCV7.js.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-PADR76WZ.cjs +4 -0
  17. package/dist/chunk-PADR76WZ.cjs.map +1 -0
  18. package/dist/chunk-QAFBZLJA.cjs +48 -0
  19. package/dist/chunk-QAFBZLJA.cjs.map +1 -0
  20. package/dist/chunk-QT6ZFRNJ.cjs +752 -0
  21. package/dist/chunk-QT6ZFRNJ.cjs.map +1 -0
  22. package/dist/chunk-R47XMJ32.js +3 -0
  23. package/dist/chunk-R47XMJ32.js.map +1 -0
  24. package/dist/chunk-V2JO6RHI.js +744 -0
  25. package/dist/chunk-V2JO6RHI.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 +4 -7
  33. package/dist/components.d.ts +4 -7
  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 +102 -57
  43. package/dist/hooks.cjs.map +1 -1
  44. package/dist/hooks.d.cts +41 -10
  45. package/dist/hooks.d.ts +41 -10
  46. package/dist/hooks.js +91 -53
  47. package/dist/hooks.js.map +1 -1
  48. package/dist/index.cjs +192 -258
  49. package/dist/index.cjs.map +1 -1
  50. package/dist/index.d.cts +3 -6
  51. package/dist/index.d.ts +3 -6
  52. package/dist/index.js +135 -228
  53. package/dist/index.js.map +1 -1
  54. package/dist/utils.cjs +32 -87
  55. package/dist/utils.cjs.map +1 -1
  56. package/dist/utils.d.cts +8 -43
  57. package/dist/utils.d.ts +8 -43
  58. package/dist/utils.js +8 -86
  59. package/dist/utils.js.map +1 -1
  60. package/package.json +20 -14
  61. package/src/OperationGenerator.ts +23 -30
  62. package/src/SchemaGenerator.ts +80 -23
  63. package/src/SchemaMapper.ts +7 -5
  64. package/src/components/Oas.tsx +1 -1
  65. package/src/components/Operation.tsx +1 -1
  66. package/src/components/Schema.tsx +2 -102
  67. package/src/{parser.tsx → generator.tsx} +35 -22
  68. package/src/generators/index.ts +1 -0
  69. package/src/generators/jsonGenerator.ts +32 -0
  70. package/src/hooks/index.ts +2 -0
  71. package/src/hooks/useOperationManager.ts +77 -29
  72. package/src/hooks/useSchemaManager.ts +77 -0
  73. package/src/index.ts +3 -3
  74. package/src/plugin.ts +67 -59
  75. package/src/types.ts +24 -16
  76. package/src/utils/getParams.ts +2 -2
  77. package/src/utils/getSchemaFactory.ts +1 -1
  78. package/src/utils/index.ts +2 -2
  79. package/src/utils/parseFromConfig.ts +7 -7
  80. package/dist/OperationGenerator-D7rSlflc.d.cts +0 -158
  81. package/dist/OperationGenerator-vw0Zf-Mi.d.ts +0 -158
  82. package/dist/Schema-DxyOIX7q.d.cts +0 -35
  83. package/dist/Schema-gHgN14i2.d.ts +0 -35
  84. package/dist/SchemaMapper-BM1IGWqD.d.cts +0 -248
  85. package/dist/SchemaMapper-BM1IGWqD.d.ts +0 -248
  86. package/dist/chunk-264TCCJF.cjs +0 -3973
  87. package/dist/chunk-264TCCJF.cjs.map +0 -1
  88. package/dist/chunk-7KIEQOVZ.cjs +0 -7
  89. package/dist/chunk-7KIEQOVZ.cjs.map +0 -1
  90. package/dist/chunk-FZN3PBEK.js +0 -3973
  91. package/dist/chunk-FZN3PBEK.js.map +0 -1
  92. package/dist/chunk-P42X362U.cjs +0 -101
  93. package/dist/chunk-P42X362U.cjs.map +0 -1
  94. package/dist/chunk-QLJIL3U5.cjs +0 -35
  95. package/dist/chunk-QLJIL3U5.cjs.map +0 -1
  96. package/dist/chunk-TWKZEVSM.js +0 -7
  97. package/dist/chunk-TWKZEVSM.js.map +0 -1
  98. package/dist/chunk-UB552H4J.js +0 -101
  99. package/dist/chunk-UB552H4J.js.map +0 -1
  100. package/dist/chunk-Y4V7HHX7.js +0 -35
  101. package/dist/chunk-Y4V7HHX7.js.map +0 -1
  102. package/dist/types-C2RXaY0_.d.cts +0 -143
  103. package/dist/types-C2RXaY0_.d.ts +0 -143
  104. package/src/utils/getGroupedByTagFiles.ts +0 -82
  105. 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/parser.tsx"],"names":["method"],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B,gCAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACA;ACrBA,8CAAA,CA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rB,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;AJuVmD;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 { createParser, createReactParser } from './parser.tsx'\nexport type { ParserReactOptions } from './parser.tsx'\nexport type { Parser, ParserOptions } from './parser.tsx'\n","import { type FileMetaBase, Generator } 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 { Exclude, Include, OperationSchemas, OperationsByMethod, Override } from './types.ts'\nimport type { Parser } from './parser.tsx'\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 Generator<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 async build(...parsers: Array<Parser<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) {\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 parsers?.forEach((parser) => {\n const promise = parser.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 parsers?.forEach((parser) => {\n const promise = parser.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'\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'\nimport { parseFromConfig } from './utils/parseFromConfig.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 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 resolvePath(baseName) {\n if (output === false) {\n return undefined\n }\n\n const root = path.resolve(this.config.root, this.config.output.path)\n\n return path.resolve(root, output.path, baseName)\n },\n resolveName(name, type) {\n return camelCase(name, { isFile: type === 'file' })\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 const schemas = getSchemas({ oas, contentType })\n\n const mapSchema = async ([name, schema]: [string, OasTypes.SchemaObject]) => {\n const resolvedPath = this.resolvePath({\n baseName: `${name}.json`,\n pluginKey: this.plugin.key,\n })\n\n const resvoledFileName = this.resolveName({\n name: `${name}.json`,\n pluginKey: [pluginOasName],\n type: 'file',\n }) as `${string}.json`\n\n if (!resolvedPath) {\n return\n }\n\n await this.addFile({\n path: resolvedPath,\n baseName: resvoledFileName,\n source: JSON.stringify(schema),\n meta: {\n pluginKey: this.plugin.key,\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 { Operation, SchemaObject } from '@kubb/oas'\nimport { App, createRoot, type KubbNode } from '@kubb/react'\nimport type * as KubbFile from '@kubb/fs/types'\nimport type { OperationsByMethod } from './types.ts'\nimport { Oas } from '@kubb/plugin-oas/components'\nimport type { OperationGenerator } from './OperationGenerator.ts'\nimport type { SchemaGenerator, SchemaGeneratorOptions } from './SchemaGenerator.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 ParserOptions<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 Parser<TOptions extends PluginFactoryOptions> = ParserOptions<TOptions>\n\nexport function createParser<TOptions extends PluginFactoryOptions>(parseOptions: ParserOptions<TOptions>): Parser<TOptions> {\n return parseOptions\n}\n\nexport type ParserReactOptions<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\nexport function createReactParser<TOptions extends PluginFactoryOptions>(parseOptions: ParserReactOptions<TOptions>): Parser<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":";;;;;;;;;;;;;;;;;AAgCa,IAAA,kBAAA,GAAN,cAGGA,kBAA6G,CAAA;AAAA,EACrH,sBAA0C,EAAC,CAAA;AAAA,EAC3C,IAAI,kBAAyC,GAAA;AAC3C,IAAA,OAAO,IAAK,CAAA,mBAAA,CAAA;AAAA,GACd;AAAA,EAEA,IAAI,mBAAmB,KAA2B,EAAA;AAChD,IAAA,IAAA,CAAK,mBAAsB,GAAA,KAAA,CAAA;AAAA,GAC7B;AAAA,EAEA,WAAA,CAAY,WAAsB,MAAgE,EAAA;AAChG,IAAA,MAAM,EAAE,QAAA,G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M,cAAiB,GAAA,MAAM,kBAAmB,CAAA,KAAA,CAAM,GAAG,UAAU,CAAA,CAAA;AAEnE,MAAM,MAAA,IAAA,CAAK,OAAQ,CAAA,GAAG,cAAc,CAAA,CAAA;AAAA,KACtC;AAAA,GACF,CAAA;AACF,CAAC","file":"index.cjs","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, 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 = any> = any\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 responseStatusCode = (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<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 { G as GetOperationGeneratorOptions, b as GetSchemaGeneratorOptions, a as OperationGenerator, O as OperationMethodResult, h as Parser, i as ParserOptions, P as ParserReactOptions, e as SchemaGenerator, S as SchemaGeneratorBuildOptions, c as SchemaGeneratorOptions, d as SchemaMethodResult, f as createParser, g as createReactParser } from './OperationGenerator-D7rSlflc.cjs';
1
+ import { O as Options, P as PluginOas } from './OperationGenerator-DhPriVDJ.cjs';
2
+ export { A as API, E as Exclude, o as Generator, p as GeneratorOptions, G as GetOperationGeneratorOptions, c 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, g as Schema, f as SchemaGenerator, S as SchemaGeneratorBuildOptions, d as SchemaGeneratorOptions, h as SchemaKeyword, i as SchemaKeywordBase, j as SchemaKeywordMapper, k as SchemaMapper, e as SchemaMethodResult, m as createGenerator, n as createReactGenerator, l as isKeyword, s as schemaKeywords } from './OperationGenerator-DhPriVDJ.cjs';
2
3
  import * as _kubb_core from '@kubb/core';
3
- import { O as Options, P as PluginOas } from './types-C2RXaY0_.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-C2RXaY0_.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-BM1IGWqD.cjs';
6
4
  import '@kubb/fs/types';
7
5
  import '@kubb/oas';
8
- import '@kubb/react';
9
- import '@kubb/oas/parser';
6
+ import '@kubb/react/types';
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 { G as GetOperationGeneratorOptions, b as GetSchemaGeneratorOptions, a as OperationGenerator, O as OperationMethodResult, h as Parser, i as ParserOptions, P as ParserReactOptions, e as SchemaGenerator, S as SchemaGeneratorBuildOptions, c as SchemaGeneratorOptions, d as SchemaMethodResult, f as createParser, g as createReactParser } from './OperationGenerator-vw0Zf-Mi.js';
1
+ import { O as Options, P as PluginOas } from './OperationGenerator-DhPriVDJ.js';
2
+ export { A as API, E as Exclude, o as Generator, p as GeneratorOptions, G as GetOperationGeneratorOptions, c 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, g as Schema, f as SchemaGenerator, S as SchemaGeneratorBuildOptions, d as SchemaGeneratorOptions, h as SchemaKeyword, i as SchemaKeywordBase, j as SchemaKeywordMapper, k as SchemaMapper, e as SchemaMethodResult, m as createGenerator, n as createReactGenerator, l as isKeyword, s as schemaKeywords } from './OperationGenerator-DhPriVDJ.js';
2
3
  import * as _kubb_core from '@kubb/core';
3
- import { O as Options, P as PluginOas } from './types-C2RXaY0_.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-C2RXaY0_.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-BM1IGWqD.js';
6
4
  import '@kubb/fs/types';
7
5
  import '@kubb/oas';
8
- import '@kubb/react';
9
- import '@kubb/oas/parser';
6
+ import '@kubb/react/types';
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,53 +1,87 @@
1
- import {
2
- parseFromConfig
3
- } from "./chunk-Y4V7HHX7.js";
4
- import "./chunk-TWKZEVSM.js";
5
- import {
6
- Oas,
7
- SchemaGenerator,
8
- isKeyword,
9
- require_jsx_runtime,
10
- schemaKeywords
11
- } from "./chunk-FZN3PBEK.js";
12
- import {
13
- __privateAdd,
14
- __privateGet,
15
- __privateMethod,
16
- __privateSet,
17
- __toESM,
18
- getSchemas,
19
- init_esm_shims
20
- } from "./chunk-UB552H4J.js";
1
+ import { parseFromConfig } from './chunk-BG77DP54.js';
2
+ import { jsonGenerator } from './chunk-ABIWUCV7.js';
3
+ export { createGenerator, createReactGenerator } from './chunk-ABIWUCV7.js';
4
+ import './chunk-R47XMJ32.js';
5
+ import { SchemaGenerator } from './chunk-V2JO6RHI.js';
6
+ export { SchemaGenerator, isKeyword, schemaKeywords } from './chunk-V2JO6RHI.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';
21
12
 
22
- // src/index.ts
23
- init_esm_shims();
24
-
25
- // src/OperationGenerator.ts
26
- init_esm_shims();
27
- import { Generator } from "@kubb/core";
28
- import transformers from "@kubb/core/transformers";
29
- var _operationsByMethod, _OperationGenerator_instances, getOptions_fn, isExcluded_fn, isIncluded_fn;
30
- var OperationGenerator = class extends Generator {
31
- constructor() {
32
- super(...arguments);
33
- __privateAdd(this, _OperationGenerator_instances);
34
- __privateAdd(this, _operationsByMethod, {});
35
- }
13
+ var OperationGenerator = class extends BaseGenerator {
14
+ #operationsByMethod = {};
36
15
  get operationsByMethod() {
37
- return __privateGet(this, _operationsByMethod);
16
+ return this.#operationsByMethod;
38
17
  }
39
18
  set operationsByMethod(paths) {
40
- __privateSet(this, _operationsByMethod, paths);
19
+ this.#operationsByMethod = paths;
20
+ }
21
+ #getOptions(operation, method) {
22
+ const { override = [] } = this.context;
23
+ return override.find(({ pattern, type }) => {
24
+ if (type === "tag") {
25
+ return !!operation.getTags()[0]?.name.match(pattern);
26
+ }
27
+ if (type === "operationId") {
28
+ return !!operation.getOperationId().match(pattern);
29
+ }
30
+ if (type === "path") {
31
+ return !!operation.path.match(pattern);
32
+ }
33
+ if (type === "method") {
34
+ return !!method.match(pattern);
35
+ }
36
+ return false;
37
+ })?.options || {};
38
+ }
39
+ #isExcluded(operation, method) {
40
+ const { exclude = [] } = this.context;
41
+ let matched = false;
42
+ exclude.forEach(({ pattern, type }) => {
43
+ if (type === "tag" && !matched) {
44
+ matched = !!operation.getTags()[0]?.name.match(pattern);
45
+ }
46
+ if (type === "operationId" && !matched) {
47
+ matched = !!operation.getOperationId().match(pattern);
48
+ }
49
+ if (type === "path" && !matched) {
50
+ matched = !!operation.path.match(pattern);
51
+ }
52
+ if (type === "method" && !matched) {
53
+ matched = !!method.match(pattern);
54
+ }
55
+ });
56
+ return matched;
57
+ }
58
+ #isIncluded(operation, method) {
59
+ const { include = [] } = this.context;
60
+ let matched = false;
61
+ include.forEach(({ pattern, type }) => {
62
+ if (type === "tag" && !matched) {
63
+ matched = !!operation.getTags()[0]?.name.match(pattern);
64
+ }
65
+ if (type === "operationId" && !matched) {
66
+ matched = !!operation.getOperationId().match(pattern);
67
+ }
68
+ if (type === "path" && !matched) {
69
+ matched = !!operation.path.match(pattern);
70
+ }
71
+ if (type === "method" && !matched) {
72
+ matched = !!method.match(pattern);
73
+ }
74
+ });
75
+ return matched;
41
76
  }
42
77
  getSchemas(operation, {
43
- forStatusCode,
44
78
  resolveName = (name) => name
45
79
  } = {}) {
46
80
  const pathParamsSchema = this.context.oas.getParametersSchema(operation, "path");
47
81
  const queryParamsSchema = this.context.oas.getParametersSchema(operation, "query");
48
82
  const headerParamsSchema = this.context.oas.getParametersSchema(operation, "header");
49
83
  const requestSchema = this.context.oas.getRequestSchema(operation);
50
- const responseStatusCode = forStatusCode || operation.schema.responses && Object.keys(operation.schema.responses).find((key) => key.startsWith("2")) || 200;
84
+ const responseStatusCode = operation.schema.responses && Object.keys(operation.schema.responses).find((key) => key.startsWith("2")) || 200;
51
85
  const responseSchema = this.context.oas.getResponseSchema(operation, responseStatusCode);
52
86
  const statusCodes = operation.getResponseStatusCodes().map((statusCode) => {
53
87
  let name = statusCode;
@@ -116,16 +150,17 @@ var OperationGenerator = class extends Generator {
116
150
  statusCodes
117
151
  };
118
152
  }
119
- async build(...parsers) {
153
+ #methods = ["get", "post", "patch", "put", "delete"];
154
+ async build(...generators) {
120
155
  const { oas } = this.context;
121
156
  const paths = oas.getPaths();
122
157
  this.operationsByMethod = Object.entries(paths).reduce((acc, [path2, method]) => {
123
158
  const methods = Object.keys(method);
124
159
  methods.forEach((method2) => {
125
160
  const operation = oas.operation(path2, method2);
126
- if (operation) {
127
- const isExcluded = __privateMethod(this, _OperationGenerator_instances, isExcluded_fn).call(this, operation, method2);
128
- const isIncluded = this.context.include ? __privateMethod(this, _OperationGenerator_instances, isIncluded_fn).call(this, operation, method2) : true;
161
+ if (operation && [this.#methods].some((methods2) => method2 === operation.method)) {
162
+ const isExcluded = this.#isExcluded(operation, method2);
163
+ const isIncluded = this.context.include ? this.#isIncluded(operation, method2) : true;
129
164
  if (isIncluded && !isExcluded) {
130
165
  if (!acc[path2]) {
131
166
  acc[path2] = {};
@@ -146,7 +181,7 @@ var OperationGenerator = class extends Generator {
146
181
  const methods = this.operationsByMethod[path2] ? Object.keys(this.operationsByMethod[path2]) : [];
147
182
  methods.forEach((method) => {
148
183
  const { operation } = this.operationsByMethod[path2]?.[method];
149
- const options = __privateMethod(this, _OperationGenerator_instances, getOptions_fn).call(this, operation, method);
184
+ const options = this.#getOptions(operation, method);
150
185
  const methodToCall = this[method];
151
186
  if (typeof methodToCall === "function") {
152
187
  const promiseMethod = methodToCall?.call(this, operation, {
@@ -164,8 +199,8 @@ var OperationGenerator = class extends Generator {
164
199
  if (promiseOperation) {
165
200
  acc.push(promiseOperation);
166
201
  }
167
- parsers?.forEach((parser) => {
168
- const promise = parser.operation?.({
202
+ generators?.forEach((generator) => {
203
+ const promise = generator.operation?.({
169
204
  instance: this,
170
205
  operation,
171
206
  options: {
@@ -182,8 +217,8 @@ var OperationGenerator = class extends Generator {
182
217
  }, []);
183
218
  const operations = Object.values(this.operationsByMethod).map((item) => Object.values(item).map((item2) => item2.operation));
184
219
  promises.push(this.all(operations.flat().filter(Boolean), this.operationsByMethod));
185
- parsers?.forEach((parser) => {
186
- const promise = parser.operations?.({
220
+ generators?.forEach((generator) => {
221
+ const promise = generator.operations?.({
187
222
  instance: this,
188
223
  operations: operations.flat().filter(Boolean),
189
224
  operationsByMethod: this.operationsByMethod,
@@ -239,92 +274,21 @@ var OperationGenerator = class extends Generator {
239
274
  return [];
240
275
  }
241
276
  };
242
- _operationsByMethod = new WeakMap();
243
- _OperationGenerator_instances = new WeakSet();
244
- getOptions_fn = function(operation, method) {
245
- const { override = [] } = this.context;
246
- return override.find(({ pattern, type }) => {
247
- if (type === "tag") {
248
- return !!operation.getTags()[0]?.name.match(pattern);
249
- }
250
- if (type === "operationId") {
251
- return !!operation.getOperationId().match(pattern);
252
- }
253
- if (type === "path") {
254
- return !!operation.path.match(pattern);
255
- }
256
- if (type === "method") {
257
- return !!method.match(pattern);
258
- }
259
- return false;
260
- })?.options || {};
261
- };
262
- /**
263
- *
264
- * @deprecated
265
- */
266
- isExcluded_fn = function(operation, method) {
267
- const { exclude = [] } = this.context;
268
- let matched = false;
269
- exclude.forEach(({ pattern, type }) => {
270
- if (type === "tag" && !matched) {
271
- matched = !!operation.getTags()[0]?.name.match(pattern);
272
- }
273
- if (type === "operationId" && !matched) {
274
- matched = !!operation.getOperationId().match(pattern);
275
- }
276
- if (type === "path" && !matched) {
277
- matched = !!operation.path.match(pattern);
278
- }
279
- if (type === "method" && !matched) {
280
- matched = !!method.match(pattern);
281
- }
282
- });
283
- return matched;
284
- };
285
- /**
286
- *
287
- * @deprecated
288
- */
289
- isIncluded_fn = function(operation, method) {
290
- const { include = [] } = this.context;
291
- let matched = false;
292
- include.forEach(({ pattern, type }) => {
293
- if (type === "tag" && !matched) {
294
- matched = !!operation.getTags()[0]?.name.match(pattern);
295
- }
296
- if (type === "operationId" && !matched) {
297
- matched = !!operation.getOperationId().match(pattern);
298
- }
299
- if (type === "path" && !matched) {
300
- matched = !!operation.path.match(pattern);
301
- }
302
- if (type === "method" && !matched) {
303
- matched = !!method.match(pattern);
304
- }
305
- });
306
- return matched;
307
- };
308
-
309
- // src/plugin.ts
310
- init_esm_shims();
311
- import path from "path";
312
- import { createPlugin } from "@kubb/core";
313
- import { camelCase } from "@kubb/core/transformers";
314
277
  var pluginOasName = "plugin-oas";
315
278
  var pluginOas = createPlugin((options) => {
316
279
  const {
317
- output = { path: "schemas", export: false },
318
- experimentalFilter: filter,
319
- experimentalSort: sort,
280
+ output = {
281
+ path: "schemas"
282
+ },
320
283
  validate = true,
284
+ generators = [jsonGenerator],
321
285
  serverIndex = 0,
322
286
  contentType,
323
287
  oasClass
324
288
  } = options;
325
- const getOas = async ({ config, logger, formatOptions }) => {
289
+ const getOas = async ({ config, logger }) => {
326
290
  try {
327
- const oas = await parseFromConfig(config, formatOptions, oasClass);
291
+ const oas = await parseFromConfig(config, oasClass);
328
292
  if (validate) {
329
293
  await oas.valdiate();
330
294
  }
@@ -332,17 +296,20 @@ var pluginOas = createPlugin((options) => {
332
296
  } catch (e) {
333
297
  const error = e;
334
298
  logger.emit("warning", error?.message);
335
- return parseFromConfig(config, {}, oasClass);
299
+ return parseFromConfig(config, oasClass);
336
300
  }
337
301
  };
338
302
  return {
339
303
  name: pluginOasName,
340
- options,
304
+ options: {
305
+ output,
306
+ ...options
307
+ },
341
308
  context() {
342
309
  const { config, logger } = this;
343
310
  return {
344
- getOas(formatOptions) {
345
- return getOas({ config, logger, formatOptions });
311
+ getOas() {
312
+ return getOas({ config, logger });
346
313
  },
347
314
  async getSchemas({ includes } = {}) {
348
315
  const oas = await this.getOas();
@@ -350,124 +317,64 @@ var pluginOas = createPlugin((options) => {
350
317
  },
351
318
  async getBaseURL() {
352
319
  const oasInstance = await this.getOas();
353
- const baseURL = oasInstance.api.servers?.at(serverIndex)?.url;
354
- return baseURL;
320
+ return oasInstance.api.servers?.at(serverIndex)?.url;
355
321
  },
356
322
  contentType
357
323
  };
358
324
  },
359
- resolvePath(baseName) {
360
- if (output === false) {
361
- return void 0;
362
- }
325
+ resolvePath(baseName, pathMode, options2) {
363
326
  const root = path.resolve(this.config.root, this.config.output.path);
327
+ const mode = pathMode ?? FileManager.getMode(path.resolve(root, output.path));
328
+ if (mode === "single") {
329
+ return path.resolve(root, output.path);
330
+ }
364
331
  return path.resolve(root, output.path, baseName);
365
332
  },
366
- resolveName(name, type) {
367
- return camelCase(name, { isFile: type === "file" });
368
- },
369
333
  async buildStart() {
370
334
  if (!output) {
371
335
  return;
372
336
  }
373
337
  const oas = await getOas({
374
338
  config: this.config,
375
- logger: this.logger,
376
- formatOptions: {
377
- filterSet: filter,
378
- sortSet: sort
379
- }
339
+ logger: this.logger
380
340
  });
381
341
  await oas.dereference();
382
- const schemas = getSchemas({ oas, contentType });
383
- const mapSchema = async ([name, schema]) => {
384
- const resolvedPath = this.resolvePath({
385
- baseName: `${name}.json`,
386
- pluginKey: this.plugin.key
387
- });
388
- const resvoledFileName = this.resolveName({
389
- name: `${name}.json`,
390
- pluginKey: [pluginOasName],
391
- type: "file"
392
- });
393
- if (!resolvedPath) {
394
- return;
342
+ const schemaGenerator = new SchemaGenerator(
343
+ {
344
+ unknownType: "unknown",
345
+ dateType: "date",
346
+ transformers: {},
347
+ ...this.plugin.options
348
+ },
349
+ {
350
+ oas,
351
+ pluginManager: this.pluginManager,
352
+ plugin: this.plugin,
353
+ contentType,
354
+ include: void 0,
355
+ override: void 0,
356
+ mode: "split",
357
+ output: output.path
395
358
  }
396
- await this.addFile({
397
- path: resolvedPath,
398
- baseName: resvoledFileName,
399
- source: JSON.stringify(schema),
400
- meta: {
401
- pluginKey: this.plugin.key
402
- }
403
- });
404
- };
405
- const promises = Object.entries(schemas).map(mapSchema);
406
- await Promise.all(promises);
407
- }
408
- };
409
- });
410
-
411
- // src/parser.tsx
412
- init_esm_shims();
413
- import { App, createRoot } from "@kubb/react";
414
- var import_jsx_runtime = __toESM(require_jsx_runtime(), 1);
415
- function createParser(parseOptions) {
416
- return parseOptions;
417
- }
418
- function createReactParser(parseOptions) {
419
- return {
420
- ...parseOptions,
421
- async operations({ instance, options, operations, operationsByMethod }) {
422
- if (!parseOptions.Operations) {
423
- return [];
424
- }
425
- const { pluginManager, oas, plugin, mode } = instance.context;
426
- const root = createRoot({
427
- logger: pluginManager.logger
428
- });
429
- root.render(
430
- /* @__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 }) }) })
431
- );
432
- return root.files;
433
- },
434
- async operation({ instance, operation, options }) {
435
- if (!parseOptions.Operation) {
436
- return [];
437
- }
438
- const { pluginManager, oas, plugin, mode } = instance.context;
439
- const root = createRoot({
440
- logger: pluginManager.logger
441
- });
442
- root.render(
443
- /* @__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 }) }) }) })
444
359
  );
445
- return root.files;
446
- },
447
- async schema({ instance, schema, name, options }) {
448
- if (!parseOptions.Schema) {
449
- return [];
450
- }
451
- const { pluginManager, oas, plugin, mode } = instance.context;
452
- const root = createRoot({
453
- logger: pluginManager.logger
360
+ const schemaFiles = await schemaGenerator.build(...generators);
361
+ await this.addFile(...schemaFiles);
362
+ const operationGenerator = new OperationGenerator(this.plugin.options, {
363
+ oas,
364
+ pluginManager: this.pluginManager,
365
+ plugin: this.plugin,
366
+ contentType,
367
+ exclude: void 0,
368
+ include: void 0,
369
+ override: void 0,
370
+ mode: "split"
454
371
  });
455
- const tree = instance.parse({ schema, name });
456
- root.render(
457
- /* @__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 }) }) }) })
458
- );
459
- return root.files;
372
+ const operationFiles = await operationGenerator.build(...generators);
373
+ await this.addFile(...operationFiles);
460
374
  }
461
375
  };
462
- }
463
- export {
464
- OperationGenerator,
465
- SchemaGenerator,
466
- createParser,
467
- createReactParser,
468
- isKeyword,
469
- pluginOas,
470
- pluginOasName,
471
- schemaKeywords
472
- };
376
+ });
377
+
378
+ export { OperationGenerator, pluginOas, pluginOasName };
379
+ //# sourceMappingURL=index.js.map
473
380
  //# sourceMappingURL=index.js.map