@kubb/plugin-oas 3.15.1 → 3.16.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.
Files changed (37) hide show
  1. package/dist/{OperationGenerator-DyM5QANw.d.ts → OperationGenerator-C7NPZtOM.d.ts} +7 -21
  2. package/dist/{OperationGenerator-LFwakDt7.d.cts → OperationGenerator-DJE2XQ83.d.cts} +7 -21
  3. package/dist/{chunk-2LJ3ZJZP.cjs → chunk-CNSA5TDG.cjs} +34 -42
  4. package/dist/chunk-CNSA5TDG.cjs.map +1 -0
  5. package/dist/{chunk-JSR2ZSPP.js → chunk-ISOHAFCA.js} +33 -42
  6. package/dist/chunk-ISOHAFCA.js.map +1 -0
  7. package/dist/{chunk-S7ZYTJXL.js → chunk-MBX66JAT.js} +5 -5
  8. package/dist/chunk-MBX66JAT.js.map +1 -0
  9. package/dist/{chunk-S3UPJP7I.cjs → chunk-QJMOOF2A.cjs} +5 -5
  10. package/dist/chunk-QJMOOF2A.cjs.map +1 -0
  11. package/dist/components.d.cts +1 -1
  12. package/dist/components.d.ts +1 -1
  13. package/dist/generators.cjs +2 -2
  14. package/dist/generators.d.cts +1 -1
  15. package/dist/generators.d.ts +1 -1
  16. package/dist/generators.js +1 -1
  17. package/dist/hooks.cjs +2 -2
  18. package/dist/hooks.d.cts +1 -1
  19. package/dist/hooks.d.ts +1 -1
  20. package/dist/hooks.js +1 -1
  21. package/dist/index.cjs +126 -191
  22. package/dist/index.cjs.map +1 -1
  23. package/dist/index.d.cts +2 -2
  24. package/dist/index.d.ts +2 -2
  25. package/dist/index.js +122 -188
  26. package/dist/index.js.map +1 -1
  27. package/dist/utils.d.cts +1 -1
  28. package/dist/utils.d.ts +1 -1
  29. package/package.json +8 -7
  30. package/src/OperationGenerator.ts +126 -223
  31. package/src/SchemaGenerator.ts +31 -45
  32. package/src/generator.tsx +4 -12
  33. package/src/types.ts +0 -1
  34. package/dist/chunk-2LJ3ZJZP.cjs.map +0 -1
  35. package/dist/chunk-JSR2ZSPP.js.map +0 -1
  36. package/dist/chunk-S3UPJP7I.cjs.map +0 -1
  37. package/dist/chunk-S7ZYTJXL.js.map +0 -1
package/dist/index.js CHANGED
@@ -1,264 +1,198 @@
1
1
  import { parseFromConfig } from './chunk-G3FDK7YW.js';
2
- import { jsonGenerator } from './chunk-S7ZYTJXL.js';
3
- export { createGenerator, createReactGenerator } from './chunk-S7ZYTJXL.js';
2
+ import { jsonGenerator } from './chunk-MBX66JAT.js';
3
+ export { createGenerator, createReactGenerator } from './chunk-MBX66JAT.js';
4
4
  import './chunk-6S7YFY6F.js';
5
- import { SchemaGenerator } from './chunk-JSR2ZSPP.js';
6
- export { SchemaGenerator } from './chunk-JSR2ZSPP.js';
5
+ import { SchemaGenerator } from './chunk-ISOHAFCA.js';
6
+ export { SchemaGenerator } from './chunk-ISOHAFCA.js';
7
7
  export { isKeyword, schemaKeywords } from './chunk-76E35IZ2.js';
8
8
  import './chunk-PORSNYI5.js';
9
9
  import './chunk-JNN4JPWK.js';
10
10
  import { createPlugin, FileManager, BaseGenerator } from '@kubb/core';
11
11
  import transformers, { camelCase } from '@kubb/core/transformers';
12
+ import pLimit from 'p-limit';
12
13
  import path from 'path';
13
14
 
