@kubb/plugin-oas 3.0.0-alpha.0 → 3.0.0-alpha.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 (73) hide show
  1. package/dist/OperationGenerator-By5WOmWB.d.ts +165 -0
  2. package/dist/OperationGenerator-Gd1X7wUz.d.cts +165 -0
  3. package/dist/{Schema-DefwBJMc.d.ts → Schema-B1vcPGiK.d.ts} +3 -5
  4. package/dist/{Schema-an5hOrjZ.d.cts → Schema-DoSFh7Qd.d.cts} +3 -5
  5. package/dist/{SchemaMapper-CsBQ6eEx.d.cts → SchemaMapper-sGcY1xL5.d.cts} +1 -2
  6. package/dist/{SchemaMapper-CsBQ6eEx.d.ts → SchemaMapper-sGcY1xL5.d.ts} +1 -2
  7. package/dist/chunk-75BIOXB7.cjs +7 -0
  8. package/dist/chunk-75BIOXB7.cjs.map +1 -0
  9. package/dist/{chunk-UKUEVTRB.cjs → chunk-IAUV3UKH.cjs} +735 -35
  10. package/dist/chunk-IAUV3UKH.cjs.map +1 -0
  11. package/dist/{chunk-QSM6A5QX.js → chunk-M347763D.js} +714 -14
  12. package/dist/chunk-M347763D.js.map +1 -0
  13. package/dist/{chunk-GUPCIAYT.js → chunk-N7EEVJA6.js} +3 -3
  14. package/dist/{chunk-J7IF3KA3.cjs → chunk-NU4F7G47.cjs} +4 -16
  15. package/dist/chunk-NU4F7G47.cjs.map +1 -0
  16. package/dist/{chunk-3UN2S6P2.cjs → chunk-O76YQFZB.cjs} +3 -3
  17. package/dist/{chunk-3UN2S6P2.cjs.map → chunk-O76YQFZB.cjs.map} +1 -1
  18. package/dist/chunk-SQ64ESS4.js +7 -0
  19. package/dist/chunk-SQ64ESS4.js.map +1 -0
  20. package/dist/{chunk-Y272OQMW.js → chunk-SZDO532A.js} +3 -15
  21. package/dist/chunk-SZDO532A.js.map +1 -0
  22. package/dist/components.cjs +4 -9
  23. package/dist/components.cjs.map +1 -1
  24. package/dist/components.d.cts +13 -7
  25. package/dist/components.d.ts +13 -7
  26. package/dist/components.js +3 -8
  27. package/dist/components.js.map +1 -1
  28. package/dist/hooks.cjs +12 -13
  29. package/dist/hooks.cjs.map +1 -1
  30. package/dist/hooks.d.cts +4 -4
  31. package/dist/hooks.d.ts +4 -4
  32. package/dist/hooks.js +2 -3
  33. package/dist/hooks.js.map +1 -1
  34. package/dist/index.cjs +282 -231
  35. package/dist/index.cjs.map +1 -1
  36. package/dist/index.d.cts +8 -77
  37. package/dist/index.d.ts +8 -77
  38. package/dist/index.js +274 -223
  39. package/dist/index.js.map +1 -1
  40. package/dist/{types-BP45TdiW.d.cts → types-CZTUCaE5.d.cts} +3 -6
  41. package/dist/{types-BP45TdiW.d.ts → types-CZTUCaE5.d.ts} +3 -6
  42. package/dist/utils.cjs +12 -54
  43. package/dist/utils.cjs.map +1 -1
  44. package/dist/utils.d.cts +7 -33
  45. package/dist/utils.d.ts +7 -33
  46. package/dist/utils.js +6 -48
  47. package/dist/utils.js.map +1 -1
  48. package/package.json +12 -11
  49. package/src/OperationGenerator.ts +68 -32
  50. package/src/SchemaGenerator.ts +32 -15
  51. package/src/SchemaMapper.ts +1 -1
  52. package/src/components/Oas.tsx +9 -3
  53. package/src/components/Operation.tsx +1 -1
  54. package/src/components/Schema.tsx +29 -31
  55. package/src/generator.tsx +125 -0
  56. package/src/hooks/useOperationManager.ts +1 -0
  57. package/src/index.ts +3 -9
  58. package/src/plugin.ts +25 -38
  59. package/src/types.ts +2 -6
  60. package/src/utils/getParams.ts +1 -1
  61. package/src/utils/index.ts +2 -1
  62. package/dist/OperationGenerator-B0RLFu4P.d.ts +0 -60
  63. package/dist/OperationGenerator-CrCcKl3S.d.cts +0 -60
  64. package/dist/chunk-J7IF3KA3.cjs.map +0 -1
  65. package/dist/chunk-K4GEQ3C2.cjs +0 -698
  66. package/dist/chunk-K4GEQ3C2.cjs.map +0 -1
  67. package/dist/chunk-QSM6A5QX.js.map +0 -1
  68. package/dist/chunk-UKUEVTRB.cjs.map +0 -1
  69. package/dist/chunk-Y272OQMW.js.map +0 -1
  70. package/dist/chunk-ZZ7ZC4TT.js +0 -698
  71. package/dist/chunk-ZZ7ZC4TT.js.map +0 -1
  72. package/src/utils/getGroupedByTagFiles.ts +0 -82
  73. /package/dist/{chunk-GUPCIAYT.js.map → chunk-N7EEVJA6.js.map} +0 -0
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/plugin.ts","../src/OperationGenerator.ts"],"sourcesContent":["import { pluginOas } from './plugin.ts'\n\nexport 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'\n\n/**\n * @deprecated Use `import { pluginOas } from '@kubb/plugin-oas'` instead\n */\nconst definePluginDefault = pluginOas\n\nexport default definePluginDefault\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\n api() {\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 writeFile(path, source) {\n if (!path.endsWith('.json') || !source) {\n return\n }\n\n return this.fileManager.write(path, source, { sanity: false })\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 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'\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 abstract 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 * @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 * @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 { forStatusCode, resolveName = (name) => name }: { forStatusCode?: string | number; resolveName?: (name: string) => string } = {},\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 get #methods() {\n return {\n get: this.get,\n post: this.post,\n patch: this.patch,\n put: this.put,\n delete: this.delete,\n head: undefined,\n options: undefined,\n trace: undefined,\n } as const\n }\n\n async build(): 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[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 const promiseMethod = this.#methods[method]?.call(this, operation, {\n ...this.options,\n ...options,\n })\n const promiseOperation = this.operation.call(this, operation, {\n ...this.options,\n ...options,\n })\n\n if (promiseMethod) {\n acc.push(promiseMethod)\n }\n if (promiseOperation) {\n acc.push(promiseOperation)\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 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 null\n }\n\n /**\n * GET\n */\n async get(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta> {\n return null\n }\n\n /**\n * POST\n */\n async post(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta> {\n return null\n }\n /**\n * PATCH\n */\n async patch(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta> {\n return null\n }\n\n /**\n * PUT\n */\n async put(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta> {\n return null\n }\n\n /**\n * DELETE\n */\n async delete(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta> {\n return null\n }\n\n /**\n * Combination of GET, POST, PATCH, PUT, DELETE\n */\n async all(operations: Operation[], paths: OperationsByMethod): OperationMethodResult<TFileMeta> {\n return null\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;;;ACAA;AAAA,OAAO,UAAU;AAEjB,SAAS,oBAAoB;AAC7B,SAAS,iBAAiB;AAWnB,IAAM,gBAAgB;AAEtB,IAAM,YAAY,aAAwB,CAAC,YAAY;AAC5D,QAAM;AAAA,IACJ,SAAS,EAAE,MAAM,WAAW,QAAQ,MAAM;AAAA,IAC1C,oBAAoB;AAAA,IACpB,kBAAkB;AAAA,IAClB,WAAW;AAAA,IACX,cAAc;AAAA,IACd;AAAA,IACA;AAAA,EACF,IAAI;AAEJ,QAAM,SAAS,OAAO,EAAE,QAAQ,QAAQ,cAAc,MAAuF;AAC3I,QAAI;AAEF,YAAM,MAAM,MAAM,gBAAgB,QAAQ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,IACX,OAAO,KAAK;AAAA,IACZ,KAAK,KAAK;AAAA,IACV,QAAQ,KAAK;AAAA,IACb,MAAM;AAAA,IACN,SAAS;AAAA,IACT,OAAO;AAAA,EACT;AACF;;;AF1MF,IAAM,sBAAsB;AAE5B,IAAO,cAAQ;","names":["path","path","method","item"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/OperationGenerator.ts","../src/plugin.ts","../src/generator.tsx"],"sourcesContent":["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"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;;;ACAA;AAAA,SAAS,qBAAwC;AACjD,OAAO,kBAAkB;AA+BlB,IAAM,qBAAN,cAIG,cAA2D;AAAA,EACnE,sBAA0C,CAAC;AAAA,EAC3C,IAAI,qBAAyC;AAC3C,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,IAAI,mBAAmB,OAA2B;AAChD,SAAK,sBAAsB;AAAA,EAC7B;AAAA,EAEA,YAAY,WAAsB,QAAuC;AACvE,UAAM,EAAE,WAAW,CAAC,EAAE,IAAI,KAAK;AAE/B,WACE,SAAS,KAAK,CAAC,EAAE,SAAS,KAAK,MAAM;AACnC,UAAI,SAAS,OAAO;AAClB,eAAO,CAAC,CAAC,UAAU,QAAQ,EAAE,CAAC,GAAG,KAAK,MAAM,OAAO;AAAA,MACrD;AAEA,UAAI,SAAS,eAAe;AA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AEA,aAAO,KAAK;AAAA,IACd;AAAA,IACA,MAAM,OAAO,EAAE,UAAU,QAAQ,MAAM,QAAQ,GAAG;AAChD,UAAI,CAAC,aAAa,QAAQ;AACxB,eAAO,CAAC;AAAA,MACV;AAEA,YAAM,EAAE,eAAe,KAAK,QAAQ,KAAK,IAAI,SAAS;AACtD,YAAM,OAAO,WAAW;AAAA,QACtB,QAAQ,cAAc;AAAA,MACxB,CAAC;AAED,YAAM,OAAO,SAAS,MAAM,EAAE,QAAQ,KAAK,CAAC;AAE5C,WAAK;AAAA,QACH,4CAAC,OAAI,eAA8B,QAAQ,EAAE,GAAG,QAAQ,QAAQ,GAAG,MACjE,sDAAC,OAAI,KACH,sDAAC,IAAI,QAAJ,EAAW,MAAY,OAAO,QAAQ,MACrC,sDAAC,aAAa,QAAb,EAAoB,QAAgB,SAAkB,UAAoB,MAAY,GACzF,GACF,GACF;AAAA,MACF;AAEA,aAAO,KAAK;AAAA,IACd;AAAA,EACF;AACF;","names":["path","method","methods","item"]}
@@ -35,6 +35,8 @@ type Options = {
35
35
  * @default 'schemas'
36
36
  */
37
37
  path: string;
38
+ extName?: KubbFile.Extname;
39
+ exportType?: 'barrel' | 'barrelNamed' | false;
38
40
  } | false;
