@kubb/plugin-oas 3.0.0-alpha.1 → 3.0.0-alpha.3
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/OperationGenerator-D7rSlflc.d.cts +158 -0
- package/dist/OperationGenerator-vw0Zf-Mi.d.ts +158 -0
- package/dist/{Schema-an5hOrjZ.d.cts → Schema-DxyOIX7q.d.cts} +1 -1
- package/dist/{Schema-DefwBJMc.d.ts → Schema-gHgN14i2.d.ts} +1 -1
- package/dist/{SchemaMapper-CsBQ6eEx.d.cts → SchemaMapper-BM1IGWqD.d.cts} +1 -1
- package/dist/{SchemaMapper-CsBQ6eEx.d.ts → SchemaMapper-BM1IGWqD.d.ts} +1 -1
- package/dist/{chunk-DRLYORTT.cjs → chunk-264TCCJF.cjs} +715 -7
- package/dist/chunk-264TCCJF.cjs.map +1 -0
- package/dist/chunk-7KIEQOVZ.cjs +7 -0
- package/dist/chunk-7KIEQOVZ.cjs.map +1 -0
- package/dist/{chunk-LEACSHKT.js → chunk-FZN3PBEK.js} +713 -5
- package/dist/chunk-FZN3PBEK.js.map +1 -0
- package/dist/chunk-TWKZEVSM.js +7 -0
- package/dist/chunk-TWKZEVSM.js.map +1 -0
- package/dist/components.cjs +4 -9
- package/dist/components.cjs.map +1 -1
- package/dist/components.d.cts +12 -6
- package/dist/components.d.ts +12 -6
- package/dist/components.js +3 -8
- package/dist/components.js.map +1 -1
- package/dist/hooks.cjs +6 -7
- package/dist/hooks.cjs.map +1 -1
- package/dist/hooks.d.cts +3 -3
- package/dist/hooks.d.ts +3 -3
- package/dist/hooks.js +1 -2
- package/dist/hooks.js.map +1 -1
- package/dist/index.cjs +225 -159
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -77
- package/dist/index.d.ts +8 -77
- package/dist/index.js +207 -141
- package/dist/index.js.map +1 -1
- package/dist/{types-Dte3MA6H.d.cts → types-C2RXaY0_.d.cts} +1 -1
- package/dist/{types-Dte3MA6H.d.ts → types-C2RXaY0_.d.ts} +1 -1
- package/dist/utils.d.cts +2 -2
- package/dist/utils.d.ts +2 -2
- package/package.json +9 -9
- package/src/OperationGenerator.ts +62 -31
- package/src/SchemaGenerator.ts +23 -4
- package/src/components/Oas.tsx +8 -2
- package/src/index.ts +3 -9
- package/src/parser.tsx +120 -0
- package/src/plugin.ts +1 -9
- package/dist/OperationGenerator-CeM_9pxW.d.cts +0 -60
- package/dist/OperationGenerator-DhUhvRJE.d.ts +0 -60
- package/dist/chunk-CJXRFYEF.cjs +0 -698
- package/dist/chunk-CJXRFYEF.cjs.map +0 -1
- package/dist/chunk-DRLYORTT.cjs.map +0 -1
- package/dist/chunk-K6KUETAI.js +0 -698
- package/dist/chunk-K6KUETAI.js.map +0 -1
- package/dist/chunk-LEACSHKT.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
import {
|
|
2
2
|
parseFromConfig
|
|
3
3
|
} from "./chunk-Y4V7HHX7.js";
|
|
4
|
+
import "./chunk-TWKZEVSM.js";
|
|
4
5
|
import {
|
|
6
|
+
Oas,
|
|
5
7
|
SchemaGenerator,
|
|
6
8
|
isKeyword,
|
|
9
|
+
require_jsx_runtime,
|
|
7
10
|
schemaKeywords
|
|
8
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-FZN3PBEK.js";
|
|
9
12
|
import {
|
|
10
13
|
__privateAdd,
|
|
11
14
|
__privateGet,
|
|
12
15
|
__privateMethod,
|
|
13
16
|
__privateSet,
|
|
17
|
+
__toESM,
|
|
14
18
|
getSchemas,
|
|
15
19
|
init_esm_shims
|
|
16
20
|
} from "./chunk-UB552H4J.js";
|
|
@@ -18,119 +22,11 @@ import {
|
|
|
18
22
|
// src/index.ts
|
|
19
23
|
init_esm_shims();
|
|
20
24
|
|
|
21
|
-
// src/plugin.ts
|
|
22
|
-
init_esm_shims();
|
|
23
|
-
import path from "path";
|
|
24
|
-
import { createPlugin } from "@kubb/core";
|
|
25
|
-
import { camelCase } from "@kubb/core/transformers";
|
|
26
|
-
var pluginOasName = "plugin-oas";
|
|
27
|
-
var pluginOas = createPlugin((options) => {
|
|
28
|
-
const {
|
|
29
|
-
output = { path: "schemas", export: false },
|
|
30
|
-
experimentalFilter: filter,
|
|
31
|
-
experimentalSort: sort,
|
|
32
|
-
validate = true,
|
|
33
|
-
serverIndex = 0,
|
|
34
|
-
contentType,
|
|
35
|
-
oasClass
|
|
36
|
-
} = options;
|
|
37
|
-
const getOas = async ({ config, logger, formatOptions }) => {
|
|
38
|
-
try {
|
|
39
|
-
const oas = await parseFromConfig(config, formatOptions, oasClass);
|
|
40
|
-
if (validate) {
|
|
41
|
-
await oas.valdiate();
|
|
42
|
-
}
|
|
43
|
-
return oas;
|
|
44
|
-
} catch (e) {
|
|
45
|
-
const error = e;
|
|
46
|
-
logger.emit("warning", error?.message);
|
|
47
|
-
return parseFromConfig(config, {}, oasClass);
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
return {
|
|
51
|
-
name: pluginOasName,
|
|
52
|
-
options,
|
|
53
|
-
api() {
|
|
54
|
-
const { config, logger } = this;
|
|
55
|
-
return {
|
|
56
|
-
getOas(formatOptions) {
|
|
57
|
-
return getOas({ config, logger, formatOptions });
|
|
58
|
-
},
|
|
59
|
-
async getSchemas({ includes } = {}) {
|
|
60
|
-
const oas = await this.getOas();
|
|
61
|
-
return getSchemas({ oas, contentType, includes });
|
|
62
|
-
},
|
|
63
|
-
async getBaseURL() {
|
|
64
|
-
const oasInstance = await this.getOas();
|
|
65
|
-
const baseURL = oasInstance.api.servers?.at(serverIndex)?.url;
|
|
66
|
-
return baseURL;
|
|
67
|
-
},
|
|
68
|
-
contentType
|
|
69
|
-
};
|
|
70
|
-
},
|
|
71
|
-
resolvePath(baseName) {
|
|
72
|
-
if (output === false) {
|
|
73
|
-
return void 0;
|
|
74
|
-
}
|
|
75
|
-
const root = path.resolve(this.config.root, this.config.output.path);
|
|
76
|
-
return path.resolve(root, output.path, baseName);
|
|
77
|
-
},
|
|
78
|
-
resolveName(name, type) {
|
|
79
|
-
return camelCase(name, { isFile: type === "file" });
|
|
80
|
-
},
|
|
81
|
-
async writeFile(path2, source) {
|
|
82
|
-
if (!path2.endsWith(".json") || !source) {
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
|
-
return this.fileManager.write(path2, source, { sanity: false });
|
|
86
|
-
},
|
|
87
|
-
async buildStart() {
|
|
88
|
-
if (!output) {
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
const oas = await getOas({
|
|
92
|
-
config: this.config,
|
|
93
|
-
logger: this.logger,
|
|
94
|
-
formatOptions: {
|
|
95
|
-
filterSet: filter,
|
|
96
|
-
sortSet: sort
|
|
97
|
-
}
|
|
98
|
-
});
|
|
99
|
-
await oas.dereference();
|
|
100
|
-
const schemas = getSchemas({ oas, contentType });
|
|
101
|
-
const mapSchema = async ([name, schema]) => {
|
|
102
|
-
const resolvedPath = this.resolvePath({
|
|
103
|
-
baseName: `${name}.json`,
|
|
104
|
-
pluginKey: this.plugin.key
|
|
105
|
-
});
|
|
106
|
-
const resvoledFileName = this.resolveName({
|
|
107
|
-
name: `${name}.json`,
|
|
108
|
-
pluginKey: [pluginOasName],
|
|
109
|
-
type: "file"
|
|
110
|
-
});
|
|
111
|
-
if (!resolvedPath) {
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
await this.addFile({
|
|
115
|
-
path: resolvedPath,
|
|
116
|
-
baseName: resvoledFileName,
|
|
117
|
-
source: JSON.stringify(schema),
|
|
118
|
-
meta: {
|
|
119
|
-
pluginKey: this.plugin.key
|
|
120
|
-
}
|
|
121
|
-
});
|
|
122
|
-
};
|
|
123
|
-
const promises = Object.entries(schemas).map(mapSchema);
|
|
124
|
-
await Promise.all(promises);
|
|
125
|
-
}
|
|
126
|
-
};
|
|
127
|
-
});
|
|
128
|
-
|
|
129
25
|
// src/OperationGenerator.ts
|
|
130
26
|
init_esm_shims();
|
|
131
27
|
import { Generator } from "@kubb/core";
|
|
132
28
|
import transformers from "@kubb/core/transformers";
|
|
133
|
-
var _operationsByMethod, _OperationGenerator_instances, getOptions_fn, isExcluded_fn, isIncluded_fn
|
|
29
|
+
var _operationsByMethod, _OperationGenerator_instances, getOptions_fn, isExcluded_fn, isIncluded_fn;
|
|
134
30
|
var OperationGenerator = class extends Generator {
|
|
135
31
|
constructor() {
|
|
136
32
|
super(...arguments);
|
|
@@ -143,7 +39,10 @@ var OperationGenerator = class extends Generator {
|
|
|
143
39
|
set operationsByMethod(paths) {
|
|
144
40
|
__privateSet(this, _operationsByMethod, paths);
|
|
145
41
|
}
|
|
146
|
-
getSchemas(operation, {
|
|
42
|
+
getSchemas(operation, {
|
|
43
|
+
forStatusCode,
|
|
44
|
+
resolveName = (name) => name
|
|
45
|
+
} = {}) {
|
|
147
46
|
const pathParamsSchema = this.context.oas.getParametersSchema(operation, "path");
|
|
148
47
|
const queryParamsSchema = this.context.oas.getParametersSchema(operation, "query");
|
|
149
48
|
const headerParamsSchema = this.context.oas.getParametersSchema(operation, "header");
|
|
@@ -217,14 +116,14 @@ var OperationGenerator = class extends Generator {
|
|
|
217
116
|
statusCodes
|
|
218
117
|
};
|
|
219
118
|
}
|
|
220
|
-
async build() {
|
|
119
|
+
async build(...parsers) {
|
|
221
120
|
const { oas } = this.context;
|
|
222
121
|
const paths = oas.getPaths();
|
|
223
122
|
this.operationsByMethod = Object.entries(paths).reduce((acc, [path2, method]) => {
|
|
224
123
|
const methods = Object.keys(method);
|
|
225
124
|
methods.forEach((method2) => {
|
|
226
125
|
const operation = oas.operation(path2, method2);
|
|
227
|
-
if (operation
|
|
126
|
+
if (operation) {
|
|
228
127
|
const isExcluded = __privateMethod(this, _OperationGenerator_instances, isExcluded_fn).call(this, operation, method2);
|
|
229
128
|
const isIncluded = this.context.include ? __privateMethod(this, _OperationGenerator_instances, isIncluded_fn).call(this, operation, method2) : true;
|
|
230
129
|
if (isIncluded && !isExcluded) {
|
|
@@ -248,25 +147,52 @@ var OperationGenerator = class extends Generator {
|
|
|
248
147
|
methods.forEach((method) => {
|
|
249
148
|
const { operation } = this.operationsByMethod[path2]?.[method];
|
|
250
149
|
const options = __privateMethod(this, _OperationGenerator_instances, getOptions_fn).call(this, operation, method);
|
|
251
|
-
const
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
150
|
+
const methodToCall = this[method];
|
|
151
|
+
if (typeof methodToCall === "function") {
|
|
152
|
+
const promiseMethod = methodToCall?.call(this, operation, {
|
|
153
|
+
...this.options,
|
|
154
|
+
...options
|
|
155
|
+
});
|
|
156
|
+
if (promiseMethod) {
|
|
157
|
+
acc.push(promiseMethod);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
255
160
|
const promiseOperation = this.operation.call(this, operation, {
|
|
256
161
|
...this.options,
|
|
257
162
|
...options
|
|
258
163
|
});
|
|
259
|
-
if (promiseMethod) {
|
|
260
|
-
acc.push(promiseMethod);
|
|
261
|
-
}
|
|
262
164
|
if (promiseOperation) {
|
|
263
165
|
acc.push(promiseOperation);
|
|
264
166
|
}
|
|
167
|
+
parsers?.forEach((parser) => {
|
|
168
|
+
const promise = parser.operation?.({
|
|
169
|
+
instance: this,
|
|
170
|
+
operation,
|
|
171
|
+
options: {
|
|
172
|
+
...this.options,
|
|
173
|
+
...options
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
if (promise) {
|
|
177
|
+
acc.push(promise);
|
|
178
|
+
}
|
|
179
|
+
});
|
|
265
180
|
});
|
|
266
181
|
return acc;
|
|
267
182
|
}, []);
|
|
268
183
|
const operations = Object.values(this.operationsByMethod).map((item) => Object.values(item).map((item2) => item2.operation));
|
|
269
184
|
promises.push(this.all(operations.flat().filter(Boolean), this.operationsByMethod));
|
|
185
|
+
parsers?.forEach((parser) => {
|
|
186
|
+
const promise = parser.operations?.({
|
|
187
|
+
instance: this,
|
|
188
|
+
operations: operations.flat().filter(Boolean),
|
|
189
|
+
operationsByMethod: this.operationsByMethod,
|
|
190
|
+
options: this.options
|
|
191
|
+
});
|
|
192
|
+
if (promise) {
|
|
193
|
+
promises.push(promise);
|
|
194
|
+
}
|
|
195
|
+
});
|
|
270
196
|
const files = await Promise.all(promises);
|
|
271
197
|
return files.flat().filter(Boolean);
|
|
272
198
|
}
|
|
@@ -274,43 +200,43 @@ var OperationGenerator = class extends Generator {
|
|
|
274
200
|
* Operation
|
|
275
201
|
*/
|
|
276
202
|
async operation(operation, options) {
|
|
277
|
-
return
|
|
203
|
+
return [];
|
|
278
204
|
}
|
|
279
205
|
/**
|
|
280
206
|
* GET
|
|
281
207
|
*/
|
|
282
208
|
async get(operation, options) {
|
|
283
|
-
return
|
|
209
|
+
return [];
|
|
284
210
|
}
|
|
285
211
|
/**
|
|
286
212
|
* POST
|
|
287
213
|
*/
|
|
288
214
|
async post(operation, options) {
|
|
289
|
-
return
|
|
215
|
+
return [];
|
|
290
216
|
}
|
|
291
217
|
/**
|
|
292
218
|
* PATCH
|
|
293
219
|
*/
|
|
294
220
|
async patch(operation, options) {
|
|
295
|
-
return
|
|
221
|
+
return [];
|
|
296
222
|
}
|
|
297
223
|
/**
|
|
298
224
|
* PUT
|
|
299
225
|
*/
|
|
300
226
|
async put(operation, options) {
|
|
301
|
-
return
|
|
227
|
+
return [];
|
|
302
228
|
}
|
|
303
229
|
/**
|
|
304
230
|
* DELETE
|
|
305
231
|
*/
|
|
306
232
|
async delete(operation, options) {
|
|
307
|
-
return
|
|
233
|
+
return [];
|
|
308
234
|
}
|
|
309
235
|
/**
|
|
310
236
|
* Combination of GET, POST, PATCH, PUT, DELETE
|
|
311
237
|
*/
|
|
312
238
|
async all(operations, paths) {
|
|
313
|
-
return
|
|
239
|
+
return [];
|
|
314
240
|
}
|
|
315
241
|
};
|
|
316
242
|
_operationsByMethod = new WeakMap();
|
|
@@ -379,26 +305,166 @@ isIncluded_fn = function(operation, method) {
|
|
|
379
305
|
});
|
|
380
306
|
return matched;
|
|
381
307
|
};
|
|
382
|
-
|
|
308
|
+
|
|
309
|
+
// src/plugin.ts
|
|
310
|
+
init_esm_shims();
|
|
311
|
+
import path from "path";
|
|
312
|
+
import { createPlugin } from "@kubb/core";
|
|
313
|
+
import { camelCase } from "@kubb/core/transformers";
|
|
314
|
+
var pluginOasName = "plugin-oas";
|
|
315
|
+
var pluginOas = createPlugin((options) => {
|
|
316
|
+
const {
|
|
317
|
+
output = { path: "schemas", export: false },
|
|
318
|
+
experimentalFilter: filter,
|
|
319
|
+
experimentalSort: sort,
|
|
320
|
+
validate = true,
|
|
321
|
+
serverIndex = 0,
|
|
322
|
+
contentType,
|
|
323
|
+
oasClass
|
|
324
|
+
} = options;
|
|
325
|
+
const getOas = async ({ config, logger, formatOptions }) => {
|
|
326
|
+
try {
|
|
327
|
+
const oas = await parseFromConfig(config, formatOptions, oasClass);
|
|
328
|
+
if (validate) {
|
|
329
|
+
await oas.valdiate();
|
|
330
|
+
}
|
|
331
|
+
return oas;
|
|
332
|
+
} catch (e) {
|
|
333
|
+
const error = e;
|
|
334
|
+
logger.emit("warning", error?.message);
|
|
335
|
+
return parseFromConfig(config, {}, oasClass);
|
|
336
|
+
}
|
|
337
|
+
};
|
|
383
338
|
return {
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
339
|
+
name: pluginOasName,
|
|
340
|
+
options,
|
|
341
|
+
context() {
|
|
342
|
+
const { config, logger } = this;
|
|
343
|
+
return {
|
|
344
|
+
getOas(formatOptions) {
|
|
345
|
+
return getOas({ config, logger, formatOptions });
|
|
346
|
+
},
|
|
347
|
+
async getSchemas({ includes } = {}) {
|
|
348
|
+
const oas = await this.getOas();
|
|
349
|
+
return getSchemas({ oas, contentType, includes });
|
|
350
|
+
},
|
|
351
|
+
async getBaseURL() {
|
|
352
|
+
const oasInstance = await this.getOas();
|
|
353
|
+
const baseURL = oasInstance.api.servers?.at(serverIndex)?.url;
|
|
354
|
+
return baseURL;
|
|
355
|
+
},
|
|
356
|
+
contentType
|
|
357
|
+
};
|
|
358
|
+
},
|
|
359
|
+
resolvePath(baseName) {
|
|
360
|
+
if (output === false) {
|
|
361
|
+
return void 0;
|
|
362
|
+
}
|
|
363
|
+
const root = path.resolve(this.config.root, this.config.output.path);
|
|
364
|
+
return path.resolve(root, output.path, baseName);
|
|
365
|
+
},
|
|
366
|
+
resolveName(name, type) {
|
|
367
|
+
return camelCase(name, { isFile: type === "file" });
|
|
368
|
+
},
|
|
369
|
+
async buildStart() {
|
|
370
|
+
if (!output) {
|
|
371
|
+
return;
|
|
372
|
+
}
|
|
373
|
+
const oas = await getOas({
|
|
374
|
+
config: this.config,
|
|
375
|
+
logger: this.logger,
|
|
376
|
+
formatOptions: {
|
|
377
|
+
filterSet: filter,
|
|
378
|
+
sortSet: sort
|
|
379
|
+
}
|
|
380
|
+
});
|
|
381
|
+
await oas.dereference();
|
|
382
|
+
const schemas = getSchemas({ oas, contentType });
|
|
383
|
+
const mapSchema = async ([name, schema]) => {
|
|
384
|
+
const resolvedPath = this.resolvePath({
|
|
385
|
+
baseName: `${name}.json`,
|
|
386
|
+
pluginKey: this.plugin.key
|
|
387
|
+
});
|
|
388
|
+
const resvoledFileName = this.resolveName({
|
|
389
|
+
name: `${name}.json`,
|
|
390
|
+
pluginKey: [pluginOasName],
|
|
391
|
+
type: "file"
|
|
392
|
+
});
|
|
393
|
+
if (!resolvedPath) {
|
|
394
|
+
return;
|
|
395
|
+
}
|
|
396
|
+
await this.addFile({
|
|
397
|
+
path: resolvedPath,
|
|
398
|
+
baseName: resvoledFileName,
|
|
399
|
+
source: JSON.stringify(schema),
|
|
400
|
+
meta: {
|
|
401
|
+
pluginKey: this.plugin.key
|
|
402
|
+
}
|
|
403
|
+
});
|
|
404
|
+
};
|
|
405
|
+
const promises = Object.entries(schemas).map(mapSchema);
|
|
406
|
+
await Promise.all(promises);
|
|
407
|
+
}
|
|
392
408
|
};
|
|
393
|
-
};
|
|
409
|
+
});
|
|
394
410
|
|
|
395
|
-
// src/
|
|
396
|
-
|
|
397
|
-
|
|
411
|
+
// src/parser.tsx
|
|
412
|
+
init_esm_shims();
|
|
413
|
+
import { App, createRoot } from "@kubb/react";
|
|
414
|
+
var import_jsx_runtime = __toESM(require_jsx_runtime(), 1);
|
|
415
|
+
function createParser(parseOptions) {
|
|
416
|
+
return parseOptions;
|
|
417
|
+
}
|
|
418
|
+
function createReactParser(parseOptions) {
|
|
419
|
+
return {
|
|
420
|
+
...parseOptions,
|
|
421
|
+
async operations({ instance, options, operations, operationsByMethod }) {
|
|
422
|
+
if (!parseOptions.Operations) {
|
|
423
|
+
return [];
|
|
424
|
+
}
|
|
425
|
+
const { pluginManager, oas, plugin, mode } = instance.context;
|
|
426
|
+
const root = createRoot({
|
|
427
|
+
logger: pluginManager.logger
|
|
428
|
+
});
|
|
429
|
+
root.render(
|
|
430
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(App, { pluginManager, plugin, mode, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Oas, { oas, operations, generator: instance, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(parseOptions.Operations, { operations, instance, operationsByMethod, options }) }) })
|
|
431
|
+
);
|
|
432
|
+
return root.files;
|
|
433
|
+
},
|
|
434
|
+
async operation({ instance, operation, options }) {
|
|
435
|
+
if (!parseOptions.Operation) {
|
|
436
|
+
return [];
|
|
437
|
+
}
|
|
438
|
+
const { pluginManager, oas, plugin, mode } = instance.context;
|
|
439
|
+
const root = createRoot({
|
|
440
|
+
logger: pluginManager.logger
|
|
441
|
+
});
|
|
442
|
+
root.render(
|
|
443
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(App, { pluginManager, plugin: { ...plugin, options }, mode, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Oas, { oas, operations: [operation], generator: instance, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Oas.Operation, { operation, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(parseOptions.Operation, { operation, options, instance }) }) }) })
|
|
444
|
+
);
|
|
445
|
+
return root.files;
|
|
446
|
+
},
|
|
447
|
+
async schema({ instance, schema, name, options }) {
|
|
448
|
+
if (!parseOptions.Schema) {
|
|
449
|
+
return [];
|
|
450
|
+
}
|
|
451
|
+
const { pluginManager, oas, plugin, mode } = instance.context;
|
|
452
|
+
const root = createRoot({
|
|
453
|
+
logger: pluginManager.logger
|
|
454
|
+
});
|
|
455
|
+
const tree = instance.parse({ schema, name });
|
|
456
|
+
root.render(
|
|
457
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(App, { pluginManager, plugin: { ...plugin, options }, mode, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Oas, { oas, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Oas.Schema, { name, value: schema, tree, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(parseOptions.Schema, { schema, options, instance, name }) }) }) })
|
|
458
|
+
);
|
|
459
|
+
return root.files;
|
|
460
|
+
}
|
|
461
|
+
};
|
|
462
|
+
}
|
|
398
463
|
export {
|
|
399
464
|
OperationGenerator,
|
|
400
465
|
SchemaGenerator,
|
|
401
|
-
|
|
466
|
+
createParser,
|
|
467
|
+
createReactParser,
|
|
402
468
|
isKeyword,
|
|
403
469
|
pluginOas,
|
|
404
470
|
pluginOasName,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/plugin.ts","../src/OperationGenerator.ts"],"sourcesContent":["import { pluginOas } from './plugin.ts'\n\nexport type {\n GetOperationGeneratorOptions,\n OperationMethodResult,\n} from './OperationGenerator.ts'\nexport { OperationGenerator } from './OperationGenerator.ts'\nexport { pluginOas, pluginOasName } from './plugin.ts'\nexport type {\n GetSchemaGeneratorOptions,\n SchemaGeneratorBuildOptions,\n SchemaGeneratorOptions,\n} from './SchemaGenerator.ts'\nexport type { SchemaMethodResult } from './SchemaGenerator.ts'\nexport { SchemaGenerator } from './SchemaGenerator.ts'\nexport type {\n Schema,\n SchemaKeyword,\n SchemaKeywordBase,\n SchemaKeywordMapper,\n SchemaMapper,\n} from './SchemaMapper.ts'\nexport { isKeyword, schemaKeywords } from './SchemaMapper.ts'\nexport type * from './types.ts'\n\n/**\n * @deprecated Use `import { pluginOas } from '@kubb/plugin-oas'` instead\n */\nconst definePluginDefault = pluginOas\n\nexport default definePluginDefault\n","import path from 'node:path'\n\nimport { createPlugin } from '@kubb/core'\nimport { camelCase } from '@kubb/core/transformers'\n\nimport { getSchemas } from './utils/getSchemas.ts'\n\nimport type { Config } from '@kubb/core'\nimport type { Logger } from '@kubb/core/logger'\nimport type { Oas, OasTypes } from '@kubb/oas'\nimport type { FormatOptions } from '@kubb/oas/parser'\nimport type { PluginOas } from './types.ts'\nimport { parseFromConfig } from './utils/parseFromConfig.ts'\n\nexport const pluginOasName = 'plugin-oas' satisfies PluginOas['name']\n\nexport const pluginOas = createPlugin<PluginOas>((options) => {\n const {\n output = { path: 'schemas', export: false },\n experimentalFilter: filter,\n experimentalSort: sort,\n validate = true,\n serverIndex = 0,\n contentType,\n oasClass,\n } = options\n\n const getOas = async ({ config, logger, formatOptions }: { config: Config; logger: Logger; formatOptions?: FormatOptions }): Promise<Oas> => {\n try {\n // needs to be in a different variable or the catch here will not work(return of a promise instead)\n const oas = await parseFromConfig(config, formatOptions, oasClass)\n\n if (validate) {\n await oas.valdiate()\n }\n\n return oas\n } catch (e) {\n const error = e as Error\n\n logger.emit('warning', error?.message)\n return parseFromConfig(config, {}, oasClass)\n }\n }\n\n return {\n name: pluginOasName,\n options,\n\n api() {\n const { config, logger } = this\n\n return {\n getOas(formatOptions) {\n return getOas({ config, logger, formatOptions })\n },\n async getSchemas({ includes } = {}) {\n const oas = await this.getOas()\n return getSchemas({ oas, contentType, includes })\n },\n async getBaseURL() {\n const oasInstance = await this.getOas()\n const baseURL = oasInstance.api.servers?.at(serverIndex)?.url\n return baseURL\n },\n contentType,\n }\n },\n resolvePath(baseName) {\n if (output === false) {\n return undefined\n }\n\n const root = path.resolve(this.config.root, this.config.output.path)\n\n return path.resolve(root, output.path, baseName)\n },\n resolveName(name, type) {\n return camelCase(name, { isFile: type === 'file' })\n },\n async writeFile(path, source) {\n if (!path.endsWith('.json') || !source) {\n return\n }\n\n return this.fileManager.write(path, source, { sanity: false })\n },\n async buildStart() {\n if (!output) {\n return\n }\n\n const oas = await getOas({\n config: this.config,\n logger: this.logger,\n formatOptions: {\n filterSet: filter,\n sortSet: sort,\n },\n })\n await oas.dereference()\n const schemas = getSchemas({ oas, contentType })\n\n const mapSchema = async ([name, schema]: [string, OasTypes.SchemaObject]) => {\n const resolvedPath = this.resolvePath({\n baseName: `${name}.json`,\n pluginKey: this.plugin.key,\n })\n\n const resvoledFileName = this.resolveName({\n name: `${name}.json`,\n pluginKey: [pluginOasName],\n type: 'file',\n }) as `${string}.json`\n\n if (!resolvedPath) {\n return\n }\n\n await this.addFile({\n path: resolvedPath,\n baseName: resvoledFileName,\n source: JSON.stringify(schema),\n meta: {\n pluginKey: this.plugin.key,\n },\n })\n }\n\n const promises = Object.entries(schemas).map(mapSchema)\n await Promise.all(promises)\n },\n }\n})\n","import { type FileMetaBase, Generator } from '@kubb/core'\nimport transformers from '@kubb/core/transformers'\n\nimport type { PluginFactoryOptions, PluginManager } from '@kubb/core'\nimport type * as KubbFile from '@kubb/fs/types'\n\nimport type { Plugin } from '@kubb/core'\nimport type { HttpMethod, Oas, OasTypes, Operation, contentType } from '@kubb/oas'\nimport type { Exclude, Include, OperationSchemas, OperationsByMethod, Override } from './types.ts'\n\nexport type GetOperationGeneratorOptions<T extends OperationGenerator<any, any, any>> = T extends OperationGenerator<infer Options, any, any> ? Options : never\n\nexport type OperationMethodResult<TFileMeta extends FileMetaBase> = Promise<KubbFile.File<TFileMeta> | Array<KubbFile.File<TFileMeta>> | null>\n\ntype Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {\n oas: Oas\n exclude: Array<Exclude> | undefined\n include: Array<Include> | undefined\n override: Array<Override<TOptions>> | undefined\n contentType: contentType | undefined\n pluginManager: PluginManager\n /**\n * Current plugin\n */\n plugin: Plugin<TPluginOptions>\n mode: KubbFile.Mode\n}\n\nexport abstract class OperationGenerator<\n TOptions = unknown,\n TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions,\n TFileMeta extends FileMetaBase = FileMetaBase,\n> extends Generator<TOptions, Context<TOptions, TPluginOptions>> {\n #operationsByMethod: OperationsByMethod = {}\n get operationsByMethod(): OperationsByMethod {\n return this.#operationsByMethod\n }\n\n set operationsByMethod(paths: OperationsByMethod) {\n this.#operationsByMethod = paths\n }\n\n #getOptions(operation: Operation, method: HttpMethod): Partial<TOptions> {\n const { override = [] } = this.context\n\n return (\n override.find(({ pattern, type }) => {\n if (type === 'tag') {\n return !!operation.getTags()[0]?.name.match(pattern)\n }\n\n if (type === 'operationId') {\n return !!operation.getOperationId().match(pattern)\n }\n\n if (type === 'path') {\n return !!operation.path.match(pattern)\n }\n\n if (type === 'method') {\n return !!method.match(pattern)\n }\n\n return false\n })?.options || {}\n )\n }\n /**\n *\n * @deprecated\n */\n #isExcluded(operation: Operation, method: HttpMethod): boolean {\n const { exclude = [] } = this.context\n let matched = false\n\n exclude.forEach(({ pattern, type }) => {\n if (type === 'tag' && !matched) {\n matched = !!operation.getTags()[0]?.name.match(pattern)\n }\n\n if (type === 'operationId' && !matched) {\n matched = !!operation.getOperationId().match(pattern)\n }\n\n if (type === 'path' && !matched) {\n matched = !!operation.path.match(pattern)\n }\n\n if (type === 'method' && !matched) {\n matched = !!method.match(pattern)\n }\n })\n\n return matched\n }\n /**\n *\n * @deprecated\n */\n #isIncluded(operation: Operation, method: HttpMethod): boolean {\n const { include = [] } = this.context\n let matched = false\n\n include.forEach(({ pattern, type }) => {\n if (type === 'tag' && !matched) {\n matched = !!operation.getTags()[0]?.name.match(pattern)\n }\n\n if (type === 'operationId' && !matched) {\n matched = !!operation.getOperationId().match(pattern)\n }\n\n if (type === 'path' && !matched) {\n matched = !!operation.path.match(pattern)\n }\n\n if (type === 'method' && !matched) {\n matched = !!method.match(pattern)\n }\n })\n\n return matched\n }\n\n getSchemas(\n operation: Operation,\n { forStatusCode, resolveName = (name) => name }: { forStatusCode?: string | number; resolveName?: (name: string) => string } = {},\n ): OperationSchemas {\n const pathParamsSchema = this.context.oas.getParametersSchema(operation, 'path')\n const queryParamsSchema = this.context.oas.getParametersSchema(operation, 'query')\n const headerParamsSchema = this.context.oas.getParametersSchema(operation, 'header')\n const requestSchema = this.context.oas.getRequestSchema(operation)\n const responseStatusCode =\n forStatusCode || (operation.schema.responses && Object.keys(operation.schema.responses).find((key) => key.startsWith('2'))) || 200\n const responseSchema = this.context.oas.getResponseSchema(operation, responseStatusCode)\n const statusCodes = operation.getResponseStatusCodes().map((statusCode) => {\n let name = statusCode\n if (name === 'default') {\n name = 'error'\n }\n\n const schema = this.context.oas.getResponseSchema(operation, statusCode)\n\n return {\n name: resolveName(transformers.pascalCase(`${operation.getOperationId()} ${name}`)),\n description: (operation.getResponseByStatusCode(statusCode) as OasTypes.ResponseObject)?.description,\n schema,\n operation,\n operationName: transformers.pascalCase(`${operation.getOperationId()}`),\n statusCode: name === 'error' ? undefined : Number(statusCode),\n keys: schema?.properties ? Object.keys(schema.properties) : undefined,\n }\n })\n\n return {\n pathParams: pathParamsSchema\n ? {\n name: resolveName(transformers.pascalCase(`${operation.getOperationId()} PathParams`)),\n operation,\n operationName: transformers.pascalCase(`${operation.getOperationId()}`),\n schema: pathParamsSchema,\n keys: pathParamsSchema.properties ? Object.keys(pathParamsSchema.properties) : undefined,\n }\n : undefined,\n queryParams: queryParamsSchema\n ? {\n name: resolveName(transformers.pascalCase(`${operation.getOperationId()} QueryParams`)),\n operation,\n operationName: transformers.pascalCase(`${operation.getOperationId()}`),\n schema: queryParamsSchema,\n keys: queryParamsSchema.properties ? Object.keys(queryParamsSchema.properties) : [],\n }\n : undefined,\n headerParams: headerParamsSchema\n ? {\n name: resolveName(transformers.pascalCase(`${operation.getOperationId()} HeaderParams`)),\n operation,\n operationName: transformers.pascalCase(`${operation.getOperationId()}`),\n schema: headerParamsSchema,\n keys: headerParamsSchema.properties ? Object.keys(headerParamsSchema.properties) : undefined,\n }\n : undefined,\n request: requestSchema\n ? {\n name: resolveName(transformers.pascalCase(`${operation.getOperationId()} ${operation.method === 'get' ? 'queryRequest' : 'mutationRequest'}`)),\n description: (operation.schema.requestBody as OasTypes.RequestBodyObject)?.description,\n operation,\n operationName: transformers.pascalCase(`${operation.getOperationId()}`),\n schema: requestSchema,\n keys: requestSchema.properties ? Object.keys(requestSchema.properties) : undefined,\n keysToOmit: requestSchema.properties\n ? Object.keys(requestSchema.properties).filter((key) => {\n const item = requestSchema.properties?.[key] as OasTypes.SchemaObject\n\n return item?.readOnly\n })\n : undefined,\n }\n : undefined,\n response: {\n name: resolveName(transformers.pascalCase(`${operation.getOperationId()} ${operation.method === 'get' ? 'queryResponse' : 'mutationResponse'}`)),\n description: operation.getResponseAsJSONSchema(responseStatusCode)?.at(0)?.description,\n operation,\n operationName: transformers.pascalCase(`${operation.getOperationId()}`),\n schema: responseSchema,\n statusCode: Number(responseStatusCode),\n keys: responseSchema?.properties ? Object.keys(responseSchema.properties) : undefined,\n keysToOmit: responseSchema?.properties\n ? Object.keys(responseSchema.properties).filter((key) => {\n const item = responseSchema.properties?.[key] as OasTypes.SchemaObject\n return item?.writeOnly\n })\n : undefined,\n },\n errors: statusCodes.filter((item) => item.statusCode?.toString().startsWith('4') || item.statusCode?.toString().startsWith('5')),\n statusCodes,\n }\n }\n\n get #methods() {\n return {\n get: this.get,\n post: this.post,\n patch: this.patch,\n put: this.put,\n delete: this.delete,\n head: undefined,\n options: undefined,\n trace: undefined,\n } as const\n }\n\n async build(): Promise<Array<KubbFile.File<TFileMeta>>> {\n const { oas } = this.context\n\n const paths = oas.getPaths()\n this.operationsByMethod = Object.entries(paths).reduce((acc, [path, method]) => {\n const methods = Object.keys(method) as HttpMethod[]\n\n methods.forEach((method) => {\n const operation = oas.operation(path, method)\n if (operation && this.#methods[method]) {\n const isExcluded = this.#isExcluded(operation, method)\n const isIncluded = this.context.include ? this.#isIncluded(operation, method) : true\n\n if (isIncluded && !isExcluded) {\n if (!acc[path]) {\n acc[path] = {} as OperationsByMethod['get']\n }\n acc[path] = {\n ...acc[path],\n [method]: {\n operation,\n schemas: this.getSchemas(operation),\n },\n } as OperationsByMethod['get']\n }\n }\n })\n\n return acc\n }, {} as OperationsByMethod)\n\n const promises = Object.keys(this.operationsByMethod).reduce((acc, path) => {\n const methods = this.operationsByMethod[path] ? (Object.keys(this.operationsByMethod[path]!) as HttpMethod[]) : []\n\n methods.forEach((method) => {\n const { operation } = this.operationsByMethod[path]?.[method]!\n const options = this.#getOptions(operation, method)\n const promiseMethod = this.#methods[method]?.call(this, operation, {\n ...this.options,\n ...options,\n })\n const promiseOperation = this.operation.call(this, operation, {\n ...this.options,\n ...options,\n })\n\n if (promiseMethod) {\n acc.push(promiseMethod)\n }\n if (promiseOperation) {\n acc.push(promiseOperation)\n }\n })\n\n return acc\n }, [] as OperationMethodResult<TFileMeta>[])\n\n const operations = Object.values(this.operationsByMethod).map((item) => Object.values(item).map((item) => item.operation))\n\n promises.push(this.all(operations.flat().filter(Boolean), this.operationsByMethod))\n\n const files = await Promise.all(promises)\n\n // using .flat because operationGenerator[method] can return a array of files or just one file\n return files.flat().filter(Boolean)\n }\n\n /**\n * Operation\n */\n async operation(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta> {\n return null\n }\n\n /**\n * GET\n */\n async get(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta> {\n return null\n }\n\n /**\n * POST\n */\n async post(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta> {\n return null\n }\n /**\n * PATCH\n */\n async patch(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta> {\n return null\n }\n\n /**\n * PUT\n */\n async put(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta> {\n return null\n }\n\n /**\n * DELETE\n */\n async delete(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta> {\n return null\n }\n\n /**\n * Combination of GET, POST, PATCH, PUT, DELETE\n */\n async all(operations: Operation[], paths: OperationsByMethod): OperationMethodResult<TFileMeta> {\n return null\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;;;ACAA;AAAA,OAAO,UAAU;AAEjB,SAAS,oBAAoB;AAC7B,SAAS,iBAAiB;AAWnB,IAAM,gBAAgB;AAEtB,IAAM,YAAY,aAAwB,CAAC,YAAY;AAC5D,QAAM;AAAA,IACJ,SAAS,EAAE,MAAM,WAAW,QAAQ,MAAM;AAAA,IAC1C,oBAAoB;AAAA,IACpB,kBAAkB;AAAA,IAClB,WAAW;AAAA,IACX,cAAc;AAAA,IACd;AAAA,IACA;AAAA,EACF,IAAI;AAEJ,QAAM,SAAS,OAAO,EAAE,QAAQ,QAAQ,cAAc,MAAuF;AAC3I,QAAI;AAEF,YAAM,MAAM,MAAM,gBAAgB,QAAQ,eAAe,QAAQ;AAEjE,UAAI,UAAU;AACZ,cAAM,IAAI,SAAS;AAAA,MACrB;AAEA,aAAO;AAAA,IACT,SAAS,GAAG;AACV,YAAM,QAAQ;AAEd,aAAO,KAAK,WAAW,OAAO,OAAO;AACrC,aAAO,gBAAgB,QAAQ,CAAC,GAAG,QAAQ;AAAA,IAC7C;AAAA,EACF;AAEA,SAAO;AAAA,IACL,MAAM;AAAA,IACN;AAAA,IAEA,MAAM;AACJ,YAAM,EAAE,QAAQ,OAAO,IAAI;AAE3B,aAAO;AAAA,QACL,OAAO,eAAe;AACpB,iBAAO,OAAO,EAAE,QAAQ,QAAQ,cAAc,CAAC;AAAA,QACjD;AAAA,QACA,MAAM,WAAW,EAAE,SAAS,IAAI,CAAC,GAAG;AAClC,gBAAM,MAAM,MAAM,KAAK,OAAO;AAC9B,iBAAO,WAAW,EAAE,KAAK,aAAa,SAAS,CAAC;AAAA,QAClD;AAAA,QAC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AAM,EAAE,UAAU,CAAC,EAAE,IAAI,KAAK;AAC9B,MAAI,UAAU;AAEd,UAAQ,QAAQ,CAAC,EAAE,SAAS,KAAK,MAAM;AACrC,QAAI,SAAS,SAAS,CAAC,SAAS;AAC9B,gBAAU,CAAC,CAAC,UAAU,QAAQ,EAAE,CAAC,GAAG,KAAK,MAAM,OAAO;AAAA,IACxD;AAEA,QAAI,SAAS,iBAAiB,CAAC,SAAS;AACtC,gBAAU,CAAC,CAAC,UAAU,eAAe,EAAE,MAAM,OAAO;AAAA,IACtD;AAEA,QAAI,SAAS,UAAU,CAAC,SAAS;AAC/B,gBAAU,CAAC,CAAC,UAAU,KAAK,MAAM,OAAO;AAAA,IAC1C;AAEA,QAAI,SAAS,YAAY,CAAC,SAAS;AACjC,gBAAU,CAAC,CAAC,OAAO,MAAM,OAAO;AAAA,IAClC;AAAA,EACF,CAAC;AAED,SAAO;AACT;AAiGI,cAAQ,WAAG;AACb,SAAO;AAAA,IACL,KAAK,KAAK;AAAA,IACV,MAAM,KAAK;AAAA,IACX,OAAO,KAAK;AAAA,IACZ,KAAK,KAAK;AAAA,IACV,QAAQ,KAAK;AAAA,IACb,MAAM;AAAA,IACN,SAAS;AAAA,IACT,OAAO;AAAA,EACT;AACF;;;AF1MF,IAAM,sBAAsB;AAE5B,IAAO,cAAQ;","names":["path","path","method","item"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/OperationGenerator.ts","../src/plugin.ts","../src/parser.tsx"],"sourcesContent":["export type {\n GetOperationGeneratorOptions,\n OperationMethodResult,\n} from './OperationGenerator.ts'\nexport { OperationGenerator } from './OperationGenerator.ts'\nexport { pluginOas, pluginOasName } from './plugin.ts'\nexport type {\n GetSchemaGeneratorOptions,\n SchemaGeneratorBuildOptions,\n SchemaGeneratorOptions,\n} from './SchemaGenerator.ts'\nexport type { SchemaMethodResult } from './SchemaGenerator.ts'\nexport { SchemaGenerator } from './SchemaGenerator.ts'\nexport type {\n Schema,\n SchemaKeyword,\n SchemaKeywordBase,\n SchemaKeywordMapper,\n SchemaMapper,\n} from './SchemaMapper.ts'\nexport { isKeyword, schemaKeywords } from './SchemaMapper.ts'\nexport type * from './types.ts'\nexport { createParser, createReactParser } from './parser.tsx'\nexport type { ParserReactOptions } from './parser.tsx'\nexport type { Parser, ParserOptions } from './parser.tsx'\n","import { type FileMetaBase, Generator } from '@kubb/core'\nimport transformers from '@kubb/core/transformers'\n\nimport type { PluginFactoryOptions, PluginManager } from '@kubb/core'\nimport type * as KubbFile from '@kubb/fs/types'\n\nimport type { Plugin } from '@kubb/core'\nimport type { HttpMethod, Oas, OasTypes, Operation, contentType } from '@kubb/oas'\nimport type { Exclude, Include, OperationSchemas, OperationsByMethod, Override } from './types.ts'\nimport type { Parser } from './parser.tsx'\n\nexport type GetOperationGeneratorOptions<T extends OperationGenerator<any, any, any>> = T extends OperationGenerator<infer Options, any, any> ? Options : never\n\nexport type OperationMethodResult<TFileMeta extends FileMetaBase> = Promise<KubbFile.File<TFileMeta> | Array<KubbFile.File<TFileMeta>> | null>\n\ntype Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {\n oas: Oas\n exclude: Array<Exclude> | undefined\n include: Array<Include> | undefined\n override: Array<Override<TOptions>> | undefined\n contentType: contentType | undefined\n pluginManager: PluginManager\n /**\n * Current plugin\n */\n plugin: Plugin<TPluginOptions>\n mode: KubbFile.Mode\n}\n\nexport class OperationGenerator<\n TOptions = unknown,\n TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions,\n TFileMeta extends FileMetaBase = FileMetaBase,\n> extends Generator<TOptions, Context<TOptions, TPluginOptions>> {\n #operationsByMethod: OperationsByMethod = {}\n get operationsByMethod(): OperationsByMethod {\n return this.#operationsByMethod\n }\n\n set operationsByMethod(paths: OperationsByMethod) {\n this.#operationsByMethod = paths\n }\n\n #getOptions(operation: Operation, method: HttpMethod): Partial<TOptions> {\n const { override = [] } = this.context\n\n return (\n override.find(({ pattern, type }) => {\n if (type === 'tag') {\n return !!operation.getTags()[0]?.name.match(pattern)\n }\n\n if (type === 'operationId') {\n return !!operation.getOperationId().match(pattern)\n }\n\n if (type === 'path') {\n return !!operation.path.match(pattern)\n }\n\n if (type === 'method') {\n return !!method.match(pattern)\n }\n\n return false\n })?.options || {}\n )\n }\n\n /**\n *\n * @deprecated\n */\n #isExcluded(operation: Operation, method: HttpMethod): boolean {\n const { exclude = [] } = this.context\n let matched = false\n\n exclude.forEach(({ pattern, type }) => {\n if (type === 'tag' && !matched) {\n matched = !!operation.getTags()[0]?.name.match(pattern)\n }\n\n if (type === 'operationId' && !matched) {\n matched = !!operation.getOperationId().match(pattern)\n }\n\n if (type === 'path' && !matched) {\n matched = !!operation.path.match(pattern)\n }\n\n if (type === 'method' && !matched) {\n matched = !!method.match(pattern)\n }\n })\n\n return matched\n }\n\n /**\n *\n * @deprecated\n */\n #isIncluded(operation: Operation, method: HttpMethod): boolean {\n const { include = [] } = this.context\n let matched = false\n\n include.forEach(({ pattern, type }) => {\n if (type === 'tag' && !matched) {\n matched = !!operation.getTags()[0]?.name.match(pattern)\n }\n\n if (type === 'operationId' && !matched) {\n matched = !!operation.getOperationId().match(pattern)\n }\n\n if (type === 'path' && !matched) {\n matched = !!operation.path.match(pattern)\n }\n\n if (type === 'method' && !matched) {\n matched = !!method.match(pattern)\n }\n })\n\n return matched\n }\n\n getSchemas(\n operation: Operation,\n {\n forStatusCode,\n resolveName = (name) => name,\n }: {\n forStatusCode?: string | number\n resolveName?: (name: string) => string\n } = {},\n ): OperationSchemas {\n const pathParamsSchema = this.context.oas.getParametersSchema(operation, 'path')\n const queryParamsSchema = this.context.oas.getParametersSchema(operation, 'query')\n const headerParamsSchema = this.context.oas.getParametersSchema(operation, 'header')\n const requestSchema = this.context.oas.getRequestSchema(operation)\n const responseStatusCode =\n forStatusCode || (operation.schema.responses && Object.keys(operation.schema.responses).find((key) => key.startsWith('2'))) || 200\n const responseSchema = this.context.oas.getResponseSchema(operation, responseStatusCode)\n const statusCodes = operation.getResponseStatusCodes().map((statusCode) => {\n let name = statusCode\n if (name === 'default') {\n name = 'error'\n }\n\n const schema = this.context.oas.getResponseSchema(operation, statusCode)\n\n return {\n name: resolveName(transformers.pascalCase(`${operation.getOperationId()} ${name}`)),\n description: (operation.getResponseByStatusCode(statusCode) as OasTypes.ResponseObject)?.description,\n schema,\n operation,\n operationName: transformers.pascalCase(`${operation.getOperationId()}`),\n statusCode: name === 'error' ? undefined : Number(statusCode),\n keys: schema?.properties ? Object.keys(schema.properties) : undefined,\n }\n })\n\n return {\n pathParams: pathParamsSchema\n ? {\n name: resolveName(transformers.pascalCase(`${operation.getOperationId()} PathParams`)),\n operation,\n operationName: transformers.pascalCase(`${operation.getOperationId()}`),\n schema: pathParamsSchema,\n keys: pathParamsSchema.properties ? Object.keys(pathParamsSchema.properties) : undefined,\n }\n : undefined,\n queryParams: queryParamsSchema\n ? {\n name: resolveName(transformers.pascalCase(`${operation.getOperationId()} QueryParams`)),\n operation,\n operationName: transformers.pascalCase(`${operation.getOperationId()}`),\n schema: queryParamsSchema,\n keys: queryParamsSchema.properties ? Object.keys(queryParamsSchema.properties) : [],\n }\n : undefined,\n headerParams: headerParamsSchema\n ? {\n name: resolveName(transformers.pascalCase(`${operation.getOperationId()} HeaderParams`)),\n operation,\n operationName: transformers.pascalCase(`${operation.getOperationId()}`),\n schema: headerParamsSchema,\n keys: headerParamsSchema.properties ? Object.keys(headerParamsSchema.properties) : undefined,\n }\n : undefined,\n request: requestSchema\n ? {\n name: resolveName(transformers.pascalCase(`${operation.getOperationId()} ${operation.method === 'get' ? 'queryRequest' : 'mutationRequest'}`)),\n description: (operation.schema.requestBody as OasTypes.RequestBodyObject)?.description,\n operation,\n operationName: transformers.pascalCase(`${operation.getOperationId()}`),\n schema: requestSchema,\n keys: requestSchema.properties ? Object.keys(requestSchema.properties) : undefined,\n keysToOmit: requestSchema.properties\n ? Object.keys(requestSchema.properties).filter((key) => {\n const item = requestSchema.properties?.[key] as OasTypes.SchemaObject\n\n return item?.readOnly\n })\n : undefined,\n }\n : undefined,\n response: {\n name: resolveName(transformers.pascalCase(`${operation.getOperationId()} ${operation.method === 'get' ? 'queryResponse' : 'mutationResponse'}`)),\n description: operation.getResponseAsJSONSchema(responseStatusCode)?.at(0)?.description,\n operation,\n operationName: transformers.pascalCase(`${operation.getOperationId()}`),\n schema: responseSchema,\n statusCode: Number(responseStatusCode),\n keys: responseSchema?.properties ? Object.keys(responseSchema.properties) : undefined,\n keysToOmit: responseSchema?.properties\n ? Object.keys(responseSchema.properties).filter((key) => {\n const item = responseSchema.properties?.[key] as OasTypes.SchemaObject\n return item?.writeOnly\n })\n : undefined,\n },\n errors: statusCodes.filter((item) => item.statusCode?.toString().startsWith('4') || item.statusCode?.toString().startsWith('5')),\n statusCodes,\n }\n }\n\n async build(...parsers: Array<Parser<Extract<TOptions, PluginFactoryOptions>>>): Promise<Array<KubbFile.File<TFileMeta>>> {\n const { oas } = this.context\n\n const paths = oas.getPaths()\n this.operationsByMethod = Object.entries(paths).reduce((acc, [path, method]) => {\n const methods = Object.keys(method) as HttpMethod[]\n\n methods.forEach((method) => {\n const operation = oas.operation(path, method)\n if (operation) {\n const isExcluded = this.#isExcluded(operation, method)\n const isIncluded = this.context.include ? this.#isIncluded(operation, method) : true\n\n if (isIncluded && !isExcluded) {\n if (!acc[path]) {\n acc[path] = {} as OperationsByMethod['get']\n }\n acc[path] = {\n ...acc[path],\n [method]: {\n operation,\n schemas: this.getSchemas(operation),\n },\n } as OperationsByMethod['get']\n }\n }\n })\n\n return acc\n }, {} as OperationsByMethod)\n\n const promises = Object.keys(this.operationsByMethod).reduce((acc, path) => {\n const methods = this.operationsByMethod[path] ? (Object.keys(this.operationsByMethod[path]!) as HttpMethod[]) : []\n\n methods.forEach((method) => {\n const { operation } = this.operationsByMethod[path]?.[method]!\n const options = this.#getOptions(operation, method)\n\n const methodToCall = this[method as keyof typeof this] as any\n\n if (typeof methodToCall === 'function') {\n const promiseMethod = methodToCall?.call(this, operation, {\n ...this.options,\n ...options,\n })\n\n if (promiseMethod) {\n acc.push(promiseMethod)\n }\n }\n\n const promiseOperation = this.operation.call(this, operation, {\n ...this.options,\n ...options,\n })\n\n if (promiseOperation) {\n acc.push(promiseOperation)\n }\n\n parsers?.forEach((parser) => {\n const promise = parser.operation?.({\n instance: this,\n operation,\n options: {\n ...this.options,\n ...options,\n },\n } as any) as Promise<Array<KubbFile.File<TFileMeta>>>\n\n if (promise) {\n acc.push(promise)\n }\n })\n })\n\n return acc\n }, [] as OperationMethodResult<TFileMeta>[])\n\n const operations = Object.values(this.operationsByMethod).map((item) => Object.values(item).map((item) => item.operation))\n\n promises.push(this.all(operations.flat().filter(Boolean), this.operationsByMethod))\n\n parsers?.forEach((parser) => {\n const promise = parser.operations?.({\n instance: this,\n operations: operations.flat().filter(Boolean),\n operationsByMethod: this.operationsByMethod,\n options: this.options,\n } as any) as Promise<Array<KubbFile.File<TFileMeta>>>\n\n if (promise) {\n promises.push(promise)\n }\n })\n\n const files = await Promise.all(promises)\n\n // using .flat because operationGenerator[method] can return a array of files or just one file\n return files.flat().filter(Boolean)\n }\n\n /**\n * Operation\n */\n async operation(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta> {\n return []\n }\n\n /**\n * GET\n */\n async get(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta> {\n return []\n }\n\n /**\n * POST\n */\n async post(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta> {\n return []\n }\n /**\n * PATCH\n */\n async patch(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta> {\n return []\n }\n\n /**\n * PUT\n */\n async put(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta> {\n return []\n }\n\n /**\n * DELETE\n */\n async delete(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta> {\n return []\n }\n\n /**\n * Combination of GET, POST, PATCH, PUT, DELETE\n */\n async all(operations: Operation[], paths: OperationsByMethod): OperationMethodResult<TFileMeta> {\n return []\n }\n}\n","import path from 'node:path'\n\nimport { createPlugin } from '@kubb/core'\nimport { camelCase } from '@kubb/core/transformers'\n\nimport { getSchemas } from './utils/getSchemas.ts'\n\nimport type { Config } from '@kubb/core'\nimport type { Logger } from '@kubb/core/logger'\nimport type { Oas, OasTypes } from '@kubb/oas'\nimport type { FormatOptions } from '@kubb/oas/parser'\nimport type { PluginOas } from './types.ts'\nimport { parseFromConfig } from './utils/parseFromConfig.ts'\n\nexport const pluginOasName = 'plugin-oas' satisfies PluginOas['name']\n\nexport const pluginOas = createPlugin<PluginOas>((options) => {\n const {\n output = { path: 'schemas', export: false },\n experimentalFilter: filter,\n experimentalSort: sort,\n validate = true,\n serverIndex = 0,\n contentType,\n oasClass,\n } = options\n\n const getOas = async ({ config, logger, formatOptions }: { config: Config; logger: Logger; formatOptions?: FormatOptions }): Promise<Oas> => {\n try {\n // needs to be in a different variable or the catch here will not work(return of a promise instead)\n const oas = await parseFromConfig(config, formatOptions, oasClass)\n\n if (validate) {\n await oas.valdiate()\n }\n\n return oas\n } catch (e) {\n const error = e as Error\n\n logger.emit('warning', error?.message)\n return parseFromConfig(config, {}, oasClass)\n }\n }\n\n return {\n name: pluginOasName,\n options,\n context() {\n const { config, logger } = this\n\n return {\n getOas(formatOptions) {\n return getOas({ config, logger, formatOptions })\n },\n async getSchemas({ includes } = {}) {\n const oas = await this.getOas()\n return getSchemas({ oas, contentType, includes })\n },\n async getBaseURL() {\n const oasInstance = await this.getOas()\n const baseURL = oasInstance.api.servers?.at(serverIndex)?.url\n return baseURL\n },\n contentType,\n }\n },\n resolvePath(baseName) {\n if (output === false) {\n return undefined\n }\n\n const root = path.resolve(this.config.root, this.config.output.path)\n\n return path.resolve(root, output.path, baseName)\n },\n resolveName(name, type) {\n return camelCase(name, { isFile: type === 'file' })\n },\n async buildStart() {\n if (!output) {\n return\n }\n\n const oas = await getOas({\n config: this.config,\n logger: this.logger,\n formatOptions: {\n filterSet: filter,\n sortSet: sort,\n },\n })\n await oas.dereference()\n const schemas = getSchemas({ oas, contentType })\n\n const mapSchema = async ([name, schema]: [string, OasTypes.SchemaObject]) => {\n const resolvedPath = this.resolvePath({\n baseName: `${name}.json`,\n pluginKey: this.plugin.key,\n })\n\n const resvoledFileName = this.resolveName({\n name: `${name}.json`,\n pluginKey: [pluginOasName],\n type: 'file',\n }) as `${string}.json`\n\n if (!resolvedPath) {\n return\n }\n\n await this.addFile({\n path: resolvedPath,\n baseName: resvoledFileName,\n source: JSON.stringify(schema),\n meta: {\n pluginKey: this.plugin.key,\n },\n })\n }\n\n const promises = Object.entries(schemas).map(mapSchema)\n await Promise.all(promises)\n },\n }\n})\n","import type { PluginFactoryOptions } from '@kubb/core'\nimport type { Operation, SchemaObject } from '@kubb/oas'\nimport { App, createRoot, type KubbNode } from '@kubb/react'\nimport type * as KubbFile from '@kubb/fs/types'\nimport type { OperationsByMethod } from './types.ts'\nimport { Oas } from '@kubb/plugin-oas/components'\nimport type { OperationGenerator } from './OperationGenerator.ts'\nimport type { SchemaGenerator, SchemaGeneratorOptions } from './SchemaGenerator.ts'\n\ntype OperationsProps<TOptions extends PluginFactoryOptions> = {\n instance: Omit<OperationGenerator<TOptions>, 'build'>\n options: TOptions['resolvedOptions']\n operations: Array<Operation>\n operationsByMethod: OperationsByMethod\n}\n\ntype OperationProps<TOptions extends PluginFactoryOptions> = {\n instance: Omit<OperationGenerator<TOptions>, 'build'>\n options: TOptions['resolvedOptions']\n operation: Operation\n}\n\ntype SchemaProps<TOptions extends PluginFactoryOptions> = {\n instance: Omit<SchemaGenerator<SchemaGeneratorOptions, TOptions>, 'build'>\n name: string\n schema: SchemaObject\n options: TOptions['resolvedOptions']\n}\n\nexport type ParserOptions<TOptions extends PluginFactoryOptions> = {\n name: string\n operations?: (props: OperationsProps<TOptions>) => Promise<KubbFile.File[]>\n operation?: (props: OperationProps<TOptions>) => Promise<KubbFile.File[]>\n schema?: (props: SchemaProps<TOptions>) => Promise<KubbFile.File[]>\n}\n\nexport type Parser<TOptions extends PluginFactoryOptions> = ParserOptions<TOptions>\n\nexport function createParser<TOptions extends PluginFactoryOptions>(parseOptions: ParserOptions<TOptions>): Parser<TOptions> {\n return parseOptions\n}\n\nexport type ParserReactOptions<TOptions extends PluginFactoryOptions> = {\n name: string\n Operations?: (props: OperationsProps<TOptions>) => KubbNode\n Operation?: (props: OperationProps<TOptions>) => KubbNode\n Schema?: (props: SchemaProps<TOptions>) => KubbNode\n}\n\nexport function createReactParser<TOptions extends PluginFactoryOptions>(parseOptions: ParserReactOptions<TOptions>): Parser<TOptions> {\n return {\n ...parseOptions,\n async operations({ instance, options, operations, operationsByMethod }) {\n if (!parseOptions.Operations) {\n return []\n }\n\n const { pluginManager, oas, plugin, mode } = instance.context\n const root = createRoot({\n logger: pluginManager.logger,\n })\n\n root.render(\n <App pluginManager={pluginManager} plugin={plugin} mode={mode}>\n <Oas oas={oas} operations={operations} generator={instance}>\n <parseOptions.Operations operations={operations} instance={instance} operationsByMethod={operationsByMethod} options={options} />\n </Oas>\n </App>,\n )\n\n return root.files\n },\n async operation({ instance, operation, options }) {\n if (!parseOptions.Operation) {\n return []\n }\n\n const { pluginManager, oas, plugin, mode } = instance.context\n const root = createRoot({\n logger: pluginManager.logger,\n })\n\n root.render(\n <App pluginManager={pluginManager} plugin={{ ...plugin, options }} mode={mode}>\n <Oas oas={oas} operations={[operation]} generator={instance}>\n <Oas.Operation operation={operation}>\n <parseOptions.Operation operation={operation} options={options} instance={instance} />\n </Oas.Operation>\n </Oas>\n </App>,\n )\n\n return root.files\n },\n async schema({ instance, schema, name, options }) {\n if (!parseOptions.Schema) {\n return []\n }\n\n const { pluginManager, oas, plugin, mode } = instance.context\n const root = createRoot({\n logger: pluginManager.logger,\n })\n\n const tree = instance.parse({ schema, name })\n\n root.render(\n <App pluginManager={pluginManager} plugin={{ ...plugin, options }} mode={mode}>\n <Oas oas={oas}>\n <Oas.Schema name={name} value={schema} tree={tree}>\n <parseOptions.Schema schema={schema} options={options} instance={instance} name={name} />\n </Oas.Schema>\n </Oas>\n </App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AAEA,aAAO,KAAK;AAAA,IACd;AAAA,EACF;AACF;","names":["path","method","item"]}
|
|
@@ -140,4 +140,4 @@ type Override<TOptions> = (ByTag | ByOperationId | ByPath | ByMethod | BySchemaN
|
|
|
140
140
|
};
|
|
141
141
|
type PluginOas = PluginFactoryOptions<'plugin-oas', Options, Options, API, never>;
|
|
142
142
|
|
|
143
|
-
export { type API as A, type Exclude as E, type GetSchemasProps as G, type Include as I, type Options as O, type PluginOas as P, type
|
|
143
|
+
export { type API as A, type Exclude as E, type GetSchemasProps as G, type Include as I, type Options as O, type PluginOas as P, type ResolvePathOptions as R, type Ref as a, type Refs as b, type Resolver as c, type OperationSchema as d, type OperationSchemas as e, type OperationsByMethod as f, type Override as g, getSchemas as h };
|
|
@@ -140,4 +140,4 @@ type Override<TOptions> = (ByTag | ByOperationId | ByPath | ByMethod | BySchemaN
|
|
|
140
140
|
};
|
|
141
141
|
type PluginOas = PluginFactoryOptions<'plugin-oas', Options, Options, API, never>;
|
|
142
142
|
|
|
143
|
-
export { type API as A, type Exclude as E, type GetSchemasProps as G, type Include as I, type Options as O, type PluginOas as P, type
|
|
143
|
+
export { type API as A, type Exclude as E, type GetSchemasProps as G, type Include as I, type Options as O, type PluginOas as P, type ResolvePathOptions as R, type Ref as a, type Refs as b, type Resolver as c, type OperationSchema as d, type OperationSchemas as e, type OperationsByMethod as f, type Override as g, getSchemas as h };
|
package/dist/utils.d.cts
CHANGED
|
@@ -4,8 +4,8 @@ import { Logger } from '@kubb/core/logger';
|
|
|
4
4
|
import * as KubbFile from '@kubb/fs/types';
|
|
5
5
|
import { FunctionParamsAST } from '@kubb/core/utils';
|
|
6
6
|
import { Params } from '@kubb/react';
|
|
7
|
-
import {
|
|
8
|
-
export { G as GetSchemasProps, h as getSchemas } from './types-
|
|
7
|
+
import { d as OperationSchema, b as Refs } from './types-C2RXaY0_.cjs';
|
|
8
|
+
export { G as GetSchemasProps, h as getSchemas } from './types-C2RXaY0_.cjs';
|
|
9
9
|
import { FormatOptions } from '@kubb/oas/parser';
|
|
10
10
|
|
|
11
11
|
declare function getComments(operation: Operation): string[];
|
package/dist/utils.d.ts
CHANGED
|
@@ -4,8 +4,8 @@ import { Logger } from '@kubb/core/logger';
|
|
|
4
4
|
import * as KubbFile from '@kubb/fs/types';
|
|
5
5
|
import { FunctionParamsAST } from '@kubb/core/utils';
|
|
6
6
|
import { Params } from '@kubb/react';
|
|
7
|
-
import {
|
|
8
|
-
export { G as GetSchemasProps, h as getSchemas } from './types-
|
|
7
|
+
import { d as OperationSchema, b as Refs } from './types-C2RXaY0_.js';
|
|
8
|
+
export { G as GetSchemasProps, h as getSchemas } from './types-C2RXaY0_.js';
|
|
9
9
|
import { FormatOptions } from '@kubb/oas/parser';
|
|
10
10
|
|
|
11
11
|
declare function getComments(operation: Operation): string[];
|