@kubb/plugin-oas 4.4.0 → 4.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{SchemaGenerator-7wBwdv8G.js → SchemaGenerator-BwYbrh7a.js} +93 -36
- package/dist/SchemaGenerator-BwYbrh7a.js.map +1 -0
- package/dist/{SchemaGenerator-DzVHk6OP.cjs → SchemaGenerator-C81yEgKY.cjs} +114 -37
- package/dist/SchemaGenerator-C81yEgKY.cjs.map +1 -0
- package/dist/{SchemaMapper-DoL-a6qq.cjs → SchemaMapper-BUV8vhg0.cjs} +1 -1
- package/dist/SchemaMapper-BUV8vhg0.cjs.map +1 -0
- package/dist/{SchemaMapper-CqBW0VOy.d.ts → SchemaMapper-CgGWx6jF.d.cts} +15 -116
- package/dist/{SchemaMapper-MiRB5_Zp.d.cts → SchemaMapper-Cj3vjPGs.d.ts} +15 -116
- package/dist/{SchemaMapper-Cx4X1al6.js → SchemaMapper-D30tqRoX.js} +1 -1
- package/dist/SchemaMapper-D30tqRoX.js.map +1 -0
- package/dist/{OperationGenerator-BZPWkxw4.d.ts → createGenerator-BvCDyuKS.d.ts} +128 -191
- package/dist/{OperationGenerator-CJTAer7l.d.cts → createGenerator-CPNglV1d.d.cts} +129 -192
- package/dist/{generators-C61FxVIj.js → generators-CJDEf8Kn.js} +6 -6
- package/dist/generators-CJDEf8Kn.js.map +1 -0
- package/dist/{generators-B27La9Vd.cjs → generators-udGOxdUV.cjs} +6 -6
- package/dist/generators-udGOxdUV.cjs.map +1 -0
- package/dist/generators.cjs +2 -7
- package/dist/generators.d.cts +8 -3
- package/dist/generators.d.ts +8 -3
- package/dist/generators.js +3 -5
- package/dist/{getFooter-D5MdeUVv.js → getFooter-CV73pVXj.js} +2 -2
- package/dist/{getFooter-D5MdeUVv.js.map → getFooter-CV73pVXj.js.map} +1 -1
- package/dist/{getFooter-CwjCW4h5.cjs → getFooter-DPh4lxBH.cjs} +3 -3
- package/dist/{getFooter-CwjCW4h5.cjs.map → getFooter-DPh4lxBH.cjs.map} +1 -1
- package/dist/getSchemas-32BHoMO-.js +100 -0
- package/dist/getSchemas-32BHoMO-.js.map +1 -0
- package/dist/getSchemas-Cl0TZ4XY.cjs +113 -0
- package/dist/getSchemas-Cl0TZ4XY.cjs.map +1 -0
- package/dist/hooks.cjs +6 -47
- package/dist/hooks.cjs.map +1 -1
- package/dist/hooks.d.cts +11 -45
- package/dist/hooks.d.ts +11 -45
- package/dist/hooks.js +8 -46
- package/dist/hooks.js.map +1 -1
- package/dist/index.cjs +37 -32
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +58 -3
- package/dist/index.d.ts +58 -3
- package/dist/index.js +32 -24
- package/dist/index.js.map +1 -1
- package/dist/mocks.cjs +1 -1
- package/dist/mocks.d.cts +1 -1
- package/dist/mocks.d.ts +1 -1
- package/dist/mocks.js +1 -1
- package/dist/{parseFromConfig-CqiiLCPe.js → parseFromConfig-BkUoWC2U.js} +1 -1
- package/dist/parseFromConfig-BkUoWC2U.js.map +1 -0
- package/dist/{parseFromConfig-RR31a98-.cjs → parseFromConfig-EjsCZ0-8.cjs} +1 -1
- package/dist/parseFromConfig-EjsCZ0-8.cjs.map +1 -0
- package/dist/utils.cjs +3 -3
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +28 -24
- package/dist/utils.d.ts +28 -24
- package/dist/utils.js +3 -3
- package/dist/utils.js.map +1 -1
- package/package.json +14 -17
- package/src/OperationGenerator.ts +27 -14
- package/src/SchemaGenerator.ts +25 -47
- package/src/SchemaMapper.ts +3 -1
- package/src/generators/createGenerator.ts +1 -1
- package/src/generators/index.ts +0 -1
- package/src/generators/jsonGenerator.ts +4 -4
- package/src/generators/types.ts +13 -14
- package/src/hooks/index.ts +1 -4
- package/src/hooks/useOas.ts +5 -11
- package/src/hooks/useOperationManager.ts +3 -5
- package/src/hooks/useSchemaManager.ts +1 -1
- package/src/index.ts +1 -1
- package/src/types.ts +1 -1
- package/src/utils/getBanner.ts +1 -1
- package/src/utils/getParams.ts +1 -2
- package/src/utils/getSchemaFactory.ts +1 -2
- package/src/utils/getSchemas.ts +89 -15
- package/src/utils/index.ts +3 -4
- package/src/utils/parseFromConfig.ts +2 -6
- package/src/utils.tsx +101 -0
- package/dist/Oas-BzrQ6RGC.cjs +0 -80
- package/dist/Oas-BzrQ6RGC.cjs.map +0 -1
- package/dist/Oas-CIeHKOo0.js +0 -60
- package/dist/Oas-CIeHKOo0.js.map +0 -1
- package/dist/Schema-CjraJhJi.d.ts +0 -38
- package/dist/Schema-zcZF0UIp.d.cts +0 -38
- package/dist/SchemaGenerator-7wBwdv8G.js.map +0 -1
- package/dist/SchemaGenerator-DzVHk6OP.cjs.map +0 -1
- package/dist/SchemaMapper-Cx4X1al6.js.map +0 -1
- package/dist/SchemaMapper-DoL-a6qq.cjs.map +0 -1
- package/dist/components.cjs +0 -5
- package/dist/components.d.cts +0 -42
- package/dist/components.d.ts +0 -42
- package/dist/components.js +0 -3
- package/dist/generators-B27La9Vd.cjs.map +0 -1
- package/dist/generators-C61FxVIj.js.map +0 -1
- package/dist/getSchemas-Bdg6n9Qk.js +0 -55
- package/dist/getSchemas-Bdg6n9Qk.js.map +0 -1
- package/dist/getSchemas-DY8s2CSl.cjs +0 -68
- package/dist/getSchemas-DY8s2CSl.cjs.map +0 -1
- package/dist/parseFromConfig-CqiiLCPe.js.map +0 -1
- package/dist/parseFromConfig-RR31a98-.cjs.map +0 -1
- package/dist/utils-BnkB1ikY.js +0 -99
- package/dist/utils-BnkB1ikY.js.map +0 -1
- package/dist/utils-nzdccPlU.cjs +0 -119
- package/dist/utils-nzdccPlU.cjs.map +0 -1
- package/src/components/Oas.tsx +0 -35
- package/src/components/Operation.tsx +0 -20
- package/src/components/Schema.tsx +0 -38
- package/src/components/index.ts +0 -3
- package/src/generators/utils.tsx +0 -114
- package/src/hooks/useOperation.ts +0 -18
- package/src/hooks/useOperations.ts +0 -40
- package/src/hooks/useSchema.ts +0 -16
package/dist/index.js
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import { n as
|
|
2
|
-
import "./
|
|
3
|
-
import "./
|
|
4
|
-
import { n as
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import "
|
|
8
|
-
import { t as parseFromConfig } from "./parseFromConfig-CqiiLCPe.js";
|
|
1
|
+
import { a as pLimit, i as buildSchema, n as buildOperation, r as buildOperations, t as SchemaGenerator } from "./SchemaGenerator-BwYbrh7a.js";
|
|
2
|
+
import { t as jsonGenerator } from "./generators-CJDEf8Kn.js";
|
|
3
|
+
import "./getFooter-CV73pVXj.js";
|
|
4
|
+
import { n as schemaKeywords, t as isKeyword } from "./SchemaMapper-D30tqRoX.js";
|
|
5
|
+
import "./getSchemas-32BHoMO-.js";
|
|
6
|
+
import { t as parseFromConfig } from "./parseFromConfig-BkUoWC2U.js";
|
|
7
|
+
import { BaseGenerator, createPlugin, getMode } from "@kubb/core";
|
|
9
8
|
import transformers, { camelCase } from "@kubb/core/transformers";
|
|
10
9
|
import path from "node:path";
|
|
11
|
-
import { BaseGenerator, createPlugin, getMode } from "@kubb/core";
|
|
12
10
|
|
|
13
11
|
//#region src/OperationGenerator.ts
|
|
14
12
|
var OperationGenerator = class extends BaseGenerator {
|
|
@@ -151,22 +149,30 @@ var OperationGenerator = class extends BaseGenerator {
|
|
|
151
149
|
const options = this.#getOptions(operation, method);
|
|
152
150
|
if (generator.type === "react") {
|
|
153
151
|
await buildOperation(operation, {
|
|
152
|
+
config: this.context.pluginManager.config,
|
|
154
153
|
fabric: this.context.fabric,
|
|
155
|
-
generator,
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
...this.
|
|
159
|
-
|
|
154
|
+
Component: generator.Operation,
|
|
155
|
+
generator: this,
|
|
156
|
+
plugin: {
|
|
157
|
+
...this.context.plugin,
|
|
158
|
+
options: {
|
|
159
|
+
...this.options,
|
|
160
|
+
...options
|
|
161
|
+
}
|
|
160
162
|
}
|
|
161
163
|
});
|
|
162
164
|
return [];
|
|
163
165
|
}
|
|
164
166
|
return await generator.operation?.({
|
|
165
|
-
|
|
167
|
+
generator: this,
|
|
168
|
+
config: this.context.pluginManager.config,
|
|
166
169
|
operation,
|
|
167
|
-
|
|
168
|
-
...this.
|
|
169
|
-
|
|
170
|
+
plugin: {
|
|
171
|
+
...this.context.plugin,
|
|
172
|
+
options: {
|
|
173
|
+
...this.options,
|
|
174
|
+
...options
|
|
175
|
+
}
|
|
170
176
|
}
|
|
171
177
|
}) ?? [];
|
|
172
178
|
}));
|
|
@@ -174,16 +180,18 @@ var OperationGenerator = class extends BaseGenerator {
|
|
|
174
180
|
if (generator.type === "react") {
|
|
175
181
|
await buildOperations(operations.map((op) => op.operation), {
|
|
176
182
|
fabric: this.context.fabric,
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
183
|
+
config: this.context.pluginManager.config,
|
|
184
|
+
Component: generator.Operations,
|
|
185
|
+
generator: this,
|
|
186
|
+
plugin: this.context.plugin
|
|
180
187
|
});
|
|
181
188
|
return [];
|
|
182
189
|
}
|
|
183
190
|
const operationsResult = await generator.operations?.({
|
|
184
|
-
|
|
191
|
+
generator: this,
|
|
192
|
+
config: this.context.pluginManager.config,
|
|
185
193
|
operations: operations.map((op) => op.operation),
|
|
186
|
-
|
|
194
|
+
plugin: this.context.plugin
|
|
187
195
|
});
|
|
188
196
|
return [...opResultsFlat, ...operationsResult ?? []];
|
|
189
197
|
}));
|
|
@@ -293,5 +301,5 @@ const pluginOas = createPlugin((options) => {
|
|
|
293
301
|
});
|
|
294
302
|
|
|
295
303
|
//#endregion
|
|
296
|
-
export { OperationGenerator, SchemaGenerator, buildOperation, buildOperations, buildSchema,
|
|
304
|
+
export { OperationGenerator, SchemaGenerator, buildOperation, buildOperations, buildSchema, isKeyword, pluginOas, pluginOasName, schemaKeywords };
|
|
297
305
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["path","#isExcluded","#isIncluded","#getOptions","oas: Oas","options","groupName: Group['name']","oas"],"sources":["../src/OperationGenerator.ts","../src/plugin.ts"],"sourcesContent":["import type { Plugin, PluginFactoryOptions, PluginManager } from '@kubb/core'\nimport { BaseGenerator, type FileMetaBase } from '@kubb/core'\nimport type { KubbFile } from '@kubb/core/fs'\nimport transformers from '@kubb/core/transformers'\nimport type { contentType, HttpMethod, Oas, OasTypes, Operation, SchemaObject } from '@kubb/oas'\nimport type { Fabric } from '@kubb/react-fabric'\nimport pLimit from 'p-limit'\nimport type { Generator } from './generators/types.ts'\nimport { buildOperation, buildOperations } from './generators/utils.tsx'\nimport type { Exclude, Include, OperationSchemas, Override } from './types.ts'\n\nexport type OperationMethodResult<TFileMeta extends FileMetaBase> = Promise<KubbFile.File<TFileMeta> | Array<KubbFile.File<TFileMeta>> | null>\n\ntype Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {\n fabric: Fabric\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 #getOptions(operation: Operation, method: HttpMethod): Partial<TPluginOptions['resolvedOptions']> {\n const { override = [] } = this.context\n const operationId = operation.getOperationId({ friendlyCase: true })\n const contentType = operation.getContentType()\n\n return (\n override.find(({ pattern, type }) => {\n switch (type) {\n case 'tag':\n return operation.getTags().some((tag) => tag.name.match(pattern))\n case 'operationId':\n return !!operationId.match(pattern)\n case 'path':\n return !!operation.path.match(pattern)\n case 'method':\n return !!method.match(pattern)\n case 'contentType':\n return !!contentType.match(pattern)\n default:\n return false\n }\n })?.options || {}\n )\n }\n\n #isExcluded(operation: Operation, method: HttpMethod): boolean {\n const { exclude = [] } = this.context\n const operationId = operation.getOperationId({ friendlyCase: true })\n const contentType = operation.getContentType()\n\n return exclude.some(({ pattern, type }) => {\n switch (type) {\n case 'tag':\n return operation.getTags().some((tag) => tag.name.match(pattern))\n case 'operationId':\n return !!operationId.match(pattern)\n case 'path':\n return !!operation.path.match(pattern)\n case 'method':\n return !!method.match(pattern)\n case 'contentType':\n return !!contentType.match(pattern)\n default:\n return false\n }\n })\n }\n\n #isIncluded(operation: Operation, method: HttpMethod): boolean {\n const { include = [] } = this.context\n const operationId = operation.getOperationId({ friendlyCase: true })\n const contentType = operation.getContentType()\n\n return include.some(({ pattern, type }) => {\n switch (type) {\n case 'tag':\n return operation.getTags().some((tag) => tag.name.match(pattern))\n case 'operationId':\n return !!operationId.match(pattern)\n case 'path':\n return !!operation.path.match(pattern)\n case 'method':\n return !!method.match(pattern)\n case 'contentType':\n return !!contentType.match(pattern)\n default:\n return false\n }\n })\n }\n\n getSchemas(\n operation: Operation,\n {\n resolveName = (name) => name,\n }: {\n resolveName?: (name: string) => string\n } = {},\n ): OperationSchemas {\n const operationId = operation.getOperationId({ friendlyCase: true })\n const method = operation.method\n const operationName = transformers.pascalCase(operationId)\n\n const resolveKeys = (schema?: SchemaObject) => (schema?.properties ? Object.keys(schema.properties) : undefined)\n\n const pathParamsSchema = this.context.oas.getParametersSchema(operation, 'path')\n const queryParamsSchema = this.context.oas.getParametersSchema(operation, 'query')\n const headerParamsSchema = this.context.oas.getParametersSchema(operation, 'header')\n const requestSchema = this.context.oas.getRequestSchema(operation)\n const statusCodes = operation.getResponseStatusCodes().map((statusCode) => {\n const name = statusCode === 'default' ? 'error' : statusCode\n const schema = this.context.oas.getResponseSchema(operation, statusCode)\n const keys = resolveKeys(schema)\n\n return {\n name: resolveName(transformers.pascalCase(`${operationId} ${name}`)),\n description: (operation.getResponseByStatusCode(statusCode) as OasTypes.ResponseObject)?.description,\n schema,\n operation,\n operationName,\n statusCode: name === 'error' ? undefined : Number(statusCode),\n keys,\n keysToOmit: keys?.filter((key) => (schema?.properties?.[key] as OasTypes.SchemaObject)?.writeOnly),\n }\n })\n\n const successful = statusCodes.filter((item) => item.statusCode?.toString().startsWith('2'))\n const errors = statusCodes.filter((item) => item.statusCode?.toString().startsWith('4') || item.statusCode?.toString().startsWith('5'))\n\n return {\n pathParams: pathParamsSchema\n ? {\n name: resolveName(transformers.pascalCase(`${operationId} PathParams`)),\n operation,\n operationName,\n schema: pathParamsSchema,\n keys: resolveKeys(pathParamsSchema),\n }\n : undefined,\n queryParams: queryParamsSchema\n ? {\n name: resolveName(transformers.pascalCase(`${operationId} QueryParams`)),\n operation,\n operationName,\n schema: queryParamsSchema,\n keys: resolveKeys(queryParamsSchema) || [],\n }\n : undefined,\n headerParams: headerParamsSchema\n ? {\n name: resolveName(transformers.pascalCase(`${operationId} HeaderParams`)),\n operation,\n operationName,\n schema: headerParamsSchema,\n keys: resolveKeys(headerParamsSchema),\n }\n : undefined,\n request: requestSchema\n ? {\n name: resolveName(transformers.pascalCase(`${operationId} ${method === 'get' ? 'queryRequest' : 'mutationRequest'}`)),\n description: (operation.schema.requestBody as OasTypes.RequestBodyObject)?.description,\n operation,\n operationName,\n schema: requestSchema,\n keys: resolveKeys(requestSchema),\n keysToOmit: resolveKeys(requestSchema)?.filter((key) => (requestSchema.properties?.[key] as OasTypes.SchemaObject)?.readOnly),\n }\n : undefined,\n response: {\n name: resolveName(transformers.pascalCase(`${operationId} ${method === 'get' ? 'queryResponse' : 'mutationResponse'}`)),\n operation,\n operationName,\n schema: {\n oneOf: successful.map((item) => ({ ...item.schema, $ref: item.name })) || undefined,\n } as SchemaObject,\n },\n responses: successful,\n errors,\n statusCodes,\n }\n }\n\n async getOperations(): Promise<Array<{ path: string; method: HttpMethod; operation: Operation }>> {\n const { oas } = this.context\n\n const paths = oas.getPaths()\n\n return Object.entries(paths).flatMap(([path, methods]) =>\n Object.entries(methods)\n .map((values) => {\n const [method, operation] = values as [HttpMethod, Operation]\n if (this.#isExcluded(operation, method)) {\n return null\n }\n\n if (this.context.include && !this.#isIncluded(operation, method)) {\n return null\n }\n\n return operation ? { path, method: method as HttpMethod, operation } : null\n })\n .filter(Boolean),\n )\n }\n\n async build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<KubbFile.File<TFileMeta>>> {\n const operations = await this.getOperations()\n\n const generatorLimit = pLimit(1)\n const operationLimit = pLimit(10)\n\n const writeTasks = generators.map((generator) =>\n generatorLimit(async () => {\n const operationTasks = operations.map(({ operation, method }) =>\n operationLimit(async () => {\n const options = this.#getOptions(operation, method)\n\n if (generator.type === 'react') {\n await buildOperation(operation, {\n fabric: this.context.fabric,\n generator,\n instance: this,\n options: {\n ...this.options,\n ...options,\n },\n })\n\n return []\n }\n\n const result = await generator.operation?.({\n instance: this,\n operation,\n options: { ...this.options, ...options },\n })\n\n return result ?? []\n }),\n )\n\n const operationResults = await Promise.all(operationTasks)\n const opResultsFlat = operationResults.flat()\n\n if (generator.type === 'react') {\n await buildOperations(\n operations.map((op) => op.operation),\n {\n fabric: this.context.fabric,\n generator,\n instance: this,\n options: this.options,\n },\n )\n\n return []\n }\n\n const operationsResult = await generator.operations?.({\n instance: this,\n operations: operations.map((op) => op.operation),\n options: this.options,\n })\n\n return [...opResultsFlat, ...(operationsResult ?? [])] as unknown as KubbFile.File<TFileMeta>\n }),\n )\n\n const nestedResults = await Promise.all(writeTasks)\n\n return nestedResults.flat()\n }\n}\n","import path from 'node:path'\nimport { type Config, createPlugin, type Group, getMode } from '@kubb/core'\nimport type { Logger } from '@kubb/core/logger'\nimport { camelCase } from '@kubb/core/transformers'\nimport type { Oas } from '@kubb/oas'\nimport { jsonGenerator } from './generators'\nimport { OperationGenerator } from './OperationGenerator.ts'\nimport { SchemaGenerator } from './SchemaGenerator.ts'\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 = {\n path: 'schemas',\n },\n group,\n validate = true,\n generators = [jsonGenerator],\n serverIndex,\n contentType,\n oasClass,\n discriminator = 'strict',\n } = options\n let oas: Oas\n\n const getOas = async ({ config, logger }: { config: Config; logger: Logger }): Promise<Oas> => {\n // needs to be in a different variable or the catch here will not work(return of a promise instead)\n oas = await parseFromConfig(config, oasClass)\n\n oas.setOptions({\n contentType,\n discriminator,\n })\n\n try {\n if (validate) {\n await oas.valdiate()\n }\n } catch (e) {\n const error = e as Error\n\n logger.emit('warning', error?.message)\n }\n\n return oas\n }\n\n return {\n name: pluginOasName,\n options: {\n output,\n validate,\n discriminator,\n ...options,\n },\n context() {\n const { config, logger } = this\n\n return {\n getOas() {\n return getOas({ config, logger })\n },\n async getBaseURL() {\n const oasInstance = await this.getOas()\n if (serverIndex) {\n return oasInstance.api.servers?.at(serverIndex)?.url\n }\n\n return undefined\n },\n }\n },\n resolvePath(baseName, pathMode, options) {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = pathMode ?? 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 if (group && (options?.group?.path || options?.group?.tag)) {\n const groupName: Group['name'] = group?.name\n ? group.name\n : (ctx) => {\n if (group?.type === 'path') {\n return `${ctx.group.split('/')[1]}`\n }\n return `${camelCase(ctx.group)}Controller`\n }\n\n return path.resolve(\n root,\n output.path,\n groupName({\n group: group.type === 'path' ? options.group.path! : options.group.tag!,\n }),\n baseName,\n )\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 emptySchemaType: 'unknown',\n dateType: 'date',\n transformers: {},\n ...this.plugin.options,\n },\n {\n fabric: this.fabric,\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 fabric: this.fabric,\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"],"mappings":";;;;;;;;;;;;;AA4BA,IAAa,qBAAb,cAGU,cAA6G;CACrH,YAAY,WAAsB,QAAgE;EAChG,MAAM,EAAE,WAAW,EAAE,KAAK,KAAK;EAC/B,MAAM,cAAc,UAAU,eAAe,EAAE,cAAc,MAAM,CAAC;EACpE,MAAM,cAAc,UAAU,gBAAgB;AAE9C,SACE,SAAS,MAAM,EAAE,SAAS,WAAW;AACnC,WAAQ,MAAR;IACE,KAAK,MACH,QAAO,UAAU,SAAS,CAAC,MAAM,QAAQ,IAAI,KAAK,MAAM,QAAQ,CAAC;IACnE,KAAK,cACH,QAAO,CAAC,CAAC,YAAY,MAAM,QAAQ;IACrC,KAAK,OACH,QAAO,CAAC,CAAC,UAAU,KAAK,MAAM,QAAQ;IACxC,KAAK,SACH,QAAO,CAAC,CAAC,OAAO,MAAM,QAAQ;IAChC,KAAK,cACH,QAAO,CAAC,CAAC,YAAY,MAAM,QAAQ;IACrC,QACE,QAAO;;IAEX,EAAE,WAAW,EAAE;;CAIrB,YAAY,WAAsB,QAA6B;EAC7D,MAAM,EAAE,UAAU,EAAE,KAAK,KAAK;EAC9B,MAAM,cAAc,UAAU,eAAe,EAAE,cAAc,MAAM,CAAC;EACpE,MAAM,cAAc,UAAU,gBAAgB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AAS;IACT,UAAU;IACV,MAAM;IACN,QAAQ,OAAO;IAChB,CACF,CAEyC,MAAM,GAAG,WAAW;AAC9D,SAAM,KAAK,QAAQ,GAAG,YAAY;GAclC,MAAM,iBAAiB,MAZI,IAAI,mBAAmB,KAAK,OAAO,SAAS;IACrE,QAAQ,KAAK;IACb;IACA,eAAe,KAAK;IACpB,QAAQ,KAAK;IACb;IACA,SAAS;IACT,SAAS;IACT,UAAU;IACV,MAAM;IACP,CAAC,CAE8C,MAAM,GAAG,WAAW;AAEpE,SAAM,KAAK,QAAQ,GAAG,eAAe;;EAExC;EACD"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["path","#isExcluded","#isIncluded","#getOptions","oas: Oas","options","groupName: Group['name']","oas"],"sources":["../src/OperationGenerator.ts","../src/plugin.ts"],"sourcesContent":["import type { Plugin, PluginFactoryOptions, PluginManager } from '@kubb/core'\nimport { BaseGenerator, type FileMetaBase } from '@kubb/core'\nimport transformers from '@kubb/core/transformers'\nimport type { KubbFile } from '@kubb/fabric-core/types'\nimport type { contentType, HttpMethod, Oas, OasTypes, Operation, SchemaObject } from '@kubb/oas'\nimport type { Fabric } from '@kubb/react-fabric'\nimport pLimit from 'p-limit'\nimport type { Generator } from './generators/types.ts'\nimport type { Exclude, Include, OperationSchemas, Override } from './types.ts'\nimport { buildOperation, buildOperations } from './utils.tsx'\n\nexport type OperationMethodResult<TFileMeta extends FileMetaBase> = Promise<KubbFile.File<TFileMeta> | Array<KubbFile.File<TFileMeta>> | null>\n\ntype Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {\n fabric: Fabric\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 #getOptions(operation: Operation, method: HttpMethod): Partial<TPluginOptions['resolvedOptions']> {\n const { override = [] } = this.context\n const operationId = operation.getOperationId({ friendlyCase: true })\n const contentType = operation.getContentType()\n\n return (\n override.find(({ pattern, type }) => {\n switch (type) {\n case 'tag':\n return operation.getTags().some((tag) => tag.name.match(pattern))\n case 'operationId':\n return !!operationId.match(pattern)\n case 'path':\n return !!operation.path.match(pattern)\n case 'method':\n return !!method.match(pattern)\n case 'contentType':\n return !!contentType.match(pattern)\n default:\n return false\n }\n })?.options || {}\n )\n }\n\n #isExcluded(operation: Operation, method: HttpMethod): boolean {\n const { exclude = [] } = this.context\n const operationId = operation.getOperationId({ friendlyCase: true })\n const contentType = operation.getContentType()\n\n return exclude.some(({ pattern, type }) => {\n switch (type) {\n case 'tag':\n return operation.getTags().some((tag) => tag.name.match(pattern))\n case 'operationId':\n return !!operationId.match(pattern)\n case 'path':\n return !!operation.path.match(pattern)\n case 'method':\n return !!method.match(pattern)\n case 'contentType':\n return !!contentType.match(pattern)\n default:\n return false\n }\n })\n }\n\n #isIncluded(operation: Operation, method: HttpMethod): boolean {\n const { include = [] } = this.context\n const operationId = operation.getOperationId({ friendlyCase: true })\n const contentType = operation.getContentType()\n\n return include.some(({ pattern, type }) => {\n switch (type) {\n case 'tag':\n return operation.getTags().some((tag) => tag.name.match(pattern))\n case 'operationId':\n return !!operationId.match(pattern)\n case 'path':\n return !!operation.path.match(pattern)\n case 'method':\n return !!method.match(pattern)\n case 'contentType':\n return !!contentType.match(pattern)\n default:\n return false\n }\n })\n }\n\n getSchemas(\n operation: Operation,\n {\n resolveName = (name) => name,\n }: {\n resolveName?: (name: string) => string\n } = {},\n ): OperationSchemas {\n const operationId = operation.getOperationId({ friendlyCase: true })\n const method = operation.method\n const operationName = transformers.pascalCase(operationId)\n\n const resolveKeys = (schema?: SchemaObject) => (schema?.properties ? Object.keys(schema.properties) : undefined)\n\n const pathParamsSchema = this.context.oas.getParametersSchema(operation, 'path')\n const queryParamsSchema = this.context.oas.getParametersSchema(operation, 'query')\n const headerParamsSchema = this.context.oas.getParametersSchema(operation, 'header')\n const requestSchema = this.context.oas.getRequestSchema(operation)\n const statusCodes = operation.getResponseStatusCodes().map((statusCode) => {\n const name = statusCode === 'default' ? 'error' : statusCode\n const schema = this.context.oas.getResponseSchema(operation, statusCode)\n const keys = resolveKeys(schema)\n\n return {\n name: resolveName(transformers.pascalCase(`${operationId} ${name}`)),\n description: (operation.getResponseByStatusCode(statusCode) as OasTypes.ResponseObject)?.description,\n schema,\n operation,\n operationName,\n statusCode: name === 'error' ? undefined : Number(statusCode),\n keys,\n keysToOmit: keys?.filter((key) => (schema?.properties?.[key] as OasTypes.SchemaObject)?.writeOnly),\n }\n })\n\n const successful = statusCodes.filter((item) => item.statusCode?.toString().startsWith('2'))\n const errors = statusCodes.filter((item) => item.statusCode?.toString().startsWith('4') || item.statusCode?.toString().startsWith('5'))\n\n return {\n pathParams: pathParamsSchema\n ? {\n name: resolveName(transformers.pascalCase(`${operationId} PathParams`)),\n operation,\n operationName,\n schema: pathParamsSchema,\n keys: resolveKeys(pathParamsSchema),\n }\n : undefined,\n queryParams: queryParamsSchema\n ? {\n name: resolveName(transformers.pascalCase(`${operationId} QueryParams`)),\n operation,\n operationName,\n schema: queryParamsSchema,\n keys: resolveKeys(queryParamsSchema) || [],\n }\n : undefined,\n headerParams: headerParamsSchema\n ? {\n name: resolveName(transformers.pascalCase(`${operationId} HeaderParams`)),\n operation,\n operationName,\n schema: headerParamsSchema,\n keys: resolveKeys(headerParamsSchema),\n }\n : undefined,\n request: requestSchema\n ? {\n name: resolveName(transformers.pascalCase(`${operationId} ${method === 'get' ? 'queryRequest' : 'mutationRequest'}`)),\n description: (operation.schema.requestBody as OasTypes.RequestBodyObject)?.description,\n operation,\n operationName,\n schema: requestSchema,\n keys: resolveKeys(requestSchema),\n keysToOmit: resolveKeys(requestSchema)?.filter((key) => (requestSchema.properties?.[key] as OasTypes.SchemaObject)?.readOnly),\n }\n : undefined,\n response: {\n name: resolveName(transformers.pascalCase(`${operationId} ${method === 'get' ? 'queryResponse' : 'mutationResponse'}`)),\n operation,\n operationName,\n schema: {\n oneOf: successful.map((item) => ({ ...item.schema, $ref: item.name })) || undefined,\n } as SchemaObject,\n },\n responses: successful,\n errors,\n statusCodes,\n }\n }\n\n async getOperations(): Promise<Array<{ path: string; method: HttpMethod; operation: Operation }>> {\n const { oas } = this.context\n\n const paths = oas.getPaths()\n\n return Object.entries(paths).flatMap(([path, methods]) =>\n Object.entries(methods)\n .map((values) => {\n const [method, operation] = values as [HttpMethod, Operation]\n if (this.#isExcluded(operation, method)) {\n return null\n }\n\n if (this.context.include && !this.#isIncluded(operation, method)) {\n return null\n }\n\n return operation ? { path, method: method as HttpMethod, operation } : null\n })\n .filter(Boolean),\n )\n }\n\n async build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<KubbFile.File<TFileMeta>>> {\n const operations = await this.getOperations()\n\n const generatorLimit = pLimit(1)\n const operationLimit = pLimit(10)\n\n const writeTasks = generators.map((generator) =>\n generatorLimit(async () => {\n const operationTasks = operations.map(({ operation, method }) =>\n operationLimit(async () => {\n const options = this.#getOptions(operation, method)\n\n if (generator.type === 'react') {\n await buildOperation(operation, {\n config: this.context.pluginManager.config,\n fabric: this.context.fabric,\n Component: generator.Operation,\n generator: this,\n plugin: {\n ...this.context.plugin,\n options: {\n ...this.options,\n ...options,\n },\n },\n })\n\n return []\n }\n\n const result = await generator.operation?.({\n generator: this,\n config: this.context.pluginManager.config,\n operation,\n plugin: {\n ...this.context.plugin,\n options: {\n ...this.options,\n ...options,\n },\n },\n })\n\n return result ?? []\n }),\n )\n\n const operationResults = await Promise.all(operationTasks)\n const opResultsFlat = operationResults.flat()\n\n if (generator.type === 'react') {\n await buildOperations(\n operations.map((op) => op.operation),\n {\n fabric: this.context.fabric,\n config: this.context.pluginManager.config,\n Component: generator.Operations,\n generator: this,\n plugin: this.context.plugin,\n },\n )\n\n return []\n }\n\n const operationsResult = await generator.operations?.({\n generator: this,\n config: this.context.pluginManager.config,\n operations: operations.map((op) => op.operation),\n plugin: this.context.plugin,\n })\n\n return [...opResultsFlat, ...(operationsResult ?? [])] as unknown as KubbFile.File<TFileMeta>\n }),\n )\n\n const nestedResults = await Promise.all(writeTasks)\n\n return nestedResults.flat()\n }\n}\n","import path from 'node:path'\nimport { type Config, createPlugin, type Group, getMode } from '@kubb/core'\nimport type { Logger } from '@kubb/core/logger'\nimport { camelCase } from '@kubb/core/transformers'\nimport type { Oas } from '@kubb/oas'\nimport { jsonGenerator } from './generators'\nimport { OperationGenerator } from './OperationGenerator.ts'\nimport { SchemaGenerator } from './SchemaGenerator.ts'\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 = {\n path: 'schemas',\n },\n group,\n validate = true,\n generators = [jsonGenerator],\n serverIndex,\n contentType,\n oasClass,\n discriminator = 'strict',\n } = options\n let oas: Oas\n\n const getOas = async ({ config, logger }: { config: Config; logger: Logger }): Promise<Oas> => {\n // needs to be in a different variable or the catch here will not work(return of a promise instead)\n oas = await parseFromConfig(config, oasClass)\n\n oas.setOptions({\n contentType,\n discriminator,\n })\n\n try {\n if (validate) {\n await oas.valdiate()\n }\n } catch (e) {\n const error = e as Error\n\n logger.emit('warning', error?.message)\n }\n\n return oas\n }\n\n return {\n name: pluginOasName,\n options: {\n output,\n validate,\n discriminator,\n ...options,\n },\n context() {\n const { config, logger } = this\n\n return {\n getOas() {\n return getOas({ config, logger })\n },\n async getBaseURL() {\n const oasInstance = await this.getOas()\n if (serverIndex) {\n return oasInstance.api.servers?.at(serverIndex)?.url\n }\n\n return undefined\n },\n }\n },\n resolvePath(baseName, pathMode, options) {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = pathMode ?? 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 if (group && (options?.group?.path || options?.group?.tag)) {\n const groupName: Group['name'] = group?.name\n ? group.name\n : (ctx) => {\n if (group?.type === 'path') {\n return `${ctx.group.split('/')[1]}`\n }\n return `${camelCase(ctx.group)}Controller`\n }\n\n return path.resolve(\n root,\n output.path,\n groupName({\n group: group.type === 'path' ? options.group.path! : options.group.tag!,\n }),\n baseName,\n )\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 emptySchemaType: 'unknown',\n dateType: 'date',\n transformers: {},\n ...this.plugin.options,\n },\n {\n fabric: this.fabric,\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 fabric: this.fabric,\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"],"mappings":";;;;;;;;;;;AA4BA,IAAa,qBAAb,cAGU,cAA6G;CACrH,YAAY,WAAsB,QAAgE;EAChG,MAAM,EAAE,WAAW,EAAE,KAAK,KAAK;EAC/B,MAAM,cAAc,UAAU,eAAe,EAAE,cAAc,MAAM,CAAC;EACpE,MAAM,cAAc,UAAU,gBAAgB;AAE9C,SACE,SAAS,M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
package/dist/mocks.d.ts
CHANGED
package/dist/mocks.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parseFromConfig-BkUoWC2U.js","names":[],"sources":["../src/utils/parseFromConfig.ts"],"sourcesContent":["import { resolve } from 'node:path'\nimport type { Config } from '@kubb/core'\nimport { URLPath } from '@kubb/core/utils'\nimport { merge, Oas, type OasTypes, parse } from '@kubb/oas'\nimport yaml from '@stoplight/yaml'\n\nexport function parseFromConfig(config: Config, oasClass: typeof Oas = Oas): Promise<Oas> {\n if ('data' in config.input) {\n if (typeof config.input.data === 'object') {\n const api: OasTypes.OASDocument = JSON.parse(JSON.stringify(config.input.data)) as OasTypes.OASDocument\n return parse(api, { oasClass })\n }\n\n try {\n const api: string = yaml.parse(config.input.data as string) as string\n\n return parse(api, { oasClass })\n } catch (_e) {\n /* empty */\n }\n\n const api: OasTypes.OASDocument = JSON.parse(JSON.stringify(config.input.data)) as OasTypes.OASDocument\n\n return parse(api, { oasClass })\n }\n\n if (Array.isArray(config.input)) {\n return merge(\n config.input.map((input) => input.path),\n { oasClass },\n )\n }\n\n if (new URLPath(config.input.path).isURL) {\n return parse(config.input.path, { oasClass })\n }\n\n return parse(resolve(config.root, config.input.path), { oasClass })\n}\n"],"mappings":";;;;;;AAMA,SAAgB,gBAAgB,QAAgB,WAAuB,KAAmB;AACxF,KAAI,UAAU,OAAO,OAAO;AAC1B,MAAI,OAAO,OAAO,MAAM,SAAS,SAE/B,QAAO,MAD2B,KAAK,MAAM,KAAK,UAAU,OAAO,MAAM,KAAK,CAAC,EAC7D,EAAE,UAAU,CAAC;AAGjC,MAAI;AAGF,UAAO,MAFa,KAAK,MAAM,OAAO,MAAM,KAAe,EAEzC,EAAE,UAAU,CAAC;WACxB,IAAI;AAMb,SAAO,MAF2B,KAAK,MAAM,KAAK,UAAU,OAAO,MAAM,KAAK,CAAC,EAE7D,EAAE,UAAU,CAAC;;AAGjC,KAAI,MAAM,QAAQ,OAAO,MAAM,CAC7B,QAAO,MACL,OAAO,MAAM,KAAK,UAAU,MAAM,KAAK,EACvC,EAAE,UAAU,CACb;AAGH,KAAI,IAAI,QAAQ,OAAO,MAAM,KAAK,CAAC,MACjC,QAAO,MAAM,OAAO,MAAM,MAAM,EAAE,UAAU,CAAC;AAG/C,QAAO,MAAM,QAAQ,OAAO,MAAM,OAAO,MAAM,KAAK,EAAE,EAAE,UAAU,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parseFromConfig-EjsCZ0-8.cjs","names":["Oas","yaml","URLPath"],"sources":["../src/utils/parseFromConfig.ts"],"sourcesContent":["import { resolve } from 'node:path'\nimport type { Config } from '@kubb/core'\nimport { URLPath } from '@kubb/core/utils'\nimport { merge, Oas, type OasTypes, parse } from '@kubb/oas'\nimport yaml from '@stoplight/yaml'\n\nexport function parseFromConfig(config: Config, oasClass: typeof Oas = Oas): Promise<Oas> {\n if ('data' in config.input) {\n if (typeof config.input.data === 'object') {\n const api: OasTypes.OASDocument = JSON.parse(JSON.stringify(config.input.data)) as OasTypes.OASDocument\n return parse(api, { oasClass })\n }\n\n try {\n const api: string = yaml.parse(config.input.data as string) as string\n\n return parse(api, { oasClass })\n } catch (_e) {\n /* empty */\n }\n\n const api: OasTypes.OASDocument = JSON.parse(JSON.stringify(config.input.data)) as OasTypes.OASDocument\n\n return parse(api, { oasClass })\n }\n\n if (Array.isArray(config.input)) {\n return merge(\n config.input.map((input) => input.path),\n { oasClass },\n )\n }\n\n if (new URLPath(config.input.path).isURL) {\n return parse(config.input.path, { oasClass })\n }\n\n return parse(resolve(config.root, config.input.path), { oasClass })\n}\n"],"mappings":";;;;;;;;;;;AAMA,SAAgB,gBAAgB,QAAgB,WAAuBA,gBAAmB;AACxF,KAAI,UAAU,OAAO,OAAO;AAC1B,MAAI,OAAO,OAAO,MAAM,SAAS,SAE/B,8BADkC,KAAK,MAAM,KAAK,UAAU,OAAO,MAAM,KAAK,CAAC,EAC7D,EAAE,UAAU,CAAC;AAGjC,MAAI;AAGF,gCAFoBC,yBAAK,MAAM,OAAO,MAAM,KAAe,EAEzC,EAAE,UAAU,CAAC;WACxB,IAAI;AAMb,+BAFkC,KAAK,MAAM,KAAK,UAAU,OAAO,MAAM,KAAK,CAAC,EAE7D,EAAE,UAAU,CAAC;;AAGjC,KAAI,MAAM,QAAQ,OAAO,MAAM,CAC7B,8BACE,OAAO,MAAM,KAAK,UAAU,MAAM,KAAK,EACvC,EAAE,UAAU,CACb;AAGH,KAAI,IAAIC,0BAAQ,OAAO,MAAM,KAAK,CAAC,MACjC,8BAAa,OAAO,MAAM,MAAM,EAAE,UAAU,CAAC;AAG/C,qDAAqB,OAAO,MAAM,OAAO,MAAM,KAAK,EAAE,EAAE,UAAU,CAAC"}
|
package/dist/utils.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const require_chunk = require('./chunk-CUT6urMc.cjs');
|
|
2
|
-
const require_getFooter = require('./getFooter-
|
|
3
|
-
const require_getSchemas = require('./getSchemas-
|
|
4
|
-
const require_parseFromConfig = require('./parseFromConfig-
|
|
2
|
+
const require_getFooter = require('./getFooter-DPh4lxBH.cjs');
|
|
3
|
+
const require_getSchemas = require('./getSchemas-Cl0TZ4XY.cjs');
|
|
4
|
+
const require_parseFromConfig = require('./parseFromConfig-EjsCZ0-8.cjs');
|
|
5
5
|
let __kubb_core_transformers = require("@kubb/core/transformers");
|
|
6
6
|
__kubb_core_transformers = require_chunk.__toESM(__kubb_core_transformers);
|
|
7
7
|
let __kubb_core_utils = require("@kubb/core/utils");
|
package/dist/utils.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.cjs","names":["URLPath","transformers","data: FunctionParamsAST"],"sources":["../src/utils/getComments.ts","../src/utils/getParams.ts"],"sourcesContent":["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 {
|
|
1
|
+
{"version":3,"file":"utils.cjs","names":["URLPath","transformers","data: FunctionParamsAST"],"sources":["../src/utils/getComments.ts","../src/utils/getParams.ts"],"sourcesContent":["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 { camelCase, isValidVarName } from '@kubb/core/transformers'\nimport type { FunctionParamsAST } from '@kubb/core/utils'\nimport type { OasTypes } from '@kubb/oas'\nimport { isParameterObject } from '@kubb/oas'\nimport type { Params } from '@kubb/react-fabric/types'\nimport type { OperationSchema } from '../types.ts'\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 casing?: 'camelcase'\n override?: (data: FunctionParamsAST) => FunctionParamsAST\n } = {},\n) {\n return getASTParams(operationSchema, options).reduce((acc, curr) => {\n if (curr.name && curr.enabled) {\n let name = isValidVarName(curr.name) ? curr.name : camelCase(curr.name)\n\n if (options.casing === 'camelcase') {\n name = camelCase(name)\n }\n\n acc[name] = {\n default: curr.default,\n type: curr.type,\n optional: !curr.required,\n }\n }\n\n return acc\n }, {} as Params)\n}\n"],"mappings":";;;;;;;;;;;;AAKA,SAAgB,YAAY,WAAgC;AAC1D,QAAO;EACL,UAAU,gBAAgB,IAAI,gBAAgB,UAAU,gBAAgB;EACxE,UAAU,YAAY,IAAI,YAAY,UAAU,YAAY;EAC5D,UAAU,QAAQ,UAAU,IAAIA,0BAAQ,UAAU,KAAK,CAAC,IAAI;EAC5D,UAAU,cAAc,IAAI;EAC7B,CACE,OAAO,QAAQ,CACf,KAAK,SAASC,iCAAa,KAAK,KAAK,CAAC;;;;;;;;;;ACF3C,SAAgB,aACd,iBACA,EACE,QAAQ,OACR,aAIE,EAAE,EACe;AACrB,KAAI,CAAC,mBAAmB,CAAC,gBAAgB,OAAO,cAAc,CAAC,gBAAgB,KAC7E,QAAO,EAAE;AAGX,QAAO,OAAO,QAAQ,gBAAgB,OAAO,WAAW,CAAC,KAAK,CAAC,MAAM,YAA6C;EAChH,MAAM,4CAA4B,OAAO;EACzC,MAAMC,OAA0B;GAC9B;GACA,SAAS,CAAC,CAAC;GACX,UAAU,UAAU,OAAO,WAAW;GACtC,MAAM,QAAQ,GAAG,gBAAgB,KAAK,IAAI,KAAK,MAAM;GACtD;AAED,SAAO,WAAW,SAAS,KAAK,GAAG;GACnC;;AAGJ,SAAgB,cACd,iBACA,UAII,EAAE,EACN;AACA,QAAO,aAAa,iBAAiB,QAAQ,CAAC,QAAQ,KAAK,SAAS;AAClE,MAAI,KAAK,QAAQ,KAAK,SAAS;GAC7B,IAAI,oDAAsB,KAAK,KAAK,GAAG,KAAK,+CAAiB,KAAK,KAAK;AAEvE,OAAI,QAAQ,WAAW,YACrB,gDAAiB,KAAK;AAGxB,OAAI,QAAQ;IACV,SAAS,KAAK;IACd,MAAM,KAAK;IACX,UAAU,CAAC,KAAK;IACjB;;AAGH,SAAO;IACN,EAAE,CAAW"}
|
package/dist/utils.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "./SchemaMapper-
|
|
1
|
+
import { D as Config, O as Output, T as Oas, g as OperationSchema } from "./createGenerator-CPNglV1d.cjs";
|
|
2
|
+
import { d as OpenAPIV3$1, f as OpenAPIV3_1, h as contentType, m as SchemaObject$1, p as Operation, u as OasTypes } from "./SchemaMapper-CgGWx6jF.cjs";
|
|
3
3
|
import { OASDocument, SchemaObject } from "oas/types";
|
|
4
4
|
import { OpenAPIV3 } from "openapi-types";
|
|
5
5
|
import { Params } from "@kubb/react-fabric/types";
|
|
@@ -8,9 +8,31 @@ import { Params } from "@kubb/react-fabric/types";
|
|
|
8
8
|
|
|
9
9
|
declare function isOptional(schema?: SchemaObject): boolean;
|
|
10
10
|
//#endregion
|
|
11
|
+
//#region src/utils/getBanner.d.ts
|
|
12
|
+
type Props$1<TOas extends Oas> = {
|
|
13
|
+
oas: TOas;
|
|
14
|
+
output: Output<any>;
|
|
15
|
+
config?: Config;
|
|
16
|
+
};
|
|
17
|
+
declare function getBanner<TOas extends Oas>({
|
|
18
|
+
output,
|
|
19
|
+
oas,
|
|
20
|
+
config
|
|
21
|
+
}: Props$1<TOas>): string;
|
|
22
|
+
//#endregion
|
|
11
23
|
//#region src/utils/getComments.d.ts
|
|
12
24
|
declare function getComments(operation: Operation): string[];
|
|
13
25
|
//#endregion
|
|
26
|
+
//#region src/utils/getFooter.d.ts
|
|
27
|
+
type Props<TOas extends Oas> = {
|
|
28
|
+
oas: TOas;
|
|
29
|
+
output: Output<any>;
|
|
30
|
+
};
|
|
31
|
+
declare function getFooter<TOas extends Oas>({
|
|
32
|
+
output,
|
|
33
|
+
oas
|
|
34
|
+
}: Props<TOas>): string | undefined;
|
|
35
|
+
//#endregion
|
|
14
36
|
//#region ../core/src/utils/FunctionParams.d.ts
|
|
15
37
|
type FunctionParamsASTWithoutType = {
|
|
16
38
|
name?: string;
|
|
@@ -83,6 +105,10 @@ type GetSchemasProps = {
|
|
|
83
105
|
contentType?: contentType;
|
|
84
106
|
includes?: Mode[];
|
|
85
107
|
};
|
|
108
|
+
/**
|
|
109
|
+
* Collect schemas from OpenAPI components (schemas, responses, requestBodies)
|
|
110
|
+
* and return them in dependency order.
|
|
111
|
+
*/
|
|
86
112
|
declare function getSchemas({
|
|
87
113
|
oas,
|
|
88
114
|
contentType,
|
|
@@ -92,27 +118,5 @@ declare function getSchemas({
|
|
|
92
118
|
//#region src/utils/parseFromConfig.d.ts
|
|
93
119
|
declare function parseFromConfig(config: Config, oasClass?: typeof Oas): Promise<Oas>;
|
|
94
120
|
//#endregion
|
|
95
|
-
//#region src/utils/getBanner.d.ts
|
|
96
|
-
type Props$1<TOas extends Oas> = {
|
|
97
|
-
oas: TOas;
|
|
98
|
-
output: Output<any>;
|
|
99
|
-
config?: Config;
|
|
100
|
-
};
|
|
101
|
-
declare function getBanner<TOas extends Oas>({
|
|
102
|
-
output,
|
|
103
|
-
oas,
|
|
104
|
-
config
|
|
105
|
-
}: Props$1<TOas>): string;
|
|
106
|
-
//#endregion
|
|
107
|
-
//#region src/utils/getFooter.d.ts
|
|
108
|
-
type Props<TOas extends Oas> = {
|
|
109
|
-
oas: TOas;
|
|
110
|
-
output: Output<any>;
|
|
111
|
-
};
|
|
112
|
-
declare function getFooter<TOas extends Oas>({
|
|
113
|
-
output,
|
|
114
|
-
oas
|
|
115
|
-
}: Props<TOas>): string | undefined;
|
|
116
|
-
//#endregion
|
|
117
121
|
export { getBanner, getComments, getFooter, getPathParams, getSchemaFactory, getSchemas, isOptional, parseFromConfig };
|
|
118
122
|
//# sourceMappingURL=utils.d.cts.map
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "./SchemaMapper-
|
|
1
|
+
import { D as Config, O as Output, T as Oas, g as OperationSchema } from "./createGenerator-BvCDyuKS.js";
|
|
2
|
+
import { d as OpenAPIV3$1, f as OpenAPIV3_1, h as contentType, m as SchemaObject$1, p as Operation, u as OasTypes } from "./SchemaMapper-Cj3vjPGs.js";
|
|
3
3
|
import { OASDocument, SchemaObject } from "oas/types";
|
|
4
4
|
import { OpenAPIV3 } from "openapi-types";
|
|
5
5
|
import { Params } from "@kubb/react-fabric/types";
|
|
@@ -8,9 +8,31 @@ import { Params } from "@kubb/react-fabric/types";
|
|
|
8
8
|
|
|
9
9
|
declare function isOptional(schema?: SchemaObject): boolean;
|
|
10
10
|
//#endregion
|
|
11
|
+
//#region src/utils/getBanner.d.ts
|
|
12
|
+
type Props$1<TOas extends Oas> = {
|
|
13
|
+
oas: TOas;
|
|
14
|
+
output: Output<any>;
|
|
15
|
+
config?: Config;
|
|
16
|
+
};
|
|
17
|
+
declare function getBanner<TOas extends Oas>({
|
|
18
|
+
output,
|
|
19
|
+
oas,
|
|
20
|
+
config
|
|
21
|
+
}: Props$1<TOas>): string;
|
|
22
|
+
//#endregion
|
|
11
23
|
//#region src/utils/getComments.d.ts
|
|
12
24
|
declare function getComments(operation: Operation): string[];
|
|
13
25
|
//#endregion
|
|
26
|
+
//#region src/utils/getFooter.d.ts
|
|
27
|
+
type Props<TOas extends Oas> = {
|
|
28
|
+
oas: TOas;
|
|
29
|
+
output: Output<any>;
|
|
30
|
+
};
|
|
31
|
+
declare function getFooter<TOas extends Oas>({
|
|
32
|
+
output,
|
|
33
|
+
oas
|
|
34
|
+
}: Props<TOas>): string | undefined;
|
|
35
|
+
//#endregion
|
|
14
36
|
//#region ../core/src/utils/FunctionParams.d.ts
|
|
15
37
|
type FunctionParamsASTWithoutType = {
|
|
16
38
|
name?: string;
|
|
@@ -83,6 +105,10 @@ type GetSchemasProps = {
|
|
|
83
105
|
contentType?: contentType;
|
|
84
106
|
includes?: Mode[];
|
|
85
107
|
};
|
|
108
|
+
/**
|
|
109
|
+
* Collect schemas from OpenAPI components (schemas, responses, requestBodies)
|
|
110
|
+
* and return them in dependency order.
|
|
111
|
+
*/
|
|
86
112
|
declare function getSchemas({
|
|
87
113
|
oas,
|
|
88
114
|
contentType,
|
|
@@ -92,27 +118,5 @@ declare function getSchemas({
|
|
|
92
118
|
//#region src/utils/parseFromConfig.d.ts
|
|
93
119
|
declare function parseFromConfig(config: Config, oasClass?: typeof Oas): Promise<Oas>;
|
|
94
120
|
//#endregion
|
|
95
|
-
//#region src/utils/getBanner.d.ts
|
|
96
|
-
type Props$1<TOas extends Oas> = {
|
|
97
|
-
oas: TOas;
|
|
98
|
-
output: Output<any>;
|
|
99
|
-
config?: Config;
|
|
100
|
-
};
|
|
101
|
-
declare function getBanner<TOas extends Oas>({
|
|
102
|
-
output,
|
|
103
|
-
oas,
|
|
104
|
-
config
|
|
105
|
-
}: Props$1<TOas>): string;
|
|
106
|
-
//#endregion
|
|
107
|
-
//#region src/utils/getFooter.d.ts
|
|
108
|
-
type Props<TOas extends Oas> = {
|
|
109
|
-
oas: TOas;
|
|
110
|
-
output: Output<any>;
|
|
111
|
-
};
|
|
112
|
-
declare function getFooter<TOas extends Oas>({
|
|
113
|
-
output,
|
|
114
|
-
oas
|
|
115
|
-
}: Props<TOas>): string | undefined;
|
|
116
|
-
//#endregion
|
|
117
121
|
export { getBanner, getComments, getFooter, getPathParams, getSchemaFactory, getSchemas, isOptional, parseFromConfig };
|
|
118
122
|
//# sourceMappingURL=utils.d.ts.map
|
package/dist/utils.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { n as getBanner, t as getFooter } from "./getFooter-
|
|
2
|
-
import { n as getSchemaFactory, t as getSchemas } from "./getSchemas-
|
|
3
|
-
import { t as parseFromConfig } from "./parseFromConfig-
|
|
1
|
+
import { n as getBanner, t as getFooter } from "./getFooter-CV73pVXj.js";
|
|
2
|
+
import { n as getSchemaFactory, t as getSchemas } from "./getSchemas-32BHoMO-.js";
|
|
3
|
+
import { t as parseFromConfig } from "./parseFromConfig-BkUoWC2U.js";
|
|
4
4
|
import transformers, { camelCase, isValidVarName } from "@kubb/core/transformers";
|
|
5
5
|
import { URLPath } from "@kubb/core/utils";
|
|
6
6
|
import { isOptional, isParameterObject } from "@kubb/oas";
|
package/dist/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","names":["data: FunctionParamsAST"],"sources":["../src/utils/getComments.ts","../src/utils/getParams.ts"],"sourcesContent":["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 {
|
|
1
|
+
{"version":3,"file":"utils.js","names":["data: FunctionParamsAST"],"sources":["../src/utils/getComments.ts","../src/utils/getParams.ts"],"sourcesContent":["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 { camelCase, isValidVarName } from '@kubb/core/transformers'\nimport type { FunctionParamsAST } from '@kubb/core/utils'\nimport type { OasTypes } from '@kubb/oas'\nimport { isParameterObject } from '@kubb/oas'\nimport type { Params } from '@kubb/react-fabric/types'\nimport type { OperationSchema } from '../types.ts'\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 casing?: 'camelcase'\n override?: (data: FunctionParamsAST) => FunctionParamsAST\n } = {},\n) {\n return getASTParams(operationSchema, options).reduce((acc, curr) => {\n if (curr.name && curr.enabled) {\n let name = isValidVarName(curr.name) ? curr.name : camelCase(curr.name)\n\n if (options.casing === 'camelcase') {\n name = camelCase(name)\n }\n\n acc[name] = {\n default: curr.default,\n type: curr.type,\n optional: !curr.required,\n }\n }\n\n return acc\n }, {} as Params)\n}\n"],"mappings":";;;;;;;;AAKA,SAAgB,YAAY,WAAgC;AAC1D,QAAO;EACL,UAAU,gBAAgB,IAAI,gBAAgB,UAAU,gBAAgB;EACxE,UAAU,YAAY,IAAI,YAAY,UAAU,YAAY;EAC5D,UAAU,QAAQ,UAAU,IAAI,QAAQ,UAAU,KAAK,CAAC,IAAI;EAC5D,UAAU,cAAc,IAAI;EAC7B,CACE,OAAO,QAAQ,CACf,KAAK,SAAS,aAAa,KAAK,KAAK,CAAC;;;;;;;;;;ACF3C,SAAgB,aACd,iBACA,EACE,QAAQ,OACR,aAIE,EAAE,EACe;AACrB,KAAI,CAAC,mBAAmB,CAAC,gBAAgB,OAAO,cAAc,CAAC,gBAAgB,KAC7E,QAAO,EAAE;AAGX,QAAO,OAAO,QAAQ,gBAAgB,OAAO,WAAW,CAAC,KAAK,CAAC,MAAM,YAA6C;EAChH,MAAM,UAAU,kBAAkB,OAAO;EACzC,MAAMA,OAA0B;GAC9B;GACA,SAAS,CAAC,CAAC;GACX,UAAU,UAAU,OAAO,WAAW;GACtC,MAAM,QAAQ,GAAG,gBAAgB,KAAK,IAAI,KAAK,MAAM;GACtD;AAED,SAAO,WAAW,SAAS,KAAK,GAAG;GACnC;;AAGJ,SAAgB,cACd,iBACA,UAII,EAAE,EACN;AACA,QAAO,aAAa,iBAAiB,QAAQ,CAAC,QAAQ,KAAK,SAAS;AAClE,MAAI,KAAK,QAAQ,KAAK,SAAS;GAC7B,IAAI,OAAO,eAAe,KAAK,KAAK,GAAG,KAAK,OAAO,UAAU,KAAK,KAAK;AAEvE,OAAI,QAAQ,WAAW,YACrB,QAAO,UAAU,KAAK;AAGxB,OAAI,QAAQ;IACV,SAAS,KAAK;IACd,MAAM,KAAK;IACX,UAAU,CAAC,KAAK;IACjB;;AAGH,SAAO;IACN,EAAE,CAAW"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/plugin-oas",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.5.0",
|
|
4
4
|
"description": "OpenAPI Specification (OAS) plugin for Kubb, providing core functionality for parsing and processing OpenAPI/Swagger schemas for code generation.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"openapi",
|
|
@@ -28,10 +28,6 @@
|
|
|
28
28
|
"import": "./dist/index.js",
|
|
29
29
|
"require": "./dist/index.cjs"
|
|
30
30
|
},
|
|
31
|
-
"./components": {
|
|
32
|
-
"import": "./dist/components.js",
|
|
33
|
-
"require": "./dist/components.cjs"
|
|
34
|
-
},
|
|
35
31
|
"./generators": {
|
|
36
32
|
"import": "./dist/generators.js",
|
|
37
33
|
"require": "./dist/generators.cjs"
|
|
@@ -61,9 +57,6 @@
|
|
|
61
57
|
"hooks": [
|
|
62
58
|
"./dist/hooks.d.ts"
|
|
63
59
|
],
|
|
64
|
-
"components": [
|
|
65
|
-
"./dist/components.d.ts"
|
|
66
|
-
],
|
|
67
60
|
"mocks": [
|
|
68
61
|
"./dist/mocks.d.ts"
|
|
69
62
|
],
|
|
@@ -78,20 +71,24 @@
|
|
|
78
71
|
"!/**/**.test.**",
|
|
79
72
|
"!/**/__tests__/**"
|
|
80
73
|
],
|
|
74
|
+
"size-limit": [
|
|
75
|
+
{
|
|
76
|
+
"path": "./dist/*.js",
|
|
77
|
+
"limit": "510 KiB",
|
|
78
|
+
"gzip": true
|
|
79
|
+
}
|
|
80
|
+
],
|
|
81
81
|
"dependencies": {
|
|
82
|
-
"@kubb/react-fabric": "0.2.
|
|
82
|
+
"@kubb/react-fabric": "0.2.14",
|
|
83
83
|
"@stoplight/yaml": "^4.3.0",
|
|
84
84
|
"p-limit": "^7.2.0",
|
|
85
85
|
"remeda": "^2.32.0",
|
|
86
|
-
"@kubb/core": "4.
|
|
87
|
-
"@kubb/oas": "4.
|
|
88
|
-
},
|
|
89
|
-
"devDependencies": {
|
|
90
|
-
"tsdown": "^0.15.11",
|
|
91
|
-
"typescript": "^5.9.3"
|
|
86
|
+
"@kubb/core": "4.5.0",
|
|
87
|
+
"@kubb/oas": "4.5.0"
|
|
92
88
|
},
|
|
89
|
+
"devDependencies": {},
|
|
93
90
|
"peerDependencies": {
|
|
94
|
-
"@kubb/react-fabric": "0.2.
|
|
91
|
+
"@kubb/react-fabric": "0.2.14"
|
|
95
92
|
},
|
|
96
93
|
"engines": {
|
|
97
94
|
"node": ">=20"
|
|
@@ -101,7 +98,7 @@
|
|
|
101
98
|
"registry": "https://registry.npmjs.org/"
|
|
102
99
|
},
|
|
103
100
|
"scripts": {
|
|
104
|
-
"build": "tsdown",
|
|
101
|
+
"build": "tsdown && size-limit",
|
|
105
102
|
"clean": "npx rimraf ./dist",
|
|
106
103
|
"lint": "bun biome lint .",
|
|
107
104
|
"lint:fix": "bun biome lint --fix --unsafe .",
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import type { Plugin, PluginFactoryOptions, PluginManager } from '@kubb/core'
|
|
2
2
|
import { BaseGenerator, type FileMetaBase } from '@kubb/core'
|
|
3
|
-
import type { KubbFile } from '@kubb/core/fs'
|
|
4
3
|
import transformers from '@kubb/core/transformers'
|
|
4
|
+
import type { KubbFile } from '@kubb/fabric-core/types'
|
|
5
5
|
import type { contentType, HttpMethod, Oas, OasTypes, Operation, SchemaObject } from '@kubb/oas'
|
|
6
6
|
import type { Fabric } from '@kubb/react-fabric'
|
|
7
7
|
import pLimit from 'p-limit'
|
|
8
8
|
import type { Generator } from './generators/types.ts'
|
|
9
|
-
import { buildOperation, buildOperations } from './generators/utils.tsx'
|
|
10
9
|
import type { Exclude, Include, OperationSchemas, Override } from './types.ts'
|
|
10
|
+
import { buildOperation, buildOperations } from './utils.tsx'
|
|
11
11
|
|
|
12
12
|
export type OperationMethodResult<TFileMeta extends FileMetaBase> = Promise<KubbFile.File<TFileMeta> | Array<KubbFile.File<TFileMeta>> | null>
|
|
13
13
|
|
|
@@ -229,12 +229,16 @@ export class OperationGenerator<
|
|
|
229
229
|
|
|
230
230
|
if (generator.type === 'react') {
|
|
231
231
|
await buildOperation(operation, {
|
|
232
|
+
config: this.context.pluginManager.config,
|
|
232
233
|
fabric: this.context.fabric,
|
|
233
|
-
generator,
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
...this.
|
|
237
|
-
|
|
234
|
+
Component: generator.Operation,
|
|
235
|
+
generator: this,
|
|
236
|
+
plugin: {
|
|
237
|
+
...this.context.plugin,
|
|
238
|
+
options: {
|
|
239
|
+
...this.options,
|
|
240
|
+
...options,
|
|
241
|
+
},
|
|
238
242
|
},
|
|
239
243
|
})
|
|
240
244
|
|
|
@@ -242,9 +246,16 @@ export class OperationGenerator<
|
|
|
242
246
|
}
|
|
243
247
|
|
|
244
248
|
const result = await generator.operation?.({
|
|
245
|
-
|
|
249
|
+
generator: this,
|
|
250
|
+
config: this.context.pluginManager.config,
|
|
246
251
|
operation,
|
|
247
|
-
|
|
252
|
+
plugin: {
|
|
253
|
+
...this.context.plugin,
|
|
254
|
+
options: {
|
|
255
|
+
...this.options,
|
|
256
|
+
...options,
|
|
257
|
+
},
|
|
258
|
+
},
|
|
248
259
|
})
|
|
249
260
|
|
|
250
261
|
return result ?? []
|
|
@@ -259,9 +270,10 @@ export class OperationGenerator<
|
|
|
259
270
|
operations.map((op) => op.operation),
|
|
260
271
|
{
|
|
261
272
|
fabric: this.context.fabric,
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
273
|
+
config: this.context.pluginManager.config,
|
|
274
|
+
Component: generator.Operations,
|
|
275
|
+
generator: this,
|
|
276
|
+
plugin: this.context.plugin,
|
|
265
277
|
},
|
|
266
278
|
)
|
|
267
279
|
|
|
@@ -269,9 +281,10 @@ export class OperationGenerator<
|
|
|
269
281
|
}
|
|
270
282
|
|
|
271
283
|
const operationsResult = await generator.operations?.({
|
|
272
|
-
|
|
284
|
+
generator: this,
|
|
285
|
+
config: this.context.pluginManager.config,
|
|
273
286
|
operations: operations.map((op) => op.operation),
|
|
274
|
-
|
|
287
|
+
plugin: this.context.plugin,
|
|
275
288
|
})
|
|
276
289
|
|
|
277
290
|
return [...opResultsFlat, ...(operationsResult ?? [])] as unknown as KubbFile.File<TFileMeta>
|