39
41
  /**
40
42
  * Which server to use from the array of `servers.url[serverIndex]`
@@ -139,10 +141,5 @@ type Override<TOptions> = (ByTag | ByOperationId | ByPath | ByMethod | BySchemaN
139
141
  options: Partial<TOptions>;
140
142
  };
141
143
  type PluginOas = PluginFactoryOptions<'plugin-oas', Options, Options, API, never>;
142
- declare module '@kubb/core' {
143
- interface _Register {
144
- ['@kubb/plugin-oas']: PluginOas;
145
- }
146
- }
147
144
 
148
- export { type API as A, type Exclude as E, type GetSchemasProps as G, type Include as I, type Options as O, type PluginOas as P, type Refs as R, type OperationSchema as a, type Override as b, type ResolvePathOptions as c, type Ref as d, type Resolver as e, type OperationSchemas as f, type OperationsByMethod as g, getSchemas as h };
145
+ export { type API as A, type Exclude as E, type GetSchemasProps as G, type Include as I, type Options as O, type PluginOas as P, type ResolvePathOptions as R, type Ref as a, type Refs as b, type Resolver as c, type OperationSchema as d, type OperationSchemas as e, type OperationsByMethod as f, type Override as g, getSchemas as h };
@@ -35,6 +35,8 @@ type Options = {
35
35
  * @default 'schemas'
36
36
  */
37
37
  path: string;
38
+ extName?: KubbFile.Extname;
39
+ exportType?: 'barrel' | 'barrelNamed' | false;
38
40
  } | false;