14
15
  var OperationGenerator = class extends BaseGenerator {
15
- #operationsByMethod = {};
16
- get operationsByMethod() {
17
- return this.#operationsByMethod;
18
- }
19
- set operationsByMethod(paths) {
20
- this.#operationsByMethod = paths;
21
- }
22
16
  #getOptions(operation, method) {
23
17
  const { override = [] } = this.context;
18
+ const operationId = operation.getOperationId({ friendlyCase: true });
19
+ const contentType = operation.getContentType();
24
20
  return override.find(({ pattern, type }) => {
25
- if (type === "tag") {
26
- return !!operation.getTags().some((tag) => tag.name.match(pattern));
27
- }
28
- if (type === "operationId") {
29
- return !!operation.getOperationId({ friendlyCase: true }).match(pattern);
30
- }
31
- if (type === "path") {
32
- return !!operation.path.match(pattern);
21
+ switch (type) {
22
+ case "tag":
23
+ return operation.getTags().some((tag) => tag.name.match(pattern));
24
+ case "operationId":
25
+ return !!operationId.match(pattern);
26
+ case "path":
27
+ return !!operation.path.match(pattern);
28
+ case "method":
29
+ return !!method.match(pattern);
30
+ case "contentType":
31
+ return !!contentType.match(pattern);
32
+ default:
33
+ return false;
33
34
  }
34
- if (type === "method") {
35
- return !!method.match(pattern);
36
- }
37
- if (type === "contentType") {
38
- return !!operation.getContentType().match(pattern);
39
- }
40
- return false;
41
35
  })?.options || {};
42
36
  }
43
37
  #isExcluded(operation, method) {
44
38
  const { exclude = [] } = this.context;
45
- let matched = false;
46
- exclude.forEach(({ pattern, type }) => {
47
- if (type === "tag" && !matched) {
48
- matched = !!operation.getTags().some((tag) => tag.name.match(pattern));
49
- }
50
- if (type === "operationId" && !matched) {
51
- matched = !!operation.getOperationId({ friendlyCase: true }).match(pattern);
52
- }
53
- if (type === "path" && !matched) {
54
- matched = !!operation.path.match(pattern);
55
- }
56
- if (type === "method" && !matched) {
57
- matched = !!method.match(pattern);
58
- }
59
- if (type === "contentType" && !matched) {
60
- return !!operation.getContentType().match(pattern);
39
+ const operationId = operation.getOperationId({ friendlyCase: true });
40
+ const contentType = operation.getContentType();
41
+ return exclude.some(({ pattern, type }) => {
42
+ switch (type) {
43
+ case "tag":
44
+ return operation.getTags().some((tag) => tag.name.match(pattern));
45
+ case "operationId":
46
+ return !!operationId.match(pattern);
47
+ case "path":
48
+ return !!operation.path.match(pattern);
49
+ case "method":
50
+ return !!method.match(pattern);
51
+ case "contentType":
52
+ return !!contentType.match(pattern);
53
+ default:
54
+ return false;
61
55
  }
62
56
  });
63
- return matched;
64
57
  }
65
58
  #isIncluded(operation, method) {
66
59
  const { include = [] } = this.context;
67
- let matched = false;
68
- include.forEach(({ pattern, type }) => {
69
- if (type === "tag" && !matched) {
70
- matched = !!operation.getTags().some((tag) => tag.name.match(pattern));
71
- }
72
- if (type === "operationId" && !matched) {
73
- matched = !!operation.getOperationId({ friendlyCase: true }).match(pattern);
74
- }
75
- if (type === "path" && !matched) {
76
- matched = !!operation.path.match(pattern);
77
- }
78
- if (type === "method" && !matched) {
79
- matched = !!method.match(pattern);
80
- }
81
- if (type === "contentType" && !matched) {
82
- matched = !!operation.getContentType().match(pattern);
60
+ const operationId = operation.getOperationId({ friendlyCase: true });
61
+ const contentType = operation.getContentType();
62
+ return include.some(({ pattern, type }) => {
63
+ switch (type) {
64
+ case "tag":
65
+ return operation.getTags().some((tag) => tag.name.match(pattern));
66
+ case "operationId":
67
+ return !!operationId.match(pattern);
68
+ case "path":
69
+ return !!operation.path.match(pattern);
70
+ case "method":
71
+ return !!method.match(pattern);
72
+ case "contentType":
73
+ return !!contentType.match(pattern);
74
+ default:
75
+ return false;
83
76
  }
84
77
  });
85
- return matched;
86
78
  }
87
79
  getSchemas(operation, {
88
80
  resolveName = (name) => name
89
81
  } = {}) {
82
+ const operationId = operation.getOperationId({ friendlyCase: true });
83
+ const method = operation.method;
84
+ const operationName = transformers.pascalCase(operationId);
85
+ const resolveKeys = (schema) => schema?.properties ? Object.keys(schema.properties) : void 0;
90
86
  const pathParamsSchema = this.context.oas.getParametersSchema(operation, "path");
91
87
  const queryParamsSchema = this.context.oas.getParametersSchema(operation, "query");
92
88
  const headerParamsSchema = this.context.oas.getParametersSchema(operation, "header");
93
89
  const requestSchema = this.context.oas.getRequestSchema(operation);
94
90
  const statusCodes = operation.getResponseStatusCodes().map((statusCode) => {
95
- let name = statusCode;
96
- if (name === "default") {
97
- name = "error";
98
- }
91
+ const name = statusCode === "default" ? "error" : statusCode;
99
92
  const schema = this.context.oas.getResponseSchema(operation, statusCode);
93
+ const keys = resolveKeys(schema);
100
94
  return {
101
- name: resolveName(transformers.pascalCase(`${operation.getOperationId({ friendlyCase: true })} ${name}`)),
95
+ name: resolveName(transformers.pascalCase(`${operationId} ${name}`)),
102
96
  description: operation.getResponseByStatusCode(statusCode)?.description,
103
97
  schema,
104
98
  operation,
105
- operationName: transformers.pascalCase(`${operation.getOperationId({ friendlyCase: true })}`),
99
+ operationName,
106
100
  statusCode: name === "error" ? void 0 : Number(statusCode),
107
- keys: schema?.properties ? Object.keys(schema.properties) : void 0,
108
- keysToOmit: schema?.properties ? Object.keys(schema.properties).filter((key) => {
109
- const item = schema.properties?.[key];
110
- return item?.writeOnly;
111
- }) : void 0
101
+ keys,
102
+ keysToOmit: keys?.filter((key) => schema?.properties?.[key]?.writeOnly)
112
103
  };
113
104
  });
114
- const hasResponses = statusCodes.some((item) => item.statusCode?.toString().startsWith("2"));
105
+ const successful = statusCodes.filter((item) => item.statusCode?.toString().startsWith("2"));
106
+ const errors = statusCodes.filter((item) => item.statusCode?.toString().startsWith("4") || item.statusCode?.toString().startsWith("5"));
115
107
  return {
116
108
  pathParams: pathParamsSchema ? {
117
- name: resolveName(transformers.pascalCase(`${operation.getOperationId({ friendlyCase: true })} PathParams`)),
109
+ name: resolveName(transformers.pascalCase(`${operationId} PathParams`)),
118
110
  operation,
119
- operationName: transformers.pascalCase(`${operation.getOperationId({ friendlyCase: true })}`),
111
+ operationName,
120
112
  schema: pathParamsSchema,
121
- keys: pathParamsSchema.properties ? Object.keys(pathParamsSchema.properties) : void 0
113
+ keys: resolveKeys(pathParamsSchema)
122
114
  } : void 0,
123
115
  queryParams: queryParamsSchema ? {
124
- name: resolveName(transformers.pascalCase(`${operation.getOperationId({ friendlyCase: true })} QueryParams`)),
116
+ name: resolveName(transformers.pascalCase(`${operationId} QueryParams`)),
125
117
  operation,
126
- operationName: transformers.pascalCase(`${operation.getOperationId({ friendlyCase: true })}`),
118
+ operationName,
127
119
  schema: queryParamsSchema,
128
- keys: queryParamsSchema.properties ? Object.keys(queryParamsSchema.properties) : []
120
+ keys: resolveKeys(queryParamsSchema) || []
129
121
  } : void 0,
130
122
  headerParams: headerParamsSchema ? {
131
- name: resolveName(transformers.pascalCase(`${operation.getOperationId({ friendlyCase: true })} HeaderParams`)),
123
+ name: resolveName(transformers.pascalCase(`${operationId} HeaderParams`)),
132
124
  operation,
133
- operationName: transformers.pascalCase(`${operation.getOperationId({ friendlyCase: true })}`),
125
+ operationName,
134
126
  schema: headerParamsSchema,
135
- keys: headerParamsSchema.properties ? Object.keys(headerParamsSchema.properties) : void 0
127
+ keys: resolveKeys(headerParamsSchema)
136
128
  } : void 0,
137
129
  request: requestSchema ? {
138
- name: resolveName(
139
- transformers.pascalCase(`${operation.getOperationId({ friendlyCase: true })} ${operation.method === "get" ? "queryRequest" : "mutationRequest"}`)
140
- ),
130
+ name: resolveName(transformers.pascalCase(`${operationId} ${method === "get" ? "queryRequest" : "mutationRequest"}`)),
141
131
  description: operation.schema.requestBody?.description,
142
132
  operation,
143
- operationName: transformers.pascalCase(`${operation.getOperationId({ friendlyCase: true })}`),
133
+ operationName,
144
134
  schema: requestSchema,
145
- keys: requestSchema.properties ? Object.keys(requestSchema.properties) : void 0,
146
- keysToOmit: requestSchema.properties ? Object.keys(requestSchema.properties).filter((key) => {
147
- const item = requestSchema.properties?.[key];
148
- return item?.readOnly;
149
- }) : void 0
135
+ keys: resolveKeys(requestSchema),
136
+ keysToOmit: resolveKeys(requestSchema)?.filter((key) => requestSchema.properties?.[key]?.readOnly)
150
137
  } : void 0,
151
138
  response: {
152
- name: resolveName(
153
- transformers.pascalCase(`${operation.getOperationId({ friendlyCase: true })} ${operation.method === "get" ? "queryResponse" : "mutationResponse"}`)
154
- ),
139
+ name: resolveName(transformers.pascalCase(`${operationId} ${method === "get" ? "queryResponse" : "mutationResponse"}`)),
155
140
  operation,
156
- operationName: transformers.pascalCase(`${operation.getOperationId({ friendlyCase: true })}`),
141
+ operationName,
157
142
  schema: {
158
- oneOf: hasResponses ? statusCodes.filter((item) => item.statusCode?.toString().startsWith("2")).map((item) => {
159
- return {
160
- ...item.schema,
161
- $ref: resolveName(transformers.pascalCase(`${operation.getOperationId({ friendlyCase: true })} ${item.statusCode}`))
162
- };
163
- }) : void 0
143
+ oneOf: successful.map((item) => ({ ...item.schema, $ref: item.name })) || void 0
164
144
  }
165
145
  },
166
- responses: statusCodes.filter((item) => item.statusCode?.toString().startsWith("2")),
167
- errors: statusCodes.filter((item) => item.statusCode?.toString().startsWith("4") || item.statusCode?.toString().startsWith("5")),
146
+ responses: successful,
147
+ errors,
168
148
  statusCodes
169
149
  };
170
150
  }
171
- async build(...generators) {
151
+ async getOperations() {
172
152
  const { oas } = this.context;
173
153
  const paths = oas.getPaths();
174
- this.operationsByMethod = Object.entries(paths).reduce((acc, [path2, method]) => {
175
- const methods = Object.keys(method);
176
- methods.forEach((method2) => {
177
- const operation = oas.operation(path2, method2);
178
- if (operation && method2 === operation.method) {
179
- const isExcluded = this.#isExcluded(operation, method2);
180
- const isIncluded = this.context.include ? this.#isIncluded(operation, method2) : true;
181
- if (isIncluded && !isExcluded) {
182
- if (!acc[path2]) {
183
- acc[path2] = {};
184
- }
185
- acc[path2] = {
186
- ...acc[path2],
187
- [method2]: {
188
- operation,
189
- schemas: this.getSchemas(operation)
190
- }
191
- };
192
- }
193
- }
194
- });
195
- return acc;
196
- }, {});
197
- const promises = Object.keys(this.operationsByMethod).reduce((acc, path2) => {
198
- const methods = this.operationsByMethod[path2] ? Object.keys(this.operationsByMethod[path2]) : [];
199
- methods.forEach((method) => {
200
- const { operation } = this.operationsByMethod[path2]?.[method];
201
- const options = this.#getOptions(operation, method);
202
- const methodToCall = this[method];
203
- if (typeof methodToCall === "function") {
204
- const promiseMethod = methodToCall?.call(this, operation, {
205
- ...this.options,
206
- ...options
207
- });
208
- if (promiseMethod) {
209
- acc.push(promiseMethod);
210
- }
154
+ return Object.entries(paths).flatMap(
155
+ ([path2, methods]) => Object.entries(methods).map((values) => {
156
+ const [method, operation] = values;
157
+ if (this.#isExcluded(operation, method)) {
158
+ return null;
211
159
  }
212
- const promiseOperation = this.operation.call(this, operation, {
213
- ...this.options,
214
- ...options
215
- });
216
- if (promiseOperation) {
217
- acc.push(promiseOperation);
160
+ if (this.context.include && !this.#isIncluded(operation, method)) {
161
+ return null;
218
162
  }
219
- generators?.forEach((generator) => {
220
- const promise = generator.operation?.({
221
- instance: this,
222
- operation,
223
- options: {
224
- ...this.options,
225
- ...options
226
- }
227
- });
228
- if (promise) {
229
- acc.push(promise);
230
- }
231
- });
232
- });
233
- return acc;
234
- }, []);
235
- const operations = Object.values(this.operationsByMethod).map((item) => Object.values(item).map((item2) => item2.operation));
236
- promises.push(this.all(operations.flat().filter(Boolean), this.operationsByMethod));
237
- generators?.forEach((generator) => {
238
- const promise = generator.operations?.({
239
- instance: this,
240
- operations: operations.flat().filter(Boolean),
241
- operationsByMethod: this.operationsByMethod,
242
- options: this.options
243
- });
244
- if (promise) {
245
- promises.push(promise);
246
- }
247
- });
248
- const files = await Promise.all(promises);
249
- return files.flat().filter(Boolean);
250
- }
251
- /**
252
- * Operation
253
- */
254
- async operation(_operation, _options) {
255
- return [];
163
+ return operation ? { path: path2, method, operation } : null;
164
+ }).filter(Boolean)
165
+ );
256
166
  }
257
- /**
258
- * Combination of GET, POST, PATCH, PUT, DELETE
259
- */
260
- async all(_operations, _paths) {
261
- return [];
167
+ async build(...generators) {
168
+ const operations = await this.getOperations();
169
+ const generatorLimit = pLimit(1);
170
+ const operationLimit = pLimit(10);
171
+ const writeTasks = generators.map(
172
+ (generator) => generatorLimit(async () => {
173
+ const operationTasks = operations.map(
174
+ ({ operation, method }) => operationLimit(async () => {
175
+ const options = this.#getOptions(operation, method);
176
+ const result = await generator.operation?.({
177
+ instance: this,
178
+ operation,
179
+ options: { ...this.options, ...options }
180
+ });
181
+ return result ?? [];
182
+ })
183
+ );
184
+ const operationResults = await Promise.all(operationTasks);
185
+ const opResultsFlat = operationResults.flat();
186
+ const operationsResult = await generator.operations?.({
187
+ instance: this,
188
+ operations: operations.map((op) => op.operation),
189
+ options: this.options
190
+ });
191
+ return [...opResultsFlat, ...operationsResult ?? []];
192
+ })
193
+ );
194
+ const nestedResults = await Promise.all(writeTasks);
195
+ return nestedResults.flat();
262
196
  }
263
197
  };
264
198
  var pluginOasName = "plugin-oas";
package/dist/index.js.map CHANGED
@@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AAA,MAAA;AAAA,UACT,QAAU,EAAA,MAAA;AAAA,UACV,IAAM,EAAA,OAAA;AAAA,UACN,QAAQ,MAAO,CAAA;AAAA;AACjB,OACF;AAEA,MAAA,MAAM,WAAc,GAAA,MAAM,eAAgB,CAAA,KAAA,CAAM,GAAG,UAAU,CAAA;AAC7D,MAAM,MAAA,IAAA,CAAK,OAAQ,CAAA,GAAG,WAAW,CAAA;AAEjC,MAAA,MAAM,kBAAqB,GAAA,IAAI,kBAAmB,CAAA,IAAA,CAAK,OAAO,OAAS,EAAA;AAAA,QACrE,GAAAA,EAAAA,IAAAA;AAAA,QACA,eAAe,IAAK,CAAA,aAAA;AAAA,QACpB,QAAQ,IAAK,CAAA,MAAA;AAAA,QACb,WAAA;AAAA,QACA,OAAS,EAAA,MAAA;AAAA,QACT,OAAS,EAAA,MAAA;AAAA,QACT,QAAU,EAAA,MAAA;AAAA,QACV,IAAM,EAAA;AAAA,OACP,CAAA;AAED,MAAA,MAAM,cAAiB,GAAA,MAAM,kBAAmB,CAAA,KAAA,CAAM,GAAG,UAAU,CAAA;AAEnE,MAAM,MAAA,IAAA,CAAK,OAAQ,CAAA,GAAG,cAAc,CAAA;AAAA;AACtC,GACF;AACF,CAAC","file":"index.js","sourcesContent":["import { BaseGenerator, type FileMetaBase } from '@kubb/core'\nimport transformers from '@kubb/core/transformers'\n\nimport type { PluginFactoryOptions, PluginManager } from '@kubb/core'\nimport type { KubbFile } from '@kubb/core/fs'\n\nimport type { Plugin } from '@kubb/core'\nimport type { HttpMethod, Oas, OasTypes, Operation, SchemaObject, contentType } from '@kubb/oas'\nimport type { Generator } from './generator.tsx'\nimport type { Exclude, Include, OperationSchemas, OperationsByMethod, Override } from './types.ts'\n\nexport type OperationMethodResult<TFileMeta extends FileMetaBase> = Promise<KubbFile.File<TFileMeta> | Array<KubbFile.File<TFileMeta>> | null>\n\ntype Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {\n oas: Oas\n exclude: Array<Exclude> | undefined\n include: Array<Include> | undefined\n override: Array<Override<TOptions>> | undefined\n contentType: contentType | undefined\n pluginManager: PluginManager\n /**\n * Current plugin\n */\n plugin: Plugin<TPluginOptions>\n mode: KubbFile.Mode\n}\n\nexport class OperationGenerator<\n TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions,\n TFileMeta extends FileMetaBase = FileMetaBase,\n> extends BaseGenerator<TPluginOptions['resolvedOptions'], Context<TPluginOptions['resolvedOptions'], TPluginOptions>> {\n #operationsByMethod: OperationsByMethod = {}\n get operationsByMethod(): OperationsByMethod {\n return this.#operationsByMethod\n }\n\n set operationsByMethod(paths: OperationsByMethod) {\n this.#operationsByMethod = paths\n }\n\n #getOptions(operation: Operation, method: HttpMethod): Partial<TPluginOptions['resolvedOptions']> {\n const { override = [] } = this.context\n\n return (\n override.find(({ pattern, type }) => {\n if (type === 'tag') {\n return !!operation.getTags().some((tag) => tag.name.match(pattern))\n }\n\n if (type === 'operationId') {\n return !!operation.getOperationId({ friendlyCase: true }).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 if (type === 'contentType') {\n return !!operation.getContentType().match(pattern)\n }\n\n return false\n })?.options || {}\n )\n }\n\n #isExcluded(operation: Operation, method: HttpMethod): boolean {\n const { exclude = [] } = this.context\n let matched = false\n\n exclude.forEach(({ pattern, type }) => {\n if (type === 'tag' && !matched) {\n matched = !!operation.getTags().some((tag) => tag.name.match(pattern))\n }\n\n if (type === 'operationId' && !matched) {\n matched = !!operation.getOperationId({ friendlyCase: true }).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 if (type === 'contentType' && !matched) {\n return !!operation.getContentType().match(pattern)\n }\n })\n\n return matched\n }\n\n #isIncluded(operation: Operation, method: HttpMethod): boolean {\n const { include = [] } = this.context\n let matched = false\n\n include.forEach(({ pattern, type }) => {\n if (type === 'tag' && !matched) {\n matched = !!operation.getTags().some((tag) => tag.name.match(pattern))\n }\n\n if (type === 'operationId' && !matched) {\n matched = !!operation.getOperationId({ friendlyCase: true }).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 if (type === 'contentType' && !matched) {\n matched = !!operation.getContentType().match(pattern)\n }\n })\n\n return matched\n }\n\n getSchemas(\n operation: Operation,\n {\n resolveName = (name) => name,\n }: {\n resolveName?: (name: string) => string\n } = {},\n ): OperationSchemas {\n const pathParamsSchema = this.context.oas.getParametersSchema(operation, 'path')\n const queryParamsSchema = this.context.oas.getParametersSchema(operation, 'query')\n const headerParamsSchema = this.context.oas.getParametersSchema(operation, 'header')\n const requestSchema = this.context.oas.getRequestSchema(operation)\n const statusCodes = operation.getResponseStatusCodes().map((statusCode) => {\n let name = statusCode\n if (name === 'default') {\n name = 'error'\n }\n\n const schema = this.context.oas.getResponseSchema(operation, statusCode)\n\n return {\n name: resolveName(transformers.pascalCase(`${operation.getOperationId({ friendlyCase: true })} ${name}`)),\n description: (operation.getResponseByStatusCode(statusCode) as OasTypes.ResponseObject)?.description,\n schema,\n operation,\n operationName: transformers.pascalCase(`${operation.getOperationId({ friendlyCase: true })}`),\n statusCode: name === 'error' ? undefined : Number(statusCode),\n keys: schema?.properties ? Object.keys(schema.properties) : undefined,\n keysToOmit: schema?.properties\n ? Object.keys(schema.properties).filter((key) => {\n const item = schema.properties?.[key] as OasTypes.SchemaObject\n return item?.writeOnly\n })\n : undefined,\n }\n })\n const hasResponses = statusCodes.some((item) => item.statusCode?.toString().startsWith('2'))\n\n return {\n pathParams: pathParamsSchema\n ? {\n name: resolveName(transformers.pascalCase(`${operation.getOperationId({ friendlyCase: true })} PathParams`)),\n operation,\n operationName: transformers.pascalCase(`${operation.getOperationId({ friendlyCase: true })}`),\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({ friendlyCase: true })} QueryParams`)),\n operation,\n operationName: transformers.pascalCase(`${operation.getOperationId({ friendlyCase: true })}`),\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({ friendlyCase: true })} HeaderParams`)),\n operation,\n operationName: transformers.pascalCase(`${operation.getOperationId({ friendlyCase: true })}`),\n schema: headerParamsSchema,\n keys: headerParamsSchema.properties ? Object.keys(headerParamsSchema.properties) : undefined,\n }\n : undefined,\n request: requestSchema\n ? {\n name: resolveName(\n transformers.pascalCase(`${operation.getOperationId({ friendlyCase: true })} ${operation.method === 'get' ? 'queryRequest' : 'mutationRequest'}`),\n ),\n description: (operation.schema.requestBody as OasTypes.RequestBodyObject)?.description,\n operation,\n operationName: transformers.pascalCase(`${operation.getOperationId({ friendlyCase: true })}`),\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(\n transformers.pascalCase(`${operation.getOperationId({ friendlyCase: true })} ${operation.method === 'get' ? 'queryResponse' : 'mutationResponse'}`),\n ),\n operation,\n operationName: transformers.pascalCase(`${operation.getOperationId({ friendlyCase: true })}`),\n schema: {\n oneOf: hasResponses\n ? statusCodes\n .filter((item) => item.statusCode?.toString().startsWith('2'))\n .map((item) => {\n return {\n ...item.schema,\n $ref: resolveName(transformers.pascalCase(`${operation.getOperationId({ friendlyCase: true })} ${item.statusCode}`)),\n }\n })\n : undefined,\n } as SchemaObject,\n },\n responses: statusCodes.filter((item) => item.statusCode?.toString().startsWith('2')),\n errors: statusCodes.filter((item) => item.statusCode?.toString().startsWith('4') || item.statusCode?.toString().startsWith('5')),\n statusCodes,\n }\n }\n\n async build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<KubbFile.File<TFileMeta>>> {\n const { oas } = this.context\n\n const paths = oas.getPaths()\n this.operationsByMethod = Object.entries(paths).reduce((acc, [path, method]) => {\n const methods = Object.keys(method) as HttpMethod[]\n\n methods.forEach((method) => {\n const operation = oas.operation(path, method)\n if (operation && method === operation.method) {\n const isExcluded = this.#isExcluded(operation, method)\n const isIncluded = this.context.include ? this.#isIncluded(operation, method) : true\n\n if (isIncluded && !isExcluded) {\n if (!acc[path]) {\n acc[path] = {} as OperationsByMethod['get']\n }\n acc[path] = {\n ...acc[path],\n [method]: {\n operation,\n schemas: this.getSchemas(operation),\n },\n } as OperationsByMethod['get']\n }\n }\n })\n\n return acc\n }, {} as OperationsByMethod)\n\n const promises = Object.keys(this.operationsByMethod).reduce((acc, path) => {\n const methods = this.operationsByMethod[path] ? (Object.keys(this.operationsByMethod[path]!) as HttpMethod[]) : []\n\n methods.forEach((method) => {\n const { operation } = this.operationsByMethod[path]?.[method]!\n const options = this.#getOptions(operation, method)\n\n const methodToCall = this[method as keyof typeof this] as any\n\n if (typeof methodToCall === 'function') {\n const promiseMethod = methodToCall?.call(this, operation, {\n ...this.options,\n ...options,\n })\n\n if (promiseMethod) {\n acc.push(promiseMethod)\n }\n }\n\n const promiseOperation = this.operation.call(this, operation, {\n ...this.options,\n ...options,\n })\n\n if (promiseOperation) {\n acc.push(promiseOperation)\n }\n\n generators?.forEach((generator) => {\n const promise = generator.operation?.({\n instance: this,\n operation,\n options: {\n ...this.options,\n ...options,\n },\n } as any) as Promise<Array<KubbFile.File<TFileMeta>>>\n\n if (promise) {\n acc.push(promise)\n }\n })\n })\n\n return acc\n }, [] as OperationMethodResult<TFileMeta>[])\n\n const operations = Object.values(this.operationsByMethod).map((item) => Object.values(item).map((item) => item.operation))\n\n promises.push(this.all(operations.flat().filter(Boolean), this.operationsByMethod))\n\n generators?.forEach((generator) => {\n const promise = generator.operations?.({\n instance: this,\n operations: operations.flat().filter(Boolean),\n operationsByMethod: this.operationsByMethod,\n options: this.options,\n } as any) as Promise<Array<KubbFile.File<TFileMeta>>>\n\n if (promise) {\n promises.push(promise)\n }\n })\n\n const files = await Promise.all(promises)\n\n // using .flat because operationGenerator[method] can return a array of files or just one file\n return files.flat().filter(Boolean)\n }\n\n /**\n * Operation\n */\n async operation(_operation: Operation, _options: TPluginOptions['resolvedOptions']): OperationMethodResult<TFileMeta> {\n return []\n }\n /**\n * 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'\nimport type { Config } from '@kubb/core'\nimport { createPlugin, FileManager, type Group } 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 ?? FileManager.getMode(path.resolve(root, output.path))\n\n if (mode === 'single') {\n /**\n * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend\n * Other plugins then need to call addOrAppend instead of just add from the fileManager class\n */\n return path.resolve(root, output.path)\n }\n\n 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 oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType,\n include: undefined,\n override: undefined,\n mode: 'split',\n output: output.path,\n },\n )\n\n const schemaFiles = await schemaGenerator.build(...generators)\n await this.addFile(...schemaFiles)\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType,\n exclude: undefined,\n include: undefined,\n override: undefined,\n mode: 'split',\n })\n\n const operationFiles = await operationGenerator.build(...generators)\n\n await this.addFile(...operationFiles)\n },\n }\n})\n"]}
1
+ {"version":3,"sources":["../src/Operation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A,QACrE,GAAAA,EAAAA,IAAAA;AAAA,QACA,eAAe,IAAK,CAAA,aAAA;AAAA,QACpB,QAAQ,IAAK,CAAA,MAAA;AAAA,QACb,WAAA;AAAA,QACA,OAAS,EAAA,MAAA;AAAA,QACT,OAAS,EAAA,MAAA;AAAA,QACT,QAAU,EAAA,MAAA;AAAA,QACV,IAAM,EAAA;AAAA,OACP,CAAA;AAED,MAAA,MAAM,cAAiB,GAAA,MAAM,kBAAmB,CAAA,KAAA,CAAM,GAAG,UAAU,CAAA;AAEnE,MAAM,MAAA,IAAA,CAAK,OAAQ,CAAA,GAAG,cAAc,CAAA;AAAA;AACtC,GACF;AACF,CAAC","file":"index.js","sourcesContent":["import { BaseGenerator, type FileMetaBase } from '@kubb/core'\nimport transformers from '@kubb/core/transformers'\n\nimport type { PluginFactoryOptions, PluginManager } from '@kubb/core'\nimport type { KubbFile } from '@kubb/core/fs'\nimport type { Plugin } from '@kubb/core'\nimport type { HttpMethod, Oas, OasTypes, Operation, SchemaObject, contentType } from '@kubb/oas'\nimport type { Generator } from './generator.tsx'\nimport type { Exclude, Include, OperationSchemas, Override } from './types.ts'\nimport pLimit from 'p-limit'\n\nexport type OperationMethodResult<TFileMeta extends FileMetaBase> = Promise<KubbFile.File<TFileMeta> | Array<KubbFile.File<TFileMeta>> | null>\n\ntype Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {\n oas: Oas\n exclude: Array<Exclude> | undefined\n include: Array<Include> | undefined\n override: Array<Override<TOptions>> | undefined\n contentType: contentType | undefined\n pluginManager: PluginManager\n /**\n * Current plugin\n */\n plugin: Plugin<TPluginOptions>\n mode: KubbFile.Mode\n}\n\nexport class OperationGenerator<\n TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions,\n TFileMeta extends FileMetaBase = FileMetaBase,\n> extends BaseGenerator<TPluginOptions['resolvedOptions'], Context<TPluginOptions['resolvedOptions'], TPluginOptions>> {\n #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 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 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 } from '@kubb/core'\nimport { createPlugin, FileManager, type Group } 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 ?? FileManager.getMode(path.resolve(root, output.path))\n\n if (mode === 'single') {\n /**\n * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend\n * Other plugins then need to call addOrAppend instead of just add from the fileManager class\n */\n return path.resolve(root, output.path)\n }\n\n 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 oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType,\n include: undefined,\n override: undefined,\n mode: 'split',\n output: output.path,\n },\n )\n\n const schemaFiles = await schemaGenerator.build(...generators)\n await this.addFile(...schemaFiles)\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType,\n exclude: undefined,\n include: undefined,\n override: undefined,\n mode: 'split',\n })\n\n const operationFiles = await operationGenerator.build(...generators)\n\n await this.addFile(...operationFiles)\n },\n }\n})\n"]}
package/dist/utils.d.cts CHANGED
@@ -2,7 +2,7 @@ import { Operation, Oas, SchemaObject, OpenAPIV3, OpenAPIV3_1, contentType, OasT
2
2
  export { isOptional } from '@kubb/oas';
3
3
  import { FunctionParamsAST } from '@kubb/core/utils';
4
4
  import { Params } from '@kubb/react/types';
5
- import { n as OperationSchema } from './OperationGenerator-LFwakDt7.cjs';
5
+ import { n as OperationSchema } from './OperationGenerator-DJE2XQ83.cjs';
6
6
  import { Config, Output } from '@kubb/core';
7
7
  import '@kubb/core/fs';
8
8
  import './SchemaMapper-B21ZmWag.cjs';
package/dist/utils.d.ts CHANGED
@@ -2,7 +2,7 @@ import { Operation, Oas, SchemaObject, OpenAPIV3, OpenAPIV3_1, contentType, OasT
2
2
  export { isOptional } from '@kubb/oas';
3
3
  import { FunctionParamsAST } from '@kubb/core/utils';
4
4
  import { Params } from '@kubb/react/types';
5
- import { n as OperationSchema } from './OperationGenerator-DyM5QANw.js';
5
+ import { n as OperationSchema } from './OperationGenerator-C7NPZtOM.js';
6
6
  import { Config, Output } from '@kubb/core';
7
7
  import '@kubb/core/fs';
8
8
  import './SchemaMapper-B21ZmWag.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/plugin-oas",
3
- "version": "3.15.1",
3
+ "version": "3.16.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",
@@ -87,18 +87,19 @@
87
87
  ],
88
88
  "dependencies": {
89
89
  "@stoplight/yaml": "^4.3.0",
90
- "remeda": "^2.25.0",
91
- "@kubb/core": "3.15.1",
92
- "@kubb/oas": "3.15.1",
93
- "@kubb/react": "3.15.1"
90
+ "p-limit": "~6.2.0",
91
+ "remeda": "^2.26.0",
92
+ "@kubb/core": "3.16.0",
93
+ "@kubb/oas": "3.16.0",
94
+ "@kubb/react": "3.16.0"
94
95
  },
95
96
  "devDependencies": {
96
97
  "@types/react": "^18.3.23",
97
98
  "react": "^18.3.1",
98
99
  "tsup": "^8.5.0",
99
100
  "typescript": "^5.8.3",
100
- "@kubb/config-ts": "3.15.1",
101
- "@kubb/config-tsup": "3.15.1"
101
+ "@kubb/config-ts": "3.16.0",
102
+ "@kubb/config-tsup": "3.16.0"
102
103
  },
103
104
  "peerDependencies": {
104
105
  "@kubb/react": "^3.0.0"