39
41
  /**
40
42
  * Which server to use from the array of `servers.url[serverIndex]`
@@ -139,10 +141,5 @@ type Override<TOptions> = (ByTag | ByOperationId | ByPath | ByMethod | BySchemaN
139
141
  options: Partial<TOptions>;
140
142
  };
141
143
  type PluginOas = PluginFactoryOptions<'plugin-oas', Options, Options, API, never>;
142
- declare module '@kubb/core' {
143
- interface _Register {
144
- ['@kubb/plugin-oas']: PluginOas;
145
- }
146
- }
147
144
 
148
- export { type API as A, type Exclude as E, type GetSchemasProps as G, type Include as I, type Options as O, type PluginOas as P, type Refs as R, type OperationSchema as a, type Override as b, type ResolvePathOptions as c, type Ref as d, type Resolver as e, type OperationSchemas as f, type OperationsByMethod as g, getSchemas as h };
145
+ export { type API as A, type Exclude as E, type GetSchemasProps as G, type Include as I, type Options as O, type PluginOas as P, type ResolvePathOptions as R, type Ref as a, type Refs as b, type Resolver as c, type OperationSchema as d, type OperationSchemas as e, type OperationsByMethod as f, type Override as g, getSchemas as h };
package/dist/utils.cjs CHANGED
@@ -1,17 +1,17 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
2
 
3
- var _chunk3UN2S6P2cjs = require('./chunk-3UN2S6P2.cjs');
3
+ var _chunkO76YQFZBcjs = require('./chunk-O76YQFZB.cjs');
4
4
 
5
5
 
6
6
 
7
7
 
8
- var _chunkJ7IF3KA3cjs = require('./chunk-J7IF3KA3.cjs');
8
+ var _chunkNU4F7G47cjs = require('./chunk-NU4F7G47.cjs');
9
9
 
10
10
  // src/utils/index.ts
11
- _chunkJ7IF3KA3cjs.init_cjs_shims.call(void 0, );
11
+ _chunkNU4F7G47cjs.init_cjs_shims.call(void 0, );
12
12
 
13
13
  // src/utils/getComments.ts
14
- _chunkJ7IF3KA3cjs.init_cjs_shims.call(void 0, );
14
+ _chunkNU4F7G47cjs.init_cjs_shims.call(void 0, );
15
15
  var _transformers = require('@kubb/core/transformers'); var _transformers2 = _interopRequireDefault(_transformers);
16
16
  var _utils = require('@kubb/core/utils');
17
17
  function getComments(operation) {
@@ -23,53 +23,8 @@ function getComments(operation) {
23
23
  ].filter(Boolean).map((text) => _transformers2.default.trim(text));
24
24
  }
25
25
 
26
- // src/utils/getGroupedByTagFiles.ts
27
- _chunkJ7IF3KA3cjs.init_cjs_shims.call(void 0, );
28
- var _path = require('path');
29
- var _core = require('@kubb/core');
30
-
31
-
32
- var _fs = require('@kubb/fs');
33
- async function getGroupedByTagFiles({ logger, files, plugin, template, exportAs, root, output }) {
34
- const { path, exportType = "barrel" } = output;
35
- const mode = _core.FileManager.getMode(_path.resolve.call(void 0, root, path));
36
- if (mode === "single" || exportType === false) {
37
- return [];
38
- }
39
- return files.filter((file) => {
40
- const name = _optionalChain([file, 'access', _ => _.meta, 'optionalAccess', _2 => _2.pluginKey, 'optionalAccess', _3 => _3[0]]);
41
- return name === plugin.name;
42
- }).map((file) => {
43
- if (!_optionalChain([file, 'access', _4 => _4.meta, 'optionalAccess', _5 => _5.tag])) {
44
- _optionalChain([logger, 'optionalAccess', _6 => _6.emit, 'call', _7 => _7("debug", [`Could not find a tagName for ${JSON.stringify(file, void 0, 2)}`])]);
45
- return;
46
- }
47
- const tag = _optionalChain([file, 'access', _8 => _8.meta, 'optionalAccess', _9 => _9.tag]) && _transformers2.default.camelCase(file.meta.tag);
48
- const tagPath = _fs.getRelativePath.call(void 0, _path.resolve.call(void 0, root, output.path), _path.resolve.call(void 0, root, _utils.renderTemplate.call(void 0, template, { tag })));
49
- const tagName = _utils.renderTemplate.call(void 0, exportAs, { tag });
50
- if (tagName) {
51
- return {
52
- baseName: "index.ts",
53
- path: _path.resolve.call(void 0, root, output.path, "index.ts"),
54
- source: "",
55
- exports: [
56
- {
57
- path: output.extName ? `${tagPath}/index${output.extName}` : `${tagPath}/index`,
58
- asAlias: true,
59
- name: tagName
60
- }
61
- ],
62
- meta: {
63
- pluginKey: plugin.key
64
- },
65
- exportable: true
66
- };
67
- }
68
- }).filter(Boolean);
69
- }
70
-
71
26
  // src/utils/getParams.ts
72
- _chunkJ7IF3KA3cjs.init_cjs_shims.call(void 0, );
27
+ _chunkNU4F7G47cjs.init_cjs_shims.call(void 0, );
73
28
  var _oas = require('@kubb/oas');
74
29
 
75
30
  function getASTParams(operationSchema, {
@@ -104,17 +59,20 @@ function getPathParams(operationSchema, options = {}) {
104
59
  }
105
60
 
106
61
  // src/utils/refSorter.ts
107
- _chunkJ7IF3KA3cjs.init_cjs_shims.call(void 0, );
62
+ _chunkNU4F7G47cjs.init_cjs_shims.call(void 0, );
108
63
  function refsSorter(a, b) {
109
- if (_optionalChain([Object, 'access', _10 => _10.keys, 'call', _11 => _11(a.import.refs), 'optionalAccess', _12 => _12.length]) < _optionalChain([Object, 'access', _13 => _13.keys, 'call', _14 => _14(b.import.refs), 'optionalAccess', _15 => _15.length])) {
64
+ if (_optionalChain([Object, 'access', _ => _.keys, 'call', _2 => _2(a.import.refs), 'optionalAccess', _3 => _3.length]) < _optionalChain([Object, 'access', _4 => _4.keys, 'call', _5 => _5(b.import.refs), 'optionalAccess', _6 => _6.length])) {
110
65
  return -1;
111
66
  }
112
- if (_optionalChain([Object, 'access', _16 => _16.keys, 'call', _17 => _17(a.import.refs), 'optionalAccess', _18 => _18.length]) > _optionalChain([Object, 'access', _19 => _19.keys, 'call', _20 => _20(b.import.refs), 'optionalAccess', _21 => _21.length])) {
67
+ if (_optionalChain([Object, 'access', _7 => _7.keys, 'call', _8 => _8(a.import.refs), 'optionalAccess', _9 => _9.length]) > _optionalChain([Object, 'access', _10 => _10.keys, 'call', _11 => _11(b.import.refs), 'optionalAccess', _12 => _12.length])) {
113
68
  return 1;
114
69
  }
115
70
  return 0;
116
71
  }
117
72
 
73
+ // src/utils/index.ts
74
+
75
+
118
76
 
119
77
 
120
78
 
@@ -123,5 +81,5 @@ function refsSorter(a, b) {
123
81
 
124
82
 
125
83
 
126
- exports.getASTParams = getASTParams; exports.getComments = getComments; exports.getGroupedByTagFiles = getGroupedByTagFiles; exports.getPathParams = getPathParams; exports.getSchemaFactory = _chunkJ7IF3KA3cjs.getSchemaFactory; exports.getSchemas = _chunkJ7IF3KA3cjs.getSchemas; exports.parseFromConfig = _chunk3UN2S6P2cjs.parseFromConfig; exports.refsSorter = refsSorter;
84
+ exports.getASTParams = getASTParams; exports.getComments = getComments; exports.getPathParams = getPathParams; exports.getSchemaFactory = _chunkNU4F7G47cjs.getSchemaFactory; exports.getSchemas = _chunkNU4F7G47cjs.getSchemas; exports.isOptional = _oas.isOptional; exports.parseFromConfig = _chunkO76YQFZBcjs.parseFromConfig; exports.refsSorter = refsSorter;
127
85
  //# sourceMappingURL=utils.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/kubb/kubb/packages/plugin-oas/dist/utils.cjs","../src/utils/index.ts","../src/utils/getComments.ts","../src/utils/getGroupedByTagFiles.ts","../src/utils/getParams.ts","../src/utils/refSorter.ts"],"names":[],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACF,wDAA6B;AAC7B;AACA;ACTA,8CAAA,CAAA;ADWA;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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/home/runner/work/kubb/kubb/packages/plugin-oas/dist/utils.cjs","sourcesContent":[null,"export { getComments } from './getComments.ts'\nexport { getGroupedByTagFiles } from './getGroupedByTagFiles.ts'\nexport { getASTParams, getPathParams } from './getParams.ts'\nexport { getSchemaFactory } from './getSchemaFactory.ts'\nexport type { GetSchemasProps } from './getSchemas.ts'\nexport { getSchemas } from './getSchemas.ts'\nexport { refsSorter } from './refSorter.ts'\nexport { parseFromConfig } from './parseFromConfig.ts'\n","import transformers from '@kubb/core/transformers'\nimport { URLPath } from '@kubb/core/utils'\n\nimport type { Operation } from '@kubb/oas'\n\nexport function getComments(operation: Operation): string[] {\n return [\n operation.getDescription() && `@description ${operation.getDescription()}`,\n operation.getSummary() && `@summary ${operation.getSummary()}`,\n operation.path && `@link ${new URLPath(operation.path).URL}`,\n operation.isDeprecated() && '@deprecated',\n ]\n .filter(Boolean)\n .map((text) => transformers.trim(text))\n}\n","import { resolve } from 'node:path'\n\nimport { FileManager } from '@kubb/core'\nimport transformers from '@kubb/core/transformers'\nimport { renderTemplate } from '@kubb/core/utils'\nimport { getRelativePath } from '@kubb/fs'\n\nimport type { Plugin } from '@kubb/core'\nimport type { Logger } from '@kubb/core/logger'\nimport type * as KubbFile from '@kubb/fs/types'\n\ntype Options = {\n logger: Logger\n files: Array<KubbFile.File<FileMeta>>\n plugin: Plugin\n template: string\n exportAs: string\n /**\n * Root based on root and output.path specified in the config\n */\n root: string\n /**\n * Output for plugin\n */\n output: {\n path: string\n exportAs?: string\n extName?: KubbFile.Extname\n exportType?: 'barrel' | 'barrelNamed' | false\n }\n}\n\ntype FileMeta = {\n pluginKey?: Plugin['key']\n tag?: string\n}\n\nexport async function getGroupedByTagFiles({ logger, files, plugin, template, exportAs, root, output }: Options): Promise<KubbFile.File<FileMeta>[]> {\n const { path, exportType = 'barrel' } = output\n const mode = FileManager.getMode(resolve(root, path))\n\n if (mode === 'single' || exportType === false) {\n return []\n }\n\n return files\n .filter((file) => {\n const name = file.meta?.pluginKey?.[0]\n return name === plugin.name\n })\n .map((file: KubbFile.File<FileMeta>) => {\n if (!file.meta?.tag) {\n logger?.emit('debug', [`Could not find a tagName for ${JSON.stringify(file, undefined, 2)}`])\n\n return\n }\n\n const tag = file.meta?.tag && transformers.camelCase(file.meta.tag)\n const tagPath = getRelativePath(resolve(root, output.path), resolve(root, renderTemplate(template, { tag })))\n const tagName = renderTemplate(exportAs, { tag })\n\n if (tagName) {\n return {\n baseName: 'index.ts' as const,\n path: resolve(root, output.path, 'index.ts'),\n source: '',\n exports: [\n {\n path: output.extName ? `${tagPath}/index${output.extName}` : `${tagPath}/index`,\n asAlias: true,\n name: tagName,\n },\n ],\n meta: {\n pluginKey: plugin.key,\n },\n exportable: true,\n }\n }\n })\n .filter(Boolean)\n}\n","import { isParameterObject } from '@kubb/oas'\n\nimport type { FunctionParamsAST } from '@kubb/core/utils'\nimport type { OasTypes } from '@kubb/oas'\nimport type { Params } from '@kubb/react'\nimport type { OperationSchema } from '../types.ts'\nimport { camelCase } from '@kubb/core/transformers'\n/**\n *\n * @deprecated\n * TODO move to operationManager hook\n */\nexport function getASTParams(\n operationSchema: OperationSchema | undefined,\n {\n typed = false,\n override,\n }: {\n typed?: boolean\n override?: (data: FunctionParamsAST) => FunctionParamsAST\n } = {},\n): FunctionParamsAST[] {\n if (!operationSchema || !operationSchema.schema.properties || !operationSchema.name) {\n return []\n }\n\n return Object.entries(operationSchema.schema.properties).map(([name, schema]: [string, OasTypes.SchemaObject]) => {\n const isParam = isParameterObject(schema)\n const data: FunctionParamsAST = {\n name,\n enabled: !!name,\n required: isParam ? schema.required : true,\n type: typed ? `${operationSchema.name}[\"${name}\"]` : undefined,\n }\n\n return override ? override(data) : data\n })\n}\n\nexport function getPathParams(\n operationSchema: OperationSchema | undefined,\n options: {\n typed?: boolean\n override?: (data: FunctionParamsAST) => FunctionParamsAST\n } = {},\n) {\n return getASTParams(operationSchema, options).reduce((acc, curr) => {\n if (curr.name && curr.enabled) {\n acc[camelCase(curr.name)] = {\n default: curr.default,\n type: curr.type,\n optional: !curr.required,\n }\n }\n\n return acc\n }, {} as Params)\n}\n","import type { Refs } from '../types.ts'\n\ntype Generated = { import: { refs: Refs; name: string } }\n\nexport function refsSorter<T extends Generated>(a: T, b: T): number {\n if (Object.keys(a.import.refs)?.length < Object.keys(b.import.refs)?.length) {\n return -1\n }\n if (Object.keys(a.import.refs)?.length > Object.keys(b.import.refs)?.length) {\n return 1\n }\n return 0\n}\n"]}
1
+ {"version":3,"sources":["/home/runner/work/kubb/kubb/packages/plugin-oas/dist/utils.cjs","../src/utils/index.ts","../src/utils/getComments.ts","../src/utils/getParams.ts","../src/utils/refSorter.ts"],"names":[],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACF,wDAA6B;AAC7B;AACA;ACTA,8CAAA,CAAA;ADWA;AACA;AEZA,8CAAA,CAAA;AAAA,mHAAyB;AACzB,yCAAwB;AAIjB,SAAS,WAAA,CAAY,SAAA,EAAgC;AAC1D,EAAA,OAAO;AAAA,IACL,SAAA,CAAU,cAAA,CAAe,EAAA,GAAK,CAAA,aAAA,EAAgB,SAAA,CAAU,cAAA,CAAe,CAAC,CAAA,CAAA;AACZ,IAAA;AACF,IAAA;AAC9B,IAAA;AAGU,EAAA;AAC1C;AFU6E;AACA;AGzB7E;AAAkC;AAMR;AAQxB;AACU,EAAA;AACR,EAAA;AAKmB;AAC0C,EAAA;AACrD,IAAA;AACV,EAAA;AAE2E,EAAA;AACjC,IAAA;AACR,IAAA;AAC9B,MAAA;AACW,MAAA;AAC2B,MAAA;AACe,MAAA;AACvD,IAAA;AAEmC,IAAA;AACpC,EAAA;AACH;AAQE;AACoE,EAAA;AACnC,IAAA;AACD,MAAA;AACZ,QAAA;AACH,QAAA;AACK,QAAA;AAClB,MAAA;AACF,IAAA;AAEO,IAAA;AACM,EAAA;AACjB;AHE6E;AACA;AI5D7E;AAIoE;AACG,EAAA;AAC5D,IAAA;AACT,EAAA;AACqE,EAAA;AAC5D,IAAA;AACT,EAAA;AACO,EAAA;AACT;AJ2D6E;AACA;AChElD;ADkEkD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/home/runner/work/kubb/kubb/packages/plugin-oas/dist/utils.cjs","sourcesContent":[null,"export { getComments } from './getComments.ts'\nexport { getASTParams, getPathParams } from './getParams.ts'\nexport { getSchemaFactory } from './getSchemaFactory.ts'\nexport type { GetSchemasProps } from './getSchemas.ts'\nexport { getSchemas } from './getSchemas.ts'\nexport { refsSorter } from './refSorter.ts'\nexport { parseFromConfig } from './parseFromConfig.ts'\n\nexport { isOptional } from '@kubb/oas'\n","import transformers from '@kubb/core/transformers'\nimport { URLPath } from '@kubb/core/utils'\n\nimport type { Operation } from '@kubb/oas'\n\nexport function getComments(operation: Operation): string[] {\n return [\n operation.getDescription() && `@description ${operation.getDescription()}`,\n operation.getSummary() && `@summary ${operation.getSummary()}`,\n operation.path && `@link ${new URLPath(operation.path).URL}`,\n operation.isDeprecated() && '@deprecated',\n ]\n .filter(Boolean)\n .map((text) => transformers.trim(text))\n}\n","import { isParameterObject } from '@kubb/oas'\n\nimport type { FunctionParamsAST } from '@kubb/core/utils'\nimport type { OasTypes } from '@kubb/oas'\nimport type { Params } from '@kubb/react/types'\nimport type { OperationSchema } from '../types.ts'\nimport { camelCase } from '@kubb/core/transformers'\n/**\n *\n * @deprecated\n * TODO move to operationManager hook\n */\nexport function getASTParams(\n operationSchema: OperationSchema | undefined,\n {\n typed = false,\n override,\n }: {\n typed?: boolean\n override?: (data: FunctionParamsAST) => FunctionParamsAST\n } = {},\n): FunctionParamsAST[] {\n if (!operationSchema || !operationSchema.schema.properties || !operationSchema.name) {\n return []\n }\n\n return Object.entries(operationSchema.schema.properties).map(([name, schema]: [string, OasTypes.SchemaObject]) => {\n const isParam = isParameterObject(schema)\n const data: FunctionParamsAST = {\n name,\n enabled: !!name,\n required: isParam ? schema.required : true,\n type: typed ? `${operationSchema.name}[\"${name}\"]` : undefined,\n }\n\n return override ? override(data) : data\n })\n}\n\nexport function getPathParams(\n operationSchema: OperationSchema | undefined,\n options: {\n typed?: boolean\n override?: (data: FunctionParamsAST) => FunctionParamsAST\n } = {},\n) {\n return getASTParams(operationSchema, options).reduce((acc, curr) => {\n if (curr.name && curr.enabled) {\n acc[camelCase(curr.name)] = {\n default: curr.default,\n type: curr.type,\n optional: !curr.required,\n }\n }\n\n return acc\n }, {} as Params)\n}\n","import type { Refs } from '../types.ts'\n\ntype Generated = { import: { refs: Refs; name: string } }\n\nexport function refsSorter<T extends Generated>(a: T, b: T): number {\n if (Object.keys(a.import.refs)?.length < Object.keys(b.import.refs)?.length) {\n return -1\n }\n if (Object.keys(a.import.refs)?.length > Object.keys(b.import.refs)?.length) {\n return 1\n }\n return 0\n}\n"]}
package/dist/utils.d.cts CHANGED
@@ -1,41 +1,15 @@
1
1
  import { Operation, Oas, SchemaObject, OpenAPIV3, OpenAPIV3_1 } from '@kubb/oas';
2
- import { Plugin, Config } from '@kubb/core';
3
- import { Logger } from '@kubb/core/logger';
4
- import * as KubbFile from '@kubb/fs/types';
2
+ export { isOptional } from '@kubb/oas';
5
3
  import { FunctionParamsAST } from '@kubb/core/utils';
6
- import { Params } from '@kubb/react';
7
- import { a as OperationSchema, R as Refs } from './types-BP45TdiW.cjs';
8
- export { G as GetSchemasProps, h as getSchemas } from './types-BP45TdiW.cjs';
4
+ import { Params } from '@kubb/react/types';
5
+ import { d as OperationSchema, b as Refs } from './types-CZTUCaE5.cjs';
6
+ export { G as GetSchemasProps, h as getSchemas } from './types-CZTUCaE5.cjs';
9
7
  import { FormatOptions } from '@kubb/oas/parser';
8
+ import { Config } from '@kubb/core';
9
+ import '@kubb/fs/types';
10
10
 
11
11
  declare function getComments(operation: Operation): string[];
12
12
 
13
- type Options = {
14
- logger: Logger;
15
- files: Array<KubbFile.File<FileMeta>>;
16
- plugin: Plugin;
17
- template: string;
18
- exportAs: string;
19
- /**
20
- * Root based on root and output.path specified in the config
21
- */
22
- root: string;
23
- /**
24
- * Output for plugin
25
- */
26
- output: {
27
- path: string;
28
- exportAs?: string;
29
- extName?: KubbFile.Extname;
30
- exportType?: 'barrel' | 'barrelNamed' | false;
31
- };
32
- };
33
- type FileMeta = {
34
- pluginKey?: Plugin['key'];
35
- tag?: string;
36
- };
37
- declare function getGroupedByTagFiles({ logger, files, plugin, template, exportAs, root, output }: Options): Promise<KubbFile.File<FileMeta>[]>;
38
-
39
13
  /**
40
14
  *
41
15
  * @deprecated
@@ -78,4 +52,4 @@ declare function refsSorter<T extends Generated>(a: T, b: T): number;
78
52
 
79
53
  declare function parseFromConfig(config: Config, options?: FormatOptions, oasClass?: typeof Oas): Promise<Oas>;
80
54
 
81
- export { getASTParams, getComments, getGroupedByTagFiles, getPathParams, getSchemaFactory, parseFromConfig, refsSorter };
55
+ export { getASTParams, getComments, getPathParams, getSchemaFactory, parseFromConfig, refsSorter };
package/dist/utils.d.ts CHANGED
@@ -1,41 +1,15 @@
1
1
  import { Operation, Oas, SchemaObject, OpenAPIV3, OpenAPIV3_1 } from '@kubb/oas';
2
- import { Plugin, Config } from '@kubb/core';
3
- import { Logger } from '@kubb/core/logger';
4
- import * as KubbFile from '@kubb/fs/types';
2
+ export { isOptional } from '@kubb/oas';
5
3
  import { FunctionParamsAST } from '@kubb/core/utils';
6
- import { Params } from '@kubb/react';
7
- import { a as OperationSchema, R as Refs } from './types-BP45TdiW.js';
8
- export { G as GetSchemasProps, h as getSchemas } from './types-BP45TdiW.js';
4
+ import { Params } from '@kubb/react/types';
5
+ import { d as OperationSchema, b as Refs } from './types-CZTUCaE5.js';
6
+ export { G as GetSchemasProps, h as getSchemas } from './types-CZTUCaE5.js';
9
7
  import { FormatOptions } from '@kubb/oas/parser';
8
+ import { Config } from '@kubb/core';
9
+ import '@kubb/fs/types';
10
10
 
11
11
  declare function getComments(operation: Operation): string[];
12
12
 
13
- type Options = {
14
- logger: Logger;
15
- files: Array<KubbFile.File<FileMeta>>;
16
- plugin: Plugin;
17
- template: string;
18
- exportAs: string;
19
- /**
20
- * Root based on root and output.path specified in the config
21
- */
22
- root: string;
23
- /**
24
- * Output for plugin
25
- */
26
- output: {
27
- path: string;
28
- exportAs?: string;
29
- extName?: KubbFile.Extname;
30
- exportType?: 'barrel' | 'barrelNamed' | false;
31
- };
32
- };
33
- type FileMeta = {
34
- pluginKey?: Plugin['key'];
35
- tag?: string;
36
- };
37
- declare function getGroupedByTagFiles({ logger, files, plugin, template, exportAs, root, output }: Options): Promise<KubbFile.File<FileMeta>[]>;
38
-
39
13
  /**
40
14
  *
41
15
  * @deprecated
@@ -78,4 +52,4 @@ declare function refsSorter<T extends Generated>(a: T, b: T): number;
78
52
 
79
53
  declare function parseFromConfig(config: Config, options?: FormatOptions, oasClass?: typeof Oas): Promise<Oas>;
80
54
 
81
- export { getASTParams, getComments, getGroupedByTagFiles, getPathParams, getSchemaFactory, parseFromConfig, refsSorter };
55
+ export { getASTParams, getComments, getPathParams, getSchemaFactory, parseFromConfig, refsSorter };
package/dist/utils.js CHANGED
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  parseFromConfig
3
- } from "./chunk-GUPCIAYT.js";
3
+ } from "./chunk-N7EEVJA6.js";
4
4
  import {
5
5
  getSchemaFactory,
6
6
  getSchemas,
7
7
  init_esm_shims
8
- } from "./chunk-Y272OQMW.js";
8
+ } from "./chunk-SZDO532A.js";
9
9
 
10
10
  // src/utils/index.ts
11
11
  init_esm_shims();
@@ -23,51 +23,6 @@ function getComments(operation) {
23
23
  ].filter(Boolean).map((text) => transformers.trim(text));
24
24
  }
25
25
 
26
- // src/utils/getGroupedByTagFiles.ts
27
- init_esm_shims();
28
- import { resolve } from "path";
29
- import { FileManager } from "@kubb/core";
30
- import transformers2 from "@kubb/core/transformers";
31
- import { renderTemplate } from "@kubb/core/utils";
32
- import { getRelativePath } from "@kubb/fs";
33
- async function getGroupedByTagFiles({ logger, files, plugin, template, exportAs, root, output }) {
34
- const { path, exportType = "barrel" } = output;
35
- const mode = FileManager.getMode(resolve(root, path));
36
- if (mode === "single" || exportType === false) {
37
- return [];
38
- }
39
- return files.filter((file) => {
40
- const name = file.meta?.pluginKey?.[0];
41
- return name === plugin.name;
42
- }).map((file) => {
43
- if (!file.meta?.tag) {
44
- logger?.emit("debug", [`Could not find a tagName for ${JSON.stringify(file, void 0, 2)}`]);
45
- return;
46
- }
47
- const tag = file.meta?.tag && transformers2.camelCase(file.meta.tag);
48
- const tagPath = getRelativePath(resolve(root, output.path), resolve(root, renderTemplate(template, { tag })));
49
- const tagName = renderTemplate(exportAs, { tag });
50
- if (tagName) {
51
- return {
52
- baseName: "index.ts",
53
- path: resolve(root, output.path, "index.ts"),
54
- source: "",
55
- exports: [
56
- {
57
- path: output.extName ? `${tagPath}/index${output.extName}` : `${tagPath}/index`,
58
- asAlias: true,
59
- name: tagName
60
- }
61
- ],
62
- meta: {
63
- pluginKey: plugin.key
64
- },
65
- exportable: true
66
- };
67
- }
68
- }).filter(Boolean);
69
- }
70
-
71
26
  // src/utils/getParams.ts
72
27
  init_esm_shims();
73
28
  import { isParameterObject } from "@kubb/oas";
@@ -114,13 +69,16 @@ function refsSorter(a, b) {
114
69
  }
115
70
  return 0;
116
71
  }
72
+
73
+ // src/utils/index.ts
74
+ import { isOptional } from "@kubb/oas";
117
75
  export {
118
76
  getASTParams,
119
77
  getComments,
120
- getGroupedByTagFiles,
121
78
  getPathParams,
122
79
  getSchemaFactory,
123
80
  getSchemas,
81
+ isOptional,
124
82
  parseFromConfig,
125
83
  refsSorter
126
84
  };
package/dist/utils.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/utils/index.ts","../src/utils/getComments.ts","../src/utils/getGroupedByTagFiles.ts","../src/utils/getParams.ts","../src/utils/refSorter.ts"],"sourcesContent":["export { getComments } from './getComments.ts'\nexport { getGroupedByTagFiles } from './getGroupedByTagFiles.ts'\nexport { getASTParams, getPathParams } from './getParams.ts'\nexport { getSchemaFactory } from './getSchemaFactory.ts'\nexport type { GetSchemasProps } from './getSchemas.ts'\nexport { getSchemas } from './getSchemas.ts'\nexport { refsSorter } from './refSorter.ts'\nexport { parseFromConfig } from './parseFromConfig.ts'\n","import transformers from '@kubb/core/transformers'\nimport { URLPath } from '@kubb/core/utils'\n\nimport type { Operation } from '@kubb/oas'\n\nexport function getComments(operation: Operation): string[] {\n return [\n operation.getDescription() && `@description ${operation.getDescription()}`,\n operation.getSummary() && `@summary ${operation.getSummary()}`,\n operation.path && `@link ${new URLPath(operation.path).URL}`,\n operation.isDeprecated() && '@deprecated',\n ]\n .filter(Boolean)\n .map((text) => transformers.trim(text))\n}\n","import { resolve } from 'node:path'\n\nimport { FileManager } from '@kubb/core'\nimport transformers from '@kubb/core/transformers'\nimport { renderTemplate } from '@kubb/core/utils'\nimport { getRelativePath } from '@kubb/fs'\n\nimport type { Plugin } from '@kubb/core'\nimport type { Logger } from '@kubb/core/logger'\nimport type * as KubbFile from '@kubb/fs/types'\n\ntype Options = {\n logger: Logger\n files: Array<KubbFile.File<FileMeta>>\n plugin: Plugin\n template: string\n exportAs: string\n /**\n * Root based on root and output.path specified in the config\n */\n root: string\n /**\n * Output for plugin\n */\n output: {\n path: string\n exportAs?: string\n extName?: KubbFile.Extname\n exportType?: 'barrel' | 'barrelNamed' | false\n }\n}\n\ntype FileMeta = {\n pluginKey?: Plugin['key']\n tag?: string\n}\n\nexport async function getGroupedByTagFiles({ logger, files, plugin, template, exportAs, root, output }: Options): Promise<KubbFile.File<FileMeta>[]> {\n const { path, exportType = 'barrel' } = output\n const mode = FileManager.getMode(resolve(root, path))\n\n if (mode === 'single' || exportType === false) {\n return []\n }\n\n return files\n .filter((file) => {\n const name = file.meta?.pluginKey?.[0]\n return name === plugin.name\n })\n .map((file: KubbFile.File<FileMeta>) => {\n if (!file.meta?.tag) {\n logger?.emit('debug', [`Could not find a tagName for ${JSON.stringify(file, undefined, 2)}`])\n\n return\n }\n\n const tag = file.meta?.tag && transformers.camelCase(file.meta.tag)\n const tagPath = getRelativePath(resolve(root, output.path), resolve(root, renderTemplate(template, { tag })))\n const tagName = renderTemplate(exportAs, { tag })\n\n if (tagName) {\n return {\n baseName: 'index.ts' as const,\n path: resolve(root, output.path, 'index.ts'),\n source: '',\n exports: [\n {\n path: output.extName ? `${tagPath}/index${output.extName}` : `${tagPath}/index`,\n asAlias: true,\n name: tagName,\n },\n ],\n meta: {\n pluginKey: plugin.key,\n },\n exportable: true,\n }\n }\n })\n .filter(Boolean)\n}\n","import { isParameterObject } from '@kubb/oas'\n\nimport type { FunctionParamsAST } from '@kubb/core/utils'\nimport type { OasTypes } from '@kubb/oas'\nimport type { Params } from '@kubb/react'\nimport type { OperationSchema } from '../types.ts'\nimport { camelCase } from '@kubb/core/transformers'\n/**\n *\n * @deprecated\n * TODO move to operationManager hook\n */\nexport function getASTParams(\n operationSchema: OperationSchema | undefined,\n {\n typed = false,\n override,\n }: {\n typed?: boolean\n override?: (data: FunctionParamsAST) => FunctionParamsAST\n } = {},\n): FunctionParamsAST[] {\n if (!operationSchema || !operationSchema.schema.properties || !operationSchema.name) {\n return []\n }\n\n return Object.entries(operationSchema.schema.properties).map(([name, schema]: [string, OasTypes.SchemaObject]) => {\n const isParam = isParameterObject(schema)\n const data: FunctionParamsAST = {\n name,\n enabled: !!name,\n required: isParam ? schema.required : true,\n type: typed ? `${operationSchema.name}[\"${name}\"]` : undefined,\n }\n\n return override ? override(data) : data\n })\n}\n\nexport function getPathParams(\n operationSchema: OperationSchema | undefined,\n options: {\n typed?: boolean\n override?: (data: FunctionParamsAST) => FunctionParamsAST\n } = {},\n) {\n return getASTParams(operationSchema, options).reduce((acc, curr) => {\n if (curr.name && curr.enabled) {\n acc[camelCase(curr.name)] = {\n default: curr.default,\n type: curr.type,\n optional: !curr.required,\n }\n }\n\n return acc\n }, {} as Params)\n}\n","import type { Refs } from '../types.ts'\n\ntype Generated = { import: { refs: Refs; name: string } }\n\nexport function refsSorter<T extends Generated>(a: T, b: T): number {\n if (Object.keys(a.import.refs)?.length < Object.keys(b.import.refs)?.length) {\n return -1\n }\n if (Object.keys(a.import.refs)?.length > Object.keys(b.import.refs)?.length) {\n return 1\n }\n return 0\n}\n"],"mappings":";;;;;;;;;;AAAA;;;ACAA;AAAA,OAAO,kBAAkB;AACzB,SAAS,eAAe;AAIjB,SAAS,YAAY,WAAgC;AAC1D,SAAO;AAAA,IACL,UAAU,eAAe,KAAK,gBAAgB,UAAU,eAAe,CAAC;AAAA,IACxE,UAAU,WAAW,KAAK,YAAY,UAAU,WAAW,CAAC;AAAA,IAC5D,UAAU,QAAQ,SAAS,IAAI,QAAQ,UAAU,IAAI,EAAE,GAAG;AAAA,IAC1D,UAAU,aAAa,KAAK;AAAA,EAC9B,EACG,OAAO,OAAO,EACd,IAAI,CAAC,SAAS,aAAa,KAAK,IAAI,CAAC;AAC1C;;;ACdA;AAAA,SAAS,eAAe;AAExB,SAAS,mBAAmB;AAC5B,OAAOA,mBAAkB;AACzB,SAAS,sBAAsB;AAC/B,SAAS,uBAAuB;AAgChC,eAAsB,qBAAqB,EAAE,QAAQ,OAAO,QAAQ,UAAU,UAAU,MAAM,OAAO,GAAgD;AACnJ,QAAM,EAAE,MAAM,aAAa,SAAS,IAAI;AACxC,QAAM,OAAO,YAAY,QAAQ,QAAQ,MAAM,IAAI,CAAC;AAEpD,MAAI,SAAS,YAAY,eAAe,OAAO;AAC7C,WAAO,CAAC;AAAA,EACV;AAEA,SAAO,MACJ,OAAO,CAAC,SAAS;AAChB,UAAM,OAAO,KAAK,MAAM,YAAY,CAAC;AACrC,WAAO,SAAS,OAAO;AAAA,EACzB,CAAC,EACA,IAAI,CAAC,SAAkC;AACtC,QAAI,CAAC,KAAK,MAAM,KAAK;AACnB,cAAQ,KAAK,SAAS,CAAC,gCAAgC,KAAK,UAAU,MAAM,QAAW,CAAC,CAAC,EAAE,CAAC;AAE5F;AAAA,IACF;AAEA,UAAM,MAAM,KAAK,MAAM,O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,SAAO,aAAa,iBAAiB,OAAO,EAAE,OAAO,CAAC,KAAK,SAAS;AAClE,QAAI,KAAK,QAAQ,KAAK,SAAS;AAC7B,UAAI,UAAU,KAAK,IAAI,CAAC,IAAI;AAAA,QAC1B,SAAS,KAAK;AAAA,QACd,MAAM,KAAK;AAAA,QACX,UAAU,CAAC,KAAK;AAAA,MAClB;AAAA,IACF;AAEA,WAAO;AAAA,EACT,GAAG,CAAC,CAAW;AACjB;;;ACzDA;AAIO,SAAS,WAAgC,GAAM,GAAc;AAClE,MAAI,OAAO,KAAK,EAAE,OAAO,IAAI,GAAG,SAAS,OAAO,KAAK,EAAE,OAAO,IAAI,GAAG,QAAQ;AAC3E,WAAO;AAAA,EACT;AACA,MAAI,OAAO,KAAK,EAAE,OAAO,IAAI,GAAG,SAAS,OAAO,KAAK,EAAE,OAAO,IAAI,GAAG,QAAQ;AAC3E,WAAO;AAAA,EACT;AACA,SAAO;AACT;","names":["transformers"]}
1
+ {"version":3,"sources":["../src/utils/index.ts","../src/utils/getComments.ts","../src/utils/getParams.ts","../src/utils/refSorter.ts"],"sourcesContent":["export { getComments } from './getComments.ts'\nexport { getASTParams, getPathParams } from './getParams.ts'\nexport { getSchemaFactory } from './getSchemaFactory.ts'\nexport type { GetSchemasProps } from './getSchemas.ts'\nexport { getSchemas } from './getSchemas.ts'\nexport { refsSorter } from './refSorter.ts'\nexport { parseFromConfig } from './parseFromConfig.ts'\n\nexport { isOptional } from '@kubb/oas'\n","import transformers from '@kubb/core/transformers'\nimport { URLPath } from '@kubb/core/utils'\n\nimport type { Operation } from '@kubb/oas'\n\nexport function getComments(operation: Operation): string[] {\n return [\n operation.getDescription() && `@description ${operation.getDescription()}`,\n operation.getSummary() && `@summary ${operation.getSummary()}`,\n operation.path && `@link ${new URLPath(operation.path).URL}`,\n operation.isDeprecated() && '@deprecated',\n ]\n .filter(Boolean)\n .map((text) => transformers.trim(text))\n}\n","import { isParameterObject } from '@kubb/oas'\n\nimport type { FunctionParamsAST } from '@kubb/core/utils'\nimport type { OasTypes } from '@kubb/oas'\nimport type { Params } from '@kubb/react/types'\nimport type { OperationSchema } from '../types.ts'\nimport { camelCase } from '@kubb/core/transformers'\n/**\n *\n * @deprecated\n * TODO move to operationManager hook\n */\nexport function getASTParams(\n operationSchema: OperationSchema | undefined,\n {\n typed = false,\n override,\n }: {\n typed?: boolean\n override?: (data: FunctionParamsAST) => FunctionParamsAST\n } = {},\n): FunctionParamsAST[] {\n if (!operationSchema || !operationSchema.schema.properties || !operationSchema.name) {\n return []\n }\n\n return Object.entries(operationSchema.schema.properties).map(([name, schema]: [string, OasTypes.SchemaObject]) => {\n const isParam = isParameterObject(schema)\n const data: FunctionParamsAST = {\n name,\n enabled: !!name,\n required: isParam ? schema.required : true,\n type: typed ? `${operationSchema.name}[\"${name}\"]` : undefined,\n }\n\n return override ? override(data) : data\n })\n}\n\nexport function getPathParams(\n operationSchema: OperationSchema | undefined,\n options: {\n typed?: boolean\n override?: (data: FunctionParamsAST) => FunctionParamsAST\n } = {},\n) {\n return getASTParams(operationSchema, options).reduce((acc, curr) => {\n if (curr.name && curr.enabled) {\n acc[camelCase(curr.name)] = {\n default: curr.default,\n type: curr.type,\n optional: !curr.required,\n }\n }\n\n return acc\n }, {} as Params)\n}\n","import type { Refs } from '../types.ts'\n\ntype Generated = { import: { refs: Refs; name: string } }\n\nexport function refsSorter<T extends Generated>(a: T, b: T): number {\n if (Object.keys(a.import.refs)?.length < Object.keys(b.import.refs)?.length) {\n return -1\n }\n if (Object.keys(a.import.refs)?.length > Object.keys(b.import.refs)?.length) {\n return 1\n }\n return 0\n}\n"],"mappings":";;;;;;;;;;AAAA;;;ACAA;AAAA,OAAO,kBAAkB;AACzB,SAAS,eAAe;AAIjB,SAAS,YAAY,WAAgC;AAC1D,SAAO;AAAA,IACL,UAAU,eAAe,KAAK,gBAAgB,UAAU,eAAe,CAAC;AAAA,IACxE,UAAU,WAAW,KAAK,YAAY,UAAU,WAAW,CAAC;AAAA,IA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WAAO;AAAA,EACT;AACA,MAAI,OAAO,KAAK,EAAE,OAAO,IAAI,GAAG,SAAS,OAAO,KAAK,EAAE,OAAO,IAAI,GAAG,QAAQ;AAC3E,WAAO;AAAA,EACT;AACA,SAAO;AACT;;;AHJA,SAAS,kBAAkB;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/plugin-oas",
3
- "version": "3.0.0-alpha.0",
3
+ "version": "3.0.0-alpha.10",
4
4
  "description": "Generator swagger",
5
5
  "keywords": [
6
6
  "typescript",
@@ -67,24 +67,25 @@
67
67
  ],
68
68
  "dependencies": {
69
69
  "@stoplight/yaml": "^4.3.0",
70
- "remeda": "^2.10.1",
71
- "@kubb/core": "3.0.0-alpha.0",
72
- "@kubb/fs": "3.0.0-alpha.0",
73
- "@kubb/oas": "3.0.0-alpha.0",
74
- "@kubb/react": "3.0.0-alpha.0"
70
+ "execa": "^9.3.1",
71
+ "remeda": "^2.11.0",
72
+ "@kubb/core": "3.0.0-alpha.10",
73
+ "@kubb/fs": "3.0.0-alpha.10",
74
+ "@kubb/oas": "3.0.0-alpha.10",
75
+ "@kubb/react": "3.0.0-alpha.10"
75
76
  },
76
77
  "devDependencies": {
77
- "@types/react": "^18.3.3",
78
+ "@types/react": "^18.3.5",
78
79
  "@types/react-dom": "^18.3.0",
79
80
  "react": "^18.3.1",
80
81
  "tsup": "^8.2.4",
81
82
  "typescript": "^5.5.4",
82
- "@kubb/config-biome": "3.0.0-alpha.0",
83
- "@kubb/config-ts": "3.0.0-alpha.0",
84
- "@kubb/config-tsup": "3.0.0-alpha.0"
83
+ "@kubb/config-biome": "3.0.0-alpha.10",
84
+ "@kubb/config-ts": "3.0.0-alpha.10",
85
+ "@kubb/config-tsup": "3.0.0-alpha.10"
85
86
  },
86
87
  "peerDependencies": {
87
- "@kubb/react": "3.0.0-alpha.0"
88
+ "@kubb/react": "3.0.0-alpha.10"
88
89
  },
89
90
  "engines": {
90
91
  "node": ">=20"